@synopackageland/cli 0.54.0 → 0.54.2

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 CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.54.2 (2026-11-15)
4
+
5
+ - `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.
6
+
7
+ ## 0.54.1 (2026-11-14)
8
+
9
+ - `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`.
10
+ - On an App with an SDK window, a unix-upstream gateway is ingress only (`mode: none`): the DSM window, launcher type, default launch mode, Package Center Open, portal and mobile entry stay as without the gateway, and the smoke entry stays the window. The gateway daemon, the native ingress web-config location (WebSocket headers, 3600 s read timeout), `ingress-check` and the mTLS socket are still generated. `console` and `mobile.entry: gateway` are refused with it.
11
+
3
12
  ## 0.54.0 (2026-11-14)
4
13
 
5
14
  - `init` defaults to native-go with Vue. Explicit `-t` still selects any of the six templates.
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.
@@ -7,7 +7,7 @@ export declare function isAppLaunchMode(value: unknown): value is AppLaunchMode;
7
7
  /** Both Compose routes use the same web default; a valid explicit choice wins. */
8
8
  export declare function resolveAppLaunch(value: unknown, webService: boolean): AppLaunchMode | undefined;
9
9
  /** A console always opens the SDK UI in a DSM window. */
10
- export declare function resolvedSdkLaunch(manifest: Pick<StandaloneManifest, 'ui' | 'compose' | 'identityGateway'> & {
10
+ export declare function resolvedSdkLaunch(manifest: Pick<StandaloneManifest, 'ui' | 'compose' | 'identityGateway' | 'sdkWindow'> & {
11
11
  console?: unknown;
12
12
  }): AppLaunchMode;
13
13
  /** DSM rewrites standalone URLs to launchApp; only SDK wrappers provide that class. */
@@ -1,3 +1,4 @@
1
+ import { gatewayIngressOnly } from '../standalone/gateway-ingress-only.js';
1
2
  export const APP_LAUNCH_MODES = ['dsm-window', 'new-page'];
2
3
  export const DEFAULT_NATIVE_LAUNCH = 'dsm-window';
3
4
  export const DEFAULT_WEB_LAUNCH = 'new-page';
@@ -11,7 +12,7 @@ export function resolveAppLaunch(value, webService) {
11
12
  }
12
13
  /** A console always opens the SDK UI in a DSM window. */
13
14
  export function resolvedSdkLaunch(manifest) {
14
- return resolveAppLaunch(manifest.console ? 'dsm-window' : manifest.ui.launch, Boolean(manifest.compose || manifest.identityGateway));
15
+ return resolveAppLaunch(manifest.console ? 'dsm-window' : manifest.ui.launch, Boolean(manifest.compose || manifest.identityGateway && !gatewayIngressOnly(manifest)));
15
16
  }
16
17
  /** DSM rewrites standalone URLs to launchApp; only SDK wrappers provide that class. */
17
18
  export function dsmLauncherType(launch, sdkWindow) {
@@ -1,6 +1,7 @@
1
1
  import { gatewayIngressPathProblem } from '../standalone/gateway-ingress.js';
2
2
  import { readFileSync } from 'node:fs';
3
3
  import { parse } from 'yaml';
4
+ import { unixUpstreamSocket } from '../standalone/gateway-ingress-only.js';
4
5
  import { resolveAppLaunch } from '../contract/app-launch.js';
5
6
  import { trustedAppEntryPath } from '../contract/web-launch.js';
6
7
  import { readDaemonIngress } from '../standalone/daemon-ingress.js';
@@ -19,7 +20,9 @@ export function deriveSmokeEntry(raw, entry) {
19
20
  }
20
21
  const native = raw.schema === 2;
21
22
  const gateway = raw.identity_gateway;
22
- const web = Boolean(gateway || raw.compose || (!native && raw.adminport));
23
+ // A unix-upstream gateway on an SDK-window App is ingress only: the window stays the entry.
24
+ const ingressOnly = Boolean(unixUpstreamSocket(gateway?.upstream) && !raw.compose && raw.ui !== false);
25
+ const web = Boolean((gateway && !ingressOnly) || raw.compose || (!native && raw.adminport));
23
26
  if ((!native && !raw.adminport) || (raw.ui === false && !gateway))
24
27
  throw new Error('This package has no app entry to smoke test.');
25
28
  const appId = native ? `SYNO.SDS.${raw.package}.Instance` : raw.package;
@@ -33,7 +36,7 @@ export function deriveSmokeEntry(raw, entry) {
33
36
  const gatewayIngress = gateway?.ingress && !gatewayIngressPathProblem(raw.package, gateway.ingress.path) ? gateway.ingress : undefined;
34
37
  if (gateway?.ingress !== undefined && !gatewayIngress)
35
38
  throw new Error("Invalid gateway ingress namespace");
36
- const derived = ingress?.path ?? gatewayIngress?.path ?? (gateway
39
+ const derived = ingress?.path ?? (ingressOnly ? undefined : gatewayIngress?.path) ?? (gateway && !ingressOnly
37
40
  ? `/webman/3rdparty/${raw.package}/sso/open.cgi`
38
41
  : native ? `/?launchApp=${encodeURIComponent(appId)}`
39
42
  : trustedAppEntryPath(raw));
@@ -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)));
@@ -1,6 +1,7 @@
1
1
  import { renderExecutorApproval } from './executor-approval.js';
2
2
  import { CALL_RETRY_RUNTIME } from './call-retry.js';
3
3
  import { oidcResumeRuntime } from "./oidc-resume.js";
4
+ import { gatewayIngressOnly } from './gateway-ingress-only.js';
4
5
  import { gatewayEntryPath } from './native-gateway.js';
5
6
  import { resolvedSdkLaunch, dsmLauncherType } from "../contract/app-launch.js";
6
7
  import { REOPEN_EVENTS_RUNTIME } from "./reopen-events.js";
@@ -124,7 +125,7 @@ export function windowAppId(manifest) {
124
125
  }
125
126
  /** Whether the window itself resumes a cold DSM sign-in; with a console the url launcher does. */
126
127
  function windowResumesOIDC(manifest) {
127
- return Boolean(manifest.identityGateway && !manifest.console);
128
+ return Boolean(manifest.identityGateway && !manifest.console && !gatewayIngressOnly(manifest));
128
129
  }
129
130
  /**
130
131
  * `ui/config`: registers the DSM main-menu app and its window class. With a
@@ -0,0 +1,15 @@
1
+ export declare const unixUpstreamSocket: (upstream: unknown) => string | undefined;
2
+ /**
3
+ * An SDK-window App whose gateway only carries path ingress (a unix upstream
4
+ * for the App's own WebSocket route). The gateway is infrastructure there: it
5
+ * never launches a web UI, so the DSM window, menu, Package Center Open,
6
+ * portal and mobile entry stay exactly as without the gateway. A unix
7
+ * upstream is new, so no existing App is inferred ingress-only.
8
+ */
9
+ export declare function gatewayIngressOnly(m: {
10
+ compose?: unknown;
11
+ sdkWindow?: false;
12
+ identityGateway?: {
13
+ upstream: number | string;
14
+ };
15
+ }): boolean;
@@ -0,0 +1,13 @@
1
+ /** `unix:<name>.sock`: a direct socket name; the gateway dials /var/packages/<package>/var/run/<name>.sock. */
2
+ const UNIX_UPSTREAM = /^unix:([a-z0-9][a-z0-9-]{0,58}\.sock)$/;
3
+ export const unixUpstreamSocket = (upstream) => typeof upstream === "string" ? UNIX_UPSTREAM.exec(upstream)?.[1] : undefined;
4
+ /**
5
+ * An SDK-window App whose gateway only carries path ingress (a unix upstream
6
+ * for the App's own WebSocket route). The gateway is infrastructure there: it
7
+ * never launches a web UI, so the DSM window, menu, Package Center Open,
8
+ * portal and mobile entry stay exactly as without the gateway. A unix
9
+ * upstream is new, so no existing App is inferred ingress-only.
10
+ */
11
+ export function gatewayIngressOnly(m) {
12
+ return Boolean(m.identityGateway && unixUpstreamSocket(m.identityGateway.upstream) && !m.compose && m.sdkWindow !== false);
13
+ }
@@ -63,8 +63,8 @@ export interface IdentityGateway {
63
63
  groups?: string[];
64
64
  max_upload_bytes?: number;
65
65
  response_header_timeout_seconds?: number;
66
- /** The App's loopback port. */
67
- upstream: number;
66
+ /** The App's loopback port, or `unix:<name>.sock`: its private SDK IPC socket under var/run. */
67
+ upstream: number | string;
68
68
  listen: {
69
69
  http?: number;
70
70
  https?: number;
@@ -6,7 +6,8 @@ import { existsSync, lstatSync, readFileSync } from "node:fs";
6
6
  import { join } from "node:path";
7
7
  import { PINNED_GO_HINT, pinnedGoBuildEnv, pinnedGoProblem, } from "../build-spk/go-toolchain.js";
8
8
  import { goChildEnv } from "../runtime/go-env.js";
9
- import { sdkSource } from "../runtime/sdk-source.js";
9
+ import { unixUpstreamSocket } from "./gateway-ingress-only.js";
10
+ import { SDK_MODULE, sdkSource } from "../runtime/sdk-source.js";
10
11
  import { checkCgiBinary } from "./binary.js";
11
12
  import { isWebAccessMode, DSM_GROUP_NAME, } from "../contract/web-launch.js";
12
13
  import { relativeExec, runtimeBudgetSource, token } from "./daemon.js";
@@ -59,6 +60,10 @@ function secureContextSdkSupported(dir) {
59
60
  const source = join(dir, "idgateway/secure_context.go");
60
61
  return existsSync(source) && /const SecureContextVersion = 1\b/.test(readFileSync(source, "utf8"));
61
62
  }
63
+ function unixUpstreamSdkSupported(dir) {
64
+ const source = join(dir, "idgateway/unix_upstream.go");
65
+ return existsSync(source) && /const UnixUpstreamVersion = 1\b/.test(readFileSync(source, "utf8"));
66
+ }
62
67
  function upstreamAuthSdkSupported(dir) {
63
68
  const source = join(dir, "idgateway/upstream_auth.go");
64
69
  return existsSync(source) && /const UpstreamAuthPathsVersion = 1\b/.test(readFileSync(source, "utf8"));
@@ -264,8 +269,26 @@ export function readIdentityGateway(value, daemon, fail, packagedPayload = false
264
269
  v.mode !== "header" &&
265
270
  v.mode !== "token")
266
271
  return invalid("mode must be none, oidc, header or token.");
267
- if (!port(v.upstream))
268
- return invalid("upstream must be the App's loopback port.");
272
+ const unixSocket = unixUpstreamSocket(v.upstream);
273
+ if (typeof v.upstream === "string") {
274
+ if (!unixSocket)
275
+ return invalid("upstream must be the App's loopback port or unix:<name>.sock (lowercase letters, digits and hyphens, at most 59 characters before .sock).");
276
+ if (composeBridge)
277
+ return invalid("a unix upstream cannot be combined with compose.");
278
+ if (v.ingress === undefined)
279
+ return invalid("a unix upstream requires ingress: the gateway has no TCP listener to serve it.");
280
+ if (record(v.listen) && Object.keys(v.listen).length)
281
+ return invalid("a unix upstream cannot combine with listen ports; use ingress only.");
282
+ try {
283
+ if (!unixUpstreamSdkSupported(sdkSource(v.sdk).goDir))
284
+ return invalid("The selected SDK lacks unix upstream support (UnixUpstreamVersion); use a matching SDK release or an explicit development source override.");
285
+ }
286
+ catch {
287
+ return invalid("The SDK unix upstream source is unavailable; use matching SDK sources.");
288
+ }
289
+ }
290
+ else if (!port(v.upstream))
291
+ return invalid("upstream must be the App's loopback port or unix:<name>.sock.");
269
292
  const ingress = v.ingress;
270
293
  if (ingress !== undefined && (!record(ingress) || !only(ingress, ["path"]) || typeof ingress.path !== "string" || gatewayIngressPathProblem(undefined, ingress.path) !== undefined))
271
294
  return invalid(gatewayIngressPathProblem(undefined, record(ingress) ? ingress.path : undefined) ?? "ingress accepts only {path: /my-app/}.");
@@ -281,7 +304,7 @@ export function readIdentityGateway(value, daemon, fail, packagedPayload = false
281
304
  const ports = [
282
305
  listen.http,
283
306
  listen.https,
284
- ...(composeBridge ? [] : [v.upstream]),
307
+ ...(composeBridge || unixSocket ? [] : [v.upstream]),
285
308
  issuer,
286
309
  ].filter((p) => p !== undefined);
287
310
  if (new Set(ports).size !== ports.length ||
@@ -527,7 +550,9 @@ export function identityGatewayConfig(m) {
527
550
  : {}),
528
551
  upstream: m.compose?.plan.ingress
529
552
  ? `http://${m.compose.plan.ingress.address}:${m.compose.plan.ingress.port}`
