@battis/lazy-secrets 1.0.1 → 1.0.2
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 +7 -0
- package/dist/LazySecrets.js +11 -5
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
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.2](https://github.com/battis/lazy-secrets/compare/ts/1.0.1...ts/1.0.2) (2026-05-12)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* wrap dynamic declaration in function call ([c309192](https://github.com/battis/lazy-secrets/commit/c309192f1e1c7544b174c1ed3f7aa835bce170b3))
|
|
11
|
+
|
|
5
12
|
## [1.0.1](https://github.com/battis/lazy-secrets/compare/ts/1.0.0...ts/1.0.1) (2026-05-12)
|
|
6
13
|
|
|
7
14
|
|
package/dist/LazySecrets.js
CHANGED
|
@@ -1,8 +1,14 @@
|
|
|
1
1
|
import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
|
|
2
|
-
|
|
2
|
+
let _client;
|
|
3
|
+
function client() {
|
|
4
|
+
if (!_client) {
|
|
5
|
+
_client = new SecretManagerServiceClient();
|
|
6
|
+
}
|
|
7
|
+
return _client;
|
|
8
|
+
}
|
|
3
9
|
export async function get(name, version = 'latest') {
|
|
4
10
|
let value = undefined;
|
|
5
|
-
const [secret] = await client.accessSecretVersion({
|
|
11
|
+
const [secret] = await client().accessSecretVersion({
|
|
6
12
|
name: `projects/${process.env.GOOGLE_CLOUD_PROJECT}/secrets/${name}/versions/${version}`
|
|
7
13
|
});
|
|
8
14
|
if (secret.payload?.data &&
|
|
@@ -19,16 +25,16 @@ export async function get(name, version = 'latest') {
|
|
|
19
25
|
}
|
|
20
26
|
export async function set(name, value) {
|
|
21
27
|
const parent = `projects/${process.env.GOOGLE_CLOUD_PROJECT}/secrets/${name}`;
|
|
22
|
-
const [latest] = await client.addSecretVersion({
|
|
28
|
+
const [latest] = await client().addSecretVersion({
|
|
23
29
|
parent,
|
|
24
30
|
payload: {
|
|
25
31
|
data: Buffer.from(JSON.stringify(value), 'utf-8')
|
|
26
32
|
}
|
|
27
33
|
});
|
|
28
|
-
const [versions] = await client.listSecretVersions({ parent });
|
|
34
|
+
const [versions] = await client().listSecretVersions({ parent });
|
|
29
35
|
for (const version of versions) {
|
|
30
36
|
if (version.name !== latest.name && version.state !== 'DESTROYED') {
|
|
31
|
-
await client.destroySecretVersion(version);
|
|
37
|
+
await client().destroySecretVersion(version);
|
|
32
38
|
}
|
|
33
39
|
}
|
|
34
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@battis/lazy-secrets",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
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": {
|