@enbox/dwn-sdk-js 0.0.5 → 0.0.7

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 (363) hide show
  1. package/dist/browser.mjs +8 -8
  2. package/dist/browser.mjs.map +4 -4
  3. package/dist/esm/generated/precompiled-validators.js +1 -2
  4. package/dist/esm/generated/precompiled-validators.js.map +1 -1
  5. package/dist/esm/src/core/abstract-message.js +4 -0
  6. package/dist/esm/src/core/abstract-message.js.map +1 -1
  7. package/dist/esm/src/core/auth.js +22 -33
  8. package/dist/esm/src/core/auth.js.map +1 -1
  9. package/dist/esm/src/core/dwn-constant.js +7 -7
  10. package/dist/esm/src/core/dwn-constant.js.map +1 -1
  11. package/dist/esm/src/core/dwn-error.js +1 -0
  12. package/dist/esm/src/core/dwn-error.js.map +1 -1
  13. package/dist/esm/src/core/grant-authorization.js +37 -52
  14. package/dist/esm/src/core/grant-authorization.js.map +1 -1
  15. package/dist/esm/src/core/message.js +85 -116
  16. package/dist/esm/src/core/message.js.map +1 -1
  17. package/dist/esm/src/core/messages-grant-authorization.js +63 -78
  18. package/dist/esm/src/core/messages-grant-authorization.js.map +1 -1
  19. package/dist/esm/src/core/protocol-authorization-action.js +266 -0
  20. package/dist/esm/src/core/protocol-authorization-action.js.map +1 -0
  21. package/dist/esm/src/core/protocol-authorization-validation.js +254 -0
  22. package/dist/esm/src/core/protocol-authorization-validation.js.map +1 -0
  23. package/dist/esm/src/core/protocol-authorization.js +122 -740
  24. package/dist/esm/src/core/protocol-authorization.js.map +1 -1
  25. package/dist/esm/src/core/protocols-grant-authorization.js +24 -38
  26. package/dist/esm/src/core/protocols-grant-authorization.js.map +1 -1
  27. package/dist/esm/src/core/record-chain.js +64 -0
  28. package/dist/esm/src/core/record-chain.js.map +1 -0
  29. package/dist/esm/src/core/records-grant-authorization.js +55 -72
  30. package/dist/esm/src/core/records-grant-authorization.js.map +1 -1
  31. package/dist/esm/src/core/resumable-task-manager.js +50 -65
  32. package/dist/esm/src/core/resumable-task-manager.js.map +1 -1
  33. package/dist/esm/src/core/tenant-gate.js +2 -13
  34. package/dist/esm/src/core/tenant-gate.js.map +1 -1
  35. package/dist/esm/src/dwn.js +69 -86
  36. package/dist/esm/src/dwn.js.map +1 -1
  37. package/dist/esm/src/event-stream/event-emitter-stream.js +17 -31
  38. package/dist/esm/src/event-stream/event-emitter-stream.js.map +1 -1
  39. package/dist/esm/src/handlers/messages-read.js +67 -77
  40. package/dist/esm/src/handlers/messages-read.js.map +1 -1
  41. package/dist/esm/src/handlers/messages-subscribe.js +51 -61
  42. package/dist/esm/src/handlers/messages-subscribe.js.map +1 -1
  43. package/dist/esm/src/handlers/messages-sync.js +75 -85
  44. package/dist/esm/src/handlers/messages-sync.js.map +1 -1
  45. package/dist/esm/src/handlers/protocols-configure.js +135 -155
  46. package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
  47. package/dist/esm/src/handlers/protocols-query.js +52 -51
  48. package/dist/esm/src/handlers/protocols-query.js.map +1 -1
  49. package/dist/esm/src/handlers/records-count.js +96 -82
  50. package/dist/esm/src/handlers/records-count.js.map +1 -1
  51. package/dist/esm/src/handlers/records-delete.js +78 -88
  52. package/dist/esm/src/handlers/records-delete.js.map +1 -1
  53. package/dist/esm/src/handlers/records-query.js +116 -101
  54. package/dist/esm/src/handlers/records-query.js.map +1 -1
  55. package/dist/esm/src/handlers/records-read.js +124 -131
  56. package/dist/esm/src/handlers/records-read.js.map +1 -1
  57. package/dist/esm/src/handlers/records-subscribe.js +150 -103
  58. package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
  59. package/dist/esm/src/handlers/records-write.js +250 -259
  60. package/dist/esm/src/handlers/records-write.js.map +1 -1
  61. package/dist/esm/src/interfaces/messages-read.js +24 -32
  62. package/dist/esm/src/interfaces/messages-read.js.map +1 -1
  63. package/dist/esm/src/interfaces/messages-subscribe.js +27 -41
  64. package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -1
  65. package/dist/esm/src/interfaces/messages-sync.js +26 -40
  66. package/dist/esm/src/interfaces/messages-sync.js.map +1 -1
  67. package/dist/esm/src/interfaces/protocols-configure.js +63 -63
  68. package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
  69. package/dist/esm/src/interfaces/protocols-query.js +55 -68
  70. package/dist/esm/src/interfaces/protocols-query.js.map +1 -1
  71. package/dist/esm/src/interfaces/records-count.js +50 -66
  72. package/dist/esm/src/interfaces/records-count.js.map +1 -1
  73. package/dist/esm/src/interfaces/records-delete.js +45 -55
  74. package/dist/esm/src/interfaces/records-delete.js.map +1 -1
  75. package/dist/esm/src/interfaces/records-query.js +60 -76
  76. package/dist/esm/src/interfaces/records-query.js.map +1 -1
  77. package/dist/esm/src/interfaces/records-read.js +51 -67
  78. package/dist/esm/src/interfaces/records-read.js.map +1 -1
  79. package/dist/esm/src/interfaces/records-subscribe.js +52 -68
  80. package/dist/esm/src/interfaces/records-subscribe.js.map +1 -1
  81. package/dist/esm/src/interfaces/records-write-query.js +102 -0
  82. package/dist/esm/src/interfaces/records-write-query.js.map +1 -0
  83. package/dist/esm/src/interfaces/records-write-signing.js +92 -0
  84. package/dist/esm/src/interfaces/records-write-signing.js.map +1 -0
  85. package/dist/esm/src/interfaces/records-write.js +407 -602
  86. package/dist/esm/src/interfaces/records-write.js.map +1 -1
  87. package/dist/esm/src/jose/algorithms/signing/ed25519.js +10 -19
  88. package/dist/esm/src/jose/algorithms/signing/ed25519.js.map +1 -1
  89. package/dist/esm/src/jose/jws/general/builder.js +23 -35
  90. package/dist/esm/src/jose/jws/general/builder.js.map +1 -1
  91. package/dist/esm/src/jose/jws/general/verifier.js +56 -69
  92. package/dist/esm/src/jose/jws/general/verifier.js.map +1 -1
  93. package/dist/esm/src/protocols/permission-grant.js +44 -15
  94. package/dist/esm/src/protocols/permission-grant.js.map +1 -1
  95. package/dist/esm/src/protocols/permission-request.js +29 -15
  96. package/dist/esm/src/protocols/permission-request.js.map +1 -1
  97. package/dist/esm/src/protocols/permissions.js +216 -226
  98. package/dist/esm/src/protocols/permissions.js.map +1 -1
  99. package/dist/esm/src/smt/smt-store-level.js +42 -64
  100. package/dist/esm/src/smt/smt-store-level.js.map +1 -1
  101. package/dist/esm/src/smt/smt-store-memory.js +19 -45
  102. package/dist/esm/src/smt/smt-store-memory.js.map +1 -1
  103. package/dist/esm/src/smt/smt-utils.js +28 -45
  104. package/dist/esm/src/smt/smt-utils.js.map +1 -1
  105. package/dist/esm/src/smt/sparse-merkle-tree.js +426 -471
  106. package/dist/esm/src/smt/sparse-merkle-tree.js.map +1 -1
  107. package/dist/esm/src/state-index/state-index-level.js +115 -150
  108. package/dist/esm/src/state-index/state-index-level.js.map +1 -1
  109. package/dist/esm/src/store/blockstore-level.js +54 -156
  110. package/dist/esm/src/store/blockstore-level.js.map +1 -1
  111. package/dist/esm/src/store/blockstore-mock.js +48 -153
  112. package/dist/esm/src/store/blockstore-mock.js.map +1 -1
  113. package/dist/esm/src/store/data-store-level.js +59 -99
  114. package/dist/esm/src/store/data-store-level.js.map +1 -1
  115. package/dist/esm/src/store/index-level-compound.js +246 -0
  116. package/dist/esm/src/store/index-level-compound.js.map +1 -0
  117. package/dist/esm/src/store/index-level.js +295 -713
  118. package/dist/esm/src/store/index-level.js.map +1 -1
  119. package/dist/esm/src/store/level-wrapper.js +143 -244
  120. package/dist/esm/src/store/level-wrapper.js.map +1 -1
  121. package/dist/esm/src/store/message-store-level.js +71 -94
  122. package/dist/esm/src/store/message-store-level.js.map +1 -1
  123. package/dist/esm/src/store/resumable-task-store-level.js +62 -101
  124. package/dist/esm/src/store/resumable-task-store-level.js.map +1 -1
  125. package/dist/esm/src/store/storage-controller.js +129 -144
  126. package/dist/esm/src/store/storage-controller.js.map +1 -1
  127. package/dist/esm/src/utils/abort.js +8 -19
  128. package/dist/esm/src/utils/abort.js.map +1 -1
  129. package/dist/esm/src/utils/array.js +15 -49
  130. package/dist/esm/src/utils/array.js.map +1 -1
  131. package/dist/esm/src/utils/cid.js +29 -77
  132. package/dist/esm/src/utils/cid.js.map +1 -1
  133. package/dist/esm/src/utils/data-stream.js +37 -65
  134. package/dist/esm/src/utils/data-stream.js.map +1 -1
  135. package/dist/esm/src/utils/encryption.js +136 -162
  136. package/dist/esm/src/utils/encryption.js.map +1 -1
  137. package/dist/esm/src/utils/filter.js +1 -12
  138. package/dist/esm/src/utils/filter.js.map +1 -1
  139. package/dist/esm/src/utils/hd-key.js +45 -63
  140. package/dist/esm/src/utils/hd-key.js.map +1 -1
  141. package/dist/esm/src/utils/jws.js +9 -20
  142. package/dist/esm/src/utils/jws.js.map +1 -1
  143. package/dist/esm/src/utils/memory-cache.js +12 -23
  144. package/dist/esm/src/utils/memory-cache.js.map +1 -1
  145. package/dist/esm/src/utils/messages.js +9 -3
  146. package/dist/esm/src/utils/messages.js.map +1 -1
  147. package/dist/esm/src/utils/private-key-signer.js +9 -17
  148. package/dist/esm/src/utils/private-key-signer.js.map +1 -1
  149. package/dist/esm/src/utils/protocols.js +62 -70
  150. package/dist/esm/src/utils/protocols.js.map +1 -1
  151. package/dist/esm/src/utils/records.js +108 -140
  152. package/dist/esm/src/utils/records.js.map +1 -1
  153. package/dist/esm/src/utils/secp256k1.js +60 -96
  154. package/dist/esm/src/utils/secp256k1.js.map +1 -1
  155. package/dist/esm/src/utils/secp256r1.js +54 -71
  156. package/dist/esm/src/utils/secp256r1.js.map +1 -1
  157. package/dist/esm/src/utils/time.js +5 -18
  158. package/dist/esm/src/utils/time.js.map +1 -1
  159. package/dist/esm/src/utils/url.js +3 -3
  160. package/dist/esm/src/utils/url.js.map +1 -1
  161. package/dist/esm/tests/core/auth.spec.js +3 -12
  162. package/dist/esm/tests/core/auth.spec.js.map +1 -1
  163. package/dist/esm/tests/core/message.spec.js +50 -59
  164. package/dist/esm/tests/core/message.spec.js.map +1 -1
  165. package/dist/esm/tests/core/protocol-authorization.spec.js +9 -18
  166. package/dist/esm/tests/core/protocol-authorization.spec.js.map +1 -1
  167. package/dist/esm/tests/dwn.spec.js +45 -58
  168. package/dist/esm/tests/dwn.spec.js.map +1 -1
  169. package/dist/esm/tests/event-stream/event-emitter-stream.spec.js +24 -33
  170. package/dist/esm/tests/event-stream/event-emitter-stream.spec.js.map +1 -1
  171. package/dist/esm/tests/event-stream/event-stream.spec.js +46 -55
  172. package/dist/esm/tests/event-stream/event-stream.spec.js.map +1 -1
  173. package/dist/esm/tests/features/author-delegated-grant.spec.js +326 -343
  174. package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -1
  175. package/dist/esm/tests/features/owner-delegated-grant.spec.js +153 -169
  176. package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -1
  177. package/dist/esm/tests/features/owner-signature.spec.js +67 -78
  178. package/dist/esm/tests/features/owner-signature.spec.js.map +1 -1
  179. package/dist/esm/tests/features/permissions.spec.js +446 -181
  180. package/dist/esm/tests/features/permissions.spec.js.map +1 -1
  181. package/dist/esm/tests/features/protocol-composition.spec.js +346 -356
  182. package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
  183. package/dist/esm/tests/features/protocol-create-action.spec.js +42 -51
  184. package/dist/esm/tests/features/protocol-create-action.spec.js.map +1 -1
  185. package/dist/esm/tests/features/protocol-delete-action.spec.js +94 -103
  186. package/dist/esm/tests/features/protocol-delete-action.spec.js.map +1 -1
  187. package/dist/esm/tests/features/protocol-update-action.spec.js +105 -114
  188. package/dist/esm/tests/features/protocol-update-action.spec.js.map +1 -1
  189. package/dist/esm/tests/features/records-prune.spec.js +175 -191
  190. package/dist/esm/tests/features/records-prune.spec.js.map +1 -1
  191. package/dist/esm/tests/features/records-tags.spec.js +441 -460
  192. package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
  193. package/dist/esm/tests/features/resumable-tasks.spec.js +82 -91
  194. package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -1
  195. package/dist/esm/tests/handlers/messages-read.spec.js +206 -207
  196. package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -1
  197. package/dist/esm/tests/handlers/messages-subscribe.spec.js +145 -154
  198. package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -1
  199. package/dist/esm/tests/handlers/messages-sync.spec.js +174 -183
  200. package/dist/esm/tests/handlers/messages-sync.spec.js.map +1 -1
  201. package/dist/esm/tests/handlers/protocols-configure.spec.js +244 -238
  202. package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -1
  203. package/dist/esm/tests/handlers/protocols-query.spec.js +156 -169
  204. package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -1
  205. package/dist/esm/tests/handlers/records-count.spec.js +93 -102
  206. package/dist/esm/tests/handlers/records-count.spec.js.map +1 -1
  207. package/dist/esm/tests/handlers/records-delete.spec.js +252 -264
  208. package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
  209. package/dist/esm/tests/handlers/records-query.spec.js +917 -988
  210. package/dist/esm/tests/handlers/records-query.spec.js.map +1 -1
  211. package/dist/esm/tests/handlers/records-read.spec.js +553 -568
  212. package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
  213. package/dist/esm/tests/handlers/records-subscribe.spec.js +269 -278
  214. package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
  215. package/dist/esm/tests/handlers/records-write.spec.js +1057 -1082
  216. package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
  217. package/dist/esm/tests/interfaces/messages-get.spec.js +39 -48
  218. package/dist/esm/tests/interfaces/messages-get.spec.js.map +1 -1
  219. package/dist/esm/tests/interfaces/messages-subscribe.spec.js +4 -13
  220. package/dist/esm/tests/interfaces/messages-subscribe.spec.js.map +1 -1
  221. package/dist/esm/tests/interfaces/protocols-configure.spec.js +212 -88
  222. package/dist/esm/tests/interfaces/protocols-configure.spec.js.map +1 -1
  223. package/dist/esm/tests/interfaces/protocols-query.spec.js +8 -17
  224. package/dist/esm/tests/interfaces/protocols-query.spec.js.map +1 -1
  225. package/dist/esm/tests/interfaces/records-delete.spec.js +8 -17
  226. package/dist/esm/tests/interfaces/records-delete.spec.js.map +1 -1
  227. package/dist/esm/tests/interfaces/records-query.spec.js +20 -29
  228. package/dist/esm/tests/interfaces/records-query.spec.js.map +1 -1
  229. package/dist/esm/tests/interfaces/records-read.spec.js +42 -51
  230. package/dist/esm/tests/interfaces/records-read.spec.js.map +1 -1
  231. package/dist/esm/tests/interfaces/records-subscribe.spec.js +16 -25
  232. package/dist/esm/tests/interfaces/records-subscribe.spec.js.map +1 -1
  233. package/dist/esm/tests/interfaces/records-write.spec.js +152 -165
  234. package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
  235. package/dist/esm/tests/jose/jws/general.spec.js +36 -45
  236. package/dist/esm/tests/jose/jws/general.spec.js.map +1 -1
  237. package/dist/esm/tests/protocols/permission-grant.spec.js +44 -50
  238. package/dist/esm/tests/protocols/permission-grant.spec.js.map +1 -1
  239. package/dist/esm/tests/protocols/permission-request.spec.js +23 -32
  240. package/dist/esm/tests/protocols/permission-request.spec.js.map +1 -1
  241. package/dist/esm/tests/protocols/permissions.spec.js +49 -55
  242. package/dist/esm/tests/protocols/permissions.spec.js.map +1 -1
  243. package/dist/esm/tests/scenarios/aggregator.spec.js +124 -135
  244. package/dist/esm/tests/scenarios/aggregator.spec.js.map +1 -1
  245. package/dist/esm/tests/scenarios/deleted-record.spec.js +23 -32
  246. package/dist/esm/tests/scenarios/deleted-record.spec.js.map +1 -1
  247. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +52 -61
  248. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
  249. package/dist/esm/tests/scenarios/nested-roles.spec.js +63 -73
  250. package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -1
  251. package/dist/esm/tests/scenarios/subscriptions.spec.js +377 -333
  252. package/dist/esm/tests/scenarios/subscriptions.spec.js.map +1 -1
  253. package/dist/esm/tests/smt/smt-store-level.spec.js +76 -87
  254. package/dist/esm/tests/smt/smt-store-level.spec.js.map +1 -1
  255. package/dist/esm/tests/smt/sparse-merkle-tree.spec.js +344 -353
  256. package/dist/esm/tests/smt/sparse-merkle-tree.spec.js.map +1 -1
  257. package/dist/esm/tests/state-index/state-index-level.spec.js +117 -126
  258. package/dist/esm/tests/state-index/state-index-level.spec.js.map +1 -1
  259. package/dist/esm/tests/store/blockstore-level.spec.js +44 -99
  260. package/dist/esm/tests/store/blockstore-level.spec.js.map +1 -1
  261. package/dist/esm/tests/store/blockstore-mock.spec.js +40 -120
  262. package/dist/esm/tests/store/blockstore-mock.spec.js.map +1 -1
  263. package/dist/esm/tests/store/data-store-level.spec.js +86 -95
  264. package/dist/esm/tests/store/data-store-level.spec.js.map +1 -1
  265. package/dist/esm/tests/store/index-level.spec.js +404 -414
  266. package/dist/esm/tests/store/index-level.spec.js.map +1 -1
  267. package/dist/esm/tests/store/message-store-level.spec.js +13 -22
  268. package/dist/esm/tests/store/message-store-level.spec.js.map +1 -1
  269. package/dist/esm/tests/store/message-store.spec.js +229 -238
  270. package/dist/esm/tests/store/message-store.spec.js.map +1 -1
  271. package/dist/esm/tests/test-event-stream.js +3 -3
  272. package/dist/esm/tests/test-event-stream.js.map +1 -1
  273. package/dist/esm/tests/test-stores.js +16 -13
  274. package/dist/esm/tests/test-stores.js.map +1 -1
  275. package/dist/esm/tests/test-suite.js +2 -11
  276. package/dist/esm/tests/test-suite.js.map +1 -1
  277. package/dist/esm/tests/utils/cid.spec.js +24 -33
  278. package/dist/esm/tests/utils/cid.spec.js.map +1 -1
  279. package/dist/esm/tests/utils/data-stream.spec.js +48 -57
  280. package/dist/esm/tests/utils/data-stream.spec.js.map +1 -1
  281. package/dist/esm/tests/utils/encryption-callbacks.spec.js +45 -54
  282. package/dist/esm/tests/utils/encryption-callbacks.spec.js.map +1 -1
  283. package/dist/esm/tests/utils/encryption.spec.js +291 -44
  284. package/dist/esm/tests/utils/encryption.spec.js.map +1 -1
  285. package/dist/esm/tests/utils/filters.spec.js +46 -55
  286. package/dist/esm/tests/utils/filters.spec.js.map +1 -1
  287. package/dist/esm/tests/utils/hd-key.spec.js +10 -19
  288. package/dist/esm/tests/utils/hd-key.spec.js.map +1 -1
  289. package/dist/esm/tests/utils/jws.spec.js +3 -12
  290. package/dist/esm/tests/utils/jws.spec.js.map +1 -1
  291. package/dist/esm/tests/utils/memory-cache.spec.js +9 -18
  292. package/dist/esm/tests/utils/memory-cache.spec.js.map +1 -1
  293. package/dist/esm/tests/utils/messages.spec.js +6 -15
  294. package/dist/esm/tests/utils/messages.spec.js.map +1 -1
  295. package/dist/esm/tests/utils/poller.js +22 -33
  296. package/dist/esm/tests/utils/poller.js.map +1 -1
  297. package/dist/esm/tests/utils/private-key-signer.spec.js +15 -24
  298. package/dist/esm/tests/utils/private-key-signer.spec.js.map +1 -1
  299. package/dist/esm/tests/utils/records.spec.js +10 -19
  300. package/dist/esm/tests/utils/records.spec.js.map +1 -1
  301. package/dist/esm/tests/utils/secp256k1.spec.js +16 -25
  302. package/dist/esm/tests/utils/secp256k1.spec.js.map +1 -1
  303. package/dist/esm/tests/utils/secp256r1.spec.js +18 -27
  304. package/dist/esm/tests/utils/secp256r1.spec.js.map +1 -1
  305. package/dist/esm/tests/utils/test-data-generator.js +414 -468
  306. package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
  307. package/dist/esm/tests/validation/json-schemas/definitions.spec.js +2 -11
  308. package/dist/esm/tests/validation/json-schemas/definitions.spec.js.map +1 -1
  309. package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js +4 -13
  310. package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js.map +1 -1
  311. package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js +8 -17
  312. package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js.map +1 -1
  313. package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js +3 -12
  314. package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js.map +1 -1
  315. package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js +4 -13
  316. package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js.map +1 -1
  317. package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js +2 -11
  318. package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js.map +1 -1
  319. package/dist/esm/tests/validation/json-schemas/records/records-read.spec.js +2 -11
  320. package/dist/esm/tests/validation/json-schemas/records/records-read.spec.js.map +1 -1
  321. package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js +7 -16
  322. package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js.map +1 -1
  323. package/dist/types/src/core/protocol-authorization-action.d.ts +42 -0
  324. package/dist/types/src/core/protocol-authorization-action.d.ts.map +1 -0
  325. package/dist/types/src/core/protocol-authorization-validation.d.ts +60 -0
  326. package/dist/types/src/core/protocol-authorization-validation.d.ts.map +1 -0
  327. package/dist/types/src/core/protocol-authorization.d.ts +10 -100
  328. package/dist/types/src/core/protocol-authorization.d.ts.map +1 -1
  329. package/dist/types/src/core/record-chain.d.ts +24 -0
  330. package/dist/types/src/core/record-chain.d.ts.map +1 -0
  331. package/dist/types/src/handlers/records-write.d.ts +2 -1
  332. package/dist/types/src/handlers/records-write.d.ts.map +1 -1
  333. package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -1
  334. package/dist/types/src/interfaces/records-write-query.d.ts +33 -0
  335. package/dist/types/src/interfaces/records-write-query.d.ts.map +1 -0
  336. package/dist/types/src/interfaces/records-write-signing.d.ts +35 -0
  337. package/dist/types/src/interfaces/records-write-signing.d.ts.map +1 -0
  338. package/dist/types/src/interfaces/records-write.d.ts +10 -44
  339. package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
  340. package/dist/types/src/store/index-level-compound.d.ts +70 -0
  341. package/dist/types/src/store/index-level-compound.d.ts.map +1 -0
  342. package/dist/types/src/store/index-level.d.ts +0 -58
  343. package/dist/types/src/store/index-level.d.ts.map +1 -1
  344. package/dist/types/src/utils/protocols.d.ts +5 -0
  345. package/dist/types/src/utils/protocols.d.ts.map +1 -1
  346. package/dist/types/src/utils/records.d.ts +3 -1
  347. package/dist/types/src/utils/records.d.ts.map +1 -1
  348. package/dist/types/tests/features/permissions.spec.d.ts.map +1 -1
  349. package/package.json +3 -3
  350. package/src/core/protocol-authorization-action.ts +377 -0
  351. package/src/core/protocol-authorization-validation.ts +391 -0
  352. package/src/core/protocol-authorization.ts +60 -849
  353. package/src/core/record-chain.ts +99 -0
  354. package/src/handlers/records-read.ts +1 -1
  355. package/src/handlers/records-write.ts +37 -21
  356. package/src/interfaces/protocols-configure.ts +33 -5
  357. package/src/interfaces/records-write-query.ts +139 -0
  358. package/src/interfaces/records-write-signing.ts +143 -0
  359. package/src/interfaces/records-write.ts +49 -221
  360. package/src/store/index-level-compound.ts +324 -0
  361. package/src/store/index-level.ts +24 -306
  362. package/src/utils/protocols.ts +8 -0
  363. package/src/utils/records.ts +9 -15
