@synopackageland/cli 0.48.10 → 0.48.12

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.
@@ -46,7 +46,7 @@ import { renderNativePrivilege } from "../build-spk/native-lifecycle.js";
46
46
  import { renderUiConfig } from "./dsm-window.js";
47
47
  import { identityGatewayConfig, gatewayCgiPaths, GATEWAY_SETTINGS_CGI_PATH, gatewayAdmissionReport, gatewayAdmissionPolicy, readIdentityGateway, } from "./identity-gateway.js";
48
48
  import { checkCgiBinary } from "./binary.js";
49
- import { matchesStandaloneScript, renderStandaloneScript, matchesStandaloneScriptPrefix } from "./lifecycle.js";
49
+ import { matchesStandaloneScript, matchesStandaloneScriptPrefix } from "./lifecycle.js";
50
50
  import { listPortExposures, loadCompose } from "../compose/analyze.js";
51
51
  import { uninstallCleanup, } from "../runtime/uninstall-cleanup.js";
52
52
  import { PORTAL_JSON_RELPATH, PORTAL_MUSTACHE_RELPATH, renderPortalJson, renderPortalLifecycle, renderPortalMustache, renderPortalWizardStep, } from "../portal/package.js";
@@ -310,8 +310,7 @@ export async function inspectSpk(spkPath, expectedKind) {
310
310
  ...(uninstallHook ? { uninstall: uninstallHook.uninstall } : {}),
311
311
  };
312
312
  for (const hook of ["preuninst", "preupgrade", "start-stop-status"]) {
313
- if (readOptional(join(dir, "scripts", hook)) !==
314
- renderStandaloneScript(hook, lifecycleManifest))
313
+ if (!matchesStandaloneScript(hook, lifecycleManifest, readOptional(join(dir, "scripts", hook))))
315
314
  findings.push(`Executor scripts/${hook} differs from fixed lifecycle.`);
316
315
  }
317
316
  }
