1.0.23 • Published 3 months ago

@embley/google-secrets-manager-cloudflare v1.0.23

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
3 months ago

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.

1.0.23

3 months ago

1.0.22

4 months ago

1.0.21

5 months ago

1.0.20

5 months ago

1.0.19

5 months ago

1.0.18

5 months ago

1.0.17

5 months ago

1.0.16

6 months ago

1.0.15

6 months ago

1.0.14

6 months ago

1.0.13

6 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

8 months ago

1.0.6

8 months ago

1.0.5

8 months ago

1.0.4

8 months ago

1.0.3

8 months ago

1.0.2

8 months ago

1.0.1

9 months ago

0.0.2

9 months ago

0.0.1

9 months ago

1.0.0

9 months ago