vestauth 0.1.12 → 0.1.13
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
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "vestauth",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.13",
|
|
4
4
|
"description": "vestauth",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"vestauth"
|
|
@@ -19,11 +19,21 @@
|
|
|
19
19
|
"author": "@motdotla",
|
|
20
20
|
"type": "commonjs",
|
|
21
21
|
"scripts": {
|
|
22
|
-
"
|
|
22
|
+
"standard": "standard",
|
|
23
|
+
"standard:fix": "standard --fix",
|
|
24
|
+
"test": "tap run --allow-empty-coverage --disable-coverage --timeout=60000",
|
|
25
|
+
"test-coverage": "tap run --show-full-coverage --timeout=60000",
|
|
26
|
+
"testshell": "bash shellspec",
|
|
27
|
+
"prerelease": "npm test && npm run testshell",
|
|
28
|
+
"release": "standard-version"
|
|
23
29
|
},
|
|
24
30
|
"dependencies": {
|
|
25
31
|
"@noble/hashes": "^1.8.0",
|
|
26
32
|
"@noble/secp256k1": "^3.0.0",
|
|
27
33
|
"eciesjs": "^0.4.16"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"standard": "^17.1.0",
|
|
37
|
+
"standard-version": "^9.5.0"
|
|
28
38
|
}
|
|
29
39
|
}
|
package/src/lib/helpers/hash.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const { sha256 } = require('@noble/hashes/sha2.js')
|
|
2
2
|
const { utf8ToBytes } = require('@noble/hashes/utils.js')
|
|
3
3
|
|
|
4
|
-
function hash (
|
|
5
|
-
return sha256(utf8ToBytes(
|
|
4
|
+
function hash (str = '') {
|
|
5
|
+
return sha256(utf8ToBytes(str))
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
module.exports = hash
|
package/src/lib/helpers/sign.js
CHANGED
|
@@ -6,10 +6,10 @@ secp.hashes.sha256 = sha256
|
|
|
6
6
|
secp.hashes.hmacSha256 = (key, msg) => hmac(sha256, key, msg)
|
|
7
7
|
const hash = require('./hash')
|
|
8
8
|
|
|
9
|
-
function sign (
|
|
10
|
-
const
|
|
9
|
+
function sign (challenge, privateKeyHex) {
|
|
10
|
+
const hashChallenge = hash(challenge)
|
|
11
11
|
const privateKeyBytes = Buffer.from(privateKeyHex, 'hex')
|
|
12
|
-
const signature = secp.sign(
|
|
12
|
+
const signature = secp.sign(hashChallenge, privateKeyBytes)
|
|
13
13
|
|
|
14
14
|
return Buffer.from(signature).toString('base64url') // base64 returned
|
|
15
15
|
}
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
const secp = require('@noble/secp256k1')
|
|
2
2
|
const hash = require('./hash')
|
|
3
3
|
|
|
4
|
-
function verify (
|
|
5
|
-
const
|
|
4
|
+
function verify (challenge, signatureBase64, publicKeyHex) {
|
|
5
|
+
const hashChallenge = hash(challenge)
|
|
6
6
|
const signature = Buffer.from(signatureBase64, 'base64url')
|
|
7
7
|
const publicKeyBytes = Buffer.from(publicKeyHex, 'hex')
|
|
8
8
|
|
|
9
|
-
return secp.verify(signature,
|
|
9
|
+
return secp.verify(signature, hashChallenge, publicKeyBytes)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
module.exports = verify
|
package/src/lib/main.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
const challenge = require('./helpers/challenge')
|
|
1
2
|
const hash = require('./helpers/hash')
|
|
2
3
|
const keypair = require('./helpers/keypair')
|
|
3
4
|
const sign = require('./helpers/sign')
|
|
4
5
|
const verify = require('./helpers/verify')
|
|
5
6
|
|
|
6
7
|
module.exports = {
|
|
8
|
+
challenge,
|
|
7
9
|
hash,
|
|
8
10
|
keypair,
|
|
9
11
|
sign,
|