type Cloudflare = {
token: string;
email: string;
key: string;
};
/**
* Edit Custom Hostname
* Modify SSL configuration for a custom hostname. When sent with SSL config that matches existing config, used to indicate that hostname should pass domain control validation (DCV). Can also be used to change validation type, e.g., from 'http' to 'email'.
*/
export async function main(
auth: Cloudflare,
identifier: string,
zone_identifier: string,
body: {
custom_metadata?: { key?: string; [k: string]: unknown };
custom_origin_server?: string;
custom_origin_sni?: string;
ssl?: {
bundle_method?: "ubiquitous" | "optimal" | "force";
certificate_authority?: "digicert" | "google" | "lets_encrypt";
custom_certificate?: string;
custom_key?: string;
method?: "http" | "txt" | "email";
settings?: {
ciphers?: string[];
early_hints?: "on" | "off";
http2?: "on" | "off";
min_tls_version?: "1.0" | "1.1" | "1.2" | "1.3";
tls_1_3?: "on" | "off";
[k: string]: unknown;
};
type?: "dv";
wildcard?: boolean;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/custom_hostnames/${identifier}`
);
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;
};
/**
* Edit Custom Hostname
* Modify SSL configuration for a custom hostname. When sent with SSL config that matches existing config, used to indicate that hostname should pass domain control validation (DCV). Can also be used to change validation type, e.g., from 'http' to 'email'.
*/
export async function main(
auth: Cloudflare,
identifier: string,
zone_identifier: string,
body: {
custom_metadata?: { key?: string; [k: string]: unknown };
custom_origin_server?: string;
custom_origin_sni?: string;
ssl?: {
bundle_method?: "ubiquitous" | "optimal" | "force";
certificate_authority?: "digicert" | "google" | "lets_encrypt";
custom_certificate?: string;
custom_key?: string;
method?: "http" | "txt" | "email";
settings?: {
ciphers?: string[];
early_hints?: "on" | "off";
http2?: "on" | "off";
min_tls_version?: "1.0" | "1.1" | "1.2" | "1.3";
tls_1_3?: "on" | "off";
[k: string]: unknown;
};
type?: "dv";
wildcard?: boolean;
[k: string]: unknown;
};
[k: string]: unknown;
}
) {
const url = new URL(
`https://api.cloudflare.com/client/v4/zones/${zone_identifier}/custom_hostnames/${identifier}`
);
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