/** * AuthGate — the stopgap access flow (see decision_2026-06-15_shared-wallet-login-flow): * 1. Technical access barrier (AccessGateScreen) → opens the SHARED wallet via * the broker redirect (with the wallet file + guide it hands the user). * 2. Perceived app login (ConnexionScreen) → pick a username. * 3. The app. * * The gate is ON BY DEFAULT (Festipod never functions without NextGraph). It is * disabled only when `globalThis.__FESTIPOD_ACCESS_GATE_DISABLED__ === true` — * injected by `build.ts` (from ACCESS_GATE_DISABLED=1) for a no-gate build, or * by the test harness via `context.addInitScript` for @e2e (which exercises the * screens, not the auth flow). Absent → gate ON. */ import type { ReactNode } from 'react'; import { useNextGraph } from '../shared/context/NextGraphContext'; import { useAccount } from '../shared/context/AccountContext'; import { AccessGateScreen } from '../modules/auth/screens/AccessGateScreen'; import { ConnexionScreen } from '../modules/auth/screens/ConnexionScreen'; declare global { // eslint-disable-next-line no-var var __FESTIPOD_ACCESS_GATE_DISABLED__: boolean | undefined; } const GATE_DISABLED = globalThis.__FESTIPOD_ACCESS_GATE_DISABLED__ === true; export function AuthGate({ children }: { children: ReactNode }) { const { status, error, connect } = useNextGraph(); const { username } = useAccount(); // Gate explicitly disabled (no-gate build / @e2e harness) → straight to app. if (GATE_DISABLED) { return <>{children}; } // 1. Technical access barrier (real NG login) — until the shared wallet opens. if (status !== 'connected') { return ; } // 2. Perceived app login — until a username is chosen. if (!username) { return ; } // 3. The app. return <>{children}; }