@synopackageland/cli 0.48.14 → 0.48.16
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 +10 -0
- package/README.md +10 -0
- package/dist/host/catalog-install.d.ts +4 -0
- package/dist/host/catalog-install.js +14 -9
- package/dist/host/install-plan.d.ts +2 -1
- package/dist/host/install-plan.js +9 -2
- package/dist/host/package-commands.d.ts +9 -2
- package/dist/host/package-commands.js +35 -17
- package/dist/standalone/identity-gateway.d.ts +3 -0
- package/dist/standalone/identity-gateway.js +30 -1
- 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/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.48.16
|
|
4
|
+
|
|
5
|
+
- install and deploy repair a broken package at its installed version with an in-place reinstall that keeps App data; healthy packages at the same version stay unchanged
|
|
6
|
+
- status shows broken packages with the exact repair command
|
|
7
|
+
|
|
8
|
+
## 0.48.15
|
|
9
|
+
|
|
10
|
+
- 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
|
|
11
|
+
- Validate DSM WebAPI requests in tests against a strict request contract
|
|
12
|
+
|
|
3
13
|
## 0.48.14
|
|
4
14
|
|
|
5
15
|
- status, install, uninstall and deploy no longer request the unsupported installing_target package-list field, so DSM versions that reject it work again
|
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
|
|
@@ -517,6 +520,13 @@ and daemon cause/endpoint when DSM provides them. Configure a reachable mirror,
|
|
|
517
520
|
trust an inspecting CA in Container Manager, or use `images pin` and preload the
|
|
518
521
|
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.
|
|
523
|
+
Installing the same release of a healthy package is a no-op. For a broken package,
|
|
524
|
+
`install <package-id>@<installed-version> --yes` or `install <file.spk> --yes`
|
|
525
|
+
reports `action: "repair"` and uses DSM's in-place reinstall with the existing data;
|
|
526
|
+
it never uninstalls first. Completion requires the selected version, a running
|
|
527
|
+
payload and no broken/error state. `status <package-id>` includes the failure
|
|
528
|
+
and a pinned repair command. An unresolved repair retains its operation record;
|
|
529
|
+
check DSM Package Center before retrying, since uncertain writes are not replayed.
|
|
520
530
|
Broken packages skip stop during uninstall; their existing install error does not
|
|
521
531
|
block removal, while new uninstall errors still fail clearly.
|
|
522
532
|
Uninstall resumes a stopped or stopping package, waits for an existing uninstall,
|
|
@@ -40,6 +40,7 @@ export declare function fetchInstalledPackageState(dsmOrigin: string, cookieHead
|
|
|
40
40
|
signal?: AbortSignal;
|
|
41
41
|
ignoreOperation?: boolean;
|
|
42
42
|
}): Promise<InstalledPackageState | undefined>;
|
|
43
|
+
export declare function packageIsBroken(state: InstalledPackageState): boolean;
|
|
43
44
|
export interface InstallWaitOptions {
|
|
44
45
|
packageId: string;
|
|
45
46
|
expectedVersion?: string;
|
|
@@ -47,6 +48,8 @@ export interface InstallWaitOptions {
|
|
|
47
48
|
pollMs?: number;
|
|
48
49
|
requireRunning?: boolean;
|
|
49
50
|
requireTransition?: boolean;
|
|
51
|
+
/** The old corrupt payload can remain visible until DSM replaces it. */
|
|
52
|
+
repairing?: boolean;
|
|
50
53
|
onProgress?: (message: string) => void;
|
|
51
54
|
maxPolls?: number;
|
|
52
55
|
consumePoll?: () => void;
|
|
@@ -78,6 +81,7 @@ export interface LocalSpkInstallOptions {
|
|
|
78
81
|
spkPath: string;
|
|
79
82
|
version: string;
|
|
80
83
|
profileName?: string;
|
|
84
|
+
repair?: boolean;
|
|
81
85
|
extraValues?: Record<string, string>;
|
|
82
86
|
deadlineMs?: number;
|
|
83
87
|
pollMs?: number;
|
|
@@ -161,7 +161,7 @@ export async function fetchInstalledPackageState(dsmOrigin, cookieHeader, packag
|
|
|
161
161
|
state.installed = true;
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
|
-
if (operation && !state.state && !(state.installed &&
|
|
164
|
+
if (operation && !state.state && !(state.installed && packageIsBroken(state))) {
|
|
165
165
|
const task = await dsmWebApi(dsmOrigin, cookieHeader, {
|
|
166
166
|
api: 'SYNO.Core.Package.Installation', method: 'status', version: '1', task_id: jsonApiParam(operation.taskId),
|
|
167
167
|
}, { timeoutMs, signal: context.signal, allowFailure: true });
|
|
@@ -196,7 +196,7 @@ function installStatusIsBroken(status) {
|
|
|
196
196
|
}
|
|
197
197
|
return /(broken|error|fail|150)/i.test(status);
|
|
198
198
|
}
|
|
199
|
-
function
|
|
199
|
+
export function packageIsBroken(state) {
|
|
200
200
|
return installStatusIsBroken(state.status) || state.statusCode === 150 ||
|
|
201
201
|
Boolean(state.statusCode && /broken|error|fail|corruption/i.test(state.statusDescription ?? '')) ||
|
|
202
202
|
Boolean(state.error && (state.error.code !== undefined ? state.error.code !== 0 : state.error.description));
|
|
@@ -219,6 +219,7 @@ export async function waitForInstalledVersion(readState, options) {
|
|
|
219
219
|
const pollMs = options.pollMs ?? dsmPollIntervalMs();
|
|
220
220
|
const progress = progressReporter(options.onProgress);
|
|
221
221
|
let transitioned = !options.requireTransition;
|
|
222
|
+
let repairStarted = !options.repairing;
|
|
222
223
|
while (Date.now() < deadline) {
|
|
223
224
|
consumePoll();
|
|
224
225
|
let state;
|
|
@@ -231,7 +232,9 @@ export async function waitForInstalledVersion(readState, options) {
|
|
|
231
232
|
throw error;
|
|
232
233
|
timedOut = true;
|
|
233
234
|
}
|
|
234
|
-
if (state &&
|
|
235
|
+
if (state && (installInProgress(state) || !packageIsBroken(state)))
|
|
236
|
+
repairStarted = true;
|
|
237
|
+
if (state && repairStarted && !installInProgress(state) && packageIsBroken(state)) {
|
|
235
238
|
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');
|
|
236
239
|
}
|
|
237
240
|
const running = /^(run|running)$/i.test(state?.status ?? '');
|
|
@@ -240,7 +243,7 @@ export async function waitForInstalledVersion(readState, options) {
|
|
|
240
243
|
transitioned = true;
|
|
241
244
|
if (Date.now() >= deadline)
|
|
242
245
|
break;
|
|
243
|
-
if (state?.installed && !/installing|upgrading|starting/i.test(state.status ?? '') &&
|
|
246
|
+
if (state?.installed && !packageIsBroken(state) && !/installing|upgrading|starting/i.test(state.status ?? '') &&
|
|
244
247
|
(!options.expectedVersion || state.version === options.expectedVersion) &&
|
|
245
248
|
(!options.requireRunning || running) && transitioned)
|
|
246
249
|
return state;
|
|
@@ -292,7 +295,7 @@ export async function uninstallPackageFromDsm(options) {
|
|
|
292
295
|
if (state && Date.now() < deadline) {
|
|
293
296
|
if (done(state))
|
|
294
297
|
return state;
|
|
295
|
-
if (
|
|
298
|
+
if (packageIsBroken(state) && !(phase === 'uninstalling' && previousFailure === failureDetail(state)))
|
|
296
299
|
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');
|
|
297
300
|
}
|
|
298
301
|
progress(timedOut ? `${options.packageId}: status request timed out; ${phase}…` :
|
|
@@ -331,7 +334,7 @@ export async function uninstallPackageFromDsm(options) {
|
|
|
331
334
|
throw new CtlError('PACKAGE_BUSY', `Package ${options.packageId} has an unresolved operation`, 'Wait for DSM to finish before uninstalling');
|
|
332
335
|
if (before.installed === false)
|
|
333
336
|
return;
|
|
334
|
-
const broken =
|
|
337
|
+
const broken = packageIsBroken(before) && !installInProgress(before);
|
|
335
338
|
if (broken) {
|
|
336
339
|
previousFailure = failureDetail(before);
|
|
337
340
|
progress(`${options.packageId}: broken package (${previousFailure || before.status}); uninstalling directly without stop…`);
|
|
@@ -490,7 +493,8 @@ export async function installPackageFromLocalSpk(options) {
|
|
|
490
493
|
await installDelay(Math.min(pollMs, remaining(requestMs)), signal);
|
|
491
494
|
}
|
|
492
495
|
}
|
|
493
|
-
if (before.state || before.installed === null
|
|
496
|
+
if (before.state || before.installed === null ||
|
|
497
|
+
(options.repair && readPackageOperation(options.dsmOrigin, options.packageId)))
|
|
494
498
|
throw new CtlError('PACKAGE_BUSY', `Package ${options.packageId} already has an unresolved operation`, 'Check package status before installing again');
|
|
495
499
|
if (options.containerImages?.length) {
|
|
496
500
|
phase = 'pulling container images';
|
|
@@ -508,7 +512,7 @@ export async function installPackageFromLocalSpk(options) {
|
|
|
508
512
|
progress(`${options.packageId}: uploading…`);
|
|
509
513
|
const uploaded = await cancelableInstall(() => uploadLocalSpk(options, sid, remaining(operationMs)), signal);
|
|
510
514
|
const compound = JSON.stringify(catalogCompoundSteps(uploaded, { version: options.version, size: readFileSync(options.spkPath).byteLength }, { blupgrade: before.installed, extraValues: options.extraValues }));
|
|
511
|
-
phase = before.installed ? 'upgrading' : 'installing';
|
|
515
|
+
phase = options.repair ? 'repairing' : before.installed ? 'upgrading' : 'installing';
|
|
512
516
|
operation = savePackageOperation(options.dsmOrigin, options.packageId, { taskId: uploaded.taskId,
|
|
513
517
|
operation: before.installed ? 'upgrading' : 'installing', fromVersion: before.installed ? before.version : undefined, toVersion: options.version });
|
|
514
518
|
progress(`${options.packageId}: ${phase}…`);
|
|
@@ -529,7 +533,8 @@ export async function installPackageFromLocalSpk(options) {
|
|
|
529
533
|
const completed = await waitForInstalledVersion(budget => fetchInstalledPackageState(options.dsmOrigin, options.cookieHeader, options.packageId, Math.min(requestMs, budget), { signal, ignoreOperation: true }), { packageId: options.packageId, expectedVersion: options.version,
|
|
530
534
|
deadlineMs: Number.isFinite(deadline) ? remaining(Number.MAX_SAFE_INTEGER) : undefined, pollMs, requireRunning: true, consumePoll, signal,
|
|
531
535
|
// A lost same-version reinstall reply must not accept the old running instance.
|
|
532
|
-
requireTransition: timedOut && before.installed === true && before.version === options.version,
|
|
536
|
+
requireTransition: timedOut && !packageIsBroken(before) && before.installed === true && before.version === options.version,
|
|
537
|
+
repairing: options.repair && packageIsBroken(before),
|
|
533
538
|
onProgress: progress });
|
|
534
539
|
verified = true;
|
|
535
540
|
progress(`${options.packageId}: ${phase} complete (${completed.version}, DSM status ${completed.status})`);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type InstalledPackageState } from "./catalog-install.js";
|
|
1
2
|
export interface NasTarget {
|
|
2
3
|
arch: string;
|
|
3
4
|
version: string;
|
|
@@ -28,5 +29,5 @@ export interface Dependency {
|
|
|
28
29
|
}
|
|
29
30
|
export declare function dependencies(value: unknown): Dependency[];
|
|
30
31
|
export declare function satisfies(version: string, dependency: Dependency): boolean;
|
|
31
|
-
export declare function resolveInstallPlan(root: StoreEntry, entries: StoreEntry[], target: NasTarget, installed:
|
|
32
|
+
export declare function resolveInstallPlan(root: StoreEntry, entries: StoreEntry[], target: NasTarget, installed: ReadonlyMap<string, string | InstalledPackageState>): StoreEntry[];
|
|
32
33
|
export declare function verifyPins(bytes: Buffer, entry: Pick<StoreEntry, "size" | "md5" | "sha256">): void;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { packageIsBroken } from "./catalog-install.js";
|
|
1
2
|
import { createHash } from "node:crypto";
|
|
2
3
|
import { CtlError } from "../ctl/errors.js";
|
|
3
4
|
import { familyOfArchToken } from "../build-spk/dsm-arch.js";
|
|
@@ -127,9 +128,15 @@ export function resolveInstallPlan(root, entries, target, installed) {
|
|
|
127
128
|
throw fail("PACKAGE_DEPENDENCY_CONFLICT", `Conflicting dependency ${dep.id}`);
|
|
128
129
|
continue;
|
|
129
130
|
}
|
|
130
|
-
|
|
131
|
+
const current = installed.get(dep.id);
|
|
132
|
+
const currentVersion = typeof current === "string" ? current : current?.version;
|
|
133
|
+
if (typeof current === "object" && (current.state || current.installed === null))
|
|
134
|
+
throw fail("PACKAGE_BUSY", `Dependency ${dep.id} already has an unresolved operation`);
|
|
135
|
+
if (currentVersion && satisfies(currentVersion, dep) &&
|
|
136
|
+
(typeof current === "string" || !packageIsBroken(current)))
|
|
131
137
|
continue;
|
|
132
|
-
const candidates = entries.filter((e) => e.package === dep.id && satisfies(e.version, dep)
|
|
138
|
+
const candidates = entries.filter((e) => e.package === dep.id && satisfies(e.version, dep) &&
|
|
139
|
+
(!(typeof current === "object" && packageIsBroken(current) && currentVersion && satisfies(currentVersion, dep)) || e.version === currentVersion));
|
|
133
140
|
if (!candidates.length)
|
|
134
141
|
throw fail("PACKAGE_DEPENDENCY_REQUIRED", `Install required Synology package ${dep.id}${Object.entries(dep.constraints)
|
|
135
142
|
.map(([k, v]) => k + v)
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { type NasConnection } from "./connection.js";
|
|
2
|
+
import { type InstalledPackageState } from "./catalog-install.js";
|
|
2
3
|
import { type NasTarget, type StoreEntry } from "./install-plan.js";
|
|
3
4
|
export declare const DEFAULT_PACKAGE_SOURCE = "https://packages.synopkgland.com";
|
|
4
5
|
export declare function packageId(value: string): string;
|
|
@@ -18,6 +19,7 @@ export declare function installPackage(spec: string, options?: InstallOptions, c
|
|
|
18
19
|
source: string;
|
|
19
20
|
packages: {
|
|
20
21
|
signed?: boolean | undefined;
|
|
22
|
+
status?: string | undefined;
|
|
21
23
|
package: string;
|
|
22
24
|
version: string;
|
|
23
25
|
size: number;
|
|
@@ -31,6 +33,7 @@ export declare function installPackage(spec: string, options?: InstallOptions, c
|
|
|
31
33
|
source: string;
|
|
32
34
|
packages: {
|
|
33
35
|
signed?: boolean | undefined;
|
|
36
|
+
status?: string | undefined;
|
|
34
37
|
package: string;
|
|
35
38
|
version: string;
|
|
36
39
|
size: number;
|
|
@@ -39,13 +42,14 @@ export declare function installPackage(spec: string, options?: InstallOptions, c
|
|
|
39
42
|
parameters: string[];
|
|
40
43
|
dryRun: boolean;
|
|
41
44
|
} | {
|
|
42
|
-
status:
|
|
45
|
+
status: InstalledPackageState | undefined;
|
|
43
46
|
message?: string | undefined;
|
|
44
47
|
host: string;
|
|
45
48
|
target: NasTarget;
|
|
46
49
|
source: string;
|
|
47
50
|
packages: {
|
|
48
51
|
signed?: boolean | undefined;
|
|
52
|
+
status?: string | undefined;
|
|
49
53
|
package: string;
|
|
50
54
|
version: string;
|
|
51
55
|
size: number;
|
|
@@ -69,7 +73,10 @@ export declare function uninstallPackage(id: string, options?: {
|
|
|
69
73
|
package: string;
|
|
70
74
|
action: string;
|
|
71
75
|
}>;
|
|
72
|
-
export declare function packageStatus(id: string, host?: string): Promise<{
|
|
76
|
+
export declare function packageStatus(id: string, host?: string, connection?: NasConnection): Promise<{
|
|
77
|
+
recommendedCommand?: string | undefined;
|
|
78
|
+
message?: string | undefined;
|
|
79
|
+
broken: boolean;
|
|
73
80
|
installed: boolean | null;
|
|
74
81
|
state?: "installing" | "upgrading" | "starting" | "stopping" | "uninstalling" | "unknown";
|
|
75
82
|
fromVersion?: string;
|
|
@@ -7,7 +7,7 @@ import { inspectAnySpk } from "../spk/inspect.js";
|
|
|
7
7
|
import { containerImageReferences } from './container-pull.js';
|
|
8
8
|
import { connectNas, requireAdministrator, } from "./connection.js";
|
|
9
9
|
import { fetchPackageSource } from "../package-source.js";
|
|
10
|
-
import { fetchInstalledPackageState, installPackageFromLocalSpk, uninstallPackageFromDsm, } from "./catalog-install.js";
|
|
10
|
+
import { fetchInstalledPackageState, packageStateFromRecord, packageIsBroken, installPackageFromLocalSpk, uninstallPackageFromDsm, } from "./catalog-install.js";
|
|
11
11
|
import { assertCompatible, sourceUrl, selectEntry, resolveInstallPlan, verifyPins, compareVersions, } from "./install-plan.js";
|
|
12
12
|
export const DEFAULT_PACKAGE_SOURCE = "https://packages.synopkgland.com";
|
|
13
13
|
const fail = (code, message, hint = "Check Package Center and retry") => new CtlError(code, message, hint, 3);
|
|
@@ -49,13 +49,13 @@ export async function readFeed(source, target) {
|
|
|
49
49
|
}
|
|
50
50
|
async function inventory(nas) {
|
|
51
51
|
const data = await nas.call("SYNO.Core.Package", "list", 2, {
|
|
52
|
-
additional: '["status"]',
|
|
52
|
+
additional: '["status","installed_info"]',
|
|
53
53
|
ignore_hidden: "false",
|
|
54
54
|
});
|
|
55
55
|
if (!Array.isArray(data?.packages) ||
|
|
56
56
|
(data.total !== undefined && data.total !== data.packages.length))
|
|
57
57
|
throw fail("NAS_INVENTORY_INVALID", "Installed package inventory is incomplete");
|
|
58
|
-
return new Map(data.packages.map((p) => [p.id, p
|
|
58
|
+
return new Map(data.packages.map((p) => [p.id, packageStateFromRecord(p)]));
|
|
59
59
|
}
|
|
60
60
|
async function confirm(action, yes) {
|
|
61
61
|
if (yes)
|
|
@@ -118,12 +118,24 @@ export async function installPackage(spec, options = {}, connection) {
|
|
|
118
118
|
root = selectEntry(entries, packageId(match[1]), match[2], target);
|
|
119
119
|
}
|
|
120
120
|
const plan = resolveInstallPlan(root, entries, target, installed);
|
|
121
|
-
for (const item of plan)
|
|
122
|
-
|
|
123
|
-
|
|
121
|
+
for (const item of plan) {
|
|
122
|
+
const state = installed.get(item.package);
|
|
123
|
+
if (state?.state || state?.installed === null)
|
|
124
|
+
throw fail("PACKAGE_BUSY", `Package ${item.package} already has an unresolved operation`, "Check package status before installing again");
|
|
125
|
+
if (state && !state.version)
|
|
126
|
+
throw fail("NAS_INVENTORY_INVALID", `DSM did not report the installed version of ${item.package}`);
|
|
127
|
+
if (state && compareVersions(item.version, state.version) < 0)
|
|
124
128
|
throw fail("PACKAGE_DOWNGRADE_REFUSED", `Refusing downgrade of ${item.package}`, "Choose the installed version or a newer release");
|
|
125
|
-
|
|
126
|
-
|
|
129
|
+
}
|
|
130
|
+
const actionFor = (item) => {
|
|
131
|
+
const state = installed.get(item.package);
|
|
132
|
+
if (!state)
|
|
133
|
+
return "install";
|
|
134
|
+
if (compareVersions(item.version, state.version) !== 0)
|
|
135
|
+
return "upgrade";
|
|
136
|
+
return packageIsBroken(state) ? "repair" : "none";
|
|
137
|
+
};
|
|
138
|
+
const changes = plan.filter((item) => actionFor(item) !== "none");
|
|
127
139
|
const publicPlan = {
|
|
128
140
|
host: nas.name,
|
|
129
141
|
target,
|
|
@@ -132,11 +144,9 @@ export async function installPackage(spec, options = {}, connection) {
|
|
|
132
144
|
package: item.package,
|
|
133
145
|
version: item.version,
|
|
134
146
|
size: item.size,
|
|
135
|
-
action:
|
|
136
|
-
|
|
137
|
-
:
|
|
138
|
-
? "none"
|
|
139
|
-
: "upgrade",
|
|
147
|
+
action: actionFor(item),
|
|
148
|
+
...(installed.get(item.package)?.status
|
|
149
|
+
? { status: installed.get(item.package).status } : {}),
|
|
140
150
|
...(item.package === root.package && report
|
|
141
151
|
? { signed: report.signed }
|
|
142
152
|
: {}),
|
|
@@ -151,7 +161,7 @@ export async function installPackage(spec, options = {}, connection) {
|
|
|
151
161
|
if (!changes.length)
|
|
152
162
|
return publicPlan;
|
|
153
163
|
await requireAdministrator(nas);
|
|
154
|
-
await confirm(
|
|
164
|
+
await confirm(changes.map((e) => `${actionFor(e)} ${e.package}@${e.version}`).join(", "), options.yes);
|
|
155
165
|
// Download, verify and inspect the entire plan before the first NAS write.
|
|
156
166
|
const files = new Map();
|
|
157
167
|
const images = new Map();
|
|
@@ -182,6 +192,7 @@ export async function installPackage(spec, options = {}, connection) {
|
|
|
182
192
|
packageId: entry.package,
|
|
183
193
|
version: entry.version,
|
|
184
194
|
spkPath: files.get(entry.package),
|
|
195
|
+
repair: actionFor(entry) === "repair",
|
|
185
196
|
containerImages: images.get(entry.package),
|
|
186
197
|
extraValues: entry.package === root.package ? options.param : undefined,
|
|
187
198
|
});
|
|
@@ -219,11 +230,18 @@ export async function uninstallPackage(id, options = {}) {
|
|
|
219
230
|
});
|
|
220
231
|
return { host: nas.name, package: id, installed: false };
|
|
221
232
|
}
|
|
222
|
-
export async function packageStatus(id, host) {
|
|
233
|
+
export async function packageStatus(id, host, connection) {
|
|
223
234
|
packageId(id);
|
|
224
|
-
const nas = await connectNas(host);
|
|
235
|
+
const nas = connection ?? await connectNas(host);
|
|
225
236
|
const state = await fetchInstalledPackageState(nas.session.origin, nas.session.cookie, id);
|
|
226
237
|
if (!state)
|
|
227
238
|
throw fail("PACKAGE_STATUS_UNKNOWN", "DSM did not return a verifiable package state");
|
|
228
|
-
|
|
239
|
+
const broken = packageIsBroken(state);
|
|
240
|
+
const quotedHost = "'" + nas.name.replace(/'/g, "'\\''") + "'";
|
|
241
|
+
return { host: nas.name, package: id, ...state, broken,
|
|
242
|
+
...(broken && state.version && /^[0-9][0-9._-]*$/.test(state.version) && !state.state ? {
|
|
243
|
+
recommendedCommand: `synopkgland install ${id}@${state.version}${nas.name === "env" ? "" : ` --host ${quotedHost}`} --yes`,
|
|
244
|
+
message: "Package is broken; reinstall the same release to repair it while retaining data",
|
|
245
|
+
} : {}),
|
|
246
|
+
};
|
|
229
247
|
}
|
|
@@ -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)) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synopackageland/cli",
|
|
3
|
-
"version": "0.48.
|
|
3
|
+
"version": "0.48.16",
|
|
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",
|