Download services/wallet/src/config.ts from AnthropicallyHuggingFaces/ProjectOS: direct link, hf CLI and curl.
- Browser
- Download file 1.82 kB
-
https://huggingface.co/spaces/AnthropicallyHuggingFaces/ProjectOS/resolve/main/services/wallet/src/config.ts
- Command line
-
hf download hf://spaces/AnthropicallyHuggingFaces/ProjectOS/services/wallet/src/config.ts
-
curl -L -o config.ts https://huggingface.co/spaces/AnthropicallyHuggingFaces/ProjectOS/resolve/main/services/wallet/src/config.ts
1.82 kB
| import { z } from "zod"; | |
| const schema = z.object({ | |
| PORT: z.coerce.number().default(7860), | |
| WALLET_USER_ID: z.string().min(1), | |
| STRIPE_SECRET_KEY: z.string().min(1).optional(), | |
| STRIPE_WEBHOOK_SECRET: z.string().min(1).optional(), | |
| STRIPE_SUCCESS_URL: z.string().url().default("http://localhost:7860/funding/success"), | |
| STRIPE_CANCEL_URL: z.string().url().default("http://localhost:7860/funding/cancel"), | |
| SUPABASE_URL: z.string().optional(), | |
| SUPABASE_SERVICE_ROLE_KEY: z.string().optional(), | |
| WALLET_STORE: z.enum(["supabase", "memory"]).default("supabase"), | |
| }); | |
| export type Config = z.infer<typeof schema>; | |
| /** Hard safety guards: test-mode only, no real-money paths, no Apple Pay credentials. */ | |
| export function assertSafeEnv(env: Record<string, string | undefined>): void { | |
| const key = env.STRIPE_SECRET_KEY ?? ""; | |
| if (key.startsWith("sk_live_") || key.startsWith("rk_live_")) { | |
| throw new Error("Refusing to start: live Stripe key detected. Wallet is TEST-mode only."); | |
| } | |
| if (key && !key.startsWith("sk_test_") && !key.startsWith("rk_test_")) { | |
| throw new Error("Refusing to start: STRIPE_SECRET_KEY must be a test key (sk_test_/rk_test_)."); | |
| } | |
| const forbidden = Object.keys(env).filter((k) => /APPLE_?PAY|PRIVATE_?RELAY|MERCHANT_IDENTITY/i.test(k)); | |
| if (forbidden.length) { | |
| throw new Error(`Refusing to start: Apple Pay / private relay credentials are not allowed (${forbidden.join(", ")}).`); | |
| } | |
| } | |
| export function loadConfig(env: Record<string, string | undefined> = process.env): Config { | |
| assertSafeEnv(env); | |
| const cfg = schema.parse(env); | |
| if (cfg.WALLET_STORE === "supabase" && (!cfg.SUPABASE_URL || !cfg.SUPABASE_SERVICE_ROLE_KEY)) { | |
| throw new Error("SUPABASE_URL and SUPABASE_SERVICE_ROLE_KEY are required when WALLET_STORE=supabase"); | |
| } | |
| return cfg; | |
| } | |