@metamask-previews/kyc-controller 0.0.0-preview-e57e5c3dc → 0.0.0-preview-c449b8da8

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 (155) hide show
  1. package/CHANGELOG.md +0 -8
  2. package/README.md +2 -10
  3. package/dist/index.cjs +10 -34
  4. package/dist/index.cjs.map +1 -1
  5. package/dist/index.d.cts +7 -18
  6. package/dist/index.d.cts.map +1 -1
  7. package/dist/index.d.mts +7 -18
  8. package/dist/index.d.mts.map +1 -1
  9. package/dist/index.mjs +9 -11
  10. package/dist/index.mjs.map +1 -1
  11. package/package.json +3 -24
  12. package/dist/KycController-method-action-types.cjs +0 -7
  13. package/dist/KycController-method-action-types.cjs.map +0 -1
  14. package/dist/KycController-method-action-types.d.cts +0 -168
  15. package/dist/KycController-method-action-types.d.cts.map +0 -1
  16. package/dist/KycController-method-action-types.d.mts +0 -168
  17. package/dist/KycController-method-action-types.d.mts.map +0 -1
  18. package/dist/KycController-method-action-types.mjs +0 -6
  19. package/dist/KycController-method-action-types.mjs.map +0 -1
  20. package/dist/KycController.cjs +0 -1085
  21. package/dist/KycController.cjs.map +0 -1
  22. package/dist/KycController.d.cts +0 -255
  23. package/dist/KycController.d.cts.map +0 -1
  24. package/dist/KycController.d.mts +0 -255
  25. package/dist/KycController.d.mts.map +0 -1
  26. package/dist/KycController.mjs +0 -1080
  27. package/dist/KycController.mjs.map +0 -1
  28. package/dist/KycService-method-action-types.cjs +0 -7
  29. package/dist/KycService-method-action-types.cjs.map +0 -1
  30. package/dist/KycService-method-action-types.d.cts +0 -121
  31. package/dist/KycService-method-action-types.d.cts.map +0 -1
  32. package/dist/KycService-method-action-types.d.mts +0 -121
  33. package/dist/KycService-method-action-types.d.mts.map +0 -1
  34. package/dist/KycService-method-action-types.mjs +0 -6
  35. package/dist/KycService-method-action-types.mjs.map +0 -1
  36. package/dist/KycService.cjs +0 -417
  37. package/dist/KycService.cjs.map +0 -1
  38. package/dist/KycService.d.cts +0 -307
  39. package/dist/KycService.d.cts.map +0 -1
  40. package/dist/KycService.d.mts +0 -307
  41. package/dist/KycService.d.mts.map +0 -1
  42. package/dist/KycService.mjs +0 -413
  43. package/dist/KycService.mjs.map +0 -1
  44. package/dist/countryCodes.cjs +0 -274
  45. package/dist/countryCodes.cjs.map +0 -1
  46. package/dist/countryCodes.d.cts +0 -18
  47. package/dist/countryCodes.d.cts.map +0 -1
  48. package/dist/countryCodes.d.mts +0 -18
  49. package/dist/countryCodes.d.mts.map +0 -1
  50. package/dist/countryCodes.mjs +0 -270
  51. package/dist/countryCodes.mjs.map +0 -1
  52. package/dist/crypto.cjs +0 -154
  53. package/dist/crypto.cjs.map +0 -1
  54. package/dist/crypto.d.cts +0 -84
  55. package/dist/crypto.d.cts.map +0 -1
  56. package/dist/crypto.d.mts +0 -84
  57. package/dist/crypto.d.mts.map +0 -1
  58. package/dist/crypto.mjs +0 -149
  59. package/dist/crypto.mjs.map +0 -1
  60. package/dist/encoding.cjs +0 -40
  61. package/dist/encoding.cjs.map +0 -1
  62. package/dist/encoding.d.cts +0 -24
  63. package/dist/encoding.d.cts.map +0 -1
  64. package/dist/encoding.d.mts +0 -24
  65. package/dist/encoding.d.mts.map +0 -1
  66. package/dist/encoding.mjs +0 -35
  67. package/dist/encoding.mjs.map +0 -1
  68. package/dist/selectors.cjs +0 -30
  69. package/dist/selectors.cjs.map +0 -1
  70. package/dist/selectors.d.cts +0 -24
  71. package/dist/selectors.d.cts.map +0 -1
  72. package/dist/selectors.d.mts +0 -24
  73. package/dist/selectors.d.mts.map +0 -1
  74. package/dist/selectors.mjs +0 -24
  75. package/dist/selectors.mjs.map +0 -1
  76. package/dist/types.cjs +0 -10
  77. package/dist/types.cjs.map +0 -1
  78. package/dist/types.d.cts +0 -124
  79. package/dist/types.d.cts.map +0 -1
  80. package/dist/types.d.mts +0 -124
  81. package/dist/types.d.mts.map +0 -1
  82. package/dist/types.mjs +0 -9
  83. package/dist/types.mjs.map +0 -1
  84. package/dist/ukyc/constants.cjs +0 -75
  85. package/dist/ukyc/constants.cjs.map +0 -1
  86. package/dist/ukyc/constants.d.cts +0 -69
  87. package/dist/ukyc/constants.d.cts.map +0 -1
  88. package/dist/ukyc/constants.d.mts +0 -69
  89. package/dist/ukyc/constants.d.mts.map +0 -1
  90. package/dist/ukyc/constants.mjs +0 -72
  91. package/dist/ukyc/constants.mjs.map +0 -1
  92. package/dist/ukyc/deriveClientMaterial.cjs +0 -65
  93. package/dist/ukyc/deriveClientMaterial.cjs.map +0 -1
  94. package/dist/ukyc/deriveClientMaterial.d.cts +0 -54
  95. package/dist/ukyc/deriveClientMaterial.d.cts.map +0 -1
  96. package/dist/ukyc/deriveClientMaterial.d.mts +0 -54
  97. package/dist/ukyc/deriveClientMaterial.d.mts.map +0 -1
  98. package/dist/ukyc/deriveClientMaterial.mjs +0 -60
  99. package/dist/ukyc/deriveClientMaterial.mjs.map +0 -1
  100. package/dist/ukyc/jwtChain.cjs +0 -54
  101. package/dist/ukyc/jwtChain.cjs.map +0 -1
  102. package/dist/ukyc/jwtChain.d.cts +0 -40
  103. package/dist/ukyc/jwtChain.d.cts.map +0 -1
  104. package/dist/ukyc/jwtChain.d.mts +0 -40
  105. package/dist/ukyc/jwtChain.d.mts.map +0 -1
  106. package/dist/ukyc/jwtChain.mjs +0 -50
  107. package/dist/ukyc/jwtChain.mjs.map +0 -1
  108. package/dist/ukyc/localUserSecret.cjs +0 -98
  109. package/dist/ukyc/localUserSecret.cjs.map +0 -1
  110. package/dist/ukyc/localUserSecret.d.cts +0 -65
  111. package/dist/ukyc/localUserSecret.d.cts.map +0 -1
  112. package/dist/ukyc/localUserSecret.d.mts +0 -65
  113. package/dist/ukyc/localUserSecret.d.mts.map +0 -1
  114. package/dist/ukyc/localUserSecret.mjs +0 -92
  115. package/dist/ukyc/localUserSecret.mjs.map +0 -1
  116. package/dist/ukyc/storageAccessToken.cjs +0 -139
  117. package/dist/ukyc/storageAccessToken.cjs.map +0 -1
  118. package/dist/ukyc/storageAccessToken.d.cts +0 -99
  119. package/dist/ukyc/storageAccessToken.d.cts.map +0 -1
  120. package/dist/ukyc/storageAccessToken.d.mts +0 -99
  121. package/dist/ukyc/storageAccessToken.d.mts.map +0 -1
  122. package/dist/ukyc/storageAccessToken.mjs +0 -133
  123. package/dist/ukyc/storageAccessToken.mjs.map +0 -1
  124. package/dist/ukyc/testToken.cjs +0 -61
  125. package/dist/ukyc/testToken.cjs.map +0 -1
  126. package/dist/ukyc/testToken.d.cts +0 -50
  127. package/dist/ukyc/testToken.d.cts.map +0 -1
  128. package/dist/ukyc/testToken.d.mts +0 -50
  129. package/dist/ukyc/testToken.d.mts.map +0 -1
  130. package/dist/ukyc/testToken.mjs +0 -57
  131. package/dist/ukyc/testToken.mjs.map +0 -1
  132. package/dist/ukyc/wrapEncryptionKey.cjs +0 -28
  133. package/dist/ukyc/wrapEncryptionKey.cjs.map +0 -1
  134. package/dist/ukyc/wrapEncryptionKey.d.cts +0 -34
  135. package/dist/ukyc/wrapEncryptionKey.d.cts.map +0 -1
  136. package/dist/ukyc/wrapEncryptionKey.d.mts +0 -34
  137. package/dist/ukyc/wrapEncryptionKey.d.mts.map +0 -1
  138. package/dist/ukyc/wrapEncryptionKey.mjs +0 -25
  139. package/dist/ukyc/wrapEncryptionKey.mjs.map +0 -1
  140. package/dist/ukyc/wrapUserKey.cjs +0 -80
  141. package/dist/ukyc/wrapUserKey.cjs.map +0 -1
  142. package/dist/ukyc/wrapUserKey.d.cts +0 -26
  143. package/dist/ukyc/wrapUserKey.d.cts.map +0 -1
  144. package/dist/ukyc/wrapUserKey.d.mts +0 -26
  145. package/dist/ukyc/wrapUserKey.d.mts.map +0 -1
  146. package/dist/ukyc/wrapUserKey.mjs +0 -76
  147. package/dist/ukyc/wrapUserKey.mjs.map +0 -1
  148. package/dist/ukyc/wrappedRelayPayload.cjs +0 -32
  149. package/dist/ukyc/wrappedRelayPayload.cjs.map +0 -1
  150. package/dist/ukyc/wrappedRelayPayload.d.cts +0 -35
  151. package/dist/ukyc/wrappedRelayPayload.d.cts.map +0 -1
  152. package/dist/ukyc/wrappedRelayPayload.d.mts +0 -35
  153. package/dist/ukyc/wrappedRelayPayload.d.mts.map +0 -1
  154. package/dist/ukyc/wrappedRelayPayload.mjs +0 -28
  155. package/dist/ukyc/wrappedRelayPayload.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapEncryptionKey.d.mts","sourceRoot":"","sources":["../../src/ukyc/wrapEncryptionKey.ts"],"names":[],"mappings":"AAIA;;;;;;;;;;GAUG;AAEH;;;;GAIG;AACH,MAAM,MAAM,yBAAyB,GAAG;IACtC,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,uBAAuB,EAAE,UAAU,EACnC,sBAAsB,EAAE,MAAM,EAC9B,SAAS,EAAE,UAAU,GACpB,yBAAyB,CAa3B"}
