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 +1 -1
- package/src/client.js +6 -4
- package/src/token.js +1 -2
package/package.json
CHANGED
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(
|
|
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}/
|
|
23
|
+
audience: `${this.baseUrl}/client/auth/token`
|
|
22
24
|
})
|
|
23
25
|
}
|
|
24
26
|
|
|
25
27
|
async getSecret(name) {
|
|
26
|
-
if (!name) throw new Error('
|
|
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('/
|
|
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
|
|