@@ -225,6 +225,7 @@ function logInWithRedirect(reset: boolean = false, extraParams?: Record<string,
225225
226226 req [ "code_challenge" ] = pkce . codeChallenge ;
227227 req [ "code_challenge_method" ] = "S256" ;
228+ if ( extraParams ?. max_age ) req [ "max_age" ] = extraParams . max_age
228229
229230 jso_saveCodeVerifier ( auth . provider , pkce . codeVerifier ) ;
230231 } else {
@@ -308,7 +309,7 @@ function logInWithRedirect(reset: boolean = false, extraParams?: Record<string,
308309 } ) ;
309310}
310311
311- const logInWithWebMessageAndPKCE = async ( reset : boolean ) => {
312+ const logInWithWebMessageAndPKCE = async ( reset : boolean , extraParams ?: Record < string , string > ) => {
312313 const auth = getConfig ( ) ;
313314
314315 return new Promise ( async ( resolve , reject ) => {
@@ -362,6 +363,7 @@ const logInWithWebMessageAndPKCE = async (reset: boolean) => {
362363
363364 req [ "code_challenge" ] = pkce . codeChallenge ;
364365 req [ "code_challenge_method" ] = "S256" ;
366+ if ( extraParams ?. max_age ) req [ "max_age" ] = extraParams . max_age
365367
366368 const timeout = setTimeout ( ( ) => {
367369 if ( auth . popupMode ) {
@@ -404,7 +406,8 @@ const logInWithWebMessageAndPKCE = async (reset: boolean) => {
404406
405407 window . addEventListener ( "message" , receiveMessage , false ) ;
406408
407- const authUrl = encodeURL ( auth . authorization , req ) ;
409+ const authUrl = encodeURL ( auth . authorization , { ...req , ...extraParams } ) ;
410+
408411 createIFrame ( authUrl ) ;
409412 } catch ( err ) {
410413 console . log ( "Error Silent refresh" ) ;
@@ -482,12 +485,9 @@ export default (token?: string, reset: boolean = false, config?: Partial<ClientC
482485 return logInWithToken ( token ) . catch ( e => new Error ( e ) ) ;
483486 }
484487
485- if ( config ?. extra_params && Object . entries ( config . extra_params ) . length ) {
486- return logInWithRedirect ( reset , config . extra_params ) ;
487- }
488488
489489 if ( config ?. response_mode === "web_message" && config . prompt === "none" ) {
490- return logInWithWebMessageAndPKCE ( reset ) ;
490+ return logInWithWebMessageAndPKCE ( reset , config ?. extra_params ) ;
491491 }
492492
493493 if ( config ?. popupMode ) {
0 commit comments