export type CreateApiCrxExplorerUiSetpasswordJspArgs = {old: string, plain: string, verify: string}; export type CreateApiCrxExplorerUiSetpasswordJspOptions = {baseUrl: string, aemAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * POST /crx/explorer/ui/setpassword.jsp */ export const createApiCrxExplorerUiSetpasswordJsp = async (args: CreateApiCrxExplorerUiSetpasswordJspArgs, options: CreateApiCrxExplorerUiSetpasswordJspOptions) => { const {baseUrl, fetch: fetchFn = fetch, aemAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.old != null) query.append("old", String(args.old)) if (args.plain != null) query.append("plain", String(args.plain)) if (args.verify != null) query.append("verify", String(args.verify)) if (aemAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${aemAuth.username}:${aemAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/crx/explorer/ui/setpassword.jsp${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };