@caido/sdk-backend 0.1.1 → 0.1.3
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/typing.d.ts +52 -37
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
package/src/types/typing.d.ts
CHANGED
|
@@ -1,43 +1,58 @@
|
|
|
1
|
-
|
|
1
|
+
declare module "caido:sdk" {
|
|
2
|
+
import { MaybePromise, FindingsSDK, RequestsSDK } from "caido:common";
|
|
2
3
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
register(
|
|
16
|
-
name: string,
|
|
17
|
-
callback: (...args: unknown[]) => MaybePromise<unknown>,
|
|
18
|
-
): void;
|
|
19
|
-
};
|
|
4
|
+
export type DefineAPI<
|
|
5
|
+
API extends Record<string, (...args: any[]) => MaybePromise<any>>,
|
|
6
|
+
> = {
|
|
7
|
+
[K in keyof API]: DefineCallback<API[K]>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export type DefineCallback<F> = F extends (
|
|
11
|
+
sdk: SDK,
|
|
12
|
+
...args: infer A
|
|
13
|
+
) => infer R
|
|
14
|
+
? (...args: A) => R
|
|
15
|
+
: "Your callback must respect the format (sdk: SDK, ...args: unknown[]) => MaybePromise<unknown>";
|
|
20
16
|
|
|
21
|
-
/**
|
|
22
|
-
* The SDK object available to all scripts.
|
|
23
|
-
*/
|
|
24
|
-
export type SDK = {
|
|
25
|
-
/**
|
|
26
|
-
* The console.
|
|
27
|
-
*
|
|
28
|
-
* This is currently the same as the global `console`.
|
|
29
|
-
*/
|
|
30
|
-
console: Console;
|
|
31
|
-
/**
|
|
32
|
-
* The SDK for the Findings service.
|
|
33
|
-
*/
|
|
34
|
-
findings: FindingsSDK;
|
|
35
17
|
/**
|
|
36
|
-
* The SDK for the
|
|
18
|
+
* The SDK for the API RPC service.
|
|
37
19
|
*/
|
|
38
|
-
|
|
20
|
+
export type APISDK = {
|
|
21
|
+
/**
|
|
22
|
+
* Registers a new backend function for the RPC.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* sdk.api.register("multiply", (a: number, b: number) => {
|
|
26
|
+
* return a * b;
|
|
27
|
+
* });
|
|
28
|
+
*/
|
|
29
|
+
register(
|
|
30
|
+
name: string,
|
|
31
|
+
callback: (sdk: SDK, ...args: any[]) => MaybePromise<any>,
|
|
32
|
+
): void;
|
|
33
|
+
};
|
|
34
|
+
|
|
39
35
|
/**
|
|
40
|
-
* The SDK
|
|
36
|
+
* The SDK object available to all scripts.
|
|
41
37
|
*/
|
|
42
|
-
|
|
43
|
-
|
|
38
|
+
export type SDK = {
|
|
39
|
+
/**
|
|
40
|
+
* The console.
|
|
41
|
+
*
|
|
42
|
+
* This is currently the same as the global `console`.
|
|
43
|
+
*/
|
|
44
|
+
console: Console;
|
|
45
|
+
/**
|
|
46
|
+
* The SDK for the Findings service.
|
|
47
|
+
*/
|
|
48
|
+
findings: FindingsSDK;
|
|
49
|
+
/**
|
|
50
|
+
* The SDK for the Requests services
|
|
51
|
+
*/
|
|
52
|
+
requests: RequestsSDK;
|
|
53
|
+
/**
|
|
54
|
+
* The SDK for the API RPC service.
|
|
55
|
+
*/
|
|
56
|
+
api: APISDK;
|
|
57
|
+
};
|
|
58
|
+
}
|