-
Notifications
You must be signed in to change notification settings - Fork 8
Add custom scopes in CreateAuthURL via PKCEConfig #20
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
base: develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -5,7 +5,6 @@ import qs from "qs"; | |
| const LOCALSTORE_AUTH_URL_KEY = "auth-url"; | ||
| const LOCALSTORE_CODE_VERIFIER_KEY = "code-verifier"; | ||
|
|
||
| const QUERYPARAM_SCOPE = "scope=openid"; | ||
| const QUERYPARAM_RESPONSE_TYPE = "response_type=code"; | ||
| const QUERYPARAM_CODE_CHALLENGE_METHOD = "code_challenge_method=S256"; | ||
|
|
||
|
|
@@ -18,7 +17,8 @@ const MISSING_CONFIG_MESSAGE = "The PKCE Client is Missing Configuration Paramet | |
|
|
||
| interface PKCEConfig { | ||
| redirectURL: string, | ||
| clientID: string | ||
| clientID: string, | ||
| scopes?: Array<string>, | ||
| } | ||
|
|
||
| interface AccessToken { | ||
|
|
@@ -64,13 +64,13 @@ export default class PKCE { | |
| let codeVerifier = this._createCodeVerifier( 50 ); | ||
| let codeChallenge = await this._createCodeChallenge( codeVerifier ); | ||
|
|
||
| let { clientID, redirectURL } = this.configuration | ||
| let { clientID, redirectURL, scopes } = this.configuration | ||
| if(overrideRedirectURL) | ||
| redirectURL = overrideRedirectURL; | ||
|
|
||
| let queryParams = [ | ||
| `code_challenge=${codeChallenge}`, `client_id=${clientID}`, `redirect_uri=${redirectURL}`, | ||
| QUERYPARAM_CODE_CHALLENGE_METHOD, QUERYPARAM_RESPONSE_TYPE, QUERYPARAM_SCOPE | ||
| QUERYPARAM_CODE_CHALLENGE_METHOD, QUERYPARAM_RESPONSE_TYPE, `scope=openid${scopes ? ` ${scopes.join(" ")}` : ''}` | ||
|
||
| ]; | ||
|
|
||
| localStorage.setItem(LOCALSTORE_CODE_VERIFIER_KEY, codeVerifier); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The
scopesproperty lacks documentation explaining its purpose and that 'openid' is automatically included. Add a JSDoc comment to clarify that this array should contain additional scopes beyond 'openid', which is always present by default.