@chainpatrol/sdk 1.5.0 → 1.7.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1255,17 +1255,17 @@ var PolyDateFormatter = class {
1255
1255
  constructor(dt, intl, opts) {
1256
1256
  this.opts = opts;
1257
1257
  this.originalZone = void 0;
1258
- let z50 = void 0;
1258
+ let z54 = void 0;
1259
1259
  if (this.opts.timeZone) {
1260
1260
  this.dt = dt;
1261
1261
  } else if (dt.zone.type === "fixed") {
1262
1262
  const gmtOffset = -1 * (dt.offset / 60);
1263
1263
  const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
1264
1264
  if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
1265
- z50 = offsetZ;
1265
+ z54 = offsetZ;
1266
1266
  this.dt = dt;
1267
1267
  } else {
1268
- z50 = "UTC";
1268
+ z54 = "UTC";
1269
1269
  this.dt = dt.offset === 0 ? dt : dt.setZone("UTC").plus({ minutes: dt.offset });
1270
1270
  this.originalZone = dt.zone;
1271
1271
  }
@@ -1273,14 +1273,14 @@ var PolyDateFormatter = class {
1273
1273
  this.dt = dt;
1274
1274
  } else if (dt.zone.type === "iana") {
1275
1275
  this.dt = dt;
1276
- z50 = dt.zone.name;
1276
+ z54 = dt.zone.name;
1277
1277
  } else {
1278
- z50 = "UTC";
1278
+ z54 = "UTC";
1279
1279
  this.dt = dt.setZone("UTC").plus({ minutes: dt.offset });
1280
1280
  this.originalZone = dt.zone;
1281
1281
  }
1282
1282
  const intlOpts = __spreadValues({}, this.opts);
1283
- intlOpts.timeZone = intlOpts.timeZone || z50;
1283
+ intlOpts.timeZone = intlOpts.timeZone || z54;
1284
1284
  this.dtf = getCachedDTF(intl, intlOpts);
1285
1285
  }
1286
1286
  format() {
@@ -7000,7 +7000,8 @@ function friendlyDateTime(dateTimeish) {
7000
7000
  // ../../internal/database/src/generated/prisma/enums.ts
7001
7001
  var BrandType = {
7002
7002
  INDIVIDUAL: "INDIVIDUAL",
7003
- ORGANIZATION: "ORGANIZATION"
7003
+ ORGANIZATION: "ORGANIZATION",
7004
+ PRODUCT: "PRODUCT"
7004
7005
  };
7005
7006
  var SubscriptionStatus = {
7006
7007
  POC: "POC",
@@ -7114,7 +7115,8 @@ var AssetType = {
7114
7115
  ARCHIVE_ORG: "ARCHIVE_ORG",
7115
7116
  FIVE_HUNDRED_PX: "FIVE_HUNDRED_PX",
7116
7117
  LUMA: "LUMA",
7117
- SMARTMONEYMATCH: "SMARTMONEYMATCH"
7118
+ SMARTMONEYMATCH: "SMARTMONEYMATCH",
7119
+ APK_GOLD: "APK_GOLD"
7118
7120
  };
7119
7121
  var LivenessStatus = {
7120
7122
  UNKNOWN: "UNKNOWN",
@@ -7404,856 +7406,69 @@ z.object({
7404
7406
  z.object({
7405
7407
  result: z.string()
7406
7408
  });
7407
- z.object({
7408
- slug: z.string().min(1),
7409
- configId: z.number().int().positive(),
7410
- status: z.nativeEnum(ThreatDetectionConfigStatus).optional(),
7411
- title: z.string().trim().optional(),
7412
- description: z.string().trim().nullable().optional(),
7413
- cron: z.string().trim().nullable().optional(),
7414
- config: z.record(z.unknown()).optional(),
7415
- mergeConfig: z.boolean().default(false),
7416
- brandId: z.number().int().positive().nullable().optional().describe(
7417
- "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."
7418
- )
7419
- });
7420
- z.object({
7421
- config: z.object({
7422
- id: z.number(),
7423
- source: z.string(),
7424
- status: z.nativeEnum(ThreatDetectionConfigStatus),
7425
- title: z.string(),
7426
- description: z.string().nullable(),
7427
- cron: z.string().nullable(),
7428
- config: z.record(z.unknown()),
7429
- updatedAt: z.date(),
7430
- brandId: z.number().nullable()
7431
- })
7432
- });
7433
- z.object({
7434
- slug: z.string().min(1),
7435
- source: z.string().optional(),
7436
- minResults: z.number().int().min(0).default(1),
7437
- lookbackHours: z.number().int().min(1).default(24 * 7),
7438
- runBeforeValidate: z.boolean().default(false),
7439
- includeDisabled: z.boolean().default(false)
7440
- });
7441
- z.object({
7442
- ok: z.boolean(),
7443
- summary: z.object({
7444
- checkedConfigs: z.number(),
7445
- passingConfigs: z.number(),
7446
- failingConfigs: z.number(),
7447
- lookbackHours: z.number(),
7448
- minResults: z.number()
7449
- }),
7450
- validations: z.array(
7451
- z.object({
7452
- configId: z.number(),
7453
- source: z.string(),
7454
- status: z.nativeEnum(ThreatDetectionConfigStatus),
7455
- ran: z.boolean(),
7456
- runOk: z.boolean(),
7457
- runMessage: z.string().nullable(),
7458
- recentResultCount: z.number(),
7459
- valid: z.boolean()
7460
- })
7461
- )
7462
- });
7463
- z.object({
7464
- slug: z.string().min(1),
7465
- configId: z.number().int().positive().optional(),
7466
- source: z.string().min(1).optional(),
7467
- includeDisabled: z.boolean().default(false)
7468
- });
7469
- z.object({
7470
- ranCount: z.number(),
7471
- successCount: z.number(),
7472
- failedCount: z.number(),
7473
- results: z.array(
7474
- z.object({
7475
- configId: z.number(),
7476
- source: z.string(),
7477
- ok: z.boolean(),
7478
- message: z.string().nullable(),
7479
- assetsCount: z.number()
7480
- })
7481
- )
7482
- });
7483
- var DetectionDriftThresholdsSchema = z.object({
7484
- zeroResultsMaxHours: z.number().int().positive().default(72),
7485
- noisyResultsPerDay: z.number().positive().default(100),
7486
- noisyAllowedRatioThreshold: z.number().min(0).max(1).default(0.6),
7487
- staleConfigDays: z.number().int().positive().default(30)
7488
- });
7489
- z.object({
7490
- slug: z.string().min(1),
7491
- lookbackHours: z.number().int().positive().default(168),
7492
- startDate: z.date().optional(),
7493
- endDate: z.date().optional(),
7494
- source: z.string().min(1).optional(),
7495
- configIds: z.array(z.number().int().positive()).optional(),
7496
- includeDisabled: z.boolean().default(false),
7497
- thresholds: DetectionDriftThresholdsSchema.optional()
7498
- }).refine(
7499
- (value) => !value.startDate && !value.endDate || Boolean(value.startDate) && Boolean(value.endDate),
7500
- {
7501
- message: "Provide both startDate and endDate when using explicit date range",
7502
- path: ["startDate"]
7503
- }
7504
- );
7505
- var DetectionDriftSignalSchema = z.object({
7506
- signal: z.enum(["zero_results_too_long", "noisy_source", "stale_query"]),
7507
- configId: z.number().int().positive(),
7508
- source: z.string(),
7509
- title: z.string().nullable(),
7510
- status: z.string(),
7511
- severity: z.enum(["low", "medium", "high"]),
7512
- details: z.record(z.unknown())
7513
- });
7514
- z.object({
7515
- ok: z.boolean(),
7516
- range: z.object({
7517
- startDate: z.date(),
7518
- endDate: z.date(),
7519
- lookbackHours: z.number().int().positive()
7520
- }),
7521
- thresholds: DetectionDriftThresholdsSchema,
7522
- summary: z.object({
7523
- checkedConfigs: z.number().int().nonnegative(),
7524
- signalCount: z.number().int().nonnegative(),
7525
- zeroResultsCount: z.number().int().nonnegative(),
7526
- noisyCount: z.number().int().nonnegative(),
7527
- staleCount: z.number().int().nonnegative()
7528
- }),
7529
- signals: z.array(DetectionDriftSignalSchema)
7530
- });
7531
- var BucketsSchema = z.object({
7532
- lt24h: z.number().int().nonnegative(),
7533
- h24to72: z.number().int().nonnegative(),
7534
- h72to168: z.number().int().nonnegative(),
7535
- gte168h: z.number().int().nonnegative()
7536
- });
7537
- z.object({
7538
- slug: z.string().min(1).optional(),
7539
- all: z.boolean().default(false),
7540
- windowHours: z.number().int().positive().default(168)
7541
- });
7542
- z.object({
7543
- generatedAt: z.date(),
7544
- scope: z.object({
7545
- slug: z.string().nullable(),
7546
- all: z.boolean()
7547
- }),
7548
- reviewQueue: z.object({
7549
- totalPendingProposals: z.number().int().nonnegative(),
7550
- distinctReports: z.number().int().nonnegative(),
7551
- ageBuckets: BucketsSchema,
7552
- slaBuckets: z.object({
7553
- breached: z.number().int().nonnegative(),
7554
- dueWithin24h: z.number().int().nonnegative(),
7555
- dueWithin72h: z.number().int().nonnegative(),
7556
- beyond72h: z.number().int().nonnegative(),
7557
- missingSla: z.number().int().nonnegative()
7558
- }),
7559
- byOrg: z.array(
7560
- z.object({
7561
- slug: z.string(),
7562
- pendingProposals: z.number().int().nonnegative()
7563
- })
7564
- )
7565
- }),
7566
- takedownQueue: z.object({
7567
- totalOpen: z.number().int().nonnegative(),
7568
- statusCounts: z.object({
7569
- todo: z.number().int().nonnegative(),
7570
- inProgress: z.number().int().nonnegative(),
7571
- pendingInput: z.number().int().nonnegative()
7572
- }),
7573
- ageBuckets: BucketsSchema,
7574
- staleInProgress: z.number().int().nonnegative(),
7575
- byOrg: z.array(
7576
- z.object({
7577
- slug: z.string(),
7578
- openTakedowns: z.number().int().nonnegative()
7579
- })
7580
- )
7581
- })
7582
- });
7583
- var HealthcheckCategorySchema = z.enum([
7584
- "detection",
7585
- "reviewing",
7586
- "blocklisting",
7587
- "takedowns",
7588
- "assets",
7589
- "organization"
7590
- ]);
7591
- var HealthcheckSeveritySchema = z.enum(["ok", "warn", "fail"]);
7592
- var HealthcheckFindingSchema = z.object({
7593
- kind: z.string(),
7594
- ref: z.string().nullable(),
7595
- message: z.string(),
7596
- severity: z.enum(["warn", "fail"])
7597
- });
7598
- z.object({
7599
- id: z.string(),
7600
- title: z.string(),
7601
- category: HealthcheckCategorySchema,
7602
- generatedAt: z.date(),
7603
- scope: z.object({
7604
- slug: z.string().nullable()
7605
- }),
7606
- ok: z.boolean(),
7607
- severity: HealthcheckSeveritySchema,
7608
- observed: z.record(z.union([z.number(), z.string(), z.boolean()]).nullable()),
7609
- threshold: z.record(z.union([z.number(), z.string(), z.boolean()]).nullable()),
7610
- findings: z.array(HealthcheckFindingSchema),
7611
- suggestedAction: z.string().nullable(),
7612
- appUrl: z.string().nullable()
7613
- });
7614
-
7615
- // ../../internal/validation/src/public/healthchecks/assets-dead-asset-spike.ts
7616
- z.object({
7617
- slug: z.string().min(1),
7618
- windowHours: z.number().int().positive().default(24),
7619
- baselineDays: z.number().int().positive().default(7),
7620
- warnMultiplier: z.number().positive().default(2),
7621
- failMultiplier: z.number().positive().default(4),
7622
- minSpikeCount: z.number().int().min(1).default(10)
7623
- });
7624
- z.object({});
7625
- var HealthcheckRegistryEntrySchema = z.object({
7626
- id: z.string(),
7627
- title: z.string(),
7628
- description: z.string(),
7629
- category: HealthcheckCategorySchema,
7630
- implemented: z.boolean(),
7631
- endpoint: z.string().nullable(),
7632
- defaultThreshold: z.record(z.union([z.number(), z.string()])).optional(),
7633
- notImplementedReason: z.string().optional()
7634
- });
7635
- z.object({
7636
- checks: z.array(HealthcheckRegistryEntrySchema)
7637
- });
7638
- z.object({
7639
- slug: z.string().min(1)
7640
- });
7641
- z.object({
7642
- slug: z.string().min(1),
7643
- warnThreshold: z.number().int().nonnegative().default(50),
7644
- failThreshold: z.number().int().nonnegative().default(100)
7645
- });
7646
- z.object({
7647
- slug: z.string().min(1),
7648
- warnAgeHours: z.number().int().positive().default(24 * 7),
7649
- failAgeHours: z.number().int().positive().default(24 * 14)
7650
- });
7651
- z.object({
7652
- slug: z.string().min(1),
7653
- warnAgeHours: z.number().int().nonnegative().default(24 * 30),
7654
- failAgeHours: z.number().int().nonnegative().default(24 * 60)
7655
- });
7656
- z.object({
7657
- slug: z.string().min(1),
7658
- lookbackHours: z.number().int().positive().default(24 * 7),
7659
- warnThreshold: z.number().int().nonnegative().default(3),
7660
- failThreshold: z.number().int().nonnegative().default(10)
7661
- });
7662
- z.object({
7663
- slug: z.string().min(1),
7664
- warnThreshold: z.number().int().nonnegative().default(30),
7665
- failThreshold: z.number().int().nonnegative().default(75)
7666
- });
7667
- z.object({
7668
- slug: z.string().min(1),
7669
- staleThresholdHours: z.number().int().positive().default(24 * 7),
7670
- warnThreshold: z.number().int().nonnegative().default(1),
7671
- failThreshold: z.number().int().nonnegative().default(5)
7672
- });
7673
- z.object({
7674
- slug: z.string().min(1),
7675
- warnThreshold: z.number().int().nonnegative().default(50),
7676
- failThreshold: z.number().int().nonnegative().default(100)
7677
- });
7678
- var BreakdownBySchema = z.enum(["day", "type", "brand"]);
7679
- z.object({
7680
- slug: z.string().min(1),
7681
- by: BreakdownBySchema,
7682
- startDate: z.date().optional(),
7683
- endDate: z.date().optional(),
7684
- brandIds: z.array(z.number().int().positive()).optional()
7685
- });
7686
- z.object({
7687
- by: BreakdownBySchema,
7688
- points: z.array(
7689
- z.object({
7690
- key: z.string(),
7691
- count: z.number(),
7692
- date: z.string().optional(),
7693
- type: z.string().optional(),
7694
- brandId: z.number().optional(),
7695
- brandSlug: z.string().optional(),
7696
- brandName: z.string().optional()
7697
- })
7698
- )
7699
- });
7700
- z.object({
7701
- slug: z.string().min(1),
7702
- startDate: z.date(),
7703
- endDate: z.date(),
7704
- brandIds: z.array(z.number().int().positive()).optional()
7705
- });
7706
- z.object({
7707
- metric: z.literal("new_threats"),
7708
- found: z.number(),
7709
- range: z.object({
7710
- startDate: z.date(),
7711
- endDate: z.date()
7712
- })
7713
- });
7714
- z.object({
7715
- slug: z.string().min(1),
7716
- startDate: z.date().optional(),
7717
- endDate: z.date().optional(),
7718
- brandIds: z.array(z.number().int().positive()).optional()
7719
- });
7720
- z.object({
7721
- metrics: z.object({
7722
- reports: z.number(),
7723
- newThreats: z.number(),
7724
- threatsWatchlisted: z.number(),
7725
- takedownsFiled: z.number(),
7726
- takedownsCompleted: z.number(),
7727
- domainThreats: z.number(),
7728
- twitterThreats: z.number(),
7729
- telegramThreats: z.number(),
7730
- otherThreats: z.number()
7731
- }),
7732
- blockedByDay: z.array(
7733
- z.object({
7734
- date: z.string(),
7735
- count: z.number()
7736
- })
7737
- ),
7738
- blockedByType: z.array(
7739
- z.object({
7740
- type: z.string(),
7741
- count: z.number()
7742
- })
7743
- )
7744
- });
7745
- z.object({
7746
- type: z.nativeEnum(AssetType).optional().describe("Filter by asset type (URL, ADDRESS, etc.)"),
7747
- groupId: z.number().int().optional().describe(
7748
- "Filter by group ID. Use -1 for ungrouped assets only. Omit for all assets."
7749
- ),
7750
- query: z.string().optional().describe("Search query to filter assets by content"),
7751
- per_page: z.number().int().min(1).max(1e3).optional().default(100).describe("The number of assets to return per page (max 1000)"),
7752
- next_page: z.string().optional().nullable().describe("Cursor for fetching the next page of results")
7753
- }).describe(
7754
- `List organization assets request body
7755
-
7756
- Returns all assets belonging to the organization associated with your API key.
7757
- Supports filtering by type, group, and search query.`
7758
- );
7759
- var organizationAssetItemSchema = z.object({
7760
- id: z.number().describe("Asset ID"),
7761
- content: z.string().describe("Asset content (URL, address, handle, etc.)"),
7762
- type: z.nativeEnum(AssetType).describe("Asset type"),
7763
- status: z.nativeEnum(AssetStatus).describe("Asset status"),
7764
- name: z.string().nullable().describe("Asset display name"),
7765
- description: z.string().nullable().describe("Asset description"),
7766
- group: z.object({
7767
- id: z.number().describe("Group ID"),
7768
- name: z.string().describe("Group name")
7769
- }).nullable().describe("Asset group information"),
7770
- livenessStatus: z.nativeEnum(LivenessStatus).nullable().describe(
7771
- "Whether the asset is currently reachable (`ALIVE`), gone (`DEAD`), or hasn't been checked (`UNKNOWN`). `null` when liveness has never been evaluated."
7772
- ),
7773
- blockedAt: z.date().nullable().describe(
7774
- "When the asset transitioned to BLOCKED status. `null` for non-blocked assets. Distinct from `updatedAt`."
7775
- ),
7776
- createdAt: z.date().describe("When the asset was created"),
7777
- updatedAt: z.date().describe("When the asset was last updated")
7778
- });
7779
- z.object({
7780
- assets: z.array(organizationAssetItemSchema).describe("List of assets"),
7781
- next_page: z.string().nullable().optional().describe("Cursor for fetching the next page of results")
7782
- }).describe("Successful operation");
7783
- var addAssetItemSchema = z.object({
7784
- content: z.string().describe("Asset content (URL, address, handle, etc.)"),
7785
- name: z.string().optional().describe("Optional display name for the asset"),
7786
- description: z.string().optional().describe("Optional description for the asset"),
7787
- groupId: z.number().int().positive().optional().describe("Optional group ID to assign the asset to")
7788
- });
7789
- z.object({
7790
- assets: z.array(addAssetItemSchema).min(1).max(1e3).describe("Array of assets to add (max 1000 per request)")
7791
- }).describe(
7792
- `Add assets to organization allowlist
7793
-
7794
- Batch add multiple assets to your organization's allowlist.
7795
- Each asset will be automatically parsed and classified.
7796
- Assets will be auto-approved as ALLOWED status.`
7797
- );
7798
- var addAssetResultSchema = z.object({
7799
- content: z.string().describe("Asset content"),
7800
- success: z.boolean().describe("Whether the asset was added successfully"),
7801
- id: z.number().optional().describe("Asset ID if successful"),
7802
- error: z.string().optional().describe("Error message if failed")
7803
- });
7804
- z.object({
7805
- results: z.array(addAssetResultSchema).describe("Results for each asset"),
7806
- successCount: z.number().describe("Number of assets successfully added"),
7807
- errorCount: z.number().describe("Number of assets that failed to add")
7808
- }).describe("Batch add operation results");
7809
- z.object({
7810
- assetId: z.number().int().positive().describe("ID of the asset to update"),
7811
- name: z.string().optional().describe("New display name for the asset"),
7812
- description: z.string().nullable().optional().describe("New description for the asset"),
7813
- groupId: z.number().int().positive().nullable().optional().describe("New group ID (null to ungroup)")
7814
- }).describe(
7815
- `Update an organization asset
7816
-
7817
- Update the name, description, or group assignment of an asset.`
7818
- );
7819
- z.object({
7820
- id: z.number().describe("Asset ID"),
7821
- content: z.string().describe("Asset content"),
7822
- name: z.string().nullable().describe("Asset display name"),
7823
- description: z.string().nullable().describe("Asset description"),
7824
- groupId: z.number().nullable().describe("Group ID")
7825
- }).describe("Updated asset");
7826
- z.object({
7827
- assetId: z.number().int().positive().describe("ID of the asset to remove")
7828
- }).describe(
7829
- `Remove an asset from the organization
7830
-
7831
- This removes the asset from the organization's allowlist.`
7832
- );
7833
- z.object({
7834
- success: z.boolean().describe("Whether the asset was removed successfully"),
7835
- id: z.number().describe("Asset ID that was removed")
7836
- }).describe("Delete operation result");
7837
- z.object({}).describe(
7838
- `List organization asset groups
7839
-
7840
- Returns all asset groups belonging to the organization associated with your API key.`
7841
- );
7842
- var assetGroupItemSchema = z.object({
7843
- id: z.number().describe("Group ID"),
7844
- name: z.string().describe("Group name"),
7845
- assetCount: z.number().describe("Number of assets in this group")
7846
- });
7847
- z.object({
7848
- groups: z.array(assetGroupItemSchema).describe("List of asset groups")
7849
- }).describe("Successful operation");
7850
- z.object({
7851
- name: z.string().min(1).max(255).describe("Name for the new group")
7852
- }).describe(
7853
- `Create a new asset group
7854
-
7855
- Creates a new asset group for organizing your organization's assets.`
7856
- );
7857
- z.object({
7858
- id: z.number().describe("Created group ID"),
7859
- name: z.string().describe("Group name")
7860
- }).describe("Created group");
7861
- z.object({
7862
- groupId: z.number().int().positive().describe("ID of the group to update"),
7863
- name: z.string().min(1).max(255).describe("New name for the group")
7864
- }).describe(
7865
- `Update an asset group
7866
-
7867
- Rename an existing asset group.`
7868
- );
7869
- z.object({
7870
- id: z.number().describe("Group ID"),
7871
- name: z.string().describe("Updated group name")
7872
- }).describe("Updated group");
7873
- z.object({
7874
- groupId: z.number().int().positive().describe("ID of the group to delete")
7875
- }).describe(
7876
- `Delete an asset group
7877
-
7878
- Deletes an asset group. Assets in this group will become ungrouped.`
7879
- );
7880
- z.object({
7881
- success: z.boolean().describe("Whether the group was deleted successfully"),
7882
- id: z.number().describe("Group ID that was deleted"),
7883
- unassignedAssetCount: z.number().describe("Number of assets that were unassigned from this group")
7884
- }).describe("Delete operation result");
7885
- z.object({}).describe(
7886
- `List organization brands
7887
-
7888
- Returns all brands belonging to the organization associated with your API key,
7889
- including sub-brands (\`ORGANIZATION\`) and individual / employee brands
7890
- (\`INDIVIDUAL\`). Soft-deleted brands are excluded.`
7891
- );
7892
- var brandLegalDocumentSchema = z.object({
7893
- present: z.boolean().describe("Whether the brand has this document attached"),
7894
- fileName: z.string().nullable().describe("Original filename of the uploaded document (null when not present)"),
7895
- fileUrl: z.string().nullable().describe("Direct URL to view or download the document (null when not present)")
7896
- });
7897
- var brandTrademarkRegistrationSchema = z.object({
7898
- id: z.number().describe("Trademark registration ID"),
7899
- brandName: z.string().describe("Trademarked brand name as it appears on the registration"),
7900
- trademarkOffice: z.string().describe("Issuing trademark office (e.g. `USPTO`, `EUIPO`)"),
7901
- registrationNumber: z.string().describe("Registration number assigned by the office"),
7902
- goodsAndServicesClass: z.string().describe("Nice Classification class(es) the registration covers"),
7903
- rightsOwnerName: z.string().nullable().describe("Legal entity the trademark is registered to, if recorded"),
7904
- registrationPageUrl: z.string().nullable().describe("Public URL on the trademark office's site, if recorded"),
7905
- certificateFileName: z.string().nullable().describe(
7906
- "Original filename of the uploaded certificate PDF (null when no certificate is attached)"
7907
- ),
7908
- certificateFileUrl: z.string().nullable().describe(
7909
- "Direct URL to view or download the certificate PDF (null when no certificate is attached)"
7910
- )
7911
- });
7912
- var brandItemSchema = z.object({
7913
- id: z.number().describe("Brand ID"),
7914
- slug: z.string().describe("Brand slug (stable, URL-safe identifier)"),
7915
- name: z.string().describe("Display name"),
7916
- type: z.nativeEnum(BrandType).describe(
7917
- "Brand type: `ORGANIZATION` for parent / product brands, `INDIVIDUAL` for employee or person brands"
7918
- ),
7919
- description: z.string().nullable().describe("Free-form description, if set"),
7920
- avatarUrl: z.string().nullable().describe("URL of the brand's avatar / logo image"),
7921
- websiteUrl: z.string().nullable().describe("Official brand website URL"),
7922
- twitterHandle: z.string().nullable().describe("Official Twitter / X handle (without @)"),
7923
- brandColors: z.array(z.string()).describe("HEX color strings associated with the brand (e.g. `#FF0000`)"),
7924
- includedTerms: z.array(z.string()).describe("Terms that should be included when matching this brand"),
7925
- excludedTerms: z.array(z.string()).describe("Terms that should be excluded when matching this brand"),
7926
- tickers: z.array(z.string()).describe("Ticker symbols associated with the brand (e.g. `$JUP`)"),
7927
- brandGroupId: z.number().nullable().describe("Group this brand belongs to (only set for `INDIVIDUAL` brands)"),
7928
- createdAt: z.date().describe("When the brand was created"),
7929
- useOrganizationDocs: z.boolean().describe(
7930
- "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."
7931
- ),
7932
- legalDocuments: z.object({
7933
- letterOfAuthorization: brandLegalDocumentSchema,
7934
- powerOfAttorney: brandLegalDocumentSchema
7935
- }).describe("Brand-level Letter of Authorization and Power of Attorney attachments"),
7936
- trademarkRegistrations: z.array(brandTrademarkRegistrationSchema).describe(
7937
- "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."
7938
- )
7939
- });
7940
- z.object({
7941
- brands: z.array(brandItemSchema).describe("List of brands")
7942
- }).describe("Successful operation");
7943
- var FILTERABLE_SUBSCRIPTION_STATUSES = [
7944
- SubscriptionStatus.PROSPECT,
7945
- SubscriptionStatus.POC,
7946
- SubscriptionStatus.ACTIVE,
7947
- SubscriptionStatus.INTEGRATION
7948
- ];
7949
- var UserOrgsSubscriptionStatusSchema = z.enum(
7950
- FILTERABLE_SUBSCRIPTION_STATUSES
7951
- );
7952
- var takedownsServiceFilterSchema = z.object({
7953
- active: z.boolean().optional(),
7954
- automated: z.boolean().optional()
7955
- }).optional();
7956
- var singleServiceFilterSchema = z.object({
7957
- active: z.boolean().optional()
7958
- }).optional();
7959
- var userOrgsServicesFilterObjectSchema = z.object({
7960
- reporting: singleServiceFilterSchema,
7961
- reviewing: singleServiceFilterSchema,
7962
- protection: singleServiceFilterSchema,
7963
- takedowns: takedownsServiceFilterSchema,
7964
- detection: singleServiceFilterSchema,
7965
- darkWebMonitoring: singleServiceFilterSchema
7966
- });
7967
- var userOrgsObligatoryAdminApprovalFilterSchema = z.object({
7968
- active: z.boolean().optional(),
7969
- assetTypes: z.array(z.nativeEnum(AssetType)).min(1).optional()
7970
- }).optional();
7971
- var PendingApprovalServiceSchema = z.enum(["protection", "takedowns"]);
7972
- var userOrgsPendingServiceApprovalFilterSchema = z.object({
7973
- active: z.boolean().optional(),
7974
- services: z.array(PendingApprovalServiceSchema).min(1).optional()
7975
- }).optional();
7976
- z.object({
7977
- query: z.string().default(""),
7978
- subscriptionStatus: z.array(UserOrgsSubscriptionStatusSchema).min(1).optional(),
7979
- services: userOrgsServicesFilterObjectSchema.optional(),
7980
- obligatoryAdminApproval: userOrgsObligatoryAdminApprovalFilterSchema,
7981
- pendingServiceApproval: userOrgsPendingServiceApprovalFilterSchema
7982
- });
7983
- var takedownsServiceSchema = z.object({
7984
- active: z.boolean(),
7985
- automated: z.boolean()
7986
- });
7987
- var singleServiceSchema = z.object({
7988
- active: z.boolean()
7989
- });
7990
- var UserOrgObligatoryAdminApprovalSchema = z.object({
7991
- active: z.boolean(),
7992
- assetTypes: z.array(z.nativeEnum(AssetType))
7993
- });
7994
- var PendingServiceApprovalSchema = z.object({
7995
- // Friendly service family, matching a key in the `services` object.
7996
- service: PendingApprovalServiceSchema,
7997
- // Whether the request is for the automated variant of the service
7998
- // (e.g. "Automated Wallet Blocking" rather than "Wallet Blocking").
7999
- automated: z.boolean(),
8000
- // Raw `ServiceType` enum value, e.g. "isProtectionActive". Lets callers
8001
- // distinguish the exact column without re-deriving it from `service` +
8002
- // `automated`.
8003
- serviceType: z.nativeEnum(ServiceType),
8004
- // Human-readable service label, e.g. "Wallet Blocking".
8005
- serviceName: z.string(),
8006
- // When the enable request was submitted (ISO 8601, UTC).
8007
- requestedAt: z.string()
8008
- });
8009
- var UserOrgIntegrationsSchema = z.object({
8010
- slack: z.boolean(),
8011
- discord: z.boolean(),
8012
- telegram: z.object({
8013
- connected: z.boolean(),
8014
- groupCount: z.number()
8015
- }),
8016
- vercel: z.boolean(),
8017
- intercom: z.boolean(),
8018
- moderation: z.boolean()
8019
- });
8020
- var UserOrgLegalDocumentSchema = z.object({
8021
- present: z.boolean().describe("Whether the organization has this document attached"),
8022
- fileName: z.string().nullable().describe("Original filename of the uploaded document (null when not present)"),
8023
- fileUrl: z.string().nullable().describe("Direct URL to view or download the document (null when not present)")
8024
- });
8025
- var UserOrgLegalDocumentsSchema = z.object({
8026
- letterOfAuthorization: UserOrgLegalDocumentSchema,
8027
- powerOfAttorney: UserOrgLegalDocumentSchema
8028
- });
8029
- var UserOrgTrademarkRegistrationSchema = z.object({
8030
- id: z.number().describe("Trademark registration ID"),
8031
- brandName: z.string().describe("Trademarked brand name as it appears on the registration"),
8032
- trademarkOffice: z.string().describe("Issuing trademark office (e.g. `USPTO`, `EUIPO`)"),
8033
- registrationNumber: z.string().describe("Registration number assigned by the office"),
8034
- goodsAndServicesClass: z.string().describe("Nice Classification class(es) the registration covers"),
8035
- rightsOwnerName: z.string().nullable().describe("Legal entity the trademark is registered to, if recorded"),
8036
- registrationPageUrl: z.string().nullable().describe("Public URL on the trademark office's site, if recorded"),
8037
- certificateFileName: z.string().nullable().describe(
8038
- "Original filename of the uploaded certificate PDF (null when no certificate is attached)"
8039
- ),
8040
- certificateFileUrl: z.string().nullable().describe(
8041
- "Direct URL to view or download the certificate PDF (null when no certificate is attached)"
8042
- )
8043
- });
8044
- var UserOrgBrandMetadataSchema = z.object({
8045
- websiteUrl: z.string().nullable().describe("Public website URL of the brand (linked from the portal header)"),
8046
- twitterHandle: z.string().nullable().describe(
8047
- "Public Twitter/X handle of the brand, stored with the leading `@` (e.g. `@acme`)"
8048
- ),
8049
- securityContactEmail: z.string().nullable().describe(
8050
- "Email address for security correspondence \u2014 used by takedown providers and researchers, distinct from the internal customer POC email"
8051
- ),
8052
- industry: z.string().nullable().describe('Free-form industry label (e.g. "DeFi", "CEX", "NFT", "Wallet")')
8053
- });
8054
- var UserOrgPortalCustomizationSchema = z.object({
8055
- useCustomDetails: z.boolean().describe(
8056
- "When true, the portal uses `name`/`slug`/`avatarUrl` from this object instead of the org's own name/slug/avatar"
8057
- ),
8058
- name: z.string().nullable().describe(
8059
- "Custom display name shown on the portal (used only when `useCustomDetails=true`)"
8060
- ),
8061
- slug: z.string().nullable().describe(
8062
- "Custom URL slug (`chainpatrol.io/<slug>`) \u2014 takes precedence over the org's own slug when set, regardless of `useCustomDetails`"
8063
- ),
8064
- avatarUrl: z.string().nullable().describe(
8065
- "Custom avatar URL shown on the portal (used only when `useCustomDetails=true`)"
8066
- ),
8067
- bannerEnabled: z.boolean().describe(
8068
- "When true, the portal renders `bannerContent` as a highlighted banner at the top of the page"
8069
- ),
8070
- bannerContent: z.string().nullable().describe(
8071
- "Markdown body of the portal banner. Null (or empty) with `bannerEnabled=true` means the toggle is on but no content has been written yet"
8072
- )
8073
- });
8074
- var UserOrgSchema = z.object({
8075
- id: z.number(),
8076
- name: z.string(),
8077
- slug: z.string(),
8078
- avatarUrl: z.string().nullable(),
8079
- contactUrl: z.string().nullable(),
8080
- subscriptionStatus: z.nativeEnum(SubscriptionStatus),
8081
- portalVisibility: z.nativeEnum(OrganizationPortalVisibility).describe(
8082
- "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."
8083
- ),
8084
- reportVisibility: z.nativeEnum(ReportVisibility).describe(
8085
- "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."
8086
- ),
8087
- metricsVisibility: z.nativeEnum(MetricsVisibility).describe(
8088
- "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."
8089
- ),
8090
- brandMetadata: UserOrgBrandMetadataSchema.describe(
8091
- "Public brand-facing metadata (website, twitter, security contact, industry) shown on the portal and used by staff for outbound"
8092
- ),
8093
- portalCustomization: UserOrgPortalCustomizationSchema.describe(
8094
- "Customer-configurable presentation of the public security portal \u2014 custom name/slug/avatar and the banner content"
8095
- ),
8096
- services: z.object({
8097
- reporting: singleServiceSchema,
8098
- reviewing: singleServiceSchema,
8099
- protection: singleServiceSchema,
8100
- takedowns: takedownsServiceSchema,
8101
- detection: singleServiceSchema,
8102
- darkWebMonitoring: singleServiceSchema
8103
- }),
8104
- integrations: UserOrgIntegrationsSchema,
8105
- obligatoryAdminApproval: UserOrgObligatoryAdminApprovalSchema,
8106
- pendingServiceApprovals: z.array(PendingServiceApprovalSchema),
8107
- legalDocuments: UserOrgLegalDocumentsSchema.describe(
8108
- "Org-level Letter of Authorization and Power of Attorney attachments"
8109
- ),
8110
- trademarkRegistrations: z.array(UserOrgTrademarkRegistrationSchema).describe(
8111
- "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."
8112
- )
8113
- });
8114
- z.object({
8115
- organizations: z.array(UserOrgSchema)
8116
- });
8117
7409
 
8118
- // ../../internal/validation/src/public/organization/metrics-get.ts
8119
- var organizationMetricsIncludeFieldSchema = z.enum([
8120
- "reports",
8121
- "newThreats",
8122
- "threatsWatchlisted",
8123
- "takedownsFiled",
8124
- "takedownsCompleted",
8125
- "domainThreats",
8126
- "twitterThreats",
8127
- "telegramThreats",
8128
- "otherThreats",
8129
- "blockedByType",
8130
- "blockedByDay"
8131
- ]);
8132
- organizationMetricsIncludeFieldSchema.options;
8133
- var ORGANIZATION_METRICS_MAX_SLUGS = 500;
8134
- var organizationMetricsServicesFilterSchema = z.preprocess((value) => {
8135
- if (typeof value !== "string") return value;
8136
- try {
8137
- return JSON.parse(value);
8138
- } catch (e4) {
8139
- return value;
8140
- }
8141
- }, userOrgsServicesFilterObjectSchema).optional();
8142
- z.object({
8143
- organizationSlug: z.string().optional().describe(
8144
- "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`."
8145
- ),
8146
- slugs: z.array(z.string()).max(ORGANIZATION_METRICS_MAX_SLUGS).optional().describe(
8147
- "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`."
8148
- ),
8149
- allMyOrgs: z.preprocess((value) => {
8150
- if (value === "true") return true;
8151
- if (value === "false") return false;
8152
- return value;
8153
- }, z.boolean()).optional().describe(
8154
- "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`."
8155
- ),
8156
- subscriptionStatus: z.array(UserOrgsSubscriptionStatusSchema).min(1).optional().describe(
8157
- "Only meaningful with `allMyOrgs: true`. Defaults to the same set `/user/orgs` uses (ACTIVE/POC/PROSPECT/INTEGRATION \u2014 INACTIVE is always excluded)."
8158
- ),
8159
- services: organizationMetricsServicesFilterSchema.describe(
8160
- "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'."
8161
- ),
8162
- brandSlug: z.string().optional(),
8163
- startDate: z.coerce.date().optional(),
8164
- endDate: z.coerce.date().optional(),
8165
- include: z.array(organizationMetricsIncludeFieldSchema).optional().describe(
8166
- "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`."
8167
- )
8168
- }).refine(
8169
- (value) => {
8170
- const explicitForms = [
8171
- Boolean(value.organizationSlug),
8172
- Boolean(value.slugs && value.slugs.length > 0),
8173
- Boolean(value.allMyOrgs)
8174
- ].filter(Boolean).length;
8175
- return explicitForms <= 1;
8176
- },
8177
- {
8178
- message: "Pass at most one of `organizationSlug`, `slugs`, or `allMyOrgs`.",
8179
- path: ["allMyOrgs"]
8180
- }
8181
- ).refine((value) => !(value.brandSlug && value.slugs && value.slugs.length > 1), {
8182
- message: "`brandSlug` is only valid alongside a single organization, not `slugs`.",
8183
- path: ["brandSlug"]
8184
- }).refine((value) => !(value.brandSlug && value.allMyOrgs), {
8185
- message: "`brandSlug` is only valid for a single org, not `allMyOrgs`.",
8186
- path: ["brandSlug"]
8187
- });
8188
- var metricValue = z.number().nullable();
8189
- var metricsObjectSchema = z.object({
8190
- reports: metricValue,
8191
- newThreats: metricValue,
8192
- threatsWatchlisted: metricValue,
8193
- takedownsFiled: metricValue,
8194
- takedownsCompleted: metricValue,
8195
- domainThreats: metricValue,
8196
- twitterThreats: metricValue,
8197
- telegramThreats: metricValue,
8198
- otherThreats: metricValue
8199
- });
8200
- var blockedByTypeSchema = z.array(
8201
- z.object({
8202
- type: z.string(),
8203
- count: z.number()
8204
- })
8205
- ).nullable();
8206
- var blockedByDaySchema = z.array(
8207
- z.object({
8208
- date: z.string(),
8209
- count: z.number()
8210
- })
8211
- ).nullable();
8212
- z.object({
8213
- /**
8214
- * Aggregate metrics. For single-org callers this is just that org's
8215
- * numbers; for multi-org callers (`slugs.length > 1` or `allMyOrgs`)
8216
- * it is the sum across all queried orgs.
8217
- */
8218
- metrics: metricsObjectSchema,
8219
- blockedByType: blockedByTypeSchema,
8220
- blockedByDay: blockedByDaySchema,
8221
- /**
8222
- * Derived averages over the time window (and, in multi-org mode,
8223
- * across orgs). `perDay = metrics / windowDays`. In multi-org mode
8224
- * `perOrgPerDay = metrics / numOrgs / windowDays`; in single-org
8225
- * mode it is `null`. Counts are floats here — the underlying
8226
- * `metrics` fields stay integer counts.
8227
- */
8228
- averages: z.object({
8229
- perDay: metricsObjectSchema.nullable(),
8230
- perOrgPerDay: metricsObjectSchema.nullable(),
8231
- windowDays: z.number().nullable()
8232
- }),
8233
- /**
8234
- * Per-org breakdown. Only populated in multi-org mode; `null` for
8235
- * single-org callers.
8236
- */
8237
- perOrg: z.record(
8238
- z.string(),
8239
- z.object({
8240
- metrics: metricsObjectSchema,
8241
- blockedByType: blockedByTypeSchema,
8242
- blockedByDay: blockedByDaySchema
8243
- })
8244
- ).nullable(),
8245
- /**
8246
- * Echoes the actual orgs the response covers, in the order they
8247
- * were resolved. Single-org responses always have length 1. The
8248
- * `resolvedFrom` field distinguishes how the caller asked for the
8249
- * scope (useful for agent reporting).
8250
- */
8251
- scope: z.object({
8252
- mode: z.enum(["single", "multi"]),
8253
- orgs: z.array(z.string()),
8254
- resolvedFrom: z.enum(["api-key", "organizationSlug", "slugs", "allMyOrgs"])
8255
- })
8256
- });
7410
+ // ../../internal/utils/src/detection.ts
7411
+ var ThreatDetectionSourceKey = /* @__PURE__ */ ((ThreatDetectionSourceKey2) => {
7412
+ ThreatDetectionSourceKey2["META_ADS_SEARCH"] = "meta_ads_search";
7413
+ ThreatDetectionSourceKey2["TELEGRAM_CHANNELS_SEARCH"] = "telegram_channels_search";
7414
+ ThreatDetectionSourceKey2["TELEGRAM_USER_SEARCH"] = "telegram_user_search";
7415
+ ThreatDetectionSourceKey2["TELEGRAM_CHANNELS_SEARCH_VETRIC"] = "telegram_channels_search_vetric";
7416
+ ThreatDetectionSourceKey2["TELEGRAM_USER_SEARCH_VETRIC"] = "telegram_user_search_vetric";
7417
+ ThreatDetectionSourceKey2["FACEBOOK_PAGE_SEARCH_VETRIC"] = "facebook_page_search_vetric";
7418
+ ThreatDetectionSourceKey2["INSTAGRAM_ACCOUNT_SEARCH_VETRIC"] = "instagram_account_search_vetric";
7419
+ ThreatDetectionSourceKey2["TWITTER_SEARCH_VETRIC"] = "twitter_search_vetric";
7420
+ ThreatDetectionSourceKey2["LINKEDIN_PEOPLE_SEARCH_VETRIC"] = "linkedin_people_search_vetric";
7421
+ ThreatDetectionSourceKey2["LINKEDIN_COMPANY_SEARCH_VETRIC"] = "linkedin_company_search_vetric";
7422
+ ThreatDetectionSourceKey2["META_ADS_SEARCH_VETRIC"] = "meta_ads_search_vetric";
7423
+ ThreatDetectionSourceKey2["TIK_TOK_VIDEO_SEARCH"] = "tik_tok_video_search";
7424
+ ThreatDetectionSourceKey2["TIK_TOK_USER_SEARCH"] = "tik_tok_user_search";
7425
+ ThreatDetectionSourceKey2["TIK_TOK_USER_SEARCH_VETRIC"] = "tik_tok_user_search_vetric";
7426
+ ThreatDetectionSourceKey2["TIK_TOK_VIDEO_SEARCH_VETRIC"] = "tik_tok_video_search_vetric";
7427
+ ThreatDetectionSourceKey2["BLOCKLIST"] = "blocklist";
7428
+ ThreatDetectionSourceKey2["APPLE_APP_STORE"] = "apple_app_store";
7429
+ ThreatDetectionSourceKey2["GOOGLE_ADS_SEARCH"] = "google_ads_search";
7430
+ ThreatDetectionSourceKey2["MOZILLA_ADDON_SEARCH"] = "mozilla_addon_search";
7431
+ ThreatDetectionSourceKey2["REDDIT_SUBREDDIT_SEARCH"] = "reddit_subreddit_search";
7432
+ ThreatDetectionSourceKey2["ASSET_CHECK"] = "asset_check";
7433
+ ThreatDetectionSourceKey2["TWITTER_POST_SEARCH"] = "twitter_post_search";
7434
+ ThreatDetectionSourceKey2["MEDIUM_TAG_RSS"] = "medium_tag_rss";
7435
+ ThreatDetectionSourceKey2["TWITTER_SEARCH"] = "twitter_search";
7436
+ ThreatDetectionSourceKey2["YAHOO_SEARCH"] = "yahoo_search";
7437
+ ThreatDetectionSourceKey2["DUCK_DUCK_GO_SEARCH"] = "duck_duck_go_search";
7438
+ ThreatDetectionSourceKey2["BING_SEARCH"] = "bing_search";
7439
+ ThreatDetectionSourceKey2["GUESTBOOK"] = "guestbook";
7440
+ ThreatDetectionSourceKey2["CERTSTREAM"] = "certstream";
7441
+ ThreatDetectionSourceKey2["EXTERNAL"] = "external";
7442
+ ThreatDetectionSourceKey2["GOOGLE_SEARCH"] = "google_search";
7443
+ ThreatDetectionSourceKey2["DNS_TWIST"] = "dns_twist";
7444
+ ThreatDetectionSourceKey2["TWITTER"] = "twitter";
7445
+ ThreatDetectionSourceKey2["TWITTER_USERNAME_MONITOR"] = "twitter_username_monitor";
7446
+ ThreatDetectionSourceKey2["URLSCAN"] = "urlscan";
7447
+ ThreatDetectionSourceKey2["URLSCAN_HOSTNAME_SEARCH"] = "urlscan_hostname_search";
7448
+ ThreatDetectionSourceKey2["YOUTUBE_SEARCH"] = "youtube_search";
7449
+ ThreatDetectionSourceKey2["GOOGLE_PLAY_SEARCH"] = "google_play_search";
7450
+ ThreatDetectionSourceKey2["DEXSCREENER_SEARCH"] = "dexscreener_search";
7451
+ ThreatDetectionSourceKey2["BLOCKED_IP_SCAN"] = "blocked_ip_scan";
7452
+ ThreatDetectionSourceKey2["BLOCKED_BILIBILI_SUGGESTED"] = "blocked_bilibili_suggested";
7453
+ ThreatDetectionSourceKey2["GROK_POST_SEARCH"] = "grok_post_search";
7454
+ ThreatDetectionSourceKey2["GROK_USER_SEARCH"] = "grok_user_search";
7455
+ ThreatDetectionSourceKey2["GOOGLE_LENS_IMAGE_SEARCH"] = "google_lens_image_search";
7456
+ ThreatDetectionSourceKey2["YANDEX_SEARCH"] = "yandex_search";
7457
+ ThreatDetectionSourceKey2["LINKEDIN_EMPLOYEE_DETECTION"] = "linkedin_employee_detection";
7458
+ ThreatDetectionSourceKey2["LINKEDIN_POST_SEARCH"] = "linkedin_post_search";
7459
+ ThreatDetectionSourceKey2["LINKEDIN_COMPANY_SEARCH"] = "linkedin_company_search";
7460
+ ThreatDetectionSourceKey2["BING_ADS_SEARCH"] = "bing_ads_search";
7461
+ ThreatDetectionSourceKey2["TIK_TOK_ADS_SEARCH"] = "tik_tok_ads_search";
7462
+ ThreatDetectionSourceKey2["DNSDB"] = "dnsdb";
7463
+ ThreatDetectionSourceKey2["DAILY_MOTION_SEARCH"] = "daily_motion_search";
7464
+ ThreatDetectionSourceKey2["WATCHLIST"] = "watchlist";
7465
+ return ThreatDetectionSourceKey2;
7466
+ })(ThreatDetectionSourceKey || {});
7467
+ var ThreatDetectionScope = /* @__PURE__ */ ((ThreatDetectionScope2) => {
7468
+ ThreatDetectionScope2["ORGANIZATION"] = "organization";
7469
+ ThreatDetectionScope2["GLOBAL"] = "global";
7470
+ return ThreatDetectionScope2;
7471
+ })(ThreatDetectionScope || {});
8257
7472
 
8258
7473
  // ../../internal/utils/src/enrichments.ts
8259
7474
  var enrichments_exports = {};
@@ -10847,977 +10062,1963 @@ var doCustomReplacements = (string, replacements2) => {
10847
10062
  for (const [key, value] of replacements2) {
10848
10063
  string = string.replace(new RegExp(escapeStringRegexp2(key), "g"), value);
10849
10064
  }
10850
- return string;
10065
+ return string;
10066
+ };
10067
+ function transliterate(string, options) {
10068
+ if (typeof string !== "string") {
10069
+ throw new TypeError(`Expected a string, got \`${typeof string}\``);
10070
+ }
10071
+ options = __spreadValues({
10072
+ customReplacements: []
10073
+ }, options);
10074
+ const customReplacements = new Map([
10075
+ ...replacements_default,
10076
+ ...options.customReplacements
10077
+ ]);
10078
+ string = string.normalize();
10079
+ string = doCustomReplacements(string, customReplacements);
10080
+ string = string.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").normalize();
10081
+ return string;
10082
+ }
10083
+
10084
+ // ../../node_modules/@sindresorhus/slugify/overridable-replacements.js
10085
+ var overridableReplacements = [
10086
+ ["&", " and "],
10087
+ ["\u{1F984}", " unicorn "],
10088
+ ["\u2665", " love "]
10089
+ ];
10090
+ var overridable_replacements_default = overridableReplacements;
10091
+
10092
+ // ../../node_modules/@sindresorhus/slugify/index.js
10093
+ var decamelize = (string) => {
10094
+ 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");
10095
+ };
10096
+ var removeMootSeparators = (string, separator) => {
10097
+ const escapedSeparator = escapeStringRegexp(separator);
10098
+ return string.replace(new RegExp(`${escapedSeparator}{2,}`, "g"), separator).replace(new RegExp(`^${escapedSeparator}|${escapedSeparator}$`, "g"), "");
10099
+ };
10100
+ var buildPatternSlug = (options) => {
10101
+ let negationSetPattern = "a-z\\d";
10102
+ negationSetPattern += options.lowercase ? "" : "A-Z";
10103
+ if (options.preserveCharacters.length > 0) {
10104
+ for (const character of options.preserveCharacters) {
10105
+ if (character === options.separator) {
10106
+ throw new Error(`The separator character \`${options.separator}\` cannot be included in preserved characters: ${options.preserveCharacters}`);
10107
+ }
10108
+ negationSetPattern += escapeStringRegexp(character);
10109
+ }
10110
+ }
10111
+ return new RegExp(`[^${negationSetPattern}]+`, "g");
10112
+ };
10113
+ function slugify(string, options) {
10114
+ if (typeof string !== "string") {
10115
+ throw new TypeError(`Expected a string, got \`${typeof string}\``);
10116
+ }
10117
+ options = __spreadValues({
10118
+ separator: "-",
10119
+ lowercase: true,
10120
+ decamelize: true,
10121
+ customReplacements: [],
10122
+ preserveLeadingUnderscore: false,
10123
+ preserveTrailingDash: false,
10124
+ preserveCharacters: []
10125
+ }, options);
10126
+ const shouldPrependUnderscore = options.preserveLeadingUnderscore && string.startsWith("_");
10127
+ const shouldAppendDash = options.preserveTrailingDash && string.endsWith("-");
10128
+ const customReplacements = new Map([
10129
+ ...overridable_replacements_default,
10130
+ ...options.customReplacements
10131
+ ]);
10132
+ string = transliterate(string, { customReplacements });
10133
+ if (options.decamelize) {
10134
+ string = decamelize(string);
10135
+ }
10136
+ const patternSlug = buildPatternSlug(options);
10137
+ if (options.lowercase) {
10138
+ string = string.toLowerCase();
10139
+ }
10140
+ string = string.replace(/([a-zA-Z\d]+)'([ts])(\s|$)/g, "$1$2$3");
10141
+ string = string.replace(patternSlug, options.separator);
10142
+ string = string.replace(/\\/g, "");
10143
+ if (options.separator) {
10144
+ string = removeMootSeparators(string, options.separator);
10145
+ }
10146
+ if (shouldPrependUnderscore) {
10147
+ string = `_${string}`;
10148
+ }
10149
+ if (shouldAppendDash) {
10150
+ string = `${string}-`;
10151
+ }
10152
+ return string;
10153
+ }
10154
+
10155
+ // ../asset-parse/src/model.ts
10156
+ var AssetModel = /* @__PURE__ */ ((AssetModel2) => {
10157
+ AssetModel2["Addon"] = "addon";
10158
+ AssetModel2["App"] = "app";
10159
+ AssetModel2["Bot"] = "bot";
10160
+ AssetModel2["BusinessProfile"] = "business-profile";
10161
+ AssetModel2["Catalog"] = "catalog";
10162
+ AssetModel2["Collection"] = "collection";
10163
+ AssetModel2["Channel"] = "channel";
10164
+ AssetModel2["Group"] = "group";
10165
+ AssetModel2["Post"] = "post";
10166
+ AssetModel2["Profile"] = "profile";
10167
+ AssetModel2["Short"] = "short";
10168
+ AssetModel2["Video"] = "video";
10169
+ AssetModel2["Space"] = "space";
10170
+ AssetModel2["Issue"] = "issue";
10171
+ AssetModel2["PullRequest"] = "pull-request";
10172
+ AssetModel2["Discussion"] = "discussion";
10173
+ AssetModel2["Repository"] = "repository";
10174
+ AssetModel2["Article"] = "Article";
10175
+ AssetModel2["Comment"] = "comment";
10176
+ AssetModel2["List"] = "list";
10177
+ AssetModel2["Subreddit"] = "subreddit";
10178
+ AssetModel2["Community"] = "community";
10179
+ AssetModel2["MiniApp"] = "mini-app";
10180
+ AssetModel2["Developer"] = "developer";
10181
+ return AssetModel2;
10182
+ })(AssetModel || {});
10183
+ function isUrl(input) {
10184
+ if (input.trim() === "") {
10185
+ return false;
10186
+ }
10187
+ if (input.startsWith("/") || input.startsWith("#") || input.startsWith("?") || input.startsWith(".") || !input.includes(".")) {
10188
+ return false;
10189
+ }
10190
+ return URL.canParse(input) || URL.canParse(`https://${input}`);
10191
+ }
10192
+ function getNormalizedUrl(input) {
10193
+ if (!isUrl(input)) {
10194
+ throw new Error(`Invalid URL: ${input}`);
10195
+ }
10196
+ let url;
10197
+ try {
10198
+ url = new URL(input);
10199
+ } catch (e4) {
10200
+ try {
10201
+ url = new URL(`https://${input}`);
10202
+ } catch (e5) {
10203
+ throw new Error(`Invalid URL: ${input}`);
10204
+ }
10205
+ }
10206
+ const normalizedUrl = normalizeUrl(url.toString(), {
10207
+ defaultProtocol: "https"
10208
+ });
10209
+ try {
10210
+ return new URL(normalizedUrl);
10211
+ } catch (e4) {
10212
+ throw new Error(`Invalid URL: ${input}`);
10213
+ }
10214
+ }
10215
+ var ensureHttpsPrefix = (url) => {
10216
+ if (!url.startsWith("http")) {
10217
+ return `https://${url}`;
10218
+ }
10219
+ return url.replace(/^https?:\/{1,2}/, "https://");
10851
10220
  };
10852
- function transliterate(string, options) {
10853
- if (typeof string !== "string") {
10854
- throw new TypeError(`Expected a string, got \`${typeof string}\``);
10221
+ function getHostname(input) {
10222
+ try {
10223
+ return getNormalizedUrl(input).hostname;
10224
+ } catch (e4) {
10225
+ return null;
10855
10226
  }
10856
- options = __spreadValues({
10857
- customReplacements: []
10858
- }, options);
10859
- const customReplacements = new Map([
10860
- ...replacements_default,
10861
- ...options.customReplacements
10862
- ]);
10863
- string = string.normalize();
10864
- string = doCustomReplacements(string, customReplacements);
10865
- string = string.normalize("NFD").replace(new RegExp("\\p{Diacritic}", "gu"), "").normalize();
10866
- return string;
10227
+ }
10228
+ function getParentDomains(input) {
10229
+ const domain = getHostname(input);
10230
+ if (!domain) {
10231
+ return [];
10232
+ }
10233
+ const subdomain = getSubdomain(domain, { mixedInputs: false });
10234
+ if (!subdomain) {
10235
+ return [domain];
10236
+ }
10237
+ const domainWithSuffix = getDomain(domain, { mixedInputs: false });
10238
+ if (!domainWithSuffix) {
10239
+ return [];
10240
+ }
10241
+ const parentDomains = [domainWithSuffix];
10242
+ const parentDomainParts = subdomain.split(".");
10243
+ for (let i = parentDomainParts.length - 1; i >= 0; i--) {
10244
+ const parentDomainPart = parentDomainParts.slice(i).join(".");
10245
+ parentDomains.push(`${parentDomainPart}.${domainWithSuffix}`);
10246
+ }
10247
+ return parentDomains.reverse();
10248
+ }
10249
+ function trimDomainToLevels(domain, options = { levels: 4 }) {
10250
+ var _a;
10251
+ const parsed = parse$1(domain);
10252
+ const eTLDPlusOne = (_a = parsed.domain) != null ? _a : "";
10253
+ const subdomains = domain.replace(/https?:\/\/(www\.)?/, "").split(".");
10254
+ const eTLDPlusOneIndex = subdomains.findIndex(
10255
+ (_, i) => subdomains.slice(i).join(".") === eTLDPlusOne
10256
+ );
10257
+ const trimmedSubdomains = subdomains.slice(Math.max(eTLDPlusOneIndex - (options.levels - 1), 0)).join(".");
10258
+ return trimmedSubdomains;
10867
10259
  }
10868
10260
 
10869
- // ../../node_modules/@sindresorhus/slugify/overridable-replacements.js
10870
- var overridableReplacements = [
10871
- ["&", " and "],
10872
- ["\u{1F984}", " unicorn "],
10873
- ["\u2665", " love "]
10874
- ];
10875
- var overridable_replacements_default = overridableReplacements;
10261
+ // ../asset-parse/src/phone.ts
10262
+ var phone_exports = {};
10263
+ __export(phone_exports, {
10264
+ PHONE_NUMBER_REGEX: () => PHONE_NUMBER_REGEX,
10265
+ isPhoneNumber: () => isPhoneNumber,
10266
+ normalizePhoneNumber: () => normalizePhoneNumber
10267
+ });
10268
+ 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;
10269
+ function preparePhoneInput(input) {
10270
+ let s2 = input.trim();
10271
+ s2 = s2.replace(/^\s*tel:\s*(?:\/\/)?\s*/i, "");
10272
+ s2 = s2.trim();
10273
+ s2 = s2.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g, " ");
10274
+ s2 = s2.replace(/[\u2010\u2011\u2012\u2013\u2014\u2015\u2212\uFE58\uFE63\uFF0D]/g, "-");
10275
+ s2 = s2.replace(/\uFF0B/g, "+");
10276
+ s2 = s2.replace(/\uFF08/g, "(");
10277
+ s2 = s2.replace(/\uFF09/g, ")");
10278
+ return s2.trim();
10279
+ }
10280
+ function isAllSameDigit(digits2) {
10281
+ return /^(\d)\1+$/.test(digits2);
10282
+ }
10283
+ function isStrictlyMonotonicStep1(digits2) {
10284
+ if (digits2.length < 8) {
10285
+ return false;
10286
+ }
10287
+ let increasing = true;
10288
+ let decreasing = true;
10289
+ for (let i = 1; i < digits2.length; i++) {
10290
+ const curr = digits2.charCodeAt(i) - 48;
10291
+ const prev = digits2.charCodeAt(i - 1) - 48;
10292
+ if (curr !== prev + 1) {
10293
+ increasing = false;
10294
+ }
10295
+ if (curr !== prev - 1) {
10296
+ decreasing = false;
10297
+ }
10298
+ }
10299
+ return increasing || decreasing;
10300
+ }
10301
+ function isValidNanpNational10(d10) {
10302
+ if (d10.length !== 10) {
10303
+ return false;
10304
+ }
10305
+ const npaFirst = d10.charCodeAt(0) - 48;
10306
+ const nxxFirst = d10.charCodeAt(3) - 48;
10307
+ if (npaFirst < 2 || npaFirst > 9) {
10308
+ return false;
10309
+ }
10310
+ if (nxxFirst < 2 || nxxFirst > 9) {
10311
+ return false;
10312
+ }
10313
+ return true;
10314
+ }
10315
+ function isPlausiblePhoneDigits(withoutExt) {
10316
+ const hasPlus = withoutExt.startsWith("+");
10317
+ const d = withoutExt.replace(/\D/g, "");
10318
+ if (d.length < 8 || d.length > 15) {
10319
+ return false;
10320
+ }
10321
+ if (isAllSameDigit(d) || isStrictlyMonotonicStep1(d)) {
10322
+ return false;
10323
+ }
10324
+ const onlyDigits = /^\d+$/.test(withoutExt);
10325
+ if (hasPlus) {
10326
+ if (d.length === 11 && d.startsWith("1")) {
10327
+ return isValidNanpNational10(d.slice(1));
10328
+ }
10329
+ return true;
10330
+ }
10331
+ if (onlyDigits) {
10332
+ if (d.length === 10) {
10333
+ return isValidNanpNational10(d);
10334
+ }
10335
+ if (d.length === 11 && d.startsWith("1")) {
10336
+ return isValidNanpNational10(d.slice(1));
10337
+ }
10338
+ if (d.length === 11 && d.startsWith("0")) {
10339
+ return true;
10340
+ }
10341
+ return false;
10342
+ }
10343
+ if (d.length === 10) {
10344
+ return isValidNanpNational10(d);
10345
+ }
10346
+ if (d.length === 11 && d.startsWith("1")) {
10347
+ return isValidNanpNational10(d.slice(1));
10348
+ }
10349
+ if (d.length === 11 && d.startsWith("0")) {
10350
+ return true;
10351
+ }
10352
+ if (d.length >= 12 && d.length <= 15) {
10353
+ return true;
10354
+ }
10355
+ return false;
10356
+ }
10357
+ function isPhoneNumber(input) {
10358
+ const trimmed = preparePhoneInput(input);
10359
+ if (trimmed === "") {
10360
+ return false;
10361
+ }
10362
+ if (!/^[+\d(]/.test(trimmed)) {
10363
+ return false;
10364
+ }
10365
+ const withoutExt = trimmed.replace(/\s*(ext|extension|x)\s*\d+$/i, "");
10366
+ if (/[a-zA-Z]/.test(withoutExt)) {
10367
+ return false;
10368
+ }
10369
+ const hasPhoneMarker = /[+()\s-]/.test(trimmed);
10370
+ const isPureDotSeparated = /^\d+(\.\d+)+$/.test(trimmed);
10371
+ if (isPureDotSeparated && !hasPhoneMarker) {
10372
+ return false;
10373
+ }
10374
+ 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;
10375
+ if (!phoneRegex.test(trimmed)) {
10376
+ return false;
10377
+ }
10378
+ return isPlausiblePhoneDigits(withoutExt);
10379
+ }
10380
+ function normalizePhoneNumber(phone) {
10381
+ const trimmed = preparePhoneInput(phone);
10382
+ const withoutExt = trimmed.replace(/\s*(ext|extension|x)\s*\d+$/i, "");
10383
+ const hasPlus = withoutExt.startsWith("+");
10384
+ const digitsOnly = withoutExt.replace(/\D/g, "");
10385
+ return hasPlus ? `+${digitsOnly}` : digitsOnly;
10386
+ }
10876
10387
 
10877
- // ../../node_modules/@sindresorhus/slugify/index.js
10878
- var decamelize = (string) => {
10879
- 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");
10880
- };
10881
- var removeMootSeparators = (string, separator) => {
10882
- const escapedSeparator = escapeStringRegexp(separator);
10883
- return string.replace(new RegExp(`${escapedSeparator}{2,}`, "g"), separator).replace(new RegExp(`^${escapedSeparator}|${escapedSeparator}$`, "g"), "");
10388
+ // ../../internal/utils/src/punycode.ts
10389
+ var maxInt = 2147483647;
10390
+ var base = 36;
10391
+ var tMin = 1;
10392
+ var tMax = 26;
10393
+ var skew = 38;
10394
+ var damp = 700;
10395
+ var initialBias = 72;
10396
+ var initialN = 128;
10397
+ var delimiter = "-";
10398
+ var regexPunycode = /^xn--/;
10399
+ var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
10400
+ var errors = {
10401
+ overflow: "Overflow: input needs wider integers to process",
10402
+ "not-basic": "Illegal input >= 0x80 (not a basic code point)",
10403
+ "invalid-input": "Invalid input"
10884
10404
  };
10885
- var buildPatternSlug = (options) => {
10886
- let negationSetPattern = "a-z\\d";
10887
- negationSetPattern += options.lowercase ? "" : "A-Z";
10888
- if (options.preserveCharacters.length > 0) {
10889
- for (const character of options.preserveCharacters) {
10890
- if (character === options.separator) {
10891
- throw new Error(`The separator character \`${options.separator}\` cannot be included in preserved characters: ${options.preserveCharacters}`);
10892
- }
10893
- negationSetPattern += escapeStringRegexp(character);
10894
- }
10405
+ var baseMinusTMin = base - tMin;
10406
+ var floor = Math.floor;
10407
+ function error(type) {
10408
+ throw new RangeError(errors[type]);
10409
+ }
10410
+ function mapDomain(domain, callback) {
10411
+ const parts = domain.split("@");
10412
+ let result = "";
10413
+ if (parts.length > 1) {
10414
+ result = parts[0] + "@";
10415
+ domain = parts[1];
10895
10416
  }
10896
- return new RegExp(`[^${negationSetPattern}]+`, "g");
10897
- };
10898
- function slugify(string, options) {
10899
- if (typeof string !== "string") {
10900
- throw new TypeError(`Expected a string, got \`${typeof string}\``);
10417
+ domain = domain.replace(regexSeparators, ".");
10418
+ const labels = domain.split(".");
10419
+ const encoded = labels.map(callback).join(".");
10420
+ return result + encoded;
10421
+ }
10422
+ function basicToDigit(codePoint) {
10423
+ if (codePoint >= 48 && codePoint < 58) {
10424
+ return 26 + (codePoint - 48);
10901
10425
  }
10902
- options = __spreadValues({
10903
- separator: "-",
10904
- lowercase: true,
10905
- decamelize: true,
10906
- customReplacements: [],
10907
- preserveLeadingUnderscore: false,
10908
- preserveTrailingDash: false,
10909
- preserveCharacters: []
10910
- }, options);
10911
- const shouldPrependUnderscore = options.preserveLeadingUnderscore && string.startsWith("_");
10912
- const shouldAppendDash = options.preserveTrailingDash && string.endsWith("-");
10913
- const customReplacements = new Map([
10914
- ...overridable_replacements_default,
10915
- ...options.customReplacements
10916
- ]);
10917
- string = transliterate(string, { customReplacements });
10918
- if (options.decamelize) {
10919
- string = decamelize(string);
10426
+ if (codePoint >= 65 && codePoint < 91) {
10427
+ return codePoint - 65;
10920
10428
  }
10921
- const patternSlug = buildPatternSlug(options);
10922
- if (options.lowercase) {
10923
- string = string.toLowerCase();
10429
+ if (codePoint >= 97 && codePoint < 123) {
10430
+ return codePoint - 97;
10924
10431
  }
10925
- string = string.replace(/([a-zA-Z\d]+)'([ts])(\s|$)/g, "$1$2$3");
10926
- string = string.replace(patternSlug, options.separator);
10927
- string = string.replace(/\\/g, "");
10928
- if (options.separator) {
10929
- string = removeMootSeparators(string, options.separator);
10432
+ return base;
10433
+ }
10434
+ function adapt(delta, numPoints, firstTime) {
10435
+ let k4 = 0;
10436
+ delta = firstTime ? floor(delta / damp) : delta >> 1;
10437
+ delta += floor(delta / numPoints);
10438
+ for (
10439
+ ;
10440
+ /* no initialization */
10441
+ delta > baseMinusTMin * tMax >> 1;
10442
+ k4 += base
10443
+ ) {
10444
+ delta = floor(delta / baseMinusTMin);
10930
10445
  }
10931
- if (shouldPrependUnderscore) {
10932
- string = `_${string}`;
10446
+ return floor(k4 + (baseMinusTMin + 1) * delta / (delta + skew));
10447
+ }
10448
+ function decode(input) {
10449
+ const output = [];
10450
+ const inputLength = input.length;
10451
+ let i = 0;
10452
+ let n2 = initialN;
10453
+ let bias2 = initialBias;
10454
+ let basic = input.lastIndexOf(delimiter);
10455
+ if (basic < 0) {
10456
+ basic = 0;
10933
10457
  }
10934
- if (shouldAppendDash) {
10935
- string = `${string}-`;
10458
+ for (let j = 0; j < basic; ++j) {
10459
+ if (input.charCodeAt(j) >= 128) {
10460
+ error("not-basic");
10461
+ }
10462
+ output.push(input.charCodeAt(j));
10936
10463
  }
10937
- return string;
10464
+ for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
10465
+ const oldi = i;
10466
+ for (let w = 1, k4 = base; ; k4 += base) {
10467
+ if (index >= inputLength) {
10468
+ error("invalid-input");
10469
+ }
10470
+ const digit = basicToDigit(input.charCodeAt(index++));
10471
+ if (digit >= base) {
10472
+ error("invalid-input");
10473
+ }
10474
+ if (digit > floor((maxInt - i) / w)) {
10475
+ error("overflow");
10476
+ }
10477
+ i += digit * w;
10478
+ const t = k4 <= bias2 ? tMin : k4 >= bias2 + tMax ? tMax : k4 - bias2;
10479
+ if (digit < t) {
10480
+ break;
10481
+ }
10482
+ const baseMinusT = base - t;
10483
+ if (w > floor(maxInt / baseMinusT)) {
10484
+ error("overflow");
10485
+ }
10486
+ w *= baseMinusT;
10487
+ }
10488
+ const out = output.length + 1;
10489
+ bias2 = adapt(i - oldi, out, oldi == 0);
10490
+ if (floor(i / out) > maxInt - n2) {
10491
+ error("overflow");
10492
+ }
10493
+ n2 += floor(i / out);
10494
+ i %= out;
10495
+ output.splice(i++, 0, n2);
10496
+ }
10497
+ return String.fromCodePoint(...output);
10498
+ }
10499
+ function toUnicode(input) {
10500
+ return mapDomain(input, function(string) {
10501
+ return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
10502
+ });
10938
10503
  }
10939
10504
 
10940
- // ../asset-parse/src/model.ts
10941
- var AssetModel = /* @__PURE__ */ ((AssetModel2) => {
10942
- AssetModel2["Addon"] = "addon";
10943
- AssetModel2["App"] = "app";
10944
- AssetModel2["Bot"] = "bot";
10945
- AssetModel2["BusinessProfile"] = "business-profile";
10946
- AssetModel2["Catalog"] = "catalog";
10947
- AssetModel2["Collection"] = "collection";
10948
- AssetModel2["Channel"] = "channel";
10949
- AssetModel2["Group"] = "group";
10950
- AssetModel2["Post"] = "post";
10951
- AssetModel2["Profile"] = "profile";
10952
- AssetModel2["Short"] = "short";
10953
- AssetModel2["Video"] = "video";
10954
- AssetModel2["Space"] = "space";
10955
- AssetModel2["Issue"] = "issue";
10956
- AssetModel2["PullRequest"] = "pull-request";
10957
- AssetModel2["Discussion"] = "discussion";
10958
- AssetModel2["Repository"] = "repository";
10959
- AssetModel2["Article"] = "Article";
10960
- AssetModel2["Comment"] = "comment";
10961
- AssetModel2["List"] = "list";
10962
- AssetModel2["Subreddit"] = "subreddit";
10963
- AssetModel2["Community"] = "community";
10964
- AssetModel2["MiniApp"] = "mini-app";
10965
- AssetModel2["Developer"] = "developer";
10966
- return AssetModel2;
10967
- })(AssetModel || {});
10968
- function isUrl(input) {
10505
+ // ../../internal/utils/src/url.ts
10506
+ function isEmail(input) {
10969
10507
  if (input.trim() === "") {
10970
10508
  return false;
10971
10509
  }
10972
- if (input.startsWith("/") || input.startsWith("#") || input.startsWith("?") || input.startsWith(".") || !input.includes(".")) {
10973
- return false;
10974
- }
10975
- return URL.canParse(input) || URL.canParse(`https://${input}`);
10510
+ const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
10511
+ return emailRegex.test(input);
10976
10512
  }
10977
- function getNormalizedUrl(input) {
10513
+ function removeHttpProtocol(input) {
10514
+ return input.replace(/^https?:\/\//, "");
10515
+ }
10516
+ function stripDomainWildcardPrefix(domain) {
10517
+ const trimmedDomain = domain.trim();
10518
+ const strippedDomain = trimmedDomain.startsWith("*.") ? trimmedDomain.slice(2) : trimmedDomain;
10519
+ return strippedDomain.length > 0 ? strippedDomain : null;
10520
+ }
10521
+ function getDefangedUrl(input) {
10978
10522
  if (!isUrl(input)) {
10979
- throw new Error(`Invalid URL: ${input}`);
10523
+ console.warn(`[getDefangedUrl] Invalid URL: ${input}, returning input as-is`);
10524
+ return input;
10980
10525
  }
10981
- let url;
10982
- try {
10983
- url = new URL(input);
10984
- } catch (e4) {
10985
- try {
10986
- url = new URL(`https://${input}`);
10987
- } catch (e5) {
10988
- throw new Error(`Invalid URL: ${input}`);
10989
- }
10526
+ return input.replace(/\./g, "[.]").replace(/(https:\/\/)/g, "hxxps://").replace(/(http:\/\/)/g, "hxxp://").replace(/:\/\//g, "[://]");
10527
+ }
10528
+ function getRefangedUrl(input) {
10529
+ return input.replace(/hxxps/gi, "https").replace(/hxxp/gi, "http").replace(/\[:\/{2}\]/g, "://").replace(/\[\.\]/g, ".");
10530
+ }
10531
+ function containsPunycode(url) {
10532
+ return url.indexOf("xn--") !== -1;
10533
+ }
10534
+ function toUnicode2(url) {
10535
+ return toUnicode(url);
10536
+ }
10537
+ function convertHttpsToHttp(url) {
10538
+ if (url.startsWith("https://")) {
10539
+ const httpUrl = new URL(url);
10540
+ httpUrl.protocol = "http:";
10541
+ return httpUrl.toString();
10990
10542
  }
10991
- const normalizedUrl = normalizeUrl(url.toString(), {
10992
- defaultProtocol: "https"
10993
- });
10994
- try {
10995
- return new URL(normalizedUrl);
10996
- } catch (e4) {
10997
- throw new Error(`Invalid URL: ${input}`);
10543
+ throw new Error(`URL is not HTTPS: ${url}`);
10544
+ }
10545
+ function generateCanonicalIPFSUrl(content) {
10546
+ if (!content) {
10547
+ return content;
10998
10548
  }
10549
+ if (content.includes("ipfs.io")) {
10550
+ return content;
10551
+ }
10552
+ if (content.startsWith("Qm") || content.startsWith("bafy")) {
10553
+ return `ipfs.io/ipfs/${content}`;
10554
+ }
10555
+ return content;
10999
10556
  }
11000
- var ensureHttpsPrefix = (url) => {
11001
- if (!url.startsWith("http")) {
11002
- return `https://${url}`;
10557
+ function isWalrusSite(content) {
10558
+ return content.includes(".walrus.site") || content.includes(".walrus.host") || content.includes(".wal.app") || content.includes(".wal.site");
10559
+ }
10560
+ function getFaviconUrl(content) {
10561
+ const normalizedUrl = getNormalizedUrl(content);
10562
+ return `https://icons.duckduckgo.com/ip3/${normalizedUrl.hostname}.ico`;
10563
+ }
10564
+ function sanitizeHttpUrl(value) {
10565
+ if (typeof value !== "string" || value.length === 0) {
10566
+ return null;
11003
10567
  }
11004
- return url.replace(/^https?:\/{1,2}/, "https://");
11005
- };
11006
- function getHostname(input) {
11007
10568
  try {
11008
- return getNormalizedUrl(input).hostname;
10569
+ const parsed = new URL(value);
10570
+ if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
10571
+ return null;
10572
+ }
10573
+ return parsed.toString();
11009
10574
  } catch (e4) {
11010
10575
  return null;
11011
10576
  }
11012
10577
  }
11013
- function getParentDomains(input) {
11014
- const domain = getHostname(input);
11015
- if (!domain) {
11016
- return [];
11017
- }
11018
- const subdomain = getSubdomain(domain, { mixedInputs: false });
11019
- if (!subdomain) {
11020
- return [domain];
11021
- }
11022
- const domainWithSuffix = getDomain(domain, { mixedInputs: false });
11023
- if (!domainWithSuffix) {
11024
- return [];
10578
+ var URL_REGEX = /https?:\/\/[^\s"'<>\])]*/g;
10579
+
10580
+ // ../../internal/utils/src/email.ts
10581
+ var email_exports = {};
10582
+ __export(email_exports, {
10583
+ extractTextFromGmailPayload: () => extractTextFromGmailPayload,
10584
+ getDomainFromEmail: () => getDomainFromEmail,
10585
+ getNameFromEmail: () => getNameFromEmail
10586
+ });
10587
+ function getDomainFromEmail(email) {
10588
+ return email.split("@")[1];
10589
+ }
10590
+ function getNameFromEmail(email) {
10591
+ return email.split("@")[0];
10592
+ }
10593
+ function extractTextFromGmailPayload(payload) {
10594
+ var _a;
10595
+ if (!payload) return "";
10596
+ if ((_a = payload.body) == null ? void 0 : _a.data) {
10597
+ if (payload.mimeType === "text/plain" || payload.mimeType === "text/html") {
10598
+ return Buffer.from(payload.body.data, "base64url").toString("utf-8");
10599
+ }
11025
10600
  }
11026
- const parentDomains = [domainWithSuffix];
11027
- const parentDomainParts = subdomain.split(".");
11028
- for (let i = parentDomainParts.length - 1; i >= 0; i--) {
11029
- const parentDomainPart = parentDomainParts.slice(i).join(".");
11030
- parentDomains.push(`${parentDomainPart}.${domainWithSuffix}`);
10601
+ if (payload.parts) {
10602
+ if (payload.mimeType === "multipart/alternative") {
10603
+ const plainTextPart = payload.parts.find((part) => part.mimeType === "text/plain");
10604
+ if (plainTextPart) {
10605
+ return extractTextFromGmailPayload(plainTextPart);
10606
+ }
10607
+ const htmlPart = payload.parts.find((part) => part.mimeType === "text/html");
10608
+ if (htmlPart) {
10609
+ return extractTextFromGmailPayload(htmlPart);
10610
+ }
10611
+ for (const part of payload.parts) {
10612
+ const text = extractTextFromGmailPayload(part);
10613
+ if (text) return text;
10614
+ }
10615
+ }
10616
+ return payload.parts.map((part) => extractTextFromGmailPayload(part)).join("\n");
11031
10617
  }
11032
- return parentDomains.reverse();
10618
+ return "";
11033
10619
  }
11034
- function trimDomainToLevels(domain, options = { levels: 4 }) {
10620
+
10621
+ // ../../internal/utils/src/vercel.ts
10622
+ var vercel_exports = {};
10623
+ __export(vercel_exports, {
10624
+ checkVercelEnv: () => checkVercelEnv
10625
+ });
10626
+ var checkVercelEnv = ({ envs }) => {
11035
10627
  var _a;
11036
- const parsed = parse$1(domain);
11037
- const eTLDPlusOne = (_a = parsed.domain) != null ? _a : "";
11038
- const subdomains = domain.replace(/https?:\/\/(www\.)?/, "").split(".");
11039
- const eTLDPlusOneIndex = subdomains.findIndex(
11040
- (_, i) => subdomains.slice(i).join(".") === eTLDPlusOne
11041
- );
11042
- const trimmedSubdomains = subdomains.slice(Math.max(eTLDPlusOneIndex - (options.levels - 1), 0)).join(".");
11043
- return trimmedSubdomains;
11044
- }
10628
+ const vercelEnv = (_a = process.env.VERCEL_ENV) != null ? _a : "development";
10629
+ if (!envs.includes(vercelEnv)) {
10630
+ return {
10631
+ ok: false,
10632
+ message: `Vercel environment is ${vercelEnv}, but expected ${envs.join(" or ")}`
10633
+ };
10634
+ }
10635
+ return { ok: true, message: "" };
10636
+ };
11045
10637
 
11046
- // ../asset-parse/src/phone.ts
11047
- var phone_exports = {};
11048
- __export(phone_exports, {
11049
- PHONE_NUMBER_REGEX: () => PHONE_NUMBER_REGEX,
11050
- isPhoneNumber: () => isPhoneNumber,
11051
- normalizePhoneNumber: () => normalizePhoneNumber
10638
+ // ../../internal/utils/src/delay.ts
10639
+ var delay_exports = {};
10640
+ __export(delay_exports, {
10641
+ delay: () => delay
11052
10642
  });
11053
- 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;
11054
- function preparePhoneInput(input) {
11055
- let s2 = input.trim();
11056
- s2 = s2.replace(/^\s*tel:\s*(?:\/\/)?\s*/i, "");
11057
- s2 = s2.trim();
11058
- s2 = s2.replace(/[\u00A0\u2000-\u200A\u202F\u205F\u3000]/g, " ");
11059
- s2 = s2.replace(/[\u2010\u2011\u2012\u2013\u2014\u2015\u2212\uFE58\uFE63\uFF0D]/g, "-");
11060
- s2 = s2.replace(/\uFF0B/g, "+");
11061
- s2 = s2.replace(/\uFF08/g, "(");
11062
- s2 = s2.replace(/\uFF09/g, ")");
11063
- return s2.trim();
10643
+ var delay = (ms) => {
10644
+ return new Promise((resolve) => setTimeout(resolve, ms));
10645
+ };
10646
+
10647
+ // ../../internal/utils/src/whois.ts
10648
+ var whois_exports = {};
10649
+ __export(whois_exports, {
10650
+ extractWhoisCountry: () => extractWhoisCountry,
10651
+ extractWhoisPayload: () => extractWhoisPayload,
10652
+ normalizeRegistrar: () => normalizeRegistrar
10653
+ });
10654
+ function extractWhoisPayload(raw) {
10655
+ var _a;
10656
+ const first = Array.isArray(raw) ? (_a = raw.find((entry) => entry !== null && typeof entry === "object")) != null ? _a : {} : raw;
10657
+ if (!first || typeof first !== "object") {
10658
+ return {};
10659
+ }
10660
+ const maybeData = first.data;
10661
+ if (maybeData && typeof maybeData === "object" && !Array.isArray(maybeData)) {
10662
+ return maybeData;
10663
+ }
10664
+ return first;
11064
10665
  }
11065
- function isAllSameDigit(digits2) {
11066
- return /^(\d)\1+$/.test(digits2);
10666
+ var WHOIS_EMPTY_VALUES = /* @__PURE__ */ new Set(["", "none", "null"]);
10667
+ var WHOIS_COUNTRY_CODE_KEY_ALIASES = /* @__PURE__ */ new Set(["countrycode", "registrantcountrycode"]);
10668
+ var WHOIS_COUNTRY_KEY_ALIASES = /* @__PURE__ */ new Set([
10669
+ "country",
10670
+ "countryname",
10671
+ "registrantcountry",
10672
+ "registrantcountryname"
10673
+ ]);
10674
+ function normalizeWhoisKey(key) {
10675
+ return key.toLowerCase().replace(/[^a-z0-9]/g, "");
11067
10676
  }
11068
- function isStrictlyMonotonicStep1(digits2) {
11069
- if (digits2.length < 8) {
11070
- return false;
10677
+ function normalizeRegistrar(value) {
10678
+ return value.toLowerCase().replace(/[^a-z0-9]/g, "");
10679
+ }
10680
+ function parseWhoisString(value) {
10681
+ if (typeof value !== "string") {
10682
+ return void 0;
11071
10683
  }
11072
- let increasing = true;
11073
- let decreasing = true;
11074
- for (let i = 1; i < digits2.length; i++) {
11075
- const curr = digits2.charCodeAt(i) - 48;
11076
- const prev = digits2.charCodeAt(i - 1) - 48;
11077
- if (curr !== prev + 1) {
11078
- increasing = false;
10684
+ const trimmedValue = value.trim();
10685
+ if (WHOIS_EMPTY_VALUES.has(trimmedValue.toLowerCase())) {
10686
+ return void 0;
10687
+ }
10688
+ return trimmedValue;
10689
+ }
10690
+ function extractWhoisFieldByAliases(payload, aliases) {
10691
+ for (const [key, value] of Object.entries(payload)) {
10692
+ if (!aliases.has(normalizeWhoisKey(key))) {
10693
+ continue;
11079
10694
  }
11080
- if (curr !== prev - 1) {
11081
- decreasing = false;
10695
+ const parsedValue = parseWhoisString(value);
10696
+ if (parsedValue) {
10697
+ return parsedValue;
11082
10698
  }
11083
10699
  }
11084
- return increasing || decreasing;
10700
+ return void 0;
11085
10701
  }
11086
- function isValidNanpNational10(d10) {
11087
- if (d10.length !== 10) {
11088
- return false;
11089
- }
11090
- const npaFirst = d10.charCodeAt(0) - 48;
11091
- const nxxFirst = d10.charCodeAt(3) - 48;
11092
- if (npaFirst < 2 || npaFirst > 9) {
11093
- return false;
11094
- }
11095
- if (nxxFirst < 2 || nxxFirst > 9) {
11096
- return false;
10702
+ function extractWhoisCountry(payload) {
10703
+ const countryCode = extractWhoisFieldByAliases(payload, WHOIS_COUNTRY_CODE_KEY_ALIASES);
10704
+ const country = extractWhoisFieldByAliases(payload, WHOIS_COUNTRY_KEY_ALIASES);
10705
+ return {
10706
+ countryCode: countryCode != null ? countryCode : void 0,
10707
+ country: country != null ? country : void 0
10708
+ };
10709
+ }
10710
+
10711
+ // ../../internal/utils/src/safe-preview.ts
10712
+ var safe_preview_exports = {};
10713
+ __export(safe_preview_exports, {
10714
+ buildSafePreviewUrl: () => buildSafePreviewUrl,
10715
+ normalizeSafeNavigationTarget: () => normalizeSafeNavigationTarget
10716
+ });
10717
+ var SAFE_NAVIGATION_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
10718
+ var PREVIEW_PATH = "/preview";
10719
+ var URL_BASE = "https://app.chainpatrol.io";
10720
+ function normalizeSafeNavigationTarget(target) {
10721
+ const normalizedTarget = getNormalizedUrl(target);
10722
+ if (!SAFE_NAVIGATION_PROTOCOLS.has(normalizedTarget.protocol)) {
10723
+ throw new Error(`Unsupported URL protocol: ${normalizedTarget.protocol}`);
11097
10724
  }
11098
- return true;
10725
+ return normalizedTarget;
11099
10726
  }
11100
- function isPlausiblePhoneDigits(withoutExt) {
11101
- const hasPlus = withoutExt.startsWith("+");
11102
- const d = withoutExt.replace(/\D/g, "");
11103
- if (d.length < 8 || d.length > 15) {
11104
- return false;
10727
+ function buildSafePreviewUrl({
10728
+ target,
10729
+ assetId,
10730
+ policy
10731
+ }) {
10732
+ const normalizedTarget = normalizeSafeNavigationTarget(target);
10733
+ const previewUrl = new URL(PREVIEW_PATH, URL_BASE);
10734
+ previewUrl.searchParams.set("target", normalizedTarget.toString());
10735
+ if (Number.isInteger(assetId) && assetId && assetId >= 1) {
10736
+ previewUrl.searchParams.set("asset_id", String(assetId));
11105
10737
  }
11106
- if (isAllSameDigit(d) || isStrictlyMonotonicStep1(d)) {
11107
- return false;
10738
+ if (policy) {
10739
+ previewUrl.searchParams.set("policy", policy);
11108
10740
  }
11109
- const onlyDigits = /^\d+$/.test(withoutExt);
11110
- if (hasPlus) {
11111
- if (d.length === 11 && d.startsWith("1")) {
11112
- return isValidNanpNational10(d.slice(1));
10741
+ return `${previewUrl.pathname}?${previewUrl.searchParams.toString()}`;
10742
+ }
10743
+
10744
+ // ../../internal/utils/src/parse.ts
10745
+ var parse_exports = {};
10746
+ __export(parse_exports, {
10747
+ parseTerms: () => parseTerms,
10748
+ stringifyTerms: () => stringifyTerms
10749
+ });
10750
+ function parseTerms(terms, {
10751
+ forceExact = false
10752
+ } = {}) {
10753
+ if (!terms) return [];
10754
+ return terms.split(",").map((term) => {
10755
+ const trimmed = term.trim();
10756
+ if (!trimmed) return null;
10757
+ const isWrappedExact = trimmed.startsWith("*") && trimmed.endsWith("*") && trimmed.length > 2;
10758
+ if (isWrappedExact) {
10759
+ return {
10760
+ value: trimmed.slice(1, -1).toLowerCase(),
10761
+ type: "exact"
10762
+ };
10763
+ } else {
10764
+ return {
10765
+ value: trimmed.toLowerCase(),
10766
+ type: forceExact ? "exact" : "loose"
10767
+ };
11113
10768
  }
11114
- return true;
10769
+ }).filter((term) => term !== null);
10770
+ }
10771
+ function stringifyTerms(parsedTerms) {
10772
+ return parsedTerms.map((term) => term.type === "exact" ? `*${term.value}*` : term.value).join(", ");
10773
+ }
10774
+
10775
+ // ../../internal/utils/src/brand-pattern.ts
10776
+ var brand_pattern_exports = {};
10777
+ __export(brand_pattern_exports, {
10778
+ anyPatternMatches: () => anyPatternMatches,
10779
+ compileBrandPattern: () => compileBrandPattern,
10780
+ countPatternMatches: () => countPatternMatches,
10781
+ findMatchingPatterns: () => findMatchingPatterns
10782
+ });
10783
+ var DEFAULT_MAX_MATCHES = 50;
10784
+ function compileBrandPattern(input) {
10785
+ var _a;
10786
+ try {
10787
+ return new RegExp(input.pattern, (_a = input.flags) != null ? _a : void 0);
10788
+ } catch (e4) {
10789
+ return null;
11115
10790
  }
11116
- if (onlyDigits) {
11117
- if (d.length === 10) {
11118
- return isValidNanpNational10(d);
11119
- }
11120
- if (d.length === 11 && d.startsWith("1")) {
11121
- return isValidNanpNational10(d.slice(1));
11122
- }
11123
- if (d.length === 11 && d.startsWith("0")) {
10791
+ }
10792
+ function anyPatternMatches(content, patterns, kind) {
10793
+ for (const input of patterns) {
10794
+ if (input.kind !== kind) continue;
10795
+ const regex = compileBrandPattern(input);
10796
+ if (!regex) continue;
10797
+ if (regex.test(content)) {
11124
10798
  return true;
11125
10799
  }
11126
- return false;
11127
10800
  }
11128
- if (d.length === 10) {
11129
- return isValidNanpNational10(d);
10801
+ return false;
10802
+ }
10803
+ function findMatchingPatterns(content, patterns, kind) {
10804
+ const matched = [];
10805
+ for (const input of patterns) {
10806
+ if (input.kind !== kind) continue;
10807
+ const regex = compileBrandPattern(input);
10808
+ if (!regex) continue;
10809
+ if (regex.test(content)) {
10810
+ matched.push(input);
10811
+ }
11130
10812
  }
11131
- if (d.length === 11 && d.startsWith("1")) {
11132
- return isValidNanpNational10(d.slice(1));
10813
+ return matched;
10814
+ }
10815
+ function countPatternMatches(content, pattern, maxMatches = DEFAULT_MAX_MATCHES) {
10816
+ const compiled = compileBrandPattern(pattern);
10817
+ if (!compiled) return 0;
10818
+ const flags = compiled.flags.includes("g") ? compiled.flags : `${compiled.flags}g`;
10819
+ const globalRegex = new RegExp(compiled.source, flags);
10820
+ let count = 0;
10821
+ let match2;
10822
+ while ((match2 = globalRegex.exec(content)) !== null) {
10823
+ count += 1;
10824
+ if (count >= maxMatches) break;
10825
+ if (match2[0].length === 0) globalRegex.lastIndex += 1;
11133
10826
  }
11134
- if (d.length === 11 && d.startsWith("0")) {
11135
- return true;
10827
+ return count;
10828
+ }
10829
+
10830
+ // ../../internal/utils/src/text.ts
10831
+ var text_exports = {};
10832
+ __export(text_exports, {
10833
+ HOMOGLYPH_MAPPINGS: () => HOMOGLYPH_MAPPINGS,
10834
+ LETTER_TO_HOMOGLYPH_MAPPINGS: () => LETTER_TO_HOMOGLYPH_MAPPINGS,
10835
+ generateHomoglyphSearchTerms: () => generateHomoglyphSearchTerms,
10836
+ normalizeHomoglyphs: () => normalizeHomoglyphs
10837
+ });
10838
+ var HOMOGLYPH_MAPPINGS = {
10839
+ "0": "o",
10840
+ "1": "i",
10841
+ "3": "e",
10842
+ "4": "a",
10843
+ "5": "s",
10844
+ "7": "t",
10845
+ "8": "b"
10846
+ };
10847
+ var LETTER_TO_HOMOGLYPH_MAPPINGS = {
10848
+ a: ["4", "\u0430"],
10849
+ b: ["8", "6"],
10850
+ c: ["\u0441"],
10851
+ e: ["3", "\u0435"],
10852
+ g: ["9"],
10853
+ i: ["1", "l", "\u0456"],
10854
+ l: ["1"],
10855
+ o: ["0", "\u043E"],
10856
+ s: ["5", "\u0455"],
10857
+ t: ["7"],
10858
+ x: ["\u0445"],
10859
+ z: ["2"]
10860
+ };
10861
+ var DEFAULT_MAX_HOMOGLYPH_VARIANTS = 20;
10862
+ function isCyrillic(char) {
10863
+ return char.charCodeAt(0) > 127;
10864
+ }
10865
+ function buildReplacementOps(term) {
10866
+ const ops = [];
10867
+ for (let i = 0; i < term.length; i++) {
10868
+ const homoglyphs = LETTER_TO_HOMOGLYPH_MAPPINGS[term[i]];
10869
+ if (!homoglyphs) continue;
10870
+ for (const replacement of homoglyphs) {
10871
+ ops.push({ index: i, replacement });
10872
+ }
11136
10873
  }
11137
- if (d.length >= 12 && d.length <= 15) {
11138
- return true;
10874
+ return ops;
10875
+ }
10876
+ function applyOps(term, ops, selected) {
10877
+ const chars = Array.from(term);
10878
+ for (const idx of selected) {
10879
+ chars[ops[idx].index] = ops[idx].replacement;
11139
10880
  }
11140
- return false;
10881
+ return chars.join("");
11141
10882
  }
11142
- function isPhoneNumber(input) {
11143
- const trimmed = preparePhoneInput(input);
11144
- if (trimmed === "") {
10883
+ function generateCombinations(ops, opIndices, term, maxVariants, addFn, variants) {
10884
+ const generate = (startIdx, depth, selected, usedPositions) => {
10885
+ if (selected.length === depth) return addFn(applyOps(term, ops, selected));
10886
+ for (let i = startIdx; i < opIndices.length && variants.length < maxVariants; i++) {
10887
+ const opIdx = opIndices[i];
10888
+ if (usedPositions.has(ops[opIdx].index)) continue;
10889
+ selected.push(opIdx);
10890
+ usedPositions.add(ops[opIdx].index);
10891
+ if (generate(i + 1, depth, selected, usedPositions)) return true;
10892
+ selected.pop();
10893
+ usedPositions.delete(ops[opIdx].index);
10894
+ }
11145
10895
  return false;
10896
+ };
10897
+ for (let depth = 2; depth <= opIndices.length && variants.length < maxVariants; depth++) {
10898
+ if (generate(0, depth, [], /* @__PURE__ */ new Set())) break;
11146
10899
  }
11147
- if (!/^[+\d(]/.test(trimmed)) {
11148
- return false;
10900
+ }
10901
+ function generateHomoglyphSearchTerms(term, maxVariants = DEFAULT_MAX_HOMOGLYPH_VARIANTS) {
10902
+ if (term.length === 0 || maxVariants <= 0) return [];
10903
+ const lowerTerm = term.toLowerCase();
10904
+ const seen = /* @__PURE__ */ new Set();
10905
+ const variants = [];
10906
+ const add = (v) => {
10907
+ if (v === lowerTerm || seen.has(v)) return false;
10908
+ seen.add(v);
10909
+ variants.push(v);
10910
+ return variants.length >= maxVariants;
10911
+ };
10912
+ const allOps = buildReplacementOps(lowerTerm);
10913
+ for (let i = 0; i < allOps.length && variants.length < maxVariants; i++) {
10914
+ add(applyOps(lowerTerm, allOps, [i]));
11149
10915
  }
11150
- const withoutExt = trimmed.replace(/\s*(ext|extension|x)\s*\d+$/i, "");
11151
- if (/[a-zA-Z]/.test(withoutExt)) {
11152
- return false;
10916
+ if (variants.length < maxVariants) {
10917
+ const cyrillicComposite = lowerTerm.split("").map((char) => {
10918
+ var _a;
10919
+ const homoglyphs = LETTER_TO_HOMOGLYPH_MAPPINGS[char];
10920
+ return (_a = homoglyphs == null ? void 0 : homoglyphs.find((h) => isCyrillic(h))) != null ? _a : char;
10921
+ }).join("");
10922
+ add(cyrillicComposite);
11153
10923
  }
11154
- const hasPhoneMarker = /[+()\s-]/.test(trimmed);
11155
- const isPureDotSeparated = /^\d+(\.\d+)+$/.test(trimmed);
11156
- if (isPureDotSeparated && !hasPhoneMarker) {
11157
- return false;
10924
+ const cyrillicOpIndices = allOps.map((op, i) => isCyrillic(op.replacement) ? i : -1).filter((i) => i >= 0);
10925
+ if (variants.length < maxVariants && cyrillicOpIndices.length >= 2) {
10926
+ generateCombinations(
10927
+ allOps,
10928
+ cyrillicOpIndices,
10929
+ lowerTerm,
10930
+ maxVariants,
10931
+ add,
10932
+ variants
10933
+ );
11158
10934
  }
11159
- 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;
11160
- if (!phoneRegex.test(trimmed)) {
11161
- return false;
10935
+ if (variants.length < maxVariants) {
10936
+ const allOpIndices = allOps.map((_, i) => i);
10937
+ generateCombinations(allOps, allOpIndices, lowerTerm, maxVariants, add, variants);
11162
10938
  }
11163
- return isPlausiblePhoneDigits(withoutExt);
10939
+ return variants;
11164
10940
  }
11165
- function normalizePhoneNumber(phone) {
11166
- const trimmed = preparePhoneInput(phone);
11167
- const withoutExt = trimmed.replace(/\s*(ext|extension|x)\s*\d+$/i, "");
11168
- const hasPlus = withoutExt.startsWith("+");
11169
- const digitsOnly = withoutExt.replace(/\D/g, "");
11170
- return hasPlus ? `+${digitsOnly}` : digitsOnly;
10941
+ function normalizeHomoglyphs(text, customMappings = {}) {
10942
+ const mappings = __spreadValues(__spreadValues({}, HOMOGLYPH_MAPPINGS), customMappings);
10943
+ return text.toLowerCase().split("").map((char) => mappings[char] || char).join("");
11171
10944
  }
11172
10945
 
11173
- // ../../internal/utils/src/punycode.ts
11174
- var maxInt = 2147483647;
11175
- var base = 36;
11176
- var tMin = 1;
11177
- var tMax = 26;
11178
- var skew = 38;
11179
- var damp = 700;
11180
- var initialBias = 72;
11181
- var initialN = 128;
11182
- var delimiter = "-";
11183
- var regexPunycode = /^xn--/;
11184
- var regexSeparators = /[\x2E\u3002\uFF0E\uFF61]/g;
11185
- var errors = {
11186
- overflow: "Overflow: input needs wider integers to process",
11187
- "not-basic": "Illegal input >= 0x80 (not a basic code point)",
11188
- "invalid-input": "Invalid input"
11189
- };
11190
- var baseMinusTMin = base - tMin;
11191
- var floor = Math.floor;
11192
- function error(type) {
11193
- throw new RangeError(errors[type]);
11194
- }
11195
- function mapDomain(domain, callback) {
11196
- const parts = domain.split("@");
11197
- let result = "";
11198
- if (parts.length > 1) {
11199
- result = parts[0] + "@";
11200
- domain = parts[1];
10946
+ // ../../internal/utils/src/format.ts
10947
+ var format_exports = {};
10948
+ __export(format_exports, {
10949
+ formatCompactNumber: () => formatCompactNumber,
10950
+ formatFileSize: () => formatFileSize
10951
+ });
10952
+ function formatCompactNumber(num3, options = {}) {
10953
+ const { decimals = 1, fallback = "-" } = options;
10954
+ if (num3 === void 0 || num3 === null) {
10955
+ return fallback;
11201
10956
  }
11202
- domain = domain.replace(regexSeparators, ".");
11203
- const labels = domain.split(".");
11204
- const encoded = labels.map(callback).join(".");
11205
- return result + encoded;
10957
+ if (num3 >= 1e9) {
10958
+ return `${(num3 / 1e9).toFixed(decimals)}B`;
10959
+ }
10960
+ if (num3 >= 1e6) {
10961
+ return `${(num3 / 1e6).toFixed(decimals)}M`;
10962
+ }
10963
+ if (num3 >= 1e3) {
10964
+ return `${(num3 / 1e3).toFixed(decimals)}K`;
10965
+ }
10966
+ return num3.toString();
11206
10967
  }
11207
- function basicToDigit(codePoint) {
11208
- if (codePoint >= 48 && codePoint < 58) {
11209
- return 26 + (codePoint - 48);
10968
+ function formatFileSize(bytes, options = {}) {
10969
+ const { decimals = 1, binary = true, showUnknown = true } = options;
10970
+ if (bytes === null || bytes === void 0 || bytes === "") {
10971
+ return showUnknown ? "Unknown" : "0 B";
11210
10972
  }
11211
- if (codePoint >= 65 && codePoint < 91) {
11212
- return codePoint - 65;
10973
+ const size = typeof bytes === "string" ? parseInt(bytes, 10) : bytes;
10974
+ if (isNaN(size) || size < 0) {
10975
+ return showUnknown ? "Unknown" : "0 B";
11213
10976
  }
11214
- if (codePoint >= 97 && codePoint < 123) {
11215
- return codePoint - 97;
10977
+ if (size === 0) {
10978
+ return "0 B";
11216
10979
  }
11217
- return base;
11218
- }
11219
- function adapt(delta, numPoints, firstTime) {
11220
- let k4 = 0;
11221
- delta = firstTime ? floor(delta / damp) : delta >> 1;
11222
- delta += floor(delta / numPoints);
11223
- for (
11224
- ;
11225
- /* no initialization */
11226
- delta > baseMinusTMin * tMax >> 1;
11227
- k4 += base
11228
- ) {
11229
- delta = floor(delta / baseMinusTMin);
10980
+ const unit = binary ? 1024 : 1e3;
10981
+ const units = binary ? ["B", "KB", "MB", "GB", "TB", "PB"] : ["B", "kB", "MB", "GB", "TB", "PB"];
10982
+ const unitIndex = Math.floor(Math.log(size) / Math.log(unit));
10983
+ const finalUnitIndex = Math.min(unitIndex, units.length - 1);
10984
+ const value = size / Math.pow(unit, finalUnitIndex);
10985
+ if (finalUnitIndex === 0) {
10986
+ return `${size} B`;
11230
10987
  }
11231
- return floor(k4 + (baseMinusTMin + 1) * delta / (delta + skew));
10988
+ return `${value.toFixed(decimals)} ${units[finalUnitIndex]}`;
11232
10989
  }
11233
- function decode(input) {
11234
- const output = [];
11235
- const inputLength = input.length;
11236
- let i = 0;
11237
- let n2 = initialN;
11238
- let bias2 = initialBias;
11239
- let basic = input.lastIndexOf(delimiter);
11240
- if (basic < 0) {
11241
- basic = 0;
11242
- }
11243
- for (let j = 0; j < basic; ++j) {
11244
- if (input.charCodeAt(j) >= 128) {
11245
- error("not-basic");
11246
- }
11247
- output.push(input.charCodeAt(j));
10990
+
10991
+ // ../../internal/utils/src/social-profile-url.ts
10992
+ var social_profile_url_exports = {};
10993
+ __export(social_profile_url_exports, {
10994
+ LINKEDIN_PROFILE_URL_PATTERN: () => LINKEDIN_PROFILE_URL_PATTERN,
10995
+ TWITTER_PROFILE_URL_PATTERN: () => TWITTER_PROFILE_URL_PATTERN,
10996
+ isLinkedInProfileUrl: () => isLinkedInProfileUrl,
10997
+ isSupportedSocialProfileUrl: () => isSupportedSocialProfileUrl,
10998
+ isTwitterProfileUrl: () => isTwitterProfileUrl,
10999
+ parseLinkedInProfileUrl: () => parseLinkedInProfileUrl
11000
+ });
11001
+ var TWITTER_PROFILE_URL_PATTERN = /^https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/?#]+\/?(?:[?#].*)?$/i;
11002
+ var LINKEDIN_PROFILE_URL_PATTERN = /^https?:\/\/(?:[a-z]{2,3}\.)?linkedin\.com\/(in|company|school)\/([^/?#]+)/i;
11003
+ function isTwitterProfileUrl(url) {
11004
+ return TWITTER_PROFILE_URL_PATTERN.test(url);
11005
+ }
11006
+ function isLinkedInProfileUrl(url) {
11007
+ return LINKEDIN_PROFILE_URL_PATTERN.test(url);
11008
+ }
11009
+ function isSupportedSocialProfileUrl(url) {
11010
+ return isTwitterProfileUrl(url) || isLinkedInProfileUrl(url);
11011
+ }
11012
+ function humanizeLinkedInHandle(handle) {
11013
+ const withoutTrailingDigits = handle.replace(/-[0-9a-f]{6,}$/i, "");
11014
+ return withoutTrailingDigits.split("-").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
11015
+ }
11016
+ function parseLinkedInProfileUrl(url) {
11017
+ var _a;
11018
+ const match2 = url.match(LINKEDIN_PROFILE_URL_PATTERN);
11019
+ if (!match2) return null;
11020
+ const pathSegment = (_a = match2[1]) == null ? void 0 : _a.toLowerCase();
11021
+ const rawHandle = match2[2];
11022
+ if (!pathSegment || !rawHandle) return null;
11023
+ let handle;
11024
+ try {
11025
+ handle = decodeURIComponent(rawHandle).trim();
11026
+ } catch (e4) {
11027
+ return null;
11248
11028
  }
11249
- for (let index = basic > 0 ? basic + 1 : 0; index < inputLength; ) {
11250
- const oldi = i;
11251
- for (let w = 1, k4 = base; ; k4 += base) {
11252
- if (index >= inputLength) {
11253
- error("invalid-input");
11254
- }
11255
- const digit = basicToDigit(input.charCodeAt(index++));
11256
- if (digit >= base) {
11257
- error("invalid-input");
11258
- }
11259
- if (digit > floor((maxInt - i) / w)) {
11260
- error("overflow");
11261
- }
11262
- i += digit * w;
11263
- const t = k4 <= bias2 ? tMin : k4 >= bias2 + tMax ? tMax : k4 - bias2;
11264
- if (digit < t) {
11265
- break;
11266
- }
11267
- const baseMinusT = base - t;
11268
- if (w > floor(maxInt / baseMinusT)) {
11269
- error("overflow");
11270
- }
11271
- w *= baseMinusT;
11272
- }
11273
- const out = output.length + 1;
11274
- bias2 = adapt(i - oldi, out, oldi == 0);
11275
- if (floor(i / out) > maxInt - n2) {
11276
- error("overflow");
11277
- }
11278
- n2 += floor(i / out);
11279
- i %= out;
11280
- output.splice(i++, 0, n2);
11029
+ if (!handle) return null;
11030
+ const name = humanizeLinkedInHandle(handle) || handle;
11031
+ const profileUrl = `https://www.linkedin.com/${pathSegment}/${handle}`;
11032
+ return { pathSegment, handle, name, profileUrl };
11033
+ }
11034
+
11035
+ // ../../internal/validation/src/public/detection/configs-create.ts
11036
+ z.object({
11037
+ slug: z.string().min(1).optional().describe(
11038
+ "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."
11039
+ ),
11040
+ source: z.nativeEnum(ThreatDetectionSourceKey).describe(
11041
+ "Detection source key, from `GET /detection/sources`. The source must support the `organization` scope; global-only sources cannot be configured per organization."
11042
+ ),
11043
+ status: z.nativeEnum(ThreatDetectionConfigStatus).default(ThreatDetectionConfigStatus.ENABLED).describe("Status to create the config with. Defaults to `ENABLED`."),
11044
+ title: z.string().trim().optional().describe("Optional label for this config"),
11045
+ description: z.string().trim().nullable().optional().describe("Optional human-readable description of what the config does"),
11046
+ cron: z.string().trim().nullable().optional().describe(
11047
+ "Optional custom CRON schedule. Only accepted for sources that run on a schedule; the source's default schedule is used when omitted."
11048
+ ),
11049
+ config: z.record(z.unknown()).optional().describe(
11050
+ "Source-specific configuration, validated against that source's `configSchema` from `GET /detection/sources`. When omitted the source's schema defaults are applied."
11051
+ ),
11052
+ brandId: z.number().int().positive().nullable().optional().describe(
11053
+ "Optional brand to scope this config to. The brand must belong to the same organization. Omit for an organization-wide config."
11054
+ )
11055
+ }).describe(
11056
+ `Create a threat detection config
11057
+
11058
+ 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.
11059
+
11060
+ A source can have several configs, each scanning with its own query, schedule or brand. Use \`title\` to tell them apart.`
11061
+ );
11062
+ z.object({
11063
+ config: z.object({
11064
+ id: z.number(),
11065
+ source: z.string(),
11066
+ status: z.nativeEnum(ThreatDetectionConfigStatus),
11067
+ title: z.string(),
11068
+ description: z.string().nullable(),
11069
+ cron: z.string().nullable(),
11070
+ config: z.record(z.unknown()),
11071
+ updatedAt: z.date(),
11072
+ brandId: z.number().nullable()
11073
+ })
11074
+ }).describe("Created detection config");
11075
+ z.object({
11076
+ slug: z.string().min(1).optional().describe(
11077
+ "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."
11078
+ ),
11079
+ configId: z.number().int().positive().describe("ID of the config to delete, from `/detection/configs/list`")
11080
+ }).describe(
11081
+ `Delete a threat detection config
11082
+
11083
+ Deletes one detection config so it stops scanning. Deleting a config that shares a source with others leaves the others running.
11084
+
11085
+ 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.`
11086
+ );
11087
+ z.object({
11088
+ success: z.boolean(),
11089
+ id: z.number().describe("ID of the deleted config")
11090
+ }).describe("Deleted detection config");
11091
+ z.object({
11092
+ slug: z.string().min(1),
11093
+ configId: z.number().int().positive(),
11094
+ status: z.nativeEnum(ThreatDetectionConfigStatus).optional(),
11095
+ title: z.string().trim().optional(),
11096
+ description: z.string().trim().nullable().optional(),
11097
+ cron: z.string().trim().nullable().optional(),
11098
+ config: z.record(z.unknown()).optional(),
11099
+ mergeConfig: z.boolean().default(false),
11100
+ brandId: z.number().int().positive().nullable().optional().describe(
11101
+ "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."
11102
+ )
11103
+ });
11104
+ z.object({
11105
+ config: z.object({
11106
+ id: z.number(),
11107
+ source: z.string(),
11108
+ status: z.nativeEnum(ThreatDetectionConfigStatus),
11109
+ title: z.string(),
11110
+ description: z.string().nullable(),
11111
+ cron: z.string().nullable(),
11112
+ config: z.record(z.unknown()),
11113
+ updatedAt: z.date(),
11114
+ brandId: z.number().nullable()
11115
+ })
11116
+ });
11117
+ z.object({
11118
+ slug: z.string().min(1),
11119
+ source: z.string().optional(),
11120
+ minResults: z.number().int().min(0).default(1),
11121
+ lookbackHours: z.number().int().min(1).default(24 * 7),
11122
+ runBeforeValidate: z.boolean().default(false),
11123
+ includeDisabled: z.boolean().default(false)
11124
+ });
11125
+ z.object({
11126
+ ok: z.boolean(),
11127
+ summary: z.object({
11128
+ checkedConfigs: z.number(),
11129
+ passingConfigs: z.number(),
11130
+ failingConfigs: z.number(),
11131
+ lookbackHours: z.number(),
11132
+ minResults: z.number()
11133
+ }),
11134
+ validations: z.array(
11135
+ z.object({
11136
+ configId: z.number(),
11137
+ source: z.string(),
11138
+ status: z.nativeEnum(ThreatDetectionConfigStatus),
11139
+ ran: z.boolean(),
11140
+ runOk: z.boolean(),
11141
+ runMessage: z.string().nullable(),
11142
+ recentResultCount: z.number(),
11143
+ valid: z.boolean()
11144
+ })
11145
+ )
11146
+ });
11147
+ z.object({
11148
+ slug: z.string().min(1),
11149
+ configId: z.number().int().positive().optional(),
11150
+ source: z.string().min(1).optional(),
11151
+ includeDisabled: z.boolean().default(false)
11152
+ });
11153
+ z.object({
11154
+ ranCount: z.number(),
11155
+ successCount: z.number(),
11156
+ failedCount: z.number(),
11157
+ results: z.array(
11158
+ z.object({
11159
+ configId: z.number(),
11160
+ source: z.string(),
11161
+ ok: z.boolean(),
11162
+ message: z.string().nullable(),
11163
+ assetsCount: z.number()
11164
+ })
11165
+ )
11166
+ });
11167
+ z.object({
11168
+ slug: z.string().min(1).optional().describe(
11169
+ "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."
11170
+ )
11171
+ }).describe(
11172
+ `List available threat detection sources
11173
+
11174
+ 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.`
11175
+ );
11176
+ var detectionSourceSchema = z.object({
11177
+ key: z.string().describe("Detection source key (e.g. google_search, certstream, dns_twist)"),
11178
+ label: z.string().describe("Human-readable source name"),
11179
+ description: z.string().describe("What this source detects"),
11180
+ scopes: z.array(z.nativeEnum(ThreatDetectionScope)).describe(
11181
+ "Scopes this source supports. A source without `organization` cannot be configured per-org and runs globally for all organizations."
11182
+ ),
11183
+ isPullBased: z.boolean().describe(
11184
+ "Whether the source runs on a schedule (pull-based). Push-based sources such as webhooks ignore `cron` and cannot be run on demand."
11185
+ ),
11186
+ brandScope: z.enum(["organization_only", "all_brands"]).describe(
11187
+ "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."
11188
+ ),
11189
+ industries: z.array(z.string()).describe(
11190
+ "Industries this source applies to. Empty means it applies to every industry."
11191
+ ),
11192
+ protectedAssetTypes: z.array(z.string()).describe(
11193
+ "Asset types this source monitors. Empty when the source does not key off protected assets."
11194
+ ),
11195
+ configSchema: z.record(z.unknown()).nullable().describe(
11196
+ "JSON Schema for this source's `config` object, for use with `/detection/configs/update`. `null` when the source takes no configuration."
11197
+ )
11198
+ });
11199
+ z.object({
11200
+ sources: z.array(detectionSourceSchema).describe("Available detection sources")
11201
+ }).describe("Successful operation");
11202
+ var DetectionDriftThresholdsSchema = z.object({
11203
+ zeroResultsMaxHours: z.number().int().positive().default(72),
11204
+ noisyResultsPerDay: z.number().positive().default(100),
11205
+ noisyAllowedRatioThreshold: z.number().min(0).max(1).default(0.6),
11206
+ staleConfigDays: z.number().int().positive().default(30)
11207
+ });
11208
+ z.object({
11209
+ slug: z.string().min(1),
11210
+ lookbackHours: z.number().int().positive().default(168),
11211
+ startDate: z.date().optional(),
11212
+ endDate: z.date().optional(),
11213
+ source: z.string().min(1).optional(),
11214
+ configIds: z.array(z.number().int().positive()).optional(),
11215
+ includeDisabled: z.boolean().default(false),
11216
+ thresholds: DetectionDriftThresholdsSchema.optional()
11217
+ }).refine(
11218
+ (value) => !value.startDate && !value.endDate || Boolean(value.startDate) && Boolean(value.endDate),
11219
+ {
11220
+ message: "Provide both startDate and endDate when using explicit date range",
11221
+ path: ["startDate"]
11281
11222
  }
11282
- return String.fromCodePoint(...output);
11283
- }
11284
- function toUnicode(input) {
11285
- return mapDomain(input, function(string) {
11286
- return regexPunycode.test(string) ? decode(string.slice(4).toLowerCase()) : string;
11287
- });
11288
- }
11223
+ );
11224
+ var DetectionDriftSignalSchema = z.object({
11225
+ signal: z.enum(["zero_results_too_long", "noisy_source", "stale_query"]),
11226
+ configId: z.number().int().positive(),
11227
+ source: z.string(),
11228
+ title: z.string().nullable(),
11229
+ status: z.string(),
11230
+ severity: z.enum(["low", "medium", "high"]),
11231
+ details: z.record(z.unknown())
11232
+ });
11233
+ z.object({
11234
+ ok: z.boolean(),
11235
+ range: z.object({
11236
+ startDate: z.date(),
11237
+ endDate: z.date(),
11238
+ lookbackHours: z.number().int().positive()
11239
+ }),
11240
+ thresholds: DetectionDriftThresholdsSchema,
11241
+ summary: z.object({
11242
+ checkedConfigs: z.number().int().nonnegative(),
11243
+ signalCount: z.number().int().nonnegative(),
11244
+ zeroResultsCount: z.number().int().nonnegative(),
11245
+ noisyCount: z.number().int().nonnegative(),
11246
+ staleCount: z.number().int().nonnegative()
11247
+ }),
11248
+ signals: z.array(DetectionDriftSignalSchema)
11249
+ });
11250
+ var BucketsSchema = z.object({
11251
+ lt24h: z.number().int().nonnegative(),
11252
+ h24to72: z.number().int().nonnegative(),
11253
+ h72to168: z.number().int().nonnegative(),
11254
+ gte168h: z.number().int().nonnegative()
11255
+ });
11256
+ z.object({
11257
+ slug: z.string().min(1).optional(),
11258
+ all: z.boolean().default(false),
11259
+ windowHours: z.number().int().positive().default(168)
11260
+ });
11261
+ z.object({
11262
+ generatedAt: z.date(),
11263
+ scope: z.object({
11264
+ slug: z.string().nullable(),
11265
+ all: z.boolean()
11266
+ }),
11267
+ reviewQueue: z.object({
11268
+ totalPendingProposals: z.number().int().nonnegative(),
11269
+ distinctReports: z.number().int().nonnegative(),
11270
+ ageBuckets: BucketsSchema,
11271
+ slaBuckets: z.object({
11272
+ breached: z.number().int().nonnegative(),
11273
+ dueWithin24h: z.number().int().nonnegative(),
11274
+ dueWithin72h: z.number().int().nonnegative(),
11275
+ beyond72h: z.number().int().nonnegative(),
11276
+ missingSla: z.number().int().nonnegative()
11277
+ }),
11278
+ byOrg: z.array(
11279
+ z.object({
11280
+ slug: z.string(),
11281
+ pendingProposals: z.number().int().nonnegative()
11282
+ })
11283
+ )
11284
+ }),
11285
+ takedownQueue: z.object({
11286
+ totalOpen: z.number().int().nonnegative(),
11287
+ statusCounts: z.object({
11288
+ todo: z.number().int().nonnegative(),
11289
+ inProgress: z.number().int().nonnegative(),
11290
+ pendingInput: z.number().int().nonnegative()
11291
+ }),
11292
+ ageBuckets: BucketsSchema,
11293
+ staleInProgress: z.number().int().nonnegative(),
11294
+ byOrg: z.array(
11295
+ z.object({
11296
+ slug: z.string(),
11297
+ openTakedowns: z.number().int().nonnegative()
11298
+ })
11299
+ )
11300
+ })
11301
+ });
11302
+ var HealthcheckCategorySchema = z.enum([
11303
+ "detection",
11304
+ "reviewing",
11305
+ "blocklisting",
11306
+ "takedowns",
11307
+ "assets",
11308
+ "organization"
11309
+ ]);
11310
+ var HealthcheckSeveritySchema = z.enum(["ok", "warn", "fail"]);
11311
+ var HealthcheckFindingSchema = z.object({
11312
+ kind: z.string(),
11313
+ ref: z.string().nullable(),
11314
+ message: z.string(),
11315
+ severity: z.enum(["warn", "fail"])
11316
+ });
11317
+ z.object({
11318
+ id: z.string(),
11319
+ title: z.string(),
11320
+ category: HealthcheckCategorySchema,
11321
+ generatedAt: z.date(),
11322
+ scope: z.object({
11323
+ slug: z.string().nullable()
11324
+ }),
11325
+ ok: z.boolean(),
11326
+ severity: HealthcheckSeveritySchema,
11327
+ observed: z.record(z.union([z.number(), z.string(), z.boolean()]).nullable()),
11328
+ threshold: z.record(z.union([z.number(), z.string(), z.boolean()]).nullable()),
11329
+ findings: z.array(HealthcheckFindingSchema),
11330
+ suggestedAction: z.string().nullable(),
11331
+ appUrl: z.string().nullable()
11332
+ });
11289
11333
 
11290
- // ../../internal/utils/src/url.ts
11291
- function isEmail(input) {
11292
- if (input.trim() === "") {
11293
- return false;
11294
- }
11295
- const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
11296
- return emailRegex.test(input);
11297
- }
11298
- function removeHttpProtocol(input) {
11299
- return input.replace(/^https?:\/\//, "");
11300
- }
11301
- function stripDomainWildcardPrefix(domain) {
11302
- const trimmedDomain = domain.trim();
11303
- const strippedDomain = trimmedDomain.startsWith("*.") ? trimmedDomain.slice(2) : trimmedDomain;
11304
- return strippedDomain.length > 0 ? strippedDomain : null;
11305
- }
11306
- function getDefangedUrl(input) {
11307
- if (!isUrl(input)) {
11308
- console.warn(`[getDefangedUrl] Invalid URL: ${input}, returning input as-is`);
11309
- return input;
11310
- }
11311
- return input.replace(/\./g, "[.]").replace(/(https:\/\/)/g, "hxxps://").replace(/(http:\/\/)/g, "hxxp://").replace(/:\/\//g, "[://]");
11312
- }
11313
- function getRefangedUrl(input) {
11314
- return input.replace(/hxxps/gi, "https").replace(/hxxp/gi, "http").replace(/\[:\/{2}\]/g, "://").replace(/\[\.\]/g, ".");
11315
- }
11316
- function containsPunycode(url) {
11317
- return url.indexOf("xn--") !== -1;
11318
- }
11319
- function toUnicode2(url) {
11320
- return toUnicode(url);
11321
- }
11322
- function convertHttpsToHttp(url) {
11323
- if (url.startsWith("https://")) {
11324
- const httpUrl = new URL(url);
11325
- httpUrl.protocol = "http:";
11326
- return httpUrl.toString();
11327
- }
11328
- throw new Error(`URL is not HTTPS: ${url}`);
11329
- }
11330
- function generateCanonicalIPFSUrl(content) {
11331
- if (!content) {
11332
- return content;
11333
- }
11334
- if (content.includes("ipfs.io")) {
11335
- return content;
11336
- }
11337
- if (content.startsWith("Qm") || content.startsWith("bafy")) {
11338
- return `ipfs.io/ipfs/${content}`;
11339
- }
11340
- return content;
11341
- }
11342
- function isWalrusSite(content) {
11343
- return content.includes(".walrus.site") || content.includes(".walrus.host") || content.includes(".wal.app") || content.includes(".wal.site");
11344
- }
11345
- function getFaviconUrl(content) {
11346
- const normalizedUrl = getNormalizedUrl(content);
11347
- return `https://icons.duckduckgo.com/ip3/${normalizedUrl.hostname}.ico`;
11348
- }
11349
- function sanitizeHttpUrl(value) {
11350
- if (typeof value !== "string" || value.length === 0) {
11351
- return null;
11334
+ // ../../internal/validation/src/public/healthchecks/assets-dead-asset-spike.ts
11335
+ z.object({
11336
+ slug: z.string().min(1),
11337
+ windowHours: z.number().int().positive().default(24),
11338
+ baselineDays: z.number().int().positive().default(7),
11339
+ warnMultiplier: z.number().positive().default(2),
11340
+ failMultiplier: z.number().positive().default(4),
11341
+ minSpikeCount: z.number().int().min(1).default(10)
11342
+ });
11343
+ z.object({});
11344
+ var HealthcheckRegistryEntrySchema = z.object({
11345
+ id: z.string(),
11346
+ title: z.string(),
11347
+ description: z.string(),
11348
+ category: HealthcheckCategorySchema,
11349
+ implemented: z.boolean(),
11350
+ endpoint: z.string().nullable(),
11351
+ defaultThreshold: z.record(z.union([z.number(), z.string()])).optional(),
11352
+ notImplementedReason: z.string().optional()
11353
+ });
11354
+ z.object({
11355
+ checks: z.array(HealthcheckRegistryEntrySchema)
11356
+ });
11357
+ z.object({
11358
+ slug: z.string().min(1)
11359
+ });
11360
+ z.object({
11361
+ slug: z.string().min(1),
11362
+ warnThreshold: z.number().int().nonnegative().default(50),
11363
+ failThreshold: z.number().int().nonnegative().default(100)
11364
+ });
11365
+ z.object({
11366
+ slug: z.string().min(1),
11367
+ warnAgeHours: z.number().int().positive().default(24 * 7),
11368
+ failAgeHours: z.number().int().positive().default(24 * 14)
11369
+ });
11370
+ z.object({
11371
+ slug: z.string().min(1),
11372
+ warnAgeHours: z.number().int().nonnegative().default(24 * 30),
11373
+ failAgeHours: z.number().int().nonnegative().default(24 * 60)
11374
+ });
11375
+ z.object({
11376
+ slug: z.string().min(1),
11377
+ lookbackHours: z.number().int().positive().default(24 * 7),
11378
+ warnThreshold: z.number().int().nonnegative().default(3),
11379
+ failThreshold: z.number().int().nonnegative().default(10)
11380
+ });
11381
+ z.object({
11382
+ slug: z.string().min(1),
11383
+ warnThreshold: z.number().int().nonnegative().default(30),
11384
+ failThreshold: z.number().int().nonnegative().default(75)
11385
+ });
11386
+ z.object({
11387
+ slug: z.string().min(1),
11388
+ staleThresholdHours: z.number().int().positive().default(24 * 7),
11389
+ warnThreshold: z.number().int().nonnegative().default(1),
11390
+ failThreshold: z.number().int().nonnegative().default(5)
11391
+ });
11392
+ z.object({
11393
+ slug: z.string().min(1),
11394
+ warnThreshold: z.number().int().nonnegative().default(50),
11395
+ failThreshold: z.number().int().nonnegative().default(100)
11396
+ });
11397
+ var BreakdownBySchema = z.enum(["day", "type", "brand"]);
11398
+ z.object({
11399
+ slug: z.string().min(1),
11400
+ by: BreakdownBySchema,
11401
+ startDate: z.date().optional(),
11402
+ endDate: z.date().optional(),
11403
+ brandIds: z.array(z.number().int().positive()).optional()
11404
+ });
11405
+ z.object({
11406
+ by: BreakdownBySchema,
11407
+ points: z.array(
11408
+ z.object({
11409
+ key: z.string(),
11410
+ count: z.number(),
11411
+ date: z.string().optional(),
11412
+ type: z.string().optional(),
11413
+ brandId: z.number().optional(),
11414
+ brandSlug: z.string().optional(),
11415
+ brandName: z.string().optional()
11416
+ })
11417
+ )
11418
+ });
11419
+ z.object({
11420
+ slug: z.string().min(1),
11421
+ startDate: z.date(),
11422
+ endDate: z.date(),
11423
+ brandIds: z.array(z.number().int().positive()).optional()
11424
+ });
11425
+ z.object({
11426
+ metric: z.literal("new_threats"),
11427
+ found: z.number(),
11428
+ range: z.object({
11429
+ startDate: z.date(),
11430
+ endDate: z.date()
11431
+ })
11432
+ });
11433
+ z.object({
11434
+ slug: z.string().min(1),
11435
+ startDate: z.date().optional(),
11436
+ endDate: z.date().optional(),
11437
+ brandIds: z.array(z.number().int().positive()).optional()
11438
+ });
11439
+ z.object({
11440
+ metrics: z.object({
11441
+ reports: z.number(),
11442
+ newThreats: z.number(),
11443
+ threatsWatchlisted: z.number(),
11444
+ takedownsFiled: z.number(),
11445
+ takedownsCompleted: z.number(),
11446
+ domainThreats: z.number(),
11447
+ twitterThreats: z.number(),
11448
+ telegramThreats: z.number(),
11449
+ otherThreats: z.number()
11450
+ }),
11451
+ blockedByDay: z.array(
11452
+ z.object({
11453
+ date: z.string(),
11454
+ count: z.number()
11455
+ })
11456
+ ),
11457
+ blockedByType: z.array(
11458
+ z.object({
11459
+ type: z.string(),
11460
+ count: z.number()
11461
+ })
11462
+ )
11463
+ });
11464
+ var DATE_ONLY_PATTERN = /^\d{4}-\d{2}-\d{2}$/;
11465
+ var utcDateSchema = (endOfDay) => z.preprocess((value) => {
11466
+ if (typeof value !== "string") {
11467
+ return value;
11352
11468
  }
11353
- try {
11354
- const parsed = new URL(value);
11355
- if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
11356
- return null;
11357
- }
11358
- return parsed.toString();
11359
- } catch (e4) {
11360
- return null;
11469
+ const parsed = DateTime.fromISO(value, { zone: "utc" });
11470
+ if (!parsed.isValid) {
11471
+ return new Date(Number.NaN);
11361
11472
  }
11362
- }
11363
- var URL_REGEX = /https?:\/\/[^\s"'<>\])]*/g;
11473
+ return endOfDay && DATE_ONLY_PATTERN.test(value) ? parsed.endOf("day").toJSDate() : parsed.toJSDate();
11474
+ }, z.coerce.date());
11475
+ z.object({
11476
+ slug: z.string().min(1).describe("Organization slug"),
11477
+ startDate: utcDateSchema(false).optional().describe(
11478
+ "Only include takedowns completed on or after this date. A date-only value (YYYY-MM-DD) starts at midnight UTC"
11479
+ ),
11480
+ endDate: utcDateSchema(true).optional().describe(
11481
+ "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"
11482
+ ),
11483
+ blockLabel: z.string().optional().describe(
11484
+ 'Only include assets blocked with this review label, e.g. "Brand Impersonation", "Employee Impersonation" or "Targeting Org Users"'
11485
+ ),
11486
+ brandType: z.nativeEnum(BrandType).optional().describe("Only include assets belonging to brands of this type"),
11487
+ countryCodes: z.array(z.string().length(2)).optional().describe("Only include assets scanned from these ISO 3166-1 alpha-2 countries"),
11488
+ brandIds: z.array(z.number().int().positive()).optional().describe("Only include assets belonging to these brands")
11489
+ });
11490
+ z.object({
11491
+ byAssetType: z.array(
11492
+ z.object({
11493
+ assetType: z.nativeEnum(AssetType).describe("Asset type the median is computed over"),
11494
+ medianTakedownMinutes: z.number(),
11495
+ medianTakedownHours: z.number(),
11496
+ medianTakedownDays: z.number(),
11497
+ count: z.number().describe("Number of completed takedowns behind the median")
11498
+ })
11499
+ ).describe(
11500
+ "Median time from takedown start to completion, one entry per asset type, ascending by median"
11501
+ )
11502
+ });
11503
+ z.object({
11504
+ slug: z.string().optional().describe(
11505
+ "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."
11506
+ ),
11507
+ type: z.nativeEnum(AssetType).optional().describe("Filter by asset type (URL, ADDRESS, etc.)"),
11508
+ groupId: z.number().int().optional().describe(
11509
+ "Filter by group ID. Use -1 for ungrouped assets only. Omit for all assets."
11510
+ ),
11511
+ query: z.string().optional().describe("Search query to filter assets by content"),
11512
+ per_page: z.number().int().min(1).max(1e3).optional().default(100).describe("The number of assets to return per page (max 1000)"),
11513
+ next_page: z.string().optional().nullable().describe("Cursor for fetching the next page of results")
11514
+ }).describe(
11515
+ `List organization assets request body
11364
11516
 
11365
- // ../../internal/utils/src/email.ts
11366
- var email_exports = {};
11367
- __export(email_exports, {
11368
- extractTextFromGmailPayload: () => extractTextFromGmailPayload,
11369
- getDomainFromEmail: () => getDomainFromEmail,
11370
- getNameFromEmail: () => getNameFromEmail
11517
+ Returns all assets belonging to the organization identified by \`slug\`, or \u2014
11518
+ when \`slug\` is omitted \u2014 the organization associated with your API key.
11519
+ Supports filtering by type, group, and search query.`
11520
+ );
11521
+ var organizationAssetItemSchema = z.object({
11522
+ id: z.number().describe("Asset ID"),
11523
+ content: z.string().describe("Asset content (URL, address, handle, etc.)"),
11524
+ type: z.nativeEnum(AssetType).describe("Asset type"),
11525
+ status: z.nativeEnum(AssetStatus).describe("Asset status"),
11526
+ name: z.string().nullable().describe("Asset display name"),
11527
+ description: z.string().nullable().describe("Asset description"),
11528
+ group: z.object({
11529
+ id: z.number().describe("Group ID"),
11530
+ name: z.string().describe("Group name")
11531
+ }).nullable().describe("Asset group information"),
11532
+ livenessStatus: z.nativeEnum(LivenessStatus).nullable().describe(
11533
+ "Whether the asset is currently reachable (`ALIVE`), gone (`DEAD`), or hasn't been checked (`UNKNOWN`). `null` when liveness has never been evaluated."
11534
+ ),
11535
+ blockedAt: z.date().nullable().describe(
11536
+ "When the asset transitioned to BLOCKED status. `null` for non-blocked assets. Distinct from `updatedAt`."
11537
+ ),
11538
+ createdAt: z.date().describe("When the asset was created"),
11539
+ updatedAt: z.date().describe("When the asset was last updated")
11371
11540
  });
11372
- function getDomainFromEmail(email) {
11373
- return email.split("@")[1];
11374
- }
11375
- function getNameFromEmail(email) {
11376
- return email.split("@")[0];
11377
- }
11378
- function extractTextFromGmailPayload(payload) {
11379
- var _a;
11380
- if (!payload) return "";
11381
- if ((_a = payload.body) == null ? void 0 : _a.data) {
11382
- if (payload.mimeType === "text/plain" || payload.mimeType === "text/html") {
11383
- return Buffer.from(payload.body.data, "base64url").toString("utf-8");
11384
- }
11385
- }
11386
- if (payload.parts) {
11387
- if (payload.mimeType === "multipart/alternative") {
11388
- const plainTextPart = payload.parts.find((part) => part.mimeType === "text/plain");
11389
- if (plainTextPart) {
11390
- return extractTextFromGmailPayload(plainTextPart);
11391
- }
11392
- const htmlPart = payload.parts.find((part) => part.mimeType === "text/html");
11393
- if (htmlPart) {
11394
- return extractTextFromGmailPayload(htmlPart);
11395
- }
11396
- for (const part of payload.parts) {
11397
- const text = extractTextFromGmailPayload(part);
11398
- if (text) return text;
11399
- }
11400
- }
11401
- return payload.parts.map((part) => extractTextFromGmailPayload(part)).join("\n");
11402
- }
11403
- return "";
11404
- }
11541
+ z.object({
11542
+ assets: z.array(organizationAssetItemSchema).describe("List of assets"),
11543
+ next_page: z.string().nullable().optional().describe("Cursor for fetching the next page of results")
11544
+ }).describe("Successful operation");
11545
+ var addAssetItemSchema = z.object({
11546
+ content: z.string().describe("Asset content (URL, address, handle, etc.)"),
11547
+ name: z.string().optional().describe("Optional display name for the asset"),
11548
+ description: z.string().optional().describe("Optional description for the asset"),
11549
+ groupId: z.number().int().positive().optional().describe("Optional group ID to assign the asset to")
11550
+ });
11551
+ z.object({
11552
+ assets: z.array(addAssetItemSchema).min(1).max(1e3).describe("Array of assets to add (max 1000 per request)")
11553
+ }).describe(
11554
+ `Add assets to organization allowlist
11555
+
11556
+ Batch add multiple assets to your organization's allowlist.
11557
+ Each asset will be automatically parsed and classified.
11558
+ Assets will be auto-approved as ALLOWED status.`
11559
+ );
11560
+ var addAssetResultSchema = z.object({
11561
+ content: z.string().describe("Asset content"),
11562
+ success: z.boolean().describe("Whether the asset was added successfully"),
11563
+ id: z.number().optional().describe("Asset ID if successful"),
11564
+ error: z.string().optional().describe("Error message if failed")
11565
+ });
11566
+ z.object({
11567
+ results: z.array(addAssetResultSchema).describe("Results for each asset"),
11568
+ successCount: z.number().describe("Number of assets successfully added"),
11569
+ errorCount: z.number().describe("Number of assets that failed to add")
11570
+ }).describe("Batch add operation results");
11571
+ z.object({
11572
+ assetId: z.number().int().positive().describe("ID of the asset to update"),
11573
+ name: z.string().optional().describe("New display name for the asset"),
11574
+ description: z.string().nullable().optional().describe("New description for the asset"),
11575
+ groupId: z.number().int().positive().nullable().optional().describe("New group ID (null to ungroup)")
11576
+ }).describe(
11577
+ `Update an organization asset
11578
+
11579
+ Update the name, description, or group assignment of an asset.`
11580
+ );
11581
+ z.object({
11582
+ id: z.number().describe("Asset ID"),
11583
+ content: z.string().describe("Asset content"),
11584
+ name: z.string().nullable().describe("Asset display name"),
11585
+ description: z.string().nullable().describe("Asset description"),
11586
+ groupId: z.number().nullable().describe("Group ID")
11587
+ }).describe("Updated asset");
11588
+ z.object({
11589
+ assetId: z.number().int().positive().describe("ID of the asset to remove")
11590
+ }).describe(
11591
+ `Remove an asset from the organization
11592
+
11593
+ This removes the asset from the organization's allowlist.`
11594
+ );
11595
+ z.object({
11596
+ success: z.boolean().describe("Whether the asset was removed successfully"),
11597
+ id: z.number().describe("Asset ID that was removed")
11598
+ }).describe("Delete operation result");
11599
+ z.object({}).describe(
11600
+ `List organization asset groups
11601
+
11602
+ Returns all asset groups belonging to the organization associated with your API key.`
11603
+ );
11604
+ var assetGroupItemSchema = z.object({
11605
+ id: z.number().describe("Group ID"),
11606
+ name: z.string().describe("Group name"),
11607
+ assetCount: z.number().describe("Number of assets in this group")
11608
+ });
11609
+ z.object({
11610
+ groups: z.array(assetGroupItemSchema).describe("List of asset groups")
11611
+ }).describe("Successful operation");
11612
+ z.object({
11613
+ name: z.string().min(1).max(255).describe("Name for the new group")
11614
+ }).describe(
11615
+ `Create a new asset group
11616
+
11617
+ Creates a new asset group for organizing your organization's assets.`
11618
+ );
11619
+ z.object({
11620
+ id: z.number().describe("Created group ID"),
11621
+ name: z.string().describe("Group name")
11622
+ }).describe("Created group");
11623
+ z.object({
11624
+ groupId: z.number().int().positive().describe("ID of the group to update"),
11625
+ name: z.string().min(1).max(255).describe("New name for the group")
11626
+ }).describe(
11627
+ `Update an asset group
11628
+
11629
+ Rename an existing asset group.`
11630
+ );
11631
+ z.object({
11632
+ id: z.number().describe("Group ID"),
11633
+ name: z.string().describe("Updated group name")
11634
+ }).describe("Updated group");
11635
+ z.object({
11636
+ groupId: z.number().int().positive().describe("ID of the group to delete")
11637
+ }).describe(
11638
+ `Delete an asset group
11405
11639
 
11406
- // ../../internal/utils/src/vercel.ts
11407
- var vercel_exports = {};
11408
- __export(vercel_exports, {
11409
- checkVercelEnv: () => checkVercelEnv
11410
- });
11411
- var checkVercelEnv = ({ envs }) => {
11412
- var _a;
11413
- const vercelEnv = (_a = process.env.VERCEL_ENV) != null ? _a : "development";
11414
- if (!envs.includes(vercelEnv)) {
11415
- return {
11416
- ok: false,
11417
- message: `Vercel environment is ${vercelEnv}, but expected ${envs.join(" or ")}`
11418
- };
11419
- }
11420
- return { ok: true, message: "" };
11421
- };
11640
+ Deletes an asset group. Assets in this group will become ungrouped.`
11641
+ );
11642
+ z.object({
11643
+ success: z.boolean().describe("Whether the group was deleted successfully"),
11644
+ id: z.number().describe("Group ID that was deleted"),
11645
+ unassignedAssetCount: z.number().describe("Number of assets that were unassigned from this group")
11646
+ }).describe("Delete operation result");
11647
+ z.object({}).describe(
11648
+ `List organization brands
11422
11649
 
11423
- // ../../internal/utils/src/delay.ts
11424
- var delay_exports = {};
11425
- __export(delay_exports, {
11426
- delay: () => delay
11650
+ Returns all brands belonging to the organization associated with your API key,
11651
+ including sub-brands (\`ORGANIZATION\`), individual / employee brands
11652
+ (\`INDIVIDUAL\`), and product brands (\`PRODUCT\`). Soft-deleted brands are
11653
+ excluded.`
11654
+ );
11655
+ var brandLegalDocumentSchema = z.object({
11656
+ present: z.boolean().describe("Whether the brand has this document attached"),
11657
+ fileName: z.string().nullable().describe("Original filename of the uploaded document (null when not present)"),
11658
+ fileUrl: z.string().nullable().describe("Direct URL to view or download the document (null when not present)")
11427
11659
  });
11428
- var delay = (ms) => {
11429
- return new Promise((resolve) => setTimeout(resolve, ms));
11430
- };
11431
-
11432
- // ../../internal/utils/src/whois.ts
11433
- var whois_exports = {};
11434
- __export(whois_exports, {
11435
- extractWhoisCountry: () => extractWhoisCountry,
11436
- extractWhoisPayload: () => extractWhoisPayload,
11437
- normalizeRegistrar: () => normalizeRegistrar
11660
+ var brandTrademarkRegistrationSchema = z.object({
11661
+ id: z.number().describe("Trademark registration ID"),
11662
+ brandName: z.string().describe("Trademarked brand name as it appears on the registration"),
11663
+ trademarkOffice: z.string().describe("Issuing trademark office (e.g. `USPTO`, `EUIPO`)"),
11664
+ registrationNumber: z.string().describe("Registration number assigned by the office"),
11665
+ goodsAndServicesClass: z.string().describe("Nice Classification class(es) the registration covers"),
11666
+ rightsOwnerName: z.string().nullable().describe("Legal entity the trademark is registered to, if recorded"),
11667
+ registrationPageUrl: z.string().nullable().describe("Public URL on the trademark office's site, if recorded"),
11668
+ certificateFileName: z.string().nullable().describe(
11669
+ "Original filename of the uploaded certificate PDF (null when no certificate is attached)"
11670
+ ),
11671
+ certificateFileUrl: z.string().nullable().describe(
11672
+ "Direct URL to view or download the certificate PDF (null when no certificate is attached)"
11673
+ )
11438
11674
  });
11439
- function extractWhoisPayload(raw) {
11440
- var _a;
11441
- const first = Array.isArray(raw) ? (_a = raw.find((entry) => entry !== null && typeof entry === "object")) != null ? _a : {} : raw;
11442
- if (!first || typeof first !== "object") {
11443
- return {};
11444
- }
11445
- const maybeData = first.data;
11446
- if (maybeData && typeof maybeData === "object" && !Array.isArray(maybeData)) {
11447
- return maybeData;
11448
- }
11449
- return first;
11450
- }
11451
- var WHOIS_EMPTY_VALUES = /* @__PURE__ */ new Set(["", "none", "null"]);
11452
- var WHOIS_COUNTRY_CODE_KEY_ALIASES = /* @__PURE__ */ new Set(["countrycode", "registrantcountrycode"]);
11453
- var WHOIS_COUNTRY_KEY_ALIASES = /* @__PURE__ */ new Set([
11454
- "country",
11455
- "countryname",
11456
- "registrantcountry",
11457
- "registrantcountryname"
11458
- ]);
11459
- function normalizeWhoisKey(key) {
11460
- return key.toLowerCase().replace(/[^a-z0-9]/g, "");
11461
- }
11462
- function normalizeRegistrar(value) {
11463
- return value.toLowerCase().replace(/[^a-z0-9]/g, "");
11464
- }
11465
- function parseWhoisString(value) {
11466
- if (typeof value !== "string") {
11467
- return void 0;
11468
- }
11469
- const trimmedValue = value.trim();
11470
- if (WHOIS_EMPTY_VALUES.has(trimmedValue.toLowerCase())) {
11471
- return void 0;
11472
- }
11473
- return trimmedValue;
11474
- }
11475
- function extractWhoisFieldByAliases(payload, aliases) {
11476
- for (const [key, value] of Object.entries(payload)) {
11477
- if (!aliases.has(normalizeWhoisKey(key))) {
11478
- continue;
11479
- }
11480
- const parsedValue = parseWhoisString(value);
11481
- if (parsedValue) {
11482
- return parsedValue;
11483
- }
11484
- }
11485
- return void 0;
11486
- }
11487
- function extractWhoisCountry(payload) {
11488
- const countryCode = extractWhoisFieldByAliases(payload, WHOIS_COUNTRY_CODE_KEY_ALIASES);
11489
- const country = extractWhoisFieldByAliases(payload, WHOIS_COUNTRY_KEY_ALIASES);
11490
- return {
11491
- countryCode: countryCode != null ? countryCode : void 0,
11492
- country: country != null ? country : void 0
11493
- };
11494
- }
11495
-
11496
- // ../../internal/utils/src/safe-preview.ts
11497
- var safe_preview_exports = {};
11498
- __export(safe_preview_exports, {
11499
- buildSafePreviewUrl: () => buildSafePreviewUrl,
11500
- normalizeSafeNavigationTarget: () => normalizeSafeNavigationTarget
11675
+ var brandItemSchema = z.object({
11676
+ id: z.number().describe("Brand ID"),
11677
+ slug: z.string().describe("Brand slug (stable, URL-safe identifier)"),
11678
+ name: z.string().describe("Display name"),
11679
+ type: z.nativeEnum(BrandType).describe(
11680
+ "Brand type: `ORGANIZATION` for parent brands, `INDIVIDUAL` for employee or person brands, `PRODUCT` for a specific product or service offering"
11681
+ ),
11682
+ description: z.string().nullable().describe("Free-form description, if set"),
11683
+ avatarUrl: z.string().nullable().describe("URL of the brand's avatar / logo image"),
11684
+ websiteUrl: z.string().nullable().describe("Official brand website URL"),
11685
+ twitterHandle: z.string().nullable().describe("Official Twitter / X handle (without @)"),
11686
+ brandColors: z.array(z.string()).describe("HEX color strings associated with the brand (e.g. `#FF0000`)"),
11687
+ includedTerms: z.array(z.string()).describe("Terms that should be included when matching this brand"),
11688
+ excludedTerms: z.array(z.string()).describe("Terms that should be excluded when matching this brand"),
11689
+ tickers: z.array(z.string()).describe("Ticker symbols associated with the brand (e.g. `$JUP`)"),
11690
+ brandGroupId: z.number().nullable().describe(
11691
+ "Group this brand belongs to (only set for `INDIVIDUAL` and `PRODUCT` brands)"
11692
+ ),
11693
+ createdAt: z.date().describe("When the brand was created"),
11694
+ useOrganizationDocs: z.boolean().describe(
11695
+ "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."
11696
+ ),
11697
+ legalDocuments: z.object({
11698
+ letterOfAuthorization: brandLegalDocumentSchema,
11699
+ powerOfAttorney: brandLegalDocumentSchema
11700
+ }).describe("Brand-level Letter of Authorization and Power of Attorney attachments"),
11701
+ trademarkRegistrations: z.array(brandTrademarkRegistrationSchema).describe(
11702
+ "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."
11703
+ )
11501
11704
  });
11502
- var SAFE_NAVIGATION_PROTOCOLS = /* @__PURE__ */ new Set(["http:", "https:"]);
11503
- var PREVIEW_PATH = "/preview";
11504
- var URL_BASE = "https://app.chainpatrol.io";
11505
- function normalizeSafeNavigationTarget(target) {
11506
- const normalizedTarget = getNormalizedUrl(target);
11507
- if (!SAFE_NAVIGATION_PROTOCOLS.has(normalizedTarget.protocol)) {
11508
- throw new Error(`Unsupported URL protocol: ${normalizedTarget.protocol}`);
11509
- }
11510
- return normalizedTarget;
11511
- }
11512
- function buildSafePreviewUrl({
11513
- target,
11514
- assetId,
11515
- policy
11516
- }) {
11517
- const normalizedTarget = normalizeSafeNavigationTarget(target);
11518
- const previewUrl = new URL(PREVIEW_PATH, URL_BASE);
11519
- previewUrl.searchParams.set("target", normalizedTarget.toString());
11520
- if (Number.isInteger(assetId) && assetId && assetId >= 1) {
11521
- previewUrl.searchParams.set("asset_id", String(assetId));
11522
- }
11523
- if (policy) {
11524
- previewUrl.searchParams.set("policy", policy);
11525
- }
11526
- return `${previewUrl.pathname}?${previewUrl.searchParams.toString()}`;
11527
- }
11528
-
11529
- // ../../internal/utils/src/parse.ts
11530
- var parse_exports = {};
11531
- __export(parse_exports, {
11532
- parseTerms: () => parseTerms,
11533
- stringifyTerms: () => stringifyTerms
11705
+ z.object({
11706
+ brands: z.array(brandItemSchema).describe("List of brands")
11707
+ }).describe("Successful operation");
11708
+ var FILTERABLE_SUBSCRIPTION_STATUSES = [
11709
+ SubscriptionStatus.PROSPECT,
11710
+ SubscriptionStatus.POC,
11711
+ SubscriptionStatus.ACTIVE,
11712
+ SubscriptionStatus.INTEGRATION
11713
+ ];
11714
+ var UserOrgsSubscriptionStatusSchema = z.enum(
11715
+ FILTERABLE_SUBSCRIPTION_STATUSES
11716
+ );
11717
+ var takedownsServiceFilterSchema = z.object({
11718
+ active: z.boolean().optional(),
11719
+ automated: z.boolean().optional()
11720
+ }).optional();
11721
+ var singleServiceFilterSchema = z.object({
11722
+ active: z.boolean().optional()
11723
+ }).optional();
11724
+ var userOrgsServicesFilterObjectSchema = z.object({
11725
+ reporting: singleServiceFilterSchema,
11726
+ reviewing: singleServiceFilterSchema,
11727
+ protection: singleServiceFilterSchema,
11728
+ takedowns: takedownsServiceFilterSchema,
11729
+ detection: singleServiceFilterSchema,
11730
+ darkWebMonitoring: singleServiceFilterSchema
11731
+ });
11732
+ var userOrgsObligatoryAdminApprovalFilterSchema = z.object({
11733
+ active: z.boolean().optional(),
11734
+ assetTypes: z.array(z.nativeEnum(AssetType)).min(1).optional()
11735
+ }).optional();
11736
+ var PendingApprovalServiceSchema = z.enum(["protection", "takedowns"]);
11737
+ var userOrgsPendingServiceApprovalFilterSchema = z.object({
11738
+ active: z.boolean().optional(),
11739
+ services: z.array(PendingApprovalServiceSchema).min(1).optional()
11740
+ }).optional();
11741
+ z.object({
11742
+ query: z.string().default(""),
11743
+ subscriptionStatus: z.array(UserOrgsSubscriptionStatusSchema).min(1).optional(),
11744
+ services: userOrgsServicesFilterObjectSchema.optional(),
11745
+ obligatoryAdminApproval: userOrgsObligatoryAdminApprovalFilterSchema,
11746
+ pendingServiceApproval: userOrgsPendingServiceApprovalFilterSchema
11747
+ });
11748
+ var takedownsServiceSchema = z.object({
11749
+ active: z.boolean(),
11750
+ automated: z.boolean()
11751
+ });
11752
+ var singleServiceSchema = z.object({
11753
+ active: z.boolean()
11754
+ });
11755
+ var UserOrgObligatoryAdminApprovalSchema = z.object({
11756
+ active: z.boolean(),
11757
+ assetTypes: z.array(z.nativeEnum(AssetType))
11758
+ });
11759
+ var PendingServiceApprovalSchema = z.object({
11760
+ // Friendly service family, matching a key in the `services` object.
11761
+ service: PendingApprovalServiceSchema,
11762
+ // Whether the request is for the automated variant of the service
11763
+ // (e.g. "Automated Wallet Blocking" rather than "Wallet Blocking").
11764
+ automated: z.boolean(),
11765
+ // Raw `ServiceType` enum value, e.g. "isProtectionActive". Lets callers
11766
+ // distinguish the exact column without re-deriving it from `service` +
11767
+ // `automated`.
11768
+ serviceType: z.nativeEnum(ServiceType),
11769
+ // Human-readable service label, e.g. "Wallet Blocking".
11770
+ serviceName: z.string(),
11771
+ // When the enable request was submitted (ISO 8601, UTC).
11772
+ requestedAt: z.string()
11773
+ });
11774
+ var UserOrgIntegrationsSchema = z.object({
11775
+ slack: z.boolean(),
11776
+ discord: z.boolean(),
11777
+ telegram: z.object({
11778
+ connected: z.boolean(),
11779
+ groupCount: z.number()
11780
+ }),
11781
+ vercel: z.boolean(),
11782
+ intercom: z.boolean(),
11783
+ moderation: z.boolean()
11534
11784
  });
11535
- function parseTerms(terms, {
11536
- forceExact = false
11537
- } = {}) {
11538
- if (!terms) return [];
11539
- return terms.split(",").map((term) => {
11540
- const trimmed = term.trim();
11541
- if (!trimmed) return null;
11542
- const isWrappedExact = trimmed.startsWith("*") && trimmed.endsWith("*") && trimmed.length > 2;
11543
- if (isWrappedExact) {
11544
- return {
11545
- value: trimmed.slice(1, -1).toLowerCase(),
11546
- type: "exact"
11547
- };
11548
- } else {
11549
- return {
11550
- value: trimmed.toLowerCase(),
11551
- type: forceExact ? "exact" : "loose"
11552
- };
11553
- }
11554
- }).filter((term) => term !== null);
11555
- }
11556
- function stringifyTerms(parsedTerms) {
11557
- return parsedTerms.map((term) => term.type === "exact" ? `*${term.value}*` : term.value).join(", ");
11558
- }
11559
-
11560
- // ../../internal/utils/src/brand-pattern.ts
11561
- var brand_pattern_exports = {};
11562
- __export(brand_pattern_exports, {
11563
- anyPatternMatches: () => anyPatternMatches,
11564
- compileBrandPattern: () => compileBrandPattern,
11565
- countPatternMatches: () => countPatternMatches,
11566
- findMatchingPatterns: () => findMatchingPatterns
11785
+ var UserOrgLegalDocumentSchema = z.object({
11786
+ present: z.boolean().describe("Whether the organization has this document attached"),
11787
+ fileName: z.string().nullable().describe("Original filename of the uploaded document (null when not present)"),
11788
+ fileUrl: z.string().nullable().describe("Direct URL to view or download the document (null when not present)")
11567
11789
  });
11568
- var DEFAULT_MAX_MATCHES = 50;
11569
- function compileBrandPattern(input) {
11570
- var _a;
11571
- try {
11572
- return new RegExp(input.pattern, (_a = input.flags) != null ? _a : void 0);
11573
- } catch (e4) {
11574
- return null;
11575
- }
11576
- }
11577
- function anyPatternMatches(content, patterns, kind) {
11578
- for (const input of patterns) {
11579
- if (input.kind !== kind) continue;
11580
- const regex = compileBrandPattern(input);
11581
- if (!regex) continue;
11582
- if (regex.test(content)) {
11583
- return true;
11584
- }
11585
- }
11586
- return false;
11587
- }
11588
- function findMatchingPatterns(content, patterns, kind) {
11589
- const matched = [];
11590
- for (const input of patterns) {
11591
- if (input.kind !== kind) continue;
11592
- const regex = compileBrandPattern(input);
11593
- if (!regex) continue;
11594
- if (regex.test(content)) {
11595
- matched.push(input);
11596
- }
11597
- }
11598
- return matched;
11599
- }
11600
- function countPatternMatches(content, pattern, maxMatches = DEFAULT_MAX_MATCHES) {
11601
- const compiled = compileBrandPattern(pattern);
11602
- if (!compiled) return 0;
11603
- const flags = compiled.flags.includes("g") ? compiled.flags : `${compiled.flags}g`;
11604
- const globalRegex = new RegExp(compiled.source, flags);
11605
- let count = 0;
11606
- let match2;
11607
- while ((match2 = globalRegex.exec(content)) !== null) {
11608
- count += 1;
11609
- if (count >= maxMatches) break;
11610
- if (match2[0].length === 0) globalRegex.lastIndex += 1;
11611
- }
11612
- return count;
11613
- }
11614
-
11615
- // ../../internal/utils/src/text.ts
11616
- var text_exports = {};
11617
- __export(text_exports, {
11618
- HOMOGLYPH_MAPPINGS: () => HOMOGLYPH_MAPPINGS,
11619
- LETTER_TO_HOMOGLYPH_MAPPINGS: () => LETTER_TO_HOMOGLYPH_MAPPINGS,
11620
- generateHomoglyphSearchTerms: () => generateHomoglyphSearchTerms,
11621
- normalizeHomoglyphs: () => normalizeHomoglyphs
11790
+ var UserOrgLegalDocumentsSchema = z.object({
11791
+ letterOfAuthorization: UserOrgLegalDocumentSchema,
11792
+ powerOfAttorney: UserOrgLegalDocumentSchema
11622
11793
  });
11623
- var HOMOGLYPH_MAPPINGS = {
11624
- "0": "o",
11625
- "1": "i",
11626
- "3": "e",
11627
- "4": "a",
11628
- "5": "s",
11629
- "7": "t",
11630
- "8": "b"
11631
- };
11632
- var LETTER_TO_HOMOGLYPH_MAPPINGS = {
11633
- a: ["4", "\u0430"],
11634
- b: ["8", "6"],
11635
- c: ["\u0441"],
11636
- e: ["3", "\u0435"],
11637
- g: ["9"],
11638
- i: ["1", "l", "\u0456"],
11639
- l: ["1"],
11640
- o: ["0", "\u043E"],
11641
- s: ["5", "\u0455"],
11642
- t: ["7"],
11643
- x: ["\u0445"],
11644
- z: ["2"]
11645
- };
11646
- var DEFAULT_MAX_HOMOGLYPH_VARIANTS = 20;
11647
- function isCyrillic(char) {
11648
- return char.charCodeAt(0) > 127;
11649
- }
11650
- function buildReplacementOps(term) {
11651
- const ops = [];
11652
- for (let i = 0; i < term.length; i++) {
11653
- const homoglyphs = LETTER_TO_HOMOGLYPH_MAPPINGS[term[i]];
11654
- if (!homoglyphs) continue;
11655
- for (const replacement of homoglyphs) {
11656
- ops.push({ index: i, replacement });
11657
- }
11658
- }
11659
- return ops;
11660
- }
11661
- function applyOps(term, ops, selected) {
11662
- const chars = Array.from(term);
11663
- for (const idx of selected) {
11664
- chars[ops[idx].index] = ops[idx].replacement;
11665
- }
11666
- return chars.join("");
11667
- }
11668
- function generateCombinations(ops, opIndices, term, maxVariants, addFn, variants) {
11669
- const generate = (startIdx, depth, selected, usedPositions) => {
11670
- if (selected.length === depth) return addFn(applyOps(term, ops, selected));
11671
- for (let i = startIdx; i < opIndices.length && variants.length < maxVariants; i++) {
11672
- const opIdx = opIndices[i];
11673
- if (usedPositions.has(ops[opIdx].index)) continue;
11674
- selected.push(opIdx);
11675
- usedPositions.add(ops[opIdx].index);
11676
- if (generate(i + 1, depth, selected, usedPositions)) return true;
11677
- selected.pop();
11678
- usedPositions.delete(ops[opIdx].index);
11679
- }
11680
- return false;
11681
- };
11682
- for (let depth = 2; depth <= opIndices.length && variants.length < maxVariants; depth++) {
11683
- if (generate(0, depth, [], /* @__PURE__ */ new Set())) break;
11684
- }
11685
- }
11686
- function generateHomoglyphSearchTerms(term, maxVariants = DEFAULT_MAX_HOMOGLYPH_VARIANTS) {
11687
- if (term.length === 0 || maxVariants <= 0) return [];
11688
- const lowerTerm = term.toLowerCase();
11689
- const seen = /* @__PURE__ */ new Set();
11690
- const variants = [];
11691
- const add = (v) => {
11692
- if (v === lowerTerm || seen.has(v)) return false;
11693
- seen.add(v);
11694
- variants.push(v);
11695
- return variants.length >= maxVariants;
11696
- };
11697
- const allOps = buildReplacementOps(lowerTerm);
11698
- for (let i = 0; i < allOps.length && variants.length < maxVariants; i++) {
11699
- add(applyOps(lowerTerm, allOps, [i]));
11700
- }
11701
- if (variants.length < maxVariants) {
11702
- const cyrillicComposite = lowerTerm.split("").map((char) => {
11703
- var _a;
11704
- const homoglyphs = LETTER_TO_HOMOGLYPH_MAPPINGS[char];
11705
- return (_a = homoglyphs == null ? void 0 : homoglyphs.find((h) => isCyrillic(h))) != null ? _a : char;
11706
- }).join("");
11707
- add(cyrillicComposite);
11708
- }
11709
- const cyrillicOpIndices = allOps.map((op, i) => isCyrillic(op.replacement) ? i : -1).filter((i) => i >= 0);
11710
- if (variants.length < maxVariants && cyrillicOpIndices.length >= 2) {
11711
- generateCombinations(
11712
- allOps,
11713
- cyrillicOpIndices,
11714
- lowerTerm,
11715
- maxVariants,
11716
- add,
11717
- variants
11718
- );
11719
- }
11720
- if (variants.length < maxVariants) {
11721
- const allOpIndices = allOps.map((_, i) => i);
11722
- generateCombinations(allOps, allOpIndices, lowerTerm, maxVariants, add, variants);
11723
- }
11724
- return variants;
11725
- }
11726
- function normalizeHomoglyphs(text, customMappings = {}) {
11727
- const mappings = __spreadValues(__spreadValues({}, HOMOGLYPH_MAPPINGS), customMappings);
11728
- return text.toLowerCase().split("").map((char) => mappings[char] || char).join("");
11729
- }
11730
-
11731
- // ../../internal/utils/src/format.ts
11732
- var format_exports = {};
11733
- __export(format_exports, {
11734
- formatCompactNumber: () => formatCompactNumber,
11735
- formatFileSize: () => formatFileSize
11794
+ var UserOrgTrademarkRegistrationSchema = z.object({
11795
+ id: z.number().describe("Trademark registration ID"),
11796
+ brandName: z.string().describe("Trademarked brand name as it appears on the registration"),
11797
+ trademarkOffice: z.string().describe("Issuing trademark office (e.g. `USPTO`, `EUIPO`)"),
11798
+ registrationNumber: z.string().describe("Registration number assigned by the office"),
11799
+ goodsAndServicesClass: z.string().describe("Nice Classification class(es) the registration covers"),
11800
+ rightsOwnerName: z.string().nullable().describe("Legal entity the trademark is registered to, if recorded"),
11801
+ registrationPageUrl: z.string().nullable().describe("Public URL on the trademark office's site, if recorded"),
11802
+ certificateFileName: z.string().nullable().describe(
11803
+ "Original filename of the uploaded certificate PDF (null when no certificate is attached)"
11804
+ ),
11805
+ certificateFileUrl: z.string().nullable().describe(
11806
+ "Direct URL to view or download the certificate PDF (null when no certificate is attached)"
11807
+ )
11808
+ });
11809
+ var UserOrgBrandMetadataSchema = z.object({
11810
+ websiteUrl: z.string().nullable().describe("Public website URL of the brand (linked from the portal header)"),
11811
+ twitterHandle: z.string().nullable().describe(
11812
+ "Public Twitter/X handle of the brand, stored with the leading `@` (e.g. `@acme`)"
11813
+ ),
11814
+ securityContactEmail: z.string().nullable().describe(
11815
+ "Email address for security correspondence \u2014 used by takedown providers and researchers, distinct from the internal customer POC email"
11816
+ ),
11817
+ industry: z.string().nullable().describe('Free-form industry label (e.g. "DeFi", "CEX", "NFT", "Wallet")')
11818
+ });
11819
+ var UserOrgPortalCustomizationSchema = z.object({
11820
+ useCustomDetails: z.boolean().describe(
11821
+ "When true, the portal uses `name`/`slug`/`avatarUrl` from this object instead of the org's own name/slug/avatar"
11822
+ ),
11823
+ name: z.string().nullable().describe(
11824
+ "Custom display name shown on the portal (used only when `useCustomDetails=true`)"
11825
+ ),
11826
+ slug: z.string().nullable().describe(
11827
+ "Custom URL slug (`chainpatrol.io/<slug>`) \u2014 takes precedence over the org's own slug when set, regardless of `useCustomDetails`"
11828
+ ),
11829
+ avatarUrl: z.string().nullable().describe(
11830
+ "Custom avatar URL shown on the portal (used only when `useCustomDetails=true`)"
11831
+ ),
11832
+ bannerEnabled: z.boolean().describe(
11833
+ "When true, the portal renders `bannerContent` as a highlighted banner at the top of the page"
11834
+ ),
11835
+ bannerContent: z.string().nullable().describe(
11836
+ "Markdown body of the portal banner. Null (or empty) with `bannerEnabled=true` means the toggle is on but no content has been written yet"
11837
+ )
11838
+ });
11839
+ var UserOrgSchema = z.object({
11840
+ id: z.number(),
11841
+ name: z.string(),
11842
+ slug: z.string(),
11843
+ avatarUrl: z.string().nullable(),
11844
+ contactUrl: z.string().nullable(),
11845
+ subscriptionStatus: z.nativeEnum(SubscriptionStatus),
11846
+ portalVisibility: z.nativeEnum(OrganizationPortalVisibility).describe(
11847
+ "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."
11848
+ ),
11849
+ reportVisibility: z.nativeEnum(ReportVisibility).describe(
11850
+ "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."
11851
+ ),
11852
+ metricsVisibility: z.nativeEnum(MetricsVisibility).describe(
11853
+ "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."
11854
+ ),
11855
+ brandMetadata: UserOrgBrandMetadataSchema.describe(
11856
+ "Public brand-facing metadata (website, twitter, security contact, industry) shown on the portal and used by staff for outbound"
11857
+ ),
11858
+ portalCustomization: UserOrgPortalCustomizationSchema.describe(
11859
+ "Customer-configurable presentation of the public security portal \u2014 custom name/slug/avatar and the banner content"
11860
+ ),
11861
+ services: z.object({
11862
+ reporting: singleServiceSchema,
11863
+ reviewing: singleServiceSchema,
11864
+ protection: singleServiceSchema,
11865
+ takedowns: takedownsServiceSchema,
11866
+ detection: singleServiceSchema,
11867
+ darkWebMonitoring: singleServiceSchema
11868
+ }),
11869
+ integrations: UserOrgIntegrationsSchema,
11870
+ obligatoryAdminApproval: UserOrgObligatoryAdminApprovalSchema,
11871
+ pendingServiceApprovals: z.array(PendingServiceApprovalSchema),
11872
+ legalDocuments: UserOrgLegalDocumentsSchema.describe(
11873
+ "Org-level Letter of Authorization and Power of Attorney attachments"
11874
+ ),
11875
+ trademarkRegistrations: z.array(UserOrgTrademarkRegistrationSchema).describe(
11876
+ "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."
11877
+ )
11736
11878
  });
11737
- function formatCompactNumber(num3, options = {}) {
11738
- const { decimals = 1, fallback = "-" } = options;
11739
- if (num3 === void 0 || num3 === null) {
11740
- return fallback;
11741
- }
11742
- if (num3 >= 1e9) {
11743
- return `${(num3 / 1e9).toFixed(decimals)}B`;
11744
- }
11745
- if (num3 >= 1e6) {
11746
- return `${(num3 / 1e6).toFixed(decimals)}M`;
11747
- }
11748
- if (num3 >= 1e3) {
11749
- return `${(num3 / 1e3).toFixed(decimals)}K`;
11750
- }
11751
- return num3.toString();
11752
- }
11753
- function formatFileSize(bytes, options = {}) {
11754
- const { decimals = 1, binary = true, showUnknown = true } = options;
11755
- if (bytes === null || bytes === void 0 || bytes === "") {
11756
- return showUnknown ? "Unknown" : "0 B";
11757
- }
11758
- const size = typeof bytes === "string" ? parseInt(bytes, 10) : bytes;
11759
- if (isNaN(size) || size < 0) {
11760
- return showUnknown ? "Unknown" : "0 B";
11761
- }
11762
- if (size === 0) {
11763
- return "0 B";
11764
- }
11765
- const unit = binary ? 1024 : 1e3;
11766
- const units = binary ? ["B", "KB", "MB", "GB", "TB", "PB"] : ["B", "kB", "MB", "GB", "TB", "PB"];
11767
- const unitIndex = Math.floor(Math.log(size) / Math.log(unit));
11768
- const finalUnitIndex = Math.min(unitIndex, units.length - 1);
11769
- const value = size / Math.pow(unit, finalUnitIndex);
11770
- if (finalUnitIndex === 0) {
11771
- return `${size} B`;
11772
- }
11773
- return `${value.toFixed(decimals)} ${units[finalUnitIndex]}`;
11774
- }
11775
-
11776
- // ../../internal/utils/src/social-profile-url.ts
11777
- var social_profile_url_exports = {};
11778
- __export(social_profile_url_exports, {
11779
- LINKEDIN_PROFILE_URL_PATTERN: () => LINKEDIN_PROFILE_URL_PATTERN,
11780
- TWITTER_PROFILE_URL_PATTERN: () => TWITTER_PROFILE_URL_PATTERN,
11781
- isLinkedInProfileUrl: () => isLinkedInProfileUrl,
11782
- isSupportedSocialProfileUrl: () => isSupportedSocialProfileUrl,
11783
- isTwitterProfileUrl: () => isTwitterProfileUrl,
11784
- parseLinkedInProfileUrl: () => parseLinkedInProfileUrl
11879
+ z.object({
11880
+ organizations: z.array(UserOrgSchema)
11785
11881
  });
11786
- var TWITTER_PROFILE_URL_PATTERN = /^https?:\/\/(?:www\.)?(?:twitter\.com|x\.com)\/[^/?#]+\/?(?:[?#].*)?$/i;
11787
- var LINKEDIN_PROFILE_URL_PATTERN = /^https?:\/\/(?:[a-z]{2,3}\.)?linkedin\.com\/(in|company|school)\/([^/?#]+)/i;
11788
- function isTwitterProfileUrl(url) {
11789
- return TWITTER_PROFILE_URL_PATTERN.test(url);
11790
- }
11791
- function isLinkedInProfileUrl(url) {
11792
- return LINKEDIN_PROFILE_URL_PATTERN.test(url);
11793
- }
11794
- function isSupportedSocialProfileUrl(url) {
11795
- return isTwitterProfileUrl(url) || isLinkedInProfileUrl(url);
11796
- }
11797
- function humanizeLinkedInHandle(handle) {
11798
- const withoutTrailingDigits = handle.replace(/-[0-9a-f]{6,}$/i, "");
11799
- return withoutTrailingDigits.split("-").filter(Boolean).map((part) => part.charAt(0).toUpperCase() + part.slice(1)).join(" ");
11800
- }
11801
- function parseLinkedInProfileUrl(url) {
11802
- var _a;
11803
- const match2 = url.match(LINKEDIN_PROFILE_URL_PATTERN);
11804
- if (!match2) return null;
11805
- const pathSegment = (_a = match2[1]) == null ? void 0 : _a.toLowerCase();
11806
- const rawHandle = match2[2];
11807
- if (!pathSegment || !rawHandle) return null;
11808
- let handle;
11882
+
11883
+ // ../../internal/validation/src/public/organization/metrics-get.ts
11884
+ var organizationMetricsIncludeFieldSchema = z.enum([
11885
+ "reports",
11886
+ "newThreats",
11887
+ "threatsWatchlisted",
11888
+ "takedownsFiled",
11889
+ "takedownsCompleted",
11890
+ "domainThreats",
11891
+ "twitterThreats",
11892
+ "telegramThreats",
11893
+ "otherThreats",
11894
+ "blockedByType",
11895
+ "blockedByDay"
11896
+ ]);
11897
+ organizationMetricsIncludeFieldSchema.options;
11898
+ var ORGANIZATION_METRICS_MAX_SLUGS = 500;
11899
+ var organizationMetricsServicesFilterSchema = z.preprocess((value) => {
11900
+ if (typeof value !== "string") return value;
11809
11901
  try {
11810
- handle = decodeURIComponent(rawHandle).trim();
11902
+ return JSON.parse(value);
11811
11903
  } catch (e4) {
11812
- return null;
11904
+ return value;
11813
11905
  }
11814
- if (!handle) return null;
11815
- const name = humanizeLinkedInHandle(handle) || handle;
11816
- const profileUrl = `https://www.linkedin.com/${pathSegment}/${handle}`;
11817
- return { pathSegment, handle, name, profileUrl };
11818
- }
11819
-
11820
- // ../../internal/validation/src/public/report/create.ts
11906
+ }, userOrgsServicesFilterObjectSchema).optional();
11907
+ z.object({
11908
+ organizationSlug: z.string().optional().describe(
11909
+ "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`."
11910
+ ),
11911
+ slugs: z.array(z.string()).max(ORGANIZATION_METRICS_MAX_SLUGS).optional().describe(
11912
+ "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`."
11913
+ ),
11914
+ allMyOrgs: z.preprocess((value) => {
11915
+ if (value === "true") return true;
11916
+ if (value === "false") return false;
11917
+ return value;
11918
+ }, z.boolean()).optional().describe(
11919
+ "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`."
11920
+ ),
11921
+ subscriptionStatus: z.array(UserOrgsSubscriptionStatusSchema).min(1).optional().describe(
11922
+ "Only meaningful with `allMyOrgs: true`. Defaults to the same set `/user/orgs` uses (ACTIVE/POC/PROSPECT/INTEGRATION \u2014 INACTIVE is always excluded)."
11923
+ ),
11924
+ services: organizationMetricsServicesFilterSchema.describe(
11925
+ "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'."
11926
+ ),
11927
+ brandSlug: z.string().optional(),
11928
+ startDate: z.coerce.date().optional(),
11929
+ endDate: z.coerce.date().optional(),
11930
+ include: z.array(organizationMetricsIncludeFieldSchema).optional().describe(
11931
+ "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`."
11932
+ )
11933
+ }).refine(
11934
+ (value) => {
11935
+ const explicitForms = [
11936
+ Boolean(value.organizationSlug),
11937
+ Boolean(value.slugs && value.slugs.length > 0),
11938
+ Boolean(value.allMyOrgs)
11939
+ ].filter(Boolean).length;
11940
+ return explicitForms <= 1;
11941
+ },
11942
+ {
11943
+ message: "Pass at most one of `organizationSlug`, `slugs`, or `allMyOrgs`.",
11944
+ path: ["allMyOrgs"]
11945
+ }
11946
+ ).refine((value) => !(value.brandSlug && value.slugs && value.slugs.length > 1), {
11947
+ message: "`brandSlug` is only valid alongside a single organization, not `slugs`.",
11948
+ path: ["brandSlug"]
11949
+ }).refine((value) => !(value.brandSlug && value.allMyOrgs), {
11950
+ message: "`brandSlug` is only valid for a single org, not `allMyOrgs`.",
11951
+ path: ["brandSlug"]
11952
+ });
11953
+ var metricValue = z.number().nullable();
11954
+ var metricsObjectSchema = z.object({
11955
+ reports: metricValue,
11956
+ newThreats: metricValue,
11957
+ threatsWatchlisted: metricValue,
11958
+ takedownsFiled: metricValue,
11959
+ takedownsCompleted: metricValue,
11960
+ domainThreats: metricValue,
11961
+ twitterThreats: metricValue,
11962
+ telegramThreats: metricValue,
11963
+ otherThreats: metricValue
11964
+ });
11965
+ var blockedByTypeSchema = z.array(
11966
+ z.object({
11967
+ type: z.string(),
11968
+ count: z.number()
11969
+ })
11970
+ ).nullable();
11971
+ var blockedByDaySchema = z.array(
11972
+ z.object({
11973
+ date: z.string(),
11974
+ count: z.number()
11975
+ })
11976
+ ).nullable();
11977
+ z.object({
11978
+ /**
11979
+ * Aggregate metrics. For single-org callers this is just that org's
11980
+ * numbers; for multi-org callers (`slugs.length > 1` or `allMyOrgs`)
11981
+ * it is the sum across all queried orgs.
11982
+ */
11983
+ metrics: metricsObjectSchema,
11984
+ blockedByType: blockedByTypeSchema,
11985
+ blockedByDay: blockedByDaySchema,
11986
+ /**
11987
+ * Derived averages over the time window (and, in multi-org mode,
11988
+ * across orgs). `perDay = metrics / windowDays`. In multi-org mode
11989
+ * `perOrgPerDay = metrics / numOrgs / windowDays`; in single-org
11990
+ * mode it is `null`. Counts are floats here — the underlying
11991
+ * `metrics` fields stay integer counts.
11992
+ */
11993
+ averages: z.object({
11994
+ perDay: metricsObjectSchema.nullable(),
11995
+ perOrgPerDay: metricsObjectSchema.nullable(),
11996
+ windowDays: z.number().nullable()
11997
+ }),
11998
+ /**
11999
+ * Per-org breakdown. Only populated in multi-org mode; `null` for
12000
+ * single-org callers.
12001
+ */
12002
+ perOrg: z.record(
12003
+ z.string(),
12004
+ z.object({
12005
+ metrics: metricsObjectSchema,
12006
+ blockedByType: blockedByTypeSchema,
12007
+ blockedByDay: blockedByDaySchema
12008
+ })
12009
+ ).nullable(),
12010
+ /**
12011
+ * Echoes the actual orgs the response covers, in the order they
12012
+ * were resolved. Single-org responses always have length 1. The
12013
+ * `resolvedFrom` field distinguishes how the caller asked for the
12014
+ * scope (useful for agent reporting).
12015
+ */
12016
+ scope: z.object({
12017
+ mode: z.enum(["single", "multi"]),
12018
+ orgs: z.array(z.string()),
12019
+ resolvedFrom: z.enum(["api-key", "organizationSlug", "slugs", "allMyOrgs"])
12020
+ })
12021
+ });
11821
12022
  var BASE_64_PATTERN = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
11822
12023
  var PHONE_COUNTRY_CODE_ERROR_MESSAGE = "Phone numbers must include a country code in E.164 format (for example, +14155552671).";
11823
12024
  function isPhoneNumberMissingCountryCode(value) {
@@ -13138,20 +13339,20 @@ var convertA98ToXyz65_default = convertA98ToXyz65;
13138
13339
 
13139
13340
  // ../../node_modules/culori/src/a98/convertXyz65ToA98.js
13140
13341
  var gamma = (v) => Math.pow(Math.abs(v), 256 / 563) * Math.sign(v);
13141
- var convertXyz65ToA98 = ({ x, y, z: z50, alpha }) => {
13342
+ var convertXyz65ToA98 = ({ x, y, z: z54, alpha }) => {
13142
13343
  if (x === void 0) x = 0;
13143
13344
  if (y === void 0) y = 0;
13144
- if (z50 === void 0) z50 = 0;
13345
+ if (z54 === void 0) z54 = 0;
13145
13346
  let res = {
13146
13347
  mode: "a98",
13147
13348
  r: gamma(
13148
- x * 2.0415879038107465 - y * 0.5650069742788597 - 0.3447313507783297 * z50
13349
+ x * 2.0415879038107465 - y * 0.5650069742788597 - 0.3447313507783297 * z54
13149
13350
  ),
13150
13351
  g: gamma(
13151
- x * -0.9692436362808798 + y * 1.8759675015077206 + 0.0415550574071756 * z50
13352
+ x * -0.9692436362808798 + y * 1.8759675015077206 + 0.0415550574071756 * z54
13152
13353
  ),
13153
13354
  b: gamma(
13154
- x * 0.0134442806320312 - y * 0.1183623922310184 + 1.0151749943912058 * z50
13355
+ x * 0.0134442806320312 - y * 0.1183623922310184 + 1.0151749943912058 * z54
13155
13356
  )
13156
13357
  };
13157
13358
  if (alpha !== void 0) {
@@ -13218,14 +13419,14 @@ var convertLrgbToRgb = ({ r, g, b, alpha }, mode = "rgb") => {
13218
13419
  var convertLrgbToRgb_default = convertLrgbToRgb;
13219
13420
 
13220
13421
  // ../../node_modules/culori/src/xyz65/convertXyz65ToRgb.js
13221
- var convertXyz65ToRgb = ({ x, y, z: z50, alpha }) => {
13422
+ var convertXyz65ToRgb = ({ x, y, z: z54, alpha }) => {
13222
13423
  if (x === void 0) x = 0;
13223
13424
  if (y === void 0) y = 0;
13224
- if (z50 === void 0) z50 = 0;
13425
+ if (z54 === void 0) z54 = 0;
13225
13426
  let res = convertLrgbToRgb_default({
13226
- r: x * 3.2409699419045226 - y * 1.537383177570094 - 0.4986107602930034 * z50,
13227
- g: x * -0.9692436362808796 + y * 1.8759675015077204 + 0.0415550574071756 * z50,
13228
- b: x * 0.0556300796969936 - y * 0.2039769588889765 + 1.0569715142428784 * z50
13427
+ r: x * 3.2409699419045226 - y * 1.537383177570094 - 0.4986107602930034 * z54,
13428
+ g: x * -0.9692436362808796 + y * 1.8759675015077204 + 0.0415550574071756 * z54,
13429
+ b: x * 0.0556300796969936 - y * 0.2039769588889765 + 1.0569715142428784 * z54
13229
13430
  });
13230
13431
  if (alpha !== void 0) {
13231
13432
  res.alpha = alpha;
@@ -13475,13 +13676,13 @@ var convertLab65ToRgb_default = convertLab65ToRgb;
13475
13676
 
13476
13677
  // ../../node_modules/culori/src/lab65/convertXyz65ToLab65.js
13477
13678
  var f = (value) => value > e ? Math.cbrt(value) : (k * value + 16) / 116;
13478
- var convertXyz65ToLab65 = ({ x, y, z: z50, alpha }) => {
13679
+ var convertXyz65ToLab65 = ({ x, y, z: z54, alpha }) => {
13479
13680
  if (x === void 0) x = 0;
13480
13681
  if (y === void 0) y = 0;
13481
- if (z50 === void 0) z50 = 0;
13682
+ if (z54 === void 0) z54 = 0;
13482
13683
  let f0 = f(x / D65.X);
13483
13684
  let f1 = f(y / D65.Y);
13484
- let f22 = f(z50 / D65.Z);
13685
+ let f22 = f(z54 / D65.Z);
13485
13686
  let res = {
13486
13687
  mode: "lab65",
13487
13688
  l: 116 * f1 - 16,
@@ -14138,10 +14339,10 @@ var convertItpToXyz65_default = convertItpToXyz65;
14138
14339
 
14139
14340
  // ../../node_modules/culori/src/itp/convertXyz65ToItp.js
14140
14341
  var toAbs = (c2 = 0) => Math.max(c2 * YW, 0);
14141
- var convertXyz65ToItp = ({ x, y, z: z50, alpha }) => {
14342
+ var convertXyz65ToItp = ({ x, y, z: z54, alpha }) => {
14142
14343
  const absX = toAbs(x);
14143
14344
  const absY = toAbs(y);
14144
- const absZ = toAbs(z50);
14345
+ const absZ = toAbs(z54);
14145
14346
  const l2 = transferPqEncode(
14146
14347
  0.3592832590121217 * absX + 0.6976051147779502 * absY - 0.0358915932320289 * absZ
14147
14348
  );
@@ -14199,15 +14400,15 @@ var jabPqEncode = (v) => {
14199
14400
  return Math.pow((C1 + C2 * vn3) / (1 + C3 * vn3), p);
14200
14401
  };
14201
14402
  var abs = (v = 0) => Math.max(v * 203, 0);
14202
- var convertXyz65ToJab = ({ x, y, z: z50, alpha }) => {
14403
+ var convertXyz65ToJab = ({ x, y, z: z54, alpha }) => {
14203
14404
  x = abs(x);
14204
14405
  y = abs(y);
14205
- z50 = abs(z50);
14206
- let xp = 1.15 * x - 0.15 * z50;
14406
+ z54 = abs(z54);
14407
+ let xp = 1.15 * x - 0.15 * z54;
14207
14408
  let yp = 0.66 * y + 0.34 * x;
14208
- let l2 = jabPqEncode(0.41478972 * xp + 0.579999 * yp + 0.014648 * z50);
14209
- let m = jabPqEncode(-0.20151 * xp + 1.120649 * yp + 0.0531008 * z50);
14210
- let s2 = jabPqEncode(-0.0166008 * xp + 0.2648 * yp + 0.6684799 * z50);
14409
+ let l2 = jabPqEncode(0.41478972 * xp + 0.579999 * yp + 0.014648 * z54);
14410
+ let m = jabPqEncode(-0.20151 * xp + 1.120649 * yp + 0.0531008 * z54);
14411
+ let s2 = jabPqEncode(-0.0166008 * xp + 0.2648 * yp + 0.6684799 * z54);
14211
14412
  let i = (l2 + m) / 2;
14212
14413
  let res = {
14213
14414
  mode: "jab",
@@ -14393,14 +14594,14 @@ var convertLabToXyz50 = ({ l: l2, a, b, alpha }) => {
14393
14594
  var convertLabToXyz50_default = convertLabToXyz50;
14394
14595
 
14395
14596
  // ../../node_modules/culori/src/xyz50/convertXyz50ToRgb.js
14396
- var convertXyz50ToRgb = ({ x, y, z: z50, alpha }) => {
14597
+ var convertXyz50ToRgb = ({ x, y, z: z54, alpha }) => {
14397
14598
  if (x === void 0) x = 0;
14398
14599
  if (y === void 0) y = 0;
14399
- if (z50 === void 0) z50 = 0;
14600
+ if (z54 === void 0) z54 = 0;
14400
14601
  let res = convertLrgbToRgb_default({
14401
- r: x * 3.1341359569958707 - y * 1.6173863321612538 - 0.4906619460083532 * z50,
14402
- g: x * -0.978795502912089 + y * 1.916254567259524 + 0.03344273116131949 * z50,
14403
- b: x * 0.07195537988411677 - y * 0.2289768264158322 + 1.405386058324125 * z50
14602
+ r: x * 3.1341359569958707 - y * 1.6173863321612538 - 0.4906619460083532 * z54,
14603
+ g: x * -0.978795502912089 + y * 1.916254567259524 + 0.03344273116131949 * z54,
14604
+ b: x * 0.07195537988411677 - y * 0.2289768264158322 + 1.405386058324125 * z54
14404
14605
  });
14405
14606
  if (alpha !== void 0) {
14406
14607
  res.alpha = alpha;
@@ -14431,13 +14632,13 @@ var convertRgbToXyz50_default = convertRgbToXyz50;
14431
14632
 
14432
14633
  // ../../node_modules/culori/src/lab/convertXyz50ToLab.js
14433
14634
  var f2 = (value) => value > e3 ? Math.cbrt(value) : (k3 * value + 16) / 116;
14434
- var convertXyz50ToLab = ({ x, y, z: z50, alpha }) => {
14635
+ var convertXyz50ToLab = ({ x, y, z: z54, alpha }) => {
14435
14636
  if (x === void 0) x = 0;
14436
14637
  if (y === void 0) y = 0;
14437
- if (z50 === void 0) z50 = 0;
14638
+ if (z54 === void 0) z54 = 0;
14438
14639
  let f0 = f2(x / D50.X);
14439
14640
  let f1 = f2(y / D50.Y);
14440
- let f22 = f2(z50 / D50.Z);
14641
+ let f22 = f2(z54 / D50.Z);
14441
14642
  let res = {
14442
14643
  mode: "lab",
14443
14644
  l: 116 * f1 - 16,
@@ -14672,18 +14873,18 @@ var convertLchuvToLuv = ({ l: l2, c: c2, h, alpha }) => {
14672
14873
  var convertLchuvToLuv_default = convertLchuvToLuv;
14673
14874
 
14674
14875
  // ../../node_modules/culori/src/luv/convertXyz50ToLuv.js
14675
- var u_fn = (x, y, z50) => 4 * x / (x + 15 * y + 3 * z50);
14676
- var v_fn = (x, y, z50) => 9 * y / (x + 15 * y + 3 * z50);
14876
+ var u_fn = (x, y, z54) => 4 * x / (x + 15 * y + 3 * z54);
14877
+ var v_fn = (x, y, z54) => 9 * y / (x + 15 * y + 3 * z54);
14677
14878
  var un = u_fn(D50.X, D50.Y, D50.Z);
14678
14879
  var vn = v_fn(D50.X, D50.Y, D50.Z);
14679
14880
  var l_fn = (value) => value <= e3 ? k3 * value : 116 * Math.cbrt(value) - 16;
14680
- var convertXyz50ToLuv = ({ x, y, z: z50, alpha }) => {
14881
+ var convertXyz50ToLuv = ({ x, y, z: z54, alpha }) => {
14681
14882
  if (x === void 0) x = 0;
14682
14883
  if (y === void 0) y = 0;
14683
- if (z50 === void 0) z50 = 0;
14884
+ if (z54 === void 0) z54 = 0;
14684
14885
  let l2 = l_fn(y / D50.Y);
14685
- let u = u_fn(x, y, z50);
14686
- let v = v_fn(x, y, z50);
14886
+ let u = u_fn(x, y, z54);
14887
+ let v = v_fn(x, y, z54);
14687
14888
  if (!isFinite(u) || !isFinite(v)) {
14688
14889
  l2 = u = v = 0;
14689
14890
  } else {
@@ -14704,8 +14905,8 @@ var convertXyz50ToLuv = ({ x, y, z: z50, alpha }) => {
14704
14905
  var convertXyz50ToLuv_default = convertXyz50ToLuv;
14705
14906
 
14706
14907
  // ../../node_modules/culori/src/luv/convertLuvToXyz50.js
14707
- var u_fn2 = (x, y, z50) => 4 * x / (x + 15 * y + 3 * z50);
14708
- var v_fn2 = (x, y, z50) => 9 * y / (x + 15 * y + 3 * z50);
14908
+ var u_fn2 = (x, y, z54) => 4 * x / (x + 15 * y + 3 * z54);
14909
+ var v_fn2 = (x, y, z54) => 9 * y / (x + 15 * y + 3 * z54);
14709
14910
  var un2 = u_fn2(D50.X, D50.Y, D50.Z);
14710
14911
  var vn2 = v_fn2(D50.X, D50.Y, D50.Z);
14711
14912
  var convertLuvToXyz50 = ({ l: l2, u, v, alpha }) => {
@@ -14719,8 +14920,8 @@ var convertLuvToXyz50 = ({ l: l2, u, v, alpha }) => {
14719
14920
  let vp = v / (13 * l2) + vn2;
14720
14921
  let y = D50.Y * (l2 <= 8 ? l2 / k3 : Math.pow((l2 + 16) / 116, 3));
14721
14922
  let x = y * (9 * up) / (4 * vp);
14722
- let z50 = y * (12 - 3 * up - 20 * vp) / (4 * vp);
14723
- let res = { mode: "xyz50", x, y, z: z50 };
14923
+ let z54 = y * (12 - 3 * up - 20 * vp) / (4 * vp);
14924
+ let res = { mode: "xyz50", x, y, z: z54 };
14724
14925
  if (alpha !== void 0) {
14725
14926
  res.alpha = alpha;
14726
14927
  }
@@ -15337,15 +15538,15 @@ var convertP3ToXyz65 = (rgb2) => {
15337
15538
  var convertP3ToXyz65_default = convertP3ToXyz65;
15338
15539
 
15339
15540
  // ../../node_modules/culori/src/p3/convertXyz65ToP3.js
15340
- var convertXyz65ToP3 = ({ x, y, z: z50, alpha }) => {
15541
+ var convertXyz65ToP3 = ({ x, y, z: z54, alpha }) => {
15341
15542
  if (x === void 0) x = 0;
15342
15543
  if (y === void 0) y = 0;
15343
- if (z50 === void 0) z50 = 0;
15544
+ if (z54 === void 0) z54 = 0;
15344
15545
  let res = convertLrgbToRgb_default(
15345
15546
  {
15346
- r: x * 2.4934969119414263 - y * 0.9313836179191242 - 0.402710784450717 * z50,
15347
- g: x * -0.8294889695615749 + y * 1.7626640603183465 + 0.0236246858419436 * z50,
15348
- b: x * 0.0358458302437845 - y * 0.0761723892680418 + 0.9568845240076871 * z50
15547
+ r: x * 2.4934969119414263 - y * 0.9313836179191242 - 0.402710784450717 * z54,
15548
+ g: x * -0.8294889695615749 + y * 1.7626640603183465 + 0.0236246858419436 * z54,
15549
+ b: x * 0.0358458302437845 - y * 0.0761723892680418 + 0.9568845240076871 * z54
15349
15550
  },
15350
15551
  "p3"
15351
15552
  );
@@ -15380,19 +15581,19 @@ var gamma2 = (v) => {
15380
15581
  }
15381
15582
  return 16 * v;
15382
15583
  };
15383
- var convertXyz50ToProphoto = ({ x, y, z: z50, alpha }) => {
15584
+ var convertXyz50ToProphoto = ({ x, y, z: z54, alpha }) => {
15384
15585
  if (x === void 0) x = 0;
15385
15586
  if (y === void 0) y = 0;
15386
- if (z50 === void 0) z50 = 0;
15587
+ if (z54 === void 0) z54 = 0;
15387
15588
  let res = {
15388
15589
  mode: "prophoto",
15389
15590
  r: gamma2(
15390
- x * 1.3457868816471585 - y * 0.2555720873797946 - 0.0511018649755453 * z50
15591
+ x * 1.3457868816471585 - y * 0.2555720873797946 - 0.0511018649755453 * z54
15391
15592
  ),
15392
15593
  g: gamma2(
15393
- x * -0.5446307051249019 + y * 1.5082477428451466 + 0.0205274474364214 * z50
15594
+ x * -0.5446307051249019 + y * 1.5082477428451466 + 0.0205274474364214 * z54
15394
15595
  ),
15395
- b: gamma2(x * 0 + y * 0 + 1.2119675456389452 * z50)
15596
+ b: gamma2(x * 0 + y * 0 + 1.2119675456389452 * z54)
15396
15597
  };
15397
15598
  if (alpha !== void 0) {
15398
15599
  res.alpha = alpha;
@@ -15452,20 +15653,20 @@ var gamma3 = (v) => {
15452
15653
  }
15453
15654
  return 4.5 * v;
15454
15655
  };
15455
- var convertXyz65ToRec2020 = ({ x, y, z: z50, alpha }) => {
15656
+ var convertXyz65ToRec2020 = ({ x, y, z: z54, alpha }) => {
15456
15657
  if (x === void 0) x = 0;
15457
15658
  if (y === void 0) y = 0;
15458
- if (z50 === void 0) z50 = 0;
15659
+ if (z54 === void 0) z54 = 0;
15459
15660
  let res = {
15460
15661
  mode: "rec2020",
15461
15662
  r: gamma3(
15462
- x * 1.7166511879712683 - y * 0.3556707837763925 - 0.2533662813736599 * z50
15663
+ x * 1.7166511879712683 - y * 0.3556707837763925 - 0.2533662813736599 * z54
15463
15664
  ),
15464
15665
  g: gamma3(
15465
- x * -0.6666843518324893 + y * 1.6164812366349395 + 0.0157685458139111 * z50
15666
+ x * -0.6666843518324893 + y * 1.6164812366349395 + 0.0157685458139111 * z54
15466
15667
  ),
15467
15668
  b: gamma3(
15468
- x * 0.0176398574453108 - y * 0.0427706132578085 + 0.9421031212354739 * z50
15669
+ x * 0.0176398574453108 - y * 0.0427706132578085 + 0.9421031212354739 * z54
15469
15670
  )
15470
15671
  };
15471
15672
  if (alpha !== void 0) {
@@ -15618,15 +15819,15 @@ var definition_default26 = definition26;
15618
15819
 
15619
15820
  // ../../node_modules/culori/src/xyz65/convertXyz65ToXyz50.js
15620
15821
  var convertXyz65ToXyz50 = (xyz652) => {
15621
- let { x, y, z: z50, alpha } = xyz652;
15822
+ let { x, y, z: z54, alpha } = xyz652;
15622
15823
  if (x === void 0) x = 0;
15623
15824
  if (y === void 0) y = 0;
15624
- if (z50 === void 0) z50 = 0;
15825
+ if (z54 === void 0) z54 = 0;
15625
15826
  let res = {
15626
15827
  mode: "xyz50",
15627
- x: 1.0479298208405488 * x + 0.0229467933410191 * y - 0.0501922295431356 * z50,
15628
- y: 0.0296278156881593 * x + 0.990434484573249 * y - 0.0170738250293851 * z50,
15629
- z: -0.0092430581525912 * x + 0.0150551448965779 * y + 0.7518742899580008 * z50
15828
+ x: 1.0479298208405488 * x + 0.0229467933410191 * y - 0.0501922295431356 * z54,
15829
+ y: 0.0296278156881593 * x + 0.990434484573249 * y - 0.0170738250293851 * z54,
15830
+ z: -0.0092430581525912 * x + 0.0150551448965779 * y + 0.7518742899580008 * z54
15630
15831
  };
15631
15832
  if (alpha !== void 0) {
15632
15833
  res.alpha = alpha;
@@ -15637,15 +15838,15 @@ var convertXyz65ToXyz50_default = convertXyz65ToXyz50;
15637
15838
 
15638
15839
  // ../../node_modules/culori/src/xyz65/convertXyz50ToXyz65.js
15639
15840
  var convertXyz50ToXyz65 = (xyz502) => {
15640
- let { x, y, z: z50, alpha } = xyz502;
15841
+ let { x, y, z: z54, alpha } = xyz502;
15641
15842
  if (x === void 0) x = 0;
15642
15843
  if (y === void 0) y = 0;
15643
- if (z50 === void 0) z50 = 0;
15844
+ if (z54 === void 0) z54 = 0;
15644
15845
  let res = {
15645
15846
  mode: "xyz65",
15646
- x: 0.9554734527042182 * x - 0.0230985368742614 * y + 0.0632593086610217 * z50,
15647
- y: -0.0283697069632081 * x + 1.0099954580058226 * y + 0.021041398966943 * z50,
15648
- z: 0.0123140016883199 * x - 0.0205076964334779 * y + 1.3303659366080753 * z50
15847
+ x: 0.9554734527042182 * x - 0.0230985368742614 * y + 0.0632593086610217 * z54,
15848
+ y: -0.0283697069632081 * x + 1.0099954580058226 * y + 0.021041398966943 * z54,
15849
+ z: 0.0123140016883199 * x - 0.0205076964334779 * y + 1.3303659366080753 * z54
15649
15850
  };
15650
15851
  if (alpha !== void 0) {
15651
15852
  res.alpha = alpha;