feat: dev and staging bypass

This commit is contained in:
Nathnael
2026-08-15 08:07:06 +00:00
parent 6c4969f3fd
commit 69805315d9
8 changed files with 142 additions and 30 deletions

View File

@@ -25,6 +25,10 @@ import {
type IdentitySubject,
type IdentityVerificationState,
} from "@/services/verifayda.service";
import { isBypassEnv } from "@/utils/dev-bypass";
/** Sentinel code that skips the real eSignet exchange in dev/staging (see api's DEV_BYPASS_FAYDA_CODE). */
const DEV_BYPASS_FAYDA_CODE = "DEV_BYPASS";
interface FaydaVerifyPanelProps {
subject: IdentitySubject;
@@ -80,6 +84,23 @@ export default function FaydaVerifyPanel({
setError(null);
setLoading(true);
try {
// Dev/staging only: send the tab straight to /fayda/callback with the
// sentinel code instead of round-tripping through eSignet — that page's
// existing completeIdentity()/navigate-back logic runs unchanged.
if (isBypassEnv()) {
stashPendingVerification({
subject,
returnTo:
window.location.pathname +
window.location.search +
window.location.hash,
});
window.location.assign(
`/fayda/callback?code=${DEV_BYPASS_FAYDA_CODE}&state=bypass`,
);
return;
}
const authorizationUrl = await verifaydaService.start();
// Record who is being verified and where to come back to before the tab
// leaves — /fayda/callback has no other way to know either.

View File

@@ -0,0 +1,4 @@
/** True when VITE_ENV is "dev" or "staging" — mirrors the API's ENV gate. */
export function isBypassEnv(): boolean {
return ["dev", "staging"].includes(import.meta.env.VITE_ENV ?? "");
}

View File

@@ -23,6 +23,8 @@ interface ImportMetaEnv {
readonly VITE_POSTHOG_KEY?: string;
/** Self-hosted PostHog instance URL. */
readonly VITE_POSTHOG_HOST?: string;
/** "dev" | "staging" — enables the OTP/payment/Fayda bypass. Unset in prod. */
readonly VITE_ENV?: string;
}
interface ImportMeta {