@@ -45,6 +45,13 @@ function standaloneScriptVariants(name, manifest, expected) {
45
45
  const wait = renderNativeGatewayPortWait(manifest, name);
46
46
  const diagnosticOnly = wait ? expected.replace(wait, '') : expected;
47
47
  const variants = [expected, ...(wait ? [diagnosticOnly] : []), ...(diagnostic ? [diagnosticOnly.replace(diagnostic, '')] : [])];
48
+ // One released renderer added daemon bookkeeping even without a daemon.
49
+ // Replay that exact variant, retaining the complete lifecycle comparison.
50
+ if (name === 'start-stop-status' && !manifest.daemon &&
51
+ (manifest.capabilities?.rootOps || manifest.capabilities?.delegate || manifest.capabilities?.webapi)) {
52
+ const stop = `"\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}/executor/lifecycle" stop --package ${manifest.package} || exit $?\n`;
53
+ variants.push(...variants.map(v => v.replace('if [ "$1" = stop ]; then\n', 'if [ "$1" = stop ]; then\ndaemon_result=0\n').replace(stop, stop + '[ "$daemon_result" = 0 ] || exit "$daemon_result"\n')));
54
+ }
48
55
  // Released packages stop the daemon in preupgrade without the first-daemon guard.
49
56
  const unguarded = (v) => v.replace(daemonGuard(manifest.package), '').replace(delegatedDaemonGuard(manifest.package), '');
50
57
  return name === 'preupgrade' ? [...new Set([...variants, ...variants.map(unguarded)])] : variants;
@@ -162,7 +169,7 @@ function renderStandaloneScriptBody(name, manifest) {
162
169
  const stopDaemon = manifest.daemon
163
170
  ? `"/var/packages/${manifest.package}/target/daemon/control" stop "\${SYNOPKG_PKGDEST:-/var/packages/${manifest.package}/target}" "\${SYNOPKG_PKGVAR:-/var/packages/${manifest.package}/var}" || daemon_result=$?\n`
164
171
  : "";
165
- return normal.replace("#!/bin/sh\n", `#!/bin/sh\n${workerStop}if [ "$1" = start ]; then\n${request("start")}fi\nif [ "$1" = stop ]; then\n${stopWorker}daemon_result=0\n${stopDaemon}${request("stop")}[ "$daemon_result" = 0 ] || exit "$daemon_result"\n${workerResult}fi\n`);
172
+ return normal.replace("#!/bin/sh\n", `#!/bin/sh\n${workerStop}if [ "$1" = start ]; then\n${request("start")}fi\nif [ "$1" = stop ]; then\n${stopWorker}${manifest.daemon ? 'daemon_result=0\n' : ''}${stopDaemon}${request("stop")}${manifest.daemon ? '[ "$daemon_result" = 0 ] || exit "$daemon_result"\n' : ''}${workerResult}fi\n`);
166
173
  }
167
174
  if (name === "preuninst")
168
175
  return renderExecutorPreuninst(manifest, workerStop, stopWorker, workerResult, request);
@@ -13,7 +13,9 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
13
13
  if (e && e.passwordConfirm) return code + (code === "dsm_3121" ? ": DSM rejected the administrator password." : ": administrator password confirmation failed.") + " Nothing was created.";
14
14
  if (e && e.detail) return code + ": " + e.detail;
15
15
  if (["dsm_106","dsm_107","dsm_119"].indexOf(code) >= 0) return code + ": the DSM session ended. Sign in to DSM again, then approve again.";
16
- return code + (code === "105" || code === "dsm_105" ? ": DSM denied administrator scheduler access. Check the DSM session and scheduler; a NAS restart resolved this on the measured DSM. No automatic retry was made." : ": scheduler readback or operation failed.");
16
+ var step = e && e.operation;
17
+ var at = step ? " [" + step.api + "/" + step.method + " v" + step.version + "]" : "";
18
+ return code + (code === "105" || code === "dsm_105" ? ": DSM denied administrator scheduler access. Sign out of DSM, sign in again from the DSM desktop, then check status before approving again. If access is still denied, contact your administrator. No automatic retry was made." : ": scheduler readback or operation failed.") + at;
17
19
  }
18
20
  // What a result's code says, for the window panel and the SDK to translate;
19
21
  // reason keeps the English detail. fallback names a step's own failure.
@@ -27,17 +29,31 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
27
29
  if (code === "executor_starting") return code;
28
30
  if (e && e.detail) return /other digests/.test(e.detail) ? "executor_mismatch" : "executor_unreachable";
29
31
  if (code.indexOf("executor_selection") === 0) return "selection_failed";
30
- if (fallback) return fallback;
31
32
  if (code === "105" || code === "dsm_105") return "scheduler_denied";
33
+ if (fallback) return fallback;
32
34
  if (["102","103","104","dsm_102","dsm_103","dsm_104"].indexOf(code) >= 0) return "scheduler_unsupported";
33
35
  return "scheduler_failed";
34
36
  }
35
- function block(result, e, fallback) { result.state = "blocked"; result.reason = reason(e); result.code = codeOf(e, fallback); return result; }
37
+ function block(result, e, fallback) {
38
+ result.state = "blocked"; result.reason = reason(e); result.code = codeOf(e, fallback);
39
+ if (e && e.diagnostic) result.diagnostic = e.diagnostic;
40
+ return result;
41
+ }
36
42
  // A find result that stops an approval, with its code.
37
- function refused(current) { var e = fail(current.reason); e.task = current.code; return e; }
43
+ function refused(current) { var e = fail(current.reason); e.task = current.code; e.diagnostic = current.diagnostic; return e; }
38
44
  // AppWindow.sendWebAPI encodes JSON parameters. Preserve their native types;
39
45
  // pre-encoding turns objects/booleans into strings and DSM rejects create.
