Skip to main content

AuthenticationController Actions

25 actions registered.

NameDeprecated
beginCredentialEnrollment
beginCredentialVerification
beginSocialLoginVerification
clearState
clearVerificationSession
completeCredentialEnrollment
completeCredentialVerification
completeSocialLoginVerification
exchangeSocialAccessToken
getBearerToken
getCustomerServiceToken
getPartnerIdentityToken
getSessionProfile
getState
getUserProfileLineage
getVerificationToken
isSignedIn
performSignIn
performSignOut
refreshCanonicalProfileId
refreshEnrolledCredentials
refreshSocialLoginCredentials
removeCredential
requestMfaApproval
requestProfilePairing

AuthenticationController:beginCredentialEnrollment​

Package: @metamask/profile-sync-controller

Begins enrollment of a passkey, email OTP or authenticator app (TOTP) credential.

Parameters:

NameDescription
requestCredential, optional email address, and trace reason.

Returns: A challenge for the client-owned ceremony.

Handler signature:

(request: BeginEnrollmentRequest) => Promise<EnrollmentChallenge>

AuthenticationController:beginCredentialVerification​

Package: @metamask/profile-sync-controller

Begins verification with an enrolled credential.

Parameters:

NameDescription
requestCredential type and trace reason.

Returns: A challenge for the client-owned ceremony.

Handler signature:

(request: BeginVerificationRequest) => Promise<VerificationChallenge>

AuthenticationController:beginSocialLoginVerification​

Package: @metamask/profile-sync-controller

Begins verification with an enrolled credential, while the wallet is locked, for the recovery of a social login wallet.

Takes its access token from the social login, like refreshSocialLoginCredentials. Throws when the wallet is unlocked: unlocked features use beginCredentialVerification.

Parameters:

NameDescription
requestCredential type and trace reason.

Returns: A challenge for the client-owned ceremony.

Handler signature:

(request: BeginVerificationRequest) => Promise<VerificationChallenge>

AuthenticationController:clearState​

Package: @metamask/profile-sync-controller

Resets the controller to defaultState. Clients call this on wallet reset so the next wallet starts unsigned with both pairing gates re-armed.

Handler signature:

() => void

AuthenticationController:clearVerificationSession​

Package: @metamask/profile-sync-controller

Clears every in-memory verification session and its expiration timer, and the tokens kept for enrollments in progress.

Handler signature:

() => void

AuthenticationController:completeCredentialEnrollment​

Package: @metamask/profile-sync-controller

Completes credential enrollment and refreshes the credential cache.

It is sent with the verification token that began the enrollment, if any: once a factor is enrolled, the server requires AAL2 for both steps.

The server returns an assertion for the new credential, which opens a verification session like completeCredentialVerification, replacing any earlier one. If that exchange fails, the earlier session is kept: the credential is enrolled either way.

A cache-refresh failure does not undo successful enrollment. Email enrollment invalidates the primary SRP session after refresh so the credentials call can reuse the still-valid access token; the next token fetch then includes the newly verified email claim. That invalidation happens even if the session ends mid-request: the enrollment succeeded on the server, so a token cached across a lock must not be reused without the new claim.

Parameters:

NameDescription
requestFlow identifier, platform or email proof, and trace reason.

Returns: The refreshed credentials, or the existing cache if refresh fails.

Handler signature:

(request: CompleteEnrollmentRequest) => Promise<EnrolledCredential[]>

AuthenticationController:completeCredentialVerification​

Package: @metamask/profile-sync-controller

Completes verification and opens a short-lived verification session.

The assertion returned by the MFA service is exchanged at Hydra for an access token. Its assurance level is not checked: the services receiving the token enforce their own requirements. The token itself never enters controller state.

Parameters:

NameDescription
requestFlow identifier, platform or email proof, and trace reason.

Returns: The verification token.

Handler signature:

(request: CompleteVerificationRequest) => Promise<VerificationToken>

AuthenticationController:completeSocialLoginVerification​

