Account security, devices and deletion
Manage email, phone, sessions, security events and account closure.
Email change
Start with new email and primary credential, then confirm with delivered challenge. Successful receipt requires login again.
const change = await auth.account.startEmailChange(newEmail, currentPassword);
await auth.account.confirmEmailChange({
challengeId: change.challengeId, method: "otp", value: otp, newEmail,
});Phone verification
Use E.164 format, including country code. Confirm with the exact phone and code. Removal requires primary credential.
const phoneChallenge = await auth.account.startPhoneVerification(phone, currentPassword);
await auth.account.confirmPhoneVerification({ challengeId: phoneChallenge.challengeId, phone, code });
// Explicit removal: await auth.account.removePhone(currentPassword);Devices and sessions
List sessions, distinguish current session, and ask confirmation before revocation. Revoking the current session clears local auth according to server receipt.
const current = await auth.sessions.current();
const sessions = await auth.sessions.list(20, 0);
// await auth.sessions.revoke(sessionId);
// await auth.sessions.revokeOthers();
// await auth.sessions.revokeAll();Security dashboard
Read status and paginated activity. Do not surface raw tokens or upstream error responses.
const security = await auth.security.status();
const activity = await auth.security.activity(20);Delete account
Check eligibility, methods and policy. Explain account closure and wallet recovery consequences. Require explicit confirmation, appropriate credential and any required assurance. Keep status secret secure for later status lookup; do not treat access_closed as completion.
const eligibility = await auth.account.deletionEligibility();
// Proceed only when eligible and password is an available method.
const intent = await auth.account.startDeletion("password");
// After explicit user confirmation:
await auth.account.confirmDeletion({
intentId: intent.intentId, intentSecret: intent.intentSecret,
policyVersion: intent.policyVersion, confirmed: true,
}, currentPassword);
// Later: auth.account.deletionStatus(intent.intentId, intent.statusSecret)