@enbox/dwn-sdk-js 0.0.1

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 (810) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +352 -0
  3. package/dist/bundles/dwn.js +153 -0
  4. package/dist/cjs/index.js +36749 -0
  5. package/dist/cjs/package.json +1 -0
  6. package/dist/esm/generated/precompiled-validators.js +11973 -0
  7. package/dist/esm/generated/precompiled-validators.js.map +1 -0
  8. package/dist/esm/json-schemas/definitions.json +23 -0
  9. package/dist/esm/src/core/abstract-message.js +47 -0
  10. package/dist/esm/src/core/abstract-message.js.map +1 -0
  11. package/dist/esm/src/core/auth.js +39 -0
  12. package/dist/esm/src/core/auth.js.map +1 -0
  13. package/dist/esm/src/core/dwn-constant.js +10 -0
  14. package/dist/esm/src/core/dwn-constant.js.map +1 -0
  15. package/dist/esm/src/core/dwn-error.js +169 -0
  16. package/dist/esm/src/core/dwn-error.js.map +1 -0
  17. package/dist/esm/src/core/grant-authorization.js +97 -0
  18. package/dist/esm/src/core/grant-authorization.js.map +1 -0
  19. package/dist/esm/src/core/message-reply.js +5 -0
  20. package/dist/esm/src/core/message-reply.js.map +1 -0
  21. package/dist/esm/src/core/message.js +233 -0
  22. package/dist/esm/src/core/message.js.map +1 -0
  23. package/dist/esm/src/core/messages-grant-authorization.js +101 -0
  24. package/dist/esm/src/core/messages-grant-authorization.js.map +1 -0
  25. package/dist/esm/src/core/protocol-authorization.js +608 -0
  26. package/dist/esm/src/core/protocol-authorization.js.map +1 -0
  27. package/dist/esm/src/core/protocols-grant-authorization.js +66 -0
  28. package/dist/esm/src/core/protocols-grant-authorization.js.map +1 -0
  29. package/dist/esm/src/core/records-grant-authorization.js +132 -0
  30. package/dist/esm/src/core/records-grant-authorization.js.map +1 -0
  31. package/dist/esm/src/core/resumable-task-manager.js +109 -0
  32. package/dist/esm/src/core/resumable-task-manager.js.map +1 -0
  33. package/dist/esm/src/core/tenant-gate.js +20 -0
  34. package/dist/esm/src/core/tenant-gate.js.map +1 -0
  35. package/dist/esm/src/dwn.js +164 -0
  36. package/dist/esm/src/dwn.js.map +1 -0
  37. package/dist/esm/src/enums/dwn-interface-method.js +16 -0
  38. package/dist/esm/src/enums/dwn-interface-method.js.map +1 -0
  39. package/dist/esm/src/event-log/event-emitter-stream.js +60 -0
  40. package/dist/esm/src/event-log/event-emitter-stream.js.map +1 -0
  41. package/dist/esm/src/event-log/event-log-level.js +63 -0
  42. package/dist/esm/src/event-log/event-log-level.js.map +1 -0
  43. package/dist/esm/src/handlers/messages-query.js +71 -0
  44. package/dist/esm/src/handlers/messages-query.js.map +1 -0
  45. package/dist/esm/src/handlers/messages-read.js +102 -0
  46. package/dist/esm/src/handlers/messages-read.js.map +1 -0
  47. package/dist/esm/src/handlers/messages-subscribe.js +81 -0
  48. package/dist/esm/src/handlers/messages-subscribe.js.map +1 -0
  49. package/dist/esm/src/handlers/protocols-configure.js +133 -0
  50. package/dist/esm/src/handlers/protocols-configure.js.map +1 -0
  51. package/dist/esm/src/handlers/protocols-query.js +73 -0
  52. package/dist/esm/src/handlers/protocols-query.js.map +1 -0
  53. package/dist/esm/src/handlers/records-delete.js +107 -0
  54. package/dist/esm/src/handlers/records-delete.js.map +1 -0
  55. package/dist/esm/src/handlers/records-query.js +210 -0
  56. package/dist/esm/src/handlers/records-query.js.map +1 -0
  57. package/dist/esm/src/handlers/records-read.js +169 -0
  58. package/dist/esm/src/handlers/records-read.js.map +1 -0
  59. package/dist/esm/src/handlers/records-subscribe.js +172 -0
  60. package/dist/esm/src/handlers/records-subscribe.js.map +1 -0
  61. package/dist/esm/src/handlers/records-write.js +344 -0
  62. package/dist/esm/src/handlers/records-write.js.map +1 -0
  63. package/dist/esm/src/index.js +49 -0
  64. package/dist/esm/src/index.js.map +1 -0
  65. package/dist/esm/src/interfaces/messages-query.js +53 -0
  66. package/dist/esm/src/interfaces/messages-query.js.map +1 -0
  67. package/dist/esm/src/interfaces/messages-read.js +61 -0
  68. package/dist/esm/src/interfaces/messages-read.js.map +1 -0
  69. package/dist/esm/src/interfaces/messages-subscribe.js +58 -0
  70. package/dist/esm/src/interfaces/messages-subscribe.js.map +1 -0
  71. package/dist/esm/src/interfaces/protocols-configure.js +271 -0
  72. package/dist/esm/src/interfaces/protocols-configure.js.map +1 -0
  73. package/dist/esm/src/interfaces/protocols-query.js +84 -0
  74. package/dist/esm/src/interfaces/protocols-query.js.map +1 -0
  75. package/dist/esm/src/interfaces/records-delete.js +89 -0
  76. package/dist/esm/src/interfaces/records-delete.js.map +1 -0
  77. package/dist/esm/src/interfaces/records-query.js +104 -0
  78. package/dist/esm/src/interfaces/records-query.js.map +1 -0
  79. package/dist/esm/src/interfaces/records-read.js +84 -0
  80. package/dist/esm/src/interfaces/records-read.js.map +1 -0
  81. package/dist/esm/src/interfaces/records-subscribe.js +91 -0
  82. package/dist/esm/src/interfaces/records-subscribe.js.map +1 -0
  83. package/dist/esm/src/interfaces/records-write.js +795 -0
  84. package/dist/esm/src/interfaces/records-write.js.map +1 -0
  85. package/dist/esm/src/jose/algorithms/signing/ed25519.js +51 -0
  86. package/dist/esm/src/jose/algorithms/signing/ed25519.js.map +1 -0
  87. package/dist/esm/src/jose/algorithms/signing/signature-algorithms.js +20 -0
  88. package/dist/esm/src/jose/algorithms/signing/signature-algorithms.js.map +1 -0
  89. package/dist/esm/src/jose/jws/general/builder.js +47 -0
  90. package/dist/esm/src/jose/jws/general/builder.js.map +1 -0
  91. package/dist/esm/src/jose/jws/general/verifier.js +97 -0
  92. package/dist/esm/src/jose/jws/general/verifier.js.map +1 -0
  93. package/dist/esm/src/protocols/permission-grant.js +39 -0
  94. package/dist/esm/src/protocols/permission-grant.js.map +1 -0
  95. package/dist/esm/src/protocols/permission-request.js +35 -0
  96. package/dist/esm/src/protocols/permission-request.js.map +1 -0
  97. package/dist/esm/src/protocols/permissions.js +357 -0
  98. package/dist/esm/src/protocols/permissions.js.map +1 -0
  99. package/dist/esm/src/schema-validator.js +37 -0
  100. package/dist/esm/src/schema-validator.js.map +1 -0
  101. package/dist/esm/src/store/blockstore-level.js +187 -0
  102. package/dist/esm/src/store/blockstore-level.js.map +1 -0
  103. package/dist/esm/src/store/blockstore-mock.js +168 -0
  104. package/dist/esm/src/store/blockstore-mock.js.map +1 -0
  105. package/dist/esm/src/store/data-store-level.js +136 -0
  106. package/dist/esm/src/store/data-store-level.js.map +1 -0
  107. package/dist/esm/src/store/index-level.js +660 -0
  108. package/dist/esm/src/store/index-level.js.map +1 -0
  109. package/dist/esm/src/store/level-wrapper.js +305 -0
  110. package/dist/esm/src/store/level-wrapper.js.map +1 -0
  111. package/dist/esm/src/store/message-store-level.js +159 -0
  112. package/dist/esm/src/store/message-store-level.js.map +1 -0
  113. package/dist/esm/src/store/resumable-task-store-level.js +131 -0
  114. package/dist/esm/src/store/resumable-task-store-level.js.map +1 -0
  115. package/dist/esm/src/store/storage-controller.js +184 -0
  116. package/dist/esm/src/store/storage-controller.js.map +1 -0
  117. package/dist/esm/src/types/cache.js +2 -0
  118. package/dist/esm/src/types/cache.js.map +1 -0
  119. package/dist/esm/src/types/data-store.js +2 -0
  120. package/dist/esm/src/types/data-store.js.map +1 -0
  121. package/dist/esm/src/types/event-log.js +2 -0
  122. package/dist/esm/src/types/event-log.js.map +1 -0
  123. package/dist/esm/src/types/jose-types.js +2 -0
  124. package/dist/esm/src/types/jose-types.js.map +1 -0
  125. package/dist/esm/src/types/jws-types.js +2 -0
  126. package/dist/esm/src/types/jws-types.js.map +1 -0
  127. package/dist/esm/src/types/message-interface.js +2 -0
  128. package/dist/esm/src/types/message-interface.js.map +1 -0
  129. package/dist/esm/src/types/message-store.js +2 -0
  130. package/dist/esm/src/types/message-store.js.map +1 -0
  131. package/dist/esm/src/types/message-types.js +3 -0
  132. package/dist/esm/src/types/message-types.js.map +1 -0
  133. package/dist/esm/src/types/messages-types.js +2 -0
  134. package/dist/esm/src/types/messages-types.js.map +1 -0
  135. package/dist/esm/src/types/method-handler.js +2 -0
  136. package/dist/esm/src/types/method-handler.js.map +1 -0
  137. package/dist/esm/src/types/permission-types.js +6 -0
  138. package/dist/esm/src/types/permission-types.js.map +1 -0
  139. package/dist/esm/src/types/protocols-types.js +20 -0
  140. package/dist/esm/src/types/protocols-types.js.map +1 -0
  141. package/dist/esm/src/types/query-types.js +6 -0
  142. package/dist/esm/src/types/query-types.js.map +1 -0
  143. package/dist/esm/src/types/records-types.js +8 -0
  144. package/dist/esm/src/types/records-types.js.map +1 -0
  145. package/dist/esm/src/types/resumable-task-store.js +2 -0
  146. package/dist/esm/src/types/resumable-task-store.js.map +1 -0
  147. package/dist/esm/src/types/signer.js +2 -0
  148. package/dist/esm/src/types/signer.js.map +1 -0
  149. package/dist/esm/src/types/subscriptions.js +2 -0
  150. package/dist/esm/src/types/subscriptions.js.map +1 -0
  151. package/dist/esm/src/utils/abort.js +40 -0
  152. package/dist/esm/src/utils/abort.js.map +1 -0
  153. package/dist/esm/src/utils/array.js +72 -0
  154. package/dist/esm/src/utils/array.js.map +1 -0
  155. package/dist/esm/src/utils/cid.js +130 -0
  156. package/dist/esm/src/utils/cid.js.map +1 -0
  157. package/dist/esm/src/utils/data-stream.js +100 -0
  158. package/dist/esm/src/utils/data-stream.js.map +1 -0
  159. package/dist/esm/src/utils/encoder.js +45 -0
  160. package/dist/esm/src/utils/encoder.js.map +1 -0
  161. package/dist/esm/src/utils/encryption.js +128 -0
  162. package/dist/esm/src/utils/encryption.js.map +1 -0
  163. package/dist/esm/src/utils/filter.js +229 -0
  164. package/dist/esm/src/utils/filter.js.map +1 -0
  165. package/dist/esm/src/utils/hd-key.js +114 -0
  166. package/dist/esm/src/utils/hd-key.js.map +1 -0
  167. package/dist/esm/src/utils/jws.js +89 -0
  168. package/dist/esm/src/utils/jws.js.map +1 -0
  169. package/dist/esm/src/utils/memory-cache.js +41 -0
  170. package/dist/esm/src/utils/memory-cache.js.map +1 -0
  171. package/dist/esm/src/utils/messages.js +84 -0
  172. package/dist/esm/src/utils/messages.js.map +1 -0
  173. package/dist/esm/src/utils/object.js +40 -0
  174. package/dist/esm/src/utils/object.js.map +1 -0
  175. package/dist/esm/src/utils/private-key-signer.js +43 -0
  176. package/dist/esm/src/utils/private-key-signer.js.map +1 -0
  177. package/dist/esm/src/utils/protocols.js +51 -0
  178. package/dist/esm/src/utils/protocols.js.map +1 -0
  179. package/dist/esm/src/utils/records.js +454 -0
  180. package/dist/esm/src/utils/records.js.map +1 -0
  181. package/dist/esm/src/utils/secp256k1.js +166 -0
  182. package/dist/esm/src/utils/secp256k1.js.map +1 -0
  183. package/dist/esm/src/utils/secp256r1.js +120 -0
  184. package/dist/esm/src/utils/secp256r1.js.map +1 -0
  185. package/dist/esm/src/utils/string.js +16 -0
  186. package/dist/esm/src/utils/string.js.map +1 -0
  187. package/dist/esm/src/utils/time.js +85 -0
  188. package/dist/esm/src/utils/time.js.map +1 -0
  189. package/dist/esm/src/utils/url.js +62 -0
  190. package/dist/esm/src/utils/url.js.map +1 -0
  191. package/dist/esm/tests/core/auth.spec.js +22 -0
  192. package/dist/esm/tests/core/auth.spec.js.map +1 -0
  193. package/dist/esm/tests/core/message-reply.spec.js +16 -0
  194. package/dist/esm/tests/core/message-reply.spec.js.map +1 -0
  195. package/dist/esm/tests/core/message.spec.js +146 -0
  196. package/dist/esm/tests/core/message.spec.js.map +1 -0
  197. package/dist/esm/tests/core/protocol-authorization.spec.js +48 -0
  198. package/dist/esm/tests/core/protocol-authorization.spec.js.map +1 -0
  199. package/dist/esm/tests/dwn.spec.js +166 -0
  200. package/dist/esm/tests/dwn.spec.js.map +1 -0
  201. package/dist/esm/tests/event-log/event-emitter-stream.spec.js +78 -0
  202. package/dist/esm/tests/event-log/event-emitter-stream.spec.js.map +1 -0
  203. package/dist/esm/tests/event-log/event-log-level.spec.js +44 -0
  204. package/dist/esm/tests/event-log/event-log-level.spec.js.map +1 -0
  205. package/dist/esm/tests/event-log/event-log.spec.js +236 -0
  206. package/dist/esm/tests/event-log/event-log.spec.js.map +1 -0
  207. package/dist/esm/tests/event-log/event-stream.spec.js +125 -0
  208. package/dist/esm/tests/event-log/event-stream.spec.js.map +1 -0
  209. package/dist/esm/tests/features/author-delegated-grant.spec.js +1273 -0
  210. package/dist/esm/tests/features/author-delegated-grant.spec.js.map +1 -0
  211. package/dist/esm/tests/features/owner-delegated-grant.spec.js +584 -0
  212. package/dist/esm/tests/features/owner-delegated-grant.spec.js.map +1 -0
  213. package/dist/esm/tests/features/owner-signature.spec.js +192 -0
  214. package/dist/esm/tests/features/owner-signature.spec.js.map +1 -0
  215. package/dist/esm/tests/features/permissions.spec.js +815 -0
  216. package/dist/esm/tests/features/permissions.spec.js.map +1 -0
  217. package/dist/esm/tests/features/protocol-create-action.spec.js +248 -0
  218. package/dist/esm/tests/features/protocol-create-action.spec.js.map +1 -0
  219. package/dist/esm/tests/features/protocol-delete-action.spec.js +492 -0
  220. package/dist/esm/tests/features/protocol-delete-action.spec.js.map +1 -0
  221. package/dist/esm/tests/features/protocol-update-action.spec.js +572 -0
  222. package/dist/esm/tests/features/protocol-update-action.spec.js.map +1 -0
  223. package/dist/esm/tests/features/records-prune.spec.js +812 -0
  224. package/dist/esm/tests/features/records-prune.spec.js.map +1 -0
  225. package/dist/esm/tests/features/records-tags.spec.js +2516 -0
  226. package/dist/esm/tests/features/records-tags.spec.js.map +1 -0
  227. package/dist/esm/tests/features/resumable-tasks.spec.js +349 -0
  228. package/dist/esm/tests/features/resumable-tasks.spec.js.map +1 -0
  229. package/dist/esm/tests/handlers/messages-query.spec.js +349 -0
  230. package/dist/esm/tests/handlers/messages-query.spec.js.map +1 -0
  231. package/dist/esm/tests/handlers/messages-read.spec.js +647 -0
  232. package/dist/esm/tests/handlers/messages-read.spec.js.map +1 -0
  233. package/dist/esm/tests/handlers/messages-subscribe.spec.js +432 -0
  234. package/dist/esm/tests/handlers/messages-subscribe.spec.js.map +1 -0
  235. package/dist/esm/tests/handlers/protocols-configure.spec.js +608 -0
  236. package/dist/esm/tests/handlers/protocols-configure.spec.js.map +1 -0
  237. package/dist/esm/tests/handlers/protocols-query.spec.js +454 -0
  238. package/dist/esm/tests/handlers/protocols-query.spec.js.map +1 -0
  239. package/dist/esm/tests/handlers/records-delete.spec.js +662 -0
  240. package/dist/esm/tests/handlers/records-delete.spec.js.map +1 -0
  241. package/dist/esm/tests/handlers/records-query.spec.js +2695 -0
  242. package/dist/esm/tests/handlers/records-query.spec.js.map +1 -0
  243. package/dist/esm/tests/handlers/records-read.spec.js +1724 -0
  244. package/dist/esm/tests/handlers/records-read.spec.js.map +1 -0
  245. package/dist/esm/tests/handlers/records-subscribe.spec.js +684 -0
  246. package/dist/esm/tests/handlers/records-subscribe.spec.js.map +1 -0
  247. package/dist/esm/tests/handlers/records-write.spec.js +3637 -0
  248. package/dist/esm/tests/handlers/records-write.spec.js.map +1 -0
  249. package/dist/esm/tests/interfaces/messages-get.spec.js +78 -0
  250. package/dist/esm/tests/interfaces/messages-get.spec.js.map +1 -0
  251. package/dist/esm/tests/interfaces/messages-subscribe.spec.js +30 -0
  252. package/dist/esm/tests/interfaces/messages-subscribe.spec.js.map +1 -0
  253. package/dist/esm/tests/interfaces/messagess-query.spec.js +127 -0
  254. package/dist/esm/tests/interfaces/messagess-query.spec.js.map +1 -0
  255. package/dist/esm/tests/interfaces/protocols-configure.spec.js +489 -0
  256. package/dist/esm/tests/interfaces/protocols-configure.spec.js.map +1 -0
  257. package/dist/esm/tests/interfaces/protocols-query.spec.js +46 -0
  258. package/dist/esm/tests/interfaces/protocols-query.spec.js.map +1 -0
  259. package/dist/esm/tests/interfaces/records-delete.spec.js +39 -0
  260. package/dist/esm/tests/interfaces/records-delete.spec.js.map +1 -0
  261. package/dist/esm/tests/interfaces/records-query.spec.js +85 -0
  262. package/dist/esm/tests/interfaces/records-query.spec.js.map +1 -0
  263. package/dist/esm/tests/interfaces/records-read.spec.js +62 -0
  264. package/dist/esm/tests/interfaces/records-read.spec.js.map +1 -0
  265. package/dist/esm/tests/interfaces/records-subscribe.spec.js +72 -0
  266. package/dist/esm/tests/interfaces/records-subscribe.spec.js.map +1 -0
  267. package/dist/esm/tests/interfaces/records-write.spec.js +423 -0
  268. package/dist/esm/tests/interfaces/records-write.spec.js.map +1 -0
  269. package/dist/esm/tests/jose/jws/general.spec.js +243 -0
  270. package/dist/esm/tests/jose/jws/general.spec.js.map +1 -0
  271. package/dist/esm/tests/protocols/permission-request.spec.js +40 -0
  272. package/dist/esm/tests/protocols/permission-request.spec.js.map +1 -0
  273. package/dist/esm/tests/protocols/permissions.spec.js +123 -0
  274. package/dist/esm/tests/protocols/permissions.spec.js.map +1 -0
  275. package/dist/esm/tests/scenarios/aggregator.spec.js +670 -0
  276. package/dist/esm/tests/scenarios/aggregator.spec.js.map +1 -0
  277. package/dist/esm/tests/scenarios/deleted-record.spec.js +102 -0
  278. package/dist/esm/tests/scenarios/deleted-record.spec.js.map +1 -0
  279. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js +220 -0
  280. package/dist/esm/tests/scenarios/end-to-end-tests.spec.js.map +1 -0
  281. package/dist/esm/tests/scenarios/messages-query.spec.js +395 -0
  282. package/dist/esm/tests/scenarios/messages-query.spec.js.map +1 -0
  283. package/dist/esm/tests/scenarios/nested-roles.spec.js +300 -0
  284. package/dist/esm/tests/scenarios/nested-roles.spec.js.map +1 -0
  285. package/dist/esm/tests/scenarios/subscriptions.spec.js +886 -0
  286. package/dist/esm/tests/scenarios/subscriptions.spec.js.map +1 -0
  287. package/dist/esm/tests/store/blockstore-mock.spec.js +192 -0
  288. package/dist/esm/tests/store/blockstore-mock.spec.js.map +1 -0
  289. package/dist/esm/tests/store/data-store-level.spec.js +146 -0
  290. package/dist/esm/tests/store/data-store-level.spec.js.map +1 -0
  291. package/dist/esm/tests/store/index-level.spec.js +1208 -0
  292. package/dist/esm/tests/store/index-level.spec.js.map +1 -0
  293. package/dist/esm/tests/store/message-store-level.spec.js +48 -0
  294. package/dist/esm/tests/store/message-store-level.spec.js.map +1 -0
  295. package/dist/esm/tests/store/message-store.spec.js +404 -0
  296. package/dist/esm/tests/store/message-store.spec.js.map +1 -0
  297. package/dist/esm/tests/store-dependent-tests.spec.js +5 -0
  298. package/dist/esm/tests/store-dependent-tests.spec.js.map +1 -0
  299. package/dist/esm/tests/test-event-stream.js +25 -0
  300. package/dist/esm/tests/test-event-stream.js.map +1 -0
  301. package/dist/esm/tests/test-stores.js +45 -0
  302. package/dist/esm/tests/test-stores.js.map +1 -0
  303. package/dist/esm/tests/test-suite.js +88 -0
  304. package/dist/esm/tests/test-suite.js.map +1 -0
  305. package/dist/esm/tests/utils/cid.spec.js +80 -0
  306. package/dist/esm/tests/utils/cid.spec.js.map +1 -0
  307. package/dist/esm/tests/utils/data-stream.spec.js +27 -0
  308. package/dist/esm/tests/utils/data-stream.spec.js.map +1 -0
  309. package/dist/esm/tests/utils/encryption.spec.js +148 -0
  310. package/dist/esm/tests/utils/encryption.spec.js.map +1 -0
  311. package/dist/esm/tests/utils/filters.spec.js +295 -0
  312. package/dist/esm/tests/utils/filters.spec.js.map +1 -0
  313. package/dist/esm/tests/utils/hd-key.spec.js +35 -0
  314. package/dist/esm/tests/utils/hd-key.spec.js.map +1 -0
  315. package/dist/esm/tests/utils/jws.spec.js +8 -0
  316. package/dist/esm/tests/utils/jws.spec.js.map +1 -0
  317. package/dist/esm/tests/utils/memory-cache.spec.js +35 -0
  318. package/dist/esm/tests/utils/memory-cache.spec.js.map +1 -0
  319. package/dist/esm/tests/utils/messages.spec.js +101 -0
  320. package/dist/esm/tests/utils/messages.spec.js.map +1 -0
  321. package/dist/esm/tests/utils/object.spec.js +36 -0
  322. package/dist/esm/tests/utils/object.spec.js.map +1 -0
  323. package/dist/esm/tests/utils/poller.js +49 -0
  324. package/dist/esm/tests/utils/poller.js.map +1 -0
  325. package/dist/esm/tests/utils/private-key-signer.spec.js +44 -0
  326. package/dist/esm/tests/utils/private-key-signer.spec.js.map +1 -0
  327. package/dist/esm/tests/utils/records.spec.js +53 -0
  328. package/dist/esm/tests/utils/records.spec.js.map +1 -0
  329. package/dist/esm/tests/utils/secp256k1.spec.js +50 -0
  330. package/dist/esm/tests/utils/secp256k1.spec.js.map +1 -0
  331. package/dist/esm/tests/utils/secp256r1.spec.js +56 -0
  332. package/dist/esm/tests/utils/secp256r1.spec.js.map +1 -0
  333. package/dist/esm/tests/utils/test-data-generator.js +643 -0
  334. package/dist/esm/tests/utils/test-data-generator.js.map +1 -0
  335. package/dist/esm/tests/utils/test-stub-generator.js +39 -0
  336. package/dist/esm/tests/utils/test-stub-generator.js.map +1 -0
  337. package/dist/esm/tests/utils/time.spec.js +64 -0
  338. package/dist/esm/tests/utils/time.spec.js.map +1 -0
  339. package/dist/esm/tests/utils/url.spec.js +43 -0
  340. package/dist/esm/tests/utils/url.spec.js.map +1 -0
  341. package/dist/esm/tests/validation/json-schemas/definitions.spec.js +33 -0
  342. package/dist/esm/tests/validation/json-schemas/definitions.spec.js.map +1 -0
  343. package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js +50 -0
  344. package/dist/esm/tests/validation/json-schemas/jwk/general-jwk.spec.js.map +1 -0
  345. package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js +36 -0
  346. package/dist/esm/tests/validation/json-schemas/jwk/public-jwk.spec.js.map +1 -0
  347. package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js +82 -0
  348. package/dist/esm/tests/validation/json-schemas/jwk-verification-method.spec.js.map +1 -0
  349. package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js +75 -0
  350. package/dist/esm/tests/validation/json-schemas/protocols/protocols-configure.spec.js.map +1 -0
  351. package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js +148 -0
  352. package/dist/esm/tests/validation/json-schemas/records/records-query.spec.js.map +1 -0
  353. package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js +421 -0
  354. package/dist/esm/tests/validation/json-schemas/records/records-write.spec.js.map +1 -0
  355. package/dist/esm/tests/vectors/protocol-definitions/anyone-collaborate.json +21 -0
  356. package/dist/esm/tests/vectors/protocol-definitions/author-can.json +33 -0
  357. package/dist/esm/tests/vectors/protocol-definitions/chat.json +70 -0
  358. package/dist/esm/tests/vectors/protocol-definitions/credential-issuance.json +41 -0
  359. package/dist/esm/tests/vectors/protocol-definitions/dex.json +58 -0
  360. package/dist/esm/tests/vectors/protocol-definitions/email.json +62 -0
  361. package/dist/esm/tests/vectors/protocol-definitions/free-for-all.json +45 -0
  362. package/dist/esm/tests/vectors/protocol-definitions/friend-role.json +48 -0
  363. package/dist/esm/tests/vectors/protocol-definitions/message.json +37 -0
  364. package/dist/esm/tests/vectors/protocol-definitions/minimal.json +10 -0
  365. package/dist/esm/tests/vectors/protocol-definitions/nested.json +31 -0
  366. package/dist/esm/tests/vectors/protocol-definitions/private-protocol.json +15 -0
  367. package/dist/esm/tests/vectors/protocol-definitions/recipient-can.json +33 -0
  368. package/dist/esm/tests/vectors/protocol-definitions/slack.json +242 -0
  369. package/dist/esm/tests/vectors/protocol-definitions/social-media.json +106 -0
  370. package/dist/esm/tests/vectors/protocol-definitions/thread-role.json +70 -0
  371. package/dist/types/generated/precompiled-validators.d.ts +597 -0
  372. package/dist/types/generated/precompiled-validators.d.ts.map +1 -0
  373. package/dist/types/src/core/abstract-message.d.ts +25 -0
  374. package/dist/types/src/core/abstract-message.d.ts.map +1 -0
  375. package/dist/types/src/core/auth.d.ts +9 -0
  376. package/dist/types/src/core/auth.d.ts.map +1 -0
  377. package/dist/types/src/core/dwn-constant.d.ts +10 -0
  378. package/dist/types/src/core/dwn-constant.d.ts.map +1 -0
  379. package/dist/types/src/core/dwn-error.d.ts +164 -0
  380. package/dist/types/src/core/dwn-error.d.ts.map +1 -0
  381. package/dist/types/src/core/grant-authorization.d.ts +43 -0
  382. package/dist/types/src/core/grant-authorization.d.ts.map +1 -0
  383. package/dist/types/src/core/message-reply.d.ts +32 -0
  384. package/dist/types/src/core/message-reply.d.ts.map +1 -0
  385. package/dist/types/src/core/message.d.ts +94 -0
  386. package/dist/types/src/core/message.d.ts.map +1 -0
  387. package/dist/types/src/core/messages-grant-authorization.d.ts +34 -0
  388. package/dist/types/src/core/messages-grant-authorization.d.ts.map +1 -0
  389. package/dist/types/src/core/protocol-authorization.d.ts +103 -0
  390. package/dist/types/src/core/protocol-authorization.d.ts.map +1 -0
  391. package/dist/types/src/core/protocols-grant-authorization.d.ts +31 -0
  392. package/dist/types/src/core/protocols-grant-authorization.d.ts.map +1 -0
  393. package/dist/types/src/core/records-grant-authorization.d.ts +60 -0
  394. package/dist/types/src/core/records-grant-authorization.d.ts.map +1 -0
  395. package/dist/types/src/core/resumable-task-manager.d.ts +43 -0
  396. package/dist/types/src/core/resumable-task-manager.d.ts.map +1 -0
  397. package/dist/types/src/core/tenant-gate.d.ts +29 -0
  398. package/dist/types/src/core/tenant-gate.d.ts.map +1 -0
  399. package/dist/types/src/dwn.d.ts +85 -0
  400. package/dist/types/src/dwn.d.ts.map +1 -0
  401. package/dist/types/src/enums/dwn-interface-method.d.ts +14 -0
  402. package/dist/types/src/enums/dwn-interface-method.d.ts.map +1 -0
  403. package/dist/types/src/event-log/event-emitter-stream.d.ts +23 -0
  404. package/dist/types/src/event-log/event-emitter-stream.d.ts.map +1 -0
  405. package/dist/types/src/event-log/event-log-level.d.ts +35 -0
  406. package/dist/types/src/event-log/event-log-level.d.ts.map +1 -0
  407. package/dist/types/src/handlers/messages-query.d.ts +17 -0
  408. package/dist/types/src/handlers/messages-query.d.ts.map +1 -0
  409. package/dist/types/src/handlers/messages-read.d.ts +22 -0
  410. package/dist/types/src/handlers/messages-read.d.ts.map +1 -0
  411. package/dist/types/src/handlers/messages-subscribe.d.ts +18 -0
  412. package/dist/types/src/handlers/messages-subscribe.d.ts.map +1 -0
  413. package/dist/types/src/handlers/protocols-configure.d.ts +24 -0
  414. package/dist/types/src/handlers/protocols-configure.d.ts.map +1 -0
  415. package/dist/types/src/handlers/protocols-query.d.ts +20 -0
  416. package/dist/types/src/handlers/protocols-query.d.ts.map +1 -0
  417. package/dist/types/src/handlers/records-delete.d.ts +23 -0
  418. package/dist/types/src/handlers/records-delete.d.ts.map +1 -0
  419. package/dist/types/src/handlers/records-query.d.ts +70 -0
  420. package/dist/types/src/handlers/records-query.d.ts.map +1 -0
  421. package/dist/types/src/handlers/records-read.d.ts +20 -0
  422. package/dist/types/src/handlers/records-read.d.ts.map +1 -0
  423. package/dist/types/src/handlers/records-subscribe.d.ts +62 -0
  424. package/dist/types/src/handlers/records-subscribe.d.ts.map +1 -0
  425. package/dist/types/src/handlers/records-write.d.ts +51 -0
  426. package/dist/types/src/handlers/records-write.d.ts.map +1 -0
  427. package/dist/types/src/index.d.ts +63 -0
  428. package/dist/types/src/index.d.ts.map +1 -0
  429. package/dist/types/src/interfaces/messages-query.d.ts +16 -0
  430. package/dist/types/src/interfaces/messages-query.d.ts.map +1 -0
  431. package/dist/types/src/interfaces/messages-read.d.ts +20 -0
  432. package/dist/types/src/interfaces/messages-read.d.ts.map +1 -0
  433. package/dist/types/src/interfaces/messages-subscribe.d.ts +20 -0
  434. package/dist/types/src/interfaces/messages-subscribe.d.ts.map +1 -0
  435. package/dist/types/src/interfaces/protocols-configure.d.ts +40 -0
  436. package/dist/types/src/interfaces/protocols-configure.d.ts.map +1 -0
  437. package/dist/types/src/interfaces/protocols-query.d.ts +17 -0
  438. package/dist/types/src/interfaces/protocols-query.d.ts.map +1 -0
  439. package/dist/types/src/interfaces/records-delete.d.ts +34 -0
  440. package/dist/types/src/interfaces/records-delete.d.ts.map +1 -0
  441. package/dist/types/src/interfaces/records-query.d.ts +31 -0
  442. package/dist/types/src/interfaces/records-query.d.ts.map +1 -0
  443. package/dist/types/src/interfaces/records-read.d.ts +36 -0
  444. package/dist/types/src/interfaces/records-read.d.ts.map +1 -0
  445. package/dist/types/src/interfaces/records-subscribe.d.ts +27 -0
  446. package/dist/types/src/interfaces/records-subscribe.d.ts.map +1 -0
  447. package/dist/types/src/interfaces/records-write.d.ts +309 -0
  448. package/dist/types/src/interfaces/records-write.d.ts.map +1 -0
  449. package/dist/types/src/jose/algorithms/signing/ed25519.d.ts +3 -0
  450. package/dist/types/src/jose/algorithms/signing/ed25519.d.ts.map +1 -0
  451. package/dist/types/src/jose/algorithms/signing/signature-algorithms.d.ts +3 -0
  452. package/dist/types/src/jose/algorithms/signing/signature-algorithms.d.ts.map +1 -0
  453. package/dist/types/src/jose/jws/general/builder.d.ts +10 -0
  454. package/dist/types/src/jose/jws/general/builder.d.ts.map +1 -0
  455. package/dist/types/src/jose/jws/general/verifier.d.ts +32 -0
  456. package/dist/types/src/jose/jws/general/verifier.d.ts.map +1 -0
  457. package/dist/types/src/protocols/permission-grant.d.ts +50 -0
  458. package/dist/types/src/protocols/permission-grant.d.ts.map +1 -0
  459. package/dist/types/src/protocols/permission-request.d.ts +35 -0
  460. package/dist/types/src/protocols/permission-request.d.ts.map +1 -0
  461. package/dist/types/src/protocols/permissions.d.ts +150 -0
  462. package/dist/types/src/protocols/permissions.d.ts.map +1 -0
  463. package/dist/types/src/schema-validator.d.ts +8 -0
  464. package/dist/types/src/schema-validator.d.ts.map +1 -0
  465. package/dist/types/src/store/blockstore-level.d.ts +34 -0
  466. package/dist/types/src/store/blockstore-level.d.ts.map +1 -0
  467. package/dist/types/src/store/blockstore-mock.d.ts +27 -0
  468. package/dist/types/src/store/blockstore-mock.d.ts.map +1 -0
  469. package/dist/types/src/store/data-store-level.d.ts +34 -0
  470. package/dist/types/src/store/data-store-level.d.ts.map +1 -0
  471. package/dist/types/src/store/index-level.d.ts +171 -0
  472. package/dist/types/src/store/index-level.d.ts.map +1 -0
  473. package/dist/types/src/store/level-wrapper.d.ts +48 -0
  474. package/dist/types/src/store/level-wrapper.d.ts.map +1 -0
  475. package/dist/types/src/store/message-store-level.d.ts +46 -0
  476. package/dist/types/src/store/message-store-level.d.ts.map +1 -0
  477. package/dist/types/src/store/resumable-task-store-level.d.ts +28 -0
  478. package/dist/types/src/store/resumable-task-store-level.d.ts.map +1 -0
  479. package/dist/types/src/store/storage-controller.d.ts +46 -0
  480. package/dist/types/src/store/storage-controller.d.ts.map +1 -0
  481. package/dist/types/src/types/cache.d.ts +16 -0
  482. package/dist/types/src/types/cache.d.ts.map +1 -0
  483. package/dist/types/src/types/data-store.d.ts +57 -0
  484. package/dist/types/src/types/data-store.d.ts.map +1 -0
  485. package/dist/types/src/types/event-log.d.ts +52 -0
  486. package/dist/types/src/types/event-log.d.ts.map +1 -0
  487. package/dist/types/src/types/jose-types.d.ts +75 -0
  488. package/dist/types/src/types/jose-types.d.ts.map +1 -0
  489. package/dist/types/src/types/jws-types.d.ts +27 -0
  490. package/dist/types/src/types/jws-types.d.ts.map +1 -0
  491. package/dist/types/src/types/message-interface.d.ts +27 -0
  492. package/dist/types/src/types/message-interface.d.ts.map +1 -0
  493. package/dist/types/src/types/message-store.d.ts +42 -0
  494. package/dist/types/src/types/message-store.d.ts.map +1 -0
  495. package/dist/types/src/types/message-types.d.ts +116 -0
  496. package/dist/types/src/types/message-types.d.ts.map +1 -0
  497. package/dist/types/src/types/messages-types.d.ts +65 -0
  498. package/dist/types/src/types/messages-types.d.ts.map +1 -0
  499. package/dist/types/src/types/method-handler.d.ts +19 -0
  500. package/dist/types/src/types/method-handler.d.ts.map +1 -0
  501. package/dist/types/src/types/permission-types.d.ts +93 -0
  502. package/dist/types/src/types/permission-types.d.ts.map +1 -0
  503. package/dist/types/src/types/protocols-types.d.ts +154 -0
  504. package/dist/types/src/types/protocols-types.d.ts.map +1 -0
  505. package/dist/types/src/types/query-types.d.ts +66 -0
  506. package/dist/types/src/types/query-types.d.ts.map +1 -0
  507. package/dist/types/src/types/records-types.d.ts +230 -0
  508. package/dist/types/src/types/records-types.d.ts.map +1 -0
  509. package/dist/types/src/types/resumable-task-store.d.ts +89 -0
  510. package/dist/types/src/types/resumable-task-store.d.ts.map +1 -0
  511. package/dist/types/src/types/signer.d.ts +26 -0
  512. package/dist/types/src/types/signer.d.ts.map +1 -0
  513. package/dist/types/src/types/subscriptions.d.ts +30 -0
  514. package/dist/types/src/types/subscriptions.d.ts.map +1 -0
  515. package/dist/types/src/utils/abort.d.ts +5 -0
  516. package/dist/types/src/utils/abort.d.ts.map +1 -0
  517. package/dist/types/src/utils/array.d.ts +18 -0
  518. package/dist/types/src/utils/array.d.ts.map +1 -0
  519. package/dist/types/src/utils/cid.d.ts +30 -0
  520. package/dist/types/src/utils/cid.d.ts.map +1 -0
  521. package/dist/types/src/utils/data-stream.d.ts +31 -0
  522. package/dist/types/src/utils/data-stream.d.ts.map +1 -0
  523. package/dist/types/src/utils/encoder.d.ts +14 -0
  524. package/dist/types/src/utils/encoder.d.ts.map +1 -0
  525. package/dist/types/src/utils/encryption.d.ts +44 -0
  526. package/dist/types/src/utils/encryption.d.ts.map +1 -0
  527. package/dist/types/src/utils/filter.d.ts +60 -0
  528. package/dist/types/src/utils/filter.d.ts.map +1 -0
  529. package/dist/types/src/utils/hd-key.d.ts +54 -0
  530. package/dist/types/src/utils/hd-key.d.ts.map +1 -0
  531. package/dist/types/src/utils/jws.d.ts +39 -0
  532. package/dist/types/src/utils/jws.d.ts.map +1 -0
  533. package/dist/types/src/utils/memory-cache.d.ts +15 -0
  534. package/dist/types/src/utils/memory-cache.d.ts.map +1 -0
  535. package/dist/types/src/utils/messages.d.ts +27 -0
  536. package/dist/types/src/utils/messages.d.ts.map +1 -0
  537. package/dist/types/src/utils/object.d.ts +13 -0
  538. package/dist/types/src/utils/object.d.ts.map +1 -0
  539. package/dist/types/src/utils/private-key-signer.d.ts +34 -0
  540. package/dist/types/src/utils/private-key-signer.d.ts.map +1 -0
  541. package/dist/types/src/utils/protocols.d.ts +14 -0
  542. package/dist/types/src/utils/protocols.d.ts.map +1 -0
  543. package/dist/types/src/utils/records.d.ts +122 -0
  544. package/dist/types/src/utils/records.d.ts.map +1 -0
  545. package/dist/types/src/utils/secp256k1.d.ts +59 -0
  546. package/dist/types/src/utils/secp256k1.d.ts.map +1 -0
  547. package/dist/types/src/utils/secp256r1.d.ts +39 -0
  548. package/dist/types/src/utils/secp256r1.d.ts.map +1 -0
  549. package/dist/types/src/utils/string.d.ts +6 -0
  550. package/dist/types/src/utils/string.d.ts.map +1 -0
  551. package/dist/types/src/utils/time.d.ts +50 -0
  552. package/dist/types/src/utils/time.d.ts.map +1 -0
  553. package/dist/types/src/utils/url.d.ts +5 -0
  554. package/dist/types/src/utils/url.d.ts.map +1 -0
  555. package/dist/types/tests/core/auth.spec.d.ts +2 -0
  556. package/dist/types/tests/core/auth.spec.d.ts.map +1 -0
  557. package/dist/types/tests/core/message-reply.spec.d.ts +2 -0
  558. package/dist/types/tests/core/message-reply.spec.d.ts.map +1 -0
  559. package/dist/types/tests/core/message.spec.d.ts +2 -0
  560. package/dist/types/tests/core/message.spec.d.ts.map +1 -0
  561. package/dist/types/tests/core/protocol-authorization.spec.d.ts +2 -0
  562. package/dist/types/tests/core/protocol-authorization.spec.d.ts.map +1 -0
  563. package/dist/types/tests/dwn.spec.d.ts +2 -0
  564. package/dist/types/tests/dwn.spec.d.ts.map +1 -0
  565. package/dist/types/tests/event-log/event-emitter-stream.spec.d.ts +2 -0
  566. package/dist/types/tests/event-log/event-emitter-stream.spec.d.ts.map +1 -0
  567. package/dist/types/tests/event-log/event-log-level.spec.d.ts +2 -0
  568. package/dist/types/tests/event-log/event-log-level.spec.d.ts.map +1 -0
  569. package/dist/types/tests/event-log/event-log.spec.d.ts +2 -0
  570. package/dist/types/tests/event-log/event-log.spec.d.ts.map +1 -0
  571. package/dist/types/tests/event-log/event-stream.spec.d.ts +2 -0
  572. package/dist/types/tests/event-log/event-stream.spec.d.ts.map +1 -0
  573. package/dist/types/tests/features/author-delegated-grant.spec.d.ts +2 -0
  574. package/dist/types/tests/features/author-delegated-grant.spec.d.ts.map +1 -0
  575. package/dist/types/tests/features/owner-delegated-grant.spec.d.ts +2 -0
  576. package/dist/types/tests/features/owner-delegated-grant.spec.d.ts.map +1 -0
  577. package/dist/types/tests/features/owner-signature.spec.d.ts +2 -0
  578. package/dist/types/tests/features/owner-signature.spec.d.ts.map +1 -0
  579. package/dist/types/tests/features/permissions.spec.d.ts +2 -0
  580. package/dist/types/tests/features/permissions.spec.d.ts.map +1 -0
  581. package/dist/types/tests/features/protocol-create-action.spec.d.ts +2 -0
  582. package/dist/types/tests/features/protocol-create-action.spec.d.ts.map +1 -0
  583. package/dist/types/tests/features/protocol-delete-action.spec.d.ts +2 -0
  584. package/dist/types/tests/features/protocol-delete-action.spec.d.ts.map +1 -0
  585. package/dist/types/tests/features/protocol-update-action.spec.d.ts +2 -0
  586. package/dist/types/tests/features/protocol-update-action.spec.d.ts.map +1 -0
  587. package/dist/types/tests/features/records-prune.spec.d.ts +2 -0
  588. package/dist/types/tests/features/records-prune.spec.d.ts.map +1 -0
  589. package/dist/types/tests/features/records-tags.spec.d.ts +2 -0
  590. package/dist/types/tests/features/records-tags.spec.d.ts.map +1 -0
  591. package/dist/types/tests/features/resumable-tasks.spec.d.ts +2 -0
  592. package/dist/types/tests/features/resumable-tasks.spec.d.ts.map +1 -0
  593. package/dist/types/tests/handlers/messages-query.spec.d.ts +2 -0
  594. package/dist/types/tests/handlers/messages-query.spec.d.ts.map +1 -0
  595. package/dist/types/tests/handlers/messages-read.spec.d.ts +2 -0
  596. package/dist/types/tests/handlers/messages-read.spec.d.ts.map +1 -0
  597. package/dist/types/tests/handlers/messages-subscribe.spec.d.ts +2 -0
  598. package/dist/types/tests/handlers/messages-subscribe.spec.d.ts.map +1 -0
  599. package/dist/types/tests/handlers/protocols-configure.spec.d.ts +2 -0
  600. package/dist/types/tests/handlers/protocols-configure.spec.d.ts.map +1 -0
  601. package/dist/types/tests/handlers/protocols-query.spec.d.ts +2 -0
  602. package/dist/types/tests/handlers/protocols-query.spec.d.ts.map +1 -0
  603. package/dist/types/tests/handlers/records-delete.spec.d.ts +2 -0
  604. package/dist/types/tests/handlers/records-delete.spec.d.ts.map +1 -0
  605. package/dist/types/tests/handlers/records-query.spec.d.ts +2 -0
  606. package/dist/types/tests/handlers/records-query.spec.d.ts.map +1 -0
  607. package/dist/types/tests/handlers/records-read.spec.d.ts +2 -0
  608. package/dist/types/tests/handlers/records-read.spec.d.ts.map +1 -0
  609. package/dist/types/tests/handlers/records-subscribe.spec.d.ts +2 -0
  610. package/dist/types/tests/handlers/records-subscribe.spec.d.ts.map +1 -0
  611. package/dist/types/tests/handlers/records-write.spec.d.ts +2 -0
  612. package/dist/types/tests/handlers/records-write.spec.d.ts.map +1 -0
  613. package/dist/types/tests/interfaces/messages-get.spec.d.ts +2 -0
  614. package/dist/types/tests/interfaces/messages-get.spec.d.ts.map +1 -0
  615. package/dist/types/tests/interfaces/messages-subscribe.spec.d.ts +2 -0
  616. package/dist/types/tests/interfaces/messages-subscribe.spec.d.ts.map +1 -0
  617. package/dist/types/tests/interfaces/messagess-query.spec.d.ts +2 -0
  618. package/dist/types/tests/interfaces/messagess-query.spec.d.ts.map +1 -0
  619. package/dist/types/tests/interfaces/protocols-configure.spec.d.ts +2 -0
  620. package/dist/types/tests/interfaces/protocols-configure.spec.d.ts.map +1 -0
  621. package/dist/types/tests/interfaces/protocols-query.spec.d.ts +2 -0
  622. package/dist/types/tests/interfaces/protocols-query.spec.d.ts.map +1 -0
  623. package/dist/types/tests/interfaces/records-delete.spec.d.ts +2 -0
  624. package/dist/types/tests/interfaces/records-delete.spec.d.ts.map +1 -0
  625. package/dist/types/tests/interfaces/records-query.spec.d.ts +2 -0
  626. package/dist/types/tests/interfaces/records-query.spec.d.ts.map +1 -0
  627. package/dist/types/tests/interfaces/records-read.spec.d.ts +2 -0
  628. package/dist/types/tests/interfaces/records-read.spec.d.ts.map +1 -0
  629. package/dist/types/tests/interfaces/records-subscribe.spec.d.ts +2 -0
  630. package/dist/types/tests/interfaces/records-subscribe.spec.d.ts.map +1 -0
  631. package/dist/types/tests/interfaces/records-write.spec.d.ts +2 -0
  632. package/dist/types/tests/interfaces/records-write.spec.d.ts.map +1 -0
  633. package/dist/types/tests/jose/jws/general.spec.d.ts +2 -0
  634. package/dist/types/tests/jose/jws/general.spec.d.ts.map +1 -0
  635. package/dist/types/tests/protocols/permission-request.spec.d.ts +2 -0
  636. package/dist/types/tests/protocols/permission-request.spec.d.ts.map +1 -0
  637. package/dist/types/tests/protocols/permissions.spec.d.ts +2 -0
  638. package/dist/types/tests/protocols/permissions.spec.d.ts.map +1 -0
  639. package/dist/types/tests/scenarios/aggregator.spec.d.ts +2 -0
  640. package/dist/types/tests/scenarios/aggregator.spec.d.ts.map +1 -0
  641. package/dist/types/tests/scenarios/deleted-record.spec.d.ts +2 -0
  642. package/dist/types/tests/scenarios/deleted-record.spec.d.ts.map +1 -0
  643. package/dist/types/tests/scenarios/end-to-end-tests.spec.d.ts +2 -0
  644. package/dist/types/tests/scenarios/end-to-end-tests.spec.d.ts.map +1 -0
  645. package/dist/types/tests/scenarios/messages-query.spec.d.ts +2 -0
  646. package/dist/types/tests/scenarios/messages-query.spec.d.ts.map +1 -0
  647. package/dist/types/tests/scenarios/nested-roles.spec.d.ts +2 -0
  648. package/dist/types/tests/scenarios/nested-roles.spec.d.ts.map +1 -0
  649. package/dist/types/tests/scenarios/subscriptions.spec.d.ts +2 -0
  650. package/dist/types/tests/scenarios/subscriptions.spec.d.ts.map +1 -0
  651. package/dist/types/tests/store/blockstore-mock.spec.d.ts +2 -0
  652. package/dist/types/tests/store/blockstore-mock.spec.d.ts.map +1 -0
  653. package/dist/types/tests/store/data-store-level.spec.d.ts +2 -0
  654. package/dist/types/tests/store/data-store-level.spec.d.ts.map +1 -0
  655. package/dist/types/tests/store/index-level.spec.d.ts +2 -0
  656. package/dist/types/tests/store/index-level.spec.d.ts.map +1 -0
  657. package/dist/types/tests/store/message-store-level.spec.d.ts +2 -0
  658. package/dist/types/tests/store/message-store-level.spec.d.ts.map +1 -0
  659. package/dist/types/tests/store/message-store.spec.d.ts +2 -0
  660. package/dist/types/tests/store/message-store.spec.d.ts.map +1 -0
  661. package/dist/types/tests/store-dependent-tests.spec.d.ts +2 -0
  662. package/dist/types/tests/store-dependent-tests.spec.d.ts.map +1 -0
  663. package/dist/types/tests/test-event-stream.d.ts +22 -0
  664. package/dist/types/tests/test-event-stream.d.ts.map +1 -0
  665. package/dist/types/tests/test-stores.d.ts +33 -0
  666. package/dist/types/tests/test-stores.d.ts.map +1 -0
  667. package/dist/types/tests/test-suite.d.ts +18 -0
  668. package/dist/types/tests/test-suite.d.ts.map +1 -0
  669. package/dist/types/tests/utils/cid.spec.d.ts +2 -0
  670. package/dist/types/tests/utils/cid.spec.d.ts.map +1 -0
  671. package/dist/types/tests/utils/data-stream.spec.d.ts +2 -0
  672. package/dist/types/tests/utils/data-stream.spec.d.ts.map +1 -0
  673. package/dist/types/tests/utils/encryption.spec.d.ts +2 -0
  674. package/dist/types/tests/utils/encryption.spec.d.ts.map +1 -0
  675. package/dist/types/tests/utils/filters.spec.d.ts +2 -0
  676. package/dist/types/tests/utils/filters.spec.d.ts.map +1 -0
  677. package/dist/types/tests/utils/hd-key.spec.d.ts +2 -0
  678. package/dist/types/tests/utils/hd-key.spec.d.ts.map +1 -0
  679. package/dist/types/tests/utils/jws.spec.d.ts +2 -0
  680. package/dist/types/tests/utils/jws.spec.d.ts.map +1 -0
  681. package/dist/types/tests/utils/memory-cache.spec.d.ts +2 -0
  682. package/dist/types/tests/utils/memory-cache.spec.d.ts.map +1 -0
  683. package/dist/types/tests/utils/messages.spec.d.ts +2 -0
  684. package/dist/types/tests/utils/messages.spec.d.ts.map +1 -0
  685. package/dist/types/tests/utils/object.spec.d.ts +2 -0
  686. package/dist/types/tests/utils/object.spec.d.ts.map +1 -0
  687. package/dist/types/tests/utils/poller.d.ts +21 -0
  688. package/dist/types/tests/utils/poller.d.ts.map +1 -0
  689. package/dist/types/tests/utils/private-key-signer.spec.d.ts +2 -0
  690. package/dist/types/tests/utils/private-key-signer.spec.d.ts.map +1 -0
  691. package/dist/types/tests/utils/records.spec.d.ts +2 -0
  692. package/dist/types/tests/utils/records.spec.d.ts.map +1 -0
  693. package/dist/types/tests/utils/secp256k1.spec.d.ts +2 -0
  694. package/dist/types/tests/utils/secp256k1.spec.d.ts.map +1 -0
  695. package/dist/types/tests/utils/secp256r1.spec.d.ts +2 -0
  696. package/dist/types/tests/utils/secp256r1.spec.d.ts.map +1 -0
  697. package/dist/types/tests/utils/test-data-generator.d.ts +342 -0
  698. package/dist/types/tests/utils/test-data-generator.d.ts.map +1 -0
  699. package/dist/types/tests/utils/test-stub-generator.d.ts +16 -0
  700. package/dist/types/tests/utils/test-stub-generator.d.ts.map +1 -0
  701. package/dist/types/tests/utils/time.spec.d.ts +2 -0
  702. package/dist/types/tests/utils/time.spec.d.ts.map +1 -0
  703. package/dist/types/tests/utils/url.spec.d.ts +2 -0
  704. package/dist/types/tests/utils/url.spec.d.ts.map +1 -0
  705. package/dist/types/tests/validation/json-schemas/definitions.spec.d.ts +2 -0
  706. package/dist/types/tests/validation/json-schemas/definitions.spec.d.ts.map +1 -0
  707. package/dist/types/tests/validation/json-schemas/jwk/general-jwk.spec.d.ts +2 -0
  708. package/dist/types/tests/validation/json-schemas/jwk/general-jwk.spec.d.ts.map +1 -0
  709. package/dist/types/tests/validation/json-schemas/jwk/public-jwk.spec.d.ts +2 -0
  710. package/dist/types/tests/validation/json-schemas/jwk/public-jwk.spec.d.ts.map +1 -0
  711. package/dist/types/tests/validation/json-schemas/jwk-verification-method.spec.d.ts +2 -0
  712. package/dist/types/tests/validation/json-schemas/jwk-verification-method.spec.d.ts.map +1 -0
  713. package/dist/types/tests/validation/json-schemas/protocols/protocols-configure.spec.d.ts +2 -0
  714. package/dist/types/tests/validation/json-schemas/protocols/protocols-configure.spec.d.ts.map +1 -0
  715. package/dist/types/tests/validation/json-schemas/records/records-query.spec.d.ts +2 -0
  716. package/dist/types/tests/validation/json-schemas/records/records-query.spec.d.ts.map +1 -0
  717. package/dist/types/tests/validation/json-schemas/records/records-write.spec.d.ts +2 -0
  718. package/dist/types/tests/validation/json-schemas/records/records-write.spec.d.ts.map +1 -0
  719. package/package.json +167 -0
  720. package/src/core/abstract-message.ts +62 -0
  721. package/src/core/auth.ts +36 -0
  722. package/src/core/dwn-constant.ts +9 -0
  723. package/src/core/dwn-error.ts +167 -0
  724. package/src/core/grant-authorization.ts +148 -0
  725. package/src/core/message-reply.ts +41 -0
  726. package/src/core/message.ts +259 -0
  727. package/src/core/messages-grant-authorization.ts +134 -0
  728. package/src/core/protocol-authorization.ts +903 -0
  729. package/src/core/protocols-grant-authorization.ts +88 -0
  730. package/src/core/records-grant-authorization.ts +197 -0
  731. package/src/core/resumable-task-manager.ts +114 -0
  732. package/src/core/tenant-gate.ts +33 -0
  733. package/src/dwn.ts +264 -0
  734. package/src/enums/dwn-interface-method.ts +14 -0
  735. package/src/event-log/event-emitter-stream.ts +69 -0
  736. package/src/event-log/event-log-level.ts +72 -0
  737. package/src/handlers/messages-query.ts +67 -0
  738. package/src/handlers/messages-read.ts +103 -0
  739. package/src/handlers/messages-subscribe.ts +89 -0
  740. package/src/handlers/protocols-configure.ts +137 -0
  741. package/src/handlers/protocols-query.ts +82 -0
  742. package/src/handlers/records-delete.ts +124 -0
  743. package/src/handlers/records-query.ts +262 -0
  744. package/src/handlers/records-read.ts +187 -0
  745. package/src/handlers/records-subscribe.ts +218 -0
  746. package/src/handlers/records-write.ts +404 -0
  747. package/src/index.ts +67 -0
  748. package/src/interfaces/messages-query.ts +60 -0
  749. package/src/interfaces/messages-read.ts +63 -0
  750. package/src/interfaces/messages-subscribe.ts +64 -0
  751. package/src/interfaces/protocols-configure.ts +340 -0
  752. package/src/interfaces/protocols-query.ts +96 -0
  753. package/src/interfaces/records-delete.ts +117 -0
  754. package/src/interfaces/records-query.ts +131 -0
  755. package/src/interfaces/records-read.ts +100 -0
  756. package/src/interfaces/records-subscribe.ts +104 -0
  757. package/src/interfaces/records-write.ts +1072 -0
  758. package/src/jose/algorithms/signing/ed25519.ts +58 -0
  759. package/src/jose/algorithms/signing/signature-algorithms.ts +22 -0
  760. package/src/jose/jws/general/builder.ts +48 -0
  761. package/src/jose/jws/general/verifier.ts +112 -0
  762. package/src/protocols/permission-grant.ts +86 -0
  763. package/src/protocols/permission-request.ts +63 -0
  764. package/src/protocols/permissions.ts +508 -0
  765. package/src/schema-validator.ts +46 -0
  766. package/src/store/blockstore-level.ts +113 -0
  767. package/src/store/blockstore-mock.ts +80 -0
  768. package/src/store/data-store-level.ts +120 -0
  769. package/src/store/index-level.ts +691 -0
  770. package/src/store/level-wrapper.ts +272 -0
  771. package/src/store/message-store-level.ts +195 -0
  772. package/src/store/resumable-task-store-level.ts +120 -0
  773. package/src/store/storage-controller.ts +240 -0
  774. package/src/types/cache.ts +16 -0
  775. package/src/types/data-store.ts +64 -0
  776. package/src/types/event-log.ts +52 -0
  777. package/src/types/jose-types.ts +76 -0
  778. package/src/types/jws-types.ts +28 -0
  779. package/src/types/message-interface.ts +30 -0
  780. package/src/types/message-store.ts +57 -0
  781. package/src/types/message-types.ts +132 -0
  782. package/src/types/messages-types.ts +77 -0
  783. package/src/types/method-handler.ts +19 -0
  784. package/src/types/permission-types.ts +110 -0
  785. package/src/types/protocols-types.ts +177 -0
  786. package/src/types/query-types.ts +61 -0
  787. package/src/types/records-types.ts +263 -0
  788. package/src/types/resumable-task-store.ts +96 -0
  789. package/src/types/signer.ts +27 -0
  790. package/src/types/subscriptions.ts +34 -0
  791. package/src/utils/abort.ts +31 -0
  792. package/src/utils/array.ts +39 -0
  793. package/src/utils/cid.ts +101 -0
  794. package/src/utils/data-stream.ts +99 -0
  795. package/src/utils/encoder.ts +54 -0
  796. package/src/utils/encryption.ts +145 -0
  797. package/src/utils/filter.ts +245 -0
  798. package/src/utils/hd-key.ts +126 -0
  799. package/src/utils/jws.ts +95 -0
  800. package/src/utils/memory-cache.ts +31 -0
  801. package/src/utils/messages.ts +109 -0
  802. package/src/utils/object.ts +43 -0
  803. package/src/utils/private-key-signer.ts +72 -0
  804. package/src/utils/protocols.ts +50 -0
  805. package/src/utils/records.ts +559 -0
  806. package/src/utils/secp256k1.ts +157 -0
  807. package/src/utils/secp256r1.ts +142 -0
  808. package/src/utils/string.ts +13 -0
  809. package/src/utils/time.ts +78 -0
  810. package/src/utils/url.ts +65 -0
