Skip to content

Commit

Permalink
test: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
DanielRivers committed Oct 29, 2024
1 parent 62ebed6 commit 3243c4e
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions lib/utils/exchangeAuthCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,27 @@ export const frameworkSettings: { framework: string; frameworkVersion: string }
frameworkVersion: "",
};

interface ExchangeAuthCodeParams {
urlParams: URLSearchParams;
domain: string;
clientId: string;
redirectURL: string;
}

interface ExchangeAuthCodeResult {
success: boolean;
error?: string;
[StorageKeys.accessToken]?: string;
[StorageKeys.idToken]?: string;
[StorageKeys.refreshToken]?: string;
}

export const exchangeAuthCode = async ({
urlParams,
domain,
clientId,
redirectURL,
}: {
urlParams: URLSearchParams;
domain: string;
clientId: string;
redirectURL: string;
}): Promise<unknown> => {
}: ExchangeAuthCodeParams): Promise<ExchangeAuthCodeResult> => {
const state = urlParams.get("state");
const code = urlParams.get("code");

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

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

// Clear all url params
// const url = new URL(window.location.toString());
// url.search = "";
// window.history.pushState({}, "", url);
const url = new URL(window.location.toString());
url.search = "";
window.history.pushState({}, "", url);

return {
success: true,
Expand Down

0 comments on commit 3243c4e

Please sign in to comment.