Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

899 B
Raw Blame
/**
 * supporterKey.ts — pure, client-safe validation for the Radar supporter-key
 * format: "omr_" + 40 lowercase hex chars.
 *
 * Kept free of any server-only import (db, sync) — same pattern as
 * autoSync.ts — so the "use client" Radar activation screen can import it
 * directly for a UX-only pre-check before calling POST /api/radar/settings.
 *
 * This is NOT a security boundary: the server (src/app/api/radar/settings/
 * route.ts) re-validates with the same shape via its Zod schema, which is
 * the authoritative check. Client-side rejection only saves a round trip.
 */

/** "omr_" followed by exactly 40 lowercase hex characters. */
export const SUPPORTER_KEY_REGEX = /^omr_[0-9a-f]{40}$/;

/** Whether `key` matches the supporter-key format. No trimming is performed. */
export function isValidSupporterKeyFormat(key: string): boolean {
  return SUPPORTER_KEY_REGEX.test(key);
}