Skip to content

feat: allow hiding TOTP codes by default (#319) - #323

Open
rootphantomer wants to merge 1 commit into
shuaiplus:mainfrom
rootphantomer:feat/hide-totp-by-default
Open

rootphantomer wants to merge 1 commit into
shuaiplus:mainfrom
rootphantomer:feat/hide-totp-by-default

Conversation

@rootphantomer

@rootphantomer rootphantomer commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

Summary

Closes #319.

控制面板此前默认以明文显示 TOTP 验证码。本 PR 在「设置 > 外观」下新增一个本地偏好「默认隐藏验证码(Hide verification codes by default)」。开启后,验证码面板和密码项详情中的 TOTP 会用星号遮罩,点击眼睛图标后才显示。复制按钮始终复制真实验证码。

该偏好保存在 localStorage(默认关闭,因此现有行为不变),并复用代码库已有的 maskSecret + Eye/EyeOff 约定。新增 txt_hide_totp_by_default[_help] 文案,覆盖全部 10 种语言。

涉及的界面:

  • TotpCodesPage —— 逐条显隐(用 Set<string> 记录已展开的 cipher ID,参照 PasswordSecurityPage 的实现)
  • VaultDetailView —— 在 showPassword 旁新增 showTotp 状态,切换条目时重置
  • 遮罩仅作用于显示层;复制按钮读取的是底层的 live.code,因此遮罩态下复制得到的仍是当前真实验证码。

Change Type

  • Bug fix
  • Feature
  • Compatibility update
  • Documentation
  • Refactor

Cross-File Checklist

  • I read CONTRIBUTING.md.
  • Schema changes, if any, updated both runtime schema and migrations/0001_init.sql.
  • Persistent data changes, if any, updated backup export/import or documented why backup is not needed.
  • User-facing text changes, if any, updated all locale files.
  • Bitwarden client compatibility was considered for sync/API shape changes.
  • No secrets, tokens, private deployment values, or real vault data are included.

Checks

  • npx tsc -p tsconfig.json --noEmit
  • npx tsc -p webapp/tsconfig.json --noEmit
  • npm run i18n:validate
  • npm run build

Notes

  • 无 schema 或持久化数据改动——该偏好仅为客户端 localStorage(nodewarden.totp.hide-by-default.v1),因此不涉及备份/导入导出或数据库。上面两条未勾选的「if any」项即因此属于 N/A;Bitwarden 同步/API 形状完全未改(纯前端改动)。
  • npx tsc -p webapp/tsconfig.json --noEmit 未勾选,是因为它在 main 上就存在 4 个预存错误,且都在本 PR
    未触及的文件中(webapp/src/lib/api/backup.tswebapp/src/lib/backup-center.tswebapp/src/lib/password-security-cache.tswebapp/vite.config.ts)。这些错误并非本次改动引入或影响——本次修改的 6个组件文件均类型检查通过。后端 tsci18n:validatenpm run build 全部通过。
  • 默认关闭,未开启该开关的用户看到的界面与当前完全一致(不会渲染任何新按钮)。

截图

image image

Add a local "Hide verification codes by default" preference under
Settings > Appearance. When enabled, TOTP codes on the verification
codes page and in the vault item detail are masked with asterisks
until revealed via the eye toggle. Copy always copies the real code.

The preference is stored in localStorage (defaults to off, so existing
behavior is unchanged) and reuses the existing maskSecret + Eye/EyeOff
convention. Adds txt_hide_totp_by_default[_help] to all 10 locales.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feature] 允许控制面板隐藏 TOTP

1 participant