@serfab/cadre-host 0.7.1 → 0.8.1
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/README.md +296 -101
- package/dist/auth/trust-circle.d.ts +44 -6
- package/dist/auth/trust-circle.js +115 -58
- package/dist/auth/trust-circle.js.map +1 -1
- package/dist/auth/types.d.ts +4 -1
- package/dist/auth/types.js.map +1 -1
- package/dist/authority/authority-node-client.d.ts +77 -0
- package/dist/authority/authority-node-client.js +143 -0
- package/dist/authority/authority-node-client.js.map +1 -0
- package/dist/authority/index.d.ts +11 -0
- package/dist/authority/index.js +11 -0
- package/dist/authority/index.js.map +1 -0
- package/dist/bin/host.js +210 -97
- package/dist/bin/host.js.map +1 -1
- package/dist/index.d.ts +10 -6
- package/dist/index.js +6 -3
- package/dist/index.js.map +1 -1
- package/dist/installer/browser.js +16 -17
- package/dist/installer/browser.js.map +1 -1
- package/dist/installer/config.d.ts +25 -0
- package/dist/installer/config.js +1 -1
- package/dist/installer/config.js.map +1 -1
- package/dist/installer/index.d.ts +5 -2
- package/dist/installer/index.js +14 -10
- package/dist/installer/index.js.map +1 -1
- package/dist/installer/service-host/launchd.js +1 -1
- package/dist/installer/service-host/launchd.js.map +1 -1
- package/dist/installer/service-host/systemd.js +1 -1
- package/dist/installer/service-host/systemd.js.map +1 -1
- package/dist/nat/index.d.ts +1 -1
- package/dist/nat/nat-service.d.ts +45 -3
- package/dist/nat/nat-service.js +116 -3
- package/dist/nat/nat-service.js.map +1 -1
- package/dist/nat/secrets/index.d.ts +7 -0
- package/dist/nat/secrets/index.js +28 -2
- package/dist/nat/secrets/index.js.map +1 -1
- package/dist/nat/types.d.ts +3 -1
- package/dist/nat/types.js.map +1 -1
- package/dist/orchestrator/host-process-orchestrator.d.ts +60 -1
- package/dist/orchestrator/host-process-orchestrator.js +246 -39
- package/dist/orchestrator/host-process-orchestrator.js.map +1 -1
- package/dist/orchestrator/index.d.ts +3 -2
- package/dist/orchestrator/index.js +1 -1
- package/dist/orchestrator/index.js.map +1 -1
- package/dist/orchestrator/state-store.d.ts +6 -5
- package/dist/orchestrator/state-store.js +10 -2
- package/dist/orchestrator/state-store.js.map +1 -1
- package/dist/orchestrator/types.d.ts +45 -10
- package/dist/orchestrator/types.js.map +1 -1
- package/dist/push/index.d.ts +67 -0
- package/dist/push/index.js +101 -0
- package/dist/push/index.js.map +1 -0
- package/dist/server/error-handler.d.ts +2 -0
- package/dist/server/error-handler.js +4 -0
- package/dist/server/error-handler.js.map +1 -1
- package/dist/server/routes/nodes.d.ts +4 -3
- package/dist/server/routes/nodes.js +38 -24
- package/dist/server/routes/nodes.js.map +1 -1
- package/dist/server/static.d.ts +12 -0
- package/dist/server/static.js +24 -7
- package/dist/server/static.js.map +1 -1
- package/dist/ui/assets/index-BlMXQPSw.js +14 -0
- package/dist/ui/assets/{index-C9uChk2P.js.map → index-BlMXQPSw.js.map} +1 -1
- package/dist/ui/index.html +1 -1
- package/dist/update/apply.d.ts +23 -1
- package/dist/update/apply.js +46 -4
- package/dist/update/apply.js.map +1 -1
- package/dist/update/index.d.ts +14 -3
- package/dist/update/index.js +35 -2
- package/dist/update/index.js.map +1 -1
- package/dist/update/manifest.d.ts +28 -9
- package/dist/update/manifest.js +56 -29
- package/dist/update/manifest.js.map +1 -1
- package/dist/update/release-key.d.ts +18 -7
- package/dist/update/release-key.js +28 -15
- package/dist/update/release-key.js.map +1 -1
- package/dist/update/sign.d.ts +46 -0
- package/dist/update/sign.js +53 -0
- package/dist/update/sign.js.map +1 -0
- package/package.json +9 -4
- package/service/README.md +95 -86
- package/src/__tests__/cli-invite.smoke.test.ts +6 -1
- package/src/__tests__/cli-nat.smoke.test.ts +6 -1
- package/src/__tests__/cli.smoke.test.ts +6 -1
- package/src/__tests__/host-authority.smoke.test.ts +123 -0
- package/src/__tests__/orchestrator-authority.test.ts +198 -0
- package/src/__tests__/orchestrator-push.test.ts +145 -0
- package/src/auth/__tests__/trust-circle-integration.test.ts +40 -21
- package/src/auth/__tests__/trust-circle.test.ts +90 -23
- package/src/auth/trust-circle.ts +363 -304
- package/src/auth/types.ts +4 -1
- package/src/authority/__tests__/authority-node-client.test.ts +166 -0
- package/src/authority/authority-node-client.ts +199 -0
- package/src/authority/index.ts +12 -0
- package/src/bin/host.ts +1038 -905
- package/src/index.ts +34 -3
- package/src/installer/__tests__/installer.smoke.test.ts +64 -0
- package/src/installer/browser.ts +40 -42
- package/src/installer/config.ts +27 -1
- package/src/installer/index.ts +18 -12
- package/src/installer/service-host/launchd.ts +1 -1
- package/src/installer/service-host/systemd.ts +1 -1
- package/src/nat/__tests__/ddns-updater.test.ts +1 -1
- package/src/nat/__tests__/nat-service.test.ts +192 -0
- package/src/nat/__tests__/port-mapper.test.ts +1 -1
- package/src/nat/__tests__/secrets.test.ts +23 -1
- package/src/nat/index.ts +1 -1
- package/src/nat/nat-service.ts +131 -5
- package/src/nat/secrets/index.ts +32 -2
- package/src/nat/types.ts +3 -1
- package/src/orchestrator/host-process-orchestrator.ts +294 -54
- package/src/orchestrator/index.ts +9 -2
- package/src/orchestrator/state-store.ts +21 -3
- package/src/orchestrator/types.ts +48 -2
- package/src/push/__tests__/push.test.ts +90 -0
- package/src/push/index.ts +146 -0
- package/src/server/__tests__/error-handler.test.ts +4 -4
- package/src/server/__tests__/nodes-route.test.ts +90 -10
- package/src/server/__tests__/publishers.test.ts +1 -1
- package/src/server/__tests__/static.test.ts +145 -0
- package/src/server/__tests__/status-route.test.ts +2 -2
- package/src/server/error-handler.ts +4 -0
- package/src/server/routes/nodes.ts +48 -26
- package/src/server/static.ts +24 -8
- package/src/update/__tests__/apply.test.ts +58 -1
- package/src/update/__tests__/manifest.test.ts +41 -6
- package/src/update/__tests__/release-key.test.ts +29 -0
- package/src/update/__tests__/sign.test.ts +78 -0
- package/src/update/__tests__/update-service.integration.test.ts +44 -9
- package/src/update/apply.ts +46 -4
- package/src/update/index.ts +41 -3
- package/src/update/manifest.ts +214 -172
- package/src/update/release-key.ts +30 -16
- package/src/update/sign.ts +74 -0
- package/dist/ui/assets/index-C9uChk2P.js +0 -14
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
* Public + internal types for the HostProcessOrchestrator.
|
|
3
3
|
*/
|
|
4
4
|
import type { ChildProcess } from 'node:child_process';
|
|
5
|
+
import type { PushCredentials } from '@serfab/cadre-core';
|
|
5
6
|
/** User-facing configuration for `HostProcessOrchestrator`. */
|
|
6
7
|
export interface HostProcessConfig {
|
|
7
8
|
/** Root directory under which per-container workdirs live. */
|
|
@@ -28,6 +29,29 @@ export interface HostProcessConfig {
|
|
|
28
29
|
spawn?: {
|
|
29
30
|
entrypoint?: string;
|
|
30
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Resolver for the platform push credentials (FCM/APNs) to inject into a
|
|
34
|
+
* spawned strand-participating node's `cadre.json` (`config.push`). Called
|
|
35
|
+
* fresh on EVERY spawn/re-spawn so the secret store stays the source of truth
|
|
36
|
+
* and no raw private key is ever persisted in `state.json`. Returns `undefined`
|
|
37
|
+
* when no push credentials are configured (the default — push is opt-in). The
|
|
38
|
+
* resolver itself is responsible for rejecting a partial credential set.
|
|
39
|
+
*/
|
|
40
|
+
pushResolver?: PushCredentialsResolver;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Resolves the push credentials to inject into a node being spawned. Re-invoked
|
|
44
|
+
* per spawn so a restart re-reads the secret store rather than replaying stale
|
|
45
|
+
* (or persisted) material. See {@link HostProcessConfig.pushResolver}.
|
|
46
|
+
*/
|
|
47
|
+
export type PushCredentialsResolver = () => Promise<PushCredentials | undefined>;
|
|
48
|
+
/** Per-child allocated ports. `admin` carries the loopback admin channel (6.6). */
|
|
49
|
+
export interface NodePorts {
|
|
50
|
+
health: number;
|
|
51
|
+
metrics: number;
|
|
52
|
+
p2p: number;
|
|
53
|
+
/** Loopback admin-channel port. Bound only by the authority node. */
|
|
54
|
+
admin: number;
|
|
31
55
|
}
|
|
32
56
|
/** In-memory record per managed child. */
|
|
33
57
|
export interface Handle {
|
|
@@ -36,14 +60,12 @@ export interface Handle {
|
|
|
36
60
|
pid: number;
|
|
37
61
|
startupToken: string;
|
|
38
62
|
workdir: string;
|
|
39
|
-
ports:
|
|
40
|
-
health: number;
|
|
41
|
-
metrics: number;
|
|
42
|
-
p2p: number;
|
|
43
|
-
};
|
|
63
|
+
ports: NodePorts;
|
|
44
64
|
spawnedAt: string;
|
|
45
65
|
partyId: string;
|
|
46
66
|
profile: 'storage' | 'transaction';
|
|
67
|
+
/** True for the admin's authority node (binds the admin channel). */
|
|
68
|
+
authority?: boolean;
|
|
47
69
|
/** Live ChildProcess reference; absent after re-attach via init(). */
|
|
48
70
|
child?: ChildProcess;
|
|
49
71
|
/** Marked false when init() finds the PID dead or token mismatched. */
|
|
@@ -61,11 +83,24 @@ export interface ManagedNodeInfo {
|
|
|
61
83
|
status: 'running' | 'stopped';
|
|
62
84
|
spawnedAt: string;
|
|
63
85
|
workdir: string;
|
|
64
|
-
ports:
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
86
|
+
ports: NodePorts;
|
|
87
|
+
/** True for the admin's authority node. */
|
|
88
|
+
authority?: boolean;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Persisted spawn parameters for the admin's authority node. Stored alongside
|
|
92
|
+
* the handles so an orchestrator restart can re-spawn the authority node from
|
|
93
|
+
* `/api/nodes/:id/{start,restart}` without the caller re-supplying them.
|
|
94
|
+
*/
|
|
95
|
+
export interface AuthoritySpawnConfig {
|
|
96
|
+
/** Absolute path to the host's libp2p protobuf identity (`identity.key`). */
|
|
97
|
+
identityPath: string;
|
|
98
|
+
/** Control-network partyId (the host's installId). */
|
|
99
|
+
partyId: string;
|
|
100
|
+
/** External libp2p port — mapped to the child's listen address. */
|
|
101
|
+
libp2pPort: number;
|
|
102
|
+
/** Node profile. Defaults to `storage` (the household node holds strands). */
|
|
103
|
+
profile?: 'storage' | 'transaction';
|
|
69
104
|
}
|
|
70
105
|
/**
|
|
71
106
|
* Listener invoked when a managed node's lifecycle state changes
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/orchestrator/types.ts"],"names":[],"mappings":"AAAA;;GAEG;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/orchestrator/types.ts"],"names":[],"mappings":"AAAA;;GAEG;AA8GH,MAAM,eAAe,GAAG,GAAG,CAAC;AAE5B;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW,EAAE,KAAa;IACvD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;QACvC,MAAM,IAAI,KAAK,CAAC,8BAA8B,GAAG,EAAE,CAAC,CAAC;IACvD,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,KAAK,CAAC,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC;QAC1D,MAAM,IAAI,KAAK,CAAC,gCAAgC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,GAAG,GAAG,GAAG,eAAe,GAAG,KAAK,EAAE,CAAC;AAC5C,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,EAAU;IACvC,MAAM,GAAG,GAAG,EAAE,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;IACxC,IAAI,GAAG,IAAI,CAAC,EAAE,CAAC;QACb,MAAM,IAAI,KAAK,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,MAAM,GAAG,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC;IAClD,MAAM,KAAK,GAAG,EAAE,CAAC,KAAK,CAAC,GAAG,GAAG,CAAC,CAAC,CAAC;IAChC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC7D,MAAM,IAAI,KAAK,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAC/C,CAAC;IACD,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AACxB,CAAC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Push (FCM/APNs) credential storage + resolution for cadre-host.
|
|
3
|
+
*
|
|
4
|
+
* The platform-push secrets a self-hosted deployment provisions live in the host
|
|
5
|
+
* secret store (keytar with file-store fallback — the same store DDNS tokens use);
|
|
6
|
+
* the non-secret app-config bits (APNs bundle id / sandbox toggle, cooldown /
|
|
7
|
+
* debounce) live in `host.config.json` (`PushSettings`). At node-spawn time the
|
|
8
|
+
* orchestrator's `pushResolver` calls {@link resolvePushCredentials}, which reads
|
|
9
|
+
* BOTH and merges them into the `PushCredentials` block written into the spawned
|
|
10
|
+
* node's `cadre.json`.
|
|
11
|
+
*
|
|
12
|
+
* Secret hygiene: the FCM service-account fields and the APNs `.p8` key are stored
|
|
13
|
+
* ONLY in the secret store, never in `host.config.json` and never in `state.json`.
|
|
14
|
+
* They are re-read on every spawn so a restart picks up rotated keys, and the
|
|
15
|
+
* resolver redacts on any log line. A partial credential set (a present platform
|
|
16
|
+
* missing required fields) is rejected — fail fast, not at first push.
|
|
17
|
+
*/
|
|
18
|
+
import type { PushCredentials } from '@serfab/cadre-core';
|
|
19
|
+
import type { SecretsStore } from '../nat/secrets/index.js';
|
|
20
|
+
import type { PushSettings } from '../installer/config.js';
|
|
21
|
+
/** Push platform whose secret bundle lives in the secret store. */
|
|
22
|
+
export type PushSecretPlatform = 'fcm' | 'apns';
|
|
23
|
+
/** Build the secret-store account key for a platform's credential bundle. */
|
|
24
|
+
export declare function pushAccount(platform: PushSecretPlatform): string;
|
|
25
|
+
/** FCM secret bundle persisted in the secret store (the whole set is sensitive). */
|
|
26
|
+
export interface FcmSecret {
|
|
27
|
+
projectId: string;
|
|
28
|
+
clientEmail: string;
|
|
29
|
+
/** Service-account RSA private key, PEM. */
|
|
30
|
+
privateKey: string;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* APNs secret bundle persisted in the secret store. `bundleId` / `production` are
|
|
34
|
+
* NOT here — they are non-secret app-config in {@link PushSettings}.
|
|
35
|
+
*/
|
|
36
|
+
export interface ApnsSecret {
|
|
37
|
+
keyId: string;
|
|
38
|
+
teamId: string;
|
|
39
|
+
/** `.p8` ES256 private key, PEM. */
|
|
40
|
+
privateKey: string;
|
|
41
|
+
}
|
|
42
|
+
/** Store (or replace) the FCM service-account secret bundle. */
|
|
43
|
+
export declare function setFcmSecret(secrets: SecretsStore, secret: FcmSecret): Promise<void>;
|
|
44
|
+
/** Store (or replace) the APNs auth-key secret bundle. */
|
|
45
|
+
export declare function setApnsSecret(secrets: SecretsStore, secret: ApnsSecret): Promise<void>;
|
|
46
|
+
/** Remove a platform's secret bundle. Returns true if one was present. */
|
|
47
|
+
export declare function clearPushSecret(secrets: SecretsStore, platform: PushSecretPlatform): Promise<boolean>;
|
|
48
|
+
/**
|
|
49
|
+
* Resolve the full {@link PushCredentials} block to inject into a spawned node,
|
|
50
|
+
* merging the secret-store bundles with the non-secret {@link PushSettings}.
|
|
51
|
+
*
|
|
52
|
+
* Returns `undefined` when NO platform is configured (push is opt-in — the node
|
|
53
|
+
* then constructs no fan-out). Throws when a configured platform is incomplete
|
|
54
|
+
* (e.g. APNs secret present but `bundleId` unset), so a misconfig surfaces at the
|
|
55
|
+
* spawn boundary rather than silently at first push.
|
|
56
|
+
*/
|
|
57
|
+
export declare function resolvePushCredentials(secrets: SecretsStore, settings: PushSettings | undefined): Promise<PushCredentials | undefined>;
|
|
58
|
+
/**
|
|
59
|
+
* A description of which push platforms are configured, for the `push status` CLI
|
|
60
|
+
* and any UI — derived without exposing any secret material.
|
|
61
|
+
*/
|
|
62
|
+
export interface PushStatus {
|
|
63
|
+
fcm: boolean;
|
|
64
|
+
apns: boolean;
|
|
65
|
+
}
|
|
66
|
+
/** Report which platforms have a stored secret bundle (no secret material). */
|
|
67
|
+
export declare function pushStatus(secrets: SecretsStore): Promise<PushStatus>;
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Push (FCM/APNs) credential storage + resolution for cadre-host.
|
|
3
|
+
*
|
|
4
|
+
* The platform-push secrets a self-hosted deployment provisions live in the host
|
|
5
|
+
* secret store (keytar with file-store fallback — the same store DDNS tokens use);
|
|
6
|
+
* the non-secret app-config bits (APNs bundle id / sandbox toggle, cooldown /
|
|
7
|
+
* debounce) live in `host.config.json` (`PushSettings`). At node-spawn time the
|
|
8
|
+
* orchestrator's `pushResolver` calls {@link resolvePushCredentials}, which reads
|
|
9
|
+
* BOTH and merges them into the `PushCredentials` block written into the spawned
|
|
10
|
+
* node's `cadre.json`.
|
|
11
|
+
*
|
|
12
|
+
* Secret hygiene: the FCM service-account fields and the APNs `.p8` key are stored
|
|
13
|
+
* ONLY in the secret store, never in `host.config.json` and never in `state.json`.
|
|
14
|
+
* They are re-read on every spawn so a restart picks up rotated keys, and the
|
|
15
|
+
* resolver redacts on any log line. A partial credential set (a present platform
|
|
16
|
+
* missing required fields) is rejected — fail fast, not at first push.
|
|
17
|
+
*/
|
|
18
|
+
import debug from 'debug';
|
|
19
|
+
import { validatePushCredentials } from '@serfab/cadre-core';
|
|
20
|
+
const log = debug('cadre:host:push');
|
|
21
|
+
/** Build the secret-store account key for a platform's credential bundle. */
|
|
22
|
+
export function pushAccount(platform) {
|
|
23
|
+
return `push:${platform}`;
|
|
24
|
+
}
|
|
25
|
+
/** Store (or replace) the FCM service-account secret bundle. */
|
|
26
|
+
export async function setFcmSecret(secrets, secret) {
|
|
27
|
+
await secrets.set(pushAccount('fcm'), JSON.stringify(secret));
|
|
28
|
+
}
|
|
29
|
+
/** Store (or replace) the APNs auth-key secret bundle. */
|
|
30
|
+
export async function setApnsSecret(secrets, secret) {
|
|
31
|
+
await secrets.set(pushAccount('apns'), JSON.stringify(secret));
|
|
32
|
+
}
|
|
33
|
+
/** Remove a platform's secret bundle. Returns true if one was present. */
|
|
34
|
+
export async function clearPushSecret(secrets, platform) {
|
|
35
|
+
return secrets.delete(pushAccount(platform));
|
|
36
|
+
}
|
|
37
|
+
/** Read a platform's stored secret bundle, or null when unset. */
|
|
38
|
+
async function readSecret(secrets, platform) {
|
|
39
|
+
const raw = await secrets.get(pushAccount(platform));
|
|
40
|
+
if (raw === null)
|
|
41
|
+
return null;
|
|
42
|
+
try {
|
|
43
|
+
return JSON.parse(raw);
|
|
44
|
+
}
|
|
45
|
+
catch (err) {
|
|
46
|
+
throw new Error(`Stored ${platform} push secret is not valid JSON: ${err.message}`, { cause: err });
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Resolve the full {@link PushCredentials} block to inject into a spawned node,
|
|
51
|
+
* merging the secret-store bundles with the non-secret {@link PushSettings}.
|
|
52
|
+
*
|
|
53
|
+
* Returns `undefined` when NO platform is configured (push is opt-in — the node
|
|
54
|
+
* then constructs no fan-out). Throws when a configured platform is incomplete
|
|
55
|
+
* (e.g. APNs secret present but `bundleId` unset), so a misconfig surfaces at the
|
|
56
|
+
* spawn boundary rather than silently at first push.
|
|
57
|
+
*/
|
|
58
|
+
export async function resolvePushCredentials(secrets, settings) {
|
|
59
|
+
const fcmSecret = await readSecret(secrets, 'fcm');
|
|
60
|
+
const apnsSecret = await readSecret(secrets, 'apns');
|
|
61
|
+
if (!fcmSecret && !apnsSecret)
|
|
62
|
+
return undefined;
|
|
63
|
+
const push = {};
|
|
64
|
+
if (fcmSecret) {
|
|
65
|
+
const fcm = {
|
|
66
|
+
projectId: fcmSecret.projectId,
|
|
67
|
+
clientEmail: fcmSecret.clientEmail,
|
|
68
|
+
privateKey: fcmSecret.privateKey,
|
|
69
|
+
};
|
|
70
|
+
push.fcm = fcm;
|
|
71
|
+
}
|
|
72
|
+
if (apnsSecret) {
|
|
73
|
+
const apns = {
|
|
74
|
+
keyId: apnsSecret.keyId,
|
|
75
|
+
teamId: apnsSecret.teamId,
|
|
76
|
+
bundleId: settings?.apns?.bundleId ?? '',
|
|
77
|
+
privateKey: apnsSecret.privateKey,
|
|
78
|
+
...(settings?.apns?.production !== undefined ? { production: settings.apns.production } : {}),
|
|
79
|
+
};
|
|
80
|
+
push.apns = apns;
|
|
81
|
+
}
|
|
82
|
+
if (settings?.cooldownMs !== undefined)
|
|
83
|
+
push.cooldownMs = settings.cooldownMs;
|
|
84
|
+
if (settings?.debounceMs !== undefined)
|
|
85
|
+
push.debounceMs = settings.debounceMs;
|
|
86
|
+
const errors = validatePushCredentials(push);
|
|
87
|
+
if (errors.length > 0) {
|
|
88
|
+
throw new Error(`Invalid push credentials: ${errors.join('; ')}`);
|
|
89
|
+
}
|
|
90
|
+
log('resolved push credentials (fcm=%s apns=%s)', !!push.fcm, !!push.apns);
|
|
91
|
+
return push;
|
|
92
|
+
}
|
|
93
|
+
/** Report which platforms have a stored secret bundle (no secret material). */
|
|
94
|
+
export async function pushStatus(secrets) {
|
|
95
|
+
const accounts = await secrets.list();
|
|
96
|
+
return {
|
|
97
|
+
fcm: accounts.includes(pushAccount('fcm')),
|
|
98
|
+
apns: accounts.includes(pushAccount('apns')),
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/push/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAG1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAK7D,MAAM,GAAG,GAAG,KAAK,CAAC,iBAAiB,CAAC,CAAC;AAKrC,6EAA6E;AAC7E,MAAM,U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,IAAI,KAAK,CAAC,6BAA6B,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;IACpE,CAAC;IACD,GAAG,CAAC,4CAA4C,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC3E,OAAO,IAAI,CAAC;AACd,CAAC;AAWD,+EAA+E;AAC/E,MAAM,CAAC,KAAK,UAAU,UAAU,CAAC,OAAqB;IACpD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,IAAI,EAAE,CAAC;IACtC,OAAO;QACL,GAAG,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC;QAC1C,IAAI,EAAE,QAAQ,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;KAC7C,CAAC;AACJ,CAAC"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* invalid_label, invalid_token → 400
|
|
8
8
|
* not_found, already_redeemed → 404
|
|
9
9
|
* expired → 410
|
|
10
|
+
* node_unavailable → 503
|
|
10
11
|
* storage_error → 500
|
|
11
12
|
* - NatError
|
|
12
13
|
* invalid_config, ddns_provider_unknown,
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
* secrets_unavailable, storage_error,
|
|
15
16
|
* mapping_failed, router_unreachable,
|
|
16
17
|
* ip_detection_failed, ddns_update_failed → 500
|
|
18
|
+
* node_unavailable → 503
|
|
17
19
|
* - UpdateErrorException
|
|
18
20
|
* manifest_invalid, no_update_available,
|
|
19
21
|
* min_previous_version → 400
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
* invalid_label, invalid_token → 400
|
|
8
8
|
* not_found, already_redeemed → 404
|
|
9
9
|
* expired → 410
|
|
10
|
+
* node_unavailable → 503
|
|
10
11
|
* storage_error → 500
|
|
11
12
|
* - NatError
|
|
12
13
|
* invalid_config, ddns_provider_unknown,
|
|
@@ -14,6 +15,7 @@
|
|
|
14
15
|
* secrets_unavailable, storage_error,
|
|
15
16
|
* mapping_failed, router_unreachable,
|
|
16
17
|
* ip_detection_failed, ddns_update_failed → 500
|
|
18
|
+
* node_unavailable → 503
|
|
17
19
|
* - UpdateErrorException
|
|
18
20
|
* manifest_invalid, no_update_available,
|
|
19
21
|
* min_previous_version → 400
|
|
@@ -34,6 +36,7 @@ const TRUST_STATUS = {
|
|
|
34
36
|
already_redeemed: 404,
|
|
35
37
|
expired: 410,
|
|
36
38
|
storage_error: 500,
|
|
39
|
+
node_unavailable: 503,
|
|
37
40
|
};
|
|
38
41
|
const NAT_STATUS = {
|
|
39
42
|
invalid_config: 400,
|
|
@@ -45,6 +48,7 @@ const NAT_STATUS = {
|
|
|
45
48
|
router_unreachable: 500,
|
|
46
49
|
ip_detection_failed: 500,
|
|
47
50
|
ddns_update_failed: 500,
|
|
51
|
+
node_unavailable: 503,
|
|
48
52
|
};
|
|
49
53
|
const UPDATE_STATUS = {
|
|
50
54
|
manifest_invalid: 400,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/server/error-handler.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"error-handler.js","sourceRoot":"","sources":["../../src/server/error-handler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAA6B,MAAM,kBAAkB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAqB,MAAM,iBAAiB,CAAC;AAC9D,OAAO,EAAE,oBAAoB,EAAwB,MAAM,oBAAoB,CAAC;AAEhF,MAAM,GAAG,GAAG,KAAK,CAAC,0BAA0B,CAAC,CAAC;AAE9C,MAAM,YAAY,GAAyC;IACzD,aAAa,EAAE,GAAG;IAClB,aAAa,EAAE,GAAG;IAClB,SAAS,EAAE,GAAG;IACd,gBAAgB,EA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AC;IACD,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,IAAI,gBAAgB,EAAE,CAAC;AACrF,CAAC"}
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* `onStateChange` (forwarded by `createLocalUiServer.start`) — the route
|
|
7
7
|
* handlers don't re-publish.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* start/restart are real for the admin's authority node (re-spawned from the
|
|
10
|
+
* persisted `AuthoritySpawnConfig`). Generic per-member node spawn from saved
|
|
11
|
+
* config is out of scope and returns `not_implemented`. Stop works for any
|
|
12
|
+
* running node.
|
|
12
13
|
*/
|
|
13
14
|
import type { FastifyInstance } from 'fastify';
|
|
14
15
|
import type { HostProcessOrchestrator } from '../../orchestrator/index.js';
|
|
@@ -6,9 +6,10 @@
|
|
|
6
6
|
* `onStateChange` (forwarded by `createLocalUiServer.start`) — the route
|
|
7
7
|
* handlers don't re-publish.
|
|
8
8
|
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
9
|
+
* start/restart are real for the admin's authority node (re-spawned from the
|
|
10
|
+
* persisted `AuthoritySpawnConfig`). Generic per-member node spawn from saved
|
|
11
|
+
* config is out of scope and returns `not_implemented`. Stop works for any
|
|
12
|
+
* running node.
|
|
12
13
|
*/
|
|
13
14
|
import { existsSync, openSync, readSync, closeSync, statSync } from 'node:fs';
|
|
14
15
|
import { defaultLogPath } from '../../orchestrator/log-rotator.js';
|
|
@@ -64,32 +65,45 @@ export function registerNodesRoutes(app, opts) {
|
|
|
64
65
|
// forwards that to the bus. Don't double-publish here.
|
|
65
66
|
return { ok: true };
|
|
66
67
|
});
|
|
67
|
-
// start / restart: the
|
|
68
|
-
//
|
|
69
|
-
//
|
|
70
|
-
//
|
|
71
|
-
// follow-up ticket. Until then these endpoints stub out cleanly so the
|
|
72
|
-
// SPA gets a predictable error rather than a route-not-found 404.
|
|
68
|
+
// start / restart: real for the admin's authority node (spawned from the
|
|
69
|
+
// persisted AuthoritySpawnConfig). Generic per-member node spawn from saved
|
|
70
|
+
// config is out of scope — those ids return a clear not_implemented; unknown
|
|
71
|
+
// ids 404.
|
|
73
72
|
app.post('/api/nodes/:id/start', async (request, reply) => {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
}
|
|
81
|
-
}
|
|
73
|
+
const { id } = request.params;
|
|
74
|
+
if (orchestrator.isAuthorityNode(id)) {
|
|
75
|
+
if (!orchestrator.hasAuthorityConfig()) {
|
|
76
|
+
return notImplemented(reply, `start ${id}: authority node has no saved spawn config.`);
|
|
77
|
+
}
|
|
78
|
+
const node = await orchestrator.ensureAuthorityNode();
|
|
79
|
+
return { ok: true, data: { node } };
|
|
80
|
+
}
|
|
81
|
+
return startRestartFallback(reply, orchestrator, id, 'start');
|
|
82
82
|
});
|
|
83
83
|
app.post('/api/nodes/:id/restart', async (request, reply) => {
|
|
84
|
-
|
|
84
|
+
const { id } = request.params;
|
|
85
|
+
if (orchestrator.isAuthorityNode(id)) {
|
|
86
|
+
if (!orchestrator.hasAuthorityConfig()) {
|
|
87
|
+
return notImplemented(reply, `restart ${id}: authority node has no saved spawn config.`);
|
|
88
|
+
}
|
|
89
|
+
const node = await orchestrator.restartAuthorityNode();
|
|
90
|
+
return { ok: true, data: { node } };
|
|
91
|
+
}
|
|
92
|
+
return startRestartFallback(reply, orchestrator, id, 'restart');
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/** 404 for unknown ids; 501 not_implemented for known non-authority nodes. */
|
|
96
|
+
function startRestartFallback(reply, orchestrator, id, verb) {
|
|
97
|
+
if (!orchestrator.getNode(id)) {
|
|
98
|
+
return reply.code(404).send({
|
|
85
99
|
ok: false,
|
|
86
|
-
error: {
|
|
87
|
-
code: 'not_implemented',
|
|
88
|
-
message: `restart ${request.params.id}: cadre-host v1 has no auto-spawn path. ` +
|
|
89
|
-
`Restart the cadre-host service to bring up persisted nodes.`,
|
|
90
|
-
},
|
|
100
|
+
error: { code: 'not_found', message: `Unknown node: ${id}` },
|
|
91
101
|
});
|
|
92
|
-
}
|
|
102
|
+
}
|
|
103
|
+
return notImplemented(reply, `${verb} ${id}: only the authority node is start/restart-able; generic node spawn is out of scope.`);
|
|
104
|
+
}
|
|
105
|
+
function notImplemented(reply, message) {
|
|
106
|
+
return reply.code(501).send({ ok: false, error: { code: 'not_implemented', message } });
|
|
93
107
|
}
|
|
94
108
|
/**
|
|
95
109
|
* Read the last `n` lines from a log file by walking the tail in chunks.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/server/routes/nodes.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"nodes.js","sourceRoot":"","sources":["../../../src/server/routes/nodes.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;AAK9E,OAAO,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AAEnE,MAAM,iBAAiB,GAAG,GAAG,CAAC;AAC9B,MAAM,aAAa,GAAG,IAAI,CAAC;AAM3B,MAAM,UAAU,mBAAmB,CAAC,GAAoB,EAAE,IAAwB;IAChF,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC;IAE9B,GAAG,CAAC,GAAG,CAAC,YAAY,EAAE,KAAK,IAAI,EAAE;QAC/B,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,EAAE,KAAK,EAAE,YAAY,CAAC,SAAS,EAAE,EAAE,EAAE,CAAC;IACjE,CAAC,CAAC,CAAC;IAEH,GAAG,CAAC,GAAG,CAA6B,gBAAgB,EAAE,KAAK,EAAE,OAAO,EAAE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AG,EAAE,CAAC,EAAE,OAAO,EAAE,GAAG,CAAC,CAAC;YACnC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;YACrB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;gBACpC,IAAI,GAAG,CAAC,CAAC,CAAC,KAAK,IAAI;oBAAE,YAAY,EAAE,CAAC;YACtC,CAAC;QACH,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC;QACvD,MAAM,KAAK,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACjC,MAAM,OAAO,GAAG,KAAK,CAAC,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC;QAC5E,OAAO,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC3B,CAAC;YAAS,CAAC;QACT,SAAS,CAAC,EAAE,CAAC,CAAC;IAChB,CAAC;AACH,CAAC"}
|
package/dist/server/static.d.ts
CHANGED
|
@@ -23,3 +23,15 @@ export interface StaticMountOptions {
|
|
|
23
23
|
rootDir?: string;
|
|
24
24
|
}
|
|
25
25
|
export declare function registerStaticMount(app: FastifyInstance, opts?: StaticMountOptions): void;
|
|
26
|
+
/**
|
|
27
|
+
* Resolve a request path to an absolute file path inside `rootDir`, or `null`
|
|
28
|
+
* if it would escape the root.
|
|
29
|
+
*
|
|
30
|
+
* Exported for direct unit testing. The containment check uses `path.relative`
|
|
31
|
+
* rather than a bare `startsWith` prefix test: the latter is the classic
|
|
32
|
+
* prefix-bypass anti-pattern, accepting sibling directories whose name shares
|
|
33
|
+
* `rootDir`'s basename as a prefix (e.g. `dist/ui-private` vs `dist/ui`).
|
|
34
|
+
* `relative` respects the path-separator boundary on both POSIX and Windows,
|
|
35
|
+
* and surfaces cross-drive escapes on Windows as an absolute result.
|
|
36
|
+
*/
|
|
37
|
+
export declare function resolveSafe(rootDir: string, urlPath: string): string | null;
|
package/dist/server/static.js
CHANGED
|
@@ -12,10 +12,8 @@
|
|
|
12
12
|
* static serving anyway.
|
|
13
13
|
*/
|
|
14
14
|
import { readFileSync, statSync, existsSync } from 'node:fs';
|
|
15
|
-
import { dirname, extname, join, normalize, resolve } from 'node:path';
|
|
15
|
+
import { dirname, extname, isAbsolute, join, normalize, relative, resolve, sep } from 'node:path';
|
|
16
16
|
import { fileURLToPath } from 'node:url';
|
|
17
|
-
import debug from 'debug';
|
|
18
|
-
const log = debug('cadre:host:static');
|
|
19
17
|
const MIME_TYPES = {
|
|
20
18
|
'.html': 'text/html; charset=utf-8',
|
|
21
19
|
'.js': 'application/javascript; charset=utf-8',
|
|
@@ -103,13 +101,32 @@ function serveStatic(rootDir, request, reply) {
|
|
|
103
101
|
error: { code: 'not_found', message: `No static asset for ${request.url}` },
|
|
104
102
|
});
|
|
105
103
|
}
|
|
106
|
-
|
|
104
|
+
/**
|
|
105
|
+
* Resolve a request path to an absolute file path inside `rootDir`, or `null`
|
|
106
|
+
* if it would escape the root.
|
|
107
|
+
*
|
|
108
|
+
* Exported for direct unit testing. The containment check uses `path.relative`
|
|
109
|
+
* rather than a bare `startsWith` prefix test: the latter is the classic
|
|
110
|
+
* prefix-bypass anti-pattern, accepting sibling directories whose name shares
|
|
111
|
+
* `rootDir`'s basename as a prefix (e.g. `dist/ui-private` vs `dist/ui`).
|
|
112
|
+
* `relative` respects the path-separator boundary on both POSIX and Windows,
|
|
113
|
+
* and surfaces cross-drive escapes on Windows as an absolute result.
|
|
114
|
+
*/
|
|
115
|
+
export function resolveSafe(rootDir, urlPath) {
|
|
107
116
|
const cleaned = decodeSafe(urlPath);
|
|
108
117
|
if (cleaned === null)
|
|
109
118
|
return null;
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
const root = normalize(rootDir);
|
|
120
|
+
const target = normalize(join(root, cleaned === '/' ? '' : cleaned));
|
|
121
|
+
// Containment: target must be rootDir itself or strictly beneath it.
|
|
122
|
+
// `relative(root, target)` is '' for root itself (accepted) and a descendant
|
|
123
|
+
// path with no leading '..' for in-root assets. Reject when it climbs out
|
|
124
|
+
// (exactly '..', or '..' + separator) or — cross-drive on Windows — is
|
|
125
|
+
// absolute. Guarding on '..' + separator rather than a bare '..' prefix avoids
|
|
126
|
+
// falsely rejecting legitimate in-root names that merely *begin* with '..'
|
|
127
|
+
// (e.g. a '..foo' asset), which would re-introduce a looser prefix check.
|
|
128
|
+
const rel = relative(root, target);
|
|
129
|
+
if (rel === '..' || rel.startsWith('..' + sep) || isAbsolute(rel))
|
|
113
130
|
return null;
|
|
114
131
|
return target;
|
|
115
132
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"static.js","sourceRoot":"","sources":["../../src/server/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"static.js","sourceRoot":"","sources":["../../src/server/static.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,EAAE,YAAY,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAC7D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE,QAAQ,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAClG,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAIzC,MAAM,UAAU,GAA2B;IACzC,OAAO,EAAE,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