@synopackageland/cli 0.54.1 → 0.54.3
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 +8 -0
- package/README.md +44 -0
- package/dist/error-registry.js +11 -0
- package/dist/runtime/approval-diff.js +19 -0
- package/dist/standalone/inspect-spk.js +50 -2
- package/dist/standalone/lifecycle.js +4 -1
- package/dist/standalone/manifest.d.ts +2 -0
- package/dist/standalone/manifest.js +11 -0
- package/dist/standalone/resource.d.ts +4 -0
- package/dist/standalone/resource.js +5 -1
- package/dist/standalone/short-paths.d.ts +48 -0
- package/dist/standalone/short-paths.js +179 -0
- package/dist/standalone/spk.js +5 -1
- package/package.json +2 -2
- package/schema/dsm-package.schema.json +21 -0
- package/skills/SKILL.md +1 -0
- package/skills/reference/ui-vue.md +41 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.54.3 (2026-11-15)
|
|
4
|
+
|
|
5
|
+
- `init` uses templates 0.44.0: Vue Apps start with a default data layer in `frontend/src/data/` (an in-memory `@tanstack/query-core` cache per window, keyed by user; cached answers show at once and are read again behind them) and a dev-only mock at `/?mock=1` with `latency=` and `trace=1` (`window.__calls`), so the frontend runs without a NAS. The `ui-vue` skill reference points at both.
|
|
6
|
+
|
|
7
|
+
## 0.54.2 (2026-11-15)
|
|
8
|
+
|
|
9
|
+
- `ui.short_paths` gives a stable page a short address on DSM's own origin, such as `https://<nas>:5001/connect` for `stable_pages.m`: `short_paths: {/connect: m}`. The build writes `etc/short-paths-nginx.conf` with exact `location = /connect` and `/connect/` blocks that answer `302` with a relative `Location` to `/webman/3rdparty/<package>/m/index.html`, keeping the query; nothing is proxied and no cookie or package code is involved. DSM's `web-config` worker registers the file as a `dsm` location while the package runs (also with `portal`: the target is not served on 80/443), and INFO reloads nginx at start and stop. A path is one lowercase segment, at most 4, and not a DSM or SDK name such as `/mobile`, `/webman` or `/synopkgland` (`STANDALONE_UI_SHORT_PATHS_INVALID`); it needs `os_min_ver` 7.2-64570 or later (`STANDALONE_UI_SHORT_PATHS_MIN_DSM`). Install and upgrade hooks first run a read-only check over the custom ingress inventory (DSM document-root entries, Portal aliases, other packages' nginx files and DSM's active locations) and refuse a path that is taken or cannot be checked. `inspect` replays the redirects, resource entry, INFO reload and check (`SHORT_PATHS_INVALID`); `approval-diff` lists short-path resource changes without asking for reapproval.
|
|
10
|
+
|
|
3
11
|
## 0.54.1 (2026-11-14)
|
|
4
12
|
|
|
5
13
|
- `identity_gateway.upstream: unix:<name>.sock` points the gateway at the App's private SDK IPC socket (`/var/packages/<package>/var/run/<name>.sock`, dialed with the SDK's package-socket checks), so an App can expose one App-authenticated route, such as a WebSocket, under DSM's own origin with no TCP port and no TCP listener. It needs `ingress`, no `listen`, no Compose and an SDK whose `idgateway` has `UnixUpstreamVersion = 1` (checked at `check` and `build`). The gateway binary now also binds `ipc.packageID`.
|
package/README.md
CHANGED
|
@@ -459,6 +459,50 @@ pointer and target stay public UI files: the secret scan covers them, and
|
|
|
459
459
|
`inspect` replays the stub and pointer (`UI_STABLE_PAGE_INVALID`). Classic
|
|
460
460
|
`app.js` UIs may declare stable pages too; their pointer names `app/<file>`.
|
|
461
461
|
|
|
462
|
+
`ui.short_paths` adds a short address on DSM's own origin that redirects to a
|
|
463
|
+
stable page, so people can type `https://<nas>:5001/connect` instead of the
|
|
464
|
+
full `/webman/3rdparty/<package>/<name>/index.html`:
|
|
465
|
+
|
|
466
|
+
```yaml
|
|
467
|
+
os_min_ver: "7.2-64570" # DSM 7.1 rejects the unsigned web-config worker
|
|
468
|
+
ui:
|
|
469
|
+
dir: frontend/dist
|
|
470
|
+
stable_pages:
|
|
471
|
+
m: m/index.html
|
|
472
|
+
short_paths:
|
|
473
|
+
/connect: m # → /webman/3rdparty/<package>/m/index.html
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
Each path is one lowercase segment (letters, digits and inner `-`, at most 64
|
|
477
|
+
characters, no trailing `/`) and names a page in `stable_pages`; at most 4. The
|
|
478
|
+
build writes `etc/short-paths-nginx.conf` with an exact `location = /connect`
|
|
479
|
+
and `location = /connect/`, each answering `302` with a relative `Location`
|
|
480
|
+
(`absolute_redirect off`, so a NAS behind a reverse proxy or tunnel keeps its
|
|
481
|
+
own host and port). The query is passed on and the browser keeps the fragment.
|
|
482
|
+
Nothing is proxied, no cookie is read or set and no package code runs. DSM's
|
|
483
|
+
`web-config` worker adds the locations to DSM's server (5000/5001 and the DSM
|
|
484
|
+
custom domain) when the package starts and removes them when it stops; INFO
|
|
485
|
+
asks DSM to reload nginx at both, as for path ingress. A stopped or uninstalled
|
|
486
|
+
App's short path returns DSM's 404, and an upgrade replaces the file. With
|
|
487
|
+
`portal`, short paths still stay on DSM's server only: their target,
|
|
488
|
+
`/webman/3rdparty/`, is not served on 80/443.
|
|
489
|
+
|
|
490
|
+
`check` refuses the root, DSM and SDK names (the reserved list of custom ingress,
|
|
491
|
+
including `/mobile`, `/webman`, `/webapi`, `/sharing` and `/synopkgland`), a
|
|
492
|
+
path that overlaps the package's own ingress, an undeclared page
|
|
493
|
+
(`STANDALONE_UI_SHORT_PATHS_INVALID`) and `os_min_ver` below 7.2-64570
|
|
494
|
+
(`STANDALONE_UI_SHORT_PATHS_MIN_DSM`). Whether a path is free depends on the
|
|
495
|
+
NAS: `preinst`, `preupgrade`, `postinst` and `postupgrade` first run a read-only
|
|
496
|
+
shell check over the same inventory as the custom ingress check (DSM's
|
|
497
|
+
`/usr/syno/synoman` entries, saved Application Portal aliases, other packages'
|
|
498
|
+
nginx files including stopped ones, and DSM's active `dsm.*`/`alias.*`
|
|
499
|
+
locations). An overlap, an unreadable inventory or a location regex the check
|
|
500
|
+
cannot evaluate refuses the installation with a readable message; choose another
|
|
501
|
+
path and rebuild. `inspect` replays the file, the resource entry, the INFO
|
|
502
|
+
reload and the check (`SHORT_PATHS_INVALID`). `approval-diff` lists an added,
|
|
503
|
+
changed or removed short path under the resource changes but does not ask for
|
|
504
|
+
reapproval: a redirect to the package's own public page widens no access.
|
|
505
|
+
|
|
462
506
|
A full page does not need Application Portal. Omit `portal` unless an alias is
|
|
463
507
|
explicitly wanted; only that opt-in adds `defaultAlias`, login styling, Portal
|
|
464
508
|
panels and capabilities. No Portal is a healthy default for inspect/info/doctor.
|
package/dist/error-registry.js
CHANGED
|
@@ -6,6 +6,7 @@ export const ERROR_REGISTRY = {
|
|
|
6
6
|
STANDALONE_MOBILE_INVALID: { code: 'STANDALONE_MOBILE_INVALID', description: 'The mobile declaration or its UI/gateway dependency is invalid', suggestion: 'Check mobile against the manifest schema and read the mobile skill' },
|
|
7
7
|
MOBILE_SDK_ENTRY_MISSING: { code: 'MOBILE_SDK_ENTRY_MISSING', description: 'The installed frontend SDK has no entry export', suggestion: 'Install an SDK with /entry in the UI build directory or project root' },
|
|
8
8
|
UI_STABLE_PAGE_INVALID: { code: 'UI_STABLE_PAGE_INVALID', description: 'A packaged stable page differs from its build record', suggestion: 'Rebuild the SPK and inspect it again' },
|
|
9
|
+
SHORT_PATHS_INVALID: { code: 'SHORT_PATHS_INVALID', description: 'Packaged short-path redirects, their INFO reload or their ownership check differ from the build record', suggestion: 'Rebuild the SPK with synopkgland build and inspect it again' },
|
|
9
10
|
MOBILE_INVALID: { code: 'MOBILE_INVALID', description: 'Packaged mobile assets differ from their build declaration', suggestion: 'Rebuild the SPK and inspect it again' },
|
|
10
11
|
SECRET_FILE_TRACKED: { code: "SECRET_FILE_TRACKED", description: "Git tracks a local secret file.", suggestion: SECRET_FILE_FIX },
|
|
11
12
|
SECRET_FILE_UNIGNORED: { code: "SECRET_FILE_UNIGNORED", description: "A local secret file lacks a repository ignore rule.", suggestion: SECRET_FILE_FIX },
|
|
@@ -696,6 +697,16 @@ export const ERROR_REGISTRY = {
|
|
|
696
697
|
description: "ui.stable_pages does not map page names to files in ui.dir.",
|
|
697
698
|
suggestion: "Map 1 to 8 names (lowercase letters, digits and -, not app, cgi, config, images, sso or texts) to a file path relative to ui.dir, for example stable_pages: {m: m/index.html}.",
|
|
698
699
|
},
|
|
700
|
+
STANDALONE_UI_SHORT_PATHS_INVALID: {
|
|
701
|
+
code: "STANDALONE_UI_SHORT_PATHS_INVALID",
|
|
702
|
+
description: "ui.short_paths does not map unreserved one-segment paths to ui.stable_pages names.",
|
|
703
|
+
suggestion: "Map 1 to 4 paths such as /connect (lowercase letters, digits and inner -, no trailing /, not a DSM or SDK name such as /mobile, /webman or /synopkgland, and not the package's own ingress path) to a page declared in ui.stable_pages, for example short_paths: {/connect: m}.",
|
|
704
|
+
},
|
|
705
|
+
STANDALONE_UI_SHORT_PATHS_MIN_DSM: {
|
|
706
|
+
code: "STANDALONE_UI_SHORT_PATHS_MIN_DSM",
|
|
707
|
+
description: "ui.short_paths needs DSM 7.2 or later: DSM 7.1 rejects the unsigned web-config worker that adds the redirect.",
|
|
708
|
+
suggestion: "Raise os_min_ver to 7.2-64570 or later, or remove ui.short_paths and share the stable page URL instead.",
|
|
709
|
+
},
|
|
699
710
|
STANDALONE_UI_STABLE_PAGE_MISSING: {
|
|
700
711
|
code: "STANDALONE_UI_STABLE_PAGE_MISSING",
|
|
701
712
|
description: "A ui.stable_pages target is not a file in the built UI.",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { inspectAnySpk } from '../spk/inspect.js';
|
|
2
|
+
import { isShortPathsEntry } from '../standalone/short-paths.js';
|
|
2
3
|
function canonical(value) {
|
|
3
4
|
if (Array.isArray(value))
|
|
4
5
|
return '[' + value.map(canonical).join(',') + ']';
|
|
@@ -47,6 +48,19 @@ function noApproval(r) {
|
|
|
47
48
|
function notRequired() {
|
|
48
49
|
return { retention: 'not-required', permissions: 'unchanged', executor_only: false, task_template_changed: false, root_programs: [], policy_changes: [], reason: 'No SDK administrator approval is required: this verified package has no executor or approval-requiring capability.' };
|
|
49
50
|
}
|
|
51
|
+
/** The resources without redirect-only short-path entries; empty containers they leave are dropped. */
|
|
52
|
+
function withoutShortPaths(resources) {
|
|
53
|
+
const copy = structuredClone(resources);
|
|
54
|
+
const web = copy['web-config'], nginx = web?.['nginx-static-config'];
|
|
55
|
+
if (!nginx || !Array.isArray(nginx.enable))
|
|
56
|
+
return copy;
|
|
57
|
+
nginx.enable = nginx.enable.filter(entry => !isShortPathsEntry(entry));
|
|
58
|
+
if (!nginx.enable.length && Object.keys(nginx).length === 1)
|
|
59
|
+
delete web['nginx-static-config'];
|
|
60
|
+
if (!Object.keys(web).length)
|
|
61
|
+
delete copy['web-config'];
|
|
62
|
+
return copy;
|
|
63
|
+
}
|
|
50
64
|
/** Resource registration changes are authority changes, even with identical executor pins. */
|
|
51
65
|
function resourceDiff(old, next, diff) {
|
|
52
66
|
if (!next.dsm.ok || next.findings.length || !old.synopkgland || !next.synopkgland || old.package !== next.package || old.arch !== next.arch)
|
|
@@ -54,6 +68,11 @@ function resourceDiff(old, next, diff) {
|
|
|
54
68
|
const resource_changes = changes(old.resources ?? {}, next.resources ?? {});
|
|
55
69
|
if (!resource_changes.length)
|
|
56
70
|
return diff;
|
|
71
|
+
// inspect has replayed the short-path file: exact 302 locations to the package's own
|
|
72
|
+
// stable pages, with no proxy or package code. Adding, changing or removing them
|
|
73
|
+
// widens no access, so it is listed but does not ask for reapproval.
|
|
74
|
+
if (!changes(withoutShortPaths(old.resources ?? {}), withoutShortPaths(next.resources ?? {})).length)
|
|
75
|
+
return { ...diff, resource_changes, reason: `${diff.reason} The changed DSM registration only redirects short paths to the package's own stable pages, which needs no reapproval.` };
|
|
57
76
|
const ingress = (r) => (r.resources?.['web-config']?.['nginx-static-config']?.enable ?? []);
|
|
58
77
|
const previous = new Set(ingress(old).map(canonical));
|
|
59
78
|
const expanded = ingress(next).some(entry => !previous.has(canonical(entry)));
|
|
@@ -3,6 +3,8 @@ import { parseDsmStrings } from "./dsm-texts.js";
|
|
|
3
3
|
import { readTCPListeners } from "./tcp-listeners.js";
|
|
4
4
|
import { inspectMobileFiles, mobileRecordProblem } from './mobile.js';
|
|
5
5
|
import { inspectStablePages } from './stable-pages.js';
|
|
6
|
+
import { LIFECYCLE_SCRIPTS } from '../spk/dsm-spec.js';
|
|
7
|
+
import { SHORT_PATHS_CONFIG, renderShortPathsCheck, renderShortPathsConfig, shortPathIngressProblem, shortPathsMinDsmProblem, shortPathsProblem, withoutShortPathsCheck } from './short-paths.js';
|
|
6
8
|
import { DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM, readNoFile, daemonSystemUnitName, renderDaemonSystemUnit, daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM } from "./daemon-nofile.js";
|
|
7
9
|
import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
8
10
|
import { renderGatewayIngressCheck } from './native-gateway.js';
|
|
@@ -254,8 +256,11 @@ export async function inspectSpk(spkPath, expectedKind, options = {}) {
|
|
|
254
256
|
await checkArch(dir, info, kind, paths.has(CGI_PAYLOAD_PATH), findings);
|
|
255
257
|
const nativeGateway = await recoverNativeGateway(dir, metadata.native_gateway, info, findings);
|
|
256
258
|
const daemonIngress = await recoverDaemonIngress(dir, metadata.daemon_ingress, info, paths, findings);
|
|
259
|
+
const shortPaths = await recoverShortPaths(dir, metadata.short_paths, metadata.stable_pages, info, nativeGateway, findings);
|
|
257
260
|
const background = compiledKind && paths.has(BACKGROUND_WORKER_PAYLOAD);
|
|
258
261
|
// Before any fixed-lifecycle comparison: those see the SDK steps alone.
|
|
262
|
+
if (shortPaths)
|
|
263
|
+
peelShortPathsCheck(join(dir, "scripts"), info.package, shortPaths, findings);
|
|
259
264
|
const appScripts = standalone || kind === "container"
|
|
260
265
|
? unwrapAppScripts(join(dir, "scripts"), findings)
|
|
261
266
|
: [];
|
|
@@ -272,7 +277,7 @@ export async function inspectSpk(spkPath, expectedKind, options = {}) {
|
|
|
272
277
|
!isDsmAtLeast(info.os_min_ver, PORTAL_MIN_DSM)) {
|
|
273
278
|
findings.push(`INFO os_min_ver "${info.os_min_ver}" is below the DSM ${PORTAL_MIN_DSM} a portal needs; ${PORTAL_MIN_DSM_REASON}`);
|
|
274
279
|
}
|
|
275
|
-
const resources = checkConf(dir, findings, kind, background, sharedFolder, info.package, portal, combined?.compose, nativeGateway, info.os_min_ver, daemonIngress, Boolean(metadata.installPorts), daemonNoFile, options.baseline);
|
|
280
|
+
const resources = checkConf(dir, findings, kind, background, sharedFolder, info.package, portal, combined?.compose, nativeGateway, info.os_min_ver, daemonIngress, Boolean(metadata.installPorts), daemonNoFile, options.baseline, shortPaths);
|
|
276
281
|
checkScripts(dir, findings);
|
|
277
282
|
checkUninstall(dir, findings);
|
|
278
283
|
if (kind === "container")
|
|
@@ -1416,7 +1421,49 @@ async function recoverDaemonIngress(dir, value, info, paths, findings) {
|
|
|
1416
1421
|
return undefined;
|
|
1417
1422
|
}
|
|
1418
1423
|
}
|
|
1419
|
-
|
|
1424
|
+
const SHORT_PATHS_INVALID = "SHORT_PATHS_INVALID";
|
|
1425
|
+
/** Replay the recorded short paths: the redirect-only locations and their DSM floor. */
|
|
1426
|
+
async function recoverShortPaths(dir, value, stablePages, info, gateway, findings) {
|
|
1427
|
+
if (value === undefined)
|
|
1428
|
+
return undefined;
|
|
1429
|
+
try {
|
|
1430
|
+
const problem = shortPathsProblem(value, stablePages && typeof stablePages === "object" && !Array.isArray(stablePages) ? stablePages : undefined)
|
|
1431
|
+
?? shortPathsMinDsmProblem(info.os_min_ver)
|
|
1432
|
+
?? shortPathIngressProblem(value, gateway?.ingress?.path);
|
|
1433
|
+
if (problem)
|
|
1434
|
+
throw new Error(problem);
|
|
1435
|
+
const shortPaths = value;
|
|
1436
|
+
const root = join(dir, "short-paths-inspection");
|
|
1437
|
+
mkdirSync(root);
|
|
1438
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: (path) => path.replace(/^\.\//, "") === SHORT_PATHS_CONFIG });
|
|
1439
|
+
if (readOptional(join(root, SHORT_PATHS_CONFIG)) !== renderShortPathsConfig(info.package, shortPaths))
|
|
1440
|
+
throw new Error(`${SHORT_PATHS_CONFIG} differs from its fixed redirects`);
|
|
1441
|
+
if (!(info.startstop_restart_services ?? "").split(/\s+/).includes("nginx.service"))
|
|
1442
|
+
throw new Error("short paths require INFO startstop_restart_services");
|
|
1443
|
+
return shortPaths;
|
|
1444
|
+
}
|
|
1445
|
+
catch (e) {
|
|
1446
|
+
findings.push(`${SHORT_PATHS_INVALID} ${e.message}`);
|
|
1447
|
+
return undefined;
|
|
1448
|
+
}
|
|
1449
|
+
}
|
|
1450
|
+
/** Peel the ownership check build puts first in each hook, so every later comparison sees the SDK steps alone. */
|
|
1451
|
+
function peelShortPathsCheck(scriptsDir, pkg, shortPaths, findings) {
|
|
1452
|
+
for (const hook of LIFECYCLE_SCRIPTS) {
|
|
1453
|
+
const file = join(scriptsDir, hook);
|
|
1454
|
+
const script = readOptional(file);
|
|
1455
|
+
const check = renderShortPathsCheck(pkg, shortPaths, hook);
|
|
1456
|
+
if (!check)
|
|
1457
|
+
continue;
|
|
1458
|
+
const peeled = script === undefined ? undefined : withoutShortPathsCheck(script, check);
|
|
1459
|
+
if (peeled === undefined) {
|
|
1460
|
+
findings.push(`${SHORT_PATHS_INVALID} scripts/${hook} lacks the short path ownership check`);
|
|
1461
|
+
continue;
|
|
1462
|
+
}
|
|
1463
|
+
writeFileSync(file, peeled);
|
|
1464
|
+
}
|
|
1465
|
+
}
|
|
1466
|
+
function checkConf(dir, findings, kind, background, sharedFolder, pkg, portal, compose, nativeGateway, osMinVer, daemonIngress, installPorts = false, nofile, baseline = false, shortPaths) {
|
|
1420
1467
|
const confDir = join(dir, "conf");
|
|
1421
1468
|
const entries = existsSync(confDir) ? readdirSync(confDir) : [];
|
|
1422
1469
|
const nativeResource = kind !== "container"
|
|
@@ -1431,6 +1478,7 @@ function checkConf(dir, findings, kind, background, sharedFolder, pkg, portal, c
|
|
|
1431
1478
|
: {},
|
|
1432
1479
|
...(sharedFolder ? { sharedFolder } : {}),
|
|
1433
1480
|
...(daemonIngress ? { daemon: { ingress: daemonIngress } } : {}),
|
|
1481
|
+
...(shortPaths ? { ui: { shortPaths } } : {}),
|
|
1434
1482
|
}, portal)
|
|
1435
1483
|
: undefined;
|
|
1436
1484
|
const actualResource = readOptional(join(confDir, "resource"));
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { renderGatewayIngressCheck } from './native-gateway.js';
|
|
2
|
+
import { renderShortPathsCheck, withShortPathsCheck } from "./short-paths.js";
|
|
2
3
|
import { renderMemoryHook } from './install-memory.js';
|
|
3
4
|
import { renderSettingsHook, renderNativeFolderHook } from './install-settings.js';
|
|
4
5
|
import { renderComposeRetainedData } from "../build-spk/compose-retained-data.js";
|
|
@@ -19,9 +20,11 @@ export function renderStandaloneScript(name, manifest) {
|
|
|
19
20
|
const script = renderStandaloneScriptInternal(name, manifest);
|
|
20
21
|
const prefix = renderStandaloneScriptPrefix(name, manifest);
|
|
21
22
|
const sdk = prefix ? script.replace('#!/bin/sh\n', () => '#!/bin/sh\n' + prefix) : script;
|
|
22
|
-
|
|
23
|
+
const composed = manifest.appScripts?.some((app) => app === name)
|
|
23
24
|
? composeAppScript(name, sdk)
|
|
24
25
|
: sdk;
|
|
26
|
+
// Outermost, before the App's own script: inspect peels it before any other comparison.
|
|
27
|
+
return withShortPathsCheck(composed, renderShortPathsCheck(manifest.package, manifest.ui?.shortPaths, name));
|
|
25
28
|
}
|
|
26
29
|
function renderStandaloneScriptPrefix(name, manifest) {
|
|
27
30
|
const prepared = ['postinst', 'postupgrade'].includes(name) ? renderNativeGatewayPrepare(manifest) : '';
|
|
@@ -99,6 +99,8 @@ export interface StandaloneManifest {
|
|
|
99
99
|
banner?: "hidden";
|
|
100
100
|
/** `ui.stable_pages`: page name → file in ui.dir, served at /webman/3rdparty/<package>/<name>/index.html in every build. */
|
|
101
101
|
stablePages?: Record<string, string>;
|
|
102
|
+
/** `ui.short_paths`: DSM path → stable page name, redirected by DSM's nginx while the package runs. */
|
|
103
|
+
shortPaths?: Record<string, string>;
|
|
102
104
|
};
|
|
103
105
|
i18n?: StandaloneI18n;
|
|
104
106
|
capabilities: Capabilities;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { loadNativeTexts } from "./dsm-texts.js";
|
|
2
2
|
import { readUiSecretIgnores } from "./public-ui.js";
|
|
3
3
|
import { stablePagesProblem } from "./stable-pages.js";
|
|
4
|
+
import { shortPathIngressProblem, shortPathsMinDsmProblem, shortPathsProblem } from "./short-paths.js";
|
|
4
5
|
import { readTCPListeners, tcpSDKProblem } from "./tcp-listeners.js";
|
|
5
6
|
import { validateNativeManifest } from './native-http.js';
|
|
6
7
|
import { readMobile, mobileIconPath } from './mobile.js';
|
|
@@ -536,6 +537,11 @@ function readManifest(raw, c) {
|
|
|
536
537
|
ui?.launch !== undefined &&
|
|
537
538
|
!isWebLaunchMode(ui.launch))
|
|
538
539
|
c.fail("STANDALONE_UI_LAUNCH_INVALID", "ui.launch must be dsm-window or new-page.");
|
|
540
|
+
if (ui && "shortPaths" in ui && ui.shortPaths) {
|
|
541
|
+
const problem = shortPathsMinDsmProblem(osMinVer) ?? shortPathIngressProblem(ui.shortPaths, identityGateway?.ingress?.path);
|
|
542
|
+
if (problem)
|
|
543
|
+
c.fail(problem.startsWith("ui.short_paths needs") ? "STANDALONE_UI_SHORT_PATHS_MIN_DSM" : "STANDALONE_UI_SHORT_PATHS_INVALID", problem);
|
|
544
|
+
}
|
|
539
545
|
if (backend &&
|
|
540
546
|
isBridgeBackend(backend) &&
|
|
541
547
|
ui &&
|
|
@@ -1120,6 +1126,11 @@ function readUi(value, c) {
|
|
|
1120
1126
|
if (stableProblem)
|
|
1121
1127
|
return c.fail("STANDALONE_UI_STABLE_PAGES_INVALID", `ui.stable_pages ${stableProblem}`);
|
|
1122
1128
|
const stable = value.stable_pages === undefined ? {} : { stablePages: { ...value.stable_pages } };
|
|
1129
|
+
const shortProblem = value.short_paths === undefined ? undefined : shortPathsProblem(value.short_paths, stable.stablePages);
|
|
1130
|
+
if (shortProblem)
|
|
1131
|
+
return c.fail("STANDALONE_UI_SHORT_PATHS_INVALID", `ui.short_paths ${shortProblem}`);
|
|
1132
|
+
if (value.short_paths !== undefined)
|
|
1133
|
+
Object.assign(stable, { shortPaths: { ...value.short_paths } });
|
|
1123
1134
|
if (value.build === undefined) {
|
|
1124
1135
|
return dir ? { dir, ...launch, ...window, ...banner, ...stable } : undefined;
|
|
1125
1136
|
}
|
|
@@ -4,6 +4,7 @@ import { type SharedFolder } from "./shared-folder.js";
|
|
|
4
4
|
import { type PortalPackage } from "../portal/package.js";
|
|
5
5
|
import { type NativeGatewayPlan } from './native-gateway.js';
|
|
6
6
|
import { type DaemonIngress } from "./daemon-ingress.js";
|
|
7
|
+
import { type ShortPaths } from "./short-paths.js";
|
|
7
8
|
/**
|
|
8
9
|
* Validate a baseline against the released resource contracts. Never skip the
|
|
9
10
|
* comparison: the only historical differences are the Portal www registrations
|
|
@@ -27,4 +28,7 @@ export declare function renderStandaloneResource(m: {
|
|
|
27
28
|
daemon?: {
|
|
28
29
|
ingress?: DaemonIngress;
|
|
29
30
|
};
|
|
31
|
+
ui?: {
|
|
32
|
+
shortPaths?: ShortPaths;
|
|
33
|
+
};
|
|
30
34
|
}, portal?: PortalPackage): string | undefined;
|
|
@@ -3,6 +3,7 @@ import { sharedFolderResource } from "./shared-folder.js";
|
|
|
3
3
|
import { portalResource } from "../portal/package.js";
|
|
4
4
|
import { nativeGatewayResource } from './native-gateway.js';
|
|
5
5
|
import { DAEMON_INGRESS_CONFIG, daemonIngressResource } from "./daemon-ingress.js";
|
|
6
|
+
import { shortPathsResourceEntry } from "./short-paths.js";
|
|
6
7
|
/**
|
|
7
8
|
* Validate a baseline against the released resource contracts. Never skip the
|
|
8
9
|
* comparison: the only historical differences are the Portal www registrations
|
|
@@ -42,7 +43,10 @@ export function renderStandaloneResource(m, portal) {
|
|
|
42
43
|
// cannot carry these sibling locations.
|
|
43
44
|
const nginx = [nativeGatewayResource(m), m.daemon?.ingress && daemonIngressResource()]
|
|
44
45
|
.flatMap((r) => r?.["nginx-static-config"]?.enable ?? [])
|
|
45
|
-
.flatMap((entry) => portal && entry.type === "dsm" ? [entry, { ...entry, type: "www" }] : [entry])
|
|
46
|
+
.flatMap((entry) => portal && entry.type === "dsm" ? [entry, { ...entry, type: "www" }] : [entry])
|
|
47
|
+
// Short paths redirect to /webman/3rdparty/, which only DSM's server serves:
|
|
48
|
+
// they stay `dsm` even with a portal.
|
|
49
|
+
.concat(m.ui?.shortPaths ? [shortPathsResourceEntry()] : []);
|
|
46
50
|
const webConfig = { ...(portal ? portalResource()['web-config'] : {}),
|
|
47
51
|
...(nginx.length ? { 'nginx-static-config': { enable: nginx } } : {}) };
|
|
48
52
|
const resource = {
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { type StablePages } from "./stable-pages.js";
|
|
2
|
+
/**
|
|
3
|
+
* `ui.short_paths`: a short URL on DSM's own origin that redirects to a stable
|
|
4
|
+
* page, for example `https://<nas>/connect` → `/webman/3rdparty/<package>/m/index.html`.
|
|
5
|
+
*
|
|
6
|
+
* DSM's `web-config` worker adds the exact locations to DSM's server blocks
|
|
7
|
+
* (5000/5001 and the DSM custom domain) when the package starts and removes them
|
|
8
|
+
* when it stops, as for path ingress. The locations only answer 302 with a
|
|
9
|
+
* relative Location: no proxy, no upstream, no cookie and no package code runs,
|
|
10
|
+
* so they widen no access. The browser keeps the query (passed on) and the
|
|
11
|
+
* fragment (never sent to the server, kept across the redirect).
|
|
12
|
+
*/
|
|
13
|
+
export type ShortPaths = Record<string, string>;
|
|
14
|
+
export declare const SHORT_PATHS_CONFIG = "etc/short-paths-nginx.conf";
|
|
15
|
+
export declare const SHORT_PATH_LIMIT = 4;
|
|
16
|
+
/** Undefined when valid; otherwise why. `stablePages` are the package's declared pages. */
|
|
17
|
+
export declare function shortPathsProblem(value: unknown, stablePages: StablePages | undefined): string | undefined;
|
|
18
|
+
/** DSM before 7.2 rejects an unsigned web-config, the worker that adds the locations. */
|
|
19
|
+
export declare function shortPathsMinDsmProblem(osMinVer: string | undefined): string | undefined;
|
|
20
|
+
/** A custom ingress of the same package must not share the path: the exact location would shadow it. */
|
|
21
|
+
export declare function shortPathIngressProblem(paths: ShortPaths, ingressPath: string | undefined): string | undefined;
|
|
22
|
+
/** The URL each short path redirects to: the stable page itself (DSM answers its folder with 403). */
|
|
23
|
+
export declare function shortPathTarget(pkg: string, page: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* One exact location per path and per path with a trailing slash. A relative
|
|
26
|
+
* Location (`absolute_redirect off`) keeps the browser's scheme, host and port,
|
|
27
|
+
* so a NAS reached through a reverse proxy or tunnel is not sent to :5001.
|
|
28
|
+
* 302 is never cached permanently, so a removed package leaves no stale redirect.
|
|
29
|
+
*/
|
|
30
|
+
export declare function renderShortPathsConfig(pkg: string, paths: ShortPaths): string;
|
|
31
|
+
export declare function shortPathsResourceEntry(): {
|
|
32
|
+
type: string;
|
|
33
|
+
relpath: string;
|
|
34
|
+
};
|
|
35
|
+
/** Every entry is a redirect-only short-path registration. */
|
|
36
|
+
export declare function isShortPathsEntry(entry: unknown): boolean;
|
|
37
|
+
/**
|
|
38
|
+
* The install-time ownership check, the same read-only inventory as the SDK's
|
|
39
|
+
* custom ingress check: DSM's document-root entries, saved Application Portal
|
|
40
|
+
* aliases, other packages' nginx files (including stopped packages) and DSM's
|
|
41
|
+
* active locations. Overlap or an unreadable inventory refuses the
|
|
42
|
+
* installation with a readable message; nothing is written.
|
|
43
|
+
*/
|
|
44
|
+
export declare function renderShortPathsCheck(pkg: string | undefined, paths: ShortPaths | undefined, hook: string, root?: string): string;
|
|
45
|
+
/** Insert the check right after the shebang: it runs before every other step. */
|
|
46
|
+
export declare function withShortPathsCheck(script: string, check: string): string;
|
|
47
|
+
/** inspect: peel the check written by build; undefined when the script does not start with it. */
|
|
48
|
+
export declare function withoutShortPathsCheck(script: string, check: string): string | undefined;
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
import { isDsmAtLeast, PORTAL_MIN_DSM } from "../build-spk/dsm-version.js";
|
|
2
|
+
import { RESERVED_GATEWAY_PREFIXES } from "./gateway-ingress.js";
|
|
3
|
+
import { STABLE_PAGE_FILE } from "./stable-pages.js";
|
|
4
|
+
export const SHORT_PATHS_CONFIG = "etc/short-paths-nginx.conf";
|
|
5
|
+
export const SHORT_PATH_LIMIT = 4;
|
|
6
|
+
const PATH = /^\/[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
7
|
+
const PACKAGE = /^[A-Za-z][A-Za-z0-9]{1,63}$/;
|
|
8
|
+
/** The lifecycle hooks that check the paths before DSM activates the resource, as for custom ingress. */
|
|
9
|
+
const CHECK_HOOKS = ["preinst", "preupgrade", "postinst", "postupgrade"];
|
|
10
|
+
/** Undefined when valid; otherwise why. `stablePages` are the package's declared pages. */
|
|
11
|
+
export function shortPathsProblem(value, stablePages) {
|
|
12
|
+
if (!value || typeof value !== "object" || Array.isArray(value))
|
|
13
|
+
return "must map a path to a ui.stable_pages name, for example {/connect: m}";
|
|
14
|
+
const entries = Object.entries(value);
|
|
15
|
+
if (!entries.length || entries.length > SHORT_PATH_LIMIT)
|
|
16
|
+
return `must list 1 to ${SHORT_PATH_LIMIT} paths`;
|
|
17
|
+
for (const [path, page] of entries) {
|
|
18
|
+
if (path.length > 65 || !PATH.test(path))
|
|
19
|
+
return `path ${JSON.stringify(path)} must be one lowercase segment such as /connect: a leading /, letters, digits and inner -, no trailing / (at most 64 characters); / is unsupported`;
|
|
20
|
+
if (RESERVED_GATEWAY_PREFIXES.includes(path.slice(1)))
|
|
21
|
+
return `path ${path} is reserved by DSM or the SDK (${RESERVED_GATEWAY_PREFIXES.join(", ")}); choose another path`;
|
|
22
|
+
if (typeof page !== "string" || !stablePages || !Object.hasOwn(stablePages, page))
|
|
23
|
+
return `${path} must name a page declared in ui.stable_pages`;
|
|
24
|
+
}
|
|
25
|
+
return undefined;
|
|
26
|
+
}
|
|
27
|
+
/** DSM before 7.2 rejects an unsigned web-config, the worker that adds the locations. */
|
|
28
|
+
export function shortPathsMinDsmProblem(osMinVer) {
|
|
29
|
+
if (osMinVer && isDsmAtLeast(osMinVer, PORTAL_MIN_DSM))
|
|
30
|
+
return undefined;
|
|
31
|
+
return `ui.short_paths needs os_min_ver ${PORTAL_MIN_DSM} or later; os_min_ver is "${osMinVer ?? ""}". DSM 7.1 rejects the unsigned web-config worker that adds the redirect to DSM's nginx. Raise os_min_ver or remove ui.short_paths; the stable page URL works on DSM 7.1 too.`;
|
|
32
|
+
}
|
|
33
|
+
/** A custom ingress of the same package must not share the path: the exact location would shadow it. */
|
|
34
|
+
export function shortPathIngressProblem(paths, ingressPath) {
|
|
35
|
+
if (!ingressPath)
|
|
36
|
+
return undefined;
|
|
37
|
+
const base = ingressPath.replace(/\/$/, "");
|
|
38
|
+
const path = Object.keys(paths).find(p => base === p || base.startsWith(`${p}/`));
|
|
39
|
+
return path ? `ui.short_paths ${path} overlaps the package's own ingress path ${ingressPath}; choose another path` : undefined;
|
|
40
|
+
}
|
|
41
|
+
function checked(pkg, paths) {
|
|
42
|
+
if (!PACKAGE.test(pkg) || Object.entries(paths).some(([path, page]) => path.length > 65 || !PATH.test(path) || RESERVED_GATEWAY_PREFIXES.includes(path.slice(1)) || !/^[a-z][a-z0-9-]{0,31}$/.test(page)))
|
|
43
|
+
throw new Error("Invalid ui.short_paths declaration");
|
|
44
|
+
return Object.entries(paths).sort(([a], [b]) => a.localeCompare(b));
|
|
45
|
+
}
|
|
46
|
+
/** The URL each short path redirects to: the stable page itself (DSM answers its folder with 403). */
|
|
47
|
+
export function shortPathTarget(pkg, page) {
|
|
48
|
+
return `/webman/3rdparty/${pkg}/${page}/${STABLE_PAGE_FILE}`;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* One exact location per path and per path with a trailing slash. A relative
|
|
52
|
+
* Location (`absolute_redirect off`) keeps the browser's scheme, host and port,
|
|
53
|
+
* so a NAS reached through a reverse proxy or tunnel is not sent to :5001.
|
|
54
|
+
* 302 is never cached permanently, so a removed package leaves no stale redirect.
|
|
55
|
+
*/
|
|
56
|
+
export function renderShortPathsConfig(pkg, paths) {
|
|
57
|
+
return checked(pkg, paths).map(([path, page]) => [path, `${path}/`].map(from => `location = ${from} {\n absolute_redirect off;\n return 302 ${shortPathTarget(pkg, page)}$is_args$args;\n}\n`).join("")).join("");
|
|
58
|
+
}
|
|
59
|
+
export function shortPathsResourceEntry() {
|
|
60
|
+
return { type: "dsm", relpath: SHORT_PATHS_CONFIG };
|
|
61
|
+
}
|
|
62
|
+
/** Every entry is a redirect-only short-path registration. */
|
|
63
|
+
export function isShortPathsEntry(entry) {
|
|
64
|
+
const e = entry;
|
|
65
|
+
return Boolean(e) && typeof e === "object" && Object.keys(e).length === 2 && e.type === "dsm" && e.relpath === SHORT_PATHS_CONFIG;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The install-time ownership check, the same read-only inventory as the SDK's
|
|
69
|
+
* custom ingress check: DSM's document-root entries, saved Application Portal
|
|
70
|
+
* aliases, other packages' nginx files (including stopped packages) and DSM's
|
|
71
|
+
* active locations. Overlap or an unreadable inventory refuses the
|
|
72
|
+
* installation with a readable message; nothing is written.
|
|
73
|
+
*/
|
|
74
|
+
export function renderShortPathsCheck(pkg, paths, hook, root = "") {
|
|
75
|
+
if (!pkg || !paths || !CHECK_HOOKS.includes(hook))
|
|
76
|
+
return "";
|
|
77
|
+
if (root && !/^\/[A-Za-z0-9._/-]+$/.test(root))
|
|
78
|
+
throw new Error("Invalid inventory root");
|
|
79
|
+
const list = checked(pkg, paths).map(([path]) => path).join(" ");
|
|
80
|
+
return `synopkgland_short_path_error=$(synopkgland_short_path_check() (
|
|
81
|
+
pkg='${pkg}'
|
|
82
|
+
unavailable() { echo "Cannot check whether short path $1 is free: $2 is unreadable. Restore it and retry the installation."; exit 1; }
|
|
83
|
+
taken() { echo "Short path $1 is already used by $2. Choose another ui.short_paths path and rebuild the package."; exit 1; }
|
|
84
|
+
overlap() {
|
|
85
|
+
synopkgland_b=\${2%/}
|
|
86
|
+
[ "$1" = "$synopkgland_b" ] && return 0
|
|
87
|
+
case "$synopkgland_b" in ("$1"/*) return 0 ;; esac
|
|
88
|
+
case "$1" in ("$synopkgland_b"/*) return 0 ;; esac
|
|
89
|
+
return 1
|
|
90
|
+
}
|
|
91
|
+
lower() { printf '%s' "$1" | tr 'A-Z' 'a-z'; }
|
|
92
|
+
alias_taken() {
|
|
93
|
+
[ -r "$2" ] || unavailable "$1" "$2"
|
|
94
|
+
synopkgland_a=$(tr '\\n' ' ' < "$2" | sed -n -E 's/.*"alias"[[:space:]]*:[[:space:]]*"([^"]*)".*/\\1/p' | sed 's#\\\\/#/#g; s#^/*##; s#/*$##')
|
|
95
|
+
[ -n "$synopkgland_a" ] && overlap "$1" "/$synopkgland_a"
|
|
96
|
+
}
|
|
97
|
+
reaches() {
|
|
98
|
+
[ -r "$2" ] || unavailable "$1" "$2"
|
|
99
|
+
synopkgland_s=$1
|
|
100
|
+
sed 's/#.*//' "$2" | tr '\\n' ' ' | grep -o -E 'location[[:space:]]+((=|\\^~|~\\*?)[[:space:]]+)?("[^"]*"|[^[:space:]{]+)[[:space:]]*\\{' | {
|
|
101
|
+
while IFS= read -r synopkgland_m; do
|
|
102
|
+
synopkgland_m=\${synopkgland_m#location}
|
|
103
|
+
synopkgland_m=\${synopkgland_m%\\{}
|
|
104
|
+
set -f; set -- $synopkgland_m; set +f
|
|
105
|
+
if [ $# -ge 2 ]; then synopkgland_mod=$1; synopkgland_p=$2; else synopkgland_mod=; synopkgland_p=$1; fi
|
|
106
|
+
synopkgland_p=\${synopkgland_p#[\\"\\']}; synopkgland_p=\${synopkgland_p%[\\"\\']}
|
|
107
|
+
case "$synopkgland_mod" in
|
|
108
|
+
("~"|"~*")
|
|
109
|
+
synopkgland_i=
|
|
110
|
+
[ "$synopkgland_mod" = "~*" ] && synopkgland_i=-i
|
|
111
|
+
synopkgland_l=$(printf '%s\\n' "$synopkgland_p" | sed -n -E 's#^\\^(/[A-Za-z0-9_/-]+).*#\\1#p')
|
|
112
|
+
if [ -n "$synopkgland_l" ]; then
|
|
113
|
+
if [ -n "$synopkgland_i" ]; then overlap "$(lower "$synopkgland_s")" "$(lower "$synopkgland_l")" && exit 0
|
|
114
|
+
else overlap "$synopkgland_s" "$synopkgland_l" && exit 0; fi
|
|
115
|
+
case "$synopkgland_l" in (*/) continue ;; esac
|
|
116
|
+
fi
|
|
117
|
+
for synopkgland_probe in "$synopkgland_s" "$synopkgland_s/" "$synopkgland_s/index.html"; do
|
|
118
|
+
printf '%s\\n' "$synopkgland_probe" | grep -q -E $synopkgland_i -e "$synopkgland_p" 2>/dev/null
|
|
119
|
+
[ $? -eq 1 ] || exit 0
|
|
120
|
+
done ;;
|
|
121
|
+
(*)
|
|
122
|
+
[ "$synopkgland_p" = / ] && continue
|
|
123
|
+
overlap "$synopkgland_s" "$synopkgland_p" && exit 0
|
|
124
|
+
if [ "$synopkgland_mod" != "=" ]; then case "$synopkgland_s/" in ("$synopkgland_p"*) exit 0 ;; esac; fi ;;
|
|
125
|
+
esac
|
|
126
|
+
done
|
|
127
|
+
exit 1
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
for synopkgland_path in ${list}; do
|
|
131
|
+
synopkgland_dir=${root}/usr/syno/synoman
|
|
132
|
+
[ -d "$synopkgland_dir" ] && [ -r "$synopkgland_dir" ] || unavailable "$synopkgland_path" "$synopkgland_dir"
|
|
133
|
+
{ [ -e "$synopkgland_dir$synopkgland_path" ] || [ -L "$synopkgland_dir$synopkgland_path" ]; } && taken "$synopkgland_path" "DSM"
|
|
134
|
+
synopkgland_dir=${root}/usr/syno/etc/www/app.d
|
|
135
|
+
[ -d "$synopkgland_dir" ] && [ -r "$synopkgland_dir" ] && [ -x "$synopkgland_dir" ] || unavailable "$synopkgland_path" "$synopkgland_dir"
|
|
136
|
+
for synopkgland_f in "$synopkgland_dir"/*.json; do
|
|
137
|
+
[ -e "$synopkgland_f" ] || continue
|
|
138
|
+
alias_taken "$synopkgland_path" "$synopkgland_f" && taken "$synopkgland_path" "an Application Portal alias"
|
|
139
|
+
done
|
|
140
|
+
[ -d ${root}/var/packages ] && [ -r ${root}/var/packages ] && [ -x ${root}/var/packages ] || unavailable "$synopkgland_path" /var/packages
|
|
141
|
+
for synopkgland_pkg in ${root}/var/packages/*; do
|
|
142
|
+
synopkgland_n=\${synopkgland_pkg##*/}
|
|
143
|
+
[ "$synopkgland_n" = "$pkg" ] && continue
|
|
144
|
+
for synopkgland_rel in sso/native-nginx.conf daemon/ingress-nginx.conf ${SHORT_PATHS_CONFIG}; do
|
|
145
|
+
synopkgland_f=$synopkgland_pkg/target/$synopkgland_rel
|
|
146
|
+
[ -e "$synopkgland_f" ] || continue
|
|
147
|
+
reaches "$synopkgland_path" "$synopkgland_f" && taken "$synopkgland_path" "package $synopkgland_n"
|
|
148
|
+
done
|
|
149
|
+
synopkgland_f=$synopkgland_pkg/target/etc/portal.json
|
|
150
|
+
[ -e "$synopkgland_f" ] && alias_taken "$synopkgland_path" "$synopkgland_f" && taken "$synopkgland_path" "package $synopkgland_n"
|
|
151
|
+
done
|
|
152
|
+
synopkgland_dir=${root}/usr/local/etc/nginx/conf.d
|
|
153
|
+
[ -d "$synopkgland_dir" ] && [ -r "$synopkgland_dir" ] && [ -x "$synopkgland_dir" ] || unavailable "$synopkgland_path" "$synopkgland_dir"
|
|
154
|
+
for synopkgland_f in "$synopkgland_dir"/dsm.*.conf "$synopkgland_dir"/alias.*.conf; do
|
|
155
|
+
[ -e "$synopkgland_f" ] || [ -L "$synopkgland_f" ] || continue
|
|
156
|
+
[ -d "$synopkgland_f" ] && continue
|
|
157
|
+
case "\${synopkgland_f##*/}" in ("dsm.pkg-static.$pkg-"*) continue ;; esac
|
|
158
|
+
reaches "$synopkgland_path" "$synopkgland_f" && taken "$synopkgland_path" "DSM or another package (\${synopkgland_f##*/})"
|
|
159
|
+
done
|
|
160
|
+
done
|
|
161
|
+
exit 0
|
|
162
|
+
); synopkgland_short_path_check 2>&1) || {
|
|
163
|
+
printf '%s\\n' "$synopkgland_short_path_error" >&2
|
|
164
|
+
if [ -n "\${SYNOPKG_TEMP_LOGFILE:-}" ]; then printf '%s\\n' "$synopkgland_short_path_error" > "$SYNOPKG_TEMP_LOGFILE"; fi
|
|
165
|
+
exit 1
|
|
166
|
+
}
|
|
167
|
+
`;
|
|
168
|
+
}
|
|
169
|
+
/** Insert the check right after the shebang: it runs before every other step. */
|
|
170
|
+
export function withShortPathsCheck(script, check) {
|
|
171
|
+
return check && script.startsWith("#!/bin/sh\n") ? `#!/bin/sh\n${check}${script.slice("#!/bin/sh\n".length)}` : script;
|
|
172
|
+
}
|
|
173
|
+
/** inspect: peel the check written by build; undefined when the script does not start with it. */
|
|
174
|
+
export function withoutShortPathsCheck(script, check) {
|
|
175
|
+
if (!check)
|
|
176
|
+
return script;
|
|
177
|
+
const head = `#!/bin/sh\n${check}`;
|
|
178
|
+
return script.startsWith(head) ? `#!/bin/sh\n${script.slice(head.length)}` : undefined;
|
|
179
|
+
}
|
package/dist/standalone/spk.js
CHANGED
|
@@ -30,6 +30,7 @@ import { renderStandaloneScript } from "./lifecycle.js";
|
|
|
30
30
|
import { APP_SCRIPTS_DIR, APP_SCRIPTS_SPK_DIR } from "./app-scripts.js";
|
|
31
31
|
import { MODULE_UI_ENTRY, precompressUiTree, uiTreeDigest } from "./ui-assets.js";
|
|
32
32
|
import { writeStablePages } from "./stable-pages.js";
|
|
33
|
+
import { SHORT_PATHS_CONFIG, renderShortPathsConfig } from "./short-paths.js";
|
|
33
34
|
import { enforcePublicUi, isUiBundle, logicalUiFile, minifyUi, minifyUiTree, storedUiSecretIgnores, uiFiles } from "./public-ui.js";
|
|
34
35
|
import { codedMessage } from "../errors.js";
|
|
35
36
|
import { CHECKSUM_PLACEHOLDER, DIGEST_PLACEHOLDER, largestInstalledInfo, projectInstalledInfoIssue, stagedInstalledInfoIssue } from "../spk/installed-info.js";
|
|
@@ -148,6 +149,8 @@ export async function assembleStandaloneSpk(options) {
|
|
|
148
149
|
if (manifest.daemon?.ingress)
|
|
149
150
|
writeFile(join(staging, "package", DAEMON_INGRESS_CONFIG), renderDaemonIngressConfig(manifest.package, manifest.daemon.ingress));
|
|
150
151
|
}
|
|
152
|
+
if (manifest.ui?.shortPaths)
|
|
153
|
+
writeFile(join(staging, "package", SHORT_PATHS_CONFIG), renderShortPathsConfig(manifest.package, manifest.ui.shortPaths));
|
|
151
154
|
if (manifest.identityGateway) {
|
|
152
155
|
if (!options.identityGateway)
|
|
153
156
|
throw new StandaloneBuildError("STANDALONE_IDENTITY_GATEWAY_ARTIFACT_REQUIRED", "identity gateway artifact required.");
|
|
@@ -319,6 +322,7 @@ export async function assembleStandaloneSpk(options) {
|
|
|
319
322
|
dependencies: packageDependencies(manifest),
|
|
320
323
|
...(moduleVersion ? { ui_module: moduleVersion } : {}),
|
|
321
324
|
...(manifest.ui?.stablePages ? { stable_pages: manifest.ui.stablePages } : {}),
|
|
325
|
+
...(manifest.ui?.shortPaths ? { short_paths: manifest.ui.shortPaths } : {}),
|
|
322
326
|
...(manifest.installSettings ? { installSettings: manifest.installSettings } : {}),
|
|
323
327
|
...(manifest.installPorts ? { installPorts: portDefaults(manifest) } : {}),
|
|
324
328
|
...(manifest.minMemoryMb !== undefined ? { minMemoryMb: manifest.minMemoryMb } : {}),
|
|
@@ -511,7 +515,7 @@ export function renderInfo(manifest, arch, checksum, executorDigest) {
|
|
|
511
515
|
// SYNO.API.Info refresh, which leaves the browser tab without API paths.
|
|
512
516
|
// An executor-registered portal entry needs no DSM reload: the executor
|
|
513
517
|
// reloads nginx itself when it removes the entry.
|
|
514
|
-
const nginx = nativeGatewaySupported(manifest) || Boolean(manifest.daemon?.ingress);
|
|
518
|
+
const nginx = nativeGatewaySupported(manifest) || Boolean(manifest.daemon?.ingress) || Boolean(manifest.ui?.shortPaths);
|
|
515
519
|
const portalReload = Boolean(manifest.portal) && !portalByExecutor(manifest.os_min_ver);
|
|
516
520
|
return portalInfoFields(fields, portalReload || nginx).map(([key, value]) => `${key}=${quote(value)}\n`).join("");
|
|
517
521
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synopackageland/cli",
|
|
3
|
-
"version": "0.54.
|
|
3
|
+
"version": "0.54.3",
|
|
4
4
|
"description": "Syno Package Land Developer Kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
44
|
"@napi-rs/keyring": "^2.1.1",
|
|
45
|
-
"@synopackageland/templates": "~0.
|
|
45
|
+
"@synopackageland/templates": "~0.44.0",
|
|
46
46
|
"ajv": "^8.17.1",
|
|
47
47
|
"commander": "^13.1.0",
|
|
48
48
|
"esbuild": "^0.28.2",
|
|
@@ -28,6 +28,27 @@
|
|
|
28
28
|
},
|
|
29
29
|
"additionalProperties": false
|
|
30
30
|
},
|
|
31
|
+
"ui": {
|
|
32
|
+
"type": ["object", "boolean"],
|
|
33
|
+
"properties": {
|
|
34
|
+
"stable_pages": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"description": "Page name -> file in ui.dir, served at /webman/3rdparty/<package>/<name>/index.html in every build.",
|
|
37
|
+
"minProperties": 1,
|
|
38
|
+
"maxProperties": 8,
|
|
39
|
+
"propertyNames": {"pattern": "^[a-z][a-z0-9-]{0,31}$"},
|
|
40
|
+
"additionalProperties": {"type": "string"}
|
|
41
|
+
},
|
|
42
|
+
"short_paths": {
|
|
43
|
+
"type": "object",
|
|
44
|
+
"description": "DSM path -> ui.stable_pages name. DSM's nginx answers 302 to /webman/3rdparty/<package>/<name>/index.html while the package runs. One lowercase segment, not a DSM or SDK name; installation checks that no other package or DSM uses it. Needs os_min_ver 7.2-64570 or later.",
|
|
45
|
+
"minProperties": 1,
|
|
46
|
+
"maxProperties": 4,
|
|
47
|
+
"propertyNames": {"pattern": "^/[a-z0-9]+(?:-[a-z0-9]+)*$", "maxLength": 65},
|
|
48
|
+
"additionalProperties": {"type": "string", "pattern": "^[a-z][a-z0-9-]{0,31}$"}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
31
52
|
"ui_secret_ignores": {
|
|
32
53
|
"description": "False-positive exceptions for public UI secret scanning. file is an exact path relative to ui/ (omit a module snapshot hash: app/help.json) and may contain one [hash] for a bundler content hash ([A-Za-z0-9_-]{6,64}, within one path segment) that must match exactly one file. match lists the exact flagged texts to exempt (required with [hash]); other hits in the file still fail, and a listed text that no longer occurs fails the build. Source maps cannot be ignored.",
|
|
33
54
|
"type": "array",
|
package/skills/SKILL.md
CHANGED
|
@@ -354,6 +354,7 @@ favicon 與手機 viewport 由 wrapper 設定。不需要 `pureEnv` 或 `allowAl
|
|
|
354
354
|
`ui.banner: hidden` 只替這個 App 的全頁拿掉 DSM 橫幅(預設 `shown` 保留);適合 App 外框已有名稱與帳號區時,帳號與登出改由 SDK `AppShell` 負責。細節見 reference/ui-vue.md。
|
|
355
355
|
|
|
356
356
|
要給人一個跨版本不變的頁面網址(QR code、書籤、手機主畫面捷徑、PWA `start_url`)時,宣告 `ui.stable_pages: {<name>: <ui.dir 內的檔案>}`,例如 `{m: m/index.html}` → `/webman/3rdparty/<package>/m/index.html`。不要把 `app/<digest>/…` 網址交給使用者:module UI 的 digest 資料夾每次 build 都會換。build 生成固定內容的轉址頁與 `target.json`,DSM 7.1+ 免登入可開,不需 ingress 或 CGI。細節見 reference/ui-vue.md 的 Stable page URLs。
|
|
357
|
+
要更短的網址(例如 `https://<nas>:5001/connect`)時,再加 `ui.short_paths: {/connect: m}`:值是 `stable_pages` 的頁名,DSM nginx 以 302 轉到 `/webman/3rdparty/<package>/m/index.html`,只在套件執行時有效,需要 `os_min_ver` 7.2-64570+。路徑是單一小寫片段;DSM 已用的名稱(`/mobile`、`/webman`、`/sharing` 等)不能用,安裝時還會檢查 NAS 上是否已被 DSM 或其他套件佔用。
|
|
357
358
|
|
|
358
359
|
Application Portal 是獨立 opt-in:不想要別名就省略 `portal`,不生成
|
|
359
360
|
`defaultAlias`、Portal 面板/capability 或 Web Station alias;沒有 Portal
|
|
@@ -112,6 +112,13 @@ Follow DSM's button policy, in the installed
|
|
|
112
112
|
section that needs a manual re-read gets its own action in that section.
|
|
113
113
|
`AppShell`'s `#actions` (and `PageHeader` `#actions`) hold only real page
|
|
114
114
|
actions, such as Add; with nothing in `#actions` the shell draws no bar.
|
|
115
|
+
- Read through the template's data layer in `frontend/src/data/`: `useQuery`
|
|
116
|
+
with keys from `data.key(...)` (they include the signed-in user), and
|
|
117
|
+
`data.revalidate()` on reopen and when a page is shown again; it re-reads in
|
|
118
|
+
the background and joins a read in flight. Keep the cache in memory only.
|
|
119
|
+
Optional reads (side panels, hints, counts) wait for the first screen
|
|
120
|
+
(`useFirstContent()`); defer and merge reads instead of lowering request
|
|
121
|
+
concurrency. Use `@tanstack/query-core`, not `@tanstack/vue-query`.
|
|
115
122
|
- In development the UI warns in the console about a capsule outside a footer,
|
|
116
123
|
two main actions in a footer, or a main action that is not last. Clear these
|
|
117
124
|
warnings before handing over the app.
|
|
@@ -175,6 +182,13 @@ window. Check long text, scrolling, focus, modal open/close and cleanup with two
|
|
|
175
182
|
independent mounts. A local mock host can check layout; it cannot prove NAS
|
|
176
183
|
permissions or real DSM integration. Obtain authorization before testing on NAS.
|
|
177
184
|
|
|
185
|
+
For the local mock host, run `pnpm run dev` in `frontend` and open
|
|
186
|
+
`/?mock=1&trace=1&latency=200`: every call waits like a NAS round trip and is
|
|
187
|
+
recorded in `window.__calls` (`method`, `params`, `at`, `ms`, `ok`, `code`), an
|
|
188
|
+
RPC timeline to count and order reads without a NAS. Add a mock answer in
|
|
189
|
+
`frontend/src/dev/mock/` for each method the App adds. Only the dev server
|
|
190
|
+
loads the mock; the build leaves it out.
|
|
191
|
+
|
|
178
192
|
For JSON portions, also follow ui-json's strict validate/render loop at the target
|
|
179
193
|
widths. The JSON preview renders a spec, not arbitrary `.vue` files or backend
|
|
180
194
|
handlers; it does not replace the Vue build, tests or actual-app screenshots.
|
|
@@ -251,6 +265,33 @@ ui:
|
|
|
251
265
|
宣告格式錯誤時 check 回 `STANDALONE_UI_STABLE_PAGES_INVALID`。
|
|
252
266
|
- 轉址頁、`target.json` 與目標都是公開 UI 檔,照樣過 secret scan;`inspect` 會比對轉址頁與 pointer(`UI_STABLE_PAGE_INVALID`)。
|
|
253
267
|
|
|
268
|
+
### Short paths
|
|
269
|
+
|
|
270
|
+
穩定網址仍然很長。要讓使用者直接輸入 `https://<nas>:5001/connect`,加 `ui.short_paths`:路徑對應到 `stable_pages` 的頁名。
|
|
271
|
+
|
|
272
|
+
```yaml
|
|
273
|
+
os_min_ver: "7.2-64570"
|
|
274
|
+
ui:
|
|
275
|
+
dir: frontend/dist
|
|
276
|
+
stable_pages:
|
|
277
|
+
m: m/index.html
|
|
278
|
+
short_paths:
|
|
279
|
+
/connect: m # → /webman/3rdparty/<package>/m/index.html
|
|
280
|
+
```
|
|
281
|
+
|
|
282
|
+
- build 寫入 `etc/short-paths-nginx.conf`:`location = /connect` 與 `location = /connect/`,回 302、相對 `Location`
|
|
283
|
+
(`absolute_redirect off`,經反向代理或 tunnel 進來也不會被帶到 :5001),query 照傳,fragment 由瀏覽器保留。
|
|
284
|
+
不 proxy、不碰 cookie、不跑套件程式。
|
|
285
|
+
- DSM `web-config` worker 在套件啟動時加入 DSM server(5000/5001 與 DSM 自訂網域),停止時移除;停止或解除安裝後回 404。
|
|
286
|
+
有 `portal` 也只註冊在 DSM server:80/443 不提供 `/webman/3rdparty/`。
|
|
287
|
+
- 規則:單一小寫片段(字母、數字、中間的 `-`,最多 64 字元,不可結尾 `/`),最多 4 個;不可用 `/`、DSM/SDK 名稱
|
|
288
|
+
(與 custom ingress 相同的保留清單,含 `/mobile`、`/webman`、`/webapi`、`/sharing`、`/synopkgland`)、
|
|
289
|
+
與自己 ingress 重疊的路徑或未宣告的頁名(`STANDALONE_UI_SHORT_PATHS_INVALID`);`os_min_ver` 低於 7.2-64570 回
|
|
290
|
+
`STANDALONE_UI_SHORT_PATHS_MIN_DSM`(DSM 7.1 拒絕未簽章的 web-config)。
|
|
291
|
+
- 安裝與升級時 `preinst`/`preupgrade`/`postinst`/`postupgrade` 先跑唯讀檢查(與 custom ingress 相同的清單:
|
|
292
|
+
`/usr/syno/synoman`、Portal alias、其他套件的 nginx 檔含已停止的套件、DSM 啟用中的 location)。被佔用或清單讀不到就拒絕安裝並顯示原因;換路徑重新 build。
|
|
293
|
+
- `inspect` 比對設定檔、resource、INFO reload 與檢查腳本(`SHORT_PATHS_INVALID`)。`approval-diff` 會列出 short path 的 resource 變更,但不要求重新核准。
|
|
294
|
+
|
|
254
295
|
Application Portal 是獨立 opt-in:不想要別名就省略 `portal`,不生成
|
|
255
296
|
`defaultAlias`、Portal 面板/capability 或 Web Station alias;沒有 Portal
|
|
256
297
|
不是 inspect/info/doctor 問題。明確啟用 `portal` 時才將其 alias 作為 `defaultAlias`。
|