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

@embley/google-secrets-manager-cloudflare

Package Overview
Dependencies
Maintainers
4
Versions
24
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@embley/google-secrets-manager-cloudflare

Google Secrets Manager - Cloudflare

  • 1.0.23
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
4
Created
Source

Node.js Google Secrets Manager - Cloudflare

Integrating Google Secret Manager with Cloudflare Workers to securely manage and dynamically retrieve sensitive information at the edge with 0 dependencies.

Prerequisites

Before you begin, make sure you have the following:

  • Node.js installed (https://nodejs.org/)
  • Google Cloud Platform (GCP) account with a project set up
  • Google Secrets Manager API active in your project.

Installation

Install as a dependency on your Cloudflare worker:

npm install google-cloud-secrets-manager

Configuration

To retrieve secrets from Google Secrets Manager, create an instance of SecretStore like:

new SecretsStore({ user, key, project_name })
  1. Where the user is the Google Cloud Platform user or service account that has at least the following permissions to handle secrets and secrets versions:
  • secretmanager.secrets.create
  • secretmanager.secrets.setIamPolicy
  • secretmanager.secrets.update
  • secretmanager.versions.add
  • secretmanager.versions.access
  1. The key is the Private Key. To obtain this key, follow the official Google documentation

IMPORTANT

The key in the format of -----BEGIN PRIVATE KEY----- .... -----END PRIVATE KEY----- taken from the JSON needs to be processed to make the '\n' real new lines because Cloudflare adds an extra '' making it a '\n' and then the decryption of the key does not work. This happens both through wrangler secret add and in the Cloudflare dashboard.

It does not happen in your local environment, though.

  1. The project_name is the Google Cloud Platform project name.

Usage

The project provides the following functionalities:

  1. Creating a new secret in Google Cloud Secrets Manager.
const secretsStore = new SecretsStore({ user, key, project_name });
await secretsStore.storeCredential('secretId', 'secret', { 'label1': 'labelValue1', 'label2': 'labelValue2' });
  1. Retrieving the value of a secret.
const secretsStore = new SecretsStore({ user, key, project_name });
await secretsStore.retrieveCredential('secretId');
  1. Update the value of a secret:
const secretsStore = new SecretsStore({ user, key, project_name });
await secretsStore.updateCredential('secretId', 'newSecret');

Disclaimer

This project is not supported by or part of Google Cloud or Cloudflare.

Keywords

FAQs

Package last updated on 01 Mar 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