export type CreateApiLibsGraniteSecurityPostSslSetupHtmlArgs = {keystorePassword: string, keystorePasswordConfirm: string, truststorePassword: string, truststorePasswordConfirm: string, httpsHostname: string, httpsPort: string, body: BodyInit}; export type CreateApiLibsGraniteSecurityPostSslSetupHtmlOptions = {baseUrl: string, aemAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * POST /libs/granite/security/post/sslSetup.html */ export const createApiLibsGraniteSecurityPostSslSetupHtml = async (args: CreateApiLibsGraniteSecurityPostSslSetupHtmlArgs, options: CreateApiLibsGraniteSecurityPostSslSetupHtmlOptions) => { const {baseUrl, fetch: fetchFn = fetch, aemAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/plain") if (args.keystorePassword != null) query.append("keystorePassword", String(args.keystorePassword)) if (args.keystorePasswordConfirm != null) query.append("keystorePasswordConfirm", String(args.keystorePasswordConfirm)) if (args.truststorePassword != null) query.append("truststorePassword", String(args.truststorePassword)) if (args.truststorePasswordConfirm != null) query.append("truststorePasswordConfirm", String(args.truststorePasswordConfirm)) if (args.httpsHostname != null) query.append("httpsHostname", String(args.httpsHostname)) if (args.httpsPort != null) query.append("httpsPort", String(args.httpsPort)) if (aemAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${aemAuth.username}:${aemAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/libs/granite/security/post/sslSetup.html${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: args.body}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.text() };