@chainpatrol/sdk 1.5.0 → 1.7.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,66 @@
1
1
  # @chainpatrol/sdk
2
2
 
3
+ ## 1.7.0
4
+
5
+ ### Minor Changes
6
+
7
+ - f98f547: Expose asset scan IDs and creation timestamps in asset search results.
8
+ - 9f19c88: Adds time-to-takedown metrics: `client.getMetricsTakedownTime()` in the SDK and
9
+ `chainpatrol metrics takedown-time --org <slug>` in the CLI, both backed by the
10
+ new `POST /metrics/takedown-time` endpoint. Returns the median time from
11
+ takedown start to completion per asset type, over an optional date range.
12
+
13
+ Also adds `parseIsoDateEndOfDay` to `@chainpatrol/sdk/api`: a date-only bound
14
+ such as `2026-08-18` now covers that whole day instead of cutting off at
15
+ midnight UTC. Server-side work lives in @chainpatrol/external-trpc and
16
+ @chainpatrol/validation; both are private packages and don't need version bumps.
17
+
18
+ - b037a0b: `GET /organization/assets` now accepts an optional `slug`, so callers whose
19
+ credentials reach more than one organization (user-scoped API keys, staff and
20
+ member sessions) can pick one instead of getting a flat 401. Organization-scoped
21
+ keys keep working unchanged when they omit it.
22
+
23
+ In the SDK, `client.listOrganizationAssets()` takes a `slug`. In the CLI,
24
+ `chainpatrol orgs assets list` forwards `--org <slug>` when one is set — the
25
+ existing no-flag invocation still resolves the org from an org-scoped key.
26
+
27
+ Server-side work lives in @chainpatrol/external-trpc and @chainpatrol/validation;
28
+ both are private packages and don't need version bumps.
29
+
30
+ ## 1.6.0
31
+
32
+ ### Minor Changes
33
+
34
+ - a253313: Adds `reviewOrganizationProposal` for approving, rejecting, or watchlisting the
35
+ proposals waiting on your organization, backed by
36
+ `POST /organization/proposals/{proposalId}/review`.
37
+
38
+ Approving takes a block `label`, plus a `brandId` for the labels that name an
39
+ impersonation target. Rejecting takes a `rejectReason` and an optional `note`.
40
+ Watchlisting parks the asset for re-evaluation. `assetId` is required alongside
41
+ `proposalId` and must match the proposal's current asset, returning `409`
42
+ otherwise.
43
+
44
+ `listOrganizationReports` now returns `proposals[].id` so a proposal can be
45
+ addressed.
46
+
47
+ Some approvals are declined and need to be handled on the Review page, returning
48
+ `403`. Reviews over the API are limited to 10 per organization per day, shared
49
+ across the organization's API credentials, and exceeding that returns `429`.
50
+ Reviews made from the Review page are not affected.
51
+
52
+ ### Patch Changes
53
+
54
+ - 108f9f8: `needsCustomerReview` now returns only the reports waiting on your review.
55
+
56
+ Reports your organization submitted itself are no longer included, and a
57
+ proposal you have passed back to ChainPatrol leaves the queue once you hand it
58
+ over. Your own reports stay fully visible in `listOrganizationReports` without
59
+ the filter.
60
+
61
+ `reviewOrganizationProposal` accepts only proposals in that queue and returns
62
+ `403` for anything else.
63
+
3
64
  ## 1.5.0
4
65
 
5
66
  ### Minor Changes
