Skip to content

Commit

Permalink
custom storage scope
Browse files Browse the repository at this point in the history
  • Loading branch information
arch1995 committed Oct 2, 2024
1 parent 4cddc65 commit b829d3e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
11 changes: 6 additions & 5 deletions src/handlers/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -400,11 +400,6 @@ export interface CreateHandlerParams {
web3AuthNetwork: TORUS_NETWORK_TYPE;
}

export interface RedirectResultParams {
replaceUrl?: boolean;
clearLoginDetails?: boolean;
}

export type SingleLoginParams = SubVerifierDetails;

export interface AggregateLoginParams {
Expand All @@ -415,6 +410,12 @@ export interface AggregateLoginParams {

export type LoginDetails = { method: TORUS_METHOD_TYPE; args: SingleLoginParams | AggregateLoginParams };

export interface RedirectResultParams {
replaceUrl?: boolean;
clearLoginDetails?: boolean;
storageData?: LoginDetails;
}

export interface RedirectResult {
method: TORUS_METHOD_TYPE;
result?: TorusLoginResponse | TorusAggregateLoginResponse | unknown;
Expand Down
8 changes: 6 additions & 2 deletions src/login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,11 @@ class CustomAuth {
return this.getTorusKey(verifier, verifierId, aggregateVerifierParams, aggregateIdToken, extraVerifierParams);
}

async getRedirectResult({ replaceUrl = true, clearLoginDetails = true }: RedirectResultParams = {}): Promise<RedirectResult> {
async getRedirectResult({
replaceUrl = true,
clearLoginDetails = true,
storageData = undefined,
}: RedirectResultParams = {}): Promise<RedirectResult> {
await this.init({ skipInit: true });
const url = new URL(window.location.href);
const hash = url.hash.substring(1);
Expand All @@ -337,7 +341,7 @@ class CustomAuth {

log.info(instanceId, "instanceId");

const loginDetails = await this.storageHelper.retrieveLoginDetails(instanceId);
const loginDetails = storageData || (await this.storageHelper.retrieveLoginDetails(instanceId));
const { args, method, ...rest } = loginDetails || {};
log.info(args, method);

Expand Down

0 comments on commit b829d3e

Please sign in to comment.