Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

generatePkcePair() cannot run in browser environment #53

Open
kschiew opened this issue May 23, 2023 · 1 comment
Open

generatePkcePair() cannot run in browser environment #53

kschiew opened this issue May 23, 2023 · 1 comment
Assignees

Comments

@kschiew
Copy link

kschiew commented May 23, 2023

Describe the bug
openid-client is a Nodejs library that is not mean to run in browser environments. Since it is technically possible that RP's generate their PKCE pairs on the frontend, our implementation of PKCE pair generation should not depend on openid-client.

To Reproduce

  1. npm i @opengovsg/sgid-client in a React project.
  2. import { generatePkcePair() } from @opengovsg/sgid-client in a .jsx/.tsx file.
  3. Run const { codeVerifier, codeChallenge } = generatePkcePair()
  4. App crashes, with the following error message in console:
    image

Expected behavior
generatePkcePair() should run successfully and return <codeChallenge, codeVerifier> pair.

@kschiew
Copy link
Author

kschiew commented May 25, 2023

As discussed in #52, the team currently does not endorse maintaining session details on the frontend, therefore as of now the team does not plan to support PKCE pair generation in the browser environment. If the user decides to do session management on frontend regardless, refer to https://www.npmjs.com/package/pkce-challenge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant