@metamask-previews/kyc-controller 0.0.0-preview-4f4c98e → 0.0.0-preview-eb263b0ee

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 (191) hide show
  1. package/dist/KycController-method-action-types.cjs +7 -0
  2. package/dist/KycController-method-action-types.cjs.map +1 -0
  3. package/dist/{KycController-method-action-types.d.ts → KycController-method-action-types.d.cts} +2 -2
  4. package/dist/KycController-method-action-types.d.cts.map +1 -0
  5. package/dist/KycController-method-action-types.d.mts +237 -0
  6. package/dist/KycController-method-action-types.d.mts.map +1 -0
  7. package/dist/{KycController-method-action-types.js → KycController-method-action-types.mjs} +1 -1
  8. package/dist/KycController-method-action-types.mjs.map +1 -0
  9. package/dist/KycController.cjs +1843 -0
  10. package/dist/KycController.cjs.map +1 -0
  11. package/dist/{KycController.d.ts → KycController.d.cts} +9 -9
  12. package/dist/KycController.d.cts.map +1 -0
  13. package/dist/KycController.d.mts +393 -0
  14. package/dist/KycController.d.mts.map +1 -0
  15. package/dist/{KycController.js → KycController.mjs} +10 -10
  16. package/dist/KycController.mjs.map +1 -0
  17. package/dist/KycService-method-action-types.cjs +7 -0
  18. package/dist/KycService-method-action-types.cjs.map +1 -0
  19. package/dist/{KycService-method-action-types.d.ts → KycService-method-action-types.d.cts} +2 -2
  20. package/dist/KycService-method-action-types.d.cts.map +1 -0
  21. package/dist/KycService-method-action-types.d.mts +186 -0
  22. package/dist/KycService-method-action-types.d.mts.map +1 -0
  23. package/dist/{KycService-method-action-types.js → KycService-method-action-types.mjs} +1 -1
  24. package/dist/KycService-method-action-types.mjs.map +1 -0
  25. package/dist/KycService.cjs +628 -0
  26. package/dist/KycService.cjs.map +1 -0
  27. package/dist/{KycService.d.ts → KycService.d.cts} +12 -12
  28. package/dist/KycService.d.cts.map +1 -0
  29. package/dist/KycService.d.mts +494 -0
  30. package/dist/KycService.d.mts.map +1 -0
  31. package/dist/{KycService.js → KycService.mjs} +7 -7
  32. package/dist/{KycService.js.map → KycService.mjs.map} +1 -1
  33. package/dist/countryCodes.cjs +274 -0
  34. package/dist/countryCodes.cjs.map +1 -0
  35. package/dist/{countryCodes.d.ts → countryCodes.d.cts} +1 -1
  36. package/dist/countryCodes.d.cts.map +1 -0
  37. package/dist/countryCodes.d.mts +18 -0
  38. package/dist/countryCodes.d.mts.map +1 -0
  39. package/dist/{countryCodes.js → countryCodes.mjs} +1 -1
  40. package/dist/countryCodes.mjs.map +1 -0
  41. package/dist/crypto.cjs +154 -0
  42. package/dist/crypto.cjs.map +1 -0
  43. package/dist/{crypto.d.ts → crypto.d.cts} +1 -1
  44. package/dist/crypto.d.cts.map +1 -0
  45. package/dist/crypto.d.mts +84 -0
  46. package/dist/crypto.d.mts.map +1 -0
  47. package/dist/{crypto.js → crypto.mjs} +7 -7
  48. package/dist/crypto.mjs.map +1 -0
  49. package/dist/encoding.cjs +40 -0
  50. package/dist/encoding.cjs.map +1 -0
  51. package/dist/{encoding.d.ts → encoding.d.cts} +1 -1
  52. package/dist/encoding.d.cts.map +1 -0
  53. package/dist/encoding.d.mts +24 -0
  54. package/dist/encoding.d.mts.map +1 -0
  55. package/dist/{encoding.js → encoding.mjs} +2 -2
  56. package/dist/encoding.mjs.map +1 -0
  57. package/dist/index.cjs +37 -0
  58. package/dist/index.cjs.map +1 -0
  59. package/dist/{index.d.ts → index.d.cts} +19 -19
  60. package/dist/index.d.cts.map +1 -0
  61. package/dist/index.d.mts +19 -0
  62. package/dist/index.d.mts.map +1 -0
  63. package/dist/index.mjs +12 -0
  64. package/dist/index.mjs.map +1 -0
  65. package/dist/selectors.cjs +30 -0
  66. package/dist/selectors.cjs.map +1 -0
  67. package/dist/{selectors.d.ts → selectors.d.cts} +4 -4
  68. package/dist/selectors.d.cts.map +1 -0
  69. package/dist/selectors.d.mts +24 -0
  70. package/dist/selectors.d.mts.map +1 -0
  71. package/dist/{selectors.js → selectors.mjs} +2 -2
  72. package/dist/selectors.mjs.map +1 -0
  73. package/dist/types.cjs +10 -0
  74. package/dist/types.cjs.map +1 -0
  75. package/dist/{types.d.ts → types.d.cts} +1 -1
  76. package/dist/types.d.cts.map +1 -0
  77. package/dist/types.d.mts +208 -0
  78. package/dist/types.d.mts.map +1 -0
  79. package/dist/{types.js → types.mjs} +1 -1
  80. package/dist/types.mjs.map +1 -0
  81. package/dist/ukyc/constants.cjs +75 -0
  82. package/dist/ukyc/constants.cjs.map +1 -0
  83. package/dist/ukyc/{constants.d.ts → constants.d.cts} +9 -9
  84. package/dist/ukyc/constants.d.cts.map +1 -0
  85. package/dist/ukyc/constants.d.mts +69 -0
  86. package/dist/ukyc/constants.d.mts.map +1 -0
  87. package/dist/ukyc/{constants.js → constants.mjs} +1 -1
  88. package/dist/ukyc/constants.mjs.map +1 -0
  89. package/dist/ukyc/deriveClientMaterial.cjs +65 -0
  90. package/dist/ukyc/deriveClientMaterial.cjs.map +1 -0
  91. package/dist/ukyc/{deriveClientMaterial.d.ts → deriveClientMaterial.d.cts} +1 -1
  92. package/dist/ukyc/deriveClientMaterial.d.cts.map +1 -0
  93. package/dist/ukyc/deriveClientMaterial.d.mts +54 -0
  94. package/dist/ukyc/deriveClientMaterial.d.mts.map +1 -0
  95. package/dist/ukyc/{deriveClientMaterial.js → deriveClientMaterial.mjs} +7 -7
  96. package/dist/ukyc/deriveClientMaterial.mjs.map +1 -0
  97. package/dist/ukyc/jwtChain.cjs +54 -0
  98. package/dist/ukyc/jwtChain.cjs.map +1 -0
  99. package/dist/ukyc/{jwtChain.d.ts → jwtChain.d.cts} +1 -1
  100. package/dist/ukyc/jwtChain.d.cts.map +1 -0
  101. package/dist/ukyc/jwtChain.d.mts +40 -0
  102. package/dist/ukyc/jwtChain.d.mts.map +1 -0
  103. package/dist/ukyc/{jwtChain.js → jwtChain.mjs} +4 -4
  104. package/dist/ukyc/jwtChain.mjs.map +1 -0
  105. package/dist/ukyc/localUserSecret.cjs +98 -0
  106. package/dist/ukyc/localUserSecret.cjs.map +1 -0
  107. package/dist/ukyc/{localUserSecret.d.ts → localUserSecret.d.cts} +1 -1
  108. package/dist/ukyc/localUserSecret.d.cts.map +1 -0
  109. package/dist/ukyc/localUserSecret.d.mts +65 -0
  110. package/dist/ukyc/localUserSecret.d.mts.map +1 -0
  111. package/dist/ukyc/{localUserSecret.js → localUserSecret.mjs} +4 -4
  112. package/dist/ukyc/localUserSecret.mjs.map +1 -0
  113. package/dist/ukyc/storageAccessToken.cjs +139 -0
  114. package/dist/ukyc/storageAccessToken.cjs.map +1 -0
  115. package/dist/ukyc/{storageAccessToken.d.ts → storageAccessToken.d.cts} +2 -2
  116. package/dist/ukyc/storageAccessToken.d.cts.map +1 -0
  117. package/dist/ukyc/storageAccessToken.d.mts +99 -0
  118. package/dist/ukyc/storageAccessToken.d.mts.map +1 -0
  119. package/dist/ukyc/{storageAccessToken.js → storageAccessToken.mjs} +5 -5
  120. package/dist/ukyc/storageAccessToken.mjs.map +1 -0
  121. package/dist/ukyc/testToken.cjs +61 -0
  122. package/dist/ukyc/testToken.cjs.map +1 -0
  123. package/dist/ukyc/{testToken.d.ts → testToken.d.cts} +2 -2
  124. package/dist/ukyc/testToken.d.cts.map +1 -0
  125. package/dist/ukyc/testToken.d.mts +50 -0
  126. package/dist/ukyc/testToken.d.mts.map +1 -0
  127. package/dist/ukyc/{testToken.js → testToken.mjs} +5 -5
  128. package/dist/ukyc/testToken.mjs.map +1 -0
  129. package/dist/ukyc/wrapEncryptionKey.cjs +37 -0
  130. package/dist/ukyc/wrapEncryptionKey.cjs.map +1 -0
  131. package/dist/ukyc/{wrapEncryptionKey.d.ts → wrapEncryptionKey.d.cts} +1 -1
  132. package/dist/ukyc/wrapEncryptionKey.d.cts.map +1 -0
  133. package/dist/ukyc/wrapEncryptionKey.d.mts +41 -0
  134. package/dist/ukyc/wrapEncryptionKey.d.mts.map +1 -0
  135. package/dist/ukyc/{wrapEncryptionKey.js → wrapEncryptionKey.mjs} +4 -3
  136. package/dist/ukyc/wrapEncryptionKey.mjs.map +1 -0
  137. package/dist/ukyc/wrapUserKey.cjs +80 -0
  138. package/dist/ukyc/wrapUserKey.cjs.map +1 -0
  139. package/dist/ukyc/{wrapUserKey.d.ts → wrapUserKey.d.cts} +1 -1
  140. package/dist/ukyc/wrapUserKey.d.cts.map +1 -0
  141. package/dist/ukyc/wrapUserKey.d.mts +26 -0
  142. package/dist/ukyc/wrapUserKey.d.mts.map +1 -0
  143. package/dist/ukyc/{wrapUserKey.js → wrapUserKey.mjs} +8 -8
  144. package/dist/ukyc/wrapUserKey.mjs.map +1 -0
  145. package/dist/ukyc/wrappedRelayPayload.cjs +32 -0
  146. package/dist/ukyc/wrappedRelayPayload.cjs.map +1 -0
  147. package/dist/ukyc/{wrappedRelayPayload.d.ts → wrappedRelayPayload.d.cts} +3 -3
  148. package/dist/ukyc/wrappedRelayPayload.d.cts.map +1 -0
  149. package/dist/ukyc/wrappedRelayPayload.d.mts +35 -0
  150. package/dist/ukyc/wrappedRelayPayload.d.mts.map +1 -0
  151. package/dist/ukyc/{wrappedRelayPayload.js → wrappedRelayPayload.mjs} +2 -2
  152. package/dist/ukyc/wrappedRelayPayload.mjs.map +1 -0
  153. package/package.json +17 -13
  154. package/dist/KycController-method-action-types.d.ts.map +0 -1
  155. package/dist/KycController-method-action-types.js.map +0 -1
  156. package/dist/KycController.d.ts.map +0 -1
  157. package/dist/KycController.js.map +0 -1
  158. package/dist/KycService-method-action-types.d.ts.map +0 -1
  159. package/dist/KycService-method-action-types.js.map +0 -1
  160. package/dist/KycService.d.ts.map +0 -1
  161. package/dist/countryCodes.d.ts.map +0 -1
  162. package/dist/countryCodes.js.map +0 -1
  163. package/dist/crypto.d.ts.map +0 -1
  164. package/dist/crypto.js.map +0 -1
  165. package/dist/encoding.d.ts.map +0 -1
  166. package/dist/encoding.js.map +0 -1
  167. package/dist/index.d.ts.map +0 -1
  168. package/dist/index.js +0 -12
  169. package/dist/index.js.map +0 -1
  170. package/dist/selectors.d.ts.map +0 -1
  171. package/dist/selectors.js.map +0 -1
  172. package/dist/types.d.ts.map +0 -1
  173. package/dist/types.js.map +0 -1
  174. package/dist/ukyc/constants.d.ts.map +0 -1
  175. package/dist/ukyc/constants.js.map +0 -1
  176. package/dist/ukyc/deriveClientMaterial.d.ts.map +0 -1
  177. package/dist/ukyc/deriveClientMaterial.js.map +0 -1
  178. package/dist/ukyc/jwtChain.d.ts.map +0 -1
  179. package/dist/ukyc/jwtChain.js.map +0 -1
  180. package/dist/ukyc/localUserSecret.d.ts.map +0 -1
  181. package/dist/ukyc/localUserSecret.js.map +0 -1
  182. package/dist/ukyc/storageAccessToken.d.ts.map +0 -1
  183. package/dist/ukyc/storageAccessToken.js.map +0 -1
  184. package/dist/ukyc/testToken.d.ts.map +0 -1
  185. package/dist/ukyc/testToken.js.map +0 -1
  186. package/dist/ukyc/wrapEncryptionKey.d.ts.map +0 -1
  187. package/dist/ukyc/wrapEncryptionKey.js.map +0 -1
  188. package/dist/ukyc/wrapUserKey.d.ts.map +0 -1
  189. package/dist/ukyc/wrapUserKey.js.map +0 -1
  190. package/dist/ukyc/wrappedRelayPayload.d.ts.map +0 -1
  191. package/dist/ukyc/wrappedRelayPayload.js.map +0 -1
