@synopackageland/cli 0.48.23 → 0.49.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 +17 -0
- package/dist/build-spk/dsm-icons.d.ts +2 -0
- package/dist/build-spk/dsm-icons.js +5 -0
- package/dist/build-spk/reproducible-archive.d.ts +2 -0
- package/dist/build-spk/reproducible-archive.js +27 -2
- package/dist/ctl/registry.d.ts +1 -1
- package/dist/error-registry.js +11 -0
- package/dist/init.js +27 -0
- package/dist/secret-files.d.ts +19 -0
- package/dist/secret-files.js +173 -0
- package/dist/skill.js +1 -0
- package/dist/standalone/build.js +2 -0
- package/dist/standalone/dsm-window.js +29 -2
- package/dist/standalone/i18n.d.ts +1 -0
- package/dist/standalone/i18n.js +2 -2
- package/dist/standalone/inspect-spk.js +30 -3
- package/dist/standalone/manifest.d.ts +4 -0
- package/dist/standalone/manifest.js +28 -0
- package/dist/standalone/mobile.d.ts +50 -0
- package/dist/standalone/mobile.js +154 -0
- package/dist/standalone/native-layout.d.ts +2 -0
- package/dist/standalone/native-layout.js +8 -4
- package/dist/standalone/sdk-check.js +12 -1
- package/dist/standalone/spk.js +9 -2
- package/dist/validate.js +16 -8
- package/package.json +5 -4
- package/schema/dsm-api-contract.json +6 -6
- package/schema/dsm-package.schema.json +11 -1
- package/schema/mobile.v1.schema.json +34 -0
- package/skills/SKILL.md +13 -0
- package/skills/reference/create.md +18 -0
- package/skills/reference/mobile.md +64 -0
- package/skills/reference/upstream-fork.md +11 -0
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { StandaloneManifest } from './manifest.js';
|
|
2
|
+
export interface MobileDeclaration {
|
|
3
|
+
entry: 'app' | 'gateway';
|
|
4
|
+
name?: string;
|
|
5
|
+
icon?: string;
|
|
6
|
+
start?: string;
|
|
7
|
+
capabilities?: Array<'download' | 'open-external' | 'camera'>;
|
|
8
|
+
intake?: {
|
|
9
|
+
route: string;
|
|
10
|
+
accept: Array<{
|
|
11
|
+
kind: 'text';
|
|
12
|
+
} | {
|
|
13
|
+
kind: 'url';
|
|
14
|
+
schemes: string[];
|
|
15
|
+
} | {
|
|
16
|
+
kind: 'file';
|
|
17
|
+
types: string[];
|
|
18
|
+
max_bytes?: number;
|
|
19
|
+
}>;
|
|
20
|
+
};
|
|
21
|
+
status?: boolean;
|
|
22
|
+
min_shell?: number;
|
|
23
|
+
}
|
|
24
|
+
/** The editor and check use the same complete declaration, including reserved post-v1 fields. */
|
|
25
|
+
export declare function readMobile(value: unknown): MobileDeclaration;
|
|
26
|
+
export declare function mobileIconPath(root: string, path: string): string;
|
|
27
|
+
export interface MobileRecord {
|
|
28
|
+
declaration: MobileDeclaration;
|
|
29
|
+
package: string;
|
|
30
|
+
version: string;
|
|
31
|
+
build: string;
|
|
32
|
+
name: Record<string, string>;
|
|
33
|
+
portal?: {
|
|
34
|
+
defaultAlias: string;
|
|
35
|
+
};
|
|
36
|
+
gatewayEntry?: string;
|
|
37
|
+
files: Record<string, string>;
|
|
38
|
+
}
|
|
39
|
+
/** Replayed by inspect from the packaged declaration, rather than copied JSON. */
|
|
40
|
+
export declare function mobileRegistration(record: MobileRecord): Record<string, unknown>;
|
|
41
|
+
export interface MobileAssets {
|
|
42
|
+
build: string;
|
|
43
|
+
files: Map<string, Buffer>;
|
|
44
|
+
record: MobileRecord;
|
|
45
|
+
}
|
|
46
|
+
/** Pure packaging glue; login, cache, portal and host behavior stay in the bundled SDK. */
|
|
47
|
+
export declare function renderMobileAssets(manifest: StandaloneManifest, uiDigest: string, moduleVersion?: string): Promise<MobileAssets | undefined>;
|
|
48
|
+
/** Validate the replay inventory before using any of its paths. */
|
|
49
|
+
export declare function mobileRecordProblem(record: unknown): string | undefined;
|
|
50
|
+
export declare function inspectMobileFiles(root: string, record: MobileRecord): string | undefined;
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Ajv } from 'ajv';
|
|
2
|
+
import { createHash } from 'node:crypto';
|
|
3
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
4
|
+
import { createRequire } from 'node:module';
|
|
5
|
+
import { isAbsolute, join, relative, resolve } from 'node:path';
|
|
6
|
+
import { build } from 'esbuild';
|
|
7
|
+
import { mobileIcons } from '../build-spk/dsm-icons.js';
|
|
8
|
+
import { appSdkTimeouts } from '../runtime/sdk-timeouts.js';
|
|
9
|
+
import { requestTimeoutSeconds } from './request-timeout.js';
|
|
10
|
+
import { MODULE_UI_ENTRY } from './ui-assets.js';
|
|
11
|
+
import { gatewayEntryPath } from './native-gateway.js';
|
|
12
|
+
import { CLI_VERSION } from '../cli-version.js';
|
|
13
|
+
import { isPortalAlias } from '../portal/alias.js';
|
|
14
|
+
const schema = JSON.parse(readFileSync(new URL('../../schema/mobile.v1.schema.json', import.meta.url), 'utf8'));
|
|
15
|
+
const ajv = new Ajv({ allErrors: true });
|
|
16
|
+
const validate = ajv.compile(schema);
|
|
17
|
+
/** The editor and check use the same complete declaration, including reserved post-v1 fields. */
|
|
18
|
+
export function readMobile(value) {
|
|
19
|
+
if (!validate(value))
|
|
20
|
+
throw new Error(`mobile ${ajv.errorsText(validate.errors)}`);
|
|
21
|
+
return value;
|
|
22
|
+
}
|
|
23
|
+
export function mobileIconPath(root, path) {
|
|
24
|
+
const rel = relative(root, resolve(root, path));
|
|
25
|
+
if (isAbsolute(path) || rel.startsWith('..') || isAbsolute(rel))
|
|
26
|
+
throw new Error('mobile.icon must stay inside the project');
|
|
27
|
+
return resolve(root, path);
|
|
28
|
+
}
|
|
29
|
+
/** Replayed by inspect from the packaged declaration, rather than copied JSON. */
|
|
30
|
+
export function mobileRegistration(record) {
|
|
31
|
+
const mobile = readMobile(record.declaration);
|
|
32
|
+
return {
|
|
33
|
+
schema: 1, package: record.package, version: record.version, build: record.build,
|
|
34
|
+
name: record.name, icon: `./icons/mobile-192.png?v=${record.build}`,
|
|
35
|
+
entry: mobile.entry === 'app' ? 'entry.html' : record.gatewayEntry,
|
|
36
|
+
...(record.portal ? { portal: record.portal } : {}),
|
|
37
|
+
start: mobile.start ?? '/', capabilities: mobile.capabilities ?? [],
|
|
38
|
+
...(mobile.intake ? { intake: mobile.intake } : {}), status: mobile.status ?? false, minShell: mobile.min_shell ?? 1,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const digest = (bytes) => createHash('sha256').update(bytes).digest('hex');
|
|
42
|
+
const json = (value) => JSON.stringify(value).replaceAll('<', '\\u003c');
|
|
43
|
+
const html = (value) => value.replaceAll('&', '&').replaceAll('<', '<').replaceAll('"', '"');
|
|
44
|
+
function entryModule(manifest) {
|
|
45
|
+
const roots = [manifest.ui.build?.cwd, manifest.root].filter((x) => !!x);
|
|
46
|
+
for (const root of roots) {
|
|
47
|
+
for (const modules of createRequire(join(root, 'package.json')).resolve.paths('@synopackageland/sdk') ?? []) {
|
|
48
|
+
try {
|
|
49
|
+
const dir = join(modules, '@synopackageland/sdk');
|
|
50
|
+
const pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
|
|
51
|
+
const entry = pkg.exports?.['./entry'];
|
|
52
|
+
const path = typeof entry === 'string' ? entry : entry?.import;
|
|
53
|
+
if (typeof path === 'string' && path.startsWith('./') && existsSync(join(dir, path)))
|
|
54
|
+
return join(dir, path);
|
|
55
|
+
}
|
|
56
|
+
catch { /* Try the next installed package */ }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
throw new Error('[MOBILE_SDK_ENTRY_MISSING] install @synopackageland/sdk with the /entry export in the UI build directory or project root');
|
|
60
|
+
}
|
|
61
|
+
/** Pure packaging glue; login, cache, portal and host behavior stay in the bundled SDK. */
|
|
62
|
+
export async function renderMobileAssets(manifest, uiDigest, moduleVersion) {
|
|
63
|
+
const mobile = manifest.mobile;
|
|
64
|
+
if (!mobile)
|
|
65
|
+
return undefined;
|
|
66
|
+
const icons = mobileIcons(mobile.icon ? mobileIconPath(manifest.root, mobile.icon) : manifest.icon);
|
|
67
|
+
const name = { en: mobile.name ?? manifest.displayname };
|
|
68
|
+
for (const [locale, text] of Object.entries(manifest.i18n?.info ?? {}))
|
|
69
|
+
if (text?.mobile_name || text?.displayname)
|
|
70
|
+
name[locale] = text.mobile_name ?? text.displayname;
|
|
71
|
+
const record = {
|
|
72
|
+
declaration: mobile, package: manifest.package, version: manifest.spkVersion, build: '', name,
|
|
73
|
+
...(manifest.portal ? { portal: { defaultAlias: manifest.portal.alias } } : {}),
|
|
74
|
+
...(mobile.entry === 'gateway' ? { gatewayEntry: gatewayEntryPath(manifest) } : {}), files: {},
|
|
75
|
+
};
|
|
76
|
+
const files = new Map();
|
|
77
|
+
for (const [size, png] of icons)
|
|
78
|
+
files.set(`icons/mobile-${size}.png`, png);
|
|
79
|
+
let runtime = '';
|
|
80
|
+
const requestTimeout = requestTimeoutSeconds(manifest.backend) * 1000 + appSdkTimeouts(manifest.backend).browserMarginMs;
|
|
81
|
+
if (mobile.entry === 'app') {
|
|
82
|
+
const result = await build({ entryPoints: [entryModule(manifest)], bundle: true, write: false, format: 'esm', platform: 'browser', target: 'es2022', minify: true, legalComments: 'inline' });
|
|
83
|
+
runtime = result.outputFiles[0].text;
|
|
84
|
+
}
|
|
85
|
+
// Hash both runtime and declaration, as well as the original UI and all icons.
|
|
86
|
+
const hash = createHash('sha256').update(readFileSync(new URL(import.meta.url))).update(uiDigest).update(json(mobileRegistration(record))).update(runtime)
|
|
87
|
+
.update(json({ generator: CLI_VERSION, requestTimeout, messages: manifest.i18n?.catalogs }));
|
|
88
|
+
for (const [path, bytes] of files)
|
|
89
|
+
hash.update(path).update(bytes);
|
|
90
|
+
const version = hash.digest('hex');
|
|
91
|
+
if (mobile.entry === 'app') {
|
|
92
|
+
const app = moduleVersion ? `./${moduleVersion}/${MODULE_UI_ENTRY}` : './app.js';
|
|
93
|
+
const options = {
|
|
94
|
+
packageId: manifest.package, build: version, displayName: name.en,
|
|
95
|
+
appIcon: `./icons/mobile-192.png?v=${version}`,
|
|
96
|
+
...(manifest.portal ? { portal: { defaultAlias: manifest.portal.alias } } : {}),
|
|
97
|
+
requestTimeout,
|
|
98
|
+
...(manifest.i18n?.catalogs ? { messages: manifest.i18n.catalogs } : {}),
|
|
99
|
+
};
|
|
100
|
+
// Classic bundles rely on document.currentScript.dataset.package; keep
|
|
101
|
+
// their script carrier rather than evaluating them as an ES module.
|
|
102
|
+
const loadApp = moduleVersion
|
|
103
|
+
? `import(${json(app + '?v=' + version)})`
|
|
104
|
+
: `new Promise((resolve,reject)=>{const script=document.createElement('script');script.src=new URL(${json(app + '?v=' + version)},import.meta.url).href;script.dataset.package=${json(manifest.package)};script.onload=()=>resolve(window.DsmPackageApps?.[${json(manifest.package)}]);script.onerror=reject;document.head.appendChild(script)})`;
|
|
105
|
+
const source = `import {bootEntryPage} from ${json(entryModule(manifest))};\nbootEntryPage({...${json(options)},root:document.querySelector('.dsmapp-root'),mount:async(root,ctx)=>{const app=await ${loadApp};if(typeof app?.mount!=='function')throw new Error('The UI must export mount(root, ctx)');return app.mount(root,ctx)}});`;
|
|
106
|
+
const bundled = await build({ stdin: { contents: source, resolveDir: manifest.root, sourcefile: 'synopkgland-entry.generated.js' }, bundle: true, write: false, format: 'esm', platform: 'browser', target: 'es2022', minify: true, plugins: [{ name: 'app-import', setup(api) { api.onResolve({ filter: /[?]v=/ }, args => ({ path: args.path, external: true })); } }], legalComments: 'inline' });
|
|
107
|
+
files.set('entry.js', Buffer.from(bundled.outputFiles[0].text));
|
|
108
|
+
const context = await build({ stdin: { contents: `export {createAppContext} from ${json(entryModule(manifest))}`, resolveDir: manifest.root, sourcefile: 'synopkgland-context.generated.js' }, bundle: true, write: false, format: 'esm', platform: 'browser', target: 'es2022', minify: true, legalComments: 'inline' });
|
|
109
|
+
files.set('entry-context.js', Buffer.from(context.outputFiles[0].text));
|
|
110
|
+
const css = moduleVersion ? `./${moduleVersion}/app.css` : './app.css';
|
|
111
|
+
files.set('entry.html', Buffer.from(`<!doctype html>\n<html><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, viewport-fit=cover"><meta name="synopkgland-build" content="${version}"><title>${html(name.en)}</title><link rel="icon" href="./icons/mobile-192.png?v=${version}"><link rel="stylesheet" href="${css}?v=${version}"><style>html,body,.dsmapp-root{margin:0;height:100%;min-height:100%}</style></head><body><div class="dsmapp-root"></div><script type="module" src="./entry.js?v=${version}"></script></body></html>\n`));
|
|
112
|
+
}
|
|
113
|
+
record.build = version;
|
|
114
|
+
const registered = mobileRegistration(record);
|
|
115
|
+
files.set('mobile.json', Buffer.from(JSON.stringify(registered, null, 2) + '\n'));
|
|
116
|
+
record.files = Object.fromEntries([...files].map(([path, bytes]) => [path, digest(bytes)]));
|
|
117
|
+
return { build: version, files, record };
|
|
118
|
+
}
|
|
119
|
+
/** Validate the replay inventory before using any of its paths. */
|
|
120
|
+
export function mobileRecordProblem(record) {
|
|
121
|
+
const r = record;
|
|
122
|
+
if (!r || typeof r !== 'object' || !r.files || typeof r.files !== 'object' || !r.name || typeof r.name !== 'object' || !r.name.en || Object.values(r.name).some(name => typeof name !== 'string'))
|
|
123
|
+
return 'invalid build record';
|
|
124
|
+
try {
|
|
125
|
+
readMobile(r.declaration);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return 'invalid mobile declaration';
|
|
129
|
+
}
|
|
130
|
+
if (typeof r.build !== 'string' || !/^[a-f0-9]{64}$/.test(r.build))
|
|
131
|
+
return 'invalid registration build';
|
|
132
|
+
if (r.declaration.entry === 'gateway' && ![`/webman/3rdparty/${r.package}/sso/open.cgi`, `/webman/3rdparty/${r.package}/sso/open.html`].includes(r.gatewayEntry ?? ''))
|
|
133
|
+
return 'invalid gateway entry';
|
|
134
|
+
if (r.portal && !isPortalAlias(r.portal.defaultAlias))
|
|
135
|
+
return 'invalid portal alias';
|
|
136
|
+
if (!r.files['mobile.json'] || !r.files['icons/mobile-192.png'] || !r.files['icons/mobile-512.png'] || (r.declaration.entry === 'app' && (!r.files['entry.html'] || !r.files['entry.js'] || !r.files['entry-context.js'])))
|
|
137
|
+
return 'missing registration or icon inventory';
|
|
138
|
+
for (const [path, hash] of Object.entries(r.files))
|
|
139
|
+
if (!/^(entry\.(?:html|js)|entry-context\.js|mobile\.json|icons\/mobile-(?:192|512)\.png)$/.test(path) || typeof hash !== 'string' || !/^[a-f0-9]{64}$/.test(hash))
|
|
140
|
+
return 'invalid asset inventory';
|
|
141
|
+
return undefined;
|
|
142
|
+
}
|
|
143
|
+
export function inspectMobileFiles(root, record) {
|
|
144
|
+
const invalid = mobileRecordProblem(record);
|
|
145
|
+
if (invalid)
|
|
146
|
+
return invalid;
|
|
147
|
+
for (const [path, hash] of Object.entries(record.files)) {
|
|
148
|
+
if (!existsSync(join(root, path)) || digest(readFileSync(join(root, path))) !== hash)
|
|
149
|
+
return `${path} differs from the generated build`;
|
|
150
|
+
}
|
|
151
|
+
if (JSON.stringify(JSON.parse(readFileSync(join(root, 'mobile.json'), 'utf8'))) !== JSON.stringify(mobileRegistration(record)))
|
|
152
|
+
return 'mobile.json differs from its declaration';
|
|
153
|
+
return undefined;
|
|
154
|
+
}
|
|
@@ -21,6 +21,8 @@ type Binary = {
|
|
|
21
21
|
arches?: LayoutArch[];
|
|
22
22
|
};
|
|
23
23
|
export interface NativeLayout {
|
|
24
|
+
/** Exact payload paths exempted from the SPK secret guard, never repository checks. */
|
|
25
|
+
allowSecretFiles?: string[];
|
|
24
26
|
metadata?: PackageMetadata;
|
|
25
27
|
dependencies?: PackageDependencies;
|
|
26
28
|
root: string;
|
|
@@ -4,6 +4,7 @@ import { validateMetadata, metadataInfoFields } from "../package-metadata.js";
|
|
|
4
4
|
/** Existing native products: the CLI owns archives/INFO, the project owns its layout. */
|
|
5
5
|
import { createHash } from 'node:crypto';
|
|
6
6
|
import { chmodSync, copyFileSync, existsSync, lstatSync, mkdirSync, mkdtempSync, readFileSync, readdirSync, realpathSync, rmSync, writeFileSync } from 'node:fs';
|
|
7
|
+
import { enforceRepositorySecrets, readAllowedSecretFiles } from '../secret-files.js';
|
|
7
8
|
import { tmpdir } from 'node:os';
|
|
8
9
|
import { dirname, isAbsolute, join, relative, resolve } from 'node:path';
|
|
9
10
|
import { parse } from 'yaml';
|
|
@@ -107,7 +108,9 @@ export function isNativeLayout(root) {
|
|
|
107
108
|
}
|
|
108
109
|
export function loadNativeLayout(root) {
|
|
109
110
|
try {
|
|
110
|
-
const m = object(parse(readFileSync(join(root, 'dsm-package.yaml'), 'utf8')), ['schema', 'backend', 'package', 'version', 'build', 'displayname', 'description', 'maintainer', 'metadata', 'os_min_ver', 'privilege', 'arches', 'layout', 'native', 'icon', 'reproducible', 'portal', 'dependencies']);
|
|
111
|
+
const m = object(parse(readFileSync(join(root, 'dsm-package.yaml'), 'utf8')), ['schema', 'backend', 'package', 'version', 'build', 'displayname', 'description', 'maintainer', 'metadata', 'os_min_ver', 'privilege', 'arches', 'layout', 'native', 'icon', 'reproducible', 'portal', 'dependencies', 'allow_secret_files']);
|
|
112
|
+
const allowSecretFiles = readAllowedSecretFiles(m.allow_secret_files);
|
|
113
|
+
delete m.allow_secret_files;
|
|
111
114
|
if (m.schema !== 2)
|
|
112
115
|
fail('schema 2 required; migrate schema: 1 to schema: 2 and add backend: {kind: native}');
|
|
113
116
|
const backend = object(m.backend, ['kind']);
|
|
@@ -163,7 +166,7 @@ export function loadNativeLayout(root) {
|
|
|
163
166
|
fail('toolkits require HTTPS and SHA-256');
|
|
164
167
|
}
|
|
165
168
|
}
|
|
166
|
-
return { ok: true, manifest: { ...m, root: resolve(root), native: { hook: hook(native.hook), ...(native.prepare ? { prepare: hook(native.prepare) } : {}), toolkits } } };
|
|
169
|
+
return { ok: true, manifest: { ...m, ...(allowSecretFiles ? { allowSecretFiles } : {}), root: resolve(root), native: { hook: hook(native.hook), ...(native.prepare ? { prepare: hook(native.prepare) } : {}), toolkits } } };
|
|
167
170
|
}
|
|
168
171
|
catch (error) {
|
|
169
172
|
return { ok: false, errors: [{ code: 'NATIVE_LAYOUT_INVALID', message: String(error) }] };
|
|
@@ -298,6 +301,7 @@ export function checkLayoutMetadata(root, inspection = false, packageId) {
|
|
|
298
301
|
}
|
|
299
302
|
}
|
|
300
303
|
export async function buildNativeLayout(options) {
|
|
304
|
+
enforceRepositorySecrets(options.root);
|
|
301
305
|
const loaded = loadNativeLayout(options.root);
|
|
302
306
|
if (!loaded.ok)
|
|
303
307
|
fail(loaded.errors.map(e => e.message).join('\n'));
|
|
@@ -347,7 +351,7 @@ export async function buildNativeLayout(options) {
|
|
|
347
351
|
const target = join(stage, 'payload');
|
|
348
352
|
mkdirSync(target);
|
|
349
353
|
const files = copyTree(payload, target);
|
|
350
|
-
await createReproducibleTar(target, join(stage, 'package.tgz'), { gzip: true });
|
|
354
|
+
await createReproducibleTar(target, join(stage, 'package.tgz'), { gzip: true, rejectSecrets: true, allowSecretFiles: m.allowSecretFiles });
|
|
351
355
|
rmSync(target, { recursive: true });
|
|
352
356
|
const fields = { package: m.package, version, arch: layoutInfoArch(arch), os_min_ver: m.os_min_ver, displayname: m.displayname, description: m.description, maintainer: m.maintainer, dsmuidir: 'ui', dsmappname: `SYNO.SDS.${m.package}.Instance`, startable: 'yes', thirdparty: 'yes', checksum: createHash('md5').update(readFileSync(join(stage, 'package.tgz'))).digest('hex') };
|
|
353
357
|
const deps = dependencyInfo(m.dependencies ?? { packages: [] });
|
|
@@ -357,7 +361,7 @@ export async function buildNativeLayout(options) {
|
|
|
357
361
|
writeFileSync(join(stage, 'INFO'), info.map(([k, v]) => `${k}="${v.replace(/([\\"$`])/g, '\\$1')}"\n`).join(''));
|
|
358
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 } : {}) }));
|
|
359
363
|
const output = join(outDir, `${m.package}-${version}-${arch}.spk`);
|
|
360
|
-
await createReproducibleTar(stage, output);
|
|
364
|
+
await createReproducibleTar(stage, output, { rejectSecrets: true });
|
|
361
365
|
return output;
|
|
362
366
|
}
|
|
363
367
|
finally {
|
|
@@ -52,12 +52,23 @@ export function sdkProblems(backend, frontendDir, needsSdk, cliVersion = CLI_VER
|
|
|
52
52
|
}
|
|
53
53
|
return problems;
|
|
54
54
|
}
|
|
55
|
-
/**
|
|
55
|
+
/** Resolve tilde pins from installed bytes or a matching lockfile; file: reads its package.json. */
|
|
56
56
|
function frontendSdkVersion(frontendDir) {
|
|
57
57
|
const pkg = readJson(join(frontendDir, "package.json"));
|
|
58
58
|
const spec = pkg?.dependencies?.[SDK_PACKAGE] ?? pkg?.devDependencies?.[SDK_PACKAGE];
|
|
59
59
|
if (typeof spec !== "string")
|
|
60
60
|
return undefined;
|
|
61
|
+
const tilde = /^~(\d+)\.(\d+)\.(\d+)$/.exec(spec);
|
|
62
|
+
if (tilde) {
|
|
63
|
+
const installed = readJson(join(frontendDir, "node_modules", SDK_PACKAGE, "package.json"));
|
|
64
|
+
const lock = readJson(join(frontendDir, "package-lock.json"));
|
|
65
|
+
const declared = lock?.packages?.[""];
|
|
66
|
+
const lockedSpec = declared?.dependencies?.[SDK_PACKAGE] ?? declared?.devDependencies?.[SDK_PACKAGE];
|
|
67
|
+
const version = installed?.version ?? (lockedSpec === spec ? lock?.packages?.[`node_modules/${SDK_PACKAGE}`]?.version : undefined);
|
|
68
|
+
const resolved = typeof version === "string" ? /^(\d+)\.(\d+)\.(\d+)$/.exec(version) : null;
|
|
69
|
+
return { spec, version: resolved && resolved[1] === tilde[1] && resolved[2] === tilde[2] &&
|
|
70
|
+
Number(resolved[3]) >= Number(tilde[3]) ? version : undefined };
|
|
71
|
+
}
|
|
61
72
|
if (!spec.startsWith("file:"))
|
|
62
73
|
return { spec, version: spec };
|
|
63
74
|
const version = readJson(join(resolve(frontendDir, spec.slice("file:".length)), "package.json"))?.version;
|
package/dist/standalone/spk.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { renderMobileAssets } from './mobile.js';
|
|
1
2
|
import { requireDaemonNoFileActivation } from "./daemon-nofile.js";
|
|
2
3
|
import { gatewayIngressOwnershipSupported } from './gateway-ingress.js';
|
|
3
4
|
import { portDefaults, portInstallSteps, writePortPayload } from "./install-ports.js";
|
|
@@ -90,7 +91,8 @@ export async function assembleStandaloneSpk(options) {
|
|
|
90
91
|
mkdirSync(appDir, { recursive: true });
|
|
91
92
|
const moduleUi = hasSdkWindow(manifest) && existsSync(join(appDir, MODULE_UI_ENTRY));
|
|
92
93
|
const uiDigest = uiTreeDigest(appDir, moduleUi);
|
|
93
|
-
const
|
|
94
|
+
const mobile = await renderMobileAssets(manifest, uiDigest, moduleUi ? uiDigest : undefined);
|
|
95
|
+
const assetVersion = mobile?.build ?? uiDigest.slice(0, 12);
|
|
94
96
|
const moduleVersion = moduleUi ? uiDigest : undefined;
|
|
95
97
|
if (moduleVersion) {
|
|
96
98
|
const snapshot = join(uiRoot, "app-snapshot");
|
|
@@ -98,6 +100,8 @@ export async function assembleStandaloneSpk(options) {
|
|
|
98
100
|
mkdirSync(appDir);
|
|
99
101
|
renameSync(snapshot, join(appDir, moduleVersion));
|
|
100
102
|
}
|
|
103
|
+
for (const [path, bytes] of mobile?.files ?? [])
|
|
104
|
+
writeFile(join(appDir, path), bytes);
|
|
101
105
|
const login = manifest.portal
|
|
102
106
|
? loginStyleAssets(manifest.loginStyle)
|
|
103
107
|
: undefined;
|
|
@@ -250,6 +254,8 @@ export async function assembleStandaloneSpk(options) {
|
|
|
250
254
|
}));
|
|
251
255
|
const packageTgz = join(staging, "package.tgz");
|
|
252
256
|
await createReproducibleTar(join(staging, "package"), packageTgz, {
|
|
257
|
+
rejectSecrets: true,
|
|
258
|
+
allowSecretFiles: manifest.allowSecretFiles,
|
|
253
259
|
gzip: true,
|
|
254
260
|
});
|
|
255
261
|
rmSync(join(staging, "package"), { recursive: true, force: true });
|
|
@@ -258,6 +264,7 @@ export async function assembleStandaloneSpk(options) {
|
|
|
258
264
|
.digest("hex");
|
|
259
265
|
writeFile(join(staging, "sdk-package.json"), JSON.stringify({
|
|
260
266
|
schema: 2,
|
|
267
|
+
...(mobile ? { mobile: mobile.record } : {}),
|
|
261
268
|
dependencies: packageDependencies(manifest),
|
|
262
269
|
...(moduleVersion ? { ui_module: moduleVersion } : {}),
|
|
263
270
|
...(manifest.installSettings ? { installSettings: manifest.installSettings } : {}),
|
|
@@ -355,7 +362,7 @@ export async function assembleStandaloneSpk(options) {
|
|
|
355
362
|
});
|
|
356
363
|
writePackageCenterIcons(staging, icons);
|
|
357
364
|
mkdirSync(dirname(options.outputPath), { recursive: true });
|
|
358
|
-
await createReproducibleTar(staging, options.outputPath);
|
|
365
|
+
await createReproducibleTar(staging, options.outputPath, { rejectSecrets: true });
|
|
359
366
|
}
|
|
360
367
|
finally {
|
|
361
368
|
rmSync(staging, { recursive: true, force: true });
|
package/dist/validate.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { upstreamAttributionWarnings } from './upstream-attribution.js';
|
|
2
|
+
import { allowedSecretFileWarnings, repositorySecretFiles } from "./secret-files.js";
|
|
2
3
|
import { existsSync } from "node:fs";
|
|
3
4
|
import { join } from "node:path";
|
|
4
5
|
import { getErrorCode } from "./error-registry.js";
|
|
@@ -26,18 +27,25 @@ export function validateProject(project, _options = {}) {
|
|
|
26
27
|
const policy = loaded.ok && "capabilities" in loaded.manifest
|
|
27
28
|
? manifestPolicyProblem(loaded.manifest)
|
|
28
29
|
: undefined;
|
|
29
|
-
const
|
|
30
|
+
const secrets = repositorySecretFiles(project.root);
|
|
31
|
+
const warnings = [...upstreamAttributionWarnings(project.root), ...secrets.filter(item => item.severity === "warning"),
|
|
32
|
+
...(loaded.ok ? allowedSecretFileWarnings(loaded.manifest.allowSecretFiles) : [])];
|
|
33
|
+
const problems = [
|
|
34
|
+
...(loaded.ok ? (policy ? [policy] : []) : loaded.errors).map(error => ({
|
|
35
|
+
...error,
|
|
36
|
+
span: { file, line: 1, column: 1 },
|
|
37
|
+
suggestion: getErrorCode(error.code)?.suggestion ??
|
|
38
|
+
"Correct the schema-2 declaration; see the SDK Compose support matrix.",
|
|
39
|
+
})),
|
|
40
|
+
...secrets.filter(item => item.severity === "error"),
|
|
41
|
+
];
|
|
30
42
|
return problems.length
|
|
31
43
|
? {
|
|
32
44
|
ok: false,
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
span: { file, line: 1, column: 1 },
|
|
36
|
-
suggestion: getErrorCode(error.code)?.suggestion ??
|
|
37
|
-
"Correct the schema-2 declaration; see the SDK Compose support matrix.",
|
|
38
|
-
})),
|
|
45
|
+
warnings,
|
|
46
|
+
errors: problems,
|
|
39
47
|
}
|
|
40
|
-
: { ok: true, errors: [], warnings: [...
|
|
48
|
+
: { ok: true, errors: [], warnings: [...warnings,
|
|
41
49
|
...(loaded.ok && 'ctl' in loaded.manifest && loaded.manifest.ctl?.enabled && !loaded.manifest.ctl.registry ? [{
|
|
42
50
|
code: 'CTL_LEGACY_COMMANDS_DEPRECATED', severity: 'warning',
|
|
43
51
|
span: { file, line: 1, column: 1 },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synopackageland/cli",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.49.0",
|
|
4
4
|
"description": "Syno Package Land Developer Kit CLI",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"bin": {
|
|
@@ -31,17 +31,18 @@
|
|
|
31
31
|
"test:scripts": "node --test scripts/test/gate.test.mjs scripts/test/release.test.mjs scripts/test/pack-docker.test.mjs scripts/test/npm-pack.test.mjs scripts/test/executor-bump.test.mjs scripts/test/smoke-exports.test.mjs scripts/test/parallel.test.mjs scripts/test/scaffold-matrix.test.mjs scripts/test/frontend-deps.test.mjs scripts/test/docker-gate.test.mjs scripts/test/gate-plan.test.mjs scripts/test/gates.test.mjs && python3 scripts/test/npm-publish.py",
|
|
32
32
|
"gates": "bash scripts/ci/gates.sh",
|
|
33
33
|
"gates:fast": "bash scripts/ci/gates.sh",
|
|
34
|
-
"prepublishOnly": "npm run build",
|
|
34
|
+
"prepublishOnly": "npm run build && node --input-type=module -e 'import {enforceRepositorySecrets} from \"./dist/secret-files.js\"; enforceRepositorySecrets(process.cwd())'",
|
|
35
35
|
"gates:full": "bash scripts/ci/gates.sh --full",
|
|
36
|
-
"test:basic": "node --import tsx --test test/schema.test.ts test/standalone-manifest.test.ts test/native-arch.test.ts test/archive-inventory.test.ts",
|
|
36
|
+
"test:basic": "node --import tsx --test test/schema.test.ts test/standalone-manifest.test.ts test/native-arch.test.ts test/archive-inventory.test.ts test/secret-files.test.ts",
|
|
37
37
|
"check:dsm-contract": "node scripts/check-dsm-api-contract.mjs",
|
|
38
38
|
"check:dsm-hub": "node scripts/check-dsm-api-hub.mjs"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
41
|
"@napi-rs/keyring": "^2.1.1",
|
|
42
|
-
"@synopackageland/templates": "~0.
|
|
42
|
+
"@synopackageland/templates": "~0.41.0",
|
|
43
43
|
"ajv": "^8.17.1",
|
|
44
44
|
"commander": "^13.1.0",
|
|
45
|
+
"esbuild": "^0.28.2",
|
|
45
46
|
"json-canonicalize": "^3.0.1",
|
|
46
47
|
"re2js": "2.9.1",
|
|
47
48
|
"tar": "^7.4.3",
|
|
@@ -1112,18 +1112,18 @@
|
|
|
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": "d45c74e012a6953ad17cd0135f97f3ba98b37d4ff8b2fb60ef0a894f15ce0d64",
|
|
1116
1116
|
"ctl/cli.ts": "a582aff3a048c14884b4ffae03efdb50142ca7d769feae97f0f9b0d11d66d6da",
|
|
1117
|
-
"ctl/external.ts": "
|
|
1117
|
+
"ctl/external.ts": "f66490ded838f934a0cf373f284418d4d02441edc8c8365066fc45b898ba81dc",
|
|
1118
1118
|
"ctl/flows.ts": "76a7b8c2e3991687e693797b7e02aae5c7e35d9a2f07220f1d223354c38e3469",
|
|
1119
|
-
"ctl/service.ts": "
|
|
1119
|
+
"ctl/service.ts": "c5bb01257db9f65f31db3fcd3d0b78c4a84a967cb96de43fa587934ea175826c",
|
|
1120
1120
|
"deploy/deploy.ts": "3f593232e8e95d029f1389d16a13127baf51ef1f381211d8be2fde5c46759f1b",
|
|
1121
1121
|
"deploy/identity.ts": "4822596d8b6e170f8aa4293bd877eb27bc549cb16f720b364e543d8037bd8071",
|
|
1122
1122
|
"deploy/plan.ts": "1f772811ca963bdf863462a256d8e810c151e096a55a91a753bd5bf855921536",
|
|
1123
1123
|
"deploy/spk-version.ts": "407a79491ffac8d00ecb9b056ab0b352e08bf6142871fa46f302fd217f98fc24",
|
|
1124
1124
|
"e2e/certificates.ts": "e9801e5f4d326d31c3c281e5106f34138493e26cd7f0ad2b1dd3f6a566832389",
|
|
1125
|
-
"e2e/dsm.ts": "
|
|
1126
|
-
"error-registry.ts": "
|
|
1125
|
+
"e2e/dsm.ts": "66c9b3f6d907a8069202c5f88f13f8051c07b099de66d3ebce5de51c6374201f",
|
|
1126
|
+
"error-registry.ts": "ca7e717532a97d1bcd3a27018c2f036e8b19691338679f2651e49cf7e19e6e57",
|
|
1127
1127
|
"host/catalog-install.ts": "df27409d835a901658dae7c2048c9028c2dc886e17575fe9189e88ae705c0fd2",
|
|
1128
1128
|
"host/compose-project-recovery.ts": "c76efa505f8ba14f50a8705b63d0f9f8a022b70505fe6a5f5976146afae17532",
|
|
1129
1129
|
"host/container-pull.ts": "d85314dd265f7609ab1fda87e23cce0fa81165baeeaf79a792d7bb6dc10338e3",
|
|
@@ -1152,7 +1152,7 @@
|
|
|
1152
1152
|
"runtime/operation-budget.ts": "126a43530d9c659f2667ba10b2c7f718373f1e6a3b97374c2eaa8b75b942ce06",
|
|
1153
1153
|
"runtime/sdk-timeouts.ts": "1b56ac9717d10d604b110120149e363b5bcb57218796acf98a64b6b4fba68339",
|
|
1154
1154
|
"standalone/install-ports.ts": "1b317071803f127b600a5324ac7952d28db9910af25210f139bbf430a3c135ee",
|
|
1155
|
-
"standalone/manifest.ts": "
|
|
1155
|
+
"standalone/manifest.ts": "09682c938fb308df95c2da0dfac88578c54237b9fb38b98d0a950f9da4f0407b",
|
|
1156
1156
|
"standalone/portal-window.ts": "bc0a16a73ff4de4acee5f5820dbad48c709a6c53d48670a98d8b23f9009650c9",
|
|
1157
1157
|
"standalone/root-window.ts": "2b3f8f3dd1c77963d9485b16739a953ecedf2019939b4b5b608cd7ac61232231"
|
|
1158
1158
|
},
|
|
@@ -7,7 +7,17 @@
|
|
|
7
7
|
"required": ["schema"],
|
|
8
8
|
"properties": {
|
|
9
9
|
"schema": {"type": "integer", "const": 2},
|
|
10
|
-
"
|
|
10
|
+
"allow_secret_files": {
|
|
11
|
+
"description": "Exact payload-relative files exempted from the SPK secret guard only. Do not use for credentials; prefer generating keys at install/runtime. Every entry must exist when packing.",
|
|
12
|
+
"type": "array",
|
|
13
|
+
"uniqueItems": true,
|
|
14
|
+
"items": {
|
|
15
|
+
"type": "string",
|
|
16
|
+
"pattern": "^(?![\\s\\S]*(?:^|/)\\.{1,2}(?:/|$))[^/\\\\*?\\[\\]{}:\\u0000-\\u001f\\u007f]+(?:/[^/\\\\*?\\[\\]{}:\\u0000-\\u001f\\u007f]+)*$(?![\\s\\S])"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
"identity_gateway": {"$ref": "identity-gateway.v1.schema.json"},
|
|
20
|
+
"mobile": {"$ref": "mobile.v1.schema.json"}
|
|
11
21
|
},
|
|
12
22
|
"additionalProperties": true
|
|
13
23
|
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "mobile.v1.schema.json",
|
|
4
|
+
"title": "Mobile registration",
|
|
5
|
+
"type": "object",
|
|
6
|
+
"additionalProperties": false,
|
|
7
|
+
"required": ["entry"],
|
|
8
|
+
"properties": {
|
|
9
|
+
"entry": {"enum": ["app", "gateway"]},
|
|
10
|
+
"name": {"type": "string", "minLength": 1, "maxLength": 128, "pattern": "^[^\\u0000-\\u001f\\u007f]+$"},
|
|
11
|
+
"icon": {"type": "string", "minLength": 1},
|
|
12
|
+
"start": {"$ref": "#/definitions/route"},
|
|
13
|
+
"capabilities": {"type": "array", "uniqueItems": true, "items": {"enum": ["download", "open-external", "camera"]}},
|
|
14
|
+
"intake": {
|
|
15
|
+
"type": "object", "additionalProperties": false, "required": ["route", "accept"],
|
|
16
|
+
"properties": {
|
|
17
|
+
"route": {"$ref": "#/definitions/route"},
|
|
18
|
+
"accept": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"oneOf": [
|
|
19
|
+
{"type": "object", "additionalProperties": false, "required": ["kind"], "properties": {"kind": {"const": "text"}}},
|
|
20
|
+
{"type": "object", "additionalProperties": false, "required": ["kind", "schemes"], "properties": {
|
|
21
|
+
"kind": {"const": "url"}, "schemes": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "pattern": "^[a-z][a-z0-9+.-]*$"}}
|
|
22
|
+
}},
|
|
23
|
+
{"type": "object", "additionalProperties": false, "required": ["kind", "types"], "properties": {
|
|
24
|
+
"kind": {"const": "file"}, "types": {"type": "array", "minItems": 1, "uniqueItems": true, "items": {"type": "string", "pattern": "^(?:[a-zA-Z0-9!#$&^_.+-]+/(?:[a-zA-Z0-9!#$&^_.+-]+|\\*)|\\.[a-zA-Z0-9][a-zA-Z0-9._+-]*)$"}},
|
|
25
|
+
"max_bytes": {"type": "integer", "minimum": 1, "maximum": 8388608}
|
|
26
|
+
}}
|
|
27
|
+
]}}
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"status": {"type": "boolean"},
|
|
31
|
+
"min_shell": {"type": "integer", "minimum": 1}
|
|
32
|
+
},
|
|
33
|
+
"definitions": {"route": {"type": "string", "pattern": "^/(?!/)[^\\u0000-\\u0020\\u007f\\\\]*$"}}
|
|
34
|
+
}
|
package/skills/SKILL.md
CHANGED
|
@@ -5,6 +5,19 @@ description: Initialize, extend, check, build, inspect, and deploy Synology appl
|
|
|
5
5
|
|
|
6
6
|
# Independent Synology SPKs
|
|
7
7
|
|
|
8
|
+
For mobile registration, entry pages and native-shell capabilities, read
|
|
9
|
+
[reference/mobile.md](reference/mobile.md).
|
|
10
|
+
|
|
11
|
+
Keep own-App local secrets in root `.env`, protected by the generated
|
|
12
|
+
`.gitignore`. Upstream forks use `synology/.env`, never the fork root.
|
|
13
|
+
Commit only `.env.example`. Run `synopkgland check`: tracked secrets inside the
|
|
14
|
+
App project directory fail; tracked upstream files outside it are left alone.
|
|
15
|
+
Untracked local secrets anywhere in the repo warn without repository ignore rules,
|
|
16
|
+
including those hidden only by `.git/info/exclude`. Build and release/publish
|
|
17
|
+
enforce the same check. Public certificates and environment templates are allowed;
|
|
18
|
+
SPK packing rejects local environment files, npm tokens and private-key PEM blocks.
|
|
19
|
+
See [reference/create.md](reference/create.md).
|
|
20
|
+
|
|
8
21
|
The CLI installs templates through its declared npm dependency range. A templates patch needs only a
|
|
9
22
|
templates release; npm install/update selects a patch in that minor line. The CLI
|
|
10
23
|
uses the locally installed templates and reads their SDK pin for defaults; it
|
|
@@ -28,6 +28,24 @@ Compose 只使用 schema-2 `dsm-package.yaml`,上游原樣保留,SDK planner
|
|
|
28
28
|
|
|
29
29
|
## 建置與檢查
|
|
30
30
|
|
|
31
|
+
Keep own-App local secrets in root `.env`, protected by the generated `.gitignore`.
|
|
32
|
+
Upstream forks use `synology/.env`, never the fork root or upstream ignore files.
|
|
33
|
+
Commit only `.env.example`, without real secrets.
|
|
34
|
+
`synopkgland check` fails tracked secrets only inside the App project directory;
|
|
35
|
+
tracked upstream files outside it are left alone. Untracked local secrets anywhere
|
|
36
|
+
in the repository warn unless repository `.gitignore` rules protect them.
|
|
37
|
+
Local `.git/info/exclude` and global ignore rules do not protect a clone.
|
|
38
|
+
Build and release/publish enforce the same check. The environment template names
|
|
39
|
+
`.env.example`, `.env.sample`, `.env.template`, `.env.dist` and `.env.defaults`
|
|
40
|
+
are allowed, as are public certificates and CA bundles.
|
|
41
|
+
Repository checks identify sensitive `.pem`, `.key` and `.p12` files by private-key
|
|
42
|
+
PEM content or a binary PKCS#12 envelope, rather than their extensions alone.
|
|
43
|
+
SPK packing rejects non-template `.env`/`.env.*` files, `.npmrc` containing
|
|
44
|
+
`_authToken`, and private-key PEM blocks under any filename. Keys generated at
|
|
45
|
+
runtime are outside the packaged payload.
|
|
46
|
+
|
|
47
|
+
To deliberately package a file blocked by the SPK secret guard, declare top-level `allow_secret_files: ["share/demo/server.key"]` in `dsm-package.yaml`. Each entry must exactly match an existing payload file relative to `package.tgz` when packing; globs, directories and missing files fail the build. Every build warns for each allowed file, and `check` lists the declarations even before build-generated files exist. This applies only to the payload; tracked-secret checks and metadata checks remain enforced. Don't use this for credentials; prefer generating keys at install/runtime.
|
|
48
|
+
|
|
31
49
|
執行 check、build、inspect,再看 deploy --dry-run。Go CGI 每包驗證 DSM session,root-ops 能力只提供固定管理員核准工作。容器必須使用已建置映像;不支援的特權 host 存取、secret/config 與 build stanza 會拒絕。
|
|
32
50
|
|
|
33
51
|
安裝前讀 deploy.md。需要資料或登入時讀 files.md、identity.md。
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
# Mobile Apps
|
|
2
|
+
|
|
3
|
+
Declare `mobile` in `dsm-package.yaml`. Both `admin-only` and `app-privilege`
|
|
4
|
+
Apps may register. DSM entry and backend permissions still apply to every request.
|
|
5
|
+
A portal is optional; without it the App stays on its entry URL.
|
|
6
|
+
|
|
7
|
+
```yaml
|
|
8
|
+
mobile:
|
|
9
|
+
entry: app
|
|
10
|
+
name: Download Hub
|
|
11
|
+
# icon: assets/mobile.png # package icon by default
|
|
12
|
+
start: /
|
|
13
|
+
capabilities: [download, open-external]
|
|
14
|
+
intake:
|
|
15
|
+
route: /add
|
|
16
|
+
accept:
|
|
17
|
+
- {kind: url, schemes: [http, https, magnet, ed2k]}
|
|
18
|
+
- {kind: text}
|
|
19
|
+
- {kind: file, types: [application/x-bittorrent, .torrent], max_bytes: 524288}
|
|
20
|
+
status: false
|
|
21
|
+
min_shell: 1
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
`entry: app` requires an SDK UI exporting `mount(root, ctx)` as `app.module.js`,
|
|
25
|
+
or a classic `app.js` registering `window.DsmPackageApps[packageId]`.
|
|
26
|
+
Install `@synopackageland/sdk` with its `/entry` export in the UI build directory
|
|
27
|
+
or project root. The CLI bundles this installed SDK into `entry.js`; the NAS
|
|
28
|
+
never loads npm or a CDN. Plain UI Apps can install the SDK at the project root.
|
|
29
|
+
Run the normal UI build before `synopkgland check` and `synopkgland build`.
|
|
30
|
+
|
|
31
|
+
`entry: gateway` requires `identity_gateway` and registers the existing gateway
|
|
32
|
+
entry URL for upstream UIs that support phones. It generates registration and
|
|
33
|
+
icons; it keeps the gateway's sign-in flow and does not generate an SDK entry page.
|
|
34
|
+
|
|
35
|
+
`name` defaults to `displayname`. Localize it with
|
|
36
|
+
`i18n.info.<locale>.mobile_name`; localized `displayname` is the fallback.
|
|
37
|
+
`icon` follows the package icon rules: a square PNG of at least 256 px, or a
|
|
38
|
+
directory with `icon_256.png`. Build generates 192 and 512 px mobile PNGs.
|
|
39
|
+
`start` and `intake.route` must be local routes beginning with a single `/`.
|
|
40
|
+
Capabilities are `download`, `open-external`, and `camera`. Intake accepts `url`
|
|
41
|
+
(with schemes), `text`, and `file` (with MIME types or extensions). Optional file
|
|
42
|
+
`max_bytes` must be between 1 and 8 MiB. Unknown fields, kinds and capabilities fail
|
|
43
|
+
check. `status` is accepted for the later launcher-status protocol; v1 does not
|
|
44
|
+
invoke it. `min_shell` is a positive integer, default 1.
|
|
45
|
+
|
|
46
|
+
Build writes `ui/app/mobile.json`, mobile icons and, for SDK Apps, `entry.html`
|
|
47
|
+
and bundled `entry.js` into the SPK only. The generated DSM window loads
|
|
48
|
+
`entry-context.js` and passes its existing session, host and privileged adapters
|
|
49
|
+
to the same SDK context builder. One immutable content hash appears in
|
|
50
|
+
the entry build meta tag, `bootEntryPage.build`, registration, and every generated
|
|
51
|
+
entry script, stylesheet and icon URL. Module UI assets retain their immutable
|
|
52
|
+
snapshot directory. SDK boot owns token acquisition, non-aborting hedges, portal
|
|
53
|
+
probing, language fallback and the package-specific identity cache.
|
|
54
|
+
|
|
55
|
+
App-owned `app.status` should use SDK Go `api.AppStatusHandler`, registered via
|
|
56
|
+
`api.HandleRequest`, or return `package`, `version`, `user`, `admin`, `lang` and
|
|
57
|
+
`locale`. Supply trusted DSM language hints when available. Empty hints use the
|
|
58
|
+
browser locale; generated Go handlers include these fallback fields.
|
|
59
|
+
|
|
60
|
+
Run `synopkgland inspect dist/<package>-<version>-<arch>.spk`. It replays the
|
|
61
|
+
recorded registration and asset digests; a changed or missing `mobile.json`,
|
|
62
|
+
entry page, bundle or icon produces `MOBILE_INVALID`. This checks build consistency,
|
|
63
|
+
not authenticity of an unsigned SPK. The mobile shell discovers the registration;
|
|
64
|
+
real-device and APK validation are separate from CLI checks.
|