@minca/core 0.1.9 → 0.1.10

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 (64) hide show
  1. package/README.md +1 -1
  2. package/dist/identity/abilities.d.ts +3 -3
  3. package/dist/identity/abilities.d.ts.map +1 -1
  4. package/dist/identity/abilities.js +9 -11
  5. package/dist/identity/abilities.js.map +1 -1
  6. package/dist/identity/root-signer.d.ts +0 -5
  7. package/dist/identity/root-signer.d.ts.map +1 -1
  8. package/dist/identity/root-signer.js +0 -1
  9. package/dist/identity/root-signer.js.map +1 -1
  10. package/dist/index.d.ts +1 -1
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js.map +1 -1
  13. package/dist/node/node.d.ts.map +1 -1
  14. package/dist/node/node.js +230 -253
  15. package/dist/node/node.js.map +1 -1
  16. package/dist/node/remote.d.ts +6 -5
  17. package/dist/node/remote.d.ts.map +1 -1
  18. package/dist/node/remote.js +141 -194
  19. package/dist/node/remote.js.map +1 -1
  20. package/dist/node/space-runtime.d.ts.map +1 -1
  21. package/dist/node/space-runtime.js +69 -82
  22. package/dist/node/space-runtime.js.map +1 -1
  23. package/dist/node/types.d.ts +12 -4
  24. package/dist/node/types.d.ts.map +1 -1
  25. package/dist/node/worker.d.ts +1 -1
  26. package/dist/node/worker.d.ts.map +1 -1
  27. package/dist/node/worker.js +10 -6
  28. package/dist/node/worker.js.map +1 -1
  29. package/dist/session/auth.d.ts +20 -0
  30. package/dist/session/auth.d.ts.map +1 -1
  31. package/dist/session/auth.js +80 -63
  32. package/dist/session/auth.js.map +1 -1
  33. package/dist/session/connect.d.ts +50 -8
  34. package/dist/session/connect.d.ts.map +1 -1
  35. package/dist/session/connect.js +91 -27
  36. package/dist/session/connect.js.map +1 -1
  37. package/dist/session/connection.d.ts +39 -6
  38. package/dist/session/connection.d.ts.map +1 -1
  39. package/dist/session/connection.js +107 -38
  40. package/dist/session/connection.js.map +1 -1
  41. package/dist/session/hosting.d.ts +15 -0
  42. package/dist/session/hosting.d.ts.map +1 -1
  43. package/dist/session/hosting.js +55 -4
  44. package/dist/session/hosting.js.map +1 -1
  45. package/dist/session/index.d.ts +5 -5
  46. package/dist/session/index.d.ts.map +1 -1
  47. package/dist/session/index.js +2 -2
  48. package/dist/session/index.js.map +1 -1
  49. package/dist/space/account-registry.d.ts +14 -4
  50. package/dist/space/account-registry.d.ts.map +1 -1
  51. package/dist/space/account-registry.js +12 -3
  52. package/dist/space/account-registry.js.map +1 -1
  53. package/dist/space/roles.d.ts +59 -140
  54. package/dist/space/roles.d.ts.map +1 -1
  55. package/dist/space/roles.js +328 -427
  56. package/dist/space/roles.js.map +1 -1
  57. package/docs/actions.md +3 -3
  58. package/docs/agents.md +2 -2
  59. package/docs/blueprints-and-guides.md +20 -1
  60. package/docs/bots.md +1 -1
  61. package/docs/node.md +99 -53
  62. package/docs/sign-in.md +16 -9
  63. package/docs/storage.md +1 -1
  64. package/package.json +1 -1
package/docs/node.md CHANGED
@@ -55,12 +55,16 @@ A node acts for one account (`node.did`) and signs with one session key
55
55
  (`node.sessionDid`) for its whole lifetime. To act for another account, start
56
56
  another node.
57
57
 