@@ -1,79 +1,143 @@
1
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
- return new (P || (P = Promise))(function (resolve, reject) {
4
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
- step((generator = generator.apply(thisArg, _arguments || [])).next());
8
- });
9
- };
10
1
  import { ArrayUtility } from '../../src/utils/array.js';
11
2
  import { DataStream } from '../../src/index.js';
3
+ import { DwnErrorCode } from '../../src/core/dwn-error.js';
4
+ import { Encoder } from '../../src/utils/encoder.js';
5
+ import { KeyDerivationScheme } from '../../src/utils/hd-key.js';
6
+ import { Records } from '../../src/utils/records.js';
12
7
  import { TestDataGenerator } from './test-data-generator.js';
13
8
  import { X25519 } from '@enbox/crypto';
14
9
  import { ContentEncryptionAlgorithm, Encryption } from '../../src/utils/encryption.js';
15
10
  import { describe, expect, it } from 'bun:test';
11
+ /** Boundary sizes that exercise edge cases in AEAD ciphers. */
12
+ const boundarySizes = [0, 1, 15, 16, 17, 32, 256];
16
13
  describe('Encryption', () => {
17
14
  describe('AEAD A256GCM', () => {
18
- it('should be able to encrypt and decrypt data correctly', () => __awaiter(void 0, void 0, void 0, function* () {
15
+ it('should be able to encrypt and decrypt data correctly', async () => {
19
16
  const key = TestDataGenerator.randomBytes(32);
20
17
  const iv = TestDataGenerator.randomBytes(12); // 96-bit nonce for AES-GCM
21
- const inputBytes = TestDataGenerator.randomBytes(1000000);
22
- const { ciphertext, tag } = yield Encryption.aeadEncrypt(ContentEncryptionAlgorithm.A256GCM, key, iv, inputBytes);
23
- const plaintext = yield Encryption.aeadDecrypt(ContentEncryptionAlgorithm.A256GCM, key, iv, ciphertext, tag);
18
+ const inputBytes = TestDataGenerator.randomBytes(1_000_000);
19
+ const { ciphertext, tag } = await Encryption.aeadEncrypt(ContentEncryptionAlgorithm.A256GCM, key, iv, inputBytes);
20
+ const plaintext = await Encryption.aeadDecrypt(ContentEncryptionAlgorithm.A256GCM, key, iv, ciphertext, tag);
24
21
  expect(ArrayUtility.byteArraysEqual(inputBytes, plaintext)).toBe(true);
25
- }));
26
- it('should be able to encrypt and decrypt a data stream correctly', () => __awaiter(void 0, void 0, void 0, function* () {
22
+ });
23
+ it('should be able to encrypt and decrypt a data stream correctly', async () => {
27
24
  const key = TestDataGenerator.randomBytes(32);
28
25
  const iv = TestDataGenerator.randomBytes(12);
29
- const inputBytes = TestDataGenerator.randomBytes(1000000);
26
+ const inputBytes = TestDataGenerator.randomBytes(1_000_000);
30
27
  const inputStream = DataStream.fromBytes(inputBytes);
31
- const { ciphertextStream, tag } = yield Encryption.aeadEncryptStream(ContentEncryptionAlgorithm.A256GCM, key, iv, inputStream);
32
- const plaintextStream = yield Encryption.aeadDecryptStream(ContentEncryptionAlgorithm.A256GCM, key, iv, ciphertextStream, tag);
33
- const plaintextBytes = yield DataStream.toBytes(plaintextStream);
28
+ const { ciphertextStream, tag } = await Encryption.aeadEncryptStream(ContentEncryptionAlgorithm.A256GCM, key, iv, inputStream);
29
+ const plaintextStream = await Encryption.aeadDecryptStream(ContentEncryptionAlgorithm.A256GCM, key, iv, ciphertextStream, tag);
30
+ const plaintextBytes = await DataStream.toBytes(plaintextStream);
34
31
  expect(ArrayUtility.byteArraysEqual(inputBytes, plaintextBytes)).toBe(true);
35
- }));
32
+ });
33
+ it('should handle boundary plaintext sizes via byte API', async () => {
34
+ const key = TestDataGenerator.randomBytes(32);
35
+ const iv = TestDataGenerator.randomBytes(12);
36
+ for (const size of boundarySizes) {
37
+ const inputBytes = size === 0 ? new Uint8Array(0) : TestDataGenerator.randomBytes(size);
38
+ const { ciphertext, tag } = await Encryption.aeadEncrypt(ContentEncryptionAlgorithm.A256GCM, key, iv, inputBytes);
39
+ const plaintext = await Encryption.aeadDecrypt(ContentEncryptionAlgorithm.A256GCM, key, iv, ciphertext, tag);
40
+ expect(plaintext.length).toBe(size);
41
+ expect(ArrayUtility.byteArraysEqual(inputBytes, plaintext)).toBe(true);
42
+ }
43
+ });
44
+ it('should handle boundary plaintext sizes via stream API', async () => {
45
+ const key = TestDataGenerator.randomBytes(32);
46
+ const iv = TestDataGenerator.randomBytes(12);
47
+ for (const size of boundarySizes) {
48
+ const inputBytes = size === 0 ? new Uint8Array(0) : TestDataGenerator.randomBytes(size);
49
+ const inputStream = DataStream.fromBytes(inputBytes);
50
+ const { ciphertextStream, tag } = await Encryption.aeadEncryptStream(ContentEncryptionAlgorithm.A256GCM, key, iv, inputStream);
51
+ const plaintextStream = await Encryption.aeadDecryptStream(ContentEncryptionAlgorithm.A256GCM, key, iv, ciphertextStream, tag);
52
+ const plaintextBytes = await DataStream.toBytes(plaintextStream);
53
+ expect(plaintextBytes.length).toBe(size);
54
+ expect(ArrayUtility.byteArraysEqual(inputBytes, plaintextBytes)).toBe(true);
55
+ }
56
+ });
36
57
  });
37
58
  describe('AEAD XC20P', () => {
38
- it('should be able to encrypt and decrypt data correctly', () => __awaiter(void 0, void 0, void 0, function* () {
59
+ it('should be able to encrypt and decrypt data correctly', async () => {
39
60
  const key = TestDataGenerator.randomBytes(32);
40
61
  const nonce = TestDataGenerator.randomBytes(24); // 192-bit nonce for XChaCha20-Poly1305
41
- const inputBytes = TestDataGenerator.randomBytes(1000000);
42
- const { ciphertext, tag } = yield Encryption.aeadEncrypt(ContentEncryptionAlgorithm.XC20P, key, nonce, inputBytes);
43
- const plaintext = yield Encryption.aeadDecrypt(ContentEncryptionAlgorithm.XC20P, key, nonce, ciphertext, tag);
62
+ const inputBytes = TestDataGenerator.randomBytes(1_000_000);
63
+ const { ciphertext, tag } = await Encryption.aeadEncrypt(ContentEncryptionAlgorithm.XC20P, key, nonce, inputBytes);
64
+ const plaintext = await Encryption.aeadDecrypt(ContentEncryptionAlgorithm.XC20P, key, nonce, ciphertext, tag);
44
65
  expect(ArrayUtility.byteArraysEqual(inputBytes, plaintext)).toBe(true);
45
- }));
46
- it('should be able to encrypt and decrypt a data stream correctly', () => __awaiter(void 0, void 0, void 0, function* () {
66
+ });
67
+ it('should be able to encrypt and decrypt a data stream correctly', async () => {
47
68
  const key = TestDataGenerator.randomBytes(32);
48
69
  const nonce = TestDataGenerator.randomBytes(24);
49
- const inputBytes = TestDataGenerator.randomBytes(1000000);
70
+ const inputBytes = TestDataGenerator.randomBytes(1_000_000);
50
71
  const inputStream = DataStream.fromBytes(inputBytes);
51
- const { ciphertextStream, tag } = yield Encryption.aeadEncryptStream(ContentEncryptionAlgorithm.XC20P, key, nonce, inputStream);
52
- const plaintextStream = yield Encryption.aeadDecryptStream(ContentEncryptionAlgorithm.XC20P, key, nonce, ciphertextStream, tag);
53
- const plaintextBytes = yield DataStream.toBytes(plaintextStream);
72
+ const { ciphertextStream, tag } = await Encryption.aeadEncryptStream(ContentEncryptionAlgorithm.XC20P, key, nonce, inputStream);
73
+ const plaintextStream = await Encryption.aeadDecryptStream(ContentEncryptionAlgorithm.XC20P, key, nonce, ciphertextStream, tag);
74
+ const plaintextBytes = await DataStream.toBytes(plaintextStream);
54
75
  expect(ArrayUtility.byteArraysEqual(inputBytes, plaintextBytes)).toBe(true);
55
- }));
76
+ });
77
+ it('should handle boundary plaintext sizes via byte API', async () => {
78
+ const key = TestDataGenerator.randomBytes(32);
79
+ const nonce = TestDataGenerator.randomBytes(24);
80
+ for (const size of boundarySizes) {
81
+ const inputBytes = size === 0 ? new Uint8Array(0) : TestDataGenerator.randomBytes(size);
82
+ const { ciphertext, tag } = await Encryption.aeadEncrypt(ContentEncryptionAlgorithm.XC20P, key, nonce, inputBytes);
83
+ const plaintext = await Encryption.aeadDecrypt(ContentEncryptionAlgorithm.XC20P, key, nonce, ciphertext, tag);
84
+ expect(plaintext.length).toBe(size);
85
+ expect(ArrayUtility.byteArraysEqual(inputBytes, plaintext)).toBe(true);
86
+ }
87
+ });
88
+ it('should handle boundary plaintext sizes via stream API', async () => {
89
+ const key = TestDataGenerator.randomBytes(32);
90
+ const nonce = TestDataGenerator.randomBytes(24);
91
+ for (const size of boundarySizes) {
92
+ const inputBytes = size === 0 ? new Uint8Array(0) : TestDataGenerator.randomBytes(size);
93
+ const inputStream = DataStream.fromBytes(inputBytes);
94
+ const { ciphertextStream, tag } = await Encryption.aeadEncryptStream(ContentEncryptionAlgorithm.XC20P, key, nonce, inputStream);
95
+ const plaintextStream = await Encryption.aeadDecryptStream(ContentEncryptionAlgorithm.XC20P, key, nonce, ciphertextStream, tag);
96
+ const plaintextBytes = await DataStream.toBytes(plaintextStream);
97
+ expect(plaintextBytes.length).toBe(size);
98
+ expect(ArrayUtility.byteArraysEqual(inputBytes, plaintextBytes)).toBe(true);
99
+ }
100
+ });
56
101
  });
57
102
  describe('ECDH-ES+A256KW', () => {
58
- it('should be able to wrap and unwrap a CEK correctly', () => __awaiter(void 0, void 0, void 0, function* () {
59
- const recipientPrivateKey = yield X25519.generateKey();
60
- const recipientPublicKey = yield X25519.getPublicKey({ key: recipientPrivateKey });
61
- const ephemeralPrivateKey = yield X25519.generateKey();
103
+ it('should be able to wrap and unwrap a CEK correctly', async () => {
104
+ const recipientPrivateKey = await X25519.generateKey();
105
+ const recipientPublicKey = await X25519.getPublicKey({ key: recipientPrivateKey });
106
+ const ephemeralPrivateKey = await X25519.generateKey();
62
107
  const cek = TestDataGenerator.randomBytes(32);
63
- const wrappedKey = yield Encryption.ecdhEsWrapKey(ephemeralPrivateKey, recipientPublicKey, cek);
64
- const ephemeralPublicKey = yield X25519.getPublicKey({ key: ephemeralPrivateKey });
65
- const unwrappedCek = yield Encryption.ecdhEsUnwrapKey(recipientPrivateKey, ephemeralPublicKey, wrappedKey);
108
+ const wrappedKey = await Encryption.ecdhEsWrapKey(ephemeralPrivateKey, recipientPublicKey, cek);
109
+ const ephemeralPublicKey = await X25519.getPublicKey({ key: ephemeralPrivateKey });
110
+ const unwrappedCek = await Encryption.ecdhEsUnwrapKey(recipientPrivateKey, ephemeralPublicKey, wrappedKey);
66
111
  expect(ArrayUtility.byteArraysEqual(cek, unwrappedCek)).toBe(true);
67
- }));
112
+ });
113
+ it('should produce different wrapped keys for the same CEK and recipient', async () => {
114
+ const recipientPrivateKey = await X25519.generateKey();
115
+ const recipientPublicKey = await X25519.getPublicKey({ key: recipientPrivateKey });
116
+ const cek = TestDataGenerator.randomBytes(32);
117
+ // Wrap the same CEK twice with different ephemeral keys
118
+ const ephemeralKey1 = await X25519.generateKey();
119
+ const ephemeralKey2 = await X25519.generateKey();
120
+ const wrappedKey1 = await Encryption.ecdhEsWrapKey(ephemeralKey1, recipientPublicKey, cek);
121
+ const wrappedKey2 = await Encryption.ecdhEsWrapKey(ephemeralKey2, recipientPublicKey, cek);
122
+ // Different ephemeral keys must produce different wrapped keys
123
+ expect(ArrayUtility.byteArraysEqual(wrappedKey1, wrappedKey2)).toBe(false);
124
+ // Both must still unwrap to the same CEK
125
+ const epk1 = await X25519.getPublicKey({ key: ephemeralKey1 });
126
+ const epk2 = await X25519.getPublicKey({ key: ephemeralKey2 });
127
+ const unwrapped1 = await Encryption.ecdhEsUnwrapKey(recipientPrivateKey, epk1, wrappedKey1);
128
+ const unwrapped2 = await Encryption.ecdhEsUnwrapKey(recipientPrivateKey, epk2, wrappedKey2);
129
+ expect(ArrayUtility.byteArraysEqual(unwrapped1, cek)).toBe(true);
130
+ expect(ArrayUtility.byteArraysEqual(unwrapped2, cek)).toBe(true);
131
+ });
68
132
  });
69
133
  describe('buildJwe', () => {
70
- it('should build a valid JWE structure with recipients', () => __awaiter(void 0, void 0, void 0, function* () {
71
- const recipientPrivateKey = yield X25519.generateKey();
72
- const recipientPublicKey = yield X25519.getPublicKey({ key: recipientPrivateKey });
134
+ it('should build a valid JWE structure with recipients', async () => {
135
+ const recipientPrivateKey = await X25519.generateKey();
136
+ const recipientPublicKey = await X25519.getPublicKey({ key: recipientPrivateKey });
73
137
  const cek = TestDataGenerator.randomBytes(32);
74
138
  const iv = TestDataGenerator.randomBytes(12);
75
139
  const tag = TestDataGenerator.randomBytes(16);
76
- const jwe = yield Encryption.buildJwe({
140
+ const jwe = await Encryption.buildJwe({
77
141
  key: cek,
78
142
  initializationVector: iv,
79
143
  authenticationTag: tag,
@@ -94,7 +158,190 @@ describe('Encryption', () => {
94
158
  const protectedHeader = Encryption.parseProtectedHeader(jwe.protected);
95
159
  expect(protectedHeader.alg).toBe('ECDH-ES+A256KW');
96
160
  expect(protectedHeader.enc).toBe('A256GCM');
97
- }));
161
+ });
162
+ it('should produce different ephemeral keys and wrapped CEKs for identical inputs', async () => {
163
+ const recipientPrivateKey = await X25519.generateKey();
164
+ const recipientPublicKey = await X25519.getPublicKey({ key: recipientPrivateKey });
165
+ const cek = TestDataGenerator.randomBytes(32);
166
+ const iv = TestDataGenerator.randomBytes(12);
167
+ const tag = TestDataGenerator.randomBytes(16);
168
+ const encryptionInput = {
169
+ key: cek,
170
+ initializationVector: iv,
171
+ authenticationTag: tag,
172
+ keyEncryptionInputs: [{
173
+ publicKeyId: 'did:example:alice#enc',
174
+ publicKey: recipientPublicKey,
175
+ derivationScheme: 'protocolPath',
176
+ }],
177
+ };
178
+ const jwe1 = await Encryption.buildJwe(encryptionInput, tag);
179
+ const jwe2 = await Encryption.buildJwe(encryptionInput, tag);
180
+ // Each call generates a fresh ephemeral key pair — epk values must differ
181
+ const epk1 = jwe1.recipients[0].header.epk;
182
+ const epk2 = jwe2.recipients[0].header.epk;
183
+ expect(JSON.stringify(epk1)).not.toBe(JSON.stringify(epk2));
184
+ // Different ephemeral keys produce different wrapped CEKs
185
+ expect(jwe1.recipients[0].encrypted_key).not.toBe(jwe2.recipients[0].encrypted_key);
186
+ // Both wrapped CEKs must still unwrap to the same original CEK
187
+ const unwrapped1 = await Encryption.ecdhEsUnwrapKey(recipientPrivateKey, epk1, Encoder.base64UrlToBytes(jwe1.recipients[0].encrypted_key));
188
+ const unwrapped2 = await Encryption.ecdhEsUnwrapKey(recipientPrivateKey, epk2, Encoder.base64UrlToBytes(jwe2.recipients[0].encrypted_key));
189
+ expect(ArrayUtility.byteArraysEqual(unwrapped1, cek)).toBe(true);
190
+ expect(ArrayUtility.byteArraysEqual(unwrapped2, cek)).toBe(true);
191
+ });
192
+ it('should attach derivedPublicKey for ProtocolContext scheme', async () => {
193
+ const recipientPrivateKey = await X25519.generateKey();
194
+ const recipientPublicKey = await X25519.getPublicKey({ key: recipientPrivateKey });
195
+ const cek = TestDataGenerator.randomBytes(32);
196
+ const iv = TestDataGenerator.randomBytes(12);
197
+ const tag = TestDataGenerator.randomBytes(16);
198
+ const jwe = await Encryption.buildJwe({
199
+ key: cek,
200
+ initializationVector: iv,
201
+ authenticationTag: tag,
202
+ keyEncryptionInputs: [{
203
+ publicKeyId: 'did:example:alice#enc',
204
+ publicKey: recipientPublicKey,
205
+ derivationScheme: KeyDerivationScheme.ProtocolContext,
206
+ }],
207
+ }, tag);
208
+ // ProtocolContext recipients should have derivedPublicKey set to the input public key
209
+ expect(jwe.recipients).toHaveLength(1);
210
+ expect(jwe.recipients[0].header.derivedPublicKey).toBeDefined();
211
+ expect(jwe.recipients[0].header.derivedPublicKey.kty).toBe(recipientPublicKey.kty);
212
+ });
213
+ it('should not attach derivedPublicKey for non-ProtocolContext schemes', async () => {
214
+ const recipientPrivateKey = await X25519.generateKey();
215
+ const recipientPublicKey = await X25519.getPublicKey({ key: recipientPrivateKey });
216
+ const cek = TestDataGenerator.randomBytes(32);
217
+ const iv = TestDataGenerator.randomBytes(12);
218
+ const tag = TestDataGenerator.randomBytes(16);
219
+ const jwe = await Encryption.buildJwe({
220
+ key: cek,
221
+ initializationVector: iv,
222
+ authenticationTag: tag,
223
+ keyEncryptionInputs: [{
224
+ publicKeyId: 'did:example:alice#enc',
225
+ publicKey: recipientPublicKey,
226
+ derivationScheme: KeyDerivationScheme.ProtocolPath,
227
+ }],
228
+ }, tag);
229
+ // Non-ProtocolContext recipients should NOT have derivedPublicKey
230
+ expect(jwe.recipients).toHaveLength(1);
231
+ expect(jwe.recipients[0].header.derivedPublicKey).toBeUndefined();
232
+ });
233
+ });
234
+ describe('error handling', () => {
235
+ it('should throw on corrupted ciphertext (wrong tag)', async () => {
236
+ const key = TestDataGenerator.randomBytes(32);
237
+ const iv = TestDataGenerator.randomBytes(12);
238
+ const plaintext = TestDataGenerator.randomBytes(64);
239
+ const { ciphertext } = await Encryption.aeadEncrypt(ContentEncryptionAlgorithm.A256GCM, key, iv, plaintext);
240
+ // Use a wrong tag
241
+ const wrongTag = TestDataGenerator.randomBytes(16);
242
+ await expect(Encryption.aeadDecrypt(ContentEncryptionAlgorithm.A256GCM, key, iv, ciphertext, wrongTag)).rejects.toThrow();
243
+ });
244
+ it('should throw on corrupted ciphertext stream (wrong tag)', async () => {
245
+ const key = TestDataGenerator.randomBytes(32);
246
+ const iv = TestDataGenerator.randomBytes(12);
247
+ const plaintext = TestDataGenerator.randomBytes(64);
248
+ const plaintextStream = DataStream.fromBytes(plaintext);
249
+ const { ciphertextStream } = await Encryption.aeadEncryptStream(ContentEncryptionAlgorithm.A256GCM, key, iv, plaintextStream);
250
+ // Use a wrong tag to trigger decryption error
251
+ const wrongTag = TestDataGenerator.randomBytes(16);
252
+ await expect(Encryption.aeadDecryptStream(ContentEncryptionAlgorithm.A256GCM, key, iv, ciphertextStream, wrongTag)).rejects.toThrow();
253
+ });
254
+ it('should throw on decryption with wrong key', async () => {
255
+ const key = TestDataGenerator.randomBytes(32);
256
+ const wrongKey = TestDataGenerator.randomBytes(32);
257
+ const iv = TestDataGenerator.randomBytes(12);
258
+ const plaintext = TestDataGenerator.randomBytes(64);
259
+ const { ciphertext, tag } = await Encryption.aeadEncrypt(ContentEncryptionAlgorithm.A256GCM, key, iv, plaintext);
260
+ await expect(Encryption.aeadDecrypt(ContentEncryptionAlgorithm.A256GCM, wrongKey, iv, ciphertext, tag)).rejects.toThrow();
261
+ });
262
+ it('should throw for unsupported algorithm in aeadEncrypt', async () => {
263
+ const key = TestDataGenerator.randomBytes(32);
264
+ const iv = TestDataGenerator.randomBytes(12);
265
+ const plaintext = TestDataGenerator.randomBytes(64);
266
+ await expect(Encryption.aeadEncrypt('INVALID_ALG', key, iv, plaintext)).rejects.toThrow('Unsupported content encryption algorithm');
267
+ });
268
+ it('should throw for unsupported algorithm in aeadDecrypt', async () => {
269
+ const key = TestDataGenerator.randomBytes(32);
270
+ const iv = TestDataGenerator.randomBytes(12);
271
+ const ciphertext = TestDataGenerator.randomBytes(64);
272
+ const tag = TestDataGenerator.randomBytes(16);
273
+ await expect(Encryption.aeadDecrypt('INVALID_ALG', key, iv, ciphertext, tag)).rejects.toThrow('Unsupported content encryption algorithm');
274
+ });
275
+ });
276
+ describe('Records.decrypt', () => {
277
+ it('should throw when message has no encryption property', async () => {
278
+ // Create a minimal RecordsWriteMessage without encryption
279
+ const messageWithoutEncryption = {
280
+ descriptor: {
281
+ interface: 'Records',
282
+ method: 'Write',
283
+ dataCid: 'bafyreib3e4uj32nq5ql3q',
284
+ dataSize: 100,
285
+ dateCreated: '2024-01-01T00:00:00.000000Z',
286
+ messageTimestamp: '2024-01-01T00:00:00.000000Z',
287
+ dataFormat: 'application/json',
288
+ },
289
+ // no encryption property
290
+ };
291
+ const dummyKey = await X25519.generateKey();
292
+ const cipherStream = DataStream.fromBytes(TestDataGenerator.randomBytes(32));
293
+ await expect(Records.decrypt(messageWithoutEncryption, {
294
+ rootKeyId: 'did:example:alice#enc',
295
+ derivationScheme: KeyDerivationScheme.ProtocolPath,
296
+ derivedPrivateKey: dummyKey,
297
+ }, cipherStream)).rejects.toThrow(DwnErrorCode.RecordsDecryptNoMatchingKeyEncryptedFound);
298
+ });
299
+ it('should propagate errors thrown by KeyDecrypter.decrypt()', async () => {
300
+ // Build a minimal encrypted message that has enough structure to reach the callback path
301
+ const recipientPrivateKey = await X25519.generateKey();
302
+ const recipientPublicKey = await X25519.getPublicKey({ key: recipientPrivateKey });
303
+ const cek = TestDataGenerator.randomBytes(32);
304
+ const iv = TestDataGenerator.randomBytes(12);
305
+ const plaintext = TestDataGenerator.randomBytes(64);
306
+ const { tag } = await Encryption.aeadEncrypt(ContentEncryptionAlgorithm.A256GCM, cek, iv, plaintext);
307
+ const jwe = await Encryption.buildJwe({
308
+ key: cek,
309
+ initializationVector: iv,
310
+ authenticationTag: tag,
311
+ keyEncryptionInputs: [{
312
+ publicKeyId: 'did:example:alice#enc',
313
+ publicKey: recipientPublicKey,
314
+ derivationScheme: KeyDerivationScheme.ProtocolPath,
315
+ }],
316
+ }, tag);
317
+ // Construct a minimal RecordsWriteMessage with the JWE encryption property
318
+ const message = {
319
+ descriptor: {
320
+ interface: 'Records',
321
+ method: 'Write',
322
+ dataCid: 'bafyreib3e4uj32nq5ql3q',
323
+ dataSize: 100,
324
+ dateCreated: '2024-01-01T00:00:00.000000Z',
325
+ messageTimestamp: '2024-01-01T00:00:00.000000Z',
326
+ dataFormat: 'application/json',
327
+ protocol: 'https://example.com/protocol',
328
+ protocolPath: 'foo',
329
+ },
330
+ encryption: jwe,
331
+ recordId: 'test-record-id',
332
+ };
333
+ // Create a KeyDecrypter that throws an error
334
+ const failingDecrypter = {
335
+ rootKeyId: 'did:example:alice#enc',
336
+ derivationScheme: KeyDerivationScheme.ProtocolPath,
337
+ decrypt: async () => {
338
+ throw new Error('KeyDecrypter: key derivation failed');
339
+ },
340
+ };
341
+ const cipherStream = DataStream.fromBytes(TestDataGenerator.randomBytes(64));
342
+ // The error from KeyDecrypter.decrypt() should propagate directly
343
+ await expect(Records.decrypt(message, failingDecrypter, cipherStream)).rejects.toThrow('KeyDecrypter: key derivation failed');
344
+ });
98
345
  });
99
346
  });
100
347
  //# sourceMappingURL=encryption.spec.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"encryption.spec.js","sourceRoot":"","sources":["../../../../tests/utils/encryption.spec.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AACvC,OAAO,EAAE,0BAA0B,EAAE,UAAU,EAAE,MAAM,+BAA+B,CAAC;AACvF,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,UAAU,CAAC;AAEhD,QAAQ,CAAC,YAAY,EAAE,GAAG,EAAE;IAC1B,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,sDAAsD,EAAE,GAAS,EAAE;YACpE,MAAM,GAAG,GAAG,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC;YAC9C,MAAM,EAAE,GAAG,iBAAiB,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,CAAC,2BAA2B;YAEzE,MAAM,UAAU,GAAG,iBAAiB,CAAC,WAAW,CAAC,OAAS,CAAC,CAAC;YAE5D,MAAM,EAAE,UAAU,EAAE,GAAG,EAAE,GAAG,MAAM,UAAU,CA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