@caido/sdk-frontend 0.0.1-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/LICENSE +21 -0
- package/README.md +44 -0
- package/package.json +15 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +0 -0
- package/src/types/__generated__/graphql-sdk.d.ts +14127 -0
- package/src/types/backend.d.ts +20 -0
- package/src/types/commands.d.ts +55 -0
- package/src/types/findings.d.ts +18 -0
- package/src/types/index.d.ts +40 -0
- package/src/types/menu.d.ts +26 -0
- package/src/types/navigation.d.ts +9 -0
- package/src/types/scopes.d.ts +23 -0
- package/src/types/storage.d.ts +6 -0
- package/src/types/ui.d.ts +23 -0
- package/src/types/utils.d.ts +10 -0
- package/src/types/window.d.ts +15 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { PromisifiedReturnType } from "./utils";
|
|
2
|
+
export type BackendEndpoints = {
|
|
3
|
+
[key: string]: (...args: any[]) => any;
|
|
4
|
+
};
|
|
5
|
+
export type BackendEvents = {
|
|
6
|
+
[key: string]: (...args: any[]) => void;
|
|
7
|
+
};
|
|
8
|
+
export type ToBackendRPC<T extends BackendEndpoints, E extends BackendEvents> = {
|
|
9
|
+
[K in keyof T]: (...args: Parameters<T[K]>) => PromisifiedReturnType<T[K]>;
|
|
10
|
+
} & {
|
|
11
|
+
/**
|
|
12
|
+
* Subscribe to a backend event.
|
|
13
|
+
* @param event The event to subscribe to.
|
|
14
|
+
* @param callback The callback to call when the event is emitted.
|
|
15
|
+
* @returns An object with a `stop` method that can be called to stop listening to the event.
|
|
16
|
+
*/
|
|
17
|
+
onEvent: <K extends keyof E>(event: K, callback: E[K]) => {
|
|
18
|
+
stop: () => void;
|
|
19
|
+
};
|
|
20
|
+
};
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export type Commands = {
|
|
2
|
+
register: (id: string, options: CommandOptions) => void;
|
|
3
|
+
};
|
|
4
|
+
type CommandOptions = {
|
|
5
|
+
name: string;
|
|
6
|
+
run: (context: CommandContext) => void;
|
|
7
|
+
group?: string;
|
|
8
|
+
when?: (context: CommandContext) => boolean;
|
|
9
|
+
};
|
|
10
|
+
type CommandContextBase = {
|
|
11
|
+
type: "BaseContext";
|
|
12
|
+
};
|
|
13
|
+
type CommandContextRequestRow = {
|
|
14
|
+
type: "RequestRowContext";
|
|
15
|
+
requests: {
|
|
16
|
+
id: string;
|
|
17
|
+
host: string;
|
|
18
|
+
port: number;
|
|
19
|
+
path: string;
|
|
20
|
+
query: string;
|
|
21
|
+
isTls: boolean;
|
|
22
|
+
}[];
|
|
23
|
+
};
|
|
24
|
+
type CommandContextRequest = {
|
|
25
|
+
type: "RequestContext";
|
|
26
|
+
request: {
|
|
27
|
+
host: string;
|
|
28
|
+
port: number;
|
|
29
|
+
path: string;
|
|
30
|
+
query: string;
|
|
31
|
+
isTls: boolean;
|
|
32
|
+
raw: string;
|
|
33
|
+
};
|
|
34
|
+
selection: string;
|
|
35
|
+
};
|
|
36
|
+
type CommandContextResponse = {
|
|
37
|
+
type: "ResponseContext";
|
|
38
|
+
request: {
|
|
39
|
+
id: string;
|
|
40
|
+
host: string;
|
|
41
|
+
port: number;
|
|
42
|
+
path: string;
|
|
43
|
+
query: string;
|
|
44
|
+
isTls: boolean;
|
|
45
|
+
};
|
|
46
|
+
response: {
|
|
47
|
+
id: string;
|
|
48
|
+
raw: string;
|
|
49
|
+
statusCode: number;
|
|
50
|
+
roundtripTime: number;
|
|
51
|
+
};
|
|
52
|
+
selection: string;
|
|
53
|
+
};
|
|
54
|
+
export type CommandContext = CommandContextBase | CommandContextRequestRow | CommandContextRequest | CommandContextResponse;
|
|
55
|
+
export {};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export type Findings = {
|
|
2
|
+
createFinding: (requestId: string, options: CreateFindingsOptions) => Promise<Finding | undefined>;
|
|
3
|
+
};
|
|
4
|
+
type Finding = {
|
|
5
|
+
id: string;
|
|
6
|
+
title: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
reporter: string;
|
|
9
|
+
host: string;
|
|
10
|
+
path: string;
|
|
11
|
+
};
|
|
12
|
+
type CreateFindingsOptions = {
|
|
13
|
+
title: string;
|
|
14
|
+
description?: string;
|
|
15
|
+
reporter: string;
|
|
16
|
+
dedupeKey?: string;
|
|
17
|
+
};
|
|
18
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { Sdk } from "./__generated__/graphql-sdk";
|
|
2
|
+
import type { BackendEndpoints, BackendEvents, ToBackendRPC } from "./backend";
|
|
3
|
+
import type { Commands } from "./commands";
|
|
4
|
+
import type { Findings } from "./findings";
|
|
5
|
+
import type { Menu } from "./menu";
|
|
6
|
+
import type { Navigation } from "./navigation";
|
|
7
|
+
import type { Scopes } from "./scopes";
|
|
8
|
+
import type { Storage } from "./storage";
|
|
9
|
+
import type { UI } from "./ui";
|
|
10
|
+
import type { Window } from "./window";
|
|
11
|
+
export type { CommandContext } from "./commands";
|
|
12
|
+
export type API<T extends BackendEndpoints = Record<string, never>, E extends BackendEvents = Record<string, never>> = {
|
|
13
|
+
ui: UI;
|
|
14
|
+
backend: ToBackendRPC<T, E>;
|
|
15
|
+
scopes: Scopes;
|
|
16
|
+
findings: Findings;
|
|
17
|
+
commands: Commands;
|
|
18
|
+
menu: Menu;
|
|
19
|
+
navigation: Navigation;
|
|
20
|
+
window: Window;
|
|
21
|
+
storage: Storage;
|
|
22
|
+
shortcuts: {
|
|
23
|
+
register: (commandId: string, keys: string[]) => void;
|
|
24
|
+
};
|
|
25
|
+
commandPalette: {
|
|
26
|
+
register: (commandId: string) => void;
|
|
27
|
+
};
|
|
28
|
+
sidebar: {
|
|
29
|
+
registerItem: (name: string, path: string, options?: SidebarItemOptions) => SidebarItem;
|
|
30
|
+
};
|
|
31
|
+
graphql: Sdk;
|
|
32
|
+
};
|
|
33
|
+
type SidebarItemOptions = {
|
|
34
|
+
icon?: string;
|
|
35
|
+
group?: string;
|
|
36
|
+
isExternal?: boolean;
|
|
37
|
+
};
|
|
38
|
+
type SidebarItem = {
|
|
39
|
+
setCount: (count: number) => void;
|
|
40
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export type Menu = {
|
|
2
|
+
registerItem: (item: MenuItem) => void;
|
|
3
|
+
};
|
|
4
|
+
type MenuItem = RequestRowMenuItem | SettingsMenuItem | RequestMenuItem | ResponseMenuItem;
|
|
5
|
+
type RequestRowMenuItem = {
|
|
6
|
+
type: "RequestRow";
|
|
7
|
+
commandId: string;
|
|
8
|
+
leadingIcon?: string;
|
|
9
|
+
};
|
|
10
|
+
type RequestMenuItem = {
|
|
11
|
+
type: "Request";
|
|
12
|
+
commandId: string;
|
|
13
|
+
leadingIcon?: string;
|
|
14
|
+
};
|
|
15
|
+
type ResponseMenuItem = {
|
|
16
|
+
type: "Response";
|
|
17
|
+
commandId: string;
|
|
18
|
+
leadingIcon?: string;
|
|
19
|
+
};
|
|
20
|
+
type SettingsMenuItem = {
|
|
21
|
+
type: "Settings";
|
|
22
|
+
label: string;
|
|
23
|
+
path: string;
|
|
24
|
+
leadingIcon?: string;
|
|
25
|
+
};
|
|
26
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type Scopes = {
|
|
2
|
+
getScopes: () => Scope[];
|
|
3
|
+
createScope: (options: CreateScopeOptions) => Promise<Scope | undefined>;
|
|
4
|
+
updateScope: (id: string, options: UpdateScopeOptions) => Promise<Scope | undefined>;
|
|
5
|
+
deleteScope: (id: string) => Promise<boolean>;
|
|
6
|
+
};
|
|
7
|
+
type Scope = {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
allowlist: string[];
|
|
11
|
+
denylist: string[];
|
|
12
|
+
};
|
|
13
|
+
type CreateScopeOptions = {
|
|
14
|
+
name: string;
|
|
15
|
+
allowlist: string[];
|
|
16
|
+
denylist: string[];
|
|
17
|
+
};
|
|
18
|
+
type UpdateScopeOptions = {
|
|
19
|
+
name?: string;
|
|
20
|
+
allowlist?: string[];
|
|
21
|
+
denylist?: string[];
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export type UI = {
|
|
2
|
+
button: (options?: ButtonOptions) => HTMLElement;
|
|
3
|
+
card: (options?: CardOptions) => HTMLElement;
|
|
4
|
+
well: (options?: WellOptions) => HTMLElement;
|
|
5
|
+
};
|
|
6
|
+
type ButtonOptions = {
|
|
7
|
+
variant?: "primary" | "secondary" | "tertiary";
|
|
8
|
+
label?: string;
|
|
9
|
+
leadingIcon?: string;
|
|
10
|
+
trailingIcon?: string;
|
|
11
|
+
size?: "small" | "medium" | "large";
|
|
12
|
+
};
|
|
13
|
+
type CardOptions = {
|
|
14
|
+
header?: HTMLElement;
|
|
15
|
+
body?: HTMLElement;
|
|
16
|
+
footer?: HTMLElement;
|
|
17
|
+
};
|
|
18
|
+
type WellOptions = {
|
|
19
|
+
header?: HTMLElement;
|
|
20
|
+
body?: HTMLElement;
|
|
21
|
+
footer?: HTMLElement;
|
|
22
|
+
};
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
type JSONPrimitive = string | number | boolean | null | undefined;
|
|
2
|
+
export type JSONValue = JSONPrimitive | JSONValue[] | {
|
|
3
|
+
[key: string]: JSONValue;
|
|
4
|
+
};
|
|
5
|
+
type NotAssignableToJson = bigint | symbol | Function;
|
|
6
|
+
export type JSONCompatible<T> = unknown extends T ? never : {
|
|
7
|
+
[P in keyof T]: T[P] extends JSONValue ? T[P] : T[P] extends NotAssignableToJson ? never : JSONCompatible<T[P]>;
|
|
8
|
+
};
|
|
9
|
+
export type PromisifiedReturnType<T extends (...args: unknown[]) => unknown> = ReturnType<T> extends Promise<infer U> ? Promise<U> : Promise<ReturnType<T>>;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type Window = {
|
|
2
|
+
getActiveEditor: () => Editor | undefined;
|
|
3
|
+
showToast: (message: string, options?: ToastOptions) => void;
|
|
4
|
+
};
|
|
5
|
+
type ToastOptions = {
|
|
6
|
+
variant?: "success" | "error" | "warning" | "info";
|
|
7
|
+
duration?: number;
|
|
8
|
+
};
|
|
9
|
+
type Editor = {
|
|
10
|
+
getSelectedText: () => string;
|
|
11
|
+
replaceSelectedText: (text: string) => void;
|
|
12
|
+
isReadOnly: () => boolean;
|
|
13
|
+
focus: () => void;
|
|
14
|
+
};
|
|
15
|
+
export {};
|