From 5a44ec6ba092b87e19df5fd83c8a0d69f27f1351 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 28 Feb 2026 02:07:48 +0000 Subject: [PATCH 1/3] fix(types): replace any with unknown for response in broker-protection types.js https://claude.ai/code/session_01QaZ2NFE7y5u8YdZhjoc79m --- injected/src/features/broker-protection/types.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/injected/src/features/broker-protection/types.js b/injected/src/features/broker-protection/types.js index 58c4cbe7627..1e93944e39f 100644 --- a/injected/src/features/broker-protection/types.js +++ b/injected/src/features/broker-protection/types.js @@ -134,7 +134,7 @@ export class ErrorResponse { * @typedef {object} SuccessResponseInterface * @property {PirAction['id']} actionID * @property {PirAction['actionType']} actionType - * @property {any} response + * @property {unknown} response * @property {import("./actions/extract").Action[]} [next] * @property {Record} [meta] - optional meta data */ From e9d77de547db15953b667f8016b1810f143e6eba Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 2 Mar 2026 12:05:49 +0000 Subject: [PATCH 2/3] fix: add type assertions for spread of unknown response in navigate.js The change from any to unknown on SuccessResponseInterface.response caused TS2698 (spread types may only be created from object types) at lines 26-27 of navigate.js. Assert as Record at the spread sites since both buildUrl and getSupportingCodeToInject always return object-typed responses. Co-authored-by: Jonathan Kingston --- injected/src/features/broker-protection/actions/navigate.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/injected/src/features/broker-protection/actions/navigate.js b/injected/src/features/broker-protection/actions/navigate.js index 4a16d5da2da..178a6c8b2de 100644 --- a/injected/src/features/broker-protection/actions/navigate.js +++ b/injected/src/features/broker-protection/actions/navigate.js @@ -23,8 +23,8 @@ export function navigate(action, userData) { } const response = { - ...urlResult.success.response, - ...codeToInjectResponse.success.response, + .../** @type {Record} */ (urlResult.success.response), + .../** @type {Record} */ (codeToInjectResponse.success.response), }; return new SuccessResponse({ actionID, actionType, response }); From edadca5261e50adbd2d99ea0b2e68366d7bc9937 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Tue, 3 Mar 2026 10:56:47 +0000 Subject: [PATCH 3/3] refactor: make SuccessResponse generic instead of casting in navigate.js Replace the Record casts with proper generics: - SuccessResponseInterface and SuccessResponse (default unknown), matching the existing PirSuccess pattern in the same file - buildUrl returns SuccessResponse<{url: string}> | ErrorResponse - getSupportingCodeToInject returns SuccessResponse<{code?: string | null}> | ErrorResponse - navigate.js spreads work without casts via TypeScript inference Co-authored-by: Jonathan Kingston --- .../features/broker-protection/actions/build-url.js | 2 +- .../features/broker-protection/actions/navigate.js | 4 ++-- .../captcha-services/captcha.service.js | 2 +- injected/src/features/broker-protection/types.js | 11 +++++++---- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/injected/src/features/broker-protection/actions/build-url.js b/injected/src/features/broker-protection/actions/build-url.js index 5a83333090e..11ae3acb0a7 100644 --- a/injected/src/features/broker-protection/actions/build-url.js +++ b/injected/src/features/broker-protection/actions/build-url.js @@ -6,7 +6,7 @@ import { ErrorResponse, SuccessResponse } from '../types.js'; * * @param action * @param {Record} userData - * @return {import('../types.js').ActionResponse} + * @return {import('../types.js').SuccessResponse<{url: string}> | import('../types.js').ErrorResponse} */ export function buildUrl(action, userData) { const result = replaceTemplatedUrl(action, userData); diff --git a/injected/src/features/broker-protection/actions/navigate.js b/injected/src/features/broker-protection/actions/navigate.js index 178a6c8b2de..4a16d5da2da 100644 --- a/injected/src/features/broker-protection/actions/navigate.js +++ b/injected/src/features/broker-protection/actions/navigate.js @@ -23,8 +23,8 @@ export function navigate(action, userData) { } const response = { - .../** @type {Record} */ (urlResult.success.response), - .../** @type {Record} */ (codeToInjectResponse.success.response), + ...urlResult.success.response, + ...codeToInjectResponse.success.response, }; return new SuccessResponse({ actionID, actionType, response }); diff --git a/injected/src/features/broker-protection/captcha-services/captcha.service.js b/injected/src/features/broker-protection/captcha-services/captcha.service.js index 6200f621d21..42bc7572f0c 100644 --- a/injected/src/features/broker-protection/captcha-services/captcha.service.js +++ b/injected/src/features/broker-protection/captcha-services/captcha.service.js @@ -28,7 +28,7 @@ const getCaptchaContainer = (root, selector) => { * Returns the supporting code to inject for the given captcha type * * @param {import('../types.js').PirAction} action - * @return {import('../types.js').ActionResponse} + * @return {import('../types.js').SuccessResponse<{code?: string | null}> | import('../types.js').ErrorResponse} */ export function getSupportingCodeToInject(action) { const { id: actionID, actionType, injectCaptchaHandler: captchaType } = action; diff --git a/injected/src/features/broker-protection/types.js b/injected/src/features/broker-protection/types.js index 1e93944e39f..37383abf856 100644 --- a/injected/src/features/broker-protection/types.js +++ b/injected/src/features/broker-protection/types.js @@ -131,28 +131,31 @@ export class ErrorResponse { } /** + * @template [T=unknown] * @typedef {object} SuccessResponseInterface * @property {PirAction['id']} actionID * @property {PirAction['actionType']} actionType - * @property {unknown} response + * @property {T} response * @property {import("./actions/extract").Action[]} [next] * @property {Record} [meta] - optional meta data */ /** * Represents success, `response` can contain other complex types + * @template [T=unknown] */ export class SuccessResponse { /** - * @param {SuccessResponseInterface} params + * @param {SuccessResponseInterface} params */ constructor(params) { this.success = params; } /** - * @param {SuccessResponseInterface} params - * @return {SuccessResponse} + * @template T + * @param {SuccessResponseInterface} params + * @return {SuccessResponse} * @static * @memberof SuccessResponse */