export type GetApiIntermediatePathAuthorizableIdKeystoreStoreP12Args = {intermediatePath: string, authorizableId: string}; export type GetApiIntermediatePathAuthorizableIdKeystoreStoreP12Options = {baseUrl: string, aemAuth?: {username: string, password: string} | undefined, fetch?: typeof fetch | undefined}; /** * GET /{intermediatePath}/{authorizableId}/keystore/store.p12 */ export const getApiIntermediatePathAuthorizableIdKeystoreStoreP12 = async (args: GetApiIntermediatePathAuthorizableIdKeystoreStoreP12Args, options: GetApiIntermediatePathAuthorizableIdKeystoreStoreP12Options) => { const {baseUrl, fetch: fetchFn = fetch, aemAuth} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "application/octet-stream") if (aemAuth !== undefined) headers.set('authorization', `Basic ${btoa(`${aemAuth.username}:${aemAuth.password}`)}`) const url = `${baseUrl.replace(/\/+$/, '')}/${encodeURIComponent(String(args.intermediatePath))}/${encodeURIComponent(String(args.authorizableId))}/keystore/store.p12${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "GET", headers}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return res.blob() };