@itgorillaz/configify 3.1.0-alpha.0 → 3.2.0-alpha.0

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.
@@ -0,0 +1,12 @@
1
+ import { SecretManagerServiceClient } from '@google-cloud/secret-manager';
2
+ import { ConfigurationResolver } from '../configuration-resolver.interface';
3
+ export declare class GoogleCloudSecretManagerConfigurationResolver implements ConfigurationResolver {
4
+ private readonly client;
5
+ private readonly GCP_SECRET_MANAGER_YAML_KEY;
6
+ private readonly GCP_SECRET_MANAGER_ENV_PREFIX;
7
+ constructor(client: SecretManagerServiceClient);
8
+ resolve(config: Record<string, any>): Promise<Record<string, any>>;
9
+ private filterConfiguration;
10
+ private resolveSecretValue;
11
+ private buildBulkRequest;
12
+ }
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoogleCloudSecretManagerConfigurationResolver = void 0;
4
+ class GoogleCloudSecretManagerConfigurationResolver {
5
+ constructor(client) {
6
+ this.client = client;
7
+ this.GCP_SECRET_MANAGER_YAML_KEY = 'gcp-secret-manager';
8
+ this.GCP_SECRET_MANAGER_ENV_PREFIX = 'GCP_SECRET_MANAGER';
9
+ }
10
+ async resolve(config) {
11
+ const parameters = this.filterConfiguration(config);
12
+ const promises = this.buildBulkRequest(parameters);
13
+ const results = await Promise.all(promises);
14
+ const errors = results.filter((r) => !r.success);
15
+ if (errors && errors.length) {
16
+ throw new Error(`Unable to resolve parameter:\n${errors
17
+ .map((e) => { var _a; return `${e.key}: ${e.id} - ${(_a = e.error) === null || _a === void 0 ? void 0 : _a.message}`; })
18
+ .join('\n')}`);
19
+ }
20
+ for (const result of results) {
21
+ config[result.key] = result.value;
22
+ }
23
+ return config;
24
+ }
25
+ filterConfiguration(config) {
26
+ return Object.fromEntries(Object.entries(config).filter(([key]) => key.startsWith(this.GCP_SECRET_MANAGER_YAML_KEY) ||
27
+ key.startsWith(this.GCP_SECRET_MANAGER_ENV_PREFIX)));
28
+ }
29
+ async resolveSecretValue(key, id) {
30
+ var _a, _b;
31
+ try {
32
+ const payload = { name: id };
33
+ const [secret] = await this.client.accessSecretVersion(payload);
34
+ return {
35
+ id,
36
+ key,
37
+ value: (_b = (_a = secret.payload) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.toString(),
38
+ success: true,
39
+ };
40
+ }
41
+ catch (e) {
42
+ return {
43
+ id,
44
+ key,
45
+ error: e,
46
+ success: false,
47
+ };
48
+ }
49
+ }
50
+ buildBulkRequest(config) {
51
+ const promises = [];
52
+ for (const [key, value] of Object.entries(config)) {
53
+ promises.push(this.resolveSecretValue(key, value));
54
+ }
55
+ return promises;
56
+ }
57
+ }
58
+ exports.GoogleCloudSecretManagerConfigurationResolver = GoogleCloudSecretManagerConfigurationResolver;
59
+ //# sourceMappingURL=google-cloud-secret-manager.resolver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-cloud-secret-manager.resolver.js","sourceRoot":"","sources":["../../../../src/configuration/resolvers/gcp/google-cloud-secret-manager.resolver.ts"],"names":[],"mappings":";;;AAOA,MAAa,6CAA6C;IAWxD,YAA6B,MAAkC;QAAlC,WAAM,GAAN,MAAM,CAA4B;QAR9C,gCAA2B,GAAG,oBAAoB,CAAC;QACnD,kCAA6B,GAAG,oBAAoB,CAAC;IAOJ,CAAC;IAUnE,KAAK,CAAC,OAAO,CAAC,MAA2B;QACvC,MAAM,UAAU,GAAG,IAAI,CAAC,mBAAmB,CAAC,MAAM,CAAC,CAAC;QACpD,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;QAEnD,MAAM,OAAO,GAAG,MAAM,OAAO,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;QAE5C,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC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BACL,EAAE;gBACF,GAAG;gBACH,KAAK,EAAE,CAAU;gBACjB,OAAO,EAAE,KAAK;aACf,CAAC;QACJ,CAAC;IACH,CAAC;IAQO,gBAAgB,CACtB,MAA2B;QAE3B,MAAM,QAAQ,GAA6B,EAAE,CAAC;QAC9C,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAClD,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,kBAAkB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC;QACrD,CAAC;QACD,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF;AA1GD,sGA0GC"}
@@ -0,0 +1,4 @@
1
+ import { GoogleCloudSecretManagerConfigurationResolver } from './google-cloud-secret-manager.resolver';
2
+ export declare class GoogleCloudSecretsResolverFactory {
3
+ static defaultSecretManagerConfigurationResolver(): GoogleCloudSecretManagerConfigurationResolver;
4
+ }
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.GoogleCloudSecretsResolverFactory = void 0;
4
+ const secret_manager_1 = require("@google-cloud/secret-manager");
5
+ const google_cloud_secret_manager_resolver_1 = require("./google-cloud-secret-manager.resolver");
6
+ class GoogleCloudSecretsResolverFactory {
7
+ static defaultSecretManagerConfigurationResolver() {
8
+ return new google_cloud_secret_manager_resolver_1.GoogleCloudSecretManagerConfigurationResolver(new secret_manager_1.SecretManagerServiceClient());
9
+ }
10
+ }
11
+ exports.GoogleCloudSecretsResolverFactory = GoogleCloudSecretsResolverFactory;
12
+ //# sourceMappingURL=google-cloud-secrets-resolver.factory.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-cloud-secrets-resolver.factory.js","sourceRoot":"","sources":["../../../../src/configuration/resolvers/gcp/google-cloud-secrets-resolver.factory.ts"],"names":[],"mappings":";;;AAAA,iEAA0E;AAC1E,iGAAuG;AAKvG,MAAa,iCAAiC;IAK5C,MAAM,CAAC,yCAAyC;QAC9C,OAAO,IAAI,oFAA6C,CACtD,IAAI,2CAA0B,EAAE,CACjC,CAAC;IACJ,CAAC;CACF;AAVD,8EAUC"}
@@ -0,0 +1,2 @@
1
+ export * from './google-cloud-secret-manager.resolver';
2
+ export * from './google-cloud-secrets-resolver.factory';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./google-cloud-secret-manager.resolver"), exports);
18
+ __exportStar(require("./google-cloud-secrets-resolver.factory"), exports);
19
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/configuration/resolvers/gcp/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,yEAAuD;AACvD,0EAAwD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@itgorillaz/configify",
3
- "version": "3.1.0-alpha.0",
3
+ "version": "3.2.0-alpha.0",
4
4
  "description": "NestJS Config on Steroids",
5
5
  "author": "tommelo",
6
6
  "private": false,
@@ -40,6 +40,7 @@
40
40
  "@aws-sdk/client-secrets-manager": "^3.454.0",
41
41
  "@aws-sdk/client-ssm": "^3.461.0",
42
42
  "@bitwarden/sdk-napi": "^1.0.0",
43
+ "@google-cloud/secret-manager": "^5.6.0",
43
44
  "@nestjs/cli": "^11.0.2",
44
45
  "@nestjs/schematics": "^11.0.0",
45
46
  "@nestjs/testing": "^11.0.5",