@metamask-previews/kyc-controller 0.0.0-preview-ea6a28c61 → 0.0.0-preview-e12b5ece6

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.
Files changed (50) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/KycController-method-action-types.cjs.map +1 -1
  3. package/dist/KycController-method-action-types.d.cts +6 -4
  4. package/dist/KycController-method-action-types.d.cts.map +1 -1
  5. package/dist/KycController-method-action-types.d.mts +6 -4
  6. package/dist/KycController-method-action-types.d.mts.map +1 -1
  7. package/dist/KycController-method-action-types.mjs.map +1 -1
  8. package/dist/KycController.cjs +180 -145
  9. package/dist/KycController.cjs.map +1 -1
  10. package/dist/KycController.d.cts +40 -34
  11. package/dist/KycController.d.cts.map +1 -1
  12. package/dist/KycController.d.mts +40 -34
  13. package/dist/KycController.d.mts.map +1 -1
  14. package/dist/KycController.mjs +177 -144
  15. package/dist/KycController.mjs.map +1 -1
  16. package/dist/KycService-method-action-types.cjs.map +1 -1
  17. package/dist/KycService-method-action-types.d.cts +4 -4
  18. package/dist/KycService-method-action-types.d.mts +4 -4
  19. package/dist/KycService-method-action-types.mjs.map +1 -1
  20. package/dist/KycService.cjs +21 -13
  21. package/dist/KycService.cjs.map +1 -1
  22. package/dist/KycService.d.cts +4 -4
  23. package/dist/KycService.d.cts.map +1 -1
  24. package/dist/KycService.d.mts +4 -4
  25. package/dist/KycService.d.mts.map +1 -1
  26. package/dist/KycService.mjs +21 -13
  27. package/dist/KycService.mjs.map +1 -1
  28. package/dist/index.cjs +3 -1
  29. package/dist/index.cjs.map +1 -1
  30. package/dist/index.d.cts +2 -2
  31. package/dist/index.d.cts.map +1 -1
  32. package/dist/index.d.mts +2 -2
  33. package/dist/index.d.mts.map +1 -1
  34. package/dist/index.mjs +1 -1
  35. package/dist/index.mjs.map +1 -1
  36. package/dist/types.cjs.map +1 -1
  37. package/dist/types.d.cts +50 -11
  38. package/dist/types.d.cts.map +1 -1
  39. package/dist/types.d.mts +50 -11
  40. package/dist/types.d.mts.map +1 -1
  41. package/dist/types.mjs.map +1 -1
  42. package/dist/vendorDisclaimerAcceptance.cjs +74 -0
  43. package/dist/vendorDisclaimerAcceptance.cjs.map +1 -0
  44. package/dist/vendorDisclaimerAcceptance.d.cts +39 -0
  45. package/dist/vendorDisclaimerAcceptance.d.cts.map +1 -0
  46. package/dist/vendorDisclaimerAcceptance.d.mts +39 -0
  47. package/dist/vendorDisclaimerAcceptance.d.mts.map +1 -0
  48. package/dist/vendorDisclaimerAcceptance.mjs +67 -0
  49. package/dist/vendorDisclaimerAcceptance.mjs.map +1 -0
  50. package/package.json +2 -2
package/dist/types.d.mts CHANGED
@@ -124,10 +124,11 @@ export type KycVendorSigning = {
124
124
  content_id?: string;
125
125
  };
126
126
  /**
127
- * A legal document in the idOS / KYC-provider catalog
128
- * (`GET /disclaimers`, or `GET`/`POST /sessions/{sessionId}/disclaimers`).
127
+ * A legal document in the global idOS / KYC-provider catalog
128
+ * (`GET /disclaimers`). Carries no consent state, which only exists within a
129
+ * session.
129
130
  */
