Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@google-cloud/secret-manager

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@google-cloud/secret-manager

Secrets client for Node.js

  • 5.6.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
509K
increased by0.25%
Maintainers
2
Weekly downloads
 
Created

What is @google-cloud/secret-manager?

@google-cloud/secret-manager is a Node.js client library for Google Cloud Secret Manager. It allows you to securely store, manage, and access secrets, such as API keys, passwords, certificates, and other sensitive data.

What are @google-cloud/secret-manager's main functionalities?

Create a Secret

This feature allows you to create a new secret in Google Cloud Secret Manager. The code sample demonstrates how to create a secret with automatic replication.

const { SecretManagerServiceClient } = require('@google-cloud/secret-manager');
const client = new SecretManagerServiceClient();

async function createSecret() {
  const [secret] = await client.createSecret({
    parent: 'projects/my-project',
    secretId: 'my-secret',
    secret: {
      replication: {
        automatic: {},
      },
    },
  });
  console.log(`Created secret: ${secret.name}`);
}
createSecret();

Add a Secret Version

This feature allows you to add a new version to an existing secret. The code sample demonstrates how to add a new version with a specific payload.

const { SecretManagerServiceClient } = require('@google-cloud/secret-manager');
const client = new SecretManagerServiceClient();

async function addSecretVersion() {
  const [version] = await client.addSecretVersion({
    parent: 'projects/my-project/secrets/my-secret',
    payload: {
      data: Buffer.from('my-secret-data', 'utf8'),
    },
  });
  console.log(`Added secret version: ${version.name}`);
}
addSecretVersion();

Access a Secret Version

This feature allows you to access the payload of a specific version of a secret. The code sample demonstrates how to access the latest version of a secret and print its payload.

const { SecretManagerServiceClient } = require('@google-cloud/secret-manager');
const client = new SecretManagerServiceClient();

async function accessSecretVersion() {
  const [accessResponse] = await client.accessSecretVersion({
    name: 'projects/my-project/secrets/my-secret/versions/latest',
  });
  const responsePayload = accessResponse.payload.data.toString('utf8');
  console.log(`Accessed secret version payload: ${responsePayload}`);
}
accessSecretVersion();

Delete a Secret

This feature allows you to delete a secret from Google Cloud Secret Manager. The code sample demonstrates how to delete a specific secret.

const { SecretManagerServiceClient } = require('@google-cloud/secret-manager');
const client = new SecretManagerServiceClient();

async function deleteSecret() {
  await client.deleteSecret({
    name: 'projects/my-project/secrets/my-secret',
  });
  console.log('Deleted secret');
}
deleteSecret();

Other packages similar to @google-cloud/secret-manager

Keywords

FAQs

Package last updated on 21 May 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc