export type EnumRiskAcceptance = 'accepted' | 'unaccepted' | 'all' | ''; export type ApiParamsQuerySortBy = string; export type GetApiApiV2DomainsDomainIdAttackPathFindingsArgs = {finding: string, filterAccepted?: EnumRiskAcceptance | undefined, sort_by?: ApiParamsQuerySortBy | undefined}; export type GetApiApiV2DomainsDomainIdAttackPathFindingsOptions = {baseUrl: string, JWTBearerToken?: string | undefined, fetch?: typeof fetch | undefined}; /** * Export attack path findings * * GET /api/v2/domains/{domain_id}/attack-path-findings * * Also accepts auth: SignedRequest + RequestDate + HMACSignature */ export const getApiApiV2DomainsDomainIdAttackPathFindings = async (args: GetApiApiV2DomainsDomainIdAttackPathFindingsArgs, options: GetApiApiV2DomainsDomainIdAttackPathFindingsOptions) => { const {baseUrl, fetch: fetchFn = fetch, JWTBearerToken} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('accept', "text/csv") if (args.finding != null) query.append("finding", String(args.finding)) if (args.filterAccepted != null) query.append("filterAccepted", String(args.filterAccepted)) if (args.sort_by != null) query.append("sort_by", String(args.sort_by)) if (JWTBearerToken !== undefined) headers.set('authorization', `Bearer ${JWTBearerToken}`) const url = `${baseUrl.replace(/\/+$/, '')}/api/v2/domains/${encodeURIComponent(String(args.domain_id))}/attack-path-findings${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.text() };