use browserify-cipher for aes.

it seems everybody was including this by default before, but now webpack and others are not.
This commit is contained in:
fiatjaf
2021-12-18 20:30:54 -03:00
parent d8eee25e3a
commit 7b0220c1b8
2 changed files with 8 additions and 6 deletions

View File

@@ -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')

View File

@@ -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": [