@@ -113,6 +113,11 @@ export type EncryptionKeys = {
113113 eccPrivateKey : Uint8Array ;
114114}
115115
116+ export const enum LoginV3ResultEnum {
117+ NOT_LOGGED_IN = 'notLoggedin' ,
118+ LINKING_BLOCKED_BY_CROSS_REGION = 'linkingBlockedByCrossRegion' ,
119+ }
120+
116121export class Auth {
117122 ssoLogoutUrl : string = ''
118123 userType : UserType = UserType . normal
@@ -279,7 +284,7 @@ export class Auth {
279284 ecOnly = false ,
280285 fromSessionToken = undefined
281286 } : Partial < LoginPayload >
282- ) {
287+ ) : Promise < { result : LoginV3ResultEnum } | undefined > {
283288 this . _username = username || this . options . sessionStorage ?. lastUsername || ''
284289
285290 let wrappedPassword : KeyWrapper | undefined ;
@@ -357,7 +362,7 @@ export class Auth {
357362 }
358363 if ( resumeSessionOnly && loginResponse && ( loginResponse . loginState != Authentication . LoginState . LOGGED_IN ) ) {
359364 return {
360- result : 'notLoggedin'
365+ result : LoginV3ResultEnum . NOT_LOGGED_IN ,
361366 }
362367 }
363368 console . log ( loginResponse )
@@ -395,7 +400,7 @@ export class Auth {
395400 break ;
396401 case Authentication . LoginState . DEVICE_APPROVAL_REQUIRED :
397402 case Authentication . LoginState . REQUIRES_DEVICE_ENCRYPTED_DATA_KEY :
398- if ( givenSessionToken ) return { result : 'notLoggedin' }
403+ if ( givenSessionToken ) return { result : LoginV3ResultEnum . NOT_LOGGED_IN }
399404 try {
400405 loginToken = await this . verifyDevice ( username , loginResponse . encryptedLoginToken , loginResponse . loginState == Authentication . LoginState . REQUIRES_DEVICE_ENCRYPTED_DATA_KEY )
401406 } catch ( e : any ) {
@@ -407,6 +412,12 @@ export class Auth {
407412 handleError ( 'license_expired' , loginResponse , new Error ( loginResponse . message ) )
408413 return ;
409414 case Authentication . LoginState . REGION_REDIRECT :
415+ if ( ! ! fromSessionToken ) {
416+ return {
417+ result : LoginV3ResultEnum . LINKING_BLOCKED_BY_CROSS_REGION ,
418+ }
419+ }
420+
410421 // TODO: put region_redirect in its own loop since
411422 // its unique to the other states.
412423 this . options . host = loginResponse . stateSpecificValue
0 commit comments