export type GetApiAuthTokenAccessorsArgs = {list: 'true'}; export type GetApiAuthTokenAccessorsOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * List token accessors, which can then be * be used to iterate and discover their properties * or revoke them. Because this can be used to * cause a denial of service, this endpoint * requires 'sudo' capability in addition to * 'list'. * * GET /auth/token/accessors/ */ export const getApiAuthTokenAccessors = async (args: GetApiAuthTokenAccessorsArgs, options: GetApiAuthTokenAccessorsOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() if (args.list != null) query.append("list", String(args.list)) const url = `${baseUrl.replace(/\/+$/, '')}/auth/token/accessors/${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };