@caido/sdk-frontend 0.54.2-beta.2 → 0.54.2-beta.4

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@caido/sdk-frontend",
3
- "version": "0.54.2-beta.2",
3
+ "version": "0.54.2-beta.4",
4
4
  "description": "Typing for the Caido Frontend SDK",
5
5
  "author": "Caido Labs Inc. <dev@caido.io>",
6
6
  "repository": "https://github.com/caido/sdk-js/",
@@ -2,7 +2,9 @@ export { FooterSlot, type FooterSlotContent } from "./types/footer";
2
2
  export type { DialogOptions } from "./types/window";
3
3
  export type { CommandContext, CommandContextRequest, CommandContextRequestRow, CommandContextResponse, CommandContextBase, } from "./types/commands";
4
4
  export type { MenuItem } from "./types/menu";
5
- export { type ReplayTab, type ReplaySession, type ReplayEntry, type ReplayCollection, type SendRequestOptions, ReplaySlot, type ReplaySlotContent, type RequestSource, type CurrentReplaySessionChangeEvent, type AddSessionIndicatorOptions, type SessionIndicator, } from "./types/replay";
5
+ export { type ReplayTab, type ReplaySession, type ReplayEntry, type ReplayCollection, type SendRequestOptions, ReplaySlot, type ReplaySlotContent, type RequestSource, type CurrentReplaySessionChangeEvent, } from "./types/replay";
6
+ export type { AutomateSession, AutomateEntry } from "./types/automate";
7
+ export type { SitemapEntry, SitemapRootEntry, ChildState, } from "./types/sitemap";
6
8
  export { SearchSlot, type SearchSlotContent } from "./types/search";
7
9
  export type { HostedFile } from "./types/files";
8
10
  export { FilterSlot, type Filter, type FilterSlotContent, type CurrentFilterChangeEvent, } from "./types/filter";
@@ -10,13 +12,14 @@ export type { HTTPQL, ID, ComponentDefinition } from "./types/utils";
10
12
  export type { JSONValue, JSONCompatible } from "./types/json";
11
13
  export type { SlotContent, ButtonSlotContent, CustomSlotContent, CommandSlotContent, } from "./types/slots";
12
14
  export type { RequestViewModeOptions, RequestFull, RequestDraft, RequestMeta, } from "./types/request";
15
+ export type { ResponseViewModeOptions, ResponseFull } from "./types/response";
13
16
  export type { CurrentMatchReplaceRuleChangeEvent, MatchReplaceRule, MatchReplaceCollection, MatchReplaceSection, MatchReplaceSectionRequestAll, MatchReplaceSectionRequestBody, MatchReplaceSectionRequestFirstLine, MatchReplaceSectionRequestHeader, MatchReplaceSectionRequestMethod, MatchReplaceSectionRequestPath, MatchReplaceSectionRequestQuery, MatchReplaceSectionRequestSNI, MatchReplaceSectionResponseAll, MatchReplaceSectionResponseBody, MatchReplaceSectionResponseFirstLine, MatchReplaceSectionResponseHeader, MatchReplaceSectionResponseStatusCode, MatchReplaceOperationStatusCode, MatchReplaceOperationStatusCodeUpdate, MatchReplaceOperationQuery, MatchReplaceOperationQueryRaw, MatchReplaceOperationQueryAdd, MatchReplaceOperationQueryRemove, MatchReplaceOperationQueryUpdate, MatchReplaceOperationPath, MatchReplaceOperationPathRaw, MatchReplaceOperationAll, MatchReplaceOperationAllRaw, MatchReplaceOperationMethod, MatchReplaceOperationMethodUpdate, MatchReplaceOperationHeader, MatchReplaceOperationHeaderRaw, MatchReplaceOperationHeaderAdd, MatchReplaceOperationHeaderRemove, MatchReplaceOperationHeaderUpdate, MatchReplaceOperationBody, MatchReplaceOperationBodyRaw, MatchReplaceOperationFirstLine, MatchReplaceOperationFirstLineRaw, MatchReplaceOperationSNI, MatchReplaceOperationSNIRaw, MatchReplaceReplacer, MatchReplaceReplacerTerm, MatchReplaceReplacerWorkflow, MatchReplaceMatcherName, MatchReplaceMatcherRaw, MatchReplaceMatcherRawFull, MatchReplaceMatcherRawRegex, MatchReplaceMatcherRawValue, } from "./types/matchReplace";
14
17
  export { MatchReplaceSlot, type MatchReplaceSlotContent, } from "./types/matchReplace";
