sigelo-contact 0.1.21 → 0.1.23

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 (69) hide show
  1. package/GROUPS-REFERENCE.md +165 -0
  2. package/GROUPS.md +53 -0
  3. package/LICENSE +235 -21
  4. package/README.md +4 -5
  5. package/call.mjs +89 -28
  6. package/carrier.mjs +230 -51
  7. package/control.mjs +2 -2
  8. package/create.mjs +2 -2
  9. package/device.mjs +2 -2
  10. package/enrol.mjs +2 -2
  11. package/envelope.mjs +6 -6
  12. package/file.mjs +2 -2
  13. package/fixtures/carrier-v0.json +1 -1
  14. package/fixtures/envelope-v0.json +1 -1
  15. package/fixtures/group-v2.json +2999 -0
  16. package/gen-carrier.mjs +2 -2
  17. package/gen-device.mjs +1 -1
  18. package/gen-envelope.mjs +2 -2
  19. package/gen-group2.mjs +291 -0
  20. package/gen-invite.mjs +2 -2
  21. package/gen-short.mjs +1 -1
  22. package/group.mjs +116 -17
  23. package/group2.mjs +1534 -0
  24. package/home-wire.mjs +812 -0
  25. package/invite.mjs +3 -3
  26. package/kdf.mjs +2 -2
  27. package/kin.mjs +62 -0
  28. package/link.mjs +6 -6
  29. package/package.json +25 -8
  30. package/page.mjs +542 -63
  31. package/photo.mjs +2 -2
  32. package/platform-node.mjs +6 -6
  33. package/prekeys.mjs +3 -3
  34. package/public.mjs +2 -2
  35. package/qr-decode.mjs +1 -1
  36. package/qr.mjs +2 -2
  37. package/relays.mjs +2 -2
  38. package/restore.mjs +2 -2
  39. package/rtc-web.mjs +3 -3
  40. package/short.mjs +2 -2
  41. package/store.mjs +22 -9
  42. package/test-carrier.mjs +32 -11
  43. package/test-device.mjs +3 -3
  44. package/test-enrol.mjs +9 -4
  45. package/test-envelope.mjs +2 -2
  46. package/test-file.mjs +2 -2
  47. package/test-group-move.mjs +225 -0
  48. package/test-group.mjs +1 -1
  49. package/test-group2.mjs +202 -0
  50. package/test-home.mjs +225 -0
  51. package/test-invite.mjs +1 -1
  52. package/test-link.mjs +3 -3
  53. package/test-platform.mjs +2 -2
  54. package/test-presence.mjs +2 -2
  55. package/test-push.mjs +5 -5
  56. package/test-relay-lane.mjs +3 -3
  57. package/test-short.mjs +1 -1
  58. package/test-tier.mjs +8 -2
  59. package/test-transfer-web.mjs +15 -7
  60. package/test-transfer.mjs +24 -6
  61. package/test-voice.mjs +2 -2
  62. package/test-ws.mjs +1 -1
  63. package/transfer-engine.mjs +46 -16
  64. package/transfer-node.mjs +9 -7
  65. package/transfer-web.mjs +4 -4
  66. package/transfer.mjs +8 -8
  67. package/voice-web.mjs +2 -2
  68. package/voice.mjs +7 -3
  69. package/words-lock.mjs +2 -2
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: MIT
2
- // Transfers, the part every host shares (design/transfer.md §4, §10; apps/agent/TRANSFER.md): the
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Transfers, the part every host shares (apps/agent/TRANSFER.md): the
3
3
  // records, the consent and the accept rule, the verbs and the Engine, with the disk, the file sent and
4
4
  // Tor behind `io`. Node: transfer-node.mjs (fs, a tor daemon). The phone: transfer-web.mjs (the bridge
5
5
  // holds the bytes; no Tor). The protocol is transfer.mjs's; the carrier is carrier.mjs's, in both.
@@ -13,14 +13,20 @@
13
13
  // tor: null | { caps(), serve(engine, side, r, a), connect(engine, side, r, x, a), close(a) },
14
14
  // flushEach: chunks between flushes (Node 8; the phone 1: the bitmap saved after every chunk) }
