From f1980f895da48f39e48825720ca9b082a89f4fb6 Mon Sep 17 00:00:00 2001 From: Emile Fugulin Date: Tue, 3 Sep 2024 15:22:57 -0400 Subject: [PATCH] Add new APIs in caido sdks --- packages/quickjs-types/package.json | 2 +- packages/quickjs-types/src/caido/index.d.ts | 38 +++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletion(-) diff --git a/packages/quickjs-types/package.json b/packages/quickjs-types/package.json index 95a911a..d668465 100644 --- a/packages/quickjs-types/package.json +++ b/packages/quickjs-types/package.json @@ -1,6 +1,6 @@ { "name": "@caido/quickjs-types", - "version": "0.4.0", + "version": "0.5.0", "description": "Typing for the QuickJS Engine", "author": "Caido Labs Inc. ", "license": "MIT", diff --git a/packages/quickjs-types/src/caido/index.d.ts b/packages/quickjs-types/src/caido/index.d.ts index 09e1c2e..df82d2f 100644 --- a/packages/quickjs-types/src/caido/index.d.ts +++ b/packages/quickjs-types/src/caido/index.d.ts @@ -116,6 +116,14 @@ declare module "caido:utils" { response: Response; }; + /** + * An immutable saved Request and optional Response pair. + */ + export type RequestResponseOpt = { + request: Request; + response?: Response | undefined; + }; + /** * Information on the current page of paginated data. */ @@ -218,6 +226,13 @@ declare module "caido:utils" { * sdk.console.log(`ID: ${page.items[1].request.getId()}`); */ query(): RequestsQuery; + /** + * Get a request by its unique {@link ID}. + * + * @example + * await sdk.requests.get("1"); + */ + get(id: ID): Promise; /** * Sends a request. * @@ -298,10 +313,33 @@ declare module "caido:utils" { request: Request; }; + export type GetFindingInput = { + /** + * The name of the reporter. + */ + reporter?: string | undefined; + /** + * The associated {@link Request}. + */ + request: Request; + }; + /** * The SDK for the Findings service. */ export type FindingsSDK = { + /** + * Try to get a {@link Finding} for a request. + * Since a request can have multiple findings, this will return the first one found. + * You can also filter by reporter to get a specific finding. + * + * @example + * await sdk.findings.get({ + * reporter: "Reporter", + * request, + * }); + */ + get(input: GetFindingInput): Promise; /** * Creates a new Finding. *