@minca/core 0.1.10 → 0.1.12
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/README.md +1 -1
- package/dist/identity/abilities.js +1 -1
- package/dist/identity/channel.d.ts +1 -1
- package/dist/identity/channel.d.ts.map +1 -1
- package/dist/identity/channel.js +1 -1
- package/dist/identity/channel.js.map +1 -1
- package/dist/identity/contact-key.d.ts +15 -15
- package/dist/identity/contact-key.d.ts.map +1 -1
- package/dist/identity/contact-key.js +21 -28
- package/dist/identity/contact-key.js.map +1 -1
- package/dist/inbox/inbox.d.ts +132 -0
- package/dist/inbox/inbox.d.ts.map +1 -0
- package/dist/inbox/inbox.js +197 -0
- package/dist/inbox/inbox.js.map +1 -0
- package/dist/inbox/index.d.ts +9 -0
- package/dist/inbox/index.d.ts.map +1 -0
- package/dist/inbox/index.js +7 -0
- package/dist/inbox/index.js.map +1 -0
- package/dist/index.d.ts +8 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/network/introductions.d.ts +1 -1
- package/dist/network/introductions.d.ts.map +1 -1
- package/dist/network/mesh.d.ts +4 -2
- package/dist/network/mesh.d.ts.map +1 -1
- package/dist/network/mesh.js +31 -45
- package/dist/network/mesh.js.map +1 -1
- package/dist/network/peer-auth.d.ts +4 -0
- package/dist/network/peer-auth.d.ts.map +1 -1
- package/dist/network/peer-auth.js +9 -7
- package/dist/network/peer-auth.js.map +1 -1
- package/dist/network/relay-minca.d.ts +6 -0
- package/dist/network/relay-minca.d.ts.map +1 -0
- package/dist/network/relay-minca.js +146 -0
- package/dist/network/relay-minca.js.map +1 -0
- package/dist/network/relay-nostr.d.ts +10 -0
- package/dist/network/relay-nostr.d.ts.map +1 -0
- package/dist/network/relay-nostr.js +247 -0
- package/dist/network/relay-nostr.js.map +1 -0
- package/dist/network/relay-socket.d.ts +87 -0
- package/dist/network/relay-socket.d.ts.map +1 -0
- package/dist/network/{signaling.js → relay-socket.js} +201 -167
- package/dist/network/relay-socket.js.map +1 -0
- package/dist/network/relays.d.ts +87 -0
- package/dist/network/relays.d.ts.map +1 -0
- package/dist/network/relays.js +43 -0
- package/dist/network/relays.js.map +1 -0
- package/dist/network/remote-transport.d.ts +1 -1
- package/dist/network/remote-transport.d.ts.map +1 -1
- package/dist/network/remote-transport.js +6 -31
- package/dist/network/remote-transport.js.map +1 -1
- package/dist/network/rendezvous.d.ts +59 -0
- package/dist/network/rendezvous.d.ts.map +1 -0
- package/dist/network/rendezvous.js +380 -0
- package/dist/network/rendezvous.js.map +1 -0
- package/dist/network/rtc-transport.d.ts.map +1 -1
- package/dist/network/rtc-transport.js +32 -17
- package/dist/network/rtc-transport.js.map +1 -1
- package/dist/network/transport.d.ts +7 -5
- package/dist/network/transport.d.ts.map +1 -1
- package/dist/node/actions.d.ts.map +1 -1
- package/dist/node/actions.js +28 -18
- package/dist/node/actions.js.map +1 -1
- package/dist/node/api.d.ts +11 -10
- package/dist/node/api.d.ts.map +1 -1
- package/dist/node/api.js +11 -10
- package/dist/node/api.js.map +1 -1
- package/dist/node/carrier.d.ts +11 -5
- package/dist/node/carrier.d.ts.map +1 -1
- package/dist/node/carrier.js +43 -2
- package/dist/node/carrier.js.map +1 -1
- package/dist/node/copy.d.ts +1 -1
- package/dist/node/copy.d.ts.map +1 -1
- package/dist/node/copy.js +10 -4
- package/dist/node/copy.js.map +1 -1
- package/dist/node/host.d.ts +2 -0
- package/dist/node/host.d.ts.map +1 -1
- package/dist/node/host.js +2 -0
- package/dist/node/host.js.map +1 -1
- package/dist/node/index.d.ts +1 -1
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/node.d.ts.map +1 -1
- package/dist/node/node.js +490 -298
- package/dist/node/node.js.map +1 -1
- package/dist/node/remote.d.ts.map +1 -1
- package/dist/node/remote.js +0 -2
- package/dist/node/remote.js.map +1 -1
- package/dist/node/space-runtime.d.ts +6 -2
- package/dist/node/space-runtime.d.ts.map +1 -1
- package/dist/node/space-runtime.js +5 -8
- package/dist/node/space-runtime.js.map +1 -1
- package/dist/node/types.d.ts +75 -46
- package/dist/node/types.d.ts.map +1 -1
- package/dist/react/use-invite-link.d.ts +1 -1
- package/dist/react/use-invite-link.d.ts.map +1 -1
- package/dist/react/use-invite-link.js +18 -11
- package/dist/react/use-invite-link.js.map +1 -1
- package/dist/records/loose.d.ts +52 -0
- package/dist/records/loose.d.ts.map +1 -0
- package/dist/records/loose.js +86 -0
- package/dist/records/loose.js.map +1 -0
- package/dist/schema/version.d.ts +2 -0
- package/dist/schema/version.d.ts.map +1 -1
- package/dist/schema/version.js +2 -1
- package/dist/schema/version.js.map +1 -1
- package/dist/schemas/choosing.d.ts +19 -0
- package/dist/schemas/choosing.d.ts.map +1 -0
- package/dist/schemas/choosing.js +69 -0
- package/dist/schemas/choosing.js.map +1 -0
- package/dist/schemas/contacts.d.ts +34 -87
- package/dist/schemas/contacts.d.ts.map +1 -1
- package/dist/schemas/contacts.js +32 -76
- package/dist/schemas/contacts.js.map +1 -1
- package/dist/schemas/index.d.ts +2 -2
- package/dist/schemas/index.d.ts.map +1 -1
- package/dist/schemas/index.js +1 -1
- package/dist/schemas/index.js.map +1 -1
- package/dist/schemas/library/annotations.d.ts +17 -285
- package/dist/schemas/library/annotations.d.ts.map +1 -1
- package/dist/schemas/library/annotations.js +9 -65
- package/dist/schemas/library/annotations.js.map +1 -1
- package/dist/schemas/library/community.d.ts +9 -17
- package/dist/schemas/library/community.d.ts.map +1 -1
- package/dist/schemas/library/community.js +5 -5
- package/dist/schemas/library/community.js.map +1 -1
- package/dist/schemas/library/life.d.ts +3 -3
- package/dist/schemas/library/life.d.ts.map +1 -1
- package/dist/schemas/library/life.js +2 -2
- package/dist/schemas/library/life.js.map +1 -1
- package/dist/schemas/library/media.d.ts +148 -541
- package/dist/schemas/library/media.d.ts.map +1 -1
- package/dist/schemas/library/media.js +28 -64
- package/dist/schemas/library/media.js.map +1 -1
- package/dist/schemas/library/money.d.ts +8 -8
- package/dist/schemas/library/money.d.ts.map +1 -1
- package/dist/schemas/library/money.js +4 -4
- package/dist/schemas/library/money.js.map +1 -1
- package/dist/schemas/library/planning.d.ts +23 -87
- package/dist/schemas/library/planning.d.ts.map +1 -1
- package/dist/schemas/library/planning.js +10 -26
- package/dist/schemas/library/planning.js.map +1 -1
- package/dist/schemas/library/publishing.d.ts +14 -14
- package/dist/schemas/library/publishing.d.ts.map +1 -1
- package/dist/schemas/library/publishing.js +7 -7
- package/dist/schemas/library/publishing.js.map +1 -1
- package/dist/schemas/library/social.d.ts +2 -2
- package/dist/schemas/library/social.d.ts.map +1 -1
- package/dist/schemas/library/social.js +1 -1
- package/dist/schemas/library/social.js.map +1 -1
- package/dist/schemas/standard.d.ts +1 -1
- package/dist/schemas/standard.d.ts.map +1 -1
- package/dist/schemas/standard.js +3 -3
- package/dist/schemas/standard.js.map +1 -1
- package/dist/session/auth.d.ts +5 -6
- package/dist/session/auth.d.ts.map +1 -1
- package/dist/session/auth.js +5 -6
- package/dist/session/auth.js.map +1 -1
- package/dist/session/channel-room.d.ts.map +1 -1
- package/dist/session/channel-room.js +3 -2
- package/dist/session/channel-room.js.map +1 -1
- package/dist/session/connect-code.d.ts +69 -55
- package/dist/session/connect-code.d.ts.map +1 -1
- package/dist/session/connect-code.js +189 -89
- package/dist/session/connect-code.js.map +1 -1
- package/dist/session/connect.d.ts +11 -15
- package/dist/session/connect.d.ts.map +1 -1
- package/dist/session/connect.js +8 -21
- package/dist/session/connect.js.map +1 -1
- package/dist/session/index.d.ts +2 -2
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +1 -1
- package/dist/session/index.js.map +1 -1
- package/dist/space/account-registry.d.ts +22 -0
- package/dist/space/account-registry.d.ts.map +1 -1
- package/dist/space/account-registry.js +18 -0
- package/dist/space/account-registry.js.map +1 -1
- package/dist/space/invitation.d.ts +61 -0
- package/dist/space/invitation.d.ts.map +1 -0
- package/dist/space/invitation.js +84 -0
- package/dist/space/invitation.js.map +1 -0
- package/dist/space/invite-link.d.ts +64 -0
- package/dist/space/invite-link.d.ts.map +1 -0
- package/dist/space/invite-link.js +212 -0
- package/dist/space/invite-link.js.map +1 -0
- package/dist/space/roles.d.ts.map +1 -1
- package/dist/space/roles.js +4 -2
- package/dist/space/roles.js.map +1 -1
- package/dist/space/space-manager.d.ts +21 -6
- package/dist/space/space-manager.d.ts.map +1 -1
- package/dist/space/space-manager.js +40 -23
- package/dist/space/space-manager.js.map +1 -1
- package/dist/types.d.ts +2 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js.map +1 -1
- package/docs/README.md +2 -2
- package/docs/actions.md +37 -37
- package/docs/agents.md +59 -37
- package/docs/automations.md +2 -2
- package/docs/blueprints-and-guides.md +44 -3
- package/docs/building-an-app.md +2 -2
- package/docs/contacts.md +48 -69
- package/docs/inbox.md +145 -0
- package/docs/node.md +68 -45
- package/docs/query-format.md +1 -1
- package/docs/sign-in.md +5 -7
- package/docs/spaces.md +33 -5
- package/docs/standard-library.md +111 -86
- package/package.json +6 -5
- package/dist/doors/doors.d.ts +0 -140
- package/dist/doors/doors.d.ts.map +0 -1
- package/dist/doors/doors.js +0 -226
- package/dist/doors/doors.js.map +0 -1
- package/dist/doors/index.d.ts +0 -9
- package/dist/doors/index.d.ts.map +0 -1
- package/dist/doors/index.js +0 -7
- package/dist/doors/index.js.map +0 -1
- package/dist/network/mailbox.d.ts +0 -45
- package/dist/network/mailbox.d.ts.map +0 -1
- package/dist/network/mailbox.js +0 -135
- package/dist/network/mailbox.js.map +0 -1
- package/dist/network/multi-signaling.d.ts +0 -41
- package/dist/network/multi-signaling.d.ts.map +0 -1
- package/dist/network/multi-signaling.js +0 -209
- package/dist/network/multi-signaling.js.map +0 -1
- package/dist/network/signaling.d.ts +0 -95
- package/dist/network/signaling.d.ts.map +0 -1
- package/dist/network/signaling.js.map +0 -1
- package/docs/doors.md +0 -151
package/docs/node.md
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
`createNode` and what it returns: configuration, root signers and notes, renewing
|
|
4
4
|
the session note, stores, holding spaces, following the account, events, live
|
|
5
5
|
messages, the rest of its surface, the network, acting as an agent, the
|
|
6
|
-
app-side client, carriers and hosting,
|
|
6
|
+
app-side client, carriers and hosting, the inbox, and the React and element
|
|
7
7
|
conveniences.
|
|
8
8
|
|
|
9
9
|
> Not protocol. This page describes the reference library, and another
|
|
@@ -18,18 +18,18 @@ conveniences.
|
|
|
18
18
|
| ------------------- | --------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
19
19
|
| `signer` | `RootSigner` | Who the node acts for. Asked only for session notes ([spec 06 §1.2](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)). |
|
|
20
20
|
| `accountKey` | bytes, optional | The account key (`deriveAccountKey(seed)`). Enables the account registry and the contacts space ([spec 06 §1.3](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)). |
|
|
21
|
-
| `contactKey` | bytes, optional | The contact key's secret. Opens
|
|
21
|
+
| `contactKey` | bytes, optional | The contact key's secret. Opens knocks, in shared spaces and, through the keys derived from it, in the inbox; published on profiles. |
|
|
22
22
|
| `contactsSpace` | string, optional | The contacts space's id, for a node given it without the account key (an app granted `contacts`, [spec 06 §2.5](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)). |
|
|
23
23
|
| `stores` | `StoreFactory` | Where the registry and each space's store live ([stores](#stores)). |
|
|
24
24
|
| `provider` | `CryptoProvider`, optional | Default: P-256 over WebCrypto. |
|
|
25
25
|
| `collections` | `CollectionDef[]`, optional | Schemas the node knows, used when a space does not describe a collection itself. Writes are checked against them; reads are flagged `conforms`. Nothing is refused on arrival for its shape ([02](https://github.com/leifriksheim/minca/blob/main/spec/02-records.md)). |
|
|
26
|
-
| `network` | optional | `relays` (
|
|
26
|
+
| `network` | optional | `relays` (where peers meet: Minca `wss://` and Nostr `nostr+wss://` relays), `nodes` (always-on nodes to dial, `wss://host/peer#<DID>`; the fragment pins the node, spec 04 §5.2; `ws://` only on this machine), `iceServers`, `transports` (extra transports per space). Omitted: offline. |
|
|
27
27
|
| `sessionTtlSeconds` | number, optional | Lifetime of each session note. Default `3600`. |
|
|
28
28
|
| `sessionKey` | `CryptoKeyPair`, optional | Sign with this key instead of a fresh one. Used when the signer's note names a specific key (an app's key, an agent's key, [spec 06 §2](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md), [spec 06 §3](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)). |
|
|
29
29
|
| `writerKey` | `WriterKeySource`, optional | Keep a signing key across runs, so this device keeps one log in each space ([writer keys](#writer-keys)). Ignored with `sessionKey`. |
|
|
30
30
|
| `watchIntervalMs` | number, optional | How often to look for writes another app, device or process made: a data folder's segments, a store file another process shares. `0` disables. Default `2000`. _Implementation detail._ |
|
|
31
31
|
| `cache` | `CacheConfig`, optional | Hold only the collections used, in spaces that name a keeper ([holding part of a space](#holding-part-of-a-space)). |
|
|
32
|
-
| `mailbox` | `MailboxClient`, optional | How
|
|
32
|
+
| `mailbox` | `MailboxClient`, optional | How the inbox and short links reach mailboxes ([07](https://github.com/leifriksheim/minca/blob/main/spec/07-inbox.md)). Default: a WebSocket to each relay. |
|
|
33
33
|
|
|
34
34
|
_Source: `packages/core/src/node/types.ts` (`NodeConfig`, `NodeNetworkConfig`, `CacheConfig`). Tests: `packages/core/tests/node.test.ts`, `packages/core/tests/caches.test.ts`._
|
|
35
35
|
|
|
@@ -450,7 +450,8 @@ and never under a note that lacks `/account/write`, such as an agent's. The prof
|
|
|
450
450
|
[03](https://github.com/leifriksheim/minca/blob/main/spec/03-spaces.md).
|
|
451
451
|
|
|
452
452
|
**Joining.** `spaces.join(invite)` accepts a bare invite or any link carrying
|
|
453
|
-
`#invite=…`, `?invite=…` or `&invite
|
|
453
|
+
`#invite=…`, `?invite=…` or `&invite=…`, long or short; a short one is
|
|
454
|
+
fetched from its mailboxes first ([spaces](spaces.md#invites)). It stores the space (and its key, for
|
|
454
455
|
a private space), stores `memberKey` when given, writes the `sys.joined`
|
|
455
456
|
record, then tries to use the invite's role secret at once. If the space's
|
|
456
457
|
invite record has not reached this device yet, the space is held with
|
|
@@ -536,17 +537,17 @@ A received live message is emitted as a `message` event,
|
|
|
536
537
|
|
|
537
538
|
`spaces.status(id)` returns `SpaceStatus`:
|
|
538
539
|
|
|
539
|
-
| Field | Meaning
|
|
540
|
-
| ------------- |
|
|
541
|
-
| `connection` | `offline` (no network), `connecting`, `connected` (while any one transport is connected: a relay socket open, or a peer), `error` (the first connect failed and nothing has connected since)
|
|
542
|
-
| `peers` | Session DIDs connected in the space.
|
|
543
|
-
| `own` | Of `peers`, the account's own other devices and apps: those also connected in the account registry, minus carriers. Empty without an account key.
|
|
544
|
-
| `carriers` | Of `peers`, the account's carriers, by the keys `sys.carrier` records name.
|
|
545
|
-
| `accounts` | Session DID → account, for each peer that showed a valid note.
|
|
546
|
-
| `fingerprint` | A fingerprint of every version held; equal on two nodes means identical data ([the store in memory](storage.md#the-store-in-memory)).
|
|
547
|
-
| `rejected` | How many versions peers sent failed validation.
|
|
548
|
-
| `holds` | `"all"`, or the sorted list of collections held ([holding part of a space](#holding-part-of-a-space)).
|
|
549
|
-
| `pending` | This node's writes still waiting for keepers ([holding part of a space](#holding-part-of-a-space)).
|
|
540
|
+
| Field | Meaning |
|
|
541
|
+
| ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
542
|
+
| `connection` | `offline` (no network), `connecting`, `connected` (while any one transport is connected: a relay socket open, or a peer), `error` (the first connect failed and nothing has connected since). A space whose relays all drop and whose peers leave is `connecting` again, not `connected`. |
|
|
543
|
+
| `peers` | Session DIDs connected in the space. |
|
|
544
|
+
| `own` | Of `peers`, the account's own other devices and apps: those also connected in the account registry, minus carriers. Empty without an account key. |
|
|
545
|
+
| `carriers` | Of `peers`, the account's carriers, by the keys `sys.carrier` records name. |
|
|
546
|
+
| `accounts` | Session DID → account, for each peer that showed a valid note. |
|
|
547
|
+
| `fingerprint` | A fingerprint of every version held; equal on two nodes means identical data ([the store in memory](storage.md#the-store-in-memory)). |
|
|
548
|
+
| `rejected` | How many versions peers sent failed validation. |
|
|
549
|
+
| `holds` | `"all"`, or the sorted list of collections held ([holding part of a space](#holding-part-of-a-space)). |
|
|
550
|
+
| `pending` | This node's writes still waiting for keepers ([holding part of a space](#holding-part-of-a-space)). |
|
|
550
551
|
|
|
551
552
|
> Rationale: a peer's key does not say whose it is, but only the account's own
|
|
552
553
|
> devices and apps can read its registry, so a peer there is one of ours.
|
|
@@ -611,7 +612,7 @@ successors, mine, heads, key, relays, keepers, copies, forks, flagged }`
|
|
|
611
612
|
account (whole-account access).
|
|
612
613
|
- `node.direct` — [direct-messages.md](direct-messages.md): `reachable`, `send`
|
|
613
614
|
and `list`. Needs the account's member key for the space.
|
|
614
|
-
- `node.
|
|
615
|
+
- `node.inbox` — [inbox.md](inbox.md), [07](https://github.com/leifriksheim/minca/blob/main/spec/07-inbox.md). Needs the contact key; knocking and
|
|
615
616
|
accepting also need whole-account access.
|
|
616
617
|
- `node.carriers`, `node.hosting`, `node.notifications` — [carriers and hosting](#carriers-hosting-and-notifications), [spec 06 §4](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md).
|
|
617
618
|
- `node.iceServers()` — the configured ICE servers plus TURN servers a relay
|
|
@@ -632,25 +633,35 @@ How the node uses relays, always-on nodes and WebRTC, where
|
|
|
632
633
|
leaves it the choice. Another implementation may pick other values and still
|
|
633
634
|
meet this one.
|
|
634
635
|
|
|
635
|
-
**Redialling a relay** (spec 04 §2). The client waits 1, 2, 4, 8, 16 s and
|
|
636
|
+
**Redialling a relay** (spec 04 §2.1). The client waits 1, 2, 4, 8, 16 s and
|
|
636
637
|
then 30 s between attempts, each ±25% so peers that dropped together do not
|
|
637
|
-
return together, and never stops until `disconnect`.
|
|
638
|
-
`refused` and waits 10 s, doubling with each refusal in a row up to 60 s. It
|
|
639
|
-
tries at once when the page becomes visible again, and when asked
|
|
638
|
+
return together, and never stops until `disconnect`. It tries at once when the page becomes visible again, and when asked
|
|
640
639
|
(`reconnect`). A successful open resets the count. A socket can die without
|
|
641
640
|
closing, and after a sleep it has: so the client looks at the clock every
|
|
642
641
|
5 s, and a look more than 30 s after the last means the device slept; it
|
|
643
642
|
then lets go of its socket and dials again at once, as it does when the
|
|
644
|
-
browser reports `online`. An open socket
|
|
645
|
-
also sends `ping`; once its relay has answered one, two going unanswered end
|
|
643
|
+
browser reports `online`. An open socket to a Minca relay that has heard
|
|
644
|
+
nothing for 30 s also sends `ping`; once its relay has answered one, two going unanswered end
|
|
646
645
|
the socket ("The relay stopped answering.") and it redials. Each relay's state
|
|
647
646
|
(`connecting`, `open`, `waiting` with the time of the next attempt and why the
|
|
648
647
|
last one failed, `stopped`) is readable as `RelayStatus`, and through a node
|
|
649
648
|
as `network.status()`.
|
|
650
649
|
|
|
651
|
-
**
|
|
652
|
-
|
|
653
|
-
it
|
|
650
|
+
**Meeting** (spec 04 §2, §3). A node says hello in each room when it joins,
|
|
651
|
+
on every relay as its socket opens, and every 2 minutes. It remembers, per
|
|
652
|
+
room, the times it acted on from each peer in the last 2 minutes (at most
|
|
653
|
+
256 a peer), and the failed tries of the last 512 peers. It
|
|
654
|
+
says hello back in a room at most once every 10 s; one due sooner waits
|
|
655
|
+
for the 10 s, once for everyone who said hello meanwhile. Each socket
|
|
656
|
+
sends at most 20 messages a second, in bursts of 40, and queues the rest. A
|
|
657
|
+
connection attempt that times out is retried on the peer's next hello. `requestIce`
|
|
658
|
+
asks every connected relay for TURN. Each WebRTC offer or answer waits for
|
|
659
|
+
ICE gathering to finish, or 2 s, and carries what it found.
|
|
660
|
+
|
|
661
|
+
**Kinds of relay** (spec 04 §1.2). `network.relays` may mix kinds:
|
|
662
|
+
`['wss://minca.fly.dev', 'nostr+wss://relay.damus.io']`. A relay of a kind
|
|
663
|
+
this library doesn't speak is left out of `network.status()`. On a Nostr
|
|
664
|
+
relay, each event is signed with a key made for it and forgotten.
|
|
654
665
|
|
|
655
666
|
**A space's relays** (spec 04 §4). A relay socket opened only for spaces'
|
|
656
667
|
own relays is closed once no room needs it. A node whose account may invoke
|
|
@@ -689,7 +700,7 @@ to every connected relay and waits up to 1.5 s for an answer (relays without
|
|
|
689
700
|
TURN never answer), then returns what it has. A node with no relays returns
|
|
690
701
|
the configured servers.
|
|
691
702
|
|
|
692
|
-
_Source: `packages/core/src/network/
|
|
703
|
+
_Source: `packages/core/src/network/relay-socket.ts` (`createRelaySocket`, `RelayStatus`), `packages/core/src/network/rendezvous.ts` (`createRendezvous`, `HELLO_MS`, `release`), `packages/core/src/network/relay-nostr.ts`, `packages/core/src/network/rtc-transport.ts` (`GATHER_MS`), `packages/core/src/network/ws-transport.ts`, `packages/core/src/network/local-transport.ts` (`createLocalHub`), `packages/core/src/node/carrier.ts` (`carry`), `packages/core/src/network/mesh.ts` (`CONNECT_TIMEOUT_MS`, `closeIfIdle`, `iceServers`, `ICE_REFRESH_MS`, `ICE_WAIT_MS`), `packages/core/src/network/introductions.ts` (`createSeenSignals`), `packages/core/src/network/rtc-transport.ts` (`DEFAULT_ICE_SERVERS`), `packages/core/src/node/space-runtime.ts` (`nameRelays`), `packages/core/src/node/node.ts` (`iceServers`), `packages/cli/src/serve.ts` (`onPeer`). Tests: `packages/core/tests/relay-socket.test.ts`, `packages/core/tests/rendezvous.test.ts`, `packages/core/tests/relay-nostr.test.ts`, `packages/core/tests/introductions.test.ts`, `packages/core/tests/space-relays.test.ts`, `packages/core/tests/ws-transport.test.ts`, `packages/core/tests/carrier.test.ts`; the client-side ICE refresh is untested._
|
|
693
704
|
|
|
694
705
|
## A node acting as an agent
|
|
695
706
|
|
|
@@ -707,7 +718,7 @@ throws unless the note verifies, grants records only (its command is under
|
|
|
707
718
|
or deleting collections; live messages (`send`, which a person's devices
|
|
708
719
|
would take as theirs); renaming or revoking at the account level; adding or
|
|
709
720
|
removing carriers; notifications; hosting; changing, blocking, asking or
|
|
710
|
-
accepting contacts; everything about
|
|
721
|
+
accepting contacts; everything about the inbox (it has none);
|
|
711
722
|
`delegate`; `asAgent`;
|
|
712
723
|
- sees the contact list only if the contacts space is within its note.
|
|
713
724
|
|
|
@@ -718,8 +729,8 @@ an agent is started on the node itself.
|
|
|
718
729
|
An agent granted `scope: account` gets a records-only note for every space
|
|
719
730
|
(`/record`, about the whole account) and the account key in its
|
|
720
731
|
grant ([spec 06 §2.8](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)), so the contact list is within its note to read. A home never
|
|
721
|
-
gives a records-only key the contact key: with it, it could open
|
|
722
|
-
|
|
732
|
+
gives a records-only key the contact key: with it, it could open the
|
|
733
|
+
account's knocks, in shared spaces and in its inbox ([inbox.md](inbox.md)).
|
|
723
734
|
|
|
724
735
|
Which of these each method of the node is — passed through, held to the note's spaces, or refused — is one table, `API` in `packages/core/src/node/api.ts`; a new method does not type-check until it is decided there. The same table lists what `remoteNode` forwards.
|
|
725
736
|
|
|
@@ -887,6 +898,18 @@ for the carrier is not left with nobody (spec 06 §4.3). `node.carriers.remove(c
|
|
|
887
898
|
writes `carry:closed` and marks the record removed; the node keeps the carry
|
|
888
899
|
space open until it closes, so the carrier hears it.
|
|
889
900
|
|
|
901
|
+
**A space made just now.** Until a carrier opens it from its pass and syncs
|
|
902
|
+
it, a new space is only on the device that made it: an invite handed out and
|
|
903
|
+
the device closed can't be used. `node.spaces.carried(spaceId, { waitMs? })`
|
|
904
|
+
is a short loading step: when a carrier of the account is connected now, it
|
|
905
|
+
names it a keeper, writes its pass at once, and waits up to `waitMs`
|
|
906
|
+
(default 3 s) until it is level with this node in the space, so it holds the
|
|
907
|
+
genesis and any invite opened before the call. It says whether it was: false
|
|
908
|
+
at once when no carrier is connected. `contacts.ask` and `inbox.knock` wait on it before the knock goes
|
|
909
|
+
out, and pass what it said on as `carried`, for the app to tell the person.
|
|
910
|
+
|
|
911
|
+
_Source: `packages/core/src/node/node.ts` (`spaces.carried`, `makePair`). Tests: `packages/core/tests/carrier.test.ts` ("a space made just now, carried before its invite goes out…", "carried is false at once with no carrier…")._
|
|
912
|
+
|
|
890
913
|
**The account's own automations.** `node.automations` (needs the account
|
|
891
914
|
key) lists, adds, updates (`name`, `paused`) and removes the account's own
|
|
892
915
|
automations, kept in its registry ([automations](automations.md#the-accounts-own)),
|
|
@@ -995,21 +1018,21 @@ paid, and what is in the fund stays there
|
|
|
995
1018
|
|
|
996
1019
|
_Source: `packages/core/src/node/node.ts` (`keepSpaceHosts`, `askSpaceHost`, `hosting.space`), `packages/core/src/session/hosting.ts` (`describeHost`, `HostError`). Tests: `packages/cli/tests/host.test.ts` ("a space paying for itself", "an address that is not a host, or one that is down", "bots a host runs": the two on stopping a space's host)._
|
|
997
1020
|
|
|
998
|
-
##
|
|
999
|
-
|
|
1000
|
-
`node.
|
|
1001
|
-
|
|
1002
|
-
| Call
|
|
1003
|
-
|
|
|
1004
|
-
| `
|
|
1005
|
-
| `open({
|
|
1006
|
-
| `
|
|
1007
|
-
| `clear(
|
|
1008
|
-
| `knock(code, { note? })`
|
|
1009
|
-
| `knocks()`
|
|
1010
|
-
| `sent()`
|
|
1011
|
-
| `accept(id)`
|
|
1012
|
-
| `dismiss(id)`
|
|
1021
|
+
## The inbox
|
|
1022
|
+
|
|
1023
|
+
`node.inbox` ([inbox.md](inbox.md), [spec 07](https://github.com/leifriksheim/minca/blob/main/spec/07-inbox.md)):
|
|
1024
|
+
|
|
1025
|
+
| Call | Does |
|
|
1026
|
+
| -------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
1027
|
+
| `get()` | Your inbox, or null until opened: `{ gen, name?, key, sign, places, code, updatedAt }`. `code` is signed afresh each time; what it says stays the same |
|
|
1028
|
+
| `open({ places?, name? })` | Opens your inbox, or changes where its knocks wait and the name it gives. Places default to the current ones, else this node's relays (up to 3); name to the current one, else the account's |
|
|
1029
|
+
| `rotate()` | Clears the inbox and replaces it with `gen + 1`: the old code leads nowhere |
|
|
1030
|
+
| `clear()` | Purges every knock waiting, from every mailbox it names |
|
|
1031
|
+
| `knock(code, { note? })` | [the exchange](inbox.md#the-exchange), returns `{ space, carried }` |
|
|
1032
|
+
| `knocks()` | Fetches the inbox's topic from every mailbox it names, opens and checks ([spec 07 §6](https://github.com/leifriksheim/minca/blob/main/spec/07-inbox.md); opened results are cached by id), settles sent knocks; returns `{ id, from, name, note?, pairSpace, at }`, newest first |
|
|
1033
|
+
| `sent()` | Your knocks nobody has joined yet: `{ space, name, at }` |
|
|
1034
|
+
| `accept(id)` | [the exchange](inbox.md#the-exchange), returns the new `ContactView` |
|
|
1035
|
+
| `dismiss(id)` | Purges one knock |
|
|
1013
1036
|
|
|
1014
1037
|
## Client conveniences
|
|
1015
1038
|
|
package/docs/query-format.md
CHANGED
|
@@ -98,7 +98,7 @@ never `null`.
|
|
|
98
98
|
| `@updatedAt` | `createdAt` of this version |
|
|
99
99
|
| `@seq` | `seq` |
|
|
100
100
|
| `@collection` | `collection` |
|
|
101
|
-
| `link:<rel>` | the `to` of the record's first link with that `rel`, as contracts' `link` and `onePer` read it; missing when it has none. `{ "link:
|
|
101
|
+
| `link:<rel>` | the `to` of the record's first link with that `rel`, as contracts' `link` and `onePer` read it; missing when it has none. `{ "link:in": key }` finds a channel's messages, `{ "link:in": { "$exists": false } }` those in no channel. |
|
|
102
102
|
| `include:<name>` | in an [automation](automations.md)'s `holds` only: what the query's `include` of that name found for the record, a number for a count |
|
|
103
103
|
| path | When its first segment names one of the collection's [computed fields](computed.md), start from that field's value and walk the rest; otherwise walk the body. A body member with a computed field's name is never read: a writer can't stand in for what the node works out. Walking: at each segment, the current value must be a non-null object or array, and the segment one of its own member names, or of an array a position (`0`, `1`, …; nothing else, not `length`); otherwise the value is _missing_. |
|
|
104
104
|
|
package/docs/sign-in.md
CHANGED
|
@@ -397,17 +397,15 @@ the keys it replaced go in `retired`, for disconnecting to revoke. Nothing
|
|
|
397
397
|
revokes an app on its own, not even once its time has passed: a revoke keeps
|
|
398
398
|
only what this home has seen of the key, and a home that is seldom open has
|
|
399
399
|
seen little ([spec 06 §2.9](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)). A connection with `via: 'code'` (a
|
|
400
|
-
program connected by code
|
|
400
|
+
program connected by code, at the home's own origin) is keyed by its audience instead,
|
|
401
401
|
so each such program is its own (`connectionKey`). A carrier is kept apart from the app at its
|
|
402
402
|
origin: connecting either replaces only its own kind, and one key is never
|
|
403
403
|
both. `auth.connections()` lists them.
|
|
404
404
|
|
|
405
|
-
**Disconnecting.** `auth.disconnect(origin, {
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
`retired`, and, unless only programs
|
|
410
|
-
connected by code go, removes the automations the app proposed. A carrier at
|
|
405
|
+
**Disconnecting.** `auth.disconnect(origin, { audience? })` removes the
|
|
406
|
+
connections made from that origin (`audience`: only that key), revokes the
|
|
407
|
+
keys of those with `access: write` and every key in their `retired`, and
|
|
408
|
+
removes the automations the app proposed. A carrier at
|
|
411
409
|
that origin stays: it goes by its key alone (`audience`), and takes nothing of
|
|
412
410
|
the app's with it. The app hears of it when the revokes reach it,
|
|
413
411
|
from this home or a device that has them: `waitMs` waits up to that long for
|
package/docs/spaces.md
CHANGED
|
@@ -144,22 +144,50 @@ _Source: `packages/core/src/node/node.ts` (`spaces.succeed`), `packages/core/src
|
|
|
144
144
|
- Each role invite gets its own fresh secret and its own `sys.invite` record,
|
|
145
145
|
so one can be closed without the others.
|
|
146
146
|
- The invite names the space's relays, or the inviter's own when the space
|
|
147
|
-
names none
|
|
148
|
-
|
|
149
|
-
|
|
147
|
+
names none, and the always-on nodes that hold it: the account's hosts and
|
|
148
|
+
the space's own, at most 8, each pinned by its DID. A host that can't be
|
|
149
|
+
described within three seconds is left out rather than hold the invite up.
|
|
150
|
+
- `short: true` makes a short link (spec 03 §7.7), about 85 characters: the
|
|
151
|
+
invite is sealed and left in the mailbox of the account's first host and of
|
|
152
|
+
the first relay that takes it, and the link names those two. Where no
|
|
153
|
+
mailbox takes it, or the space's constitution is too large for one, the
|
|
154
|
+
long invite is returned instead; it works the same. `until` (ms) says when
|
|
155
|
+
to stop sharing it.
|
|
156
|
+
|
|
157
|
+
**Short links the account keeps.** Each short link's sealed invite is kept in
|
|
158
|
+
the account registry (`sys.link`), never its secret, and copied to every
|
|
159
|
+
carrier's carry space, so the account's host serves it while every device is
|
|
160
|
+
away. Every hour, and whenever the registry or a space's key changes, a
|
|
161
|
+
device holding the account key drops each one again where the space's members
|
|
162
|
+
meet. One past its `until`, or carrying a key the space has moved on from, is
|
|
163
|
+
ended: its role invite is closed and the record deleted. `closeInvite` by a
|
|
164
|
+
short link closes its invite and forgets the record. The device that made a
|
|
165
|
+
link holds its secret nowhere: copy the link when it is made.
|
|
166
|
+
|
|
167
|
+
`node.spaces.preview(invite)` reads an invite without storing anything, and
|
|
168
|
+
for a short link fetches it first, which is why it is async:
|
|
150
169
|
|
|
151
170
|
```
|
|
152
171
|
{ space: { id, name, visibility, founders, createdAt, succeeds? }, invitedBy,
|
|
153
|
-
carriesKey, carriesWrite, role
|
|
172
|
+
carriesKey, carriesWrite, role, // role is null for a view-only invite
|
|
173
|
+
until? } // a short link's, when given
|
|
154
174
|
```
|
|
155
175
|
|
|
176
|
+
`invitedBy` is the account that signed the invitation: `preview` and `join`
|
|
177
|
+
both refuse an invite whose signature or note doesn't check out ([spec 03 §7.4](https://github.com/leifriksheim/minca/blob/main/spec/03-spaces.md)).
|
|
178
|
+
A short link is fetched once and remembered by the node, so a preview and the
|
|
179
|
+
join after it ask the mailboxes once. A link whose invite is nowhere fails
|
|
180
|
+
with "That invite was not found"; it may have expired or its places be down.
|
|
181
|
+
Invite nodes are dialled for the space alongside the hosts the account uses,
|
|
182
|
+
and kept like its invite relays.
|
|
183
|
+
|
|
156
184
|
On `join`, relays carried by the invite are a hint: the node uses them only
|
|
157
185
|
when they pass `checkRelays` and it holds no relay list for the space yet.
|
|
158
186
|
While the invite's record has not reached this device, the space is held with
|
|
159
187
|
`joining: true` and the node tries again as records arrive
|
|
160
188
|
([spec 06 §1.3](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)).
|
|
161
189
|
|
|
162
|
-
_Source: `packages/core/src/node/node.ts` (`spaces.invite`, `preview`, `join`), `packages/core/src/space/space-manager.ts` (`previewInvite`, `join`). Tests: `packages/core/tests/space.test.ts` ("invites"), `packages/core/tests/roles.test.ts` ("invites")._
|
|
190
|
+
_Source: `packages/core/src/node/node.ts` (`spaces.invite`, `preview`, `join`, `nodesOf`, `shortInvite`, `resolveInvite`, `keepLinks`), `packages/core/src/space/space-manager.ts` (`previewInvite`, `join`), `packages/core/src/space/invite-link.ts`. Tests: `packages/core/tests/space.test.ts` ("invites"), `packages/core/tests/roles.test.ts` ("invites"), `packages/core/tests/invite-link.test.ts`, `packages/cli/tests/host.test.ts` ("someone invited reaches the space through the inviter’s host…", "a short link: the host keeps it…")._
|
|
163
191
|
|
|
164
192
|
## Keeping a space's keys and relays
|
|
165
193
|
|