15
18
  export { ScopeSlot, type CurrentScopeChangeEvent, type Scope, type ScopeSlotContent, } from "./types/scopes";
16
19
  export { HTTPHistorySlot, type HTTPHistorySlotContent, } from "./types/httpHistory";
17
20
  export type { EnvironmentVariable } from "./types/environment";
18
21
  export type { Workflow, WorkflowKind, OnCreatedWorkflowCallback, OnUpdatedWorkflowCallback, OnDeletedWorkflowCallback, } from "./types/workflows";
19
- export type { ListenerHandle } from "./types/utils";
22
+ export type { ListenerHandle, AddIndicatorOptions, Indicator, } from "./types/utils";
20
23
  export type { AIProvider, AILanguageModelSettings, AIReasoningSettings, AIUpstreamProvider, AIUpstreamProviderId, AIUpstreamProviderStatus, } from "./types/ai";
21
24
  export type { SelectedProjectChangeEvent } from "./types/projects";
22
25
  export type { CommandPaletteView } from "./sdks/commandPalette";
@@ -1,5 +1,8 @@
1
1
  import type { Extension } from "@codemirror/state";
2
+ import type { AutomateEntry, AutomateSession } from "src/types/automate";
3
+ import type { AddIndicatorOptions, ID, Indicator } from "src/types/utils";
2
4
  import type { RequestViewModeOptions } from "../types/request";
5
+ import type { ResponseViewModeOptions } from "../types/response";
3
6
  /**
4
7
  * Utilities to interact with the Automate page.
5
8
  * @category Automate
@@ -15,4 +18,38 @@ export type AutomateSDK = {
15
18
  * @param options The view mode options.
16
19
  */
17
20
  addRequestViewMode: (options: RequestViewModeOptions) => void;
21
+ /**
22
+ * Add a custom response view mode.
23
+ * @param options The view mode options.
24
+ */
25
+ addResponseViewMode: (options: ResponseViewModeOptions) => void;
26
+ /**
27
+ * Get the list of all automate sessions.
28
+ * @returns The list of all automate sessions.
29
+ */
30
+ getSessions: () => AutomateSession[];
31
+ /**
32
+ * Get the list of all automate entries.
33
+ * @param sessionId The ID of the session to get the entries of.
34
+ * @returns The list of all automate entries.
35
+ */
36
+ getEntries: (sessionId: ID) => AutomateEntry[];
37
+ /**
38
+ * Add an indicator to an automate entry.
39
+ * Indicators are displayed next to the entry name in the collections tree.
40
+ * @param entryId The ID of the entry to add the indicator to.
41
+ * @param indicator The indicator configuration.
42
+ * @returns A handle object with a `remove` method to remove the indicator.
43
+ * @example
44
+ *
45
+ * const indicator = sdk.automate.addEntryIndicator(entryId, {
46
+ * icon: "fas fa-exclamation-triangle",
47
+ * description: "Security warning",
48
+ * });
49
+ *
50
+ * // Later, remove the indicator
51
+ * indicator.remove();
52
+ *
53
+ */
54
+ addEntryIndicator: (entryId: ID, indicator: AddIndicatorOptions) => Indicator;
18
55
  };
@@ -1,6 +1,7 @@
1
1
  import type { Extension } from "@codemirror/state";
2
2
  import { type Finding } from "../types/findings";
3
3
  import type { RequestViewModeOptions } from "../types/request";
4
+ import type { ResponseViewModeOptions } from "../types/response";
4
5
  import type { ID } from "../types/utils";
5
6
  /**
6
7
  * Utilities to interact with findings
@@ -33,4 +34,9 @@ export type FindingsSDK = {
33
34
  * @param options The view mode options.
34
35
  */
35
36
  addRequestViewMode: (options: RequestViewModeOptions) => void;
37
+ /**
38
+ * Add a custom response view mode.
39
+ * @param options The view mode options.
40
+ */
41
+ addResponseViewMode: (options: ResponseViewModeOptions) => void;
36
42
  };
@@ -1,6 +1,7 @@
1
1
  import type { Extension } from "@codemirror/state";
2
2
  import type { HTTPHistorySlotContent } from "../types/httpHistory";
3
3
  import type { RequestViewModeOptions } from "../types/request";
4
+ import type { ResponseViewModeOptions } from "../types/response";
4
5
  import { type DefineAddToSlotFn } from "../types/slots";
5
6
  import type { HTTPQL, ID } from "../types/utils";
6
7
  /**
@@ -43,6 +44,11 @@ export type HTTPHistorySDK = {
43
44
  * @param options The view mode options.
44
45
  */
