Skip to main content

MfaRecoveryController Actions

15 actions registered.

NameDeprecated
abort
acquireLock
authenticateIdentifier
getIdentifiers
getPhase
getRecoverySecret
getState
isTrusted
register
releaseLock
resume
trustIdentifier
untrustPasskey
updateIdentifiers
updateRecoverySecret

MfaRecoveryController:abort​

Package: @metamask/mfa-recovery-controller

Drops authorizing pending. Drops writing pending only once its approval expired more than 5 minutes ago and no escrow applied it; otherwise finish it with resume.

Handler signature:

() => Promise<void>

MfaRecoveryController:acquireLock​

Package: @metamask/mfa-recovery-controller

Acquires or extends the per-profile recovery lease. Hold it from the first read through any Auth identifier changes and mutations.

Handler signature:

() => Promise<void>

MfaRecoveryController:authenticateIdentifier​

Package: @metamask/mfa-recovery-controller

Authenticates an identifier with a single login. Returns an ephemeral IdentifierSession for getRecoverySecret. For seedless social logins, the session also carries seedlessAuthData for SeedlessOnboardingController.authenticate. Callers decide whether they need seedlessAuthData (and its revokeToken), drop it after seedless authenticate, and keep the key-bound session fields for recovery reads.

Parameters:

NameDescription
identifierIdentifier to authenticate.

Returns: Session for recovery reads, with seedless auth data when the login returned it.

Handler signature:

(identifier: Identifier) => Promise<IdentifierSession>

MfaRecoveryController:getIdentifiers​

Package: @metamask/mfa-recovery-controller

Reads the enrolled identifiers from every escrow, with Auth's current identifiers. Needs no recent MFA, so a new device can build an updateIdentifiers call from it. Throws replica_lagging when escrows are at different versions.

Returns: Enrolled identifiers, epoch, and Auth's identifiers.

Handler signature:

() => Promise<RecoveryIdentifiers>

MfaRecoveryController:getPhase​

Package: @metamask/mfa-recovery-controller

Returns: Current recovery phase.

Handler signature:

() => Promise<RecoveryPhase>

MfaRecoveryController:getRecoverySecret​

Package: @metamask/mfa-recovery-controller

Reads the recovery secret from available escrows and returns the highest consistent version. epoch is the current recovery version and is required by later mutations. Does not wait for a pending mutation to be repaired.

Parameters:

NameDescription
sessionIdentifier authentication session used to authorize the read.

Returns: Recovered secret bytes and the selected epoch.

Handler signature:

(session: IdentifierSession) => Promise<RecoveredSecret>

MfaRecoveryController:getState​

Package: @metamask/mfa-recovery-controller

Handler signature:

() => MfaRecoveryControllerState

MfaRecoveryController:isTrusted​

Package: @metamask/mfa-recovery-controller

Returns whether writes accept the identifier: a user device saw it, or it is SIWE. Use it to pick from the identifiers Auth returns.

Parameters:

NameDescription
identifierAn identifier from Auth.

Returns: Whether the identifier is trusted.

Handler signature:

(identifier: Identifier) => Promise<boolean>

MfaRecoveryController:register​

Package: @metamask/mfa-recovery-controller

Creates version 1 of a recovery record.

Parameters:

NameDescription
recoverySecretSecret replicated in full to every escrow.
identifiersOwnership-approved identifier set. Must contain at least two identifiers.

Handler signature:

(recoverySecret: Uint8Array, identifiers: Identifier[]) => Promise<void>

MfaRecoveryController:releaseLock​

Package: @metamask/mfa-recovery-controller

Releases the lease. A pending mutation must finish first.

Handler signature:

() => Promise<void>

MfaRecoveryController:resume​

Package: @metamask/mfa-recovery-controller

Completes a persisted pending mutation. With none pending and an identifier, copies the highest escrow record to escrows one version behind it; pass an identifier when a mutation fails with replica_lagging. Clears a writing mutation, throwing MutationRejectedError, once its approval expired more than 5 minutes ago and no escrow applied it.

The recovery secret of a pending register or updateRecoverySecret is held only in memory. After a restart, a writing one reads it back from an escrow that applied it, with the update's identifier or, for register, identifier. Without such an escrow it throws recovery_secret_unavailable until the approval expires. An authorizing one reached no escrow, so it is cleared, throwing MutationRejectedError.

Parameters:

NameDescription
identifierEnrolled identifier that authorizes the repair, replaces the one authorizing a pending update (e.g. if it was lost), or reads back the recovery secret of a pending register.

Handler signature:

(identifier?: Identifier) => Promise<void>

MfaRecoveryController:trustIdentifier​

Package: @metamask/mfa-recovery-controller

Records a passkey the device just created. register and updateIdentifiers only accept recorded passkeys and the device's social login, so a compromised Auth API cannot add its own.

Parameters:

NameDescription
witnessWhat the device saw.

Handler signature:

(witness: IdentifierWitness) => Promise<void>

MfaRecoveryController:untrustPasskey​

Package: @metamask/mfa-recovery-controller

Stops trusting a passkey, so a later approval cannot add it back. Call it before removing the passkey from Auth.

Parameters:

NameDescription
credentialIdThe passkey's base64url WebAuthn credential ID.

Handler signature:

(credentialId: string) => Promise<void>

MfaRecoveryController:updateIdentifiers​

Package: @metamask/mfa-recovery-controller

Replaces the complete identifier set.

Parameters:

NameDescription
identifierCurrently registered identifier used to authorize.
identifiersNew identifier set. Must contain at least two identifiers.
epochCurrent recovery version, used as expectedVersion.

Handler signature:

(identifier: Identifier, identifiers: Identifier[], epoch: number) => Promise<void>

MfaRecoveryController:updateRecoverySecret​

Package: @metamask/mfa-recovery-controller

Replaces the recovery secret.

Parameters:

NameDescription
identifierCurrently registered identifier used to authorize.
recoverySecretNew secret.
epochCurrent recovery version, used as expectedVersion.

Handler signature:

(identifier: Identifier, recoverySecret: Uint8Array, epoch: number) => Promise<void>