@synopackageland/cli 0.52.4 → 0.52.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,18 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.52.6
4
+
5
+ - Report executor approval as not-required in build and inspect for SDK packages without an executor (#192)
6
+ - Warn when DSM-window Vue sources combine OS color-scheme detection with a dynamic color-scheme binding
7
+ - Warn when standalone identity is enabled without an Application Portal declaration
8
+ - Clarify that standalone login and DSM-cookie reuse require HTTPS and belong outside DSM windows; document HTTP recovery and light DSM window themes
9
+
10
+ ## 0.52.5
11
+
12
+ - Fix first executor approval from mobile App entries by resuming DSM's native Noise session and signing protected requests
13
+ - Honor each DSM API's advertised request format, including JSON-encoded string parameters and password confirmation tokens
14
+ - Keep the desktop AppWindow transport and existing administrator, password confirmation and task verification checks
15
+
3
16
  ## 0.52.4
4
17
 
5
18
  - Wire executor approval into mobile App entries using the same tasks, digest pins and access runtime as DSM windows
@@ -46,6 +46,8 @@ export const ERROR_REGISTRY = {
46
46
  INIT_UPSTREAM_INVALID: { code: "INIT_UPSTREAM_INVALID", description: "The upstream repository URL is invalid.", suggestion: "Supply --upstream with an HTTPS repository URL without credentials." },
47
47
  INIT_PUBLISHER_INVALID: { code: "INIT_PUBLISHER_INVALID", description: "The attribution name or publisher URL is invalid.", suggestion: "Use plain single-line project/publisher names and an http(s) publisher URL without credentials." },
48
48
  UPSTREAM_ATTRIBUTION: { code: "UPSTREAM_ATTRIBUTION", description: "Upstream App attribution is incomplete or names the distributor as maintainer.", suggestion: "Name the original project/team or owner as maintainer; set metadata.maintainer_url to the upstream repository and metadata.distributor/distributor_url to your publisher; resolve TODOs before release." },
49
+ DSM_WINDOW_COLOR_SCHEME: { code: 'DSM_WINDOW_COLOR_SCHEME', description: 'A DSM-window Vue component combines OS theme detection with a dynamic color-scheme binding', suggestion: 'Leave color-scheme unset in DSM windows; follow OS preferences only on the App\'s own full page' },
50
+ STANDALONE_IDENTITY_WITHOUT_PORTAL: { code: 'STANDALONE_IDENTITY_WITHOUT_PORTAL', description: 'Standalone identity is enabled without an Application Portal declaration', suggestion: 'Use HTTPS-only standalone login outside DSM windows; declare portal only when an alias is needed' },
49
51
  INSTALL_SETTINGS_INVALID: { "code": "INSTALL_SETTINGS_INVALID", "description": "The installation setting declaration is invalid.", "suggestion": "Declare 1–32 lowercase identifier keys in install.settings, each with type https-origin, a plain label and an explicit boolean required; omit defaults and values." },
50
52
  INSTALL_PORT_INVALID: { code: "INSTALL_PORT_INVALID", description: "The installation port declaration or selected value is invalid", suggestion: "Enable install.ports for a declared identity gateway and choose distinct available non-reserved ports between 1024 and 65535" },
51
53
  SDK_PORT_SETTINGS_UNSUPPORTED: { code: "SDK_PORT_SETTINGS_UNSUPPORTED", description: "The selected SDK does not provide installer-selected ports", suggestion: "Pin SDK 0.38.2 or a matching supported release and rebuild with the matching CLI" },
@@ -14,7 +14,7 @@ export interface ApprovalInventory {
14
14
  }>;
15
15
  }
16
16
  export interface ApprovalDifference {
17
- retention: 'unknown' | 'eligible' | 'required';
17
+ retention: 'unknown' | 'eligible' | 'required' | 'not-required';
18
18
  permissions: 'unknown' | 'unchanged' | 'expanded' | 'review-required';
19
19
  executor_only: boolean;
20
20
  task_template_changed: boolean | null;
@@ -41,13 +41,22 @@ function inventory(r) {
41
41
  return;
42
42
  return { package: r.package, arch: r.arch, ...r.executor, anchored: true }; // inspect verifies the INFO anchor and every root payload digest.
43
43
  }
44
+ function noApproval(r) {
45
+ return r.synopkgland && r.dsm.ok && r.findings.length === 0 && Boolean(r.package && r.arch) && !r.executor && r.capabilities.every(cap => !cap.requiresAdminApproval);
46
+ }
47
+ function notRequired() {
48
+ return { retention: 'not-required', permissions: 'unchanged', executor_only: false, task_template_changed: false, root_programs: [], policy_changes: [], reason: 'No SDK administrator approval is required: this verified package has no executor or approval-requiring capability.' };
49
+ }
44
50
  export async function spkApprovalDiff(current, baseline, report) {
51
+ const nextReport = report ?? await inspectAnySpk(current);
45
52
  if (!baseline)
46
- return approvalDiff(undefined, undefined);
47
- const next = inventory(report ?? await inspectAnySpk(current));
53
+ return noApproval(nextReport) ? notRequired() : approvalDiff(undefined, undefined);
54
+ const next = inventory(nextReport);
48
55
  const old = await inspectAnySpk(baseline);
49
56
  if (!old.dsm.ok || old.findings.length)
50
57
  throw new Error('[APPROVAL_BASELINE_INVALID] Baseline SPK failed inspection: ' + [...old.findings, ...old.dsm.errors.map(e => e.message)].join('; '));
58
+ if (old.package === nextReport.package && old.arch === nextReport.arch && noApproval(old) && noApproval(nextReport))
59
+ return notRequired();
51
60
  return approvalDiff(inventory(old), next);
52
61
  }
53
62
  export function formatApprovalDiff(d) {
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Honor DSM API formats and resume Noise only when mobile approval needs it. Reuse
3
+ * the NAS libraries instead of shipping another implementation or login flow.
4
+ * The desktop keeps its injected AppWindow WebAPI channel.
5
+ */
6
+ export declare const MOBILE_APPROVAL_WEBAPI = "\nvar mobileApprovalCredential;\nfunction createMobileApprovalWebApi(ctx) {\n var formats = {};\n function url(path) {\n var base = new URL(ctx.files.endpoint);\n base.pathname = base.pathname.slice(0, base.pathname.indexOf(\"/webman/3rdparty/\") + 1);\n base.search = \"\"; base.hash = \"\";\n return new URL(path, base).href;\n }\n function failure() { return {code: \"dsm_119\"}; }\n function script(path) {\n return new Promise(function (resolve, reject) {\n var element = document.createElement(\"script\");\n var timer = setTimeout(function () { element.remove(); reject(failure()); }, ctx.requestTimeout || 300000);\n element.src = url(path);\n element.onload = function () { clearTimeout(timer); resolve(); };\n element.onerror = function () { clearTimeout(timer); element.remove(); reject(failure()); };\n document.head.appendChild(element);\n });\n }\n async function request(params, headers, json, path) {\n var body = new URLSearchParams();\n Object.keys(params).forEach(function (key) {\n var value = params[key];\n var routing = key === \"api\" || key === \"method\" || key === \"version\";\n body.set(key, (json && !routing) || typeof value !== \"string\" ? JSON.stringify(value) : value);\n });\n var response = await fetch(url(\"webapi/\" + (path || \"entry.cgi\")), {\n method: \"POST\", mode: \"same-origin\", credentials: \"same-origin\",\n redirect: \"error\", cache: \"no-store\", headers: headers, body: body,\n signal: AbortSignal.timeout(ctx.requestTimeout || 300000)\n });\n var reply = await response.json();\n if (response.ok && reply && reply.success === true) return reply.data;\n throw {code: \"dsm_\" + (reply && reply.error && reply.error.code || \"error\")};\n }\n async function credential() {\n var native = globalThis.SYNO && globalThis.SYNO.SDS && globalThis.SYNO.SDS.HandShake;\n if (native && native.cred) { await native.cred.WaitForReady(); return native.cred; }\n var stored;\n try { stored = JSON.parse(localStorage.getItem(\"lastHS\")); } catch (_) {}\n var remote = document.cookie.match(/(?:^|;\\s*)_SSID=([^;]+)/);\n // Older DSM and sessions without Noise retain their existing server checks.\n if (!remote || !stored || stored.account !== ctx.user.name || !stored.authtok) return;\n if (!mobileApprovalCredential) mobileApprovalCredential = (async function () {\n if (!globalThis.noise_c_wasm) {\n await script(\"scripts/noise/noise-c.js\");\n await script(\"scripts/noise/constants.js\");\n await script(\"scripts/noise/index.js\");\n }\n if (!globalThis.sodium) await script(\"scripts/noise/sodium.js\");\n if (!globalThis.synocredential) await script(\"scripts/synocredential.js/synocredential.min.js\");\n await globalThis.sodium.ready;\n var noise = await new Promise(function (resolve) { globalThis.noise_c_wasm(resolve); });\n var cred = new globalThis.synocredential(noise, {account: stored.account, authtok: stored.authtok});\n var params = cred.GetResumeParams({enable_syno_token: \"yes\"}, remote[1]);\n if (!params) throw failure();\n var resumed = await request(params, {\"X-SYNO-TOKEN\": ctx.files.token() || \"\"});\n if (!resumed || !resumed.kk_message) throw failure();\n // SetResumeResult's token updater belongs to the desktop's global session.\n // Keep this transport's token in its own credential headers instead.\n cred.SetResumeResult({kk_message: resumed.kk_message});\n cred.info.headers[\"X-SYNO-TOKEN\"] = resumed.synotoken\n ? encodeURIComponent(resumed.synotoken) : ctx.files.token() || \"\";\n return cred;\n })().catch(function (error) { mobileApprovalCredential = undefined; throw error; });\n return mobileApprovalCredential;\n }\n return async function (api, method, version, params) {\n if (!formats[api]) formats[api] = ctx.webApi(\"SYNO.API.Info\", \"query\", 1, {query: api}).then(function (info) {\n var entry = info && info[api];\n if (!entry || !/^[A-Za-z0-9_.-]+\\.cgi$/.test(entry.path)) throw {code: \"dsm_102\"};\n return entry;\n }).catch(function (error) { delete formats[api]; throw error; });\n var info = await formats[api];\n var protectedRequest = api === \"SYNO.Core.User.PasswordConfirm\" || api === \"SYNO.Core.EventScheduler.Root\" ||\n api === \"SYNO.Core.TaskScheduler.Root\";\n var cred = protectedRequest ? await credential() : undefined;\n // GetRequestHeaders generates a fresh hash/nonce for every request.\n return request(Object.assign({}, params, {api: api, method: method, version: version}),\n cred ? cred.GetRequestHeaders() : {\"X-SYNO-TOKEN\": ctx.files.token() || \"\"},\n info.requestFormat === \"JSON\", info.path);\n };\n}\n";
@@ -0,0 +1,91 @@
1
+ /**
2
+ * Honor DSM API formats and resume Noise only when mobile approval needs it. Reuse
3
+ * the NAS libraries instead of shipping another implementation or login flow.
4
+ * The desktop keeps its injected AppWindow WebAPI channel.
5
+ */
6
+ export const MOBILE_APPROVAL_WEBAPI = `
7
+ var mobileApprovalCredential;
8
+ function createMobileApprovalWebApi(ctx) {
9
+ var formats = {};
10
+ function url(path) {
11
+ var base = new URL(ctx.files.endpoint);
12
+ base.pathname = base.pathname.slice(0, base.pathname.indexOf("/webman/3rdparty/") + 1);
13
+ base.search = ""; base.hash = "";
14
+ return new URL(path, base).href;
15
+ }
16
+ function failure() { return {code: "dsm_119"}; }
17
+ function script(path) {
18
+ return new Promise(function (resolve, reject) {
19
+ var element = document.createElement("script");
20
+ var timer = setTimeout(function () { element.remove(); reject(failure()); }, ctx.requestTimeout || 300000);
21
+ element.src = url(path);
22
+ element.onload = function () { clearTimeout(timer); resolve(); };
23
+ element.onerror = function () { clearTimeout(timer); element.remove(); reject(failure()); };
24
+ document.head.appendChild(element);
25
+ });
26
+ }
27
+ async function request(params, headers, json, path) {
28
+ var body = new URLSearchParams();
29
+ Object.keys(params).forEach(function (key) {
30
+ var value = params[key];
31
+ var routing = key === "api" || key === "method" || key === "version";
32
+ body.set(key, (json && !routing) || typeof value !== "string" ? JSON.stringify(value) : value);
33
+ });
34
+ var response = await fetch(url("webapi/" + (path || "entry.cgi")), {
35
+ method: "POST", mode: "same-origin", credentials: "same-origin",
36
+ redirect: "error", cache: "no-store", headers: headers, body: body,
37
+ signal: AbortSignal.timeout(ctx.requestTimeout || 300000)
38
+ });
39
+ var reply = await response.json();
40
+ if (response.ok && reply && reply.success === true) return reply.data;
41
+ throw {code: "dsm_" + (reply && reply.error && reply.error.code || "error")};
42
+ }
43
+ async function credential() {
44
+ var native = globalThis.SYNO && globalThis.SYNO.SDS && globalThis.SYNO.SDS.HandShake;
45
+ if (native && native.cred) { await native.cred.WaitForReady(); return native.cred; }
46
+ var stored;
47
+ try { stored = JSON.parse(localStorage.getItem("lastHS")); } catch (_) {}
48
+ var remote = document.cookie.match(/(?:^|;\\s*)_SSID=([^;]+)/);
49
+ // Older DSM and sessions without Noise retain their existing server checks.
50
+ if (!remote || !stored || stored.account !== ctx.user.name || !stored.authtok) return;
51
+ if (!mobileApprovalCredential) mobileApprovalCredential = (async function () {
52
+ if (!globalThis.noise_c_wasm) {
53
+ await script("scripts/noise/noise-c.js");
54
+ await script("scripts/noise/constants.js");
55
+ await script("scripts/noise/index.js");
56
+ }
57
+ if (!globalThis.sodium) await script("scripts/noise/sodium.js");
58
+ if (!globalThis.synocredential) await script("scripts/synocredential.js/synocredential.min.js");
59
+ await globalThis.sodium.ready;
60
+ var noise = await new Promise(function (resolve) { globalThis.noise_c_wasm(resolve); });
61
+ var cred = new globalThis.synocredential(noise, {account: stored.account, authtok: stored.authtok});
62
+ var params = cred.GetResumeParams({enable_syno_token: "yes"}, remote[1]);
63
+ if (!params) throw failure();
64
+ var resumed = await request(params, {"X-SYNO-TOKEN": ctx.files.token() || ""});
65
+ if (!resumed || !resumed.kk_message) throw failure();
66
+ // SetResumeResult's token updater belongs to the desktop's global session.
67
+ // Keep this transport's token in its own credential headers instead.
68
+ cred.SetResumeResult({kk_message: resumed.kk_message});
69
+ cred.info.headers["X-SYNO-TOKEN"] = resumed.synotoken
70
+ ? encodeURIComponent(resumed.synotoken) : ctx.files.token() || "";
71
+ return cred;
72
+ })().catch(function (error) { mobileApprovalCredential = undefined; throw error; });
73
+ return mobileApprovalCredential;
74
+ }
75
+ return async function (api, method, version, params) {
76
+ if (!formats[api]) formats[api] = ctx.webApi("SYNO.API.Info", "query", 1, {query: api}).then(function (info) {
77
+ var entry = info && info[api];
78
+ if (!entry || !/^[A-Za-z0-9_.-]+\\.cgi$/.test(entry.path)) throw {code: "dsm_102"};
79
+ return entry;
80
+ }).catch(function (error) { delete formats[api]; throw error; });
81
+ var info = await formats[api];
82
+ var protectedRequest = api === "SYNO.Core.User.PasswordConfirm" || api === "SYNO.Core.EventScheduler.Root" ||
83
+ api === "SYNO.Core.TaskScheduler.Root";
84
+ var cred = protectedRequest ? await credential() : undefined;
85
+ // GetRequestHeaders generates a fresh hash/nonce for every request.
86
+ return request(Object.assign({}, params, {api: api, method: method, version: version}),
87
+ cred ? cred.GetRequestHeaders() : {"X-SYNO-TOKEN": ctx.files.token() || ""},
88
+ info.requestFormat === "JSON", info.path);
89
+ };
90
+ }
91
+ `;
@@ -13,6 +13,7 @@ import { CLI_VERSION } from '../cli-version.js';
13
13
  import { isPortalAlias } from '../portal/alias.js';
14
14
  import { renderExecutorApproval } from './executor-approval.js';
15
15
  import { CALL_RETRY_RUNTIME } from './call-retry.js';
16
+ import { MOBILE_APPROVAL_WEBAPI } from './mobile-approval-webapi.js';
16
17
  const schema = JSON.parse(readFileSync(new URL('../../schema/mobile.v1.schema.json', import.meta.url), 'utf8'));
17
18
  const ajv = new Ajv({ allErrors: true });
18
19
  const validate = ajv.compile(schema);
@@ -83,12 +84,14 @@ export async function renderMobileAssets(manifest, uiDigest, moduleVersion) {
83
84
  ? `var executorApproval = {};
84
85
  ${renderExecutorApproval('executorApproval', manifest)}
85
86
  ${CALL_RETRY_RUNTIME}
86
- function attachExecutor(ctx) {
87
+ ${MOBILE_APPROVAL_WEBAPI}
88
+ function attachExecutor(ctx, desktopWebApi) {
87
89
  ctx.call = createRetryCall(ctx.call);
90
+ var send = desktopWebApi || createMobileApprovalWebApi(ctx);
88
91
  ctx.executor = executorApproval.createExecutorAccess({
89
92
  user: function () { return {name: ctx.user?.name, admin: ctx.user?.isAdmin === true}; },
90
- send: ctx.webApi,
91
- confirmPassword: executorApproval.createPasswordConfirm(ctx.webApi),
93
+ send: send,
94
+ confirmPassword: executorApproval.createPasswordConfirm(send),
92
95
  call: ctx.call
93
96
  });
94
97
  return ctx;
@@ -125,7 +128,7 @@ function attachExecutor(ctx) {
125
128
  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, keepNames: true, plugins: [{ name: 'app-import', setup(api) { api.onResolve({ filter: /[?]v=/ }, args => ({ path: args.path, external: true })); } }], legalComments: 'none' });
126
129
  files.set('entry.js', Buffer.from(bundled.outputFiles[0].text));
127
130
  const contextSource = approval
128
- ? `import {createAppContext as createContext} from ${json(entryModule(manifest))};\n${approval}export function createAppContext(options) { return attachExecutor(createContext(options)); }`
131
+ ? `import {createAppContext as createContext} from ${json(entryModule(manifest))};\n${approval}export function createAppContext(options) { return attachExecutor(createContext(options), options.webApi); }`
129
132
  : `export {createAppContext} from ${json(entryModule(manifest))}`;
130
133
  const context = await build({ stdin: { contents: contextSource, resolveDir: manifest.root, sourcefile: 'synopkgland-context.generated.js' }, bundle: true, write: false, format: 'esm', platform: 'browser', target: 'es2022', minify: true, keepNames: true, legalComments: 'none' });
131
134
  files.set('entry-context.js', Buffer.from(context.outputFiles[0].text));
@@ -0,0 +1,4 @@
1
+ import type { ValidationError } from '../types.js';
2
+ import type { StandaloneManifest } from './manifest.js';
3
+ /** Advisory source heuristic, not Vue compilation or cross-file data-flow analysis. */
4
+ export declare function uiGuidanceWarnings(manifest: StandaloneManifest): ValidationError[];
@@ -0,0 +1,77 @@
1
+ import { lstatSync, readFileSync, readdirSync } from 'node:fs';
2
+ import { join, relative } from 'node:path';
3
+ import { resolvedSdkLaunch } from '../contract/app-launch.js';
4
+ import { hasSdkWindow } from './dsm-window.js';
5
+ const SKIP_DIRECTORIES = new Set(['node_modules', 'dist', 'build', 'coverage', 'vendor', 'test', 'tests', '__tests__']);
6
+ /** Advisory source heuristic, not Vue compilation or cross-file data-flow analysis. */
7
+ export function uiGuidanceWarnings(manifest) {
8
+ const warnings = [];
9
+ if (manifest.capabilities.identity === 'standalone' && !manifest.portal) {
10
+ warnings.push({
11
+ code: 'STANDALONE_IDENTITY_WITHOUT_PORTAL', severity: 'warning',
12
+ span: { file: 'dsm-package.yaml', line: 1, column: 1 },
13
+ message: 'capabilities.identity: standalone is enabled without portal; standalone sign-in requires HTTPS, including DSM-cookie reuse',
14
+ suggestion: 'Use standalone identity / --with login only for Apps opened outside a DSM window (a portal or their own tab). Remove login from DSM-window Apps; declare portal only if an alias is needed',
15
+ });
16
+ }
17
+ if (!hasSdkWindow(manifest) || resolvedSdkLaunch(manifest) !== 'dsm-window')
18
+ return warnings;
19
+ // Build cwd is the frontend source root, not the generated ui.dir output.
20
+ const sourceRoot = manifest.ui.build?.cwd ?? manifest.ui.dir;
21
+ const walk = (dir) => {
22
+ let entries;
23
+ try {
24
+ if (!lstatSync(dir).isDirectory() || lstatSync(dir).isSymbolicLink())
25
+ return;
26
+ entries = readdirSync(dir, { withFileTypes: true }).sort((a, b) => a.name.localeCompare(b.name));
27
+ }
28
+ catch {
29
+ return;
30
+ } // The source may not have been generated yet.
31
+ for (const entry of entries) {
32
+ if (entry.isSymbolicLink() || entry.name.startsWith('.'))
33
+ continue;
34
+ const path = join(dir, entry.name);
35
+ if (entry.isDirectory()) {
36
+ if (!SKIP_DIRECTORIES.has(entry.name) && path !== manifest.ui.dir)
37
+ walk(path);
38
+ }
39
+ else if (entry.isFile() && entry.name.endsWith('.vue')) {
40
+ let source;
41
+ try {
42
+ source = readFileSync(path, 'utf8');
43
+ }
44
+ catch {
45
+ continue;
46
+ }
47
+ const binding = schemeBinding(source);
48
+ if (binding === undefined)
49
+ continue;
50
+ const before = source.slice(0, binding);
51
+ warnings.push({
52
+ code: 'DSM_WINDOW_COLOR_SCHEME', severity: 'warning',
53
+ span: { file: relative(manifest.root, path).replaceAll('\\', '/'), line: before.split('\n').length, column: binding - before.lastIndexOf('\n') },
54
+ message: 'This Vue component combines a dynamic color-scheme/colorScheme binding with matchMedia(prefers-color-scheme); review it for the DSM window',
55
+ suggestion: 'Leave color-scheme unset in DSM windows: DSM draws them light. Follow prefers-color-scheme only on the App\'s own full page (portal or own tab)',
56
+ });
57
+ }
58
+ }
59
+ };
60
+ walk(sourceRoot);
61
+ return warnings;
62
+ }
63
+ function schemeBinding(source) {
64
+ // Preserve offsets for file/line diagnostics, including multiline comments.
65
+ const blank = (text) => text.replace(/[^\r\n]/g, ' ');
66
+ const uncommented = source.replace(/<!--[\s\S]*?-->/g, blank)
67
+ .replace(/(["'`])(?:\\[\s\S]|(?!\1)[^\\])*?\1|\/\*[\s\S]*?\*\/|\/\/[^\r\n]*/g, token => token.startsWith('/') ? blank(token) : token);
68
+ if (!/\bmatchMedia\s*\(\s*(["'`])\s*\(\s*prefers-color-scheme\s*:[^"'`]*\1/.test(uncommented))
69
+ return undefined;
70
+ for (const binding of uncommented.matchAll(/(?:v-bind:|:)(?:color-scheme|colorScheme)\s*=\s*(["'])([\s\S]*?)\1/g)) {
71
+ // A constant light theme does not follow the OS preference.
72
+ if (/^\s*(["'`])[\s\S]*\1\s*$/.test(binding[2]))
73
+ continue;
74
+ return binding.index;
75
+ }
76
+ return undefined;
77
+ }
package/dist/validate.js CHANGED
@@ -6,6 +6,7 @@ import { getErrorCode } from "./error-registry.js";
6
6
  import { loadStandaloneManifest } from "./standalone/manifest.js";
7
7
  import { applyUiIgnores, scanUiTree } from "./standalone/public-ui.js";
8
8
  import { hasSdkWindow } from "./standalone/dsm-window.js";
9
+ import { uiGuidanceWarnings } from "./standalone/ui-guidance.js";
9
10
  import { isNativeLayout, loadNativeLayout, } from "./standalone/native-layout.js";
10
11
  import { manifestPolicyProblem } from "./runtime/executor-policy-check.js";
11
12
  /** All shipped Compose and native projects use the schema-2 build path. */
@@ -43,6 +44,8 @@ export function validateProject(project, _options = {}) {
43
44
  ];
44
45
  if (loaded.ok) {
45
46
  const manifest = loaded.manifest;
47
+ if ('ui' in manifest)
48
+ warnings.push(...uiGuidanceWarnings(manifest));
46
49
  const roots = "ui" in manifest
47
50
  ? hasSdkWindow(manifest) ? [{ dir: manifest.ui.dir, prefix: "app/" }] : []
48
51
  : manifest.arches.map(arch => ({ dir: join(manifest.root, manifest.layout.payload.replaceAll("{arch}", arch), "ui"), prefix: "" }));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.52.4",
3
+ "version": "0.52.6",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
package/skills/SKILL.md CHANGED
@@ -416,11 +416,16 @@ Apps requiring `/` cannot use ingress.
416
416
 
417
417
  ## HTTPS 與舊 DSM token
418
418
 
419
- 不是每個 App 都需要 HTTPS,很多 App 用 HTTP 就夠。一般 CRUD、設定或檔案類
420
- App 不要預設強制 HTTPS。只有使用 secure context 能力(`getUserMedia`、
419
+ 使用 DSM session、未啟用 standalone identity 的 DSM 視窗 App,一般 CRUD、設定或檔案操作
420
+ 可以使用 HTTP,不要預設強制 HTTPS。只有使用 secure context 能力(`getUserMedia`、
421
421
  剪貼簿讀寫、Service Worker、WebCrypto `subtle` 等)、瀏覽器 Extension 或外部
422
422
  裝置配對,或 App 的嚴格 Origin 驗證確實要求 HTTPS 時,才明確啟用限制。
423
423
 
424
+ `identity: standalone`/`--with login` 則只給 DSM 視窗外開啟的 App(portal 或自己的分頁),
425
+ 密碼/OTP 登入與 DSM cookie 重用一律只走 HTTPS,App session cookie 保持 Secure。
426
+ DSM 視窗 App 不要加 login。HTTP 頁面仍可開啟,以可關閉的 Callout 說明限制,
427
+ 並用 `readDsmHttpsURL` 提供一鍵前往 HTTPS;詳見 [identity](reference/identity.md)。
428
+
424
429
  要求 HTTPS 的 App 應回專屬碼 `https_required`,不可混成 `NOT_AUTHENTICATED`
425
430
  或 `session_required`,否則重新登入也無法解決。可選用 Go
426
431
  `api.RequireSecureOrigin(request)`;它不取代 session、同源或權限檢查。
@@ -9,7 +9,7 @@ common reads and writes, rather than stopping at status commands.
9
9
  先選擇 `native-go`(Go CGI + DSM 視窗)、`native-python`/`native-node`/`native-rust`(同一個 App,backend 換成 Python、Node.js(TypeScript)或 Rust)、`binary`(預建服務程式)或 `compose`(上游容器)。`compose` 產生 schema-2 的上游 Compose 範例與 DSM 差異宣告,`--from <compose.yaml>` 匯入現有 Compose。
10
10
 
11
11
  ```sh
12
- synopkgland init -t native-go --with files,jobs,login --package MyApp my-app
12
+ synopkgland init -t native-go --with files,jobs --package MyApp my-app
13
13
  synopkgland init -t native-python --with jobs,delegate my-py-app
14
14
  synopkgland init -t binary service
15
15
  synopkgland init -t compose --from ./compose.yaml upstream-app
@@ -54,7 +54,9 @@ To deliberately package a file blocked by the SPK secret guard, declare top-leve
54
54
 
55
55
  native-go 與 binary 使用 `dsm-package.yaml` 的 `schema: 2`,backend 寫 `kind: go, dir: backend` 或 `kind: binary, files: {x86_64: prebuilt/api-x86_64}`。
56
56
  `--with files,jobs,login,root-ops,delegate` 分別宣告 `capabilities.files: session`、`jobs: true`、`identity: standalone`、`rootOps: true`、`delegate: {operations: [files.moveFromStaging], destinations: [save], lifetime: until-revoked, scope: install-selected}`。jobs 可寫 `{worker: sha256-v1}`,與 daemon 互斥;delegate 隱含 worker 並可與 daemon 共存;admin/normal 都以本人 UID 執行。binary/compose 不支援 files/jobs/login/delegate。
57
- 既有 native-go 專案用 `synopkgland add files jobs login`;已存在能力回報 no-op。overlay 檔案已有不同內容或 stub 被改動時,add 拒絕並列出衝突;不修改業務 routes 或 App.vue。
57
+ `--with login`/`add login` 宣告 `capabilities.identity: standalone`,只適用於在 DSM 視窗外開啟的 App(portal 或自己的分頁);DSM 視窗 App 不要加。Standalone identity 的密碼/OTP 登入及 DSM cookie 重用都只走 HTTPS,App session cookie 必須保持 Secure。HTTP 頁面可以開啟,但須以可關閉的 Callout 說明原因,並用 `readDsmHttpsURL` 提供一鍵前往 HTTPS,不要靜默停用登入控制項。需要 Application Portal 別名時才宣告 `portal`;自己的分頁不強制需要別名。
58
+
59
+ 既有 native-go 專案用 `synopkgland add files jobs`;已存在能力回報 no-op。overlay 檔案已有不同內容或 stub 被改動時,add 拒絕並列出衝突;不修改業務 routes 或 App.vue。
58
60
  check、inspect、build、deploy、status 支援 `--json`,stdout 只有單一 JSON 物件,錯誤包含 code、message、hint;進度在 stderr。
59
61
 
60
62
  rootOps 與 delegate 已共用管理員 PasswordConfirm 核准的 protected executor、boot/control tasks;精確 task readback 與 digest health 一致才 ready;policy(operations、scope、root 腳本)變更須重核准,policy 不變的 executor 更新會自動 repin,install-selected 的 scope 需管理員確認一次。Vue App 只在 SDK 的 ExecutorSettings 核准;plain UI 由 DSM 視窗面板核准,兩者都在面板內輸入密碼並走 PasswordConfirm。native 產品另可明確 opt-in `@synopackageland/sdk/native` 的 runtime,不與 generated executor tasks 混用。SDK off stub 與 routes_test.go 的預設 policy scaffold 只有內容仍等於 bundled base 時才會替換;App 自訂版本拒絕。
@@ -11,18 +11,25 @@ for migration and build binding.
11
11
 
12
12
  Entry: omit `entry` for legacy access; `entry: admin-only` admits administrators only and is the floor of every route: SDK routes a capability adds (files, jobs, portal, delegate, rootOps) refuse ordinary users with `admin_required`, the launcher is hidden, and an app route marked `authenticated` or `public` in permissions.json fails validate/build with `STANDALONE_ENTRY_WIDENED` (only the public `identity: standalone` login routes stay public; they admit no one by themselves). The SPK records the mode in `sdk-package.json`; `inspect` prints it and flags `ENTRY_LAUNCHER_MISMATCH`; `entry: app-privilege` also admits accounts DSM Application Privileges allows for `SYNO.SDS.<package>.Instance` (native-go only, needs an `authenticated` route). DSM evaluates user/group/everyone rules, allow/deny precedence and IP ranges; one CGI check covers every route, failures refuse with `app_privilege_denied`, and decisions are cached at most 30 seconds. DSM's install default allows administrators only, so declaring or upgrading never opens the app to everyone. DSM keeps those rules after uninstall and applies them again to a later install under the same name: an App with the executor (rootOps or delegate) removes them automatically at uninstall (failures go to the system log entry `synopkgland-executor`); a no-privilege App never uses root, so an administrator removes them in Control Panel > Application Privileges. The delegate executor applies the same entry rule to every protected and producer move: once DSM no longer allows a user, new moves under that user's still-valid grant are refused (`APP_DENIED`, grant invalidated); files already saved stay. Guard global settings in shared routes with Go `api.RequireAdmin(caller)` (`admin_required`); the frontend `ctx.user?.isAdmin` only hides controls.
13
13
 
14
- I capability: init --with login or add login enables Go-native standalone identity and Vue login. Same-host DSM cookies can be reused across ports after backend verification. Missing cookies use an HTTPS DSM account/password/OTP fallback; passwords and DSM credentials are not persisted. Plain UI is unsupported. App sessions last at most 15 minutes; sensitive operations revalidate live DSM cookies and local UID. Password-only sessions permit only basic app.status reads. Missing revalidation returns session_revalidation_required; files return dsm_session_required. Sign in to DSM on the same hostname. Web Station portal/proxy acceptance remains pending.
14
+ I capability: `init --with login` or `add login` declares `capabilities.identity: standalone` and enables Go-native standalone identity and Vue login. Use it only for Apps opened outside a DSM window (a portal or their own tab); DSM-window Apps must not add login. Standalone identity is HTTPS-only: both DSM-cookie bootstrap (including Continue with DSM) and account/password/OTP sign-in require HTTPS. The App session cookie is Secure. Same-host DSM cookies can be reused across ports only over HTTPS after backend verification. Missing cookies use the HTTPS DSM account/password/OTP fallback; passwords and DSM credentials are not persisted. Plain UI is unsupported. App sessions last at most 15 minutes; sensitive operations revalidate live DSM cookies and local UID. Password-only sessions permit only basic app.status reads. Missing revalidation returns session_revalidation_required; files return dsm_session_required. Sign in to DSM on the same hostname. Web Station portal/proxy acceptance remains pending.
15
15
 
16
16
  B files needs the current user's DSM session. A jobs processes owner-bound private copies as the package account without administrator setup. Neither App identity nor login alone grants offline File Station access.
17
17
 
18
18
  ## HTTPS and stale DSM tokens
19
19
 
20
- HTTP is sufficient for many CRUD, settings and file Apps. Require HTTPS only
21
- when the App needs secure context browser features, pairing or a strict secure
22
- Origin policy. Return `https_required`, separate from authentication failures,
23
- and render `identityCopy(locale).httpsTitle` / `errors.https_required` with a
24
- way to reopen through HTTPS. Go `api.RequireSecureOrigin(request)` is opt-in
25
- and supplements the existing origin/session/permission checks.
20
+ Apps using the DSM session inside a DSM window can use HTTP for CRUD, settings
21
+ and files unless they need secure context browser features, pairing or a strict
22
+ secure Origin policy. Go `api.RequireSecureOrigin(request)` is opt-in for these
23
+ Apps and supplements the existing origin/session/permission checks.
24
+
25
+ Standalone identity (`identity: standalone` / `--with login`) always requires
26
+ HTTPS for sign-in and DSM-cookie reuse; this does not depend on
27
+ `RequireSecureOrigin`. Never send passwords over HTTP or relax the Secure
28
+ session cookie. Allow the HTTP page to open and explain `https_required` in a
29
+ dismissible Callout, with a one-click HTTPS action using `readDsmHttpsURL`;
30
+ do not silently disable all sign-in controls. Keep this separate from
31
+ authentication failures and use `identityCopy(locale).httpsTitle` /
32
+ `errors.https_required`.
26
33
 
27
34
  Only administrators may call `readDsmPorts(ctx)` to find `dms_https`;
28
35
  `readDsmHttpsURL(ctx, location.href)` provides this guard and a DSM link.
@@ -58,6 +58,7 @@ do not guess APIs or copy a version-specific component inventory.
58
58
  front. Below 600px of viewport width the UI turns them into bottom sheets.
59
59
  Keep the default `app` bounds outside DSM windows (standalone web, Portal,
60
60
  previews).
61
+ - In a DSM window, leave `color-scheme` / `colorScheme` unset: DSM draws it light. Follow `prefers-color-scheme` only on the App's own full page (portal or own tab).
61
62
  - Import only `@synopackageland/ui/themes/dsm7-embedded.css` for the template.
62
63
  The standalone `theme.css` and `dsm7.css` entrypoints affect the host page.
63
64
  - Set a unique `app.config.idPrefix` for every independent Vue app before