How shield-intelligence/shield-authenticator works
Purpose and entry points
SHIELD-Authenticator is a React-based TOTP authenticator with a client-side encrypted account vault, Firebase-backed identity/sync, offline behavior, and a Capacitor Android shell. Browser startup flows through src/index.js into src/App.js; native Android starts at android/app/src/main/java/com/shieldintelligence/authenticator/MainActivity.java.
Application composition and routing
App.js is the application orchestrator, combining lifecycle/security hooks, handler modules, and routes. src/pages/AppRoutes.js separates public authentication/legal pages from the authenticated vault experience. Primary user surfaces are the dashboard and settings:
• src/App.js
• src/pages/AppRoutes.js
• src/pages/Dashboard.js
• src/pages/SettingsPage.js
Identity, vault lifecycle, and recovery
Firebase authentication establishes the user identity; vault access is a separate passphrase-controlled lifecycle. The lifecycle hook and handlers coordinate setup, unlock, recovery, passphrase changes, and teardown. Recovery questions support resetting vault access, but encrypted data remains dependent on vault cryptographic material.
• src/hooks/useAuthVaultLifecycle.js
• src/modules/appHandlers/authHandlers.js
• src/modules/appHandlers/vaultHandlers.js
• src/Utils/recoveryQuestions.js
Encryption and local persistence boundary
2FA secrets are encrypted/decrypted on the client before cloud persistence. Vault cryptography uses Argon2id-derived passphrase keys; local state and secure storage retain device-side vault/session readiness needed for offline behavior. Firebase/Firestore is a ciphertext store rather than a trusted plaintext vault.
• src/Utils/vaultCrypto.js
• src/Utils/vault.js
• src/Utils/vaultLocalState.js
• src/Utils/secureStorage.js
Account and TOTP workflow
Authenticated, unlocked users manage account records through dashboard forms/list items. Account handlers mediate create/edit/delete and persistence; the ticker hook continuously derives and refreshes display codes. Filtering, provider presentation, and CSV import/export operate around this decrypted in-app account model.
• src/modules/appHandlers/accountHandlers.js
• src/components/AddAccountForm.js
• src/components/AccountList.js
• src/hooks/useCodesTicker.js
• src/Utils/csvUtils.js
Cloud sync and connectivity
Firebase initialization and service access are centralized in utilities, configured through public REACT_APP_FIREBASE_* build-time values. Connectivity/security state distinguishes online use, offline-ready devices after successful sync, and fresh offline installs without cached vault data.
• src/Utils/firebase.js
• src/Utils/services.js
• src/hooks/useSecurityAndConnectivity.js
• src/Utils/networkUtils.js
Native and deployment boundary
The frontend is a static React/PWA build, deployable to static hosting; _redirects and _headers indicate host-level SPA/routing and response policy support. Capacitor packages the same web app for Android and exposes native root-detection and screen-security plugins to JavaScript.
• capacitor.config.ts
• android/app/src/main/java/com/shieldintelligence/authenticator/RootDetectionPlugin.java
• android/app/src/main/java/com/shieldintelligence/authenticator/ScreenSecurityPlugin.java
• public/_redirects
Main entry points: App.js Application orchestrator · AppRoutes.js Application routes · Dashboard.js Dashboard · accountHandlers.js Account handlers
Components 21
React application
- Browser entry
src/index.js - Application orchestrator · Combines lifecycle hooks, handlers, and routes.
src/App.js - Application routes · Separates public pages from the authenticated vault.
src/pages/AppRoutes.js - Dashboard
src/pages/Dashboard.js - Settings
src/pages/SettingsPage.js - Account handlers · Mediates account create, edit, delete, and persistence.
src/modules/appHandlers/accountHandlers.js - Account management UI · Forms and list for decrypted in-app account records.
src/components/AddAccountForm.js - TOTP code ticker · Continuously derives and refreshes display codes.
src/hooks/useCodesTicker.js - CSV import/export
src/Utils/csvUtils.js
Vault security
Passphrase-gated encrypted account lifecycle.
- Auth-vault lifecycle · Coordinates identity, vault readiness, recovery, and teardown.
src/hooks/useAuthVaultLifecycle.js - Authentication handlers
src/modules/appHandlers/authHandlers.js - Vault handlers
src/modules/appHandlers/vaultHandlers.js - Recovery questions
src/Utils/recoveryQuestions.js - Vault cryptography · Derives Argon2id passphrase keys and encrypts account secrets.
src/Utils/vaultCrypto.js - Local vault state · Retains device vault and session readiness for offline use.
src/Utils/vaultLocalState.js - Secure storage
src/Utils/secureStorage.js
Sync and platform
- Firebase services · Centralized Firebase initialization and service access.
src/Utils/firebase.js - Firestore ciphertext store · Stores encrypted vault data, not plaintext secrets.
- Security and connectivity · Distinguishes online, offline-ready, and fresh offline states.
src/hooks/useSecurityAndConnectivity.js - Android Capacitor shell · Hosts the same web application and native security plugins.
android/app/src/main/java/com/shieldintelligence/authenticator/MainActivity.java - Native security plugins · Provides root detection and screen-security controls.
android/app/src/main/java/com/shieldintelligence/authenticator/RootDetectionPlugin.java
Connections 23
- Browser entry → Application orchestrator: mounts
- Application orchestrator → Application routes: renders
- Application routes → Dashboard: authenticated route
- Application routes → Settings: authenticated route
- Application orchestrator → Auth-vault lifecycle: uses
- Application orchestrator → Authentication handlers: uses
- Application orchestrator → Vault handlers: uses
- Auth-vault lifecycle → Firebase services: establishes identity
- Auth-vault lifecycle → Local vault state: restores readiness
- Vault handlers → Vault cryptography: unlocks and rekeys
- Vault handlers → Recovery questions: supports recovery
- Local vault state → Secure storage: persists device state
- Dashboard → Account management UI: hosts
- Account management UI → Account handlers: manages records
- Account handlers → Vault cryptography: encrypts/decrypts secrets
- Account handlers → Firestore ciphertext store: syncs ciphertext
- Dashboard → TOTP code ticker: displays codes
- Account management UI → CSV import/export: imports/exports
- Firebase services → Firestore ciphertext store: accesses
- Security and connectivity → Firebase services: evaluates sync availability
- Security and connectivity → Local vault state: checks offline readiness
- Android Capacitor shell → Application orchestrator: hosts web app
- Android Capacitor shell → Native security plugins: registers