@serfab/cadre-host 1.13.0 → 1.15.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/README.md +347 -423
- package/dist/bin/host.d.ts +6 -3
- package/dist/bin/host.js +332 -524
- package/dist/bin/host.js.map +1 -1
- package/dist/bin/join-output.d.ts +56 -0
- package/dist/bin/join-output.js +92 -0
- package/dist/bin/join-output.js.map +1 -0
- package/dist/bin/nat-output.d.ts +54 -0
- package/dist/bin/nat-output.js +138 -0
- package/dist/bin/nat-output.js.map +1 -0
- package/dist/bin/ui-access.d.ts +22 -0
- package/dist/bin/ui-access.js +44 -0
- package/dist/bin/ui-access.js.map +1 -0
- package/dist/hosted/claim-details.d.ts +66 -0
- package/dist/hosted/claim-details.js +60 -0
- package/dist/hosted/claim-details.js.map +1 -0
- package/dist/hosted/hosted-node-service.d.ts +325 -0
- package/dist/hosted/hosted-node-service.js +678 -0
- package/dist/hosted/hosted-node-service.js.map +1 -0
- package/dist/hosted/hosted-node-store.d.ts +40 -0
- package/dist/hosted/hosted-node-store.js +126 -0
- package/dist/hosted/hosted-node-store.js.map +1 -0
- package/dist/{donation/donation-supervisor.d.ts → hosted/hosted-node-supervisor.d.ts} +70 -53
- package/dist/hosted/hosted-node-supervisor.js +396 -0
- package/dist/hosted/hosted-node-supervisor.js.map +1 -0
- package/dist/hosted/hosted-node-watcher.d.ts +95 -0
- package/dist/hosted/hosted-node-watcher.js +260 -0
- package/dist/hosted/hosted-node-watcher.js.map +1 -0
- package/dist/hosted/index.d.ts +16 -0
- package/dist/hosted/index.js +13 -0
- package/dist/hosted/index.js.map +1 -0
- package/dist/hosted/node-status.d.ts +51 -0
- package/dist/hosted/node-status.js +77 -0
- package/dist/hosted/node-status.js.map +1 -0
- package/dist/hosted/types.d.ts +141 -0
- package/dist/hosted/types.js +22 -0
- package/dist/hosted/types.js.map +1 -0
- package/dist/index.d.ts +12 -24
- package/dist/index.js +9 -19
- package/dist/index.js.map +1 -1
- package/dist/installer/config.d.ts +27 -34
- package/dist/installer/config.js +46 -15
- package/dist/installer/config.js.map +1 -1
- package/dist/installer/index.d.ts +9 -19
- package/dist/installer/index.js +21 -85
- package/dist/installer/index.js.map +1 -1
- package/dist/installer/paths.d.ts +0 -2
- package/dist/installer/paths.js +0 -4
- package/dist/installer/paths.js.map +1 -1
- package/dist/installer/wizard.d.ts +12 -9
- package/dist/installer/wizard.js +15 -14
- package/dist/installer/wizard.js.map +1 -1
- package/dist/nat/address-resolver.d.ts +18 -17
- package/dist/nat/address-resolver.js +79 -25
- package/dist/nat/address-resolver.js.map +1 -1
- package/dist/nat/address-watch.d.ts +37 -0
- package/dist/nat/address-watch.js +84 -0
- package/dist/nat/address-watch.js.map +1 -0
- package/dist/nat/ddns/duckdns.d.ts +2 -1
- package/dist/nat/ddns/duckdns.js +5 -1
- package/dist/nat/ddns/duckdns.js.map +1 -1
- package/dist/nat/ddns/index.d.ts +6 -0
- package/dist/nat/ddns/index.js.map +1 -1
- package/dist/nat/index.d.ts +13 -9
- package/dist/nat/index.js +7 -5
- package/dist/nat/index.js.map +1 -1
- package/dist/nat/nat-service.d.ts +220 -77
- package/dist/nat/nat-service.js +653 -239
- package/dist/nat/nat-service.js.map +1 -1
- package/dist/nat/nat-store.d.ts +12 -5
- package/dist/nat/nat-store.js +124 -29
- package/dist/nat/nat-store.js.map +1 -1
- package/dist/nat/network-mode.d.ts +19 -0
- package/dist/nat/network-mode.js +32 -0
- package/dist/nat/network-mode.js.map +1 -0
- package/dist/nat/port-mapper.d.ts +83 -79
- package/dist/nat/port-mapper.js +148 -189
- package/dist/nat/port-mapper.js.map +1 -1
- package/dist/nat/reachability.d.ts +32 -15
- package/dist/nat/reachability.js +110 -22
- package/dist/nat/reachability.js.map +1 -1
- package/dist/nat/types.d.ts +98 -27
- package/dist/nat/types.js +8 -5
- package/dist/nat/types.js.map +1 -1
- package/dist/orchestrator/host-process-orchestrator.d.ts +32 -74
- package/dist/orchestrator/host-process-orchestrator.js +84 -233
- package/dist/orchestrator/host-process-orchestrator.js.map +1 -1
- package/dist/{installer/identity.d.ts → orchestrator/identity-file.d.ts} +5 -5
- package/dist/{installer/identity.js → orchestrator/identity-file.js} +6 -6
- package/dist/orchestrator/identity-file.js.map +1 -0
- package/dist/orchestrator/index.d.ts +2 -3
- package/dist/orchestrator/index.js +1 -1
- package/dist/orchestrator/index.js.map +1 -1
- package/dist/orchestrator/node-identity.d.ts +6 -6
- package/dist/orchestrator/node-identity.js +7 -7
- package/dist/orchestrator/node-identity.js.map +1 -1
- package/dist/orchestrator/port-allocator.d.ts +5 -6
- package/dist/orchestrator/port-allocator.js +9 -11
- package/dist/orchestrator/port-allocator.js.map +1 -1
- package/dist/orchestrator/state-store.d.ts +3 -5
- package/dist/orchestrator/state-store.js +2 -10
- package/dist/orchestrator/state-store.js.map +1 -1
- package/dist/orchestrator/types.d.ts +33 -22
- package/dist/orchestrator/types.js.map +1 -1
- package/dist/package-version.d.ts +1 -0
- package/dist/package-version.js +4 -0
- package/dist/package-version.js.map +1 -0
- package/dist/server/error-handler.d.ts +5 -25
- package/dist/server/error-handler.js +11 -74
- package/dist/server/error-handler.js.map +1 -1
- package/dist/server/events/types.d.ts +7 -11
- package/dist/server/events/types.js +2 -1
- package/dist/server/events/types.js.map +1 -1
- package/dist/server/index.d.ts +11 -37
- package/dist/server/index.js +30 -48
- package/dist/server/index.js.map +1 -1
- package/dist/server/routes/hosted-nodes.d.ts +28 -0
- package/dist/server/routes/hosted-nodes.js +68 -0
- package/dist/server/routes/hosted-nodes.js.map +1 -0
- package/dist/server/routes/nat.d.ts +4 -1
- package/dist/server/routes/nat.js +13 -2
- package/dist/server/routes/nat.js.map +1 -1
- package/dist/server/routes/nodes.d.ts +6 -20
- package/dist/server/routes/nodes.js +7 -86
- package/dist/server/routes/nodes.js.map +1 -1
- package/dist/server/routes/settings.d.ts +3 -7
- package/dist/server/routes/settings.js +18 -8
- package/dist/server/routes/settings.js.map +1 -1
- package/dist/server/routes/status.d.ts +2 -25
- package/dist/server/routes/status.js +3 -43
- package/dist/server/routes/status.js.map +1 -1
- package/dist/server/server.js +8 -8
- package/dist/server/settings-store.d.ts +2 -2
- package/dist/server/settings-store.js +2 -2
- package/dist/server/static.js +1 -2
- package/dist/server/static.js.map +1 -1
- package/dist/ui/assets/index-BHd8CWZA.css +1 -0
- package/dist/ui/assets/index-Ccr2GjPT.js +23 -0
- package/dist/ui/assets/index-Ccr2GjPT.js.map +1 -0
- package/dist/ui/index.html +2 -2
- package/dist/update/index.d.ts +2 -2
- package/dist/update/index.js +2 -2
- package/dist/update/store.d.ts +1 -1
- package/dist/update/store.js +1 -1
- package/dist/update/types.d.ts +1 -1
- package/dist/update/types.js +1 -1
- package/package.json +5 -7
- package/src/__tests__/cli-nat.smoke.test.ts +219 -212
- package/src/__tests__/cli.smoke.test.ts +2 -2
- package/src/__tests__/global-setup.ts +2 -3
- package/src/__tests__/orchestrator-claim-secret.test.ts +111 -0
- package/src/__tests__/orchestrator-env-scrub.test.ts +160 -163
- package/src/__tests__/orchestrator-handle-contract.ts +134 -134
- package/src/__tests__/orchestrator-node-identity.test.ts +177 -203
- package/src/__tests__/orchestrator-ports.test.ts +124 -143
- package/src/__tests__/orchestrator-push.test.ts +138 -146
- package/src/__tests__/orchestrator.test.ts +1017 -1063
- package/src/__tests__/ui-access.test.ts +30 -0
- package/src/bin/host.ts +397 -572
- package/src/bin/join-output.ts +120 -0
- package/src/bin/nat-output.ts +188 -0
- package/src/bin/ui-access.ts +50 -0
- package/src/{donation → hosted}/__tests__/fake-orchestrator.test.ts +172 -173
- package/src/{donation → hosted}/__tests__/fake-orchestrator.ts +43 -23
- package/src/hosted/__tests__/hosted-node-service.test.ts +708 -0
- package/src/hosted/__tests__/hosted-node-supervisor.test.ts +475 -0
- package/src/hosted/__tests__/test-invitation.ts +33 -0
- package/src/hosted/claim-details.ts +103 -0
- package/src/hosted/hosted-node-service.ts +814 -0
- package/src/hosted/hosted-node-store.ts +144 -0
- package/src/hosted/hosted-node-supervisor.ts +439 -0
- package/src/hosted/hosted-node-watcher.ts +288 -0
- package/src/hosted/index.ts +53 -0
- package/src/hosted/node-status.ts +97 -0
- package/src/hosted/types.ts +160 -0
- package/src/index.ts +72 -91
- package/src/installer/__tests__/config.test.ts +15 -40
- package/src/installer/__tests__/installer.smoke.test.ts +184 -263
- package/src/installer/__tests__/wizard.test.ts +25 -13
- package/src/installer/config.ts +201 -175
- package/src/installer/index.ts +252 -327
- package/src/installer/paths.ts +104 -109
- package/src/installer/wizard.ts +24 -26
- package/src/nat/__tests__/address-resolver.test.ts +107 -82
- package/src/nat/__tests__/nat-service.test.ts +608 -515
- package/src/nat/__tests__/nat-store.test.ts +49 -12
- package/src/nat/__tests__/network-mode.test.ts +38 -0
- package/src/nat/__tests__/port-mapper.test.ts +30 -191
- package/src/nat/__tests__/reachability.test.ts +96 -13
- package/src/nat/address-resolver.ts +94 -52
- package/src/nat/address-watch.ts +92 -0
- package/src/nat/ddns/duckdns.ts +5 -1
- package/src/nat/ddns/index.ts +6 -0
- package/src/nat/index.ts +33 -13
- package/src/nat/nat-service.ts +942 -501
- package/src/nat/nat-store.ts +126 -31
- package/src/nat/network-mode.ts +36 -0
- package/src/nat/port-mapper.ts +241 -329
- package/src/nat/reachability.ts +155 -34
- package/src/nat/types.ts +110 -37
- package/src/{installer/__tests__/identity.test.ts → orchestrator/__tests__/identity-file.test.ts} +34 -34
- package/src/orchestrator/__tests__/node-identity.test.ts +62 -62
- package/src/orchestrator/host-process-orchestrator.ts +1089 -1260
- package/src/{installer/identity.ts → orchestrator/identity-file.ts} +56 -56
- package/src/orchestrator/index.ts +9 -10
- package/src/orchestrator/node-identity.ts +41 -41
- package/src/orchestrator/port-allocator.ts +71 -73
- package/src/orchestrator/state-store.ts +76 -90
- package/src/orchestrator/types.ts +34 -23
- package/src/package-version.ts +4 -0
- package/src/server/__tests__/bus.test.ts +38 -38
- package/src/server/__tests__/error-handler.test.ts +81 -118
- package/src/server/__tests__/fakes.ts +15 -18
- package/src/server/__tests__/hosted-nodes-route.test.ts +161 -0
- package/src/server/__tests__/nodes-route.test.ts +114 -283
- package/src/server/__tests__/publishers.test.ts +193 -180
- package/src/server/__tests__/server.smoke.test.ts +134 -223
- package/src/server/__tests__/settings-route.test.ts +210 -195
- package/src/server/__tests__/sse-route.test.ts +119 -119
- package/src/server/__tests__/status-route.test.ts +82 -121
- package/src/server/error-handler.ts +112 -178
- package/src/server/events/types.ts +20 -24
- package/src/server/index.ts +223 -267
- package/src/server/routes/hosted-nodes.ts +83 -0
- package/src/server/routes/nat.ts +75 -63
- package/src/server/routes/nodes.ts +96 -188
- package/src/server/routes/settings.ts +20 -15
- package/src/server/routes/status.ts +5 -67
- package/src/server/server.ts +8 -8
- package/src/server/settings-store.ts +2 -2
- package/src/server/static.ts +1 -2
- package/src/update/index.ts +2 -2
- package/src/update/store.ts +1 -1
- package/src/update/types.ts +1 -1
- package/dist/auth/duration.d.ts +0 -1
- package/dist/auth/duration.js +0 -32
- package/dist/auth/duration.js.map +0 -1
- package/dist/auth/index.d.ts +0 -11
- package/dist/auth/index.js +0 -9
- package/dist/auth/index.js.map +0 -1
- package/dist/auth/self-label.d.ts +0 -36
- package/dist/auth/self-label.js +0 -57
- package/dist/auth/self-label.js.map +0 -1
- package/dist/auth/trust-circle-store.d.ts +0 -26
- package/dist/auth/trust-circle-store.js +0 -129
- package/dist/auth/trust-circle-store.js.map +0 -1
- package/dist/auth/trust-circle.d.ts +0 -156
- package/dist/auth/trust-circle.js +0 -307
- package/dist/auth/trust-circle.js.map +0 -1
- package/dist/auth/types.d.ts +0 -84
- package/dist/auth/types.js +0 -24
- package/dist/auth/types.js.map +0 -1
- package/dist/donation/donation-service.d.ts +0 -389
- package/dist/donation/donation-service.js +0 -828
- package/dist/donation/donation-service.js.map +0 -1
- package/dist/donation/donation-store.d.ts +0 -51
- package/dist/donation/donation-store.js +0 -152
- package/dist/donation/donation-store.js.map +0 -1
- package/dist/donation/donation-supervisor.js +0 -364
- package/dist/donation/donation-supervisor.js.map +0 -1
- package/dist/donation/grant-service.d.ts +0 -80
- package/dist/donation/grant-service.js +0 -210
- package/dist/donation/grant-service.js.map +0 -1
- package/dist/donation/grant-store.d.ts +0 -38
- package/dist/donation/grant-store.js +0 -135
- package/dist/donation/grant-store.js.map +0 -1
- package/dist/donation/index.d.ts +0 -20
- package/dist/donation/index.js +0 -17
- package/dist/donation/index.js.map +0 -1
- package/dist/donation/types.d.ts +0 -224
- package/dist/donation/types.js +0 -40
- package/dist/donation/types.js.map +0 -1
- package/dist/installer/identity.js.map +0 -1
- package/dist/owner/index.d.ts +0 -11
- package/dist/owner/index.js +0 -11
- package/dist/owner/index.js.map +0 -1
- package/dist/owner/owner-node-client.d.ts +0 -110
- package/dist/owner/owner-node-client.js +0 -184
- package/dist/owner/owner-node-client.js.map +0 -1
- package/dist/server/routes/bootstrap-node-validation.d.ts +0 -115
- package/dist/server/routes/bootstrap-node-validation.js +0 -197
- package/dist/server/routes/bootstrap-node-validation.js.map +0 -1
- package/dist/server/routes/grants-admin.d.ts +0 -29
- package/dist/server/routes/grants-admin.js +0 -58
- package/dist/server/routes/grants-admin.js.map +0 -1
- package/dist/server/routes/grants.d.ts +0 -28
- package/dist/server/routes/grants.js +0 -165
- package/dist/server/routes/grants.js.map +0 -1
- package/dist/server/routes/provision-request-validation.d.ts +0 -45
- package/dist/server/routes/provision-request-validation.js +0 -97
- package/dist/server/routes/provision-request-validation.js.map +0 -1
- package/dist/server/routes/strands.d.ts +0 -20
- package/dist/server/routes/strands.js +0 -38
- package/dist/server/routes/strands.js.map +0 -1
- package/dist/server/routes/trust-circle.d.ts +0 -17
- package/dist/server/routes/trust-circle.js +0 -35
- package/dist/server/routes/trust-circle.js.map +0 -1
- package/dist/strands/index.d.ts +0 -7
- package/dist/strands/index.js +0 -6
- package/dist/strands/index.js.map +0 -1
- package/dist/strands/strand-service.d.ts +0 -50
- package/dist/strands/strand-service.js +0 -103
- package/dist/strands/strand-service.js.map +0 -1
- package/dist/strands/types.d.ts +0 -93
- package/dist/strands/types.js +0 -23
- package/dist/strands/types.js.map +0 -1
- package/dist/ui/assets/index-C6nELNfC.js +0 -23
- package/dist/ui/assets/index-C6nELNfC.js.map +0 -1
- package/dist/ui/assets/index-TtIYSeZO.css +0 -1
- package/src/__tests__/cli-invite.smoke.test.ts +0 -192
- package/src/__tests__/host-owner.smoke.test.ts +0 -123
- package/src/__tests__/orchestrator-owner.test.ts +0 -234
- package/src/__tests__/orchestrator-pin-keys.test.ts +0 -152
- package/src/auth/__tests__/duration.test.ts +0 -28
- package/src/auth/__tests__/self-label.test.ts +0 -85
- package/src/auth/__tests__/trust-circle-integration.test.ts +0 -152
- package/src/auth/__tests__/trust-circle-store.test.ts +0 -115
- package/src/auth/__tests__/trust-circle.test.ts +0 -445
- package/src/auth/duration.ts +0 -33
- package/src/auth/index.ts +0 -21
- package/src/auth/self-label.ts +0 -74
- package/src/auth/trust-circle-store.ts +0 -155
- package/src/auth/trust-circle.ts +0 -395
- package/src/auth/types.ts +0 -99
- package/src/donation/__tests__/donation-service.test.ts +0 -1193
- package/src/donation/__tests__/donation-supervisor.test.ts +0 -548
- package/src/donation/__tests__/grant-service.test.ts +0 -213
- package/src/donation/__tests__/grant-store.test.ts +0 -113
- package/src/donation/donation-service.ts +0 -1033
- package/src/donation/donation-store.ts +0 -176
- package/src/donation/donation-supervisor.ts +0 -411
- package/src/donation/grant-service.ts +0 -252
- package/src/donation/grant-store.ts +0 -152
- package/src/donation/index.ts +0 -65
- package/src/donation/types.ts +0 -260
- package/src/owner/__tests__/owner-node-client.test.ts +0 -194
- package/src/owner/index.ts +0 -12
- package/src/owner/owner-node-client.ts +0 -259
- package/src/server/__tests__/bootstrap-node-validation.test.ts +0 -138
- package/src/server/__tests__/grants-admin-route.test.ts +0 -171
- package/src/server/__tests__/grants-route.test.ts +0 -394
- package/src/server/__tests__/strands-route.test.ts +0 -234
- package/src/server/routes/bootstrap-node-validation.ts +0 -206
- package/src/server/routes/grants-admin.ts +0 -74
- package/src/server/routes/grants.ts +0 -193
- package/src/server/routes/provision-request-validation.ts +0 -105
- package/src/server/routes/strands.ts +0 -54
- package/src/server/routes/trust-circle.ts +0 -49
- package/src/strands/__tests__/strand-service.test.ts +0 -165
- package/src/strands/index.ts +0 -14
- package/src/strands/strand-service.ts +0 -135
- package/src/strands/types.ts +0 -102
package/dist/index.d.ts
CHANGED
|
@@ -4,37 +4,25 @@
|
|
|
4
4
|
* This package is the sibling of @serfab/cadre-provider for self-hosted
|
|
5
5
|
* basement-PC deployments. It depends on @serfab/cadre-provider for the
|
|
6
6
|
* orchestration interface and container lifecycle types but ships its own
|
|
7
|
-
* orchestrator (host processes, not Docker),
|
|
8
|
-
*
|
|
7
|
+
* orchestrator (host processes, not Docker), the hosted-node service behind
|
|
8
|
+
* "Join a cadre", installer, NAT layer, and local management UI.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* under src
|
|
13
|
-
*
|
|
14
|
-
* - cadre-host-process-orchestrator [DONE]
|
|
15
|
-
* - cadre-host-trust-circle [DONE]
|
|
16
|
-
* - cadre-host-nat
|
|
17
|
-
* - cadre-host-installer
|
|
18
|
-
* - cadre-host-local-ui
|
|
10
|
+
* HostProcessOrchestrator, the hosted-node layer, the NAT layer, the
|
|
11
|
+
* installer, and the local UI server each live in a sibling subdirectory
|
|
12
|
+
* under src/.
|
|
19
13
|
*/
|
|
20
14
|
export type { Orchestrator, OrchestratorCreateRequest, OrchestratorCreateResult, OrchestratorStats, ContainerStatus, ContainerResources, } from '@serfab/cadre-provider';
|
|
21
|
-
export { HostProcessOrchestrator
|
|
22
|
-
export type { HostProcessConfig, PersistedHandle, ManagedNodeInfo, NodeStateListener, NodePorts,
|
|
23
|
-
export {
|
|
24
|
-
export type {
|
|
25
|
-
export { TrustCircleService, TrustCircleStore, TrustCircleError, createTrustCircleHandlers, parseDuration, ensureSelfLabel, DEFAULT_INVITE_TTL_MS, } from './auth/index.js';
|
|
26
|
-
export type { TrustCircleServiceOptions, CadreNodeLike, TrustCircleMember, PendingInvite, TrustCircleFile, TrustCircleSnapshot, TrustCircleHandlers, TrustCircleErrorCode, } from './auth/index.js';
|
|
27
|
-
export { StrandService, StrandError, createStrandHandlers } from './strands/index.js';
|
|
28
|
-
export type { StrandServiceOptions, CadreNodeLike as StrandCadreNodeLike, StrandSummary, StrandListSnapshot, StrandRemovalResult, StrandHandlers, StrandErrorCode, } from './strands/index.js';
|
|
29
|
-
export { GrantStore, GrantService, createGrantAdminHandlers, GrantError, DEFAULT_MAX_NODES, DonationStore, DonationService, DonationError, } from './donation/index.js';
|
|
30
|
-
export type { Grant, GrantDenyReason, GrantValidation, GrantValidator, GrantFile, GrantAdminHandlers, GrantErrorCode, GrantServiceOptions, Donation, DonationView, DonationStatus, DonationFile, DonationErrorCode, DonationProvisionRequest, DonationSeedResult, DonationPeerInfo, DonationServiceOptions, } from './donation/index.js';
|
|
15
|
+
export { HostProcessOrchestrator } from './orchestrator/index.js';
|
|
16
|
+
export type { HostProcessConfig, HostedSpawnRequest, PersistedHandle, ManagedNodeInfo, NodeStateListener, NodePorts, } from './orchestrator/index.js';
|
|
17
|
+
export { HostedNodeStore, HostedNodeService, HostedNodeSupervisor, HostedNodeError, HOSTED_NODE_SPAWNING_TTL_MS, HOSTED_NODE_REAP_SWEEP_MS, HOSTED_NODE_CLAIM_POLL_MS, HOSTED_NODE_CONNECTED_POLL_MS, HOSTED_NODE_RESPAWN_BACKOFF_BASE_MS, HOSTED_NODE_RESPAWN_BACKOFF_MAX_MS, HOSTED_NODE_RESPAWN_MAX_ATTEMPTS, HOSTED_NODE_RESPAWN_HEALTHY_MS, HOSTED_NODE_RESPAWN_SWEEP_MS, PLACEHOLDER_PARTY, } from './hosted/index.js';
|
|
18
|
+
export type { ClaimDetails, HostedNode, HostedNodeAddressSource, HostedNodeChange, HostedNodeChangeKind, HostedNodeChangeListener, HostedNodeErrorCode, HostedNodeClaimJoin, HostedNodeFile, HostedNodeInvitationJoin, HostedNodeJoin, HostedNodeJoinView, HostedNodeOrchestrator, HostedNodeServiceOptions, HostedNodeStatus, HostedNodeSupervisorOptions, HostedNodeView, JoinOptions, RespawnOptions, RespawnResult, SupervisedOrchestrator, } from './hosted/index.js';
|
|
31
19
|
export { Installer, readHostConfig, updateHostConfig, writeHostConfig } from './installer/index.js';
|
|
32
20
|
export type { InstallOptions, InstallResult, UninstallOptions, InstallerOptions, HostConfigFile, PushSettings, WizardAnswers, WizardDefaults, ServiceHost, ServiceHostContext, ServiceHostStatus, } from './installer/index.js';
|
|
33
21
|
export { resolvePushCredentials, setFcmSecret, setApnsSecret, clearPushSecret, pushAccount, pushStatus, } from './push/index.js';
|
|
34
22
|
export type { FcmSecret, ApnsSecret, PushSecretPlatform, PushStatus, } from './push/index.js';
|
|
35
23
|
export { UpdateService, createUpdateHandlers, UpdateStateStore, UpdateErrorException, applyUpdate, defaultNpmExecutor, fetchManifest, verifyManifest, canonicalJson, signManifest, validateManifestFields, buildManifest, derivePublicKeyBase64, signAndSelfVerify, compareVersions, parseVersion, getReleasePublicKey, getReleasePublicKeyBase64, ed25519FromRaw, isPlaceholderReleaseKey, } from './update/index.js';
|
|
36
24
|
export type { UpdateServiceOptions, UpdateHandlers, UpdateState, SignedManifest, UpdateApplyResult, UpdateSettings, UpdateManifest, UpdateErrorCode, ManifestFields, NpmExecutor, ServiceRestarter, } from './update/index.js';
|
|
37
|
-
export { NatService, NatStore, NatError, createNatHandlers, ExternalIpDetector,
|
|
38
|
-
export type { NatServiceOptions,
|
|
25
|
+
export { NatService, NatStore, NatError, createNatHandlers, NAT_UNMAP_GRACE_MS, NAT_RECONCILE_INTERVAL_MS, NAT_IP_REDETECT_INTERVAL_MS, ExternalIpDetector, UpnpPortMapper, pickLanAddress, evaluateNodeReachability, evaluateHostReachability, buildPublicAddresses, isPublicIpv4, BUILTIN_PROVIDERS, getProvider, listProviders, duckDnsProvider, DdnsUpdater, KeytarSecretsStore, FileSecretsStore, createSecretsStore, ddnsAccount, KEYTAR_SERVICE, DEFAULT_LEASE_TTL_MS, DEFAULT_REFRESH_MS, GATEWAY_DISCOVERY_TIMEOUT_MS, isPlausibleIp, } from './nat/index.js';
|
|
26
|
+
export type { NatServiceOptions, NatNodeSource, NatChangeListener, NodeAddressesStaleListener, NatStatusSnapshot, NatGatewayStatus, NatDdnsStatus, NatSettingsFile, NatDdnsSettings, NatHandlers, NatErrorCode, DirectReachability, NodeReachability, NodeVerdict, PortKind, PortRoute, PortRouteSource, ManualForward, ManualForwardPatch, DdnsProviderInfo, DdnsConfigField, ExternalIpResult, RouterIpProbe, ExternalIpDetectorOptions, PortMapper, GatewayInfo, PortMapRequest, PortMapResult, NodeVerdictInput, NodeVerdictResult, PublicAddressInput, DdnsProvider, DdnsProviderDeps, DdnsUpdaterOptions, DdnsUpdateOutcome, SecretsStore, KeytarLike, } from './nat/index.js';
|
|
39
27
|
export { createLocalUiServer, EventBus, HostSettingsStore, } from './server/index.js';
|
|
40
|
-
export type {
|
|
28
|
+
export type { LocalUiServer, LocalUiServerOptions, LocalUiEvent, LocalUiEventType, LocalUiEventListener, } from './server/index.js';
|
package/dist/index.js
CHANGED
|
@@ -4,31 +4,21 @@
|
|
|
4
4
|
* This package is the sibling of @serfab/cadre-provider for self-hosted
|
|
5
5
|
* basement-PC deployments. It depends on @serfab/cadre-provider for the
|
|
6
6
|
* orchestration interface and container lifecycle types but ships its own
|
|
7
|
-
* orchestrator (host processes, not Docker),
|
|
8
|
-
*
|
|
7
|
+
* orchestrator (host processes, not Docker), the hosted-node service behind
|
|
8
|
+
* "Join a cadre", installer, NAT layer, and local management UI.
|
|
9
9
|
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
* under src
|
|
13
|
-
*
|
|
14
|
-
* - cadre-host-process-orchestrator [DONE]
|
|
15
|
-
* - cadre-host-trust-circle [DONE]
|
|
16
|
-
* - cadre-host-nat
|
|
17
|
-
* - cadre-host-installer
|
|
18
|
-
* - cadre-host-local-ui
|
|
10
|
+
* HostProcessOrchestrator, the hosted-node layer, the NAT layer, the
|
|
11
|
+
* installer, and the local UI server each live in a sibling subdirectory
|
|
12
|
+
* under src/.
|
|
19
13
|
*/
|
|
20
|
-
export { HostProcessOrchestrator
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
/* ──────────────── strand management ──────────────── */
|
|
24
|
-
export { StrandService, StrandError, createStrandHandlers } from './strands/index.js';
|
|
25
|
-
/* ──────────────── donation grant tokens ──────────────── */
|
|
26
|
-
export { GrantStore, GrantService, createGrantAdminHandlers, GrantError, DEFAULT_MAX_NODES, DonationStore, DonationService, DonationError, } from './donation/index.js';
|
|
14
|
+
export { HostProcessOrchestrator } from './orchestrator/index.js';
|
|
15
|
+
/* ──────────────── hosted nodes ("Join a cadre") ──────────────── */
|
|
16
|
+
export { HostedNodeStore, HostedNodeService, HostedNodeSupervisor, HostedNodeError, HOSTED_NODE_SPAWNING_TTL_MS, HOSTED_NODE_REAP_SWEEP_MS, HOSTED_NODE_CLAIM_POLL_MS, HOSTED_NODE_CONNECTED_POLL_MS, HOSTED_NODE_RESPAWN_BACKOFF_BASE_MS, HOSTED_NODE_RESPAWN_BACKOFF_MAX_MS, HOSTED_NODE_RESPAWN_MAX_ATTEMPTS, HOSTED_NODE_RESPAWN_HEALTHY_MS, HOSTED_NODE_RESPAWN_SWEEP_MS, PLACEHOLDER_PARTY, } from './hosted/index.js';
|
|
27
17
|
export { Installer, readHostConfig, updateHostConfig, writeHostConfig } from './installer/index.js';
|
|
28
18
|
/* ──────────────── push credentials (FCM/APNs) ──────────────── */
|
|
29
19
|
export { resolvePushCredentials, setFcmSecret, setApnsSecret, clearPushSecret, pushAccount, pushStatus, } from './push/index.js';
|
|
30
20
|
export { UpdateService, createUpdateHandlers, UpdateStateStore, UpdateErrorException, applyUpdate, defaultNpmExecutor, fetchManifest, verifyManifest, canonicalJson, signManifest, validateManifestFields, buildManifest, derivePublicKeyBase64, signAndSelfVerify, compareVersions, parseVersion, getReleasePublicKey, getReleasePublicKeyBase64, ed25519FromRaw, isPlaceholderReleaseKey, } from './update/index.js';
|
|
31
|
-
export { NatService, NatStore, NatError, createNatHandlers, ExternalIpDetector,
|
|
21
|
+
export { NatService, NatStore, NatError, createNatHandlers, NAT_UNMAP_GRACE_MS, NAT_RECONCILE_INTERVAL_MS, NAT_IP_REDETECT_INTERVAL_MS, ExternalIpDetector, UpnpPortMapper, pickLanAddress, evaluateNodeReachability, evaluateHostReachability, buildPublicAddresses, isPublicIpv4, BUILTIN_PROVIDERS, getProvider, listProviders, duckDnsProvider, DdnsUpdater, KeytarSecretsStore, FileSecretsStore, createSecretsStore, ddnsAccount, KEYTAR_SERVICE, DEFAULT_LEASE_TTL_MS, DEFAULT_REFRESH_MS, GATEWAY_DISCOVERY_TIMEOUT_MS, isPlausibleIp, } from './nat/index.js';
|
|
32
22
|
/* ──────────────── local UI server (6.5.1) ──────────────── */
|
|
33
23
|
export { createLocalUiServer, EventBus, HostSettingsStore, } from './server/index.js';
|
|
34
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAWH,OAAO,EAAE,uBAAuB,EAAE,MAAM,yBAAyB,CAAC;AAUlE,qEAAqE;AAErE,OAAO,EACL,eAAe,EACf,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EACf,2BAA2B,EAC3B,yBAAyB,EACzB,yBAAyB,EACzB,6BAA6B,EAC7B,mCAAmC,EACnC,kCAAkC,EAClC,gCAAgC,EAChC,8BAA8B,EAC9B,4BAA4B,EAC5B,iBAAiB,GAClB,MAAM,mBAAmB,CAAC;AAyB3B,OAAO,EAAE,SAAS,EAAE,cAAc,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAepG,mEAAmE;AAEnE,OAAO,EACL,sBAAsB,EACtB,YAAY,EACZ,aAAa,EACb,eAAe,EACf,WAAW,EACX,UAAU,GACX,MAAM,iBAAiB,CAAC;AAQzB,OAAO,EACL,aAAa,EACb,oBAAoB,EACpB,gBAAgB,EAChB,oBAAoB,EACpB,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,cAAc,EACd,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,aAAa,EACb,qBAAqB,EACrB,iBAAiB,EACjB,eAAe,EACf,YAAY,EACZ,mBAAmB,EACnB,yBAAyB,EACzB,cAAc,EACd,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAe3B,OAAO,EACL,UAAU,EACV,QAAQ,EACR,QAAQ,EACR,iBAAiB,EACjB,kBAAkB,EAClB,yBAAyB,EACzB,2BAA2B,EAC3B,kBAAkB,EAClB,cAAc,EACd,cAAc,EACd,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EACpB,YAAY,EACZ,iBAAiB,EACjB,WAAW,EACX,aAAa,EACb,eAAe,EACf,WAAW,EACX,kBAAkB,EAClB,gBAAgB,EAChB,kBAAkB,EAClB,WAAW,EACX,cAAc,EACd,oBAAoB,EACpB,kBAAkB,EAClB,4BAA4B,EAC5B,aAAa,GACd,MAAM,gBAAgB,CAAC;AAyCxB,+DAA+D;AAE/D,OAAO,EACL,mBAAmB,EACnB,QAAQ,EACR,iBAAiB,GAClB,MAAM,mBAAmB,CAAC"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `host.config.json` schema + I/O.
|
|
3
3
|
*
|
|
4
|
-
* This file captures the wizard's output. Subsystems (
|
|
4
|
+
* This file captures the wizard's output. Subsystems (hosted nodes, NAT,
|
|
5
5
|
* orchestrator) each own their own files under `<dataDir>/`; this is NOT
|
|
6
6
|
* an umbrella config.
|
|
7
7
|
*
|
|
8
|
-
* Schema version:
|
|
8
|
+
* Schema version: 3. `version` is a forward guard — a file whose version
|
|
9
9
|
* does not match `CURRENT_VERSION` is rejected on read rather than
|
|
10
10
|
* reinterpreted, so a future incompatible layout fails loudly instead of
|
|
11
11
|
* being silently misread.
|
|
@@ -16,20 +16,6 @@ export interface UpdatesConfig {
|
|
|
16
16
|
/** Optional override for the manifest URL (env var still wins). */
|
|
17
17
|
manifestUrl?: string;
|
|
18
18
|
}
|
|
19
|
-
/**
|
|
20
|
-
* Whether this host also runs its own personal cadre (the opt-in "founder"
|
|
21
|
-
* persona), on top of the always-on node-donor role.
|
|
22
|
-
*
|
|
23
|
-
* Default (absent or `enabled: false`) is donor-only: `cadre-host start` brings
|
|
24
|
-
* up the donation surface but spawns **no** owner node, so the trust-circle and
|
|
25
|
-
* NAT surfaces stay inactive. Set `enabled: true` (install-time choice) to also
|
|
26
|
-
* spawn the host's own owner node and enable `/auth` + `/nat`. See
|
|
27
|
-
* docs/cadre-host.md § Two roles: donor and founder.
|
|
28
|
-
*/
|
|
29
|
-
export interface OwnCadreConfig {
|
|
30
|
-
/** When true, `start` spawns the host-owned owner node + trust-circle + NAT. */
|
|
31
|
-
enabled: boolean;
|
|
32
|
-
}
|
|
33
19
|
/**
|
|
34
20
|
* Non-secret push (FCM/APNs) settings. The actual private keys (and the FCM
|
|
35
21
|
* service-account / APNs key identifiers) live in the secret store — see
|
|
@@ -49,18 +35,35 @@ export interface PushSettings {
|
|
|
49
35
|
/** Per-strand burst-coalescing window (ms) forwarded into the node's push block. */
|
|
50
36
|
debounceMs?: number;
|
|
51
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Which addresses a hosted node's QR code carries (cadre-core's `selectNodeClaimAddresses`).
|
|
40
|
+
* Absent ⇒ `{ lan: 'auto' }`. Read on every claim-code request, so an edit applies to the
|
|
41
|
+
* next code shown.
|
|
42
|
+
*/
|
|
43
|
+
export interface ClaimAddressSettings {
|
|
44
|
+
/**
|
|
45
|
+
* The LAN address a phone at home dials: `'auto'` (the address on the router's subnet, else
|
|
46
|
+
* the machine's primary one; none in public-IP mode), `'none'` (public addresses only), or an
|
|
47
|
+
* IP address. Other private addresses (Docker bridges, VPNs) are left out either way.
|
|
48
|
+
*/
|
|
49
|
+
lan?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Exact addresses to put in every code instead, for an operator who knows better than the
|
|
52
|
+
* rule, such as one name behind a proxy. Each names no destination peer (a relay address ends
|
|
53
|
+
* at its `/p2p-circuit` hop); every node's code appends its own peer id.
|
|
54
|
+
*/
|
|
55
|
+
addrs?: string[];
|
|
56
|
+
}
|
|
57
|
+
/** Why a `claimAddresses` value is unacceptable, naming the field; undefined when it is fine. */
|
|
58
|
+
export declare function claimAddressSettingsProblem(value: unknown): string | undefined;
|
|
52
59
|
export interface HostConfigFile {
|
|
53
|
-
version:
|
|
54
|
-
/** A stable per-install id
|
|
60
|
+
version: 3;
|
|
61
|
+
/** A stable per-install id, for log correlation. */
|
|
55
62
|
installId: string;
|
|
56
63
|
/** Localhost-only management UI + API listener port. */
|
|
57
64
|
uiPort: number;
|
|
58
|
-
/** External cadre libp2p port (NAT will map to this). */
|
|
59
|
-
libp2pPort: number;
|
|
60
65
|
/** Self-reference (convenient for service-host ExecStart). */
|
|
61
66
|
dataDir: string;
|
|
62
|
-
/** Absolute path to the Ed25519 protobuf identity. */
|
|
63
|
-
identityPath: string;
|
|
64
67
|
/** Whether UPnP/NAT-PMP should be attempted at start time. */
|
|
65
68
|
upnpEnabled: boolean;
|
|
66
69
|
/** ISO timestamp the wizard wrote this file. */
|
|
@@ -69,25 +72,15 @@ export interface HostConfigFile {
|
|
|
69
72
|
installerVersion: string;
|
|
70
73
|
/** Update-flow settings; defaults: { autoApply: false }. */
|
|
71
74
|
updates: UpdatesConfig;
|
|
72
|
-
/**
|
|
73
|
-
* Host-own-cadre (founder persona) opt-in. Optional — absent is treated as
|
|
74
|
-
* `{ enabled: false }` (donor-only). Written by the installer; read via
|
|
75
|
-
* `hostOwnsCadre()`. Not editable through /api/settings (install-time only).
|
|
76
|
-
*/
|
|
77
|
-
ownCadre?: OwnCadreConfig;
|
|
78
75
|
/**
|
|
79
76
|
* Non-secret push settings (bundle id, sandbox/prod toggle, cooldown/debounce).
|
|
80
77
|
* Optional — absent when push is not configured. Private keys never live here;
|
|
81
78
|
* they are read from the secret store at node-spawn time (`src/push/`).
|
|
82
79
|
*/
|
|
83
80
|
push?: PushSettings;
|
|
81
|
+
/** Which addresses claim codes carry; absent ⇒ automatic. */
|
|
82
|
+
claimAddresses?: ClaimAddressSettings;
|
|
84
83
|
}
|
|
85
|
-
/**
|
|
86
|
-
* Whether this host runs its own personal cadre (founder persona). Absent
|
|
87
|
-
* `ownCadre` ⇒ donor-only (false). The single source of truth for the
|
|
88
|
-
* founder/donor gate in `bin/host.ts start`.
|
|
89
|
-
*/
|
|
90
|
-
export declare function hostOwnsCadre(cfg: HostConfigFile): boolean;
|
|
91
84
|
export declare function writeHostConfig(filePath: string, cfg: HostConfigFile): void;
|
|
92
85
|
/** Apply a partial patch to the persisted config (read-modify-write). */
|
|
93
86
|
export declare function updateHostConfig(filePath: string, patch: Partial<Omit<HostConfigFile, 'version'>>): HostConfigFile;
|
package/dist/installer/config.js
CHANGED
|
@@ -1,26 +1,61 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* `host.config.json` schema + I/O.
|
|
3
3
|
*
|
|
4
|
-
* This file captures the wizard's output. Subsystems (
|
|
4
|
+
* This file captures the wizard's output. Subsystems (hosted nodes, NAT,
|
|
5
5
|
* orchestrator) each own their own files under `<dataDir>/`; this is NOT
|
|
6
6
|
* an umbrella config.
|
|
7
7
|
*
|
|
8
|
-
* Schema version:
|
|
8
|
+
* Schema version: 3. `version` is a forward guard — a file whose version
|
|
9
9
|
* does not match `CURRENT_VERSION` is rejected on read rather than
|
|
10
10
|
* reinterpreted, so a future incompatible layout fails loudly instead of
|
|
11
11
|
* being silently misread.
|
|
12
12
|
*/
|
|
13
13
|
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
|
|
14
|
+
import { isIP } from 'node:net';
|
|
14
15
|
import { dirname } from 'node:path';
|
|
16
|
+
import { destinationPeerIdOf } from '@serfab/cadre-core';
|
|
17
|
+
/** Why a `claimAddresses` value is unacceptable, naming the field; undefined when it is fine. */
|
|
18
|
+
export function claimAddressSettingsProblem(value) {
|
|
19
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
20
|
+
return '"claimAddresses" must be an object';
|
|
21
|
+
const o = value;
|
|
22
|
+
for (const key of Object.keys(o)) {
|
|
23
|
+
if (key !== 'lan' && key !== 'addrs')
|
|
24
|
+
return `Unknown setting "claimAddresses.${key}"`;
|
|
25
|
+
}
|
|
26
|
+
if (o.lan !== undefined) {
|
|
27
|
+
if (typeof o.lan !== 'string' || (o.lan !== 'auto' && o.lan !== 'none' && isIP(o.lan) === 0)) {
|
|
28
|
+
return '"claimAddresses.lan" must be "auto", "none" or an IP address';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
if (o.addrs !== undefined) {
|
|
32
|
+
if (!Array.isArray(o.addrs) || !o.addrs.every((a) => typeof a === 'string')) {
|
|
33
|
+
return '"claimAddresses.addrs" must be a list of multiaddr strings';
|
|
34
|
+
}
|
|
35
|
+
for (const addr of o.addrs) {
|
|
36
|
+
const problem = exactClaimAddressProblem(addr);
|
|
37
|
+
if (problem)
|
|
38
|
+
return `"claimAddresses.addrs" entry "${addr}" ${problem}`;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
return undefined;
|
|
42
|
+
}
|
|
15
43
|
/**
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
44
|
+
* Why one `claimAddresses.addrs` entry is unacceptable. It must not name its destination peer:
|
|
45
|
+
* the list is host-wide and each hosted node's code appends its own peer id, so a named one
|
|
46
|
+
* would be some other node's address in every code but that node's.
|
|
19
47
|
*/
|
|
20
|
-
|
|
21
|
-
|
|
48
|
+
function exactClaimAddressProblem(addr) {
|
|
49
|
+
let destination;
|
|
50
|
+
try {
|
|
51
|
+
destination = destinationPeerIdOf(addr.trim());
|
|
52
|
+
}
|
|
53
|
+
catch {
|
|
54
|
+
return 'is not a valid multiaddr';
|
|
55
|
+
}
|
|
56
|
+
return destination === null ? undefined : 'must not end in /p2p/<peer id>: each node\'s own id is appended';
|
|
22
57
|
}
|
|
23
|
-
const CURRENT_VERSION =
|
|
58
|
+
const CURRENT_VERSION = 3;
|
|
24
59
|
export function writeHostConfig(filePath, cfg) {
|
|
25
60
|
if (cfg.version !== CURRENT_VERSION) {
|
|
26
61
|
throw new Error(`Refusing to write host.config.json with version=${cfg.version} (current: ${CURRENT_VERSION})`);
|
|
@@ -59,6 +94,9 @@ export function readHostConfig(filePath) {
|
|
|
59
94
|
if (!isHostConfigShape(obj)) {
|
|
60
95
|
throw new Error(`host.config.json at ${filePath} is missing required fields`);
|
|
61
96
|
}
|
|
97
|
+
const claimAddressesProblem = obj.claimAddresses === undefined ? undefined : claimAddressSettingsProblem(obj.claimAddresses);
|
|
98
|
+
if (claimAddressesProblem)
|
|
99
|
+
throw new Error(`host.config.json at ${filePath}: ${claimAddressesProblem}`);
|
|
62
100
|
return obj;
|
|
63
101
|
}
|
|
64
102
|
function isHostConfigShape(v) {
|
|
@@ -67,9 +105,7 @@ function isHostConfigShape(v) {
|
|
|
67
105
|
const o = v;
|
|
68
106
|
if (typeof o.installId !== 'string' ||
|
|
69
107
|
typeof o.uiPort !== 'number' ||
|
|
70
|
-
typeof o.libp2pPort !== 'number' ||
|
|
71
108
|
typeof o.dataDir !== 'string' ||
|
|
72
|
-
typeof o.identityPath !== 'string' ||
|
|
73
109
|
typeof o.upnpEnabled !== 'boolean' ||
|
|
74
110
|
typeof o.installedAt !== 'string' ||
|
|
75
111
|
typeof o.installerVersion !== 'string') {
|
|
@@ -82,11 +118,6 @@ function isHostConfigShape(v) {
|
|
|
82
118
|
return false;
|
|
83
119
|
if (updates.manifestUrl !== undefined && typeof updates.manifestUrl !== 'string')
|
|
84
120
|
return false;
|
|
85
|
-
if (o.ownCadre !== undefined) {
|
|
86
|
-
const own = o.ownCadre;
|
|
87
|
-
if (!own || typeof own !== 'object' || typeof own.enabled !== 'boolean')
|
|
88
|
-
return false;
|
|
89
|
-
}
|
|
90
121
|
return true;
|
|
91
122
|
}
|
|
92
123
|
//# sourceMappingURL=config.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/installer/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/installer/config.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,OAAO,EAAE,SAAS,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AACjE,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAEpC,OAAO,EAAE,mBAAmB,EAAE,MAAM,oBAAoB,CAAC;AAiDzD,iGAAiG;AACjG,MAAM,UAAU,2BAA2B,CAAC,KAAc;IACxD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,oCAAoC,CAAC;IAC7G,MAAM,CAAC,GAAG,KAAgC,CAAC;IAC3C,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;QACjC,IAAI,GAAG,KAAK,KAAK,IAAI,GAAG,KAAK,OAAO;YAAE,OAAO,mCAAmC,GAAG,GAAG,CAAC;IACzF,CAAC;IACD,IAAI,CAAC,CAAC,GAAG,K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IAAI,OAAO,OAAO,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC1D,IAAI,OAAO,OAAO,CAAC,SAAS,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACzD,IAAI,OAAO,CAAC,WAAW,KAAK,SAAS,IAAI,OAAO,OAAO,CAAC,WAAW,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC/F,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* `tickets/implement/6.4.1-cadre-host-installer.md`.
|
|
6
6
|
*
|
|
7
7
|
* The class is purposefully thin — heavy lifting lives in the focused
|
|
8
|
-
* subsystem modules (wizard.ts,
|
|
9
|
-
*
|
|
8
|
+
* subsystem modules (wizard.ts, config.ts, service-host/{systemd,launchd,nssm}.ts,
|
|
9
|
+
* browser.ts).
|
|
10
10
|
*/
|
|
11
11
|
import { type SupportedPlatform } from './platform.js';
|
|
12
12
|
import { type ServiceHost } from './service-host/index.js';
|
|
13
|
-
import { defaultsForPlatform, runWizard, runWizardWith, DEFAULT_UI_PORT,
|
|
13
|
+
import { defaultsForPlatform, runWizard, runWizardWith, DEFAULT_UI_PORT, type WizardAnswers, type WizardDefaults } from './wizard.js';
|
|
14
14
|
export type { HostConfigFile, PushSettings } from './config.js';
|
|
15
15
|
export { readHostConfig, updateHostConfig, writeHostConfig } from './config.js';
|
|
16
16
|
export type { WizardAnswers, WizardDefaults } from './wizard.js';
|
|
@@ -22,31 +22,26 @@ export interface InstallOptions {
|
|
|
22
22
|
dataDir?: string;
|
|
23
23
|
/** Override the UI port. */
|
|
24
24
|
uiPort?: number;
|
|
25
|
-
/** Override the libp2p port. */
|
|
26
|
-
libp2pPort?: number;
|
|
27
25
|
/** Disable UPnP probing on first run. */
|
|
28
26
|
noUpnp?: boolean;
|
|
29
|
-
/** Also run the host's own personal cadre here (founder persona). Default false. */
|
|
30
|
-
ownCadre?: boolean;
|
|
31
27
|
/** Open browser at end (default true; suppressed by --no-browser or non-TTY). */
|
|
32
28
|
openBrowser?: boolean;
|
|
33
|
-
/** Skip the enrollment-invite step (no QR printed). */
|
|
34
|
-
noInvite?: boolean;
|
|
35
29
|
/** System-wide install — v1 emits a not-yet-supported error. */
|
|
36
30
|
system?: boolean;
|
|
37
31
|
/** Path to node.exe / node binary used by the service-host unit. */
|
|
38
32
|
nodePath?: string;
|
|
39
33
|
/**
|
|
40
|
-
* Write the data dir (
|
|
34
|
+
* Write the data dir (config, NAT seed) but register no OS service.
|
|
41
35
|
* The host is then run by hand with `cadre-host start`. Nothing is listening
|
|
42
|
-
* after such an install, so the browser-open
|
|
43
|
-
* skipped too.
|
|
36
|
+
* after such an install, so the browser-open step is skipped too.
|
|
44
37
|
*/
|
|
45
38
|
noService?: boolean;
|
|
46
39
|
/** Test-only: stub the service-host registration. */
|
|
47
40
|
serviceHost?: ServiceHost;
|
|
48
41
|
/** Test-only: stub the interactive wizard. Production callers leave unset. */
|
|
49
42
|
wizard?: (defaults: WizardDefaults) => Promise<WizardAnswers>;
|
|
43
|
+
/** Test-only: stub the interface read that decides whether to ask about UPnP. */
|
|
44
|
+
publicInterfaceAddress?: () => string | null;
|
|
50
45
|
}
|
|
51
46
|
export interface InstallResult {
|
|
52
47
|
dataDir: string;
|
|
@@ -55,14 +50,9 @@ export interface InstallResult {
|
|
|
55
50
|
serviceName?: string;
|
|
56
51
|
/** Path to the rendered config file. */
|
|
57
52
|
configPath: string;
|
|
58
|
-
/** Generated enrollment invite, unless --no-invite. */
|
|
59
|
-
enrollmentInvite?: {
|
|
60
|
-
encodedInvite: string;
|
|
61
|
-
expiresAt?: string;
|
|
62
|
-
};
|
|
63
53
|
}
|
|
64
54
|
export interface UninstallOptions {
|
|
65
|
-
/** Also remove the data dir (default false — preserve
|
|
55
|
+
/** Also remove the data dir (default false — preserve hosted-node records, node identities and NAT state). */
|
|
66
56
|
removeData: boolean;
|
|
67
57
|
/** Skip the confirmation prompt (for scripts). */
|
|
68
58
|
yes: boolean;
|
|
@@ -92,5 +82,5 @@ export declare class Installer {
|
|
|
92
82
|
resolveAnswersFromOptions(opts: InstallOptions): WizardAnswers;
|
|
93
83
|
private resolveAnswers;
|
|
94
84
|
}
|
|
95
|
-
export { runWizardWith, defaultsForPlatform, DEFAULT_UI_PORT
|
|
85
|
+
export { runWizardWith, defaultsForPlatform, DEFAULT_UI_PORT };
|
|
96
86
|
export { runWizard };
|
package/dist/installer/index.js
CHANGED
|
@@ -5,26 +5,26 @@
|
|
|
5
5
|
* `tickets/implement/6.4.1-cadre-host-installer.md`.
|
|
6
6
|
*
|
|
7
7
|
* The class is purposefully thin — heavy lifting lives in the focused
|
|
8
|
-
* subsystem modules (wizard.ts,
|
|
9
|
-
*
|
|
8
|
+
* subsystem modules (wizard.ts, config.ts, service-host/{systemd,launchd,nssm}.ts,
|
|
9
|
+
* browser.ts).
|
|
10
10
|
*/
|
|
11
|
-
import { existsSync, mkdirSync,
|
|
11
|
+
import { existsSync, mkdirSync, rmSync } from 'node:fs';
|
|
12
12
|
import { randomBytes } from 'node:crypto';
|
|
13
13
|
import debug from 'debug';
|
|
14
|
-
import { NatStore } from '../nat/index.js';
|
|
14
|
+
import { NatStore, publicInterfaceAddress } from '../nat/index.js';
|
|
15
|
+
import { packageVersion } from '../package-version.js';
|
|
15
16
|
import { openBrowser } from './browser.js';
|
|
16
17
|
import { writeHostConfig } from './config.js';
|
|
17
|
-
import {
|
|
18
|
-
import { configPath, defaultHostJs, defaultServiceDir, identityPath, logsDir, } from './paths.js';
|
|
18
|
+
import { configPath, defaultHostJs, defaultServiceDir, logsDir, } from './paths.js';
|
|
19
19
|
import { detectPlatform, } from './platform.js';
|
|
20
20
|
import { createServiceHost } from './service-host/index.js';
|
|
21
|
-
import { defaultsForPlatform, runWizard, runWizardWith, DEFAULT_UI_PORT,
|
|
21
|
+
import { defaultsForPlatform, runWizard, runWizardWith, DEFAULT_UI_PORT, } from './wizard.js';
|
|
22
22
|
export { readHostConfig, updateHostConfig, writeHostConfig } from './config.js';
|
|
23
23
|
const log = debug('cadre:host:installer');
|
|
24
24
|
export class Installer {
|
|
25
25
|
constructor(opts = {}) {
|
|
26
26
|
this.platform = opts.platform ?? detectPlatform();
|
|
27
|
-
this.installerVersion = opts.installerVersion ??
|
|
27
|
+
this.installerVersion = opts.installerVersion ?? packageVersion;
|
|
28
28
|
}
|
|
29
29
|
async install(opts) {
|
|
30
30
|
if (opts.system) {
|
|
@@ -36,37 +36,27 @@ export class Installer {
|
|
|
36
36
|
// 2. Make sure the data dir exists.
|
|
37
37
|
mkdirSync(answers.dataDir, { recursive: true });
|
|
38
38
|
mkdirSync(logsDir(answers.dataDir), { recursive: true });
|
|
39
|
-
// 3.
|
|
40
|
-
// install on a populated data dir must preserve the host's peer ID.
|
|
41
|
-
const idPath = identityPath(answers.dataDir);
|
|
42
|
-
if (existsSync(idPath)) {
|
|
43
|
-
log('identity already exists at %s — leaving it', idPath);
|
|
44
|
-
}
|
|
45
|
-
else {
|
|
46
|
-
await generateIdentity(idPath);
|
|
47
|
-
}
|
|
39
|
+
// 3. Config.
|
|
48
40
|
const cfg = {
|
|
49
|
-
version:
|
|
41
|
+
version: 3,
|
|
50
42
|
installId: randomInstallId(),
|
|
51
43
|
uiPort: answers.uiPort,
|
|
52
|
-
libp2pPort: answers.libp2pPort,
|
|
53
44
|
dataDir: answers.dataDir,
|
|
54
|
-
identityPath: idPath,
|
|
55
45
|
upnpEnabled: answers.upnpEnabled,
|
|
56
46
|
installedAt: new Date().toISOString(),
|
|
57
47
|
installerVersion: this.installerVersion,
|
|
58
48
|
updates: { autoApply: false },
|
|
59
|
-
ownCadre: { enabled: answers.ownCadre },
|
|
60
49
|
};
|
|
61
50
|
const cfgPath = configPath(answers.dataDir);
|
|
62
51
|
writeHostConfig(cfgPath, cfg);
|
|
63
|
-
// 4. Seed nat.json with the
|
|
64
|
-
//
|
|
65
|
-
|
|
52
|
+
// 4. Seed nat.json with the UPnP flag so the NatService picks it up on
|
|
53
|
+
// first start. Ports are not seeded: the service maps every hosted
|
|
54
|
+
// node's ports from the orchestrator's allocations.
|
|
55
|
+
seedNatSettings(answers.dataDir, answers.upnpEnabled);
|
|
66
56
|
const uiUrl = `http://127.0.0.1:${answers.uiPort}/`;
|
|
67
57
|
// 5. Service-host registration.
|
|
68
58
|
if (opts.noService) {
|
|
69
|
-
log('--no-service: skipping service registration
|
|
59
|
+
log('--no-service: skipping service registration and browser open');
|
|
70
60
|
return { dataDir: answers.dataDir, uiUrl, configPath: cfgPath };
|
|
71
61
|
}
|
|
72
62
|
const serviceHost = opts.serviceHost ?? createServiceHost(this.platform);
|
|
@@ -82,20 +72,11 @@ export class Installer {
|
|
|
82
72
|
if (shouldOpenBrowser) {
|
|
83
73
|
openBrowser(uiUrl);
|
|
84
74
|
}
|
|
85
|
-
// 7. Enrollment invite (best-effort — the listener may not be up yet).
|
|
86
|
-
let invite;
|
|
87
|
-
if (!opts.noInvite && !opts.nonInteractive) {
|
|
88
|
-
invite = await fetchEnrollmentInvite(answers.uiPort).catch((err) => {
|
|
89
|
-
log('enrollment-invite fetch failed: %s', err.message);
|
|
90
|
-
return undefined;
|
|
91
|
-
});
|
|
92
|
-
}
|
|
93
75
|
return {
|
|
94
76
|
dataDir: answers.dataDir,
|
|
95
77
|
uiUrl,
|
|
96
78
|
serviceName: serviceHost.name,
|
|
97
79
|
configPath: cfgPath,
|
|
98
|
-
...(invite ? { enrollmentInvite: invite } : {}),
|
|
99
80
|
};
|
|
100
81
|
}
|
|
101
82
|
async uninstall(opts) {
|
|
@@ -131,10 +112,7 @@ export class Installer {
|
|
|
131
112
|
return {
|
|
132
113
|
dataDir: opts.dataDir ?? defaults.dataDir,
|
|
133
114
|
uiPort: opts.uiPort ?? defaults.uiPort,
|
|
134
|
-
libp2pPort: opts.libp2pPort ?? defaults.libp2pPort,
|
|
135
115
|
upnpEnabled: opts.noUpnp ? false : defaults.upnpEnabled,
|
|
136
|
-
configureDdns: false,
|
|
137
|
-
ownCadre: opts.ownCadre ?? defaults.ownCadre,
|
|
138
116
|
};
|
|
139
117
|
}
|
|
140
118
|
async resolveAnswers(opts) {
|
|
@@ -150,66 +128,24 @@ export class Installer {
|
|
|
150
128
|
const defaults = {
|
|
151
129
|
dataDir: opts.dataDir ?? platformDefaults.dataDir,
|
|
152
130
|
uiPort: opts.uiPort ?? platformDefaults.uiPort,
|
|
153
|
-
libp2pPort: opts.libp2pPort ?? platformDefaults.libp2pPort,
|
|
154
131
|
upnpEnabled: opts.noUpnp ? false : platformDefaults.upnpEnabled,
|
|
155
|
-
|
|
132
|
+
// A flag answers its question: the wizard asks only for what the command line left open.
|
|
133
|
+
given: { dataDir: opts.dataDir !== undefined, uiPort: opts.uiPort !== undefined, upnpEnabled: opts.noUpnp === true },
|
|
134
|
+
publicInterfaceIp: (opts.publicInterfaceAddress ?? publicInterfaceAddress)(),
|
|
156
135
|
};
|
|
157
136
|
const wizard = opts.wizard ?? runWizard;
|
|
158
137
|
return await wizard(defaults);
|
|
159
138
|
}
|
|
160
139
|
}
|
|
161
|
-
export { runWizardWith, defaultsForPlatform, DEFAULT_UI_PORT
|
|
162
|
-
function seedNatSettings(dataDir,
|
|
140
|
+
export { runWizardWith, defaultsForPlatform, DEFAULT_UI_PORT };
|
|
141
|
+
function seedNatSettings(dataDir, upnpEnabled) {
|
|
163
142
|
const store = new NatStore(dataDir);
|
|
164
143
|
// `update()` merges + persists.
|
|
165
|
-
store.update({
|
|
166
|
-
externalPort: libp2pPort,
|
|
167
|
-
internalPort: libp2pPort,
|
|
168
|
-
upnpEnabled,
|
|
169
|
-
});
|
|
144
|
+
store.update({ upnpEnabled });
|
|
170
145
|
}
|
|
171
146
|
function randomInstallId() {
|
|
172
147
|
return randomBytes(16).toString('hex');
|
|
173
148
|
}
|
|
174
|
-
function readPackageVersion() {
|
|
175
|
-
// Best-effort: read the package.json next to dist/ at runtime.
|
|
176
|
-
try {
|
|
177
|
-
const here = new URL('../../package.json', import.meta.url);
|
|
178
|
-
const raw = readFileSync(here, 'utf8');
|
|
179
|
-
const parsed = JSON.parse(raw);
|
|
180
|
-
return parsed.version ?? '0.0.0-unknown';
|
|
181
|
-
}
|
|
182
|
-
catch {
|
|
183
|
-
return '0.0.0-unknown';
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
async function fetchEnrollmentInvite(uiPort) {
|
|
187
|
-
const url = `http://127.0.0.1:${uiPort}/auth/invites`;
|
|
188
|
-
// Node 18+'s fetch has no default timeout. Bound it so a slow / hung
|
|
189
|
-
// local-UI listener can't wedge `cadre-host install` indefinitely.
|
|
190
|
-
const controller = new AbortController();
|
|
191
|
-
const timer = setTimeout(() => controller.abort(), 5000);
|
|
192
|
-
try {
|
|
193
|
-
const response = await fetch(url, {
|
|
194
|
-
method: 'POST',
|
|
195
|
-
headers: { 'content-type': 'application/json' },
|
|
196
|
-
body: JSON.stringify({ label: 'Install — first device', ttlMs: 24 * 60 * 60 * 1000 }),
|
|
197
|
-
signal: controller.signal,
|
|
198
|
-
});
|
|
199
|
-
if (!response.ok)
|
|
200
|
-
return undefined;
|
|
201
|
-
const body = await response.json();
|
|
202
|
-
if (!body.encodedInvite)
|
|
203
|
-
return undefined;
|
|
204
|
-
return {
|
|
205
|
-
encodedInvite: body.encodedInvite,
|
|
206
|
-
...(body.expiresAt ? { expiresAt: body.expiresAt } : {}),
|
|
207
|
-
};
|
|
208
|
-
}
|
|
209
|
-
finally {
|
|
210
|
-
clearTimeout(timer);
|
|
211
|
-
}
|
|
212
|
-
}
|
|
213
149
|
// Exposed for tests that drive the wizard with a custom prompt fn.
|
|
214
150
|
export { runWizard };
|
|
215
151
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/installer/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../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