@battis/lazy-secrets 1.0.1 → 1.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
4
4
 
5
+ ## [1.0.3](https://github.com/battis/lazy-secrets/compare/ts/1.0.2...ts/1.0.3) (2026-05-12)
6
+
7
+
8
+ ### Bug Fixes
9
+
10
+ * explicitly instantiate client using env var GOOGLE_CLOUD_PROJECT ([56bbbfa](https://github.com/battis/lazy-secrets/commit/56bbbfa4fdca03071eee78153ce51156af7cde88))
11
+
12
+ ## [1.0.2](https://github.com/battis/lazy-secrets/compare/ts/1.0.1...ts/1.0.2) (2026-05-12)
13
+
14
+
15
+ ### Bug Fixes
16
+
17
+ * wrap dynamic declaration in function call ([c309192](https://github.com/battis/lazy-secrets/commit/c309192f1e1c7544b174c1ed3f7aa835bce170b3))
18
+
5
19
  ## [1.0.1](https://github.com/battis/lazy-secrets/compare/ts/1.0.0...ts/1.0.1) (2026-05-12)
6
20
 
7
21
 
@@ -1,8 +1,16 @@
1
1
  import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
2
- const client = new SecretManagerServiceClient();
2
+ let _client;
3
+ function client() {
4
+ if (!_client) {
5
+ _client = new SecretManagerServiceClient({
6
+ projectId: process.env.GOOGLE_CLOUD_PROJECT
7
+ });
8
+ }
9
+ return _client;
10
+ }
3
11
  export async function get(name, version = 'latest') {
4
12
  let value = undefined;
5
- const [secret] = await client.accessSecretVersion({
13
+ const [secret] = await client().accessSecretVersion({
6
14
  name: `projects/${process.env.GOOGLE_CLOUD_PROJECT}/secrets/${name}/versions/${version}`
7
15
  });
8
16
  if (secret.payload?.data &&
@@ -19,16 +27,16 @@ export async function get(name, version = 'latest') {
19
27
  }
20
28
  export async function set(name, value) {
21
29
  const parent = `projects/${process.env.GOOGLE_CLOUD_PROJECT}/secrets/${name}`;
22
- const [latest] = await client.addSecretVersion({
30
+ const [latest] = await client().addSecretVersion({
23
31
  parent,
24
32
  payload: {
25
33
  data: Buffer.from(JSON.stringify(value), 'utf-8')
26
34
  }
27
35
  });
28
- const [versions] = await client.listSecretVersions({ parent });
36
+ const [versions] = await client().listSecretVersions({ parent });
29
37
  for (const version of versions) {
30
38
  if (version.name !== latest.name && version.state !== 'DESTROYED') {
31
- await client.destroySecretVersion(version);
39
+ await client().destroySecretVersion(version);
32
40
  }
33
41
  }
34
42
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@battis/lazy-secrets",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "A (thin) wrapper for @google-cloud/cloud-secret-manager to reduce boilerplate",
5
5
  "homepage": "https://github.com/battis/lazy-secrets/tree/typescript#readme",
6
6
  "repository": {