@enbox/agent 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 (348) hide show
  1. package/dist/browser.js +2215 -0
  2. package/dist/browser.js.map +7 -0
  3. package/dist/browser.mjs +2215 -0
  4. package/dist/browser.mjs.map +7 -0
  5. package/dist/cjs/index.js +8530 -0
  6. package/dist/cjs/index.js.map +7 -0
  7. package/dist/cjs/package.json +1 -0
  8. package/dist/esm/agent-did-resolver-cache.js +87 -0
  9. package/dist/esm/agent-did-resolver-cache.js.map +1 -0
  10. package/dist/esm/bearer-identity.js +41 -0
  11. package/dist/esm/bearer-identity.js.map +1 -0
  12. package/dist/esm/connect.js +191 -0
  13. package/dist/esm/connect.js.map +1 -0
  14. package/dist/esm/crypto-api.js +346 -0
  15. package/dist/esm/crypto-api.js.map +1 -0
  16. package/dist/esm/did-api.js +278 -0
  17. package/dist/esm/did-api.js.map +1 -0
  18. package/dist/esm/dwn-api.js +336 -0
  19. package/dist/esm/dwn-api.js.map +1 -0
  20. package/dist/esm/dwn-registrar.js +120 -0
  21. package/dist/esm/dwn-registrar.js.map +1 -0
  22. package/dist/esm/hd-identity-vault.js +729 -0
  23. package/dist/esm/hd-identity-vault.js.map +1 -0
  24. package/dist/esm/identity-api.js +262 -0
  25. package/dist/esm/identity-api.js.map +1 -0
  26. package/dist/esm/index.js +23 -0
  27. package/dist/esm/index.js.map +1 -0
  28. package/dist/esm/local-key-manager.js +498 -0
  29. package/dist/esm/local-key-manager.js.map +1 -0
  30. package/dist/esm/oidc.js +507 -0
  31. package/dist/esm/oidc.js.map +1 -0
  32. package/dist/esm/permissions-api.js +322 -0
  33. package/dist/esm/permissions-api.js.map +1 -0
  34. package/dist/esm/prototyping/clients/dwn-rpc-types.js +2 -0
  35. package/dist/esm/prototyping/clients/dwn-rpc-types.js.map +1 -0
  36. package/dist/esm/prototyping/clients/dwn-server-info-cache-memory.js +74 -0
  37. package/dist/esm/prototyping/clients/dwn-server-info-cache-memory.js.map +1 -0
  38. package/dist/esm/prototyping/clients/http-dwn-rpc-client.js +105 -0
  39. package/dist/esm/prototyping/clients/http-dwn-rpc-client.js.map +1 -0
  40. package/dist/esm/prototyping/clients/json-rpc-socket.js +150 -0
  41. package/dist/esm/prototyping/clients/json-rpc-socket.js.map +1 -0
  42. package/dist/esm/prototyping/clients/json-rpc.js +58 -0
  43. package/dist/esm/prototyping/clients/json-rpc.js.map +1 -0
  44. package/dist/esm/prototyping/clients/server-info-types.js +2 -0
  45. package/dist/esm/prototyping/clients/server-info-types.js.map +1 -0
  46. package/dist/esm/prototyping/clients/web-socket-clients.js +90 -0
  47. package/dist/esm/prototyping/clients/web-socket-clients.js.map +1 -0
  48. package/dist/esm/prototyping/common/object.js +14 -0
  49. package/dist/esm/prototyping/common/object.js.map +1 -0
  50. package/dist/esm/prototyping/common/type-utils.js +2 -0
  51. package/dist/esm/prototyping/common/type-utils.js.map +1 -0
  52. package/dist/esm/prototyping/crypto/algorithms/aes-gcm.js +147 -0
  53. package/dist/esm/prototyping/crypto/algorithms/aes-gcm.js.map +1 -0
  54. package/dist/esm/prototyping/crypto/algorithms/aes-kw.js +137 -0
  55. package/dist/esm/prototyping/crypto/algorithms/aes-kw.js.map +1 -0
  56. package/dist/esm/prototyping/crypto/algorithms/ecdsa.js +307 -0
  57. package/dist/esm/prototyping/crypto/algorithms/ecdsa.js.map +1 -0
  58. package/dist/esm/prototyping/crypto/algorithms/eddsa.js +264 -0
  59. package/dist/esm/prototyping/crypto/algorithms/eddsa.js.map +1 -0
  60. package/dist/esm/prototyping/crypto/algorithms/hkdf.js +39 -0
  61. package/dist/esm/prototyping/crypto/algorithms/hkdf.js.map +1 -0
  62. package/dist/esm/prototyping/crypto/algorithms/pbkdf2.js +41 -0
  63. package/dist/esm/prototyping/crypto/algorithms/pbkdf2.js.map +1 -0
  64. package/dist/esm/prototyping/crypto/crypto-error.js +41 -0
  65. package/dist/esm/prototyping/crypto/crypto-error.js.map +1 -0
  66. package/dist/esm/prototyping/crypto/dsa.js +236 -0
  67. package/dist/esm/prototyping/crypto/dsa.js.map +1 -0
  68. package/dist/esm/prototyping/crypto/jose/jwe-compact.js +130 -0
  69. package/dist/esm/prototyping/crypto/jose/jwe-compact.js.map +1 -0
  70. package/dist/esm/prototyping/crypto/jose/jwe-flattened.js +294 -0
  71. package/dist/esm/prototyping/crypto/jose/jwe-flattened.js.map +1 -0
  72. package/dist/esm/prototyping/crypto/jose/jwe.js +308 -0
  73. package/dist/esm/prototyping/crypto/jose/jwe.js.map +1 -0
  74. package/dist/esm/prototyping/crypto/primitives/aes-gcm.js +352 -0
  75. package/dist/esm/prototyping/crypto/primitives/aes-gcm.js.map +1 -0
  76. package/dist/esm/prototyping/crypto/primitives/aes-kw.js +247 -0
  77. package/dist/esm/prototyping/crypto/primitives/aes-kw.js.map +1 -0
  78. package/dist/esm/prototyping/crypto/primitives/hkdf.js +80 -0
  79. package/dist/esm/prototyping/crypto/primitives/hkdf.js.map +1 -0
  80. package/dist/esm/prototyping/crypto/primitives/pbkdf2.js +85 -0
  81. package/dist/esm/prototyping/crypto/primitives/pbkdf2.js.map +1 -0
  82. package/dist/esm/prototyping/crypto/types/cipher.js +2 -0
  83. package/dist/esm/prototyping/crypto/types/cipher.js.map +1 -0
  84. package/dist/esm/prototyping/crypto/types/crypto-api.js +2 -0
  85. package/dist/esm/prototyping/crypto/types/crypto-api.js.map +1 -0
  86. package/dist/esm/prototyping/crypto/types/key-converter.js +2 -0
  87. package/dist/esm/prototyping/crypto/types/key-converter.js.map +1 -0
  88. package/dist/esm/prototyping/crypto/types/key-deriver.js +2 -0
  89. package/dist/esm/prototyping/crypto/types/key-deriver.js.map +1 -0
  90. package/dist/esm/prototyping/crypto/types/key-io.js +2 -0
  91. package/dist/esm/prototyping/crypto/types/key-io.js.map +1 -0
  92. package/dist/esm/prototyping/crypto/types/key-manager.js +2 -0
  93. package/dist/esm/prototyping/crypto/types/key-manager.js.map +1 -0
  94. package/dist/esm/prototyping/crypto/types/key-wrapper.js +2 -0
  95. package/dist/esm/prototyping/crypto/types/key-wrapper.js.map +1 -0
  96. package/dist/esm/prototyping/crypto/types/params-direct.js +2 -0
  97. package/dist/esm/prototyping/crypto/types/params-direct.js.map +1 -0
  98. package/dist/esm/prototyping/crypto/types/params-kms.js +2 -0
  99. package/dist/esm/prototyping/crypto/types/params-kms.js.map +1 -0
  100. package/dist/esm/prototyping/crypto/utils.js +19 -0
  101. package/dist/esm/prototyping/crypto/utils.js.map +1 -0
  102. package/dist/esm/prototyping/dids/resolver-cache-memory.js +77 -0
  103. package/dist/esm/prototyping/dids/resolver-cache-memory.js.map +1 -0
  104. package/dist/esm/prototyping/dids/utils.js +9 -0
  105. package/dist/esm/prototyping/dids/utils.js.map +1 -0
  106. package/dist/esm/rpc-client.js +123 -0
  107. package/dist/esm/rpc-client.js.map +1 -0
  108. package/dist/esm/store-data-protocols.js +38 -0
  109. package/dist/esm/store-data-protocols.js.map +1 -0
  110. package/dist/esm/store-data.js +320 -0
  111. package/dist/esm/store-data.js.map +1 -0
  112. package/dist/esm/store-did.js +136 -0
  113. package/dist/esm/store-did.js.map +1 -0
  114. package/dist/esm/store-identity.js +140 -0
  115. package/dist/esm/store-identity.js.map +1 -0
  116. package/dist/esm/store-key.js +136 -0
  117. package/dist/esm/store-key.js.map +1 -0
  118. package/dist/esm/sync-api.js +61 -0
  119. package/dist/esm/sync-api.js.map +1 -0
  120. package/dist/esm/sync-engine-level.js +618 -0
  121. package/dist/esm/sync-engine-level.js.map +1 -0
  122. package/dist/esm/test-harness.js +239 -0
  123. package/dist/esm/test-harness.js.map +1 -0
  124. package/dist/esm/types/agent.js +2 -0
  125. package/dist/esm/types/agent.js.map +1 -0
  126. package/dist/esm/types/dwn.js +31 -0
  127. package/dist/esm/types/dwn.js.map +1 -0
  128. package/dist/esm/types/identity-vault.js +2 -0
  129. package/dist/esm/types/identity-vault.js.map +1 -0
  130. package/dist/esm/types/identity.js +2 -0
  131. package/dist/esm/types/identity.js.map +1 -0
  132. package/dist/esm/types/key-manager.js +2 -0
  133. package/dist/esm/types/key-manager.js.map +1 -0
  134. package/dist/esm/types/permissions.js +2 -0
  135. package/dist/esm/types/permissions.js.map +1 -0
  136. package/dist/esm/types/sync.js +2 -0
  137. package/dist/esm/types/sync.js.map +1 -0
  138. package/dist/esm/types/vc.js +5 -0
  139. package/dist/esm/types/vc.js.map +1 -0
  140. package/dist/esm/utils-internal.js +147 -0
  141. package/dist/esm/utils-internal.js.map +1 -0
  142. package/dist/esm/utils.js +161 -0
  143. package/dist/esm/utils.js.map +1 -0
  144. package/dist/types/agent-did-resolver-cache.d.ts +30 -0
  145. package/dist/types/agent-did-resolver-cache.d.ts.map +1 -0
  146. package/dist/types/bearer-identity.d.ts +31 -0
  147. package/dist/types/bearer-identity.d.ts.map +1 -0
  148. package/dist/types/connect.d.ts +88 -0
  149. package/dist/types/connect.d.ts.map +1 -0
  150. package/dist/types/crypto-api.d.ts +286 -0
  151. package/dist/types/crypto-api.d.ts.map +1 -0
  152. package/dist/types/did-api.d.ts +119 -0
  153. package/dist/types/did-api.d.ts.map +1 -0
  154. package/dist/types/dwn-api.d.ts +66 -0
  155. package/dist/types/dwn-api.d.ts.map +1 -0
  156. package/dist/types/dwn-registrar.d.ts +29 -0
  157. package/dist/types/dwn-registrar.d.ts.map +1 -0
  158. package/dist/types/hd-identity-vault.d.ts +306 -0
  159. package/dist/types/hd-identity-vault.d.ts.map +1 -0
  160. package/dist/types/identity-api.d.ts +107 -0
  161. package/dist/types/identity-api.d.ts.map +1 -0
  162. package/dist/types/index.d.ts +30 -0
  163. package/dist/types/index.d.ts.map +1 -0
  164. package/dist/types/local-key-manager.d.ts +311 -0
  165. package/dist/types/local-key-manager.d.ts.map +1 -0
  166. package/dist/types/oidc.d.ts +247 -0
  167. package/dist/types/oidc.d.ts.map +1 -0
  168. package/dist/types/permissions-api.d.ts +35 -0
  169. package/dist/types/permissions-api.d.ts.map +1 -0
  170. package/dist/types/prototyping/clients/dwn-rpc-types.d.ts +45 -0
  171. package/dist/types/prototyping/clients/dwn-rpc-types.d.ts.map +1 -0
  172. package/dist/types/prototyping/clients/dwn-server-info-cache-memory.d.ts +57 -0
  173. package/dist/types/prototyping/clients/dwn-server-info-cache-memory.d.ts.map +1 -0
  174. package/dist/types/prototyping/clients/http-dwn-rpc-client.d.ts +13 -0
  175. package/dist/types/prototyping/clients/http-dwn-rpc-client.d.ts.map +1 -0
  176. package/dist/types/prototyping/clients/json-rpc-socket.d.ts +43 -0
  177. package/dist/types/prototyping/clients/json-rpc-socket.d.ts.map +1 -0
  178. package/dist/types/prototyping/clients/json-rpc.d.ts +49 -0
  179. package/dist/types/prototyping/clients/json-rpc.d.ts.map +1 -0
  180. package/dist/types/prototyping/clients/server-info-types.d.ts +20 -0
  181. package/dist/types/prototyping/clients/server-info-types.d.ts.map +1 -0
  182. package/dist/types/prototyping/clients/web-socket-clients.d.ts +10 -0
  183. package/dist/types/prototyping/clients/web-socket-clients.d.ts.map +1 -0
  184. package/dist/types/prototyping/common/object.d.ts +2 -0
  185. package/dist/types/prototyping/common/object.d.ts.map +1 -0
  186. package/dist/types/prototyping/common/type-utils.d.ts +7 -0
  187. package/dist/types/prototyping/common/type-utils.d.ts.map +1 -0
  188. package/dist/types/prototyping/crypto/algorithms/aes-gcm.d.ts +151 -0
  189. package/dist/types/prototyping/crypto/algorithms/aes-gcm.d.ts.map +1 -0
  190. package/dist/types/prototyping/crypto/algorithms/aes-kw.d.ts +109 -0
  191. package/dist/types/prototyping/crypto/algorithms/aes-kw.d.ts.map +1 -0
  192. package/dist/types/prototyping/crypto/algorithms/ecdsa.d.ts +160 -0
  193. package/dist/types/prototyping/crypto/algorithms/ecdsa.d.ts.map +1 -0
  194. package/dist/types/prototyping/crypto/algorithms/eddsa.d.ts +157 -0
  195. package/dist/types/prototyping/crypto/algorithms/eddsa.d.ts.map +1 -0
  196. package/dist/types/prototyping/crypto/algorithms/hkdf.d.ts +21 -0
  197. package/dist/types/prototyping/crypto/algorithms/hkdf.d.ts.map +1 -0
  198. package/dist/types/prototyping/crypto/algorithms/pbkdf2.d.ts +21 -0
  199. package/dist/types/prototyping/crypto/algorithms/pbkdf2.d.ts.map +1 -0
  200. package/dist/types/prototyping/crypto/crypto-error.d.ts +29 -0
  201. package/dist/types/prototyping/crypto/crypto-error.d.ts.map +1 -0
  202. package/dist/types/prototyping/crypto/dsa.d.ts +169 -0
  203. package/dist/types/prototyping/crypto/dsa.d.ts.map +1 -0
  204. package/dist/types/prototyping/crypto/jose/jwe-compact.d.ts +135 -0
  205. package/dist/types/prototyping/crypto/jose/jwe-compact.d.ts.map +1 -0
  206. package/dist/types/prototyping/crypto/jose/jwe-flattened.d.ts +134 -0
  207. package/dist/types/prototyping/crypto/jose/jwe-flattened.d.ts.map +1 -0
  208. package/dist/types/prototyping/crypto/jose/jwe.d.ts +378 -0
  209. package/dist/types/prototyping/crypto/jose/jwe.d.ts.map +1 -0
  210. package/dist/types/prototyping/crypto/primitives/aes-gcm.d.ts +245 -0
  211. package/dist/types/prototyping/crypto/primitives/aes-gcm.d.ts.map +1 -0
  212. package/dist/types/prototyping/crypto/primitives/aes-kw.d.ts +103 -0
  213. package/dist/types/prototyping/crypto/primitives/aes-kw.d.ts.map +1 -0
  214. package/dist/types/prototyping/crypto/primitives/hkdf.d.ts +90 -0
  215. package/dist/types/prototyping/crypto/primitives/hkdf.d.ts.map +1 -0
  216. package/dist/types/prototyping/crypto/primitives/pbkdf2.d.ts +84 -0
  217. package/dist/types/prototyping/crypto/primitives/pbkdf2.d.ts.map +1 -0
  218. package/dist/types/prototyping/crypto/types/cipher.d.ts +14 -0
  219. package/dist/types/prototyping/crypto/types/cipher.d.ts.map +1 -0
  220. package/dist/types/prototyping/crypto/types/crypto-api.d.ts +35 -0
  221. package/dist/types/prototyping/crypto/types/crypto-api.d.ts.map +1 -0
  222. package/dist/types/prototyping/crypto/types/key-converter.d.ts +49 -0
  223. package/dist/types/prototyping/crypto/types/key-converter.d.ts.map +1 -0
  224. package/dist/types/prototyping/crypto/types/key-deriver.d.ts +50 -0
  225. package/dist/types/prototyping/crypto/types/key-deriver.d.ts.map +1 -0
  226. package/dist/types/prototyping/crypto/types/key-io.d.ts +49 -0
  227. package/dist/types/prototyping/crypto/types/key-io.d.ts.map +1 -0
  228. package/dist/types/prototyping/crypto/types/key-manager.d.ts +69 -0
  229. package/dist/types/prototyping/crypto/types/key-manager.d.ts.map +1 -0
  230. package/dist/types/prototyping/crypto/types/key-wrapper.d.ts +14 -0
  231. package/dist/types/prototyping/crypto/types/key-wrapper.d.ts.map +1 -0
  232. package/dist/types/prototyping/crypto/types/params-direct.d.ts +75 -0
  233. package/dist/types/prototyping/crypto/types/params-direct.d.ts.map +1 -0
  234. package/dist/types/prototyping/crypto/types/params-kms.d.ts +63 -0
  235. package/dist/types/prototyping/crypto/types/params-kms.d.ts.map +1 -0
  236. package/dist/types/prototyping/crypto/utils.d.ts +7 -0
  237. package/dist/types/prototyping/crypto/utils.d.ts.map +1 -0
  238. package/dist/types/prototyping/dids/resolver-cache-memory.d.ts +57 -0
  239. package/dist/types/prototyping/dids/resolver-cache-memory.d.ts.map +1 -0
  240. package/dist/types/prototyping/dids/utils.d.ts +3 -0
  241. package/dist/types/prototyping/dids/utils.d.ts.map +1 -0
  242. package/dist/types/rpc-client.d.ts +51 -0
  243. package/dist/types/rpc-client.d.ts.map +1 -0
  244. package/dist/types/store-data-protocols.d.ts +4 -0
  245. package/dist/types/store-data-protocols.d.ts.map +1 -0
  246. package/dist/types/store-data.d.ts +95 -0
  247. package/dist/types/store-data.d.ts.map +1 -0
  248. package/dist/types/store-did.d.ts +33 -0
  249. package/dist/types/store-did.d.ts.map +1 -0
  250. package/dist/types/store-identity.d.ts +34 -0
  251. package/dist/types/store-identity.d.ts.map +1 -0
  252. package/dist/types/store-key.d.ts +32 -0
  253. package/dist/types/store-key.d.ts.map +1 -0
  254. package/dist/types/sync-api.d.ts +41 -0
  255. package/dist/types/sync-api.d.ts.map +1 -0
  256. package/dist/types/sync-engine-level.d.ts +85 -0
  257. package/dist/types/sync-engine-level.d.ts.map +1 -0
  258. package/dist/types/test-harness.d.ts +69 -0
  259. package/dist/types/test-harness.d.ts.map +1 -0
  260. package/dist/types/types/agent.d.ts +172 -0
  261. package/dist/types/types/agent.d.ts.map +1 -0
  262. package/dist/types/types/dwn.d.ts +178 -0
  263. package/dist/types/types/dwn.d.ts.map +1 -0
  264. package/dist/types/types/identity-vault.d.ts +129 -0
  265. package/dist/types/types/identity-vault.d.ts.map +1 -0
  266. package/dist/types/types/identity.d.ts +16 -0
  267. package/dist/types/types/identity.d.ts.map +1 -0
  268. package/dist/types/types/key-manager.d.ts +9 -0
  269. package/dist/types/types/key-manager.d.ts.map +1 -0
  270. package/dist/types/types/permissions.d.ts +98 -0
  271. package/dist/types/types/permissions.d.ts.map +1 -0
  272. package/dist/types/types/sync.d.ts +66 -0
  273. package/dist/types/types/sync.d.ts.map +1 -0
  274. package/dist/types/types/vc.d.ts +7 -0
  275. package/dist/types/types/vc.d.ts.map +1 -0
  276. package/dist/types/utils-internal.d.ts +50 -0
  277. package/dist/types/utils-internal.d.ts.map +1 -0
  278. package/dist/types/utils.d.ts +37 -0
  279. package/dist/types/utils.d.ts.map +1 -0
  280. package/package.json +112 -0
  281. package/src/agent-did-resolver-cache.ts +95 -0
  282. package/src/bearer-identity.ts +42 -0
  283. package/src/connect.ts +296 -0
  284. package/src/crypto-api.ts +593 -0
  285. package/src/did-api.ts +429 -0
  286. package/src/dwn-api.ts +462 -0
  287. package/src/dwn-registrar.ts +127 -0
  288. package/src/hd-identity-vault.ts +853 -0
  289. package/src/identity-api.ts +324 -0
  290. package/src/index.ts +30 -0
  291. package/src/local-key-manager.ts +672 -0
  292. package/src/oidc.ts +857 -0
  293. package/src/permissions-api.ts +408 -0
  294. package/src/prototyping/clients/dwn-rpc-types.ts +55 -0
  295. package/src/prototyping/clients/dwn-server-info-cache-memory.ts +79 -0
  296. package/src/prototyping/clients/http-dwn-rpc-client.ts +110 -0
  297. package/src/prototyping/clients/json-rpc-socket.ts +169 -0
  298. package/src/prototyping/clients/json-rpc.ts +113 -0
  299. package/src/prototyping/clients/server-info-types.ts +21 -0
  300. package/src/prototyping/clients/web-socket-clients.ts +100 -0
  301. package/src/prototyping/common/object.ts +15 -0
  302. package/src/prototyping/common/type-utils.ts +6 -0
  303. package/src/prototyping/crypto/algorithms/aes-gcm.ts +211 -0
  304. package/src/prototyping/crypto/algorithms/aes-kw.ts +164 -0
  305. package/src/prototyping/crypto/algorithms/ecdsa.ts +365 -0
  306. package/src/prototyping/crypto/algorithms/eddsa.ts +310 -0
  307. package/src/prototyping/crypto/algorithms/hkdf.ts +40 -0
  308. package/src/prototyping/crypto/algorithms/pbkdf2.ts +44 -0
  309. package/src/prototyping/crypto/crypto-error.ts +45 -0
  310. package/src/prototyping/crypto/dsa.ts +367 -0
  311. package/src/prototyping/crypto/jose/jwe-compact.ts +225 -0
  312. package/src/prototyping/crypto/jose/jwe-flattened.ts +459 -0
  313. package/src/prototyping/crypto/jose/jwe.ts +653 -0
  314. package/src/prototyping/crypto/primitives/aes-gcm.ts +374 -0
  315. package/src/prototyping/crypto/primitives/aes-kw.ts +271 -0
  316. package/src/prototyping/crypto/primitives/hkdf.ts +121 -0
  317. package/src/prototyping/crypto/primitives/pbkdf2.ts +116 -0
  318. package/src/prototyping/crypto/types/cipher.ts +17 -0
  319. package/src/prototyping/crypto/types/crypto-api.ts +78 -0
  320. package/src/prototyping/crypto/types/key-converter.ts +53 -0
  321. package/src/prototyping/crypto/types/key-deriver.ts +56 -0
  322. package/src/prototyping/crypto/types/key-io.ts +51 -0
  323. package/src/prototyping/crypto/types/key-manager.ts +83 -0
  324. package/src/prototyping/crypto/types/key-wrapper.ts +17 -0
  325. package/src/prototyping/crypto/types/params-direct.ts +95 -0
  326. package/src/prototyping/crypto/types/params-kms.ts +76 -0
  327. package/src/prototyping/crypto/utils.ts +41 -0
  328. package/src/prototyping/dids/resolver-cache-memory.ts +83 -0
  329. package/src/prototyping/dids/utils.ts +10 -0
  330. package/src/rpc-client.ts +162 -0
  331. package/src/store-data-protocols.ts +40 -0
  332. package/src/store-data.ts +400 -0
  333. package/src/store-did.ts +105 -0
  334. package/src/store-identity.ts +109 -0
  335. package/src/store-key.ts +104 -0
  336. package/src/sync-api.ts +71 -0
  337. package/src/sync-engine-level.ts +714 -0
  338. package/src/test-harness.ts +330 -0
  339. package/src/types/agent.ts +195 -0
  340. package/src/types/dwn.ts +278 -0
  341. package/src/types/identity-vault.ts +137 -0
  342. package/src/types/identity.ts +18 -0
  343. package/src/types/key-manager.ts +15 -0
  344. package/src/types/permissions.ts +115 -0
  345. package/src/types/sync.ts +58 -0
  346. package/src/types/vc.ts +7 -0
  347. package/src/utils-internal.ts +157 -0
  348. package/src/utils.ts +181 -0
