KycController Actions
20 actions registered.
KycController:clearState
Package: @metamask/kyc-controller
Restores the controller to its default state.
Handler signature:
() => void
KycController:deleteEncryptedStorage
Package: @metamask/kyc-controller
Deletes the caller's encrypted KYC blobs from MetaMask servers.
Mints a fresh X25519 keypair, fetches a wrapping key from
POST /deletions, seals a delete-scoped ukyc_capability_token (4 hour
lifetime, client-presented) for that key, and submits it to
DELETE /deletions/{deletionId}. Both KYC API calls are authenticated
with params.aal2Token. Does not clear controller state.
Parameters:
| Name | Description |
|---|---|
params | The deletion parameters. |
params.aal2Token | AAL2 authentication token sent as the Authorization bearer value for both deletion requests. |
Handler signature:
(params: {
aal2Token: string;
}) => Promise<void>
KycController:ensureLocalUserSecret
Package: @metamask/kyc-controller
Creates the UKYC local_user_secret and stores it in Encrypted User
Storage when one does not already exist.
Call this after the user has expressed intent to onboard and before
startSession. Persisting the secret here moves generation and the
storage write off the startSession path. startSession still reads the
secret, and still creates it when this has not been called.
Await this call, or attach a rejection handler. A failure does not block
onboarding: startSession creates the secret if it is still missing.
The operation is idempotent and uses the same primary entropy source as session creation. The plaintext secret is not returned and is not sent to idOS. Only the encrypted User Storage copy is synced.
Handler signature:
() => Promise<void>
KycController:fetchSessionDisclaimers
Package: @metamask/kyc-controller
Fetches the idOS + KYC-provider disclaimer catalog. Pass exactly one of
sessionId or country:
{ sessionId }→KycService.fetchSessionDisclaimersBySessionId(GET /sessions/{sessionId}/disclaimers){ country }→KycService.fetchSessionDisclaimersByCountry(GET /disclaimers?country=)
A session-id fetch also writes the catalog to sessionDisclaimers.
Parameters:
| Name | Description |
|---|---|
params | The parameters. Provide exactly one of sessionId or country. |
params.sessionId | The UKYC session id. |
params.country | ISO 3166-1 alpha-3 country code. |
Returns: The catalog. Session fetches include consent state; country fetches do not.
Handler signature:
(params: FetchSessionDisclaimersParams) => Promise<KycSessionDisclaimers | KycDisclaimersCatalog>
KycController:fetchSessionStatusOnce
Package: @metamask/kyc-controller
Fetches GET /sessions/{id}/status once and writes the result onto state.
Does not start the session-status polling timer.
Parameters:
| Name | Description |
|---|---|
sessionId | UKYC session id. |
Returns: The fetched session status.
Handler signature:
(sessionId: string) => Promise<KycSessionStatus>
KycController:fetchVendorDisclaimers
Package: @metamask/kyc-controller
Fetches the vendor T&Cs the customer must accept before a session is
created (GET /vendors/{vendor}/disclaimers?country=).
Parameters:
| Name | Description |
|---|---|
params | The parameters. |
params.vendor | Identity vendor. Defaults to moonpay. |
params.country | ISO 3166-1 alpha-3 country code. |
Returns: The disclaimers.
Handler signature:
(params: {
vendor?: KycVendor;
country: string;
}) => Promise<KycDisclaimer[]>
KycController:getDataShares
Package: @metamask/kyc-controller
Fetches the vendors this customer's verified identity data has been shared with, newest first.
The external user id comes from the session status on state. When no session has been stored yet, the latest session for the vendor on state is fetched first (without writing it to state). An unresolvable session — no vendor on state, or no latest session for it — yields an empty list rather than an error, so consumers can render an empty "shared with" list.
Returns: The data shares, newest first; empty when no session can be resolved.
Handler signature:
() => Promise<KycDataShare[]>
KycController:getProviderFlowStatus
Package: @metamask/kyc-controller
Returns the durable outcome of the identity-provider flow.
Returns: The latest provider-flow status.
Handler signature:
() => KycProviderFlowStatus
KycController:getSessionStatusForVendor
Package: @metamask/kyc-controller
Fetches the latest UKYC session status for a vendor.
Parameters:
| Name | Description |
|---|---|
vendor | Identity vendor whose latest session should be queried. |
Returns: The session status, or null when none exists.
Handler signature:
(vendor: KycVendor) => Promise<KycSessionStatus | null>
KycController:getState
Package: @metamask/kyc-controller
Handler signature:
() => KycControllerState
KycController:hasCompletedSessionDisclaimers
Package: @metamask/kyc-controller
Fetches the current session status and reports whether consent was given.
Returns: Whether consentStatus is given.
Handler signature:
() => Promise<boolean>
KycController:hasCompletedVendorDisclaimers
Package: @metamask/kyc-controller
Fetches the current vendor T&C catalog and returns whether every document
is already recorded in KycControllerState.vendorDisclaimersAccepted.
Returns: Whether persisted acceptance covers the fetched catalog.
Handler signature:
() => Promise<boolean>
KycController:launchProviderFlow
Package: @metamask/kyc-controller
Presents the identity-provider verification UI. Currently launches SumSub.
Parameters:
| Name | Description |
|---|---|
params | Optional SDK presentation options. |
params.locale | BCP-47 locale for the SDK UI. |
params.debug | Enables SDK debug logging. |
Returns: The durable provider-flow outcome.
Handler signature:
({ locale, debug, }: {
locale?: string;
debug?: boolean;
}) => Promise<KycProviderFlowStatus>
KycController:readSessionStatus
Package: @metamask/kyc-controller
Returns the persisted session status.
Does not call the network and does not start session-status polling.
Returns: The session on state, or null when none is stored.
Handler signature:
() => KycSessionStatus | null
KycController:recordSessionDisclaimers
Package: @metamask/kyc-controller
Fetches the session-scoped disclaimer catalog and records consents derived from the T&C2 flags. Already-consented catalog rows are omitted from the POST. A 409 is re-checked with a GET: continue only when every accepted document is now consented, otherwise fail closed.
Parameters:
| Name | Description |
|---|---|
params | Accepted session-disclaimer records. |
params.providerDisclaimersAccepted | Accepted Sumsub disclaimer records. |
params.idosDisclaimersAccepted | Accepted idOS disclaimer records. |
params.credentialReusabilityConsentGiven | Whether credential reuse was accepted. |
Handler signature:
(params: {
providerDisclaimersAccepted: KycConsentRecord[];
idosDisclaimersAccepted: KycConsentRecord[];
credentialReusabilityConsentGiven: boolean;
}) => Promise<void>
KycController:recordVendorDisclaimers
Package: @metamask/kyc-controller
Records vendor T&C acceptance via KycService.submitVendorDisclaimers
and persists the accepted ids on state.
Parameters:
| Name | Description |
|---|---|
params | The parameters. |
params.disclaimerIds | Accepted vendor T&C ids. |
Returns: The vendor signing records.
Handler signature:
(params: {
disclaimerIds: string[];
}) => Promise<KycVendorSigning[]>
KycController:refreshSessionStatus
Package: @metamask/kyc-controller
Returns the session already stored on state.
Starts session-status polling when finalStatus is not approved,
rejected, or retry. Does not fetch status or refresh capability
authorization.
Returns: The session status stored at call time.
Handler signature:
() => KycSessionStatus
KycController:reset
Package: @metamask/kyc-controller
Stops session-status polling and restores default controller state.
Handler signature:
() => Promise<void>
KycController:startSession
Package: @metamask/kyc-controller
Starts a KYC session for the given vendor. Reuses a latest vendor session when one exists; otherwise creates a UKYC session.
The verified email stored on controller state comes from the partner
identity token. When that request returns HTTP 422, a stored email is
kept for an existing session. Creating a vendor customer and UKYC session
requires the token, which both requests send as partnerIdentityToken.
Session creation derives client material from the UKYC
local_user_secret. Call ensureLocalUserSecret after the user
has expressed intent to onboard so that secret is generated and stored
before this method runs.
Parameters:
| Name | Description |
|---|---|
params | The session parameters. |
params.vendor | Identity vendor for the session. |
params.aal2Token | AAL2 authentication token. Required only when a UKYC session must be created, where it is sent as the Authorization bearer value. Omit it when reusing an existing session. |
Returns: The current or newly created session status.
Handler signature:
(params: {
vendor: KycVendor;
aal2Token?: string;
}) => Promise<KycSessionStatus>
KycController:startSessionStatusPolling
Package: @metamask/kyc-controller
Starts polling GET /sessions/{id}/status for
KycControllerState.sessionStatus's current id. Each tick writes
the result onto state only when the payload changed. The first poll runs
immediately. Each later wait starts at 10 seconds and grows by 10 seconds
after every poll, including a failed one. Starting the loop again resets
that delay. The loop stops once finalStatus is approved, rejected,
or retry, or when reset / clearState runs.
Handler signature:
() => void