Edits history of script submission #5006 for ' Edit SSL Certificate Pack Validation Method (cloudflare)'

  • nativets
    One script reply has been approved by the moderators
    Ap­pro­ved
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * Edit SSL Certificate Pack Validation Method
     * Edit SSL validation method for a certificate pack. A PATCH request will request an immediate validation check on any certificate, and return the updated status. If a validation method is provided, the validation will be immediately attempted using that method.
     */
    export async function main(
      auth: Cloudflare,
      cert_pack_uuid: string,
      zone_identifier: string,
      body: {
        validation_method: "http" | "cname" | "txt" | "email";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.cloudflare.com/client/v4/zones/${zone_identifier}/ssl/verification/${cert_pack_uuid}`
      );
    
      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

  • nativets
    type Cloudflare = {
      token: string;
      email: string;
      key: string;
    };
    /**
     * Edit SSL Certificate Pack Validation Method
     * Edit SSL validation method for a certificate pack. A PATCH request will request an immediate validation check on any certificate, and return the updated status. If a validation method is provided, the validation will be immediately attempted using that method.
     */
    export async function main(
      auth: Cloudflare,
      cert_pack_uuid: string,
      zone_identifier: string,
      body: {
        validation_method: "http" | "cname" | "txt" | "email";
        [k: string]: unknown;
      }
    ) {
      const url = new URL(
        `https://api.cloudflare.com/client/v4/zones/${zone_identifier}/ssl/verification/${cert_pack_uuid}`
      );
    
      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