@orion-js/env 4.0.0-next.3 → 4.0.0-next.4

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.
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/index.ts","../src/cli/add/getConfig.ts","../src/files/index.ts","../src/crypto/tweetnacl.ts","../src/crypto/index.ts","../src/environment/getVariables.ts","../src/environment/getDts.ts","../src/environment/load.ts","../src/environment/index.ts","../src/internalGetEnv.ts"],"sourcesContent":["export * from './environment'\nexport * from './internalGetEnv'\n","import YAML from 'yaml'\nimport {Config} from '../../environment/getVariables'\nimport {readFile} from '../../files'\n\nexport const getConfig = (envPath: string): Config => {\n const configFile = readFile(envPath)\n\n if (!configFile) {\n throw new Error('No config file found at path ' + envPath)\n }\n\n return YAML.parse(configFile)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nexport function readFile(filePath: string) {\n if (!fs.existsSync(filePath)) return null\n\n return fs.readFileSync(filePath).toString()\n}\n\nexport function writeFile(path: string, content: string) {\n ensureDirectory(path)\n fs.writeFileSync(path, content)\n}\n\nexport function ensureDirectory(filePath) {\n const dirname = path.dirname(filePath)\n if (fs.existsSync(dirname)) return true\n ensureDirectory(dirname)\n fs.mkdirSync(dirname)\n}\n","import {box, randomBytes} from 'tweetnacl'\nimport {decodeUTF8, encodeUTF8, encodeBase64, decodeBase64} from 'tweetnacl-util'\n\nconst newNonce = () => randomBytes(box.nonceLength)\nexport const generateKeyPair = () => box.keyPair()\n\nexport const encrypt = (bSecretKey: Uint8Array, aPublicKey: Uint8Array, message: string) => {\n const nonce = newNonce()\n const messageUint8 = decodeUTF8(message)\n const encrypted = box(messageUint8, nonce, aPublicKey, bSecretKey)\n\n const fullMessage = new Uint8Array(nonce.length + encrypted.length)\n fullMessage.set(nonce)\n fullMessage.set(encrypted, nonce.length)\n\n const base64FullMessage = encodeBase64(fullMessage)\n return base64FullMessage\n}\n\nexport const decrypt = (\n aSecretKey: Uint8Array,\n bPublicKey: Uint8Array,\n messageWithNonce: string\n) => {\n const messageWithNonceAsUint8Array = decodeBase64(messageWithNonce)\n const nonce = messageWithNonceAsUint8Array.slice(0, box.nonceLength)\n const message = messageWithNonceAsUint8Array.slice(box.nonceLength, messageWithNonce.length)\n\n const decrypted = box.open(message, nonce, bPublicKey, aSecretKey)\n\n if (!decrypted) {\n throw new Error('Could not decrypt message')\n }\n\n const base64DecryptedMessage = encodeUTF8(decrypted)\n return base64DecryptedMessage\n}\n","import {generateKeyPair, encrypt as tweetEncrypt, decrypt as tweetDecrypt} from './tweetnacl'\nimport {encodeBase64, decodeBase64} from 'tweetnacl-util'\n\nexport function generateKeys() {\n const {publicKey, secretKey} = generateKeyPair()\n\n const encryptKeyHex = encodeBase64(publicKey)\n const decryptKeyHex = encodeBase64(secretKey)\n\n return {\n encryptKey: encryptKeyHex,\n decryptKey: decryptKeyHex\n }\n}\n\n/**\n * Creates a temporal keypair just to encrypt one message.\n * Saves the public key in the result so that the message can be decrypted.\n */\nexport function encrypt(encryptKey: string, message: string) {\n const encryptPublicKey = decodeBase64(encryptKey)\n const tempPair = generateKeyPair()\n const encrypted = tweetEncrypt(tempPair.secretKey, encryptPublicKey, message)\n const hexTempPublic = encodeBase64(tempPair.publicKey)\n return `${hexTempPublic}:${encrypted}`\n}\n\n/**\n * Ecrypts a message using the decrypt key\n */\nexport function decrypt(decryptKey: string, encrypted: string) {\n const decryptSecretKey = decodeBase64(decryptKey)\n const [messagePubKeyHex, encryptedMessage] = encrypted.split(':')\n const messagePubKey = decodeBase64(messagePubKeyHex)\n\n return tweetDecrypt(decryptSecretKey, messagePubKey, encryptedMessage)\n}\n","import {decrypt} from '../crypto'\n\nexport interface Config {\n version: string\n publicKey: string\n cleanKeys: {\n [key: string]: string\n }\n encryptedKeys: {\n [key: string]: string\n }\n readFromSecret?: {\n [key: string]: string[]\n }\n}\n\nexport interface Variables {\n [key: string]: string\n}\n\nfunction readSecrets(readFromSecret): {variables: Variables; secretKey: string} {\n const variables: Variables = {}\n let secretKey = null\n if (!readFromSecret) return {variables, secretKey}\n for (const secretName in readFromSecret) {\n const keys = readFromSecret[secretName]\n if (!process.env[secretName]) {\n console.warn(\n `@orion/env could not find the secret \"${secretName}\" in the environment. Related variables will be undefined.`\n )\n continue\n }\n\n try {\n const values = JSON.parse(process.env[secretName])\n if (values.ORION_ENV_SECRET_KEY) {\n secretKey = values.ORION_ENV_SECRET_KEY\n }\n for (const key of keys) {\n if (values[key]) {\n variables[key] = values[key]\n } else {\n console.warn(\n `@orion/env could not find the variable \"${key}\" in the secret \"${secretName}\". Related variables will be undefined.`\n )\n }\n }\n } catch (error) {\n console.warn(\n `'@orion/env found a the secret \"${secretName}\" variable in the environment but it is not a valid JSON. Related variables will be undefined.'`\n )\n }\n }\n return {variables, secretKey: secretKey}\n} \n\nexport function getVariables(config: Config, secretKey?: string): Variables {\n const {cleanKeys, encryptedKeys, readFromSecret} = config\n const {variables, secretKey: foundSecretKey} = readSecrets(readFromSecret)\n let decryptKey = foundSecretKey || secretKey\n if (!decryptKey) {\n throw new Error(\n 'Orion encrypted env was passed but process.env.ORION_ENV_SECRET_KEY is not defined'\n )\n }\n\n for (const key in cleanKeys) {\n const value = cleanKeys[key]\n variables[key] = value\n }\n\n for (const key in encryptedKeys) {\n const encrypted = encryptedKeys[key]\n try {\n variables[key] = decrypt(decryptKey, encrypted)\n } catch (error) {\n throw new Error(\n `Orion encrypted env was passed but process.env.ORION_ENV_SECRET_KEY is not the right key for \"${key}\"`\n )\n }\n }\n return variables\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {readFile, writeFile} from '../files'\nimport {Config} from './getVariables'\n\nexport function getDts(config: Config) {\n const keys = [\n ...Object.keys(config.cleanKeys),\n ...Object.keys(config.encryptedKeys),\n ...Object.values(config.readFromSecret).flat()\n ]\n return `declare module '@orion-js/env' {\n export const env: {\n${keys.map(key => ` ${key}: string`).join('\\n')}\n }\n}\n`\n}\n\nexport function writeDtsFile(config: Config, path: string) {\n const currentFile = readFile(path)\n const dts = getDts(config)\n if (currentFile !== dts) {\n writeFile(path, dts)\n }\n}\n\nexport function writeDtsFileFromConfigFile(configFilePath: string, path: string) {\n const config = getConfig(configFilePath)\n writeDtsFile(config, path)\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {getVariables} from './getVariables'\n\nexport interface LoadEnvOptions {\n // Secret password used to decrypt the encrypted env file. Default: process.env.ORION_ENV_SECRET_KEY\n secretKey?: string\n // Location of the file to read. Default: process.env.ORION_ENV_FILE_PATH\n envFilePath?: string\n // Set to true to set the environment variables even if the variable was already set. Default: process.env.ORION_ENV_OVERRIDE\n override?: boolean\n}\n\nconst defaultOptions: LoadEnvOptions = {\n secretKey: process.env.ORION_ENV_SECRET_KEY,\n envFilePath: process.env.ORION_ENV_FILE_PATH,\n override: !!process.env.ORION_ENV_OVERRIDE\n}\n\nexport function loadEnv(passedOptions: LoadEnvOptions = {}) {\n const options = {...defaultOptions, ...passedOptions}\n const data = getConfig(options.envFilePath)\n const variables = getVariables(data, options.secretKey)\n\n for (const key in variables) {\n const variable = variables[key]\n\n if (!Object.prototype.hasOwnProperty.call(process.env, key)) {\n process.env[key] = variable\n } else {\n if (options.override) {\n process.env[key] = variable\n }\n\n if (options.override) {\n console.log(`\"${key}\" is already defined in \\`process.env\\` and WAS overwritten`)\n } else {\n console.log(`\"${key}\" is already defined in \\`process.env\\` and was NOT overwritten`)\n }\n }\n }\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {getVariables} from './getVariables'\nexport * from './getDts'\nexport * from './load'\n\nexport interface Variables {\n [key: string]: string\n}\n\nlet variables: Variables = {}\n\nconst g = global as any\n\nconst secretKey = process.env.ORION_ENV_SECRET_KEY\nconst envFilePath = process.env.ORION_ENV_FILE_PATH\n\nexport const readEnv = () => {\n const data = getConfig(envFilePath)\n return getVariables(data, secretKey)\n}\n\nif (g.__orion_env_final__) {\n variables = g.__orion_env_final__\n} else if (envFilePath) {\n variables = readEnv()\n}\n\ng.__orion_env_final__ = variables\n\nconst env = variables\n\nexport {env}\n","import {env} from '.'\n\nexport const internalGetEnv = (orionEnvName: string, processEnvName: string): string | null => {\n if (env[orionEnvName]) {\n return env[orionEnvName]\n }\n\n if (process.env[processEnvName]) {\n return process.env[processEnvName]\n }\n\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACAA,kBAAiB;;;ACAjB,qBAAe;AACf,uBAAiB;AAEV,SAAS,SAAS,UAAkB;AACzC,MAAI,CAAC,eAAAA,QAAG,WAAW,QAAQ,EAAG,QAAO;AAErC,SAAO,eAAAA,QAAG,aAAa,QAAQ,EAAE,SAAS;AAC5C;AAEO,SAAS,UAAUC,OAAc,SAAiB;AACvD,kBAAgBA,KAAI;AACpB,iBAAAD,QAAG,cAAcC,OAAM,OAAO;AAChC;AAEO,SAAS,gBAAgB,UAAU;AACxC,QAAM,UAAU,iBAAAA,QAAK,QAAQ,QAAQ;AACrC,MAAI,eAAAD,QAAG,WAAW,OAAO,EAAG,QAAO;AACnC,kBAAgB,OAAO;AACvB,iBAAAA,QAAG,UAAU,OAAO;AACtB;;;ADfO,IAAM,YAAY,CAAC,YAA4B;AACpD,QAAM,aAAa,SAAS,OAAO;AAEnC,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,kCAAkC,OAAO;AAAA,EAC3D;AAEA,SAAO,YAAAE,QAAK,MAAM,UAAU;AAC9B;;;AEZA,uBAA+B;AAC/B,4BAAiE;AAkB1D,IAAM,UAAU,CACrB,YACA,YACA,qBACG;AACH,QAAM,mCAA+B,oCAAa,gBAAgB;AAClE,QAAM,QAAQ,6BAA6B,MAAM,GAAG,qBAAI,WAAW;AACnE,QAAM,UAAU,6BAA6B,MAAM,qBAAI,aAAa,iBAAiB,MAAM;AAE3F,QAAM,YAAY,qBAAI,KAAK,SAAS,OAAO,YAAY,UAAU;AAEjE,M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AAC1D,QAAM,UAAU,EAAC,GAAG,gBAAgB,GAAG,cAAa;AACpD,QAAM,OAAO,UAAU,QAAQ,WAAW;AAC1C,QAAMC,aAAY,aAAa,MAAM,QAAQ,SAAS;AAEtD,aAAW,OAAOA,YAAW;AAC3B,UAAM,WAAWA,WAAU,GAAG;AAE9B,QAAI,CAAC,OAAO,UAAU,eAAe,KAAK,QAAQ,KAAK,GAAG,GAAG;AAC3D,cAAQ,IAAI,GAAG,IAAI;AAAA,IACrB,OAAO;AACL,UAAI,QAAQ,UAAU;AACpB,gBAAQ,IAAI,GAAG,IAAI;AAAA,MACrB;AAEA,UAAI,QAAQ,UAAU;AACpB,gBAAQ,IAAI,IAAI,GAAG,6DAA6D;AAAA,MAClF,OAAO;AACL,gBAAQ,IAAI,IAAI,GAAG,iEAAiE;AAAA,MACtF;AAAA,IACF;AAAA,EACF;AACF;;;AC/BA,IAAI,YAAuB,CAAC;AAE5B,IAAM,IAAI;AAEV,IAAM,YAAY,QAAQ,IAAI;AAC9B,IAAM,cAAc,QAAQ,IAAI;AAEzB,IAAM,UAAU,MAAM;AAC3B,QAAM,OAAO,UAAU,WAAW;AAClC,SAAO,aAAa,MAAM,SAAS;AACrC;AAEA,IAAI,EAAE,qBAAqB;AACzB,cAAY,EAAE;AAChB,WAAW,aAAa;AACtB,cAAY,QAAQ;AACtB;AAEA,EAAE,sBAAsB;AAExB,IAAM,MAAM;;;AC3BL,IAAM,iBAAiB,CAAC,cAAsB,mBAA0C;AAC7F,MAAI,IAAI,YAAY,GAAG;AACrB,WAAO,IAAI,YAAY;AAAA,EACzB;AAEA,MAAI,QAAQ,IAAI,cAAc,GAAG;AAC/B,WAAO,QAAQ,IAAI,cAAc;AAAA,EACnC;AAEA,SAAO;AACT;","names":["fs","path","YAML","import_tweetnacl_util","decrypt","variables","secretKey","decrypt","path","variables"]}
1
+ {"version":3,"sources":["../src/index.ts","../src/cli/add/getConfig.ts","../src/files/index.ts","../src/crypto/tweetnacl.ts","../src/crypto/index.ts","../src/environment/getVariables.ts","../src/environment/getDts.ts","../src/environment/load.ts","../src/environment/index.ts","../src/internalGetEnv.ts"],"sourcesContent":["export * from './environment'\nexport * from './internalGetEnv'\n","import YAML from 'yaml'\nimport {Config} from '../../environment/getVariables'\nimport {readFile} from '../../files'\n\nexport const getConfig = (envPath: string): Config => {\n const configFile = readFile(envPath)\n\n if (!configFile) {\n throw new Error('No config file found at path ' + envPath)\n }\n\n return YAML.parse(configFile)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nexport function readFile(filePath: string) {\n if (!fs.existsSync(filePath)) return null\n\n return fs.readFileSync(filePath).toString()\n}\n\nexport function writeFile(path: string, content: string) {\n ensureDirectory(path)\n fs.writeFileSync(path, content)\n}\n\nexport function ensureDirectory(filePath) {\n const dirname = path.dirname(filePath)\n if (fs.existsSync(dirname)) return true\n ensureDirectory(dirname)\n fs.mkdirSync(dirname)\n}\n","import {box, randomBytes} from 'tweetnacl'\nimport {decodeUTF8, encodeUTF8, encodeBase64, decodeBase64} from 'tweetnacl-util'\n\nconst newNonce = () => randomBytes(box.nonceLength)\nexport const generateKeyPair = () => box.keyPair()\n\nexport const encrypt = (bSecretKey: Uint8Array, aPublicKey: Uint8Array, message: string) => {\n const nonce = newNonce()\n const messageUint8 = decodeUTF8(message)\n const encrypted = box(messageUint8, nonce, aPublicKey, bSecretKey)\n\n const fullMessage = new Uint8Array(nonce.length + encrypted.length)\n fullMessage.set(nonce)\n fullMessage.set(encrypted, nonce.length)\n\n const base64FullMessage = encodeBase64(fullMessage)\n return base64FullMessage\n}\n\nexport const decrypt = (\n aSecretKey: Uint8Array,\n bPublicKey: Uint8Array,\n messageWithNonce: string,\n) => {\n const messageWithNonceAsUint8Array = decodeBase64(messageWithNonce)\n const nonce = messageWithNonceAsUint8Array.slice(0, box.nonceLength)\n const message = messageWithNonceAsUint8Array.slice(box.nonceLength, messageWithNonce.length)\n\n const decrypted = box.open(message, nonce, bPublicKey, aSecretKey)\n\n if (!decrypted) {\n throw new Error('Could not decrypt message')\n }\n\n const base64DecryptedMessage = encodeUTF8(decrypted)\n return base64DecryptedMessage\n}\n","import {generateKeyPair, encrypt as tweetEncrypt, decrypt as tweetDecrypt} from './tweetnacl'\nimport {encodeBase64, decodeBase64} from 'tweetnacl-util'\n\nexport function generateKeys() {\n const {publicKey, secretKey} = generateKeyPair()\n\n const encryptKeyHex = encodeBase64(publicKey)\n const decryptKeyHex = encodeBase64(secretKey)\n\n return {\n encryptKey: encryptKeyHex,\n decryptKey: decryptKeyHex,\n }\n}\n\n/**\n * Creates a temporal keypair just to encrypt one message.\n * Saves the public key in the result so that the message can be decrypted.\n */\nexport function encrypt(encryptKey: string, message: string) {\n const encryptPublicKey = decodeBase64(encryptKey)\n const tempPair = generateKeyPair()\n const encrypted = tweetEncrypt(tempPair.secretKey, encryptPublicKey, message)\n const hexTempPublic = encodeBase64(tempPair.publicKey)\n return `${hexTempPublic}:${encrypted}`\n}\n\n/**\n * Ecrypts a message using the decrypt key\n */\nexport function decrypt(decryptKey: string, encrypted: string) {\n const decryptSecretKey = decodeBase64(decryptKey)\n const [messagePubKeyHex, encryptedMessage] = encrypted.split(':')\n const messagePubKey = decodeBase64(messagePubKeyHex)\n\n return tweetDecrypt(decryptSecretKey, messagePubKey, encryptedMessage)\n}\n","import {decrypt} from '../crypto'\n\nexport interface Config {\n version: string\n publicKey: string\n cleanKeys: {\n [key: string]: string\n }\n encryptedKeys: {\n [key: string]: string\n }\n readFromSecret?: {\n [key: string]: string[]\n }\n}\n\nexport interface Variables {\n [key: string]: string\n}\n\nfunction readSecrets(readFromSecret): {variables: Variables; secretKey: string} {\n const variables: Variables = {}\n let secretKey = null\n if (!readFromSecret) return {variables, secretKey}\n for (const secretName in readFromSecret) {\n const keys = readFromSecret[secretName]\n if (!process.env[secretName]) {\n console.warn(\n `@orion/env could not find the secret \"${secretName}\" in the environment. Related variables will be undefined.`,\n )\n continue\n }\n\n try {\n const values = JSON.parse(process.env[secretName])\n if (values.ORION_ENV_SECRET_KEY) {\n secretKey = values.ORION_ENV_SECRET_KEY\n }\n for (const key of keys) {\n if (values[key]) {\n variables[key] = values[key]\n } else {\n console.warn(\n `@orion/env could not find the variable \"${key}\" in the secret \"${secretName}\". Related variables will be undefined.`,\n )\n }\n }\n } catch (error) {\n console.warn(\n `'@orion/env found a the secret \"${secretName}\" variable in the environment but it is not a valid JSON. Related variables will be undefined.'`,\n )\n }\n }\n return {variables, secretKey: secretKey}\n}\n\nexport function getVariables(config: Config, secretKey?: string): Variables {\n const {cleanKeys, encryptedKeys, readFromSecret} = config\n const {variables, secretKey: foundSecretKey} = readSecrets(readFromSecret)\n let decryptKey = foundSecretKey || secretKey\n if (!decryptKey) {\n throw new Error(\n 'Orion encrypted env was passed but process.env.ORION_ENV_SECRET_KEY is not defined',\n )\n }\n\n for (const key in cleanKeys) {\n const value = cleanKeys[key]\n variables[key] = value\n }\n\n for (const key in encryptedKeys) {\n const encrypted = encryptedKeys[key]\n try {\n variables[key] = decrypt(decryptKey, encrypted)\n } catch (error) {\n throw new Error(\n `Orion encrypted env was passed but process.env.ORION_ENV_SECRET_KEY is not the right key for \"${key}\"`,\n )\n }\n }\n return variables\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {readFile, writeFile} from '../files'\nimport {Config} from './getVariables'\n\nexport function getDts(config: Config) {\n const keys = [\n ...Object.keys(config.cleanKeys),\n ...Object.keys(config.encryptedKeys),\n ...Object.values(config.readFromSecret).flat(),\n ]\n return `declare module '@orion-js/env' {\n export const env: {\n${keys.map(key => ` ${key}: string`).join('\\n')}\n }\n}\n`\n}\n\nexport function writeDtsFile(config: Config, path: string) {\n const currentFile = readFile(path)\n const dts = getDts(config)\n if (currentFile !== dts) {\n writeFile(path, dts)\n }\n}\n\nexport function writeDtsFileFromConfigFile(configFilePath: string, path: string) {\n const config = getConfig(configFilePath)\n writeDtsFile(config, path)\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {getVariables} from './getVariables'\n\nexport interface LoadEnvOptions {\n // Secret password used to decrypt the encrypted env file. Default: process.env.ORION_ENV_SECRET_KEY\n secretKey?: string\n // Location of the file to read. Default: process.env.ORION_ENV_FILE_PATH\n envFilePath?: string\n // Set to true to set the environment variables even if the variable was already set. Default: process.env.ORION_ENV_OVERRIDE\n override?: boolean\n}\n\nconst defaultOptions: LoadEnvOptions = {\n secretKey: process.env.ORION_ENV_SECRET_KEY,\n envFilePath: process.env.ORION_ENV_FILE_PATH,\n override: !!process.env.ORION_ENV_OVERRIDE,\n}\n\nexport function loadEnv(passedOptions: LoadEnvOptions = {}) {\n const options = {...defaultOptions, ...passedOptions}\n const data = getConfig(options.envFilePath)\n const variables = getVariables(data, options.secretKey)\n\n for (const key in variables) {\n const variable = variables[key]\n\n if (!Object.prototype.hasOwnProperty.call(process.env, key)) {\n process.env[key] = variable\n } else {\n if (options.override) {\n process.env[key] = variable\n }\n\n if (options.override) {\n console.log(`\"${key}\" is already defined in \\`process.env\\` and WAS overwritten`)\n } else {\n console.log(`\"${key}\" is already defined in \\`process.env\\` and was NOT overwritten`)\n }\n }\n }\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {getVariables} from './getVariables'\nexport * from './getDts'\nexport * from './load'\n\nexport interface Variables {\n [key: string]: string\n}\n\nlet variables: Variables = {}\n\nconst g = global as any\n\nconst secretKey = process.env.ORION_ENV_SECRET_KEY\nconst envFilePath = process.env.ORION_ENV_FILE_PATH\n\nexport const readEnv = () => {\n const data = getConfig(envFilePath)\n return getVariables(data, secretKey)\n}\n\nif (g.__orion_env_final__) {\n variables = g.__orion_env_final__\n} else if (envFilePath) {\n variables = readEnv()\n}\n\ng.__orion_env_final__ = variables\n\nconst env = variables\n\nexport {env}\n","import {env} from '.'\n\nexport const internalGetEnv = (orionEnvName: string, processEnvName: string): string | null => {\n if (env[orionEnvName]) {\n return env[orionEnvName]\n }\n\n if (process.env[processEnvName]) {\n return process.env[processEnvName]\n }\n\n return null\n}\n"],"mappings":";;;;;;;;;;;;;;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AAC,OAAO,UAAU,eAAe,KAAK,QAAQ,KAAK,GAAG,GAAG;AAC3D,cAAQ,IAAI,GAAG,IAAI;AAAA,IACrB,OAAO;AACL,UAAI,QAAQ,UAAU;AACpB,gBAAQ,IAAI,GAAG,IAAI;AAAA,MACrB;AAEA,UAAI,QAAQ,UAAU;AACpB,gBAAQ,IAAI,IAAI,GAAG,6DAA6D;AAAA,MAClF,OAAO;AACL,gBAAQ,IAAI,IAAI,GAAG,iEAAiE;AAAA,MACtF;AAAA,IACF;AAAA,EACF;AACF;;;AC/BA,IAAI,YAAuB,CAAC;AAE5B,IAAM,IAAI;AAEV,IAAM,YAAY,QAAQ,IAAI;AAC9B,IAAM,cAAc,QAAQ,IAAI;AAEzB,IAAM,UAAU,MAAM;AAC3B,QAAM,OAAO,UAAU,WAAW;AAClC,SAAO,aAAa,MAAM,SAAS;AACrC;AAEA,IAAI,EAAE,qBAAqB;AACzB,cAAY,EAAE;AAChB,WAAW,aAAa;AACtB,cAAY,QAAQ;AACtB;AAEA,EAAE,sBAAsB;AAExB,IAAM,MAAM;;;AC3BL,IAAM,iBAAiB,CAAC,cAAsB,mBAA0C;AAC7F,MAAI,IAAI,YAAY,GAAG;AACrB,WAAO,IAAI,YAAY;AAAA,EACzB;AAEA,MAAI,QAAQ,IAAI,cAAc,GAAG;AAC/B,WAAO,QAAQ,IAAI,cAAc;AAAA,EACnC;AAEA,SAAO;AACT;","names":["fs","path","YAML","import_tweetnacl_util","decrypt","variables","secretKey","decrypt","path","variables"]}
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../src/cli/add/getConfig.ts","../src/files/index.ts","../src/crypto/tweetnacl.ts","../src/crypto/index.ts","../src/environment/getVariables.ts","../src/environment/getDts.ts","../src/environment/load.ts","../src/environment/index.ts","../src/internalGetEnv.ts"],"sourcesContent":["import YAML from 'yaml'\nimport {Config} from '../../environment/getVariables'\nimport {readFile} from '../../files'\n\nexport const getConfig = (envPath: string): Config => {\n const configFile = readFile(envPath)\n\n if (!configFile) {\n throw new Error('No config file found at path ' + envPath)\n }\n\n return YAML.parse(configFile)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nexport function readFile(filePath: string) {\n if (!fs.existsSync(filePath)) return null\n\n return fs.readFileSync(filePath).toString()\n}\n\nexport function writeFile(path: string, content: string) {\n ensureDirectory(path)\n fs.writeFileSync(path, content)\n}\n\nexport function ensureDirectory(filePath) {\n const dirname = path.dirname(filePath)\n if (fs.existsSync(dirname)) return true\n ensureDirectory(dirname)\n fs.mkdirSync(dirname)\n}\n","import {box, randomBytes} from 'tweetnacl'\nimport {decodeUTF8, encodeUTF8, encodeBase64, decodeBase64} from 'tweetnacl-util'\n\nconst newNonce = () => randomBytes(box.nonceLength)\nexport const generateKeyPair = () => box.keyPair()\n\nexport const encrypt = (bSecretKey: Uint8Array, aPublicKey: Uint8Array, message: string) => {\n const nonce = newNonce()\n const messageUint8 = decodeUTF8(message)\n const encrypted = box(messageUint8, nonce, aPublicKey, bSecretKey)\n\n const fullMessage = new Uint8Array(nonce.length + encrypted.length)\n fullMessage.set(nonce)\n fullMessage.set(encrypted, nonce.length)\n\n const base64FullMessage = encodeBase64(fullMessage)\n return base64FullMessage\n}\n\nexport const decrypt = (\n aSecretKey: Uint8Array,\n bPublicKey: Uint8Array,\n messageWithNonce: string\n) => {\n const messageWithNonceAsUint8Array = decodeBase64(messageWithNonce)\n const nonce = messageWithNonceAsUint8Array.slice(0, box.nonceLength)\n const message = messageWithNonceAsUint8Array.slice(box.nonceLength, messageWithNonce.length)\n\n const decrypted = box.open(message, nonce, bPublicKey, aSecretKey)\n\n if (!decrypted) {\n throw new Error('Could not decrypt message')\n }\n\n const base64DecryptedMessage = encodeUTF8(decrypted)\n return base64DecryptedMessage\n}\n","import {generateKeyPair, encrypt as tweetEncrypt, decrypt as tweetDecrypt} from './tweetnacl'\nimport {encodeBase64, decodeBase64} from 'tweetnacl-util'\n\nexport function generateKeys() {\n const {publicKey, secretKey} = generateKeyPair()\n\n const encryptKeyHex = encodeBase64(publicKey)\n const decryptKeyHex = encodeBase64(secretKey)\n\n return {\n encryptKey: encryptKeyHex,\n decryptKey: decryptKeyHex\n }\n}\n\n/**\n * Creates a temporal keypair just to encrypt one message.\n * Saves the public key in the result so that the message can be decrypted.\n */\nexport function encrypt(encryptKey: string, message: string) {\n const encryptPublicKey = decodeBase64(encryptKey)\n const tempPair = generateKeyPair()\n const encrypted = tweetEncrypt(tempPair.secretKey, encryptPublicKey, message)\n const hexTempPublic = encodeBase64(tempPair.publicKey)\n return `${hexTempPublic}:${encrypted}`\n}\n\n/**\n * Ecrypts a message using the decrypt key\n */\nexport function decrypt(decryptKey: string, encrypted: string) {\n const decryptSecretKey = decodeBase64(decryptKey)\n const [messagePubKeyHex, encryptedMessage] = encrypted.split(':')\n const messagePubKey = decodeBase64(messagePubKeyHex)\n\n return tweetDecrypt(decryptSecretKey, messagePubKey, encryptedMessage)\n}\n","import {decrypt} from '../crypto'\n\nexport interface Config {\n version: string\n publicKey: string\n cleanKeys: {\n [key: string]: string\n }\n encryptedKeys: {\n [key: string]: string\n }\n readFromSecret?: {\n [key: string]: string[]\n }\n}\n\nexport interface Variables {\n [key: string]: string\n}\n\nfunction readSecrets(readFromSecret): {variables: Variables; secretKey: string} {\n const variables: Variables = {}\n let secretKey = null\n if (!readFromSecret) return {variables, secretKey}\n for (const secretName in readFromSecret) {\n const keys = readFromSecret[secretName]\n if (!process.env[secretName]) {\n console.warn(\n `@orion/env could not find the secret \"${secretName}\" in the environment. Related variables will be undefined.`\n )\n continue\n }\n\n try {\n const values = JSON.parse(process.env[secretName])\n if (values.ORION_ENV_SECRET_KEY) {\n secretKey = values.ORION_ENV_SECRET_KEY\n }\n for (const key of keys) {\n if (values[key]) {\n variables[key] = values[key]\n } else {\n console.warn(\n `@orion/env could not find the variable \"${key}\" in the secret \"${secretName}\". Related variables will be undefined.`\n )\n }\n }\n } catch (error) {\n console.warn(\n `'@orion/env found a the secret \"${secretName}\" variable in the environment but it is not a valid JSON. Related variables will be undefined.'`\n )\n }\n }\n return {variables, secretKey: secretKey}\n} \n\nexport function getVariables(config: Config, secretKey?: string): Variables {\n const {cleanKeys, encryptedKeys, readFromSecret} = config\n const {variables, secretKey: foundSecretKey} = readSecrets(readFromSecret)\n let decryptKey = foundSecretKey || secretKey\n if (!decryptKey) {\n throw new Error(\n 'Orion encrypted env was passed but process.env.ORION_ENV_SECRET_KEY is not defined'\n )\n }\n\n for (const key in cleanKeys) {\n const value = cleanKeys[key]\n variables[key] = value\n }\n\n for (const key in encryptedKeys) {\n const encrypted = encryptedKeys[key]\n try {\n variables[key] = decrypt(decryptKey, encrypted)\n } catch (error) {\n throw new Error(\n `Orion encrypted env was passed but process.env.ORION_ENV_SECRET_KEY is not the right key for \"${key}\"`\n )\n }\n }\n return variables\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {readFile, writeFile} from '../files'\nimport {Config} from './getVariables'\n\nexport function getDts(config: Config) {\n const keys = [\n ...Object.keys(config.cleanKeys),\n ...Object.keys(config.encryptedKeys),\n ...Object.values(config.readFromSecret).flat()\n ]\n return `declare module '@orion-js/env' {\n export const env: {\n${keys.map(key => ` ${key}: string`).join('\\n')}\n }\n}\n`\n}\n\nexport function writeDtsFile(config: Config, path: string) {\n const currentFile = readFile(path)\n const dts = getDts(config)\n if (currentFile !== dts) {\n writeFile(path, dts)\n }\n}\n\nexport function writeDtsFileFromConfigFile(configFilePath: string, path: string) {\n const config = getConfig(configFilePath)\n writeDtsFile(config, path)\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {getVariables} from './getVariables'\n\nexport interface LoadEnvOptions {\n // Secret password used to decrypt the encrypted env file. Default: process.env.ORION_ENV_SECRET_KEY\n secretKey?: string\n // Location of the file to read. Default: process.env.ORION_ENV_FILE_PATH\n envFilePath?: string\n // Set to true to set the environment variables even if the variable was already set. Default: process.env.ORION_ENV_OVERRIDE\n override?: boolean\n}\n\nconst defaultOptions: LoadEnvOptions = {\n secretKey: process.env.ORION_ENV_SECRET_KEY,\n envFilePath: process.env.ORION_ENV_FILE_PATH,\n override: !!process.env.ORION_ENV_OVERRIDE\n}\n\nexport function loadEnv(passedOptions: LoadEnvOptions = {}) {\n const options = {...defaultOptions, ...passedOptions}\n const data = getConfig(options.envFilePath)\n const variables = getVariables(data, options.secretKey)\n\n for (const key in variables) {\n const variable = variables[key]\n\n if (!Object.prototype.hasOwnProperty.call(process.env, key)) {\n process.env[key] = variable\n } else {\n if (options.override) {\n process.env[key] = variable\n }\n\n if (options.override) {\n console.log(`\"${key}\" is already defined in \\`process.env\\` and WAS overwritten`)\n } else {\n console.log(`\"${key}\" is already defined in \\`process.env\\` and was NOT overwritten`)\n }\n }\n }\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {getVariables} from './getVariables'\nexport * from './getDts'\nexport * from './load'\n\nexport interface Variables {\n [key: string]: string\n}\n\nlet variables: Variables = {}\n\nconst g = global as any\n\nconst secretKey = process.env.ORION_ENV_SECRET_KEY\nconst envFilePath = process.env.ORION_ENV_FILE_PATH\n\nexport const readEnv = () => {\n const data = getConfig(envFilePath)\n return getVariables(data, secretKey)\n}\n\nif (g.__orion_env_final__) {\n variables = g.__orion_env_final__\n} else if (envFilePath) {\n variables = readEnv()\n}\n\ng.__orion_env_final__ = variables\n\nconst env = variables\n\nexport {env}\n","import {env} from '.'\n\nexport const internalGetEnv = (orionEnvName: string, processEnvName: string): string | null => {\n if (env[orionEnvName]) {\n return env[orionEnvName]\n }\n\n if (process.env[processEnvName]) {\n return process.env[processEnvName]\n }\n\n return null\n}\n"],"mappings":";AAAA,OAAO,UAAU;;;ACAjB,OAAO,QAAQ;AACf,OAAO,UAAU;AAEV,SAAS,SAAS,UAAkB;AACzC,MAAI,CAAC,GAAG,WAAW,QAAQ,EAAG,QAAO;AAErC,SAAO,GAAG,aAAa,QAAQ,EAAE,SAAS;AAC5C;AAEO,SAAS,UAAUA,OAAc,SAAiB;AACvD,kBAAgBA,KAAI;AACp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A,IACF;AAAA,EACF;AACF;;;AC/BA,IAAI,YAAuB,CAAC;AAE5B,IAAM,IAAI;AAEV,IAAM,YAAY,QAAQ,IAAI;AAC9B,IAAM,cAAc,QAAQ,IAAI;AAEzB,IAAM,UAAU,MAAM;AAC3B,QAAM,OAAO,UAAU,WAAW;AAClC,SAAO,aAAa,MAAM,SAAS;AACrC;AAEA,IAAI,EAAE,qBAAqB;AACzB,cAAY,EAAE;AAChB,WAAW,aAAa;AACtB,cAAY,QAAQ;AACtB;AAEA,EAAE,sBAAsB;AAExB,IAAM,MAAM;;;AC3BL,IAAM,iBAAiB,CAAC,cAAsB,mBAA0C;AAC7F,MAAI,IAAI,YAAY,GAAG;AACrB,WAAO,IAAI,YAAY;AAAA,EACzB;AAEA,MAAI,QAAQ,IAAI,cAAc,GAAG;AAC/B,WAAO,QAAQ,IAAI,cAAc;AAAA,EACnC;AAEA,SAAO;AACT;","names":["path","encodeBase64","decodeBase64","decrypt","decodeBase64","variables","secretKey","decrypt","path","variables"]}
1
+ {"version":3,"sources":["../src/cli/add/getConfig.ts","../src/files/index.ts","../src/crypto/tweetnacl.ts","../src/crypto/index.ts","../src/environment/getVariables.ts","../src/environment/getDts.ts","../src/environment/load.ts","../src/environment/index.ts","../src/internalGetEnv.ts"],"sourcesContent":["import YAML from 'yaml'\nimport {Config} from '../../environment/getVariables'\nimport {readFile} from '../../files'\n\nexport const getConfig = (envPath: string): Config => {\n const configFile = readFile(envPath)\n\n if (!configFile) {\n throw new Error('No config file found at path ' + envPath)\n }\n\n return YAML.parse(configFile)\n}\n","import fs from 'node:fs'\nimport path from 'node:path'\n\nexport function readFile(filePath: string) {\n if (!fs.existsSync(filePath)) return null\n\n return fs.readFileSync(filePath).toString()\n}\n\nexport function writeFile(path: string, content: string) {\n ensureDirectory(path)\n fs.writeFileSync(path, content)\n}\n\nexport function ensureDirectory(filePath) {\n const dirname = path.dirname(filePath)\n if (fs.existsSync(dirname)) return true\n ensureDirectory(dirname)\n fs.mkdirSync(dirname)\n}\n","import {box, randomBytes} from 'tweetnacl'\nimport {decodeUTF8, encodeUTF8, encodeBase64, decodeBase64} from 'tweetnacl-util'\n\nconst newNonce = () => randomBytes(box.nonceLength)\nexport const generateKeyPair = () => box.keyPair()\n\nexport const encrypt = (bSecretKey: Uint8Array, aPublicKey: Uint8Array, message: string) => {\n const nonce = newNonce()\n const messageUint8 = decodeUTF8(message)\n const encrypted = box(messageUint8, nonce, aPublicKey, bSecretKey)\n\n const fullMessage = new Uint8Array(nonce.length + encrypted.length)\n fullMessage.set(nonce)\n fullMessage.set(encrypted, nonce.length)\n\n const base64FullMessage = encodeBase64(fullMessage)\n return base64FullMessage\n}\n\nexport const decrypt = (\n aSecretKey: Uint8Array,\n bPublicKey: Uint8Array,\n messageWithNonce: string,\n) => {\n const messageWithNonceAsUint8Array = decodeBase64(messageWithNonce)\n const nonce = messageWithNonceAsUint8Array.slice(0, box.nonceLength)\n const message = messageWithNonceAsUint8Array.slice(box.nonceLength, messageWithNonce.length)\n\n const decrypted = box.open(message, nonce, bPublicKey, aSecretKey)\n\n if (!decrypted) {\n throw new Error('Could not decrypt message')\n }\n\n const base64DecryptedMessage = encodeUTF8(decrypted)\n return base64DecryptedMessage\n}\n","import {generateKeyPair, encrypt as tweetEncrypt, decrypt as tweetDecrypt} from './tweetnacl'\nimport {encodeBase64, decodeBase64} from 'tweetnacl-util'\n\nexport function generateKeys() {\n const {publicKey, secretKey} = generateKeyPair()\n\n const encryptKeyHex = encodeBase64(publicKey)\n const decryptKeyHex = encodeBase64(secretKey)\n\n return {\n encryptKey: encryptKeyHex,\n decryptKey: decryptKeyHex,\n }\n}\n\n/**\n * Creates a temporal keypair just to encrypt one message.\n * Saves the public key in the result so that the message can be decrypted.\n */\nexport function encrypt(encryptKey: string, message: string) {\n const encryptPublicKey = decodeBase64(encryptKey)\n const tempPair = generateKeyPair()\n const encrypted = tweetEncrypt(tempPair.secretKey, encryptPublicKey, message)\n const hexTempPublic = encodeBase64(tempPair.publicKey)\n return `${hexTempPublic}:${encrypted}`\n}\n\n/**\n * Ecrypts a message using the decrypt key\n */\nexport function decrypt(decryptKey: string, encrypted: string) {\n const decryptSecretKey = decodeBase64(decryptKey)\n const [messagePubKeyHex, encryptedMessage] = encrypted.split(':')\n const messagePubKey = decodeBase64(messagePubKeyHex)\n\n return tweetDecrypt(decryptSecretKey, messagePubKey, encryptedMessage)\n}\n","import {decrypt} from '../crypto'\n\nexport interface Config {\n version: string\n publicKey: string\n cleanKeys: {\n [key: string]: string\n }\n encryptedKeys: {\n [key: string]: string\n }\n readFromSecret?: {\n [key: string]: string[]\n }\n}\n\nexport interface Variables {\n [key: string]: string\n}\n\nfunction readSecrets(readFromSecret): {variables: Variables; secretKey: string} {\n const variables: Variables = {}\n let secretKey = null\n if (!readFromSecret) return {variables, secretKey}\n for (const secretName in readFromSecret) {\n const keys = readFromSecret[secretName]\n if (!process.env[secretName]) {\n console.warn(\n `@orion/env could not find the secret \"${secretName}\" in the environment. Related variables will be undefined.`,\n )\n continue\n }\n\n try {\n const values = JSON.parse(process.env[secretName])\n if (values.ORION_ENV_SECRET_KEY) {\n secretKey = values.ORION_ENV_SECRET_KEY\n }\n for (const key of keys) {\n if (values[key]) {\n variables[key] = values[key]\n } else {\n console.warn(\n `@orion/env could not find the variable \"${key}\" in the secret \"${secretName}\". Related variables will be undefined.`,\n )\n }\n }\n } catch (error) {\n console.warn(\n `'@orion/env found a the secret \"${secretName}\" variable in the environment but it is not a valid JSON. Related variables will be undefined.'`,\n )\n }\n }\n return {variables, secretKey: secretKey}\n}\n\nexport function getVariables(config: Config, secretKey?: string): Variables {\n const {cleanKeys, encryptedKeys, readFromSecret} = config\n const {variables, secretKey: foundSecretKey} = readSecrets(readFromSecret)\n let decryptKey = foundSecretKey || secretKey\n if (!decryptKey) {\n throw new Error(\n 'Orion encrypted env was passed but process.env.ORION_ENV_SECRET_KEY is not defined',\n )\n }\n\n for (const key in cleanKeys) {\n const value = cleanKeys[key]\n variables[key] = value\n }\n\n for (const key in encryptedKeys) {\n const encrypted = encryptedKeys[key]\n try {\n variables[key] = decrypt(decryptKey, encrypted)\n } catch (error) {\n throw new Error(\n `Orion encrypted env was passed but process.env.ORION_ENV_SECRET_KEY is not the right key for \"${key}\"`,\n )\n }\n }\n return variables\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {readFile, writeFile} from '../files'\nimport {Config} from './getVariables'\n\nexport function getDts(config: Config) {\n const keys = [\n ...Object.keys(config.cleanKeys),\n ...Object.keys(config.encryptedKeys),\n ...Object.values(config.readFromSecret).flat(),\n ]\n return `declare module '@orion-js/env' {\n export const env: {\n${keys.map(key => ` ${key}: string`).join('\\n')}\n }\n}\n`\n}\n\nexport function writeDtsFile(config: Config, path: string) {\n const currentFile = readFile(path)\n const dts = getDts(config)\n if (currentFile !== dts) {\n writeFile(path, dts)\n }\n}\n\nexport function writeDtsFileFromConfigFile(configFilePath: string, path: string) {\n const config = getConfig(configFilePath)\n writeDtsFile(config, path)\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {getVariables} from './getVariables'\n\nexport interface LoadEnvOptions {\n // Secret password used to decrypt the encrypted env file. Default: process.env.ORION_ENV_SECRET_KEY\n secretKey?: string\n // Location of the file to read. Default: process.env.ORION_ENV_FILE_PATH\n envFilePath?: string\n // Set to true to set the environment variables even if the variable was already set. Default: process.env.ORION_ENV_OVERRIDE\n override?: boolean\n}\n\nconst defaultOptions: LoadEnvOptions = {\n secretKey: process.env.ORION_ENV_SECRET_KEY,\n envFilePath: process.env.ORION_ENV_FILE_PATH,\n override: !!process.env.ORION_ENV_OVERRIDE,\n}\n\nexport function loadEnv(passedOptions: LoadEnvOptions = {}) {\n const options = {...defaultOptions, ...passedOptions}\n const data = getConfig(options.envFilePath)\n const variables = getVariables(data, options.secretKey)\n\n for (const key in variables) {\n const variable = variables[key]\n\n if (!Object.prototype.hasOwnProperty.call(process.env, key)) {\n process.env[key] = variable\n } else {\n if (options.override) {\n process.env[key] = variable\n }\n\n if (options.override) {\n console.log(`\"${key}\" is already defined in \\`process.env\\` and WAS overwritten`)\n } else {\n console.log(`\"${key}\" is already defined in \\`process.env\\` and was NOT overwritten`)\n }\n }\n }\n}\n","import {getConfig} from '../cli/add/getConfig'\nimport {getVariables} from './getVariables'\nexport * from './getDts'\nexport * from './load'\n\nexport interface Variables {\n [key: string]: string\n}\n\nlet variables: Variables = {}\n\nconst g = global as any\n\nconst secretKey = process.env.ORION_ENV_SECRET_KEY\nconst envFilePath = process.env.ORION_ENV_FILE_PATH\n\nexport const readEnv = () => {\n const data = getConfig(envFilePath)\n return getVariables(data, secretKey)\n}\n\nif (g.__orion_env_final__) {\n variables = g.__orion_env_final__\n} else if (envFilePath) {\n variables = readEnv()\n}\n\ng.__orion_env_final__ = variables\n\nconst env = variables\n\nexport {env}\n","import {env} from '.'\n\nexport const internalGetEnv = (orionEnvName: string, processEnvName: string): string | null => {\n if (env[orionEnvName]) {\n return env[orionEnvName]\n }\n\n if (process.env[processEnvName]) {\n return process.env[processEnvName]\n }\n\n return null\n}\n"],"mappings":";AAAA,OAAO,UAAU;;;ACAjB,OAAO,QAAQ;AACf,OAAO,UAAU;AAEV,SAAS,SAAS,UAAkB;AACzC,MAAI,CAAC,GAAG,WAAW,QAAQ,EAAG,QAAO;AAErC,SAAO,GAAG,aAAa,QAAQ,EAAE,SAAS;AAC5C;AAEO,SAAS,UAAUA,OAAc,SAAiB;AACvD,kBAAgBA,KAAI;AACpB,KAAG,cAAcA,OAAM,OAAO;AAChC;AAEO,SAAS,gBAAgB,UAAU;AACxC,QAAM,UAAU,KAAK,QAAQ,QAAQ;AACrC,MAAI,GAAG,WAAW,OAAO,EAAG,QAAO;AACnC,kBAAgB,OAAO;AACvB,KAAG,UAAU,OAAO;AACtB;;;ADfO,IAAM,YAAY,CAAC,YAA4B;AACpD,QAAM,aAAa,SAAS,OAAO;AAEnC,MAAI,CAAC,YAAY;AACf,UAAM,IAAI,MAAM,kCAAkC,OAAO;AAAA,EAC3D;A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sB;AAExB,IAAM,MAAM;;;AC3BL,IAAM,iBAAiB,CAAC,cAAsB,mBAA0C;AAC7F,MAAI,IAAI,YAAY,GAAG;AACrB,WAAO,IAAI,YAAY;AAAA,EACzB;AAEA,MAAI,QAAQ,IAAI,cAAc,GAAG;AAC/B,WAAO,QAAQ,IAAI,cAAc;AAAA,EACnC;AAEA,SAAO;AACT;","names":["path","encodeBase64","decodeBase64","decrypt","decodeBase64","variables","secretKey","decrypt","path","variables"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@orion-js/env",
3
- "version": "4.0.0-next.3",
3
+ "version": "4.0.0-next.4",
4
4
  "main": "./dist/index.cjs",
5
5
  "author": "nicolaslopezj",
6
6
  "license": "MIT",