vestauth 0.1.7 → 0.1.9

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.7",
3
+ "version": "0.1.9",
4
4
  "description": "vestauth",
5
5
  "keywords": [
6
6
  "vestauth"
@@ -4,11 +4,8 @@ const { sha256 } = require('@noble/hashes/sha2.js')
4
4
  const { hmac } = require('@noble/hashes/hmac.js')
5
5
  secp.hashes.sha256 = sha256
6
6
  secp.hashes.hmacSha256 = (key, msg) => hmac(sha256, key, msg)
7
- const hash = require('./helpers/hash')
7
+ const hash = require('./hash')
8
8
 
9
- // // privateKey: 32-byte Uint8Array (or hex depending on your setup)
10
- // const signature = await sign(hash, privateKey, { der: false })
11
- //
12
9
  // // publicKey (compressed): Uint8Array
13
10
  // const publicKey = getPublicKey(privateKey, true)
14
11
  //
@@ -16,7 +13,11 @@ const hash = require('./helpers/hash')
16
13
  // const ok = verify(signature, hash, publicKey)
17
14
 
18
15
  function sign (message, privateKey) {
19
- return secp.sign(hash(message), hash(privateKey))
16
+ const hashMessage = hash(message)
17
+ const hashPrivateKey = hash(privateKey)
18
+ const signature = secp.sign(hashMessage, hashPrivateKey)
19
+
20
+ return Buffer.from(signature).toString('base64url') // base64 returned
20
21
  }
21
22
 
22
23
  module.exports = sign