dsh-auth-remote 0.1.0
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 +16 -0
- package/CHANGELOG.zh-CN.md +16 -0
- package/CONTRIBUTING.md +23 -0
- package/CONTRIBUTING.zh-CN.md +23 -0
- package/LICENSE +21 -0
- package/README.md +65 -0
- package/README.zh-CN.md +65 -0
- package/cordis.patch.yml +45 -0
- package/dist/cli.js +1858 -0
- package/dist/cli.js.map +7 -0
- package/dist/client.js +3076 -0
- package/dist/client.js.map +7 -0
- package/dist/index.js +2473 -0
- package/dist/index.js.map +7 -0
- package/dist/login.css +230 -0
- package/dist/login.css.map +7 -0
- package/dist/login.js +2865 -0
- package/dist/login.js.map +7 -0
- package/dist/types/adapters/dsh/browser-auth.d.ts +8 -0
- package/dist/types/adapters/dsh/browser-auth.d.ts.map +1 -0
- package/dist/types/adapters/dsh/browser-capability.d.ts +8 -0
- package/dist/types/adapters/dsh/browser-capability.d.ts.map +1 -0
- package/dist/types/adapters/dsh/compatibility.d.ts +7 -0
- package/dist/types/adapters/dsh/compatibility.d.ts.map +1 -0
- package/dist/types/adapters/dsh/readiness.d.ts +22 -0
- package/dist/types/adapters/dsh/readiness.d.ts.map +1 -0
- package/dist/types/adapters/dsh/startup-urls.d.ts +4 -0
- package/dist/types/adapters/dsh/startup-urls.d.ts.map +1 -0
- package/dist/types/adapters/dsh/webserver.d.ts +36 -0
- package/dist/types/adapters/dsh/webserver.d.ts.map +1 -0
- package/dist/types/auth/password.d.ts +12 -0
- package/dist/types/auth/password.d.ts.map +1 -0
- package/dist/types/auth/service.d.ts +90 -0
- package/dist/types/auth/service.d.ts.map +1 -0
- package/dist/types/auth/sessions.d.ts +8 -0
- package/dist/types/auth/sessions.d.ts.map +1 -0
- package/dist/types/auth/totp.d.ts +10 -0
- package/dist/types/auth/totp.d.ts.map +1 -0
- package/dist/types/cli/index.d.ts +3 -0
- package/dist/types/cli/index.d.ts.map +1 -0
- package/dist/types/cli/ipc-client.d.ts +18 -0
- package/dist/types/cli/ipc-client.d.ts.map +1 -0
- package/dist/types/cli/language.d.ts +14 -0
- package/dist/types/cli/language.d.ts.map +1 -0
- package/dist/types/cli/profile.d.ts +10 -0
- package/dist/types/cli/profile.d.ts.map +1 -0
- package/dist/types/cli/prompt.d.ts +20 -0
- package/dist/types/cli/prompt.d.ts.map +1 -0
- package/dist/types/config.d.ts +27 -0
- package/dist/types/config.d.ts.map +1 -0
- package/dist/types/http/admin-socket.d.ts +18 -0
- package/dist/types/http/admin-socket.d.ts.map +1 -0
- package/dist/types/http/connections.d.ts +21 -0
- package/dist/types/http/connections.d.ts.map +1 -0
- package/dist/types/http/gate.d.ts +24 -0
- package/dist/types/http/gate.d.ts.map +1 -0
- package/dist/types/http/origin-policy.d.ts +35 -0
- package/dist/types/http/origin-policy.d.ts.map +1 -0
- package/dist/types/http/origin.d.ts +5 -0
- package/dist/types/http/origin.d.ts.map +1 -0
- package/dist/types/http/request-context.d.ts +5 -0
- package/dist/types/http/request-context.d.ts.map +1 -0
- package/dist/types/http/routes.d.ts +15 -0
- package/dist/types/http/routes.d.ts.map +1 -0
- package/dist/types/index.d.ts +33 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/shared/admin-contract.d.ts +40 -0
- package/dist/types/shared/admin-contract.d.ts.map +1 -0
- package/dist/types/shared/auth-contract.d.ts +33 -0
- package/dist/types/shared/auth-contract.d.ts.map +1 -0
- package/dist/types/shared/i18n.d.ts +323 -0
- package/dist/types/shared/i18n.d.ts.map +1 -0
- package/dist/types/shared/locales/en.d.ts +151 -0
- package/dist/types/shared/locales/en.d.ts.map +1 -0
- package/dist/types/shared/locales/zh.d.ts +150 -0
- package/dist/types/shared/locales/zh.d.ts.map +1 -0
- package/dist/types/storage/lock.d.ts +17 -0
- package/dist/types/storage/lock.d.ts.map +1 -0
- package/dist/types/storage/state.d.ts +34 -0
- package/dist/types/storage/state.d.ts.map +1 -0
- package/dist/types/storage/store.d.ts +30 -0
- package/dist/types/storage/store.d.ts.map +1 -0
- package/docs/deployment.md +89 -0
- package/docs/deployment.zh-CN.md +89 -0
- package/docs/development.md +43 -0
- package/docs/development.zh-CN.md +43 -0
- package/docs/releasing.md +44 -0
- package/docs/releasing.zh-CN.md +44 -0
- package/docs/reverse-proxy.md +27 -0
- package/docs/reverse-proxy.zh-CN.md +27 -0
- package/examples/nginx.conf +27 -0
- package/examples/traefik-dsh.yml +20 -0
- package/examples/web-profile-auth-remote.patch.yml +14 -0
- package/package.json +112 -0
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
export declare const zh: {
|
|
2
|
+
readonly brand: "DSH · 远程登录";
|
|
3
|
+
readonly errorNetwork: "连接失败,请检查网络后重试。";
|
|
4
|
+
readonly errorRateLimited: "尝试过于频繁,请约 {seconds} 秒后重试。";
|
|
5
|
+
readonly errorUnauthorized: "会话已失效,请重新登录。";
|
|
6
|
+
readonly errorServiceUnavailable: "服务暂时不可用,请稍后重试。";
|
|
7
|
+
readonly errorGeneric: "操作未完成,请重试。";
|
|
8
|
+
readonly loginInitialTitle: "登录 DSH";
|
|
9
|
+
readonly loginInitialLoading: "正在检查登录状态…";
|
|
10
|
+
readonly loginLanguageLabel: "语言";
|
|
11
|
+
readonly loginSetupTitle: "先初始化账号";
|
|
12
|
+
readonly loginSetupDescription: "请在运行 DSH 的服务器终端输入下列命令,然后按提示创建用户名和密码。网页不会创建账号。";
|
|
13
|
+
readonly loginSetupCopy: "复制命令";
|
|
14
|
+
readonly loginSetupRecheck: "我已完成初始化";
|
|
15
|
+
readonly loginSetupCopied: "命令已复制。";
|
|
16
|
+
readonly loginSetupCopyFallback: "请手动选择并复制命令。";
|
|
17
|
+
readonly loginSetupNotFound: "尚未检测到账号。请确认命令使用了当前 profile,再重新检查。";
|
|
18
|
+
readonly loginTitle: "登录 DSH";
|
|
19
|
+
readonly loginDescription: "输入服务器终端创建的单用户账号。";
|
|
20
|
+
readonly loginUsername: "用户名";
|
|
21
|
+
readonly loginPassword: "密码";
|
|
22
|
+
readonly loginContinue: "继续";
|
|
23
|
+
readonly loginMfaTitle: "验证第二因素";
|
|
24
|
+
readonly loginMfaDescription: "输入身份验证器中的 6 位数字,或输入一次性备用码。挑战 5 分钟后失效。";
|
|
25
|
+
readonly loginMfaCode: "验证码或备用码";
|
|
26
|
+
readonly loginMfaSubmit: "验证并登录";
|
|
27
|
+
readonly loginBackToPassword: "返回密码登录";
|
|
28
|
+
readonly loginMfaExhausted: "本次挑战已用尽,请重新输入密码。";
|
|
29
|
+
readonly loginBindingTitle: "绑定身份验证器";
|
|
30
|
+
readonly loginBindingDescription: "使用身份验证器扫描二维码,或手动输入下方密钥。确认成功后将显示 10 个一次性备用码,并要求重新登录。";
|
|
31
|
+
readonly loginBindingQrAlt: "身份验证器绑定二维码";
|
|
32
|
+
readonly loginBindingManualSecret: "手工密钥";
|
|
33
|
+
readonly loginBindingCode: "身份验证器中的 6 位验证码";
|
|
34
|
+
readonly loginBindingConfirm: "确认绑定";
|
|
35
|
+
readonly loginBindingRestart: "重新登录";
|
|
36
|
+
readonly loginBindingQrUnavailable: "二维码暂不可用,请使用上方手工密钥。";
|
|
37
|
+
readonly loginBindingExhausted: "绑定挑战已用尽,请重新输入密码。";
|
|
38
|
+
readonly loginBackupTitle: "保存备用码";
|
|
39
|
+
readonly loginBackupDescription: "这些备用码只会显示这一次。请存放在安全的位置,每个备用码只能使用一次。保存后重新登录。";
|
|
40
|
+
readonly loginBackupSaved: "我已保存,重新登录";
|
|
41
|
+
readonly loginOptionalTitle: "保护你的账号";
|
|
42
|
+
readonly loginOptionalDescription: "当前 profile 允许稍后绑定身份验证器。现在绑定可以增加保护;跳过后也可在安全设置中绑定。";
|
|
43
|
+
readonly loginOptionalBindNow: "现在绑定 TOTP";
|
|
44
|
+
readonly loginOptionalSkip: "跳过,进入 DSH";
|
|
45
|
+
readonly loginOptionalVerifyTitle: "再次验证后绑定";
|
|
46
|
+
readonly loginOptionalVerifyDescription: "为保护账号,请再次输入当前密码。";
|
|
47
|
+
readonly loginOptionalCurrentPassword: "当前密码";
|
|
48
|
+
readonly loginOptionalStart: "开始绑定";
|
|
49
|
+
readonly loginOptionalSkipLater: "稍后绑定,进入 DSH";
|
|
50
|
+
readonly loginReasonExpired: "会话已失效,请重新登录。";
|
|
51
|
+
readonly loginReasonUpdated: "安全设置已更新,请重新登录。";
|
|
52
|
+
readonly loginReasonSignedOut: "已退出当前设备。";
|
|
53
|
+
readonly loginUnavailableTitle: "暂时无法登录";
|
|
54
|
+
readonly loginUnavailableDescription: "服务状态暂时无法取得,请检查连接并重试。";
|
|
55
|
+
readonly loginRetry: "重新检查";
|
|
56
|
+
readonly loginErrorInvalidCredentials: "用户名或密码不正确,请重试。";
|
|
57
|
+
readonly loginErrorInvalidFactor: "验证码或备用码不正确;连续失败 5 次后需重新输入密码。";
|
|
58
|
+
readonly loginErrorChallenge: "本次验证已失效,请重新输入用户名和密码。";
|
|
59
|
+
readonly loginErrorUninitialized: "账号尚未初始化,请先在服务器终端运行初始化命令。";
|
|
60
|
+
readonly settingsSectionLabel: "安全";
|
|
61
|
+
readonly settingsSectionAria: "安全设置";
|
|
62
|
+
readonly settingsTitle: "账号安全";
|
|
63
|
+
readonly settingsAccountSummary: "账号:{username} · TOTP:{totp}";
|
|
64
|
+
readonly settingsTotpEnabled: "已启用";
|
|
65
|
+
readonly settingsTotpNotBound: "未绑定";
|
|
66
|
+
readonly settingsLoading: "正在读取账号状态…";
|
|
67
|
+
readonly settingsChangePassword: "修改密码";
|
|
68
|
+
readonly settingsBindTotp: "绑定 TOTP";
|
|
69
|
+
readonly settingsRebindTotp: "重新绑定 TOTP";
|
|
70
|
+
readonly settingsSessions: "会话管理";
|
|
71
|
+
readonly settingsPasswordMismatch: "两次输入的新密码不一致。";
|
|
72
|
+
readonly settingsPasswordDescription: "完成后所有设备都需要重新登录。";
|
|
73
|
+
readonly settingsCurrentPassword: "当前密码";
|
|
74
|
+
readonly settingsCurrentCode: "当前验证码或备用码";
|
|
75
|
+
readonly settingsNewPassword: "新密码";
|
|
76
|
+
readonly settingsConfirmPassword: "再次输入新密码";
|
|
77
|
+
readonly settingsSavePassword: "保存新密码";
|
|
78
|
+
readonly settingsBindDescription: "请输入当前凭证;新绑定完成后所有设备都需要重新登录。";
|
|
79
|
+
readonly settingsStartBinding: "开始绑定";
|
|
80
|
+
readonly settingsDisableTotp: "关闭 TOTP";
|
|
81
|
+
readonly settingsDisableDescription: "关闭后所有设备都需要重新登录。";
|
|
82
|
+
readonly settingsScanQr: "扫描二维码";
|
|
83
|
+
readonly settingsQrAlt: "身份验证器绑定二维码";
|
|
84
|
+
readonly settingsQrUnavailable: "二维码暂不可用,请使用下方手工密钥。";
|
|
85
|
+
readonly settingsQrLoading: "二维码生成中;也可以使用下方手工密钥。";
|
|
86
|
+
readonly settingsManualSecret: "手工密钥:";
|
|
87
|
+
readonly settingsNewCode: "新身份验证器的 6 位验证码";
|
|
88
|
+
readonly settingsConfirmBinding: "确认绑定";
|
|
89
|
+
readonly settingsRestartBinding: "重新开始";
|
|
90
|
+
readonly settingsSignOutCurrent: "退出当前设备";
|
|
91
|
+
readonly settingsSignOutAll: "退出全部设备";
|
|
92
|
+
readonly settingsSignOutAllDescription: "请输入当前凭证;提交后所有已登录设备和长连接都会失效。";
|
|
93
|
+
readonly settingsBackupTitle: "保存备用码";
|
|
94
|
+
readonly settingsBackupDescription: "这些备用码只会显示这一次。请存放在安全的位置,每个备用码只能使用一次。";
|
|
95
|
+
readonly settingsBackupSaved: "我已保存,重新登录";
|
|
96
|
+
readonly settingsErrorInvalidCredentials: "当前密码不正确。";
|
|
97
|
+
readonly settingsErrorInvalidFactor: "当前验证码或备用码不正确。";
|
|
98
|
+
readonly settingsErrorInvalidInput: "输入不符合要求;密码需符合服务端长度规则。";
|
|
99
|
+
readonly settingsErrorChallenge: "绑定挑战已失效,请重新开始绑定。";
|
|
100
|
+
readonly settingsErrorTotpRequired: "当前 profile 要求 TOTP,无法关闭。";
|
|
101
|
+
readonly cliHelp: "dsh-auth-remote {version}\n\n用法:\n dsh plugin --profile web exec dsh-auth-remote [--lang en|zh] COMMAND\n\n命令:\n init 在终端交互初始化单用户账号\n status [--json] 查看不含秘密的认证状态\n reset-password 重置密码并撤销全部会话\n reset-totp 清除 TOTP、备用码及全部会话\n revoke-sessions 退出所有设备\n\n选项:\n --lang en|zh 选择人类可读输出的语言\n --help, -h 显示帮助\n --version, -v 显示包版本\n\n命令使用 dsh plugin exec 选定的 profile 和调用者的 DSH_HOME。\n";
|
|
102
|
+
readonly cliPromptUsername: "用户名: ";
|
|
103
|
+
readonly cliPromptPassword: "密码: ";
|
|
104
|
+
readonly cliPromptPasswordAgain: "再次输入密码: ";
|
|
105
|
+
readonly cliPromptNewPassword: "新密码: ";
|
|
106
|
+
readonly cliPromptNewPasswordAgain: "再次输入新密码: ";
|
|
107
|
+
readonly cliPromptConfirmTarget: "输入 {profile} 以确认 {command}: ";
|
|
108
|
+
readonly cliTargetProfile: "目标 profile: {profile}";
|
|
109
|
+
readonly cliDataFile: "数据文件: {path}";
|
|
110
|
+
readonly cliStatusProfile: "profile: {profile}";
|
|
111
|
+
readonly cliStatusAccount: "账号: {state}";
|
|
112
|
+
readonly cliStatusTotp: "TOTP: {state}";
|
|
113
|
+
readonly cliStatusSessions: "有效会话: {count}";
|
|
114
|
+
readonly cliStatusService: "服务: {state}";
|
|
115
|
+
readonly cliInitialized: "已初始化";
|
|
116
|
+
readonly cliNotInitialized: "未初始化";
|
|
117
|
+
readonly cliTotpEnabled: "已启用";
|
|
118
|
+
readonly cliTotpDisabled: "未启用";
|
|
119
|
+
readonly cliOnlineReady: "在线且就绪";
|
|
120
|
+
readonly cliOnlineNotReady: "在线但未就绪";
|
|
121
|
+
readonly cliOffline: "离线";
|
|
122
|
+
readonly cliCompleted: "{command} 已完成;变更已持久化并生效。";
|
|
123
|
+
readonly cliErrorInvalidArguments: "命令或参数无效,请使用 --help。";
|
|
124
|
+
readonly cliErrorInvalidLanguage: "--lang 的值无效,请使用 en 或 zh。";
|
|
125
|
+
readonly cliErrorDuplicateLanguage: "--lang 只能指定一次。";
|
|
126
|
+
readonly cliErrorMissingLanguage: "--lang 缺少值,请使用 en 或 zh。";
|
|
127
|
+
readonly cliErrorPasswordsMismatch: "两次输入的密码不一致。";
|
|
128
|
+
readonly cliErrorConfirmationMismatch: "确认输入与目标 profile 不一致。";
|
|
129
|
+
readonly cliErrorPasswordLength: "密码须包含 12–256 个 Unicode 字符。";
|
|
130
|
+
readonly cliErrorTerminalRequired: "此操作需要交互终端。";
|
|
131
|
+
readonly cliErrorTerminalClosed: "终端输入已关闭。";
|
|
132
|
+
readonly cliErrorCancelled: "已取消。";
|
|
133
|
+
readonly cliErrorProfileDirectory: "当前目录不是 DSH_HOME 下选定的 DSH profile。";
|
|
134
|
+
readonly cliErrorProfileManifest: "缺少 profile 的 package.json。";
|
|
135
|
+
readonly cliErrorUnsafeManagementDirectory: "管理目录权限不安全。";
|
|
136
|
+
readonly cliErrorUnsafeManagementSocket: "管理 socket 权限不安全。";
|
|
137
|
+
readonly cliErrorManagementUnavailable: "管理 socket 不可用。";
|
|
138
|
+
readonly cliErrorOutcomeUnknown: "管理请求已断开或超时,结果未知;再次操作前请先检查状态。";
|
|
139
|
+
readonly cliErrorOfflineLock: "服务仍持有 profile 锁且管理 socket 不可用,已拒绝离线操作。";
|
|
140
|
+
readonly cliErrorInvalidCredentials: "当前凭证不正确。";
|
|
141
|
+
readonly cliErrorAlreadyInitialized: "账号已初始化。";
|
|
142
|
+
readonly cliErrorInvalidInput: "输入无效。";
|
|
143
|
+
readonly cliErrorInvalidFactor: "验证码或备用码不正确。";
|
|
144
|
+
readonly cliErrorUninitialized: "账号尚未初始化。";
|
|
145
|
+
readonly cliErrorTotpRequired: "此 profile 要求 TOTP。";
|
|
146
|
+
readonly cliErrorConflict: "账号状态已变化,请检查状态后重试。";
|
|
147
|
+
readonly cliErrorBusy: "服务正忙,请稍后重试。";
|
|
148
|
+
readonly cliErrorUnknown: "操作失败;再次操作前请先检查状态。";
|
|
149
|
+
};
|
|
150
|
+
//# sourceMappingURL=zh.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"zh.d.ts","sourceRoot":"","sources":["../../../../src/shared/locales/zh.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8K0C,CAAA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
export declare const STATE_DIR = "auth-remote";
|
|
2
|
+
export declare const STATE_FILE = "auth-state.json";
|
|
3
|
+
export declare const LOCK_FILE = "auth-state.lock";
|
|
4
|
+
export declare function ensureStateDirectory(profileDir: string): Promise<string>;
|
|
5
|
+
/** Lock recovery uses a second exclusive directory, so reclaimers cannot erase one another's new lock. */
|
|
6
|
+
export declare class StateLock {
|
|
7
|
+
readonly dir: string;
|
|
8
|
+
readonly path: string;
|
|
9
|
+
private readonly owner;
|
|
10
|
+
private released;
|
|
11
|
+
private constructor();
|
|
12
|
+
static acquire(profileDir: string): Promise<StateLock>;
|
|
13
|
+
private static recoverStale;
|
|
14
|
+
release(): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
export declare function assertPrivateStateFile(path: string): Promise<void>;
|
|
17
|
+
//# sourceMappingURL=lock.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"lock.d.ts","sourceRoot":"","sources":["../../../src/storage/lock.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,SAAS,gBAAgB,CAAA;AACtC,eAAO,MAAM,UAAU,oBAAoB,CAAA;AAC3C,eAAO,MAAM,SAAS,oBAAoB,CAAA;AA+E1C,wBAAsB,oBAAoB,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAoB9E;AAED,0GAA0G;AAC1G,qBAAa,SAAS;IAIlB,QAAQ,CAAC,GAAG,EAAE,MAAM;IACpB,QAAQ,CAAC,IAAI,EAAE,MAAM;IACrB,OAAO,CAAC,QAAQ,CAAC,KAAK;IALxB,OAAO,CAAC,QAAQ,CAAQ;IAExB,OAAO;WAMM,OAAO,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,CAAC;mBA8BvC,YAAY;IA0C3B,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;CAQ/B;AAED,wBAAsB,sBAAsB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAExE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/** The only persisted representation of account and full-session state. */
|
|
2
|
+
export declare const STATE_SCHEMA_VERSION = 1;
|
|
3
|
+
export interface PasswordRecord {
|
|
4
|
+
salt: string;
|
|
5
|
+
hash: string;
|
|
6
|
+
}
|
|
7
|
+
export interface TotpRecord {
|
|
8
|
+
secret: string;
|
|
9
|
+
lastUsedStep: number | null;
|
|
10
|
+
backupCodeHashes: string[];
|
|
11
|
+
}
|
|
12
|
+
export interface AccountRecord {
|
|
13
|
+
id: string;
|
|
14
|
+
username: string;
|
|
15
|
+
password: PasswordRecord;
|
|
16
|
+
totp: TotpRecord | null;
|
|
17
|
+
securityVersion: number;
|
|
18
|
+
}
|
|
19
|
+
export interface SessionRecord {
|
|
20
|
+
accountId: string;
|
|
21
|
+
securityVersion: number;
|
|
22
|
+
createdAt: number;
|
|
23
|
+
expiresAt: number;
|
|
24
|
+
}
|
|
25
|
+
export interface AuthState {
|
|
26
|
+
schemaVersion: typeof STATE_SCHEMA_VERSION;
|
|
27
|
+
revision: number;
|
|
28
|
+
account: AccountRecord | null;
|
|
29
|
+
/** Keys are SHA-256 token hashes, never bearer tokens. */
|
|
30
|
+
sessions: Record<string, SessionRecord>;
|
|
31
|
+
}
|
|
32
|
+
export declare function emptyState(): AuthState;
|
|
33
|
+
export declare function validateState(value: unknown): AuthState;
|
|
34
|
+
//# sourceMappingURL=state.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"state.d.ts","sourceRoot":"","sources":["../../../src/storage/state.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,IAAI,CAAA;AAErC,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAA;IACZ,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAA;IACd,YAAY,EAAE,MAAM,GAAG,IAAI,CAAA;IAC3B,gBAAgB,EAAE,MAAM,EAAE,CAAA;CAC3B;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAA;IACV,QAAQ,EAAE,MAAM,CAAA;IAChB,QAAQ,EAAE,cAAc,CAAA;IACxB,IAAI,EAAE,UAAU,GAAG,IAAI,CAAA;IACvB,eAAe,EAAE,MAAM,CAAA;CACxB;AAED,MAAM,WAAW,aAAa;IAC5B,SAAS,EAAE,MAAM,CAAA;IACjB,eAAe,EAAE,MAAM,CAAA;IACvB,SAAS,EAAE,MAAM,CAAA;IACjB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,SAAS;IACxB,aAAa,EAAE,OAAO,oBAAoB,CAAA;IAC1C,QAAQ,EAAE,MAAM,CAAA;IAChB,OAAO,EAAE,aAAa,GAAG,IAAI,CAAA;IAC7B,0DAA0D;IAC1D,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,aAAa,CAAC,CAAA;CACxC;AAED,wBAAgB,UAAU,IAAI,SAAS,CAEtC;AAmCD,wBAAgB,aAAa,CAAC,KAAK,EAAE,OAAO,GAAG,SAAS,CAsEvD"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { type AuthState } from './state.js';
|
|
2
|
+
export type CommitStage = 'afterTempWrite' | 'afterFileSync' | 'beforeRename' | 'afterRename' | 'afterDirSync' | 'beforeSuccess';
|
|
3
|
+
export interface StoreOptions {
|
|
4
|
+
/** A failed notification makes the store unavailable before a caller can report success. */
|
|
5
|
+
onCommitted?: (previous: AuthState, current: AuthState) => void | Promise<void>;
|
|
6
|
+
onUnavailable?: (reason: Error) => void;
|
|
7
|
+
/** Fault injection for isolated tests only. */
|
|
8
|
+
onStage?: (stage: CommitStage) => void | Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
/** One process owns the lock; every mutation serializes through this instance. */
|
|
11
|
+
export declare class AuthStateStore {
|
|
12
|
+
private readonly lock;
|
|
13
|
+
private readonly options;
|
|
14
|
+
readonly path: string;
|
|
15
|
+
private state;
|
|
16
|
+
private queue;
|
|
17
|
+
private unavailableReason;
|
|
18
|
+
private closed;
|
|
19
|
+
private readonly listeners;
|
|
20
|
+
private constructor();
|
|
21
|
+
static open(profileDir: string, options?: StoreOptions): Promise<AuthStateStore>;
|
|
22
|
+
healthy(): boolean;
|
|
23
|
+
current(): AuthState;
|
|
24
|
+
/** Notifications finish before transact reports success; a failed listener closes admission. */
|
|
25
|
+
subscribe(listener: (previous: AuthState, current: AuthState) => void | Promise<void>): () => void;
|
|
26
|
+
transact<T>(mutate: (draft: AuthState) => T | Promise<T>): Promise<T>;
|
|
27
|
+
private persist;
|
|
28
|
+
close(): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
//# sourceMappingURL=store.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/storage/store.ts"],"names":[],"mappings":"AAKA,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,YAAY,CAAA;AAEtE,MAAM,MAAM,WAAW,GACnB,gBAAgB,GAChB,eAAe,GACf,cAAc,GACd,aAAa,GACb,cAAc,GACd,eAAe,CAAA;AAEnB,MAAM,WAAW,YAAY;IAC3B,4FAA4F;IAC5F,WAAW,CAAC,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;IAC/E,aAAa,CAAC,EAAE,CAAC,MAAM,EAAE,KAAK,KAAK,IAAI,CAAA;IACvC,+CAA+C;IAC/C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,WAAW,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CACvD;AAMD,kFAAkF;AAClF,qBAAa,cAAc;IAWvB,OAAO,CAAC,QAAQ,CAAC,IAAI;IAErB,OAAO,CAAC,QAAQ,CAAC,OAAO;IAZ1B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;IACrB,OAAO,CAAC,KAAK,CAAW;IACxB,OAAO,CAAC,KAAK,CAAmC;IAChD,OAAO,CAAC,iBAAiB,CAAqB;IAC9C,OAAO,CAAC,MAAM,CAAQ;IACtB,OAAO,CAAC,QAAQ,CAAC,SAAS,CAEvB;IAEH,OAAO;WASM,IAAI,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,cAAc,CAAC;IAqB1F,OAAO,IAAI,OAAO;IAIlB,OAAO,IAAI,SAAS;IAKpB,gGAAgG;IAChG,SAAS,CACP,QAAQ,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,KAAK,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,GAC1E,MAAM,IAAI;IAMP,QAAQ,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;YAoB7D,OAAO;IAkDf,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAM7B"}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# Deployment
|
|
2
|
+
|
|
3
|
+
[简体中文](deployment.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
This guide describes a new installation with the verified DSH `0.1.7-rc.1` runtime and its default `~/.dsh` data directory. It does not depend on a particular public hostname, proxy network, service manager, or existing account database.
|
|
6
|
+
|
|
7
|
+
## Minimal local installation
|
|
8
|
+
|
|
9
|
+
From the source checkout, build the local archive and install it into the default `web` profile:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm install --frozen-lockfile
|
|
13
|
+
pnpm pack:local
|
|
14
|
+
dsh --version
|
|
15
|
+
dsh plugin --profile web add "$PWD/artifacts/dsh-auth-remote-0.1.0.tgz"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
Verify that `dsh --version` prints `0.1.7-rc.1`. DSH runs the plugin installer inside the profile directory, so `$PWD` supplies an absolute archive path. The bundle supplies an auth listener with `allowedOrigins: []`, which admits only literal loopback hosts. No profile patch is needed for this setup. Start DSH in one terminal:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
dsh web --no-open --port 13090
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
In another terminal, require `/auth-remote/ready` to return `"plugin":"dsh-auth-remote"`, `"protocolVersion":1`, and `"ready":true`, then initialize the account:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
curl -fsS http://127.0.0.1:13090/auth-remote/ready
|
|
28
|
+
dsh plugin --profile web exec dsh-auth-remote init --lang en
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
The minimal setup is local only. After initialization, use the `http://127.0.0.1:13090` URL printed at startup; unauthenticated browser navigation redirects to sign-in. The bundle suppresses the native token URL and browser handoff. Keep development and test homes separate from this default profile.
|
|
32
|
+
|
|
33
|
+
## Complete public-origin configuration
|
|
34
|
+
|
|
35
|
+
For an HTTPS entry such as `https://dsh.example.com`, merge the following rows into `~/.dsh/profiles/web/cordis.patch.yml`. They also appear in the reusable [profile example](../examples/web-profile-auth-remote.patch.yml). Keep unrelated model and plugin rows. The `webserver` row is recommended for an independent native-listener disable; it is optional while the auth bundle is active:
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
- id: webserver
|
|
39
|
+
disabled: true
|
|
40
|
+
|
|
41
|
+
- id: auth-remote
|
|
42
|
+
config:
|
|
43
|
+
allowedOrigins: [https://dsh.example.com]
|
|
44
|
+
requireTotp: true
|
|
45
|
+
sessionHours: 168
|
|
46
|
+
preserveOriginPaths: []
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
Replace the hostname and exact origin in the profile and proxy configuration, and choose the private port with `dsh web --port`. The plugin reads that port from DSH web startup. DSH replaces an entire plugin `config` when a later row supplies one. If a home-level patch also defines `auth-remote`, inspect the final composition with `dsh --profile web --dump-config` before opening the proxy. Remove the optional `webserver` row if uninstalling this plugin and returning to DSH's native listener.
|
|
50
|
+
|
|
51
|
+
## Profile and origin contract
|
|
52
|
+
|
|
53
|
+
| Setting | Required relationship |
|
|
54
|
+
| --------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
55
|
+
| `webserver: disabled` | Recommended in the profile for an independent native-listener disable; the auth bundle disables it while active. |
|
|
56
|
+
| `dsh web --port` | Sets the authenticated listener port; the example uses `127.0.0.1:13090`. The plugin reads DSH web startup, so no listener setting is repeated in its config. |
|
|
57
|
+
| `allowedOrigins` | List exact HTTP(S) origins, including nondefault ports. The example has `https://dsh.example.com`. An empty list allows only literal loopback. No wildcard, inferred forwarded host, or CORS fallback exists. |
|
|
58
|
+
| `requireTotp` | Defaults to `true`. With `false`, an account without TOTP can skip setup; an already bound account still needs its second factor. |
|
|
59
|
+
| `sessionHours` | Defaults to a fixed 168-hour lifetime. Reducing it tightens existing sessions; increasing it does not resurrect expired ones. |
|
|
60
|
+
| `preserveOriginPaths` | Optional segment-prefix paths whose validated public Host and existing Origin are passed to DSH. The default `[]` rewrites authenticated requests to the internal authority. The bundle configures Connection for preserved paths. |
|
|
61
|
+
|
|
62
|
+
Registered HTTP and HTTPS entries must have unambiguous authorities. A request must have one valid Host; mutations and WebSocket upgrades require a matching Origin. A Host from one registered entry and an Origin from another do not form a same-origin request. When Fetch Metadata is present, cross-site or mismatched modes are rejected. Direct canonical loopback requests remain available even with a public entry; an unregistered LAN or public Host is rejected. Neither `Forwarded` nor `X-Forwarded-*` decides admission or the Secure flag. The external TLS origin controls Secure cookies while the private upstream can remain HTTP. Cookies are host-only, HttpOnly, and SameSite; ports do not isolate cookies.
|
|
63
|
+
|
|
64
|
+
The plugin guards DSH pages, RPC, streams, WebSockets, and the official workspace browser and preview. A healthy `/auth-remote/ready` preflights the internal authority; it also preflights configured public authorities when `preserveOriginPaths` is nonempty. It does not mean an account has been initialized.
|
|
65
|
+
|
|
66
|
+
The standard DSH `/api` routes work with `preserveOriginPaths: []`; there is no need to list `/api`. If a downstream route requires the original public Host after authentication, add only that path prefix. When a path matches, the plugin preserves the validated public Host and forwards the original Origin if the request supplied one; it does not create an Origin for requests without one. The bundle adds the authorities from `allowedOrigins` to native Connection automatically when `preserveOriginPaths` is nonempty. No profile-level Connection configuration is needed. The auth gate still checks the original Host, Origin and session before forwarding.
|
|
67
|
+
|
|
68
|
+
### Bind directly to a private interface
|
|
69
|
+
|
|
70
|
+
For a proxy on another machine, an example command is `dsh web --no-open --host 192.0.2.10 --port 13090`. Replace the documentation address `192.0.2.10` with an IPv4 address assigned to the DSH host before running it. The plugin reads the listener address from DSH web startup. Startup prints `dsh web start at` with the HTTP listener URL, then `public access at` with each configured `allowedOrigins` root URL. The listener URL is a browser entry only if its origin is admitted. DSH rejects `--host 0.0.0.0` before plugins activate.
|
|
71
|
+
|
|
72
|
+
Binding to an interface does not restrict client source addresses. Apply any required source restrictions through a firewall or private network policy. Register the browser or proxy's exact HTTP(S) origin in `allowedOrigins`; this checks browser authority, not the client's IP address.
|
|
73
|
+
|
|
74
|
+
## Start and verify the public entry
|
|
75
|
+
|
|
76
|
+
1. Verify Linux, Node.js 24+, pnpm 12.5.1, and the installed DSH version. Install the archive with the minimal commands above. Keep any test or development runtime separate from the default account profile.
|
|
77
|
+
2. Merge the public-origin profile configuration above. The independent `webserver` disable is recommended. A proxy should reach only the private listener through a transport you control; see the [proxy guide](reverse-proxy.md).
|
|
78
|
+
3. Start with `dsh web --no-open --port 13090`. Before opening external access, inspect `curl -fsS -H 'Host: dsh.example.com' http://127.0.0.1:13090/auth-remote/ready` and require JSON containing `"plugin":"dsh-auth-remote"`, `"protocolVersion":1`, and `"ready":true`.
|
|
79
|
+
4. Confirm an anonymous HTML request redirects to `/auth-remote/login`, and an anonymous API request such as `/api/settings` is denied. Initialize through the local CLI if needed, then sign in, bind TOTP, save backup codes and exercise official settings, workspace, preview, uploads and streams through the chosen browser origin.
|
|
80
|
+
|
|
81
|
+
The listener must remain private until the readiness and anonymous denial checks succeed. A failed plugin load, corrupt state, or unavailable native Connection should fail closed; investigate it before exposing an upstream. This repository does not install a reverse proxy or service manager configuration for you.
|
|
82
|
+
|
|
83
|
+
## Backup, recovery and changes
|
|
84
|
+
|
|
85
|
+
Stop DSH and verify it has released the profile lock before copying `~/.dsh/profiles/web/auth-remote/auth-state.json`. Store the copy in a private directory (0700) with file mode 0600. That file includes password hashes, the TOTP secret, backup code hashes and session state. Do not copy an in-progress temporary file, overwrite a live locked state file, or commit any copy to Git. Keep a separate copy of the profile patch and package/lock files used at the same time.
|
|
86
|
+
|
|
87
|
+
For recovery, stop DSH, verify the target uses the same state schema and compatible package, restore the saved file with private ownership/mode, then start and check readiness and CLI `status --json`. CLI `reset-password`, `reset-totp`, and `revoke-sessions` are the supported local recovery actions; they revoke sessions. A lost management response has an uncertain outcome, so inspect status before another mutation.
|
|
88
|
+
|
|
89
|
+
When changing an external origin, add the new exact URL to `allowedOrigins`, update the proxy to preserve Host/Origin, and check both entries before removing the old one. The bundle updates Connection trust from `allowedOrigins` when the profile restarts. Restart DSH after profile changes. Validate HTTPS cookies, redirects, WebSocket and streaming through every entry.
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
# 部署指南
|
|
2
|
+
|
|
3
|
+
[English](deployment.md)
|
|
4
|
+
|
|
5
|
+
本指南说明使用已验证的 DSH `0.1.7-rc.1` 和默认的 `~/.dsh` 数据目录进行全新安装,不假定公网域名、代理网络、服务管理器或现有账号数据库。
|
|
6
|
+
|
|
7
|
+
## 最小化本地安装
|
|
8
|
+
|
|
9
|
+
在源码检出目录构建本地压缩包,并安装到默认的 `web` profile:
|
|
10
|
+
|
|
11
|
+
```sh
|
|
12
|
+
pnpm install --frozen-lockfile
|
|
13
|
+
pnpm pack:local
|
|
14
|
+
dsh --version
|
|
15
|
+
dsh plugin --profile web add "$PWD/artifacts/dsh-auth-remote-0.1.0.tgz"
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
确认 `dsh --version` 输出 `0.1.7-rc.1`。DSH 会在 profile 目录执行插件安装,因此 `$PWD` 为压缩包提供绝对路径。bundle 提供认证监听,默认 `allowedOrigins: []`,因此只准入字面回环主机。最小安装无需修改 profile 补丁。在一个终端启动 DSH:
|
|
19
|
+
|
|
20
|
+
```sh
|
|
21
|
+
dsh web --no-open --port 13090
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
在另一个终端确认 `/auth-remote/ready` 返回 `"plugin":"dsh-auth-remote"`、`"protocolVersion":1` 和 `"ready":true`,随后初始化账号:
|
|
25
|
+
|
|
26
|
+
```sh
|
|
27
|
+
curl -fsS http://127.0.0.1:13090/auth-remote/ready
|
|
28
|
+
dsh plugin --profile web exec dsh-auth-remote init --lang zh
|
|
29
|
+
```
|
|
30
|
+
|
|
31
|
+
最小配置仅供本机使用。初始化后使用启动时打印的 `http://127.0.0.1:13090` 地址;未登录的浏览器访问会跳转到登录页。bundle 会关闭原生 token URL 输出与自动打开浏览器的行为。开发和测试 home 应与该默认 profile 分开。
|
|
32
|
+
|
|
33
|
+
## 公网入口完整配置
|
|
34
|
+
|
|
35
|
+
若使用 `https://dsh.example.com` 等 HTTPS 入口,将以下条目合并到 `~/.dsh/profiles/web/cordis.patch.yml`。这些条目也见可复用的 [profile 示例](../examples/web-profile-auth-remote.patch.yml)。保留无关模型和插件条目。`webserver` 条目建议用于在 profile 中独立禁用原生监听;认证 bundle 正常加载时不强制要求此条目:
|
|
36
|
+
|
|
37
|
+
```yaml
|
|
38
|
+
- id: webserver
|
|
39
|
+
disabled: true
|
|
40
|
+
|
|
41
|
+
- id: auth-remote
|
|
42
|
+
config:
|
|
43
|
+
allowedOrigins: [https://dsh.example.com]
|
|
44
|
+
requireTotp: true
|
|
45
|
+
sessionHours: 168
|
|
46
|
+
preserveOriginPaths: []
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
在 profile 和代理配置中一致地替换主机名与精确来源,用 `dsh web --port` 选择私有端口。插件从 DSH web startup 读取该端口。后应用的 DSH 条目会整段替换插件 `config`。若 home 级补丁也定义了 `auth-remote`,开放代理前用 `dsh --profile web --dump-config` 核对最终合成配置。若卸载本插件并恢复 DSH 原生监听,也要移除可选的 `webserver` 禁用条目。
|
|
50
|
+
|
|
51
|
+
## Profile 与来源契约
|
|
52
|
+
|
|
53
|
+
| 设置 | 必须满足的关系 |
|
|
54
|
+
| --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
55
|
+
| `webserver: disabled` | 建议在 profile 中独立禁用原生监听;认证 bundle 正常加载时会自行禁用。 |
|
|
56
|
+
| `dsh web --port` | 设置认证监听端口;示例使用 `127.0.0.1:13090`。插件读取 DSH web startup,无需在插件配置中重复填写监听参数。 |
|
|
57
|
+
| `allowedOrigins` | 精确列出 HTTP(S) 来源,含非默认端口。示例为 `https://dsh.example.com`。空列表只允许字面回环;没有通配、转发头推断或 CORS 回退。 |
|
|
58
|
+
| `requireTotp` | 默认 `true`。设为 `false` 时未绑定账号可以跳过;已绑定账号仍需第二因素。 |
|
|
59
|
+
| `sessionHours` | 默认固定 168 小时。缩短会收紧已有会话,放宽不会复活过期会话。 |
|
|
60
|
+
| `preserveOriginPaths` | 可选的路径段前缀,让已验证的公网 Host 和请求中已有的 Origin 传给 DSH。默认 `[]` 把已认证请求改写到内部 authority;bundle 会为保留路径配置 Connection。 |
|
|
61
|
+
|
|
62
|
+
已登记 HTTP 与 HTTPS 入口的 authority 不能歧义。请求必须有一个合法 Host;修改请求和 WebSocket 升级必须携带匹配 Origin。一个登记入口的 Host 与另一个入口的 Origin 不构成同源。有 Fetch Metadata 时会拒绝跨站或不匹配模式。即使登记了公网入口,规范的回环直连仍可用;未登记的 LAN 或公网 Host 会被拒绝。`Forwarded` 和 `X-Forwarded-*` 不决定准入或 Secure 标志。外部 TLS 来源决定 Secure Cookie,私有上游可保持 HTTP。Cookie 仅限主机、HttpOnly、SameSite;端口不隔离 Cookie。
|
|
63
|
+
|
|
64
|
+
插件保护 DSH 页面、RPC、流、WebSocket,以及官方工作区浏览与预览。健康的 `/auth-remote/ready` 会预检内部 authority;仅在 `preserveOriginPaths` 非空时才预检已配置公网 authority。它不表示账号已经初始化。
|
|
65
|
+
|
|
66
|
+
标准 DSH `/api` 路由在 `preserveOriginPaths: []` 下即可工作,无需列出 `/api`。仅当下游路由在认证后仍需原始公网 Host 时,才加入对应路径前缀。路径匹配后,插件保留已验证的公网 Host;请求原本携带 Origin 时也透传该 Origin,未携带时不会补造。`preserveOriginPaths` 非空时,bundle 自动把 `allowedOrigins` 的 authority 加入原生 Connection,无需用户在 profile 中配置 Connection。转交前认证门禁仍检查原始 Host、Origin 和会话。
|
|
67
|
+
|
|
68
|
+
### 直接监听私有网卡
|
|
69
|
+
|
|
70
|
+
代理位于另一台机器时,可以参考 `dsh web --no-open --host 192.0.2.10 --port 13090`。运行前须将文档专用地址 `192.0.2.10` 替换为 DSH 主机实际拥有的 IPv4 地址。插件从 DSH web startup 读取监听地址。启动时在 `dsh web start at` 下打印 HTTP 监听 URL,在 `public access at` 下逐行打印 `allowedOrigins` 的根地址。监听 URL 只有在其来源被准入时才能作为浏览器入口。DSH 会在插件激活前拒绝 `--host 0.0.0.0`。
|
|
71
|
+
|
|
72
|
+
直接绑定网卡不会限制客户端来源 IP。需要限制来源时,在防火墙或私有网络策略中配置。还要将浏览器或代理的精确 HTTP(S) 来源登记到 `allowedOrigins`;它检查浏览器访问地址,不检查客户端 IP。
|
|
73
|
+
|
|
74
|
+
## 启动并检查公网入口
|
|
75
|
+
|
|
76
|
+
1. 核对 Linux、Node.js 24+、pnpm 12.5.1 和已安装的 DSH 版本。按上文最小化命令安装压缩包。测试和开发运行时应与默认账号 profile 分开。
|
|
77
|
+
2. 合并上文公网入口的 profile 配置;建议独立禁用 `webserver`。代理只应通过受控私有传输访问监听;参见[代理指南](reverse-proxy.zh-CN.md)。
|
|
78
|
+
3. 用 `dsh web --no-open --port 13090` 启动。开放外部入口前检查 `curl -fsS -H 'Host: dsh.example.com' http://127.0.0.1:13090/auth-remote/ready`,要求 JSON 同时包含 `"plugin":"dsh-auth-remote"`、`"protocolVersion":1` 和 `"ready":true`。
|
|
79
|
+
4. 确认匿名 HTML 请求跳转 `/auth-remote/login`,匿名 `/api/settings` 等 API 被拒绝。若尚未初始化账号,先用本地 CLI 初始化;随后登录、绑定 TOTP、保存备用码,并经选定浏览器入口测试官方设置、工作区、预览、上传和流。
|
|
80
|
+
|
|
81
|
+
就绪和匿名拒绝检查成功前,监听必须保持私有。插件加载失败、状态损坏或原生 Connection 不可用时应失败关闭;排查后才能暴露上游。本仓库不会替你安装反向代理或服务管理配置。
|
|
82
|
+
|
|
83
|
+
## 备份、恢复与变更
|
|
84
|
+
|
|
85
|
+
停止 DSH 并确认已释放 profile 锁,再复制 `~/.dsh/profiles/web/auth-remote/auth-state.json`。副本放在权限 0700 的私有目录,文件权限 0600。该文件含密码哈希、TOTP 密钥、备用码哈希和会话状态。不要复制写入中的临时文件、覆盖运行中持锁的状态文件,或把副本提交到 Git。同时另存对应时期的 profile 补丁和包/锁文件。
|
|
86
|
+
|
|
87
|
+
恢复时先停止 DSH,确认目标使用相同状态 schema 与兼容包,以私有属主/权限恢复文件,再启动并检查就绪与 CLI `status --json`。本地恢复动作是 CLI `reset-password`、`reset-totp` 和 `revoke-sessions`,都会撤销会话。管理响应丢失后结果不明,先查状态再决定是否执行下一次修改。
|
|
88
|
+
|
|
89
|
+
外部入口变更时,先把新精确 URL 加到 `allowedOrigins`,更新代理以保留 Host/Origin,并检查新旧两个入口,再移除旧入口。profile 重启后,bundle 会从 `allowedOrigins` 更新 Connection 信任地址。profile 变更后重启 DSH。逐个入口验证 HTTPS Cookie、重定向、WebSocket 和流式响应。
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# Development
|
|
2
|
+
|
|
3
|
+
[简体中文](development.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Development and the full test suite use Linux (`/proc` is required for the profile lock), Node.js 24+, pnpm 12.5.1, and DSH `0.1.7-rc.1`. Browser tests use Playwright-managed Chromium and a Node HTTP/HTTPS forwarder.
|
|
6
|
+
|
|
7
|
+
## Set up and check a checkout
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm install --frozen-lockfile
|
|
11
|
+
pnpm exec playwright install chromium
|
|
12
|
+
pnpm check
|
|
13
|
+
pnpm pack:local
|
|
14
|
+
pnpm smoke
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`pnpm check` runs type checking, formatting, build, package/deployment/document checks, then unit, integration, CLI, and browser tests. `pnpm pack:local` writes `artifacts/dsh-auth-remote-0.1.0.tgz` after static checks; it does not publish. `pnpm smoke` installs that archive into an isolated DSH home, starts the pinned DSH runtime briefly, checks readiness, anonymous redirection/denial and an online CLI status, then stops it.
|
|
18
|
+
|
|
19
|
+
## Use the isolated development profile
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pnpm dev:prepare
|
|
23
|
+
pnpm dev:install
|
|
24
|
+
pnpm dev:start
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
The scripts manage only `.dev/runtime` and `.dev/dsh-home` under this checkout; the default listener is `127.0.0.1:13090`. They reject an ambient `DSH_HOME` pointing elsewhere and symlinked development paths. `dev:install` rebuilds and installs the current archive even when the version stays the same. `dev:start` runs DSH in the foreground; Ctrl+C stops it. A source watcher can run in another terminal with `pnpm dev`, but rebuilds still need `dev:install` and a `dev:start` restart to load the new package.
|
|
28
|
+
|
|
29
|
+
For direct inspection, use the same isolated home explicitly:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
DSH_HOME="$PWD/.dev/dsh-home" "$PWD/.dev/runtime/node_modules/.bin/dsh" plugin --profile web exec dsh-auth-remote status --json
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
The development home contains test account data. Keep it private and do not commit or copy it into a deployment profile.
|
|
36
|
+
|
|
37
|
+
## Test boundaries
|
|
38
|
+
|
|
39
|
+
`pnpm test:unit` covers the auth state machine, TOTP, backup codes, origin policy, translations, storage durability and lock recovery. `pnpm test:integration` exercises real HTTP/WebSocket sockets, native readiness, cookies, origin decisions and revocation. `pnpm test:cli` builds the real archive and tests interactive and noninteractive commands against isolated profiles and Unix sockets. `pnpm test:browser` boots rc.1 with temporary profiles and verifies the login and Security UI, native settings, workspace, upload/preview, SSE, WebSocket and an HTTPS forwarding chain.
|
|
40
|
+
|
|
41
|
+
Browser network traffic uses a Node HTTP/HTTPS forwarder. The dedicated self-signed certificate and key under `tests/fixtures/tls/` are test fixtures only; they are never packaged or deployment credentials. Chat uses a local model stub. No real third-party authorization or paid model request is exercised. The default browser is Playwright Chromium; `DSH_TEST_BROWSER` can select a local browser executable, and `DSH_TEST_BIN` can select another binary only if it reports exactly `0.1.7-rc.1`.
|
|
42
|
+
|
|
43
|
+
The DSH test runtime lives in `.cache/test-runtime` and is pinned separately from the source dependencies. Host services and React remain external to the client bundle. The [deployment guide](deployment.md) describes profile and backup rules.
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# 开发指南
|
|
2
|
+
|
|
3
|
+
[English](development.md)
|
|
4
|
+
|
|
5
|
+
开发和完整测试需要 Linux(profile 锁依赖 `/proc`)、Node.js 24+、pnpm 12.5.1,以及 DSH `0.1.7-rc.1`。浏览器测试使用 Playwright 管理的 Chromium 和 Node HTTP/HTTPS 转发器。
|
|
6
|
+
|
|
7
|
+
## 准备和检查源码检出
|
|
8
|
+
|
|
9
|
+
```sh
|
|
10
|
+
pnpm install --frozen-lockfile
|
|
11
|
+
pnpm exec playwright install chromium
|
|
12
|
+
pnpm check
|
|
13
|
+
pnpm pack:local
|
|
14
|
+
pnpm smoke
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
`pnpm check` 依次执行类型、格式、构建、包/部署/文档检查,以及单元、集成、CLI 和浏览器测试。`pnpm pack:local` 在静态检查后写出 `artifacts/dsh-auth-remote-0.1.0.tgz`,不会发布。`pnpm smoke` 将包安装到隔离 DSH_HOME,短暂启动固定版本的 DSH,验证就绪、匿名重定向/拒绝和在线 CLI 状态,然后停止。
|
|
18
|
+
|
|
19
|
+
## 使用隔离开发 profile
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
pnpm dev:prepare
|
|
23
|
+
pnpm dev:install
|
|
24
|
+
pnpm dev:start
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
脚本只管理当前源码目录下的 `.dev/runtime` 和 `.dev/dsh-home`,默认监听 `127.0.0.1:13090`。终端的 `DSH_HOME` 若指向其他位置,或开发路径为符号链接,脚本会拒绝执行。即使版本号不变,`dev:install` 也会重建并安装当前压缩包。`dev:start` 在前台运行,Ctrl+C 停止。可在另一个终端执行 `pnpm dev` 监听源码,但重建后仍需重新 `dev:install` 并重启 `dev:start` 才会载入新包。
|
|
28
|
+
|
|
29
|
+
直接查看状态时显式使用同一隔离 home:
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
DSH_HOME="$PWD/.dev/dsh-home" "$PWD/.dev/runtime/node_modules/.bin/dsh" plugin --profile web exec dsh-auth-remote status --json
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
开发 home 可能含测试账号数据,须保持私有,不要提交或复制到部署 profile。
|
|
36
|
+
|
|
37
|
+
## 测试边界
|
|
38
|
+
|
|
39
|
+
`pnpm test:unit` 覆盖认证状态机、TOTP、备用码、来源策略、翻译、存储持久性和锁恢复。`pnpm test:integration` 使用真实 HTTP/WebSocket socket 验证原生就绪、Cookie、来源判定与撤销。`pnpm test:cli` 构建真实压缩包,并用隔离 profile/Unix socket 验证交互与非交互命令。`pnpm test:browser` 用临时 profile 启动 rc.1,验证登录、安全页、原生设置、工作区、上传/预览、SSE、WebSocket 和 HTTPS 转发链。
|
|
40
|
+
|
|
41
|
+
浏览器网络链路使用 Node HTTP/HTTPS 转发器。`tests/fixtures/tls/` 下的专用自签证书与私钥仅为测试夹具,不进入安装包,也不是部署凭证。聊天使用本地模型替身;不执行真实第三方授权或付费模型请求。默认浏览器为 Playwright Chromium;`DSH_TEST_BROWSER` 可选择本地浏览器程序,`DSH_TEST_BIN` 仅在报告精确版本 `0.1.7-rc.1` 时可替换 DSH 二进制。
|
|
42
|
+
|
|
43
|
+
DSH 测试运行时位于 `.cache/test-runtime`,与源码依赖分别固定。宿主服务和 React 不打入客户端 bundle。[部署指南](deployment.zh-CN.md)说明 profile 与备份规则。
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# Releasing
|
|
2
|
+
|
|
3
|
+
[简体中文](releasing.zh-CN.md)
|
|
4
|
+
|
|
5
|
+
Each release starts from a tested commit on `master`. A `vX.Y.Z` tag must match the stable version in `package.json` and the dated entries in both changelogs. The tag workflow repeats the full checks, builds the npm archive, verifies or publishes the npm version, and creates a GitHub Release containing the same archive and `SHA256SUMS`.
|
|
6
|
+
|
|
7
|
+
## Prepare the version
|
|
8
|
+
|
|
9
|
+
Update `package.json` to `X.Y.Z`, move user-visible changes from Unreleased into `## X.Y.Z - YYYY-MM-DD` in both changelogs, and update any versioned installation examples. Open a pull request, let `CI Verify` pass, merge it, and wait for the `master` check to pass. Do not tag a commit whose checks are still running.
|
|
10
|
+
|
|
11
|
+
To verify the merged checkout locally, run:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pnpm install --frozen-lockfile
|
|
15
|
+
pnpm exec playwright install chromium
|
|
16
|
+
pnpm check
|
|
17
|
+
pnpm pack:local
|
|
18
|
+
pnpm smoke
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`pnpm pack:local` creates and checks `artifacts/dsh-auth-remote-X.Y.Z.tgz`; `pnpm smoke` installs that archive into an isolated DSH home and tests startup. Neither command publishes a package.
|
|
22
|
+
|
|
23
|
+
## Tag and inspect the release
|
|
24
|
+
|
|
25
|
+
Use the version that is already on `master`:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
git switch master
|
|
29
|
+
git pull --ff-only origin master
|
|
30
|
+
git tag -a v0.1.0 -m "Release v0.1.0"
|
|
31
|
+
git push origin v0.1.0
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Replace `0.1.0` in these commands with the intended version. The tag must point to a commit reachable from `master`. A mismatched tag, missing changelog entry, failed test, or mismatched existing npm archive stops the release.
|
|
35
|
+
|
|
36
|
+
After the workflow completes, confirm the run, GitHub Release, and npm version:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
gh run list --workflow release.yml --limit 5
|
|
40
|
+
gh release view v0.1.0
|
|
41
|
+
npm view dsh-auth-remote@0.1.0 version dist.integrity
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
The GitHub Release includes the `.tgz` and `SHA256SUMS`. Download them into the same directory and run `sha256sum -c SHA256SUMS` there to check the release asset. A failed workflow should be inspected in **Actions → Release** before retrying; npm versions are immutable, so the workflow only skips an existing version when its archive bytes match.
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# 发布指南
|
|
2
|
+
|
|
3
|
+
[English](releasing.md)
|
|
4
|
+
|
|
5
|
+
每次发布都从已通过检查的 `master` 提交开始。`vX.Y.Z` 标签必须与 `package.json` 中的稳定版本以及两份更新日志的日期条目一致。标签工作流会再次执行完整检查、构建 npm 压缩包、核对或发布 npm 版本,并创建包含相同压缩包和 `SHA256SUMS` 的 GitHub Release。
|
|
6
|
+
|
|
7
|
+
## 准备版本
|
|
8
|
+
|
|
9
|
+
将 `package.json` 更新为 `X.Y.Z`,把两份更新日志中用户可见的“未发布”变更移入 `## X.Y.Z - YYYY-MM-DD`,同时更新带版本号的安装示例。创建 Pull Request,等待 `CI Verify` 通过,合入后再等待 `master` 检查通过。检查尚未结束时不要打标签。
|
|
10
|
+
|
|
11
|
+
如需在已合入的检出中本地验证,可执行:
|
|
12
|
+
|
|
13
|
+
```sh
|
|
14
|
+
pnpm install --frozen-lockfile
|
|
15
|
+
pnpm exec playwright install chromium
|
|
16
|
+
pnpm check
|
|
17
|
+
pnpm pack:local
|
|
18
|
+
pnpm smoke
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
`pnpm pack:local` 创建并检查 `artifacts/dsh-auth-remote-X.Y.Z.tgz`;`pnpm smoke` 将压缩包安装到隔离的 DSH home 并测试启动。这两个命令都不会发布包。
|
|
22
|
+
|
|
23
|
+
## 打标签并核对结果
|
|
24
|
+
|
|
25
|
+
使用已经位于 `master` 的版本:
|
|
26
|
+
|
|
27
|
+
```sh
|
|
28
|
+
git switch master
|
|
29
|
+
git pull --ff-only origin master
|
|
30
|
+
git tag -a v0.1.0 -m "Release v0.1.0"
|
|
31
|
+
git push origin v0.1.0
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
执行时把 `0.1.0` 换成目标版本。标签必须指向 `master` 可达的提交。标签版本不匹配、缺少更新日志条目、测试失败,或 npm 现存版本与本次压缩包字节不同,都会阻止发布。
|
|
35
|
+
|
|
36
|
+
工作流结束后检查运行状态、GitHub Release 和 npm 版本:
|
|
37
|
+
|
|
38
|
+
```sh
|
|
39
|
+
gh run list --workflow release.yml --limit 5
|
|
40
|
+
gh release view v0.1.0
|
|
41
|
+
npm view dsh-auth-remote@0.1.0 version dist.integrity
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
GitHub Release 包含 `.tgz` 和 `SHA256SUMS`。把两者下载到同一个目录,在该目录运行 `sha256sum -c SHA256SUMS` 验证附件。工作流失败时先查看 **Actions → Release** 再重试;npm 版本不可覆盖,因此只有现存版本的压缩包字节与本次构建一致时,工作流才会跳过重复发布。
|