From c907642dc57787de1a24ba6339d27d5f9a406cef Mon Sep 17 00:00:00 2001 From: Mohit Davar Date: Fri, 10 Apr 2026 22:26:54 +0530 Subject: [PATCH] fix: resolve typescript buffer-to-uint8array type mismatches Fixes #444 --- src/utils/event.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/utils/event.ts b/src/utils/event.ts index 1bdde933..688b4dfc 100644 --- a/src/utils/event.ts +++ b/src/utils/event.ts @@ -103,7 +103,7 @@ export const isEventMatchingFilter = (filter: SubscriptionFilter) => (event: Eve } export const getEventHash = async (event: Event | UnidentifiedEvent | UnsignedEvent): Promise => { - const id = await secp256k1.utils.sha256(Buffer.from(JSON.stringify(serializeEvent(event)))) + const id = await secp256k1.utils.sha256(new Uint8Array(Buffer.from(JSON.stringify(serializeEvent(event))))) return Buffer.from(id).toString('hex') } @@ -160,7 +160,7 @@ export const encryptKind4Event = ( receiverPubkey: Pubkey, ) => (event: UnsignedEvent): UnsignedEvent => { const key = secp256k1 - .getSharedSecret(senderPrivkey, `02${receiverPubkey}`, true) + .getSharedSecret(typeof senderPrivkey === 'string' ? senderPrivkey : new Uint8Array(senderPrivkey), `02${receiverPubkey}`, true) .subarray(1) const iv = getRandomValues(new Uint8Array(16)) @@ -168,7 +168,7 @@ export const encryptKind4Event = ( // deepcode ignore InsecureCipherNoIntegrity: NIP-04 Encrypted Direct Message uses aes-256-cbc const cipher = createCipheriv( 'aes-256-cbc', - Buffer.from(key), + new Uint8Array(key), iv, )