diff --git a/nip04.js b/nip04.js index cd3c4cb..39c5d16 100644 --- a/nip04.js +++ b/nip04.js @@ -1,3 +1,4 @@ +import aes from 'browserify-cipher' import {Buffer} from 'buffer' import randomBytes from 'randombytes' import * as secp256k1 from '@noble/secp256k1' @@ -7,7 +8,7 @@ export function encrypt(privkey, pubkey, text) { const normalizedKey = getOnlyXFromFullSharedSecret(key) let iv = Uint8Array.from(randomBytes(16)) - var cipher = crypto.createCipheriv( + var cipher = aes.createCipheriv( 'aes-256-cbc', Buffer.from(normalizedKey, 'hex'), iv @@ -22,7 +23,7 @@ export function decrypt(privkey, pubkey, ciphertext, iv) { const key = secp256k1.getSharedSecret(privkey, '02' + pubkey) const normalizedKey = getOnlyXFromFullSharedSecret(key) - var decipher = crypto.createDecipheriv( + var decipher = aes.createDecipheriv( 'aes-256-cbc', Buffer.from(normalizedKey, 'hex'), Buffer.from(iv, 'base64') diff --git a/package.json b/package.json index 3050a6e..9428707 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "nostr-tools", - "version": "0.10.3", + "version": "0.11.0", "description": "Tools for making a Nostr client.", "repository": { "type": "git", @@ -9,10 +9,11 @@ "dependencies": { "@noble/secp256k1": "^1.3.0", "bip39": "^3.0.4", - "buffer": "^6.0.3", - "create-hmac": "^1.1.7", + "browserify-cipher": ">=1", + "buffer": ">=5", + "create-hmac": ">=1", "dns-packet": "^5.2.4", - "randombytes": "^2.1.0", + "randombytes": ">=2", "websocket-polyfill": "^0.0.3" }, "keywords": [