@chainpatrol/sdk 0.6.0 → 0.8.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.mts +4 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.js +65 -12
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +65 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetCheckInput, AssetCheckOutput, AssetListInput, AssetListOutput, ReportCreateInput } from '@chainpatrol/validation';
|
|
1
|
+
import { AssetCheckInput, AssetCheckOutput, AssetListInput, AssetListOutput, AssetSubmitInput, AssetSubmitOutput, ReportCreateInput } from '@chainpatrol/validation';
|
|
2
2
|
|
|
3
3
|
declare const ContinueAtOwnRisk = "CHAINPATROL_CONTINUE_AT_OWN_RISK";
|
|
4
4
|
declare const IgnorelistUpdated = "CHAINPATROL_IGNORELIST_UPDATED";
|
|
@@ -46,6 +46,7 @@ declare class Relay {
|
|
|
46
46
|
type ChainPatrolClientOptions = {
|
|
47
47
|
apiKey: string;
|
|
48
48
|
baseUrl?: string;
|
|
49
|
+
fetchOptions?: Pick<RequestInit, "headers" | "signal" | "redirect" | "mode" | "credentials">;
|
|
49
50
|
};
|
|
50
51
|
type ApiRequest = {
|
|
51
52
|
path: string[];
|
|
@@ -66,11 +67,13 @@ declare class ChainPatrolClient {
|
|
|
66
67
|
readonly baseUrl: string;
|
|
67
68
|
private readonly apiKey;
|
|
68
69
|
private readonly logger;
|
|
70
|
+
private readonly fetchOptions;
|
|
69
71
|
constructor(options: ChainPatrolClientOptions);
|
|
70
72
|
fetch<TResult = unknown>(req: ApiRequest): Promise<TResult>;
|
|
71
73
|
get asset(): {
|
|
72
74
|
check: (req: AssetCheckInput) => Promise<AssetCheckOutput>;
|
|
73
75
|
list: (req: AssetListInput) => Promise<AssetListOutput>;
|
|
76
|
+
submit: (req: AssetSubmitInput) => Promise<AssetSubmitOutput>;
|
|
74
77
|
};
|
|
75
78
|
get report(): {
|
|
76
79
|
create: (req: ReportCreateInput) => Promise<{
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AssetCheckInput, AssetCheckOutput, AssetListInput, AssetListOutput, ReportCreateInput } from '@chainpatrol/validation';
|
|
1
|
+
import { AssetCheckInput, AssetCheckOutput, AssetListInput, AssetListOutput, AssetSubmitInput, AssetSubmitOutput, ReportCreateInput } from '@chainpatrol/validation';
|
|
2
2
|
|
|
3
3
|
declare const ContinueAtOwnRisk = "CHAINPATROL_CONTINUE_AT_OWN_RISK";
|
|
4
4
|
declare const IgnorelistUpdated = "CHAINPATROL_IGNORELIST_UPDATED";
|
|
@@ -46,6 +46,7 @@ declare class Relay {
|
|
|
46
46
|
type ChainPatrolClientOptions = {
|
|
47
47
|
apiKey: string;
|
|
48
48
|
baseUrl?: string;
|
|
49
|
+
fetchOptions?: Pick<RequestInit, "headers" | "signal" | "redirect" | "mode" | "credentials">;
|
|
49
50
|
};
|
|
50
51
|
type ApiRequest = {
|
|
51
52
|
path: string[];
|
|
@@ -66,11 +67,13 @@ declare class ChainPatrolClient {
|
|
|
66
67
|
readonly baseUrl: string;
|
|
67
68
|
private readonly apiKey;
|
|
68
69
|
private readonly logger;
|
|
70
|
+
private readonly fetchOptions;
|
|
69
71
|
constructor(options: ChainPatrolClientOptions);
|
|
70
72
|
fetch<TResult = unknown>(req: ApiRequest): Promise<TResult>;
|
|
71
73
|
get asset(): {
|
|
72
74
|
check: (req: AssetCheckInput) => Promise<AssetCheckOutput>;
|
|
73
75
|
list: (req: AssetListInput) => Promise<AssetListOutput>;
|
|
76
|
+
submit: (req: AssetSubmitInput) => Promise<AssetSubmitOutput>;
|
|
74
77
|
};
|
|
75
78
|
get report(): {
|
|
76
79
|
create: (req: ReportCreateInput) => Promise<{
|
package/dist/index.js
CHANGED
|
@@ -1277,17 +1277,17 @@ var PolyDateFormatter = class {
|
|
|
1277
1277
|
constructor(dt, intl, opts) {
|
|
1278
1278
|
this.opts = opts;
|
|
1279
1279
|
this.originalZone = void 0;
|
|
1280
|
-
let
|
|
1280
|
+
let z16 = void 0;
|
|
1281
1281
|
if (this.opts.timeZone) {
|
|
1282
1282
|
this.dt = dt;
|
|
1283
1283
|
} else if (dt.zone.type === "fixed") {
|
|
1284
1284
|
const gmtOffset = -1 * (dt.offset / 60);
|
|
1285
1285
|
const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
|
|
1286
1286
|
if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
|
|
1287
|
-
|
|
1287
|
+
z16 = offsetZ;
|
|
1288
1288
|
this.dt = dt;
|
|
1289
1289
|
} else {
|
|
1290
|
-
|
|
1290
|
+
z16 = "UTC";
|
|
1291
1291
|
this.dt = dt.offset === 0 ? dt : dt.setZone("UTC").plus({ minutes: dt.offset });
|
|
1292
1292
|
this.originalZone = dt.zone;
|
|
1293
1293
|
}
|
|
@@ -1295,14 +1295,14 @@ var PolyDateFormatter = class {
|
|
|
1295
1295
|
this.dt = dt;
|
|
1296
1296
|
} else if (dt.zone.type === "iana") {
|
|
1297
1297
|
this.dt = dt;
|
|
1298
|
-
|
|
1298
|
+
z16 = dt.zone.name;
|
|
1299
1299
|
} else {
|
|
1300
|
-
|
|
1300
|
+
z16 = "UTC";
|
|
1301
1301
|
this.dt = dt.setZone("UTC").plus({ minutes: dt.offset });
|
|
1302
1302
|
this.originalZone = dt.zone;
|
|
1303
1303
|
}
|
|
1304
1304
|
const intlOpts = __spreadValues({}, this.opts);
|
|
1305
|
-
intlOpts.timeZone = intlOpts.timeZone ||
|
|
1305
|
+
intlOpts.timeZone = intlOpts.timeZone || z16;
|
|
1306
1306
|
this.dtf = getCachedDTF(intl, intlOpts);
|
|
1307
1307
|
}
|
|
1308
1308
|
format() {
|
|
@@ -7241,6 +7241,23 @@ zod.z.object({
|
|
|
7241
7241
|
*/
|
|
7242
7242
|
next_page: zod.z.string().nullable().optional().describe("Cursor for fetching the next page of results")
|
|
7243
7243
|
}).describe("Successful operation");
|
|
7244
|
+
var assetSubmitInputSchema = zod.z.object({
|
|
7245
|
+
assets: zod.z.array(zod.z.string()).max(100).describe(
|
|
7246
|
+
"List of assets to classify, such as domains, social profiles, or blockchain addresses."
|
|
7247
|
+
),
|
|
7248
|
+
organizationSlug: zod.z.string().optional().describe(
|
|
7249
|
+
"Organization slug to classify assets for. If not provided, the classification will be done for all organizations."
|
|
7250
|
+
)
|
|
7251
|
+
});
|
|
7252
|
+
zod.z.object({
|
|
7253
|
+
submittedAssets: zod.z.array(
|
|
7254
|
+
zod.z.object({
|
|
7255
|
+
asset: zod.z.string().describe("The original asset content submitted"),
|
|
7256
|
+
assetId: zod.z.number().describe("The ID of the created or existing asset"),
|
|
7257
|
+
scanId: zod.z.number().optional().describe("The ID of the asset scan created (if immediately created)")
|
|
7258
|
+
})
|
|
7259
|
+
).describe("Array of submitted assets with their corresponding IDs")
|
|
7260
|
+
});
|
|
7244
7261
|
var BASE_64_PATTERN = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
7245
7262
|
var reportCreateInputSchema = zod.z.object({
|
|
7246
7263
|
/** Optional slug for identifying the organization within ChainPatrol. */
|
|
@@ -7355,6 +7372,17 @@ zod.z.object({
|
|
|
7355
7372
|
organizationLogo: zod.z.string(),
|
|
7356
7373
|
organizationLogos: zod.z.record(zod.z.string(), zod.z.string()),
|
|
7357
7374
|
hiddenLogos: zod.z.record(zod.z.string(), zod.z.boolean()).default({}),
|
|
7375
|
+
logoCustomization: zod.z.object({
|
|
7376
|
+
position: zod.z.object({
|
|
7377
|
+
x: zod.z.number(),
|
|
7378
|
+
y: zod.z.number()
|
|
7379
|
+
}),
|
|
7380
|
+
size: zod.z.object({
|
|
7381
|
+
width: zod.z.number(),
|
|
7382
|
+
height: zod.z.number()
|
|
7383
|
+
}),
|
|
7384
|
+
scale: zod.z.number().min(0.1).max(3).default(1)
|
|
7385
|
+
}).optional(),
|
|
7358
7386
|
executiveSummary: zod.z.string(),
|
|
7359
7387
|
overviewText: zod.z.string(),
|
|
7360
7388
|
overviewDisplayLocation: zod.z.enum(["cover", "separate"]).default("cover"),
|
|
@@ -7368,7 +7396,8 @@ zod.z.object({
|
|
|
7368
7396
|
proposalId: zod.z.number().optional(),
|
|
7369
7397
|
screenshotUrl: zod.z.string().nullable().optional(),
|
|
7370
7398
|
screenshotUrls: zod.z.array(zod.z.string()).optional(),
|
|
7371
|
-
imageUrl: zod.z.string().optional()
|
|
7399
|
+
imageUrl: zod.z.string().optional(),
|
|
7400
|
+
takedownCompletedAt: zod.z.string().nullable().optional()
|
|
7372
7401
|
})
|
|
7373
7402
|
),
|
|
7374
7403
|
productUpdates: zod.z.array(
|
|
@@ -7410,7 +7439,15 @@ zod.z.object({
|
|
|
7410
7439
|
title: zod.z.string(),
|
|
7411
7440
|
content: zod.z.string()
|
|
7412
7441
|
})
|
|
7413
|
-
).default([])
|
|
7442
|
+
).default([]),
|
|
7443
|
+
faqs: zod.z.record(
|
|
7444
|
+
zod.z.string(),
|
|
7445
|
+
zod.z.object({
|
|
7446
|
+
title: zod.z.string(),
|
|
7447
|
+
content: zod.z.string(),
|
|
7448
|
+
enabled: zod.z.boolean().default(true)
|
|
7449
|
+
})
|
|
7450
|
+
).default({})
|
|
7414
7451
|
});
|
|
7415
7452
|
|
|
7416
7453
|
// src/client.ts
|
|
@@ -7430,28 +7467,36 @@ var ChainPatrolClientErrorCodes = /* @__PURE__ */ ((ChainPatrolClientErrorCodes2
|
|
|
7430
7467
|
})(ChainPatrolClientErrorCodes || {});
|
|
7431
7468
|
var ChainPatrolClient = class {
|
|
7432
7469
|
constructor(options) {
|
|
7433
|
-
var _a;
|
|
7470
|
+
var _a, _b;
|
|
7434
7471
|
if (!options.apiKey) {
|
|
7435
7472
|
throw new ChainPatrolClientError(
|
|
7436
7473
|
"Missing API key",
|
|
7437
7474
|
"MISSING_API_KEY" /* MISSING_API_KEY */
|
|
7438
7475
|
);
|
|
7439
7476
|
}
|
|
7440
|
-
this.baseUrl = (
|
|
7477
|
+
this.baseUrl = trimTrailingSlashes(
|
|
7478
|
+
(_a = options.baseUrl) != null ? _a : "https://app.chainpatrol.io/api/"
|
|
7479
|
+
);
|
|
7441
7480
|
this.logger = new Logger({ component: "ChainPatrolClient" });
|
|
7442
7481
|
this.apiKey = options.apiKey;
|
|
7482
|
+
this.fetchOptions = (_b = options.fetchOptions) != null ? _b : {};
|
|
7443
7483
|
}
|
|
7444
7484
|
fetch(req) {
|
|
7445
7485
|
return __async(this, null, function* () {
|
|
7486
|
+
var _a;
|
|
7446
7487
|
const url = `${trimTrailingSlashes(this.baseUrl)}/${req.path.join("/")}`;
|
|
7447
7488
|
this.logger.debug("fetch", { url, req });
|
|
7448
7489
|
const bodyString = JSON.stringify(req.body);
|
|
7449
7490
|
const res = yield fetch(url, {
|
|
7450
7491
|
method: req.method,
|
|
7451
|
-
headers: {
|
|
7492
|
+
headers: __spreadValues({
|
|
7452
7493
|
"Content-Type": "application/json",
|
|
7453
7494
|
"X-Api-Key": this.apiKey
|
|
7454
|
-
},
|
|
7495
|
+
}, (_a = this.fetchOptions.headers) != null ? _a : {}),
|
|
7496
|
+
signal: this.fetchOptions.signal,
|
|
7497
|
+
redirect: this.fetchOptions.redirect,
|
|
7498
|
+
mode: this.fetchOptions.mode,
|
|
7499
|
+
credentials: this.fetchOptions.credentials,
|
|
7455
7500
|
body: bodyString
|
|
7456
7501
|
});
|
|
7457
7502
|
if (!res.ok) {
|
|
@@ -7479,6 +7524,14 @@ var ChainPatrolClient = class {
|
|
|
7479
7524
|
method: "POST",
|
|
7480
7525
|
body
|
|
7481
7526
|
});
|
|
7527
|
+
}),
|
|
7528
|
+
submit: (req) => __async(this, null, function* () {
|
|
7529
|
+
const body = assetSubmitInputSchema.parse(req);
|
|
7530
|
+
return yield this.fetch({
|
|
7531
|
+
path: ["v2", "asset", "submit"],
|
|
7532
|
+
method: "POST",
|
|
7533
|
+
body
|
|
7534
|
+
});
|
|
7482
7535
|
})
|
|
7483
7536
|
};
|
|
7484
7537
|
}
|