dsh-config-manager 0.4.1 → 0.4.3
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/README.md +14 -0
- package/lib/cli/actions.js +2 -3
- package/lib/cli/import-source.js +2 -6
- package/lib/cli/index.js +2 -3
- package/lib/client.d.ts +5 -5
- package/lib/client.js +26250 -25872
- package/lib/core/access-mode.d.ts +25 -0
- package/lib/core/access-mode.js +28 -0
- package/lib/core/exporter.js +2 -4
- package/lib/core/host-schedulers/cache-cleanup.d.ts +41 -0
- package/lib/core/host-schedulers/cache-cleanup.js +45 -0
- package/lib/core/host-schedulers/lifecycle-hooks.d.ts +51 -0
- package/lib/core/host-schedulers/lifecycle-hooks.js +78 -0
- package/lib/core/host-schedulers/market-cache.d.ts +40 -0
- package/lib/core/host-schedulers/market-cache.js +92 -0
- package/lib/core/model-tools.js +2 -6
- package/lib/core/restore.d.ts +0 -2
- package/lib/core/restore.js +16 -18
- package/lib/core/verify-recovery.js +4 -7
- package/lib/index.d.ts +3 -22
- package/lib/index.js +74 -330
- package/lib/profiles/dsh-profile-manager.d.ts +23 -1
- package/lib/profiles/dsh-profile-manager.js +70 -2
- package/lib/routes/kit.d.ts +61 -1
- package/lib/routes/kit.js +72 -3
- package/lib/routes/prefs.js +6 -6
- package/lib/routes/recovery.js +25 -41
- package/lib/routes/request-trust.d.ts +28 -0
- package/lib/routes/request-trust.js +65 -0
- package/lib/routes/route-support.d.ts +23 -1
- package/lib/routes/route-support.js +185 -0
- package/lib/routes/snapshots.js +4 -11
- package/lib/routes/sync.js +5 -7
- package/lib/security/redaction.d.ts +5 -1
- package/lib/security/redaction.js +26 -23
- package/lib/sync/backup-scheduler.js +2 -6
- package/lib/ui/backup-inspect.d.ts +1 -1
- package/lib/ui/dsh-profiles-view.d.ts +0 -10
- package/lib/ui/dsh-profiles-view.js +3 -7
- package/lib/ui/snapshots-view.d.ts +0 -14
- package/lib/ui/snapshots-view.js +16 -2
- package/lib/utils/paths.d.ts +20 -4
- package/lib/utils/paths.js +22 -6
- package/lib/utils/time.d.ts +31 -0
- package/lib/utils/time.js +54 -0
- package/package.json +1 -1
- package/src/cli/actions.ts +2 -3
- package/src/cli/import-source.ts +2 -7
- package/src/cli/index.ts +2 -3
- package/src/client/about/AboutPanel.tsx +8 -1
- package/src/client/about/ReleaseBody.tsx +22 -52
- package/src/client/about/ReleaseNotesDialog.tsx +15 -69
- package/src/client/about/release-notes-view.ts +4 -11
- package/src/client/common/access-mode.ts +21 -0
- package/src/client/common/info-hint-guard.test.ts +11 -5
- package/src/client/common/ui.tsx +23 -0
- package/src/client/config-manager.module.css +201 -32
- package/src/client/css-token-guard.test.ts +135 -1
- package/src/client/home/HomePanel.tsx +31 -6
- package/src/client/import/ConflictList.tsx +3 -3
- package/src/client/import/ImportWizardView.tsx +1 -1
- package/src/client/library/ArtifactRow.tsx +2 -2
- package/src/client/library/RestorePlanView.tsx +21 -9
- package/src/client/library/report-dismiss.test.ts +5 -3
- package/src/client/locales/about.ts +103 -0
- package/src/client/locales/backup.ts +141 -0
- package/src/client/locales/common.ts +113 -0
- package/src/client/locales/export.ts +184 -0
- package/src/client/locales/foreign.ts +184 -0
- package/src/client/locales/import-compat.ts +32 -0
- package/src/client/locales/import.ts +192 -0
- package/src/client/locales/next-steps.ts +25 -0
- package/src/client/locales/overview-control.ts +32 -0
- package/src/client/locales/overview.ts +153 -0
- package/src/client/locales/profiles.ts +263 -0
- package/src/client/locales/report.ts +17 -0
- package/src/client/locales/restore.ts +132 -0
- package/src/client/locales/sessions.ts +257 -0
- package/src/client/locales/shell.ts +149 -0
- package/src/client/locales.ts +49 -1783
- package/src/client/market/MarketImportReview.tsx +2 -2
- package/src/client/market/MarketPanel.tsx +1 -1
- package/src/client/market/market-view.ts +3 -5
- package/src/client/recovery/RecoveryPanel.tsx +62 -1054
- package/src/client/recovery/SessionHealthCard.tsx +134 -0
- package/src/client/recovery/SessionHealthDialog.tsx +665 -0
- package/src/client/recovery/SessionLayoutSection.tsx +284 -0
- package/src/client/recovery/recovery-api.ts +10 -1
- package/src/client/recovery/recovery-panel-layout.test.ts +20 -5
- package/src/client/recovery/session-dialog-mount.test.ts +16 -9
- package/src/client/recovery/use-recovery-write.test.ts +90 -0
- package/src/client/recovery/use-recovery-write.ts +53 -0
- package/src/client/run-store.ts +57 -2
- package/src/client/sync/PushPreviewCard.tsx +2 -2
- package/src/client/sync/SyncConfirmView.tsx +5 -5
- package/src/client/sync/SyncLogList.tsx +2 -2
- package/src/client/sync/history-model.ts +4 -5
- package/src/client/sync/sync-view.ts +3 -4
- package/src/core/access-mode.ts +37 -0
- package/src/core/exporter.ts +2 -4
- package/src/core/host-schedulers/cache-cleanup.test.ts +84 -0
- package/src/core/host-schedulers/cache-cleanup.ts +74 -0
- package/src/core/host-schedulers/lifecycle-hooks.test.ts +111 -0
- package/src/core/host-schedulers/lifecycle-hooks.ts +118 -0
- package/src/core/host-schedulers/market-cache.test.ts +93 -0
- package/src/core/host-schedulers/market-cache.ts +116 -0
- package/src/core/model-tools.ts +2 -7
- package/src/core/restore-failure-state.test.ts +210 -0
- package/src/core/restore.ts +16 -18
- package/src/core/verify-recovery.ts +4 -7
- package/src/index.ts +81 -335
- package/src/profiles/dsh-profile-copy-rollback.test.ts +156 -0
- package/src/profiles/dsh-profile-manager.ts +71 -3
- package/src/routes/kit.ts +106 -3
- package/src/routes/prefs.ts +6 -6
- package/src/routes/recovery.ts +25 -42
- package/src/routes/request-trust.ts +97 -0
- package/src/routes/route-support.ts +208 -1
- package/src/routes/snapshots.ts +4 -9
- package/src/routes/sync.ts +4 -7
- package/src/security/redaction.ts +29 -23
- package/src/sync/backup-scheduler.ts +3 -6
- package/src/sync/sync-config.test.ts +24 -13
- package/src/ui/backup-inspect.ts +1 -1
- package/src/ui/dsh-profiles-view.ts +3 -5
- package/src/ui/i18n.test.ts +8 -3
- package/src/ui/snapshots-view.ts +2 -2
- package/src/utils/paths.test.ts +36 -1
- package/src/utils/paths.ts +30 -6
- package/src/utils/time.test.ts +46 -0
- package/src/utils/time.ts +55 -0
package/README.md
CHANGED
|
@@ -627,6 +627,20 @@ dsh-config-manager web # starts it and opens your browser (the termin
|
|
|
627
627
|
- **Safety:** loopback-only binding; a one-time token printed to your terminal is exchanged for an HttpOnly + SameSite=Strict session cookie; the page has no scripts and no external resources. `Ctrl+C` or the idle timeout (30 minutes by default) shuts it down.
|
|
628
628
|
- **Preconditions:** session relocation and restore need DSH stopped; with an unresolved SAFE MODE transaction or a leftover environment lock every write action is refused (the page says why). **Import** (writing a bundle back into this machine) stays on the GUI/CLI — structural sections need live DSH services.
|
|
629
629
|
|
|
630
|
+
### 🔒 Opening the panel from another machine (LAN / tunnel)
|
|
631
|
+
|
|
632
|
+
The panel's API is fenced: every `/api/dsh-config-manager/*` request is accepted only from **loopback** (`127.0.0.1` / `localhost`), or from an address and session the host itself already trusts.
|
|
633
|
+
|
|
634
|
+
```bash
|
|
635
|
+
# recommended: keep the host on loopback and tunnel in
|
|
636
|
+
ssh -L 3080:127.0.0.1:3080 you@server # then open http://localhost:3080
|
|
637
|
+
```
|
|
638
|
+
|
|
639
|
+
- **Why it is fenced:** these endpoints read and write local files, credentials-backed sync settings and snapshots. Loopback requests are let through; anything else is decided by the host itself (Host / bind address, same-origin, and a signed `dsh-auth` session cookie). The plugin never validates sessions on its own, so a proxy or tunnel in front of it still needs its own auth.
|
|
640
|
+
- **`dsh web --host <LAN address>`:** the page itself loads from another machine, but the panel then only works if the host trusts that address **and** the browser carries a signed `dsh-auth` session cookie. `--host` takes one concrete interface address — wildcard addresses such as `0.0.0.0` are rejected by the host. Behind a proxy, add the authority the browser uses with `--trusted-host <authority>` (repeatable, `host` or `host:port`); `--public-url` advertises a URL but grants no trust.
|
|
641
|
+
- **What you see when it is not allowed:** a single **“This page cannot read local data from its current address”** banner with the page's origin and the fix — not a generic “5 requests failed”, and no useless Retry button.
|
|
642
|
+
- **Not affected:** the CLI (`dsh-config-manager …`) and the agent tools (`config_backup`, `config_list_snapshots`, `config_sync_*`) never go through this fence.
|
|
643
|
+
|
|
630
644
|
### 🌐 Behind a proxy? (GitHub login / sync)
|
|
631
645
|
|
|
632
646
|
Node's built-in `fetch()` does **not** read `HTTP_PROXY` / `HTTPS_PROXY` by default, so on networks where GitHub is only reachable through a local proxy, "Sign in with GitHub" would previously fail with `请求 GitHub 设备码失败:fetch failed` even though your browser and `git` work fine.
|
package/lib/cli/actions.js
CHANGED
|
@@ -28,6 +28,7 @@ import { readTextSafe } from '../profiles/dsh-profile-io.js';
|
|
|
28
28
|
import { AUTO_BACKUP_PREFIX, DEFAULT_BACKUP_RETENTION, listBackupFiles, } from '../sync/backup-files.js';
|
|
29
29
|
import { EnvironmentLockManager, OWNERSHIP_FILE } from '../utils/env-lock.js';
|
|
30
30
|
import { scanSessionHealth } from '../utils/session-health-scan.js';
|
|
31
|
+
import { formatDateStamp } from '../utils/time.js';
|
|
31
32
|
/* ------------------------------------------------------------ 进程/实例事实 */
|
|
32
33
|
/** 进程是否存活(不发送信号,只探测)。EPERM = 存在但无权限发信号 → 仍算存活。 */
|
|
33
34
|
export function isProcessAlive(pid) {
|
|
@@ -970,9 +971,7 @@ export async function exportOfflineBackup(paths, sections) {
|
|
|
970
971
|
if (collection.entries.length === 0) {
|
|
971
972
|
return { ok: false, code: 'nothing-to-export', message: '没有可打包的内容(该 home 下未找到可离线收集的分区)。' };
|
|
972
973
|
}
|
|
973
|
-
const
|
|
974
|
-
const stamp = String(now.getFullYear()) + String(now.getMonth() + 1).padStart(2, '0') + String(now.getDate()).padStart(2, '0')
|
|
975
|
-
+ '-' + String(now.getHours()).padStart(2, '0') + String(now.getMinutes()).padStart(2, '0') + String(now.getSeconds()).padStart(2, '0');
|
|
974
|
+
const stamp = formatDateStamp();
|
|
976
975
|
const { randomBytes } = await import('node:crypto');
|
|
977
976
|
const desired = 'dsh-config-cli-' + stamp + '-' + randomBytes(4).toString('hex') + '.zip';
|
|
978
977
|
await fsp.mkdir(paths.exportsDir, { recursive: true });
|
package/lib/cli/import-source.js
CHANGED
|
@@ -21,6 +21,7 @@ import { verifyBackupZip } from '../core/backup-verify.js';
|
|
|
21
21
|
import { writeForeignBundle } from '../foreign/bundle.js';
|
|
22
22
|
import { FOREIGN_CONFLICT_POLICY, ForeignSourceError, createBuiltinForeignSourceRegistry, } from '../foreign/registry.js';
|
|
23
23
|
import { foreignSourceContext } from '../routes/foreign-context.js';
|
|
24
|
+
import { formatDateStamp } from '../utils/time.js';
|
|
24
25
|
/** 分区摘要的一行:文件类给文件数,JSON 类给该分区的计数键(全部是机器可读的条目数) */
|
|
25
26
|
function sectionLine(section, result) {
|
|
26
27
|
if (section.files !== undefined)
|
|
@@ -67,7 +68,7 @@ function printImportSummary(sourceId, detection, result, io) {
|
|
|
67
68
|
async function resolveOutPath(options, sourceId) {
|
|
68
69
|
const desired = options.out !== undefined && options.out !== ''
|
|
69
70
|
? path.resolve(options.out)
|
|
70
|
-
: path.join(options.exportsDir, 'foreign-' + sourceId + '-' +
|
|
71
|
+
: path.join(options.exportsDir, 'foreign-' + sourceId + '-' + formatDateStamp() + '-' + randomHex4() + '.zip');
|
|
71
72
|
if (!(await pathExists(desired)))
|
|
72
73
|
return desired;
|
|
73
74
|
const base = desired.endsWith('.zip') ? desired.slice(0, -4) : desired;
|
|
@@ -77,11 +78,6 @@ async function resolveOutPath(options, sourceId) {
|
|
|
77
78
|
return candidate;
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
|
-
function stamp() {
|
|
81
|
-
const now = new Date();
|
|
82
|
-
return `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}`
|
|
83
|
-
+ `-${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;
|
|
84
|
-
}
|
|
85
81
|
function randomHex4() {
|
|
86
82
|
// 用全局 crypto(Node ≥ 19);零额外依赖
|
|
87
83
|
const bytes = new Uint8Array(4);
|
package/lib/cli/index.js
CHANGED
|
@@ -39,6 +39,7 @@ import { buildChecksums } from '../utils/hashing.js';
|
|
|
39
39
|
import { stringifyJsonSafe } from '../utils/json.js';
|
|
40
40
|
import { buildManifest, CHECKSUMS_FILE, MANIFEST_FILE } from '../schema/manifest.js';
|
|
41
41
|
import { writeZip } from '../utils/zip.js';
|
|
42
|
+
import { formatDateStamp } from '../utils/time.js';
|
|
42
43
|
const VALUE_FLAGS = new Map([
|
|
43
44
|
['--data-dir', 'dataDir'],
|
|
44
45
|
['--data-root', 'dataRoot'],
|
|
@@ -1191,9 +1192,7 @@ async function runBackup(options, io, env) {
|
|
|
1191
1192
|
}
|
|
1192
1193
|
else {
|
|
1193
1194
|
// 注意:此处刻意不 mkdir —— dry-run 必须零写入,目录在真正落盘前才创建
|
|
1194
|
-
const
|
|
1195
|
-
const stamp = `${now.getFullYear()}${String(now.getMonth() + 1).padStart(2, '0')}${String(now.getDate()).padStart(2, '0')}`
|
|
1196
|
-
+ `-${String(now.getHours()).padStart(2, '0')}${String(now.getMinutes()).padStart(2, '0')}${String(now.getSeconds()).padStart(2, '0')}`;
|
|
1195
|
+
const stamp = formatDateStamp();
|
|
1197
1196
|
try {
|
|
1198
1197
|
const rand = await randomHex4();
|
|
1199
1198
|
outPath = await resolveNonCollidingName(exportsDir, `dsh-config-cli-${stamp}-${rand}.zip`);
|
package/lib/client.d.ts
CHANGED
|
@@ -5014,11 +5014,6 @@ interface ConfigManagerSectionInjected {
|
|
|
5014
5014
|
*/
|
|
5015
5015
|
uiT: UiT;
|
|
5016
5016
|
}
|
|
5017
|
-
/**
|
|
5018
|
-
* Config Manager 表面文案:zh 为源语言,en 镜像每个键。
|
|
5019
|
-
* 字典 namespace 由 client/index.ts 注册(declare module 合并进 LocaleNamespaceMap)。
|
|
5020
|
-
* 键集合通过 `ConfigManagerKey` 类型在注册处做编译期校验(缺键/多键即编译错误)。
|
|
5021
|
-
*/
|
|
5022
5017
|
declare const zh$4: {
|
|
5023
5018
|
readonly 'section.label': '备份与迁移';
|
|
5024
5019
|
readonly 'section.description': '导出 / 导入 / 迁移 DSH 配置(备份不含密钥,加密备份可选)';
|
|
@@ -5105,6 +5100,9 @@ declare const zh$4: {
|
|
|
5105
5100
|
readonly 'overview.activity.empty': '暂无操作记录';
|
|
5106
5101
|
readonly 'overview.activity.unavailable': '活动记录读取失败(这不是「没有记录」)';
|
|
5107
5102
|
readonly 'overview.loadFailed': '有 {count} 项数据读取失败:{message} —— 下面的指标可能不完整';
|
|
5103
|
+
readonly 'overview.accessMode.title': '当前访问方式不被允许读取本机数据。';
|
|
5104
|
+
readonly 'overview.accessMode.origin': '页面地址:{origin}。';
|
|
5105
|
+
readonly 'overview.accessMode.hint': '面板只接受本机回环访问,或宿主已信任的地址与已登录会话。改法:用 ssh -L 3080:127.0.0.1:3080 隧道后从 localhost 打开;或以 dsh web --host 127.0.0.1 启动后在本机访问;若本就在可信地址上,重新打开 dsh web 打印的访问链接(会话可能已过期)。';
|
|
5108
5106
|
readonly 'overview.empty.title': '开始保护你的配置';
|
|
5109
5107
|
readonly 'overview.empty.step1': '创建第一份备份';
|
|
5110
5108
|
readonly 'overview.empty.step2': '导出 ZIP 带走';
|
|
@@ -5460,6 +5458,8 @@ declare const zh$4: {
|
|
|
5460
5458
|
readonly 'about.cli.title': 'CLI 救援工具';
|
|
5461
5459
|
readonly 'about.cli.hint': 'GUI 运行在 DSH 内部——DSH 无法启动时,独立安装的 CLI(dsh-config-manager)是第一救援手段:列快照 / 离线恢复 / 一键重装 DSH,全程无需 DSH 运行。安装一次即可在任何机器上用:';
|
|
5462
5460
|
readonly 'about.cli.docs': 'CLI 使用文档';
|
|
5461
|
+
readonly 'about.access.title': '访问范围';
|
|
5462
|
+
readonly 'about.access.hint': '本面板只接受两种来源:本机回环地址(127.0.0.1 / localhost),或宿主已信任的地址与已登录的 dsh web 会话。用 dsh web --host <局域网地址> 启动后从别的机器打开时,页面能加载但读不到本机数据——改用 ssh -L 3080:127.0.0.1:3080 隧道从 localhost 打开即可。CLI 与 agent 工具不受此限制。';
|
|
5463
5463
|
readonly 'profiles.title': '档案';
|
|
5464
5464
|
readonly 'profiles.subtitle': '管理 DSH 自带的 profile($DSH_HOME/profiles/<name>):每个档案 = 一套插件组合(bundles)+ 依赖 + patch 层,用 dsh --profile <name> 启动。';
|
|
5465
5465
|
readonly 'profiles.loading': '加载档案中…';
|