vestauth 0.1.5 → 0.1.7
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/package.json +2 -2
- package/src/lib/helpers/sign.js +8 -9
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vestauth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.7",
|
|
4
4
|
"description": "vestauth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vestauth"
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
23
23
|
},
|
|
24
24
|
"dependencies": {
|
|
25
|
-
"@noble/hashes": "^
|
|
25
|
+
"@noble/hashes": "^1.8.0",
|
|
26
26
|
"@noble/secp256k1": "^3.0.0",
|
|
27
27
|
"eciesjs": "^0.4.16"
|
|
28
28
|
}
|
package/src/lib/helpers/sign.js
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
// import { sign, verify, getPublicKey } from '@noble/secp256k1'
|
|
2
|
-
const
|
|
2
|
+
const secp = require('@noble/secp256k1')
|
|
3
|
+
const { sha256 } = require('@noble/hashes/sha2.js')
|
|
4
|
+
const { hmac } = require('@noble/hashes/hmac.js')
|
|
5
|
+
secp.hashes.sha256 = sha256
|
|
6
|
+
secp.hashes.hmacSha256 = (key, msg) => hmac(sha256, key, msg)
|
|
7
|
+
const hash = require('./helpers/hash')
|
|
3
8
|
|
|
4
9
|
// // privateKey: 32-byte Uint8Array (or hex depending on your setup)
|
|
5
10
|
// const signature = await sign(hash, privateKey, { der: false })
|
|
@@ -10,14 +15,8 @@ const hashf = require('./hash')
|
|
|
10
15
|
// // verifier side (server or client)
|
|
11
16
|
// const ok = verify(signature, hash, publicKey)
|
|
12
17
|
|
|
13
|
-
function sign () {
|
|
14
|
-
|
|
15
|
-
const hash = hashf(message)
|
|
16
|
-
|
|
17
|
-
return {
|
|
18
|
-
message,
|
|
19
|
-
hash
|
|
20
|
-
}
|
|
18
|
+
function sign (message, privateKey) {
|
|
19
|
+
return secp.sign(hash(message), hash(privateKey))
|
|
21
20
|
}
|
|
22
21
|
|
|
23
22
|
module.exports = sign
|