nestjs-infisical-sdk
Version:
A NestJS module for Infisical Node SDK
38 lines • 1.53 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.createInfisicalClient = void 0;
const sdk_1 = require("@infisical/sdk");
const file_watcher_util_1 = require("./file-watcher.util");
const exceptions_1 = require("../exceptions");
async function createInfisicalClient(options) {
if (!options.clientId || !options.clientSecret) {
throw new exceptions_1.ClientCredentialsNotFoundException();
}
const client = new sdk_1.InfisicalSDK({
siteUrl: options.siteUrl || process.env.INFISICAL_SITE_URL || 'https://app.infisical.com'
});
await client.auth().universalAuth.login({
clientId: options.clientId || process.env.INFISICAL_CLIENT_ID,
clientSecret: options.clientSecret || process.env.INFISICAL_CLIENT_SECRET
});
if (options.watchEnvFile) {
(0, file_watcher_util_1.watchEnviromentFile)();
}
if (options.renewToken) {
await client.auth().universalAuth.renew();
}
if (options.setManuallyAccessToken) {
client.auth().accessToken(options.setManuallyAccessToken || process.env.INFISICAL_ACCESS_TOKEN);
}
if (options.awsIamLogin) {
await client.auth().awsIamAuth.login({
identityId: options.awsIamLogin || process.env.INFISICAL_AWS_IAM_LOGIN
});
}
if (options.renewAwsIamToken) {
await client.auth().awsIamAuth.renew();
}
return client;
}
exports.createInfisicalClient = createInfisicalClient;
//# sourceMappingURL=create-infisical-client.util.js.map
;