export type CreateApiV1AuthRefreshArgs = {body: {refresh_token?: string | undefined}}; export type CreateApiV1AuthRefreshOptions = {baseUrl?: string | undefined, AccessToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * # Regenerating refresh token * * POST /v1/auth/refresh */ export const createApiV1AuthRefresh = async (args: CreateApiV1AuthRefreshArgs, options?: CreateApiV1AuthRefreshOptions) => { const {baseUrl = "https://api.picussecurity.com", fetch: fetchFn = fetch, AccessToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (AccessToken !== undefined) headers.set("Authorization", AccessToken) const url = `${baseUrl.replace(/\/+$/, '')}/v1/auth/refresh${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 };