@minca/core 0.1.14 → 0.1.16

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 (528) hide show
  1. package/README.md +4 -4
  2. package/dist/elements/auth-styles.d.ts +1 -1
  3. package/dist/elements/auth-styles.d.ts.map +1 -1
  4. package/dist/elements/auth-styles.js +21 -4
  5. package/dist/elements/auth-styles.js.map +1 -1
  6. package/dist/elements/minca-auth.d.ts.map +1 -1
  7. package/dist/elements/minca-auth.js +151 -57
  8. package/dist/elements/minca-auth.js.map +1 -1
  9. package/dist/files/space-files.d.ts +15 -3
  10. package/dist/files/space-files.d.ts.map +1 -1
  11. package/dist/files/space-files.js +225 -37
  12. package/dist/files/space-files.js.map +1 -1
  13. package/dist/identity/abilities.d.ts +2 -0
  14. package/dist/identity/abilities.d.ts.map +1 -1
  15. package/dist/identity/abilities.js +2 -0
  16. package/dist/identity/abilities.js.map +1 -1
  17. package/dist/identity/account-vault.d.ts +15 -71
  18. package/dist/identity/account-vault.d.ts.map +1 -1
  19. package/dist/identity/account-vault.js +45 -104
  20. package/dist/identity/account-vault.js.map +1 -1
  21. package/dist/identity/channel.d.ts +3 -9
  22. package/dist/identity/channel.d.ts.map +1 -1
  23. package/dist/identity/channel.js +42 -42
  24. package/dist/identity/channel.js.map +1 -1
  25. package/dist/identity/contact-key.d.ts +14 -29
  26. package/dist/identity/contact-key.d.ts.map +1 -1
  27. package/dist/identity/contact-key.js +31 -51
  28. package/dist/identity/contact-key.js.map +1 -1
  29. package/dist/identity/crypto-p256.d.ts.map +1 -1
  30. package/dist/identity/crypto-p256.js +39 -53
  31. package/dist/identity/crypto-p256.js.map +1 -1
  32. package/dist/identity/hpke.d.ts.map +1 -1
  33. package/dist/identity/hpke.js +19 -19
  34. package/dist/identity/hpke.js.map +1 -1
  35. package/dist/identity/identity-manager.d.ts.map +1 -1
  36. package/dist/identity/identity-manager.js +1 -2
  37. package/dist/identity/identity-manager.js.map +1 -1
  38. package/dist/identity/policy.d.ts.map +1 -1
  39. package/dist/identity/policy.js +35 -61
  40. package/dist/identity/policy.js.map +1 -1
  41. package/dist/identity/recovery-code.d.ts +2 -8
  42. package/dist/identity/recovery-code.d.ts.map +1 -1
  43. package/dist/identity/recovery-code.js +4 -11
  44. package/dist/identity/recovery-code.js.map +1 -1
  45. package/dist/identity/root-signer.d.ts +1 -6
  46. package/dist/identity/root-signer.d.ts.map +1 -1
  47. package/dist/identity/root-signer.js +12 -15
  48. package/dist/identity/root-signer.js.map +1 -1
  49. package/dist/identity/ucan.d.ts.map +1 -1
  50. package/dist/identity/ucan.js +48 -39
  51. package/dist/identity/ucan.js.map +1 -1
  52. package/dist/identity/webauthn.d.ts +6 -11
  53. package/dist/identity/webauthn.d.ts.map +1 -1
  54. package/dist/identity/webauthn.js +18 -30
  55. package/dist/identity/webauthn.js.map +1 -1
  56. package/dist/inbox/inbox.d.ts.map +1 -1
  57. package/dist/inbox/inbox.js +40 -30
  58. package/dist/inbox/inbox.js.map +1 -1
  59. package/dist/inbox/index.d.ts +2 -0
  60. package/dist/inbox/index.d.ts.map +1 -1
  61. package/dist/inbox/index.js +1 -0
  62. package/dist/inbox/index.js.map +1 -1
  63. package/dist/inbox/names.d.ts +54 -0
  64. package/dist/inbox/names.d.ts.map +1 -0
  65. package/dist/inbox/names.js +299 -0
  66. package/dist/inbox/names.js.map +1 -0
  67. package/dist/index.d.ts +3 -6
  68. package/dist/index.d.ts.map +1 -1
  69. package/dist/index.js +9 -12
  70. package/dist/index.js.map +1 -1
  71. package/dist/network/mesh.d.ts +7 -20
  72. package/dist/network/mesh.d.ts.map +1 -1
  73. package/dist/network/mesh.js +267 -245
  74. package/dist/network/mesh.js.map +1 -1
  75. package/dist/network/relay-link.d.ts +31 -0
  76. package/dist/network/relay-link.d.ts.map +1 -0
  77. package/dist/network/relay-link.js +62 -0
  78. package/dist/network/relay-link.js.map +1 -0
  79. package/dist/network/relay-minca.d.ts +12 -1
  80. package/dist/network/relay-minca.d.ts.map +1 -1
  81. package/dist/network/relay-minca.js +25 -55
  82. package/dist/network/relay-minca.js.map +1 -1
  83. package/dist/network/relay-nostr.d.ts +14 -3
  84. package/dist/network/relay-nostr.d.ts.map +1 -1
  85. package/dist/network/relay-nostr.js +34 -72
  86. package/dist/network/relay-nostr.js.map +1 -1
  87. package/dist/network/relay-socket.d.ts +1 -1
  88. package/dist/network/relay-socket.d.ts.map +1 -1
  89. package/dist/network/relay-socket.js +3 -1
  90. package/dist/network/relay-socket.js.map +1 -1
  91. package/dist/network/relays.d.ts +26 -17
  92. package/dist/network/relays.d.ts.map +1 -1
  93. package/dist/network/relays.js +21 -28
  94. package/dist/network/relays.js.map +1 -1
  95. package/dist/network/rendezvous.d.ts +1 -1
  96. package/dist/network/rendezvous.d.ts.map +1 -1
  97. package/dist/network/rendezvous.js +2 -2
  98. package/dist/network/rendezvous.js.map +1 -1
  99. package/dist/node/actions.d.ts.map +1 -1
  100. package/dist/node/actions.js +56 -39
  101. package/dist/node/actions.js.map +1 -1
  102. package/dist/node/api.d.ts +6 -0
  103. package/dist/node/api.d.ts.map +1 -1
  104. package/dist/node/api.js +6 -0
  105. package/dist/node/api.js.map +1 -1
  106. package/dist/node/carrier.d.ts +5 -0
  107. package/dist/node/carrier.d.ts.map +1 -1
  108. package/dist/node/carrier.js +94 -73
  109. package/dist/node/carrier.js.map +1 -1
  110. package/dist/node/copy.d.ts +8 -7
  111. package/dist/node/copy.d.ts.map +1 -1
  112. package/dist/node/copy.js +54 -56
  113. package/dist/node/copy.js.map +1 -1
  114. package/dist/node/host.d.ts +39 -65
  115. package/dist/node/host.d.ts.map +1 -1
  116. package/dist/node/host.js +362 -379
  117. package/dist/node/host.js.map +1 -1
  118. package/dist/node/index.d.ts +2 -2
  119. package/dist/node/index.d.ts.map +1 -1
  120. package/dist/node/index.js +1 -1
  121. package/dist/node/index.js.map +1 -1
  122. package/dist/node/node-carriers.d.ts +35 -0
  123. package/dist/node/node-carriers.d.ts.map +1 -0
  124. package/dist/node/node-carriers.js +562 -0
  125. package/dist/node/node-carriers.js.map +1 -0
  126. package/dist/node/node-contacts.d.ts +11 -0
  127. package/dist/node/node-contacts.d.ts.map +1 -0
  128. package/dist/node/node-contacts.js +808 -0
  129. package/dist/node/node-contacts.js.map +1 -0
  130. package/dist/node/node-context.d.ts +76 -0
  131. package/dist/node/node-context.d.ts.map +1 -0
  132. package/dist/node/node-context.js +54 -0
  133. package/dist/node/node-context.js.map +1 -0
  134. package/dist/node/node-hosting.d.ts +20 -0
  135. package/dist/node/node-hosting.d.ts.map +1 -0
  136. package/dist/node/node-hosting.js +449 -0
  137. package/dist/node/node-hosting.js.map +1 -0
  138. package/dist/node/node-records.d.ts +18 -0
  139. package/dist/node/node-records.d.ts.map +1 -0
  140. package/dist/node/node-records.js +262 -0
  141. package/dist/node/node-records.js.map +1 -0
  142. package/dist/node/node.d.ts.map +1 -1
  143. package/dist/node/node.js +197 -1989
  144. package/dist/node/node.js.map +1 -1
  145. package/dist/node/remote.d.ts +5 -6
  146. package/dist/node/remote.d.ts.map +1 -1
  147. package/dist/node/remote.js +272 -260
  148. package/dist/node/remote.js.map +1 -1
  149. package/dist/node/space-catalog.d.ts +40 -0
  150. package/dist/node/space-catalog.d.ts.map +1 -0
  151. package/dist/node/space-catalog.js +158 -0
  152. package/dist/node/space-catalog.js.map +1 -0
  153. package/dist/node/space-checks.d.ts +25 -0
  154. package/dist/node/space-checks.d.ts.map +1 -0
  155. package/dist/node/space-checks.js +343 -0
  156. package/dist/node/space-checks.js.map +1 -0
  157. package/dist/node/space-history.d.ts +37 -0
  158. package/dist/node/space-history.d.ts.map +1 -0
  159. package/dist/node/space-history.js +350 -0
  160. package/dist/node/space-history.js.map +1 -0
  161. package/dist/node/space-holding.d.ts +49 -0
  162. package/dist/node/space-holding.d.ts.map +1 -0
  163. package/dist/node/space-holding.js +267 -0
  164. package/dist/node/space-holding.js.map +1 -0
  165. package/dist/node/space-index.d.ts +41 -0
  166. package/dist/node/space-index.d.ts.map +1 -0
  167. package/dist/node/space-index.js +217 -0
  168. package/dist/node/space-index.js.map +1 -0
  169. package/dist/node/space-keys.d.ts +34 -0
  170. package/dist/node/space-keys.d.ts.map +1 -0
  171. package/dist/node/space-keys.js +309 -0
  172. package/dist/node/space-keys.js.map +1 -0
  173. package/dist/node/space-lines.d.ts +33 -0
  174. package/dist/node/space-lines.d.ts.map +1 -0
  175. package/dist/node/space-lines.js +145 -0
  176. package/dist/node/space-lines.js.map +1 -0
  177. package/dist/node/space-membership.d.ts +69 -0
  178. package/dist/node/space-membership.d.ts.map +1 -0
  179. package/dist/node/space-membership.js +242 -0
  180. package/dist/node/space-membership.js.map +1 -0
  181. package/dist/node/space-mirrors.d.ts +43 -0
  182. package/dist/node/space-mirrors.d.ts.map +1 -0
  183. package/dist/node/space-mirrors.js +125 -0
  184. package/dist/node/space-mirrors.js.map +1 -0
  185. package/dist/node/space-peers.d.ts +104 -0
  186. package/dist/node/space-peers.d.ts.map +1 -0
  187. package/dist/node/space-peers.js +595 -0
  188. package/dist/node/space-peers.js.map +1 -0
  189. package/dist/node/space-profiles.d.ts +18 -0
  190. package/dist/node/space-profiles.d.ts.map +1 -0
  191. package/dist/node/space-profiles.js +105 -0
  192. package/dist/node/space-profiles.js.map +1 -0
  193. package/dist/node/space-rules.d.ts +29 -0
  194. package/dist/node/space-rules.d.ts.map +1 -0
  195. package/dist/node/space-rules.js +144 -0
  196. package/dist/node/space-rules.js.map +1 -0
  197. package/dist/node/space-runtime.d.ts +104 -143
  198. package/dist/node/space-runtime.d.ts.map +1 -1
  199. package/dist/node/space-runtime.js +293 -3954
  200. package/dist/node/space-runtime.js.map +1 -1
  201. package/dist/node/space-standing.d.ts +20 -0
  202. package/dist/node/space-standing.d.ts.map +1 -0
  203. package/dist/node/space-standing.js +317 -0
  204. package/dist/node/space-standing.js.map +1 -0
  205. package/dist/node/space-versions.d.ts +104 -0
  206. package/dist/node/space-versions.d.ts.map +1 -0
  207. package/dist/node/space-versions.js +153 -0
  208. package/dist/node/space-versions.js.map +1 -0
  209. package/dist/node/space-warrants.d.ts +25 -0
  210. package/dist/node/space-warrants.d.ts.map +1 -0
  211. package/dist/node/space-warrants.js +214 -0
  212. package/dist/node/space-warrants.js.map +1 -0
  213. package/dist/node/space-writing.d.ts +72 -0
  214. package/dist/node/space-writing.d.ts.map +1 -0
  215. package/dist/node/space-writing.js +440 -0
  216. package/dist/node/space-writing.js.map +1 -0
  217. package/dist/node/stores.d.ts +19 -50
  218. package/dist/node/stores.d.ts.map +1 -1
  219. package/dist/node/stores.js +14 -33
  220. package/dist/node/stores.js.map +1 -1
  221. package/dist/node/types.d.ts +225 -305
  222. package/dist/node/types.d.ts.map +1 -1
  223. package/dist/node/usage.d.ts +2 -24
  224. package/dist/node/usage.d.ts.map +1 -1
  225. package/dist/node/usage.js +118 -102
  226. package/dist/node/usage.js.map +1 -1
  227. package/dist/node/watch-notifications.d.ts.map +1 -1
  228. package/dist/node/watch-notifications.js +32 -29
  229. package/dist/node/watch-notifications.js.map +1 -1
  230. package/dist/node/worker.d.ts +5 -6
  231. package/dist/node/worker.d.ts.map +1 -1
  232. package/dist/node/worker.js +80 -72
  233. package/dist/node/worker.js.map +1 -1
  234. package/dist/node/writer-keys.d.ts +5 -6
  235. package/dist/node/writer-keys.d.ts.map +1 -1
  236. package/dist/node/writer-keys.js +66 -57
  237. package/dist/node/writer-keys.js.map +1 -1
  238. package/dist/node/writers.d.ts +12 -19
  239. package/dist/node/writers.d.ts.map +1 -1
  240. package/dist/node/writers.js +7 -15
  241. package/dist/node/writers.js.map +1 -1
  242. package/dist/privacy/direct.d.ts.map +1 -1
  243. package/dist/privacy/direct.js +31 -27
  244. package/dist/privacy/direct.js.map +1 -1
  245. package/dist/privacy/space-encryption.d.ts.map +1 -1
  246. package/dist/privacy/space-encryption.js +5 -9
  247. package/dist/privacy/space-encryption.js.map +1 -1
  248. package/dist/query/computed.d.ts.map +1 -1
  249. package/dist/query/computed.js +78 -77
  250. package/dist/query/computed.js.map +1 -1
  251. package/dist/query/engine.d.ts +3 -4
  252. package/dist/query/engine.d.ts.map +1 -1
  253. package/dist/query/engine.js +93 -86
  254. package/dist/query/engine.js.map +1 -1
  255. package/dist/query/filter.d.ts +8 -10
  256. package/dist/query/filter.d.ts.map +1 -1
  257. package/dist/query/filter.js +144 -161
  258. package/dist/query/filter.js.map +1 -1
  259. package/dist/records/cel-types.d.ts.map +1 -1
  260. package/dist/records/cel-types.js +13 -27
  261. package/dist/records/cel-types.js.map +1 -1
  262. package/dist/records/cel.d.ts.map +1 -1
  263. package/dist/records/cel.js +177 -242
  264. package/dist/records/cel.js.map +1 -1
  265. package/dist/records/rules.d.ts.map +1 -1
  266. package/dist/records/rules.js +46 -50
  267. package/dist/records/rules.js.map +1 -1
  268. package/dist/records/topics.d.ts.map +1 -1
  269. package/dist/records/topics.js +18 -22
  270. package/dist/records/topics.js.map +1 -1
  271. package/dist/schema/collection-def.d.ts.map +1 -1
  272. package/dist/schema/collection-def.js +16 -5
  273. package/dist/schema/collection-def.js.map +1 -1
  274. package/dist/schemas/automations.d.ts +16 -15
  275. package/dist/schemas/automations.d.ts.map +1 -1
  276. package/dist/schemas/automations.js +203 -165
  277. package/dist/schemas/automations.js.map +1 -1
  278. package/dist/schemas/blueprints.d.ts.map +1 -1
  279. package/dist/schemas/blueprints.js +14 -13
  280. package/dist/schemas/blueprints.js.map +1 -1
  281. package/dist/schemas/connectors.d.ts +12 -0
  282. package/dist/schemas/connectors.d.ts.map +1 -1
  283. package/dist/schemas/connectors.js +16 -11
  284. package/dist/schemas/connectors.js.map +1 -1
  285. package/dist/schemas/contacts.d.ts +57 -0
  286. package/dist/schemas/contacts.d.ts.map +1 -1
  287. package/dist/schemas/contacts.js +32 -0
  288. package/dist/schemas/contacts.js.map +1 -1
  289. package/dist/schemas/cron.d.ts.map +1 -1
  290. package/dist/schemas/cron.js +27 -28
  291. package/dist/schemas/cron.js.map +1 -1
  292. package/dist/schemas/defined.d.ts +6 -0
  293. package/dist/schemas/defined.d.ts.map +1 -0
  294. package/dist/schemas/defined.js +7 -0
  295. package/dist/schemas/defined.js.map +1 -0
  296. package/dist/schemas/fragments.d.ts +22 -2
  297. package/dist/schemas/fragments.d.ts.map +1 -1
  298. package/dist/schemas/fragments.js +20 -12
  299. package/dist/schemas/fragments.js.map +1 -1
  300. package/dist/schemas/guides.d.ts +3 -1
  301. package/dist/schemas/guides.d.ts.map +1 -1
  302. package/dist/schemas/guides.js +13 -12
  303. package/dist/schemas/guides.js.map +1 -1
  304. package/dist/schemas/index.d.ts +2 -2
  305. package/dist/schemas/index.d.ts.map +1 -1
  306. package/dist/schemas/index.js +18 -14
  307. package/dist/schemas/index.js.map +1 -1
  308. package/dist/schemas/library/annotations.d.ts +30 -0
  309. package/dist/schemas/library/annotations.d.ts.map +1 -1
  310. package/dist/schemas/library/annotations.js +1 -0
  311. package/dist/schemas/library/annotations.js.map +1 -1
  312. package/dist/schemas/library/community.d.ts +28 -0
  313. package/dist/schemas/library/community.d.ts.map +1 -1
  314. package/dist/schemas/library/life.d.ts +62 -2
  315. package/dist/schemas/library/life.d.ts.map +1 -1
  316. package/dist/schemas/library/media.d.ts +36 -0
  317. package/dist/schemas/library/media.d.ts.map +1 -1
  318. package/dist/schemas/library/money.d.ts +74 -2
  319. package/dist/schemas/library/money.d.ts.map +1 -1
  320. package/dist/schemas/library/planning.d.ts +56 -0
  321. package/dist/schemas/library/planning.d.ts.map +1 -1
  322. package/dist/schemas/library/publishing.d.ts +80 -4
  323. package/dist/schemas/library/publishing.d.ts.map +1 -1
  324. package/dist/schemas/library/social.d.ts +44 -0
  325. package/dist/schemas/library/social.d.ts.map +1 -1
  326. package/dist/session/account-hint.d.ts.map +1 -1
  327. package/dist/session/account-hint.js +8 -5
  328. package/dist/session/account-hint.js.map +1 -1
  329. package/dist/session/auth.d.ts +36 -2
  330. package/dist/session/auth.d.ts.map +1 -1
  331. package/dist/session/auth.js +95 -2
  332. package/dist/session/auth.js.map +1 -1
  333. package/dist/session/connect.d.ts +1 -0
  334. package/dist/session/connect.d.ts.map +1 -1
  335. package/dist/session/connect.js +3 -1
  336. package/dist/session/connect.js.map +1 -1
  337. package/dist/session/credentials.d.ts +8 -26
  338. package/dist/session/credentials.d.ts.map +1 -1
  339. package/dist/session/credentials.js +14 -32
  340. package/dist/session/credentials.js.map +1 -1
  341. package/dist/session/index.d.ts +1 -0
  342. package/dist/session/index.d.ts.map +1 -1
  343. package/dist/session/index.js +1 -0
  344. package/dist/session/index.js.map +1 -1
  345. package/dist/session/pairing.d.ts.map +1 -1
  346. package/dist/session/pairing.js +92 -88
  347. package/dist/session/pairing.js.map +1 -1
  348. package/dist/session/password-strength.d.ts.map +1 -1
  349. package/dist/session/password-strength.js +37 -37
  350. package/dist/session/password-strength.js.map +1 -1
  351. package/dist/session/places.d.ts.map +1 -1
  352. package/dist/session/places.js +18 -13
  353. package/dist/session/places.js.map +1 -1
  354. package/dist/session/popup.d.ts +13 -0
  355. package/dist/session/popup.d.ts.map +1 -0
  356. package/dist/session/popup.js +23 -0
  357. package/dist/session/popup.js.map +1 -0
  358. package/dist/space/constitution.d.ts.map +1 -1
  359. package/dist/space/constitution.js +22 -29
  360. package/dist/space/constitution.js.map +1 -1
  361. package/dist/space/grants.d.ts.map +1 -1
  362. package/dist/space/grants.js +37 -39
  363. package/dist/space/grants.js.map +1 -1
  364. package/dist/space/invite-link.d.ts.map +1 -1
  365. package/dist/space/invite-link.js +33 -33
  366. package/dist/space/invite-link.js.map +1 -1
  367. package/dist/space/own-automations.d.ts +13 -24
  368. package/dist/space/own-automations.d.ts.map +1 -1
  369. package/dist/space/own-automations.js +47 -37
  370. package/dist/space/own-automations.js.map +1 -1
  371. package/dist/space/roles.d.ts +56 -80
  372. package/dist/space/roles.d.ts.map +1 -1
  373. package/dist/space/roles.js +448 -441
  374. package/dist/space/roles.js.map +1 -1
  375. package/dist/space/space-access.d.ts +3 -4
  376. package/dist/space/space-access.d.ts.map +1 -1
  377. package/dist/space/space-access.js +3 -8
  378. package/dist/space/space-access.js.map +1 -1
  379. package/dist/storage/blob/directory.d.ts.map +1 -1
  380. package/dist/storage/blob/directory.js +39 -32
  381. package/dist/storage/blob/directory.js.map +1 -1
  382. package/dist/storage/blob/s3.d.ts.map +1 -1
  383. package/dist/storage/blob/s3.js +21 -19
  384. package/dist/storage/blob/s3.js.map +1 -1
  385. package/dist/storage/blob-store.d.ts +0 -9
  386. package/dist/storage/blob-store.d.ts.map +1 -1
  387. package/dist/storage/directory-access.d.ts +8 -32
  388. package/dist/storage/directory-access.d.ts.map +1 -1
  389. package/dist/storage/directory-access.js +11 -36
  390. package/dist/storage/directory-access.js.map +1 -1
  391. package/dist/storage/encrypted-adapter.d.ts +12 -32
  392. package/dist/storage/encrypted-adapter.d.ts.map +1 -1
  393. package/dist/storage/encrypted-adapter.js +31 -54
  394. package/dist/storage/encrypted-adapter.js.map +1 -1
  395. package/dist/storage/folder-adapter.d.ts +12 -26
  396. package/dist/storage/folder-adapter.d.ts.map +1 -1
  397. package/dist/storage/folder-adapter.js +37 -54
  398. package/dist/storage/folder-adapter.js.map +1 -1
  399. package/dist/storage/folder-reconcile.d.ts +12 -26
  400. package/dist/storage/folder-reconcile.d.ts.map +1 -1
  401. package/dist/storage/folder-reconcile.js +39 -48
  402. package/dist/storage/folder-reconcile.js.map +1 -1
  403. package/dist/storage/indexeddb-adapter.d.ts +2 -6
  404. package/dist/storage/indexeddb-adapter.d.ts.map +1 -1
  405. package/dist/storage/indexeddb-adapter.js +60 -114
  406. package/dist/storage/indexeddb-adapter.js.map +1 -1
  407. package/dist/storage/mirror.d.ts +0 -29
  408. package/dist/storage/mirror.d.ts.map +1 -1
  409. package/dist/storage/mirror.js +153 -110
  410. package/dist/storage/mirror.js.map +1 -1
  411. package/dist/storage/segment.d.ts.map +1 -1
  412. package/dist/storage/segment.js +3 -7
  413. package/dist/storage/segment.js.map +1 -1
  414. package/dist/storage/storage-provider.d.ts +6 -11
  415. package/dist/storage/storage-provider.d.ts.map +1 -1
  416. package/dist/storage/storage-provider.js +112 -116
  417. package/dist/storage/storage-provider.js.map +1 -1
  418. package/dist/sync/sync-engine.d.ts +10 -44
  419. package/dist/sync/sync-engine.d.ts.map +1 -1
  420. package/dist/sync/sync-engine.js +245 -247
  421. package/dist/sync/sync-engine.js.map +1 -1
  422. package/dist/sync/sync-messages.d.ts +1 -1
  423. package/dist/sync/sync-messages.d.ts.map +1 -1
  424. package/dist/sync/sync-messages.js +1 -1
  425. package/dist/sync/sync-messages.js.map +1 -1
  426. package/dist/utils/guards.d.ts +1 -0
  427. package/dist/utils/guards.d.ts.map +1 -1
  428. package/dist/utils/guards.js +1 -0
  429. package/dist/utils/guards.js.map +1 -1
  430. package/dist/utils/hmac.d.ts +5 -0
  431. package/dist/utils/hmac.d.ts.map +1 -0
  432. package/dist/utils/hmac.js +20 -0
  433. package/dist/utils/hmac.js.map +1 -0
  434. package/dist/utils/map.d.ts +10 -0
  435. package/dist/utils/map.d.ts.map +1 -0
  436. package/dist/utils/map.js +30 -0
  437. package/dist/utils/map.js.map +1 -0
  438. package/dist/utils/serial.d.ts +2 -0
  439. package/dist/utils/serial.d.ts.map +1 -1
  440. package/dist/utils/serial.js +9 -0
  441. package/dist/utils/serial.js.map +1 -1
  442. package/dist/validation/capability-gate.d.ts +7 -15
  443. package/dist/validation/capability-gate.d.ts.map +1 -1
  444. package/dist/validation/capability-gate.js +32 -36
  445. package/dist/validation/capability-gate.js.map +1 -1
  446. package/dist/validation/crypto-gate.d.ts.map +1 -1
  447. package/dist/validation/crypto-gate.js +12 -21
  448. package/dist/validation/crypto-gate.js.map +1 -1
  449. package/docs/README.md +3 -2
  450. package/docs/actions.md +47 -20
  451. package/docs/automations.md +1 -1
  452. package/docs/blueprints-and-guides.md +57 -13
  453. package/docs/building-an-app.md +11 -8
  454. package/docs/collections.md +33 -5
  455. package/docs/contacts.md +34 -1
  456. package/docs/contracts.md +1 -1
  457. package/docs/direct-messages.md +1 -1
  458. package/docs/inbox.md +5 -11
  459. package/docs/node.md +36 -26
  460. package/docs/records-and-queries.md +1 -1
  461. package/docs/sign-in.md +54 -26
  462. package/docs/spaces.md +6 -6
  463. package/docs/standard-library.md +33 -31
  464. package/docs/storage.md +37 -15
  465. package/docs/usernames.md +161 -0
  466. package/docs/warrants.md +1 -1
  467. package/package.json +2 -21
  468. package/dist/calls/calls.d.ts +0 -140
  469. package/dist/calls/calls.d.ts.map +0 -1
  470. package/dist/calls/calls.js +0 -861
  471. package/dist/calls/calls.js.map +0 -1
  472. package/dist/calls/index.d.ts +0 -4
  473. package/dist/calls/index.d.ts.map +0 -1
  474. package/dist/calls/index.js +0 -3
  475. package/dist/calls/index.js.map +0 -1
  476. package/dist/react/context.d.ts +0 -81
  477. package/dist/react/context.d.ts.map +0 -1
  478. package/dist/react/context.js +0 -97
  479. package/dist/react/context.js.map +0 -1
  480. package/dist/react/follow.d.ts +0 -11
  481. package/dist/react/follow.d.ts.map +0 -1
  482. package/dist/react/follow.js +0 -7
  483. package/dist/react/follow.js.map +0 -1
  484. package/dist/react/index.d.ts +0 -44
  485. package/dist/react/index.d.ts.map +0 -1
  486. package/dist/react/index.js +0 -40
  487. package/dist/react/index.js.map +0 -1
  488. package/dist/react/minca-auth.d.ts +0 -19
  489. package/dist/react/minca-auth.d.ts.map +0 -1
  490. package/dist/react/minca-auth.js +0 -36
  491. package/dist/react/minca-auth.js.map +0 -1
  492. package/dist/react/use-calls.d.ts +0 -21
  493. package/dist/react/use-calls.d.ts.map +0 -1
  494. package/dist/react/use-calls.js +0 -39
  495. package/dist/react/use-calls.js.map +0 -1
  496. package/dist/react/use-invite-link.d.ts +0 -24
  497. package/dist/react/use-invite-link.d.ts.map +0 -1
  498. package/dist/react/use-invite-link.js +0 -62
  499. package/dist/react/use-invite-link.js.map +0 -1
  500. package/dist/react/use-live.d.ts +0 -16
  501. package/dist/react/use-live.d.ts.map +0 -1
  502. package/dist/react/use-live.js +0 -56
  503. package/dist/react/use-live.js.map +0 -1
  504. package/dist/react/use-my-name.d.ts +0 -12
  505. package/dist/react/use-my-name.d.ts.map +0 -1
  506. package/dist/react/use-my-name.js +0 -38
  507. package/dist/react/use-my-name.js.map +0 -1
  508. package/dist/react/use-names.d.ts +0 -7
  509. package/dist/react/use-names.d.ts.map +0 -1
  510. package/dist/react/use-names.js +0 -13
  511. package/dist/react/use-names.js.map +0 -1
  512. package/dist/react/use-network.d.ts +0 -9
  513. package/dist/react/use-network.d.ts.map +0 -1
  514. package/dist/react/use-network.js +0 -33
  515. package/dist/react/use-network.js.map +0 -1
  516. package/dist/react/use-query.d.ts +0 -14
  517. package/dist/react/use-query.d.ts.map +0 -1
  518. package/dist/react/use-query.js +0 -26
  519. package/dist/react/use-query.js.map +0 -1
  520. package/dist/react/use-space.d.ts +0 -29
  521. package/dist/react/use-space.d.ts.map +0 -1
  522. package/dist/react/use-space.js +0 -57
  523. package/dist/react/use-space.js.map +0 -1
  524. package/dist/react/use-spaces.d.ts +0 -29
  525. package/dist/react/use-spaces.d.ts.map +0 -1
  526. package/dist/react/use-spaces.js +0 -78
  527. package/dist/react/use-spaces.js.map +0 -1
  528. package/docs/calls.md +0 -189
