import { useSyncMfaFlow, useMfa, useDynamicContext } from '@dynamic-labs/sdk-react-core';
export function CustomMfa() {
const { getUserDevices, addDevice, getRecoveryCodes } = useMfa();
const { userWithMissingInfo } = useDynamicContext();
useSyncMfaFlow({
handler: async () => {
if (userWithMissingInfo?.scope?.includes('requiresAdditionalAuth')) {
const devices = await getUserDevices();
if (devices.length === 0) {
const { uri, secret } = await addDevice();
// show QR code using uri/secret, then prompt for OTP verification
} else {
// prompt for OTP verification
}
} else {
const codes = await getRecoveryCodes();
// display backup codes, then ask user to acknowledge
}
},
});
return <div>...</div>;
}