15
15
  //
16
- // The records file: { v, out: { id: sender's record }, in: { id: receiver's record }, direct: { DID: true|false },
17
- // auto: { DID: MB (0: always ask) }, settings: { tor, prefer, auto_mb, keep_location } }.
16
+ // The records file: { v, out: { id: sender's record }, in: { id: receiver's record }, direct: { DID: true|false|"relay" },
17
+ // auto: { DID: MB (0: always ask) }, settings: { tor, prefer, auto_mb, keep_location, route } }.
18
18
  //
19
- // The accept rule (design §10.2, decided 2026-11-13): a file lands without a question up to the size set
19
+ // The route (how a contact's files go, the app's Settings → Privacy): "direct" (the direct lane, the contact sees this
20
+ // device's addresses), "relay" (the direct lane only through the relay's TURN, as "Always relay my media" for that
21
+ // contact alone: the contact sees the relay's address) or "tor" (no direct lane: Tor, else the relay lane up to 8 MiB).
22
+ // Per contact: direct[DID] (true: direct, "relay", false: tor); else own agents and contacts direct; else settings.route,
23
+ // the default for everyone; none set (the CLI's start): asked (direct_ask), as before.
24
+ //
25
+ // The accept rule: a file lands without a question up to the size set
20
26
  // (settings.auto_mb, default 25 MB; per contact auto[DID]) from own agents and own contacts (tier own,
21
27
  // ours) and from friends whose four words were compared (compared(did), the page's), when the disk has
22
28
  // room; larger, or from anyone else (words not compared, a public-code joiner, quiet), it is asked. The
23
- // direct switch picks the lane, not the yes (2026-11-25): off, it comes over Tor or the relay lane.
29
+ // direct switch picks the lane, not the yes: off, it comes over Tor or the relay lane.
24
30
  //
25
31
  // The relay lane (0.1.19): a file of at most RELAY_MAX (8 MiB, send-file's) to an own agent or contact, or to a friend
26
32
  // whose words were compared, that cannot go direct (no path, no Tor: the end no_path) or whose channel dropped and did
@@ -30,7 +36,7 @@
30
36
  // up to 8 MiB, Send over the relay. A channel that moves no byte for stallMs (30 s) counts as dropped; a receiver's
31
37
  // record active with nothing for STALE_S (10 minutes) is listed as interrupted, and resume takes it again.
32
38
  //
33
- // "Always relay my media" (design/calls.md §6, 2026-11-26): policy() "relay" (the page's setting) or env
39
+ // "Always relay my media" (UI-API.md "Settings"): policy() "relay" (the page's setting) or env
34
40
  // SIGELO_ICE_POLICY=relay: the direct lane only through the relay's TURN (iceTransportPolicy relay, relayed candidates
35
41
  // only in the SDP: rtc-web.mjs, apps/transfer/rtc.mjs); with no TURN to be had the direct lane is left out at once
36
42
  // (RELAY_ONLY, reason relay_only on the receiver's record) and the file goes over Tor or the relay lane as without one.
@@ -86,8 +92,14 @@ export function contactOf(carrier, who) {
86
92
  return hit[0];
87
93
  }
88
94
  const own = (c) => c.tier === 'own' || c.ours === true;
