From 85cfb6a6421709cfdc5cbc50c53e07068e0e2138 Mon Sep 17 00:00:00 2001 From: Claude Date: Sun, 8 Feb 2026 21:26:21 +0000 Subject: [PATCH] fix: address PR review - type consistency and runtime safety - crypto.ts: widen aesEncrypWithIV params to Uint8Array for consistency with other AES helpers (Copilot review comment #1) - noise-handler.ts: replace unsafe `as Buffer` type assertions with Buffer.from() for proper runtime conversion (Copilot review comment #2) https://claude.ai/code/session_01Ffc5YrPuqv8N9SwEuSM8mr --- src/Utils/crypto.ts | 2 +- src/Utils/noise-handler.ts | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Utils/crypto.ts b/src/Utils/crypto.ts index de3985d3..9152b01f 100644 --- a/src/Utils/crypto.ts +++ b/src/Utils/crypto.ts @@ -100,7 +100,7 @@ export function aesEncrypt(buffer: Buffer | Uint8Array, key: Uint8Array) { } // encrypt AES 256 CBC with a given IV -export function aesEncrypWithIV(buffer: Buffer, key: Buffer, IV: Buffer) { +export function aesEncrypWithIV(buffer: Buffer | Uint8Array, key: Uint8Array, IV: Uint8Array) { const aes = createCipheriv('aes-256-cbc', key, IV) return Buffer.concat([aes.update(buffer), aes.final()]) // prefix IV to the buffer } diff --git a/src/Utils/noise-handler.ts b/src/Utils/noise-handler.ts index b0fee3e9..f8a36c76 100644 --- a/src/Utils/noise-handler.ts +++ b/src/Utils/noise-handler.ts @@ -123,9 +123,9 @@ export const makeNoiseHandler = ({ const mixIntoKey = (data: Uint8Array) => { const [write, read] = localHKDF(data) - salt = write as Buffer - encKey = read as Buffer - decKey = read as Buffer + salt = Buffer.from(write) + encKey = Buffer.from(read) + decKey = Buffer.from(read) counter = 0 }