export interface AtprotoEnv { publicUrl: string; privateKeyPath: string; } export function getAtprotoEnv(): AtprotoEnv | null { const publicUrl = process.env["PUBLIC_URL"]; const privateKeyPath = process.env["OAUTH_PRIVATE_KEY_PATH"]; if (!publicUrl || !privateKeyPath) { return null; } return { publicUrl, privateKeyPath }; } export function isAuthEnabled(): boolean { return getAtprotoEnv() !== null; } export function getJetstreamUrl(): string { return ( process.env["JETSTREAM_URL"] ?? "wss://jetstream2.us-east.bsky.network" ); } export function getHandleResolverUrl(): string { return process.env["HANDLE_RESOLVER_URL"] ?? "https://bsky.social"; } interface DevAccount { did: string; handle: string; } const DEFAULT_DEV_ACCOUNTS: Record = { alice: { did: "did:plc:devalice00000000000000000", handle: "alice.test", }, bob: { did: "did:plc:devbob0000000000000000000", handle: "bob.test", }, }; // Cookie-only impersonation list used when OAuth is off; null in production. export function getDevAccounts(): Record | null { if (getAtprotoEnv() !== null) return null; const raw = process.env["DEV_ACCOUNTS"]; if (!raw) return DEFAULT_DEV_ACCOUNTS; try { return JSON.parse(raw) as Record; } catch { return DEFAULT_DEV_ACCOUNTS; } }