Skip to content

Commit 1de35ee

Browse files
committed
[wip] add extra paramaters
1 parent 7c41a88 commit 1de35ee

File tree

2 files changed

+8
-7
lines changed

2 files changed

+8
-7
lines changed

src/authentication/connector.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -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) {

src/jso/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,8 @@ export type OAuthRequest = {
1515
scope?: string,
1616
state?: string,
1717
location?: string,
18-
providerID?: string
18+
providerID?: string,
19+
max_age?: string
1920
} & Partial<Omit<ClientConfiguration, "scope">>;
2021

2122
export type CodeOAuthRedirectResponse = {

0 commit comments

Comments
 (0)