mirror of
https://github.com/nbd-wtf/nostr-tools.git
synced 2025-12-08 16:28:49 +00:00
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:
5
nip04.js
5
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')
|
||||
|
||||
@@ -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": [
|
||||
|
||||
Reference in New Issue
Block a user