Action-Based MFA requires users to verify their identity for sensitive actions like transactions.
By default, we only require action-based MFA once the user already has an MFA method registered.
Use requestedScopes to receive elevated access tokens instead of legacy MFA tokens. This is the recommended approach and will be required in the next major version.
TOTP
Passkey
import { isMfaRequiredForAction, authenticateTotpMfaDevice, MFAAction, TokenScope,} from '@dynamic-labs-sdk/client';import { exportWaasPrivateKey } from '@dynamic-labs-sdk/client/waas';const onExportPrivateKeyClick = async () => { const required = await isMfaRequiredForAction({ mfaAction: MFAAction.WalletWaasExport }); if (required) { await authenticateTotpMfaDevice({ code: '123456', requestedScopes: [TokenScope.Walletexport], }); } // Elevated token is now stored — the SDK attaches it automatically await exportWaasPrivateKey(params);};
import { isMfaRequiredForAction, authenticatePasskeyMFA, MFAAction, TokenScope,} from '@dynamic-labs-sdk/client';import { exportWaasPrivateKey } from '@dynamic-labs-sdk/client/waas';const onExportPrivateKeyClick = async () => { const required = await isMfaRequiredForAction({ mfaAction: MFAAction.WalletWaasExport }); if (required) { await authenticatePasskeyMFA({ requestedScopes: [TokenScope.Walletexport], }); } // Elevated token is now stored — the SDK attaches it automatically await exportWaasPrivateKey(params);};
For a complete guide on step-up authentication including all verification methods, see Step-Up Authentication.
In React, use useAuthenticateTotpMfaDevice for the MFA challenge and call the one-shot isMfaRequiredForAction check directly inside your handler before the sensitive operation:
createMfaToken and createMfaTokenOptions are deprecated and will be removed in the next major version. Use requestedScopes instead. See migration guide.