@caido/sdk-workflow 0.39.0 → 0.40.1-beta.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
CHANGED
|
@@ -1,11 +1,14 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caido/sdk-workflow",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.40.1-beta.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.4.0"
|
|
13
|
+
}
|
|
11
14
|
}
|
package/src/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
///<reference path="
|
|
2
|
-
///<reference path="
|
|
3
|
-
///<reference
|
|
4
|
-
///<reference path="types/typing.d.ts" />
|
|
1
|
+
///<reference path="./global.d.ts" />
|
|
2
|
+
///<reference path="./typing.d.ts" />
|
|
3
|
+
///<reference types="@caido/quickjs-types" />
|
package/src/types/common.d.ts
DELETED
|
@@ -1,225 +0,0 @@
|
|
|
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
|
-
}
|
package/src/types/runtime.d.ts
DELETED
|
@@ -1,148 +0,0 @@
|
|
|
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 {};
|
|
File without changes
|
|
File without changes
|