@synopackageland/cli 0.48.21 → 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,11 @@
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
+
3
9
  ## 0.48.21
4
10
 
5
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
@@ -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.
package/docs/daemon.md ADDED
@@ -0,0 +1,288 @@
1
+ # Package daemon: Node runtime and same-origin ingress
2
+
3
+ A native App's `daemon` is one foreground process that the SDK's
4
+ `daemon/control` supervises as the package account. Two optional keys extend it:
5
+
6
+ ```yaml
7
+ package: MyApp
8
+ os_min_ver: 7.2-64570 # needed by ingress
9
+ daemon:
10
+ exec: server.mjs # with node: a JavaScript entry inside the payload
11
+ targets: {x86_64: daemon, aarch64: daemon}
12
+ args: [--serve]
13
+ node:
14
+ package: Node.js_v22 # Node.js_v18, Node.js_v20 or Node.js_v22
15
+ min_version: 22.19.0 # optional, same major as the package
16
+ ingress:
17
+ path: /synopkgland/MyApp/ # exact, case-sensitive package namespace
18
+ timeout: 3600 # optional; proxy read/send timeout in seconds
19
+ ```
20
+
21
+ `check` validates both keys. `daemon.backend` (below) runs the App's Go
22
+ backend itself. None of them can be combined with
23
+ `identity_gateway`, which runs its own gateway as the daemon.
24
+
25
+ ## Runtime environment and launchers
26
+
27
+ `daemon.env` contains fixed string values. Only `${SYNOPKG_PKGDEST}` and
28
+ `${SYNOPKG_PKGVAR}` expand, in environment values and arguments; shell commands,
29
+ `$(...)`, `$HOME` and arbitrary `${NAME}` substitutions are not evaluated.
30
+ The runtime supplies `PATH=/usr/bin:/bin`, `HOME=${SYNOPKG_PKGVAR}` and a private
31
+ `TMPDIR`. The manifest cannot override `HOME`, `PATH`, `TMPDIR`, loader/shell
32
+ variables or `SYNOPKG_*` system variables. Do not assume the daemon inherits
33
+ the installer's environment.
34
+
35
+ For values computed at startup, package a small native env launcher in
36
+ `daemon.targets` and select it as `daemon.exec`. It computes the required
37
+ application variables, preserves the runtime environment, then replaces itself
38
+ with the upstream using `exec` (for Go, `syscall.Exec` with explicit argv/env).
39
+ For example, a public URL may need the default-route interface rather than a
40
+ loopback or container bridge address. Use the upstream's supported env/config
41
+ contract and keep the launcher under `synology/` in a fork. Replacing the process
42
+ preserves the supervised PID and normal stop/signal behavior.
43
+
44
+ The supervisor's SHA-256 digest covers the bytes of `daemon/config.json`.
45
+ It binds its control record/socket protocol to that configuration; it does not
46
+ hash the launcher, upstream executable or payload tree at runtime. Build/SPK
47
+ inspection digests are separate. Replacing an upstream binary through its own
48
+ updater is therefore not detected by this supervisor digest. Follow
49
+ [self-updating upstream guidance](../skills/reference/upstream-fork.md#self-updating-upstreams).
50
+
51
+ ## `daemon.restart`: bounded native crash recovery
52
+
53
+ `daemon.restart` is optional. Use `mode: off` to disable crash recovery.
54
+ Omitting the object leaves restart policy to the selected SDK controller. The SDK
55
+ defaults to `always` with its shared supervision limits.
56
+
57
+ ```yaml
58
+ daemon:
59
+ exec: service
60
+ targets: {x86_64: daemon}
61
+ restart:
62
+ mode: on-failure
63
+ initial_seconds: 1
64
+ max_seconds: 30
65
+ max_attempts: 5
66
+ window_seconds: 300
67
+ ```
68
+
69
+ Only `mode` is required. Numeric limits omitted or set to zero use the defaults
70
+ shown. Delays accept 1–3600 seconds; the normalized maximum must be at least the
71
+ initial delay. Attempts accept 1–100, and the window accepts 1–86400 seconds.
72
+ Other fields, modes, nulls, strings and fractional limits are rejected. The
73
+ published fragment `schema/daemon-restart.v1.schema.json` supplies the same
74
+ shape/bounds to the CLI reader; the reader also checks the normalized delay
75
+ relationship. The schema-2 manifest continues to use its existing reader.
76
+
77
+ `check` rejects a selected controller SDK without restart support, with an upgrade message.
78
+ The controller SDK is selected from `identity_gateway.sdk`, then a Go
79
+ backend's SDK requirement, then the CLI's fixed SDK pin.
80
+ `build` additionally checks the selected SDK
81
+ source for the restart implementation and config decoder, so an old local
82
+ `SYNOPKGLAND_SDK_DIR` override cannot produce a controller that rejects the new
83
+ JSON field. A source override does not bypass the minimum declared SDK version.
84
+
85
+ The normalized object is retained in `daemon/config.json` and the SPK build
86
+ record (`daemon_restart`, `daemon_sdk`). `inspect` checks the recorded minimum
87
+ version and exact policy/config equality, rejecting a changed or missing policy
88
+ or an unrecorded injection. Legacy SPKs without a policy retain their previous
89
+ inspection contract. Inspection validates the build record, not a cryptographic
90
+ attestation of arbitrary controller binaries.
91
+
92
+ The SDK doubles the delay up to the ceiling, reserving at most five attempts
93
+ within a sliding 300-second window by default. A full window stops recovery
94
+ with `DAEMON_RESTART_LIMIT` and requires an explicit start/restart. Clean child
95
+ exits, package stop, upgrade stop, uninstall and supervisor TERM/INT do not
96
+ restart. Initial package startup remains fail-fast within its original deadline;
97
+ the policy starts after the first successful launch. Compose supervision does
98
+ not accept this declaration. Native gateway argv adaptation and Node ingress
99
+ preserve it without adding another App retry loop.
100
+
101
+ The existing package status action is nonzero during recovery/failure. An App
102
+ backend can expose the SDK's fixed `control status-json <target> <var>` result
103
+ through its authenticated status API, mapping `state`, `reason`, `restarts` and
104
+ `retry_at` to the existing UI. No UI adapter is generated here. Keep raw daemon
105
+ logs and process inventory private. See the SDK's
106
+ [runtime policy](https://github.com/synopackageland/syno-pkg-land-sdk/blob/main/docs/native-daemon-restart.md)
107
+ for the stop fence, state semantics and DSM user-unit assessment.
108
+
109
+ ## `daemon.node`: run on DSM's Node.js package
110
+
111
+ Use `daemon.node` only when `daemon.exec` is a JavaScript entry: it selects
112
+ Node as the supervised interpreter. A native Go daemon that starts Node
113
+ children instead declares a [generic package dependency](manifest.md):
114
+
115
+ ```yaml
116
+ dependencies:
117
+ packages:
118
+ - name: Node.js_v22
119
+ min_version: "22.19.0"
120
+ daemon:
121
+ exec: bin/service
122
+ targets: {x86_64: daemon}
123
+ ```
124
+
125
+ This leaves the ELF executable, arguments, environment and process model
126
+ unchanged. The daemon can start children using
127
+ `/var/packages/Node.js_v22/target/usr/local/bin/node`. Any DSM package can be
128
+ declared this way; its target is `/var/packages/<name>/target`. Explicit and
129
+ inferred requirements merge into one INFO field; different specified minimum
130
+ versions for the same name fail validation.
131
+
132
+ The SPK does not bundle Node. The build:
133
+
134
+ - adds `install_dep_packages="Node.js_v22>=22.19.0"` to INFO (just the package
135
+ name when `min_version` is absent);
136
+ - writes the launcher `daemon/payload/_synopkgland/node`, which runs
137
+ `/var/packages/<package>/target/usr/local/bin/node` in place of the shell, so
138
+ `daemon/control` supervises node itself. The payload must not contain its own
139
+ `_synopkgland/` directory;
140
+ - writes `daemon/config.json` with `exec: _synopkgland/node` and the argv
141
+ `${SYNOPKG_PKGDEST}/daemon/payload/<exec> <args…>`. `uninstall_args` get the
142
+ same entry in front.
143
+
144
+ `exec` doesn't have to be a static binary here. Without `node`, `exec` must
145
+ still be a statically linked ELF.
146
+
147
+ The node path is the one the SDK bridge runtime already uses
148
+ (`bridge/runtime.go`, `<PackagesDir>/<package>/target/usr/local/bin/node`). It
149
+ was observed on a DSM 7.4-90069 x86_64 NAS with Node.js_v22 22.22.3 (SDK
150
+ `docs/multilang/design.md`). A DSM 7.3.2 x86_64 NAS runs Node.js_v22
151
+ 22.22.3. Confidence: high for x86_64; not observed on ARM.
152
+
153
+ ### Availability of Node.js_v22 (checked 2026-10-22)
154
+
155
+ Source: <https://archive.synology.com/download/Package/Node.js_v22>.
156
+
157
+ | Version | Date | Platforms in the archive |
158
+ |---|---|---|
159
+ | 22.13.1-1004 | — | x86_64, armv8, armv7, armada38x, alpine, monaco |
160
+ | 22.19.0-1006 | 2025-09-10 | same six |
161
+ | 22.22.0-2007 | 2026-02-11 | only `BSM` (BeeStation) x86_64 and armv8 builds |
162
+ | 22.22.3-1010 | 2026-05-29 | x86_64, armv8, armv7, armada38x, alpine, monaco |
163
+
164
+ - **x86_64 and aarch64 (`armv8`).** Both have 22.22.3, which meets
165
+ `min_version: 22.19.0` (high).
166
+ - **Minimum DSM version.** The archive does not show the minimum DSM version of
167
+ each Node.js_v22 build: the SPKs are signed containers whose INFO cannot be
168
+ read offline. DSM 7.3 x86_64 was confirmed during bounded hardware validation.
169
+ - DSM 7.2 is likely, but this is not verified (moderate). Node.js_v20 already
170
+ states "requires DSM 7.2-60085 or onward".
171
+ - Package Center shows the package per model, and a forum report says some
172
+ older models don't get v22 (low).
173
+ - **If the package is missing.** On a model or DSM version without the package,
174
+ Package Center refuses to install the App. It does not install a broken App.
175
+
176
+ ### When the dependency is stopped, upgraded or removed
177
+
178
+ From the DSM 7 Developer Guide, INFO `install_dep_packages`:
179
+
180
+ > Before a package is installed or upgraded, these packages must be installed
181
+ > first. In addition, the order of starting or stopping packages is also
182
+ > dependent on it.
183
+
184
+ The guide's version syntax supports `=`, `<`, `>`, `>=`, `<=`. Its release notes
185
+ list "synopkg start starts a package with its dependees", "Be able to stop a
186
+ package with its dependers" and "Be able to uninstall a package with its
187
+ dependers".
188
+
189
+ | Event | What happens to the daemon |
190
+ |---|---|
191
+ | Install or upgrade the App without Node.js_v22 (or older than `min_version`) | The dependency "must be installed first" (high, documented). Whether Package Center offers to install it or only refuses is not verified (moderate). |
192
+ | Start the App while Node.js_v22 is stopped | DSM starts the dependency first (high, documented). |
193
+ | Stop Node.js_v22 | Package Center stops dependents with it (documented as possible). Whether it warns first is not verified on a NAS (moderate). The node binary stays in place, so a still-running daemon is unaffected. |
194
+ | Upgrade Node.js_v22 | A running daemon keeps the old process image. The next start uses the new node. |
195
+ | Uninstall Node.js_v22 | Package Center uninstalls or blocks on dependents. The exact UI isn't verified (moderate). If node is nevertheless missing, the launcher exits 127 with "Node.js_v22 is not installed or is incomplete; install it in Package Center.", and `daemon/control start` fails, so DSM reports the App failed to start. |
196
+
197
+ ## `daemon.ingress`: a same-origin path through DSM's nginx
198
+
199
+ The build adds DSM's `web-config` resource:
200
+
201
+ ```json
202
+ {"web-config":{"nginx-static-config":{"enable":[{"type":"dsm","relpath":"daemon/ingress-nginx.conf"}]}}}
203
+ ```
204
+
205
+ `daemon.ingress.path` must be exactly `/synopkgland/<package>/`, where
206
+ `<package>` is the manifest's case-sensitive package ID. For `package: MyApp`,
207
+ the only accepted path is `/synopkgland/MyApp/`. Build, SPK inspection and App
208
+ smoke entry validation enforce the same package binding. Encoded names,
209
+ additional path segments, query strings and missing trailing slashes are refused.
210
+ The SDK's `api.ServeIngress` validates this
211
+ same namespace against the package ID in the ingress socket.
212
+
213
+ `daemon/ingress-nginx.conf` is a fixed `location ^~ /synopkgland/<package>/` block. DSM includes
214
+ it in its own 5000/5001 server blocks and custom domains, so the browser sends
215
+ its DSM cookie and the page stays same-origin. The block sets:
216
+
217
+ - `proxy_pass http://unix:/tmp/synopkgland-ingress-<package>.sock:` (nginx
218
+ forwards the full request path, prefix included);
219
+ - `proxy_buffering off`, `proxy_request_buffering off`, `proxy_cache off` and
220
+ `gzip off`, so server-sent events arrive as they are written;
221
+ - `proxy_read_timeout` and `proxy_send_timeout` set to `timeout` (default
222
+ 3600 s);
223
+ - `Host` from the request and `X-Real-IP` from the TCP peer, overriding any
224
+ client value;
225
+ - `client_max_body_size 8m`.
226
+
227
+ INFO gets `instuninst_restart_services` and `startstop_restart_services` set to
228
+ `nginx.service`. DSM reloads nginx when the package is installed, uninstalled,
229
+ started or stopped, so a stopped App's path returns 404.
230
+
231
+ The daemon receives:
232
+
233
+ - `SYNOPKGLAND_INGRESS_SOCKET`: the socket it must listen on. Remove a stale
234
+ socket before binding, and make it connectable by nginx's `http` user. The
235
+ probe used mode 0666; any local process can then connect, so the daemon must
236
+ never trust the socket alone.
237
+ - `SYNOPKGLAND_INGRESS_PATH`: the fixed package path. Mount backend routes at
238
+ this prefix and use it as the base for client URLs.
239
+
240
+ The daemon must check DSM sign-in itself. nginx only proxies.
241
+
242
+ `ingress` needs `os_min_ver` 7.2-64570 or later
243
+ (`STANDALONE_DAEMON_INGRESS_MIN_DSM`). DSM 7.1 lists `web-config` as a
244
+ Synology-only worker and rejects it in unsigned packages, the same floor as
245
+ `portal`. Each package owns only its fixed namespace.
246
+
247
+ Measured on DSM 7.3.2 x86_64: on HTTP 5000 and HTTPS 5001, a 100-second SSE
248
+ stream arrived unbuffered with no gaps.
249
+
250
+ ## `daemon.backend`: the App's own backend as the daemon
251
+
252
+ A native App can run its backend, the same `ui/cgi/api.cgi` the CGI path
253
+ uses, as the daemon instead of a separate executable:
254
+
255
+ ```yaml
256
+ package: MyApp
257
+ daemon:
258
+ backend: true
259
+ args: [serve] # the backend's own daemon mode
260
+ ingress:
261
+ path: /synopkgland/MyApp/
262
+ node: # optional: a runtime for the backend's children
263
+ package: Node.js_v22
264
+ targets: {x86_64: build/children, aarch64: build/children} # optional payload
265
+ ```
266
+
267
+ - `exec` is refused; `daemon/control` runs `${SYNOPKG_PKGDEST}/ui/cgi/api.cgi`
268
+ with `args`. The binary keeps the route audit and build-time digests of the
269
+ CGI build, so no second binary needs the same checks.
270
+ - Only native backends (Go or a prebuilt binary) take a daemon. The SDK must
271
+ contain backend support in its daemon controller
272
+ (`STANDALONE_DAEMON_BUILD_FAILED` otherwise).
273
+ - `targets` is optional and is copied to `daemon/payload` for the backend's
274
+ child processes.
275
+ - With `node`, the CLI writes its launcher but does not run Node itself. The
276
+ backend gets `SYNOPKGLAND_NODE` (the launcher) and
277
+ `SYNOPKGLAND_DAEMON_PAYLOAD` and decides which children to start.
278
+ - With `ingress`, the backend serves it with `api.ServeIngress`, which the
279
+ route audit treats like `cgi.Serve`: called directly in `main` with a handler
280
+ built for it.
281
+
282
+ ## Upgrades that introduce the daemon
283
+
284
+ DSM runs the new package's `preupgrade` before replacing the payload, so the
285
+ hook sees the old package. When that payload has no `daemon/` at all, the hook
286
+ now exits 0 instead of running a missing `daemon/control` (DSM error 4541). A
287
+ partial or symlinked `daemon/` still stops or fails closed. `inspect` also
288
+ accepts the earlier unguarded `preupgrade` of released packages.
@@ -0,0 +1,70 @@
1
+ # Installer-selected host ports
2
+
3
+ `<sdk-version>` is a placeholder, not manifest syntax. `synopkgland init` copies compatible SDK pins from the locally installed templates. For a manual configuration, query `npm view @synopackageland/sdk version`, replace the placeholder with that exact release, and keep all App SDK declarations (including Go, Rust and frontend dependencies) aligned. Run `synopkgland check` with an up-to-date CLI before building.
4
+
5
+ ```yaml
6
+ install:
7
+ ports: true
8
+ identity_gateway:
9
+ sdk: <sdk-version>
10
+ listen: {https: 28443}
11
+ ```
12
+
13
+ The manifest's gateway HTTP/HTTPS listeners and optional local OIDC issuer port
14
+ are the defaults. The install wizard shows each port with a localized label and
15
+ reason. It refuses values outside 1024–65535, reserved DSM/discovery ports,
16
+ duplicates and conflicts returned by DSM's `SYNO.Core.Service.PortInfo` listing.
17
+ The listing includes DSM and installed-package service definitions. An unreadable,
18
+ empty or malformed listing blocks Next; the wizard never assumes a port is free.
19
+
20
+ The SDK repeats the check with DSM's `servicetool --conf-port-conflict-check` as
21
+ the package account. It parses the documented `IsConflict` output and allows
22
+ only its exact existing service ID during upgrade. A successful command exit
23
+ alone does not mean a port is free. A concurrent change can still race a check;
24
+ DSM's native resource acquisition and the listener bind remain final checks.
25
+
26
+ The package-account preinst controller materializes the selected values into all
27
+ generated consumers: gateway configuration, nginx ingress, DSM window launcher,
28
+ daemon listener inventory and environment, required-origin validation settings,
29
+ and the package-specific `install/<package>.sc` service definition. The official
30
+ `port-config` resource registers that file with DSM's firewall/service listing.
31
+ Managed nginx resources omit stale fixed port reservations. No root App or
32
+ manual DSM configuration write is used.
33
+
34
+ Native subprocesses receive `SYNOPKGLAND_PORT_GATEWAY_HTTP`,
35
+ `SYNOPKGLAND_PORT_GATEWAY_HTTPS` and, when applicable,
36
+ `SYNOPKGLAND_PORT_OIDC_ISSUER`. Go Apps may also call
37
+ `installsettings.PortValues(payloadRoot)`. Compose's generated `.env` contains
38
+ the same values. When upstream configuration needs a selected public port, bind
39
+ it explicitly through the existing runtime configuration mechanism:
40
+
41
+ ```yaml
42
+ compose:
43
+ services:
44
+ web:
45
+ storage_init:
46
+ directories: [{base: /data, path: app}]
47
+ runtime:
48
+ environment:
49
+ PUBLIC_PORT: {port: gateway_https}
50
+ ```
51
+
52
+ The selected value is mounted read-only and supplied as a literal environment
53
+ value to the upstream process. Existing runtime file templates can use that
54
+ variable in the upstream's own configuration. Container-internal ports and
55
+ fixed protocol discovery ports keep their upstream contract; changing a public
56
+ host listener does not change the container's internal listening port.
57
+
58
+ Upgrade retains the saved port selection and ignores new wizard environment
59
+ values. To change ports, reinstall the same package and choose the new values
60
+ in its installation wizard; shared data is retained by default. Re-enter any
61
+ required HTTPS origin with the newly selected HTTPS port. The UI never copies
62
+ private retained settings into a package or report.
63
+
64
+ Use `--param pkgwizard_port_gateway_https=29443` for a first CLI deployment;
65
+ programmatic upgrades reject port changes. Apps must adopt `install.ports: true`
66
+ and declare upstream runtime bindings where their own configuration needs the
67
+ public port. Templates enable this for the Compose gateway by default.
68
+
69
+ DSM references: [service port definitions and conflict checks](https://help.synology.com/developer-guide/integrate_dsm/ports.html)
70
+ and [Port Config resource](https://help.synology.com/developer-guide/resource_acquisition/port_config.html).
@@ -0,0 +1,141 @@
1
+ # DSM path ingress
2
+
3
+ DSM-managed HTTPS on a dedicated App port and a path in DSM's own server are
4
+ separate ingress mechanisms. Gateway JSON `native_ingress` selects DSM-managed
5
+ nginx; the path route also declares `ingress_path`.
6
+
7
+ ## Choose an entry route
8
+
9
+ Prefer a native DSM URL when the upstream can serve the selected path. Audit
10
+ root-absolute asset/API URLs, redirects and WebSockets before choosing:
11
+
12
+ | Route | Manifest selection | Use when |
13
+ | --- | --- | --- |
14
+ | Per-package path ingress | `ingress: {path: /synopkgland/ExampleApp/}` | The upstream supports a configurable base path, including its asset/API URLs and redirects. This keeps the DSM origin without a public App port. |
15
+ | Custom top-level path ingress | `ingress: {path: /my-app/}` | The upstream hard-codes a nonreserved subpath and all its routes fit under it. The CLI validates the path; installation checks ownership and conflicts on the NAS. |
16
+ | Dedicated HTTPS port | `listen: {https: 28443}` | The upstream requires `/`, or root-absolute routes span paths that cannot fit one supported base. DSM nginx serves the App at that port with DSM's certificate; the App does not copy certificate keys. |
17
+
18
+ `listen` and `ingress` are mutually exclusive. The gateway forwards the full
19
+ path; it does not rewrite arbitrary upstream HTML, JavaScript or API payloads.
20
+ A custom path does not capture unrelated root routes such as `/api`.
21
+ With `install.ports: true`, `listen` supplies defaults for installer selection;
22
+ DSM's `port-config` resource owns port registration, and the nginx `web-config`
23
+ resource omits its own `ports` list. See [installer-selected ports](install-ports.md).
24
+
25
+ ## Configure path ingress
26
+
27
+ For a prefix-aware upstream, a CLI and SDK with path ingress support accept:
28
+
29
+ ```yaml
30
+ package: ExampleApp
31
+ os_min_ver: "7.2.1-69057"
32
+ identity_gateway:
33
+ sdk: <matching-sdk-version>
34
+ mode: header # Keep the existing none, header, token or oidc mode
35
+ upstream: 18000 # Native daemon only; Compose derives its upstream
36
+ ingress: {path: /synopkgland/ExampleApp/}
37
+ headers: {user: Remote-User}
38
+ ```
39
+
40
+ Replace `listen` with `ingress`. The default is `/synopkgland/<exact-package-ID>/` (case sensitive).
41
+ The SDK and CLI also accept an explicit custom path:
42
+
43
+ `<sdk-version>` is a placeholder, not manifest syntax. `synopkgland init` copies compatible SDK pins from the locally installed templates. For a manual configuration, query `npm view @synopackageland/sdk version`, replace the placeholder with that exact release, and keep all App SDK declarations (including Go, Rust and frontend dependencies) aligned. Run `synopkgland check` with an up-to-date CLI before building.
44
+
45
+ ```yaml
46
+ identity_gateway:
47
+ sdk: <sdk-version>
48
+ mode: none
49
+ upstream: 18000
50
+ ingress: {path: /my-app/} # Or /my-app/ui/
51
+ ```
52
+
53
+ Custom paths have one or more lowercase segments, leading and trailing slashes,
54
+ and at most 255 characters total and 64 per segment. Segments contain lowercase
55
+ letters, digits and internal hyphens. Empty segments, dot segments, escapes,
56
+ queries, fragments, uppercase and `/` are refused. DSM/native prefixes (including
57
+ `webman`, `webapi`, `scripts`, `synohdpack`, `drive`, `photo` and `synopkgland`)
58
+ are reserved; only the package's exact default namespace is allowed under
59
+ `/synopkgland/`. Apps requiring the origin root `/` cannot use path ingress.
60
+
61
+ `check` validates the syntax and static reserved prefixes. Availability depends
62
+ on the target NAS: installation checks native document-root entries, saved Portal
63
+ aliases, installed SDK gateways (including stopped ones), and DSM nginx locations.
64
+ An overlap with another route, or an unreadable/unknown inventory, fails installation
65
+ with a readable error. Choose an unused path and rebuild; do not remove another
66
+ App's config. The checker only reads inventory and runs as the package account.
67
+ DSM's `web-config` worker registers and removes its own configuration. Upgrade
68
+ replaces that owned resource, including namespace-to-custom and custom-to-namespace
69
+ changes; uninstall never deletes a different owner's route. No shared registry is
70
+ written. The menu CGI stays stable and launches the selected path.
71
+
72
+ A non-slash request redirects to that path,
73
+ retaining its query. DSM's `web-config` worker registers a `type: dsm` location;
74
+ INFO requests nginx reload on lifecycle transitions. No App public port or
75
+ manually maintained reverse proxy rule is created. The existing private,
76
+ mutually authenticated Unix socket still protects the nginx-to-gateway hop.
77
+ DSM 7.2 or newer is required. An SDK source capability check prevents building
78
+ against a released SDK that cannot interpret `ingress_path`.
79
+
80
+ Remove `install.ports` for header/none/token gateways. For OIDC, keep it if the
81
+ upstream uses a runtime `{port: oidc_issuer}` binding: only the loopback issuer
82
+ port remains configurable. Remove old public gateway port bindings from runtime
83
+ configuration. Keep `entry`, access policies, roles and native-client exceptions.
84
+
85
+ All gateway manifest paths remain relative to the selected ingress base: `redirects`,
86
+ `passthrough`, `upstream_auth_paths`, optional passthrough prefixes, OIDC callback
87
+ paths, browser paths and `launch_path`. The SDK scopes these once. For example,
88
+ `redirect_paths: [/callback]` allows only
89
+ `/synopkgland/ExampleApp/callback` on the same DSM origin. Login return paths,
90
+ cold-login resume and gateway cookies are scoped to the same package. The menu
91
+ CGI continues to support DSM launch parameters; E2E smoke derives the selected
92
+ path when ingress is declared.
93
+
94
+ The upstream receives the full prefixed path, including on WebSocket requests.
95
+ Configure its native base URL/router base path accordingly, along with native
96
+ OAuth callback configuration. Health probes run directly against the upstream;
97
+ choose a path that it actually serves. The gateway does not rewrite arbitrary
98
+ application HTML, JavaScript or API payloads. An App with a hardcoded subpath can select that custom ingress base. An App
99
+ requiring `/` cannot use ingress. Existing wrappers with
100
+ hard-coded API, logout or bootstrap URLs also need a base-path audit.
101
+
102
+ Path ingress uses the DSM request origin. Remove the dedicated-port
103
+ `external_access.single_origin` setting; dedicated-port Connect projection
104
+ routing is not applied to path ingress. Do not claim external-provider or
105
+ QuickConnect acceptance until the actual provider has been tested.
106
+
107
+ For a native App that already owns its HTTP server and SDK authentication,
108
+ use the existing `daemon.ingress: {path: /synopkgland/ExampleApp/}` instead.
109
+ That daemon must listen on `SYNOPKGLAND_INGRESS_SOCKET` and serve
110
+ `SYNOPKGLAND_INGRESS_PATH`. Do not combine daemon ingress with an identity gateway.
111
+
112
+ Validate with `check`, `build`, and `inspect`, then upgrade the installed test
113
+ package and check both the active nginx location and an authenticated browser
114
+ navigation. Include anonymous denial, the original entry policy and upstream
115
+ assets/API calls; a successful install response alone is insufficient.
116
+
117
+ ## Apps requiring HTTPS
118
+
119
+ With the latest CLI and SDK, declare `identity_gateway.secure_context: required`
120
+ for an App that needs WebCrypto or another secure context feature. The same
121
+ field works for Compose and standalone gateways. Omission preserves HTTP
122
+ behavior; any value other than the string `required` is rejected by `check`.
123
+ `check` and `build` also verify that the selected SDK source implements HTTPS
124
+ guidance and report an explicit error when it does not.
125
+
126
+ The gateway serves a localized DSM light page for HTTP top-level navigations,
127
+ with a user-operated HTTPS link and no automatic redirect. HTTP API, resource
128
+ and iframe requests receive status 403 with `https_required`; HTTPS behavior
129
+ is unchanged. The package readiness ping remains available.
130
+
131
+ Path ingress uses the browser scheme supplied by DSM's authenticated ingress.
132
+ The HTTPS link uses the current hostname and an actual DSM HTTPS port
133
+ declaration, opening the HTTPS DSM desktop with the App's `launchApp`. Direct
134
+ gateways use their declared HTTPS listener. Request queries and fragments are
135
+ not forwarded. When no reliable HTTPS port is available, the page shows
136
+ instructions instead of guessing a port. No administrator API or DSM settings
137
+ change is needed.
138
+
139
+ Editors can use `schema/dsm-package.schema.json`, which references the focused
140
+ `schema/identity-gateway.v1.schema.json` HTTPS policy fragment. These editor
141
+ schemas supplement the complete manifest validation performed by `check`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.48.21",
3
+ "version": "0.48.22",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
@@ -15,6 +15,10 @@
15
15
  "CHANGELOG.md",
16
16
  "schema",
17
17
  "docs/ctl-external.md",
18
+ "docs/app-entry.md",
19
+ "docs/daemon.md",
20
+ "docs/install-ports.md",
21
+ "docs/path-ingress.md",
18
22
  "skills",
19
23
  "docs/shared-folders.md",
20
24
  "docs/daemon-nofile.md"
package/skills/SKILL.md CHANGED
@@ -333,11 +333,15 @@ Application Portal 是獨立 opt-in:不想要別名就省略 `portal`,不生
333
333
  compose App、沒有 gateway 的 App、`ui.launch` 或 `portal` 都會被 check 拒絕。
334
334
  冷登入由 url 圖示經 `open.cgi` 續接,`oidc.browser` 需要支援此續接的 SDK。
335
335
 
336
- 原生 App 搭配 `identity_gateway`、而且唯一的 UI 就是包裝的網頁時,宣告 `ui: false` 取代 `ui.dir`。
336
+ ### Upstream-web-only Apps
337
+
338
+ 原生 App 搭配 `identity_gateway`、而且唯一的 UI 就是包裝的網頁時,宣告 `ui: false` 取代整個 `ui` 區塊。
337
339
  沒有 SDK 視窗:主選單只有一個 `displayname` 圖示,是 `type: "url"`,經 `sso/open.cgi` 在新分頁開原生 UI;
338
340
  套件中心「開啟」經 INFO `adminurl` 開同一個入口,與 compose App 相同。backend 與 ctl 指令不受影響。
339
341
  沒有 `identity_gateway`、搭配 `console` 或 `portal`、或使用 `capabilities.rootOps`、`delegate`、`webapi`、`identity`
340
342
  (這些的核准或登入畫面在 SDK 視窗裡)都會被 check 以 `STANDALONE_UI_NO_WINDOW_INVALID` 拒絕。省略 `ui` 仍是錯誤。
343
+ 保留 entry gate 使用的 backend 與 `i18n/messages`,刪除不用的 UI/UI e2e;
344
+ 檔案與設定清理細節見 [upstream-fork](reference/upstream-fork.md#upstream-web-only-apps)。
341
345
 
342
346
  Schema 2 Compose 使用 `dsm-package.yaml` 的 `compose.files`、`compose.web` 與
343
347
  `identity_gateway`;不使用 file/targets/address_env 或手寫 upstream。
@@ -11,6 +11,10 @@ manifest package ID's case. The backend mounts routes at
11
11
  `SYNOPKGLAND_INGRESS_PATH`; build, inspect and smoke entry checks bind this path
12
12
  to the package.
13
13
 
14
+ For `daemon.env` expansion, runtime-owned `HOME`, startup env launchers and the
15
+ supervisor configuration digest, read
16
+ [the runtime environment contract](../../docs/daemon.md#runtime-environment-and-launchers).
17
+
14
18
  Daemon mode is not the default recommendation. It removes work that repeats
15
19
  on every request. It does not make a single expensive request cheaper, and it
16
20
  costs memory for as long as the package runs. Measure first, then decide.
@@ -6,6 +6,29 @@ The independent container path uses resource-worker lifecycle. Unsupported Compo
6
6
 
7
7
  Never work around a failed permission check by running the package as root. Native CGI authentication and root-operation administrator approval are separate checks.
8
8
 
9
+ ## Blank frames or broken images
10
+
11
+ A frame is blank or images are broken behind the gateway → compare
12
+ `fetch(url, {credentials: 'include'})` with `fetch(url, {credentials: 'omit'})`
13
+ from the signed-in panel page, using the same failing resource URL:
14
+
15
+ ```js
16
+ const url = "/synopkgland/ExampleApp/_app/plugin/icon.png";
17
+ for (const credentials of ["include", "omit"]) {
18
+ const response = await fetch(url, {credentials});
19
+ console.log(credentials, response.status);
20
+ }
21
+ ```
22
+
23
+ If `include` returns 200 but `omit` returns 401 `dsm_sign_in_required`, inspect
24
+ the iframe sandbox and request cookies. A sandboxed plugin with an opaque origin
25
+ may omit DSM cookies; symptoms include "Opening…", `naturalWidth === 0` and
26
+ an undefined upstream global without a CSP violation. Only when the upstream
27
+ authenticates those resources itself, add the narrow plugin prefix to
28
+ `identity_gateway.upstream_auth_paths` and rebuild. Keep its token checks and
29
+ CSP sandbox, and verify both valid access and invalid-token denial. See
30
+ [upstream-authenticated paths](identity-gateway.md#upstream-authenticated-paths).
31
+
9
32
  ## Native HTTPS fails before the App starts
10
33
 
11
34
  For a package using DSM-managed native gateway HTTPS (including Compose Apps),
@@ -2,11 +2,11 @@
2
2
 
3
3
  ## Upstream-authenticated paths
4
4
 
5
- Build with matching SDK and CLI releases. Use `upstream_auth_paths` for client API
6
- paths that use upstream authentication.
5
+ Build with matching SDK and CLI releases. Use `upstream_auth_paths` for client API,
6
+ share or sandboxed plugin resource paths that use upstream authentication.
7
7
 
8
8
  Keep browser routes behind `entry: admin-only` or `entry: app-privilege`; list
9
- only upstream API/share prefixes in `identity_gateway.upstream_auth_paths`, for
9
+ only narrowly scoped upstream-authenticated prefixes in `identity_gateway.upstream_auth_paths`, for
10
10
  example `[/rest, /share]`. Prefixes are case-sensitive and segment-bounded;
11
11
  `/rest` does not match `/restore`. Use 1-16 nonoverlapping absolute prefixes with
12
12
  URL unreserved characters and `/`, no root, dot segments, repeated slashes,
@@ -18,7 +18,43 @@ headers. Upstream auth owns authentication, CSRF, authorization and WebSockets;
18
18
  public upstream share links remain public. Other paths keep the DSM entry gate.
19
19
  SDK RPC methods cannot use this exception. The CLI checks matching SDK capability
20
20
  and links the gateway policy digest; editing the static paths requires rebuilding.
21
- See `docs/app-entry.md` for the complete contract.
21
+ See [the App entry contract](../../docs/app-entry.md) for the complete contract.
22
+
23
+ A plugin page in an iframe with `sandbox="allow-scripts"` has an opaque origin
24
+ and may request resources without DSM cookies. The frame can stay on "Opening…",
25
+ show broken images (`naturalWidth === 0`) and lack its upstream JavaScript global,
26
+ while resource requests return 401 `dsm_sign_in_required` without a CSP violation.
27
+ If the upstream already protects that plugin with its own per-run token and CSP
28
+ sandbox, declare its narrow prefix, for example
29
+ `upstream_auth_paths: [/_app/plugin]`. Verify that upstream authentication still
30
+ rejects invalid credentials; the exception removes the DSM entry gate on that
31
+ prefix. Keep the upstream sandbox. Compare credentialed and credential-free
32
+ fetches as described in [Diagnose](diagnose.md#blank-frames-or-broken-images).
33
+
34
+ ## Choose the upstream URL
35
+
36
+ Prefer a native DSM path when the upstream can serve it. For root-absolute
37
+ assets, API calls or redirects, choose among all three supported routes in
38
+ [the ingress decision table](../../docs/path-ingress.md#choose-an-entry-route).
39
+ Both the per-package namespace and an explicitly selected custom top-level
40
+ path preserve the DSM origin. A dedicated `listen: {https: 28443}` serves the
41
+ upstream at `/` through DSM nginx using DSM's certificate.
42
+
43
+ ## Token adapter headers
44
+
45
+ In `mode: token`, the adapter returns a JSON `headers` map with arrays of
46
+ values. It can supply any request header needed by the upstream, including
47
+ `Cookie`, rather than only `Authorization`:
48
+
49
+ ```json
50
+ {"headers":{"Cookie":["upstream_session=<private-value>"]}}
51
+ ```
52
+
53
+ After DSM admission, the gateway injects these credentials into the upstream
54
+ request server-side. The adapter result is never delivered to browser code,
55
+ URLs or localStorage. This does not suppress the upstream's own responses or
56
+ credential-management APIs; review those separately. Use upstream-supported
57
+ credentials, fixed native argv and package-private storage.
22
58
 
23
59
  ## External access
24
60
 
@@ -114,8 +150,8 @@ trusted proxy header instead. Test sign-in over both HTTP and HTTPS.
114
150
 
115
151
  ## Per-request OIDC browser origins (development)
116
152
 
117
- `oidc.browser_redirect: {}` opts into per-request browser origins for SDK/CLI
118
- 0.23. Optional `html_paths` and `same_origin_referrer` configure HTML behavior.
153
+ `oidc.browser_redirect: {}` opts into per-request browser origins.
154
+ Optional `html_paths` and `same_origin_referrer` configure HTML behavior.
119
155
  No host list is accepted or stored in the SPK: users can open the same install
120
156
  by IP, hostname, DDNS or a new DNS alias. Each request must use a syntactically
121
157
  valid IP/DNS authority and the declared gateway scheme/port; forwarding headers
@@ -208,7 +244,7 @@ For native Apps, retain the existing daemon, identity_gateway and account.on_del
208
244
  Bridge readiness is availability only: declared App health + loopback TCP + the current-version SDK lifecycle acquire generation. It cannot attest actual image/project/generation: another process already executing on the NAS can occupy the port. This local-code-execution threat is accepted; restore official full readback when available. Never use root, Docker socket access or borrowed admin credentials. See compose.md.
209
245
 
210
246
 
211
- ## Optional native-client prefixes (next minor SDK)
247
+ ## Optional native-client prefixes
212
248
 
213
249
  For user-controlled mobile API or WebDAV access, declare fixed prefixes:
214
250
 
@@ -128,6 +128,69 @@ architecture-specific `daemon.targets` below `synology/` and keep the small SDK
128
128
  CGI as a separate management shell. The upgrade command fetches/merges the tag,
129
129
  derives the version, runs the selected native payload hook, checks and builds.
130
130
 
131
+ `--ui plain` selects the small JavaScript/CSS management UI in `synology/ui/`
132
+ instead of the Vue frontend, with a `new-page` launcher. It still generates the
133
+ backend, i18n and test scaffolding; it does not build the upstream web panel,
134
+ configure a gateway or select `ui: false`.
135
+
136
+ ### Upstream-web-only Apps
137
+
138
+ When the upstream web panel is the only UI, configure `daemon` and
139
+ `identity_gateway`, then replace the manifest's entire `ui` block with
140
+ `ui: false`. Keep `backend/` for the authenticated entry gate and
141
+ `i18n/messages/` for its localized responses. Keep the manifest's i18n
142
+ declaration, wrapper lifecycle files, notices and any explicitly authorized ctl
143
+ adapters/registry. Delete the unused `ui/` (or Vue `frontend/`) and UI e2e files
144
+ under `tests/e2e/`, along with unused e2e configs, npm scripts and dependencies.
145
+ Retain any local/backend tests you choose to use.
146
+
147
+ The DSM menu and Package Center Open both use `sso/open.cgi` to open the
148
+ upstream panel. Do not add `console`, `portal` or capabilities requiring an SDK
149
+ window. See the [orchestrator's upstream-web-only contract](../SKILL.md#upstream-web-only-apps).
150
+
151
+ ### Package icon and listener ownership
152
+
153
+ Store a square PNG of at least 256 pixels at `synology/assets/icon.png` and set
154
+ `icon: assets/icon.png` in `synology/dsm-package.yaml`. The path is relative to
155
+ that manifest, not the upstream root. The CLI resizes it for DSM menu/window
156
+ icons and Package Center's 64- and 256-pixel icons; no hand-made size set is
157
+ required. Omitting `icon` uses the bundled default.
158
+
159
+ Prefer [DSM path ingress](../../docs/path-ingress.md#choose-an-entry-route) when
160
+ the upstream supports a base path. For an upstream that needs `/`, declare
161
+ `identity_gateway.listen: {https: 28443}`: DSM nginx serves the public listener
162
+ with DSM's certificate. With `install.ports: true`, those ports are installer
163
+ defaults and DSM's `port-config` resource owns registration; the native-nginx
164
+ `web-config` resource omits its own `ports` list to avoid duplicate ownership.
165
+ See [installer-selected ports](../../docs/install-ports.md).
166
+
167
+ For computed daemon configuration, use a
168
+ [native env launcher that execs the upstream](../../docs/daemon.md#runtime-environment-and-launchers).
169
+
170
+ ## Self-updating upstreams
171
+
172
+ Disable upstream self-update through its supported setting when available.
173
+ Let Package Center own the installed release and update it with a reviewed SPK.
174
+ An upstream update can change integration contracts such as cookie names,
175
+ token formats, command output or environment keys while the SPK still passes
176
+ inspection.
177
+
178
+ If self-update cannot be disabled, document these consequences:
179
+
180
+ - The running upstream binary can differ from Package Center's version and the
181
+ packaged checksum/source record. Record the actual upstream version and
182
+ verify its release integrity and source/license correspondence separately.
183
+ - A package upgrade replaces the payload with its packaged binary, potentially
184
+ downgrading an upstream that updated itself. Between package upgrades, the
185
+ packaged release is only a starting floor for upstream updates.
186
+ - Cookie/env/API drift can break the panel or token adapter while package
187
+ status and SPK inspection still look healthy. Recheck login, resources,
188
+ restart and retained-data upgrades against the actual running release.
189
+ - The supervisor digest covers `daemon/config.json`, not payload executable
190
+ bytes. A binary-only update does not invalidate that digest or by itself stop
191
+ supervision; it is not runtime tamper detection. The updater must still
192
+ preserve the foreground-process and stop/signal contract.
193
+
131
194
  ## Use DSM login
132
195
 
133
196
  Every integrated App must admit **DSM administrators directly**, without a separate
@@ -158,8 +221,10 @@ upstream mechanisms in order:
158
221
  upstream `admin token` CLI while the server is stopped to obtain the native
159
222
  administrator API token. The package stores it in a package-private **0600**
160
223
  file under a 0700 directory. After DSM administrator admission, the gateway
161
- runs the package's token adapter and injects `Authorization` server-side,
162
- replacing client credentials. Packaging never delivers the token to the
224
+ runs the package's token adapter and injects its returned request headers
225
+ server-side, replacing client credentials. The adapter can return any
226
+ upstream-required header, including `Cookie`; `Authorization` is one
227
+ example. Packaging never delivers the adapter's token to the
163
228
  browser, URL, localStorage or page script. No new SDK authentication API,
164
229
  OIDC/SSO server, upstream source change or direct database edit is required.
165
230
  All admitted DSM administrators share one upstream admin account; this does