@@ -0,0 +1,278 @@
1
+ import type { DidService } from '@enbox/dids';
2
+ import type { Readable, RequireOnly } from '@enbox/common';
3
+ import type {
4
+ RecordsReadReply,
5
+ RecordsQueryReply,
6
+ RecordsReadMessage,
7
+ RecordsReadOptions,
8
+ GenericMessageReply,
9
+ ProtocolsQueryReply,
10
+ RecordsQueryMessage,
11
+ RecordsQueryOptions,
12
+ RecordsWriteMessage,
13
+ RecordsWriteOptions,
14
+ RecordsDeleteMessage,
15
+ RecordsDeleteOptions,
16
+ ProtocolsQueryMessage,
17
+ ProtocolsQueryOptions,
18
+ ProtocolsConfigureMessage,
19
+ ProtocolsConfigureOptions,
20
+ RecordsSubscribeMessage,
21
+ RecordsSubscribeOptions,
22
+ RecordsSubscribeReply,
23
+ MessageSubscriptionHandler,
24
+ RecordSubscriptionHandler,
25
+ MessagesQueryMessage,
26
+ MessagesReadMessage,
27
+ MessagesSubscribeMessage,
28
+ MessagesQueryOptions,
29
+ MessagesReadOptions,
30
+ MessagesSubscribeOptions,
31
+ MessagesQueryReply,
32
+ MessagesReadReply,
33
+ MessagesSubscribeReply,
34
+ } from '@enbox/dwn-sdk-js';
35
+
36
+ import {
37
+ RecordsRead,
38
+ RecordsQuery,
39
+ RecordsWrite,
40
+ DwnMethodName,
41
+ RecordsDelete,
42
+ ProtocolsQuery,
43
+ DwnInterfaceName,
44
+ ProtocolsConfigure,
45
+ RecordsSubscribe,
46
+ MessagesQuery,
47
+ MessagesRead,
48
+ MessagesSubscribe,
49
+ } from '@enbox/dwn-sdk-js';
50
+
51
+ /**
52
+ * Represents a Decentralized Web Node (DWN) service in a DID Document.
53
+ *
54
+ * A DWN DID service is a specialized type of DID service with the `type` set to
55
+ * `DecentralizedWebNode`. It includes specific properties `enc` and `sig` that are used to identify
56
+ * the public keys that can be used to interact with the DID Subject. The values of these properties
57
+ * are strings or arrays of strings containing one or more verification method `id` values present in
58
+ * the same DID document. If the `enc` and/or `sig` properties are an array of strings, an entity
59
+ * interacting with the DID subject is expected to use the verification methods in the order they
60
+ * are listed.
61
+ *
62
+ * @example
63
+ * ```ts
64
+ * const service: DwnDidService = {
65
+ * id: 'did:example:123#dwn',
66
+ * type: 'DecentralizedWebNode',
67
+ * serviceEndpoint: 'https://enbox-production.up.railway.app',
68
+ * enc: 'did:example:123#key-1',
69
+ * sig: 'did:example:123#key-2'
70
+ * }
71
+ * ```
72
+ *
73
+ * @see {@link https://identity.foundation/decentralized-web-node/spec/ | DIF Decentralized Web Node (DWN) Specification}
74
+ */
75
+ export interface DwnDidService extends DidService {
76
+ /**
77
+ * One or more verification method `id` values that can be used to encrypt information
78
+ * intended for the DID subject.
79
+ */
80
+ enc?: string | string[];
81
+
82
+ /**
83
+ * One or more verification method `id` values that will be used by the DID subject to sign data
84
+ * or by another entity to verify signatures created by the DID subject.
85
+ */
86
+ sig: string | string[];
87
+ }
88
+
89
+ export enum DwnInterface {
90
+ MessagesQuery = DwnInterfaceName.Messages + DwnMethodName.Query,
91
+ MessagesRead = DwnInterfaceName.Messages + DwnMethodName.Read,
92
+ MessagesSubscribe = DwnInterfaceName.Messages + DwnMethodName.Subscribe,
93
+ ProtocolsConfigure = DwnInterfaceName.Protocols + DwnMethodName.Configure,
94
+ ProtocolsQuery = DwnInterfaceName.Protocols + DwnMethodName.Query,
95
+ RecordsDelete = DwnInterfaceName.Records + DwnMethodName.Delete,
96
+ RecordsQuery = DwnInterfaceName.Records + DwnMethodName.Query,
97
+ RecordsRead = DwnInterfaceName.Records + DwnMethodName.Read,
98
+ RecordsSubscribe = DwnInterfaceName.Records + DwnMethodName.Subscribe,
99
+ RecordsWrite = DwnInterfaceName.Records + DwnMethodName.Write
100
+ }
101
+
102
+ export type DwnRecordsInterfaces = DwnInterface.RecordsDelete | DwnInterface.RecordsQuery | DwnInterface.RecordsRead | DwnInterface.RecordsSubscribe | DwnInterface.RecordsWrite;
103
+ export type DwnMessageInterfaces = DwnInterface.MessagesQuery | DwnInterface.MessagesRead | DwnInterface.MessagesSubscribe;
104
+ export type DwnProtocolInterfaces = DwnInterface.ProtocolsConfigure | DwnInterface.ProtocolsQuery;
105
+
106
+ export interface DwnMessage {
107
+ [DwnInterface.MessagesQuery] : MessagesQueryMessage;
108
+ [DwnInterface.MessagesRead] : MessagesReadMessage;
109
+ [DwnInterface.MessagesSubscribe] : MessagesSubscribeMessage;
110
+ [DwnInterface.ProtocolsConfigure] : ProtocolsConfigureMessage;
111
+ [DwnInterface.ProtocolsQuery] : ProtocolsQueryMessage;
112
+ [DwnInterface.RecordsDelete] : RecordsDeleteMessage;
113
+ [DwnInterface.RecordsQuery] : RecordsQueryMessage;
114
+ [DwnInterface.RecordsRead] : RecordsReadMessage;
115
+ [DwnInterface.RecordsSubscribe] : RecordsSubscribeMessage;
116
+ [DwnInterface.RecordsWrite] : RecordsWriteMessage;
117
+ }
118
+
119
+ export interface DwnMessageDescriptor {
120
+ [DwnInterface.MessagesQuery] : MessagesQueryMessage['descriptor'];
121
+ [DwnInterface.MessagesRead] : MessagesReadMessage['descriptor'];
122
+ [DwnInterface.MessagesSubscribe] : MessagesSubscribeMessage['descriptor'];
123
+ [DwnInterface.ProtocolsConfigure] : ProtocolsConfigureMessage['descriptor'];
124
+ [DwnInterface.ProtocolsQuery] : ProtocolsQueryMessage['descriptor'];
125
+ [DwnInterface.RecordsDelete] : RecordsDeleteMessage['descriptor'];
126
+ [DwnInterface.RecordsQuery] : RecordsQueryMessage['descriptor'];
127
+ [DwnInterface.RecordsRead] : RecordsReadMessage['descriptor'];
128
+ [DwnInterface.RecordsSubscribe] : RecordsSubscribeMessage['descriptor'];
129
+ [DwnInterface.RecordsWrite] : RecordsWriteMessage['descriptor'];
130
+ }
131
+
132
+ export interface DwnMessageParams {
133
+ [DwnInterface.MessagesQuery] : RequireOnly<MessagesQueryOptions, 'filters'>;
134
+ [DwnInterface.MessagesRead] : RequireOnly<MessagesReadOptions, 'messageCid'>;
135
+ [DwnInterface.MessagesSubscribe] : Partial<MessagesSubscribeOptions>;
136
+ [DwnInterface.ProtocolsConfigure] : RequireOnly<ProtocolsConfigureOptions, 'definition'>;
137
+ [DwnInterface.ProtocolsQuery] : ProtocolsQueryOptions;
138
+ [DwnInterface.RecordsDelete] : RequireOnly<RecordsDeleteOptions, 'recordId'>;
139
+ [DwnInterface.RecordsQuery] : RecordsQueryOptions;
140
+ [DwnInterface.RecordsRead] : RecordsReadOptions;
141
+ [DwnInterface.RecordsSubscribe] : RecordsSubscribeOptions;
142
+ [DwnInterface.RecordsWrite] : RecordsWriteOptions;
143
+ }
144
+
145
+ export interface DwnMessageReply {
146
+ [DwnInterface.MessagesQuery] : MessagesQueryReply;
147
+ [DwnInterface.MessagesRead] : MessagesReadReply;
148
+ [DwnInterface.MessagesSubscribe] : MessagesSubscribeReply;
149
+ [DwnInterface.ProtocolsConfigure] : GenericMessageReply;
150
+ [DwnInterface.ProtocolsQuery] : ProtocolsQueryReply;
151
+ [DwnInterface.RecordsDelete] : GenericMessageReply;
152
+ [DwnInterface.RecordsQuery] : RecordsQueryReply;
153
+ [DwnInterface.RecordsRead] : RecordsReadReply;
154
+ [DwnInterface.RecordsSubscribe] : RecordsSubscribeReply;
155
+ [DwnInterface.RecordsWrite] : GenericMessageReply;
156
+ }
157
+
158
+ export interface MessageHandler {
159
+ [DwnInterface.MessagesSubscribe] : MessageSubscriptionHandler;
160
+ [DwnInterface.RecordsSubscribe] : RecordSubscriptionHandler;
161
+
162
+ // define all of them individually as undefined
163
+ [DwnInterface.MessagesQuery] : undefined;
164
+ [DwnInterface.MessagesRead] : undefined;
165
+ [DwnInterface.ProtocolsConfigure] : undefined;
166
+ [DwnInterface.ProtocolsQuery] : undefined;
167
+ [DwnInterface.RecordsDelete] : undefined;
168
+ [DwnInterface.RecordsQuery] : undefined;
169
+ [DwnInterface.RecordsRead] : undefined;
170
+ [DwnInterface.RecordsWrite] : undefined;
171
+ }
172
+
173
+ export type DwnRequest<T extends DwnInterface> = {
174
+ author: string;
175
+ target: string;
176
+ messageType: T;
177
+ }
178
+
179
+ /**
180
+ * Defines the structure for response status, including a status code and detail message.
181
+ */
182
+ export type DwnResponseStatus = {
183
+ /** Encapsulates the outcome of an operation, providing both a numeric status code and a descriptive message. */
184
+ status: {
185
+ /** Numeric status code representing the outcome of the operation. */
186
+ code: number;
187
+
188
+ /** Descriptive detail about the status or error. */
189
+ detail: string;
190
+ };
191
+ };
192
+
193
+ export type ProcessDwnRequest<T extends DwnInterface> = DwnRequest<T> & {
194
+ dataStream?: Blob | ReadableStream | Readable;
195
+ rawMessage?: DwnMessage[T];
196
+ messageParams?: DwnMessageParams[T];
197
+ store?: boolean;
198
+ signAsOwner?: boolean;
199
+ signAsOwnerDelegate?: boolean;
200
+ granteeDid?: string;
201
+ subscriptionHandler?: MessageHandler[T];
202
+ }
203
+
204
+ export type SendDwnRequest<T extends DwnInterface> = DwnRequest<T> & (ProcessDwnRequest<T> | { messageCid: string })
205
+
206
+ export type DwnResponse<T extends DwnInterface> = {
207
+ message?: DwnMessage[T];
208
+ messageCid: string;
209
+ reply: DwnMessageReply[T];
210
+ }
211
+
212
+ export interface DwnMessageConstructor<T extends DwnInterface> {
213
+ new (): DwnMessageInstance[T];
214
+ create(params: DwnMessageParams[T]): Promise<DwnMessageInstance[T]>;
215
+ parse(rawMessage: DwnMessage[T]): Promise<DwnMessageInstance[T]>;
216
+ }
217
+
218
+ export const dwnMessageConstructors: { [T in DwnInterface]: DwnMessageConstructor<T> } = {
219
+ [DwnInterface.MessagesQuery] : MessagesQuery as any,
220
+ [DwnInterface.MessagesRead] : MessagesRead as any,
221
+ [DwnInterface.MessagesSubscribe] : MessagesSubscribe as any,
222
+ [DwnInterface.ProtocolsConfigure] : ProtocolsConfigure as any,
223
+ [DwnInterface.ProtocolsQuery] : ProtocolsQuery as any,
224
+ [DwnInterface.RecordsDelete] : RecordsDelete as any,
225
+ [DwnInterface.RecordsQuery] : RecordsQuery as any,
226
+ [DwnInterface.RecordsRead] : RecordsRead as any,
227
+ [DwnInterface.RecordsSubscribe] : RecordsSubscribe as any,
228
+ [DwnInterface.RecordsWrite] : RecordsWrite as any,
229
+ } as const;
230
+
231
+ export type DwnMessageConstructors = typeof dwnMessageConstructors;
232
+
233
+ export interface DwnMessageInstance {
234
+ [DwnInterface.MessagesQuery] : MessagesQuery;
235
+ [DwnInterface.MessagesRead] : MessagesRead;
236
+ [DwnInterface.MessagesSubscribe] : MessagesSubscribe;
237
+ [DwnInterface.ProtocolsConfigure] : ProtocolsConfigure;
238
+ [DwnInterface.ProtocolsQuery] : ProtocolsQuery;
239
+ [DwnInterface.RecordsDelete] : RecordsDelete;
240
+ [DwnInterface.RecordsQuery] : RecordsQuery;
241
+ [DwnInterface.RecordsRead] : RecordsRead;
242
+ [DwnInterface.RecordsSubscribe] : RecordsSubscribe;
243
+ [DwnInterface.RecordsWrite] : RecordsWrite;
244
+ }
245
+
246
+ export type DwnMessageWithData<T extends DwnInterface> = {
247
+ message: DwnMessage[T];
248
+ dataStream?: Readable;
249
+ }
250
+
251
+ // The following types are exported by the DWN SDK and are re-exported here so that dependent
252
+ // packages do not need to import the DWN SDK directly. This ensures that downstream packages are
253
+ // always using the same version of the DWN SDK as the agent package.
254
+
255
+ export {
256
+ DwnConstant,
257
+ Signer as DwnSigner,
258
+ DateSort as DwnDateSort,
259
+ DataEncodedRecordsWriteMessage as DwnDataEncodedRecordsWriteMessage,
260
+ PublicJwk as DwnPublicKeyJwk, // TODO: Remove once DWN SDK switches to Jwk from @enbox/crypto
261
+ PaginationCursor as DwnPaginationCursor,
262
+ MessageSubscriptionHandler as DwnMessageSubscriptionHandler,
263
+ RecordSubscriptionHandler as DwnRecordSubscriptionHandler,
264
+ MessageSubscription as DwnMessageSubscription,
265
+ MessagesPermissionScope as DwnMessagesPermissionScope,
266
+ EncryptionAlgorithm as DwnEncryptionAlgorithm,
267
+ KeyDerivationScheme as DwnKeyDerivationScheme,
268
+ PermissionGrant as DwnPermissionGrant,
269
+ PermissionGrantData as DwnPermissionGrantData,
270
+ PermissionRequest as DwnPermissionRequest,
271
+ PermissionRequestData as DwnPermissionRequestData,
272
+ PermissionsProtocol as DwnPermissionsProtocol,
273
+ ProtocolDefinition as DwnProtocolDefinition,
274
+ ProtocolPermissionScope as DwnProtocolPermissionScope,
275
+ RecordsPermissionScope as DwnRecordsPermissionScope,
276
+ PermissionConditions as DwnPermissionConditions,
277
+ PermissionScope as DwnPermissionScope,
278
+ } from '@enbox/dwn-sdk-js';
@@ -0,0 +1,137 @@
1
+ import type { BearerDid } from '@enbox/dids';
2
+ import type { KeyValueStore } from '@enbox/common';
3
+
4
+ /**
5
+ * Represents the structure of a backup for an IdentityVault, encapsulating all necessary
6
+ * information to restore the vault's state.
7
+ *
8
+ * The encrypted data encompasses all necessary information to reconstruct the vault's state,
9
+ * including the DID, keys, and any other relevant data stored in the vault.
10
+ */
11
+ export type IdentityVaultBackup = {
12
+ /** A timestamp to record when the backup was made. */
13
+ dateCreated: string;
14
+
15
+ /** The size of the backup data, in bytes. */
16
+ size: number;
17
+
18
+ /** Encrypted vault contents. */
19
+ data: string;
20
+ }
21
+
22
+ /**
23
+ * Represents the detailed data structure of a backup for an {@link IdentityVault}.
24
+ *
25
+ * This type is used to encapsulate the essential components needed to fully restore the identity
26
+ * vault from a backup. It is an intermediate representation that holds the DID and the Content
27
+ * Encryption Key (CEK) in Compact JWE format, as well as the current status of the identity vault.
28
+ */
29
+ export type IdentityVaultBackupData = {
30
+ /** The encrypted DID associated with the vault in Compact JWE format. */
31
+ did: string;
32
+
33
+ /** The encrypted key used to secure the vault's contents in Compact JWE format. */
34
+ contentEncryptionKey: string;
35
+
36
+ /** An object detailing the current status of the vault at the time of the backup. */
37
+ status: IdentityVaultStatus;
38
+ };
39
+
40
+ /**
41
+ * Configuration parameters for initializing an {@link IdentityVault} instance. These parameters
42
+ * define the settings and resources used by the {@link IdentityVault} to secure and manage identity
43
+ * data.
44
+ */
45
+ export type IdentityVaultParams = {
46
+ /**
47
+ * Optionally defines the computational effort required for key derivation, affecting security and
48
+ * performance.
49
+ */
50
+ keyDerivationWorkFactor?: number;
51
+
52
+ /** Optionally specifies a custom key-value store for persisting the vault's encrypted data. */
53
+ store?: KeyValueStore<string, any>;
54
+ }
55
+
56
+ export interface IdentityVault<T extends Record<string, any> = { InitializeResult: any }> {
57
+ /**
58
+ * Creates a backup of the current state of the IdentityVault instance returning an
59
+ * {@link IdentityVaultBackup} object.
60
+ *
61
+ * The IdentityVault must be initialized and unlocked or the backup operation will fail.
62
+ */
63
+ backup(): Promise<IdentityVaultBackup>;
64
+
65
+ /**
66
+ * Attempts to change the password of the IdentityVault.
67
+ *
68
+ * The IdentityVault must be initialized and the old password correct or the operation will fail.
69
+ *
70
+ * @throws An error if the IdentityVault has not been initialized or the `oldPassword` is
71
+ * incorrect.
72
+ */
73
+ changePassword(params: { oldPassword: string, newPassword: string }): Promise<void>;
74
+
75
+ /**
76
+ * Returns the DID associated with the {@link IdentityVault} instance.
77
+ */
78
+ getDid(): Promise<BearerDid>
79
+
80
+ /**
81
+ * Returns an {@link IdentityVaultStatus} object, which provides information about the current
82
+ * status of the `IdentityVault` instance.
83
+ */
84
+ getStatus(): Promise<IdentityVaultStatus>
85
+
86
+ /**
87
+ * Initializes the IdentityVault instance with the given `password`.
88
+ */
89
+ initialize(params: { password: string }): Promise<T['InitializeResult']>;
90
+
91
+ /**
92
+ * Returns a boolean indicating whether the IdentityVault has been initialized.
93
+ */
94
+ isInitialized(): Promise<boolean>;
95
+
96
+ /**
97
+ * Returns a boolean indicating whether the IdentityVault is currently locked.
98
+ */
99
+ isLocked(): boolean;
100
+
101
+ /**
102
+ * Locks the IdentityVault, secured by a password that must be entered to unlock.
103
+ */
104
+ lock(): Promise<void>;
105
+
106
+ /**
107
+ * Restores the IdentityVault instance to the state in the provided {@link IdentityVaultBackup}
108
+ * object.
109
+ *
110
+ * @throws An error if the backup is invalid or the password is incorrect.
111
+ */
112
+ restore(params: { backup: IdentityVaultBackup, password: string }): Promise<void>;
113
+
114
+ /**
115
+ * Attempts to unlock the IdentityVault with the provided password.
116
+ *
117
+ * @throws An error if the password is incorrect.
118
+ */
119
+ unlock(params: { password: string }): Promise<void>;
120
+ }
121
+
122
+ export type IdentityVaultStatus = {
123
+ /**
124
+ * Boolean indicating whether the IdentityVault has been initialized.
125
+ */
126
+ initialized: boolean;
127
+
128
+ /**
129
+ * The timestamp of the last backup.
130
+ */
131
+ lastBackup: string | null;
132
+
133
+ /**
134
+ * The timestamp of the last restore.
135
+ */
136
+ lastRestore: string | null;
137
+ }
@@ -0,0 +1,18 @@
1
+ import type { PortableDid } from '@enbox/dids';
2
+
3
+ /**
4
+ * Represents metadata about a Web5 Identity.
5
+ */
6
+ export interface IdentityMetadata {
7
+ name: string;
8
+ tenant: string;
9
+ uri: string;
10
+ connectedDid?: string;
11
+ }
12
+
13
+ export interface PortableIdentity {
14
+ portableDid: PortableDid;
15
+
16
+ /** {@inheritDoc IdentityMetadata} */
17
+ metadata: IdentityMetadata;
18
+ }
@@ -0,0 +1,15 @@
1
+ import type { Cipher, Jwk, KeyIdentifier, KeyWrapper, KmsExportKeyParams, KmsImportKeyParams } from '@enbox/crypto';
2
+
3
+ import type { Web5PlatformAgent } from './agent.js';
4
+ import type { KeyManager } from '../prototyping/crypto/types/key-manager.js';
5
+ import type { KeyDeleter, KeyExporter, KeyImporter } from '../prototyping/crypto/types/key-io.js';
6
+ import type { KmsCipherParams, KmsDeleteKeyParams, KmsUnwrapKeyParams, KmsWrapKeyParams } from '../prototyping/crypto/types/params-kms.js';
7
+ export interface AgentKeyManager extends KeyManager,
8
+ Cipher<KmsCipherParams, KmsCipherParams>,
9
+ KeyImporter<KmsImportKeyParams, KeyIdentifier>,
10
+ KeyExporter<KmsExportKeyParams, Jwk>,
11
+ KeyDeleter<KmsDeleteKeyParams>,
12
+ KeyWrapper<KmsWrapKeyParams, KmsUnwrapKeyParams> {
13
+
14
+ agent: Web5PlatformAgent;
15
+ }
@@ -0,0 +1,115 @@
1
+ import { DwnDataEncodedRecordsWriteMessage, DwnInterface, DwnPermissionGrant, DwnPermissionRequest, DwnPermissionScope } from './dwn.js';
2
+
3
+ export type FetchPermissionsParams = {
4
+ author: string;
5
+ target: string;
6
+ grantee?: string;
7
+ grantor?: string;
8
+ protocol?: string;
9
+ remote?: boolean;
10
+ }
11
+
12
+ export type FetchPermissionRequestParams = {
13
+ author: string;
14
+ target: string;
15
+ protocol?: string;
16
+ remote?: boolean;
17
+ }
18
+
19
+ export type IsGrantRevokedParams = {
20
+ author: string;
21
+ target: string;
22
+ grantRecordId: string;
23
+ remote?: boolean;
24
+ }
25
+
26
+ export type PermissionGrantEntry = {
27
+ grant: DwnPermissionGrant;
28
+ message: DwnDataEncodedRecordsWriteMessage;
29
+ }
30
+
31
+ export type PermissionRequestEntry = {
32
+ request: DwnPermissionRequest;
33
+ message: DwnDataEncodedRecordsWriteMessage;
34
+ }
35
+
36
+ export type PermissionRevocationEntry = {
37
+ message: DwnDataEncodedRecordsWriteMessage;
38
+ }
39
+
40
+ export type CreateGrantParams = {
41
+ store?: boolean;
42
+ requestId?: string;
43
+ author: string;
44
+ description?: string;
45
+ dateExpires: string;
46
+ grantedTo: string;
47
+ scope: DwnPermissionScope;
48
+ delegated?: boolean;
49
+ }
50
+
51
+ export type CreateRequestParams = {
52
+ store?: boolean;
53
+ author: string;
54
+ description?: string;
55
+ scope: DwnPermissionScope;
56
+ delegated?: boolean;
57
+ }
58
+
59
+ export type CreateRevocationParams = {
60
+ store?: boolean;
61
+ author: string;
62
+ grant: DwnPermissionGrant;
63
+ description?: string;
64
+ }
65
+
66
+ export type GetPermissionParams = {
67
+ connectedDid: string;
68
+ delegateDid: string;
69
+ messageType: DwnInterface;
70
+ protocol?: string;
71
+ cached?: boolean;
72
+ delegate?: boolean;
73
+ }
74
+
75
+ export interface PermissionsApi {
76
+ /**
77
+ * Get the permission grant for a given author, target, and protocol. To be used when authoring delegated requests.
78
+ */
79
+ getPermissionForRequest: (params: GetPermissionParams) => Promise<PermissionGrantEntry>;
80
+
81
+ /**
82
+ * Fetch all grants for a given author and target, optionally filtered by a specific grantee, grantor, or protocol.
83
+ */
84
+ fetchGrants: (params: FetchPermissionsParams) => Promise<PermissionGrantEntry[]>;
85
+
86
+ /**
87
+ * Fetch all requests for a given author and target, optionally filtered by a specific protocol.
88
+ */
89
+ fetchRequests: (params: FetchPermissionRequestParams) => Promise<PermissionRequestEntry[]>;
90
+
91
+ /**
92
+ * Check whether a grant is revoked by reading the revocation record for a given grant recordId.
93
+ */
94
+ isGrantRevoked: (request: IsGrantRevokedParams) => Promise<boolean>;
95
+
96
+ /**
97
+ * Create a new permission grant, optionally storing it in the DWN.
98
+ */
99
+ createGrant:(params: CreateGrantParams) => Promise<PermissionGrantEntry>;
100
+
101
+ /**
102
+ * Create a new permission request, optionally storing it in the DWN.
103
+ */
104
+ createRequest(params: CreateRequestParams): Promise<PermissionRequestEntry>;
105
+
106
+ /**
107
+ * Create a new permission revocation, optionally storing it in the DWN.
108
+ */
109
+ createRevocation(params: CreateRevocationParams): Promise<PermissionRevocationEntry>;
110
+
111
+ /**
112
+ * Clears the cache of matched permissions.
113
+ */
114
+ clear: () => Promise<void>;
115
+ }
@@ -0,0 +1,58 @@
1
+ import type { Web5PlatformAgent } from './agent.js';
2
+
3
+ /**
4
+ * The SyncEngine is responsible for syncing messages between the agent and the platform.
5
+ */
6
+ export type SyncIdentityOptions = {
7
+ /**
8
+ * The delegate DID that should be used to sign the sync messages.
9
+ */
10
+ delegateDid?: string;
11
+ /**
12
+ * The protocols that should be synced for this identity, if an empty array is provided, all messages for all protocols will be synced.
13
+ */
14
+ protocols: string[]
15
+ }
16
+ export interface SyncEngine {
17
+ /**
18
+ * The agent that the SyncEngine is attached to.
19
+ */
20
+ agent: Web5PlatformAgent;
21
+ /**
22
+ * Register an identity to be managed by the SyncEngine for syncing.
23
+ * The options can define specific protocols that should only be synced, or a delegate DID that should be used to sign the sync messages.
24
+ */
25
+ registerIdentity(params: { did: string, options?: SyncIdentityOptions }): Promise<void>;
26
+ /**
27
+ * Unregister an identity from the SyncEngine, this will stop syncing messages for this identity.
28
+ */
29
+ unregisterIdentity(did: string): Promise<void>;
30
+ /**
31
+ * Get the Sync Options for a specific identity.
32
+ */
33
+ getIdentityOptions(did: string): Promise<SyncIdentityOptions | undefined>;
34
+ /**
35
+ * Update the Sync Options for a specific identity, replaces the existing options.
36
+ */
37
+ updateIdentityOptions(params: { did: string, options: SyncIdentityOptions }): Promise<void>;
38
+ /**
39
+ * Preforms a one-shot sync operation. If no direction is provided, it will perform both push and pull.
40
+ * @param direction which direction you'd like to perform the sync operation.
41
+ *
42
+ * @throws {Error} if a sync is already in progress or the sync operation fails.
43
+ */
44
+ sync(direction?: 'push' | 'pull'): Promise<void>;
45
+ /**
46
+ * Starts a periodic sync that runs at an interval. Subsequent calls to startSync will update the interval.
47
+ *
48
+ * @param params { interval: string } the interval at which the sync operation should be performed. ex: '30s', '1m', '10m'
49
+ */
50
+ startSync(params: { interval: string }): Promise<void>;
51
+ /**
52
+ * Stops the periodic sync operation, will complete the current sync operation if one is already in progress.
53
+ *
54
+ * @param timeout the maximum amount of time, in milliseconds, to wait for the current sync operation to complete. Default is 2000 (2 seconds).
55
+ * @throws {Error} if the sync operation fails to stop before the timeout.
56
+ */
57
+ stopSync(timeout?: number): Promise<void>;
58
+ }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Verifiable Credential Types
3
+ */
4
+
5
+ export type ProcessVcRequest = { /** empty */ }
6
+ export type SendVcRequest = { /** empty */ }
7
+ export type VcResponse = { /** empty */ }