Skip to content

fix(mobile): auto-lock on background and idle (#408) - #413

Open
mashfromband wants to merge 1 commit into
mainfrom
worktree-agent-a47ae9ef88a5972fe
Open

mashfromband wants to merge 1 commit into
mainfrom
worktree-agent-a47ae9ef88a5972fe

Conversation

@mashfromband

Copy link
Copy Markdown
Contributor

概要

モバイルアプリはアプリロック(PIN / 生体)を コールドスタート時に一度だけ 要求し、以後 unlocked がプロセス寿命の間ずっと保持され、バックグラウンド遷移・アイドル経過で再ロックされなかった(自動ロック不在)。本 PR で以下の 2 トリガーで自動再ロックを実装する。

  • バックグラウンド遷移: WebView が hidden(visibilitychange / pagehide)になったら猶予後に再ロック。既定は即時(猶予 0ms、設定可能)。復帰が猶予内なら取消。
  • アイドルタイムアウト: 無操作が続くと再ロック。既定 120 秒(設定で 60 / 120 / 300 秒)。pointerdown / keydown / touchstart でリセット。

再ロックは unlocked を false に戻し、開いているパスワードボックスを閉じ、既存の生体 / PIN アンロックフロー(AppLockScreen)を再度通す。

設計

  • 判定ロジックを UI 非依存の AutoLockController(apps/mobile/src/lib/auto-lock.ts)に分離し、フェイククロックでユニットテスト(apps/mobile/test/auto-lock.test.ts、9 ケース)。
  • React 配線は hooks/useAutoLock.ts。App.tsx で useAutoLock(unlocked, relock)。
  • アイドル時間は Settings で変更可能(mobile.settings.autoLock*)。変更は passshare:auto-lock-changed / storage イベントで実行中セッションに即時反映。

i18n

  • 新規 6 キー(mobile.autoLock.idle.{1m,2m,5m} / mobile.settings.autoLock / autoLockIdle / autoLockHint)を 全 10 ロケール に追加。node scripts/i18n-check.mjs green(273 keys)。「パスワードボックス」用語遵守(金庫 / Vault / ボルト不使用)。

仕様

  • documents/spec/biometric-unlock.md に「自動ロック / 再ロック」セクション、documents/spec/mobile-ui.md に Auto-lock セクションを追記(issue 指摘の仕様欠落を解消)。

テスト / 検証

Closes #408

Mobile only required app-lock (PIN/biometric) on cold start; `unlocked`
was then held for the whole process lifetime, so an unattended unlocked
device exposed every password box. Add an auto-lock that returns the app
to its locked state on two triggers:

- Background transition (`visibilitychange` hidden / `pagehide`) — locks
  immediately by default (configurable grace).
- Idle timeout — locks after inactivity (default 120s; user-selectable
  60/120/300s in Settings), reset by pointer/key/touch activity.

The decision logic is isolated in a framework-agnostic AutoLockController
(`lib/auto-lock.ts`) unit-tested with a fake clock; React wiring lives in
`hooks/useAutoLock.ts`. Re-lock resets `unlocked` and closes the open box,
re-entering the existing biometric/PIN AppLockScreen.

Adds ja/en/ru (+ should-locales) strings for the Settings control, and
documents the auto-lock requirement in the biometric-unlock / mobile-ui
specs (previously unspecified).

Closes #408
@vercel

vercel Bot commented Jul 11, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
pass-share-frontend Ready Ready Preview, Comment Jul 11, 2026 4:34pm

Request Review

This branch was previously deployed

1 inactive deployment
Preview — 754c7bae Deployed Jul 11, 2026 by vercel[bot]
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.

fix(mobile): アンロック後に自動ロックが無く、バックグラウンド/アイドルでも再ロックされない

1 participant