@@ -0,0 +1,41 @@
1
+ /**
2
+ * Wraps a secret for the UKYC session server using NaCl's `crypto_box`
3
+ * (X25519 + XSalsa20-Poly1305) established with a per-secret wrapping key
4
+ * returned inside an encryption schema from `createUkycSession`.
5
+ *
6
+ * Unlike {@link wrapUserKey} (which generates a fresh ephemeral keypair per
7
+ * call), this reuses a session client keypair. There is no prior wrapping-key
8
+ * exchange to register that public key, so `data` is
9
+ * `clientPublicKey (32) || ciphertext+tag` and only `{ data, nonce }` need be
10
+ * transmitted. Used for both the `data_encryption_key` and the
11
+ * `ukyc_capability_token`.
12
+ */
13
+ /**
14
+ * The transmitted portion of a wrapped secret: the sender public key prefixed
15
+ * to the `crypto_box` ciphertext (which includes the 16-byte Poly1305 auth
16
+ * tag), and the nonce, both unpadded base64url-encoded. Matches the KYC API
17
+ * `CapabilityAuthorization` wire shape.
18
+ */
19
+ export type WrappedEncryptionKeyParts = {
20
+ data: string;
21
+ nonce: string;
22
+ };
23
+ /**
24
+ * Wraps `plaintext` for the UKYC session server.
25
+ *
26
+ * The box is sealed with NaCl's `crypto_box`, keyed by the X25519 shared secret
27
+ * between our session client private key and the session server public key
28
+ * from an encryption schema (`encryptionDataKey` or `ukycCapabilityToken`)
29
+ * returned by `createUkycSession`. The 32-byte client public key is prefixed
30
+ * onto `data` so the server can open the box without a prior key-registration
31
+ * step.
32
+ *
33
+ * @param sessionClientPrivateKey - Our session's X25519 private key.
34
+ * @param sessionServerPublicKey - The server's X25519 public key (base64url).
35
+ * @param plaintext - The raw bytes to encrypt (e.g. the `data_encryption_key`
36
+ * or the encoded `ukyc_capability_token`).
37
+ * @returns The base64url `data` (`clientPublicKey || ciphertext+tag`) and
38
+ * `nonce`.
39
+ */
40
+ export declare function wrapEncryptionKey(sessionClientPrivateKey: Uint8Array, sessionServerPublicKey: string, plaintext: Uint8Array): WrappedEncryptionKeyParts;
41
+ //# sourceMappingURL=wrapEncryptionKey.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapEncryptionKey.d.mts","sourceRoot":"","sources":["../../src/ukyc/wrapEncryptionKey.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;;GAWG;AAEH;;;;;GAKG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;;;;;;GAgBG;AACH,wBAAgB,iBAAiB,CAC/B,uBAAuB,EAAE,UAAU,EACnC,sBAAsB,EAAE,MAAM,EAC9B,SAAS,EAAE,UAAU,GACpB,yBAAyB,CAmB3B"}
@@ -1,5 +1,6 @@
1
- import { randomBytes, box } from 'tweetnacl';
2
- import { base64UrlToBytes, toBase64Url } from '../encoding.js';
1
+ import $tweetnacl from "tweetnacl";
2
+ const { randomBytes, box } = $tweetnacl;
3
+ import { base64UrlToBytes, toBase64Url } from "../encoding.mjs";
3
4
  /**
4
5
  * Wraps `plaintext` for the UKYC session server.
5
6
  *
@@ -30,4 +31,4 @@ export function wrapEncryptionKey(sessionClientPrivateKey, sessionServerPublicKe
30
31
  nonce: toBase64Url(nonce),
31
32
  };
32
33
  }
33
- //# sourceMappingURL=wrapEncryptionKey.js.map
34
+ //# sourceMappingURL=wrapEncryptionKey.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapEncryptionKey.mjs","sourceRoot":"","sources":["../../src/ukyc/wrapEncryptionKey.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,wBAAuB;AA0B/D;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,UAAU,iBAAiB,CAC/B,uBAAmC,EACnC,sBAA8B,EAC9B,SAAqB;IAErB,MAAM,eAAe,GAAG,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IACjE,MAAM,EAAE,SAAS,EAAE,eAAe,EAAE,GAAG,GAAG,CAAC,OAAO,CAAC,aAAa,CAC9D,uBAAuB,CACxB,CAAC;IACF,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,UAAU,GAAG,GAAG,CACpB,SAAS,EACT,KAAK,EACL,eAAe,EACf,uBAAuB,CACxB,CAAC;IACF,MAAM,IAAI,GAAG,IAAI,UAAU,CAAC,eAAe,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC;IACxE,IAAI,CAAC,GAAG,CAAC,eAAe,EAAE,CAAC,CAAC,CAAC;IAC7B,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,eAAe,CAAC,MAAM,CAAC,CAAC;IAC7C,OAAO;QACL,IAAI,EAAE,WAAW,CAAC,IAAI,CAAC;QACvB,KAAK,EAAE,WAAW,CAAC,KAAK,CAAC;KAC1B,CAAC;AACJ,CAAC","sourcesContent":["import { randomBytes, box } from 'tweetnacl';\n\nimport { base64UrlToBytes, toBase64Url } from '../encoding.js';\n\n/**\n * Wraps a secret for the UKYC session server using NaCl's `crypto_box`\n * (X25519 + XSalsa20-Poly1305) established with a per-secret wrapping key\n * returned inside an encryption schema from `createUkycSession`.\n *\n * Unlike {@link wrapUserKey} (which generates a fresh ephemeral keypair per\n * call), this reuses a session client keypair. There is no prior wrapping-key\n * exchange to register that public key, so `data` is\n * `clientPublicKey (32) || ciphertext+tag` and only `{ data, nonce }` need be\n * transmitted. Used for both the `data_encryption_key` and the\n * `ukyc_capability_token`.\n */\n\n/**\n * The transmitted portion of a wrapped secret: the sender public key prefixed\n * to the `crypto_box` ciphertext (which includes the 16-byte Poly1305 auth\n * tag), and the nonce, both unpadded base64url-encoded. Matches the KYC API\n * `CapabilityAuthorization` wire shape.\n */\nexport type WrappedEncryptionKeyParts = {\n data: string;\n nonce: string;\n};\n\n/**\n * Wraps `plaintext` for the UKYC session server.\n *\n * The box is sealed with NaCl's `crypto_box`, keyed by the X25519 shared secret\n * between our session client private key and the session server public key\n * from an encryption schema (`encryptionDataKey` or `ukycCapabilityToken`)\n * returned by `createUkycSession`. The 32-byte client public key is prefixed\n * onto `data` so the server can open the box without a prior key-registration\n * step.\n *\n * @param sessionClientPrivateKey - Our session's X25519 private key.\n * @param sessionServerPublicKey - The server's X25519 public key (base64url).\n * @param plaintext - The raw bytes to encrypt (e.g. the `data_encryption_key`\n * or the encoded `ukyc_capability_token`).\n * @returns The base64url `data` (`clientPublicKey || ciphertext+tag`) and\n * `nonce`.\n */\nexport function wrapEncryptionKey(\n sessionClientPrivateKey: Uint8Array,\n sessionServerPublicKey: string,\n plaintext: Uint8Array,\n): WrappedEncryptionKeyParts {\n const serverPublicKey = base64UrlToBytes(sessionServerPublicKey);\n const { publicKey: clientPublicKey } = box.keyPair.fromSecretKey(\n sessionClientPrivateKey,\n );\n const nonce = randomBytes(box.nonceLength);\n const ciphertext = box(\n plaintext,\n nonce,\n serverPublicKey,\n sessionClientPrivateKey,\n );\n const data = new Uint8Array(clientPublicKey.length + ciphertext.length);\n data.set(clientPublicKey, 0);\n data.set(ciphertext, clientPublicKey.length);\n return {\n data: toBase64Url(data),\n nonce: toBase64Url(nonce),\n };\n}\n"]}
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.wrapUserKey = void 0;
4
+ const utils_1 = require("@metamask/utils");
5
+ const aes_1 = require("@noble/ciphers/aes");
6
+ const ed25519_1 = require("@noble/curves/ed25519");
7
+ const hkdf_1 = require("@noble/hashes/hkdf");
8
+ const sha2_1 = require("@noble/hashes/sha2");
9
+ const utils_2 = require("@noble/hashes/utils");
10
+ const encoding_js_1 = require("../encoding.cjs");
11
+ /**
12
+ * Wraps (encrypts) a symmetric key so that only the holder of a given X25519
13
+ * private key can recover it — used to seal the `data_encryption_key` for the
14
+ * idOS Relay before it is handed to the UKYC API as `wrappedUserKey`.
15
+ */
16
+ /** X25519 public/private keys and AES-256-GCM keys are all 32 bytes. */
17
+ const X25519_KEY_SIZE_BYTES = 32;
18
+ /** 96-bit IV, the AES-GCM standard nonce size. */
19
+ const IV_SIZE_BYTES = 12;
20
+ /**
21
+ * Decodes an X25519 public key presented as either hex or base64/base64url.
22
+ *
23
+ * @param recipientPublicKey - The recipient's 32-byte X25519 public key.
24
+ * @returns The raw 32-byte public key.
25
+ */
26
+ function decodePublicKey(recipientPublicKey) {
27
+ const isHex = recipientPublicKey.length === X25519_KEY_SIZE_BYTES * 2 &&
28
+ /^[0-9a-fA-F]+$/u.test(recipientPublicKey);
29
+ const bytes = isHex
30
+ ? (0, utils_2.hexToBytes)(recipientPublicKey)
31
+ : (0, utils_1.base64ToBytes)(recipientPublicKey
32
+ .replace(/-/gu, '+')
33
+ .replace(/_/gu, '/')
34
+ .padEnd(recipientPublicKey.length +
35
+ ((4 - (recipientPublicKey.length % 4)) % 4), '='));
36
+ if (bytes.length !== X25519_KEY_SIZE_BYTES) {
37
+ throw new Error(`UKYC: wrappingPublicKey has unexpected length ${bytes.length}, expected ${X25519_KEY_SIZE_BYTES}.`);
38
+ }
39
+ return bytes;
40
+ }
41
+ /**
42
+ * Wraps `keyToWrap` for the holder of `recipientPublicKey` using an
43
+ * ephemeral-static ECDH + AES-256-GCM sealed-box scheme:
44
+ *
45
+ * ephemeral = fresh X25519 keypair (one per call)
46
+ * shared = X25519(ephemeralPrivate, recipientPublic)
47
+ * aeadKey = HKDF-SHA256(shared, 32 bytes)
48
+ * iv = 12 random bytes
49
+ * ct = AES-256-GCM(aeadKey, iv).encrypt(keyToWrap) // ct includes tag
50
+ *
51
+ * The recipient reverses it with their private key:
52
+ *
53
+ * shared = X25519(recipientPrivate, ephemeralPublic)
54
+ * aeadKey = HKDF-SHA256(shared, 32 bytes)
55
+ * key = AES-256-GCM(aeadKey, iv).decrypt(ct)
56
+ *
57
+ * This mirrors the X25519 + AES-256-GCM/HKDF decryption used for MoonPay
58
+ * Check/Auth-frame credentials, so both directions share one primitive.
59
+ *
60
+ * @param recipientPublicKey - The recipient's X25519 public key (hex or base64).
61
+ * @param keyToWrap - The raw symmetric key bytes to encrypt (e.g. the
62
+ * `data_encryption_key`).
63
+ * @returns Base64url of `ephemeralPublicKey(32) || iv(12) || ciphertext+tag`.
64
+ */
65
+ function wrapUserKey(recipientPublicKey, keyToWrap) {
66
+ const recipient = decodePublicKey(recipientPublicKey);
67
+ const ephemeralPrivateKey = ed25519_1.x25519.utils.randomSecretKey();
68
+ const ephemeralPublicKey = ed25519_1.x25519.getPublicKey(ephemeralPrivateKey);
69
+ const shared = ed25519_1.x25519.getSharedSecret(ephemeralPrivateKey, recipient);
70
+ const aeadKey = (0, hkdf_1.hkdf)(sha2_1.sha256, shared, undefined, undefined, 32);
71
+ const iv = (0, utils_2.randomBytes)(IV_SIZE_BYTES);
72
+ const ciphertext = (0, aes_1.gcm)(aeadKey, iv).encrypt(keyToWrap);
73
+ const blob = new Uint8Array(ephemeralPublicKey.length + iv.length + ciphertext.length);
74
+ blob.set(ephemeralPublicKey, 0);
75
+ blob.set(iv, ephemeralPublicKey.length);
76
+ blob.set(ciphertext, ephemeralPublicKey.length + iv.length);
77
+ return (0, encoding_js_1.toBase64Url)(blob);
78
+ }
79
+ exports.wrapUserKey = wrapUserKey;
80
+ //# sourceMappingURL=wrapUserKey.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapUserKey.cjs","sourceRoot":"","sources":["../../src/ukyc/wrapUserKey.ts"],"names":[],"mappings":";;;AAAA,2CAAgD;AAChD,4CAAyC;AACzC,mDAA+C;AAC/C,6CAA0C;AAC1C,6CAA4C;AAC5C,+CAA8D;AAE9D,iDAA6C;AAE7C;;;;GAIG;AAEH,wEAAwE;AACxE,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,kDAAkD;AAClD,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;;;;GAKG;AACH,SAAS,eAAe,CAAC,kBAA0B;IACjD,MAAM,KAAK,GACT,kBAAkB,CAAC,MAAM,KAAK,qBAAqB,GAAG,CAAC;QACvD,iBAAiB,CAAC,IAAI,CAAC,kBAAkB,CAAC,CAAC;IAE7C,MAAM,KAAK,GAAG,KAAK;QACjB,CAAC,CAAC,IAAA,kBAAU,EAAC,kBAAkB,CAAC;QAChC,CAAC,CAAC,IAAA,qBAAa,EACX,kBAAkB;aACf,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC;aACnB,MAAM,CACL,kBAAkB,CAAC,MAAM;YACvB,CAAC,CAAC,CAAC,GAAG,CAAC,kBAAkB,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,EAC7C,GAAG,CACJ,CACJ,CAAC;IAEN,IAAI,KAAK,CAAC,MAAM,KAAK,qBAAqB,EAAE,CAAC;QAC3C,MAAM,IAAI,KAAK,CACb,iDAAiD,KAAK,CAAC,MAAM,cA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'@noble/curves/ed25519';\nimport { hkdf } from '@noble/hashes/hkdf';\nimport { sha256 } from '@noble/hashes/sha2';\nimport { hexToBytes, randomBytes } from '@noble/hashes/utils';\n\nimport { toBase64Url } from '../encoding.js';\n\n/**\n * Wraps (encrypts) a symmetric key so that only the holder of a given X25519\n * private key can recover it — used to seal the `data_encryption_key` for the\n * idOS Relay before it is handed to the UKYC API as `wrappedUserKey`.\n */\n\n/** X25519 public/private keys and AES-256-GCM keys are all 32 bytes. */\nconst X25519_KEY_SIZE_BYTES = 32;\n\n/** 96-bit IV, the AES-GCM standard nonce size. */\nconst IV_SIZE_BYTES = 12;\n\n/**\n * Decodes an X25519 public key presented as either hex or base64/base64url.\n *\n * @param recipientPublicKey - The recipient's 32-byte X25519 public key.\n * @returns The raw 32-byte public key.\n */\nfunction decodePublicKey(recipientPublicKey: string): Uint8Array {\n const isHex =\n recipientPublicKey.length === X25519_KEY_SIZE_BYTES * 2 &&\n /^[0-9a-fA-F]+$/u.test(recipientPublicKey);\n\n const bytes = isHex\n ? hexToBytes(recipientPublicKey)\n : base64ToBytes(\n recipientPublicKey\n .replace(/-/gu, '+')\n .replace(/_/gu, '/')\n .padEnd(\n recipientPublicKey.length +\n ((4 - (recipientPublicKey.length % 4)) % 4),\n '=',\n ),\n );\n\n if (bytes.length !== X25519_KEY_SIZE_BYTES) {\n throw new Error(\n `UKYC: wrappingPublicKey has unexpected length ${bytes.length}, expected ${X25519_KEY_SIZE_BYTES}.`,\n );\n }\n return bytes;\n}\n\n/**\n * Wraps `keyToWrap` for the holder of `recipientPublicKey` using an\n * ephemeral-static ECDH + AES-256-GCM sealed-box scheme:\n *\n * ephemeral = fresh X25519 keypair (one per call)\n * shared = X25519(ephemeralPrivate, recipientPublic)\n * aeadKey = HKDF-SHA256(shared, 32 bytes)\n * iv = 12 random bytes\n * ct = AES-256-GCM(aeadKey, iv).encrypt(keyToWrap) // ct includes tag\n *\n * The recipient reverses it with their private key:\n *\n * shared = X25519(recipientPrivate, ephemeralPublic)\n * aeadKey = HKDF-SHA256(shared, 32 bytes)\n * key = AES-256-GCM(aeadKey, iv).decrypt(ct)\n *\n * This mirrors the X25519 + AES-256-GCM/HKDF decryption used for MoonPay\n * Check/Auth-frame credentials, so both directions share one primitive.\n *\n * @param recipientPublicKey - The recipient's X25519 public key (hex or base64).\n * @param keyToWrap - The raw symmetric key bytes to encrypt (e.g. the\n * `data_encryption_key`).\n * @returns Base64url of `ephemeralPublicKey(32) || iv(12) || ciphertext+tag`.\n */\nexport function wrapUserKey(\n recipientPublicKey: string,\n keyToWrap: Uint8Array,\n): string {\n const recipient = decodePublicKey(recipientPublicKey);\n\n const ephemeralPrivateKey = x25519.utils.randomSecretKey();\n const ephemeralPublicKey = x25519.getPublicKey(ephemeralPrivateKey);\n\n const shared = x25519.getSharedSecret(ephemeralPrivateKey, recipient);\n const aeadKey = hkdf(sha256, shared, undefined, undefined, 32);\n\n const iv = randomBytes(IV_SIZE_BYTES);\n const ciphertext = gcm(aeadKey, iv).encrypt(keyToWrap);\n\n const blob = new Uint8Array(\n ephemeralPublicKey.length + iv.length + ciphertext.length,\n );\n blob.set(ephemeralPublicKey, 0);\n blob.set(iv, ephemeralPublicKey.length);\n blob.set(ciphertext, ephemeralPublicKey.length + iv.length);\n\n return toBase64Url(blob);\n}\n"]}
@@ -23,4 +23,4 @@
23
23
  * @returns Base64url of `ephemeralPublicKey(32) || iv(12) || ciphertext+tag`.
