@@ -11,7 +11,6 @@ import {
1111 AuthSessionData ,
1212 AuthUserInfo ,
1313 BaseLoginParams ,
14- BaseRedirectParams ,
1514 BrowserStorage ,
1615 BUILD_ENV ,
1716 cloneDeep ,
@@ -100,8 +99,7 @@ export class Auth {
10099 if ( ! options . mfaSettings ) options . mfaSettings = { } ;
101100 if ( ! options . storageServerUrl ) options . storageServerUrl = SESSION_SERVER_API_URL ;
102101 if ( ! options . sessionSocketUrl ) options . sessionSocketUrl = SESSION_SERVER_SOCKET_URL ;
103- if ( ! options . storageKey ) options . storageKey = "local" ;
104- if ( ! options . webauthnTransports ) options . webauthnTransports = [ "internal" ] ;
102+ if ( ! options . storage ) options . storage = "local" ;
105103 if ( ! options . sessionTime ) options . sessionTime = 86400 ;
106104
107105 this . options = options ;
@@ -166,8 +164,9 @@ export class Auth {
166164 const params = getHashQueryParams ( this . options . replaceUrlOnRedirect ) ;
167165 if ( params . sessionNamespace ) this . options . sessionNamespace = params . sessionNamespace ;
168166
169- const storageKey = this . options . sessionNamespace ? `${ this . _storageBaseKey } _${ this . options . sessionNamespace } ` : this . _storageBaseKey ;
170- this . currentStorage = BrowserStorage . getInstance ( storageKey , this . options . storageKey ) ;
167+ const storageKey =
168+ this . options . sessionKey || this . options . sessionNamespace ? `${ this . _storageBaseKey } _${ this . options . sessionNamespace } ` : this . _storageBaseKey ;
169+ this . currentStorage = BrowserStorage . getInstance ( storageKey , this . options . storage ) ;
171170
172171 const sessionId = this . currentStorage . get < string > ( "sessionId" ) ;
173172
@@ -232,18 +231,11 @@ export class Auth {
232231 return finalConfig ;
233232 }
234233
235- async login ( params : LoginParams & Partial < BaseRedirectParams > ) : Promise < { privKey : string } | null > {
234+ async login ( params : LoginParams ) : Promise < { privKey : string } | null > {
236235 if ( ! params . loginProvider ) throw LoginError . invalidLoginParams ( `loginProvider is required` ) ;
237236
238- // in case of redirect mode, redirect url will be dapp specified
239- // in case of popup mode, redirect url will be sdk specified
240- const defaultParams : BaseRedirectParams = {
241- redirectUrl : this . options . redirectUrl ,
242- } ;
243-
244237 const loginParams : LoginParams = {
245238 loginProvider : params . loginProvider ,
246- ...defaultParams ,
247239 ...params ,
248240 } ;
249241
@@ -266,7 +258,7 @@ export class Auth {
266258 return { privKey : this . privKey } ;
267259 }
268260
269- async postLoginInitiatedMessage ( params : LoginParams & Partial < BaseRedirectParams > , nonce ?: string ) : Promise < void > {
261+ async postLoginInitiatedMessage ( params : LoginParams , nonce ?: string ) : Promise < void > {
270262 if ( this . options . sdkMode !== SDK_MODE . IFRAME ) throw LoginError . invalidLoginParams ( "Cannot perform this action in default mode." ) ;
271263 if ( ! this . authProvider || ! this . authProvider . initialized ) throw InitializationError . notInitialized ( ) ;
272264
@@ -329,17 +321,11 @@ export class Auth {
329321 async enableMFA ( params : Partial < LoginParams > ) : Promise < boolean > {
330322 if ( ! this . sessionId ) throw LoginError . userNotLoggedIn ( ) ;
331323 if ( this . state . userInfo . isMfaEnabled ) throw LoginError . mfaAlreadyEnabled ( ) ;
332- // in case of redirect mode, redirect url will be dapp specified
333- // in case of popup mode, redirect url will be sdk specified
334- const defaultParams : BaseRedirectParams = {
335- redirectUrl : this . options . redirectUrl ,
336- } ;
337324
338325 const dataObject : AuthSessionConfig = {
339326 actionType : AUTH_ACTIONS . ENABLE_MFA ,
340327 options : this . options ,
341328 params : {
342- ...defaultParams ,
343329 ...params ,
344330 loginProvider : this . state . userInfo . typeOfLogin ,
345331 extraLoginOptions : {
@@ -407,20 +393,13 @@ export class Auth {
407393 window . open ( loginUrl , "_blank" ) ;
408394 }
409395
410- async manageSocialFactor ( actionType : AUTH_ACTIONS_TYPE , params : SocialMfaModParams & Partial < BaseRedirectParams > ) : Promise < boolean > {
396+ async manageSocialFactor ( actionType : AUTH_ACTIONS_TYPE , params : SocialMfaModParams & Pick < LoginParams , "appState" > ) : Promise < boolean > {
411397 if ( ! this . sessionId ) throw LoginError . userNotLoggedIn ( ) ;
412398
413- // in case of redirect mode, redirect url will be dapp specified
414- // in case of popup mode, redirect url will be sdk specified
415- const defaultParams : BaseRedirectParams = {
416- redirectUrl : this . options . redirectUrl ,
417- } ;
418-
419399 const dataObject : AuthSessionConfig = {
420400 actionType,
421401 options : this . options ,
422402 params : {
423- ...defaultParams ,
424403 ...params ,
425404 } ,
426405 sessionId : this . sessionId ,
@@ -432,20 +411,13 @@ export class Auth {
432411 return true ;
433412 }
434413
435- async addAuthenticatorFactor ( params : Partial < BaseRedirectParams > ) : Promise < boolean > {
414+ async addAuthenticatorFactor ( params : Pick < LoginParams , "appState" > ) : Promise < boolean > {
436415 if ( ! this . sessionId ) throw LoginError . userNotLoggedIn ( ) ;
437416
438- // in case of redirect mode, redirect url will be dapp specified
439- // in case of popup mode, redirect url will be sdk specified
440- const defaultParams : BaseRedirectParams = {
441- redirectUrl : this . options . redirectUrl ,
442- } ;
443-
444417 const dataObject : AuthSessionConfig = {
445418 actionType : AUTH_ACTIONS . ADD_AUTHENTICATOR_FACTOR ,
446419 options : this . options ,
447420 params : {
448- ...defaultParams ,
449421 ...params ,
450422 loginProvider : LOGIN_PROVIDER . AUTHENTICATOR ,
451423 } ,
@@ -458,20 +430,13 @@ export class Auth {
458430 return true ;
459431 }
460432
461- async addPasskeyFactor ( params : Partial < BaseRedirectParams > ) : Promise < boolean > {
433+ async addPasskeyFactor ( params : Pick < LoginParams , "appState" > ) : Promise < boolean > {
462434 if ( ! this . sessionId ) throw LoginError . userNotLoggedIn ( ) ;
463435
464- // in case of redirect mode, redirect url will be dapp specified
465- // in case of popup mode, redirect url will be sdk specified
466- const defaultParams : BaseRedirectParams = {
467- redirectUrl : this . options . redirectUrl ,
468- } ;
469-
470436 const dataObject : AuthSessionConfig = {
471437 actionType : AUTH_ACTIONS . ADD_PASSKEY_FACTOR ,
472438 options : this . options ,
473439 params : {
474- ...defaultParams ,
475440 ...params ,
476441 loginProvider : LOGIN_PROVIDER . PASSKEYS ,
477442 } ,
0 commit comments