@caido/sdk-workflow 0.38.0 → 0.39.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 +1 -1
- package/src/index.d.ts +4 -1
- package/src/types/common.d.ts +225 -0
- package/src/types/global.d.ts +55 -0
- package/src/types/runtime.d.ts +148 -0
- package/src/types/typing.d.ts +52 -0
- package/src/typing.d.ts +0 -249
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -0,0 +1,225 @@
|
|
|
1
|
+
declare module "caido:utils" {
|
|
2
|
+
/**
|
|
3
|
+
* The body of a Request or Response.
|
|
4
|
+
*
|
|
5
|
+
* Calling `to<FORMAT>` will try to convert the body to the desired format.
|
|
6
|
+
*/
|
|
7
|
+
export class Body {
|
|
8
|
+
constructor(data: string | Array<number> | Uint8Array);
|
|
9
|
+
/**
|
|
10
|
+
* Parse the body as a string.
|
|
11
|
+
*
|
|
12
|
+
* Unprintable characters will be replaced with `�`.
|
|
13
|
+
*/
|
|
14
|
+
toText(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Try to parse the body as JSON.
|
|
17
|
+
*
|
|
18
|
+
* @throws {SyntaxError} If the body is not valid JSON.
|
|
19
|
+
*/
|
|
20
|
+
toJson(): any;
|
|
21
|
+
/**
|
|
22
|
+
* Get the raw body as an array of bytes.
|
|
23
|
+
*/
|
|
24
|
+
toRaw(): Uint8Array;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* A saved immutable Request.
|
|
29
|
+
*
|
|
30
|
+
* To modify, use `toSpec` to get a `RequestSpec` object.
|
|
31
|
+
*/
|
|
32
|
+
export type Request = {
|
|
33
|
+
getId(): ID;
|
|
34
|
+
getHost(): string;
|
|
35
|
+
getPort(): number;
|
|
36
|
+
getTls(): boolean;
|
|
37
|
+
getMethod(): string;
|
|
38
|
+
getPath(): string;
|
|
39
|
+
getQuery(): string;
|
|
40
|
+
getHeaders(): Record<string, Array<string>>;
|
|
41
|
+
getHeader(name: string): Array<string> | undefined;
|
|
42
|
+
getBody(): Body | undefined;
|
|
43
|
+
toSpec(): RequestSpec;
|
|
44
|
+
toSpecRaw(): RequestSpecRaw;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export type SetBodyOptions = {
|
|
48
|
+
/**
|
|
49
|
+
* Should update the Content-export type header.
|
|
50
|
+
*
|
|
51
|
+
* @default true
|
|
52
|
+
*/
|
|
53
|
+
updateContentLength: boolean;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A mutable Request not yet sent.
|
|
58
|
+
*/
|
|
59
|
+
export class RequestSpec {
|
|
60
|
+
constructor(url: string);
|
|
61
|
+
getHost(): string;
|
|
62
|
+
setHost(host: string): void;
|
|
63
|
+
getPort(): number;
|
|
64
|
+
setPort(port: number): void;
|
|
65
|
+
getTls(): boolean;
|
|
66
|
+
setTls(tls: boolean): void;
|
|
67
|
+
getMethod(): string;
|
|
68
|
+
setMethod(method: string): void;
|
|
69
|
+
getPath(): string;
|
|
70
|
+
setPath(path: string): void;
|
|
71
|
+
getQuery(): string;
|
|
72
|
+
setQuery(query: string): void;
|
|
73
|
+
getHeaders(): Record<string, Array<string>>;
|
|
74
|
+
getHeader(name: string): Array<string> | undefined;
|
|
75
|
+
setHeader(name: string, value: string): void;
|
|
76
|
+
removeHeader(name: string): void;
|
|
77
|
+
getBody(): Body | undefined;
|
|
78
|
+
setBody(body: Body | Bytes, options?: SetBodyOptions): void;
|
|
79
|
+
setRaw(raw: Bytes): RequestSpecRaw;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* A mutable raw Request not yet sent.
|
|
84
|
+
*/
|
|
85
|
+
export class RequestSpecRaw {
|
|
86
|
+
constructor(url: string);
|
|
87
|
+
getHost(): string;
|
|
88
|
+
setHost(host: string): void;
|
|
89
|
+
getPort(): number;
|
|
90
|
+
setPort(port: number): void;
|
|
91
|
+
getTls(): boolean;
|
|
92
|
+
setTls(tls: boolean): void;
|
|
93
|
+
getRaw(): Uint8Array;
|
|
94
|
+
setRaw(raw: Bytes): void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* An immutable saved Response.
|
|
99
|
+
*/
|
|
100
|
+
export type Response = {
|
|
101
|
+
getId(): ID;
|
|
102
|
+
getCode(): number;
|
|
103
|
+
getHeaders(): Record<string, Array<string>>;
|
|
104
|
+
getHeader(name: string): Array<string> | undefined;
|
|
105
|
+
getBody(): Body | undefined;
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* An immutable saved Request and Response pair.
|
|
110
|
+
*/
|
|
111
|
+
export type RequestResponse = {
|
|
112
|
+
request: Request;
|
|
113
|
+
response: Response;
|
|
114
|
+
};
|
|
115
|
+
|
|
116
|
+
/**
|
|
117
|
+
* The SDK for the Requests service.
|
|
118
|
+
*/
|
|
119
|
+
export type RequestsSDK = {
|
|
120
|
+
/**
|
|
121
|
+
* Sends a request.
|
|
122
|
+
*
|
|
123
|
+
* This respects the upstream proxy settings.
|
|
124
|
+
*
|
|
125
|
+
* @throws {Error} If the request cannot be sent.
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* const spec = new RequestSpec("https://example.com");
|
|
129
|
+
* sdk.requests.send(request)
|
|
130
|
+
* .then((res) => {
|
|
131
|
+
* console.log(res.request.getId());
|
|
132
|
+
* console.log(res.response.getCode());
|
|
133
|
+
* })
|
|
134
|
+
* .catch((err) => {
|
|
135
|
+
* console.error(err);
|
|
136
|
+
* });
|
|
137
|
+
*/
|
|
138
|
+
send(request: RequestSpec | RequestSpecRaw): Promise<RequestResponse>;
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Checks if a request is in scope.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* if (sdk.requests.inScope(request)) {
|
|
145
|
+
* console.log("In scope");
|
|
146
|
+
* }
|
|
147
|
+
*/
|
|
148
|
+
inScope(request: Request | RequestSpec): boolean;
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* A saved immutable Finding.
|
|
153
|
+
*/
|
|
154
|
+
export type Finding = {
|
|
155
|
+
/**
|
|
156
|
+
* The unique Caido {@link ID} of the finding.
|
|
157
|
+
*/
|
|
158
|
+
getId(): ID;
|
|
159
|
+
/**
|
|
160
|
+
* The title of the finding.
|
|
161
|
+
*/
|
|
162
|
+
getTitle(): string;
|
|
163
|
+
/**
|
|
164
|
+
* The description of the finding.
|
|
165
|
+
*/
|
|
166
|
+
getDescription(): string | undefined;
|
|
167
|
+
/**
|
|
168
|
+
* The name of the reporter.
|
|
169
|
+
*/
|
|
170
|
+
getReporter(): string;
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
/**
|
|
174
|
+
* A mutable Finding not yet created.
|
|
175
|
+
*/
|
|
176
|
+
export type FindingSpec = {
|
|
177
|
+
/**
|
|
178
|
+
* The title of the finding.
|
|
179
|
+
*/
|
|
180
|
+
title: string;
|
|
181
|
+
/**
|
|
182
|
+
* The description of the finding.
|
|
183
|
+
*/
|
|
184
|
+
description?: string | undefined;
|
|
185
|
+
/**
|
|
186
|
+
* The name of the reporter.
|
|
187
|
+
* It will be used to group findings.
|
|
188
|
+
*/
|
|
189
|
+
reporter: string;
|
|
190
|
+
/**
|
|
191
|
+
* Deduplication key for findings.
|
|
192
|
+
* If a finding with the same dedupe key already exists, it will not be created.
|
|
193
|
+
*/
|
|
194
|
+
dedupeKey?: string | undefined;
|
|
195
|
+
/**
|
|
196
|
+
* The associated {@link Request}.
|
|
197
|
+
*/
|
|
198
|
+
request: Request;
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The SDK for the Findings service.
|
|
203
|
+
*/
|
|
204
|
+
export type FindingsSDK = {
|
|
205
|
+
/**
|
|
206
|
+
* Creates a new Finding.
|
|
207
|
+
*
|
|
208
|
+
* @throws {Error} If the request cannot be saved.
|
|
209
|
+
*
|
|
210
|
+
* @example
|
|
211
|
+
* sdk.findings.create({
|
|
212
|
+
* title: "Title",
|
|
213
|
+
* description: "Description",
|
|
214
|
+
* reporter: "Reporter",
|
|
215
|
+
* dedupe: `${request.getHost()}-${request.getPath()}`,
|
|
216
|
+
* request,
|
|
217
|
+
* });
|
|
218
|
+
*/
|
|
219
|
+
create(spec: FindingSpec): Promise<Finding>;
|
|
220
|
+
};
|
|
221
|
+
|
|
222
|
+
export type ID = string;
|
|
223
|
+
export type Bytes = string | Array<number> | Uint8Array;
|
|
224
|
+
export type MaybePromise<T> = T | Promise<T>;
|
|
225
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Body as _Body,
|
|
3
|
+
Bytes as _Bytes,
|
|
4
|
+
Finding as _Finding,
|
|
5
|
+
FindingSpec as _FindingSpec,
|
|
6
|
+
FindingsSDK as _FindingsSDK,
|
|
7
|
+
ID as _ID,
|
|
8
|
+
MaybePromise as _MaybePromise,
|
|
9
|
+
Request as _Request,
|
|
10
|
+
RequestResponse as _RequestResponse,
|
|
11
|
+
RequestSpec as _RequestSpec,
|
|
12
|
+
RequestSpecRaw as _RequestSpecRaw,
|
|
13
|
+
RequestsSDK as _RequestsSDK,
|
|
14
|
+
Response as _Response,
|
|
15
|
+
} from "caido:utils";
|
|
16
|
+
|
|
17
|
+
import {
|
|
18
|
+
HttpInput as _HttpInput,
|
|
19
|
+
PassiveInput as _PassiveInput,
|
|
20
|
+
BytesInput as _BytesInput,
|
|
21
|
+
ConvertInput as _ConvertInput,
|
|
22
|
+
Data as _Data,
|
|
23
|
+
Decision as _Decision,
|
|
24
|
+
SDK as _SDK,
|
|
25
|
+
} from "caido:workflow";
|
|
26
|
+
|
|
27
|
+
declare global {
|
|
28
|
+
//@ts-ignore TS2666
|
|
29
|
+
export {
|
|
30
|
+
_Body as Body,
|
|
31
|
+
_Request as Request,
|
|
32
|
+
_RequestSpec as RequestSpec,
|
|
33
|
+
_RequestSpecRaw as RequestSpecRaw,
|
|
34
|
+
_Response as Response,
|
|
35
|
+
_RequestResponse as RequestResponse,
|
|
36
|
+
_Finding as Finding,
|
|
37
|
+
_FindingSpec as FindingSpec,
|
|
38
|
+
_ID as ID,
|
|
39
|
+
_Bytes as Bytes,
|
|
40
|
+
_MaybePromise as MaybePromise,
|
|
41
|
+
_RequestsSDK as RequestsSDK,
|
|
42
|
+
_FindingsSDK as FindingsSDK,
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
//@ts-ignore TS2666
|
|
46
|
+
export {
|
|
47
|
+
_HttpInput as HttpInput,
|
|
48
|
+
_PassiveInput as PassiveInput,
|
|
49
|
+
_BytesInput as BytesInput,
|
|
50
|
+
_ConvertInput as ConvertInput,
|
|
51
|
+
_Data as Data,
|
|
52
|
+
_Decision as Decision,
|
|
53
|
+
_SDK as SDK,
|
|
54
|
+
};
|
|
55
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
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
|
+
export {};
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
declare module "caido:workflow" {
|
|
2
|
+
import {
|
|
3
|
+
Bytes,
|
|
4
|
+
FindingsSDK,
|
|
5
|
+
RequestsSDK,
|
|
6
|
+
Request,
|
|
7
|
+
Response,
|
|
8
|
+
} from "caido:utils";
|
|
9
|
+
|
|
10
|
+
export type HttpInput = {
|
|
11
|
+
request: Request | undefined;
|
|
12
|
+
response: Response | undefined;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* @deprecated Use HttpInput instead.
|
|
16
|
+
*/
|
|
17
|
+
export type PassiveInput = HttpInput;
|
|
18
|
+
export type BytesInput = Array<number>;
|
|
19
|
+
/**
|
|
20
|
+
* @deprecated Use BytesInput instead.
|
|
21
|
+
*/
|
|
22
|
+
export type ConvertInput = BytesInput;
|
|
23
|
+
|
|
24
|
+
export type Data = Bytes;
|
|
25
|
+
export type Decision = boolean;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* The SDK object available to all scripts.
|
|
29
|
+
*/
|
|
30
|
+
export type SDK = {
|
|
31
|
+
/**
|
|
32
|
+
* The console.
|
|
33
|
+
*
|
|
34
|
+
* This is currently the same as the global `console`.
|
|
35
|
+
*/
|
|
36
|
+
console: Console;
|
|
37
|
+
/**
|
|
38
|
+
* The SDK for the Findings service.
|
|
39
|
+
*/
|
|
40
|
+
findings: FindingsSDK;
|
|
41
|
+
/**
|
|
42
|
+
* The SDK for the Requests services
|
|
43
|
+
*/
|
|
44
|
+
requests: RequestsSDK;
|
|
45
|
+
/**
|
|
46
|
+
* Converts bytes to a string.
|
|
47
|
+
*
|
|
48
|
+
* Unprintable characters will be replaced with `�`.
|
|
49
|
+
*/
|
|
50
|
+
asString(array: Bytes): string;
|
|
51
|
+
};
|
|
52
|
+
}
|
package/src/typing.d.ts
DELETED
|
@@ -1,249 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Console interface for logging.
|
|
3
|
-
*
|
|
4
|
-
* Currently logs are only available in the backend logs.
|
|
5
|
-
* See https://docs.caido.io/report_bug.html#1-backend-logs
|
|
6
|
-
*/
|
|
7
|
-
export declare type Console = {
|
|
8
|
-
debug(message: any): void;
|
|
9
|
-
log(message: any): void;
|
|
10
|
-
warn(message: any): void;
|
|
11
|
-
error(message: any): void;
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* The body of a Request or Response.
|
|
16
|
-
*
|
|
17
|
-
* Calling `to<FORMAT>` will try to convert the body to the desired format.
|
|
18
|
-
*/
|
|
19
|
-
export declare class Body {
|
|
20
|
-
constructor(data: string | Array<number> | Uint8Array);
|
|
21
|
-
/**
|
|
22
|
-
* Parse the body as a string.
|
|
23
|
-
*
|
|
24
|
-
* Unprintable characters will be replaced with `�`.
|
|
25
|
-
*/
|
|
26
|
-
toText(): string;
|
|
27
|
-
/**
|
|
28
|
-
* Try to parse the body as JSON.
|
|
29
|
-
*
|
|
30
|
-
* @throws {SyntaxError} If the body is not valid JSON.
|
|
31
|
-
*/
|
|
32
|
-
toJson(): any;
|
|
33
|
-
/**
|
|
34
|
-
* Get the raw body as an array of bytes.
|
|
35
|
-
*/
|
|
36
|
-
toRaw(): Uint8Array;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* A saved immutable Request.
|
|
41
|
-
*
|
|
42
|
-
* To modify, use `toSpec` to get a `RequestSpec` object.
|
|
43
|
-
*/
|
|
44
|
-
export declare type Request = {
|
|
45
|
-
getId(): ID;
|
|
46
|
-
getHost(): string;
|
|
47
|
-
getPort(): number;
|
|
48
|
-
getTls(): boolean;
|
|
49
|
-
getMethod(): string;
|
|
50
|
-
getPath(): string;
|
|
51
|
-
getQuery(): string;
|
|
52
|
-
getHeaders(): Record<string, Array<string>>;
|
|
53
|
-
getHeader(name: string): Array<string> | undefined;
|
|
54
|
-
getBody(): Body | undefined;
|
|
55
|
-
toSpec(): RequestSpec;
|
|
56
|
-
toSpecRaw(): RequestSpecRaw;
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
type SetBodyOptions = {
|
|
60
|
-
/**
|
|
61
|
-
* Should update the Content-Type header.
|
|
62
|
-
*
|
|
63
|
-
* @default true
|
|
64
|
-
*/
|
|
65
|
-
updateContentLength: boolean;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
/**
|
|
69
|
-
* A mutable Request not yet sent.
|
|
70
|
-
*/
|
|
71
|
-
export declare class RequestSpec {
|
|
72
|
-
constructor(url: string);
|
|
73
|
-
getHost(): string;
|
|
74
|
-
setHost(host: string): void;
|
|
75
|
-
getPort(): number;
|
|
76
|
-
setPort(port: number): void;
|
|
77
|
-
getTls(): boolean;
|
|
78
|
-
setTls(tls: boolean): void;
|
|
79
|
-
getMethod(): string;
|
|
80
|
-
setMethod(method: string): void;
|
|
81
|
-
getPath(): string;
|
|
82
|
-
setPath(path: string): void;
|
|
83
|
-
getQuery(): string;
|
|
84
|
-
setQuery(query: string): void;
|
|
85
|
-
getHeaders(): Record<string, Array<string>>;
|
|
86
|
-
getHeader(name: string): Array<string> | undefined;
|
|
87
|
-
setHeader(name: string, value: string): void;
|
|
88
|
-
removeHeader(name: string): void;
|
|
89
|
-
getBody(): Body | undefined;
|
|
90
|
-
setBody(body: Body | Bytes, options?: SetBodyOptions): void;
|
|
91
|
-
setRaw(raw: Bytes): RequestSpecRaw;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
/**
|
|
95
|
-
* A mutable raw Request not yet sent.
|
|
96
|
-
*/
|
|
97
|
-
export declare class RequestSpecRaw {
|
|
98
|
-
constructor(url: string);
|
|
99
|
-
getHost(): string;
|
|
100
|
-
setHost(host: string): void;
|
|
101
|
-
getPort(): number;
|
|
102
|
-
setPort(port: number): void;
|
|
103
|
-
getTls(): boolean;
|
|
104
|
-
setTls(tls: boolean): void;
|
|
105
|
-
getRaw(): Uint8Array;
|
|
106
|
-
setRaw(raw: Bytes): void;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
/**
|
|
110
|
-
* An immutable saved Response.
|
|
111
|
-
*/
|
|
112
|
-
export declare type Response = {
|
|
113
|
-
getId(): ID;
|
|
114
|
-
getCode(): number;
|
|
115
|
-
getHeaders(): Record<string, Array<string>>;
|
|
116
|
-
getHeader(name: string): Array<string> | undefined;
|
|
117
|
-
getBody(): Body | undefined;
|
|
118
|
-
};
|
|
119
|
-
|
|
120
|
-
/**
|
|
121
|
-
* An immutable saved Request and Response pair.
|
|
122
|
-
*/
|
|
123
|
-
export declare type RequestResponse = {
|
|
124
|
-
request: Request;
|
|
125
|
-
response: Response;
|
|
126
|
-
};
|
|
127
|
-
|
|
128
|
-
/**
|
|
129
|
-
* The SDK for the Requests service.
|
|
130
|
-
*/
|
|
131
|
-
export declare type RequestsSDK = {
|
|
132
|
-
/**
|
|
133
|
-
* Sends a request.
|
|
134
|
-
*
|
|
135
|
-
* This respects the upstream proxy settings.
|
|
136
|
-
*
|
|
137
|
-
* @throws {Error} If the request cannot be sent.
|
|
138
|
-
*
|
|
139
|
-
* @example
|
|
140
|
-
* const spec = new RequestSpec("https://example.com");
|
|
141
|
-
* sdk.requests.send(request)
|
|
142
|
-
* .then((res) => {
|
|
143
|
-
* console.log(res.request.getId());
|
|
144
|
-
* console.log(res.response.getCode());
|
|
145
|
-
* })
|
|
146
|
-
* .catch((err) => {
|
|
147
|
-
* console.error(err);
|
|
148
|
-
* });
|
|
149
|
-
*/
|
|
150
|
-
send(request: RequestSpec | RequestSpecRaw): Promise<RequestResponse>;
|
|
151
|
-
|
|
152
|
-
/**
|
|
153
|
-
* Checks if a request is in scope.
|
|
154
|
-
*
|
|
155
|
-
* @example
|
|
156
|
-
* if (sdk.requests.inScope(request)) {
|
|
157
|
-
* console.log("In scope");
|
|
158
|
-
* }
|
|
159
|
-
*/
|
|
160
|
-
inScope(request: Request | RequestSpec): boolean;
|
|
161
|
-
};
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* A saved immutable Finding.
|
|
165
|
-
*
|
|
166
|
-
* To modify, use `toSpec` to get a `FindingSpec` object.
|
|
167
|
-
*/
|
|
168
|
-
export declare type Finding = {
|
|
169
|
-
getId(): ID;
|
|
170
|
-
getTitle(): string;
|
|
171
|
-
getDescription(): string | undefined;
|
|
172
|
-
getReporter(): string;
|
|
173
|
-
};
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* A mutable Finding not yet created.
|
|
177
|
-
*/
|
|
178
|
-
export declare type FindingSpec = {
|
|
179
|
-
title: string;
|
|
180
|
-
description?: string | undefined;
|
|
181
|
-
reporter: string;
|
|
182
|
-
request: Request;
|
|
183
|
-
};
|
|
184
|
-
|
|
185
|
-
/**
|
|
186
|
-
* The SDK for the Findings service.
|
|
187
|
-
*/
|
|
188
|
-
export declare type FindingsSDK = {
|
|
189
|
-
/**
|
|
190
|
-
* Creates a new Finding.
|
|
191
|
-
*
|
|
192
|
-
* @throws {Error} If the request cannot be saved.
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* sdk.findings.create({
|
|
196
|
-
* title: "Title",
|
|
197
|
-
* description: "Description",
|
|
198
|
-
* reporter: "Reporter",
|
|
199
|
-
* request,
|
|
200
|
-
* });
|
|
201
|
-
*/
|
|
202
|
-
create(spec: FindingSpec): Promise<Finding>;
|
|
203
|
-
};
|
|
204
|
-
|
|
205
|
-
export declare type HttpInput = {
|
|
206
|
-
request: Request | undefined;
|
|
207
|
-
response: Response | undefined;
|
|
208
|
-
};
|
|
209
|
-
/**
|
|
210
|
-
* @deprecated Use HttpInput instead.
|
|
211
|
-
*/
|
|
212
|
-
export declare type PassiveInput = HttpInput;
|
|
213
|
-
export declare type BytesInput = Array<number>;
|
|
214
|
-
/**
|
|
215
|
-
* @deprecated Use BytesInput instead.
|
|
216
|
-
*/
|
|
217
|
-
export declare type ConvertInput = BytesInput;
|
|
218
|
-
|
|
219
|
-
export declare type ID = string;
|
|
220
|
-
export declare type Data = Bytes;
|
|
221
|
-
export declare type Decision = boolean;
|
|
222
|
-
export declare type Bytes = string | Array<number> | Uint8Array;
|
|
223
|
-
export declare type MaybePromise<T> = T | Promise<T>;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* The SDK object available to all scripts.
|
|
227
|
-
*/
|
|
228
|
-
export declare type SDK = {
|
|
229
|
-
/**
|
|
230
|
-
* The console.
|
|
231
|
-
*
|
|
232
|
-
* This is currently the same as the global `console`.
|
|
233
|
-
*/
|
|
234
|
-
console: Console;
|
|
235
|
-
/**
|
|
236
|
-
* The SDK for the Findings service.
|
|
237
|
-
*/
|
|
238
|
-
findings: FindingsSDK;
|
|
239
|
-
/**
|
|
240
|
-
* The SDK for the Requests services
|
|
241
|
-
*/
|
|
242
|
-
requests: RequestsSDK;
|
|
243
|
-
/**
|
|
244
|
-
* Converts bytes to a string.
|
|
245
|
-
*
|
|
246
|
-
* Unprintable characters will be replaced with `�`.
|
|
247
|
-
*/
|
|
248
|
-
asString(array: Bytes): string;
|
|
249
|
-
};
|