type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Change Challenge TTL setting
* Specify how long a visitor is allowed access to your site after successfully completing a challenge (such as a CAPTCHA). After the TTL has expired the visitor will have to complete a new challenge. We recommend a 15 - 45 minute setting and will attempt to honor any setting above 45 minutes. (https://support.cloudflare.com/hc/en-us/articles/200170136).
*/
export async function main(
auth: Cloudflare,
zone_identifier: string,
body: {
value:
| 300
| 900
| 1800
| 2700
| 3600
| 7200
| 10800
| 14400
| 28800
| 57600
| 86400
| 604800
| 2592000
| 31536000;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/settings/challenge_ttl`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
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;
};
/**
* Change Challenge TTL setting
* Specify how long a visitor is allowed access to your site after successfully completing a challenge (such as a CAPTCHA). After the TTL has expired the visitor will have to complete a new challenge. We recommend a 15 - 45 minute setting and will attempt to honor any setting above 45 minutes. (https://support.cloudflare.com/hc/en-us/articles/200170136).
*/
export async function main(
auth: Cloudflare,
zone_identifier: string,
body: {
value:
| 300
| 900
| 1800
| 2700
| 3600
| 7200
| 10800
| 14400
| 28800
| 57600
| 86400
| 604800
| 2592000
| 31536000;
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/settings/challenge_ttl`
);
const response = await fetch(url, {
method: "PATCH",
headers: {
"X-AUTH-EMAIL": auth.email,
"X-AUTH-KEY": auth.key,
"Content-Type": "application/json",
Authorization: "Bearer " + auth.token,
},
body: JSON.stringify(body),
});
if (!response.ok) {
const text = await response.text();
throw new Error(`${response.status} ${text}`);
}
return await response.json();
}
Submitted by hugo697 920 days ago