@designsystemsinternational/react-github-admin-proxy

1.0.0 • Public • Published

React GitHub Admin Proxy

This small proxy function is to be used alongside @designsystemsinternational/react-github-admin as a proxy for the OAuth login call. We need this proxy in order to hide the GitHub app secret, and this is impossible on static sites.

This package has only a single function export with the following signature:

authorizeGitHub(client, code);
  • client is the GitHub app client ID
  • code is the auth code returned from the first step of the GitHub OAuth flow

The function expects an environment variable to be present where the key is set to the GitHub app client ID and the secret is set to the GitHub app client secret. This makes it possible to use this function for more than a single GitHub app.

Deploying

This package has on purpose no server code. It's a simple function with a single dependency, so you can deploy it to AWS Lambda, Netlify cloud functions, Heroku, or any other service.

AWS Lambda

This is the code required to deploy this package to an AWS Lambda:

const proxyGitHub = require("@designsystemsinternational/react-github-admin-proxy");

const handler = async (event) => {
  const payload = JSON.parse(event.body);
  try {
    const res = await proxyGitHub(payload.client, payload.code);
    return res;
  } catch (e) {
    return {
      error: e.toString(),
    };
  }
};

module.exports = {
  handler,
};

Readme

Keywords

none

Package Sidebar

Install

npm i @designsystemsinternational/react-github-admin-proxy

Weekly Downloads

0

Version

1.0.0

License

none

Unpacked Size

2.62 kB

Total Files

4

Last publish

Collaborators

  • lnolte
  • runemadsen
  • bravomartin
  • ejsandoval
  • fdoflorenzano