Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@incanta/config

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@incanta/config - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

34

lib/secrets/hcp-vault.js

@@ -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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc