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

aws-secrets-manager-wrapper

v0.0.4

Published

A TypeScript wrapper for AWS Secrets Manager that simplifies common operations and provides a more user-friendly interface.

Downloads

49

Readme

AWS Secrets Manager Wrapper

A TypeScript wrapper for AWS Secrets Manager that simplifies common operations and provides a more user-friendly interface.

Features

  • Easy-to-use methods for common Secrets Manager operations
  • Automatic parsing of JSON secrets
  • Customizable AWS configuration
  • Proper error handling and custom error types
  • TypeScript support for better type safety

Installation

npm install aws-secrets-manager-wrapper

Usage

Initialization

import { AWSSecretsManager } from "aws-secrets-manager-wrapper";

const secretsManager = new AWSSecretsManager({
  region: "us-east-1",
  // Optional: Provide credentials if not using environment variables or IAM roles
  // accessKeyId: 'YOUR_ACCESS_KEY_ID',
  // secretAccessKey: 'YOUR_SECRET_ACCESS_KEY',
});

Get a Secret

const secretName = "my-secret";
const secret = await secretsManager.getSecret(secretName);
console.log(secret);

Batch Get Secrets

const secretNames = ["secret1", "secret2", "secret3"];
const result = await secretsManager.batchGetSecrets({ secretIds: secretNames });
console.log(result.secrets);
console.log(result.errors);

Create a Secret

const secretName = "new-secret";
const secretValue = { key: "value" };
const arn = await secretsManager.createSecret(secretName, secretValue);
console.log(`Secret created with ARN: ${arn}`);

Update a Secret

const secretName = "existing-secret";
const newSecretValue = { updatedKey: "updatedValue" };
const arn = await secretsManager.updateSecret(secretName, newSecretValue);
console.log(`Secret updated with ARN: ${arn}`);

Delete a Secret

const secretName = "secret-to-delete";
await secretsManager.deleteSecret(secretName);
console.log(`Secret "${secretName}" deleted`);

API

AWSSecretsManager

Constructor

constructor(config: AWSSecretsManagerConfig = {})
  • config: Optional configuration object
    • region: AWS region (default: 'us-east-1')
    • accessKeyId: AWS access key ID
    • secretAccessKey: AWS secret access key
    • credentials: AWS credentials object (alternative to accessKeyId and secretAccessKey)

Methods

  • getSecret<T = any>(secretName: string, options?: GetSecretOptions): Promise<T>
  • batchGetSecrets(options: BatchGetSecretOptions): Promise<BatchGetSecretResult>
  • createSecret<T = any>(secretName: string, secretValue: T, options?: SecretOptions): Promise<string>
  • updateSecret<T = any>(secretName: string, secretValue: T, options?: SecretOptions): Promise<string>
  • deleteSecret(secretName: string, options?: DeleteSecretOptions): Promise<void>

Error Handling

The wrapper uses a custom SecretsManagerError class for error handling. All methods throw this error type, which includes the original AWS SDK error for reference.

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

This project is licensed under the MIT License.