sigelo-contact 0.1.21 → 0.1.22

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 +507 -57
  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 +7 -7
  60. package/test-transfer.mjs +6 -6
  61. package/test-voice.mjs +2 -2
  62. package/test-ws.mjs +1 -1
  63. package/transfer-engine.mjs +6 -6
  64. package/transfer-node.mjs +5 -5
  65. package/transfer-web.mjs +3 -3
  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
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
  //