@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/README.md +1 -1
- package/dist/index.d.mts +26 -43
- package/dist/index.d.ts +26 -43
- package/dist/index.js +263 -148
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +263 -148
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -10
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -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,6 +67,7 @@ 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(): {
|
|
@@ -85,7 +87,7 @@ declare class ChainPatrolClient {
|
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
interface Storage {
|
|
90
|
+
interface Storage$1 {
|
|
89
91
|
get: (key: string) => Promise<string | null>;
|
|
90
92
|
set: (key: string, value: string) => Promise<void>;
|
|
91
93
|
delete: (key: string) => Promise<void>;
|
|
@@ -108,11 +110,6 @@ declare class DomainParseError extends Error {
|
|
|
108
110
|
constructor(message: string);
|
|
109
111
|
}
|
|
110
112
|
declare class ThreatDetector {
|
|
111
|
-
static StorageKeys: {
|
|
112
|
-
ALLOWLIST: string;
|
|
113
|
-
BLOCKLIST: string;
|
|
114
|
-
IGNORELIST: string;
|
|
115
|
-
};
|
|
116
113
|
private static readonly CHAINPATROL_WARNING_URL;
|
|
117
114
|
private static readonly Schema;
|
|
118
115
|
private mode;
|
|
@@ -122,20 +119,20 @@ declare class ThreatDetector {
|
|
|
122
119
|
private readonly logger;
|
|
123
120
|
constructor({ mode, storage, redirectUrl, }: {
|
|
124
121
|
mode: "local";
|
|
125
|
-
storage?: Storage;
|
|
122
|
+
storage?: Storage$1;
|
|
126
123
|
redirectUrl?: string | ((url: string) => string);
|
|
127
124
|
});
|
|
128
125
|
constructor({ mode, apiKey, storage, redirectUrl, }: {
|
|
129
126
|
mode: "cloud";
|
|
130
127
|
apiKey: string;
|
|
131
|
-
storage?: Storage;
|
|
128
|
+
storage?: Storage$1;
|
|
132
129
|
redirectUrl?: string | ((url: string) => string);
|
|
133
130
|
});
|
|
134
131
|
constructor({ mode, apiKey, proxyUrl, storage, redirectUrl, }: {
|
|
135
132
|
mode: "cloud";
|
|
136
133
|
apiKey: string;
|
|
137
134
|
proxyUrl?: string;
|
|
138
|
-
storage?: Storage;
|
|
135
|
+
storage?: Storage$1;
|
|
139
136
|
redirectUrl?: string | ((url: string) => string);
|
|
140
137
|
});
|
|
141
138
|
url(url: string): Promise<URLResult>;
|
|
@@ -175,39 +172,25 @@ declare class ThreatDetector {
|
|
|
175
172
|
private getStatusFromCache;
|
|
176
173
|
}
|
|
177
174
|
|
|
178
|
-
declare const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
175
|
+
declare const Storage: {
|
|
176
|
+
Memory: () => {
|
|
177
|
+
get: (key: string) => Promise<string | null>;
|
|
178
|
+
set: (key: string, value: string) => Promise<void>;
|
|
179
|
+
delete: (key: string) => Promise<void>;
|
|
180
|
+
size: () => Promise<number>;
|
|
181
|
+
};
|
|
182
|
+
Extension: () => {
|
|
183
|
+
get: (key: string) => Promise<any>;
|
|
184
|
+
set: (key: string, value: string) => Promise<void>;
|
|
185
|
+
delete: (key: string) => Promise<void>;
|
|
186
|
+
size: () => Promise<number>;
|
|
187
|
+
};
|
|
188
|
+
Browser: () => {
|
|
189
|
+
get: (key: string) => Promise<string | null>;
|
|
190
|
+
set: (key: string, value: string) => Promise<void>;
|
|
191
|
+
delete: (key: string) => Promise<void>;
|
|
192
|
+
size: () => Promise<number>;
|
|
193
|
+
};
|
|
197
194
|
};
|
|
198
195
|
|
|
199
|
-
|
|
200
|
-
keys: string[];
|
|
201
|
-
}
|
|
202
|
-
declare function defineStorage<T extends Storage>(config: (ctx: Context) => T): () => T;
|
|
203
|
-
|
|
204
|
-
declare const index_Browser: typeof Browser;
|
|
205
|
-
declare const index_Extension: typeof Extension;
|
|
206
|
-
declare const index_Memory: typeof Memory;
|
|
207
|
-
type index_Storage = Storage;
|
|
208
|
-
declare const index_defineStorage: typeof defineStorage;
|
|
209
|
-
declare namespace index {
|
|
210
|
-
export { index_Browser as Browser, index_Extension as Extension, index_Memory as Memory, type index_Storage as Storage, index_defineStorage as defineStorage };
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export { type AssetStatus, type AssetType, ChainPatrolClient, ChainPatrolClientError, ChainPatrolClientErrorCodes, type ChainPatrolClientOptions, type DetectorAssetStatus, DomainParseError, type EventData, Events, Relay, index as Storage, ThreatDetector, type URLResult };
|
|
196
|
+
export { type AssetStatus, type AssetType, ChainPatrolClient, ChainPatrolClientError, ChainPatrolClientErrorCodes, type ChainPatrolClientOptions, type DetectorAssetStatus, DomainParseError, type EventData, Events, Relay, Storage, ThreatDetector, type URLResult };
|
package/dist/index.d.ts
CHANGED
|
@@ -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,6 +67,7 @@ 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(): {
|
|
@@ -85,7 +87,7 @@ declare class ChainPatrolClient {
|
|
|
85
87
|
};
|
|
86
88
|
}
|
|
87
89
|
|
|
88
|
-
interface Storage {
|
|
90
|
+
interface Storage$1 {
|
|
89
91
|
get: (key: string) => Promise<string | null>;
|
|
90
92
|
set: (key: string, value: string) => Promise<void>;
|
|
91
93
|
delete: (key: string) => Promise<void>;
|
|
@@ -108,11 +110,6 @@ declare class DomainParseError extends Error {
|
|
|
108
110
|
constructor(message: string);
|
|
109
111
|
}
|
|
110
112
|
declare class ThreatDetector {
|
|
111
|
-
static StorageKeys: {
|
|
112
|
-
ALLOWLIST: string;
|
|
113
|
-
BLOCKLIST: string;
|
|
114
|
-
IGNORELIST: string;
|
|
115
|
-
};
|
|
116
113
|
private static readonly CHAINPATROL_WARNING_URL;
|
|
117
114
|
private static readonly Schema;
|
|
118
115
|
private mode;
|
|
@@ -122,20 +119,20 @@ declare class ThreatDetector {
|
|
|
122
119
|
private readonly logger;
|
|
123
120
|
constructor({ mode, storage, redirectUrl, }: {
|
|
124
121
|
mode: "local";
|
|
125
|
-
storage?: Storage;
|
|
122
|
+
storage?: Storage$1;
|
|
126
123
|
redirectUrl?: string | ((url: string) => string);
|
|
127
124
|
});
|
|
128
125
|
constructor({ mode, apiKey, storage, redirectUrl, }: {
|
|
129
126
|
mode: "cloud";
|
|
130
127
|
apiKey: string;
|
|
131
|
-
storage?: Storage;
|
|
128
|
+
storage?: Storage$1;
|
|
132
129
|
redirectUrl?: string | ((url: string) => string);
|
|
133
130
|
});
|
|
134
131
|
constructor({ mode, apiKey, proxyUrl, storage, redirectUrl, }: {
|
|
135
132
|
mode: "cloud";
|
|
136
133
|
apiKey: string;
|
|
137
134
|
proxyUrl?: string;
|
|
138
|
-
storage?: Storage;
|
|
135
|
+
storage?: Storage$1;
|
|
139
136
|
redirectUrl?: string | ((url: string) => string);
|
|
140
137
|
});
|
|
141
138
|
url(url: string): Promise<URLResult>;
|
|
@@ -175,39 +172,25 @@ declare class ThreatDetector {
|
|
|
175
172
|
private getStatusFromCache;
|
|
176
173
|
}
|
|
177
174
|
|
|
178
|
-
declare const
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
175
|
+
declare const Storage: {
|
|
176
|
+
Memory: () => {
|
|
177
|
+
get: (key: string) => Promise<string | null>;
|
|
178
|
+
set: (key: string, value: string) => Promise<void>;
|
|
179
|
+
delete: (key: string) => Promise<void>;
|
|
180
|
+
size: () => Promise<number>;
|
|
181
|
+
};
|
|
182
|
+
Extension: () => {
|
|
183
|
+
get: (key: string) => Promise<any>;
|
|
184
|
+
set: (key: string, value: string) => Promise<void>;
|
|
185
|
+
delete: (key: string) => Promise<void>;
|
|
186
|
+
size: () => Promise<number>;
|
|
187
|
+
};
|
|
188
|
+
Browser: () => {
|
|
189
|
+
get: (key: string) => Promise<string | null>;
|
|
190
|
+
set: (key: string, value: string) => Promise<void>;
|
|
191
|
+
delete: (key: string) => Promise<void>;
|
|
192
|
+
size: () => Promise<number>;
|
|
193
|
+
};
|
|
197
194
|
};
|
|
198
195
|
|
|
199
|
-
|
|
200
|
-
keys: string[];
|
|
201
|
-
}
|
|
202
|
-
declare function defineStorage<T extends Storage>(config: (ctx: Context) => T): () => T;
|
|
203
|
-
|
|
204
|
-
declare const index_Browser: typeof Browser;
|
|
205
|
-
declare const index_Extension: typeof Extension;
|
|
206
|
-
declare const index_Memory: typeof Memory;
|
|
207
|
-
type index_Storage = Storage;
|
|
208
|
-
declare const index_defineStorage: typeof defineStorage;
|
|
209
|
-
declare namespace index {
|
|
210
|
-
export { index_Browser as Browser, index_Extension as Extension, index_Memory as Memory, type index_Storage as Storage, index_defineStorage as defineStorage };
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
export { type AssetStatus, type AssetType, ChainPatrolClient, ChainPatrolClientError, ChainPatrolClientErrorCodes, type ChainPatrolClientOptions, type DetectorAssetStatus, DomainParseError, type EventData, Events, Relay, index as Storage, ThreatDetector, type URLResult };
|
|
196
|
+
export { type AssetStatus, type AssetType, ChainPatrolClient, ChainPatrolClientError, ChainPatrolClientErrorCodes, type ChainPatrolClientOptions, type DetectorAssetStatus, DomainParseError, type EventData, Events, Relay, Storage, ThreatDetector, type URLResult };
|