//native
type Circleci = {
token: string
}
/**
* Delete org-level claims
* Deletes org-level custom claims of OIDC identity tokens
*/
export async function main(auth: Circleci, orgID: string, claims: string | undefined) {
const url = new URL(`https://circleci.com/api/v2/org/${orgID}/oidc-custom-claims`)
for (const [k, v] of [['claims', claims]]) {
if (v !== undefined && v !== '' && k !== undefined) {
url.searchParams.append(k, v)
}
}
const response = await fetch(url, {
method: 'DELETE',
headers: {
'Circle-Token': auth.token
},
body: undefined
})
if (!response.ok) {
const text = await response.text()
throw new Error(`${response.status} ${text}`)
}
return await response.json()
}
Submitted by hugo697 536 days ago