{"id":23236762,"url":"https://github.com/pratikpc/node.js-vault-username-password","last_synced_at":"2026-05-10T02:52:07.491Z","repository":{"id":125288778,"uuid":"246528034","full_name":"pratikpc/Node.JS-Vault-Username-Password","owner":"pratikpc","description":"A sample code for Node.JS with Hashicorp involving Username and Password based Authentication","archived":false,"fork":false,"pushed_at":"2020-10-27T16:22:37.000Z","size":39,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-25T22:22:17.514Z","etag":null,"topics":["nodejs","typescript","vault","vault-client"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/node-vault-user-pass","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/pratikpc.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":"2020-03-11T09:27:05.000Z","updated_at":"2020-10-27T16:22:34.000Z","dependencies_parsed_at":null,"dependency_job_id":"b9875b6c-d8a3-492d-9747-df2512e2628e","html_url":"https://github.com/pratikpc/Node.JS-Vault-Username-Password","commit_stats":{"total_commits":32,"total_committers":1,"mean_commits":32.0,"dds":0.0,"last_synced_commit":"aac77c77d251997801753333c604cf6672ade8dc"},"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pratikpc%2FNode.JS-Vault-Username-Password","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pratikpc%2FNode.JS-Vault-Username-Password/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pratikpc%2FNode.JS-Vault-Username-Password/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pratikpc%2FNode.JS-Vault-Username-Password/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pratikpc","download_url":"https://codeload.github.com/pratikpc/Node.JS-Vault-Username-Password/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247399897,"owners_count":20932881,"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":["nodejs","typescript","vault","vault-client"],"created_at":"2024-12-19T04:12:38.887Z","updated_at":"2026-05-10T02:52:07.449Z","avatar_url":"https://github.com/pratikpc.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# [Node.JS-Vault-Username-Password](https://github.com/pratikpc/Node.JS-Vault-Username-Password)\n\nA sample code for Node.JS [Vault by Hashicorp](https://www.hashicorp.com/products/vault) involving [Username and Password based Authentication](https://learn.hashicorp.com/vault/secrets-management/sm-static-secrets#step-1-enable-kv-secrets-engine). This ensures that all data is securely stored behind username-password based authentication.\n\nIn case a user, has no desire to store Secrets on the Vault, this code can also be used for User Authentication as well.\n\nFor further details regarding Password Based Auth, check out [https://learn.hashicorp.com/vault/secrets-management/sm-static-secrets](https://learn.hashicorp.com/vault/secrets-management/sm-static-secrets)\n\nThis code also tries to ensure that One User cannot access data of another user present in the Vault.\n\nInstall with\n`npm i node-vault-user-pass `\n\n## [Sample Code](samples/index.js)\n\n#### CONFIGURATION\n\n```javascript\n// process.env.DEBUG = 'node-vault'; // switch on debug mode\nconst { VaultAccess } = require(\"node-vault-user-pass\");\n```\n\n#### Initialize\n\n```javascript\nconst Vault = new VaultAccess({\n  Authority: [\"create\", \"read\", \"update\", \"delete\", \"list\", \"sudo\"],\n  Path: \"path\",\n  Policy: \"auth_policy\",\n  EndPoint: \"http://localhost:8200\",\n  UserName: \"username\",\n  SecretMountPoint: \"secret_zone\",\n  // Either Set this in Command Line as an Environment Variable\n  // Use set VAULT_TOKEN or export VAULT_TOKEN depending\n  // upon your OS\n  // Or Provide it as String Here\n  // This must be a Root Token\n  // Or a token with substantial access\n  Token: String(process.env.VAULT_TOKEN),\n  // Yet to be Implemented\n  CertificateMountPoint: \"certificate\"\n});\n```\n\n#### RUNNING\n\n```javascript\nasync function run() {\n  // In Order to run Setup, the user needs Root Token\n  await Vault.Setup();\n  await Vault.SignUp(\"password\" /*'username'*/);\n  console.log(\"Sign Up Successfull\");\n  await Vault.SignIn(\"password\" /*'username'*/);\n  console.log(\"Sign In Successfull\");\n\n  const value = {\n    foo: \"3\",\n    bar: \"4\"\n  };\n  await Vault.Write(\"key\", value);\n  console.log(\"Wrote Value\", value, \"successfully\");\n  const val = await Vault.Read(\"key\");\n  console.log(\"Read value is \", val);\n\n  // Unmount is an admin action\n  // As such, the user needs Root Token\n  // Or At least access to /sys/mount provided\n  await Vault.Unmount();\n}\n\nrun().then(() =\u003e {\n  console.log(\"done\");\n});\n```\n\n## Reason for Creation\n\n1. To Ensure Secured Access to data\n2. To Ensure Secured Storage of Data\n3. This Project was mostly born out of a linkage with A Blockchain Based project where we needed to store Public and Private Keys in a secure manner\n\n## TODO\n\n1. [Add Support for Certificates](https://www.vaultproject.io/api-docs/secret/pki/)\n\n#### DEPENDENCIES\n\n1. [node-vault](https://www.npmjs.com/package/node-vault \"node-vault\") Library for API Calls to Vault\n\n#### RUNNING Vault\n\nYou can run Vault via Docker. I have created a [simple script to run Vault with Docker](https://github.com/pratikpc/Docker-Common-Configs/blob/master/Vault%20Docker%20Starter.bat).\n\n#### Contact Us\n\nYou could contact me [via LinkedIn](https://www.linkedin.com/in/pratik-chowdhury-889bb2183/ \"via LinkedIn\")\nYou could file issues or add features via Pull Requests on GitHub\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpratikpc%2Fnode.js-vault-username-password","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpratikpc%2Fnode.js-vault-username-password","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpratikpc%2Fnode.js-vault-username-password/lists"}