@caido/sdk-workflow 0.0.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/LICENSE +21 -0
- package/README.md +47 -0
- package/package.json +11 -0
- package/src/index.d.ts +1 -0
- package/src/typing.d.ts +199 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Caido Labs Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
<img width="1000" alt="image" src="https://user-images.githubusercontent.com/6225588/211916659-567751d1-0225-402b-9141-4145c18b0834.png">
|
|
3
|
+
|
|
4
|
+
<br />
|
|
5
|
+
<br />
|
|
6
|
+
<a href="https://caido.io/">Website</a>
|
|
7
|
+
<span> • </span>
|
|
8
|
+
<a href="https://dashboard.caido.io/">Dashboard</a>
|
|
9
|
+
<span> • </span>
|
|
10
|
+
<a href="https://docs.caido.io/" target="_blank">Docs</a>
|
|
11
|
+
<span> • </span>
|
|
12
|
+
<a href="https://links.caido.io/roadmap">Roadmap</a>
|
|
13
|
+
<span> • </span>
|
|
14
|
+
<a href="https://github.com/caido/caido/tree/main/brand">Branding</a>
|
|
15
|
+
<span> • </span>
|
|
16
|
+
<a href="https://links.caido.io/www-discord" target="_blank">Discord</a>
|
|
17
|
+
<br />
|
|
18
|
+
<hr />
|
|
19
|
+
</div>
|
|
20
|
+
|
|
21
|
+
## 👋 Frontend SDK
|
|
22
|
+
|
|
23
|
+
[](https://www.npmjs.com/package/@caido/sdk-workflow)
|
|
24
|
+
|
|
25
|
+
This is repository for the Caido workflow SDK.
|
|
26
|
+
|
|
27
|
+
You usually don't need to use this package directly since typing is already included in the runtime.
|
|
28
|
+
|
|
29
|
+
But this can be useful if you want to write to code externally in Typescript and built it to JS.
|
|
30
|
+
|
|
31
|
+
```typescript
|
|
32
|
+
import { PassiveInput, SDK, Data } from "./typing";
|
|
33
|
+
|
|
34
|
+
export async function run(
|
|
35
|
+
input: PassiveInput,
|
|
36
|
+
sdk: SDK,
|
|
37
|
+
): Promise<Data | undefined> {
|
|
38
|
+
if (input.request) {
|
|
39
|
+
sdk.console.log(input.request.getMethod());
|
|
40
|
+
}
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## 💚 Community
|
|
46
|
+
|
|
47
|
+
Come join our [Discord](https://links.caido.io/www-discord) community and connect with other Caido users! We'd love to have you as part of the conversation and help with any questions you may have.
|
package/package.json
ADDED
package/src/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./typing";
|
package/src/typing.d.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Console interface for logging.
|
|
3
|
+
*
|
|
4
|
+
* Currently logs are only available in the backend logs.
|
|
5
|
+
* See https://docs.caido.io/report_bug.html#1-backend-logs
|
|
6
|
+
*/
|
|
7
|
+
export declare type Console = {
|
|
8
|
+
debug(message: any): void;
|
|
9
|
+
log(message: any): void;
|
|
10
|
+
warn(message: any): void;
|
|
11
|
+
error(message: any): void;
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* The body of a Request or Response.
|
|
16
|
+
*
|
|
17
|
+
* Calling `to<FORMAT>` will try to convert the body to the desired format.
|
|
18
|
+
*/
|
|
19
|
+
export declare class Body {
|
|
20
|
+
/**
|
|
21
|
+
* Parse the body as a string.
|
|
22
|
+
*
|
|
23
|
+
* Unprintable characters will be replaced with `�`.
|
|
24
|
+
*/
|
|
25
|
+
toText(): string;
|
|
26
|
+
/**
|
|
27
|
+
* Try to parse the body as JSON.
|
|
28
|
+
*
|
|
29
|
+
* @throws {SyntaxError} If the body is not valid JSON.
|
|
30
|
+
*/
|
|
31
|
+
toJson(): any;
|
|
32
|
+
/**
|
|
33
|
+
* Get the raw body as an array of bytes.
|
|
34
|
+
*/
|
|
35
|
+
toRaw(): Uint8Array;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A saved immutable Request.
|
|
40
|
+
*
|
|
41
|
+
* To modify, use `toSpec` to get a `RequestSpec` object.
|
|
42
|
+
*/
|
|
43
|
+
export declare type Request = {
|
|
44
|
+
getId(): ID;
|
|
45
|
+
getHost(): string;
|
|
46
|
+
getPort(): number;
|
|
47
|
+
getTls(): boolean;
|
|
48
|
+
getMethod(): string;
|
|
49
|
+
getPath(): string;
|
|
50
|
+
getQuery(): string;
|
|
51
|
+
getHeader(name: string): Array<string> | undefined;
|
|
52
|
+
getBody(): Body | undefined;
|
|
53
|
+
toSpec(): RequestSpec;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
/**
|
|
57
|
+
* A mutable Request not yet sent.
|
|
58
|
+
*/
|
|
59
|
+
export declare class RequestSpec {
|
|
60
|
+
getHost(): string;
|
|
61
|
+
setHost(host: string): void;
|
|
62
|
+
getPort(): number;
|
|
63
|
+
setPort(port: number): void;
|
|
64
|
+
getTls(): boolean;
|
|
65
|
+
setTls(tls: boolean): void;
|
|
66
|
+
getMethod(): string;
|
|
67
|
+
setMethod(method: string): void;
|
|
68
|
+
getPath(): string;
|
|
69
|
+
setPath(path: string): void;
|
|
70
|
+
getQuery(): string;
|
|
71
|
+
setQuery(query: string): void;
|
|
72
|
+
getHeader(name: string): Array<string> | undefined;
|
|
73
|
+
setHeader(name: string, value: string): void;
|
|
74
|
+
getBody(): Body | undefined;
|
|
75
|
+
setBody(body: Body | Bytes): void;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* An immutable saved Response.
|
|
80
|
+
*/
|
|
81
|
+
export declare type Response = {
|
|
82
|
+
getId(): ID;
|
|
83
|
+
getCode(): number;
|
|
84
|
+
getHeader(name: string): Array<string> | undefined;
|
|
85
|
+
getBody(): Body | undefined;
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* An immutable saved Request and Response pair.
|
|
90
|
+
*/
|
|
91
|
+
export declare type RequestReponse = {
|
|
92
|
+
request: Request;
|
|
93
|
+
response: Response;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* The SDK for the Requests service.
|
|
98
|
+
*/
|
|
99
|
+
export declare type RequestsSDK = {
|
|
100
|
+
/**
|
|
101
|
+
* Sends a request.
|
|
102
|
+
*
|
|
103
|
+
* This respects the upstream proxy settings.
|
|
104
|
+
*
|
|
105
|
+
* @throws {Error} If the request cannot be sent.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* const spec = new RequestSpec("https://example.com");
|
|
109
|
+
* sdk.send(request)
|
|
110
|
+
* .then((res) => {
|
|
111
|
+
* console.log(res.request.getId());
|
|
112
|
+
* console.log(res.response.getCode());
|
|
113
|
+
* })
|
|
114
|
+
* .catch((err) => {
|
|
115
|
+
* console.error(err);
|
|
116
|
+
* });
|
|
117
|
+
*/
|
|
118
|
+
send(request: RequestSpec): Promise<RequestReponse>;
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* A saved immutable Finding.
|
|
123
|
+
*
|
|
124
|
+
* To modify, use `toSpec` to get a `FindingSpec` object.
|
|
125
|
+
*/
|
|
126
|
+
export declare type Finding = {
|
|
127
|
+
getId(): ID;
|
|
128
|
+
getTitle(): string;
|
|
129
|
+
getDescription(): string | undefined;
|
|
130
|
+
getReporter(): string;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* A mutable Finding not yet created.
|
|
135
|
+
*/
|
|
136
|
+
export declare type FindingSpec = {
|
|
137
|
+
title: string;
|
|
138
|
+
description?: string | undefined;
|
|
139
|
+
reporter: string;
|
|
140
|
+
request: Request;
|
|
141
|
+
};
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* The SDK for the Findings service.
|
|
145
|
+
*/
|
|
146
|
+
export declare type FindingsSDK = {
|
|
147
|
+
/**
|
|
148
|
+
* Creates a new Finding.
|
|
149
|
+
*
|
|
150
|
+
* @throws {Error} If the request cannot be saved.
|
|
151
|
+
*
|
|
152
|
+
* @example
|
|
153
|
+
* sdk.findings.create({
|
|
154
|
+
* title: "Title",
|
|
155
|
+
* description: "Description",
|
|
156
|
+
* reporter: "Reporter",
|
|
157
|
+
* request,
|
|
158
|
+
* });
|
|
159
|
+
*/
|
|
160
|
+
create(spec: FindingSpec): Promise<Finding>;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export declare type PassiveInput = {
|
|
164
|
+
request: Request | undefined;
|
|
165
|
+
response: Response | undefined;
|
|
166
|
+
};
|
|
167
|
+
export declare type ConvertInput = Array<number>;
|
|
168
|
+
|
|
169
|
+
export declare type ID = string;
|
|
170
|
+
export declare type Data = Bytes;
|
|
171
|
+
export declare type Decision = boolean;
|
|
172
|
+
export declare type Bytes = string | Array<number> | Uint8Array;
|
|
173
|
+
export declare type MaybePromise<T> = T | Promise<T>;
|
|
174
|
+
|
|
175
|
+
/**
|
|
176
|
+
* The SDK object available to all scripts.
|
|
177
|
+
*/
|
|
178
|
+
export declare type SDK = {
|
|
179
|
+
/**
|
|
180
|
+
* The console.
|
|
181
|
+
*
|
|
182
|
+
* This is currently the same as the global `console`.
|
|
183
|
+
*/
|
|
184
|
+
console: Console;
|
|
185
|
+
/**
|
|
186
|
+
* The SDK for the Findings service.
|
|
187
|
+
*/
|
|
188
|
+
findings: FindingsSDK;
|
|
189
|
+
/**
|
|
190
|
+
* The SDK for the Requests services
|
|
191
|
+
*/
|
|
192
|
+
requests: RequestsSDK;
|
|
193
|
+
/**
|
|
194
|
+
* Converts bytes to a string.
|
|
195
|
+
*
|
|
196
|
+
* Unprintable characters will be replaced with `�`.
|
|
197
|
+
*/
|
|
198
|
+
asString(array: Bytes): string;
|
|
199
|
+
};
|