Commit 3010015 1 parent 12bce7d commit 3010015 Copy full SHA for 3010015
File tree 2 files changed +13
-5
lines changed
2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ export type LoginMethodParams = Pick<
17
17
| "orgName"
18
18
| "connectionId"
19
19
| "redirectURL"
20
- | "hasSuccessPage"
20
+ | "hasSuccessPage"
21
21
> ;
22
22
23
23
export type LoginOptions = {
@@ -105,6 +105,10 @@ export type LoginOptions = {
105
105
* Whether to show the success screen at the end of the flow, this is most useful when the callback is not a webpage.
106
106
*/
107
107
hasSuccessPage ?: boolean ;
108
+ /**
109
+ * Single use code to prevent replay attacks
110
+ */
111
+ nonce ?: string ;
108
112
} ;
109
113
110
114
export enum IssuerRouteTypes {
Original file line number Diff line number Diff line change @@ -22,11 +22,15 @@ export const generateAuthUrl = (
22
22
...mapLoginMethodParamsForUrl ( options ) ,
23
23
} ;
24
24
25
- const generatedState = generateRandomString ( 32 ) ;
26
- const generatedNonce = generateRandomString ( 16 ) ;
25
+ if ( ! options . state ) {
26
+ options . state = generateRandomString ( 32 ) ;
27
+ }
28
+ searchParams [ "state" ] = options . state ;
27
29
28
- searchParams [ "state" ] = options . state || generatedState ;
29
- searchParams [ "nonce" ] = generatedNonce ;
30
+ if ( ! options . nonce ) {
31
+ options . nonce = generateRandomString ( 16 ) ;
32
+ }
33
+ searchParams [ "nonce" ] = options . nonce ;
30
34
31
35
if ( options . codeChallenge ) {
32
36
searchParams [ "code_challenge" ] = options . codeChallenge ;
You can’t perform that action at this time.
0 commit comments