@caido/sdk-backend 0.1.6 → 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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido/sdk-backend",
3
- "version": "0.1.6",
3
+ "version": "0.39.0",
4
4
  "description": "Typing for the Caido Backend SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "license": "MIT",
@@ -150,13 +150,23 @@ declare module "caido:utils" {
150
150
 
151
151
  /**
152
152
  * A saved immutable Finding.
153
- *
154
- * To modify, use `toSpec` to get a `FindingSpec` object.
155
153
  */
156
154
  export type Finding = {
155
+ /**
156
+ * The unique Caido {@link ID} of the finding.
157
+ */
157
158
  getId(): ID;
159
+ /**
160
+ * The title of the finding.
161
+ */
158
162
  getTitle(): string;
163
+ /**
164
+ * The description of the finding.
165
+ */
159
166
  getDescription(): string | undefined;
167
+ /**
168
+ * The name of the reporter.
169
+ */
160
170
  getReporter(): string;
161
171
  };
162
172
 
@@ -164,9 +174,27 @@ declare module "caido:utils" {
164
174
  * A mutable Finding not yet created.
165
175
  */
166
176
  export type FindingSpec = {
177
+ /**
178
+ * The title of the finding.
179
+ */
167
180
  title: string;
181
+ /**
182
+ * The description of the finding.
183
+ */
168
184
  description?: string | undefined;
185
+ /**
186
+ * The name of the reporter.
187
+ * It will be used to group findings.
188
+ */
169
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
+ */
170
198
  request: Request;
171
199
  };
172
200
 
@@ -184,6 +212,7 @@ declare module "caido:utils" {
184
212
  * title: "Title",
185
213
  * description: "Description",
186
214
  * reporter: "Reporter",
215
+ * dedupe: `${request.getHost()}-${request.getPath()}`,
187
216
  * request,
188
217
  * });
189
218
  */
@@ -1,5 +1,11 @@
1
1
  declare module "caido:plugin" {
2
- import { MaybePromise, FindingsSDK, RequestsSDK } from "caido:utils";
2
+ import {
3
+ MaybePromise,
4
+ FindingsSDK,
5
+ RequestsSDK,
6
+ Request,
7
+ Response,
8
+ } from "caido:utils";
3
9
 
4
10
  export type DefineAPI<
5
11
  API extends Record<string, (...args: any[]) => MaybePromise<any>>,
@@ -22,7 +28,7 @@ declare module "caido:plugin" {
22
28
  * Registers a new backend function for the RPC.
23
29
  *
24
30
  * @example
25
- * sdk.api.register("multiply", (a: number, b: number) => {
31
+ * sdk.api.register("multiply", (sdk: SDK, a: number, b: number) => {
26
32
  * return a * b;
27
33
  * });
28
34
  */
@@ -32,6 +38,43 @@ declare module "caido:plugin" {
32
38
  ): void;
33
39
  };
34
40
 
41
+ /**
42
+ * The SDK for the API RPC service.
43
+ */
44
+ export type EventsSDK = {
45
+ /**
46
+ * Registers an callback on new intercepted requests.
47
+ *
48
+ * This callback is called asynchronously and cannot modify requests.
49
+ *
50
+ * @example
51
+ * sdk.events.onInterceptRequest((sdk: SDK, request: Request) => {
52
+ * // Do something with the request
53
+ * });
54
+ */
55
+ onInterceptRequest(
56
+ callback: (sdk: SDK, request: Request) => MaybePromise<void>,
57
+ ): void;
58
+
59
+ /**
60
+ * Registers an callback on new intercepted responses.
61
+ *
62
+ * This callback is called asynchronously and cannot modify responses.
63
+ *
64
+ * @example
65
+ * sdk.events.onInterceptResponse((sdk: SDK, request: Request, response: Response) => {
66
+ * // Do something with the request/response
67
+ * });
68
+ */
69
+ onInterceptResponse(
70
+ callback: (
71
+ sdk: SDK,
72
+ request: Request,
73
+ response: Response,
74
+ ) => MaybePromise<void>,
75
+ ): void;
76
+ };
77
+
35
78
  /**
36
79
  * The SDK object available to all scripts.
37
80
  */
@@ -54,5 +97,9 @@ declare module "caido:plugin" {
54
97
  * The SDK for the API RPC service.
55
98
  */
56
99
  api: APISDK;
100
+ /**
101
+ * The SDK for the Events service.
102
+ */
103
+ events: EventsSDK;
57
104
  };
58
105
  }