@enbox/agent 0.1.3 → 0.1.5

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 +92 -81
  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 +15 -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 +12 -14
  65. package/src/crypto-api.ts +24 -20
  66. package/src/dwn-api.ts +123 -105
  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.
@@ -463,10 +463,11 @@ export class AgentDwnApi {
463
463
  else {
464
464
  throw new Error('AgentDwnApi: Data must be provided for encrypted records.');
465
465
  }
466
- // 5. Generate random DEK and IV
466
+ // 5. Generate random DEK and IV (IV size depends on content encryption algorithm)
467
+ const contentEncryptionAlgorithm = ContentEncryptionAlgorithm.A256GCM;
467
468
  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
469
+ const dataEncryptionIV = crypto.getRandomValues(new Uint8Array(AgentDwnApi.ivLength(contentEncryptionAlgorithm)));
470
+ // 6. Build partial EncryptionInput (authenticationTag added after AEAD encryption)
470
471
  let encryptionInput;
471
472
  const buildProtocolPathInput = () => this.buildEncryptionInput(dataEncryptionKey, dataEncryptionIV, ruleSet.$encryption.rootKeyId, ruleSet.$encryption.publicKeyJwk, KeyDerivationScheme.ProtocolPath);
472
473
  if (isCrossDwn && isMultiPartyContext && isRootRecord) {
@@ -474,7 +475,7 @@ export class AgentDwnApi {
474
475
  // External authors cannot derive the target's context key (HKDF requires
475
476
  // the private key). Use the target's ProtocolPath public key from their
476
477
  // protocol definition. The target's agent will reactively upgrade the record
477
- // to include a ProtocolContext keyEncryption entry.
478
+ // to include a ProtocolContext recipient entry.
478
479
  encryptionInput = buildProtocolPathInput();
479
480
  }
480
481
  else if (isCrossDwn && isMultiPartyContext && !isRootRecord) {
@@ -524,8 +525,8 @@ export class AgentDwnApi {
524
525
  // --- Local single-party → ProtocolPath key (existing logic) ---
525
526
  encryptionInput = buildProtocolPathInput();
526
527
  }
527
- // 7. Encrypt data with AES-256-CTR and compute CID
528
- const { encryptedBytes, dataCid, dataSize } = yield this.encryptAndComputeCid(plaintextBytes, dataEncryptionKey, dataEncryptionIV);
528
+ // 7. Encrypt data with AEAD and compute CID
529
+ const { encryptedBytes, dataCid, dataSize, authenticationTag } = yield this.encryptAndComputeCid(plaintextBytes, dataEncryptionKey, dataEncryptionIV, contentEncryptionAlgorithm);
529
530
  // 8. Replace plaintext with encrypted data
530
531
  messageParams.dataCid = dataCid;
531
532
  messageParams.dataSize = dataSize;
@@ -533,11 +534,12 @@ export class AgentDwnApi {
533
534
  readableStream = DataStream.fromBytes(encryptedBytes);
534
535
  request.dataStream = undefined;
535
536
  if (encryptionInput) {
537
+ encryptionInput.authenticationTag = authenticationTag;
536
538
  messageParams.encryptionInput = encryptionInput;
537
539
  }
538
540
  else {
539
541
  // Deferred — store info for post-creation encryption
540
- deferredContextEncryption = { dataEncryptionKey, dataEncryptionIV, encryptedBytes };
542
+ deferredContextEncryption = { dataEncryptionKey, dataEncryptionIV, encryptedBytes, authenticationTag };
541
543
  }
542
544
  // 9. For cross-DWN writes in multi-party contexts, attach the author's
543
545
  // key-delivery ProtocolPath public key so the DWN owner can encrypt
@@ -577,7 +579,8 @@ export class AgentDwnApi {
577
579
  const recordsWriteInstance = dwnMessage;
578
580
  const contextId = recordsWriteInstance.message.recordId;
579
581
  const { encryptionInput: contextEncryptionInput, keyId, keyUri, contextDerivationPath } = yield this.deriveContextEncryptionInput(request.author, contextId, deferredContextEncryption.dataEncryptionKey, deferredContextEncryption.dataEncryptionIV);
580
- yield recordsWriteInstance.encryptSymmetricEncryptionKey(contextEncryptionInput);
582
+ const fullContextInput = Object.assign(Object.assign({}, contextEncryptionInput), { authenticationTag: deferredContextEncryption.authenticationTag });
583
+ yield recordsWriteInstance.encryptSymmetricEncryptionKey(fullContextInput);
581
584
  yield recordsWriteInstance.sign({ signer });
582
585
  // Cache context key info for subsequent writes in this context
583
586
  this._contextKeyCache.set(contextId, { keyId, keyUri, contextDerivationPath });
@@ -657,7 +660,7 @@ export class AgentDwnApi {
657
660
  * @param didUri - The DID URI to resolve encryption key info for
658
661
  * @returns keyId (fully qualified verification method ID), keyUri (KMS reference),
659
662
  * and publicKeyJwk. No private key material is returned.
660
- * @throws If the DID has no keyAgreement verification method or it's not secp256k1.
663
+ * @throws If the DID has no keyAgreement verification method or it's not X25519.
661
664
  */
662
665
  getEncryptionKeyInfo(didUri) {
663
666
  return __awaiter(this, void 0, void 0, function* () {
@@ -672,7 +675,7 @@ export class AgentDwnApi {
672
675
  const keyAgreementRefs = didDocument.keyAgreement;
673
676
  if (!keyAgreementRefs || keyAgreementRefs.length === 0) {
674
677
  throw new Error(`AgentDwnApi: DID '${didUri}' does not have a keyAgreement ` +
675
- `verification method. Create the identity with a secp256k1 key ` +
678
+ `verification method. Create the identity with an X25519 key ` +
676
679
  `with keyAgreement purpose to use protocol encryption.`);
677
680
  }
678
681
  // 3. Resolve the verification method (handle both inline and string refs)
@@ -691,11 +694,11 @@ export class AgentDwnApi {
691
694
  throw new Error(`AgentDwnApi: keyAgreement verification method for '${didUri}' ` +
692
695
  `does not contain a public key in JWK format.`);
693
696
  }
694
- // 4. Verify it's a secp256k1 key
697
+ // 4. Verify it's an X25519 key
695
698
  const publicKeyJwk = verificationMethod.publicKeyJwk;
696
- if (publicKeyJwk.crv !== 'secp256k1') {
699
+ if (publicKeyJwk.crv !== 'X25519') {
697
700
  throw new Error(`AgentDwnApi: keyAgreement key for '${didUri}' uses curve ` +
698
- `'${publicKeyJwk.crv}', but DWN encryption requires 'secp256k1'.`);
701
+ `'${publicKeyJwk.crv}', but DWN encryption requires 'X25519'.`);
699
702
  }
700
703
  // 5. Compute the KMS key URI (does NOT export the key)
701
704
  const keyUri = yield this.agent.keyManager.getKeyUri({ key: publicKeyJwk });
@@ -707,10 +710,17 @@ export class AgentDwnApi {
707
710
  });
708
711
  }
709
712
  /**
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.
713
+ * Builds a partial EncryptionInput object for a single key-encryption entry.
714
+ * The `authenticationTag` is NOT set here the caller must set it after
715
+ * AEAD encryption produces the tag.
713
716
  */
717
+ /**
718
+ * Returns the correct nonce/IV byte length for the given content encryption algorithm.
719
+ * A256GCM uses 96-bit (12-byte) nonces; XC20P uses 192-bit (24-byte) nonces.
720
+ */
721
+ static ivLength(algorithm) {
722
+ return algorithm === ContentEncryptionAlgorithm.XC20P ? 24 : 12;
723
+ }
714
724
  buildEncryptionInput(dek, iv, publicKeyId, publicKey, derivationScheme) {
715
725
  return {
716
726
  initializationVector: iv,
@@ -723,18 +733,17 @@ export class AgentDwnApi {
723
733
  };
724
734
  }
725
735
  /**
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.
736
+ * Encrypts plaintext bytes with AEAD and computes the CID of the resulting ciphertext.
737
+ * Returns everything needed to attach the encrypted data to a DWN message, including
738
+ * the authentication tag.
729
739
  */
730
- encryptAndComputeCid(plaintextBytes, dek, iv) {
731
- 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);
740
+ encryptAndComputeCid(plaintextBytes_1, dek_1, iv_1) {
741
+ return __awaiter(this, arguments, void 0, function* (plaintextBytes, dek, iv, algorithm = ContentEncryptionAlgorithm.A256GCM) {
742
+ const { ciphertextStream, tag: authenticationTag } = yield Encryption.aeadEncryptStream(algorithm, dek, iv, DataStream.fromBytes(plaintextBytes));
743
+ const encryptedBytes = yield DataStream.toBytes(ciphertextStream);
735
744
  const cidStream = DataStream.fromBytes(encryptedBytes);
736
745
  const dataCid = yield Cid.computeDagPbCidFromStream(cidStream);
737
- return { encryptedBytes, dataCid, dataSize: encryptedBytes.length };
746
+ return { encryptedBytes, dataCid, dataSize: encryptedBytes.length, authenticationTag };
738
747
  });
739
748
  }
740
749
  /**
@@ -756,7 +765,7 @@ export class AgentDwnApi {
756
765
  });
757
766
  }
758
767
  /**
759
- * Builds a KMS-backed ECIES decrypt callback. Used for both ProtocolPath
768
+ * Builds a KMS-backed JWE key unwrap callback. Used for both ProtocolPath
760
769
  * and ProtocolContext decryption where the KMS holds the root private key.
761
770
  */
762
771
  buildKmsDecryptCallback(keyId, keyUri, derivationScheme) {
@@ -764,14 +773,12 @@ export class AgentDwnApi {
764
773
  return {
765
774
  rootKeyId: keyId,
766
775
  derivationScheme,
767
- decrypt: (fullDerivationPath, eciesPayload) => __awaiter(this, void 0, void 0, function* () {
768
- return keyManager.eciesSecp256k1Decrypt({
776
+ decrypt: (fullDerivationPath, jwePayload) => __awaiter(this, void 0, void 0, function* () {
777
+ return keyManager.jweKeyUnwrap({
769
778
  keyUri,
770
779
  derivationPath: fullDerivationPath,
771
- ciphertext: eciesPayload.ciphertext,
772
- ephemeralPublicKey: eciesPayload.ephemeralPublicKey,
773
- initializationVector: eciesPayload.initializationVector,
774
- messageAuthenticationCode: eciesPayload.messageAuthenticationCode,
780
+ encryptedKey: jwePayload.encryptedKey,
781
+ ephemeralPublicKey: jwePayload.ephemeralPublicKey,
775
782
  });
776
783
  }),
777
784
  };
@@ -1054,15 +1061,15 @@ export class AgentDwnApi {
1054
1061
  if (queryReply.status.code !== 200 || !((_a = queryReply.entries) === null || _a === void 0 ? void 0 : _a.length)) {
1055
1062
  return undefined;
1056
1063
  }
1057
- // Search entries for one with a ProtocolContext keyEncryption entry
1064
+ // Search entries for one with a ProtocolContext recipient entry
1058
1065
  // that includes derivedPublicKey
1059
1066
  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) {
1067
+ if ((_b = entry.encryption) === null || _b === void 0 ? void 0 : _b.recipients) {
1068
+ const contextEntry = entry.encryption.recipients.find((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolContext && r.header.derivedPublicKey);
1069
+ if (contextEntry === null || contextEntry === void 0 ? void 0 : contextEntry.header.derivedPublicKey) {
1063
1070
  return {
1064
- rootKeyId: contextEntry.rootKeyId,
1065
- derivedPublicKey: contextEntry.derivedPublicKey,
1071
+ rootKeyId: contextEntry.header.kid,
1072
+ derivedPublicKey: contextEntry.header.derivedPublicKey,
1066
1073
  };
1067
1074
  }
1068
1075
  }
@@ -1072,7 +1079,7 @@ export class AgentDwnApi {
1072
1079
  }
1073
1080
  /**
1074
1081
  * Reactively upgrades an externally-authored root record that has only
1075
- * ProtocolPath encryption by appending a ProtocolContext keyEncryption entry.
1082
+ * ProtocolPath encryption by appending a ProtocolContext recipient entry.
1076
1083
  *
1077
1084
  * After the upgrade, both the owner (ProtocolPath) and context key holders —
1078
1085
  * including the external author (ProtocolContext) — can decrypt the record.
@@ -1081,7 +1088,7 @@ export class AgentDwnApi {
1081
1088
  * 1. Decrypt the DEK using the owner's ProtocolPath-derived private key
1082
1089
  * 2. Derive the context public key from the owner's #enc key
1083
1090
  * 3. ECIES-encrypt the same DEK to the context public key
1084
- * 4. Append the ProtocolContext keyEncryption entry (using PR 0b append mode)
1091
+ * 4. Append the ProtocolContext recipient entry (using PR 0b append mode)
1085
1092
  * 5. Re-sign the record as owner
1086
1093
  *
1087
1094
  * The author's signature payload includes an `encryptionCid` that becomes
@@ -1106,32 +1113,32 @@ export class AgentDwnApi {
1106
1113
  return;
1107
1114
  }
1108
1115
  // 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);
1116
+ const hasProtocolPath = encryption.recipients.some((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolPath);
1117
+ const hasProtocolContext = encryption.recipients.some((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolContext);
1111
1118
  if (!hasProtocolPath || hasProtocolContext) {
1112
1119
  return;
1113
1120
  }
1114
1121
  // 1. Decrypt the DEK using the owner's ProtocolPath key
1115
1122
  const keyDecrypter = yield this.getKeyDecrypter(tenantDid);
1116
- // Find the ProtocolPath keyEncryption entry
1117
- const pathEntry = encryption.keyEncryption.find((k) => k.derivationScheme === KeyDerivationScheme.ProtocolPath);
1123
+ // Find the ProtocolPath recipient entry
1124
+ const pathRecipient = encryption.recipients.find((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolPath);
1118
1125
  const fullDerivationPath = Records.constructKeyDerivationPathUsingProtocolPathScheme(recordsWrite.descriptor);
1119
1126
  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),
1127
+ encryptedKey: Encoder.base64UrlToBytes(pathRecipient.encrypted_key),
1128
+ ephemeralPublicKey: pathRecipient.header.epk,
1124
1129
  });
1125
1130
  // 2. Derive the context public key — contextId = recordId for root records
1126
1131
  const contextId = recordsWrite.recordId;
1127
- const encryptionIV = Encoder.base64UrlToBytes(encryption.initializationVector);
1128
- // 3 & 4. Append the ProtocolContext keyEncryption entry using append mode.
1132
+ const encryptionIV = Encoder.base64UrlToBytes(encryption.iv);
1133
+ // 3 & 4. Append the ProtocolContext recipient entry using append mode.
1129
1134
  // Append mode preserves the author's identity and authorization so that
1130
1135
  // signAsOwner() can be called in step 5.
1131
1136
  const { encryptionInput: contextEncryptionInput, keyId, keyUri, contextDerivationPath } = yield this.deriveContextEncryptionInput(tenantDid, contextId, dataEncryptionKey, encryptionIV);
1137
+ // Set the authentication tag from the existing JWE encryption property
1138
+ const fullContextInput = Object.assign(Object.assign({}, contextEncryptionInput), { authenticationTag: Encoder.base64UrlToBytes(encryption.tag) });
1132
1139
  // Parse the message to get a RecordsWrite instance we can mutate
1133
1140
  const recordsWriteInstance = yield dwnMessageConstructors[DwnInterface.RecordsWrite].parse(recordsWrite);
1134
- yield recordsWriteInstance.encryptSymmetricEncryptionKey(contextEncryptionInput, { append: true });
1141
+ yield recordsWriteInstance.encryptSymmetricEncryptionKey(fullContextInput, { append: true });
1135
1142
  // 5. Re-sign as owner — the author's signature is preserved but its
1136
1143
  // encryptionCid is now stale; the owner's signature vouches for the
1137
1144
  // updated encryption property.
@@ -1145,29 +1152,37 @@ export class AgentDwnApi {
1145
1152
  // We must also update the state index and event stream to keep sync and
1146
1153
  // real-time subscribers consistent — without this, the upgraded record
1147
1154
  // 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;
1155
+ const { messageStore, stateIndex, eventStream } = this._dwn.storage;
1156
+ // Validate the upgrade only changed encryption and authorization fields.
1157
+ // The descriptor, recordId, contextId, and data must remain identical.
1158
+ // Note: parse() may produce a new descriptor object, so we compare by value.
1159
+ const upgradedMessage = recordsWriteInstance.message;
1160
+ if (JSON.stringify(upgradedMessage.descriptor) !== JSON.stringify(recordsWrite.descriptor)) {
1161
+ throw new Error('AgentDwnApi: upgradeExternalRootRecord() must not modify the descriptor.');
1162
+ }
1163
+ if (upgradedMessage.recordId !== recordsWrite.recordId) {
1164
+ throw new Error('AgentDwnApi: upgradeExternalRootRecord() must not modify the recordId.');
1165
+ }
1152
1166
  // Fetch the stored original (which carries encodedData for small payloads)
1153
1167
  const originalCid = yield Message.getCid(recordsWrite);
1154
1168
  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
1169
  // Build indexes for the upgraded message (mark as latest base state)
1159
1170
  const isLatestBaseState = true;
1160
1171
  const upgradedIndexes = yield recordsWriteInstance.constructIndexes(isLatestBaseState);
1161
1172
  // Carry over the encoded data from the stored original (the handler
1162
1173
  // base64url-encodes small payloads into encodedData during processMessage)
1163
- const upgradedMessage = recordsWriteInstance.message;
1164
1174
  if (storedOriginal === null || storedOriginal === void 0 ? void 0 : storedOriginal.encodedData) {
1165
1175
  upgradedMessage.encodedData = storedOriginal.encodedData;
1166
1176
  }
1167
- // Store the upgraded message and insert into state index
1168
- yield messageStore.put(tenantDid, upgradedMessage, upgradedIndexes);
1177
+ // Use put-before-delete ordering: if a crash occurs after the put but
1178
+ // before the delete, we end up with a duplicate (recoverable via the
1179
+ // isLatestBaseState index) rather than data loss (unrecoverable).
1169
1180
  const upgradedCid = yield Message.getCid(upgradedMessage);
1181
+ yield messageStore.put(tenantDid, upgradedMessage, upgradedIndexes);
1170
1182
  yield stateIndex.insert(tenantDid, upgradedCid, upgradedIndexes);
1183
+ // Now remove the original message and its state index entry.
1184
+ yield messageStore.delete(tenantDid, originalCid);
1185
+ yield stateIndex.delete(tenantDid, [originalCid]);
1171
1186
  // Notify real-time subscribers (mirrors handler behavior)
1172
1187
  if (eventStream !== undefined) {
1173
1188
  eventStream.emit(tenantDid, { message: upgradedMessage }, upgradedIndexes);
@@ -1188,17 +1203,17 @@ export class AgentDwnApi {
1188
1203
  return __awaiter(this, void 0, void 0, function* () {
1189
1204
  const { encryption } = recordsWrite;
1190
1205
  // 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);
1206
+ const hasContextKey = encryption === null || encryption === void 0 ? void 0 : encryption.recipients.some((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolContext);
1192
1207
  if (!hasContextKey || !recordsWrite.contextId) {
1193
1208
  // Single-party protocol-path encryption
1194
1209
  return this.getKeyDecrypter(authorDid);
1195
1210
  }
1196
1211
  // --- Multi-party context encryption ---
1197
- const contextKeyEntry = encryption.keyEncryption.find((k) => k.derivationScheme === KeyDerivationScheme.ProtocolContext);
1212
+ const contextKeyEntry = encryption.recipients.find((r) => r.header.derivationScheme === KeyDerivationScheme.ProtocolContext);
1198
1213
  const rootContextId = recordsWrite.contextId.split('/')[0];
1199
1214
  // Case 1: I am the context creator — rootKeyId matches my encryption key
1200
1215
  const { keyId, keyUri } = yield this.getEncryptionKeyInfo(authorDid);
1201
- if (contextKeyEntry.rootKeyId === keyId) {
1216
+ if (contextKeyEntry.header.kid === keyId) {
1202
1217
  return this.buildKmsDecryptCallback(keyId, keyUri, KeyDerivationScheme.ProtocolContext);
1203
1218
  }
1204
1219
  // Case 2: I am a participant — fetch my context key from the key-delivery protocol
@@ -1246,15 +1261,10 @@ export class AgentDwnApi {
1246
1261
  return {
1247
1262
  rootKeyId: contextKey.rootKeyId,
1248
1263
  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
- });
1264
+ decrypt: (fullDerivationPath, jwePayload) => __awaiter(this, void 0, void 0, function* () {
1265
+ const leafPrivateKeyBytes = yield Records.derivePrivateKey(contextKey, fullDerivationPath);
1266
+ const leafPrivateKeyJwk = yield X25519.bytesToPrivateKey({ privateKeyBytes: leafPrivateKeyBytes });
1267
+ return Encryption.ecdhEsUnwrapKey(leafPrivateKeyJwk, jwePayload.ephemeralPublicKey, jwePayload.encryptedKey);
1258
1268
  }),
1259
1269
  };
1260
1270
  }
@@ -1414,10 +1424,11 @@ export class AgentDwnApi {
1414
1424
  // --- Encrypt to the recipient's ProtocolPath key (cross-DWN delivery) ---
1415
1425
  // Manually build encryption input targeting the recipient's key so the
1416
1426
  // record is decryptable only by the recipient.
1427
+ const algorithm = ContentEncryptionAlgorithm.A256GCM;
1417
1428
  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);
1429
+ const dataEncryptionIV = crypto.getRandomValues(new Uint8Array(AgentDwnApi.ivLength(algorithm)));
1430
+ const { encryptedBytes, dataCid, dataSize, authenticationTag } = yield this.encryptAndComputeCid(plaintextBytes, dataEncryptionKey, dataEncryptionIV, algorithm);
1431
+ const encryptionInput = Object.assign(Object.assign({}, this.buildEncryptionInput(dataEncryptionKey, dataEncryptionIV, recipientKeyDeliveryPublicKey.rootKeyId, recipientKeyDeliveryPublicKey.publicKeyJwk, KeyDerivationScheme.ProtocolPath)), { authenticationTag });
1421
1432
  ({ message, reply: { status } } = yield this.processRequest({
1422
1433
  author: tenantDid,
1423
1434
  target: tenantDid,