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

ez-aws-secrets

v1.0.9

Published

This package is a easy implementation to gather AWS secrets. It uses the AWS sdk and provides typings for typescript development also.

Downloads

6

Readme

Easy AWS Secrets

This package is a easy implementation to gather AWS secrets. It uses the AWS sdk and provides typings for typescript development also.

Installation

Simply intall via npm:

npm install ez-aws-secrets

Usage

There a two functionalities provided by this package

1. get

A simple function to get one or more aws secrets.

Inputs:

  • endpoint: string - Your AWS endpoint
  • region: string - Your AWS region
  • secrets: string [] - Array of secret ID's to retrieve

Outputs:

  • If given a single element in the array, the function returns the secret value
  • If given multiple, an object mapping secret id to value is returned

Example 1:

const { get } = require('ez-aws-secrets');
const endpoint = '...';
const region = '...';
const secretNames = ['testSecret'];

const value = get(endpoint, region, secretNames);
// Returned: secret value

Example 2:

const { get } = require('ez-aws-secrets');
const endpoint = '...';
const region = '...';
const secretNames = ['testSecret', 'testSecret2'];

const value = get(endpoint, region, secretNames);
/* Returned:
{
    'testSecret': value
    'testSecret2': value
}
*/

2. SecretManager

The SecretManager class allows a bulk of secrets to be retrieved upon initialisation, stored/cached and re-gathered efficiently later.

class SecretManager {
  // A public array mapping the secretID to the value
  public secrets: { secretID: any };

  /**
   * Initialises the class with the endpoint and region
   *
   *  @param { string } endpoint - AWS Endpoint
   *  @param { string } region - AWS Region
   */
  constructor(enpoint: string, region: string) {}

  /**
   * Function to initialise a bulk of secret keys. These
   * are stored in the secrets object.
   *
   *  @param { string[] } secrets - Array of secret IDs
   *
   *  @returns { "secretID": any } - Object mapping secretID to secret value for all secrets
   */
  async init(secrets: string[]) {}

  /**
   * Retrieves a secret value from the secrets object if exists, else retreives
   * from secret manager.
   *
   * @param {string} secret - SecretID to retrieve
   *
   * @returns { any } The secret value
   */
  async getSecret(secret: string) {}
}

Example:

const { SecretManager } = require('ez-aws-secrets');
const endpoint = '...';
const region = '...';
const secretNames = ['testSecret', 'testSecret2'];

const manager = new SecretManager(endpoint, region);
const values = await manager.init(secretNames);
/* Returned:
{
    'testSecret': value
    'testSecret2': value
}
*/

const secret = await manager.getSecret('testSecret');
/* Returned:
Secret Value
*/