nostr-tools 0.6.5 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +0 -2
- package/nip04.js +2 -1
- package/nip06.js +16 -0
- package/package.json +4 -1
- package/rollup.config.js +0 -16
package/index.js
CHANGED
package/nip04.js
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import {Buffer} from 'buffer'
|
|
2
|
+
import randomBytes from 'randombytes'
|
|
2
3
|
import * as secp256k1 from '@noble/secp256k1'
|
|
3
4
|
|
|
4
5
|
export function encrypt(privkey, pubkey, text) {
|
|
5
6
|
const key = secp256k1.getSharedSecret(privkey, '02' + pubkey)
|
|
6
7
|
const normalizedKey = getOnlyXFromFullSharedSecret(key)
|
|
7
8
|
|
|
8
|
-
let iv =
|
|
9
|
+
let iv = Uint8Array.from(randomBytes(16))
|
|
9
10
|
var cipher = crypto.createCipheriv(
|
|
10
11
|
'aes-256-cbc',
|
|
11
12
|
Buffer.from(normalizedKey, 'hex'),
|
package/nip06.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import createHmac from 'create-hmac'
|
|
2
|
+
import * as bip39 from 'bip39'
|
|
3
|
+
|
|
4
|
+
export function privateKeyFromSeed(seed) {
|
|
5
|
+
let hmac = createHmac('sha512', Buffer.from('Nostr seed', 'utf8'))
|
|
6
|
+
hmac.update(seed)
|
|
7
|
+
return hmac.digest().slice(0, 32).toString('hex')
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function seedFromWords(mnemonic) {
|
|
11
|
+
return bip39.mnemonicToSeedSync(mnemonic)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export function generateSeedWords() {
|
|
15
|
+
return bip39.entropyToMnemonic(randomBytes(16).toString('hex'))
|
|
16
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "nostr-tools",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.7.0",
|
|
4
4
|
"description": "Tools for making a Nostr client.",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -8,8 +8,11 @@
|
|
|
8
8
|
},
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"@noble/secp256k1": "^1.3.0",
|
|
11
|
+
"bip39": "^3.0.4",
|
|
11
12
|
"buffer": "^6.0.3",
|
|
13
|
+
"create-hmac": "^1.1.7",
|
|
12
14
|
"dns-packet": "^5.2.4",
|
|
15
|
+
"randombytes": "^2.1.0",
|
|
13
16
|
"websocket-polyfill": "^0.0.3"
|
|
14
17
|
},
|
|
15
18
|
"keywords": [
|