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.
- package/GROUPS-REFERENCE.md +165 -0
- package/GROUPS.md +53 -0
- package/LICENSE +235 -21
- package/README.md +4 -5
- package/call.mjs +89 -28
- package/carrier.mjs +230 -51
- package/control.mjs +2 -2
- package/create.mjs +2 -2
- package/device.mjs +2 -2
- package/enrol.mjs +2 -2
- package/envelope.mjs +6 -6
- package/file.mjs +2 -2
- package/fixtures/carrier-v0.json +1 -1
- package/fixtures/envelope-v0.json +1 -1
- package/fixtures/group-v2.json +2999 -0
- package/gen-carrier.mjs +2 -2
- package/gen-device.mjs +1 -1
- package/gen-envelope.mjs +2 -2
- package/gen-group2.mjs +291 -0
- package/gen-invite.mjs +2 -2
- package/gen-short.mjs +1 -1
- package/group.mjs +116 -17
- package/group2.mjs +1534 -0
- package/home-wire.mjs +812 -0
- package/invite.mjs +3 -3
- package/kdf.mjs +2 -2
- package/kin.mjs +62 -0
- package/link.mjs +6 -6
- package/package.json +25 -8
- package/page.mjs +507 -57
- package/photo.mjs +2 -2
- package/platform-node.mjs +6 -6
- package/prekeys.mjs +3 -3
- package/public.mjs +2 -2
- package/qr-decode.mjs +1 -1
- package/qr.mjs +2 -2
- package/relays.mjs +2 -2
- package/restore.mjs +2 -2
- package/rtc-web.mjs +3 -3
- package/short.mjs +2 -2
- package/store.mjs +22 -9
- package/test-carrier.mjs +32 -11
- package/test-device.mjs +3 -3
- package/test-enrol.mjs +9 -4
- package/test-envelope.mjs +2 -2
- package/test-file.mjs +2 -2
- package/test-group-move.mjs +225 -0
- package/test-group.mjs +1 -1
- package/test-group2.mjs +202 -0
- package/test-home.mjs +225 -0
- package/test-invite.mjs +1 -1
- package/test-link.mjs +3 -3
- package/test-platform.mjs +2 -2
- package/test-presence.mjs +2 -2
- package/test-push.mjs +5 -5
- package/test-relay-lane.mjs +3 -3
- package/test-short.mjs +1 -1
- package/test-tier.mjs +8 -2
- package/test-transfer-web.mjs +7 -7
- package/test-transfer.mjs +6 -6
- package/test-voice.mjs +2 -2
- package/test-ws.mjs +1 -1
- package/transfer-engine.mjs +6 -6
- package/transfer-node.mjs +5 -5
- package/transfer-web.mjs +3 -3
- package/transfer.mjs +8 -8
- package/voice-web.mjs +2 -2
- package/voice.mjs +7 -3
- package/words-lock.mjs +2 -2
package/invite.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
2
|
-
// Invite codes and the invite handshake, contract sigelo-invite/0 (
|
|
3
|
-
// "
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// Invite codes and the invite handshake, contract sigelo-invite/0 (README.md
|
|
3
|
+
// "How it works", 1 and 2). Alice: makeInvite, store.addInvite, hand over `text`.
|
|
4
4
|
// Bob: parseInvite, buildAnswer, store.addAccept(code, answerId(answer), …). Alice: checkAnswer,
|
|
5
5
|
// buildReply. Bob: checkReply.
|
|
6
6
|
// No network here. The carrier encrypts answer and reply under inviteKeys(secret).key and posts
|
package/kdf.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
2
|
-
// sigelo-msg/0 key schedule (
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// sigelo-msg/0 key schedule (README.md "How it works"): pairing key, mailbox topics, the epoch
|
|
3
3
|
// chain. HKDF-SHA256 and HMAC-SHA256 only; every label below is part of the wire contract.
|
|
4
4
|
import { hkdf } from '@noble/hashes/hkdf.js';
|
|
5
5
|
import { hmac } from '@noble/hashes/hmac.js';
|
package/kin.mjs
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
|
+
// "One of mine": is a peer agent a sibling, another worker of my operator (apps/agent/ENROL.md
|
|
3
|
+
// "Your agents recognise each other", THREAT-MODEL §2.11b)? Two checks, both required:
|
|
4
|
+
// 1. an operator attestation on the peer's chain (ctx sigelo-relay/operator, SPEC §5): sub a DID
|
|
5
|
+
// of its chain, unexpired, its signature verified (SPEC §9 step 5) against the genesis whose
|
|
6
|
+
// hash is the issuer's DID, and that issuer is MY operator: the one my own identity carries an
|
|
7
|
+
// unexpired operator attestation from (pinned at enrolment: `enrolled.operator`, when given);
|
|
8
|
+
// 2. the peer's governing recovery commitment is mine (every worker's genesis commits to the
|
|
9
|
+
// operator's seed). The commitment is public (SPEC §7, a genesis may copy it): never enough alone.
|
|
10
|
+
// The DID-to-genesis binding is a hash, so the operator genesis the peer presents IS my operator's
|
|
11
|
+
// genesis whenever its DID is: an agent missing it takes it from the peer, checked so, once.
|
|
12
|
+
// App layer, not ts/: the core verifier reports and never judges (CLAUDE.md invariant 8); this is
|
|
13
|
+
// a judgement over two §9 results.
|
|
14
|
+
// kin({ me, peer, now, operator?, roster? }) → { kin: true, operator, did, exp, worker? }
|
|
15
|
+
// | { kin: false, reason, detail }
|
|
16
|
+
// me, peer: bundles (SPEC §8; an identity file is one, with its secret ignored). operator: the
|
|
17
|
+
// pinned operator DID. roster: { [i]: { did, original } } (me.local.keeper.json workers), for `worker`.
|
|
18
|
+
// On the operator itself (no operator attestation, the peer attested by a DID of its chain) the
|
|
19
|
+
// answer is the same, operator = me. Reasons: peer_bundle, my_bundle, self, no_operator, operator,
|
|
20
|
+
// expired, other_operator, no_attestation, commitment.
|
|
21
|
+
import { verify, did as didOf } from 'sigelo';
|
|
22
|
+
|
|
23
|
+
export const OPERATOR_CTX = 'sigelo-relay/operator';
|
|
24
|
+
const no = (reason, detail) => ({ kin: false, reason, detail });
|
|
25
|
+
const bundleOf = (x) => ({ v: 'sigelo/0', typ: 'bundle', genesis: x.genesis, rotations: x.rotations ?? [], bindings: [], attestations: x.attestations ?? [], issuers: x.issuers ?? [] });
|
|
26
|
+
const raw = (b) => (b.attestations ?? []).map((a) => a?.body).filter((x) => x?.ctx === OPERATOR_CTX && typeof x.iss === 'string');
|
|
27
|
+
|
|
28
|
+
export function kin({ me, peer, now, operator, roster } = {}) {
|
|
29
|
+
if (!Number.isSafeInteger(now)) throw new TypeError('kin: now must be Unix seconds');
|
|
30
|
+
let p;
|
|
31
|
+
try { p = verify(bundleOf(peer ?? {}), now); } catch (e) { return no('peer_bundle', `the peer's bundle does not verify: ${e.message}`); }
|
|
32
|
+
const mine = bundleOf(me ?? {});
|
|
33
|
+
// My operator's genesis, if my file lacks it: from the peer, only under the DID I already name.
|
|
34
|
+
const want = new Set([operator, ...raw(mine).map((b) => b.iss)].filter(Boolean)), have = new Set(mine.issuers.map((g) => { try { return didOf(g); } catch { return null; } }));
|
|
35
|
+
for (const g of p && peer?.issuers ? peer.issuers : []) {
|
|
36
|
+
let d; try { d = didOf(g); } catch { continue; }
|
|
37
|
+
if (want.has(d) && !have.has(d)) { mine.issuers = [...mine.issuers, g]; have.add(d); }
|
|
38
|
+
}
|
|
39
|
+
let m;
|
|
40
|
+
try { m = verify(mine, now); } catch (e) { return no('my_bundle', `this identity does not verify: ${e.message}`); }
|
|
41
|
+
if (p.chain.some((d) => m.chain.includes(d))) return no('self', `${p.did} is this identity`);
|
|
42
|
+
// My operators: issuers of an unexpired operator attestation about me (§9 checked it), the pin
|
|
43
|
+
// alone when there is one; and myself, for the operator's own check.
|
|
44
|
+
const attesting = Object.entries(m.attestations).filter(([iss, bs]) => !m.chain.includes(iss) && bs.some((b) => b.ctx === OPERATOR_CTX)).map(([iss]) => iss);
|
|
45
|
+
const ops = operator ? attesting.filter((d) => d === operator) : attesting;
|
|
46
|
+
if (operator && ops.length === 0) return no('no_operator', `this identity holds no unexpired attestation from its operator ${operator}: renew it (enrol --here on the operator's side)`);
|
|
47
|
+
const by = [...ops, ...m.chain];
|
|
48
|
+
if (p.chain.some((d) => ops.includes(d))) return no('operator', `${p.did} is your operator, not a sibling`);
|
|
49
|
+
const found = Object.entries(p.attestations).flatMap(([iss, bs]) => bs.filter((b) => b.ctx === OPERATOR_CTX && by.includes(iss)));
|
|
50
|
+
if (found.length === 0) {
|
|
51
|
+
const theirs = raw(bundleOf(peer));
|
|
52
|
+
if (theirs.some((b) => by.includes(b.iss) && b.exp <= now)) return no('expired', `its attestation from ${ops[0] ?? m.did} has expired: the operator renews it`);
|
|
53
|
+
if (ops.length === 0 && Object.values(p.attestations).flat().every((b) => b.ctx !== OPERATOR_CTX)) return no('no_operator', 'this identity has no operator and did not attest the peer');
|
|
54
|
+
const other = Object.entries(p.attestations).find(([, bs]) => bs.some((b) => b.ctx === OPERATOR_CTX))?.[0];
|
|
55
|
+
if (other) return no('other_operator', `its operator is ${other}, not ${ops[0] ?? m.did}`);
|
|
56
|
+
return no('no_attestation', `no valid operator attestation from ${ops[0] ?? m.did} on ${p.did}'s chain (a copied one names another DID and is discarded)`);
|
|
57
|
+
}
|
|
58
|
+
if (m.recovery === null || p.recovery !== m.recovery) return no('commitment', `its recovery commitment ${p.recovery ?? 'none'} is not yours: not derived from your operator's seed`);
|
|
59
|
+
const a = found.reduce((x, y) => (y.exp > x.exp ? y : x));
|
|
60
|
+
const i = Object.entries(roster ?? {}).find(([, w]) => w && (p.chain.includes(w.did) || p.chain.includes(w.original)))?.[0];
|
|
61
|
+
return { kin: true, operator: a.iss, did: p.did, exp: a.exp, ...(i !== undefined && { worker: Number(i) }) };
|
|
62
|
+
}
|
package/link.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
// SPDX-License-Identifier:
|
|
1
|
+
// SPDX-License-Identifier: AGPL-3.0-only
|
|
2
2
|
// Links, contract sigelo-link/1: the operator introduces two of its own agents, or one of its agents
|
|
3
3
|
// to an external contact X (apps/agent/LINKS.md, THREAT-MODEL §2.16). The operator asks agent A
|
|
4
4
|
// for a one-use long code (never parked,
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
// setLink): {id, purpose, linked_by, expires, tier}. A link sets a tier (friend or quiet, or none:
|
|
9
9
|
// computed) and a purpose, never `ours`, never own.
|
|
10
10
|
//
|
|
11
|
-
// External (
|
|
11
|
+
// External (apps/agent/LINKS.md): B is X, a contact of the operator's that is not its own. A files
|
|
12
12
|
// X at friend (default) or quiet; how X files A is X's operator's (tierB refused, link_tier). The code
|
|
13
13
|
// names the relay of the operator's pairing with X unless `relay` says otherwise. X takes an offer
|
|
14
14
|
// unasked only from its own operator; any other is an introduction: kept pending in X's file (a
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
// they return messages; never by the model.
|
|
34
34
|
// list({ carrier, file }) → { links: this agent's linked contacts, made: the operator's }
|
|
35
35
|
// labelled(carrier, messages) → the messages, each from a linked contact carrying
|
|
36
|
-
// link: {id, purpose} (
|
|
36
|
+
// link: {id, purpose} (the inbox shows why; data, never instructions)
|
|
37
37
|
//
|
|
38
38
|
// The messages: label LINK_LABEL on sigelo-msg/0, content {v, typ, id, iat, …}, id 8 characters of
|
|
39
39
|
// short.mjs's alphabet:
|
|
@@ -59,7 +59,7 @@
|
|
|
59
59
|
// restores that tier and keeps the contact. Otherwise an end forgets the contact on both sides, as
|
|
60
60
|
// ended (store.mjs): a NEW link between the same two pairs again only when each side is asked afresh
|
|
61
61
|
// (an ask, its operator's offer, or X's operator's accept; never an allow rule), each leaving a
|
|
62
|
-
// one-use permit (carrier.relink); the ended id never again (link_stale).
|
|
62
|
+
// one-use permit (carrier.relink); the ended id never again (link_stale).
|
|
63
63
|
//
|
|
64
64
|
// The file, 0600, beside the identity (x.json → x.links.json), under its own lock:
|
|
65
65
|
// { v, links: { id: operator records }, pending: { "<by> <id>": an agent's step in progress },
|
|
@@ -70,7 +70,7 @@ import { canonicalize, verify } from 'sigelo';
|
|
|
70
70
|
import { LINK_LABEL, LINK_SEND, readCode } from './carrier.mjs';
|
|
71
71
|
import { MsgError, checkNow, fail } from './kdf.mjs';
|
|
72
72
|
import { ALPHABET } from './short.mjs';
|
|
73
|
-
// Files and the lock: the carrier's platform (
|
|
73
|
+
// Files and the lock: the carrier's platform (README.md "Platforms"), Node's without one.
|
|
74
74
|
import { platform as nodePlatform } from './platform-node.mjs';
|
|
75
75
|
|
|
76
76
|
export const LINK_V = 'sigelo-link/1', FILE_V = 'sigelo-links/1';
|
|
@@ -407,7 +407,7 @@ async function onOperator(carrier, file, m, x, out) {
|
|
|
407
407
|
l.steps[side] = x.status; l.at = now;
|
|
408
408
|
if (x.status === 'refused' && l.status === 'pending') Object.assign(l, { status: 'refused', check: x.check ?? 'link_refused' });
|
|
409
409
|
else if (x.status === 'ended' && l.status !== 'refused') Object.assign(l, { status: 'ended', check: l.check ?? x.check ?? null });
|
|
410
|
-
// External: A's word is enough (X need not tell
|
|
410
|
+
// External: A's word is enough (X need not tell).
|
|
411
411
|
else if (l.status === 'pending' && l.steps.a === 'linked' && (l.steps.b === 'linked' || l.kind === 'external')) l.status = 'linked';
|
|
412
412
|
});
|
|
413
413
|
if (r.status === 'refused' && x.status === 'refused') out.refused.push({ id: x.id, check: r.check, detail: `${side === 'a' ? rec.a_name : rec.b_name} refused link ${x.id}`, from: m.from });
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sigelo-contact",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.22",
|
|
4
4
|
"private": false,
|
|
5
|
-
"description": "Agent contacts for sigelo identities: invite codes, a contact store, end-to-end encrypted envelopes with hybrid post-quantum key agreement, and an MQTT carrier. Client code (MIT); the relay server is csigelo/sigelo-
|
|
5
|
+
"description": "Agent contacts for sigelo identities: invite codes, a contact store, end-to-end encrypted envelopes with hybrid post-quantum key agreement, and an MQTT carrier. Client code (MIT); the relay server is csigelo/sigelo-apps (AGPL-3.0).",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"ai-agents",
|
|
8
8
|
"agent-identity",
|
|
@@ -21,13 +21,13 @@
|
|
|
21
21
|
"homepage": "https://sigelo.io/",
|
|
22
22
|
"repository": {
|
|
23
23
|
"type": "git",
|
|
24
|
-
"url": "git+https://github.com/csigelo/sigelo.git",
|
|
24
|
+
"url": "git+https://github.com/csigelo/sigelo-apps.git",
|
|
25
25
|
"directory": "apps/contact"
|
|
26
26
|
},
|
|
27
27
|
"bugs": {
|
|
28
|
-
"url": "https://github.com/csigelo/sigelo/issues"
|
|
28
|
+
"url": "https://github.com/csigelo/sigelo-apps/issues"
|
|
29
29
|
},
|
|
30
|
-
"license": "
|
|
30
|
+
"license": "AGPL-3.0-only",
|
|
31
31
|
"type": "module",
|
|
32
32
|
"main": "carrier.mjs",
|
|
33
33
|
"exports": {
|
|
@@ -50,10 +50,16 @@
|
|
|
50
50
|
"./short.mjs": "./short.mjs",
|
|
51
51
|
"./enrol": "./enrol.mjs",
|
|
52
52
|
"./enrol.mjs": "./enrol.mjs",
|
|
53
|
+
"./kin": "./kin.mjs",
|
|
54
|
+
"./kin.mjs": "./kin.mjs",
|
|
53
55
|
"./link": "./link.mjs",
|
|
54
56
|
"./link.mjs": "./link.mjs",
|
|
55
57
|
"./group": "./group.mjs",
|
|
56
58
|
"./group.mjs": "./group.mjs",
|
|
59
|
+
"./home-wire": "./home-wire.mjs",
|
|
60
|
+
"./group2": "./group2.mjs",
|
|
61
|
+
"./group2.mjs": "./group2.mjs",
|
|
62
|
+
"./home-wire.mjs": "./home-wire.mjs",
|
|
57
63
|
"./page": "./page.mjs",
|
|
58
64
|
"./page.mjs": "./page.mjs",
|
|
59
65
|
"./platform-node": "./platform-node.mjs",
|
|
@@ -94,6 +100,8 @@
|
|
|
94
100
|
},
|
|
95
101
|
"files": [
|
|
96
102
|
"README.md",
|
|
103
|
+
"GROUPS.md",
|
|
104
|
+
"GROUPS-REFERENCE.md",
|
|
97
105
|
"bip39-english.mjs",
|
|
98
106
|
"carrier.mjs",
|
|
99
107
|
"control.mjs",
|
|
@@ -104,8 +112,11 @@
|
|
|
104
112
|
"file.mjs",
|
|
105
113
|
"invite.mjs",
|
|
106
114
|
"kdf.mjs",
|
|
115
|
+
"kin.mjs",
|
|
107
116
|
"link.mjs",
|
|
108
117
|
"group.mjs",
|
|
118
|
+
"home-wire.mjs",
|
|
119
|
+
"group2.mjs",
|
|
109
120
|
"page.mjs",
|
|
110
121
|
"platform-node.mjs",
|
|
111
122
|
"prekeys.mjs",
|
|
@@ -129,11 +140,13 @@
|
|
|
129
140
|
"fixtures/carrier-v0.json",
|
|
130
141
|
"fixtures/device-v1.json",
|
|
131
142
|
"fixtures/envelope-v0.json",
|
|
143
|
+
"fixtures/group-v2.json",
|
|
132
144
|
"fixtures/invite-v0.json",
|
|
133
145
|
"fixtures/short-code-v0.json",
|
|
134
146
|
"gen-carrier.mjs",
|
|
135
147
|
"gen-device.mjs",
|
|
136
148
|
"gen-envelope.mjs",
|
|
149
|
+
"gen-group2.mjs",
|
|
137
150
|
"gen-invite.mjs",
|
|
138
151
|
"gen-short.mjs",
|
|
139
152
|
"test-carrier.mjs",
|
|
@@ -146,6 +159,9 @@
|
|
|
146
159
|
"test-invite.mjs",
|
|
147
160
|
"test-link.mjs",
|
|
148
161
|
"test-group.mjs",
|
|
162
|
+
"test-group2.mjs",
|
|
163
|
+
"test-group-move.mjs",
|
|
164
|
+
"test-home.mjs",
|
|
149
165
|
"test-platform.mjs",
|
|
150
166
|
"test-short.mjs",
|
|
151
167
|
"test-device.mjs",
|
|
@@ -159,18 +175,19 @@
|
|
|
159
175
|
"node": ">=22.18"
|
|
160
176
|
},
|
|
161
177
|
"scripts": {
|
|
162
|
-
"test": "node test-invite.mjs && node test-envelope.mjs && node test-carrier.mjs && node test-ws.mjs && node test-short.mjs && node test-renew.mjs && node test-public.mjs && node test-file.mjs && node test-enrol.mjs && node test-tier.mjs && node test-presence.mjs && node test-ended.mjs && node test-link.mjs && node test-device.mjs && node test-platform.mjs && node test-group.mjs && node test-transfer.mjs && node test-transfer-web.mjs && node test-relay-lane.mjs && node test-voice.mjs && node test-push.mjs && node test-call.mjs",
|
|
163
|
-
"gen": "node gen-invite.mjs && node gen-envelope.mjs && node gen-carrier.mjs && node gen-short.mjs && node gen-device.mjs",
|
|
178
|
+
"test": "node test-invite.mjs && node test-envelope.mjs && node test-carrier.mjs && node test-ws.mjs && node test-short.mjs && node test-renew.mjs && node test-public.mjs && node test-file.mjs && node test-enrol.mjs && node test-tier.mjs && node test-kin.mjs && node test-presence.mjs && node test-ended.mjs && node test-link.mjs && node test-device.mjs && node test-platform.mjs && node test-group.mjs && node test-group2.mjs && node test-home.mjs && node test-home-review.mjs && node test-events.mjs && node test-group-move.mjs && node test-super.mjs && node test-home-push.mjs && node test-transfer.mjs && node test-transfer-web.mjs && node test-relay-lane.mjs && node test-voice.mjs && node test-push.mjs && node test-call.mjs",
|
|
179
|
+
"gen": "node gen-invite.mjs && node gen-envelope.mjs && node gen-carrier.mjs && node gen-short.mjs && node gen-device.mjs && node gen-group2.mjs",
|
|
164
180
|
"prepack": "node ../../release/prepack.mjs pre",
|
|
165
181
|
"postpack": "node ../../release/prepack.mjs post",
|
|
166
182
|
"prepublishOnly": "node -e \"if(process.env.SIGELO_PUBLISH!=='1'){console.error('refusing: publish the release tarball (release/RELEASE.md) with SIGELO_PUBLISH=1');process.exit(1)}\""
|
|
167
183
|
},
|
|
168
184
|
"dependencies": {
|
|
169
185
|
"@noble/ciphers": "^2.4.0",
|
|
186
|
+
"@noble/curves": "^2.4.0",
|
|
170
187
|
"@noble/hashes": "^2.4.0",
|
|
171
188
|
"@noble/post-quantum": "^0.7.1",
|
|
172
189
|
"hash-wasm": "4.12.0",
|
|
173
190
|
"mqtt": "^5.16.0",
|
|
174
|
-
"sigelo": "^0.1.
|
|
191
|
+
"sigelo": "^0.1.22"
|
|
175
192
|
}
|
|
176
193
|
}
|