40
- function send(api, method, version, params) { return options.send(api, method, version, params || {}); }
46
+ function send(api, method, version, params) {
47
+ return options.send(api, method, version, params || {}).catch(function (error) {
48
+ // Identify the refused native operation without carrying request parameters,
49
+ // credentials, a password token or a raw DSM response into diagnostics.
50
+ var e = fail(error && error.code || "executor_bad_response");
51
+ e.operation = {api: api, method: method, version: version};
52
+ var match = /^(?:dsm_)?([0-9]+)$/.exec(String(e.code));
53
+ if (match) e.diagnostic = {api: api, method: method, version: version, dsm_code: Number(match[1])};
54
+ throw e;
55
+ });
56
+ }
41
57
  // DSM 7.1 has no Root APIs: TaskScheduler stops at list v2 (offset) and get v3.
42
58
  // Only an unsupported method version on a read selects that profile, which
43
59
  // then creates through the plain scheduler APIs. Writes never fall back.
@@ -105,7 +121,11 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
105
121
  delete listed[task.name];
106
122
  return find(task, false);
107
123
  });
108
- }).catch(function (e) { return {state: ["102","103","104","dsm_102","dsm_103","dsm_104"].indexOf(String(e && e.code)) >= 0 ? "unsupported" : "blocked", reason: reason(e), code: codeOf(e)}; });
124
+ }).catch(function (e) {
125
+ var result = block({}, e);
126
+ if (["102","103","104","dsm_102","dsm_103","dsm_104"].indexOf(String(e && e.code)) >= 0) result.state = "unsupported";
127
+ return result;
128
+ });
109
129
  }
110
130
  function read(cached) {
111
131
  try { admin(); } catch (e) { return Promise.resolve(block({tasks: {}}, e)); }
@@ -113,7 +133,7 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
113
133
  var result = {state: "ready", tasks: {}};
114
134
  options.tasks.forEach(function (t, i) {
115
135
  result.tasks[t.kind] = found[i];
116
- if (found[i].state === "blocked" || (found[i].state !== "ready" && result.state === "ready")) { result.state = found[i].state; result.reason = found[i].reason; result.code = found[i].code; }
136
+ if (found[i].state === "blocked" || (found[i].state !== "ready" && result.state === "ready")) { result.state = found[i].state; result.reason = found[i].reason; result.code = found[i].code; result.diagnostic = found[i].diagnostic; }
117
137
  });
118
138
  return result;
119
139
  });
@@ -124,7 +144,10 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
124
144
  var failed;
125
145
  return created.reduceRight(function (withdrawn, task) {
126
146
  return withdrawn.then(function () { return find(task); }).then(function (current) {
127
- if (current.state === "ready") return remove(task, current.ref);
147
+ if (current.state === "ready") return remove(task, current.ref).then(function () { return find(task); }).then(function (after) {
148
+ if (after.state !== "needs-admin-approval" || after.ref) throw refused(after);
149
+ });
150
+ if (current.state !== "needs-admin-approval" || current.ref) throw refused(current);
128
151
  }).catch(function (e) { failed = reason(e); });
129
152
  }, Promise.resolve()).then(function () { return failed; });
130
153
  }