24
24
  */
25
25
  export declare function wrapUserKey(recipientPublicKey: string, keyToWrap: Uint8Array): string;
26
- //# sourceMappingURL=wrapUserKey.d.ts.map
26
+ //# sourceMappingURL=wrapUserKey.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapUserKey.d.cts","sourceRoot":"","sources":["../../src/ukyc/wrapUserKey.ts"],"names":[],"mappings":"AAqDA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,WAAW,CACzB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,UAAU,GACpB,MAAM,CAoBR"}
@@ -0,0 +1,26 @@
1
+ /**
2
+ * Wraps `keyToWrap` for the holder of `recipientPublicKey` using an
3
+ * ephemeral-static ECDH + AES-256-GCM sealed-box scheme:
4
+ *
5
+ * ephemeral = fresh X25519 keypair (one per call)
6
+ * shared = X25519(ephemeralPrivate, recipientPublic)
7
+ * aeadKey = HKDF-SHA256(shared, 32 bytes)
8
+ * iv = 12 random bytes
9
+ * ct = AES-256-GCM(aeadKey, iv).encrypt(keyToWrap) // ct includes tag
10
+ *
11
+ * The recipient reverses it with their private key:
12
+ *
13
+ * shared = X25519(recipientPrivate, ephemeralPublic)
14
+ * aeadKey = HKDF-SHA256(shared, 32 bytes)
15
+ * key = AES-256-GCM(aeadKey, iv).decrypt(ct)
16
+ *
17
+ * This mirrors the X25519 + AES-256-GCM/HKDF decryption used for MoonPay
18
+ * Check/Auth-frame credentials, so both directions share one primitive.
19
+ *
20
+ * @param recipientPublicKey - The recipient's X25519 public key (hex or base64).
21
+ * @param keyToWrap - The raw symmetric key bytes to encrypt (e.g. the
22
+ * `data_encryption_key`).
23
+ * @returns Base64url of `ephemeralPublicKey(32) || iv(12) || ciphertext+tag`.
24
+ */
25
+ export declare function wrapUserKey(recipientPublicKey: string, keyToWrap: Uint8Array): string;
26
+ //# sourceMappingURL=wrapUserKey.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapUserKey.d.mts","sourceRoot":"","sources":["../../src/ukyc/wrapUserKey.ts"],"names":[],"mappings":"AAqDA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAgB,WAAW,CACzB,kBAAkB,EAAE,MAAM,EAC1B,SAAS,EAAE,UAAU,GACpB,MAAM,CAoBR"}
@@ -1,10 +1,10 @@
1
- import { base64ToBytes } from '@metamask/utils';
2
- import { gcm } from '@noble/ciphers/aes';
3
- import { x25519 } from '@noble/curves/ed25519';
4
- import { hkdf } from '@noble/hashes/hkdf';
5
- import { sha256 } from '@noble/hashes/sha2';
6
- import { hexToBytes, randomBytes } from '@noble/hashes/utils';
7
- import { toBase64Url } from '../encoding.js';
1
+ import { base64ToBytes } from "@metamask/utils";
2
+ import { gcm } from "@noble/ciphers/aes";
3
+ import { x25519 } from "@noble/curves/ed25519";
4
+ import { hkdf } from "@noble/hashes/hkdf";
5
+ import { sha256 } from "@noble/hashes/sha2";
6
+ import { hexToBytes, randomBytes } from "@noble/hashes/utils";
7
+ import { toBase64Url } from "../encoding.mjs";
8
8
  /**
9
9
  * Wraps (encrypts) a symmetric key so that only the holder of a given X25519
10
10
  * private key can recover it — used to seal the `data_encryption_key` for the
@@ -73,4 +73,4 @@ export function wrapUserKey(recipientPublicKey, keyToWrap) {
73
73
  blob.set(ciphertext, ephemeralPublicKey.length + iv.length);
74
74
  return toBase64Url(blob);
75
75
  }
76
- //# sourceMappingURL=wrapUserKey.js.map
76
+ //# sourceMappingURL=wrapUserKey.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrapUserKey.mjs","sourceRoot":"","sources":["../../src/ukyc/wrapUserKey.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,wBAAwB;AAChD,OAAO,EAAE,GAAG,EAAE,2BAA2B;AACzC,OAAO,EAAE,MAAM,EAAE,8BAA8B;AAC/C,OAAO,EAAE,IAAI,EAAE,2BAA2B;AAC1C,OAAO,EAAE,MAAM,EAAE,2BAA2B;AAC5C,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,4BAA4B;AAE9D,OAAO,EAAE,WAAW,EAAE,wBAAuB;AAE7C;;;;GAIG;AAEH,wEAAwE;AACxE,MAAM,qBAAqB,GAAG,EAAE,CAAC;AAEjC,kDAAkD;AAClD,MAAM,aAAa,GAAG,EAAE,CAAC;AAEzB;;;;;GAKG;AACH,SAAS,eAAe,CAAC,kBAA0B;IACjD,MAAM,KAAK,GACT,kBAAkB,CAAC,MAAM,KAAK,qBAAqB,GAAG,CAAC;QACvD,iBAAiB,CAAC,IAAI,C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AI,UAAU,CACzB,kBAAkB,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,GAAG,UAAU,CAAC,MAAM,CAC1D,CAAC;IACF,IAAI,CAAC,GAAG,CAAC,kBAAkB,EAAE,CAAC,CAAC,CAAC;IAChC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,kBAAkB,CAAC,MAAM,CAAC,CAAC;IACxC,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,kBAAkB,CAAC,MAAM,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAE5D,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["import { base64ToBytes } from '@metamask/utils';\nimport { gcm } from '@noble/ciphers/aes';\nimport { x25519 } from '@noble/curves/ed25519';\nimport { hkdf } from '@noble/hashes/hkdf';\nimport { sha256 } from '@noble/hashes/sha2';\nimport { hexToBytes, randomBytes } from '@noble/hashes/utils';\n\nimport { toBase64Url } from '../encoding.js';\n\n/**\n * Wraps (encrypts) a symmetric key so that only the holder of a given X25519\n * private key can recover it — used to seal the `data_encryption_key` for the\n * idOS Relay before it is handed to the UKYC API as `wrappedUserKey`.\n */\n\n/** X25519 public/private keys and AES-256-GCM keys are all 32 bytes. */\nconst X25519_KEY_SIZE_BYTES = 32;\n\n/** 96-bit IV, the AES-GCM standard nonce size. */\nconst IV_SIZE_BYTES = 12;\n\n/**\n * Decodes an X25519 public key presented as either hex or base64/base64url.\n *\n * @param recipientPublicKey - The recipient's 32-byte X25519 public key.\n * @returns The raw 32-byte public key.\n */\nfunction decodePublicKey(recipientPublicKey: string): Uint8Array {\n const isHex =\n recipientPublicKey.length === X25519_KEY_SIZE_BYTES * 2 &&\n /^[0-9a-fA-F]+$/u.test(recipientPublicKey);\n\n const bytes = isHex\n ? hexToBytes(recipientPublicKey)\n : base64ToBytes(\n recipientPublicKey\n .replace(/-/gu, '+')\n .replace(/_/gu, '/')\n .padEnd(\n recipientPublicKey.length +\n ((4 - (recipientPublicKey.length % 4)) % 4),\n '=',\n ),\n );\n\n if (bytes.length !== X25519_KEY_SIZE_BYTES) {\n throw new Error(\n `UKYC: wrappingPublicKey has unexpected length ${bytes.length}, expected ${X25519_KEY_SIZE_BYTES}.`,\n );\n }\n return bytes;\n}\n\n/**\n * Wraps `keyToWrap` for the holder of `recipientPublicKey` using an\n * ephemeral-static ECDH + AES-256-GCM sealed-box scheme:\n *\n * ephemeral = fresh X25519 keypair (one per call)\n * shared = X25519(ephemeralPrivate, recipientPublic)\n * aeadKey = HKDF-SHA256(shared, 32 bytes)\n * iv = 12 random bytes\n * ct = AES-256-GCM(aeadKey, iv).encrypt(keyToWrap) // ct includes tag\n *\n * The recipient reverses it with their private key:\n *\n * shared = X25519(recipientPrivate, ephemeralPublic)\n * aeadKey = HKDF-SHA256(shared, 32 bytes)\n * key = AES-256-GCM(aeadKey, iv).decrypt(ct)\n *\n * This mirrors the X25519 + AES-256-GCM/HKDF decryption used for MoonPay\n * Check/Auth-frame credentials, so both directions share one primitive.\n *\n * @param recipientPublicKey - The recipient's X25519 public key (hex or base64).\n * @param keyToWrap - The raw symmetric key bytes to encrypt (e.g. the\n * `data_encryption_key`).\n * @returns Base64url of `ephemeralPublicKey(32) || iv(12) || ciphertext+tag`.\n */\nexport function wrapUserKey(\n recipientPublicKey: string,\n keyToWrap: Uint8Array,\n): string {\n const recipient = decodePublicKey(recipientPublicKey);\n\n const ephemeralPrivateKey = x25519.utils.randomSecretKey();\n const ephemeralPublicKey = x25519.getPublicKey(ephemeralPrivateKey);\n\n const shared = x25519.getSharedSecret(ephemeralPrivateKey, recipient);\n const aeadKey = hkdf(sha256, shared, undefined, undefined, 32);\n\n const iv = randomBytes(IV_SIZE_BYTES);\n const ciphertext = gcm(aeadKey, iv).encrypt(keyToWrap);\n\n const blob = new Uint8Array(\n ephemeralPublicKey.length + iv.length + ciphertext.length,\n );\n blob.set(ephemeralPublicKey, 0);\n blob.set(iv, ephemeralPublicKey.length);\n blob.set(ciphertext, ephemeralPublicKey.length + iv.length);\n\n return toBase64Url(blob);\n}\n"]}
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.buildWrappedRelayPayload = void 0;
4
+ const encoding_js_1 = require("../encoding.cjs");
5
+ /**
6
+ * Assembles the `wrapped_relay_payload` from derived client material and a
7
+ * Relay-presented `storage_access_token`.
8
+ *
9
+ * The token must be scoped for the Relay to present (`presenter: 'idos-relay'`)
10
+ * and must not authorize `delete`, which is never delegated to the Relay.
11
+ *
12
+ * @param material - Client material derived from `local_user_secret`.
13
+ * @param storageAccessToken - A `read`/`write`-scoped, Relay-presented token.
14
+ * @returns The `wrapped_relay_payload` to send to the Relay via the UKYC API.
15
+ */
16
+ function buildWrappedRelayPayload(material, storageAccessToken) {
17
+ const { presenter, operations } = storageAccessToken.payload;
18
+ if (presenter !== 'idos-relay') {
19
+ throw new Error('UKYC: wrapped_relay_payload requires a Relay-presented storage_access_token.');
20
+ }
21
+ if (operations.includes('delete')) {
22
+ throw new Error('UKYC: wrapped_relay_payload must not carry a delete-scoped storage_access_token.');
23
+ }
24
+ return {
25
+ storage_id: (0, encoding_js_1.toBase64Url)(material.storageId),
26
+ data_encryption_key: (0, encoding_js_1.toBase64Url)(material.dataEncryptionKey),
27
+ signing_public_key: (0, encoding_js_1.toBase64Url)(material.signingPublicKey),
28
+ storage_access_token: storageAccessToken,
29
+ };
30
+ }
31
+ exports.buildWrappedRelayPayload = buildWrappedRelayPayload;
32
+ //# sourceMappingURL=wrappedRelayPayload.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrappedRelayPayload.cjs","sourceRoot":"","sources":["../../src/ukyc/wrappedRelayPayload.ts"],"names":[],"mappings":";;;AAAA,iDAA6C;AA6B7C;;;;;;;;;;GAUG;AACH,SAAgB,wBAAwB,CACtC,QAA4B,EAC5B,kBAA0C;IAE1C,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,kBAAkB,CAAC,OAAO,CAAC;IAE7D,IAAI,SAAS,KAAK,YAAY,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,UAAU,EAAE,IAAA,yBAAW,EAAC,QAAQ,CAAC,SAAS,CAAC;QAC3C,mBAAmB,EAAE,IAAA,yBAAW,EAAC,QAAQ,CAAC,iBAAiB,CAAC;QAC5D,kBAAkB,EAAE,IAAA,yBAAW,EAAC,QAAQ,CAAC,gBAAgB,CAAC;QAC1D,oBAAoB,EAAE,kBAAkB;KACzC,CAAC;AACJ,CAAC;AAxBD,4DAwBC","sourcesContent":["import { toBase64Url } from '../encoding.js';\nimport type { UkycClientMaterial } from './deriveClientMaterial.js';\nimport type { UkycStorageAccessToken } from './storageAccessToken.js';\n\n/**\n * Builds the `wrapped_relay_payload` — the only client-derived material that\n * leaves the device. It is sent to the idOS Relay (through the UKYC API) so the\n * Relay can encrypt/decrypt and store KYC payloads on the user's behalf. See the\n * architecture doc, section \"Client-Derived Material\".\n *\n * Neither `local_user_secret` nor the private `signing_key` are ever included.\n * The `data_encryption_key` *is* included: it is intentionally shared with the\n * Relay so it can encrypt/decrypt payloads transiently.\n */\n\n/**\n * The Relay-facing bundle. `data_encryption_key` is base64url-encoded secret\n * material shared with the Relay; the other fields are non-secret.\n */\nexport type UkycWrappedRelayPayload = {\n // Wire-shape fields are snake_case.\n /* eslint-disable @typescript-eslint/naming-convention */\n storage_id: string;\n data_encryption_key: string;\n signing_public_key: string;\n storage_access_token: UkycStorageAccessToken;\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n\n/**\n * Assembles the `wrapped_relay_payload` from derived client material and a\n * Relay-presented `storage_access_token`.\n *\n * The token must be scoped for the Relay to present (`presenter: 'idos-relay'`)\n * and must not authorize `delete`, which is never delegated to the Relay.\n *\n * @param material - Client material derived from `local_user_secret`.\n * @param storageAccessToken - A `read`/`write`-scoped, Relay-presented token.\n * @returns The `wrapped_relay_payload` to send to the Relay via the UKYC API.\n */\nexport function buildWrappedRelayPayload(\n material: UkycClientMaterial,\n storageAccessToken: UkycStorageAccessToken,\n): UkycWrappedRelayPayload {\n const { presenter, operations } = storageAccessToken.payload;\n\n if (presenter !== 'idos-relay') {\n throw new Error(\n 'UKYC: wrapped_relay_payload requires a Relay-presented storage_access_token.',\n );\n }\n\n if (operations.includes('delete')) {\n throw new Error(\n 'UKYC: wrapped_relay_payload must not carry a delete-scoped storage_access_token.',\n );\n }\n\n return {\n storage_id: toBase64Url(material.storageId),\n data_encryption_key: toBase64Url(material.dataEncryptionKey),\n signing_public_key: toBase64Url(material.signingPublicKey),\n storage_access_token: storageAccessToken,\n };\n}\n"]}
@@ -1,5 +1,5 @@
1
- import type { UkycClientMaterial } from './deriveClientMaterial.js';
2
- import type { UkycStorageAccessToken } from './storageAccessToken.js';
1
+ import type { UkycClientMaterial } from "./deriveClientMaterial.cjs";
2
+ import type { UkycStorageAccessToken } from "./storageAccessToken.cjs";
3
3
  /**
4
4
  * Builds the `wrapped_relay_payload` — the only client-derived material that
5
5
  * leaves the device. It is sent to the idOS Relay (through the UKYC API) so the
@@ -32,4 +32,4 @@ export type UkycWrappedRelayPayload = {
32
32
  * @returns The `wrapped_relay_payload` to send to the Relay via the UKYC API.
33
33
  */
