type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* List SSL Configurations
* List, search, and filter all of your custom SSL certificates. The higher priority will break ties across overlapping 'legacy_custom' certificates, but 'legacy_custom' certificates will always supercede 'sni_custom' certificates.
*/
export async function main(
auth: Cloudflare,
zone_identifier: string,
page: string | undefined,
per_page: string | undefined,
match: "any" | "all" | undefined,
status:
| "active"
| "expired"
| "deleted"
| "pending"
| "initializing"
| undefined
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/custom_certificates`
);
for (const [k, v] of [
["page", page],
["per_page", per_page],
["match", match],
["status", status],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 383 days ago
type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* List SSL Configurations
* List, search, and filter all of your custom SSL certificates. The higher priority will break ties across overlapping 'legacy_custom' certificates, but 'legacy_custom' certificates will always supercede 'sni_custom' certificates.
*/
export async function main(
auth: Cloudflare,
zone_identifier: string,
page: string | undefined,
per_page: string | undefined,
match: "any" | "all" | undefined,
status:
| "active"
| "expired"
| "deleted"
| "pending"
| "initializing"
| undefined
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/custom_certificates`
);
for (const [k, v] of [
["page", page],
["per_page", per_page],
["match", match],
["status", status],
]) {
if (v !== undefined && v !== "") {
url.searchParams.append(k, v);
}
}
const response = await fetch(url, {
method: "GET",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
Authorization: "Bearer " + auth.token,
},
body: undefined,
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 920 days ago