0

List all JWT Issuers

by
Published Oct 17, 2025

Lists all the JWT Issuer configurations registered for the CockroachDB Cloud organization 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
 * List all JWT Issuers
7
 * Lists all the JWT Issuer configurations registered for the CockroachDB Cloud organization
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
  pagination_page: string | undefined,
16
  pagination_limit: string | undefined,
17
  pagination_as_of_time: string | undefined,
18
  pagination_sort_order: "ASC" | "DESC" | undefined,
19
) {
20
  const url = new URL(`https://cockroachlabs.cloud/api/v1/jwt-issuers`);
21
  for (const [k, v] of [
22
    ["pagination.page", pagination_page],
23
    ["pagination.limit", pagination_limit],
24
    ["pagination.as_of_time", pagination_as_of_time],
25
    ["pagination.sort_order", pagination_sort_order],
26
  ]) {
27
    if (v !== undefined && v !== "" && k !== undefined) {
28
      url.searchParams.append(k, v);
29
    }
30
  }
31
  const response = await fetch(url, {
32
    method: "GET",
33
    headers: {
34
      Authorization: "Bearer " + auth.token,
35
    },
36
    body: undefined,
37
  });
38
  if (!response.ok) {
39
    const text = await response.text();
40
    throw new Error(`${response.status} ${text}`);
41
  }
42
  return await response.json();
43
}
44