Skip to content

Open-Source API Development Ecosystem • https://hoppscotch.io • Offline, On-Prem & Cloud • Web, Desktop & CLI • Open-Source Alternative to Postman, Insomnia

fix(common): agent interceptor dependency compat (#5613)

Shreyas017341928caa
diff --git a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/agent/store.ts b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/agent/store.ts
index 9a8d081bc..6b2fd6056 100644
--- a/packages/hoppscotch-common/src/platform/std/kernel-interceptors/agent/store.ts
+++ b/packages/hoppscotch-common/src/platform/std/kernel-interceptors/agent/store.ts
@@ -95,7 +95,7 @@ export class KernelInterceptorAgentStore extends Service {
private async setupWatchers() {
const watcher = await Store.watch(STORE_NAMESPACE, STORE_KEYS.SETTINGS)
- watcher.on("change", async ({ value }) => {
+ watcher.on("change", async ({ value }: { value: unknown }) => {
if (value) {
const store = value as StoredData
this.domainSettings = new Map(Object.entries(store.domains))
@@ -182,7 +182,7 @@ export class KernelInterceptorAgentStore extends Service {
}
public completeRequest(
- request: Omit<RelayRequest, "proxy" | "security" | "meta">
+ request: Omit<PluginRequest, "proxy" | "security" | "meta">
): PluginRequest {
const host = new URL(request.url).host
const settings = this.getMergedSettings(host)
@@ -228,7 +228,7 @@ export class KernelInterceptorAgentStore extends Service {
}
public async verifyRegistration(otp: string): Promise<void> {
- const myPrivateKey = x25519.utils.randomPrivateKey()
+ const myPrivateKey = crypto.getRandomValues(new Uint8Array(32))
const myPublicKey = x25519.getPublicKey(myPrivateKey)
const myPublicKeyB16 = base16.encode(myPublicKey).toLowerCase()
@@ -246,7 +246,9 @@ export class KernelInterceptorAgentStore extends Service {
if (typeof newAuthKey !== "string")
throw new Error("Invalid auth key received")
- const agentPublicKey = base16.decode(agentPublicKeyB16.toUpperCase())
+ const agentPublicKey = new Uint8Array(
+ base16.decode(agentPublicKeyB16.toUpperCase())
+ )
const sharedSecret = x25519.getSharedSecret(myPrivateKey, agentPublicKey)
const sharedSecretB16 = base16.encode(sharedSecret).toLowerCase()
@@ -293,8 +295,8 @@ export class KernelInterceptorAgentStore extends Service {
const nonce = window.crypto.getRandomValues(new Uint8Array(12))
const nonceB16 = base16.encode(nonce).toLowerCase()
- const sharedSecretKeyBytes = base16.decode(
- this.sharedSecretB16.value!.toUpperCase()
+ const sharedSecretKeyBytes = new Uint8Array(
+ base16.decode(this.sharedSecretB16.value!.toUpperCase())
)
const sharedSecretKey = await window.crypto.subtle.importKey(
"raw",
@@ -317,11 +319,10 @@ export class KernelInterceptorAgentStore extends Service {
nonceB16: string,
encryptedResponse: ArrayBuffer
): Promise<PluginResponse> {
- const nonce = base16.decode(nonceB16.toUpperCase())
- const sharedSecretKeyBytes = base16.decode(
- this.sharedSecretB16.value!.toUpperCase()
+ const nonce = new Uint8Array(base16.decode(nonceB16.toUpperCase()))
+ const sharedSecretKeyBytes = new Uint8Array(
+ base16.decode(this.sharedSecretB16.value!.toUpperCase())
)
-
const sharedSecretKey = await window.crypto.subtle.importKey(
"raw",
sharedSecretKeyBytes,