dsh-auth-remote 0.1.9 → 0.2.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.
Files changed (57) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/CHANGELOG.zh-CN.md +32 -0
  3. package/CONTRIBUTING.md +3 -1
  4. package/CONTRIBUTING.zh-CN.md +3 -1
  5. package/README.md +49 -23
  6. package/README.zh-CN.md +37 -11
  7. package/cordis.patch.yml +4 -3
  8. package/dist/cli.js +91 -46
  9. package/dist/cli.js.map +2 -2
  10. package/dist/client.js +2880 -581
  11. package/dist/client.js.map +4 -4
  12. package/dist/index.js +201 -36
  13. package/dist/index.js.map +4 -4
  14. package/dist/login.css +2 -8
  15. package/dist/login.css.map +2 -2
  16. package/dist/login.js +80 -42
  17. package/dist/login.js.map +2 -2
  18. package/dist/types/adapters/dsh/account-callback.d.ts +3 -0
  19. package/dist/types/adapters/dsh/account-callback.d.ts.map +1 -1
  20. package/dist/types/adapters/dsh/hmr-context.d.ts +10 -0
  21. package/dist/types/adapters/dsh/hmr-context.d.ts.map +1 -0
  22. package/dist/types/auth/service.d.ts +2 -0
  23. package/dist/types/auth/service.d.ts.map +1 -1
  24. package/dist/types/auth/sessions.d.ts +2 -0
  25. package/dist/types/auth/sessions.d.ts.map +1 -1
  26. package/dist/types/config.d.ts +9 -3
  27. package/dist/types/config.d.ts.map +1 -1
  28. package/dist/types/http/account-login.d.ts +5 -3
  29. package/dist/types/http/account-login.d.ts.map +1 -1
  30. package/dist/types/index.d.ts +2 -2
  31. package/dist/types/index.d.ts.map +1 -1
  32. package/dist/types/shared/account-login.d.ts +2 -1
  33. package/dist/types/shared/account-login.d.ts.map +1 -1
  34. package/dist/types/shared/auth-contract.d.ts +2 -0
  35. package/dist/types/shared/auth-contract.d.ts.map +1 -1
  36. package/dist/types/shared/dsh-support.d.ts +38 -0
  37. package/dist/types/shared/dsh-support.d.ts.map +1 -0
  38. package/dist/types/shared/i18n.d.ts +78 -40
  39. package/dist/types/shared/i18n.d.ts.map +1 -1
  40. package/dist/types/shared/locales/en.d.ts +39 -20
  41. package/dist/types/shared/locales/en.d.ts.map +1 -1
  42. package/dist/types/shared/locales/zh.d.ts +39 -20
  43. package/dist/types/shared/locales/zh.d.ts.map +1 -1
  44. package/docs/deployment.md +26 -21
  45. package/docs/deployment.zh-CN.md +26 -21
  46. package/docs/development.md +74 -8
  47. package/docs/development.zh-CN.md +74 -8
  48. package/docs/legacy-compatibility.md +96 -64
  49. package/docs/legacy-compatibility.zh-CN.md +96 -64
  50. package/docs/releasing.md +40 -10
  51. package/docs/releasing.zh-CN.md +40 -10
  52. package/docs/support-history.md +97 -0
  53. package/docs/support-history.zh-CN.md +97 -0
  54. package/docs/support-policy.md +87 -0
  55. package/docs/support-policy.zh-CN.md +87 -0
  56. package/examples/web-profile-auth-remote.patch.yml +6 -3
  57. package/package.json +28 -17
