crypta-client 0.1.2 → 0.1.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": "crypta-client",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Crypta Secret Manager client library for Javascript Application",
5
5
  "main": "index.js",
6
6
  "type": "commonjs",
package/src/client.js CHANGED
@@ -5,7 +5,9 @@ const { CryptaError } = require('./errors')
5
5
  class CryptaClient {
6
6
  constructor({ baseUrl, clientId, privateKeyPem }) {
7
7
  if (!baseUrl || !clientId || !privateKeyPem) {
8
- throw new Error('baseUrl, clientId, dan privateKeyPem wajib diisi')
8
+ throw new Error(
9
+ 'Missing required parameters: baseUrl, clientId, privateKeyPem'
10
+ )
9
11
  }
10
12
 
11
13
  this.baseUrl = baseUrl.replace(/\/+$/, '')
@@ -18,18 +20,18 @@ class CryptaClient {
18
20
  http: this.http,
19
21
  clientId: this.clientId,
20
22
  privateKeyPem: this.privateKeyPem,
21
- audience: `${this.baseUrl}/public-api/auth/token`
23
+ audience: `${this.baseUrl}/client/auth/token`
22
24
  })
23
25
  }
24
26
 
25
27
  async getSecret(name) {
26
- if (!name) throw new Error('secret name wajib diisi')
28
+ if (!name) throw new Error('Secret name is required')
27
29
 
28
30
  const token = await this.tokenManager.getToken()
29
31
 
30
32
  try {
31
33
  const res = await this.http.get(
32
- `/v1/secrets/${name}/versions/latest:access`,
34
+ `/client/latest-secret/v1/secrets/${name}/versions/latest:access`,
33
35
  {
34
36
  headers: { Authorization: `Bearer ${token}` }
35
37
  }
package/src/token.js CHANGED
@@ -22,10 +22,9 @@ class TokenManager {
22
22
  audience: this.audience
23
23
  })
24
24
 
25
- const res = await this.http.post('/public-api/auth/token', { assertion })
25
+ const res = await this.http.post('/client/auth/token', { assertion })
26
26
 
27
27
  this.accessToken = res.data.access_token
28
- // 1 menit buffer
29
28
  this.expiresAt = Date.now() + 9 * 60 * 1000
30
29
  }
31
30