1export interface Env {2 CONTENT: R2Bucket;3 DB: D1Database;4 NZIP_TOKEN: string;5 PUBLIC_BASE: string;6 // Per-IP limiter for bare-address hits — throttles address enumeration.7 RL_ENUM: RateLimit;8 // Per-IP+address limiter for the unlock endpoint — throttles password guessing.9 RL_UNLOCK: RateLimit;10}1112export function json<T = unknown>(body: T, status = 200, headers: HeadersInit = {}): Response {13 return new Response(JSON.stringify(body), {14 status,15 headers: { "content-type": "application/json; charset=utf-8", ...headers },16 });17}1819export function err(message: string, status: number): Response {20 return json({ error: message }, status);21}2223export function siteUrl(env: Env, address: string): string {24 return `${env.PUBLIC_BASE}/${address}`;25}