45
46
  addRequestViewMode: (options: RequestViewModeOptions) => void;
47
+ /**
48
+ * Add a custom response view mode.
49
+ * @param options The view mode options.
50
+ */
51
+ addResponseViewMode: (options: ResponseViewModeOptions) => void;
46
52
  /**
47
53
  * Scrolls the HTTP History table to a specific entry.
48
54
  * @param id The ID of the entry to scroll to.
@@ -1,6 +1,6 @@
1
1
  import { type CurrentMatchReplaceRuleChangeEvent, type MatchReplaceCollection, type MatchReplaceRule, type MatchReplaceSection, type MatchReplaceSlotContent, type Source } from "../types/matchReplace";
2
2
  import { type DefineAddToSlotFn } from "../types/slots";
3
- import type { HTTPQL, ID, ListenerHandle } from "../types/utils";
3
+ import type { AddIndicatorOptions, HTTPQL, ID, Indicator, ListenerHandle } from "../types/utils";
4
4
  /**
5
5
  * Utilities to interact with the Match and Replace page.
6
6
  * @category Match and Replace
@@ -138,4 +138,22 @@ export type MatchReplaceSDK = {
138
138
  * ```
139
139
  */
140
140
  addToSlot: DefineAddToSlotFn<MatchReplaceSlotContent>;
141
+ /**
142
+ * Add an indicator to a rule.
143
+ * Indicators are displayed next to the session name in the collections tree.
144
+ * @param ruleId The ID of the rule to add the indicator to.
145
+ * @param indicator The indicator configuration.
146
+ * @returns A handle object with a `remove` method to remove the indicator.
147
+ * @example
148
+ *
149
+ * const indicator = sdk.matchReplace.addRuleIndicator(ruleId, {
150
+ * icon: "fas fa-exclamation-triangle",
151
+ * description: "Security warning",
152
+ * });
153
+ *
154
+ * // Later, remove the indicator
155
+ * indicator.remove();
156
+ *
157
+ */
158
+ addRuleIndicator: (ruleId: ID, indicator: AddIndicatorOptions) => Indicator;
141
159
  };
@@ -1,8 +1,8 @@
1
1
  import { type Extension } from "@codemirror/state";
2
- import { type AddSessionIndicatorOptions, type CurrentReplaySessionChangeEvent, type OpenTabOptions, type ReplayCollection, type ReplayCollectionCreatedEvent, type ReplayEntry, type ReplaySession, type ReplaySessionCreatedEvent, type ReplaySlotContent, type ReplayTab, type RequestSource, type SendRequestOptions, type SessionIndicator } from "../types/replay";
2
+ import { type CurrentReplaySessionChangeEvent, type OpenTabOptions, type ReplayCollection, type ReplayCollectionCreatedEvent, type ReplayEntry, type ReplaySession, type ReplaySessionCreatedEvent, type ReplaySlotContent, type ReplayTab, type RequestSource, type SendRequestOptions } from "../types/replay";
3
3
  import type { RequestViewModeOptions } from "../types/request";
4
4
  import { type DefineAddToSlotFn } from "../types/slots";
5
- import type { ID, ListenerHandle } from "../types/utils";
5
+ import type { AddIndicatorOptions, ID, Indicator, ListenerHandle } from "../types/utils";
6
6
  /**
7
7
  * Utilities to interact with Replay.
8
8
  * @category Replay
@@ -241,5 +241,5 @@ export type ReplaySDK = {
241
241
  * indicator.remove();
242
242
  *
243
243
  */
244
- addSessionIndicator: (sessionId: ID, indicator: AddSessionIndicatorOptions) => SessionIndicator;
244
+ addSessionIndicator: (sessionId: ID, indicator: AddIndicatorOptions) => Indicator;
245
245
  };
@@ -1,5 +1,6 @@
1
1
  import type { Extension } from "@codemirror/state";
2
2
  import type { RequestViewModeOptions } from "../types/request";
3
+ import type { ResponseViewModeOptions } from "../types/response";
3
4
  import type { SearchSlot, SearchSlotContent } from "../types/search";
4
5
  import type { HTTPQL, ID } from "../types/utils";
5
6
  /**
@@ -37,6 +38,11 @@ export type SearchSDK = {
37
38
  * @param options The view mode options.
38
39
  */
39
40
  addRequestViewMode: (options: RequestViewModeOptions) => void;
