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.
This commit is contained in:
Claude
2026-01-22 20:51:43 +00:00
parent 3d4ba16dc5
commit 7d2a1fc540
+9 -9
View File
@@ -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')