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 🙏

© 2026 – Pkg Stats / Ryan Hefner

secret-manager-lig

v1.0.9

Published

Uma biblioteca para gerenciar e deixar mais segura as variáveis de ambiente usando o Google Secret Manager, inspirada na criação de uma lib feita em java pelo desenvolvedor Tulio Vasconcelos

Downloads

22

Readme

Secret Manager Lib (English)

This library helps Node.js applications securely and automatically load environment variables from Google Secret Manager. It also supports programmatically updating secrets stored in GCP.


🚀 Installation

1. Install the library:

npm install secret-manager-lig

2. Install Google Cloud SDK:

For macOS:

brew install --cask google-cloud-sdk

For Windows:
Go to the installer

3. Authenticate and configure:

gcloud auth login
gcloud config set project abcinc-operation-ab-hdg-prd
gcloud auth application-default login

Replace abcinc-operation-ab-hdg-prd with your actual GCP project ID.


⚙️ Project Configuration

Create a .env file and add:

GCP_PROJECT_ID=your-project-id
SECRET_NAME=xx-operation-gcp-prd

🛠️ How to Use in Your App

Automatically load secrets on startup:

import { initializeSecrets } from 'secret-manager-lig';

async function main() {
  await initializeSecrets('your-project-id', 'your-secret-name', {
    printSecrets: true, // Print secrets to console
    enable: true, // Controlled via env variable
  });

  console.log('App started!');
}

main();

Update or create secrets:

import { SecretManagerService } from './SecretManagerService';

const secretManagerService = new SecretManagerService();

async function updateSecrets() {
  const projectId = process.env.GCP_PROJECT_ID || 'your-project-id';
  const secretName = process.env.SECRET_NAME || 'your-secret-name';

  const newVariables = {
    NEW_VARIABLE: 'NEW_VALUE',
    ANOTHER_VARIABLE: 'ANOTHER_VALUE',
  };

  await secretManagerService.updateSecretJson(projectId, secretName, newVariables);
  console.log('Secrets updated successfully!');
}

📌 Benefits

  • No need to manually manage .env files;
  • Secure and centralized secret management;
  • Simplifies onboarding in team environments.

Compatibility

This library is compatible with:

  • Node.js ≥ 16.0.0
  • TypeScript ≥ 4.5.0

Node.js compatibility and Google Secret Manager dependency

Important:

  • For Node.js 16.x, you must install @google-cloud/secret-manager@^5.4.0.
  • For Node.js 18.x or higher, you can install @google-cloud/secret-manager@^6.0.0 or higher.

The library automatically detects your Node.js version and will warn you at runtime if you are using an incompatible version of @google-cloud/secret-manager.

Example:

# For Node 16.x
npm install @google-cloud/secret-manager@^5.x.x

# For Node 18.x or higher
npm install @google-cloud/secret-manager@^6.0.0

Secret Manager Lib(BR)

Esta biblioteca facilita o uso do Google Secret Manager em aplicações Node.js. Com ela, você consegue carregar automaticamente variáveis de ambiente a partir de um segredo armazenado no Google Cloud, além de atualizá-lo sempre que necessário.


🚀 Instalação

1. Instale a biblioteca:

npm install secret-manager-lig

2. Instale o SDK do Google Cloud:

Para macOS:

brew install --cask google-cloud-sdk

Para Windows:
Acesse o instalador aqui

3. Autenticação e configuração

Autentique-se com o Google Cloud:

gcloud auth login
gcloud config set project abcinc-operation-ab-hdg-prd
gcloud auth application-default login

Substitua abcinc-operation-ab-hdg-prd pelo ID do seu projeto.


⚙️ Configuração do projeto

Adicione as variáveis no seu .env:

projectId=seu-project-id
appName=xx-operation-gcp-prd

🛠️ Como usar na aplicação

Inicialização automática dos secrets:

import { initializeSecrets } from 'secret-manager-lig';

async function main() {
  await initializeSecrets('seu-project-id', 'seu-secret-name', {
    printSecrets: true, // Imprime os segredos no console
    enable: true, // Controla via variável de ambiente
  });

  console.log('Aplicação iniciada!');
}

main();

Atualizar ou criar segredos:

import { SecretManagerService } from './SecretManagerService';

const secretManagerService = new SecretManagerService();

async function updateSecrets() {
  const projectId = process.env.GCP_PROJECT_ID || 'seu-project-id';
  const secretName = process.env.SECRET_NAME || 'seu-secret-name';

  const newVariables = {
    NEW_VARIABLE: 'NEW_VALUE',
    ANOTHER_VARIABLE: 'ANOTHER_VALUE',
  };

  await secretManagerService.updateSecretJson(projectId, secretName, newVariables);
  console.log('Segredo atualizado com sucesso!');
}

📌 Benefícios

  • Elimina a necessidade de manter .env manual;
  • Garante maior segurança com os dados sensíveis;
  • Ideal para projetos com múltiplos desenvolvedores.

Compatibilidade

Esta biblioteca é compatível com:

  • Node.js ≥ 16.0.0
  • TypeScript ≥ 4.5.0

Compatibilidade com Node.js e dependência do Google Secret Manager

Importante:

  • Para Node.js 16.x, você deve instalar @google-cloud/secret-manager@^5.4.0.
  • Para Node.js 18.x ou superior, você pode instalar @google-cloud/secret-manager@^6.0.0 ou superior.

A biblioteca detecta automaticamente a versão do seu Node.js e exibirá um aviso em tempo de execução se você estiver usando uma versão incompatível de @google-cloud/secret-manager.

Exemplo:

# Para Node 16.x
npm install @google-cloud/secret-manager@^5.4.0

# Para Node 18.x ou superior
npm install @google-cloud/secret-manager@^6.0.0