@synopackageland/cli 0.48.13 → 0.48.15
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/CHANGELOG.md +9 -1
- package/README.md +10 -1
- package/dist/cli.js +2 -0
- package/dist/host/catalog-install.d.ts +1 -1
- package/dist/host/catalog-install.js +30 -16
- package/dist/host/container-pull.js +2 -7
- package/dist/host/package-commands.d.ts +6 -7
- package/dist/host/package-commands.js +6 -3
- package/dist/standalone/identity-gateway.d.ts +3 -0
- package/dist/standalone/identity-gateway.js +30 -1
- package/dist/terminal-output.d.ts +4 -0
- package/dist/terminal-output.js +36 -0
- package/package.json +5 -3
- package/schema/dsm-api-contract.json +1127 -0
- package/schema/dsm-package.schema.json +13 -0
- package/schema/identity-gateway.v1.schema.json +15 -0
- package/schema/package-state.schema.json +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,7 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.48.15
|
|
4
4
|
|
|
5
|
+
- Accept identity_gateway.secure_context: required; check and build reject it when the pinned SDK does not support it, and the gateway shows a localized HTTPS guidance page for HTTP visits without redirecting
|
|
6
|
+
- Validate DSM WebAPI requests in tests against a strict request contract
|
|
7
|
+
|
|
8
|
+
## 0.48.14
|
|
9
|
+
|
|
10
|
+
- status, install, uninstall and deploy no longer request the unsupported installing_target package-list field, so DSM versions that reject it work again
|
|
11
|
+
- --json prints one final object on stdout; progress goes to stderr once per change
|
|
12
|
+
- Closing the output pipe no longer abandons stop and uninstall; an interrupted uninstall resumes or reports the package as removed
|
|
5
13
|
- Reject daemon.nofile in check, build and inspect until package-safe activation is supported
|
|
6
14
|
- Stop daemons through the non-root SDK controller during migration and teardown; continue executor cleanup after a daemon stop failure
|
|
7
15
|
|
package/README.md
CHANGED
|
@@ -107,6 +107,9 @@ package Unix sockets. The audit follows each shipped Linux binary's import graph
|
|
|
107
107
|
unimported development commands are excluded. Use
|
|
108
108
|
`identity_gateway.upstream_auth_paths` for client API paths that use upstream
|
|
109
109
|
authentication. See [App entry and registration](docs/app-entry.md).
|
|
110
|
+
Apps needing a secure context can declare `identity_gateway.secure_context: required`
|
|
111
|
+
with the latest SDK; HTTP navigation then shows standard HTTPS guidance. See
|
|
112
|
+
[HTTPS guidance](docs/path-ingress.md#apps-requiring-https).
|
|
110
113
|
|
|
111
114
|
`init` and `add` read their templates from the locally installed
|
|
112
115
|
`@synopackageland/templates`. The CLI's npm dependency range selects compatible
|
|
@@ -502,7 +505,7 @@ variables also work in `.env`; timeout/interval values accept integer seconds fr
|
|
|
502
505
|
| `DSM_OPERATION_TIMEOUT_SECONDS` | 600 | One SPK upload, install/upgrade compound, or package start/stop request |
|
|
503
506
|
| `DSM_INSTALL_MAX_POLLS` | 10000 | Per-package polling attempts across initial checks, pre-pull and install/start verification |
|
|
504
507
|
| `DSM_UNINSTALL_TIMEOUT_SECONDS` | 1800 | State check, stop and uninstall together |
|
|
505
|
-
| `DSM_POLL_INTERVAL_SECONDS` | 5 | Package-state polling
|
|
508
|
+
| `DSM_POLL_INTERVAL_SECONDS` | 5 | Package-state polling interval |
|
|
506
509
|
| `DSM_IMAGE_PULL_STALL_TIMEOUT_SECONDS` | 1200 | No increase in NAS pull bytes; status heartbeats do not reset this budget |
|
|
507
510
|
|
|
508
511
|
Install/upgrade waiting has no default elapsed-time deadline. Slow successful work
|
|
@@ -519,6 +522,11 @@ pinned image. Pinning alone does not download layers onto the NAS. Pull tasks
|
|
|
519
522
|
are not cancelled or replayed when their response is lost or a budget expires.
|
|
520
523
|
Broken packages skip stop during uninstall; their existing install error does not
|
|
521
524
|
block removal, while new uninstall errors still fail clearly.
|
|
525
|
+
Uninstall resumes a stopped or stopping package, waits for an existing uninstall,
|
|
526
|
+
and succeeds when DSM already verifies the package is absent.
|
|
527
|
+
Polling progress goes to stderr only when it changes, in both text and JSON modes.
|
|
528
|
+
`--json` stdout contains one final JSON object. A closed stdout or stderr pipe does
|
|
529
|
+
not interrupt DSM writes; the command finishes and reports its result through its exit code.
|
|
522
530
|
|
|
523
531
|
`logs --json` emits the usual single JSON envelope, including DSM `worker_msg`,
|
|
524
532
|
status details and the last reported Compose error. A locally retained pre-pull
|
|
@@ -528,6 +536,7 @@ unknown; a generic `install_corruption` does not prove a registry failure.
|
|
|
528
536
|
|
|
529
537
|
`status <package-id> --json` reports `state: "upgrading"`, `"installing"` or
|
|
530
538
|
`"starting"` during replacement/startup, with `fromVersion`/`toVersion` when known.
|
|
539
|
+
Stopping/removal reports `state: "stopping"` or `"uninstalling"` until DSM verifies completion.
|
|
531
540
|
It never reports `installed:false` for those transitions: an upgrade retains
|
|
532
541
|
`installed:true`; a fresh install without a verified payload uses `installed:null`.
|
|
533
542
|
`status` carries the effective DSM/CLI status. The result contract is
|
package/dist/cli.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { nasFlags, withNasOptions } from './nas/options.js';
|
|
2
|
+
import { installOutputGuards } from './terminal-output.js';
|
|
2
3
|
import { upstreamRepository, upstreamMaintainer } from './upstream-attribution.js';
|
|
3
4
|
import { Command, CommanderError } from "commander";
|
|
4
5
|
import { CLI_VERSION } from "./cli-version.js";
|
|
@@ -298,6 +299,7 @@ async function containerBuild(project, arches, options) {
|
|
|
298
299
|
}
|
|
299
300
|
/** Resolves after dispatch; commands may set process.exitCode. Rejections are failures. */
|
|
300
301
|
export async function runCli(argv) {
|
|
302
|
+
installOutputGuards();
|
|
301
303
|
if (argv[2] === 'ctl' && argv[3] === 'external') {
|
|
302
304
|
const { runCtl } = await import('./ctl/cli.js');
|
|
303
305
|
return runCtl(argv.slice(3));
|
|
@@ -13,7 +13,7 @@ interface CatalogPackageEntry {
|
|
|
13
13
|
export interface InstalledPackageState {
|
|
14
14
|
/** null means DSM cannot currently verify an installed payload. */
|
|
15
15
|
installed: boolean | null;
|
|
16
|
-
state?: 'installing' | 'upgrading' | 'starting' | 'unknown';
|
|
16
|
+
state?: 'installing' | 'upgrading' | 'starting' | 'stopping' | 'uninstalling' | 'unknown';
|
|
17
17
|
fromVersion?: string;
|
|
18
18
|
toVersion?: string;
|
|
19
19
|
version?: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CtlError } from '../ctl/errors.js';
|
|
2
2
|
import { readFileSync } from "node:fs";
|
|
3
|
-
import {
|
|
3
|
+
import { progressReporter } from '../terminal-output.js';
|
|
4
4
|
import { pullContainerImages } from './container-pull.js';
|
|
5
5
|
import { savePullFailure } from './package-diagnostics.js';
|
|
6
6
|
import { readPackageOperation, operationOwnerAlive, savePackageOperation, clearPackageOperation, releasePackageOperation } from './package-operation.js';
|
|
@@ -83,7 +83,8 @@ export function packageStateFromRecord(value) {
|
|
|
83
83
|
installed: Boolean(installedPath) || match.installed === true,
|
|
84
84
|
};
|
|
85
85
|
const transition = status?.toLowerCase();
|
|
86
|
-
if (transition === 'installing' || transition === 'upgrading' || transition === 'starting'
|
|
86
|
+
if (transition === 'installing' || transition === 'upgrading' || transition === 'starting' ||
|
|
87
|
+
transition === 'stopping' || transition === 'uninstalling') {
|
|
87
88
|
state.state = transition;
|
|
88
89
|
// DSM can remove installed_info while replacing the payload.
|
|
89
90
|
state.installed = state.installed || transition === 'upgrading' ? true : null;
|
|
@@ -133,7 +134,10 @@ export async function fetchInstalledPackageState(dsmOrigin, cookieHeader, packag
|
|
|
133
134
|
api: "SYNO.Core.Package",
|
|
134
135
|
version: "2",
|
|
135
136
|
method: "list",
|
|
136
|
-
additional
|
|
137
|
+
// installing_target is not a supported additional field on some DSM 7.x
|
|
138
|
+
// versions (error 120). Transitions come from status/list_status and the
|
|
139
|
+
// retained installation task; only report a target version with evidence.
|
|
140
|
+
additional: JSON.stringify(["status", "installed_info"]),
|
|
137
141
|
ignore_hidden: "false",
|
|
138
142
|
}, { timeoutMs, signal: context.signal });
|
|
139
143
|
if (!Array.isArray(record(body.data).packages))
|
|
@@ -213,17 +217,19 @@ export async function waitForInstalledVersion(readState, options) {
|
|
|
213
217
|
const deadline = options.deadlineMs === undefined ? Infinity : Date.now() + options.deadlineMs;
|
|
214
218
|
const consumePoll = options.consumePoll ?? installWorkload(options.packageId, options.maxPolls);
|
|
215
219
|
const pollMs = options.pollMs ?? dsmPollIntervalMs();
|
|
220
|
+
const progress = progressReporter(options.onProgress);
|
|
216
221
|
let transitioned = !options.requireTransition;
|
|
217
222
|
while (Date.now() < deadline) {
|
|
218
223
|
consumePoll();
|
|
219
224
|
let state;
|
|
225
|
+
let timedOut = false;
|
|
220
226
|
try {
|
|
221
227
|
state = await cancelableInstall(() => Promise.resolve(readState(Math.min(dsmRequestTimeoutMs(), Math.max(1, deadline - Date.now())))), options.signal);
|
|
222
228
|
}
|
|
223
229
|
catch (error) {
|
|
224
230
|
if (!isHostTimeout(error))
|
|
225
231
|
throw error;
|
|
226
|
-
|
|
232
|
+
timedOut = true;
|
|
227
233
|
}
|
|
228
234
|
if (state && !installInProgress(state) && packageFailure(state)) {
|
|
229
235
|
throw new CtlError('DSM_INSTALL_FAILED', `DSM reports package ${options.packageId} install did not complete (Package Center status ${state.status ?? 'unknown'}): ${failureDetail(state)}`.trim(), 'Check the DSM Package Center install/start log');
|
|
@@ -238,7 +244,8 @@ export async function waitForInstalledVersion(readState, options) {
|
|
|
238
244
|
(!options.expectedVersion || state.version === options.expectedVersion) &&
|
|
239
245
|
(!options.requireRunning || running) && transitioned)
|
|
240
246
|
return state;
|
|
241
|
-
|
|
247
|
+
progress(timedOut ? `${options.packageId}: status request timed out; still installing/starting…` :
|
|
248
|
+
`${options.packageId}: installing/starting… (DSM status ${state?.status ?? 'unavailable'})`);
|
|
242
249
|
await installDelay(Math.min(pollMs, Math.max(0, deadline - Date.now())), options.signal);
|
|
243
250
|
}
|
|
244
251
|
throw installBudgetExpired(options);
|
|
@@ -259,7 +266,7 @@ export async function uninstallPackageFromDsm(options) {
|
|
|
259
266
|
const deadline = Date.now() + (options.deadlineMs ?? dsmUninstallTimeoutMs());
|
|
260
267
|
const requestMs = dsmRequestTimeoutMs(), operationMs = dsmOperationTimeoutMs();
|
|
261
268
|
const pollMs = options.pollMs ?? dsmPollIntervalMs();
|
|
262
|
-
const progress = options.onProgress
|
|
269
|
+
const progress = progressReporter(options.onProgress);
|
|
263
270
|
let phase = 'checking package state';
|
|
264
271
|
let previousFailure;
|
|
265
272
|
const expired = () => new CtlError('DSM_UNINSTALL_TIMEOUT', `Package ${options.packageId}: overall uninstall budget exhausted while ${phase}; DSM may still be stopping/uninstalling.`, 'Check Package Center before retrying; stop/uninstall requests were not replayed');
|
|
@@ -268,19 +275,19 @@ export async function uninstallPackageFromDsm(options) {
|
|
|
268
275
|
throw expired();
|
|
269
276
|
return Math.min(limit, deadline - Date.now());
|
|
270
277
|
};
|
|
271
|
-
const heartbeat = setInterval(() => progress(`${options.packageId}: ${phase}…`), pollMs);
|
|
272
278
|
try {
|
|
273
279
|
const sid = extractSid(options.cookieHeader);
|
|
274
280
|
const wait = async (done) => {
|
|
275
281
|
while (Date.now() < deadline) {
|
|
276
282
|
let state;
|
|
283
|
+
let timedOut = false;
|
|
277
284
|
try {
|
|
278
285
|
state = await fetchInstalledPackageState(options.dsmOrigin, options.cookieHeader, options.packageId, remaining(requestMs));
|
|
279
286
|
}
|
|
280
287
|
catch (error) {
|
|
281
288
|
if (!isHostTimeout(error))
|
|
282
289
|
throw error;
|
|
283
|
-
|
|
290
|
+
timedOut = true;
|
|
284
291
|
}
|
|
285
292
|
if (state && Date.now() < deadline) {
|
|
286
293
|
if (done(state))
|
|
@@ -288,7 +295,8 @@ export async function uninstallPackageFromDsm(options) {
|
|
|
288
295
|
if (packageFailure(state) && !(phase === 'uninstalling' && previousFailure === failureDetail(state)))
|
|
289
296
|
throw new CtlError('DSM_UNINSTALL_FAILED', `DSM reports ${options.packageId} failed while ${phase}: ${failureDetail(state) || state.status}`, 'Check the DSM Package Center stop/uninstall log');
|
|
290
297
|
}
|
|
291
|
-
progress(`${options.packageId}:
|
|
298
|
+
progress(timedOut ? `${options.packageId}: status request timed out; ${phase}…` :
|
|
299
|
+
`${options.packageId}: ${phase}…${state?.status === phase ? '' : ` (DSM status ${state?.status ?? 'unavailable'})`}`);
|
|
292
300
|
await new Promise(resolve => setTimeout(resolve, Math.min(pollMs, Math.max(0, deadline - Date.now()))));
|
|
293
301
|
}
|
|
294
302
|
throw expired();
|
|
@@ -307,7 +315,18 @@ export async function uninstallPackageFromDsm(options) {
|
|
|
307
315
|
progress(`${options.packageId}: ${method} request timed out; checking DSM state without replay…`);
|
|
308
316
|
}
|
|
309
317
|
};
|
|
310
|
-
|
|
318
|
+
let before = await wait(() => true);
|
|
319
|
+
if (before.state === 'uninstalling') {
|
|
320
|
+
phase = 'uninstalling';
|
|
321
|
+
progress(`${options.packageId}: ${phase}…`);
|
|
322
|
+
await wait(state => state.installed === false);
|
|
323
|
+
return;
|
|
324
|
+
}
|
|
325
|
+
if (before.state === 'stopping') {
|
|
326
|
+
phase = 'stopping';
|
|
327
|
+
progress(`${options.packageId}: ${phase}…`);
|
|
328
|
+
before = await wait(state => state.installed === false || packageStatusIsStopped(state));
|
|
329
|
+
}
|
|
311
330
|
if (before.state || before.installed === null)
|
|
312
331
|
throw new CtlError('PACKAGE_BUSY', `Package ${options.packageId} has an unresolved operation`, 'Wait for DSM to finish before uninstalling');
|
|
313
332
|
if (before.installed === false)
|
|
@@ -331,9 +350,6 @@ export async function uninstallPackageFromDsm(options) {
|
|
|
331
350
|
catch (error) {
|
|
332
351
|
throw uninstallFailure(options.packageId, error);
|
|
333
352
|
}
|
|
334
|
-
finally {
|
|
335
|
-
clearInterval(heartbeat);
|
|
336
|
-
}
|
|
337
353
|
}
|
|
338
354
|
export function catalogInstallationRequests(entry, installed, sid, volumePath) {
|
|
339
355
|
const install = {
|
|
@@ -446,7 +462,7 @@ export async function installPackageFromLocalSpk(options) {
|
|
|
446
462
|
let verified = false;
|
|
447
463
|
const requestMs = dsmRequestTimeoutMs(), operationMs = dsmOperationTimeoutMs();
|
|
448
464
|
const pollMs = options.pollMs ?? dsmPollIntervalMs();
|
|
449
|
-
const progress = options.onProgress
|
|
465
|
+
const progress = progressReporter(options.onProgress);
|
|
450
466
|
let phase = 'checking package state';
|
|
451
467
|
const remaining = (limit) => {
|
|
452
468
|
if (signal.aborted)
|
|
@@ -455,7 +471,6 @@ export async function installPackageFromLocalSpk(options) {
|
|
|
455
471
|
throw installBudgetExpired(options);
|
|
456
472
|
return Math.min(limit, deadline - Date.now());
|
|
457
473
|
};
|
|
458
|
-
const heartbeat = setInterval(() => progress(`${options.packageId}: ${phase}…`), pollMs);
|
|
459
474
|
process.once('SIGINT', cancel);
|
|
460
475
|
process.once('SIGTERM', cancel);
|
|
461
476
|
try {
|
|
@@ -531,7 +546,6 @@ export async function installPackageFromLocalSpk(options) {
|
|
|
531
546
|
throw error;
|
|
532
547
|
}
|
|
533
548
|
finally {
|
|
534
|
-
clearInterval(heartbeat);
|
|
535
549
|
process.removeListener('SIGINT', cancel);
|
|
536
550
|
process.removeListener('SIGTERM', cancel);
|
|
537
551
|
if (operation) {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { CtlError } from '../ctl/errors.js';
|
|
2
2
|
import { parseImageReference } from '../images/pin.js';
|
|
3
3
|
import { registryBaseUrl } from '../compose/registry-mirrors.js';
|
|
4
|
-
import {
|
|
4
|
+
import { progressReporter } from '../terminal-output.js';
|
|
5
5
|
import { maskDiagnostic } from './package-diagnostics.js';
|
|
6
6
|
import { installWorkload, installCanceled, installDelay } from './install-control.js';
|
|
7
7
|
import { dsmFetch } from './dsm-http.js';
|
|
@@ -23,7 +23,7 @@ export async function pullContainerImages(options) {
|
|
|
23
23
|
const consumePoll = options.consumePoll ?? installWorkload('container image pull');
|
|
24
24
|
const stallMs = options.stallMs ?? dsmPullStallTimeoutMs();
|
|
25
25
|
const pollMs = options.pollMs ?? dsmPollIntervalMs();
|
|
26
|
-
const progress = options.onProgress
|
|
26
|
+
const progress = progressReporter(options.onProgress);
|
|
27
27
|
for (const image of new Set(options.images)) {
|
|
28
28
|
const parsed = parseImageReference(image);
|
|
29
29
|
if (!parsed)
|
|
@@ -56,8 +56,6 @@ export async function pullContainerImages(options) {
|
|
|
56
56
|
return body.data;
|
|
57
57
|
};
|
|
58
58
|
progress(`${context}: starting NAS image pull…`);
|
|
59
|
-
// Even while a NAS request is pending, keep stderr alive.
|
|
60
|
-
const heartbeat = setInterval(() => progress(`${context}: pulling… (${Math.max(0, downloaded)} bytes)`), pollMs);
|
|
61
59
|
try {
|
|
62
60
|
if (parsed.digest) {
|
|
63
61
|
const inventory = await call('list', { offset: '0', limit: '-1' });
|
|
@@ -119,8 +117,5 @@ export async function pullContainerImages(options) {
|
|
|
119
117
|
throw error;
|
|
120
118
|
throw fail('CONTAINER_PULL_FAILED', `NAS image pull failed: ${error instanceof Error ? error.message : 'unknown transport error'}`);
|
|
121
119
|
}
|
|
122
|
-
finally {
|
|
123
|
-
clearInterval(heartbeat);
|
|
124
|
-
}
|
|
125
120
|
}
|
|
126
121
|
}
|
|
@@ -58,21 +58,20 @@ export declare function uninstallPackage(id: string, options?: {
|
|
|
58
58
|
yes?: boolean;
|
|
59
59
|
dryRun?: boolean;
|
|
60
60
|
}): Promise<{
|
|
61
|
-
dryRun
|
|
61
|
+
dryRun?: boolean | undefined;
|
|
62
62
|
host: string;
|
|
63
63
|
package: string;
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
installed: boolean;
|
|
65
|
+
action?: undefined;
|
|
66
66
|
} | {
|
|
67
|
+
dryRun: boolean;
|
|
67
68
|
host: string;
|
|
68
69
|
package: string;
|
|
69
|
-
|
|
70
|
-
dryRun?: undefined;
|
|
71
|
-
action?: undefined;
|
|
70
|
+
action: string;
|
|
72
71
|
}>;
|
|
73
72
|
export declare function packageStatus(id: string, host?: string): Promise<{
|
|
74
73
|
installed: boolean | null;
|
|
75
|
-
state?: "installing" | "upgrading" | "starting" | "unknown";
|
|
74
|
+
state?: "installing" | "upgrading" | "starting" | "stopping" | "uninstalling" | "unknown";
|
|
76
75
|
fromVersion?: string;
|
|
77
76
|
toVersion?: string;
|
|
78
77
|
version?: string;
|
|
@@ -201,10 +201,13 @@ export async function uninstallPackage(id, options = {}) {
|
|
|
201
201
|
packageId(id);
|
|
202
202
|
const nas = await connectNas(options.host);
|
|
203
203
|
const state = await fetchInstalledPackageState(nas.session.origin, nas.session.cookie, id);
|
|
204
|
-
if (state
|
|
204
|
+
if (!state)
|
|
205
|
+
throw fail('PACKAGE_STATUS_UNKNOWN', 'DSM did not return a verifiable package state');
|
|
206
|
+
if (state.installed === false && !state.state)
|
|
207
|
+
return { host: nas.name, package: id, installed: false, ...(options.dryRun ? { dryRun: true } : {}) };
|
|
208
|
+
const resuming = state.state === 'stopping' || state.state === 'uninstalling';
|
|
209
|
+
if (!resuming && (state.state || state.installed === null))
|
|
205
210
|
throw fail('PACKAGE_BUSY', `Package ${id} has an unresolved operation`);
|
|
206
|
-
if (!state?.installed)
|
|
207
|
-
throw fail("PACKAGE_NOT_INSTALLED", `Package ${id} is not installed`);
|
|
208
211
|
if (options.dryRun)
|
|
209
212
|
return { dryRun: true, host: nas.name, package: id, action: "uninstall" };
|
|
210
213
|
await requireAdministrator(nas);
|
|
@@ -19,6 +19,7 @@ export interface GatewayExternalAccess {
|
|
|
19
19
|
/** One-URL upstream: DSM launch and local navigations go to the primary external origin. */
|
|
20
20
|
single_origin?: true;
|
|
21
21
|
}
|
|
22
|
+
export declare const SECURE_CONTEXT_MIN_SDK = "0.50.8";
|
|
22
23
|
export declare const EXTERNAL_ACCESS_MIN_SDK = "0.29.0";
|
|
23
24
|
/** SDK 0.28 has the diagnostic ping only; older gateways reject external JSON. */
|
|
24
25
|
export declare function externalAccessSdkSupported(sdk: string): boolean;
|
|
@@ -48,6 +49,8 @@ export interface IdentityGateway {
|
|
|
48
49
|
/** The SDK release the gateway is built from. */
|
|
49
50
|
sdk: string;
|
|
50
51
|
external_access?: GatewayExternalAccess;
|
|
52
|
+
/** Require an HTTPS browser origin before serving App routes. Omit to allow HTTP. */
|
|
53
|
+
secure_context?: "required";
|
|
51
54
|
mode: GatewayMode;
|
|
52
55
|
/** Fixed same-origin menu target, including optional query and fragment. */
|
|
53
56
|
launch_path?: string;
|
|
@@ -20,6 +20,11 @@ export const GATEWAY_SETTINGS_CGI_PATH = "ui/sso/settings.cgi";
|
|
|
20
20
|
export const GATEWAY_PAYLOAD_DIR = "_sso";
|
|
21
21
|
export const GATEWAY_EXEC = `${GATEWAY_PAYLOAD_DIR}/gateway`;
|
|
22
22
|
export const GATEWAY_CONFIG_PATH = "sso/gateway.json";
|
|
23
|
+
export const SECURE_CONTEXT_MIN_SDK = "0.50.8";
|
|
24
|
+
function secureContextReleaseSupported(sdk) {
|
|
25
|
+
const [major, minor, patch] = sdk.split(".").map(Number);
|
|
26
|
+
return major > 0 || minor > 50 || minor === 50 && patch >= 8;
|
|
27
|
+
}
|
|
23
28
|
export const EXTERNAL_ACCESS_MIN_SDK = "0.29.0";
|
|
24
29
|
/** SDK 0.28 has the diagnostic ping only; older gateways reject external JSON. */
|
|
25
30
|
export function externalAccessSdkSupported(sdk) {
|
|
@@ -50,6 +55,10 @@ const pathPrefix = (path, prefix) => {
|
|
|
50
55
|
const upstreamPrefix = (v) => typeof v === "string" && v.length <= 512 && /^\/[A-Za-z0-9._~/-]+$/.test(v) &&
|
|
51
56
|
v !== "/" && !v.includes("//") && !v.split("/").some(p => p === "." || p === "..") &&
|
|
52
57
|
!pathPrefix(v, "/_sso") && !pathPrefix(v, "/_spl");
|
|
58
|
+
function secureContextSdkSupported(dir) {
|
|
59
|
+
const source = join(dir, "idgateway/secure_context.go");
|
|
60
|
+
return existsSync(source) && /const SecureContextVersion = 1\b/.test(readFileSync(source, "utf8"));
|
|
61
|
+
}
|
|
53
62
|
function upstreamAuthSdkSupported(dir) {
|
|
54
63
|
const source = join(dir, "idgateway/upstream_auth.go");
|
|
55
64
|
return existsSync(source) && /const UpstreamAuthPathsVersion = 1\b/.test(readFileSync(source, "utf8"));
|
|
@@ -154,6 +163,7 @@ export function readIdentityGateway(value, daemon, fail, packagedPayload = false
|
|
|
154
163
|
!only(value, [
|
|
155
164
|
"sdk",
|
|
156
165
|
"external_access",
|
|
166
|
+
"secure_context",
|
|
157
167
|
"mode",
|
|
158
168
|
"access",
|
|
159
169
|
"upstream_access",
|
|
@@ -176,9 +186,11 @@ export function readIdentityGateway(value, daemon, fail, packagedPayload = false
|
|
|
176
186
|
"token",
|
|
177
187
|
"account",
|
|
178
188
|
])) {
|
|
179
|
-
return invalid("accepts only sdk, external_access, mode, access, upstream_access, groups, upstream, listen, passthrough, upstream_auth_paths, optional_passthrough, redirects, email_domain, session_ttl, roles, headers, oidc, token and account.");
|
|
189
|
+
return invalid("accepts only sdk, external_access, secure_context, mode, access, upstream_access, groups, upstream, listen, passthrough, upstream_auth_paths, optional_passthrough, redirects, email_domain, session_ttl, roles, headers, oidc, token and account.");
|
|
180
190
|
}
|
|
181
191
|
const v = value;
|
|
192
|
+
if (v.secure_context !== undefined && v.secure_context !== "required")
|
|
193
|
+
return invalid("secure_context must be required or omitted.");
|
|
182
194
|
let externalAccess;
|
|
183
195
|
if (v.external_access !== undefined) {
|
|
184
196
|
const external = v.external_access;
|
|
@@ -230,6 +242,17 @@ export function readIdentityGateway(value, daemon, fail, packagedPayload = false
|
|
|
230
242
|
return invalid("response_header_timeout_seconds must be 1–3600.");
|
|
231
243
|
if (typeof v.sdk !== "string" || !/^\d+\.\d+\.\d+$/.test(v.sdk))
|
|
232
244
|
return invalid("sdk must be the SDK release (x.y.z) to build the gateway from.");
|
|
245
|
+
if (v.secure_context !== undefined) {
|
|
246
|
+
if (!secureContextReleaseSupported(v.sdk))
|
|
247
|
+
return invalid(`secure_context requires SDK ${SECURE_CONTEXT_MIN_SDK} or later; upgrade identity_gateway.sdk and use matching SDK sources.`);
|
|
248
|
+
try {
|
|
249
|
+
if (!secureContextSdkSupported(sdkSource(v.sdk).goDir))
|
|
250
|
+
return invalid("secure_context requires an SDK with HTTPS guidance support; upgrade the selected SDK and use matching SDK sources.");
|
|
251
|
+
}
|
|
252
|
+
catch {
|
|
253
|
+
return invalid("The SDK source for secure_context is unavailable; select an SDK with HTTPS guidance support and matching sources.");
|
|
254
|
+
}
|
|
255
|
+
}
|
|
233
256
|
if (externalAccess && !externalAccessSdkSupported(v.sdk)) {
|
|
234
257
|
fail({ code: "STANDALONE_IDENTITY_GATEWAY_EXTERNAL_SDK_REQUIRED", message: `identity_gateway.external_access requires SDK ${EXTERNAL_ACCESS_MIN_SDK} or later; SDK 0.28.0 provides the diagnostic ping only.` });
|
|
235
258
|
return undefined;
|
|
@@ -340,6 +363,7 @@ export function readIdentityGateway(value, daemon, fail, packagedPayload = false
|
|
|
340
363
|
...(ingress ? { ingress: ingress } : {}),
|
|
341
364
|
...(v.launch_path !== undefined ? { launch_path: v.launch_path } : {}),
|
|
342
365
|
access,
|
|
366
|
+
...(v.secure_context !== undefined ? { secure_context: "required" } : {}),
|
|
343
367
|
...(v.upstream_access !== undefined ? { upstream_access: v.upstream_access } : {}),
|
|
344
368
|
...(Array.isArray(v.groups) ? { groups: v.groups } : {}),
|
|
345
369
|
...(v.max_upload_bytes !== undefined
|
|
@@ -489,6 +513,7 @@ export function identityGatewayConfig(m) {
|
|
|
489
513
|
stop_seconds: m.daemon?.timeouts.stop ?? m.lifecycleTimeouts?.stop ?? 30,
|
|
490
514
|
} : {}),
|
|
491
515
|
mode: g.mode,
|
|
516
|
+
...(g.secure_context ? { secure_context: g.secure_context } : {}),
|
|
492
517
|
...(g.launch_path ? { launch_path: g.launch_path } : {}),
|
|
493
518
|
access: g.access ?? "dsm-users",
|
|
494
519
|
...(g.upstream_access ? { upstream_access: g.upstream_access } : {}),
|
|
@@ -561,6 +586,8 @@ export function gatewayDaemon(daemon) {
|
|
|
561
586
|
export async function buildIdentityGateway(m, arch, work, run) {
|
|
562
587
|
if (!m.identityGateway)
|
|
563
588
|
return undefined;
|
|
589
|
+
if (m.identityGateway.secure_context && !secureContextReleaseSupported(m.identityGateway.sdk))
|
|
590
|
+
throw new StandaloneBuildError("STANDALONE_IDENTITY_GATEWAY_INVALID", `secure_context requires SDK ${SECURE_CONTEXT_MIN_SDK} or later; upgrade identity_gateway.sdk and use matching SDK sources.`);
|
|
564
591
|
let sdk;
|
|
565
592
|
try {
|
|
566
593
|
sdk = sdkSource(m.identityGateway.sdk);
|
|
@@ -569,6 +596,8 @@ export async function buildIdentityGateway(m, arch, work, run) {
|
|
|
569
596
|
throw new StandaloneBuildError("SDK_DOWNLOAD_FAILED", error.message.replace(/^\[[A-Z_]+\] /, ""));
|
|
570
597
|
}
|
|
571
598
|
runtimeBudgetSource(sdk.goDir, m);
|
|
599
|
+
if (m.identityGateway.secure_context && !secureContextSdkSupported(sdk.goDir))
|
|
600
|
+
throw new StandaloneBuildError("STANDALONE_IDENTITY_GATEWAY_INVALID", "secure_context requires an SDK with HTTPS guidance support; upgrade the selected SDK and use matching SDK sources.");
|
|
572
601
|
if (m.identityGateway.upstream_auth_paths && !upstreamAuthSdkSupported(sdk.goDir))
|
|
573
602
|
throw new StandaloneBuildError("STANDALONE_IDENTITY_GATEWAY_INVALID", "The selected SDK lacks upstream_auth_paths and its build-bound entry policy; use matching SDK sources.");
|
|
574
603
|
if (gatewayExternalAccess(m.identityGateway)) {
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
/** A disconnected output consumer must not abandon a dispatched DSM mutation. */
|
|
2
|
+
export declare function installOutputGuards(): void;
|
|
3
|
+
/** Report changes, keeping machine-readable command results on stdout. */
|
|
4
|
+
export declare function progressReporter(output?: (message: string) => void): (message: string) => void;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { terminalSafe } from './terminal-text.js';
|
|
2
|
+
const guarded = new WeakSet();
|
|
3
|
+
let signalGuarded = false;
|
|
4
|
+
const brokenPipe = (error) => error?.code === 'EPIPE';
|
|
5
|
+
/** A disconnected output consumer must not abandon a dispatched DSM mutation. */
|
|
6
|
+
export function installOutputGuards() {
|
|
7
|
+
for (const stream of [process.stdout, process.stderr]) {
|
|
8
|
+
if (guarded.has(stream))
|
|
9
|
+
continue;
|
|
10
|
+
guarded.add(stream);
|
|
11
|
+
stream.on('error', error => { if (!brokenPipe(error))
|
|
12
|
+
throw error; });
|
|
13
|
+
}
|
|
14
|
+
if (!signalGuarded) {
|
|
15
|
+
signalGuarded = true;
|
|
16
|
+
process.on('SIGPIPE', () => { });
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Report changes, keeping machine-readable command results on stdout. */
|
|
20
|
+
export function progressReporter(output = message => {
|
|
21
|
+
process.stderr.write(`${terminalSafe(message)}\n`);
|
|
22
|
+
}) {
|
|
23
|
+
let previous;
|
|
24
|
+
return message => {
|
|
25
|
+
if (message === previous)
|
|
26
|
+
return;
|
|
27
|
+
previous = message;
|
|
28
|
+
try {
|
|
29
|
+
output(message);
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
if (!brokenPipe(error))
|
|
33
|
+
throw error;
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synopackageland/cli",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.15",
|
|
4
4
|
"description": "Syno Package Land Developer Kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -22,14 +22,16 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"check:docs": "node --test scripts/check-doc-versions.test.mjs && node scripts/check-doc-versions.mjs",
|
|
24
24
|
"build": "rm -rf dist && tsc",
|
|
25
|
-
"test": "npm run build && node --import tsx --test --test-concurrency=${SYNOPKGLAND_GATE_JOBS:-3} test/*.test.ts test/ctl/*.test.ts",
|
|
25
|
+
"test": "npm run build && node --import tsx --import ./test/helpers/strict-dsm-setup.ts --test --test-concurrency=${SYNOPKGLAND_GATE_JOBS:-3} test/*.test.ts test/ctl/*.test.ts",
|
|
26
26
|
"test:glossary": "node --test scripts/test/glossary-drift.test.mjs",
|
|
27
27
|
"test:scripts": "node --test scripts/test/gate.test.mjs scripts/test/release.test.mjs scripts/test/pack-docker.test.mjs scripts/test/npm-pack.test.mjs scripts/test/executor-bump.test.mjs scripts/test/smoke-exports.test.mjs scripts/test/parallel.test.mjs scripts/test/scaffold-matrix.test.mjs scripts/test/frontend-deps.test.mjs scripts/test/docker-gate.test.mjs scripts/test/gate-plan.test.mjs scripts/test/gates.test.mjs && python3 scripts/test/npm-publish.py",
|
|
28
28
|
"gates": "bash scripts/ci/gates.sh",
|
|
29
29
|
"gates:fast": "bash scripts/ci/gates.sh",
|
|
30
30
|
"prepublishOnly": "npm run build",
|
|
31
31
|
"gates:full": "bash scripts/ci/gates.sh --full",
|
|
32
|
-
"test:basic": "node --import tsx --test test/schema.test.ts test/standalone-manifest.test.ts test/native-arch.test.ts test/archive-inventory.test.ts"
|
|
32
|
+
"test:basic": "node --import tsx --test test/schema.test.ts test/standalone-manifest.test.ts test/native-arch.test.ts test/archive-inventory.test.ts",
|
|
33
|
+
"check:dsm-contract": "node scripts/check-dsm-api-contract.mjs",
|
|
34
|
+
"check:dsm-hub": "node scripts/check-dsm-api-hub.mjs"
|
|
33
35
|
},
|
|
34
36
|
"dependencies": {
|
|
35
37
|
"@napi-rs/keyring": "^2.1.1",
|