@caido/sdk-backend 0.54.1 → 0.55.0-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 +2 -2
- package/src/typing.d.ts +50 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@caido/sdk-backend",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.55.0-beta.0",
|
|
4
4
|
"description": "Typing for the Caido Backend SDK",
|
|
5
5
|
"author": "Caido Labs Inc. <dev@caido.io>",
|
|
6
6
|
"repository": "https://github.com/caido/sdk-js/",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"src/*"
|
|
11
11
|
],
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@caido/quickjs-types": "^0.
|
|
13
|
+
"@caido/quickjs-types": "^0.25.0",
|
|
14
14
|
"@caido/sdk-shared": "^0.1.0"
|
|
15
15
|
},
|
|
16
16
|
"scripts": {
|
package/src/typing.d.ts
CHANGED
|
@@ -14,6 +14,10 @@ declare module "caido:plugin" {
|
|
|
14
14
|
ScopeSDK,
|
|
15
15
|
GraphQLSDK,
|
|
16
16
|
HostedFileSDK,
|
|
17
|
+
NetSDK,
|
|
18
|
+
RequestSpecRaw,
|
|
19
|
+
Connection,
|
|
20
|
+
RequestSpec,
|
|
17
21
|
} from "caido:utils";
|
|
18
22
|
|
|
19
23
|
/**
|
|
@@ -47,6 +51,19 @@ declare module "caido:plugin" {
|
|
|
47
51
|
): void;
|
|
48
52
|
};
|
|
49
53
|
|
|
54
|
+
/**
|
|
55
|
+
* The result of an upstream callback.
|
|
56
|
+
* @category Events
|
|
57
|
+
*/
|
|
58
|
+
export type UpstreamResult =
|
|
59
|
+
| Connection
|
|
60
|
+
| RequestSpec
|
|
61
|
+
| {
|
|
62
|
+
connection?: Connection;
|
|
63
|
+
request?: RequestSpec;
|
|
64
|
+
}
|
|
65
|
+
| undefined;
|
|
66
|
+
|
|
50
67
|
/**
|
|
51
68
|
* The SDK for the API RPC service.
|
|
52
69
|
* @category Events
|
|
@@ -110,6 +127,35 @@ declare module "caido:plugin" {
|
|
|
110
127
|
project: Project | null,
|
|
111
128
|
) => MaybePromise<void>,
|
|
112
129
|
): void;
|
|
130
|
+
|
|
131
|
+
/**
|
|
132
|
+
* Callback called before the request is sent to the target.
|
|
133
|
+
*
|
|
134
|
+
* This callback is called synchronously so special care should be taken
|
|
135
|
+
* to not impact overall performance.
|
|
136
|
+
*
|
|
137
|
+
* The callback can return a `Connection` that will then be used to send the request.
|
|
138
|
+
* It can also return a `RequestSpec` to override the request sent to the target.
|
|
139
|
+
*
|
|
140
|
+
* This will only be called if the user has enabled it for a given domain
|
|
141
|
+
* in the settings for Upstream Plugins.
|
|
142
|
+
*
|
|
143
|
+
* @example
|
|
144
|
+
* ```ts
|
|
145
|
+
* sdk.events.onUpstream(async (sdk, request) => {
|
|
146
|
+
* // Send all requests to example.com
|
|
147
|
+
* return {
|
|
148
|
+
* connection: await sdk.net.connect("https://example.com"),
|
|
149
|
+
* };
|
|
150
|
+
* });
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
onUpstream(
|
|
154
|
+
callback: (
|
|
155
|
+
sdk: SDK<API, Events>,
|
|
156
|
+
request: RequestSpecRaw,
|
|
157
|
+
) => MaybePromise<UpstreamResult>,
|
|
158
|
+
): void;
|
|
113
159
|
};
|
|
114
160
|
|
|
115
161
|
/**
|
|
@@ -205,5 +251,9 @@ declare module "caido:plugin" {
|
|
|
205
251
|
* The SDK for the HostedFile service.
|
|
206
252
|
*/
|
|
207
253
|
hostedFile: HostedFileSDK;
|
|
254
|
+
/**
|
|
255
|
+
* The SDK for the Net service.
|
|
256
|
+
*/
|
|
257
|
+
net: NetSDK;
|
|
208
258
|
}
|
|
209
259
|
}
|