130
- export type KycConsentDocument = {
131
+ export type KycCatalogDocument = {
131
132
  /** Stable identifier of the legal document. */
132
133
  key: string;
133
134
  /** Version of the document currently in force. */
@@ -136,10 +137,13 @@ export type KycConsentDocument = {
136
137
  title: string;
137
138
  /** URL the document body is hosted at. */
138
139
  url: string;
139
- /**
140
- * Whether the document version has already been consented to (session-scoped
141
- * fetches). For the global catalog this is typically `false`.
142
- */
140
+ };
141
+ /**
142
+ * A legal document in the session-scoped idOS / KYC-provider catalog
143
+ * (`GET`/`POST /sessions/{sessionId}/disclaimers`).
144
+ */
145
+ export type KycConsentDocument = KycCatalogDocument & {
146
+ /** Whether the document version has already been consented to. */
143
147
  consented: boolean;
144
148
  };
145
149
  /**
@@ -150,21 +154,56 @@ export type KycConsentRecord = {
150
154
  key: string;
151
155
  version: string;
152
156
  };
157
+ /**
158
+ * MoonPay vendor T&C1 acceptance persisted under
159
+ * {@link KycVendorDisclaimersAccepted.moonpay}.
160
+ */
161
+ export type KycMoonpayVendorDisclaimersAccepted = {
162
+ /** ISO-8601 timestamp of terms acceptance for MoonPay. */
163
+ termsAcceptedAt: string;
164
+ };
165
+ /**
166
+ * Iron vendor T&C1 acceptance persisted under
167
+ * {@link KycVendorDisclaimersAccepted.iron}.
168
+ */
169
+ export type KycIronVendorDisclaimersAccepted = {
170
+ /** IDs of Iron vendor disclaimers the customer accepted. */
171
+ disclaimerIds: string[];
172
+ };
173
+ /**
174
+ * Persisted KYC-provider disclaimer acceptance (T&C2) with a fixed `sumsub`
175
+ * key.
176
+ */
177
+ export type KycProviderDisclaimersAccepted = {
178
+ sumsub: KycConsentRecord[] | null;
179
+ };
180
+ /**
181
+ * Persisted vendor-disclaimer acceptance with fixed `moonpay` and `iron` keys.
182
+ */
183
+ export type KycVendorDisclaimersAccepted = {
184
+ moonpay: KycMoonpayVendorDisclaimersAccepted | null;
185
+ iron: KycIronVendorDisclaimersAccepted | null;
186
+ };
153
187
  /**
154
188
  * idOS / KYC-provider disclaimer catalog returned by
155
189
  * `GET /disclaimers?country=` (no session — no credential-reuse consent state).
156
190
  */
157
191
  export type KycDisclaimersCatalog = {
158
192
  /** idOS legal documents. */
159
- idOS: KycConsentDocument[];
193
+ idOS: KycCatalogDocument[];
160
194
  /** KYC provider (SumSub) legal documents. */
161
- kycProvider: KycConsentDocument[];
195
+ kycProvider: KycCatalogDocument[];
162
196
  };
163
197
  /**
164
198
  * Session-scoped disclaimer catalog returned by
165
- * `GET`/`POST /sessions/{sessionId}/disclaimers`.
199
+ * `GET`/`POST /sessions/{sessionId}/disclaimers`. Documents additionally report
200
+ * whether that version was already consented to for the session.
166
201
  */
167
- export type KycSessionDisclaimers = KycDisclaimersCatalog & {
202
+ export type KycSessionDisclaimers = {
203
+ /** idOS legal documents. */
204
+ idOS: KycConsentDocument[];
205
+ /** KYC provider (SumSub) legal documents. */
206
+ kycProvider: KycConsentDocument[];
168
207
  /** Whether the user consented to reuse existing idOS credentials. */
169
208
  credentialReusabilityConsentGiven: boolean;
170
209
  };
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.mts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH;;;GAGG;AACH,MAAM,MAAM,UAAU,GAAG,OAAO,GAAG,MAAM,GAAG,OAAO,CAAC;AAEpD;;;;;;GAMG;AACH,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,CAAC;AAE3C;;;;;;;;GAQG;AACH,MAAM,MAAM,mBAAmB,GAAG;IAChC,sEAAsE;IACtE,MAAM,EAAE,SAAS,CAAC;IAClB,2DAA2D;IAC3D,EAAE,EAAE,MAAM,CAAC;CACZ,CAAC;AAEF;;;;GAIG;AACH,MAAM,MAAM,aAAa,GACrB,aAAa,GACb,SAAS,GACT,uBAAuB,GACvB,kBAAkB,GAClB,WAAW,CAAC;AAEhB;;;GAGG;AACH,MAAM,MAAM,qBAAqB,GAAG;IAClC,MAAM,EAAE,aAAa,CAAC;IACtB,0EAA0E;IAC1E,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF;;;;;;;;;;;;;;;;;;GAkBG;AACH,MAAM,MAAM,QAAQ,GAChB,MAAM,GACN,OAAO,GACP,SAAS,GACT,OAAO,GACP,MAAM,GACN,MAAM,GACN,QAAQ,GACR,MAAM,GACN,OAAO,CAAC;AAEZ;;;;;;;;;;GAUG;AACH,MAAM,MAAM,eAAe,GACvB,MAAM,GACN,iBAAiB,GACjB,eAAe,GACf,WAAW,GACX,YAAY,GACZ,SAAS,GACT,UAAU,GACV,QAAQ,GACR,kBAAkB,CAAC;AAEvB;;;;GAIG;AACH,MAAM,MAAM,gBAAgB,GAAG;IAC7B;;;;OAIG;IACH,WAAW,EAAE,MAAM,CAAC;IACpB,6DAA6D;IAC7D,aAAa,CAAC,EAAE,MAAM,CA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CAAC,MAAM,CAAC,CAAC;IAEzC;;OAEG;IACH,cAAc,CAAC,EAAE,CAAC,UAAU,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IAEjE;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB;;OAEG;IACH,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB,CAAC;AAEF;;;;;;;;GAQG;AACH,MAAM,MAAM,iBAAiB,GAAG;IAC9B;;;OAGG;IACH,WAAW,IAAI,OAAO,CAAC;IAEvB;;OAEG;IACH,MAAM,CAAC,MAAM,EAAE,qBAAqB,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC,CAAC;CACzE,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Shared types for the KYC controller and service.\n *\n * The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for\n * document verification) but the surface exposed to consumers (ramps, card) is\n * intentionally vendor-neutral so a future vendor swap does not ripple out.\n */\n\n/**\n * A MetaMask feature that consumes KYC. Used to key the per-product\n * \"is KYC required\" cache so ramps, card, and money can share one controller.\n */\nexport type KycProduct = 'ramps' | 'card' | 'money';\n\n/**\n * Identity vendors supported behind the KYC surface.\n *\n * - `moonpay` — MoonPay Check/Auth frames + SumSub documents.\n * - `iron` — Iron-only Money/VBA path: empty-shell customer → consents →\n * SumSub, with no MoonPay Check/Auth frames.\n */\nexport type KycVendor = 'moonpay' | 'iron';\n\n/**\n * Vendor-scoped identity for the currently authenticated KYC customer.\n *\n * Exposed to consumers (e.g. ramps) that must attach the vendor customer id to\n * downstream provider calls without reading the full KYC state, which also\n * holds session/access tokens. The identifier is session-scoped: it is only\n * available once the customer has authenticated through the current flow and\n * is cleared on `reset()`.\n */\nexport type KycCustomerIdentity = {\n /** The identity vendor that issued {@link KycCustomerIdentity.id}. */\n vendor: KycVendor;\n /** The vendor customer id (e.g. MoonPay customer UUID). */\n id: string;\n};\n\n/**\n * User-keyed KYC status returned by `GET /kyc/status` and stored for toast /\n * banner rendering. Collapses vendor + SumSub / relay state into the offsite\n * contract.\n */\nexport type KycUserStatus =\n | 'not-started'\n | 'pending'\n | 'need-more-information'\n | 'terminal-failure'\n | 'completed';\n\n/**\n * Payload from `GET /kyc/status`, including optional fields that power the\n * 3-state error contract (retryable SumSub vs terminal vs EDD).\n */\nexport type KycUserStatusResponse = {\n status: KycUserStatus;\n /** Present when the user can reopen a SumSub session (retryable path). */\n sumsubSessionId?: string;\n /** Machine-readable error code for terminal / EDD UX. */\n errorCode?: string;\n};\n\n/**\n * Phases of the end-to-end identity flow.\n *\n * - `idle` — nothing started.\n * - `terms` — waiting for the customer to accept the vendor terms.\n * - `session` — creating the vendor session (MoonPay) or creating the UKYC\n * session and recording session-scoped disclaimers (non-MoonPay vendors).\n * - `check` — running the invisible connection-check frame (MoonPay only).\n * - `auth` — running the visible authentication (OTP) frame (MoonPay only).\n * - `form` — authenticated. When the flow is scoped to a product, the\n * KYC-required check runs automatically from here; otherwise the consumer\n * drives it manually via `checkKycRequired`. Consents-path vendors skip\n * this phase.\n * - `submit` — submitting the KYC-required check / launching SumSub.\n * - `done` — flow complete; see `kycRequiredByProduct` / `sumsub` /\n * `userStatus`. When KYC is required, the document-verification sub-flow is\n * launched automatically.\n * - `error` — flow halted; see `error`.\n */\nexport type KycPhase =\n | 'idle'\n | 'terms'\n | 'session'\n | 'check'\n | 'auth'\n | 'form'\n | 'submit'\n | 'done'\n | 'error';\n\n/**\n * Progress of the SumSub document-verification sub-flow.\n *\n * - `polling` — the SDK finished and the controller is polling the UKYC\n * backend for the session's final decision (see `KycSessionStatus`). The\n * sub-flow resolves to `complete` or `failed` once a terminal status arrives.\n * - `vendorProcessing` — session creation reported that the applicant is\n * already approved on the relay (`kycStatus`) while the vendor is still\n * finalizing its own decision (`finalStatus`). There is nothing left for the\n * applicant to do, so the SDK is not launched; see `statusMessage`.\n */\nexport type KycSumSubStatus =\n | 'idle'\n | 'creatingSession'\n | 'fetchingToken'\n | 'launching'\n | 'inProgress'\n | 'polling'\n | 'complete'\n | 'failed'\n | 'vendorProcessing';\n\n/**\n * The status of a UKYC session, returned by the `GET /sessions/{id}/status`\n * endpoint and polled after the SumSub SDK completes to determine the final\n * verification decision.\n */\nexport type KycSessionStatus = {\n /**\n * The overall status of the session. Terminal values (e.g. `approved`,\n * `completed`, `rejected`, `failed`, `blocked`) end polling; any other value\n * keeps polling.\n */\n finalStatus: string;\n /** Optional human-readable message describing the status. */\n statusMessage?: string;\n /** The vendor-agnostic external user id associated with the session. */\n externalUserId: string;\n /** The KYC decision status. */\n kycStatus: string;\n /** The identity vendor that handled the session. */\n vendor: string;\n /** The vendor-specific status. */\n vendorStatus: string;\n};\n\n/**\n * A single disclaimer/term the customer must accept before a vendor session is\n * created (`GET /vendors/{vendor}/disclaimers`).\n */\nexport type KycDisclaimer = {\n id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n display_name: string;\n url: string;\n};\n\n/**\n * A vendor T&C signing returned by `POST /vendors/{vendor}/disclaimers`.\n */\nexport type KycVendorSigning = {\n /** Iron signing id. */\n id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n customer_id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n content_id?: string;\n};\n\n/**\n * A legal document in the idOS / KYC-provider catalog\n * (`GET /disclaimers`, or `GET`/`POST /sessions/{sessionId}/disclaimers`).\n */\nexport type KycConsentDocument = {\n /** Stable identifier of the legal document. */\n key: string;\n /** Version of the document currently in force. */\n version: string;\n /** Human-readable document title. */\n title: string;\n /** URL the document body is hosted at. */\n url: string;\n /**\n * Whether the document version has already been consented to (session-scoped\n * fetches). For the global catalog this is typically `false`.\n */\n consented: boolean;\n};\n\n/**\n * A consent record posted for a catalog document. `key` and `version` must\n * match the current session catalog.\n */\nexport type KycConsentRecord = {\n key: string;\n version: string;\n};\n\n/**\n * idOS / KYC-provider disclaimer catalog returned by\n * `GET /disclaimers?country=` (no session — no credential-reuse consent state).\n */\nexport type KycDisclaimersCatalog = {\n /** idOS legal documents. */\n idOS: KycConsentDocument[];\n /** KYC provider (SumSub) legal documents. */\n kycProvider: KycConsentDocument[];\n};\n\n/**\n * Session-scoped disclaimer catalog returned by\n * `GET`/`POST /sessions/{sessionId}/disclaimers`.\n */\nexport type KycSessionDisclaimers = KycDisclaimersCatalog & {\n /** Whether the user consented to reuse existing idOS credentials. */\n credentialReusabilityConsentGiven: boolean;\n};\n\n/**\n * Parameters passed to a platform SumSub launcher.\n */\nexport type KycSumSubLaunchParams = {\n /**\n * The applicant access token used to initialize the SumSub SDK.\n */\n applicantAccessToken: string;\n\n /**\n * Called by the SDK when the access token expires; must resolve with a fresh\n * applicant access token.\n */\n onTokenExpiration: () => Promise<string>;\n\n /**\n * Called when the SDK reports a status transition.\n */\n onStatusChange?: (prevStatus: string, newStatus: string) => void;\n\n /**\n * BCP-47 locale for the SDK UI.\n */\n locale?: string;\n\n /**\n * Enables SDK debug logging.\n */\n debug?: boolean;\n};\n\n/**\n * Platform adapter that launches the native/web SumSub SDK.\n *\n * The KYC controller is platform-agnostic and does not import any SDK; each\n * client (mobile / extension / web) injects an implementation of this\n * interface. The controller owns all orchestration (session creation, token\n * exchange, token refresh, state) and only delegates the actual SDK\n * presentation to `launch`.\n */\nexport type KycSumSubLauncher = {\n /**\n * Whether the underlying SDK is available in the current runtime (e.g. the\n * native module is linked). When `false`, `startSumSub` fails fast.\n */\n isAvailable(): boolean;\n\n /**\n * Presents the SumSub verification flow and resolves with the SDK result.\n */\n launch(params: KycSumSubLaunchParams): Promise<Record<string, unknown>>;\n};\n"]}
1
+ {"version":3,"file":"types.mjs","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG","sourcesContent":["/**\n * Shared types for the KYC controller and service.\n *\n * The KYC flow is vendor-backed (currently MoonPay for identity + SumSub for\n * document verification) but the surface exposed to consumers (ramps, card) is\n * intentionally vendor-neutral so a future vendor swap does not ripple out.\n */\n\n/**\n * A MetaMask feature that consumes KYC. Used to key the per-product\n * \"is KYC required\" cache so ramps, card, and money can share one controller.\n */\nexport type KycProduct = 'ramps' | 'card' | 'money';\n\n/**\n * Identity vendors supported behind the KYC surface.\n *\n * - `moonpay` — MoonPay Check/Auth frames + SumSub documents.\n * - `iron` — Iron-only Money/VBA path: empty-shell customer → consents →\n * SumSub, with no MoonPay Check/Auth frames.\n */\nexport type KycVendor = 'moonpay' | 'iron';\n\n/**\n * Vendor-scoped identity for the currently authenticated KYC customer.\n *\n * Exposed to consumers (e.g. ramps) that must attach the vendor customer id to\n * downstream provider calls without reading the full KYC state, which also\n * holds session/access tokens. The identifier is session-scoped: it is only\n * available once the customer has authenticated through the current flow and\n * is cleared on `reset()`.\n */\nexport type KycCustomerIdentity = {\n /** The identity vendor that issued {@link KycCustomerIdentity.id}. */\n vendor: KycVendor;\n /** The vendor customer id (e.g. MoonPay customer UUID). */\n id: string;\n};\n\n/**\n * User-keyed KYC status returned by `GET /kyc/status` and stored for toast /\n * banner rendering. Collapses vendor + SumSub / relay state into the offsite\n * contract.\n */\nexport type KycUserStatus =\n | 'not-started'\n | 'pending'\n | 'need-more-information'\n | 'terminal-failure'\n | 'completed';\n\n/**\n * Payload from `GET /kyc/status`, including optional fields that power the\n * 3-state error contract (retryable SumSub vs terminal vs EDD).\n */\nexport type KycUserStatusResponse = {\n status: KycUserStatus;\n /** Present when the user can reopen a SumSub session (retryable path). */\n sumsubSessionId?: string;\n /** Machine-readable error code for terminal / EDD UX. */\n errorCode?: string;\n};\n\n/**\n * Phases of the end-to-end identity flow.\n *\n * - `idle` — nothing started.\n * - `terms` — waiting for the customer to accept the vendor terms.\n * - `session` — creating the vendor session (MoonPay) or creating the UKYC\n * session and recording session-scoped disclaimers (non-MoonPay vendors).\n * - `check` — running the invisible connection-check frame (MoonPay only).\n * - `auth` — running the visible authentication (OTP) frame (MoonPay only).\n * - `form` — authenticated. When the flow is scoped to a product, the\n * KYC-required check runs automatically from here; otherwise the consumer\n * drives it manually via `checkKycRequired`. Consents-path vendors skip\n * this phase.\n * - `submit` — submitting the KYC-required check / launching SumSub.\n * - `done` — flow complete; see `kycRequiredByProduct` / `sumsub` /\n * `userStatus`. When KYC is required, the document-verification sub-flow is\n * launched automatically.\n * - `error` — flow halted; see `error`.\n */\nexport type KycPhase =\n | 'idle'\n | 'terms'\n | 'session'\n | 'check'\n | 'auth'\n | 'form'\n | 'submit'\n | 'done'\n | 'error';\n\n/**\n * Progress of the SumSub document-verification sub-flow.\n *\n * - `polling` — the SDK finished and the controller is polling the UKYC\n * backend for the session's final decision (see `KycSessionStatus`). The\n * sub-flow resolves to `complete` or `failed` once a terminal status arrives.\n * - `vendorProcessing` — session creation reported that the applicant is\n * already approved on the relay (`kycStatus`) while the vendor is still\n * finalizing its own decision (`finalStatus`). There is nothing left for the\n * applicant to do, so the SDK is not launched; see `statusMessage`.\n */\nexport type KycSumSubStatus =\n | 'idle'\n | 'creatingSession'\n | 'fetchingToken'\n | 'launching'\n | 'inProgress'\n | 'polling'\n | 'complete'\n | 'failed'\n | 'vendorProcessing';\n\n/**\n * The status of a UKYC session, returned by the `GET /sessions/{id}/status`\n * endpoint and polled after the SumSub SDK completes to determine the final\n * verification decision.\n */\nexport type KycSessionStatus = {\n /**\n * The overall status of the session. Terminal values (e.g. `approved`,\n * `completed`, `rejected`, `failed`, `blocked`) end polling; any other value\n * keeps polling.\n */\n finalStatus: string;\n /** Optional human-readable message describing the status. */\n statusMessage?: string;\n /** The vendor-agnostic external user id associated with the session. */\n externalUserId: string;\n /** The KYC decision status. */\n kycStatus: string;\n /** The identity vendor that handled the session. */\n vendor: string;\n /** The vendor-specific status. */\n vendorStatus: string;\n};\n\n/**\n * A single disclaimer/term the customer must accept before a vendor session is\n * created (`GET /vendors/{vendor}/disclaimers`).\n */\nexport type KycDisclaimer = {\n id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n display_name: string;\n url: string;\n};\n\n/**\n * A vendor T&C signing returned by `POST /vendors/{vendor}/disclaimers`.\n */\nexport type KycVendorSigning = {\n /** Iron signing id. */\n id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n customer_id: string;\n // Mirrors the vendor API response field, which is snake_case.\n // eslint-disable-next-line @typescript-eslint/naming-convention\n content_id?: string;\n};\n\n/**\n * A legal document in the global idOS / KYC-provider catalog\n * (`GET /disclaimers`). Carries no consent state, which only exists within a\n * session.\n */\nexport type KycCatalogDocument = {\n /** Stable identifier of the legal document. */\n key: string;\n /** Version of the document currently in force. */\n version: string;\n /** Human-readable document title. */\n title: string;\n /** URL the document body is hosted at. */\n url: string;\n};\n\n/**\n * A legal document in the session-scoped idOS / KYC-provider catalog\n * (`GET`/`POST /sessions/{sessionId}/disclaimers`).\n */\nexport type KycConsentDocument = KycCatalogDocument & {\n /** Whether the document version has already been consented to. */\n consented: boolean;\n};\n\n/**\n * A consent record posted for a catalog document. `key` and `version` must\n * match the current session catalog.\n */\nexport type KycConsentRecord = {\n key: string;\n version: string;\n};\n\n/**\n * MoonPay vendor T&C1 acceptance persisted under\n * {@link KycVendorDisclaimersAccepted.moonpay}.\n */\nexport type KycMoonpayVendorDisclaimersAccepted = {\n /** ISO-8601 timestamp of terms acceptance for MoonPay. */\n termsAcceptedAt: string;\n};\n\n/**\n * Iron vendor T&C1 acceptance persisted under\n * {@link KycVendorDisclaimersAccepted.iron}.\n */\nexport type KycIronVendorDisclaimersAccepted = {\n /** IDs of Iron vendor disclaimers the customer accepted. */\n disclaimerIds: string[];\n};\n\n/**\n * Persisted KYC-provider disclaimer acceptance (T&C2) with a fixed `sumsub`\n * key.\n */\nexport type KycProviderDisclaimersAccepted = {\n sumsub: KycConsentRecord[] | null;\n};\n\n/**\n * Persisted vendor-disclaimer acceptance with fixed `moonpay` and `iron` keys.\n */\nexport type KycVendorDisclaimersAccepted = {\n moonpay: KycMoonpayVendorDisclaimersAccepted | null;\n iron: KycIronVendorDisclaimersAccepted | null;\n};\n\n/**\n * idOS / KYC-provider disclaimer catalog returned by\n * `GET /disclaimers?country=` (no session — no credential-reuse consent state).\n */\nexport type KycDisclaimersCatalog = {\n /** idOS legal documents. */\n idOS: KycCatalogDocument[];\n /** KYC provider (SumSub) legal documents. */\n kycProvider: KycCatalogDocument[];\n};\n\n/**\n * Session-scoped disclaimer catalog returned by\n * `GET`/`POST /sessions/{sessionId}/disclaimers`. Documents additionally report\n * whether that version was already consented to for the session.\n */\nexport type KycSessionDisclaimers = {\n /** idOS legal documents. */\n idOS: KycConsentDocument[];\n /** KYC provider (SumSub) legal documents. */\n kycProvider: KycConsentDocument[];\n /** Whether the user consented to reuse existing idOS credentials. */\n credentialReusabilityConsentGiven: boolean;\n};\n\n/**\n * Parameters passed to a platform SumSub launcher.\n */\nexport type KycSumSubLaunchParams = {\n /**\n * The applicant access token used to initialize the SumSub SDK.\n */\n applicantAccessToken: string;\n\n /**\n * Called by the SDK when the access token expires; must resolve with a fresh\n * applicant access token.\n */\n onTokenExpiration: () => Promise<string>;\n\n /**\n * Called when the SDK reports a status transition.\n */\n onStatusChange?: (prevStatus: string, newStatus: string) => void;\n\n /**\n * BCP-47 locale for the SDK UI.\n */\n locale?: string;\n\n /**\n * Enables SDK debug logging.\n */\n debug?: boolean;\n};\n\n/**\n * Platform adapter that launches the native/web SumSub SDK.\n *\n * The KYC controller is platform-agnostic and does not import any SDK; each\n * client (mobile / extension / web) injects an implementation of this\n * interface. The controller owns all orchestration (session creation, token\n * exchange, token refresh, state) and only delegates the actual SDK\n * presentation to `launch`.\n */\nexport type KycSumSubLauncher = {\n /**\n * Whether the underlying SDK is available in the current runtime (e.g. the\n * native module is linked). When `false`, `startSumSub` fails fast.\n */\n isAvailable(): boolean;\n\n /**\n * Presents the SumSub verification flow and resolves with the SDK result.\n */\n launch(params: KycSumSubLaunchParams): Promise<Record<string, unknown>>;\n};\n"]}
@@ -0,0 +1,74 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.clearVendorDisclaimerAcceptance = exports.recordVendorDisclaimerAcceptance = exports.ironDisclaimerIds = exports.hasVendorDisclaimerAcceptance = void 0;
4
+ /**
5
+ * Returns whether persisted vendor disclaimer acceptance exists for `vendor`.
6
+ *
7
+ * @param accepted - Vendor-disclaimer acceptance map.
8
+ * @param vendor - Identity vendor to inspect.
9
+ * @returns Whether acceptance is present for the vendor.
10
+ */
11
+ function hasVendorDisclaimerAcceptance(accepted, vendor) {
12
+ if (vendor === 'moonpay') {
13
+ return Boolean(accepted.moonpay?.termsAcceptedAt);
14
+ }
15
+ if (vendor === 'iron') {
16
+ return Boolean(accepted.iron?.disclaimerIds.length);
17
+ }
18
+ return false;
19
+ }
20
+ exports.hasVendorDisclaimerAcceptance = hasVendorDisclaimerAcceptance;
21
+ /**
22
+ * Returns persisted Iron disclaimer ids, if any.
23
+ *
24
+ * @param accepted - Vendor-disclaimer acceptance map.
25
+ * @returns The accepted disclaimer ids, or an empty array.
26
+ */
27
+ function ironDisclaimerIds(accepted) {
28
+ return accepted.iron?.disclaimerIds ?? [];
29
+ }
30
+ exports.ironDisclaimerIds = ironDisclaimerIds;
31
+ /**
32
+ * Records vendor disclaimer acceptance for the active vendor.
33
+ *
34
+ * @param accepted - Existing vendor-disclaimer acceptance map.
35
+ * @param vendor - Identity vendor being accepted.
36
+ * @param params - Acceptance payload for the vendor.
37
+ * @param params.termsAcceptedAt - MoonPay acceptance timestamp.
38
+ * @param params.disclaimerIds - Iron disclaimer ids.
39
+ * @returns The updated acceptance map.
40
+ */
41
+ function recordVendorDisclaimerAcceptance(accepted, vendor, params) {
42
+ if (vendor === 'moonpay') {
43
+ return {
44
+ ...accepted,
45
+ moonpay: { termsAcceptedAt: params.termsAcceptedAt },
46
+ };
47
+ }
48
+ if (vendor === 'iron') {
49
+ return {
50
+ ...accepted,
51
+ iron: { disclaimerIds: params.disclaimerIds },
52
+ };
53
+ }
54
+ return accepted;
55
+ }
56
+ exports.recordVendorDisclaimerAcceptance = recordVendorDisclaimerAcceptance;
57
+ /**
58
+ * Clears persisted vendor disclaimer acceptance for one vendor.
59
+ *
60
+ * @param accepted - Existing vendor-disclaimer acceptance map.
61
+ * @param vendor - Identity vendor whose acceptance should be cleared.
62
+ * @returns The updated acceptance map.
63
+ */
64
+ function clearVendorDisclaimerAcceptance(accepted, vendor) {
65
+ if (vendor === 'moonpay') {
66
+ return { ...accepted, moonpay: null };
67
+ }
68
+ if (vendor === 'iron') {
69
+ return { ...accepted, iron: null };
70
+ }
71
+ return accepted;
72
+ }
73
+ exports.clearVendorDisclaimerAcceptance = clearVendorDisclaimerAcceptance;
74
+ //# sourceMappingURL=vendorDisclaimerAcceptance.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendorDisclaimerAcceptance.cjs","sourceRoot":"","sources":["../src/vendorDisclaimerAcceptance.ts"],"names":[],"mappings":";;;AAEA;;;;;;GAMG;AACH,SAAgB,6BAA6B,CAC3C,QAAsC,EACtC,MAAiB;IAEjB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,OAAO,CAAC,QAAQ,CAAC,OAAO,EAAE,eAAe,CAAC,CAAC;IACpD,CAAC;IACD,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,OAAO,CAAC,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACtD,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAXD,sEAWC;AAED;;;;;GAKG;AACH,SAAgB,iBAAiB,CAC/B,QAAsC;IAEtC,OAAO,QAAQ,CAAC,IAAI,EAAE,aAAa,IAAI,EAAE,CAAC;AAC5C,CAAC;AAJD,8CAIC;AAED;;;;;;;;;GASG;AACH,SAAgB,gCAAgC,CAC9C,QAAsC,EACtC,MAAiB,EACjB,MAA4D;IAE5D,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO;YACL,GAAG,QAAQ;YACX,OAAO,EAAE,EAAE,eAAe,EAAE,MAAM,CAAC,eAAe,EAAE;SACrD,CAAC;IACJ,CAAC;IACD,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO;YACL,GAAG,QAAQ;YACX,IAAI,EAAE,EAAE,aAAa,EAAE,MAAM,CAAC,aAAa,EAAE;SAC9C,CAAC;IACJ,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAlBD,4EAkBC;AAED;;;;;;GAMG;AACH,SAAgB,+BAA+B,CAC7C,QAAsC,EACtC,MAAiB;IAEjB,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;QACzB,OAAO,EAAE,GAAG,QAAQ,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACxC,CAAC;IACD,IAAI,MAAM,KAAK,MAAM,EAAE,CAAC;QACtB,OAAO,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACrC,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAXD,0EAWC","sourcesContent":["import type { KycVendor, KycVendorDisclaimersAccepted } from './types.js';\n\n/**\n * Returns whether persisted vendor disclaimer acceptance exists for `vendor`.\n *\n * @param accepted - Vendor-disclaimer acceptance map.\n * @param vendor - Identity vendor to inspect.\n * @returns Whether acceptance is present for the vendor.\n */\nexport function hasVendorDisclaimerAcceptance(\n accepted: KycVendorDisclaimersAccepted,\n vendor: KycVendor,\n): boolean {\n if (vendor === 'moonpay') {\n return Boolean(accepted.moonpay?.termsAcceptedAt);\n }\n if (vendor === 'iron') {\n return Boolean(accepted.iron?.disclaimerIds.length);\n }\n return false;\n}\n\n/**\n * Returns persisted Iron disclaimer ids, if any.\n *\n * @param accepted - Vendor-disclaimer acceptance map.\n * @returns The accepted disclaimer ids, or an empty array.\n */\nexport function ironDisclaimerIds(\n accepted: KycVendorDisclaimersAccepted,\n): string[] {\n return accepted.iron?.disclaimerIds ?? [];\n}\n\n/**\n * Records vendor disclaimer acceptance for the active vendor.\n *\n * @param accepted - Existing vendor-disclaimer acceptance map.\n * @param vendor - Identity vendor being accepted.\n * @param params - Acceptance payload for the vendor.\n * @param params.termsAcceptedAt - MoonPay acceptance timestamp.\n * @param params.disclaimerIds - Iron disclaimer ids.\n * @returns The updated acceptance map.\n */\nexport function recordVendorDisclaimerAcceptance(\n accepted: KycVendorDisclaimersAccepted,\n vendor: KycVendor,\n params: { termsAcceptedAt: string; disclaimerIds: string[] },\n): KycVendorDisclaimersAccepted {\n if (vendor === 'moonpay') {\n return {\n ...accepted,\n moonpay: { termsAcceptedAt: params.termsAcceptedAt },\n };\n }\n if (vendor === 'iron') {\n return {\n ...accepted,\n iron: { disclaimerIds: params.disclaimerIds },\n };\n }\n return accepted;\n}\n\n/**\n * Clears persisted vendor disclaimer acceptance for one vendor.\n *\n * @param accepted - Existing vendor-disclaimer acceptance map.\n * @param vendor - Identity vendor whose acceptance should be cleared.\n * @returns The updated acceptance map.\n */\nexport function clearVendorDisclaimerAcceptance(\n accepted: KycVendorDisclaimersAccepted,\n vendor: KycVendor,\n): KycVendorDisclaimersAccepted {\n if (vendor === 'moonpay') {\n return { ...accepted, moonpay: null };\n }\n if (vendor === 'iron') {\n return { ...accepted, iron: null };\n }\n return accepted;\n}\n"]}
@@ -0,0 +1,39 @@
1
+ import type { KycVendor, KycVendorDisclaimersAccepted } from "./types.cjs";
2
+ /**
3
+ * Returns whether persisted vendor disclaimer acceptance exists for `vendor`.
4
+ *
5
+ * @param accepted - Vendor-disclaimer acceptance map.
6
+ * @param vendor - Identity vendor to inspect.
7
+ * @returns Whether acceptance is present for the vendor.
8
+ */
9
+ export declare function hasVendorDisclaimerAcceptance(accepted: KycVendorDisclaimersAccepted, vendor: KycVendor): boolean;
10
+ /**
11
+ * Returns persisted Iron disclaimer ids, if any.
12
+ *
13
+ * @param accepted - Vendor-disclaimer acceptance map.
14
+ * @returns The accepted disclaimer ids, or an empty array.
15
+ */
16
+ export declare function ironDisclaimerIds(accepted: KycVendorDisclaimersAccepted): string[];
17
+ /**
18
+ * Records vendor disclaimer acceptance for the active vendor.
19
+ *
20
+ * @param accepted - Existing vendor-disclaimer acceptance map.
21
+ * @param vendor - Identity vendor being accepted.
22
+ * @param params - Acceptance payload for the vendor.
23
+ * @param params.termsAcceptedAt - MoonPay acceptance timestamp.
24
+ * @param params.disclaimerIds - Iron disclaimer ids.
25
+ * @returns The updated acceptance map.
26
+ */
27
+ export declare function recordVendorDisclaimerAcceptance(accepted: KycVendorDisclaimersAccepted, vendor: KycVendor, params: {
28
+ termsAcceptedAt: string;
29
+ disclaimerIds: string[];
30
+ }): KycVendorDisclaimersAccepted;
31
+ /**
32
+ * Clears persisted vendor disclaimer acceptance for one vendor.
33
+ *
34
+ * @param accepted - Existing vendor-disclaimer acceptance map.
35
+ * @param vendor - Identity vendor whose acceptance should be cleared.
36
+ * @returns The updated acceptance map.
37
+ */
38
+ export declare function clearVendorDisclaimerAcceptance(accepted: KycVendorDisclaimersAccepted, vendor: KycVendor): KycVendorDisclaimersAccepted;
39
+ //# sourceMappingURL=vendorDisclaimerAcceptance.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendorDisclaimerAcceptance.d.cts","sourceRoot":"","sources":["../src/vendorDisclaimerAcceptance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B,EAAE,oBAAmB;AAE1E;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,4BAA4B,EACtC,MAAM,EAAE,SAAS,GAChB,OAAO,CAQT;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,4BAA4B,GACrC,MAAM,EAAE,CAEV;AAED;;;;;;;;;GASG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,4BAA4B,EACtC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,GAC3D,4BAA4B,CAc9B;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,4BAA4B,EACtC,MAAM,EAAE,SAAS,GAChB,4BAA4B,CAQ9B"}
@@ -0,0 +1,39 @@
1
+ import type { KycVendor, KycVendorDisclaimersAccepted } from "./types.mjs";
2
+ /**
3
+ * Returns whether persisted vendor disclaimer acceptance exists for `vendor`.
4
+ *
5
+ * @param accepted - Vendor-disclaimer acceptance map.
6
+ * @param vendor - Identity vendor to inspect.
7
+ * @returns Whether acceptance is present for the vendor.
8
+ */
9
+ export declare function hasVendorDisclaimerAcceptance(accepted: KycVendorDisclaimersAccepted, vendor: KycVendor): boolean;
10
+ /**
11
+ * Returns persisted Iron disclaimer ids, if any.
12
+ *
13
+ * @param accepted - Vendor-disclaimer acceptance map.
14
+ * @returns The accepted disclaimer ids, or an empty array.
15
+ */
16
+ export declare function ironDisclaimerIds(accepted: KycVendorDisclaimersAccepted): string[];
17
+ /**
18
+ * Records vendor disclaimer acceptance for the active vendor.
19
+ *
20
+ * @param accepted - Existing vendor-disclaimer acceptance map.
21
+ * @param vendor - Identity vendor being accepted.
22
+ * @param params - Acceptance payload for the vendor.
23
+ * @param params.termsAcceptedAt - MoonPay acceptance timestamp.
24
+ * @param params.disclaimerIds - Iron disclaimer ids.
25
+ * @returns The updated acceptance map.
26
+ */
27
+ export declare function recordVendorDisclaimerAcceptance(accepted: KycVendorDisclaimersAccepted, vendor: KycVendor, params: {
28
+ termsAcceptedAt: string;
29
+ disclaimerIds: string[];
30
+ }): KycVendorDisclaimersAccepted;
31
+ /**
32
+ * Clears persisted vendor disclaimer acceptance for one vendor.
33
+ *
34
+ * @param accepted - Existing vendor-disclaimer acceptance map.
35
+ * @param vendor - Identity vendor whose acceptance should be cleared.
36
+ * @returns The updated acceptance map.
37
+ */
38
+ export declare function clearVendorDisclaimerAcceptance(accepted: KycVendorDisclaimersAccepted, vendor: KycVendor): KycVendorDisclaimersAccepted;
39
+ //# sourceMappingURL=vendorDisclaimerAcceptance.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendorDisclaimerAcceptance.d.mts","sourceRoot":"","sources":["../src/vendorDisclaimerAcceptance.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,4BAA4B,EAAE,oBAAmB;AAE1E;;;;;;GAMG;AACH,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,4BAA4B,EACtC,MAAM,EAAE,SAAS,GAChB,OAAO,CAQT;AAED;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAC/B,QAAQ,EAAE,4BAA4B,GACrC,MAAM,EAAE,CAEV;AAED;;;;;;;;;GASG;AACH,wBAAgB,gCAAgC,CAC9C,QAAQ,EAAE,4BAA4B,EACtC,MAAM,EAAE,SAAS,EACjB,MAAM,EAAE;IAAE,eAAe,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAA;CAAE,GAC3D,4BAA4B,CAc9B;AAED;;;;;;GAMG;AACH,wBAAgB,+BAA+B,CAC7C,QAAQ,EAAE,4BAA4B,EACtC,MAAM,EAAE,SAAS,GAChB,4BAA4B,CAQ9B"}
@@ -0,0 +1,67 @@
1
+ /**
2
+ * Returns whether persisted vendor disclaimer acceptance exists for `vendor`.
3
+ *
4
+ * @param accepted - Vendor-disclaimer acceptance map.
5
+ * @param vendor - Identity vendor to inspect.
6
+ * @returns Whether acceptance is present for the vendor.
7
+ */
8
+ export function hasVendorDisclaimerAcceptance(accepted, vendor) {
9
+ if (vendor === 'moonpay') {
10
+ return Boolean(accepted.moonpay?.termsAcceptedAt);
11
+ }
12
+ if (vendor === 'iron') {
13
+ return Boolean(accepted.iron?.disclaimerIds.length);
14
+ }
15
+ return false;
16
+ }
17
+ /**
18
+ * Returns persisted Iron disclaimer ids, if any.
19
+ *
20
+ * @param accepted - Vendor-disclaimer acceptance map.
21
+ * @returns The accepted disclaimer ids, or an empty array.
22
+ */
23
+ export function ironDisclaimerIds(accepted) {
24
+ return accepted.iron?.disclaimerIds ?? [];
25
+ }
26
+ /**
27
+ * Records vendor disclaimer acceptance for the active vendor.
28
+ *
29
+ * @param accepted - Existing vendor-disclaimer acceptance map.
30
+ * @param vendor - Identity vendor being accepted.
31
+ * @param params - Acceptance payload for the vendor.
32
+ * @param params.termsAcceptedAt - MoonPay acceptance timestamp.
33
+ * @param params.disclaimerIds - Iron disclaimer ids.
34
+ * @returns The updated acceptance map.
35
+ */
36
+ export function recordVendorDisclaimerAcceptance(accepted, vendor, params) {
37
+ if (vendor === 'moonpay') {
38
+ return {
39
+ ...accepted,
40
+ moonpay: { termsAcceptedAt: params.termsAcceptedAt },
41
+ };
42
+ }
43
+ if (vendor === 'iron') {
44
+ return {
45
+ ...accepted,
46
+ iron: { disclaimerIds: params.disclaimerIds },
47
+ };
48
+ }
49
+ return accepted;
50
+ }
51
+ /**
52
+ * Clears persisted vendor disclaimer acceptance for one vendor.
53
+ *
54
+ * @param accepted - Existing vendor-disclaimer acceptance map.
55
+ * @param vendor - Identity vendor whose acceptance should be cleared.
56
+ * @returns The updated acceptance map.
57
+ */
58
+ export function clearVendorDisclaimerAcceptance(accepted, vendor) {
59
+ if (vendor === 'moonpay') {
60
+ return { ...accepted, moonpay: null };
61
+ }
62
+ if (vendor === 'iron') {
63
+ return { ...accepted, iron: null };
64
+ }
65
+ return accepted;
66
+ }
67
+ //# sourceMappingURL=vendorDisclaimerAcceptance.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"vendorDisclaimerAcceptance.mjs","sourceRoot":"","sources":["../src/vendorDisclaimerAcceptance.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,UAAU,6BAA6B,CAC3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":["import type { KycVendor, KycVendorDisclaimersAccepted } from './types.js';\n\n/**\n * Returns whether persisted vendor disclaimer acceptance exists for `vendor`.\n *\n * @param accepted - Vendor-disclaimer acceptance map.\n * @param vendor - Identity vendor to inspect.\n * @returns Whether acceptance is present for the vendor.\n */\nexport function hasVendorDisclaimerAcceptance(\n accepted: KycVendorDisclaimersAccepted,\n vendor: KycVendor,\n): boolean {\n if (vendor === 'moonpay') {\n return Boolean(accepted.moonpay?.termsAcceptedAt);\n }\n if (vendor === 'iron') {\n return Boolean(accepted.iron?.disclaimerIds.length);\n }\n return false;\n}\n\n/**\n * Returns persisted Iron disclaimer ids, if any.\n *\n * @param accepted - Vendor-disclaimer acceptance map.\n * @returns The accepted disclaimer ids, or an empty array.\n */\nexport function ironDisclaimerIds(\n accepted: KycVendorDisclaimersAccepted,\n): string[] {\n return accepted.iron?.disclaimerIds ?? [];\n}\n\n/**\n * Records vendor disclaimer acceptance for the active vendor.\n *\n * @param accepted - Existing vendor-disclaimer acceptance map.\n * @param vendor - Identity vendor being accepted.\n * @param params - Acceptance payload for the vendor.\n * @param params.termsAcceptedAt - MoonPay acceptance timestamp.\n * @param params.disclaimerIds - Iron disclaimer ids.\n * @returns The updated acceptance map.\n */\nexport function recordVendorDisclaimerAcceptance(\n accepted: KycVendorDisclaimersAccepted,\n vendor: KycVendor,\n params: { termsAcceptedAt: string; disclaimerIds: string[] },\n): KycVendorDisclaimersAccepted {\n if (vendor === 'moonpay') {\n return {\n ...accepted,\n moonpay: { termsAcceptedAt: params.termsAcceptedAt },\n };\n }\n if (vendor === 'iron') {\n return {\n ...accepted,\n iron: { disclaimerIds: params.disclaimerIds },\n };\n }\n return accepted;\n}\n\n/**\n * Clears persisted vendor disclaimer acceptance for one vendor.\n *\n * @param accepted - Existing vendor-disclaimer acceptance map.\n * @param vendor - Identity vendor whose acceptance should be cleared.\n * @returns The updated acceptance map.\n */\nexport function clearVendorDisclaimerAcceptance(\n accepted: KycVendorDisclaimersAccepted,\n vendor: KycVendor,\n): KycVendorDisclaimersAccepted {\n if (vendor === 'moonpay') {\n return { ...accepted, moonpay: null };\n }\n if (vendor === 'iron') {\n return { ...accepted, iron: null };\n }\n return accepted;\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@metamask-previews/kyc-controller",
3
- "version": "0.0.0-preview-ea6a28c61",
3
+ "version": "0.0.0-preview-e12b5ece6",
4
4
  "description": "Shared KYC / identity verification controller used across MetaMask clients",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -64,7 +64,7 @@
64
64
  "@metamask/messenger": "^2.0.0",
65
65
  "@metamask/profile-sync-controller": "^29.0.0",
66
66
  "@metamask/superstruct": "^3.4.1",
67
- "@metamask/utils": "^11.11.0",
67
+ "@metamask/utils": "^11.12.0",
68
68
  "@noble/ciphers": "^1.3.0",
69
69
  "@noble/curves": "^1.9.2",
70
70
  "@noble/hashes": "^1.8.0",