0

Read System Bypass

by
Published Apr 8, 2025

Retrieve the system bypass rules configured for the specified project

Script vercel Verified

The script

Submitted by hugo697 Bun
Verified 428 days ago
1
//native
2
type Vercel = {
3
  token: string;
4
};
5
/**
6
 * Read System Bypass
7
 * Retrieve the system bypass rules configured for the specified project
8
 */
9
export async function main(
10
  auth: Vercel,
11
  projectId: string | undefined,
12
  limit: string | undefined,
13
  sourceIp: string | undefined,
14
  domain: string | undefined,
15
  projectScope: string | undefined,
16
  offset: string | undefined,
17
  teamId: string | undefined,
18
  slug: string | undefined,
19
) {
20
  const url = new URL(`https://api.vercel.com/v1/security/firewall/bypass`);
21
  for (const [k, v] of [
22
    ["projectId", projectId],
23
    ["limit", limit],
24
    ["sourceIp", sourceIp],
25
    ["domain", domain],
26
    ["projectScope", projectScope],
27
    ["offset", offset],
28
    ["teamId", teamId],
29
    ["slug", slug],
30
  ]) {
31
    if (v !== undefined && v !== "" && k !== undefined) {
32
      url.searchParams.append(k, v);
33
    }
34
  }
35
  const response = await fetch(url, {
36
    method: "GET",
37
    headers: {
38
      Authorization: "Bearer " + auth.token,
39
    },
40
    body: undefined,
41
  });
42
  if (!response.ok) {
43
    const text = await response.text();
44
    throw new Error(`${response.status} ${text}`);
45
  }
46
  return await response.json();
47
}
48