@chainpatrol/sdk 0.11.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,31 @@
1
1
  # @chainpatrol/sdk
2
2
 
3
+ ## 1.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - 2c03d10: Rename the `TRIAL` organization subscription status to `POC` everywhere, matching the term we use in our CRM. The product status, API response payloads, and CLI flags now say `POC` in place of `TRIAL`.
8
+
9
+ **Breaking changes for SDK and CLI consumers:**
10
+
11
+ - `/user/orgs` and `/user/orgs/{slug}` now return `"subscriptionStatus": "POC"` instead of `"TRIAL"`.
12
+ - `chainpatrol orgs list --subscription-status POC` replaces `--subscription-status TRIAL` (the alias `TRIAL` is no longer accepted).
13
+ - `UserOrgsSubscriptionStatus` SDK type is now `"PROSPECT" | "POC" | "ACTIVE" | "INTEGRATION"`.
14
+
15
+ The underlying database column value is unchanged (`"trial"` via Prisma `@map`), so no data migration is required.
16
+
17
+ ## 0.12.0
18
+
19
+ ### Minor Changes
20
+
21
+ - 5a1208e: Expose organization trademark registrations and legal documents (Letter of Authorization, Power of Attorney) on the API, SDK, and CLI so callers can answer questions like "which customers have their trademarks added?" from one place.
22
+
23
+ - `/user/orgs` and `/user/orgs/{slug}` now include `legalDocuments` (`{ letterOfAuthorization, powerOfAttorney }`, each `{ present, fileName, fileUrl }`) and `trademarkRegistrations` (full list with issuing office, registration number, page URL, and a `certificateFileUrl` link to the certificate PDF when uploaded).
24
+ - `/organization/brands` adds the same `legalDocuments` and `trademarkRegistrations` per brand, plus a `useOrganizationDocs` flag that signals brand-level fallback to org-level docs.
25
+ - `chainpatrol orgs list`, `chainpatrol orgs get`, and `chainpatrol brands list` print the new fields in human / markdown / CSV / JSON output, including the direct view links for the documents and certificates.
26
+
27
+ Backing work in `@chainpatrol/external-trpc` and `@chainpatrol/validation` adds the new Zod schemas and Kysely helpers; both are private packages and don't need version bumps.
28
+
3
29
  ## 0.11.0
4
30
 
5
31
  ### Minor Changes
@@ -556,6 +556,26 @@ interface OrganizationAssetGroupsListResult {
556
556
  groups: AssetGroupItem[];
557
557
  }
558
558
  type BrandType = "ORGANIZATION" | "INDIVIDUAL";
