@enbox/agent 0.1.3 → 0.1.4

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 (224) hide show
  1. package/dist/browser.mjs +45 -52
  2. package/dist/browser.mjs.map +4 -4
  3. package/dist/esm/crypto-api.js +6 -13
  4. package/dist/esm/crypto-api.js.map +1 -1
  5. package/dist/esm/dwn-api.js +80 -78
  6. package/dist/esm/dwn-api.js.map +1 -1
  7. package/dist/esm/hd-identity-vault.js +4 -5
  8. package/dist/esm/hd-identity-vault.js.map +1 -1
  9. package/dist/esm/identity-api.js +1 -1
  10. package/dist/esm/identity-api.js.map +1 -1
  11. package/dist/esm/index.js +0 -2
  12. package/dist/esm/index.js.map +1 -1
  13. package/dist/esm/local-key-manager.js +31 -32
  14. package/dist/esm/local-key-manager.js.map +1 -1
  15. package/dist/esm/prototyping/crypto/jose/jwe-compact.js +1 -2
  16. package/dist/esm/prototyping/crypto/jose/jwe-compact.js.map +1 -1
  17. package/dist/esm/prototyping/crypto/jose/jwe-flattened.js +15 -4
  18. package/dist/esm/prototyping/crypto/jose/jwe-flattened.js.map +1 -1
  19. package/dist/esm/prototyping/crypto/jose/jwe.js +1 -1
  20. package/dist/esm/prototyping/crypto/jose/jwe.js.map +1 -1
  21. package/dist/esm/store-data.js +3 -3
  22. package/dist/esm/store-data.js.map +1 -1
  23. package/dist/esm/store-did.js +1 -1
  24. package/dist/esm/store-did.js.map +1 -1
  25. package/dist/esm/sync-engine-level.js +49 -11
  26. package/dist/esm/sync-engine-level.js.map +1 -1
  27. package/dist/esm/test-harness.js +24 -8
  28. package/dist/esm/test-harness.js.map +1 -1
  29. package/dist/esm/types/dwn.js +1 -1
  30. package/dist/esm/types/dwn.js.map +1 -1
  31. package/dist/esm/web5-user-agent.js +1 -1
  32. package/dist/esm/web5-user-agent.js.map +1 -1
  33. package/dist/types/crypto-api.d.ts +8 -12
  34. package/dist/types/crypto-api.d.ts.map +1 -1
  35. package/dist/types/dwn-api.d.ts +10 -10
  36. package/dist/types/dwn-api.d.ts.map +1 -1
  37. package/dist/types/hd-identity-vault.d.ts.map +1 -1
  38. package/dist/types/identity-api.d.ts.map +1 -1
  39. package/dist/types/index.d.ts +0 -2
  40. package/dist/types/index.d.ts.map +1 -1
  41. package/dist/types/local-key-manager.d.ts +15 -18
  42. package/dist/types/local-key-manager.d.ts.map +1 -1
  43. package/dist/types/prototyping/crypto/jose/jwe-compact.d.ts +1 -3
  44. package/dist/types/prototyping/crypto/jose/jwe-compact.d.ts.map +1 -1
  45. package/dist/types/prototyping/crypto/jose/jwe-flattened.d.ts +1 -3
  46. package/dist/types/prototyping/crypto/jose/jwe-flattened.d.ts.map +1 -1
  47. package/dist/types/prototyping/crypto/jose/jwe.d.ts +1 -3
  48. package/dist/types/prototyping/crypto/jose/jwe.d.ts.map +1 -1
  49. package/dist/types/store-data.d.ts +2 -2
  50. package/dist/types/store-did.d.ts.map +1 -1
  51. package/dist/types/sync-engine-level.d.ts +18 -6
  52. package/dist/types/sync-engine-level.d.ts.map +1 -1
  53. package/dist/types/test-harness.d.ts.map +1 -1
  54. package/dist/types/types/agent.d.ts +1 -1
  55. package/dist/types/types/agent.d.ts.map +1 -1
  56. package/dist/types/types/dwn.d.ts +2 -2
  57. package/dist/types/types/dwn.d.ts.map +1 -1
  58. package/dist/types/types/key-manager.d.ts +15 -22
  59. package/dist/types/types/key-manager.d.ts.map +1 -1
  60. package/dist/types/utils-internal.d.ts +1 -1
  61. package/dist/types/utils-internal.d.ts.map +1 -1
  62. package/dist/types/web5-user-agent.d.ts +1 -1
  63. package/dist/types/web5-user-agent.d.ts.map +1 -1
  64. package/package.json +10 -12
  65. package/src/crypto-api.ts +24 -20
  66. package/src/dwn-api.ts +109 -102
  67. package/src/hd-identity-vault.ts +4 -5
  68. package/src/identity-api.ts +2 -1
  69. package/src/index.ts +0 -2
  70. package/src/local-key-manager.ts +43 -44
  71. package/src/prototyping/crypto/jose/jwe-compact.ts +3 -7
  72. package/src/prototyping/crypto/jose/jwe-flattened.ts +20 -9
  73. package/src/prototyping/crypto/jose/jwe.ts +2 -6
  74. package/src/store-data.ts +3 -3
  75. package/src/store-did.ts +1 -1
  76. package/src/sync-engine-level.ts +59 -16
  77. package/src/test-harness.ts +23 -8
  78. package/src/types/agent.ts +1 -1
  79. package/src/types/dwn.ts +2 -2
  80. package/src/types/key-manager.ts +31 -22
  81. package/src/utils-internal.ts +1 -1
  82. package/src/web5-user-agent.ts +2 -2
  83. package/dist/browser.js +0 -2213
  84. package/dist/browser.js.map +0 -7
  85. package/dist/esm/dwn-registrar.js +0 -120
  86. package/dist/esm/dwn-registrar.js.map +0 -1
  87. package/dist/esm/prototyping/clients/dwn-rpc-types.js +0 -2
  88. package/dist/esm/prototyping/clients/dwn-rpc-types.js.map +0 -1
  89. package/dist/esm/prototyping/clients/dwn-server-info-cache-memory.js +0 -74
  90. package/dist/esm/prototyping/clients/dwn-server-info-cache-memory.js.map +0 -1
  91. package/dist/esm/prototyping/clients/http-dwn-rpc-client.js +0 -112
  92. package/dist/esm/prototyping/clients/http-dwn-rpc-client.js.map +0 -1
  93. package/dist/esm/prototyping/clients/json-rpc-socket.js +0 -167
  94. package/dist/esm/prototyping/clients/json-rpc-socket.js.map +0 -1
  95. package/dist/esm/prototyping/clients/json-rpc.js +0 -58
  96. package/dist/esm/prototyping/clients/json-rpc.js.map +0 -1
  97. package/dist/esm/prototyping/clients/server-info-types.js +0 -2
  98. package/dist/esm/prototyping/clients/server-info-types.js.map +0 -1
  99. package/dist/esm/prototyping/clients/web-socket-clients.js +0 -90
  100. package/dist/esm/prototyping/clients/web-socket-clients.js.map +0 -1
  101. package/dist/esm/prototyping/common/object.js +0 -14
  102. package/dist/esm/prototyping/common/object.js.map +0 -1
  103. package/dist/esm/prototyping/common/type-utils.js +0 -2
  104. package/dist/esm/prototyping/common/type-utils.js.map +0 -1
  105. package/dist/esm/prototyping/crypto/algorithms/aes-gcm.js +0 -147
  106. package/dist/esm/prototyping/crypto/algorithms/aes-gcm.js.map +0 -1
  107. package/dist/esm/prototyping/crypto/algorithms/aes-kw.js +0 -136
  108. package/dist/esm/prototyping/crypto/algorithms/aes-kw.js.map +0 -1
  109. package/dist/esm/prototyping/crypto/algorithms/ecdsa.js +0 -311
  110. package/dist/esm/prototyping/crypto/algorithms/ecdsa.js.map +0 -1
  111. package/dist/esm/prototyping/crypto/algorithms/eddsa.js +0 -268
  112. package/dist/esm/prototyping/crypto/algorithms/eddsa.js.map +0 -1
  113. package/dist/esm/prototyping/crypto/algorithms/hkdf.js +0 -38
  114. package/dist/esm/prototyping/crypto/algorithms/hkdf.js.map +0 -1
  115. package/dist/esm/prototyping/crypto/algorithms/pbkdf2.js +0 -40
  116. package/dist/esm/prototyping/crypto/algorithms/pbkdf2.js.map +0 -1
  117. package/dist/esm/prototyping/crypto/crypto-error.js +0 -41
  118. package/dist/esm/prototyping/crypto/crypto-error.js.map +0 -1
  119. package/dist/esm/prototyping/crypto/types/crypto-api.js +0 -2
  120. package/dist/esm/prototyping/crypto/types/crypto-api.js.map +0 -1
  121. package/dist/esm/prototyping/crypto/types/key-converter.js +0 -2
  122. package/dist/esm/prototyping/crypto/types/key-converter.js.map +0 -1
  123. package/dist/esm/prototyping/crypto/types/key-deriver.js +0 -2
  124. package/dist/esm/prototyping/crypto/types/key-deriver.js.map +0 -1
  125. package/dist/esm/prototyping/crypto/types/key-io.js +0 -2
  126. package/dist/esm/prototyping/crypto/types/key-io.js.map +0 -1
  127. package/dist/esm/prototyping/crypto/types/key-manager.js +0 -2
  128. package/dist/esm/prototyping/crypto/types/key-manager.js.map +0 -1
  129. package/dist/esm/prototyping/crypto/types/params-direct.js +0 -2
  130. package/dist/esm/prototyping/crypto/types/params-direct.js.map +0 -1
  131. package/dist/esm/prototyping/crypto/types/params-kms.js +0 -2
  132. package/dist/esm/prototyping/crypto/types/params-kms.js.map +0 -1
  133. package/dist/esm/prototyping/crypto/utils.js +0 -19
  134. package/dist/esm/prototyping/crypto/utils.js.map +0 -1
  135. package/dist/esm/prototyping/dids/resolver-cache-memory.js +0 -77
  136. package/dist/esm/prototyping/dids/resolver-cache-memory.js.map +0 -1
  137. package/dist/esm/prototyping/dids/utils.js +0 -9
  138. package/dist/esm/prototyping/dids/utils.js.map +0 -1
  139. package/dist/esm/rpc-client.js +0 -123
  140. package/dist/esm/rpc-client.js.map +0 -1
  141. package/dist/types/dwn-registrar.d.ts +0 -29
  142. package/dist/types/dwn-registrar.d.ts.map +0 -1
  143. package/dist/types/prototyping/clients/dwn-rpc-types.d.ts +0 -45
  144. package/dist/types/prototyping/clients/dwn-rpc-types.d.ts.map +0 -1
  145. package/dist/types/prototyping/clients/dwn-server-info-cache-memory.d.ts +0 -57
  146. package/dist/types/prototyping/clients/dwn-server-info-cache-memory.d.ts.map +0 -1
  147. package/dist/types/prototyping/clients/http-dwn-rpc-client.d.ts +0 -13
  148. package/dist/types/prototyping/clients/http-dwn-rpc-client.d.ts.map +0 -1
  149. package/dist/types/prototyping/clients/json-rpc-socket.d.ts +0 -43
  150. package/dist/types/prototyping/clients/json-rpc-socket.d.ts.map +0 -1
  151. package/dist/types/prototyping/clients/json-rpc.d.ts +0 -49
  152. package/dist/types/prototyping/clients/json-rpc.d.ts.map +0 -1
  153. package/dist/types/prototyping/clients/server-info-types.d.ts +0 -20
  154. package/dist/types/prototyping/clients/server-info-types.d.ts.map +0 -1
  155. package/dist/types/prototyping/clients/web-socket-clients.d.ts +0 -10
  156. package/dist/types/prototyping/clients/web-socket-clients.d.ts.map +0 -1
  157. package/dist/types/prototyping/common/object.d.ts +0 -2
  158. package/dist/types/prototyping/common/object.d.ts.map +0 -1
  159. package/dist/types/prototyping/common/type-utils.d.ts +0 -7
  160. package/dist/types/prototyping/common/type-utils.d.ts.map +0 -1
  161. package/dist/types/prototyping/crypto/algorithms/aes-gcm.d.ts +0 -151
  162. package/dist/types/prototyping/crypto/algorithms/aes-gcm.d.ts.map +0 -1
  163. package/dist/types/prototyping/crypto/algorithms/aes-kw.d.ts +0 -108
  164. package/dist/types/prototyping/crypto/algorithms/aes-kw.d.ts.map +0 -1
  165. package/dist/types/prototyping/crypto/algorithms/ecdsa.d.ts +0 -160
  166. package/dist/types/prototyping/crypto/algorithms/ecdsa.d.ts.map +0 -1
  167. package/dist/types/prototyping/crypto/algorithms/eddsa.d.ts +0 -157
  168. package/dist/types/prototyping/crypto/algorithms/eddsa.d.ts.map +0 -1
  169. package/dist/types/prototyping/crypto/algorithms/hkdf.d.ts +0 -20
  170. package/dist/types/prototyping/crypto/algorithms/hkdf.d.ts.map +0 -1
  171. package/dist/types/prototyping/crypto/algorithms/pbkdf2.d.ts +0 -20
  172. package/dist/types/prototyping/crypto/algorithms/pbkdf2.d.ts.map +0 -1
  173. package/dist/types/prototyping/crypto/crypto-error.d.ts +0 -29
  174. package/dist/types/prototyping/crypto/crypto-error.d.ts.map +0 -1
  175. package/dist/types/prototyping/crypto/types/crypto-api.d.ts +0 -34
  176. package/dist/types/prototyping/crypto/types/crypto-api.d.ts.map +0 -1
  177. package/dist/types/prototyping/crypto/types/key-converter.d.ts +0 -49
  178. package/dist/types/prototyping/crypto/types/key-converter.d.ts.map +0 -1
  179. package/dist/types/prototyping/crypto/types/key-deriver.d.ts +0 -50
  180. package/dist/types/prototyping/crypto/types/key-deriver.d.ts.map +0 -1
  181. package/dist/types/prototyping/crypto/types/key-io.d.ts +0 -49
  182. package/dist/types/prototyping/crypto/types/key-io.d.ts.map +0 -1
  183. package/dist/types/prototyping/crypto/types/key-manager.d.ts +0 -69
  184. package/dist/types/prototyping/crypto/types/key-manager.d.ts.map +0 -1
  185. package/dist/types/prototyping/crypto/types/params-direct.d.ts +0 -75
  186. package/dist/types/prototyping/crypto/types/params-direct.d.ts.map +0 -1
  187. package/dist/types/prototyping/crypto/types/params-kms.d.ts +0 -63
  188. package/dist/types/prototyping/crypto/types/params-kms.d.ts.map +0 -1
  189. package/dist/types/prototyping/crypto/utils.d.ts +0 -7
  190. package/dist/types/prototyping/crypto/utils.d.ts.map +0 -1
  191. package/dist/types/prototyping/dids/resolver-cache-memory.d.ts +0 -57
  192. package/dist/types/prototyping/dids/resolver-cache-memory.d.ts.map +0 -1
  193. package/dist/types/prototyping/dids/utils.d.ts +0 -3
  194. package/dist/types/prototyping/dids/utils.d.ts.map +0 -1
  195. package/dist/types/rpc-client.d.ts +0 -51
  196. package/dist/types/rpc-client.d.ts.map +0 -1
  197. package/src/dwn-registrar.ts +0 -127
  198. package/src/prototyping/clients/dwn-rpc-types.ts +0 -55
  199. package/src/prototyping/clients/dwn-server-info-cache-memory.ts +0 -79
  200. package/src/prototyping/clients/http-dwn-rpc-client.ts +0 -119
  201. package/src/prototyping/clients/json-rpc-socket.ts +0 -189
  202. package/src/prototyping/clients/json-rpc.ts +0 -113
  203. package/src/prototyping/clients/server-info-types.ts +0 -21
  204. package/src/prototyping/clients/web-socket-clients.ts +0 -103
  205. package/src/prototyping/common/object.ts +0 -15
  206. package/src/prototyping/common/type-utils.ts +0 -6
  207. package/src/prototyping/crypto/algorithms/aes-gcm.ts +0 -211
  208. package/src/prototyping/crypto/algorithms/aes-kw.ts +0 -160
  209. package/src/prototyping/crypto/algorithms/ecdsa.ts +0 -366
  210. package/src/prototyping/crypto/algorithms/eddsa.ts +0 -311
  211. package/src/prototyping/crypto/algorithms/hkdf.ts +0 -38
  212. package/src/prototyping/crypto/algorithms/pbkdf2.ts +0 -41
  213. package/src/prototyping/crypto/crypto-error.ts +0 -45
  214. package/src/prototyping/crypto/types/crypto-api.ts +0 -77
  215. package/src/prototyping/crypto/types/key-converter.ts +0 -53
  216. package/src/prototyping/crypto/types/key-deriver.ts +0 -56
  217. package/src/prototyping/crypto/types/key-io.ts +0 -51
  218. package/src/prototyping/crypto/types/key-manager.ts +0 -83
  219. package/src/prototyping/crypto/types/params-direct.ts +0 -95
  220. package/src/prototyping/crypto/types/params-kms.ts +0 -76
  221. package/src/prototyping/crypto/utils.ts +0 -41
  222. package/src/prototyping/dids/resolver-cache-memory.ts +0 -83
  223. package/src/prototyping/dids/utils.ts +0 -10
  224. package/src/rpc-client.ts +0 -160
