Skip to content

Commit 3243c4e

Browse files
committed
test: update tests
1 parent 62ebed6 commit 3243c4e

File tree

1 file changed

+19
-10
lines changed

1 file changed

+19
-10
lines changed

lib/utils/exchangeAuthCode.ts

+19-10
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,27 @@ export const frameworkSettings: { framework: string; frameworkVersion: string }
55
frameworkVersion: "",
66
};
77

8+
interface ExchangeAuthCodeParams {
9+
urlParams: URLSearchParams;
10+
domain: string;
11+
clientId: string;
12+
redirectURL: string;
13+
}
14+
15+
interface ExchangeAuthCodeResult {
16+
success: boolean;
17+
error?: string;
18+
[StorageKeys.accessToken]?: string;
19+
[StorageKeys.idToken]?: string;
20+
[StorageKeys.refreshToken]?: string;
21+
}
22+
823
export const exchangeAuthCode = async ({
924
urlParams,
1025
domain,
1126
clientId,
1227
redirectURL,
13-
}: {
14-
urlParams: URLSearchParams;
15-
domain: string;
16-
clientId: string;
17-
redirectURL: string;
18-
}): Promise<unknown> => {
28+
}: ExchangeAuthCodeParams): Promise<ExchangeAuthCodeResult> => {
1929
const state = urlParams.get("state");
2030
const code = urlParams.get("code");
2131

@@ -31,7 +41,6 @@ export const exchangeAuthCode = async ({
3141
if (!activeStorage) {
3242
throw new Error("No active storage found");
3343
}
34-
activeStorage.getSessionItem(StorageKeys.state);
3544

3645
// warn if framework and version has not been set
3746
if (!frameworkSettings.framework || !frameworkSettings.frameworkVersion) {
@@ -90,9 +99,9 @@ export const exchangeAuthCode = async ({
9099
activeStorage.removeItems(StorageKeys.state, StorageKeys.codeVerifier);
91100

92101
// Clear all url params
93-
// const url = new URL(window.location.toString());
94-
// url.search = "";
95-
// window.history.pushState({}, "", url);
102+
const url = new URL(window.location.toString());
103+
url.search = "";
104+
window.history.pushState({}, "", url);
96105

97106
return {
98107
success: true,

0 commit comments

Comments
 (0)