@@ -135,7 +158,11 @@ export const ROOT_RUNTIME = `function createRootAccess(options) {
135
158
  return removed.reduceRight(function (restored, earlier) {
136
159
  return restored.then(function () { return find(earlier); }).then(function (current) {
137
160
  if (current.state === "blocked") throw refused(current);
138
- if (!current.ref) return create(earlier.kind === "boot", definition(earlier), confirmation);
161
+ if (current.state === "ready") return;
162
+ if (current.ref) throw refused(current);
163
+ return create(earlier.kind === "boot", definition(earlier), confirmation).then(function () { return find(earlier); }).then(function (restored) {
164
+ if (restored.state !== "ready") throw refused(restored);
165
+ });
139
166
  }).catch(function (e) { failed = reason(e); });
140
167
  }, Promise.resolve()).then(function () { return failed; });
141
168
  });
@@ -407,7 +434,7 @@ export const ROOT_PANEL_MESSAGES = {
407
434
  "reason.password_confirm_failed": { en: "DSM could not confirm the administrator password. Nothing was changed.", "zh-TW": "DSM 無法確認管理員密碼,沒有做任何變更。", "zh-CN": "DSM 无法确认管理员密码,没有做任何更改。", ja: "DSM で管理者パスワードを確認できませんでした。何も変更されていません。", ko: "DSM에서 관리자 비밀번호를 확인할 수 없습니다. 변경된 내용은 없습니다.", de: "DSM konnte das Administratorkennwort nicht bestätigen. Es wurde nichts geändert.", fr: "DSM n'a pas pu confirmer le mot de passe administrateur. Rien n'a été modifié.", es: "DSM no pudo confirmar la contraseña de administrador. No se ha cambiado nada.", it: "DSM non ha potuto confermare la password amministratore. Non è stato modificato nulla." },
408
435
  "reason.session_ended": { en: "The DSM session ended. Sign in to DSM again, then approve again.", "zh-TW": "DSM 工作階段已結束。請重新登入 DSM 後再核准一次。", "zh-CN": "DSM 会话已结束。请重新登录 DSM 后再批准一次。", ja: "DSM セッションが終了しました。DSM に再度サインインしてから、もう一度承認してください。", ko: "DSM 세션이 종료되었습니다. DSM에 다시 로그인한 후 다시 승인하십시오.", de: "Die DSM-Sitzung ist abgelaufen. Melden Sie sich erneut bei DSM an und genehmigen Sie dann erneut.", fr: "La session DSM a expiré. Reconnectez-vous à DSM, puis approuvez de nouveau.", es: "La sesión de DSM ha finalizado. Vuelva a iniciar sesión en DSM y apruebe de nuevo.", it: "La sessione DSM è terminata. Accedere di nuovo a DSM, quindi approvare di nuovo." },
409
436
  "reason.admin_required": { en: "Only a DSM administrator can approve.", "zh-TW": "只有 DSM 管理員可以核准。", "zh-CN": "只有 DSM 管理员可以批准。", ja: "承認できるのは DSM 管理者のみです。", ko: "DSM 관리자만 승인할 수 있습니다.", de: "Nur ein DSM-Administrator kann genehmigen.", fr: "Seul un administrateur DSM peut approuver.", es: "Solo un administrador de DSM puede aprobar.", it: "Solo un amministratore DSM può approvare." },
410
- "reason.scheduler_denied": { en: "DSM denied the administrator access to Task Scheduler. Check the DSM session; restarting the NAS resolved this before.", "zh-TW": "DSM 拒絕了管理員對任務排程表的存取。請檢查 DSM 工作階段;先前重新啟動 NAS 可解決此問題。", "zh-CN": "DSM 拒绝了管理员对任务计划的访问。请检查 DSM 会话;之前重新启动 NAS 可解决此问题。", ja: "DSM が管理者のタスクスケジューラへのアクセスを拒否しました。DSM セッションを確認してください。以前は NAS の再起動で解決しました。", ko: "DSM에서 관리자의 작업 스케줄러 액세스를 거부했습니다. DSM 세션을 확인하십시오. 이전에는 NAS를 다시 시작하여 해결되었습니다.", de: "DSM hat dem Administrator den Zugriff auf den Aufgabenplaner verweigert. Prüfen Sie die DSM-Sitzung; ein Neustart des NAS hat dies bisher behoben.", fr: "DSM a refusé à l'administrateur l'accès au Planificateur de tâches. Vérifiez la session DSM ; un redémarrage du NAS a déjà résolu ce problème.", es: "DSM denegó al administrador el acceso al Programador de tareas. Compruebe la sesión de DSM; reiniciar el NAS lo resolvió anteriormente.", it: "DSM ha negato all'amministratore l'accesso a Utilità di pianificazione. Controllare la sessione DSM; in passato il riavvio del NAS ha risolto il problema." },
437
+ "reason.scheduler_denied": { "en": "DSM denied Task Scheduler access. Sign out of DSM, sign in again from the DSM desktop, then select Check status. If access is still denied, contact your administrator", "zh-TW": "DSM 拒絕了管理員對任務排程表的存取。請登出 DSM,重新登入 DSM 桌面後按「檢查狀態」。若仍被拒絕,請聯絡管理員", "zh-CN": "DSM 拒绝访问任务计划。请退出 DSM,重新登录 DSM 桌面后点击“检查状态”。若仍被拒绝,请联系管理员", "ja": "DSM がタスクスケジューラへのアクセスを拒否しました。DSM からサインアウトし、DSM デスクトップに再度サインインしてから「状態を確認」を選択してください。拒否が続く場合は管理者にお問い合わせください", "ko": "DSM에서 작업 스케줄러 액세스를 거부했습니다. DSM에서 로그아웃하고 DSM 데스크톱에 다시 로그인한 후 상태 확인을 선택하십시오. 계속 거부되면 관리자에게 문의하십시오", "de": "DSM hat den Zugriff auf den Aufgabenplaner verweigert. Melden Sie sich von DSM ab und am DSM-Desktop erneut an. Wählen Sie dann „Status prüfen“. Wird der Zugriff weiterhin verweigert, wenden Sie sich an Ihren Administrator", "fr": "DSM a refusé l’accès au Planificateur de tâches. Déconnectez-vous de DSM, reconnectez-vous au bureau DSM, puis sélectionnez Vérifier l’état. Si l’accès est toujours refusé, contactez votre administrateur", "es": "DSM denegó el acceso al Programador de tareas. Cierre sesión en DSM, vuelva a entrar desde el escritorio de DSM y seleccione Comprobar estado. Si se sigue denegando el acceso, contacte con su administrador", "it": "DSM ha negato l’accesso a Utilità di pianificazione. Esci da DSM, accedi nuovamente dal desktop DSM e seleziona Verifica stato. Se l’accesso viene ancora negato, contatta l’amministratore" },
411
438
  "reason.scheduler_failed": { en: "Reading or changing the scheduled tasks failed.", "zh-TW": "讀取或變更排程任務失敗。", "zh-CN": "读取或更改计划任务失败。", ja: "スケジュール済みタスクの読み取りまたは変更に失敗しました。", ko: "예약된 작업을 읽거나 변경하지 못했습니다.", de: "Die geplanten Aufgaben konnten nicht gelesen oder geändert werden.", fr: "La lecture ou la modification des tâches planifiées a échoué.", es: "No se pudieron leer ni cambiar las tareas programadas.", it: "Impossibile leggere o modificare le attività pianificate." },
412
439
  "reason.scheduler_unsupported": { en: "This DSM's Task Scheduler does not offer what background access needs.", "zh-TW": "這台 DSM 的任務排程表不提供背景存取所需的功能。", "zh-CN": "此 DSM 的任务计划不提供后台访问所需的功能。", ja: "この DSM のタスクスケジューラには、バックグラウンドアクセスに必要な機能がありません。", ko: "이 DSM의 작업 스케줄러는 백그라운드 액세스에 필요한 기능을 제공하지 않습니다.", de: "Der Aufgabenplaner dieses DSM bietet nicht, was der Hintergrundzugriff benötigt.", fr: "Le Planificateur de tâches de ce DSM n'offre pas ce dont l'accès en arrière-plan a besoin.", es: "El Programador de tareas de este DSM no ofrece lo que necesita el acceso en segundo plano.", it: "L'Utilità di pianificazione di questo DSM non offre quanto necessario all'accesso in background." },
413
440
  "reason.task_missing": { en: "The approved tasks are not in Task Scheduler.", "zh-TW": "任務排程表中沒有已核准的任務。", "zh-CN": "任务计划中没有已批准的任务。", ja: "承認済みのタスクがタスクスケジューラにありません。", ko: "승인된 작업이 작업 스케줄러에 없습니다.", de: "Die genehmigten Aufgaben fehlen im Aufgabenplaner.", fr: "Les tâches approuvées ne figurent pas dans le Planificateur de tâches.", es: "Las tareas aprobadas no están en el Programador de tareas.", it: "Le attività approvate non sono presenti in Utilità di pianificazione." },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@synopackageland/cli",
3
- "version": "0.48.10",
3
+ "version": "0.48.12",
4
4
  "description": "Syno Package Land Developer Kit CLI",
5
5
  "type": "module",
6
6
  "bin": {
package/skills/SKILL.md CHANGED
@@ -21,6 +21,11 @@ keep the installed dependency tree and generated pins consistent.
21
21
 
22
22
  For Apps with data folders or gateway listeners, read [reference/install.md](reference/install.md). Default to an App-named dedicated DSM data share and installer-selected ports. Existing-folder access, port number format/range and required HTTPS origins use localized wizard validation before Next; detected port conflicts are nonblocking inline warnings, and an unavailable DSM port inventory does not block installation; upgrades retain port selections.
23
23
 
24
+ For private native `<audio>` / `<video>` playback and seeking, read
25
+ [reference/media.md](reference/media.md). Use SDK session-bound media grants,
26
+ owner hooks and a stable renewable URL; do not put DSM tokens in media URLs or
27
+ change DSM CSP for Blob playback.
28
+
24
29
  All CLI NAS requests share one connection path. NAS certificates are accepted by default, including self-signed, wrong-name and expired certificates. A changed certificate warns once, updates its displayed SHA-256 and continues. `host add --strict-tls` stores strict verification; `--strict-tls` or `--ca <file>` on a command opts in for that command. Read [reference/host-install.md](reference/host-install.md) for host trust and error codes.
25
30
 
26
31
  Before releasing an executor App, read [reference/approval-upgrades.md](reference/approval-upgrades.md). Run build/inspect with the previous released SPK as `--baseline` and include the approval difference in release notes. Without a comparable baseline, retention is unknown.
@@ -1,5 +1,9 @@
1
1
  # 檔案與背景工作
2
2
 
3
+ App 私人錄音/影片的原生 `<audio>`/`<video>` 播放與 seek,使用 SDK 的短效
4
+ media grant;先讀 [media.md](media.md)。File Station 下載與原生 media 是不同傳輸,
5
+ 不能將下載表單的 token URL 模式套在 App 私人媒體。
6
+
3
7
  Native-go 的 B 能力使用 `init --with files` 或 `add files`,對應 schema 2 `capabilities.files: session`。File tree 與共用 NasPicker 以 TreeView/DataGrid 顯示本人可見內容;一般選取不建立授權;delegate destination 選取例外,確認即授權。FilePicker 選瀏覽器本機檔案。上傳/下載使用 streaming transport,不把內容放進 JSON。每次以呼叫者有效 DSM session 由 File Station 判權,不需管理員進行能力設定。
4
8
 
5
9
  SDK 的 delegated `files.write` 逐檔上限為 100 MiB;`files.read` 與
@@ -0,0 +1,51 @@
1
+ # 原生私人音訊與影片
2
+
3
+ 私人錄音/影片要使用原生 `<audio>`/`<video>` 時,採用 SDK Go `media`
4
+ service 與前端 `mediaUrl(ctx, {asset})`。完整接線與安全契約見
5
+ [SDK media 文件](https://github.com/synopackageland/syno-pkg-land-sdk/blob/main/docs/media.md)。
6
+ 先確認專案解析到的 SDK 確實匯出這些 API,再更新 matching Go/npm SDK pins 與
7
+ lockfiles;不要臆造版本或僅升級其中一端。此能力不新增 CLI flag 或 capability。
8
+
9
+ 原生 media element 不能加 `X-SYNO-TOKEN` header;認證 fetch 成功不代表轉成
10
+ Blob URL 就能播放,DSM shell CSP 可能禁止 `blob:` media。不要修改 CSP、放
11
+ SynoToken 到 URL、開 public route、使用 Service Worker 或以 root App 解決。
12
+
13
+ 後端以 `dsm.NewMediaAuthenticator(entryMode, packageID)` 配置不使用 cache 的
14
+ media admission,再用 `media.Service.Authenticator(existingAuthenticator)` 保留
15
+ 其他 RPC 的既有身份檢查。issue/renew 仍需正常 cookie + header token + owner hook。
16
+ 若既有 middleware 在 SDK Server 之前強制 header,只讓固定 media selector 進入
17
+ SDK 的完整 admission;不普遍略過認證。
18
+
19
+ App 自己的 operations.json 必須宣告 `media.issue`、`media.renew`、`media.revoke`
20
+ 三個 write JSON RPC 與 `media.content` stream,全部至少 authenticated,然後
21
+ 執行既有 `ctl generate` 產生 permissions/型別。自訂 prefix 必須在 Go、前端與
22
+ operation registry 一致。media issue/renew/revoke 不可標成 read recovery 或自動重送。
23
+
24
+ App 必須提供可信的 current install generation、每次重查 owner/read 權限的
25
+ Authorize hook,以及開啟同一已授權 immutable asset 的 Open hook。generation 必須
26
+ 隨重新安裝/升級替換,不能只在 daemon 啟動時截取,也不能用版本字串或 browser params。
27
+ Open 回傳 seekable content、明確 audio/video Content-Type 與對應 bytes 的強 ETag。
28
+ 不要讓 asset id 直接成為任意檔案路徑;admin 也不能略過 owner hook。
29
+
30
+ URL 只有固定 method selector 與高熵 `media_grant`。每次 GET/HEAD/Range 仍需原本
31
+ DSM id cookie 與 SDK 的加密 HttpOnly media cookie,並即時檢查 session、UID、App entry、
32
+ install generation、owner、撤銷。不同使用者或同使用者的不同 session 均不得互用。
33
+ SDK 只在 request memory 還原 token 給 DSM;磁碟保存 grant/session hashes、binding
34
+ metadata 與私有加密 key,不保存 DSM token/cookie。
35
+
36
+ 預設 TTL 五分鐘,最高三十分鐘;是憑證有效期,不是播放或工作的失敗 timeout。
37
+ `mediaUrl` 在 TTL 一半時以已認證 RPC 續期相同 URL,GET/HEAD/Range 活動也延長
38
+ 有效期;不替換 src 或改 currentTime。錯誤由 helper.error/onError 回報且停止自動
39
+ 續期;讓 App 明確重試或登入後重新 issue,不隱藏重送。unmount 時 dispose,並由 App
40
+ pause、移除 src、load 釋放媒體。revoke 阻擋下一請求;已交付 bytes/已開啟 response
41
+ 無法收回。native seek、Range 206、Content-Range、HEAD、If-Range/ETag 沿用 HTTP。
42
+
43
+ HTTP 依 SDK 政策允許並警告;建議 HTTPS 保護 session cookie。不要把 grant 轉送
44
+ 其他 origin/CDN。回應 private,no-store/no-referrer/nosniff/same-origin CORP。
45
+ 記錄診斷只用 SDK observer/redactor;精確欄位 `media_grant` 與 URL 中該 query
46
+ 值應遮罩,client response 不遮。reverse proxy/DSM access log 必須省略 query、
47
+ Cookie/Set-Cookie;SDK 無法清洗程序外的 log。
48
+
49
+ 開發驗證至少涵蓋簽發、cookie/subject/UID/entry/generation/asset 綁定、過期、
50
+ 撤銷、權限撤回、Range/HEAD/ETag、非 GET/HEAD 拒絕、log 無 grant,以及前端穩定 URL
51
+ 續期與 dispose。單元測試或本機瀏覽器不等於真機 DSM shell 播放+seek 驗收。