34
34
  export declare function buildWrappedRelayPayload(material: UkycClientMaterial, storageAccessToken: UkycStorageAccessToken): UkycWrappedRelayPayload;
35
- //# sourceMappingURL=wrappedRelayPayload.d.ts.map
35
+ //# sourceMappingURL=wrappedRelayPayload.d.cts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrappedRelayPayload.d.cts","sourceRoot":"","sources":["../../src/ukyc/wrappedRelayPayload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mCAAkC;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,iCAAgC;AAEtE;;;;;;;;;GASG;AAEH;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAGpC,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,sBAAsB,CAAC;CAE9C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,kBAAkB,EAC5B,kBAAkB,EAAE,sBAAsB,GACzC,uBAAuB,CAqBzB"}
@@ -0,0 +1,35 @@
1
+ import type { UkycClientMaterial } from "./deriveClientMaterial.mjs";
2
+ import type { UkycStorageAccessToken } from "./storageAccessToken.mjs";
3
+ /**
4
+ * Builds the `wrapped_relay_payload` — the only client-derived material that
5
+ * leaves the device. It is sent to the idOS Relay (through the UKYC API) so the
6
+ * Relay can encrypt/decrypt and store KYC payloads on the user's behalf. See the
7
+ * architecture doc, section "Client-Derived Material".
8
+ *
9
+ * Neither `local_user_secret` nor the private `signing_key` are ever included.
10
+ * The `data_encryption_key` *is* included: it is intentionally shared with the
11
+ * Relay so it can encrypt/decrypt payloads transiently.
12
+ */
13
+ /**
14
+ * The Relay-facing bundle. `data_encryption_key` is base64url-encoded secret
15
+ * material shared with the Relay; the other fields are non-secret.
16
+ */
17
+ export type UkycWrappedRelayPayload = {
18
+ storage_id: string;
19
+ data_encryption_key: string;
20
+ signing_public_key: string;
21
+ storage_access_token: UkycStorageAccessToken;
22
+ };
23
+ /**
24
+ * Assembles the `wrapped_relay_payload` from derived client material and a
25
+ * Relay-presented `storage_access_token`.
26
+ *
27
+ * The token must be scoped for the Relay to present (`presenter: 'idos-relay'`)
28
+ * and must not authorize `delete`, which is never delegated to the Relay.
29
+ *
30
+ * @param material - Client material derived from `local_user_secret`.
31
+ * @param storageAccessToken - A `read`/`write`-scoped, Relay-presented token.
32
+ * @returns The `wrapped_relay_payload` to send to the Relay via the UKYC API.
33
+ */
34
+ export declare function buildWrappedRelayPayload(material: UkycClientMaterial, storageAccessToken: UkycStorageAccessToken): UkycWrappedRelayPayload;
35
+ //# sourceMappingURL=wrappedRelayPayload.d.mts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrappedRelayPayload.d.mts","sourceRoot":"","sources":["../../src/ukyc/wrappedRelayPayload.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mCAAkC;AACpE,OAAO,KAAK,EAAE,sBAAsB,EAAE,iCAAgC;AAEtE;;;;;;;;;GASG;AAEH;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG;IAGpC,UAAU,EAAE,MAAM,CAAC;IACnB,mBAAmB,EAAE,MAAM,CAAC;IAC5B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,oBAAoB,EAAE,sBAAsB,CAAC;CAE9C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,kBAAkB,EAC5B,kBAAkB,EAAE,sBAAsB,GACzC,uBAAuB,CAqBzB"}
@@ -1,4 +1,4 @@
1
- import { toBase64Url } from '../encoding.js';
1
+ import { toBase64Url } from "../encoding.mjs";
2
2
  /**
3
3
  * Assembles the `wrapped_relay_payload` from derived client material and a
4
4
  * Relay-presented `storage_access_token`.
@@ -25,4 +25,4 @@ export function buildWrappedRelayPayload(material, storageAccessToken) {
25
25
  storage_access_token: storageAccessToken,
26
26
  };
27
27
  }
28
- //# sourceMappingURL=wrappedRelayPayload.js.map
28
+ //# sourceMappingURL=wrappedRelayPayload.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"wrappedRelayPayload.mjs","sourceRoot":"","sources":["../../src/ukyc/wrappedRelayPayload.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,wBAAuB;AA6B7C;;;;;;;;;;GAUG;AACH,MAAM,UAAU,wBAAwB,CACtC,QAA4B,EAC5B,kBAA0C;IAE1C,MAAM,EAAE,SAAS,EAAE,UAAU,EAAE,GAAG,kBAAkB,CAAC,OAAO,CAAC;IAE7D,IAAI,SAAS,KAAK,YAAY,EAAE,CAAC;QAC/B,MAAM,IAAI,KAAK,CACb,8EAA8E,CAC/E,CAAC;IACJ,CAAC;IAED,IAAI,UAAU,CAAC,QAAQ,CAAC,QAAQ,CAAC,EAAE,CAAC;QAClC,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;IACJ,CAAC;IAED,OAAO;QACL,UAAU,EAAE,WAAW,CAAC,QAAQ,CAAC,SAAS,CAAC;QAC3C,mBAAmB,EAAE,WAAW,CAAC,QAAQ,CAAC,iBAAiB,CAAC;QAC5D,kBAAkB,EAAE,WAAW,CAAC,QAAQ,CAAC,gBAAgB,CAAC;QAC1D,oBAAoB,EAAE,kBAAkB;KACzC,CAAC;AACJ,CAAC","sourcesContent":["import { toBase64Url } from '../encoding.js';\nimport type { UkycClientMaterial } from './deriveClientMaterial.js';\nimport type { UkycStorageAccessToken } from './storageAccessToken.js';\n\n/**\n * Builds the `wrapped_relay_payload` — the only client-derived material that\n * leaves the device. It is sent to the idOS Relay (through the UKYC API) so the\n * Relay can encrypt/decrypt and store KYC payloads on the user's behalf. See the\n * architecture doc, section \"Client-Derived Material\".\n *\n * Neither `local_user_secret` nor the private `signing_key` are ever included.\n * The `data_encryption_key` *is* included: it is intentionally shared with the\n * Relay so it can encrypt/decrypt payloads transiently.\n */\n\n/**\n * The Relay-facing bundle. `data_encryption_key` is base64url-encoded secret\n * material shared with the Relay; the other fields are non-secret.\n */\nexport type UkycWrappedRelayPayload = {\n // Wire-shape fields are snake_case.\n /* eslint-disable @typescript-eslint/naming-convention */\n storage_id: string;\n data_encryption_key: string;\n signing_public_key: string;\n storage_access_token: UkycStorageAccessToken;\n /* eslint-enable @typescript-eslint/naming-convention */\n};\n\n/**\n * Assembles the `wrapped_relay_payload` from derived client material and a\n * Relay-presented `storage_access_token`.\n *\n * The token must be scoped for the Relay to present (`presenter: 'idos-relay'`)\n * and must not authorize `delete`, which is never delegated to the Relay.\n *\n * @param material - Client material derived from `local_user_secret`.\n * @param storageAccessToken - A `read`/`write`-scoped, Relay-presented token.\n * @returns The `wrapped_relay_payload` to send to the Relay via the UKYC API.\n */\nexport function buildWrappedRelayPayload(\n material: UkycClientMaterial,\n storageAccessToken: UkycStorageAccessToken,\n): UkycWrappedRelayPayload {\n const { presenter, operations } = storageAccessToken.payload;\n\n if (presenter !== 'idos-relay') {\n throw new Error(\n 'UKYC: wrapped_relay_payload requires a Relay-presented storage_access_token.',\n );\n }\n\n if (operations.includes('delete')) {\n throw new Error(\n 'UKYC: wrapped_relay_payload must not carry a delete-scoped storage_access_token.',\n );\n }\n\n return {\n storage_id: toBase64Url(material.storageId),\n data_encryption_key: toBase64Url(material.dataEncryptionKey),\n signing_public_key: toBase64Url(material.signingPublicKey),\n storage_access_token: storageAccessToken,\n };\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-4f4c98e",
3
+ "version": "0.0.0-preview-eb263b0ee",
4
4
  "description": "Shared KYC / identity verification controller used across MetaMask clients",
5
5
  "keywords": [
6
6
  "Ethereum",
@@ -18,12 +18,19 @@
18
18
  "files": [
19
19
  "dist/"
20
20
  ],
21
- "type": "module",
22
21
  "sideEffects": false,
22
+ "main": "./dist/index.cjs",
23
+ "types": "./dist/index.d.cts",
23
24
  "exports": {
24
25
  ".": {
25
- "types": "./dist/index.d.ts",
26
- "default": "./dist/index.js"
26
+ "import": {
27
+ "types": "./dist/index.d.mts",
28
+ "default": "./dist/index.mjs"
29
+ },
30
+ "require": {
31
+ "types": "./dist/index.d.cts",
32
+ "default": "./dist/index.cjs"
33
+ }
27
34
  },
28
35
  "./package.json": "./package.json"
29
36
  },
@@ -32,12 +39,10 @@
32
39
  "registry": "https://registry.npmjs.org/"
33
40
  },
34
41
  "scripts": {
35
- "build": "tsc --project tsconfig.build.json",
36
- "build:all": "tsc --build tsconfig.build.json --verbose",
37
- "build:clean": "yarn build:only-clean && yarn build",
42
+ "build": "ts-bridge --project tsconfig.build.json --verbose --clean --no-references",
43
+ "build:all": "ts-bridge --project tsconfig.build.json --verbose --clean",
38
44
  "build:docs": "typedoc",
39
- "build:only-clean": "rimraf './dist' './tsconfig.build.tsbuildinfo'",
40
- "build:watch": "yarn build && chokidar 'src/**/*.ts' -c 'tsc --project tsconfig.build.json' --initial",
45
+ "build:watch": "yarn build && chokidar 'src/**/*.ts' -c 'ts-bridge --project tsconfig.build.json --verbose --no-references' --initial",
41
46
  "changelog:update": "../../scripts/update-changelog.sh @metamask/kyc-controller",
42
47
  "changelog:validate": "../../scripts/validate-changelog.sh @metamask/kyc-controller",
43
48
  "lint:tsconfigs": "tsx ../../scripts/lint-tsconfigs/lint-tsconfigs.mts",
@@ -70,20 +75,19 @@
70
75
  },
71
76
  "devDependencies": {
72
77
  "@metamask/auto-changelog": "^6.1.0",
78
+ "@ts-bridge/cli": "^0.6.4",
73
79
  "@types/jest": "^30.0.0",
74
- "@typescript/native": "npm:typescript@^7.0.2",
75
80
  "chokidar-cli": "^3.0.0",
76
81
  "deepmerge": "^4.2.2",
77
82
  "jest": "^30.4.2",
78
83
  "nock": "^13.3.1",
79
- "rimraf": "^5.0.5",
80
84
  "ts-jest": "^29.4.11",
81
85
  "tsx": "^4.20.5",
82
86
  "typedoc": "^0.25.13",
83
87
  "typedoc-plugin-missing-exports": "^2.0.0",
84
- "typescript": "npm:@typescript/typescript6@^6.0.2"
88
+ "typescript": "~5.3.3"
85
89
  },
86
90
  "engines": {
87
- "node": "^22.14.0 || ^24"
91
+ "node": "^18.18 || >=20"
88
92
  }
89
93
  }