41
+ /**
42
+ * Add a custom response view mode.
43
+ * @param options The view mode options.
44
+ */
45
+ addResponseViewMode: (options: ResponseViewModeOptions) => void;
40
46
  /**
41
47
  * Scrolls the Search table to a specific request.
42
48
  * @param id The ID of the request to scroll to.
@@ -1,11 +1,39 @@
1
1
  import type { Extension } from "@codemirror/state";
2
2
  import type { RequestViewModeOptions } from "../types/request";
3
- import type { ID } from "../types/utils";
3
+ import type { ResponseViewModeOptions } from "../types/response";
4
+ import type { SitemapEntry, SitemapEntryChildStateUpdateEvent, SitemapRootEntry } from "../types/sitemap";
5
+ import type { AddIndicatorOptions, ID, Indicator, ListenerHandle } from "../types/utils";
4
6
  /**
5
7
  * Utilities to interact with the Sitemap page.
6
8
  * @category Sitemap
7
9
  */
8
10
  export type SitemapSDK = {
11
+ /**
12
+ * Listen for child state updates on a sitemap entry.
13
+ * @param callback The callback function that receives the entry ID and new child state.
14
+ * @returns A handle object with a `stop` method to stop listening.
15
+ * @example
16
+ *
17
+ * const handle = sdk.sitemap.onEntryChildStateUpdate((entryId, newChildState) => {
18
+ * console.log(`Entry ${entryId} child state changed:`, newChildState);
19
+ * });
20
+ *
21
+ * // Later, stop listening
22
+ * handle.stop();
23
+ */
24
+ onEntryChildStateUpdate: (callback: (event: SitemapEntryChildStateUpdateEvent) => void) => ListenerHandle;
25
+ /**
26
+ * Get the list of all sitemap entries in tree format.
27
+ * @returns The list of all sitemap entries.
28
+ */
29
+ getTreeEntries: () => SitemapRootEntry[];
30
+ /**
31
+ * Load children for a sitemap entry.
32
+ * This will fetch and load children if they haven't been loaded yet.
33
+ * @param entryId The ID of the entry to load children for.
34
+ * @returns Promise that resolves when children are loaded.
35
+ */
36
+ getChildren: (entryId: ID) => Promise<SitemapEntry[]>;
9
37
  /**
10
38
  * Get the current scope ID.
11
39
  * @returns The current scope ID.
@@ -26,4 +54,27 @@ export type SitemapSDK = {
26
54
  * @param options The view mode options.
27
55
  */
28
56
  addRequestViewMode: (options: RequestViewModeOptions) => void;
57
+ /**
58
+ * Add a custom response view mode.
59
+ * @param options The view mode options.
60
+ */
61
+ addResponseViewMode: (options: ResponseViewModeOptions) => void;
62
+ /**
63
+ * Add an indicator to a sitemap session.
64
+ * Indicators are displayed next to the entry name in the collections tree.
65
+ * @param entryId The ID of the entry to add the indicator to.
66
+ * @param indicator The indicator configuration.
67
+ * @returns A handle object with a `remove` method to remove the indicator.
68
+ * @example
69
+ *
70
+ * const indicator = sdk.sitemap.addEntryIndicator(entryId, {
71
+ * icon: "fas fa-exclamation-triangle",
72
+ * description: "Security warning",
73
+ * });
74
+ *
75
+ * // Later, remove the indicator
76
+ * indicator.remove();
77
+ *
78
+ */
79
+ addEntryIndicator: (entryId: ID, indicator: AddIndicatorOptions) => Indicator;
29
80
  };
@@ -0,0 +1,41 @@
1
+ import type { ID } from "./utils";
2
+ /**
3
+ * A automate session.
4
+ * @category Automate
5
+ */
6
+ export type AutomateSession = {
7
+ /**
8
+ * The ID of the session.
9
+ */
10
+ id: ID;
11
+ /**
12
+ * The name of the session.
13
+ */
14
+ name: string;
15
+ /**
16
+ * The date the session was created.
17
+ */
18
+ createdAt: Date;
19
+ /**
20
+ * The IDs of all entries in this session.
21
+ */
22
+ entryIds: ID[];
23
+ };
24
+ /**
25
+ * A automate entry.
26
+ * @category Automate
27
+ */
28
+ export type AutomateEntry = {
29
+ /**
30
+ * The ID of the entry.
31
+ */
32
+ id: ID;
33
+ /**
34
+ * The name of the entry.
35
+ */
36
+ name: string;
37
+ /**
38
+ * The date the entry was created.
39
+ */
40
+ createdAt: Date;
41
+ };
@@ -218,19 +218,3 @@ export type ReplayCollectionCreatedEvent = {
218
218
  */
219
219
  collection: ReplayCollection;
220
220
  };
