@chainpatrol/sdk 0.2.4 → 0.4.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.d.ts +15 -2
- package/dist/index.js +183 -76
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +182 -77
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -4
package/dist/index.d.ts
CHANGED
|
@@ -47,14 +47,27 @@ type ChainPatrolClientOptions = {
|
|
|
47
47
|
apiKey: string;
|
|
48
48
|
baseUrl?: string;
|
|
49
49
|
};
|
|
50
|
+
type ApiRequest = {
|
|
51
|
+
path: string[];
|
|
52
|
+
method: "GET" | "POST" | "PUT" | "DELETE";
|
|
53
|
+
body?: unknown;
|
|
54
|
+
};
|
|
50
55
|
type AssetType = "URL" | "PAGE" | "ADDRESS";
|
|
51
56
|
type AssetStatus = "ALLOWED" | "BLOCKED" | "UNKNOWN";
|
|
57
|
+
declare class ChainPatrolClientError extends Error {
|
|
58
|
+
readonly code: ChainPatrolClientErrorCodes;
|
|
59
|
+
constructor(message: string, code: ChainPatrolClientErrorCodes);
|
|
60
|
+
}
|
|
61
|
+
declare enum ChainPatrolClientErrorCodes {
|
|
62
|
+
MISSING_API_KEY = "MISSING_API_KEY",
|
|
63
|
+
API_ERROR = "API_ERROR"
|
|
64
|
+
}
|
|
52
65
|
declare class ChainPatrolClient {
|
|
53
66
|
readonly baseUrl: string;
|
|
54
67
|
private readonly apiKey;
|
|
55
68
|
private readonly logger;
|
|
56
69
|
constructor(options: ChainPatrolClientOptions);
|
|
57
|
-
|
|
70
|
+
fetch<TResult = unknown>(req: ApiRequest): Promise<TResult>;
|
|
58
71
|
get asset(): {
|
|
59
72
|
check: (req: AssetCheckInput) => Promise<AssetCheckOutput>;
|
|
60
73
|
list: (req: AssetListInput) => Promise<AssetListOutput>;
|
|
@@ -203,4 +216,4 @@ declare namespace index {
|
|
|
203
216
|
};
|
|
204
217
|
}
|
|
205
218
|
|
|
206
|
-
export { AssetStatus, AssetType, ChainPatrolClient, ChainPatrolClientOptions, DetectorAssetStatus, DomainParseError, EventData, Events, Relay, index as Storage, ThreatDetector, URLResult };
|
|
219
|
+
export { AssetStatus, AssetType, ChainPatrolClient, ChainPatrolClientError, ChainPatrolClientErrorCodes, ChainPatrolClientOptions, DetectorAssetStatus, DomainParseError, EventData, Events, Relay, index as Storage, ThreatDetector, URLResult };
|
package/dist/index.js
CHANGED
|
@@ -473,50 +473,13 @@ zod.z.object({
|
|
|
473
473
|
description: zod.z.string().optional(),
|
|
474
474
|
assetGroupId: zod.z.number().optional()
|
|
475
475
|
});
|
|
476
|
-
|
|
477
|
-
// ../../internal/database/prisma/enums/index.ts
|
|
478
|
-
var AssetType = {
|
|
479
|
-
URL: "URL",
|
|
480
|
-
PAGE: "PAGE",
|
|
481
|
-
ADDRESS: "ADDRESS",
|
|
482
|
-
DISCORD: "DISCORD",
|
|
483
|
-
LINKEDIN: "LINKEDIN",
|
|
484
|
-
TWITTER: "TWITTER",
|
|
485
|
-
FACEBOOK: "FACEBOOK",
|
|
486
|
-
YOUTUBE: "YOUTUBE",
|
|
487
|
-
REDDIT: "REDDIT",
|
|
488
|
-
TELEGRAM: "TELEGRAM"
|
|
489
|
-
};
|
|
490
|
-
var AssetStatus = {
|
|
491
|
-
UNKNOWN: "UNKNOWN",
|
|
492
|
-
ALLOWED: "ALLOWED",
|
|
493
|
-
BLOCKED: "BLOCKED"
|
|
494
|
-
};
|
|
495
|
-
|
|
496
|
-
// ../../internal/validation/src/public/asset/check.ts
|
|
497
|
-
var assetCheckInputSchema = zod.z.object({
|
|
498
|
-
/** Asset content. Could be a domain, URL, or crypto address. */
|
|
499
|
-
content: zod.z.string().describe("Asset content")
|
|
500
|
-
}).describe("Check asset request body");
|
|
501
476
|
zod.z.object({
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
*/
|
|
507
|
-
status: zod.z.nativeEnum(AssetStatus).describe("The result of the asset status check"),
|
|
508
|
-
/**
|
|
509
|
-
* Optional reason for the asset's status.
|
|
510
|
-
* If the asset is allowed or blocked, this will be the reason why.
|
|
511
|
-
* ChainPatrol aggregates data from multiple sources, so this will
|
|
512
|
-
* tell you which source blocked or allowed the asset.
|
|
513
|
-
*/
|
|
514
|
-
reason: zod.z.string().optional().describe(`The reason for the result. If the result is \`BLOCKED\` this will be either
|
|
515
|
-
\`report\` if it was reported on ChainPatrol or \`eth-phishing-detect\` if it was
|
|
516
|
-
reported on the eth-phishing-detect list.`)
|
|
517
|
-
}).describe("Check asset response body");
|
|
477
|
+
content: zod.z.string().min(1, { message: "Content must be at least 3 character" }).max(1e3, { message: "Content must be less than 1000 characters" }),
|
|
478
|
+
email: zod.z.string().email(),
|
|
479
|
+
description: zod.z.string().optional().default("")
|
|
480
|
+
});
|
|
518
481
|
|
|
519
|
-
// ../../node_modules/luxon/src/errors.js
|
|
482
|
+
// ../../internal/validation/node_modules/luxon/src/errors.js
|
|
520
483
|
var LuxonError = class extends Error {
|
|
521
484
|
};
|
|
522
485
|
var InvalidDateTimeError = class extends LuxonError {
|
|
@@ -549,7 +512,7 @@ var ZoneIsAbstractError = class extends LuxonError {
|
|
|
549
512
|
}
|
|
550
513
|
};
|
|
551
514
|
|
|
552
|
-
// ../../node_modules/luxon/src/impl/formats.js
|
|
515
|
+
// ../../internal/validation/node_modules/luxon/src/impl/formats.js
|
|
553
516
|
var n = "numeric";
|
|
554
517
|
var s = "short";
|
|
555
518
|
var l = "long";
|
|
@@ -701,7 +664,7 @@ var DATETIME_HUGE_WITH_SECONDS = {
|
|
|
701
664
|
timeZoneName: l
|
|
702
665
|
};
|
|
703
666
|
|
|
704
|
-
// ../../node_modules/luxon/src/impl/util.js
|
|
667
|
+
// ../../internal/validation/node_modules/luxon/src/impl/util.js
|
|
705
668
|
function isUndefined(o) {
|
|
706
669
|
return typeof o === "undefined";
|
|
707
670
|
}
|
|
@@ -893,7 +856,7 @@ function timeObject(obj) {
|
|
|
893
856
|
}
|
|
894
857
|
var ianaRegex = /[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;
|
|
895
858
|
|
|
896
|
-
// ../../node_modules/luxon/src/impl/english.js
|
|
859
|
+
// ../../internal/validation/node_modules/luxon/src/impl/english.js
|
|
897
860
|
var monthsLong = [
|
|
898
861
|
"January",
|
|
899
862
|
"February",
|
|
@@ -1019,7 +982,7 @@ function formatRelativeTime(unit, count, numeric = "always", narrow = false) {
|
|
|
1019
982
|
return isInPast ? `${fmtValue} ${fmtUnit} ago` : `in ${fmtValue} ${fmtUnit}`;
|
|
1020
983
|
}
|
|
1021
984
|
|
|
1022
|
-
// ../../node_modules/luxon/src/impl/formatter.js
|
|
985
|
+
// ../../internal/validation/node_modules/luxon/src/impl/formatter.js
|
|
1023
986
|
function stringifyTokens(splits, tokenToString) {
|
|
1024
987
|
let s2 = "";
|
|
1025
988
|
for (const token of splits) {
|
|
@@ -1297,7 +1260,7 @@ var Formatter = class _Formatter {
|
|
|
1297
1260
|
}
|
|
1298
1261
|
};
|
|
1299
1262
|
|
|
1300
|
-
// ../../node_modules/luxon/src/impl/invalid.js
|
|
1263
|
+
// ../../internal/validation/node_modules/luxon/src/impl/invalid.js
|
|
1301
1264
|
var Invalid = class {
|
|
1302
1265
|
constructor(reason, explanation) {
|
|
1303
1266
|
this.reason = reason;
|
|
@@ -1312,7 +1275,7 @@ var Invalid = class {
|
|
|
1312
1275
|
}
|
|
1313
1276
|
};
|
|
1314
1277
|
|
|
1315
|
-
// ../../node_modules/luxon/src/zone.js
|
|
1278
|
+
// ../../internal/validation/node_modules/luxon/src/zone.js
|
|
1316
1279
|
var Zone = class {
|
|
1317
1280
|
/**
|
|
1318
1281
|
* The type of zone
|
|
@@ -1392,7 +1355,7 @@ var Zone = class {
|
|
|
1392
1355
|
}
|
|
1393
1356
|
};
|
|
1394
1357
|
|
|
1395
|
-
// ../../node_modules/luxon/src/zones/systemZone.js
|
|
1358
|
+
// ../../internal/validation/node_modules/luxon/src/zones/systemZone.js
|
|
1396
1359
|
var singleton = null;
|
|
1397
1360
|
var SystemZone = class _SystemZone extends Zone {
|
|
1398
1361
|
/**
|
|
@@ -1439,7 +1402,7 @@ var SystemZone = class _SystemZone extends Zone {
|
|
|
1439
1402
|
}
|
|
1440
1403
|
};
|
|
1441
1404
|
|
|
1442
|
-
// ../../node_modules/luxon/src/zones/IANAZone.js
|
|
1405
|
+
// ../../internal/validation/node_modules/luxon/src/zones/IANAZone.js
|
|
1443
1406
|
var dtfCache = {};
|
|
1444
1407
|
function makeDTF(zone) {
|
|
1445
1408
|
if (!dtfCache[zone]) {
|
|
@@ -1594,7 +1557,7 @@ var IANAZone = class _IANAZone extends Zone {
|
|
|
1594
1557
|
}
|
|
1595
1558
|
};
|
|
1596
1559
|
|
|
1597
|
-
// ../../node_modules/luxon/src/zones/fixedOffsetZone.js
|
|
1560
|
+
// ../../internal/validation/node_modules/luxon/src/zones/fixedOffsetZone.js
|
|
1598
1561
|
var singleton2 = null;
|
|
1599
1562
|
var FixedOffsetZone = class _FixedOffsetZone extends Zone {
|
|
1600
1563
|
/**
|
|
@@ -1677,7 +1640,7 @@ var FixedOffsetZone = class _FixedOffsetZone extends Zone {
|
|
|
1677
1640
|
}
|
|
1678
1641
|
};
|
|
1679
1642
|
|
|
1680
|
-
// ../../node_modules/luxon/src/zones/invalidZone.js
|
|
1643
|
+
// ../../internal/validation/node_modules/luxon/src/zones/invalidZone.js
|
|
1681
1644
|
var InvalidZone = class extends Zone {
|
|
1682
1645
|
constructor(zoneName) {
|
|
1683
1646
|
super();
|
|
@@ -1717,7 +1680,7 @@ var InvalidZone = class extends Zone {
|
|
|
1717
1680
|
}
|
|
1718
1681
|
};
|
|
1719
1682
|
|
|
1720
|
-
// ../../node_modules/luxon/src/impl/zoneUtil.js
|
|
1683
|
+
// ../../internal/validation/node_modules/luxon/src/impl/zoneUtil.js
|
|
1721
1684
|
function normalizeZone(input, defaultZone2) {
|
|
1722
1685
|
if (isUndefined(input) || input === null) {
|
|
1723
1686
|
return defaultZone2;
|
|
@@ -1742,7 +1705,7 @@ function normalizeZone(input, defaultZone2) {
|
|
|
1742
1705
|
}
|
|
1743
1706
|
}
|
|
1744
1707
|
|
|
1745
|
-
// ../../node_modules/luxon/src/settings.js
|
|
1708
|
+
// ../../internal/validation/node_modules/luxon/src/settings.js
|
|
1746
1709
|
var now = () => Date.now();
|
|
1747
1710
|
var defaultZone = "system";
|
|
1748
1711
|
var defaultLocale = null;
|
|
@@ -1849,7 +1812,7 @@ var Settings = class {
|
|
|
1849
1812
|
}
|
|
1850
1813
|
};
|
|
1851
1814
|
|
|
1852
|
-
// ../../node_modules/luxon/src/impl/locale.js
|
|
1815
|
+
// ../../internal/validation/node_modules/luxon/src/impl/locale.js
|
|
1853
1816
|
var intlLFCache = {};
|
|
1854
1817
|
function getCachedLF(locString, opts = {}) {
|
|
1855
1818
|
const key = JSON.stringify([locString, opts]);
|
|
@@ -1988,15 +1951,15 @@ var PolyNumberFormatter = class {
|
|
|
1988
1951
|
var PolyDateFormatter = class {
|
|
1989
1952
|
constructor(dt, intl, opts) {
|
|
1990
1953
|
this.opts = opts;
|
|
1991
|
-
let
|
|
1954
|
+
let z9;
|
|
1992
1955
|
if (dt.zone.isUniversal) {
|
|
1993
1956
|
const gmtOffset = -1 * (dt.offset / 60);
|
|
1994
1957
|
const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
|
|
1995
1958
|
if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
|
|
1996
|
-
|
|
1959
|
+
z9 = offsetZ;
|
|
1997
1960
|
this.dt = dt;
|
|
1998
1961
|
} else {
|
|
1999
|
-
|
|
1962
|
+
z9 = "UTC";
|
|
2000
1963
|
if (opts.timeZoneName) {
|
|
2001
1964
|
this.dt = dt;
|
|
2002
1965
|
} else {
|
|
@@ -2007,11 +1970,11 @@ var PolyDateFormatter = class {
|
|
|
2007
1970
|
this.dt = dt;
|
|
2008
1971
|
} else {
|
|
2009
1972
|
this.dt = dt;
|
|
2010
|
-
|
|
1973
|
+
z9 = dt.zone.name;
|
|
2011
1974
|
}
|
|
2012
1975
|
const intlOpts = __spreadValues({}, this.opts);
|
|
2013
|
-
if (
|
|
2014
|
-
intlOpts.timeZone =
|
|
1976
|
+
if (z9) {
|
|
1977
|
+
intlOpts.timeZone = z9;
|
|
2015
1978
|
}
|
|
2016
1979
|
this.dtf = getCachedDTF(intl, intlOpts);
|
|
2017
1980
|
}
|
|
@@ -2181,7 +2144,7 @@ var Locale = class _Locale {
|
|
|
2181
2144
|
}
|
|
2182
2145
|
};
|
|
2183
2146
|
|
|
2184
|
-
// ../../node_modules/luxon/src/impl/regexParser.js
|
|
2147
|
+
// ../../internal/validation/node_modules/luxon/src/impl/regexParser.js
|
|
2185
2148
|
function combineRegexes(...regexes) {
|
|
2186
2149
|
const full = regexes.reduce((f, r) => f + r.source, "");
|
|
2187
2150
|
return RegExp(`^${full}$`);
|
|
@@ -2416,7 +2379,7 @@ function parseSQL(s2) {
|
|
|
2416
2379
|
);
|
|
2417
2380
|
}
|
|
2418
2381
|
|
|
2419
|
-
// ../../node_modules/luxon/src/duration.js
|
|
2382
|
+
// ../../internal/validation/node_modules/luxon/src/duration.js
|
|
2420
2383
|
var INVALID = "Invalid Duration";
|
|
2421
2384
|
var lowOrderMatrix = {
|
|
2422
2385
|
weeks: {
|
|
@@ -3211,7 +3174,7 @@ var Duration = class _Duration {
|
|
|
3211
3174
|
}
|
|
3212
3175
|
};
|
|
3213
3176
|
|
|
3214
|
-
// ../../node_modules/luxon/src/interval.js
|
|
3177
|
+
// ../../internal/validation/node_modules/luxon/src/interval.js
|
|
3215
3178
|
var INVALID2 = "Invalid Interval";
|
|
3216
3179
|
function validateStartEnd(start, end) {
|
|
3217
3180
|
if (!start || !start.isValid) {
|
|
@@ -3724,7 +3687,7 @@ var Interval = class _Interval {
|
|
|
3724
3687
|
}
|
|
3725
3688
|
};
|
|
3726
3689
|
|
|
3727
|
-
// ../../node_modules/luxon/src/info.js
|
|
3690
|
+
// ../../internal/validation/node_modules/luxon/src/info.js
|
|
3728
3691
|
var Info = class {
|
|
3729
3692
|
/**
|
|
3730
3693
|
* Return whether the specified zone contains a DST.
|
|
@@ -3865,7 +3828,7 @@ var Info = class {
|
|
|
3865
3828
|
}
|
|
3866
3829
|
};
|
|
3867
3830
|
|
|
3868
|
-
// ../../node_modules/luxon/src/impl/diff.js
|
|
3831
|
+
// ../../internal/validation/node_modules/luxon/src/impl/diff.js
|
|
3869
3832
|
function dayDiff(earlier, later) {
|
|
3870
3833
|
const utcDayStart = (dt) => dt.toUTC(0, { keepLocalTime: true }).startOf("day").valueOf(), ms = utcDayStart(later) - utcDayStart(earlier);
|
|
3871
3834
|
return Math.floor(Duration.fromMillis(ms).as("days"));
|
|
@@ -3924,7 +3887,7 @@ function diff_default(earlier, later, units, opts) {
|
|
|
3924
3887
|
}
|
|
3925
3888
|
}
|
|
3926
3889
|
|
|
3927
|
-
// ../../node_modules/luxon/src/impl/digits.js
|
|
3890
|
+
// ../../internal/validation/node_modules/luxon/src/impl/digits.js
|
|
3928
3891
|
var numberingSystems = {
|
|
3929
3892
|
arab: "[\u0660-\u0669]",
|
|
3930
3893
|
arabext: "[\u06F0-\u06F9]",
|
|
@@ -3996,7 +3959,7 @@ function digitRegex({ numberingSystem }, append = "") {
|
|
|
3996
3959
|
return new RegExp(`${numberingSystems[numberingSystem || "latn"]}${append}`);
|
|
3997
3960
|
}
|
|
3998
3961
|
|
|
3999
|
-
// ../../node_modules/luxon/src/impl/tokenParser.js
|
|
3962
|
+
// ../../internal/validation/node_modules/luxon/src/impl/tokenParser.js
|
|
4000
3963
|
var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
|
|
4001
3964
|
function intUnit(regex, post = (i) => i) {
|
|
4002
3965
|
return { regex, deser: ([s2]) => post(parseDigits(s2)) };
|
|
@@ -4341,7 +4304,7 @@ function formatOptsToTokens(formatOpts, locale) {
|
|
|
4341
4304
|
return parts.map((p) => tokenForPart(p, locale, formatOpts));
|
|
4342
4305
|
}
|
|
4343
4306
|
|
|
4344
|
-
// ../../node_modules/luxon/src/impl/conversions.js
|
|
4307
|
+
// ../../internal/validation/node_modules/luxon/src/impl/conversions.js
|
|
4345
4308
|
var nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
|
|
4346
4309
|
var leapLadder = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
|
|
4347
4310
|
function unitOutOfRange(unit, value) {
|
|
@@ -4450,7 +4413,7 @@ function hasInvalidTimeData(obj) {
|
|
|
4450
4413
|
return false;
|
|
4451
4414
|
}
|
|
4452
4415
|
|
|
4453
|
-
// ../../node_modules/luxon/src/datetime.js
|
|
4416
|
+
// ../../internal/validation/node_modules/luxon/src/datetime.js
|
|
4454
4417
|
var INVALID3 = "Invalid DateTime";
|
|
4455
4418
|
var MAX_DATE = 864e13;
|
|
4456
4419
|
function unsupportedZone(zone) {
|
|
@@ -6259,6 +6222,124 @@ function friendlyDateTime(dateTimeish) {
|
|
|
6259
6222
|
);
|
|
6260
6223
|
}
|
|
6261
6224
|
}
|
|
6225
|
+
|
|
6226
|
+
// ../../internal/database/prisma/enums/index.ts
|
|
6227
|
+
var AssetType = {
|
|
6228
|
+
URL: "URL",
|
|
6229
|
+
PAGE: "PAGE",
|
|
6230
|
+
ADDRESS: "ADDRESS",
|
|
6231
|
+
DISCORD: "DISCORD",
|
|
6232
|
+
LINKEDIN: "LINKEDIN",
|
|
6233
|
+
TWITTER: "TWITTER",
|
|
6234
|
+
FACEBOOK: "FACEBOOK",
|
|
6235
|
+
YOUTUBE: "YOUTUBE",
|
|
6236
|
+
REDDIT: "REDDIT",
|
|
6237
|
+
TELEGRAM: "TELEGRAM",
|
|
6238
|
+
GOOGLE_APP_STORE: "GOOGLE_APP_STORE",
|
|
6239
|
+
APPLE_APP_STORE: "APPLE_APP_STORE",
|
|
6240
|
+
AMAZON_APP_STORE: "AMAZON_APP_STORE",
|
|
6241
|
+
MICROSOFT_APP_STORE: "MICROSOFT_APP_STORE",
|
|
6242
|
+
TIKTOK: "TIKTOK",
|
|
6243
|
+
INSTAGRAM: "INSTAGRAM",
|
|
6244
|
+
THREADS: "THREADS",
|
|
6245
|
+
MEDIUM: "MEDIUM",
|
|
6246
|
+
CHROME_WEB_STORE: "CHROME_WEB_STORE",
|
|
6247
|
+
MOZILLA_ADDONS: "MOZILLA_ADDONS",
|
|
6248
|
+
OPERA_ADDONS: "OPERA_ADDONS",
|
|
6249
|
+
EMAIL: "EMAIL",
|
|
6250
|
+
PATREON: "PATREON",
|
|
6251
|
+
OPENSEA: "OPENSEA",
|
|
6252
|
+
FARCASTER: "FARCASTER"
|
|
6253
|
+
};
|
|
6254
|
+
var AssetStatus = {
|
|
6255
|
+
UNKNOWN: "UNKNOWN",
|
|
6256
|
+
ALLOWED: "ALLOWED",
|
|
6257
|
+
BLOCKED: "BLOCKED"
|
|
6258
|
+
};
|
|
6259
|
+
|
|
6260
|
+
// ../../internal/validation/src/public/asset/changelog.ts
|
|
6261
|
+
zod.z.object({
|
|
6262
|
+
/** The type of asset to retrieve. */
|
|
6263
|
+
type: zod.z.nativeEnum(AssetType).optional().describe("Asset type"),
|
|
6264
|
+
/** The content of the asset to retrieve. */
|
|
6265
|
+
content: zod.z.string().optional().describe("Asset content"),
|
|
6266
|
+
/** Optional filter determening from which status asset was updated. */
|
|
6267
|
+
fromStatus: zod.z.nativeEnum(AssetStatus).optional().describe("Status of the changed assets to retrieve"),
|
|
6268
|
+
/** Optional filter determening to which status asset was updated. */
|
|
6269
|
+
toStatus: zod.z.nativeEnum(AssetStatus).optional().describe("Status of the changed assets to retrieve"),
|
|
6270
|
+
/**
|
|
6271
|
+
* Optional start date for listing assets; should be in `YYYY-MM-DD` format and is inclusive.
|
|
6272
|
+
* Transformed into JavaScript Date objects from strings.
|
|
6273
|
+
* If the startDate is after the endDate, a validation error will occur.
|
|
6274
|
+
*/
|
|
6275
|
+
startDate: zod.z.string().transform((str) => new Date(str)).optional().describe(
|
|
6276
|
+
"The start date to list items from. This should be in the format `YYYY-MM-DD` and is inclusive."
|
|
6277
|
+
),
|
|
6278
|
+
/**
|
|
6279
|
+
* Optional end date for listing assets; should be in `YYYY-MM-DD` format and is inclusive.
|
|
6280
|
+
* Defaults to the current date if not provided.
|
|
6281
|
+
* Transformed into JavaScript Date objects from strings.
|
|
6282
|
+
* If the startDate is after the endDate, a validation error will occur.
|
|
6283
|
+
*/
|
|
6284
|
+
endDate: zod.z.string().transform((str) => new Date(str)).optional().describe(
|
|
6285
|
+
"The end date to list items from. This should be in the format `YYYY-MM-DD` and is inclusive."
|
|
6286
|
+
)
|
|
6287
|
+
}).describe(
|
|
6288
|
+
`List asset request body
|
|
6289
|
+
|
|
6290
|
+
Defaults to getting all the updates in the last 1 day.
|
|
6291
|
+
|
|
6292
|
+
You can also choose a \`startDate\` and \`endDate\` for the range of asset updates, most
|
|
6293
|
+
timestamp formats should work, we use [Luxon](https://moment.github.io/luxon/#/parsing)
|
|
6294
|
+
for parsing the dates.`
|
|
6295
|
+
).transform((data) => {
|
|
6296
|
+
if (data.startDate && !data.endDate) {
|
|
6297
|
+
data.endDate = DateTime.now().toJSDate();
|
|
6298
|
+
}
|
|
6299
|
+
return data;
|
|
6300
|
+
}).refine((data) => {
|
|
6301
|
+
if (data.startDate && data.endDate && data.startDate > data.endDate) {
|
|
6302
|
+
return {
|
|
6303
|
+
path: ["startDate"],
|
|
6304
|
+
message: "startDate must be before endDate"
|
|
6305
|
+
};
|
|
6306
|
+
}
|
|
6307
|
+
return true;
|
|
6308
|
+
});
|
|
6309
|
+
zod.z.object({
|
|
6310
|
+
/** An array of asset change with their content, type, status, and update timestamp. */
|
|
6311
|
+
changelog: zod.z.array(
|
|
6312
|
+
zod.z.object({
|
|
6313
|
+
assetId: zod.z.number().describe("Asset ID"),
|
|
6314
|
+
type: zod.z.nativeEnum(AssetType).describe("Asset type"),
|
|
6315
|
+
content: zod.z.string().describe("Asset content"),
|
|
6316
|
+
fromStatus: zod.z.nativeEnum(AssetStatus).describe("The result of the asset status check"),
|
|
6317
|
+
toStatus: zod.z.nativeEnum(AssetStatus).describe("Status to which asset was updated at `updatedAt`"),
|
|
6318
|
+
updatedAt: zod.z.date()
|
|
6319
|
+
})
|
|
6320
|
+
)
|
|
6321
|
+
}).describe("Successful operation");
|
|
6322
|
+
var assetCheckInputSchema = zod.z.object({
|
|
6323
|
+
/** Asset content. Could be a domain, URL, or crypto address. */
|
|
6324
|
+
content: zod.z.string().describe("Asset content")
|
|
6325
|
+
}).describe("Check asset request body");
|
|
6326
|
+
zod.z.object({
|
|
6327
|
+
/**
|
|
6328
|
+
* - `ALLOWED` - the asset is on the allowlist
|
|
6329
|
+
* - `BLOCKED` - the asset is on the blocklist
|
|
6330
|
+
* - `UNKNOWN` - the asset's status is not known
|
|
6331
|
+
*/
|
|
6332
|
+
status: zod.z.nativeEnum(AssetStatus).describe("The result of the asset status check"),
|
|
6333
|
+
/**
|
|
6334
|
+
* Optional reason for the asset's status.
|
|
6335
|
+
* If the asset is allowed or blocked, this will be the reason why.
|
|
6336
|
+
* ChainPatrol aggregates data from multiple sources, so this will
|
|
6337
|
+
* tell you which source blocked or allowed the asset.
|
|
6338
|
+
*/
|
|
6339
|
+
reason: zod.z.string().optional().describe(`The reason for the result. If the result is \`BLOCKED\` this will be either
|
|
6340
|
+
\`report\` if it was reported on ChainPatrol or \`eth-phishing-detect\` if it was
|
|
6341
|
+
reported on the eth-phishing-detect list.`)
|
|
6342
|
+
}).describe("Check asset response body");
|
|
6262
6343
|
var assetListInputSchema = zod.z.object({
|
|
6263
6344
|
/** The type of asset to retrieve. */
|
|
6264
6345
|
type: zod.z.nativeEnum(AssetType).describe("Asset type"),
|
|
@@ -6377,20 +6458,43 @@ zod.z.object({
|
|
|
6377
6458
|
name: zod.z.string().describe("Name of the organization")
|
|
6378
6459
|
}).nullable().describe("Organization the report was created for")
|
|
6379
6460
|
});
|
|
6461
|
+
zod.z.object({
|
|
6462
|
+
token: zod.z.string(),
|
|
6463
|
+
memo: zod.z.string(),
|
|
6464
|
+
additional_data: zod.z.object({
|
|
6465
|
+
location: zod.z.string()
|
|
6466
|
+
})
|
|
6467
|
+
});
|
|
6468
|
+
zod.z.object({
|
|
6469
|
+
result: zod.z.string()
|
|
6470
|
+
});
|
|
6380
6471
|
|
|
6381
6472
|
// src/client.ts
|
|
6382
6473
|
function trimTrailingSlashes(url) {
|
|
6383
6474
|
return url.replace(/\/+$/, "");
|
|
6384
6475
|
}
|
|
6476
|
+
var ChainPatrolClientError = class extends Error {
|
|
6477
|
+
constructor(message, code) {
|
|
6478
|
+
super(message);
|
|
6479
|
+
this.code = code;
|
|
6480
|
+
}
|
|
6481
|
+
};
|
|
6482
|
+
var ChainPatrolClientErrorCodes = /* @__PURE__ */ ((ChainPatrolClientErrorCodes2) => {
|
|
6483
|
+
ChainPatrolClientErrorCodes2["MISSING_API_KEY"] = "MISSING_API_KEY";
|
|
6484
|
+
ChainPatrolClientErrorCodes2["API_ERROR"] = "API_ERROR";
|
|
6485
|
+
return ChainPatrolClientErrorCodes2;
|
|
6486
|
+
})(ChainPatrolClientErrorCodes || {});
|
|
6385
6487
|
var ChainPatrolClient = class {
|
|
6386
6488
|
constructor(options) {
|
|
6387
|
-
this.logger = new Logger({ component: "ChainPatrolClient" });
|
|
6388
6489
|
var _a;
|
|
6389
|
-
console.log("CREATING CLIENT");
|
|
6390
|
-
this.baseUrl = (_a = options.baseUrl) != null ? _a : "https://app.chainpatrol.io/api/";
|
|
6391
6490
|
if (!options.apiKey) {
|
|
6392
|
-
throw new
|
|
6491
|
+
throw new ChainPatrolClientError(
|
|
6492
|
+
"Missing API key",
|
|
6493
|
+
"MISSING_API_KEY" /* MISSING_API_KEY */
|
|
6494
|
+
);
|
|
6393
6495
|
}
|
|
6496
|
+
this.baseUrl = (_a = options.baseUrl) != null ? _a : "https://app.chainpatrol.io/api/";
|
|
6497
|
+
this.logger = new Logger({ component: "ChainPatrolClient" });
|
|
6394
6498
|
this.apiKey = options.apiKey;
|
|
6395
6499
|
}
|
|
6396
6500
|
fetch(req) {
|
|
@@ -6398,7 +6502,6 @@ var ChainPatrolClient = class {
|
|
|
6398
6502
|
const url = `${trimTrailingSlashes(this.baseUrl)}/${req.path.join("/")}`;
|
|
6399
6503
|
this.logger.debug("fetch", { url, req });
|
|
6400
6504
|
const bodyString = JSON.stringify(req.body);
|
|
6401
|
-
console.log("request body", bodyString);
|
|
6402
6505
|
const res = yield fetch(url, {
|
|
6403
6506
|
method: req.method,
|
|
6404
6507
|
headers: {
|
|
@@ -6408,7 +6511,9 @@ var ChainPatrolClient = class {
|
|
|
6408
6511
|
body: bodyString
|
|
6409
6512
|
});
|
|
6410
6513
|
if (!res.ok) {
|
|
6411
|
-
|
|
6514
|
+
const text = yield res.text();
|
|
6515
|
+
this.logger.error("fetch", { url, req, res: { status: res.status, text } });
|
|
6516
|
+
throw new ChainPatrolClientError(text, "API_ERROR" /* API_ERROR */);
|
|
6412
6517
|
}
|
|
6413
6518
|
return res.json();
|
|
6414
6519
|
});
|
|
@@ -6855,6 +6960,8 @@ _ThreatDetector.Schema = zod.z.object({
|
|
|
6855
6960
|
var ThreatDetector = _ThreatDetector;
|
|
6856
6961
|
|
|
6857
6962
|
exports.ChainPatrolClient = ChainPatrolClient;
|
|
6963
|
+
exports.ChainPatrolClientError = ChainPatrolClientError;
|
|
6964
|
+
exports.ChainPatrolClientErrorCodes = ChainPatrolClientErrorCodes;
|
|
6858
6965
|
exports.DomainParseError = DomainParseError;
|
|
6859
6966
|
exports.Events = Events;
|
|
6860
6967
|
exports.Relay = Relay;
|