@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.
- package/dist/identity/abilities.d.ts +0 -2
- package/dist/identity/abilities.d.ts.map +1 -1
- package/dist/identity/abilities.js +2 -2
- package/dist/identity/abilities.js.map +1 -1
- package/dist/identity/account-vault.d.ts +0 -2
- package/dist/identity/account-vault.d.ts.map +1 -1
- package/dist/identity/account-vault.js +1 -1
- package/dist/identity/account-vault.js.map +1 -1
- package/dist/identity/crypto-p256.d.ts +1 -1
- package/dist/identity/crypto-p256.d.ts.map +1 -1
- package/dist/identity/ucan.d.ts +2 -1
- package/dist/identity/ucan.d.ts.map +1 -1
- package/dist/identity/ucan.js +1 -1
- package/dist/identity/ucan.js.map +1 -1
- package/dist/inbox/inbox.d.ts +0 -21
- package/dist/inbox/inbox.d.ts.map +1 -1
- package/dist/inbox/inbox.js +4 -4
- package/dist/inbox/inbox.js.map +1 -1
- package/dist/inbox/index.d.ts +4 -5
- package/dist/inbox/index.d.ts.map +1 -1
- package/dist/inbox/index.js +2 -3
- package/dist/inbox/index.js.map +1 -1
- package/dist/inbox/names.d.ts +0 -4
- package/dist/inbox/names.d.ts.map +1 -1
- package/dist/inbox/names.js +2 -2
- package/dist/inbox/names.js.map +1 -1
- package/dist/index.d.ts +45 -71
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +34 -53
- package/dist/index.js.map +1 -1
- package/dist/network/mesh.d.ts.map +1 -1
- package/dist/network/mesh.js +10 -0
- package/dist/network/mesh.js.map +1 -1
- package/dist/network/rendezvous.d.ts +2 -0
- package/dist/network/rendezvous.d.ts.map +1 -1
- package/dist/network/rendezvous.js +5 -0
- package/dist/network/rendezvous.js.map +1 -1
- package/dist/network/rtc-transport.d.ts.map +1 -1
- package/dist/network/rtc-transport.js +8 -3
- package/dist/network/rtc-transport.js.map +1 -1
- package/dist/node/carrier.d.ts +1 -33
- package/dist/node/carrier.d.ts.map +1 -1
- package/dist/node/carrier.js +38 -68
- package/dist/node/carrier.js.map +1 -1
- package/dist/node/index.d.ts +7 -14
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +4 -8
- package/dist/node/index.js.map +1 -1
- package/dist/node/node-carriers.d.ts.map +1 -1
- package/dist/node/node-carriers.js +21 -52
- package/dist/node/node-carriers.js.map +1 -1
- package/dist/node/node-context.d.ts +0 -2
- package/dist/node/node-context.d.ts.map +1 -1
- package/dist/node/node-context.js.map +1 -1
- package/dist/node/node-hosting.d.ts.map +1 -1
- package/dist/node/node-hosting.js +13 -4
- package/dist/node/node-hosting.js.map +1 -1
- package/dist/node/node-records.js +1 -1
- package/dist/node/node-records.js.map +1 -1
- package/dist/node/node.d.ts.map +1 -1
- package/dist/node/node.js +134 -36
- package/dist/node/node.js.map +1 -1
- package/dist/node/space-checks.d.ts +3 -1
- package/dist/node/space-checks.d.ts.map +1 -1
- package/dist/node/space-checks.js +7 -3
- package/dist/node/space-checks.js.map +1 -1
- package/dist/node/space-holding.d.ts +5 -0
- package/dist/node/space-holding.d.ts.map +1 -1
- package/dist/node/space-holding.js +90 -5
- package/dist/node/space-holding.js.map +1 -1
- package/dist/node/space-lines.d.ts +3 -0
- package/dist/node/space-lines.d.ts.map +1 -1
- package/dist/node/space-lines.js +13 -1
- package/dist/node/space-lines.js.map +1 -1
- package/dist/node/space-membership.js +4 -4
- package/dist/node/space-membership.js.map +1 -1
- package/dist/node/space-peers.d.ts +5 -2
- package/dist/node/space-peers.d.ts.map +1 -1
- package/dist/node/space-peers.js +3 -2
- package/dist/node/space-peers.js.map +1 -1
- package/dist/node/space-runtime.d.ts +3 -1
- package/dist/node/space-runtime.d.ts.map +1 -1
- package/dist/node/space-runtime.js +29 -8
- package/dist/node/space-runtime.js.map +1 -1
- package/dist/node/space-standing.d.ts +1 -1
- package/dist/node/space-standing.d.ts.map +1 -1
- package/dist/node/space-standing.js +11 -4
- package/dist/node/space-standing.js.map +1 -1
- package/dist/node/space-writing.d.ts.map +1 -1
- package/dist/node/space-writing.js +9 -0
- package/dist/node/space-writing.js.map +1 -1
- package/dist/node/stores.d.ts +9 -1
- package/dist/node/stores.d.ts.map +1 -1
- package/dist/node/stores.js +4 -2
- package/dist/node/stores.js.map +1 -1
- package/dist/node/types.d.ts +16 -5
- package/dist/node/types.d.ts.map +1 -1
- package/dist/node/worker.d.ts +14 -6
- package/dist/node/worker.d.ts.map +1 -1
- package/dist/node/worker.js +59 -20
- package/dist/node/worker.js.map +1 -1
- package/dist/node/writer-keys.d.ts +2 -2
- package/dist/node/writer-keys.d.ts.map +1 -1
- package/dist/node/writer-keys.js +12 -14
- package/dist/node/writer-keys.js.map +1 -1
- package/dist/privacy/direct.d.ts +0 -7
- package/dist/privacy/direct.d.ts.map +1 -1
- package/dist/privacy/direct.js +2 -2
- package/dist/privacy/direct.js.map +1 -1
- package/dist/query/filter.d.ts +0 -2
- package/dist/query/filter.d.ts.map +1 -1
- package/dist/query/filter.js +1 -1
- package/dist/query/filter.js.map +1 -1
- package/dist/query/types.d.ts +2 -6
- package/dist/query/types.d.ts.map +1 -1
- package/dist/query/types.js.map +1 -1
- package/dist/records/key.d.ts +2 -0
- package/dist/records/key.d.ts.map +1 -1
- package/dist/records/key.js +4 -0
- package/dist/records/key.js.map +1 -1
- package/dist/records/links.js +1 -1
- package/dist/schemas/direct.d.ts +70 -0
- package/dist/schemas/direct.d.ts.map +1 -0
- package/dist/schemas/direct.js +39 -0
- package/dist/schemas/direct.js.map +1 -0
- package/dist/schemas/index.d.ts +10 -73
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +8 -66
- package/dist/schemas/index.js.map +1 -1
- package/dist/session/connect.d.ts +12 -5
- package/dist/session/connect.d.ts.map +1 -1
- package/dist/session/connect.js +25 -21
- package/dist/session/connect.js.map +1 -1
- package/dist/session/connection.d.ts +8 -2
- package/dist/session/connection.d.ts.map +1 -1
- package/dist/session/connection.js +140 -11
- package/dist/session/connection.js.map +1 -1
- package/dist/session/hosting.d.ts +1 -7
- package/dist/session/hosting.d.ts.map +1 -1
- package/dist/session/hosting.js +3 -3
- package/dist/session/hosting.js.map +1 -1
- package/dist/session/index.d.ts +7 -12
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +6 -9
- package/dist/session/index.js.map +1 -1
- package/dist/session/stay-signed-in.d.ts +0 -1
- package/dist/session/stay-signed-in.d.ts.map +1 -1
- package/dist/session/stay-signed-in.js +1 -1
- package/dist/session/stay-signed-in.js.map +1 -1
- package/dist/space/account-registry.d.ts +0 -3
- package/dist/space/account-registry.d.ts.map +1 -1
- package/dist/space/account-registry.js.map +1 -1
- package/dist/space/own-automations.d.ts +51 -95
- package/dist/space/own-automations.d.ts.map +1 -1
- package/dist/space/own-automations.js +100 -295
- package/dist/space/own-automations.js.map +1 -1
- package/dist/space/pass.d.ts +8 -3
- package/dist/space/pass.d.ts.map +1 -1
- package/dist/space/pass.js +4 -3
- package/dist/space/pass.js.map +1 -1
- package/dist/space/space-manager.d.ts +1 -3
- package/dist/space/space-manager.d.ts.map +1 -1
- package/dist/space/space-manager.js +5 -7
- package/dist/space/space-manager.js.map +1 -1
- package/dist/storage/body-cache.d.ts +26 -0
- package/dist/storage/body-cache.d.ts.map +1 -0
- package/dist/storage/body-cache.js +41 -0
- package/dist/storage/body-cache.js.map +1 -0
- package/dist/storage/encrypted-adapter.d.ts +0 -5
- package/dist/storage/encrypted-adapter.d.ts.map +1 -1
- package/dist/storage/encrypted-adapter.js +1 -1
- package/dist/storage/encrypted-adapter.js.map +1 -1
- package/dist/storage/folder-adapter.d.ts +8 -2
- package/dist/storage/folder-adapter.d.ts.map +1 -1
- package/dist/storage/folder-adapter.js +43 -26
- package/dist/storage/folder-adapter.js.map +1 -1
- package/dist/storage/indexeddb-adapter.js +27 -2
- package/dist/storage/indexeddb-adapter.js.map +1 -1
- package/dist/storage/sqlite-adapter.d.ts +57 -0
- package/dist/storage/sqlite-adapter.d.ts.map +1 -0
- package/dist/storage/sqlite-adapter.js +213 -0
- package/dist/storage/sqlite-adapter.js.map +1 -0
- package/dist/storage/storage-provider.d.ts +21 -2
- package/dist/storage/storage-provider.d.ts.map +1 -1
- package/dist/storage/storage-provider.js +149 -56
- package/dist/storage/storage-provider.js.map +1 -1
- package/dist/sync/sync-engine.d.ts +10 -4
- package/dist/sync/sync-engine.d.ts.map +1 -1
- package/dist/sync/sync-engine.js +120 -38
- package/dist/sync/sync-engine.js.map +1 -1
- package/dist/sync/sync-messages.d.ts +4 -0
- package/dist/sync/sync-messages.d.ts.map +1 -1
- package/dist/sync/sync-messages.js.map +1 -1
- package/dist/types.d.ts +0 -7
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +0 -1
- package/dist/types.js.map +1 -1
- package/dist/utils/step.d.ts +8 -0
- package/dist/utils/step.d.ts.map +1 -0
- package/dist/utils/step.js +15 -0
- package/dist/utils/step.js.map +1 -0
- package/docs/README.md +1 -1
- package/docs/actions.md +41 -2
- package/docs/agents.md +13 -10
- package/docs/automations.md +16 -48
- package/docs/blueprints-and-guides.md +2 -2
- package/docs/bots.md +3 -3
- package/docs/collections.md +2 -4
- package/docs/computed.md +1 -2
- package/docs/node.md +87 -23
- package/docs/proposing-collections.md +3 -3
- package/docs/sign-in.md +16 -16
- package/docs/spaces.md +0 -5
- package/docs/standard-library.md +6 -8
- package/docs/storage.md +78 -12
- package/docs/usernames.md +1 -1
- package/package.json +7 -8
- package/dist/node/actions.d.ts +0 -85
- package/dist/node/actions.d.ts.map +0 -1
- package/dist/node/actions.js +0 -921
- package/dist/node/actions.js.map +0 -1
- package/dist/node/host.d.ts +0 -187
- package/dist/node/host.d.ts.map +0 -1
- package/dist/node/host.js +0 -818
- package/dist/node/host.js.map +0 -1
- package/dist/node/usage.d.ts +0 -32
- package/dist/node/usage.d.ts.map +0 -1
- package/dist/node/usage.js +0 -217
- package/dist/node/usage.js.map +0 -1
- package/dist/node/watch-notifications.d.ts +0 -25
- package/dist/node/watch-notifications.d.ts.map +0 -1
- package/dist/node/watch-notifications.js +0 -166
- package/dist/node/watch-notifications.js.map +0 -1
- package/dist/schemas/automations.d.ts +0 -390
- package/dist/schemas/automations.d.ts.map +0 -1
- package/dist/schemas/automations.js +0 -619
- package/dist/schemas/automations.js.map +0 -1
- package/dist/schemas/blueprints.d.ts +0 -122
- package/dist/schemas/blueprints.d.ts.map +0 -1
- package/dist/schemas/blueprints.js +0 -337
- package/dist/schemas/blueprints.js.map +0 -1
- package/dist/schemas/choosing.d.ts +0 -19
- package/dist/schemas/choosing.d.ts.map +0 -1
- package/dist/schemas/choosing.js +0 -69
- package/dist/schemas/choosing.js.map +0 -1
- package/dist/schemas/connectors.d.ts +0 -202
- package/dist/schemas/connectors.d.ts.map +0 -1
- package/dist/schemas/connectors.js +0 -140
- package/dist/schemas/connectors.js.map +0 -1
- package/dist/schemas/cron.d.ts +0 -14
- package/dist/schemas/cron.d.ts.map +0 -1
- package/dist/schemas/cron.js +0 -75
- package/dist/schemas/cron.js.map +0 -1
- package/dist/schemas/geo.d.ts +0 -63
- package/dist/schemas/geo.d.ts.map +0 -1
- package/dist/schemas/geo.js +0 -131
- package/dist/schemas/geo.js.map +0 -1
- package/dist/schemas/guides.d.ts +0 -26
- package/dist/schemas/guides.d.ts.map +0 -1
- package/dist/schemas/guides.js +0 -33
- package/dist/schemas/guides.js.map +0 -1
- package/dist/schemas/library/annotations.d.ts +0 -616
- package/dist/schemas/library/annotations.d.ts.map +0 -1
- package/dist/schemas/library/annotations.js +0 -156
- package/dist/schemas/library/annotations.js.map +0 -1
- package/dist/schemas/library/collections.d.ts +0 -211
- package/dist/schemas/library/collections.d.ts.map +0 -1
- package/dist/schemas/library/collections.js +0 -57
- package/dist/schemas/library/collections.js.map +0 -1
- package/dist/schemas/library/community.d.ts +0 -1136
- package/dist/schemas/library/community.d.ts.map +0 -1
- package/dist/schemas/library/community.js +0 -315
- package/dist/schemas/library/community.js.map +0 -1
- package/dist/schemas/library/life.d.ts +0 -1440
- package/dist/schemas/library/life.d.ts.map +0 -1
- package/dist/schemas/library/life.js +0 -202
- package/dist/schemas/library/life.js.map +0 -1
- package/dist/schemas/library/media.d.ts +0 -1002
- package/dist/schemas/library/media.d.ts.map +0 -1
- package/dist/schemas/library/media.js +0 -110
- package/dist/schemas/library/media.js.map +0 -1
- package/dist/schemas/library/money.d.ts +0 -1221
- package/dist/schemas/library/money.d.ts.map +0 -1
- package/dist/schemas/library/money.js +0 -168
- package/dist/schemas/library/money.js.map +0 -1
- package/dist/schemas/library/planning.d.ts +0 -1107
- package/dist/schemas/library/planning.d.ts.map +0 -1
- package/dist/schemas/library/planning.js +0 -214
- package/dist/schemas/library/planning.js.map +0 -1
- package/dist/schemas/library/publishing.d.ts +0 -1499
- package/dist/schemas/library/publishing.d.ts.map +0 -1
- package/dist/schemas/library/publishing.js +0 -285
- package/dist/schemas/library/publishing.js.map +0 -1
- package/dist/schemas/library/social.d.ts +0 -1257
- package/dist/schemas/library/social.d.ts.map +0 -1
- package/dist/schemas/library/social.js +0 -147
- package/dist/schemas/library/social.js.map +0 -1
- package/dist/schemas/standard.d.ts +0 -21
- package/dist/schemas/standard.d.ts.map +0 -1
- package/dist/schemas/standard.js +0 -39
- package/dist/schemas/standard.js.map +0 -1
- package/dist/session/auth.d.ts +0 -411
- package/dist/session/auth.d.ts.map +0 -1
- package/dist/session/auth.js +0 -1529
- package/dist/session/auth.js.map +0 -1
- package/dist/session/credentials.d.ts +0 -30
- package/dist/session/credentials.d.ts.map +0 -1
- package/dist/session/credentials.js +0 -63
- package/dist/session/credentials.js.map +0 -1
- package/dist/session/password-strength.d.ts +0 -22
- package/dist/session/password-strength.d.ts.map +0 -1
- package/dist/session/password-strength.js +0 -130
- 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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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/
|
|
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.
|
|
346
|
-
|
|
347
|
-
|
|
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/
|
|
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/
|
|
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/
|
|
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
|
|
496
|
-
|
|
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.
|
package/docs/standard-library.md
CHANGED
|
@@ -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/
|
|
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/
|
|
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/
|
|
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
|
|
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" } }
|
|
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/
|
|
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
|
|
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
|
-
|
|
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.**
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
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
|
|
358
|
-
|
|
359
|
-
|
|
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/
|
|
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.
|
|
3
|
+
"version": "0.3.1",
|
|
4
4
|
"type": "module",
|
|
5
|
-
"description": "Self-sovereign P2P protocol for the browser
|
|
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",
|
package/dist/node/actions.d.ts
DELETED
|
@@ -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"}
|