@@ -1 +0,0 @@
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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C1C,IAAI,EAAE,0BAA0B,CAAC;IACjC,OAAO,EAAE,aAAa,CAAC,YAAY,CAAC,CAAC;CACtC,CAAC;AAEF;;GAEG;AACH,MAAM,MAAM,0BAA0B,GAClC,6BAA6B,GAC7B,uCAAuC,GACvC,kCAAkC,GAClC,6CAA6C,GAC7C,kCAAkC,GAClC,qCAAqC,GACrC,qCAAqC,GACrC,oCAAoC,GACpC,qCAAqC,GACrC,mCAAmC,GACnC,+BAA+B,GAC/B,sCAAsC,GACtC,8BAA8B,GAC9B,mCAAmC,GACnC,mCAAmC,GACnC,wBAAwB,GACxB,6BAA6B,CAAC"}
@@ -1 +0,0 @@
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 * Resolves persisted terms + geolocation, and auto-creates a session when\n * terms are already accepted and an email is available.\n *\n * @param params - Optional parameters.\n * @param params.email - The account email to associate with the session.\n * @param params.product - The consuming feature the flow runs for. When\n * provided, the controller automatically runs the KYC-required check once\n * authentication completes (and chains into document verification when KYC\n * is required). When omitted, the flow stops at `form` and the consumer must\n * call `checkKycRequired` manually.\n * @param params.vendor - Identity vendor for this flow. Non-MoonPay vendors\n * skip Check/Auth frames and use the consents path. Defaults to `moonpay`.\n */\nexport type KycControllerInitializeAction = {\n type: `KycController:initialize`;\n handler: KycController['initialize'];\n};\n\n/**\n * Creates (or resumes) an empty-shell customer for the given identity\n * vendor. Exposed so a consumer can ensure the customer exists before\n * showing T&C screens independently of {@link initialize}.\n *\n * A call while a session flow is already in progress is a no-op — matching\n * {@link initialize} — so a vendor switch cannot leave Check/Auth frames\n * attached to the wrong vendor. Call {@link reset} first to start over.\n *\n * @param params - The parameters.\n * @param params.vendor - Identity vendor for the customer.\n * @param params.email - Email for the vendor customer.\n */\nexport type KycControllerCreateVendorCustomerAction = {\n type: `KycController:createVendorCustomer`;\n handler: KycController['createVendorCustomer'];\n};\n\n/**\n * Loads the disclaimers for the resolved (or provided) country.\n *\n * @param params - Optional parameters.\n * @param params.country - ISO 3166-1 alpha-3 country code override.\n */\nexport type KycControllerLoadDisclaimersAction = {\n type: `KycController:loadDisclaimers`;\n handler: KycController['loadDisclaimers'];\n};\n\n/**\n * Captures terms acceptance for the currently loaded disclaimers and creates\n * a session.\n *\n * @param params - The parameters.\n * @param params.email - The account email to associate with the session.\n * @param params.product - The consuming feature the flow runs for. See\n * {@link initialize} for how the product drives the automatic post\n * authentication continuation.\n * @param params.sumsubTncSigned - Whether Sumsub T&C were accepted (T&C2).\n * Required for every vendor so callers explicitly declare acceptance.\n * @param params.idosTncSigned - Whether idOS T&C were accepted (T&C2).\n * Required for every vendor so callers explicitly declare acceptance.\n * @param params.credentialReusabilityConsentGiven - Whether the customer\n * consented to reuse existing idOS credentials. Used when recording\n * session-scoped disclaimers on the consents path. Defaults to `false`.\n */\nexport type KycControllerAcceptTermsAndStartSessionAction = {\n type: `KycController:acceptTermsAndStartSession`;\n handler: KycController['acceptTermsAndStartSession'];\n};\n\n/**\n * Clears the persisted terms acceptance.\n */\nexport type KycControllerClearSavedTermsAction = {\n type: `KycController:clearSavedTerms`;\n handler: KycController['clearSavedTerms'];\n};\n\n/**\n * Handles a message posted by a Check/Auth frame and advances the flow.\n *\n * The transport-agnostic caller (WebView on mobile, iframe on web) forwards\n * the raw message and injects the returned `reply` back into the frame.\n *\n * @param params - The parameters.\n * @param params.message - The raw message posted by the frame.\n * @returns An object whose optional `reply` should be posted back.\n */\nexport type KycControllerHandleFrameMessageAction = {\n type: `KycController:handleFrameMessage`;\n handler: KycController['handleFrameMessage'];\n};\n\n/**\n * Builds the Check-frame URL, or `null` when no session exists yet.\n *\n * @returns The Check-frame URL or `null`.\n */\nexport type KycControllerBuildCheckFrameUrlAction = {\n type: `KycController:buildCheckFrameUrl`;\n handler: KycController['buildCheckFrameUrl'];\n};\n\n/**\n * Builds the Auth-frame URL, or `null` when no client token is available.\n *\n * @returns The Auth-frame URL or `null`.\n */\nexport type KycControllerBuildAuthFrameUrlAction = {\n type: `KycController:buildAuthFrameUrl`;\n handler: KycController['buildAuthFrameUrl'];\n};\n\n/**\n * Builds the Reset-frame URL.\n *\n * @returns The Reset-frame URL.\n */\nexport type KycControllerBuildResetFrameUrlAction = {\n type: `KycController:buildResetFrameUrl`;\n handler: KycController['buildResetFrameUrl'];\n};\n\n/**\n * Checks whether KYC is required for a product and caches the result.\n *\n * @param params - The parameters.\n * @param params.product - The consuming feature.\n * @param params.country - Optional alpha-3 country override.\n * @returns Whether KYC is required.\n */\nexport type KycControllerCheckKycRequiredAction = {\n type: `KycController:checkKycRequired`;\n handler: KycController['checkKycRequired'];\n};\n\n/**\n * Reads the cached \"is KYC required\" result for a product.\n *\n * @param params - The parameters.\n * @param params.product - The consuming feature.\n * @returns The cached value, or `undefined` if not yet checked.\n */\nexport type KycControllerGetKycStatusAction = {\n type: `KycController:getKycStatus`;\n handler: KycController['getKycStatus'];\n};\n\n/**\n * Returns the vendor-scoped identity for the currently authenticated\n * customer, or `null` when the flow has not yet captured a vendor customer\n * id (before authentication or after {@link reset}), or when a MoonPay id\n * is present under a different `activeVendor`.\n *\n * Exposed so consumers (e.g. ramps autoramp creation) can attach the vendor\n * customer id to downstream calls without reading the full KYC state, which\n * also holds session/access tokens. The id is session-scoped and never\n * persisted.\n *\n * @returns The current {@link KycCustomerIdentity}, or `null`.\n */\nexport type KycControllerGetCustomerIdentityAction = {\n type: `KycController:getCustomerIdentity`;\n handler: KycController['getCustomerIdentity'];\n};\n\n/**\n * Runs the SumSub document-verification sub-flow end to end:\n *\n * 1. creates a UKYC session, receiving per-secret encryption schemas;\n * 2. verifies each schema's `jwtChain` against the Fractal JWKS and confirms\n * the attested session server public key;\n * 3. derives the `data_encryption_key` from the wallet's UKYC\n * `local_user_secret` and wraps it for the session server;\n * 4. mints a client-signed, read-only `ukyc_capability_token`, wraps it the\n * same way as the encryption key, and submits both via authorizations;\n * 5. fetches the SumSub applicant access token; and\n * 6. presents the SDK via the injected launcher.\n *\n * If a UKYC session already exists (the consents path creates it before\n * recording session disclaimers), steps 1–4 are skipped.\n *\n * If authorizations report the applicant is already approved on the relay\n * while the vendor is still finalizing (`kycStatus: approved`,\n * `finalStatus: pending`), the sub-flow stops at step 4 with a\n * `vendorProcessing` status and a message rather than launching the SDK.\n *\n * @param params - Optional parameters.\n * @param params.locale - BCP-47 locale for the SDK UI.\n * @param params.debug - Enables SDK debug logging.\n * @returns The SDK result.\n */\nexport type KycControllerStartSumSubAction = {\n type: `KycController:startSumSub`;\n handler: KycController['startSumSub'];\n};\n\n/**\n * Refreshes the user-keyed simplified KYC status from `GET /kyc/status`,\n * stores it on state, publishes {@link KycControllerStatusChangedEvent}, and\n * schedules short-interval polling while the status is `pending`.\n *\n * @returns The latest status payload.\n */\nexport type KycControllerRefreshKycStatusAction = {\n type: `KycController:refreshKycStatus`;\n handler: KycController['refreshKycStatus'];\n};\n\n/**\n * Fetches the current UKYC session status for the active sub-flow and records\n * it on state. Useful for a one-off refresh outside the automatic polling\n * loop that {@link startSumSub} runs.\n *\n * @returns The fetched session status.\n * @throws If there is no active SumSub session to query.\n */\nexport type KycControllerGetSessionStatusAction = {\n type: `KycController:getSessionStatus`;\n handler: KycController['getSessionStatus'];\n};\n\n/**\n * Resets the flow to idle, clearing session tokens and sub-flow state while\n * preserving persisted terms acceptance and the per-product cache.\n */\nexport type KycControllerResetAction = {\n type: `KycController:reset`;\n handler: KycController['reset'];\n};\n\n/**\n * Restores the controller to its default state, discarding everything\n * {@link reset} deliberately keeps: the session email, the persisted terms\n * acceptance, the per-product KYC-required cache and the user-keyed status.\n *\n * Intended for a full wallet reset, where no trace of the previous\n * customer may survive into the next wallet.\n */\nexport type KycControllerClearStateAction = {\n type: `KycController:clearState`;\n handler: KycController['clearState'];\n};\n\n/**\n * Union of all KycController action types.\n */\nexport type KycControllerMethodActions =\n | KycControllerInitializeAction\n | KycControllerCreateVendorCustomerAction\n | KycControllerLoadDisclaimersAction\n | KycControllerAcceptTermsAndStartSessionAction\n | KycControllerClearSavedTermsAction\n | KycControllerHandleFrameMessageAction\n | KycControllerBuildCheckFrameUrlAction\n | KycControllerBuildAuthFrameUrlAction\n | KycControllerBuildResetFrameUrlAction\n | KycControllerCheckKycRequiredAction\n | KycControllerGetKycStatusAction\n | KycControllerGetCustomerIdentityAction\n | KycControllerStartSumSubAction\n | KycControllerRefreshKycStatusAction\n | KycControllerGetSessionStatusAction\n | KycControllerResetAction\n | KycControllerClearStateAction;\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"KycController.d.ts","sourceRoot":"","sources":["../src/KycController.ts"],"names":[],"mappings":"AAAA,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,EACV,4CAA4C,EAC5C,4CAA4C,EAC7C,MAAM,gDAAgD,CAAC;AACxD,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,iBAAiB,CAAC;AAM5C,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wCAAwC,CAAC;AACzF,OAAO,KAAK,EAAE,uBAAuB,EAAE,MAAM,qCAAqC,CAAC;AAKnF,OAAO,KAAK,EAEV,mBAAmB,EACnB,aAAa,EACb,QAAQ,EACR,UAAU,EACV,qBAAqB,EACrB,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,aAAa,EACb,SAAS,EACV,MAAM,YAAY,CAAC;AAcpB,eAAO,MAAM,cAAc,kBAAkB,CAAC;AAsF9C;;GAEG;AACH,MAAM,MAAM,kBAAkB,GAAG;IAC/B,0CAA0C;IAC1C,KAAK,EAAE,QAAQ,CAAC;IAChB,2DAA2D;IAC3D,aAAa,EA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