@chainpatrol/sdk 0.5.0 → 0.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
@@ -33,10 +33,6 @@ var __objRest = (source, exclude) => {
33
33
  }
34
34
  return target;
35
35
  };
36
- var __export = (target, all) => {
37
- for (var name in all)
38
- __defProp(target, name, { get: all[name], enumerable: true });
39
- };
40
36
  var __async = (__this, __arguments, generator) => {
41
37
  return new Promise((resolve, reject) => {
42
38
  var fulfilled = (value) => {
@@ -58,6 +54,110 @@ var __async = (__this, __arguments, generator) => {
58
54
  });
59
55
  };
60
56
 
57
+ // src/constants.ts
58
+ var StorageKeys = {
59
+ ALLOWLIST: "chainpatrol.allowed",
60
+ BLOCKLIST: "chainpatrol.blocked",
61
+ IGNORELIST: "chainpatrol.ignored"
62
+ };
63
+
64
+ // src/storage/define-storage.ts
65
+ function defineStorage(config) {
66
+ return () => config({
67
+ keys: Object.values(StorageKeys)
68
+ });
69
+ }
70
+
71
+ // src/storage/browser.ts
72
+ function isStorageAvailable(type) {
73
+ let storage;
74
+ try {
75
+ storage = window[type];
76
+ const x = "__storage_test__";
77
+ storage.setItem(x, x);
78
+ storage.removeItem(x);
79
+ return true;
80
+ } catch (e) {
81
+ return e instanceof DOMException && // everything except Firefox
82
+ (e.code === 22 || // Firefox
83
+ e.code === 1014 || // test name field too, because code might not be present
84
+ // everything except Firefox
85
+ e.name === "QuotaExceededError" || // Firefox
86
+ e.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored
87
+ storage && storage.length !== 0;
88
+ }
89
+ }
90
+ var Browser = defineStorage(({ keys }) => {
91
+ if (!isStorageAvailable("localStorage")) {
92
+ throw new Error("localStorage is not available");
93
+ }
94
+ return {
95
+ get: (key) => __async(null, null, function* () {
96
+ return localStorage.getItem(key);
97
+ }),
98
+ set: (key, value) => __async(null, null, function* () {
99
+ localStorage.setItem(key, value);
100
+ }),
101
+ delete: (key) => __async(null, null, function* () {
102
+ localStorage.removeItem(key);
103
+ }),
104
+ size: () => __async(null, null, function* () {
105
+ var _a, _b;
106
+ let total = 0;
107
+ for (let i = 0; i < localStorage.length; i++) {
108
+ const key = localStorage.key(i);
109
+ if (key && keys.includes(key)) {
110
+ total += (_b = (_a = localStorage.getItem(key)) == null ? void 0 : _a.length) != null ? _b : 0;
111
+ }
112
+ }
113
+ return total;
114
+ })
115
+ };
116
+ });
117
+
118
+ // src/storage/extension.ts
119
+ var Extension = defineStorage(({ keys }) => {
120
+ return {
121
+ get: (key) => __async(null, null, function* () {
122
+ const result = yield chrome.storage.local.get(key);
123
+ return result[key];
124
+ }),
125
+ set: (key, value) => __async(null, null, function* () {
126
+ yield chrome.storage.local.set({ [key]: value });
127
+ }),
128
+ delete: (key) => __async(null, null, function* () {
129
+ yield chrome.storage.local.remove(key);
130
+ }),
131
+ size: () => __async(null, null, function* () {
132
+ const usageBytes = yield chrome.storage.local.getBytesInUse(keys);
133
+ return usageBytes;
134
+ })
135
+ };
136
+ });
137
+
138
+ // src/storage/memory.ts
139
+ var Memory = defineStorage(() => {
140
+ const storage = /* @__PURE__ */ new Map();
141
+ return {
142
+ get: (key) => __async(null, null, function* () {
143
+ return storage.get(key) || null;
144
+ }),
145
+ set: (key, value) => __async(null, null, function* () {
146
+ storage.set(key, value);
147
+ }),
148
+ delete: (key) => __async(null, null, function* () {
149
+ storage.delete(key);
150
+ }),
151
+ size: () => __async(null, null, function* () {
152
+ let total = 0;
153
+ for (const value of storage.values()) {
154
+ total += value.length;
155
+ }
156
+ return total;
157
+ })
158
+ };
159
+ });
160
+
61
161
  // src/events.ts
62
162
  var ContinueAtOwnRisk = "CHAINPATROL_CONTINUE_AT_OWN_RISK";
63
163
  var IgnorelistUpdated = "CHAINPATROL_IGNORELIST_UPDATED";
@@ -143,7 +243,7 @@ function getBackgroundScriptHandle() {
143
243
  removeListener: (callback) => {
144
244
  runtime.onMessage.removeListener(callback);
145
245
  },
146
- postMessage: (message) => __async(this, null, function* () {
246
+ postMessage: (message) => __async(null, null, function* () {
147
247
  const [tab] = yield globalThis.chrome.tabs.query({
148
248
  active: true,
149
249
  lastFocusedWindow: true
@@ -165,7 +265,7 @@ function getContentScriptHandle() {
165
265
  removeListener: (callback) => {
166
266
  runtime.onMessage.removeListener(callback);
167
267
  },
168
- postMessage: (message) => __async(this, null, function* () {
268
+ postMessage: (message) => __async(null, null, function* () {
169
269
  runtime.sendMessage(message).catch((error) => {
170
270
  console.error("Failed to send message", { message, error });
171
271
  });
@@ -283,7 +383,7 @@ var supportedProtocols = /* @__PURE__ */ new Set([
283
383
  var hasCustomProtocol = (urlString) => {
284
384
  try {
285
385
  const { protocol } = new URL(urlString);
286
- return protocol.endsWith(":") && !supportedProtocols.has(protocol);
386
+ return protocol.endsWith(":") && !protocol.includes(".") && !supportedProtocols.has(protocol);
287
387
  } catch (e) {
288
388
  return false;
289
389
  }
@@ -494,7 +594,7 @@ z.object({
494
594
  assetId: z.number(),
495
595
  name: z.string().optional(),
496
596
  description: z.string().optional(),
497
- assetGroupId: z.number().optional(),
597
+ assetGroupId: z.number().nullable().optional(),
498
598
  updatedByOrganizationId: z.number().optional()
499
599
  });
500
600
  z.object({
@@ -1175,17 +1275,17 @@ var PolyDateFormatter = class {
1175
1275
  constructor(dt, intl, opts) {
1176
1276
  this.opts = opts;
1177
1277
  this.originalZone = void 0;
1178
- let z14 = void 0;
1278
+ let z15 = void 0;
1179
1279
  if (this.opts.timeZone) {
1180
1280
  this.dt = dt;
1181
1281
  } else if (dt.zone.type === "fixed") {
1182
1282
  const gmtOffset = -1 * (dt.offset / 60);
1183
1283
  const offsetZ = gmtOffset >= 0 ? `Etc/GMT+${gmtOffset}` : `Etc/GMT${gmtOffset}`;
1184
1284
  if (dt.offset !== 0 && IANAZone.create(offsetZ).valid) {
1185
- z14 = offsetZ;
1285
+ z15 = offsetZ;
1186
1286
  this.dt = dt;
1187
1287
  } else {
1188
- z14 = "UTC";
1288
+ z15 = "UTC";
1189
1289
  this.dt = dt.offset === 0 ? dt : dt.setZone("UTC").plus({ minutes: dt.offset });
1190
1290
  this.originalZone = dt.zone;
1191
1291
  }
@@ -1193,14 +1293,14 @@ var PolyDateFormatter = class {
1193
1293
  this.dt = dt;
1194
1294
  } else if (dt.zone.type === "iana") {
1195
1295
  this.dt = dt;
1196
- z14 = dt.zone.name;
1296
+ z15 = dt.zone.name;
1197
1297
  } else {
1198
- z14 = "UTC";
1298
+ z15 = "UTC";
1199
1299
  this.dt = dt.setZone("UTC").plus({ minutes: dt.offset });
1200
1300
  this.originalZone = dt.zone;
1201
1301
  }
1202
1302
  const intlOpts = __spreadValues({}, this.opts);
1203
- intlOpts.timeZone = intlOpts.timeZone || z14;
1303
+ intlOpts.timeZone = intlOpts.timeZone || z15;
1204
1304
  this.dtf = getCachedDTF(intl, intlOpts);
1205
1305
  }
1206
1306
  format() {
@@ -5320,7 +5420,7 @@ var DateTime = class _DateTime {
5320
5420
  throw new InvalidArgumentError(
5321
5421
  `fromMillis requires a numerical input, but received a ${typeof milliseconds} with value ${milliseconds}`
5322
5422
  );
5323
- } else if (milliseconds < -864e13 || milliseconds > MAX_DATE) {
5423
+ } else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) {
5324
5424
  return _DateTime.invalid("Timestamp out of range");
5325
5425
  } else {
5326
5426
  return new _DateTime({
@@ -6917,7 +7017,7 @@ function friendlyDateTime(dateTimeish) {
6917
7017
  }
6918
7018
  }
6919
7019
 
6920
- // ../../internal/database/prisma/enums/index.ts
7020
+ // ../../internal/database/src/generated/enums.ts
6921
7021
  var AssetType = {
6922
7022
  URL: "URL",
6923
7023
  PAGE: "PAGE",
@@ -6950,13 +7050,26 @@ var AssetType = {
6950
7050
  DISCORD_USER: "DISCORD_USER",
6951
7051
  QUORA: "QUORA",
6952
7052
  GITHUB: "GITHUB",
6953
- TEACHABLE: "TEACHABLE"
7053
+ TEACHABLE: "TEACHABLE",
7054
+ SUBSTACK: "SUBSTACK",
7055
+ DEBANK: "DEBANK",
7056
+ TAWK_TO: "TAWK_TO",
7057
+ JOTFORM: "JOTFORM",
7058
+ PRIMAL: "PRIMAL",
7059
+ BLUESKY: "BLUESKY",
7060
+ SNAPCHAT: "SNAPCHAT",
7061
+ DESO: "DESO"
6954
7062
  };
6955
7063
  var AssetStatus = {
6956
7064
  UNKNOWN: "UNKNOWN",
6957
7065
  ALLOWED: "ALLOWED",
6958
7066
  BLOCKED: "BLOCKED"
6959
7067
  };
7068
+ var ProposalReviewStatus = {
7069
+ PENDING: "PENDING",
7070
+ APPROVED: "APPROVED",
7071
+ REJECTED: "REJECTED"
7072
+ };
6960
7073
 
6961
7074
  // ../../internal/validation/src/public/asset/changelog.ts
6962
7075
  var DateString = z.string().regex(/^\d{4}-\d{2}-\d{2}$/, "Must be in the format `YYYY-MM-DD`").pipe(z.coerce.date());
@@ -7026,6 +7139,7 @@ var AssetRecordSource = /* @__PURE__ */ ((AssetRecordSource2) => {
7026
7139
  AssetRecordSource2["EthPhishingDetect"] = "eth-phishing-detect";
7027
7140
  AssetRecordSource2["Phishfort"] = "phishfort";
7028
7141
  AssetRecordSource2["Seal"] = "seal";
7142
+ AssetRecordSource2["PolkadotPhishing"] = "polkadot-phishing";
7029
7143
  return AssetRecordSource2;
7030
7144
  })(AssetRecordSource || {});
7031
7145
  var AssetStatusReason = /* @__PURE__ */ ((AssetStatusReason2) => {
@@ -7034,6 +7148,7 @@ var AssetStatusReason = /* @__PURE__ */ ((AssetStatusReason2) => {
7034
7148
  AssetStatusReason2["SourceError"] = "source-error";
7035
7149
  AssetStatusReason2["ParentDomain"] = "parent-domain";
7036
7150
  AssetStatusReason2["HostingDomain"] = "hosting-domain";
7151
+ AssetStatusReason2["Timeout"] = "timeout";
7037
7152
  return AssetStatusReason2;
7038
7153
  })(AssetStatusReason || {});
7039
7154
  var AssetCheckErrorCodes = /* @__PURE__ */ ((AssetCheckErrorCodes2) => {
@@ -7082,7 +7197,7 @@ var assetListInputSchema = z.object({
7082
7197
  endDate: z.string().transform((str) => new Date(str)).optional().describe(
7083
7198
  "The end date to list assets from. This should be in the format `YYYY-MM-DD` and is inclusive."
7084
7199
  ),
7085
- per_page: z.number().int().min(1).max(1e4).optional().describe("The number of assets to return per page"),
7200
+ per_page: z.number().int().min(1).max(1e4).optional().default(100).describe("The number of assets to return per page"),
7086
7201
  /**
7087
7202
  * Optional next_page cursor for pagination; indicates where the next page of results should start.
7088
7203
  */
@@ -7133,13 +7248,15 @@ var reportCreateInputSchema = z.object({
7133
7248
  /** Optional Telegram Group ID associated with the organization. */
7134
7249
  telegramGroupId: z.string().describe("Telegram Group ID linked to the organization on ChainPatrol").optional(),
7135
7250
  /** Title of the report. */
7136
- title: z.string().min(3).describe("Title of the report"),
7251
+ title: z.string().min(3).describe("Title of the report").optional(),
7137
7252
  /** Description of the report, supporting markdown syntax. */
7138
- description: z.string().describe("Description of the report. Supports markdown"),
7253
+ description: z.string().describe("Description of the report. Supports markdown").optional(),
7139
7254
  /** Optional contact information of the reporter. */
7140
7255
  contactInfo: z.string().optional(),
7141
7256
  /** Optional list of URLs for images to be attached to the report. */
7142
7257
  attachmentUrls: z.array(z.string().url()).optional().describe("URLs of images to attach to the report"),
7258
+ /** Optional link to the external submission (e.g. Telegram message link) */
7259
+ externalSubmissionLink: z.string().url().optional().describe("Link to the external submission (e.g. Telegram message link)"),
7143
7260
  /**
7144
7261
  * List of assets with their content and proposed status.
7145
7262
  * Each asset can optionally include a screenshot object.
@@ -7172,7 +7289,7 @@ var reportCreateInputSchema = z.object({
7172
7289
  if (v.rawAssetsInput && v.assets.length === 0) {
7173
7290
  v.assets = v.rawAssetsInput.split("\n").map((line) => line.trim()).filter((line) => line.length > 0).map((line) => ({
7174
7291
  content: line,
7175
- status: "BLOCKED"
7292
+ status: AssetStatus.BLOCKED
7176
7293
  }));
7177
7294
  }
7178
7295
  return v;
@@ -7213,12 +7330,106 @@ z.object({
7213
7330
  z.object({
7214
7331
  id: z.number(),
7215
7332
  content: z.string(),
7216
- status: z.nativeEnum(AssetStatus)
7333
+ status: z.nativeEnum(AssetStatus),
7334
+ reviewStatus: z.nativeEnum(ProposalReviewStatus)
7217
7335
  })
7218
7336
  )
7219
7337
  })
7220
7338
  )
7221
7339
  });
7340
+ z.object({
7341
+ selectedOrgs: z.array(
7342
+ z.object({
7343
+ id: z.number(),
7344
+ name: z.string(),
7345
+ slug: z.string(),
7346
+ avatarUrl: z.string().nullable().optional()
7347
+ })
7348
+ ),
7349
+ parentOrg: z.string(),
7350
+ startDate: z.string(),
7351
+ endDate: z.string(),
7352
+ weekNumber: z.number().max(53).optional(),
7353
+ organizationLogo: z.string(),
7354
+ organizationLogos: z.record(z.string(), z.string()),
7355
+ hiddenLogos: z.record(z.string(), z.boolean()).default({}),
7356
+ logoCustomization: z.object({
7357
+ position: z.object({
7358
+ x: z.number(),
7359
+ y: z.number()
7360
+ }),
7361
+ size: z.object({
7362
+ width: z.number(),
7363
+ height: z.number()
7364
+ }),
7365
+ scale: z.number().min(0.1).max(3).default(1)
7366
+ }).optional(),
7367
+ executiveSummary: z.string(),
7368
+ overviewText: z.string(),
7369
+ overviewDisplayLocation: z.enum(["cover", "separate"]).default("cover"),
7370
+ publishedDate: z.string().default(() => (/* @__PURE__ */ new Date()).toISOString().split("T")[0]),
7371
+ caseStudies: z.array(
7372
+ z.object({
7373
+ id: z.string(),
7374
+ title: z.string(),
7375
+ description: z.string(),
7376
+ assetId: z.number().optional(),
7377
+ proposalId: z.number().optional(),
7378
+ screenshotUrl: z.string().nullable().optional(),
7379
+ screenshotUrls: z.array(z.string()).optional(),
7380
+ imageUrl: z.string().optional(),
7381
+ takedownCompletedAt: z.string().nullable().optional()
7382
+ })
7383
+ ),
7384
+ productUpdates: z.array(
7385
+ z.object({
7386
+ id: z.string(),
7387
+ title: z.string(),
7388
+ content: z.string(),
7389
+ createdAt: z.string().optional()
7390
+ })
7391
+ ),
7392
+ recommendations: z.array(
7393
+ z.object({
7394
+ id: z.string(),
7395
+ title: z.string(),
7396
+ content: z.string()
7397
+ })
7398
+ ),
7399
+ customMetrics: z.object({
7400
+ totalReports: z.number(),
7401
+ threatsBlocked: z.number(),
7402
+ domainsBlocked: z.number(),
7403
+ takedownsFiled: z.number(),
7404
+ falsePositives: z.number(),
7405
+ additionalNotes: z.string().optional()
7406
+ }),
7407
+ recentTakedowns: z.array(
7408
+ z.object({
7409
+ id: z.number(),
7410
+ content: z.string(),
7411
+ type: z.string(),
7412
+ createdAt: z.coerce.date(),
7413
+ takedownCompletedAt: z.coerce.date().nullable(),
7414
+ description: z.string().nullable().optional()
7415
+ })
7416
+ ).default([]),
7417
+ customPages: z.array(
7418
+ z.object({
7419
+ id: z.string(),
7420
+ title: z.string(),
7421
+ content: z.string()
7422
+ })
7423
+ ).default([]),
7424
+ faqs: z.record(
7425
+ z.string(),
7426
+ z.object({
7427
+ title: z.string(),
7428
+ content: z.string(),
7429
+ enabled: z.boolean().default(true)
7430
+ })
7431
+ ).default({})
7432
+ });
7222
7433
 
7223
7434
  // src/client.ts
7224
7435
  function trimTrailingSlashes(url) {
@@ -7237,28 +7448,36 @@ var ChainPatrolClientErrorCodes = /* @__PURE__ */ ((ChainPatrolClientErrorCodes2
7237
7448
  })(ChainPatrolClientErrorCodes || {});
7238
7449
  var ChainPatrolClient = class {
7239
7450
  constructor(options) {
7240
- var _a;
7451
+ var _a, _b;
7241
7452
  if (!options.apiKey) {
7242
7453
  throw new ChainPatrolClientError(
7243
7454
  "Missing API key",
7244
7455
  "MISSING_API_KEY" /* MISSING_API_KEY */
7245
7456
  );
7246
7457
  }
7247
- this.baseUrl = (_a = options.baseUrl) != null ? _a : "https://app.chainpatrol.io/api/";
7458
+ this.baseUrl = trimTrailingSlashes(
7459
+ (_a = options.baseUrl) != null ? _a : "https://app.chainpatrol.io/api/"
7460
+ );
7248
7461
  this.logger = new Logger({ component: "ChainPatrolClient" });
7249
7462
  this.apiKey = options.apiKey;
7463
+ this.fetchOptions = (_b = options.fetchOptions) != null ? _b : {};
7250
7464
  }
7251
7465
  fetch(req) {
7252
7466
  return __async(this, null, function* () {
7467
+ var _a;
7253
7468
  const url = `${trimTrailingSlashes(this.baseUrl)}/${req.path.join("/")}`;
7254
7469
  this.logger.debug("fetch", { url, req });
7255
7470
  const bodyString = JSON.stringify(req.body);
7256
7471
  const res = yield fetch(url, {
7257
7472
  method: req.method,
7258
- headers: {
7473
+ headers: __spreadValues({
7259
7474
  "Content-Type": "application/json",
7260
7475
  "X-Api-Key": this.apiKey
7261
- },
7476
+ }, (_a = this.fetchOptions.headers) != null ? _a : {}),
7477
+ signal: this.fetchOptions.signal,
7478
+ redirect: this.fetchOptions.redirect,
7479
+ mode: this.fetchOptions.mode,
7480
+ credentials: this.fetchOptions.credentials,
7262
7481
  body: bodyString
7263
7482
  });
7264
7483
  if (!res.ok) {
@@ -7303,112 +7522,6 @@ var ChainPatrolClient = class {
7303
7522
  }
7304
7523
  };
7305
7524
 
7306
- // src/storage/index.ts
7307
- var storage_exports = {};
7308
- __export(storage_exports, {
7309
- Browser: () => Browser,
7310
- Extension: () => Extension,
7311
- Memory: () => Memory,
7312
- defineStorage: () => defineStorage
7313
- });
7314
-
7315
- // src/storage/define-storage.ts
7316
- function defineStorage(config) {
7317
- return () => config({
7318
- keys: Object.values(ThreatDetector.StorageKeys)
7319
- });
7320
- }
7321
-
7322
- // src/storage/extension.ts
7323
- var Extension = defineStorage(({ keys }) => {
7324
- return {
7325
- get: (key) => __async(void 0, null, function* () {
7326
- const result = yield chrome.storage.local.get(key);
7327
- return result[key];
7328
- }),
7329
- set: (key, value) => __async(void 0, null, function* () {
7330
- yield chrome.storage.local.set({ [key]: value });
7331
- }),
7332
- delete: (key) => __async(void 0, null, function* () {
7333
- yield chrome.storage.local.remove(key);
7334
- }),
7335
- size: () => __async(void 0, null, function* () {
7336
- const usageBytes = yield chrome.storage.local.getBytesInUse(keys);
7337
- return usageBytes;
7338
- })
7339
- };
7340
- });
7341
-
7342
- // src/storage/browser.ts
7343
- function isStorageAvailable(type) {
7344
- let storage;
7345
- try {
7346
- storage = window[type];
7347
- const x = "__storage_test__";
7348
- storage.setItem(x, x);
7349
- storage.removeItem(x);
7350
- return true;
7351
- } catch (e) {
7352
- return e instanceof DOMException && // everything except Firefox
7353
- (e.code === 22 || // Firefox
7354
- e.code === 1014 || // test name field too, because code might not be present
7355
- // everything except Firefox
7356
- e.name === "QuotaExceededError" || // Firefox
7357
- e.name === "NS_ERROR_DOM_QUOTA_REACHED") && // acknowledge QuotaExceededError only if there's something already stored
7358
- storage && storage.length !== 0;
7359
- }
7360
- }
7361
- var Browser = defineStorage(({ keys }) => {
7362
- if (!isStorageAvailable("localStorage")) {
7363
- throw new Error("localStorage is not available");
7364
- }
7365
- return {
7366
- get: (key) => __async(void 0, null, function* () {
7367
- return localStorage.getItem(key);
7368
- }),
7369
- set: (key, value) => __async(void 0, null, function* () {
7370
- localStorage.setItem(key, value);
7371
- }),
7372
- delete: (key) => __async(void 0, null, function* () {
7373
- localStorage.removeItem(key);
7374
- }),
7375
- size: () => __async(void 0, null, function* () {
7376
- var _a, _b;
7377
- let total = 0;
7378
- for (let i = 0; i < localStorage.length; i++) {
7379
- const key = localStorage.key(i);
7380
- if (key && keys.includes(key)) {
7381
- total += (_b = (_a = localStorage.getItem(key)) == null ? void 0 : _a.length) != null ? _b : 0;
7382
- }
7383
- }
7384
- return total;
7385
- })
7386
- };
7387
- });
7388
-
7389
- // src/storage/memory.ts
7390
- var Memory = defineStorage(() => {
7391
- const storage = /* @__PURE__ */ new Map();
7392
- return {
7393
- get: (key) => __async(void 0, null, function* () {
7394
- return storage.get(key) || null;
7395
- }),
7396
- set: (key, value) => __async(void 0, null, function* () {
7397
- storage.set(key, value);
7398
- }),
7399
- delete: (key) => __async(void 0, null, function* () {
7400
- storage.delete(key);
7401
- }),
7402
- size: () => __async(void 0, null, function* () {
7403
- let total = 0;
7404
- for (const value of storage.values()) {
7405
- total += value.length;
7406
- }
7407
- return total;
7408
- })
7409
- };
7410
- });
7411
-
7412
7525
  // src/detector.ts
7413
7526
  var DomainParseError = class extends Error {
7414
7527
  constructor(message) {
@@ -7499,9 +7612,9 @@ var _ThreatDetector = class _ThreatDetector {
7499
7612
  const res = yield this.client.asset.check({ content: domain });
7500
7613
  this.logger.debug("Updating cache", { domain, status: res.status });
7501
7614
  if (res.status === "ALLOWED") {
7502
- yield this.addDomainToCache(domain, _ThreatDetector.StorageKeys.ALLOWLIST);
7615
+ yield this.addDomainToCache(domain, StorageKeys.ALLOWLIST);
7503
7616
  } else if (res.status === "BLOCKED") {
7504
- yield this.addDomainToCache(domain, _ThreatDetector.StorageKeys.BLOCKLIST);
7617
+ yield this.addDomainToCache(domain, StorageKeys.BLOCKLIST);
7505
7618
  }
7506
7619
  status = res.status;
7507
7620
  } catch (e) {
@@ -7536,7 +7649,7 @@ var _ThreatDetector = class _ThreatDetector {
7536
7649
  const domain = this.parseDomainOrThrow(url);
7537
7650
  this.logger.debug("Allowing URL", { url, domain });
7538
7651
  yield this.invalidateDomainInCaches(domain);
7539
- yield this.addDomainToCache(domain, _ThreatDetector.StorageKeys.ALLOWLIST);
7652
+ yield this.addDomainToCache(domain, StorageKeys.ALLOWLIST);
7540
7653
  return {
7541
7654
  ok: true,
7542
7655
  url: domain
@@ -7557,7 +7670,7 @@ var _ThreatDetector = class _ThreatDetector {
7557
7670
  const domain = this.parseDomainOrThrow(url);
7558
7671
  this.logger.debug("Blocking URL", { url, domain });
7559
7672
  yield this.invalidateDomainInCaches(domain);
7560
- yield this.addDomainToCache(domain, _ThreatDetector.StorageKeys.BLOCKLIST);
7673
+ yield this.addDomainToCache(domain, StorageKeys.BLOCKLIST);
7561
7674
  return {
7562
7675
  ok: true,
7563
7676
  url: domain
@@ -7577,7 +7690,7 @@ var _ThreatDetector = class _ThreatDetector {
7577
7690
  try {
7578
7691
  const domain = this.parseDomainOrThrow(url);
7579
7692
  this.logger.debug("Ignoring URL", { url, domain });
7580
- yield this.addDomainToCache(domain, _ThreatDetector.StorageKeys.IGNORELIST);
7693
+ yield this.addDomainToCache(domain, StorageKeys.IGNORELIST);
7581
7694
  return {
7582
7695
  ok: true,
7583
7696
  url: domain
@@ -7626,8 +7739,8 @@ var _ThreatDetector = class _ThreatDetector {
7626
7739
  }
7627
7740
  invalidateDomainInCaches(domain) {
7628
7741
  return __async(this, null, function* () {
7629
- yield this.invalidateDomainInCache(domain, _ThreatDetector.StorageKeys.ALLOWLIST);
7630
- yield this.invalidateDomainInCache(domain, _ThreatDetector.StorageKeys.BLOCKLIST);
7742
+ yield this.invalidateDomainInCache(domain, StorageKeys.ALLOWLIST);
7743
+ yield this.invalidateDomainInCache(domain, StorageKeys.BLOCKLIST);
7631
7744
  });
7632
7745
  }
7633
7746
  invalidateDomainInCache(domain, key) {
@@ -7684,11 +7797,11 @@ var _ThreatDetector = class _ThreatDetector {
7684
7797
  }
7685
7798
  getStatusFromCache(domain) {
7686
7799
  return __async(this, null, function* () {
7687
- if (yield this.isDomainInList(domain, _ThreatDetector.StorageKeys.IGNORELIST)) {
7800
+ if (yield this.isDomainInList(domain, StorageKeys.IGNORELIST)) {
7688
7801
  return "IGNORED";
7689
- } else if (yield this.isDomainInList(domain, _ThreatDetector.StorageKeys.BLOCKLIST)) {
7802
+ } else if (yield this.isDomainInList(domain, StorageKeys.BLOCKLIST)) {
7690
7803
  return "BLOCKED";
7691
- } else if (yield this.isDomainInList(domain, _ThreatDetector.StorageKeys.ALLOWLIST)) {
7804
+ } else if (yield this.isDomainInList(domain, StorageKeys.ALLOWLIST)) {
7692
7805
  return "ALLOWED";
7693
7806
  } else {
7694
7807
  return "UNKNOWN";
@@ -7696,11 +7809,6 @@ var _ThreatDetector = class _ThreatDetector {
7696
7809
  });
7697
7810
  }
7698
7811
  };
7699
- _ThreatDetector.StorageKeys = {
7700
- ALLOWLIST: "chainpatrol.allowed",
7701
- BLOCKLIST: "chainpatrol.blocked",
7702
- IGNORELIST: "chainpatrol.ignored"
7703
- };
7704
7812
  _ThreatDetector.CHAINPATROL_WARNING_URL = "https://app.chainpatrol.io/warning";
7705
7813
  _ThreatDetector.Schema = z.object({
7706
7814
  version: z.literal(1),
@@ -7710,6 +7818,13 @@ _ThreatDetector.Schema = z.object({
7710
7818
  });
7711
7819
  var ThreatDetector = _ThreatDetector;
7712
7820
 
7713
- export { ChainPatrolClient, ChainPatrolClientError, ChainPatrolClientErrorCodes, DomainParseError, Events, Relay, storage_exports as Storage, ThreatDetector };
7821
+ // src/index.ts
7822
+ var Storage = {
7823
+ Memory,
7824
+ Extension,
7825
+ Browser
7826
+ };
7827
+
7828
+ export { ChainPatrolClient, ChainPatrolClientError, ChainPatrolClientErrorCodes, DomainParseError, Events, Relay, Storage, ThreatDetector };
7714
7829
  //# sourceMappingURL=index.mjs.map
7715
7830
  //# sourceMappingURL=index.mjs.map