@cotal-ai/cli 0.101.5 → 0.101.6
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/commands/stack-up.d.ts +6 -1
- package/dist/commands/stack-up.d.ts.map +1 -1
- package/dist/commands/stack-up.js +14 -4
- package/dist/commands/stack-up.js.map +1 -1
- package/dist/commands/up.d.ts +3 -0
- package/dist/commands/up.d.ts.map +1 -1
- package/dist/commands/up.js +65 -16
- package/dist/commands/up.js.map +1 -1
- package/package.json +4 -4
package/dist/commands/up.js
CHANGED
|
@@ -83,6 +83,7 @@ export const upFlags = [
|
|
|
83
83
|
{ name: "root", type: "string", value: "<dir>", description: "start the project in this folder instead of the current one; it must already have its own .cotal" },
|
|
84
84
|
{ name: "store-dir", type: "string", value: "<dir>", description: "JetStream store directory" },
|
|
85
85
|
{ name: "max-file-store", type: "string", value: "<bytes>", description: "JetStream file storage cap in bytes (default: nats-server's dynamic cap). Fixed at broker start and recorded for the next `up`; a legacy root also keeps it across `down --preserve-state`" },
|
|
86
|
+
{ name: "auth-timeout", type: "string", value: "<seconds>", description: "user-auth only: how long the broker waits for the auth callout, 1 to 60 seconds (default: nats-server's 2); the auth service answers inside it. Fixed at broker start and recorded for the next `up`" },
|
|
86
87
|
{ name: "channels", type: "string", value: "<path>", description: "channel-registry seed file (JSON; default .cotal/channels.json)" },
|
|
87
88
|
{ name: "tls-cert", type: "string", value: "<file>", description: "serve the broker over TLS with this certificate (requires --tls-key)" },
|
|
88
89
|
{ name: "tls-key", type: "string", value: "<file>", description: "the private key for --tls-cert" },
|
|
@@ -183,6 +184,14 @@ export function validateUpArguments(args) {
|
|
|
183
184
|
// its own checks for maintenance re-entries, which do not pass through this validation.
|
|
184
185
|
parsePositiveIntegerFlag("--max-sessions", args.values["max-sessions"]);
|
|
185
186
|
parseMaxFileStore(args.values["max-file-store"]);
|
|
187
|
+
// The timeout belongs to the auth callout, which only a user-auth space has. A manifest or a
|
|
188
|
+
// restore starts the broker its own record describes, so neither takes it.
|
|
189
|
+
if (parseAuthTimeout(args.values["auth-timeout"]) !== undefined) {
|
|
190
|
+
if (args.values.open === true)
|
|
191
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--auth-timeout sets the auth callout's timeout, and an open space has no auth callout; nothing was started", { remedy: "drop --auth-timeout, or start a user-auth space with --user-auth" });
|
|
192
|
+
if (args.values.file !== undefined || args.values.restore !== undefined)
|
|
193
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `--auth-timeout cannot be combined with ${args.values.file !== undefined ? "--file/-f" : "--restore"}, which starts the broker its own record describes; nothing was started`, { remedy: "start it without --auth-timeout; a recorded timeout is rendered again" });
|
|
194
|
+
}
|
|
186
195
|
if (typeof args.values["store-dir"] === "string")
|
|
187
196
|
assertStoreDirArgument(args.values["store-dir"], typeof args.values.root === "string" ? resolve(args.values.root) : freshFolderRoot(args.values) ?? cotalRoot());
|
|
188
197
|
const restoreOnly = args.values["restore-only"];
|
|
@@ -961,6 +970,11 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
961
970
|
const requestedMaxFileStore = parseMaxFileStore(values["max-file-store"]);
|
|
962
971
|
if (requestedMaxFileStore !== undefined && requestedMaxFileStore !== resumeMaxFileStore)
|
|
963
972
|
throw preservedOnly("--max-file-store", requestedMaxFileStore, "file store cap", resumeMaxFileStore === undefined ? "no cap" : String(resumeMaxFileStore));
|
|
973
|
+
// The resumed broker renders this root's recorded auth callout timeout again.
|
|
974
|
+
const recordedTimeout = readBrokerPolicy(root)?.authTimeout;
|
|
975
|
+
const requestedTimeout = parseAuthTimeout(values["auth-timeout"]);
|
|
976
|
+
if (requestedTimeout !== undefined && requestedTimeout !== recordedTimeout)
|
|
977
|
+
throw preservedOnly("--auth-timeout", requestedTimeout, "auth callout timeout", recordedTimeout === undefined ? "none" : String(recordedTimeout));
|
|
964
978
|
if (values.runtime && runtimes[0] && values.runtime !== runtimes[0])
|
|
965
979
|
throw preservedOnly("--runtime", values.runtime, "agent runtime", runtimes[0]);
|
|
966
980
|
const resumeRuntime = values.runtime ?? runtimes[0] ?? "pty";
|
|
@@ -1018,6 +1032,9 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1018
1032
|
const requestedMaxFileStore = parseMaxFileStore(values["max-file-store"]);
|
|
1019
1033
|
if (requestedMaxFileStore !== undefined && requestedMaxFileStore !== recoveredMaxFileStore)
|
|
1020
1034
|
throw new Error(`--max-file-store ${requestedMaxFileStore} is not the preserved launch cap (${recoveredMaxFileStore ?? "unset"}); resume attempt ${attemptId} re-renders exactly the preserved cap - omit --max-file-store`);
|
|
1035
|
+
const requestedTimeout = parseAuthTimeout(values["auth-timeout"]);
|
|
1036
|
+
if (requestedTimeout !== undefined && requestedTimeout !== readBrokerPolicy(root)?.authTimeout)
|
|
1037
|
+
throw new Error(`--auth-timeout ${requestedTimeout} is not this root's recorded auth callout timeout; resume attempt ${attemptId} re-renders the recorded one - omit --auth-timeout`);
|
|
1021
1038
|
// Recovery re-asserts the source identity rather than trusting the journaled spelling.
|
|
1022
1039
|
assertStoreIdentity(journal.source);
|
|
1023
1040
|
// The bound listener decides re-entry: a live exact listener is ADOPTED, a provably dead
|
|
@@ -1160,6 +1177,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1160
1177
|
const publicExchange = [...publicExchangeArgs(values, wantUser), ...serviceEndpointsArgs(values, wantUser)];
|
|
1161
1178
|
const maxSessions = parsePositiveIntegerFlag("--max-sessions", values["max-sessions"]);
|
|
1162
1179
|
const maxFileStore = parseMaxFileStore(values["max-file-store"]);
|
|
1180
|
+
const authTimeout = parseAuthTimeout(values["auth-timeout"]);
|
|
1163
1181
|
// The manifest path renders its broker from the manifest, which has no store fields, so the flag
|
|
1164
1182
|
// would be accepted and never rendered. Refuse it rather than drop it.
|
|
1165
1183
|
if (maxFileStore !== undefined && values.file)
|
|
@@ -1284,7 +1302,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1284
1302
|
const stackServer = values.server ?? readStackJournal(meshRoot)?.journal.server ?? localMeshesForRoot(meshRoot).find((m) => m.space === stackSpace)?.server ?? await unrecordedStackServer(meshRoot, stackSpace, values.host);
|
|
1285
1303
|
if (values.foreground && presentation !== "json")
|
|
1286
1304
|
stackUpForegroundNotice(presentation, stackSpace, takeover);
|
|
1287
|
-
await stackUp({ maintenanceLock: stackLock, root: meshRoot, space: stackSpace, server: stackServer, transport, runtime: values.runtime ?? "pty", noManager, ...(stackMode ? { mode: stackMode } : {}), ...(values.idp ? { idp: values.idp } : {}), ...(values.host ? { host: values.host } : {}), ...(values["store-dir"] ? { storeDir: values["store-dir"] } : {}), ...(values["rotate-sys"] ? { rotateSys: true } : {}), ...(maxFileStore !== undefined ? { maxFileStore } : {}), ...(maxSessions !== undefined ? { maxSessions } : {}), ...(values.channels ? { channels: values.channels } : {}), ...(values.__invokedRoot ? { invokedRoot: values.__invokedRoot } : {}), foreground: values.foreground === true, presentation }, native);
|
|
1305
|
+
await stackUp({ maintenanceLock: stackLock, root: meshRoot, space: stackSpace, server: stackServer, transport, runtime: values.runtime ?? "pty", noManager, ...(stackMode ? { mode: stackMode } : {}), ...(values.idp ? { idp: values.idp } : {}), ...(values.host ? { host: values.host } : {}), ...(values["store-dir"] ? { storeDir: values["store-dir"] } : {}), ...(values["rotate-sys"] ? { rotateSys: true } : {}), ...(maxFileStore !== undefined ? { maxFileStore } : {}), ...(authTimeout !== undefined ? { authTimeout } : {}), ...(maxSessions !== undefined ? { maxSessions } : {}), ...(values.channels ? { channels: values.channels } : {}), ...(values.__invokedRoot ? { invokedRoot: values.__invokedRoot } : {}), foreground: values.foreground === true, presentation }, native);
|
|
1288
1306
|
}
|
|
1289
1307
|
finally {
|
|
1290
1308
|
releaseMaintenanceLock(stackLock);
|
|
@@ -1302,6 +1320,8 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1302
1320
|
}
|
|
1303
1321
|
// A manifest or retained-launcher start reports no interrupt notice of its own.
|
|
1304
1322
|
await releaseStartupNotice();
|
|
1323
|
+
if (authTimeout !== undefined && !wantUser)
|
|
1324
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "--auth-timeout sets the auth callout's timeout, which only a user-auth space has; pair it with --user-auth, and nothing was started", { remedy: "add --user-auth, or drop --auth-timeout" });
|
|
1305
1325
|
// A named space this machine runs from another folder is refused before anything is written here,
|
|
1306
1326
|
// and in every presentation, since the launcher below has no structured receipt.
|
|
1307
1327
|
if (!values.file && values.space !== undefined)
|
|
@@ -1600,6 +1620,13 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1600
1620
|
console.error(c.red(`✗ mesh "${held.space}" is already running at ${server} - a running broker can't change --max-file-store (it is fixed at start); \`cotal down\` it first, then \`cotal up --max-file-store ${maxFileStore}\``));
|
|
1601
1621
|
process.exit(1);
|
|
1602
1622
|
}
|
|
1623
|
+
// So is the auth callout timeout: the running broker keeps the one it was started with, which
|
|
1624
|
+
// its broker policy records.
|
|
1625
|
+
const runningTimeout = readBrokerPolicy(root)?.authTimeout;
|
|
1626
|
+
if (authTimeout !== undefined && authTimeout !== runningTimeout) {
|
|
1627
|
+
console.error(c.red(`✗ mesh "${held.space}" is already running at ${server} - a running broker can't change --auth-timeout (it is fixed at start); \`cotal down\` it first, then \`cotal up --user-auth --auth-timeout ${authTimeout}\``));
|
|
1628
|
+
process.exit(1);
|
|
1629
|
+
}
|
|
1603
1630
|
// The store directory is fixed the same way: an explicit --store-dir on a live refresh can
|
|
1604
1631
|
// only be refused when it disagrees with what the running broker actually opened. Absent
|
|
1605
1632
|
// `held.storeDir` (a pre-field record) has nothing to compare against, so it is not checked.
|
|
@@ -1715,7 +1742,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1715
1742
|
stderrLine("✗ ", `${e.message}`, c.red);
|
|
1716
1743
|
process.exit(1);
|
|
1717
1744
|
}
|
|
1718
|
-
const svc = await startUserAuthService(held.space, server, { prepared, stateDir }, publicExchange);
|
|
1745
|
+
const svc = await startUserAuthService(held.space, server, { prepared, stateDir }, [...publicExchange, ...authTimeoutArgs(runningTimeout)]);
|
|
1719
1746
|
userAuth = svc.userAuth;
|
|
1720
1747
|
// The refresh IS the recovery command — a heal that didn't heal must not exit 0.
|
|
1721
1748
|
if (!svc.ok)
|
|
@@ -1828,6 +1855,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1828
1855
|
server,
|
|
1829
1856
|
storeDir: values["store-dir"],
|
|
1830
1857
|
maxFileStore,
|
|
1858
|
+
authTimeout,
|
|
1831
1859
|
space: values.space,
|
|
1832
1860
|
open: values.open,
|
|
1833
1861
|
userAuth: wantUser ? { idpUrl: values.idp } : undefined,
|
|
@@ -1911,7 +1939,7 @@ async function runUp(args, inheritedLock, onAdopt, freshTeamBoot = false, restor
|
|
|
1911
1939
|
// Decided above the branch; the dial host is only settled here (a port collision may have moved
|
|
1912
1940
|
// the server, and the hostname is what the certificate has to match).
|
|
1913
1941
|
assertServesDialHost(transport, new URL(server).hostname);
|
|
1914
|
-
const setup = useAuth ? await authSetup(storeDir, server, space, host, wantUser ? { idpUrl: values.idp } : undefined, transport, values["rotate-sys"], maxFileStore) : undefined;
|
|
1942
|
+
const setup = useAuth ? await authSetup(storeDir, server, space, host, wantUser ? { idpUrl: values.idp } : undefined, transport, values["rotate-sys"], maxFileStore, false, authTimeout) : undefined;
|
|
1915
1943
|
const port = Number(new URL(server).port) || 4222;
|
|
1916
1944
|
// Both modes go through a RENDERER, never bare CLI flags. Open mode used to start from
|
|
1917
1945
|
// `-js -sd … -p … -a …`, which never called a renderer at all — so the required transport union
|
|
@@ -2441,6 +2469,8 @@ async function resumeControllerStack(lock, root, values, restoreSink) {
|
|
|
2441
2469
|
throw new CommandFailure("refused", "USAGE_INVALID", "a controller resume takes its broker address from the cut; --server is refused", { target: { root, space } });
|
|
2442
2470
|
if (values["store-dir"] !== undefined || values["max-file-store"] !== undefined)
|
|
2443
2471
|
throw new CommandFailure("refused", "USAGE_INVALID", "a controller resume takes its store and cap from the cut; --store-dir and --max-file-store are refused", { target: { root, space } });
|
|
2472
|
+
if (values["auth-timeout"] !== undefined)
|
|
2473
|
+
throw new CommandFailure("refused", "USAGE_INVALID", "a controller resume renders this root's recorded auth callout timeout; --auth-timeout is refused", { target: { root, space }, remedy: "run cotal up without --auth-timeout" });
|
|
2444
2474
|
const runtimes = [...new Set(agents.map((agent) => agent.launch?.runtime).filter((value) => typeof value === "string"))];
|
|
2445
2475
|
if (runtimes.length > 1 || (values.runtime !== undefined && runtimes[0] !== undefined && values.runtime !== runtimes[0]))
|
|
2446
2476
|
throw new CommandFailure("refused", "USAGE_INVALID", "--runtime must equal the preserved inventory's runtime; a controller resume does not change it", { target: { root, space } });
|
|
@@ -3067,13 +3097,13 @@ export async function recheckFreshTeamBoot(plan, own) {
|
|
|
3067
3097
|
export function controllerStackNative() {
|
|
3068
3098
|
return {
|
|
3069
3099
|
prepareBroker: async (opts) => {
|
|
3070
|
-
const prepared = await prepareBrokerStart({ transport: opts.transport, server: opts.server, space: opts.space, ...(opts.open ? { open: true } : {}), ...(opts.userAuth ? { userAuth: opts.userAuth } : {}), ...(opts.host ? { host: opts.host } : {}), ...(opts.storeDir ? { storeDir: opts.storeDir } : {}), ...(opts.existingStore ? { existingStore: opts.existingStore } : {}), ...(opts.maxFileStore !== undefined ? { maxFileStore: opts.maxFileStore } : {}), ...(opts.seed !== undefined ? { seed: opts.seed } : opts.channels ? { channels: opts.channels } : {}), quietBoot: true });
|
|
3071
|
-
return { root: prepared.root, server: prepared.server, space: prepared.space, storeDir: prepared.storeDir, transport: prepared.transport, ...(prepared.setup ? { setup: { creds: prepared.setup.creds, wsPort: prepared.setup.wsPort } } : {}), ...(prepared.setup?.prepared && prepared.setup.stateDir ? { user: { prepared: prepared.setup.prepared, stateDir: prepared.setup.stateDir } } : {}), confPath: prepared.confPath, bin: prepared.bin, source: prepared.source, version: prepared.version, seedFile: prepared.seedFile };
|
|
3100
|
+
const prepared = await prepareBrokerStart({ transport: opts.transport, server: opts.server, space: opts.space, ...(opts.open ? { open: true } : {}), ...(opts.userAuth ? { userAuth: opts.userAuth } : {}), ...(opts.host ? { host: opts.host } : {}), ...(opts.storeDir ? { storeDir: opts.storeDir } : {}), ...(opts.existingStore ? { existingStore: opts.existingStore } : {}), ...(opts.maxFileStore !== undefined ? { maxFileStore: opts.maxFileStore } : {}), ...(opts.authTimeout !== undefined ? { authTimeout: opts.authTimeout } : {}), ...(opts.seed !== undefined ? { seed: opts.seed } : opts.channels ? { channels: opts.channels } : {}), quietBoot: true });
|
|
3101
|
+
return { root: prepared.root, server: prepared.server, space: prepared.space, storeDir: prepared.storeDir, transport: prepared.transport, ...(prepared.setup ? { setup: { creds: prepared.setup.creds, wsPort: prepared.setup.wsPort } } : {}), ...(prepared.setup?.prepared && prepared.setup.stateDir ? { user: { prepared: prepared.setup.prepared, stateDir: prepared.setup.stateDir } } : {}), confPath: prepared.confPath, bin: prepared.bin, source: prepared.source, version: prepared.version, seedFile: prepared.seedFile, ...(prepared.setup?.authTimeout !== undefined ? { authTimeout: prepared.setup.authTimeout } : {}) };
|
|
3072
3102
|
},
|
|
3073
3103
|
initializeStreams: (server, space, setup, seedFile) => postStart(server, space, setup, seedFile),
|
|
3074
3104
|
recreateDeletedStreams: ({ seed, ...opts }) => recreateDeletedStreams({ ...opts, ...(seed !== undefined ? { seed: seed } : {}) }),
|
|
3075
3105
|
recordMesh: (entry) => recordOurMesh({ ...entry, ts: new Date().toISOString() }, "started", true),
|
|
3076
|
-
commitTransport: (root, chosen) => commitTransportPolicy(root, chosen, true),
|
|
3106
|
+
commitTransport: (root, chosen, authTimeout) => commitTransportPolicy(root, chosen, true, undefined, authTimeout),
|
|
3077
3107
|
};
|
|
3078
3108
|
}
|
|
3079
3109
|
/** The structured refusal for a manifest `up -f` cannot use: the located problems of one that does
|
|
@@ -3572,7 +3602,7 @@ async function serveReadyListener(l) {
|
|
|
3572
3602
|
// USER MODE: the auth service comes up FIRST among the daemons — until its callout answers,
|
|
3573
3603
|
// every user-mode connect to this broker is denied, so `up` must not report a usable user mesh
|
|
3574
3604
|
// (nor let agents race it) on a half-started auth plane.
|
|
3575
|
-
const svc = await startUserAuthService(space, server, setup, l.publicExchange, l.quietBoot);
|
|
3605
|
+
const svc = await startUserAuthService(space, server, setup, [...(l.publicExchange ?? []), ...authTimeoutArgs(setup?.authTimeout)], l.quietBoot);
|
|
3576
3606
|
// Record BEFORE the control plane comes up: the manager's fail-closed mode detection requires
|
|
3577
3607
|
// an authoritative registry entry (marker-without-registry is a refused start, not a guess),
|
|
3578
3608
|
// so the record must exist by the time it boots. A manager/delivery failure after this leaves
|
|
@@ -3604,7 +3634,7 @@ async function serveReadyListener(l) {
|
|
|
3604
3634
|
// Commit the policy only for a listener that is up and recorded (S5), and before the control
|
|
3605
3635
|
// plane (S9). startDeliveryWithBroker is HANDED the transport decision, so it does not depend on
|
|
3606
3636
|
// the file at all.
|
|
3607
|
-
commitTransportPolicy(cotalRoot(), transport, l.quietBoot, server);
|
|
3637
|
+
commitTransportPolicy(cotalRoot(), transport, l.quietBoot, server, setup?.authTimeout);
|
|
3608
3638
|
// The delivery daemon self-gates on `.cotal/auth`, so an open mesh has none. Class-2 credential
|
|
3609
3639
|
// renewal is NOT wired here: the MANAGER is the renewal owner (it is resident in every mesh mode,
|
|
3610
3640
|
// where a foreground `up` process is not).
|
|
@@ -3658,7 +3688,7 @@ export async function prepareBrokerStart(opts) {
|
|
|
3658
3688
|
// effective server is finally known — a manifest may name a different host than the flags did, and
|
|
3659
3689
|
// a certificate that is valid for one is not thereby valid for the other.
|
|
3660
3690
|
const transport = assertServesDialHost(opts.transport, new URL(server).hostname);
|
|
3661
|
-
const setup = useAuth ? await authSetup(storeDir, server, space, host, opts.userAuth, transport, opts.rotateSys, opts.maxFileStore, opts.quietBoot) : undefined;
|
|
3691
|
+
const setup = useAuth ? await authSetup(storeDir, server, space, host, opts.userAuth, transport, opts.rotateSys, opts.maxFileStore, opts.quietBoot, opts.authTimeout) : undefined;
|
|
3662
3692
|
const port = Number(new URL(server).port) || 4222;
|
|
3663
3693
|
// Same rule as the foreground path: every route to a listener names its transport (see
|
|
3664
3694
|
// `writeOpenBrokerConf`). Detach must not be the mode where the fence quietly does not apply.
|
|
@@ -4389,6 +4419,20 @@ function parseMaxFileStore(raw) {
|
|
|
4389
4419
|
throw new CommandFailure("refused", "USAGE_INVALID", `--max-file-store ${cap} is below ${MIN_FILE_STORE} bytes, the least the space's streams start on: its membership bucket reserves ${MEMBERSHIP_MAX_BYTES} bytes (64 MiB) of the broker's file store, and nats-server needs one more byte free to create the others; nothing was started`, { remedy: `pass --max-file-store ${MIN_FILE_STORE} or more, leaving room for messages, or omit it` });
|
|
4390
4420
|
return cap;
|
|
4391
4421
|
}
|
|
4422
|
+
/** `--auth-timeout`, whole seconds from 1 to 60. nats-server warns above 60 that the value is
|
|
4423
|
+
* probably a mistake, and a stalled callout holds every connect that long. */
|
|
4424
|
+
function parseAuthTimeout(raw) {
|
|
4425
|
+
const seconds = parsePositiveIntegerFlag("--auth-timeout", raw);
|
|
4426
|
+
if (seconds !== undefined && seconds > MAX_AUTH_TIMEOUT_SECONDS)
|
|
4427
|
+
throw new CommandFailure("refused", "USAGE_INVALID", `--auth-timeout ${seconds} is over ${MAX_AUTH_TIMEOUT_SECONDS} seconds; it is how long the broker holds a connect while the auth callout has not answered, and nothing was started`, { remedy: `pass --auth-timeout 1 to ${MAX_AUTH_TIMEOUT_SECONDS}, or omit it for nats-server's 2 seconds` });
|
|
4428
|
+
return seconds;
|
|
4429
|
+
}
|
|
4430
|
+
const MAX_AUTH_TIMEOUT_SECONDS = 60;
|
|
4431
|
+
/** The auth-service daemon argv that gives the callout the broker's timeout as its deadline. Built
|
|
4432
|
+
* only from the value the broker configuration rendered, so the two never differ. */
|
|
4433
|
+
function authTimeoutArgs(seconds) {
|
|
4434
|
+
return seconds === undefined ? [] : ["--auth-timeout", String(seconds)];
|
|
4435
|
+
}
|
|
4392
4436
|
/** Load the declarative channels-config file to seed the registry. An explicit `--channels`
|
|
4393
4437
|
* path that's missing is a hard error; the default `.cotal/channels.json` is optional (absent
|
|
4394
4438
|
* ⇒ nothing to seed). */
|
|
@@ -4572,11 +4616,12 @@ function assertTlsIntentServed(server, transport, source) {
|
|
|
4572
4616
|
if (tls && transport.kind !== "tls-required")
|
|
4573
4617
|
throw new CommandFailure("refused", "USAGE_INVALID", `${source} names a tls:// address, but no TLS certificate and key are configured, so the broker would serve plaintext; nothing was started`, { target: { server: brokerAddressForDisplay(server) ?? "not displayable" }, remedy: "serve TLS with --tls-cert <cert.pem> --tls-key <key.pem>, or use a nats:// address" });
|
|
4574
4618
|
}
|
|
4575
|
-
/** Persist a transport
|
|
4576
|
-
|
|
4577
|
-
|
|
4619
|
+
/** Persist a transport, and the auth callout timeout the broker configuration rendered, after its
|
|
4620
|
+
* listener starts; a structured boot leaves stdout to its receipt. */
|
|
4621
|
+
function commitTransportPolicy(root, transport, quietBoot = false, server, authTimeout) {
|
|
4622
|
+
if (transport.kind !== "tls-required" && authTimeout === undefined)
|
|
4578
4623
|
return;
|
|
4579
|
-
writeBrokerPolicy(root, { version: 1, transport });
|
|
4624
|
+
writeBrokerPolicy(root, { version: 1, transport, ...(authTimeout !== undefined ? { authTimeout } : {}) });
|
|
4580
4625
|
if (!quietBoot)
|
|
4581
4626
|
announceTransport(transport, server);
|
|
4582
4627
|
}
|
|
@@ -4795,7 +4840,10 @@ async function authSetup(storeDir, server, space, host = "127.0.0.1", user,
|
|
|
4795
4840
|
// operator's `--tls-cert` sat validated and unused. A default here cannot be right, because the
|
|
4796
4841
|
// safe value and the common value are different values — every caller knows its transport, and
|
|
4797
4842
|
// the one that does not is the one that must not compile.
|
|
4798
|
-
transport, rotateSys = false, maxFileStore, quietBoot = false
|
|
4843
|
+
transport, rotateSys = false, maxFileStore, quietBoot = false,
|
|
4844
|
+
// `--auth-timeout`. Absent: the timeout the root's broker policy records, so a bare `up` renders
|
|
4845
|
+
// the one an earlier `up` set.
|
|
4846
|
+
requestedAuthTimeout) {
|
|
4799
4847
|
const dir = authDir(cotalRoot()); // the broker config (server.conf) still lands under the FS auth dir
|
|
4800
4848
|
const store = workspaceSecretStore(cotalRoot());
|
|
4801
4849
|
let auth = await getSpaceAuth(store, space).catch((error) => { throw unreadableTrust(error); });
|
|
@@ -4912,12 +4960,13 @@ transport, rotateSys = false, maxFileStore, quietBoot = false) {
|
|
|
4912
4960
|
}
|
|
4913
4961
|
// Owner-private regardless of umask, as `writeOpenBrokerConf` writes the open configuration: the
|
|
4914
4962
|
// broker preset refuses a configuration that other local users can write.
|
|
4915
|
-
|
|
4963
|
+
const authTimeout = requestedAuthTimeout ?? readBrokerPolicy(cotalRoot())?.authTimeout;
|
|
4964
|
+
writeBrokerConfig(confPath, serverConfig(auth, spaces, { transport, port, storeDir: configuredStoreDir(cotalRoot(), storeDir), maxFileStore, authTimeout, host, wsPort, wsHost: host, extraAccounts }));
|
|
4916
4965
|
// Ephemeral setup cred: used only to probe reachability, pre-create the space streams/buckets
|
|
4917
4966
|
// (setupSpaceStreams) and seed the channel registry (seedChannelRegistry) — all within the
|
|
4918
4967
|
// enumerated `provisioner` scope. No broad `manager` residual for the up path.
|
|
4919
4968
|
const creds = await mintCreds(auth, newIdentity(), "provisioner");
|
|
4920
|
-
return { confPath, creds, wsPort, ...(prepared ? { prepared, stateDir } : {}) };
|
|
4969
|
+
return { confPath, creds, wsPort, ...(prepared ? { prepared, stateDir } : {}), ...(authTimeout !== undefined ? { authTimeout } : {}) };
|
|
4921
4970
|
}
|
|
4922
4971
|
/**
|
|
4923
4972
|
* Refuse the rotation if this root's own bookkeeping still shows a broker running. This is a
|