@chainpatrol/sdk 1.6.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/dist/index.js CHANGED
@@ -1313,17 +1313,17 @@ var PolyDateFormatter = class {
1313
1313
  constructor(dt, intl, opts) {
1314
1314
  this.opts = opts;
1315
1315
  this.originalZone = void 0;
1316
- let z50 = void 0;
1316
+ let z54 = void 0;
1317
1317
  if (this.opts.timeZone) {
1318
1318
  this.dt = dt;
1319
1319
  } else if (dt.zone.type === "fixed") {
1320
1320
  const gmtOffset = -1 * (dt.offset / 60);
1321
1321
  const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
1322
1322
  if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
1323
- z50 = offsetZ;
1323
+ z54 = offsetZ;
1324
1324
  this.dt = dt;
1325
1325
  } else {
1326
- z50 = "UTC";
1326
+ z54 = "UTC";
1327
1327
  this.dt = dt.offset === 0 ? dt : dt.setZone("UTC").plus({ minutes: dt.offset });
1328
1328
  this.originalZone = dt.zone;
1329
1329
  }
@@ -1331,14 +1331,14 @@ var PolyDateFormatter = class {
1331
1331
  this.dt = dt;
1332
1332
  } else if (dt.zone.type === "iana") {
1333
1333
  this.dt = dt;
1334
- z50 = dt.zone.name;
1334
+ z54 = dt.zone.name;
1335
1335
  } else {
1336
- z50 = "UTC";
1336
+ z54 = "UTC";
1337
1337
  this.dt = dt.setZone("UTC").plus({ minutes: dt.offset });
1338
1338
  this.originalZone = dt.zone;
1339
1339
  }
1340
1340
  const intlOpts = __spreadValues({}, this.opts);
1341
- intlOpts.timeZone = intlOpts.timeZone || z50;
1341
+ intlOpts.timeZone = intlOpts.timeZone || z54;
1342
1342
  this.dtf = getCachedDTF(intl, intlOpts);
1343
1343
  }
1344
1344
  format() {
@@ -7464,859 +7464,69 @@ zod.z.object({
7464
7464
  zod.z.object({
7465
7465
  result: zod.z.string()
7466
7466
  });
7467
- zod.z.object({
7468
- slug: zod.z.string().min(1),
7469
- configId: zod.z.number().int().positive(),
7470
- status: zod.z.nativeEnum(ThreatDetectionConfigStatus).optional(),
7471
- title: zod.z.string().trim().optional(),
7472
- description: zod.z.string().trim().nullable().optional(),
7473
- cron: zod.z.string().trim().nullable().optional(),
7474
- config: zod.z.record(zod.z.unknown()).optional(),
7475
- mergeConfig: zod.z.boolean().default(false),
7476
- brandId: zod.z.number().int().positive().nullable().optional().describe(
7477
- "Optional brand connection for this detection config. Pass null to clear the link. Only valid for org-scoped configs; the brand must belong to the same organization."
7478
- )
7479
- });
7480
- zod.z.object({
7481
- config: zod.z.object({
7482
- id: zod.z.number(),
7483
- source: zod.z.string(),
7484
- status: zod.z.nativeEnum(ThreatDetectionConfigStatus),
7485
- title: zod.z.string(),
7486
- description: zod.z.string().nullable(),
7487
- cron: zod.z.string().nullable(),
7488
- config: zod.z.record(zod.z.unknown()),
7489
- updatedAt: zod.z.date(),
7490
- brandId: zod.z.number().nullable()
7491
- })
7492
- });
7493
- zod.z.object({
7494
- slug: zod.z.string().min(1),
7495
- source: zod.z.string().optional(),
7496
- minResults: zod.z.number().int().min(0).default(1),
7497
- lookbackHours: zod.z.number().int().min(1).default(24 * 7),
7498
- runBeforeValidate: zod.z.boolean().default(false),
7499
- includeDisabled: zod.z.boolean().default(false)
7500
- });
7501
- zod.z.object({
7502
- ok: zod.z.boolean(),
7503
- summary: zod.z.object({
7504
- checkedConfigs: zod.z.number(),
7505
- passingConfigs: zod.z.number(),
7506
- failingConfigs: zod.z.number(),
7507
- lookbackHours: zod.z.number(),
7508
- minResults: zod.z.number()
7509
- }),
7510
- validations: zod.z.array(
7511
- zod.z.object({
7512
- configId: zod.z.number(),
7513
- source: zod.z.string(),
7514
- status: zod.z.nativeEnum(ThreatDetectionConfigStatus),
7515
- ran: zod.z.boolean(),
7516
- runOk: zod.z.boolean(),
7517
- runMessage: zod.z.string().nullable(),
7518
- recentResultCount: zod.z.number(),
7519
- valid: zod.z.boolean()
7520
- })
7521
- )
7522
- });
7523
- zod.z.object({
7524
- slug: zod.z.string().min(1),
7525
- configId: zod.z.number().int().positive().optional(),
7526
- source: zod.z.string().min(1).optional(),
7527
- includeDisabled: zod.z.boolean().default(false)
7528
- });
7529
- zod.z.object({
7530
- ranCount: zod.z.number(),
7531
- successCount: zod.z.number(),
7532
- failedCount: zod.z.number(),
7533
- results: zod.z.array(
7534
- zod.z.object({
7535
- configId: zod.z.number(),
7536
- source: zod.z.string(),
7537
- ok: zod.z.boolean(),
7538
- message: zod.z.string().nullable(),
7539
- assetsCount: zod.z.number()
7540
- })
7541
- )
7542
- });
7543
- var DetectionDriftThresholdsSchema = zod.z.object({
7544
- zeroResultsMaxHours: zod.z.number().int().positive().default(72),
7545
- noisyResultsPerDay: zod.z.number().positive().default(100),
7546
- noisyAllowedRatioThreshold: zod.z.number().min(0).max(1).default(0.6),
7547
- staleConfigDays: zod.z.number().int().positive().default(30)
7548
- });
7549
- zod.z.object({
7550
- slug: zod.z.string().min(1),
7551
- lookbackHours: zod.z.number().int().positive().default(168),
7552
- startDate: zod.z.date().optional(),
7553
- endDate: zod.z.date().optional(),
7554
- source: zod.z.string().min(1).optional(),
7555
- configIds: zod.z.array(zod.z.number().int().positive()).optional(),
7556
- includeDisabled: zod.z.boolean().default(false),
7557
- thresholds: DetectionDriftThresholdsSchema.optional()
7558
- }).refine(
7559
- (value) => !value.startDate && !value.endDate || Boolean(value.startDate) && Boolean(value.endDate),
7560
- {
7561
- message: "Provide both startDate and endDate when using explicit date range",
7562
- path: ["startDate"]
7563
- }
7564
- );
7565
- var DetectionDriftSignalSchema = zod.z.object({
7566
- signal: zod.z.enum(["zero_results_too_long", "noisy_source", "stale_query"]),
7567
- configId: zod.z.number().int().positive(),
7568
- source: zod.z.string(),
7569
- title: zod.z.string().nullable(),
7570
- status: zod.z.string(),
7571
- severity: zod.z.enum(["low", "medium", "high"]),
7572
- details: zod.z.record(zod.z.unknown())
7573
- });
7574
- zod.z.object({
7575
- ok: zod.z.boolean(),
7576
- range: zod.z.object({
7577
- startDate: zod.z.date(),
7578
- endDate: zod.z.date(),
7579
- lookbackHours: zod.z.number().int().positive()
7580
- }),
7581
- thresholds: DetectionDriftThresholdsSchema,
7582
- summary: zod.z.object({
7583
- checkedConfigs: zod.z.number().int().nonnegative(),
7584
- signalCount: zod.z.number().int().nonnegative(),
7585
- zeroResultsCount: zod.z.number().int().nonnegative(),
7586
- noisyCount: zod.z.number().int().nonnegative(),
7587
- staleCount: zod.z.number().int().nonnegative()
7588
- }),
7589
- signals: zod.z.array(DetectionDriftSignalSchema)
7590
- });
7591
- var BucketsSchema = zod.z.object({
7592
- lt24h: zod.z.number().int().nonnegative(),
7593
- h24to72: zod.z.number().int().nonnegative(),
7594
- h72to168: zod.z.number().int().nonnegative(),
7595
- gte168h: zod.z.number().int().nonnegative()
7596
- });
7597
- zod.z.object({
7598
- slug: zod.z.string().min(1).optional(),
7599
- all: zod.z.boolean().default(false),
7600
- windowHours: zod.z.number().int().positive().default(168)
7601
- });
7602
- zod.z.object({
7603
- generatedAt: zod.z.date(),
7604
- scope: zod.z.object({
7605
- slug: zod.z.string().nullable(),
7606
- all: zod.z.boolean()
7607
- }),
7608
- reviewQueue: zod.z.object({
7609
- totalPendingProposals: zod.z.number().int().nonnegative(),
7610
- distinctReports: zod.z.number().int().nonnegative(),
7611
- ageBuckets: BucketsSchema,
7612
- slaBuckets: zod.z.object({
7613
- breached: zod.z.number().int().nonnegative(),
7614
- dueWithin24h: zod.z.number().int().nonnegative(),
7615
- dueWithin72h: zod.z.number().int().nonnegative(),
7616
- beyond72h: zod.z.number().int().nonnegative(),
7617
- missingSla: zod.z.number().int().nonnegative()
7618
- }),
7619
- byOrg: zod.z.array(
7620
- zod.z.object({
7621
- slug: zod.z.string(),
7622
- pendingProposals: zod.z.number().int().nonnegative()
7623
- })
7624
- )
7625
- }),
7626
- takedownQueue: zod.z.object({
7627
- totalOpen: zod.z.number().int().nonnegative(),
7628
- statusCounts: zod.z.object({
7629
- todo: zod.z.number().int().nonnegative(),
7630
- inProgress: zod.z.number().int().nonnegative(),
7631
- pendingInput: zod.z.number().int().nonnegative()
7632
- }),
7633
- ageBuckets: BucketsSchema,
7634
- staleInProgress: zod.z.number().int().nonnegative(),
7635
- byOrg: zod.z.array(
7636
- zod.z.object({
7637
- slug: zod.z.string(),
7638
- openTakedowns: zod.z.number().int().nonnegative()
7639
- })
7640
- )
7641
- })
7642
- });
7643
- var HealthcheckCategorySchema = zod.z.enum([
7644
- "detection",
7645
- "reviewing",
7646
- "blocklisting",
7647
- "takedowns",
7648
- "assets",
7649
- "organization"
7650
- ]);
7651
- var HealthcheckSeveritySchema = zod.z.enum(["ok", "warn", "fail"]);
7652
- var HealthcheckFindingSchema = zod.z.object({
7653
- kind: zod.z.string(),
7654
- ref: zod.z.string().nullable(),
7655
- message: zod.z.string(),
7656
- severity: zod.z.enum(["warn", "fail"])
7657
- });
7658
- zod.z.object({
7659
- id: zod.z.string(),
7660
- title: zod.z.string(),
7661
- category: HealthcheckCategorySchema,
7662
- generatedAt: zod.z.date(),
7663
- scope: zod.z.object({
7664
- slug: zod.z.string().nullable()
7665
- }),
7666
- ok: zod.z.boolean(),
7667
- severity: HealthcheckSeveritySchema,
7668
- observed: zod.z.record(zod.z.union([zod.z.number(), zod.z.string(), zod.z.boolean()]).nullable()),
7669
- threshold: zod.z.record(zod.z.union([zod.z.number(), zod.z.string(), zod.z.boolean()]).nullable()),
7670
- findings: zod.z.array(HealthcheckFindingSchema),
7671
- suggestedAction: zod.z.string().nullable(),
7672
- appUrl: zod.z.string().nullable()
7673
- });
7674
-
7675
- // ../../internal/validation/src/public/healthchecks/assets-dead-asset-spike.ts
7676
- zod.z.object({
7677
- slug: zod.z.string().min(1),
7678
- windowHours: zod.z.number().int().positive().default(24),
7679
- baselineDays: zod.z.number().int().positive().default(7),
7680
- warnMultiplier: zod.z.number().positive().default(2),
7681
- failMultiplier: zod.z.number().positive().default(4),
7682
- minSpikeCount: zod.z.number().int().min(1).default(10)
7683
- });
7684
- zod.z.object({});
7685
- var HealthcheckRegistryEntrySchema = zod.z.object({
7686
- id: zod.z.string(),
7687
- title: zod.z.string(),
7688
- description: zod.z.string(),
7689
- category: HealthcheckCategorySchema,
7690
- implemented: zod.z.boolean(),
7691
- endpoint: zod.z.string().nullable(),
7692
- defaultThreshold: zod.z.record(zod.z.union([zod.z.number(), zod.z.string()])).optional(),
7693
- notImplementedReason: zod.z.string().optional()
7694
- });
7695
- zod.z.object({
7696
- checks: zod.z.array(HealthcheckRegistryEntrySchema)
7697
- });
7698
- zod.z.object({
7699
- slug: zod.z.string().min(1)
7700
- });
7701
- zod.z.object({
7702
- slug: zod.z.string().min(1),
7703
- warnThreshold: zod.z.number().int().nonnegative().default(50),
7704
- failThreshold: zod.z.number().int().nonnegative().default(100)
7705
- });
7706
- zod.z.object({
7707
- slug: zod.z.string().min(1),
7708
- warnAgeHours: zod.z.number().int().positive().default(24 * 7),
7709
- failAgeHours: zod.z.number().int().positive().default(24 * 14)
7710
- });
7711
- zod.z.object({
7712
- slug: zod.z.string().min(1),
7713
- warnAgeHours: zod.z.number().int().nonnegative().default(24 * 30),
7714
- failAgeHours: zod.z.number().int().nonnegative().default(24 * 60)
7715
- });
7716
- zod.z.object({
7717
- slug: zod.z.string().min(1),
7718
- lookbackHours: zod.z.number().int().positive().default(24 * 7),
7719
- warnThreshold: zod.z.number().int().nonnegative().default(3),
7720
- failThreshold: zod.z.number().int().nonnegative().default(10)
7721
- });
7722
- zod.z.object({
7723
- slug: zod.z.string().min(1),
7724
- warnThreshold: zod.z.number().int().nonnegative().default(30),
7725
- failThreshold: zod.z.number().int().nonnegative().default(75)
7726
- });
7727
- zod.z.object({
7728
- slug: zod.z.string().min(1),
7729
- staleThresholdHours: zod.z.number().int().positive().default(24 * 7),
7730
- warnThreshold: zod.z.number().int().nonnegative().default(1),
7731
- failThreshold: zod.z.number().int().nonnegative().default(5)
7732
- });
7733
- zod.z.object({
7734
- slug: zod.z.string().min(1),
7735
- warnThreshold: zod.z.number().int().nonnegative().default(50),
7736
- failThreshold: zod.z.number().int().nonnegative().default(100)
7737
- });
7738
- var BreakdownBySchema = zod.z.enum(["day", "type", "brand"]);
7739
- zod.z.object({
7740
- slug: zod.z.string().min(1),
7741
- by: BreakdownBySchema,
7742
- startDate: zod.z.date().optional(),
7743
- endDate: zod.z.date().optional(),
7744
- brandIds: zod.z.array(zod.z.number().int().positive()).optional()
7745
- });
7746
- zod.z.object({
7747
- by: BreakdownBySchema,
7748
- points: zod.z.array(
7749
- zod.z.object({
7750
- key: zod.z.string(),
7751
- count: zod.z.number(),
7752
- date: zod.z.string().optional(),
7753
- type: zod.z.string().optional(),
7754
- brandId: zod.z.number().optional(),
7755
- brandSlug: zod.z.string().optional(),
7756
- brandName: zod.z.string().optional()
7757
- })
7758
- )
7759
- });
7760
- zod.z.object({
7761
- slug: zod.z.string().min(1),
7762
- startDate: zod.z.date(),
7763
- endDate: zod.z.date(),
7764
- brandIds: zod.z.array(zod.z.number().int().positive()).optional()
7765
- });
7766
- zod.z.object({
7767
- metric: zod.z.literal("new_threats"),
7768
- found: zod.z.number(),
7769
- range: zod.z.object({
7770
- startDate: zod.z.date(),
7771
- endDate: zod.z.date()
7772
- })
7773
- });
7774
- zod.z.object({
7775
- slug: zod.z.string().min(1),
7776
- startDate: zod.z.date().optional(),
7777
- endDate: zod.z.date().optional(),
7778
- brandIds: zod.z.array(zod.z.number().int().positive()).optional()
7779
- });
7780
- zod.z.object({
7781
- metrics: zod.z.object({
7782
- reports: zod.z.number(),
7783
- newThreats: zod.z.number(),
7784
- threatsWatchlisted: zod.z.number(),
7785
- takedownsFiled: zod.z.number(),
7786
- takedownsCompleted: zod.z.number(),
7787
- domainThreats: zod.z.number(),
7788
- twitterThreats: zod.z.number(),
7789
- telegramThreats: zod.z.number(),
7790
- otherThreats: zod.z.number()
7791
- }),
7792
- blockedByDay: zod.z.array(
7793
- zod.z.object({
7794
- date: zod.z.string(),
7795
- count: zod.z.number()
7796
- })
7797
- ),
7798
- blockedByType: zod.z.array(
7799
- zod.z.object({
7800
- type: zod.z.string(),
7801
- count: zod.z.number()
7802
- })
7803
- )
7804
- });
7805
- zod.z.object({
7806
- type: zod.z.nativeEnum(AssetType).optional().describe("Filter by asset type (URL, ADDRESS, etc.)"),
7807
- groupId: zod.z.number().int().optional().describe(
7808
- "Filter by group ID. Use -1 for ungrouped assets only. Omit for all assets."
7809
- ),
7810
- query: zod.z.string().optional().describe("Search query to filter assets by content"),
7811
- per_page: zod.z.number().int().min(1).max(1e3).optional().default(100).describe("The number of assets to return per page (max 1000)"),
7812
- next_page: zod.z.string().optional().nullable().describe("Cursor for fetching the next page of results")
7813
- }).describe(
7814
- `List organization assets request body
7815
-
7816
- Returns all assets belonging to the organization associated with your API key.
7817
- Supports filtering by type, group, and search query.`
7818
- );
7819
- var organizationAssetItemSchema = zod.z.object({
7820
- id: zod.z.number().describe("Asset ID"),
7821
- content: zod.z.string().describe("Asset content (URL, address, handle, etc.)"),
7822
- type: zod.z.nativeEnum(AssetType).describe("Asset type"),
7823
- status: zod.z.nativeEnum(AssetStatus).describe("Asset status"),
7824
- name: zod.z.string().nullable().describe("Asset display name"),
7825
- description: zod.z.string().nullable().describe("Asset description"),
7826
- group: zod.z.object({
7827
- id: zod.z.number().describe("Group ID"),
7828
- name: zod.z.string().describe("Group name")
7829
- }).nullable().describe("Asset group information"),
7830
- livenessStatus: zod.z.nativeEnum(LivenessStatus).nullable().describe(
7831
- "Whether the asset is currently reachable (`ALIVE`), gone (`DEAD`), or hasn't been checked (`UNKNOWN`). `null` when liveness has never been evaluated."
7832
- ),
7833
- blockedAt: zod.z.date().nullable().describe(
7834
- "When the asset transitioned to BLOCKED status. `null` for non-blocked assets. Distinct from `updatedAt`."
7835
- ),
7836
- createdAt: zod.z.date().describe("When the asset was created"),
7837
- updatedAt: zod.z.date().describe("When the asset was last updated")
7838
- });
7839
- zod.z.object({
7840
- assets: zod.z.array(organizationAssetItemSchema).describe("List of assets"),
7841
- next_page: zod.z.string().nullable().optional().describe("Cursor for fetching the next page of results")
7842
- }).describe("Successful operation");
7843
- var addAssetItemSchema = zod.z.object({
7844
- content: zod.z.string().describe("Asset content (URL, address, handle, etc.)"),
7845
- name: zod.z.string().optional().describe("Optional display name for the asset"),
7846
- description: zod.z.string().optional().describe("Optional description for the asset"),
7847
- groupId: zod.z.number().int().positive().optional().describe("Optional group ID to assign the asset to")
7848
- });
7849
- zod.z.object({
7850
- assets: zod.z.array(addAssetItemSchema).min(1).max(1e3).describe("Array of assets to add (max 1000 per request)")
7851
- }).describe(
7852
- `Add assets to organization allowlist
7853
-
7854
- Batch add multiple assets to your organization's allowlist.
7855
- Each asset will be automatically parsed and classified.
7856
- Assets will be auto-approved as ALLOWED status.`
7857
- );
7858
- var addAssetResultSchema = zod.z.object({
7859
- content: zod.z.string().describe("Asset content"),
7860
- success: zod.z.boolean().describe("Whether the asset was added successfully"),
7861
- id: zod.z.number().optional().describe("Asset ID if successful"),
7862
- error: zod.z.string().optional().describe("Error message if failed")
7863
- });
7864
- zod.z.object({
7865
- results: zod.z.array(addAssetResultSchema).describe("Results for each asset"),
7866
- successCount: zod.z.number().describe("Number of assets successfully added"),
7867
- errorCount: zod.z.number().describe("Number of assets that failed to add")
7868
- }).describe("Batch add operation results");
7869
- zod.z.object({
7870
- assetId: zod.z.number().int().positive().describe("ID of the asset to update"),
7871
- name: zod.z.string().optional().describe("New display name for the asset"),
7872
- description: zod.z.string().nullable().optional().describe("New description for the asset"),
7873
- groupId: zod.z.number().int().positive().nullable().optional().describe("New group ID (null to ungroup)")
7874
- }).describe(
7875
- `Update an organization asset
7876
-
7877
- Update the name, description, or group assignment of an asset.`
7878
- );
7879
- zod.z.object({
7880
- id: zod.z.number().describe("Asset ID"),
7881
- content: zod.z.string().describe("Asset content"),
7882
- name: zod.z.string().nullable().describe("Asset display name"),
7883
- description: zod.z.string().nullable().describe("Asset description"),
7884
- groupId: zod.z.number().nullable().describe("Group ID")
7885
- }).describe("Updated asset");
7886
- zod.z.object({
7887
- assetId: zod.z.number().int().positive().describe("ID of the asset to remove")
7888
- }).describe(
7889
- `Remove an asset from the organization
7890
-
7891
- This removes the asset from the organization's allowlist.`
7892
- );
7893
- zod.z.object({
7894
- success: zod.z.boolean().describe("Whether the asset was removed successfully"),
7895
- id: zod.z.number().describe("Asset ID that was removed")
7896
- }).describe("Delete operation result");
7897
- zod.z.object({}).describe(
7898
- `List organization asset groups
7899
-
7900
- Returns all asset groups belonging to the organization associated with your API key.`
7901
- );
7902
- var assetGroupItemSchema = zod.z.object({
7903
- id: zod.z.number().describe("Group ID"),
7904
- name: zod.z.string().describe("Group name"),
7905
- assetCount: zod.z.number().describe("Number of assets in this group")
7906
- });
7907
- zod.z.object({
7908
- groups: zod.z.array(assetGroupItemSchema).describe("List of asset groups")
7909
- }).describe("Successful operation");
7910
- zod.z.object({
7911
- name: zod.z.string().min(1).max(255).describe("Name for the new group")
7912
- }).describe(
7913
- `Create a new asset group
7914
-
7915
- Creates a new asset group for organizing your organization's assets.`
7916
- );
7917
- zod.z.object({
7918
- id: zod.z.number().describe("Created group ID"),
7919
- name: zod.z.string().describe("Group name")
7920
- }).describe("Created group");
7921
- zod.z.object({
7922
- groupId: zod.z.number().int().positive().describe("ID of the group to update"),
7923
- name: zod.z.string().min(1).max(255).describe("New name for the group")
7924
- }).describe(
7925
- `Update an asset group
7926
-
7927
- Rename an existing asset group.`
7928
- );
7929
- zod.z.object({
7930
- id: zod.z.number().describe("Group ID"),
7931
- name: zod.z.string().describe("Updated group name")
7932
- }).describe("Updated group");
7933
- zod.z.object({
7934
- groupId: zod.z.number().int().positive().describe("ID of the group to delete")
7935
- }).describe(
7936
- `Delete an asset group
7937
-
7938
- Deletes an asset group. Assets in this group will become ungrouped.`
7939
- );
7940
- zod.z.object({
7941
- success: zod.z.boolean().describe("Whether the group was deleted successfully"),
7942
- id: zod.z.number().describe("Group ID that was deleted"),
7943
- unassignedAssetCount: zod.z.number().describe("Number of assets that were unassigned from this group")
7944
- }).describe("Delete operation result");
7945
- zod.z.object({}).describe(
7946
- `List organization brands
7947
-
7948
- Returns all brands belonging to the organization associated with your API key,
7949
- including sub-brands (\`ORGANIZATION\`), individual / employee brands
7950
- (\`INDIVIDUAL\`), and product brands (\`PRODUCT\`). Soft-deleted brands are
7951
- excluded.`
7952
- );
7953
- var brandLegalDocumentSchema = zod.z.object({
7954
- present: zod.z.boolean().describe("Whether the brand has this document attached"),
7955
- fileName: zod.z.string().nullable().describe("Original filename of the uploaded document (null when not present)"),
7956
- fileUrl: zod.z.string().nullable().describe("Direct URL to view or download the document (null when not present)")
7957
- });
7958
- var brandTrademarkRegistrationSchema = zod.z.object({
7959
- id: zod.z.number().describe("Trademark registration ID"),
7960
- brandName: zod.z.string().describe("Trademarked brand name as it appears on the registration"),
7961
- trademarkOffice: zod.z.string().describe("Issuing trademark office (e.g. `USPTO`, `EUIPO`)"),
7962
- registrationNumber: zod.z.string().describe("Registration number assigned by the office"),
7963
- goodsAndServicesClass: zod.z.string().describe("Nice Classification class(es) the registration covers"),
7964
- rightsOwnerName: zod.z.string().nullable().describe("Legal entity the trademark is registered to, if recorded"),
7965
- registrationPageUrl: zod.z.string().nullable().describe("Public URL on the trademark office's site, if recorded"),
7966
- certificateFileName: zod.z.string().nullable().describe(
7967
- "Original filename of the uploaded certificate PDF (null when no certificate is attached)"
7968
- ),
7969
- certificateFileUrl: zod.z.string().nullable().describe(
7970
- "Direct URL to view or download the certificate PDF (null when no certificate is attached)"
7971
- )
7972
- });
7973
- var brandItemSchema = zod.z.object({
7974
- id: zod.z.number().describe("Brand ID"),
7975
- slug: zod.z.string().describe("Brand slug (stable, URL-safe identifier)"),
7976
- name: zod.z.string().describe("Display name"),
7977
- type: zod.z.nativeEnum(BrandType).describe(
7978
- "Brand type: `ORGANIZATION` for parent brands, `INDIVIDUAL` for employee or person brands, `PRODUCT` for a specific product or service offering"
7979
- ),
7980
- description: zod.z.string().nullable().describe("Free-form description, if set"),
7981
- avatarUrl: zod.z.string().nullable().describe("URL of the brand's avatar / logo image"),
7982
- websiteUrl: zod.z.string().nullable().describe("Official brand website URL"),
7983
- twitterHandle: zod.z.string().nullable().describe("Official Twitter / X handle (without @)"),
7984
- brandColors: zod.z.array(zod.z.string()).describe("HEX color strings associated with the brand (e.g. `#FF0000`)"),
7985
- includedTerms: zod.z.array(zod.z.string()).describe("Terms that should be included when matching this brand"),
7986
- excludedTerms: zod.z.array(zod.z.string()).describe("Terms that should be excluded when matching this brand"),
7987
- tickers: zod.z.array(zod.z.string()).describe("Ticker symbols associated with the brand (e.g. `$JUP`)"),
7988
- brandGroupId: zod.z.number().nullable().describe(
7989
- "Group this brand belongs to (only set for `INDIVIDUAL` and `PRODUCT` brands)"
7990
- ),
7991
- createdAt: zod.z.date().describe("When the brand was created"),
7992
- useOrganizationDocs: zod.z.boolean().describe(
7993
- "When true, this brand inherits its Letter of Authorization and Power of Attorney from the organization rather than carrying its own. The `legalDocuments` block below always reflects the brand-level attachments \u2014 read `/user/orgs/{slug}` for the org-level fallbacks."
7994
- ),
7995
- legalDocuments: zod.z.object({
7996
- letterOfAuthorization: brandLegalDocumentSchema,
7997
- powerOfAttorney: brandLegalDocumentSchema
7998
- }).describe("Brand-level Letter of Authorization and Power of Attorney attachments"),
7999
- trademarkRegistrations: zod.z.array(brandTrademarkRegistrationSchema).describe(
8000
- "Trademark registrations attached to this brand. An empty array means no trademarks are on file for the brand \u2014 use this to identify brands that still need them added."
8001
- )
8002
- });
8003
- zod.z.object({
8004
- brands: zod.z.array(brandItemSchema).describe("List of brands")
8005
- }).describe("Successful operation");
8006
- var FILTERABLE_SUBSCRIPTION_STATUSES = [
8007
- SubscriptionStatus.PROSPECT,
8008
- SubscriptionStatus.POC,
8009
- SubscriptionStatus.ACTIVE,
8010
- SubscriptionStatus.INTEGRATION
8011
- ];
8012
- var UserOrgsSubscriptionStatusSchema = zod.z.enum(
8013
- FILTERABLE_SUBSCRIPTION_STATUSES
8014
- );
8015
- var takedownsServiceFilterSchema = zod.z.object({
8016
- active: zod.z.boolean().optional(),
8017
- automated: zod.z.boolean().optional()
8018
- }).optional();
8019
- var singleServiceFilterSchema = zod.z.object({
8020
- active: zod.z.boolean().optional()
8021
- }).optional();
8022
- var userOrgsServicesFilterObjectSchema = zod.z.object({
8023
- reporting: singleServiceFilterSchema,
8024
- reviewing: singleServiceFilterSchema,
8025
- protection: singleServiceFilterSchema,
8026
- takedowns: takedownsServiceFilterSchema,
8027
- detection: singleServiceFilterSchema,
8028
- darkWebMonitoring: singleServiceFilterSchema
8029
- });
8030
- var userOrgsObligatoryAdminApprovalFilterSchema = zod.z.object({
8031
- active: zod.z.boolean().optional(),
8032
- assetTypes: zod.z.array(zod.z.nativeEnum(AssetType)).min(1).optional()
8033
- }).optional();
8034
- var PendingApprovalServiceSchema = zod.z.enum(["protection", "takedowns"]);
8035
- var userOrgsPendingServiceApprovalFilterSchema = zod.z.object({
8036
- active: zod.z.boolean().optional(),
8037
- services: zod.z.array(PendingApprovalServiceSchema).min(1).optional()
8038
- }).optional();
8039
- zod.z.object({
8040
- query: zod.z.string().default(""),
8041
- subscriptionStatus: zod.z.array(UserOrgsSubscriptionStatusSchema).min(1).optional(),
8042
- services: userOrgsServicesFilterObjectSchema.optional(),
8043
- obligatoryAdminApproval: userOrgsObligatoryAdminApprovalFilterSchema,
8044
- pendingServiceApproval: userOrgsPendingServiceApprovalFilterSchema
8045
- });
8046
- var takedownsServiceSchema = zod.z.object({
8047
- active: zod.z.boolean(),
8048
- automated: zod.z.boolean()
8049
- });
8050
- var singleServiceSchema = zod.z.object({
8051
- active: zod.z.boolean()
8052
- });
8053
- var UserOrgObligatoryAdminApprovalSchema = zod.z.object({
8054
- active: zod.z.boolean(),
8055
- assetTypes: zod.z.array(zod.z.nativeEnum(AssetType))
8056
- });
8057
- var PendingServiceApprovalSchema = zod.z.object({
8058
- // Friendly service family, matching a key in the `services` object.
8059
- service: PendingApprovalServiceSchema,
8060
- // Whether the request is for the automated variant of the service
8061
- // (e.g. "Automated Wallet Blocking" rather than "Wallet Blocking").
8062
- automated: zod.z.boolean(),
8063
- // Raw `ServiceType` enum value, e.g. "isProtectionActive". Lets callers
8064
- // distinguish the exact column without re-deriving it from `service` +
8065
- // `automated`.
8066
- serviceType: zod.z.nativeEnum(ServiceType),
8067
- // Human-readable service label, e.g. "Wallet Blocking".
8068
- serviceName: zod.z.string(),
8069
- // When the enable request was submitted (ISO 8601, UTC).
8070
- requestedAt: zod.z.string()
8071
- });
8072
- var UserOrgIntegrationsSchema = zod.z.object({
8073
- slack: zod.z.boolean(),
8074
- discord: zod.z.boolean(),
8075
- telegram: zod.z.object({
8076
- connected: zod.z.boolean(),
8077
- groupCount: zod.z.number()
8078
- }),
8079
- vercel: zod.z.boolean(),
8080
- intercom: zod.z.boolean(),
8081
- moderation: zod.z.boolean()
8082
- });
8083
- var UserOrgLegalDocumentSchema = zod.z.object({
8084
- present: zod.z.boolean().describe("Whether the organization has this document attached"),
8085
- fileName: zod.z.string().nullable().describe("Original filename of the uploaded document (null when not present)"),
8086
- fileUrl: zod.z.string().nullable().describe("Direct URL to view or download the document (null when not present)")
8087
- });
8088
- var UserOrgLegalDocumentsSchema = zod.z.object({
8089
- letterOfAuthorization: UserOrgLegalDocumentSchema,
8090
- powerOfAttorney: UserOrgLegalDocumentSchema
8091
- });
8092
- var UserOrgTrademarkRegistrationSchema = zod.z.object({
8093
- id: zod.z.number().describe("Trademark registration ID"),
8094
- brandName: zod.z.string().describe("Trademarked brand name as it appears on the registration"),
8095
- trademarkOffice: zod.z.string().describe("Issuing trademark office (e.g. `USPTO`, `EUIPO`)"),
8096
- registrationNumber: zod.z.string().describe("Registration number assigned by the office"),
8097
- goodsAndServicesClass: zod.z.string().describe("Nice Classification class(es) the registration covers"),
8098
- rightsOwnerName: zod.z.string().nullable().describe("Legal entity the trademark is registered to, if recorded"),
8099
- registrationPageUrl: zod.z.string().nullable().describe("Public URL on the trademark office's site, if recorded"),
8100
- certificateFileName: zod.z.string().nullable().describe(
8101
- "Original filename of the uploaded certificate PDF (null when no certificate is attached)"
8102
- ),
8103
- certificateFileUrl: zod.z.string().nullable().describe(
8104
- "Direct URL to view or download the certificate PDF (null when no certificate is attached)"
8105
- )
8106
- });
8107
- var UserOrgBrandMetadataSchema = zod.z.object({
8108
- websiteUrl: zod.z.string().nullable().describe("Public website URL of the brand (linked from the portal header)"),
8109
- twitterHandle: zod.z.string().nullable().describe(
8110
- "Public Twitter/X handle of the brand, stored with the leading `@` (e.g. `@acme`)"
8111
- ),
8112
- securityContactEmail: zod.z.string().nullable().describe(
8113
- "Email address for security correspondence \u2014 used by takedown providers and researchers, distinct from the internal customer POC email"
8114
- ),
8115
- industry: zod.z.string().nullable().describe('Free-form industry label (e.g. "DeFi", "CEX", "NFT", "Wallet")')
8116
- });
8117
- var UserOrgPortalCustomizationSchema = zod.z.object({
8118
- useCustomDetails: zod.z.boolean().describe(
8119
- "When true, the portal uses `name`/`slug`/`avatarUrl` from this object instead of the org's own name/slug/avatar"
8120
- ),
8121
- name: zod.z.string().nullable().describe(
8122
- "Custom display name shown on the portal (used only when `useCustomDetails=true`)"
8123
- ),
8124
- slug: zod.z.string().nullable().describe(
8125
- "Custom URL slug (`chainpatrol.io/<slug>`) \u2014 takes precedence over the org's own slug when set, regardless of `useCustomDetails`"
8126
- ),
8127
- avatarUrl: zod.z.string().nullable().describe(
8128
- "Custom avatar URL shown on the portal (used only when `useCustomDetails=true`)"
8129
- ),
8130
- bannerEnabled: zod.z.boolean().describe(
8131
- "When true, the portal renders `bannerContent` as a highlighted banner at the top of the page"
8132
- ),
8133
- bannerContent: zod.z.string().nullable().describe(
8134
- "Markdown body of the portal banner. Null (or empty) with `bannerEnabled=true` means the toggle is on but no content has been written yet"
8135
- )
8136
- });
8137
- var UserOrgSchema = zod.z.object({
8138
- id: zod.z.number(),
8139
- name: zod.z.string(),
8140
- slug: zod.z.string(),
8141
- avatarUrl: zod.z.string().nullable(),
8142
- contactUrl: zod.z.string().nullable(),
8143
- subscriptionStatus: zod.z.nativeEnum(SubscriptionStatus),
8144
- portalVisibility: zod.z.nativeEnum(OrganizationPortalVisibility).describe(
8145
- "Visibility of the org's public security portal (chainpatrol.io/<slug>). `PUBLIC` is discoverable; `PRIVATE` renders only the report form (no metrics or listings); `DISABLED` returns a 404."
8146
- ),
8147
- reportVisibility: zod.z.nativeEnum(ReportVisibility).describe(
8148
- "Whether the report listings on the public portal are visible to visitors. `PUBLIC` shows the org's reports; `PRIVATE` hides the report list even when the portal is discoverable."
8149
- ),
8150
- metricsVisibility: zod.z.nativeEnum(MetricsVisibility).describe(
8151
- "Whether the metrics/threats-blocked stats render on the public portal. `PUBLIC` shows the metrics tab; `PRIVATE` hides it from anonymous visitors; `DISABLED` doesn't compute metrics at all."
8152
- ),
8153
- brandMetadata: UserOrgBrandMetadataSchema.describe(
8154
- "Public brand-facing metadata (website, twitter, security contact, industry) shown on the portal and used by staff for outbound"
8155
- ),
8156
- portalCustomization: UserOrgPortalCustomizationSchema.describe(
8157
- "Customer-configurable presentation of the public security portal \u2014 custom name/slug/avatar and the banner content"
8158
- ),
8159
- services: zod.z.object({
8160
- reporting: singleServiceSchema,
8161
- reviewing: singleServiceSchema,
8162
- protection: singleServiceSchema,
8163
- takedowns: takedownsServiceSchema,
8164
- detection: singleServiceSchema,
8165
- darkWebMonitoring: singleServiceSchema
8166
- }),
8167
- integrations: UserOrgIntegrationsSchema,
8168
- obligatoryAdminApproval: UserOrgObligatoryAdminApprovalSchema,
8169
- pendingServiceApprovals: zod.z.array(PendingServiceApprovalSchema),
8170
- legalDocuments: UserOrgLegalDocumentsSchema.describe(
8171
- "Org-level Letter of Authorization and Power of Attorney attachments"
8172
- ),
8173
- trademarkRegistrations: zod.z.array(UserOrgTrademarkRegistrationSchema).describe(
8174
- "Org-level trademark registrations attached to the organization. An empty array means no trademarks are on file \u2014 use this to identify customers who still need to add them."
8175
- )
8176
- });
8177
- zod.z.object({
8178
- organizations: zod.z.array(UserOrgSchema)
8179
- });
8180
7467
 
8181
- // ../../internal/validation/src/public/organization/metrics-get.ts
8182
- var organizationMetricsIncludeFieldSchema = zod.z.enum([
8183
- "reports",
8184
- "newThreats",
8185
- "threatsWatchlisted",
8186
- "takedownsFiled",
8187
- "takedownsCompleted",
8188
- "domainThreats",
8189
- "twitterThreats",
8190
- "telegramThreats",
8191
- "otherThreats",
8192
- "blockedByType",
8193
- "blockedByDay"
8194
- ]);
8195
- organizationMetricsIncludeFieldSchema.options;
8196
- var ORGANIZATION_METRICS_MAX_SLUGS = 500;
8197
- var organizationMetricsServicesFilterSchema = zod.z.preprocess((value) => {
8198
- if (typeof value !== "string") return value;
8199
- try {
8200
- return JSON.parse(value);
8201
- } catch (e4) {
8202
- return value;
8203
- }
8204
- }, userOrgsServicesFilterObjectSchema).optional();
8205
- zod.z.object({
8206
- organizationSlug: zod.z.string().optional().describe(
8207
- "Organization slug. Required when authenticating with a user session (Bearer token) and `slugs`/`allMyOrgs` are not supplied; ignored when using an org-scoped API key (org is derived from the key). Mutually exclusive with `slugs` and `allMyOrgs`."
8208
- ),
8209
- slugs: zod.z.array(zod.z.string()).max(ORGANIZATION_METRICS_MAX_SLUGS).optional().describe(
8210
- "Multi-org form. Each slug is auth-checked individually (org-scoped API keys may only pass their own org; sessions and user API keys must have membership or staff role per slug). When supplied with more than one slug, the response includes a `perOrg` breakdown plus `metrics` rolled up across all of them. Capped at " + String(ORGANIZATION_METRICS_MAX_SLUGS) + " slugs per call. Mutually exclusive with `organizationSlug` and `allMyOrgs`."
8211
- ),
8212
- allMyOrgs: zod.z.preprocess((value) => {
8213
- if (value === "true") return true;
8214
- if (value === "false") return false;
8215
- return value;
8216
- }, zod.z.boolean()).optional().describe(
8217
- "Shortcut for 'every org the caller is authorized to read'. Reuses the same filter logic as `/user/orgs`: org-scoped API keys are rejected (they're pinned to one org \u2014 use the default form); user API keys / Bearer sessions resolve to the user's memberships (or every active org for staff). Combine with `subscriptionStatus` and `services` to narrow (e.g. only paying customers with takedowns enabled). The resolved org set is still capped at " + String(ORGANIZATION_METRICS_MAX_SLUGS) + " and a 413 is returned if exceeded. Mutually exclusive with `organizationSlug`, `slugs`, and `brandSlug`."
8218
- ),
8219
- subscriptionStatus: zod.z.array(UserOrgsSubscriptionStatusSchema).min(1).optional().describe(
8220
- "Only meaningful with `allMyOrgs: true`. Defaults to the same set `/user/orgs` uses (ACTIVE/POC/PROSPECT/INTEGRATION \u2014 INACTIVE is always excluded)."
8221
- ),
8222
- services: organizationMetricsServicesFilterSchema.describe(
8223
- "Only meaningful with `allMyOrgs: true`. Same shape as `/user/orgs`'s `services` filter \u2014 every service accepts `{ active }`, and **only `takedowns` additionally accepts `automated`** (the one service where manual-vs-automated changes real platform behavior). E.g. `{ takedowns: { active: true, automated: false } }` for 'orgs with takedowns enabled but automation off'."
8224
- ),
8225
- brandSlug: zod.z.string().optional(),
8226
- startDate: zod.z.coerce.date().optional(),
8227
- endDate: zod.z.coerce.date().optional(),
8228
- include: zod.z.array(organizationMetricsIncludeFieldSchema).optional().describe(
8229
- "Subset of metrics to compute. When omitted or empty, every metric is computed (legacy behavior). Each value in `include` costs roughly one Prisma aggregate, so narrow the list when an agent only needs a couple of numbers \u2014 this is the main lever for keeping big-org calls inside the 30s function cap. Fields not in `include` come back as `null`."
8230
- )
8231
- }).refine(
8232
- (value) => {
8233
- const explicitForms = [
8234
- Boolean(value.organizationSlug),
8235
- Boolean(value.slugs && value.slugs.length > 0),
8236
- Boolean(value.allMyOrgs)
8237
- ].filter(Boolean).length;
8238
- return explicitForms <= 1;
8239
- },
8240
- {
8241
- message: "Pass at most one of `organizationSlug`, `slugs`, or `allMyOrgs`.",
8242
- path: ["allMyOrgs"]
8243
- }
8244
- ).refine((value) => !(value.brandSlug && value.slugs && value.slugs.length > 1), {
8245
- message: "`brandSlug` is only valid alongside a single organization, not `slugs`.",
8246
- path: ["brandSlug"]
8247
- }).refine((value) => !(value.brandSlug && value.allMyOrgs), {
8248
- message: "`brandSlug` is only valid for a single org, not `allMyOrgs`.",
8249
- path: ["brandSlug"]
8250
- });
8251
- var metricValue = zod.z.number().nullable();
8252
- var metricsObjectSchema = zod.z.object({
8253
- reports: metricValue,
8254
- newThreats: metricValue,
8255
- threatsWatchlisted: metricValue,
8256
- takedownsFiled: metricValue,
8257
- takedownsCompleted: metricValue,
8258
- domainThreats: metricValue,
8259
- twitterThreats: metricValue,
8260
- telegramThreats: metricValue,
8261
- otherThreats: metricValue
8262
- });
8263
- var blockedByTypeSchema = zod.z.array(
8264
- zod.z.object({
8265
- type: zod.z.string(),
8266
- count: zod.z.number()
8267
- })
8268
- ).nullable();
8269
- var blockedByDaySchema = zod.z.array(
8270
- zod.z.object({
8271
- date: zod.z.string(),
8272
- count: zod.z.number()
8273
- })
8274
- ).nullable();
8275
- zod.z.object({
8276
- /**
8277
- * Aggregate metrics. For single-org callers this is just that org's
8278
- * numbers; for multi-org callers (`slugs.length > 1` or `allMyOrgs`)
8279
- * it is the sum across all queried orgs.
8280
- */
8281
- metrics: metricsObjectSchema,
8282
- blockedByType: blockedByTypeSchema,
8283
- blockedByDay: blockedByDaySchema,
8284
- /**
8285
- * Derived averages over the time window (and, in multi-org mode,
8286
- * across orgs). `perDay = metrics / windowDays`. In multi-org mode
8287
- * `perOrgPerDay = metrics / numOrgs / windowDays`; in single-org
8288
- * mode it is `null`. Counts are floats here — the underlying
8289
- * `metrics` fields stay integer counts.
8290
- */
8291
- averages: zod.z.object({
8292
- perDay: metricsObjectSchema.nullable(),
8293
- perOrgPerDay: metricsObjectSchema.nullable(),
8294
- windowDays: zod.z.number().nullable()
8295
- }),
8296
- /**
8297
- * Per-org breakdown. Only populated in multi-org mode; `null` for
8298
- * single-org callers.
8299
- */
8300
- perOrg: zod.z.record(
8301
- zod.z.string(),
8302
- zod.z.object({
8303
- metrics: metricsObjectSchema,
8304
- blockedByType: blockedByTypeSchema,
8305
- blockedByDay: blockedByDaySchema
8306
- })
8307
- ).nullable(),
8308
- /**
8309
- * Echoes the actual orgs the response covers, in the order they
8310
- * were resolved. Single-org responses always have length 1. The
8311
- * `resolvedFrom` field distinguishes how the caller asked for the
8312
- * scope (useful for agent reporting).
8313
- */
8314
- scope: zod.z.object({
8315
- mode: zod.z.enum(["single", "multi"]),
8316
- orgs: zod.z.array(zod.z.string()),
8317
- resolvedFrom: zod.z.enum(["api-key", "organizationSlug", "slugs", "allMyOrgs"])
8318
- })
8319
- });
7468
+ // ../../internal/utils/src/detection.ts
7469
+ var ThreatDetectionSourceKey = /* @__PURE__ */ ((ThreatDetectionSourceKey2) => {
7470
+ ThreatDetectionSourceKey2["META_ADS_SEARCH"] = "meta_ads_search";
7471
+ ThreatDetectionSourceKey2["TELEGRAM_CHANNELS_SEARCH"] = "telegram_channels_search";
7472
+ ThreatDetectionSourceKey2["TELEGRAM_USER_SEARCH"] = "telegram_user_search";
7473
+ ThreatDetectionSourceKey2["TELEGRAM_CHANNELS_SEARCH_VETRIC"] = "telegram_channels_search_vetric";
7474
+ ThreatDetectionSourceKey2["TELEGRAM_USER_SEARCH_VETRIC"] = "telegram_user_search_vetric";
7475
+ ThreatDetectionSourceKey2["FACEBOOK_PAGE_SEARCH_VETRIC"] = "facebook_page_search_vetric";
7476
+ ThreatDetectionSourceKey2["INSTAGRAM_ACCOUNT_SEARCH_VETRIC"] = "instagram_account_search_vetric";
7477
+ ThreatDetectionSourceKey2["TWITTER_SEARCH_VETRIC"] = "twitter_search_vetric";
7478
+ ThreatDetectionSourceKey2["LINKEDIN_PEOPLE_SEARCH_VETRIC"] = "linkedin_people_search_vetric";
7479
+ ThreatDetectionSourceKey2["LINKEDIN_COMPANY_SEARCH_VETRIC"] = "linkedin_company_search_vetric";
7480
+ ThreatDetectionSourceKey2["META_ADS_SEARCH_VETRIC"] = "meta_ads_search_vetric";
7481
+ ThreatDetectionSourceKey2["TIK_TOK_VIDEO_SEARCH"] = "tik_tok_video_search";
7482
+ ThreatDetectionSourceKey2["TIK_TOK_USER_SEARCH"] = "tik_tok_user_search";
7483
+ ThreatDetectionSourceKey2["TIK_TOK_USER_SEARCH_VETRIC"] = "tik_tok_user_search_vetric";
7484
+ ThreatDetectionSourceKey2["TIK_TOK_VIDEO_SEARCH_VETRIC"] = "tik_tok_video_search_vetric";
7485
+ ThreatDetectionSourceKey2["BLOCKLIST"] = "blocklist";
7486
+ ThreatDetectionSourceKey2["APPLE_APP_STORE"] = "apple_app_store";
7487
+ ThreatDetectionSourceKey2["GOOGLE_ADS_SEARCH"] = "google_ads_search";
7488
+ ThreatDetectionSourceKey2["MOZILLA_ADDON_SEARCH"] = "mozilla_addon_search";
7489
+ ThreatDetectionSourceKey2["REDDIT_SUBREDDIT_SEARCH"] = "reddit_subreddit_search";
7490
+ ThreatDetectionSourceKey2["ASSET_CHECK"] = "asset_check";
7491
+ ThreatDetectionSourceKey2["TWITTER_POST_SEARCH"] = "twitter_post_search";
7492
+ ThreatDetectionSourceKey2["MEDIUM_TAG_RSS"] = "medium_tag_rss";
7493
+ ThreatDetectionSourceKey2["TWITTER_SEARCH"] = "twitter_search";
7494
+ ThreatDetectionSourceKey2["YAHOO_SEARCH"] = "yahoo_search";
7495
+ ThreatDetectionSourceKey2["DUCK_DUCK_GO_SEARCH"] = "duck_duck_go_search";
7496
+ ThreatDetectionSourceKey2["BING_SEARCH"] = "bing_search";
7497
+ ThreatDetectionSourceKey2["GUESTBOOK"] = "guestbook";
7498
+ ThreatDetectionSourceKey2["CERTSTREAM"] = "certstream";
7499
+ ThreatDetectionSourceKey2["EXTERNAL"] = "external";
7500
+ ThreatDetectionSourceKey2["GOOGLE_SEARCH"] = "google_search";
7501
+ ThreatDetectionSourceKey2["DNS_TWIST"] = "dns_twist";
7502
+ ThreatDetectionSourceKey2["TWITTER"] = "twitter";
7503
+ ThreatDetectionSourceKey2["TWITTER_USERNAME_MONITOR"] = "twitter_username_monitor";
7504
+ ThreatDetectionSourceKey2["URLSCAN"] = "urlscan";
7505
+ ThreatDetectionSourceKey2["URLSCAN_HOSTNAME_SEARCH"] = "urlscan_hostname_search";
7506
+ ThreatDetectionSourceKey2["YOUTUBE_SEARCH"] = "youtube_search";
7507
+ ThreatDetectionSourceKey2["GOOGLE_PLAY_SEARCH"] = "google_play_search";
7508
+ ThreatDetectionSourceKey2["DEXSCREENER_SEARCH"] = "dexscreener_search";
7509
+ ThreatDetectionSourceKey2["BLOCKED_IP_SCAN"] = "blocked_ip_scan";
7510
+ ThreatDetectionSourceKey2["BLOCKED_BILIBILI_SUGGESTED"] = "blocked_bilibili_suggested";
7511
+ ThreatDetectionSourceKey2["GROK_POST_SEARCH"] = "grok_post_search";
7512
+ ThreatDetectionSourceKey2["GROK_USER_SEARCH"] = "grok_user_search";
7513
+ ThreatDetectionSourceKey2["GOOGLE_LENS_IMAGE_SEARCH"] = "google_lens_image_search";
7514
+ ThreatDetectionSourceKey2["YANDEX_SEARCH"] = "yandex_search";
7515
+ ThreatDetectionSourceKey2["LINKEDIN_EMPLOYEE_DETECTION"] = "linkedin_employee_detection";
7516
+ ThreatDetectionSourceKey2["LINKEDIN_POST_SEARCH"] = "linkedin_post_search";
7517
+ ThreatDetectionSourceKey2["LINKEDIN_COMPANY_SEARCH"] = "linkedin_company_search";
7518
+ ThreatDetectionSourceKey2["BING_ADS_SEARCH"] = "bing_ads_search";
7519
+ ThreatDetectionSourceKey2["TIK_TOK_ADS_SEARCH"] = "tik_tok_ads_search";
7520
+ ThreatDetectionSourceKey2["DNSDB"] = "dnsdb";
7521
+ ThreatDetectionSourceKey2["DAILY_MOTION_SEARCH"] = "daily_motion_search";
7522
+ ThreatDetectionSourceKey2["WATCHLIST"] = "watchlist";
7523
+ return ThreatDetectionSourceKey2;
7524
+ })(ThreatDetectionSourceKey || {});
7525
+ var ThreatDetectionScope = /* @__PURE__ */ ((ThreatDetectionScope2) => {
7526
+ ThreatDetectionScope2["ORGANIZATION"] = "organization";
7527
+ ThreatDetectionScope2["GLOBAL"] = "global";
7528
+ return ThreatDetectionScope2;
7529
+ })(ThreatDetectionScope || {});
8320
7530
 
8321
7531
  // ../../internal/utils/src/enrichments.ts
8322
7532
  var enrichments_exports = {};
@@ -10910,977 +10120,1963 @@ var doCustomReplacements = (string, replacements2) => {
10910
10120
  for (const [key, value] of replacements2) {
10911
10121
  string = string.replace(new RegExp(escapeStringRegexp2(key), "g"), value);
10912
10122
  }
10913
- return string;
10123
+ return string;
10124
+ };
10125
+ function transliterate(string, options) {
10126
+ if (typeof string !== "string") {
10127
+ throw new TypeError(`Expected a string, got \`${typeof string}\``);
10128
+ }
10129
+ options = __spreadValues({
10130
+ customReplacements: []
10131
+ }, options);
10132
+ const customReplacements = new Map([
10133
+ ...replacements_default,
10134
+ ...options.customReplacements
10135
+ ]);
10136
+ string = string.normalize();
10137
+ string = doCustomReplacements(string, customReplacements);
10138
+ string = string.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").normalize();
10139
+ return string;
10140
+ }
10141
+
10142
+ // ../../node_modules/@sindresorhus/slugify/overridable-replacements.js
10143
+ var overridableReplacements = [
10144
+ ["&", " and "],
10145
+ ["\u{1F984}", " unicorn "],
10146
+ ["\u2665", " love "]
10147
+ ];
10148
+ var overridable_replacements_default = overridableReplacements;
10149
+
10150
+ // ../../node_modules/@sindresorhus/slugify/index.js
10151
+ var decamelize = (string) => {
10152
+ return string.replace(/([A-Z]{2,})(\d+)/g, "$1 $2").replace(/([a-z\d]+)([A-Z]{2,})/g, "$1 $2").replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-rt-z\d]+)/g, "$1 $2");
10153
+ };
10154
+ var removeMootSeparators = (string, separator) => {
10155
+ const escapedSeparator = escapeStringRegexp(separator);
10156
+ return string.replace(new RegExp(`${escapedSeparator}{2,}`, "g"), separator).replace(new RegExp(`^${escapedSeparator}|${escapedSeparator}$`, "g"), "");
10157
+ };
10158
+ var buildPatternSlug = (options) => {
10159
+ let negationSetPattern = "a-z\\d";
10160
+ negationSetPattern += options.lowercase ? "" : "A-Z";
10161
+ if (options.preserveCharacters.length > 0) {
10162
+ for (const character of options.preserveCharacters) {
10163
+ if (character === options.separator) {
10164
+ throw new Error(`The separator character \`${options.separator}\` cannot be included in preserved characters: ${options.preserveCharacters}`);
10165
+ }
10166
+ negationSetPattern += escapeStringRegexp(character);
10167
+ }
10168
+ }
10169
+ return new RegExp(`[^${negationSetPattern}]+`, "g");
10170
+ };
10171
+ function slugify(string, options) {
10172
+ if (typeof string !== "string") {
10173
+ throw new TypeError(`Expected a string, got \`${typeof string}\``);
10174
+ }
10175
+ options = __spreadValues({
10176
+ separator: "-",
10177
+ lowercase: true,
10178
+ decamelize: true,
10179
+ customReplacements: [],
10180
+ preserveLeadingUnderscore: false,
10181
+ preserveTrailingDash: false,
10182
+ preserveCharacters: []
10183
+ }, options);
10184
+ const shouldPrependUnderscore = options.preserveLeadingUnderscore && string.startsWith("_");
10185
+ const shouldAppendDash = options.preserveTrailingDash && string.endsWith("-");
10186
+ const customReplacements = new Map([
10187
+ ...overridable_replacements_default,
10188
+ ...options.customReplacements
10189
+ ]);
10190
+ string = transliterate(string, { customReplacements });
10191
+ if (options.decamelize) {
10192
+ string = decamelize(string);
10193
+ }
10194
+ const patternSlug = buildPatternSlug(options);
10195
+ if (options.lowercase) {
10196
+ string = string.toLowerCase();
10197
+ }
10198
+ string = string.replace(/([a-zA-Z\d]+)'([ts])(\s|$)/g, "$1$2$3");
10199
+ string = string.replace(patternSlug, options.separator);
10200
+ string = string.replace(/\\/g, "");
10201
+ if (options.separator) {
10202
+ string = removeMootSeparators(string, options.separator);
10203
+ }
10204
+ if (shouldPrependUnderscore) {
10205
+ string = `_${string}`;
10206
+ }
10207
+ if (shouldAppendDash) {
10208
+ string = `${string}-`;
10209
+ }
10210
+ return string;
10211
+ }
10212
+
10213
+ // ../asset-parse/src/model.ts
10214
+ var AssetModel = /* @__PURE__ */ ((AssetModel2) => {
10215
+ AssetModel2["Addon"] = "addon";
10216
+ AssetModel2["App"] = "app";
10217
+ AssetModel2["Bot"] = "bot";
10218
+ AssetModel2["BusinessProfile"] = "business-profile";
10219
+ AssetModel2["Catalog"] = "catalog";
10220
+ AssetModel2["Collection"] = "collection";
10221
+ AssetModel2["Channel"] = "channel";
10222
+ AssetModel2["Group"] = "group";
10223
+ AssetModel2["Post"] = "post";
10224
+ AssetModel2["Profile"] = "profile";
10225
+ AssetModel2["Short"] = "short";
10226
+ AssetModel2["Video"] = "video";
10227
+ AssetModel2["Space"] = "space";
10228
+ AssetModel2["Issue"] = "issue";
10229
+ AssetModel2["PullRequest"] = "pull-request";
10230
+ AssetModel2["Discussion"] = "discussion";
10231
+ AssetModel2["Repository"] = "repository";
10232
+ AssetModel2["Article"] = "Article";
10233
+ AssetModel2["Comment"] = "comment";
10234
+ AssetModel2["List"] = "list";
10235
+ AssetModel2["Subreddit"] = "subreddit";
10236
+ AssetModel2["Community"] = "community";
10237
+ AssetModel2["MiniApp"] = "mini-app";
10238
+ AssetModel2["Developer"] = "developer";
10239
+ return AssetModel2;
10240
+ })(AssetModel || {});
10241
+ function isUrl(input) {
10242
+ if (input.trim() === "") {
10243
+ return false;
10244
+ }
10245
+ if (input.startsWith("/") || input.startsWith("#") || input.startsWith("?") || input.startsWith(".") || !input.includes(".")) {
10246
+ return false;
10247
+ }
10248
+ return URL.canParse(input) || URL.canParse(`https://${input}`);
10249
+ }
10250
+ function getNormalizedUrl(input) {
10251
+ if (!isUrl(input)) {
10252
+ throw new Error(`Invalid URL: ${input}`);
10253
+ }
10254
+ let url;
10255
+ try {
10256
+ url = new URL(input);
10257
+ } catch (e4) {
10258
+ try {
10259
+ url = new URL(`https://${input}`);
10260
+ } catch (e5) {
10261
+ throw new Error(`Invalid URL: ${input}`);
10262
+ }
10263
+ }
10264
+ const normalizedUrl = normalizeUrl(url.toString(), {
10265
+ defaultProtocol: "https"
10266
+ });
10267
+ try {
10268
+ return new URL(normalizedUrl);
10269
+ } catch (e4) {
10270
+ throw new Error(`Invalid URL: ${input}`);
10271
+ }
10272
+ }
10273
+ var ensureHttpsPrefix = (url) => {
10274
+ if (!url.startsWith("http")) {
10275
+ return `https://${url}`;
10276
+ }
10277
+ return url.replace(/^https?:\/{1,2}/, "https://");
10914
10278
  };
10915
- function transliterate(string, options) {
10916
- if (typeof string !== "string") {
10917
- throw new TypeError(`Expected a string, got \`${typeof string}\``);
10279
+ function getHostname(input) {
10280
+ try {
10281
+ return getNormalizedUrl(input).hostname;
10282
+ } catch (e4) {
10283
+ return null;
10918
10284
  }
10919
- options = __spreadValues({
10920
- customReplacements: []
10921
- }, options);
10922
- const customReplacements = new Map([
10923
- ...replacements_default,
10924
- ...options.customReplacements
10925
- ]);
10926
- string = string.normalize();
10927
- string = doCustomReplacements(string, customReplacements);
10928
- string = string.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").normalize();
10929
- return string;
10285
+ }
10286
+ function getParentDomains(input) {
10287
+ const domain = getHostname(input);
10288
+ if (!domain) {
10289
+ return [];
10290
+ }
10291
+ const subdomain = tldts.getSubdomain(domain, { mixedInputs: false });
10292
+ if (!subdomain) {
10293
+ return [domain];
10294
+ }
10295
+ const domainWithSuffix = tldts.getDomain(domain, { mixedInputs: false });
10296
+ if (!domainWithSuffix) {
10297
+ return [];
10298
+ }
10299
+ const parentDomains = [domainWithSuffix];
10300
+ const parentDomainParts = subdomain.split(".");
10301
+ for (let i = parentDomainParts.length - 1; i >= 0; i--) {
10302
+ const parentDomainPart = parentDomainParts.slice(i).join(".");
10303
+ parentDomains.push(`${parentDomainPart}.${domainWithSuffix}`);
10304
+ }
10305
+ return parentDomains.reverse();
10306
+ }
10307
+ function trimDomainToLevels(domain, options = { levels: 4 }) {
10308
+ var _a;
10309
+ const parsed = tldts.parse(domain);
10310
+ const eTLDPlusOne = (_a = parsed.domain) != null ? _a : "";
10311
+ const subdomains = domain.replace(/https?:\/\/(www\.)?/, "").split(".");
10312
+ const eTLDPlusOneIndex = subdomains.findIndex(
10313
+ (_, i) => subdomains.slice(i).join(".") === eTLDPlusOne
10314
+ );
10315
+ const trimmedSubdomains = subdomains.slice(Math.max(eTLDPlusOneIndex - (options.levels - 1), 0)).join(".");
10316
+ return trimmedSubdomains;
10930
10317
  }
10931
10318
 
10932
- // ../../node_modules/@sindresorhus/slugify/overridable-replacements.js
10933
- var overridableReplacements = [
10934
- ["&", " and "],
10935
- ["\u{1F984}", " unicorn "],
10936
- ["\u2665", " love "]
10937
- ];
10938
- var overridable_replacements_default = overridableReplacements;
10939
-
10940
- // ../../node_modules/@sindresorhus/slugify/index.js
10941
- var decamelize = (string) => {
10942
- return string.replace(/([A-Z]{2,})(\d+)/g, "$1 $2").replace(/([a-z\d]+)([A-Z]{2,})/g, "$1 $2").replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-rt-z\d]+)/g, "$1 $2");
10943
- };
10944
- var removeMootSeparators = (string, separator) => {
10945
- const escapedSeparator = escapeStringRegexp(separator);
10946
- return string.replace(new RegExp(`${escapedSeparator}{2,}`, "g"), separator).replace(new RegExp(`^${escapedSeparator}|${escapedSeparator}$`, "g"), "");
10947
- };
10948
- var buildPatternSlug = (options) => {
10949
- let negationSetPattern = "a-z\\d";
10950
- negationSetPattern += options.lowercase ? "" : "A-Z";
10951
- if (options.preserveCharacters.length > 0) {
10952
- for (const character of options.preserveCharacters) {
10953
- if (character === options.separator) {
10954
- throw new Error(`The separator character \`${options.separator}\` cannot be included in preserved characters: ${options.preserveCharacters}`);
10955
- }
10956
- negationSetPattern += escapeStringRegexp(character);
10319
+ // ../asset-parse/src/phone.ts
10320
+ var phone_exports = {};
10321
+ __export(phone_exports, {
10322
+ PHONE_NUMBER_REGEX: () => PHONE_NUMBER_REGEX,
10323
+ isPhoneNumber: () => isPhoneNumber,
10324
+ normalizePhoneNumber: () => normalizePhoneNumber
10325
+ });
10326
+ var PHONE_NUMBER_REGEX = /(?:\+?\d{1,4}[\s.-]?)?(?:\(\d{1,4}\)|\d{1,4})[\s.-]?\d{1,4}[\s.-]?\d{1,4}[\s.-]?\d{0,4}(?:\s*(?:ext|x|extension)[\s.]*\d{1,6})?/gi;
10327
+ function preparePhoneInput(input) {
10328
+ let s2 = input.trim();
10329
+ s2 = s2.replace(/^\s*tel:\s*(?:\/\/)?\s*/i, "");
10330
+ s2 = s2.trim();
10331
+ s2 = s2.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g, " ");
10332
+ s2 = s2.replace(/[\u2010\u2011\u2012\u2013\u2014\u2015\u2212\uFE58\uFE63\uFF0D]/g, "-");
10333
+ s2 = s2.replace(/\uFF0B/g, "+");
10334
+ s2 = s2.replace(/\uFF08/g, "(");
10335
+ s2 = s2.replace(/\uFF09/g, ")");
10336
+ return s2.trim();
10337
+ }
10338
+ function isAllSameDigit(digits2) {
10339
+ return /^(\d)\1+$/.test(digits2);
10340
+ }
10341
+ function isStrictlyMonotonicStep1(digits2) {
10342
+ if (digits2.length < 8) {
10343
+ return false;
10344
+ }
10345
+ let increasing = true;
10346
+ let decreasing = true;
10347
+ for (let i = 1; i < digits2.length; i++) {
10348
+ const curr = digits2.charCodeAt(i) - 48;
10349
+ const prev = digits2.charCodeAt(i - 1) - 48;
10350
+ if (curr !== prev + 1) {
10351
+ increasing = false;
10352
+ }
10353
+ if (curr !== prev - 1) {
10354
+ decreasing = false;
10957
10355
  }
10958
10356
  }
10959
- return new RegExp(`[^${negationSetPattern}]+`, "g");
10357
+ return increasing || decreasing;
10358
+ }
10359
+ function isValidNanpNational10(d10) {
10360
+ if (d10.length !== 10) {
10361
+ return false;
10362
+ }
10363
+ const npaFirst = d10.charCodeAt(0) - 48;
10364
+ const nxxFirst = d10.charCodeAt(3) - 48;
10365
+ if (npaFirst < 2 || npaFirst > 9) {
10366
+ return false;
10367
+ }
10368
+ if (nxxFirst < 2 || nxxFirst > 9) {
10369
+ return false;
10370
+ }
10371
+ return true;
10372
+ }
10373
+ function isPlausiblePhoneDigits(withoutExt) {
10374
+ const hasPlus = withoutExt.startsWith("+");
10375
+ const d = withoutExt.replace(/\D/g, "");
10376
+ if (d.length < 8 || d.length > 15) {
10377
+ return false;
10378
+ }
10379
+ if (isAllSameDigit(d) || isStrictlyMonotonicStep1(d)) {
10380
+ return false;
10381
+ }
10382
+ const onlyDigits = /^\d+$/.test(withoutExt);
10383
+ if (hasPlus) {
10384
+ if (d.length === 11 && d.startsWith("1")) {
10385
+ return isValidNanpNational10(d.slice(1));
10386
+ }
10387
+ return true;
10388
+ }
10389
+ if (onlyDigits) {
10390
+ if (d.length === 10) {
10391
+ return isValidNanpNational10(d);
10392
+ }
10393
+ if (d.length === 11 && d.startsWith("1")) {
10394
+ return isValidNanpNational10(d.slice(1));
10395
+ }
10396
+ if (d.length === 11 && d.startsWith("0")) {
10397
+ return true;
10398
+ }
10399
+ return false;
10400
+ }
10401
+ if (d.length === 10) {
10402
+ return isValidNanpNational10(d);
10403
+ }
10404
+ if (d.length === 11 && d.startsWith("1")) {
10405
+ return isValidNanpNational10(d.slice(1));
10406
+ }
10407
+ if (d.length === 11 && d.startsWith("0")) {
10408
+ return true;
10409
+ }
10410
+ if (d.length >= 12 && d.length <= 15) {
10411
+ return true;
10412
+ }
10413
+ return false;
10414
+ }
10415
+ function isPhoneNumber(input) {
10416
+ const trimmed = preparePhoneInput(input);
10417
+ if (trimmed === "") {
10418
+ return false;
10419
+ }
10420
+ if (!/^[+\d(]/.test(trimmed)) {
10421
+ return false;
10422
+ }
10423
+ const withoutExt = trimmed.replace(/\s*(ext|extension|x)\s*\d+$/i, "");
10424
+ if (/[a-zA-Z]/.test(withoutExt)) {
10425
+ return false;
10426
+ }
10427
+ const hasPhoneMarker = /[+()\s-]/.test(trimmed);
10428
+ const isPureDotSeparated = /^\d+(\.\d+)+$/.test(trimmed);
10429
+ if (isPureDotSeparated && !hasPhoneMarker) {
10430
+ return false;
10431
+ }
10432
+ const phoneRegex = /^(?:\+?\d{1,4}[\s.-]?)?(?:\(\d{1,4}\)|\d{1,4})[\s.-]?\d{1,4}[\s.-]?\d{1,4}[\s.-]?\d{0,4}(?:\s*(?:ext|x|extension)[\s.]*\d{1,6})?$/i;
10433
+ if (!phoneRegex.test(trimmed)) {
10434
+ return false;
10435
+ }
10436
+ return isPlausiblePhoneDigits(withoutExt);
10437
+ }
10438
+ function normalizePhoneNumber(phone) {
10439
+ const trimmed = preparePhoneInput(phone);
10440
+ const withoutExt = trimmed.replace(/\s*(ext|extension|x)\s*\d+$/i, "");
10441
+ const hasPlus = withoutExt.startsWith("+");
10442
+ const digitsOnly = withoutExt.replace(/\D/g, "");
10443
+ return hasPlus ? `+${digitsOnly}` : digitsOnly;
10444
+ }
10445
+
10446
+ // ../../internal/utils/src/punycode.ts
10447
+ var maxInt = 2147483647;
10448
+ var base = 36;
10449
+ var tMin = 1;
10450
+ var tMax = 26;
10451
+ var skew = 38;
10452
+ var damp = 700;
10453
+ var initialBias = 72;
10454
+ var initialN = 128;
10455
+ var delimiter = "-";
10456
+ var regexPunycode = /^xn--/;
10457
+ var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
10458
+ var errors = {
10459
+ overflow: "Overflow: input needs wider integers to process",
10460
+ "not-basic": "Illegal input >= 0x80 (not a basic code point)",
10461
+ "invalid-input": "Invalid input"
10960
10462
  };
10961
- function slugify(string, options) {
10962
- if (typeof string !== "string") {
10963
- throw new TypeError(`Expected a string, got \`${typeof string}\``);
10463
+ var baseMinusTMin = base - tMin;
10464
+ var floor = Math.floor;
10465
+ function error(type) {
10466
+ throw new RangeError(errors[type]);
10467
+ }
10468
+ function mapDomain(domain, callback) {
10469
+ const parts = domain.split("@");
10470
+ let result = "";
10471
+ if (parts.length > 1) {
10472
+ result = parts[0] + "@";
10473
+ domain = parts[1];
10964
10474
  }
10965
- options = __spreadValues({
10966
- separator: "-",
10967
- lowercase: true,
10968
- decamelize: true,
10969
- customReplacements: [],
10970
- preserveLeadingUnderscore: false,
10971
- preserveTrailingDash: false,
10972
- preserveCharacters: []
10973
- }, options);
10974
- const shouldPrependUnderscore = options.preserveLeadingUnderscore && string.startsWith("_");
10975
- const shouldAppendDash = options.preserveTrailingDash && string.endsWith("-");
10976
- const customReplacements = new Map([
10977
- ...overridable_replacements_default,
10978
- ...options.customReplacements
10979
- ]);
10980
- string = transliterate(string, { customReplacements });
10981
- if (options.decamelize) {
10982
- string = decamelize(string);
10475
+ domain = domain.replace(regexSeparators, ".");
10476
+ const labels = domain.split(".");
10477
+ const encoded = labels.map(callback).join(".");
10478
+ return result + encoded;
10479
+ }
10480
+ function basicToDigit(codePoint) {
10481
+ if (codePoint >= 48 && codePoint < 58) {
10482
+ return 26 + (codePoint - 48);
10983
10483
  }
10984
- const patternSlug = buildPatternSlug(options);
10985
- if (options.lowercase) {
10986
- string = string.toLowerCase();
10484
+ if (codePoint >= 65 && codePoint < 91) {
10485
+ return codePoint - 65;
10987
10486
  }
10988
- string = string.replace(/([a-zA-Z\d]+)'([ts])(\s|$)/g, "$1$2$3");
10989
- string = string.replace(patternSlug, options.separator);
10990
- string = string.replace(/\\/g, "");
10991
- if (options.separator) {
10992
- string = removeMootSeparators(string, options.separator);
10487
+ if (codePoint >= 97 && codePoint < 123) {
10488
+ return codePoint - 97;
10993
10489
  }
10994
- if (shouldPrependUnderscore) {
10995
- string = `_${string}`;
10490
+ return base;
10491
+ }
10492
+ function adapt(delta, numPoints, firstTime) {
10493
+ let k4 = 0;
10494
+ delta = firstTime ? floor(delta / damp) : delta >> 1;
10495
+ delta += floor(delta / numPoints);
10496
+ for (
10497
+ ;
10498
+ /* no initialization */
10499
+ delta > baseMinusTMin * tMax >> 1;
10500
+ k4 += base
10501
+ ) {
10502
+ delta = floor(delta / baseMinusTMin);
10996
10503
  }
10997
- if (shouldAppendDash) {
10998
- string = `${string}-`;
10504
+ return floor(k4 + (baseMinusTMin + 1) * delta / (delta + skew));
10505
+ }
10506
+ function decode(input) {
10507
+ const output = [];
10508
+ const inputLength = input.length;
10509
+ let i = 0;
10510
+ let n2 = initialN;
10511
+ let bias2 = initialBias;
10512
+ let basic = input.lastIndexOf(delimiter);
10513
+ if (basic < 0) {
10514
+ basic = 0;
10999
10515
  }
11000
- return string;
10516
+ for (let j = 0; j < basic; ++j) {
10517
+ if (input.charCodeAt(j) >= 128) {
10518
+ error("not-basic");
10519
+ }
10520
+ output.push(input.charCodeAt(j));
10521
+ }
10522
+ for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
10523
+ const oldi = i;
10524
+ for (let w = 1, k4 = base; ; k4 += base) {
10525
+ if (index >= inputLength) {
10526
+ error("invalid-input");
10527
+ }
10528
+ const digit = basicToDigit(input.charCodeAt(index++));
10529
+ if (digit >= base) {
10530
+ error("invalid-input");
10531
+ }
10532
+ if (digit > floor((maxInt - i) / w)) {
10533
+ error("overflow");
10534
+ }
10535
+ i += digit * w;
10536
+ const t = k4 <= bias2 ? tMin : k4 >= bias2 + tMax ? tMax : k4 - bias2;
10537
+ if (digit < t) {
10538
+ break;
10539
+ }
10540
+ const baseMinusT = base - t;
10541
+ if (w > floor(maxInt / baseMinusT)) {
10542
+ error("overflow");
10543
+ }
10544
+ w *= baseMinusT;
10545
+ }
10546
+ const out = output.length + 1;
10547
+ bias2 = adapt(i - oldi, out, oldi == 0);
10548
+ if (floor(i / out) > maxInt - n2) {
10549
+ error("overflow");
10550
+ }
10551
+ n2 += floor(i / out);
10552
+ i %= out;
10553
+ output.splice(i++, 0, n2);
10554
+ }
10555
+ return String.fromCodePoint(...output);
10556
+ }
10557
+ function toUnicode(input) {
10558
+ return mapDomain(input, function(string) {
10559
+ return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
10560
+ });
11001
10561
  }
11002
10562
 
11003
- // ../asset-parse/src/model.ts
11004
- var AssetModel = /* @__PURE__ */ ((AssetModel2) => {
11005
- AssetModel2["Addon"] = "addon";
11006
- AssetModel2["App"] = "app";
11007
- AssetModel2["Bot"] = "bot";
11008
- AssetModel2["BusinessProfile"] = "business-profile";
11009
- AssetModel2["Catalog"] = "catalog";
11010
- AssetModel2["Collection"] = "collection";
11011
- AssetModel2["Channel"] = "channel";
11012
- AssetModel2["Group"] = "group";
11013
- AssetModel2["Post"] = "post";
11014
- AssetModel2["Profile"] = "profile";
11015
- AssetModel2["Short"] = "short";
11016
- AssetModel2["Video"] = "video";
11017
- AssetModel2["Space"] = "space";
11018
- AssetModel2["Issue"] = "issue";
11019
- AssetModel2["PullRequest"] = "pull-request";
11020
- AssetModel2["Discussion"] = "discussion";
11021
- AssetModel2["Repository"] = "repository";
11022
- AssetModel2["Article"] = "Article";
11023
- AssetModel2["Comment"] = "comment";
11024
- AssetModel2["List"] = "list";
11025
- AssetModel2["Subreddit"] = "subreddit";
11026
- AssetModel2["Community"] = "community";
11027
- AssetModel2["MiniApp"] = "mini-app";
11028
- AssetModel2["Developer"] = "developer";
11029
- return AssetModel2;
11030
- })(AssetModel || {});
11031
- function isUrl(input) {
10563
+ // ../../internal/utils/src/url.ts
10564
+ function isEmail(input) {
11032
10565
  if (input.trim() === "") {
11033
10566
  return false;
11034
10567
  }
11035
- if (input.startsWith("/") || input.startsWith("#") || input.startsWith("?") || input.startsWith(".") || !input.includes(".")) {
11036
- return false;
11037
- }
11038
- return URL.canParse(input) || URL.canParse(`https://${input}`);
10568
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
10569
+ return emailRegex.test(input);
11039
10570
  }
11040
- function getNormalizedUrl(input) {
10571
+ function removeHttpProtocol(input) {
10572
+ return input.replace(/^https?:\/\//, "");
10573
+ }
10574
+ function stripDomainWildcardPrefix(domain) {
10575
+ const trimmedDomain = domain.trim();
10576
+ const strippedDomain = trimmedDomain.startsWith("*.") ? trimmedDomain.slice(2) : trimmedDomain;
10577
+ return strippedDomain.length > 0 ? strippedDomain : null;
10578
+ }
10579
+ function getDefangedUrl(input) {
11041
10580
  if (!isUrl(input)) {
11042
- throw new Error(`Invalid URL: ${input}`);
10581
+ console.warn(`[getDefangedUrl] Invalid URL: ${input}, returning input as-is`);
10582
+ return input;
10583
+ }
10584
+ return input.replace(/\./g, "[.]").replace(/(https:\/\/)/g, "hxxps://").replace(/(http:\/\/)/g, "hxxp://").replace(/:\/\//g, "[://]");
10585
+ }
10586
+ function getRefangedUrl(input) {
10587
+ return input.replace(/hxxps/gi, "https").replace(/hxxp/gi, "http").replace(/\[:\/{2}\]/g, "://").replace(/\[\.\]/g, ".");
10588
+ }
10589
+ function containsPunycode(url) {
10590
+ return url.indexOf("xn--") !== -1;
10591
+ }
10592
+ function toUnicode2(url) {
10593
+ return toUnicode(url);
10594
+ }
10595
+ function convertHttpsToHttp(url) {
10596
+ if (url.startsWith("https://")) {
10597
+ const httpUrl = new URL(url);
10598
+ httpUrl.protocol = "http:";
10599
+ return httpUrl.toString();
10600
+ }
10601
+ throw new Error(`URL is not HTTPS: ${url}`);
10602
+ }
10603
+ function generateCanonicalIPFSUrl(content) {
10604
+ if (!content) {
10605
+ return content;
10606
+ }
10607
+ if (content.includes("ipfs.io")) {
10608
+ return content;
10609
+ }
10610
+ if (content.startsWith("Qm") || content.startsWith("bafy")) {
10611
+ return `ipfs.io/ipfs/${content}`;
10612
+ }
10613
+ return content;
10614
+ }
10615
+ function isWalrusSite(content) {
10616
+ return content.includes(".walrus.site") || content.includes(".walrus.host") || content.includes(".wal.app") || content.includes(".wal.site");
10617
+ }
10618
+ function getFaviconUrl(content) {
10619
+ const normalizedUrl = getNormalizedUrl(content);
10620
+ return `https://icons.duckduckgo.com/ip3/${normalizedUrl.hostname}.ico`;
10621
+ }
10622
+ function sanitizeHttpUrl(value) {
10623
+ if (typeof value !== "string" || value.length === 0) {
10624
+ return null;
11043
10625
  }
11044
- let url;
11045
10626
  try {
11046
- url = new URL(input);
10627
+ const parsed = new URL(value);
10628
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
10629
+ return null;
10630
+ }
10631
+ return parsed.toString();
11047
10632
  } catch (e4) {
11048
- try {
11049
- url = new URL(`https://${input}`);
11050
- } catch (e5) {
11051
- throw new Error(`Invalid URL: ${input}`);
10633
+ return null;
10634
+ }
10635
+ }
10636
+ var URL_REGEX = /https?:\/\/[^\s"'<>\])]*/g;
10637
+
10638
+ // ../../internal/utils/src/email.ts
10639
+ var email_exports = {};
10640
+ __export(email_exports, {
10641
+ extractTextFromGmailPayload: () => extractTextFromGmailPayload,
10642
+ getDomainFromEmail: () => getDomainFromEmail,
10643
+ getNameFromEmail: () => getNameFromEmail
10644
+ });
10645
+ function getDomainFromEmail(email) {
10646
+ return email.split("@")[1];
10647
+ }
10648
+ function getNameFromEmail(email) {
10649
+ return email.split("@")[0];
10650
+ }
10651
+ function extractTextFromGmailPayload(payload) {
10652
+ var _a;
10653
+ if (!payload) return "";
10654
+ if ((_a = payload.body) == null ? void 0 : _a.data) {
10655
+ if (payload.mimeType === "text/plain" || payload.mimeType === "text/html") {
10656
+ return Buffer.from(payload.body.data, "base64url").toString("utf-8");
11052
10657
  }
11053
10658
  }
11054
- const normalizedUrl = normalizeUrl(url.toString(), {
11055
- defaultProtocol: "https"
11056
- });
11057
- try {
11058
- return new URL(normalizedUrl);
11059
- } catch (e4) {
11060
- throw new Error(`Invalid URL: ${input}`);
10659
+ if (payload.parts) {
10660
+ if (payload.mimeType === "multipart/alternative") {
10661
+ const plainTextPart = payload.parts.find((part) => part.mimeType === "text/plain");
10662
+ if (plainTextPart) {
10663
+ return extractTextFromGmailPayload(plainTextPart);
10664
+ }
10665
+ const htmlPart = payload.parts.find((part) => part.mimeType === "text/html");
10666
+ if (htmlPart) {
10667
+ return extractTextFromGmailPayload(htmlPart);
10668
+ }
10669
+ for (const part of payload.parts) {
10670
+ const text = extractTextFromGmailPayload(part);
10671
+ if (text) return text;
10672
+ }
10673
+ }
10674
+ return payload.parts.map((part) => extractTextFromGmailPayload(part)).join("\n");
11061
10675
  }
10676
+ return "";
11062
10677
  }
11063
- var ensureHttpsPrefix = (url) => {
11064
- if (!url.startsWith("http")) {
11065
- return `https://${url}`;
10678
+
10679
+ // ../../internal/utils/src/vercel.ts
10680
+ var vercel_exports = {};
10681
+ __export(vercel_exports, {
10682
+ checkVercelEnv: () => checkVercelEnv
10683
+ });
10684
+ var checkVercelEnv = ({ envs }) => {
10685
+ var _a;
10686
+ const vercelEnv = (_a = process.env.VERCEL_ENV) != null ? _a : "development";
10687
+ if (!envs.includes(vercelEnv)) {
10688
+ return {
10689
+ ok: false,
10690
+ message: `Vercel environment is ${vercelEnv}, but expected ${envs.join(" or ")}`
10691
+ };
11066
10692
  }
11067
- return url.replace(/^https?:\/{1,2}/, "https://");
10693
+ return { ok: true, message: "" };
11068
10694
  };
11069
- function getHostname(input) {
11070
- try {
11071
- return getNormalizedUrl(input).hostname;
11072
- } catch (e4) {
11073
- return null;
10695
+
10696
+ // ../../internal/utils/src/delay.ts
10697
+ var delay_exports = {};
10698
+ __export(delay_exports, {
10699
+ delay: () => delay
10700
+ });
10701
+ var delay = (ms) => {
10702
+ return new Promise((resolve) => setTimeout(resolve, ms));
10703
+ };
10704
+
10705
+ // ../../internal/utils/src/whois.ts
10706
+ var whois_exports = {};
10707
+ __export(whois_exports, {
10708
+ extractWhoisCountry: () => extractWhoisCountry,
10709
+ extractWhoisPayload: () => extractWhoisPayload,
10710
+ normalizeRegistrar: () => normalizeRegistrar
10711
+ });
10712
+ function extractWhoisPayload(raw) {
10713
+ var _a;
10714
+ const first = Array.isArray(raw) ? (_a = raw.find((entry) => entry !== null && typeof entry === "object")) != null ? _a : {} : raw;
10715
+ if (!first || typeof first !== "object") {
10716
+ return {};
11074
10717
  }
11075
- }
11076
- function getParentDomains(input) {
11077
- const domain = getHostname(input);
11078
- if (!domain) {
11079
- return [];
10718
+ const maybeData = first.data;
10719
+ if (maybeData && typeof maybeData === "object" && !Array.isArray(maybeData)) {
10720
+ return maybeData;
11080
10721
  }
11081
- const subdomain = tldts.getSubdomain(domain, { mixedInputs: false });
11082
- if (!subdomain) {
11083
- return [domain];
10722
+ return first;
10723
+ }
10724
+ var WHOIS_EMPTY_VALUES = /* @__PURE__ */ new Set(["", "none", "null"]);
10725
+ var WHOIS_COUNTRY_CODE_KEY_ALIASES = /* @__PURE__ */ new Set(["countrycode", "registrantcountrycode"]);
10726
+ var WHOIS_COUNTRY_KEY_ALIASES = /* @__PURE__ */ new Set([
10727
+ "country",
10728
+ "countryname",
10729
+ "registrantcountry",
10730
+ "registrantcountryname"
10731
+ ]);
10732
+ function normalizeWhoisKey(key) {
10733
+ return key.toLowerCase().replace(/[^a-z0-9]/g, "");
10734
+ }
10735
+ function normalizeRegistrar(value) {
10736
+ return value.toLowerCase().replace(/[^a-z0-9]/g, "");
10737
+ }
10738
+ function parseWhoisString(value) {
10739
+ if (typeof value !== "string") {
10740
+ return void 0;
11084
10741
  }
11085
- const domainWithSuffix = tldts.getDomain(domain, { mixedInputs: false });
11086
- if (!domainWithSuffix) {
11087
- return [];
10742
+ const trimmedValue = value.trim();
10743
+ if (WHOIS_EMPTY_VALUES.has(trimmedValue.toLowerCase())) {
10744
+ return void 0;
11088
10745
  }
11089
- const parentDomains = [domainWithSuffix];
11090
- const parentDomainParts = subdomain.split(".");
11091
- for (let i = parentDomainParts.length - 1; i >= 0; i--) {
11092
- const parentDomainPart = parentDomainParts.slice(i).join(".");
11093
- parentDomains.push(`${parentDomainPart}.${domainWithSuffix}`);
10746
+ return trimmedValue;
10747
+ }
10748
+ function extractWhoisFieldByAliases(payload, aliases) {
10749
+ for (const [key, value] of Object.entries(payload)) {
10750
+ if (!aliases.has(normalizeWhoisKey(key))) {
10751
+ continue;
10752
+ }
10753
+ const parsedValue = parseWhoisString(value);
10754
+ if (parsedValue) {
10755
+ return parsedValue;
10756
+ }
11094
10757
  }
11095
- return parentDomains.reverse();
10758
+ return void 0;
11096
10759
  }
11097
- function trimDomainToLevels(domain, options = { levels: 4 }) {
11098
- var _a;
11099
- const parsed = tldts.parse(domain);
11100
- const eTLDPlusOne = (_a = parsed.domain) != null ? _a : "";
11101
- const subdomains = domain.replace(/https?:\/\/(www\.)?/, "").split(".");
11102
- const eTLDPlusOneIndex = subdomains.findIndex(
11103
- (_, i) => subdomains.slice(i).join(".") === eTLDPlusOne
11104
- );
11105
- const trimmedSubdomains = subdomains.slice(Math.max(eTLDPlusOneIndex - (options.levels - 1), 0)).join(".");
11106
- return trimmedSubdomains;
10760
+ function extractWhoisCountry(payload) {
10761
+ const countryCode = extractWhoisFieldByAliases(payload, WHOIS_COUNTRY_CODE_KEY_ALIASES);
10762
+ const country = extractWhoisFieldByAliases(payload, WHOIS_COUNTRY_KEY_ALIASES);
10763
+ return {
10764
+ countryCode: countryCode != null ? countryCode : void 0,
10765
+ country: country != null ? country : void 0
10766
+ };
11107
10767
  }
11108
10768
 
11109
- // ../asset-parse/src/phone.ts
11110
- var phone_exports = {};
11111
- __export(phone_exports, {
11112
- PHONE_NUMBER_REGEX: () => PHONE_NUMBER_REGEX,
11113
- isPhoneNumber: () => isPhoneNumber,
11114
- normalizePhoneNumber: () => normalizePhoneNumber
10769
+ // ../../internal/utils/src/safe-preview.ts
10770
+ var safe_preview_exports = {};
10771
+ __export(safe_preview_exports, {
10772
+ buildSafePreviewUrl: () => buildSafePreviewUrl,
10773
+ normalizeSafeNavigationTarget: () => normalizeSafeNavigationTarget
11115
10774
  });
11116
- var PHONE_NUMBER_REGEX = /(?:\+?\d{1,4}[\s.-]?)?(?:\(\d{1,4}\)|\d{1,4})[\s.-]?\d{1,4}[\s.-]?\d{1,4}[\s.-]?\d{0,4}(?:\s*(?:ext|x|extension)[\s.]*\d{1,6})?/gi;
11117
- function preparePhoneInput(input) {
11118
- let s2 = input.trim();
11119
- s2 = s2.replace(/^\s*tel:\s*(?:\/\/)?\s*/i, "");
11120
- s2 = s2.trim();
11121
- s2 = s2.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g, " ");
11122
- s2 = s2.replace(/[\u2010\u2011\u2012\u2013\u2014\u2015\u2212\uFE58\uFE63\uFF0D]/g, "-");
11123
- s2 = s2.replace(/\uFF0B/g, "+");
11124
- s2 = s2.replace(/\uFF08/g, "(");
11125
- s2 = s2.replace(/\uFF09/g, ")");
11126
- return s2.trim();
11127
- }
11128
- function isAllSameDigit(digits2) {
11129
- return /^(\d)\1+$/.test(digits2);
11130
- }
11131
- function isStrictlyMonotonicStep1(digits2) {
11132
- if (digits2.length < 8) {
11133
- return false;
11134
- }
11135
- let increasing = true;
11136
- let decreasing = true;
11137
- for (let i = 1; i < digits2.length; i++) {
11138
- const curr = digits2.charCodeAt(i) - 48;
11139
- const prev = digits2.charCodeAt(i - 1) - 48;
11140
- if (curr !== prev + 1) {
11141
- increasing = false;
11142
- }
11143
- if (curr !== prev - 1) {
11144
- decreasing = false;
11145
- }
10775
+ var SAFE_NAVIGATION_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
10776
+ var PREVIEW_PATH = "/preview";
10777
+ var URL_BASE = "https://app.chainpatrol.io";
10778
+ function normalizeSafeNavigationTarget(target) {
10779
+ const normalizedTarget = getNormalizedUrl(target);
10780
+ if (!SAFE_NAVIGATION_PROTOCOLS.has(normalizedTarget.protocol)) {
10781
+ throw new Error(`Unsupported URL protocol: ${normalizedTarget.protocol}`);
11146
10782
  }
11147
- return increasing || decreasing;
10783
+ return normalizedTarget;
11148
10784
  }
11149
- function isValidNanpNational10(d10) {
11150
- if (d10.length !== 10) {
11151
- return false;
10785
+ function buildSafePreviewUrl({
10786
+ target,
10787
+ assetId,
10788
+ policy
10789
+ }) {
10790
+ const normalizedTarget = normalizeSafeNavigationTarget(target);
10791
+ const previewUrl = new URL(PREVIEW_PATH, URL_BASE);
10792
+ previewUrl.searchParams.set("target", normalizedTarget.toString());
10793
+ if (Number.isInteger(assetId) && assetId && assetId >= 1) {
10794
+ previewUrl.searchParams.set("asset_id", String(assetId));
11152
10795
  }
11153
- const npaFirst = d10.charCodeAt(0) - 48;
11154
- const nxxFirst = d10.charCodeAt(3) - 48;
11155
- if (npaFirst < 2 || npaFirst > 9) {
11156
- return false;
10796
+ if (policy) {
10797
+ previewUrl.searchParams.set("policy", policy);
11157
10798
  }
11158
- if (nxxFirst < 2 || nxxFirst > 9) {
11159
- return false;
10799
+ return `${previewUrl.pathname}?${previewUrl.searchParams.toString()}`;
10800
+ }
10801
+
10802
+ // ../../internal/utils/src/parse.ts
10803
+ var parse_exports = {};
10804
+ __export(parse_exports, {
10805
+ parseTerms: () => parseTerms,
10806
+ stringifyTerms: () => stringifyTerms
10807
+ });
10808
+ function parseTerms(terms, {
10809
+ forceExact = false
10810
+ } = {}) {
10811
+ if (!terms) return [];
10812
+ return terms.split(",").map((term) => {
10813
+ const trimmed = term.trim();
10814
+ if (!trimmed) return null;
10815
+ const isWrappedExact = trimmed.startsWith("*") && trimmed.endsWith("*") && trimmed.length > 2;
10816
+ if (isWrappedExact) {
10817
+ return {
10818
+ value: trimmed.slice(1, -1).toLowerCase(),
10819
+ type: "exact"
10820
+ };
10821
+ } else {
10822
+ return {
10823
+ value: trimmed.toLowerCase(),
10824
+ type: forceExact ? "exact" : "loose"
10825
+ };
10826
+ }
10827
+ }).filter((term) => term !== null);
10828
+ }
10829
+ function stringifyTerms(parsedTerms) {
10830
+ return parsedTerms.map((term) => term.type === "exact" ? `*${term.value}*` : term.value).join(", ");
10831
+ }
10832
+
10833
+ // ../../internal/utils/src/brand-pattern.ts
10834
+ var brand_pattern_exports = {};
10835
+ __export(brand_pattern_exports, {
10836
+ anyPatternMatches: () => anyPatternMatches,
10837
+ compileBrandPattern: () => compileBrandPattern,
10838
+ countPatternMatches: () => countPatternMatches,
10839
+ findMatchingPatterns: () => findMatchingPatterns
10840
+ });
10841
+ var DEFAULT_MAX_MATCHES = 50;
10842
+ function compileBrandPattern(input) {
10843
+ var _a;
10844
+ try {
10845
+ return new RegExp(input.pattern, (_a = input.flags) != null ? _a : void 0);
10846
+ } catch (e4) {
10847
+ return null;
11160
10848
  }
11161
- return true;
11162
10849
  }
11163
- function isPlausiblePhoneDigits(withoutExt) {
11164
- const hasPlus = withoutExt.startsWith("+");
11165
- const d = withoutExt.replace(/\D/g, "");
11166
- if (d.length < 8 || d.length > 15) {
11167
- return false;
11168
- }
11169
- if (isAllSameDigit(d) || isStrictlyMonotonicStep1(d)) {
11170
- return false;
11171
- }
11172
- const onlyDigits = /^\d+$/.test(withoutExt);
11173
- if (hasPlus) {
11174
- if (d.length === 11 && d.startsWith("1")) {
11175
- return isValidNanpNational10(d.slice(1));
11176
- }
11177
- return true;
11178
- }
11179
- if (onlyDigits) {
11180
- if (d.length === 10) {
11181
- return isValidNanpNational10(d);
11182
- }
11183
- if (d.length === 11 && d.startsWith("1")) {
11184
- return isValidNanpNational10(d.slice(1));
11185
- }
11186
- if (d.length === 11 && d.startsWith("0")) {
10850
+ function anyPatternMatches(content, patterns, kind) {
10851
+ for (const input of patterns) {
10852
+ if (input.kind !== kind) continue;
10853
+ const regex = compileBrandPattern(input);
10854
+ if (!regex) continue;
10855
+ if (regex.test(content)) {
11187
10856
  return true;
11188
10857
  }
11189
- return false;
11190
10858
  }
11191
- if (d.length === 10) {
11192
- return isValidNanpNational10(d);
10859
+ return false;
10860
+ }
10861
+ function findMatchingPatterns(content, patterns, kind) {
10862
+ const matched = [];
10863
+ for (const input of patterns) {
10864
+ if (input.kind !== kind) continue;
10865
+ const regex = compileBrandPattern(input);
10866
+ if (!regex) continue;
10867
+ if (regex.test(content)) {
10868
+ matched.push(input);
10869
+ }
11193
10870
  }
11194
- if (d.length === 11 && d.startsWith("1")) {
11195
- return isValidNanpNational10(d.slice(1));
10871
+ return matched;
10872
+ }
10873
+ function countPatternMatches(content, pattern, maxMatches = DEFAULT_MAX_MATCHES) {
10874
+ const compiled = compileBrandPattern(pattern);
10875
+ if (!compiled) return 0;
10876
+ const flags = compiled.flags.includes("g") ? compiled.flags : `${compiled.flags}g`;
10877
+ const globalRegex = new RegExp(compiled.source, flags);
10878
+ let count = 0;
10879
+ let match2;
10880
+ while ((match2 = globalRegex.exec(content)) !== null) {
10881
+ count += 1;
10882
+ if (count >= maxMatches) break;
10883
+ if (match2[0].length === 0) globalRegex.lastIndex += 1;
11196
10884
  }
11197
- if (d.length === 11 && d.startsWith("0")) {
11198
- return true;
10885
+ return count;
10886
+ }
10887
+
10888
+ // ../../internal/utils/src/text.ts
10889
+ var text_exports = {};
10890
+ __export(text_exports, {
10891
+ HOMOGLYPH_MAPPINGS: () => HOMOGLYPH_MAPPINGS,
10892
+ LETTER_TO_HOMOGLYPH_MAPPINGS: () => LETTER_TO_HOMOGLYPH_MAPPINGS,
10893
+ generateHomoglyphSearchTerms: () => generateHomoglyphSearchTerms,
10894
+ normalizeHomoglyphs: () => normalizeHomoglyphs
10895
+ });
10896
+ var HOMOGLYPH_MAPPINGS = {
10897
+ "0": "o",
10898
+ "1": "i",
10899
+ "3": "e",
10900
+ "4": "a",
10901
+ "5": "s",
10902
+ "7": "t",
10903
+ "8": "b"
10904
+ };
10905
+ var LETTER_TO_HOMOGLYPH_MAPPINGS = {
10906
+ a: ["4", "\u0430"],
10907
+ b: ["8", "6"],
10908
+ c: ["\u0441"],
10909
+ e: ["3", "\u0435"],
10910
+ g: ["9"],
10911
+ i: ["1", "l", "\u0456"],
10912
+ l: ["1"],
10913
+ o: ["0", "\u043E"],
10914
+ s: ["5", "\u0455"],
10915
+ t: ["7"],
10916
+ x: ["\u0445"],
10917
+ z: ["2"]
10918
+ };
10919
+ var DEFAULT_MAX_HOMOGLYPH_VARIANTS = 20;
10920
+ function isCyrillic(char) {
10921
+ return char.charCodeAt(0) > 127;
10922
+ }
10923
+ function buildReplacementOps(term) {
10924
+ const ops = [];
10925
+ for (let i = 0; i < term.length; i++) {
10926
+ const homoglyphs = LETTER_TO_HOMOGLYPH_MAPPINGS[term[i]];
10927
+ if (!homoglyphs) continue;
10928
+ for (const replacement of homoglyphs) {
10929
+ ops.push({ index: i, replacement });
10930
+ }
11199
10931
  }
11200
- if (d.length >= 12 && d.length <= 15) {
11201
- return true;
10932
+ return ops;
10933
+ }
10934
+ function applyOps(term, ops, selected) {
10935
+ const chars = Array.from(term);
10936
+ for (const idx of selected) {
10937
+ chars[ops[idx].index] = ops[idx].replacement;
11202
10938
  }
11203
- return false;
10939
+ return chars.join("");
11204
10940
  }
11205
- function isPhoneNumber(input) {
11206
- const trimmed = preparePhoneInput(input);
11207
- if (trimmed === "") {
10941
+ function generateCombinations(ops, opIndices, term, maxVariants, addFn, variants) {
10942
+ const generate = (startIdx, depth, selected, usedPositions) => {
10943
+ if (selected.length === depth) return addFn(applyOps(term, ops, selected));
10944
+ for (let i = startIdx; i < opIndices.length && variants.length < maxVariants; i++) {
10945
+ const opIdx = opIndices[i];
10946
+ if (usedPositions.has(ops[opIdx].index)) continue;
10947
+ selected.push(opIdx);
10948
+ usedPositions.add(ops[opIdx].index);
10949
+ if (generate(i + 1, depth, selected, usedPositions)) return true;
10950
+ selected.pop();
10951
+ usedPositions.delete(ops[opIdx].index);
10952
+ }
11208
10953
  return false;
10954
+ };
10955
+ for (let depth = 2; depth <= opIndices.length && variants.length < maxVariants; depth++) {
10956
+ if (generate(0, depth, [], /* @__PURE__ */ new Set())) break;
11209
10957
  }
11210
- if (!/^[+\d(]/.test(trimmed)) {
11211
- return false;
10958
+ }
10959
+ function generateHomoglyphSearchTerms(term, maxVariants = DEFAULT_MAX_HOMOGLYPH_VARIANTS) {
10960
+ if (term.length === 0 || maxVariants <= 0) return [];
10961
+ const lowerTerm = term.toLowerCase();
10962
+ const seen = /* @__PURE__ */ new Set();
10963
+ const variants = [];
10964
+ const add = (v) => {
10965
+ if (v === lowerTerm || seen.has(v)) return false;
10966
+ seen.add(v);
10967
+ variants.push(v);
10968
+ return variants.length >= maxVariants;
10969
+ };
10970
+ const allOps = buildReplacementOps(lowerTerm);
10971
+ for (let i = 0; i < allOps.length && variants.length < maxVariants; i++) {
10972
+ add(applyOps(lowerTerm, allOps, [i]));
11212
10973
  }
11213
- const withoutExt = trimmed.replace(/\s*(ext|extension|x)\s*\d+$/i, "");
11214
- if (/[a-zA-Z]/.test(withoutExt)) {
11215
- return false;
10974
+ if (variants.length < maxVariants) {
10975
+ const cyrillicComposite = lowerTerm.split("").map((char) => {
10976
+ var _a;
10977
+ const homoglyphs = LETTER_TO_HOMOGLYPH_MAPPINGS[char];
10978
+ return (_a = homoglyphs == null ? void 0 : homoglyphs.find((h) => isCyrillic(h))) != null ? _a : char;
10979
+ }).join("");
10980
+ add(cyrillicComposite);
11216
10981
  }
11217
- const hasPhoneMarker = /[+()\s-]/.test(trimmed);
11218
- const isPureDotSeparated = /^\d+(\.\d+)+$/.test(trimmed);
11219
- if (isPureDotSeparated && !hasPhoneMarker) {
11220
- return false;
10982
+ const cyrillicOpIndices = allOps.map((op, i) => isCyrillic(op.replacement) ? i : -1).filter((i) => i >= 0);
10983
+ if (variants.length < maxVariants && cyrillicOpIndices.length >= 2) {
10984
+ generateCombinations(
10985
+ allOps,
10986
+ cyrillicOpIndices,
10987
+ lowerTerm,
10988
+ maxVariants,
10989
+ add,
10990
+ variants
10991
+ );
11221
10992
  }
11222
- const phoneRegex = /^(?:\+?\d{1,4}[\s.-]?)?(?:\(\d{1,4}\)|\d{1,4})[\s.-]?\d{1,4}[\s.-]?\d{1,4}[\s.-]?\d{0,4}(?:\s*(?:ext|x|extension)[\s.]*\d{1,6})?$/i;
11223
- if (!phoneRegex.test(trimmed)) {
11224
- return false;
10993
+ if (variants.length < maxVariants) {
10994
+ const allOpIndices = allOps.map((_, i) => i);
10995
+ generateCombinations(allOps, allOpIndices, lowerTerm, maxVariants, add, variants);
11225
10996
  }
11226
- return isPlausiblePhoneDigits(withoutExt);
10997
+ return variants;
11227
10998
  }
11228
- function normalizePhoneNumber(phone) {
11229
- const trimmed = preparePhoneInput(phone);
11230
- const withoutExt = trimmed.replace(/\s*(ext|extension|x)\s*\d+$/i, "");
11231
- const hasPlus = withoutExt.startsWith("+");
11232
- const digitsOnly = withoutExt.replace(/\D/g, "");
11233
- return hasPlus ? `+${digitsOnly}` : digitsOnly;
10999
+ function normalizeHomoglyphs(text, customMappings = {}) {
11000
+ const mappings = __spreadValues(__spreadValues({}, HOMOGLYPH_MAPPINGS), customMappings);
11001
+ return text.toLowerCase().split("").map((char) => mappings[char] || char).join("");
11234
11002
  }
11235
11003
 
11236
- // ../../internal/utils/src/punycode.ts
11237
- var maxInt = 2147483647;
11238
- var base = 36;
11239
- var tMin = 1;
11240
- var tMax = 26;
11241
- var skew = 38;
11242
- var damp = 700;
11243
- var initialBias = 72;
11244
- var initialN = 128;
11245
- var delimiter = "-";
11246
- var regexPunycode = /^xn--/;
11247
- var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
11248
- var errors = {
11249
- overflow: "Overflow: input needs wider integers to process",
11250
- "not-basic": "Illegal input >= 0x80 (not a basic code point)",
11251
- "invalid-input": "Invalid input"
11252
- };
11253
- var baseMinusTMin = base - tMin;
11254
- var floor = Math.floor;
11255
- function error(type) {
11256
- throw new RangeError(errors[type]);
11257
- }
11258
- function mapDomain(domain, callback) {
11259
- const parts = domain.split("@");
11260
- let result = "";
11261
- if (parts.length > 1) {
11262
- result = parts[0] + "@";
11263
- domain = parts[1];
11004
+ // ../../internal/utils/src/format.ts
11005
+ var format_exports = {};
11006
+ __export(format_exports, {
11007
+ formatCompactNumber: () => formatCompactNumber,
11008
+ formatFileSize: () => formatFileSize
11009
+ });
11010
+ function formatCompactNumber(num3, options = {}) {
11011
+ const { decimals = 1, fallback = "-" } = options;
11012
+ if (num3 === void 0 || num3 === null) {
11013
+ return fallback;
11264
11014
  }
11265
- domain = domain.replace(regexSeparators, ".");
11266
- const labels = domain.split(".");
11267
- const encoded = labels.map(callback).join(".");
11268
- return result + encoded;
11015
+ if (num3 >= 1e9) {
11016
+ return `${(num3 / 1e9).toFixed(decimals)}B`;
11017
+ }
11018
+ if (num3 >= 1e6) {
11019
+ return `${(num3 / 1e6).toFixed(decimals)}M`;
11020
+ }
11021
+ if (num3 >= 1e3) {
11022
+ return `${(num3 / 1e3).toFixed(decimals)}K`;
11023
+ }
11024
+ return num3.toString();
11269
11025
  }
11270
- function basicToDigit(codePoint) {
11271
- if (codePoint >= 48 && codePoint < 58) {
11272
- return 26 + (codePoint - 48);
11026
+ function formatFileSize(bytes, options = {}) {
11027
+ const { decimals = 1, binary = true, showUnknown = true } = options;
11028
+ if (bytes === null || bytes === void 0 || bytes === "") {
11029
+ return showUnknown ? "Unknown" : "0 B";
11273
11030
  }
11274
- if (codePoint >= 65 && codePoint < 91) {
11275
- return codePoint - 65;
11031
+ const size = typeof bytes === "string" ? parseInt(bytes, 10) : bytes;
11032
+ if (isNaN(size) || size < 0) {
11033
+ return showUnknown ? "Unknown" : "0 B";
11276
11034
  }
11277
- if (codePoint >= 97 && codePoint < 123) {
11278
- return codePoint - 97;
11035
+ if (size === 0) {
11036
+ return "0 B";
11279
11037
  }
11280
- return base;
11281
- }
11282
- function adapt(delta, numPoints, firstTime) {
11283
- let k4 = 0;
11284
- delta = firstTime ? floor(delta / damp) : delta >> 1;
11285
- delta += floor(delta / numPoints);
11286
- for (
11287
- ;
11288
- /* no initialization */
11289
- delta > baseMinusTMin * tMax >> 1;
11290
- k4 += base
11291
- ) {
11292
- delta = floor(delta / baseMinusTMin);
11038
+ const unit = binary ? 1024 : 1e3;
11039
+ const units = binary ? ["B", "KB", "MB", "GB", "TB", "PB"] : ["B", "kB", "MB", "GB", "TB", "PB"];
11040
+ const unitIndex = Math.floor(Math.log(size) / Math.log(unit));
11041
+ const finalUnitIndex = Math.min(unitIndex, units.length - 1);
11042
+ const value = size / Math.pow(unit, finalUnitIndex);
11043
+ if (finalUnitIndex === 0) {
11044
+ return `${size} B`;
11293
11045
  }
11294
- return floor(k4 + (baseMinusTMin + 1) * delta / (delta + skew));
11046
+ return `${value.toFixed(decimals)} ${units[finalUnitIndex]}`;
11295
11047
  }
11296
- function decode(input) {
11297
- const output = [];
11298
- const inputLength = input.length;
11299
- let i = 0;
11300
- let n2 = initialN;
11301
- let bias2 = initialBias;
11302
- let basic = input.lastIndexOf(delimiter);
11303
- if (basic < 0) {
11304
- basic = 0;
11305
- }
11306
- for (let j = 0; j < basic; ++j) {
11307
- if (input.charCodeAt(j) >= 128) {
11308
- error("not-basic");
11309
- }
11310
- output.push(input.charCodeAt(j));
11048
+
11049
+ // ../../internal/utils/src/social-profile-url.ts
11050
+ var social_profile_url_exports = {};
11051
+ __export(social_profile_url_exports, {
11052
+ LINKEDIN_PROFILE_URL_PATTERN: () => LINKEDIN_PROFILE_URL_PATTERN,
11053
+ TWITTER_PROFILE_URL_PATTERN: () => TWITTER_PROFILE_URL_PATTERN,
11054
+ isLinkedInProfileUrl: () => isLinkedInProfileUrl,
11055
+ isSupportedSocialProfileUrl: () => isSupportedSocialProfileUrl,
11056
+ isTwitterProfileUrl: () => isTwitterProfileUrl,
11057
+ parseLinkedInProfileUrl: () => parseLinkedInProfileUrl
11058
+ });
11059
+ var TWITTER_PROFILE_URL_PATTERN = /^https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/?#]+\/?(?:[?#].*)?$/i;
11060
+ var LINKEDIN_PROFILE_URL_PATTERN = /^https?:\/\/(?:[a-z]{2,3}\.)?linkedin\.com\/(in|company|school)\/([^/?#]+)/i;
11061
+ function isTwitterProfileUrl(url) {
11062
+ return TWITTER_PROFILE_URL_PATTERN.test(url);
11063
+ }
11064
+ function isLinkedInProfileUrl(url) {
11065
+ return LINKEDIN_PROFILE_URL_PATTERN.test(url);
11066
+ }
11067
+ function isSupportedSocialProfileUrl(url) {
11068
+ return isTwitterProfileUrl(url) || isLinkedInProfileUrl(url);
11069
+ }
11070
+ function humanizeLinkedInHandle(handle) {
11071
+ const withoutTrailingDigits = handle.replace(/-[0-9a-f]{6,}$/i, "");
11072
+ return withoutTrailingDigits.split("-").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
11073
+ }
11074
+ function parseLinkedInProfileUrl(url) {
11075
+ var _a;
11076
+ const match2 = url.match(LINKEDIN_PROFILE_URL_PATTERN);
11077
+ if (!match2) return null;
11078
+ const pathSegment = (_a = match2[1]) == null ? void 0 : _a.toLowerCase();
11079
+ const rawHandle = match2[2];
11080
+ if (!pathSegment || !rawHandle) return null;
11081
+ let handle;
11082
+ try {
11083
+ handle = decodeURIComponent(rawHandle).trim();
11084
+ } catch (e4) {
11085
+ return null;
11311
11086
  }
11312
- for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
11313
- const oldi = i;
11314
- for (let w = 1, k4 = base; ; k4 += base) {
11315
- if (index >= inputLength) {
11316
- error("invalid-input");
11317
- }
11318
- const digit = basicToDigit(input.charCodeAt(index++));
11319
- if (digit >= base) {
11320
- error("invalid-input");
11321
- }
11322
- if (digit > floor((maxInt - i) / w)) {
11323
- error("overflow");
11324
- }
11325
- i += digit * w;
11326
- const t = k4 <= bias2 ? tMin : k4 >= bias2 + tMax ? tMax : k4 - bias2;
11327
- if (digit < t) {
11328
- break;
11329
- }
11330
- const baseMinusT = base - t;
11331
- if (w > floor(maxInt / baseMinusT)) {
11332
- error("overflow");
11333
- }
11334
- w *= baseMinusT;
11335
- }
11336
- const out = output.length + 1;
11337
- bias2 = adapt(i - oldi, out, oldi == 0);
11338
- if (floor(i / out) > maxInt - n2) {
11339
- error("overflow");
11340
- }
11341
- n2 += floor(i / out);
11342
- i %= out;
11343
- output.splice(i++, 0, n2);
11087
+ if (!handle) return null;
11088
+ const name = humanizeLinkedInHandle(handle) || handle;
11089
+ const profileUrl = `https://www.linkedin.com/${pathSegment}/${handle}`;
11090
+ return { pathSegment, handle, name, profileUrl };
11091
+ }
11092
+
11093
+ // ../../internal/validation/src/public/detection/configs-create.ts
11094
+ zod.z.object({
11095
+ slug: zod.z.string().min(1).optional().describe(
11096
+ "Organization slug. Defaults to the organization your API key is scoped to, so you only need this when authenticating with a key that spans organizations."
11097
+ ),
11098
+ source: zod.z.nativeEnum(ThreatDetectionSourceKey).describe(
11099
+ "Detection source key, from `GET /detection/sources`. The source must support the `organization` scope; global-only sources cannot be configured per organization."
11100
+ ),
11101
+ status: zod.z.nativeEnum(ThreatDetectionConfigStatus).default(ThreatDetectionConfigStatus.ENABLED).describe("Status to create the config with. Defaults to `ENABLED`."),
11102
+ title: zod.z.string().trim().optional().describe("Optional label for this config"),
11103
+ description: zod.z.string().trim().nullable().optional().describe("Optional human-readable description of what the config does"),
11104
+ cron: zod.z.string().trim().nullable().optional().describe(
11105
+ "Optional custom CRON schedule. Only accepted for sources that run on a schedule; the source's default schedule is used when omitted."
11106
+ ),
11107
+ config: zod.z.record(zod.z.unknown()).optional().describe(
11108
+ "Source-specific configuration, validated against that source's `configSchema` from `GET /detection/sources`. When omitted the source's schema defaults are applied."
11109
+ ),
11110
+ brandId: zod.z.number().int().positive().nullable().optional().describe(
11111
+ "Optional brand to scope this config to. The brand must belong to the same organization. Omit for an organization-wide config."
11112
+ )
11113
+ }).describe(
11114
+ `Create a threat detection config
11115
+
11116
+ Creates the config row that makes a detection source run for your organization. Sources that are disabled by default have no config row, so they cannot be enabled through \`/detection/configs/update\` until one exists.
11117
+
11118
+ A source can have several configs, each scanning with its own query, schedule or brand. Use \`title\` to tell them apart.`
11119
+ );
11120
+ zod.z.object({
11121
+ config: zod.z.object({
11122
+ id: zod.z.number(),
11123
+ source: zod.z.string(),
11124
+ status: zod.z.nativeEnum(ThreatDetectionConfigStatus),
11125
+ title: zod.z.string(),
11126
+ description: zod.z.string().nullable(),
11127
+ cron: zod.z.string().nullable(),
11128
+ config: zod.z.record(zod.z.unknown()),
11129
+ updatedAt: zod.z.date(),
11130
+ brandId: zod.z.number().nullable()
11131
+ })
11132
+ }).describe("Created detection config");
11133
+ zod.z.object({
11134
+ slug: zod.z.string().min(1).optional().describe(
11135
+ "Organization slug. Defaults to the organization your API key is scoped to, so you only need this when authenticating with a key that spans organizations."
11136
+ ),
11137
+ configId: zod.z.number().int().positive().describe("ID of the config to delete, from `/detection/configs/list`")
11138
+ }).describe(
11139
+ `Delete a threat detection config
11140
+
11141
+ Deletes one detection config so it stops scanning. Deleting a config that shares a source with others leaves the others running.
11142
+
11143
+ Deleting the *last* config for a source that is enabled by default for your organization is not permanent: automation re-creates a default config for that source on its next run. To stop such a source durably, set \`status\` to \`DISABLED\` through \`/detection/configs/update\` instead, which automation will not override.`
11144
+ );
11145
+ zod.z.object({
11146
+ success: zod.z.boolean(),
11147
+ id: zod.z.number().describe("ID of the deleted config")
11148
+ }).describe("Deleted detection config");
11149
+ zod.z.object({
11150
+ slug: zod.z.string().min(1),
11151
+ configId: zod.z.number().int().positive(),
11152
+ status: zod.z.nativeEnum(ThreatDetectionConfigStatus).optional(),
11153
+ title: zod.z.string().trim().optional(),
11154
+ description: zod.z.string().trim().nullable().optional(),
11155
+ cron: zod.z.string().trim().nullable().optional(),
11156
+ config: zod.z.record(zod.z.unknown()).optional(),
11157
+ mergeConfig: zod.z.boolean().default(false),
11158
+ brandId: zod.z.number().int().positive().nullable().optional().describe(
11159
+ "Optional brand connection for this detection config. Pass null to clear the link. Only valid for org-scoped configs; the brand must belong to the same organization."
11160
+ )
11161
+ });
11162
+ zod.z.object({
11163
+ config: zod.z.object({
11164
+ id: zod.z.number(),
11165
+ source: zod.z.string(),
11166
+ status: zod.z.nativeEnum(ThreatDetectionConfigStatus),
11167
+ title: zod.z.string(),
11168
+ description: zod.z.string().nullable(),
11169
+ cron: zod.z.string().nullable(),
11170
+ config: zod.z.record(zod.z.unknown()),
11171
+ updatedAt: zod.z.date(),
11172
+ brandId: zod.z.number().nullable()
11173
+ })
11174
+ });
11175
+ zod.z.object({
11176
+ slug: zod.z.string().min(1),
11177
+ source: zod.z.string().optional(),
11178
+ minResults: zod.z.number().int().min(0).default(1),
11179
+ lookbackHours: zod.z.number().int().min(1).default(24 * 7),
11180
+ runBeforeValidate: zod.z.boolean().default(false),
11181
+ includeDisabled: zod.z.boolean().default(false)
11182
+ });
11183
+ zod.z.object({
11184
+ ok: zod.z.boolean(),
11185
+ summary: zod.z.object({
11186
+ checkedConfigs: zod.z.number(),
11187
+ passingConfigs: zod.z.number(),
11188
+ failingConfigs: zod.z.number(),
11189
+ lookbackHours: zod.z.number(),
11190
+ minResults: zod.z.number()
11191
+ }),
11192
+ validations: zod.z.array(
11193
+ zod.z.object({
11194
+ configId: zod.z.number(),
11195
+ source: zod.z.string(),
11196
+ status: zod.z.nativeEnum(ThreatDetectionConfigStatus),
11197
+ ran: zod.z.boolean(),
11198
+ runOk: zod.z.boolean(),
11199
+ runMessage: zod.z.string().nullable(),
11200
+ recentResultCount: zod.z.number(),
11201
+ valid: zod.z.boolean()
11202
+ })
11203
+ )
11204
+ });
11205
+ zod.z.object({
11206
+ slug: zod.z.string().min(1),
11207
+ configId: zod.z.number().int().positive().optional(),
11208
+ source: zod.z.string().min(1).optional(),
11209
+ includeDisabled: zod.z.boolean().default(false)
11210
+ });
11211
+ zod.z.object({
11212
+ ranCount: zod.z.number(),
11213
+ successCount: zod.z.number(),
11214
+ failedCount: zod.z.number(),
11215
+ results: zod.z.array(
11216
+ zod.z.object({
11217
+ configId: zod.z.number(),
11218
+ source: zod.z.string(),
11219
+ ok: zod.z.boolean(),
11220
+ message: zod.z.string().nullable(),
11221
+ assetsCount: zod.z.number()
11222
+ })
11223
+ )
11224
+ });
11225
+ zod.z.object({
11226
+ slug: zod.z.string().min(1).optional().describe(
11227
+ "Organization slug. Defaults to the organization your API key is scoped to, so you only need this when authenticating with a key that spans organizations. Sources that do not apply to the organization's industry are omitted."
11228
+ )
11229
+ }).describe(
11230
+ `List available threat detection sources
11231
+
11232
+ Returns the catalog of detection sources ChainPatrol can run, including the scopes each source supports and the JSON Schema its \`config\` object must satisfy. Use this to discover valid \`source\` keys before creating or updating a detection config.`
11233
+ );
11234
+ var detectionSourceSchema = zod.z.object({
11235
+ key: zod.z.string().describe("Detection source key (e.g. google_search, certstream, dns_twist)"),
11236
+ label: zod.z.string().describe("Human-readable source name"),
11237
+ description: zod.z.string().describe("What this source detects"),
11238
+ scopes: zod.z.array(zod.z.nativeEnum(ThreatDetectionScope)).describe(
11239
+ "Scopes this source supports. A source without `organization` cannot be configured per-org and runs globally for all organizations."
11240
+ ),
11241
+ isPullBased: zod.z.boolean().describe(
11242
+ "Whether the source runs on a schedule (pull-based). Push-based sources such as webhooks ignore `cron` and cannot be run on demand."
11243
+ ),
11244
+ brandScope: zod.z.enum(["organization_only", "all_brands"]).describe(
11245
+ "Which brands this source fans out to. `organization_only` sources only use brands of type `ORGANIZATION`; `all_brands` sources use every brand in the organization."
11246
+ ),
11247
+ industries: zod.z.array(zod.z.string()).describe(
11248
+ "Industries this source applies to. Empty means it applies to every industry."
11249
+ ),
11250
+ protectedAssetTypes: zod.z.array(zod.z.string()).describe(
11251
+ "Asset types this source monitors. Empty when the source does not key off protected assets."
11252
+ ),
11253
+ configSchema: zod.z.record(zod.z.unknown()).nullable().describe(
11254
+ "JSON Schema for this source's `config` object, for use with `/detection/configs/update`. `null` when the source takes no configuration."
11255
+ )
11256
+ });
11257
+ zod.z.object({
11258
+ sources: zod.z.array(detectionSourceSchema).describe("Available detection sources")
11259
+ }).describe("Successful operation");
11260
+ var DetectionDriftThresholdsSchema = zod.z.object({
11261
+ zeroResultsMaxHours: zod.z.number().int().positive().default(72),
11262
+ noisyResultsPerDay: zod.z.number().positive().default(100),
11263
+ noisyAllowedRatioThreshold: zod.z.number().min(0).max(1).default(0.6),
11264
+ staleConfigDays: zod.z.number().int().positive().default(30)
11265
+ });
11266
+ zod.z.object({
11267
+ slug: zod.z.string().min(1),
11268
+ lookbackHours: zod.z.number().int().positive().default(168),
11269
+ startDate: zod.z.date().optional(),
11270
+ endDate: zod.z.date().optional(),
11271
+ source: zod.z.string().min(1).optional(),
11272
+ configIds: zod.z.array(zod.z.number().int().positive()).optional(),
11273
+ includeDisabled: zod.z.boolean().default(false),
11274
+ thresholds: DetectionDriftThresholdsSchema.optional()
11275
+ }).refine(
11276
+ (value) => !value.startDate && !value.endDate || Boolean(value.startDate) && Boolean(value.endDate),
11277
+ {
11278
+ message: "Provide both startDate and endDate when using explicit date range",
11279
+ path: ["startDate"]
11344
11280
  }
11345
- return String.fromCodePoint(...output);
11346
- }
11347
- function toUnicode(input) {
11348
- return mapDomain(input, function(string) {
11349
- return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
11350
- });
11351
- }
11281
+ );
11282
+ var DetectionDriftSignalSchema = zod.z.object({
11283
+ signal: zod.z.enum(["zero_results_too_long", "noisy_source", "stale_query"]),
11284
+ configId: zod.z.number().int().positive(),
11285
+ source: zod.z.string(),
11286
+ title: zod.z.string().nullable(),
11287
+ status: zod.z.string(),
11288
+ severity: zod.z.enum(["low", "medium", "high"]),
11289
+ details: zod.z.record(zod.z.unknown())
11290
+ });
11291
+ zod.z.object({
11292
+ ok: zod.z.boolean(),
11293
+ range: zod.z.object({
11294
+ startDate: zod.z.date(),
11295
+ endDate: zod.z.date(),
11296
+ lookbackHours: zod.z.number().int().positive()
11297
+ }),
11298
+ thresholds: DetectionDriftThresholdsSchema,
11299
+ summary: zod.z.object({
11300
+ checkedConfigs: zod.z.number().int().nonnegative(),
11301
+ signalCount: zod.z.number().int().nonnegative(),
11302
+ zeroResultsCount: zod.z.number().int().nonnegative(),
11303
+ noisyCount: zod.z.number().int().nonnegative(),
11304
+ staleCount: zod.z.number().int().nonnegative()
11305
+ }),
11306
+ signals: zod.z.array(DetectionDriftSignalSchema)
11307
+ });
11308
+ var BucketsSchema = zod.z.object({
11309
+ lt24h: zod.z.number().int().nonnegative(),
11310
+ h24to72: zod.z.number().int().nonnegative(),
11311
+ h72to168: zod.z.number().int().nonnegative(),
11312
+ gte168h: zod.z.number().int().nonnegative()
11313
+ });
11314
+ zod.z.object({
11315
+ slug: zod.z.string().min(1).optional(),
11316
+ all: zod.z.boolean().default(false),
11317
+ windowHours: zod.z.number().int().positive().default(168)
11318
+ });
11319
+ zod.z.object({
11320
+ generatedAt: zod.z.date(),
11321
+ scope: zod.z.object({
11322
+ slug: zod.z.string().nullable(),
11323
+ all: zod.z.boolean()
11324
+ }),
11325
+ reviewQueue: zod.z.object({
11326
+ totalPendingProposals: zod.z.number().int().nonnegative(),
11327
+ distinctReports: zod.z.number().int().nonnegative(),
11328
+ ageBuckets: BucketsSchema,
11329
+ slaBuckets: zod.z.object({
11330
+ breached: zod.z.number().int().nonnegative(),
11331
+ dueWithin24h: zod.z.number().int().nonnegative(),
11332
+ dueWithin72h: zod.z.number().int().nonnegative(),
11333
+ beyond72h: zod.z.number().int().nonnegative(),
11334
+ missingSla: zod.z.number().int().nonnegative()
11335
+ }),
11336
+ byOrg: zod.z.array(
11337
+ zod.z.object({
11338
+ slug: zod.z.string(),
11339
+ pendingProposals: zod.z.number().int().nonnegative()
11340
+ })
11341
+ )
11342
+ }),
11343
+ takedownQueue: zod.z.object({
11344
+ totalOpen: zod.z.number().int().nonnegative(),
11345
+ statusCounts: zod.z.object({
11346
+ todo: zod.z.number().int().nonnegative(),
11347
+ inProgress: zod.z.number().int().nonnegative(),
11348
+ pendingInput: zod.z.number().int().nonnegative()
11349
+ }),
11350
+ ageBuckets: BucketsSchema,
11351
+ staleInProgress: zod.z.number().int().nonnegative(),
11352
+ byOrg: zod.z.array(
11353
+ zod.z.object({
11354
+ slug: zod.z.string(),
11355
+ openTakedowns: zod.z.number().int().nonnegative()
11356
+ })
11357
+ )
11358
+ })
11359
+ });
11360
+ var HealthcheckCategorySchema = zod.z.enum([
11361
+ "detection",
11362
+ "reviewing",
11363
+ "blocklisting",
11364
+ "takedowns",
11365
+ "assets",
11366
+ "organization"
11367
+ ]);
11368
+ var HealthcheckSeveritySchema = zod.z.enum(["ok", "warn", "fail"]);
11369
+ var HealthcheckFindingSchema = zod.z.object({
11370
+ kind: zod.z.string(),
11371
+ ref: zod.z.string().nullable(),
11372
+ message: zod.z.string(),
11373
+ severity: zod.z.enum(["warn", "fail"])
11374
+ });
11375
+ zod.z.object({
11376
+ id: zod.z.string(),
11377
+ title: zod.z.string(),
11378
+ category: HealthcheckCategorySchema,
11379
+ generatedAt: zod.z.date(),
11380
+ scope: zod.z.object({
11381
+ slug: zod.z.string().nullable()
11382
+ }),
11383
+ ok: zod.z.boolean(),
11384
+ severity: HealthcheckSeveritySchema,
11385
+ observed: zod.z.record(zod.z.union([zod.z.number(), zod.z.string(), zod.z.boolean()]).nullable()),
11386
+ threshold: zod.z.record(zod.z.union([zod.z.number(), zod.z.string(), zod.z.boolean()]).nullable()),
11387
+ findings: zod.z.array(HealthcheckFindingSchema),
11388
+ suggestedAction: zod.z.string().nullable(),
11389
+ appUrl: zod.z.string().nullable()
11390
+ });
11352
11391
 
11353
- // ../../internal/utils/src/url.ts
11354
- function isEmail(input) {
11355
- if (input.trim() === "") {
11356
- return false;
11357
- }
11358
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
11359
- return emailRegex.test(input);
11360
- }
11361
- function removeHttpProtocol(input) {
11362
- return input.replace(/^https?:\/\//, "");
11363
- }
11364
- function stripDomainWildcardPrefix(domain) {
11365
- const trimmedDomain = domain.trim();
11366
- const strippedDomain = trimmedDomain.startsWith("*.") ? trimmedDomain.slice(2) : trimmedDomain;
11367
- return strippedDomain.length > 0 ? strippedDomain : null;
11368
- }
11369
- function getDefangedUrl(input) {
11370
- if (!isUrl(input)) {
11371
- console.warn(`[getDefangedUrl] Invalid URL: ${input}, returning input as-is`);
11372
- return input;
11373
- }
11374
- return input.replace(/\./g, "[.]").replace(/(https:\/\/)/g, "hxxps://").replace(/(http:\/\/)/g, "hxxp://").replace(/:\/\//g, "[://]");
11375
- }
11376
- function getRefangedUrl(input) {
11377
- return input.replace(/hxxps/gi, "https").replace(/hxxp/gi, "http").replace(/\[:\/{2}\]/g, "://").replace(/\[\.\]/g, ".");
11378
- }
11379
- function containsPunycode(url) {
11380
- return url.indexOf("xn--") !== -1;
11381
- }
11382
- function toUnicode2(url) {
11383
- return toUnicode(url);
11384
- }
11385
- function convertHttpsToHttp(url) {
11386
- if (url.startsWith("https://")) {
11387
- const httpUrl = new URL(url);
11388
- httpUrl.protocol = "http:";
11389
- return httpUrl.toString();
11390
- }
11391
- throw new Error(`URL is not HTTPS: ${url}`);
11392
- }
11393
- function generateCanonicalIPFSUrl(content) {
11394
- if (!content) {
11395
- return content;
11396
- }
11397
- if (content.includes("ipfs.io")) {
11398
- return content;
11399
- }
11400
- if (content.startsWith("Qm") || content.startsWith("bafy")) {
11401
- return `ipfs.io/ipfs/${content}`;
11402
- }
11403
- return content;
11404
- }
11405
- function isWalrusSite(content) {
11406
- return content.includes(".walrus.site") || content.includes(".walrus.host") || content.includes(".wal.app") || content.includes(".wal.site");
11407
- }
11408
- function getFaviconUrl(content) {
11409
- const normalizedUrl = getNormalizedUrl(content);
11410
- return `https://icons.duckduckgo.com/ip3/${normalizedUrl.hostname}.ico`;
11411
- }
11412
- function sanitizeHttpUrl(value) {
11413
- if (typeof value !== "string" || value.length === 0) {
11414
- return null;
11392
+ // ../../internal/validation/src/public/healthchecks/assets-dead-asset-spike.ts
11393
+ zod.z.object({
11394
+ slug: zod.z.string().min(1),
11395
+ windowHours: zod.z.number().int().positive().default(24),
11396
+ baselineDays: zod.z.number().int().positive().default(7),
11397
+ warnMultiplier: zod.z.number().positive().default(2),
11398
+ failMultiplier: zod.z.number().positive().default(4),
11399
+ minSpikeCount: zod.z.number().int().min(1).default(10)
11400
+ });
11401
+ zod.z.object({});
11402
+ var HealthcheckRegistryEntrySchema = zod.z.object({
11403
+ id: zod.z.string(),
11404
+ title: zod.z.string(),
11405
+ description: zod.z.string(),
11406
+ category: HealthcheckCategorySchema,
11407
+ implemented: zod.z.boolean(),
11408
+ endpoint: zod.z.string().nullable(),
11409
+ defaultThreshold: zod.z.record(zod.z.union([zod.z.number(), zod.z.string()])).optional(),
11410
+ notImplementedReason: zod.z.string().optional()
11411
+ });
11412
+ zod.z.object({
11413
+ checks: zod.z.array(HealthcheckRegistryEntrySchema)
11414
+ });
11415
+ zod.z.object({
11416
+ slug: zod.z.string().min(1)
11417
+ });
11418
+ zod.z.object({
11419
+ slug: zod.z.string().min(1),
11420
+ warnThreshold: zod.z.number().int().nonnegative().default(50),
11421
+ failThreshold: zod.z.number().int().nonnegative().default(100)
11422
+ });
11423
+ zod.z.object({
11424
+ slug: zod.z.string().min(1),
11425
+ warnAgeHours: zod.z.number().int().positive().default(24 * 7),
11426
+ failAgeHours: zod.z.number().int().positive().default(24 * 14)
11427
+ });
11428
+ zod.z.object({
11429
+ slug: zod.z.string().min(1),
11430
+ warnAgeHours: zod.z.number().int().nonnegative().default(24 * 30),
11431
+ failAgeHours: zod.z.number().int().nonnegative().default(24 * 60)
11432
+ });
11433
+ zod.z.object({
11434
+ slug: zod.z.string().min(1),
11435
+ lookbackHours: zod.z.number().int().positive().default(24 * 7),
11436
+ warnThreshold: zod.z.number().int().nonnegative().default(3),
11437
+ failThreshold: zod.z.number().int().nonnegative().default(10)
11438
+ });
11439
+ zod.z.object({
11440
+ slug: zod.z.string().min(1),
11441
+ warnThreshold: zod.z.number().int().nonnegative().default(30),
11442
+ failThreshold: zod.z.number().int().nonnegative().default(75)
11443
+ });
11444
+ zod.z.object({
11445
+ slug: zod.z.string().min(1),
11446
+ staleThresholdHours: zod.z.number().int().positive().default(24 * 7),
11447
+ warnThreshold: zod.z.number().int().nonnegative().default(1),
11448
+ failThreshold: zod.z.number().int().nonnegative().default(5)
11449
+ });
11450
+ zod.z.object({
11451
+ slug: zod.z.string().min(1),
11452
+ warnThreshold: zod.z.number().int().nonnegative().default(50),
11453
+ failThreshold: zod.z.number().int().nonnegative().default(100)
11454
+ });
11455
+ var BreakdownBySchema = zod.z.enum(["day", "type", "brand"]);
11456
+ zod.z.object({
11457
+ slug: zod.z.string().min(1),
11458
+ by: BreakdownBySchema,
11459
+ startDate: zod.z.date().optional(),
11460
+ endDate: zod.z.date().optional(),
11461
+ brandIds: zod.z.array(zod.z.number().int().positive()).optional()
11462
+ });
11463
+ zod.z.object({
11464
+ by: BreakdownBySchema,
11465
+ points: zod.z.array(
11466
+ zod.z.object({
11467
+ key: zod.z.string(),
11468
+ count: zod.z.number(),
11469
+ date: zod.z.string().optional(),
11470
+ type: zod.z.string().optional(),
11471
+ brandId: zod.z.number().optional(),
11472
+ brandSlug: zod.z.string().optional(),
11473
+ brandName: zod.z.string().optional()
11474
+ })
11475
+ )
11476
+ });
11477
+ zod.z.object({
11478
+ slug: zod.z.string().min(1),
11479
+ startDate: zod.z.date(),
11480
+ endDate: zod.z.date(),
11481
+ brandIds: zod.z.array(zod.z.number().int().positive()).optional()
11482
+ });
11483
+ zod.z.object({
11484
+ metric: zod.z.literal("new_threats"),
11485
+ found: zod.z.number(),
11486
+ range: zod.z.object({
11487
+ startDate: zod.z.date(),
11488
+ endDate: zod.z.date()
11489
+ })
11490
+ });
11491
+ zod.z.object({
11492
+ slug: zod.z.string().min(1),
11493
+ startDate: zod.z.date().optional(),
11494
+ endDate: zod.z.date().optional(),
11495
+ brandIds: zod.z.array(zod.z.number().int().positive()).optional()
11496
+ });
11497
+ zod.z.object({
11498
+ metrics: zod.z.object({
11499
+ reports: zod.z.number(),
11500
+ newThreats: zod.z.number(),
11501
+ threatsWatchlisted: zod.z.number(),
11502
+ takedownsFiled: zod.z.number(),
11503
+ takedownsCompleted: zod.z.number(),
11504
+ domainThreats: zod.z.number(),
11505
+ twitterThreats: zod.z.number(),
11506
+ telegramThreats: zod.z.number(),
11507
+ otherThreats: zod.z.number()
11508
+ }),
11509
+ blockedByDay: zod.z.array(
11510
+ zod.z.object({
11511
+ date: zod.z.string(),
11512
+ count: zod.z.number()
11513
+ })
11514
+ ),
11515
+ blockedByType: zod.z.array(
11516
+ zod.z.object({
11517
+ type: zod.z.string(),
11518
+ count: zod.z.number()
11519
+ })
11520
+ )
11521
+ });
11522
+ var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
11523
+ var utcDateSchema = (endOfDay) => zod.z.preprocess((value) => {
11524
+ if (typeof value !== "string") {
11525
+ return value;
11415
11526
  }
11416
- try {
11417
- const parsed = new URL(value);
11418
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
11419
- return null;
11420
- }
11421
- return parsed.toString();
11422
- } catch (e4) {
11423
- return null;
11527
+ const parsed = DateTime.fromISO(value, { zone: "utc" });
11528
+ if (!parsed.isValid) {
11529
+ return new Date(Number.NaN);
11424
11530
  }
11425
- }
11426
- var URL_REGEX = /https?:\/\/[^\s"'<>\])]*/g;
11531
+ return endOfDay && DATE_ONLY_PATTERN.test(value) ? parsed.endOf("day").toJSDate() : parsed.toJSDate();
11532
+ }, zod.z.coerce.date());
11533
+ zod.z.object({
11534
+ slug: zod.z.string().min(1).describe("Organization slug"),
11535
+ startDate: utcDateSchema(false).optional().describe(
11536
+ "Only include takedowns completed on or after this date. A date-only value (YYYY-MM-DD) starts at midnight UTC"
11537
+ ),
11538
+ endDate: utcDateSchema(true).optional().describe(
11539
+ "Only include takedowns completed on or before this date. A date-only value (YYYY-MM-DD) covers the whole day in UTC; pass a full timestamp for a precise cut-off"
11540
+ ),
11541
+ blockLabel: zod.z.string().optional().describe(
11542
+ 'Only include assets blocked with this review label, e.g. "Brand Impersonation", "Employee Impersonation" or "Targeting Org Users"'
11543
+ ),
11544
+ brandType: zod.z.nativeEnum(BrandType).optional().describe("Only include assets belonging to brands of this type"),
11545
+ countryCodes: zod.z.array(zod.z.string().length(2)).optional().describe("Only include assets scanned from these ISO 3166-1 alpha-2 countries"),
11546
+ brandIds: zod.z.array(zod.z.number().int().positive()).optional().describe("Only include assets belonging to these brands")
11547
+ });
11548
+ zod.z.object({
11549
+ byAssetType: zod.z.array(
11550
+ zod.z.object({
11551
+ assetType: zod.z.nativeEnum(AssetType).describe("Asset type the median is computed over"),
11552
+ medianTakedownMinutes: zod.z.number(),
11553
+ medianTakedownHours: zod.z.number(),
11554
+ medianTakedownDays: zod.z.number(),
11555
+ count: zod.z.number().describe("Number of completed takedowns behind the median")
11556
+ })
11557
+ ).describe(
11558
+ "Median time from takedown start to completion, one entry per asset type, ascending by median"
11559
+ )
11560
+ });
11561
+ zod.z.object({
11562
+ slug: zod.z.string().optional().describe(
11563
+ "Organization slug. Optional for organization-scoped API keys, which resolve the organization from the key itself. Required when your credentials can reach more than one organization."
11564
+ ),
11565
+ type: zod.z.nativeEnum(AssetType).optional().describe("Filter by asset type (URL, ADDRESS, etc.)"),
11566
+ groupId: zod.z.number().int().optional().describe(
11567
+ "Filter by group ID. Use -1 for ungrouped assets only. Omit for all assets."
11568
+ ),
11569
+ query: zod.z.string().optional().describe("Search query to filter assets by content"),
11570
+ per_page: zod.z.number().int().min(1).max(1e3).optional().default(100).describe("The number of assets to return per page (max 1000)"),
11571
+ next_page: zod.z.string().optional().nullable().describe("Cursor for fetching the next page of results")
11572
+ }).describe(
11573
+ `List organization assets request body
11427
11574
 
11428
- // ../../internal/utils/src/email.ts
11429
- var email_exports = {};
11430
- __export(email_exports, {
11431
- extractTextFromGmailPayload: () => extractTextFromGmailPayload,
11432
- getDomainFromEmail: () => getDomainFromEmail,
11433
- getNameFromEmail: () => getNameFromEmail
11575
+ Returns all assets belonging to the organization identified by \`slug\`, or \u2014
11576
+ when \`slug\` is omitted \u2014 the organization associated with your API key.
11577
+ Supports filtering by type, group, and search query.`
11578
+ );
11579
+ var organizationAssetItemSchema = zod.z.object({
11580
+ id: zod.z.number().describe("Asset ID"),
11581
+ content: zod.z.string().describe("Asset content (URL, address, handle, etc.)"),
11582
+ type: zod.z.nativeEnum(AssetType).describe("Asset type"),
11583
+ status: zod.z.nativeEnum(AssetStatus).describe("Asset status"),
11584
+ name: zod.z.string().nullable().describe("Asset display name"),
11585
+ description: zod.z.string().nullable().describe("Asset description"),
11586
+ group: zod.z.object({
11587
+ id: zod.z.number().describe("Group ID"),
11588
+ name: zod.z.string().describe("Group name")
11589
+ }).nullable().describe("Asset group information"),
11590
+ livenessStatus: zod.z.nativeEnum(LivenessStatus).nullable().describe(
11591
+ "Whether the asset is currently reachable (`ALIVE`), gone (`DEAD`), or hasn't been checked (`UNKNOWN`). `null` when liveness has never been evaluated."
11592
+ ),
11593
+ blockedAt: zod.z.date().nullable().describe(
11594
+ "When the asset transitioned to BLOCKED status. `null` for non-blocked assets. Distinct from `updatedAt`."
11595
+ ),
11596
+ createdAt: zod.z.date().describe("When the asset was created"),
11597
+ updatedAt: zod.z.date().describe("When the asset was last updated")
11434
11598
  });
11435
- function getDomainFromEmail(email) {
11436
- return email.split("@")[1];
11437
- }
11438
- function getNameFromEmail(email) {
11439
- return email.split("@")[0];
11440
- }
11441
- function extractTextFromGmailPayload(payload) {
11442
- var _a;
11443
- if (!payload) return "";
11444
- if ((_a = payload.body) == null ? void 0 : _a.data) {
11445
- if (payload.mimeType === "text/plain" || payload.mimeType === "text/html") {
11446
- return Buffer.from(payload.body.data, "base64url").toString("utf-8");
11447
- }
11448
- }
11449
- if (payload.parts) {
11450
- if (payload.mimeType === "multipart/alternative") {
11451
- const plainTextPart = payload.parts.find((part) => part.mimeType === "text/plain");
11452
- if (plainTextPart) {
11453
- return extractTextFromGmailPayload(plainTextPart);
11454
- }
11455
- const htmlPart = payload.parts.find((part) => part.mimeType === "text/html");
11456
- if (htmlPart) {
11457
- return extractTextFromGmailPayload(htmlPart);
11458
- }
11459
- for (const part of payload.parts) {
11460
- const text = extractTextFromGmailPayload(part);
11461
- if (text) return text;
11462
- }
11463
- }
11464
- return payload.parts.map((part) => extractTextFromGmailPayload(part)).join("\n");
11465
- }
11466
- return "";
11467
- }
11599
+ zod.z.object({
11600
+ assets: zod.z.array(organizationAssetItemSchema).describe("List of assets"),
11601
+ next_page: zod.z.string().nullable().optional().describe("Cursor for fetching the next page of results")
11602
+ }).describe("Successful operation");
11603
+ var addAssetItemSchema = zod.z.object({
11604
+ content: zod.z.string().describe("Asset content (URL, address, handle, etc.)"),
11605
+ name: zod.z.string().optional().describe("Optional display name for the asset"),
11606
+ description: zod.z.string().optional().describe("Optional description for the asset"),
11607
+ groupId: zod.z.number().int().positive().optional().describe("Optional group ID to assign the asset to")
11608
+ });
11609
+ zod.z.object({
11610
+ assets: zod.z.array(addAssetItemSchema).min(1).max(1e3).describe("Array of assets to add (max 1000 per request)")
11611
+ }).describe(
11612
+ `Add assets to organization allowlist
11613
+
11614
+ Batch add multiple assets to your organization's allowlist.
11615
+ Each asset will be automatically parsed and classified.
11616
+ Assets will be auto-approved as ALLOWED status.`
11617
+ );
11618
+ var addAssetResultSchema = zod.z.object({
11619
+ content: zod.z.string().describe("Asset content"),
11620
+ success: zod.z.boolean().describe("Whether the asset was added successfully"),
11621
+ id: zod.z.number().optional().describe("Asset ID if successful"),
11622
+ error: zod.z.string().optional().describe("Error message if failed")
11623
+ });
11624
+ zod.z.object({
11625
+ results: zod.z.array(addAssetResultSchema).describe("Results for each asset"),
11626
+ successCount: zod.z.number().describe("Number of assets successfully added"),
11627
+ errorCount: zod.z.number().describe("Number of assets that failed to add")
11628
+ }).describe("Batch add operation results");
11629
+ zod.z.object({
11630
+ assetId: zod.z.number().int().positive().describe("ID of the asset to update"),
11631
+ name: zod.z.string().optional().describe("New display name for the asset"),
11632
+ description: zod.z.string().nullable().optional().describe("New description for the asset"),
11633
+ groupId: zod.z.number().int().positive().nullable().optional().describe("New group ID (null to ungroup)")
11634
+ }).describe(
11635
+ `Update an organization asset
11636
+
11637
+ Update the name, description, or group assignment of an asset.`
11638
+ );
11639
+ zod.z.object({
11640
+ id: zod.z.number().describe("Asset ID"),
11641
+ content: zod.z.string().describe("Asset content"),
11642
+ name: zod.z.string().nullable().describe("Asset display name"),
11643
+ description: zod.z.string().nullable().describe("Asset description"),
11644
+ groupId: zod.z.number().nullable().describe("Group ID")
11645
+ }).describe("Updated asset");
11646
+ zod.z.object({
11647
+ assetId: zod.z.number().int().positive().describe("ID of the asset to remove")
11648
+ }).describe(
11649
+ `Remove an asset from the organization
11650
+
11651
+ This removes the asset from the organization's allowlist.`
11652
+ );
11653
+ zod.z.object({
11654
+ success: zod.z.boolean().describe("Whether the asset was removed successfully"),
11655
+ id: zod.z.number().describe("Asset ID that was removed")
11656
+ }).describe("Delete operation result");
11657
+ zod.z.object({}).describe(
11658
+ `List organization asset groups
11659
+
11660
+ Returns all asset groups belonging to the organization associated with your API key.`
11661
+ );
11662
+ var assetGroupItemSchema = zod.z.object({
11663
+ id: zod.z.number().describe("Group ID"),
11664
+ name: zod.z.string().describe("Group name"),
11665
+ assetCount: zod.z.number().describe("Number of assets in this group")
11666
+ });
11667
+ zod.z.object({
11668
+ groups: zod.z.array(assetGroupItemSchema).describe("List of asset groups")
11669
+ }).describe("Successful operation");
11670
+ zod.z.object({
11671
+ name: zod.z.string().min(1).max(255).describe("Name for the new group")
11672
+ }).describe(
11673
+ `Create a new asset group
11674
+
11675
+ Creates a new asset group for organizing your organization's assets.`
11676
+ );
11677
+ zod.z.object({
11678
+ id: zod.z.number().describe("Created group ID"),
11679
+ name: zod.z.string().describe("Group name")
11680
+ }).describe("Created group");
11681
+ zod.z.object({
11682
+ groupId: zod.z.number().int().positive().describe("ID of the group to update"),
11683
+ name: zod.z.string().min(1).max(255).describe("New name for the group")
11684
+ }).describe(
11685
+ `Update an asset group
11686
+
11687
+ Rename an existing asset group.`
11688
+ );
11689
+ zod.z.object({
11690
+ id: zod.z.number().describe("Group ID"),
11691
+ name: zod.z.string().describe("Updated group name")
11692
+ }).describe("Updated group");
11693
+ zod.z.object({
11694
+ groupId: zod.z.number().int().positive().describe("ID of the group to delete")
11695
+ }).describe(
11696
+ `Delete an asset group
11697
+
11698
+ Deletes an asset group. Assets in this group will become ungrouped.`
11699
+ );
11700
+ zod.z.object({
11701
+ success: zod.z.boolean().describe("Whether the group was deleted successfully"),
11702
+ id: zod.z.number().describe("Group ID that was deleted"),
11703
+ unassignedAssetCount: zod.z.number().describe("Number of assets that were unassigned from this group")
11704
+ }).describe("Delete operation result");
11705
+ zod.z.object({}).describe(
11706
+ `List organization brands
11468
11707
 
11469
- // ../../internal/utils/src/vercel.ts
11470
- var vercel_exports = {};
11471
- __export(vercel_exports, {
11472
- checkVercelEnv: () => checkVercelEnv
11708
+ Returns all brands belonging to the organization associated with your API key,
11709
+ including sub-brands (\`ORGANIZATION\`), individual / employee brands
11710
+ (\`INDIVIDUAL\`), and product brands (\`PRODUCT\`). Soft-deleted brands are
11711
+ excluded.`
11712
+ );
11713
+ var brandLegalDocumentSchema = zod.z.object({
11714
+ present: zod.z.boolean().describe("Whether the brand has this document attached"),
11715
+ fileName: zod.z.string().nullable().describe("Original filename of the uploaded document (null when not present)"),
11716
+ fileUrl: zod.z.string().nullable().describe("Direct URL to view or download the document (null when not present)")
11473
11717
  });
11474
- var checkVercelEnv = ({ envs }) => {
11475
- var _a;
11476
- const vercelEnv = (_a = process.env.VERCEL_ENV) != null ? _a : "development";
11477
- if (!envs.includes(vercelEnv)) {
11478
- return {
11479
- ok: false,
11480
- message: `Vercel environment is ${vercelEnv}, but expected ${envs.join(" or ")}`
11481
- };
11482
- }
11483
- return { ok: true, message: "" };
11484
- };
11485
-
11486
- // ../../internal/utils/src/delay.ts
11487
- var delay_exports = {};
11488
- __export(delay_exports, {
11489
- delay: () => delay
11718
+ var brandTrademarkRegistrationSchema = zod.z.object({
11719
+ id: zod.z.number().describe("Trademark registration ID"),
11720
+ brandName: zod.z.string().describe("Trademarked brand name as it appears on the registration"),
11721
+ trademarkOffice: zod.z.string().describe("Issuing trademark office (e.g. `USPTO`, `EUIPO`)"),
11722
+ registrationNumber: zod.z.string().describe("Registration number assigned by the office"),
11723
+ goodsAndServicesClass: zod.z.string().describe("Nice Classification class(es) the registration covers"),
11724
+ rightsOwnerName: zod.z.string().nullable().describe("Legal entity the trademark is registered to, if recorded"),
11725
+ registrationPageUrl: zod.z.string().nullable().describe("Public URL on the trademark office's site, if recorded"),
11726
+ certificateFileName: zod.z.string().nullable().describe(
11727
+ "Original filename of the uploaded certificate PDF (null when no certificate is attached)"
11728
+ ),
11729
+ certificateFileUrl: zod.z.string().nullable().describe(
11730
+ "Direct URL to view or download the certificate PDF (null when no certificate is attached)"
11731
+ )
11490
11732
  });
11491
- var delay = (ms) => {
11492
- return new Promise((resolve) => setTimeout(resolve, ms));
11493
- };
11494
-
11495
- // ../../internal/utils/src/whois.ts
11496
- var whois_exports = {};
11497
- __export(whois_exports, {
11498
- extractWhoisCountry: () => extractWhoisCountry,
11499
- extractWhoisPayload: () => extractWhoisPayload,
11500
- normalizeRegistrar: () => normalizeRegistrar
11733
+ var brandItemSchema = zod.z.object({
11734
+ id: zod.z.number().describe("Brand ID"),
11735
+ slug: zod.z.string().describe("Brand slug (stable, URL-safe identifier)"),
11736
+ name: zod.z.string().describe("Display name"),
11737
+ type: zod.z.nativeEnum(BrandType).describe(
11738
+ "Brand type: `ORGANIZATION` for parent brands, `INDIVIDUAL` for employee or person brands, `PRODUCT` for a specific product or service offering"
11739
+ ),
11740
+ description: zod.z.string().nullable().describe("Free-form description, if set"),
11741
+ avatarUrl: zod.z.string().nullable().describe("URL of the brand's avatar / logo image"),
11742
+ websiteUrl: zod.z.string().nullable().describe("Official brand website URL"),
11743
+ twitterHandle: zod.z.string().nullable().describe("Official Twitter / X handle (without @)"),
11744
+ brandColors: zod.z.array(zod.z.string()).describe("HEX color strings associated with the brand (e.g. `#FF0000`)"),
11745
+ includedTerms: zod.z.array(zod.z.string()).describe("Terms that should be included when matching this brand"),
11746
+ excludedTerms: zod.z.array(zod.z.string()).describe("Terms that should be excluded when matching this brand"),
11747
+ tickers: zod.z.array(zod.z.string()).describe("Ticker symbols associated with the brand (e.g. `$JUP`)"),
11748
+ brandGroupId: zod.z.number().nullable().describe(
11749
+ "Group this brand belongs to (only set for `INDIVIDUAL` and `PRODUCT` brands)"
11750
+ ),
11751
+ createdAt: zod.z.date().describe("When the brand was created"),
11752
+ useOrganizationDocs: zod.z.boolean().describe(
11753
+ "When true, this brand inherits its Letter of Authorization and Power of Attorney from the organization rather than carrying its own. The `legalDocuments` block below always reflects the brand-level attachments \u2014 read `/user/orgs/{slug}` for the org-level fallbacks."
11754
+ ),
11755
+ legalDocuments: zod.z.object({
11756
+ letterOfAuthorization: brandLegalDocumentSchema,
11757
+ powerOfAttorney: brandLegalDocumentSchema
11758
+ }).describe("Brand-level Letter of Authorization and Power of Attorney attachments"),
11759
+ trademarkRegistrations: zod.z.array(brandTrademarkRegistrationSchema).describe(
11760
+ "Trademark registrations attached to this brand. An empty array means no trademarks are on file for the brand \u2014 use this to identify brands that still need them added."
11761
+ )
11501
11762
  });
11502
- function extractWhoisPayload(raw) {
11503
- var _a;
11504
- const first = Array.isArray(raw) ? (_a = raw.find((entry) => entry !== null && typeof entry === "object")) != null ? _a : {} : raw;
11505
- if (!first || typeof first !== "object") {
11506
- return {};
11507
- }
11508
- const maybeData = first.data;
11509
- if (maybeData && typeof maybeData === "object" && !Array.isArray(maybeData)) {
11510
- return maybeData;
11511
- }
11512
- return first;
11513
- }
11514
- var WHOIS_EMPTY_VALUES = /* @__PURE__ */ new Set(["", "none", "null"]);
11515
- var WHOIS_COUNTRY_CODE_KEY_ALIASES = /* @__PURE__ */ new Set(["countrycode", "registrantcountrycode"]);
11516
- var WHOIS_COUNTRY_KEY_ALIASES = /* @__PURE__ */ new Set([
11517
- "country",
11518
- "countryname",
11519
- "registrantcountry",
11520
- "registrantcountryname"
11521
- ]);
11522
- function normalizeWhoisKey(key) {
11523
- return key.toLowerCase().replace(/[^a-z0-9]/g, "");
11524
- }
11525
- function normalizeRegistrar(value) {
11526
- return value.toLowerCase().replace(/[^a-z0-9]/g, "");
11527
- }
11528
- function parseWhoisString(value) {
11529
- if (typeof value !== "string") {
11530
- return void 0;
11531
- }
11532
- const trimmedValue = value.trim();
11533
- if (WHOIS_EMPTY_VALUES.has(trimmedValue.toLowerCase())) {
11534
- return void 0;
11535
- }
11536
- return trimmedValue;
11537
- }
11538
- function extractWhoisFieldByAliases(payload, aliases) {
11539
- for (const [key, value] of Object.entries(payload)) {
11540
- if (!aliases.has(normalizeWhoisKey(key))) {
11541
- continue;
11542
- }
11543
- const parsedValue = parseWhoisString(value);
11544
- if (parsedValue) {
11545
- return parsedValue;
11546
- }
11547
- }
11548
- return void 0;
11549
- }
11550
- function extractWhoisCountry(payload) {
11551
- const countryCode = extractWhoisFieldByAliases(payload, WHOIS_COUNTRY_CODE_KEY_ALIASES);
11552
- const country = extractWhoisFieldByAliases(payload, WHOIS_COUNTRY_KEY_ALIASES);
11553
- return {
11554
- countryCode: countryCode != null ? countryCode : void 0,
11555
- country: country != null ? country : void 0
11556
- };
11557
- }
11558
-
11559
- // ../../internal/utils/src/safe-preview.ts
11560
- var safe_preview_exports = {};
11561
- __export(safe_preview_exports, {
11562
- buildSafePreviewUrl: () => buildSafePreviewUrl,
11563
- normalizeSafeNavigationTarget: () => normalizeSafeNavigationTarget
11763
+ zod.z.object({
11764
+ brands: zod.z.array(brandItemSchema).describe("List of brands")
11765
+ }).describe("Successful operation");
11766
+ var FILTERABLE_SUBSCRIPTION_STATUSES = [
11767
+ SubscriptionStatus.PROSPECT,
11768
+ SubscriptionStatus.POC,
11769
+ SubscriptionStatus.ACTIVE,
11770
+ SubscriptionStatus.INTEGRATION
11771
+ ];
11772
+ var UserOrgsSubscriptionStatusSchema = zod.z.enum(
11773
+ FILTERABLE_SUBSCRIPTION_STATUSES
11774
+ );
11775
+ var takedownsServiceFilterSchema = zod.z.object({
11776
+ active: zod.z.boolean().optional(),
11777
+ automated: zod.z.boolean().optional()
11778
+ }).optional();
11779
+ var singleServiceFilterSchema = zod.z.object({
11780
+ active: zod.z.boolean().optional()
11781
+ }).optional();
11782
+ var userOrgsServicesFilterObjectSchema = zod.z.object({
11783
+ reporting: singleServiceFilterSchema,
11784
+ reviewing: singleServiceFilterSchema,
11785
+ protection: singleServiceFilterSchema,
11786
+ takedowns: takedownsServiceFilterSchema,
11787
+ detection: singleServiceFilterSchema,
11788
+ darkWebMonitoring: singleServiceFilterSchema
11564
11789
  });
11565
- var SAFE_NAVIGATION_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
11566
- var PREVIEW_PATH = "/preview";
11567
- var URL_BASE = "https://app.chainpatrol.io";
11568
- function normalizeSafeNavigationTarget(target) {
11569
- const normalizedTarget = getNormalizedUrl(target);
11570
- if (!SAFE_NAVIGATION_PROTOCOLS.has(normalizedTarget.protocol)) {
11571
- throw new Error(`Unsupported URL protocol: ${normalizedTarget.protocol}`);
11572
- }
11573
- return normalizedTarget;
11574
- }
11575
- function buildSafePreviewUrl({
11576
- target,
11577
- assetId,
11578
- policy
11579
- }) {
11580
- const normalizedTarget = normalizeSafeNavigationTarget(target);
11581
- const previewUrl = new URL(PREVIEW_PATH, URL_BASE);
11582
- previewUrl.searchParams.set("target", normalizedTarget.toString());
11583
- if (Number.isInteger(assetId) && assetId && assetId >= 1) {
11584
- previewUrl.searchParams.set("asset_id", String(assetId));
11585
- }
11586
- if (policy) {
11587
- previewUrl.searchParams.set("policy", policy);
11588
- }
11589
- return `${previewUrl.pathname}?${previewUrl.searchParams.toString()}`;
11590
- }
11591
-
11592
- // ../../internal/utils/src/parse.ts
11593
- var parse_exports = {};
11594
- __export(parse_exports, {
11595
- parseTerms: () => parseTerms,
11596
- stringifyTerms: () => stringifyTerms
11790
+ var userOrgsObligatoryAdminApprovalFilterSchema = zod.z.object({
11791
+ active: zod.z.boolean().optional(),
11792
+ assetTypes: zod.z.array(zod.z.nativeEnum(AssetType)).min(1).optional()
11793
+ }).optional();
11794
+ var PendingApprovalServiceSchema = zod.z.enum(["protection", "takedowns"]);
11795
+ var userOrgsPendingServiceApprovalFilterSchema = zod.z.object({
11796
+ active: zod.z.boolean().optional(),
11797
+ services: zod.z.array(PendingApprovalServiceSchema).min(1).optional()
11798
+ }).optional();
11799
+ zod.z.object({
11800
+ query: zod.z.string().default(""),
11801
+ subscriptionStatus: zod.z.array(UserOrgsSubscriptionStatusSchema).min(1).optional(),
11802
+ services: userOrgsServicesFilterObjectSchema.optional(),
11803
+ obligatoryAdminApproval: userOrgsObligatoryAdminApprovalFilterSchema,
11804
+ pendingServiceApproval: userOrgsPendingServiceApprovalFilterSchema
11805
+ });
11806
+ var takedownsServiceSchema = zod.z.object({
11807
+ active: zod.z.boolean(),
11808
+ automated: zod.z.boolean()
11809
+ });
11810
+ var singleServiceSchema = zod.z.object({
11811
+ active: zod.z.boolean()
11812
+ });
11813
+ var UserOrgObligatoryAdminApprovalSchema = zod.z.object({
11814
+ active: zod.z.boolean(),
11815
+ assetTypes: zod.z.array(zod.z.nativeEnum(AssetType))
11816
+ });
11817
+ var PendingServiceApprovalSchema = zod.z.object({
11818
+ // Friendly service family, matching a key in the `services` object.
11819
+ service: PendingApprovalServiceSchema,
11820
+ // Whether the request is for the automated variant of the service
11821
+ // (e.g. "Automated Wallet Blocking" rather than "Wallet Blocking").
11822
+ automated: zod.z.boolean(),
11823
+ // Raw `ServiceType` enum value, e.g. "isProtectionActive". Lets callers
11824
+ // distinguish the exact column without re-deriving it from `service` +
11825
+ // `automated`.
11826
+ serviceType: zod.z.nativeEnum(ServiceType),
11827
+ // Human-readable service label, e.g. "Wallet Blocking".
11828
+ serviceName: zod.z.string(),
11829
+ // When the enable request was submitted (ISO 8601, UTC).
11830
+ requestedAt: zod.z.string()
11831
+ });
11832
+ var UserOrgIntegrationsSchema = zod.z.object({
11833
+ slack: zod.z.boolean(),
11834
+ discord: zod.z.boolean(),
11835
+ telegram: zod.z.object({
11836
+ connected: zod.z.boolean(),
11837
+ groupCount: zod.z.number()
11838
+ }),
11839
+ vercel: zod.z.boolean(),
11840
+ intercom: zod.z.boolean(),
11841
+ moderation: zod.z.boolean()
11597
11842
  });
11598
- function parseTerms(terms, {
11599
- forceExact = false
11600
- } = {}) {
11601
- if (!terms) return [];
11602
- return terms.split(",").map((term) => {
11603
- const trimmed = term.trim();
11604
- if (!trimmed) return null;
11605
- const isWrappedExact = trimmed.startsWith("*") && trimmed.endsWith("*") && trimmed.length > 2;
11606
- if (isWrappedExact) {
11607
- return {
11608
- value: trimmed.slice(1, -1).toLowerCase(),
11609
- type: "exact"
11610
- };
11611
- } else {
11612
- return {
11613
- value: trimmed.toLowerCase(),
11614
- type: forceExact ? "exact" : "loose"
11615
- };
11616
- }
11617
- }).filter((term) => term !== null);
11618
- }
11619
- function stringifyTerms(parsedTerms) {
11620
- return parsedTerms.map((term) => term.type === "exact" ? `*${term.value}*` : term.value).join(", ");
11621
- }
11622
-
11623
- // ../../internal/utils/src/brand-pattern.ts
11624
- var brand_pattern_exports = {};
11625
- __export(brand_pattern_exports, {
11626
- anyPatternMatches: () => anyPatternMatches,
11627
- compileBrandPattern: () => compileBrandPattern,
11628
- countPatternMatches: () => countPatternMatches,
11629
- findMatchingPatterns: () => findMatchingPatterns
11843
+ var UserOrgLegalDocumentSchema = zod.z.object({
11844
+ present: zod.z.boolean().describe("Whether the organization has this document attached"),
11845
+ fileName: zod.z.string().nullable().describe("Original filename of the uploaded document (null when not present)"),
11846
+ fileUrl: zod.z.string().nullable().describe("Direct URL to view or download the document (null when not present)")
11630
11847
  });
11631
- var DEFAULT_MAX_MATCHES = 50;
11632
- function compileBrandPattern(input) {
11633
- var _a;
11634
- try {
11635
- return new RegExp(input.pattern, (_a = input.flags) != null ? _a : void 0);
11636
- } catch (e4) {
11637
- return null;
11638
- }
11639
- }
11640
- function anyPatternMatches(content, patterns, kind) {
11641
- for (const input of patterns) {
11642
- if (input.kind !== kind) continue;
11643
- const regex = compileBrandPattern(input);
11644
- if (!regex) continue;
11645
- if (regex.test(content)) {
11646
- return true;
11647
- }
11648
- }
11649
- return false;
11650
- }
11651
- function findMatchingPatterns(content, patterns, kind) {
11652
- const matched = [];
11653
- for (const input of patterns) {
11654
- if (input.kind !== kind) continue;
11655
- const regex = compileBrandPattern(input);
11656
- if (!regex) continue;
11657
- if (regex.test(content)) {
11658
- matched.push(input);
11659
- }
11660
- }
11661
- return matched;
11662
- }
11663
- function countPatternMatches(content, pattern, maxMatches = DEFAULT_MAX_MATCHES) {
11664
- const compiled = compileBrandPattern(pattern);
11665
- if (!compiled) return 0;
11666
- const flags = compiled.flags.includes("g") ? compiled.flags : `${compiled.flags}g`;
11667
- const globalRegex = new RegExp(compiled.source, flags);
11668
- let count = 0;
11669
- let match2;
11670
- while ((match2 = globalRegex.exec(content)) !== null) {
11671
- count += 1;
11672
- if (count >= maxMatches) break;
11673
- if (match2[0].length === 0) globalRegex.lastIndex += 1;
11674
- }
11675
- return count;
11676
- }
11677
-
11678
- // ../../internal/utils/src/text.ts
11679
- var text_exports = {};
11680
- __export(text_exports, {
11681
- HOMOGLYPH_MAPPINGS: () => HOMOGLYPH_MAPPINGS,
11682
- LETTER_TO_HOMOGLYPH_MAPPINGS: () => LETTER_TO_HOMOGLYPH_MAPPINGS,
11683
- generateHomoglyphSearchTerms: () => generateHomoglyphSearchTerms,
11684
- normalizeHomoglyphs: () => normalizeHomoglyphs
11848
+ var UserOrgLegalDocumentsSchema = zod.z.object({
11849
+ letterOfAuthorization: UserOrgLegalDocumentSchema,
11850
+ powerOfAttorney: UserOrgLegalDocumentSchema
11685
11851
  });
11686
- var HOMOGLYPH_MAPPINGS = {
11687
- "0": "o",
11688
- "1": "i",
11689
- "3": "e",
11690
- "4": "a",
11691
- "5": "s",
11692
- "7": "t",
11693
- "8": "b"
11694
- };
11695
- var LETTER_TO_HOMOGLYPH_MAPPINGS = {
11696
- a: ["4", "\u0430"],
11697
- b: ["8", "6"],
11698
- c: ["\u0441"],
11699
- e: ["3", "\u0435"],
11700
- g: ["9"],
11701
- i: ["1", "l", "\u0456"],
11702
- l: ["1"],
11703
- o: ["0", "\u043E"],
11704
- s: ["5", "\u0455"],
11705
- t: ["7"],
11706
- x: ["\u0445"],
11707
- z: ["2"]
11708
- };
11709
- var DEFAULT_MAX_HOMOGLYPH_VARIANTS = 20;
11710
- function isCyrillic(char) {
11711
- return char.charCodeAt(0) > 127;
11712
- }
11713
- function buildReplacementOps(term) {
11714
- const ops = [];
11715
- for (let i = 0; i < term.length; i++) {
11716
- const homoglyphs = LETTER_TO_HOMOGLYPH_MAPPINGS[term[i]];
11717
- if (!homoglyphs) continue;
11718
- for (const replacement of homoglyphs) {
11719
- ops.push({ index: i, replacement });
11720
- }
11721
- }
11722
- return ops;
11723
- }
11724
- function applyOps(term, ops, selected) {
11725
- const chars = Array.from(term);
11726
- for (const idx of selected) {
11727
- chars[ops[idx].index] = ops[idx].replacement;
11728
- }
11729
- return chars.join("");
11730
- }
11731
- function generateCombinations(ops, opIndices, term, maxVariants, addFn, variants) {
11732
- const generate = (startIdx, depth, selected, usedPositions) => {
11733
- if (selected.length === depth) return addFn(applyOps(term, ops, selected));
11734
- for (let i = startIdx; i < opIndices.length && variants.length < maxVariants; i++) {
11735
- const opIdx = opIndices[i];
11736
- if (usedPositions.has(ops[opIdx].index)) continue;
11737
- selected.push(opIdx);
11738
- usedPositions.add(ops[opIdx].index);
11739
- if (generate(i + 1, depth, selected, usedPositions)) return true;
11740
- selected.pop();
11741
- usedPositions.delete(ops[opIdx].index);
11742
- }
11743
- return false;
11744
- };
11745
- for (let depth = 2; depth <= opIndices.length && variants.length < maxVariants; depth++) {
11746
- if (generate(0, depth, [], /* @__PURE__ */ new Set())) break;
11747
- }
11748
- }
11749
- function generateHomoglyphSearchTerms(term, maxVariants = DEFAULT_MAX_HOMOGLYPH_VARIANTS) {
11750
- if (term.length === 0 || maxVariants <= 0) return [];
11751
- const lowerTerm = term.toLowerCase();
11752
- const seen = /* @__PURE__ */ new Set();
11753
- const variants = [];
11754
- const add = (v) => {
11755
- if (v === lowerTerm || seen.has(v)) return false;
11756
- seen.add(v);
11757
- variants.push(v);
11758
- return variants.length >= maxVariants;
11759
- };
11760
- const allOps = buildReplacementOps(lowerTerm);
11761
- for (let i = 0; i < allOps.length && variants.length < maxVariants; i++) {
11762
- add(applyOps(lowerTerm, allOps, [i]));
11763
- }
11764
- if (variants.length < maxVariants) {
11765
- const cyrillicComposite = lowerTerm.split("").map((char) => {
11766
- var _a;
11767
- const homoglyphs = LETTER_TO_HOMOGLYPH_MAPPINGS[char];
11768
- return (_a = homoglyphs == null ? void 0 : homoglyphs.find((h) => isCyrillic(h))) != null ? _a : char;
11769
- }).join("");
11770
- add(cyrillicComposite);
11771
- }
11772
- const cyrillicOpIndices = allOps.map((op, i) => isCyrillic(op.replacement) ? i : -1).filter((i) => i >= 0);
11773
- if (variants.length < maxVariants && cyrillicOpIndices.length >= 2) {
11774
- generateCombinations(
11775
- allOps,
11776
- cyrillicOpIndices,
11777
- lowerTerm,
11778
- maxVariants,
11779
- add,
11780
- variants
11781
- );
11782
- }
11783
- if (variants.length < maxVariants) {
11784
- const allOpIndices = allOps.map((_, i) => i);
11785
- generateCombinations(allOps, allOpIndices, lowerTerm, maxVariants, add, variants);
11786
- }
11787
- return variants;
11788
- }
11789
- function normalizeHomoglyphs(text, customMappings = {}) {
11790
- const mappings = __spreadValues(__spreadValues({}, HOMOGLYPH_MAPPINGS), customMappings);
11791
- return text.toLowerCase().split("").map((char) => mappings[char] || char).join("");
11792
- }
11793
-
11794
- // ../../internal/utils/src/format.ts
11795
- var format_exports = {};
11796
- __export(format_exports, {
11797
- formatCompactNumber: () => formatCompactNumber,
11798
- formatFileSize: () => formatFileSize
11852
+ var UserOrgTrademarkRegistrationSchema = zod.z.object({
11853
+ id: zod.z.number().describe("Trademark registration ID"),
11854
+ brandName: zod.z.string().describe("Trademarked brand name as it appears on the registration"),
11855
+ trademarkOffice: zod.z.string().describe("Issuing trademark office (e.g. `USPTO`, `EUIPO`)"),
11856
+ registrationNumber: zod.z.string().describe("Registration number assigned by the office"),
11857
+ goodsAndServicesClass: zod.z.string().describe("Nice Classification class(es) the registration covers"),
11858
+ rightsOwnerName: zod.z.string().nullable().describe("Legal entity the trademark is registered to, if recorded"),
11859
+ registrationPageUrl: zod.z.string().nullable().describe("Public URL on the trademark office's site, if recorded"),
11860
+ certificateFileName: zod.z.string().nullable().describe(
11861
+ "Original filename of the uploaded certificate PDF (null when no certificate is attached)"
11862
+ ),
11863
+ certificateFileUrl: zod.z.string().nullable().describe(
11864
+ "Direct URL to view or download the certificate PDF (null when no certificate is attached)"
11865
+ )
11866
+ });
11867
+ var UserOrgBrandMetadataSchema = zod.z.object({
11868
+ websiteUrl: zod.z.string().nullable().describe("Public website URL of the brand (linked from the portal header)"),
11869
+ twitterHandle: zod.z.string().nullable().describe(
11870
+ "Public Twitter/X handle of the brand, stored with the leading `@` (e.g. `@acme`)"
11871
+ ),
11872
+ securityContactEmail: zod.z.string().nullable().describe(
11873
+ "Email address for security correspondence \u2014 used by takedown providers and researchers, distinct from the internal customer POC email"
11874
+ ),
11875
+ industry: zod.z.string().nullable().describe('Free-form industry label (e.g. "DeFi", "CEX", "NFT", "Wallet")')
11876
+ });
11877
+ var UserOrgPortalCustomizationSchema = zod.z.object({
11878
+ useCustomDetails: zod.z.boolean().describe(
11879
+ "When true, the portal uses `name`/`slug`/`avatarUrl` from this object instead of the org's own name/slug/avatar"
11880
+ ),
11881
+ name: zod.z.string().nullable().describe(
11882
+ "Custom display name shown on the portal (used only when `useCustomDetails=true`)"
11883
+ ),
11884
+ slug: zod.z.string().nullable().describe(
11885
+ "Custom URL slug (`chainpatrol.io/<slug>`) \u2014 takes precedence over the org's own slug when set, regardless of `useCustomDetails`"
11886
+ ),
11887
+ avatarUrl: zod.z.string().nullable().describe(
11888
+ "Custom avatar URL shown on the portal (used only when `useCustomDetails=true`)"
11889
+ ),
11890
+ bannerEnabled: zod.z.boolean().describe(
11891
+ "When true, the portal renders `bannerContent` as a highlighted banner at the top of the page"
11892
+ ),
11893
+ bannerContent: zod.z.string().nullable().describe(
11894
+ "Markdown body of the portal banner. Null (or empty) with `bannerEnabled=true` means the toggle is on but no content has been written yet"
11895
+ )
11896
+ });
11897
+ var UserOrgSchema = zod.z.object({
11898
+ id: zod.z.number(),
11899
+ name: zod.z.string(),
11900
+ slug: zod.z.string(),
11901
+ avatarUrl: zod.z.string().nullable(),
11902
+ contactUrl: zod.z.string().nullable(),
11903
+ subscriptionStatus: zod.z.nativeEnum(SubscriptionStatus),
11904
+ portalVisibility: zod.z.nativeEnum(OrganizationPortalVisibility).describe(
11905
+ "Visibility of the org's public security portal (chainpatrol.io/<slug>). `PUBLIC` is discoverable; `PRIVATE` renders only the report form (no metrics or listings); `DISABLED` returns a 404."
11906
+ ),
11907
+ reportVisibility: zod.z.nativeEnum(ReportVisibility).describe(
11908
+ "Whether the report listings on the public portal are visible to visitors. `PUBLIC` shows the org's reports; `PRIVATE` hides the report list even when the portal is discoverable."
11909
+ ),
11910
+ metricsVisibility: zod.z.nativeEnum(MetricsVisibility).describe(
11911
+ "Whether the metrics/threats-blocked stats render on the public portal. `PUBLIC` shows the metrics tab; `PRIVATE` hides it from anonymous visitors; `DISABLED` doesn't compute metrics at all."
11912
+ ),
11913
+ brandMetadata: UserOrgBrandMetadataSchema.describe(
11914
+ "Public brand-facing metadata (website, twitter, security contact, industry) shown on the portal and used by staff for outbound"
11915
+ ),
11916
+ portalCustomization: UserOrgPortalCustomizationSchema.describe(
11917
+ "Customer-configurable presentation of the public security portal \u2014 custom name/slug/avatar and the banner content"
11918
+ ),
11919
+ services: zod.z.object({
11920
+ reporting: singleServiceSchema,
11921
+ reviewing: singleServiceSchema,
11922
+ protection: singleServiceSchema,
11923
+ takedowns: takedownsServiceSchema,
11924
+ detection: singleServiceSchema,
11925
+ darkWebMonitoring: singleServiceSchema
11926
+ }),
11927
+ integrations: UserOrgIntegrationsSchema,
11928
+ obligatoryAdminApproval: UserOrgObligatoryAdminApprovalSchema,
11929
+ pendingServiceApprovals: zod.z.array(PendingServiceApprovalSchema),
11930
+ legalDocuments: UserOrgLegalDocumentsSchema.describe(
11931
+ "Org-level Letter of Authorization and Power of Attorney attachments"
11932
+ ),
11933
+ trademarkRegistrations: zod.z.array(UserOrgTrademarkRegistrationSchema).describe(
11934
+ "Org-level trademark registrations attached to the organization. An empty array means no trademarks are on file \u2014 use this to identify customers who still need to add them."
11935
+ )
11799
11936
  });
11800
- function formatCompactNumber(num3, options = {}) {
11801
- const { decimals = 1, fallback = "-" } = options;
11802
- if (num3 === void 0 || num3 === null) {
11803
- return fallback;
11804
- }
11805
- if (num3 >= 1e9) {
11806
- return `${(num3 / 1e9).toFixed(decimals)}B`;
11807
- }
11808
- if (num3 >= 1e6) {
11809
- return `${(num3 / 1e6).toFixed(decimals)}M`;
11810
- }
11811
- if (num3 >= 1e3) {
11812
- return `${(num3 / 1e3).toFixed(decimals)}K`;
11813
- }
11814
- return num3.toString();
11815
- }
11816
- function formatFileSize(bytes, options = {}) {
11817
- const { decimals = 1, binary = true, showUnknown = true } = options;
11818
- if (bytes === null || bytes === void 0 || bytes === "") {
11819
- return showUnknown ? "Unknown" : "0 B";
11820
- }
11821
- const size = typeof bytes === "string" ? parseInt(bytes, 10) : bytes;
11822
- if (isNaN(size) || size < 0) {
11823
- return showUnknown ? "Unknown" : "0 B";
11824
- }
11825
- if (size === 0) {
11826
- return "0 B";
11827
- }
11828
- const unit = binary ? 1024 : 1e3;
11829
- const units = binary ? ["B", "KB", "MB", "GB", "TB", "PB"] : ["B", "kB", "MB", "GB", "TB", "PB"];
11830
- const unitIndex = Math.floor(Math.log(size) / Math.log(unit));
11831
- const finalUnitIndex = Math.min(unitIndex, units.length - 1);
11832
- const value = size / Math.pow(unit, finalUnitIndex);
11833
- if (finalUnitIndex === 0) {
11834
- return `${size} B`;
11835
- }
11836
- return `${value.toFixed(decimals)} ${units[finalUnitIndex]}`;
11837
- }
11838
-
11839
- // ../../internal/utils/src/social-profile-url.ts
11840
- var social_profile_url_exports = {};
11841
- __export(social_profile_url_exports, {
11842
- LINKEDIN_PROFILE_URL_PATTERN: () => LINKEDIN_PROFILE_URL_PATTERN,
11843
- TWITTER_PROFILE_URL_PATTERN: () => TWITTER_PROFILE_URL_PATTERN,
11844
- isLinkedInProfileUrl: () => isLinkedInProfileUrl,
11845
- isSupportedSocialProfileUrl: () => isSupportedSocialProfileUrl,
11846
- isTwitterProfileUrl: () => isTwitterProfileUrl,
11847
- parseLinkedInProfileUrl: () => parseLinkedInProfileUrl
11937
+ zod.z.object({
11938
+ organizations: zod.z.array(UserOrgSchema)
11848
11939
  });
11849
- var TWITTER_PROFILE_URL_PATTERN = /^https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/?#]+\/?(?:[?#].*)?$/i;
11850
- var LINKEDIN_PROFILE_URL_PATTERN = /^https?:\/\/(?:[a-z]{2,3}\.)?linkedin\.com\/(in|company|school)\/([^/?#]+)/i;
11851
- function isTwitterProfileUrl(url) {
11852
- return TWITTER_PROFILE_URL_PATTERN.test(url);
11853
- }
11854
- function isLinkedInProfileUrl(url) {
11855
- return LINKEDIN_PROFILE_URL_PATTERN.test(url);
11856
- }
11857
- function isSupportedSocialProfileUrl(url) {
11858
- return isTwitterProfileUrl(url) || isLinkedInProfileUrl(url);
11859
- }
11860
- function humanizeLinkedInHandle(handle) {
11861
- const withoutTrailingDigits = handle.replace(/-[0-9a-f]{6,}$/i, "");
11862
- return withoutTrailingDigits.split("-").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
11863
- }
11864
- function parseLinkedInProfileUrl(url) {
11865
- var _a;
11866
- const match2 = url.match(LINKEDIN_PROFILE_URL_PATTERN);
11867
- if (!match2) return null;
11868
- const pathSegment = (_a = match2[1]) == null ? void 0 : _a.toLowerCase();
11869
- const rawHandle = match2[2];
11870
- if (!pathSegment || !rawHandle) return null;
11871
- let handle;
11940
+
11941
+ // ../../internal/validation/src/public/organization/metrics-get.ts
11942
+ var organizationMetricsIncludeFieldSchema = zod.z.enum([
11943
+ "reports",
11944
+ "newThreats",
11945
+ "threatsWatchlisted",
11946
+ "takedownsFiled",
11947
+ "takedownsCompleted",
11948
+ "domainThreats",
11949
+ "twitterThreats",
11950
+ "telegramThreats",
11951
+ "otherThreats",
11952
+ "blockedByType",
11953
+ "blockedByDay"
11954
+ ]);
11955
+ organizationMetricsIncludeFieldSchema.options;
11956
+ var ORGANIZATION_METRICS_MAX_SLUGS = 500;
11957
+ var organizationMetricsServicesFilterSchema = zod.z.preprocess((value) => {
11958
+ if (typeof value !== "string") return value;
11872
11959
  try {
11873
- handle = decodeURIComponent(rawHandle).trim();
11960
+ return JSON.parse(value);
11874
11961
  } catch (e4) {
11875
- return null;
11962
+ return value;
11876
11963
  }
11877
- if (!handle) return null;
11878
- const name = humanizeLinkedInHandle(handle) || handle;
11879
- const profileUrl = `https://www.linkedin.com/${pathSegment}/${handle}`;
11880
- return { pathSegment, handle, name, profileUrl };
11881
- }
11882
-
11883
- // ../../internal/validation/src/public/report/create.ts
11964
+ }, userOrgsServicesFilterObjectSchema).optional();
11965
+ zod.z.object({
11966
+ organizationSlug: zod.z.string().optional().describe(
11967
+ "Organization slug. Required when authenticating with a user session (Bearer token) and `slugs`/`allMyOrgs` are not supplied; ignored when using an org-scoped API key (org is derived from the key). Mutually exclusive with `slugs` and `allMyOrgs`."
11968
+ ),
11969
+ slugs: zod.z.array(zod.z.string()).max(ORGANIZATION_METRICS_MAX_SLUGS).optional().describe(
11970
+ "Multi-org form. Each slug is auth-checked individually (org-scoped API keys may only pass their own org; sessions and user API keys must have membership or staff role per slug). When supplied with more than one slug, the response includes a `perOrg` breakdown plus `metrics` rolled up across all of them. Capped at " + String(ORGANIZATION_METRICS_MAX_SLUGS) + " slugs per call. Mutually exclusive with `organizationSlug` and `allMyOrgs`."
11971
+ ),
11972
+ allMyOrgs: zod.z.preprocess((value) => {
11973
+ if (value === "true") return true;
11974
+ if (value === "false") return false;
11975
+ return value;
11976
+ }, zod.z.boolean()).optional().describe(
11977
+ "Shortcut for 'every org the caller is authorized to read'. Reuses the same filter logic as `/user/orgs`: org-scoped API keys are rejected (they're pinned to one org \u2014 use the default form); user API keys / Bearer sessions resolve to the user's memberships (or every active org for staff). Combine with `subscriptionStatus` and `services` to narrow (e.g. only paying customers with takedowns enabled). The resolved org set is still capped at " + String(ORGANIZATION_METRICS_MAX_SLUGS) + " and a 413 is returned if exceeded. Mutually exclusive with `organizationSlug`, `slugs`, and `brandSlug`."
11978
+ ),
11979
+ subscriptionStatus: zod.z.array(UserOrgsSubscriptionStatusSchema).min(1).optional().describe(
11980
+ "Only meaningful with `allMyOrgs: true`. Defaults to the same set `/user/orgs` uses (ACTIVE/POC/PROSPECT/INTEGRATION \u2014 INACTIVE is always excluded)."
11981
+ ),
11982
+ services: organizationMetricsServicesFilterSchema.describe(
11983
+ "Only meaningful with `allMyOrgs: true`. Same shape as `/user/orgs`'s `services` filter \u2014 every service accepts `{ active }`, and **only `takedowns` additionally accepts `automated`** (the one service where manual-vs-automated changes real platform behavior). E.g. `{ takedowns: { active: true, automated: false } }` for 'orgs with takedowns enabled but automation off'."
11984
+ ),
11985
+ brandSlug: zod.z.string().optional(),
11986
+ startDate: zod.z.coerce.date().optional(),
11987
+ endDate: zod.z.coerce.date().optional(),
11988
+ include: zod.z.array(organizationMetricsIncludeFieldSchema).optional().describe(
11989
+ "Subset of metrics to compute. When omitted or empty, every metric is computed (legacy behavior). Each value in `include` costs roughly one Prisma aggregate, so narrow the list when an agent only needs a couple of numbers \u2014 this is the main lever for keeping big-org calls inside the 30s function cap. Fields not in `include` come back as `null`."
11990
+ )
11991
+ }).refine(
11992
+ (value) => {
11993
+ const explicitForms = [
11994
+ Boolean(value.organizationSlug),
11995
+ Boolean(value.slugs && value.slugs.length > 0),
11996
+ Boolean(value.allMyOrgs)
11997
+ ].filter(Boolean).length;
11998
+ return explicitForms <= 1;
11999
+ },
12000
+ {
12001
+ message: "Pass at most one of `organizationSlug`, `slugs`, or `allMyOrgs`.",
12002
+ path: ["allMyOrgs"]
12003
+ }
12004
+ ).refine((value) => !(value.brandSlug && value.slugs && value.slugs.length > 1), {
12005
+ message: "`brandSlug` is only valid alongside a single organization, not `slugs`.",
12006
+ path: ["brandSlug"]
12007
+ }).refine((value) => !(value.brandSlug && value.allMyOrgs), {
12008
+ message: "`brandSlug` is only valid for a single org, not `allMyOrgs`.",
12009
+ path: ["brandSlug"]
12010
+ });
12011
+ var metricValue = zod.z.number().nullable();
12012
+ var metricsObjectSchema = zod.z.object({
12013
+ reports: metricValue,
12014
+ newThreats: metricValue,
12015
+ threatsWatchlisted: metricValue,
12016
+ takedownsFiled: metricValue,
12017
+ takedownsCompleted: metricValue,
12018
+ domainThreats: metricValue,
12019
+ twitterThreats: metricValue,
12020
+ telegramThreats: metricValue,
12021
+ otherThreats: metricValue
12022
+ });
12023
+ var blockedByTypeSchema = zod.z.array(
12024
+ zod.z.object({
12025
+ type: zod.z.string(),
12026
+ count: zod.z.number()
12027
+ })
12028
+ ).nullable();
12029
+ var blockedByDaySchema = zod.z.array(
12030
+ zod.z.object({
12031
+ date: zod.z.string(),
12032
+ count: zod.z.number()
12033
+ })
12034
+ ).nullable();
12035
+ zod.z.object({
12036
+ /**
12037
+ * Aggregate metrics. For single-org callers this is just that org's
12038
+ * numbers; for multi-org callers (`slugs.length > 1` or `allMyOrgs`)
12039
+ * it is the sum across all queried orgs.
12040
+ */
12041
+ metrics: metricsObjectSchema,
12042
+ blockedByType: blockedByTypeSchema,
12043
+ blockedByDay: blockedByDaySchema,
12044
+ /**
12045
+ * Derived averages over the time window (and, in multi-org mode,
12046
+ * across orgs). `perDay = metrics / windowDays`. In multi-org mode
12047
+ * `perOrgPerDay = metrics / numOrgs / windowDays`; in single-org
12048
+ * mode it is `null`. Counts are floats here — the underlying
12049
+ * `metrics` fields stay integer counts.
12050
+ */
12051
+ averages: zod.z.object({
12052
+ perDay: metricsObjectSchema.nullable(),
12053
+ perOrgPerDay: metricsObjectSchema.nullable(),
12054
+ windowDays: zod.z.number().nullable()
12055
+ }),
12056
+ /**
12057
+ * Per-org breakdown. Only populated in multi-org mode; `null` for
12058
+ * single-org callers.
12059
+ */
12060
+ perOrg: zod.z.record(
12061
+ zod.z.string(),
12062
+ zod.z.object({
12063
+ metrics: metricsObjectSchema,
12064
+ blockedByType: blockedByTypeSchema,
12065
+ blockedByDay: blockedByDaySchema
12066
+ })
12067
+ ).nullable(),
12068
+ /**
12069
+ * Echoes the actual orgs the response covers, in the order they
12070
+ * were resolved. Single-org responses always have length 1. The
12071
+ * `resolvedFrom` field distinguishes how the caller asked for the
12072
+ * scope (useful for agent reporting).
12073
+ */
12074
+ scope: zod.z.object({
12075
+ mode: zod.z.enum(["single", "multi"]),
12076
+ orgs: zod.z.array(zod.z.string()),
12077
+ resolvedFrom: zod.z.enum(["api-key", "organizationSlug", "slugs", "allMyOrgs"])
12078
+ })
12079
+ });
11884
12080
  var BASE_64_PATTERN = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
11885
12081
  var PHONE_COUNTRY_CODE_ERROR_MESSAGE = "Phone numbers must include a country code in E.164 format (for example, +14155552671).";
11886
12082
  function isPhoneNumberMissingCountryCode(value) {
@@ -13201,20 +13397,20 @@ var convertA98ToXyz65_default = convertA98ToXyz65;
13201
13397
 
13202
13398
  // ../../node_modules/culori/src/a98/convertXyz65ToA98.js
13203
13399
  var gamma = (v) => Math.pow(Math.abs(v), 256 / 563) * Math.sign(v);
13204
- var convertXyz65ToA98 = ({ x, y, z: z50, alpha }) => {
13400
+ var convertXyz65ToA98 = ({ x, y, z: z54, alpha }) => {
13205
13401
  if (x === void 0) x = 0;
13206
13402
  if (y === void 0) y = 0;
13207
- if (z50 === void 0) z50 = 0;
13403
+ if (z54 === void 0) z54 = 0;
13208
13404
  let res = {
13209
13405
  mode: "a98",
13210
13406
  r: gamma(
13211
- x * 2.0415879038107465 - y * 0.5650069742788597 - 0.3447313507783297 * z50
13407
+ x * 2.0415879038107465 - y * 0.5650069742788597 - 0.3447313507783297 * z54
13212
13408
  ),
13213
13409
  g: gamma(
13214
- x * -0.9692436362808798 + y * 1.8759675015077206 + 0.0415550574071756 * z50
13410
+ x * -0.9692436362808798 + y * 1.8759675015077206 + 0.0415550574071756 * z54
13215
13411
  ),
13216
13412
  b: gamma(
13217
- x * 0.0134442806320312 - y * 0.1183623922310184 + 1.0151749943912058 * z50
13413
+ x * 0.0134442806320312 - y * 0.1183623922310184 + 1.0151749943912058 * z54
13218
13414
  )
13219
13415
  };
13220
13416
  if (alpha !== void 0) {
@@ -13281,14 +13477,14 @@ var convertLrgbToRgb = ({ r, g, b, alpha }, mode = "rgb") => {
13281
13477
  var convertLrgbToRgb_default = convertLrgbToRgb;
13282
13478
 
13283
13479
  // ../../node_modules/culori/src/xyz65/convertXyz65ToRgb.js
13284
- var convertXyz65ToRgb = ({ x, y, z: z50, alpha }) => {
13480
+ var convertXyz65ToRgb = ({ x, y, z: z54, alpha }) => {
13285
13481
  if (x === void 0) x = 0;
13286
13482
  if (y === void 0) y = 0;
13287
- if (z50 === void 0) z50 = 0;
13483
+ if (z54 === void 0) z54 = 0;
13288
13484
  let res = convertLrgbToRgb_default({
13289
- r: x * 3.2409699419045226 - y * 1.537383177570094 - 0.4986107602930034 * z50,
13290
- g: x * -0.9692436362808796 + y * 1.8759675015077204 + 0.0415550574071756 * z50,
13291
- b: x * 0.0556300796969936 - y * 0.2039769588889765 + 1.0569715142428784 * z50
13485
+ r: x * 3.2409699419045226 - y * 1.537383177570094 - 0.4986107602930034 * z54,
13486
+ g: x * -0.9692436362808796 + y * 1.8759675015077204 + 0.0415550574071756 * z54,
13487
+ b: x * 0.0556300796969936 - y * 0.2039769588889765 + 1.0569715142428784 * z54
13292
13488
  });
13293
13489
  if (alpha !== void 0) {
13294
13490
  res.alpha = alpha;
@@ -13538,13 +13734,13 @@ var convertLab65ToRgb_default = convertLab65ToRgb;
13538
13734
 
13539
13735
  // ../../node_modules/culori/src/lab65/convertXyz65ToLab65.js
13540
13736
  var f = (value) => value > e ? Math.cbrt(value) : (k * value + 16) / 116;
13541
- var convertXyz65ToLab65 = ({ x, y, z: z50, alpha }) => {
13737
+ var convertXyz65ToLab65 = ({ x, y, z: z54, alpha }) => {
13542
13738
  if (x === void 0) x = 0;
13543
13739
  if (y === void 0) y = 0;
13544
- if (z50 === void 0) z50 = 0;
13740
+ if (z54 === void 0) z54 = 0;
13545
13741
  let f0 = f(x / D65.X);
13546
13742
  let f1 = f(y / D65.Y);
13547
- let f22 = f(z50 / D65.Z);
13743
+ let f22 = f(z54 / D65.Z);
13548
13744
  let res = {
13549
13745
  mode: "lab65",
13550
13746
  l: 116 * f1 - 16,
@@ -14201,10 +14397,10 @@ var convertItpToXyz65_default = convertItpToXyz65;
14201
14397
 
14202
14398
  // ../../node_modules/culori/src/itp/convertXyz65ToItp.js
14203
14399
  var toAbs = (c2 = 0) => Math.max(c2 * YW, 0);
14204
- var convertXyz65ToItp = ({ x, y, z: z50, alpha }) => {
14400
+ var convertXyz65ToItp = ({ x, y, z: z54, alpha }) => {
14205
14401
  const absX = toAbs(x);
14206
14402
  const absY = toAbs(y);
14207
- const absZ = toAbs(z50);
14403
+ const absZ = toAbs(z54);
14208
14404
  const l2 = transferPqEncode(
14209
14405
  0.3592832590121217 * absX + 0.6976051147779502 * absY - 0.0358915932320289 * absZ
14210
14406
  );
@@ -14262,15 +14458,15 @@ var jabPqEncode = (v) => {
14262
14458
  return Math.pow((C1 + C2 * vn3) / (1 + C3 * vn3), p);
14263
14459
  };
14264
14460
  var abs = (v = 0) => Math.max(v * 203, 0);
14265
- var convertXyz65ToJab = ({ x, y, z: z50, alpha }) => {
14461
+ var convertXyz65ToJab = ({ x, y, z: z54, alpha }) => {
14266
14462
  x = abs(x);
14267
14463
  y = abs(y);
14268
- z50 = abs(z50);
14269
- let xp = 1.15 * x - 0.15 * z50;
14464
+ z54 = abs(z54);
14465
+ let xp = 1.15 * x - 0.15 * z54;
14270
14466
  let yp = 0.66 * y + 0.34 * x;
14271
- let l2 = jabPqEncode(0.41478972 * xp + 0.579999 * yp + 0.014648 * z50);
14272
- let m = jabPqEncode(-0.20151 * xp + 1.120649 * yp + 0.0531008 * z50);
14273
- let s2 = jabPqEncode(-0.0166008 * xp + 0.2648 * yp + 0.6684799 * z50);
14467
+ let l2 = jabPqEncode(0.41478972 * xp + 0.579999 * yp + 0.014648 * z54);
14468
+ let m = jabPqEncode(-0.20151 * xp + 1.120649 * yp + 0.0531008 * z54);
14469
+ let s2 = jabPqEncode(-0.0166008 * xp + 0.2648 * yp + 0.6684799 * z54);
14274
14470
  let i = (l2 + m) / 2;
14275
14471
  let res = {
14276
14472
  mode: "jab",
@@ -14456,14 +14652,14 @@ var convertLabToXyz50 = ({ l: l2, a, b, alpha }) => {
14456
14652
  var convertLabToXyz50_default = convertLabToXyz50;
14457
14653
 
14458
14654
  // ../../node_modules/culori/src/xyz50/convertXyz50ToRgb.js
14459
- var convertXyz50ToRgb = ({ x, y, z: z50, alpha }) => {
14655
+ var convertXyz50ToRgb = ({ x, y, z: z54, alpha }) => {
14460
14656
  if (x === void 0) x = 0;
14461
14657
  if (y === void 0) y = 0;
14462
- if (z50 === void 0) z50 = 0;
14658
+ if (z54 === void 0) z54 = 0;
14463
14659
  let res = convertLrgbToRgb_default({
14464
- r: x * 3.1341359569958707 - y * 1.6173863321612538 - 0.4906619460083532 * z50,
14465
- g: x * -0.978795502912089 + y * 1.916254567259524 + 0.03344273116131949 * z50,
14466
- b: x * 0.07195537988411677 - y * 0.2289768264158322 + 1.405386058324125 * z50
14660
+ r: x * 3.1341359569958707 - y * 1.6173863321612538 - 0.4906619460083532 * z54,
14661
+ g: x * -0.978795502912089 + y * 1.916254567259524 + 0.03344273116131949 * z54,
14662
+ b: x * 0.07195537988411677 - y * 0.2289768264158322 + 1.405386058324125 * z54
14467
14663
  });
14468
14664
  if (alpha !== void 0) {
14469
14665
  res.alpha = alpha;
@@ -14494,13 +14690,13 @@ var convertRgbToXyz50_default = convertRgbToXyz50;
14494
14690
 
14495
14691
  // ../../node_modules/culori/src/lab/convertXyz50ToLab.js
14496
14692
  var f2 = (value) => value > e3 ? Math.cbrt(value) : (k3 * value + 16) / 116;
14497
- var convertXyz50ToLab = ({ x, y, z: z50, alpha }) => {
14693
+ var convertXyz50ToLab = ({ x, y, z: z54, alpha }) => {
14498
14694
  if (x === void 0) x = 0;
14499
14695
  if (y === void 0) y = 0;
14500
- if (z50 === void 0) z50 = 0;
14696
+ if (z54 === void 0) z54 = 0;
14501
14697
  let f0 = f2(x / D50.X);
14502
14698
  let f1 = f2(y / D50.Y);
14503
- let f22 = f2(z50 / D50.Z);
14699
+ let f22 = f2(z54 / D50.Z);
14504
14700
  let res = {
14505
14701
  mode: "lab",
14506
14702
  l: 116 * f1 - 16,
@@ -14735,18 +14931,18 @@ var convertLchuvToLuv = ({ l: l2, c: c2, h, alpha }) => {
14735
14931
  var convertLchuvToLuv_default = convertLchuvToLuv;
14736
14932
 
14737
14933
  // ../../node_modules/culori/src/luv/convertXyz50ToLuv.js
14738
- var u_fn = (x, y, z50) => 4 * x / (x + 15 * y + 3 * z50);
14739
- var v_fn = (x, y, z50) => 9 * y / (x + 15 * y + 3 * z50);
14934
+ var u_fn = (x, y, z54) => 4 * x / (x + 15 * y + 3 * z54);
14935
+ var v_fn = (x, y, z54) => 9 * y / (x + 15 * y + 3 * z54);
14740
14936
  var un = u_fn(D50.X, D50.Y, D50.Z);
14741
14937
  var vn = v_fn(D50.X, D50.Y, D50.Z);
14742
14938
  var l_fn = (value) => value <= e3 ? k3 * value : 116 * Math.cbrt(value) - 16;
14743
- var convertXyz50ToLuv = ({ x, y, z: z50, alpha }) => {
14939
+ var convertXyz50ToLuv = ({ x, y, z: z54, alpha }) => {
14744
14940
  if (x === void 0) x = 0;
14745
14941
  if (y === void 0) y = 0;
14746
- if (z50 === void 0) z50 = 0;
14942
+ if (z54 === void 0) z54 = 0;
14747
14943
  let l2 = l_fn(y / D50.Y);
14748
- let u = u_fn(x, y, z50);
14749
- let v = v_fn(x, y, z50);
14944
+ let u = u_fn(x, y, z54);
14945
+ let v = v_fn(x, y, z54);
14750
14946
  if (!isFinite(u) || !isFinite(v)) {
14751
14947
  l2 = u = v = 0;
14752
14948
  } else {
@@ -14767,8 +14963,8 @@ var convertXyz50ToLuv = ({ x, y, z: z50, alpha }) => {
14767
14963
  var convertXyz50ToLuv_default = convertXyz50ToLuv;
14768
14964
 
14769
14965
  // ../../node_modules/culori/src/luv/convertLuvToXyz50.js
14770
- var u_fn2 = (x, y, z50) => 4 * x / (x + 15 * y + 3 * z50);
14771
- var v_fn2 = (x, y, z50) => 9 * y / (x + 15 * y + 3 * z50);
14966
+ var u_fn2 = (x, y, z54) => 4 * x / (x + 15 * y + 3 * z54);
14967
+ var v_fn2 = (x, y, z54) => 9 * y / (x + 15 * y + 3 * z54);
14772
14968
  var un2 = u_fn2(D50.X, D50.Y, D50.Z);
14773
14969
  var vn2 = v_fn2(D50.X, D50.Y, D50.Z);
14774
14970
  var convertLuvToXyz50 = ({ l: l2, u, v, alpha }) => {
@@ -14782,8 +14978,8 @@ var convertLuvToXyz50 = ({ l: l2, u, v, alpha }) => {
14782
14978
  let vp = v / (13 * l2) + vn2;
14783
14979
  let y = D50.Y * (l2 <= 8 ? l2 / k3 : Math.pow((l2 + 16) / 116, 3));
14784
14980
  let x = y * (9 * up) / (4 * vp);
14785
- let z50 = y * (12 - 3 * up - 20 * vp) / (4 * vp);
14786
- let res = { mode: "xyz50", x, y, z: z50 };
14981
+ let z54 = y * (12 - 3 * up - 20 * vp) / (4 * vp);
14982
+ let res = { mode: "xyz50", x, y, z: z54 };
14787
14983
  if (alpha !== void 0) {
14788
14984
  res.alpha = alpha;
14789
14985
  }
@@ -15400,15 +15596,15 @@ var convertP3ToXyz65 = (rgb2) => {
15400
15596
  var convertP3ToXyz65_default = convertP3ToXyz65;
15401
15597
 
15402
15598
  // ../../node_modules/culori/src/p3/convertXyz65ToP3.js
15403
- var convertXyz65ToP3 = ({ x, y, z: z50, alpha }) => {
15599
+ var convertXyz65ToP3 = ({ x, y, z: z54, alpha }) => {
15404
15600
  if (x === void 0) x = 0;
15405
15601
  if (y === void 0) y = 0;
15406
- if (z50 === void 0) z50 = 0;
15602
+ if (z54 === void 0) z54 = 0;
15407
15603
  let res = convertLrgbToRgb_default(
15408
15604
  {
15409
- r: x * 2.4934969119414263 - y * 0.9313836179191242 - 0.402710784450717 * z50,
15410
- g: x * -0.8294889695615749 + y * 1.7626640603183465 + 0.0236246858419436 * z50,
15411
- b: x * 0.0358458302437845 - y * 0.0761723892680418 + 0.9568845240076871 * z50
15605
+ r: x * 2.4934969119414263 - y * 0.9313836179191242 - 0.402710784450717 * z54,
15606
+ g: x * -0.8294889695615749 + y * 1.7626640603183465 + 0.0236246858419436 * z54,
15607
+ b: x * 0.0358458302437845 - y * 0.0761723892680418 + 0.9568845240076871 * z54
15412
15608
  },
15413
15609
  "p3"
15414
15610
  );
@@ -15443,19 +15639,19 @@ var gamma2 = (v) => {
15443
15639
  }
15444
15640
  return 16 * v;
15445
15641
  };
15446
- var convertXyz50ToProphoto = ({ x, y, z: z50, alpha }) => {
15642
+ var convertXyz50ToProphoto = ({ x, y, z: z54, alpha }) => {
15447
15643
  if (x === void 0) x = 0;
15448
15644
  if (y === void 0) y = 0;
15449
- if (z50 === void 0) z50 = 0;
15645
+ if (z54 === void 0) z54 = 0;
15450
15646
  let res = {
15451
15647
  mode: "prophoto",
15452
15648
  r: gamma2(
15453
- x * 1.3457868816471585 - y * 0.2555720873797946 - 0.0511018649755453 * z50
15649
+ x * 1.3457868816471585 - y * 0.2555720873797946 - 0.0511018649755453 * z54
15454
15650
  ),
15455
15651
  g: gamma2(
15456
- x * -0.5446307051249019 + y * 1.5082477428451466 + 0.0205274474364214 * z50
15652
+ x * -0.5446307051249019 + y * 1.5082477428451466 + 0.0205274474364214 * z54
15457
15653
  ),
15458
- b: gamma2(x * 0 + y * 0 + 1.2119675456389452 * z50)
15654
+ b: gamma2(x * 0 + y * 0 + 1.2119675456389452 * z54)
15459
15655
  };
15460
15656
  if (alpha !== void 0) {
15461
15657
  res.alpha = alpha;
@@ -15515,20 +15711,20 @@ var gamma3 = (v) => {
15515
15711
  }
15516
15712
  return 4.5 * v;
15517
15713
  };
15518
- var convertXyz65ToRec2020 = ({ x, y, z: z50, alpha }) => {
15714
+ var convertXyz65ToRec2020 = ({ x, y, z: z54, alpha }) => {
15519
15715
  if (x === void 0) x = 0;
15520
15716
  if (y === void 0) y = 0;
15521
- if (z50 === void 0) z50 = 0;
15717
+ if (z54 === void 0) z54 = 0;
15522
15718
  let res = {
15523
15719
  mode: "rec2020",
15524
15720
  r: gamma3(
15525
- x * 1.7166511879712683 - y * 0.3556707837763925 - 0.2533662813736599 * z50
15721
+ x * 1.7166511879712683 - y * 0.3556707837763925 - 0.2533662813736599 * z54
15526
15722
  ),
15527
15723
  g: gamma3(
15528
- x * -0.6666843518324893 + y * 1.6164812366349395 + 0.0157685458139111 * z50
15724
+ x * -0.6666843518324893 + y * 1.6164812366349395 + 0.0157685458139111 * z54
15529
15725
  ),
15530
15726
  b: gamma3(
15531
- x * 0.0176398574453108 - y * 0.0427706132578085 + 0.9421031212354739 * z50
15727
+ x * 0.0176398574453108 - y * 0.0427706132578085 + 0.9421031212354739 * z54
15532
15728
  )
15533
15729
  };
15534
15730
  if (alpha !== void 0) {
@@ -15681,15 +15877,15 @@ var definition_default26 = definition26;
15681
15877
 
15682
15878
  // ../../node_modules/culori/src/xyz65/convertXyz65ToXyz50.js
15683
15879
  var convertXyz65ToXyz50 = (xyz652) => {
15684
- let { x, y, z: z50, alpha } = xyz652;
15880
+ let { x, y, z: z54, alpha } = xyz652;
15685
15881
  if (x === void 0) x = 0;
15686
15882
  if (y === void 0) y = 0;
15687
- if (z50 === void 0) z50 = 0;
15883
+ if (z54 === void 0) z54 = 0;
15688
15884
  let res = {
15689
15885
  mode: "xyz50",
15690
- x: 1.0479298208405488 * x + 0.0229467933410191 * y - 0.0501922295431356 * z50,
15691
- y: 0.0296278156881593 * x + 0.990434484573249 * y - 0.0170738250293851 * z50,
15692
- z: -0.0092430581525912 * x + 0.0150551448965779 * y + 0.7518742899580008 * z50
15886
+ x: 1.0479298208405488 * x + 0.0229467933410191 * y - 0.0501922295431356 * z54,
15887
+ y: 0.0296278156881593 * x + 0.990434484573249 * y - 0.0170738250293851 * z54,
15888
+ z: -0.0092430581525912 * x + 0.0150551448965779 * y + 0.7518742899580008 * z54
15693
15889
  };
15694
15890
  if (alpha !== void 0) {
15695
15891
  res.alpha = alpha;
@@ -15700,15 +15896,15 @@ var convertXyz65ToXyz50_default = convertXyz65ToXyz50;
15700
15896
 
15701
15897
  // ../../node_modules/culori/src/xyz65/convertXyz50ToXyz65.js
15702
15898
  var convertXyz50ToXyz65 = (xyz502) => {
15703
- let { x, y, z: z50, alpha } = xyz502;
15899
+ let { x, y, z: z54, alpha } = xyz502;
15704
15900
  if (x === void 0) x = 0;
15705
15901
  if (y === void 0) y = 0;
15706
- if (z50 === void 0) z50 = 0;
15902
+ if (z54 === void 0) z54 = 0;
15707
15903
  let res = {
15708
15904
  mode: "xyz65",
15709
- x: 0.9554734527042182 * x - 0.0230985368742614 * y + 0.0632593086610217 * z50,
15710
- y: -0.0283697069632081 * x + 1.0099954580058226 * y + 0.021041398966943 * z50,
15711
- z: 0.0123140016883199 * x - 0.0205076964334779 * y + 1.3303659366080753 * z50
15905
+ x: 0.9554734527042182 * x - 0.0230985368742614 * y + 0.0632593086610217 * z54,
15906
+ y: -0.0283697069632081 * x + 1.0099954580058226 * y + 0.021041398966943 * z54,
15907
+ z: 0.0123140016883199 * x - 0.0205076964334779 * y + 1.3303659366080753 * z54
15712
15908
  };
15713
15909
  if (alpha !== void 0) {
15714
15910
  res.alpha = alpha;