package/dist/cli.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../src/cli/index.ts", "../src/auth/service.ts", "../src/storage/store.ts", "../src/storage/lock.ts", "../src/storage/state.ts", "../src/auth/password.ts", "../src/auth/sessions.ts", "../src/auth/totp.ts", "../src/shared/admin-contract.ts", "../src/cli/ipc-client.ts", "../src/shared/locales/en.ts", "../src/shared/locales/zh.ts", "../src/shared/i18n.ts", "../src/cli/language.ts", "../src/cli/profile.ts", "../src/cli/prompt.ts"],
4
- "sourcesContent": ["#!/usr/bin/env node\nimport { readFileSync } from 'node:fs'\nimport { AuthError, AuthService } from '../auth/service.js'\nimport { PasswordValidationError, validatePassword } from '../auth/password.js'\nimport {\n ADMIN_PROTOCOL_VERSION,\n type AdminRequest,\n type AdminStatus,\n} from '../shared/admin-contract.js'\nimport { AuthStateStore } from '../storage/store.js'\nimport { AdminOutcomeUnknown, AdminRejected, AdminUnavailable, requestAdmin } from './ipc-client.js'\nimport { CliDiagnostic, cliText, environmentLocale, parseLanguage } from './language.js'\nimport { resolveProfileTarget, type ProfileTarget } from './profile.js'\nimport { TerminalPrompt } from './prompt.js'\nimport type { Locale, MessageKey } from '../shared/i18n.js'\n\nconst manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as {\n version: string\n}\n\ntype Command = AdminRequest['command']\nlet currentLocale = environmentLocale(process.env)\nconst output = (key: MessageKey, params: Record<string, string | number> = {}): string =>\n cliText(currentLocale, key, params)\n\nfunction authErrorKey(code: string): MessageKey {\n switch (code) {\n case 'already_initialized':\n return 'cliErrorAlreadyInitialized'\n case 'invalid_input':\n return 'cliErrorInvalidInput'\n case 'invalid_credentials':\n return 'cliErrorInvalidCredentials'\n case 'invalid_factor':\n return 'cliErrorInvalidFactor'\n case 'uninitialized':\n return 'cliErrorUninitialized'\n case 'totp_required':\n return 'cliErrorTotpRequired'\n case 'conflict':\n return 'cliErrorConflict'\n case 'busy':\n return 'cliErrorBusy'\n default:\n return 'cliErrorUnknown'\n }\n}\n\nfunction errorText(error: unknown, locale: Locale): string {\n if (error instanceof CliDiagnostic) return cliText(error.locale ?? locale, error.key)\n if (error instanceof PasswordValidationError) return cliText(locale, 'cliErrorPasswordLength')\n if (error instanceof AdminOutcomeUnknown) return cliText(locale, 'cliErrorOutcomeUnknown')\n if (error instanceof AdminUnavailable) return cliText(locale, 'cliErrorManagementUnavailable')\n if (error instanceof AdminRejected || error instanceof AuthError) {\n if (error.code === 'rate_limited')\n return cliText(locale, 'errorRateLimited', {\n seconds: error instanceof AuthError ? (error.retryAfter ?? 1) : 1,\n })\n return cliText(locale, authErrorKey(error.code))\n }\n return cliText(locale, 'cliErrorUnknown')\n}\n\nasync function offline(\n target: ProfileTarget,\n request: AdminRequest,\n): Promise<AdminStatus | { ok: true }> {\n let store: AuthStateStore\n try {\n store = await AuthStateStore.open(target.dir)\n } catch (error) {\n if (error instanceof Error && /state lock held|state lock is held/u.test(error.message))\n throw new CliDiagnostic(\n 'cliErrorOfflineLock',\n 'dsh-auth-remote: management socket is unavailable while the service holds the profile lock; refusing offline access',\n )\n throw error\n }\n const auth = new AuthService(store, { requireTotp: false, sessionHours: 168 })\n try {\n switch (request.command) {\n case 'status':\n return { ...auth.status(), online: false, ready: false }\n case 'init':\n await auth.initialize(request.username, request.password)\n return { ok: true }\n case 'reset-password':\n await auth.resetPassword(request.password)\n return { ok: true }\n case 'reset-totp':\n await auth.resetTotp()\n return { ok: true }\n case 'revoke-sessions':\n await auth.revokeAll()\n return { ok: true }\n }\n } finally {\n auth.dispose()\n await store.close()\n }\n}\n\nasync function execute(\n target: ProfileTarget,\n request: AdminRequest,\n): Promise<AdminStatus | { ok: true }> {\n try {\n return await requestAdmin(target.socketPath, request)\n } catch (error) {\n if (!(error instanceof AdminUnavailable)) throw error\n return offline(target, request)\n }\n}\n\nasync function interactiveRequest(\n target: ProfileTarget,\n command: Exclude<Command, 'status'>,\n): Promise<AdminRequest> {\n const prompt = new TerminalPrompt()\n try {\n if (command === 'init') {\n const username = await prompt.ask(output('cliPromptUsername'), false, 64)\n const password = await prompt.ask(output('cliPromptPassword'), true, 256)\n const again = await prompt.ask(output('cliPromptPasswordAgain'), true, 256)\n if (password !== again)\n throw new CliDiagnostic(\n 'cliErrorPasswordsMismatch',\n 'dsh-auth-remote: passwords do not match',\n )\n validatePassword(password)\n return { version: ADMIN_PROTOCOL_VERSION, command, username, password }\n }\n const confirmation = await prompt.ask(\n output('cliPromptConfirmTarget', { profile: target.name, command }),\n false,\n 64,\n )\n if (confirmation !== target.name)\n throw new CliDiagnostic(\n 'cliErrorConfirmationMismatch',\n 'dsh-auth-remote: confirmation did not match the target profile',\n )\n if (command === 'reset-password') {\n const password = await prompt.ask(output('cliPromptNewPassword'), true, 256)\n const again = await prompt.ask(output('cliPromptNewPasswordAgain'), true, 256)\n if (password !== again)\n throw new CliDiagnostic(\n 'cliErrorPasswordsMismatch',\n 'dsh-auth-remote: passwords do not match',\n )\n validatePassword(password)\n return { version: ADMIN_PROTOCOL_VERSION, command, password }\n }\n return { version: ADMIN_PROTOCOL_VERSION, command }\n } finally {\n prompt.close()\n }\n}\n\nasync function main(): Promise<void> {\n const parsed = parseLanguage(process.argv.slice(2))\n currentLocale = parsed.locale\n const args = parsed.args\n if (args.length === 0 || (args.length === 1 && ['--help', '-h'].includes(args[0]!))) {\n process.stdout.write(output('cliHelp', { version: manifest.version }))\n return\n }\n if (args.length === 1 && ['--version', '-v'].includes(args[0]!)) {\n process.stdout.write(`${manifest.version}\\n`)\n return\n }\n const command = args[0]\n if (\n !['init', 'status', 'reset-password', 'reset-totp', 'revoke-sessions'].includes(\n command ?? '',\n ) ||\n (command === 'status'\n ? args.length > 2 || (args.length === 2 && args[1] !== '--json')\n : args.length !== 1)\n )\n throw new CliDiagnostic(\n 'cliErrorInvalidArguments',\n 'dsh-auth-remote: invalid command or arguments; use --help',\n )\n const target = await resolveProfileTarget()\n if (command !== 'status')\n process.stdout.write(\n `${output('cliTargetProfile', { profile: target.name })}\\n${output('cliDataFile', { path: target.statePath })}\\n`,\n )\n const request: AdminRequest =\n command === 'status'\n ? { version: ADMIN_PROTOCOL_VERSION, command: 'status' }\n : await interactiveRequest(target, command as Exclude<Command, 'status'>)\n const result = await execute(target, request)\n if (command === 'status') {\n const status = result as AdminStatus\n if (args[1] === '--json')\n process.stdout.write(\n `${JSON.stringify({ profile: target.name, statePath: target.statePath, ...status })}\\n`,\n )\n else\n process.stdout.write(\n [\n output('cliStatusProfile', { profile: target.name }),\n output('cliDataFile', { path: target.statePath }),\n output('cliStatusAccount', {\n state: output(status.initialized ? 'cliInitialized' : 'cliNotInitialized'),\n }),\n output('cliStatusTotp', {\n state: output(status.totpEnabled ? 'cliTotpEnabled' : 'cliTotpDisabled'),\n }),\n output('cliStatusSessions', { count: status.activeSessions }),\n output('cliStatusService', {\n state: output(\n status.online\n ? status.ready\n ? 'cliOnlineReady'\n : 'cliOnlineNotReady'\n : 'cliOffline',\n ),\n }),\n ].join('\\n') + '\\n',\n )\n return\n }\n process.stdout.write(`${output('cliCompleted', { command: command! })}\\n`)\n}\n\nvoid main().catch((error: unknown) => {\n process.stderr.write(`${errorText(error, currentLocale)}\\n`)\n process.exitCode = 1\n})\n", "import { randomBytes } from 'node:crypto'\nimport type { AuthState, AccountRecord, SessionRecord } from '../storage/state.js'\nimport { AuthStateStore } from '../storage/store.js'\nimport {\n DUMMY_PASSWORD_RECORD,\n hashPassword,\n validatePassword,\n verifyPassword,\n} from './password.js'\nimport { issueSession, sessionFor, sessionHash } from './sessions.js'\nimport { backupCodeHash, generateBackupCodes, generateTotpSecret, matchedTotpStep } from './totp.js'\n\nexport interface AuthPolicy {\n requireTotp: boolean\n sessionHours: number\n}\n\nexport type AuthErrorCode =\n | 'invalid_input'\n | 'uninitialized'\n | 'already_initialized'\n | 'invalid_credentials'\n | 'invalid_factor'\n | 'invalid_challenge'\n | 'challenge_expired'\n | 'unauthorized'\n | 'rate_limited'\n | 'busy'\n | 'conflict'\n | 'totp_required'\n\nexport class AuthError extends Error {\n constructor(\n readonly code: AuthErrorCode,\n readonly retryAfter?: number,\n ) {\n super(`auth-remote: ${code}`)\n }\n}\n\ninterface BaseChallenge {\n id: string\n accountId: string\n securityVersion: number\n expiresAt: number\n failures: number\n busy: boolean\n}\n\ninterface MfaChallenge extends BaseChallenge {\n kind: 'mfa'\n}\n\ninterface BindingChallenge extends BaseChallenge {\n kind: 'binding'\n secret: string\n originSessionHash: string | null\n}\n\ntype Challenge = MfaChallenge | BindingChallenge\n\nexport type LoginResult =\n | { kind: 'session'; token: string; expiresAt: number }\n | { kind: 'mfa'; challenge: string; expiresAt: number }\n | { kind: 'binding'; challenge: string; secret: string; expiresAt: number }\n\nexport interface AuthServiceOptions {\n now?: () => number\n}\n\nconst LOGIN_CHALLENGE_MS = 5 * 60_000\nconst BINDING_CHALLENGE_MS = 10 * 60_000\nconst RATE_WINDOW_MS = 60_000\nconst MAX_ATTEMPTS = 10\nconst MAX_CHALLENGES = 32\n\nfunction validatePolicy(policy: AuthPolicy, now: number): void {\n if (\n typeof policy.requireTotp !== 'boolean' ||\n !Number.isSafeInteger(policy.sessionHours) ||\n policy.sessionHours < 1 ||\n !Number.isSafeInteger(now + policy.sessionHours * 3_600_000)\n )\n throw new AuthError('invalid_input')\n}\n\nfunction validUsername(username: unknown): username is string {\n return (\n typeof username === 'string' &&\n username.length > 0 &&\n [...username].length <= 64 &&\n !/[\\u0000-\\u001f\\u007f]/u.test(username)\n )\n}\n\nexport class AuthService {\n private readonly now: () => number\n private readonly challenges = new Map<string, Challenge>()\n private readonly attempts: number[] = []\n private activeDerivations = 0\n private policyChanging = false\n private readonly unsubscribe: () => void\n\n constructor(\n private readonly store: AuthStateStore,\n private policy: AuthPolicy,\n options: AuthServiceOptions = {},\n ) {\n this.now = options.now ?? Date.now\n validatePolicy(policy, this.now())\n this.unsubscribe = store.subscribe((previous, current) => {\n if (previous.account?.securityVersion !== current.account?.securityVersion) {\n this.challenges.clear()\n return\n }\n for (const [id, challenge] of this.challenges) {\n if (\n challenge.kind === 'binding' &&\n challenge.originSessionHash &&\n previous.sessions[challenge.originSessionHash] &&\n !current.sessions[challenge.originSessionHash]\n )\n this.challenges.delete(id)\n }\n })\n }\n\n dispose(): void {\n this.unsubscribe()\n this.challenges.clear()\n }\n\n status(): { initialized: boolean; totpEnabled: boolean; activeSessions: number } {\n const state = this.store.current()\n return {\n initialized: state.account !== null,\n totpEnabled: state.account?.totp !== null && state.account?.totp !== undefined,\n activeSessions: Object.values(state.sessions).filter(\n (session) =>\n state.account &&\n session.accountId === state.account.id &&\n session.securityVersion === state.account.securityVersion &&\n session.expiresAt > this.now() &&\n (!this.policy.requireTotp || state.account.totp),\n ).length,\n }\n }\n\n session(token: string): SessionRecord | null {\n return sessionFor(this.store.current(), token, this.now(), this.policy.requireTotp)\n }\n\n policySnapshot(): AuthPolicy {\n return { ...this.policy }\n }\n\n me(token: string): { username: string; totpEnabled: boolean; expiresAt: number } {\n const state = this.store.current()\n const session = sessionFor(state, token, this.now(), this.policy.requireTotp)\n if (!session || !state.account) throw new AuthError('unauthorized')\n return {\n username: state.account.username,\n totpEnabled: state.account.totp !== null,\n expiresAt: session.expiresAt,\n }\n }\n\n bindingDetails(id: string): { secret: string; expiresAt: number } {\n const challenge = this.challenges.get(id)\n if (!challenge || challenge.kind !== 'binding') throw new AuthError('invalid_challenge')\n if (challenge.expiresAt <= this.now()) {\n this.challenges.delete(id)\n throw new AuthError('challenge_expired')\n }\n const state = this.store.current()\n this.sameAccount(state, challenge.accountId, challenge.securityVersion)\n if (challenge.originSessionHash) {\n const session = state.sessions[challenge.originSessionHash]\n if (!session || session.expiresAt <= this.now()) throw new AuthError('unauthorized')\n }\n return { secret: challenge.secret, expiresAt: challenge.expiresAt }\n }\n\n pendingChallenges(): number {\n this.expireChallenges()\n return this.challenges.size\n }\n\n private occupyAttempt(): void {\n const now = this.now()\n while (this.attempts.length > 0 && this.attempts[0]! <= now - RATE_WINDOW_MS)\n this.attempts.shift()\n if (this.attempts.length >= MAX_ATTEMPTS)\n throw new AuthError(\n 'rate_limited',\n Math.ceil((this.attempts[0]! + RATE_WINDOW_MS - now) / 1000),\n )\n this.attempts.push(now)\n }\n\n private async derive<T>(run: () => Promise<T>): Promise<T> {\n if (this.activeDerivations >= 2) throw new AuthError('busy')\n this.activeDerivations++\n try {\n return await run()\n } finally {\n this.activeDerivations--\n }\n }\n\n private expireChallenges(): void {\n const now = this.now()\n for (const [id, challenge] of this.challenges)\n if (challenge.expiresAt <= now) this.challenges.delete(id)\n }\n\n private createChallenge(\n kind: 'mfa' | 'binding',\n account: AccountRecord,\n originSessionHash: string | null = null,\n ): LoginResult {\n this.expireChallenges()\n if (this.challenges.size >= MAX_CHALLENGES) throw new AuthError('busy')\n const id = randomBytes(32).toString('base64url')\n const expiresAt = this.now() + (kind === 'mfa' ? LOGIN_CHALLENGE_MS : BINDING_CHALLENGE_MS)\n const base = {\n id,\n accountId: account.id,\n securityVersion: account.securityVersion,\n expiresAt,\n failures: 0,\n busy: false,\n }\n if (kind === 'mfa') {\n this.challenges.set(id, { ...base, kind })\n return { kind, challenge: id, expiresAt }\n }\n const secret = generateTotpSecret()\n this.challenges.set(id, { ...base, kind, secret, originSessionHash })\n return { kind, challenge: id, secret, expiresAt }\n }\n\n private claim(id: string, kind: Challenge['kind']): Challenge {\n const challenge = this.challenges.get(id)\n if (!challenge || challenge.kind !== kind) throw new AuthError('invalid_challenge')\n if (challenge.expiresAt <= this.now()) {\n this.challenges.delete(id)\n throw new AuthError('challenge_expired')\n }\n if (challenge.busy || challenge.failures >= 5) throw new AuthError('invalid_challenge')\n challenge.busy = true\n return challenge\n }\n\n private failedChallenge(challenge: Challenge): void {\n challenge.failures++\n if (challenge.failures >= 5) this.challenges.delete(challenge.id)\n }\n\n private sameAccount(state: AuthState, accountId: string, securityVersion: number): AccountRecord {\n const account = state.account\n if (!account || account.id !== accountId || account.securityVersion !== securityVersion)\n throw new AuthError('conflict')\n return account\n }\n\n private requireSession(state: AuthState, token: string): AccountRecord {\n if (!sessionFor(state, token, this.now(), this.policy.requireTotp))\n throw new AuthError('unauthorized')\n return state.account!\n }\n\n private verifyFactor(account: AccountRecord, code: string | undefined): boolean {\n const factor = account.totp\n if (!factor) return true\n if (!code) return false\n const step = matchedTotpStep(factor.secret, code, this.now(), factor.lastUsedStep)\n if (step !== null) {\n factor.lastUsedStep = step\n return true\n }\n const hash = backupCodeHash(code)\n if (!hash) return false\n const index = factor.backupCodeHashes.indexOf(hash)\n if (index < 0) return false\n factor.backupCodeHashes.splice(index, 1)\n return true\n }\n\n async initialize(username: string, password: string): Promise<void> {\n if (!validUsername(username)) throw new AuthError('invalid_input')\n validatePassword(password)\n if (this.store.current().account) throw new AuthError('already_initialized')\n const record = await this.derive(() => hashPassword(password))\n await this.store.transact((draft) => {\n if (draft.account) throw new AuthError('already_initialized')\n draft.account = {\n id: randomBytes(16).toString('hex'),\n username,\n password: record,\n totp: null,\n securityVersion: 1,\n }\n })\n }\n\n async login(username: string, password: string): Promise<LoginResult> {\n this.occupyAttempt()\n if (!validUsername(username) || typeof password !== 'string' || password.length > 1024)\n throw new AuthError('invalid_credentials')\n const snapshot = this.store.current()\n const account = snapshot.account\n if (!account) throw new AuthError('uninitialized')\n const match = await this.derive(() =>\n verifyPassword(\n password,\n username === account.username ? account.password : DUMMY_PASSWORD_RECORD,\n ),\n )\n if (!match || username !== account.username) throw new AuthError('invalid_credentials')\n const current = this.store.current()\n const latest = this.sameAccount(current, account.id, account.securityVersion)\n if (latest.totp) return this.createChallenge('mfa', latest)\n if (this.policy.requireTotp) return this.createChallenge('binding', latest)\n const issued = await this.store.transact((draft) => {\n this.sameAccount(draft, account.id, account.securityVersion)\n if (draft.account!.totp || this.policy.requireTotp) throw new AuthError('conflict')\n return issueSession(draft, this.now(), this.policy.sessionHours)\n })\n return { kind: 'session', ...issued }\n }\n\n async verifyMfa(id: string, code: string): Promise<{ token: string; expiresAt: number }> {\n this.occupyAttempt()\n const challenge = this.claim(id, 'mfa') as MfaChallenge\n try {\n const issued = await this.store.transact((draft) => {\n if (challenge.expiresAt <= this.now()) throw new AuthError('challenge_expired')\n const account = this.sameAccount(draft, challenge.accountId, challenge.securityVersion)\n if (!account.totp || !this.verifyFactor(account, code))\n throw new AuthError('invalid_factor')\n return issueSession(draft, this.now(), this.policy.sessionHours)\n })\n this.challenges.delete(id)\n return issued\n } catch (error) {\n if (error instanceof AuthError && error.code === 'invalid_factor')\n this.failedChallenge(challenge)\n throw error\n } finally {\n challenge.busy = false\n }\n }\n\n async startBinding(\n token: string,\n password: string,\n currentCode?: string,\n ): Promise<Extract<LoginResult, { kind: 'binding' }>> {\n this.occupyAttempt()\n const snapshot = this.store.current()\n const account = this.requireSession(snapshot, token)\n if (typeof password !== 'string' || password.length > 1024)\n throw new AuthError('invalid_credentials')\n const match = await this.derive(() => verifyPassword(password, account.password))\n if (!match) throw new AuthError('invalid_credentials')\n if (account.totp) {\n await this.store.transact((draft) => {\n this.requireSession(draft, token)\n this.sameAccount(draft, account.id, account.securityVersion)\n if (!this.verifyFactor(draft.account!, currentCode)) throw new AuthError('invalid_factor')\n })\n } else {\n const latest = this.store.current()\n this.requireSession(latest, token)\n this.sameAccount(latest, account.id, account.securityVersion)\n }\n return this.createChallenge('binding', account, sessionHash(token)) as Extract<\n LoginResult,\n { kind: 'binding' }\n >\n }\n\n async confirmBinding(id: string, code: string): Promise<{ backupCodes: string[] }> {\n this.occupyAttempt()\n const challenge = this.claim(id, 'binding') as BindingChallenge\n try {\n const step = matchedTotpStep(challenge.secret, code, this.now(), null)\n if (step === null) {\n this.failedChallenge(challenge)\n throw new AuthError('invalid_factor')\n }\n const backups = generateBackupCodes()\n await this.store.transact((draft) => {\n if (challenge.expiresAt <= this.now()) throw new AuthError('challenge_expired')\n const account = this.sameAccount(draft, challenge.accountId, challenge.securityVersion)\n const originSession = challenge.originSessionHash\n ? draft.sessions[challenge.originSessionHash]\n : null\n if (\n challenge.originSessionHash &&\n (!originSession || originSession.expiresAt <= this.now())\n )\n throw new AuthError('unauthorized')\n account.totp = {\n secret: challenge.secret,\n lastUsedStep: step,\n backupCodeHashes: backups.hashes,\n }\n account.securityVersion++\n draft.sessions = {}\n })\n this.challenges.clear()\n return { backupCodes: backups.codes }\n } finally {\n challenge.busy = false\n }\n }\n\n async changePassword(\n token: string,\n currentPassword: string,\n currentCode: string | undefined,\n newPassword: string,\n ): Promise<void> {\n this.occupyAttempt()\n validatePassword(newPassword)\n if (typeof currentPassword !== 'string' || currentPassword.length > 1024)\n throw new AuthError('invalid_credentials')\n const snapshot = this.store.current()\n const account = this.requireSession(snapshot, token)\n const match = await this.derive(() => verifyPassword(currentPassword, account.password))\n if (!match) throw new AuthError('invalid_credentials')\n const replacement = await this.derive(() => hashPassword(newPassword))\n await this.store.transact((draft) => {\n this.requireSession(draft, token)\n const current = this.sameAccount(draft, account.id, account.securityVersion)\n if (!this.verifyFactor(current, currentCode)) throw new AuthError('invalid_factor')\n current.password = replacement\n current.securityVersion++\n draft.sessions = {}\n })\n }\n\n async disableTotp(token: string, password: string, currentCode: string): Promise<void> {\n this.occupyAttempt()\n if (this.policy.requireTotp) throw new AuthError('totp_required')\n if (typeof password !== 'string' || password.length > 1024)\n throw new AuthError('invalid_credentials')\n const snapshot = this.store.current()\n const account = this.requireSession(snapshot, token)\n const match = await this.derive(() => verifyPassword(password, account.password))\n if (!match) throw new AuthError('invalid_credentials')\n await this.store.transact((draft) => {\n this.requireSession(draft, token)\n const current = this.sameAccount(draft, account.id, account.securityVersion)\n if (!current.totp || !this.verifyFactor(current, currentCode))\n throw new AuthError('invalid_factor')\n current.totp = null\n current.securityVersion++\n draft.sessions = {}\n })\n }\n\n async revokeWithCredentials(\n token: string,\n password: string,\n currentCode?: string,\n ): Promise<void> {\n this.occupyAttempt()\n if (typeof password !== 'string' || password.length > 1024)\n throw new AuthError('invalid_credentials')\n const snapshot = this.store.current()\n const account = this.requireSession(snapshot, token)\n const match = await this.derive(() => verifyPassword(password, account.password))\n if (!match) throw new AuthError('invalid_credentials')\n await this.store.transact((draft) => {\n this.requireSession(draft, token)\n const current = this.sameAccount(draft, account.id, account.securityVersion)\n if (!this.verifyFactor(current, currentCode)) throw new AuthError('invalid_factor')\n current.securityVersion++\n draft.sessions = {}\n })\n }\n\n async logout(token: string): Promise<void> {\n if (typeof token !== 'string' || !/^[A-Za-z0-9_-]{43}$/u.test(token)) return\n const hash = sessionHash(token)\n if (!this.store.current().sessions[hash]) return\n await this.store.transact((draft) => {\n delete draft.sessions[hash]\n })\n }\n\n async resetPassword(newPassword: string): Promise<void> {\n validatePassword(newPassword)\n const replacement = await this.derive(() => hashPassword(newPassword))\n await this.store.transact((draft) => {\n if (!draft.account) throw new AuthError('uninitialized')\n draft.account.password = replacement\n draft.account.securityVersion++\n draft.sessions = {}\n })\n }\n\n async resetTotp(): Promise<void> {\n await this.store.transact((draft) => {\n if (!draft.account) throw new AuthError('uninitialized')\n draft.account.totp = null\n draft.account.securityVersion++\n draft.sessions = {}\n })\n }\n\n async revokeAll(): Promise<void> {\n await this.store.transact((draft) => {\n if (!draft.account) throw new AuthError('uninitialized')\n draft.account.securityVersion++\n draft.sessions = {}\n })\n }\n\n async applyPolicy(next: AuthPolicy): Promise<void> {\n validatePolicy(next, this.now())\n if (this.policyChanging) throw new AuthError('busy')\n if (\n next.requireTotp === this.policy.requireTotp &&\n next.sessionHours === this.policy.sessionHours\n )\n return\n this.policyChanging = true\n const previous = this.policy\n this.policy = next // fail closed while the policy commit is pending\n try {\n await this.store.transact((draft) => {\n if (next.requireTotp && !previous.requireTotp && draft.account && !draft.account.totp) {\n draft.account.securityVersion++\n draft.sessions = {}\n }\n if (next.sessionHours < previous.sessionHours) {\n for (const session of Object.values(draft.sessions))\n session.expiresAt = Math.min(\n session.expiresAt,\n session.createdAt + next.sessionHours * 3_600_000,\n )\n }\n })\n this.challenges.clear()\n } catch (error) {\n if (this.store.healthy()) this.policy = previous\n throw error\n } finally {\n this.policyChanging = false\n }\n }\n\n /** Startup/re-activation must persist tightening before the guarded listener opens. */\n async enforceCurrentPolicy(): Promise<void> {\n const state = this.store.current()\n const revokeUnbound =\n this.policy.requireTotp && !state.account?.totp && Object.keys(state.sessions).length > 0\n const shorten = Object.values(state.sessions).some(\n (session) => session.expiresAt > session.createdAt + this.policy.sessionHours * 3_600_000,\n )\n if (!revokeUnbound && !shorten) return\n await this.store.transact((draft) => {\n if (this.policy.requireTotp && draft.account && !draft.account.totp) {\n draft.account.securityVersion++\n draft.sessions = {}\n }\n for (const session of Object.values(draft.sessions))\n session.expiresAt = Math.min(\n session.expiresAt,\n session.createdAt + this.policy.sessionHours * 3_600_000,\n )\n })\n }\n}\n", "import { randomUUID } from 'node:crypto'\nimport { constants } from 'node:fs'\nimport { lstat, open, readFile, rename, unlink } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { assertPrivateStateFile, STATE_FILE, StateLock } from './lock.js'\nimport { emptyState, validateState, type AuthState } from './state.js'\n\nexport type CommitStage =\n | 'afterTempWrite'\n | 'afterFileSync'\n | 'beforeRename'\n | 'afterRename'\n | 'afterDirSync'\n | 'beforeSuccess'\n\nexport interface StoreOptions {\n /** A failed notification makes the store unavailable before a caller can report success. */\n onCommitted?: (previous: AuthState, current: AuthState) => void | Promise<void>\n onUnavailable?: (reason: Error) => void\n /** Fault injection for isolated tests only. */\n onStage?: (stage: CommitStage) => void | Promise<void>\n}\n\nfunction errno(error: unknown, code: string): boolean {\n return typeof error === 'object' && error !== null && 'code' in error && error.code === code\n}\n\n/** One process owns the lock; every mutation serializes through this instance. */\nexport class AuthStateStore {\n readonly path: string\n private state: AuthState\n private queue: Promise<void> = Promise.resolve()\n private unavailableReason: Error | null = null\n private closed = false\n private readonly listeners = new Set<\n (previous: AuthState, current: AuthState) => void | Promise<void>\n >()\n\n private constructor(\n private readonly lock: StateLock,\n state: AuthState,\n private readonly options: StoreOptions,\n ) {\n this.path = join(lock.dir, STATE_FILE)\n this.state = state\n }\n\n static async open(profileDir: string, options: StoreOptions = {}): Promise<AuthStateStore> {\n const lock = await StateLock.acquire(profileDir)\n try {\n const path = join(lock.dir, STATE_FILE)\n let state = emptyState()\n try {\n await assertPrivateStateFile(path)\n const info = await lstat(path)\n if (info.size > 16 * 1024 * 1024)\n throw new Error('auth-remote: state file exceeds the supported size')\n state = validateState(JSON.parse(await readFile(path, 'utf8')))\n } catch (error) {\n if (!errno(error, 'ENOENT')) throw error\n }\n return new AuthStateStore(lock, state, options)\n } catch (error) {\n await lock.release()\n throw error\n }\n }\n\n healthy(): boolean {\n return !this.closed && this.unavailableReason === null\n }\n\n current(): AuthState {\n if (!this.healthy()) throw this.unavailableReason ?? new Error('auth-remote: store is closed')\n return structuredClone(this.state)\n }\n\n /** Notifications finish before transact reports success; a failed listener closes admission. */\n subscribe(\n listener: (previous: AuthState, current: AuthState) => void | Promise<void>,\n ): () => void {\n if (!this.healthy()) throw this.unavailableReason ?? new Error('auth-remote: store is closed')\n this.listeners.add(listener)\n return () => this.listeners.delete(listener)\n }\n\n async transact<T>(mutate: (draft: AuthState) => T | Promise<T>): Promise<T> {\n const run = async (): Promise<T> => {\n if (!this.healthy()) throw this.unavailableReason ?? new Error('auth-remote: store is closed')\n const draft = structuredClone(this.state)\n const result = await mutate(draft)\n if (this.state.revision >= Number.MAX_SAFE_INTEGER)\n throw new Error('auth-remote: state revision exhausted')\n draft.revision = this.state.revision + 1\n const next = validateState(draft)\n await this.persist(next)\n return result\n }\n const operation = this.queue.then(run)\n this.queue = operation.then(\n () => undefined,\n () => undefined,\n )\n return operation\n }\n\n private async persist(next: AuthState): Promise<void> {\n const temp = `${this.path}.tmp-${process.pid}-${randomUUID()}`\n const bytes = Buffer.from(`${JSON.stringify(next)}\\n`, 'utf8')\n if (bytes.length > 16 * 1024 * 1024)\n throw new Error('auth-remote: state file exceeds the supported size')\n let renamed = false\n let file: Awaited<ReturnType<typeof open>> | undefined\n try {\n file = await open(\n temp,\n constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | constants.O_NOFOLLOW,\n 0o600,\n )\n await file.writeFile(bytes)\n await this.options.onStage?.('afterTempWrite')\n await file.sync()\n await this.options.onStage?.('afterFileSync')\n await file.close()\n file = undefined\n await this.options.onStage?.('beforeRename')\n await rename(temp, this.path)\n renamed = true\n await this.options.onStage?.('afterRename')\n const parent = await open(this.lock.dir, constants.O_RDONLY | constants.O_DIRECTORY)\n try {\n await parent.sync()\n } finally {\n await parent.close()\n }\n await this.options.onStage?.('afterDirSync')\n const previous = this.state\n this.state = next\n await this.options.onCommitted?.(structuredClone(previous), structuredClone(next))\n for (const listener of this.listeners)\n await listener(structuredClone(previous), structuredClone(next))\n await this.options.onStage?.('beforeSuccess')\n } catch (error) {\n if (renamed) {\n this.unavailableReason = new Error('auth-remote: state commit outcome is uncertain', {\n cause: error,\n })\n this.options.onUnavailable?.(this.unavailableReason)\n }\n throw error\n } finally {\n await file?.close().catch(() => undefined)\n if (!renamed) await unlink(temp).catch(() => undefined)\n }\n }\n\n async close(): Promise<void> {\n if (this.closed) return\n this.closed = true\n await this.queue\n await this.lock.release()\n }\n}\n", "import { randomUUID } from 'node:crypto'\nimport { constants } from 'node:fs'\nimport { lstat, mkdir, open, readFile, rmdir, unlink } from 'node:fs/promises'\nimport { join } from 'node:path'\n\nexport const STATE_DIR = 'auth-remote'\nexport const STATE_FILE = 'auth-state.json'\nexport const LOCK_FILE = 'auth-state.lock'\n\ninterface Owner {\n pid: number\n bootId: string\n startTicks: string\n nonce: string\n}\n\nfunction errno(error: unknown, code: string): boolean {\n return typeof error === 'object' && error !== null && 'code' in error && error.code === code\n}\n\nasync function processStartTicks(pid: number): Promise<string | null> {\n let raw: string\n try {\n raw = await readFile(`/proc/${pid}/stat`, 'utf8')\n } catch (error) {\n if (errno(error, 'ENOENT')) return null\n throw error\n }\n const tail = raw\n .slice(raw.lastIndexOf(')') + 1)\n .trim()\n .split(/\\s+/u)\n const ticks = tail[19]\n if (!ticks || !/^\\d+$/u.test(ticks)) throw new Error('auth-remote: cannot verify lock owner')\n return ticks\n}\n\nasync function localOwner(): Promise<Owner> {\n const [bootId, startTicks] = await Promise.all([\n readFile('/proc/sys/kernel/random/boot_id', 'utf8'),\n processStartTicks(process.pid),\n ])\n if (!startTicks) throw new Error('auth-remote: cannot verify own process identity')\n return { pid: process.pid, bootId: bootId.trim(), startTicks, nonce: randomUUID() }\n}\n\nfunction parseOwner(raw: string): Owner {\n let value: unknown\n try {\n value = JSON.parse(raw)\n } catch {\n throw new Error('auth-remote: lock owner is unreadable; manual recovery required')\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new Error('auth-remote: lock owner is invalid; manual recovery required')\n const owner = value as Record<string, unknown>\n if (\n !Number.isSafeInteger(owner.pid) ||\n (owner.pid as number) <= 0 ||\n typeof owner.bootId !== 'string' ||\n !/^[0-9a-f-]{36}$/u.test(owner.bootId) ||\n typeof owner.startTicks !== 'string' ||\n !/^\\d+$/u.test(owner.startTicks) ||\n typeof owner.nonce !== 'string' ||\n !/^[0-9a-f-]{36}$/u.test(owner.nonce)\n )\n throw new Error('auth-remote: lock owner is invalid; manual recovery required')\n return owner as unknown as Owner\n}\n\nasync function isDead(owner: Owner, currentBootId: string): Promise<boolean> {\n if (owner.bootId !== currentBootId) return true\n const ticks = await processStartTicks(owner.pid)\n return ticks === null || ticks !== owner.startTicks\n}\n\nasync function assertPrivate(path: string, kind: 'directory' | 'file'): Promise<void> {\n const info = await lstat(path)\n if (\n (kind === 'directory' ? !info.isDirectory() : !info.isFile()) ||\n info.uid !== process.getuid?.() ||\n (info.mode & 0o777) !== (kind === 'directory' ? 0o700 : 0o600)\n )\n throw new Error(`auth-remote: unsafe ${kind} permissions or owner: ${path}`)\n}\n\nexport async function ensureStateDirectory(profileDir: string): Promise<string> {\n if (process.platform !== 'linux') throw new Error('auth-remote: storage requires Linux /proc')\n const dir = join(profileDir, STATE_DIR)\n let created = false\n try {\n await mkdir(dir, { mode: 0o700 })\n created = true\n } catch (error) {\n if (!errno(error, 'EEXIST')) throw error\n }\n await assertPrivate(dir, 'directory')\n if (created) {\n const parent = await open(profileDir, constants.O_RDONLY | constants.O_DIRECTORY)\n try {\n await parent.sync()\n } finally {\n await parent.close()\n }\n }\n return dir\n}\n\n/** Lock recovery uses a second exclusive directory, so reclaimers cannot erase one another's new lock. */\nexport class StateLock {\n private released = false\n\n private constructor(\n readonly dir: string,\n readonly path: string,\n private readonly owner: Owner,\n ) {}\n\n static async acquire(profileDir: string): Promise<StateLock> {\n const dir = await ensureStateDirectory(profileDir)\n const path = join(dir, LOCK_FILE)\n const owner = await localOwner()\n for (let attempt = 0; attempt < 2; attempt++) {\n try {\n const file = await open(\n path,\n constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | constants.O_NOFOLLOW,\n 0o600,\n )\n try {\n await file.writeFile(JSON.stringify(owner))\n await file.sync()\n } catch (error) {\n await file.close()\n await unlink(path).catch(() => undefined)\n throw error\n }\n await file.close()\n return new StateLock(dir, path, owner)\n } catch (error) {\n if (!errno(error, 'EEXIST')) throw error\n if (attempt === 1) throw new Error('auth-remote: state lock is held or contested')\n await this.recoverStale(dir, path, owner.bootId)\n }\n }\n throw new Error('auth-remote: state lock acquisition failed')\n }\n\n private static async recoverStale(\n dir: string,\n path: string,\n currentBootId: string,\n ): Promise<void> {\n const recovery = `${path}.recovery`\n try {\n await mkdir(recovery, { mode: 0o700 })\n } catch (error) {\n if (errno(error, 'EEXIST'))\n throw new Error(\n 'auth-remote: lock recovery is already active or abandoned; manual review required',\n )\n throw error\n }\n try {\n let info\n try {\n info = await lstat(path)\n } catch (error) {\n if (errno(error, 'ENOENT')) return\n throw error\n }\n await assertPrivate(path, 'file')\n const old = parseOwner(await readFile(path, 'utf8'))\n if (!(await isDead(old, currentBootId)))\n throw new Error(`auth-remote: state lock held by live process ${old.pid}`)\n const latest = await lstat(path)\n if (latest.ino !== info.ino || latest.dev !== info.dev)\n throw new Error('auth-remote: state lock changed during recovery')\n await unlink(path)\n const parent = await open(dir, constants.O_RDONLY | constants.O_DIRECTORY)\n try {\n await parent.sync()\n } finally {\n await parent.close()\n }\n } finally {\n await rmdir(recovery)\n }\n }\n\n async release(): Promise<void> {\n if (this.released) return\n const current = parseOwner(await readFile(this.path, 'utf8'))\n if (current.nonce !== this.owner.nonce)\n throw new Error('auth-remote: state lock ownership changed before release')\n await unlink(this.path)\n this.released = true\n }\n}\n\nexport async function assertPrivateStateFile(path: string): Promise<void> {\n await assertPrivate(path, 'file')\n}\n", "/** The only persisted representation of account and full-session state. */\nexport const STATE_SCHEMA_VERSION = 1\n\nexport interface PasswordRecord {\n salt: string\n hash: string\n}\n\nexport interface TotpRecord {\n secret: string\n lastUsedStep: number | null\n backupCodeHashes: string[]\n}\n\nexport interface AccountRecord {\n id: string\n username: string\n password: PasswordRecord\n totp: TotpRecord | null\n securityVersion: number\n}\n\nexport interface SessionRecord {\n accountId: string\n securityVersion: number\n createdAt: number\n expiresAt: number\n}\n\nexport interface AuthState {\n schemaVersion: typeof STATE_SCHEMA_VERSION\n revision: number\n account: AccountRecord | null\n /** Keys are SHA-256 token hashes, never bearer tokens. */\n sessions: Record<string, SessionRecord>\n}\n\nexport function emptyState(): AuthState {\n return { schemaVersion: STATE_SCHEMA_VERSION, revision: 0, account: null, sessions: {} }\n}\n\nfunction record(value: unknown, keys: string[], label: string): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new Error(`auth-remote: invalid ${label}`)\n const entries = Object.keys(value)\n if (entries.length !== keys.length || entries.some((key) => !keys.includes(key)))\n throw new Error(`auth-remote: invalid ${label} fields`)\n return value as Record<string, unknown>\n}\n\nfunction integer(value: unknown, label: string, min = 0): number {\n if (!Number.isSafeInteger(value) || (value as number) < min)\n throw new Error(`auth-remote: invalid ${label}`)\n return value as number\n}\n\nfunction nonempty(value: unknown, label: string): string {\n if (typeof value !== 'string' || value.length === 0)\n throw new Error(`auth-remote: invalid ${label}`)\n return value\n}\n\nfunction hex(value: unknown, bytes: number, label: string): string {\n if (typeof value !== 'string' || !new RegExp(`^[a-f0-9]{${bytes * 2}}$`, 'u').test(value))\n throw new Error(`auth-remote: invalid ${label}`)\n return value\n}\n\nfunction digest(value: unknown, label: string): string {\n if (typeof value !== 'string' || !/^[a-f0-9]{64}$/u.test(value))\n throw new Error(`auth-remote: invalid ${label}`)\n return value\n}\n\nexport function validateState(value: unknown): AuthState {\n const state = record(value, ['schemaVersion', 'revision', 'account', 'sessions'], 'state')\n if (state.schemaVersion !== STATE_SCHEMA_VERSION)\n throw new Error(`auth-remote: unsupported state schema version ${String(state.schemaVersion)}`)\n const revision = integer(state.revision, 'revision')\n let account: AccountRecord | null = null\n if (state.account !== null) {\n const entry = record(\n state.account,\n ['id', 'username', 'password', 'totp', 'securityVersion'],\n 'account',\n )\n const password = record(entry.password, ['salt', 'hash'], 'password record')\n let totp: TotpRecord | null = null\n if (entry.totp !== null) {\n const factor = record(\n entry.totp,\n ['secret', 'lastUsedStep', 'backupCodeHashes'],\n 'TOTP record',\n )\n if (!Array.isArray(factor.backupCodeHashes) || factor.backupCodeHashes.length > 10)\n throw new Error('auth-remote: invalid backup code hashes')\n if (typeof factor.secret !== 'string' || !/^[A-Z2-7]{32}$/u.test(factor.secret))\n throw new Error('auth-remote: invalid TOTP secret')\n totp = {\n secret: factor.secret,\n lastUsedStep:\n factor.lastUsedStep === null ? null : integer(factor.lastUsedStep, 'TOTP step'),\n backupCodeHashes: factor.backupCodeHashes.map((hash) => digest(hash, 'backup code hash')),\n }\n if (new Set(totp.backupCodeHashes).size !== totp.backupCodeHashes.length)\n throw new Error('auth-remote: duplicate backup code hash')\n }\n const username = nonempty(entry.username, 'username')\n if ([...username].length > 64 || /[\\u0000-\\u001f\\u007f]/u.test(username))\n throw new Error('auth-remote: invalid username')\n account = {\n id: hex(entry.id, 16, 'account id'),\n username,\n password: {\n salt: hex(password.salt, 32, 'password salt'),\n hash: hex(password.hash, 64, 'password hash'),\n },\n totp,\n securityVersion: integer(entry.securityVersion, 'security version', 1),\n }\n }\n const sessions = state.sessions\n if (typeof sessions !== 'object' || sessions === null || Array.isArray(sessions))\n throw new Error('auth-remote: invalid sessions')\n const validatedSessions: Record<string, SessionRecord> = Object.create(null)\n for (const [hash, value] of Object.entries(sessions)) {\n digest(hash, 'session token hash')\n const session = record(\n value,\n ['accountId', 'securityVersion', 'createdAt', 'expiresAt'],\n 'session',\n )\n const createdAt = integer(session.createdAt, 'session creation')\n const expiresAt = integer(session.expiresAt, 'session expiry')\n if (!account || session.accountId !== account.id || expiresAt <= createdAt)\n throw new Error('auth-remote: invalid session account or lifetime')\n validatedSessions[hash] = {\n accountId: account.id,\n securityVersion: integer(session.securityVersion, 'session security version', 1),\n createdAt,\n expiresAt,\n }\n }\n return { schemaVersion: STATE_SCHEMA_VERSION, revision, account, sessions: validatedSessions }\n}\n", "import { randomBytes, scrypt as scryptCallback, timingSafeEqual } from 'node:crypto'\nimport type { PasswordRecord } from '../storage/state.js'\n\nexport const PASSWORD_MIN_CHARACTERS = 12\nexport const PASSWORD_MAX_CHARACTERS = 256\n\nexport class PasswordValidationError extends Error {\n constructor() {\n super('auth-remote: password must contain 12\u2013256 Unicode characters')\n }\n}\n\nexport function validatePassword(password: unknown): asserts password is string {\n if (\n typeof password !== 'string' ||\n [...password].length < PASSWORD_MIN_CHARACTERS ||\n [...password].length > PASSWORD_MAX_CHARACTERS\n )\n throw new PasswordValidationError()\n}\n\nasync function derive(password: string, salt: string): Promise<Buffer> {\n return new Promise<Buffer>((resolve, reject) => {\n scryptCallback(\n password,\n Buffer.from(salt, 'hex'),\n 64,\n { N: 16_384, r: 8, p: 1, maxmem: 32 * 1024 * 1024 },\n (error, key) => (error ? reject(error) : resolve(key)),\n )\n })\n}\n\nexport async function hashPassword(password: string): Promise<PasswordRecord> {\n validatePassword(password)\n const salt = randomBytes(32).toString('hex')\n return { salt, hash: (await derive(password, salt)).toString('hex') }\n}\n\nexport async function verifyPassword(password: string, record: PasswordRecord): Promise<boolean> {\n const derived = await derive(password, record.salt)\n return timingSafeEqual(derived, Buffer.from(record.hash, 'hex'))\n}\n\n/** Wrong usernames still perform a comparable derivation. */\nexport const DUMMY_PASSWORD_RECORD: PasswordRecord = {\n salt: '0'.repeat(64),\n hash: '0'.repeat(128),\n}\n", "import { createHash, randomBytes } from 'node:crypto'\nimport type { AuthState, SessionRecord } from '../storage/state.js'\n\nexport function sessionHash(token: string): string {\n return createHash('sha256').update(token).digest('hex')\n}\n\nexport function issueSession(\n draft: AuthState,\n now: number,\n sessionHours: number,\n): { token: string; expiresAt: number } {\n const account = draft.account\n if (!account) throw new Error('auth-remote: cannot issue a session without an account')\n const expiresAt = now + sessionHours * 3_600_000\n if (!Number.isSafeInteger(expiresAt)) throw new Error('auth-remote: session expiry overflow')\n const token = randomBytes(32).toString('base64url')\n draft.sessions[sessionHash(token)] = {\n accountId: account.id,\n securityVersion: account.securityVersion,\n createdAt: now,\n expiresAt,\n }\n return { token, expiresAt }\n}\n\nexport function sessionFor(\n state: AuthState,\n token: string,\n now: number,\n requireTotp: boolean,\n): SessionRecord | null {\n if (typeof token !== 'string' || !/^[A-Za-z0-9_-]{43}$/u.test(token)) return null\n const session = state.sessions[sessionHash(token)]\n const account = state.account\n if (\n !session ||\n !account ||\n session.accountId !== account.id ||\n session.securityVersion !== account.securityVersion ||\n session.expiresAt <= now ||\n (requireTotp && !account.totp)\n )\n return null\n return session\n}\n", "import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto'\n\nconst alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'\nexport const TOTP_PERIOD_MS = 30_000\n\nfunction base32(bytes: Buffer): string {\n let bits = 0\n let value = 0\n let output = ''\n for (const byte of bytes) {\n value = (value << 8) | byte\n bits += 8\n while (bits >= 5) {\n output += alphabet[(value >>> (bits - 5)) & 31]\n bits -= 5\n }\n }\n if (bits > 0) output += alphabet[(value << (5 - bits)) & 31]\n return output\n}\n\nfunction fromBase32(value: string): Buffer {\n let bits = 0\n let accum = 0\n const output: number[] = []\n for (const char of value) {\n const digit = alphabet.indexOf(char)\n if (digit < 0) throw new Error('auth-remote: invalid TOTP secret')\n accum = (accum << 5) | digit\n bits += 5\n if (bits >= 8) {\n output.push((accum >>> (bits - 8)) & 255)\n bits -= 8\n }\n }\n return Buffer.from(output)\n}\n\nexport function generateTotpSecret(): string {\n return base32(randomBytes(20))\n}\n\nexport function totpCode(secret: string, step: number): string {\n if (!Number.isSafeInteger(step) || step < 0) throw new Error('auth-remote: invalid TOTP step')\n const counter = Buffer.alloc(8)\n counter.writeBigUInt64BE(BigInt(step))\n const mac = createHmac('sha1', fromBase32(secret)).update(counter).digest()\n const offset = mac[mac.length - 1]! & 15\n const value = (mac.readUInt32BE(offset) & 0x7fff_ffff) % 1_000_000\n return String(value).padStart(6, '0')\n}\n\nexport function matchedTotpStep(\n secret: string,\n code: string,\n timestamp: number,\n lastUsedStep: number | null,\n): number | null {\n if (typeof code !== 'string' || !/^\\d{6}$/u.test(code)) return null\n const current = Math.floor(timestamp / TOTP_PERIOD_MS)\n for (const step of [current - 1, current, current + 1]) {\n if (step < 0 || (lastUsedStep !== null && step <= lastUsedStep)) continue\n if (timingSafeEqual(Buffer.from(totpCode(secret, step)), Buffer.from(code))) return step\n }\n return null\n}\n\nexport function backupCodeHash(code: string): string | null {\n if (typeof code !== 'string') return null\n const canonical = code.replaceAll('-', '').toUpperCase()\n if (!/^[A-Z2-7]{20}$/u.test(canonical)) return null\n return createHash('sha256').update(`auth-remote-backup:${canonical}`).digest('hex')\n}\n\nexport function generateBackupCodes(): { codes: string[]; hashes: string[] } {\n const codes = Array.from({ length: 10 }, () =>\n base32(randomBytes(12))\n .match(/.{1,5}/gu)!\n .join('-'),\n )\n return { codes, hashes: codes.map((code) => backupCodeHash(code)!) }\n}\n", "export const ADMIN_PROTOCOL_VERSION = 1\nexport const ADMIN_MAX_BYTES = 16 * 1024\n\nexport type AdminRequest =\n | { version: 1; command: 'status' }\n | { version: 1; command: 'init'; username: string; password: string }\n | { version: 1; command: 'reset-password'; password: string }\n | { version: 1; command: 'reset-totp' }\n | { version: 1; command: 'revoke-sessions' }\n\nexport interface AdminStatus {\n initialized: boolean\n totpEnabled: boolean\n activeSessions: number\n online: boolean\n ready: boolean\n}\n\nexport type AdminResponse =\n | { version: 1; ok: true; result: AdminStatus | { ok: true } }\n | { version: 1; ok: false; error: string }\n", "import { lstat } from 'node:fs/promises'\nimport { connect, type Socket } from 'node:net'\nimport { dirname } from 'node:path'\nimport {\n ADMIN_MAX_BYTES,\n ADMIN_PROTOCOL_VERSION,\n type AdminRequest,\n type AdminResponse,\n} from '../shared/admin-contract.js'\nimport { CliDiagnostic } from './language.js'\n\ntype AdminResult = Extract<AdminResponse, { ok: true }>['result']\n\nexport class AdminUnavailable extends Error {\n constructor() {\n super('dsh-auth-remote: management socket is unavailable')\n }\n}\n\nexport class AdminOutcomeUnknown extends Error {\n constructor() {\n super('dsh-auth-remote: management request disconnected or timed out; result is unknown')\n }\n}\n\nexport class AdminRejected extends Error {\n constructor(readonly code: string) {\n super(`dsh-auth-remote: ${code}`)\n }\n}\n\nfunction errno(error: unknown, code: string): boolean {\n return typeof error === 'object' && error !== null && 'code' in error && error.code === code\n}\n\nasync function inspectSocket(path: string): Promise<boolean> {\n let directory\n try {\n directory = await lstat(dirname(path))\n } catch (error) {\n if (errno(error, 'ENOENT')) return false\n throw error\n }\n if (\n !directory.isDirectory() ||\n directory.uid !== process.getuid?.() ||\n (directory.mode & 0o777) !== 0o700\n )\n throw new CliDiagnostic(\n 'cliErrorUnsafeManagementDirectory',\n 'dsh-auth-remote: unsafe management directory',\n )\n let socket\n try {\n socket = await lstat(path)\n } catch (error) {\n if (errno(error, 'ENOENT')) return false\n throw error\n }\n if (!socket.isSocket() || socket.uid !== process.getuid?.() || (socket.mode & 0o777) !== 0o600)\n throw new CliDiagnostic(\n 'cliErrorUnsafeManagementSocket',\n 'dsh-auth-remote: unsafe management socket',\n )\n return true\n}\n\n/** Only pre-connect absence may fall back to the offline state lock. */\nexport async function requestAdmin(path: string, request: AdminRequest): Promise<AdminResult> {\n if (!(await inspectSocket(path))) throw new AdminUnavailable()\n let socket: Socket\n try {\n socket = await new Promise<Socket>((resolve, reject) => {\n const candidate = connect(path)\n candidate.setTimeout(2_000, () => {\n candidate.destroy()\n reject(new AdminUnavailable())\n })\n candidate.once('connect', () => {\n candidate.setTimeout(0)\n resolve(candidate)\n })\n candidate.once('error', reject)\n })\n } catch (error) {\n if (errno(error, 'ENOENT') || errno(error, 'ECONNREFUSED')) throw new AdminUnavailable()\n throw error\n }\n try {\n return await new Promise<AdminResult>((resolve, reject) => {\n let bytes = 0\n const chunks: Buffer[] = []\n let settled = false\n const fail = (error: Error) => {\n if (settled) return\n settled = true\n reject(error)\n socket.destroy()\n }\n socket.setTimeout(30_000, () => fail(new AdminOutcomeUnknown()))\n socket.on('error', () => fail(new AdminOutcomeUnknown()))\n socket.on('end', () => {\n if (!settled) fail(new AdminOutcomeUnknown())\n })\n socket.on('data', (chunk: Buffer) => {\n if (settled) return\n bytes += chunk.length\n if (bytes > ADMIN_MAX_BYTES) return fail(new AdminOutcomeUnknown())\n chunks.push(chunk)\n const data = Buffer.concat(chunks)\n const newline = data.indexOf(10)\n if (newline < 0) return\n if (newline !== data.length - 1) return fail(new AdminOutcomeUnknown())\n let response: unknown\n try {\n response = JSON.parse(data.subarray(0, newline).toString('utf8'))\n } catch {\n return fail(new AdminOutcomeUnknown())\n }\n if (\n typeof response !== 'object' ||\n response === null ||\n !('version' in response) ||\n response.version !== ADMIN_PROTOCOL_VERSION ||\n !('ok' in response) ||\n typeof response.ok !== 'boolean'\n )\n return fail(new AdminOutcomeUnknown())\n const reply = response as AdminResponse\n settled = true\n socket.end()\n if (reply.ok) resolve(reply.result)\n else reject(new AdminRejected(reply.error))\n })\n socket.write(`${JSON.stringify(request)}\\n`)\n })\n } finally {\n socket.destroy()\n }\n}\n", "/** Human-facing text only. Protocol identifiers and command names stay unchanged. */\nexport const en = {\n brand: 'DSH \u00B7 Remote sign-in',\n errorNetwork: 'Connection failed. Check your network and try again.',\n errorRateLimited: 'Too many attempts. Try again in about {seconds} seconds.',\n errorUnauthorized: 'Your session has expired. Sign in again.',\n errorServiceUnavailable: 'The service is temporarily unavailable. Try again later.',\n errorGeneric: 'The operation could not be completed. Try again.',\n\n accountLoginTitle: 'Sign in to your DeepSeek account',\n accountLoginDescription:\n 'Complete authorization in a new tab, then return here to finish signing in.',\n accountLoginStepOpen: 'Click \u201COpen DeepSeek sign-in\u201D below and sign in on the official page.',\n accountLoginStepCopy:\n 'After authorization, the new tab may show a connection error or 404. Copy its full address from the address bar.',\n accountLoginStepSubmit:\n 'Return to this dialog, paste the address below and click \u201CConfirm sign-in\u201D.',\n accountLoginCallbackLabel: 'Full callback address',\n accountLoginCallbackHint:\n 'Include both code and state. The page does not need to load. Submit before this authorization expires.',\n accountLoginOpen: 'Open DeepSeek sign-in',\n accountLoginConfirm: 'Confirm sign-in',\n accountLoginCancel: 'Cancel',\n accountLoginUseApiKey: 'Use API key',\n accountLoginClose: 'Close',\n accountLoginRetry: 'Start again',\n accountLoginReopen: 'Reopen authorization page',\n accountLoginPopupBlocked: 'The new tab was blocked.',\n accountLoginInitializing: 'Preparing authorization\u2026',\n accountLoginWaiting:\n 'Waiting for the callback address. This authorization lasts at most 10 minutes.',\n accountLoginExchanging: 'Completing sign-in\u2026',\n accountLoginInvalidCallback:\n 'This callback address does not match the current authorization. Copy the full address, including code and state, from the latest authorization tab.',\n accountLoginExpired: 'This authorization has expired. Start again.',\n accountLoginMismatch:\n 'This authorization is no longer available in this session. Close this dialog and start again.',\n accountLoginBusy:\n 'Another authorization is in progress. Finish or cancel it before starting again.',\n accountLoginUnavailable: 'This DSH version does not provide compatible account sign-in.',\n accountLoginFailed:\n 'Authorization could not be completed. Start again and submit the address from the new tab.',\n accountLoginNoResponse:\n 'The DeepSeek platform did not respond. Check the DSH server\u2019s network connection and start again.',\n\n loginInitialTitle: 'Sign in to DSH',\n loginInitialLoading: 'Checking sign-in status\u2026',\n loginLanguageLabel: 'Language',\n loginSetupTitle: 'Set up your account first',\n loginSetupDescription:\n 'Run this command in a terminal on the server running DSH, then create a username and password when prompted. The web page cannot create the account.',\n loginSetupCopy: 'Copy command',\n loginSetupRecheck: 'I finished setup',\n loginSetupCopied: 'Command copied.',\n loginSetupCopyFallback: 'Select and copy the command manually.',\n loginSetupNotFound:\n 'No account was found. Check that the command used this profile, then try again.',\n loginTitle: 'Sign in to DSH',\n loginDescription: 'Enter the single-user account created in the server terminal.',\n loginUsername: 'Username',\n loginPassword: 'Password',\n loginContinue: 'Continue',\n loginMfaTitle: 'Verify your second factor',\n loginMfaDescription:\n 'Enter the six-digit code from your authenticator or a one-time backup code. This challenge expires in five minutes.',\n loginMfaCode: 'Verification or backup code',\n loginMfaSubmit: 'Verify and sign in',\n loginBackToPassword: 'Back to password sign-in',\n loginMfaExhausted: 'This challenge is exhausted. Enter your password again.',\n loginBindingTitle: 'Connect an authenticator',\n loginBindingDescription:\n 'Scan the QR code with your authenticator, or enter the secret below. After confirmation, ten one-time backup codes will appear and you will need to sign in again.',\n loginBindingQrAlt: 'Authenticator setup QR code',\n loginBindingManualSecret: 'Manual secret',\n loginBindingCode: 'Six-digit code from the authenticator',\n loginBindingConfirm: 'Confirm setup',\n loginBindingRestart: 'Sign in again',\n loginBindingQrUnavailable: 'The QR code is unavailable. Use the manual secret above.',\n loginBindingExhausted: 'This setup challenge is exhausted. Enter your password again.',\n loginBackupTitle: 'Save your backup codes',\n loginBackupDescription:\n 'These codes are shown only once. Store them safely; each code can be used only once. Sign in again after saving them.',\n loginBackupSaved: 'I saved them; sign in again',\n loginOptionalTitle: 'Protect your account',\n loginOptionalDescription:\n 'This profile lets you connect an authenticator later. Connecting one now adds protection; you can also do it in Security settings.',\n loginOptionalBindNow: 'Connect TOTP now',\n loginOptionalSkip: 'Skip and enter DSH',\n loginOptionalVerifyTitle: 'Verify again before setup',\n loginOptionalVerifyDescription: 'Enter your current password to protect your account.',\n loginOptionalCurrentPassword: 'Current password',\n loginOptionalStart: 'Start setup',\n loginOptionalSkipLater: 'Connect later and enter DSH',\n loginReasonExpired: 'Your session has expired. Sign in again.',\n loginReasonUpdated: 'Security settings changed. Sign in again.',\n loginReasonSignedOut: 'You signed out of this device.',\n loginUnavailableTitle: 'Sign-in is temporarily unavailable',\n loginUnavailableDescription: 'The service status is unavailable. Check the connection and retry.',\n loginRetry: 'Check again',\n loginErrorInvalidCredentials: 'The username or password is incorrect. Try again.',\n loginErrorInvalidFactor:\n 'The verification or backup code is incorrect. After five failed attempts, you must enter your password again.',\n loginErrorChallenge: 'This verification expired. Enter your username and password again.',\n loginErrorUninitialized:\n 'The account is not set up. Run the setup command in the server terminal.',\n\n settingsSectionLabel: 'Security',\n settingsSectionAria: 'Security settings',\n settingsTitle: 'Account security',\n settingsAccountSummary: 'Account: {username} \u00B7 TOTP: {totp}',\n settingsTotpEnabled: 'Enabled',\n settingsTotpNotBound: 'Not connected',\n settingsLoading: 'Loading account status\u2026',\n settingsChangePassword: 'Change password',\n settingsBindTotp: 'Connect TOTP',\n settingsRebindTotp: 'Reconnect TOTP',\n settingsSessions: 'Session management',\n settingsPasswordMismatch: 'The new passwords do not match.',\n settingsPasswordDescription: 'After this change, every device must sign in again.',\n settingsCurrentPassword: 'Current password',\n settingsCurrentCode: 'Current verification or backup code',\n settingsNewPassword: 'New password',\n settingsConfirmPassword: 'Confirm new password',\n settingsSavePassword: 'Save new password',\n settingsBindDescription:\n 'Enter your current credentials. After connecting the new authenticator, every device must sign in again.',\n settingsStartBinding: 'Start setup',\n settingsDisableTotp: 'Turn off TOTP',\n settingsDisableDescription: 'After turning off TOTP, every device must sign in again.',\n settingsScanQr: 'Scan the QR code',\n settingsQrAlt: 'Authenticator setup QR code',\n settingsQrUnavailable: 'The QR code is unavailable. Use the manual secret below.',\n settingsQrLoading: 'Generating the QR code; you can use the manual secret below.',\n settingsManualSecret: 'Manual secret:',\n settingsNewCode: 'Six-digit code from the new authenticator',\n settingsConfirmBinding: 'Confirm setup',\n settingsRestartBinding: 'Start over',\n settingsSignOutCurrent: 'Sign out this device',\n settingsSignOutAll: 'Sign out every device',\n settingsSignOutAllDescription:\n 'Enter your current credentials. All signed-in devices and open connections will be revoked.',\n settingsBackupTitle: 'Save your backup codes',\n settingsBackupDescription:\n 'These codes are shown only once. Store them safely; each code can be used only once.',\n settingsBackupSaved: 'I saved them; sign in again',\n settingsErrorInvalidCredentials: 'The current password is incorrect.',\n settingsErrorInvalidFactor: 'The current verification or backup code is incorrect.',\n settingsErrorInvalidInput: 'The input is invalid. Passwords must meet the server length rules.',\n settingsErrorChallenge: 'The setup challenge expired. Start setup again.',\n settingsErrorTotpRequired: 'This profile requires TOTP, so it cannot be turned off.',\n\n cliHelp: `dsh-auth-remote {version}\n\nUsage:\n dsh plugin --profile web exec dsh-auth-remote [--lang en|zh] COMMAND\n\nCommands:\n init Create the single account interactively\n status [--json] Show non-sensitive authentication status\n reset-password Reset the password and revoke all sessions\n reset-totp Clear TOTP, backup codes and all sessions\n revoke-sessions Sign out every device\n\nOptions:\n --lang en|zh Choose the language for human-readable output\n --help, -h Show this help\n --version, -v Show the package version\n\nThe command uses the profile selected by dsh plugin exec and the caller's DSH_HOME.\n`,\n cliPromptUsername: 'Username: ',\n cliPromptPassword: 'Password: ',\n cliPromptPasswordAgain: 'Enter password again: ',\n cliPromptNewPassword: 'New password: ',\n cliPromptNewPasswordAgain: 'Enter new password again: ',\n cliPromptConfirmTarget: 'Enter {profile} to confirm {command}: ',\n cliTargetProfile: 'Target profile: {profile}',\n cliDataFile: 'State file: {path}',\n cliStatusProfile: 'Profile: {profile}',\n cliStatusAccount: 'Account: {state}',\n cliStatusTotp: 'TOTP: {state}',\n cliStatusSessions: 'Active sessions: {count}',\n cliStatusService: 'Service: {state}',\n cliInitialized: 'Initialized',\n cliNotInitialized: 'Not initialized',\n cliTotpEnabled: 'Enabled',\n cliTotpDisabled: 'Disabled',\n cliOnlineReady: 'Online and ready',\n cliOnlineNotReady: 'Online but not ready',\n cliOffline: 'Offline',\n cliCompleted: '{command} completed; the change is durable and effective.',\n cliErrorInvalidArguments: 'Invalid command or arguments. Use --help.',\n cliErrorInvalidLanguage: 'Invalid --lang value. Use en or zh.',\n cliErrorDuplicateLanguage: 'Specify --lang only once.',\n cliErrorMissingLanguage: 'Missing value for --lang. Use en or zh.',\n cliErrorPasswordsMismatch: 'The passwords do not match.',\n cliErrorConfirmationMismatch: 'The confirmation did not match the target profile.',\n cliErrorPasswordLength: 'Password must contain 12\u2013256 Unicode characters.',\n cliErrorTerminalRequired: 'An interactive terminal is required.',\n cliErrorTerminalClosed: 'Terminal input closed.',\n cliErrorCancelled: 'Cancelled.',\n cliErrorProfileDirectory: 'The current directory is not the selected DSH profile under DSH_HOME.',\n cliErrorProfileManifest: 'The profile package.json is missing.',\n cliErrorUnsafeManagementDirectory: 'The management directory has unsafe permissions.',\n cliErrorUnsafeManagementSocket: 'The management socket has unsafe permissions.',\n cliErrorManagementUnavailable: 'The management socket is unavailable.',\n cliErrorOutcomeUnknown:\n 'The management request disconnected or timed out. Its result is unknown; check status before trying again.',\n cliErrorOfflineLock:\n 'The management socket is unavailable while the service holds the profile lock. Offline access was refused.',\n cliErrorInvalidCredentials: 'The current credentials are incorrect.',\n cliErrorAlreadyInitialized: 'The account is already initialized.',\n cliErrorInvalidInput: 'The input is invalid.',\n cliErrorInvalidFactor: 'The verification or backup code is incorrect.',\n cliErrorUninitialized: 'The account is not initialized.',\n cliErrorTotpRequired: 'This profile requires TOTP.',\n cliErrorConflict: 'The account state changed. Check status and retry.',\n cliErrorBusy: 'The service is busy. Try again later.',\n cliErrorUnknown: 'The operation failed. Check status before trying again.',\n} as const\n", "import type { en } from './en.js'\n\nexport const zh = {\n brand: 'DSH \u00B7 \u8FDC\u7A0B\u767B\u5F55',\n errorNetwork: '\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002',\n errorRateLimited: '\u5C1D\u8BD5\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7EA6 {seconds} \u79D2\u540E\u91CD\u8BD5\u3002',\n errorUnauthorized: '\u4F1A\u8BDD\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002',\n errorServiceUnavailable: '\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002',\n errorGeneric: '\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002',\n\n accountLoginTitle: '\u767B\u5F55 DeepSeek \u5B98\u65B9\u8D26\u53F7',\n accountLoginDescription: '\u5728\u65B0\u6807\u7B7E\u9875\u5B8C\u6210\u5B98\u65B9\u6388\u6743\u540E\uFF0C\u8FD4\u56DE\u6B64\u5904\u7EE7\u7EED\u767B\u5F55\u3002',\n accountLoginStepOpen: '\u70B9\u51FB\u4E0B\u65B9\u201C\u6253\u5F00 DeepSeek \u767B\u5F55\u9875\u201D\uFF0C\u5728\u5B98\u65B9\u9875\u9762\u767B\u5F55\u8D26\u53F7\u3002',\n accountLoginStepCopy:\n '\u6388\u6743\u540E\uFF0C\u65B0\u6807\u7B7E\u9875\u53EF\u80FD\u663E\u793A\u8FDE\u63A5\u5931\u8D25\u6216 404\u3002\u8BF7\u590D\u5236\u8BE5\u6807\u7B7E\u9875\u5730\u5740\u680F\u4E2D\u7684\u5B8C\u6574\u5730\u5740\u3002',\n accountLoginStepSubmit: '\u8FD4\u56DE\u6B64\u5F39\u7A97\uFF0C\u5C06\u5730\u5740\u7C98\u8D34\u5230\u4E0B\u65B9\u8F93\u5165\u6846\uFF0C\u518D\u70B9\u51FB\u201C\u786E\u8BA4\u767B\u5F55\u201D\u3002',\n accountLoginCallbackLabel: '\u5B8C\u6574\u56DE\u8C03\u5730\u5740',\n accountLoginCallbackHint:\n '\u5730\u5740\u987B\u5305\u542B code \u548C state\uFF1B\u8BE5\u9875\u9762\u65E0\u9700\u80FD\u6B63\u5E38\u6253\u5F00\u3002\u8BF7\u5728\u672C\u6B21\u6388\u6743\u5230\u671F\u524D\u63D0\u4EA4\u3002',\n accountLoginOpen: '\u6253\u5F00 DeepSeek \u767B\u5F55\u9875',\n accountLoginConfirm: '\u786E\u8BA4\u767B\u5F55',\n accountLoginCancel: '\u53D6\u6D88',\n accountLoginUseApiKey: '\u4F7F\u7528 API Key',\n accountLoginClose: '\u5173\u95ED',\n accountLoginRetry: '\u91CD\u65B0\u5F00\u59CB',\n accountLoginReopen: '\u91CD\u65B0\u6253\u5F00\u6388\u6743\u9875',\n accountLoginPopupBlocked: '\u65B0\u6807\u7B7E\u9875\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\u3002',\n accountLoginInitializing: '\u6B63\u5728\u51C6\u5907\u6388\u6743\u2026',\n accountLoginWaiting: '\u7B49\u5F85\u586B\u5199\u56DE\u8C03\u5730\u5740\u3002\u672C\u6B21\u6388\u6743\u6700\u957F\u6709\u6548\u671F\u4E3A 10 \u5206\u949F\u3002',\n accountLoginExchanging: '\u6B63\u5728\u5B8C\u6210\u767B\u5F55\u2026',\n accountLoginInvalidCallback:\n '\u56DE\u8C03\u5730\u5740\u4E0E\u5F53\u524D\u6388\u6743\u4E0D\u5339\u914D\uFF0C\u8BF7\u4ECE\u6700\u8FD1\u4E00\u6B21\u6388\u6743\u6807\u7B7E\u9875\u590D\u5236\u5305\u542B code \u548C state \u7684\u5B8C\u6574\u5730\u5740\u3002',\n accountLoginExpired: '\u672C\u6B21\u6388\u6743\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u5F00\u59CB\u3002',\n accountLoginMismatch: '\u5F53\u524D\u4F1A\u8BDD\u5DF2\u65E0\u6CD5\u7EE7\u7EED\u6B64\u6388\u6743\uFF0C\u8BF7\u5173\u95ED\u5F39\u7A97\u540E\u91CD\u65B0\u5F00\u59CB\u3002',\n accountLoginBusy: '\u5DF2\u6709\u6388\u6743\u6B63\u5728\u8FDB\u884C\uFF0C\u8BF7\u5148\u5B8C\u6210\u6216\u53D6\u6D88\u540E\u518D\u5F00\u59CB\u3002',\n accountLoginUnavailable: '\u5F53\u524D DSH \u7248\u672C\u672A\u63D0\u4F9B\u517C\u5BB9\u7684\u8D26\u53F7\u767B\u5F55\u529F\u80FD\u3002',\n accountLoginFailed: '\u672A\u80FD\u5B8C\u6210\u6388\u6743\uFF0C\u8BF7\u91CD\u65B0\u5F00\u59CB\uFF0C\u5E76\u63D0\u4EA4\u65B0\u6807\u7B7E\u9875\u4E2D\u7684\u56DE\u8C03\u5730\u5740\u3002',\n accountLoginNoResponse: 'DeepSeek \u5E73\u53F0\u672A\u54CD\u5E94\uFF0C\u8BF7\u68C0\u67E5 DSH \u670D\u52A1\u5668\u7684\u7F51\u7EDC\u8FDE\u63A5\u540E\u91CD\u65B0\u5F00\u59CB\u3002',\n\n loginInitialTitle: '\u767B\u5F55 DSH',\n loginInitialLoading: '\u6B63\u5728\u68C0\u67E5\u767B\u5F55\u72B6\u6001\u2026',\n loginLanguageLabel: '\u8BED\u8A00',\n loginSetupTitle: '\u5148\u521D\u59CB\u5316\u8D26\u53F7',\n loginSetupDescription:\n '\u8BF7\u5728\u8FD0\u884C DSH \u7684\u670D\u52A1\u5668\u7EC8\u7AEF\u8F93\u5165\u4E0B\u5217\u547D\u4EE4\uFF0C\u7136\u540E\u6309\u63D0\u793A\u521B\u5EFA\u7528\u6237\u540D\u548C\u5BC6\u7801\u3002\u7F51\u9875\u4E0D\u4F1A\u521B\u5EFA\u8D26\u53F7\u3002',\n loginSetupCopy: '\u590D\u5236\u547D\u4EE4',\n loginSetupRecheck: '\u6211\u5DF2\u5B8C\u6210\u521D\u59CB\u5316',\n loginSetupCopied: '\u547D\u4EE4\u5DF2\u590D\u5236\u3002',\n loginSetupCopyFallback: '\u8BF7\u624B\u52A8\u9009\u62E9\u5E76\u590D\u5236\u547D\u4EE4\u3002',\n loginSetupNotFound: '\u5C1A\u672A\u68C0\u6D4B\u5230\u8D26\u53F7\u3002\u8BF7\u786E\u8BA4\u547D\u4EE4\u4F7F\u7528\u4E86\u5F53\u524D profile\uFF0C\u518D\u91CD\u65B0\u68C0\u67E5\u3002',\n loginTitle: '\u767B\u5F55 DSH',\n loginDescription: '\u8F93\u5165\u670D\u52A1\u5668\u7EC8\u7AEF\u521B\u5EFA\u7684\u5355\u7528\u6237\u8D26\u53F7\u3002',\n loginUsername: '\u7528\u6237\u540D',\n loginPassword: '\u5BC6\u7801',\n loginContinue: '\u7EE7\u7EED',\n loginMfaTitle: '\u9A8C\u8BC1\u7B2C\u4E8C\u56E0\u7D20',\n loginMfaDescription: '\u8F93\u5165\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u4E2D\u7684 6 \u4F4D\u6570\u5B57\uFF0C\u6216\u8F93\u5165\u4E00\u6B21\u6027\u5907\u7528\u7801\u3002\u6311\u6218 5 \u5206\u949F\u540E\u5931\u6548\u3002',\n loginMfaCode: '\u9A8C\u8BC1\u7801\u6216\u5907\u7528\u7801',\n loginMfaSubmit: '\u9A8C\u8BC1\u5E76\u767B\u5F55',\n loginBackToPassword: '\u8FD4\u56DE\u5BC6\u7801\u767B\u5F55',\n loginMfaExhausted: '\u672C\u6B21\u6311\u6218\u5DF2\u7528\u5C3D\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\u5BC6\u7801\u3002',\n loginBindingTitle: '\u7ED1\u5B9A\u8EAB\u4EFD\u9A8C\u8BC1\u5668',\n loginBindingDescription:\n '\u4F7F\u7528\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u626B\u63CF\u4E8C\u7EF4\u7801\uFF0C\u6216\u624B\u52A8\u8F93\u5165\u4E0B\u65B9\u5BC6\u94A5\u3002\u786E\u8BA4\u6210\u529F\u540E\u5C06\u663E\u793A 10 \u4E2A\u4E00\u6B21\u6027\u5907\u7528\u7801\uFF0C\u5E76\u8981\u6C42\u91CD\u65B0\u767B\u5F55\u3002',\n loginBindingQrAlt: '\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u7ED1\u5B9A\u4E8C\u7EF4\u7801',\n loginBindingManualSecret: '\u624B\u5DE5\u5BC6\u94A5',\n loginBindingCode: '\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u4E2D\u7684 6 \u4F4D\u9A8C\u8BC1\u7801',\n loginBindingConfirm: '\u786E\u8BA4\u7ED1\u5B9A',\n loginBindingRestart: '\u91CD\u65B0\u767B\u5F55',\n loginBindingQrUnavailable: '\u4E8C\u7EF4\u7801\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4F7F\u7528\u4E0A\u65B9\u624B\u5DE5\u5BC6\u94A5\u3002',\n loginBindingExhausted: '\u7ED1\u5B9A\u6311\u6218\u5DF2\u7528\u5C3D\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\u5BC6\u7801\u3002',\n loginBackupTitle: '\u4FDD\u5B58\u5907\u7528\u7801',\n loginBackupDescription:\n '\u8FD9\u4E9B\u5907\u7528\u7801\u53EA\u4F1A\u663E\u793A\u8FD9\u4E00\u6B21\u3002\u8BF7\u5B58\u653E\u5728\u5B89\u5168\u7684\u4F4D\u7F6E\uFF0C\u6BCF\u4E2A\u5907\u7528\u7801\u53EA\u80FD\u4F7F\u7528\u4E00\u6B21\u3002\u4FDD\u5B58\u540E\u91CD\u65B0\u767B\u5F55\u3002',\n loginBackupSaved: '\u6211\u5DF2\u4FDD\u5B58\uFF0C\u91CD\u65B0\u767B\u5F55',\n loginOptionalTitle: '\u4FDD\u62A4\u4F60\u7684\u8D26\u53F7',\n loginOptionalDescription:\n '\u5F53\u524D profile \u5141\u8BB8\u7A0D\u540E\u7ED1\u5B9A\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u3002\u73B0\u5728\u7ED1\u5B9A\u53EF\u4EE5\u589E\u52A0\u4FDD\u62A4\uFF1B\u8DF3\u8FC7\u540E\u4E5F\u53EF\u5728\u5B89\u5168\u8BBE\u7F6E\u4E2D\u7ED1\u5B9A\u3002',\n loginOptionalBindNow: '\u73B0\u5728\u7ED1\u5B9A TOTP',\n loginOptionalSkip: '\u8DF3\u8FC7\uFF0C\u8FDB\u5165 DSH',\n loginOptionalVerifyTitle: '\u518D\u6B21\u9A8C\u8BC1\u540E\u7ED1\u5B9A',\n loginOptionalVerifyDescription: '\u4E3A\u4FDD\u62A4\u8D26\u53F7\uFF0C\u8BF7\u518D\u6B21\u8F93\u5165\u5F53\u524D\u5BC6\u7801\u3002',\n loginOptionalCurrentPassword: '\u5F53\u524D\u5BC6\u7801',\n loginOptionalStart: '\u5F00\u59CB\u7ED1\u5B9A',\n loginOptionalSkipLater: '\u7A0D\u540E\u7ED1\u5B9A\uFF0C\u8FDB\u5165 DSH',\n loginReasonExpired: '\u4F1A\u8BDD\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002',\n loginReasonUpdated: '\u5B89\u5168\u8BBE\u7F6E\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002',\n loginReasonSignedOut: '\u5DF2\u9000\u51FA\u5F53\u524D\u8BBE\u5907\u3002',\n loginUnavailableTitle: '\u6682\u65F6\u65E0\u6CD5\u767B\u5F55',\n loginUnavailableDescription: '\u670D\u52A1\u72B6\u6001\u6682\u65F6\u65E0\u6CD5\u53D6\u5F97\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u5E76\u91CD\u8BD5\u3002',\n loginRetry: '\u91CD\u65B0\u68C0\u67E5',\n loginErrorInvalidCredentials: '\u7528\u6237\u540D\u6216\u5BC6\u7801\u4E0D\u6B63\u786E\uFF0C\u8BF7\u91CD\u8BD5\u3002',\n loginErrorInvalidFactor: '\u9A8C\u8BC1\u7801\u6216\u5907\u7528\u7801\u4E0D\u6B63\u786E\uFF1B\u8FDE\u7EED\u5931\u8D25 5 \u6B21\u540E\u9700\u91CD\u65B0\u8F93\u5165\u5BC6\u7801\u3002',\n loginErrorChallenge: '\u672C\u6B21\u9A8C\u8BC1\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\u7528\u6237\u540D\u548C\u5BC6\u7801\u3002',\n loginErrorUninitialized: '\u8D26\u53F7\u5C1A\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u5728\u670D\u52A1\u5668\u7EC8\u7AEF\u8FD0\u884C\u521D\u59CB\u5316\u547D\u4EE4\u3002',\n\n settingsSectionLabel: '\u5B89\u5168',\n settingsSectionAria: '\u5B89\u5168\u8BBE\u7F6E',\n settingsTitle: '\u8D26\u53F7\u5B89\u5168',\n settingsAccountSummary: '\u8D26\u53F7\uFF1A{username} \u00B7 TOTP\uFF1A{totp}',\n settingsTotpEnabled: '\u5DF2\u542F\u7528',\n settingsTotpNotBound: '\u672A\u7ED1\u5B9A',\n settingsLoading: '\u6B63\u5728\u8BFB\u53D6\u8D26\u53F7\u72B6\u6001\u2026',\n settingsChangePassword: '\u4FEE\u6539\u5BC6\u7801',\n settingsBindTotp: '\u7ED1\u5B9A TOTP',\n settingsRebindTotp: '\u91CD\u65B0\u7ED1\u5B9A TOTP',\n settingsSessions: '\u4F1A\u8BDD\u7BA1\u7406',\n settingsPasswordMismatch: '\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4\u3002',\n settingsPasswordDescription: '\u5B8C\u6210\u540E\u6240\u6709\u8BBE\u5907\u90FD\u9700\u8981\u91CD\u65B0\u767B\u5F55\u3002',\n settingsCurrentPassword: '\u5F53\u524D\u5BC6\u7801',\n settingsCurrentCode: '\u5F53\u524D\u9A8C\u8BC1\u7801\u6216\u5907\u7528\u7801',\n settingsNewPassword: '\u65B0\u5BC6\u7801',\n settingsConfirmPassword: '\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801',\n settingsSavePassword: '\u4FDD\u5B58\u65B0\u5BC6\u7801',\n settingsBindDescription: '\u8BF7\u8F93\u5165\u5F53\u524D\u51ED\u8BC1\uFF1B\u65B0\u7ED1\u5B9A\u5B8C\u6210\u540E\u6240\u6709\u8BBE\u5907\u90FD\u9700\u8981\u91CD\u65B0\u767B\u5F55\u3002',\n settingsStartBinding: '\u5F00\u59CB\u7ED1\u5B9A',\n settingsDisableTotp: '\u5173\u95ED TOTP',\n settingsDisableDescription: '\u5173\u95ED\u540E\u6240\u6709\u8BBE\u5907\u90FD\u9700\u8981\u91CD\u65B0\u767B\u5F55\u3002',\n settingsScanQr: '\u626B\u63CF\u4E8C\u7EF4\u7801',\n settingsQrAlt: '\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u7ED1\u5B9A\u4E8C\u7EF4\u7801',\n settingsQrUnavailable: '\u4E8C\u7EF4\u7801\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4F7F\u7528\u4E0B\u65B9\u624B\u5DE5\u5BC6\u94A5\u3002',\n settingsQrLoading: '\u4E8C\u7EF4\u7801\u751F\u6210\u4E2D\uFF1B\u4E5F\u53EF\u4EE5\u4F7F\u7528\u4E0B\u65B9\u624B\u5DE5\u5BC6\u94A5\u3002',\n settingsManualSecret: '\u624B\u5DE5\u5BC6\u94A5\uFF1A',\n settingsNewCode: '\u65B0\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u7684 6 \u4F4D\u9A8C\u8BC1\u7801',\n settingsConfirmBinding: '\u786E\u8BA4\u7ED1\u5B9A',\n settingsRestartBinding: '\u91CD\u65B0\u5F00\u59CB',\n settingsSignOutCurrent: '\u9000\u51FA\u5F53\u524D\u8BBE\u5907',\n settingsSignOutAll: '\u9000\u51FA\u5168\u90E8\u8BBE\u5907',\n settingsSignOutAllDescription: '\u8BF7\u8F93\u5165\u5F53\u524D\u51ED\u8BC1\uFF1B\u63D0\u4EA4\u540E\u6240\u6709\u5DF2\u767B\u5F55\u8BBE\u5907\u548C\u957F\u8FDE\u63A5\u90FD\u4F1A\u5931\u6548\u3002',\n settingsBackupTitle: '\u4FDD\u5B58\u5907\u7528\u7801',\n settingsBackupDescription:\n '\u8FD9\u4E9B\u5907\u7528\u7801\u53EA\u4F1A\u663E\u793A\u8FD9\u4E00\u6B21\u3002\u8BF7\u5B58\u653E\u5728\u5B89\u5168\u7684\u4F4D\u7F6E\uFF0C\u6BCF\u4E2A\u5907\u7528\u7801\u53EA\u80FD\u4F7F\u7528\u4E00\u6B21\u3002',\n settingsBackupSaved: '\u6211\u5DF2\u4FDD\u5B58\uFF0C\u91CD\u65B0\u767B\u5F55',\n settingsErrorInvalidCredentials: '\u5F53\u524D\u5BC6\u7801\u4E0D\u6B63\u786E\u3002',\n settingsErrorInvalidFactor: '\u5F53\u524D\u9A8C\u8BC1\u7801\u6216\u5907\u7528\u7801\u4E0D\u6B63\u786E\u3002',\n settingsErrorInvalidInput: '\u8F93\u5165\u4E0D\u7B26\u5408\u8981\u6C42\uFF1B\u5BC6\u7801\u9700\u7B26\u5408\u670D\u52A1\u7AEF\u957F\u5EA6\u89C4\u5219\u3002',\n settingsErrorChallenge: '\u7ED1\u5B9A\u6311\u6218\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u5F00\u59CB\u7ED1\u5B9A\u3002',\n settingsErrorTotpRequired: '\u5F53\u524D profile \u8981\u6C42 TOTP\uFF0C\u65E0\u6CD5\u5173\u95ED\u3002',\n\n cliHelp: `dsh-auth-remote {version}\n\n\u7528\u6CD5\uFF1A\n dsh plugin --profile web exec dsh-auth-remote [--lang en|zh] COMMAND\n\n\u547D\u4EE4\uFF1A\n init \u5728\u7EC8\u7AEF\u4EA4\u4E92\u521D\u59CB\u5316\u5355\u7528\u6237\u8D26\u53F7\n status [--json] \u67E5\u770B\u4E0D\u542B\u79D8\u5BC6\u7684\u8BA4\u8BC1\u72B6\u6001\n reset-password \u91CD\u7F6E\u5BC6\u7801\u5E76\u64A4\u9500\u5168\u90E8\u4F1A\u8BDD\n reset-totp \u6E05\u9664 TOTP\u3001\u5907\u7528\u7801\u53CA\u5168\u90E8\u4F1A\u8BDD\n revoke-sessions \u9000\u51FA\u6240\u6709\u8BBE\u5907\n\n\u9009\u9879\uFF1A\n --lang en|zh \u9009\u62E9\u4EBA\u7C7B\u53EF\u8BFB\u8F93\u51FA\u7684\u8BED\u8A00\n --help, -h \u663E\u793A\u5E2E\u52A9\n --version, -v \u663E\u793A\u5305\u7248\u672C\n\n\u547D\u4EE4\u4F7F\u7528 dsh plugin exec \u9009\u5B9A\u7684 profile \u548C\u8C03\u7528\u8005\u7684 DSH_HOME\u3002\n`,\n cliPromptUsername: '\u7528\u6237\u540D: ',\n cliPromptPassword: '\u5BC6\u7801: ',\n cliPromptPasswordAgain: '\u518D\u6B21\u8F93\u5165\u5BC6\u7801: ',\n cliPromptNewPassword: '\u65B0\u5BC6\u7801: ',\n cliPromptNewPasswordAgain: '\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ',\n cliPromptConfirmTarget: '\u8F93\u5165 {profile} \u4EE5\u786E\u8BA4 {command}: ',\n cliTargetProfile: '\u76EE\u6807 profile: {profile}',\n cliDataFile: '\u6570\u636E\u6587\u4EF6: {path}',\n cliStatusProfile: 'profile: {profile}',\n cliStatusAccount: '\u8D26\u53F7: {state}',\n cliStatusTotp: 'TOTP: {state}',\n cliStatusSessions: '\u6709\u6548\u4F1A\u8BDD: {count}',\n cliStatusService: '\u670D\u52A1: {state}',\n cliInitialized: '\u5DF2\u521D\u59CB\u5316',\n cliNotInitialized: '\u672A\u521D\u59CB\u5316',\n cliTotpEnabled: '\u5DF2\u542F\u7528',\n cliTotpDisabled: '\u672A\u542F\u7528',\n cliOnlineReady: '\u5728\u7EBF\u4E14\u5C31\u7EEA',\n cliOnlineNotReady: '\u5728\u7EBF\u4F46\u672A\u5C31\u7EEA',\n cliOffline: '\u79BB\u7EBF',\n cliCompleted: '{command} \u5DF2\u5B8C\u6210\uFF1B\u53D8\u66F4\u5DF2\u6301\u4E45\u5316\u5E76\u751F\u6548\u3002',\n cliErrorInvalidArguments: '\u547D\u4EE4\u6216\u53C2\u6570\u65E0\u6548\uFF0C\u8BF7\u4F7F\u7528 --help\u3002',\n cliErrorInvalidLanguage: '--lang \u7684\u503C\u65E0\u6548\uFF0C\u8BF7\u4F7F\u7528 en \u6216 zh\u3002',\n cliErrorDuplicateLanguage: '--lang \u53EA\u80FD\u6307\u5B9A\u4E00\u6B21\u3002',\n cliErrorMissingLanguage: '--lang \u7F3A\u5C11\u503C\uFF0C\u8BF7\u4F7F\u7528 en \u6216 zh\u3002',\n cliErrorPasswordsMismatch: '\u4E24\u6B21\u8F93\u5165\u7684\u5BC6\u7801\u4E0D\u4E00\u81F4\u3002',\n cliErrorConfirmationMismatch: '\u786E\u8BA4\u8F93\u5165\u4E0E\u76EE\u6807 profile \u4E0D\u4E00\u81F4\u3002',\n cliErrorPasswordLength: '\u5BC6\u7801\u987B\u5305\u542B 12\u2013256 \u4E2A Unicode \u5B57\u7B26\u3002',\n cliErrorTerminalRequired: '\u6B64\u64CD\u4F5C\u9700\u8981\u4EA4\u4E92\u7EC8\u7AEF\u3002',\n cliErrorTerminalClosed: '\u7EC8\u7AEF\u8F93\u5165\u5DF2\u5173\u95ED\u3002',\n cliErrorCancelled: '\u5DF2\u53D6\u6D88\u3002',\n cliErrorProfileDirectory: '\u5F53\u524D\u76EE\u5F55\u4E0D\u662F DSH_HOME \u4E0B\u9009\u5B9A\u7684 DSH profile\u3002',\n cliErrorProfileManifest: '\u7F3A\u5C11 profile \u7684 package.json\u3002',\n cliErrorUnsafeManagementDirectory: '\u7BA1\u7406\u76EE\u5F55\u6743\u9650\u4E0D\u5B89\u5168\u3002',\n cliErrorUnsafeManagementSocket: '\u7BA1\u7406 socket \u6743\u9650\u4E0D\u5B89\u5168\u3002',\n cliErrorManagementUnavailable: '\u7BA1\u7406 socket \u4E0D\u53EF\u7528\u3002',\n cliErrorOutcomeUnknown: '\u7BA1\u7406\u8BF7\u6C42\u5DF2\u65AD\u5F00\u6216\u8D85\u65F6\uFF0C\u7ED3\u679C\u672A\u77E5\uFF1B\u518D\u6B21\u64CD\u4F5C\u524D\u8BF7\u5148\u68C0\u67E5\u72B6\u6001\u3002',\n cliErrorOfflineLock: '\u670D\u52A1\u4ECD\u6301\u6709 profile \u9501\u4E14\u7BA1\u7406 socket \u4E0D\u53EF\u7528\uFF0C\u5DF2\u62D2\u7EDD\u79BB\u7EBF\u64CD\u4F5C\u3002',\n cliErrorInvalidCredentials: '\u5F53\u524D\u51ED\u8BC1\u4E0D\u6B63\u786E\u3002',\n cliErrorAlreadyInitialized: '\u8D26\u53F7\u5DF2\u521D\u59CB\u5316\u3002',\n cliErrorInvalidInput: '\u8F93\u5165\u65E0\u6548\u3002',\n cliErrorInvalidFactor: '\u9A8C\u8BC1\u7801\u6216\u5907\u7528\u7801\u4E0D\u6B63\u786E\u3002',\n cliErrorUninitialized: '\u8D26\u53F7\u5C1A\u672A\u521D\u59CB\u5316\u3002',\n cliErrorTotpRequired: '\u6B64 profile \u8981\u6C42 TOTP\u3002',\n cliErrorConflict: '\u8D26\u53F7\u72B6\u6001\u5DF2\u53D8\u5316\uFF0C\u8BF7\u68C0\u67E5\u72B6\u6001\u540E\u91CD\u8BD5\u3002',\n cliErrorBusy: '\u670D\u52A1\u6B63\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002',\n cliErrorUnknown: '\u64CD\u4F5C\u5931\u8D25\uFF1B\u518D\u6B21\u64CD\u4F5C\u524D\u8BF7\u5148\u68C0\u67E5\u72B6\u6001\u3002',\n} as const satisfies { [Key in keyof typeof en]: string }\n", "import { en } from './locales/en.js'\nimport { zh } from './locales/zh.js'\n\nexport { en, zh }\nexport const dictionaries = { en, zh } as const\n\nexport type Locale = keyof typeof dictionaries\nexport type MessageKey = keyof typeof en\n\ntype Placeholders<Text extends string> = Text extends `${string}{${infer Name}}${infer Rest}`\n ? Name | Placeholders<Rest>\n : never\ntype SameSet<Left, Right> = [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false\ntype MismatchedPlaceholderKeys = {\n [Key in MessageKey]: SameSet<\n Placeholders<(typeof en)[Key]>,\n Placeholders<(typeof zh)[Key]>\n > extends true\n ? never\n : Key\n}[MessageKey]\n\n/** A compile-time failure here identifies any key whose placeholder names differ by language. */\nexport const localePlaceholdersMatch: MismatchedPlaceholderKeys extends never ? true : never = true\n\ntype FormatArgs<Key extends MessageKey> = [Placeholders<(typeof en)[Key]>] extends [never]\n ? []\n : [values: Record<Placeholders<(typeof en)[Key]>, string | number>]\n\n/** Only exact en/zh values are valid for the login page's stored preference. */\nexport function parseExactLocale(value: unknown): Locale | null {\n return value === 'en' || value === 'zh' ? value : null\n}\n\n/** CLI and language-tag inputs use Chinese for zh variants and English otherwise. */\nexport function localeFromLanguageTag(value: string | undefined): Locale {\n return value && /^zh(?:[-_.@]|$)/iu.test(value.trim()) ? 'zh' : 'en'\n}\n\nexport function normalizeLocale(value: unknown): Locale {\n return parseExactLocale(value) ?? 'en'\n}\n\n/** Returns plain text. Insert into textContent, React text, or escape before HTML templates. */\nexport function formatMessage<Key extends MessageKey>(\n locale: Locale | string | undefined,\n key: Key,\n ...args: FormatArgs<Key>\n): string {\n const template: string = dictionaries[normalizeLocale(locale)][key]\n const values = (args[0] ?? {}) as Record<string, string | number>\n return template.replace(/\\{([A-Za-z][A-Za-z0-9]*)\\}/gu, (_match, name: string) => {\n if (!Object.hasOwn(values, name)) throw new Error(`Missing i18n parameter ${name} for ${key}`)\n return String(values[name])\n })\n}\n\n/** For the existing standalone login HTML templates; dynamic values remain text. */\nexport function escapeHtmlText(value: string): string {\n return value.replace(/[&<>\"']/gu, (char) => {\n switch (char) {\n case '&':\n return '&amp;'\n case '<':\n return '&lt;'\n case '>':\n return '&gt;'\n case '\"':\n return '&quot;'\n default:\n return '&#39;'\n }\n })\n}\n", "import {\n formatMessage,\n localeFromLanguageTag,\n type Locale,\n type MessageKey,\n} from '../shared/i18n.js'\n\nexport class CliDiagnostic extends Error {\n constructor(\n readonly key: MessageKey,\n englishMessage: string,\n readonly locale?: Locale,\n ) {\n super(englishMessage)\n }\n}\n\nexport function environmentLocale(env: NodeJS.ProcessEnv): Locale {\n const value = [env.LC_ALL, env.LC_MESSAGES, env.LANG].find(\n (candidate) => candidate !== undefined && candidate.trim().length > 0,\n )\n return localeFromLanguageTag(value)\n}\n\n/** Strip one language option from either side of the command before command validation. */\nexport function parseLanguage(\n input: readonly string[],\n env: NodeJS.ProcessEnv = process.env,\n): { locale: Locale; args: string[] } {\n let locale = environmentLocale(env)\n let explicit = false\n const args: string[] = []\n for (let index = 0; index < input.length; index++) {\n const token = input[index]!\n if (token !== '--lang' && !token.startsWith('--lang=')) {\n args.push(token)\n continue\n }\n if (explicit)\n throw new CliDiagnostic(\n 'cliErrorDuplicateLanguage',\n 'dsh-auth-remote: --lang may be specified only once',\n locale,\n )\n explicit = true\n const value = token === '--lang' ? input[++index] : token.slice('--lang='.length)\n if (value === undefined || value.length === 0 || value.startsWith('--'))\n throw new CliDiagnostic(\n 'cliErrorMissingLanguage',\n 'dsh-auth-remote: --lang requires en or zh',\n locale,\n )\n if (value !== 'en' && value !== 'zh')\n throw new CliDiagnostic(\n 'cliErrorInvalidLanguage',\n 'dsh-auth-remote: invalid --lang value; use en or zh',\n locale,\n )\n locale = value\n }\n return { locale, args }\n}\n\nexport function cliText(\n locale: Locale,\n key: MessageKey,\n params: Record<string, string | number> = {},\n): string {\n return formatMessage(locale, key, params)\n}\n", "import { lstat, realpath } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { basename, dirname, join, resolve } from 'node:path'\nimport { CliDiagnostic } from './language.js'\n\nexport interface ProfileTarget {\n name: string\n dir: string\n home: string\n statePath: string\n socketPath: string\n}\n\nfunction dshHome(env: NodeJS.ProcessEnv): string {\n const supplied = env.DSH_HOME\n const candidate =\n supplied !== undefined && supplied.trim().length > 0 ? supplied : join(homedir(), '.dsh')\n const expanded =\n candidate === '~'\n ? homedir()\n : candidate.startsWith('~/') || candidate.startsWith('~\\\\')\n ? join(homedir(), candidate.slice(2))\n : candidate\n return resolve(expanded)\n}\n\n/** `dsh plugin --profile NAME exec` runs pnpm in the selected profile directory. */\nexport async function resolveProfileTarget(\n cwd = process.cwd(),\n env: NodeJS.ProcessEnv = process.env,\n): Promise<ProfileTarget> {\n const dir = await realpath(cwd)\n const home = await realpath(dshHome(env))\n const profiles = await realpath(join(home, 'profiles'))\n const name = basename(dir)\n const info = await lstat(dir)\n if (\n !info.isDirectory() ||\n info.uid !== process.getuid?.() ||\n dirname(dir) !== profiles ||\n name === 'node_modules' ||\n name === '.' ||\n name === '..'\n )\n throw new CliDiagnostic(\n 'cliErrorProfileDirectory',\n 'dsh-auth-remote: current directory is not the selected DSH profile under DSH_HOME',\n )\n let manifest\n try {\n manifest = await lstat(join(dir, 'package.json'))\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT')\n throw new CliDiagnostic(\n 'cliErrorProfileManifest',\n 'dsh-auth-remote: profile package.json is missing',\n )\n throw error\n }\n if (!manifest.isFile())\n throw new CliDiagnostic(\n 'cliErrorProfileManifest',\n 'dsh-auth-remote: profile package.json is missing',\n )\n return {\n name,\n dir,\n home,\n statePath: join(dir, 'auth-remote', 'auth-state.json'),\n socketPath: join(dir, 'auth-remote', 'admin.sock'),\n }\n}\n", "import type { ReadStream, WriteStream } from 'node:tty'\nimport { CliDiagnostic } from './language.js'\n\n/** One terminal session; secret input is read in raw mode and never echoed. */\nexport class TerminalPrompt {\n private readonly pending: string[] = []\n private wake: (() => void) | undefined\n private readonly decoder = new TextDecoder()\n private readonly previousRaw: boolean\n private closed = false\n private ended = false\n private skipLf = false\n\n constructor(\n private readonly input = process.stdin as ReadStream,\n private readonly output = process.stdout as WriteStream,\n ) {\n if (!input.isTTY || !output.isTTY || typeof input.setRawMode !== 'function')\n throw new CliDiagnostic(\n 'cliErrorTerminalRequired',\n 'dsh-auth-remote: an interactive terminal is required',\n )\n this.previousRaw = input.isRaw\n input.setRawMode(true)\n input.resume()\n input.on('data', this.onData)\n input.once('end', this.onEnd)\n }\n\n private readonly onData = (chunk: Buffer): void => {\n for (const char of this.decoder.decode(chunk, { stream: true })) this.pending.push(char)\n this.wake?.()\n this.wake = undefined\n }\n\n private readonly onEnd = (): void => {\n this.ended = true\n this.wake?.()\n this.wake = undefined\n }\n\n private async take(): Promise<string> {\n while (this.pending.length === 0) {\n if (this.closed || this.ended)\n throw new CliDiagnostic('cliErrorTerminalClosed', 'dsh-auth-remote: terminal input closed')\n await new Promise<void>((resolve) => {\n this.wake = resolve\n })\n }\n const char = this.pending.shift()!\n if (this.skipLf) {\n this.skipLf = false\n if (char === '\\n') return this.take()\n }\n return char\n }\n\n async ask(label: string, secret = false, maxCharacters = 256): Promise<string> {\n if (this.closed)\n throw new CliDiagnostic('cliErrorTerminalClosed', 'dsh-auth-remote: terminal input closed')\n this.output.write(label)\n const answer: string[] = []\n let escape = false\n for (;;) {\n const char = await this.take()\n if (escape) {\n if (/[A-Za-z~]/u.test(char)) escape = false\n continue\n }\n if (char === '\\u001b') {\n escape = true\n continue\n }\n if (char === '\\u0003')\n throw new CliDiagnostic('cliErrorCancelled', 'dsh-auth-remote: cancelled')\n if (char === '\\u0004')\n throw new CliDiagnostic('cliErrorTerminalClosed', 'dsh-auth-remote: terminal input closed')\n if (char === '\\r' || char === '\\n') {\n if (char === '\\r') this.skipLf = true\n this.output.write('\\n')\n return answer.join('')\n }\n if (char === '\\u007f' || char === '\\b') {\n if (answer.length > 0) {\n answer.pop()\n if (!secret) this.output.write('\\b \\b')\n }\n continue\n }\n if (/[\\u0000-\\u001f\\u007f]/u.test(char)) continue\n if (answer.length >= maxCharacters) continue\n answer.push(char)\n if (!secret) this.output.write(char)\n }\n }\n\n close(): void {\n if (this.closed) return\n this.closed = true\n this.input.off('data', this.onData)\n this.input.off('end', this.onEnd)\n this.input.setRawMode(this.previousRaw)\n this.input.pause()\n this.wake?.()\n this.wake = undefined\n }\n}\n"],
5
- "mappings": ";;;AACA,SAAS,oBAAoB;;;ACD7B,SAAS,eAAAA,oBAAmB;;;ACA5B,SAAS,cAAAC,mBAAkB;AAC3B,SAAS,aAAAC,kBAAiB;AAC1B,SAAS,SAAAC,QAAO,QAAAC,OAAM,YAAAC,WAAU,QAAQ,UAAAC,eAAc;AACtD,SAAS,QAAAC,aAAY;;;ACHrB,SAAS,kBAAkB;AAC3B,SAAS,iBAAiB;AAC1B,SAAS,OAAO,OAAO,MAAM,UAAU,OAAO,cAAc;AAC5D,SAAS,YAAY;AAEd,IAAM,YAAY;AAClB,IAAM,aAAa;AACnB,IAAM,YAAY;AASzB,SAAS,MAAM,OAAgB,MAAuB;AACpD,SAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,MAAM,SAAS;AAC1F;AAEA,eAAe,kBAAkB,KAAqC;AACpE,MAAI;AACJ,MAAI;AACF,UAAM,MAAM,SAAS,SAAS,GAAG,SAAS,MAAM;AAAA,EAClD,SAAS,OAAO;AACd,QAAI,MAAM,OAAO,QAAQ,EAAG,QAAO;AACnC,UAAM;AAAA,EACR;AACA,QAAM,OAA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AA,CAAI;AAC3D,UAAQ,WAAW;AACrB,CAAC;",
4
+ "sourcesContent": ["#!/usr/bin/env node\nimport { readFileSync } from 'node:fs'\nimport { AuthError, AuthService } from '../auth/service.js'\nimport { PasswordValidationError, validatePassword } from '../auth/password.js'\nimport {\n ADMIN_PROTOCOL_VERSION,\n type AdminRequest,\n type AdminStatus,\n} from '../shared/admin-contract.js'\nimport { AuthStateStore } from '../storage/store.js'\nimport { AdminOutcomeUnknown, AdminRejected, AdminUnavailable, requestAdmin } from './ipc-client.js'\nimport { CliDiagnostic, cliText, environmentLocale, parseLanguage } from './language.js'\nimport { resolveProfileTarget, type ProfileTarget } from './profile.js'\nimport { TerminalPrompt } from './prompt.js'\nimport type { Locale, MessageKey } from '../shared/i18n.js'\n\nconst manifest = JSON.parse(readFileSync(new URL('../package.json', import.meta.url), 'utf8')) as {\n version: string\n}\n\ntype Command = AdminRequest['command']\nlet currentLocale = environmentLocale(process.env)\nconst output = (key: MessageKey, params: Record<string, string | number> = {}): string =>\n cliText(currentLocale, key, params)\n\nfunction authErrorKey(code: string): MessageKey {\n switch (code) {\n case 'already_initialized':\n return 'cliErrorAlreadyInitialized'\n case 'invalid_input':\n return 'cliErrorInvalidInput'\n case 'invalid_credentials':\n return 'cliErrorInvalidCredentials'\n case 'invalid_factor':\n return 'cliErrorInvalidFactor'\n case 'uninitialized':\n return 'cliErrorUninitialized'\n case 'totp_required':\n return 'cliErrorTotpRequired'\n case 'conflict':\n return 'cliErrorConflict'\n case 'busy':\n return 'cliErrorBusy'\n default:\n return 'cliErrorUnknown'\n }\n}\n\nfunction errorText(error: unknown, locale: Locale): string {\n if (error instanceof CliDiagnostic) return cliText(error.locale ?? locale, error.key)\n if (error instanceof PasswordValidationError) return cliText(locale, 'cliErrorPasswordLength')\n if (error instanceof AdminOutcomeUnknown) return cliText(locale, 'cliErrorOutcomeUnknown')\n if (error instanceof AdminUnavailable) return cliText(locale, 'cliErrorManagementUnavailable')\n if (error instanceof AdminRejected || error instanceof AuthError) {\n if (error.code === 'rate_limited')\n return cliText(locale, 'errorRateLimited', {\n seconds: error instanceof AuthError ? (error.retryAfter ?? 1) : 1,\n })\n return cliText(locale, authErrorKey(error.code))\n }\n return cliText(locale, 'cliErrorUnknown')\n}\n\nasync function offline(\n target: ProfileTarget,\n request: AdminRequest,\n): Promise<AdminStatus | { ok: true }> {\n let store: AuthStateStore\n try {\n store = await AuthStateStore.open(target.dir)\n } catch (error) {\n if (error instanceof Error && /state lock held|state lock is held/u.test(error.message))\n throw new CliDiagnostic(\n 'cliErrorOfflineLock',\n 'dsh-auth-remote: management socket is unavailable while the service holds the profile lock; refusing offline access',\n )\n throw error\n }\n const auth = new AuthService(store, { requireTotp: false, sessionHours: 168 })\n try {\n switch (request.command) {\n case 'status':\n return { ...auth.status(), online: false, ready: false }\n case 'init':\n await auth.initialize(request.username, request.password)\n return { ok: true }\n case 'reset-password':\n await auth.resetPassword(request.password)\n return { ok: true }\n case 'reset-totp':\n await auth.resetTotp()\n return { ok: true }\n case 'revoke-sessions':\n await auth.revokeAll()\n return { ok: true }\n }\n } finally {\n auth.dispose()\n await store.close()\n }\n}\n\nasync function execute(\n target: ProfileTarget,\n request: AdminRequest,\n): Promise<AdminStatus | { ok: true }> {\n try {\n return await requestAdmin(target.socketPath, request)\n } catch (error) {\n if (!(error instanceof AdminUnavailable)) throw error\n return offline(target, request)\n }\n}\n\nasync function interactiveRequest(\n target: ProfileTarget,\n command: Exclude<Command, 'status'>,\n): Promise<AdminRequest> {\n const prompt = new TerminalPrompt()\n try {\n if (command === 'init') {\n const username = await prompt.ask(output('cliPromptUsername'), false, 64)\n const password = await prompt.ask(output('cliPromptPassword'), true, 256)\n const again = await prompt.ask(output('cliPromptPasswordAgain'), true, 256)\n if (password !== again)\n throw new CliDiagnostic(\n 'cliErrorPasswordsMismatch',\n 'dsh-auth-remote: passwords do not match',\n )\n validatePassword(password)\n return { version: ADMIN_PROTOCOL_VERSION, command, username, password }\n }\n const confirmation = await prompt.ask(\n output('cliPromptConfirmTarget', { profile: target.name, command }),\n false,\n 64,\n )\n if (confirmation !== target.name)\n throw new CliDiagnostic(\n 'cliErrorConfirmationMismatch',\n 'dsh-auth-remote: confirmation did not match the target profile',\n )\n if (command === 'reset-password') {\n const password = await prompt.ask(output('cliPromptNewPassword'), true, 256)\n const again = await prompt.ask(output('cliPromptNewPasswordAgain'), true, 256)\n if (password !== again)\n throw new CliDiagnostic(\n 'cliErrorPasswordsMismatch',\n 'dsh-auth-remote: passwords do not match',\n )\n validatePassword(password)\n return { version: ADMIN_PROTOCOL_VERSION, command, password }\n }\n return { version: ADMIN_PROTOCOL_VERSION, command }\n } finally {\n prompt.close()\n }\n}\n\nasync function main(): Promise<void> {\n const parsed = parseLanguage(process.argv.slice(2))\n currentLocale = parsed.locale\n const args = parsed.args\n if (args.length === 0 || (args.length === 1 && ['--help', '-h'].includes(args[0]!))) {\n process.stdout.write(output('cliHelp', { version: manifest.version }))\n return\n }\n if (args.length === 1 && ['--version', '-v'].includes(args[0]!)) {\n process.stdout.write(`${manifest.version}\\n`)\n return\n }\n const command = args[0]\n if (\n !['init', 'status', 'reset-password', 'reset-totp', 'revoke-sessions'].includes(\n command ?? '',\n ) ||\n (command === 'status'\n ? args.length > 2 || (args.length === 2 && args[1] !== '--json')\n : args.length !== 1)\n )\n throw new CliDiagnostic(\n 'cliErrorInvalidArguments',\n 'dsh-auth-remote: invalid command or arguments; use --help',\n )\n const target = await resolveProfileTarget()\n if (command !== 'status')\n process.stdout.write(\n `${output('cliTargetProfile', { profile: target.name })}\\n${output('cliDataFile', { path: target.statePath })}\\n`,\n )\n const request: AdminRequest =\n command === 'status'\n ? { version: ADMIN_PROTOCOL_VERSION, command: 'status' }\n : await interactiveRequest(target, command as Exclude<Command, 'status'>)\n const result = await execute(target, request)\n if (command === 'status') {\n const status = result as AdminStatus\n if (args[1] === '--json')\n process.stdout.write(\n `${JSON.stringify({ profile: target.name, statePath: target.statePath, ...status })}\\n`,\n )\n else\n process.stdout.write(\n [\n output('cliStatusProfile', { profile: target.name }),\n output('cliDataFile', { path: target.statePath }),\n output('cliStatusAccount', {\n state: output(status.initialized ? 'cliInitialized' : 'cliNotInitialized'),\n }),\n output('cliStatusTotp', {\n state: output(status.totpEnabled ? 'cliTotpEnabled' : 'cliTotpDisabled'),\n }),\n output('cliStatusSessions', { count: status.activeSessions }),\n output('cliStatusService', {\n state: output(\n status.online\n ? status.ready\n ? 'cliOnlineReady'\n : 'cliOnlineNotReady'\n : 'cliOffline',\n ),\n }),\n ].join('\\n') + '\\n',\n )\n return\n }\n process.stdout.write(`${output('cliCompleted', { command: command! })}\\n`)\n}\n\nvoid main().catch((error: unknown) => {\n process.stderr.write(`${errorText(error, currentLocale)}\\n`)\n process.exitCode = 1\n})\n", "import { randomBytes } from 'node:crypto'\nimport type { AuthState, AccountRecord, SessionRecord } from '../storage/state.js'\nimport { AuthStateStore } from '../storage/store.js'\nimport {\n DUMMY_PASSWORD_RECORD,\n hashPassword,\n validatePassword,\n verifyPassword,\n} from './password.js'\nimport { isActiveSession, issueSession, sessionFor, sessionHash } from './sessions.js'\nimport { backupCodeHash, generateBackupCodes, generateTotpSecret, matchedTotpStep } from './totp.js'\n\nexport interface AuthPolicy {\n requireTotp: boolean\n sessionHours: number\n}\n\nexport type AuthErrorCode =\n | 'invalid_input'\n | 'uninitialized'\n | 'already_initialized'\n | 'invalid_credentials'\n | 'invalid_factor'\n | 'invalid_challenge'\n | 'challenge_expired'\n | 'unauthorized'\n | 'rate_limited'\n | 'busy'\n | 'conflict'\n | 'totp_required'\n\nexport class AuthError extends Error {\n constructor(\n readonly code: AuthErrorCode,\n readonly retryAfter?: number,\n ) {\n super(`auth-remote: ${code}`)\n }\n}\n\ninterface BaseChallenge {\n id: string\n accountId: string\n securityVersion: number\n expiresAt: number\n failures: number\n busy: boolean\n}\n\ninterface MfaChallenge extends BaseChallenge {\n kind: 'mfa'\n}\n\ninterface BindingChallenge extends BaseChallenge {\n kind: 'binding'\n secret: string\n originSessionHash: string | null\n}\n\ntype Challenge = MfaChallenge | BindingChallenge\n\nexport type LoginResult =\n | { kind: 'session'; token: string; expiresAt: number }\n | { kind: 'mfa'; challenge: string; expiresAt: number }\n | { kind: 'binding'; challenge: string; secret: string; expiresAt: number }\n\nexport interface AuthServiceOptions {\n now?: () => number\n}\n\nconst LOGIN_CHALLENGE_MS = 5 * 60_000\nconst BINDING_CHALLENGE_MS = 10 * 60_000\nconst RATE_WINDOW_MS = 60_000\nconst MAX_ATTEMPTS = 10\nconst MAX_CHALLENGES = 32\n\nfunction validatePolicy(policy: AuthPolicy, now: number): void {\n if (\n typeof policy.requireTotp !== 'boolean' ||\n !Number.isSafeInteger(policy.sessionHours) ||\n policy.sessionHours < 1 ||\n !Number.isSafeInteger(now + policy.sessionHours * 3_600_000)\n )\n throw new AuthError('invalid_input')\n}\n\nfunction validUsername(username: unknown): username is string {\n return (\n typeof username === 'string' &&\n username.length > 0 &&\n [...username].length <= 64 &&\n !/[\\u0000-\\u001f\\u007f]/u.test(username)\n )\n}\n\nexport class AuthService {\n private readonly now: () => number\n private readonly challenges = new Map<string, Challenge>()\n private readonly attempts: number[] = []\n private activeDerivations = 0\n private policyChanging = false\n private readonly unsubscribe: () => void\n\n constructor(\n private readonly store: AuthStateStore,\n private policy: AuthPolicy,\n options: AuthServiceOptions = {},\n ) {\n this.now = options.now ?? Date.now\n validatePolicy(policy, this.now())\n this.unsubscribe = store.subscribe((previous, current) => {\n if (previous.account?.securityVersion !== current.account?.securityVersion) {\n this.challenges.clear()\n return\n }\n for (const [id, challenge] of this.challenges) {\n if (\n challenge.kind === 'binding' &&\n challenge.originSessionHash &&\n previous.sessions[challenge.originSessionHash] &&\n !current.sessions[challenge.originSessionHash]\n )\n this.challenges.delete(id)\n }\n })\n }\n\n dispose(): void {\n this.unsubscribe()\n this.challenges.clear()\n }\n\n status(): { initialized: boolean; totpEnabled: boolean; activeSessions: number } {\n const state = this.store.current()\n const now = this.now()\n return {\n initialized: state.account !== null,\n totpEnabled: state.account?.totp !== null && state.account?.totp !== undefined,\n activeSessions: Object.values(state.sessions).filter((session) =>\n isActiveSession(state, session, now, this.policy.requireTotp),\n ).length,\n }\n }\n\n session(token: string): SessionRecord | null {\n return sessionFor(this.store.current(), token, this.now(), this.policy.requireTotp)\n }\n\n policySnapshot(): AuthPolicy {\n return { ...this.policy }\n }\n\n me(token: string): {\n username: string\n totpEnabled: boolean\n createdAt: number\n expiresAt: number\n activeSessions: number\n } {\n const state = this.store.current()\n const now = this.now()\n const session = sessionFor(state, token, now, this.policy.requireTotp)\n if (!session || !state.account) throw new AuthError('unauthorized')\n return {\n username: state.account.username,\n totpEnabled: state.account.totp !== null,\n createdAt: session.createdAt,\n expiresAt: session.expiresAt,\n activeSessions: Object.values(state.sessions).filter((entry) =>\n isActiveSession(state, entry, now, this.policy.requireTotp),\n ).length,\n }\n }\n\n bindingDetails(id: string): { secret: string; expiresAt: number } {\n const challenge = this.challenges.get(id)\n if (!challenge || challenge.kind !== 'binding') throw new AuthError('invalid_challenge')\n if (challenge.expiresAt <= this.now()) {\n this.challenges.delete(id)\n throw new AuthError('challenge_expired')\n }\n const state = this.store.current()\n this.sameAccount(state, challenge.accountId, challenge.securityVersion)\n if (challenge.originSessionHash) {\n const session = state.sessions[challenge.originSessionHash]\n if (!session || session.expiresAt <= this.now()) throw new AuthError('unauthorized')\n }\n return { secret: challenge.secret, expiresAt: challenge.expiresAt }\n }\n\n pendingChallenges(): number {\n this.expireChallenges()\n return this.challenges.size\n }\n\n private occupyAttempt(): void {\n const now = this.now()\n while (this.attempts.length > 0 && this.attempts[0]! <= now - RATE_WINDOW_MS)\n this.attempts.shift()\n if (this.attempts.length >= MAX_ATTEMPTS)\n throw new AuthError(\n 'rate_limited',\n Math.ceil((this.attempts[0]! + RATE_WINDOW_MS - now) / 1000),\n )\n this.attempts.push(now)\n }\n\n private async derive<T>(run: () => Promise<T>): Promise<T> {\n if (this.activeDerivations >= 2) throw new AuthError('busy')\n this.activeDerivations++\n try {\n return await run()\n } finally {\n this.activeDerivations--\n }\n }\n\n private expireChallenges(): void {\n const now = this.now()\n for (const [id, challenge] of this.challenges)\n if (challenge.expiresAt <= now) this.challenges.delete(id)\n }\n\n private createChallenge(\n kind: 'mfa' | 'binding',\n account: AccountRecord,\n originSessionHash: string | null = null,\n ): LoginResult {\n this.expireChallenges()\n if (this.challenges.size >= MAX_CHALLENGES) throw new AuthError('busy')\n const id = randomBytes(32).toString('base64url')\n const expiresAt = this.now() + (kind === 'mfa' ? LOGIN_CHALLENGE_MS : BINDING_CHALLENGE_MS)\n const base = {\n id,\n accountId: account.id,\n securityVersion: account.securityVersion,\n expiresAt,\n failures: 0,\n busy: false,\n }\n if (kind === 'mfa') {\n this.challenges.set(id, { ...base, kind })\n return { kind, challenge: id, expiresAt }\n }\n const secret = generateTotpSecret()\n this.challenges.set(id, { ...base, kind, secret, originSessionHash })\n return { kind, challenge: id, secret, expiresAt }\n }\n\n private claim(id: string, kind: Challenge['kind']): Challenge {\n const challenge = this.challenges.get(id)\n if (!challenge || challenge.kind !== kind) throw new AuthError('invalid_challenge')\n if (challenge.expiresAt <= this.now()) {\n this.challenges.delete(id)\n throw new AuthError('challenge_expired')\n }\n if (challenge.busy || challenge.failures >= 5) throw new AuthError('invalid_challenge')\n challenge.busy = true\n return challenge\n }\n\n private failedChallenge(challenge: Challenge): void {\n challenge.failures++\n if (challenge.failures >= 5) this.challenges.delete(challenge.id)\n }\n\n private sameAccount(state: AuthState, accountId: string, securityVersion: number): AccountRecord {\n const account = state.account\n if (!account || account.id !== accountId || account.securityVersion !== securityVersion)\n throw new AuthError('conflict')\n return account\n }\n\n private requireSession(state: AuthState, token: string): AccountRecord {\n if (!sessionFor(state, token, this.now(), this.policy.requireTotp))\n throw new AuthError('unauthorized')\n return state.account!\n }\n\n private verifyFactor(account: AccountRecord, code: string | undefined): boolean {\n const factor = account.totp\n if (!factor) return true\n if (!code) return false\n const step = matchedTotpStep(factor.secret, code, this.now(), factor.lastUsedStep)\n if (step !== null) {\n factor.lastUsedStep = step\n return true\n }\n const hash = backupCodeHash(code)\n if (!hash) return false\n const index = factor.backupCodeHashes.indexOf(hash)\n if (index < 0) return false\n factor.backupCodeHashes.splice(index, 1)\n return true\n }\n\n async initialize(username: string, password: string): Promise<void> {\n if (!validUsername(username)) throw new AuthError('invalid_input')\n validatePassword(password)\n if (this.store.current().account) throw new AuthError('already_initialized')\n const record = await this.derive(() => hashPassword(password))\n await this.store.transact((draft) => {\n if (draft.account) throw new AuthError('already_initialized')\n draft.account = {\n id: randomBytes(16).toString('hex'),\n username,\n password: record,\n totp: null,\n securityVersion: 1,\n }\n })\n }\n\n async login(username: string, password: string): Promise<LoginResult> {\n this.occupyAttempt()\n if (!validUsername(username) || typeof password !== 'string' || password.length > 1024)\n throw new AuthError('invalid_credentials')\n const snapshot = this.store.current()\n const account = snapshot.account\n if (!account) throw new AuthError('uninitialized')\n const match = await this.derive(() =>\n verifyPassword(\n password,\n username === account.username ? account.password : DUMMY_PASSWORD_RECORD,\n ),\n )\n if (!match || username !== account.username) throw new AuthError('invalid_credentials')\n const current = this.store.current()\n const latest = this.sameAccount(current, account.id, account.securityVersion)\n if (latest.totp) return this.createChallenge('mfa', latest)\n if (this.policy.requireTotp) return this.createChallenge('binding', latest)\n const issued = await this.store.transact((draft) => {\n this.sameAccount(draft, account.id, account.securityVersion)\n if (draft.account!.totp || this.policy.requireTotp) throw new AuthError('conflict')\n return issueSession(draft, this.now(), this.policy.sessionHours)\n })\n return { kind: 'session', ...issued }\n }\n\n async verifyMfa(id: string, code: string): Promise<{ token: string; expiresAt: number }> {\n this.occupyAttempt()\n const challenge = this.claim(id, 'mfa') as MfaChallenge\n try {\n const issued = await this.store.transact((draft) => {\n if (challenge.expiresAt <= this.now()) throw new AuthError('challenge_expired')\n const account = this.sameAccount(draft, challenge.accountId, challenge.securityVersion)\n if (!account.totp || !this.verifyFactor(account, code))\n throw new AuthError('invalid_factor')\n return issueSession(draft, this.now(), this.policy.sessionHours)\n })\n this.challenges.delete(id)\n return issued\n } catch (error) {\n if (error instanceof AuthError && error.code === 'invalid_factor')\n this.failedChallenge(challenge)\n throw error\n } finally {\n challenge.busy = false\n }\n }\n\n async startBinding(\n token: string,\n password: string,\n currentCode?: string,\n ): Promise<Extract<LoginResult, { kind: 'binding' }>> {\n this.occupyAttempt()\n const snapshot = this.store.current()\n const account = this.requireSession(snapshot, token)\n if (typeof password !== 'string' || password.length > 1024)\n throw new AuthError('invalid_credentials')\n const match = await this.derive(() => verifyPassword(password, account.password))\n if (!match) throw new AuthError('invalid_credentials')\n if (account.totp) {\n await this.store.transact((draft) => {\n this.requireSession(draft, token)\n this.sameAccount(draft, account.id, account.securityVersion)\n if (!this.verifyFactor(draft.account!, currentCode)) throw new AuthError('invalid_factor')\n })\n } else {\n const latest = this.store.current()\n this.requireSession(latest, token)\n this.sameAccount(latest, account.id, account.securityVersion)\n }\n return this.createChallenge('binding', account, sessionHash(token)) as Extract<\n LoginResult,\n { kind: 'binding' }\n >\n }\n\n async confirmBinding(id: string, code: string): Promise<{ backupCodes: string[] }> {\n this.occupyAttempt()\n const challenge = this.claim(id, 'binding') as BindingChallenge\n try {\n const step = matchedTotpStep(challenge.secret, code, this.now(), null)\n if (step === null) {\n this.failedChallenge(challenge)\n throw new AuthError('invalid_factor')\n }\n const backups = generateBackupCodes()\n await this.store.transact((draft) => {\n if (challenge.expiresAt <= this.now()) throw new AuthError('challenge_expired')\n const account = this.sameAccount(draft, challenge.accountId, challenge.securityVersion)\n const originSession = challenge.originSessionHash\n ? draft.sessions[challenge.originSessionHash]\n : null\n if (\n challenge.originSessionHash &&\n (!originSession || originSession.expiresAt <= this.now())\n )\n throw new AuthError('unauthorized')\n account.totp = {\n secret: challenge.secret,\n lastUsedStep: step,\n backupCodeHashes: backups.hashes,\n }\n account.securityVersion++\n draft.sessions = {}\n })\n this.challenges.clear()\n return { backupCodes: backups.codes }\n } finally {\n challenge.busy = false\n }\n }\n\n async changePassword(\n token: string,\n currentPassword: string,\n currentCode: string | undefined,\n newPassword: string,\n ): Promise<void> {\n this.occupyAttempt()\n validatePassword(newPassword)\n if (typeof currentPassword !== 'string' || currentPassword.length > 1024)\n throw new AuthError('invalid_credentials')\n const snapshot = this.store.current()\n const account = this.requireSession(snapshot, token)\n const match = await this.derive(() => verifyPassword(currentPassword, account.password))\n if (!match) throw new AuthError('invalid_credentials')\n const replacement = await this.derive(() => hashPassword(newPassword))\n await this.store.transact((draft) => {\n this.requireSession(draft, token)\n const current = this.sameAccount(draft, account.id, account.securityVersion)\n if (!this.verifyFactor(current, currentCode)) throw new AuthError('invalid_factor')\n current.password = replacement\n current.securityVersion++\n draft.sessions = {}\n })\n }\n\n async disableTotp(token: string, password: string, currentCode: string): Promise<void> {\n this.occupyAttempt()\n if (this.policy.requireTotp) throw new AuthError('totp_required')\n if (typeof password !== 'string' || password.length > 1024)\n throw new AuthError('invalid_credentials')\n const snapshot = this.store.current()\n const account = this.requireSession(snapshot, token)\n const match = await this.derive(() => verifyPassword(password, account.password))\n if (!match) throw new AuthError('invalid_credentials')\n await this.store.transact((draft) => {\n this.requireSession(draft, token)\n const current = this.sameAccount(draft, account.id, account.securityVersion)\n if (!current.totp || !this.verifyFactor(current, currentCode))\n throw new AuthError('invalid_factor')\n current.totp = null\n current.securityVersion++\n draft.sessions = {}\n })\n }\n\n async revokeWithCredentials(\n token: string,\n password: string,\n currentCode?: string,\n ): Promise<void> {\n this.occupyAttempt()\n if (typeof password !== 'string' || password.length > 1024)\n throw new AuthError('invalid_credentials')\n const snapshot = this.store.current()\n const account = this.requireSession(snapshot, token)\n const match = await this.derive(() => verifyPassword(password, account.password))\n if (!match) throw new AuthError('invalid_credentials')\n await this.store.transact((draft) => {\n this.requireSession(draft, token)\n const current = this.sameAccount(draft, account.id, account.securityVersion)\n if (!this.verifyFactor(current, currentCode)) throw new AuthError('invalid_factor')\n current.securityVersion++\n draft.sessions = {}\n })\n }\n\n async logout(token: string): Promise<void> {\n if (typeof token !== 'string' || !/^[A-Za-z0-9_-]{43}$/u.test(token)) return\n const hash = sessionHash(token)\n if (!this.store.current().sessions[hash]) return\n await this.store.transact((draft) => {\n delete draft.sessions[hash]\n })\n }\n\n async resetPassword(newPassword: string): Promise<void> {\n validatePassword(newPassword)\n const replacement = await this.derive(() => hashPassword(newPassword))\n await this.store.transact((draft) => {\n if (!draft.account) throw new AuthError('uninitialized')\n draft.account.password = replacement\n draft.account.securityVersion++\n draft.sessions = {}\n })\n }\n\n async resetTotp(): Promise<void> {\n await this.store.transact((draft) => {\n if (!draft.account) throw new AuthError('uninitialized')\n draft.account.totp = null\n draft.account.securityVersion++\n draft.sessions = {}\n })\n }\n\n async revokeAll(): Promise<void> {\n await this.store.transact((draft) => {\n if (!draft.account) throw new AuthError('uninitialized')\n draft.account.securityVersion++\n draft.sessions = {}\n })\n }\n\n async applyPolicy(next: AuthPolicy): Promise<void> {\n validatePolicy(next, this.now())\n if (this.policyChanging) throw new AuthError('busy')\n if (\n next.requireTotp === this.policy.requireTotp &&\n next.sessionHours === this.policy.sessionHours\n )\n return\n this.policyChanging = true\n const previous = this.policy\n this.policy = next // fail closed while the policy commit is pending\n try {\n await this.store.transact((draft) => {\n if (next.requireTotp && !previous.requireTotp && draft.account && !draft.account.totp) {\n draft.account.securityVersion++\n draft.sessions = {}\n }\n if (next.sessionHours < previous.sessionHours) {\n for (const session of Object.values(draft.sessions))\n session.expiresAt = Math.min(\n session.expiresAt,\n session.createdAt + next.sessionHours * 3_600_000,\n )\n }\n })\n this.challenges.clear()\n } catch (error) {\n if (this.store.healthy()) this.policy = previous\n throw error\n } finally {\n this.policyChanging = false\n }\n }\n\n /** Startup/re-activation must persist tightening before the guarded listener opens. */\n async enforceCurrentPolicy(): Promise<void> {\n const state = this.store.current()\n const revokeUnbound =\n this.policy.requireTotp && !state.account?.totp && Object.keys(state.sessions).length > 0\n const shorten = Object.values(state.sessions).some(\n (session) => session.expiresAt > session.createdAt + this.policy.sessionHours * 3_600_000,\n )\n if (!revokeUnbound && !shorten) return\n await this.store.transact((draft) => {\n if (this.policy.requireTotp && draft.account && !draft.account.totp) {\n draft.account.securityVersion++\n draft.sessions = {}\n }\n for (const session of Object.values(draft.sessions))\n session.expiresAt = Math.min(\n session.expiresAt,\n session.createdAt + this.policy.sessionHours * 3_600_000,\n )\n })\n }\n}\n", "import { randomUUID } from 'node:crypto'\nimport { constants } from 'node:fs'\nimport { lstat, open, readFile, rename, unlink } from 'node:fs/promises'\nimport { join } from 'node:path'\nimport { assertPrivateStateFile, STATE_FILE, StateLock } from './lock.js'\nimport { emptyState, validateState, type AuthState } from './state.js'\n\nexport type CommitStage =\n | 'afterTempWrite'\n | 'afterFileSync'\n | 'beforeRename'\n | 'afterRename'\n | 'afterDirSync'\n | 'beforeSuccess'\n\nexport interface StoreOptions {\n /** A failed notification makes the store unavailable before a caller can report success. */\n onCommitted?: (previous: AuthState, current: AuthState) => void | Promise<void>\n onUnavailable?: (reason: Error) => void\n /** Fault injection for isolated tests only. */\n onStage?: (stage: CommitStage) => void | Promise<void>\n}\n\nfunction errno(error: unknown, code: string): boolean {\n return typeof error === 'object' && error !== null && 'code' in error && error.code === code\n}\n\n/** One process owns the lock; every mutation serializes through this instance. */\nexport class AuthStateStore {\n readonly path: string\n private state: AuthState\n private queue: Promise<void> = Promise.resolve()\n private unavailableReason: Error | null = null\n private closed = false\n private readonly listeners = new Set<\n (previous: AuthState, current: AuthState) => void | Promise<void>\n >()\n\n private constructor(\n private readonly lock: StateLock,\n state: AuthState,\n private readonly options: StoreOptions,\n ) {\n this.path = join(lock.dir, STATE_FILE)\n this.state = state\n }\n\n static async open(profileDir: string, options: StoreOptions = {}): Promise<AuthStateStore> {\n const lock = await StateLock.acquire(profileDir)\n try {\n const path = join(lock.dir, STATE_FILE)\n let state = emptyState()\n try {\n await assertPrivateStateFile(path)\n const info = await lstat(path)\n if (info.size > 16 * 1024 * 1024)\n throw new Error('auth-remote: state file exceeds the supported size')\n state = validateState(JSON.parse(await readFile(path, 'utf8')))\n } catch (error) {\n if (!errno(error, 'ENOENT')) throw error\n }\n return new AuthStateStore(lock, state, options)\n } catch (error) {\n await lock.release()\n throw error\n }\n }\n\n healthy(): boolean {\n return !this.closed && this.unavailableReason === null\n }\n\n current(): AuthState {\n if (!this.healthy()) throw this.unavailableReason ?? new Error('auth-remote: store is closed')\n return structuredClone(this.state)\n }\n\n /** Notifications finish before transact reports success; a failed listener closes admission. */\n subscribe(\n listener: (previous: AuthState, current: AuthState) => void | Promise<void>,\n ): () => void {\n if (!this.healthy()) throw this.unavailableReason ?? new Error('auth-remote: store is closed')\n this.listeners.add(listener)\n return () => this.listeners.delete(listener)\n }\n\n async transact<T>(mutate: (draft: AuthState) => T | Promise<T>): Promise<T> {\n const run = async (): Promise<T> => {\n if (!this.healthy()) throw this.unavailableReason ?? new Error('auth-remote: store is closed')\n const draft = structuredClone(this.state)\n const result = await mutate(draft)\n if (this.state.revision >= Number.MAX_SAFE_INTEGER)\n throw new Error('auth-remote: state revision exhausted')\n draft.revision = this.state.revision + 1\n const next = validateState(draft)\n await this.persist(next)\n return result\n }\n const operation = this.queue.then(run)\n this.queue = operation.then(\n () => undefined,\n () => undefined,\n )\n return operation\n }\n\n private async persist(next: AuthState): Promise<void> {\n const temp = `${this.path}.tmp-${process.pid}-${randomUUID()}`\n const bytes = Buffer.from(`${JSON.stringify(next)}\\n`, 'utf8')\n if (bytes.length > 16 * 1024 * 1024)\n throw new Error('auth-remote: state file exceeds the supported size')\n let renamed = false\n let file: Awaited<ReturnType<typeof open>> | undefined\n try {\n file = await open(\n temp,\n constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | constants.O_NOFOLLOW,\n 0o600,\n )\n await file.writeFile(bytes)\n await this.options.onStage?.('afterTempWrite')\n await file.sync()\n await this.options.onStage?.('afterFileSync')\n await file.close()\n file = undefined\n await this.options.onStage?.('beforeRename')\n await rename(temp, this.path)\n renamed = true\n await this.options.onStage?.('afterRename')\n const parent = await open(this.lock.dir, constants.O_RDONLY | constants.O_DIRECTORY)\n try {\n await parent.sync()\n } finally {\n await parent.close()\n }\n await this.options.onStage?.('afterDirSync')\n const previous = this.state\n this.state = next\n await this.options.onCommitted?.(structuredClone(previous), structuredClone(next))\n for (const listener of this.listeners)\n await listener(structuredClone(previous), structuredClone(next))\n await this.options.onStage?.('beforeSuccess')\n } catch (error) {\n if (renamed) {\n this.unavailableReason = new Error('auth-remote: state commit outcome is uncertain', {\n cause: error,\n })\n this.options.onUnavailable?.(this.unavailableReason)\n }\n throw error\n } finally {\n await file?.close().catch(() => undefined)\n if (!renamed) await unlink(temp).catch(() => undefined)\n }\n }\n\n async close(): Promise<void> {\n if (this.closed) return\n this.closed = true\n await this.queue\n await this.lock.release()\n }\n}\n", "import { randomUUID } from 'node:crypto'\nimport { constants } from 'node:fs'\nimport { lstat, mkdir, open, readFile, rmdir, unlink } from 'node:fs/promises'\nimport { join } from 'node:path'\n\nexport const STATE_DIR = 'auth-remote'\nexport const STATE_FILE = 'auth-state.json'\nexport const LOCK_FILE = 'auth-state.lock'\n\ninterface Owner {\n pid: number\n bootId: string\n startTicks: string\n nonce: string\n}\n\nfunction errno(error: unknown, code: string): boolean {\n return typeof error === 'object' && error !== null && 'code' in error && error.code === code\n}\n\nasync function processStartTicks(pid: number): Promise<string | null> {\n let raw: string\n try {\n raw = await readFile(`/proc/${pid}/stat`, 'utf8')\n } catch (error) {\n if (errno(error, 'ENOENT')) return null\n throw error\n }\n const tail = raw\n .slice(raw.lastIndexOf(')') + 1)\n .trim()\n .split(/\\s+/u)\n const ticks = tail[19]\n if (!ticks || !/^\\d+$/u.test(ticks)) throw new Error('auth-remote: cannot verify lock owner')\n return ticks\n}\n\nasync function localOwner(): Promise<Owner> {\n const [bootId, startTicks] = await Promise.all([\n readFile('/proc/sys/kernel/random/boot_id', 'utf8'),\n processStartTicks(process.pid),\n ])\n if (!startTicks) throw new Error('auth-remote: cannot verify own process identity')\n return { pid: process.pid, bootId: bootId.trim(), startTicks, nonce: randomUUID() }\n}\n\nfunction parseOwner(raw: string): Owner {\n let value: unknown\n try {\n value = JSON.parse(raw)\n } catch {\n throw new Error('auth-remote: lock owner is unreadable; manual recovery required')\n }\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new Error('auth-remote: lock owner is invalid; manual recovery required')\n const owner = value as Record<string, unknown>\n if (\n !Number.isSafeInteger(owner.pid) ||\n (owner.pid as number) <= 0 ||\n typeof owner.bootId !== 'string' ||\n !/^[0-9a-f-]{36}$/u.test(owner.bootId) ||\n typeof owner.startTicks !== 'string' ||\n !/^\\d+$/u.test(owner.startTicks) ||\n typeof owner.nonce !== 'string' ||\n !/^[0-9a-f-]{36}$/u.test(owner.nonce)\n )\n throw new Error('auth-remote: lock owner is invalid; manual recovery required')\n return owner as unknown as Owner\n}\n\nasync function isDead(owner: Owner, currentBootId: string): Promise<boolean> {\n if (owner.bootId !== currentBootId) return true\n const ticks = await processStartTicks(owner.pid)\n return ticks === null || ticks !== owner.startTicks\n}\n\nasync function assertPrivate(path: string, kind: 'directory' | 'file'): Promise<void> {\n const info = await lstat(path)\n if (\n (kind === 'directory' ? !info.isDirectory() : !info.isFile()) ||\n info.uid !== process.getuid?.() ||\n (info.mode & 0o777) !== (kind === 'directory' ? 0o700 : 0o600)\n )\n throw new Error(`auth-remote: unsafe ${kind} permissions or owner: ${path}`)\n}\n\nexport async function ensureStateDirectory(profileDir: string): Promise<string> {\n if (process.platform !== 'linux') throw new Error('auth-remote: storage requires Linux /proc')\n const dir = join(profileDir, STATE_DIR)\n let created = false\n try {\n await mkdir(dir, { mode: 0o700 })\n created = true\n } catch (error) {\n if (!errno(error, 'EEXIST')) throw error\n }\n await assertPrivate(dir, 'directory')\n if (created) {\n const parent = await open(profileDir, constants.O_RDONLY | constants.O_DIRECTORY)\n try {\n await parent.sync()\n } finally {\n await parent.close()\n }\n }\n return dir\n}\n\n/** Lock recovery uses a second exclusive directory, so reclaimers cannot erase one another's new lock. */\nexport class StateLock {\n private released = false\n\n private constructor(\n readonly dir: string,\n readonly path: string,\n private readonly owner: Owner,\n ) {}\n\n static async acquire(profileDir: string): Promise<StateLock> {\n const dir = await ensureStateDirectory(profileDir)\n const path = join(dir, LOCK_FILE)\n const owner = await localOwner()\n for (let attempt = 0; attempt < 2; attempt++) {\n try {\n const file = await open(\n path,\n constants.O_CREAT | constants.O_EXCL | constants.O_WRONLY | constants.O_NOFOLLOW,\n 0o600,\n )\n try {\n await file.writeFile(JSON.stringify(owner))\n await file.sync()\n } catch (error) {\n await file.close()\n await unlink(path).catch(() => undefined)\n throw error\n }\n await file.close()\n return new StateLock(dir, path, owner)\n } catch (error) {\n if (!errno(error, 'EEXIST')) throw error\n if (attempt === 1) throw new Error('auth-remote: state lock is held or contested')\n await this.recoverStale(dir, path, owner.bootId)\n }\n }\n throw new Error('auth-remote: state lock acquisition failed')\n }\n\n private static async recoverStale(\n dir: string,\n path: string,\n currentBootId: string,\n ): Promise<void> {\n const recovery = `${path}.recovery`\n try {\n await mkdir(recovery, { mode: 0o700 })\n } catch (error) {\n if (errno(error, 'EEXIST'))\n throw new Error(\n 'auth-remote: lock recovery is already active or abandoned; manual review required',\n )\n throw error\n }\n try {\n let info\n try {\n info = await lstat(path)\n } catch (error) {\n if (errno(error, 'ENOENT')) return\n throw error\n }\n await assertPrivate(path, 'file')\n const old = parseOwner(await readFile(path, 'utf8'))\n if (!(await isDead(old, currentBootId)))\n throw new Error(`auth-remote: state lock held by live process ${old.pid}`)\n const latest = await lstat(path)\n if (latest.ino !== info.ino || latest.dev !== info.dev)\n throw new Error('auth-remote: state lock changed during recovery')\n await unlink(path)\n const parent = await open(dir, constants.O_RDONLY | constants.O_DIRECTORY)\n try {\n await parent.sync()\n } finally {\n await parent.close()\n }\n } finally {\n await rmdir(recovery)\n }\n }\n\n async release(): Promise<void> {\n if (this.released) return\n const current = parseOwner(await readFile(this.path, 'utf8'))\n if (current.nonce !== this.owner.nonce)\n throw new Error('auth-remote: state lock ownership changed before release')\n await unlink(this.path)\n this.released = true\n }\n}\n\nexport async function assertPrivateStateFile(path: string): Promise<void> {\n await assertPrivate(path, 'file')\n}\n", "/** The only persisted representation of account and full-session state. */\nexport const STATE_SCHEMA_VERSION = 1\n\nexport interface PasswordRecord {\n salt: string\n hash: string\n}\n\nexport interface TotpRecord {\n secret: string\n lastUsedStep: number | null\n backupCodeHashes: string[]\n}\n\nexport interface AccountRecord {\n id: string\n username: string\n password: PasswordRecord\n totp: TotpRecord | null\n securityVersion: number\n}\n\nexport interface SessionRecord {\n accountId: string\n securityVersion: number\n createdAt: number\n expiresAt: number\n}\n\nexport interface AuthState {\n schemaVersion: typeof STATE_SCHEMA_VERSION\n revision: number\n account: AccountRecord | null\n /** Keys are SHA-256 token hashes, never bearer tokens. */\n sessions: Record<string, SessionRecord>\n}\n\nexport function emptyState(): AuthState {\n return { schemaVersion: STATE_SCHEMA_VERSION, revision: 0, account: null, sessions: {} }\n}\n\nfunction record(value: unknown, keys: string[], label: string): Record<string, unknown> {\n if (typeof value !== 'object' || value === null || Array.isArray(value))\n throw new Error(`auth-remote: invalid ${label}`)\n const entries = Object.keys(value)\n if (entries.length !== keys.length || entries.some((key) => !keys.includes(key)))\n throw new Error(`auth-remote: invalid ${label} fields`)\n return value as Record<string, unknown>\n}\n\nfunction integer(value: unknown, label: string, min = 0): number {\n if (!Number.isSafeInteger(value) || (value as number) < min)\n throw new Error(`auth-remote: invalid ${label}`)\n return value as number\n}\n\nfunction nonempty(value: unknown, label: string): string {\n if (typeof value !== 'string' || value.length === 0)\n throw new Error(`auth-remote: invalid ${label}`)\n return value\n}\n\nfunction hex(value: unknown, bytes: number, label: string): string {\n if (typeof value !== 'string' || !new RegExp(`^[a-f0-9]{${bytes * 2}}$`, 'u').test(value))\n throw new Error(`auth-remote: invalid ${label}`)\n return value\n}\n\nfunction digest(value: unknown, label: string): string {\n if (typeof value !== 'string' || !/^[a-f0-9]{64}$/u.test(value))\n throw new Error(`auth-remote: invalid ${label}`)\n return value\n}\n\nexport function validateState(value: unknown): AuthState {\n const state = record(value, ['schemaVersion', 'revision', 'account', 'sessions'], 'state')\n if (state.schemaVersion !== STATE_SCHEMA_VERSION)\n throw new Error(`auth-remote: unsupported state schema version ${String(state.schemaVersion)}`)\n const revision = integer(state.revision, 'revision')\n let account: AccountRecord | null = null\n if (state.account !== null) {\n const entry = record(\n state.account,\n ['id', 'username', 'password', 'totp', 'securityVersion'],\n 'account',\n )\n const password = record(entry.password, ['salt', 'hash'], 'password record')\n let totp: TotpRecord | null = null\n if (entry.totp !== null) {\n const factor = record(\n entry.totp,\n ['secret', 'lastUsedStep', 'backupCodeHashes'],\n 'TOTP record',\n )\n if (!Array.isArray(factor.backupCodeHashes) || factor.backupCodeHashes.length > 10)\n throw new Error('auth-remote: invalid backup code hashes')\n if (typeof factor.secret !== 'string' || !/^[A-Z2-7]{32}$/u.test(factor.secret))\n throw new Error('auth-remote: invalid TOTP secret')\n totp = {\n secret: factor.secret,\n lastUsedStep:\n factor.lastUsedStep === null ? null : integer(factor.lastUsedStep, 'TOTP step'),\n backupCodeHashes: factor.backupCodeHashes.map((hash) => digest(hash, 'backup code hash')),\n }\n if (new Set(totp.backupCodeHashes).size !== totp.backupCodeHashes.length)\n throw new Error('auth-remote: duplicate backup code hash')\n }\n const username = nonempty(entry.username, 'username')\n if ([...username].length > 64 || /[\\u0000-\\u001f\\u007f]/u.test(username))\n throw new Error('auth-remote: invalid username')\n account = {\n id: hex(entry.id, 16, 'account id'),\n username,\n password: {\n salt: hex(password.salt, 32, 'password salt'),\n hash: hex(password.hash, 64, 'password hash'),\n },\n totp,\n securityVersion: integer(entry.securityVersion, 'security version', 1),\n }\n }\n const sessions = state.sessions\n if (typeof sessions !== 'object' || sessions === null || Array.isArray(sessions))\n throw new Error('auth-remote: invalid sessions')\n const validatedSessions: Record<string, SessionRecord> = Object.create(null)\n for (const [hash, value] of Object.entries(sessions)) {\n digest(hash, 'session token hash')\n const session = record(\n value,\n ['accountId', 'securityVersion', 'createdAt', 'expiresAt'],\n 'session',\n )\n const createdAt = integer(session.createdAt, 'session creation')\n const expiresAt = integer(session.expiresAt, 'session expiry')\n if (!account || session.accountId !== account.id || expiresAt <= createdAt)\n throw new Error('auth-remote: invalid session account or lifetime')\n validatedSessions[hash] = {\n accountId: account.id,\n securityVersion: integer(session.securityVersion, 'session security version', 1),\n createdAt,\n expiresAt,\n }\n }\n return { schemaVersion: STATE_SCHEMA_VERSION, revision, account, sessions: validatedSessions }\n}\n", "import { randomBytes, scrypt as scryptCallback, timingSafeEqual } from 'node:crypto'\nimport type { PasswordRecord } from '../storage/state.js'\n\nexport const PASSWORD_MIN_CHARACTERS = 12\nexport const PASSWORD_MAX_CHARACTERS = 256\n\nexport class PasswordValidationError extends Error {\n constructor() {\n super('auth-remote: password must contain 12\u2013256 Unicode characters')\n }\n}\n\nexport function validatePassword(password: unknown): asserts password is string {\n if (\n typeof password !== 'string' ||\n [...password].length < PASSWORD_MIN_CHARACTERS ||\n [...password].length > PASSWORD_MAX_CHARACTERS\n )\n throw new PasswordValidationError()\n}\n\nasync function derive(password: string, salt: string): Promise<Buffer> {\n return new Promise<Buffer>((resolve, reject) => {\n scryptCallback(\n password,\n Buffer.from(salt, 'hex'),\n 64,\n { N: 16_384, r: 8, p: 1, maxmem: 32 * 1024 * 1024 },\n (error, key) => (error ? reject(error) : resolve(key)),\n )\n })\n}\n\nexport async function hashPassword(password: string): Promise<PasswordRecord> {\n validatePassword(password)\n const salt = randomBytes(32).toString('hex')\n return { salt, hash: (await derive(password, salt)).toString('hex') }\n}\n\nexport async function verifyPassword(password: string, record: PasswordRecord): Promise<boolean> {\n const derived = await derive(password, record.salt)\n return timingSafeEqual(derived, Buffer.from(record.hash, 'hex'))\n}\n\n/** Wrong usernames still perform a comparable derivation. */\nexport const DUMMY_PASSWORD_RECORD: PasswordRecord = {\n salt: '0'.repeat(64),\n hash: '0'.repeat(128),\n}\n", "import { createHash, randomBytes } from 'node:crypto'\nimport type { AuthState, SessionRecord } from '../storage/state.js'\n\nexport function sessionHash(token: string): string {\n return createHash('sha256').update(token).digest('hex')\n}\n\nexport function issueSession(\n draft: AuthState,\n now: number,\n sessionHours: number,\n): { token: string; expiresAt: number } {\n const account = draft.account\n if (!account) throw new Error('auth-remote: cannot issue a session without an account')\n const expiresAt = now + sessionHours * 3_600_000\n if (!Number.isSafeInteger(expiresAt)) throw new Error('auth-remote: session expiry overflow')\n const token = randomBytes(32).toString('base64url')\n draft.sessions[sessionHash(token)] = {\n accountId: account.id,\n securityVersion: account.securityVersion,\n createdAt: now,\n expiresAt,\n }\n return { token, expiresAt }\n}\n\nexport function sessionFor(\n state: AuthState,\n token: string,\n now: number,\n requireTotp: boolean,\n): SessionRecord | null {\n if (typeof token !== 'string' || !/^[A-Za-z0-9_-]{43}$/u.test(token)) return null\n const session = state.sessions[sessionHash(token)]\n return session && isActiveSession(state, session, now, requireTotp) ? session : null\n}\n\n/** Shared admission predicate for authentication and the account overview. */\nexport function isActiveSession(\n state: AuthState,\n session: SessionRecord,\n now: number,\n requireTotp: boolean,\n): boolean {\n const account = state.account\n return !!(\n account &&\n session.accountId === account.id &&\n session.securityVersion === account.securityVersion &&\n session.expiresAt > now &&\n (!requireTotp || account.totp)\n )\n}\n", "import { createHash, createHmac, randomBytes, timingSafeEqual } from 'node:crypto'\n\nconst alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ234567'\nexport const TOTP_PERIOD_MS = 30_000\n\nfunction base32(bytes: Buffer): string {\n let bits = 0\n let value = 0\n let output = ''\n for (const byte of bytes) {\n value = (value << 8) | byte\n bits += 8\n while (bits >= 5) {\n output += alphabet[(value >>> (bits - 5)) & 31]\n bits -= 5\n }\n }\n if (bits > 0) output += alphabet[(value << (5 - bits)) & 31]\n return output\n}\n\nfunction fromBase32(value: string): Buffer {\n let bits = 0\n let accum = 0\n const output: number[] = []\n for (const char of value) {\n const digit = alphabet.indexOf(char)\n if (digit < 0) throw new Error('auth-remote: invalid TOTP secret')\n accum = (accum << 5) | digit\n bits += 5\n if (bits >= 8) {\n output.push((accum >>> (bits - 8)) & 255)\n bits -= 8\n }\n }\n return Buffer.from(output)\n}\n\nexport function generateTotpSecret(): string {\n return base32(randomBytes(20))\n}\n\nexport function totpCode(secret: string, step: number): string {\n if (!Number.isSafeInteger(step) || step < 0) throw new Error('auth-remote: invalid TOTP step')\n const counter = Buffer.alloc(8)\n counter.writeBigUInt64BE(BigInt(step))\n const mac = createHmac('sha1', fromBase32(secret)).update(counter).digest()\n const offset = mac[mac.length - 1]! & 15\n const value = (mac.readUInt32BE(offset) & 0x7fff_ffff) % 1_000_000\n return String(value).padStart(6, '0')\n}\n\nexport function matchedTotpStep(\n secret: string,\n code: string,\n timestamp: number,\n lastUsedStep: number | null,\n): number | null {\n if (typeof code !== 'string' || !/^\\d{6}$/u.test(code)) return null\n const current = Math.floor(timestamp / TOTP_PERIOD_MS)\n for (const step of [current - 1, current, current + 1]) {\n if (step < 0 || (lastUsedStep !== null && step <= lastUsedStep)) continue\n if (timingSafeEqual(Buffer.from(totpCode(secret, step)), Buffer.from(code))) return step\n }\n return null\n}\n\nexport function backupCodeHash(code: string): string | null {\n if (typeof code !== 'string') return null\n const canonical = code.replaceAll('-', '').toUpperCase()\n if (!/^[A-Z2-7]{20}$/u.test(canonical)) return null\n return createHash('sha256').update(`auth-remote-backup:${canonical}`).digest('hex')\n}\n\nexport function generateBackupCodes(): { codes: string[]; hashes: string[] } {\n const codes = Array.from({ length: 10 }, () =>\n base32(randomBytes(12))\n .match(/.{1,5}/gu)!\n .join('-'),\n )\n return { codes, hashes: codes.map((code) => backupCodeHash(code)!) }\n}\n", "export const ADMIN_PROTOCOL_VERSION = 1\nexport const ADMIN_MAX_BYTES = 16 * 1024\n\nexport type AdminRequest =\n | { version: 1; command: 'status' }\n | { version: 1; command: 'init'; username: string; password: string }\n | { version: 1; command: 'reset-password'; password: string }\n | { version: 1; command: 'reset-totp' }\n | { version: 1; command: 'revoke-sessions' }\n\nexport interface AdminStatus {\n initialized: boolean\n totpEnabled: boolean\n activeSessions: number\n online: boolean\n ready: boolean\n}\n\nexport type AdminResponse =\n | { version: 1; ok: true; result: AdminStatus | { ok: true } }\n | { version: 1; ok: false; error: string }\n", "import { lstat } from 'node:fs/promises'\nimport { connect, type Socket } from 'node:net'\nimport { dirname } from 'node:path'\nimport {\n ADMIN_MAX_BYTES,\n ADMIN_PROTOCOL_VERSION,\n type AdminRequest,\n type AdminResponse,\n} from '../shared/admin-contract.js'\nimport { CliDiagnostic } from './language.js'\n\ntype AdminResult = Extract<AdminResponse, { ok: true }>['result']\n\nexport class AdminUnavailable extends Error {\n constructor() {\n super('dsh-auth-remote: management socket is unavailable')\n }\n}\n\nexport class AdminOutcomeUnknown extends Error {\n constructor() {\n super('dsh-auth-remote: management request disconnected or timed out; result is unknown')\n }\n}\n\nexport class AdminRejected extends Error {\n constructor(readonly code: string) {\n super(`dsh-auth-remote: ${code}`)\n }\n}\n\nfunction errno(error: unknown, code: string): boolean {\n return typeof error === 'object' && error !== null && 'code' in error && error.code === code\n}\n\nasync function inspectSocket(path: string): Promise<boolean> {\n let directory\n try {\n directory = await lstat(dirname(path))\n } catch (error) {\n if (errno(error, 'ENOENT')) return false\n throw error\n }\n if (\n !directory.isDirectory() ||\n directory.uid !== process.getuid?.() ||\n (directory.mode & 0o777) !== 0o700\n )\n throw new CliDiagnostic(\n 'cliErrorUnsafeManagementDirectory',\n 'dsh-auth-remote: unsafe management directory',\n )\n let socket\n try {\n socket = await lstat(path)\n } catch (error) {\n if (errno(error, 'ENOENT')) return false\n throw error\n }\n if (!socket.isSocket() || socket.uid !== process.getuid?.() || (socket.mode & 0o777) !== 0o600)\n throw new CliDiagnostic(\n 'cliErrorUnsafeManagementSocket',\n 'dsh-auth-remote: unsafe management socket',\n )\n return true\n}\n\n/** Only pre-connect absence may fall back to the offline state lock. */\nexport async function requestAdmin(path: string, request: AdminRequest): Promise<AdminResult> {\n if (!(await inspectSocket(path))) throw new AdminUnavailable()\n let socket: Socket\n try {\n socket = await new Promise<Socket>((resolve, reject) => {\n const candidate = connect(path)\n candidate.setTimeout(2_000, () => {\n candidate.destroy()\n reject(new AdminUnavailable())\n })\n candidate.once('connect', () => {\n candidate.setTimeout(0)\n resolve(candidate)\n })\n candidate.once('error', reject)\n })\n } catch (error) {\n if (errno(error, 'ENOENT') || errno(error, 'ECONNREFUSED')) throw new AdminUnavailable()\n throw error\n }\n try {\n return await new Promise<AdminResult>((resolve, reject) => {\n let bytes = 0\n const chunks: Buffer[] = []\n let settled = false\n const fail = (error: Error) => {\n if (settled) return\n settled = true\n reject(error)\n socket.destroy()\n }\n socket.setTimeout(30_000, () => fail(new AdminOutcomeUnknown()))\n socket.on('error', () => fail(new AdminOutcomeUnknown()))\n socket.on('end', () => {\n if (!settled) fail(new AdminOutcomeUnknown())\n })\n socket.on('data', (chunk: Buffer) => {\n if (settled) return\n bytes += chunk.length\n if (bytes > ADMIN_MAX_BYTES) return fail(new AdminOutcomeUnknown())\n chunks.push(chunk)\n const data = Buffer.concat(chunks)\n const newline = data.indexOf(10)\n if (newline < 0) return\n if (newline !== data.length - 1) return fail(new AdminOutcomeUnknown())\n let response: unknown\n try {\n response = JSON.parse(data.subarray(0, newline).toString('utf8'))\n } catch {\n return fail(new AdminOutcomeUnknown())\n }\n if (\n typeof response !== 'object' ||\n response === null ||\n !('version' in response) ||\n response.version !== ADMIN_PROTOCOL_VERSION ||\n !('ok' in response) ||\n typeof response.ok !== 'boolean'\n )\n return fail(new AdminOutcomeUnknown())\n const reply = response as AdminResponse\n settled = true\n socket.end()\n if (reply.ok) resolve(reply.result)\n else reject(new AdminRejected(reply.error))\n })\n socket.write(`${JSON.stringify(request)}\\n`)\n })\n } finally {\n socket.destroy()\n }\n}\n", "/** Human-facing text only. Protocol identifiers and command names stay unchanged. */\nexport const en = {\n errorNetwork: 'Connection failed. Check your network and try again.',\n errorRateLimited: 'Too many attempts. Try again in about {seconds} seconds.',\n errorUnauthorized: 'Your session has expired. Sign in again.',\n errorServiceUnavailable: 'The service is temporarily unavailable. Try again later.',\n errorGeneric: 'The operation could not be completed. Try again.',\n\n accountLoginDisabled:\n 'Manual account sign-in is disabled. Refresh this page to use the native sign-in entry.',\n settingsLoginConfiguration: 'Sign-in preferences',\n settingsManualDescription: 'Authorize in a new tab, then paste the callback address.',\n settingsManualAccountLogin: 'Remote DeepSeek account sign-in',\n settingsManualConfigUnavailable: 'Sign-in preferences are temporarily unavailable.',\n settingsManualUnavailable: 'Manual account sign-in is unavailable in this DSH environment.',\n settingsManualSaveFailed:\n 'Could not save this preference. Check the current value and try again.',\n settingsSaving: 'Saving\u2026',\n settingsRetry: 'Retry',\n\n accountLoginTitle: 'Sign in to DeepSeek',\n accountLoginStepOpen: 'Sign in to DeepSeek in a new tab.',\n accountLoginStepCopy: 'Copy the full address after authorization and paste it here.',\n accountLoginCallbackLabel: 'Full callback address',\n accountLoginCallbackHint:\n 'A connection error or 404 after authorization is expected. Copy the full address.',\n accountLoginOpen: 'Open sign-in page',\n accountLoginConfirm: 'Confirm sign-in',\n accountLoginCancel: 'Cancel',\n accountLoginUseApiKey: 'Use API key',\n accountLoginClose: 'Close',\n accountLoginRetry: 'Start again',\n accountLoginReopen: 'Reopen authorization page',\n accountLoginPopupBlocked: 'The new tab was blocked.',\n accountLoginInitializing: 'Preparing authorization\u2026',\n accountLoginWaiting: 'Authorization lasts at most 10 minutes.',\n accountLoginExchanging: 'Completing sign-in\u2026',\n accountLoginInvalidCallback:\n 'This callback address does not match the current authorization. Copy the full address, including code and state, from the latest authorization tab.',\n accountLoginExpired: 'This authorization has expired. Start again.',\n accountLoginMismatch:\n 'This authorization is no longer available in this session. Close this dialog and start again.',\n accountLoginBusy:\n 'Another authorization is in progress. Finish or cancel it before starting again.',\n accountLoginUnavailable: 'This DSH version does not provide compatible account sign-in.',\n accountLoginFailed:\n 'Authorization could not be completed. Start again and submit the address from the new tab.',\n accountLoginNoResponse:\n 'The DeepSeek platform did not respond. Check the DSH server\u2019s network connection and start again.',\n\n loginInitialTitle: 'Sign in',\n loginInitialLoading: 'Checking sign-in status\u2026',\n loginLanguageLabel: 'Language',\n loginSetupTitle: 'Set up your account first',\n loginSetupDescription:\n 'Run this command in a terminal on the server running DSH, then create a username and password when prompted. The web page cannot create the account.',\n loginSetupCopy: 'Copy command',\n loginSetupRecheck: 'I finished setup',\n loginSetupCopied: 'Command copied.',\n loginSetupCopyFallback: 'Select and copy the command manually.',\n loginSetupNotFound:\n 'No account was found. Check that the command used this profile, then try again.',\n loginTitle: 'Sign in',\n loginUsername: 'Username',\n loginPassword: 'Password',\n loginContinue: 'Continue',\n loginMfaTitle: 'Verify your second factor',\n loginMfaDescription:\n 'Enter the six-digit code from your authenticator or a one-time backup code. This challenge expires in five minutes.',\n loginMfaCode: 'Verification or backup code',\n loginMfaSubmit: 'Verify and sign in',\n loginBackToPassword: 'Back to password sign-in',\n loginMfaExhausted: 'This challenge is exhausted. Enter your password again.',\n loginBindingTitle: 'Connect an authenticator',\n loginBindingDescription:\n 'Scan the QR code with your authenticator, or enter the secret below. After confirmation, ten one-time backup codes will appear and you will need to sign in again.',\n loginBindingQrAlt: 'Authenticator setup QR code',\n loginBindingManualSecret: 'Manual secret',\n loginBindingCode: 'Six-digit code from the authenticator',\n loginBindingConfirm: 'Confirm setup',\n loginBindingRestart: 'Sign in again',\n loginBindingQrUnavailable: 'The QR code is unavailable. Use the manual secret above.',\n loginBindingExhausted: 'This setup challenge is exhausted. Enter your password again.',\n loginBackupTitle: 'Save your backup codes',\n loginBackupDescription:\n 'These codes are shown only once. Store them safely; each code can be used only once. Sign in again after saving them.',\n loginBackupSaved: 'I saved them; sign in again',\n loginOptionalTitle: 'Protect your account',\n loginOptionalDescription:\n 'This profile lets you connect an authenticator later. Connecting one now adds protection; you can also do it in Security settings.',\n loginOptionalBindNow: 'Connect TOTP now',\n loginOptionalSkip: 'Skip and enter DSH',\n loginOptionalVerifyTitle: 'Verify again before setup',\n loginOptionalVerifyDescription: 'Enter your current password to protect your account.',\n loginOptionalCurrentPassword: 'Current password',\n loginOptionalStart: 'Start setup',\n loginOptionalSkipLater: 'Connect later and enter DSH',\n loginReasonExpired: 'Your session has expired. Sign in again.',\n loginReasonUpdated: 'Security settings changed. Sign in again.',\n loginReasonSignedOut: 'You signed out of this session.',\n loginUnavailableTitle: 'Sign-in is temporarily unavailable',\n loginUnavailableDescription: 'The service status is unavailable. Check the connection and retry.',\n loginRetry: 'Check again',\n loginErrorInvalidCredentials: 'The username or password is incorrect. Try again.',\n loginErrorInvalidFactor:\n 'The verification or backup code is incorrect. After five failed attempts, you must enter your password again.',\n loginErrorChallenge: 'This verification expired. Enter your username and password again.',\n loginErrorUninitialized:\n 'The account is not set up. Run the setup command in the server terminal.',\n\n settingsClose: 'Close',\n settingsCancel: 'Cancel',\n settingsOverview: 'Account overview',\n settingsUsername: 'DSH sign-in username',\n settingsCreatedAt: 'Signed in at',\n settingsExpiresAt: 'Session expires at',\n settingsActiveSessions: 'Active sessions',\n settingsTotpRequired: 'TOTP is required by configuration and cannot be turned off.',\n settingsPasswordTitle: 'Password',\n settingsSignOutCurrentDescription: 'Sign out this session? Other sessions will stay signed in.',\n\n settingsSectionLabel: 'Security & sign-in',\n settingsSectionAria: 'Security & sign-in settings',\n settingsTitle: 'Security & sign-in',\n settingsAccountSummary: 'Account: {username} \u00B7 TOTP: {totp}',\n settingsTotpEnabled: 'Enabled',\n settingsTotpNotBound: 'Not connected',\n settingsLoading: 'Loading account status\u2026',\n settingsChangePassword: 'Change password',\n settingsBindTotp: 'Turn on TOTP',\n settingsRebindTotp: 'Reconnect TOTP',\n settingsSessions: 'Session management',\n settingsPasswordMismatch: 'The new passwords do not match.',\n settingsPasswordDescription: 'After this change, every device must sign in again.',\n settingsCurrentPassword: 'Current password',\n settingsCurrentCode: 'Current verification or backup code',\n settingsNewPassword: 'New password',\n settingsConfirmPassword: 'Confirm new password',\n settingsSavePassword: 'Save new password',\n settingsBindDescription:\n 'Enter your current credentials. After connecting the new authenticator, every device must sign in again.',\n settingsStartBinding: 'Start setup',\n settingsDisableTotp: 'Turn off TOTP',\n settingsDisableDescription: 'After turning off TOTP, every device must sign in again.',\n settingsScanQr: 'Scan the QR code',\n settingsQrAlt: 'Authenticator setup QR code',\n settingsQrUnavailable: 'The QR code is unavailable. Use the manual secret below.',\n settingsQrLoading: 'Generating the QR code; you can use the manual secret below.',\n settingsManualSecret: 'Manual secret:',\n settingsNewCode: 'Six-digit code from the new authenticator',\n settingsConfirmBinding: 'Confirm setup',\n settingsRestartBinding: 'Start over',\n settingsSignOutCurrent: 'Sign out this session',\n settingsSignOutAll: 'Sign out all sessions',\n settingsSignOutAllDescription:\n 'Enter your current credentials. All sessions, including this one, and open connections will be revoked.',\n settingsOldBackupInvalid: 'Your previous backup codes no longer work.',\n settingsCopyAll: 'Copy all',\n settingsBackupCopied: 'Backup codes copied.',\n settingsBackupCopyFailed: 'Could not copy. Select the codes and copy them manually.',\n\n settingsBackupTitle: 'Save your backup codes',\n settingsBackupDescription:\n 'These codes are shown only once. Store them safely; each code can be used only once.',\n settingsBackupSaved: 'I saved them; sign in again',\n settingsErrorInvalidCredentials: 'The current password is incorrect.',\n settingsErrorInvalidFactor: 'The current verification or backup code is incorrect.',\n settingsErrorInvalidInput: 'The input is invalid. Passwords must meet the server length rules.',\n settingsErrorChallenge: 'The setup challenge expired. Start setup again.',\n settingsErrorTotpRequired: 'This profile requires TOTP, so it cannot be turned off.',\n\n cliHelp: `dsh-auth-remote {version}\n\nUsage:\n dsh plugin --profile web exec dsh-auth-remote [--lang en|zh] COMMAND\n\nCommands:\n init Create the single account interactively\n status [--json] Show non-sensitive authentication status\n reset-password Reset the password and revoke all sessions\n reset-totp Clear TOTP, backup codes and all sessions\n revoke-sessions Sign out every device\n\nOptions:\n --lang en|zh Choose the language for human-readable output\n --help, -h Show this help\n --version, -v Show the package version\n\nThe command uses the profile selected by dsh plugin exec and the caller's DSH_HOME.\n`,\n cliPromptUsername: 'Username: ',\n cliPromptPassword: 'Password: ',\n cliPromptPasswordAgain: 'Enter password again: ',\n cliPromptNewPassword: 'New password: ',\n cliPromptNewPasswordAgain: 'Enter new password again: ',\n cliPromptConfirmTarget: 'Enter {profile} to confirm {command}: ',\n cliTargetProfile: 'Target profile: {profile}',\n cliDataFile: 'State file: {path}',\n cliStatusProfile: 'Profile: {profile}',\n cliStatusAccount: 'Account: {state}',\n cliStatusTotp: 'TOTP: {state}',\n cliStatusSessions: 'Active sessions: {count}',\n cliStatusService: 'Service: {state}',\n cliInitialized: 'Initialized',\n cliNotInitialized: 'Not initialized',\n cliTotpEnabled: 'Enabled',\n cliTotpDisabled: 'Disabled',\n cliOnlineReady: 'Online and ready',\n cliOnlineNotReady: 'Online but not ready',\n cliOffline: 'Offline',\n cliCompleted: '{command} completed; the change is durable and effective.',\n cliErrorInvalidArguments: 'Invalid command or arguments. Use --help.',\n cliErrorInvalidLanguage: 'Invalid --lang value. Use en or zh.',\n cliErrorDuplicateLanguage: 'Specify --lang only once.',\n cliErrorMissingLanguage: 'Missing value for --lang. Use en or zh.',\n cliErrorPasswordsMismatch: 'The passwords do not match.',\n cliErrorConfirmationMismatch: 'The confirmation did not match the target profile.',\n cliErrorPasswordLength: 'Password must contain 12\u2013256 Unicode characters.',\n cliErrorTerminalRequired: 'An interactive terminal is required.',\n cliErrorTerminalClosed: 'Terminal input closed.',\n cliErrorCancelled: 'Cancelled.',\n cliErrorProfileDirectory: 'The current directory is not the selected DSH profile under DSH_HOME.',\n cliErrorProfileManifest: 'The profile package.json is missing.',\n cliErrorUnsafeManagementDirectory: 'The management directory has unsafe permissions.',\n cliErrorUnsafeManagementSocket: 'The management socket has unsafe permissions.',\n cliErrorManagementUnavailable: 'The management socket is unavailable.',\n cliErrorOutcomeUnknown:\n 'The management request disconnected or timed out. Its result is unknown; check status before trying again.',\n cliErrorOfflineLock:\n 'The management socket is unavailable while the service holds the profile lock. Offline access was refused.',\n cliErrorInvalidCredentials: 'The current credentials are incorrect.',\n cliErrorAlreadyInitialized: 'The account is already initialized.',\n cliErrorInvalidInput: 'The input is invalid.',\n cliErrorInvalidFactor: 'The verification or backup code is incorrect.',\n cliErrorUninitialized: 'The account is not initialized.',\n cliErrorTotpRequired: 'This profile requires TOTP.',\n cliErrorConflict: 'The account state changed. Check status and retry.',\n cliErrorBusy: 'The service is busy. Try again later.',\n cliErrorUnknown: 'The operation failed. Check status before trying again.',\n} as const\n", "import type { en } from './en.js'\n\nexport const zh = {\n errorNetwork: '\u8FDE\u63A5\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\u91CD\u8BD5\u3002',\n errorRateLimited: '\u5C1D\u8BD5\u8FC7\u4E8E\u9891\u7E41\uFF0C\u8BF7\u7EA6 {seconds} \u79D2\u540E\u91CD\u8BD5\u3002',\n errorUnauthorized: '\u4F1A\u8BDD\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002',\n errorServiceUnavailable: '\u670D\u52A1\u6682\u65F6\u4E0D\u53EF\u7528\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002',\n errorGeneric: '\u64CD\u4F5C\u672A\u5B8C\u6210\uFF0C\u8BF7\u91CD\u8BD5\u3002',\n\n accountLoginDisabled: '\u624B\u52A8\u8D26\u53F7\u767B\u5F55\u5DF2\u5173\u95ED\u3002\u8BF7\u5237\u65B0\u9875\u9762\uFF0C\u4F7F\u7528\u539F\u751F\u767B\u5F55\u5165\u53E3\u3002',\n settingsLoginConfiguration: '\u767B\u5F55\u914D\u7F6E',\n settingsManualDescription: '\u5728\u65B0\u6807\u7B7E\u9875\u6388\u6743\u540E\uFF0C\u7C98\u8D34\u56DE\u8C03\u5730\u5740\u767B\u5F55\u3002',\n settingsManualAccountLogin: '\u8FDC\u7A0B DeepSeek \u8D26\u53F7\u767B\u5F55',\n settingsManualConfigUnavailable: '\u767B\u5F55\u914D\u7F6E\u6682\u65F6\u4E0D\u53EF\u7528\u3002',\n settingsManualUnavailable: '\u5F53\u524D DSH \u73AF\u5883\u4E0D\u652F\u6301\u624B\u52A8\u8D26\u53F7\u767B\u5F55\u3002',\n settingsManualSaveFailed: '\u914D\u7F6E\u4FDD\u5B58\u5931\u8D25\u3002\u8BF7\u68C0\u67E5\u5F53\u524D\u503C\u540E\u91CD\u8BD5\u3002',\n settingsSaving: '\u6B63\u5728\u4FDD\u5B58\u2026',\n settingsRetry: '\u91CD\u8BD5',\n\n accountLoginTitle: '\u767B\u5F55 DeepSeek \u8D26\u53F7',\n accountLoginStepOpen: '\u5728\u65B0\u6807\u7B7E\u9875\u5B8C\u6210 DeepSeek \u767B\u5F55\u3002',\n accountLoginStepCopy: '\u590D\u5236\u6388\u6743\u540E\u5730\u5740\u680F\u7684\u5B8C\u6574\u5730\u5740\uFF0C\u8FD4\u56DE\u6B64\u5904\u7C98\u8D34\u3002',\n accountLoginCallbackLabel: '\u5B8C\u6574\u56DE\u8C03\u5730\u5740',\n accountLoginCallbackHint: '\u6388\u6743\u540E\u5373\u4F7F\u9875\u9762\u663E\u793A\u8FDE\u63A5\u5931\u8D25\u6216 404\uFF0C\u4E5F\u53EF\u4EE5\u590D\u5236\u5B8C\u6574\u5730\u5740\u3002',\n accountLoginOpen: '\u6253\u5F00\u767B\u5F55\u9875',\n accountLoginConfirm: '\u786E\u8BA4\u767B\u5F55',\n accountLoginCancel: '\u53D6\u6D88',\n accountLoginUseApiKey: '\u4F7F\u7528 API Key',\n accountLoginClose: '\u5173\u95ED',\n accountLoginRetry: '\u91CD\u65B0\u5F00\u59CB',\n accountLoginReopen: '\u91CD\u65B0\u6253\u5F00\u6388\u6743\u9875',\n accountLoginPopupBlocked: '\u65B0\u6807\u7B7E\u9875\u88AB\u6D4F\u89C8\u5668\u62E6\u622A\u3002',\n accountLoginInitializing: '\u6B63\u5728\u51C6\u5907\u6388\u6743\u2026',\n accountLoginWaiting: '\u6388\u6743\u6709\u6548\u671F\u6700\u957F 10 \u5206\u949F\u3002',\n accountLoginExchanging: '\u6B63\u5728\u5B8C\u6210\u767B\u5F55\u2026',\n accountLoginInvalidCallback:\n '\u56DE\u8C03\u5730\u5740\u4E0E\u5F53\u524D\u6388\u6743\u4E0D\u5339\u914D\uFF0C\u8BF7\u4ECE\u6700\u8FD1\u4E00\u6B21\u6388\u6743\u6807\u7B7E\u9875\u590D\u5236\u5305\u542B code \u548C state \u7684\u5B8C\u6574\u5730\u5740\u3002',\n accountLoginExpired: '\u672C\u6B21\u6388\u6743\u5DF2\u8FC7\u671F\uFF0C\u8BF7\u91CD\u65B0\u5F00\u59CB\u3002',\n accountLoginMismatch: '\u5F53\u524D\u4F1A\u8BDD\u5DF2\u65E0\u6CD5\u7EE7\u7EED\u6B64\u6388\u6743\uFF0C\u8BF7\u5173\u95ED\u5F39\u7A97\u540E\u91CD\u65B0\u5F00\u59CB\u3002',\n accountLoginBusy: '\u5DF2\u6709\u6388\u6743\u6B63\u5728\u8FDB\u884C\uFF0C\u8BF7\u5148\u5B8C\u6210\u6216\u53D6\u6D88\u540E\u518D\u5F00\u59CB\u3002',\n accountLoginUnavailable: '\u5F53\u524D DSH \u7248\u672C\u672A\u63D0\u4F9B\u517C\u5BB9\u7684\u8D26\u53F7\u767B\u5F55\u529F\u80FD\u3002',\n accountLoginFailed: '\u672A\u80FD\u5B8C\u6210\u6388\u6743\uFF0C\u8BF7\u91CD\u65B0\u5F00\u59CB\uFF0C\u5E76\u63D0\u4EA4\u65B0\u6807\u7B7E\u9875\u4E2D\u7684\u56DE\u8C03\u5730\u5740\u3002',\n accountLoginNoResponse: 'DeepSeek \u5E73\u53F0\u672A\u54CD\u5E94\uFF0C\u8BF7\u68C0\u67E5 DSH \u670D\u52A1\u5668\u7684\u7F51\u7EDC\u8FDE\u63A5\u540E\u91CD\u65B0\u5F00\u59CB\u3002',\n\n loginInitialTitle: '\u767B\u5F55',\n loginInitialLoading: '\u6B63\u5728\u68C0\u67E5\u767B\u5F55\u72B6\u6001\u2026',\n loginLanguageLabel: '\u8BED\u8A00',\n loginSetupTitle: '\u5148\u521D\u59CB\u5316\u8D26\u53F7',\n loginSetupDescription:\n '\u8BF7\u5728\u8FD0\u884C DSH \u7684\u670D\u52A1\u5668\u7EC8\u7AEF\u8F93\u5165\u4E0B\u5217\u547D\u4EE4\uFF0C\u7136\u540E\u6309\u63D0\u793A\u521B\u5EFA\u7528\u6237\u540D\u548C\u5BC6\u7801\u3002\u7F51\u9875\u4E0D\u4F1A\u521B\u5EFA\u8D26\u53F7\u3002',\n loginSetupCopy: '\u590D\u5236\u547D\u4EE4',\n loginSetupRecheck: '\u6211\u5DF2\u5B8C\u6210\u521D\u59CB\u5316',\n loginSetupCopied: '\u547D\u4EE4\u5DF2\u590D\u5236\u3002',\n loginSetupCopyFallback: '\u8BF7\u624B\u52A8\u9009\u62E9\u5E76\u590D\u5236\u547D\u4EE4\u3002',\n loginSetupNotFound: '\u5C1A\u672A\u68C0\u6D4B\u5230\u8D26\u53F7\u3002\u8BF7\u786E\u8BA4\u547D\u4EE4\u4F7F\u7528\u4E86\u5F53\u524D profile\uFF0C\u518D\u91CD\u65B0\u68C0\u67E5\u3002',\n loginTitle: '\u767B\u5F55',\n loginUsername: '\u7528\u6237\u540D',\n loginPassword: '\u5BC6\u7801',\n loginContinue: '\u7EE7\u7EED',\n loginMfaTitle: '\u9A8C\u8BC1\u7B2C\u4E8C\u56E0\u7D20',\n loginMfaDescription: '\u8F93\u5165\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u4E2D\u7684 6 \u4F4D\u6570\u5B57\uFF0C\u6216\u8F93\u5165\u4E00\u6B21\u6027\u5907\u7528\u7801\u3002\u6311\u6218 5 \u5206\u949F\u540E\u5931\u6548\u3002',\n loginMfaCode: '\u9A8C\u8BC1\u7801\u6216\u5907\u7528\u7801',\n loginMfaSubmit: '\u9A8C\u8BC1\u5E76\u767B\u5F55',\n loginBackToPassword: '\u8FD4\u56DE\u5BC6\u7801\u767B\u5F55',\n loginMfaExhausted: '\u672C\u6B21\u6311\u6218\u5DF2\u7528\u5C3D\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\u5BC6\u7801\u3002',\n loginBindingTitle: '\u7ED1\u5B9A\u8EAB\u4EFD\u9A8C\u8BC1\u5668',\n loginBindingDescription:\n '\u4F7F\u7528\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u626B\u63CF\u4E8C\u7EF4\u7801\uFF0C\u6216\u624B\u52A8\u8F93\u5165\u4E0B\u65B9\u5BC6\u94A5\u3002\u786E\u8BA4\u6210\u529F\u540E\u5C06\u663E\u793A 10 \u4E2A\u4E00\u6B21\u6027\u5907\u7528\u7801\uFF0C\u5E76\u8981\u6C42\u91CD\u65B0\u767B\u5F55\u3002',\n loginBindingQrAlt: '\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u7ED1\u5B9A\u4E8C\u7EF4\u7801',\n loginBindingManualSecret: '\u624B\u5DE5\u5BC6\u94A5',\n loginBindingCode: '\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u4E2D\u7684 6 \u4F4D\u9A8C\u8BC1\u7801',\n loginBindingConfirm: '\u786E\u8BA4\u7ED1\u5B9A',\n loginBindingRestart: '\u91CD\u65B0\u767B\u5F55',\n loginBindingQrUnavailable: '\u4E8C\u7EF4\u7801\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4F7F\u7528\u4E0A\u65B9\u624B\u5DE5\u5BC6\u94A5\u3002',\n loginBindingExhausted: '\u7ED1\u5B9A\u6311\u6218\u5DF2\u7528\u5C3D\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\u5BC6\u7801\u3002',\n loginBackupTitle: '\u4FDD\u5B58\u5907\u7528\u7801',\n loginBackupDescription:\n '\u8FD9\u4E9B\u5907\u7528\u7801\u53EA\u4F1A\u663E\u793A\u8FD9\u4E00\u6B21\u3002\u8BF7\u5B58\u653E\u5728\u5B89\u5168\u7684\u4F4D\u7F6E\uFF0C\u6BCF\u4E2A\u5907\u7528\u7801\u53EA\u80FD\u4F7F\u7528\u4E00\u6B21\u3002\u4FDD\u5B58\u540E\u91CD\u65B0\u767B\u5F55\u3002',\n loginBackupSaved: '\u6211\u5DF2\u4FDD\u5B58\uFF0C\u91CD\u65B0\u767B\u5F55',\n loginOptionalTitle: '\u4FDD\u62A4\u4F60\u7684\u8D26\u53F7',\n loginOptionalDescription:\n '\u5F53\u524D profile \u5141\u8BB8\u7A0D\u540E\u7ED1\u5B9A\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u3002\u73B0\u5728\u7ED1\u5B9A\u53EF\u4EE5\u589E\u52A0\u4FDD\u62A4\uFF1B\u8DF3\u8FC7\u540E\u4E5F\u53EF\u5728\u5B89\u5168\u8BBE\u7F6E\u4E2D\u7ED1\u5B9A\u3002',\n loginOptionalBindNow: '\u73B0\u5728\u7ED1\u5B9A TOTP',\n loginOptionalSkip: '\u8DF3\u8FC7\uFF0C\u8FDB\u5165 DSH',\n loginOptionalVerifyTitle: '\u518D\u6B21\u9A8C\u8BC1\u540E\u7ED1\u5B9A',\n loginOptionalVerifyDescription: '\u4E3A\u4FDD\u62A4\u8D26\u53F7\uFF0C\u8BF7\u518D\u6B21\u8F93\u5165\u5F53\u524D\u5BC6\u7801\u3002',\n loginOptionalCurrentPassword: '\u5F53\u524D\u5BC6\u7801',\n loginOptionalStart: '\u5F00\u59CB\u7ED1\u5B9A',\n loginOptionalSkipLater: '\u7A0D\u540E\u7ED1\u5B9A\uFF0C\u8FDB\u5165 DSH',\n loginReasonExpired: '\u4F1A\u8BDD\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002',\n loginReasonUpdated: '\u5B89\u5168\u8BBE\u7F6E\u5DF2\u66F4\u65B0\uFF0C\u8BF7\u91CD\u65B0\u767B\u5F55\u3002',\n loginReasonSignedOut: '\u5DF2\u9000\u51FA\u5F53\u524D\u4F1A\u8BDD\u3002',\n loginUnavailableTitle: '\u6682\u65F6\u65E0\u6CD5\u767B\u5F55',\n loginUnavailableDescription: '\u670D\u52A1\u72B6\u6001\u6682\u65F6\u65E0\u6CD5\u53D6\u5F97\uFF0C\u8BF7\u68C0\u67E5\u8FDE\u63A5\u5E76\u91CD\u8BD5\u3002',\n loginRetry: '\u91CD\u65B0\u68C0\u67E5',\n loginErrorInvalidCredentials: '\u7528\u6237\u540D\u6216\u5BC6\u7801\u4E0D\u6B63\u786E\uFF0C\u8BF7\u91CD\u8BD5\u3002',\n loginErrorInvalidFactor: '\u9A8C\u8BC1\u7801\u6216\u5907\u7528\u7801\u4E0D\u6B63\u786E\uFF1B\u8FDE\u7EED\u5931\u8D25 5 \u6B21\u540E\u9700\u91CD\u65B0\u8F93\u5165\u5BC6\u7801\u3002',\n loginErrorChallenge: '\u672C\u6B21\u9A8C\u8BC1\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u8F93\u5165\u7528\u6237\u540D\u548C\u5BC6\u7801\u3002',\n loginErrorUninitialized: '\u8D26\u53F7\u5C1A\u672A\u521D\u59CB\u5316\uFF0C\u8BF7\u5148\u5728\u670D\u52A1\u5668\u7EC8\u7AEF\u8FD0\u884C\u521D\u59CB\u5316\u547D\u4EE4\u3002',\n\n settingsClose: '\u5173\u95ED',\n settingsCancel: '\u53D6\u6D88',\n settingsOverview: '\u8D26\u6237\u6982\u89C8',\n settingsUsername: 'DSH \u767B\u5F55\u7528\u6237\u540D',\n settingsCreatedAt: '\u672C\u6B21\u767B\u5F55\u65F6\u95F4',\n settingsExpiresAt: '\u5F53\u524D\u4F1A\u8BDD\u5230\u671F\u65F6\u95F4',\n settingsActiveSessions: '\u6709\u6548\u4F1A\u8BDD\u6570\u91CF',\n settingsTotpRequired: '\u914D\u7F6E\u8981\u6C42\u5F00\u542F TOTP\uFF0C\u65E0\u6CD5\u5173\u95ED\u3002',\n settingsPasswordTitle: '\u5BC6\u7801',\n settingsSignOutCurrentDescription: '\u786E\u5B9A\u9000\u51FA\u5F53\u524D\u4F1A\u8BDD\uFF1F\u5176\u4ED6\u4F1A\u8BDD\u5C06\u7EE7\u7EED\u4FDD\u6301\u767B\u5F55\u3002',\n\n settingsSectionLabel: '\u5B89\u5168\u4E0E\u767B\u5F55',\n settingsSectionAria: '\u5B89\u5168\u4E0E\u767B\u5F55\u8BBE\u7F6E',\n settingsTitle: '\u5B89\u5168\u4E0E\u767B\u5F55',\n settingsAccountSummary: '\u8D26\u53F7\uFF1A{username} \u00B7 TOTP\uFF1A{totp}',\n settingsTotpEnabled: '\u5DF2\u542F\u7528',\n settingsTotpNotBound: '\u672A\u7ED1\u5B9A',\n settingsLoading: '\u6B63\u5728\u8BFB\u53D6\u8D26\u53F7\u72B6\u6001\u2026',\n settingsChangePassword: '\u4FEE\u6539\u5BC6\u7801',\n settingsBindTotp: '\u5F00\u542F TOTP',\n settingsRebindTotp: '\u91CD\u65B0\u7ED1\u5B9A TOTP',\n settingsSessions: '\u4F1A\u8BDD\u7BA1\u7406',\n settingsPasswordMismatch: '\u4E24\u6B21\u8F93\u5165\u7684\u65B0\u5BC6\u7801\u4E0D\u4E00\u81F4\u3002',\n settingsPasswordDescription: '\u5B8C\u6210\u540E\u6240\u6709\u8BBE\u5907\u90FD\u9700\u8981\u91CD\u65B0\u767B\u5F55\u3002',\n settingsCurrentPassword: '\u5F53\u524D\u5BC6\u7801',\n settingsCurrentCode: '\u5F53\u524D\u9A8C\u8BC1\u7801\u6216\u5907\u7528\u7801',\n settingsNewPassword: '\u65B0\u5BC6\u7801',\n settingsConfirmPassword: '\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801',\n settingsSavePassword: '\u4FDD\u5B58\u65B0\u5BC6\u7801',\n settingsBindDescription: '\u8BF7\u8F93\u5165\u5F53\u524D\u51ED\u8BC1\uFF1B\u65B0\u7ED1\u5B9A\u5B8C\u6210\u540E\u6240\u6709\u8BBE\u5907\u90FD\u9700\u8981\u91CD\u65B0\u767B\u5F55\u3002',\n settingsStartBinding: '\u5F00\u59CB\u7ED1\u5B9A',\n settingsDisableTotp: '\u5173\u95ED TOTP',\n settingsDisableDescription: '\u5173\u95ED\u540E\u6240\u6709\u8BBE\u5907\u90FD\u9700\u8981\u91CD\u65B0\u767B\u5F55\u3002',\n settingsScanQr: '\u626B\u63CF\u4E8C\u7EF4\u7801',\n settingsQrAlt: '\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u7ED1\u5B9A\u4E8C\u7EF4\u7801',\n settingsQrUnavailable: '\u4E8C\u7EF4\u7801\u6682\u4E0D\u53EF\u7528\uFF0C\u8BF7\u4F7F\u7528\u4E0B\u65B9\u624B\u5DE5\u5BC6\u94A5\u3002',\n settingsQrLoading: '\u4E8C\u7EF4\u7801\u751F\u6210\u4E2D\uFF1B\u4E5F\u53EF\u4EE5\u4F7F\u7528\u4E0B\u65B9\u624B\u5DE5\u5BC6\u94A5\u3002',\n settingsManualSecret: '\u624B\u5DE5\u5BC6\u94A5\uFF1A',\n settingsNewCode: '\u65B0\u8EAB\u4EFD\u9A8C\u8BC1\u5668\u7684 6 \u4F4D\u9A8C\u8BC1\u7801',\n settingsConfirmBinding: '\u786E\u8BA4\u7ED1\u5B9A',\n settingsRestartBinding: '\u91CD\u65B0\u5F00\u59CB',\n settingsSignOutCurrent: '\u9000\u51FA\u5F53\u524D\u4F1A\u8BDD',\n settingsSignOutAll: '\u9000\u51FA\u6240\u6709\u4F1A\u8BDD',\n settingsSignOutAllDescription:\n '\u8BF7\u8F93\u5165\u5F53\u524D\u51ED\u8BC1\uFF1B\u63D0\u4EA4\u540E\u5305\u62EC\u5F53\u524D\u4F1A\u8BDD\u5728\u5185\u7684\u5168\u90E8\u4F1A\u8BDD\u548C\u957F\u8FDE\u63A5\u90FD\u4F1A\u5931\u6548\u3002',\n settingsOldBackupInvalid: '\u65E7\u5907\u7528\u7801\u5DF2\u5931\u6548\u3002',\n settingsCopyAll: '\u590D\u5236\u5168\u90E8',\n settingsBackupCopied: '\u5907\u7528\u7801\u5DF2\u590D\u5236\u3002',\n settingsBackupCopyFailed: '\u590D\u5236\u5931\u8D25\uFF0C\u8BF7\u9009\u4E2D\u5907\u7528\u7801\u624B\u52A8\u590D\u5236\u3002',\n\n settingsBackupTitle: '\u4FDD\u5B58\u5907\u7528\u7801',\n settingsBackupDescription:\n '\u8FD9\u4E9B\u5907\u7528\u7801\u53EA\u4F1A\u663E\u793A\u8FD9\u4E00\u6B21\u3002\u8BF7\u5B58\u653E\u5728\u5B89\u5168\u7684\u4F4D\u7F6E\uFF0C\u6BCF\u4E2A\u5907\u7528\u7801\u53EA\u80FD\u4F7F\u7528\u4E00\u6B21\u3002',\n settingsBackupSaved: '\u6211\u5DF2\u4FDD\u5B58\uFF0C\u91CD\u65B0\u767B\u5F55',\n settingsErrorInvalidCredentials: '\u5F53\u524D\u5BC6\u7801\u4E0D\u6B63\u786E\u3002',\n settingsErrorInvalidFactor: '\u5F53\u524D\u9A8C\u8BC1\u7801\u6216\u5907\u7528\u7801\u4E0D\u6B63\u786E\u3002',\n settingsErrorInvalidInput: '\u8F93\u5165\u4E0D\u7B26\u5408\u8981\u6C42\uFF1B\u5BC6\u7801\u9700\u7B26\u5408\u670D\u52A1\u7AEF\u957F\u5EA6\u89C4\u5219\u3002',\n settingsErrorChallenge: '\u7ED1\u5B9A\u6311\u6218\u5DF2\u5931\u6548\uFF0C\u8BF7\u91CD\u65B0\u5F00\u59CB\u7ED1\u5B9A\u3002',\n settingsErrorTotpRequired: '\u5F53\u524D profile \u8981\u6C42 TOTP\uFF0C\u65E0\u6CD5\u5173\u95ED\u3002',\n\n cliHelp: `dsh-auth-remote {version}\n\n\u7528\u6CD5\uFF1A\n dsh plugin --profile web exec dsh-auth-remote [--lang en|zh] COMMAND\n\n\u547D\u4EE4\uFF1A\n init \u5728\u7EC8\u7AEF\u4EA4\u4E92\u521D\u59CB\u5316\u5355\u7528\u6237\u8D26\u53F7\n status [--json] \u67E5\u770B\u4E0D\u542B\u79D8\u5BC6\u7684\u8BA4\u8BC1\u72B6\u6001\n reset-password \u91CD\u7F6E\u5BC6\u7801\u5E76\u64A4\u9500\u5168\u90E8\u4F1A\u8BDD\n reset-totp \u6E05\u9664 TOTP\u3001\u5907\u7528\u7801\u53CA\u5168\u90E8\u4F1A\u8BDD\n revoke-sessions \u9000\u51FA\u6240\u6709\u8BBE\u5907\n\n\u9009\u9879\uFF1A\n --lang en|zh \u9009\u62E9\u4EBA\u7C7B\u53EF\u8BFB\u8F93\u51FA\u7684\u8BED\u8A00\n --help, -h \u663E\u793A\u5E2E\u52A9\n --version, -v \u663E\u793A\u5305\u7248\u672C\n\n\u547D\u4EE4\u4F7F\u7528 dsh plugin exec \u9009\u5B9A\u7684 profile \u548C\u8C03\u7528\u8005\u7684 DSH_HOME\u3002\n`,\n cliPromptUsername: '\u7528\u6237\u540D: ',\n cliPromptPassword: '\u5BC6\u7801: ',\n cliPromptPasswordAgain: '\u518D\u6B21\u8F93\u5165\u5BC6\u7801: ',\n cliPromptNewPassword: '\u65B0\u5BC6\u7801: ',\n cliPromptNewPasswordAgain: '\u518D\u6B21\u8F93\u5165\u65B0\u5BC6\u7801: ',\n cliPromptConfirmTarget: '\u8F93\u5165 {profile} \u4EE5\u786E\u8BA4 {command}: ',\n cliTargetProfile: '\u76EE\u6807 profile: {profile}',\n cliDataFile: '\u6570\u636E\u6587\u4EF6: {path}',\n cliStatusProfile: 'profile: {profile}',\n cliStatusAccount: '\u8D26\u53F7: {state}',\n cliStatusTotp: 'TOTP: {state}',\n cliStatusSessions: '\u6709\u6548\u4F1A\u8BDD: {count}',\n cliStatusService: '\u670D\u52A1: {state}',\n cliInitialized: '\u5DF2\u521D\u59CB\u5316',\n cliNotInitialized: '\u672A\u521D\u59CB\u5316',\n cliTotpEnabled: '\u5DF2\u542F\u7528',\n cliTotpDisabled: '\u672A\u542F\u7528',\n cliOnlineReady: '\u5728\u7EBF\u4E14\u5C31\u7EEA',\n cliOnlineNotReady: '\u5728\u7EBF\u4F46\u672A\u5C31\u7EEA',\n cliOffline: '\u79BB\u7EBF',\n cliCompleted: '{command} \u5DF2\u5B8C\u6210\uFF1B\u53D8\u66F4\u5DF2\u6301\u4E45\u5316\u5E76\u751F\u6548\u3002',\n cliErrorInvalidArguments: '\u547D\u4EE4\u6216\u53C2\u6570\u65E0\u6548\uFF0C\u8BF7\u4F7F\u7528 --help\u3002',\n cliErrorInvalidLanguage: '--lang \u7684\u503C\u65E0\u6548\uFF0C\u8BF7\u4F7F\u7528 en \u6216 zh\u3002',\n cliErrorDuplicateLanguage: '--lang \u53EA\u80FD\u6307\u5B9A\u4E00\u6B21\u3002',\n cliErrorMissingLanguage: '--lang \u7F3A\u5C11\u503C\uFF0C\u8BF7\u4F7F\u7528 en \u6216 zh\u3002',\n cliErrorPasswordsMismatch: '\u4E24\u6B21\u8F93\u5165\u7684\u5BC6\u7801\u4E0D\u4E00\u81F4\u3002',\n cliErrorConfirmationMismatch: '\u786E\u8BA4\u8F93\u5165\u4E0E\u76EE\u6807 profile \u4E0D\u4E00\u81F4\u3002',\n cliErrorPasswordLength: '\u5BC6\u7801\u987B\u5305\u542B 12\u2013256 \u4E2A Unicode \u5B57\u7B26\u3002',\n cliErrorTerminalRequired: '\u6B64\u64CD\u4F5C\u9700\u8981\u4EA4\u4E92\u7EC8\u7AEF\u3002',\n cliErrorTerminalClosed: '\u7EC8\u7AEF\u8F93\u5165\u5DF2\u5173\u95ED\u3002',\n cliErrorCancelled: '\u5DF2\u53D6\u6D88\u3002',\n cliErrorProfileDirectory: '\u5F53\u524D\u76EE\u5F55\u4E0D\u662F DSH_HOME \u4E0B\u9009\u5B9A\u7684 DSH profile\u3002',\n cliErrorProfileManifest: '\u7F3A\u5C11 profile \u7684 package.json\u3002',\n cliErrorUnsafeManagementDirectory: '\u7BA1\u7406\u76EE\u5F55\u6743\u9650\u4E0D\u5B89\u5168\u3002',\n cliErrorUnsafeManagementSocket: '\u7BA1\u7406 socket \u6743\u9650\u4E0D\u5B89\u5168\u3002',\n cliErrorManagementUnavailable: '\u7BA1\u7406 socket \u4E0D\u53EF\u7528\u3002',\n cliErrorOutcomeUnknown: '\u7BA1\u7406\u8BF7\u6C42\u5DF2\u65AD\u5F00\u6216\u8D85\u65F6\uFF0C\u7ED3\u679C\u672A\u77E5\uFF1B\u518D\u6B21\u64CD\u4F5C\u524D\u8BF7\u5148\u68C0\u67E5\u72B6\u6001\u3002',\n cliErrorOfflineLock: '\u670D\u52A1\u4ECD\u6301\u6709 profile \u9501\u4E14\u7BA1\u7406 socket \u4E0D\u53EF\u7528\uFF0C\u5DF2\u62D2\u7EDD\u79BB\u7EBF\u64CD\u4F5C\u3002',\n cliErrorInvalidCredentials: '\u5F53\u524D\u51ED\u8BC1\u4E0D\u6B63\u786E\u3002',\n cliErrorAlreadyInitialized: '\u8D26\u53F7\u5DF2\u521D\u59CB\u5316\u3002',\n cliErrorInvalidInput: '\u8F93\u5165\u65E0\u6548\u3002',\n cliErrorInvalidFactor: '\u9A8C\u8BC1\u7801\u6216\u5907\u7528\u7801\u4E0D\u6B63\u786E\u3002',\n cliErrorUninitialized: '\u8D26\u53F7\u5C1A\u672A\u521D\u59CB\u5316\u3002',\n cliErrorTotpRequired: '\u6B64 profile \u8981\u6C42 TOTP\u3002',\n cliErrorConflict: '\u8D26\u53F7\u72B6\u6001\u5DF2\u53D8\u5316\uFF0C\u8BF7\u68C0\u67E5\u72B6\u6001\u540E\u91CD\u8BD5\u3002',\n cliErrorBusy: '\u670D\u52A1\u6B63\u5FD9\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002',\n cliErrorUnknown: '\u64CD\u4F5C\u5931\u8D25\uFF1B\u518D\u6B21\u64CD\u4F5C\u524D\u8BF7\u5148\u68C0\u67E5\u72B6\u6001\u3002',\n} as const satisfies { [Key in keyof typeof en]: string }\n", "import { en } from './locales/en.js'\nimport { zh } from './locales/zh.js'\n\nexport { en, zh }\nexport const dictionaries = { en, zh } as const\n\nexport type Locale = keyof typeof dictionaries\nexport type MessageKey = keyof typeof en\n\ntype Placeholders<Text extends string> = Text extends `${string}{${infer Name}}${infer Rest}`\n ? Name | Placeholders<Rest>\n : never\ntype SameSet<Left, Right> = [Left] extends [Right] ? ([Right] extends [Left] ? true : false) : false\ntype MismatchedPlaceholderKeys = {\n [Key in MessageKey]: SameSet<\n Placeholders<(typeof en)[Key]>,\n Placeholders<(typeof zh)[Key]>\n > extends true\n ? never\n : Key\n}[MessageKey]\n\n/** A compile-time failure here identifies any key whose placeholder names differ by language. */\nexport const localePlaceholdersMatch: MismatchedPlaceholderKeys extends never ? true : never = true\n\ntype FormatArgs<Key extends MessageKey> = [Placeholders<(typeof en)[Key]>] extends [never]\n ? []\n : [values: Record<Placeholders<(typeof en)[Key]>, string | number>]\n\n/** Only exact en/zh values are valid for the login page's stored preference. */\nexport function parseExactLocale(value: unknown): Locale | null {\n return value === 'en' || value === 'zh' ? value : null\n}\n\n/** CLI and language-tag inputs use Chinese for zh variants and English otherwise. */\nexport function localeFromLanguageTag(value: string | undefined): Locale {\n return value && /^zh(?:[-_.@]|$)/iu.test(value.trim()) ? 'zh' : 'en'\n}\n\nexport function normalizeLocale(value: unknown): Locale {\n return parseExactLocale(value) ?? 'en'\n}\n\n/** Returns plain text. Insert into textContent, React text, or escape before HTML templates. */\nexport function formatMessage<Key extends MessageKey>(\n locale: Locale | string | undefined,\n key: Key,\n ...args: FormatArgs<Key>\n): string {\n const template: string = dictionaries[normalizeLocale(locale)][key]\n const values = (args[0] ?? {}) as Record<string, string | number>\n return template.replace(/\\{([A-Za-z][A-Za-z0-9]*)\\}/gu, (_match, name: string) => {\n if (!Object.hasOwn(values, name)) throw new Error(`Missing i18n parameter ${name} for ${key}`)\n return String(values[name])\n })\n}\n\n/** For the existing standalone login HTML templates; dynamic values remain text. */\nexport function escapeHtmlText(value: string): string {\n return value.replace(/[&<>\"']/gu, (char) => {\n switch (char) {\n case '&':\n return '&amp;'\n case '<':\n return '&lt;'\n case '>':\n return '&gt;'\n case '\"':\n return '&quot;'\n default:\n return '&#39;'\n }\n })\n}\n", "import {\n formatMessage,\n localeFromLanguageTag,\n type Locale,\n type MessageKey,\n} from '../shared/i18n.js'\n\nexport class CliDiagnostic extends Error {\n constructor(\n readonly key: MessageKey,\n englishMessage: string,\n readonly locale?: Locale,\n ) {\n super(englishMessage)\n }\n}\n\nexport function environmentLocale(env: NodeJS.ProcessEnv): Locale {\n const value = [env.LC_ALL, env.LC_MESSAGES, env.LANG].find(\n (candidate) => candidate !== undefined && candidate.trim().length > 0,\n )\n return localeFromLanguageTag(value)\n}\n\n/** Strip one language option from either side of the command before command validation. */\nexport function parseLanguage(\n input: readonly string[],\n env: NodeJS.ProcessEnv = process.env,\n): { locale: Locale; args: string[] } {\n let locale = environmentLocale(env)\n let explicit = false\n const args: string[] = []\n for (let index = 0; index < input.length; index++) {\n const token = input[index]!\n if (token !== '--lang' && !token.startsWith('--lang=')) {\n args.push(token)\n continue\n }\n if (explicit)\n throw new CliDiagnostic(\n 'cliErrorDuplicateLanguage',\n 'dsh-auth-remote: --lang may be specified only once',\n locale,\n )\n explicit = true\n const value = token === '--lang' ? input[++index] : token.slice('--lang='.length)\n if (value === undefined || value.length === 0 || value.startsWith('--'))\n throw new CliDiagnostic(\n 'cliErrorMissingLanguage',\n 'dsh-auth-remote: --lang requires en or zh',\n locale,\n )\n if (value !== 'en' && value !== 'zh')\n throw new CliDiagnostic(\n 'cliErrorInvalidLanguage',\n 'dsh-auth-remote: invalid --lang value; use en or zh',\n locale,\n )\n locale = value\n }\n return { locale, args }\n}\n\nexport function cliText(\n locale: Locale,\n key: MessageKey,\n params: Record<string, string | number> = {},\n): string {\n return formatMessage(locale, key, params)\n}\n", "import { lstat, realpath } from 'node:fs/promises'\nimport { homedir } from 'node:os'\nimport { basename, dirname, join, resolve } from 'node:path'\nimport { CliDiagnostic } from './language.js'\n\nexport interface ProfileTarget {\n name: string\n dir: string\n home: string\n statePath: string\n socketPath: string\n}\n\nfunction dshHome(env: NodeJS.ProcessEnv): string {\n const supplied = env.DSH_HOME\n const candidate =\n supplied !== undefined && supplied.trim().length > 0 ? supplied : join(homedir(), '.dsh')\n const expanded =\n candidate === '~'\n ? homedir()\n : candidate.startsWith('~/') || candidate.startsWith('~\\\\')\n ? join(homedir(), candidate.slice(2))\n : candidate\n return resolve(expanded)\n}\n\n/** `dsh plugin --profile NAME exec` runs pnpm in the selected profile directory. */\nexport async function resolveProfileTarget(\n cwd = process.cwd(),\n env: NodeJS.ProcessEnv = process.env,\n): Promise<ProfileTarget> {\n const dir = await realpath(cwd)\n const home = await realpath(dshHome(env))\n const profiles = await realpath(join(home, 'profiles'))\n const name = basename(dir)\n const info = await lstat(dir)\n if (\n !info.isDirectory() ||\n info.uid !== process.getuid?.() ||\n dirname(dir) !== profiles ||\n name === 'node_modules' ||\n name === '.' ||\n name === '..'\n )\n throw new CliDiagnostic(\n 'cliErrorProfileDirectory',\n 'dsh-auth-remote: current directory is not the selected DSH profile under DSH_HOME',\n )\n let manifest\n try {\n manifest = await lstat(join(dir, 'package.json'))\n } catch (error) {\n if (typeof error === 'object' && error !== null && 'code' in error && error.code === 'ENOENT')\n throw new CliDiagnostic(\n 'cliErrorProfileManifest',\n 'dsh-auth-remote: profile package.json is missing',\n )\n throw error\n }\n if (!manifest.isFile())\n throw new CliDiagnostic(\n 'cliErrorProfileManifest',\n 'dsh-auth-remote: profile package.json is missing',\n )\n return {\n name,\n dir,\n home,\n statePath: join(dir, 'auth-remote', 'auth-state.json'),\n socketPath: join(dir, 'auth-remote', 'admin.sock'),\n }\n}\n", "import type { ReadStream, WriteStream } from 'node:tty'\nimport { CliDiagnostic } from './language.js'\n\n/** One terminal session; secret input is read in raw mode and never echoed. */\nexport class TerminalPrompt {\n private readonly pending: string[] = []\n private wake: (() => void) | undefined\n private readonly decoder = new TextDecoder()\n private readonly previousRaw: boolean\n private closed = false\n private ended = false\n private skipLf = false\n\n constructor(\n private readonly input = process.stdin as ReadStream,\n private readonly output = process.stdout as WriteStream,\n ) {\n if (!input.isTTY || !output.isTTY || typeof input.setRawMode !== 'function')\n throw new CliDiagnostic(\n 'cliErrorTerminalRequired',\n 'dsh-auth-remote: an interactive terminal is required',\n )\n this.previousRaw = input.isRaw\n input.setRawMode(true)\n input.resume()\n input.on('data', this.onData)\n input.once('end', this.onEnd)\n }\n\n private readonly onData = (chunk: Buffer): void => {\n for (const char of this.decoder.decode(chunk, { stream: true })) this.pending.push(char)\n this.wake?.()\n this.wake = undefined\n }\n\n private readonly onEnd = (): void => {\n this.ended = true\n this.wake?.()\n this.wake = undefined\n }\n\n private async take(): Promise<string> {\n while (this.pending.length === 0) {\n if (this.closed || this.ended)\n throw new CliDiagnostic('cliErrorTerminalClosed', 'dsh-auth-remote: terminal input closed')\n await new Promise<void>((resolve) => {\n this.wake = resolve\n })\n }\n const char = this.pending.shift()!\n if (this.skipLf) {\n this.skipLf = false\n if (char === '\\n') return this.take()\n }\n return char\n }\n\n async ask(label: string, secret = false, maxCharacters = 256): Promise<string> {\n if (this.closed)\n throw new CliDiagnostic('cliErrorTerminalClosed', 'dsh-auth-remote: terminal input closed')\n this.output.write(label)\n const answer: string[] = []\n let escape = false\n for (;;) {\n const char = await this.take()\n if (escape) {\n if (/[A-Za-z~]/u.test(char)) escape = false\n continue\n }\n if (char === '\\u001b') {\n escape = true\n continue\n }\n if (char === '\\u0003')\n throw new CliDiagnostic('cliErrorCancelled', 'dsh-auth-remote: cancelled')\n if (char === '\\u0004')\n throw new CliDiagnostic('cliErrorTerminalClosed', 'dsh-auth-remote: terminal input closed')\n if (char === '\\r' || char === '\\n') {\n if (char === '\\r') this.skipLf = true\n this.output.write('\\n')\n return answer.join('')\n }\n if (char === '\\u007f' || char === '\\b') {\n if (answer.length > 0) {\n answer.pop()\n if (!secret) this.output.write('\\b \\b')\n }\n continue\n }\n if (/[\\u0000-\\u001f\\u007f]/u.test(char)) continue\n if (answer.length >= maxCharacters) continue\n answer.push(char)\n if (!secret) this.output.write(char)\n }\n }\n\n close(): void {\n if (this.closed) return\n this.closed = true\n this.input.off('data', this.onData)\n this.input.off('end', this.onEnd)\n this.input.setRawMode(this.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,iBAAiB;AAAA,YACtB,OAAO,OAAO,OAAO,cAAc,mBAAmB,iBAAiB;AAAA,UACzE,CAAC;AAAA,UACD,OAAO,qBAAqB,EAAE,OAAO,OAAO,eAAe,CAAC;AAAA,UAC5D,OAAO,oBAAoB;AAAA,YACzB,OAAO;AAAA,cACL,OAAO,SACH,OAAO,QACL,mBACA,sBACF;AAAA,YACN;AAAA,UACF,CAAC;AAAA,QACH,EAAE,KAAK,IAAI,IAAI;AAAA,MACjB;AACF;AAAA,EACF;AACA,UAAQ,OAAO,MAAM,GAAG,OAAO,gBAAgB,EAAE,QAAkB,CAAC,CAAC;AAAA,CAAI;AAC3E;AAEA,KAAK,KAAK,EAAE,MAAM,CAAC,UAAmB;AACpC,UAAQ,OAAO,MAAM,GAAG,UAAU,OAAO,aAAa,CAAC;AAAA,CAAI;AAC3D,UAAQ,WAAW;AACrB,CAAC;",
6
6
  "names": ["randomBytes", "randomUUID", "constants", "lstat", "open", "readFile", "unlink", "join", "value", "errno", "join", "lstat", "readFile", "randomUUID", "open", "constants", "unlink", "resolve", "record", "randomBytes", "createHash", "randomBytes", "timingSafeEqual", "output", "randomBytes", "record", "lstat", "errno", "lstat", "resolve", "lstat", "dirname", "join", "join", "lstat", "dirname", "manifest", "output", "resolve"]
7
7
  }