export type ResetPasswordSchema = {password: string, repeat_password: string}; export type UpdateApiV1PasswordResetResetHashArgs = {reset_hash: string, body: ResetPasswordSchema}; export type UpdateApiV1PasswordResetResetHashOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Changes password to a new one * * PUT /v1/password/reset/{reset_hash}/ */ export const updateApiV1PasswordResetResetHash = async (args: UpdateApiV1PasswordResetResetHashArgs, options: UpdateApiV1PasswordResetResetHashOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/v1/password/reset/${encodeURIComponent(String(args.reset_hash))}/${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 };