npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

secure-credentials

v0.0.1

Published

Securely save credentials on S3 and download at run-time

Downloads

143

Readme

Secure Credentials Node Module

Background

In almost every project, it's necessary to use credentials to access various resources (databases, APIs, etc.). The recommended way of loading these credentials in Node is through environment variables. However, the credentials still need to be hard-coded somewhere. On AWS, it is possible to create an S3 bucket that is very heavily restricted through access controls and IAM roles. This module allows for the dynamic loading of credentials from a file stored in such a bucket into environment variables accessible to the current process. If a machine hosting the code is compromised, its access can be revoked via IAM, thus never exposing the credentials for the running code.

Requirements

To use the module:

npm install secure-credentials
var sc = require('secure-credentials');
var config = {
	'AWS_REGION':'us-east-1',						// Required
	'AWS_ACCESS_KEY_ID':'accesskey',
	'AWS_SECRET_ACCESS_KEY':'secret',
	'BUCKET':'bucket.company.com/somebucket',		// Required
	'KEY':'test.config'								// Required
};

sc.download(config, function(err) {
	if (err) {
		// Handle error
	} else {
		// Start web server, make connections, etc.
	}
});

Additionally, be sure that the file, test.config, is hosted in the S3 bucket and is structured as:

VARIABLE=value
NEXTVARIABLE=nextvalue

With no spaces, commas, or extra characters.

IAM Roles

AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are provided as part of the config object for testing only. Hard-coding them in a production environment entirely defeats the purpose of this module. Instead, run the module from a machine that is part of an IAM role. The AWS SDK will automatically retrieve the temporary credentials securely and they will never be stored locally.

An Asynchronous Note

Because of Node.js's nature, this module cannot be used synchronously when making connections to a database, API, etc. The callback must be utilized so that the connection information is fully downloaded and loaded into the environment variable before the connections are attempted. When used with a webserver or framework such as Express, the module must be called first, then, in the callback, app.listen() can be called.