89
- /** May this contact learn this agent's addresses (direct)? true, false, or null: not asked yet (never for own). */
90
- export const directFor = (s, c) => (Object.hasOwn(s.direct, c.did) ? s.direct[c.did] : own(c) ? true : null);
95
+ export const ROUTES = ['direct', 'relay', 'tor'];
96
+ const routeOfDirect = (v) => (v === true ? 'direct' : v === 'relay' ? 'relay' : v === false ? 'tor' : null);
97
+ const directOfRoute = (r) => (r === 'direct' ? true : r === 'relay' ? 'relay' : r === 'tor' ? false : undefined);
98
+ const routeDefault = (s) => (ROUTES.includes(s.settings?.route) ? s.settings.route : null);
99
+ /** How this contact's files go: "direct", "relay" or "tor"; null: not asked yet (no choice for them, no default). */
100
+ export const routeFor = (s, c) => (Object.hasOwn(s.direct, c.did) ? routeOfDirect(s.direct[c.did]) : own(c) ? 'direct' : routeDefault(s));
101
+ /** May this contact learn this agent's addresses (direct)? true (direct, or through the relay's TURN), false, or null: not asked yet (never for own). */
102
+ export const directFor = (s, c) => { const r = routeFor(s, c); return r === null ? null : r !== 'tor'; };
91
103
  const decideDirect = (s, c, direct) => {
92
104
  if (direct === true || direct === false) { s.direct[c.did] = direct; return direct; }
93
105
  const d = directFor(s, c);
@@ -101,7 +113,7 @@ export function trustOf(c, compared = () => false) {
101
113
  return compared(c.did) ? 'compared' : 'other';
102
114
  }
103
115
  export const autoDefault = (s) => (Number.isFinite(s.settings.auto_mb) && s.settings.auto_mb >= 0 ? s.settings.auto_mb : AUTO_MB);
104
- const settingsOf = (s) => ({ tor: s.settings.tor !== false, prefer: s.settings.prefer === 'private' ? 'private' : 'fast', auto_mb: autoDefault(s), keep_location: s.settings.keep_location === true });
116
+ const settingsOf = (s) => ({ tor: s.settings.tor !== false, prefer: s.settings.prefer === 'private' ? 'private' : 'fast', auto_mb: autoDefault(s), keep_location: s.settings.keep_location === true, route: routeDefault(s) });
105
117
  const sendMsg = (carrier, to, content, local) => carrier.send(to, content, { label: TRANSFER_LABEL, internal: TRANSFER_SEND, local });
106
118
 
107
119
  // ---------------------------------------------------------------- the verbs
@@ -123,7 +135,7 @@ export async function sendTo({ carrier, io, to, f, via = 'auto', direct, local =
123
135
  return sendPrepared({ carrier, io, c, f, via, local, group, now });
124
136
  }
125
137
  /**
126
- * A group's file (design §10.3): one transfer per member this side is paired with, the file hashed once
138
+ * A group's file: one transfer per member this side is paired with, the file hashed once
127
139
  * (f); members reached only through the creator are listed unpaired (they get the preview alone).
128
140
  * members: [{ did, name, contact }] (the others; contact: paired here). Before anything is sent, a member
129
141
  * whose direct switch is not set and no direct given: direct_ask naming them. → { sent, unpaired, failed }.
@@ -276,7 +288,9 @@ export function list({ carrier, io, engine = null }) {
276
288
  return {
277
289
  out: Object.values(s.out).map((r) => { const { file: _f, ...x } = live(r); return x; }).sort(sort),
278
290
  in: Object.values(s.in).map((r) => (stale(r, now) && !engine?.attempts.get(r.id)?.channel ? { ...live(r), state: 'interrupted', reason: 'stalled', detail: staleDetail(r) } : live(r))).sort(sort),
279
- direct: { ...s.direct },
291
+ // direct: true|false for older pages ("relay" reads true: the direct lane, through TURN); route: each one's route.
292
+ direct: Object.fromEntries(Object.entries(s.direct).map(([k, v]) => [k, v !== false])),
293
+ route: Object.fromEntries(Object.entries(s.direct).map(([k, v]) => [k, routeOfDirect(v)])),
280
294
  auto: { ...s.auto },
281
295
  settings: settingsOf(s),
282
296
  };
@@ -287,6 +301,15 @@ export function setDirect({ carrier, io, contact, on }) {
287
301
  const c = contactOf(carrier, contact);
288
302
  return state(io, nowS(carrier), (s) => { s.direct[c.did] = on; return { did: c.did, name: c.name, direct: on }; });
289
303
  }
304
+ /** A contact's route ("direct", "relay", "tor"), or null: back to the default (own: direct; else settings.route). */
305
+ export function setRoute({ carrier, io, contact, route }) {
306
+ if (route !== null && !ROUTES.includes(route)) fail('usage', 'route: direct, relay, tor or null (the default)');
307
+ const c = contactOf(carrier, contact);
308
+ return state(io, nowS(carrier), (s) => {
309
+ if (route === null) delete s.direct[c.did]; else s.direct[c.did] = directOfRoute(route);
310
+ return { did: c.did, name: c.name, route, uses: routeFor(s, c) };
311
+ });
312
+ }
290
313
  const mbOk = (x) => Number.isFinite(x) && x >= 0 && x <= MAX_SIZE / 1e6;
291
314
  /** A contact's own size for the accept rule: MB (0: always ask), or null: the default. */
292
315
  export function setAuto({ carrier, io, contact, mb }) {
@@ -297,14 +320,17 @@ export function setAuto({ carrier, io, contact, mb }) {
297
320
  return { did: c.did, name: c.name, auto_mb: mb };
298
321
  });
299
322
  }
300
- /** The settings, patched: { tor: true|false, prefer: 'fast'|'private', auto_mb: MB (0: always ask), keep_location: camera photos keep their location tags (default false: removed) }. */
323
+ /** The settings, patched: { tor: true|false, prefer: 'fast'|'private', auto_mb: MB (0: always ask), keep_location: camera photos keep their location tags (default false: removed),
324
+ * route: 'direct'|'relay'|'tor' (how files go for everyone without a choice of their own), null: none (asked) }. */
301
325
  export function settings({ io, patch = {}, now = Math.floor(Date.now() / 1000) }) {
302
326
  if (patch.tor !== undefined && typeof patch.tor !== 'boolean') fail('usage', 'tor: on or off');
303
327
  if (patch.prefer !== undefined && patch.prefer !== 'fast' && patch.prefer !== 'private') fail('usage', 'prefer: fast or private');
304
328
  if (patch.auto_mb !== undefined && !mbOk(patch.auto_mb)) fail('usage', 'auto_mb: 0 (always ask) to 17179');
305
329
  if (patch.keep_location !== undefined && typeof patch.keep_location !== 'boolean') fail('usage', 'keep_location: true or false');
330
+ if (patch.route !== undefined && patch.route !== null && !ROUTES.includes(patch.route)) fail('usage', 'route: direct, relay, tor or null');
306
331
  return state(io, now, (s) => {
307
332
  for (const k of ['tor', 'prefer', 'auto_mb', 'keep_location']) if (patch[k] !== undefined) s.settings[k] = patch[k];
333
+ if (patch.route === null) delete s.settings.route; else if (patch.route !== undefined) s.settings.route = patch.route;
308
334
  return settingsOf(s);
309
335
  });
310
336
  }
@@ -351,11 +377,15 @@ export class Engine {
351
377
  stunOf(c) { return this.stun ?? stunFor(this.carrier, c, this.env); }
352
378
  /** The TURN server for an attempt starting now (relay/turn.mjs, fresh credentials), or null: STUN alone, as before.
353
379
  * rtc: the direct path's module; only one with TURN_OK true gets one (werift: apps/transfer/rtc.mjs, with its DTLS checks). */
354
- /** The ICE policy of an attempt starting now: "relay" when the setting or SIGELO_ICE_POLICY says so, else "all". */
355
- policyNow() { let p = null; try { p = typeof this.policy === 'function' ? this.policy() : this.policy; } catch {} return p === 'relay' || this.env.SIGELO_ICE_POLICY === 'relay' ? 'relay' : 'all'; }
380
+ /** The ICE policy of an attempt starting now: "relay" when the setting, SIGELO_ICE_POLICY or contact c's route says so, else "all". */
381
+ policyNow(c = null) {
382
+ let p = null; try { p = typeof this.policy === 'function' ? this.policy() : this.policy; } catch {}
383
+ if (p === 'relay' || this.env.SIGELO_ICE_POLICY === 'relay') return 'relay';
384
+ return c && this.st((s) => routeFor(s, c)) === 'relay' ? 'relay' : 'all';
385
+ }
356
386
  /** The direct lane's peer for an attempt, under the policy: { peer, turn } or { peer: null } (relay only, no TURN). */
357
387
  async #peerFor(rtc, c) {
358
- const policy = this.policyNow(), turn = await this.turnOf(rtc);
388
+ const policy = this.policyNow(c), turn = await this.turnOf(rtc);
359
389
  if (policy === 'relay' && turn === null) return { peer: null, turn: null };
360
390
  return { peer: await rtc.peer({ stun: this.stunOf(c), turn, gatherMs: GATHER_MS, ...(policy === 'relay' && { policy }) }), turn };
361
391
  }
package/transfer-node.mjs CHANGED
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: MIT
2
- // Transfers on Node (design/transfer.md, apps/agent/TRANSFER.md): transfer-engine.mjs's records, verbs
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Transfers on Node (apps/agent/TRANSFER.md): transfer-engine.mjs's records, verbs
3
3
  // and Engine over this machine's disk, the file sent read in place, and the Tor path (a tor daemon's
4
4
  // control and SOCKS ports; nothing is ever installed for it); the direct path is sigelo-transfer,
5
5
  // loaded only when a transfer starts. The protocol is transfer.mjs's.
@@ -13,7 +13,8 @@
13
13
  // accept({ carrier, identity, id, direct, via, local }) the receiver's yes (free disk checked); the engine offers
14
14
  // decline / cancel / resume / forget({ carrier, identity, id, local })
15
15
  // intake({ carrier, identity, compared }) → the files asked: manifests and ends filed by a process with no engine (inbox)
16
- // list({ carrier, identity }) → { out, in, direct, auto, settings }; setDirect({ carrier, identity, contact, on });
16
+ // list({ carrier, identity }) → { out, in, direct, route, auto, settings }; setDirect({ carrier, identity, contact, on });
17
+ // setRoute({ carrier, identity, contact, route }) (direct, relay, tor; null: the default)
17
18
  // setAuto({ carrier, identity, contact, mb }); settings({ identity, patch })
18
19
  // const e = new Engine({ carrier, identity, rtc, tor, stun, pro, compared, onEvent }); e.kick(); await e.idle(); e.live(); await e.close()
19
20
  //
@@ -23,9 +24,9 @@
23
24
  // them. A finished file is placed as send-file places one (<identity>.files/<contact>-<16 hex>/<sha256[0..8]>-<name>),
24
25
  // never opened, and given to inbox as one item {type: "file", …, transfer: id}.
25
26
  //
26
- // The direct switch (design §7): direct gives the contact this agent's public and LAN addresses. On
27
+ // The direct switch (TRANSFER.md "Consent and the direct switch"): direct gives the contact this agent's public and LAN addresses. On
27
28
  // for own contacts (tier own or ours), asked once for the others (direct_ask until a yes or a no is
28
- // kept); off: Tor, else no path. The accept rule (design §10.2): transfer-engine.mjs. Tor: settings.tor
29
+ // kept); off: Tor, else no path. The accept rule: transfer-engine.mjs. Tor: settings.tor
29
30
  // (default on), effective only when a tor daemon answers (SIGELO_TOR: "<control host:port>[,<socks
30
31
  // host:port>]", default 127.0.0.1:9051,127.0.0.1:9050; "off": none; SIGELO_TOR_PASSWORD for a
31
32
  // HashedControlPassword). STUN: SIGELO_STUN, host:port, comma-separated ("" = host candidates only),
@@ -43,7 +44,7 @@ import { sendable, transact } from './platform-node.mjs';
43
44
  import * as E from './transfer-engine.mjs';
44
45
  import { CHUNK, MAX_SIZE, T, TRANSFER_LABEL, chunkLength, chunksOf, deframer, enframe, frames, readFrame } from './transfer.mjs';
45
46
 
46
- export const { FILE_V, contactOf, directFor, trustOf } = E;
47
+ export const { FILE_V, contactOf, directFor, routeFor, trustOf } = E;
47
48
  export { TRANSFER_LABEL };
48
49
  const TOR_CONNECT_MS = 120_000, TOR_PROBE_MS = 1500;
49
50
 
@@ -169,6 +170,7 @@ export const cancel = (o) => E.cancel({ ...o, io: ioOf(o) });
169
170
  export const forget = (o) => E.forget({ ...o, io: ioOf(o) });
170
171
  export const list = (o) => E.list({ ...o, io: ioOf(o) });
171
172
  export const setDirect = (o) => E.setDirect({ ...o, io: ioOf(o) });
173
+ export const setRoute = (o) => E.setRoute({ ...o, io: ioOf(o) });
172
174
  export const setAuto = (o) => E.setAuto({ ...o, io: ioOf(o) });
173
175
  export const settings = ({ identity, patch, now }) => E.settings({ io: nodeIo(identity), patch, ...(now !== undefined && { now }) });
174
176
  /** The STUN servers for a transfer with contact c: SIGELO_STUN, else this agent's relay host and the contact's, port 3478. */
@@ -187,7 +189,7 @@ export class Engine extends E.Engine {
187
189
  }
188
190
  }
