@synopackageland/cli 0.43.0 → 0.44.0

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,12 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.44.0
4
+
5
+ - Allow opt-in custom lowercase identity gateway ingress paths with reserved-prefix checks and actionable validation errors.
6
+ - Check route ownership before installation and upgrade without changing App privileges or writing global DSM config.
7
+ - Inspect the packaged checker and preserve the default namespace, upstream authentication and WebSocket proxy.
8
+ - Document both ingress forms and the unsupported origin root.
9
+
3
10
  ## 0.43.0 (2026-11-02)
4
11
 
5
12
  - Add identity_gateway.ingress for fixed DSM package paths without a public gateway port.
@@ -1,3 +1,4 @@
1
+ import { gatewayIngressPathProblem } from '../standalone/gateway-ingress.js';
1
2
  import { readFileSync } from 'node:fs';
2
3
  import { parse } from 'yaml';
3
4
  import { resolveAppLaunch } from '../contract/app-launch.js';
@@ -29,7 +30,7 @@ export function deriveSmokeEntry(raw, entry) {
29
30
  const ingress = readDaemonIngress(raw.daemon?.ingress, raw.package, () => { });
30
31
  if (raw.daemon?.ingress !== undefined && !ingress)
31
32
  throw new Error('Invalid daemon ingress: use /synopkgland/<package>/ with the exact package ID');
32
- const gatewayIngress = readDaemonIngress(gateway?.ingress, raw.package, () => { });
33
+ const gatewayIngress = gateway?.ingress && !gatewayIngressPathProblem(raw.package, gateway.ingress.path) ? gateway.ingress : undefined;
33
34
  if (gateway?.ingress !== undefined && !gatewayIngress)
34
35
  throw new Error("Invalid gateway ingress namespace");
35
36
  const derived = ingress?.path ?? gatewayIngress?.path ?? (gateway
@@ -1,7 +1,7 @@
1
1
  export { goPrivateCovers } from './go-env.js';
2
2
  import { type ExecutorManifest } from './sdk-executor-manifest.js';
3
3
  /** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
4
- export declare const DEFAULT_SDK_VERSION = "0.43.0";
4
+ export declare const DEFAULT_SDK_VERSION = "0.44.0";
5
5
  export declare const SDK_PACKAGE = "@synopackageland/sdk";
6
6
  export declare const SDK_MODULE = "github.com/synopackageland/syno-pkg-land-sdk";
7
7
  export declare const EXECUTOR_MODULE = "github.com/synopackageland/syno-pkg-land-sdk/executor";
@@ -5,7 +5,7 @@ import { tmpdir } from 'node:os';
5
5
  import { join } from 'node:path';
6
6
  import { readExecutorManifest, predatesExecutorManifest } from './sdk-executor-manifest.js';
7
7
  /** Pinned SDK for CLI-owned controllers and Compose planning; App pins take precedence. */
8
- export const DEFAULT_SDK_VERSION = '0.43.0';
8
+ export const DEFAULT_SDK_VERSION = '0.44.0';
9
9
  export const SDK_PACKAGE = '@synopackageland/sdk';
10
10
  export const SDK_MODULE = 'github.com/synopackageland/syno-pkg-land-sdk';
11
11
  export const EXECUTOR_MODULE = `${SDK_MODULE}/executor`;
@@ -0,0 +1,4 @@
1
+ export declare const RESERVED_GATEWAY_PREFIXES: string[];
2
+ /** The package namespace remains case sensitive; custom segments are URL-safe lowercase. */
3
+ export declare function gatewayIngressPathProblem(pkg: string | undefined, path: unknown): string | undefined;
4
+ export declare function gatewayIngressOwnershipSupported(sdk: string): boolean;
@@ -0,0 +1,21 @@
1
+ import { RESERVED_PORTAL_ALIASES } from '../portal/alias.js';
2
+ export const RESERVED_GATEWAY_PREFIXES = [...RESERVED_PORTAL_ALIASES, 'synopkgland'];
3
+ /** The package namespace remains case sensitive; custom segments are URL-safe lowercase. */
4
+ export function gatewayIngressPathProblem(pkg, path) {
5
+ if (typeof path !== 'string')
6
+ return 'ingress.path must be a string';
7
+ if (pkg && path === `/synopkgland/${pkg}/`)
8
+ return undefined;
9
+ if (!pkg && /^\/synopkgland\/[A-Za-z][A-Za-z0-9]{1,63}\/$/.test(path))
10
+ return undefined;
11
+ if (path.length > 255 || !/^\/(?:[a-z0-9]+(?:-[a-z0-9]+)*\/)+$/.test(path)
12
+ || path.split('/').some(segment => segment.length > 64))
13
+ return 'Use /synopkgland/<exact-package-ID>/ or a lowercase path such as /my-app/ or /my-app/ui/ with leading and trailing slashes; / is unsupported';
14
+ if (RESERVED_GATEWAY_PREFIXES.includes(path.split('/')[1]))
15
+ return 'This ingress path is reserved by DSM; use /synopkgland/<exact-package-ID>/ or an unreserved custom path';
16
+ return undefined;
17
+ }
18
+ export function gatewayIngressOwnershipSupported(sdk) {
19
+ const [major, minor] = sdk.split('.').map(Number);
20
+ return major > 0 || minor >= 44;
21
+ }
@@ -1,3 +1,4 @@
1
+ import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
1
2
  import { nativeGatewaySupported } from './native-gateway.js';
2
3
  import { createHash } from 'node:crypto';
3
4
  import { operationBudgetSeconds, runtimeBudgetSdkSupported } from "../runtime/runtime-budgets.js";
@@ -243,8 +244,8 @@ export function readIdentityGateway(value, daemon, fail, packagedPayload = false
243
244
  if (!port(v.upstream))
244
245
  return invalid("upstream must be the App's loopback port.");
245
246
  const ingress = v.ingress;
246
- if (ingress !== undefined && (!record(ingress) || !only(ingress, ["path"]) || typeof ingress.path !== "string" || !/^\/synopkgland\/[A-Za-z][A-Za-z0-9]{1,63}\/$/.test(ingress.path)))
247
- return invalid("ingress.path must be exactly /synopkgland/<package>/.");
247
+ if (ingress !== undefined && (!record(ingress) || !only(ingress, ["path"]) || typeof ingress.path !== "string" || gatewayIngressPathProblem(undefined, ingress.path) !== undefined))
248
+ return invalid(gatewayIngressPathProblem(undefined, record(ingress) ? ingress.path : undefined) ?? "ingress accepts only {path: /my-app/}.");
248
249
  if (ingress !== undefined && v.listen !== undefined && !(packagedPayload && record(v.listen) && Object.keys(v.listen).length === 0))
249
250
  return invalid("ingress replaces listen; remove the public gateway ports.");
250
251
  const listen = ingress !== undefined ? {} : v.listen;
@@ -598,8 +599,10 @@ export async function buildIdentityGateway(m, arch, work, run) {
598
599
  }
599
600
  if (m.identityGateway.ingress) {
600
601
  const capability = join(sdk.goDir, "idgateway/path_ingress.go");
601
- if (!existsSync(capability) || !/const PathIngressVersion = 1\b/.test(readFileSync(capability, "utf8")))
602
+ if (!existsSync(capability) || !/const PathIngressVersion = [12]\b/.test(readFileSync(capability, "utf8")))
602
603
  throw new StandaloneBuildError("STANDALONE_IDENTITY_GATEWAY_INVALID", "The selected SDK lacks DSM path ingress; use a matching SDK release or an explicit development source override.");
604
+ if (gatewayIngressOwnershipSupported(m.identityGateway.sdk) && !/const PathIngressVersion = 2\b/.test(readFileSync(capability, "utf8")))
605
+ throw new StandaloneBuildError("STANDALONE_IDENTITY_GATEWAY_INVALID", "Custom ingress ownership checks require SDK 0.44.0 or later; update identity_gateway.sdk.");
603
606
  }
604
607
  const out = join(work, `identity-gateway-${arch}`);
605
608
  const policyFlag = upstreamAuthSdkSupported(sdk.goDir)
@@ -1,3 +1,5 @@
1
+ import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
2
+ import { renderGatewayIngressCheck } from './native-gateway.js';
1
3
  import { portDefaults, portInstallSteps } from "./install-ports.js";
2
4
  import { inspectPackageDependencies, dependencyInfo } from "./package-dependencies.js";
3
5
  import { readInstallSettings, settingsInstallSteps, settingsConfig, renderSettingsHook } from './install-settings.js';
@@ -1261,13 +1263,13 @@ async function recoverNativeGateway(dir, value, info, findings) {
1261
1263
  || Object.entries(plan.listen).some(([k, v]) => !['http', 'https'].includes(k) || !Number.isInteger(v) || v < 1 || v > 65535))
1262
1264
  throw new Error('invalid native gateway ports');
1263
1265
  const target = { package: info.package, os_min_ver: info.os_min_ver, identityGateway: plan };
1264
- if (plan.ingress && (plan.ingress.path !== `/synopkgland/${info.package}/` || Object.keys(plan.ingress).some(k => k !== 'path') || Object.keys(plan.listen).length))
1266
+ if (plan.ingress && (gatewayIngressPathProblem(info.package, plan.ingress.path) !== undefined || Object.keys(plan.ingress).some(k => k !== 'path') || Object.keys(plan.listen).length))
1265
1267
  throw new Error('invalid gateway ingress namespace');
1266
1268
  if (!nativeGatewaySupported(target))
1267
1269
  throw new Error('unsupported native gateway SDK/DSM floor');
1268
1270
  const root = join(dir, 'native-gateway-inspection');
1269
1271
  mkdirSync(root);
1270
- await tar.x({ file: join(dir, 'package.tgz'), cwd: root, filter: path => ['sso/gateway.json', NATIVE_GATEWAY_CONFIG].includes(path.replace(/^\.\//, '')) });
1272
+ await tar.x({ file: join(dir, 'package.tgz'), cwd: root, filter: path => ['sso/gateway.json', 'ui/sso/open.cgi', NATIVE_GATEWAY_CONFIG].includes(path.replace(/^\.\//, '')) });
1271
1273
  const config = JSON.parse(readFileSync(join(root, 'sso/gateway.json'), 'utf8'));
1272
1274
  if (config.native_ingress !== true || config.package !== info.package || !isDeepStrictEqual(config.listen, plan.listen) || config.ingress_path !== plan.ingress?.path
1273
1275
  || config.state_dir !== `/var/packages/${info.package}/var/sso`)
@@ -1280,6 +1282,14 @@ async function recoverNativeGateway(dir, value, info, findings) {
1280
1282
  for (const hook of ['postinst', 'postupgrade'])
1281
1283
  if (!readFileSync(join(dir, 'scripts', hook), 'utf8').includes(renderNativeGatewayPrepare(target)))
1282
1284
  throw new Error('native gateway credential preparation is missing');
1285
+ if (plan.ingress && gatewayIngressOwnershipSupported(plan.sdk)) {
1286
+ const checker = join(dir, 'scripts/ingress-check');
1287
+ if (!readFileSync(checker).equals(readFileSync(join(root, 'ui/sso/open.cgi'))))
1288
+ throw new Error('ingress ownership checker differs from the gateway');
1289
+ for (const hook of ['preinst', 'preupgrade', 'postinst', 'postupgrade'])
1290
+ if (!readFileSync(join(dir, 'scripts', hook), 'utf8').includes(renderGatewayIngressCheck(target, hook)))
1291
+ throw new Error('ingress ownership check is missing');
1292
+ }
1283
1293
  return plan;
1284
1294
  }
1285
1295
  catch (e) {
@@ -1,3 +1,4 @@
1
+ import { renderGatewayIngressCheck } from './native-gateway.js';
1
2
  import { renderSettingsHook } from './install-settings.js';
2
3
  import { renderComposeRetainedData } from "../build-spk/compose-retained-data.js";
3
4
  import { renderNativeGatewayDiagnostic, renderNativeGatewayPortWait, renderNativeGatewayPrepare } from './native-gateway.js';
@@ -23,7 +24,7 @@ export function renderStandaloneScript(name, manifest) {
23
24
  }
24
25
  function renderStandaloneScriptPrefix(name, manifest) {
25
26
  const prepared = ['postinst', 'postupgrade'].includes(name) ? renderNativeGatewayPrepare(manifest) : '';
26
- return renderNativeGatewayDiagnostic(manifest, name) + renderNativeGatewayPortWait(manifest, name) + renderSettingsHook(name, manifest) + prepared;
27
+ return renderGatewayIngressCheck(manifest, name) + renderNativeGatewayDiagnostic(manifest, name) + renderNativeGatewayPortWait(manifest, name) + renderSettingsHook(name, manifest) + prepared;
27
28
  }
28
29
  /** Settings inspection peels its hook only at the position build's renderer writes.
29
30
  * The backend inspector then replays the entire remaining lifecycle script. */
@@ -1,3 +1,4 @@
1
+ import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
1
2
  import { nativeGatewaySdk } from "./native-gateway.js";
2
3
  import { portDefaults } from "./install-ports.js";
3
4
  import { readPackageDependencies, packageDependencies, dependencyError } from "./package-dependencies.js";
@@ -315,8 +316,11 @@ function readManifest(raw, c) {
315
316
  if (identityGateway?.ingress) {
316
317
  if (!nativeGatewaySdk(identityGateway.sdk))
317
318
  c.fail("STANDALONE_IDENTITY_GATEWAY_INVALID", "Path ingress requires an SDK with native gateway support.");
318
- if (identityGateway.ingress.path !== `/synopkgland/${raw.package}/`)
319
- c.fail('STANDALONE_IDENTITY_GATEWAY_INVALID', 'identity_gateway.ingress.path must use the exact manifest package ID.');
319
+ const problem = gatewayIngressPathProblem(raw.package, identityGateway.ingress.path);
320
+ if (problem)
321
+ c.fail('STANDALONE_IDENTITY_GATEWAY_INVALID', problem);
322
+ if (identityGateway.ingress.path !== `/synopkgland/${raw.package}/` && !gatewayIngressOwnershipSupported(identityGateway.sdk))
323
+ c.fail('STANDALONE_IDENTITY_GATEWAY_INVALID', 'Custom ingress requires SDK 0.44.0 or later; update identity_gateway.sdk.');
320
324
  if (daemonIngressMinDsmProblem(typeof raw.os_min_ver === "string" ? raw.os_min_ver : undefined))
321
325
  c.fail('STANDALONE_IDENTITY_GATEWAY_INVALID', 'identity_gateway.ingress requires DSM 7.2-64570 or later.');
322
326
  if (installPorts && !identityGateway.oidc)
@@ -19,4 +19,6 @@ export declare function nativeGatewayResource(m: Target): Record<string, unknown
19
19
  export declare function renderNativeGatewayConfig(m: Target): string;
20
20
  /** Runs after DSM creates pkgvar, before package start activates the nginx resource. */
21
21
  export declare function renderNativeGatewayPrepare(m: Target): string;
22
+ /** Check the incoming declaration before DSM activates its package-owned resource. */
23
+ export declare function renderGatewayIngressCheck(m: Target, hook: string): string;
22
24
  export {};
@@ -1,3 +1,4 @@
1
+ import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
1
2
  import { isDsmAtLeast, PORTAL_MIN_DSM } from '../build-spk/dsm-version.js';
2
3
  export const NATIVE_GATEWAY_CONFIG = 'sso/native-nginx.conf';
3
4
  // Earlier SDK releases do not understand native_ingress. Keep their JSON ABI
@@ -142,8 +143,11 @@ export function renderNativeGatewayConfig(m) {
142
143
  proxy_read_timeout 3600s;
143
144
  `;
144
145
  if (g.ingress) {
145
- if (g.ingress.path !== `/synopkgland/${m.package}/`)
146
- throw new Error('Invalid gateway ingress namespace');
146
+ const problem = gatewayIngressPathProblem(m.package, g.ingress.path);
147
+ if (problem)
148
+ throw new Error(problem);
149
+ if (g.ingress.path !== `/synopkgland/${m.package}/` && !gatewayIngressOwnershipSupported(g.sdk))
150
+ throw new Error("Custom ingress requires SDK 0.44.0 or later");
147
151
  return `location = ${g.ingress.path.slice(0, -1)} { return 308 ${g.ingress.path}$is_args$args; }\nlocation ^~ ${g.ingress.path} {\n client_max_body_size 0;\n${proxy} proxy_set_header X-Synopkgland-Scheme $scheme;\n}\n`;
148
152
  }
149
153
  return `server {
@@ -239,3 +243,17 @@ function managedPortHook(m, hook, wait) {
239
243
  synopkgland_managed_port_${wait ? 'wait' : 'diagnostic'} "$@" >/dev/null 2>&1 || :
240
244
  `;
241
245
  }
246
+ /** Check the incoming declaration before DSM activates its package-owned resource. */
247
+ export function renderGatewayIngressCheck(m, hook) {
248
+ const g = m.identityGateway;
249
+ if (!g?.ingress || !gatewayIngressOwnershipSupported(g.sdk) || !['preinst', 'preupgrade', 'postinst', 'postupgrade'].includes(hook))
250
+ return '';
251
+ if (gatewayIngressPathProblem(m.package, g.ingress.path) || !/^[A-Za-z][A-Za-z0-9]{1,63}$/.test(m.package))
252
+ throw new Error('Invalid gateway ingress declaration');
253
+ return `synopkgland_ingress_error=$("$(dirname "$0")/ingress-check" ingress-check '${m.package}' '${g.ingress.path}' 2>&1) || {
254
+ printf '%s\\n' "$synopkgland_ingress_error" >&2
255
+ if [ -n "\${SYNOPKG_TEMP_LOGFILE:-}" ]; then printf '%s\\n' "$synopkgland_ingress_error" > "$SYNOPKG_TEMP_LOGFILE"; fi
256
+ exit 1
257
+ }
258
+ `;
259
+ }
@@ -1,3 +1,4 @@
1
+ import { gatewayIngressOwnershipSupported } from './gateway-ingress.js';
1
2
  import { portDefaults, portInstallSteps, writePortPayload } from "./install-ports.js";
2
3
  import { packageDependencies, dependencyInfo } from "./package-dependencies.js";
3
4
  import { settingsInstallSteps, settingsConfig } from './install-settings.js';
@@ -303,6 +304,10 @@ export async function assembleStandaloneSpk(options) {
303
304
  writeFile(join(staging, BACKGROUND_UNIT_DIR, backgroundUnitName(manifest.package)), renderBackgroundUnit(manifest.package, isBridgeBackend(manifest.backend) ? BRIDGE_WORKER_ARGS : [], manifest.daemon?.timeouts.stop ?? manifest.lifecycleTimeouts?.stop ?? 30));
304
305
  }
305
306
  mkdirSync(join(staging, "scripts"));
307
+ if (manifest.identityGateway?.ingress && gatewayIngressOwnershipSupported(manifest.identityGateway.sdk)) {
308
+ copyFileSync(options.identityGateway, join(staging, 'scripts/ingress-check'));
309
+ chmodSync(join(staging, 'scripts/ingress-check'), EXEC_MODE);
310
+ }
306
311
  for (const name of LIFECYCLE_SCRIPTS) {
307
312
  writeFile(join(staging, "scripts", name), renderStandaloneScript(name, manifest), EXEC_MODE);
308
313
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.43.0",
3
+ "version": "0.44.0",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
package/skills/SKILL.md CHANGED
@@ -5,7 +5,7 @@ description: Initialize, extend, check, build, inspect, and deploy Synology appl
5
5
 
6
6
  # Independent Synology SPKs
7
7
 
8
- The CLI installs templates through `~0.37.0`. A templates patch needs only a
8
+ The CLI installs templates through `~0.38.0`. A templates patch needs only a
9
9
  templates release; npm install/update selects a patch in that minor line. The CLI
10
10
  uses the locally installed templates and reads their SDK pin for defaults; it
11
11
  never downloads templates at runtime. Preserve the lockfile and use `npm ci` for
@@ -328,3 +328,9 @@ entry policy when running the smoke.
328
328
  Override `app` for a manifest filename or `entry` for a configured URL.
329
329
  Only a manifest-declared upstream-authenticated entry may use `publicLogin`.
330
330
  Keep `.env` and `.e2e/` untracked; never add NAS details to source.
331
+
332
+ For DSM same-origin gateway URLs, keep the default `/synopkgland/<package>/`.
333
+ SDK/CLI 0.44.0 adds opt-in `identity_gateway.ingress: {path: /my-app/}` for
334
+ upstreams with a hardcoded base path. Read [reference/identity-gateway.md](reference/identity-gateway.md)
335
+ for reserved paths, install-time ownership checks and unchanged auth policy.
336
+ Apps requiring `/` cannot use ingress.
@@ -294,3 +294,21 @@ fragment/query semantics still require deployment acceptance.
294
294
  Single-origin Apps require SDK 0.30.0 or later. Their `manual_origin` may include an explicit HTTPS port (for example, `https://example.ts.net:29443`). The DSM launcher resolves the destination for the provider used to open DSM, probes `/_spl/ping` for up to eight seconds, and offers **Open anyway** if the probe fails. A single-origin App always uses its configured primary origin. Other Apps and the `external-origin` install setting continue to require HTTPS DNS origins on port 443.
295
295
 
296
296
  Configurable gateway ports use `install.ports: true`; read [install.md](install.md) for field validation, retained selections and upstream runtime bindings. Do not repeat the manifest defaults in App configuration.
297
+
298
+ ## DSM same-origin path ingress
299
+
300
+ Keep `/synopkgland/<exact-package-ID>/` as the default. With SDK/CLI 0.44.0 or
301
+ later, an upstream with a fixed base path may opt in to
302
+ `identity_gateway.ingress: {path: /my-app/}` (nested lowercase segments also work).
303
+ Use leading/trailing slashes, lowercase letters/digits/internal hyphens, at most
304
+ 64 characters per segment and 255 total. Root `/`, DSM/native prefixes and other
305
+ packages' namespaces are refused. Apps requiring `/` cannot use ingress.
306
+ Replace `listen`; preserve entry, access, OIDC/header/none/token mode, API/share
307
+ exceptions, WebSocket and App privileges. Paths in gateway policy stay relative
308
+ to the selected base; the upstream receives the full URL path.
309
+
310
+ `check` reports syntax/reserved-prefix errors with a fix. Installation checks
311
+ NAS route ownership, including saved aliases and stopped SDK packages, and fails
312
+ closed if inventory cannot be checked. DSM owns registration, upgrade replacement
313
+ and uninstall cleanup; never overwrite or remove another owner's config. The
314
+ menu CGI URL remains stable. See [path ingress](https://github.com/synopackageland/syno-pkg-land-cli/blob/main/docs/path-ingress.md).