@@ -0,0 +1,105 @@
1
+ /**
2
+ * @module node/space-profiles
3
+ * What each member says of themselves in a space: their profile, and the
4
+ * member key a new key of the space is sealed to.
5
+ *
6
+ * Each person says who they are in a space with one record, keyed by their
7
+ * identity (`profileKey`), whose versions are always retained. The fold
8
+ * takes the newest version signed by the identity the key names, so nobody
9
+ * can rename anyone else: a version written by someone else under your key
10
+ * is simply never the answer, and it cannot push yours out, because yours
11
+ * are kept.
12
+ */
13
+ import { isContactPublicKey } from '../identity/contact-key.js';
14
+ import { MEMBER_KEY_COLLECTION, memberKeyRecordKey } from '../space/space-access.js';
15
+ import { PROFILE_COLLECTION, isAvatarRef } from '../space/account-registry.js';
16
+ import { hashedKey } from '../utils/hash.js';
17
+ import { isRecord } from '../utils/guards.js';
18
+ /**
19
+ * The key of a person's profile record in a space: one per identity, named by
20
+ * a hash of it (record keys are lower case; a did:key is not).
21
+ */
22
+ export async function profileKey(did) {
23
+ return hashedKey('profile', did);
24
+ }
25
+ export function createProfiles({ storage, versions, standing, }) {
26
+ const { judge, openBody } = versions;
27
+ const { standingOf } = standing;
28
+ let profilesCache = null;
29
+ const profileMap = () => (profilesCache ??= loadProfiles());
30
+ async function loadProfiles() {
31
+ const result = new Map();
32
+ // By key: the current version may be anyone's.
33
+ for (const [key, versions] of await storage.histories('profile:')) {
34
+ let found = null;
35
+ for (const version of versions) {
36
+ if (version.collection !== PROFILE_COLLECTION)
37
+ continue;
38
+ const verdict = await judge(version);
39
+ if (!verdict.verified || !verdict.root || (await profileKey(verdict.root)) !== key)
40
+ continue;
41
+ if (!(await standingOf(version)).ok)
42
+ continue;
43
+ if (version.deleted)
44
+ break; // they took it down
45
+ const opened = (await openBody(version)).body;
46
+ const body = isRecord(opened) ? opened : null;
47
+ if (!found) {
48
+ const name = body?.name;
49
+ if (typeof name !== 'string' || !name.trim())
50
+ break;
51
+ found = { did: verdict.root, name: name.trim().slice(0, 64), updatedAt: version.createdAt };
52
+ }
53
+ // The picture, from the newest version: one without it shows none (the older stay kept, as retained).
54
+ if (!found.avatar && found.updatedAt === version.createdAt && isAvatarRef(body?.avatar))
55
+ found = { ...found, avatar: body.avatar };
56
+ // The contact key from the newest version that has one: it never changes, and an app
57
+ // without it that wrote a newer version first must not hide it.
58
+ if (isContactPublicKey(body?.contactKey)) {
59
+ found = { ...found, contactKey: body.contactKey };
60
+ break;
61
+ }
62
+ }
63
+ if (found)
64
+ result.set(found.did, found);
65
+ }
66
+ return result;
67
+ }
68
+ /**
69
+ * Each member's member key, from their own record of it — kept in the
70
+ * clear, so someone who holds only an older key of the space can still say
71
+ * where to seal the new one.
72
+ */
73
+ let memberKeysCache = null;
74
+ const memberKeyMap = () => (memberKeysCache ??= loadMemberKeys());
75
+ async function loadMemberKeys() {
76
+ const found = new Map();
77
+ // By key: the current version may be anyone's.
78
+ for (const [key, versions] of await storage.histories('memberkey:')) {
79
+ for (const version of versions) {
80
+ if (version.collection !== MEMBER_KEY_COLLECTION || version.deleted)
81
+ continue;
82
+ const verdict = await judge(version);
83
+ if (!verdict.verified || !verdict.root || (await memberKeyRecordKey(verdict.root)) !== key)
84
+ continue;
85
+ if (!(await standingOf(version)).ok)
86
+ continue;
87
+ const body = isRecord(version.body) ? version.body : null;
88
+ if (isContactPublicKey(body?.key)) {
89
+ found.set(verdict.root, body.key);
90
+ break;
91
+ }
92
+ }
93
+ }
94
+ return found;
95
+ }
96
+ return {
97
+ profiles: profileMap,
98
+ memberKeys: memberKeyMap,
99
+ forget() {
100
+ profilesCache = null;
101
+ memberKeysCache = null;
102
+ },
103
+ };
104
+ }
105
+ //# sourceMappingURL=space-profiles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-profiles.js","sourceRoot":"","sources":["../../src/node/space-profiles.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AACH,OAAO,EAAE,kBAAkB,EAAE,MAAM,4BAA4B,CAAC;AAChE,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,0BAA0B,CAAC;AACrF,OAAO,EAAE,kBAAkB,EAAE,WAAW,EAAE,MAAM,8BAA8B,CAAC;AAC/E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAK9C;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,GAAW;IAC1C,OAAO,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,CAAC;AACnC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAC7B,OAAO,EACP,QAAQ,EACR,QAAQ,GACsE;IAC9E,MAAM,EAAE,KAAK,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAAC;IACrC,MAAM,EAAE,UAAU,EAAE,GAAG,QAAQ,CAAC;IAEhC,IAAI,aAAa,GAA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KAAK,CAAC,OAAO,CAAC,CAAC;gBACrC,IAAI,CAAC,OAAO,CAAC,QAAQ,IAAI,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,MAAM,kBAAkB,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,KAAK,GAAG;oBAAE,SAAS;gBACrG,IAAI,CAAC,CAAC,MAAM,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE;oBAAE,SAAS;gBAC9C,MAAM,IAAI,GAAG,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC;gBAC1D,IAAI,kBAAkB,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,CAAC;oBAClC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,IAAI,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;oBAClC,MAAM;gBACR,CAAC;YACH,CAAC;QACH,CAAC;QACD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO;QACL,QAAQ,EAAE,UAAU;QACpB,UAAU,EAAE,YAAY;QACxB,MAAM;YACJ,aAAa,GAAG,IAAI,CAAC;YACrB,eAAe,GAAG,IAAI,CAAC;QACzB,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { Link, Version } from '../types.js';
2
+ import type { AccessState } from '../space/roles.js';
3
+ import { type StoredCollection } from '../schema/collection-def.js';
4
+ import { type Versions, type Standing, type SpaceBase } from './space-versions.js';
5
+ export declare function createRules({ space, storage, keyring, versions, }: SpaceBase & {
6
+ readonly versions: Versions;
7
+ }): {
8
+ onePerKeying: () => Promise<CryptoKey> | null;
9
+ derivedKey: (collection: string, onePer: ReadonlyArray<string>, record: {
10
+ root: string;
11
+ links: ReadonlyArray<Link>;
12
+ body: unknown;
13
+ }) => Promise<string | null>;
14
+ definitionIn: (id: string) => Promise<"invalid" | "missing" | "unreadable" | {
15
+ readonly definition: StoredCollection;
16
+ }>;
17
+ inForce: (state: AccessState, collection: string) => Promise<string | null>;
18
+ rulesAt: (state: AccessState, collection: string) => Promise<{
19
+ rules: NonNullable<StoredCollection['rules']>;
20
+ topics: ReadonlyArray<string>;
21
+ contract: unknown;
22
+ } | null>;
23
+ tagKey: (keyId: string | null) => Promise<CryptoKey> | null;
24
+ tagProblem: (version: Version, topics: ReadonlyArray<string>) => Promise<Standing | null>;
25
+ /** A definition this node couldn't read may open now */
26
+ forgetDefinitions: () => void;
27
+ };
28
+ export type Rules = ReturnType<typeof createRules>;
29
+ //# sourceMappingURL=space-rules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-rules.d.ts","sourceRoot":"","sources":["../../src/node/space-rules.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAGjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAA0C,KAAK,gBAAgB,EAAE,MAAM,6BAA6B,CAAC;AAE5G,OAAO,EAAE,KAAK,QAAQ,EAAE,KAAK,QAAQ,EAAe,KAAK,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAEhG,wBAAgB,WAAW,CAAC,EAC1B,KAAK,EACL,OAAO,EACP,OAAO,EACP,QAAQ,GACT,EAAE,SAAS,GAAG;IAAE,QAAQ,CAAC,QAAQ,EAAE,QAAQ,CAAA;CAAE;wBASnB,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI;6BASpC,MAAM,UACV,aAAa,CAAC,MAAM,CAAC,UACrB;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,KAClE,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;uBAUC,MAAM,KAAG,OAAO;6BAJD,gBAAgB;MAIH;qBA0BxB,WAAW,cAAc,MAAM,KAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;qBAc7E,WAAW,cACN,MAAM,KACjB,OAAO,CAAC;QACT,KAAK,EAAE,WAAW,CAAC,gBAAgB,CAAC,OAAO,CAAC,CAAC,CAAC;QAC9C,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QAC9B,QAAQ,EAAE,OAAO,CAAC;KACnB,GAAG,IAAI,CAAC;oBAqBc,MAAM,GAAG,IAAI,KAAG,OAAO,CAAC,SAAS,CAAC,GAAG,IAAI;0BAgB7B,OAAO,UAAU,aAAa,CAAC,MAAM,CAAC,KAAG,OAAO,CAAC,QAAQ,GAAG,IAAI,CAAC;IAoBlG,wDAAwD;;EAG3D;AAED,MAAM,MAAM,KAAK,GAAG,UAAU,CAAC,OAAO,WAAW,CAAC,CAAC"}
@@ -0,0 +1,144 @@
1
+ /**
2
+ * @module node/space-rules
3
+ * What a collection's definition says, as of a point in the access history,
4
+ * and the keys its rules and topics derive from.
5
+ *
6
+ * A version is judged by the definition in force as of the access changes
7
+ * it saw — the same on every peer, since everyone replays the same history.
8
+ * A definition a peer cannot read (a private space, no key) cannot be
9
+ * judged by; members judge instead.
10
+ */
11
+ import { cached } from '../utils/map.js';
12
+ import { canonicalize } from '../schema/version.js';
13
+ import { onePerKey, onePerSecret } from '../records/rules.js';
14
+ import { CATALOG_COLLECTION, isStoredCollection } from '../schema/collection-def.js';
15
+ import { sameTags, tagsFor, topicKey } from '../records/topics.js';
16
+ import { sealedKeyId } from './space-versions.js';
17
+ export function createRules({ space, storage, keyring, versions, }) {
18
+ const { openBody } = versions;
19
+ let oneSecret = null;
20
+ /**
21
+ * What this space's onePer keys are keyed with: its first space key in a
22
+ * private space, its id in a public one (02 §7.3). Null when this node
23
+ * holds no key of a private space.
24
+ */
25
+ function onePerKeying() {
26
+ if (oneSecret)
27
+ return oneSecret;
28
+ if (space.visibility !== 'private')
29
+ return (oneSecret = onePerSecret({ spaceId: space.id }));
30
+ const first = space.encryptionKeyId ? keyring.get(space.encryptionKeyId) : undefined;
31
+ return first ? (oneSecret = onePerSecret({ spaceKey: first.raw })) : null;
32
+ }
33
+ /** The key `put` writes a body at under a collection's `onePer`, for `root`; null when a part it names is missing */
34
+ async function derivedKey(collection, onePer, record) {
35
+ const keying = onePerKeying();
36
+ if (!keying)
37
+ throw new Error('This private space has no key on this node');
38
+ return onePerKey(await keying, collection, onePer, record);
39
+ }
40
+ const definitions = new Map();
41
+ /** The definition held in one version of `sys.collection` */
42
+ function definitionIn(id) {
43
+ // Something missing may turn up; only settled answers are kept.
44
+ return cached(definitions, id, async () => {
45
+ const version = await storage.getVersion(id);
46
+ if (!version)
47
+ return 'missing';
48
+ if (version.collection !== CATALOG_COLLECTION || version.deleted)
49
+ return 'invalid';
50
+ const opened = await openBody(version);
51
+ if (opened.body === null)
52
+ return 'unreadable';
53
+ const body = opened.body;
54
+ if (!isStoredCollection(body) || version.key !== `collection:${body.name}`)
55
+ return 'invalid';
56
+ return { definition: body };
57
+ }, (answer) => answer !== 'missing');
58
+ }
59
+ /**
60
+ * The id of the definition in force for a collection in one state of the
61
+ * history (02 §6.3): the replay's, or, while rival first definitions stand,
62
+ * the lowest of them only when they all say the same, so no ground id picks
63
+ * the rules. One this node can't read when it can't read them all; null
64
+ * when none is in force.
65
+ */
66
+ async function inForce(state, collection) {
67
+ const entry = state.definitions.get(collection);
68
+ if (entry)
69
+ return entry.event;
70
+ const rivals = state.contested.get(collection);
71
+ if (!rivals?.length)
72
+ return null;
73
+ const found = await Promise.all(rivals.map((id) => definitionIn(id)));
74
+ const unreadable = rivals.find((_, i) => found[i] === 'unreadable');
75
+ if (unreadable)
76
+ return unreadable;
77
+ const said = new Set(found.map((one) => (typeof one === 'string' ? one : canonicalize(one.definition))));
78
+ return said.size === 1 && typeof found[0] !== 'string' ? rivals[0] : null;
79
+ }
80
+ /** The rules and topics in force for a collection in one state of the history — null when there are none to judge by */
81
+ async function rulesAt(state, collection) {
82
+ if (collection.startsWith('sys.'))
83
+ return null;
84
+ const id = await inForce(state, collection);
85
+ if (!id)
86
+ return null;
87
+ const found = await definitionIn(id);
88
+ return typeof found === 'string'
89
+ ? null
90
+ : {
91
+ rules: found.definition.rules ?? {},
92
+ topics: found.definition.topics ?? [],
93
+ contract: found.definition.contract,
94
+ };
95
+ }
96
+ // ─── Topic tags ────────────────────────────────────────────────────
97
+ //
98
+ // Keyed from the key a record's body was sealed with, in a private space;
99
+ // from the space id in a public one (`records/topics.ts`).
100
+ const topicKeys = new Map();
101
+ /** The tag key for one of the space's keys, or the public one; null when this node doesn't hold that key */
102
+ function tagKey(keyId) {
103
+ const name = keyId ?? 'public';
104
+ let found = topicKeys.get(name);
105
+ if (!found) {
106
+ const held = keyId === null ? null : keyring.get(keyId);
107
+ if (keyId !== null && !held)
108
+ return null;
109
+ found = topicKey(held ? { spaceKey: held.raw } : { spaceId: space.id });
110
+ topicKeys.set(name, found);
111
+ }
112
+ return found;
113
+ }
114
+ /**
115
+ * Why a version's tags don't match its body under the topics in force, or
116
+ * null when they do — or when this node can't read the body to tell.
117
+ */
118
+ async function tagProblem(version, topics) {
119
+ if (topics.length === 0 && !version.tags?.length)
120
+ return null;
121
+ const opened = await openBody(version);
122
+ if (opened.body === null)
123
+ return null;
124
+ const key = tagKey(opened.encrypted ? sealedKeyId(version.body) : null);
125
+ if (!key)
126
+ return null;
127
+ const expected = await tagsFor(await key, version.collection, topics, opened.body, opened.links);
128
+ return sameTags(version.tags, expected)
129
+ ? null
130
+ : { ok: false, reason: `Its topic tags don't match what it says` };
131
+ }
132
+ return {
133
+ onePerKeying,
134
+ derivedKey,
135
+ definitionIn,
136
+ inForce,
137
+ rulesAt,
138
+ tagKey,
139
+ tagProblem,
140
+ /** A definition this node couldn't read may open now */
141
+ forgetDefinitions: () => definitions.clear(),
142
+ };
143
+ }
144
+ //# sourceMappingURL=space-rules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"space-rules.js","sourceRoot":"","sources":["../../src/node/space-rules.ts"],"names":[],"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AAM,CAAC,IAAI,KAAK,IAAI;YAAE,OAAO,IAAI,CAAC;QACtC,MAAM,GAAG,GAAG,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,WAAW,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACxE,IAAI,CAAC,GAAG;YAAE,OAAO,IAAI,CAAC;QACtB,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,MAAM,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,IAAI,EAAE,MAAM,CAAC,KAAK,CAAC,CAAC;QACjG,OAAO,QAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,QAAQ,CAAC;YACrC,CAAC,CAAC,IAAI;YACN,CAAC,CAAC,EAAE,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,yCAAyC,EAAE,CAAC;IACvE,CAAC;IAED,OAAO;QACL,YAAY;QACZ,UAAU;QACV,YAAY;QACZ,OAAO;QACP,OAAO;QACP,MAAM;QACN,UAAU;QACV,wDAAwD;QACxD,iBAAiB,EAAE,GAAG,EAAE,CAAC,WAAW,CAAC,KAAK,EAAE;KAC7C,CAAC;AACJ,CAAC"}
@@ -1,47 +1,50 @@
1
- import type { Version, CryptoProvider } from '../types.js';
1
+ /**
2
+ * @module node/space-runtime
3
+ * One open space: its store, its gatekeeper, its peers, its sync.
4
+ *
5
+ * A space is the unit of storage and of sync — its own store, its own
6
+ * rooms and sockets — so two spaces never mix, and a peer you share one space
7
+ * with learns nothing about the others.
8
+ *
9
+ * **A record keeps its key; changes are versions.** Editing a record writes its
10
+ * next version — same key, `seq` one higher, `prev` naming the one replaced —
11
+ * and deleting it writes a version marked deleted. Which version is current is
12
+ * decided by `seq` and id alone (`records/version.ts`), never by a clock, so
13
+ * every node agrees and nothing replayed can roll a record back.
14
+ *
15
+ * **Who may write is the space's access history** (`space/roles.ts`): roles,
16
+ * members, invites, revoked notes and collection definitions, as records every
17
+ * version points into with `seen`. A version stands when its author held what
18
+ * its collection's rules ask, as of what it saw, and nothing it had not seen
19
+ * took that away. A version that stops standing — its author was removed, and
20
+ * the remover never saw it — is passed over when reading, and the version
21
+ * before it counts again, where the store still has one.
22
+ *
23
+ * Each part has a module of its own, opened here in the order they lean on
24
+ * each other: what a version is (`space-versions.ts`), the access history
25
+ * (`space-history.ts`), the rules (`space-rules.ts`), whether a version
26
+ * stands (`space-standing.ts`) and passes its checks (`space-checks.ts`),
27
+ * the catalogue (`space-catalog.ts`), what counts now (`space-index.ts`),
28
+ * profiles (`space-profiles.ts`), the space's keys (`space-keys.ts`),
29
+ * writing (`space-writing.ts`), writers' lines (`space-lines.ts`), warrants
30
+ * (`space-warrants.ts`), mirrors (`space-mirrors.ts`), peers
31
+ * (`space-peers.ts`) and membership (`space-membership.ts`).
32
+ */
33
+ import type { CryptoProvider, Version } from '../types.js';
2
34
  import type { Signer } from '../schema/signer.js';