58
- `revokeSelf()` revokes the node's session key in every space it writes in,
59
- its carry spaces, the contacts space and the account registry, each with a
60
- cutoff at what it wrote, and forgets a lasting key at once; the account
61
- home's sign-out calls it ([spec 01 §7.4](https://github.com/leifriksheim/minca/blob/main/spec/01-identity.md)).
62
- A record is judged with no time, so this, not the note running out, is what
63
- ends what a key can write. An agent's view refuses it.
58
+ `revokeKey(key, { spaces?, waitMs? })` revokes a key of the account, each
59
+ revoke with a cutoff at what the key wrote: in `spaces`, or by default
60
+ wherever the account writes (every space it lists, its carry spaces, the
61
+ contacts space and the account registry). It says whether a peer took each in
62
+ within `waitMs`. The account home's disconnect calls it for an app's key.
63
+ `revokeSelf()` does the same for the node's own session key, and forgets a
64
+ lasting key at once; the account home's sign-out calls it
65
+ ([spec 01 §7.4](https://github.com/leifriksheim/minca/blob/main/spec/01-identity.md)).
66
+ A record is judged with no time, so a revoke, not the note running out, is
67
+ what ends what a key can write. An agent's view refuses both.
64
68
 
65
69
  `close()` stops renewal, closes every open space (flushing what each keeps,
66
70
  stopping sync and disconnecting its transports), closes the registry store,
@@ -76,11 +80,10 @@ which hides where the key lives and is asked only for notes. This is an
76
80
  in-process interface, not a wire format; what a note must be is
77
81
  [spec 01 §7](https://github.com/leifriksheim/minca/blob/main/spec/01-identity.md).
78
82
 
79
- | Member | Type | Meaning |
80
- | -------------------------------------------------------------- | ----------------------- | ------------------------------------------------------------------------------------------------ |
81
- | `did` | string | The account DID |
82
- | `custody` | `'local'` \| `'remote'` | `local`: the seed is unlocked in this page. `remote`: another context (an account home) holds it |
83
- | `delegate({audience, command, subject?, policy?, expiration})` | → `Delegation` | Issue a note from the account to `audience` |
83
+ | Member | Type | Meaning |
84
+ | -------------------------------------------------------------- | -------------- | ------------------------------------------- |
85
+ | `did` | string | The account DID |
86
+ | `delegate({audience, command, subject?, policy?, expiration})` | → `Delegation` | Issue a note from the account to `audience` |
84
87
 
85
88
  - The **local** signer (`createLocalRootSigner`) calls `issueDelegation` with
86
89
  the root key. `subject` defaults to the account's own DID (the whole
@@ -89,6 +92,12 @@ in-process interface, not a wire format; what a note must be is
89
92
  already issued to the app's key, unchanged, and refuses once the grant's
90
93
  `expiresAt` has passed. It cannot mint new notes
91
94
  ([spec 06 §2](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)).
95
+ - A signer **across a port** (`serveSigner` on the side that holds the key,
96
+ `remoteSigner` on the node's, as a page signs for its worker's node) signs
97
+ only notes of the session note's shape below: `command` `/`, no `subject`,
98
+ no `policy`. It refuses anything else without asking the signer behind it.
99
+ The audience and expiration are the far end's to pick, so it bounds
100
+ neither.
92
101
 
93
102
  The **session note** a node asks for when it starts:
94
103
 
@@ -124,7 +133,7 @@ policy statement it can't read that way, so it never offers more than the
124
133
  note grants; peers judge each use against the note itself
125
134
  ([spec 06 §2.5](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)).
126
135
 
127
- _Source: `packages/core/src/identity/root-signer.ts`, `packages/core/src/identity/ucan.ts` (`issueDelegation`, `verifyNote`), `packages/core/src/identity/abilities.ts` (`noteTerms`, `noteSpaces`), `packages/core/src/node/node.ts` (`SESSION_COMMAND`, `delegate`), `packages/core/src/session/connect.ts` (`grantSigner`, `grantTerms`). Tests: `packages/core/tests/ucan.test.ts`, `packages/core/tests/node.test.ts`, `packages/core/tests/connect.test.ts`._
136
+ _Source: `packages/core/src/identity/root-signer.ts`, `packages/core/src/node/remote.ts` (`serveSigner`, `remoteSigner`), `packages/core/src/identity/ucan.ts` (`issueDelegation`, `verifyNote`), `packages/core/src/identity/abilities.ts` (`noteTerms`, `noteSpaces`), `packages/core/src/node/node.ts` (`SESSION_COMMAND`, `delegate`), `packages/core/src/session/connect.ts` (`grantSigner`, `grantTerms`). Tests: `packages/core/tests/ucan.test.ts`, `packages/core/tests/remote.test.ts` ("the page's signer, from a worker"), `packages/core/tests/node.test.ts`, `packages/core/tests/connect.test.ts`._
128
137
 
129
138
  ## Renewing the session note
130
139
 
@@ -142,7 +151,9 @@ The note format, and that every record carries it, are protocol
142
151
 
143
152
  A signer need not be able to sign. `grantSigner(grant)` answers every
144
153
  `delegate` call with the one note an account home granted, unchanged, and
145
- refuses once `grant.expiresAt` has passed. A node started from a grant
154
+ refuses once `grant.expiresAt` has passed. `grantSigner(() => grant)` answers
155
+ with whichever grant the getter returns, as the desktop app's node does when
156
+ a renewed grant replaces the last. A node started from a grant
146
157
  therefore never gets a fresh note: its "renewal" returns the same note, and when
147
158
  it runs out the app must connect again ([spec 06 §2.9](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)).
148
159
 
@@ -301,8 +312,8 @@ needs no grant. A founder who leaves is a founder no more, for good; to stay
301
312
  without being one, `spaces.stepDown`
302
313
  ([spaces](spaces.md#the-top-and-founders)). Then it deletes
303
314
  the space's `sys.joined` record in the account registry, closes the space and
304
- forgets it with its keys. The account registry and the contacts space cannot
305
- be left.
315
+ forgets it with its keys. The account registry, the contacts space and carry
316
+ spaces cannot be left.
306
317
 
307
318
  - The removal goes out only while the space is open, so `leave` waits up to
308
319
  5 s for a peer of another account to say it has it. With nobody reachable,
@@ -317,7 +328,7 @@ be left.
317
328
 
318
329
  `contacts.remove` and `contacts.block` leave the space for two this way.
319
330
 
320
- _Source: `packages/core/src/node/node.ts` (`spaces.leave`, `giveUpPlace`, `forget`, `LEAVE_WAIT_MS`), `packages/core/src/node/space-runtime.ts` (`giveUpPlace`). Tests: `packages/core/tests/key-change.test.ts` ("leaving a private space"), `packages/core/tests/contacts.test.ts` ("removing a contact gives up your place"), `packages/core/tests/node.test.ts` ("the account registry")._
331
+ _Source: `packages/core/src/node/node.ts` (`spaces.leave`, `giveUpPlace`, `forget`, `LEAVE_WAIT_MS`), `packages/core/src/node/space-runtime.ts` (`giveUpPlace`). Tests: `packages/core/tests/key-change.test.ts` ("leaving a private space"), `packages/core/tests/contacts.test.ts` ("removing a contact gives up your place"), `packages/core/tests/node.test.ts` ("the account registry"), `packages/core/tests/carrier.test.ts` ("its carry space cannot be left…")._
321
332
 
322
333
  ## Holding part of a space
323
334
 
@@ -407,26 +418,23 @@ Three kinds of space are the account's own machinery and are hidden from
407
418
  | -------------------- | ------------------------------------------ | -------------------------------------------------------------- |
408
419
  | The account registry | the account key | Never in the node's registry; opened directly. Cannot be left. |
409
420
  | The contacts space | the account key, or `config.contactsSpace` | Held in the registry, hidden. Cannot be left. |
410
- | Carry spaces | one per carrier the account uses | Held in the registry, hidden. |
421
+ | Carry spaces | the account key and the carrier's key | Never in the node's registry; opened directly. Cannot be left. |
411
422
 
412
423
  **Reconciling.** With an account key, the node makes its spaces match the
413
424
  account's list of `sys.joined` records. This runs at start and whenever
414
425
  records change in the account registry, one run at a time. It:
415
426
 
416
- 1. joins every carry space a live `sys.carrier` record names, and closes and
417
- forgets one whose carrier was removed more than 30 days ago (kept open until
418
- then, so an offline carrier still hears it was removed);
419
- 2. joins every space a live `sys.joined` record names that the node does not
427
+ 1. joins every space a live `sys.joined` record names that the node does not
420
428
  hold, using the view-only invite in the record;
421
- 3. leaves every space whose `sys.joined` record is deleted;
422
- 4. writes a `sys.joined` record for any space held here that the account
429
+ 2. leaves every space whose `sys.joined` record is deleted;
430
+ 3. writes a `sys.joined` record for any space held here that the account
423
431
  registry has never heard of (joined before the registry existed, or on a
424
432
  node without the account key);
425
- 5. brings every carrier's passes and wakes up to date
433
+ 4. brings every carrier's passes and wakes up to date
426
434
  ([spec 06 §4.2](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md));
427
- 6. names the account's carriers as keepers of the open spaces it manages
435
+ 5. names the account's carriers as keepers of the open spaces it manages
428
436
  (also whenever a space opens);
429
- 7. asks every host the account uses how it stands, handing it the spaces if it
437
+ 6. asks every host the account uses how it stands, handing it the spaces if it
430
438
  has been paid since ([carriers and hosting](#carriers-hosting-and-notifications)),
431
439
  without waiting for the answer.
432
440
 
@@ -703,7 +711,9 @@ throws unless the note verifies, grants records only (its command is under
703
711
  `delegate`; `asAgent`;
704
712
  - sees the contact list only if the contacts space is within its note.
705
713
 
706
- Closing the agent leaves the underlying node running.
714
+ Closing the agent leaves the underlying node running. A node used across a
715
+ port (`remoteNode`) starts no agent: the agent's keys would have to cross, so
716
+ an agent is started on the node itself.
707
717
 
708
718
  An agent granted `scope: account` gets a records-only note for every space
709
719
  (`/record`, about the whole account) and the account key in its
@@ -713,7 +723,7 @@ requests and knocks on the account's doors ([doors.md](doors.md)).
713
723
 
714
724
  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.
715
725
 
716
- _Source: `packages/core/src/node/node.ts` (`asAgent`), `packages/core/src/node/api.ts` (`API`). Tests: `packages/core/tests/records-only.test.ts` ("an agent acting for a person"), `packages/core/tests/remote.test.ts`._
726
+ _Source: `packages/core/src/node/node.ts` (`asAgent`), `packages/core/src/node/api.ts` (`API`). Tests: `packages/core/tests/records-only.test.ts` ("an agent acting for a person"), `packages/core/tests/remote.test.ts` ("no agent is started across the port…")._
717
727
 
718
728
  ## The app-side client
719
729
 
@@ -742,8 +752,7 @@ account: connecting as another account deletes the last one's, so its
742
752
  spaces never reach the new one's registry. Copied without the keychain, the
743
753
  folder yields no key, grant or private body, only what a carrier sees; a
744
754
  program running as the person can ask the keychain, as it can read a
745
- browser profile. Renewing keeps the key, as a page's app does: a new one would have the home
746
- revoke the last, withdrawing what the app wrote that the home hadn't seen.
755
+ browser profile. Renewing keeps the key (a page's app asks with a new one each time, below).
747
756
  The key changes only when the app leaves an account: disconnecting, from the
748
757
  app or at the home, forgets it (`forgetAppKey` in a page), so a revoked key
749
758
  stays revoked. A home that answers as another account than the one connected
@@ -778,29 +787,67 @@ closed it, and gives up after 10 minutes by default.
778
787
  starts a node with:
779
788
 
780
789
  - `signer = grantSigner(grant)` ([renewing the session note](#renewing-the-session-note)):
781
- `did` = `grant.did`, `custody: "remote"`;
790
+ `did` = `grant.did`;
782
791
  - `sessionKey` = the app's key;
783
792
  - stores `indexedDBStores('minca-app:<grant.did>')` unless given;
784
793
  - `cache: {}` unless `cache: false` ([holding part of a space](#holding-part-of-a-space));
785
- - `accountKey`, `contactKey`, `contactsSpace` from the grant when present;
786
- - relays = the app's relays ∪ `grant.relays`.
794
+ - `accountKey`, `contactKey`, `contactsSpace` from the grant when present (never `contactKey` under a records-only note), and
795
+ relays = the app's relays ∪ `grant.relays` (`nodeOptionsFromGrant`).
787
796
 
788
- It then joins each granted space it does not hold yet, passing its `memberKey`.
797
+ It then joins each granted space it does not hold yet, passing its `memberKey`
798
+ (`joinGranted`). The desktop app's node (`minca app-node`) and the agent on a
799
+ computer start theirs from a grant the same way, from their own folders.
789
800
 
790
- **The connection.** `createMincaConnection({ home, request, network?, storage?, stores? })`
801
+ **The connection.** `createMincaConnection({ home, request, network?, storage?, stores?, worker?, keys?, account? })`
791
802
  is the app's twin of [sign-in](sign-in.md): statuses `starting`, `disconnected`,
792
803
  `connecting`, `ready`, `expired`. With `worker`, it runs the node there
793
804
  (`startNodeInWorker`); a worker that reports a load error, or does not say the
794
805
  node started within 30 s (`WorkerNotStarted`), is given up on and the node
795
- runs in the page. A worker that started and refused passes its reason on. It keeps the grant in `localStorage` under
796
- `minca.grant` and the person's chosen home under `minca.home` (`home` in the
797
- config is only a default). It switches to `expired` at `expiresAt` and does not
798
- load an expired grant from storage, nor one of another format (`v` other
799
- than `GRANT_VERSION`, 2): the person connects again. When the node sees its own note revoked in
800
- a space it emits `revoked` ([events](#events)), and the connection forgets the
801
- grant and the app key. `propose(automations)` sends a proposal to the grant's home
806
+ runs in the page. A worker that started and refused passes its reason on.
807
+ It switches to `expired` at `expiresAt` (`watchGrant`). When the node sees its
808
+ own note revoked in a space it emits `revoked` ([events](#events)), and the
809
+ connection forgets that account's grant and key. `propose(automations)` sends
810
+ a proposal to the grant's home
802
811
  ([spec 06 §2.11](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)).
803
812
 
813
+ **Several accounts.** The connection keeps a grant for every account the
814
+ person connects, and acts for one at a time; `state.accounts` lists them
815
+ (`did`, the `name` the home gave, `expiresAt`), in the order they were first
816
+ connected. Each grant is made out to a key of its own, named
817
+ `account-<uuid>` in `appKey`'s store (or `keys`, given), so peers never see
818
+ one key act for two accounts. They are kept in `localStorage` under
819
+ `minca.grants` (`[{ grant, keyName }]`), the account acted for last under
820
+ `minca.account`, and the person's chosen home under `minca.home` (`home` in
821
+ the config is only a default). A grant of another format (`v` other than
822
+ `GRANT_VERSION`, 2) is dropped when read; one that ran out stays, and opens
823
+ as `expired`.
824
+
825
+ - `start()` acts for the account `account(accounts)` names, else the one used
826
+ last, else the first.
827
+ - `use(did)` acts for another connected account. Its grant is here, so the
828
+ home is not asked; the node acting for the last one closes, and one for
829
+ this one starts, with its own stores.
830
+ - `connect(home?)` asks with a new key, and acts for whichever account the
831
+ person chooses at the home: a new one, or one connected already, whose grant
832
+ it renews. A key that asked once may hold a note from whatever account the
833
+ home was signed in as, so no key is asked with twice. An account connected
834
+ again gets the new key and the app forgets the old one; the home revokes
835
+ nothing, and what the old key wrote stands
836
+ ([spec 06 §2.10](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)).
837
+ While it waits, an app acting for an account stays `ready`; a grant whose
838
+ node won't start is kept, and the connection says `disconnected` with why.
839
+ - `disconnect(did?)` forgets an account's grant and key (default the one
840
+ acted for) and acts for the next connected account, or none. Disconnected
841
+ at the home instead, it acts for none, with `error` saying why, rather than
842
+ another account the person didn't choose.
843
+
844
+ Another tab's changes reach `state.accounts` by `storage` events; each tab
845
+ acts for its own account. A tab whose account another tab connected again
846
+ goes on with its key until it starts again, then takes the newer grant; one
847
+ whose key is revoked takes up a newer grant rather than forgetting it. A
848
+ shared worker runs a node per key, not only per account, so tabs on two keys
849
+ never share one. Switching again before a node has started closes it.
850
+
804
851
  **Showing notifications.** The app shows its own notifications.
805
852
  `watchNotifications(node, { origin?, onNotify })` needs the account key (an
806
853
  app with `scope: account`): it reads the account's own automations naming the
@@ -814,20 +861,19 @@ held the first time an automation made it look there; anything arriving after th
814
861
  is, even while the account or the list of spaces changes. How the app shows a match is its own
815
862
  to decide; a "Notify me" button is where a proposal usually starts.
816
863
 
817
- _Source: `packages/core/src/session/connect.ts` (`appKey`, `forgetAppKey`, `homeAddress`, `connectToHome`, `proposeToHome`, `startConnectedNode`, `grantSigner`), `packages/core/src/session/connection.ts`, `packages/core/src/node/watch-notifications.ts`, `packages/core/src/space/own-automations.ts` (`matchesRecord`). Tests: `packages/core/tests/connect.test.ts` ("an account home typed by a person", "an app showing its own notifications"), `packages/core/tests/topics.test.ts` ("an automation of the account’s own: its where"), `packages/core/tests/watch-notifications.test.ts`._
864
+ _Source: `packages/core/src/session/connect.ts` (`appKey`, `forgetAppKey`, `homeAddress`, `connectToHome`, `proposeToHome`, `startConnectedNode`, `nodeOptionsFromGrant`, `joinGranted`, `grantSigner`, `usableGrant`, `watchGrant`, `grantStore`), `packages/cli/src/app-node.ts` (`startDesktopNode`), `packages/core/src/session/connection.ts`, `packages/core/src/node/watch-notifications.ts`, `packages/core/src/space/own-automations.ts` (`matchesRecord`). Tests: `packages/core/tests/connect.test.ts` ("an account home typed by a person", "watching a grant", "an app connected to several accounts", "an app showing its own notifications"), `packages/core/tests/topics.test.ts` ("an automation of the account’s own: its where"), `packages/core/tests/watch-notifications.test.ts`._
818
865
 
819
866
  ## Carriers, hosting and notifications
820
867
 
821
868
  What goes into a carry space, what a carrier checks and the host's HTTP API
822
869
  are protocol ([spec 06 §4](https://github.com/leifriksheim/minca/blob/main/spec/06-nodes-and-sessions.md)). The reference node's side:
823
870
 
824
- **Carriers.** `node.carriers.add({ did, name })` (needs the account key) makes
825
- the carry space, named `Carried by <name>` (name trimmed to 80, default
826
- `Carrier`), writes the `sys.carrier` record, fills the carry space, and returns
827
- `{ space, invite }` for the carrier to join with; for a carrier it already
828
- has, by `did`, it returns that one's. If the record can't be written, it
829
- takes the carry space back out before failing, so a restart never lists it as
830
- a space the account uses. A node that starts, or hears the registry change,
871
+ **Carriers.** `node.carriers.add({ did, name })` (needs the account key)
872
+ derives the carry space, writes the `sys.carrier` record (name trimmed to 80,
873
+ default `Carrier`), fills the carry space, and returns `{ space, invite }` for
874
+ the carrier to join with; for a carrier it already has, by `did`, it returns
875
+ that one's. Carry spaces are never kept in the node's own list: each is
876
+ derived again from its record. A node that starts, or hears the registry change,
831
877
  refills every carrier's carry space in the background: it opens every space
832
878
  the account holds, which from a data folder is slow, and signing in doesn't
833
879
  wait for it. Adding an automation doesn't either (adding a carrier writes that
@@ -838,8 +884,8 @@ waits up to `waitMs` for the node to be level with the carrier in the carry
838
884
  space and then the account registry, and says whether it was: a node about to
839
885
  close (the home's window, once it has answered) waits on it, so what it wrote
840
886
  for the carrier is not left with nobody (spec 06 §4.3). `node.carriers.remove(carrySpace)`
841
- writes `carry:closed` and deletes the record; the node keeps the carry space
842
- open for 30 days after, so a carrier that is offline still hears it.
887
+ writes `carry:closed` and marks the record removed; the node keeps the carry
888
+ space open until it closes, so the carrier hears it.
843
889
 
844
890
  **The account's own automations.** `node.automations` (needs the account
845
891
  key) lists, adds, updates (`name`, `paused`) and removes the account's own
@@ -851,7 +897,7 @@ person to pause or remove ([sign-in](sign-in.md#the-account-homes-side)).
851
897
  **A carrier's matches.** `CarrierNode` reports a version that wakes one of
852
898
  the account's wakes through a `wake` event, with only the wake, the space and
853
899
  the record's key, collection and `createdAt`; `wakes()` lists the wakes it
854
- holds. Nothing shows these yet, the browser extension included.
900
+ holds. The desktop app shows them as notifications (`apps/desktop/src/bun/notify.ts`); the browser extension shows none yet.
855
901
 
856
902
  **Hosting.** `node.hosting`:
857
903
 
package/docs/sign-in.md CHANGED
@@ -386,22 +386,27 @@ lifetime, clamped to [1/24, 365].
386
386
  **Connections.** The home remembers each connection per account in
387
387
  `localStorage` under `<prefix>.connections:<accountId>` (`Connection`:
388
388
  `origin`, `name`, `audience`, `access`, `scope`, `carrySpace?`, `spaces`,
389
- `grantedAt`, `expiresAt`, `via?`, `recordsOnly?`). It keeps no note:
389
+ `grantedAt`, `expiresAt`, `via?`, `recordsOnly?`, `retired?`). It keeps no note:
390
390
  disconnecting revokes the `audience` key, which is all a revoke names. A kept
391
391
  connection with any other field (a `token` from before notes were
392
392
  delegations in the UCAN 1.0 profile, say), or one of these in another
393
393
  shape, is dropped when read, not read in part: its app or program connects
394
394
  again.
395
- Connecting the same origin again replaces its connection; a connection with `via: 'code'` (a
395
+ Connecting the same origin again replaces its connection, revoking nothing:
396
+ the keys it replaced go in `retired`, for disconnecting to revoke. Nothing
397
+ revokes an app on its own, not even once its time has passed: a revoke keeps
398
+ only what this home has seen of the key, and a home that is seldom open has
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
396
400
  program connected by code through the app) is keyed by its audience instead,
397
- so each such program is its own. A carrier is kept apart from the app at its
401
+ so each such program is its own (`connectionKey`). A carrier is kept apart from the app at its
398
402
  origin: connecting either replaces only its own kind, and one key is never
399
403
  both. `auth.connections()` lists them.
400
404
 
401
405
  **Disconnecting.** `auth.disconnect(origin, { byCode?, audience? })` removes
402
406
  the app's connections (by default the app and every program connected through
403
407
  it by code; `byCode: true` only those programs; `audience` only that key),
404
- revokes the keys of those with `access: write`, and, unless only programs
408
+ revokes the keys of those with `access: write` and every key in their
409
+ `retired`, and, unless only programs
405
410
  connected by code go, removes the automations the app proposed. A carrier at
406
411
  that origin stays: it goes by its key alone (`audience`), and takes nothing of
407
412
  the app's with it. The app hears of it when the revokes reach it,
@@ -413,10 +418,12 @@ they are still only here, and the app keeps working until this home is next
413
418
  online with another of the account's devices or apps. The account home waits
414
419
  5 s, and says so when nobody took them in.
415
420
 
416
- **Signing out.** `auth.signOut()` forgets the unlocked account on this device,
417
- lets apps whose time has passed go and revokes the home's own session key. An
421
+ **Signing out.** `auth.signOut()` forgets the unlocked account on this device
422
+ and revokes the home's own session key, with a cutoff at what it wrote, so
423
+ nothing it wrote is lost. An
418
424
  app's note doesn't need the home signed in, so the apps connected from here
419
- keep working until it runs out. `auth.signOut({ disconnect: true })`
425
+ keep working; a note running out stops only their live use, and what they
426
+ write counts until they are disconnected. `auth.signOut({ disconnect: true })`
420
427
  disconnects them first, and the programs connected through them, with the
421
428
  automations they proposed; carriers stay. The node sends nothing once it has
422
429
  stopped, so it waits, up to 5 s for them all (`signOutGraceMs` in
@@ -426,7 +433,7 @@ open space as signing out starts, so signing out with nobody else online is
426
433
  quick; `state.signingOut` is true meanwhile. A node with no network
427
434
  configured doesn't wait. With nobody reachable, they leave the next time the account signs in here. A read-only app has no key to revoke: it loses
428
435
  access when its time runs out. The account home asks each time, with
429
- disconnecting ticked, and is not ready to grant anything from the moment
436
+ disconnecting unticked, since revoking is for when something is wrong, and is not ready to grant anything from the moment
430
437
  signing out starts. Choosing another account on the connect page signs out
431
438
  without disconnecting: switching accounts disconnects nothing.
432
439
 
@@ -441,4 +448,4 @@ carrier from the same origin (never an app there), adds the carrier with `node.c
441
448
  returns the `CarryGrant`. Its connection is kept with `expiresAt: 0`, since a
442
449
  carry connection never expires.
443
450
 
444
- _Source: `packages/core/src/session/auth.ts` (`grant`, `grantCarry`, `propose`, `connections`, `disconnect`, `signOut`, `isConnection`), `packages/core/src/session/connect.ts` (`receiveConnectRequest`). Tests: `packages/core/tests/connect.test.ts` ("the home receiving a request", "connecting an app to an account home", "disconnecting …", "connecting a carrier to an account home", "signing out and disconnecting…", "signing out alone…"), `packages/core/tests/records-only.test.ts` ("a connection kept in an older shape is dropped, not read as the app’s own")._
451
+ _Source: `packages/core/src/session/auth.ts` (`grant`, `grantCarry`, `propose`, `connections`, `disconnect`, `signOut`, `isConnection`, `connectionKey`), `apps/home/src/components/Settings.tsx`, `packages/core/src/session/connect.ts` (`receiveConnectRequest`). Tests: `packages/core/tests/connect.test.ts` ("the home receiving a request", "connecting an app to an account home", "disconnecting …", "connecting a carrier to an account home", "signing out and disconnecting…", "signing out alone…"), `packages/core/tests/records-only.test.ts` ("a connection kept in an older shape is dropped, not read as the app’s own")._
package/docs/storage.md CHANGED
@@ -55,7 +55,7 @@ When another writer changed the same store, the node re-reads all of it
55
55
  (`invalidate`). Other tabs of one browser are told through a
56
56
  `BroadcastChannel` named `minca-node:<root DID>:<space id>`. Where a browser
57
57
  has shared workers that work, the apps in this repository run one node for all
58
- of a site's tabs in a `SharedWorker`, so those tabs share one store and have
58
+ of a site's tabs in a `SharedWorker` (one per account and key), so those tabs share one store and have
59
59
  nothing to tell each other; the channel remains for the rest (Chrome on
60
60
  Android has none; WebKit drops a message to one that holds a `CryptoKey`),
61
61
  where each tab's node runs in a worker of its own
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@minca/core",
3
- "version": "0.1.9",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "description": "Self-sovereign P2P protocol for the browser — identity, schemas, storage, networking, and gossip sync",
6
6
  "repository": {