mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 20:42:02 +00:00
feat(ui): register Stripe publishable keys in runtime config island (#12021)
Co-authored-by: Pablo F.G <pablo.fernandez@prowler.com>
This commit is contained in:
@@ -105,6 +105,8 @@ describe("getRuntimeConfigClient", () => {
|
||||
"reoDevClientId",
|
||||
"sentryDsn",
|
||||
"sentryEnvironment",
|
||||
"stripePublishableKey",
|
||||
"stripePublishableKeyV2",
|
||||
].sort(),
|
||||
);
|
||||
expect(config.apiBaseUrl).toBe("https://api.example.com/api/v1");
|
||||
|
||||
@@ -21,6 +21,8 @@ const pickConfig = (
|
||||
posthogHost: parsed.posthogHost ?? null,
|
||||
reoDevClientId: parsed.reoDevClientId ?? null,
|
||||
cloudBillingEnabled: parsed.cloudBillingEnabled ?? false,
|
||||
stripePublishableKey: parsed.stripePublishableKey ?? null,
|
||||
stripePublishableKeyV2: parsed.stripePublishableKeyV2 ?? null,
|
||||
});
|
||||
|
||||
// Reads the <head> island once (memoized); all-null during SSR or if it's
|
||||
|
||||
@@ -10,6 +10,8 @@ export interface RuntimePublicConfig {
|
||||
posthogHost: string | null; // reserved
|
||||
reoDevClientId: string | null; // reserved
|
||||
cloudBillingEnabled: boolean;
|
||||
stripePublishableKey: string | null; // reserved
|
||||
stripePublishableKeyV2: string | null; // reserved
|
||||
}
|
||||
|
||||
export const RUNTIME_CONFIG_SCRIPT_ID = "__PROWLER_RUNTIME_CONFIG__";
|
||||
@@ -25,4 +27,6 @@ export const EMPTY_RUNTIME_PUBLIC_CONFIG: RuntimePublicConfig = {
|
||||
posthogHost: null,
|
||||
reoDevClientId: null,
|
||||
cloudBillingEnabled: false,
|
||||
stripePublishableKey: null,
|
||||
stripePublishableKeyV2: null,
|
||||
};
|
||||
|
||||
@@ -49,5 +49,13 @@ export async function getRuntimePublicConfig(): Promise<RuntimePublicConfig> {
|
||||
// server-side for V1/V2 routing). Default (unset) is off.
|
||||
cloudBillingEnabled:
|
||||
(readEnv("CLOUD_BILLING_ENABLED") ?? "false") !== "false",
|
||||
stripePublishableKey: readEnv(
|
||||
"UI_CLOUD_STRIPE_PUBLISHABLE_KEY",
|
||||
"NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY",
|
||||
),
|
||||
stripePublishableKeyV2: readEnv(
|
||||
"UI_CLOUD_STRIPE_PUBLISHABLE_KEY_V2",
|
||||
"NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY_V2",
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
@@ -20,6 +20,8 @@ export const RUNTIME_CONFIG_KEYS = [
|
||||
"posthogHost",
|
||||
"reoDevClientId",
|
||||
"cloudBillingEnabled",
|
||||
"stripePublishableKey",
|
||||
"stripePublishableKeyV2",
|
||||
] as const satisfies ReadonlyArray<keyof RuntimePublicConfig>;
|
||||
|
||||
/**
|
||||
|
||||
Vendored
+9
@@ -30,6 +30,15 @@ declare global {
|
||||
|
||||
CLOUD_BILLING_ENABLED?: "legacy" | "metronome" | "false";
|
||||
|
||||
// Cloud-only Stripe publishable keys (public; shipped to the browser).
|
||||
// V1 = legacy billing, V2 = metronome.
|
||||
/** @deprecated use UI_CLOUD_STRIPE_PUBLISHABLE_KEY */
|
||||
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY?: string;
|
||||
UI_CLOUD_STRIPE_PUBLISHABLE_KEY?: string;
|
||||
/** @deprecated use UI_CLOUD_STRIPE_PUBLISHABLE_KEY_V2 */
|
||||
NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY_V2?: string;
|
||||
UI_CLOUD_STRIPE_PUBLISHABLE_KEY_V2?: string;
|
||||
|
||||
// Build-time public config
|
||||
NEXT_PUBLIC_IS_CLOUD_ENV?: "true" | "false";
|
||||
NEXT_PUBLIC_PROWLER_RELEASE_VERSION?: string;
|
||||
|
||||
Reference in New Issue
Block a user