@caido/sdk-workflow 0.39.0 → 0.40.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/package.json +5 -2
- package/src/index.d.ts +1 -0
- package/src/types/common.d.ts +110 -10
- package/src/types/runtime.d.ts +2 -147
package/package.json
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caido/sdk-workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.0",
|
|
4
4
|
"description": "Typing for the Caido Workflow SDK",
|
|
5
5
|
"author": "Caido Labs Inc. <dev@caido.io>",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"types": "./src/index.d.ts",
|
|
8
8
|
"files": [
|
|
9
9
|
"src/*"
|
|
10
|
-
]
|
|
10
|
+
],
|
|
11
|
+
"dependencies": {
|
|
12
|
+
"@caido/quickjs-types": "0.2.1"
|
|
13
|
+
}
|
|
11
14
|
}
|
package/src/index.d.ts
CHANGED
package/src/types/common.d.ts
CHANGED
|
@@ -40,6 +40,7 @@ declare module "caido:utils" {
|
|
|
40
40
|
getHeaders(): Record<string, Array<string>>;
|
|
41
41
|
getHeader(name: string): Array<string> | undefined;
|
|
42
42
|
getBody(): Body | undefined;
|
|
43
|
+
getCreatedAt(): Date;
|
|
43
44
|
toSpec(): RequestSpec;
|
|
44
45
|
toSpecRaw(): RequestSpecRaw;
|
|
45
46
|
};
|
|
@@ -103,6 +104,8 @@ declare module "caido:utils" {
|
|
|
103
104
|
getHeaders(): Record<string, Array<string>>;
|
|
104
105
|
getHeader(name: string): Array<string> | undefined;
|
|
105
106
|
getBody(): Body | undefined;
|
|
107
|
+
getRoundtripTime(): number;
|
|
108
|
+
getCreatedAt(): Date;
|
|
106
109
|
};
|
|
107
110
|
|
|
108
111
|
/**
|
|
@@ -113,10 +116,108 @@ declare module "caido:utils" {
|
|
|
113
116
|
response: Response;
|
|
114
117
|
};
|
|
115
118
|
|
|
119
|
+
/**
|
|
120
|
+
* Information on the current page of paginated data.
|
|
121
|
+
*/
|
|
122
|
+
export type PageInfo = {
|
|
123
|
+
hasNextPage: boolean;
|
|
124
|
+
hasPreviousPage: boolean;
|
|
125
|
+
startCursor: string;
|
|
126
|
+
endCursor: string;
|
|
127
|
+
};
|
|
128
|
+
|
|
129
|
+
export type RequestOrderField =
|
|
130
|
+
| "ext"
|
|
131
|
+
| "host"
|
|
132
|
+
| "id"
|
|
133
|
+
| "method"
|
|
134
|
+
| "path"
|
|
135
|
+
| "query"
|
|
136
|
+
| "created_at"
|
|
137
|
+
| "source";
|
|
138
|
+
export type ResponseOrderField = "length" | "roundtrip" | "code";
|
|
139
|
+
|
|
140
|
+
export type RequestsConnectionItem = {
|
|
141
|
+
cursor: string;
|
|
142
|
+
request: Request;
|
|
143
|
+
response?: Response;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
export type RequestsConnection = {
|
|
147
|
+
pageInfo: PageInfo;
|
|
148
|
+
items: Array<RequestsConnectionItem>;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Query builder to fetch requests.
|
|
153
|
+
*/
|
|
154
|
+
export type RequestsQuery = {
|
|
155
|
+
/**
|
|
156
|
+
* Requests after a given cursor.
|
|
157
|
+
* @param cursor Cursor of the request
|
|
158
|
+
*/
|
|
159
|
+
after(cursor: string): RequestsQuery;
|
|
160
|
+
|
|
161
|
+
/**
|
|
162
|
+
* Requests before a given cursor.
|
|
163
|
+
* @param cursor Cursor of the request
|
|
164
|
+
*/
|
|
165
|
+
before(cursor: string): RequestsQuery;
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* First n requests.
|
|
169
|
+
* @param n Number of requests to return
|
|
170
|
+
*/
|
|
171
|
+
first(n: number): RequestsQuery;
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* Last n requests.
|
|
175
|
+
* @param n Number of requests to return
|
|
176
|
+
*/
|
|
177
|
+
last(n: number): RequestsQuery;
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Filter requests.
|
|
181
|
+
* @param filter HTTPQL filter
|
|
182
|
+
*/
|
|
183
|
+
filter(filter: string): RequestsQuery;
|
|
184
|
+
|
|
185
|
+
/**
|
|
186
|
+
* Ascending ordering.
|
|
187
|
+
* @param target Target of the ordering: req or resp.
|
|
188
|
+
* @param field Field to order by.
|
|
189
|
+
*/
|
|
190
|
+
ascending(target: "req", field: RequestOrderField): RequestsQuery;
|
|
191
|
+
ascending(target: "resp", field: ResponseOrderField): RequestsQuery;
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Descending ordering.
|
|
195
|
+
* @param target Target of the ordering: req or resp.
|
|
196
|
+
* @param field Field to order by.
|
|
197
|
+
*/
|
|
198
|
+
descending(target: "req", field: RequestOrderField): RequestsQuery;
|
|
199
|
+
descending(target: "resp", field: ResponseOrderField): RequestsQuery;
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Execute the query.
|
|
203
|
+
*
|
|
204
|
+
* @throws {Error} If a query parameter is invalid or the query cannot be executed.
|
|
205
|
+
*/
|
|
206
|
+
execute(): Promise<RequestsConnection>;
|
|
207
|
+
};
|
|
208
|
+
|
|
116
209
|
/**
|
|
117
210
|
* The SDK for the Requests service.
|
|
118
211
|
*/
|
|
119
212
|
export type RequestsSDK = {
|
|
213
|
+
/**
|
|
214
|
+
* Query requests of the current project.
|
|
215
|
+
*
|
|
216
|
+
* @example
|
|
217
|
+
* const page = await sqk.requests.query().first(2).execute();
|
|
218
|
+
* sdk.console.log(`ID: ${page.items[1].request.getId()}`);
|
|
219
|
+
*/
|
|
220
|
+
query(): RequestsQuery;
|
|
120
221
|
/**
|
|
121
222
|
* Sends a request.
|
|
122
223
|
*
|
|
@@ -126,14 +227,13 @@ declare module "caido:utils" {
|
|
|
126
227
|
*
|
|
127
228
|
* @example
|
|
128
229
|
* const spec = new RequestSpec("https://example.com");
|
|
129
|
-
*
|
|
130
|
-
* .
|
|
131
|
-
*
|
|
132
|
-
*
|
|
133
|
-
*
|
|
134
|
-
* .
|
|
135
|
-
*
|
|
136
|
-
* });
|
|
230
|
+
* try {
|
|
231
|
+
* const res = await sdk.requests.send(request)
|
|
232
|
+
* sdk.console.log(res.request.getId());
|
|
233
|
+
* sdk.console.log(res.response.getCode());
|
|
234
|
+
* } catch (err) {
|
|
235
|
+
* sdk.console.error(err);
|
|
236
|
+
* }
|
|
137
237
|
*/
|
|
138
238
|
send(request: RequestSpec | RequestSpecRaw): Promise<RequestResponse>;
|
|
139
239
|
|
|
@@ -142,7 +242,7 @@ declare module "caido:utils" {
|
|
|
142
242
|
*
|
|
143
243
|
* @example
|
|
144
244
|
* if (sdk.requests.inScope(request)) {
|
|
145
|
-
* console.log("In scope");
|
|
245
|
+
* sdk.console.log("In scope");
|
|
146
246
|
* }
|
|
147
247
|
*/
|
|
148
248
|
inScope(request: Request | RequestSpec): boolean;
|
|
@@ -208,7 +308,7 @@ declare module "caido:utils" {
|
|
|
208
308
|
* @throws {Error} If the request cannot be saved.
|
|
209
309
|
*
|
|
210
310
|
* @example
|
|
211
|
-
* sdk.findings.create({
|
|
311
|
+
* await sdk.findings.create({
|
|
212
312
|
* title: "Title",
|
|
213
313
|
* description: "Description",
|
|
214
314
|
* reporter: "Reporter",
|
package/src/types/runtime.d.ts
CHANGED
|
@@ -1,148 +1,3 @@
|
|
|
1
|
-
declare global {
|
|
2
|
-
/**
|
|
3
|
-
* Console interface for logging.
|
|
4
|
-
*
|
|
5
|
-
* Currently logs are only available in the backend logs.
|
|
6
|
-
* See https://docs.caido.io/report_bug.html#1-backend-logs
|
|
7
|
-
*/
|
|
8
|
-
type Console = {
|
|
9
|
-
debug(message: any): void;
|
|
10
|
-
log(message: any): void;
|
|
11
|
-
warn(message: any): void;
|
|
12
|
-
error(message: any): void;
|
|
13
|
-
};
|
|
14
|
-
var console: Console;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* The URLSearchParams interface defines utility methods to work with the query string of a URL.
|
|
18
|
-
*/
|
|
19
|
-
class URLSearchParams implements Iterable<[string, string]> {
|
|
20
|
-
constructor(
|
|
21
|
-
init?:
|
|
22
|
-
| URLSearchParams
|
|
23
|
-
| string
|
|
24
|
-
| { readonly [name: string]: string }
|
|
25
|
-
| Iterable<readonly [name: string, value: string]>
|
|
26
|
-
| ReadonlyArray<readonly [name: string, value: string]>,
|
|
27
|
-
);
|
|
28
|
-
/**
|
|
29
|
-
* Append a new name-value pair to the query string.
|
|
30
|
-
*/
|
|
31
|
-
append(name: string, value: string): void;
|
|
32
|
-
/**
|
|
33
|
-
* If `value` is provided, removes all name-value pairs
|
|
34
|
-
* where name is `name` and value is `value`.
|
|
35
|
-
*
|
|
36
|
-
* If `value` is not provided, removes all name-value pairs whose name is `name`.
|
|
37
|
-
*/
|
|
38
|
-
delete(name: string, value?: string): void;
|
|
39
|
-
/**
|
|
40
|
-
* Returns an ES6 `Iterator` over each of the name-value pairs in the query.
|
|
41
|
-
* Each item of the iterator is a JavaScript `Array`. The first item of the `Array` is the `name`, the second item of the `Array` is the `value`.
|
|
42
|
-
*
|
|
43
|
-
* Alias for `urlSearchParams[@@iterator]()`.
|
|
44
|
-
*/
|
|
45
|
-
entries(): IterableIterator<[string, string]>;
|
|
46
|
-
/**
|
|
47
|
-
* Iterates over each name-value pair in the query and invokes the given function.
|
|
48
|
-
*
|
|
49
|
-
* ```js
|
|
50
|
-
* const myURL = new URL('https://example.org/?a=b&c=d');
|
|
51
|
-
* myURL.searchParams.forEach((value, name) => {
|
|
52
|
-
* console.log(name, value);
|
|
53
|
-
* });
|
|
54
|
-
* // Prints:
|
|
55
|
-
* // a b
|
|
56
|
-
* // c d
|
|
57
|
-
* ```
|
|
58
|
-
* @param fn Invoked for each name-value pair in the query
|
|
59
|
-
*/
|
|
60
|
-
forEach(fn: (value: string, name: string) => void): void;
|
|
61
|
-
/**
|
|
62
|
-
* Returns the value of the first name-value pair whose name is `name`. If there
|
|
63
|
-
* are no such pairs, `null` is returned.
|
|
64
|
-
* @return or `null` if there is no name-value pair with the given `name`.
|
|
65
|
-
*/
|
|
66
|
-
get(name: string): string | null;
|
|
67
|
-
/**
|
|
68
|
-
* Returns the values of all name-value pairs whose name is `name`. If there are
|
|
69
|
-
* no such pairs, an empty array is returned.
|
|
70
|
-
*/
|
|
71
|
-
getAll(name: string): string[];
|
|
72
|
-
/**
|
|
73
|
-
* Checks if the `URLSearchParams` object contains key-value pair(s) based on `name` and an optional `value` argument.
|
|
74
|
-
*
|
|
75
|
-
* If `value` is provided, returns `true` when name-value pair with
|
|
76
|
-
* same `name` and `value` exists.
|
|
77
|
-
*
|
|
78
|
-
* If `value` is not provided, returns `true` if there is at least one name-value
|
|
79
|
-
* pair whose name is `name`.
|
|
80
|
-
*/
|
|
81
|
-
has(name: string, value?: string): boolean;
|
|
82
|
-
/**
|
|
83
|
-
* Returns an ES6 `Iterator` over the names of each name-value pair.
|
|
84
|
-
*
|
|
85
|
-
* ```js
|
|
86
|
-
* const params = new URLSearchParams('foo=bar&foo=baz');
|
|
87
|
-
* for (const name of params.keys()) {
|
|
88
|
-
* console.log(name);
|
|
89
|
-
* }
|
|
90
|
-
* // Prints:
|
|
91
|
-
* // foo
|
|
92
|
-
* // foo
|
|
93
|
-
* ```
|
|
94
|
-
*/
|
|
95
|
-
keys(): IterableIterator<string>;
|
|
96
|
-
/**
|
|
97
|
-
* Sets the value in the `URLSearchParams` object associated with `name` to `value`. If there are any pre-existing name-value pairs whose names are `name`,
|
|
98
|
-
* set the first such pair's value to `value` and remove all others. If not,
|
|
99
|
-
* append the name-value pair to the query string.
|
|
100
|
-
*
|
|
101
|
-
* ```js
|
|
102
|
-
* const params = new URLSearchParams();
|
|
103
|
-
* params.append('foo', 'bar');
|
|
104
|
-
* params.append('foo', 'baz');
|
|
105
|
-
* params.append('abc', 'def');
|
|
106
|
-
* console.log(params.toString());
|
|
107
|
-
* // Prints foo=bar&foo=baz&abc=def
|
|
108
|
-
*
|
|
109
|
-
* params.set('foo', 'def');
|
|
110
|
-
* params.set('xyz', 'opq');
|
|
111
|
-
* console.log(params.toString());
|
|
112
|
-
* // Prints foo=def&abc=def&xyz=opq
|
|
113
|
-
* ```
|
|
114
|
-
*/
|
|
115
|
-
set(name: string, value: string): void;
|
|
116
|
-
/**
|
|
117
|
-
* The total number of parameter entries.
|
|
118
|
-
*/
|
|
119
|
-
readonly size: number;
|
|
120
|
-
/**
|
|
121
|
-
* Sort all existing name-value pairs in-place by their names. Sorting is done
|
|
122
|
-
* with a [stable sorting algorithm](https://en.wikipedia.org/wiki/Sorting_algorithm#Stability), so relative order between name-value pairs
|
|
123
|
-
* with the same name is preserved.
|
|
124
|
-
*
|
|
125
|
-
* This method can be used, in particular, to increase cache hits.
|
|
126
|
-
*
|
|
127
|
-
* ```js
|
|
128
|
-
* const params = new URLSearchParams('query[]=abc&type=search&query[]=123');
|
|
129
|
-
* params.sort();
|
|
130
|
-
* console.log(params.toString());
|
|
131
|
-
* // Prints query%5B%5D=abc&query%5B%5D=123&type=search
|
|
132
|
-
* ```
|
|
133
|
-
*/
|
|
134
|
-
sort(): void;
|
|
135
|
-
/**
|
|
136
|
-
* Returns the search parameters serialized as a string, with characters
|
|
137
|
-
* percent-encoded where necessary.
|
|
138
|
-
*/
|
|
139
|
-
toString(): string;
|
|
140
|
-
/**
|
|
141
|
-
* Returns an ES6 `Iterator` over the values of each name-value pair.
|
|
142
|
-
*/
|
|
143
|
-
values(): IterableIterator<string>;
|
|
144
|
-
[Symbol.iterator](): IterableIterator<[string, string]>;
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
|
|
148
1
|
export {};
|
|
2
|
+
|
|
3
|
+
declare global {}
|