@synopackageland/cli 0.42.2 → 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 +13 -0
- package/README.md +2 -0
- package/dist/e2e/app-open.js +7 -2
- package/dist/error-registry.js +1 -1
- package/dist/runtime/sdk-source.d.ts +1 -1
- package/dist/runtime/sdk-source.js +1 -1
- package/dist/standalone/gateway-ingress.d.ts +4 -0
- package/dist/standalone/gateway-ingress.js +21 -0
- package/dist/standalone/identity-gateway.d.ts +3 -0
- package/dist/standalone/identity-gateway.js +18 -2
- package/dist/standalone/inspect-spk.js +16 -4
- package/dist/standalone/install-ports.js +1 -1
- package/dist/standalone/lifecycle.js +2 -1
- package/dist/standalone/manifest.js +18 -1
- package/dist/standalone/native-gateway.d.ts +3 -1
- package/dist/standalone/native-gateway.js +35 -9
- package/dist/standalone/spk.js +6 -1
- package/package.json +2 -2
- package/skills/SKILL.md +7 -1
- package/skills/reference/identity-gateway.md +18 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
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
|
+
|
|
10
|
+
## 0.43.0 (2026-11-02)
|
|
11
|
+
|
|
12
|
+
- Add identity_gateway.ingress for fixed DSM package paths without a public gateway port.
|
|
13
|
+
- Validate and inspect the exact package namespace, require matching SDK path support, and derive the same path for browser smoke checks.
|
|
14
|
+
- Pin SDK 0.43.0 and templates ~0.38.0; existing dedicated-port manifests retain their behavior.
|
|
15
|
+
|
|
3
16
|
## 0.42.2 (2026-11-01)
|
|
4
17
|
|
|
5
18
|
- Pin SDK 0.42.0 for CLI-owned runtime defaults (daemon controllers, Compose
|
package/README.md
CHANGED
|
@@ -627,3 +627,5 @@ nonroot package process with no-new-privileges has zero effective, permitted and
|
|
|
627
627
|
ambient capabilities on the tested provider. This general platform behavior is
|
|
628
628
|
not a GPU blocker. Plan metadata describes SDK policy, not an attestation of the
|
|
629
629
|
provider's final container configuration; see the SDK Compose security boundary.
|
|
630
|
+
|
|
631
|
+
For same-origin App URLs, see [DSM path ingress](docs/path-ingress.md).
|
package/dist/e2e/app-open.js
CHANGED
|
@@ -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,10 @@ 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
|
|
33
|
+
const gatewayIngress = gateway?.ingress && !gatewayIngressPathProblem(raw.package, gateway.ingress.path) ? gateway.ingress : undefined;
|
|
34
|
+
if (gateway?.ingress !== undefined && !gatewayIngress)
|
|
35
|
+
throw new Error("Invalid gateway ingress namespace");
|
|
36
|
+
const derived = ingress?.path ?? gatewayIngress?.path ?? (gateway
|
|
33
37
|
? `/webman/3rdparty/${raw.package}/sso/open.cgi`
|
|
34
38
|
: native ? `/?launchApp=${encodeURIComponent(appId)}`
|
|
35
39
|
: trustedAppEntryPath(raw));
|
|
@@ -39,7 +43,8 @@ export function deriveSmokeEntry(raw, entry) {
|
|
|
39
43
|
const menuEntry = `/webman/3rdparty/${raw.package}/sso/open.cgi`;
|
|
40
44
|
const upstreamAuthenticated = (gateway?.upstream_access === 'public' && pathname !== menuEntry) ||
|
|
41
45
|
(!native && raw.integration?.web?.access === 'public') ||
|
|
42
|
-
(gateway?.upstream_auth_paths ?? []).some((prefix) => pathname ===
|
|
46
|
+
(gateway?.upstream_auth_paths ?? []).some((prefix) => pathname === (gatewayIngress ? gatewayIngress.path.slice(0, -1) + prefix : prefix) ||
|
|
47
|
+
pathname.startsWith((gatewayIngress ? gatewayIngress.path.slice(0, -1) + prefix : prefix).replace(/\/$/, '') + '/'));
|
|
43
48
|
return { package: raw.package, appId, entry: selected, window: entry ? false : window, upstreamAuthenticated,
|
|
44
49
|
normalExpectation: raw.entry === 'admin-only' ? 'denied' : 'ready' };
|
|
45
50
|
}
|
package/dist/error-registry.js
CHANGED
|
@@ -406,7 +406,7 @@ export const ERROR_REGISTRY = {
|
|
|
406
406
|
STANDALONE_IDENTITY_GATEWAY_INVALID: {
|
|
407
407
|
code: "STANDALONE_IDENTITY_GATEWAY_INVALID",
|
|
408
408
|
description: "The identity_gateway declaration does not match the gateway contract.",
|
|
409
|
-
suggestion: "Declare a daemon; set sdk, mode (oidc, header or token),
|
|
409
|
+
suggestion: "Declare a daemon or Compose web service; set sdk, mode (none, oidc, header or token), and either ingress.path at /synopkgland/<package>/ or distinct public listen ports; keep passthrough and redirects local paths outside /_sso; oidc needs issuer_port and clients, header needs headers.user, token needs token.exec in the daemon payload.",
|
|
410
410
|
},
|
|
411
411
|
STANDALONE_IDENTITY_GATEWAY_EXTERNAL_INVALID: {
|
|
412
412
|
code: "STANDALONE_IDENTITY_GATEWAY_EXTERNAL_INVALID",
|
|
@@ -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.
|
|
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.
|
|
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
|
+
}
|
|
@@ -51,6 +51,9 @@ export interface IdentityGateway {
|
|
|
51
51
|
mode: GatewayMode;
|
|
52
52
|
/** Fixed same-origin menu target, including optional query and fragment. */
|
|
53
53
|
launch_path?: string;
|
|
54
|
+
ingress?: {
|
|
55
|
+
path: string;
|
|
56
|
+
};
|
|
54
57
|
access?: WebAccessMode;
|
|
55
58
|
/** Public App routes keep upstream authentication; access still protects OIDC issuance. */
|
|
56
59
|
upstream_access?: "protected" | "public";
|
|
@@ -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";
|
|
@@ -157,6 +158,7 @@ export function readIdentityGateway(value, daemon, fail, packagedPayload = false
|
|
|
157
158
|
"access",
|
|
158
159
|
"upstream_access",
|
|
159
160
|
"launch_path",
|
|
161
|
+
"ingress",
|
|
160
162
|
"groups",
|
|
161
163
|
"max_upload_bytes",
|
|
162
164
|
"response_header_timeout_seconds",
|
|
@@ -241,10 +243,15 @@ export function readIdentityGateway(value, daemon, fail, packagedPayload = false
|
|
|
241
243
|
return invalid("mode must be none, oidc, header or token.");
|
|
242
244
|
if (!port(v.upstream))
|
|
243
245
|
return invalid("upstream must be the App's loopback port.");
|
|
244
|
-
const
|
|
246
|
+
const ingress = v.ingress;
|
|
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/}.");
|
|
249
|
+
if (ingress !== undefined && v.listen !== undefined && !(packagedPayload && record(v.listen) && Object.keys(v.listen).length === 0))
|
|
250
|
+
return invalid("ingress replaces listen; remove the public gateway ports.");
|
|
251
|
+
const listen = ingress !== undefined ? {} : v.listen;
|
|
245
252
|
if (!record(listen) ||
|
|
246
253
|
!only(listen, ["http", "https"]) ||
|
|
247
|
-
(listen.http === undefined && listen.https === undefined) ||
|
|
254
|
+
(ingress === undefined && listen.http === undefined && listen.https === undefined) ||
|
|
248
255
|
![listen.http, listen.https].every((p) => p === undefined || port(p)))
|
|
249
256
|
return invalid("listen needs an http and/or https port.");
|
|
250
257
|
const issuer = record(v.oidc) ? v.oidc.issuer_port : undefined;
|
|
@@ -330,6 +337,7 @@ export function readIdentityGateway(value, daemon, fail, packagedPayload = false
|
|
|
330
337
|
sdk: v.sdk,
|
|
331
338
|
...(externalAccess ? { external_access: externalAccess } : {}),
|
|
332
339
|
mode: v.mode,
|
|
340
|
+
...(ingress ? { ingress: ingress } : {}),
|
|
333
341
|
...(v.launch_path !== undefined ? { launch_path: v.launch_path } : {}),
|
|
334
342
|
access,
|
|
335
343
|
...(v.upstream_access !== undefined ? { upstream_access: v.upstream_access } : {}),
|
|
@@ -475,6 +483,7 @@ export function identityGatewayConfig(m) {
|
|
|
475
483
|
package: m.package,
|
|
476
484
|
...(gatewayExternalAccess(g) ? { external: gatewayExternalAccess(g) } : {}),
|
|
477
485
|
...(nativeGatewaySupported(m) ? { native_ingress: true } : {}),
|
|
486
|
+
...(g.ingress ? { ingress_path: g.ingress.path } : {}),
|
|
478
487
|
...(runtimeBudgetSdkSupported(g.sdk) ? {
|
|
479
488
|
operation_seconds: operationBudgetSeconds(m),
|
|
480
489
|
stop_seconds: m.daemon?.timeouts.stop ?? m.lifecycleTimeouts?.stop ?? 30,
|
|
@@ -588,6 +597,13 @@ export async function buildIdentityGateway(m, arch, work, run) {
|
|
|
588
597
|
if (!existsSync(capability) || !/const LauncherPathVersion = 1\b/.test(readFileSync(capability, "utf8")))
|
|
589
598
|
throw new StandaloneBuildError("STANDALONE_IDENTITY_GATEWAY_INVALID", "The selected SDK lacks fixed launch_path support; use a matching SDK release or an explicit development source override.");
|
|
590
599
|
}
|
|
600
|
+
if (m.identityGateway.ingress) {
|
|
601
|
+
const capability = join(sdk.goDir, "idgateway/path_ingress.go");
|
|
602
|
+
if (!existsSync(capability) || !/const PathIngressVersion = [12]\b/.test(readFileSync(capability, "utf8")))
|
|
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.");
|
|
606
|
+
}
|
|
591
607
|
const out = join(work, `identity-gateway-${arch}`);
|
|
592
608
|
const policyFlag = upstreamAuthSdkSupported(sdk.goDir)
|
|
593
609
|
? ` -X github.com/synopackageland/syno-pkg-land-sdk/idgateway.expectedEntryPolicyDigest=${gatewayEntryPolicyDigest(JSON.parse(identityGatewayConfig(m)))}`
|
|
@@ -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';
|
|
@@ -1257,17 +1259,19 @@ async function recoverNativeGateway(dir, value, info, findings) {
|
|
|
1257
1259
|
throw new Error('invalid native gateway record');
|
|
1258
1260
|
const plan = value;
|
|
1259
1261
|
if (typeof plan.sdk !== 'string' || !plan.listen || typeof plan.listen !== 'object' || Array.isArray(plan.listen)
|
|
1260
|
-
|| !Object.keys(plan.listen).length || Object.keys(plan).some(k => !['sdk', 'listen'].includes(k))
|
|
1262
|
+
|| !plan.ingress && !Object.keys(plan.listen).length || Object.keys(plan).some(k => !['sdk', 'listen', 'ingress'].includes(k))
|
|
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 };
|
|
1266
|
+
if (plan.ingress && (gatewayIngressPathProblem(info.package, plan.ingress.path) !== undefined || Object.keys(plan.ingress).some(k => k !== 'path') || Object.keys(plan.listen).length))
|
|
1267
|
+
throw new Error('invalid gateway ingress namespace');
|
|
1264
1268
|
if (!nativeGatewaySupported(target))
|
|
1265
1269
|
throw new Error('unsupported native gateway SDK/DSM floor');
|
|
1266
1270
|
const root = join(dir, 'native-gateway-inspection');
|
|
1267
1271
|
mkdirSync(root);
|
|
1268
|
-
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(/^\.\//, '')) });
|
|
1269
1273
|
const config = JSON.parse(readFileSync(join(root, 'sso/gateway.json'), 'utf8'));
|
|
1270
|
-
if (config.native_ingress !== true || config.package !== info.package || !isDeepStrictEqual(config.listen, plan.listen)
|
|
1274
|
+
if (config.native_ingress !== true || config.package !== info.package || !isDeepStrictEqual(config.listen, plan.listen) || config.ingress_path !== plan.ingress?.path
|
|
1271
1275
|
|| config.state_dir !== `/var/packages/${info.package}/var/sso`)
|
|
1272
1276
|
throw new Error('native gateway config does not match its package');
|
|
1273
1277
|
if (readOptional(join(root, NATIVE_GATEWAY_CONFIG)) !== renderNativeGatewayConfig(target))
|
|
@@ -1278,6 +1282,14 @@ async function recoverNativeGateway(dir, value, info, findings) {
|
|
|
1278
1282
|
for (const hook of ['postinst', 'postupgrade'])
|
|
1279
1283
|
if (!readFileSync(join(dir, 'scripts', hook), 'utf8').includes(renderNativeGatewayPrepare(target)))
|
|
1280
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
|
+
}
|
|
1281
1293
|
return plan;
|
|
1282
1294
|
}
|
|
1283
1295
|
catch (e) {
|
|
@@ -1523,7 +1535,7 @@ async function inspectInstallSettings(dir, payload, metadata, findings) {
|
|
|
1523
1535
|
if (ports) {
|
|
1524
1536
|
const config = JSON.parse(readFileSync(join(root, 'install/ports.json'), 'utf8'));
|
|
1525
1537
|
const actualGateway = JSON.parse(readFileSync(join(root, 'sso/gateway.json'), 'utf8'));
|
|
1526
|
-
const expected = portDefaults({ ...m, identityGateway: { ...actualGateway, sdk: gateway.sdk } });
|
|
1538
|
+
const expected = portDefaults({ ...m, identityGateway: { ...actualGateway, sdk: gateway.sdk, ...(actualGateway.ingress_path ? { ingress: { path: actualGateway.ingress_path } } : {}) } });
|
|
1527
1539
|
if (config.schema !== 1 || config.package !== info.package || !isDeepStrictEqual(config.ports, ports) || !isDeepStrictEqual(ports, expected))
|
|
1528
1540
|
throw new Error('port defaults differ from gateway listeners');
|
|
1529
1541
|
const required = ['sso/gateway.json', 'daemon/config.json', ...(actualGateway.native_ingress ? ['sso/native-nginx.conf'] : []), ...(settings ? ['install/settings.json'] : []), ...payload.filter(p => /^ui\/window-[0-9]+\.js$/.test(p.path)).map(p => p.path)].sort();
|
|
@@ -5,7 +5,7 @@ export function portDefaults(m) {
|
|
|
5
5
|
return {};
|
|
6
6
|
const g = m.identityGateway;
|
|
7
7
|
return Object.fromEntries([
|
|
8
|
-
...Object.entries(g.listen ?? {}).map(([key, value]) => ['gateway_' + key, { default: value, protocol: 'tcp' }]),
|
|
8
|
+
...Object.entries(g.ingress ? {} : g.listen ?? {}).map(([key, value]) => ['gateway_' + key, { default: value, protocol: 'tcp' }]),
|
|
9
9
|
...(g.oidc ? [['oidc_issuer', { default: g.oidc.issuer_port, protocol: 'tcp' }]] : []),
|
|
10
10
|
]);
|
|
11
11
|
}
|
|
@@ -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,5 @@
|
|
|
1
|
+
import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
2
|
+
import { nativeGatewaySdk } from "./native-gateway.js";
|
|
1
3
|
import { portDefaults } from "./install-ports.js";
|
|
2
4
|
import { readPackageDependencies, packageDependencies, dependencyError } from "./package-dependencies.js";
|
|
3
5
|
import { readInstallSettings } from './install-settings.js';
|
|
@@ -300,7 +302,7 @@ function readManifest(raw, c) {
|
|
|
300
302
|
? {
|
|
301
303
|
sdk: compose.sdk,
|
|
302
304
|
mode: "none",
|
|
303
|
-
listen: { http: 28000 },
|
|
305
|
+
...(gatewayRaw.ingress === undefined ? { listen: { http: 28000 } } : {}),
|
|
304
306
|
...gatewayRaw,
|
|
305
307
|
upstream: compose.plan.ingress?.port ??
|
|
306
308
|
compose.web.host_port ??
|
|
@@ -311,6 +313,21 @@ function readManifest(raw, c) {
|
|
|
311
313
|
c.fail("COMPOSE_WEB_INVALID", "Compose upstream is derived from the SDK Compose ingress endpoint; remove identity_gateway.upstream.");
|
|
312
314
|
// A failed Compose plan already explains the invalid upstream declaration.
|
|
313
315
|
const identityGateway = raw.compose !== undefined && !compose ? undefined : readIdentityGateway(gatewayValue, daemon || (compose ? { targets: compose.targets } : undefined), (e) => c.fail(e.code, e.message), false, Boolean(compose?.plan.ingress));
|
|
316
|
+
if (identityGateway?.ingress) {
|
|
317
|
+
if (!nativeGatewaySdk(identityGateway.sdk))
|
|
318
|
+
c.fail("STANDALONE_IDENTITY_GATEWAY_INVALID", "Path ingress requires an SDK with native gateway support.");
|
|
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.');
|
|
324
|
+
if (daemonIngressMinDsmProblem(typeof raw.os_min_ver === "string" ? raw.os_min_ver : undefined))
|
|
325
|
+
c.fail('STANDALONE_IDENTITY_GATEWAY_INVALID', 'identity_gateway.ingress requires DSM 7.2-64570 or later.');
|
|
326
|
+
if (installPorts && !identityGateway.oidc)
|
|
327
|
+
c.fail('INSTALL_PORT_INVALID', 'Path ingress has no public gateway ports; remove install.ports.');
|
|
328
|
+
if (identityGateway.external_access?.single_origin)
|
|
329
|
+
c.fail('STANDALONE_IDENTITY_GATEWAY_INVALID', 'Path ingress uses the DSM origin and cannot combine with external_access.single_origin.');
|
|
330
|
+
}
|
|
314
331
|
if (installPorts && !identityGateway)
|
|
315
332
|
c.fail('INSTALL_PORT_INVALID', 'install.ports requires an identity gateway');
|
|
316
333
|
if (installPorts && identityGateway) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { IdentityGateway } from './identity-gateway.js';
|
|
2
|
-
export type NativeGatewayPlan = Pick<IdentityGateway, 'sdk' | 'listen'>;
|
|
2
|
+
export type NativeGatewayPlan = Pick<IdentityGateway, 'sdk' | 'listen' | 'ingress'>;
|
|
3
3
|
type Target = {
|
|
4
4
|
package: string;
|
|
5
5
|
os_min_ver?: string;
|
|
@@ -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
|
|
@@ -12,7 +13,7 @@ export function nativeGatewaySupported(m) {
|
|
|
12
13
|
}
|
|
13
14
|
/** Observe the boundary before DSM acquires web-config, without claiming port ownership. */
|
|
14
15
|
export function renderNativeGatewayDiagnostic(m, hook) {
|
|
15
|
-
if (!nativeGatewaySupported(m) || !['start-stop-status', 'postinst', 'postupgrade', 'preupgrade', 'preuninst'].includes(hook))
|
|
16
|
+
if (m.identityGateway?.ingress || !nativeGatewaySupported(m) || !['start-stop-status', 'postinst', 'postupgrade', 'preupgrade', 'preuninst'].includes(hook))
|
|
16
17
|
return '';
|
|
17
18
|
if (m.installPorts)
|
|
18
19
|
return managedPortHook(m, hook, false);
|
|
@@ -43,7 +44,7 @@ synopkgland_native_diagnostic "$@" >/dev/null 2>&1 || :
|
|
|
43
44
|
}
|
|
44
45
|
/** Give a retiring nginx listener a bounded window before DSM acquires web-config. */
|
|
45
46
|
export function renderNativeGatewayPortWait(m, hook) {
|
|
46
|
-
if (hook !== 'start-stop-status' || !nativeGatewaySupported(m))
|
|
47
|
+
if (m.identityGateway?.ingress || hook !== 'start-stop-status' || !nativeGatewaySupported(m))
|
|
47
48
|
return '';
|
|
48
49
|
if (m.installPorts)
|
|
49
50
|
return managedPortHook(m, hook, true);
|
|
@@ -109,6 +110,8 @@ export function legacyGatewayNotice() {
|
|
|
109
110
|
export function nativeGatewayResource(m) {
|
|
110
111
|
if (!nativeGatewaySupported(m))
|
|
111
112
|
return undefined;
|
|
113
|
+
if (m.identityGateway.ingress)
|
|
114
|
+
return { "nginx-static-config": { enable: [{ type: "dsm", relpath: NATIVE_GATEWAY_CONFIG }] } };
|
|
112
115
|
const g = m.identityGateway, https = g.listen.https ?? g.listen.http;
|
|
113
116
|
const ports = [https, ...(g.listen.http && g.listen.http !== https ? [g.listen.http] : [])];
|
|
114
117
|
return { 'nginx-static-config': { enable: [{ type: 'server', relpath: NATIVE_GATEWAY_CONFIG,
|
|
@@ -122,13 +125,7 @@ export function renderNativeGatewayConfig(m) {
|
|
|
122
125
|
// Public ssl_certificate is deliberately inherited from DSM's http context.
|
|
123
126
|
// Only nginx's master reads the package's private upstream key. No DSM key
|
|
124
127
|
// is read or copied by the package, and no secret appears in this config.
|
|
125
|
-
|
|
126
|
-
listen ${port} ssl;
|
|
127
|
-
listen [::]:${port} ssl;
|
|
128
|
-
server_name _;
|
|
129
|
-
client_max_body_size 0;
|
|
130
|
-
location / {
|
|
131
|
-
proxy_pass https://unix:/tmp/synopkgland-gateway-${m.package}.sock:;
|
|
128
|
+
const proxy = ` proxy_pass https://unix:/tmp/synopkgland-gateway-${m.package}.sock:;
|
|
132
129
|
proxy_http_version 1.1;
|
|
133
130
|
proxy_ssl_verify on;
|
|
134
131
|
proxy_ssl_verify_depth 1;
|
|
@@ -144,7 +141,22 @@ export function renderNativeGatewayConfig(m) {
|
|
|
144
141
|
proxy_request_buffering off;
|
|
145
142
|
proxy_buffering off;
|
|
146
143
|
proxy_read_timeout 3600s;
|
|
144
|
+
`;
|
|
145
|
+
if (g.ingress) {
|
|
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");
|
|
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`;
|
|
147
152
|
}
|
|
153
|
+
return `server {
|
|
154
|
+
listen ${port} ssl;
|
|
155
|
+
listen [::]:${port} ssl;
|
|
156
|
+
server_name _;
|
|
157
|
+
client_max_body_size 0;
|
|
158
|
+
location / {
|
|
159
|
+
${proxy} }
|
|
148
160
|
}
|
|
149
161
|
${g.listen.http && g.listen.http !== port ? `server {
|
|
150
162
|
listen ${g.listen.http};
|
|
@@ -231,3 +243,17 @@ function managedPortHook(m, hook, wait) {
|
|
|
231
243
|
synopkgland_managed_port_${wait ? 'wait' : 'diagnostic'} "$@" >/dev/null 2>&1 || :
|
|
232
244
|
`;
|
|
233
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
|
+
}
|
package/dist/standalone/spk.js
CHANGED
|
@@ -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';
|
|
@@ -268,7 +269,7 @@ export async function assembleStandaloneSpk(options) {
|
|
|
268
269
|
...(gatewayAdmissionPolicy(manifest.identityGateway, manifest.entry) ? { provider_only_oidc: gatewayAdmissionPolicy(manifest.identityGateway, manifest.entry) } : {}),
|
|
269
270
|
...(manifest.identityGateway && gatewayExternalAccess(manifest.identityGateway)
|
|
270
271
|
? { gateway_external: gatewayExternalAccess(manifest.identityGateway) } : {}),
|
|
271
|
-
...(nativeGatewaySupported(manifest) ? { native_gateway: { sdk: manifest.identityGateway.sdk, listen: manifest.identityGateway.listen } } : {}),
|
|
272
|
+
...(nativeGatewaySupported(manifest) ? { native_gateway: { sdk: manifest.identityGateway.sdk, listen: manifest.identityGateway.listen, ...(manifest.identityGateway.ingress ? { ingress: manifest.identityGateway.ingress } : {}) } } : {}),
|
|
272
273
|
...(manifest.daemon?.ingress ? { daemon_ingress: manifest.daemon.ingress } : {}),
|
|
273
274
|
...(manifest.daemon?.node ? { daemon_node: manifest.daemon.node } : {}),
|
|
274
275
|
...(manifest.daemon?.restart ? { daemon_restart: manifest.daemon.restart, daemon_sdk: daemonSdkVersion(manifest) } : {}),
|
|
@@ -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.
|
|
3
|
+
"version": "0.44.0",
|
|
4
4
|
"description": "Syno Package Land Developer Kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@napi-rs/keyring": "^2.1.1",
|
|
31
|
-
"@synopackageland/templates": "~0.
|
|
31
|
+
"@synopackageland/templates": "~0.38.0",
|
|
32
32
|
"ajv": "^8.17.1",
|
|
33
33
|
"commander": "^13.1.0",
|
|
34
34
|
"json-canonicalize": "^3.0.1",
|
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.
|
|
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).
|