export type UUID4 = unknown; export type Password = string; export type UpdateApiPasswordArgs = {body: {user_id: UUID4, password: Password}}; export type UpdateApiPasswordOptions = {baseUrl?: string | undefined, CookieAuth?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create/Set a password * * PUT /password * * Also accepts auth: BearerTokenAuth */ export const updateApiPassword = async (args: UpdateApiPasswordArgs, options?: UpdateApiPasswordOptions) => { const {baseUrl = "https://.hanko.io/admin", fetch: fetchFn = fetch, CookieAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (CookieAuth !== undefined) cookies.push("hanko=" + encodeURIComponent(CookieAuth)) const url = `${baseUrl.replace(/\/+$/, '')}/password${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "PUT", 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 };