Edits history of script submission #11957 for ' Create a JWT template (clerk)'

  • bun
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    type Clerk = {
      apiKey: string;
    };
    /**
     * Create a JWT template
     * Create a new JWT template
     */
    export async function main(
      auth: Clerk,
      body: {
        name?: string;
        claims?: {};
        lifetime?: number;
        allowed_clock_skew?: number;
        custom_signing_key?: false | true;
        signing_algorithm?: string;
        signing_key?: string;
      },
    ) {
      const url = new URL(`https://api.clerk.com/v1/jwt_templates`);
    
      const response = await fetch(url, {
        method: "POST",
        headers: {
          "Content-Type": "application/json",
          Authorization: "Bearer " + auth.apiKey,
        },
        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 428 days ago