Package: @metamask/profile-sync-controller

Completes verification while the wallet is locked and returns the verification token, for the recovery of a social login wallet.

Unlike completeCredentialVerification, no verification session is opened: the token goes to the caller alone, so nothing proven here is readable once the wallet unlocks. Takes its access token from the social login. Throws when the wallet is unlocked.

Parameters:

NameDescription
requestFlow identifier, platform or email proof, and trace reason.

Returns: The verification token.

Handler signature:

(request: CompleteVerificationRequest) => Promise<VerificationToken>

AuthenticationController:exchangeSocialAccessToken​

Package: @metamask/profile-sync-controller

Exchanges the social access token SeedlessOnboarding holds for the wallet's Google/Apple/Telegram login (POST /api/v2/social/login) for an access token and the canonical profile it is paired to. Shows no UI and stores nothing: SRP sessions remain the source of truth for getBearerToken.

Throws when the wallet has no social login (no known authConnection, whether or not the vault is written yet) or no social token, and SocialIdentifierNotPairedError when the identifier was never paired to a profile.

Returns: The access token and canonical profile.

Handler signature:

() => Promise<LoginResponse>

AuthenticationController:getBearerToken​

Package: @metamask/profile-sync-controller

Returns a bearer token for the specified SRP, logging in if needed.

When called without entropySourceId, returns the primary (first) SRP's access token, which is effectively the canonical profile's token that can be used by alias-aware consumers for cross-SRP operations.

Parameters:

NameDescription
entropySourceIdThe entropy source ID. Omit for the primary SRP.

Returns: The OIDC access token.

Handler signature:

(entropySourceId?: string) => Promise<string>

AuthenticationController:getCustomerServiceToken​

Package: @metamask/profile-sync-controller

Returns a Customer Service specific access token for the specified SRP, logging in if needed.

Exchanges the OIDC access token for a short-lived token scoped to the customer-service audience. Customer Service tooling consumes this token to identify and authenticate the user.

Parameters:

NameDescription
entropySourceIdThe entropy source ID. Omit for the primary SRP.

Returns: The customer-service access token.

Handler signature:

(entropySourceId?: string) => Promise<string>

AuthenticationController:getPartnerIdentityToken​

Package: @metamask/profile-sync-controller

Mints a partner identity token for the specified SRP, logging in if needed.

Calls POST /api/v2/oidc/token with the Hydra login bearer and returns the minted access_token. Email on live tokens is under JWT ext. HTTP 422 throws EmailRequiredError when this profile has no verified email.

Parameters:

NameDescription
claimsClaim names to embed. Only email is supported.
audiencePartner audience (kyc or iron).
entropySourceIdThe entropy source ID. Omit for the primary SRP.

Returns: The partner identity access token.

Handler signature:

(claims: OidcTokenClaims, audience: OidcTokenAudience, entropySourceId?: string) => Promise<string>

AuthenticationController:getSessionProfile​

Package: @metamask/profile-sync-controller

Returns the cached session profile, logging in if no session exists.

The returned canonicalProfileId reflects the value from the most recent login or pairing. In the rare event where a canonical changed because of a pairing that happened on another device, the cached value may be stale until the next login. For guaranteed freshness, call refreshCanonicalProfileId() before reading canonicalProfileId.

Parameters:

NameDescription
entropySourceIdThe entropy source ID used to derive the key, when multiple sources are available (Multi-SRP).

Returns: profile for the session.

Handler signature:

(entropySourceId?: string) => Promise<UserProfile>

AuthenticationController:getState​

Package: @metamask/profile-sync-controller

Handler signature:

() => AuthenticationControllerState

AuthenticationController:getUserProfileLineage​

Package: @metamask/profile-sync-controller

Handler signature:

(entropySourceId?: string) => Promise<UserProfileLineage>

AuthenticationController:getVerificationToken​

Package: @metamask/profile-sync-controller

Returns the active verification token when it meets the requested freshness.