221
- /**
222
- * Visual indicator displayed next to a session label in the replay tree component.
223
- * Includes an icon and an associated description.
224
- * @category Replay
225
- */
226
- export type AddSessionIndicatorOptions = {
227
- icon: string;
228
- description: string;
229
- };
230
- /**
231
- * Providing operations that can be performed on a session indicator.
232
- * @category Replay
233
- */
234
- export type SessionIndicator = {
235
- remove: () => void;
236
- };
@@ -0,0 +1,27 @@
1
+ import type { As, ComponentDefinition, ID, Prettify } from "./utils";
2
+ /**
3
+ * A complete response with all metadata and raw content.
4
+ * @category Response
5
+ */
6
+ export type ResponseFull = Prettify<As<"ResponseFull"> & {
7
+ id: ID;
8
+ raw: string;
9
+ statusCode: number;
10
+ roundtripTime: number;
11
+ length: number;
12
+ createdAt: Date;
13
+ }>;
14
+ /**
15
+ * Options for defining a custom response view mode.
16
+ * @category Response
17
+ */
18
+ export type ResponseViewModeOptions = {
19
+ /**
20
+ * The label of the view mode.
21
+ */
22
+ label: string;
23
+ /**
24
+ * The component to render when the view mode is selected.
25
+ */
26
+ view: ComponentDefinition;
27
+ };
@@ -0,0 +1,87 @@
1
+ import { type ID } from "./utils";
2
+ /**
3
+ * An entry in sitemap.
4
+ * @category Sitemap
5
+ */
6
+ export type SitemapEntry = {
7
+ /**
8
+ * The ID of the entry.
9
+ */
10
+ id: ID;
11
+ /**
12
+ * The label of the entry.
13
+ */
14
+ label: string;
15
+ /**
16
+ * The kind of the entry.
17
+ */
18
+ kind: SitemapEntryKind;
19
+ /**
20
+ * The ID of the parent entry.
21
+ */
22
+ parentId?: ID;
23
+ /**
24
+ * The child state of the entry.
25
+ */
26
+ childState: ChildState;
27
+ };
28
+ export type SitemapRootEntry = {
29
+ /**
30
+ * The ID of the entry.
31
+ */
32
+ id: ID;
33
+ /**
34
+ * The label of the entry.
35
+ */
36
+ label: string;
37
+ /**
38
+ * The child state of the entry.
39
+ */
40
+ childState: ChildState;
41
+ };
42
+ /**
43
+ * The kind of a sitemap entry.
44
+ * @category Sitemap
45
+ */
46
+ export declare const SitemapEntryKind: {
47
+ readonly Directory: "DIRECTORY";
48
+ readonly Domain: "DOMAIN";
49
+ readonly Request: "REQUEST";
50
+ readonly RequestBody: "REQUEST_BODY";
51
+ readonly RequestQuery: "REQUEST_QUERY";
52
+ };
53
+ /**
54
+ * The kind of a sitemap entry.
55
+ * @category Sitemap
56
+ * @example
57
+ * ```ts
58
+ * const entry = {
59
+ * id: "123",
60
+ * label: "Example",
61
+ * kind: SitemapEntryKind.Request,
62
+ * };
63
+ * ```
64
+ */
65
+ export type SitemapEntryKind = (typeof SitemapEntryKind)[keyof typeof SitemapEntryKind];
66
+ export type ChildState = {
67
+ kind: "Empty";
68
+ } | {
69
+ kind: "NotLoaded";
70
+ } | {
71
+ kind: "Loaded";
72
+ items: ID[];
73
+ };
74
+ /**
75
+ * Event fired when the child state of a sitemap entry changes.
76
+ * @category Sitemap
77
+ */
78
+ export type SitemapEntryChildStateUpdateEvent = {
79
+ /**
80
+ * The ID of the entry that changed.
81
+ */
82
+ entryId: ID;
83
+ /**
84
+ * The new child state of the entry.
85
+ */
86
+ newChildState: ChildState;
87
+ };
@@ -60,3 +60,19 @@ export type Prettify<T> = {
60
60
  export type As<TType extends string> = {
61
61
  type: TType;
62
62
  };
63
+ /**
64
+ * Visual indicator displayed next to a item label in a tree component.
65
+ * Includes an icon and an associated description.
66
+ * @category Utils
67
+ */
68
+ export type AddIndicatorOptions = {
69
+ icon: Icon;
70
+ description: string;
71
+ };
72
+ /**
73
+ * Providing operations that can be performed on a item indicator.
74
+ * @category Utils
75
+ */
76
+ export type Indicator = {
77
+ remove: () => void;
78
+ };