@synopackageland/cli 0.48.20 → 0.48.22

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,16 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.48.22
4
+
5
+ - Recognize generated nginx restart and native Portal INFO fields during inspection without hiding unknown-field warnings
6
+ - Document sandboxed plugin resources, gateway entry choices, token adapter headers, daemon environment and self-update limits
7
+ - Explain upstream-only web UIs, plain fork scaffolding, icons and installer-owned ports; include the linked packaging guides in the npm package
8
+
9
+ ## 0.48.21
10
+
11
+ - ctl and MCP return App results and errors exactly as the App sent them; values that match request parameters are no longer replaced with `<redacted>`, so public fields such as `admin` stay intact
12
+ - Diagnostic logs mask only exactly named secret fields
13
+
3
14
  ## 0.48.20
4
15
 
5
16
  - Add optional App testing guidance, from fast local unit and ctl registry contracts through local package checks, real-NAS ctl, deterministic UI tests and optional AI steps
@@ -5,7 +5,6 @@ import { CtlStore } from './store.js';
5
5
  import { CtlClient } from './service.js';
6
6
  import { canonicalOrigin, createRequest } from './transport.js';
7
7
  import { nasOptions } from '../nas/options.js';
8
- import { SensitiveOutput } from './redaction.js';
9
8
  const LIMIT = 1048576;
10
9
  const PROTOCOL = /^[a-z][a-z0-9-]{0,63}$/;
11
10
  const METHOD = /^[a-z][a-z0-9_]*(\.[a-z][a-z0-9_]*)+$/;
