@serfab/cadre-host 0.8.1 → 0.10.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/dist/auth/index.d.ts +2 -0
- package/dist/auth/index.js +1 -0
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/self-label.d.ts +36 -0
- package/dist/auth/self-label.js +57 -0
- package/dist/auth/self-label.js.map +1 -0
- package/dist/auth/trust-circle.d.ts +36 -9
- package/dist/auth/trust-circle.js +40 -20
- package/dist/auth/trust-circle.js.map +1 -1
- package/dist/auth/types.d.ts +2 -2
- package/dist/bin/host.js +291 -54
- package/dist/bin/host.js.map +1 -1
- package/dist/donation/__tests__/fake-orchestrator.d.ts +103 -0
- package/dist/donation/__tests__/fake-orchestrator.js +180 -0
- package/dist/donation/__tests__/fake-orchestrator.js.map +1 -0
- package/dist/donation/donation-service.d.ts +361 -0
- package/dist/donation/donation-service.js +763 -0
- package/dist/donation/donation-service.js.map +1 -0
- package/dist/donation/donation-store.d.ts +49 -0
- package/dist/donation/donation-store.js +148 -0
- package/dist/donation/donation-store.js.map +1 -0
- package/dist/donation/donation-supervisor.d.ts +167 -0
- package/dist/donation/donation-supervisor.js +341 -0
- package/dist/donation/donation-supervisor.js.map +1 -0
- package/dist/donation/grant-service.d.ts +71 -0
- package/dist/donation/grant-service.js +163 -0
- package/dist/donation/grant-service.js.map +1 -0
- package/dist/donation/grant-store.d.ts +38 -0
- package/dist/donation/grant-store.js +135 -0
- package/dist/donation/grant-store.js.map +1 -0
- package/dist/donation/index.d.ts +20 -0
- package/dist/donation/index.js +17 -0
- package/dist/donation/index.js.map +1 -0
- package/dist/donation/types.d.ts +201 -0
- package/dist/donation/types.js +40 -0
- package/dist/donation/types.js.map +1 -0
- package/dist/index.d.ts +9 -5
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/installer/config.d.ts +26 -0
- package/dist/installer/config.js +13 -0
- package/dist/installer/config.js.map +1 -1
- package/dist/installer/index.d.ts +2 -0
- package/dist/installer/index.js +3 -0
- package/dist/installer/index.js.map +1 -1
- package/dist/installer/wizard.d.ts +4 -0
- package/dist/installer/wizard.js +5 -1
- package/dist/installer/wizard.js.map +1 -1
- package/dist/nat/nat-service.d.ts +5 -5
- package/dist/nat/nat-service.js +9 -9
- package/dist/nat/nat-service.js.map +1 -1
- package/dist/nat/types.d.ts +1 -1
- package/dist/orchestrator/host-process-orchestrator.d.ts +144 -32
- package/dist/orchestrator/host-process-orchestrator.js +397 -128
- package/dist/orchestrator/host-process-orchestrator.js.map +1 -1
- package/dist/orchestrator/index.d.ts +3 -3
- package/dist/orchestrator/index.js +1 -1
- package/dist/orchestrator/index.js.map +1 -1
- package/dist/orchestrator/node-identity.d.ts +26 -0
- package/dist/orchestrator/node-identity.js +36 -0
- package/dist/orchestrator/node-identity.js.map +1 -0
- package/dist/orchestrator/port-allocator.d.ts +14 -0
- package/dist/orchestrator/port-allocator.js +45 -0
- package/dist/orchestrator/port-allocator.js.map +1 -1
- package/dist/orchestrator/state-store.d.ts +5 -5
- package/dist/orchestrator/state-store.js +2 -2
- package/dist/orchestrator/state-store.js.map +1 -1
- package/dist/orchestrator/types.d.ts +8 -8
- package/dist/owner/index.d.ts +11 -0
- package/dist/owner/index.js +11 -0
- package/dist/owner/index.js.map +1 -0
- package/dist/owner/owner-node-client.d.ts +110 -0
- package/dist/{authority/authority-node-client.js → owner/owner-node-client.js} +58 -17
- package/dist/owner/owner-node-client.js.map +1 -0
- package/dist/server/error-handler.d.ts +22 -1
- package/dist/server/error-handler.js +64 -1
- package/dist/server/error-handler.js.map +1 -1
- package/dist/server/events/types.d.ts +3 -0
- package/dist/server/index.d.ts +33 -2
- package/dist/server/index.js +43 -16
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/grants-admin.d.ts +17 -0
- package/dist/server/routes/grants-admin.js +32 -0
- package/dist/server/routes/grants-admin.js.map +1 -0
- package/dist/server/routes/grants.d.ts +28 -0
- package/dist/server/routes/grants.js +182 -0
- package/dist/server/routes/grants.js.map +1 -0
- package/dist/server/routes/nodes.d.ts +5 -4
- package/dist/server/routes/nodes.js +19 -18
- package/dist/server/routes/nodes.js.map +1 -1
- package/dist/server/routes/settings.d.ts +6 -1
- package/dist/server/routes/settings.js +5 -2
- package/dist/server/routes/settings.js.map +1 -1
- package/dist/server/routes/status.d.ts +8 -4
- package/dist/server/routes/status.js +9 -4
- package/dist/server/routes/status.js.map +1 -1
- package/dist/server/routes/strands.d.ts +20 -0
- package/dist/server/routes/strands.js +38 -0
- package/dist/server/routes/strands.js.map +1 -0
- package/dist/strands/index.d.ts +7 -0
- package/dist/strands/index.js +6 -0
- package/dist/strands/index.js.map +1 -0
- package/dist/strands/strand-service.d.ts +50 -0
- package/dist/strands/strand-service.js +103 -0
- package/dist/strands/strand-service.js.map +1 -0
- package/dist/strands/types.d.ts +93 -0
- package/dist/strands/types.js +23 -0
- package/dist/strands/types.js.map +1 -0
- package/dist/ui/assets/index-BVoqLjyX.css +1 -0
- package/dist/ui/assets/index-C-iks41M.js +17 -0
- package/dist/ui/assets/index-C-iks41M.js.map +1 -0
- package/dist/ui/index.html +2 -2
- package/dist/update/release-key.d.ts +1 -1
- package/dist/update/release-key.js +8 -6
- package/dist/update/release-key.js.map +1 -1
- package/package.json +5 -5
- package/src/__tests__/build-targets.test.ts +26 -0
- package/src/__tests__/global-setup.ts +51 -0
- package/src/__tests__/{host-authority.smoke.test.ts → host-owner.smoke.test.ts} +7 -7
- package/src/__tests__/orchestrator-env-scrub.test.ts +140 -0
- package/src/__tests__/orchestrator-node-identity.test.ts +204 -0
- package/src/__tests__/{orchestrator-authority.test.ts → orchestrator-owner.test.ts} +33 -33
- package/src/__tests__/orchestrator-pin-keys.test.ts +153 -0
- package/src/__tests__/orchestrator-push.test.ts +10 -10
- package/src/__tests__/orchestrator.test.ts +387 -6
- package/src/auth/__tests__/self-label.test.ts +85 -0
- package/src/auth/__tests__/trust-circle-integration.test.ts +152 -147
- package/src/auth/__tests__/trust-circle.test.ts +55 -11
- package/src/auth/index.ts +2 -0
- package/src/auth/self-label.ts +74 -0
- package/src/auth/trust-circle.ts +54 -22
- package/src/auth/types.ts +2 -2
- package/src/bin/host.ts +1299 -1038
- package/src/donation/__tests__/donation-service.test.ts +1068 -0
- package/src/donation/__tests__/donation-supervisor.test.ts +510 -0
- package/src/donation/__tests__/fake-orchestrator.test.ts +168 -0
- package/src/donation/__tests__/fake-orchestrator.ts +225 -0
- package/src/donation/__tests__/grant-service.test.ts +213 -0
- package/src/donation/__tests__/grant-store.test.ts +113 -0
- package/src/donation/donation-service.ts +962 -0
- package/src/donation/donation-store.ts +171 -0
- package/src/donation/donation-supervisor.ts +388 -0
- package/src/donation/grant-service.ts +200 -0
- package/src/donation/grant-store.ts +152 -0
- package/src/donation/index.ts +64 -0
- package/src/donation/types.ts +243 -0
- package/src/index.ts +51 -5
- package/src/installer/__tests__/config.test.ts +27 -1
- package/src/installer/__tests__/installer.smoke.test.ts +31 -1
- package/src/installer/__tests__/wizard.test.ts +5 -1
- package/src/installer/config.ts +34 -0
- package/src/installer/index.ts +5 -0
- package/src/installer/wizard.ts +12 -1
- package/src/nat/__tests__/nat-service.test.ts +5 -5
- package/src/nat/nat-service.ts +10 -10
- package/src/nat/types.ts +1 -1
- package/src/orchestrator/__tests__/node-identity.test.ts +62 -0
- package/src/orchestrator/host-process-orchestrator.ts +401 -134
- package/src/orchestrator/index.ts +3 -3
- package/src/orchestrator/node-identity.ts +40 -0
- package/src/orchestrator/port-allocator.ts +48 -0
- package/src/orchestrator/state-store.ts +7 -7
- package/src/orchestrator/types.ts +8 -8
- package/src/{authority/__tests__/authority-node-client.test.ts → owner/__tests__/owner-node-client.test.ts} +45 -17
- package/src/owner/index.ts +12 -0
- package/src/{authority/authority-node-client.ts → owner/owner-node-client.ts} +83 -23
- package/src/server/__tests__/error-handler.test.ts +22 -0
- package/src/server/__tests__/grants-admin-route.test.ts +73 -0
- package/src/server/__tests__/grants-route.test.ts +263 -0
- package/src/server/__tests__/nodes-route.test.ts +25 -25
- package/src/server/__tests__/server.smoke.test.ts +75 -0
- package/src/server/__tests__/settings-route.test.ts +17 -0
- package/src/server/__tests__/status-route.test.ts +21 -0
- package/src/server/__tests__/strands-route.test.ts +233 -0
- package/src/server/error-handler.ts +67 -1
- package/src/server/events/types.ts +1 -0
- package/src/server/index.ts +75 -17
- package/src/server/routes/grants-admin.ts +41 -0
- package/src/server/routes/grants.ts +210 -0
- package/src/server/routes/nodes.ts +19 -18
- package/src/server/routes/settings.ts +11 -3
- package/src/server/routes/status.ts +18 -8
- package/src/server/routes/strands.ts +54 -0
- package/src/strands/__tests__/strand-service.test.ts +165 -0
- package/src/strands/index.ts +14 -0
- package/src/strands/strand-service.ts +135 -0
- package/src/strands/types.ts +102 -0
- package/src/update/__tests__/release-key.test.ts +16 -3
- package/src/update/release-key.ts +8 -6
- package/dist/authority/authority-node-client.d.ts +0 -77
- package/dist/authority/authority-node-client.js.map +0 -1
- package/dist/authority/index.d.ts +0 -11
- package/dist/authority/index.js +0 -11
- package/dist/authority/index.js.map +0 -1
- package/dist/ui/assets/index-BlMXQPSw.js +0 -14
- package/dist/ui/assets/index-BlMXQPSw.js.map +0 -1
- package/dist/ui/assets/index-BwU5mJGF.css +0 -1
- package/src/authority/index.ts +0 -12
package/dist/auth/index.d.ts
CHANGED
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
export { TrustCircleService, createTrustCircleHandlers, DEFAULT_INVITE_TTL_MS } from './trust-circle.js';
|
|
5
5
|
export type { TrustCircleServiceOptions, CadreNodeLike } from './trust-circle.js';
|
|
6
6
|
export { TrustCircleStore } from './trust-circle-store.js';
|
|
7
|
+
export { ensureSelfLabel, SELF_LABEL } from './self-label.js';
|
|
8
|
+
export type { EnsureSelfLabelOptions } from './self-label.js';
|
|
7
9
|
export { parseDuration } from './duration.js';
|
|
8
10
|
export { TrustCircleError, } from './types.js';
|
|
9
11
|
export type { TrustCircleMember, PendingInvite, TrustCircleFile, TrustCircleSnapshot, TrustCircleHandlers, TrustCircleErrorCode, } from './types.js';
|
package/dist/auth/index.js
CHANGED
|
@@ -3,6 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export { TrustCircleService, createTrustCircleHandlers, DEFAULT_INVITE_TTL_MS } from './trust-circle.js';
|
|
5
5
|
export { TrustCircleStore } from './trust-circle-store.js';
|
|
6
|
+
export { ensureSelfLabel, SELF_LABEL } from './self-label.js';
|
|
6
7
|
export { parseDuration } from './duration.js';
|
|
7
8
|
export { TrustCircleError, } from './types.js';
|
|
8
9
|
//# sourceMappingURL=index.js.map
|
package/dist/auth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEzG,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,kBAAkB,EAAE,yBAAyB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAC;AAEzG,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE9D,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EACL,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-labelling for the trust-circle listing.
|
|
3
|
+
*
|
|
4
|
+
* `TrustCircleService.list()` shows the cadre's *authorized* membership, which
|
|
5
|
+
* deliberately excludes the node's own self-published row — a node's own
|
|
6
|
+
* address record isn't something an owner key vouched for. To keep the owner's
|
|
7
|
+
* own device visible in the listing, cadre-host records a local
|
|
8
|
+
* `self: true` label for it and `list()` splices that row back in.
|
|
9
|
+
*
|
|
10
|
+
* Writing that label is this module's job. Kept out of `bin/host.ts` so it is
|
|
11
|
+
* unit-testable without standing up the CLI.
|
|
12
|
+
*/
|
|
13
|
+
import type { TrustCircleStore } from './trust-circle-store.js';
|
|
14
|
+
/** Label written for the owner's own device when none exists yet. */
|
|
15
|
+
export declare const SELF_LABEL = "This device";
|
|
16
|
+
export interface EnsureSelfLabelOptions {
|
|
17
|
+
/** Local labels store to write into. */
|
|
18
|
+
store: TrustCircleStore;
|
|
19
|
+
/** Resolves the owner node's peer ID; '' when the node isn't ready yet. */
|
|
20
|
+
getPeerId: () => Promise<string>;
|
|
21
|
+
/** Clock override for tests. */
|
|
22
|
+
now?: () => Date;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Record the owner node's own peer ID as a `self: true` local label.
|
|
26
|
+
*
|
|
27
|
+
* Idempotent: an existing row for that peer ID is left alone, so an admin's
|
|
28
|
+
* rename survives restarts. Stale `self` rows (a different peer ID — the node
|
|
29
|
+
* identity was replaced) are dropped, since `list()` splices every `self` row
|
|
30
|
+
* in unconditionally and would otherwise show a device that no longer exists.
|
|
31
|
+
*
|
|
32
|
+
* Returns the peer ID that is now labelled, or `undefined` when the node
|
|
33
|
+
* wasn't ready. Throws whatever `getPeerId` throws — callers treat a failure
|
|
34
|
+
* as best-effort (the next start heals it).
|
|
35
|
+
*/
|
|
36
|
+
export declare function ensureSelfLabel(opts: EnsureSelfLabelOptions): Promise<string | undefined>;
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Self-labelling for the trust-circle listing.
|
|
3
|
+
*
|
|
4
|
+
* `TrustCircleService.list()` shows the cadre's *authorized* membership, which
|
|
5
|
+
* deliberately excludes the node's own self-published row — a node's own
|
|
6
|
+
* address record isn't something an owner key vouched for. To keep the owner's
|
|
7
|
+
* own device visible in the listing, cadre-host records a local
|
|
8
|
+
* `self: true` label for it and `list()` splices that row back in.
|
|
9
|
+
*
|
|
10
|
+
* Writing that label is this module's job. Kept out of `bin/host.ts` so it is
|
|
11
|
+
* unit-testable without standing up the CLI.
|
|
12
|
+
*/
|
|
13
|
+
import debug from 'debug';
|
|
14
|
+
const log = debug('cadre:host:trust-circle-self');
|
|
15
|
+
/** Label written for the owner's own device when none exists yet. */
|
|
16
|
+
export const SELF_LABEL = 'This device';
|
|
17
|
+
/**
|
|
18
|
+
* Record the owner node's own peer ID as a `self: true` local label.
|
|
19
|
+
*
|
|
20
|
+
* Idempotent: an existing row for that peer ID is left alone, so an admin's
|
|
21
|
+
* rename survives restarts. Stale `self` rows (a different peer ID — the node
|
|
22
|
+
* identity was replaced) are dropped, since `list()` splices every `self` row
|
|
23
|
+
* in unconditionally and would otherwise show a device that no longer exists.
|
|
24
|
+
*
|
|
25
|
+
* Returns the peer ID that is now labelled, or `undefined` when the node
|
|
26
|
+
* wasn't ready. Throws whatever `getPeerId` throws — callers treat a failure
|
|
27
|
+
* as best-effort (the next start heals it).
|
|
28
|
+
*/
|
|
29
|
+
export async function ensureSelfLabel(opts) {
|
|
30
|
+
const { store, getPeerId } = opts;
|
|
31
|
+
const now = opts.now ?? (() => new Date());
|
|
32
|
+
const peerId = await getPeerId();
|
|
33
|
+
if (!peerId) {
|
|
34
|
+
log('owner node not ready — no self label written');
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
37
|
+
for (const member of store.listMembers()) {
|
|
38
|
+
if (member.self && member.peerId !== peerId) {
|
|
39
|
+
log('dropping stale self label for %s (current identity is %s)', member.peerId, peerId);
|
|
40
|
+
store.removeMember(member.peerId);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
const existing = store.getMember(peerId);
|
|
44
|
+
if (!existing) {
|
|
45
|
+
store.addMember({ peerId, label: SELF_LABEL, addedAt: now().toISOString(), self: true });
|
|
46
|
+
log('labelled own device %s as "%s"', peerId, SELF_LABEL);
|
|
47
|
+
}
|
|
48
|
+
else if (!existing.self) {
|
|
49
|
+
// Row predates self-labelling (or was written by a redemption). Stamp the
|
|
50
|
+
// flag, keeping the label: without it `list()` prunes the row, since the
|
|
51
|
+
// authorized set never contains self.
|
|
52
|
+
store.addMember({ ...existing, self: true });
|
|
53
|
+
log('stamped existing label for own device %s as self', peerId);
|
|
54
|
+
}
|
|
55
|
+
return peerId;
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=self-label.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"self-label.js","sourceRoot":"","sources":["../../src/auth/self-label.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,MAAM,GAAG,GAAG,KAAK,CAAC,8BAA8B,CAAC,CAAC;AAElD,qEAAqE;AACrE,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC;AAWxC;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAA4B;IAChE,MAAM,EAAE,KAAK,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC;IAClC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAE3C,MAAM,MAAM,GAAG,MAAM,SAAS,EAAE,CAAC;IACjC,IAAI,CAAC,MAAM,EAAE,CAAC;QACZ,GAAG,CAAC,8CAA8C,CAAC,CAAC;QACpD,OAAO,SAAS,CAAC;IACnB,CAAC;IAED,KAAK,MAAM,MAAM,IAAI,KAAK,CAAC,WAAW,EAAE,EAAE,CAAC;QACzC,IAAI,MAAM,CAAC,IAAI,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM,EAAE,CAAC;YAC5C,GAAG,CAAC,2DAA2D,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;YACxF,KAAK,CAAC,YAAY,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACpC,CAAC;IACH,CAAC;IAED,MAAM,QAAQ,GAAG,KAAK,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACzC,IAAI,CAAC,QAAQ,EAAE,CAAC;QACd,KAAK,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,KAAK,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,EAAE,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACzF,GAAG,CAAC,gCAAgC,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC;IAC5D,CAAC;SAAM,IAAI,CAAC,QAAQ,CAAC,IAAI,EAAE,CAAC;QAC1B,0EAA0E;QAC1E,yEAAyE;QACzE,sCAAsC;QACtC,KAAK,CAAC,SAAS,CAAC,EAAE,GAAG,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QAC7C,GAAG,CAAC,kDAAkD,EAAE,MAAM,CAAC,CAAC;IAClE,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -28,22 +28,37 @@ export interface CadreNodeLike {
|
|
|
28
28
|
}, issuedInvite?: CadreInvite): Promise<void>;
|
|
29
29
|
removePeer(peerId: string): Promise<void>;
|
|
30
30
|
encodeInvite(invite: CadreInvite): string;
|
|
31
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Enumerate the cadre's *addressable* peers (over the admin channel) —
|
|
33
|
+
* anyone with an address record, including devices no owner vouched for.
|
|
34
|
+
* Used only for {@link removeMember}, where "the row exists" is the point.
|
|
35
|
+
*/
|
|
32
36
|
listMembers(): Promise<Array<{
|
|
33
37
|
peerId: string;
|
|
34
38
|
multiaddr: string | null;
|
|
35
39
|
}>>;
|
|
36
|
-
/** Probe whether a peer is
|
|
40
|
+
/** Probe whether a peer is *addressable* (over the admin channel). See {@link listMembers}. */
|
|
37
41
|
isMember(peerId: string): Promise<boolean>;
|
|
42
|
+
/**
|
|
43
|
+
* Enumerate the cadre's *authorized* membership (over the admin channel) —
|
|
44
|
+
* devices an owner key vouched for. Excludes the node's own self-published
|
|
45
|
+
* row. This is the real membership test the trust-circle listing shows.
|
|
46
|
+
*/
|
|
47
|
+
listAuthorizedMembers(): Promise<Array<{
|
|
48
|
+
peerId: string;
|
|
49
|
+
multiaddr: string | null;
|
|
50
|
+
}>>;
|
|
51
|
+
/** Probe whether a peer is *authorized*. See {@link listAuthorizedMembers}. */
|
|
52
|
+
isAuthorizedMember(peerId: string): Promise<boolean>;
|
|
38
53
|
}
|
|
39
54
|
/**
|
|
40
55
|
* TrustCircleService — orchestrates invite issuance, redemption, and
|
|
41
56
|
* membership management.
|
|
42
57
|
*
|
|
43
58
|
* Membership is canonical in the cadre control DB (`CadrePeer` table),
|
|
44
|
-
* reached over the
|
|
59
|
+
* reached over the owner node's admin channel; labels and pending tokens
|
|
45
60
|
* live in the host-local `TrustCircleStore`. When the node is unreachable,
|
|
46
|
-
*
|
|
61
|
+
* owner operations surface `node_unavailable` (→ 503) and `list()`
|
|
47
62
|
* degrades to the local labels file.
|
|
48
63
|
*/
|
|
49
64
|
export declare class TrustCircleService {
|
|
@@ -60,7 +75,7 @@ export declare class TrustCircleService {
|
|
|
60
75
|
constructor(opts: TrustCircleServiceOptions);
|
|
61
76
|
/**
|
|
62
77
|
* Issue a new invite. Generates a token, persists a pending row, and
|
|
63
|
-
* delegates to cadre-core to embed the host's
|
|
78
|
+
* delegates to cadre-core to embed the host's owner addresses.
|
|
64
79
|
*/
|
|
65
80
|
issueInvite(opts: {
|
|
66
81
|
label: string;
|
|
@@ -85,7 +100,7 @@ export declare class TrustCircleService {
|
|
|
85
100
|
*
|
|
86
101
|
* Crash-safety tradeoff: if the host crashes between `acceptPhone` success
|
|
87
102
|
* and the durable `removePending`, a retry will dial in fine but the
|
|
88
|
-
*
|
|
103
|
+
* owner node's `acceptPhone` will reject the second `CadrePeer` insert
|
|
89
104
|
* with a PK constraint error (cadre-core does not upsert). That surfaces to
|
|
90
105
|
* the redeemer as a non-`node_unavailable` failure; the admin can revoke
|
|
91
106
|
* the lingering pending row. This is a narrower window than the prior
|
|
@@ -103,15 +118,27 @@ export declare class TrustCircleService {
|
|
|
103
118
|
/**
|
|
104
119
|
* Remove an authorised member. Deletes the CadrePeer row and the local
|
|
105
120
|
* label. Throws not_found when the peer is in neither place.
|
|
121
|
+
*
|
|
122
|
+
* NOTE: no special case for the host's own peer ID — the local UI hides the
|
|
123
|
+
* Remove button on the `self` row, but `DELETE /auth/members/<ownPeerId>`
|
|
124
|
+
* (or `cadre-host trust revoke <ownPeerId>`) will delete the node's own
|
|
125
|
+
* `CadrePeer` row. cadre-core re-registers self on node start, so a restart
|
|
126
|
+
* heals it. If that stops being true, or the removal path grows a
|
|
127
|
+
* non-loopback caller, guard `self` rows here.
|
|
106
128
|
*/
|
|
107
129
|
removeMember(peerId: string): Promise<void>;
|
|
108
130
|
/** Whether the peer is present in the cadre's CadrePeer table. */
|
|
109
131
|
isMember(peerId: string): Promise<boolean>;
|
|
110
132
|
/**
|
|
111
|
-
* UI snapshot. Joins the
|
|
133
|
+
* UI snapshot. Joins the *authorized* membership (fetched over the admin
|
|
112
134
|
* channel) with local labels; prunes any orphan labels (peer is no longer
|
|
113
|
-
* authorised).
|
|
114
|
-
*
|
|
135
|
+
* authorised). Addressable-but-unauthorized peers — devices that merely
|
|
136
|
+
* published an address record without an owner voucher — are deliberately
|
|
137
|
+
* excluded; this is the listing an operator uses to decide who belongs.
|
|
138
|
+
* The node's own self-published row is spliced back in from the local
|
|
139
|
+
* label, since the authorized set excludes self by design. When the owner
|
|
140
|
+
* node is unreachable, degrades to the local labels file so listing keeps
|
|
141
|
+
* working while the node is down.
|
|
115
142
|
*/
|
|
116
143
|
list(): Promise<TrustCircleSnapshot>;
|
|
117
144
|
/**
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { randomBytes } from 'node:crypto';
|
|
2
2
|
import debug from 'debug';
|
|
3
|
-
import {
|
|
3
|
+
import { OwnerNodeUnavailableError } from '../owner/owner-node-client.js';
|
|
4
4
|
import { TrustCircleError } from './types.js';
|
|
5
5
|
const log = debug('cadre:host:trust-circle');
|
|
6
6
|
/** Default invite lifetime: 24 hours. */
|
|
@@ -12,9 +12,9 @@ const TOKEN_BYTES = 32;
|
|
|
12
12
|
* membership management.
|
|
13
13
|
*
|
|
14
14
|
* Membership is canonical in the cadre control DB (`CadrePeer` table),
|
|
15
|
-
* reached over the
|
|
15
|
+
* reached over the owner node's admin channel; labels and pending tokens
|
|
16
16
|
* live in the host-local `TrustCircleStore`. When the node is unreachable,
|
|
17
|
-
*
|
|
17
|
+
* owner operations surface `node_unavailable` (→ 503) and `list()`
|
|
18
18
|
* degrades to the local labels file.
|
|
19
19
|
*/
|
|
20
20
|
export class TrustCircleService {
|
|
@@ -32,7 +32,7 @@ export class TrustCircleService {
|
|
|
32
32
|
}
|
|
33
33
|
/**
|
|
34
34
|
* Issue a new invite. Generates a token, persists a pending row, and
|
|
35
|
-
* delegates to cadre-core to embed the host's
|
|
35
|
+
* delegates to cadre-core to embed the host's owner addresses.
|
|
36
36
|
*/
|
|
37
37
|
async issueInvite(opts) {
|
|
38
38
|
const label = normaliseLabel(opts.label);
|
|
@@ -70,7 +70,7 @@ export class TrustCircleService {
|
|
|
70
70
|
*
|
|
71
71
|
* Crash-safety tradeoff: if the host crashes between `acceptPhone` success
|
|
72
72
|
* and the durable `removePending`, a retry will dial in fine but the
|
|
73
|
-
*
|
|
73
|
+
* owner node's `acceptPhone` will reject the second `CadrePeer` insert
|
|
74
74
|
* with a PK constraint error (cadre-core does not upsert). That surfaces to
|
|
75
75
|
* the redeemer as a non-`node_unavailable` failure; the admin can revoke
|
|
76
76
|
* the lingering pending row. This is a narrower window than the prior
|
|
@@ -106,7 +106,7 @@ export class TrustCircleService {
|
|
|
106
106
|
// matches by construction) and re-checks expiration.
|
|
107
107
|
const reconstructed = {
|
|
108
108
|
partyId: '',
|
|
109
|
-
|
|
109
|
+
ownerAddrs: [],
|
|
110
110
|
token: pending.token,
|
|
111
111
|
createdAt: new Date(pending.createdAt).getTime(),
|
|
112
112
|
...(pending.expiresAt ? { expiresAt: new Date(pending.expiresAt).getTime() } : {}),
|
|
@@ -145,6 +145,13 @@ export class TrustCircleService {
|
|
|
145
145
|
/**
|
|
146
146
|
* Remove an authorised member. Deletes the CadrePeer row and the local
|
|
147
147
|
* label. Throws not_found when the peer is in neither place.
|
|
148
|
+
*
|
|
149
|
+
* NOTE: no special case for the host's own peer ID — the local UI hides the
|
|
150
|
+
* Remove button on the `self` row, but `DELETE /auth/members/<ownPeerId>`
|
|
151
|
+
* (or `cadre-host trust revoke <ownPeerId>`) will delete the node's own
|
|
152
|
+
* `CadrePeer` row. cadre-core re-registers self on node start, so a restart
|
|
153
|
+
* heals it. If that stops being true, or the removal path grows a
|
|
154
|
+
* non-loopback caller, guard `self` rows here.
|
|
148
155
|
*/
|
|
149
156
|
async removeMember(peerId) {
|
|
150
157
|
const inLocal = this.store.getMember(peerId);
|
|
@@ -170,10 +177,15 @@ export class TrustCircleService {
|
|
|
170
177
|
}
|
|
171
178
|
}
|
|
172
179
|
/**
|
|
173
|
-
* UI snapshot. Joins the
|
|
180
|
+
* UI snapshot. Joins the *authorized* membership (fetched over the admin
|
|
174
181
|
* channel) with local labels; prunes any orphan labels (peer is no longer
|
|
175
|
-
* authorised).
|
|
176
|
-
*
|
|
182
|
+
* authorised). Addressable-but-unauthorized peers — devices that merely
|
|
183
|
+
* published an address record without an owner voucher — are deliberately
|
|
184
|
+
* excluded; this is the listing an operator uses to decide who belongs.
|
|
185
|
+
* The node's own self-published row is spliced back in from the local
|
|
186
|
+
* label, since the authorized set excludes self by design. When the owner
|
|
187
|
+
* node is unreachable, degrades to the local labels file so listing keeps
|
|
188
|
+
* working while the node is down.
|
|
177
189
|
*/
|
|
178
190
|
async list() {
|
|
179
191
|
const labels = new Map();
|
|
@@ -184,18 +196,18 @@ export class TrustCircleService {
|
|
|
184
196
|
// Consult the control DB over the admin channel. A node-unavailable error
|
|
185
197
|
// is non-fatal — fall back to the local labels rather than 503-ing a
|
|
186
198
|
// read-only listing.
|
|
187
|
-
let
|
|
199
|
+
let authorizedMembers;
|
|
188
200
|
try {
|
|
189
|
-
|
|
201
|
+
authorizedMembers = await this.cadreNode.listAuthorizedMembers();
|
|
190
202
|
}
|
|
191
203
|
catch (err) {
|
|
192
|
-
if (!(err instanceof
|
|
204
|
+
if (!(err instanceof OwnerNodeUnavailableError))
|
|
193
205
|
throw err;
|
|
194
|
-
|
|
206
|
+
authorizedMembers = null;
|
|
195
207
|
}
|
|
196
|
-
if (
|
|
208
|
+
if (authorizedMembers) {
|
|
197
209
|
const seenPeerIds = new Set();
|
|
198
|
-
for (const { peerId } of
|
|
210
|
+
for (const { peerId } of authorizedMembers) {
|
|
199
211
|
seenPeerIds.add(peerId);
|
|
200
212
|
const label = labels.get(peerId);
|
|
201
213
|
members.push({
|
|
@@ -205,9 +217,17 @@ export class TrustCircleService {
|
|
|
205
217
|
...(label?.self ? { self: true } : {}),
|
|
206
218
|
});
|
|
207
219
|
}
|
|
208
|
-
//
|
|
209
|
-
//
|
|
210
|
-
|
|
220
|
+
// The authorized set excludes the node's own self-published row —
|
|
221
|
+
// splice it back in from the local label rather than dropping it.
|
|
222
|
+
for (const [peerId, row] of labels) {
|
|
223
|
+
if (row.self && !seenPeerIds.has(peerId)) {
|
|
224
|
+
seenPeerIds.add(peerId);
|
|
225
|
+
members.push({ peerId, ...row });
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
// Prune labels for peers that are neither authorized nor self. Only
|
|
229
|
+
// when we successfully consulted the node — otherwise a transient
|
|
230
|
+
// outage would wipe labels.
|
|
211
231
|
for (const peerId of labels.keys()) {
|
|
212
232
|
if (!seenPeerIds.has(peerId)) {
|
|
213
233
|
this.store.removeMember(peerId);
|
|
@@ -232,8 +252,8 @@ export class TrustCircleService {
|
|
|
232
252
|
* `never` so callers can `.catch(err => this.toDomainError(err))`.
|
|
233
253
|
*/
|
|
234
254
|
toDomainError(err) {
|
|
235
|
-
if (err instanceof
|
|
236
|
-
throw new TrustCircleError('node_unavailable', `
|
|
255
|
+
if (err instanceof OwnerNodeUnavailableError) {
|
|
256
|
+
throw new TrustCircleError('node_unavailable', `Owner node unavailable: ${err.message}`);
|
|
237
257
|
}
|
|
238
258
|
throw err instanceof Error ? err : new Error(String(err));
|
|
239
259
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"trust-circle.js","sourceRoot":"","sources":["../../src/auth/trust-circle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"trust-circle.js","sourceRoot":"","sources":["../../src/auth/trust-circle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC1C,OAAO,KAAK,MAAM,OAAO,CAAC;AAI1B,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAS1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAE9C,MAAM,GAAG,GAAG,KAAK,CAAC,yBAAyB,CAAC,CAAC;AAE7C,yCAAyC;AACzC,MAAM,CAAC,MAAM,qBAAqB,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAEzD,wDAAwD;AACxD,MAAM,WAAW,GAAG,EAAE,CAAC;AAwCvB;;;;;;;;;GASG;AACH,MAAM,OAAO,kBAAkB;IAY7B,YAAY,IAA+B;QAR3C;;;;;WAKG;QACc,wBAAmB,GAAG,IAAI,GAAG,EAAU,CAAC;QA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,KAAK,CAAC,YAAY,CAAC,KAAK;YACtB,MAAM,OAAO,CAAC,aAAa,CAAC,KAAK,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,CAAC,YAAY,CAAC,MAAM;YACvB,MAAM,OAAO,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACrC,CAAC;QACD,KAAK,CAAC,eAAe;YACnB,OAAO,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;QAC9B,CAAC;KACF,CAAC;AACJ,CAAC;AAED,SAAS,aAAa;IACpB,mEAAmE;IACnE,OAAO,WAAW,CAAC,WAAW,CAAC,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;AACxD,CAAC;AAED,SAAS,cAAc,CAAC,KAAc;IACpC,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,IAAI,gBAAgB,CAAC,eAAe,EAAE,wBAAwB,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,OAAO,GAAG,KAAK,CAAC,IAAI,EAAE,CAAC;IAC7B,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACzB,MAAM,IAAI,gBAAgB,CAAC,eAAe,EAAE,yBAAyB,CAAC,CAAC;IACzE,CAAC;IACD,IAAI,OAAO,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;QACzB,MAAM,IAAI,gBAAgB,CAAC,eAAe,EAAE,uCAAuC,CAAC,CAAC;IACvF,CAAC;IACD,OAAO,OAAO,CAAC;AACjB,CAAC"}
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -57,7 +57,7 @@ export interface TrustCircleSnapshot {
|
|
|
57
57
|
* - `not_found` → 404 (unknown token / unknown peer)
|
|
58
58
|
* - `expired` → 410 (invite past expiresAt)
|
|
59
59
|
* - `already_redeemed` → 409 (token was used and is gone)
|
|
60
|
-
* - `node_unavailable` → 503 (
|
|
60
|
+
* - `node_unavailable` → 503 (owner node admin channel down/not ready)
|
|
61
61
|
* - default → 500
|
|
62
62
|
*/
|
|
63
63
|
export interface TrustCircleHandlers {
|
|
@@ -75,7 +75,7 @@ export interface TrustCircleHandlers {
|
|
|
75
75
|
}
|
|
76
76
|
/** Error codes thrown by TrustCircleService. */
|
|
77
77
|
export type TrustCircleErrorCode = 'not_found' | 'expired' | 'already_redeemed' | 'invalid_label' | 'invalid_token' | 'storage_error'
|
|
78
|
-
/** The
|
|
78
|
+
/** The owner node's admin channel is unreachable / not ready. */
|
|
79
79
|
| 'node_unavailable';
|
|
80
80
|
/** Typed error carrying a stable `code` for HTTP mapping. */
|
|
81
81
|
export declare class TrustCircleError extends Error {
|