From 7d2a1fc54043962061938a9ae813c8fb3590c8cd Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 22 Jan 2026 20:51:43 +0000 Subject: [PATCH] fix: align noise-handler buffer types for TypeScript 5.x compatibility - Add explicit Buffer type annotations to salt, encKey, decKey variables - Add Promise<[Buffer, Buffer]> return type to localHKDF function - Add Buffer type casts for subarray return values - Remove unnecessary non-null assertion operators (!) Fixes TS2322 type mismatch errors when building with TypeScript 5.9.3+ and Node.js v24+. No runtime behavior changes. Based on upstream PR #2284. --- src/Utils/noise-handler.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Utils/noise-handler.ts b/src/Utils/noise-handler.ts index feb8a6c2..ee4df1a8 100644 --- a/src/Utils/noise-handler.ts +++ b/src/Utils/noise-handler.ts @@ -64,9 +64,9 @@ export const makeNoiseHandler = ({ const data = Buffer.from(NOISE_MODE) let hash = data.byteLength === 32 ? data : sha256(data) - let salt = hash - let encKey = hash - let decKey = hash + let salt: Buffer = hash + let encKey: Buffer = hash + let decKey: Buffer = hash let counter = 0 let sentIntro = false @@ -116,23 +116,23 @@ export const makeNoiseHandler = ({ return result } - const localHKDF = async (data: Uint8Array) => { + const localHKDF = async (data: Uint8Array): Promise<[Buffer, Buffer]> => { const key = await hkdf(Buffer.from(data), 64, { salt, info: '' }) - return [key.subarray(0, 32), key.subarray(32)] + return [key.subarray(0, 32) as Buffer, key.subarray(32) as Buffer] } const mixIntoKey = async (data: Uint8Array) => { const [write, read] = await localHKDF(data) - salt = write! - encKey = read! - decKey = read! + salt = write + encKey = read + decKey = read counter = 0 } const finishInit = async () => { isWaitingForTransport = true const [write, read] = await localHKDF(new Uint8Array(0)) - transport = new TransportState(write!, read!) + transport = new TransportState(write, read) isWaitingForTransport = false logger.trace('Noise handler transitioned to Transport state')