@@ -110,7 +109,6 @@ export class ExternalClient {
110
109
  if (app.payload.transport.auth !== 'dsm-session')
111
110
  fail('CTL_EXTERNAL_TRANSPORT', 'External callers require the DSM session transport.');
112
111
  const pins = { package: { id: pkg.id, version: pkg.version }, descriptionSha256: app.sha256 };
113
- const output = new SensitiveOutput({ carriers: [session.token, session.cookie, ...session.cookie.split(';').map(part => part.slice(part.indexOf('=') + 1).trim())] }, { type: 'object', properties: { carriers: { writeOnly: true } } });
114
112
  const invoke = async (request) => {
115
113
  await assertCurrent();
116
114
  // The App must verify these pins and revision in its dispatch boundary,
@@ -128,7 +126,7 @@ export class ExternalClient {
128
126
  };
129
127
  const catalog = validateCatalog(await invoke({ protocol, action: 'describe' }));
130
128
  if (input.action === 'describe')
131
- return output.clean(catalog);
129
+ return catalog;
132
130
  if (catalog.revision !== input.revision)
133
131
  fail('CTL_EXTERNAL_REVISION', 'External tool revision changed.');
134
132
  const tool = catalog.tools.find(tool => tool._meta.method === input.method);
@@ -136,12 +134,11 @@ export class ExternalClient {
136
134
  fail('CTL_EXTERNAL_METHOD', 'Method is not an external tool.');
137
135
  if (!ajv.validate(tool.inputSchema, input.arguments))
138
136
  fail('CTL_EXTERNAL_INPUT', 'Arguments do not match the current tool schema.', 3);
139
- const sensitive = new SensitiveOutput(input.arguments, tool.inputSchema);
140
137
  // Exactly one call attempt. Errors, lost replies and invalid results never replay it.
141
138
  const result = await invoke(input);
142
139
  if (!ajv.validate(tool.outputSchema, result))
143
140
  fail('CTL_EXTERNAL_RESULT', 'External result does not match its schema.', 5);
144
- return output.clean(sensitive.clean(result, tool.outputSchema));
141
+ return result;
145
142
  }
146
143
  }
147
144
  export async function runExternal(argv, io = {}) {
@@ -1,15 +1,7 @@
1
1
  import type { Descriptor, Operation } from './descriptor.js';
2
- import { CtlError } from './errors.js';
3
2
  type Schema = Record<string, any> | boolean | undefined;
4
3
  export declare const REDACTED = "<redacted>";
5
4
  export declare function redactValue<T>(value: T, schema: Schema, root?: Schema, onSecret?: (value: unknown) => void): T;
6
5
  export declare function publicOperation(operation: Operation): Operation;
7
6
  export declare function publicDescriptor(description: Descriptor): Descriptor;
8
- export declare class SensitiveOutput {
9
- private readonly secrets;
10
- constructor(params: unknown, schema: Schema);
11
- private remember;
12
- clean<T>(value: T, schema?: Schema): T;
13
- error(error: unknown): CtlError;
14
- }
15
7
  export {};
@@ -1,4 +1,3 @@
1
- import { CtlError, ctlError } from './errors.js';
2
1
  import { schemaPattern } from './pattern.js';
3
2
  export const REDACTED = '<redacted>';
4
3
  function reference(root, ref) {
@@ -150,68 +149,3 @@ export function publicDescriptor(description) {
150
149
  commands: Object.fromEntries(Object.entries(description.payload.commands).map(([id, operation]) => [id, publicOperation(operation)])),
151
150
  } };
152
151
  }
153
- // Redact copies of known secret values even when an App repeats them in a result
154
- // under another key, a job ID, or an error string. Requests keep their originals.
155
- export class SensitiveOutput {
156
- secrets = new Set();
157
- constructor(params, schema) { redactValue(params, schema, schema, value => this.remember(value)); }
158
- remember(value) {
159
- if (typeof value === 'string') {
160
- if (!value || value === REDACTED)
161
- return;
162
- this.secrets.add(value);
163
- this.secrets.add(encodeURIComponent(value));
164
- try {
165
- const url = new URL(value);
166
- if (['http:', 'https:'].includes(url.protocol)) {
167
- for (const part of [url.username, url.password, ...url.searchParams.values()])
168
- if (part)
169
- this.secrets.add(part);
170
- }
171
- }
172
- catch { /* Not a URL. */ }
173
- }
174
- else if (value && typeof value === 'object') {
175
- for (const [key, child] of Object.entries(value)) {
176
- if (!Array.isArray(value))
177
- this.remember(key);
178
- this.remember(child);
179
- }
180
- }
181
- else if (value !== undefined && value !== null)
182
- this.secrets.add(String(value));
183
- }
184
- clean(value, schema) {
185
- const redacted = redactValue(value, schema, schema, secret => this.remember(secret));
186
- const secrets = [...this.secrets].sort((a, b) => b.length - a.length);
187
- const text = (input) => {
188
- if (input === REDACTED)
189
- return input;
190
- // Keep replacements separate from remaining text. This also handles large
191
- // upload/base64 values without compiling them into a regular expression.
192
- let parts = [input];
193
- for (const secret of secrets)
194
- parts = parts.flatMap(part => {
195
- if (part === null)
196
- return [null];
197
- return part.split(secret).flatMap((chunk, index) => index ? [null, chunk] : [chunk]);
198
- });
199
- return parts.map(part => part === null ? REDACTED : part).join('');
200
- };
201
- const walk = (input) => {
202
- if (typeof input === 'string')
203
- return text(input);
204
- if (Array.isArray(input))
205
- return input.map(walk);
206
- if (input && typeof input === 'object')
207
- return Object.fromEntries(Object.entries(input).map(([key, child]) => [this.secrets.has(key) ? REDACTED : key, walk(child)]));
208
- return input !== null && this.secrets.has(String(input)) ? REDACTED : input;
209
- };
210
- return walk(redacted);
211
- }
212
- error(error) {
213
- const original = ctlError(error);
214
- const safe = this.clean({ message: original.message, hint: original.hint, allowed: original.allowed, plan: original.plan });
215
- return new CtlError(original.code, safe.message, safe.hint, original.exitCode, safe.allowed, safe.plan);
216
- }
217
- }
@@ -2,7 +2,6 @@ import { CtlError, ctlError, errorData } from './errors.js';
2
2
  import { APP_COOKIE, CTL_TIMEOUT_MS, createRequest } from './transport.js';
3
3
  import { DESCRIPTION_METHOD, validateDescriptor, ajv } from './descriptor.js';
4
4
  import { runFlow } from './flows.js';
5
- import { SensitiveOutput } from './redaction.js';
6
5
  import { localFile, transferRequest } from './transfers.js';
7
6
  import { selectApp, selectOperation, operationInput, requestPlan, confirmOperation } from './input.js';
8
7
  export async function boundedMap(items, limit, fn) { const output = new Array(items.length); let next = 0; await Promise.all(Array.from({ length: Math.min(limit, items.length) }, async () => { while (next < items.length) {
@@ -132,52 +131,46 @@ export class CtlClient {
132
131
  const app = this.selectApp(listing, name);
133
132
  const { id, operation } = selectOperation(app, path);
134
133
  const params = operationInput(operation, args, options.stdin, `run: synopkgland ctl ${name} ${operation.cli.join(' ')} --host ${this.host.name} --help`);
135
- const output = new SensitiveOutput(params, operation.paramsSchema);
136
134
  if (operation.flow.type === 'job') {
137
135
  this.until = undefined;
138
136
  this.jobRequestBudget = options.timeoutMs ?? operation.flow.timeoutMs ?? CTL_TIMEOUT_MS;
139
137
  }
138
+ const plan = requestPlan(app, id, params);
139
+ if (operation.flow.type === 'upload')
140
+ localFile(params[operation.flow.fileParam]);
141
+ confirmOperation(operation, !!options.yes, !!options.dryRun, plan);
142
+ if (options.dryRun)
143
+ return { dryRun: true, request: plan };
144
+ const session = await this.store.session(this.host);
145
+ let appSession = session;
146
+ if (app.payload.transport.auth === 'dsm-app-session') {
147
+ const boot = await this.request(app.payload.transport.path, { method: 'identity.session', params: { bootstrap: true } }, session);
148
+ // The transport adapter adds only validated, path-scoped App cookies for this call.
149
+ if (boot?.success !== true)
150
+ throw new CtlError('CTL_APP_SESSION', 'App session bootstrap failed; HTTPS is required.', `run: synopkgland host show ${this.host.name}`, 5);
151
+ appSession = this.appCookieSession(session, boot);
152
+ }
140
153
  try {
141
- const plan = requestPlan(app, id, params);
142
- if (operation.flow.type === 'upload')
143
- localFile(params[operation.flow.fileParam]);
144
- confirmOperation(operation, !!options.yes, !!options.dryRun, plan);
145
- if (options.dryRun)
146
- return { dryRun: true, request: plan };
147
- const session = await this.store.session(this.host);
148
- let appSession = session;
149
- if (app.payload.transport.auth === 'dsm-app-session') {
150
- const boot = await this.request(app.payload.transport.path, { method: 'identity.session', params: { bootstrap: true } }, session);
151
- // The transport adapter adds only validated, path-scoped App cookies for this call.
152
- if (boot?.success !== true)
153
- throw new CtlError('CTL_APP_SESSION', 'App session bootstrap failed; HTTPS is required.', `run: synopkgland host show ${this.host.name}`, 5);
154
- appSession = this.appCookieSession(session, boot);
155
- }
156
- try {
157
- const invoke = async (method, input) => {
158
- if (!app.payload.bindings[method])
159
- throw new CtlError('CTL_METHOD_NOT_ALLOWED', 'Flow method is not allowlisted.', 'Refresh the API description.', 4);
160
- const response = await this.request(app.payload.transport.path, { method, params: input }, appSession, options.signal);
161
- if (response?.success !== true) {
162
- const code = String(response?.error?.code ?? 'invalid_response');
163
- throw new CtlError(['admin_required', 'app_privilege_denied'].includes(code) ? 'CTL_PERMISSION_DENIED' : 'CTL_APP_ERROR', `App rejected operation (${code}).`, 'Check command permissions and App state.', ['admin_required', 'app_privilege_denied'].includes(code) ? 4 : 5);
164
- }
165
- return response.data;
166
- };
167
- const result = await runFlow(operation.flow, params, invoke, { wait: options.wait, signal: options.signal, timeoutMs: this.remaining(options.timeoutMs ?? CTL_TIMEOUT_MS),
168
- ndjson: (method, input) => transferRequest(appSession, app.payload.transport.path, method, input, { trust: this.store.trust(this.host), timeoutMs: this.remaining(options.timeoutMs ?? CTL_TIMEOUT_MS) }),
169
- upload: (method, input, flow) => transferRequest(appSession, app.payload.transport.path, method, {}, { trust: this.store.trust(this.host), timeoutMs: this.remaining(options.timeoutMs ?? CTL_TIMEOUT_MS), file: { path: String(input[flow.fileParam]), parent: String(input[flow.parentParam]), name: String(input[flow.nameParam]) } }) });
170
- if (operation.resultSchema && !ajv.validate(operation.resultSchema, result))
171
- throw new CtlError('CTL_RESPONSE_INVALID', 'Result does not match command schema.', 'Check the App version.', 5);
172
- return output.clean(result, operation.resultSchema);
173
- }
174
- finally {
175
- if (app.payload.transport.auth === 'dsm-app-session')
176
- await this.request(app.payload.transport.path, { method: 'identity.logout', params: {} }, appSession);
177
- }
154
+ const invoke = async (method, input) => {
155
+ if (!app.payload.bindings[method])
156
+ throw new CtlError('CTL_METHOD_NOT_ALLOWED', 'Flow method is not allowlisted.', 'Refresh the API description.', 4);
157
+ const response = await this.request(app.payload.transport.path, { method, params: input }, appSession, options.signal);
158
+ if (response?.success !== true) {
159
+ const code = String(response?.error?.code ?? 'invalid_response');
160
+ throw new CtlError(['admin_required', 'app_privilege_denied'].includes(code) ? 'CTL_PERMISSION_DENIED' : 'CTL_APP_ERROR', `App rejected operation (${code}).`, 'Check command permissions and App state.', ['admin_required', 'app_privilege_denied'].includes(code) ? 4 : 5);
161
+ }
162
+ return response.data;
163
+ };
164
+ const result = await runFlow(operation.flow, params, invoke, { wait: options.wait, signal: options.signal, timeoutMs: this.remaining(options.timeoutMs ?? CTL_TIMEOUT_MS),
165
+ ndjson: (method, input) => transferRequest(appSession, app.payload.transport.path, method, input, { trust: this.store.trust(this.host), timeoutMs: this.remaining(options.timeoutMs ?? CTL_TIMEOUT_MS) }),
166
+ upload: (method, input, flow) => transferRequest(appSession, app.payload.transport.path, method, {}, { trust: this.store.trust(this.host), timeoutMs: this.remaining(options.timeoutMs ?? CTL_TIMEOUT_MS), file: { path: String(input[flow.fileParam]), parent: String(input[flow.parentParam]), name: String(input[flow.nameParam]) } }) });
167
+ if (operation.resultSchema && !ajv.validate(operation.resultSchema, result))
168
+ throw new CtlError('CTL_RESPONSE_INVALID', 'Result does not match command schema.', 'Check the App version.', 5);
169
+ return result;
178
170
  }
179
- catch (error) {
180
- throw output.error(error);
171
+ finally {
172
+ if (app.payload.transport.auth === 'dsm-app-session')
173
+ await this.request(app.payload.transport.path, { method: 'identity.logout', params: {} }, appSession);
181
174
  }
182
175
  }
183
176
  appCookieSession(session, body) { if (typeof body[APP_COOKIE] !== 'string' || !body[APP_COOKIE])
@@ -1,5 +1,4 @@
1
1
  import type { InstalledPackageState } from './catalog-install.js';
2
- /** Diagnostic text is untrusted and can contain daemon URLs or echoed credentials. */
3
2
  export declare function maskDiagnostic(text: string): string;
4
3
  export declare function savePullFailure(origin: string, packageId: string, message?: string): void;
5
4
  export declare function packageDiagnostics(packageId: string, state: InstalledPackageState | undefined, origin: string): Record<string, unknown>;
@@ -2,23 +2,24 @@ import { createHash } from 'node:crypto';
2
2
  import { mkdirSync, readFileSync, renameSync, writeFileSync, rmSync } from 'node:fs';
3
3
  import { homedir } from 'node:os';
4
4
  import { join } from 'node:path';
5
- /** Diagnostic text is untrusted and can contain daemon URLs or echoed credentials. */
5
+ // Logs redact these complete field names only, never matching a secret value
6
+ // against unrelated values or public response keys.
7
+ const secretName = /^(?:password|passwd|token|synotoken|sid|_sid|authorization|cookie|set-cookie)$/i;
6
8
  export function maskDiagnostic(text) {
7
9
  return text.replace(/https?:\/\/[^\s"'<>]+/gi, value => {
8
10
  try {
9
11
  const url = new URL(value);
10
- if (!url.username && !url.password && !url.search && !url.hash)
11
- return value;
12
12
  url.username = '';
13
13
  url.password = '';
14
- url.search = '';
15
- url.hash = '';
14
+ for (const key of [...url.searchParams.keys()])
15
+ if (secretName.test(key))
16
+ url.searchParams.set(key, '<redacted>');
16
17
  return url.href;
17
18
  }
18
19
  catch {
19
- return '<redacted URL>';
20
+ return value;
20
21
  }
21
- }).replace(/\b(password|passwd|token|synotoken|_sid|authorization|cookie|set-cookie)\s*[:=]\s*[^\r\n]+/gi, '$1=<redacted>');
22
+ }).replace(/(^|[\s{,])(["']?)(password|passwd|token|synotoken|sid|_sid|authorization|cookie|set-cookie)\2\s*[:=]\s*[^\r\n]+/gim, '$1$2$3$2=<redacted>');
22
23
  }
23
24
  function pathFor(origin, packageId) {
24
25
  const key = createHash('sha256').update(new URL(origin).origin + '\0' + packageId).digest('hex');
@@ -50,7 +51,7 @@ function readPullFailure(origin, packageId) {
50
51
  }
51
52
  export function packageDiagnostics(packageId, state, origin) {
52
53
  const clean = (value) => typeof value === 'string' ? maskDiagnostic(value) : Array.isArray(value) ? value.map(clean)
53
- : value && typeof value === 'object' ? Object.fromEntries(Object.entries(value).map(([key, v]) => [key, /password|passwd|token|sid|authorization|cookie/i.test(key) ? '<redacted>' : clean(v)])) : value;
54
+ : value && typeof value === 'object' ? Object.fromEntries(Object.entries(value).map(([key, v]) => [key, secretName.test(key) ? '<redacted>' : clean(v)])) : value;
54
55
  const worker = clean(state?.error?.workerMsg ?? []);
55
56
  const messages = (value) => typeof value === 'string' ? [value] : Array.isArray(value) ? value.flatMap(messages)
56
57
  : value && typeof value === 'object' ? Object.values(value).flatMap(messages) : [];
@@ -6,13 +6,13 @@
6
6
  /** INFO Necessary Fields. */
7
7
  export declare const REQUIRED_INFO_FIELDS: readonly ["package", "version", "os_min_ver", "description", "arch", "maintainer"];
8
8
  /** INFO Optional Fields, without the `displayname_<lang>` and `description_<lang>` families. */
9
- export declare const OPTIONAL_INFO_FIELDS: readonly ["displayname", "maintainer_url", "distributor", "distributor_url", "support_url", "support_center", "model", "exclude_arch", "checksum", "adminport", "adminurl", "adminprotocol", "dsmuidir", "dsmappname", "dsmapppage", "dsmapplaunchname", "checkport", "startable", "ctl_stop", "ctl_uninstall", "precheckstartstop", "helpurl", "beta", "report_url", "install_reboot", "install_dep_packages", "install_conflict_packages", "install_break_packages", "install_replace_packages", "install_dep_services", "start_dep_services", "extractsize", "support_conf_folder", "install_type", "silent_install", "silent_upgrade", "silent_uninstall", "auto_upgrade_from", "offline_install", "thirdparty", "os_max_ver", "support_move", "exclude_model", "use_deprecated_replace_mechanism", "install_on_cold_storage"];
9
+ export declare const OPTIONAL_INFO_FIELDS: readonly ["displayname", "maintainer_url", "distributor", "distributor_url", "support_url", "support_center", "model", "exclude_arch", "checksum", "adminport", "adminurl", "adminprotocol", "dsmuidir", "dsmappname", "dsmapppage", "dsmapplaunchname", "checkport", "startable", "ctl_stop", "ctl_uninstall", "precheckstartstop", "helpurl", "beta", "report_url", "install_reboot", "install_dep_packages", "install_conflict_packages", "install_break_packages", "install_replace_packages", "install_dep_services", "start_dep_services", "extractsize", "support_conf_folder", "install_type", "silent_install", "silent_upgrade", "silent_uninstall", "auto_upgrade_from", "offline_install", "thirdparty", "os_max_ver", "support_move", "exclude_model", "use_deprecated_replace_mechanism", "install_on_cold_storage", "startstop_restart_services", "instuninst_restart_services"];
10
10
  /**
11
11
  * Fields outside the guide's list that are still expected: `changelog` is
12
12
  * shown by Package Center and used by first-party packages; the others are
13
- * written by this SDK and ignored by DSM.
13
+ * SDK metadata, including the native layout's declared Portal alias.
14
14
  */
15
- export declare const EXTRA_INFO_FIELDS: readonly ["changelog", "synopkgland_executor_sha256", "spk_land_metadata"];
15
+ export declare const EXTRA_INFO_FIELDS: readonly ["changelog", "synopkgland_executor_sha256", "synopkgland_portal_alias", "spk_land_metadata"];
16
16
  /** Optional fields whose value is "yes" or "no". */
17
17
  export declare const BOOLEAN_INFO_FIELDS: readonly ["support_center", "checkport", "startable", "ctl_stop", "ctl_uninstall", "precheckstartstop", "beta", "install_reboot", "support_conf_folder", "silent_install", "silent_upgrade", "silent_uninstall", "offline_install", "thirdparty", "support_move", "use_deprecated_replace_mechanism", "install_on_cold_storage"];
18
18
  /** Language codes of `displayname_<lang>` and `description_<lang>`. */
@@ -15,14 +15,14 @@ export const OPTIONAL_INFO_FIELDS = [
15
15
  "install_replace_packages", "install_dep_services", "start_dep_services", "extractsize", "support_conf_folder",
16
16
  "install_type", "silent_install", "silent_upgrade", "silent_uninstall", "auto_upgrade_from", "offline_install",
17
17
  "thirdparty", "os_max_ver", "support_move", "exclude_model", "use_deprecated_replace_mechanism",
18
- "install_on_cold_storage",
18
+ "install_on_cold_storage", "startstop_restart_services", "instuninst_restart_services",
19
19
  ];
20
20
  /**
21
21
  * Fields outside the guide's list that are still expected: `changelog` is
22
22
  * shown by Package Center and used by first-party packages; the others are
23
- * written by this SDK and ignored by DSM.
23
+ * SDK metadata, including the native layout's declared Portal alias.
24
24
  */
25
- export const EXTRA_INFO_FIELDS = ["changelog", "synopkgland_executor_sha256", "spk_land_metadata"];
25
+ export const EXTRA_INFO_FIELDS = ["changelog", "synopkgland_executor_sha256", "synopkgland_portal_alias", "spk_land_metadata"];
26
26
  /** Optional fields whose value is "yes" or "no". */
27
27
  export const BOOLEAN_INFO_FIELDS = [
28
28
  "support_center", "checkport", "startable", "ctl_stop", "ctl_uninstall", "precheckstartstop", "beta",
@@ -0,0 +1,162 @@
1
+ # App entry and explicit API registration
2
+
3
+ `entry: admin-only` admits verified DSM administrators before any App handler,
4
+ including a public route, batch member, streamed response, upload or download.
5
+ `entry: app-privilege` admits verified sessions allowed by DSM Application
6
+ Privileges, including administrators. Without `entry`, existing route permissions
7
+ and anonymous public access remain in effect.
8
+
9
+ `check` refuses an administrator-only App with App methods marked `public` or
10
+ `authenticated` (`STANDALONE_ENTRY_WIDENED`). Use `administrators`, or choose the
11
+ entry mode that describes the intended audience. The SDK's four immutable
12
+ identity ceremony operations remain public to establish or dispose of a session;
13
+ Apps cannot add their own exception.
14
+
15
+ Explicit entry cannot combine with public gateway access or public upstream
16
+ access. Permanent/optional passthrough with entry must be contained in static
17
+ `identity_gateway.upstream_auth_paths`. Provider-only OIDC without App entry
18
+ retains its separate DSM issuer admission.
19
+
20
+ ## Upstream-authenticated paths
21
+
22
+ ```yaml
23
+ entry: admin-only
24
+ identity_gateway:
25
+ # Keep the App's existing sdk, mode, upstream, listen and adapter fields.
26
+ upstream_auth_paths: [/rest, /share]
27
+ passthrough: [/rest, /share]
28
+ ```
29
+
30
+ `upstream_auth_paths` accepts 1-16 nonoverlapping absolute path prefixes, each at
31
+ most 512 characters, using URL unreserved characters and `/`. Empty/root paths,
32
+ dot segments, double slashes, percent escapes, backslashes, query/fragment
33
+ delimiters, regex and wildcards are rejected. `/_sso` and `/_spl` are reserved.
34
+ Matching is case-sensitive and respects segment boundaries: `/rest` and `/rest/`
35
+ match `/rest` and descendants, never `/restore` or `/REST`. Requests are decoded
36
+ once before matching; ambiguous traversal and encoded separators fail closed.
37
+
38
+ These prefixes proxy directly to the upstream without DSM entry checks or trusted
39
+ identity injection. DSM/SDK session cookies and identity headers are stripped;
40
+ upstream tokens, cookies, bodies, queries and responses are preserved. Normal
41
+ proxy forwarding headers, readiness, upload budgets and blocked Share activation
42
+ still apply. Upstream auth owns CSRF and WebSocket checks on listed paths.
43
+ Optional passthrough retains its default-off switch and stream cancellation.
44
+ Other paths retain the full entry gate, including uploads and WebSockets.
45
+
46
+ This field applies only to upstream gateway traffic. It cannot mark an SDK RPC
47
+ method or exempt a custom HTTP handler from the AST audit or `permissions.json`.
48
+ The CLI requires an SDK with `UpstreamAuthPathsVersion = 1`; it binds the entry,
49
+ access, upstream-auth prefixes and passthrough settings into
50
+ `idgateway.expectedEntryPolicyDigest`. Changing them requires rebuilding.
51
+ Build with matching SDK and CLI releases that support operation registration.
52
+
53
+ **Security:** listed paths are only as strong as upstream authentication,
54
+ authorization, CSRF and WebSocket policy. Browser calls to the same prefixes also
55
+ use upstream auth. Share links public in the upstream remain public, and DSM
56
+ logout does not revoke upstream tokens or sessions.
57
+
58
+ ## In-process administrator calls
59
+
60
+ A package command outside CGI that already authenticated an administrator,
61
+ such as a helper daemon's `api.cgi <subcommand>`, calls
62
+ `server.InvokeAsAdministrator(ctx, user, "app.method", params)` on the App's
63
+ normal server instead of `ServeHTTP`. The audit requires a literal method
64
+ declared `administrators` in permissions.json; the SDK asks DSM whether the
65
+ account is a current administrator and refuses under CGI or inside a request.
66
+
67
+ ## Integration callbacks
68
+
69
+ Chat buttons and slash commands, Drive webhooks and third-party webhooks cannot
70
+ sign in to DSM. With a Go backend, register each with `api.HandleIntegration`
71
+ (SDK with integration support), give it the `integration` permission, and list
72
+ it in `dsm-package.yaml`:
73
+
74
+ ```yaml
75
+ integrations:
76
+ - app.chat.callback
77
+ ```
78
+
79
+ ```json
80
+ {"schema":1,"default":"administrators","methods":{"app.chat.callback":"integration"}}
81
+ ```
82
+
83
+ `check` requires the list to equal the `integration` permissions
84
+ (`STANDALONE_INTEGRATIONS_MISMATCH`), so a callback is never added by the policy
85
+ file alone. The route audit requires `api.HandleIntegration` for every
86
+ `integration` permission and the reverse, with a literal method name. Only the
87
+ callback's handler graph may build `http.HandlerFunc`. Each method joins the
88
+ bound HTTP route inventory as `?method=<method>`.
89
+
90
+ The install and upgrade wizards show the administrator every listed callback,
91
+ and `inspect` verifies those wizard files and reports `integrations`. An
92
+ `integration` method skips the DSM session and entry gate only for itself; its
93
+ handler verifies the caller and uses `api.ActAs` to act for an enabled DSM
94
+ account allowed by Application Privileges, never as an administrator. It does
95
+ not count as ordinary-user access and is allowed with `entry: admin-only`, where
96
+ `ActAs` admits no account.
97
+
98
+ ## Registration and build binding
99
+
100
+ Every App method must be declared in `operations.json`, even when its permission equals the administrator default. `ctl generate` emits `permissions.json` and runtime bindings from that registry. SDK methods use the SDK's immutable policy. Bridge method lists and discovered methods must match the generated App table.
101
+
102
+ For Go, `check` builds a small bundled standard-library syntax auditor and parses
103
+ each configured Go binary's import graph for every packaged Linux architecture,
104
+ including the background worker and local replacements. Unshipped dev commands
105
+ and tools are excluded. App code is never run. Go must be available
106
+ on the check machine. Import aliases, literal names and file-local string
107
+ constants work. Dynamic route names, constructor aliases, dot imports, Go source
108
+ symlinks, unregistered `ServeHTTP`, App-created gateway listeners and direct standard-library HTTP listeners
109
+ fail with `STANDALONE_API_REGISTRY_INVALID`.
110
+
111
+ Register business HTTP work through `api.HandleRequest`, `HandleResponse` or
112
+ `HandleStream`. The SDK also supports `api.HandleHTTP("/proxy/", "app.proxy",
113
+ handler)` in the same registry, with an authenticated or administrator method
114
+ key in the permissions table. Prefixes must be literal, disjoint full segments
115
+ ending in `/`, outside `/_sso/`, `/_spl/`, `/api/`, `/api.cgi/`, `/rpc/`,
116
+ `/webman/` and `/cgi/`.
117
+ Origin, entry, identity and permission checks precede raw dispatch. The CLI binds
118
+ the sorted prefix/method inventory; changed or removed registrations fail
119
+ startup. Raw keys cannot be invoked through RPC, batch or query transfers.
120
+
121
+ Private worker HTTP uses `ipc.ServeUnix(ctx, path, handler)` and `ipc.DialUnix`.
122
+ The CLI binds `ipc.packageID`. Only an owned mode-0600 socket directly beneath
123
+ that package's private mode-0700 `var/run` is accepted. Existing paths and
124
+ symlinks are refused. Muxes, handler functions and `ServeHTTP` implementations
125
+ must be reachable through an approved handler argument. TCP and other direct
126
+ listeners remain rejected even when they reuse an IPC handler.
127
+
128
+ Streaming and initial upgrades retain the underlying HTTP interfaces. CGI
129
+ cannot upgrade a connection; registration does not install an ingress or turn
130
+ CGI into a WebSocket server. Use an existing upgrade-capable deployment
131
+ transport; active-stream revocation remains the App's responsibility.
132
+
133
+ Keep fixed method names in the App policy. Published external dependencies
134
+ and independent executable/listening ports remain trusted package inputs; syntax
135
+ inspection is not whole-program sandboxing.
136
+
137
+ Build repeats registration validation after UI hooks. The existing permissions
138
+ digest is also linked into the SDK API server, alongside the immutable SDK
139
+ policy digest and the App entry mode. Runtime startup/description rejects a
140
+ different App policy or an undeclared App route. A lost authenticator wrapper
141
+ cannot erase the packaged administrator floor. Application-privilege builds
142
+ require a matching entry authenticator.
143
+
144
+ Entry-enabled projects must use an SDK containing the build-bound entry floor;
145
+ older SDK source is rejected. Wrappers around `dsm.EntryGate` must preserve its
146
+ `EntryMode()` interface. The package continues to run as its non-root account.
147
+
148
+ ## Existing projects
149
+
150
+ Declare every App method in `operations.json`, including administrator-only methods, with an explicit AI class. Run `ctl generate` to emit the permissions table, runtime bindings, descriptor, tools, App reference and `generated/session-retry.ts` (an effect/kind map for `createClient.sessionRetry`); run `ctl generate --check` to detect drift. Native Go, Python, Node and Rust scaffolds ship `app.status` with an administrator policy; capability policies still apply.
151
+
152
+ Replace dynamic names and custom HTTP dispatchers with fixed SDK routes.
153
+ Use `upstream_auth_paths` for client API paths that rely on upstream
154
+ authentication; retain explicit App entry on the remaining paths.
155
+ Existing accepted jobs, package lifecycle IPC and upstream-issued
156
+ tokens retain their own execution/revocation semantics.
157
+
158
+ Package-account peer protocols use `ipc.StartPackagePeerUnix` with an explicit
159
+ SO_PEERCRED authorization callback (nil denies all). Its owned 0711 directory
160
+ and 0666 socket admit connections from other packages while the callback and
161
+ per-request checks decide authority. The entry audit accepts direct calls and
162
+ rejects constructor aliases; custom listeners remain forbidden.
@@ -191,10 +191,7 @@ returning evidence afterward cannot undo an unauthorized effect.
191
191
  The CLI rereads local session/host/approval state before each external RPC. It
192
192
  does not refresh expired sessions. All errors return bounded generic text;
193
193
  upstream messages, request arguments and exception text are never echoed.
194
- Session carriers and schema-marked sensitive call values are redacted from
195
- results. The App remains responsible for its own secret-free Catalog and Result.
196
- Authentication failures exit 2, invalid input/options 3, trust/permission/revision
197
- refusals 4, contract failures 5 and network failures 6.
194
+ Responses, including errors and MCP tool results, are returned unchanged after validation. Public response keys are never renamed or removed based on secret values. Log masking uses exact secret field names only.
198
195
 
199
196
  There is exactly one mutation dispatch attempt. Timeout, interruption, invalid
200
197
  evidence/schema or oversized output may follow a committed mutation; none