by hugo697 ยท 11/16/2023
1
type Cloudflare = {
2
token: string;
3
email: string;
4
key: string;
5
};
6
/**
7
* User Details
8
*
9
*/
10
export async function main(auth: Cloudflare) {
11
const url = new URL(`https://api.cloudflare.com/client/v4/user`);
12
13
const response = await fetch(url, {
14
method: "GET",
15
headers: {
16
"X-AUTH-EMAIL": auth.email,
17
"X-AUTH-KEY": auth.key,
18
Authorization: "Bearer " + auth.token,
19
},
20
body: undefined,
21
});
22
if (!response.ok) {
23
const text = await response.text();
24
throw new Error(`${response.status} ${text}`);
25
}
26
return await response.json();
27
28