vestauth 0.1.29 → 0.1.30

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.29",
3
+ "version": "0.1.30",
4
4
  "description": "auth for agents",
5
5
  "keywords": [
6
6
  "vestauth"
@@ -1,7 +1,9 @@
1
1
  const secp = require('@noble/secp256k1')
2
2
  const hash = require('./hash')
3
+ const stripFormatting = require('./stripFormatting')
3
4
 
4
- async function sign (challenge, privateKeyHex) {
5
+ async function sign (challenge, privateKeyHexPossiblyFormatted) {
6
+ const privateKeyHex = stripFormatting(privateKeyHexPossiblyFormatted)
5
7
  const hashChallenge = hash(challenge)
6
8
  const privateKeyBytes = Buffer.from(privateKeyHex, 'hex')
7
9
  const signature = await secp.sign(hashChallenge, privateKeyBytes)
@@ -0,0 +1,5 @@
1
+ function stripFormatting (key) {
2
+ return String(key).split('_').at(-1)
3
+ }
4
+
5
+ module.exports = stripFormatting
@@ -1,7 +1,9 @@
1
1
  const secp = require('@noble/secp256k1')
2
2
  const hash = require('./hash')
3
+ const stripFormatting = require('./stripFormatting')
3
4
 
4
- function verify (challenge, signatureBase64, publicKeyHex) {
5
+ function verify (challenge, signatureBase64, publicKeyHexPossiblyFormatted) {
6
+ const publicKeyHex = stripFormatting(publicKeyHexPossiblyFormatted)
5
7
  const hashChallenge = hash(challenge)
6
8
  const signature = Buffer.from(signatureBase64, 'base64url')
7
9
  const publicKeyBytes = Buffer.from(publicKeyHex, 'hex')