{"_id":"@2colours/toml-env","_rev":"5-cbb7f0ada83798e4e736cc4102cf1c6f","name":"@2colours/toml-env","dist-tags":{"latest":"0.1.0"},"versions":{"0.0.1":{"name":"@2colours/toml-env","version":"0.0.1","description":"Node.JS dotenv-alike module using \"env files\" written in TOML","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./config":"./dist/config.js"},"directories":{"test":"test"},"scripts":{"build":"tsc","test":"vitest"},"repository":{"type":"git","url":"git+https://github.com/2colours/toml-env.git"},"author":"","license":"Apache-2.0","bugs":{"url":"https://github.com/2colours/toml-env/issues"},"homepage":"https://github.com/2colours/toml-env#readme","devDependencies":{"@types/node":"^20.12.2","typescript":"^5.4.3","vitest":"^1.4.0"},"dependencies":{"smol-toml":"^1.1.4"},"_id":"@2colours/toml-env@0.0.1","gitHead":"7b69357397d6ee78a37d412d7470c179484c261a","_nodeVersion":"20.12.0","_npmVersion":"10.5.0","dist":{"integrity":"sha512-ZBGCdPdvBpu+5k4I5PEMOwrP3vhztws7QGkZzJmQeZE9GP7RNw/xexfb5RCT3tEw6f16NM8M2lQLXJezxne9aA==","shasum":"c3f448805ac783f12359e63c3e53f10de9746721","tarball":"https://registry.npmjs.org/@2colours/toml-env/-/toml-env-0.0.1.tgz","fileCount":10,"unpackedSize":23701,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCmbQ9f+Qcv0IyR+DvI9V4Y886vJMne7MMemYPW+g/qaAIgWAyHwm9mpB/BxaMtjFWEPwN7hj3KTeQ0JkZa3MPmGzI="}]},"_npmUser":{"name":"2colours","email":"polgar.marton@windowslive.com"},"maintainers":[{"name":"2colours","email":"polgar.marton@windowslive.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/toml-env_0.0.1_1711890028617_0.5831447067406192"},"_hasShrinkwrap":false},"0.0.2":{"name":"@2colours/toml-env","version":"0.0.2","description":"Node.JS dotenv-alike module using \"env files\" written in TOML","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./config":"./dist/config.js"},"directories":{"test":"test"},"scripts":{"build":"tsc","test":"vitest"},"repository":{"type":"git","url":"git+https://github.com/2colours/toml-env.git"},"author":"","license":"Apache-2.0","bugs":{"url":"https://github.com/2colours/toml-env/issues"},"homepage":"https://github.com/2colours/toml-env#readme","devDependencies":{"@types/node":"^20.12.2","typescript":"^5.4.3","vitest":"^1.4.0"},"dependencies":{"smol-toml":"^1.1.4"},"_id":"@2colours/toml-env@0.0.2","gitHead":"7b69357397d6ee78a37d412d7470c179484c261a","_nodeVersion":"20.11.1","_npmVersion":"10.2.4","dist":{"integrity":"sha512-QgEdsm/b1GTApnV8f2mf0HmC7Utr+KuJ5FdjjzLhDJKo6jidKU2fiy1qLkBW+Xswn1RBWZeX/RMyt5HA6BLfJQ==","shasum":"099f1ef026f1f4064c1beb8e262e31b8566e3efb","tarball":"https://registry.npmjs.org/@2colours/toml-env/-/toml-env-0.0.2.tgz","fileCount":13,"unpackedSize":24741,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQC2voHv6RfcBhZG44z+pcOtpHXlacU7S67ym9cc7WkIrAIhANB2bWyILh7msNCG/e4rF7w3H/iBIwCaNJzElvIm8I+j"}]},"_npmUser":{"name":"2colours","email":"polgar.marton@windowslive.com"},"maintainers":[{"name":"2colours","email":"polgar.marton@windowslive.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/toml-env_0.0.2_1711897733747_0.1469907432662252"},"_hasShrinkwrap":false},"0.0.3":{"name":"@2colours/toml-env","version":"0.0.3","description":"Node.JS dotenv-alike module using \"env files\" written in TOML","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./config":"./dist/config.js"},"directories":{"test":"test"},"scripts":{"build":"tsc","test":"vitest"},"repository":{"type":"git","url":"git+https://github.com/2colours/toml-env.git"},"author":"","license":"Apache-2.0","bugs":{"url":"https://github.com/2colours/toml-env/issues"},"homepage":"https://github.com/2colours/toml-env#readme","devDependencies":{"@types/node":"^20.12.2","typescript":"^5.4.3","vitest":"^1.4.0"},"dependencies":{"smol-toml":"^1.1.4"},"_id":"@2colours/toml-env@0.0.3","gitHead":"e91ad48ed08a1f64877e38927883913a468c8638","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-hDILiTXta3aUOtkthcyRTlhmVfe9an4msAqKmKItq93RDNhb3jZlT1pudRmtSqjvXz9SQVxuDjTqkG1BCUBx+A==","shasum":"fab6bf76b510c2b1d1c7dce5f171bc4171df21f1","tarball":"https://registry.npmjs.org/@2colours/toml-env/-/toml-env-0.0.3.tgz","fileCount":13,"unpackedSize":26647,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCGVtjeuc34g+V2zq5fcdgZv0LqJi/WR9GIMrEToUk4IwIgE3eKQQBS1xXCBe+57EurfVVClJpgBz2QzBcWQyQoBkA="}]},"_npmUser":{"name":"2colours","email":"polgar.marton@windowslive.com"},"maintainers":[{"name":"2colours","email":"polgar.marton@windowslive.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/toml-env_0.0.3_1714670273047_0.02359687772694241"},"_hasShrinkwrap":false},"0.0.4":{"name":"@2colours/toml-env","version":"0.0.4","description":"Node.JS dotenv-alike module using \"env files\" written in TOML","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./config":"./dist/config.js"},"directories":{"test":"test"},"scripts":{"build":"tsc","test":"vitest"},"repository":{"type":"git","url":"git+https://github.com/2colours/toml-env.git"},"author":"","license":"Apache-2.0","bugs":{"url":"https://github.com/2colours/toml-env/issues"},"homepage":"https://github.com/2colours/toml-env#readme","devDependencies":{"@types/node":"^20.12.2","typescript":"^5.4.3","vitest":"^1.4.0"},"dependencies":{"smol-toml":"^1.1.4"},"_id":"@2colours/toml-env@0.0.4","gitHead":"07731541f23629d05800a9b2548ac14d3dbf5153","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-s6owH4xr3cuY/p1S3CcLFpkH2RTrLMMtkc7OU/nPA4BOBFInfcloPSBLl4oTaqXDnM530bKBFoL5HIPHQ1N8yw==","shasum":"a4cbde7e88b4f7b73ce1dc98df4368065bcc55ef","tarball":"https://registry.npmjs.org/@2colours/toml-env/-/toml-env-0.0.4.tgz","fileCount":13,"unpackedSize":26652,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCICCEkyaWES1QL/WLtF4ZxwgaN6seEM0swWY5wG154cN0AiBfGpwrOHjfgH055Di+FFsvwbzSwLlm/ch9485/N45nEw=="}]},"_npmUser":{"name":"2colours","email":"polgar.marton@windowslive.com"},"maintainers":[{"name":"2colours","email":"polgar.marton@windowslive.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/toml-env_0.0.4_1714672232402_0.45760526182186334"},"_hasShrinkwrap":false},"0.0.5":{"name":"@2colours/toml-env","version":"0.0.5","description":"Node.JS dotenv-alike module using \"env files\" written in TOML","type":"module","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./config":"./dist/config.js"},"directories":{"test":"test"},"scripts":{"build":"tsc","test":"vitest"},"repository":{"type":"git","url":"git+https://github.com/2colours/toml-env.git"},"author":"","license":"Apache-2.0","bugs":{"url":"https://github.com/2colours/toml-env/issues"},"homepage":"https://github.com/2colours/toml-env#readme","devDependencies":{"@types/node":"^20.12.2","typescript":"^5.4.3","vitest":"^1.4.0"},"dependencies":{"smol-toml":"^1.1.4"},"_id":"@2colours/toml-env@0.0.5","gitHead":"cf3fea46d974db8b758cf6896c884c7955e6a232","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-/u0lF4xWcjFfCO2EpKaFRN5vSljsa+t3zozH23FZFAUdsA+gocKo8uw5qAaYkl1Uzv40pZYwiv54vHIBDHh4/w==","shasum":"0985f6fe7633aececef7092935b79678c4c0e428","tarball":"https://registry.npmjs.org/@2colours/toml-env/-/toml-env-0.0.5.tgz","fileCount":13,"unpackedSize":26780,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCtizvJotaNQwgeURTuD/aohGEKlFxpuzx5XrjgY/uS+AIgQA0KErlqu665Q0MN1YVPw2VxbINx2XSBTJbw3t8ZW9E="}]},"_npmUser":{"name":"2colours","email":"polgar.marton@windowslive.com"},"maintainers":[{"name":"2colours","email":"polgar.marton@windowslive.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/toml-env_0.0.5_1714678609859_0.18198328784448736"},"_hasShrinkwrap":false},"0.1.0":{"name":"@2colours/toml-env","version":"0.1.0","description":"Node.JS dotenv-alike module using \"env files\" written in TOML","exports":{".":{"types":"./dist/index.d.ts","default":"./dist/index.js"},"./config":"./dist/config.js"},"directories":{"test":"test"},"scripts":{"build":"tsc","test":"vitest"},"repository":{"type":"git","url":"git+https://github.com/2colours/toml-env.git"},"author":"","license":"Apache-2.0","bugs":{"url":"https://github.com/2colours/toml-env/issues"},"homepage":"https://github.com/2colours/toml-env#readme","devDependencies":{"@types/node":"^20.12.2","typescript":"^5.4.3","vitest":"^1.4.0"},"dependencies":{"smol-toml":"^1.2.0"},"_id":"@2colours/toml-env@0.1.0","gitHead":"f50ce2a5e24252425a06fdab476ad234f2066c2d","_nodeVersion":"20.12.2","_npmVersion":"10.5.0","dist":{"integrity":"sha512-A/Ei640EdsXUTNck07+fx3YT2IihCDDGkXyk+ldHpe5Lv1j66rSEyogM0KZWMz+F4Yc0Fxti/zZLyyLo0L5ZjQ==","shasum":"3974faf4d2e105ff227cf149d17c0c92e8dd9d0f","tarball":"https://registry.npmjs.org/@2colours/toml-env/-/toml-env-0.1.0.tgz","fileCount":13,"unpackedSize":32303,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIBPcl/YJqgYtBiNNH2Ginjvtq2E9msHYxNHtTtMOxuNKAiB0R5tU0gfg6HiMGjr6l6KfNjh2i5CRwhrG5uMI8Hu9OA=="}]},"_npmUser":{"name":"2colours","email":"polgar.marton@windowslive.com"},"maintainers":[{"name":"2colours","email":"polgar.marton@windowslive.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/toml-env_0.1.0_1716500512924_0.7186282982544672"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-31T13:00:28.508Z","0.0.1":"2024-03-31T13:00:28.782Z","modified":"2024-05-23T21:41:53.245Z","0.0.2":"2024-03-31T15:08:53.928Z","0.0.3":"2024-05-02T17:17:53.257Z","0.0.4":"2024-05-02T17:50:32.573Z","0.0.5":"2024-05-02T19:36:50.012Z","0.1.0":"2024-05-23T21:41:53.079Z"},"maintainers":[{"name":"2colours","email":"polgar.marton@windowslive.com"}],"description":"Node.JS dotenv-alike module using \"env files\" written in TOML","homepage":"https://github.com/2colours/toml-env#readme","repository":{"type":"git","url":"git+https://github.com/2colours/toml-env.git"},"bugs":{"url":"https://github.com/2colours/toml-env/issues"},"license":"Apache-2.0","readme":"# toml-env [![NPM version](https://img.shields.io/npm/v/@2colours/toml-env.svg?style=flat_square)](https://www.npmjs.com/package/@2colours/toml-env) [![LICENSE](https://img.shields.io/github/license/2colours/toml-env.svg)](LICENSE)\n\n### Node.JS dotenv-alike module using \"env files\" written in TOML\n\n`toml-env` is a largely [dotenv](https://github.com/motdotla/dotenv)-compatible module written in Typescript that uses [TOML](https://toml.io) to load configuration from a `.env.toml` file and exposes them via the [`process.env`](https://nodejs.org/docs/latest/api/process.html#process_process_env) and `process.envTyped` fields.\n\n* [🌱 Install](#-install)\n* [🏗️ Usage (.env.toml)](#-usage)\n* [🌴 Multiple Environments 🆕](#-manage-multiple-environments) (**dotenv legacy**)\n* [🚀 Deploying (.env.vault) 🆕](#-deploying) (**dotenv legacy**)\n* [📖 Docs](#-documentation)\n* [👏 Prior art and thanks](#-prior-art-and-thanks)\n\n## 🌱 Install\n\n```sh\n# using npm\nnpm install @2colours/toml-env --save\n# using yarn\nyarn add @2colours/toml-env\n```\n\n## 🏗️ Usage\n\nCreate a `.env.toml` file in the folder where you start the entry point of your project (typically the root of the repository). This file should be a valid TOML file so strings should adhere to [TOML's allowed string notations](https://toml.io/en/v1.0.0#string).\n\n```toml\nREMOTE_HOST='42.42.42.42'\nAPI_TOKEN=\"bla42bla42bla42_\"\n```\n\nThere are plenty of ways to load `toml-env` with the default configuration:\n\n```sh\n# using Node's --require flag, assuming index.js as entry point\nnode -r @2colours/toml-env/config index.js\n```\n\n```javascript\n// within the source code, as soon as possible\nrequire('@2colours/toml-env').config();\nconsole.log(process.env.REMOTE_HOST);\n```\n\n.. or using ES6\n\n```javascript\n// within the source code, as soon as possible\nimport '@2colours/toml-env/config';\n```\n\nAfter the loading of the package, the values from `.env.toml` are exposed under `process.env` and `process.envTyped`. The difference is that in `process.env` all values are stringified (TOML allows advanced types like dates, tables and arrays), while `process.envTyped` preserves the types using the native JS equivalents.\n\n### Format and parsing\n\n`toml-env` uses a fully-fledged [TOML](https://toml.io) parser to process the content of the configuration file. Everything can be used, within the limits of Javascript types. For more information, consult [the underlying TOML parser library](https://github.com/squirrelchat/smol-toml).\n\n### Preload\n\nYou can use the `--require` (`-r`) [command line option](https://nodejs.org/api/cli.html#-r---require-module) to preload `toml-env`. By doing this, you do not need to require and load `toml-env` in your application code.\n\nThe configuration options below are supported as command line arguments in the format `toml_env_config_<option>=value`\n\n```sh\n$ node -r @2colours/toml-env/config your_script.js toml_env_config_path=/custom/path/to/.env.toml toml_env_config_debug=true\n```\n\nAdditionally, you can use environment variables to set configuration options. Command line arguments will precede these.\n\n```sh\n$ TOML_ENV_CONFIG_<OPTION>=value node -r @2colours/toml-env/config your_script.js\n```\n\n```sh\n$ TOML_ENV_CONFIG_ENCODING=latin1 TOML_ENV_CONFIG_DEBUG=true node -r @2colours/toml-env/config your_script.js toml_env_config_path=/custom/path/to/.env.toml\n```\n\n------------------------------\n\n### Multiple Environments\n\n*** Notice: currently, this functionality is largely relying on the original functionality of `dotenv`, therefore the following parts are verbatim taken from the README of `dotenv`. To migrate the files, the following steps are required: ***\n\n1. Please make sure that your `.env.vault` file is valid according to TOML syntax (e.g. string quoting).\n2. Instead of `DOTENV_NAMES`, use `TOML_ENV_NAMES` as the keys.\n3. Rename the `.env.vault` file to `.env.toml.vault` or specify the path.\n\nYou need to manage your secrets across different environments and apply them as needed? Use a `.env.vault` file with a `DOTENV_KEY`.\n\n### Deploying\n\nYou need to deploy your secrets in a cloud-agnostic manner? Use a `.env.vault` file. See [deploying `.env.vault` files](https://github.com/motdotla/dotenv/tree/master#-deploying).\n\n## 🌴 Manage Multiple Environments\n\nUse [dotenvx](https://github.com/dotenvx/dotenvx) or [dotenv-vault](https://github.com/dotenv-org/dotenv-vault).\n\n### dotenvx\n\nRun any environment locally. Create a `.env.ENVIRONMENT` file and use `--env-file` to load it. It's straightforward, yet flexible.\n\n```bash\n$ echo \"HELLO=production\" > .env.production\n$ echo \"console.log('Hello ' + process.env.HELLO)\" > index.js\n\n$ dotenvx run --env-file=.env.production -- node index.js\nHello production\n> ^^\n```\n\nor with multiple .env files\n\n```bash\n$ echo \"HELLO=local\" > .env.local\n$ echo \"HELLO=World\" > .env\n$ echo \"console.log('Hello ' + process.env.HELLO)\" > index.js\n\n$ dotenvx run --env-file=.env.local --env-file=.env -- node index.js\nHello local\n```\n\n[more environment examples](https://dotenvx.com/docs/quickstart/environments)\n\n### dotenv-vault\n\nEdit your production environment variables.\n\n```bash\n$ npx dotenv-vault open production\n```\n\nRegenerate your `.env.vault` file.\n\n```bash\n$ npx dotenv-vault build\n```\n\n*ℹ️  🔐 Vault Managed vs 💻 Locally Managed: The above example, for brevity's sake, used the 🔐 Vault Managed solution to manage your `.env.vault` file. You can instead use the 💻 Locally Managed solution. [Read more here](https://github.com/dotenv-org/dotenv-vault#how-do-i-use--locally-managed-dotenv-vault). Our vision is that other platforms and orchestration tools adopt the `.env.vault` standard as they did the `.env` standard. We don't expect to be the only ones providing tooling to manage and generate `.env.vault` files.*\n\n<a href=\"https://github.com/dotenv-org/dotenv-vault#-manage-multiple-environments\">Learn more at dotenv-vault: Manage Multiple Environments</a>\n\n## 🚀 Deploying\n\nUse [dotenvx](https://github.com/dotenvx/dotenvx) or [dotenv-vault](https://github.com/dotenv-org/dotenv-vault).\n\n### dotenvx\n\nEncrypt your secrets to a `.env.vault` file and load from it (recommended for production and ci).\n\n```bash\n$ echo \"HELLO=World\" > .env\n$ echo \"HELLO=production\" > .env.production\n$ echo \"console.log('Hello ' + process.env.HELLO)\" > index.js\n\n$ dotenvx encrypt\n[dotenvx][info] encrypted to .env.vault (.env,.env.production)\n[dotenvx][info] keys added to .env.keys (DOTENV_KEY_PRODUCTION,DOTENV_KEY_PRODUCTION)\n\n$ DOTENV_KEY='<dotenv_key_production>' dotenvx run -- node index.js\n[dotenvx][info] loading env (1) from encrypted .env.vault\nHello production\n^ :-]\n```\n\n[learn more](https://github.com/dotenvx/dotenvx?tab=readme-ov-file#encryption)\n\n### dotenv-vault\n\nEncrypt your `.env.vault` file.\n\n```bash\n$ npx dotenv-vault build\n```\n\nFetch your production `DOTENV_KEY`.\n\n```bash\n$ npx dotenv-vault keys production\n```\n\nSet `DOTENV_KEY` on your server.\n\n```bash\n# heroku example\nheroku config:set DOTENV_KEY=dotenv://:key_1234…@dotenvx.com/vault/.env.vault?environment=production\n```\n\nThat's it! On deploy, your `.env.vault` file will be decrypted and its secrets injected as environment variables – just in time.\n\n*ℹ️ A note from [Mot](https://github.com/motdotla): Until recently, we did not have an opinion on how and where to store your secrets in production. We now strongly recommend generating a `.env.vault` file. It's the best way to prevent your secrets from being scattered across multiple servers and cloud providers – protecting you from breaches like the [CircleCI breach](https://techcrunch.com/2023/01/05/circleci-breach/). Also it unlocks interoperability WITHOUT native third-party integrations. Third-party integrations are [increasingly risky](https://coderpad.io/blog/development/heroku-github-breach/) to our industry. They may be the 'du jour' of today, but we imagine a better future.*\n\n<a href=\"https://github.com/dotenv-org/dotenv-vault#-deploying\">Learn more at dotenv-vault: Deploying</a>\n\n----------------------------------------\n\n## 📖 Documentation\n\n`toml-env` exposes four functions:\n\n* `config`\n* `parse`\n* `populate`\n* `decrypt`\n\n### Config\n\n`config` will read your `.env.toml` file, parse the contents, assign it to `process.env` (all values stringified) and `process.envTyped` (all values as JS equivalents of TOML types) and return an Object with a `parsed` key containing the loaded content (either the stringified one or the typed one) or an `error` key if it failed.\n\n```js\nconst result = tomlEnv.config();\n\nif (result.error) {\n  throw result.error;\n}\n\nconsole.log(result.parsed);\n```\n\nYou can additionally, pass options to `config`.\n\n#### Options\n\n##### path\n\nDefault: `path.resolve(process.cwd(), '.env.toml')`\n\nSpecify a custom path if your file is located elsewhere.\n\n```js\nrequire('@2colours/toml-env').config({ path: '/custom/path/to/.env.toml' });\n```\n\nBy default, `config` will look for a file called .env.toml in the current working directory.\n\nPass in multiple files as an array, and they will be parsed in order and combined into `process.env` and `process.envTyped` (or `option.processEnv` and `option.processEnvTyped` respectively, if set). By default, once a key has been set a value, instances of that same key in subsequent files are ignored. To override the value of a key with each subsequent file, set `options.override` to `true`. \n\n```js  \nrequire('@2colours/toml-env').config({ path: ['.env.toml.local', '.env.toml'] });\n```\n\n##### encoding\n\nDefault: `utf8`\n\nSpecify the encoding of your file containing environment variables.\n\n```js\nrequire('@2colours/toml-env').config({ encoding: 'latin1' });\n```\n\n##### debug\n\nDefault: `false`\n\nTurn on logging to help debug why certain keys or values are not being set as you expect.\n\n```js\nrequire('@2colours/toml-env').config({ debug: process.env.DEBUG });\n```\n\n##### override\n\nDefault: `false`\n\nOverride any environment variables that have already been set on your machine with values from your .env file(s).\n\nWhen providing multiple files in `options.path`, this option will also tell `toml-env` to override the value of a key upon encountering a duplicate definition.\n\n```js\nrequire('@2colours/toml-env').config({ override: true });\n```\n\n##### processEnv\n\nDefault: `process.env`\n\nSpecify an object to write your (stringified) secrets to. Defaults to `process.env` environment variables.\n\n```js\nconst myObject = {};\nrequire('@2colours/toml-env').config({ processEnv: myObject });\n\nconsole.log(myObject); // values from .env.toml or .env.toml.vault live here now.\nconsole.log(process.env); // this was not changed or written to\n```\n\n##### processEnvTyped\n\nDefault: `process.envTyped`\n\nSpecify an object to write your (typed) secrets to. Defaults to the monkey-patched `process.envTyped` property.\n\n```js\nconst myObject = {};\nrequire('@2colours/toml-env').config({ processEnvTyped: myObject });\n\nconsole.log(myObject); // values from .env.toml or .env.toml.vault live here now.\nconsole.log(process.envTyped); // this was not changed or written to\n```\n\n##### TOML_ENV_KEY\n\nDefault: `process.env.TOML_ENV_KEY`\n\nPass the `TOML_ENV_KEY` directly to config options. Defaults to looking for `process.env.TOML_ENV_KEY` environment variable. Note this only applies to decrypting `.env.toml.vault` files. If passed as null or undefined, or not passed at all, `toml-env` falls back to its traditional job of parsing a `.env.toml` file.\n\n```js\nrequire('@2colours/toml-env').config({ TOML_ENV_KEY: 'toml-env://:key_1234…@dotenvx.com/vault/.env.vault?environment=production' })\n```\n\n### Parse\n\nThe underlying TOML parser exposed as is. Unlike for `dotenv`, it only accepts strings. Please consult the [official repository](https://github.com/squirrelchat/smol-toml) for further information.\n\n```js\nconst tomlEnv = require('@2colours/toml-env');\nconst rawData = `point = { x = 1, y = 2 }\nnames = ['Alfred', 'Dorothy', 'Kim']\n`;\nconst config = tomlEnv.parse(rawData); // will return an object\n// { point : { x : 1, y : 2}, names: [\"Alfred\", \"Dorothy\", \"Kim\"] }\n```\n\n### Populate\n\nThe engine which populates `process.env` and `process.envTyped` with the contents of your .env.toml file is available for use. It accepts a target, a source, and options. This is useful for power users who want to supply their own objects.\n\nFor example, customizing the source:\n\n```js\nconst tomlEnv = require('@2colours/toml-env');\nconst parsed = { HELLO: 'world' };\n\ntomlEnv.populate(process.env, parsed);\n\nconsole.log(process.env.HELLO); // world\n```\n\nFor example, customizing the source AND target:\n\n```js\nconst tomlEnv = require('@2colours/toml-env');\nconst parsed = { HELLO: 'universe' };\nconst target = { HELLO: 'world' }; // empty object\n\ntomlEnv.populate(target, parsed, { override: true, debug: true });\n\nconsole.log(target); // { HELLO: 'universe' }\n```\n\n#### options\n\n##### Debug\n\nDefault: `false`\n\nTurn on logging to help debug why certain keys or values are not being populated as you expect.\n\n##### override\n\nDefault: `false`\n\nOverride any environment variables that have already been set.\n\n### Decrypt\n\nThe engine which decrypts the ciphertext contents of your .env.vault file is available for use. It accepts a ciphertext and a decryption key. It uses AES-256-GCM encryption.\n\nFor example, decrypting a simple ciphertext:\n\n```js\nconst tomlEnv = require('@2colours/toml-env');\nconst ciphertext = 's7NYXa809k/bVSPwIAmJhPJmEGTtU0hG58hOZy7I0ix6y5HP8LsHBsZCYC/gw5DDFy5DgOcyd18R';\nconst decryptionKey = 'ddcaa26504cd70a6fef9801901c3981538563a1767c297cb8416e8a38c62fe00';\n\nconst decrypted = tomlEnv.decrypt(ciphertext, decryptionKey);\n\nconsole.log(decrypted); // # development@v6\\nALPHA=\"zeta\"\n```\n\n## 👏 Prior art and thanks\n\nThe project is based on the idea, spec tests and source code of [dotenv](https://github.com/motdotla/dotenv), its licensing terms are included in [LICENSE](./LICENSE).\n\nSpecial thanks to the creators of [smol-toml](https://github.com/squirrelchat/smol-toml), a modern, performant and reliable TOML 1.0 compatible parser written in Typescript.\n\n[zaida04's tomlenv](https://github.com/zaida04/tomlenv) deserves to be mentioned as prior art. It has a different aim from `toml-env`:\n- `tomlenv` aims to contain only environment variables like `dotenv` and it only uses TOML segments for defining various environments in the same file\n- `toml-env` aims to extend over core `dotenv` functionality by allowing structured data in the file containing secrets, filling the gap between arbitrary configuration files and environment variables while trying to retain good compatibility with `dotenv` where appropriate\n","readmeFilename":"README.md"}