@@ -255,6 +255,18 @@ export class KeycloakClient implements KeycloakInstance {
255
255
const nonce = createUUID ( ) ;
256
256
257
257
const redirectUri = this . adapter ! . redirectUri ( options ) ;
258
+ const {
259
+ scope : scopeOption ,
260
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
261
+ redirectUri : redirectUriOption ,
262
+ prompt,
263
+ action,
264
+ maxAge,
265
+ loginHint,
266
+ idpHint,
267
+ locale,
268
+ ...rest
269
+ } = options ?? { } ;
258
270
259
271
let codeVerifier ;
260
272
let pkceChallenge ;
@@ -272,18 +284,18 @@ export class KeycloakClient implements KeycloakInstance {
272
284
} ;
273
285
274
286
let scope ;
275
- if ( options ?. scope ) {
276
- if ( options . scope . indexOf ( 'openid' ) !== - 1 ) {
277
- scope = options . scope ;
287
+ if ( scopeOption ) {
288
+ if ( scopeOption . indexOf ( 'openid' ) !== - 1 ) {
289
+ scope = scopeOption ;
278
290
} else {
279
- scope = 'openid ' + options . scope ;
291
+ scope = 'openid ' + scopeOption ;
280
292
}
281
293
} else {
282
294
scope = 'openid' ;
283
295
}
284
296
285
297
const baseUrl =
286
- options && options . action === 'register'
298
+ action === 'register'
287
299
? this . endpoints ! . register ( )
288
300
: this . endpoints ! . authorize ( ) ;
289
301
@@ -299,28 +311,28 @@ export class KeycloakClient implements KeycloakInstance {
299
311
params . set ( 'nonce' , nonce ) ;
300
312
}
301
313
302
- if ( options ?. prompt ) {
303
- params . set ( 'prompt' , options . prompt ) ;
314
+ if ( prompt ) {
315
+ params . set ( 'prompt' , prompt ) ;
304
316
}
305
317
306
- if ( options ?. maxAge ) {
307
- params . set ( 'max_age' , `${ options . maxAge } ` ) ;
318
+ if ( maxAge ) {
319
+ params . set ( 'max_age' , `${ maxAge } ` ) ;
308
320
}
309
321
310
- if ( options ?. loginHint ) {
311
- params . set ( 'login_hint' , options . loginHint ) ;
322
+ if ( loginHint ) {
323
+ params . set ( 'login_hint' , loginHint ) ;
312
324
}
313
325
314
- if ( options ?. idpHint ) {
315
- params . set ( 'kc_idp_hint' , options . idpHint ) ;
326
+ if ( idpHint ) {
327
+ params . set ( 'kc_idp_hint' , idpHint ) ;
316
328
}
317
329
318
- if ( options ?. action && options ?. action !== 'register' ) {
319
- params . set ( 'kc_action' , options . action ) ;
330
+ if ( action && action !== 'register' ) {
331
+ params . set ( 'kc_action' , action ) ;
320
332
}
321
333
322
- if ( options ?. locale ) {
323
- params . set ( 'ui_locales' , options . locale ) ;
334
+ if ( locale ) {
335
+ params . set ( 'ui_locales' , locale ) ;
324
336
}
325
337
326
338
if ( this ?. pkceMethod && ! ! pkceChallenge ) {
@@ -330,6 +342,10 @@ export class KeycloakClient implements KeycloakInstance {
330
342
331
343
this . callbackStorage ! . add ( callbackState ) ;
332
344
345
+ Object . keys ( rest ) . forEach ( ( key ) => {
346
+ params . set ( key , `${ rest [ key ] } ` ) ;
347
+ } ) ;
348
+
333
349
return `${ baseUrl } ?${ formatQuerystringParameters ( params ) } ` ;
334
350
}
335
351
0 commit comments