@synopackageland/cli 0.50.0 → 0.51.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 +5 -0
- package/README.md +9 -0
- package/dist/build-spk/generator.js +3 -3
- package/dist/build-spk/reproducible-archive.js +3 -1
- package/dist/build-spk/ui-texts.d.ts +3 -1
- package/dist/build-spk/ui-texts.js +17 -8
- package/dist/ctl/ai-tools.d.ts +2 -0
- package/dist/ctl/cli.js +14 -0
- package/dist/ctl/diagnostics.d.ts +16 -0
- package/dist/ctl/diagnostics.js +11 -0
- package/dist/ctl/native-auth-command.js +5 -0
- package/dist/ctl/native-paths.js +13 -2
- package/dist/ctl/native-store.d.ts +6 -0
- package/dist/ctl/native-store.js +20 -26
- package/dist/ctl/service.d.ts +2 -0
- package/dist/ctl/service.js +1 -1
- package/dist/ctl/windows-acl.d.ts +39 -0
- package/dist/ctl/windows-acl.js +80 -0
- package/dist/ctl/windows-prompt.d.ts +5 -0
- package/dist/ctl/windows-prompt.js +119 -0
- package/dist/ctl/windows-sddl.d.ts +20 -0
- package/dist/ctl/windows-sddl.js +162 -0
- package/dist/ctl/windows-security-helper.d.ts +7 -0
- package/dist/ctl/windows-security-helper.js +88 -0
- package/dist/ctl/windows-security.d.ts +10 -0
- package/dist/ctl/windows-security.js +95 -0
- package/dist/ctl/windows-tools.d.ts +11 -0
- package/dist/ctl/windows-tools.js +23 -0
- package/dist/error-registry.js +6 -1
- package/dist/native-http-schema/source.json +1 -1
- package/dist/skill.js +1 -0
- package/dist/spk/extract.d.ts +6 -0
- package/dist/spk/extract.js +39 -0
- package/dist/standalone/daemon.js +1 -0
- 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 +2 -0
- package/dist/standalone/inspect-spk.js +46 -20
- package/dist/standalone/install-ports.js +2 -1
- package/dist/standalone/manifest.d.ts +3 -0
- package/dist/standalone/manifest.js +33 -20
- package/dist/standalone/native-layout.js +2 -0
- package/package.json +2 -1
- package/schema/dsm-package.schema.json +12 -1
- package/skills/SKILL.md +3 -0
- package/skills/reference/ctl.md +32 -1
- package/skills/reference/dsm-texts.md +95 -0
|
@@ -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
|
},
|
|
@@ -11,6 +11,8 @@ import type { EntryMode } from "./manifest.js";
|
|
|
11
11
|
import { type UninstallCleanupItem } from "../runtime/uninstall-cleanup.js";
|
|
12
12
|
export type SpkKind = "native-go" | "native-python" | "native-node" | "native-rust" | "binary" | "container" | "native-layout";
|
|
13
13
|
export interface SpkInspection {
|
|
14
|
+
/** Archived DSM language -> native section -> sorted keys (no text values). */
|
|
15
|
+
nativeTexts?: Record<string, Record<string, string[]>>;
|
|
14
16
|
dependencies?: PackageDependencies;
|
|
15
17
|
installSettings?: InstallSettings;
|
|
16
18
|
/** Hyper Backup application backup, as sdk-package.json records it. */
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { parseDsmStrings } from "./dsm-texts.js";
|
|
1
2
|
import { inspectMobileFiles, mobileRecordProblem } from './mobile.js';
|
|
2
3
|
import { DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM, readNoFile, daemonSystemUnitName, renderDaemonSystemUnit, daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM } from "./daemon-nofile.js";
|
|
3
4
|
import { gatewayIngressPathProblem, gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
@@ -27,6 +28,7 @@ import { inspectHyperBackup } from "./hyper-backup.js";
|
|
|
27
28
|
import { tmpdir } from "node:os";
|
|
28
29
|
import { join } from "node:path";
|
|
29
30
|
import * as tar from "tar";
|
|
31
|
+
import { extractSpkArchive } from "../spk/extract.js";
|
|
30
32
|
import { familyOfArchToken, NATIVE_ARCH_FAMILIES, } from "../build-spk/dsm-arch.js";
|
|
31
33
|
import { CONTAINER_MIN_DSM, isDsmAtLeast, PORTAL_EXECUTOR_MIN_DSM, PORTAL_MIN_DSM, PORTAL_MIN_DSM_REASON, } from "../build-spk/dsm-version.js";
|
|
32
34
|
import { ELF_MACHINE } from "./binary.js";
|
|
@@ -74,7 +76,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
74
76
|
const findings = (await archiveInventory(spkPath, true)).map(formatArchiveIssue);
|
|
75
77
|
if (findings.length)
|
|
76
78
|
return { signed: false, payload: [], findings, capabilities: [] };
|
|
77
|
-
await
|
|
79
|
+
findings.push(...await extractSpkArchive({ file: spkPath, cwd: dir }));
|
|
78
80
|
if (existsSync(join(dir, 'package.tgz'))) {
|
|
79
81
|
findings.push(...(await archiveInventory(join(dir, 'package.tgz'))).map(formatArchiveIssue));
|
|
80
82
|
if (findings.length)
|
|
@@ -90,7 +92,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
90
92
|
const payload = await listPayload(join(dir, "package.tgz"), findings);
|
|
91
93
|
const target = join(dir, "layout-inspection");
|
|
92
94
|
mkdirSync(target);
|
|
93
|
-
await
|
|
95
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: target });
|
|
94
96
|
findings.push(...inspectNativeLayout(dir, target, info));
|
|
95
97
|
for (const key of [
|
|
96
98
|
"package",
|
|
@@ -177,10 +179,11 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
177
179
|
const root = join(dir, "backup-inspection");
|
|
178
180
|
if (!existsSync(root)) {
|
|
179
181
|
mkdirSync(root);
|
|
180
|
-
await
|
|
182
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root });
|
|
181
183
|
}
|
|
182
184
|
return root;
|
|
183
185
|
}, 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);
|
|
186
|
+
const nativeTexts = await inspectNativeTexts(dir, paths, findings);
|
|
184
187
|
const integrations = metadata.integrations ?? [];
|
|
185
188
|
await inspectCtlArtifacts(dir, paths, metadata.ctl, metadata.entry, findings);
|
|
186
189
|
if (metadata.compose !== undefined) {
|
|
@@ -196,6 +199,8 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
196
199
|
result.identityGateway = identityGateway;
|
|
197
200
|
if (gateway)
|
|
198
201
|
result.gateway = gateway;
|
|
202
|
+
if (nativeTexts)
|
|
203
|
+
result.nativeTexts = nativeTexts;
|
|
199
204
|
result.icon = inspectPackageIcons(dir, findings);
|
|
200
205
|
return result;
|
|
201
206
|
}
|
|
@@ -268,7 +273,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
268
273
|
paths.has("executor/executor")) {
|
|
269
274
|
const executorDir = join(dir, "executor-inspection");
|
|
270
275
|
mkdirSync(executorDir);
|
|
271
|
-
await
|
|
276
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: executorDir });
|
|
272
277
|
const inspected = inspectExecutor(executorDir, info.package, info.arch);
|
|
273
278
|
findings.push(...inspected.findings);
|
|
274
279
|
executor = inspected.executor;
|
|
@@ -341,6 +346,7 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
341
346
|
return {
|
|
342
347
|
...(dependencies ? { dependencies } : {}),
|
|
343
348
|
kind,
|
|
349
|
+
...(nativeTexts ? { nativeTexts } : {}),
|
|
344
350
|
...(identityGateway ? { identityGateway } : {}),
|
|
345
351
|
...(gateway ? { gateway } : {}),
|
|
346
352
|
...(installSettings ? { installSettings } : {}),
|
|
@@ -389,6 +395,26 @@ export async function inspectSpk(spkPath, expectedKind) {
|
|
|
389
395
|
rmSync(dir, { recursive: true, force: true });
|
|
390
396
|
}
|
|
391
397
|
}
|
|
398
|
+
/** Read the archived bytes so inspect proves sections shipped, without consulting source files. */
|
|
399
|
+
async function inspectNativeTexts(dir, paths, findings) {
|
|
400
|
+
const files = [...paths].filter((path) => /^ui\/texts\/[^/]+\/strings$/.test(path)).sort();
|
|
401
|
+
if (!files.length)
|
|
402
|
+
return undefined;
|
|
403
|
+
const root = join(dir, "native-texts-inspection");
|
|
404
|
+
mkdirSync(root);
|
|
405
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: (path) => files.includes(path.replace(/^\.\//, "")) });
|
|
406
|
+
const result = {};
|
|
407
|
+
for (const file of files) {
|
|
408
|
+
try {
|
|
409
|
+
const sections = parseDsmStrings(readFileSync(join(root, file), "utf8"), true);
|
|
410
|
+
result[file.split("/")[2]] = Object.fromEntries([...sections].map(([section, entries]) => [section, [...entries.keys()].sort()]));
|
|
411
|
+
}
|
|
412
|
+
catch (error) {
|
|
413
|
+
findings.push(`STANDALONE_DSM_TEXTS_INVALID ${file}: ${error instanceof Error ? error.message : String(error)}`);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
return result;
|
|
417
|
+
}
|
|
392
418
|
async function inspectModuleUi(dir, paths, version, findings, mobile) {
|
|
393
419
|
if (version === undefined) {
|
|
394
420
|
if ([...paths].some(path => /^ui\/app\/[a-f0-9]{64}\/app\.module\.js$/.test(path)))
|
|
@@ -406,7 +432,7 @@ async function inspectModuleUi(dir, paths, version, findings, mobile) {
|
|
|
406
432
|
throw new Error("module UI assets must all belong to the recorded tree");
|
|
407
433
|
const root = join(dir, "module-ui-inspection");
|
|
408
434
|
mkdirSync(root);
|
|
409
|
-
await
|
|
435
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: path => path.replace(/^\.\//, "").startsWith(prefix) });
|
|
410
436
|
if (uiTreeDigest(join(root, "ui/app", version), true) !== version)
|
|
411
437
|
throw new Error("UI assets differ from their recorded digest");
|
|
412
438
|
}
|
|
@@ -420,7 +446,7 @@ const LAUNCHER_PORTAL_MISMATCH = "LAUNCHER_PORTAL_MISMATCH";
|
|
|
420
446
|
async function checkLaunchConfiguration(dir, info, native, declared, alias, findings, console = false, windowless = false) {
|
|
421
447
|
const target = join(dir, "launch-inspection");
|
|
422
448
|
mkdirSync(target);
|
|
423
|
-
await
|
|
449
|
+
await extractSpkArchive({
|
|
424
450
|
file: join(dir, "package.tgz"),
|
|
425
451
|
cwd: target,
|
|
426
452
|
filter: (path) => ["ui/config", "synology-app.yaml"].includes(path.replace(/^\.\//, "")),
|
|
@@ -558,7 +584,7 @@ function checkGatewayOnlyLauncher(target, info, native, findings) {
|
|
|
558
584
|
async function checkEntryLauncher(dir, pkg, entry, findings) {
|
|
559
585
|
const target = join(dir, "entry-inspection");
|
|
560
586
|
mkdirSync(target);
|
|
561
|
-
await
|
|
587
|
+
await extractSpkArchive({
|
|
562
588
|
file: join(dir, "package.tgz"),
|
|
563
589
|
cwd: target,
|
|
564
590
|
filter: (path) => path.replace(/^\.\//, "") === "ui/config",
|
|
@@ -591,7 +617,7 @@ const LOGIN_STYLE_FILES = [
|
|
|
591
617
|
async function inspectLoginStyle(dir, pkg, portal, findings) {
|
|
592
618
|
const target = join(dir, "login-style-inspection");
|
|
593
619
|
mkdirSync(target);
|
|
594
|
-
await
|
|
620
|
+
await extractSpkArchive({
|
|
595
621
|
file: join(dir, "package.tgz"),
|
|
596
622
|
cwd: target,
|
|
597
623
|
filter: (path) => path.replace(/^\.\//, "").startsWith("ui/"),
|
|
@@ -701,7 +727,7 @@ async function checkArch(dir, info, kind, hasCgi, findings) {
|
|
|
701
727
|
const cgi = join(dir, "cgi-inspection");
|
|
702
728
|
mkdirSync(cgi);
|
|
703
729
|
// Only the header is read; the CGI is never run.
|
|
704
|
-
await
|
|
730
|
+
await extractSpkArchive({
|
|
705
731
|
file: join(dir, "package.tgz"),
|
|
706
732
|
cwd: cgi,
|
|
707
733
|
filter: (path) => path.replace(/^\.\//, "") === CGI_PAYLOAD_PATH,
|
|
@@ -735,7 +761,7 @@ async function inspectUnifiedCompose(dir, payload, metadata, findings) {
|
|
|
735
761
|
const appScripts = unwrapAppScripts(join(dir, "scripts"), findings);
|
|
736
762
|
const root = join(dir, "unified-compose-inspection");
|
|
737
763
|
mkdirSync(root);
|
|
738
|
-
await
|
|
764
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root });
|
|
739
765
|
try {
|
|
740
766
|
if (metadata.capabilities?.some((c) => c !== "composeMounts"))
|
|
741
767
|
throw new Error("Compose cannot claim an undeclared executor capability");
|
|
@@ -927,7 +953,7 @@ async function recoverCompose(dir, value, findings) {
|
|
|
927
953
|
throw new Error("invalid compose inventory");
|
|
928
954
|
const root = join(dir, "compose-inspection");
|
|
929
955
|
mkdirSync(root);
|
|
930
|
-
await
|
|
956
|
+
await extractSpkArchive({
|
|
931
957
|
file: join(dir, "package.tgz"),
|
|
932
958
|
cwd: root,
|
|
933
959
|
filter: (p) => ["compose/docker-compose.yml", "sso/gateway.json"].includes(p.replace(/^\.\//, "")),
|
|
@@ -974,7 +1000,7 @@ async function checkDaemon(dir, info, paths, payload, findings, executor, backgr
|
|
|
974
1000
|
// Extract only the bounded config; the payload executable is never run.
|
|
975
1001
|
const { mkdirSync } = await import("node:fs");
|
|
976
1002
|
mkdirSync(unpacked);
|
|
977
|
-
await
|
|
1003
|
+
await extractSpkArchive({
|
|
978
1004
|
file: join(dir, "package.tgz"),
|
|
979
1005
|
cwd: unpacked,
|
|
980
1006
|
filter: (path) => ["daemon/config.json", `daemon/payload/${NODE_LAUNCHER}`].includes(path.replace(/^\.\//, "")),
|
|
@@ -1166,7 +1192,7 @@ function readInfo(path, findings, kind, compose = false, daemonNode, dependencie
|
|
|
1166
1192
|
async function checkContainerExposure(dir, packageTgz, findings) {
|
|
1167
1193
|
const extracted = join(dir, "payload");
|
|
1168
1194
|
mkdirSync(extracted);
|
|
1169
|
-
await
|
|
1195
|
+
await extractSpkArchive({
|
|
1170
1196
|
file: packageTgz,
|
|
1171
1197
|
cwd: extracted,
|
|
1172
1198
|
filter: (path) => path.replace(/^\.\//, "") === "compose.yaml",
|
|
@@ -1198,7 +1224,7 @@ async function inspectGatewayAdmission(dir, paths, saved, findings) {
|
|
|
1198
1224
|
}
|
|
1199
1225
|
const root = join(dir, "gateway-admission-inspection");
|
|
1200
1226
|
mkdirSync(root);
|
|
1201
|
-
await
|
|
1227
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: p => p.replace(/^\.\//, "") === "sso/gateway.json" });
|
|
1202
1228
|
const cfg = JSON.parse(readFileSync(join(root, "sso/gateway.json"), "utf8"));
|
|
1203
1229
|
const gateway = gatewayReviewReport(cfg);
|
|
1204
1230
|
if (cfg.upstream_access !== undefined && !["public", "protected"].includes(cfg.upstream_access))
|
|
@@ -1233,7 +1259,7 @@ async function inspectExternalGateway(dir, paths, payload, saved, findings) {
|
|
|
1233
1259
|
const root = join(dir, "external-gateway-inspection");
|
|
1234
1260
|
mkdirSync(root);
|
|
1235
1261
|
const entries = ["sso/gateway.json", GATEWAY_SETTINGS_CGI_PATH, "ui/sso/open.cgi"];
|
|
1236
|
-
await
|
|
1262
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: p => entries.includes(p.replace(/^\.\//, "")) });
|
|
1237
1263
|
const cfg = JSON.parse(readFileSync(join(root, "sso/gateway.json"), "utf8"));
|
|
1238
1264
|
if (saved === undefined && cfg.external === undefined && !paths.has(GATEWAY_SETTINGS_CGI_PATH))
|
|
1239
1265
|
return;
|
|
@@ -1276,7 +1302,7 @@ async function recoverNativeGateway(dir, value, info, findings) {
|
|
|
1276
1302
|
throw new Error('unsupported native gateway SDK/DSM floor');
|
|
1277
1303
|
const root = join(dir, 'native-gateway-inspection');
|
|
1278
1304
|
mkdirSync(root);
|
|
1279
|
-
await
|
|
1305
|
+
await extractSpkArchive({ file: join(dir, 'package.tgz'), cwd: root, filter: path => ['sso/gateway.json', 'ui/sso/open.cgi', NATIVE_GATEWAY_CONFIG].includes(path.replace(/^\.\//, '')) });
|
|
1280
1306
|
const config = JSON.parse(readFileSync(join(root, 'sso/gateway.json'), 'utf8'));
|
|
1281
1307
|
if (config.native_ingress !== true || config.package !== info.package || !isDeepStrictEqual(config.listen, plan.listen) || config.ingress_path !== plan.ingress?.path
|
|
1282
1308
|
|| config.state_dir !== `/var/packages/${info.package}/var/sso`)
|
|
@@ -1328,7 +1354,7 @@ async function recoverDaemonIngress(dir, value, info, paths, findings) {
|
|
|
1328
1354
|
throw new Error("ingress needs the package daemon");
|
|
1329
1355
|
const root = join(dir, "daemon-ingress-inspection");
|
|
1330
1356
|
mkdirSync(root);
|
|
1331
|
-
await
|
|
1357
|
+
await extractSpkArchive({ file: join(dir, "package.tgz"), cwd: root, filter: (path) => path.replace(/^\.\//, "") === DAEMON_INGRESS_CONFIG });
|
|
1332
1358
|
if (readOptional(join(root, DAEMON_INGRESS_CONFIG)) !== renderDaemonIngressConfig(info.package, ingress))
|
|
1333
1359
|
throw new Error("ingress location differs from its fixed proxy");
|
|
1334
1360
|
for (const key of ["instuninst_restart_services", "startstop_restart_services"])
|
|
@@ -1544,7 +1570,7 @@ async function inspectInstallSettings(dir, payload, metadata, findings) {
|
|
|
1544
1570
|
}
|
|
1545
1571
|
const root = join(dir, 'install-settings-inspection');
|
|
1546
1572
|
mkdirSync(root);
|
|
1547
|
-
await
|
|
1573
|
+
await extractSpkArchive({ file: join(dir, 'package.tgz'), cwd: root });
|
|
1548
1574
|
const info = readInfo(join(dir, 'INFO'), findings, 'binary', Boolean(metadata.compose), undefined, inspectPackageDependencies(metadata.dependencies, findings));
|
|
1549
1575
|
const gateway = metadata.compose?.gateway ?? metadata.native_gateway;
|
|
1550
1576
|
const m = { package: info.package, os_min_ver: info.os_min_ver, capabilities: {}, installSettings: settings, identityGateway: gateway, ...(ports ? { installPorts: true } : {}) };
|
|
@@ -1621,7 +1647,7 @@ async function recoverPortal(dir, info, appId, paths, payload, findings, nativeG
|
|
|
1621
1647
|
return;
|
|
1622
1648
|
const unpacked = join(dir, "portal-inspection");
|
|
1623
1649
|
mkdirSync(unpacked);
|
|
1624
|
-
await
|
|
1650
|
+
await extractSpkArchive({
|
|
1625
1651
|
file: join(dir, "package.tgz"),
|
|
1626
1652
|
cwd: unpacked,
|
|
1627
1653
|
filter: (path) => files.includes(path.replace(/^\.\//, "")),
|
|
@@ -1827,7 +1853,7 @@ async function inspectMobile(dir, paths, record, info, findings) {
|
|
|
1827
1853
|
throw new Error('registration package or version differs from INFO');
|
|
1828
1854
|
const target = join(dir, 'mobile-inspection');
|
|
1829
1855
|
mkdirSync(target);
|
|
1830
|
-
await
|
|
1856
|
+
await extractSpkArchive({ file: join(dir, 'package.tgz'), cwd: target, filter: path => path.replace(/^\.\//, '').startsWith('ui/app/') });
|
|
1831
1857
|
const problem = inspectMobileFiles(join(target, 'ui/app'), record);
|
|
1832
1858
|
if (problem)
|
|
1833
1859
|
throw new Error(problem);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync, readFileSync, existsSync } from 'node:fs';
|
|
1
|
+
import { chmodSync, mkdirSync, writeFileSync, readFileSync, existsSync } from 'node:fs';
|
|
2
2
|
import { join } from 'node:path';
|
|
3
3
|
export function portDefaults(m) {
|
|
4
4
|
if (!m.installPorts || !m.identityGateway)
|
|
@@ -125,4 +125,5 @@ export function writePortPayload(m, root, render) {
|
|
|
125
125
|
mkdirSync(join(root, 'install'), { recursive: true });
|
|
126
126
|
writeFileSync(join(root, 'install/ports.json'), JSON.stringify({ schema: 1, package: m.package, ports, files }, null, 2) + '\n', { mode: 0o600 });
|
|
127
127
|
writeFileSync(join(root, `install/${m.package}.sc`), Object.entries(ports).map(([key, p]) => `[synopkgland.${m.package.replaceAll('_', '-')}.${key.replaceAll('_', '-')}]\ntitle="${m.package}"\ndesc="${m.package}"\nport_forward="no"\ndst.ports="${p.default}/${p.protocol}"\n`).join('\n'), { mode: 0o644 });
|
|
128
|
+
chmodSync(join(root, `install/${m.package}.sc`), 0o644);
|
|
128
129
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type NativeTexts } from "./dsm-texts.js";
|
|
1
2
|
import { type MobileDeclaration } from './mobile.js';
|
|
2
3
|
import { type PackageDependencies } from "./package-dependencies.js";
|
|
3
4
|
import { type InstallSettings } from './install-settings.js';
|
|
@@ -42,6 +43,8 @@ export type StandaloneBackend = {
|
|
|
42
43
|
export interface StandaloneI18n {
|
|
43
44
|
/** UI messages per locale, embedded into the DSM window. */
|
|
44
45
|
catalogs?: Catalogs;
|
|
46
|
+
/** Additional validated DSM native sections, merged with the packager texts. */
|
|
47
|
+
nativeTexts?: NativeTexts;
|
|
45
48
|
/** INFO `displayname_<dsm lang>` / `description_<dsm lang>`. */
|
|
46
49
|
info: InfoTranslations;
|
|
47
50
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { loadNativeTexts } from "./dsm-texts.js";
|
|
1
2
|
import { validateNativeManifest } from './native-http.js';
|
|
2
3
|
import { readMobile, mobileIconPath } from './mobile.js';
|
|
3
4
|
import { daemonNoFileSdkProblem, daemonNoFileIdentityProblem, DAEMON_NOFILE_MIN_DSM, DAEMON_NOFILE_UNSUPPORTED, DAEMON_NOFILE_ACTIVATION_PROBLEM } from './daemon-nofile.js';
|
|
@@ -82,7 +83,7 @@ export const KNOWN_FIELDS = new Set([
|
|
|
82
83
|
"root",
|
|
83
84
|
"login_style",
|
|
84
85
|
]);
|
|
85
|
-
const I18N_FIELDS = new Set(["messages", "glossary", "info"]);
|
|
86
|
+
const I18N_FIELDS = new Set(["messages", "glossary", "info", "dsm_texts"]);
|
|
86
87
|
const PACKAGE_ID = /^[A-Za-z][A-Za-z0-9]{1,63}$/;
|
|
87
88
|
const VERSION = /^\d+(\.\d+){0,3}$/;
|
|
88
89
|
const OS_MIN_VER = /^\d+\.\d+(\.\d+)?-\d+$/;
|
|
@@ -1031,34 +1032,46 @@ function readI18n(value, c) {
|
|
|
1031
1032
|
const invalid = (why) => c.fail("STANDALONE_I18N_INVALID", `i18n ${why}`);
|
|
1032
1033
|
if (!isRecord(value) ||
|
|
1033
1034
|
Object.keys(value).some((key) => !I18N_FIELDS.has(key))) {
|
|
1034
|
-
return invalid("Only messages (the message directory), glossary (the terminology table)
|
|
1035
|
+
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
1036
|
}
|
|
1036
1037
|
const info = readInfoTranslations(value.info, {
|
|
1037
1038
|
invalid: (why) => c.fail("STANDALONE_I18N_INVALID", `i18n.info ${why}`),
|
|
1038
1039
|
text: (text, field) => c.text(text, field),
|
|
1039
1040
|
});
|
|
1041
|
+
let catalogs;
|
|
1040
1042
|
if (value.messages === undefined) {
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
: invalid("glossary needs messages.");
|
|
1043
|
+
if (value.glossary !== undefined)
|
|
1044
|
+
return invalid("glossary needs messages.");
|
|
1044
1045
|
}
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
? undefined
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1046
|
+
else {
|
|
1047
|
+
const dir = c.path(value.messages, "i18n.messages");
|
|
1048
|
+
const glossary = value.glossary === undefined ? undefined : c.path(value.glossary, "i18n.glossary");
|
|
1049
|
+
if (!dir || (value.glossary !== undefined && !glossary))
|
|
1050
|
+
return undefined;
|
|
1051
|
+
const loaded = loadCatalogs(dir);
|
|
1052
|
+
if (!loaded.ok) {
|
|
1053
|
+
loaded.errors.forEach((e) => c.fail(e.code, e.message));
|
|
1054
|
+
return undefined;
|
|
1055
|
+
}
|
|
1056
|
+
catalogs = loaded.catalogs;
|
|
1057
|
+
const drift = glossary ? checkGlossary(glossary, catalogs) : [];
|
|
1058
|
+
drift.forEach((e) => c.fail(e.code, e.message));
|
|
1059
|
+
if (drift.length)
|
|
1060
|
+
return undefined;
|
|
1051
1061
|
}
|
|
1052
|
-
|
|
1053
|
-
if (
|
|
1054
|
-
|
|
1055
|
-
|
|
1062
|
+
let nativeTexts;
|
|
1063
|
+
if (value.dsm_texts !== undefined) {
|
|
1064
|
+
const dir = c.path(value.dsm_texts, "i18n.dsm_texts");
|
|
1065
|
+
if (!dir)
|
|
1066
|
+
return undefined;
|
|
1067
|
+
const loaded = loadNativeTexts(dir, [...Object.keys(catalogs ?? {}), ...Object.keys(info ?? {})], c.root);
|
|
1068
|
+
if (!loaded.ok) {
|
|
1069
|
+
loaded.errors.forEach((e) => c.fail(e.code, e.message));
|
|
1070
|
+
return undefined;
|
|
1071
|
+
}
|
|
1072
|
+
nativeTexts = loaded.texts;
|
|
1056
1073
|
}
|
|
1057
|
-
|
|
1058
|
-
drift.forEach((e) => c.fail(e.code, e.message));
|
|
1059
|
-
return info && drift.length === 0
|
|
1060
|
-
? { catalogs: loaded.catalogs, info }
|
|
1061
|
-
: undefined;
|
|
1074
|
+
return info ? { info, ...(catalogs ? { catalogs } : {}), ...(nativeTexts ? { nativeTexts } : {}) } : undefined;
|
|
1062
1075
|
}
|
|
1063
1076
|
/**
|
|
1064
1077
|
* The nearest directory at or above `start` that holds dsm-package.yaml,
|
|
@@ -360,6 +360,8 @@ export async function buildNativeLayout(options) {
|
|
|
360
360
|
fail('INFO anchor collides with an INFO field');
|
|
361
361
|
writeFileSync(join(stage, 'INFO'), info.map(([k, v]) => `${k}="${v.replace(/([\\"$`])/g, '\\$1')}"\n`).join(''));
|
|
362
362
|
writeFileSync(join(stage, 'native-layout.json'), JSON.stringify({ format: 1, arch, dependencies: m.dependencies ?? { packages: [] }, binaries: binaries.map(({ path, linkage }) => ({ path, linkage })), files, ...(m.layout.anchors ? { anchors: m.layout.anchors } : {}), ...(m.portal ? { portal: m.portal } : {}) }));
|
|
363
|
+
for (const name of ['INFO', 'native-layout.json'])
|
|
364
|
+
chmodSync(join(stage, name), 0o644);
|
|
363
365
|
const output = join(outDir, `${m.package}-${version}-${arch}.spk`);
|
|
364
366
|
await createReproducibleTar(stage, output, { rejectSecrets: true });
|
|
365
367
|
return output;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synopackageland/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.51.0",
|
|
4
4
|
"description": "Syno Package Land Developer Kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"commander": "^13.1.0",
|
|
45
45
|
"esbuild": "^0.28.2",
|
|
46
46
|
"json-canonicalize": "^3.0.1",
|
|
47
|
+
"koffi": "3.3.7",
|
|
47
48
|
"re2js": "2.9.1",
|
|
48
49
|
"tar": "^7.4.3",
|
|
49
50
|
"yaml": "^2.7.0"
|
|
@@ -17,7 +17,18 @@
|
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
19
|
"identity_gateway": {"$ref": "identity-gateway.v1.schema.json"},
|
|
20
|
-
"mobile": {"$ref": "mobile.v1.schema.json"}
|
|
20
|
+
"mobile": {"$ref": "mobile.v1.schema.json"},
|
|
21
|
+
"i18n": {
|
|
22
|
+
"type": "object",
|
|
23
|
+
"properties": {
|
|
24
|
+
"dsm_texts": {
|
|
25
|
+
"type": "string",
|
|
26
|
+
"minLength": 1,
|
|
27
|
+
"description": "Project-relative <locale>/strings directory. English and every messages/INFO locale are required; synopkgland is reserved. See synopkgland skill show dsm-texts."
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"additionalProperties": true
|
|
31
|
+
}
|
|
21
32
|
},
|
|
22
33
|
"additionalProperties": true
|
|
23
34
|
}
|
package/skills/SKILL.md
CHANGED
|
@@ -5,6 +5,9 @@ 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
|
+
|
|
8
11
|
For mobile registration, entry pages and native-shell capabilities, read
|
|
9
12
|
[reference/mobile.md](reference/mobile.md).
|
|
10
13
|
|
package/skills/reference/ctl.md
CHANGED
|
@@ -92,7 +92,38 @@ The independent passphrase is hidden, process-local and never derived from DSM
|
|
|
92
92
|
credentials. The vault uses scrypt and AES-256-GCM, bounded authenticated metadata,
|
|
93
93
|
private file permissions (user-only ACL on Windows), exclusive locking and atomic
|
|
94
94
|
replacement. Wrong passphrase, tamper, symlinks or unsafe permissions refuse
|
|
95
|
-
access.
|
|
95
|
+
access. On Windows, inherited ACLs on the shared ctl state directory are accepted
|
|
96
|
+
only when its owner is the current user, Administrators, local Administrator (LA)
|
|
97
|
+
or SYSTEM and no other
|
|
98
|
+
principal has write, delete, ACL-change or ownership-change access. Ancestors
|
|
99
|
+
are checked separately: the exact TrustedInstaller SID is also trusted there;
|
|
100
|
+
inherit-only grants do not apply to that directory, and create-subdirectory
|
|
101
|
+
permission alone cannot replace an existing protected child. Each next directory
|
|
102
|
+
is checked for effective grants. These ancestor exceptions do not apply to state
|
|
103
|
+
or private leaves. LA/LG use Win32 identity resolution, never the current user
|
|
104
|
+
SID prefix. Other recognized well-known aliases remain subject to the same
|
|
105
|
+
untrusted-writer policy. Private native
|
|
106
|
+
directories and files additionally reject other principals' read access. Existing
|
|
107
|
+
unsafe ACLs are refused rather than rewritten; new private objects use protected
|
|
108
|
+
current-user ACLs. An unavailable list entry includes a bounded `auth.reason`
|
|
109
|
+
code (for example `windows-acl-other-user-write`), without paths, SIDs or secrets.
|
|
110
|
+
ACL inspection uses Win32 GetNamedSecurityInfoW through a pinned native bridge
|
|
111
|
+
in a Node child that waits for completion without a wall-clock timeout; Ctrl-C
|
|
112
|
+
can interrupt it. No PowerShell is involved. Child output remains size-bounded,
|
|
113
|
+
with hidden windows and piped stdio. It reads the actual owner and DACL;
|
|
114
|
+
icacls /save alone omits the owner. The current SID is queried once per process
|
|
115
|
+
with whoami. New private objects use icacls and native readback;
|
|
116
|
+
unknown SDDL rights, flags or ACEs fail closed. Object ACE grants are evaluated
|
|
117
|
+
conservatively; conditional ACEs are explicitly refused. OWNER RIGHTS follows the
|
|
118
|
+
validated owner. Group, audit and mandatory-label sections cannot excuse unsafe
|
|
119
|
+
DACL grants. Invalid descriptors include a bounded tokenKind/token/section detail
|
|
120
|
+
with account SIDs masked, never the full descriptor or local paths. Inspection failures include a
|
|
121
|
+
fixed auth.detail.category and, when available, exitCode or win32Code. Raw child
|
|
122
|
+
stderr is never returned. ACL phase diagnostics include elapsedMs. Windows interactive prompts enable raw mode
|
|
123
|
+
before displaying input and wait for the prompt write to flush. An optional
|
|
124
|
+
`SYNOPKGLAND_CTL_DIAGNOSTICS_FILE` records private phase/TTY metadata only, never
|
|
125
|
+
input values, prompt text, local paths or SIDs.
|
|
126
|
+
Headless encrypted-file unlock is unsupported; automation requires an OS
|
|
96
127
|
secret service. Actual OS availability must be verified on the target platform.
|
|
97
128
|
Changing storage backends requires explicit `--reset` and enrollment, which
|
|
98
129
|
prevents a failed migration from leaving an unindexed old secret behind.
|