agent-comms 4.4.0 → 4.5.0
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/.claude-plugin/marketplace.json +1 -1
- package/.claude-plugin/plugin.json +1 -1
- package/README.md +5 -1
- package/dist/core/agent-registry.d.ts.map +1 -1
- package/dist/core/agent-registry.js +2 -0
- package/dist/core/agent-registry.js.map +1 -1
- package/dist/core/bridge-mesh.d.ts.map +1 -1
- package/dist/core/bridge-mesh.js +1 -0
- package/dist/core/bridge-mesh.js.map +1 -1
- package/dist/core/device-membership-verification.d.ts +2 -1
- package/dist/core/device-membership-verification.d.ts.map +1 -1
- package/dist/core/device-membership-verification.js +1 -1
- package/dist/core/device-membership-verification.js.map +1 -1
- package/dist/core/device-membership.d.ts +2 -0
- package/dist/core/device-membership.d.ts.map +1 -1
- package/dist/core/device-membership.js +9 -5
- package/dist/core/device-membership.js.map +1 -1
- package/dist/core/directory-admission.d.ts +20 -0
- package/dist/core/directory-admission.d.ts.map +1 -0
- package/dist/core/directory-admission.js +88 -0
- package/dist/core/directory-admission.js.map +1 -0
- package/dist/core/gateway-trust-actions.d.ts +1 -1
- package/dist/core/gateway-trust-actions.d.ts.map +1 -1
- package/dist/core/gateway-trust-actions.js +5 -1
- package/dist/core/gateway-trust-actions.js.map +1 -1
- package/dist/core/gateway-trust.d.ts +14 -2
- package/dist/core/gateway-trust.d.ts.map +1 -1
- package/dist/core/gateway-trust.js +40 -2
- package/dist/core/gateway-trust.js.map +1 -1
- package/dist/core/gossip-directory.d.ts +2 -0
- package/dist/core/gossip-directory.d.ts.map +1 -1
- package/dist/core/gossip-directory.js +9 -0
- package/dist/core/gossip-directory.js.map +1 -1
- package/dist/core/gossip-extensions.d.ts +2 -0
- package/dist/core/gossip-extensions.d.ts.map +1 -1
- package/dist/core/hub-session.d.ts +3 -3
- package/dist/core/hub-session.d.ts.map +1 -1
- package/dist/core/hub-session.js +6 -4
- package/dist/core/hub-session.js.map +1 -1
- package/dist/core/membership-proof.d.ts +45 -0
- package/dist/core/membership-proof.d.ts.map +1 -0
- package/dist/core/membership-proof.js +59 -0
- package/dist/core/membership-proof.js.map +1 -0
- package/dist/core/membership-proofs.d.ts +34 -0
- package/dist/core/membership-proofs.d.ts.map +1 -0
- package/dist/core/membership-proofs.js +66 -0
- package/dist/core/membership-proofs.js.map +1 -0
- package/dist/core/mesh-store.d.ts +8 -0
- package/dist/core/mesh-store.d.ts.map +1 -1
- package/dist/core/mesh-store.js +18 -3
- package/dist/core/mesh-store.js.map +1 -1
- package/dist/core/tool.d.ts +5 -0
- package/dist/core/tool.d.ts.map +1 -1
- package/dist/core/tool.js.map +1 -1
- package/dist/core/wire-mesh-transport-options.d.ts +12 -0
- package/dist/core/wire-mesh-transport-options.d.ts.map +1 -1
- package/dist/core/wire-mesh-transport.d.ts +1 -1
- package/dist/core/wire-mesh-transport.d.ts.map +1 -1
- package/dist/core/wire-mesh-transport.js +5 -5
- package/dist/core/wire-mesh-transport.js.map +1 -1
- package/dist/test/directory-admission.unit.test.d.ts +2 -0
- package/dist/test/directory-admission.unit.test.d.ts.map +1 -0
- package/dist/test/directory-admission.unit.test.js +182 -0
- package/dist/test/directory-admission.unit.test.js.map +1 -0
- package/dist/test/dm-grant-tool.integration.test.js +2 -1
- package/dist/test/dm-grant-tool.integration.test.js.map +1 -1
- package/dist/test/gateway-trust-tool.integration.test.js +22 -0
- package/dist/test/gateway-trust-tool.integration.test.js.map +1 -1
- package/dist/test/gateway-trust.unit.test.js +82 -1
- package/dist/test/gateway-trust.unit.test.js.map +1 -1
- package/dist/test/membership-proof.unit.test.d.ts +2 -0
- package/dist/test/membership-proof.unit.test.d.ts.map +1 -0
- package/dist/test/membership-proof.unit.test.js +148 -0
- package/dist/test/membership-proof.unit.test.js.map +1 -0
- package/dist/test/principal-membership-trust.integration.test.d.ts +5 -0
- package/dist/test/principal-membership-trust.integration.test.d.ts.map +1 -0
- package/dist/test/principal-membership-trust.integration.test.js +169 -0
- package/dist/test/principal-membership-trust.integration.test.js.map +1 -0
- package/dist/test/test-transport.d.ts.map +1 -1
- package/dist/test/test-transport.js +1 -0
- package/dist/test/test-transport.js.map +1 -1
- package/package.json +1 -1
|
@@ -32,6 +32,15 @@ export function findPresenceAdvert(deviceIdHex, directory) {
|
|
|
32
32
|
const status = entry.advert[PRESENCE_GOSSIP_KEY];
|
|
33
33
|
return AgentStatus.is(status) ? status : undefined;
|
|
34
34
|
}
|
|
35
|
+
/** The membership proof a peer gossiped in its agent/self advert, or undefined when it carries none. The advert is self-asserted by whichever peer sent it, so this only reads it; nothing about the proof is believed until it is verified. */
|
|
36
|
+
export function readMembershipProof(advert) {
|
|
37
|
+
const self = advert[AGENT_SELF_GOSSIP_KEY];
|
|
38
|
+
if (typeof self !== "object" || self === null)
|
|
39
|
+
return undefined;
|
|
40
|
+
if (!("membership" in self))
|
|
41
|
+
return undefined;
|
|
42
|
+
return typeof self.membership === "string" ? self.membership : undefined;
|
|
43
|
+
}
|
|
35
44
|
/** Re-sends this side's own current presence status, currently-hosted rooms, self-agent identity, and package versions, together, onto every live session's gossip self-advert -- one gossip frame per tick carrying whichever facts are actually known, rather than a separate frame per fact. Split out of wire-mesh-transport.ts's own WireMeshTransport class purely to keep that file under the repo's max-lines cap, the same reason mergeKnownDevices/findPresenceAdvert above already live here rather than there. A session that fails to send (mid-disconnect, most likely -- watchForDisconnect will independently notice and clean it up) is reported via onError and skipped, not allowed to stop the tick from reaching the rest of allSessions: a periodic broadcast to N peers is N independent operations, not one atomic unit. Unlike presence/hostedRooms/selfAgentAdvert, the versions extension is never actually absent (this side's own agent-comms package version is always known), so every tick this function is called for sends at least that one fact -- there is no "nothing to report" case left to short-circuit on. The hub's own session (agent-comms#156) is gated separately from every ordinary local-peer session in allSessions: local mesh trust is a different layer (connect_request/introduce approval already gated it before it ever joined allSessions), but the hub session is a broadcast to every connected hub peer, trusted or not, and would otherwise leak this side's own presence/hosted-rooms/self-agent/versions advert onto the hub regardless of GatewayTrust -- forwardAdvertsToHub/pushHubCatchUp's own hasAny gate exists to prevent exactly this for OTHER local peers' adverts, and this side's own self-advert deserves the identical gate, not a bypass. */
|
|
36
45
|
export function readvertiseGossip(options) {
|
|
37
46
|
const { allSessions, hub, hasAnyTrustedGateway, onError, getCurrentPresence, getHostedRooms, getSelfAgentAdvert, getCcPeerVersion, } = options;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gossip-directory.js","sourceRoot":"","sources":["../../src/core/gossip-directory.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAMhE,OAAO,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AACzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GAGpB,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,8BAA8B,GAE/B,MAAM,oBAAoB,CAAC;AAG5B,2OAA2O;AAC3O,MAAM,UAAU,iBAAiB,CAC/B,YAAqC,EACrC,SAAoC;IAEpC,KAAK,MAAM,KAAK,IAAI,SAAS,EAAE,CAAC;QAC9B,MAAM,WAAW,GAAG,aAAa,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;QAChD,MAAM,QAAQ,GAAG,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;QAC/C,IACE,QAAQ,KAAK,SAAS;YACtB,KAAK,CAAC,MAAM,CAAC,kBAAkB,CAAC,IAAI,QAAQ,CAAC,kBAAkB,CAAC,EAChE,CAAC;YACD,YAAY,CAAC,GAAG,CAAC,WAAW,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;QAC9C,CAAC;IACH,CAAC;AACH,CAAC;AAED,idAAid;AACjd,MAAM,UAAU,uBAAuB,CACrC,YAAuD;IAEvD,OAAO,KAAK,CAAC,IAAI,CAAC,YAAY,EAAE,CAAC,CAAC,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QAChC,iBAAiB,CAAC;YAChB,WAAW;YACX,GAAG;YACH,oBAAoB;YACpB,OAAO;YACP,kBAAkB;YAClB,cAAc;YACd,kBAAkB;YAClB,gBAAgB;SACjB,CAAC,CAAC;IACL,CAAC,EAAE,UAAU,CAAC,CAAC;IACf,QAAQ,CAAC,KAAK,EAAE,CAAC;IACjB,OAAO,QAAQ,CAAC;AAClB,CAAC"}
|
|
@@ -23,5 +23,7 @@ export interface AgentSelfAdvert {
|
|
|
23
23
|
startedAt: string;
|
|
24
24
|
tags: string[];
|
|
25
25
|
subscribedRooms: string[];
|
|
26
|
+
/** A proof that this device's user principal vouches for it (membership-proof.ts), so a peer that trusts that principal trusts this device without it being listed individually. Absent until the first proof has been minted. */
|
|
27
|
+
membership?: string;
|
|
26
28
|
}
|
|
27
29
|
//# sourceMappingURL=gossip-extensions.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gossip-extensions.d.ts","sourceRoot":"","sources":["../../src/core/gossip-extensions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,8QAA8Q;AAC9Q,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,mSAAmS;AACnS,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AAErD,+cAA+c;AAC/c,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,6RAA6R;AAC7R,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,gkBAAgkB;AAChkB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,eAAe,EAAE,MAAM,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"gossip-extensions.d.ts","sourceRoot":"","sources":["../../src/core/gossip-extensions.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,8QAA8Q;AAC9Q,eAAO,MAAM,mBAAmB,oBAAoB,CAAC;AAErD,mSAAmS;AACnS,eAAO,MAAM,uBAAuB,gBAAgB,CAAC;AAErD,+cAA+c;AAC/c,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,QAAQ,GAAG,SAAS,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;CACrB;AAED,6RAA6R;AAC7R,eAAO,MAAM,qBAAqB,eAAe,CAAC;AAElD,gkBAAgkB;AAChkB,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,EAAE,CAAC;IACf,eAAe,EAAE,MAAM,EAAE,CAAC;IAC1B,kOAAkO;IAClO,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB"}
|
|
@@ -27,10 +27,10 @@ export interface HubSessionDeps {
|
|
|
27
27
|
onDirectory: (entries: readonly DirectoryEntry[]) => void;
|
|
28
28
|
/** Dispatches an already-received, non-legacy-frame request (a real core/room verb: room.send, room.notify, room.join, ...) to WireMeshTransport's own roomRouter, the identical dispatch a local peer session's own drainSession already uses -- the outbound half of agent-comms#155's "remote to local" routing leg. Deferred the same lazy-`this`-capture way DeliveryEngine's own sendRoomRequestToMember closure is, since roomRouter is constructed after this class's own instance in WireMeshTransport's constructor. Declared with the identical (request, handle, origin?) shape RoomRouter.handleRequest itself has (agent-comms#216) so WireMeshTransport can keep wiring this dep as a direct method reference rather than a wrapper -- dispatchHubRequest below is what actually supplies a non-empty origin, carrying this side's own dialled hub address. */
|
|
29
29
|
handleRoomRequest: (request: IncomingManageRequest, handle: Readonly<ConnectionHandle>, origin?: Readonly<RoomRequestOrigin>) => Promise<void>;
|
|
30
|
-
/** The gateway trust boundary (agent-comms#156): whether the given device-id (hex) is currently trusted as a bare device. Since agent-comms#192, this gates only the traffic that carries no independent per-message security of its own: the legacy FRAME_VERB path (consume()'s own doc explains why) and dispatchHubRequest's own hubPeersKnown bookkeeping for a room-domain sender. A real room-domain verb's own dispatch is never gated on this at all; see dispatchHubRequest's own doc for why that is sound. connect()'s own directory-merge filter uses
|
|
30
|
+
/** The gateway trust boundary (agent-comms#156): whether the given device-id (hex) is currently trusted as a bare device. Since agent-comms#192, this gates only the traffic that carries no independent per-message security of its own: the legacy FRAME_VERB path (consume()'s own doc explains why) and dispatchHubRequest's own hubPeersKnown bookkeeping for a room-domain sender. A real room-domain verb's own dispatch is never gated on this at all; see dispatchHubRequest's own doc for why that is sound. connect()'s own directory-merge filter uses admitEntries below instead, not this. */
|
|
31
31
|
isTrusted: (deviceHex: string) => boolean;
|
|
32
|
-
/** Whether
|
|
33
|
-
|
|
32
|
+
/** Whether a gossiped directory entry may be merged (agent-comms#156, widened by #187 and #266): its device is trusted by id, or is itself a trusted principal's own device (agent-comms#192), or carries a membership proof a trusted principal vouches for. A gossiped advert is self-asserted, so the proof is what makes trusting a principal cover its devices; verifying one is cryptography, hence asynchronous. */
|
|
33
|
+
admitEntries: (entries: readonly DirectoryEntry[]) => Promise<DirectoryEntry[]>;
|
|
34
34
|
/** Forwards a room-domain manage-request on to a specific LOCAL peer session (one this gateway is directly connected to over the ordinary local mesh, keyed by device-id hex) rather than dispatching it against this gateway's own local state -- consume()'s own toDevice disambiguation (agent-comms#184, wire-mesh-core 1.48.1's IncomingManageRequest.toDevice). Returns undefined when no local session exists for that device-id, in which case consume() falls back to handleRoomRequest exactly as it always has. */
|
|
35
35
|
forwardToLocalPeer: (deviceHex: string, command: ManageCommand, scope: Readonly<CapabilityScope>, token?: CapabilityToken) => Promise<ManageOutcome> | undefined;
|
|
36
36
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-session.d.ts","sourceRoot":"","sources":["../../src/core/hub-session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAEL,KAAK,mBAAmB,EACxB,KAAK,cAAc,EACnB,KAAK,qBAAqB,EAC1B,KAAK,aAAa,EACnB,MAAM,oCAAoC,CAAC;AAG5C,OAAO,KAAK,EACV,eAAe,EACf,eAAe,EACf,KAAK,EACL,aAAa,EACd,MAAM,mCAAmC,CAAC;AAC3C,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EACV,gBAAgB,EAChB,eAAe,EACf,eAAe,EAChB,MAAM,gBAAgB,CAAC;AAKxB,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAEtD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAS1D,2fAA2f;AAE3f,MAAM,WAAW,cAAc;IAC7B,oIAAoI;IACpI,yBAAyB,EAAE,MAAM,CAAC;IAClC,yDAAyD;IACzD,aAAa,EAAE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC,CAAC;IAC/C,MAAM,EAAE,QAAQ,CAAC,eAAe,CAAC,CAAC;IAClC,yHAAyH;IACzH,cAAc,EAAE,MAAM,OAAO,CAAC;IAC9B,wEAAwE;IACxE,mBAAmB,EAAE,SAAS,MAAM,EAAE,CAAC;IACvC,sIAAsI;IACtI,OAAO,EAAE,CACP,UAAU,EAAE,QAAQ,CAAC,UAAU,CAAC,EAChC,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,KACnB,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;IAC1B,2FAA2F;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,EAAE,MAAM,CAAC;IACrB,IAAI,EAAE,QAAQ,CAAC,sBAAsB,CAAC,CAAC;IACvC,WAAW,EAAE,CAAC,SAAS,EAAE,MAAM,KAAK,IAAI,CAAC;IACzC,UAAU,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;CACjC,GAAG,OAAO,CAAC,IAAI,CAAC,CA6DhB"}
|
package/dist/core/hub-session.js
CHANGED
|
@@ -66,14 +66,13 @@ export class HubSession {
|
|
|
66
66
|
this.connection = connection;
|
|
67
67
|
this.url = url;
|
|
68
68
|
this.deps.trackForShutdown(session);
|
|
69
|
-
// Merge the hub's directory (its catch-up arrives as the first session events) and keep refreshing it on every subsequent one. Every trusted remote entry is also surfaced via onDirectory, so the transport can merge it into its own mesh-wide knownDevices (agent-comms#155's remote-directory-merge leg). Filtered to
|
|
69
|
+
// Merge the hub's directory (its catch-up arrives as the first session events) and keep refreshing it on every subsequent one. Every trusted remote entry is also surfaced via onDirectory, so the transport can merge it into its own mesh-wide knownDevices (agent-comms#155's remote-directory-merge leg). Filtered to admitEntries (agent-comms#156, widened by agent-comms#187's principal allowlist per agent-comms#192 and by #266's membership proofs) before either hubPeersKnown tracking or onDirectory sees it: an untrusted device's gossiped presence is not merely withheld from listAgents, it is never even recorded as "known" here, so nothing downstream can act on it via any path this class exposes.
|
|
70
70
|
void (async () => {
|
|
71
71
|
const ownHex = deviceIdToHex(identity.deviceId);
|
|
72
72
|
for await (const event of session.events) {
|
|
73
73
|
if (this.deps.isShuttingDown())
|
|
74
74
|
break;
|
|
75
|
-
const remoteEntries = event.directory.filter((entry) => deviceIdToHex(entry.device) !== ownHex
|
|
76
|
-
this.deps.isTrustedForDirectory(deviceIdToHex(entry.device)));
|
|
75
|
+
const remoteEntries = await this.deps.admitEntries(event.directory.filter((entry) => deviceIdToHex(entry.device) !== ownHex));
|
|
77
76
|
for (const entry of remoteEntries) {
|
|
78
77
|
this.hubPeersKnown.add(deviceIdToHex(entry.device));
|
|
79
78
|
}
|
|
@@ -82,7 +81,10 @@ export class HubSession {
|
|
|
82
81
|
if (event.state.status === "closed")
|
|
83
82
|
break;
|
|
84
83
|
}
|
|
85
|
-
})()
|
|
84
|
+
})().catch((error) => {
|
|
85
|
+
// The merge loop must not die silently: a failure here would stop this side learning of every remote device until the hub is redialled.
|
|
86
|
+
this.deps.events.onError?.(error instanceof Error ? error : new Error(String(error)));
|
|
87
|
+
});
|
|
86
88
|
this.consume(session, deviceIdToHex(identity.deviceId));
|
|
87
89
|
void (async () => {
|
|
88
90
|
await this.watchDisconnect(session);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hub-session.js","sourceRoot":"","sources":["../../src/core/hub-session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,iBAAiB,GAKlB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAc9E,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAElD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,YAAY,EACZ,MAAM,EACN,WAAW,EACX,UAAU,GACX,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"hub-session.js","sourceRoot":"","sources":["../../src/core/hub-session.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,iBAAiB,GAKlB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAc9E,OAAO,EACL,uBAAuB,EACvB,sBAAsB,GACvB,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EAAE,cAAc,EAA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AS,GAAG,IAAI,CAAC,kBAAkB,CACvC,WAAW,EACX,gBAAgB,EAChB,OAAO,CAAC,KAAK,EACb,OAAO,CAAC,KAAK,CACd,CAAC;QACF,IAAI,SAAS,KAAK,SAAS,EAAE,CAAC;YAC5B,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC;YAChC,MAAM,OAAO,CAAC,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YACtD,OAAO;QACT,CAAC;IACH,CAAC;IACD,MAAM,IAAI,CAAC,iBAAiB,CAC1B,OAAO,EACP,MAAM,EACN,UAAU,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,UAAU,EAAE,CAAC,CAAC,CAAC,EAAE,CAChE,CAAC;AACJ,CAAC;AAED,s5CAAs5C;AACt5C,SAAS,sBAAsB,CAAC,OAAoB;IAClD,OAAO,OAAO,CAAC,MAAM,KAAK,YAAY,IAAI,OAAO,CAAC,MAAM,KAAK,cAAc,CAAC;AAC9E,CAAC"}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The proof a device gossips to show that its user principal vouches for it (agent-comms#266): a short-lived group:member token, minted by that principal for that one device, carried as one line of text. A receiver that trusts the principal verifies it against the gossiping device and then trusts the device without it being listed individually, which is what trusting a principal is for.
|
|
3
|
+
*
|
|
4
|
+
* A proof shows that the principal vouches for a device id. It does not show that whoever gossips it is that device: both arrive in the same unauthenticated advert and anyone who has read one can repeat it, so it earns only what GatewayTrust.isReachable grants (see directory-admission.ts). It is also public: it names the principal, so anyone connected to the hub can see which devices belong to which principal.
|
|
5
|
+
*
|
|
6
|
+
* Every bridge of one account shares that account's user identity, so any of them can mint a proof for any device id, which is the same trust the principal is given anyway. Proofs are short-lived rather than revocable, so removeDevice (which revokes an admitDevice grant) does not affect them and a removed device holding the account's key can keep minting its own: they are minted without recording an issued-grant, so a bridge refreshing its own does not rewrite the shared user-identity.json.
|
|
7
|
+
*/
|
|
8
|
+
import type { Clock } from "wire-mesh-core/ports/clock";
|
|
9
|
+
import type { IdentityPort } from "wire-mesh-core/ports/identity";
|
|
10
|
+
import type { RevocationView } from "wire-mesh-core/domain/revocation-view";
|
|
11
|
+
import type { DeviceId } from "wire-mesh-core/generated/protocol";
|
|
12
|
+
/** The longest proof text a receiver will look at. A real proof is a single root-level token, well under half of this; a longer one can only be something else, and the length also bounds how deep a delegation chain could be smuggled in. */
|
|
13
|
+
export declare const MAX_MEMBERSHIP_PROOF_LENGTH = 4096;
|
|
14
|
+
/** How long a minted proof stays valid. Long enough to ride out a missed refresh or a gossip gap, short enough that a device an account stops running stops being trusted soon after. */
|
|
15
|
+
export declare const MEMBERSHIP_PROOF_LIFETIME_MS: number;
|
|
16
|
+
export interface MintMembershipProofOptions {
|
|
17
|
+
/** The user principal vouching for the device. */
|
|
18
|
+
userIdentity: IdentityPort;
|
|
19
|
+
clock: Clock;
|
|
20
|
+
/** The device the proof is for, and the only device it will verify for. */
|
|
21
|
+
deviceId: DeviceId;
|
|
22
|
+
}
|
|
23
|
+
/** A fresh proof that options.userIdentity vouches for options.deviceId, as one line of text. Throws MINT_FAILED if the token cannot be minted. */
|
|
24
|
+
export declare function mintMembershipProof(options: Readonly<MintMembershipProofOptions>): Promise<string>;
|
|
25
|
+
export interface VerifyMembershipProofOptions {
|
|
26
|
+
proof: string;
|
|
27
|
+
/** The device the proof is claimed for: the gossiping device the directory entry names. */
|
|
28
|
+
deviceId: DeviceId;
|
|
29
|
+
/** The principal the proof must have been minted by. */
|
|
30
|
+
principalId: DeviceId;
|
|
31
|
+
/** The verifying node's own identity, clock and revocation view. */
|
|
32
|
+
identity: IdentityPort;
|
|
33
|
+
clock: Clock;
|
|
34
|
+
revocation: RevocationView;
|
|
35
|
+
}
|
|
36
|
+
export type MembershipProofVerdict = {
|
|
37
|
+
ok: true;
|
|
38
|
+
expires: number;
|
|
39
|
+
} | {
|
|
40
|
+
ok: false;
|
|
41
|
+
reason: string;
|
|
42
|
+
};
|
|
43
|
+
/** Whether options.proof shows that options.principalId vouches for options.deviceId right now. Never throws for a bad proof: text that is not a token, a token for another device or principal, an expired or revoked one, all come back as a refusal. */
|
|
44
|
+
export declare function verifyMembershipProof(options: Readonly<VerifyMembershipProofOptions>): Promise<MembershipProofVerdict>;
|
|
45
|
+
//# sourceMappingURL=membership-proof.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership-proof.d.ts","sourceRoot":"","sources":["../../src/core/membership-proof.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,4BAA4B,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,+BAA+B,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,uCAAuC,CAAC;AAC5E,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAUlE,gPAAgP;AAChP,eAAO,MAAM,2BAA2B,OAAO,CAAC;AAEhD,yLAAyL;AACzL,eAAO,MAAM,4BAA4B,QACU,CAAC;AAEpD,MAAM,WAAW,0BAA0B;IACzC,kDAAkD;IAClD,YAAY,EAAE,YAAY,CAAC;IAC3B,KAAK,EAAE,KAAK,CAAC;IACb,2EAA2E;IAC3E,QAAQ,EAAE,QAAQ,CAAC;CACpB;AAED,mJAAmJ;AACnJ,wBAAsB,mBAAmB,CACvC,OAAO,EAAE,QAAQ,CAAC,0BAA0B,CAAC,GAC5C,OAAO,CAAC,MAAM,CAAC,CAejB;AAED,MAAM,WAAW,4BAA4B;IAC3C,KAAK,EAAE,MAAM,CAAC;IACd,2FAA2F;IAC3F,QAAQ,EAAE,QAAQ,CAAC;IACnB,wDAAwD;IACxD,WAAW,EAAE,QAAQ,CAAC;IACtB,oEAAoE;IACpE,QAAQ,EAAE,YAAY,CAAC;IACvB,KAAK,EAAE,KAAK,CAAC;IACb,UAAU,EAAE,cAAc,CAAC;CAC5B;AAED,MAAM,MAAM,sBAAsB,GAChC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAEhE,2PAA2P;AAC3P,wBAAsB,qBAAqB,CACzC,OAAO,EAAE,QAAQ,CAAC,4BAA4B,CAAC,GAC9C,OAAO,CAAC,sBAAsB,CAAC,CAqBjC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The proof a device gossips to show that its user principal vouches for it (agent-comms#266): a short-lived group:member token, minted by that principal for that one device, carried as one line of text. A receiver that trusts the principal verifies it against the gossiping device and then trusts the device without it being listed individually, which is what trusting a principal is for.
|
|
3
|
+
*
|
|
4
|
+
* A proof shows that the principal vouches for a device id. It does not show that whoever gossips it is that device: both arrive in the same unauthenticated advert and anyone who has read one can repeat it, so it earns only what GatewayTrust.isReachable grants (see directory-admission.ts). It is also public: it names the principal, so anyone connected to the hub can see which devices belong to which principal.
|
|
5
|
+
*
|
|
6
|
+
* Every bridge of one account shares that account's user identity, so any of them can mint a proof for any device id, which is the same trust the principal is given anyway. Proofs are short-lived rather than revocable, so removeDevice (which revokes an admitDevice grant) does not affect them and a removed device holding the account's key can keep minting its own: they are minted without recording an issued-grant, so a bridge refreshing its own does not rewrite the shared user-identity.json.
|
|
7
|
+
*/
|
|
8
|
+
import { mintDeviceMembership } from "./device-membership.js";
|
|
9
|
+
import { verifyDeviceMembership } from "./device-membership-verification.js";
|
|
10
|
+
import { randomId } from "./random-id.js";
|
|
11
|
+
import { CommsError } from "./store.js";
|
|
12
|
+
import { decodeTokenText, encodeTokenText } from "./token-text.js";
|
|
13
|
+
const MS_PER_MINUTE = 60_000;
|
|
14
|
+
const MEMBERSHIP_PROOF_LIFETIME_MINUTES = 15;
|
|
15
|
+
/** The longest proof text a receiver will look at. A real proof is a single root-level token, well under half of this; a longer one can only be something else, and the length also bounds how deep a delegation chain could be smuggled in. */
|
|
16
|
+
export const MAX_MEMBERSHIP_PROOF_LENGTH = 4096;
|
|
17
|
+
/** How long a minted proof stays valid. Long enough to ride out a missed refresh or a gossip gap, short enough that a device an account stops running stops being trusted soon after. */
|
|
18
|
+
export const MEMBERSHIP_PROOF_LIFETIME_MS = MEMBERSHIP_PROOF_LIFETIME_MINUTES * MS_PER_MINUTE;
|
|
19
|
+
/** A fresh proof that options.userIdentity vouches for options.deviceId, as one line of text. Throws MINT_FAILED if the token cannot be minted. */
|
|
20
|
+
export async function mintMembershipProof(options) {
|
|
21
|
+
const verdict = await mintDeviceMembership({
|
|
22
|
+
userIdentity: options.userIdentity,
|
|
23
|
+
clock: options.clock,
|
|
24
|
+
tokenId: randomId(),
|
|
25
|
+
deviceId: options.deviceId,
|
|
26
|
+
expires: options.clock.now() + MEMBERSHIP_PROOF_LIFETIME_MS,
|
|
27
|
+
});
|
|
28
|
+
if (!verdict.ok) {
|
|
29
|
+
throw new CommsError(`Failed to mint a membership proof: ${verdict.reason}`, "MINT_FAILED");
|
|
30
|
+
}
|
|
31
|
+
return encodeTokenText(verdict.token);
|
|
32
|
+
}
|
|
33
|
+
/** Whether options.proof shows that options.principalId vouches for options.deviceId right now. Never throws for a bad proof: text that is not a token, a token for another device or principal, an expired or revoked one, all come back as a refusal. */
|
|
34
|
+
export async function verifyMembershipProof(options) {
|
|
35
|
+
if (options.proof.length > MAX_MEMBERSHIP_PROOF_LENGTH) {
|
|
36
|
+
return { ok: false, reason: "too_long" };
|
|
37
|
+
}
|
|
38
|
+
let token;
|
|
39
|
+
try {
|
|
40
|
+
token = decodeTokenText(options.proof);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return { ok: false, reason: "not_a_token" };
|
|
44
|
+
}
|
|
45
|
+
const verdict = await verifyDeviceMembership(token, {
|
|
46
|
+
identity: options.identity,
|
|
47
|
+
clock: options.clock,
|
|
48
|
+
revocation: options.revocation,
|
|
49
|
+
expectedBearer: options.deviceId,
|
|
50
|
+
userDeviceId: options.principalId,
|
|
51
|
+
});
|
|
52
|
+
if (!verdict.ok)
|
|
53
|
+
return { ok: false, reason: verdict.reason };
|
|
54
|
+
// Every proof is minted at the root and cannot be delegated; a chain here would be someone else's construction.
|
|
55
|
+
if (verdict.depth !== 0)
|
|
56
|
+
return { ok: false, reason: "not_root_level" };
|
|
57
|
+
return { ok: true, expires: verdict.claims.expires };
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=membership-proof.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership-proof.js","sourceRoot":"","sources":["../../src/core/membership-proof.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAMH,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAC9D,OAAO,EAAE,sBAAsB,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AACxC,OAAO,EAAE,eAAe,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAEnE,MAAM,aAAa,GAAG,MAAM,CAAC;AAC7B,MAAM,iCAAiC,GAAG,EAAE,CAAC;AAE7C,gPAAgP;AAChP,MAAM,CAAC,MAAM,2BAA2B,GAAG,IAAI,CAAC;AAEhD,yLAAyL;AACzL,MAAM,CAAC,MAAM,4BAA4B,GACvC,iCAAiC,GAAG,aAAa,CAAC;AAUpD,mJAAmJ;AACnJ,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,OAA6C;IAE7C,MAAM,OAAO,GAAG,MAAM,oBAAoB,CAAC;QACzC,YAAY,EAAE,OAAO,CAAC,YAAY;QAClC,KAAK,EAAE,OAAO,CAAC,KAAK;QACpB,OAAO,EAAE,QAAQ,EAAE;QACnB,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B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E,CAAC;IACxE,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A device's own membership proof, kept fresh, and the check for other devices' proofs (agent-comms#266). Split out of MeshStore, which hands it its identity, peer id and error sink.
|
|
3
|
+
*/
|
|
4
|
+
import type { MeshStoreIdentity } from "./mesh-store-shared.js";
|
|
5
|
+
import { type MembershipProofVerdict } from "./membership-proof.js";
|
|
6
|
+
export interface MembershipProofsDeps {
|
|
7
|
+
/** Throws if the store has no identity yet. */
|
|
8
|
+
getIdentity: () => MeshStoreIdentity;
|
|
9
|
+
/** This device's own id (hex). */
|
|
10
|
+
getPeerId: () => string;
|
|
11
|
+
onError: (error: Error) => void;
|
|
12
|
+
}
|
|
13
|
+
export declare class MembershipProofs {
|
|
14
|
+
private readonly deps;
|
|
15
|
+
private proof;
|
|
16
|
+
private minting;
|
|
17
|
+
private timer;
|
|
18
|
+
constructor(deps: Readonly<MembershipProofsDeps>);
|
|
19
|
+
/** The agent/self advert field carrying this device's current proof, empty until the first has been minted. */
|
|
20
|
+
advertField(): {
|
|
21
|
+
membership?: string;
|
|
22
|
+
};
|
|
23
|
+
/** Mints a proof now and again on an interval. A failed mint is reported and retried on the next tick; the previous proof stays until it lapses. */
|
|
24
|
+
start(): void;
|
|
25
|
+
stop(): void;
|
|
26
|
+
/** Whether a gossiped proof shows that principalHex vouches for deviceHex, as this node sees it: its own identity, clock and revocation view. */
|
|
27
|
+
verify(claim: Readonly<{
|
|
28
|
+
proof: string;
|
|
29
|
+
deviceHex: string;
|
|
30
|
+
principalHex: string;
|
|
31
|
+
}>): Promise<MembershipProofVerdict>;
|
|
32
|
+
private refresh;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=membership-proofs.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership-proofs.d.ts","sourceRoot":"","sources":["../../src/core/membership-proofs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAChE,OAAO,EAIL,KAAK,sBAAsB,EAC5B,MAAM,uBAAuB,CAAC;AAO/B,MAAM,WAAW,oBAAoB;IACnC,+CAA+C;IAC/C,WAAW,EAAE,MAAM,iBAAiB,CAAC;IACrC,kCAAkC;IAClC,SAAS,EAAE,MAAM,MAAM,CAAC;IACxB,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAC;CACjC;AAED,qBAAa,gBAAgB;IAKf,OAAO,CAAC,QAAQ,CAAC,IAAI;IAJjC,OAAO,CAAC,KAAK,CAAqB;IAClC,OAAO,CAAC,OAAO,CAAS;IACxB,OAAO,CAAC,KAAK,CAA6C;gBAE7B,IAAI,EAAE,QAAQ,CAAC,oBAAoB,CAAC;IAEjE,+GAA+G;IAC/G,WAAW,IAAI;QAAE,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE;IAItC,oJAAoJ;IACpJ,KAAK,IAAI,IAAI;IASb,IAAI,IAAI,IAAI;IAKZ,iJAAiJ;IAC3I,MAAM,CACV,KAAK,EAAE,QAAQ,CAAC;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,SAAS,EAAE,MAAM,CAAC;QAAC,YAAY,EAAE,MAAM,CAAA;KAAE,CAAC,GAC1E,OAAO,CAAC,sBAAsB,CAAC;IAYlC,OAAO,CAAC,OAAO;CAuBhB"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A device's own membership proof, kept fresh, and the check for other devices' proofs (agent-comms#266). Split out of MeshStore, which hands it its identity, peer id and error sink.
|
|
3
|
+
*/
|
|
4
|
+
import { deviceIdFromHex } from "wire-mesh-core/domain/device-id";
|
|
5
|
+
import { MEMBERSHIP_PROOF_LIFETIME_MS, mintMembershipProof, verifyMembershipProof, } from "./membership-proof.js";
|
|
6
|
+
/** How many times per proof lifetime the proof is re-minted, so a missed tick or two never lets the advertised proof lapse. */
|
|
7
|
+
const REFRESHES_PER_LIFETIME = 3;
|
|
8
|
+
const REFRESH_INTERVAL_MS = MEMBERSHIP_PROOF_LIFETIME_MS / REFRESHES_PER_LIFETIME;
|
|
9
|
+
export class MembershipProofs {
|
|
10
|
+
deps;
|
|
11
|
+
proof;
|
|
12
|
+
minting = false;
|
|
13
|
+
timer;
|
|
14
|
+
constructor(deps) {
|
|
15
|
+
this.deps = deps;
|
|
16
|
+
}
|
|
17
|
+
/** The agent/self advert field carrying this device's current proof, empty until the first has been minted. */
|
|
18
|
+
advertField() {
|
|
19
|
+
return this.proof === undefined ? {} : { membership: this.proof };
|
|
20
|
+
}
|
|
21
|
+
/** Mints a proof now and again on an interval. A failed mint is reported and retried on the next tick; the previous proof stays until it lapses. */
|
|
22
|
+
start() {
|
|
23
|
+
this.stop();
|
|
24
|
+
this.refresh();
|
|
25
|
+
this.timer = setInterval(() => {
|
|
26
|
+
this.refresh();
|
|
27
|
+
}, REFRESH_INTERVAL_MS);
|
|
28
|
+
this.timer.unref();
|
|
29
|
+
}
|
|
30
|
+
stop() {
|
|
31
|
+
clearInterval(this.timer);
|
|
32
|
+
this.timer = undefined;
|
|
33
|
+
}
|
|
34
|
+
/** Whether a gossiped proof shows that principalHex vouches for deviceHex, as this node sees it: its own identity, clock and revocation view. */
|
|
35
|
+
async verify(claim) {
|
|
36
|
+
const { identity, clock, revocation } = this.deps.getIdentity();
|
|
37
|
+
return verifyMembershipProof({
|
|
38
|
+
proof: claim.proof,
|
|
39
|
+
deviceId: deviceIdFromHex(claim.deviceHex),
|
|
40
|
+
principalId: deviceIdFromHex(claim.principalHex),
|
|
41
|
+
identity,
|
|
42
|
+
clock,
|
|
43
|
+
revocation,
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
refresh() {
|
|
47
|
+
if (this.minting)
|
|
48
|
+
return;
|
|
49
|
+
this.minting = true;
|
|
50
|
+
const { userIdentity, clock } = this.deps.getIdentity();
|
|
51
|
+
mintMembershipProof({
|
|
52
|
+
userIdentity,
|
|
53
|
+
clock,
|
|
54
|
+
deviceId: deviceIdFromHex(this.deps.getPeerId()),
|
|
55
|
+
})
|
|
56
|
+
.then((proof) => {
|
|
57
|
+
this.proof = proof;
|
|
58
|
+
}, (error) => {
|
|
59
|
+
this.deps.onError(error instanceof Error ? error : new Error(String(error)));
|
|
60
|
+
})
|
|
61
|
+
.finally(() => {
|
|
62
|
+
this.minting = false;
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=membership-proofs.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"membership-proofs.js","sourceRoot":"","sources":["../../src/core/membership-proofs.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,eAAe,EAAE,MAAM,iCAAiC,CAAC;AAElE,OAAO,EACL,4BAA4B,EAC5B,mBAAmB,EACnB,qBAAqB,GAEtB,MAAM,uBAAuB,CAAC;AAE/B,+HAA+H;AAC/H,MAAM,sBAAsB,GAAG,CAAC,CAAC;AACjC,MAAM,mBAAmB,GACvB,4BAA4B,GAAG,sBAAsB,CAAC;AAUxD,MAAM,OAAO,gBAAgB;IAKE;IAJrB,KAAK,CAAqB;IAC1B,OAAO,GAAG,KAAK,CAAC;IAChB,KAAK,CAA6C;IAE1D,YAA6B,IAAoC;QAApC,SAAI,GAAJ,IAAI,CAAgC;IAAG,CAAC;IAErE,+GAA+G;IAC/G,WAAW;QACT,OAAO,IAAI,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,UAAU,EAAE,IAAI,CAAC,KAAK,EAAE,CAAC;IACpE,CAAC;IAED,oJAAoJ;IACpJ,KAAK;QACH,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,IAAI,CAAC,OAAO,EAAE,CAA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C,IAAI,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAC1D,CAAC;QACJ,CAAC,CACF;aACA,OAAO,CAAC,GAAG,EAAE;YACZ,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC;QACvB,CAAC,CAAC,CAAC;IACP,CAAC;CACF"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
*
|
|
8
8
|
* MeshStore itself is an orchestrator: it owns the shared state (the core agents/rooms/messages/dms/deliveryQueues Maps and a handful of smaller fields) and constructs the collaborators that implement almost every behaviour against direct references into that state -- DeliveryEngine, RoomProtocol, RoomMessaging, RoomLifecycle, AgentRegistry, ConnectionApproval, StaleAgentChecker, and PeerLifecycle. Every public method below that isn't inherently a MeshStore-level concern (transport/identity wiring, init/shutdown lifecycle, the events getter, mesh visibility, listener management) is a thin delegating wrapper to whichever collaborator now owns the real implementation, kept here only because CommsStore/MeshOnlyFeatures and a handful of concrete-only call sites (tests, bridge-mesh.ts, the web server, etc.) reach these names directly on a MeshStore-typed value.
|
|
9
9
|
*/
|
|
10
|
+
import { MembershipProofs } from "./membership-proofs.js";
|
|
10
11
|
import { DiscoveryManager } from "./discovery.js";
|
|
11
12
|
import type { MeshStoreIdentity } from "./mesh-store-shared.js";
|
|
12
13
|
import { GatewayTrust } from "./gateway-trust.js";
|
|
@@ -39,6 +40,8 @@ export declare class MeshStore implements CommsStore {
|
|
|
39
40
|
private readonly hubUrl;
|
|
40
41
|
/** Read by whoever wires this store to a transport, so both halves of a room.join agree on the approval window. */
|
|
41
42
|
readonly roomJoinApprovalTimeoutMs: number;
|
|
43
|
+
/** This device's own membership proof and the check for other devices' proofs (agent-comms#266). */
|
|
44
|
+
readonly membership: MembershipProofs;
|
|
42
45
|
private readonly agents;
|
|
43
46
|
private readonly rooms;
|
|
44
47
|
private readonly messages;
|
|
@@ -99,6 +102,11 @@ export declare class MeshStore implements CommsStore {
|
|
|
99
102
|
private requireTransport;
|
|
100
103
|
/** Sets the identity/clock/slot this store mints and persists room-membership grants against. Must be called before createRoom() or any other identity-using method, mirroring setTransport()'s own contract. */
|
|
101
104
|
setIdentity(identity: MeshStoreIdentity): void;
|
|
105
|
+
/** Every device this side trusts only because a trusted principal vouches for it, with that principal. */
|
|
106
|
+
listVerifiedMembers(): {
|
|
107
|
+
device: string;
|
|
108
|
+
principal: string;
|
|
109
|
+
}[];
|
|
102
110
|
/** The set identity, or throws if setIdentity() hasn't been called yet -- the single place every identity-using method reads through, mirroring requireTransport() above. */
|
|
103
111
|
private requireIdentity;
|
|
104
112
|
init(): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mesh-store.d.ts","sourceRoot":"","sources":["../../src/core/mesh-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;
|
|
1
|
+
{"version":3,"file":"mesh-store.d.ts","sourceRoot":"","sources":["../../src/core/mesh-store.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAKH,OAAO,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAIlD,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAEhE,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAEL,KAAK,6BAA6B,EAClC,KAAK,2BAA2B,EAChC,KAAK,0BAA0B,EAChC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,qBAAqB,CAAC;AAQxD,OAAO,KAAK,EACV,qBAAqB,EAEtB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,mCAAmC,CAAC;AAGlE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AACxD,OAAO,KAAK,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAKhF,OAAO,KAAK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B,oBAAoB,IAAI,gBAAgB,EAAE;IAqB1C,qOAAqO;IACrO,wBAAwB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAK9D,6PAA6P;IAC7P,oBAAoB,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAI1D,+OAA+O;IAC/O,0BAA0B,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAQhE,wWAAwW;IAClW,YAAY,CAChB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC;QAAE,OAAO,EAAE,MAAM,CAAA;KAAE,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IAsB7C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAyBhC"}
|
package/dist/core/mesh-store.js
CHANGED
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
import { deviceIdToHex } from "wire-mesh-core/domain/device-id";
|
|
11
11
|
import * as os from "node:os";
|
|
12
12
|
import { nanoid } from "./nanoid.js";
|
|
13
|
+
import { MembershipProofs } from "./membership-proofs.js";
|
|
13
14
|
import { ROOM_JOIN_APPROVAL_TIMEOUT_MS } from "./request-timeouts.js";
|
|
14
15
|
import { CommsError } from "./store.js";
|
|
15
16
|
import { DiscoveryManager } from "./discovery.js";
|
|
@@ -42,6 +43,14 @@ export class MeshStore {
|
|
|
42
43
|
hubUrl;
|
|
43
44
|
/** Read by whoever wires this store to a transport, so both halves of a room.join agree on the approval window. */
|
|
44
45
|
roomJoinApprovalTimeoutMs;
|
|
46
|
+
/** This device's own membership proof and the check for other devices' proofs (agent-comms#266). */
|
|
47
|
+
membership = new MembershipProofs({
|
|
48
|
+
getIdentity: () => this.requireIdentity(),
|
|
49
|
+
getPeerId: () => this.peerId,
|
|
50
|
+
onError: (error) => {
|
|
51
|
+
this.onError?.(error);
|
|
52
|
+
},
|
|
53
|
+
});
|
|
45
54
|
agents = new Map();
|
|
46
55
|
rooms = new Map();
|
|
47
56
|
messages = new Map();
|
|
@@ -106,6 +115,7 @@ export class MeshStore {
|
|
|
106
115
|
startedAt: agent.startedAt,
|
|
107
116
|
tags: agent.tags,
|
|
108
117
|
subscribedRooms: agent.subscribedRooms,
|
|
118
|
+
...this.membership.advertField(),
|
|
109
119
|
};
|
|
110
120
|
}
|
|
111
121
|
/** Whether the mesh has a live coordinator connection. */
|
|
@@ -278,6 +288,11 @@ export class MeshStore {
|
|
|
278
288
|
/** Sets the identity/clock/slot this store mints and persists room-membership grants against. Must be called before createRoom() or any other identity-using method, mirroring setTransport()'s own contract. */
|
|
279
289
|
setIdentity(identity) {
|
|
280
290
|
this.storeIdentity = identity;
|
|
291
|
+
this.membership.start();
|
|
292
|
+
}
|
|
293
|
+
/** Every device this side trusts only because a trusted principal vouches for it, with that principal. */
|
|
294
|
+
listVerifiedMembers() {
|
|
295
|
+
return this.gatewayTrust.listVerifiedMembers();
|
|
281
296
|
}
|
|
282
297
|
/** The set identity, or throws if setIdentity() hasn't been called yet -- the single place every identity-using method reads through, mirroring requireTransport() above. */
|
|
283
298
|
requireIdentity() {
|
|
@@ -435,9 +450,8 @@ export class MeshStore {
|
|
|
435
450
|
}
|
|
436
451
|
/** This user's own principal id (hex): the identity every device on this account shares, and the thing another user names to admit or trust this whole user rather than one device. Undefined until this store's identity is attached. */
|
|
437
452
|
getUserPrincipalId() {
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
: deviceIdToHex(this.storeIdentity.userIdentity.deviceId);
|
|
453
|
+
const user = this.storeIdentity?.userIdentity;
|
|
454
|
+
return user === undefined ? undefined : deviceIdToHex(user.deviceId);
|
|
441
455
|
}
|
|
442
456
|
/** Admits bearerId into this user's own DM-communication scope (agent-comms#162): mints and persists a dm:send grant, self-signed by this store's own user principal. Returns the minted token for the caller to deliver to bearerId out of band. Deliberately outside the CommsStore interface, like requestDmAccess above. Concrete-only -- reached directly by tests. delegationsRemaining defaults to 0 (non-delegable, the original behaviour); a positive value admits bearerId as a user principal capable of sub-delegating to its own devices (agent-comms#187) -- see RoomLifecycle.admitAgentForDm's own doc comment. */
|
|
443
457
|
async admitAgentForDm(bearerId, delegationsRemaining = 0) {
|
|
@@ -708,6 +722,7 @@ export class MeshStore {
|
|
|
708
722
|
// -----------------------------------------------------------------------
|
|
709
723
|
async shutdown() {
|
|
710
724
|
this.isShutDown = true;
|
|
725
|
+
this.membership.stop();
|
|
711
726
|
// Clear any pending markRead timers so they don't fire after the transport is shut down (which would attempt sends on closed sockets) or keep the event loop alive after process.exit().
|
|
712
727
|
for (const timer of this.pendingMarkReadTimers) {
|
|
713
728
|
clearTimeout(timer);
|