export type RevokeRequest = {token: string, token_type_hint?: (string | null) | undefined}; export type CreateApiV2AuthRevokeArgs = {body: RevokeRequest}; export type CreateApiV2AuthRevokeOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Revoke a refresh token * * POST /v2/auth/revoke */ export const createApiV2AuthRevoke = async (args: CreateApiV2AuthRevokeArgs, options: CreateApiV2AuthRevokeOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v2/auth/revoke${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };