diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 5878def4..593d067a 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,2 +1,2 @@ github: motdotla -custom: https://www.dotenv.org +custom: https://www.dotenvx.com diff --git a/README.md b/README.md index f27a095f..456a90ad 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,6 @@ Dotenv is a zero-dependency module that loads environment variables from a `.env [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square)](https://github.com/feross/standard) [![LICENSE](https://img.shields.io/github/license/motdotla/dotenv.svg)](LICENSE) -[![dotenv-vault](https://badge.dotenv.org/works-with.svg?r=1)](https://www.dotenv.org/r/github.com/dotenv-org/dotenv-vault?r=1) * [🌱 Install](#-install) * [🏗️ Usage (.env)](#%EF%B8%8F-usage) @@ -291,7 +290,7 @@ Set `DOTENV_KEY` on your server. ```bash # heroku example -heroku config:set DOTENV_KEY=dotenv://:key_1234…@dotenv.org/vault/.env.vault?environment=production +heroku config:set DOTENV_KEY=dotenv://:key_1234…@dotenvx.com/vault/.env.vault?environment=production ``` That's it! On deploy, your `.env.vault` file will be decrypted and its secrets injected as environment variables – just in time. @@ -418,7 +417,7 @@ Default: `process.env.DOTENV_KEY` Pass the `DOTENV_KEY` directly to config options. Defaults to looking for `process.env.DOTENV_KEY` environment variable. Note this only applies to decrypting `.env.vault` files. If passed as null or undefined, or not passed at all, dotenv falls back to its traditional job of parsing a `.env` file. ```js -require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenv.org/vault/.env.vault?environment=production' }) +require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenvx.com/vault/.env.vault?environment=production' }) ``` ### Parse diff --git a/lib/main.d.ts b/lib/main.d.ts index 965988e8..a48c3c15 100644 --- a/lib/main.d.ts +++ b/lib/main.d.ts @@ -9,7 +9,7 @@ export interface DotenvParseOutput { /** * Parses a string or buffer in the .env file format into an object. * - * See https://docs.dotenv.org + * See https://dotenvx.com/docs * * @param src - contents to be parsed. example: `'DB_HOST=localhost'` * @returns an object with keys and values based on `src`. example: `{ DB_HOST : 'localhost' }` @@ -71,7 +71,7 @@ export interface DotenvConfigOptions { * * Pass the DOTENV_KEY directly to config options. Defaults to looking for process.env.DOTENV_KEY environment variable. Note this only applies to decrypting .env.vault files. If passed as null or undefined, or not passed at all, dotenv falls back to its traditional job of parsing a .env file. * - * example: `require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenv.org/vault/.env.vault?environment=production' })` + * example: `require('dotenv').config({ DOTENV_KEY: 'dotenv://:key_1234…@dotenvx.com/vault/.env.vault?environment=production' })` */ DOTENV_KEY?: string; } @@ -108,7 +108,7 @@ export interface DotenvPopulateInput { /** * Loads `.env` file contents into process.env by default. If `DOTENV_KEY` is present, it smartly attempts to load encrypted `.env.vault` file contents into process.env. * - * See https://docs.dotenv.org + * See https://dotenvx.com/docs * * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', debug: true, override: false }` * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } } @@ -119,7 +119,7 @@ export function config(options?: DotenvConfigOptions): DotenvConfigOutput; /** * Loads `.env` file contents into process.env. * - * See https://docs.dotenv.org + * See https://dotenvx.com/docs * * @param options - additional options. example: `{ path: './custom/path', encoding: 'latin1', debug: true, override: false }` * @returns an object with a `parsed` key if successful or `error` key if an error occurred. example: { parsed: { KEY: 'value' } } @@ -130,7 +130,7 @@ export function configDotenv(options?: DotenvConfigOptions): DotenvConfigOutput; /** * Loads `source` json contents into `target` like process.env. * - * See https://docs.dotenv.org + * See https://dotenvx.com/docs * * @param processEnv - the target JSON object. in most cases use process.env but you can also pass your own JSON object * @param parsed - the source JSON object @@ -143,7 +143,7 @@ export function populate(processEnv: DotenvPopulateInput, parsed: DotenvPopulate /** * Decrypt ciphertext * - * See https://docs.dotenv.org + * See https://dotenvx.com/docs * * @param encrypted - the encrypted ciphertext string * @param keyStr - the decryption key string diff --git a/lib/main.js b/lib/main.js index 069f49c9..fd04dce7 100644 --- a/lib/main.js +++ b/lib/main.js @@ -59,7 +59,7 @@ function _parseVault (options) { } // handle scenario for comma separated keys - for use with key rotation - // example: DOTENV_KEY="dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenv.org/vault/.env.vault?environment=prod" + // example: DOTENV_KEY="dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=prod,dotenv://:key_7890@dotenvx.com/vault/.env.vault?environment=prod" const keys = _dotenvKey(options).split(',') const length = keys.length @@ -123,7 +123,7 @@ function _instructions (result, dotenvKey) { uri = new URL(dotenvKey) } catch (error) { if (error.code === 'ERR_INVALID_URL') { - const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development') + const err = new Error('INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development') err.code = 'INVALID_DOTENV_KEY' throw err } diff --git a/tests/test-config-vault.js b/tests/test-config-vault.js index 2eca9b85..5719f86c 100644 --- a/tests/test-config-vault.js +++ b/tests/test-config-vault.js @@ -7,7 +7,7 @@ const dotenv = require('../lib/main') const testPath = 'tests/.env' -const dotenvKey = 'dotenv://:key_ddcaa26504cd70a6fef9801901c3981538563a1767c297cb8416e8a38c62fe00@dotenv.org/vault/.env.vault?environment=development' +const dotenvKey = 'dotenv://:key_ddcaa26504cd70a6fef9801901c3981538563a1767c297cb8416e8a38c62fe00@dotenvx.com/vault/.env.vault?environment=development' let envStub let logStub @@ -146,7 +146,7 @@ t.test('throws error when invalid formed DOTENV_KEY', ct => { try { dotenv.config({ path: testPath }) } catch (e) { - ct.equal(e.message, 'INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenv.org/vault/.env.vault?environment=development') + ct.equal(e.message, 'INVALID_DOTENV_KEY: Wrong format. Must be in valid uri format like dotenv://:key_1234@dotenvx.com/vault/.env.vault?environment=development') ct.equal(e.code, 'INVALID_DOTENV_KEY') } @@ -173,7 +173,7 @@ t.test('throws error when invalid formed DOTENV_KEY that otherwise is not caught t.test('throws error when DOTENV_KEY missing password', ct => { envStub.restore() - envStub = sinon.stub(process.env, 'DOTENV_KEY').value('dotenv://username@dotenv.org/vault/.env.vault?environment=development') + envStub = sinon.stub(process.env, 'DOTENV_KEY').value('dotenv://username@dotenvx.com/vault/.env.vault?environment=development') ct.plan(2) @@ -189,7 +189,7 @@ t.test('throws error when DOTENV_KEY missing password', ct => { t.test('throws error when DOTENV_KEY missing environment', ct => { envStub.restore() - envStub = sinon.stub(process.env, 'DOTENV_KEY').value('dotenv://:key_ddcaa26504cd70a6fef9801901c3981538563a1767c297cb8416e8a38c62fe00@dotenv.org/vault/.env.vault') + envStub = sinon.stub(process.env, 'DOTENV_KEY').value('dotenv://:key_ddcaa26504cd70a6fef9801901c3981538563a1767c297cb8416e8a38c62fe00@dotenvx.com/vault/.env.vault') ct.plan(2) @@ -290,7 +290,7 @@ t.test('logs when debug is on and override is false', ct => { t.test('raises an INVALID_DOTENV_KEY if key RangeError', ct => { envStub.restore() - envStub = sinon.stub(process.env, 'DOTENV_KEY').value('dotenv://:key_ddcaa26504cd70a@dotenv.org/vault/.env.vault?environment=development') + envStub = sinon.stub(process.env, 'DOTENV_KEY').value('dotenv://:key_ddcaa26504cd70a@dotenvx.com/vault/.env.vault?environment=development') ct.plan(2) @@ -306,7 +306,7 @@ t.test('raises an INVALID_DOTENV_KEY if key RangeError', ct => { t.test('raises an DECRYPTION_FAILED if key fails to decrypt payload', ct => { envStub.restore() - envStub = sinon.stub(process.env, 'DOTENV_KEY').value('dotenv://:key_2c4d267b8c3865f921311612e69273666cc76c008acb577d3e22bc3046fba386@dotenv.org/vault/.env.vault?environment=development') + envStub = sinon.stub(process.env, 'DOTENV_KEY').value('dotenv://:key_2c4d267b8c3865f921311612e69273666cc76c008acb577d3e22bc3046fba386@dotenvx.com/vault/.env.vault?environment=development') ct.plan(2) @@ -322,7 +322,7 @@ t.test('raises an DECRYPTION_FAILED if key fails to decrypt payload', ct => { t.test('raises an DECRYPTION_FAILED if both (comma separated) keys fail to decrypt', ct => { envStub.restore() - envStub = sinon.stub(process.env, 'DOTENV_KEY').value('dotenv://:key_2c4d267b8c3865f921311612e69273666cc76c008acb577d3e22bc3046fba386@dotenv.org/vault/.env.vault?environment=development,dotenv://:key_c04959b64473e43dd60c56a536ef8481388528b16759736d89515c25eec69247@dotenv.org/vault/.env.vault?environment=development') + envStub = sinon.stub(process.env, 'DOTENV_KEY').value('dotenv://:key_2c4d267b8c3865f921311612e69273666cc76c008acb577d3e22bc3046fba386@dotenvx.com/vault/.env.vault?environment=development,dotenv://:key_c04959b64473e43dd60c56a536ef8481388528b16759736d89515c25eec69247@dotenvx.com/vault/.env.vault?environment=development') ct.plan(2) diff --git a/tests/test-env-options.js b/tests/test-env-options.js index 7bfad616..b1cc7a23 100644 --- a/tests/test-env-options.js +++ b/tests/test-env-options.js @@ -48,7 +48,7 @@ testOption('DOTENV_CONFIG_DEBUG', 'true', { debug: 'true' }) testOption('DOTENV_CONFIG_OVERRIDE', 'true', { override: 'true' }) // sets DOTENV_KEY option -testOption('DOTENV_CONFIG_DOTENV_KEY', 'dotenv://:key_ddcaa26504cd70a@dotenv.org/vault/.env.vault?environment=development', { DOTENV_KEY: 'dotenv://:key_ddcaa26504cd70a@dotenv.org/vault/.env.vault?environment=development' }) +testOption('DOTENV_CONFIG_DOTENV_KEY', 'dotenv://:key_ddcaa26504cd70a@dotenvx.com/vault/.env.vault?environment=development', { DOTENV_KEY: 'dotenv://:key_ddcaa26504cd70a@dotenvx.com/vault/.env.vault?environment=development' }) // restore existing env process.env.DOTENV_CONFIG_ENCODING = e