@@ -7,13 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { computeJwkThumbprint, CryptoError, CryptoErrorCode, Sha2Algorithm } from '@enbox/crypto';
11
- import { AesGcmAlgorithm } from './prototyping/crypto/algorithms/aes-gcm.js';
12
- import { AesKwAlgorithm } from './prototyping/crypto/algorithms/aes-kw.js';
13
- import { EcdsaAlgorithm } from './prototyping/crypto/algorithms/ecdsa.js';
14
- import { EdDsaAlgorithm } from './prototyping/crypto/algorithms/eddsa.js';
15
- import { HkdfAlgorithm } from './prototyping/crypto/algorithms/hkdf.js';
16
- import { Pbkdf2Algorithm } from './prototyping/crypto/algorithms/pbkdf2.js';
10
+ import { AesGcmAlgorithm, AesKwAlgorithm, computeJwkThumbprint, CryptoError, CryptoErrorCode, EcdsaAlgorithm, EdDsaAlgorithm, HkdfAlgorithm, Pbkdf2Algorithm, Sha2Algorithm, X25519Algorithm, } from '@enbox/crypto';
17
11
  /**
18
12
  * `supportedAlgorithms` is an object mapping algorithm names to their respective implementations
19
13
  * Each entry in this map specifies the algorithm name and its associated properties, including the
@@ -62,6 +56,11 @@ const supportedAlgorithms = {
62
56
  implementation: Sha2Algorithm,
63
57
  names: ['SHA-256'],
64
58
  operations: ['digest'],
59
+ },
60
+ 'X25519': {
61
+ implementation: X25519Algorithm,
62
+ names: ['X25519'],
63
+ operations: ['bytesToPrivateKey', 'generateKey'],
65
64
  }
66
65
  };
67
66
  export class AgentCryptoApi {
@@ -209,12 +208,6 @@ export class AgentCryptoApi {
209
208
  return privateKey;
210
209
  });
211
210
  }
212
- // ! TODO: Remove this once the `Dsa` interface is updated in @enbox/crypto to remove KMS-specific methods.
213
- getKeyUri(_params) {
214
- return __awaiter(this, void 0, void 0, function* () {
215
- throw new Error('Method not implemented.');
216
- });
217
- }
218
211
  getPublicKey(_a) {
219
212
  return __awaiter(this, arguments, void 0, function* ({ key }) {
220
213
  // Determine the algorithm name based on the JWK's `alg` and `crv` properties.
@@ -1 +1 @@
1
- {"version":3,"file":"crypto-api.js","sourceRoot":"","sources":["../../src/crypto-api.ts"],"names":[],"mappings":";;;;;;;;;AA0BA,OAAO,EAAE,oBAAoB,EAAE,WAAW,EAAE,eAAe,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAOlG,OAAO,EAAE,eAAe,EAAE,MAAM,4CAA4C,CAAC;AAC7E,OAAO,EAAE,cAAc,EAAE,MAAM,2CAA2C,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,0CAA0C,CAAC;AAC1E,OAAO,EAAE,aAAa,EAAE,MAAM,yCAAyC,CAAC;AACxE,OAAO,EAAE,eAAe,EAAE,MAAM,2CAA2C,CAAC;AAuF5E;;;;;;;GAOG;AACH,MAAM,mBAAmB,GAAG;IAC1B,SAAS,EAAE;QACT,cAAc,EAAG,eAAe;QAChC,KAAK,EAAY,CAAC,SAAS,EAAE,SAAS,EAAE,SAAS,CAAC;QAClD,UAAU,EAAO,CAAC,mBAAmB,EAAE,SAAS,EAAE,SAAS,EAAE,aAAa,CAAC;KAC5E;IACD,QAAQ,EAAE;QACR,cAAc,EAAG,cAAc;QAC/B,KAAK,EAAY,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,CAAC;QAC/C,UAAU,EAAO,CAAC,mBAAmB,EAAE,aAAa,EAAE,mBAAmB,EAAE,SAAS,EAAE,WAAW,CAAC;KACnG;IACD,SAAS,EAAE;QACT,cAAc,EAAG,cAAc;QAC/B,KAAK,EAAY,CAAC,SAAS,CAAC;QAC5B,UAAU,EAAO,CAAC,mBAAmB,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,CAAC;KAC5F;IACD,MAAM,E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CAAC;QAED,6BAA6B;QAC7B,OAAO,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,uBAAuB,CAAE,CAAC;IAChE,CAAC;IA6BO,gBAAgB,CAAC,EAAE,SAAS,EAAE,GAAG,EAGxC;;QACC,MAAM,WAAW,GAAG,MAAA,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,GAAG,mCAAI,SAAS,CAAC;QAC1C,MAAM,WAAW,GAAG,GAAG,aAAH,GAAG,uBAAH,GAAG,CAAE,GAAG,CAAC;QAE7B,KAAK,MAAM,mBAAmB,IAAI,MAAM,CAAC,IAAI,CAAC,mBAAmB,CAAyB,EAAE,CAAC;YAC3F,MAAM,cAAc,GAAG,mBAAmB,CAAC,mBAAmB,CAAC,CAAC,KAA0B,CAAC;YAC3F,IAAI,WAAW,IAAI,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBACxD,OAAO,mBAAmB,CAAC;YAC7B,CAAC;iBAAM,IAAI,WAAW,IAAI,cAAc,CAAC,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC;gBAC/D,OAAO,mBAAmB,CAAC;YAC7B,CAAC;QACH,CAAC;QAED,MAAM,IAAI,WAAW,CAAC,eAAe,CAAC,qBAAqB,EACzD,wDAAwD,WAAW,SAAS,WAAW,IAAI;YAC3F,sEAAsE,CACvE,CAAC;IACJ,CAAC;CACF"}
@@ -7,9 +7,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
7
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
8
8
  });
9
9
  };
10
- import { CryptoUtils } from '@enbox/crypto';
11
10
  import { TtlCache } from '@enbox/common';
12
- import { Cid, DataStoreLevel, DataStream, Dwn, DwnInterfaceName, DwnMethodName, Encoder, Encryption, EventEmitterStream, Jws, KeyDerivationScheme, Message, MessageStoreLevel, Protocols, Records, ResumableTaskStoreLevel, Secp256k1, StateIndexLevel } from '@enbox/dwn-sdk-js';
11
+ import { Cid, ContentEncryptionAlgorithm, DataStoreLevel, DataStream, Dwn, DwnInterfaceName, DwnMethodName, Encoder, Encryption, EventEmitterStream, Jws, KeyDerivationScheme, Message, MessageStoreLevel, Protocols, Records, ResumableTaskStoreLevel, StateIndexLevel } from '@enbox/dwn-sdk-js';
12
+ import { CryptoUtils, X25519 } from '@enbox/crypto';
13
13
  import { DidDht, DidJwk, DidResolverCacheLevel, UniversalResolver } from '@enbox/dids';
14
14
  import { KeyDeliveryProtocolDefinition } from './store-data-protocols.js';
15
15
  import { DwnInterface, dwnMessageConstructors } from './types/dwn.js';
@@ -148,7 +148,7 @@ export class AgentDwnApi {
148
148
  const recordsWriteMessage = message;
149
149
  // Reactive root-record upgrade (PR E): if this is an externally-authored
150
150
  // root record with only ProtocolPath encryption, the owner upgrades it by
151
- // appending a ProtocolContext keyEncryption entry so that context key
151
+ // appending a ProtocolContext recipient entry so that context key
152
152
  // holders (including the external author) can also decrypt.
153
153
  const authorDid = Jws.getSignerDid(recordsWriteMessage.authorization.signature.signatures[0]);
154
154
  const isExternallyAuthored = authorDid !== request.target;
@@ -185,7 +185,7 @@ export class AgentDwnApi {
185
185
  keyUri,
186
186
  derivationPath: contextDerivationPath,
187
187
  });
188
- const contextDerivedPrivateJwk = yield Secp256k1.privateKeyToJwk(contextDerivedPrivateKeyBytes);
188
+ const contextDerivedPrivateJwk = yield X25519.bytesToPrivateKey({ privateKeyBytes: contextDerivedPrivateKeyBytes });
189
189
  const contextKeyPayload = {
190
190
  rootKeyId: keyId,
191
191
  derivationScheme: KeyDerivationScheme.ProtocolContext,
@@ -401,7 +401,7 @@ export class AgentDwnApi {
401
401
  // For cross-DWN writes (target !== author), the external author cannot
402
402
  // derive the target's context key. Root records use the target's ProtocolPath
403
403
  // public key. The target's agent reactively upgrades the record to include a
404
- // ProtocolContext keyEncryption entry. Non-root records extract the context
404
+ // ProtocolContext recipient entry. Non-root records extract the context
405
405
  // public key (derivedPublicKey) from existing ProtocolContext-encrypted records
406
406
  // in the same context on the target's DWN.
407
407
  // Tracks deferred context encryption info for root multi-party records.
@@ -465,8 +465,8 @@ export class AgentDwnApi {
465
465
  }
466
466
  // 5. Generate random DEK and IV
467
467
  const dataEncryptionKey = crypto.getRandomValues(new Uint8Array(32));
468
- const dataEncryptionIV = crypto.getRandomValues(new Uint8Array(16));
469
- // 6. Build EncryptionInput based on the encryption scheme decision
468
+ const dataEncryptionIV = crypto.getRandomValues(new Uint8Array(12));
469
+ // 6. Build partial EncryptionInput (authenticationTag added after AEAD encryption)
470
470
  let encryptionInput;
471
471
  const buildProtocolPathInput = () => this.buildEncryptionInput(dataEncryptionKey, dataEncryptionIV, ruleSet.$encryption.rootKeyId, ruleSet.$encryption.publicKeyJwk, KeyDerivationScheme.ProtocolPath);
472
472
  if (isCrossDwn && isMultiPartyContext && isRootRecord) {
@@ -474,7 +474,7 @@ export class AgentDwnApi {
474
474
  // External authors cannot derive the target's context key (HKDF requires
475
475
  // the private key). Use the target's ProtocolPath public key from their
476
476
  // protocol definition. The target's agent will reactively upgrade the record
477
- // to include a ProtocolContext keyEncryption entry.
477
+ // to include a ProtocolContext recipient entry.
478
478
  encryptionInput = buildProtocolPathInput();
479
479
  }
480
480
  else if (isCrossDwn && isMultiPartyContext && !isRootRecord) {
@@ -524,8 +524,8 @@ export class AgentDwnApi {
524
524
  // --- Local single-party → ProtocolPath key (existing logic) ---
525
525
  encryptionInput = buildProtocolPathInput();
526
526
  }
527
- // 7. Encrypt data with AES-256-CTR and compute CID
528
- const { encryptedBytes, dataCid, dataSize } = yield this.encryptAndComputeCid(plaintextBytes, dataEncryptionKey, dataEncryptionIV);
527
+ // 7. Encrypt data with AEAD (AES-256-GCM) and compute CID
528
+ const { encryptedBytes, dataCid, dataSize, authenticationTag } = yield this.encryptAndComputeCid(plaintextBytes, dataEncryptionKey, dataEncryptionIV);
529
529
  // 8. Replace plaintext with encrypted data
530
530
  messageParams.dataCid = dataCid;
531
531
  messageParams.dataSize = dataSize;
@@ -533,11 +533,12 @@ export class AgentDwnApi {
533
533
  readableStream = DataStream.fromBytes(encryptedBytes);
534
534
  request.dataStream = undefined;
535
535
  if (encryptionInput) {
536
+ encryptionInput.authenticationTag = authenticationTag;
536
537
  messageParams.encryptionInput = encryptionInput;
537
538
  }
538
539
  else {
539
540
  // Deferred — store info for post-creation encryption
540
- deferredContextEncryption = { dataEncryptionKey, dataEncryptionIV, encryptedBytes };
541
+ deferredContextEncryption = { dataEncryptionKey, dataEncryptionIV, encryptedBytes, authenticationTag };
541
542
  }
542
543
  // 9. For cross-DWN writes in multi-party contexts, attach the author's
543
544
  // key-delivery ProtocolPath public key so the DWN owner can encrypt
@@ -577,7 +578,8 @@ export class AgentDwnApi {
577
578
  const recordsWriteInstance = dwnMessage;
578
579
  const contextId = recordsWriteInstance.message.recordId;
579
580
  const { encryptionInput: contextEncryptionInput, keyId, keyUri, contextDerivationPath } = yield this.deriveContextEncryptionInput(request.author, contextId, deferredContextEncryption.dataEncryptionKey, deferredContextEncryption.dataEncryptionIV);
580
- yield recordsWriteInstance.encryptSymmetricEncryptionKey(contextEncryptionInput);
581
+ const fullContextInput = Object.assign(Object.assign({}, contextEncryptionInput), { authenticationTag: deferredContextEncryption.authenticationTag });
582
+ yield recordsWriteInstance.encryptSymmetricEncryptionKey(fullContextInput);
581
583
  yield recordsWriteInstance.sign({ signer });
582
584
  // Cache context key info for subsequent writes in this context
583
585
  this._contextKeyCache.set(contextId, { keyId, keyUri, contextDerivationPath });
@@ -657,7 +659,7 @@ export class AgentDwnApi {
657
659
  * @param didUri - The DID URI to resolve encryption key info for
658
660
  * @returns keyId (fully qualified verification method ID), keyUri (KMS reference),
659
661
  * and publicKeyJwk. No private key material is returned.
660
- * @throws If the DID has no keyAgreement verification method or it's not secp256k1.
662
+ * @throws If the DID has no keyAgreement verification method or it's not X25519.
661
663
  */
