1 | |
2 | type Vercel = { |
3 | token: string; |
4 | }; |
5 | |
6 | * Remove System Bypass Rule |
7 | * Remove system bypass rules |
8 | */ |
9 | export async function main( |
10 | auth: Vercel, |
11 | projectId: string | undefined, |
12 | teamId: string | undefined, |
13 | slug: string | undefined, |
14 | body: { |
15 | domain?: string; |
16 | projectScope?: false | true; |
17 | sourceIp?: string; |
18 | allSources?: false | true; |
19 | note?: string; |
20 | } & {}, |
21 | ) { |
22 | const url = new URL(`https://api.vercel.com/v1/security/firewall/bypass`); |
23 | for (const [k, v] of [ |
24 | ["projectId", projectId], |
25 | ["teamId", teamId], |
26 | ["slug", slug], |
27 | ]) { |
28 | if (v !== undefined && v !== "" && k !== undefined) { |
29 | url.searchParams.append(k, v); |
30 | } |
31 | } |
32 | const response = await fetch(url, { |
33 | method: "DELETE", |
34 | headers: { |
35 | "Content-Type": "application/json", |
36 | Authorization: "Bearer " + auth.token, |
37 | }, |
38 | body: JSON.stringify(body), |
39 | }); |
40 | if (!response.ok) { |
41 | const text = await response.text(); |
42 | throw new Error(`${response.status} ${text}`); |
43 | } |
44 | return await response.json(); |
45 | } |
46 |
|