@caido/sdk-frontend 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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Caido
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,2 @@
1
+ # sdk-frontend
2
+ SDK definition for the Caido Frontend
package/package.json ADDED
@@ -0,0 +1,16 @@
1
+ {
2
+ "name": "@caido/sdk-frontend",
3
+ "version": "0.0.1",
4
+ "description": "Typing for the Caido Frontend SDK",
5
+ "author": "Caido Labs Inc. <dev@caido.io>",
6
+ "license": "MIT",
7
+ "types": "./src/index.d.ts",
8
+ "main": "./src/index.js",
9
+ "module": "./src/index.js",
10
+ "scripts": {
11
+ "publish": "npm publish --access public"
12
+ },
13
+ "files": [
14
+ "src/*"
15
+ ]
16
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,11 @@
1
+ import { API } from "./types";
2
+
3
+ declare global {
4
+ interface Window {
5
+ Caido: API;
6
+ }
7
+ }
8
+
9
+ declare const Caido: API;
10
+
11
+ export { Caido };
package/src/index.js ADDED
@@ -0,0 +1 @@
1
+ export const Caido = window.Caido;
@@ -0,0 +1,28 @@
1
+ export type Commands = {
2
+ register: (id: string, options: CommandOptions) => void;
3
+ };
4
+
5
+ type CommandOptions = {
6
+ name: string;
7
+ run: (context: CommandContext) => void;
8
+ group?: string;
9
+ when?: (context: CommandContext) => boolean;
10
+ };
11
+
12
+ type CommandContextBase = {
13
+ type: "BaseContext";
14
+ };
15
+
16
+ type CommandContextRequestRow = {
17
+ type: "RequestRowContext";
18
+ request: {
19
+ id: string;
20
+ host: string;
21
+ port: number;
22
+ path: string;
23
+ query: string;
24
+ isTls: boolean;
25
+ };
26
+ };
27
+
28
+ export type CommandContext = CommandContextBase | CommandContextRequestRow;
@@ -0,0 +1,49 @@
1
+ import type { Commands } from "./commands";
2
+ import type { Menu } from "./menu";
3
+ import type { Scopes } from "./scopes";
4
+ import type { UI } from "./ui";
5
+
6
+ export type { CommandContext } from "./commands";
7
+
8
+ export type API = {
9
+ ui: UI;
10
+ scopes: Scopes;
11
+ commands: Commands;
12
+ menu: Menu;
13
+
14
+ navigation: {
15
+ goTo: (path: string) => void;
16
+ addPage: (path: string, options: PageOptions) => void;
17
+ };
18
+
19
+ shortcuts: {
20
+ register: (commandId: string, keys: string[]) => void;
21
+ };
22
+
23
+ commandPalette: {
24
+ register: (commandId: string) => void;
25
+ };
26
+
27
+ sidebar: {
28
+ registerItem: (
29
+ name: string,
30
+ path: string,
31
+ options?: SidebarItemOptions
32
+ ) => SidebarItem;
33
+ };
34
+ };
35
+
36
+ type PageOptions = {
37
+ body: HTMLElement;
38
+ topbar?: HTMLElement;
39
+ };
40
+
41
+ type SidebarItemOptions = {
42
+ icon?: string;
43
+ group?: string;
44
+ isExternal?: boolean;
45
+ };
46
+
47
+ type SidebarItem = {
48
+ setCount: (count: number) => void;
49
+ };
@@ -0,0 +1,13 @@
1
+ type MenuId = "RequestRow";
2
+
3
+ export type Menu = {
4
+ registerItem: (
5
+ menuId: MenuId,
6
+ commandId: string,
7
+ options?: MenuOptions,
8
+ ) => void;
9
+ };
10
+
11
+ type MenuOptions = {
12
+ leadingIcon?: string;
13
+ };
@@ -0,0 +1,28 @@
1
+ export type Scopes = {
2
+ getScopes: () => Scope[];
3
+ createScope: (options: CreateScopeOptions) => Promise<Scope | undefined>;
4
+ updateScope: (
5
+ id: string,
6
+ options: UpdateScopeOptions,
7
+ ) => Promise<Scope | undefined>;
8
+ deleteScope: (id: string) => Promise<boolean>;
9
+ };
10
+
11
+ type Scope = {
12
+ id: string;
13
+ name: string;
14
+ allowlist: string[];
15
+ denylist: string[];
16
+ };
17
+
18
+ type CreateScopeOptions = {
19
+ name: string;
20
+ allowlist: string[];
21
+ denylist: string[];
22
+ };
23
+
24
+ type UpdateScopeOptions = {
25
+ name?: string;
26
+ allowlist?: string[];
27
+ denylist?: string[];
28
+ };
@@ -0,0 +1,25 @@
1
+ export type UI = {
2
+ button: (options?: ButtonOptions) => HTMLElement;
3
+ card: (options?: CardOptions) => HTMLElement;
4
+ well: (options?: WellOptions) => HTMLElement;
5
+ };
6
+
7
+ type ButtonOptions = {
8
+ variant?: "primary" | "secondary" | "tertiary";
9
+ label?: string;
10
+ leadingIcon?: string;
11
+ trailingIcon?: string;
12
+ size?: "small" | "medium" | "large";
13
+ };
14
+
15
+ type CardOptions = {
16
+ header?: HTMLElement;
17
+ body?: HTMLElement;
18
+ footer?: HTMLElement;
19
+ };
20
+
21
+ type WellOptions = {
22
+ header?: HTMLElement;
23
+ body?: HTMLElement;
24
+ footer?: HTMLElement;
25
+ };