package/LICENSE ADDED
@@ -0,0 +1,201 @@
1
+ Apache License
2
+ Version 2.0, January 2004
3
+ http://www.apache.org/licenses/
4
+
5
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6
+
7
+ 1. Definitions.
8
+
9
+ "License" shall mean the terms and conditions for use, reproduction,
10
+ and distribution as defined by Sections 1 through 9 of this document.
11
+
12
+ "Licensor" shall mean the copyright owner or entity authorized by
13
+ the copyright owner that is granting the License.
14
+
15
+ "Legal Entity" shall mean the union of the acting entity and all
16
+ other entities that control, are controlled by, or are under common
17
+ control with that entity. For the purposes of this definition,
18
+ "control" means (i) the power, direct or indirect, to cause the
19
+ direction or management of such entity, whether by contract or
20
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
21
+ outstanding shares, or (iii) beneficial ownership of such entity.
22
+
23
+ "You" (or "Your") shall mean an individual or Legal Entity
24
+ exercising permissions granted by this License.
25
+
26
+ "Source" form shall mean the preferred form for making modifications,
27
+ including but not limited to software source code, documentation
28
+ source, and configuration files.
29
+
30
+ "Object" form shall mean any form resulting from mechanical
31
+ transformation or translation of a Source form, including but
32
+ not limited to compiled object code, generated documentation,
33
+ and conversions to other media types.
34
+
35
+ "Work" shall mean the work of authorship, whether in Source or
36
+ Object form, made available under the License, as indicated by a
37
+ copyright notice that is included in or attached to the work
38
+ (an example is provided in the Appendix below).
39
+
40
+ "Derivative Works" shall mean any work, whether in Source or Object
41
+ form, that is based on (or derived from) the Work and for which the
42
+ editorial revisions, annotations, elaborations, or other modifications
43
+ represent, as a whole, an original work of authorship. For the purposes
44
+ of this License, Derivative Works shall not include works that remain
45
+ separable from, or merely link (or bind by name) to the interfaces of,
46
+ the Work and Derivative Works thereof.
47
+
48
+ "Contribution" shall mean any work of authorship, including
49
+ the original version of the Work and any modifications or additions
50
+ to that Work or Derivative Works thereof, that is intentionally
51
+ submitted to Licensor for inclusion in the Work by the copyright owner
52
+ or by an individual or Legal Entity authorized to submit on behalf of
53
+ the copyright owner. For the purposes of this definition, "submitted"
54
+ means any form of electronic, verbal, or written communication sent
55
+ to the Licensor or its representatives, including but not limited to
56
+ communication on electronic mailing lists, source code control systems,
57
+ and issue tracking systems that are managed by, or on behalf of, the
58
+ Licensor for the purpose of discussing and improving the Work, but
59
+ excluding communication that is conspicuously marked or otherwise
60
+ designated in writing by the copyright owner as "Not a Contribution."
61
+
62
+ "Contributor" shall mean Licensor and any individual or Legal Entity
63
+ on behalf of whom a Contribution has been received by Licensor and
64
+ subsequently incorporated within the Work.
65
+
66
+ 2. Grant of Copyright License. Subject to the terms and conditions of
67
+ this License, each Contributor hereby grants to You a perpetual,
68
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69
+ copyright license to reproduce, prepare Derivative Works of,
70
+ publicly display, publicly perform, sublicense, and distribute the
71
+ Work and such Derivative Works in Source or Object form.
72
+
73
+ 3. Grant of Patent License. Subject to the terms and conditions of
74
+ this License, each Contributor hereby grants to You a perpetual,
75
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76
+ (except as stated in this section) patent license to make, have made,
77
+ use, offer to sell, sell, import, and otherwise transfer the Work,
78
+ where such license applies only to those patent claims licensable
79
+ by such Contributor that are necessarily infringed by their
80
+ Contribution(s) alone or by combination of their Contribution(s)
81
+ with the Work to which such Contribution(s) was submitted. If You
82
+ institute patent litigation against any entity (including a
83
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
84
+ or a Contribution incorporated within the Work constitutes direct
85
+ or contributory patent infringement, then any patent licenses
86
+ granted to You under this License for that Work shall terminate
87
+ as of the date such litigation is filed.
88
+
89
+ 4. Redistribution. You may reproduce and distribute copies of the
90
+ Work or Derivative Works thereof in any medium, with or without
91
+ modifications, and in Source or Object form, provided that You
92
+ meet the following conditions:
93
+
94
+ (a) You must give any other recipients of the Work or
95
+ Derivative Works a copy of this License; and
96
+
97
+ (b) You must cause any modified files to carry prominent notices
98
+ stating that You changed the files; and
99
+
100
+ (c) You must retain, in the Source form of any Derivative Works
101
+ that You distribute, all copyright, patent, trademark, and
102
+ attribution notices from the Source form of the Work,
103
+ excluding those notices that do not pertain to any part of
104
+ the Derivative Works; and
105
+
106
+ (d) If the Work includes a "NOTICE" text file as part of its
107
+ distribution, then any Derivative Works that You distribute must
108
+ include a readable copy of the attribution notices contained
109
+ within such NOTICE file, excluding those notices that do not
110
+ pertain to any part of the Derivative Works, in at least one
111
+ of the following places: within a NOTICE text file distributed
112
+ as part of the Derivative Works; within the Source form or
113
+ documentation, if provided along with the Derivative Works; or,
114
+ within a display generated by the Derivative Works, if and
115
+ wherever such third-party notices normally appear. The contents
116
+ of the NOTICE file are for informational purposes only and
117
+ do not modify the License. You may add Your own attribution
118
+ notices within Derivative Works that You distribute, alongside
119
+ or as an addendum to the NOTICE text from the Work, provided
120
+ that such additional attribution notices cannot be construed
121
+ as modifying the License.
122
+
123
+ You may add Your own copyright statement to Your modifications and
124
+ may provide additional or different license terms and conditions
125
+ for use, reproduction, or distribution of Your modifications, or
126
+ for any such Derivative Works as a whole, provided Your use,
127
+ reproduction, and distribution of the Work otherwise complies with
128
+ the conditions stated in this License.
129
+
130
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
131
+ any Contribution intentionally submitted for inclusion in the Work
132
+ by You to the Licensor shall be under the terms and conditions of
133
+ this License, without any additional terms or conditions.
134
+ Notwithstanding the above, nothing herein shall supersede or modify
135
+ the terms of any separate license agreement you may have executed
136
+ with Licensor regarding such Contributions.
137
+
138
+ 6. Trademarks. This License does not grant permission to use the trade
139
+ names, trademarks, service marks, or product names of the Licensor,
140
+ except as required for reasonable and customary use in describing the
141
+ origin of the Work and reproducing the content of the NOTICE file.
142
+
143
+ 7. Disclaimer of Warranty. Unless required by applicable law or
144
+ agreed to in writing, Licensor provides the Work (and each
145
+ Contributor provides its Contributions) on an "AS IS" BASIS,
146
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147
+ implied, including, without limitation, any warranties or conditions
148
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149
+ PARTICULAR PURPOSE. You are solely responsible for determining the
150
+ appropriateness of using or redistributing the Work and assume any
151
+ risks associated with Your exercise of permissions under this License.
152
+
153
+ 8. Limitation of Liability. In no event and under no legal theory,
154
+ whether in tort (including negligence), contract, or otherwise,
155
+ unless required by applicable law (such as deliberate and grossly
156
+ negligent acts) or agreed to in writing, shall any Contributor be
157
+ liable to You for damages, including any direct, indirect, special,
158
+ incidental, or consequential damages of any character arising as a
159
+ result of this License or out of the use or inability to use the
160
+ Work (including but not limited to damages for loss of goodwill,
161
+ work stoppage, computer failure or malfunction, or any and all
162
+ other commercial damages or losses), even if such Contributor
163
+ has been advised of the possibility of such damages.
164
+
165
+ 9. Accepting Warranty or Additional Liability. While redistributing
166
+ the Work or Derivative Works thereof, You may choose to offer,
167
+ and charge a fee for, acceptance of support, warranty, indemnity,
168
+ or other liability obligations and/or rights consistent with this
169
+ License. However, in accepting such obligations, You may act only
170
+ on Your own behalf and on Your sole responsibility, not on behalf
171
+ of any other Contributor, and only if You agree to indemnify,
172
+ defend, and hold each Contributor harmless for any liability
173
+ incurred by, or claims asserted against, such Contributor by reason
174
+ of your accepting any such warranty or additional liability.
175
+
176
+ END OF TERMS AND CONDITIONS
177
+
178
+ APPENDIX: How to apply the Apache License to your work.
179
+
180
+ To apply the Apache License to your work, attach the following
181
+ boilerplate notice, with the fields enclosed by brackets "[]"
182
+ replaced with your own identifying information. (Don't include
183
+ the brackets!) The text should be enclosed in the appropriate
184
+ comment syntax for the file format. We also recommend that a
185
+ file or class name and description of purpose be included on the
186
+ same "printed page" as the copyright notice for easier
187
+ identification within third-party archives.
188
+
189
+ Copyright [yyyy] [name of copyright owner]
190
+
191
+ Licensed under the Apache License, Version 2.0 (the "License");
192
+ you may not use this file except in compliance with the License.
193
+ You may obtain a copy of the License at
194
+
195
+ http://www.apache.org/licenses/LICENSE-2.0
196
+
197
+ Unless required by applicable law or agreed to in writing, software
198
+ distributed under the License is distributed on an "AS IS" BASIS,
199
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200
+ See the License for the specific language governing permissions and
201
+ limitations under the License.
package/README.md ADDED
@@ -0,0 +1,352 @@
1
+ <!-- @format -->
2
+ # Decentralized Web Node (DWN) SDK <!-- omit in toc -->
3
+
4
+ [![NPM](https://img.shields.io/npm/v/@enbox/dwn-sdk-js.svg?logo=npm)](https://www.npmjs.com/package/@enbox/dwn-sdk-js)
5
+ [![codecov](https://codecov.io/github/enboxorg/enbox/dwn-sdk-js/graphs/badge.svg)](https://codecov.io/github/enboxorg/enbox/dwn-sdk-js)
6
+ [![Build Status](https://img.shields.io/github/actions/workflow/status/enboxorg/enbox/dwn-sdk-js/npm-publish-unstable.yml?branch=main&logo=github)](https://github.com/enboxorg/enbox/dwn-sdk-js/actions/workflows/npm-publish-unstable.yml)
7
+ [![License](https://img.shields.io/npm/l/@enbox/dwn-sdk-js.svg?logo=apache)](https://github.com/enboxorg/enbox/dwn-sdk-js/blob/main/LICENSE)
8
+ [![Chat](https://img.shields.io/badge/chat-on%20discord-7289da.svg?logo=discord)](https://discord.com/channels/937858703112155166/1068273971432280196)
9
+
10
+
11
+ - [Introduction](#introduction)
12
+ - [Installation](#installation)
13
+ - [Additional Steps](#additional-steps)
14
+ - [Node.js \<= 18](#nodejs--18)
15
+ - [React Native](#react-native)
16
+ - [Usage in Browser:](#usage-in-browser)
17
+ - [Vanilla HTML / JS](#vanilla-html--js)
18
+ - [Webpack \>= 5](#webpack--5)
19
+ - [Vite](#vite)
20
+ - [esbuild](#esbuild)
21
+ - [Usage](#usage)
22
+ - [Release/Build Process](#releasebuild-process)
23
+ - [Stable Build](#stable-build)
24
+ - [Unstable Build](#unstable-build)
25
+ - [Some projects that use this library:](#some-projects-that-use-this-library)
26
+ - [Architecture](#architecture)
27
+ - [Project Resources](#project-resources)
28
+
29
+ ## 🎉 Hacktoberfest 2024 🎉
30
+
31
+ `dwn-sdk-js` is a participating project in Hacktoberfest 2024! We’re so excited for your contributions, and have created a wide variety of issues so that anyone can contribute. Whether you're a seasoned developer or a first-time open source contributor, there's something for everyone.
32
+
33
+ ### To get started:
34
+ 1. Read the [contributing guide](https://github.com/enboxorg/enbox/dwn-sdk-js/blob/main/CONTRIBUTING.md).
35
+ 2. Read the [code of conduct](https://github.com/enboxorg/enbox/dwn-sdk-js/blob/main/CODE_OF_CONDUCT.md).
36
+ 3. Choose a task from this project's Hacktoberfest issues in our [Project Hub](https://github.com/enboxorg/enbox/dwn-sdk-js/issues/806) and follow the instructions. Each issue has the 🏷️ `hacktoberfest` label.
37
+
38
+ Have questions? Connecting with us in our [Discord community](https://discord.gg/tbd) in the `#hacktoberfest` project channel.
39
+
40
+ ---
41
+
42
+ ## Introduction
43
+
44
+ This repository contains a reference implementation of Decentralized Web Node (DWN) as per the [specification](https://identity.foundation/decentralized-web-node/spec/). This specification is in a draft state and very much so a WIP. For the foreseeable future, a lot of the work on DWN will be split across this repo and the [repo that houses the specification](https://github.com/decentralized-identity/decentralized-web-node). The current implementation does not include all interfaces described in the DWN spec, but is enough to begin building test applications.
45
+
46
+ This project is used as a dependency by several other projects.
47
+
48
+ Proposals and issues for the specification itself should be submitted as pull requests to the [spec repo](https://github.com/decentralized-identity/decentralized-web-node).
49
+
50
+ ## Running online environment
51
+
52
+ Interested in contributing instantly? You can make your updates directly without cloning in the running CodeSandbox environment.
53
+
54
+ [![Button to click to edit code in CodeSandbox](https://assets.codesandbox.io/github/button-edit-lime.svg)](https://codesandbox.io/p/github/enboxorg/enbox/dwn-sdk-js/main)
55
+
56
+ ## Installation
57
+
58
+ If you are interested in using DWNs and web5 in your web app, you probably want to look at enbox, instead of this repository. Head on over here: https://github.com/enboxorg/enbox/enbox.
59
+
60
+ For advanced users wishing to use this repo directly:
61
+
62
+ ```bash
63
+ npm install @enbox/dwn-sdk-js
64
+ ```
65
+
66
+ ## Additional Steps
67
+
68
+ This package has dependency on [`@noble/ed25519`](https://github.com/paulmillr/noble-ed25519#usage) and [`@noble/secp256k1`](https://github.com/paulmillr/noble-secp256k1#usage) v2, additional steps are needed for some environments:
69
+
70
+ ### Node.js <= 18
71
+
72
+ ```js
73
+ // node.js 18 and earlier, needs globalThis.crypto polyfill
74
+ import { webcrypto } from "node:crypto";
75
+ // @ts-ignore
76
+ if (!globalThis.crypto) globalThis.crypto = webcrypto;
77
+ ```
78
+
79
+ ### React Native
80
+ Usage of DWN SDK in react native requires a bit of set up at the moment. To simplify, we've [published an npm package](https://www.npmjs.com/package/@enbox/web5-react-native-polyfills) that can be used to set everything up. Follow the instructions to get started.
81
+
82
+ ### Usage in Browser:
83
+
84
+ `dwn-sdk-js` requires 2 polyfills: `crypto` and `stream`. we recommend using `crypto-browserify` and `stream-browserify`. Both of these polyfills can be installed using npm. e.g. `npm install --save crypto-browserify stream-browserify`
85
+
86
+ #### Vanilla HTML / JS
87
+
88
+ DWN SDK includes a polyfilled distribution that can imported in a `module` script tag. e.g.
89
+
90
+ ```html
91
+ <!DOCTYPE html>
92
+ <html lang="en">
93
+ <body>
94
+ <script type="module">
95
+ // Import necessary modules from external sources using ES6 modules.
96
+ import { Dwn, DataStream, DidKeyResolver, Jws, RecordsWrite } from 'https://cdn.jsdelivr.net/npm/@enbox/dwn-sdk-js@0.1.1/dist/bundles/dwn.js'
97
+ import { MessageStoreLevel, DataStoreLevel, EventLogLevel } from 'https://cdn.jsdelivr.net/npm/@enbox/dwn-sdk-js@0.1.1/dist/bundles/level-stores.js'
98
+
99
+ // Create instances of various components from the imported modules.
100
+ const messageStore = new MessageStoreLevel();
101
+ const dataStore = new DataStoreLevel();
102
+ const eventLog = new EventLogLevel();
103
+ const dwn = await Dwn.create({ messageStore, dataStore, eventLog });
104
+
105
+ // Generate a did:key DID (Decentralized Identifier).
106
+ const didKey = await TestDataGenerator.generateDidKeyPersona();
107
+
108
+ // Create some data to be stored.
109
+ const encoder = new TextEncoder();
110
+ const data = encoder.encode('Hello, World!');
111
+
112
+ // Create a RecordsWrite message to be stored in DWN.
113
+ const recordsWrite = await RecordsWrite.create({
114
+ data,
115
+ dataFormat: 'application/json',
116
+ published: true,
117
+ schema: 'yeeter/post', // Specify a schema for the data.
118
+ signer: Jws.createSigner(didKey) // Sign the data using the generated DID key.
119
+ });
120
+
121
+ // Create a readable stream from the data to be stored.
122
+ const dataStream = DataStream.fromBytes(data);
123
+ // Process the RecordsWrite message using the DWN instance.
124
+ const result = await dwn.processMessage(didKey.did, recordsWrite.message, { dataStream });
125
+
126
+ // Log the processing result status and perform an assertion.
127
+ console.log(result.status);
128
+ console.assert(result.status.code === 202)
129
+
130
+ // Close the DWN instance, freeing up resources.
131
+ await dwn.close()
132
+
133
+ </script>
134
+ </body>
135
+
136
+ </html>
137
+ ```
138
+
139
+ #### Webpack >= 5
140
+
141
+ Add the following to the top level of your webpack config (`webpack.config.js`)
142
+
143
+ ```js
144
+ resolve: {
145
+ fallback: {
146
+ stream: require.resolve("stream-browserify"),
147
+ crypto: require.resolve("crypto-browserify")
148
+ }
149
+ }
150
+ ```
151
+
152
+ #### Vite
153
+ Add the following to the top level of your vite config (`vite.config.js`)
154
+
155
+ ```js
156
+ define: {
157
+ global: 'globalThis'
158
+ },
159
+ resolve: {
160
+ alias: {
161
+ 'crypto': 'crypto-browserify',
162
+ 'stream': 'stream-browserify'
163
+ }
164
+ }
165
+ ```
166
+
167
+ #### esbuild
168
+ We recommend using `node-stdlib-browser` instead of `crypto-browserify` and `stream-browserify` individually. Example usage:
169
+
170
+ ```js
171
+ import esbuild from 'esbuild'
172
+ import stdLibBrowser from 'node-stdlib-browser'
173
+ import polyfillProviderPlugin from 'node-stdlib-browser/helpers/esbuild/plugin'
174
+
175
+ import { createRequire } from 'node:module';
176
+
177
+ const require = createRequire(import.meta.url);
178
+
179
+ // Build the project using esbuild.
180
+ esbuild.build({
181
+ entryPoints: ['dwn-sdk-test.js'],
182
+ platform: 'browser',
183
+ bundle: true,
184
+ format: 'esm',
185
+ outfile: 'dist/dwn-sdk-test.js',
186
+
187
+ // Inject the specified shim for Node.js standard library browser compatibility.
188
+ inject : [require.resolve('node-stdlib-browser/helpers/esbuild/shim')],
189
+ // Use the polyfillProviderPlugin to provide polyfills for Node.js standard library.
190
+ plugins : [polyfillProviderPlugin(stdLibBrowser)],
191
+ // Define 'global' as 'globalThis' to ensure compatibility with global objects.
192
+ define : {
193
+ 'global': 'globalThis'
194
+ }
195
+ })
196
+ ```
197
+
198
+ ## Usage
199
+
200
+ [API docs](https://enboxorg/enbox.github.io/dwn-sdk-js/)
201
+
202
+ ```ts
203
+
204
+ import { Dwn, DataStream, DidKeyResolver, Jws, RecordsWrite } from '@enbox/dwn-sdk-js';
205
+ import { DataStoreLevel, EventLogLevel, MessageStoreLevel } from '@enbox/dwn-sdk-js/stores';
206
+
207
+ // Initialize the required stores and components for the DWN SDK.
208
+ const messageStore = new MessageStoreLevel();
209
+ const dataStore = new DataStoreLevel();
210
+ const eventLog = new EventLogLevel();
211
+ const dwn = await Dwn.create({ messageStore, dataStore, eventLog });
212
+
213
+ // Generate a did:key DID (Decentralized Identifier).
214
+ const didKey = await TestDataGenerator.generateDidKeyPersona();
215
+
216
+ // Create some data to be stored.
217
+ const encoder = new TextEncoder();
218
+ const data = encoder.encode('Hello, World!');
219
+
220
+ // Create a RecordsWrite message to be stored in the DWN.
221
+ const recordsWrite = await RecordsWrite.create({
222
+ data,
223
+ dataFormat: 'application/json',
224
+ published: true, // Mark the data as published.
225
+ schema: 'yeeter/post', // Specify a schema for the data.
226
+ signer: Jws.createSigner(didKey) // Sign the data using the generated DID key.
227
+ });
228
+
229
+ // Create a readable stream from the data to be stored.
230
+ const dataStream = DataStream.fromBytes(data);
231
+ // Process the RecordsWrite message using the DWN instance.
232
+ const result = await dwn.processMessage(didKey.did, recordsWrite.message, { dataStream });
233
+ // Log the processing result status.
234
+ console.log(result.status);
235
+
236
+ ```
237
+
238
+ With a web wallet installed:
239
+
240
+ ```javascript
241
+ const result = await window.web5.dwn.processMessage({
242
+ method: "RecordsQuery",
243
+ message: {
244
+ filter: {
245
+ schema: "http://some-schema-registry.org/todo",
246
+ },
247
+ dateSort: "createdAscending",
248
+ },
249
+ });
250
+ ```
251
+
252
+ ### Custom Tenant Gating
253
+ By default, all DIDs are allowed as tenants. A custom tenant gate implementation can be provided when initializing the DWN.
254
+ ```ts
255
+ import { ActiveTenantCheckResult, Dwn, TenantGate, DataStoreLevel, EventLogLevel, MessageStoreLevel } from '@enbox/dwn-sdk-js';
256
+
257
+ // Define a custom implementation of the TenantGate interface.
258
+ class CustomTenantGate implements TenantGate {
259
+ public async isActiveTenant(did): Promise<ActiveTenantCheckResult> {
260
+ // Custom implementation
261
+ }
262
+ }
263
+
264
+ // Initialize the required stores and components for the DWN SDK.
265
+ const messageStore = new MessageStoreLevel();
266
+ const dataStore = new DataStoreLevel();
267
+ const eventLog = new EventLogLevel();
268
+ // Create an instance of the custom TenantGate.
269
+ const tenantGate = new CustomTenantGate();
270
+ // Create a DWN instance with configured stores, logs, and the custom TenantGate.
271
+ const dwn = await Dwn.create({ messageStore, dataStore, eventLog, tenantGate });
272
+ ```
273
+
274
+ ### Custom Signature Signer
275
+ If you have the private key readily available, it is recommended to use the built-in `PrivateKeySigner`. Otherwise, you can implement a customer signer to interface with external signing service, API, HSM, TPM etc and use it for signing your DWN messages:
276
+
277
+ ```ts
278
+ // Create a custom signer implementing the Signer interface.
279
+ class CustomSigner implements Signer {
280
+ public keyId = 'did:example:alice#key1'; // Specify the key ID.
281
+ public algorithm = 'EdDSA'; // Specify the signing algorithm (valid `alg` value published).
282
+ https://www.iana.org/assignments/jose/jose.xhtml
283
+ public async sign (content: Uint8Array): Promise<Uint8Array> {
284
+ ... // custom signing logic
285
+ }
286
+ }
287
+
288
+ // Create an instance of the custom signer for authorization.
289
+ const signer = new CustomSigner();
290
+
291
+ // Define options for creating a RecordsWrite message.
292
+ const options: RecordsWriteOptions = {
293
+ ...
294
+ signer // Use the custom signer for authorization.
295
+ };
296
+
297
+ // Create a RecordsWrite message with the specified options.
298
+ const recordsWrite = await RecordsWrite.create(options);
299
+ ```
300
+
301
+
302
+ ## Release/Build Process
303
+
304
+ The DWN JS SDK releases builds to [npmjs.com](https://www.npmjs.com/package/@enbox/dwn-sdk-js). There are two build types: stable build and unstable build.
305
+
306
+ ### Stable Build
307
+
308
+ This is triggered manually by:
309
+
310
+ 1. Increment `version` in `package.json` in [Semantic Versioning (semver)](https://semver.org/) format.
311
+ 2. Merge the change into `main` branch
312
+ 3. Create a release from GitHub.
313
+
314
+ An official build with version matching the `package.json` will be published to [npmjs.com](https://www.npmjs.com/package/@enbox/dwn-sdk-js).
315
+
316
+ ### Unstable Build
317
+
318
+ Every push to the `main` branch will automatically trigger an unstable build to [npmjs.com](https://www.npmjs.com/package/@enbox/dwn-sdk-js) for developers to experiment and test.
319
+
320
+ The version string contains the date as well as the commit hash of the last change.
321
+
322
+ An example version string:
323
+
324
+ `0.0.26-unstable-2023-03-16-36ec2ce`
325
+
326
+ - `0.0.26` came from `version` in `package.json`
327
+ - `2023-03-16` indicates the date of March 16th 2023
328
+ - `36ec2ce` is the commit hash of the last change
329
+
330
+ ## Some projects that use this library:
331
+
332
+ - [Web5 JS SDK](https://github.com/enboxorg/enbox/enbox)
333
+ - [Example CLI](https://github.com/enboxorg/enbox/dwn-cli)
334
+ - [Example with a web wallet](https://github.com/enboxorg/enbox/incubating-web5-labs/)
335
+ - [Server side aggregator](https://github.com/enboxorg/enbox/dwn-server)
336
+
337
+ ## Architecture
338
+
339
+ <img src="./images/dwn-architecture.png" alt="Architecture diagram of DWN SDN" width="700">
340
+
341
+ > NOTE: The diagram is a conceptual view of the architecture, the actual component abstraction and names in source file may differ.
342
+
343
+ ## Project Resources
344
+
345
+ | Resource | Description |
346
+ | -------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------- |
347
+ | [CODEOWNERS](https://github.com/enboxorg/enbox/dwn-sdk-js/blob/main/CODEOWNERS) | Outlines the project lead(s) |
348
+ | [CODE_OF_CONDUCT.md](https://github.com/enboxorg/enbox/dwn-sdk-js/blob/main/CODE_OF_CONDUCT.md) | Expected behavior for project contributors, promoting a welcoming environment |
349
+ | [CONTRIBUTING.md](https://github.com/enboxorg/enbox/dwn-sdk-js/blob/main/CONTRIBUTING.md) | Developer guide to build, test, run, access CI, chat, discuss, file issues |
350
+ | [GOVERNANCE.md](https://github.com/enboxorg/enbox/dwn-sdk-js/blob/main/GOVERNANCE.md) | Project governance |
351
+ | [LICENSE](https://github.com/enboxorg/enbox/dwn-sdk-js/blob/main/LICENSE) | Apache License, Version 2.0 |
352
+ | [Q_AND_A.md](https://github.com/enboxorg/enbox/dwn-sdk-js/blob/main/Q_AND_A.md) | Questions and answers on DWN |