vestauth 0.1.30 → 0.1.31

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.30",
3
+ "version": "0.1.31",
4
4
  "description": "auth for agents",
5
5
  "keywords": [
6
6
  "vestauth"
@@ -6,7 +6,7 @@ function keypair (existingPrivateKey) {
6
6
  const options = this.opts()
7
7
  logger.debug(`options: ${JSON.stringify(options)}`)
8
8
 
9
- const kp = main.keypair(existingPrivateKey)
9
+ const kp = main.keypair(existingPrivateKey, options.prefix)
10
10
 
11
11
  const output = {
12
12
  public_key: kp.publicKey,
@@ -58,6 +58,7 @@ const keypairAction = require('./actions/keypair')
58
58
  program.command('keypair')
59
59
  .description('generate public/private keypair')
60
60
  .argument('[private_key]', 'pre-existing private key')
61
+ .option('--prefix <type>', 'agent (default) | provider | none', 'agent')
61
62
  .option('-pp, --pretty-print', 'pretty print output')
62
63
  .action(keypairAction)
63
64
 
@@ -1,6 +1,6 @@
1
1
  const { PrivateKey } = require('eciesjs')
2
2
 
3
- function keypair (existingPrivateKey) {
3
+ function keypair (existingPrivateKey, prefix = 'agent') {
4
4
  let kp
5
5
 
6
6
  if (existingPrivateKey) {
@@ -9,8 +9,18 @@ function keypair (existingPrivateKey) {
9
9
  kp = new PrivateKey()
10
10
  }
11
11
 
12
- const publicKey = kp.publicKey.toHex()
13
- const privateKey = kp.secret.toString('hex')
12
+ let publicKey = kp.publicKey.toHex()
13
+ let privateKey = kp.secret.toString('hex')
14
+
15
+ if (prefix === 'agent') {
16
+ publicKey = `agent_pub_${publicKey}`
17
+ privateKey = `agent_prv_${privateKey}`
18
+ }
19
+
20
+ if (prefix === 'provider') {
21
+ publicKey = `provider_pub_${publicKey}`
22
+ privateKey = `provider_prv_${privateKey}`
23
+ }
14
24
 
15
25
  return {
16
26
  publicKey,