UNPKG

dotencr

Version:

Encrypt and decrypt individual lines inside a .env file. Supports multiple encryption keys. Keys and dotenv files can be read text file or read from the environment.

18 lines 901 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); const crypto_key_manager_1 = require("./crypto_key_manager"); const dotenv_processor_1 = require("./dotenv_processor"); const crypto_wrapper_1 = require("./crypto_wrapper"); exports.decryptProcessEnvironment = () => { const cryptoKeyManager = new crypto_key_manager_1.CryptoKeyManager(); // Load the keys from the environment. Could be loaded from a dotenv file. cryptoKeyManager.loadFromEnv(); const dotenvProcessor = new dotenv_processor_1.DotenvProcessor(cryptoKeyManager); const res = dotenvProcessor.decrypt(); res.filter((x) => x.status === crypto_wrapper_1.StatusCryptoWrapperResult.success).forEach((x) => { // Overwrite env value. This behavior differs from dotenv. process.env[x.newDotenvVariableName] = x.result; }); return res; }; //# sourceMappingURL=index.js.map