@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.mjs
CHANGED
|
@@ -471,50 +471,13 @@ z.object({
|
|
|
471
471
|
description: z.string().optional(),
|
|
472
472
|
assetGroupId: z.number().optional()
|
|
473
473
|
});
|
|
474
|
-
|
|
475
|
-
// ../../internal/database/prisma/enums/index.ts
|
|
476
|
-
var AssetType = {
|
|
477
|
-
URL: "URL",
|
|
478
|
-
PAGE: "PAGE",
|
|
479
|
-
ADDRESS: "ADDRESS",
|
|
480
|
-
DISCORD: "DISCORD",
|
|
481
|
-
LINKEDIN: "LINKEDIN",
|
|
482
|
-
TWITTER: "TWITTER",
|
|
483
|
-
FACEBOOK: "FACEBOOK",
|
|
484
|
-
YOUTUBE: "YOUTUBE",
|
|
485
|
-
REDDIT: "REDDIT",
|
|
486
|
-
TELEGRAM: "TELEGRAM"
|
|
487
|
-
};
|
|
488
|
-
var AssetStatus = {
|
|
489
|
-
UNKNOWN: "UNKNOWN",
|
|
490
|
-
ALLOWED: "ALLOWED",
|
|
491
|
-
BLOCKED: "BLOCKED"
|
|
492
|
-
};
|
|
493
|
-
|
|
494
|
-
// ../../internal/validation/src/public/asset/check.ts
|
|
495
|
-
var assetCheckInputSchema = z.object({
|
|
496
|
-
/** Asset content. Could be a domain, URL, or crypto address. */
|
|
497
|
-
content: z.string().describe("Asset content")
|
|
498
|
-
}).describe("Check asset request body");
|
|
499
474
|
z.object({
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
*/
|
|
505
|
-
status: z.nativeEnum(AssetStatus).describe("The result of the asset status check"),
|
|
506
|
-
/**
|
|
507
|
-
* Optional reason for the asset's status.
|
|
508
|
-
* If the asset is allowed or blocked, this will be the reason why.
|
|
509
|
-
* ChainPatrol aggregates data from multiple sources, so this will
|
|
510
|
-
* tell you which source blocked or allowed the asset.
|
|
511
|
-
*/
|
|
512
|
-
reason: z.string().optional().describe(`The reason for the result. If the result is \`BLOCKED\` this will be either
|
|
513
|
-
\`report\` if it was reported on ChainPatrol or \`eth-phishing-detect\` if it was
|
|
514
|
-
reported on the eth-phishing-detect list.`)
|
|
515
|
-
}).describe("Check asset response body");
|
|
475
|
+
content: z.string().min(1, { message: "Content must be at least 3 character" }).max(1e3, { message: "Content must be less than 1000 characters" }),
|
|
476
|
+
email: z.string().email(),
|
|
477
|
+
description: z.string().optional().default("")
|
|
478
|
+
});
|
|
516
479
|
|
|
517
|
-
// ../../node_modules/luxon/src/errors.js
|
|
480
|
+
// ../../internal/validation/node_modules/luxon/src/errors.js
|
|
518
481
|
var LuxonError = class extends Error {
|
|
519
482
|
};
|
|
520
483
|
var InvalidDateTimeError = class extends LuxonError {
|
|
@@ -547,7 +510,7 @@ var ZoneIsAbstractError = class extends LuxonError {
|
|
|
547
510
|
}
|
|
548
511
|
};
|
|
549
512
|
|
|
550
|
-
// ../../node_modules/luxon/src/impl/formats.js
|
|
513
|
+
// ../../internal/validation/node_modules/luxon/src/impl/formats.js
|
|
551
514
|
var n = "numeric";
|
|
552
515
|
var s = "short";
|
|
553
516
|
var l = "long";
|
|
@@ -699,7 +662,7 @@ var DATETIME_HUGE_WITH_SECONDS = {
|
|
|
699
662
|
timeZoneName: l
|
|
700
663
|
};
|
|
701
664
|
|
|
702
|
-
// ../../node_modules/luxon/src/impl/util.js
|
|
665
|
+
// ../../internal/validation/node_modules/luxon/src/impl/util.js
|
|
703
666
|
function isUndefined(o) {
|
|
704
667
|
return typeof o === "undefined";
|
|
705
668
|
}
|
|
@@ -891,7 +854,7 @@ function timeObject(obj) {
|
|
|
891
854
|
}
|
|
892
855
|
var ianaRegex = /[A-Za-z_+-]{1,256}(?::?\/[A-Za-z0-9_+-]{1,256}(?:\/[A-Za-z0-9_+-]{1,256})?)?/;
|
|
893
856
|
|
|
894
|
-
// ../../node_modules/luxon/src/impl/english.js
|
|
857
|
+
// ../../internal/validation/node_modules/luxon/src/impl/english.js
|
|
895
858
|
var monthsLong = [
|
|
896
859
|
"January",
|
|
897
860
|
"February",
|
|
@@ -1017,7 +980,7 @@ function formatRelativeTime(unit, count, numeric = "always", narrow = false) {
|
|
|
1017
980
|
return isInPast ? `${fmtValue} ${fmtUnit} ago` : `in ${fmtValue} ${fmtUnit}`;
|
|
1018
981
|
}
|
|
1019
982
|
|
|
1020
|
-
// ../../node_modules/luxon/src/impl/formatter.js
|
|
983
|
+
// ../../internal/validation/node_modules/luxon/src/impl/formatter.js
|
|
1021
984
|
function stringifyTokens(splits, tokenToString) {
|
|
1022
985
|
let s2 = "";
|
|
1023
986
|
for (const token of splits) {
|
|
@@ -1295,7 +1258,7 @@ var Formatter = class _Formatter {
|
|
|
1295
1258
|
}
|
|
1296
1259
|
};
|
|
1297
1260
|
|
|
1298
|
-
// ../../node_modules/luxon/src/impl/invalid.js
|
|
1261
|
+
// ../../internal/validation/node_modules/luxon/src/impl/invalid.js
|
|
1299
1262
|
var Invalid = class {
|
|
1300
1263
|
constructor(reason, explanation) {
|
|
1301
1264
|
this.reason = reason;
|
|
@@ -1310,7 +1273,7 @@ var Invalid = class {
|
|
|
1310
1273
|
}
|
|
1311
1274
|
};
|
|
1312
1275
|
|
|
1313
|
-
// ../../node_modules/luxon/src/zone.js
|
|
1276
|
+
// ../../internal/validation/node_modules/luxon/src/zone.js
|
|
1314
1277
|
var Zone = class {
|
|
1315
1278
|
/**
|
|
1316
1279
|
* The type of zone
|
|
@@ -1390,7 +1353,7 @@ var Zone = class {
|
|
|
1390
1353
|
}
|
|
1391
1354
|
};
|
|
1392
1355
|
|
|
1393
|
-
// ../../node_modules/luxon/src/zones/systemZone.js
|
|
1356
|
+
// ../../internal/validation/node_modules/luxon/src/zones/systemZone.js
|
|
1394
1357
|
var singleton = null;
|
|
1395
1358
|
var SystemZone = class _SystemZone extends Zone {
|
|
1396
1359
|
/**
|
|
@@ -1437,7 +1400,7 @@ var SystemZone = class _SystemZone extends Zone {
|
|
|
1437
1400
|
}
|
|
1438
1401
|
};
|
|
1439
1402
|
|
|
1440
|
-
// ../../node_modules/luxon/src/zones/IANAZone.js
|
|
1403
|
+
// ../../internal/validation/node_modules/luxon/src/zones/IANAZone.js
|
|
1441
1404
|
var dtfCache = {};
|
|
1442
1405
|
function makeDTF(zone) {
|
|
1443
1406
|
if (!dtfCache[zone]) {
|
|
@@ -1592,7 +1555,7 @@ var IANAZone = class _IANAZone extends Zone {
|
|
|
1592
1555
|
}
|
|
1593
1556
|
};
|
|
1594
1557
|
|
|
1595
|
-
// ../../node_modules/luxon/src/zones/fixedOffsetZone.js
|
|
1558
|
+
// ../../internal/validation/node_modules/luxon/src/zones/fixedOffsetZone.js
|
|
1596
1559
|
var singleton2 = null;
|
|
1597
1560
|
var FixedOffsetZone = class _FixedOffsetZone extends Zone {
|
|
1598
1561
|
/**
|
|
@@ -1675,7 +1638,7 @@ var FixedOffsetZone = class _FixedOffsetZone extends Zone {
|
|
|
1675
1638
|
}
|
|
1676
1639
|
};
|
|
1677
1640
|
|
|
1678
|
-
// ../../node_modules/luxon/src/zones/invalidZone.js
|
|
1641
|
+
// ../../internal/validation/node_modules/luxon/src/zones/invalidZone.js
|
|
1679
1642
|
var InvalidZone = class extends Zone {
|
|
1680
1643
|
constructor(zoneName) {
|
|
1681
1644
|
super();
|
|
@@ -1715,7 +1678,7 @@ var InvalidZone = class extends Zone {
|
|
|
1715
1678
|
}
|
|
1716
1679
|
};
|
|
1717
1680
|
|
|
1718
|
-
// ../../node_modules/luxon/src/impl/zoneUtil.js
|
|
1681
|
+
// ../../internal/validation/node_modules/luxon/src/impl/zoneUtil.js
|
|
1719
1682
|
function normalizeZone(input, defaultZone2) {
|
|
1720
1683
|
if (isUndefined(input) || input === null) {
|
|
1721
1684
|
return defaultZone2;
|
|
@@ -1740,7 +1703,7 @@ function normalizeZone(input, defaultZone2) {
|
|
|
1740
1703
|
}
|
|
1741
1704
|
}
|
|
1742
1705
|
|
|
1743
|
-
// ../../node_modules/luxon/src/settings.js
|
|
1706
|
+
// ../../internal/validation/node_modules/luxon/src/settings.js
|
|
1744
1707
|
var now = () => Date.now();
|
|
1745
1708
|
var defaultZone = "system";
|
|
1746
1709
|
var defaultLocale = null;
|
|
@@ -1847,7 +1810,7 @@ var Settings = class {
|
|
|
1847
1810
|
}
|
|
1848
1811
|
};
|
|
1849
1812
|
|
|
1850
|
-
// ../../node_modules/luxon/src/impl/locale.js
|
|
1813
|
+
// ../../internal/validation/node_modules/luxon/src/impl/locale.js
|
|
1851
1814
|
var intlLFCache = {};
|
|
1852
1815
|
function getCachedLF(locString, opts = {}) {
|
|
1853
1816
|
const key = JSON.stringify([locString, opts]);
|
|
@@ -1986,15 +1949,15 @@ var PolyNumberFormatter = class {
|
|
|
1986
1949
|
var PolyDateFormatter = class {
|
|
1987
1950
|
constructor(dt, intl, opts) {
|
|
1988
1951
|
this.opts = opts;
|
|
1989
|
-
let
|
|
1952
|
+
let z9;
|
|
1990
1953
|
if (dt.zone.isUniversal) {
|
|
1991
1954
|
const gmtOffset = -1 * (dt.offset / 60);
|
|
1992
1955
|
const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
|
|
1993
1956
|
if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
|
|
1994
|
-
|
|
1957
|
+
z9 = offsetZ;
|
|
1995
1958
|
this.dt = dt;
|
|
1996
1959
|
} else {
|
|
1997
|
-
|
|
1960
|
+
z9 = "UTC";
|
|
1998
1961
|
if (opts.timeZoneName) {
|
|
1999
1962
|
this.dt = dt;
|
|
2000
1963
|
} else {
|
|
@@ -2005,11 +1968,11 @@ var PolyDateFormatter = class {
|
|
|
2005
1968
|
this.dt = dt;
|
|
2006
1969
|
} else {
|
|
2007
1970
|
this.dt = dt;
|
|
2008
|
-
|
|
1971
|
+
z9 = dt.zone.name;
|
|
2009
1972
|
}
|
|
2010
1973
|
const intlOpts = __spreadValues({}, this.opts);
|
|
2011
|
-
if (
|
|
2012
|
-
intlOpts.timeZone =
|
|
1974
|
+
if (z9) {
|
|
1975
|
+
intlOpts.timeZone = z9;
|
|
2013
1976
|
}
|
|
2014
1977
|
this.dtf = getCachedDTF(intl, intlOpts);
|
|
2015
1978
|
}
|
|
@@ -2179,7 +2142,7 @@ var Locale = class _Locale {
|
|
|
2179
2142
|
}
|
|
2180
2143
|
};
|
|
2181
2144
|
|
|
2182
|
-
// ../../node_modules/luxon/src/impl/regexParser.js
|
|
2145
|
+
// ../../internal/validation/node_modules/luxon/src/impl/regexParser.js
|
|
2183
2146
|
function combineRegexes(...regexes) {
|
|
2184
2147
|
const full = regexes.reduce((f, r) => f + r.source, "");
|
|
2185
2148
|
return RegExp(`^${full}$`);
|
|
@@ -2414,7 +2377,7 @@ function parseSQL(s2) {
|
|
|
2414
2377
|
);
|
|
2415
2378
|
}
|
|
2416
2379
|
|
|
2417
|
-
// ../../node_modules/luxon/src/duration.js
|
|
2380
|
+
// ../../internal/validation/node_modules/luxon/src/duration.js
|
|
2418
2381
|
var INVALID = "Invalid Duration";
|
|
2419
2382
|
var lowOrderMatrix = {
|
|
2420
2383
|
weeks: {
|
|
@@ -3209,7 +3172,7 @@ var Duration = class _Duration {
|
|
|
3209
3172
|
}
|
|
3210
3173
|
};
|
|
3211
3174
|
|
|
3212
|
-
// ../../node_modules/luxon/src/interval.js
|
|
3175
|
+
// ../../internal/validation/node_modules/luxon/src/interval.js
|
|
3213
3176
|
var INVALID2 = "Invalid Interval";
|
|
3214
3177
|
function validateStartEnd(start, end) {
|
|
3215
3178
|
if (!start || !start.isValid) {
|
|
@@ -3722,7 +3685,7 @@ var Interval = class _Interval {
|
|
|
3722
3685
|
}
|
|
3723
3686
|
};
|
|
3724
3687
|
|
|
3725
|
-
// ../../node_modules/luxon/src/info.js
|
|
3688
|
+
// ../../internal/validation/node_modules/luxon/src/info.js
|
|
3726
3689
|
var Info = class {
|
|
3727
3690
|
/**
|
|
3728
3691
|
* Return whether the specified zone contains a DST.
|
|
@@ -3863,7 +3826,7 @@ var Info = class {
|
|
|
3863
3826
|
}
|
|
3864
3827
|
};
|
|
3865
3828
|
|
|
3866
|
-
// ../../node_modules/luxon/src/impl/diff.js
|
|
3829
|
+
// ../../internal/validation/node_modules/luxon/src/impl/diff.js
|
|
3867
3830
|
function dayDiff(earlier, later) {
|
|
3868
3831
|
const utcDayStart = (dt) => dt.toUTC(0, { keepLocalTime: true }).startOf("day").valueOf(), ms = utcDayStart(later) - utcDayStart(earlier);
|
|
3869
3832
|
return Math.floor(Duration.fromMillis(ms).as("days"));
|
|
@@ -3922,7 +3885,7 @@ function diff_default(earlier, later, units, opts) {
|
|
|
3922
3885
|
}
|
|
3923
3886
|
}
|
|
3924
3887
|
|
|
3925
|
-
// ../../node_modules/luxon/src/impl/digits.js
|
|
3888
|
+
// ../../internal/validation/node_modules/luxon/src/impl/digits.js
|
|
3926
3889
|
var numberingSystems = {
|
|
3927
3890
|
arab: "[\u0660-\u0669]",
|
|
3928
3891
|
arabext: "[\u06F0-\u06F9]",
|
|
@@ -3994,7 +3957,7 @@ function digitRegex({ numberingSystem }, append = "") {
|
|
|
3994
3957
|
return new RegExp(`${numberingSystems[numberingSystem || "latn"]}${append}`);
|
|
3995
3958
|
}
|
|
3996
3959
|
|
|
3997
|
-
// ../../node_modules/luxon/src/impl/tokenParser.js
|
|
3960
|
+
// ../../internal/validation/node_modules/luxon/src/impl/tokenParser.js
|
|
3998
3961
|
var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
|
|
3999
3962
|
function intUnit(regex, post = (i) => i) {
|
|
4000
3963
|
return { regex, deser: ([s2]) => post(parseDigits(s2)) };
|
|
@@ -4339,7 +4302,7 @@ function formatOptsToTokens(formatOpts, locale) {
|
|
|
4339
4302
|
return parts.map((p) => tokenForPart(p, locale, formatOpts));
|
|
4340
4303
|
}
|
|
4341
4304
|
|
|
4342
|
-
// ../../node_modules/luxon/src/impl/conversions.js
|
|
4305
|
+
// ../../internal/validation/node_modules/luxon/src/impl/conversions.js
|
|
4343
4306
|
var nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
|
|
4344
4307
|
var leapLadder = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
|
|
4345
4308
|
function unitOutOfRange(unit, value) {
|
|
@@ -4448,7 +4411,7 @@ function hasInvalidTimeData(obj) {
|
|
|
4448
4411
|
return false;
|
|
4449
4412
|
}
|
|
4450
4413
|
|
|
4451
|
-
// ../../node_modules/luxon/src/datetime.js
|
|
4414
|
+
// ../../internal/validation/node_modules/luxon/src/datetime.js
|
|
4452
4415
|
var INVALID3 = "Invalid DateTime";
|
|
4453
4416
|
var MAX_DATE = 864e13;
|
|
4454
4417
|
function unsupportedZone(zone) {
|
|
@@ -6257,6 +6220,124 @@ function friendlyDateTime(dateTimeish) {
|
|
|
6257
6220
|
);
|
|
6258
6221
|
}
|
|
6259
6222
|
}
|
|
6223
|
+
|
|
6224
|
+
// ../../internal/database/prisma/enums/index.ts
|
|
6225
|
+
var AssetType = {
|
|
6226
|
+
URL: "URL",
|
|
6227
|
+
PAGE: "PAGE",
|
|
6228
|
+
ADDRESS: "ADDRESS",
|
|
6229
|
+
DISCORD: "DISCORD",
|
|
6230
|
+
LINKEDIN: "LINKEDIN",
|
|
6231
|
+
TWITTER: "TWITTER",
|
|
6232
|
+
FACEBOOK: "FACEBOOK",
|
|
6233
|
+
YOUTUBE: "YOUTUBE",
|
|
6234
|
+
REDDIT: "REDDIT",
|
|
6235
|
+
TELEGRAM: "TELEGRAM",
|
|
6236
|
+
GOOGLE_APP_STORE: "GOOGLE_APP_STORE",
|
|
6237
|
+
APPLE_APP_STORE: "APPLE_APP_STORE",
|
|
6238
|
+
AMAZON_APP_STORE: "AMAZON_APP_STORE",
|
|
6239
|
+
MICROSOFT_APP_STORE: "MICROSOFT_APP_STORE",
|
|
6240
|
+
TIKTOK: "TIKTOK",
|
|
6241
|
+
INSTAGRAM: "INSTAGRAM",
|
|
6242
|
+
THREADS: "THREADS",
|
|
6243
|
+
MEDIUM: "MEDIUM",
|
|
6244
|
+
CHROME_WEB_STORE: "CHROME_WEB_STORE",
|
|
6245
|
+
MOZILLA_ADDONS: "MOZILLA_ADDONS",
|
|
6246
|
+
OPERA_ADDONS: "OPERA_ADDONS",
|
|
6247
|
+
EMAIL: "EMAIL",
|
|
6248
|
+
PATREON: "PATREON",
|
|
6249
|
+
OPENSEA: "OPENSEA",
|
|
6250
|
+
FARCASTER: "FARCASTER"
|
|
6251
|
+
};
|
|
6252
|
+
var AssetStatus = {
|
|
6253
|
+
UNKNOWN: "UNKNOWN",
|
|
6254
|
+
ALLOWED: "ALLOWED",
|
|
6255
|
+
BLOCKED: "BLOCKED"
|
|
6256
|
+
};
|
|
6257
|
+
|
|
6258
|
+
// ../../internal/validation/src/public/asset/changelog.ts
|
|
6259
|
+
z.object({
|
|
6260
|
+
/** The type of asset to retrieve. */
|
|
6261
|
+
type: z.nativeEnum(AssetType).optional().describe("Asset type"),
|
|
6262
|
+
/** The content of the asset to retrieve. */
|
|
6263
|
+
content: z.string().optional().describe("Asset content"),
|
|
6264
|
+
/** Optional filter determening from which status asset was updated. */
|
|
6265
|
+
fromStatus: z.nativeEnum(AssetStatus).optional().describe("Status of the changed assets to retrieve"),
|
|
6266
|
+
/** Optional filter determening to which status asset was updated. */
|
|
6267
|
+
toStatus: z.nativeEnum(AssetStatus).optional().describe("Status of the changed assets to retrieve"),
|
|
6268
|
+
/**
|
|
6269
|
+
* Optional start date for listing assets; should be in `YYYY-MM-DD` format and is inclusive.
|
|
6270
|
+
* Transformed into JavaScript Date objects from strings.
|
|
6271
|
+
* If the startDate is after the endDate, a validation error will occur.
|
|
6272
|
+
*/
|
|
6273
|
+
startDate: z.string().transform((str) => new Date(str)).optional().describe(
|
|
6274
|
+
"The start date to list items from. This should be in the format `YYYY-MM-DD` and is inclusive."
|
|
6275
|
+
),
|
|
6276
|
+
/**
|
|
6277
|
+
* Optional end date for listing assets; should be in `YYYY-MM-DD` format and is inclusive.
|
|
6278
|
+
* Defaults to the current date if not provided.
|
|
6279
|
+
* Transformed into JavaScript Date objects from strings.
|
|
6280
|
+
* If the startDate is after the endDate, a validation error will occur.
|
|
6281
|
+
*/
|
|
6282
|
+
endDate: z.string().transform((str) => new Date(str)).optional().describe(
|
|
6283
|
+
"The end date to list items from. This should be in the format `YYYY-MM-DD` and is inclusive."
|
|
6284
|
+
)
|
|
6285
|
+
}).describe(
|
|
6286
|
+
`List asset request body
|
|
6287
|
+
|
|
6288
|
+
Defaults to getting all the updates in the last 1 day.
|
|
6289
|
+
|
|
6290
|
+
You can also choose a \`startDate\` and \`endDate\` for the range of asset updates, most
|
|
6291
|
+
timestamp formats should work, we use [Luxon](https://moment.github.io/luxon/#/parsing)
|
|
6292
|
+
for parsing the dates.`
|
|
6293
|
+
).transform((data) => {
|
|
6294
|
+
if (data.startDate && !data.endDate) {
|
|
6295
|
+
data.endDate = DateTime.now().toJSDate();
|
|
6296
|
+
}
|
|
6297
|
+
return data;
|
|
6298
|
+
}).refine((data) => {
|
|
6299
|
+
if (data.startDate && data.endDate && data.startDate > data.endDate) {
|
|
6300
|
+
return {
|
|
6301
|
+
path: ["startDate"],
|
|
6302
|
+
message: "startDate must be before endDate"
|
|
6303
|
+
};
|
|
6304
|
+
}
|
|
6305
|
+
return true;
|
|
6306
|
+
});
|
|
6307
|
+
z.object({
|
|
6308
|
+
/** An array of asset change with their content, type, status, and update timestamp. */
|
|
6309
|
+
changelog: z.array(
|
|
6310
|
+
z.object({
|
|
6311
|
+
assetId: z.number().describe("Asset ID"),
|
|
6312
|
+
type: z.nativeEnum(AssetType).describe("Asset type"),
|
|
6313
|
+
content: z.string().describe("Asset content"),
|
|
6314
|
+
fromStatus: z.nativeEnum(AssetStatus).describe("The result of the asset status check"),
|
|
6315
|
+
toStatus: z.nativeEnum(AssetStatus).describe("Status to which asset was updated at `updatedAt`"),
|
|
6316
|
+
updatedAt: z.date()
|
|
6317
|
+
})
|
|
6318
|
+
)
|
|
6319
|
+
}).describe("Successful operation");
|
|
6320
|
+
var assetCheckInputSchema = z.object({
|
|
6321
|
+
/** Asset content. Could be a domain, URL, or crypto address. */
|
|
6322
|
+
content: z.string().describe("Asset content")
|
|
6323
|
+
}).describe("Check asset request body");
|
|
6324
|
+
z.object({
|
|
6325
|
+
/**
|
|
6326
|
+
* - `ALLOWED` - the asset is on the allowlist
|
|
6327
|
+
* - `BLOCKED` - the asset is on the blocklist
|
|
6328
|
+
* - `UNKNOWN` - the asset's status is not known
|
|
6329
|
+
*/
|
|
6330
|
+
status: z.nativeEnum(AssetStatus).describe("The result of the asset status check"),
|
|
6331
|
+
/**
|
|
6332
|
+
* Optional reason for the asset's status.
|
|
6333
|
+
* If the asset is allowed or blocked, this will be the reason why.
|
|
6334
|
+
* ChainPatrol aggregates data from multiple sources, so this will
|
|
6335
|
+
* tell you which source blocked or allowed the asset.
|
|
6336
|
+
*/
|
|
6337
|
+
reason: z.string().optional().describe(`The reason for the result. If the result is \`BLOCKED\` this will be either
|
|
6338
|
+
\`report\` if it was reported on ChainPatrol or \`eth-phishing-detect\` if it was
|
|
6339
|
+
reported on the eth-phishing-detect list.`)
|
|
6340
|
+
}).describe("Check asset response body");
|
|
6260
6341
|
var assetListInputSchema = z.object({
|
|
6261
6342
|
/** The type of asset to retrieve. */
|
|
6262
6343
|
type: z.nativeEnum(AssetType).describe("Asset type"),
|
|
@@ -6375,20 +6456,43 @@ z.object({
|
|
|
6375
6456
|
name: z.string().describe("Name of the organization")
|
|
6376
6457
|
}).nullable().describe("Organization the report was created for")
|
|
6377
6458
|
});
|
|
6459
|
+
z.object({
|
|
6460
|
+
token: z.string(),
|
|
6461
|
+
memo: z.string(),
|
|
6462
|
+
additional_data: z.object({
|
|
6463
|
+
location: z.string()
|
|
6464
|
+
})
|
|
6465
|
+
});
|
|
6466
|
+
z.object({
|
|
6467
|
+
result: z.string()
|
|
6468
|
+
});
|
|
6378
6469
|
|
|
6379
6470
|
// src/client.ts
|
|
6380
6471
|
function trimTrailingSlashes(url) {
|
|
6381
6472
|
return url.replace(/\/+$/, "");
|
|
6382
6473
|
}
|
|
6474
|
+
var ChainPatrolClientError = class extends Error {
|
|
6475
|
+
constructor(message, code) {
|
|
6476
|
+
super(message);
|
|
6477
|
+
this.code = code;
|
|
6478
|
+
}
|
|
6479
|
+
};
|
|
6480
|
+
var ChainPatrolClientErrorCodes = /* @__PURE__ */ ((ChainPatrolClientErrorCodes2) => {
|
|
6481
|
+
ChainPatrolClientErrorCodes2["MISSING_API_KEY"] = "MISSING_API_KEY";
|
|
6482
|
+
ChainPatrolClientErrorCodes2["API_ERROR"] = "API_ERROR";
|
|
6483
|
+
return ChainPatrolClientErrorCodes2;
|
|
6484
|
+
})(ChainPatrolClientErrorCodes || {});
|
|
6383
6485
|
var ChainPatrolClient = class {
|
|
6384
6486
|
constructor(options) {
|
|
6385
|
-
this.logger = new Logger({ component: "ChainPatrolClient" });
|
|
6386
6487
|
var _a;
|
|
6387
|
-
console.log("CREATING CLIENT");
|
|
6388
|
-
this.baseUrl = (_a = options.baseUrl) != null ? _a : "https://app.chainpatrol.io/api/";
|
|
6389
6488
|
if (!options.apiKey) {
|
|
6390
|
-
throw new
|
|
6489
|
+
throw new ChainPatrolClientError(
|
|
6490
|
+
"Missing API key",
|
|
6491
|
+
"MISSING_API_KEY" /* MISSING_API_KEY */
|
|
6492
|
+
);
|
|
6391
6493
|
}
|
|
6494
|
+
this.baseUrl = (_a = options.baseUrl) != null ? _a : "https://app.chainpatrol.io/api/";
|
|
6495
|
+
this.logger = new Logger({ component: "ChainPatrolClient" });
|
|
6392
6496
|
this.apiKey = options.apiKey;
|
|
6393
6497
|
}
|
|
6394
6498
|
fetch(req) {
|
|
@@ -6396,7 +6500,6 @@ var ChainPatrolClient = class {
|
|
|
6396
6500
|
const url = `${trimTrailingSlashes(this.baseUrl)}/${req.path.join("/")}`;
|
|
6397
6501
|
this.logger.debug("fetch", { url, req });
|
|
6398
6502
|
const bodyString = JSON.stringify(req.body);
|
|
6399
|
-
console.log("request body", bodyString);
|
|
6400
6503
|
const res = yield fetch(url, {
|
|
6401
6504
|
method: req.method,
|
|
6402
6505
|
headers: {
|
|
@@ -6406,7 +6509,9 @@ var ChainPatrolClient = class {
|
|
|
6406
6509
|
body: bodyString
|
|
6407
6510
|
});
|
|
6408
6511
|
if (!res.ok) {
|
|
6409
|
-
|
|
6512
|
+
const text = yield res.text();
|
|
6513
|
+
this.logger.error("fetch", { url, req, res: { status: res.status, text } });
|
|
6514
|
+
throw new ChainPatrolClientError(text, "API_ERROR" /* API_ERROR */);
|
|
6410
6515
|
}
|
|
6411
6516
|
return res.json();
|
|
6412
6517
|
});
|
|
@@ -6852,6 +6957,6 @@ _ThreatDetector.Schema = z.object({
|
|
|
6852
6957
|
});
|
|
6853
6958
|
var ThreatDetector = _ThreatDetector;
|
|
6854
6959
|
|
|
6855
|
-
export { ChainPatrolClient, DomainParseError, Events, Relay, storage_exports as Storage, ThreatDetector };
|
|
6960
|
+
export { ChainPatrolClient, ChainPatrolClientError, ChainPatrolClientErrorCodes, DomainParseError, Events, Relay, storage_exports as Storage, ThreatDetector };
|
|
6856
6961
|
//# sourceMappingURL=out.js.map
|
|
6857
6962
|
//# sourceMappingURL=index.mjs.map
|