(params: Partial<LoginParams>)
| 274 | } |
| 275 | |
| 276 | async enableMFA(params: Partial<LoginParams>): Promise<boolean> { |
| 277 | if (!this.sessionId) throw LoginError.userNotLoggedIn(); |
| 278 | await this.refreshSession(); |
| 279 | |
| 280 | if (this.state.userInfo.isMfaEnabled) throw LoginError.mfaAlreadyEnabled(); |
| 281 | const dataObject: AuthRequestPayload = { |
| 282 | actionType: AUTH_ACTIONS.ENABLE_MFA, |
| 283 | options: { ...this.options, sdkMode: SDK_MODE.DEFAULT }, |
| 284 | params: { |
| 285 | ...params, |
| 286 | authConnection: this.state.userInfo.authConnection, |
| 287 | authConnectionId: this.state.userInfo.authConnectionId, |
| 288 | groupedAuthConnectionId: this.state.userInfo.groupedAuthConnectionId, |
| 289 | extraLoginOptions: { |
| 290 | login_hint: this.state.userInfo.userId, |
| 291 | }, |
| 292 | mfaLevel: "mandatory", |
| 293 | }, |
| 294 | sessionId: this.sessionId, |
| 295 | accessToken: await this.getAccessToken(), |
| 296 | }; |
| 297 | |
| 298 | const result = await this.authHandler(`${this.baseUrl}/start`, dataObject, POPUP_TIMEOUT); |
| 299 | if (!result) return false; |
| 300 | if (isAuthFlowError(result)) { |
| 301 | this.dappState = result.state; |
| 302 | throw LoginError.loginFailed(result.error); |
| 303 | } |
| 304 | await this.sessionManager.setTokens({ |
| 305 | sessionId: add0x(result.sessionId), |
| 306 | accessToken: result.accessToken, |
| 307 | refreshToken: result.refreshToken, |
| 308 | idToken: result.idToken, |
| 309 | }); |
| 310 | await this.refreshSession(); |
| 311 | return Boolean(this.state.userInfo?.isMfaEnabled); |
| 312 | } |
| 313 | |
| 314 | async manageMFA(params: Partial<LoginParams>): Promise<void> { |
| 315 | if (!this.sessionId) throw LoginError.userNotLoggedIn(); |
nothing calls this directly
no test coverage detected