0

Update a JWT Issuer

by
Published Oct 17, 2025

Updates the JWT Issuer configuration Can be used by the following roles assigned at the organization scope: - ORG_ADMIN

Script cockroachdb Verified

The script

Submitted by hugo697 Bun
Verified 235 days ago
1
//native
2
type Cockroachdb = {
3
  token: string;
4
};
5
/**
6
 * Update a JWT Issuer
7
 * Updates the JWT Issuer configuration
8

9
Can be used by the following roles assigned at the organization scope:
10
- ORG_ADMIN
11

12
 */
13
export async function main(
14
  auth: Cockroachdb,
15
  id: string,
16
  body: {
17
    audience?: string;
18
    claim?: string;
19
    identity_map?: { cc_identity: string; token_identity: string }[];
20
    issuer_url?: string;
21
    jwks?: string;
22
  },
23
) {
24
  const url = new URL(`https://cockroachlabs.cloud/api/v1/jwt-issuers/${id}`);
25

26
  const response = await fetch(url, {
27
    method: "PATCH",
28
    headers: {
29
      "Content-Type": "application/json",
30
      Authorization: "Bearer " + auth.token,
31
    },
32
    body: JSON.stringify(body),
33
  });
34
  if (!response.ok) {
35
    const text = await response.text();
36
    throw new Error(`${response.status} ${text}`);
37
  }
38
  return await response.json();
39
}
40