@enbox/dwn-sdk-js 0.0.7 → 0.1.0

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 (368) 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 +817 -911
  4. package/dist/esm/generated/precompiled-validators.js.map +1 -1
  5. package/dist/esm/src/core/constants.js +11 -0
  6. package/dist/esm/src/core/constants.js.map +1 -0
  7. package/dist/esm/src/core/core-protocol.js +44 -0
  8. package/dist/esm/src/core/core-protocol.js.map +1 -0
  9. package/dist/esm/src/core/dwn-error.js +12 -12
  10. package/dist/esm/src/core/dwn-error.js.map +1 -1
  11. package/dist/esm/src/core/grant-authorization.js +16 -3
  12. package/dist/esm/src/core/grant-authorization.js.map +1 -1
  13. package/dist/esm/src/core/protocol-authorization-action.js +5 -0
  14. package/dist/esm/src/core/protocol-authorization-action.js.map +1 -1
  15. package/dist/esm/src/core/protocol-authorization-validation.js +91 -0
  16. package/dist/esm/src/core/protocol-authorization-validation.js.map +1 -1
  17. package/dist/esm/src/core/protocol-authorization.js +53 -30
  18. package/dist/esm/src/core/protocol-authorization.js.map +1 -1
  19. package/dist/esm/src/core/records-grant-authorization.js +6 -8
  20. package/dist/esm/src/core/records-grant-authorization.js.map +1 -1
  21. package/dist/esm/src/core/resumable-task-manager.js +2 -0
  22. package/dist/esm/src/core/resumable-task-manager.js.map +1 -1
  23. package/dist/esm/src/dwn.js +42 -18
  24. package/dist/esm/src/dwn.js.map +1 -1
  25. package/dist/esm/src/event-stream/event-emitter-event-log.js +204 -0
  26. package/dist/esm/src/event-stream/event-emitter-event-log.js.map +1 -0
  27. package/dist/esm/src/handlers/messages-read.js +7 -11
  28. package/dist/esm/src/handlers/messages-read.js.map +1 -1
  29. package/dist/esm/src/handlers/messages-subscribe.js +22 -24
  30. package/dist/esm/src/handlers/messages-subscribe.js.map +1 -1
  31. package/dist/esm/src/handlers/messages-sync.js +11 -15
  32. package/dist/esm/src/handlers/messages-sync.js.map +1 -1
  33. package/dist/esm/src/handlers/protocols-configure.js +37 -27
  34. package/dist/esm/src/handlers/protocols-configure.js.map +1 -1
  35. package/dist/esm/src/handlers/protocols-query.js +7 -11
  36. package/dist/esm/src/handlers/protocols-query.js.map +1 -1
  37. package/dist/esm/src/handlers/records-count.js +10 -12
  38. package/dist/esm/src/handlers/records-count.js.map +1 -1
  39. package/dist/esm/src/handlers/records-delete.js +10 -18
  40. package/dist/esm/src/handlers/records-delete.js.map +1 -1
  41. package/dist/esm/src/handlers/records-query.js +11 -15
  42. package/dist/esm/src/handlers/records-query.js.map +1 -1
  43. package/dist/esm/src/handlers/records-read.js +31 -26
  44. package/dist/esm/src/handlers/records-read.js.map +1 -1
  45. package/dist/esm/src/handlers/records-subscribe.js +39 -26
  46. package/dist/esm/src/handlers/records-subscribe.js.map +1 -1
  47. package/dist/esm/src/handlers/records-write.js +128 -105
  48. package/dist/esm/src/handlers/records-write.js.map +1 -1
  49. package/dist/esm/src/index.js +5 -2
  50. package/dist/esm/src/index.js.map +1 -1
  51. package/dist/esm/src/interfaces/messages-subscribe.js +1 -0
  52. package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -1
  53. package/dist/esm/src/interfaces/protocols-configure.js +33 -3
  54. package/dist/esm/src/interfaces/protocols-configure.js.map +1 -1
  55. package/dist/esm/src/interfaces/records-count.js +1 -1
  56. package/dist/esm/src/interfaces/records-count.js.map +1 -1
  57. package/dist/esm/src/interfaces/records-delete.js +1 -1
  58. package/dist/esm/src/interfaces/records-delete.js.map +1 -1
  59. package/dist/esm/src/interfaces/records-query.js +1 -1
  60. package/dist/esm/src/interfaces/records-query.js.map +1 -1
  61. package/dist/esm/src/interfaces/records-read.js +1 -1
  62. package/dist/esm/src/interfaces/records-read.js.map +1 -1
  63. package/dist/esm/src/interfaces/records-subscribe.js +2 -1
  64. package/dist/esm/src/interfaces/records-subscribe.js.map +1 -1
  65. package/dist/esm/src/interfaces/records-write-signing.js +1 -12
  66. package/dist/esm/src/interfaces/records-write-signing.js.map +1 -1
  67. package/dist/esm/src/interfaces/records-write.js +25 -41
  68. package/dist/esm/src/interfaces/records-write.js.map +1 -1
  69. package/dist/esm/src/protocols/permission-grant.js +1 -1
  70. package/dist/esm/src/protocols/permission-grant.js.map +1 -1
  71. package/dist/esm/src/protocols/permission-request.js +1 -1
  72. package/dist/esm/src/protocols/permission-request.js.map +1 -1
  73. package/dist/esm/src/protocols/permissions.js +113 -5
  74. package/dist/esm/src/protocols/permissions.js.map +1 -1
  75. package/dist/esm/src/state-index/state-index-level.js +5 -7
  76. package/dist/esm/src/state-index/state-index-level.js.map +1 -1
  77. package/dist/esm/src/store/data-store-level.js +110 -33
  78. package/dist/esm/src/store/data-store-level.js.map +1 -1
  79. package/dist/esm/src/store/index-level.js +42 -32
  80. package/dist/esm/src/store/index-level.js.map +1 -1
  81. package/dist/esm/src/store/storage-controller.js +70 -6
  82. package/dist/esm/src/store/storage-controller.js.map +1 -1
  83. package/dist/esm/src/types/permission-types.js.map +1 -1
  84. package/dist/esm/src/types/protocols-types.js +11 -0
  85. package/dist/esm/src/types/protocols-types.js.map +1 -1
  86. package/dist/esm/src/types/records-types.js.map +1 -1
  87. package/dist/esm/src/utils/hd-key.js +0 -8
  88. package/dist/esm/src/utils/hd-key.js.map +1 -1
  89. package/dist/esm/src/utils/messages.js +16 -34
  90. package/dist/esm/src/utils/messages.js.map +1 -1
  91. package/dist/esm/src/utils/records.js +5 -43
  92. package/dist/esm/src/utils/records.js.map +1 -1
  93. package/dist/esm/tests/core/protocol-authorization.spec.js +2 -1
  94. package/dist/esm/tests/core/protocol-authorization.spec.js.map +1 -1
  95. package/dist/esm/tests/dwn.spec.js +32 -43
  96. package/dist/esm/tests/dwn.spec.js.map +1 -1
  97. package/dist/esm/tests/event-emitter-event-log.spec.js +305 -0
  98. package/dist/esm/tests/event-emitter-event-log.spec.js.map +1 -0
  99. package/dist/esm/tests/features/author-delegated-grant.spec.js +14 -7
  100. package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -1
  101. package/dist/esm/tests/features/owner-delegated-grant.spec.js +9 -5
  102. package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -1
  103. package/dist/esm/tests/features/owner-signature.spec.js +14 -7
  104. package/dist/esm/tests/features/owner-signature.spec.js.map +1 -1
  105. package/dist/esm/tests/features/permissions.spec.js +12 -12
  106. package/dist/esm/tests/features/permissions.spec.js.map +1 -1
  107. package/dist/esm/tests/features/protocol-composition.spec.js +636 -5
  108. package/dist/esm/tests/features/protocol-composition.spec.js.map +1 -1
  109. package/dist/esm/tests/features/protocol-create-action.spec.js +4 -4
  110. package/dist/esm/tests/features/protocol-create-action.spec.js.map +1 -1
  111. package/dist/esm/tests/features/protocol-delete-action.spec.js +7 -7
  112. package/dist/esm/tests/features/protocol-delete-action.spec.js.map +1 -1
  113. package/dist/esm/tests/features/protocol-update-action.spec.js +4 -4
  114. package/dist/esm/tests/features/protocol-update-action.spec.js.map +1 -1
  115. package/dist/esm/tests/features/records-delivery.spec.js +236 -0
  116. package/dist/esm/tests/features/records-delivery.spec.js.map +1 -0
  117. package/dist/esm/tests/features/records-immutable.spec.js +315 -0
  118. package/dist/esm/tests/features/records-immutable.spec.js.map +1 -0
  119. package/dist/esm/tests/features/records-prune.spec.js +4 -4
  120. package/dist/esm/tests/features/records-prune.spec.js.map +1 -1
  121. package/dist/esm/tests/features/records-record-limit.spec.js +542 -0
  122. package/dist/esm/tests/features/records-record-limit.spec.js.map +1 -0
  123. package/dist/esm/tests/features/records-squash.spec.js +1055 -0
  124. package/dist/esm/tests/features/records-squash.spec.js.map +1 -0
  125. package/dist/esm/tests/features/records-tags.spec.js +16 -4
  126. package/dist/esm/tests/features/records-tags.spec.js.map +1 -1
  127. package/dist/esm/tests/features/resumable-tasks.spec.js +7 -8
  128. package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -1
  129. package/dist/esm/tests/handlers/messages-read.spec.js +11 -5
  130. package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -1
  131. package/dist/esm/tests/handlers/messages-subscribe.spec.js +169 -22
  132. package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -1
  133. package/dist/esm/tests/handlers/messages-sync.spec.js +103 -21
  134. package/dist/esm/tests/handlers/messages-sync.spec.js.map +1 -1
  135. package/dist/esm/tests/handlers/protocols-configure.spec.js +5 -5
  136. package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -1
  137. package/dist/esm/tests/handlers/protocols-query.spec.js +5 -5
  138. package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -1
  139. package/dist/esm/tests/handlers/records-count.spec.js +9 -4
  140. package/dist/esm/tests/handlers/records-count.spec.js.map +1 -1
  141. package/dist/esm/tests/handlers/records-delete.spec.js +24 -25
  142. package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -1
  143. package/dist/esm/tests/handlers/records-query.spec.js +68 -9
  144. package/dist/esm/tests/handlers/records-query.spec.js.map +1 -1
  145. package/dist/esm/tests/handlers/records-read.spec.js +24 -138
  146. package/dist/esm/tests/handlers/records-read.spec.js.map +1 -1
  147. package/dist/esm/tests/handlers/records-subscribe.spec.js +175 -35
  148. package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -1
  149. package/dist/esm/tests/handlers/records-write.spec.js +176 -72
  150. package/dist/esm/tests/handlers/records-write.spec.js.map +1 -1
  151. package/dist/esm/tests/interfaces/records-write.spec.js +52 -68
  152. package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -1
  153. package/dist/esm/tests/protocols/permission-grant.spec.js +6 -6
  154. package/dist/esm/tests/protocols/permission-grant.spec.js.map +1 -1
  155. package/dist/esm/tests/protocols/permission-request.spec.js +4 -4
  156. package/dist/esm/tests/protocols/permission-request.spec.js.map +1 -1
  157. package/dist/esm/tests/protocols/permissions.spec.js +4 -4
  158. package/dist/esm/tests/protocols/permissions.spec.js.map +1 -1
  159. package/dist/esm/tests/scenarios/aggregator.spec.js +4 -4
  160. package/dist/esm/tests/scenarios/aggregator.spec.js.map +1 -1
  161. package/dist/esm/tests/scenarios/deleted-record.spec.js +350 -5
  162. package/dist/esm/tests/scenarios/deleted-record.spec.js.map +1 -1
  163. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +4 -4
  164. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -1
  165. package/dist/esm/tests/scenarios/nested-roles.spec.js +4 -4
  166. package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -1
  167. package/dist/esm/tests/scenarios/subscriptions.spec.js +93 -40
  168. package/dist/esm/tests/scenarios/subscriptions.spec.js.map +1 -1
  169. package/dist/esm/tests/store/data-store-level.spec.js +102 -41
  170. package/dist/esm/tests/store/data-store-level.spec.js.map +1 -1
  171. package/dist/esm/tests/test-event-stream.js +12 -13
  172. package/dist/esm/tests/test-event-stream.js.map +1 -1
  173. package/dist/esm/tests/test-suite.js +10 -4
  174. package/dist/esm/tests/test-suite.js.map +1 -1
  175. package/dist/esm/tests/utils/messages.spec.js +12 -5
  176. package/dist/esm/tests/utils/messages.spec.js.map +1 -1
  177. package/dist/esm/tests/utils/records.spec.js +8 -12
  178. package/dist/esm/tests/utils/records.spec.js.map +1 -1
  179. package/dist/esm/tests/utils/test-data-generator.js +36 -2
  180. package/dist/esm/tests/utils/test-data-generator.js.map +1 -1
  181. package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js +37 -8
  182. package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js.map +1 -1
  183. package/dist/types/generated/precompiled-validators.d.ts +49 -40
  184. package/dist/types/generated/precompiled-validators.d.ts.map +1 -1
  185. package/dist/types/src/core/constants.d.ts +11 -0
  186. package/dist/types/src/core/constants.d.ts.map +1 -0
  187. package/dist/types/src/core/core-protocol.d.ts +89 -0
  188. package/dist/types/src/core/core-protocol.d.ts.map +1 -0
  189. package/dist/types/src/core/dwn-error.d.ts +12 -12
  190. package/dist/types/src/core/dwn-error.d.ts.map +1 -1
  191. package/dist/types/src/core/grant-authorization.d.ts +6 -2
  192. package/dist/types/src/core/grant-authorization.d.ts.map +1 -1
  193. package/dist/types/src/core/protocol-authorization-action.d.ts.map +1 -1
  194. package/dist/types/src/core/protocol-authorization-validation.d.ts +30 -0
  195. package/dist/types/src/core/protocol-authorization-validation.d.ts.map +1 -1
  196. package/dist/types/src/core/protocol-authorization.d.ts +19 -11
  197. package/dist/types/src/core/protocol-authorization.d.ts.map +1 -1
  198. package/dist/types/src/core/records-grant-authorization.d.ts.map +1 -1
  199. package/dist/types/src/core/resumable-task-manager.d.ts +2 -1
  200. package/dist/types/src/core/resumable-task-manager.d.ts.map +1 -1
  201. package/dist/types/src/dwn.d.ts +19 -7
  202. package/dist/types/src/dwn.d.ts.map +1 -1
  203. package/dist/types/src/event-stream/event-emitter-event-log.d.ts +50 -0
  204. package/dist/types/src/event-stream/event-emitter-event-log.d.ts.map +1 -0
  205. package/dist/types/src/handlers/messages-read.d.ts +3 -8
  206. package/dist/types/src/handlers/messages-read.d.ts.map +1 -1
  207. package/dist/types/src/handlers/messages-subscribe.d.ts +6 -10
  208. package/dist/types/src/handlers/messages-subscribe.d.ts.map +1 -1
  209. package/dist/types/src/handlers/messages-sync.d.ts +3 -8
  210. package/dist/types/src/handlers/messages-sync.d.ts.map +1 -1
  211. package/dist/types/src/handlers/protocols-configure.d.ts +3 -10
  212. package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -1
  213. package/dist/types/src/handlers/protocols-query.d.ts +3 -8
  214. package/dist/types/src/handlers/protocols-query.d.ts.map +1 -1
  215. package/dist/types/src/handlers/records-count.d.ts +3 -6
  216. package/dist/types/src/handlers/records-count.d.ts.map +1 -1
  217. package/dist/types/src/handlers/records-delete.d.ts +3 -8
  218. package/dist/types/src/handlers/records-delete.d.ts.map +1 -1
  219. package/dist/types/src/handlers/records-query.d.ts +3 -8
  220. package/dist/types/src/handlers/records-query.d.ts.map +1 -1
  221. package/dist/types/src/handlers/records-read.d.ts +3 -8
  222. package/dist/types/src/handlers/records-read.d.ts.map +1 -1
  223. package/dist/types/src/handlers/records-subscribe.d.ts +8 -10
  224. package/dist/types/src/handlers/records-subscribe.d.ts.map +1 -1
  225. package/dist/types/src/handlers/records-write.d.ts +12 -25
  226. package/dist/types/src/handlers/records-write.d.ts.map +1 -1
  227. package/dist/types/src/index.d.ts +8 -4
  228. package/dist/types/src/index.d.ts.map +1 -1
  229. package/dist/types/src/interfaces/messages-subscribe.d.ts +5 -0
  230. package/dist/types/src/interfaces/messages-subscribe.d.ts.map +1 -1
  231. package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -1
  232. package/dist/types/src/interfaces/records-subscribe.d.ts +5 -0
  233. package/dist/types/src/interfaces/records-subscribe.d.ts.map +1 -1
  234. package/dist/types/src/interfaces/records-write-signing.d.ts +3 -4
  235. package/dist/types/src/interfaces/records-write-signing.d.ts.map +1 -1
  236. package/dist/types/src/interfaces/records-write.d.ts +11 -11
  237. package/dist/types/src/interfaces/records-write.d.ts.map +1 -1
  238. package/dist/types/src/protocols/permission-grant.d.ts +1 -1
  239. package/dist/types/src/protocols/permission-grant.d.ts.map +1 -1
  240. package/dist/types/src/protocols/permission-request.d.ts +1 -1
  241. package/dist/types/src/protocols/permission-request.d.ts.map +1 -1
  242. package/dist/types/src/protocols/permissions.d.ts +40 -3
  243. package/dist/types/src/protocols/permissions.d.ts.map +1 -1
  244. package/dist/types/src/state-index/state-index-level.d.ts.map +1 -1
  245. package/dist/types/src/store/data-store-level.d.ts +20 -4
  246. package/dist/types/src/store/data-store-level.d.ts.map +1 -1
  247. package/dist/types/src/store/index-level.d.ts +4 -0
  248. package/dist/types/src/store/index-level.d.ts.map +1 -1
  249. package/dist/types/src/store/storage-controller.d.ts +20 -6
  250. package/dist/types/src/store/storage-controller.d.ts.map +1 -1
  251. package/dist/types/src/types/message-types.d.ts +3 -3
  252. package/dist/types/src/types/message-types.d.ts.map +1 -1
  253. package/dist/types/src/types/messages-types.d.ts +12 -3
  254. package/dist/types/src/types/messages-types.d.ts.map +1 -1
  255. package/dist/types/src/types/method-handler.d.ts +24 -3
  256. package/dist/types/src/types/method-handler.d.ts.map +1 -1
  257. package/dist/types/src/types/permission-types.d.ts +7 -0
  258. package/dist/types/src/types/permission-types.d.ts.map +1 -1
  259. package/dist/types/src/types/protocols-types.d.ts +69 -2
  260. package/dist/types/src/types/protocols-types.d.ts.map +1 -1
  261. package/dist/types/src/types/records-types.d.ts +23 -6
  262. package/dist/types/src/types/records-types.d.ts.map +1 -1
  263. package/dist/types/src/types/subscriptions.d.ts +151 -13
  264. package/dist/types/src/types/subscriptions.d.ts.map +1 -1
  265. package/dist/types/src/utils/hd-key.d.ts +1 -9
  266. package/dist/types/src/utils/hd-key.d.ts.map +1 -1
  267. package/dist/types/src/utils/messages.d.ts +7 -5
  268. package/dist/types/src/utils/messages.d.ts.map +1 -1
  269. package/dist/types/src/utils/records.d.ts +1 -11
  270. package/dist/types/src/utils/records.d.ts.map +1 -1
  271. package/dist/types/tests/dwn.spec.d.ts.map +1 -1
  272. package/dist/types/tests/event-emitter-event-log.spec.d.ts +2 -0
  273. package/dist/types/tests/event-emitter-event-log.spec.d.ts.map +1 -0
  274. package/dist/types/tests/features/author-delegated-grant.spec.d.ts.map +1 -1
  275. package/dist/types/tests/features/owner-delegated-grant.spec.d.ts.map +1 -1
  276. package/dist/types/tests/features/owner-signature.spec.d.ts.map +1 -1
  277. package/dist/types/tests/features/protocol-composition.spec.d.ts.map +1 -1
  278. package/dist/types/tests/features/records-delivery.spec.d.ts +2 -0
  279. package/dist/types/tests/features/records-delivery.spec.d.ts.map +1 -0
  280. package/dist/types/tests/features/records-immutable.spec.d.ts +2 -0
  281. package/dist/types/tests/features/records-immutable.spec.d.ts.map +1 -0
  282. package/dist/types/tests/features/records-record-limit.spec.d.ts +2 -0
  283. package/dist/types/tests/features/records-record-limit.spec.d.ts.map +1 -0
  284. package/dist/types/tests/features/records-squash.spec.d.ts +2 -0
  285. package/dist/types/tests/features/records-squash.spec.d.ts.map +1 -0
  286. package/dist/types/tests/features/records-tags.spec.d.ts.map +1 -1
  287. package/dist/types/tests/features/resumable-tasks.spec.d.ts.map +1 -1
  288. package/dist/types/tests/handlers/messages-read.spec.d.ts.map +1 -1
  289. package/dist/types/tests/handlers/messages-subscribe.spec.d.ts.map +1 -1
  290. package/dist/types/tests/handlers/messages-sync.spec.d.ts.map +1 -1
  291. package/dist/types/tests/handlers/records-count.spec.d.ts.map +1 -1
  292. package/dist/types/tests/handlers/records-delete.spec.d.ts.map +1 -1
  293. package/dist/types/tests/handlers/records-query.spec.d.ts.map +1 -1
  294. package/dist/types/tests/handlers/records-read.spec.d.ts.map +1 -1
  295. package/dist/types/tests/handlers/records-subscribe.spec.d.ts.map +1 -1
  296. package/dist/types/tests/handlers/records-write.spec.d.ts.map +1 -1
  297. package/dist/types/tests/scenarios/deleted-record.spec.d.ts.map +1 -1
  298. package/dist/types/tests/scenarios/subscriptions.spec.d.ts.map +1 -1
  299. package/dist/types/tests/test-event-stream.d.ts +11 -12
  300. package/dist/types/tests/test-event-stream.d.ts.map +1 -1
  301. package/dist/types/tests/test-suite.d.ts +2 -2
  302. package/dist/types/tests/test-suite.d.ts.map +1 -1
  303. package/dist/types/tests/utils/test-data-generator.d.ts +19 -0
  304. package/dist/types/tests/utils/test-data-generator.d.ts.map +1 -1
  305. package/package.json +5 -4
  306. package/src/core/constants.ts +11 -0
  307. package/src/core/core-protocol.ts +129 -0
  308. package/src/core/dwn-error.ts +18 -12
  309. package/src/core/grant-authorization.ts +20 -3
  310. package/src/core/protocol-authorization-action.ts +5 -0
  311. package/src/core/protocol-authorization-validation.ts +133 -0
  312. package/src/core/protocol-authorization.ts +71 -23
  313. package/src/core/records-grant-authorization.ts +6 -8
  314. package/src/core/resumable-task-manager.ts +3 -1
  315. package/src/dwn.ts +58 -73
  316. package/src/event-stream/event-emitter-event-log.ts +283 -0
  317. package/src/handlers/messages-read.ts +8 -9
  318. package/src/handlers/messages-subscribe.ts +24 -28
  319. package/src/handlers/messages-sync.ts +10 -16
  320. package/src/handlers/protocols-configure.ts +47 -32
  321. package/src/handlers/protocols-query.ts +6 -9
  322. package/src/handlers/records-count.ts +11 -10
  323. package/src/handlers/records-delete.ts +12 -21
  324. package/src/handlers/records-query.ts +12 -12
  325. package/src/handlers/records-read.ts +34 -22
  326. package/src/handlers/records-subscribe.ts +47 -26
  327. package/src/handlers/records-write.ts +152 -119
  328. package/src/index.ts +9 -5
  329. package/src/interfaces/messages-subscribe.ts +7 -1
  330. package/src/interfaces/protocols-configure.ts +51 -3
  331. package/src/interfaces/records-count.ts +1 -1
  332. package/src/interfaces/records-delete.ts +1 -1
  333. package/src/interfaces/records-query.ts +1 -1
  334. package/src/interfaces/records-read.ts +1 -1
  335. package/src/interfaces/records-subscribe.ts +8 -1
  336. package/src/interfaces/records-write-signing.ts +2 -22
  337. package/src/interfaces/records-write.ts +35 -48
  338. package/src/protocols/permission-grant.ts +1 -1
  339. package/src/protocols/permission-request.ts +1 -1
  340. package/src/protocols/permissions.ts +148 -6
  341. package/src/state-index/state-index-level.ts +5 -7
  342. package/src/store/data-store-level.ts +124 -34
  343. package/src/store/index-level.ts +44 -35
  344. package/src/store/storage-controller.ts +89 -12
  345. package/src/types/message-types.ts +3 -3
  346. package/src/types/messages-types.ts +12 -3
  347. package/src/types/method-handler.ts +26 -4
  348. package/src/types/mitt.d.ts +28 -0
  349. package/src/types/permission-types.ts +7 -0
  350. package/src/types/protocols-types.ts +78 -1
  351. package/src/types/records-types.ts +24 -6
  352. package/src/types/subscriptions.ts +178 -14
  353. package/src/utils/hd-key.ts +0 -9
  354. package/src/utils/messages.ts +17 -37
  355. package/src/utils/records.ts +7 -58
  356. package/dist/esm/src/event-stream/event-emitter-stream.js +0 -46
  357. package/dist/esm/src/event-stream/event-emitter-stream.js.map +0 -1
  358. package/dist/esm/tests/event-stream/event-emitter-stream.spec.js +0 -68
  359. package/dist/esm/tests/event-stream/event-emitter-stream.spec.js.map +0 -1
  360. package/dist/esm/tests/event-stream/event-stream.spec.js +0 -114
  361. package/dist/esm/tests/event-stream/event-stream.spec.js.map +0 -1
  362. package/dist/types/src/event-stream/event-emitter-stream.d.ts +0 -23
  363. package/dist/types/src/event-stream/event-emitter-stream.d.ts.map +0 -1
  364. package/dist/types/tests/event-stream/event-emitter-stream.spec.d.ts +0 -2
  365. package/dist/types/tests/event-stream/event-emitter-stream.spec.d.ts.map +0 -1
  366. package/dist/types/tests/event-stream/event-stream.spec.d.ts +0 -2
  367. package/dist/types/tests/event-stream/event-stream.spec.d.ts.map +0 -1
  368. package/src/event-stream/event-emitter-stream.ts +0 -69
