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

Nonce API is inflexible and inaccurately typed #61

Closed
mantariksh opened this issue Jul 28, 2023 · 0 comments · Fixed by #62
Closed

Nonce API is inflexible and inaccurately typed #61

mantariksh opened this issue Jul 28, 2023 · 0 comments · Fixed by #62
Assignees

Comments

@mantariksh
Copy link
Contributor

tl;dr there are 2 problems:

  1. No util function to generate nonce
  2. Nonce returned from authorizationUrl is inconveniently typed as string | undefined

I want to implement the following flow for generating the authorisation URL:

  1. Controller calls a service to generate required params for authorisation URL (code verifier/challenge, nonce)
  2. Controller calls another service to generate authorisation URL with the params generated in step 1
  3. Controller saves code verifier and nonce in a cookie

But in step 1, there is no API to generate a nonce separately from auth URL. Workarounds are either:

  1. Call .authorizationUrl just to get a random nonce. But this returns a nonce of type string | undefined, which forces me to write unnecessary null checks like return nonce ?? ''
  2. Call generateCodeVerifier because it uses the same underlying function to generate the nonce. But this requires knowledge of sgID client internals.

Suggestion: expose a separate util function to generate a nonce, as with code verifier and code 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