Skip to content

Commit 2d2eff4

Browse files
committed
feat: add code verifier to generateAuthUrl reponse
1 parent d96303f commit 2d2eff4

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

lib/utils/generateAuthUrl.ts

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export const generateAuthUrl = async (
1818
state: string;
1919
nonce: string;
2020
codeChallenge: string;
21+
codeVerifier: string;
2122
}> => {
2223
const authUrl = new URL(`${domain}/oauth2/auth`);
2324
const activeStorage = getInsecureStorage();
@@ -43,10 +44,12 @@ export const generateAuthUrl = async (
4344
activeStorage.setSessionItem(StorageKeys.nonce, options.nonce);
4445
}
4546

47+
let returnCodeVerifier = "";
4648
if (options.codeChallenge) {
4749
searchParams["code_challenge"] = options.codeChallenge;
4850
} else {
4951
const { codeVerifier, codeChallenge } = await generatePKCEPair();
52+
returnCodeVerifier = codeVerifier;
5053
if (activeStorage) {
5154
activeStorage.setSessionItem(StorageKeys.codeVerifier, codeVerifier);
5255
}
@@ -68,6 +71,7 @@ export const generateAuthUrl = async (
6871
state: searchParams["state"],
6972
nonce: searchParams["nonce"],
7073
codeChallenge: searchParams["code_challenge"],
74+
codeVerifier: returnCodeVerifier,
7175
};
7276
};
7377

0 commit comments

Comments
 (0)