@caido/sdk-frontend 0.37.0 → 0.39.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.
@@ -0,0 +1,4 @@
1
+ export type BackendAPI = Record<string, (...args: any[]) => any>;
2
+ export type ToBackendRPC<T extends BackendAPI> = {
3
+ [K in keyof T]: (...args: Parameters<T[K]>) => ReturnType<T[K]> extends Promise<infer U> ? Promise<U> : Promise<ReturnType<T[K]>>;
4
+ };
@@ -21,5 +21,35 @@ type CommandContextRequestRow = {
21
21
  isTls: boolean;
22
22
  }[];
23
23
  };
24
- export type CommandContext = CommandContextBase | CommandContextRequestRow;
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;
25
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 {};
@@ -1,5 +1,7 @@
1
1
  import type { Sdk } from "./__generated__/graphql-sdk";
2
+ import type { BackendAPI, ToBackendRPC } from "./backend";
2
3
  import type { Commands } from "./commands";
4
+ import type { Findings } from "./findings";
3
5
  import type { Menu } from "./menu";
4
6
  import type { Navigation } from "./navigation";
5
7
  import type { Scopes } from "./scopes";
@@ -7,9 +9,11 @@ import type { Storage } from "./storage";
7
9
  import type { UI } from "./ui";
8
10
  import type { Window } from "./window";
9
11
  export type { CommandContext } from "./commands";
10
- export type API = {
12
+ export type API<T extends BackendAPI = Record<string, never>> = {
11
13
  ui: UI;
14
+ backend: ToBackendRPC<T>;
12
15
  scopes: Scopes;
16
+ findings: Findings;
13
17
  commands: Commands;
14
18
  menu: Menu;
15
19
  navigation: Navigation;
@@ -1,12 +1,22 @@
1
1
  export type Menu = {
2
2
  registerItem: (item: MenuItem) => void;
3
3
  };
4
- type MenuItem = RequestRowMenuItem | SettingsMenuItem;
4
+ type MenuItem = RequestRowMenuItem | SettingsMenuItem | RequestMenuItem | ResponseMenuItem;
5
5
  type RequestRowMenuItem = {
6
6
  type: "RequestRow";
7
7
  commandId: string;
8
8
  leadingIcon?: string;
9
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
+ };
10
20
  type SettingsMenuItem = {
11
21
  type: "Settings";
12
22
  label: string;
@@ -1,14 +1,6 @@
1
- type JSONPrimitive = string | number | boolean | null | undefined;
2
- type JSONValue = JSONPrimitive | JSONValue[] | {
3
- [key: string]: JSONValue;
4
- };
5
- type NotAssignableToJson = bigint | symbol | Function;
6
- 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
- };
1
+ import type { JSONCompatible, JSONValue } from "./utils";
9
2
  export type Storage = {
10
3
  get: () => JSONValue;
11
4
  set: <T>(value: JSONCompatible<T>) => Promise<void>;
12
5
  onChange: (callback: (value: JSONValue) => void) => void;
13
6
  };
14
- export {};
@@ -0,0 +1,9 @@
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 {};
@@ -1,5 +1,10 @@
1
1
  export type Window = {
2
2
  getActiveEditor: () => Editor | undefined;
3
+ showToast: (message: string, options?: ToastOptions) => void;
4
+ };
5
+ type ToastOptions = {
6
+ variant?: "success" | "error" | "warning" | "info";
7
+ duration?: number;
3
8
  };
4
9
  type Editor = {
5
10
  getSelectedText: () => string;