@incanta/config
Advanced tools
Comparing version 0.5.2 to 0.5.3
@@ -10,16 +10,22 @@ "use strict"; | ||
async getAuthToken() { | ||
const response = await axios_1.default.post("https://auth.idp.hashicorp.com/oauth2/token", { | ||
client_id: process.env.HCP_CLIENT_ID, | ||
client_secret: process.env.HCP_CLIENT_SECRET, | ||
grant_type: "client_credentials", | ||
audience: "https://api.hashicorp.cloud", | ||
}, { | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded", | ||
}, | ||
}); | ||
return { | ||
value: response.data.access_token, | ||
expires: new Date(Date.now() + response.data.expires_in * 1000), | ||
}; | ||
try { | ||
const response = await axios_1.default.post("https://auth.idp.hashicorp.com/oauth2/token", { | ||
client_id: process.env.HCP_CLIENT_ID, | ||
client_secret: process.env.HCP_CLIENT_SECRET, | ||
grant_type: "client_credentials", | ||
audience: "https://api.hashicorp.cloud", | ||
}, { | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded", | ||
}, | ||
}); | ||
return { | ||
value: response.data.access_token, | ||
expires: new Date(Date.now() + response.data.expires_in * 1000), | ||
}; | ||
} | ||
catch (error) { | ||
const typedError = error; | ||
throw new Error(`Failed to get HCP Vault token: ${typedError.code}; did you set HCP_CLIENT_ID and HCP_CLIENT_SECRET?`); | ||
} | ||
} | ||
@@ -26,0 +32,0 @@ async getSecrets(config, token) { |
{ | ||
"name": "@incanta/config", | ||
"version": "0.5.2", | ||
"version": "0.5.3", | ||
"main": "lib/index.js", | ||
@@ -5,0 +5,0 @@ "exports": { |
@@ -1,2 +0,2 @@ | ||
import axios from "axios"; | ||
import axios, { AxiosError } from "axios"; | ||
import Config from "../config"; | ||
@@ -30,21 +30,27 @@ import { ISecretsProvider, ISecretsToken } from "./provider"; | ||
public async getAuthToken(): Promise<ISecretsToken> { | ||
const response = await axios.post( | ||
"https://auth.idp.hashicorp.com/oauth2/token", | ||
{ | ||
client_id: process.env.HCP_CLIENT_ID, | ||
client_secret: process.env.HCP_CLIENT_SECRET, | ||
grant_type: "client_credentials", | ||
audience: "https://api.hashicorp.cloud", | ||
}, | ||
{ | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded", | ||
try { | ||
const response = await axios.post( | ||
"https://auth.idp.hashicorp.com/oauth2/token", | ||
{ | ||
client_id: process.env.HCP_CLIENT_ID, | ||
client_secret: process.env.HCP_CLIENT_SECRET, | ||
grant_type: "client_credentials", | ||
audience: "https://api.hashicorp.cloud", | ||
}, | ||
} | ||
); | ||
return { | ||
value: response.data.access_token, | ||
expires: new Date(Date.now() + response.data.expires_in * 1000), | ||
}; | ||
{ | ||
headers: { | ||
"Content-Type": "application/x-www-form-urlencoded", | ||
}, | ||
} | ||
); | ||
return { | ||
value: response.data.access_token, | ||
expires: new Date(Date.now() + response.data.expires_in * 1000), | ||
}; | ||
} catch (error: any) { | ||
const typedError = error as AxiosError; | ||
throw new Error( | ||
`Failed to get HCP Vault token: ${typedError.code}; did you set HCP_CLIENT_ID and HCP_CLIENT_SECRET?` | ||
); | ||
} | ||
} | ||
@@ -51,0 +57,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74236
1344