export type Email = string; export type EmailPasswordTokenDto = {email?: Email | undefined, password?: string | undefined, token?: string | undefined}; export type CreateApiAuthV1UsersResetPasswordArgs = {body: EmailPasswordTokenDto}; export type CreateApiAuthV1UsersResetPasswordOptions = {baseUrl: string, fetch?: typeof fetch | undefined}; /** * Change password with token * * POST /auth/v1/users/reset_password */ export const createApiAuthV1UsersResetPassword = async (args: CreateApiAuthV1UsersResetPasswordArgs, options: CreateApiAuthV1UsersResetPasswordOptions) => { const {baseUrl, fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") const url = `${baseUrl.replace(/\/+$/, '')}/auth/v1/users/reset_password${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 };