@@ -63,14 +63,14 @@ export const defaultLoginAsync =
63
63
) ;
64
64
let storage ;
65
65
if ( serviceWorker ) {
66
- serviceWorker . setLoginParams ( { callbackPath : url , extras : originExtras } ) ;
66
+ serviceWorker . setLoginParams ( { callbackPath : url , extras : originExtras , scope : scope } ) ;
67
67
await serviceWorker . initAsync ( oidcServerConfiguration , 'loginAsync' , configuration ) ;
68
68
await serviceWorker . setNonceAsync ( nonce ) ;
69
69
serviceWorker . startKeepAliveServiceWorker ( ) ;
70
70
storage = serviceWorker ;
71
71
} else {
72
72
const session = initSession ( configurationName , configuration . storage ?? sessionStorage ) ;
73
- session . setLoginParams ( { callbackPath : url , extras : originExtras } ) ;
73
+ session . setLoginParams ( { callbackPath : url , extras : originExtras , scope : scope } ) ;
74
74
await session . setNonceAsync ( nonce ) ;
75
75
storage = session ;
76
76
}
@@ -139,24 +139,24 @@ export const loginCallbackAsync =
139
139
storage = session ;
140
140
}
141
141
142
- const params = getParseQueryStringFromLocation ( href ) ;
143
-
144
- if ( params . error || params . error_description ) {
145
- throw new Error ( `Error from OIDC server: ${ params . error } - ${ params . error_description } ` ) ;
142
+ if ( queryParams . error || queryParams . error_description ) {
143
+ throw new Error (
144
+ `Error from OIDC server: ${ queryParams . error } - ${ queryParams . error_description } ` ,
145
+ ) ;
146
146
}
147
147
148
- if ( params . iss && params . iss !== oidcServerConfiguration . issuer ) {
148
+ if ( queryParams . iss && queryParams . iss !== oidcServerConfiguration . issuer ) {
149
149
console . error ( ) ;
150
150
throw new Error (
151
- `Issuer not valid (expected: ${ oidcServerConfiguration . issuer } , received: ${ params . iss } )` ,
151
+ `Issuer not valid (expected: ${ oidcServerConfiguration . issuer } , received: ${ queryParams . iss } )` ,
152
152
) ;
153
153
}
154
- if ( params . state && params . state !== state ) {
155
- throw new Error ( `State not valid (expected: ${ state } , received: ${ params . state } )` ) ;
154
+ if ( queryParams . state && queryParams . state !== state ) {
155
+ throw new Error ( `State not valid (expected: ${ state } , received: ${ queryParams . state } )` ) ;
156
156
}
157
157
158
158
const data = {
159
- code : params . code ,
159
+ code : queryParams . code ,
160
160
grant_type : 'authorization_code' ,
161
161
client_id : configuration . client_id ,
162
162
redirect_uri : redirectUri ,
@@ -269,6 +269,8 @@ export const loginCallbackAsync =
269
269
tokens : formattedTokens ,
270
270
state : 'request.state' ,
271
271
callbackPath : loginParams . callbackPath ,
272
+ scope : queryParams . scope ,
273
+ extras : loginParams . extras ,
272
274
} ;
273
275
} catch ( exception ) {
274
276
console . error ( exception ) ;
0 commit comments