@caido/sdk-workflow 0.40.0 → 0.40.1-beta.1

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido/sdk-workflow",
3
- "version": "0.40.0",
3
+ "version": "0.40.1-beta.1",
4
4
  "description": "Typing for the Caido Workflow SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "license": "MIT",
@@ -9,6 +9,6 @@
9
9
  "src/*"
10
10
  ],
11
11
  "dependencies": {
12
- "@caido/quickjs-types": "0.2.1"
12
+ "@caido/quickjs-types": "0.6.0"
13
13
  }
14
14
  }
package/src/index.d.ts CHANGED
@@ -1,5 +1,3 @@
1
- ///<reference path="types/common.d.ts" />
2
- ///<reference path="types/global.d.ts" />
3
- ///<reference path="types/runtime.d.ts" />
4
- ///<reference path="types/typing.d.ts" />
1
+ ///<reference path="./global.d.ts" />
2
+ ///<reference path="./typing.d.ts" />
5
3
  ///<reference types="@caido/quickjs-types" />
@@ -1,325 +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
- getCreatedAt(): Date;
44
- toSpec(): RequestSpec;
45
- toSpecRaw(): RequestSpecRaw;
46
- };
47
-
48
- export type SetBodyOptions = {
49
- /**
50
- * Should update the Content-export type header.
51
- *
52
- * @default true
53
- */
54
- updateContentLength: boolean;
55
- };
56
-
57
- /**
58
- * A mutable Request not yet sent.
59
- */
60
- export class RequestSpec {
61
- constructor(url: string);
62
- getHost(): string;
63
- setHost(host: string): void;
64
- getPort(): number;
65
- setPort(port: number): void;
66
- getTls(): boolean;
67
- setTls(tls: boolean): void;
68
- getMethod(): string;
69
- setMethod(method: string): void;
70
- getPath(): string;
71
- setPath(path: string): void;
72
- getQuery(): string;
73
- setQuery(query: string): void;
74
- getHeaders(): Record<string, Array<string>>;
75
- getHeader(name: string): Array<string> | undefined;
76
- setHeader(name: string, value: string): void;
77
- removeHeader(name: string): void;
78
- getBody(): Body | undefined;
79
- setBody(body: Body | Bytes, options?: SetBodyOptions): void;
80
- setRaw(raw: Bytes): RequestSpecRaw;
81
- }
82
-
83
- /**
84
- * A mutable raw Request not yet sent.
85
- */
86
- export class RequestSpecRaw {
87
- constructor(url: string);
88
- getHost(): string;
89
- setHost(host: string): void;
90
- getPort(): number;
91
- setPort(port: number): void;
92
- getTls(): boolean;
93
- setTls(tls: boolean): void;
94
- getRaw(): Uint8Array;
95
- setRaw(raw: Bytes): void;
96
- }
97
-
98
- /**
99
- * An immutable saved Response.
100
- */
101
- export type Response = {
102
- getId(): ID;
103
- getCode(): number;
104
- getHeaders(): Record<string, Array<string>>;
105
- getHeader(name: string): Array<string> | undefined;
106
- getBody(): Body | undefined;
107
- getRoundtripTime(): number;
108
- getCreatedAt(): Date;
109
- };
110
-
111
- /**
112
- * An immutable saved Request and Response pair.
113
- */
114
- export type RequestResponse = {
115
- request: Request;
116
- response: Response;
117
- };
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
-
209
- /**
210
- * The SDK for the Requests service.
211
- */
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;
221
- /**
222
- * Sends a request.
223
- *
224
- * This respects the upstream proxy settings.
225
- *
226
- * @throws {Error} If the request cannot be sent.
227
- *
228
- * @example
229
- * const spec = new RequestSpec("https://example.com");
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
- * }
237
- */
238
- send(request: RequestSpec | RequestSpecRaw): Promise<RequestResponse>;
239
-
240
- /**
241
- * Checks if a request is in scope.
242
- *
243
- * @example
244
- * if (sdk.requests.inScope(request)) {
245
- * sdk.console.log("In scope");
246
- * }
247
- */
248
- inScope(request: Request | RequestSpec): boolean;
249
- };
250
-
251
- /**
252
- * A saved immutable Finding.
253
- */
254
- export type Finding = {
255
- /**
256
- * The unique Caido {@link ID} of the finding.
257
- */
258
- getId(): ID;
259
- /**
260
- * The title of the finding.
261
- */
262
- getTitle(): string;
263
- /**
264
- * The description of the finding.
265
- */
266
- getDescription(): string | undefined;
267
- /**
268
- * The name of the reporter.
269
- */
270
- getReporter(): string;
271
- };
272
-
273
- /**
274
- * A mutable Finding not yet created.
275
- */
276
- export type FindingSpec = {
277
- /**
278
- * The title of the finding.
279
- */
280
- title: string;
281
- /**
282
- * The description of the finding.
283
- */
284
- description?: string | undefined;
285
- /**
286
- * The name of the reporter.
287
- * It will be used to group findings.
288
- */
289
- reporter: string;
290
- /**
291
- * Deduplication key for findings.
292
- * If a finding with the same dedupe key already exists, it will not be created.
293
- */
294
- dedupeKey?: string | undefined;
295
- /**
296
- * The associated {@link Request}.
297
- */
298
- request: Request;
299
- };
300
-
301
- /**
302
- * The SDK for the Findings service.
303
- */
304
- export type FindingsSDK = {
305
- /**
306
- * Creates a new Finding.
307
- *
308
- * @throws {Error} If the request cannot be saved.
309
- *
310
- * @example
311
- * await sdk.findings.create({
312
- * title: "Title",
313
- * description: "Description",
314
- * reporter: "Reporter",
315
- * dedupe: `${request.getHost()}-${request.getPath()}`,
316
- * request,
317
- * });
318
- */
319
- create(spec: FindingSpec): Promise<Finding>;
320
- };
321
-
322
- export type ID = string;
323
- export type Bytes = string | Array<number> | Uint8Array;
324
- export type MaybePromise<T> = T | Promise<T>;
325
- }
@@ -1,3 +0,0 @@
1
- export {};
2
-
3
- declare global {}
File without changes
File without changes