fix: align noise-handler buffer types for TypeScript

fix: align noise-handler buffer types for TypeScript
This commit is contained in:
Renato Alcara
2026-01-22 17:55:16 -03:00
committed by GitHub
+9 -9
View File
@@ -64,9 +64,9 @@ export const makeNoiseHandler = ({
const data = Buffer.from(NOISE_MODE) const data = Buffer.from(NOISE_MODE)
let hash = data.byteLength === 32 ? data : sha256(data) let hash = data.byteLength === 32 ? data : sha256(data)
let salt = hash let salt: Buffer = hash
let encKey = hash let encKey: Buffer = hash
let decKey = hash let decKey: Buffer = hash
let counter = 0 let counter = 0
let sentIntro = false let sentIntro = false
@@ -116,23 +116,23 @@ export const makeNoiseHandler = ({
return result 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: '' }) 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 mixIntoKey = async (data: Uint8Array) => {
const [write, read] = await localHKDF(data) const [write, read] = await localHKDF(data)
salt = write! salt = write
encKey = read! encKey = read
decKey = read! decKey = read
counter = 0 counter = 0
} }
const finishInit = async () => { const finishInit = async () => {
isWaitingForTransport = true isWaitingForTransport = true
const [write, read] = await localHKDF(new Uint8Array(0)) const [write, read] = await localHKDF(new Uint8Array(0))
transport = new TransportState(write!, read!) transport = new TransportState(write, read)
isWaitingForTransport = false isWaitingForTransport = false
logger.trace('Noise handler transitioned to Transport state') logger.trace('Noise handler transitioned to Transport state')