@caido/sdk-backend 0.58.3 → 0.60.0-rc.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 +1 -1
- package/src/typing.d.ts +111 -0
package/package.json
CHANGED
package/src/typing.d.ts
CHANGED
|
@@ -2,6 +2,7 @@ declare module "caido:plugin" {
|
|
|
2
2
|
import type {
|
|
3
3
|
Connection,
|
|
4
4
|
EnvironmentSDK,
|
|
5
|
+
Finding,
|
|
5
6
|
FindingsSDK,
|
|
6
7
|
GraphQLSDK,
|
|
7
8
|
HostedFileSDK,
|
|
@@ -37,6 +38,96 @@ declare module "caido:plugin" {
|
|
|
37
38
|
? A
|
|
38
39
|
: InvalidEventParametersMessage;
|
|
39
40
|
|
|
41
|
+
/**
|
|
42
|
+
* Represents any valid value for the key-value store.
|
|
43
|
+
* It needs to be serializable to JSON.
|
|
44
|
+
* @category KV
|
|
45
|
+
*/
|
|
46
|
+
export type KVValue =
|
|
47
|
+
| string
|
|
48
|
+
| number
|
|
49
|
+
| boolean
|
|
50
|
+
| KVValue[]
|
|
51
|
+
| null
|
|
52
|
+
| { [key: string]: KVValue };
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Options for defining a key-value pair.
|
|
56
|
+
* @category KV
|
|
57
|
+
*/
|
|
58
|
+
type KVDefineOptions = {
|
|
59
|
+
/**
|
|
60
|
+
* Whether the key-value pair is exportable.
|
|
61
|
+
*
|
|
62
|
+
* Usually this should be true for keys that are settings that you would want to
|
|
63
|
+
* transfer between Caido instances.
|
|
64
|
+
*
|
|
65
|
+
* @default false
|
|
66
|
+
*/
|
|
67
|
+
exportable?: boolean | undefined;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* The SDK for the key-value store.
|
|
72
|
+
* @category KV
|
|
73
|
+
*/
|
|
74
|
+
export type KVSDK = {
|
|
75
|
+
/**
|
|
76
|
+
* Defines a new key-value pair. Only call this once per key.
|
|
77
|
+
* If the key is not defined, it will be created at first set with default options.
|
|
78
|
+
*
|
|
79
|
+
* @param key The key to define.
|
|
80
|
+
* @param options The options for the key.
|
|
81
|
+
*/
|
|
82
|
+
define(key: string, options: KVDefineOptions): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Gets a value from the key-value store.
|
|
85
|
+
*
|
|
86
|
+
* @param key The key to get.
|
|
87
|
+
* @returns The value or undefined if the key is not defined.
|
|
88
|
+
*/
|
|
89
|
+
get<T extends KVValue>(key: string): Promise<T | undefined>;
|
|
90
|
+
|
|
91
|
+
/**
|
|
92
|
+
* Sets a value in the key-value store.
|
|
93
|
+
*
|
|
94
|
+
* @param key The key to set.
|
|
95
|
+
* @param value The value to set.
|
|
96
|
+
*/
|
|
97
|
+
set<T extends KVValue>(key: string, value: T): Promise<void>;
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Deletes a key-value pair from the key-value store.
|
|
101
|
+
*
|
|
102
|
+
* No-op if the key is not defined.
|
|
103
|
+
*
|
|
104
|
+
* @param key The key to delete.
|
|
105
|
+
*/
|
|
106
|
+
del(key: string): Promise<void>;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Registers a callback for when a key-value pair is set.
|
|
110
|
+
*
|
|
111
|
+
* @param event The event to register for.
|
|
112
|
+
* @param callback The callback to register.
|
|
113
|
+
*/
|
|
114
|
+
on(
|
|
115
|
+
event: "set",
|
|
116
|
+
callback: <T extends KVValue>(
|
|
117
|
+
key: string,
|
|
118
|
+
value: T,
|
|
119
|
+
) => MaybePromise<void>,
|
|
120
|
+
): void;
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Registers a callback for when a key-value pair is deleted.
|
|
124
|
+
*
|
|
125
|
+
* @param event The event to register for.
|
|
126
|
+
* @param callback The callback to register.
|
|
127
|
+
*/
|
|
128
|
+
on(event: "delete", callback: (key: string) => MaybePromise<void>): void;
|
|
129
|
+
};
|
|
130
|
+
|
|
40
131
|
/**
|
|
41
132
|
* The SDK for the API RPC service.
|
|
42
133
|
* @category API
|
|
@@ -176,6 +267,22 @@ declare module "caido:plugin" {
|
|
|
176
267
|
request: RequestSpecRaw,
|
|
177
268
|
) => MaybePromise<UpstreamResult>,
|
|
178
269
|
): void;
|
|
270
|
+
|
|
271
|
+
/**
|
|
272
|
+
* Callback called when a finding is created.
|
|
273
|
+
*
|
|
274
|
+
* This callback is called asynchronously and cannot modify the finding.
|
|
275
|
+
*
|
|
276
|
+
* @example
|
|
277
|
+
* ```ts
|
|
278
|
+
* sdk.events.onFindingCreated((sdk, finding) => {
|
|
279
|
+
* // Do something with the finding
|
|
280
|
+
* });
|
|
281
|
+
* ```
|
|
282
|
+
*/
|
|
283
|
+
onFindingCreated(
|
|
284
|
+
callback: (sdk: SDK<API, Events>, finding: Finding) => MaybePromise<void>,
|
|
285
|
+
): void;
|
|
179
286
|
};
|
|
180
287
|
|
|
181
288
|
/**
|
|
@@ -279,5 +386,9 @@ declare module "caido:plugin" {
|
|
|
279
386
|
* The SDK for the Net service.
|
|
280
387
|
*/
|
|
281
388
|
net: NetSDK;
|
|
389
|
+
/**
|
|
390
|
+
* The SDK for the Key-Value store.
|
|
391
|
+
*/
|
|
392
|
+
kv: KVSDK;
|
|
282
393
|
}
|
|
283
394
|
}
|