From 128360e8bad63973e45bdba40f7f0dd11eb2ca83 Mon Sep 17 00:00:00 2001 From: sherzod-bakhodirov Date: Mon, 16 Sep 2024 14:21:37 +0500 Subject: [PATCH] feat: implement disable MFA types --- .../types/src/modules/auth-types.ts | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/packages/@magic-sdk/types/src/modules/auth-types.ts b/packages/@magic-sdk/types/src/modules/auth-types.ts index 4c1791fd0..4ee947cab 100644 --- a/packages/@magic-sdk/types/src/modules/auth-types.ts +++ b/packages/@magic-sdk/types/src/modules/auth-types.ts @@ -113,13 +113,24 @@ export interface LoginWithCredentialConfiguration { lifespan?: number; } -export interface EnableMfaConfiguration { +export interface EnableMFAConfiguration { /** * When `true`, a pre-built modal interface will show to the user, directing * them to enable MFA usign Google Authenticator app. * * When `false`, developers will be able to implement their own custom UI to - * continue the SMS OTP flow. + * continue the enable MFA flow. + */ + showUI?: boolean; +} + +export interface DisableMFAConfiguration { + /** + * When `true`, a pre-built modal interface will show to the user, directing + * them to disable MFA. + * + * When `false`, developers will be able to implement their own custom UI to + * continue the disable MFA flow. */ showUI?: boolean; } @@ -224,6 +235,18 @@ export enum EnableMFAEventEmit { Cancel = 'cancel-mfa-setup', } +export enum DisableMFAEventOnReceived { + MFACodeRequested = 'mfa-code-requested', + InvalidMFAOtp = 'invalid-mfa-otp', + InvalidRecoveryCode = 'invalid-recovery-code', +} + +export enum DisableMFAEventEmit { + VerifyMFACode = 'verify-mfa-code', + LostDevice = 'lost-device', + Cancel = 'cancel-mfa-disable', +} + /** * EventHandlers */ @@ -322,3 +345,13 @@ export type EnableMFAEventHandlers = { [EnableMFAEventEmit.VerifyMFACode]: (totp: string) => void; [EnableMFAEventEmit.Cancel]: () => void; }; + +/** + * Disable MFA + */ + +export type DisableMFAEventHandlers = { + [DisableMFAEventOnReceived.MFACodeRequested]: () => void; + [DisableMFAEventOnReceived.InvalidMFAOtp]: (error: string) => void; + [DisableMFAEventOnReceived.InvalidRecoveryCode]: () => void; +};