Spaces:
Runtime error
Runtime error
File size: 3,695 Bytes
cd8bd0a | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 | import { z } from "zod";
export const freeProxySourceSchema = z.enum(["1proxy", "proxifly", "iplocate"]);
export const freeProxyListSchema = z.object({
sources: z
.string()
.optional()
.transform((val) => (val ? val.split(",").filter(Boolean) : undefined))
.pipe(z.array(freeProxySourceSchema).optional()),
protocol: z.enum(["http", "https", "socks4", "socks5"]).optional(),
country: z
.string()
.max(2)
.optional()
.transform((v) => v?.toUpperCase()),
minQuality: z.coerce.number().int().min(0).max(100).optional(),
limit: z.coerce.number().int().min(1).max(1000).optional(),
offset: z.coerce.number().int().min(0).optional(),
onlyNotInPool: z
.string()
.optional()
.transform((v) => v === "1" || v === "true"),
});
export const freeProxySyncSchema = z.object({
sources: z.array(freeProxySourceSchema).optional(),
});
export const freeProxyBulkAddSchema = z.object({
ids: z.array(z.string().uuid()).min(1).max(100),
});
export const denoDeploySchema = z.object({
// Deno Deploy Organization Tokens are prefixed `ddo_` followed by an opaque
// base-58/64-ish blob. Reject obviously-malformed inputs early so users get
// clearer feedback than a Deno 401 (and so accidentally pasting an
// OpenAI/Anthropic key is caught at the boundary).
denoToken: z
.string()
.min(20, "Deno Deploy token looks too short")
.max(200)
.regex(
/^[A-Za-z0-9_-]+$/,
"Deno Deploy token must contain only alphanumeric, underscore, or hyphen"
),
orgDomain: z
.string()
.min(3)
.max(253)
// org domain looks like "<slug>.deno.net" — accept any DNS-shaped host so
// we don't have to chase Deno renames; the runtime fetch is the real gate.
.regex(/^[a-z0-9.-]+$/i, "Organization domain must be a DNS-shaped hostname"),
projectName: z
.string()
.min(3)
.max(52)
.regex(/^[a-z0-9-]+$/, "Project name must be lowercase alphanumeric with hyphens")
.default("omniroute-deno-relay"),
});
export const vercelDeploySchema = z.object({
// Vercel personal access tokens are not strictly versioned but follow a
// base-64-ish alphanumeric format. Reject obviously-malformed inputs early
// so users get clearer feedback than a Vercel 401 (and so accidentally
// pasting an OpenAI/Anthropic key is caught at the boundary).
token: z
.string()
.min(20, "Vercel token looks too short")
.max(200)
.regex(
/^[A-Za-z0-9_-]+$/,
"Vercel token must contain only alphanumeric, underscore, or hyphen"
),
projectName: z
.string()
.min(3)
.max(52)
.regex(/^[a-z0-9-]+$/, "Project name must be lowercase alphanumeric with hyphens")
.default("omniroute-relay"),
});
export const cloudflareDeploySchema = z.object({
// Cloudflare Account ID is a 32-char lowercase hex string. Reject anything
// obviously malformed so users get clearer feedback than a Cloudflare 401/404.
accountId: z
.string()
.min(8, "Cloudflare Account ID looks too short")
.max(64)
.regex(
/^[a-f0-9]+$/,
"Cloudflare Account ID must be lowercase hex"
),
// Cloudflare API tokens are opaque alphanumeric (40+ chars) — same alphabet
// we accept for Vercel tokens; constrain length to catch paste accidents.
apiToken: z
.string()
.min(20, "Cloudflare API token looks too short")
.max(200)
.regex(
/^[A-Za-z0-9_-]+$/,
"Cloudflare API token must contain only alphanumeric, underscore, or hyphen"
),
projectName: z
.string()
.min(3)
.max(52)
.regex(/^[a-z0-9-]+$/, "Worker name must be lowercase alphanumeric with hyphens")
.default("omniroute-relay"),
});
|