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 9a8d081b..6b2fd605 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 + request: Omit ): 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 { - 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 { - 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,