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
This commit is contained in:
+1
-1
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user