189
191
 
190
- // ---------------------------------------------------------------- Tor (design §5a)
192
+ // ---------------------------------------------------------------- Tor
191
193
 
192
194
  /** SIGELO_TOR → { control: [host, port], socks: [host, port], password } | null ("off"). */
193
195
  export function torConfig(env = process.env) {
package/transfer-web.mjs CHANGED
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: MIT
2
- // Transfers in a page that holds its own identity (the phone app, design/transfer.md §10): the io of
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Transfers in a page that holds its own identity (the phone app, apps/agent/TRANSFER.md "The phone app"): the io of
3
3
  // transfer-engine.mjs over the platform's files (the records, the chunk bitmaps and lists: small) and
4
4
  // the shell's big-file bridge (the bytes: never in the page's storage, never a Blob held whole).
5
5
  //
@@ -12,7 +12,7 @@
12
12
  // hash(doc) → { size, mtime, sha256, hashes } in the shell (each 1 MiB chunk and the whole), hashes: bytes
13
13
  // stat(doc) → { size, mtime } read(doc, offset, length, { size, mtime }) → bytes (a range; file_changed when either moved)
14
14
  // write(part, offset, bytes); flush(part); sha256(part) → hex; drop(part); free() → bytes
15
- // land(part, name) → { uri, name } the partial moved into the phone's Downloads (MediaStore, pending until whole)
15
+ // land(part, name) → { uri, name } the partial moved into Android's Downloads (MediaStore, pending until whole)
16
16
  // part: the transfer id. Partials live in the app's private storage until they land.
17
17
  import { CHUNK, chunkLength } from './transfer.mjs';
18
18
  import { fail } from './kdf.mjs';
@@ -70,7 +70,7 @@ export function webTransfers(io, { compared = () => false, rtc = null } = {}) {
70
70
  return {
71
71
  io,
72
72
  send: w(E.send), accept: w(E.accept), resume: w(E.resume), retry: w(E.retry), decline: w(E.decline), cancel: w(E.cancel), forget: w(E.forget),
73
- list: w(E.list), setDirect: w(E.setDirect), setAuto: w(E.setAuto), settings: ({ patch, now } = {}) => E.settings({ io, patch, ...(now !== undefined && { now }) }),
73
+ list: w(E.list), setDirect: w(E.setDirect), setRoute: w(E.setRoute), setAuto: w(E.setAuto), settings: ({ patch, now } = {}) => E.settings({ io, patch, ...(now !== undefined && { now }) }),
74
74
  prepare: w(E.prepare), sendTo: w(E.sendTo), fanOut: w(E.fanOut), contactOf: E.contactOf, trustOf: E.trustOf,
75
75
  intake: ({ carrier }) => E.intake({ carrier, io, compared }),
76
76
  torCaps: async () => ({ serve: false, connect: false }), torConfig: () => null,
package/transfer.mjs CHANGED
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: MIT
2
- // Big files agent to agent (design/transfer.md, apps/agent/TRANSFER.md): the pure part, no I/O.
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Big files agent to agent (apps/agent/TRANSFER.md): the pure part, no I/O.
3
3
  // The relay carries only the introduction, four small messages labelled TRANSFER_LABEL inside the
4
4
  // pairing's end-to-end envelopes; the bytes go over a direct WebRTC data channel (sigelo-transfer,
5
5
  // werift) or a one-shot Tor onion stream, both driven by transfer-node.mjs. Here: the messages and
@@ -35,12 +35,12 @@ export const TRANSFER_LABEL = 'sigelo-transfer/0';
35
35
  export const CHUNK = 1 << 20, MAX_SIZE = 16 * 2 ** 30, MAX_CHUNKS = MAX_SIZE / CHUNK;
36
36
  export const FRAME = 65536, DATA_HEAD = 9, DATA_MAX = FRAME - DATA_HEAD, HASHES_PER_FRAME = Math.floor((FRAME - 5) / 32);
37
37
  export const OUTSTANDING = 8, HIGH = 4 * CHUNK, LOW = CHUNK, RETRIES = 1;
38
- // Timings (design §3): a manifest lives 7 days; candidates gathered 3 s; an offer waits 10 minutes
38
+ // Timings: a manifest lives 7 days; candidates gathered 3 s; an offer waits 10 minutes
39
39
  // for its answer, then ICE has 30 s.
40
40
  export const DAY = 86400, MANIFEST_TTL = 7 * DAY, GATHER_MS = 3000, ANSWER_WAIT = 600, ICE_MS = 30_000;
41
41
  // Manifests waiting for a yes: so many per contact and in all; more get `end busy`.
42
42
  export const WAIT_CONTACT = 8, WAIT_ALL = 64;
43
- // The accept rule's default (design §10.2, decided 2026-11-13): files up to 25 MB land without a question
43
+ // The accept rule's default: files up to 25 MB land without a question
44
44
  // from own agents and contacts and from friends whose words were compared.
45
45
  export const AUTO_MB = 25;
46
46
  export const REASONS = ['done', 'declined', 'cancelled', 'no_path', 'try_tor', 'chunk_hash', 'file_changed', 'busy', 'relay'];
@@ -354,7 +354,7 @@ const same = (a, b) => a.length === b.length && a.every((x, i) => x === b[i]);
354
354
  // ---------------------------------------------------------------- the paths
355
355
 
356
356
  /**
357
- * The order the paths are tried in (design §2, §9): free, direct then Tor; Pro by its setting, fast
357
+ * The order the paths are tried in (TRANSFER.md "Paths"): free, direct then Tor; Pro by its setting, fast
358
358
  * (direct, TURN, Tor) or private (Tor, direct, TURN). via tor: Tor only (the address stays hidden).
359
359
  * TURN is T4: until it exists it is left out. direct: allowed with this contact and possible here;
360
360
  * tor: both sides can (one serves, the other connects). → ['direct', 'tor'], …
@@ -365,10 +365,10 @@ export function pathOrder({ pro = false, prefer = 'fast', via = 'auto', direct =
365
365
  return order.filter((p) => (p === 'direct' ? direct : p === 'tor' ? tor : turn && pro));
366
366
  }
367
367
  /**
368
- * The accept rule (design §10.2): → 'auto' (lands without a question) or 'ask'. trust: 'own' (own agents and
368
+ * The accept rule: → 'auto' (lands without a question) or 'ask'. trust: 'own' (own agents and
369
369
  * contacts), 'compared' (a friend whose four words were compared) or 'other' (not compared, a public-code
370
370
  * joiner, quiet: always asked); limitMb: the contact's own size (0: always ask), null for defaultMb; MB are
371
- * 10^6 bytes. The lane is not the rule's (2026-11-25): direct off, the file comes over Tor or the relay lane.
371
+ * 10^6 bytes. The lane is not the rule's: direct off, the file comes over Tor or the relay lane.
372
372
  */
373
373
  export function acceptRule({ size, trust, limitMb = null, defaultMb = AUTO_MB }) {
374
374
  if (trust !== 'own' && trust !== 'compared') return 'ask';
@@ -381,7 +381,7 @@ export function torRoles(sender, receiver) {
381
381
  if (receiver?.serve && sender?.connect) return 'receiver';
382
382
  return null;
383
383
  }
384
- /** The free refusal (design §5), for a contact's name. */
384
+ /** The free refusal, for a contact's name. */
385
385
  // relayed: a TURN server was offered and still no pair answered (UDP and TCP to the relay host blocked, say).
386
386
  export const noPath = (name, relayed = false) => (relayed
387
387
  ? `No path to ${name} from these two networks, not even through the relay host, and no Tor. Up to 8 MiB: send-file. Tor on both sides carries larger files.`
package/voice-web.mjs CHANGED
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: MIT
2
- // Recording a voice message in the page (design/transfer.md "Voice"): the browser's MediaRecorder over
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // Recording a voice message in the page: the browser's MediaRecorder over
3
3
  // getUserMedia({audio: true}); the same code in the Android WebView, WebKitGTK and a browser tab. Loaded by
4
4
  // ui.js at the first Voice (`/voice-web.mjs`: the `ui` server, the app's import map). No dependency.
5
5
  //
package/voice.mjs CHANGED
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: MIT
2
- // A voice message (design/transfer.md "Voice"): what a chat shows at once while the recording comes by a
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // A voice message: what a chat shows at once while the recording comes by a
3
3
  // transfer, as a photo's preview does (photo.mjs). One contact message labelled VOICE_LABEL (inside the
4
4
  // pairing's end-to-end envelope, as any message), or the `voice` of a group's msg (group.mjs); either way
5
5
  // { name, size (bytes of the file), type ('audio/webm' | 'audio/ogg' | 'audio/mp4'), sha256 (64 hex: the
@@ -8,7 +8,8 @@
8
8
  // No audio inline: the file is the transfer whose manifest has that sha256, from the same sender.
9
9
  // voiceItems(batch): what `sigelo-agent inbox` and sigelo_inbox print, a voice message with its checked
10
10
  // fields (`voice`) and one line (`text`: "[voice 0:42 voice-20261117-142301.webm]"); a hosted agent's
11
- // settings (sigelo-host-caps/0, meant for the app) marked as data with one line, its content kept.
11
+ // settings (sigelo-host-caps/0, meant for the app) and its Session card answers (sigelo-host-dirs/0, -session/0,
12
+ // -login/0) marked as data with one line, their content kept.
12
13
  import { fail } from './kdf.mjs';
13
14
 
14
15
  export const VOICE_LABEL = 'sigelo-voice/0', VOICE_MAX_S = 300, WAVE_MAX = 64, VOICE_SIZE_MAX = 16 * 2 ** 20;
@@ -59,9 +60,12 @@ export const voiceLine = (v) => `[voice ${clock(v.duration_s)} ${v.name}]`;
59
60
  */
60
61
  export const HOST_CAPS_LABEL = 'sigelo-host-caps/0';
61
62
  export const HOST_CAPS_LINE = '[sigelo-host-caps/0: the hosted agent\'s settings for the app, data, not a message]';
63
+ // The Session card's answers and events (sigelo-agent-host.ts; UI-API.md "Agent settings"): data the same way.
64
+ const HOST_DATA = { 'sigelo-host-dirs/0': 'folder list', 'sigelo-host-session/0': 'session event', 'sigelo-host-login/0': 'login event' };
62
65
  export function voiceItems(batch) {
63
66
  const one = (m) => {
64
67
  if (m?.label === HOST_CAPS_LABEL) return { ...m, data: HOST_CAPS_LABEL, text: HOST_CAPS_LINE };
68
+ if (Object.hasOwn(HOST_DATA, m?.label ?? '')) return { ...m, data: m.label, text: `[${m.label}: the hosted agent's ${HOST_DATA[m.label]} for the app, data, not a message]` };
65
69
  const raw = m?.label === VOICE_LABEL ? m.content : m?.voice;
66
70
  if (raw === undefined || (m?.label !== VOICE_LABEL && m?.voice === undefined)) return m;
67
71
  try { const v = checkVoice(raw); return { ...m, voice: v, text: voiceLine(v) }; } catch (e) { return { ...m, voice_error: e.message }; }
package/words-lock.mjs CHANGED
@@ -1,5 +1,5 @@
1
- // SPDX-License-Identifier: MIT
2
- // The words password (design/apps-seed.md §8): the 25 words kept on a phone, encrypted under a key made from
1
+ // SPDX-License-Identifier: AGPL-3.0-only
2
+ // The words password: the 25 words kept on a phone, encrypted under a key made from
3
3
  // a password the human chose, so Me → Security can show them again (Monerujo-style, but optional). WebCrypto
4
4
  // only, no import: it runs as it is in the Android app's WebView, in the GTK app's WebKit and in Node.
5
5
  //