@camstack/server 1.2.144 → 1.2.146

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.
@@ -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)
@@ -12,18 +12,26 @@ exports.isSessionGradeJwtPayload = isSessionGradeJwtPayload;
12
12
  * after a tRPC login; read by the addon-route catch-all for `authenticated`
13
13
  * routes hit by a plain browser navigation. */
14
14
  exports.SESSION_COOKIE = 'camstack_session';
15
- function buildSessionCookie(token, ttlSec) {
15
+ function buildSessionCookie(token, ttlSec, opts = {}) {
16
16
  return {
17
17
  name: exports.SESSION_COOKIE,
18
18
  value: token,
19
- options: { httpOnly: true, sameSite: 'lax', secure: true, path: '/', maxAge: ttlSec },
19
+ options: {
20
+ httpOnly: true,
21
+ sameSite: 'lax',
22
+ // Secure cookies are invisible on the LAN HTTP sibling (plain http://).
23
+ // Default stays true so HTTPS callers do not regress.
24
+ secure: opts.secure ?? true,
25
+ path: '/',
26
+ maxAge: ttlSec,
27
+ },
20
28
  };
21
29
  }
22
- function clearSessionCookie() {
30
+ function clearSessionCookie(opts = {}) {
23
31
  return {
24
32
  name: exports.SESSION_COOKIE,
25
33
  value: '',
26
- options: { httpOnly: true, sameSite: 'lax', secure: true, path: '/', maxAge: 0 },
34
+ options: { httpOnly: true, sameSite: 'lax', secure: opts.secure ?? true, path: '/', maxAge: 0 },
27
35
  };
28
36
  }
29
37
  /**
@@ -222,7 +222,8 @@ async function setupInfra(configPath, bootstrapConfig) {
222
222
  }
223
223
  else {
224
224
  // Hub-generated local CA → leaf (D227)
225
- const tlsResult = await ensureTlsCert(dataPath);
225
+ const extraSans = [...(core.readExtraSans?.(dataPath) ?? [])];
226
+ const tlsResult = await ensureTlsCert(dataPath, extraSans.length > 0 ? { extraSans } : undefined);
226
227
  tlsCert = tlsResult;
227
228
  logTlsCert(tlsResult);
228
229
  const pair = loadTlsCert(tlsResult.certPath, tlsResult.keyPath);
package/dist/main.js CHANGED
@@ -790,13 +790,13 @@ async function bootstrap() {
790
790
  catch {
791
791
  return reply.status(401).send({ error: 'invalid token' });
792
792
  }
793
- const c = (0, session_cookie_js_1.buildSessionCookie)(token, ttlSec);
793
+ const c = (0, session_cookie_js_1.buildSessionCookie)(token, ttlSec, { secure: request.protocol === 'https' });
794
794
  reply.setCookie(c.name, c.value, c.options);
795
795
  return reply.send({ ok: true });
796
796
  });
797
797
  // DELETE /api/auth/session — clear the cookie on logout.
798
- fastify.delete('/api/auth/session', async (_request, reply) => {
799
- const c = (0, session_cookie_js_1.clearSessionCookie)();
798
+ fastify.delete('/api/auth/session', async (request, reply) => {
799
+ const c = (0, session_cookie_js_1.clearSessionCookie)({ secure: request.protocol === 'https' });
800
800
  reply.setCookie(c.name, c.value, c.options);
801
801
  return reply.send({ ok: true });
802
802
  });
@@ -826,7 +826,7 @@ async function bootstrap() {
826
826
  catch {
827
827
  return reply.status(401).send({ error: 'invalid token' });
828
828
  }
829
- const c = (0, session_cookie_js_1.buildSessionCookie)(token, ttlSec);
829
+ const c = (0, session_cookie_js_1.buildSessionCookie)(token, ttlSec, { secure: request.protocol === 'https' });
830
830
  reply.setCookie(c.name, c.value, c.options);
831
831
  return reply.redirect(next);
832
832
  });
@@ -1301,7 +1301,18 @@ async function bootstrap() {
1301
1301
  }
1302
1302
  };
1303
1303
  try {
1304
- await app.listen(port, host);
1304
+ const listenHost = (0, system_1.allFamiliesListenHost)(host).host;
1305
+ try {
1306
+ await app.listen(port, listenHost);
1307
+ }
1308
+ catch (listenErr) {
1309
+ if (listenHost === '::' && host !== '::') {
1310
+ await app.listen(port, '0.0.0.0');
1311
+ }
1312
+ else {
1313
+ throw listenErr;
1314
+ }
1315
+ }
1305
1316
  }
1306
1317
  catch (listenErr) {
1307
1318
  if (listenErr !== null &&
@@ -1316,6 +1327,31 @@ async function bootstrap() {
1316
1327
  const logger = app.get(logging_service_1.LoggingService).createLogger('System');
1317
1328
  const protocol = tlsOptions ? 'https' : 'http';
1318
1329
  logger.info('CamStack server listening', { meta: { protocol, host, port, trpcRegistered } });
1330
+ // LAN HTTP sibling — same Fastify request graph, dedicated port. Handler
1331
+ // is registered as soon as we have the instance; bind happens after HTTPS
1332
+ // is up so a failed HTTPS listen does not leave HTTP serving alone.
1333
+ (0, system_1.registerLanHttpHandler)({
1334
+ onRequest: (req, res) => {
1335
+ fastify.server.emit('request', req, res);
1336
+ },
1337
+ onUpgrade: (req, socket, head) => {
1338
+ fastify.server.emit('upgrade', req, socket, head);
1339
+ },
1340
+ });
1341
+ try {
1342
+ const lanHttp = await (0, system_1.bindPendingLanHttp)();
1343
+ if (lanHttp.listening) {
1344
+ logger.info('LAN HTTP listening', { meta: { port: lanHttp.port } });
1345
+ }
1346
+ else if (lanHttp.error) {
1347
+ logger.warn('LAN HTTP not bound', { meta: { error: lanHttp.error, port: lanHttp.port } });
1348
+ }
1349
+ }
1350
+ catch (err) {
1351
+ logger.warn('LAN HTTP bind failed', {
1352
+ meta: { error: err instanceof Error ? err.message : String(err) },
1353
+ });
1354
+ }
1319
1355
  // UI runners are not part of control-plane readiness. Their mutable route
1320
1356
  // state switches from 503 to static serving as soon as each capability is up.
1321
1357
  void Promise.all([resolveAdminUi(), resolveViewerUi()]);
@@ -414,7 +414,13 @@ async function bootManual(opts) {
414
414
  });
415
415
  },
416
416
  async listen(port, host) {
417
- await fastify.listen({ port, host });
417
+ await fastify.listen({
418
+ port,
419
+ host,
420
+ // Dual-stack when binding `::`. Positional listen() drops this and
421
+ // on macOS/BSD `IPV6_V6ONLY` defaults to 1 — IPv4 clients die.
422
+ ipv6Only: host === '::' ? false : undefined,
423
+ });
418
424
  },
419
425
  close,
420
426
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@camstack/server",
3
- "version": "1.2.144",
3
+ "version": "1.2.146",
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.87",
36
+ "@camstack/addon-admin-ui": "1.2.89",
37
37
  "@camstack/addon-agent-ui": "1.2.27",
38
38
  "@camstack/addon-auth": "1.2.29",
39
39
  "@camstack/addon-decoder-nodeav": "1.2.25",
40
40
  "@camstack/addon-notifiers": "1.2.30",
41
- "@camstack/addon-pipeline": "1.2.106",
42
- "@camstack/addon-pipeline-orchestrator": "1.2.89",
43
- "@camstack/addon-post-analysis": "1.2.108",
44
- "@camstack/sdk": "1.2.28",
45
- "@camstack/system": "1.2.115",
46
- "@camstack/types": "1.2.96",
47
- "@camstack/ui-library": "1.2.66",
41
+ "@camstack/addon-pipeline": "1.2.107",
42
+ "@camstack/addon-pipeline-orchestrator": "1.2.91",
43
+ "@camstack/addon-post-analysis": "1.2.109",
44
+ "@camstack/sdk": "1.2.29",
45
+ "@camstack/system": "1.2.117",
46
+ "@camstack/types": "1.2.98",
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",