@camstack/server 1.2.143 → 1.2.145
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/api/trpc/generated-cap-routers.js +48 -0
- package/dist/boot/boot-config.js +28 -10
- package/dist/boot/post-boot.service.js +25 -1
- package/dist/main.js +22 -2
- package/package.json +13 -13
|
@@ -4361,6 +4361,45 @@ function createCapRouter_localNetwork(getProvider, createRemoteProxy) {
|
|
|
4361
4361
|
const p = resolveProvider('local-network', input?.nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
4362
4362
|
return p.resetAllowlistToBestMatch();
|
|
4363
4363
|
}),
|
|
4364
|
+
getTlsStatus: trpc_middleware_js_1.protectedProcedure
|
|
4365
|
+
.input(zod_1.z.object({ nodeId: zod_1.z.string().optional() }).optional())
|
|
4366
|
+
.output(types_57.localNetworkCapability.methods.getTlsStatus.output)
|
|
4367
|
+
.query(async ({ input, ctx }) => {
|
|
4368
|
+
const p = resolveProvider('local-network', input?.nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
4369
|
+
return p.getTlsStatus();
|
|
4370
|
+
}),
|
|
4371
|
+
regenerateCertificate: trpc_middleware_js_1.adminProcedure
|
|
4372
|
+
.input(types_57.localNetworkCapability.methods.regenerateCertificate.input.loose())
|
|
4373
|
+
.output(types_57.localNetworkCapability.methods.regenerateCertificate.output)
|
|
4374
|
+
.mutation(async ({ input, ctx }) => {
|
|
4375
|
+
const { nodeId, ...methodInput } = input;
|
|
4376
|
+
const p = resolveProvider('local-network', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
4377
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
4378
|
+
return p.regenerateCertificate(methodInput);
|
|
4379
|
+
}),
|
|
4380
|
+
uploadCertificate: trpc_middleware_js_1.adminProcedure
|
|
4381
|
+
.input(types_57.localNetworkCapability.methods.uploadCertificate.input.loose())
|
|
4382
|
+
.output(types_57.localNetworkCapability.methods.uploadCertificate.output)
|
|
4383
|
+
.mutation(async ({ input, ctx }) => {
|
|
4384
|
+
const { nodeId, ...methodInput } = input;
|
|
4385
|
+
const p = resolveProvider('local-network', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
4386
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
4387
|
+
return p.uploadCertificate(methodInput);
|
|
4388
|
+
}),
|
|
4389
|
+
downloadCa: trpc_middleware_js_1.protectedProcedure
|
|
4390
|
+
.input(zod_1.z.object({ nodeId: zod_1.z.string().optional() }).optional())
|
|
4391
|
+
.output(types_57.localNetworkCapability.methods.downloadCa.output)
|
|
4392
|
+
.query(async ({ input, ctx }) => {
|
|
4393
|
+
const p = resolveProvider('local-network', input?.nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
4394
|
+
return p.downloadCa();
|
|
4395
|
+
}),
|
|
4396
|
+
revertToGeneratedCertificate: trpc_middleware_js_1.adminProcedure
|
|
4397
|
+
.input(zod_1.z.object({ nodeId: zod_1.z.string().optional() }).optional())
|
|
4398
|
+
.output(types_57.localNetworkCapability.methods.revertToGeneratedCertificate.output)
|
|
4399
|
+
.mutation(async ({ input, ctx }) => {
|
|
4400
|
+
const p = resolveProvider('local-network', input?.nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
4401
|
+
return p.revertToGeneratedCertificate();
|
|
4402
|
+
}),
|
|
4364
4403
|
});
|
|
4365
4404
|
}
|
|
4366
4405
|
function createCapRouter_lockControl(getProvider, createRemoteProxy) {
|
|
@@ -9016,6 +9055,15 @@ function createCapRouter_terminalSession(getProvider, createRemoteProxy) {
|
|
|
9016
9055
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
9017
9056
|
return p.createInstance(methodInput);
|
|
9018
9057
|
}),
|
|
9058
|
+
updateInstance: trpc_middleware_js_1.adminProcedure
|
|
9059
|
+
.input(types_110.terminalSessionCapability.methods.updateInstance.input.loose())
|
|
9060
|
+
.output(types_110.terminalSessionCapability.methods.updateInstance.output)
|
|
9061
|
+
.mutation(async ({ input, ctx }) => {
|
|
9062
|
+
const { nodeId, ...methodInput } = input;
|
|
9063
|
+
const p = resolveProvider('terminal-session', nodeId, () => getProvider(ctx), createRemoteProxy);
|
|
9064
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-unsafe-argument
|
|
9065
|
+
return p.updateInstance(methodInput);
|
|
9066
|
+
}),
|
|
9019
9067
|
deleteInstance: trpc_middleware_js_1.adminProcedure
|
|
9020
9068
|
.input(types_110.terminalSessionCapability.methods.deleteInstance.input.loose())
|
|
9021
9069
|
.output(types_110.terminalSessionCapability.methods.deleteInstance.output)
|
package/dist/boot/boot-config.js
CHANGED
|
@@ -41,11 +41,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
41
|
exports.loadBootstrapConfig = loadBootstrapConfig;
|
|
42
42
|
exports.autoGenerateJwtSecret = autoGenerateJwtSecret;
|
|
43
43
|
exports.setupInfra = setupInfra;
|
|
44
|
+
const node_crypto_1 = require("node:crypto");
|
|
44
45
|
const fs = __importStar(require("node:fs"));
|
|
45
46
|
const path = __importStar(require("node:path"));
|
|
46
|
-
const yaml = __importStar(require("js-yaml"));
|
|
47
|
-
const node_crypto_1 = require("node:crypto");
|
|
48
47
|
const types_1 = require("@camstack/types");
|
|
48
|
+
const yaml = __importStar(require("js-yaml"));
|
|
49
49
|
const config_schema_1 = require("../core/config/config.schema");
|
|
50
50
|
const storage_location_manager_1 = require("../core/storage/storage-location-manager");
|
|
51
51
|
// ---------------------------------------------------------------------------
|
|
@@ -207,6 +207,7 @@ async function setupInfra(configPath, bootstrapConfig) {
|
|
|
207
207
|
}
|
|
208
208
|
// --- Phase 2c: TLS certificate setup ---
|
|
209
209
|
let tlsOptions;
|
|
210
|
+
let tlsCert;
|
|
210
211
|
if (config.tls.enabled) {
|
|
211
212
|
// Use require() instead of import() — the ESM build of @camstack/system has
|
|
212
213
|
// broken chunks with require("fs") when leaked .js files exist in core/src/.
|
|
@@ -220,14 +221,11 @@ async function setupInfra(configPath, bootstrapConfig) {
|
|
|
220
221
|
tlsOptions = { key: pair.key, cert: pair.cert };
|
|
221
222
|
}
|
|
222
223
|
else {
|
|
223
|
-
//
|
|
224
|
-
const
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
else {
|
|
229
|
-
console.log(`[Phase2c] Using existing TLS cert at ${tlsResult.certPath}`);
|
|
230
|
-
}
|
|
224
|
+
// Hub-generated local CA → leaf (D227)
|
|
225
|
+
const extraSans = [...(core.readExtraSans?.(dataPath) ?? [])];
|
|
226
|
+
const tlsResult = await ensureTlsCert(dataPath, extraSans.length > 0 ? { extraSans } : undefined);
|
|
227
|
+
tlsCert = tlsResult;
|
|
228
|
+
logTlsCert(tlsResult);
|
|
231
229
|
const pair = loadTlsCert(tlsResult.certPath, tlsResult.keyPath);
|
|
232
230
|
tlsOptions = { key: pair.key, cert: pair.cert };
|
|
233
231
|
}
|
|
@@ -237,5 +235,25 @@ async function setupInfra(configPath, bootstrapConfig) {
|
|
|
237
235
|
dataPath,
|
|
238
236
|
locationManager,
|
|
239
237
|
tlsOptions,
|
|
238
|
+
tlsCert,
|
|
240
239
|
};
|
|
241
240
|
}
|
|
241
|
+
/**
|
|
242
|
+
* A certificate change is never silent. Anyone who installed the previous
|
|
243
|
+
* certificate as trusted by hand has to act, and the only chance to tell
|
|
244
|
+
* them before a browser does is right here — the scoped logger does not
|
|
245
|
+
* exist yet at phase 2c, so these go to the boot console like every other
|
|
246
|
+
* line in this file, and post-boot re-reports it as an alert.
|
|
247
|
+
*/
|
|
248
|
+
function logTlsCert(result) {
|
|
249
|
+
if (!result.generated) {
|
|
250
|
+
console.log(`[Phase2c] TLS cert unchanged — ${result.certPath} (leaf ${result.fingerprintSha256}, valid to ${result.validTo})`);
|
|
251
|
+
return;
|
|
252
|
+
}
|
|
253
|
+
console.log(`[Phase2c] TLS CERTIFICATE REISSUED — reason=${result.reason}, caRotated=${result.caRotated}`);
|
|
254
|
+
console.log(`[Phase2c] leaf ${result.previousFingerprintSha256 ?? '(none)'} → ${result.fingerprintSha256}`);
|
|
255
|
+
console.log(`[Phase2c] valid to ${result.validTo}, names: ${result.sans.join(', ')}`);
|
|
256
|
+
console.log(result.caRotated
|
|
257
|
+
? `[Phase2c] ACTION REQUIRED: the local CA changed. Install ${result.caCertPath} (SHA-256 ${result.caFingerprintSha256}) on every device that trusted the previous certificate.`
|
|
258
|
+
: `[Phase2c] Local CA unchanged (${result.caFingerprintSha256}) — devices that trust ${result.caCertPath} keep working.`);
|
|
259
|
+
}
|
|
@@ -37,7 +37,7 @@ class PostBootService {
|
|
|
37
37
|
return entry.payload;
|
|
38
38
|
}
|
|
39
39
|
async run(context) {
|
|
40
|
-
const { port, host, dataPath, trpcRegistered } = context;
|
|
40
|
+
const { port, host, dataPath, trpcRegistered, tlsCert } = context;
|
|
41
41
|
// Device stream wiring moved into `addon-stream-broker` — the addon
|
|
42
42
|
// does its own initial sync against `ctx.deviceRegistry` plus listens
|
|
43
43
|
// to `DeviceRegistered` events for future registrations. No kernel
|
|
@@ -56,6 +56,9 @@ class PostBootService {
|
|
|
56
56
|
// restart, …). `readPendingRestart` clears the marker atomically so
|
|
57
57
|
// we never re-fire on a crash-loop boot.
|
|
58
58
|
this.emitRestartCompletedIfPending(dataPath);
|
|
59
|
+
// A certificate that changed underneath the operator is an alert, not
|
|
60
|
+
// a boot line they will never scroll back to (D227).
|
|
61
|
+
this.emitTlsCertChangedIfReissued(tlsCert);
|
|
59
62
|
// Re-drive every non-terminal lifecycle job (addon task phases) from its
|
|
60
63
|
// on-disk checkpoint. Framework tasks are no longer applied by the engine
|
|
61
64
|
// (single-copy collapse — framework updates ship via applyServerUpdate);
|
|
@@ -68,6 +71,27 @@ class PostBootService {
|
|
|
68
71
|
this.logger.info('Lifecycle jobs reconciled at boot', { meta: { resumed, failed } });
|
|
69
72
|
}
|
|
70
73
|
}
|
|
74
|
+
emitTlsCertChangedIfReissued(tlsCert) {
|
|
75
|
+
if (tlsCert === undefined || !tlsCert.generated)
|
|
76
|
+
return;
|
|
77
|
+
const payload = {
|
|
78
|
+
reason: tlsCert.reason ?? 'unknown',
|
|
79
|
+
fingerprintSha256: tlsCert.fingerprintSha256,
|
|
80
|
+
caFingerprintSha256: tlsCert.caFingerprintSha256,
|
|
81
|
+
caRotated: tlsCert.caRotated,
|
|
82
|
+
caCertPath: tlsCert.caCertPath,
|
|
83
|
+
validTo: tlsCert.validTo,
|
|
84
|
+
sans: tlsCert.sans,
|
|
85
|
+
};
|
|
86
|
+
this.logger.warn('TLS certificate reissued', { meta: payload });
|
|
87
|
+
this.eventBus.emit({
|
|
88
|
+
id: (0, node_crypto_1.randomUUID)(),
|
|
89
|
+
timestamp: new Date(),
|
|
90
|
+
source: { type: 'core', id: 'system' },
|
|
91
|
+
category: types_1.EventCategory.SystemTlsCertChanged,
|
|
92
|
+
data: payload,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
71
95
|
emitRestartCompletedIfPending(dataDir) {
|
|
72
96
|
const marker = (0, system_1.readPendingRestart)(dataDir);
|
|
73
97
|
if (marker === null)
|
package/dist/main.js
CHANGED
|
@@ -249,7 +249,7 @@ async function bootstrap() {
|
|
|
249
249
|
path.join(process.env.CAMSTACK_DATA ?? path.join(process.cwd(), 'camstack-data'), 'config.yaml');
|
|
250
250
|
const bootstrapConfig = (0, boot_config_1.loadBootstrapConfig)(configPath);
|
|
251
251
|
const infra = await (0, boot_config_1.setupInfra)(configPath, bootstrapConfig);
|
|
252
|
-
const { dataPath, tlsOptions } = infra;
|
|
252
|
+
const { dataPath, tlsOptions, tlsCert } = infra;
|
|
253
253
|
const port = infra.bootstrapConfig.server.port;
|
|
254
254
|
const host = infra.bootstrapConfig.server.host;
|
|
255
255
|
// --- Phase 3: Create app + tRPC register + listen ---
|
|
@@ -1316,12 +1316,32 @@ async function bootstrap() {
|
|
|
1316
1316
|
const logger = app.get(logging_service_1.LoggingService).createLogger('System');
|
|
1317
1317
|
const protocol = tlsOptions ? 'https' : 'http';
|
|
1318
1318
|
logger.info('CamStack server listening', { meta: { protocol, host, port, trpcRegistered } });
|
|
1319
|
+
// LAN HTTP sibling — same Fastify request graph, dedicated port. Handler
|
|
1320
|
+
// is registered as soon as we have the instance; bind happens after HTTPS
|
|
1321
|
+
// is up so a failed HTTPS listen does not leave HTTP serving alone.
|
|
1322
|
+
(0, system_1.registerLanHttpHandler)((req, res) => {
|
|
1323
|
+
fastify.server.emit('request', req, res);
|
|
1324
|
+
});
|
|
1325
|
+
try {
|
|
1326
|
+
const lanHttp = await (0, system_1.bindPendingLanHttp)();
|
|
1327
|
+
if (lanHttp.listening) {
|
|
1328
|
+
logger.info('LAN HTTP listening', { meta: { port: lanHttp.port } });
|
|
1329
|
+
}
|
|
1330
|
+
else if (lanHttp.error) {
|
|
1331
|
+
logger.warn('LAN HTTP not bound', { meta: { error: lanHttp.error, port: lanHttp.port } });
|
|
1332
|
+
}
|
|
1333
|
+
}
|
|
1334
|
+
catch (err) {
|
|
1335
|
+
logger.warn('LAN HTTP bind failed', {
|
|
1336
|
+
meta: { error: err instanceof Error ? err.message : String(err) },
|
|
1337
|
+
});
|
|
1338
|
+
}
|
|
1319
1339
|
// UI runners are not part of control-plane readiness. Their mutable route
|
|
1320
1340
|
// state switches from 503 to static serving as soon as each capability is up.
|
|
1321
1341
|
void Promise.all([resolveAdminUi(), resolveViewerUi()]);
|
|
1322
1342
|
// Post-boot: fork workers, register device streams, emit system.boot
|
|
1323
1343
|
const postBoot = app.get(post_boot_service_1.PostBootService);
|
|
1324
|
-
await postBoot.run({ port, host, dataPath, trpcRegistered });
|
|
1344
|
+
await postBoot.run({ port, host, dataPath, trpcRegistered, tlsCert });
|
|
1325
1345
|
// The hub reached ready — when this boot is the PROBATION boot of a freshly
|
|
1326
1346
|
// staged @camstack/server root, promote it (currentVersion ← pending, N-1
|
|
1327
1347
|
// retained for rollback) and disarm the starter's crash-loop auto-rollback.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@camstack/server",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.145",
|
|
4
4
|
"private": false,
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -33,18 +33,18 @@
|
|
|
33
33
|
]
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@camstack/addon-admin-ui": "1.2.
|
|
37
|
-
"@camstack/addon-agent-ui": "1.2.
|
|
38
|
-
"@camstack/addon-auth": "1.2.
|
|
39
|
-
"@camstack/addon-decoder-nodeav": "1.2.
|
|
40
|
-
"@camstack/addon-notifiers": "1.2.
|
|
41
|
-
"@camstack/addon-pipeline": "1.2.
|
|
42
|
-
"@camstack/addon-pipeline-orchestrator": "1.2.
|
|
43
|
-
"@camstack/addon-post-analysis": "1.2.
|
|
44
|
-
"@camstack/sdk": "1.2.
|
|
45
|
-
"@camstack/system": "1.2.
|
|
46
|
-
"@camstack/types": "1.2.
|
|
47
|
-
"@camstack/ui-library": "1.2.
|
|
36
|
+
"@camstack/addon-admin-ui": "1.2.88",
|
|
37
|
+
"@camstack/addon-agent-ui": "1.2.27",
|
|
38
|
+
"@camstack/addon-auth": "1.2.29",
|
|
39
|
+
"@camstack/addon-decoder-nodeav": "1.2.25",
|
|
40
|
+
"@camstack/addon-notifiers": "1.2.30",
|
|
41
|
+
"@camstack/addon-pipeline": "1.2.107",
|
|
42
|
+
"@camstack/addon-pipeline-orchestrator": "1.2.90",
|
|
43
|
+
"@camstack/addon-post-analysis": "1.2.109",
|
|
44
|
+
"@camstack/sdk": "1.2.29",
|
|
45
|
+
"@camstack/system": "1.2.116",
|
|
46
|
+
"@camstack/types": "1.2.97",
|
|
47
|
+
"@camstack/ui-library": "1.2.67",
|
|
48
48
|
"@fastify/compress": "^9.0.0",
|
|
49
49
|
"@fastify/cookie": "^11.0.2",
|
|
50
50
|
"@fastify/cors": "^11.2.0",
|