{"id":28758275,"url":"https://github.com/pixielabs/jsecrets","last_synced_at":"2025-06-17T04:07:38.141Z","repository":{"id":57284307,"uuid":"241916685","full_name":"pixielabs/jsecrets","owner":"pixielabs","description":"jsecrets is a wrapper around AWS Secrets Manager for your JavaScript projects.","archived":false,"fork":false,"pushed_at":"2020-02-20T16:39:48.000Z","size":99,"stargazers_count":6,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-05T16:41:15.273Z","etag":null,"topics":["aws-secrets-manager","aws-security","express-js","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","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/pixielabs.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.txt","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-02-20T15:18:11.000Z","updated_at":"2024-04-18T12:31:49.000Z","dependencies_parsed_at":"2022-09-16T22:40:44.716Z","dependency_job_id":null,"html_url":"https://github.com/pixielabs/jsecrets","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/pixielabs/jsecrets","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixielabs%2Fjsecrets","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixielabs%2Fjsecrets/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixielabs%2Fjsecrets/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixielabs%2Fjsecrets/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pixielabs","download_url":"https://codeload.github.com/pixielabs/jsecrets/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pixielabs%2Fjsecrets/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260288472,"owners_count":22986667,"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":["aws-secrets-manager","aws-security","express-js","javascript"],"created_at":"2025-06-17T04:07:37.115Z","updated_at":"2025-06-17T04:07:38.107Z","avatar_url":"https://github.com/pixielabs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Actions Status](https://github.com/pixielabs/jsecrets/workflows/Unit%20and%20Feature%20tests/badge.svg)](https://github.com/pixielabs/jsecrets/actions)\n[![npm version](https://badge.fury.io/js/jsecrets.svg)](https://badge.fury.io/js/jsecrets)\n\n# jsecrets\n\njsecrets lets you fetch and use secrets from\n[AWS Secrets Manager](https://aws.amazon.com/secrets-manager/) in your\nJavaScript projects. jsecrets is built and maintained by \n[Pixie Labs](https://pixielabs.io).\n\nYou may want to use this if you use AWS Secrets Manager to store encrypted\ncredentials, e.g. for your database, or for accessing an API with a token,\nand need to access those credentials in a backend JavaScript application e.g.\nan Express server, Lambda function, or some other backend piece of code.\n\n## Install\n\nAdd the package to your package.json with either NPM or Yarn:\n\n```shell\n# With NPM:\n$ npm i -S jsecrets\n# With Yarn:\n$ yarn add jsecrets\n```\n\n## Fetching secrets\n\njsecrets expects that your secrets are JSON objects stored in AWS Secrets\nManager as strings.\n\n```js\n// app.js\nconst jsecrets = require(\"jsecrets\");\n\ntry {\n  // Fetch secrets from AWS Secrets Manager with jsecrets.fetch(), passing in\n  // the region and an array of secret IDs. The secret ID can be the Amazon\n  // Resource Name (ARN) or the \"friendly name\" of the secret.\n  await jsecrets.fetch(\"eu-west-2\", [\"databaseSecret\", \"anotherSecret\"]);\n\n  // Once the secrets have been retrieved, individual values can be extracted by\n  // passing in the name of the secret and the key to jsecrets.get().\n  const database = jsecrets.get(\"databaseSecret\", \"database\");\n  const username = jsecrets.get(\"databaseSecret\", \"username\");\n  const password = jsecrets.get(\"databaseSecret\", \"password\");\n  const options = {\n    host: jsecrets.get(\"databaseSecret\", \"host\"),\n    dialect: \"postgres\"\n  };\n\n  // You might then use those secrets to configure a DB connection, such as:\n  const sequelize = new Sequelize(database, username, password, options);\n\n  // The rest of your app goes here.\n\n} catch (e) {\n  console.log(e.message);\n}\n```\n\n## Stubbing jsecrets in development\n\njsecrets has a helper method making it easy to stub calls to AWS when you are\ndeveloping your application, and so don't need to use production secrets.\nImmediately after the `import`, call `jsecrets.devStubs()` passing in an \nobject with the same shape as your secrets.The stubs will be used in all\ncircumstances.\n\nWrap the call to `jsecrets.devStubs()` in a `if` block to ensure `devStubs()`\nis not called in production.\n\nIf you have multiple secrets, you can pass them all into `jsecrets.devStubs()`\nat once.\n\nFor example:\n\n```js\nconst jsecrets = require('jsecrets');\n\nif (process.env.NODE_ENV != 'production') {\n  // Stub the return values of jsecrets.get() unless the app is running in\n  // production.\n  jsecrets.devStubs({\n    'databaseSecret': {\n      'database': 'jsecrets_node_app',\n      'host': 'localhost',\n      'username': 'pixielabs',\n      'password': 'pixielabs_secrets'\n    },\n    'anotherSecret': {\n      'jwt_signing_key': 'jsecret_signing',\n      'jwt_client_key': 'jsecret_client'\n    }\n  })\n}\n\ntry {\n  // Fetch secrets from AWS Secrets Manager with jsecrets.fetch()\n  await jsecrets.fetch(\"eu-west-2\", [\"databaseSecret\", \"anotherSecret\"]);\n```\n\n## Errors\n\nAll errors returned by jsecrets will have a `message` key.\n\nIf the error is from AWS then there will also be other keys such as\n`code`, `time` and `statusCode`.\n\n\n## Contributing\n\n### Running the tests\n\nUnit tests can be run with:\n```\n$ npm test\n```\n\nFeature tests are part of the example Express app within the exampleApp folder:\n```\n$ npm run exampleAppStart\n```\n\nIn a new terminal:\n```\n$ npm run exampleAppTest\n```\n\nBefore contributing, please read the [code of conduct](CODE_OF_CONDUCT.md).\n- Check out the latest master to make sure the feature hasn't been implemented\n  or the bug hasn't been fixed yet.\n- Check out the issue tracker to make sure someone already hasn't requested it\n  and/or contributed it.\n- Fork the project.\n- Start a feature/bugfix branch.\n- Commit and push until you are happy with your contribution.\n- Please try not to mess with the package.json, version, or history. If you\n  want to have your own version, or is otherwise necessary, that is fine, but\n  please isolate to its own commit so we can cherry-pick around it.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixielabs%2Fjsecrets","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpixielabs%2Fjsecrets","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpixielabs%2Fjsecrets/lists"}