Low-level: features should go through the client MFA kit (verifyOrEnroll), which reuses a matching session without showing any screen and checks which method proved it. Read the token directly only from code that cannot show UI, and treat null as "let the UI layer ask".

Parameters:

NameDescription
requestOptional maximum session age in milliseconds, measured from when the token was obtained. Zero always requires a new ceremony.

Returns: A live verification token, or null when no reusable session exists.

Handler signature:

(request?: GetVerificationTokenRequest) => VerificationToken | null

AuthenticationController:isSignedIn​

Package: @metamask/profile-sync-controller

Handler signature:

() => boolean

AuthenticationController:performSignIn​

Package: @metamask/profile-sync-controller

Handler signature:

() => Promise<string[]>

AuthenticationController:performSignOut​

Package: @metamask/profile-sync-controller

Handler signature:

() => void

AuthenticationController:refreshCanonicalProfileId​

Package: @metamask/profile-sync-controller

Forces a fresh retrieval of the canonical profile ID from the server and propagates it to all cached SRP sessions.

This method invalidates the primary SRP's cached session and forces a re-login. Use it before operations that require a guaranteed-fresh canonical (e.g. storage key derivation for Accounts ADR 0005). For best-effort reads, use getSessionProfile().canonicalProfileId instead.

Only the primary SRP is re-logged-in regardless of how many SRPs exist — the server returns the current canonical for the entire pairing group from any single SRP login.

Returns: The refreshed canonical profile ID.

Handler signature:

() => Promise<string>

AuthenticationController:refreshEnrolledCredentials​

Package: @metamask/profile-sync-controller

Refreshes credentials enrolled on the canonical profile.

Returns: The current supported credentials.

Handler signature:

() => Promise<EnrolledCredential[]>

AuthenticationController:refreshSocialLoginCredentials​

Package: @metamask/profile-sync-controller

Refreshes the credentials enrolled on the profile a social login is paired to, while the wallet is locked, for the recovery of a social login wallet.

Takes its access token from the social login (see exchangeSocialAccessToken), so no keyring or signing is involved. Throws when the wallet is unlocked: unlocked features use refreshEnrolledCredentials. Nothing is cached.

Returns: The current supported credentials.

Handler signature:

() => Promise<EnrolledCredential[]>

AuthenticationController:removeCredential​

Package: @metamask/profile-sync-controller

Removes a credential from the profile and caches the credentials left.

The server requires a verification proven with another type of credential (cross_type_step_up_required otherwise) and refuses to remove the last one (last_credential). This sends the verification session: without one, it throws a StepUpRequiredError (aal2_required) without calling the server. The caller verifies with another method through the client MFA kit first, which decides how recent that verification must be.

Parameters:

NameDescription
requestThe credential's id, and the trace reason.

Returns: The credentials left.

Handler signature:

(request: RemoveCredentialRequest) => Promise<EnrolledCredential[]>

AuthenticationController:requestMfaApproval​

Package: @metamask/profile-sync-controller

Requests an approval bound to one request (POST /api/v2/mfa/approvals), for the services in audiences, such as recovery or signing.

Shows no UI. When requireVerification is set, the approval proves the verification session: without one, this throws a StepUpRequiredError (aal2_required) without calling the server. The server answers the same way when the verification is too old for it, and that session is then dropped. Either way, the caller verifies through the client MFA kit (verifyOrEnroll), which runs a new ceremony, and calls again.

Parameters:

NameDescription
requestRequest digest, audiences, whether a recent verification is required, whether to return identifiers, and the trace reason.

Returns: The approval, its lifetime and the recovery identifiers.

Handler signature:

(request: RequestMfaApprovalRequest) => Promise<MfaApproval>

AuthenticationController:requestProfilePairing​

Package: @metamask/profile-sync-controller

Marks profile pairing as needed. Clients call this when the SRP set changes (e.g. a new keyring was added) so the next auto-sign-in cycle re-runs performSignIn and re-pairs.

Handler signature:

() => void