@@ -14,11 +14,11 @@ import { Message } from '../../src/core/message.js';
14
14
  import { RecordsQuery } from '../../src/interfaces/records-query.js';
15
15
  import { RecordsQueryHandler } from '../../src/handlers/records-query.js';
16
16
  import { RecordsWriteHandler } from '../../src/handlers/records-write.js';
17
- import { TestDataGenerator } from '../utils/test-data-generator.js';
18
- import { TestEventStream } from '../test-event-stream.js';
17
+ import { TestEventLog } from '../test-event-stream.js';
19
18
  import { TestStores } from '../test-stores.js';
20
19
  import { TestStubGenerator } from '../utils/test-stub-generator.js';
21
- import { DataStoreLevel, Dwn, MessageStoreLevel, RecordsWrite, Time } from '../../src/index.js';
20
+ import { CoreProtocolRegistry, DataStoreLevel, Dwn, MessageStoreLevel, ProtocolsConfigure, RecordsWrite, Time } from '../../src/index.js';
21
+ import { defaultTestProtocolDefinition, TestDataGenerator } from '../utils/test-data-generator.js';
22
22
  import { DidKey, UniversalResolver } from '@enbox/dids';
23
23
  export function testRecordsQueryHandler() {
24
24
  describe('RecordsQueryHandler.handle()', () => {
@@ -31,7 +31,7 @@ export function testRecordsQueryHandler() {
31
31
  let dataStore;
32
32
  let resumableTaskStore;
33
33
  let stateIndex;
34
- let eventStream;
34
+ let eventLog;
35
35
  let dwn;
36
36
  // important to follow the `before` and `after` pattern to initialize and clean the stores in tests
37
37
  // so that different test suites can reuse the same backend store for testing
@@ -42,8 +42,9 @@ export function testRecordsQueryHandler() {
42
42
  dataStore = stores.dataStore;
43
43
  resumableTaskStore = stores.resumableTaskStore;
44
44
  stateIndex = stores.stateIndex;
45
- eventStream = TestEventStream.get();
46
- dwn = await Dwn.create({ didResolver, messageStore, dataStore, stateIndex, eventStream, resumableTaskStore });
45
+ eventLog = TestEventLog.get();
46
+ eventLog = TestEventLog.get();
47
+ dwn = await Dwn.create({ didResolver, messageStore, dataStore, stateIndex, eventLog, resumableTaskStore });
47
48
  });
48
49
  beforeEach(async () => {
49
50
  // clean up before each test rather than after so that a test does not depend on other tests to do the clean up
@@ -77,6 +78,7 @@ export function testRecordsQueryHandler() {
77
78
  const alice = await TestDataGenerator.generatePersona();
78
79
  const bob = await TestDataGenerator.generatePersona();
79
80
  TestStubGenerator.stubDidResolver(didResolver, [alice, bob]);
81
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
80
82
  const dataFormat = 'myAwesomeDataFormat';
81
83
  const write = await TestDataGenerator.generateRecordsWrite({ author: alice, attesters: [bob], dataFormat });
82
84
  const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream });
@@ -101,6 +103,7 @@ export function testRecordsQueryHandler() {
101
103
  const mockResolution = TestDataGenerator.createDidResolutionResult(alice);
102
104
  ;
103
105
  sinon.stub(didResolver, 'resolve').resolves(mockResolution);
106
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
104
107
  // insert data
105
108
  const writeReply1 = await dwn.processMessage(alice.did, write1.message, { dataStream: write1.dataStream });
106
109
  const writeReply2 = await dwn.processMessage(alice.did, write2.message, { dataStream: write2.dataStream });
@@ -128,6 +131,7 @@ export function testRecordsQueryHandler() {
128
131
  it('should return `encodedData` if data size is within the spec threshold', async () => {
129
132
  const data = TestDataGenerator.randomBytes(DwnConstant.maxDataSizeAllowedToBeEncoded); // within/on threshold
130
133
  const alice = await TestDataGenerator.generateDidKeyPersona();
134
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
131
135
  const write = await TestDataGenerator.generateRecordsWrite({ author: alice, data });
132
136
  const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream });
133
137
  expect(writeReply.status.code).toBe(202);
@@ -140,6 +144,7 @@ export function testRecordsQueryHandler() {
140
144
  it('should not return `encodedData` if data size is greater then spec threshold', async () => {
141
145
  const data = TestDataGenerator.randomBytes(DwnConstant.maxDataSizeAllowedToBeEncoded + 1); // exceeding threshold
142
146
  const alice = await TestDataGenerator.generateDidKeyPersona();
147
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
143
148
  const write = await TestDataGenerator.generateRecordsWrite({ author: alice, data });
144
149
  const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream });
145
150
  expect(writeReply.status.code).toBe(202);
@@ -151,6 +156,7 @@ export function testRecordsQueryHandler() {
151
156
  });
152
157
  it('should include `initialWrite` property if RecordsWrite is not initial write', async () => {
153
158
  const alice = await TestDataGenerator.generateDidKeyPersona();
159
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
154
160
  const write = await TestDataGenerator.generateRecordsWrite({ author: alice, published: false });
155
161
  const writeReply = await dwn.processMessage(alice.did, write.message, { dataStream: write.dataStream });
156
162
  expect(writeReply.status.code).toBe(202);
@@ -170,6 +176,7 @@ export function testRecordsQueryHandler() {
170
176
  // scenario: 2 records authored by alice, 1st attested by alice, 2nd attested by bob
171
177
  const alice = await TestDataGenerator.generateDidKeyPersona();
172
178
  const bob = await TestDataGenerator.generateDidKeyPersona();
179
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
173
180
  const recordsWrite1 = await TestDataGenerator.generateRecordsWrite({ author: alice, attesters: [alice] });
174
181
  const recordsWrite2 = await TestDataGenerator.generateRecordsWrite({ author: alice, attesters: [bob] });
175
182
  // insert data
@@ -393,6 +400,7 @@ export function testRecordsQueryHandler() {
393
400
  it('should be able to query for published records', async () => {
394
401
  const alice = await TestDataGenerator.generateDidKeyPersona();
395
402
  const bob = await TestDataGenerator.generateDidKeyPersona();
403
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
396
404
  // create a published record
397
405
  const publishedWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true, schema: 'post' });
398
406
  const publishedWriteReply = await dwn.processMessage(alice.did, publishedWrite.message, { dataStream: publishedWrite.dataStream });
@@ -449,6 +457,7 @@ export function testRecordsQueryHandler() {
449
457
  });
450
458
  it('should be able to query for unpublished records', async () => {
451
459
  const alice = await TestDataGenerator.generateDidKeyPersona();
460
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
452
461
  // create a published record
453
462
  const publishedWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true, schema: 'post' });
454
463
  const publishedWriteReply = await dwn.processMessage(alice.did, publishedWrite.message, { dataStream: publishedWrite.dataStream });
@@ -479,6 +488,7 @@ export function testRecordsQueryHandler() {
479
488
  it('should not be able to query for unpublished records if unauthorized', async () => {
480
489
  const alice = await TestDataGenerator.generateDidKeyPersona();
481
490
  const bob = await TestDataGenerator.generateDidKeyPersona();
491
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
482
492
  // create a published record
483
493
  const publishedWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, published: true, schema: 'post' });
484
494
  const publishedWriteReply = await dwn.processMessage(alice.did, publishedWrite.message, { dataStream: publishedWrite.dataStream });
@@ -517,6 +527,7 @@ export function testRecordsQueryHandler() {
517
527
  });
518
528
  it('should be able to query for a record by a dataCid', async () => {
519
529
  const alice = await TestDataGenerator.generateDidKeyPersona();
530
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
520
531
  // create a record
521
532
  const writeRecord = await TestDataGenerator.generateRecordsWrite({ author: alice });
522
533
  const writeRecordReply = await dwn.processMessage(alice.did, writeRecord.message, { dataStream: writeRecord.dataStream });
@@ -531,6 +542,7 @@ export function testRecordsQueryHandler() {
531
542
  });
532
543
  it('should be able to query with `dataSize` filter (half-open range)', async () => {
533
544
  const alice = await TestDataGenerator.generateDidKeyPersona();
545
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
534
546
  const write1 = await TestDataGenerator.generateRecordsWrite({ author: alice, data: TestDataGenerator.randomBytes(10) });
535
547
  const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice, data: TestDataGenerator.randomBytes(50) });
536
548
  const write3 = await TestDataGenerator.generateRecordsWrite({ author: alice, data: TestDataGenerator.randomBytes(100) });
@@ -590,6 +602,7 @@ export function testRecordsQueryHandler() {
590
602
  });
591
603
  it('should be able to range query with `dataSize` filter (open & closed range)', async () => {
592
604
  const alice = await TestDataGenerator.generateDidKeyPersona();
605
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
593
606
  const write1 = await TestDataGenerator.generateRecordsWrite({ author: alice, data: TestDataGenerator.randomBytes(10) });
594
607
  const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice, data: TestDataGenerator.randomBytes(50) });
595
608
  const write3 = await TestDataGenerator.generateRecordsWrite({ author: alice, data: TestDataGenerator.randomBytes(100) });
@@ -642,6 +655,7 @@ export function testRecordsQueryHandler() {
642
655
  const firstDayOf2022 = Time.createTimestamp({ year: 2022, month: 1, day: 1 });
643
656
  const firstDayOf2023 = Time.createTimestamp({ year: 2023, month: 1, day: 1 });
644
657
  const alice = await TestDataGenerator.generateDidKeyPersona();
658
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
645
659
  const write1 = await TestDataGenerator.generateRecordsWrite({ author: alice, dateCreated: firstDayOf2021, messageTimestamp: firstDayOf2021 });
646
660
  const write2 = await TestDataGenerator.generateRecordsWrite({ author: alice, dateCreated: firstDayOf2022, messageTimestamp: firstDayOf2022 });
647
661
  const write3 = await TestDataGenerator.generateRecordsWrite({ author: alice, dateCreated: firstDayOf2023, messageTimestamp: firstDayOf2023 });
@@ -702,6 +716,14 @@ export function testRecordsQueryHandler() {
702
716
  const firstDayOf2022 = Time.createTimestamp({ year: 2022, month: 1, day: 1 });
703
717
  const firstDayOf2023 = Time.createTimestamp({ year: 2023, month: 1, day: 1 });
704
718
  const alice = await TestDataGenerator.generateDidKeyPersona();
719
+ // install protocol at a timestamp before the record timestamps so temporal lookup works for updates
720
+ const protocolsConfigure = await ProtocolsConfigure.create({
721
+ definition: defaultTestProtocolDefinition,
722
+ signer: Jws.createSigner(alice),
723
+ messageTimestamp: Time.createTimestamp({ year: 2019, month: 1, day: 1 }),
724
+ });
725
+ const protoReply = await dwn.processMessage(alice.did, protocolsConfigure.message);
726
+ expect(protoReply.status.code).toBe(202);
705
727
  const write1 = await TestDataGenerator.generateRecordsWrite({
706
728
  author: alice, published: true, dateCreated: firstDayOf2020, datePublished: firstDayOf2021, messageTimestamp: firstDayOf2020
707
729
  });
@@ -807,6 +829,7 @@ export function testRecordsQueryHandler() {
807
829
  const firstDayOf2022 = Time.createTimestamp({ year: 2022, month: 1, day: 1 });
808
830
  const firstDayOf2023 = Time.createTimestamp({ year: 2023, month: 1, day: 1 });
809
831
  const alice = await TestDataGenerator.generateDidKeyPersona();
832
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
810
833
  const write1 = await TestDataGenerator.generateRecordsWrite({
811
834
  author: alice, published: true, dateCreated: firstDayOf2020, datePublished: firstDayOf2021, messageTimestamp: firstDayOf2020
812
835
  });
@@ -896,6 +919,14 @@ export function testRecordsQueryHandler() {
896
919
  const firstDayOf2022 = Time.createTimestamp({ year: 2022, month: 1, day: 1 });
897
920
  const firstDayOf2023 = Time.createTimestamp({ year: 2023, month: 1, day: 1 });
898
921
  const alice = await TestDataGenerator.generateDidKeyPersona();
922
+ // install protocol at a timestamp before the record timestamps so temporal lookup works for updates
923
+ const protocolsConfigure = await ProtocolsConfigure.create({
924
+ definition: defaultTestProtocolDefinition,
925
+ signer: Jws.createSigner(alice),
926
+ messageTimestamp: Time.createTimestamp({ year: 2019, month: 1, day: 1 }),
927
+ });
928
+ const protoReply = await dwn.processMessage(alice.did, protocolsConfigure.message);
929
+ expect(protoReply.status.code).toBe(202);
899
930
  const write1 = await TestDataGenerator.generateRecordsWrite({
900
931
  author: alice, dateCreated: firstDayOf2020, messageTimestamp: firstDayOf2020
901
932
  });
@@ -989,6 +1020,7 @@ export function testRecordsQueryHandler() {
989
1020
  const firstDayOf2022 = Time.createTimestamp({ year: 2022, month: 1, day: 1 });
990
1021
  const firstDayOf2023 = Time.createTimestamp({ year: 2023, month: 1, day: 1 });
991
1022
  const alice = await TestDataGenerator.generateDidKeyPersona();
1023
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
992
1024
  const schema = '2021And2022Schema';
993
1025
  const write1 = await TestDataGenerator.generateRecordsWrite({
994
1026
  author: alice, dateCreated: firstDayOf2021, messageTimestamp: firstDayOf2021, schema
@@ -1027,6 +1059,7 @@ export function testRecordsQueryHandler() {
1027
1059
  // setting up a stub method resolver
1028
1060
  const mockResolution = TestDataGenerator.createDidResolutionResult(alice);
1029
1061
  sinon.stub(didResolver, 'resolve').resolves(mockResolution);
1062
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
1030
1063
  const writeReply = await dwn.processMessage(alice.did, message, { dataStream });
1031
1064
  expect(writeReply.status.code).toBe(202);
1032
1065
  const queryData = await TestDataGenerator.generateRecordsQuery({
@@ -1041,6 +1074,7 @@ export function testRecordsQueryHandler() {
1041
1074
  it('should include `attestation` in returned records', async () => {
1042
1075
  // scenario: alice and bob attest to a message alice authored
1043
1076
  const alice = await TestDataGenerator.generateDidKeyPersona();
1077
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
1044
1078
  const { message, dataStream } = await TestDataGenerator.generateRecordsWrite({ author: alice, attesters: [alice] });
1045
1079
  const writeReply = await dwn.processMessage(alice.did, message, { dataStream });
1046
1080
  expect(writeReply.status.code).toBe(202);
@@ -1068,6 +1102,7 @@ export function testRecordsQueryHandler() {
1068
1102
  const mockResolution = TestDataGenerator.createDidResolutionResult(alice);
1069
1103
  ;
1070
1104
  sinon.stub(didResolver, 'resolve').resolves(mockResolution);
1105
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
1071
1106
  // insert data
1072
1107
  const publishedWriteReply = await dwn.processMessage(alice.did, publishedWriteData.message, { dataStream: publishedWriteData.dataStream });
1073
1108
  const unpublishedWriteReply = await dwn.processMessage(alice.did, unpublishedWriteData.message, { dataStream: unpublishedWriteData.dataStream });
@@ -1106,6 +1141,7 @@ export function testRecordsQueryHandler() {
1106
1141
  const mockResolution = TestDataGenerator.createDidResolutionResult(alice);
1107
1142
  ;
1108
1143
  sinon.stub(didResolver, 'resolve').resolves(mockResolution);
1144
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
1109
1145
  // insert data, intentionally out of order
1110
1146
  const writeReply2 = await dwn.processMessage(alice.did, write2Data.message, { dataStream: write2Data.dataStream });
1111
1147
  const writeReply1 = await dwn.processMessage(alice.did, write1Data.message, { dataStream: write1Data.dataStream });
@@ -1238,6 +1274,7 @@ export function testRecordsQueryHandler() {
1238
1274
  it('should sort records by `updatedAscending` and `updatedDescending`', async () => {
1239
1275
  // insert three messages into DB
1240
1276
  const alice = await TestDataGenerator.generateDidKeyPersona();
1277
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
1241
1278
  const schema = 'aSchema';
1242
1279
  const write1Data = await TestDataGenerator.generateRecordsWrite({ author: alice, schema });
1243
1280
  await Time.minimalSleep();
@@ -1279,6 +1316,14 @@ export function testRecordsQueryHandler() {
1279
1316
  // updatedAscending should return them in order of their update, not creation.
1280
1317
  const createdTimestamp = Time.createTimestamp({ year: 2020, month: 1, day: 1 });
1281
1318
  const alice = await TestDataGenerator.generateDidKeyPersona();
1319
+ // install protocol at a timestamp before the record timestamps so temporal lookup works for updates
1320
+ const protocolsConfigure = await ProtocolsConfigure.create({
1321
+ definition: defaultTestProtocolDefinition,
1322
+ signer: Jws.createSigner(alice),
1323
+ messageTimestamp: Time.createTimestamp({ year: 2019, month: 1, day: 1 }),
1324
+ });
1325
+ const protoReply = await dwn.processMessage(alice.did, protocolsConfigure.message);
1326
+ expect(protoReply.status.code).toBe(202);
1282
1327
  const schema = 'aSchema';
1283
1328
  const write1 = await TestDataGenerator.generateRecordsWrite({
1284
1329
  author: alice, schema, dateCreated: createdTimestamp, messageTimestamp: createdTimestamp,
@@ -1345,6 +1390,7 @@ export function testRecordsQueryHandler() {
1345
1390
  const dateCreated = Time.getCurrentTimestamp();
1346
1391
  const messageTimestamp = dateCreated;
1347
1392
  const alice = await TestDataGenerator.generateDidKeyPersona();
1393
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
1348
1394
  const schema = 'aSchema';
1349
1395
  const published = true;
1350
1396
  const write1Data = await TestDataGenerator.generateRecordsWrite({ messageTimestamp, dateCreated, author: alice, schema, published });
@@ -1384,6 +1430,7 @@ export function testRecordsQueryHandler() {
1384
1430
  });
1385
1431
  it('should paginate all records in ascending order', async () => {
1386
1432
  const alice = await TestDataGenerator.generateDidKeyPersona();
1433
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
1387
1434
  const messages = await Promise.all(Array(12).fill({}).map(_ => TestDataGenerator.generateRecordsWrite({
1388
1435
  author: alice,
1389
1436
  schema: 'https://schema'
@@ -1421,6 +1468,7 @@ export function testRecordsQueryHandler() {
1421
1468
  });
1422
1469
  it('should paginate all records in descending order', async () => {
1423
1470
  const alice = await TestDataGenerator.generateDidKeyPersona();
1471
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
1424
1472
  const messages = await Promise.all(Array(12).fill({}).map(_ => TestDataGenerator.generateRecordsWrite({
1425
1473
  author: alice,
1426
1474
  schema: 'https://schema'
@@ -1461,6 +1509,7 @@ export function testRecordsQueryHandler() {
1461
1509
  // 1st is unpublished
1462
1510
  // 2nd is published
1463
1511
  const alice = await TestDataGenerator.generateDidKeyPersona();
1512
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
1464
1513
  const record1Data = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'https://schema1', published: false });
1465
1514
  const record2Data = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'https://schema2', published: true });
1466
1515
  const recordsWrite1Reply = await dwn.processMessage(alice.did, record1Data.message, { dataStream: record1Data.dataStream });
@@ -1996,7 +2045,9 @@ export function testRecordsQueryHandler() {
1996
2045
  ...alicePublishedPromise,
1997
2046
  ...aliceMessagesForBobPromise,
1998
2047
  ];
1999
- const recordsWriteHandler = new RecordsWriteHandler(didResolver, messageStore, dataStore, stateIndex, eventStream);
2048
+ const recordsWriteHandler = new RecordsWriteHandler({
2049
+ didResolver, messageStore, dataStore, stateIndex, coreProtocols: new CoreProtocolRegistry(), eventLog,
2050
+ });
2000
2051
  const messages = [];
2001
2052
  for await (const { recordsWrite, message, dataBytes } of messagePromises) {
2002
2053
  const indexes = await recordsWrite.constructIndexes(true);
@@ -2083,6 +2134,7 @@ export function testRecordsQueryHandler() {
2083
2134
  it('#170 - should treat records with `published` explicitly set to `false` as unpublished', async () => {
2084
2135
  const alice = await TestDataGenerator.generateDidKeyPersona();
2085
2136
  const bob = await TestDataGenerator.generateDidKeyPersona();
2137
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
2086
2138
  const schema = 'schema1';
2087
2139
  const unpublishedRecordsWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema, data: Encoder.stringToBytes('1'), published: false } // explicitly setting `published` to `false`
2088
2140
  );
@@ -2119,6 +2171,8 @@ export function testRecordsQueryHandler() {
2119
2171
  // insert three messages into DB, two with matching schema
2120
2172
  const alice = await TestDataGenerator.generateDidKeyPersona();
2121
2173
  const bob = await TestDataGenerator.generateDidKeyPersona();
2174
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
2175
+ await TestDataGenerator.installDefaultTestProtocol(dwn, bob);
2122
2176
  const schema = 'myAwesomeSchema';
2123
2177
  const recordsWriteMessage1Data = await TestDataGenerator.generateRecordsWrite({ author: alice, schema });
2124
2178
  const recordsWriteMessage2Data = await TestDataGenerator.generateRecordsWrite({ author: bob, schema });
@@ -2187,6 +2241,7 @@ export function testRecordsQueryHandler() {
2187
2241
  });
2188
2242
  it('should return 401 for anonymous queries that filter explicitly for unpublished records', async () => {
2189
2243
  const alice = await TestDataGenerator.generateDidKeyPersona();
2244
+ await TestDataGenerator.installDefaultTestProtocol(dwn, alice);
2190
2245
  // create an unpublished record
2191
2246
  const draftWrite = await TestDataGenerator.generateRecordsWrite({ author: alice, schema: 'post' });
2192
2247
  const draftWriteReply = await dwn.processMessage(alice.did, draftWrite.message, { dataStream: draftWrite.dataStream });
@@ -3002,7 +3057,9 @@ export function testRecordsQueryHandler() {
3002
3057
  const didResolver = TestStubGenerator.createDidResolverStub(mismatchingPersona);
3003
3058
  const messageStoreStub = sinon.createStubInstance(MessageStoreLevel);
3004
3059
  const dataStoreStub = sinon.createStubInstance(DataStoreLevel);
3005
- const recordsQueryHandler = new RecordsQueryHandler(didResolver, messageStoreStub, dataStoreStub);
3060
+ const recordsQueryHandler = new RecordsQueryHandler({
3061
+ didResolver, messageStore: messageStoreStub, dataStore: dataStoreStub,
3062
+ });
3006
3063
  const reply = await recordsQueryHandler.handle({ tenant, message });
3007
3064
  expect(reply.status.code).toBe(401);
3008
3065
  });
@@ -3013,7 +3070,9 @@ export function testRecordsQueryHandler() {
3013
3070
  const didResolver = TestStubGenerator.createDidResolverStub(author);
3014
3071
  const messageStoreStub = sinon.createStubInstance(MessageStoreLevel);
3015
3072
  const dataStoreStub = sinon.createStubInstance(DataStoreLevel);
3016
- const recordsQueryHandler = new RecordsQueryHandler(didResolver, messageStoreStub, dataStoreStub);
3073
+ const recordsQueryHandler = new RecordsQueryHandler({
3074
+ didResolver, messageStore: messageStoreStub, dataStore: dataStoreStub,
3075
+ });
3017
3076
  // stub the `parse()` function to throw an error
3018
3077
  sinon.stub(RecordsQuery, 'parse').throws('anyError');
3019
3078
  const reply = await recordsQueryHandler.handle({ tenant, message });