export type SystemAuthRequest = {config?: Record | undefined, description?: string | undefined, external_entropy_access?: boolean | undefined, local?: boolean | undefined, options?: Record | undefined, plugin_name?: string | undefined, plugin_version?: string | undefined, seal_wrap?: boolean | undefined, type?: string | undefined}; export type CreateApiSysAuthPathArgs = {body: SystemAuthRequest}; export type CreateApiSysAuthPathOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Enables a new auth method. * * POST /sys/auth/{path} */ export const createApiSysAuthPath = async (args: CreateApiSysAuthPathArgs, options: CreateApiSysAuthPathOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/sys/auth/${encodeURIComponent(String(args.path))}${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 };