@minca/core 0.2.0 → 0.3.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 (313) hide show
  1. package/dist/identity/abilities.d.ts +0 -2
  2. package/dist/identity/abilities.d.ts.map +1 -1
  3. package/dist/identity/abilities.js +2 -2
  4. package/dist/identity/abilities.js.map +1 -1
  5. package/dist/identity/account-vault.d.ts +0 -2
  6. package/dist/identity/account-vault.d.ts.map +1 -1
  7. package/dist/identity/account-vault.js +1 -1
  8. package/dist/identity/account-vault.js.map +1 -1
  9. package/dist/identity/crypto-p256.d.ts +1 -1
  10. package/dist/identity/crypto-p256.d.ts.map +1 -1
  11. package/dist/identity/ucan.d.ts +2 -1
  12. package/dist/identity/ucan.d.ts.map +1 -1
  13. package/dist/identity/ucan.js +1 -1
  14. package/dist/identity/ucan.js.map +1 -1
  15. package/dist/inbox/inbox.d.ts +0 -21
  16. package/dist/inbox/inbox.d.ts.map +1 -1
  17. package/dist/inbox/inbox.js +4 -4
  18. package/dist/inbox/inbox.js.map +1 -1
  19. package/dist/inbox/index.d.ts +4 -5
  20. package/dist/inbox/index.d.ts.map +1 -1
  21. package/dist/inbox/index.js +2 -3
  22. package/dist/inbox/index.js.map +1 -1
  23. package/dist/inbox/names.d.ts +0 -4
  24. package/dist/inbox/names.d.ts.map +1 -1
  25. package/dist/inbox/names.js +2 -2
  26. package/dist/inbox/names.js.map +1 -1
  27. package/dist/index.d.ts +45 -71
  28. package/dist/index.d.ts.map +1 -1
  29. package/dist/index.js +34 -53
  30. package/dist/index.js.map +1 -1
  31. package/dist/network/mesh.d.ts.map +1 -1
  32. package/dist/network/mesh.js +10 -0
  33. package/dist/network/mesh.js.map +1 -1
  34. package/dist/network/rendezvous.d.ts +2 -0
  35. package/dist/network/rendezvous.d.ts.map +1 -1
  36. package/dist/network/rendezvous.js +5 -0
  37. package/dist/network/rendezvous.js.map +1 -1
  38. package/dist/network/rtc-transport.d.ts.map +1 -1
  39. package/dist/network/rtc-transport.js +8 -3
  40. package/dist/network/rtc-transport.js.map +1 -1
  41. package/dist/node/carrier.d.ts +1 -33
  42. package/dist/node/carrier.d.ts.map +1 -1
  43. package/dist/node/carrier.js +38 -68
  44. package/dist/node/carrier.js.map +1 -1
  45. package/dist/node/index.d.ts +7 -14
  46. package/dist/node/index.d.ts.map +1 -1
  47. package/dist/node/index.js +4 -8
  48. package/dist/node/index.js.map +1 -1
  49. package/dist/node/node-carriers.d.ts.map +1 -1
  50. package/dist/node/node-carriers.js +21 -52
  51. package/dist/node/node-carriers.js.map +1 -1
  52. package/dist/node/node-context.d.ts +0 -2
  53. package/dist/node/node-context.d.ts.map +1 -1
  54. package/dist/node/node-context.js.map +1 -1
  55. package/dist/node/node-hosting.d.ts.map +1 -1
  56. package/dist/node/node-hosting.js +13 -4
  57. package/dist/node/node-hosting.js.map +1 -1
  58. package/dist/node/node-records.js +1 -1
  59. package/dist/node/node-records.js.map +1 -1
  60. package/dist/node/node.d.ts.map +1 -1
  61. package/dist/node/node.js +134 -36
  62. package/dist/node/node.js.map +1 -1
  63. package/dist/node/space-checks.d.ts +3 -1
  64. package/dist/node/space-checks.d.ts.map +1 -1
  65. package/dist/node/space-checks.js +7 -3
  66. package/dist/node/space-checks.js.map +1 -1
  67. package/dist/node/space-holding.d.ts +5 -0
  68. package/dist/node/space-holding.d.ts.map +1 -1
  69. package/dist/node/space-holding.js +90 -5
  70. package/dist/node/space-holding.js.map +1 -1
  71. package/dist/node/space-lines.d.ts +3 -0
  72. package/dist/node/space-lines.d.ts.map +1 -1
  73. package/dist/node/space-lines.js +13 -1
  74. package/dist/node/space-lines.js.map +1 -1
  75. package/dist/node/space-membership.js +4 -4
  76. package/dist/node/space-membership.js.map +1 -1
  77. package/dist/node/space-peers.d.ts +5 -2
  78. package/dist/node/space-peers.d.ts.map +1 -1
  79. package/dist/node/space-peers.js +3 -2
  80. package/dist/node/space-peers.js.map +1 -1
  81. package/dist/node/space-runtime.d.ts +3 -1
  82. package/dist/node/space-runtime.d.ts.map +1 -1
  83. package/dist/node/space-runtime.js +29 -8
  84. package/dist/node/space-runtime.js.map +1 -1
  85. package/dist/node/space-standing.d.ts +1 -1
  86. package/dist/node/space-standing.d.ts.map +1 -1
  87. package/dist/node/space-standing.js +11 -4
  88. package/dist/node/space-standing.js.map +1 -1
  89. package/dist/node/space-writing.d.ts.map +1 -1
  90. package/dist/node/space-writing.js +9 -0
  91. package/dist/node/space-writing.js.map +1 -1
  92. package/dist/node/stores.d.ts +9 -1
  93. package/dist/node/stores.d.ts.map +1 -1
  94. package/dist/node/stores.js +4 -2
  95. package/dist/node/stores.js.map +1 -1
  96. package/dist/node/types.d.ts +16 -5
  97. package/dist/node/types.d.ts.map +1 -1
  98. package/dist/node/worker.d.ts +14 -6
  99. package/dist/node/worker.d.ts.map +1 -1
  100. package/dist/node/worker.js +59 -20
  101. package/dist/node/worker.js.map +1 -1
  102. package/dist/node/writer-keys.d.ts +2 -2
  103. package/dist/node/writer-keys.d.ts.map +1 -1
  104. package/dist/node/writer-keys.js +12 -14
  105. package/dist/node/writer-keys.js.map +1 -1
  106. package/dist/privacy/direct.d.ts +0 -7
  107. package/dist/privacy/direct.d.ts.map +1 -1
  108. package/dist/privacy/direct.js +2 -2
  109. package/dist/privacy/direct.js.map +1 -1
  110. package/dist/query/filter.d.ts +0 -2
  111. package/dist/query/filter.d.ts.map +1 -1
  112. package/dist/query/filter.js +1 -1
  113. package/dist/query/filter.js.map +1 -1
  114. package/dist/query/types.d.ts +2 -6
  115. package/dist/query/types.d.ts.map +1 -1
  116. package/dist/query/types.js.map +1 -1
  117. package/dist/records/key.d.ts +2 -0
  118. package/dist/records/key.d.ts.map +1 -1
  119. package/dist/records/key.js +4 -0
  120. package/dist/records/key.js.map +1 -1
  121. package/dist/records/links.js +1 -1
  122. package/dist/schemas/direct.d.ts +70 -0
  123. package/dist/schemas/direct.d.ts.map +1 -0
  124. package/dist/schemas/direct.js +39 -0
  125. package/dist/schemas/direct.js.map +1 -0
  126. package/dist/schemas/index.d.ts +10 -73
  127. package/dist/schemas/index.d.ts.map +1 -1
  128. package/dist/schemas/index.js +8 -66
  129. package/dist/schemas/index.js.map +1 -1
  130. package/dist/session/connect.d.ts +12 -5
  131. package/dist/session/connect.d.ts.map +1 -1
  132. package/dist/session/connect.js +25 -21
  133. package/dist/session/connect.js.map +1 -1
  134. package/dist/session/connection.d.ts +8 -2
  135. package/dist/session/connection.d.ts.map +1 -1
  136. package/dist/session/connection.js +140 -11
  137. package/dist/session/connection.js.map +1 -1
  138. package/dist/session/hosting.d.ts +1 -7
  139. package/dist/session/hosting.d.ts.map +1 -1
  140. package/dist/session/hosting.js +3 -3
  141. package/dist/session/hosting.js.map +1 -1
  142. package/dist/session/index.d.ts +7 -12
  143. package/dist/session/index.d.ts.map +1 -1
  144. package/dist/session/index.js +6 -9
  145. package/dist/session/index.js.map +1 -1
  146. package/dist/session/stay-signed-in.d.ts +0 -1
  147. package/dist/session/stay-signed-in.d.ts.map +1 -1
  148. package/dist/session/stay-signed-in.js +1 -1
  149. package/dist/session/stay-signed-in.js.map +1 -1
  150. package/dist/space/account-registry.d.ts +0 -3
  151. package/dist/space/account-registry.d.ts.map +1 -1
  152. package/dist/space/account-registry.js.map +1 -1
  153. package/dist/space/own-automations.d.ts +51 -95
  154. package/dist/space/own-automations.d.ts.map +1 -1
  155. package/dist/space/own-automations.js +100 -295
  156. package/dist/space/own-automations.js.map +1 -1
  157. package/dist/space/pass.d.ts +8 -3
  158. package/dist/space/pass.d.ts.map +1 -1
  159. package/dist/space/pass.js +4 -3
  160. package/dist/space/pass.js.map +1 -1
  161. package/dist/space/space-manager.d.ts +1 -3
  162. package/dist/space/space-manager.d.ts.map +1 -1
  163. package/dist/space/space-manager.js +5 -7
  164. package/dist/space/space-manager.js.map +1 -1
  165. package/dist/storage/body-cache.d.ts +26 -0
  166. package/dist/storage/body-cache.d.ts.map +1 -0
  167. package/dist/storage/body-cache.js +41 -0
  168. package/dist/storage/body-cache.js.map +1 -0
  169. package/dist/storage/encrypted-adapter.d.ts +0 -5
  170. package/dist/storage/encrypted-adapter.d.ts.map +1 -1
  171. package/dist/storage/encrypted-adapter.js +1 -1
  172. package/dist/storage/encrypted-adapter.js.map +1 -1
  173. package/dist/storage/folder-adapter.d.ts +8 -2
  174. package/dist/storage/folder-adapter.d.ts.map +1 -1
  175. package/dist/storage/folder-adapter.js +43 -26
  176. package/dist/storage/folder-adapter.js.map +1 -1
  177. package/dist/storage/indexeddb-adapter.js +27 -2
  178. package/dist/storage/indexeddb-adapter.js.map +1 -1
  179. package/dist/storage/sqlite-adapter.d.ts +57 -0
  180. package/dist/storage/sqlite-adapter.d.ts.map +1 -0
  181. package/dist/storage/sqlite-adapter.js +213 -0
  182. package/dist/storage/sqlite-adapter.js.map +1 -0
  183. package/dist/storage/storage-provider.d.ts +21 -2
  184. package/dist/storage/storage-provider.d.ts.map +1 -1
  185. package/dist/storage/storage-provider.js +149 -56
  186. package/dist/storage/storage-provider.js.map +1 -1
  187. package/dist/sync/sync-engine.d.ts +10 -4
  188. package/dist/sync/sync-engine.d.ts.map +1 -1
  189. package/dist/sync/sync-engine.js +120 -38
  190. package/dist/sync/sync-engine.js.map +1 -1
  191. package/dist/sync/sync-messages.d.ts +4 -0
  192. package/dist/sync/sync-messages.d.ts.map +1 -1
  193. package/dist/sync/sync-messages.js.map +1 -1
  194. package/dist/types.d.ts +0 -7
  195. package/dist/types.d.ts.map +1 -1
  196. package/dist/types.js +0 -1
  197. package/dist/types.js.map +1 -1
  198. package/dist/utils/step.d.ts +8 -0
  199. package/dist/utils/step.d.ts.map +1 -0
  200. package/dist/utils/step.js +15 -0
  201. package/dist/utils/step.js.map +1 -0
  202. package/docs/README.md +1 -1
  203. package/docs/actions.md +41 -2
  204. package/docs/agents.md +13 -10
  205. package/docs/automations.md +16 -48
  206. package/docs/blueprints-and-guides.md +2 -2
  207. package/docs/bots.md +3 -3
  208. package/docs/collections.md +2 -4
  209. package/docs/computed.md +1 -2
  210. package/docs/node.md +87 -23
  211. package/docs/proposing-collections.md +3 -3
  212. package/docs/sign-in.md +16 -16
  213. package/docs/spaces.md +0 -5
  214. package/docs/standard-library.md +6 -8
  215. package/docs/storage.md +78 -12
  216. package/docs/usernames.md +1 -1
  217. package/package.json +7 -8
  218. package/dist/node/actions.d.ts +0 -85
  219. package/dist/node/actions.d.ts.map +0 -1
  220. package/dist/node/actions.js +0 -921
  221. package/dist/node/actions.js.map +0 -1
  222. package/dist/node/host.d.ts +0 -187
  223. package/dist/node/host.d.ts.map +0 -1
  224. package/dist/node/host.js +0 -818
  225. package/dist/node/host.js.map +0 -1
  226. package/dist/node/usage.d.ts +0 -32
  227. package/dist/node/usage.d.ts.map +0 -1
  228. package/dist/node/usage.js +0 -217
  229. package/dist/node/usage.js.map +0 -1
  230. package/dist/node/watch-notifications.d.ts +0 -25
  231. package/dist/node/watch-notifications.d.ts.map +0 -1
  232. package/dist/node/watch-notifications.js +0 -166
  233. package/dist/node/watch-notifications.js.map +0 -1
  234. package/dist/schemas/automations.d.ts +0 -390
  235. package/dist/schemas/automations.d.ts.map +0 -1
  236. package/dist/schemas/automations.js +0 -619
  237. package/dist/schemas/automations.js.map +0 -1
  238. package/dist/schemas/blueprints.d.ts +0 -122
  239. package/dist/schemas/blueprints.d.ts.map +0 -1
  240. package/dist/schemas/blueprints.js +0 -337
  241. package/dist/schemas/blueprints.js.map +0 -1
  242. package/dist/schemas/choosing.d.ts +0 -19
  243. package/dist/schemas/choosing.d.ts.map +0 -1
  244. package/dist/schemas/choosing.js +0 -69
  245. package/dist/schemas/choosing.js.map +0 -1
  246. package/dist/schemas/connectors.d.ts +0 -202
  247. package/dist/schemas/connectors.d.ts.map +0 -1
  248. package/dist/schemas/connectors.js +0 -140
  249. package/dist/schemas/connectors.js.map +0 -1
  250. package/dist/schemas/cron.d.ts +0 -14
  251. package/dist/schemas/cron.d.ts.map +0 -1
  252. package/dist/schemas/cron.js +0 -75
  253. package/dist/schemas/cron.js.map +0 -1
  254. package/dist/schemas/geo.d.ts +0 -63
  255. package/dist/schemas/geo.d.ts.map +0 -1
  256. package/dist/schemas/geo.js +0 -131
  257. package/dist/schemas/geo.js.map +0 -1
  258. package/dist/schemas/guides.d.ts +0 -26
  259. package/dist/schemas/guides.d.ts.map +0 -1
  260. package/dist/schemas/guides.js +0 -33
  261. package/dist/schemas/guides.js.map +0 -1
  262. package/dist/schemas/library/annotations.d.ts +0 -616
  263. package/dist/schemas/library/annotations.d.ts.map +0 -1
  264. package/dist/schemas/library/annotations.js +0 -156
  265. package/dist/schemas/library/annotations.js.map +0 -1
  266. package/dist/schemas/library/collections.d.ts +0 -211
  267. package/dist/schemas/library/collections.d.ts.map +0 -1
  268. package/dist/schemas/library/collections.js +0 -57
  269. package/dist/schemas/library/collections.js.map +0 -1
  270. package/dist/schemas/library/community.d.ts +0 -1136
  271. package/dist/schemas/library/community.d.ts.map +0 -1
  272. package/dist/schemas/library/community.js +0 -315
  273. package/dist/schemas/library/community.js.map +0 -1
  274. package/dist/schemas/library/life.d.ts +0 -1440
  275. package/dist/schemas/library/life.d.ts.map +0 -1
  276. package/dist/schemas/library/life.js +0 -202
  277. package/dist/schemas/library/life.js.map +0 -1
  278. package/dist/schemas/library/media.d.ts +0 -1002
  279. package/dist/schemas/library/media.d.ts.map +0 -1
  280. package/dist/schemas/library/media.js +0 -110
  281. package/dist/schemas/library/media.js.map +0 -1
  282. package/dist/schemas/library/money.d.ts +0 -1221
  283. package/dist/schemas/library/money.d.ts.map +0 -1
  284. package/dist/schemas/library/money.js +0 -168
  285. package/dist/schemas/library/money.js.map +0 -1
  286. package/dist/schemas/library/planning.d.ts +0 -1107
  287. package/dist/schemas/library/planning.d.ts.map +0 -1
  288. package/dist/schemas/library/planning.js +0 -214
  289. package/dist/schemas/library/planning.js.map +0 -1
  290. package/dist/schemas/library/publishing.d.ts +0 -1499
  291. package/dist/schemas/library/publishing.d.ts.map +0 -1
  292. package/dist/schemas/library/publishing.js +0 -285
  293. package/dist/schemas/library/publishing.js.map +0 -1
  294. package/dist/schemas/library/social.d.ts +0 -1257
  295. package/dist/schemas/library/social.d.ts.map +0 -1
  296. package/dist/schemas/library/social.js +0 -147
  297. package/dist/schemas/library/social.js.map +0 -1
  298. package/dist/schemas/standard.d.ts +0 -21
  299. package/dist/schemas/standard.d.ts.map +0 -1
  300. package/dist/schemas/standard.js +0 -39
  301. package/dist/schemas/standard.js.map +0 -1
  302. package/dist/session/auth.d.ts +0 -411
  303. package/dist/session/auth.d.ts.map +0 -1
  304. package/dist/session/auth.js +0 -1529
  305. package/dist/session/auth.js.map +0 -1
  306. package/dist/session/credentials.d.ts +0 -30
  307. package/dist/session/credentials.d.ts.map +0 -1
  308. package/dist/session/credentials.js +0 -63
  309. package/dist/session/credentials.js.map +0 -1
  310. package/dist/session/password-strength.d.ts +0 -22
  311. package/dist/session/password-strength.d.ts.map +0 -1
  312. package/dist/session/password-strength.js +0 -130
  313. package/dist/session/password-strength.js.map +0 -1
package/docs/sign-in.md CHANGED
@@ -12,7 +12,7 @@ The flow is state and actions: draw a screen for each `stage`, and call an
12
12
  action from its buttons. `subscribe` calls back after every change.
13
13
 
14
14
  ```js
15
- import { createMincaAuth } from '@minca/core/session';
15
+ import { createMincaAuth } from '@minca/auth';
16
16
 
17
17
  const auth = createMincaAuth({ appName: 'Todo', network: { relays: ['wss://relay.minca.social'] } });
18
18
 
@@ -28,7 +28,7 @@ In React, hand the flow to `MincaProvider`, and read it with `useMinca`:
28
28
 
29
29
  ```tsx
30
30
  import { createRoot } from 'react-dom/client';
31
- import { createMincaAuth } from '@minca/core/session';
31
+ import { createMincaAuth } from '@minca/auth';
32
32
  import { MincaProvider, useMinca } from '@minca/react';
33
33
 
34
34
  const auth = createMincaAuth({ appName: 'Todo', network: { relays: ['wss://relay.minca.social'] } });
@@ -71,13 +71,13 @@ them most recently used first.
71
71
  The flow is a state to read and actions to call. `auth.getState().stage`
72
72
  says which screen it is on. It goes from `starting` through the screens of signing in or setting up,
73
73
  to `ready`. What each stage means is in
74
- [`AuthStage`](https://minca.dev/api/session/type-aliases/AuthStage/).
74
+ [`AuthStage`](https://minca.dev/api/auth/type-aliases/AuthStage/).
75
75
 
76
76
  Where data lives is asked at `existing`, not up front. A page that waits for
77
77
  `ready` doesn't see the session during `recovery`, `unlock` or `pod`.
78
78
 
79
79
  A failed action sets `error`, an
80
- [`AuthError`](https://minca.dev/api/session/interfaces/AuthError/), and stays
80
+ [`AuthError`](https://minca.dev/api/auth/interfaces/AuthError/), and stays
81
81
  on the same stage. A dismissed passkey or folder prompt sets no error.
82
82
 
83
83
  ### Moving between stages
@@ -179,7 +179,7 @@ doesn't ask again. The choices are `never`, `1d`, `7d` and `30d`. The default
179
179
  is `7d`, and each use pushes the expiry forward.
180
180
 
181
181
  ```ts
182
- import { createMincaAuth } from '@minca/core/session';
182
+ import { createMincaAuth } from '@minca/auth';
183
183
 
184
184
  const auth = createMincaAuth();
185
185
  await auth.staySignedIn.setChoice('30d');
@@ -225,7 +225,7 @@ sign-in kept for days. So anything that hands out the whole account, or
225
225
  changes how it signs in, asks again first:
226
226
 
227
227
  ```ts
228
- import { createMincaAuth } from '@minca/core/session';
228
+ import { createMincaAuth } from '@minca/auth';
229
229
 
230
230
  const auth = createMincaAuth();
231
231
  const ok = await auth.confirm({ password: 'correct horse battery staple' });
@@ -233,7 +233,7 @@ const ok = await auth.confirm({ password: 'correct horse battery staple' });
233
233
 
234
234
  The proof is the password, the passkey's own check (a fingerprint, a face or
235
235
  a PIN), or the recovery code itself
236
- ([`MincaAuth.confirm`](https://minca.dev/api/session/interfaces/MincaAuth/)).
236
+ ([`MincaAuth.confirm`](https://minca.dev/api/auth/interfaces/MincaAuth/)).
237
237
  A wrong answer resolves false and sets `error`. A passkey with nothing behind
238
238
  it is no proof.
239
239
 
@@ -342,10 +342,9 @@ the person chooses:
342
342
  `forgetBrowserCopy()` then deletes the browser's copy. Other accounts in the
343
343
  pod are never touched.
344
344
 
345
- The page writes to the pod only while it is open. A carrier given the same
346
- folder, such as the Chrome extension, keeps it up to date while the page is
347
- closed. It learns of the pod when it connects, so one that connected before
348
- the move must connect again.
345
+ The page writes to the pod only while it is open. The Chrome extension, given
346
+ the same folder, keeps it up to date while the page is closed: the person
347
+ picks the folder there, and it finds the account in it.
349
348
 
350
349
  ## Removing an account
351
350
 
@@ -384,7 +383,7 @@ no proof. [Threat model §3.1](https://github.com/leifriksheim/minca/blob/main/s
384
383
  ## Options
385
384
 
386
385
  `createMincaAuth(config)` takes the options in
387
- [`MincaAuthConfig`](https://minca.dev/api/session/interfaces/MincaAuthConfig/).
386
+ [`MincaAuthConfig`](https://minca.dev/api/auth/interfaces/MincaAuthConfig/).
388
387
  Every one has a default, so `createMincaAuth()` alone signs in offline, in
389
388
  this browser.
390
389
 
@@ -448,7 +447,7 @@ Device keys in the vault are in
448
447
 
449
448
  A sign-in starts a node with the account's keys, the place's stores for that
450
449
  account ([stores](node.md#stores)) and the configured network. The session is a
451
- [`MincaSession`](https://minca.dev/api/session/interfaces/MincaSession/).
450
+ [`MincaSession`](https://minca.dev/api/auth/interfaces/MincaSession/).
452
451
 
453
452
  The seed stays inside the auth object. `recoveryCode()` returns it as a
454
453
  recovery code. The page also holds the local key, which seals a pod's
@@ -481,7 +480,7 @@ chose, from 1/24 to 365.
481
480
  ### Connections
482
481
 
483
482
  `auth.connections()` lists what the home has connected, each a
484
- [`Connection`](https://minca.dev/api/session/interfaces/Connection/). They are kept
483
+ [`Connection`](https://minca.dev/api/auth/interfaces/Connection/). They are kept
485
484
  per account in `localStorage` under `<prefix>.connections:<accountId>`. A kept
486
485
  connection in any other shape is dropped when read, and its app connects
487
486
  again.
@@ -492,8 +491,9 @@ revokes an app just because its time has passed.
492
491
 
493
492
  A program connected by code at the home's own origin (`via: 'code'`) is kept
494
493
  by its key instead, so each such program is its own (`connectionKey`). A
495
- carrier is kept apart from the app at its origin, and connecting one never
496
- replaces the other.
494
+ carrier is kept by its key too. One connecting leaves the app at its origin;
495
+ an app connecting from a carrier's origin is that program now holding keys,
496
+ and the home removes the carrier.
497
497
 
498
498
  ### Disconnecting
499
499
 
package/docs/spaces.md CHANGED
@@ -327,8 +327,3 @@ await connection.propose([
327
327
  `checkOwnAutomation` says whether one can be kept. `matches(record, filter)`
328
328
  says whether a filter holds, so you can show what it would have matched
329
329
  before proposing it.
330
-
331
- A carrier wakes the app only on a condition on a topic field, at the top of
332
- `where` or in an `$and` there. The app judges the rest. With no such
333
- condition, a carrier wakes the app for every new record of the collection,
334
- and the app turns down the rest.
@@ -9,7 +9,7 @@ records, and you read theirs.
9
9
  import type { NodeRecord } from '@minca/core';
10
10
  declare const post: NodeRecord;
11
11
  // ---cut---
12
- import { reaction, comment, useSchemas } from '@minca/core/schemas';
12
+ import { reaction, comment, useSchemas } from '@minca/std';
13
13
 
14
14
  await useSchemas(node, space.id, [reaction, comment]);
15
15
  await node.records.put(
@@ -148,7 +148,7 @@ the space's grants. In the `community` template, members change only what
148
148
  they made, moderators change anything, and only moderators and admins write
149
149
  in the collections in `STAFF_COLLECTIONS` ([spaces](permissions.md#presets)).
150
150
 
151
- The tables are made from the definitions in `@minca/core/schemas` each time
151
+ The tables are made from the definitions in `@minca/std` each time
152
152
  [minca.dev](https://minca.dev/collections/standard-library/#the-definitions)
153
153
  is built, so they always match the code.
154
154
 
@@ -249,7 +249,7 @@ the one it had.
249
249
  import type { NodeRecord } from '@minca/core';
250
250
  declare const message: NodeRecord;
251
251
  // ---cut---
252
- import { setActivity, activeNow } from '@minca/core/schemas';
252
+ import { setActivity, activeNow } from '@minca/std';
253
253
 
254
254
  await setActivity(node, space.id, message.key, 'working', 'Reading the thread');
255
255
  ```
@@ -338,7 +338,7 @@ message they replied to. Never fill them by matching text.
338
338
 
339
339
  They are topics, as is a message's `in` link. So an automation of the
340
340
  account's own can ask for only what mentions it, replies to it, or is in one
341
- channel, and a carrier's wake can match these unread:
341
+ channel:
342
342
 
343
343
  ```json
344
344
  { "where": { "mentions": { "$contains": "$me" } } }
@@ -368,9 +368,7 @@ A record written in answer to someone's record names them in
368
368
  | `std.order`, `std.order-update` | the listing's or the order's author |
369
369
 
370
370
  It's a topic, so "someone answered what I wrote" is
371
- `where: { "respondingTo": { "$contains": "$me" } }`, and a carrier's wake can
372
- match it unread. The link says the same to a node that can read, but a
373
- carrier can't read a private space's links, so the account is written out.
371
+ `where: { "respondingTo": { "$contains": "$me" } }`.
374
372
  Fill it from the author of the linked record, and leave it out when that's
375
373
  the writer.
376
374
 
@@ -446,7 +444,7 @@ import type { NodeRecord } from '@minca/core';
446
444
  declare const above: NodeRecord<{ position: string }> | undefined;
447
445
  declare const below: NodeRecord<{ position: string }> | undefined;
448
446
  // ---cut---
449
- import { positionBetween } from '@minca/core/schemas';
447
+ import { positionBetween } from '@minca/std';
450
448
 
451
449
  positionBetween(above?.body?.position, below?.body?.position);
452
450
  ```
package/docs/storage.md CHANGED
@@ -312,26 +312,71 @@ names a version that isn't there.
312
312
 
313
313
  The library's adapters are IndexedDB ([above](#indexeddb)), a directory
314
314
  (`directoryStores`, for a data folder's registry and a node's stores on
315
- disk), a sealing wrapper, and one in memory for tests.
315
+ disk), SQLite (`sqliteStores`, [below](#sqlite)), a sealing wrapper, and one
316
+ in memory for tests.
317
+
318
+ A directory store keeps its versions and its entries' keys in memory, so a
319
+ query or a listing reads no directory. It reads the keys again when the node
320
+ reloads it. The values stay on disk, since they include file chunks. A data
321
+ folder's registry is written by every app of the account and reloaded by
322
+ none, so it reads the disk each time instead (`shared`).
323
+
324
+ Since the keys are in memory, one process writes a directory store, or the
325
+ node that has it open watches it: the daemon finds a command's writes to a
326
+ space's store when it reloads, every two seconds. Until then a key another
327
+ writer deleted is still listed, though it reads as missing.
328
+
329
+ ### SQLite
330
+
331
+ `sqliteStores(db)` keeps every store of a node in one SQLite database. A
332
+ host keeps its stores this way. Pass it a connection: `DatabaseSync` from
333
+ `node:sqlite` in Node, or `Database` from `bun:sqlite` in Bun. The library
334
+ imports no driver, so it runs wherever one does.
335
+
336
+ ```ts
337
+ import { sqliteStores, type SqliteDatabase } from '@minca/core';
338
+ declare const DatabaseSync: new (file: string) => SqliteDatabase;
339
+ // ---cut---
340
+ // import { DatabaseSync } from 'node:sqlite';
341
+ const stores = sqliteStores(new DatabaseSync('node.sqlite'));
342
+ ```
343
+
344
+ Each store is a path, and its entries and version bodies are rows. Every
345
+ write is one transaction, and listing a prefix reads an index. A key may not
346
+ hold U+0000. It keeps
347
+ nothing in memory between calls, so there is nothing to reload, and nothing
348
+ polls it. One process writes the database. `stores.size(path)` gives what a
349
+ store takes, in bytes.
350
+
351
+ Closing a store leaves the database open, since the other stores share it.
352
+ Close the connection when the node is done.
316
353
 
317
354
  ## The store in memory
318
355
 
319
356
  A store reads its entries once, then keeps what it needs in memory: each
320
357
  collection's set of records, and the entries it read or wrote. It also keeps
321
- up to 50,000 version bodies, letting the oldest go first. A body never
358
+ version bodies, letting the one used longest ago go first. A body never
322
359
  changes, so this is always safe. An entry read while a change was landing is
323
360
  not kept.
324
361
 
362
+ Each store keeps up to 50,000 bodies of its own, unless its store factory
363
+ has a `cache`. Then all the stores share that one. The SQLite stores share
364
+ 4,000, since reading a body again is cheap: the bodies a node keeps then
365
+ take the same memory however many spaces it holds. Each open space still
366
+ keeps its sets and entries.
367
+
325
368
  When another writer changes the same store, the node reads all of it again
326
369
  (`invalidate`):
327
370
 
328
- - **Tabs in one browser.** Where shared workers work, the apps in this
329
- repository run one node for all of a site's tabs in a `SharedWorker`, one
330
- per account and key. Then there's nothing to tell.
331
- - **Elsewhere** each tab runs its node in a worker of its own. Tabs tell each other through a
332
- `BroadcastChannel` named `minca-node:<root DID>:<space id>`. Chrome on
333
- Android has no shared workers, and WebKit drops a message to one that
334
- holds a `CryptoKey`.
371
+ - **Tabs in one browser.** The app in this repository runs one node for all
372
+ of a site's tabs in a `SharedWorker`, one per account and key. Its stores
373
+ have that one writer, so there's nothing to tell, and a tab the browser
374
+ freezes holds nothing another waits on. The account home does the same.
375
+ - **In a browser without shared workers** each tab runs its node in a worker
376
+ of its own. Tabs tell each other through a
377
+ `BroadcastChannel` named `minca-node:<root DID>:<space id>`. Only the tab
378
+ in view runs its node, one at a time per account, so a frozen tab holds no
379
+ store another is waiting on.
335
380
  - **Writers on a shared folder** are found by reading it again
336
381
  ([data folders](#data-folders)).
337
382
 
@@ -339,6 +384,23 @@ The store's fingerprint, in `spaces.status`, is the Negentropy fingerprint
339
384
  of every collection together, as hex. Two nodes with the same fingerprint
340
385
  hold the same data.
341
386
 
387
+ ### Planned: stores that scale with what is in use
388
+
389
+ > **Planned.** Not built yet.
390
+
391
+ - **Sync sets that don't rebuild.** Today a write to a collection drops its
392
+ sorted set, and the next sync sorts it again. Kept in blocks, each with its
393
+ sum, a write would change one block, and a sync in progress would keep the
394
+ blocks it started with.
395
+ - **Files beside the database.** File chunks are 256 KiB, past the size SQLite
396
+ reads faster than separate files. A host would keep them as files under a
397
+ budget, with its bucket holding them all, and the database would know which
398
+ files each version names, so deleting what nothing names is one query.
399
+ - **Spaces open while used.** A host would close a space that has been idle,
400
+ and open it again when a peer asks for it.
401
+ - **The same store in the browser.** IndexedDB answering what SQLite does,
402
+ before deciding whether a browser needs SQLite at all.
403
+
342
404
  ## Pacing sync
343
405
 
344
406
  The spec says which sync messages go, and when a peer must answer. How often
@@ -354,9 +416,13 @@ a node speaks, and how much it asks for at once, is its own choice:
354
416
  | Versions waiting | 1,000 | Versions held back for later wait in memory. Past 1,000 the oldest go |
355
417
  | Refusals remembered | 10,000 | A refused version isn't asked of that peer again. Past 10,000 the oldest are forgotten |
356
418
 
357
- The node asks first for the space's own records (`sys.*`), and for earlier
358
- versions a waiting version needs. Everything else waits its turn. An id
359
- already asked for is not asked again.
419
+ The side that starts reconciling begins with the space's own records
420
+ (`sys.*`, profiles among them), then the rest from the collection it holds
421
+ fewest versions of to the most, so a long log goes last. Which side starts is
422
+ down to the peers' ids. A new device that starts holds nothing yet, so past
423
+ `sys.*` it goes in the order the peer named the collections. The node asks
424
+ first for `sys.*` too, and for earlier versions a waiting version needs.
425
+ Everything else waits its turn. An id already asked for is not asked again.
360
426
 
361
427
  A session with a peer that is running and has heard something in the last
362
428
  30 s isn't started again. It runs once more when it ends.
package/docs/usernames.md CHANGED
@@ -57,7 +57,7 @@ Pass `usernames` to `createMincaAuth`, and the account is made with a
57
57
  username: the create screen asks for one.
58
58
 
59
59
  ```ts
60
- import { createMincaAuth } from '@minca/core/session';
60
+ import { createMincaAuth } from '@minca/auth';
61
61
 
62
62
  const auth = createMincaAuth({ usernames: 'minca.social' });
63
63
  ```
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@minca/core",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "type": "module",
5
- "description": "Self-sovereign P2P protocol for the browser — identity, schemas, storage, networking, and gossip sync",
5
+ "description": "Self-sovereign P2P protocol for the browser \u2014 identity, schemas, storage, networking, and gossip sync",
6
6
  "repository": {
7
7
  "type": "git",
8
8
  "url": "git+https://github.com/leifriksheim/minca.git",
@@ -31,11 +31,6 @@
31
31
  "types": "./dist/node-worker.d.ts",
32
32
  "import": "./dist/node-worker.js"
33
33
  },
34
- "./node": {
35
- "@minca/source": "./src/node/index.ts",
36
- "types": "./dist/node/index.d.ts",
37
- "import": "./dist/node/index.js"
38
- },
39
34
  "./schemas": {
40
35
  "@minca/source": "./src/schemas/index.ts",
41
36
  "types": "./dist/schemas/index.d.ts",
@@ -55,13 +50,17 @@
55
50
  "scripts": {
56
51
  "build": "rm -rf dist && tsc",
57
52
  "typecheck": "tsc --noEmit && tsc -p tests",
58
- "test": "node --experimental-vm-modules --import tsx --test --test-concurrency=8 --test-timeout=60000 --test-force-exit tests/*.test.ts",
53
+ "test": "node --experimental-vm-modules --conditions=@minca/source --import tsx --test --test-concurrency=8 --test-timeout=60000 --test-force-exit tests/*.test.ts",
59
54
  "prepack": "node ../../scripts/npm-readme.mjs",
60
55
  "postpack": "rm -f README.md",
61
56
  "prepublishOnly": "npm run build"
62
57
  },
63
58
  "devDependencies": {
59
+ "@minca/actions": "*",
60
+ "@minca/auth": "*",
61
+ "@minca/std": "*",
64
62
  "@types/ws": "^8.18.2",
63
+ "esbuild": "^0.28.2",
65
64
  "tsx": "^4.19.0",
66
65
  "typescript": "^7.0.2",
67
66
  "ws": "^8.22.0",
@@ -1,85 +0,0 @@
1
- /**
2
- * @module node/actions
3
- * The node's operations, described once so every front end can be generated
4
- * from the same list.
5
- *
6
- * Each action has a name, a sentence saying what it does, a JSON Schema for its
7
- * input and a function that runs it. That is exactly what a command line needs
8
- * to parse flags, what an MCP server lists as tools, and what WebMCP's
9
- * `registerTool` takes — so a CLI, an agent on the desktop and an agent in the
10
- * browser all see the same operations with the same names.
11
- *
12
- * Inputs and outputs are plain JSON. Nothing here may return a key, a handle or
13
- * a function.
14
- */
15
- import type { P2PNode } from './types.js';
16
- /** The subset of JSON Schema these inputs use */
17
- export interface ActionSchema {
18
- readonly type: 'object';
19
- readonly properties: Readonly<Record<string, {
20
- readonly type?: string;
21
- readonly enum?: ReadonlyArray<string>;
22
- readonly description?: string;
23
- readonly items?: unknown;
24
- }>>;
25
- readonly required?: ReadonlyArray<string>;
26
- readonly additionalProperties?: boolean;
27
- }
28
- export interface NodeAction {
29
- /** `[a-z_]+`, so it is a valid tool name everywhere */
30
- readonly name: string;
31
- /** A few words for people: what a client shows when it asks before running it */
32
- readonly title: string;
33
- /** One or more sentences, for a person or a model */
34
- readonly description: string;
35
- /** What it takes, as a JSON Schema object */
36
- readonly input: ActionSchema;
37
- /** Reads only. Agents may run these without asking; everything else changes data. Default false. */
38
- readonly readOnly: boolean;
39
- /**
40
- * Returns something that grants access — an invite to a private space
41
- * carries its key. A front end should confirm with a person before handing
42
- * the result to anyone.
43
- */
44
- readonly sensitive?: boolean;
45
- /**
46
- * Removes or overwrites something, or brings in someone else's space. A
47
- * front end should ask a person before an agent runs it: an agent reads
48
- * records other people wrote, and one of them may be telling it what to do.
49
- */
50
- readonly destructive?: boolean;
51
- /**
52
- * Returns what other people wrote — record bodies, names, collection
53
- * descriptions. Data for an agent to read, never instructions to follow.
54
- */
55
- readonly peerContent?: boolean;
56
- /** Runs it. Input and output are plain JSON: never a key, a handle or a function. */
57
- readonly run: (node: P2PNode, input: Record<string, unknown>) => Promise<unknown>;
58
- }
59
- export declare const NODE_ACTIONS: ReadonlyArray<NodeAction>;
60
- /** Why an input does not fit an action's schema, or null when it does. */
61
- export declare function checkActionInput(action: NodeAction, input: unknown): string | null;
62
- /**
63
- * Runs an action by name, checking its input first.
64
- * @throws When the action is unknown or the input does not fit
65
- */
66
- export declare function runAction(node: P2PNode, name: string, input?: unknown): Promise<unknown>;
67
- /** Said before anything other people wrote, so a model reads it as data */
68
- export declare const PEER_CONTENT_NOTE: string;
69
- /** What an agent's node refuses: spaces, people and collections are a person's to change. It proposes collections instead. */
70
- export declare const PERSON_ONLY: ReadonlySet<string>;
71
- /** The actions offered to a model: all for the account; for a bot, all but PERSON_ONLY; for an agent, not direct messages either */
72
- export declare const offeredActions: (as?: {
73
- readonly agent?: boolean;
74
- readonly bot?: boolean;
75
- }) => NodeAction[];
76
- /**
77
- * Runs an action for a model: its result as JSON text, after PEER_CONTENT_NOTE
78
- * when others wrote it. A failure is text for the model to read and correct.
79
- */
80
- export declare function callAction(node: P2PNode, name: string, input?: unknown): Promise<{
81
- readonly text: string;
82
- readonly isError: boolean;
83
- readonly value?: unknown;
84
- }>;
85
- //# sourceMappingURL=actions.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../src/node/actions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;GAaG;AACH,OAAO,KAAK,EAAoC,OAAO,EAAE,MAAM,YAAY,CAAC;AAuB5E,iDAAiD;AACjD,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;IACxB,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAC3B,MAAM,CACJ,MAAM,EACN;QACE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;QACvB,QAAQ,CAAC,IAAI,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;QACtC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;QAC9B,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;KAC1B,CACF,CACF,CAAC;IACF,QAAQ,CAAC,QAAQ,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC1C,QAAQ,CAAC,oBAAoB,CAAC,EAAE,OAAO,CAAC;CACzC;AAED,MAAM,WAAW,UAAU;IACzB,uDAAuD;IACvD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iFAAiF;IACjF,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,qDAAqD;IACrD,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,6CAA6C;IAC7C,QAAQ,CAAC,KAAK,EAAE,YAAY,CAAC;IAC7B,oGAAoG;IACpG,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,SAAS,CAAC,EAAE,OAAO,CAAC;IAC7B;;;;OAIG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B;;;OAGG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,OAAO,CAAC;IAC/B,qFAAqF;IACrF,QAAQ,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,KAAK,OAAO,CAAC,OAAO,CAAC,CAAC;CACnF;AA05BD,eAAO,MAAM,YAAY,EAAE,aAAa,CAAC,UAAU,CAElD,CAAC;AAEF,0EAA0E;AAC1E,wBAAgB,gBAAgB,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAiBlF;AAED;;;GAGG;AACH,wBAAsB,SAAS,CAAC,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,GAAE,OAAY,GAAG,OAAO,CAAC,OAAO,CAAC,CAOlG;AAED,2EAA2E;AAC3E,eAAO,MAAM,iBAAiB,QAEqE,CAAC;AAEpG,8HAA8H;AAC9H,eAAO,MAAM,WAAW,EAAE,WAAW,CAAC,MAAM,CAa1C,CAAC;AAKH,oIAAoI;AACpI,eAAO,MAAM,cAAc,QAAQ;IAAE,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,iBAIpF,CAAC;AAEJ;;;GAGG;AACH,wBAAsB,UAAU,CAC9B,IAAI,EAAE,OAAO,EACb,IAAI,EAAE,MAAM,EACZ,KAAK,GAAE,OAAY,GAClB,OAAO,CAAC;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC,CAUzF"}