662
664
  getEncryptionKeyInfo(didUri) {
663
665
  return __awaiter(this, void 0, void 0, function* () {
@@ -672,7 +674,7 @@ export class AgentDwnApi {
672
674
  const keyAgreementRefs = didDocument.keyAgreement;
673
675
  if (!keyAgreementRefs || keyAgreementRefs.length === 0) {
674
676
  throw new Error(`AgentDwnApi: DID '${didUri}' does not have a keyAgreement ` +
675
- `verification method. Create the identity with a secp256k1 key ` +
677
+ `verification method. Create the identity with an X25519 key ` +
676
678
  `with keyAgreement purpose to use protocol encryption.`);
677
679
  }
678
680
  // 3. Resolve the verification method (handle both inline and string refs)
@@ -691,11 +693,11 @@ export class AgentDwnApi {
691
693
  throw new Error(`AgentDwnApi: keyAgreement verification method for '${didUri}' ` +
692
694
  `does not contain a public key in JWK format.`);
693
695
  }
694
- // 4. Verify it's a secp256k1 key
696
+ // 4. Verify it's an X25519 key
695
697
  const publicKeyJwk = verificationMethod.publicKeyJwk;
696
- if (publicKeyJwk.crv !== 'secp256k1') {
698
+ if (publicKeyJwk.crv !== 'X25519') {
697
699
  throw new Error(`AgentDwnApi: keyAgreement key for '${didUri}' uses curve ` +
698
- `'${publicKeyJwk.crv}', but DWN encryption requires 'secp256k1'.`);
700
+ `'${publicKeyJwk.crv}', but DWN encryption requires 'X25519'.`);
699
701
  }
700
702
  // 5. Compute the KMS key URI (does NOT export the key)
701
703
  const keyUri = yield this.agent.keyManager.getKeyUri({ key: publicKeyJwk });
@@ -707,9 +709,9 @@ export class AgentDwnApi {
707
709
  });
708
710
  }
709
711
  /**
710
- * Builds an EncryptionInput object for a single key-encryption entry.
711
- * Consolidates the repeated pattern of assembling DEK, IV, and a single
712
- * keyEncryptionInputs entry into one place.
712
+ * Builds a partial EncryptionInput object for a single key-encryption entry.
713
+ * The `authenticationTag` is NOT set here the caller must set it after
714
+ * AEAD encryption produces the tag.
713
715
  */
714
716
  buildEncryptionInput(dek, iv, publicKeyId, publicKey, derivationScheme) {
715
717
  return {
@@ -723,18 +725,17 @@ export class AgentDwnApi {
723
725
  };
724
726
  }
725
727
  /**
726
- * Encrypts plaintext bytes with AES-256-CTR and computes the CID of the
727
- * resulting ciphertext. Returns everything needed to attach the encrypted
728
- * data to a DWN message.
728
+ * Encrypts plaintext bytes with AEAD (AES-256-GCM by default) and computes
729
+ * the CID of the resulting ciphertext. Returns everything needed to attach
730
+ * the encrypted data to a DWN message, including the authentication tag.
729
731
  */
730
732
  encryptAndComputeCid(plaintextBytes, dek, iv) {
731
733
  return __awaiter(this, void 0, void 0, function* () {
732
- const plaintextStream = DataStream.fromBytes(plaintextBytes);
733
- const encryptedStream = yield Encryption.aes256CtrEncrypt(dek, iv, plaintextStream);
734
- const encryptedBytes = yield DataStream.toBytes(encryptedStream);
734
+ const { ciphertextStream, tag: authenticationTag } = yield Encryption.aeadEncryptStream(ContentEncryptionAlgorithm.A256GCM, dek, iv, DataStream.fromBytes(plaintextBytes));
735
+ const encryptedBytes = yield DataStream.toBytes(ciphertextStream);
735
736
  const cidStream = DataStream.fromBytes(encryptedBytes);
736
737
  const dataCid = yield Cid.computeDagPbCidFromStream(cidStream);
737
- return { encryptedBytes, dataCid, dataSize: encryptedBytes.length };
738
+ return { encryptedBytes, dataCid, dataSize: encryptedBytes.length, authenticationTag };
738
739
  });
739
740
  }
740
741
  /**
@@ -756,7 +757,7 @@ export class AgentDwnApi {
756
757
  });
757
758
  }
758
759
  /**
759
- * Builds a KMS-backed ECIES decrypt callback. Used for both ProtocolPath
760
+ * Builds a KMS-backed JWE key unwrap callback. Used for both ProtocolPath
760
761
  * and ProtocolContext decryption where the KMS holds the root private key.
761
762
  */
762
763
  buildKmsDecryptCallback(keyId, keyUri, derivationScheme) {
@@ -764,14 +765,12 @@ export class AgentDwnApi {
764
765
  return {
765
766
  rootKeyId: keyId,
766
767
  derivationScheme,
767
- decrypt: (fullDerivationPath, eciesPayload) => __awaiter(this, void 0, void 0, function* () {
768
- return keyManager.eciesSecp256k1Decrypt({
768
+ decrypt: (fullDerivationPath, jwePayload) => __awaiter(this, void 0, void 0, function* () {
769
+ return keyManager.jweKeyUnwrap({
769
770
  keyUri,
770
771
  derivationPath: fullDerivationPath,
771
- ciphertext: eciesPayload.ciphertext,
772
- ephemeralPublicKey: eciesPayload.ephemeralPublicKey,
773
- initializationVector: eciesPayload.initializationVector,
774
- messageAuthenticationCode: eciesPayload.messageAuthenticationCode,
772
+ encryptedKey: jwePayload.encryptedKey,
773
+ ephemeralPublicKey: jwePayload.ephemeralPublicKey,
775
774
  });
776
775
  }),
777
776
  };
@@ -1054,15 +1053,15 @@ export class AgentDwnApi {
1054
1053
  if (queryReply.status.code !== 200 || !((_a = queryReply.entries) === null || _a === void 0 ? void 0 : _a.length)) {
1055
1054
  return undefined;
1056
1055
  }
1057
- // Search entries for one with a ProtocolContext keyEncryption entry
1056
+ // Search entries for one with a ProtocolContext recipient entry
1058
1057
  // that includes derivedPublicKey
1059
1058
  for (const entry of queryReply.entries) {
1060
- if ((_b = entry.encryption) === null || _b === void 0 ? void 0 : _b.keyEncryption) {
1061
- const contextEntry = entry.encryption.keyEncryption.find((k) => k.derivationScheme === KeyDerivationScheme.ProtocolContext && k.derivedPublicKey);
1062
- if (contextEntry === null || contextEntry === void 0 ? void 0 : contextEntry.derivedPublicKey) {
1059
+ if ((_b = entry.encryption) === null || _b === void 0 ? void 0 : _b.recipients) {
1060
+ const contextEntry = entry.encryption.recipients.find((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolContext && r.header.derivedPublicKey);
1061
+ if (contextEntry === null || contextEntry === void 0 ? void 0 : contextEntry.header.derivedPublicKey) {
1063
1062
  return {
1064
- rootKeyId: contextEntry.rootKeyId,
1065
- derivedPublicKey: contextEntry.derivedPublicKey,
1063
+ rootKeyId: contextEntry.header.kid,
1064
+ derivedPublicKey: contextEntry.header.derivedPublicKey,
1066
1065
  };
1067
1066
  }
1068
1067
  }
@@ -1072,7 +1071,7 @@ export class AgentDwnApi {
1072
1071
  }
1073
1072
  /**
1074
1073
  * Reactively upgrades an externally-authored root record that has only
1075
- * ProtocolPath encryption by appending a ProtocolContext keyEncryption entry.
1074
+ * ProtocolPath encryption by appending a ProtocolContext recipient entry.
1076
1075
  *
1077
1076
  * After the upgrade, both the owner (ProtocolPath) and context key holders —
1078
1077
  * including the external author (ProtocolContext) — can decrypt the record.
@@ -1081,7 +1080,7 @@ export class AgentDwnApi {
1081
1080
  * 1. Decrypt the DEK using the owner's ProtocolPath-derived private key
1082
1081
  * 2. Derive the context public key from the owner's #enc key
1083
1082
  * 3. ECIES-encrypt the same DEK to the context public key
1084
- * 4. Append the ProtocolContext keyEncryption entry (using PR 0b append mode)
1083
+ * 4. Append the ProtocolContext recipient entry (using PR 0b append mode)
1085
1084
  * 5. Re-sign the record as owner
1086
1085
  *
1087
1086
  * The author's signature payload includes an `encryptionCid` that becomes
@@ -1106,32 +1105,32 @@ export class AgentDwnApi {
1106
1105
  return;
1107
1106
  }
1108
1107
  // Verify: has ProtocolPath but NOT ProtocolContext
1109
- const hasProtocolPath = encryption.keyEncryption.some((k) => k.derivationScheme === KeyDerivationScheme.ProtocolPath);
1110
- const hasProtocolContext = encryption.keyEncryption.some((k) => k.derivationScheme === KeyDerivationScheme.ProtocolContext);
1108
+ const hasProtocolPath = encryption.recipients.some((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolPath);
1109
+ const hasProtocolContext = encryption.recipients.some((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolContext);
1111
1110
  if (!hasProtocolPath || hasProtocolContext) {
1112
1111
  return;
1113
1112
  }
1114
1113
  // 1. Decrypt the DEK using the owner's ProtocolPath key
1115
1114
  const keyDecrypter = yield this.getKeyDecrypter(tenantDid);
1116
- // Find the ProtocolPath keyEncryption entry
1117
- const pathEntry = encryption.keyEncryption.find((k) => k.derivationScheme === KeyDerivationScheme.ProtocolPath);
1115
+ // Find the ProtocolPath recipient entry
1116
+ const pathRecipient = encryption.recipients.find((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolPath);
1118
1117
  const fullDerivationPath = Records.constructKeyDerivationPathUsingProtocolPathScheme(recordsWrite.descriptor);
1119
1118
  const dataEncryptionKey = yield keyDecrypter.decrypt(fullDerivationPath, {
1120
- ciphertext: Encoder.base64UrlToBytes(pathEntry.encryptedKey),
1121
- ephemeralPublicKey: Secp256k1.publicJwkToBytes(pathEntry.ephemeralPublicKey),
1122
- initializationVector: Encoder.base64UrlToBytes(pathEntry.initializationVector),
1123
- messageAuthenticationCode: Encoder.base64UrlToBytes(pathEntry.messageAuthenticationCode),
1119
+ encryptedKey: Encoder.base64UrlToBytes(pathRecipient.encrypted_key),
1120
+ ephemeralPublicKey: pathRecipient.header.epk,
1124
1121
  });
1125
1122
  // 2. Derive the context public key — contextId = recordId for root records
1126
1123
  const contextId = recordsWrite.recordId;
1127
- const encryptionIV = Encoder.base64UrlToBytes(encryption.initializationVector);
1128
- // 3 & 4. Append the ProtocolContext keyEncryption entry using append mode.
1124
+ const encryptionIV = Encoder.base64UrlToBytes(encryption.iv);
1125
+ // 3 & 4. Append the ProtocolContext recipient entry using append mode.
1129
1126
  // Append mode preserves the author's identity and authorization so that
1130
1127
  // signAsOwner() can be called in step 5.
1131
1128
  const { encryptionInput: contextEncryptionInput, keyId, keyUri, contextDerivationPath } = yield this.deriveContextEncryptionInput(tenantDid, contextId, dataEncryptionKey, encryptionIV);
1129
+ // Set the authentication tag from the existing JWE encryption property
1130
+ const fullContextInput = Object.assign(Object.assign({}, contextEncryptionInput), { authenticationTag: Encoder.base64UrlToBytes(encryption.tag) });
1132
1131
  // Parse the message to get a RecordsWrite instance we can mutate
1133
1132
  const recordsWriteInstance = yield dwnMessageConstructors[DwnInterface.RecordsWrite].parse(recordsWrite);
1134
- yield recordsWriteInstance.encryptSymmetricEncryptionKey(contextEncryptionInput, { append: true });
1133
+ yield recordsWriteInstance.encryptSymmetricEncryptionKey(fullContextInput, { append: true });
1135
1134
  // 5. Re-sign as owner — the author's signature is preserved but its
1136
1135
  // encryptionCid is now stale; the owner's signature vouches for the
1137
1136
  // updated encryption property.
@@ -1145,29 +1144,37 @@ export class AgentDwnApi {
1145
1144
  // We must also update the state index and event stream to keep sync and
1146
1145
  // real-time subscribers consistent — without this, the upgraded record
1147
1146
  // would never propagate to remote DWNs or notify subscribers.
1148
- const dwnInternal = this._dwn;
1149
- const messageStore = dwnInternal.messageStore;
1150
- const stateIndex = dwnInternal.stateIndex;
1151
- const eventStream = dwnInternal.eventStream;
1147
+ const { messageStore, stateIndex, eventStream } = this._dwn.storage;
1148
+ // Validate the upgrade only changed encryption and authorization fields.
1149
+ // The descriptor, recordId, contextId, and data must remain identical.
1150
+ // Note: parse() may produce a new descriptor object, so we compare by value.
1151
+ const upgradedMessage = recordsWriteInstance.message;
1152
+ if (JSON.stringify(upgradedMessage.descriptor) !== JSON.stringify(recordsWrite.descriptor)) {
1153
+ throw new Error('AgentDwnApi: upgradeExternalRootRecord() must not modify the descriptor.');
1154
+ }
1155
+ if (upgradedMessage.recordId !== recordsWrite.recordId) {
1156
+ throw new Error('AgentDwnApi: upgradeExternalRootRecord() must not modify the recordId.');
1157
+ }
1152
1158
  // Fetch the stored original (which carries encodedData for small payloads)
1153
1159
  const originalCid = yield Message.getCid(recordsWrite);
1154
1160
  const storedOriginal = yield messageStore.get(tenantDid, originalCid);
1155
- // Remove the original message and its state index entry
1156
- yield messageStore.delete(tenantDid, originalCid);
1157
- yield stateIndex.delete(tenantDid, [originalCid]);
1158
1161
  // Build indexes for the upgraded message (mark as latest base state)
1159
1162
  const isLatestBaseState = true;
1160
1163
  const upgradedIndexes = yield recordsWriteInstance.constructIndexes(isLatestBaseState);
1161
1164
  // Carry over the encoded data from the stored original (the handler
1162
1165
  // base64url-encodes small payloads into encodedData during processMessage)
1163
- const upgradedMessage = recordsWriteInstance.message;
1164
1166
  if (storedOriginal === null || storedOriginal === void 0 ? void 0 : storedOriginal.encodedData) {
1165
1167
  upgradedMessage.encodedData = storedOriginal.encodedData;
1166
1168
  }
1167
- // Store the upgraded message and insert into state index
1168
- yield messageStore.put(tenantDid, upgradedMessage, upgradedIndexes);
1169
+ // Use put-before-delete ordering: if a crash occurs after the put but
1170
+ // before the delete, we end up with a duplicate (recoverable via the
1171
+ // isLatestBaseState index) rather than data loss (unrecoverable).
1169
1172
  const upgradedCid = yield Message.getCid(upgradedMessage);
1173
+ yield messageStore.put(tenantDid, upgradedMessage, upgradedIndexes);
1170
1174
  yield stateIndex.insert(tenantDid, upgradedCid, upgradedIndexes);
1175
+ // Now remove the original message and its state index entry.
1176
+ yield messageStore.delete(tenantDid, originalCid);
1177
+ yield stateIndex.delete(tenantDid, [originalCid]);
1171
1178
  // Notify real-time subscribers (mirrors handler behavior)
1172
1179
  if (eventStream !== undefined) {
1173
1180
  eventStream.emit(tenantDid, { message: upgradedMessage }, upgradedIndexes);
@@ -1188,17 +1195,17 @@ export class AgentDwnApi {
1188
1195
  return __awaiter(this, void 0, void 0, function* () {
1189
1196
  const { encryption } = recordsWrite;
1190
1197
  // Check if the record uses context-derived encryption
1191
- const hasContextKey = encryption === null || encryption === void 0 ? void 0 : encryption.keyEncryption.some((k) => k.derivationScheme === KeyDerivationScheme.ProtocolContext);
1198
+ const hasContextKey = encryption === null || encryption === void 0 ? void 0 : encryption.recipients.some((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolContext);
1192
1199
  if (!hasContextKey || !recordsWrite.contextId) {
1193
1200
  // Single-party protocol-path encryption
1194
1201
  return this.getKeyDecrypter(authorDid);
1195
1202
  }
1196
1203
  // --- Multi-party context encryption ---
1197
- const contextKeyEntry = encryption.keyEncryption.find((k) => k.derivationScheme === KeyDerivationScheme.ProtocolContext);
1204
+ const contextKeyEntry = encryption.recipients.find((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolContext);
1198
1205
  const rootContextId = recordsWrite.contextId.split('/')[0];
1199
1206
  // Case 1: I am the context creator — rootKeyId matches my encryption key
1200
1207
  const { keyId, keyUri } = yield this.getEncryptionKeyInfo(authorDid);
1201
- if (contextKeyEntry.rootKeyId === keyId) {
1208
+ if (contextKeyEntry.header.kid === keyId) {
1202
1209
  return this.buildKmsDecryptCallback(keyId, keyUri, KeyDerivationScheme.ProtocolContext);
1203
1210
  }
1204
1211
  // Case 2: I am a participant — fetch my context key from the key-delivery protocol
@@ -1246,15 +1253,10 @@ export class AgentDwnApi {
1246
1253
  return {
1247
1254
  rootKeyId: contextKey.rootKeyId,
1248
1255
  derivationScheme: contextKey.derivationScheme,
1249
- decrypt: (fullDerivationPath, eciesPayload) => __awaiter(this, void 0, void 0, function* () {
1250
- const leafPrivateKey = yield Records.derivePrivateKey(contextKey, fullDerivationPath);
1251
- return Encryption.eciesSecp256k1Decrypt({
1252
- privateKey: leafPrivateKey,
1253
- ciphertext: eciesPayload.ciphertext,
1254
- ephemeralPublicKey: eciesPayload.ephemeralPublicKey,
1255
- initializationVector: eciesPayload.initializationVector,
1256
- messageAuthenticationCode: eciesPayload.messageAuthenticationCode,
1257
- });
1256
+ decrypt: (fullDerivationPath, jwePayload) => __awaiter(this, void 0, void 0, function* () {
1257
+ const leafPrivateKeyBytes = yield Records.derivePrivateKey(contextKey, fullDerivationPath);
1258
+ const leafPrivateKeyJwk = yield X25519.bytesToPrivateKey({ privateKeyBytes: leafPrivateKeyBytes });
1259
+ return Encryption.ecdhEsUnwrapKey(leafPrivateKeyJwk, jwePayload.ephemeralPublicKey, jwePayload.encryptedKey);
1258
1260
  }),
1259
1261
  };
1260
1262
  }
@@ -1415,9 +1417,9 @@ export class AgentDwnApi {
1415
1417
  // Manually build encryption input targeting the recipient's key so the
1416
1418
  // record is decryptable only by the recipient.
1417
1419
  const dataEncryptionKey = crypto.getRandomValues(new Uint8Array(32));
1418
- const dataEncryptionIV = crypto.getRandomValues(new Uint8Array(16));
1419
- const { encryptedBytes, dataCid, dataSize } = yield this.encryptAndComputeCid(plaintextBytes, dataEncryptionKey, dataEncryptionIV);
1420
- const encryptionInput = this.buildEncryptionInput(dataEncryptionKey, dataEncryptionIV, recipientKeyDeliveryPublicKey.rootKeyId, recipientKeyDeliveryPublicKey.publicKeyJwk, KeyDerivationScheme.ProtocolPath);
1420
+ const dataEncryptionIV = crypto.getRandomValues(new Uint8Array(12));
1421
+ const { encryptedBytes, dataCid, dataSize, authenticationTag } = yield this.encryptAndComputeCid(plaintextBytes, dataEncryptionKey, dataEncryptionIV);
1422
+ const encryptionInput = Object.assign(Object.assign({}, this.buildEncryptionInput(dataEncryptionKey, dataEncryptionIV, recipientKeyDeliveryPublicKey.rootKeyId, recipientKeyDeliveryPublicKey.publicKeyJwk, KeyDerivationScheme.ProtocolPath)), { authenticationTag });
1421
1423
  ({ message, reply: { status } } = yield this.processRequest({
1422
1424
  author: tenantDid,
1423
1425
  target: tenantDid,