@metamask-previews/kyc-controller 0.14.0-preview-30e373da1 → 0.14.0-preview-770db011a
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 +8 -0
- package/dist/KycController-method-action-types.d.ts +13 -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 +9 -0
- package/dist/KycController.d.ts.map +1 -1
- package/dist/KycController.js +101 -5
- package/dist/KycController.js.map +1 -1
- package/dist/KycService-method-action-types.d.ts +32 -1
- package/dist/KycService-method-action-types.d.ts.map +1 -1
- package/dist/KycService-method-action-types.js.map +1 -1
- package/dist/KycService.d.ts +87 -0
- package/dist/KycService.d.ts.map +1 -1
- package/dist/KycService.js +48 -0
- 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.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
### Added
|
|
11
|
+
|
|
12
|
+
- Add `KycController.deleteEncryptedStorage`, which deletes the caller's encrypted KYC blobs ([#11262](https://github.com/MetaMask/core/pull/11262))
|
|
13
|
+
- `KycService.createDeletion` posts `POST /deletions` with a fresh client public key and returns `deletionId` plus the `ukycCapabilityToken` wrapping key
|
|
14
|
+
- The controller mints a client-presented `delete`-scoped uKYC capability token with a 4 hour lifetime, wraps it with that key, and `KycService.completeDeletion` sends it to `DELETE /deletions/{deletionId}`
|
|
15
|
+
- Both service methods are exposed as the `KycService:createDeletion` and `KycService:completeDeletion` messenger actions, and the controller method as `KycController:deleteEncryptedStorage`
|
|
16
|
+
- Controller state is left unchanged
|
|
17
|
+
|
|
10
18
|
## [0.14.0]
|
|
11
19
|
|
|
12
20
|
### Added
|
|
@@ -238,6 +238,18 @@ export type KycControllerHasCompletedVendorDisclaimersAction = {
|
|
|
238
238
|
type: `KycController:hasCompletedVendorDisclaimers`;
|
|
239
239
|
handler: KycController['hasCompletedVendorDisclaimers'];
|
|
240
240
|
};
|
|
241
|
+
/**
|
|
242
|
+
* Deletes the caller's encrypted KYC blobs from MetaMask servers.
|
|
243
|
+
*
|
|
244
|
+
* Mints a fresh X25519 keypair, fetches a wrapping key from
|
|
245
|
+
* `POST /deletions`, seals a `delete`-scoped `ukyc_capability_token` (4 hour
|
|
246
|
+
* lifetime, client-presented) for that key, and submits it to
|
|
247
|
+
* `DELETE /deletions/{deletionId}`. Does not clear controller state.
|
|
248
|
+
*/
|
|
249
|
+
export type KycControllerDeleteEncryptedStorageAction = {
|
|
250
|
+
type: `KycController:deleteEncryptedStorage`;
|
|
251
|
+
handler: KycController['deleteEncryptedStorage'];
|
|
252
|
+
};
|
|
241
253
|
/**
|
|
242
254
|
* Presents the identity-provider verification UI. Currently launches SumSub.
|
|
243
255
|
*
|
|
@@ -253,5 +265,5 @@ export type KycControllerLaunchProviderFlowAction = {
|
|
|
253
265
|
/**
|
|
254
266
|
* Union of all KycController action types.
|
|
255
267
|
*/
|
|
256
|
-
export type KycControllerMethodActions = KycControllerEnsureLocalUserSecretAction | KycControllerStartSessionAction | KycControllerResetAction | KycControllerClearStateAction | KycControllerGetSessionStatusForVendorAction | KycControllerGetDataSharesAction | KycControllerGetProviderFlowStatusAction | KycControllerRefreshSessionStatusAction | KycControllerReadSessionStatusAction | KycControllerFetchSessionStatusOnceAction | KycControllerStartSessionStatusPollingAction | KycControllerFetchSessionDisclaimersAction | KycControllerRecordSessionDisclaimersAction | KycControllerHasCompletedSessionDisclaimersAction | KycControllerFetchVendorDisclaimersAction | KycControllerRecordVendorDisclaimersAction | KycControllerHasCompletedVendorDisclaimersAction | KycControllerLaunchProviderFlowAction;
|
|
268
|
+
export type KycControllerMethodActions = KycControllerEnsureLocalUserSecretAction | KycControllerStartSessionAction | KycControllerResetAction | KycControllerClearStateAction | KycControllerGetSessionStatusForVendorAction | KycControllerGetDataSharesAction | KycControllerGetProviderFlowStatusAction | KycControllerRefreshSessionStatusAction | KycControllerReadSessionStatusAction | KycControllerFetchSessionStatusOnceAction | KycControllerStartSessionStatusPollingAction | KycControllerFetchSessionDisclaimersAction | KycControllerRecordSessionDisclaimersAction | KycControllerHasCompletedSessionDisclaimersAction | KycControllerFetchVendorDisclaimersAction | KycControllerRecordVendorDisclaimersAction | KycControllerHasCompletedVendorDisclaimersAction | KycControllerDeleteEncryptedStorageAction | KycControllerLaunchProviderFlowAction;
|
|
257
269
|
//# 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;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,wCAAwC,GAAG;IACrD,IAAI,EAAE,qCAAqC,CAAC;IAC5C,OAAO,EAAE,aAAa,CAAC,uBAAuB,CAAC,CAAC;CACjD,CAAC;AAEF;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,MAAM,+BAA+B,GAAG;IAC5C,IAAI,EAAE,4BAA4B,CAAC;IACnC,OAAO,EAAE,aAAa,CAAC,cAAc,CAAC,CAAC;CACxC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,wBAAwB,GAAG;IACrC,IAAI,EAAE,qBAAqB,CAAC;IAC5B,OAAO,EAAE,aAAa,CAAC,OAAO,CAAC,CAAC;CACjC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,6BAA6B,GAAG;IAC1C,IAAI,EAAE,0BAA0B,CAAC;IACjC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CACtC,CAAC;AA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,GAAG;IACxD,IAAI,EAAE,wCAAwC,CAAC;IAC/C,OAAO,EAAE,aAAa,CAAC,0BAA0B,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;GAKG;AACH,MAAM,MAAM,iDAAiD,GAAG;IAC9D,IAAI,EAAE,8CAA8C,CAAC;IACrD,OAAO,EAAE,aAAa,CAAC,gCAAgC,CAAC,CAAC;CAC1D,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,0CAA0C,GAAG;IACvD,IAAI,EAAE,uCAAuC,CAAC;IAC9C,OAAO,EAAE,aAAa,CAAC,yBAAyB,CAAC,CAAC;CACnD,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,aAAa,CAAC,+BAA+B,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;;;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
|
+
{"version":3,"file":"KycController-method-action-types.d.ts","sourceRoot":"","sources":["../src/KycController-method-action-types.ts"],"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EF;;;;;;GAMG;AACH,MAAM,MAAM,gDAAgD,GAAG;IAC7D,IAAI,EAAE,6CAA6C,CAAC;IACpD,OAAO,EAAE,aAAa,CAAC,+BAA+B,CAAC,CAAC;CACzD,CAAC;AAEF;;;;;;;GAOG;AACH,MAAM,MAAM,yCAAyC,GAAG;IACtD,IAAI,EAAE,sCAAsC,CAAC;IAC7C,OAAO,EAAE,aAAa,CAAC,wBAAwB,CAAC,CAAC;CAClD,CAAC;AAEF;;;;;;;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,yCAAyC,GACzC,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 * 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"]}
|
|
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 * Deletes the caller's encrypted KYC blobs from MetaMask servers.\n *\n * Mints a fresh X25519 keypair, fetches a wrapping key from\n * `POST /deletions`, seals a `delete`-scoped `ukyc_capability_token` (4 hour\n * lifetime, client-presented) for that key, and submits it to\n * `DELETE /deletions/{deletionId}`. Does not clear controller state.\n */\nexport type KycControllerDeleteEncryptedStorageAction = {\n type: `KycController:deleteEncryptedStorage`;\n handler: KycController['deleteEncryptedStorage'];\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 | KycControllerDeleteEncryptedStorageAction\n | KycControllerLaunchProviderFlowAction;\n"]}
|
package/dist/KycController.d.ts
CHANGED
|
@@ -330,6 +330,15 @@ export declare class KycController extends BaseController<typeof controllerName,
|
|
|
330
330
|
* @throws If `vendor` or `geoCountry` is missing from state.
|
|
331
331
|
*/
|
|
332
332
|
hasCompletedVendorDisclaimers(): Promise<boolean>;
|
|
333
|
+
/**
|
|
334
|
+
* Deletes the caller's encrypted KYC blobs from MetaMask servers.
|
|
335
|
+
*
|
|
336
|
+
* Mints a fresh X25519 keypair, fetches a wrapping key from
|
|
337
|
+
* `POST /deletions`, seals a `delete`-scoped `ukyc_capability_token` (4 hour
|
|
338
|
+
* lifetime, client-presented) for that key, and submits it to
|
|
339
|
+
* `DELETE /deletions/{deletionId}`. Does not clear controller state.
|
|
340
|
+
*/
|
|
341
|
+
deleteEncryptedStorage(): Promise<void>;
|
|
333
342
|
/**
|
|
334
343
|
* Presents the identity-provider verification UI. Currently launches SumSub.
|
|
335
344
|
*
|
|
@@ -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,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,KAAK,EAAE,qDAAqD,EAAE,MAAM,wCAAwC,CAAC;AACpH,OAAO,KAAK,EACV,4CAA4C,EAC5C,4CAA4C,EAC7C,MAAM,gDAAgD,CAAC;AAIxD,OAAO,KAAK,EAEV,oBAAoB,EAErB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAanF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,uBAAuB,CAAC;AAQ/D,OAAO,KAAK,EACV,gBAAgB,EAChB,YAAY,EACZ,aAAa,EACb,qBAAqB,EACrB,8BAA8B,EAC9B,qBAAqB,EACrB,gBAAgB,EAChB,SAAS,EACT,4BAA4B,EAC5B,gBAAgB,EACjB,MAAM,YAAY,CAAC;
|
|
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,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B,IAAI,IAAI,CA2BhC;IAuUD;;;;;;;;;;;;;;;;;OAiBG;IACG,uBAAuB,CAC3B,MAAM,EAAE,6BAA6B,GACpC,OAAO,CAAC,qBAAqB,GAAG,qBAAqB,CAAC,CA6BxD;IAED;;;;;;;;;;;OAWG;IACG,wBAAwB,CAAC,MAAM,EAAE;QACrC,2BAA2B,EAAE,gBAAgB,EAAE,CAAC;QAChD,uBAAuB,EAAE,gBAAgB,EAAE,CAAC;QAC5C,iCAAiC,EAAE,OAAO,CAAC;KAC5C,GAAG,OAAO,CAAC,IAAI,CAAC,CAuChB;IAED;;;;;OAKG;IACG,8BAA8B,IAAI,OAAO,CAAC,OAAO,CAAC,CAcvD;IAED;;;;;;;;OAQG;IACG,sBAAsB,CAAC,MAAM,EAAE;QACnC,MAAM,CAAC,EAAE,SAAS,CAAC;QACnB,OAAO,EAAE,MAAM,CAAC;KACjB,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC,CAE3B;IAED;;;;;;;;OAQG;IACG,uBAAuB,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;IACG,sBAAsB,IAAI,OAAO,CAAC,IAAI,CAAC,CA0B5C;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;CA8RF"}
|
package/dist/KycController.js
CHANGED
|
@@ -26,6 +26,9 @@ export const KYC_PROVIDER_FLOW_STATUSES = [
|
|
|
26
26
|
// cover the KYC session's expected lifetime — including the provider journey —
|
|
27
27
|
// rather than a fixed short window, so this is a session-scoped window.
|
|
28
28
|
const UKYC_CAPABILITY_TOKEN_TTL_MS = 72 * 60 * 60 * 1000;
|
|
29
|
+
// Lifetime of the `delete`-scoped `ukyc_capability_token`. The token is minted
|
|
30
|
+
// and presented immediately, so four hours is enough.
|
|
31
|
+
const UKYC_DELETE_CAPABILITY_TOKEN_TTL_MS = 4 * 60 * 60 * 1000;
|
|
29
32
|
// First wait between UKYC session-status polls. Each later wait grows by this
|
|
30
33
|
// step, so the delays are 10s, 20s, 30s, and so on.
|
|
31
34
|
const SESSION_STATUS_POLL_INTERVAL_MS = 10_000;
|
|
@@ -139,6 +142,7 @@ const MESSENGER_EXPOSED_METHODS = [
|
|
|
139
142
|
'recordVendorDisclaimers',
|
|
140
143
|
'hasCompletedVendorDisclaimers',
|
|
141
144
|
'launchProviderFlow',
|
|
145
|
+
'deleteEncryptedStorage',
|
|
142
146
|
];
|
|
143
147
|
// === CONTROLLER DEFINITION ===
|
|
144
148
|
/**
|
|
@@ -858,6 +862,34 @@ export class KycController extends BaseController {
|
|
|
858
862
|
// TODO: this only works for Iron right now
|
|
859
863
|
return areVendorDisclaimersCompleted(this.state.vendorDisclaimersAccepted, this.state.vendor, fetched);
|
|
860
864
|
}
|
|
865
|
+
/**
|
|
866
|
+
* Deletes the caller's encrypted KYC blobs from MetaMask servers.
|
|
867
|
+
*
|
|
868
|
+
* Mints a fresh X25519 keypair, fetches a wrapping key from
|
|
869
|
+
* `POST /deletions`, seals a `delete`-scoped `ukyc_capability_token` (4 hour
|
|
870
|
+
* lifetime, client-presented) for that key, and submits it to
|
|
871
|
+
* `DELETE /deletions/{deletionId}`. Does not clear controller state.
|
|
872
|
+
*/
|
|
873
|
+
async deleteEncryptedStorage() {
|
|
874
|
+
const sessionClientPrivateKey = x25519.utils.randomSecretKey();
|
|
875
|
+
const sessionClientPublicKey = toBase64Url(x25519.getPublicKey(sessionClientPrivateKey));
|
|
876
|
+
const { deletionId, ukycCapabilityToken: capabilityTokenSchema } = await this.messenger.call('KycService:createDeletion', {
|
|
877
|
+
sessionClientPublicKey,
|
|
878
|
+
});
|
|
879
|
+
await this.#verifyCapabilityTokenSchema(capabilityTokenSchema);
|
|
880
|
+
const clientMaterial = await this.#getClientMaterial();
|
|
881
|
+
const wrappedUkycCapabilityToken = this.#wrapCapabilityToken({
|
|
882
|
+
clientMaterial,
|
|
883
|
+
sessionClientPrivateKey,
|
|
884
|
+
serverPublicKeyX: capabilityTokenSchema.serverPublicKey.x,
|
|
885
|
+
operations: ['delete'],
|
|
886
|
+
expiresAt: new Date(Date.now() + UKYC_DELETE_CAPABILITY_TOKEN_TTL_MS),
|
|
887
|
+
});
|
|
888
|
+
await this.messenger.call('KycService:completeDeletion', {
|
|
889
|
+
deletionId,
|
|
890
|
+
wrappedUkycCapabilityToken,
|
|
891
|
+
});
|
|
892
|
+
}
|
|
861
893
|
/**
|
|
862
894
|
* Presents the identity-provider verification UI. Currently launches SumSub.
|
|
863
895
|
*
|
|
@@ -967,6 +999,32 @@ export class KycController extends BaseController {
|
|
|
967
999
|
return 'failed';
|
|
968
1000
|
}
|
|
969
1001
|
}
|
|
1002
|
+
/**
|
|
1003
|
+
* Verifies the deletion wrapping key. A deletion response carries only the
|
|
1004
|
+
* `ukycCapabilityToken` schema, attested by the idOS relay.
|
|
1005
|
+
*
|
|
1006
|
+
* Fetch and verification failures are rethrown as a short message suitable
|
|
1007
|
+
* for display. The original error is preserved on `cause`.
|
|
1008
|
+
*
|
|
1009
|
+
* @param capabilityTokenSchema - Encryption schema for the capability token.
|
|
1010
|
+
* @throws When the relay signing keys cannot be fetched, or the schema's
|
|
1011
|
+
* `jwtChain` does not verify.
|
|
1012
|
+
*/
|
|
1013
|
+
async #verifyCapabilityTokenSchema(capabilityTokenSchema) {
|
|
1014
|
+
let idosRelayKeys;
|
|
1015
|
+
try {
|
|
1016
|
+
({ keys: idosRelayKeys } = await this.messenger.call('KycService:fetchIdosRelayJwks'));
|
|
1017
|
+
}
|
|
1018
|
+
catch (error) {
|
|
1019
|
+
throw wrapError(error, 'KycController.#verifyCapabilityTokenSchema: Unable to fetch JWKS needed to verify wrapping keys.');
|
|
1020
|
+
}
|
|
1021
|
+
try {
|
|
1022
|
+
assertAttestedServerPublicKey(idosRelayKeys, capabilityTokenSchema);
|
|
1023
|
+
}
|
|
1024
|
+
catch (error) {
|
|
1025
|
+
throw wrapError(error, 'KycController.#verifyCapabilityTokenSchema: Failed to verify the wrapping keys.');
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
970
1028
|
/**
|
|
971
1029
|
* Verifies each schema's jwtChain against the matching issuer JWKS, then
|
|
972
1030
|
* confirms the returned server public key matches the value attested inside
|
|
@@ -1017,17 +1075,55 @@ export class KycController extends BaseController {
|
|
|
1017
1075
|
* @returns The wrapped encryption key and capability token.
|
|
1018
1076
|
*/
|
|
1019
1077
|
async #generateWrappedAuthorizations(sessionClientPrivateKey, encryptionDataKey, capabilityTokenSchema) {
|
|
1020
|
-
const
|
|
1021
|
-
const clientMaterial = deriveClientMaterial(localUserSecret);
|
|
1078
|
+
const clientMaterial = await this.#getClientMaterial();
|
|
1022
1079
|
const wrappedEncryptionDataKey = wrapEncryptionKey(sessionClientPrivateKey, encryptionDataKey.serverPublicKey.x, clientMaterial.dataEncryptionKey);
|
|
1023
|
-
const
|
|
1024
|
-
|
|
1080
|
+
const wrappedUkycCapabilityToken = this.#wrapCapabilityToken({
|
|
1081
|
+
clientMaterial,
|
|
1082
|
+
sessionClientPrivateKey,
|
|
1083
|
+
serverPublicKeyX: capabilityTokenSchema.serverPublicKey.x,
|
|
1025
1084
|
// TODO: Confirm with idOS when this can be switched back to read and a separate token is sent for write
|
|
1026
1085
|
operations: ['read', 'write'],
|
|
1027
1086
|
expiresAt: new Date(Date.now() + UKYC_CAPABILITY_TOKEN_TTL_MS),
|
|
1028
1087
|
});
|
|
1029
|
-
const wrappedUkycCapabilityToken = wrapEncryptionKey(sessionClientPrivateKey, capabilityTokenSchema.serverPublicKey.x, stringToBytes(encodeStorageAccessTokenForHeader(ukycCapabilityToken)));
|
|
1030
1088
|
return { wrappedEncryptionDataKey, wrappedUkycCapabilityToken };
|
|
1031
1089
|
}
|
|
1090
|
+
/**
|
|
1091
|
+
* Loads the stored `local_user_secret`, creating one when none exists, and
|
|
1092
|
+
* derives the UKYC client material from it.
|
|
1093
|
+
*
|
|
1094
|
+
* @returns Client material derived from `local_user_secret`.
|
|
1095
|
+
*/
|
|
1096
|
+
async #getClientMaterial() {
|
|
1097
|
+
const localUserSecret = await getOrCreateLocalUserSecret(this.#localUserSecretStore);
|
|
1098
|
+
return deriveClientMaterial(localUserSecret);
|
|
1099
|
+
}
|
|
1100
|
+
/**
|
|
1101
|
+
* Mints a client-presented `ukyc_capability_token` and seals it for the
|
|
1102
|
+
* server public key from a capability-token encryption schema.
|
|
1103
|
+
*
|
|
1104
|
+
* The operation list and lifetime stay with the caller: session
|
|
1105
|
+
* authorizations grant `read` and `write` for the session lifetime, while
|
|
1106
|
+
* deletion grants `delete` alone for a short window.
|
|
1107
|
+
*
|
|
1108
|
+
* @param params - Key material and token claims.
|
|
1109
|
+
* @param params.clientMaterial - Client material derived from
|
|
1110
|
+
* `local_user_secret`.
|
|
1111
|
+
* @param params.sessionClientPrivateKey - X25519 private key used to seal
|
|
1112
|
+
* the token.
|
|
1113
|
+
* @param params.serverPublicKeyX - Server X25519 public key (unpadded
|
|
1114
|
+
* base64url) from the capability-token schema.
|
|
1115
|
+
* @param params.operations - Storage operations the token authorizes.
|
|
1116
|
+
* `delete` must be the sole operation.
|
|
1117
|
+
* @param params.expiresAt - Token expiry. Must be after the issue time.
|
|
1118
|
+
* @returns The wrapped capability token.
|
|
1119
|
+
*/
|
|
1120
|
+
#wrapCapabilityToken(params) {
|
|
1121
|
+
const ukycCapabilityToken = signStorageAccessToken({
|
|
1122
|
+
material: params.clientMaterial,
|
|
1123
|
+
operations: params.operations,
|
|
1124
|
+
expiresAt: params.expiresAt,
|
|
1125
|
+
});
|
|
1126
|
+
return wrapEncryptionKey(params.sessionClientPrivateKey, params.serverPublicKeyX, stringToBytes(encodeStorageAccessTokenForHeader(ukycCapabilityToken)));
|
|
1127
|
+
}
|
|
1032
1128
|
}
|
|
1033
1129
|
//# sourceMappingURL=KycController.js.map
|