@deepbounty/sdk 1.2.10 → 1.2.12
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 +15 -15
- package/dist/index.d.ts +39 -0
- package/dist/types/tasks.d.ts +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
# DeepBounty SDK
|
|
2
|
-
|
|
3
|
-
The official SDK for developing modules for the DeepBounty project.
|
|
4
|
-
|
|
5
|
-
## 📦 Installation
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
npm install @deepbounty/sdk
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
## 📤 Publish
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
npm publish --access public
|
|
15
|
-
```
|
|
1
|
+
# DeepBounty SDK
|
|
2
|
+
|
|
3
|
+
The official SDK for developing modules for the DeepBounty project.
|
|
4
|
+
|
|
5
|
+
## 📦 Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @deepbounty/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## 📤 Publish
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm publish --access public
|
|
15
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -4,6 +4,7 @@ export interface Logger {
|
|
|
4
4
|
info: (message: string) => void;
|
|
5
5
|
warn: (message: string) => void;
|
|
6
6
|
error: (message: string, error?: any) => void;
|
|
7
|
+
debug: (message: string) => void;
|
|
7
8
|
}
|
|
8
9
|
export interface ConfigAPI {
|
|
9
10
|
/** Get a configuration value by key
|
|
@@ -65,6 +66,24 @@ export interface StorageAPI {
|
|
|
65
66
|
changes: number | bigint;
|
|
66
67
|
lastInsertRowid: number | bigint;
|
|
67
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* Run a function inside a single database transaction (BEGIN/COMMIT, with
|
|
71
|
+
* automatic ROLLBACK if the function throws).
|
|
72
|
+
*
|
|
73
|
+
* Wrapping bulk work in one transaction is fast (thousands of
|
|
74
|
+
* inserts in tens of ms).
|
|
75
|
+
* @param fn The work to run inside the transaction
|
|
76
|
+
* @returns Whatever the function returns
|
|
77
|
+
*/
|
|
78
|
+
transaction<T>(fn: () => T): T;
|
|
79
|
+
/**
|
|
80
|
+
* Execute the same SQL statement for many parameter rows inside a single
|
|
81
|
+
* transaction. The statement is prepared once and reused for every row.
|
|
82
|
+
* Use this for bulk INSERT/UPDATE/DELETE instead of calling execute() in a loop.
|
|
83
|
+
* @param sql The SQL statement to execute for each row
|
|
84
|
+
* @param rows An array of parameter arrays, one per execution
|
|
85
|
+
*/
|
|
86
|
+
executeMany(sql: string, rows: any[][]): void;
|
|
68
87
|
/**
|
|
69
88
|
* Helper method to create a table if it doesn't exist
|
|
70
89
|
* @param tableName The name of the table to create
|
|
@@ -217,6 +236,20 @@ export interface TargetAPI {
|
|
|
217
236
|
*/
|
|
218
237
|
getTargetsForTask(taskTemplateId: number): Promise<Target[]>;
|
|
219
238
|
}
|
|
239
|
+
/**
|
|
240
|
+
* A synchronous scope checker bound to a snapshot of the current scope.
|
|
241
|
+
*
|
|
242
|
+
* Hot loops that process many hostnames (e.g. thousands of discovered subdomains)
|
|
243
|
+
* should call `api.getScopeChecker()` ONCE before the loop and then use these
|
|
244
|
+
* synchronous methods per item, instead of awaiting `api.isHostnameInScope()`
|
|
245
|
+
* per item.
|
|
246
|
+
*/
|
|
247
|
+
export interface ScopeChecker {
|
|
248
|
+
/** Whether the hostname is within scope of an active target. */
|
|
249
|
+
isInScope(hostname: string): boolean;
|
|
250
|
+
/** The owning target ID for the hostname, or null if none matches. */
|
|
251
|
+
detectTargetId(hostname: string): number | null;
|
|
252
|
+
}
|
|
220
253
|
export interface ServerAPI {
|
|
221
254
|
version: string;
|
|
222
255
|
logger: Logger;
|
|
@@ -228,6 +261,12 @@ export interface ServerAPI {
|
|
|
228
261
|
targets: TargetAPI;
|
|
229
262
|
/** Check if a hostname is in scope based on targets_subdomains */
|
|
230
263
|
isHostnameInScope(hostname: string): Promise<boolean>;
|
|
264
|
+
/**
|
|
265
|
+
* Get a synchronous scope checker bound to a snapshot of the current scope.
|
|
266
|
+
* Await this once before a hot loop, then call its methods synchronously per
|
|
267
|
+
* item instead of awaiting isHostnameInScope() per item.
|
|
268
|
+
*/
|
|
269
|
+
getScopeChecker(): Promise<ScopeChecker>;
|
|
231
270
|
/**
|
|
232
271
|
* Register a task template that can be scheduled for all targets
|
|
233
272
|
* @param uniqueKey Unique identifier for this task within the module (e.g., "subdomain-scan")
|
package/dist/types/tasks.d.ts
CHANGED
|
@@ -37,6 +37,8 @@ export interface TaskExecution {
|
|
|
37
37
|
workerId?: number;
|
|
38
38
|
status: "pending" | "running" | "completed" | "failed";
|
|
39
39
|
createdAt: Date;
|
|
40
|
+
startedAt?: Date;
|
|
41
|
+
completedAt?: Date;
|
|
40
42
|
content: TaskContent;
|
|
41
43
|
targetId?: number;
|
|
42
44
|
customData?: Record<string, any>;
|
|
@@ -48,6 +50,7 @@ export interface TaskResult {
|
|
|
48
50
|
output?: string;
|
|
49
51
|
error?: string;
|
|
50
52
|
targetId?: number;
|
|
53
|
+
durationMs?: number;
|
|
51
54
|
customData?: Record<string, any>;
|
|
52
55
|
}
|
|
53
56
|
export interface TargetTaskOverride {
|