530
- : `http://127.0.0.1:${g.upstream}`,
553
+ : unixUpstreamSocket(g.upstream)
554
+ ? `unix:/var/packages/${m.package}/var/run/${unixUpstreamSocket(g.upstream)}`
555
+ : `http://127.0.0.1:${g.upstream}`,
531
556
  ...(m.compose?.plan.ingress
532
557
  ? { compose_ingress: { candidate: m.compose.plan.ingress.candidate } }
533
558
  : {}),
@@ -598,6 +623,8 @@ export async function buildIdentityGateway(m, arch, work, run) {
598
623
  runtimeBudgetSource(sdk.goDir, m);
599
624
  if (m.identityGateway.secure_context && !secureContextSdkSupported(sdk.goDir))
600
625
  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.");
626
+ if (unixUpstreamSocket(m.identityGateway.upstream) && !unixUpstreamSdkSupported(sdk.goDir))
627
+ throw new StandaloneBuildError("STANDALONE_IDENTITY_GATEWAY_INVALID", "The selected SDK lacks unix upstream support (UnixUpstreamVersion); use a matching SDK release or an explicit development source override.");
601
628
  if (m.identityGateway.upstream_auth_paths && !upstreamAuthSdkSupported(sdk.goDir))
602
629
  throw new StandaloneBuildError("STANDALONE_IDENTITY_GATEWAY_INVALID", "The selected SDK lacks upstream_auth_paths and its build-bound entry policy; use matching SDK sources.");
603
630
  if (gatewayExternalAccess(m.identityGateway)) {
@@ -637,7 +664,7 @@ export async function buildIdentityGateway(m, arch, work, run) {
637
664
  const policyFlag = upstreamAuthSdkSupported(sdk.goDir)
638
665
  ? ` -X github.com/synopackageland/syno-pkg-land-sdk/idgateway.expectedEntryPolicyDigest=${gatewayEntryPolicyDigest(JSON.parse(identityGatewayConfig(m)))}`
639
666
  : "";
640
- const ldflags = `-s -w -buildid= -X main.configPath=${packageDest(m)}/${GATEWAY_CONFIG_PATH}${policyFlag}`;
667
+ const ldflags = `-s -w -buildid= -X main.configPath=${packageDest(m)}/${GATEWAY_CONFIG_PATH} -X ${SDK_MODULE}/ipc.packageID=${m.package}${policyFlag}`;
641
668
  const result = await run("go", [
642
669
  "build",
643
670
  "-trimpath",
@@ -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
- function checkConf(dir, findings, kind, background, sharedFolder, pkg, portal, compose, nativeGateway, osMinVer, daemonIngress, installPorts = false, nofile, baseline = false) {
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
- return manifest.appScripts?.some((app) => app === name)
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';
@@ -31,6 +32,7 @@ import { daemonSdkVersion, readDaemon, readLifecycleTimeouts } from "./daemon.js
31
32
  import { daemonRestartSdkProblem } from "./daemon-restart.js";
32
33
  import { daemonIngressMinDsmProblem } from "./daemon-ingress.js";
33
34
  import { readIdentityGateway, } from "./identity-gateway.js";
35
+ import { gatewayIngressOnly, unixUpstreamSocket } from "./gateway-ingress-only.js";
34
36
  import { readUninstall } from "./uninstall.js";
35
37
  import { readHyperBackup } from "./hyper-backup.js";
36
38
  import { readAppScripts } from "./app-scripts.js";
@@ -511,6 +513,14 @@ function readManifest(raw, c) {
511
513
  const noWindow = raw.compose === undefined && raw.ui === false;
512
514
  if (noWindow)
513
515
  readNoWindow(raw, capabilities, c);
516
+ if (identityGateway && unixUpstreamSocket(identityGateway.upstream)) {
517
+ const why = raw.compose !== undefined ? "cannot be combined with compose"
518
+ : raw.console !== undefined ? "cannot be combined with console: the gateway serves no web UI"
519
+ : !noWindow && identityGateway.mode !== "none" ? "on an App with an SDK window requires mode: none: the window stays the App's entry"
520
+ : undefined;
521
+ if (why)
522
+ c.fail("STANDALONE_IDENTITY_GATEWAY_INVALID", `identity_gateway: a unix upstream ${why}.`);
523
+ }
514
524
  const ui = raw.compose !== undefined || noWindow
515
525
  ? {
516
526
  dir: c.root,
@@ -527,6 +537,11 @@ function readManifest(raw, c) {
527
537
  ui?.launch !== undefined &&
528
538
  !isWebLaunchMode(ui.launch))
529
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
+ }
530
545
  if (backend &&
531
546
  isBridgeBackend(backend) &&
532
547
  ui &&
@@ -553,6 +568,8 @@ function readManifest(raw, c) {
553
568
  c.fail('STANDALONE_MOBILE_INVALID', 'mobile.entry: app needs a UI');
554
569
  if (mobile.entry === 'gateway' && !identityGateway)
555
570
  c.fail('STANDALONE_MOBILE_INVALID', 'mobile.entry: gateway needs identity_gateway');
571
+ if (mobile.entry === 'gateway' && gatewayIngressOnly({ sdkWindow: noWindow ? false : undefined, identityGateway }))
572
+ c.fail('STANDALONE_MOBILE_INVALID', 'mobile.entry: gateway needs a gateway web UI; a unix-upstream gateway only carries ingress. Use mobile.entry: app.');
556
573
  if (mobile.icon)
557
574
  renderPackageIcons(mobileIconPath(c.root, mobile.icon));
558
575
  }
@@ -1109,6 +1126,11 @@ function readUi(value, c) {
1109
1126
  if (stableProblem)
1110
1127
  return c.fail("STANDALONE_UI_STABLE_PAGES_INVALID", `ui.stable_pages ${stableProblem}`);
1111
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 } });
1112
1134
  if (value.build === undefined) {
1113
1135
  return dir ? { dir, ...launch, ...window, ...banner, ...stable } : undefined;
1114
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
+ }
@@ -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
  }
@@ -37,6 +37,28 @@ identity_gateway:
37
37
  headers: {user: Remote-User}
38
38
  ```
39
39
 
40
+ ### Ingress only, with no TCP port
41
+
42
+ An App with an SDK window that needs one App-authenticated route (for example a
43
+ WebSocket) on DSM's origin can point the gateway at its private SDK IPC socket:
44
+
45
+ ```yaml
46
+ identity_gateway:
47
+ sdk: <sdk-with-UnixUpstreamVersion>
48
+ mode: none
49
+ upstream: unix:reverse-ingress.sock # /var/packages/<package>/var/run/<name>.sock
50
+ ingress: {path: /synopkgland/ExampleApp/}
51
+ upstream_auth_paths: [/reverse]
52
+ ```
53
+
54
+ The name is `[a-z0-9][a-z0-9-]{0,58}\.sock`, a direct name. The App serves it with
55
+ the SDK's `ipc.ServeUnix`; no TCP listener is involved. The form needs `ingress`,
56
+ no `listen`, no Compose and an SDK whose `idgateway` declares
57
+ `UnixUpstreamVersion = 1`. With an SDK window the gateway is ingress only: the
58
+ DSM window, menu, Package Center Open, portal and mobile entry are unchanged
59
+ (`console` and `mobile.entry: gateway` are refused). Without a window the
60
+ gateway opens its web UI as usual.
61
+
40
62
  Replace `listen` with `ingress`. The default is `/synopkgland/<exact-package-ID>/` (case sensitive).
41
63
  The SDK and CLI also accept an explicit custom path:
42
64
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.54.0",
3
+ "version": "0.54.2",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -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
@@ -251,6 +251,33 @@ ui:
251
251
  宣告格式錯誤時 check 回 `STANDALONE_UI_STABLE_PAGES_INVALID`。
252
252
  - 轉址頁、`target.json` 與目標都是公開 UI 檔,照樣過 secret scan;`inspect` 會比對轉址頁與 pointer(`UI_STABLE_PAGE_INVALID`)。
253
253
 
254
+ ### Short paths
255
+
256
+ 穩定網址仍然很長。要讓使用者直接輸入 `https://<nas>:5001/connect`,加 `ui.short_paths`:路徑對應到 `stable_pages` 的頁名。
257
+
258
+ ```yaml
259
+ os_min_ver: "7.2-64570"
260
+ ui:
261
+ dir: frontend/dist
262
+ stable_pages:
263
+ m: m/index.html
264
+ short_paths:
265
+ /connect: m # → /webman/3rdparty/<package>/m/index.html
266
+ ```
267
+
268
+ - build 寫入 `etc/short-paths-nginx.conf`:`location = /connect` 與 `location = /connect/`,回 302、相對 `Location`
269
+ (`absolute_redirect off`,經反向代理或 tunnel 進來也不會被帶到 :5001),query 照傳,fragment 由瀏覽器保留。
270
+ 不 proxy、不碰 cookie、不跑套件程式。
271
+ - DSM `web-config` worker 在套件啟動時加入 DSM server(5000/5001 與 DSM 自訂網域),停止時移除;停止或解除安裝後回 404。
272
+ 有 `portal` 也只註冊在 DSM server:80/443 不提供 `/webman/3rdparty/`。
273
+ - 規則:單一小寫片段(字母、數字、中間的 `-`,最多 64 字元,不可結尾 `/`),最多 4 個;不可用 `/`、DSM/SDK 名稱
274
+ (與 custom ingress 相同的保留清單,含 `/mobile`、`/webman`、`/webapi`、`/sharing`、`/synopkgland`)、
275
+ 與自己 ingress 重疊的路徑或未宣告的頁名(`STANDALONE_UI_SHORT_PATHS_INVALID`);`os_min_ver` 低於 7.2-64570 回
276
+ `STANDALONE_UI_SHORT_PATHS_MIN_DSM`(DSM 7.1 拒絕未簽章的 web-config)。
277
+ - 安裝與升級時 `preinst`/`preupgrade`/`postinst`/`postupgrade` 先跑唯讀檢查(與 custom ingress 相同的清單:
278
+ `/usr/syno/synoman`、Portal alias、其他套件的 nginx 檔含已停止的套件、DSM 啟用中的 location)。被佔用或清單讀不到就拒絕安裝並顯示原因;換路徑重新 build。
279
+ - `inspect` 比對設定檔、resource、INFO reload 與檢查腳本(`SHORT_PATHS_INVALID`)。`approval-diff` 會列出 short path 的 resource 變更,但不要求重新核准。
280
+
254
281
  Application Portal 是獨立 opt-in:不想要別名就省略 `portal`,不生成
255
282
  `defaultAlias`、Portal 面板/capability 或 Web Station alias;沒有 Portal
256
283
  不是 inspect/info/doctor 問題。明確啟用 `portal` 時才將其 alias 作為 `defaultAlias`。