vestauth 0.4.2 → 0.4.3

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.4.2",
3
+ "version": "0.4.3",
4
4
  "description": "auth for agents–from the creator of dotenvx",
5
5
  "keywords": [
6
6
  "vestauth"
@@ -2,11 +2,11 @@ const { logger } = require('./../../../shared/logger')
2
2
 
3
3
  const agent = require('./../../../lib/agent')
4
4
 
5
- function init () {
5
+ async function init () {
6
6
  const options = this.opts()
7
7
  logger.debug(`options: ${JSON.stringify(options)}`)
8
8
 
9
- const output = agent.init()
9
+ const output = await agent.init()
10
10
 
11
11
  let space = 0
12
12
  if (options.prettyPrint) {
@@ -1,5 +1,6 @@
1
1
  const { http } = require('../helpers/http')
2
2
  const buildApiError = require('../helpers/buildApiError')
3
+ const agentHeaders = require('../helpers/agentHeaders')
3
4
 
4
5
  class PostAgentRegister {
5
6
  constructor (hostname, publicJwk) {
@@ -11,11 +12,13 @@ class PostAgentRegister {
11
12
  const url = `${this.hostname}/api/agent/register`
12
13
  const publicJwk = this.publicJwk
13
14
 
15
+ const httpMethod = 'POST'
16
+ const headers = await agentHeaders(httpMethod, url)
17
+ headers['Content-Type'] = 'application/json'
18
+
14
19
  const resp = await http(url, {
15
- method: 'POST',
16
- headers: {
17
- 'Content-Type': 'application/json'
18
- },
20
+ method: httpMethod,
21
+ headers,
19
22
  body: JSON.stringify({
20
23
  public_jwk: publicJwk
21
24
  })
@@ -18,8 +18,7 @@ async function agentInit () {
18
18
  dotenvx.set('AGENT_PRIVATE_KEY', JSON.stringify(kp.privateKey), { path: envPath, plain: true, quiet: true })
19
19
 
20
20
  // register agent with api
21
- const postAgentRegister = new PostAgentRegister(null, kp.publicKey)
22
- await postAgentRegister.run()
21
+ await new PostAgentRegister(null, kp.publicKey).run()
23
22
 
24
23
  return {
25
24
  AGENT_PUBLIC_KEY: kp.publicKey,