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

Fixes agent interceptor registration broken by dependency update

---------

Co-authored-by: James George <25279263+jamesgeorge007@users.noreply.github.com>
This commit is contained in:
Shreyas 2025-11-25 14:44:41 +05:30 committed by GitHub
parent e63bfe3723
commit 017341928c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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,