跳到主要内容

Security

Security features in the @espressif/rainmaker-base-sdk include multi-factor authentication (MFA) configuration and account deletion management.

备注

The userInstance mentioned below refers to the ESPRMUser instance obtained during User Sign in.

Multi-Factor Authentication (MFA)

Configure MFA

Enable or disable multi-factor authentication (MFA) for the current user using the configureMFA method.

/*
- enabled: A boolean indicating whether MFA should be enabled (true) or not (false).
*/

try {
const response = await userInstance.configureMFA(true);
console.log("MFA configured successfully:", response);
} catch (error) {
console.error("Error configuring MFA:", error);
}

Account Deletion

Account deletion is a two-step process:

  1. Request Account Deletion - Send a request to initiate the account deletion process, which will send a verification code
  2. Confirm Account Deletion - Verify and complete the account deletion using the verification code received

Step 1: Request Account Deletion

Send a request to initiate the account deletion process using the requestAccountDeletion method. This will send a verification code to the user.

try {
const response = await userInstance.requestAccountDeletion();
console.log("Account deletion request sent successfully. Verification code sent:", response);
} catch (error) {
console.error("Error requesting account deletion:", error);
}

Step 2: Confirm Account Deletion

Confirm the account deletion request by providing a verification code using the confirmAccountDeletion method. Use the verification code received from the requestAccountDeletion step to complete the account deletion.

/*
- verificationCode: The verification code sent to the user for account deletion confirmation.
*/

try {
const response = await userInstance.confirmAccountDeletion(verificationCode);
console.log("Account deletion confirmed successfully:", response);
} catch (error) {
console.error("Error confirming account deletion:", error);
}

On this page