Idea: a fail-closed, route-aware screen guard for React Navigation #7
AmineYagoub
started this conversation in
Ideas
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
The problem
Apps that show private data on Android (health, school, banking) need
FLAG_SECUREon the screens that show it: it blocks screenshots and screen recordings, and blanks the app's card in recent apps. In React Native the usual tools turn it on per screen: a screen calls a hook such asexpo-screen-capture'susePreventScreenCapture, and is protected while that component is mounted. That fails open:What Minhajna does
Minhajna, a school-records app, ran into this while building its app lock (djazairdev/minhajna#210, djazairdev/minhajna#255). Its guard:
open,recordsorpin); an unknown kind is treated as a PIN pad;__unsafe_action__event to raise the guard as each action is dispatched, before the next screen is drawn, then settles on the computed kind after the render;On an Android 15 emulator, 25 samples of the window flag through an unlock were all secure, and Back from an open screen was secure within 0.14 s. The code is in
apps/android/src/lock/screen-guard.ts,App.tsxandandroid/.../lock/ScreenGuard.ktin djazairdev/minhajna.What to build
A small library,
react-navigation-screen-guardor similar:<ScreenGuard openScreens={[...]} pinScreens={[...]}>wrapper, or a hook for theNavigationContainer, that drives it from the focused route;dumpsys window.Rough size: a few hundred lines of TypeScript and Kotlin, plus an example app.
Who it helps
Any React Native app with private screens: health records, banking, messaging, education. Today each of them either guards the whole app or opts in screen by screen.
All reactions