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

1.8 KB
Raw Blame
/**
 * PII masking catalog shared by the response sanitizer, the request masker,
 * the settings API and the dashboard panel.
 *
 * The ids are the pattern names of `src/lib/piiSanitizer.ts`. The request-side
 * engine (`src/shared/utils/inputSanitizer.ts`) names one of them differently;
 * `PII_REQUEST_TYPE_ALIASES` maps it back so one selection drives both sides.
 *
 * Masking itself stays opt-in (PII_REDACTION_ENABLED / PII_RESPONSE_SANITIZATION,
 * both default off). Nothing here turns it on.
 */

export const PII_BUILTIN_TYPES = [
  "email",
  "phone_us",
  "phone_br",
  "ssn",
  "credit_card",
  "cpf",
  "cnpj",
  "ip_address",
  "ipv6_address",
  "aws_key",
  "api_key_generic",
] as const;

export type PiiBuiltinType = (typeof PII_BUILTIN_TYPES)[number];

/** Request-side pattern name → catalog id. */
export const PII_REQUEST_TYPE_ALIASES: Readonly<Record<string, PiiBuiltinType>> = {
  ssn_us: "ssn",
};

/** Dashboard presets. They only fill the per-type selection; there is no server-side template. */
export const PII_TEMPLATES: ReadonlyArray<{ id: string; types: readonly PiiBuiltinType[] }> = [
  { id: "minimal", types: ["email", "phone_us", "phone_br"] },
  {
    id: "standard",
    types: [
      "email",
      "phone_us",
      "phone_br",
      "cpf",
      "cnpj",
      "credit_card",
      "ip_address",
      "aws_key",
      "api_key_generic",
    ],
  },
  { id: "financial", types: ["credit_card", "cpf", "cnpj", "aws_key", "api_key_generic"] },
  { id: "brazilian", types: ["cpf", "cnpj", "phone_br", "email"] },
  { id: "usa", types: ["ssn", "phone_us", "email"] },
  { id: "full", types: [...PII_BUILTIN_TYPES] },
];

export const PII_CUSTOM_PATTERN_LIMITS = {
  maxPatterns: 20,
  maxPatternLength: 500,
  maxNameLength: 80,
  maxIdLength: 64,
  /** UTF-8 bytes accepted by the pattern test endpoint. */
  maxSampleBytes: 8192,
} as const;