@metamask-previews/kyc-controller 0.13.0-preview-979919367 → 0.13.0-preview-a26804c
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -0
- package/dist/KycController-method-action-types.d.ts +29 -1
- package/dist/KycController-method-action-types.d.ts.map +1 -1
- package/dist/KycController-method-action-types.js.map +1 -1
- package/dist/KycController.d.ts +25 -0
- package/dist/KycController.d.ts.map +1 -1
- package/dist/KycController.js +33 -2
- package/dist/KycController.js.map +1 -1
- package/dist/KycService.d.ts.map +1 -1
- package/dist/KycService.js +17 -3
- package/dist/KycService.js.map +1 -1
- package/dist/index.d.ts +3 -3
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/types.d.ts +52 -2
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +45 -0
- package/dist/types.js.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -9,12 +9,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
9
9
|
|
|
10
10
|
### Added
|
|
11
11
|
|
|
12
|
+
- Add optional `currentStep` to `KycSessionStatus`. Known values are `processing`, `emailOtpCollection`, `phoneOtpCollection`, `capabilityAuthorization`, `kyc`, `approved`, and `rejected` ([#11094](https://github.com/MetaMask/core/pull/11094))
|
|
13
|
+
- `KycService.getSessionStatus`, `KycService.getSessionStatusForVendor`, and `KycService.setAuthorizations` read `currentStep` from the kyc-api session response
|
|
14
|
+
- A missing `currentStep` is left unset. Any other value, including one this package does not know, is returned as sent. Sessions saved before this field existed keep working until the next status fetch
|
|
15
|
+
- Export `KYC_CURRENT_STEPS` and `KycCurrentStep`
|
|
16
|
+
- Add `KycController.ensureLocalUserSecret` and the `KycController:ensureLocalUserSecret` messenger action, which create and store the UKYC `local_user_secret` when one does not already exist ([#11099](https://github.com/MetaMask/core/pull/11099))
|
|
17
|
+
- Call it after the user has expressed intent to onboard and before `startSession`, so secret generation and the Encrypted User Storage write happen before session creation
|
|
18
|
+
- `startSession` still creates the secret when this method has not been called
|
|
19
|
+
- The secret is not returned
|
|
12
20
|
- Add `KycService.getDataShares` and `KycController.getDataShares`, which list the vendors the customer's verified identity data has been shared with, newest first ([#11158](https://github.com/MetaMask/core/pull/11158))
|
|
13
21
|
- `KycService.getDataShares({ externalUserId })` reads `GET /api/kyc/external-user-id/{externalUserId}/shares` on the idOS relay and returns the unwrapped `shares` array. It requires `idosRelayBaseUrl` to be configured
|
|
14
22
|
- `KycController.getDataShares()` takes the external user id from the session status on state, falling back to the latest session for the vendor on state (which it does not write to state), and returns an empty array when no session can be resolved. It stores nothing
|
|
15
23
|
- Both methods are exposed as the `KycService:getDataShares` and `KycController:getDataShares` messenger actions
|
|
16
24
|
- Export the `KycDataShare` and `GetDataSharesParams` types and the `KycServiceGetDataSharesAction` and `KycControllerGetDataSharesAction` action types ([#11158](https://github.com/MetaMask/core/pull/11158))
|
|
17
25
|
|
|
26
|
+
### Changed
|
|
27
|
+
|
|
28
|
+
- When a kyc-api session reports `finalStatus` `pending` and `currentStep` `kyc`, the session returned by those endpoints uses `finalStatus` `new`. Every other `finalStatus` is returned unchanged. This resolves a regression where `finalStatus: pending` originally was only possible after sumsub was fully submitted, but now it is possible when partially submitted. ([#11094](https://github.com/MetaMask/core/pull/11094))
|
|
29
|
+
- After the SumSub SDK completes, the stored session is `finalStatus` `pending` with `currentStep` `processing`
|
|
30
|
+
|
|
18
31
|
## [0.13.0]
|
|
19
32
|
|
|
20
33
|
### Added
|
|
@@ -3,6 +3,29 @@
|
|
|
3
3
|
* Do not edit manually.
|
|
4
4
|
*/
|
|
5
5
|
import type { KycController } from './KycController.js';
|
|
6
|
+
/**
|
|
7
|
+
* Creates the UKYC `local_user_secret` and stores it in Encrypted User
|
|
8
|
+
* Storage when one does not already exist.
|
|
9
|
+
*
|
|
10
|
+
* Call this after the user has expressed intent to onboard and before
|
|
11
|
+
* {@link startSession}. Persisting the secret here moves generation and the
|
|
12
|
+
* storage write off the `startSession` path. `startSession` still reads the
|
|
13
|
+
* secret, and still creates it when this has not been called.
|
|
14
|
+
*
|
|
15
|
+
* Await this call, or attach a rejection handler. A failure does not block
|
|
16
|
+
* onboarding: {@link startSession} creates the secret if it is still missing.
|
|
17
|
+
*
|
|
18
|
+
* The operation is idempotent and uses the same primary entropy source as
|
|
19
|
+
* session creation. The plaintext secret is not returned and is not sent to
|
|
20
|
+
* idOS. Only the encrypted User Storage copy is synced.
|
|
21
|
+
*
|
|
22
|
+
* @throws When Encrypted User Storage cannot be read or written, or when a
|
|
23
|
+
* stored secret has an unexpected length.
|
|
24
|
+
*/
|
|
25
|
+
export type KycControllerEnsureLocalUserSecretAction = {
|
|
26
|
+
type: `KycController:ensureLocalUserSecret`;
|
|
27
|
+
handler: KycController['ensureLocalUserSecret'];
|
|
28
|
+
};
|
|
6
29
|
/**
|
|
7
30
|
* Starts a KYC session for the given vendor. Reuses a latest vendor session
|
|
8
31
|
* when one exists; otherwise creates a UKYC session.
|
|
@@ -12,6 +35,11 @@ import type { KycController } from './KycController.js';
|
|
|
12
35
|
* kept for an existing session. Creating a vendor customer and UKYC session
|
|
13
36
|
* requires the token, which both requests send as `partnerIdentityToken`.
|
|
14
37
|
*
|
|
38
|
+
* Session creation derives client material from the UKYC
|
|
39
|
+
* `local_user_secret`. Call {@link ensureLocalUserSecret} after the user
|
|
40
|
+
* has expressed intent to onboard so that secret is generated and stored
|
|
41
|
+
* before this method runs.
|
|
42
|
+
*
|
|
15
43
|
* @param params - The session parameters.
|
|
16
44
|
* @param params.vendor - Identity vendor for the session.
|
|
17
45
|
* @param params.aal2Token - AAL2 authentication token. Required only when a
|
|
@@ -225,5 +253,5 @@ export type KycControllerLaunchProviderFlowAction = {
|
|
|
225
253
|
/**
|
|
226
254
|
* Union of all KycController action types.
|
|
227
255
|
*/
|
|
228
|
-
export type KycControllerMethodActions = KycControllerStartSessionAction | KycControllerResetAction | KycControllerClearStateAction | KycControllerGetSessionStatusForVendorAction | KycControllerGetDataSharesAction | KycControllerGetProviderFlowStatusAction | KycControllerRefreshSessionStatusAction | KycControllerReadSessionStatusAction | KycControllerFetchSessionStatusOnceAction | KycControllerStartSessionStatusPollingAction | KycControllerFetchSessionDisclaimersAction | KycControllerRecordSessionDisclaimersAction | KycControllerHasCompletedSessionDisclaimersAction | KycControllerFetchVendorDisclaimersAction | KycControllerRecordVendorDisclaimersAction | KycControllerHasCompletedVendorDisclaimersAction | KycControllerLaunchProviderFlowAction;
|
|
256
|
+
export type KycControllerMethodActions = KycControllerEnsureLocalUserSecretAction | KycControllerStartSessionAction | KycControllerResetAction | KycControllerClearStateAction | KycControllerGetSessionStatusForVendorAction | KycControllerGetDataSharesAction | KycControllerGetProviderFlowStatusAction | KycControllerRefreshSessionStatusAction | KycControllerReadSessionStatusAction | KycControllerFetchSessionStatusOnceAction | KycControllerStartSessionStatusPollingAction | KycControllerFetchSessionDisclaimersAction | KycControllerRecordSessionDisclaimersAction | KycControllerHasCompletedSessionDisclaimersAction | KycControllerFetchVendorDisclaimersAction | KycControllerRecordVendorDisclaimersAction | KycControllerHasCompletedVendorDisclaimersAction | KycControllerLaunchProviderFlowAction;
|
|
229
257
|
//# sourceMappingURL=KycController-method-action-types.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KycController-method-action-types.d.ts","sourceRoot":"","sources":["../src/KycController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD
|
|
1
|
+
{"version":3,"file":"KycController-method-action-types.d.ts","sourceRoot":"","sources":["../src/KycController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAExD;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,wCAAwC,GAAG;I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;;;;;;GAOG;AACH,MAAM,MAAM,qCAAqC,GAAG;IAClD,IAAI,EAAE,kCAAkC,CAAC;IACzC,OAAO,EAAE,aAAa,CAAC,oBAAoB,CAAC,CAAC;CAC9C,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,wCAAwC,GACxC,+BAA+B,GAC/B,wBAAwB,GACxB,6BAA6B,GAC7B,4CAA4C,GAC5C,gCAAgC,GAChC,wCAAwC,GACxC,uCAAuC,GACvC,oCAAoC,GACpC,yCAAyC,GACzC,4CAA4C,GAC5C,0CAA0C,GAC1C,2CAA2C,GAC3C,iDAAiD,GACjD,yCAAyC,GACzC,0CAA0C,GAC1C,gDAAgD,GAChD,qCAAqC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KycController-method-action-types.js","sourceRoot":"","sources":["../src/KycController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { KycController } from './KycController.js';\n\n/**\n * Starts a KYC session for the given vendor. Reuses a latest vendor session\n * when one exists; otherwise creates a UKYC session.\n *\n * The verified email stored on controller state comes from the partner\n * identity token. When that request returns HTTP 422, a stored email is\n * kept for an existing session. Creating a vendor customer and UKYC session\n * requires the token, which both requests send as `partnerIdentityToken`.\n *\n * @param params - The session parameters.\n * @param params.vendor - Identity vendor for the session.\n * @param params.aal2Token - AAL2 authentication token. Required only when a\n * UKYC session must be created, where it is sent as the Authorization bearer\n * value. Omit it when reusing an existing session.\n * @returns The current or newly created session status.\n */\nexport type KycControllerStartSessionAction = {\n type: `KycController:startSession`;\n handler: KycController['startSession'];\n};\n\n/**\n * Stops session-status polling and restores default controller state.\n */\nexport type KycControllerResetAction = {\n type: `KycController:reset`;\n handler: KycController['reset'];\n};\n\n/**\n * Restores the controller to its default state.\n */\nexport type KycControllerClearStateAction = {\n type: `KycController:clearState`;\n handler: KycController['clearState'];\n};\n\n/**\n * Fetches the latest UKYC session status for a vendor.\n *\n * @param vendor - Identity vendor whose latest session should be queried.\n * @returns The session status, or `null` when none exists.\n */\nexport type KycControllerGetSessionStatusForVendorAction = {\n type: `KycController:getSessionStatusForVendor`;\n handler: KycController['getSessionStatusForVendor'];\n};\n\n/**\n * Fetches the vendors this customer's verified identity data has been shared\n * with, newest first.\n *\n * The external user id comes from the session status on state. When no\n * session has been stored yet, the latest session for the vendor on state is\n * fetched first (without writing it to state). An unresolvable session — no\n * vendor on state, or no latest session for it — yields an empty list rather\n * than an error, so consumers can render an empty \"shared with\" list.\n *\n * @returns The data shares, newest first; empty when no session can be\n * resolved.\n */\nexport type KycControllerGetDataSharesAction = {\n type: `KycController:getDataShares`;\n handler: KycController['getDataShares'];\n};\n\n/**\n * Returns the durable outcome of the identity-provider flow.\n *\n * @returns The latest provider-flow status.\n */\nexport type KycControllerGetProviderFlowStatusAction = {\n type: `KycController:getProviderFlowStatus`;\n handler: KycController['getProviderFlowStatus'];\n};\n\n/**\n * Returns the session already stored on state.\n *\n * Starts session-status polling when `finalStatus` is not `approved`,\n * `rejected`, or `retry`. Does not fetch status or refresh capability\n * authorization.\n *\n * @returns The session status stored at call time.\n * @throws If there is no session on state.\n */\nexport type KycControllerRefreshSessionStatusAction = {\n type: `KycController:refreshSessionStatus`;\n handler: KycController['refreshSessionStatus'];\n};\n\n/**\n * Returns the persisted session status.\n *\n * Does not call the network and does not start session-status polling.\n *\n * @returns The session on state, or `null` when none is stored.\n */\nexport type KycControllerReadSessionStatusAction = {\n type: `KycController:readSessionStatus`;\n handler: KycController['readSessionStatus'];\n};\n\n/**\n * Fetches `GET /sessions/{id}/status` once and writes the result onto state.\n *\n * Does not start the session-status polling timer.\n *\n * @param sessionId - UKYC session id.\n * @returns The fetched session status.\n */\nexport type KycControllerFetchSessionStatusOnceAction = {\n type: `KycController:fetchSessionStatusOnce`;\n handler: KycController['fetchSessionStatusOnce'];\n};\n\n/**\n * Starts polling `GET /sessions/{id}/status` for\n * {@link KycControllerState.sessionStatus}'s current `id`. Each tick writes\n * the result onto state only when the payload changed. The first poll runs\n * immediately. Each later wait starts at 10 seconds and grows by 10 seconds\n * after every poll, including a failed one. Starting the loop again resets\n * that delay. The loop stops once `finalStatus` is `approved`, `rejected`,\n * or `retry`, or when {@link reset} / {@link clearState} runs.\n *\n * @throws If there is no current session id to poll.\n */\nexport type KycControllerStartSessionStatusPollingAction = {\n type: `KycController:startSessionStatusPolling`;\n handler: KycController['startSessionStatusPolling'];\n};\n\n/**\n * Fetches the idOS + KYC-provider disclaimer catalog. Pass exactly one of\n * `sessionId` or `country`:\n *\n * - `{ sessionId }` → {@link KycService.fetchSessionDisclaimersBySessionId}\n * (`GET /sessions/{sessionId}/disclaimers`)\n * - `{ country }` → {@link KycService.fetchSessionDisclaimersByCountry}\n * (`GET /disclaimers?country=`)\n *\n * A session-id fetch also writes the catalog to `sessionDisclaimers`.\n *\n * @param params - The parameters. Provide exactly one of `sessionId` or\n * `country`.\n * @param params.sessionId - The UKYC session id.\n * @param params.country - ISO 3166-1 alpha-3 country code.\n * @returns The catalog. Session fetches include consent state; country\n * fetches do not.\n */\nexport type KycControllerFetchSessionDisclaimersAction = {\n type: `KycController:fetchSessionDisclaimers`;\n handler: KycController['fetchSessionDisclaimers'];\n};\n\n/**\n * Fetches the session-scoped disclaimer catalog and records consents\n * derived from the T&C2 flags. Already-consented catalog rows are omitted\n * from the POST. A 409 is re-checked with a GET: continue only when every\n * accepted document is now consented, otherwise fail closed.\n *\n * @param params - Accepted session-disclaimer records.\n * @param params.providerDisclaimersAccepted - Accepted Sumsub disclaimer records.\n * @param params.idosDisclaimersAccepted - Accepted idOS disclaimer records.\n * @param params.credentialReusabilityConsentGiven - Whether credential\n * reuse was accepted.\n */\nexport type KycControllerRecordSessionDisclaimersAction = {\n type: `KycController:recordSessionDisclaimers`;\n handler: KycController['recordSessionDisclaimers'];\n};\n\n/**\n * Fetches the current session status and reports whether consent was given.\n *\n * @returns Whether `consentStatus` is `given`.\n * @throws If there is no session on state.\n */\nexport type KycControllerHasCompletedSessionDisclaimersAction = {\n type: `KycController:hasCompletedSessionDisclaimers`;\n handler: KycController['hasCompletedSessionDisclaimers'];\n};\n\n/**\n * Fetches the vendor T&Cs the customer must accept before a session is\n * created (`GET /vendors/{vendor}/disclaimers?country=`).\n *\n * @param params - The parameters.\n * @param params.vendor - Identity vendor. Defaults to `moonpay`.\n * @param params.country - ISO 3166-1 alpha-3 country code.\n * @returns The disclaimers.\n */\nexport type KycControllerFetchVendorDisclaimersAction = {\n type: `KycController:fetchVendorDisclaimers`;\n handler: KycController['fetchVendorDisclaimers'];\n};\n\n/**\n * Records vendor T&C acceptance via {@link KycService.submitVendorDisclaimers}\n * and persists the accepted ids on state.\n *\n * @param params - The parameters.\n * @param params.disclaimerIds - Accepted vendor T&C ids.\n * @returns The vendor signing records.\n * @throws If `vendor` is missing from state.\n */\nexport type KycControllerRecordVendorDisclaimersAction = {\n type: `KycController:recordVendorDisclaimers`;\n handler: KycController['recordVendorDisclaimers'];\n};\n\n/**\n * Fetches the current vendor T&C catalog and returns whether every document\n * is already recorded in {@link KycControllerState.vendorDisclaimersAccepted}.\n *\n * @returns Whether persisted acceptance covers the fetched catalog.\n * @throws If `vendor` or `geoCountry` is missing from state.\n */\nexport type KycControllerHasCompletedVendorDisclaimersAction = {\n type: `KycController:hasCompletedVendorDisclaimers`;\n handler: KycController['hasCompletedVendorDisclaimers'];\n};\n\n/**\n * Presents the identity-provider verification UI. Currently launches SumSub.\n *\n * @param params - Optional SDK presentation options.\n * @param params.locale - BCP-47 locale for the SDK UI.\n * @param params.debug - Enables SDK debug logging.\n * @returns The durable provider-flow outcome.\n */\nexport type KycControllerLaunchProviderFlowAction = {\n type: `KycController:launchProviderFlow`;\n handler: KycController['launchProviderFlow'];\n};\n\n/**\n * Union of all KycController action types.\n */\nexport type KycControllerMethodActions =\n | KycControllerStartSessionAction\n | KycControllerResetAction\n | KycControllerClearStateAction\n | KycControllerGetSessionStatusForVendorAction\n | KycControllerGetDataSharesAction\n | KycControllerGetProviderFlowStatusAction\n | KycControllerRefreshSessionStatusAction\n | KycControllerReadSessionStatusAction\n | KycControllerFetchSessionStatusOnceAction\n | KycControllerStartSessionStatusPollingAction\n | KycControllerFetchSessionDisclaimersAction\n | KycControllerRecordSessionDisclaimersAction\n | KycControllerHasCompletedSessionDisclaimersAction\n | KycControllerFetchVendorDisclaimersAction\n | KycControllerRecordVendorDisclaimersAction\n | KycControllerHasCompletedVendorDisclaimersAction\n | KycControllerLaunchProviderFlowAction;\n"]}
|
|
1
|
+
{"version":3,"file":"KycController-method-action-types.js","sourceRoot":"","sources":["../src/KycController-method-action-types.ts"],"names":[],"mappings":"AAAA;;;GAGG","sourcesContent":["/**\n * This file is auto generated.\n * Do not edit manually.\n */\n\nimport type { KycController } from './KycController.js';\n\n/**\n * Creates the UKYC `local_user_secret` and stores it in Encrypted User\n * Storage when one does not already exist.\n *\n * Call this after the user has expressed intent to onboard and before\n * {@link startSession}. Persisting the secret here moves generation and the\n * storage write off the `startSession` path. `startSession` still reads the\n * secret, and still creates it when this has not been called.\n *\n * Await this call, or attach a rejection handler. A failure does not block\n * onboarding: {@link startSession} creates the secret if it is still missing.\n *\n * The operation is idempotent and uses the same primary entropy source as\n * session creation. The plaintext secret is not returned and is not sent to\n * idOS. Only the encrypted User Storage copy is synced.\n *\n * @throws When Encrypted User Storage cannot be read or written, or when a\n * stored secret has an unexpected length.\n */\nexport type KycControllerEnsureLocalUserSecretAction = {\n type: `KycController:ensureLocalUserSecret`;\n handler: KycController['ensureLocalUserSecret'];\n};\n\n/**\n * Starts a KYC session for the given vendor. Reuses a latest vendor session\n * when one exists; otherwise creates a UKYC session.\n *\n * The verified email stored on controller state comes from the partner\n * identity token. When that request returns HTTP 422, a stored email is\n * kept for an existing session. Creating a vendor customer and UKYC session\n * requires the token, which both requests send as `partnerIdentityToken`.\n *\n * Session creation derives client material from the UKYC\n * `local_user_secret`. Call {@link ensureLocalUserSecret} after the user\n * has expressed intent to onboard so that secret is generated and stored\n * before this method runs.\n *\n * @param params - The session parameters.\n * @param params.vendor - Identity vendor for the session.\n * @param params.aal2Token - AAL2 authentication token. Required only when a\n * UKYC session must be created, where it is sent as the Authorization bearer\n * value. Omit it when reusing an existing session.\n * @returns The current or newly created session status.\n */\nexport type KycControllerStartSessionAction = {\n type: `KycController:startSession`;\n handler: KycController['startSession'];\n};\n\n/**\n * Stops session-status polling and restores default controller state.\n */\nexport type KycControllerResetAction = {\n type: `KycController:reset`;\n handler: KycController['reset'];\n};\n\n/**\n * Restores the controller to its default state.\n */\nexport type KycControllerClearStateAction = {\n type: `KycController:clearState`;\n handler: KycController['clearState'];\n};\n\n/**\n * Fetches the latest UKYC session status for a vendor.\n *\n * @param vendor - Identity vendor whose latest session should be queried.\n * @returns The session status, or `null` when none exists.\n */\nexport type KycControllerGetSessionStatusForVendorAction = {\n type: `KycController:getSessionStatusForVendor`;\n handler: KycController['getSessionStatusForVendor'];\n};\n\n/**\n * Fetches the vendors this customer's verified identity data has been shared\n * with, newest first.\n *\n * The external user id comes from the session status on state. When no\n * session has been stored yet, the latest session for the vendor on state is\n * fetched first (without writing it to state). An unresolvable session — no\n * vendor on state, or no latest session for it — yields an empty list rather\n * than an error, so consumers can render an empty \"shared with\" list.\n *\n * @returns The data shares, newest first; empty when no session can be\n * resolved.\n */\nexport type KycControllerGetDataSharesAction = {\n type: `KycController:getDataShares`;\n handler: KycController['getDataShares'];\n};\n\n/**\n * Returns the durable outcome of the identity-provider flow.\n *\n * @returns The latest provider-flow status.\n */\nexport type KycControllerGetProviderFlowStatusAction = {\n type: `KycController:getProviderFlowStatus`;\n handler: KycController['getProviderFlowStatus'];\n};\n\n/**\n * Returns the session already stored on state.\n *\n * Starts session-status polling when `finalStatus` is not `approved`,\n * `rejected`, or `retry`. Does not fetch status or refresh capability\n * authorization.\n *\n * @returns The session status stored at call time.\n * @throws If there is no session on state.\n */\nexport type KycControllerRefreshSessionStatusAction = {\n type: `KycController:refreshSessionStatus`;\n handler: KycController['refreshSessionStatus'];\n};\n\n/**\n * Returns the persisted session status.\n *\n * Does not call the network and does not start session-status polling.\n *\n * @returns The session on state, or `null` when none is stored.\n */\nexport type KycControllerReadSessionStatusAction = {\n type: `KycController:readSessionStatus`;\n handler: KycController['readSessionStatus'];\n};\n\n/**\n * Fetches `GET /sessions/{id}/status` once and writes the result onto state.\n *\n * Does not start the session-status polling timer.\n *\n * @param sessionId - UKYC session id.\n * @returns The fetched session status.\n */\nexport type KycControllerFetchSessionStatusOnceAction = {\n type: `KycController:fetchSessionStatusOnce`;\n handler: KycController['fetchSessionStatusOnce'];\n};\n\n/**\n * Starts polling `GET /sessions/{id}/status` for\n * {@link KycControllerState.sessionStatus}'s current `id`. Each tick writes\n * the result onto state only when the payload changed. The first poll runs\n * immediately. Each later wait starts at 10 seconds and grows by 10 seconds\n * after every poll, including a failed one. Starting the loop again resets\n * that delay. The loop stops once `finalStatus` is `approved`, `rejected`,\n * or `retry`, or when {@link reset} / {@link clearState} runs.\n *\n * @throws If there is no current session id to poll.\n */\nexport type KycControllerStartSessionStatusPollingAction = {\n type: `KycController:startSessionStatusPolling`;\n handler: KycController['startSessionStatusPolling'];\n};\n\n/**\n * Fetches the idOS + KYC-provider disclaimer catalog. Pass exactly one of\n * `sessionId` or `country`:\n *\n * - `{ sessionId }` → {@link KycService.fetchSessionDisclaimersBySessionId}\n * (`GET /sessions/{sessionId}/disclaimers`)\n * - `{ country }` → {@link KycService.fetchSessionDisclaimersByCountry}\n * (`GET /disclaimers?country=`)\n *\n * A session-id fetch also writes the catalog to `sessionDisclaimers`.\n *\n * @param params - The parameters. Provide exactly one of `sessionId` or\n * `country`.\n * @param params.sessionId - The UKYC session id.\n * @param params.country - ISO 3166-1 alpha-3 country code.\n * @returns The catalog. Session fetches include consent state; country\n * fetches do not.\n */\nexport type KycControllerFetchSessionDisclaimersAction = {\n type: `KycController:fetchSessionDisclaimers`;\n handler: KycController['fetchSessionDisclaimers'];\n};\n\n/**\n * Fetches the session-scoped disclaimer catalog and records consents\n * derived from the T&C2 flags. Already-consented catalog rows are omitted\n * from the POST. A 409 is re-checked with a GET: continue only when every\n * accepted document is now consented, otherwise fail closed.\n *\n * @param params - Accepted session-disclaimer records.\n * @param params.providerDisclaimersAccepted - Accepted Sumsub disclaimer records.\n * @param params.idosDisclaimersAccepted - Accepted idOS disclaimer records.\n * @param params.credentialReusabilityConsentGiven - Whether credential\n * reuse was accepted.\n */\nexport type KycControllerRecordSessionDisclaimersAction = {\n type: `KycController:recordSessionDisclaimers`;\n handler: KycController['recordSessionDisclaimers'];\n};\n\n/**\n * Fetches the current session status and reports whether consent was given.\n *\n * @returns Whether `consentStatus` is `given`.\n * @throws If there is no session on state.\n */\nexport type KycControllerHasCompletedSessionDisclaimersAction = {\n type: `KycController:hasCompletedSessionDisclaimers`;\n handler: KycController['hasCompletedSessionDisclaimers'];\n};\n\n/**\n * Fetches the vendor T&Cs the customer must accept before a session is\n * created (`GET /vendors/{vendor}/disclaimers?country=`).\n *\n * @param params - The parameters.\n * @param params.vendor - Identity vendor. Defaults to `moonpay`.\n * @param params.country - ISO 3166-1 alpha-3 country code.\n * @returns The disclaimers.\n */\nexport type KycControllerFetchVendorDisclaimersAction = {\n type: `KycController:fetchVendorDisclaimers`;\n handler: KycController['fetchVendorDisclaimers'];\n};\n\n/**\n * Records vendor T&C acceptance via {@link KycService.submitVendorDisclaimers}\n * and persists the accepted ids on state.\n *\n * @param params - The parameters.\n * @param params.disclaimerIds - Accepted vendor T&C ids.\n * @returns The vendor signing records.\n * @throws If `vendor` is missing from state.\n */\nexport type KycControllerRecordVendorDisclaimersAction = {\n type: `KycController:recordVendorDisclaimers`;\n handler: KycController['recordVendorDisclaimers'];\n};\n\n/**\n * Fetches the current vendor T&C catalog and returns whether every document\n * is already recorded in {@link KycControllerState.vendorDisclaimersAccepted}.\n *\n * @returns Whether persisted acceptance covers the fetched catalog.\n * @throws If `vendor` or `geoCountry` is missing from state.\n */\nexport type KycControllerHasCompletedVendorDisclaimersAction = {\n type: `KycController:hasCompletedVendorDisclaimers`;\n handler: KycController['hasCompletedVendorDisclaimers'];\n};\n\n/**\n * Presents the identity-provider verification UI. Currently launches SumSub.\n *\n * @param params - Optional SDK presentation options.\n * @param params.locale - BCP-47 locale for the SDK UI.\n * @param params.debug - Enables SDK debug logging.\n * @returns The durable provider-flow outcome.\n */\nexport type KycControllerLaunchProviderFlowAction = {\n type: `KycController:launchProviderFlow`;\n handler: KycController['launchProviderFlow'];\n};\n\n/**\n * Union of all KycController action types.\n */\nexport type KycControllerMethodActions =\n | KycControllerEnsureLocalUserSecretAction\n | KycControllerStartSessionAction\n | KycControllerResetAction\n | KycControllerClearStateAction\n | KycControllerGetSessionStatusForVendorAction\n | KycControllerGetDataSharesAction\n | KycControllerGetProviderFlowStatusAction\n | KycControllerRefreshSessionStatusAction\n | KycControllerReadSessionStatusAction\n | KycControllerFetchSessionStatusOnceAction\n | KycControllerStartSessionStatusPollingAction\n | KycControllerFetchSessionDisclaimersAction\n | KycControllerRecordSessionDisclaimersAction\n | KycControllerHasCompletedSessionDisclaimersAction\n | KycControllerFetchVendorDisclaimersAction\n | KycControllerRecordVendorDisclaimersAction\n | KycControllerHasCompletedVendorDisclaimersAction\n | KycControllerLaunchProviderFlowAction;\n"]}
|
package/dist/KycController.d.ts
CHANGED
|
@@ -134,6 +134,26 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
134
134
|
* @param options.trackKycAnalytics - Optional callbacks that record KYC analytics.
|
|
135
135
|
*/
|
|
136
136
|
constructor({ messenger, state, sumsubLauncher, trackKycAnalytics, }: KycControllerOptions);
|
|
137
|
+
/**
|
|
138
|
+
* Creates the UKYC `local_user_secret` and stores it in Encrypted User
|
|
139
|
+
* Storage when one does not already exist.
|
|
140
|
+
*
|
|
141
|
+
* Call this after the user has expressed intent to onboard and before
|
|
142
|
+
* {@link startSession}. Persisting the secret here moves generation and the
|
|
143
|
+
* storage write off the `startSession` path. `startSession` still reads the
|
|
144
|
+
* secret, and still creates it when this has not been called.
|
|
145
|
+
*
|
|
146
|
+
* Await this call, or attach a rejection handler. A failure does not block
|
|
147
|
+
* onboarding: {@link startSession} creates the secret if it is still missing.
|
|
148
|
+
*
|
|
149
|
+
* The operation is idempotent and uses the same primary entropy source as
|
|
150
|
+
* session creation. The plaintext secret is not returned and is not sent to
|
|
151
|
+
* idOS. Only the encrypted User Storage copy is synced.
|
|
152
|
+
*
|
|
153
|
+
* @throws When Encrypted User Storage cannot be read or written, or when a
|
|
154
|
+
* stored secret has an unexpected length.
|
|
155
|
+
*/
|
|
156
|
+
ensureLocalUserSecret(): Promise<void>;
|
|
137
157
|
/**
|
|
138
158
|
* Starts a KYC session for the given vendor. Reuses a latest vendor session
|
|
139
159
|
* when one exists; otherwise creates a UKYC session.
|
|
@@ -143,6 +163,11 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
143
163
|
* kept for an existing session. Creating a vendor customer and UKYC session
|
|
144
164
|
* requires the token, which both requests send as `partnerIdentityToken`.
|
|
145
165
|
*
|
|
166
|
+
* Session creation derives client material from the UKYC
|
|
167
|
+
* `local_user_secret`. Call {@link ensureLocalUserSecret} after the user
|
|
168
|
+
* has expressed intent to onboard so that secret is generated and stored
|
|
169
|
+
* before this method runs.
|
|
170
|
+
*
|
|
146
171
|
* @param params - The session parameters.
|
|
147
172
|
* @param params.vendor - Identity vendor for the session.
|
|
148
173
|
* @param params.aal2Token - AAL2 authentication token. Required only when a
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"KycController.d.ts","sourceRoot":"","sources":["../src/KycController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,8DAA8D,EAE/D,MAAM,sCAAsC,CAAC;AAC9C,OAAO,KAAK,EACV,wBAAwB,EACxB,0BAA0B,EAE3B,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,S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AAuB,CAAC,MAAM,EAAE;QACpC,aAAa,EAAE,MAAM,EAAE,CAAC;KACzB,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC,CA+B9B;IAED;;;;;;OAMG;IACG,6BAA6B,IAAI,OAAO,CAAC,OAAO,CAAC,CAmBtD;IAED;;;;;;;OAOG;IACH,kBAAkB,CAAC,EACjB,MAAM,EACN,KAAK,GACN,EAAE;QACD,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,KAAK,CAAC,EAAE,OAAO,CAAC;KACjB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAGjC;CA6MF"}
|
package/dist/KycController.js
CHANGED
|
@@ -6,7 +6,7 @@ import { toBase64Url } from './encoding.js';
|
|
|
6
6
|
import { getEmailFromPartnerIdentityToken, isEmailRequiredError, } from './partnerIdentityToken.js';
|
|
7
7
|
import { isSumSubFlowCompleted, isSumSubFlowFailed, } from './providers/sumsub.js';
|
|
8
8
|
import { consentRecordsFromAcceptedList } from './sessionDisclaimers.js';
|
|
9
|
-
import { needsCapabilityAuthorizationRefresh, FINAL_STATUSES_TO_STOP_POLLING, } from './types.js';
|
|
9
|
+
import { needsCapabilityAuthorizationRefresh, FINAL_STATUSES_TO_STOP_POLLING, KYC_CURRENT_STEPS, KYC_STATUSES, } from './types.js';
|
|
10
10
|
import { deriveClientMaterial } from './ukyc/deriveClientMaterial.js';
|
|
11
11
|
import { assertAttestedServerPublicKey } from './ukyc/jwtChain.js';
|
|
12
12
|
import { getOrCreateLocalUserSecret, UkycLocalUserSecretStore, } from './ukyc/localUserSecret.js';
|
|
@@ -121,6 +121,7 @@ export function getDefaultKycControllerState() {
|
|
|
121
121
|
}
|
|
122
122
|
// === MESSENGER ===
|
|
123
123
|
const MESSENGER_EXPOSED_METHODS = [
|
|
124
|
+
'ensureLocalUserSecret',
|
|
124
125
|
'startSession',
|
|
125
126
|
'reset',
|
|
126
127
|
'clearState',
|
|
@@ -206,6 +207,28 @@ export class KycController extends BaseController {
|
|
|
206
207
|
email: getEmailFromPartnerIdentityToken(partnerIdentityToken),
|
|
207
208
|
};
|
|
208
209
|
}
|
|
210
|
+
/**
|
|
211
|
+
* Creates the UKYC `local_user_secret` and stores it in Encrypted User
|
|
212
|
+
* Storage when one does not already exist.
|
|
213
|
+
*
|
|
214
|
+
* Call this after the user has expressed intent to onboard and before
|
|
215
|
+
* {@link startSession}. Persisting the secret here moves generation and the
|
|
216
|
+
* storage write off the `startSession` path. `startSession` still reads the
|
|
217
|
+
* secret, and still creates it when this has not been called.
|
|
218
|
+
*
|
|
219
|
+
* Await this call, or attach a rejection handler. A failure does not block
|
|
220
|
+
* onboarding: {@link startSession} creates the secret if it is still missing.
|
|
221
|
+
*
|
|
222
|
+
* The operation is idempotent and uses the same primary entropy source as
|
|
223
|
+
* session creation. The plaintext secret is not returned and is not sent to
|
|
224
|
+
* idOS. Only the encrypted User Storage copy is synced.
|
|
225
|
+
*
|
|
226
|
+
* @throws When Encrypted User Storage cannot be read or written, or when a
|
|
227
|
+
* stored secret has an unexpected length.
|
|
228
|
+
*/
|
|
229
|
+
async ensureLocalUserSecret() {
|
|
230
|
+
await getOrCreateLocalUserSecret(this.#localUserSecretStore);
|
|
231
|
+
}
|
|
209
232
|
/**
|
|
210
233
|
* Starts a KYC session for the given vendor. Reuses a latest vendor session
|
|
211
234
|
* when one exists; otherwise creates a UKYC session.
|
|
@@ -215,6 +238,11 @@ export class KycController extends BaseController {
|
|
|
215
238
|
* kept for an existing session. Creating a vendor customer and UKYC session
|
|
216
239
|
* requires the token, which both requests send as `partnerIdentityToken`.
|
|
217
240
|
*
|
|
241
|
+
* Session creation derives client material from the UKYC
|
|
242
|
+
* `local_user_secret`. Call {@link ensureLocalUserSecret} after the user
|
|
243
|
+
* has expressed intent to onboard so that secret is generated and stored
|
|
244
|
+
* before this method runs.
|
|
245
|
+
*
|
|
218
246
|
* @param params - The session parameters.
|
|
219
247
|
* @param params.vendor - Identity vendor for the session.
|
|
220
248
|
* @param params.aal2Token - AAL2 authentication token. Required only when a
|
|
@@ -912,7 +940,10 @@ export class KycController extends BaseController {
|
|
|
912
940
|
this.#recordLaunchOutcomeAndTrackAnalytics('submitted', (state) => {
|
|
913
941
|
state.sessionStatus = {
|
|
914
942
|
...currentSessionStatus,
|
|
915
|
-
finalStatus:
|
|
943
|
+
finalStatus: KYC_STATUSES.pending,
|
|
944
|
+
// The applicant has submitted documents, so the session is in
|
|
945
|
+
// vendor processing rather than still on the `kyc` step.
|
|
946
|
+
currentStep: KYC_CURRENT_STEPS.processing,
|
|
916
947
|
};
|
|
917
948
|
state.providerFlowStatus = 'submitted';
|
|
918
949
|
});
|