@@ -1,25 +0,0 @@
1
- import $tweetnacl from "tweetnacl";
2
- const { randomBytes, box } = $tweetnacl;
3
- import { base64UrlToBytes, toBase64Url } from "../encoding.mjs";
4
- /**
5
- * Wraps `keyToWrap` for the UKYC session server.
6
- *
7
- * The box is sealed with NaCl's `crypto_box`, keyed by the X25519 shared secret
8
- * between our session client private key and the session server public key
9
- * returned by `getWrappingKey`.
10
- *
11
- * @param sessionClientPrivateKey - Our session's X25519 private key.
12
- * @param sessionServerPublicKey - The server's X25519 public key (base64url).
13
- * @param keyToWrap - The raw symmetric key bytes to encrypt.
14
- * @returns The base64url `encryptedKey` (ciphertext + tag) and `nonce`.
15
- */
16
- export function wrapEncryptionKey(sessionClientPrivateKey, sessionServerPublicKey, keyToWrap) {
17
- const serverPublicKey = base64UrlToBytes(sessionServerPublicKey);
18
- const nonce = randomBytes(box.nonceLength);
19
- const encryptedKey = box(keyToWrap, nonce, serverPublicKey, sessionClientPrivateKey);
20
- return {
21
- encryptedKey: toBase64Url(encryptedKey),
22
- nonce: toBase64Url(nonce),
23
- };
24
- }
25
- //# sourceMappingURL=wrapEncryptionKey.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrapEncryptionKey.mjs","sourceRoot":"","sources":["../../src/ukyc/wrapEncryptionKey.ts"],"names":[],"mappings":";;AAEA,OAAO,EAAE,gBAAgB,EAAE,WAAW,EAAE,wBAAuB;AAwB/D;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,iBAAiB,CAC/B,uBAAmC,EACnC,sBAA8B,EAC9B,SAAqB;IAErB,MAAM,eAAe,GAAG,gBAAgB,CAAC,sBAAsB,CAAC,CAAC;IACjE,MAAM,KAAK,GAAG,WAAW,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IAC3C,MAAM,YAAY,GAAG,GAAG,CACtB,SAAS,EACT,KAAK,EACL,eAAe,EACf,uBAAuB,CACxB,CAAC;IACF,OAAO;QACL,YAAY,EAAE,WAAW,CAAC,YAAY,CAAC;QACvC,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 the `data_encryption_key` for the UKYC session server using NaCl's\n * `crypto_box` (X25519 + XSalsa20-Poly1305) established with the server's\n * per-session wrapping key.\n *\n * Unlike {@link wrapUserKey} (which generates a fresh ephemeral keypair per\n * call), this uses the session client keypair whose public half was already\n * handed to the server via `POST /wrapping-key`. The server therefore already\n * knows our public key and can derive the same shared secret from its session\n * private key, so only `{ encryptedKey, nonce }` need be transmitted.\n */\n\n/**\n * The transmitted portion of a wrapped encryption key: the `crypto_box`\n * ciphertext (which includes the 16-byte Poly1305 auth tag) and the nonce,\n * both unpadded base64url-encoded.\n */\nexport type WrappedEncryptionKeyParts = {\n encryptedKey: string;\n nonce: string;\n};\n\n/**\n * Wraps `keyToWrap` 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 * returned by `getWrappingKey`.\n *\n * @param sessionClientPrivateKey - Our session's X25519 private key.\n * @param sessionServerPublicKey - The server's X25519 public key (base64url).\n * @param keyToWrap - The raw symmetric key bytes to encrypt.\n * @returns The base64url `encryptedKey` (ciphertext + tag) and `nonce`.\n */\nexport function wrapEncryptionKey(\n sessionClientPrivateKey: Uint8Array,\n sessionServerPublicKey: string,\n keyToWrap: Uint8Array,\n): WrappedEncryptionKeyParts {\n const serverPublicKey = base64UrlToBytes(sessionServerPublicKey);\n const nonce = randomBytes(box.nonceLength);\n const encryptedKey = box(\n keyToWrap,\n nonce,\n serverPublicKey,\n sessionClientPrivateKey,\n );\n return {\n encryptedKey: toBase64Url(encryptedKey),\n nonce: toBase64Url(nonce),\n };\n}\n"]}
@@ -1,80 +0,0 @@
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
@@ -1 +0,0 @@
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,cAAc,qBAAqB,GAAG,CACpG,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,SAAgB,WAAW,CACzB,kBAA0B,EAC1B,SAAqB;IAErB,MAAM,SAAS,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;IAEtD,MAAM,mBAAmB,GAAG,gBAAM,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;IAC3D,MAAM,kBAAkB,GAAG,gBAAM,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;IAEpE,MAAM,MAAM,GAAG,gBAAM,CAAC,eAAe,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG,IAAA,WAAI,EAAC,aAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAE/D,MAAM,EAAE,GAAG,IAAA,mBAAW,EAAC,aAAa,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,IAAA,SAAG,EAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvD,MAAM,IAAI,GAAG,IAAI,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,IAAA,yBAAW,EAAC,IAAI,CAAC,CAAC;AAC3B,CAAC;AAvBD,kCAuBC","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"]}
@@ -1,26 +0,0 @@
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.cts.map
@@ -1 +0,0 @@
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"}
@@ -1,26 +0,0 @@
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
@@ -1 +0,0 @@
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,76 +0,0 @@
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
- /**
9
- * Wraps (encrypts) a symmetric key so that only the holder of a given X25519
10
- * private key can recover it — used to seal the `data_encryption_key` for the
11
- * idOS Relay before it is handed to the UKYC API as `wrappedUserKey`.
12
- */
13
- /** X25519 public/private keys and AES-256-GCM keys are all 32 bytes. */
14
- const X25519_KEY_SIZE_BYTES = 32;
15
- /** 96-bit IV, the AES-GCM standard nonce size. */
16
- const IV_SIZE_BYTES = 12;
17
- /**
18
- * Decodes an X25519 public key presented as either hex or base64/base64url.
19
- *
20
- * @param recipientPublicKey - The recipient's 32-byte X25519 public key.
21
- * @returns The raw 32-byte public key.
22
- */
23
- function decodePublicKey(recipientPublicKey) {
24
- const isHex = recipientPublicKey.length === X25519_KEY_SIZE_BYTES * 2 &&
25
- /^[0-9a-fA-F]+$/u.test(recipientPublicKey);
26
- const bytes = isHex
27
- ? hexToBytes(recipientPublicKey)
28
- : base64ToBytes(recipientPublicKey
29
- .replace(/-/gu, '+')
30
- .replace(/_/gu, '/')
31
- .padEnd(recipientPublicKey.length +
32
- ((4 - (recipientPublicKey.length % 4)) % 4), '='));
33
- if (bytes.length !== X25519_KEY_SIZE_BYTES) {
34
- throw new Error(`UKYC: wrappingPublicKey has unexpected length ${bytes.length}, expected ${X25519_KEY_SIZE_BYTES}.`);
35
- }
36
- return bytes;
37
- }
38
- /**
39
- * Wraps `keyToWrap` for the holder of `recipientPublicKey` using an
40
- * ephemeral-static ECDH + AES-256-GCM sealed-box scheme:
41
- *
42
- * ephemeral = fresh X25519 keypair (one per call)
43
- * shared = X25519(ephemeralPrivate, recipientPublic)
44
- * aeadKey = HKDF-SHA256(shared, 32 bytes)
45
- * iv = 12 random bytes
46
- * ct = AES-256-GCM(aeadKey, iv).encrypt(keyToWrap) // ct includes tag
47
- *
48
- * The recipient reverses it with their private key:
49
- *
50
- * shared = X25519(recipientPrivate, ephemeralPublic)
51
- * aeadKey = HKDF-SHA256(shared, 32 bytes)
52
- * key = AES-256-GCM(aeadKey, iv).decrypt(ct)
53
- *
54
- * This mirrors the X25519 + AES-256-GCM/HKDF decryption used for MoonPay
55
- * Check/Auth-frame credentials, so both directions share one primitive.
56
- *
57
- * @param recipientPublicKey - The recipient's X25519 public key (hex or base64).
58
- * @param keyToWrap - The raw symmetric key bytes to encrypt (e.g. the
59
- * `data_encryption_key`).
60
- * @returns Base64url of `ephemeralPublicKey(32) || iv(12) || ciphertext+tag`.
61
- */
62
- export function wrapUserKey(recipientPublicKey, keyToWrap) {
63
- const recipient = decodePublicKey(recipientPublicKey);
64
- const ephemeralPrivateKey = x25519.utils.randomSecretKey();
65
- const ephemeralPublicKey = x25519.getPublicKey(ephemeralPrivateKey);
66
- const shared = x25519.getSharedSecret(ephemeralPrivateKey, recipient);
67
- const aeadKey = hkdf(sha256, shared, undefined, undefined, 32);
68
- const iv = randomBytes(IV_SIZE_BYTES);
69
- const ciphertext = gcm(aeadKey, iv).encrypt(keyToWrap);
70
- const blob = new Uint8Array(ephemeralPublicKey.length + iv.length + ciphertext.length);
71
- blob.set(ephemeralPublicKey, 0);
72
- blob.set(iv, ephemeralPublicKey.length);
73
- blob.set(ciphertext, ephemeralPublicKey.length + iv.length);
74
- return toBase64Url(blob);
75
- }
76
- //# sourceMappingURL=wrapUserKey.mjs.map
@@ -1 +0,0 @@
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,CAAC,kBAAkB,CAAC,CAAC;IAE7C,MAAM,KAAK,GAAG,KAAK;QACjB,CAAC,CAAC,UAAU,CAAC,kBAAkB,CAAC;QAChC,CAAC,CAAC,aAAa,CACX,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,cAAc,qBAAqB,GAAG,CACpG,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,MAAM,UAAU,WAAW,CACzB,kBAA0B,EAC1B,SAAqB;IAErB,MAAM,SAAS,GAAG,eAAe,CAAC,kBAAkB,CAAC,CAAC;IAEtD,MAAM,mBAAmB,GAAG,MAAM,CAAC,KAAK,CAAC,eAAe,EAAE,CAAC;IAC3D,MAAM,kBAAkB,GAAG,MAAM,CAAC,YAAY,CAAC,mBAAmB,CAAC,CAAC;IAEpE,MAAM,MAAM,GAAG,MAAM,CAAC,eAAe,CAAC,mBAAmB,EAAE,SAAS,CAAC,CAAC;IACtE,MAAM,OAAO,GAAG,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CAAC,CAAC;IAE/D,MAAM,EAAE,GAAG,WAAW,CAAC,aAAa,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,GAAG,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;IAEvD,MAAM,IAAI,GAAG,IAAI,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"]}
@@ -1,32 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrappedRelayPayload.cjs","sourceRoot":"","sources":["../../src/ukyc/wrappedRelayPayload.ts"],"names":[],"mappings":";;;AACA,iDAA6C;AA4B7C;;;;;;;;;;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 type { UkycClientMaterial } from './deriveClientMaterial.js';\nimport { toBase64Url } from '../encoding.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,35 +0,0 @@
1
- import type { UkycClientMaterial } from "./deriveClientMaterial.cjs";
2
- import type { UkycStorageAccessToken } from "./storageAccessToken.cjs";
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.cts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrappedRelayPayload.d.cts","sourceRoot":"","sources":["../../src/ukyc/wrappedRelayPayload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mCAAkC;AAEpE,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,35 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrappedRelayPayload.d.mts","sourceRoot":"","sources":["../../src/ukyc/wrappedRelayPayload.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,kBAAkB,EAAE,mCAAkC;AAEpE,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,28 +0,0 @@
1
- import { toBase64Url } from "../encoding.mjs";
2
- /**
3
- * Assembles the `wrapped_relay_payload` from derived client material and a
4
- * Relay-presented `storage_access_token`.
5
- *
6
- * The token must be scoped for the Relay to present (`presenter: 'idos-relay'`)
7
- * and must not authorize `delete`, which is never delegated to the Relay.
8
- *
9
- * @param material - Client material derived from `local_user_secret`.
10
- * @param storageAccessToken - A `read`/`write`-scoped, Relay-presented token.
11
- * @returns The `wrapped_relay_payload` to send to the Relay via the UKYC API.
12
- */
13
- export function buildWrappedRelayPayload(material, storageAccessToken) {
14
- const { presenter, operations } = storageAccessToken.payload;
15
- if (presenter !== 'idos-relay') {
16
- throw new Error('UKYC: wrapped_relay_payload requires a Relay-presented storage_access_token.');
17
- }
18
- if (operations.includes('delete')) {
19
- throw new Error('UKYC: wrapped_relay_payload must not carry a delete-scoped storage_access_token.');
20
- }
21
- return {
22
- storage_id: toBase64Url(material.storageId),
23
- data_encryption_key: toBase64Url(material.dataEncryptionKey),
24
- signing_public_key: toBase64Url(material.signingPublicKey),
25
- storage_access_token: storageAccessToken,
26
- };
27
- }
28
- //# sourceMappingURL=wrappedRelayPayload.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"wrappedRelayPayload.mjs","sourceRoot":"","sources":["../../src/ukyc/wrappedRelayPayload.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,wBAAuB;AA4B7C;;;;;;;;;;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 type { UkycClientMaterial } from './deriveClientMaterial.js';\nimport { toBase64Url } from '../encoding.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"]}