@@ -3318,44 +3318,41 @@ export default class GoTrueClient {
33183318 * {@see GoTrueMFAApi#getAuthenticatorAssuranceLevel }
33193319 */
33203320 private async _getAuthenticatorAssuranceLevel ( ) : Promise < AuthMFAGetAuthenticatorAssuranceLevelResponse > {
3321- return this . _acquireLock ( - 1 , async ( ) => {
3322- return await this . _useSession ( async ( result ) => {
3323- const {
3324- data : { session } ,
3325- error : sessionError ,
3326- } = result
3327- if ( sessionError ) {
3328- return { data : null , error : sessionError }
3329- }
3330- if ( ! session ) {
3331- return {
3332- data : { currentLevel : null , nextLevel : null , currentAuthenticationMethods : [ ] } ,
3333- error : null ,
3334- }
3335- }
3321+ const {
3322+ data : { session } ,
3323+ error : sessionError ,
3324+ } = await this . getSession ( )
33363325
3337- const { payload } = decodeJWT ( session . access_token )
3326+ if ( sessionError ) {
3327+ return { data : null , error : sessionError }
3328+ }
3329+ if ( ! session ) {
3330+ return {
3331+ data : { currentLevel : null , nextLevel : null , currentAuthenticationMethods : [ ] } ,
3332+ error : null ,
3333+ }
3334+ }
33383335
3339- let currentLevel : AuthenticatorAssuranceLevels | null = null
3336+ const { payload } = decodeJWT ( session . access_token )
33403337
3341- if ( payload . aal ) {
3342- currentLevel = payload . aal
3343- }
3338+ let currentLevel : AuthenticatorAssuranceLevels | null = null
33443339
3345- let nextLevel : AuthenticatorAssuranceLevels | null = currentLevel
3340+ if ( payload . aal ) {
3341+ currentLevel = payload . aal
3342+ }
33463343
3347- const verifiedFactors =
3348- session . user . factors ?. filter ( ( factor : Factor ) => factor . status === 'verified' ) ?? [ ]
3344+ let nextLevel : AuthenticatorAssuranceLevels | null = currentLevel
33493345
3350- if ( verifiedFactors . length > 0 ) {
3351- nextLevel = 'aal2'
3352- }
3346+ const verifiedFactors =
3347+ session . user . factors ?. filter ( ( factor : Factor ) => factor . status === 'verified' ) ?? [ ]
3348+
3349+ if ( verifiedFactors . length > 0 ) {
3350+ nextLevel = 'aal2'
3351+ }
33533352
3354- const currentAuthenticationMethods = payload . amr || [ ]
3353+ const currentAuthenticationMethods = payload . amr || [ ]
33553354
3356- return { data : { currentLevel, nextLevel, currentAuthenticationMethods } , error : null }
3357- } )
3358- } )
3355+ return { data : { currentLevel, nextLevel, currentAuthenticationMethods } , error : null }
33593356 }
33603357
33613358 /**
0 commit comments