559
+ interface BrandLegalDocument {
560
+ present: boolean;
561
+ fileName: string | null;
562
+ fileUrl: string | null;
563
+ }
564
+ interface BrandLegalDocuments {
565
+ letterOfAuthorization: BrandLegalDocument;
566
+ powerOfAttorney: BrandLegalDocument;
567
+ }
568
+ interface BrandTrademarkRegistrationItem {
569
+ id: number;
570
+ brandName: string;
571
+ trademarkOffice: string;
572
+ registrationNumber: string;
573
+ goodsAndServicesClass: string;
574
+ rightsOwnerName: string | null;
575
+ registrationPageUrl: string | null;
576
+ certificateFileName: string | null;
577
+ certificateFileUrl: string | null;
578
+ }
559
579
  interface BrandItem {
560
580
  id: number;
561
581
  slug: string;
@@ -571,6 +591,9 @@ interface BrandItem {
571
591
  tickers: string[];
572
592
  brandGroupId: number | null;
573
593
  createdAt: string;
594
+ useOrganizationDocs: boolean;
595
+ legalDocuments: BrandLegalDocuments;
596
+ trademarkRegistrations: BrandTrademarkRegistrationItem[];
574
597
  }
575
598
  interface OrganizationBrandsListResult {
576
599
  brands: BrandItem[];
@@ -772,7 +795,7 @@ interface HealthcheckRegistryEntry {
772
795
  interface HealthchecksListResult {
773
796
  checks: HealthcheckRegistryEntry[];
774
797
  }
775
- type UserOrgsSubscriptionStatus = "PROSPECT" | "TRIAL" | "ACTIVE" | "INTEGRATION";
798
+ type UserOrgsSubscriptionStatus = "PROSPECT" | "POC" | "ACTIVE" | "INTEGRATION";
776
799
  type PendingApprovalService = "protection" | "takedowns";
777
800
  interface PendingServiceApproval {
778
801
  service: PendingApprovalService;
@@ -828,13 +851,33 @@ interface UserOrgIntegrations {
828
851
  intercom: boolean;
829
852
  moderation: boolean;
830
853
  }
854
+ interface UserOrgLegalDocument {
855
+ present: boolean;
856
+ fileName: string | null;
857
+ fileUrl: string | null;
858
+ }
859
+ interface UserOrgLegalDocuments {
860
+ letterOfAuthorization: UserOrgLegalDocument;
861
+ powerOfAttorney: UserOrgLegalDocument;
862
+ }
863
+ interface UserOrgTrademarkRegistration {
864
+ id: number;
865
+ brandName: string;
866
+ trademarkOffice: string;
867
+ registrationNumber: string;
868
+ goodsAndServicesClass: string;
869
+ rightsOwnerName: string | null;
870
+ registrationPageUrl: string | null;
871
+ certificateFileName: string | null;
872
+ certificateFileUrl: string | null;
873
+ }
831
874
  interface UserOrg {
832
875
  id: number;
833
876
  name: string;
834
877
  slug: string;
835
878
  avatarUrl: string | null;
836
879
  contactUrl: string | null;
837
- subscriptionStatus: "PROSPECT" | "TRIAL" | "ACTIVE" | "INTEGRATION" | "INACTIVE";
880
+ subscriptionStatus: "PROSPECT" | "POC" | "ACTIVE" | "INTEGRATION" | "INACTIVE";
838
881
  services: {
839
882
  reporting: {
840
883
  active: boolean;
@@ -862,6 +905,8 @@ interface UserOrg {
862
905
  assetTypes: string[];
863
906
  };
864
907
  pendingServiceApprovals: PendingServiceApproval[];
908
+ legalDocuments: UserOrgLegalDocuments;
909
+ trademarkRegistrations: UserOrgTrademarkRegistration[];
865
910
  }
866
911
  interface UserOrgsResult {
867
912
  organizations: UserOrg[];
@@ -918,4 +963,4 @@ declare class ChainPatrolApiClient implements ApiClient {
918
963
  declare function parseIsoDate(value: string | undefined): Date | undefined;
919
964
  declare function parseIsoDateString(value: string | undefined): string | undefined;
920
965
 
921
- export { type ApiClient, type ApiCredential, type AssetCheckInput, type AssetCheckResult, type AssetCheckSourceEntry, type AssetCheckStatus, type AssetGroupItem, type AssetListInput, type AssetListItem, type AssetListResult, type AssetSearchInput, type AssetSearchResult, type AssetSearchResultItem, type BrandItem, type BrandType, ChainPatrolApiClient, type ChainPatrolApiClientOptions, type ConfigEntry, type CredentialProvider, DETECTION_CONFIDENCE_LEVELS, DETECTION_REPORTED_FILTERS, type DetectionConfidence, type DetectionConfigRunInput, type DetectionConfigRunResult, type DetectionConfigUpdateInput, type DetectionConfigUpdateResult, type DetectionConfigValidateInput, type DetectionConfigValidateResult, type DetectionDriftInput, type DetectionDriftResult, type DetectionListInput, type DetectionListItem, type DetectionListResult, type DetectionReportStatus, type DetectionReportedFilter, type DetectionSource, type HealthcheckCategory, type HealthcheckFinding, type HealthcheckRegistryEntry, type HealthcheckResult, type HealthcheckSeverity, type HealthchecksListResult, LIVENESS_FILTER_VALUES, LIVENESS_STATUSES, type LivenessFilterValue, type LivenessStatus, type MetricsBreakdownInput, type MetricsBreakdownResult, type MetricsFoundInput, type MetricsFoundResult, type MetricsSummaryInput, type MetricsSummaryResult, ORGANIZATION_METRICS_INCLUDE_FIELDS, type OperationsQueuesSnapshotInput, type OperationsQueuesSnapshotResult, type OrganizationAssetGroupsListResult, type OrganizationAssetItem, type OrganizationAssetsListInput, type OrganizationAssetsListResult, type OrganizationBrandsListResult, type OrganizationMetricsIncludeField, type OrganizationMetricsInput, type OrganizationMetricsResult, type OrganizationMetricsResultMetrics, type OrganizationMetricsServicesFilter, type OrganizationReportsListInput, type OrganizationReportsListResult, type PendingApprovalService, type PendingServiceApproval, REPORT_REVIEW_DECISIONS, REPORT_STATUSES, type ReportAssetInput, type ReportCreateInput, type ReportCreateResult, type ReportReviewDecision, type ReportStatus, type ReportsSearchInput, type ReportsSearchResult, type ReportsSearchResultItem, TAKEDOWN_SORT_KEYS, TAKEDOWN_STATUSES, type TakedownItem, type TakedownSortKey, type TakedownStatus, type TakedownsListInput, type TakedownsListResult, type ThreatItem, type ThreatsListInput, type ThreatsListResult, type UserMeResult, type UserOrg, type UserOrgGetInput, type UserOrgGetResult, type UserOrgIntegrations, type UserOrgsInput, type UserOrgsObligatoryAdminApprovalFilter, type UserOrgsPendingServiceApprovalFilter, type UserOrgsResult, type UserOrgsServiceFilters, type UserOrgsSubscriptionStatus, type ValidateApiKeyResult, WATCHLIST_FILTER_VALUES, type WatchlistFilterValue, parseIsoDate, parseIsoDateString, staticApiKey, staticBearerToken };
966
+ export { type ApiClient, type ApiCredential, type AssetCheckInput, type AssetCheckResult, type AssetCheckSourceEntry, type AssetCheckStatus, type AssetGroupItem, type AssetListInput, type AssetListItem, type AssetListResult, type AssetSearchInput, type AssetSearchResult, type AssetSearchResultItem, type BrandItem, type BrandLegalDocument, type BrandLegalDocuments, type BrandTrademarkRegistrationItem, type BrandType, ChainPatrolApiClient, type ChainPatrolApiClientOptions, type ConfigEntry, type CredentialProvider, DETECTION_CONFIDENCE_LEVELS, DETECTION_REPORTED_FILTERS, type DetectionConfidence, type DetectionConfigRunInput, type DetectionConfigRunResult, type DetectionConfigUpdateInput, type DetectionConfigUpdateResult, type DetectionConfigValidateInput, type DetectionConfigValidateResult, type DetectionDriftInput, type DetectionDriftResult, type DetectionListInput, type DetectionListItem, type DetectionListResult, type DetectionReportStatus, type DetectionReportedFilter, type DetectionSource, type HealthcheckCategory, type HealthcheckFinding, type HealthcheckRegistryEntry, type HealthcheckResult, type HealthcheckSeverity, type HealthchecksListResult, LIVENESS_FILTER_VALUES, LIVENESS_STATUSES, type LivenessFilterValue, type LivenessStatus, type MetricsBreakdownInput, type MetricsBreakdownResult, type MetricsFoundInput, type MetricsFoundResult, type MetricsSummaryInput, type MetricsSummaryResult, ORGANIZATION_METRICS_INCLUDE_FIELDS, type OperationsQueuesSnapshotInput, type OperationsQueuesSnapshotResult, type OrganizationAssetGroupsListResult, type OrganizationAssetItem, type OrganizationAssetsListInput, type OrganizationAssetsListResult, type OrganizationBrandsListResult, type OrganizationMetricsIncludeField, type OrganizationMetricsInput, type OrganizationMetricsResult, type OrganizationMetricsResultMetrics, type OrganizationMetricsServicesFilter, type OrganizationReportsListInput, type OrganizationReportsListResult, type PendingApprovalService, type PendingServiceApproval, REPORT_REVIEW_DECISIONS, REPORT_STATUSES, type ReportAssetInput, type ReportCreateInput, type ReportCreateResult, type ReportReviewDecision, type ReportStatus, type ReportsSearchInput, type ReportsSearchResult, type ReportsSearchResultItem, TAKEDOWN_SORT_KEYS, TAKEDOWN_STATUSES, type TakedownItem, type TakedownSortKey, type TakedownStatus, type TakedownsListInput, type TakedownsListResult, type ThreatItem, type ThreatsListInput, type ThreatsListResult, type UserMeResult, type UserOrg, type UserOrgGetInput, type UserOrgGetResult, type UserOrgIntegrations, type UserOrgLegalDocument, type UserOrgLegalDocuments, type UserOrgTrademarkRegistration, type UserOrgsInput, type UserOrgsObligatoryAdminApprovalFilter, type UserOrgsPendingServiceApprovalFilter, type UserOrgsResult, type UserOrgsServiceFilters, type UserOrgsSubscriptionStatus, type ValidateApiKeyResult, WATCHLIST_FILTER_VALUES, type WatchlistFilterValue, parseIsoDate, parseIsoDateString, staticApiKey, staticBearerToken };
@@ -556,6 +556,26 @@ interface OrganizationAssetGroupsListResult {
556
556
  groups: AssetGroupItem[];
557
557
  }
558
558
  type BrandType = "ORGANIZATION" | "INDIVIDUAL";
559
+ interface BrandLegalDocument {
560
+ present: boolean;
561
+ fileName: string | null;
562
+ fileUrl: string | null;
563
+ }
564
+ interface BrandLegalDocuments {
565
+ letterOfAuthorization: BrandLegalDocument;
566
+ powerOfAttorney: BrandLegalDocument;
567
+ }
568
+ interface BrandTrademarkRegistrationItem {
569
+ id: number;
570
+ brandName: string;
571
+ trademarkOffice: string;
572
+ registrationNumber: string;
573
+ goodsAndServicesClass: string;
574
+ rightsOwnerName: string | null;
575
+ registrationPageUrl: string | null;
576
+ certificateFileName: string | null;
577
+ certificateFileUrl: string | null;
578
+ }
559
579
  interface BrandItem {
560
580
  id: number;
561
581
  slug: string;
@@ -571,6 +591,9 @@ interface BrandItem {
571
591
  tickers: string[];
572
592
  brandGroupId: number | null;
573
593
  createdAt: string;
594
+ useOrganizationDocs: boolean;
595
+ legalDocuments: BrandLegalDocuments;
596
+ trademarkRegistrations: BrandTrademarkRegistrationItem[];
574
597
  }
575
598
  interface OrganizationBrandsListResult {
576
599
  brands: BrandItem[];
@@ -772,7 +795,7 @@ interface HealthcheckRegistryEntry {
772
795
  interface HealthchecksListResult {
773
796
  checks: HealthcheckRegistryEntry[];
774
797
  }
775
- type UserOrgsSubscriptionStatus = "PROSPECT" | "TRIAL" | "ACTIVE" | "INTEGRATION";
798
+ type UserOrgsSubscriptionStatus = "PROSPECT" | "POC" | "ACTIVE" | "INTEGRATION";
776
799
  type PendingApprovalService = "protection" | "takedowns";
777
800
  interface PendingServiceApproval {
778
801
  service: PendingApprovalService;
@@ -828,13 +851,33 @@ interface UserOrgIntegrations {
828
851
  intercom: boolean;
829
852
  moderation: boolean;
830
853
  }
854
+ interface UserOrgLegalDocument {
855
+ present: boolean;
856
+ fileName: string | null;
857
+ fileUrl: string | null;
858
+ }
859
+ interface UserOrgLegalDocuments {
860
+ letterOfAuthorization: UserOrgLegalDocument;
861
+ powerOfAttorney: UserOrgLegalDocument;
862
+ }
863
+ interface UserOrgTrademarkRegistration {
864
+ id: number;
865
+ brandName: string;
866
+ trademarkOffice: string;
867
+ registrationNumber: string;
868
+ goodsAndServicesClass: string;
869
+ rightsOwnerName: string | null;
870
+ registrationPageUrl: string | null;
871
+ certificateFileName: string | null;
872
+ certificateFileUrl: string | null;
873
+ }
831
874
  interface UserOrg {
832
875
  id: number;
833
876
  name: string;
834
877
  slug: string;
835
878
  avatarUrl: string | null;
836
879
  contactUrl: string | null;
837
- subscriptionStatus: "PROSPECT" | "TRIAL" | "ACTIVE" | "INTEGRATION" | "INACTIVE";
880
+ subscriptionStatus: "PROSPECT" | "POC" | "ACTIVE" | "INTEGRATION" | "INACTIVE";
838
881
  services: {
839
882
  reporting: {
840
883
  active: boolean;
@@ -862,6 +905,8 @@ interface UserOrg {
862
905
  assetTypes: string[];
863
906
  };
864
907
  pendingServiceApprovals: PendingServiceApproval[];
908
+ legalDocuments: UserOrgLegalDocuments;
909
+ trademarkRegistrations: UserOrgTrademarkRegistration[];
865
910
  }
866
911
  interface UserOrgsResult {
867
912
  organizations: UserOrg[];
@@ -918,4 +963,4 @@ declare class ChainPatrolApiClient implements ApiClient {
918
963
  declare function parseIsoDate(value: string | undefined): Date | undefined;
919
964
  declare function parseIsoDateString(value: string | undefined): string | undefined;
920
965
 
921
- export { type ApiClient, type ApiCredential, type AssetCheckInput, type AssetCheckResult, type AssetCheckSourceEntry, type AssetCheckStatus, type AssetGroupItem, type AssetListInput, type AssetListItem, type AssetListResult, type AssetSearchInput, type AssetSearchResult, type AssetSearchResultItem, type BrandItem, type BrandType, ChainPatrolApiClient, type ChainPatrolApiClientOptions, type ConfigEntry, type CredentialProvider, DETECTION_CONFIDENCE_LEVELS, DETECTION_REPORTED_FILTERS, type DetectionConfidence, type DetectionConfigRunInput, type DetectionConfigRunResult, type DetectionConfigUpdateInput, type DetectionConfigUpdateResult, type DetectionConfigValidateInput, type DetectionConfigValidateResult, type DetectionDriftInput, type DetectionDriftResult, type DetectionListInput, type DetectionListItem, type DetectionListResult, type DetectionReportStatus, type DetectionReportedFilter, type DetectionSource, type HealthcheckCategory, type HealthcheckFinding, type HealthcheckRegistryEntry, type HealthcheckResult, type HealthcheckSeverity, type HealthchecksListResult, LIVENESS_FILTER_VALUES, LIVENESS_STATUSES, type LivenessFilterValue, type LivenessStatus, type MetricsBreakdownInput, type MetricsBreakdownResult, type MetricsFoundInput, type MetricsFoundResult, type MetricsSummaryInput, type MetricsSummaryResult, ORGANIZATION_METRICS_INCLUDE_FIELDS, type OperationsQueuesSnapshotInput, type OperationsQueuesSnapshotResult, type OrganizationAssetGroupsListResult, type OrganizationAssetItem, type OrganizationAssetsListInput, type OrganizationAssetsListResult, type OrganizationBrandsListResult, type OrganizationMetricsIncludeField, type OrganizationMetricsInput, type OrganizationMetricsResult, type OrganizationMetricsResultMetrics, type OrganizationMetricsServicesFilter, type OrganizationReportsListInput, type OrganizationReportsListResult, type PendingApprovalService, type PendingServiceApproval, REPORT_REVIEW_DECISIONS, REPORT_STATUSES, type ReportAssetInput, type ReportCreateInput, type ReportCreateResult, type ReportReviewDecision, type ReportStatus, type ReportsSearchInput, type ReportsSearchResult, type ReportsSearchResultItem, TAKEDOWN_SORT_KEYS, TAKEDOWN_STATUSES, type TakedownItem, type TakedownSortKey, type TakedownStatus, type TakedownsListInput, type TakedownsListResult, type ThreatItem, type ThreatsListInput, type ThreatsListResult, type UserMeResult, type UserOrg, type UserOrgGetInput, type UserOrgGetResult, type UserOrgIntegrations, type UserOrgsInput, type UserOrgsObligatoryAdminApprovalFilter, type UserOrgsPendingServiceApprovalFilter, type UserOrgsResult, type UserOrgsServiceFilters, type UserOrgsSubscriptionStatus, type ValidateApiKeyResult, WATCHLIST_FILTER_VALUES, type WatchlistFilterValue, parseIsoDate, parseIsoDateString, staticApiKey, staticBearerToken };
966
+ export { type ApiClient, type ApiCredential, type AssetCheckInput, type AssetCheckResult, type AssetCheckSourceEntry, type AssetCheckStatus, type AssetGroupItem, type AssetListInput, type AssetListItem, type AssetListResult, type AssetSearchInput, type AssetSearchResult, type AssetSearchResultItem, type BrandItem, type BrandLegalDocument, type BrandLegalDocuments, type BrandTrademarkRegistrationItem, type BrandType, ChainPatrolApiClient, type ChainPatrolApiClientOptions, type ConfigEntry, type CredentialProvider, DETECTION_CONFIDENCE_LEVELS, DETECTION_REPORTED_FILTERS, type DetectionConfidence, type DetectionConfigRunInput, type DetectionConfigRunResult, type DetectionConfigUpdateInput, type DetectionConfigUpdateResult, type DetectionConfigValidateInput, type DetectionConfigValidateResult, type DetectionDriftInput, type DetectionDriftResult, type DetectionListInput, type DetectionListItem, type DetectionListResult, type DetectionReportStatus, type DetectionReportedFilter, type DetectionSource, type HealthcheckCategory, type HealthcheckFinding, type HealthcheckRegistryEntry, type HealthcheckResult, type HealthcheckSeverity, type HealthchecksListResult, LIVENESS_FILTER_VALUES, LIVENESS_STATUSES, type LivenessFilterValue, type LivenessStatus, type MetricsBreakdownInput, type MetricsBreakdownResult, type MetricsFoundInput, type MetricsFoundResult, type MetricsSummaryInput, type MetricsSummaryResult, ORGANIZATION_METRICS_INCLUDE_FIELDS, type OperationsQueuesSnapshotInput, type OperationsQueuesSnapshotResult, type OrganizationAssetGroupsListResult, type OrganizationAssetItem, type OrganizationAssetsListInput, type OrganizationAssetsListResult, type OrganizationBrandsListResult, type OrganizationMetricsIncludeField, type OrganizationMetricsInput, type OrganizationMetricsResult, type OrganizationMetricsResultMetrics, type OrganizationMetricsServicesFilter, type OrganizationReportsListInput, type OrganizationReportsListResult, type PendingApprovalService, type PendingServiceApproval, REPORT_REVIEW_DECISIONS, REPORT_STATUSES, type ReportAssetInput, type ReportCreateInput, type ReportCreateResult, type ReportReviewDecision, type ReportStatus, type ReportsSearchInput, type ReportsSearchResult, type ReportsSearchResultItem, TAKEDOWN_SORT_KEYS, TAKEDOWN_STATUSES, type TakedownItem, type TakedownSortKey, type TakedownStatus, type TakedownsListInput, type TakedownsListResult, type ThreatItem, type ThreatsListInput, type ThreatsListResult, type UserMeResult, type UserOrg, type UserOrgGetInput, type UserOrgGetResult, type UserOrgIntegrations, type UserOrgLegalDocument, type UserOrgLegalDocuments, type UserOrgTrademarkRegistration, type UserOrgsInput, type UserOrgsObligatoryAdminApprovalFilter, type UserOrgsPendingServiceApprovalFilter, type UserOrgsResult, type UserOrgsServiceFilters, type UserOrgsSubscriptionStatus, type ValidateApiKeyResult, WATCHLIST_FILTER_VALUES, type WatchlistFilterValue, parseIsoDate, parseIsoDateString, staticApiKey, staticBearerToken };
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/api/types.ts","../../src/api/date-utils.ts","../../src/api/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAibO,IAAM,uBAAA,GAA0B,CAAC,SAAA,EAAW,QAAA,EAAU,QAAQ,UAAU;AAGxE,IAAM,eAAA,GAAkB,CAAC,MAAA,EAAQ,aAAA,EAAe,QAAQ;AA2DxD,IAAM,2BAAA,GAA8B,CAAC,MAAA,EAAQ,KAAA,EAAO,UAAU,MAAM;AAIpE,IAAM,0BAAA,GAA6B,CAAC,UAAA,EAAY,cAAc;AAG9D,IAAM,sBAAA,G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,MACV,4BAAA;AAAA,MACA;AAAC,KACH;AAAA,EACF;AAAA,EAEA,sBAAA,GAAyB;AACvB,IAAA,OAAO,IAAA,CAAK,UAAA,CAAyC,sBAAA,EAAwB,EAAE,CAAA;AAAA,EACjF;AAAA,EAEA,cAAA,GAAiB;AACf,IAAA,OAAO,IAAA,CAAK,OAAA,CAAsB,UAAA,EAAY,EAAE,CAAA;AAAA,EAClD;AAAA,EAEA,cAAA,GAAiB;AACf,IAAA,OAAO,IAAA,CAAK,UAAA,CAAiC,WAAA,EAAa,EAAE,CAAA;AAAA,EAC9D;AACF","file":"index.js","sourcesContent":["export type ApiCredential =\n | { kind: \"api-key\"; value: string }\n | { kind: \"bearer\"; value: string };\n\nexport type CredentialProvider = () => ApiCredential | Promise<ApiCredential>;\n\nexport interface ChainPatrolApiClientOptions {\n baseUrl?: string;\n credential: CredentialProvider;\n timeoutMs?: number;\n}\n\nexport interface ConfigEntry {\n id: number;\n title: string;\n status: string;\n cron: string | null;\n config: Record<string, unknown>;\n}\n\nexport interface DetectionSource {\n source: string;\n scope: \"global\" | \"organization\";\n configs: ConfigEntry[];\n}\n\nexport interface ApiClient {\n assetCheck: (input: AssetCheckInput) => Promise<AssetCheckResult>;\n assetSearch: (input: AssetSearchInput) => Promise<AssetSearchResult>;\n listAssets: (input: AssetListInput) => Promise<AssetListResult>;\n listDetectionConfigs: (slug: string) => Promise<DetectionSource[]>;\n updateDetectionConfig: (\n input: DetectionConfigUpdateInput,\n ) => Promise<DetectionConfigUpdateResult>;\n runDetectionConfigs: (\n input: DetectionConfigRunInput,\n ) => Promise<DetectionConfigRunResult>;\n validateDetectionConfigs: (\n input: DetectionConfigValidateInput,\n ) => Promise<DetectionConfigValidateResult>;\n getDetectionDrift: (input: DetectionDriftInput) => Promise<DetectionDriftResult>;\n listDetections: (input: DetectionListInput) => Promise<DetectionListResult>;\n getOperationsQueuesSnapshot: (\n input: OperationsQueuesSnapshotInput,\n ) => Promise<OperationsQueuesSnapshotResult>;\n getMetricsSummary: (input: MetricsSummaryInput) => Promise<MetricsSummaryResult>;\n getMetricsFound: (input: MetricsFoundInput) => Promise<MetricsFoundResult>;\n getMetricsBreakdown: (input: MetricsBreakdownInput) => Promise<MetricsBreakdownResult>;\n createReport: (input: ReportCreateInput) => Promise<ReportCreateResult>;\n listOrganizationReports: (\n input: OrganizationReportsListInput,\n ) => Promise<OrganizationReportsListResult>;\n searchReports: (input: ReportsSearchInput) => Promise<ReportsSearchResult>;\n listTakedowns: (input: TakedownsListInput) => Promise<TakedownsListResult>;\n listThreats: (input: ThreatsListInput) => Promise<ThreatsListResult>;\n getOrganizationMetrics: (\n input: OrganizationMetricsInput,\n ) => Promise<OrganizationMetricsResult>;\n listOrganizationAssets: (\n input: OrganizationAssetsListInput,\n ) => Promise<OrganizationAssetsListResult>;\n listOrganizationAssetGroups: () => Promise<OrganizationAssetGroupsListResult>;\n listOrganizationBrands: () => Promise<OrganizationBrandsListResult>;\n listHealthchecks: () => Promise<HealthchecksListResult>;\n runHealthcheck: (\n endpoint: string,\n input: Record<string, unknown>,\n ) => Promise<HealthcheckResult>;\n getUserOrgs: (input: UserOrgsInput) => Promise<UserOrgsResult>;\n getUserOrg: (input: UserOrgGetInput) => Promise<UserOrgGetResult>;\n getCurrentUser: () => Promise<UserMeResult>;\n validateApiKey: () => Promise<ValidateApiKeyResult>;\n}\n\nexport interface AssetCheckInput {\n content: string;\n}\n\nexport type AssetCheckStatus = \"ALLOWED\" | \"BLOCKED\" | \"UNKNOWN\";\n\nexport interface AssetCheckSourceEntry {\n source: string;\n status: AssetCheckStatus;\n}\n\nexport interface AssetCheckResult {\n status: AssetCheckStatus;\n source: string;\n reason?: string;\n sources: AssetCheckSourceEntry[];\n message?: string;\n code?: string;\n watchStatus?: \"ENABLED\" | \"DISABLED\";\n}\n\nexport interface AssetSearchInput {\n content?: string;\n assetId?: number;\n assetIds?: number[];\n}\n\nexport interface AssetSearchResultItem {\n asset: {\n id: number;\n content: string;\n type: string;\n status: string;\n watchStatus: string;\n createdAt: string;\n updatedAt: string;\n } | null;\n reports: Array<{\n id: number;\n title: string | null;\n status: string;\n createdAt: string;\n }>;\n takedown: {\n id: number;\n status: string;\n createdAt: string;\n updatedAt: string;\n tasks: Array<{\n id: number;\n type: string;\n status: string;\n retractionStatus: string;\n externalId: string | null;\n submittedAt: string | null;\n retractedAt: string | null;\n lastResponseAt: string | null;\n createdAt: string;\n updatedAt: string;\n takedownProvider: { name: string } | null;\n }>;\n } | null;\n blockedBy: Array<{\n consumer: string;\n name: string | null;\n consumedAt: string;\n }>;\n}\n\nexport interface AssetSearchResult extends AssetSearchResultItem {\n results?: AssetSearchResultItem[];\n}\n\nexport interface AssetListInput {\n type: string;\n status?: string;\n startDate?: string;\n endDate?: string;\n perPage?: number;\n nextPage?: string;\n}\n\nexport interface AssetListItem {\n content: string;\n type: string;\n status: string;\n watchStatus: string;\n updatedAt: string;\n}\n\nexport interface AssetListResult {\n assets: AssetListItem[];\n next_page: string | null;\n}\n\nexport interface DetectionConfigUpdateInput {\n slug: string;\n configId: number;\n status?: \"ENABLED\" | \"DISABLED\";\n title?: string;\n description?: string | null;\n cron?: string | null;\n config?: Record<string, unknown>;\n mergeConfig?: boolean;\n}\n\nexport interface DetectionConfigUpdateResult {\n config: {\n id: number;\n source: string;\n status: string;\n title: string;\n description: string | null;\n cron: string | null;\n config: Record<string, unknown>;\n updatedAt: string;\n };\n}\n\nexport interface DetectionConfigRunInput {\n slug: string;\n configId?: number;\n source?: string;\n includeDisabled?: boolean;\n}\n\nexport interface DetectionConfigRunResult {\n ranCount: number;\n successCount: number;\n failedCount: number;\n results: Array<{\n configId: number;\n source: string;\n ok: boolean;\n message: string | null;\n assetsCount: number;\n }>;\n}\n\nexport interface DetectionConfigValidateInput {\n slug: string;\n source?: string;\n minResults?: number;\n lookbackHours?: number;\n runBeforeValidate?: boolean;\n includeDisabled?: boolean;\n}\n\nexport interface DetectionConfigValidateResult {\n ok: boolean;\n summary: {\n checkedConfigs: number;\n passingConfigs: number;\n failingConfigs: number;\n lookbackHours: number;\n minResults: number;\n };\n validations: Array<{\n configId: number;\n source: string;\n status: string;\n ran: boolean;\n runOk: boolean;\n runMessage: string | null;\n recentResultCount: number;\n valid: boolean;\n }>;\n}\n\nexport interface DetectionDriftInput {\n slug: string;\n lookbackHours?: number;\n startDate?: string;\n endDate?: string;\n source?: string;\n configIds?: number[];\n includeDisabled?: boolean;\n thresholds?: {\n zeroResultsMaxHours?: number;\n noisyResultsPerDay?: number;\n noisyAllowedRatioThreshold?: number;\n staleConfigDays?: number;\n };\n}\n\nexport interface DetectionDriftResult {\n ok: boolean;\n range: {\n startDate: string;\n endDate: string;\n lookbackHours: number;\n };\n thresholds: {\n zeroResultsMaxHours: number;\n noisyResultsPerDay: number;\n noisyAllowedRatioThreshold: number;\n staleConfigDays: number;\n };\n summary: {\n checkedConfigs: number;\n signalCount: number;\n zeroResultsCount: number;\n noisyCount: number;\n staleCount: number;\n };\n signals: Array<{\n signal: \"zero_results_too_long\" | \"noisy_source\" | \"stale_query\";\n configId: number;\n source: string;\n title: string | null;\n status: string;\n severity: \"low\" | \"medium\" | \"high\";\n details: Record<string, unknown>;\n }>;\n}\n\nexport interface OperationsQueuesSnapshotInput {\n slug?: string;\n all?: boolean;\n windowHours?: number;\n}\n\nexport interface OperationsQueuesSnapshotResult {\n generatedAt: string;\n scope: {\n slug: string | null;\n all: boolean;\n };\n reviewQueue: {\n totalPendingProposals: number;\n distinctReports: number;\n ageBuckets: {\n lt24h: number;\n h24to72: number;\n h72to168: number;\n gte168h: number;\n };\n slaBuckets: {\n breached: number;\n dueWithin24h: number;\n dueWithin72h: number;\n beyond72h: number;\n missingSla: number;\n };\n byOrg: Array<{ slug: string; pendingProposals: number }>;\n };\n takedownQueue: {\n totalOpen: number;\n statusCounts: {\n todo: number;\n inProgress: number;\n pendingInput: number;\n };\n ageBuckets: {\n lt24h: number;\n h24to72: number;\n h72to168: number;\n gte168h: number;\n };\n staleInProgress: number;\n byOrg: Array<{ slug: string; openTakedowns: number }>;\n };\n}\n\nexport interface MetricsSummaryInput {\n slug: string;\n startDate?: string;\n endDate?: string;\n brandIds?: number[];\n}\n\nexport interface MetricsSummaryResult {\n metrics: {\n reports: number;\n newThreats: number;\n threatsWatchlisted: number;\n takedownsFiled: number;\n takedownsCompleted: number;\n domainThreats: number;\n twitterThreats: number;\n telegramThreats: number;\n otherThreats: number;\n };\n blockedByDay: Array<{ date: string; count: number }>;\n blockedByType: Array<{ type: string; count: number }>;\n}\n\nexport interface MetricsFoundInput {\n slug: string;\n startDate: string;\n endDate: string;\n brandIds?: number[];\n}\n\nexport interface MetricsFoundResult {\n metric: \"new_threats\";\n found: number;\n range: {\n startDate: string;\n endDate: string;\n };\n}\n\nexport interface MetricsBreakdownInput {\n slug: string;\n by: \"day\" | \"type\" | \"brand\";\n startDate?: string;\n endDate?: string;\n brandIds?: number[];\n}\n\nexport interface MetricsBreakdownResult {\n by: \"day\" | \"type\" | \"brand\";\n points: Array<{\n key: string;\n count: number;\n date?: string;\n type?: string;\n brandId?: number;\n brandSlug?: string;\n brandName?: string;\n }>;\n}\n\nexport interface ReportAssetInput {\n content: string;\n status?: \"BLOCKED\" | \"ALLOWED\" | \"UNKNOWN\";\n brandSlug?: string;\n}\n\nexport interface ReportCreateInput {\n organizationSlug?: string;\n title?: string;\n description?: string;\n contactInfo?: string;\n attachmentUrls?: string[];\n externalSubmissionLink?: string;\n userAgent?: string;\n referrer?: string;\n assets: ReportAssetInput[];\n rawAssetsInput?: string;\n externalReporter?: {\n avatarUrl?: string;\n platformIdentifier: string;\n platform: string;\n displayName: string;\n };\n}\n\nexport interface ReportCreateResult {\n id: number;\n createdAt: string;\n organization: {\n id: number;\n slug: string;\n name: string;\n } | null;\n}\n\nexport const REPORT_REVIEW_DECISIONS = [\"APPROVE\", \"REJECT\", \"SKIP\", \"ESCALATE\"] as const;\nexport type ReportReviewDecision = (typeof REPORT_REVIEW_DECISIONS)[number];\n\nexport const REPORT_STATUSES = [\"TODO\", \"IN_PROGRESS\", \"CLOSED\"] as const;\nexport type ReportStatus = (typeof REPORT_STATUSES)[number];\n\nexport interface OrganizationReportsListInput {\n slug: string;\n limit?: number;\n cursor?: number;\n status?: string;\n searchQuery?: string;\n reporterQuery?: string;\n reportedByCustomer?: boolean;\n excludeAutomation?: boolean;\n onlyRejected?: boolean;\n reviewStatuses?: ReportReviewDecision[];\n assetTypes?: string[];\n brandIds?: number[];\n countryCodes?: string[];\n reviewedByUserId?: number;\n startDate?: string;\n endDate?: string;\n updatedAtStartDate?: string;\n updatedAtEndDate?: string;\n}\n\nexport interface OrganizationReportsListResult {\n reports: Array<{\n id: number;\n title: string;\n description: string;\n status: string | null;\n reportedByCustomer: boolean;\n createdAt: string;\n updatedAt: string;\n proposals: Array<{\n reviewStatus: string;\n asset: {\n id: number;\n type: string;\n content: string;\n status: string;\n };\n }>;\n reporter: {\n id: number;\n role: string;\n fullName: string;\n avatarUrl: string | null;\n } | null;\n externalReporter: {\n id: number;\n displayName: string | null;\n avatarUrl: string | null;\n platform: string;\n } | null;\n }>;\n nextCursor: number | null;\n totalCount: number;\n}\n\nexport const DETECTION_CONFIDENCE_LEVELS = [\"none\", \"low\", \"medium\", \"high\"] as const;\nexport type DetectionConfidence = (typeof DETECTION_CONFIDENCE_LEVELS)[number];\nexport type DetectionReportStatus = \"REPORTED\" | \"NOT_REPORTED\";\n\nexport const DETECTION_REPORTED_FILTERS = [\"reported\", \"not_reported\"] as const;\nexport type DetectionReportedFilter = (typeof DETECTION_REPORTED_FILTERS)[number];\n\nexport const LIVENESS_FILTER_VALUES = [\"ALIVE\", \"DEAD\", \"UNKNOWN\"] as const;\nexport type LivenessFilterValue = (typeof LIVENESS_FILTER_VALUES)[number];\n\nexport const WATCHLIST_FILTER_VALUES = [\"ENABLED\", \"DISABLED\"] as const;\nexport type WatchlistFilterValue = (typeof WATCHLIST_FILTER_VALUES)[number];\n\nexport interface DetectionListInput {\n slug: string;\n cursor?: number;\n limit?: number;\n query?: string;\n startDate?: string;\n endDate?: string;\n sources?: string[];\n confidence?: DetectionConfidence[];\n assetStatus?: string[];\n assetType?: string[];\n brandIds?: number[];\n liveness?: LivenessFilterValue[];\n watchlist?: WatchlistFilterValue[];\n reported?: DetectionReportedFilter[];\n countryCodes?: string[];\n onlyDeleted?: boolean;\n}\n\nexport interface DetectionListItem {\n id: number;\n threatContent: string;\n source: string;\n createdAt: string;\n confidence: DetectionConfidence;\n reportStatus: DetectionReportStatus;\n asset: {\n id: number;\n content: string;\n type: string;\n status: string;\n };\n}\n\nexport interface DetectionListResult {\n detections: DetectionListItem[];\n nextCursor?: number;\n}\n\nexport interface ThreatsListInput {\n query?: string;\n startDate?: string;\n endDate?: string;\n assetType?: string[];\n sorting?: Array<{ key: string; direction: \"asc\" | \"desc\" }>;\n perPage?: number;\n nextPage?: string;\n}\n\nexport interface ThreatItem {\n id: number;\n content: string;\n type: string;\n blockedAt: string;\n}\n\nexport interface ThreatsListResult {\n threats: ThreatItem[];\n next_page: string | null;\n}\n\nexport interface OrganizationAssetsListInput {\n type?: string;\n groupId?: number;\n query?: string;\n perPage?: number;\n nextPage?: string;\n}\n\nexport interface OrganizationAssetItem {\n id: number;\n content: string;\n type: string;\n status: string;\n name: string | null;\n description: string | null;\n group: { id: number; name: string } | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface OrganizationAssetsListResult {\n assets: OrganizationAssetItem[];\n next_page: string | null;\n}\n\nexport interface AssetGroupItem {\n id: number;\n name: string;\n assetCount: number;\n}\n\nexport interface OrganizationAssetGroupsListResult {\n groups: AssetGroupItem[];\n}\n\nexport type BrandType = \"ORGANIZATION\" | \"INDIVIDUAL\";\n\nexport interface BrandItem {\n id: number;\n slug: string;\n name: string;\n type: BrandType;\n description: string | null;\n avatarUrl: string | null;\n websiteUrl: string | null;\n twitterHandle: string | null;\n brandColors: string[];\n includedTerms: string[];\n excludedTerms: string[];\n tickers: string[];\n brandGroupId: number | null;\n createdAt: string;\n}\n\nexport interface OrganizationBrandsListResult {\n brands: BrandItem[];\n}\n\nexport interface ReportsSearchInput {\n assetContents: string[];\n reportedByCustomer?: boolean;\n}\n\nexport interface ReportsSearchResultItem {\n id: number;\n status: string;\n reportedByCustomer: boolean;\n assets: string[];\n}\n\nexport interface ReportsSearchResult {\n reports: ReportsSearchResultItem[];\n}\n\nexport interface UserMeResult {\n user: {\n id: number;\n name: string;\n avatarUrl: string | null;\n email: string;\n role: string;\n protectionConfig: {\n linkMonitoring: boolean;\n socialMediaScanning: boolean;\n historyScanning: boolean;\n } | null;\n };\n}\n\nexport interface ValidateApiKeyResult {\n status: \"success\";\n message: string;\n}\n\nexport const TAKEDOWN_STATUSES = [\n \"TODO\",\n \"IN_PROGRESS\",\n \"COMPLETED\",\n \"CANCELLED\",\n \"PENDING_RETRACTION\",\n \"RETRACTION_SENT\",\n \"RETRACTED\",\n \"PENDING_INPUT\",\n] as const;\nexport type TakedownStatus = (typeof TAKEDOWN_STATUSES)[number];\n\nexport const LIVENESS_STATUSES = [\"UNKNOWN\", \"ALIVE\", \"DEAD\"] as const;\nexport type LivenessStatus = (typeof LIVENESS_STATUSES)[number];\n\nexport const TAKEDOWN_SORT_KEYS = [\n \"updatedAt\",\n \"createdAt\",\n \"takedownStatus\",\n \"takedownUpdatedAt\",\n \"assigneeId\",\n \"brandId\",\n] as const;\nexport type TakedownSortKey = (typeof TAKEDOWN_SORT_KEYS)[number];\n\nexport interface TakedownsListInput {\n organizationSlug?: string;\n query?: string;\n startDate?: string;\n endDate?: string;\n assetType?: string[];\n takedownStatus?: TakedownStatus[];\n livenessStatus?: LivenessStatus[];\n brandIds?: number[];\n assigneeIds?: number[];\n startedAtStartDate?: string;\n startedAtEndDate?: string;\n hideAutomatedTakedowns?: boolean;\n hideAutomatedLivenessChecks?: boolean;\n sorting?: Array<{ key: TakedownSortKey; direction: \"asc\" | \"desc\" }>;\n perPage?: number;\n nextPage?: string;\n}\n\nexport interface TakedownItem {\n id: number;\n status: TakedownStatus;\n createdAt: string;\n updatedAt: string;\n asset: {\n id: number;\n content: string;\n type: string;\n livenessStatus: LivenessStatus | null;\n };\n assignee: {\n id: number;\n fullName: string | null;\n } | null;\n brand: {\n id: number;\n name: string;\n slug: string | null;\n } | null;\n}\n\nexport interface TakedownsListResult {\n takedowns: TakedownItem[];\n next_page: string | null;\n}\n\nexport const ORGANIZATION_METRICS_INCLUDE_FIELDS = [\n \"reports\",\n \"newThreats\",\n \"threatsWatchlisted\",\n \"takedownsFiled\",\n \"takedownsCompleted\",\n \"domainThreats\",\n \"twitterThreats\",\n \"telegramThreats\",\n \"otherThreats\",\n \"blockedByType\",\n \"blockedByDay\",\n] as const;\n\nexport type OrganizationMetricsIncludeField =\n (typeof ORGANIZATION_METRICS_INCLUDE_FIELDS)[number];\n\nexport interface OrganizationMetricsServicesFilter {\n reporting?: { active?: boolean };\n reviewing?: { active?: boolean };\n protection?: { active?: boolean };\n takedowns?: { active?: boolean; automated?: boolean };\n detection?: { active?: boolean };\n darkWebMonitoring?: { active?: boolean };\n}\n\nexport interface OrganizationMetricsInput {\n organizationSlug?: string;\n slugs?: string[];\n allMyOrgs?: boolean;\n subscriptionStatus?: string[];\n services?: OrganizationMetricsServicesFilter;\n brandSlug?: string;\n startDate?: string;\n endDate?: string;\n include?: OrganizationMetricsIncludeField[];\n}\n\nexport interface OrganizationMetricsResultMetrics {\n reports: number | null;\n newThreats: number | null;\n threatsWatchlisted: number | null;\n takedownsFiled: number | null;\n takedownsCompleted: number | null;\n domainThreats: number | null;\n twitterThreats: number | null;\n telegramThreats: number | null;\n otherThreats: number | null;\n}\n\nexport interface OrganizationMetricsResult {\n metrics: OrganizationMetricsResultMetrics;\n blockedByType: Array<{ type: string; count: number }> | null;\n blockedByDay: Array<{ date: string; count: number }> | null;\n averages: {\n perDay: OrganizationMetricsResultMetrics | null;\n perOrgPerDay: OrganizationMetricsResultMetrics | null;\n windowDays: number | null;\n };\n perOrg: Record<\n string,\n {\n metrics: OrganizationMetricsResultMetrics;\n blockedByType: Array<{ type: string; count: number }> | null;\n blockedByDay: Array<{ date: string; count: number }> | null;\n }\n > | null;\n scope: {\n mode: \"single\" | \"multi\";\n orgs: string[];\n resolvedFrom: \"api-key\" | \"organizationSlug\" | \"slugs\" | \"allMyOrgs\";\n };\n}\n\nexport type HealthcheckCategory =\n | \"detection\"\n | \"reviewing\"\n | \"blocklisting\"\n | \"takedowns\"\n | \"assets\"\n | \"organization\";\n\nexport type HealthcheckSeverity = \"ok\" | \"warn\" | \"fail\";\n\nexport interface HealthcheckFinding {\n kind: string;\n ref: string | null;\n message: string;\n severity: \"warn\" | \"fail\";\n}\n\nexport interface HealthcheckResult {\n id: string;\n title: string;\n category: HealthcheckCategory;\n generatedAt: string;\n scope: { slug: string | null };\n ok: boolean;\n severity: HealthcheckSeverity;\n observed: Record<string, number | string | boolean | null>;\n threshold: Record<string, number | string | boolean | null>;\n findings: HealthcheckFinding[];\n suggestedAction: string | null;\n appUrl: string | null;\n}\n\nexport interface HealthcheckRegistryEntry {\n id: string;\n title: string;\n description: string;\n category: HealthcheckCategory;\n implemented: boolean;\n endpoint: string | null;\n defaultThreshold?: Record<string, number | string>;\n notImplementedReason?: string;\n}\n\nexport interface HealthchecksListResult {\n checks: HealthcheckRegistryEntry[];\n}\n\nexport type UserOrgsSubscriptionStatus = \"PROSPECT\" | \"TRIAL\" | \"ACTIVE\" | \"INTEGRATION\";\n\nexport type PendingApprovalService = \"protection\" | \"takedowns\";\n\nexport interface PendingServiceApproval {\n service: PendingApprovalService;\n automated: boolean;\n serviceType: string;\n serviceName: string;\n requestedAt: string;\n}\n\nexport interface UserOrgsServiceFilters {\n reporting?: { active?: boolean };\n reviewing?: { active?: boolean };\n protection?: { active?: boolean };\n takedowns?: { active?: boolean; automated?: boolean };\n detection?: { active?: boolean };\n darkWebMonitoring?: { active?: boolean };\n}\n\nexport interface UserOrgsObligatoryAdminApprovalFilter {\n active?: boolean;\n assetTypes?: string[];\n}\n\nexport interface UserOrgsPendingServiceApprovalFilter {\n active?: boolean;\n services?: PendingApprovalService[];\n}\n\nexport interface UserOrgsInput {\n query?: string;\n subscriptionStatus?: UserOrgsSubscriptionStatus[];\n services?: UserOrgsServiceFilters;\n obligatoryAdminApproval?: UserOrgsObligatoryAdminApprovalFilter;\n pendingServiceApproval?: UserOrgsPendingServiceApprovalFilter;\n}\n\nexport interface UserOrgIntegrations {\n slack: boolean;\n discord: boolean;\n telegram: { connected: boolean; groupCount: number };\n vercel: boolean;\n intercom: boolean;\n moderation: boolean;\n}\n\nexport interface UserOrg {\n id: number;\n name: string;\n slug: string;\n avatarUrl: string | null;\n contactUrl: string | null;\n subscriptionStatus: \"PROSPECT\" | \"TRIAL\" | \"ACTIVE\" | \"INTEGRATION\" | \"INACTIVE\";\n services: {\n reporting: { active: boolean };\n reviewing: { active: boolean };\n protection: { active: boolean };\n takedowns: { active: boolean; automated: boolean };\n detection: { active: boolean };\n darkWebMonitoring: { active: boolean };\n };\n integrations: UserOrgIntegrations;\n obligatoryAdminApproval: {\n active: boolean;\n assetTypes: string[];\n };\n pendingServiceApprovals: PendingServiceApproval[];\n}\n\nexport interface UserOrgsResult {\n organizations: UserOrg[];\n}\n\nexport interface UserOrgGetInput {\n slug: string;\n}\n\nexport interface UserOrgGetResult {\n organization: UserOrg;\n}\n","const ISO_DATE_REGEX =\n /^(\\d{4})-(\\d{2})-(\\d{2})(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:?\\d{2})?)?$/;\n\nexport function parseIsoDate(value: string | undefined): Date | undefined {\n if (!value) return undefined;\n const m = ISO_DATE_REGEX.exec(value);\n if (!m) {\n throw new Error(`Invalid ISO date: '${value}'. Use YYYY-MM-DD or full ISO 8601.`);\n }\n // Normalize offset-less datetimes to UTC (matches Luxon's { zone: \"utc\" } behavior).\n // Date-only strings are already UTC per ECMAScript spec.\n const hasTime = m[4] !== undefined;\n const hasOffset = m[7] !== undefined;\n const normalized = hasTime && !hasOffset ? value + \"Z\" : value;\n const date = new Date(normalized);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid ISO date: '${value}'. Use YYYY-MM-DD or full ISO 8601.`);\n }\n // Reject impossible calendar dates that Date rolls forward (e.g. Feb 31 → Mar 3)\n if (\n date.getUTCFullYear() !== Number(m[1]) ||\n date.getUTCMonth() + 1 !== Number(m[2]) ||\n date.getUTCDate() !== Number(m[3])\n ) {\n throw new Error(`Invalid ISO date: '${value}'. Use YYYY-MM-DD or full ISO 8601.`);\n }\n return date;\n}\n\nexport function parseIsoDateString(value: string | undefined): string | undefined {\n return parseIsoDate(value)?.toISOString();\n}\n","import { parseIsoDate, parseIsoDateString } from \"./date-utils\";\nimport type {\n ApiClient,\n ApiCredential,\n AssetCheckInput,\n AssetCheckResult,\n AssetListInput,\n AssetListResult,\n AssetSearchInput,\n AssetSearchResult,\n ChainPatrolApiClientOptions,\n CredentialProvider,\n DetectionConfigRunInput,\n DetectionConfigRunResult,\n DetectionConfigUpdateInput,\n DetectionConfigUpdateResult,\n DetectionConfigValidateInput,\n DetectionConfigValidateResult,\n DetectionDriftInput,\n DetectionDriftResult,\n DetectionListInput,\n DetectionListResult,\n DetectionSource,\n HealthcheckResult,\n HealthchecksListResult,\n MetricsBreakdownInput,\n MetricsBreakdownResult,\n MetricsFoundInput,\n MetricsFoundResult,\n MetricsSummaryInput,\n MetricsSummaryResult,\n OperationsQueuesSnapshotInput,\n OperationsQueuesSnapshotResult,\n OrganizationAssetsListInput,\n OrganizationAssetsListResult,\n OrganizationAssetGroupsListResult,\n OrganizationBrandsListResult,\n OrganizationMetricsInput,\n OrganizationMetricsResult,\n OrganizationReportsListInput,\n OrganizationReportsListResult,\n ReportCreateInput,\n ReportCreateResult,\n ReportsSearchInput,\n ReportsSearchResult,\n TakedownsListInput,\n TakedownsListResult,\n ThreatsListInput,\n ThreatsListResult,\n UserMeResult,\n UserOrgGetInput,\n UserOrgGetResult,\n UserOrgsInput,\n UserOrgsResult,\n ValidateApiKeyResult,\n} from \"./types\";\n\nconst DEFAULT_BASE_URL = \"https://app.chainpatrol.io\";\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\nfunction trimTrailingSlashes(url: string): string {\n return url.replace(/\\/+$/, \"\");\n}\n\nexport function staticApiKey(key: string): CredentialProvider {\n return () => ({ kind: \"api-key\", value: key });\n}\n\nexport function staticBearerToken(token: string): CredentialProvider {\n return () => ({ kind: \"bearer\", value: token });\n}\n\nexport class ChainPatrolApiClient implements ApiClient {\n private readonly baseUrl: string;\n private readonly credential: CredentialProvider;\n private readonly timeoutMs: number;\n\n constructor(options: ChainPatrolApiClientOptions) {\n this.baseUrl = trimTrailingSlashes(options.baseUrl ?? DEFAULT_BASE_URL);\n this.credential = options.credential;\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n }\n\n private async buildAuthHeaders(): Promise<Record<string, string>> {\n const credential = await this.credential();\n const headers: Record<string, string> = {};\n if (credential.kind === \"api-key\") {\n headers[\"x-api-key\"] = credential.value;\n } else {\n headers[\"Authorization\"] = `Bearer ${credential.value}`;\n }\n return headers;\n }\n\n private async requestGet<T>(\n path: string,\n query: Record<string, string | string[] | undefined>,\n ): Promise<T> {\n const headers = await this.buildAuthHeaders();\n const search = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item !== undefined && item !== \"\") {\n search.append(key, item);\n }\n }\n continue;\n }\n if (value !== \"\") {\n search.set(key, value);\n }\n }\n const queryString = search.toString();\n const url = `${this.baseUrl}/api/v2${path}${queryString ? `?${queryString}` : \"\"}`;\n\n let res: Response;\n try {\n res = await fetch(url, {\n method: \"GET\",\n headers,\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n } catch (err) {\n throw this.wrapFetchError(err);\n }\n\n return this.handleResponse<T>(res);\n }\n\n private async request<T>(path: string, body: unknown): Promise<T> {\n const headers = await this.buildAuthHeaders();\n headers[\"Content-Type\"] = \"application/json\";\n\n let res: Response;\n try {\n res = await fetch(`${this.baseUrl}/api/v2${path}`, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n } catch (err) {\n throw this.wrapFetchError(err);\n }\n\n return this.handleResponse<T>(res);\n }\n\n private wrapFetchError(err: unknown): Error {\n if (err instanceof DOMException && err.name === \"TimeoutError\") {\n return new Error(\"Request timed out. Check your network connection and try again.\");\n }\n if (\n err instanceof TypeError &&\n (err as NodeJS.ErrnoException).code === \"ECONNREFUSED\"\n ) {\n return new Error(`Cannot connect to ${this.baseUrl}. Is the server running?`);\n }\n return new Error(\"Network error. Check your internet connection and try again.\");\n }\n\n private async handleResponse<T>(res: Response): Promise<T> {\n if (!res.ok) {\n let errorMessageFromResponse: string | null = null;\n try {\n const errorBody = (await res.json()) as { message?: string };\n errorMessageFromResponse = errorBody.message ?? null;\n } catch {\n // Response body may not be JSON; ignore parse failures\n }\n\n if (res.status === 401) {\n throw new Error(errorMessageFromResponse ?? \"Authentication failed.\");\n }\n if (res.status === 403) {\n throw new Error(\n errorMessageFromResponse ??\n \"You don't have permission to access this resource.\",\n );\n }\n if (res.status === 404) {\n throw new Error(errorMessageFromResponse ?? \"Resource not found.\");\n }\n if (res.status === 422) {\n throw new Error(errorMessageFromResponse ?? \"Request validation failed.\");\n }\n if (res.status >= 500) {\n throw new Error(\n \"ChainPatrol API is temporarily unavailable. Please try again later.\",\n );\n }\n throw new Error(errorMessageFromResponse ?? `Request failed (${res.status}).`);\n }\n\n return (await res.json()) as T;\n }\n\n assetCheck(input: AssetCheckInput) {\n return this.request<AssetCheckResult>(\"/asset/check\", input);\n }\n\n assetSearch(input: AssetSearchInput) {\n return this.request<AssetSearchResult>(\"/asset/search\", input);\n }\n\n listDetectionConfigs(slug: string) {\n return this.request<DetectionSource[]>(\"/detection/configs/list\", { slug });\n }\n\n updateDetectionConfig(input: DetectionConfigUpdateInput) {\n return this.request<DetectionConfigUpdateResult>(\"/detection/configs/update\", input);\n }\n\n runDetectionConfigs(input: DetectionConfigRunInput) {\n return this.request<DetectionConfigRunResult>(\"/detection/configs/run\", input);\n }\n\n validateDetectionConfigs(input: DetectionConfigValidateInput) {\n return this.request<DetectionConfigValidateResult>(\n \"/detection/configs/validate\",\n input,\n );\n }\n\n getDetectionDrift(input: DetectionDriftInput) {\n return this.request<DetectionDriftResult>(\"/detection/drift\", {\n ...input,\n startDate: parseIsoDate(input.startDate),\n endDate: parseIsoDate(input.endDate),\n });\n }\n\n getOperationsQueuesSnapshot(input: OperationsQueuesSnapshotInput) {\n return this.request<OperationsQueuesSnapshotResult>(\n \"/operations/queues/snapshot\",\n input,\n );\n }\n\n getMetricsSummary(input: MetricsSummaryInput) {\n return this.request<MetricsSummaryResult>(\"/metrics/summary\", {\n ...input,\n startDate: parseIsoDate(input.startDate),\n endDate: parseIsoDate(input.endDate),\n });\n }\n\n getMetricsFound(input: MetricsFoundInput) {\n return this.request<MetricsFoundResult>(\"/metrics/found\", {\n ...input,\n startDate: parseIsoDate(input.startDate),\n endDate: parseIsoDate(input.endDate),\n });\n }\n\n getMetricsBreakdown(input: MetricsBreakdownInput) {\n return this.request<MetricsBreakdownResult>(\"/metrics/breakdown\", {\n ...input,\n startDate: parseIsoDate(input.startDate),\n endDate: parseIsoDate(input.endDate),\n });\n }\n\n createReport(input: ReportCreateInput) {\n return this.request<ReportCreateResult>(\"/report/create\", input);\n }\n\n listOrganizationReports(input: OrganizationReportsListInput) {\n return this.request<OrganizationReportsListResult>(\"/public/getOrganizationReports\", {\n slug: input.slug,\n limit: input.limit ?? 10,\n cursor: input.cursor,\n status: input.status,\n searchQuery: input.searchQuery,\n reporterQuery: input.reporterQuery,\n reportedByCustomer: input.reportedByCustomer,\n excludeAutomation: input.excludeAutomation,\n onlyRejected: input.onlyRejected,\n reviewStatuses: input.reviewStatuses?.length ? input.reviewStatuses : undefined,\n assetTypes: input.assetTypes?.length ? input.assetTypes : undefined,\n brandIds: input.brandIds?.length ? input.brandIds : undefined,\n countryCodes: input.countryCodes?.length ? input.countryCodes : undefined,\n reviewedByUserId: input.reviewedByUserId,\n startDate: parseIsoDateString(input.startDate),\n endDate: parseIsoDateString(input.endDate),\n updatedAtStartDate: parseIsoDateString(input.updatedAtStartDate),\n updatedAtEndDate: parseIsoDateString(input.updatedAtEndDate),\n });\n }\n\n listTakedowns(input: TakedownsListInput) {\n return this.request<TakedownsListResult>(\"/takedowns/list\", {\n organizationSlug: input.organizationSlug,\n query: input.query,\n startDate: parseIsoDateString(input.startDate),\n endDate: parseIsoDateString(input.endDate),\n assetType: input.assetType,\n takedownStatus: input.takedownStatus,\n livenessStatus: input.livenessStatus,\n brandIds: input.brandIds?.length ? input.brandIds : undefined,\n assigneeIds: input.assigneeIds?.length ? input.assigneeIds : undefined,\n startedAtStartDate: parseIsoDateString(input.startedAtStartDate),\n startedAtEndDate: parseIsoDateString(input.startedAtEndDate),\n hideAutomatedTakedowns: input.hideAutomatedTakedowns,\n hideAutomatedLivenessChecks: input.hideAutomatedLivenessChecks,\n sorting: input.sorting,\n per_page: input.perPage,\n next_page: input.nextPage,\n });\n }\n\n getOrganizationMetrics(input: OrganizationMetricsInput) {\n return this.requestGet<OrganizationMetricsResult>(\"/organization/metrics\", {\n organizationSlug: input.organizationSlug,\n slugs: input.slugs,\n allMyOrgs: input.allMyOrgs ? \"true\" : undefined,\n subscriptionStatus: input.subscriptionStatus,\n services: input.services ? JSON.stringify(input.services) : undefined,\n brandSlug: input.brandSlug,\n startDate: parseIsoDateString(input.startDate),\n endDate: parseIsoDateString(input.endDate),\n include: input.include,\n });\n }\n\n listHealthchecks() {\n return this.request<HealthchecksListResult>(\"/healthchecks/list\", {});\n }\n\n runHealthcheck(endpoint: string, input: Record<string, unknown>) {\n return this.request<HealthcheckResult>(endpoint, input);\n }\n\n getUserOrgs(input: UserOrgsInput) {\n return this.request<UserOrgsResult>(\"/user/orgs\", input);\n }\n\n getUserOrg(input: UserOrgGetInput) {\n return this.requestGet<UserOrgGetResult>(\n `/user/orgs/${encodeURIComponent(input.slug)}`,\n {},\n );\n }\n\n listAssets(input: AssetListInput) {\n return this.request<AssetListResult>(\"/asset/list\", {\n type: input.type,\n status: input.status,\n startDate: parseIsoDateString(input.startDate),\n endDate: parseIsoDateString(input.endDate),\n per_page: input.perPage,\n next_page: input.nextPage,\n });\n }\n\n listThreats(input: ThreatsListInput) {\n return this.request<ThreatsListResult>(\"/threats/list\", {\n query: input.query,\n startDate: parseIsoDateString(input.startDate),\n endDate: parseIsoDateString(input.endDate),\n assetType: input.assetType,\n sorting: input.sorting,\n per_page: input.perPage,\n next_page: input.nextPage,\n });\n }\n\n listDetections(input: DetectionListInput) {\n const filters: Array<{\n property: string;\n operator: \"in\" | \"notIn\";\n value: unknown[];\n }> = [];\n if (input.sources?.length) {\n filters.push({ property: \"source\", operator: \"in\", value: input.sources });\n }\n if (input.confidence?.length) {\n filters.push({ property: \"confidence\", operator: \"in\", value: input.confidence });\n }\n if (input.assetStatus?.length) {\n filters.push({\n property: \"assetStatus\",\n operator: \"in\",\n value: input.assetStatus,\n });\n }\n if (input.assetType?.length) {\n filters.push({ property: \"assetType\", operator: \"in\", value: input.assetType });\n }\n if (input.brandIds?.length) {\n filters.push({ property: \"brand\", operator: \"in\", value: input.brandIds });\n }\n if (input.liveness?.length) {\n filters.push({ property: \"liveness\", operator: \"in\", value: input.liveness });\n }\n if (input.watchlist?.length) {\n filters.push({ property: \"watchlist\", operator: \"in\", value: input.watchlist });\n }\n if (input.reported?.length) {\n filters.push({ property: \"reported\", operator: \"in\", value: input.reported });\n }\n if (input.countryCodes?.length) {\n filters.push({\n property: \"countryCode\",\n operator: \"in\",\n value: input.countryCodes,\n });\n }\n if (input.onlyDeleted) {\n filters.push({ property: \"deleted\", operator: \"in\", value: [\"deleted\"] });\n }\n return this.request<DetectionListResult>(\"/detection/list\", {\n slug: input.slug,\n cursor: input.cursor,\n limit: input.limit,\n query: input.query,\n startDate: parseIsoDate(input.startDate),\n endDate: parseIsoDate(input.endDate),\n filters: filters.length > 0 ? filters : undefined,\n });\n }\n\n searchReports(input: ReportsSearchInput) {\n return this.request<ReportsSearchResult>(\"/reports/search\", input);\n }\n\n listOrganizationAssets(input: OrganizationAssetsListInput) {\n return this.requestGet<OrganizationAssetsListResult>(\"/organization/assets\", {\n type: input.type,\n groupId: input.groupId !== undefined ? String(input.groupId) : undefined,\n query: input.query,\n per_page: input.perPage !== undefined ? String(input.perPage) : undefined,\n next_page: input.nextPage,\n });\n }\n\n listOrganizationAssetGroups() {\n return this.requestGet<OrganizationAssetGroupsListResult>(\n \"/organization/asset-groups\",\n {},\n );\n }\n\n listOrganizationBrands() {\n return this.requestGet<OrganizationBrandsListResult>(\"/organization/brands\", {});\n }\n\n getCurrentUser() {\n return this.request<UserMeResult>(\"/user/me\", {});\n }\n\n validateApiKey() {\n return this.requestGet<ValidateApiKeyResult>(\"/validate\", {});\n }\n}\n"]}
1
+ {"version":3,"sources":["../../src/api/types.ts","../../src/api/date-utils.ts","../../src/api/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAibO,IAAM,uBAAA,GAA0B,CAAC,SAAA,EAAW,QAAA,EAAU,QAAQ,UAAU;AAGxE,IAAM,eAAA,GAAkB,CAAC,MAAA,EAAQ,aAAA,EAAe,QAAQ;AA2DxD,IAAM,2BAAA,GAA8B,CAAC,MAAA,EAAQ,KAAA,EAAO,UAAU,MAAM;AAIpE,IAAM,0BAAA,GAA6B,CAAC,UAAA,EAAY,cAAc;AAG9D,IAAM,sBAAA,GAAyB,CAAC,OAAA,EAAS,MAAA,EAAQ,SAAS;AAG1D,IAAM,uBAAA,GAA0B,CAAC,SAAA,EAAW,UAAU;AAwLtD,IAAM,iBAAA,GAAoB;AAAA,EAC/B,MAAA;AAAA,EACA,aAAA;AAAA,EACA,WAAA;AAAA,EACA,WAAA;AAAA,EACA,oBAAA;AAAA,EACA,iBAAA;AAAA,EACA,WAAA;A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AA,EAClD;AAAA,EAEA,cAAA,GAAiB;AACf,IAAA,OAAO,IAAA,CAAK,UAAA,CAAiC,WAAA,EAAa,EAAE,CAAA;AAAA,EAC9D;AACF","file":"index.js","sourcesContent":["export type ApiCredential =\n | { kind: \"api-key\"; value: string }\n | { kind: \"bearer\"; value: string };\n\nexport type CredentialProvider = () => ApiCredential | Promise<ApiCredential>;\n\nexport interface ChainPatrolApiClientOptions {\n baseUrl?: string;\n credential: CredentialProvider;\n timeoutMs?: number;\n}\n\nexport interface ConfigEntry {\n id: number;\n title: string;\n status: string;\n cron: string | null;\n config: Record<string, unknown>;\n}\n\nexport interface DetectionSource {\n source: string;\n scope: \"global\" | \"organization\";\n configs: ConfigEntry[];\n}\n\nexport interface ApiClient {\n assetCheck: (input: AssetCheckInput) => Promise<AssetCheckResult>;\n assetSearch: (input: AssetSearchInput) => Promise<AssetSearchResult>;\n listAssets: (input: AssetListInput) => Promise<AssetListResult>;\n listDetectionConfigs: (slug: string) => Promise<DetectionSource[]>;\n updateDetectionConfig: (\n input: DetectionConfigUpdateInput,\n ) => Promise<DetectionConfigUpdateResult>;\n runDetectionConfigs: (\n input: DetectionConfigRunInput,\n ) => Promise<DetectionConfigRunResult>;\n validateDetectionConfigs: (\n input: DetectionConfigValidateInput,\n ) => Promise<DetectionConfigValidateResult>;\n getDetectionDrift: (input: DetectionDriftInput) => Promise<DetectionDriftResult>;\n listDetections: (input: DetectionListInput) => Promise<DetectionListResult>;\n getOperationsQueuesSnapshot: (\n input: OperationsQueuesSnapshotInput,\n ) => Promise<OperationsQueuesSnapshotResult>;\n getMetricsSummary: (input: MetricsSummaryInput) => Promise<MetricsSummaryResult>;\n getMetricsFound: (input: MetricsFoundInput) => Promise<MetricsFoundResult>;\n getMetricsBreakdown: (input: MetricsBreakdownInput) => Promise<MetricsBreakdownResult>;\n createReport: (input: ReportCreateInput) => Promise<ReportCreateResult>;\n listOrganizationReports: (\n input: OrganizationReportsListInput,\n ) => Promise<OrganizationReportsListResult>;\n searchReports: (input: ReportsSearchInput) => Promise<ReportsSearchResult>;\n listTakedowns: (input: TakedownsListInput) => Promise<TakedownsListResult>;\n listThreats: (input: ThreatsListInput) => Promise<ThreatsListResult>;\n getOrganizationMetrics: (\n input: OrganizationMetricsInput,\n ) => Promise<OrganizationMetricsResult>;\n listOrganizationAssets: (\n input: OrganizationAssetsListInput,\n ) => Promise<OrganizationAssetsListResult>;\n listOrganizationAssetGroups: () => Promise<OrganizationAssetGroupsListResult>;\n listOrganizationBrands: () => Promise<OrganizationBrandsListResult>;\n listHealthchecks: () => Promise<HealthchecksListResult>;\n runHealthcheck: (\n endpoint: string,\n input: Record<string, unknown>,\n ) => Promise<HealthcheckResult>;\n getUserOrgs: (input: UserOrgsInput) => Promise<UserOrgsResult>;\n getUserOrg: (input: UserOrgGetInput) => Promise<UserOrgGetResult>;\n getCurrentUser: () => Promise<UserMeResult>;\n validateApiKey: () => Promise<ValidateApiKeyResult>;\n}\n\nexport interface AssetCheckInput {\n content: string;\n}\n\nexport type AssetCheckStatus = \"ALLOWED\" | \"BLOCKED\" | \"UNKNOWN\";\n\nexport interface AssetCheckSourceEntry {\n source: string;\n status: AssetCheckStatus;\n}\n\nexport interface AssetCheckResult {\n status: AssetCheckStatus;\n source: string;\n reason?: string;\n sources: AssetCheckSourceEntry[];\n message?: string;\n code?: string;\n watchStatus?: \"ENABLED\" | \"DISABLED\";\n}\n\nexport interface AssetSearchInput {\n content?: string;\n assetId?: number;\n assetIds?: number[];\n}\n\nexport interface AssetSearchResultItem {\n asset: {\n id: number;\n content: string;\n type: string;\n status: string;\n watchStatus: string;\n createdAt: string;\n updatedAt: string;\n } | null;\n reports: Array<{\n id: number;\n title: string | null;\n status: string;\n createdAt: string;\n }>;\n takedown: {\n id: number;\n status: string;\n createdAt: string;\n updatedAt: string;\n tasks: Array<{\n id: number;\n type: string;\n status: string;\n retractionStatus: string;\n externalId: string | null;\n submittedAt: string | null;\n retractedAt: string | null;\n lastResponseAt: string | null;\n createdAt: string;\n updatedAt: string;\n takedownProvider: { name: string } | null;\n }>;\n } | null;\n blockedBy: Array<{\n consumer: string;\n name: string | null;\n consumedAt: string;\n }>;\n}\n\nexport interface AssetSearchResult extends AssetSearchResultItem {\n results?: AssetSearchResultItem[];\n}\n\nexport interface AssetListInput {\n type: string;\n status?: string;\n startDate?: string;\n endDate?: string;\n perPage?: number;\n nextPage?: string;\n}\n\nexport interface AssetListItem {\n content: string;\n type: string;\n status: string;\n watchStatus: string;\n updatedAt: string;\n}\n\nexport interface AssetListResult {\n assets: AssetListItem[];\n next_page: string | null;\n}\n\nexport interface DetectionConfigUpdateInput {\n slug: string;\n configId: number;\n status?: \"ENABLED\" | \"DISABLED\";\n title?: string;\n description?: string | null;\n cron?: string | null;\n config?: Record<string, unknown>;\n mergeConfig?: boolean;\n}\n\nexport interface DetectionConfigUpdateResult {\n config: {\n id: number;\n source: string;\n status: string;\n title: string;\n description: string | null;\n cron: string | null;\n config: Record<string, unknown>;\n updatedAt: string;\n };\n}\n\nexport interface DetectionConfigRunInput {\n slug: string;\n configId?: number;\n source?: string;\n includeDisabled?: boolean;\n}\n\nexport interface DetectionConfigRunResult {\n ranCount: number;\n successCount: number;\n failedCount: number;\n results: Array<{\n configId: number;\n source: string;\n ok: boolean;\n message: string | null;\n assetsCount: number;\n }>;\n}\n\nexport interface DetectionConfigValidateInput {\n slug: string;\n source?: string;\n minResults?: number;\n lookbackHours?: number;\n runBeforeValidate?: boolean;\n includeDisabled?: boolean;\n}\n\nexport interface DetectionConfigValidateResult {\n ok: boolean;\n summary: {\n checkedConfigs: number;\n passingConfigs: number;\n failingConfigs: number;\n lookbackHours: number;\n minResults: number;\n };\n validations: Array<{\n configId: number;\n source: string;\n status: string;\n ran: boolean;\n runOk: boolean;\n runMessage: string | null;\n recentResultCount: number;\n valid: boolean;\n }>;\n}\n\nexport interface DetectionDriftInput {\n slug: string;\n lookbackHours?: number;\n startDate?: string;\n endDate?: string;\n source?: string;\n configIds?: number[];\n includeDisabled?: boolean;\n thresholds?: {\n zeroResultsMaxHours?: number;\n noisyResultsPerDay?: number;\n noisyAllowedRatioThreshold?: number;\n staleConfigDays?: number;\n };\n}\n\nexport interface DetectionDriftResult {\n ok: boolean;\n range: {\n startDate: string;\n endDate: string;\n lookbackHours: number;\n };\n thresholds: {\n zeroResultsMaxHours: number;\n noisyResultsPerDay: number;\n noisyAllowedRatioThreshold: number;\n staleConfigDays: number;\n };\n summary: {\n checkedConfigs: number;\n signalCount: number;\n zeroResultsCount: number;\n noisyCount: number;\n staleCount: number;\n };\n signals: Array<{\n signal: \"zero_results_too_long\" | \"noisy_source\" | \"stale_query\";\n configId: number;\n source: string;\n title: string | null;\n status: string;\n severity: \"low\" | \"medium\" | \"high\";\n details: Record<string, unknown>;\n }>;\n}\n\nexport interface OperationsQueuesSnapshotInput {\n slug?: string;\n all?: boolean;\n windowHours?: number;\n}\n\nexport interface OperationsQueuesSnapshotResult {\n generatedAt: string;\n scope: {\n slug: string | null;\n all: boolean;\n };\n reviewQueue: {\n totalPendingProposals: number;\n distinctReports: number;\n ageBuckets: {\n lt24h: number;\n h24to72: number;\n h72to168: number;\n gte168h: number;\n };\n slaBuckets: {\n breached: number;\n dueWithin24h: number;\n dueWithin72h: number;\n beyond72h: number;\n missingSla: number;\n };\n byOrg: Array<{ slug: string; pendingProposals: number }>;\n };\n takedownQueue: {\n totalOpen: number;\n statusCounts: {\n todo: number;\n inProgress: number;\n pendingInput: number;\n };\n ageBuckets: {\n lt24h: number;\n h24to72: number;\n h72to168: number;\n gte168h: number;\n };\n staleInProgress: number;\n byOrg: Array<{ slug: string; openTakedowns: number }>;\n };\n}\n\nexport interface MetricsSummaryInput {\n slug: string;\n startDate?: string;\n endDate?: string;\n brandIds?: number[];\n}\n\nexport interface MetricsSummaryResult {\n metrics: {\n reports: number;\n newThreats: number;\n threatsWatchlisted: number;\n takedownsFiled: number;\n takedownsCompleted: number;\n domainThreats: number;\n twitterThreats: number;\n telegramThreats: number;\n otherThreats: number;\n };\n blockedByDay: Array<{ date: string; count: number }>;\n blockedByType: Array<{ type: string; count: number }>;\n}\n\nexport interface MetricsFoundInput {\n slug: string;\n startDate: string;\n endDate: string;\n brandIds?: number[];\n}\n\nexport interface MetricsFoundResult {\n metric: \"new_threats\";\n found: number;\n range: {\n startDate: string;\n endDate: string;\n };\n}\n\nexport interface MetricsBreakdownInput {\n slug: string;\n by: \"day\" | \"type\" | \"brand\";\n startDate?: string;\n endDate?: string;\n brandIds?: number[];\n}\n\nexport interface MetricsBreakdownResult {\n by: \"day\" | \"type\" | \"brand\";\n points: Array<{\n key: string;\n count: number;\n date?: string;\n type?: string;\n brandId?: number;\n brandSlug?: string;\n brandName?: string;\n }>;\n}\n\nexport interface ReportAssetInput {\n content: string;\n status?: \"BLOCKED\" | \"ALLOWED\" | \"UNKNOWN\";\n brandSlug?: string;\n}\n\nexport interface ReportCreateInput {\n organizationSlug?: string;\n title?: string;\n description?: string;\n contactInfo?: string;\n attachmentUrls?: string[];\n externalSubmissionLink?: string;\n userAgent?: string;\n referrer?: string;\n assets: ReportAssetInput[];\n rawAssetsInput?: string;\n externalReporter?: {\n avatarUrl?: string;\n platformIdentifier: string;\n platform: string;\n displayName: string;\n };\n}\n\nexport interface ReportCreateResult {\n id: number;\n createdAt: string;\n organization: {\n id: number;\n slug: string;\n name: string;\n } | null;\n}\n\nexport const REPORT_REVIEW_DECISIONS = [\"APPROVE\", \"REJECT\", \"SKIP\", \"ESCALATE\"] as const;\nexport type ReportReviewDecision = (typeof REPORT_REVIEW_DECISIONS)[number];\n\nexport const REPORT_STATUSES = [\"TODO\", \"IN_PROGRESS\", \"CLOSED\"] as const;\nexport type ReportStatus = (typeof REPORT_STATUSES)[number];\n\nexport interface OrganizationReportsListInput {\n slug: string;\n limit?: number;\n cursor?: number;\n status?: string;\n searchQuery?: string;\n reporterQuery?: string;\n reportedByCustomer?: boolean;\n excludeAutomation?: boolean;\n onlyRejected?: boolean;\n reviewStatuses?: ReportReviewDecision[];\n assetTypes?: string[];\n brandIds?: number[];\n countryCodes?: string[];\n reviewedByUserId?: number;\n startDate?: string;\n endDate?: string;\n updatedAtStartDate?: string;\n updatedAtEndDate?: string;\n}\n\nexport interface OrganizationReportsListResult {\n reports: Array<{\n id: number;\n title: string;\n description: string;\n status: string | null;\n reportedByCustomer: boolean;\n createdAt: string;\n updatedAt: string;\n proposals: Array<{\n reviewStatus: string;\n asset: {\n id: number;\n type: string;\n content: string;\n status: string;\n };\n }>;\n reporter: {\n id: number;\n role: string;\n fullName: string;\n avatarUrl: string | null;\n } | null;\n externalReporter: {\n id: number;\n displayName: string | null;\n avatarUrl: string | null;\n platform: string;\n } | null;\n }>;\n nextCursor: number | null;\n totalCount: number;\n}\n\nexport const DETECTION_CONFIDENCE_LEVELS = [\"none\", \"low\", \"medium\", \"high\"] as const;\nexport type DetectionConfidence = (typeof DETECTION_CONFIDENCE_LEVELS)[number];\nexport type DetectionReportStatus = \"REPORTED\" | \"NOT_REPORTED\";\n\nexport const DETECTION_REPORTED_FILTERS = [\"reported\", \"not_reported\"] as const;\nexport type DetectionReportedFilter = (typeof DETECTION_REPORTED_FILTERS)[number];\n\nexport const LIVENESS_FILTER_VALUES = [\"ALIVE\", \"DEAD\", \"UNKNOWN\"] as const;\nexport type LivenessFilterValue = (typeof LIVENESS_FILTER_VALUES)[number];\n\nexport const WATCHLIST_FILTER_VALUES = [\"ENABLED\", \"DISABLED\"] as const;\nexport type WatchlistFilterValue = (typeof WATCHLIST_FILTER_VALUES)[number];\n\nexport interface DetectionListInput {\n slug: string;\n cursor?: number;\n limit?: number;\n query?: string;\n startDate?: string;\n endDate?: string;\n sources?: string[];\n confidence?: DetectionConfidence[];\n assetStatus?: string[];\n assetType?: string[];\n brandIds?: number[];\n liveness?: LivenessFilterValue[];\n watchlist?: WatchlistFilterValue[];\n reported?: DetectionReportedFilter[];\n countryCodes?: string[];\n onlyDeleted?: boolean;\n}\n\nexport interface DetectionListItem {\n id: number;\n threatContent: string;\n source: string;\n createdAt: string;\n confidence: DetectionConfidence;\n reportStatus: DetectionReportStatus;\n asset: {\n id: number;\n content: string;\n type: string;\n status: string;\n };\n}\n\nexport interface DetectionListResult {\n detections: DetectionListItem[];\n nextCursor?: number;\n}\n\nexport interface ThreatsListInput {\n query?: string;\n startDate?: string;\n endDate?: string;\n assetType?: string[];\n sorting?: Array<{ key: string; direction: \"asc\" | \"desc\" }>;\n perPage?: number;\n nextPage?: string;\n}\n\nexport interface ThreatItem {\n id: number;\n content: string;\n type: string;\n blockedAt: string;\n}\n\nexport interface ThreatsListResult {\n threats: ThreatItem[];\n next_page: string | null;\n}\n\nexport interface OrganizationAssetsListInput {\n type?: string;\n groupId?: number;\n query?: string;\n perPage?: number;\n nextPage?: string;\n}\n\nexport interface OrganizationAssetItem {\n id: number;\n content: string;\n type: string;\n status: string;\n name: string | null;\n description: string | null;\n group: { id: number; name: string } | null;\n createdAt: string;\n updatedAt: string;\n}\n\nexport interface OrganizationAssetsListResult {\n assets: OrganizationAssetItem[];\n next_page: string | null;\n}\n\nexport interface AssetGroupItem {\n id: number;\n name: string;\n assetCount: number;\n}\n\nexport interface OrganizationAssetGroupsListResult {\n groups: AssetGroupItem[];\n}\n\nexport type BrandType = \"ORGANIZATION\" | \"INDIVIDUAL\";\n\nexport interface BrandLegalDocument {\n present: boolean;\n fileName: string | null;\n fileUrl: string | null;\n}\n\nexport interface BrandLegalDocuments {\n letterOfAuthorization: BrandLegalDocument;\n powerOfAttorney: BrandLegalDocument;\n}\n\nexport interface BrandTrademarkRegistrationItem {\n id: number;\n brandName: string;\n trademarkOffice: string;\n registrationNumber: string;\n goodsAndServicesClass: string;\n rightsOwnerName: string | null;\n registrationPageUrl: string | null;\n certificateFileName: string | null;\n certificateFileUrl: string | null;\n}\n\nexport interface BrandItem {\n id: number;\n slug: string;\n name: string;\n type: BrandType;\n description: string | null;\n avatarUrl: string | null;\n websiteUrl: string | null;\n twitterHandle: string | null;\n brandColors: string[];\n includedTerms: string[];\n excludedTerms: string[];\n tickers: string[];\n brandGroupId: number | null;\n createdAt: string;\n useOrganizationDocs: boolean;\n legalDocuments: BrandLegalDocuments;\n trademarkRegistrations: BrandTrademarkRegistrationItem[];\n}\n\nexport interface OrganizationBrandsListResult {\n brands: BrandItem[];\n}\n\nexport interface ReportsSearchInput {\n assetContents: string[];\n reportedByCustomer?: boolean;\n}\n\nexport interface ReportsSearchResultItem {\n id: number;\n status: string;\n reportedByCustomer: boolean;\n assets: string[];\n}\n\nexport interface ReportsSearchResult {\n reports: ReportsSearchResultItem[];\n}\n\nexport interface UserMeResult {\n user: {\n id: number;\n name: string;\n avatarUrl: string | null;\n email: string;\n role: string;\n protectionConfig: {\n linkMonitoring: boolean;\n socialMediaScanning: boolean;\n historyScanning: boolean;\n } | null;\n };\n}\n\nexport interface ValidateApiKeyResult {\n status: \"success\";\n message: string;\n}\n\nexport const TAKEDOWN_STATUSES = [\n \"TODO\",\n \"IN_PROGRESS\",\n \"COMPLETED\",\n \"CANCELLED\",\n \"PENDING_RETRACTION\",\n \"RETRACTION_SENT\",\n \"RETRACTED\",\n \"PENDING_INPUT\",\n] as const;\nexport type TakedownStatus = (typeof TAKEDOWN_STATUSES)[number];\n\nexport const LIVENESS_STATUSES = [\"UNKNOWN\", \"ALIVE\", \"DEAD\"] as const;\nexport type LivenessStatus = (typeof LIVENESS_STATUSES)[number];\n\nexport const TAKEDOWN_SORT_KEYS = [\n \"updatedAt\",\n \"createdAt\",\n \"takedownStatus\",\n \"takedownUpdatedAt\",\n \"assigneeId\",\n \"brandId\",\n] as const;\nexport type TakedownSortKey = (typeof TAKEDOWN_SORT_KEYS)[number];\n\nexport interface TakedownsListInput {\n organizationSlug?: string;\n query?: string;\n startDate?: string;\n endDate?: string;\n assetType?: string[];\n takedownStatus?: TakedownStatus[];\n livenessStatus?: LivenessStatus[];\n brandIds?: number[];\n assigneeIds?: number[];\n startedAtStartDate?: string;\n startedAtEndDate?: string;\n hideAutomatedTakedowns?: boolean;\n hideAutomatedLivenessChecks?: boolean;\n sorting?: Array<{ key: TakedownSortKey; direction: \"asc\" | \"desc\" }>;\n perPage?: number;\n nextPage?: string;\n}\n\nexport interface TakedownItem {\n id: number;\n status: TakedownStatus;\n createdAt: string;\n updatedAt: string;\n asset: {\n id: number;\n content: string;\n type: string;\n livenessStatus: LivenessStatus | null;\n };\n assignee: {\n id: number;\n fullName: string | null;\n } | null;\n brand: {\n id: number;\n name: string;\n slug: string | null;\n } | null;\n}\n\nexport interface TakedownsListResult {\n takedowns: TakedownItem[];\n next_page: string | null;\n}\n\nexport const ORGANIZATION_METRICS_INCLUDE_FIELDS = [\n \"reports\",\n \"newThreats\",\n \"threatsWatchlisted\",\n \"takedownsFiled\",\n \"takedownsCompleted\",\n \"domainThreats\",\n \"twitterThreats\",\n \"telegramThreats\",\n \"otherThreats\",\n \"blockedByType\",\n \"blockedByDay\",\n] as const;\n\nexport type OrganizationMetricsIncludeField =\n (typeof ORGANIZATION_METRICS_INCLUDE_FIELDS)[number];\n\nexport interface OrganizationMetricsServicesFilter {\n reporting?: { active?: boolean };\n reviewing?: { active?: boolean };\n protection?: { active?: boolean };\n takedowns?: { active?: boolean; automated?: boolean };\n detection?: { active?: boolean };\n darkWebMonitoring?: { active?: boolean };\n}\n\nexport interface OrganizationMetricsInput {\n organizationSlug?: string;\n slugs?: string[];\n allMyOrgs?: boolean;\n subscriptionStatus?: string[];\n services?: OrganizationMetricsServicesFilter;\n brandSlug?: string;\n startDate?: string;\n endDate?: string;\n include?: OrganizationMetricsIncludeField[];\n}\n\nexport interface OrganizationMetricsResultMetrics {\n reports: number | null;\n newThreats: number | null;\n threatsWatchlisted: number | null;\n takedownsFiled: number | null;\n takedownsCompleted: number | null;\n domainThreats: number | null;\n twitterThreats: number | null;\n telegramThreats: number | null;\n otherThreats: number | null;\n}\n\nexport interface OrganizationMetricsResult {\n metrics: OrganizationMetricsResultMetrics;\n blockedByType: Array<{ type: string; count: number }> | null;\n blockedByDay: Array<{ date: string; count: number }> | null;\n averages: {\n perDay: OrganizationMetricsResultMetrics | null;\n perOrgPerDay: OrganizationMetricsResultMetrics | null;\n windowDays: number | null;\n };\n perOrg: Record<\n string,\n {\n metrics: OrganizationMetricsResultMetrics;\n blockedByType: Array<{ type: string; count: number }> | null;\n blockedByDay: Array<{ date: string; count: number }> | null;\n }\n > | null;\n scope: {\n mode: \"single\" | \"multi\";\n orgs: string[];\n resolvedFrom: \"api-key\" | \"organizationSlug\" | \"slugs\" | \"allMyOrgs\";\n };\n}\n\nexport type HealthcheckCategory =\n | \"detection\"\n | \"reviewing\"\n | \"blocklisting\"\n | \"takedowns\"\n | \"assets\"\n | \"organization\";\n\nexport type HealthcheckSeverity = \"ok\" | \"warn\" | \"fail\";\n\nexport interface HealthcheckFinding {\n kind: string;\n ref: string | null;\n message: string;\n severity: \"warn\" | \"fail\";\n}\n\nexport interface HealthcheckResult {\n id: string;\n title: string;\n category: HealthcheckCategory;\n generatedAt: string;\n scope: { slug: string | null };\n ok: boolean;\n severity: HealthcheckSeverity;\n observed: Record<string, number | string | boolean | null>;\n threshold: Record<string, number | string | boolean | null>;\n findings: HealthcheckFinding[];\n suggestedAction: string | null;\n appUrl: string | null;\n}\n\nexport interface HealthcheckRegistryEntry {\n id: string;\n title: string;\n description: string;\n category: HealthcheckCategory;\n implemented: boolean;\n endpoint: string | null;\n defaultThreshold?: Record<string, number | string>;\n notImplementedReason?: string;\n}\n\nexport interface HealthchecksListResult {\n checks: HealthcheckRegistryEntry[];\n}\n\nexport type UserOrgsSubscriptionStatus = \"PROSPECT\" | \"POC\" | \"ACTIVE\" | \"INTEGRATION\";\n\nexport type PendingApprovalService = \"protection\" | \"takedowns\";\n\nexport interface PendingServiceApproval {\n service: PendingApprovalService;\n automated: boolean;\n serviceType: string;\n serviceName: string;\n requestedAt: string;\n}\n\nexport interface UserOrgsServiceFilters {\n reporting?: { active?: boolean };\n reviewing?: { active?: boolean };\n protection?: { active?: boolean };\n takedowns?: { active?: boolean; automated?: boolean };\n detection?: { active?: boolean };\n darkWebMonitoring?: { active?: boolean };\n}\n\nexport interface UserOrgsObligatoryAdminApprovalFilter {\n active?: boolean;\n assetTypes?: string[];\n}\n\nexport interface UserOrgsPendingServiceApprovalFilter {\n active?: boolean;\n services?: PendingApprovalService[];\n}\n\nexport interface UserOrgsInput {\n query?: string;\n subscriptionStatus?: UserOrgsSubscriptionStatus[];\n services?: UserOrgsServiceFilters;\n obligatoryAdminApproval?: UserOrgsObligatoryAdminApprovalFilter;\n pendingServiceApproval?: UserOrgsPendingServiceApprovalFilter;\n}\n\nexport interface UserOrgIntegrations {\n slack: boolean;\n discord: boolean;\n telegram: { connected: boolean; groupCount: number };\n vercel: boolean;\n intercom: boolean;\n moderation: boolean;\n}\n\nexport interface UserOrgLegalDocument {\n present: boolean;\n fileName: string | null;\n fileUrl: string | null;\n}\n\nexport interface UserOrgLegalDocuments {\n letterOfAuthorization: UserOrgLegalDocument;\n powerOfAttorney: UserOrgLegalDocument;\n}\n\nexport interface UserOrgTrademarkRegistration {\n id: number;\n brandName: string;\n trademarkOffice: string;\n registrationNumber: string;\n goodsAndServicesClass: string;\n rightsOwnerName: string | null;\n registrationPageUrl: string | null;\n certificateFileName: string | null;\n certificateFileUrl: string | null;\n}\n\nexport interface UserOrg {\n id: number;\n name: string;\n slug: string;\n avatarUrl: string | null;\n contactUrl: string | null;\n subscriptionStatus: \"PROSPECT\" | \"POC\" | \"ACTIVE\" | \"INTEGRATION\" | \"INACTIVE\";\n services: {\n reporting: { active: boolean };\n reviewing: { active: boolean };\n protection: { active: boolean };\n takedowns: { active: boolean; automated: boolean };\n detection: { active: boolean };\n darkWebMonitoring: { active: boolean };\n };\n integrations: UserOrgIntegrations;\n obligatoryAdminApproval: {\n active: boolean;\n assetTypes: string[];\n };\n pendingServiceApprovals: PendingServiceApproval[];\n legalDocuments: UserOrgLegalDocuments;\n trademarkRegistrations: UserOrgTrademarkRegistration[];\n}\n\nexport interface UserOrgsResult {\n organizations: UserOrg[];\n}\n\nexport interface UserOrgGetInput {\n slug: string;\n}\n\nexport interface UserOrgGetResult {\n organization: UserOrg;\n}\n","const ISO_DATE_REGEX =\n /^(\\d{4})-(\\d{2})-(\\d{2})(T\\d{2}:\\d{2}(:\\d{2}(\\.\\d+)?)?(Z|[+-]\\d{2}:?\\d{2})?)?$/;\n\nexport function parseIsoDate(value: string | undefined): Date | undefined {\n if (!value) return undefined;\n const m = ISO_DATE_REGEX.exec(value);\n if (!m) {\n throw new Error(`Invalid ISO date: '${value}'. Use YYYY-MM-DD or full ISO 8601.`);\n }\n // Normalize offset-less datetimes to UTC (matches Luxon's { zone: \"utc\" } behavior).\n // Date-only strings are already UTC per ECMAScript spec.\n const hasTime = m[4] !== undefined;\n const hasOffset = m[7] !== undefined;\n const normalized = hasTime && !hasOffset ? value + \"Z\" : value;\n const date = new Date(normalized);\n if (Number.isNaN(date.getTime())) {\n throw new Error(`Invalid ISO date: '${value}'. Use YYYY-MM-DD or full ISO 8601.`);\n }\n // Reject impossible calendar dates that Date rolls forward (e.g. Feb 31 → Mar 3)\n if (\n date.getUTCFullYear() !== Number(m[1]) ||\n date.getUTCMonth() + 1 !== Number(m[2]) ||\n date.getUTCDate() !== Number(m[3])\n ) {\n throw new Error(`Invalid ISO date: '${value}'. Use YYYY-MM-DD or full ISO 8601.`);\n }\n return date;\n}\n\nexport function parseIsoDateString(value: string | undefined): string | undefined {\n return parseIsoDate(value)?.toISOString();\n}\n","import { parseIsoDate, parseIsoDateString } from \"./date-utils\";\nimport type {\n ApiClient,\n ApiCredential,\n AssetCheckInput,\n AssetCheckResult,\n AssetListInput,\n AssetListResult,\n AssetSearchInput,\n AssetSearchResult,\n ChainPatrolApiClientOptions,\n CredentialProvider,\n DetectionConfigRunInput,\n DetectionConfigRunResult,\n DetectionConfigUpdateInput,\n DetectionConfigUpdateResult,\n DetectionConfigValidateInput,\n DetectionConfigValidateResult,\n DetectionDriftInput,\n DetectionDriftResult,\n DetectionListInput,\n DetectionListResult,\n DetectionSource,\n HealthcheckResult,\n HealthchecksListResult,\n MetricsBreakdownInput,\n MetricsBreakdownResult,\n MetricsFoundInput,\n MetricsFoundResult,\n MetricsSummaryInput,\n MetricsSummaryResult,\n OperationsQueuesSnapshotInput,\n OperationsQueuesSnapshotResult,\n OrganizationAssetsListInput,\n OrganizationAssetsListResult,\n OrganizationAssetGroupsListResult,\n OrganizationBrandsListResult,\n OrganizationMetricsInput,\n OrganizationMetricsResult,\n OrganizationReportsListInput,\n OrganizationReportsListResult,\n ReportCreateInput,\n ReportCreateResult,\n ReportsSearchInput,\n ReportsSearchResult,\n TakedownsListInput,\n TakedownsListResult,\n ThreatsListInput,\n ThreatsListResult,\n UserMeResult,\n UserOrgGetInput,\n UserOrgGetResult,\n UserOrgsInput,\n UserOrgsResult,\n ValidateApiKeyResult,\n} from \"./types\";\n\nconst DEFAULT_BASE_URL = \"https://app.chainpatrol.io\";\nconst DEFAULT_TIMEOUT_MS = 30_000;\n\nfunction trimTrailingSlashes(url: string): string {\n return url.replace(/\\/+$/, \"\");\n}\n\nexport function staticApiKey(key: string): CredentialProvider {\n return () => ({ kind: \"api-key\", value: key });\n}\n\nexport function staticBearerToken(token: string): CredentialProvider {\n return () => ({ kind: \"bearer\", value: token });\n}\n\nexport class ChainPatrolApiClient implements ApiClient {\n private readonly baseUrl: string;\n private readonly credential: CredentialProvider;\n private readonly timeoutMs: number;\n\n constructor(options: ChainPatrolApiClientOptions) {\n this.baseUrl = trimTrailingSlashes(options.baseUrl ?? DEFAULT_BASE_URL);\n this.credential = options.credential;\n this.timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;\n }\n\n private async buildAuthHeaders(): Promise<Record<string, string>> {\n const credential = await this.credential();\n const headers: Record<string, string> = {};\n if (credential.kind === \"api-key\") {\n headers[\"x-api-key\"] = credential.value;\n } else {\n headers[\"Authorization\"] = `Bearer ${credential.value}`;\n }\n return headers;\n }\n\n private async requestGet<T>(\n path: string,\n query: Record<string, string | string[] | undefined>,\n ): Promise<T> {\n const headers = await this.buildAuthHeaders();\n const search = new URLSearchParams();\n for (const [key, value] of Object.entries(query)) {\n if (value === undefined) continue;\n if (Array.isArray(value)) {\n for (const item of value) {\n if (item !== undefined && item !== \"\") {\n search.append(key, item);\n }\n }\n continue;\n }\n if (value !== \"\") {\n search.set(key, value);\n }\n }\n const queryString = search.toString();\n const url = `${this.baseUrl}/api/v2${path}${queryString ? `?${queryString}` : \"\"}`;\n\n let res: Response;\n try {\n res = await fetch(url, {\n method: \"GET\",\n headers,\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n } catch (err) {\n throw this.wrapFetchError(err);\n }\n\n return this.handleResponse<T>(res);\n }\n\n private async request<T>(path: string, body: unknown): Promise<T> {\n const headers = await this.buildAuthHeaders();\n headers[\"Content-Type\"] = \"application/json\";\n\n let res: Response;\n try {\n res = await fetch(`${this.baseUrl}/api/v2${path}`, {\n method: \"POST\",\n headers,\n body: JSON.stringify(body),\n signal: AbortSignal.timeout(this.timeoutMs),\n });\n } catch (err) {\n throw this.wrapFetchError(err);\n }\n\n return this.handleResponse<T>(res);\n }\n\n private wrapFetchError(err: unknown): Error {\n if (err instanceof DOMException && err.name === \"TimeoutError\") {\n return new Error(\"Request timed out. Check your network connection and try again.\");\n }\n if (\n err instanceof TypeError &&\n (err as NodeJS.ErrnoException).code === \"ECONNREFUSED\"\n ) {\n return new Error(`Cannot connect to ${this.baseUrl}. Is the server running?`);\n }\n return new Error(\"Network error. Check your internet connection and try again.\");\n }\n\n private async handleResponse<T>(res: Response): Promise<T> {\n if (!res.ok) {\n let errorMessageFromResponse: string | null = null;\n try {\n const errorBody = (await res.json()) as { message?: string };\n errorMessageFromResponse = errorBody.message ?? null;\n } catch {\n // Response body may not be JSON; ignore parse failures\n }\n\n if (res.status === 401) {\n throw new Error(errorMessageFromResponse ?? \"Authentication failed.\");\n }\n if (res.status === 403) {\n throw new Error(\n errorMessageFromResponse ??\n \"You don't have permission to access this resource.\",\n );\n }\n if (res.status === 404) {\n throw new Error(errorMessageFromResponse ?? \"Resource not found.\");\n }\n if (res.status === 422) {\n throw new Error(errorMessageFromResponse ?? \"Request validation failed.\");\n }\n if (res.status >= 500) {\n throw new Error(\n \"ChainPatrol API is temporarily unavailable. Please try again later.\",\n );\n }\n throw new Error(errorMessageFromResponse ?? `Request failed (${res.status}).`);\n }\n\n return (await res.json()) as T;\n }\n\n assetCheck(input: AssetCheckInput) {\n return this.request<AssetCheckResult>(\"/asset/check\", input);\n }\n\n assetSearch(input: AssetSearchInput) {\n return this.request<AssetSearchResult>(\"/asset/search\", input);\n }\n\n listDetectionConfigs(slug: string) {\n return this.request<DetectionSource[]>(\"/detection/configs/list\", { slug });\n }\n\n updateDetectionConfig(input: DetectionConfigUpdateInput) {\n return this.request<DetectionConfigUpdateResult>(\"/detection/configs/update\", input);\n }\n\n runDetectionConfigs(input: DetectionConfigRunInput) {\n return this.request<DetectionConfigRunResult>(\"/detection/configs/run\", input);\n }\n\n validateDetectionConfigs(input: DetectionConfigValidateInput) {\n return this.request<DetectionConfigValidateResult>(\n \"/detection/configs/validate\",\n input,\n );\n }\n\n getDetectionDrift(input: DetectionDriftInput) {\n return this.request<DetectionDriftResult>(\"/detection/drift\", {\n ...input,\n startDate: parseIsoDate(input.startDate),\n endDate: parseIsoDate(input.endDate),\n });\n }\n\n getOperationsQueuesSnapshot(input: OperationsQueuesSnapshotInput) {\n return this.request<OperationsQueuesSnapshotResult>(\n \"/operations/queues/snapshot\",\n input,\n );\n }\n\n getMetricsSummary(input: MetricsSummaryInput) {\n return this.request<MetricsSummaryResult>(\"/metrics/summary\", {\n ...input,\n startDate: parseIsoDate(input.startDate),\n endDate: parseIsoDate(input.endDate),\n });\n }\n\n getMetricsFound(input: MetricsFoundInput) {\n return this.request<MetricsFoundResult>(\"/metrics/found\", {\n ...input,\n startDate: parseIsoDate(input.startDate),\n endDate: parseIsoDate(input.endDate),\n });\n }\n\n getMetricsBreakdown(input: MetricsBreakdownInput) {\n return this.request<MetricsBreakdownResult>(\"/metrics/breakdown\", {\n ...input,\n startDate: parseIsoDate(input.startDate),\n endDate: parseIsoDate(input.endDate),\n });\n }\n\n createReport(input: ReportCreateInput) {\n return this.request<ReportCreateResult>(\"/report/create\", input);\n }\n\n listOrganizationReports(input: OrganizationReportsListInput) {\n return this.request<OrganizationReportsListResult>(\"/public/getOrganizationReports\", {\n slug: input.slug,\n limit: input.limit ?? 10,\n cursor: input.cursor,\n status: input.status,\n searchQuery: input.searchQuery,\n reporterQuery: input.reporterQuery,\n reportedByCustomer: input.reportedByCustomer,\n excludeAutomation: input.excludeAutomation,\n onlyRejected: input.onlyRejected,\n reviewStatuses: input.reviewStatuses?.length ? input.reviewStatuses : undefined,\n assetTypes: input.assetTypes?.length ? input.assetTypes : undefined,\n brandIds: input.brandIds?.length ? input.brandIds : undefined,\n countryCodes: input.countryCodes?.length ? input.countryCodes : undefined,\n reviewedByUserId: input.reviewedByUserId,\n startDate: parseIsoDateString(input.startDate),\n endDate: parseIsoDateString(input.endDate),\n updatedAtStartDate: parseIsoDateString(input.updatedAtStartDate),\n updatedAtEndDate: parseIsoDateString(input.updatedAtEndDate),\n });\n }\n\n listTakedowns(input: TakedownsListInput) {\n return this.request<TakedownsListResult>(\"/takedowns/list\", {\n organizationSlug: input.organizationSlug,\n query: input.query,\n startDate: parseIsoDateString(input.startDate),\n endDate: parseIsoDateString(input.endDate),\n assetType: input.assetType,\n takedownStatus: input.takedownStatus,\n livenessStatus: input.livenessStatus,\n brandIds: input.brandIds?.length ? input.brandIds : undefined,\n assigneeIds: input.assigneeIds?.length ? input.assigneeIds : undefined,\n startedAtStartDate: parseIsoDateString(input.startedAtStartDate),\n startedAtEndDate: parseIsoDateString(input.startedAtEndDate),\n hideAutomatedTakedowns: input.hideAutomatedTakedowns,\n hideAutomatedLivenessChecks: input.hideAutomatedLivenessChecks,\n sorting: input.sorting,\n per_page: input.perPage,\n next_page: input.nextPage,\n });\n }\n\n getOrganizationMetrics(input: OrganizationMetricsInput) {\n return this.requestGet<OrganizationMetricsResult>(\"/organization/metrics\", {\n organizationSlug: input.organizationSlug,\n slugs: input.slugs,\n allMyOrgs: input.allMyOrgs ? \"true\" : undefined,\n subscriptionStatus: input.subscriptionStatus,\n services: input.services ? JSON.stringify(input.services) : undefined,\n brandSlug: input.brandSlug,\n startDate: parseIsoDateString(input.startDate),\n endDate: parseIsoDateString(input.endDate),\n include: input.include,\n });\n }\n\n listHealthchecks() {\n return this.request<HealthchecksListResult>(\"/healthchecks/list\", {});\n }\n\n runHealthcheck(endpoint: string, input: Record<string, unknown>) {\n return this.request<HealthcheckResult>(endpoint, input);\n }\n\n getUserOrgs(input: UserOrgsInput) {\n return this.request<UserOrgsResult>(\"/user/orgs\", input);\n }\n\n getUserOrg(input: UserOrgGetInput) {\n return this.requestGet<UserOrgGetResult>(\n `/user/orgs/${encodeURIComponent(input.slug)}`,\n {},\n );\n }\n\n listAssets(input: AssetListInput) {\n return this.request<AssetListResult>(\"/asset/list\", {\n type: input.type,\n status: input.status,\n startDate: parseIsoDateString(input.startDate),\n endDate: parseIsoDateString(input.endDate),\n per_page: input.perPage,\n next_page: input.nextPage,\n });\n }\n\n listThreats(input: ThreatsListInput) {\n return this.request<ThreatsListResult>(\"/threats/list\", {\n query: input.query,\n startDate: parseIsoDateString(input.startDate),\n endDate: parseIsoDateString(input.endDate),\n assetType: input.assetType,\n sorting: input.sorting,\n per_page: input.perPage,\n next_page: input.nextPage,\n });\n }\n\n listDetections(input: DetectionListInput) {\n const filters: Array<{\n property: string;\n operator: \"in\" | \"notIn\";\n value: unknown[];\n }> = [];\n if (input.sources?.length) {\n filters.push({ property: \"source\", operator: \"in\", value: input.sources });\n }\n if (input.confidence?.length) {\n filters.push({ property: \"confidence\", operator: \"in\", value: input.confidence });\n }\n if (input.assetStatus?.length) {\n filters.push({\n property: \"assetStatus\",\n operator: \"in\",\n value: input.assetStatus,\n });\n }\n if (input.assetType?.length) {\n filters.push({ property: \"assetType\", operator: \"in\", value: input.assetType });\n }\n if (input.brandIds?.length) {\n filters.push({ property: \"brand\", operator: \"in\", value: input.brandIds });\n }\n if (input.liveness?.length) {\n filters.push({ property: \"liveness\", operator: \"in\", value: input.liveness });\n }\n if (input.watchlist?.length) {\n filters.push({ property: \"watchlist\", operator: \"in\", value: input.watchlist });\n }\n if (input.reported?.length) {\n filters.push({ property: \"reported\", operator: \"in\", value: input.reported });\n }\n if (input.countryCodes?.length) {\n filters.push({\n property: \"countryCode\",\n operator: \"in\",\n value: input.countryCodes,\n });\n }\n if (input.onlyDeleted) {\n filters.push({ property: \"deleted\", operator: \"in\", value: [\"deleted\"] });\n }\n return this.request<DetectionListResult>(\"/detection/list\", {\n slug: input.slug,\n cursor: input.cursor,\n limit: input.limit,\n query: input.query,\n startDate: parseIsoDate(input.startDate),\n endDate: parseIsoDate(input.endDate),\n filters: filters.length > 0 ? filters : undefined,\n });\n }\n\n searchReports(input: ReportsSearchInput) {\n return this.request<ReportsSearchResult>(\"/reports/search\", input);\n }\n\n listOrganizationAssets(input: OrganizationAssetsListInput) {\n return this.requestGet<OrganizationAssetsListResult>(\"/organization/assets\", {\n type: input.type,\n groupId: input.groupId !== undefined ? String(input.groupId) : undefined,\n query: input.query,\n per_page: input.perPage !== undefined ? String(input.perPage) : undefined,\n next_page: input.nextPage,\n });\n }\n\n listOrganizationAssetGroups() {\n return this.requestGet<OrganizationAssetGroupsListResult>(\n \"/organization/asset-groups\",\n {},\n );\n }\n\n listOrganizationBrands() {\n return this.requestGet<OrganizationBrandsListResult>(\"/organization/brands\", {});\n }\n\n getCurrentUser() {\n return this.request<UserMeResult>(\"/user/me\", {});\n }\n\n validateApiKey() {\n return this.requestGet<ValidateApiKeyResult>(\"/validate\", {});\n }\n}\n"]}