Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia
TypeScript apiapi-clientapi-restapi-testingdeveloper-toolsgraphqlhttphttp-clientpwarestrest-apispatestingtesting-toolstoolsvuevuejswebsocket
fix: import bug with extension and agent interceptors (#4932)
Nivedinfb2b677fafdc
diff --git a/packages/hoppscotch-common/src/components.d.ts b/packages/hoppscotch-common/src/components.d.tsindex 8d304cbfe..4ea41f4ad 100644--- a/packages/hoppscotch-common/src/components.d.ts+++ b/packages/hoppscotch-common/src/components.d.ts@@ -205,7 +205,6 @@ declare module 'vue' {IconLucideArrowLeft: typeof import('~icons/lucide/arrow-left')['default']IconLucideArrowUpRight: typeof import('~icons/lucide/arrow-up-right')['default']IconLucideBrush: typeof import('~icons/lucide/brush')['default']- IconLucideCheck: typeof import('~icons/lucide/check')['default']IconLucideCheckCircle: typeof import('~icons/lucide/check-circle')['default']IconLucideChevronRight: typeof import('~icons/lucide/chevron-right')['default']IconLucideCircleCheck: typeof import('~icons/lucide/circle-check')['default']@@ -216,7 +215,6 @@ declare module 'vue' {IconLucideLayers: typeof import('~icons/lucide/layers')['default']IconLucideListEnd: typeof import('~icons/lucide/list-end')['default']IconLucideMinus: typeof import('~icons/lucide/minus')['default']- IconLucidePlus: typeof import('~icons/lucide/plus')['default']IconLucidePlusCircle: typeof import('~icons/lucide/plus-circle')['default']IconLucideRss: typeof import('~icons/lucide/rss')['default']IconLucideSearch: typeof import('~icons/lucide/search')['default']diff --git a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/agent/index.ts b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/agent/index.tsindex 292469b1d..9a377d425 100644--- a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/agent/index.ts+++ b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/agent/index.ts@@ -132,8 +132,24 @@ export class AgentKernelInterceptorService.join(";")}+ const existingUserAgentHeader = Object.keys(+ effectiveRequest.headers || {}+ ).find((header) => header.toLowerCase() === "user-agent")++ // A temporary workaround to add a User-Agent header to the request+ // This will be removed once the agent is updated to add User-Agent header by default+ const effectiveRequestWithUserAgent = {+ ...effectiveRequest,+ headers: {+ ...effectiveRequest.headers,+ "User-Agent": existingUserAgentHeader+ ? effectiveRequest.headers[existingUserAgentHeader]+ : "HoppscotchKernel/0.1.0",+ },+ }+const [nonceB16, encryptedReq] = await this.store.encryptRequest(- await relayRequestToNativeAdapter(effectiveRequest),+ await relayRequestToNativeAdapter(effectiveRequestWithUserAgent),reqID)diff --git a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/index.ts b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/index.tsindex 7a733e2f2..0c377203d 100644--- a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/index.ts+++ b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/extension/index.ts@@ -276,7 +276,7 @@ export class ExtensionKernelInterceptorServiceawait window.__POSTWOMAN_EXTENSION_HOOK__.sendRequest({url: request.url,method: request.method,- headers: request.headers,+ headers: request.headers ?? {},data: requestData,wantsBinary: true,})diff --git a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/native/index.ts b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/native/index.tsindex b356b8993..f60977d1f 100644--- a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/native/index.ts+++ b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/native/index.ts@@ -83,7 +83,23 @@ export class NativeKernelInterceptorService.join(";")}- const relayExecution = Relay.execute(effectiveRequest)+ const existingUserAgentHeader = Object.keys(+ effectiveRequest.headers || {}+ ).find((header) => header.toLowerCase() === "user-agent")++ // A temporary workaround to add a User-Agent header to the request+ // This will be removed once the kernel/relay is updated to add User-Agent header by default+ const effectiveRequestWithUserAgent = {+ ...effectiveRequest,+ headers: {+ ...effectiveRequest.headers,+ "User-Agent": existingUserAgentHeader+ ? effectiveRequest.headers[existingUserAgentHeader]+ : "HoppscotchKernel/0.1.0",+ },+ }++ const relayExecution = Relay.execute(effectiveRequestWithUserAgent)const response = pipe(relayExecution.response, (promise) =>promise.then((either) =>