3
35
  import type { SchemaEngine } from '../schema/schema-engine.js';
4
36
  import type { SpaceRecord } from '../space/space-manager.js';
5
- import { type Delegation } from '../identity/ucan.js';
6
- import type { Link } from '../types.js';
37
+ import type { Delegation } from '../identity/ucan.js';
38
+ import { type ComputedFields } from '../query/computed.js';
7
39
  import type { BlobStore } from '../storage/blob-store.js';
8
- import type { Writers } from './writers.js';
9
- import { type SpaceKey } from '../privacy/space-encryption.js';
10
- import { type Mesh } from '../network/mesh.js';
11
- import { type ReadAccess } from '../network/peer-auth.js';
12
- import { type Keeper } from '../space/roles.js';
13
- import { type FoundingRole } from '../space/grants.js';
40
+ import type { SpaceKey } from '../privacy/space-encryption.js';
41
+ import type { Mesh } from '../network/mesh.js';
42
+ import { type AvatarRef } from '../space/account-registry.js';
14
43
  import { type SealedFile } from '../files/space-files.js';
15
44
  import type { StoreFactory } from './stores.js';
16
- import { type AvatarRef } from '../space/account-registry.js';
17
- import type { CacheConfig, ConnectionState, DefineCollection, NodeCollection, ListOptions, NodeEvent, NodeNetworkConfig, NodeRecord, SpaceAccess, SpaceProfile } from './types.js';
18
- /**
19
- * The key of a person's profile record in a space: one per identity, named by
20
- * a hash of it (record keys are lower case; a did:key is not).
21
- */
22
- export declare function profileKey(did: string): Promise<string>;
23
- /**
24
- * The room a space's peers meet in on a relay. A hash of the space's id, so a
25
- * relay learns which connections belong together but not which space they are
26
- * — it cannot match the room to an invite, or to the same space elsewhere.
27
- */
28
- export declare function relayRoom(spaceId: string): Promise<string>;
29
- /** The one mesh a node's spaces share, when it has relays to meet on */
30
- export declare function meshFor(network: NodeNetworkConfig | undefined, session: {
31
- readonly did: string;
32
- readonly key: CryptoKey;
33
- }): Mesh | undefined;
34
- /** The relays a node was configured with that a space may name */
35
- export declare const usableRelays: (network: NodeNetworkConfig | undefined) => string[];
36
- /** Said when a key's note doesn't let it define collections — it can propose them instead */
37
- export declare const CANNOT_DEFINE = "This key's note doesn't let it add or change collections. Propose them instead (collections_propose), and someone who may adds them.";
38
- /** The key that signs, and the delegation that lets it */
39
- export interface ActiveSession {
40
- readonly did: string;
41
- readonly key: CryptoKey;
42
- /** The current note from the account — it is renewed, so always read it fresh. None for a key that signs for itself. */
43
- readonly proof: () => Delegation | undefined;
44
- }
45
+ import type { Writers } from './writers.js';
46
+ import { type ActiveSession } from './space-versions.js';
47
+ import type { CacheConfig, DefineCollection, NodeCollection, NodeEvent, NodeNetworkConfig } from './types.js';
45
48
  export interface SpaceRuntimeDeps {
46
49
  readonly record: SpaceRecord;
47
50
  /** The logs of the keys this node signs with: one line per key, space and collection (`node/writers.ts`) */
@@ -72,62 +75,87 @@ export interface SpaceRuntimeDeps {
72
75
  readonly onKeys?: (keys: ReadonlyArray<SpaceKey>, current: string) => Promise<void>;
73
76
  /** Told the relays the space names, when they differ from the ones the record came with */
74
77
  readonly onRelays?: (relays: ReadonlyArray<string>) => Promise<void>;
75
- /**
76
- * File stores the space is also kept in (`storage/mirror.ts`): a bucket, an
77
- * app folder. Read when the space opens, written soon after every change.
78
- */
78
+ /** File stores the space is also kept in (`storage/mirror.ts`): read when it opens, written soon after every change */
79
79
  readonly mirrors?: ReadonlyArray<BlobStore>;
80
80
  /**
81
81
  * Only notes that grant `account/write` count here — for the account's own
82
- * spaces (its list of spaces, a carrier's passes), where a note for "every
83
- * space" would otherwise let a key it trusts less join the account to a
84
- * space or leave one.
82
+ * spaces, where a note for "every space" would otherwise let a key it
83
+ * trusts less join the account to a space or leave one.
85
84
  */
86
85
  readonly accountOnly?: boolean;
87
86
  /** Hold only the collections used, once the space names a keeper (`NodeConfig.cache`). Absent: hold it whole. */
88
87
  readonly cache?: CacheConfig;
89
88
  /** Told of every version a peer sent that was taken in — what a carrier matches subscriptions against */
90
89
  readonly onArrived?: (version: Version) => void;
91
- /** Fetch every file the space's records name, as a keeper does, rather than only those read (spec 05 §16.6) */
90
+ /** Fetch and keep every file the space's records name, as a keeper does, rather than within a device's limits (spec 05 §16.6) */
92
91
  readonly fetchFiles?: 'all';
93
92
  }
94
93
  /** One open space, as `openSpaceRuntime` gives it */
95
94
  export type SpaceRuntime = Awaited<ReturnType<typeof openSpaceRuntime>>;
96
- /** Whether a version goes in the store: it stands, or stood until a later change withdrew it */
97
- /** How a version fares under its collection's contract, as this node reads them */
98
- import type { RecordContracts } from './types.js';
99
- import { type ComputedFields } from '../query/computed.js';
100
95
  export declare function openSpaceRuntime(deps: SpaceRuntimeDeps): Promise<Readonly<{
101
- list<T>(options?: ListOptions): Promise<ReadonlyArray<NodeRecord<T>>>;
102
- get: <T>(recordKey: string) => Promise<NodeRecord<T> | null>;
103
- contracts: (recordKey: string, versionId?: string) => Promise<RecordContracts | null>;
104
- /** The note a record's current version was signed under; null when its account signed it itself */
105
- noteOf: (recordKey: string) => Promise<Delegation | null>;
106
- put<T>(collection: string, body: T, options?: {
96
+ setRelays(named: ReadonlyArray<string>): Promise<void>;
97
+ setKeepers(keepers: ReadonlyArray<import("./index.js").Keeper>, copies?: number | null): Promise<void>;
98
+ access(): Promise<import("./types.js").SpaceAccess>;
99
+ may(cmd: string, args?: Readonly<Record<string, unknown>>, account?: string): Promise<boolean>;
100
+ holdsRole(role: string, account?: string): Promise<boolean>;
101
+ assign(did: string, role: string): Promise<void>;
102
+ unassign(did: string, role: string): Promise<void>;
103
+ removeMember(did: string): Promise<void>;
104
+ stepDown(keep?: string): Promise<void>;
105
+ succeed(successor: string): Promise<void>;
106
+ giveUpPlace(waitMs: number): Promise<boolean>;
107
+ defineRole(role: import("../index.js").FoundingRole): Promise<void>;
108
+ openInvite(role: string, secret?: Uint8Array): Promise<{
109
+ secret: Uint8Array<ArrayBufferLike>;
110
+ key: string;
111
+ }>;
112
+ closeInvite(inviteDid: string): Promise<void>;
113
+ revoke(key: string, options?: {
114
+ readonly waitMs?: number;
115
+ }): Promise<boolean>;
116
+ isRevoked(key: string): Promise<boolean>;
117
+ join(secret: Uint8Array): Promise<boolean>;
118
+ list: <T>(options?: import("./types.js").ListOptions) => Promise<ReadonlyArray<import("./types.js").NodeRecord<T>>>;
119
+ get: <T>(recordKey: string) => Promise<import("./types.js").NodeRecord<T> | null>;
120
+ linked: <T>(recordKey: string, options?: {
121
+ rel?: string;
122
+ collection?: string;
123
+ }) => Promise<ReadonlyArray<import("./types.js").NodeRecord<T>>>;
124
+ history: <T>(recordKey: string) => Promise<ReadonlyArray<import("./types.js").NodeRecord<T>>>;
125
+ contracts: (recordKey: string, versionId?: string) => Promise<import("./types.js").RecordContracts | null>;
126
+ put: <T>(collection: string, body: T, options?: {
107
127
  key?: string;
108
- links?: ReadonlyArray<Link>;
128
+ links?: ReadonlyArray<import("../types.js").Link>;
109
129
  as?: ActiveSession;
110
- }): Promise<NodeRecord<T>>;
111
- /** The key `name` has in an account's namespace: this account's, unless another is named */
112
- keyFor: (name: string, account?: string) => Promise<string>;
113
- /**
114
- * The key a record with this body and these links has under its
115
- * collection's `onePer`, written by `account` (default this one): null
116
- * when the collection has none, or the body lacks a part it names.
117
- */
118
- onePerKey(collection: string, body: unknown, options?: {
119
- links?: ReadonlyArray<Link>;
130
+ }) => Promise<import("./types.js").NodeRecord<T>>;
131
+ update: <T>(recordKey: string, body: T, options?: {
132
+ links?: ReadonlyArray<import("../types.js").Link>;
133
+ as?: ActiveSession;
134
+ }) => Promise<import("./types.js").NodeRecord<T>>;
135
+ remove: (recordKey: string, options?: {
136
+ as?: ActiveSession;
137
+ }) => Promise<void>;
138
+ onePerKey: (collection: string, body: unknown, options?: {
139
+ links?: ReadonlyArray<import("../types.js").Link>;
120
140
  account?: string;
121
141
  onePer?: ReadonlyArray<string>;
122
- }): Promise<string | null>;
123
- can(action: 'create' | 'edit' | 'delete', target: string): Promise<boolean>;
142
+ }) => Promise<string | null>;
143
+ can: (action: 'create' | 'edit' | 'delete', target: string) => Promise<boolean>;
144
+ /** The note a record's current version was signed under; null when its account signed it itself */
145
+ noteOf: (recordKey: string) => Promise<Delegation | null>;
146
+ /** The key `name` has in an account's namespace: this account's, unless another is named */
147
+ keyFor: (name: string, account?: string) => Promise<string>;
124
148
  /** Seals a file, keeps it, and gives back the reference a body names it by (spec 05 §16.6) */
125
149
  addFile: (bytes: Uint8Array) => Promise<SealedFile>;
126
150
  /** The bytes of a file a body refers to: held here, or fetched from peers or mirrors */
127
151
  readFile: (ref: SealedFile) => Promise<Uint8Array>;
128
152
  /** For the node itself: writes the next version of a record in a collection `put` refuses, like the profile */
129
- upsertSystem: <T>(collection: string, recordKey: string, body: T) => Promise<NodeRecord<T>>;
130
- profiles(): Promise<SpaceProfile[]>;
153
+ upsertSystem: <T>(collection: string, recordKey: string, body: T, options?: {
154
+ joining?: boolean;
155
+ }) => Promise<import("./types.js").NodeRecord<T>>;
156
+ /** For the node itself: deletes a record in a managed collection */
157
+ removeSystem: (recordKey: string, as?: ActiveSession) => Promise<void>;
158
+ profiles(): Promise<import("./types.js").SpaceProfile[]>;
131
159
  /** For the node itself: says who this account is here, when that changed and the space takes its writes */
132
160
  publishProfile(profile: {
133
161
  name: string;
@@ -137,82 +165,20 @@ export declare function openSpaceRuntime(deps: SpaceRuntimeDeps): Promise<Readon
137
165
  rotateKey: () => Promise<void>;
138
166
  memberKeys: () => Promise<Map<string, string>>;
139
167
  ownMemberKey: () => import("../index.js").ContactKeyPair | null;
140
- readAccess: () => ReadAccess | null;
141
- setRelays(named: ReadonlyArray<string>): Promise<void>;
168
+ readAccess: () => import("../network/peer-auth.js").ReadAccess | null;
142
169
  topicTag(collection: string, field: string, value: string | number | boolean): Promise<string>;
143
- setKeepers(keepers: ReadonlyArray<Keeper>, copies?: number | null): Promise<void>;
144
- update<T>(recordKey: string, body: T, options?: {
145
- links?: ReadonlyArray<Link>;
146
- as?: ActiveSession;
147
- }): Promise<NodeRecord<T>>;
148
- linked<T>(recordKey: string, options?: {
149
- rel?: string;
150
- collection?: string;
151
- }): Promise<ReadonlyArray<NodeRecord<T>>>;
152
- remove(recordKey: string, options?: {
153
- as?: ActiveSession;
154
- }): Promise<void>;
155
- /** For the node itself: deletes a record in a managed collection */
156
- removeSystem: (recordKey: string, as?: ActiveSession) => Promise<void>;
157
- history<T>(recordKey: string): Promise<ReadonlyArray<NodeRecord<T>>>;
158
170
  /** A collection's computed fields, as its definition says now; a malformed member reads as none */
159
171
  computed(collection: string): Promise<ComputedFields | undefined>;
160
172
  collections(): Promise<ReadonlyArray<NodeCollection>>;
161
173
  define(input: DefineCollection): Promise<NodeCollection>;
162
174
  undefine(name: string): Promise<void>;
163
- access(): Promise<SpaceAccess>;
164
- /** Whether this account, or another, may invoke a command with these arguments, now */
165
- may(cmd: string, args?: Readonly<Record<string, unknown>>, account?: string): Promise<boolean>;
166
- /** Whether this account, or another, holds every grant a role gives, as wide or wider, now */
167
- holdsRole(role: string, account?: string): Promise<boolean>;
168
- assign(did: string, role: string): Promise<void>;
169
- unassign(did: string, role: string): Promise<void>;
170
- removeMember(did: string): Promise<void>;
171
- /** Stops being a founder, keeping the roles held, and `keep` first when given */
172
- stepDown(keep?: string): Promise<void>;
173
- /** Names a space that succeeds this one. It changes nothing here */
174
- succeed(successor: string): Promise<void>;
175
- /**
176
- * Gives up this account's place before it forgets the space: its own
177
- * member record with no role, so the others stop counting it a reader and
178
- * a key change becomes due. Nothing sends the removal once the space is
179
- * closed, so this waits up to `waitMs` for a peer of another account to
180
- * say it has it. False when it couldn't be written, or nobody took it in
181
- * time.
182
- */
183
- giveUpPlace(waitMs: number): Promise<boolean>;
184
- /**
185
- * Waits up to `waitMs` for this node to be level with `peer` here: nothing
186
- * left in flight either way, so the peer holds everything this node does.
187
- * False when that long passed first.
188
- */
189
- syncedWith(peer: string, waitMs: number): Promise<boolean>;
190
- /** Writes a role's definition: its grants, issued by this account, and the roles it nests */
191
- defineRole(role: FoundingRole): Promise<void>;
192
- /** Opens an invite to a role, with its own fresh secret unless a short link's gives it one */
193
- openInvite(role: string, secret?: Uint8Array): Promise<{
194
- secret: Uint8Array<ArrayBufferLike>;
195
- key: string;
196
- }>;
197
- closeInvite(inviteDid: string): Promise<void>;
198
- /**
199
- * Revokes a key of this account's. With `waitMs`, it then waits up to that
200
- * long for a peer to say it has the revoke: a device about to stop sends
201
- * nothing after, so true means it left. A node with no network configured
202
- * can't send it anywhere, so false at once. Without, true once written.
203
- */
204
- revoke(key: string, options?: {
205
- readonly waitMs?: number;
206
- }): Promise<boolean>;
207
- isRevoked(key: string): Promise<boolean>;
175
+ syncedWith: (peer: string, waitMs: number) => Promise<boolean>;
208
176
  versionsOf(keys: ReadonlyArray<string>): Promise<Version<unknown>[]>;
209
177
  /** Takes in versions handed over outside sync, through the same checks as a peer's. How many were new. */
210
178
  take(versions: ReadonlyArray<Version>): Promise<number>;
211
- /** Uses an invite's secret, once its record has arrived. True when this account is a member. */
212
- join(secret: Uint8Array): Promise<boolean>;
213
179
  status(): Promise<{
214
180
  space: string;
215
- connection: ConnectionState;
181
+ connection: import("./types.js").ConnectionState;
216
182
  peers: string[];
217
183
  accounts: {
218
184
  [k: string]: string;
@@ -223,13 +189,8 @@ export declare function openSpaceRuntime(deps: SpaceRuntimeDeps): Promise<Readon
223
189
  pending: number;
224
190
  }>;
225
191
  use: (collections: ReadonlyArray<string>) => boolean;
226
- send(message: unknown, to?: string): Promise<void>;
227
- /**
228
- * Always-on nodes to hold a socket to besides those configured: the hosts
229
- * the account or the space uses. Sockets to any given before and not now
230
- * are closed.
231
- */
232
- useNodes(nodes: ReadonlyArray<string>): void;
192
+ send: (message: unknown, to?: string) => Promise<void>;
193
+ useNodes: (nodes: ReadonlyArray<string>) => void;
233
194
  close(): Promise<void>;
234
195
  }>>;
235
196
  //# sourceMappingURL=space-runtime.d.ts.map