From d43a15562b2dc5301b24f4dcaf9618b278ec6040 Mon Sep 17 00:00:00 2001 From: Archit Date: Wed, 2 Oct 2024 22:37:41 +0530 Subject: [PATCH] custom storage scope --- src/handlers/interfaces.ts | 11 ++++++----- src/login.ts | 8 ++++++-- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/handlers/interfaces.ts b/src/handlers/interfaces.ts index 451aa08..0754cb4 100644 --- a/src/handlers/interfaces.ts +++ b/src/handlers/interfaces.ts @@ -418,11 +418,6 @@ export interface CreateHandlerParams { web3AuthNetwork: TORUS_NETWORK_TYPE; } -export interface RedirectResultParams { - replaceUrl?: boolean; - clearLoginDetails?: boolean; -} - export type SingleLoginParams = SubVerifierDetails; export interface AggregateLoginParams { @@ -433,6 +428,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; diff --git a/src/login.ts b/src/login.ts index e46e4bd..95215df 100644 --- a/src/login.ts +++ b/src/login.ts @@ -344,7 +344,11 @@ class CustomAuth { return this.getTorusKey(verifier, verifierId, aggregateVerifierParams, aggregateIdToken, extraVerifierParams); } - async getRedirectResult({ replaceUrl = true, clearLoginDetails = true }: RedirectResultParams = {}): Promise { + async getRedirectResult({ + replaceUrl = true, + clearLoginDetails = true, + storageData = undefined, + }: RedirectResultParams = {}): Promise { await this.init({ skipInit: true }); const url = new URL(window.location.href); const hash = url.hash.substring(1); @@ -363,7 +367,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);