@@ -65,8 +65,10 @@ interface ApiClient {
65
65
  getMetricsSummary: (input: MetricsSummaryInput) => Promise<MetricsSummaryResult>;
66
66
  getMetricsFound: (input: MetricsFoundInput) => Promise<MetricsFoundResult>;
67
67
  getMetricsBreakdown: (input: MetricsBreakdownInput) => Promise<MetricsBreakdownResult>;
68
+ getMetricsTakedownTime: (input: MetricsTakedownTimeInput) => Promise<MetricsTakedownTimeResult>;
68
69
  createReport: (input: ReportCreateInput) => Promise<ReportCreateResult>;
69
70
  listOrganizationReports: (input: OrganizationReportsListInput) => Promise<OrganizationReportsListResult>;
71
+ reviewOrganizationProposal: (input: OrganizationProposalsReviewInput) => Promise<OrganizationProposalsReviewResult>;
70
72
  searchReports: (input: ReportsSearchInput) => Promise<ReportsSearchResult>;
71
73
  listTakedowns: (input: TakedownsListInput) => Promise<TakedownsListResult>;
72
74
  listThreats: (input: ThreatsListInput) => Promise<ThreatsListResult>;
@@ -129,6 +131,11 @@ interface AssetSearchResultItem {
129
131
  status: string;
130
132
  createdAt: string;
131
133
  }>;
134
+ scans: Array<{
135
+ id: number;
136
+ /** When the asset scan was created (ISO 8601, UTC). */
137
+ createdAt: string;
138
+ }>;
132
139
  takedown: {
133
140
  id: number;
134
141
  status: string;
@@ -415,6 +422,24 @@ interface MetricsBreakdownResult {
415
422
  brandName?: string;
416
423
  }>;
417
424
  }
425
+ interface MetricsTakedownTimeInput {
426
+ slug: string;
427
+ startDate?: string;
428
+ endDate?: string;
429
+ blockLabel?: string;
430
+ brandType?: "INDIVIDUAL" | "ORGANIZATION" | "PRODUCT";
431
+ countryCodes?: string[];
432
+ brandIds?: number[];
433
+ }
434
+ interface MetricsTakedownTimeResult {
435
+ byAssetType: Array<{
436
+ assetType: string;
437
+ medianTakedownMinutes: number;
438
+ medianTakedownHours: number;
439
+ medianTakedownDays: number;
440
+ count: number;
441
+ }>;
442
+ }
418
443
  interface ReportAssetInput {
419
444
  content: string;
420
445
  status?: "BLOCKED" | "ALLOWED" | "UNKNOWN";
@@ -544,6 +569,11 @@ interface OrganizationReportsListResult {
544
569
  updatedAt: string;
545
570
  attachments: OrganizationReportAttachment[];
546
571
  proposals: Array<{
572
+ /**
573
+ * Pass to `reviewOrganizationProposal` to approve, reject, or watchlist
574
+ * this proposal.
575
+ */
576
+ id: number;
547
577
  reviewStatus: string;
548
578
  asset: {
549
579
  id: number;
@@ -574,6 +604,75 @@ interface OrganizationReportsListResult {
574
604
  nextCursor: number | null;
575
605
  totalCount: number;
576
606
  }
607
+ /**
608
+ * Reject reasons the Review page offers. These feed ChainPatrol's
609
+ * detection-tuning breakdown, so pick the closest one rather than relying on
610
+ * `note`.
611
+ */
612
+ declare const PROPOSAL_REJECT_REASONS: readonly ["irrelevant", "no_malicious_activity", "insufficient_evidence", "not_targeting_org", "decayed"];
613
+ type ProposalRejectReason = (typeof PROPOSAL_REJECT_REASONS)[number];
614
+ /**
615
+ * Reasons for parking an asset on the watchlist. `OTHER` requires a `note`,
616
+ * which is then treated as the reason.
617
+ */
618
+ declare const PROPOSAL_WATCHLIST_REASONS: readonly ["DEAD", "PARKING", "NOT_ENOUGH_EVIDENCE", "OTHER"];
619
+ type ProposalWatchlistReason = (typeof PROPOSAL_WATCHLIST_REASONS)[number];
620
+ type CustomerReviewDecision = "APPROVE" | "REJECT" | "WATCHLIST";
621
+ interface OrganizationProposalsReviewInput {
622
+ /** From `proposals[].id` on `listOrganizationReports`. */
623
+ proposalId: number;
624
+ /**
625
+ * From `proposals[].asset.id` on the same proposal. Required, and must match
626
+ * the proposal's current asset — a mismatch returns 409. Proves the request was
627
+ * built from a proposal you read rather than a guessed or stale ID.
628
+ */
629
+ assetId: number;
630
+ /**
631
+ * Optional for organization-scoped API keys. Required when your credentials
632
+ * can reach more than one organization.
633
+ */
634
+ slug?: string;
635
+ /**
636
+ * `WATCHLIST` rejects the proposal and parks the asset so it is re-evaluated
637
+ * if it comes back alive.
638
+ */
639
+ decision: CustomerReviewDecision;
640
+ /** Required when `decision` is `APPROVE`. */
641
+ label?: string;
642
+ /**
643
+ * Optional for most labels, but required for `Brand Impersonation` and
644
+ * `Employee Impersonation`, which name a specific impersonation target.
645
+ */
646
+ brandId?: number;
647
+ /** Required when `decision` is `REJECT`. */
648
+ rejectReason?: ProposalRejectReason;
649
+ /** Required when `decision` is `WATCHLIST`. */
650
+ watchlistReason?: ProposalWatchlistReason;
651
+ /** Free-text detail. Required when `watchlistReason` is `OTHER`. */
652
+ note?: string;
653
+ }
654
+ interface OrganizationProposalsReviewResult {
655
+ proposal: {
656
+ id: number;
657
+ reviewStatus: string;
658
+ asset: {
659
+ id: number;
660
+ type: string;
661
+ content: string;
662
+ status: string;
663
+ };
664
+ };
665
+ review: {
666
+ id: number;
667
+ /** A `WATCHLIST` request is recorded as `REJECT` with the asset parked. */
668
+ decision: string;
669
+ label: string;
670
+ brandId: number | null;
671
+ comment: string;
672
+ createdAt: string;
673
+ };
674
+ watchlisted: boolean;
675
+ }
577
676
  declare const DETECTION_CONFIDENCE_LEVELS: readonly ["none", "low", "medium", "high"];
578
677
  type DetectionConfidence = (typeof DETECTION_CONFIDENCE_LEVELS)[number];
579
678
  type DetectionReportStatus = "REPORTED" | "NOT_REPORTED";
@@ -677,6 +776,7 @@ interface ThreatsListResult {
677
776
  next_page: string | null;
678
777
  }
679
778
  interface OrganizationAssetsListInput {
779
+ slug?: string;
680
780
  type?: string;
681
781
  groupId?: number;
682
782
  query?: string;
@@ -719,7 +819,7 @@ interface AssetGroupItem {
719
819
  interface OrganizationAssetGroupsListResult {
720
820
  groups: AssetGroupItem[];
721
821
  }
722
- type BrandType = "ORGANIZATION" | "INDIVIDUAL";
822
+ type BrandType = "ORGANIZATION" | "INDIVIDUAL" | "PRODUCT";
723
823
  interface BrandLegalDocument {
724
824
  present: boolean;
725
825
  fileName: string | null;
@@ -1241,8 +1341,10 @@ declare class ChainPatrolApiClient implements ApiClient {
1241
1341
  getMetricsSummary(input: MetricsSummaryInput): Promise<MetricsSummaryResult>;
1242
1342
  getMetricsFound(input: MetricsFoundInput): Promise<MetricsFoundResult>;
1243
1343
  getMetricsBreakdown(input: MetricsBreakdownInput): Promise<MetricsBreakdownResult>;
1344
+ getMetricsTakedownTime(input: MetricsTakedownTimeInput): Promise<MetricsTakedownTimeResult>;
1244
1345
  createReport(input: ReportCreateInput): Promise<ReportCreateResult>;
1245
1346
  listOrganizationReports(input: OrganizationReportsListInput): Promise<OrganizationReportsListResult>;
1347
+ reviewOrganizationProposal(input: OrganizationProposalsReviewInput): Promise<OrganizationProposalsReviewResult>;
1246
1348
  listTakedowns(input: TakedownsListInput): Promise<TakedownsListResult>;
1247
1349
  getOrganizationMetrics(input: OrganizationMetricsInput): Promise<OrganizationMetricsResult>;
1248
1350
  listHealthchecks(): Promise<HealthchecksListResult>;
@@ -1262,5 +1364,12 @@ declare class ChainPatrolApiClient implements ApiClient {
1262
1364
 
1263
1365
  declare function parseIsoDate(value: string | undefined): Date | undefined;
1264
1366
  declare function parseIsoDateString(value: string | undefined): string | undefined;
1367
+ /**
1368
+ * Same validation as `parseIsoDate`, but a date-only value covers the whole day
1369
+ * rather than collapsing to its first instant. An endpoint filtering on "up to
1370
+ * and including this date" would otherwise cut off at midnight UTC and drop
1371
+ * everything recorded on the day the caller asked for.
1372
+ */
1373
+ declare function parseIsoDateEndOfDay(value: string | undefined): Date | undefined;
1265
1374
 
1266
- export { ACTOR_KINDS, type ActorKind, 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 DetectionBrand, 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 OrganizationMetricsVisibility, type OrganizationPortalVisibility, type OrganizationReportAssetScan, type OrganizationReportAssetScanEnrichment, type OrganizationReportAttachment, type OrganizationReportVisibility, 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 TakedownProviderRef, type TakedownSortKey, type TakedownStatus, type TakedownsListInput, type TakedownsListResult, type ThreatItem, type ThreatsListInput, type ThreatsListResult, type UserMeResult, type UserOrg, type UserOrgBrandMetadata, type UserOrgGetInput, type UserOrgGetResult, type UserOrgIntegrations, type UserOrgLegalDocument, type UserOrgLegalDocuments, type UserOrgPortalCustomization, 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 };
1375
+ export { ACTOR_KINDS, type ActorKind, 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, type CustomerReviewDecision, DETECTION_CONFIDENCE_LEVELS, DETECTION_REPORTED_FILTERS, type DetectionBrand, 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, type MetricsTakedownTimeInput, type MetricsTakedownTimeResult, 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 OrganizationMetricsVisibility, type OrganizationPortalVisibility, type OrganizationProposalsReviewInput, type OrganizationProposalsReviewResult, type OrganizationReportAssetScan, type OrganizationReportAssetScanEnrichment, type OrganizationReportAttachment, type OrganizationReportVisibility, type OrganizationReportsListInput, type OrganizationReportsListResult, PROPOSAL_REJECT_REASONS, PROPOSAL_WATCHLIST_REASONS, type PendingApprovalService, type PendingServiceApproval, type ProposalRejectReason, type ProposalWatchlistReason, 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 TakedownProviderRef, type TakedownSortKey, type TakedownStatus, type TakedownsListInput, type TakedownsListResult, type ThreatItem, type ThreatsListInput, type ThreatsListResult, type UserMeResult, type UserOrg, type UserOrgBrandMetadata, type UserOrgGetInput, type UserOrgGetResult, type UserOrgIntegrations, type UserOrgLegalDocument, type UserOrgLegalDocuments, type UserOrgPortalCustomization, type UserOrgTrademarkRegistration, type UserOrgsInput, type UserOrgsObligatoryAdminApprovalFilter, type UserOrgsPendingServiceApprovalFilter, type UserOrgsResult, type UserOrgsServiceFilters, type UserOrgsSubscriptionStatus, type ValidateApiKeyResult, WATCHLIST_FILTER_VALUES, type WatchlistFilterValue, parseIsoDate, parseIsoDateEndOfDay, parseIsoDateString, staticApiKey, staticBearerToken };
@@ -65,8 +65,10 @@ interface ApiClient {
65
65
  getMetricsSummary: (input: MetricsSummaryInput) => Promise<MetricsSummaryResult>;
66
66
  getMetricsFound: (input: MetricsFoundInput) => Promise<MetricsFoundResult>;
67
67
  getMetricsBreakdown: (input: MetricsBreakdownInput) => Promise<MetricsBreakdownResult>;
68
+ getMetricsTakedownTime: (input: MetricsTakedownTimeInput) => Promise<MetricsTakedownTimeResult>;
68
69
  createReport: (input: ReportCreateInput) => Promise<ReportCreateResult>;
69
70
  listOrganizationReports: (input: OrganizationReportsListInput) => Promise<OrganizationReportsListResult>;
71
+ reviewOrganizationProposal: (input: OrganizationProposalsReviewInput) => Promise<OrganizationProposalsReviewResult>;
70
72
  searchReports: (input: ReportsSearchInput) => Promise<ReportsSearchResult>;
71
73
  listTakedowns: (input: TakedownsListInput) => Promise<TakedownsListResult>;
72
74
  listThreats: (input: ThreatsListInput) => Promise<ThreatsListResult>;
@@ -129,6 +131,11 @@ interface AssetSearchResultItem {
129
131
  status: string;
130
132
  createdAt: string;
131
133
  }>;
134
+ scans: Array<{
135
+ id: number;
136
+ /** When the asset scan was created (ISO 8601, UTC). */
137
+ createdAt: string;
138
+ }>;
132
139
  takedown: {
133
140
  id: number;
134
141
  status: string;
@@ -415,6 +422,24 @@ interface MetricsBreakdownResult {
415
422
  brandName?: string;
416
423
  }>;
417
424
  }
425
+ interface MetricsTakedownTimeInput {
426
+ slug: string;
427
+ startDate?: string;
428
+ endDate?: string;
429
+ blockLabel?: string;
430
+ brandType?: "INDIVIDUAL" | "ORGANIZATION" | "PRODUCT";
431
+ countryCodes?: string[];
432
+ brandIds?: number[];
433
+ }
434
+ interface MetricsTakedownTimeResult {
435
+ byAssetType: Array<{
436
+ assetType: string;
437
+ medianTakedownMinutes: number;
438
+ medianTakedownHours: number;
439
+ medianTakedownDays: number;
440
+ count: number;
441
+ }>;
442
+ }
418
443
  interface ReportAssetInput {
419
444
  content: string;
420
445
  status?: "BLOCKED" | "ALLOWED" | "UNKNOWN";
@@ -544,6 +569,11 @@ interface OrganizationReportsListResult {
544
569
  updatedAt: string;
545
570
  attachments: OrganizationReportAttachment[];
546
571
  proposals: Array<{
572
+ /**
573
+ * Pass to `reviewOrganizationProposal` to approve, reject, or watchlist
574
+ * this proposal.
575
+ */
576
+ id: number;
547
577
  reviewStatus: string;
548
578
  asset: {
549
579
  id: number;
@@ -574,6 +604,75 @@ interface OrganizationReportsListResult {
574
604
  nextCursor: number | null;
575
605
  totalCount: number;
576
606
  }
607
+ /**
608
+ * Reject reasons the Review page offers. These feed ChainPatrol's
609
+ * detection-tuning breakdown, so pick the closest one rather than relying on
610
+ * `note`.
611
+ */
612
+ declare const PROPOSAL_REJECT_REASONS: readonly ["irrelevant", "no_malicious_activity", "insufficient_evidence", "not_targeting_org", "decayed"];
613
+ type ProposalRejectReason = (typeof PROPOSAL_REJECT_REASONS)[number];
614
+ /**
615
+ * Reasons for parking an asset on the watchlist. `OTHER` requires a `note`,
616
+ * which is then treated as the reason.
617
+ */
618
+ declare const PROPOSAL_WATCHLIST_REASONS: readonly ["DEAD", "PARKING", "NOT_ENOUGH_EVIDENCE", "OTHER"];
619
+ type ProposalWatchlistReason = (typeof PROPOSAL_WATCHLIST_REASONS)[number];
620
+ type CustomerReviewDecision = "APPROVE" | "REJECT" | "WATCHLIST";
621
+ interface OrganizationProposalsReviewInput {
622
+ /** From `proposals[].id` on `listOrganizationReports`. */
623
+ proposalId: number;
624
+ /**
625
+ * From `proposals[].asset.id` on the same proposal. Required, and must match
626
+ * the proposal's current asset — a mismatch returns 409. Proves the request was
627
+ * built from a proposal you read rather than a guessed or stale ID.
628
+ */
629
+ assetId: number;
630
+ /**
631
+ * Optional for organization-scoped API keys. Required when your credentials
632
+ * can reach more than one organization.
633
+ */
634
+ slug?: string;
635
+ /**
636
+ * `WATCHLIST` rejects the proposal and parks the asset so it is re-evaluated
637
+ * if it comes back alive.
638
+ */
639
+ decision: CustomerReviewDecision;
640
+ /** Required when `decision` is `APPROVE`. */
641
+ label?: string;
642
+ /**
643
+ * Optional for most labels, but required for `Brand Impersonation` and
644
+ * `Employee Impersonation`, which name a specific impersonation target.
645
+ */
646
+ brandId?: number;
647
+ /** Required when `decision` is `REJECT`. */
648
+ rejectReason?: ProposalRejectReason;
649
+ /** Required when `decision` is `WATCHLIST`. */
650
+ watchlistReason?: ProposalWatchlistReason;
651
+ /** Free-text detail. Required when `watchlistReason` is `OTHER`. */
652
+ note?: string;
653
+ }
654
+ interface OrganizationProposalsReviewResult {
655
+ proposal: {
656
+ id: number;
657
+ reviewStatus: string;
658
+ asset: {
659
+ id: number;
660
+ type: string;
661
+ content: string;
662
+ status: string;
663
+ };
664
+ };
665
+ review: {
666
+ id: number;
667
+ /** A `WATCHLIST` request is recorded as `REJECT` with the asset parked. */
668
+ decision: string;
669
+ label: string;
670
+ brandId: number | null;
671
+ comment: string;
672
+ createdAt: string;
673
+ };
674
+ watchlisted: boolean;
675
+ }
577
676
  declare const DETECTION_CONFIDENCE_LEVELS: readonly ["none", "low", "medium", "high"];
578
677
  type DetectionConfidence = (typeof DETECTION_CONFIDENCE_LEVELS)[number];
579
678
  type DetectionReportStatus = "REPORTED" | "NOT_REPORTED";
@@ -677,6 +776,7 @@ interface ThreatsListResult {
677
776
  next_page: string | null;
678
777
  }
679
778
  interface OrganizationAssetsListInput {
779
+ slug?: string;
680
780
  type?: string;
681
781
  groupId?: number;
682
782
  query?: string;
@@ -719,7 +819,7 @@ interface AssetGroupItem {
719
819
  interface OrganizationAssetGroupsListResult {
720
820
  groups: AssetGroupItem[];
721
821
  }
722
- type BrandType = "ORGANIZATION" | "INDIVIDUAL";
822
+ type BrandType = "ORGANIZATION" | "INDIVIDUAL" | "PRODUCT";
723
823
  interface BrandLegalDocument {
724
824
  present: boolean;
725
825
  fileName: string | null;
@@ -1241,8 +1341,10 @@ declare class ChainPatrolApiClient implements ApiClient {
1241
1341
  getMetricsSummary(input: MetricsSummaryInput): Promise<MetricsSummaryResult>;
1242
1342
  getMetricsFound(input: MetricsFoundInput): Promise<MetricsFoundResult>;
1243
1343
  getMetricsBreakdown(input: MetricsBreakdownInput): Promise<MetricsBreakdownResult>;
1344
+ getMetricsTakedownTime(input: MetricsTakedownTimeInput): Promise<MetricsTakedownTimeResult>;
1244
1345
  createReport(input: ReportCreateInput): Promise<ReportCreateResult>;
1245
1346
  listOrganizationReports(input: OrganizationReportsListInput): Promise<OrganizationReportsListResult>;
1347
+ reviewOrganizationProposal(input: OrganizationProposalsReviewInput): Promise<OrganizationProposalsReviewResult>;
1246
1348
  listTakedowns(input: TakedownsListInput): Promise<TakedownsListResult>;
1247
1349
  getOrganizationMetrics(input: OrganizationMetricsInput): Promise<OrganizationMetricsResult>;
1248
1350
  listHealthchecks(): Promise<HealthchecksListResult>;
@@ -1262,5 +1364,12 @@ declare class ChainPatrolApiClient implements ApiClient {
1262
1364
 
1263
1365
  declare function parseIsoDate(value: string | undefined): Date | undefined;
1264
1366
  declare function parseIsoDateString(value: string | undefined): string | undefined;
1367
+ /**
1368
+ * Same validation as `parseIsoDate`, but a date-only value covers the whole day
1369
+ * rather than collapsing to its first instant. An endpoint filtering on "up to
1370
+ * and including this date" would otherwise cut off at midnight UTC and drop
1371
+ * everything recorded on the day the caller asked for.
1372
+ */
1373
+ declare function parseIsoDateEndOfDay(value: string | undefined): Date | undefined;
1265
1374
 
1266
- export { ACTOR_KINDS, type ActorKind, 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 DetectionBrand, 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 OrganizationMetricsVisibility, type OrganizationPortalVisibility, type OrganizationReportAssetScan, type OrganizationReportAssetScanEnrichment, type OrganizationReportAttachment, type OrganizationReportVisibility, 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 TakedownProviderRef, type TakedownSortKey, type TakedownStatus, type TakedownsListInput, type TakedownsListResult, type ThreatItem, type ThreatsListInput, type ThreatsListResult, type UserMeResult, type UserOrg, type UserOrgBrandMetadata, type UserOrgGetInput, type UserOrgGetResult, type UserOrgIntegrations, type UserOrgLegalDocument, type UserOrgLegalDocuments, type UserOrgPortalCustomization, 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 };
1375
+ export { ACTOR_KINDS, type ActorKind, 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, type CustomerReviewDecision, DETECTION_CONFIDENCE_LEVELS, DETECTION_REPORTED_FILTERS, type DetectionBrand, 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, type MetricsTakedownTimeInput, type MetricsTakedownTimeResult, 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 OrganizationMetricsVisibility, type OrganizationPortalVisibility, type OrganizationProposalsReviewInput, type OrganizationProposalsReviewResult, type OrganizationReportAssetScan, type OrganizationReportAssetScanEnrichment, type OrganizationReportAttachment, type OrganizationReportVisibility, type OrganizationReportsListInput, type OrganizationReportsListResult, PROPOSAL_REJECT_REASONS, PROPOSAL_WATCHLIST_REASONS, type PendingApprovalService, type PendingServiceApproval, type ProposalRejectReason, type ProposalWatchlistReason, 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 TakedownProviderRef, type TakedownSortKey, type TakedownStatus, type TakedownsListInput, type TakedownsListResult, type ThreatItem, type ThreatsListInput, type ThreatsListResult, type UserMeResult, type UserOrg, type UserOrgBrandMetadata, type UserOrgGetInput, type UserOrgGetResult, type UserOrgIntegrations, type UserOrgLegalDocument, type UserOrgLegalDocuments, type UserOrgPortalCustomization, type UserOrgTrademarkRegistration, type UserOrgsInput, type UserOrgsObligatoryAdminApprovalFilter, type UserOrgsPendingServiceApprovalFilter, type UserOrgsResult, type UserOrgsServiceFilters, type UserOrgsSubscriptionStatus, type ValidateApiKeyResult, WATCHLIST_FILTER_VALUES, type WatchlistFilterValue, parseIsoDate, parseIsoDateEndOfDay, parseIsoDateString, staticApiKey, staticBearerToken };
package/dist/api/index.js CHANGED
@@ -19,6 +19,18 @@ var __spreadValues = (a, b) => {
19
19
  return a;
20
20
  };
21
21
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
22
+ var __objRest = (source, exclude) => {
23
+ var target = {};
24
+ for (var prop in source)
25
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
26
+ target[prop] = source[prop];
27
+ if (source != null && __getOwnPropSymbols)
28
+ for (var prop of __getOwnPropSymbols(source)) {
29
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
30
+ target[prop] = source[prop];
31
+ }
32
+ return target;
33
+ };
22
34
  var __async = (__this, __arguments, generator) => {
23
35
  return new Promise((resolve, reject) => {
24
36
  var fulfilled = (value) => {
@@ -44,6 +56,19 @@ var __async = (__this, __arguments, generator) => {
44
56
  var REPORT_REVIEW_DECISIONS = ["APPROVE", "REJECT", "SKIP", "ESCALATE"];
45
57
  var REPORT_STATUSES = ["TODO", "IN_PROGRESS", "CLOSED"];
46
58
  var ACTOR_KINDS = ["human", "automation"];
59
+ var PROPOSAL_REJECT_REASONS = [
60
+ "irrelevant",
61
+ "no_malicious_activity",
62
+ "insufficient_evidence",
63
+ "not_targeting_org",
64
+ "decayed"
65
+ ];
66
+ var PROPOSAL_WATCHLIST_REASONS = [
67
+ "DEAD",
68
+ "PARKING",
69
+ "NOT_ENOUGH_EVIDENCE",
70
+ "OTHER"
71
+ ];
47
72
  var DETECTION_CONFIDENCE_LEVELS = ["none", "low", "medium", "high"];
48
73
  var DETECTION_REPORTED_FILTERS = ["reported", "not_reported"];
49
74
  var LIVENESS_FILTER_VALUES = ["ALIVE", "DEAD", "UNKNOWN"];
@@ -105,6 +130,15 @@ function parseIsoDateString(value) {
105
130
  var _a;
106
131
  return (_a = parseIsoDate(value)) == null ? void 0 : _a.toISOString();
107
132
  }
133
+ var DATE_ONLY_REGEX = /^\d{4}-\d{2}-\d{2}$/;
134
+ var MS_PER_DAY = 24 * 60 * 60 * 1e3;
135
+ function parseIsoDateEndOfDay(value) {
136
+ const parsed = parseIsoDate(value);
137
+ if (!parsed || !value || !DATE_ONLY_REGEX.test(value)) {
138
+ return parsed;
139
+ }
140
+ return new Date(parsed.getTime() + MS_PER_DAY - 1);
141
+ }
108
142
 
109
143
  // src/api/client.ts
110
144
  var DEFAULT_BASE_URL = "https://app.chainpatrol.io";
@@ -288,6 +322,15 @@ var ChainPatrolApiClient = class {
288
322
  endDate: parseIsoDate(input.endDate)
289
323
  }));
290
324
  }
325
+ getMetricsTakedownTime(input) {
326
+ return this.request("/metrics/takedown-time", __spreadProps(__spreadValues({}, input), {
327
+ startDate: parseIsoDate(input.startDate),
328
+ // Dates serialize as full timestamps, so a date-only `endDate` has to be
329
+ // widened here — the API can no longer tell it apart from an explicit
330
+ // midnight cut-off once it arrives.
331
+ endDate: parseIsoDateEndOfDay(input.endDate)
332
+ }));
333
+ }
291
334
  createReport(input) {
292
335
  return this.request("/report/create", input);
293
336
  }
@@ -317,6 +360,13 @@ var ChainPatrolApiClient = class {
317
360
  needsCustomerReview: optionalBooleanParam(input.needsCustomerReview)
318
361
  });
319
362
  }
363
+ reviewOrganizationProposal(input) {
364
+ const _a = input, { proposalId } = _a, body = __objRest(_a, ["proposalId"]);
365
+ return this.request(
366
+ `/organization/proposals/${proposalId}/review`,
367
+ body
368
+ );
369
+ }
320
370
  listTakedowns(input) {
321
371
  var _a, _b;
322
372
  return this.request("/takedowns/list", {
@@ -443,6 +493,7 @@ var ChainPatrolApiClient = class {
443
493
  }
444
494
  listOrganizationAssets(input) {
445
495
  return this.requestGet("/organization/assets", {
496
+ slug: input.slug,
446
497
  type: input.type,
447
498
  groupId: input.groupId !== void 0 ? String(input.groupId) : void 0,
448
499
  query: input.query,
@@ -474,12 +525,15 @@ exports.DETECTION_REPORTED_FILTERS = DETECTION_REPORTED_FILTERS;
474
525
  exports.LIVENESS_FILTER_VALUES = LIVENESS_FILTER_VALUES;
475
526
  exports.LIVENESS_STATUSES = LIVENESS_STATUSES;
476
527
  exports.ORGANIZATION_METRICS_INCLUDE_FIELDS = ORGANIZATION_METRICS_INCLUDE_FIELDS;
528
+ exports.PROPOSAL_REJECT_REASONS = PROPOSAL_REJECT_REASONS;
529
+ exports.PROPOSAL_WATCHLIST_REASONS = PROPOSAL_WATCHLIST_REASONS;
477
530
  exports.REPORT_REVIEW_DECISIONS = REPORT_REVIEW_DECISIONS;
478
531
  exports.REPORT_STATUSES = REPORT_STATUSES;
479
532
  exports.TAKEDOWN_SORT_KEYS = TAKEDOWN_SORT_KEYS;
480
533
  exports.TAKEDOWN_STATUSES = TAKEDOWN_STATUSES;
481
534
  exports.WATCHLIST_FILTER_VALUES = WATCHLIST_FILTER_VALUES;
482
535
  exports.parseIsoDate = parseIsoDate;
536
+ exports.parseIsoDateEndOfDay = parseIsoDateEndOfDay;
483
537
  exports.parseIsoDateString = parseIsoDateString;
484
538
  exports.staticApiKey = staticApiKey;
485
539
  exports.staticBearerToken = staticBearerToken;