@synopackageland/cli 0.50.1 → 0.52.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 +12 -0
- package/README.md +16 -0
- package/assets/go/route-audit/main.go +23 -6
- package/dist/build-spk/ui-texts.d.ts +3 -1
- package/dist/build-spk/ui-texts.js +17 -8
- package/dist/cli.js +9 -1
- package/dist/error-registry.js +16 -1
- package/dist/native-http-schema/source.json +1 -1
- package/dist/runtime/sdk-source.d.ts +1 -1
- package/dist/runtime/sdk-source.js +1 -1
- package/dist/skill.js +2 -0
- package/dist/standalone/api-description.js +2 -1
- package/dist/standalone/build.js +5 -2
- package/dist/standalone/dsm-texts.d.ts +17 -0
- package/dist/standalone/dsm-texts.js +102 -0
- package/dist/standalone/dsm-window.js +3 -0
- package/dist/standalone/inspect-spk.d.ts +5 -0
- package/dist/standalone/inspect-spk.js +36 -0
- package/dist/standalone/manifest.d.ts +5 -0
- package/dist/standalone/manifest.js +54 -21
- package/dist/standalone/route-audit.d.ts +1 -1
- package/dist/standalone/route-audit.js +2 -2
- package/dist/standalone/spk.js +1 -0
- package/dist/standalone/tcp-listeners.d.ts +11 -0
- package/dist/standalone/tcp-listeners.js +57 -0
- package/package.json +1 -1
- package/schema/dsm-api-contract.json +1 -1
- package/schema/dsm-package.schema.json +28 -1
- package/skills/SKILL.md +5 -0
- package/skills/reference/dsm-texts.md +95 -0
- package/skills/reference/raw-tcp.md +66 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.52.0
|
|
4
|
+
|
|
5
|
+
- Add declarative `tcp_listeners` for native Go protocols, validating listener IDs, bind scopes, port bounds, and SDK policy support
|
|
6
|
+
- Bind the normalized TCP policy into CGI and worker builds; reject undeclared or dynamic listener IDs and constructor aliases during route audit
|
|
7
|
+
- Show archived TCP listener declarations in `inspect` and add `synopkgland skill show raw-tcp`
|
|
8
|
+
- Pin CLI-owned SDK defaults to 0.53.0; preserve declarative DSM text sections and their inspection and skill guidance
|
|
9
|
+
|
|
10
|
+
## 0.51.0
|
|
11
|
+
|
|
12
|
+
- Add declarative `i18n.dsm_texts`: per-locale DSM strings files become native DSM text sections (for example `[notify]`) in the package, validated against English with matching keys and placeholders; `[synopkgland]` stays reserved
|
|
13
|
+
- Show archived native text sections in `inspect`
|
|
14
|
+
|
|
3
15
|
## 0.50.0
|
|
4
16
|
|
|
5
17
|
- Preserve headless Compose STOP failures and stop before restart; missing Container Manager profiles remain normal lifecycle state
|
package/README.md
CHANGED
|
@@ -708,3 +708,19 @@ executes HTTP bindings without forwarding DSM cookies. Authentication failures
|
|
|
708
708
|
offer explicit renewal without replaying the command. Uploads and downloads
|
|
709
709
|
stream with declared byte/MIME limits and secure local file handling. Read
|
|
710
710
|
`synopkgland skill show ctl` for configuration, auth commands and transfer rules.
|
|
711
|
+
|
|
712
|
+
### Native DSM text sections
|
|
713
|
+
|
|
714
|
+
Declare `i18n.dsm_texts: i18n/dsm-texts` to merge package-owned `[notify]` or
|
|
715
|
+
other native sections into `ui/texts/<DSM language>/strings`. `check` validates
|
|
716
|
+
all declared locales, keys and placeholder parity; `build` adds the keys to
|
|
717
|
+
`ui/config` preload lists. `inspect --json <SPK>` reports archived `nativeTexts`
|
|
718
|
+
sections and keys per DSM language. See `synopkgland skill show dsm-texts` and
|
|
719
|
+
[the format and evidence notes](skills/reference/dsm-texts.md).
|
|
720
|
+
|
|
721
|
+
### Raw TCP protocols
|
|
722
|
+
|
|
723
|
+
Declare `tcp_listeners` for a native Go protocol listener, then call
|
|
724
|
+
`ipc.ListenTCP(ctx, "declared_id", port)` directly. `check` validates bind scope,
|
|
725
|
+
port bounds and SDK policy support; audit rejects undeclared/dynamic IDs and
|
|
726
|
+
constructor aliases. See `synopkgland skill show raw-tcp`.
|
|
@@ -19,11 +19,12 @@ import (
|
|
|
19
19
|
)
|
|
20
20
|
|
|
21
21
|
type input struct {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
TCPListeners []string
|
|
23
|
+
Dir string
|
|
24
|
+
Roots []string
|
|
25
|
+
Arches []string
|
|
26
|
+
Permissions map[string]string
|
|
27
|
+
SDK map[string]map[string]string
|
|
27
28
|
}
|
|
28
29
|
|
|
29
30
|
type result struct {
|
|
@@ -607,7 +608,7 @@ func main() {
|
|
|
607
608
|
}
|
|
608
609
|
if module == sdkModule+"/ipc" && !direct[selector] {
|
|
609
610
|
switch name {
|
|
610
|
-
case "ServeUnix", "StartUnix", "ServePeerUnix", "StartPeerUnix", "StartPackagePeerUnix", "DialUnix", "DialPeerUnix", "ReserveLoopback", "ProbeLoopback":
|
|
611
|
+
case "ServeUnix", "StartUnix", "ServePeerUnix", "StartPeerUnix", "StartPackagePeerUnix", "DialUnix", "DialPeerUnix", "ReserveLoopback", "ProbeLoopback", "ListenTCP":
|
|
611
612
|
problem(selector.Pos(), "IPC constructor aliases cannot be audited")
|
|
612
613
|
}
|
|
613
614
|
}
|
|
@@ -655,6 +656,22 @@ func main() {
|
|
|
655
656
|
if !ok {
|
|
656
657
|
return true
|
|
657
658
|
}
|
|
659
|
+
if pkg, ok := selector.X.(*ast.Ident); ok && imports[pkg.Name] == sdkModule+"/ipc" && selector.Sel.Name == "ListenTCP" {
|
|
660
|
+
id := ""
|
|
661
|
+
if len(call.Args) == 3 {
|
|
662
|
+
id = stringLiteral(call.Args[1])
|
|
663
|
+
}
|
|
664
|
+
declared := false
|
|
665
|
+
for _, name := range in.TCPListeners {
|
|
666
|
+
if id != "" && name == id {
|
|
667
|
+
declared = true
|
|
668
|
+
}
|
|
669
|
+
}
|
|
670
|
+
if !declared {
|
|
671
|
+
problem(call.Pos(), "ipc.ListenTCP requires a literal declared tcp_listeners ID and three arguments")
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
|
|
658
675
|
// An in-process administrator call names one fixed route that
|
|
659
676
|
// already requires DSM administrators; the SDK verifies the account.
|
|
660
677
|
if selector.Sel.Name == "InvokeAsAdministrator" {
|
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
import { type NativeTexts } from "../standalone/dsm-texts.js";
|
|
1
2
|
import { type InfoTranslations } from "../standalone/i18n.js";
|
|
2
3
|
/** The English INFO text and its translations, which also name the app in DSM. */
|
|
3
4
|
export interface AppTitle {
|
|
4
5
|
displayname: string;
|
|
5
6
|
description: string;
|
|
6
7
|
info?: InfoTranslations;
|
|
8
|
+
nativeTexts?: NativeTexts;
|
|
7
9
|
}
|
|
8
10
|
/**
|
|
9
11
|
* `ui/config` title fields. With translations they are `section:key`
|
|
@@ -26,7 +28,7 @@ export declare function consoleTitle(displayname: string, console: {
|
|
|
26
28
|
export declare function uiConsoleTitleFields(app: AppTitle, console: {
|
|
27
29
|
title?: string;
|
|
28
30
|
}): ReturnType<typeof uiTitleFields>;
|
|
29
|
-
/**
|
|
31
|
+
/** Merge validated native sections after the reserved section, in fixed locale/section/key order. */
|
|
30
32
|
export declare function renderUiTexts(app: AppTitle, console?: {
|
|
31
33
|
title?: string;
|
|
32
34
|
}): Map<string, string>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { nativeTextRefs } from "../standalone/dsm-texts.js";
|
|
1
2
|
import { chmodSync, mkdirSync, writeFileSync } from "node:fs";
|
|
2
3
|
import { join } from "node:path";
|
|
3
4
|
import { DSM_LANGS, LOCALES } from "../standalone/i18n.js";
|
|
@@ -7,6 +8,10 @@ const DESC = `${SECTION}:app_desc`;
|
|
|
7
8
|
const CONSOLE_TITLE = `${SECTION}:console_title`;
|
|
8
9
|
/** `ui/` subdirectory with the strings; a `ui/config` entry's `texts` names it relative to `ui/`. */
|
|
9
10
|
const TEXTS_DIR = "texts";
|
|
11
|
+
function nativeTextFields(app) {
|
|
12
|
+
const refs = nativeTextRefs(app.nativeTexts);
|
|
13
|
+
return refs.length ? { texts: TEXTS_DIR, preloadTexts: refs } : {};
|
|
14
|
+
}
|
|
10
15
|
function translated(app) {
|
|
11
16
|
return Object.values(app.info ?? {}).some((text) => text?.displayname || text?.description);
|
|
12
17
|
}
|
|
@@ -19,8 +24,8 @@ function translated(app) {
|
|
|
19
24
|
*/
|
|
20
25
|
export function uiTitleFields(app) {
|
|
21
26
|
return translated(app)
|
|
22
|
-
? { title: TITLE, desc: DESC, texts: TEXTS_DIR, preloadTexts: [TITLE, DESC] }
|
|
23
|
-
: { title: app.displayname, desc: app.description };
|
|
27
|
+
? { title: TITLE, desc: DESC, texts: TEXTS_DIR, preloadTexts: [TITLE, DESC, ...nativeTextRefs(app.nativeTexts)] }
|
|
28
|
+
: { title: app.displayname, desc: app.description, ...nativeTextFields(app) };
|
|
24
29
|
}
|
|
25
30
|
/** The console's name: the declared title in every language, else "<displayname> for DSM". */
|
|
26
31
|
export function consoleTitle(displayname, console) {
|
|
@@ -29,22 +34,26 @@ export function consoleTitle(displayname, console) {
|
|
|
29
34
|
/** {@link uiTitleFields} for the console window, which shares the App's description. */
|
|
30
35
|
export function uiConsoleTitleFields(app, console) {
|
|
31
36
|
return translated(app)
|
|
32
|
-
? { title: CONSOLE_TITLE, desc: DESC, texts: TEXTS_DIR, preloadTexts: [CONSOLE_TITLE, DESC] }
|
|
33
|
-
: { title: consoleTitle(app.displayname, console), desc: app.description };
|
|
37
|
+
? { title: CONSOLE_TITLE, desc: DESC, texts: TEXTS_DIR, preloadTexts: [CONSOLE_TITLE, DESC, ...nativeTextRefs(app.nativeTexts)] }
|
|
38
|
+
: { title: consoleTitle(app.displayname, console), desc: app.description, ...nativeTextFields(app) };
|
|
34
39
|
}
|
|
35
|
-
/**
|
|
40
|
+
/** Merge validated native sections after the reserved section, in fixed locale/section/key order. */
|
|
36
41
|
export function renderUiTexts(app, console) {
|
|
37
42
|
const files = new Map();
|
|
38
|
-
if (!translated(app))
|
|
43
|
+
if (!translated(app) && !app.nativeTexts)
|
|
39
44
|
return files;
|
|
40
45
|
for (const locale of LOCALES) {
|
|
41
46
|
const text = locale === "en" ? undefined : app.info?.[locale];
|
|
42
|
-
|
|
47
|
+
const native = app.nativeTexts?.[locale];
|
|
48
|
+
if (!translated(app) && !native)
|
|
49
|
+
continue;
|
|
50
|
+
if (locale !== "en" && !text && !native)
|
|
43
51
|
continue;
|
|
44
52
|
const title = text?.displayname ?? app.displayname;
|
|
45
53
|
const desc = text?.description ?? app.description;
|
|
46
54
|
const consoleLine = console ? `console_title="${consoleTitle(title, console)}"\n` : "";
|
|
47
|
-
|
|
55
|
+
const own = translated(app) ? `[${SECTION}]\napp_title="${title}"\napp_desc="${desc}"\n${consoleLine}` : "";
|
|
56
|
+
files.set(DSM_LANGS[locale], own + (own && native ? "\n" : "") + (native ?? ""));
|
|
48
57
|
}
|
|
49
58
|
return files;
|
|
50
59
|
}
|
package/dist/cli.js
CHANGED
|
@@ -371,7 +371,15 @@ async function runCliWithin(argv) {
|
|
|
371
371
|
const policy = options.permissions
|
|
372
372
|
? parseApiPermissions(readFileSync(resolve(dir, options.permissions)))
|
|
373
373
|
: { schema: 1, default: "administrators", methods: {} };
|
|
374
|
-
const
|
|
374
|
+
const root = findStandaloneRoot(dir);
|
|
375
|
+
let listeners = [];
|
|
376
|
+
if (root) {
|
|
377
|
+
const loaded = loadStandaloneManifest(root);
|
|
378
|
+
if (!loaded.ok)
|
|
379
|
+
throw Error(loaded.errors.map(e => e.message).join('\n'));
|
|
380
|
+
listeners = Object.keys(loaded.manifest.tcpListeners ?? {});
|
|
381
|
+
}
|
|
382
|
+
const audit = auditGoRoutes(dir, policy, {}, [main], arches, listeners);
|
|
375
383
|
const ok = audit.problems.length === 0;
|
|
376
384
|
if (json)
|
|
377
385
|
stdout(JSON.stringify({ ok, ...audit }));
|
package/dist/error-registry.js
CHANGED
|
@@ -713,10 +713,25 @@ export const ERROR_REGISTRY = {
|
|
|
713
713
|
description: "An image login_style names is missing, in the wrong format or the wrong size.",
|
|
714
714
|
suggestion: "Use a JPEG wallpaper of at least 1920x1080 and at most 2 MiB, a 320x200 JPEG wallpaper_thumbnail and a 680x124 PNG title, inside the project.",
|
|
715
715
|
},
|
|
716
|
+
STANDALONE_TCP_LISTENERS_INVALID: {
|
|
717
|
+
code: "STANDALONE_TCP_LISTENERS_INVALID",
|
|
718
|
+
description: "A raw TCP listener declaration has invalid names, fields, scopes or port bounds.",
|
|
719
|
+
suggestion: "Declare tcp_listeners.<id> with port 1024..65535, scope loopback (default) or all, and optional port_range: [min,max] including port.",
|
|
720
|
+
},
|
|
721
|
+
STANDALONE_TCP_LISTENERS_UNSUPPORTED: {
|
|
722
|
+
code: "STANDALONE_TCP_LISTENERS_UNSUPPORTED",
|
|
723
|
+
description: "The backend SDK does not support the build-bound raw TCP listener policy.",
|
|
724
|
+
suggestion: "Use a native Go backend and an SDK with ipc.ListenTCP policy v1; SYNOPKGLAND_SDK_DIR may select a local SDK branch for development.",
|
|
725
|
+
},
|
|
716
726
|
STANDALONE_I18N_INVALID: {
|
|
717
727
|
code: "STANDALONE_I18N_INVALID",
|
|
718
728
|
description: "The i18n configuration in dsm-package.yaml is invalid.",
|
|
719
|
-
suggestion: "i18n accepts only messages, glossary and
|
|
729
|
+
suggestion: "i18n accepts only messages, glossary, info and dsm_texts; info is keyed by a supported language such as zh-TW or ja (English goes at the top level).",
|
|
730
|
+
},
|
|
731
|
+
STANDALONE_DSM_TEXTS_INVALID: {
|
|
732
|
+
code: "STANDALONE_DSM_TEXTS_INVALID",
|
|
733
|
+
description: "A DSM native strings source is invalid or differs across locales.",
|
|
734
|
+
suggestion: "Use dsm_texts/<locale>/strings with non-empty [section] key=\"text\" entries, identical keys and placeholders in every declared locale; synopkgland is reserved.",
|
|
720
735
|
},
|
|
721
736
|
STANDALONE_I18N_MESSAGES_MISSING: {
|
|
722
737
|
code: "STANDALONE_I18N_MESSAGES_MISSING",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"
|
|
1
|
+
{"module":"github.com/synopackageland/syno-pkg-land-sdk","version":"development","local":true}
|
|
@@ -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.53.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.53.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`;
|
package/dist/skill.js
CHANGED
|
@@ -32,6 +32,8 @@ const SKILL_CATALOG = [
|
|
|
32
32
|
file: "reference/identity.md",
|
|
33
33
|
when: "Needs a DSM sign-in",
|
|
34
34
|
},
|
|
35
|
+
{ id: "dsm-texts", file: "reference/dsm-texts.md", when: "Ship native DSM sections and fixed desktop notification strings" },
|
|
36
|
+
{ id: "raw-tcp", file: "reference/raw-tcp.md", when: "Declare raw TCP protocol listeners and their bind/port boundary" },
|
|
35
37
|
{ id: "mobile", file: "reference/mobile.md", when: "Register an App for the mobile shell and generate its SDK entry page" },
|
|
36
38
|
{ id: "files", file: "reference/files.md", when: "Needs NAS files" },
|
|
37
39
|
{
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tcpPolicyFlag } from "./tcp-listeners.js";
|
|
1
2
|
import { portalByExecutor } from '../build-spk/dsm-version.js';
|
|
2
3
|
import { generateOperations } from './operation-registry.js';
|
|
3
4
|
import { readFileSync, mkdtempSync, writeFileSync, rmSync } from 'node:fs';
|
|
@@ -49,7 +50,7 @@ export async function describeApiRoutes(m, bridgeMethods, run) {
|
|
|
49
50
|
else {
|
|
50
51
|
if (!readFileSync(join(m.backend.dir, m.backend.main, 'main.go'), 'utf8').includes('--describe'))
|
|
51
52
|
throw new StandaloneBuildError('CTL_DESCRIBE_REQUIRED', 'Go CGI must support build-only --describe; update its template.');
|
|
52
|
-
const flags = [`-X github.com/synopackageland/syno-pkg-land-sdk/api.expectedEntryMode=${m.entry ?? ''}`, `-X main.packageID=${m.package}`, `-X main.version=${m.spkVersion}`, ...(m.capabilities.files || m.capabilities.delegate ? ['-X main.fileStation=session'] : []), ...(m.portal ? [`-X main.portal=${portalByExecutor(m.os_min_ver) ? 'executor' : 'on'}`] : [])].join(' ');
|
|
53
|
+
const flags = [...tcpPolicyFlag(m), `-X github.com/synopackageland/syno-pkg-land-sdk/ipc.packageID=${m.package}`, `-X github.com/synopackageland/syno-pkg-land-sdk/api.expectedEntryMode=${m.entry ?? ''}`, `-X main.packageID=${m.package}`, `-X main.version=${m.spkVersion}`, ...(m.capabilities.files || m.capabilities.delegate ? ['-X main.fileStation=session'] : []), ...(m.portal ? [`-X main.portal=${portalByExecutor(m.os_min_ver) ? 'executor' : 'on'}`] : [])].join(' ');
|
|
53
54
|
const response = await run('go', ['run', '-trimpath', '-buildvcs=false', '-ldflags', flags, m.backend.main, '--describe'], { cwd: m.backend.dir, env: goChildEnv({ ...process.env, GOOS: undefined, GOARCH: undefined, GOARM: undefined, CGO_ENABLED: '0' }), capture: true });
|
|
54
55
|
if (response.status !== 0)
|
|
55
56
|
throw new StandaloneBuildError('CTL_DESCRIBE_FAILED', 'Go route metadata export failed.');
|
package/dist/standalone/build.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { tcpPolicyFlag } from "./tcp-listeners.js";
|
|
1
2
|
import { buildInstallSettings } from './install-settings.js';
|
|
2
3
|
import { enforceRepositorySecrets } from "../secret-files.js";
|
|
3
4
|
import { buildAppBackup } from './hyper-backup.js';
|
|
@@ -244,7 +245,7 @@ async function buildGoCgi(manifest, backend, arch, work, run) {
|
|
|
244
245
|
throw new StandaloneBuildError("STANDALONE_API_PERMISSIONS_CHANGED", "API permissions changed during build; check and rebuild.");
|
|
245
246
|
}
|
|
246
247
|
const policy = readApiPermissions(backend, manifest.capabilities);
|
|
247
|
-
const audit = auditGoRoutes(backend.dir, policy.policy, policy.sdk, [backend.main], [goBuildEnv(arch).GOARCH]);
|
|
248
|
+
const audit = auditGoRoutes(backend.dir, policy.policy, policy.sdk, [backend.main], [goBuildEnv(arch).GOARCH], Object.keys(manifest.tcpListeners ?? {}));
|
|
248
249
|
if (audit.problems.length || manifest.entry && !audit.entryGate) {
|
|
249
250
|
throw new StandaloneBuildError("STANDALONE_API_REGISTRY_INVALID", audit.problems.join("\n") || "App entry gate was removed during build.");
|
|
250
251
|
}
|
|
@@ -264,6 +265,7 @@ async function buildGoCgi(manifest, backend, arch, work, run) {
|
|
|
264
265
|
`-X ${SDK_MODULE}/api.expectedPermissionsDigest=${manifest.apiPermissionsDigest}`,
|
|
265
266
|
`-X ${SDK_MODULE}/api.expectedHTTPRoutesDigest=${httpRoutesDigest(audit)}`,
|
|
266
267
|
`-X ${SDK_MODULE}/ipc.packageID=${manifest.package}`,
|
|
268
|
+
...tcpPolicyFlag(manifest),
|
|
267
269
|
`-X ${SDK_MODULE}/ipc.executorTier=none`,
|
|
268
270
|
...(manifest.entry ? [`-X ${SDK_MODULE}/api.expectedEntryMode=${manifest.entry}`] : []),
|
|
269
271
|
...delegateBuildFlags(manifest),
|
|
@@ -317,7 +319,7 @@ async function buildBackgroundWorker(manifest, arch, work, run) {
|
|
|
317
319
|
return undefined;
|
|
318
320
|
const out = join(work, `background-worker-${arch}`);
|
|
319
321
|
const policy = readApiPermissions(manifest.backend, manifest.capabilities);
|
|
320
|
-
const audit = auditGoRoutes(manifest.backend.dir, policy.policy, policy.sdk, [BACKGROUND_WORKER_MAIN], [goBuildEnv(arch).GOARCH]);
|
|
322
|
+
const audit = auditGoRoutes(manifest.backend.dir, policy.policy, policy.sdk, [BACKGROUND_WORKER_MAIN], [goBuildEnv(arch).GOARCH], Object.keys(manifest.tcpListeners ?? {}));
|
|
321
323
|
if (audit.problems.length)
|
|
322
324
|
throw new StandaloneBuildError("STANDALONE_API_REGISTRY_INVALID", audit.problems.join("\n"));
|
|
323
325
|
const ldflags = [
|
|
@@ -326,6 +328,7 @@ async function buildBackgroundWorker(manifest, arch, work, run) {
|
|
|
326
328
|
"-buildid=",
|
|
327
329
|
`-X main.packageID=${manifest.package}`,
|
|
328
330
|
`-X ${SDK_MODULE}/ipc.packageID=${manifest.package}`,
|
|
331
|
+
...tcpPolicyFlag(manifest),
|
|
329
332
|
`-X ${SDK_MODULE}/ipc.executorTier=none`,
|
|
330
333
|
`-X ${SDK_MODULE}/api.expectedHTTPRoutesDigest=${httpRoutesDigest(audit)}`,
|
|
331
334
|
`-X ${SDK_MODULE}/api.expectedPermissionsDigest=${manifest.apiPermissionsDigest}`,
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type Locale } from "./i18n.js";
|
|
2
|
+
import type { StandaloneError } from "./manifest.js";
|
|
3
|
+
/** Validated, canonical DSM strings bytes, keyed by package locale (not DSM code). */
|
|
4
|
+
export type NativeTexts = Partial<Record<Locale, string>>;
|
|
5
|
+
export type NativeSections = Map<string, Map<string, string>>;
|
|
6
|
+
/** Deliberately accepts only the evidenced single-line, quoted strings subset. */
|
|
7
|
+
export declare function parseDsmStrings(text: string, allowReserved?: boolean): NativeSections;
|
|
8
|
+
export declare function renderDsmStrings(sections: NativeSections): string;
|
|
9
|
+
export declare function nativeTextRefs(texts?: NativeTexts): string[];
|
|
10
|
+
/** English plus every locale declared by messages / INFO is mandatory; no fallback hides omissions. */
|
|
11
|
+
export declare function loadNativeTexts(dir: string, required: string[], root: string): {
|
|
12
|
+
ok: true;
|
|
13
|
+
texts: NativeTexts;
|
|
14
|
+
} | {
|
|
15
|
+
ok: false;
|
|
16
|
+
errors: StandaloneError[];
|
|
17
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { lstatSync, readdirSync, readFileSync, realpathSync } from "node:fs";
|
|
2
|
+
import { isAbsolute, join, relative } from "node:path";
|
|
3
|
+
import { TextDecoder } from "node:util";
|
|
4
|
+
import { isLocale } from "./i18n.js";
|
|
5
|
+
const NAME = "[A-Za-z][A-Za-z0-9_]*";
|
|
6
|
+
const SECTION = new RegExp(`^\\[(${NAME})\\]$`);
|
|
7
|
+
const ENTRY = new RegExp(`^(${NAME})\\s*=\\s*\"([^\"\\\\\\x00-\\x1f\\x7f]*)\"$`);
|
|
8
|
+
/** Deliberately accepts only the evidenced single-line, quoted strings subset. */
|
|
9
|
+
export function parseDsmStrings(text, allowReserved = false) {
|
|
10
|
+
const sections = new Map();
|
|
11
|
+
let entries;
|
|
12
|
+
for (const [index, raw] of text.split(/\r?\n/).entries()) {
|
|
13
|
+
const line = raw.trim();
|
|
14
|
+
if (!line || line.startsWith("#") || line.startsWith(";"))
|
|
15
|
+
continue;
|
|
16
|
+
const section = SECTION.exec(line);
|
|
17
|
+
if (section) {
|
|
18
|
+
const name = section[1];
|
|
19
|
+
if (!allowReserved && name.toLowerCase() === "synopkgland")
|
|
20
|
+
throw new Error(`line ${index + 1}: [synopkgland] is reserved for the packager`);
|
|
21
|
+
if (sections.has(name))
|
|
22
|
+
throw new Error(`line ${index + 1}: duplicate section [${name}]`);
|
|
23
|
+
entries = new Map();
|
|
24
|
+
sections.set(name, entries);
|
|
25
|
+
continue;
|
|
26
|
+
}
|
|
27
|
+
const entry = ENTRY.exec(line);
|
|
28
|
+
if (!entries || !entry || !entry[2].trim())
|
|
29
|
+
throw new Error(`line ${index + 1}: expected [section] or key="non-empty single-line text"; names use letters, digits and underscores, starting with a letter; quotes, backslashes and controls in values are unsupported`);
|
|
30
|
+
if (entries.has(entry[1]))
|
|
31
|
+
throw new Error(`line ${index + 1}: duplicate key ${entry[1]}`);
|
|
32
|
+
entries.set(entry[1], entry[2]);
|
|
33
|
+
}
|
|
34
|
+
if (!sections.size || [...sections.values()].some((entries) => !entries.size))
|
|
35
|
+
throw new Error("each strings file needs at least one section, and every section needs a key");
|
|
36
|
+
return sections;
|
|
37
|
+
}
|
|
38
|
+
export function renderDsmStrings(sections) {
|
|
39
|
+
return [...sections.keys()].sort().map((section) => `[${section}]\n` + [...sections.get(section).keys()].sort().map((key) => `${key}="${sections.get(section).get(key)}"\n`).join("")).join("\n");
|
|
40
|
+
}
|
|
41
|
+
export function nativeTextRefs(texts) {
|
|
42
|
+
if (!texts?.en)
|
|
43
|
+
return [];
|
|
44
|
+
return [...parseDsmStrings(texts.en)].flatMap(([section, entries]) => [...entries.keys()].map((key) => `${section}:${key}`)).sort();
|
|
45
|
+
}
|
|
46
|
+
// Lint parity only: desktop key mode does not interpolate these tokens.
|
|
47
|
+
function placeholders(text) {
|
|
48
|
+
return (text.match(/\{[A-Za-z0-9_]+\}|%[A-Za-z_][A-Za-z0-9_]*%|%%|%(?:\d+\$)?[-+#0 ]*(?:\d+|\*)?(?:\.(?:\d+|\*))?[sdifuxXocgeEG]/g) ?? []).sort().join("\0");
|
|
49
|
+
}
|
|
50
|
+
function flattened(sections) {
|
|
51
|
+
return new Map([...sections].flatMap(([section, entries]) => [...entries].map(([key, text]) => [`${section}:${key}`, text])));
|
|
52
|
+
}
|
|
53
|
+
/** English plus every locale declared by messages / INFO is mandatory; no fallback hides omissions. */
|
|
54
|
+
export function loadNativeTexts(dir, required, root) {
|
|
55
|
+
const errors = [];
|
|
56
|
+
const texts = {};
|
|
57
|
+
const invalid = (message) => errors.push({ code: "STANDALONE_DSM_TEXTS_INVALID", message: `i18n.dsm_texts ${message}` });
|
|
58
|
+
try {
|
|
59
|
+
const rel = relative(realpathSync(root), realpathSync(dir));
|
|
60
|
+
if (rel.startsWith("..") || isAbsolute(rel) || !lstatSync(dir).isDirectory())
|
|
61
|
+
throw new Error("source must be a directory inside the project, not a symlink");
|
|
62
|
+
for (const locale of readdirSync(dir).sort()) {
|
|
63
|
+
try {
|
|
64
|
+
if (!isLocale(locale))
|
|
65
|
+
throw new Error("unsupported locale; use en, zh-TW, zh-CN, ja, ko, de, fr, es, it");
|
|
66
|
+
const folder = join(dir, locale);
|
|
67
|
+
if (!lstatSync(folder).isDirectory())
|
|
68
|
+
throw new Error("locale must be a directory, not a symlink");
|
|
69
|
+
const files = readdirSync(folder);
|
|
70
|
+
if (files.length !== 1 || files[0] !== "strings" || !lstatSync(join(folder, "strings")).isFile())
|
|
71
|
+
throw new Error('locale must contain exactly one regular file named "strings" (no symlinks)');
|
|
72
|
+
const source = new TextDecoder("utf-8", { fatal: true }).decode(readFileSync(join(folder, "strings")));
|
|
73
|
+
texts[locale] = renderDsmStrings(parseDsmStrings(source));
|
|
74
|
+
}
|
|
75
|
+
catch (error) {
|
|
76
|
+
invalid(`${locale}/strings: ${error instanceof Error ? error.message : String(error)}`);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
invalid(`${dir}: ${error instanceof Error ? error.message : String(error)}`);
|
|
82
|
+
}
|
|
83
|
+
for (const locale of [...new Set(["en", ...required])].sort()) {
|
|
84
|
+
if (!texts[locale])
|
|
85
|
+
invalid(`missing valid ${locale}/strings; required by English fallback, messages or INFO`);
|
|
86
|
+
}
|
|
87
|
+
if (texts.en) {
|
|
88
|
+
const en = flattened(parseDsmStrings(texts.en));
|
|
89
|
+
for (const [locale, text] of Object.entries(texts)) {
|
|
90
|
+
const current = flattened(parseDsmStrings(text));
|
|
91
|
+
const missing = [...en.keys()].filter((key) => !current.has(key));
|
|
92
|
+
const extra = [...current.keys()].filter((key) => !en.has(key));
|
|
93
|
+
if (missing.length || extra.length)
|
|
94
|
+
invalid(`${locale}/strings differs from en/strings: missing [${missing.join(", ")}]; extra [${extra.join(", ")}]`);
|
|
95
|
+
for (const [key, value] of current) {
|
|
96
|
+
if (en.has(key) && placeholders(value) !== placeholders(en.get(key)))
|
|
97
|
+
invalid(`${locale}/strings ${key}: placeholders differ from en/strings`);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
return errors.length ? { ok: false, errors } : { ok: true, texts };
|
|
102
|
+
}
|
|
@@ -90,6 +90,7 @@ export function appTitle(manifest) {
|
|
|
90
90
|
displayname: manifest.displayname,
|
|
91
91
|
description: manifest.description,
|
|
92
92
|
info: manifest.i18n?.info,
|
|
93
|
+
nativeTexts: manifest.i18n?.nativeTexts,
|
|
93
94
|
};
|
|
94
95
|
}
|
|
95
96
|
/**
|
|
@@ -172,6 +173,7 @@ export function renderUiConfig(manifest, icons = packageIcons(manifest.icon), lo
|
|
|
172
173
|
type: "lib",
|
|
173
174
|
title: consoleFields.title,
|
|
174
175
|
texts: consoleFields.texts,
|
|
176
|
+
...(manifest.i18n?.nativeTexts ? { preloadTexts: consoleFields.preloadTexts } : {}),
|
|
175
177
|
icon,
|
|
176
178
|
depend: [],
|
|
177
179
|
},
|
|
@@ -195,6 +197,7 @@ export function renderUiConfig(manifest, icons = packageIcons(manifest.icon), lo
|
|
|
195
197
|
type: "lib",
|
|
196
198
|
title: titleFields.title,
|
|
197
199
|
texts: titleFields.texts,
|
|
200
|
+
...(manifest.i18n?.nativeTexts ? { preloadTexts: titleFields.preloadTexts } : {}),
|
|
198
201
|
icon,
|
|
199
202
|
depend: [],
|
|
200
203
|
},
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type TCPListeners } from "./tcp-listeners.js";
|
|
1
2
|
import { type PackageDependencies } from "./package-dependencies.js";
|
|
2
3
|
import { type InstallSettings } from './install-settings.js';
|
|
3
4
|
import { type WebLaunchMode } from "../contract/web-launch.js";
|
|
@@ -11,6 +12,10 @@ import type { EntryMode } from "./manifest.js";
|
|
|
11
12
|
import { type UninstallCleanupItem } from "../runtime/uninstall-cleanup.js";
|
|
12
13
|
export type SpkKind = "native-go" | "native-python" | "native-node" | "native-rust" | "binary" | "container" | "native-layout";
|
|
13
14
|
export interface SpkInspection {
|
|
15
|
+
/** Archived DSM language -> native section -> sorted keys (no text values). */
|
|
16
|
+
nativeTexts?: Record<string, Record<string, string[]>>;
|
|
17
|
+
/** Manifest policy recorded at build time; not proof of runtime listener health. */
|
|
18
|
+
tcpListeners?: TCPListeners;
|
|
14
19
|
dependencies?: PackageDependencies;
|
|
15
20
|
installSettings?: InstallSettings;
|
|
16
21
|
/** Hyper Backup application backup, as sdk-package.json records it. */
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { parseDsmStrings } from "./dsm-texts.js";
|
|
2
|
+
import { readTCPListeners } from "./tcp-listeners.js";
|
|
1
3
|
import { inspectMobileFiles, mobileRecordProblem } from './mobile.js';
|
|
2
4
|
import { DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM, readNoFile, daemonSystemUnitName, renderDaemonSystemUnit, daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM } from "./daemon-nofile.js";
|
|
3
5
|
import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
@@ -156,6 +158,15 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
156
158
|
findings.push("sdk-package.json does not match the schema 2 capability inventory.");
|
|
157
159
|
}
|
|
158
160
|
}
|
|
161
|
+
let tcpListeners;
|
|
162
|
+
try {
|
|
163
|
+
tcpListeners = readTCPListeners(metadata.tcp_listeners);
|
|
164
|
+
if (tcpListeners && metadata.backend !== "go")
|
|
165
|
+
throw Error("tcp_listeners requires a native Go backend");
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
findings.push(`STANDALONE_TCP_LISTENERS_INVALID ${error.message}`);
|
|
169
|
+
}
|
|
159
170
|
const dependencies = inspectPackageDependencies(metadata.dependencies, findings);
|
|
160
171
|
const daemonNoFile = readNoFile(metadata.daemon_nofile, e => findings.push(e.message));
|
|
161
172
|
if (metadata.daemon_nofile !== undefined)
|
|
@@ -182,6 +193,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
182
193
|
}
|
|
183
194
|
return root;
|
|
184
195
|
}, payload, metadata.hyperBackup, /^package="([^"]*)"$/m.exec(readOptional(join(dir, "INFO")) ?? "")?.[1] ?? "", familyOfArchToken(/^arch="([^"]*)"$/m.exec(readOptional(join(dir, "INFO")) ?? "")?.[1]?.split(/\s+/)[0] ?? "") ?? "x86_64", findings);
|
|
196
|
+
const nativeTexts = await inspectNativeTexts(dir, paths, findings);
|
|
185
197
|
const integrations = metadata.integrations ?? [];
|
|
186
198
|
await inspectCtlArtifacts(dir, paths, metadata.ctl, metadata.entry, findings);
|
|
187
199
|
if (metadata.compose !== undefined) {
|
|
@@ -197,6 +209,8 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
197
209
|
result.identityGateway = identityGateway;
|
|
198
210
|
if (gateway)
|
|
199
211
|
result.gateway = gateway;
|
|
212
|
+
if (nativeTexts)
|
|
213
|
+
result.nativeTexts = nativeTexts;
|
|
200
214
|
result.icon = inspectPackageIcons(dir, findings);
|
|
201
215
|
return result;
|
|
202
216
|
}
|
|
@@ -342,6 +356,8 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
342
356
|
return {
|
|
343
357
|
...(dependencies ? { dependencies } : {}),
|
|
344
358
|
kind,
|
|
359
|
+
...(nativeTexts ? { nativeTexts } : {}),
|
|
360
|
+
...(tcpListeners ? { tcpListeners } : {}),
|
|
345
361
|
...(identityGateway ? { identityGateway } : {}),
|
|
346
362
|
...(gateway ? { gateway } : {}),
|
|
347
363
|
...(installSettings ? { installSettings } : {}),
|
|
@@ -390,6 +406,26 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
390
406
|
rmSync(dir, { recursive: true, force: true });
|
|
391
407
|
}
|
|
392
408
|
}
|
|
409
|
+
/** Read the archived bytes so inspect proves sections shipped, without consulting source files. */
|
|
410
|
+
async function inspectNativeTexts(dir, paths, findings) {
|
|
411
|
+
const files = [...paths].filter((path) => /^ui\/texts\/[^/]+\/strings$/.test(path)).sort();
|
|
412
|
+
if (!files.length)
|
|
413
|
+
return undefined;
|
|
414
|
+
const root = join(dir, "native-texts-inspection");
|
|
415
|
+
mkdirSync(root);
|
|
416
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: (path) => files.includes(path.replace(/^\.\//, "")) });
|
|
417
|
+
const result = {};
|
|
418
|
+
for (const file of files) {
|
|
419
|
+
try {
|
|
420
|
+
const sections = parseDsmStrings(readFileSync(join(root, file), "utf8"), true);
|
|
421
|
+
result[file.split("/")[2]] = Object.fromEntries([...sections].map(([section, entries]) => [section, [...entries.keys()].sort()]));
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
findings.push(`STANDALONE_DSM_TEXTS_INVALID ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
return result;
|
|
428
|
+
}
|
|
393
429
|
async function inspectModuleUi(dir, paths, version, findings, mobile) {
|
|
394
430
|
if (version === undefined) {
|
|
395
431
|
if ([...paths].some(path => /^ui\/app\/[a-f0-9]{64}\/app\.module\.js$/.test(path)))
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { type NativeTexts } from "./dsm-texts.js";
|
|
2
|
+
import { type TCPListeners } from "./tcp-listeners.js";
|
|
1
3
|
import { type MobileDeclaration } from './mobile.js';
|
|
2
4
|
import { type PackageDependencies } from "./package-dependencies.js";
|
|
3
5
|
import { type InstallSettings } from './install-settings.js';
|
|
@@ -42,10 +44,13 @@ export type StandaloneBackend = {
|
|
|
42
44
|
export interface StandaloneI18n {
|
|
43
45
|
/** UI messages per locale, embedded into the DSM window. */
|
|
44
46
|
catalogs?: Catalogs;
|
|
47
|
+
/** Additional validated DSM native sections, merged with the packager texts. */
|
|
48
|
+
nativeTexts?: NativeTexts;
|
|
45
49
|
/** INFO `displayname_<dsm lang>` / `description_<dsm lang>`. */
|
|
46
50
|
info: InfoTranslations;
|
|
47
51
|
}
|
|
48
52
|
export interface StandaloneManifest {
|
|
53
|
+
tcpListeners?: TCPListeners;
|
|
49
54
|
/** Exact payload paths exempted from the SPK secret guard, never repository checks. */
|
|
50
55
|
allowSecretFiles?: string[];
|
|
51
56
|
ctl?: {
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { loadNativeTexts } from "./dsm-texts.js";
|
|
2
|
+
import { readTCPListeners, tcpSDKProblem } from "./tcp-listeners.js";
|
|
1
3
|
import { validateNativeManifest } from './native-http.js';
|
|
2
4
|
import { readMobile, mobileIconPath } from './mobile.js';
|
|
3
5
|
import { daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM, DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM } from './daemon-nofile.js';
|
|
@@ -49,6 +51,7 @@ import { BRIDGE_RUNTIMES, isBridgeBackend, overlaps, readBridgeBackend, } from "
|
|
|
49
51
|
*/
|
|
50
52
|
export const STANDALONE_MANIFEST = "dsm-package.yaml";
|
|
51
53
|
export const KNOWN_FIELDS = new Set([
|
|
54
|
+
"tcp_listeners",
|
|
52
55
|
"allow_secret_files",
|
|
53
56
|
"ctl",
|
|
54
57
|
"schema",
|
|
@@ -82,7 +85,7 @@ export const KNOWN_FIELDS = new Set([
|
|
|
82
85
|
"root",
|
|
83
86
|
"login_style",
|
|
84
87
|
]);
|
|
85
|
-
const I18N_FIELDS = new Set(["messages", "glossary", "info"]);
|
|
88
|
+
const I18N_FIELDS = new Set(["messages", "glossary", "info", "dsm_texts"]);
|
|
86
89
|
const PACKAGE_ID = /^[A-Za-z][A-Za-z0-9]{1,63}$/;
|
|
87
90
|
const VERSION = /^\d+(\.\d+){0,3}$/;
|
|
88
91
|
const OS_MIN_VER = /^\d+\.\d+(\.\d+)?-\d+$/;
|
|
@@ -439,12 +442,29 @@ function readManifest(raw, c) {
|
|
|
439
442
|
c.fail("STANDALONE_ENTRY_UNSUPPORTED", "The SDK entry floor source is unavailable; update the SDK and retry.");
|
|
440
443
|
}
|
|
441
444
|
}
|
|
445
|
+
let tcpListeners;
|
|
446
|
+
if (raw.tcp_listeners !== undefined) {
|
|
447
|
+
try {
|
|
448
|
+
tcpListeners = readTCPListeners(raw.tcp_listeners);
|
|
449
|
+
const problem = backend ? tcpSDKProblem(backend) : "tcp_listeners requires a native Go backend.";
|
|
450
|
+
if (problem)
|
|
451
|
+
c.fail("STANDALONE_TCP_LISTENERS_UNSUPPORTED", problem);
|
|
452
|
+
const occupied = Object.values(identityGateway?.listen ?? {}).concat(identityGateway?.oidc ? [identityGateway.oidc.issuer_port] : []);
|
|
453
|
+
for (const [id, listener] of Object.entries(tcpListeners ?? {})) {
|
|
454
|
+
if (occupied.includes(listener.port))
|
|
455
|
+
c.fail("STANDALONE_TCP_LISTENERS_INVALID", `tcp_listeners.${id}.port conflicts with an identity_gateway default port.`);
|
|
456
|
+
}
|
|
457
|
+
}
|
|
458
|
+
catch (error) {
|
|
459
|
+
c.fail("STANDALONE_TCP_LISTENERS_INVALID", error.message);
|
|
460
|
+
}
|
|
461
|
+
}
|
|
442
462
|
if (backend?.kind === "go" && permissions && sdkVersionOrUndefined(backend) && (raw.entry === undefined || entry)) {
|
|
443
463
|
try {
|
|
444
464
|
const problems = new Set();
|
|
445
465
|
for (const main of [backend.main, ...(capabilities.jobs ? [BACKGROUND_WORKER_MAIN] : [])]) {
|
|
446
466
|
for (const arch of arches ?? []) {
|
|
447
|
-
const audit = auditGoRoutes(backend.dir, permissions.policy, permissions.sdk, [main], [({ x86_64: 'amd64', aarch64: 'arm64', armv7: 'arm' })[arch]]);
|
|
467
|
+
const audit = auditGoRoutes(backend.dir, permissions.policy, permissions.sdk, [main], [({ x86_64: 'amd64', aarch64: 'arm64', armv7: 'arm' })[arch]], Object.keys(tcpListeners ?? {}));
|
|
448
468
|
for (const problem of audit.problems)
|
|
449
469
|
problems.add(problem);
|
|
450
470
|
if (main === backend.main && entry && !audit.entryGate)
|
|
@@ -636,6 +656,7 @@ function readManifest(raw, c) {
|
|
|
636
656
|
}
|
|
637
657
|
: {}),
|
|
638
658
|
ui,
|
|
659
|
+
...(tcpListeners ? { tcpListeners } : {}),
|
|
639
660
|
...(i18n ? { i18n } : {}),
|
|
640
661
|
capabilities,
|
|
641
662
|
...(rootOps ? { rootOps } : {}),
|
|
@@ -1031,34 +1052,46 @@ function readI18n(value, c) {
|
|
|
1031
1052
|
const invalid = (why) => c.fail("STANDALONE_I18N_INVALID", `i18n ${why}`);
|
|
1032
1053
|
if (!isRecord(value) ||
|
|
1033
1054
|
Object.keys(value).some((key) => !I18N_FIELDS.has(key))) {
|
|
1034
|
-
return invalid("Only messages (the message directory), glossary (the terminology table)
|
|
1055
|
+
return invalid("Only messages (the message directory), glossary (the terminology table), info (per-language INFO text) and dsm_texts (native sections directory) are accepted.");
|
|
1035
1056
|
}
|
|
1036
1057
|
const info = readInfoTranslations(value.info, {
|
|
1037
1058
|
invalid: (why) => c.fail("STANDALONE_I18N_INVALID", `i18n.info ${why}`),
|
|
1038
1059
|
text: (text, field) => c.text(text, field),
|
|
1039
1060
|
});
|
|
1061
|
+
let catalogs;
|
|
1040
1062
|
if (value.messages === undefined) {
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
: invalid("glossary needs messages.");
|
|
1063
|
+
if (value.glossary !== undefined)
|
|
1064
|
+
return invalid("glossary needs messages.");
|
|
1044
1065
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
? undefined
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1066
|
+
else {
|
|
1067
|
+
const dir = c.path(value.messages, "i18n.messages");
|
|
1068
|
+
const glossary = value.glossary === undefined ? undefined : c.path(value.glossary, "i18n.glossary");
|
|
1069
|
+
if (!dir || (value.glossary !== undefined && !glossary))
|
|
1070
|
+
return undefined;
|
|
1071
|
+
const loaded = loadCatalogs(dir);
|
|
1072
|
+
if (!loaded.ok) {
|
|
1073
|
+
loaded.errors.forEach((e) => c.fail(e.code, e.message));
|
|
1074
|
+
return undefined;
|
|
1075
|
+
}
|
|
1076
|
+
catalogs = loaded.catalogs;
|
|
1077
|
+
const drift = glossary ? checkGlossary(glossary, catalogs) : [];
|
|
1078
|
+
drift.forEach((e) => c.fail(e.code, e.message));
|
|
1079
|
+
if (drift.length)
|
|
1080
|
+
return undefined;
|
|
1051
1081
|
}
|
|
1052
|
-
|
|
1053
|
-
if (
|
|
1054
|
-
|
|
1055
|
-
|
|
1082
|
+
let nativeTexts;
|
|
1083
|
+
if (value.dsm_texts !== undefined) {
|
|
1084
|
+
const dir = c.path(value.dsm_texts, "i18n.dsm_texts");
|
|
1085
|
+
if (!dir)
|
|
1086
|
+
return undefined;
|
|
1087
|
+
const loaded = loadNativeTexts(dir, [...Object.keys(catalogs ?? {}), ...Object.keys(info ?? {})], c.root);
|
|
1088
|
+
if (!loaded.ok) {
|
|
1089
|
+
loaded.errors.forEach((e) => c.fail(e.code, e.message));
|
|
1090
|
+
return undefined;
|
|
1091
|
+
}
|
|
1092
|
+
nativeTexts = loaded.texts;
|
|
1056
1093
|
}
|
|
1057
|
-
|
|
1058
|
-
drift.forEach((e) => c.fail(e.code, e.message));
|
|
1059
|
-
return info && drift.length === 0
|
|
1060
|
-
? { catalogs: loaded.catalogs, info }
|
|
1061
|
-
: undefined;
|
|
1094
|
+
return info ? { info, ...(catalogs ? { catalogs } : {}), ...(nativeTexts ? { nativeTexts } : {}) } : undefined;
|
|
1062
1095
|
}
|
|
1063
1096
|
/**
|
|
1064
1097
|
* The nearest directory at or above `start` that holds dsm-package.yaml,
|
|
@@ -9,4 +9,4 @@ export interface RouteAudit {
|
|
|
9
9
|
}
|
|
10
10
|
export declare function httpRoutesDigest(audit: RouteAudit): string;
|
|
11
11
|
/** Parse Go syntax without executing an App's main, init functions or --describe. */
|
|
12
|
-
export declare function auditGoRoutes(dir: string, policy: ApiPermissions, sdk: Record<string, Record<string, string>>, roots?: string[], arches?: string[]): RouteAudit;
|
|
12
|
+
export declare function auditGoRoutes(dir: string, policy: ApiPermissions, sdk: Record<string, Record<string, string>>, roots?: string[], arches?: string[], tcpListeners?: string[]): RouteAudit;
|
|
@@ -10,7 +10,7 @@ export function httpRoutesDigest(audit) {
|
|
|
10
10
|
return createHash('sha256').update(JSON.stringify(audit.httpRoutes)).digest('hex');
|
|
11
11
|
}
|
|
12
12
|
/** Parse Go syntax without executing an App's main, init functions or --describe. */
|
|
13
|
-
export function auditGoRoutes(dir, policy, sdk, roots = ['.'], arches = ['amd64', 'arm64', 'arm']) {
|
|
13
|
+
export function auditGoRoutes(dir, policy, sdk, roots = ['.'], arches = ['amd64', 'arm64', 'arm'], tcpListeners = []) {
|
|
14
14
|
const env = goChildEnv({ ...process.env, GOOS: undefined, GOARCH: undefined, GOARM: undefined, GOWORK: 'off', CGO_ENABLED: '0' });
|
|
15
15
|
if (!binary) {
|
|
16
16
|
const work = mkdtempSync(join(tmpdir(), 'synopkgland-route-audit-'));
|
|
@@ -22,7 +22,7 @@ export function auditGoRoutes(dir, policy, sdk, roots = ['.'], arches = ['amd64'
|
|
|
22
22
|
throw new Error('Cannot build the Go route auditor; install Go and retry.');
|
|
23
23
|
binary = out;
|
|
24
24
|
}
|
|
25
|
-
const result = spawnSync(binary, [], { env, input: JSON.stringify({ Dir: realpathSync(dir), Roots: roots, Arches: arches, Permissions: policy.methods, SDK: sdk }), encoding: 'utf8', timeout: 120_000, maxBuffer: 4 << 20 });
|
|
25
|
+
const result = spawnSync(binary, [], { env, input: JSON.stringify({ Dir: realpathSync(dir), Roots: roots, Arches: arches, Permissions: policy.methods, SDK: sdk, TCPListeners: tcpListeners }), encoding: 'utf8', timeout: 120_000, maxBuffer: 4 << 20 });
|
|
26
26
|
if (result.error || result.status !== 0)
|
|
27
27
|
throw new Error(`Cannot audit Go routes: ${result.stderr?.trim() || 'auditor unavailable'}`);
|
|
28
28
|
return JSON.parse(result.stdout);
|
package/dist/standalone/spk.js
CHANGED
|
@@ -278,6 +278,7 @@ export async function assembleStandaloneSpk(options) {
|
|
|
278
278
|
.digest("hex");
|
|
279
279
|
writeFile(join(staging, "sdk-package.json"), JSON.stringify({
|
|
280
280
|
schema: 2,
|
|
281
|
+
...(manifest.tcpListeners ? { tcp_listeners: manifest.tcpListeners } : {}),
|
|
281
282
|
...(mobile ? { mobile: mobile.record } : {}),
|
|
282
283
|
dependencies: packageDependencies(manifest),
|
|
283
284
|
...(moduleVersion ? { ui_module: moduleVersion } : {}),
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { StandaloneBackend, StandaloneManifest } from './manifest.js';
|
|
2
|
+
export interface TCPListener {
|
|
3
|
+
scope: 'loopback' | 'all';
|
|
4
|
+
port: number;
|
|
5
|
+
port_range?: [number, number];
|
|
6
|
+
}
|
|
7
|
+
export type TCPListeners = Record<string, TCPListener>;
|
|
8
|
+
/** Normalize once for audit, linker flags and the archived declaration. */
|
|
9
|
+
export declare function readTCPListeners(raw: unknown): TCPListeners | undefined;
|
|
10
|
+
export declare function tcpSDKProblem(backend: StandaloneBackend): string | undefined;
|
|
11
|
+
export declare function tcpPolicyFlag(m: Pick<StandaloneManifest, 'tcpListeners'>): string[];
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { readFileSync } from 'node:fs';
|
|
2
|
+
import { join } from 'node:path';
|
|
3
|
+
import { appSdkVersion, sdkSource } from '../runtime/sdk-source.js';
|
|
4
|
+
const ID = /^[a-z][a-z0-9_]{0,63}$/;
|
|
5
|
+
function record(value) { return typeof value === 'object' && value !== null && !Array.isArray(value); }
|
|
6
|
+
/** Normalize once for audit, linker flags and the archived declaration. */
|
|
7
|
+
export function readTCPListeners(raw) {
|
|
8
|
+
if (raw === undefined)
|
|
9
|
+
return undefined;
|
|
10
|
+
const invalid = (why) => { throw Error('tcp_listeners ' + why); };
|
|
11
|
+
if (!record(raw) || Object.keys(raw).length === 0 || Object.keys(raw).length > 64)
|
|
12
|
+
invalid('must declare between 1 and 64 named listeners.');
|
|
13
|
+
const result = {};
|
|
14
|
+
for (const id of Object.keys(raw).sort()) {
|
|
15
|
+
const value = raw[id];
|
|
16
|
+
if (!ID.test(id) || !record(value) || Object.keys(value).some(k => !['scope', 'port', 'port_range'].includes(k)))
|
|
17
|
+
invalid(`${id}: use a lowercase letter followed by lowercase letters, digits or underscores (max 64); accepted fields: scope, port, port_range.`);
|
|
18
|
+
const v = value;
|
|
19
|
+
const scope = v.scope === undefined ? 'loopback' : v.scope;
|
|
20
|
+
if (scope !== 'loopback' && scope !== 'all')
|
|
21
|
+
invalid(`${id}.scope must be loopback (default, 127.0.0.1) or explicit all (0.0.0.0), IPv4 only.`);
|
|
22
|
+
if (!Number.isInteger(v.port) || Number(v.port) < 1024 || Number(v.port) > 65535)
|
|
23
|
+
invalid(`${id}.port must be an integer from 1024 to 65535.`);
|
|
24
|
+
const range = v.port_range;
|
|
25
|
+
if (range !== undefined && (!Array.isArray(range) || range.length !== 2 || range.some(p => !Number.isInteger(p) || p < 1024 || p > 65535) || range[0] > range[1] || Number(v.port) < range[0] || Number(v.port) > range[1]))
|
|
26
|
+
invalid(`${id}.port_range must be [min,max] within 1024..65535 and include port; omit it to allow only port.`);
|
|
27
|
+
result[id] = { scope: scope, port: v.port, ...(range !== undefined ? { port_range: range } : {}) };
|
|
28
|
+
}
|
|
29
|
+
const entries = Object.entries(result);
|
|
30
|
+
for (let i = 0; i < entries.length; i++)
|
|
31
|
+
for (let j = i + 1; j < entries.length; j++)
|
|
32
|
+
if (entries[i][1].port === entries[j][1].port)
|
|
33
|
+
invalid(`${entries[j][0]} default port conflicts with ${entries[i][0]}; all and loopback bindings share the IPv4 port space.`);
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
export function tcpSDKProblem(backend) {
|
|
37
|
+
if (backend.kind !== 'go')
|
|
38
|
+
return 'tcp_listeners requires a native Go backend.';
|
|
39
|
+
try {
|
|
40
|
+
const version = appSdkVersion(backend);
|
|
41
|
+
if (!version)
|
|
42
|
+
return 'tcp_listeners requires a pinned Go SDK with ipc.ListenTCP policy v1 (SDK 0.53.0).';
|
|
43
|
+
const source = readFileSync(join(sdkSource(version).goDir, 'ipc/tcp.go'), 'utf8');
|
|
44
|
+
if (!source.includes('const RawTCPPolicyVersion = 1'))
|
|
45
|
+
throw Error('policy v1 missing');
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return 'tcp_listeners requires Go SDK ipc.ListenTCP policy v1 (SDK 0.53.0); update the SDK pin, or use SYNOPKGLAND_SDK_DIR for local branch validation.';
|
|
49
|
+
}
|
|
50
|
+
return undefined;
|
|
51
|
+
}
|
|
52
|
+
export function tcpPolicyFlag(m) {
|
|
53
|
+
if (!m.tcpListeners)
|
|
54
|
+
return [];
|
|
55
|
+
const policy = Buffer.from(JSON.stringify({ schema: 1, listeners: m.tcpListeners })).toString('base64url');
|
|
56
|
+
return [`-X github.com/synopackageland/syno-pkg-land-sdk/ipc.tcpListenersPolicy=${policy}`];
|
|
57
|
+
}
|
package/package.json
CHANGED
|
@@ -1112,7 +1112,7 @@
|
|
|
1112
1112
|
"sourceAudit": {
|
|
1113
1113
|
"build-spk/share-combobox.ts": "797cd3eea347e7fe57946f9584f725d6faef79fe9c56b690e1199ea7489fa973",
|
|
1114
1114
|
"build-spk/share-validation.ts": "a51b160cea9bea096e6efb45879abbf6d0dfecf21c761dca7cd06647d44cef62",
|
|
1115
|
-
"cli.ts": "
|
|
1115
|
+
"cli.ts": "d198112e9b2e238373f96e85da50f509f55915a3995704936591162c2a37a783",
|
|
1116
1116
|
"ctl/cli.ts": "97d218069c6fac42f64573c68c354d7a0e549ca2900b9d8b2935c9786bc5d11d",
|
|
1117
1117
|
"ctl/external.ts": "f66490ded838f934a0cf373f284418d4d02441edc8c8365066fc45b898ba81dc",
|
|
1118
1118
|
"ctl/flows.ts": "0f35d03176655bfe1d1df5d02ea36199e05973634dffcc6710112b7c8ce78b7e",
|
|
@@ -16,8 +16,35 @@
|
|
|
16
16
|
"pattern": "^(?![\\s\\S]*(?:^|/)\\.{1,2}(?:/|$))[^/\\\\*?\\[\\]{}:\\u0000-\\u001f\\u007f]+(?:/[^/\\\\*?\\[\\]{}:\\u0000-\\u001f\\u007f]+)*$(?![\\s\\S])"
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
+
"tcp_listeners": {
|
|
20
|
+
"type": "object",
|
|
21
|
+
"minProperties": 1,
|
|
22
|
+
"maxProperties": 64,
|
|
23
|
+
"propertyNames": {"pattern": "^[a-z][a-z0-9_]{0,63}$"},
|
|
24
|
+
"additionalProperties": {
|
|
25
|
+
"type": "object",
|
|
26
|
+
"required": ["port"],
|
|
27
|
+
"properties": {
|
|
28
|
+
"scope": {"enum": ["loopback", "all"], "default": "loopback"},
|
|
29
|
+
"port": {"type": "integer", "minimum": 1024, "maximum": 65535},
|
|
30
|
+
"port_range": {"type": "array", "minItems": 2, "maxItems": 2, "items": {"type": "integer", "minimum": 1024, "maximum": 65535}}
|
|
31
|
+
},
|
|
32
|
+
"additionalProperties": false
|
|
33
|
+
}
|
|
34
|
+
},
|
|
19
35
|
"identity_gateway": {"$ref": "identity-gateway.v1.schema.json"},
|
|
20
|
-
"mobile": {"$ref": "mobile.v1.schema.json"}
|
|
36
|
+
"mobile": {"$ref": "mobile.v1.schema.json"},
|
|
37
|
+
"i18n": {
|
|
38
|
+
"type": "object",
|
|
39
|
+
"properties": {
|
|
40
|
+
"dsm_texts": {
|
|
41
|
+
"type": "string",
|
|
42
|
+
"minLength": 1,
|
|
43
|
+
"description": "Project-relative <locale>/strings directory. English and every messages/INFO locale are required; synopkgland is reserved. See synopkgland skill show dsm-texts."
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
"additionalProperties": true
|
|
47
|
+
}
|
|
21
48
|
},
|
|
22
49
|
"additionalProperties": true
|
|
23
50
|
}
|
package/skills/SKILL.md
CHANGED
|
@@ -5,6 +5,11 @@ description: Initialize, extend, check, build, inspect, and deploy Synology appl
|
|
|
5
5
|
|
|
6
6
|
# Independent Synology SPKs
|
|
7
7
|
|
|
8
|
+
For native DSM strings and fixed desktop notifications, read
|
|
9
|
+
[reference/dsm-texts.md](reference/dsm-texts.md) (`synopkgland skill show dsm-texts`).
|
|
10
|
+
For raw TCP protocols, read [reference/raw-tcp.md](reference/raw-tcp.md)
|
|
11
|
+
(`synopkgland skill show raw-tcp`).
|
|
12
|
+
|
|
8
13
|
For mobile registration, entry pages and native-shell capabilities, read
|
|
9
14
|
[reference/mobile.md](reference/mobile.md).
|
|
10
15
|
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
# Native DSM text sections and desktop notifications
|
|
2
|
+
|
|
3
|
+
Use this for schema 2 (`dsm-package.yaml`), independently of browser JSON message
|
|
4
|
+
keys. Add an explicit directory; no source is copied by convention alone:
|
|
5
|
+
|
|
6
|
+
```yaml
|
|
7
|
+
i18n:
|
|
8
|
+
messages: i18n/messages # optional existing browser catalogs
|
|
9
|
+
dsm_texts: i18n/dsm-texts
|
|
10
|
+
info:
|
|
11
|
+
zh-TW: {description: NAS 健康助理}
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
`i18n/dsm-texts/en/strings`:
|
|
15
|
+
|
|
16
|
+
```ini
|
|
17
|
+
[notify]
|
|
18
|
+
title="NAS assistant"
|
|
19
|
+
new_warning="A new warning needs your attention; open the app for details"
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
Provide the same sections and keys in `zh-TW/strings` and in every other locale
|
|
23
|
+
present in `i18n.messages` or declared under `i18n.info`. English is mandatory.
|
|
24
|
+
Native-only locales are also accepted and checked against English. The nine
|
|
25
|
+
supported source locales map to DSM directories as follows:
|
|
26
|
+
|
|
27
|
+
| Source | DSM |
|
|
28
|
+
| --- | --- |
|
|
29
|
+
| en | enu |
|
|
30
|
+
| zh-TW | cht |
|
|
31
|
+
| zh-CN | chs |
|
|
32
|
+
| ja | jpn |
|
|
33
|
+
| ko | krn |
|
|
34
|
+
| de | ger |
|
|
35
|
+
| fr | fre |
|
|
36
|
+
| es | spn |
|
|
37
|
+
| it | ita |
|
|
38
|
+
|
|
39
|
+
Each locale directory must contain exactly one regular UTF-8 `strings` file.
|
|
40
|
+
Symlinks and sources outside the project are refused. Blank lines and full-line
|
|
41
|
+
`#` / `;` comments are allowed. Section and key names start with an ASCII letter,
|
|
42
|
+
then contain only ASCII letters, digits and underscores. Each section needs at
|
|
43
|
+
least one key; duplicate sections/keys and empty values fail. Values must be
|
|
44
|
+
single-line double-quoted text without embedded double quotes, backslashes or
|
|
45
|
+
control characters. Escaping and multiline syntax are deliberately unsupported
|
|
46
|
+
until DSM parsing evidence is available. `[synopkgland]` is reserved (case
|
|
47
|
+
insensitive) and cannot be supplied by packages.
|
|
48
|
+
|
|
49
|
+
`check` reports `STANDALONE_DSM_TEXTS_INVALID` with file/line or locale/key context.
|
|
50
|
+
Every locale must have exactly the English section/key set. Placeholder tokens
|
|
51
|
+
`{name}`, `%NAME%` and printf conversions (including positional forms like `%1$s`)
|
|
52
|
+
must match English, including repeated occurrences. This is a translation lint;
|
|
53
|
+
it does not implement or promise substitution in DSM desktop key mode. Use fixed
|
|
54
|
+
text for desktop notifications and put variable details in the package UI.
|
|
55
|
+
|
|
56
|
+
`build` sorts sections and keys and writes LF-terminated files to
|
|
57
|
+
`ui/texts/<DSM language>/strings`, preserving the packager's title/description
|
|
58
|
+
section. It adds `texts: texts` and every native `section:key` to each generated
|
|
59
|
+
launcher/window's `preloadTexts`, including apps without INFO translations.
|
|
60
|
+
`inspect <SPK> --json` reads the archive and returns `nativeTexts`, mapping DSM
|
|
61
|
+
language to section to sorted key names. It reports malformed strings as a
|
|
62
|
+
finding. Inspect does not prove delivery, language selection or fallback on DSM.
|
|
63
|
+
|
|
64
|
+
A sender can invoke, with a validated recipient and fixed keys as argv:
|
|
65
|
+
|
|
66
|
+
```text
|
|
67
|
+
/usr/syno/bin/synodsmnotify -c SYNO.SDS.MyPackage.Instance \
|
|
68
|
+
<user|@group> MyPackage:notify:title MyPackage:notify:new_warning
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
`MyPackage` is `INFO.package`; use the actual app ID from `ui/config` (`.Console`
|
|
72
|
+
for packages whose SDK window is a separate console). The packager adds resources;
|
|
73
|
+
it grants no runtime privileges and provides no sender. Never shell-concatenate
|
|
74
|
+
recipients or accept arbitrary package/section/key references from callers.
|
|
75
|
+
|
|
76
|
+
## Evidence and limits
|
|
77
|
+
|
|
78
|
+
A DSM 7.3.2-86009 Update 3 experiment (2026-11-06)
|
|
79
|
+
recorded one fixed-key desktop send as a non-root package user, with an existing
|
|
80
|
+
installed package's preloaded title/description keys. Its source index references
|
|
81
|
+
`developer-guide` commit `eeeffb04af21f14a5928e93c03b1f9e71a0bb15d`,
|
|
82
|
+
`synology_package/show_massage.md` L88-101 and `integrate_dsm/i18n.md` L7-43:
|
|
83
|
+
UI texts are `texts/<DSM language>/strings`, using `[section]` and `key="value"`;
|
|
84
|
+
config declares `texts` and `preloadTexts`. `libsynosysnotify/lib/utils/string.c`
|
|
85
|
+
DSM7-3 commit `99131ab07c4fc7c9c5980db475bd46c61e25316a` L362-390 validates
|
|
86
|
+
`package:section:key`. These are research references, not bundled internal source.
|
|
87
|
+
|
|
88
|
+
A separate unsigned-SPK test (2026-11-07) recorded a package rejected with
|
|
89
|
+
4539 for the Synology-only `sysnotify` worker. This extension adds no `sysnotify`
|
|
90
|
+
resource, `mails` event definitions, JSON-variable mode or email/push/webhook
|
|
91
|
+
forwarding. Those are different mechanisms. Exact `[notify]` resources generated
|
|
92
|
+
here, all nine runtime language selections, missing-language fallback, escaped
|
|
93
|
+
text syntax and cross-model/DSM-version behavior have not been tested on a NAS
|
|
94
|
+
in this change. The evidence establishes the native format and existing-key
|
|
95
|
+
mechanism; local archive inspection establishes packaging, not device acceptance.
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
# Declared raw TCP listeners
|
|
2
|
+
|
|
3
|
+
`ipc.ListenTCP(ctx, "mail_relay", port)` returns a `net.Listener` constrained by
|
|
4
|
+
the native Go package's build-bound manifest declaration. This supports private
|
|
5
|
+
protocols such as a loopback SMTP relay without permitting arbitrary `net.Listen`
|
|
6
|
+
constructors in shipped application binaries. Use a matching CLI with TCP policy
|
|
7
|
+
v1 support; look up matching released SDK and CLI versions before updating pins.
|
|
8
|
+
No release is made by this change.
|
|
9
|
+
|
|
10
|
+
```yaml
|
|
11
|
+
# dsm-package.yaml, schema 2
|
|
12
|
+
tcp_listeners:
|
|
13
|
+
mail_relay:
|
|
14
|
+
port: 2525
|
|
15
|
+
# scope defaults to loopback: exactly IPv4 127.0.0.1
|
|
16
|
+
port_range: [1024, 65535] # optional explicit configurable-port allowance
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```go
|
|
20
|
+
import "github.com/synopackageland/syno-pkg-land-sdk/ipc"
|
|
21
|
+
|
|
22
|
+
listener, err := ipc.ListenTCP(ctx, "mail_relay", configuredPort)
|
|
23
|
+
if err != nil { return err }
|
|
24
|
+
defer listener.Close()
|
|
25
|
+
// Accept and serve the App's bounded, authenticated protocol.
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
A zero requested port selects the manifest default, rather than an ephemeral
|
|
29
|
+
port. Without `port_range`, only that fixed default is allowed. All ports must
|
|
30
|
+
be unprivileged integers, 1024–65535. Only the declaration selects the address:
|
|
31
|
+
`scope: loopback` (default) means `tcp4` on `127.0.0.1`; explicit `scope: all`
|
|
32
|
+
means `tcp4` on `0.0.0.0`. IPv6, DNS names, arbitrary host strings and privileged
|
|
33
|
+
ports are unsupported. Names use lowercase ASCII letters, digits and underscores,
|
|
34
|
+
start with a letter and have at most 64 characters. At most 64 declarations are
|
|
35
|
+
allowed. Duplicate default ports fail CLI validation; overlapping configurable
|
|
36
|
+
ranges are allowed and runtime binding decides conflicts. No DSM firewall rule,
|
|
37
|
+
service-port registration, installer UI, process supervision or root authority is
|
|
38
|
+
created. Use the existing jobs worker or daemon to host a long-lived service.
|
|
39
|
+
|
|
40
|
+
The CLI normalizes the policy and binds it, plus the package identity, into both
|
|
41
|
+
CGI and worker binaries with linker flags. The SDK does not read an environment
|
|
42
|
+
variable, a writable policy file or policy supplied by the caller. A binary with
|
|
43
|
+
no compiled policy/identity, an undeclared ID or an out-of-policy port fails
|
|
44
|
+
closed. Local SDK source replacement is a development mechanism, not a published
|
|
45
|
+
SDK pin. `check` validates the pinned/resolved SDK supports policy v1.
|
|
46
|
+
|
|
47
|
+
Use a **direct call with a literal ID** at each call site. Constructor aliases,
|
|
48
|
+
dynamic IDs and undeclared IDs fail the shipped-source audit. Declaring TCP does
|
|
49
|
+
not exempt any `net`, `tls`, syscall or HTTP constructor, file, directory or
|
|
50
|
+
handler from the existing audit. HTTP routes still use the SDK HTTP registry.
|
|
51
|
+
The auditor and compiler policy provide a supported source boundary, not an OS
|
|
52
|
+
sandbox against malicious code, reflection, plugins, cgo or custom syscalls.
|
|
53
|
+
|
|
54
|
+
Loopback binding uses the same internal bind primitive as `ipc.ReserveLoopback`;
|
|
55
|
+
the raw listener retains the bound socket without a release/rebind handoff.
|
|
56
|
+
Reservations still expose no listener and cannot bypass declarations. Kernel bind
|
|
57
|
+
failure is authoritative; a prior probe never guarantees ownership. `Close` is
|
|
58
|
+
idempotent. Context cancellation closes the listening socket and unblocks
|
|
59
|
+
`Accept`, but **does not close already accepted connections**. The App owns those
|
|
60
|
+
connections, deadlines, shutdown, concurrency limits, TLS/STARTTLS, authentication,
|
|
61
|
+
frame/message limits and upstream authorization. Other NAS processes can connect
|
|
62
|
+
to loopback; it is not a DSM identity boundary.
|
|
63
|
+
|
|
64
|
+
`inspect --json` reports the archived normalized `tcpListeners` policy. That is
|
|
65
|
+
build metadata, not proof of runtime binding, firewall reachability, SMTP delivery
|
|
66
|
+
or a package signature. No NAS acceptance is established by local tests.
|