{"id":19107338,"url":"https://github.com/smartcontractkit/env-enc","last_synced_at":"2025-04-30T18:46:02.523Z","repository":{"id":151709533,"uuid":"624631085","full_name":"smartcontractkit/env-enc","owner":"smartcontractkit","description":null,"archived":false,"fork":false,"pushed_at":"2023-04-11T17:16:02.000Z","size":45,"stargazers_count":31,"open_issues_count":4,"forks_count":4,"subscribers_count":10,"default_branch":"main","last_synced_at":"2025-04-19T08:10:31.803Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smartcontractkit.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2023-04-06T22:46:43.000Z","updated_at":"2025-03-30T08:15:17.000Z","dependencies_parsed_at":"2023-04-21T15:16:57.216Z","dependency_job_id":null,"html_url":"https://github.com/smartcontractkit/env-enc","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fenv-enc","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fenv-enc/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fenv-enc/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smartcontractkit%2Fenv-enc/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smartcontractkit","download_url":"https://codeload.github.com/smartcontractkit/env-enc/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251765284,"owners_count":21640170,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-09T04:12:11.799Z","updated_at":"2025-04-30T18:46:02.517Z","avatar_url":"https://github.com/smartcontractkit.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# env-enc\n\nA tool for loading and storing encrypted environment variables\n\n## What\n\nThis is a tool for keeping environment variables such as private keys and other credentials encrypted at rest.\nThis reduces the risk of credential exposure by ensuring credentials are not visible in plaintext or in terminal history.\nIt also allows an encrypted environment variables to be stored on Github, provided they are protected with a secure password.\n\nFor loading environment variables, this works in a similar manner to the NPM package `dotenv` where environment variables are loaded from a `.env` file.\nHowever, this plugin instead uses CLI commands to create an `.env.enc` file which stores environment variables that are encrypted using a password.\nThen, when the `config()` method is called, these variables will be decrypted and loaded into the environment.\n\n## Installation\n\n1. Install `@chainlink/env-enc` from NPM\n2. Import the package in your project's main file (this will be `hardhat.config.js` or `hardhat.config.ts` for HardHat projects)\n\n- For JavaScript projects, add the following line to the top of main file (usually `index.js`):\n\n  ```\n  require(\"@chainlink/env-enc\").config();\n  ```\n\n- For Typescript projects, add the following lines to the top of main file (usually `index.ts`):\n\n  ```\n  import * as envEnc from \"@chainlink/env-enc\";\n  envEnc.config();\n  ```\n\n## Commands\n\nThe following commands accept an optional `--path` flag followed by a path to the desired encrypted environment variable file.\nIf one does not exist, it will be created automatically by the `npx env-enc set` command.\n\nThe `--path` flag has no effect on the `npx env-enc set-pw` command as the password is stored as an ephemeral environment variable for the current terminal session.\n\n| Command                     | Description                                                                                                                                       | Parameters            |\n| --------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |\n| `npx env-enc set-pw`        | Sets the password to encrypt and decrypt the environment variable file **NOTE:** On Windows, this command may show a security confirmation prompt |                       |\n| `npx env-enc set`           | Sets and saves variables to the encrypted environment variable file                                                                               |                       |\n| `npx env-enc view`          | Shows all currently saved variables in the encrypted environment variable file                                                                    |                       |\n| `npx env-enc remove \u003cname\u003e` | Removes a variable from the encrypted environment variable file                                                                                   | `name`: Variable name |\n| `npx env-enc remove-all`    | Deletes the encrypted environment variable file                                                                                                   |                       |\n\n## Configuration\n\nBy default, all encrypted environment variables will be stored in a file named `.env.enc` in the root directory of your project.\nHowever, this file path can be configured using the `path` option in the `config()` method as shown below:\n\n```\nrequire(\"@chainlink/env-enc\").config({ path: './your_directory/my_env.enc' });\n```\n\n## Usage\n\nFirst, set the encryption password by running the command `npx env-enc set-password`.\nThe password must be set at the beginning of each new session.\nIf this password is lost, there will be no way to recover the encrypted environment variables.\n\nWhen running this command on a Windows machine, you may receive a security confirmation prompt. Enter \"r\" to proceed.\n\n\u003e **NOTE:** When you finish each work session, exit your terminal to prevent your password from becoming exposes if your machine is compromised.\n\nRun the command `npx env-enc set` to set and save environment variables.\nThese variables will be loaded into your environment when the `config()` method is called.\nUse `npx env-enc view` to view all currently saved environment variables.\nWhen pressing _ENTER_, the terminal will be cleared to prevent these values from remaining visible.\nRunning `npx env-enc remove VAR_NAME_HERE` deletes the specified environment variable.\nThe command `npx env-enc remove-all` deletes the entire saved environment variable file.\n\nIf you lose your password, delete your encrypted environment variable file. If you attempt to load an encrypted environment variable file without the correct password, it will cause an error.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartcontractkit%2Fenv-enc","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmartcontractkit%2Fenv-enc","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmartcontractkit%2Fenv-enc/lists"}