//native
type Cockroachdb = {
token: string;
};
/**
* Add a JWT Issuer
* Registers a JWT Issuer with the CockroachDB Cloud to allow verifying JWTs during API authentication
Can be used by the following roles assigned at the organization scope:
- ORG_ADMIN
*/
export async function main(
auth: Cockroachdb,
body: {
audience: string;
claim?: string;
identity_map?: { cc_identity: string; token_identity: string }[];
issuer_url: string;
jwks?: string;
},
) {
const url = new URL(`https://cockroachlabs.cloud/api/v1/jwt-issuers`);
const response = await fetch(url, {
method: "POST",
headers: {
"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 235 days ago