Skip to content

Commit

Permalink
feat: implement recover account events
Browse files Browse the repository at this point in the history
  • Loading branch information
sherzod-bakhodirov committed Nov 6, 2024
1 parent 7e2962a commit 39ddb72
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
12 changes: 10 additions & 2 deletions packages/@magic-sdk/types/src/modules/intermediary-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,12 @@ import { NftCheckoutIntermediaryEvents } from './nft-types';

import { WalletEventOnReceived } from './wallet-types';
import { UiEventsEmit } from './common-types';
import { RecoveryFactorEventEmit, RecoveryFactorEventOnReceived } from './user-types';
import {
RecoverAccountEventEmit,
RecoverAccountEventOnReceived,
RecoveryFactorEventEmit,
RecoveryFactorEventOnReceived,
} from './user-types';

export type IntermediaryEvents =
// EmailOTP
Expand Down Expand Up @@ -60,4 +65,7 @@ export type IntermediaryEvents =
| `${EnableMFAEventEmit}`
// Disable MFA Events
| `${DisableMFAEventOnReceived}`
| `${DisableMFAEventEmit}`;
| `${DisableMFAEventEmit}`
// Recover Account Events
| `${RecoverAccountEventOnReceived}`
| `${RecoverAccountEventEmit}`;
33 changes: 33 additions & 0 deletions packages/@magic-sdk/types/src/modules/user-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@ export interface RecoverAccountConfiguration {
* The email to recover
*/
email: string;
showUI: boolean;
}

export interface ShowSettingsConfiguration {
Expand All @@ -113,3 +114,35 @@ export interface ShowSettingsConfiguration {
page: DeepLinkPage;
showUI?: boolean;
}

export enum RecoverAccountEventOnReceived {
SmsOtpSent = 'sms-otp-sent',
LoginThrottled = 'login-throttled',
InvalidSmsOtp = 'invalid-sms-otp',
SmsVerified = 'sms-verified',
}

export enum RecoverAccountEventEmit {
Cancel = 'cancel',
VerifyOtp = 'verify-otp-code',
ResendSms = 'resend-sms-otp',
}

export type RecoverAccountEventHandlers = {
// Event Received
[RecoverAccountEventEmit.Cancel]: () => void;
[RecoverAccountEventEmit.VerifyOtp]: (otp: string) => void;
[RecoverAccountEventEmit.ResendSms]: () => void;

// Event sent
[RecoverAccountEventOnReceived.SmsOtpSent]: ({ phoneNumber }: { phoneNumber: string }) => void;
[RecoverAccountEventOnReceived.LoginThrottled]: (error: string) => {};
[RecoverAccountEventOnReceived.InvalidSmsOtp]: ({
errorMessage,
errorCode,
}: {
errorMessage: string;
errorCode: string;
}) => {};
[RecoverAccountEventOnReceived.SmsVerified]: () => {};
};

0 comments on commit 39ddb72

Please sign in to comment.