@nest-omni/core 3.1.1-9 → 3.1.1
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/.hygen/new/crud/controller.ejs.t +82 -0
- package/.hygen/new/crud/create.dto.ejs.t +12 -0
- package/.hygen/new/crud/entity.ejs.t +26 -0
- package/.hygen/new/crud/get.dto.ejs.t +19 -0
- package/.hygen/new/crud/index-dto.ejs.t +29 -0
- package/.hygen/new/crud/index-response.dto.ejs.t +18 -0
- package/.hygen/new/crud/module.ejs.t +32 -0
- package/.hygen/new/crud/prompt.js +89 -0
- package/.hygen/new/crud/service.ejs.t +76 -0
- package/.hygen/new/crud/update.dto.ejs.t +11 -0
- package/.hygen/new/module/controller.ejs.t +93 -0
- package/.hygen/new/module/create-command.ejs.t +90 -0
- package/.hygen/new/module/create.dto.ejs.t +11 -0
- package/.hygen/new/module/dto.ejs.t +24 -0
- package/.hygen/new/module/entity.ejs.t +33 -0
- package/.hygen/new/module/get-query.ejs.t +57 -0
- package/.hygen/new/module/module.ejs.t +44 -0
- package/.hygen/new/module/not-found.exception.ejs.t +18 -0
- package/.hygen/new/module/page-options.dto.ejs.t +12 -0
- package/.hygen/new/module/prompt.js +104 -0
- package/.hygen/new/module/repository.ejs.t +16 -0
- package/.hygen/new/module/service.ejs.t +139 -0
- package/.hygen/new/module/translation-dto.ejs.t +27 -0
- package/.hygen/new/module/translation-entity.ejs.t +40 -0
- package/.hygen/new/module/translation-repository.ejs.t +16 -0
- package/.hygen/new/module/update.dto.ejs.t +10 -0
- package/.hygen.js +116 -0
- package/cache/cache-metrics.service.d.ts +83 -0
- package/cache/cache-metrics.service.js +298 -0
- package/cache/cache-serialization.service.d.ts +22 -0
- package/cache/cache-serialization.service.js +122 -0
- package/cache/cache.constants.d.ts +2 -0
- package/cache/cache.constants.js +5 -0
- package/cache/cache.health.d.ts +35 -0
- package/cache/cache.health.js +193 -0
- package/cache/cache.module.d.ts +26 -0
- package/cache/cache.module.js +155 -0
- package/cache/cache.service.d.ts +37 -0
- package/cache/cache.service.js +308 -0
- package/cache/cache.warmup.service.d.ts +34 -0
- package/cache/cache.warmup.service.js +199 -0
- package/cache/decorators/cache-evict.decorator.d.ts +2 -0
- package/cache/decorators/cache-evict.decorator.js +72 -0
- package/cache/decorators/cache-put.decorator.d.ts +2 -0
- package/cache/decorators/cache-put.decorator.js +48 -0
- package/cache/decorators/cacheable.decorator.d.ts +4 -0
- package/cache/decorators/cacheable.decorator.js +68 -0
- package/cache/decorators/index.d.ts +3 -0
- package/cache/decorators/index.js +11 -0
- package/cache/dependencies/callback.dependency.d.ts +11 -0
- package/cache/dependencies/callback.dependency.js +92 -0
- package/cache/dependencies/chain.dependency.d.ts +20 -0
- package/cache/dependencies/chain.dependency.js +113 -0
- package/cache/dependencies/db.dependency.d.ts +15 -0
- package/cache/dependencies/db.dependency.js +71 -0
- package/cache/dependencies/file.dependency.d.ts +17 -0
- package/cache/dependencies/file.dependency.js +63 -0
- package/cache/dependencies/index.d.ts +6 -0
- package/cache/dependencies/index.js +22 -0
- package/cache/dependencies/tag.dependency.d.ts +16 -0
- package/cache/dependencies/tag.dependency.js +75 -0
- package/cache/dependencies/time.dependency.d.ts +19 -0
- package/cache/dependencies/time.dependency.js +71 -0
- package/cache/examples/basic-usage.d.ts +58 -0
- package/cache/examples/basic-usage.js +379 -0
- package/cache/index.d.ts +15 -0
- package/cache/index.js +44 -0
- package/cache/interfaces/cache-dependency.interface.d.ts +11 -0
- package/cache/interfaces/cache-dependency.interface.js +2 -0
- package/cache/interfaces/cache-options.interface.d.ts +32 -0
- package/cache/interfaces/cache-options.interface.js +9 -0
- package/cache/interfaces/cache-provider.interface.d.ts +28 -0
- package/cache/interfaces/cache-provider.interface.js +2 -0
- package/cache/interfaces/index.d.ts +3 -0
- package/cache/interfaces/index.js +19 -0
- package/cache/providers/base-cache.provider.d.ts +16 -0
- package/cache/providers/base-cache.provider.js +32 -0
- package/cache/providers/cls-cache.provider.d.ts +16 -0
- package/cache/providers/cls-cache.provider.js +140 -0
- package/cache/providers/index.d.ts +4 -0
- package/cache/providers/index.js +23 -0
- package/cache/providers/memory-cache.provider.d.ts +26 -0
- package/cache/providers/memory-cache.provider.js +171 -0
- package/cache/providers/redis-cache.provider.d.ts +23 -0
- package/cache/providers/redis-cache.provider.js +215 -0
- package/cache/utils/dependency-manager.util.d.ts +15 -0
- package/cache/utils/dependency-manager.util.js +141 -0
- package/cache/utils/index.d.ts +2 -0
- package/cache/utils/index.js +18 -0
- package/cache/utils/key-generator.util.d.ts +13 -0
- package/cache/utils/key-generator.util.js +74 -0
- package/common/abstract.entity.d.ts +20 -0
- package/common/abstract.entity.js +81 -0
- package/common/boilerplate.polyfill.d.ts +50 -0
- package/common/boilerplate.polyfill.js +152 -0
- package/common/dto/abstract.dto.d.ts +13 -0
- package/common/dto/abstract.dto.js +59 -0
- package/common/dto/bulk-id.dto.d.ts +3 -0
- package/common/dto/bulk-id.dto.js +27 -0
- package/common/dto/create-translation.dto.d.ts +5 -0
- package/common/dto/create-translation.dto.js +25 -0
- package/common/dto/dto-container.d.ts +9 -0
- package/common/dto/dto-container.js +59 -0
- package/common/dto/dto-decorators.d.ts +18 -0
- package/common/dto/dto-decorators.js +59 -0
- package/common/dto/dto-extensions.d.ts +12 -0
- package/common/dto/dto-extensions.js +63 -0
- package/common/dto/dto-service-accessor.d.ts +7 -0
- package/common/dto/dto-service-accessor.js +49 -0
- package/common/dto/dto-transformer.d.ts +11 -0
- package/common/dto/dto-transformer.js +49 -0
- package/common/dto/index.d.ts +12 -0
- package/common/dto/index.js +28 -0
- package/common/dto/page-meta.dto.d.ts +15 -0
- package/common/dto/page-meta.dto.js +48 -0
- package/common/dto/page-options.dto.d.ts +5 -0
- package/common/dto/page-options.dto.js +40 -0
- package/common/dto/page.dto.d.ts +11 -0
- package/common/dto/page.dto.js +53 -0
- package/common/examples/paginate-and-map.example.d.ts +14 -0
- package/common/examples/paginate-and-map.example.js +158 -0
- package/common/index.d.ts +6 -0
- package/common/index.js +22 -0
- package/common/snake-naming.strategy.d.ts +11 -0
- package/common/snake-naming.strategy.js +37 -0
- package/common/types.d.ts +9 -0
- package/common/types.js +2 -0
- package/common/utils.d.ts +3 -0
- package/common/utils.js +24 -0
- package/constants/index.d.ts +2 -0
- package/constants/index.js +18 -0
- package/constants/language-code.d.ts +5 -0
- package/constants/language-code.js +9 -0
- package/constants/order.d.ts +4 -0
- package/constants/order.js +8 -0
- package/decorators/api-page-ok-response.decorator.d.ts +5 -0
- package/decorators/api-page-ok-response.decorator.js +24 -0
- package/decorators/auth-user.decorator.d.ts +1 -0
- package/decorators/auth-user.decorator.js +14 -0
- package/decorators/controller.decorator.d.ts +1 -0
- package/decorators/controller.decorator.js +10 -0
- package/decorators/examples/validation-decorators.example.d.ts +69 -0
- package/decorators/examples/validation-decorators.example.js +331 -0
- package/decorators/field.decorators.d.ts +79 -0
- package/decorators/field.decorators.js +499 -0
- package/decorators/http.decorators.d.ts +3 -0
- package/decorators/http.decorators.js +7 -0
- package/decorators/index.d.ts +12 -0
- package/decorators/index.js +28 -0
- package/decorators/operation.decorator.d.ts +1 -0
- package/decorators/operation.decorator.js +6 -0
- package/decorators/property.decorators.d.ts +15 -0
- package/decorators/property.decorators.js +31 -0
- package/decorators/public-route.decorator.d.ts +3 -0
- package/decorators/public-route.decorator.js +7 -0
- package/decorators/swagger.schema.d.ts +5 -0
- package/decorators/swagger.schema.js +78 -0
- package/decorators/timestamp-column.decorator.d.ts +1 -0
- package/decorators/timestamp-column.decorator.js +27 -0
- package/decorators/transform.decorators.d.ts +8 -0
- package/decorators/transform.decorators.js +100 -0
- package/decorators/translate.decorator.d.ts +5 -0
- package/decorators/translate.decorator.js +17 -0
- package/decorators/use-dto.decorator.d.ts +4 -0
- package/decorators/use-dto.decorator.js +8 -0
- package/decorators/user-check.decorator.d.ts +6 -0
- package/decorators/user-check.decorator.js +21 -0
- package/decorators/user.decorator.d.ts +12 -0
- package/decorators/user.decorator.js +44 -0
- package/decorators/user_auth.decorator.d.ts +1 -0
- package/decorators/user_auth.decorator.js +15 -0
- package/decorators/validator.decorators.d.ts +18 -0
- package/decorators/validator.decorators.js +193 -0
- package/exceptions/file-not-image.exception.d.ts +4 -0
- package/exceptions/file-not-image.exception.js +10 -0
- package/exceptions/index.d.ts +2 -0
- package/exceptions/index.js +18 -0
- package/exceptions/page-type.exception.d.ts +4 -0
- package/exceptions/page-type.exception.js +10 -0
- package/exceptions/user-not-found.exception.d.ts +4 -0
- package/exceptions/user-not-found.exception.js +10 -0
- package/filters/bad-request.filter.d.ts +5 -0
- package/filters/bad-request.filter.js +71 -0
- package/filters/constraint-errors.d.ts +1 -0
- package/filters/constraint-errors.js +6 -0
- package/filters/index.d.ts +3 -0
- package/filters/index.js +19 -0
- package/filters/query-failed.filter.d.ts +10 -0
- package/filters/query-failed.filter.js +42 -0
- package/health-checker/health-checker.controller.d.ts +13 -0
- package/health-checker/health-checker.controller.js +69 -0
- package/health-checker/health-checker.module.d.ts +2 -0
- package/health-checker/health-checker.module.js +24 -0
- package/health-checker/index.d.ts +2 -0
- package/health-checker/index.js +18 -0
- package/helpers/common.helper.d.ts +3 -0
- package/helpers/common.helper.js +36 -0
- package/helpers/date.helper.d.ts +10 -0
- package/helpers/date.helper.js +57 -0
- package/helpers/index.d.ts +2 -0
- package/helpers/index.js +18 -0
- package/i18n/en_US/validation.json +44 -0
- package/i18n/zh_CN/validation.json +44 -0
- package/index.d.ts +18 -0
- package/index.js +3 -0
- package/interceptors/index.d.ts +2 -0
- package/interceptors/index.js +18 -0
- package/interceptors/language-interceptor.service.d.ts +6 -0
- package/interceptors/language-interceptor.service.js +29 -0
- package/interceptors/translation-interceptor.service.d.ts +5 -0
- package/interceptors/translation-interceptor.service.js +34 -0
- package/interfaces/IApiFile.d.ts +4 -0
- package/interfaces/IApiFile.js +2 -0
- package/interfaces/IFile.d.ts +8 -0
- package/interfaces/IFile.js +2 -0
- package/interfaces/ITranslationDecoratorInterface.d.ts +3 -0
- package/interfaces/ITranslationDecoratorInterface.js +2 -0
- package/interfaces/index.d.ts +3 -0
- package/interfaces/index.js +19 -0
- package/interfaces/response.d.ts +25 -0
- package/interfaces/response.js +2 -0
- package/middlewares/index.d.ts +4 -0
- package/middlewares/index.js +20 -0
- package/middlewares/omni-auth.middleware.d.ts +1 -0
- package/middlewares/omni-auth.middleware.js +13 -0
- package/middlewares/powerby.middleware.d.ts +1 -0
- package/middlewares/powerby.middleware.js +10 -0
- package/middlewares/request-id.middleware.d.ts +7 -0
- package/middlewares/request-id.middleware.js +22 -0
- package/middlewares/xml.middleware.d.ts +4 -0
- package/middlewares/xml.middleware.js +24 -0
- package/package.json +41 -116
- package/providers/context.provider.d.ts +34 -0
- package/providers/context.provider.js +80 -0
- package/providers/generator.provider.d.ts +9 -0
- package/providers/generator.provider.js +50 -0
- package/providers/index.d.ts +2 -0
- package/providers/index.js +18 -0
- package/redis-lock/examples/lock-strategy.examples.d.ts +73 -0
- package/redis-lock/examples/lock-strategy.examples.js +387 -0
- package/redis-lock/index.d.ts +4 -0
- package/redis-lock/index.js +16 -0
- package/redis-lock/redis-lock.decorator.d.ts +12 -0
- package/redis-lock/redis-lock.decorator.js +125 -0
- package/redis-lock/redis-lock.module.d.ts +23 -0
- package/redis-lock/redis-lock.module.js +117 -0
- package/redis-lock/redis-lock.service.d.ts +66 -0
- package/redis-lock/redis-lock.service.js +413 -0
- package/setup/bootstrap.setup.d.ts +2 -0
- package/setup/bootstrap.setup.js +184 -0
- package/setup/index.d.ts +4 -0
- package/setup/index.js +20 -0
- package/setup/mode.setup.d.ts +12 -0
- package/setup/mode.setup.js +60 -0
- package/setup/schedule.decorator.d.ts +23 -0
- package/setup/schedule.decorator.js +233 -0
- package/setup/worker.decorator.d.ts +14 -0
- package/setup/worker.decorator.js +130 -0
- package/shared/index.d.ts +2 -0
- package/shared/index.js +18 -0
- package/shared/serviceRegistryModule.d.ts +2 -0
- package/shared/serviceRegistryModule.js +170 -0
- package/shared/services/api-config.service.d.ts +54 -0
- package/shared/services/api-config.service.js +287 -0
- package/shared/services/generator.service.d.ts +4 -0
- package/shared/services/generator.service.js +23 -0
- package/shared/services/index.d.ts +4 -0
- package/shared/services/index.js +20 -0
- package/shared/services/translation.service.d.ts +9 -0
- package/shared/services/translation.service.js +70 -0
- package/shared/services/validator.service.d.ts +3 -0
- package/shared/services/validator.service.js +20 -0
- package/validator-json/decorators.d.ts +6 -0
- package/validator-json/decorators.js +22 -0
- package/validator-json/default.d.ts +6 -0
- package/validator-json/default.js +138 -0
- package/validator-json/defaultConverters.d.ts +8 -0
- package/validator-json/defaultConverters.js +376 -0
- package/validator-json/index.d.ts +4 -0
- package/validator-json/index.js +20 -0
- package/validator-json/options.d.ts +11 -0
- package/validator-json/options.js +10 -0
- package/validators/file-mimetype.validator.d.ts +13 -0
- package/validators/file-mimetype.validator.js +21 -0
- package/validators/index.d.ts +6 -0
- package/validators/index.js +22 -0
- package/validators/is-exists.validator.d.ts +18 -0
- package/validators/is-exists.validator.js +60 -0
- package/validators/is-unique.validator.d.ts +17 -0
- package/validators/is-unique.validator.js +91 -0
- package/validators/phone-country-code.validator.d.ts +2 -0
- package/validators/phone-country-code.validator.js +29 -0
- package/validators/same-as.validator.d.ts +2 -0
- package/validators/same-as.validator.js +24 -0
- package/validators/skip-empty.validator.d.ts +1 -0
- package/validators/skip-empty.validator.js +17 -0
- package/vault/index.d.ts +4 -0
- package/vault/index.js +20 -0
- package/vault/interfaces/vault-options.interface.d.ts +22 -0
- package/vault/interfaces/vault-options.interface.js +2 -0
- package/vault/vault-config.loader.d.ts +13 -0
- package/vault/vault-config.loader.js +246 -0
- package/vault/vault-config.service.d.ts +18 -0
- package/vault/vault-config.service.js +174 -0
- package/vault/vault.module.d.ts +2 -0
- package/vault/vault.module.js +21 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IsPhoneNumberWithCountryCode = IsPhoneNumberWithCountryCode;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
function IsPhoneNumberWithCountryCode(validationOptions) {
|
|
6
|
+
return function (object, propertyName) {
|
|
7
|
+
(0, class_validator_1.ValidateIf)((_, value) => !!value)(object, propertyName);
|
|
8
|
+
const countryCodePropertyName = 'countryCode';
|
|
9
|
+
(0, class_validator_1.registerDecorator)({
|
|
10
|
+
name: 'isPhoneNumberWithCountryCode',
|
|
11
|
+
target: object.constructor,
|
|
12
|
+
propertyName: propertyName,
|
|
13
|
+
constraints: [countryCodePropertyName],
|
|
14
|
+
options: validationOptions,
|
|
15
|
+
validator: {
|
|
16
|
+
validate(value, args) {
|
|
17
|
+
const [countryCodePropertyName] = args.constraints;
|
|
18
|
+
const countryCode = args.object[countryCodePropertyName];
|
|
19
|
+
return (0, class_validator_1.isPhoneNumber)(value, countryCode);
|
|
20
|
+
},
|
|
21
|
+
defaultMessage(args) {
|
|
22
|
+
const [countryCodePropertyName] = args.constraints;
|
|
23
|
+
const countryCode = args.object[countryCodePropertyName];
|
|
24
|
+
return `$property must be a valid phone number in the country code ${countryCode}`;
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SameAs = SameAs;
|
|
4
|
+
const class_validator_1 = require("class-validator");
|
|
5
|
+
function SameAs(property, validationOptions) {
|
|
6
|
+
return function (object, propertyName) {
|
|
7
|
+
(0, class_validator_1.registerDecorator)({
|
|
8
|
+
name: 'sameAs',
|
|
9
|
+
target: object.constructor,
|
|
10
|
+
propertyName,
|
|
11
|
+
options: validationOptions,
|
|
12
|
+
constraints: [property],
|
|
13
|
+
validator: {
|
|
14
|
+
validate(value, args) {
|
|
15
|
+
const [relatedPropertyName] = args.constraints;
|
|
16
|
+
return (args === null || args === void 0 ? void 0 : args.object[relatedPropertyName]) === value;
|
|
17
|
+
},
|
|
18
|
+
defaultMessage() {
|
|
19
|
+
return '$property must match $constraint1';
|
|
20
|
+
},
|
|
21
|
+
},
|
|
22
|
+
});
|
|
23
|
+
};
|
|
24
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function SkipEmpty(field?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SkipEmpty = SkipEmpty;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
6
|
+
const class_validator_1 = require("class-validator");
|
|
7
|
+
const lodash_1 = require("lodash");
|
|
8
|
+
function SkipEmpty(field) {
|
|
9
|
+
return (0, common_1.applyDecorators)((0, swagger_1.ApiProperty)({ required: false }), (0, class_validator_1.ValidateIf)((obj, value) => {
|
|
10
|
+
if (field) {
|
|
11
|
+
value = obj[field];
|
|
12
|
+
}
|
|
13
|
+
return !(value === null ||
|
|
14
|
+
value === undefined ||
|
|
15
|
+
((0, lodash_1.isString)(value) && value.trim() === ''));
|
|
16
|
+
}));
|
|
17
|
+
}
|
package/vault/index.d.ts
ADDED
package/vault/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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("./vault-config.loader"), exports);
|
|
18
|
+
__exportStar(require("./vault-config.service"), exports);
|
|
19
|
+
__exportStar(require("./vault.module"), exports);
|
|
20
|
+
__exportStar(require("./interfaces/vault-options.interface"), exports);
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export interface VaultAuthOptions {
|
|
2
|
+
token?: string;
|
|
3
|
+
roleId?: string;
|
|
4
|
+
secretId?: string;
|
|
5
|
+
k8sRole?: string;
|
|
6
|
+
k8sServiceAccountToken?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface VaultOptions {
|
|
9
|
+
endpoint: string;
|
|
10
|
+
auth: VaultAuthOptions;
|
|
11
|
+
secretPaths: string[];
|
|
12
|
+
namespace?: string;
|
|
13
|
+
apiVersion?: 'v1' | 'v2';
|
|
14
|
+
timeout?: number;
|
|
15
|
+
enableHotReload?: boolean;
|
|
16
|
+
hotReloadInterval?: number;
|
|
17
|
+
failOnError?: boolean;
|
|
18
|
+
}
|
|
19
|
+
export interface VaultConfig {
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
options?: VaultOptions;
|
|
22
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export declare class VaultConfigLoader {
|
|
2
|
+
private static readonly logger;
|
|
3
|
+
private static vaultClient;
|
|
4
|
+
private static hotReloadTimer;
|
|
5
|
+
private static buildVaultOptions;
|
|
6
|
+
private static initializeVaultClient;
|
|
7
|
+
private static readSecrets;
|
|
8
|
+
static loadVaultConfig(): Promise<void>;
|
|
9
|
+
private static startHotReload;
|
|
10
|
+
static stopHotReload(): void;
|
|
11
|
+
static getVaultClient(): any;
|
|
12
|
+
static isConnected(): boolean;
|
|
13
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.VaultConfigLoader = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
class VaultConfigLoader {
|
|
15
|
+
static buildVaultOptions() {
|
|
16
|
+
var _a;
|
|
17
|
+
const enabled = process.env.VAULT_ENABLED === 'true';
|
|
18
|
+
if (!enabled) {
|
|
19
|
+
this.logger.log('Vault is disabled (VAULT_ENABLED != true)');
|
|
20
|
+
return null;
|
|
21
|
+
}
|
|
22
|
+
const endpoint = process.env.VAULT_ENDPOINT;
|
|
23
|
+
const secretPaths = ((_a = process.env.VAULT_SECRET_PATHS) === null || _a === void 0 ? void 0 : _a.split(',').map(p => p.trim())) || [];
|
|
24
|
+
if (!endpoint) {
|
|
25
|
+
this.logger.warn('Vault enabled but VAULT_ENDPOINT is not set');
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
if (secretPaths.length === 0) {
|
|
29
|
+
this.logger.warn('Vault enabled but VAULT_SECRET_PATHS is empty');
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
const auth = {};
|
|
33
|
+
if (process.env.VAULT_TOKEN) {
|
|
34
|
+
auth.token = process.env.VAULT_TOKEN;
|
|
35
|
+
this.logger.log('Using Vault Token authentication');
|
|
36
|
+
}
|
|
37
|
+
else if (process.env.VAULT_ROLE_ID && process.env.VAULT_SECRET_ID) {
|
|
38
|
+
auth.roleId = process.env.VAULT_ROLE_ID;
|
|
39
|
+
auth.secretId = process.env.VAULT_SECRET_ID;
|
|
40
|
+
this.logger.log('Using Vault AppRole authentication');
|
|
41
|
+
}
|
|
42
|
+
else if (process.env.VAULT_K8S_ROLE) {
|
|
43
|
+
auth.k8sRole = process.env.VAULT_K8S_ROLE;
|
|
44
|
+
auth.k8sServiceAccountToken = process.env.VAULT_K8S_SA_TOKEN;
|
|
45
|
+
this.logger.log('Using Vault Kubernetes authentication');
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
this.logger.warn('Vault enabled but no valid authentication method configured');
|
|
49
|
+
return null;
|
|
50
|
+
}
|
|
51
|
+
const options = {
|
|
52
|
+
endpoint,
|
|
53
|
+
auth,
|
|
54
|
+
secretPaths,
|
|
55
|
+
namespace: process.env.VAULT_NAMESPACE,
|
|
56
|
+
apiVersion: process.env.VAULT_API_VERSION || 'v2',
|
|
57
|
+
timeout: parseInt(process.env.VAULT_TIMEOUT || '5000', 10),
|
|
58
|
+
enableHotReload: process.env.VAULT_HOT_RELOAD === 'true',
|
|
59
|
+
hotReloadInterval: parseInt(process.env.VAULT_HOT_RELOAD_INTERVAL || '300', 10),
|
|
60
|
+
failOnError: process.env.VAULT_FAIL_ON_ERROR !== 'false',
|
|
61
|
+
};
|
|
62
|
+
this.logger.log(`Vault configuration loaded: ${secretPaths.length} secret path(s)`);
|
|
63
|
+
return options;
|
|
64
|
+
}
|
|
65
|
+
static initializeVaultClient(options) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
let vault;
|
|
68
|
+
try {
|
|
69
|
+
vault = yield Promise.resolve().then(() => require('node-vault'));
|
|
70
|
+
vault = vault.default || vault;
|
|
71
|
+
}
|
|
72
|
+
catch (error) {
|
|
73
|
+
throw new Error('node-vault package not installed. Run: npm install node-vault');
|
|
74
|
+
}
|
|
75
|
+
const client = vault({
|
|
76
|
+
endpoint: options.endpoint,
|
|
77
|
+
namespace: options.namespace,
|
|
78
|
+
requestOptions: {
|
|
79
|
+
timeout: options.timeout,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
try {
|
|
83
|
+
if (options.auth.token) {
|
|
84
|
+
client.token = options.auth.token;
|
|
85
|
+
this.logger.log('Vault Token authentication configured');
|
|
86
|
+
}
|
|
87
|
+
else if (options.auth.roleId && options.auth.secretId) {
|
|
88
|
+
const result = yield client.approleLogin({
|
|
89
|
+
role_id: options.auth.roleId,
|
|
90
|
+
secret_id: options.auth.secretId,
|
|
91
|
+
});
|
|
92
|
+
client.token = result.auth.client_token;
|
|
93
|
+
this.logger.log('Vault AppRole authentication successful');
|
|
94
|
+
}
|
|
95
|
+
else if (options.auth.k8sRole) {
|
|
96
|
+
let jwt = options.auth.k8sServiceAccountToken;
|
|
97
|
+
if (!jwt) {
|
|
98
|
+
const fs = yield Promise.resolve().then(() => require('fs'));
|
|
99
|
+
const K8S_SA_TOKEN_PATH = '/var/run/secrets/kubernetes.io/serviceaccount/token';
|
|
100
|
+
if (fs.existsSync(K8S_SA_TOKEN_PATH)) {
|
|
101
|
+
jwt = fs.readFileSync(K8S_SA_TOKEN_PATH, 'utf8');
|
|
102
|
+
}
|
|
103
|
+
else {
|
|
104
|
+
throw new Error('Kubernetes service account token not found');
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
const result = yield client.kubernetesLogin({
|
|
108
|
+
role: options.auth.k8sRole,
|
|
109
|
+
jwt,
|
|
110
|
+
});
|
|
111
|
+
client.token = result.auth.client_token;
|
|
112
|
+
this.logger.log('Vault Kubernetes authentication successful');
|
|
113
|
+
}
|
|
114
|
+
else {
|
|
115
|
+
throw new Error('No valid Vault authentication method configured');
|
|
116
|
+
}
|
|
117
|
+
yield client.tokenLookupSelf();
|
|
118
|
+
this.logger.log('Vault authentication verified');
|
|
119
|
+
return client;
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
this.logger.error('Vault authentication failed', error);
|
|
123
|
+
throw error;
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
static readSecrets(client, secretPath, apiVersion) {
|
|
128
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
129
|
+
try {
|
|
130
|
+
this.logger.debug(`Reading secrets from: ${secretPath}`);
|
|
131
|
+
const result = yield client.read(secretPath);
|
|
132
|
+
if (!result || !result.data) {
|
|
133
|
+
this.logger.warn(`No data found at path: ${secretPath}`);
|
|
134
|
+
return {};
|
|
135
|
+
}
|
|
136
|
+
const secrets = apiVersion === 'v2' ? result.data.data : result.data;
|
|
137
|
+
if (!secrets || typeof secrets !== 'object') {
|
|
138
|
+
this.logger.warn(`Invalid secret format at path: ${secretPath}`);
|
|
139
|
+
return {};
|
|
140
|
+
}
|
|
141
|
+
const secretCount = Object.keys(secrets).length;
|
|
142
|
+
this.logger.log(`Loaded ${secretCount} secret(s) from ${secretPath}`);
|
|
143
|
+
return secrets;
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
this.logger.error(`Failed to read secrets from path: ${secretPath}`, error.message);
|
|
147
|
+
return {};
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
static loadVaultConfig() {
|
|
152
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
153
|
+
const options = this.buildVaultOptions();
|
|
154
|
+
if (!options) {
|
|
155
|
+
this.logger.log('Skipping Vault configuration loading');
|
|
156
|
+
return;
|
|
157
|
+
}
|
|
158
|
+
try {
|
|
159
|
+
this.logger.log(`Connecting to Vault at ${options.endpoint}`);
|
|
160
|
+
this.vaultClient = yield this.initializeVaultClient(options);
|
|
161
|
+
const allSecrets = {};
|
|
162
|
+
for (const secretPath of options.secretPaths) {
|
|
163
|
+
const secrets = yield this.readSecrets(this.vaultClient, secretPath, options.apiVersion);
|
|
164
|
+
Object.assign(allSecrets, secrets);
|
|
165
|
+
}
|
|
166
|
+
let injectedCount = 0;
|
|
167
|
+
let overriddenCount = 0;
|
|
168
|
+
for (const [key, value] of Object.entries(allSecrets)) {
|
|
169
|
+
const hadPreviousValue = key in process.env;
|
|
170
|
+
process.env[key] = String(value);
|
|
171
|
+
if (hadPreviousValue) {
|
|
172
|
+
overriddenCount++;
|
|
173
|
+
this.logger.debug(`Override ${key} with Vault value`);
|
|
174
|
+
}
|
|
175
|
+
else {
|
|
176
|
+
injectedCount++;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
this.logger.log(`Vault configuration loaded: ${injectedCount} new, ${overriddenCount} overridden`);
|
|
180
|
+
if (options.enableHotReload) {
|
|
181
|
+
this.startHotReload(options);
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
this.logger.error('Failed to load Vault configuration', error.message);
|
|
186
|
+
if (options.failOnError) {
|
|
187
|
+
this.logger.error('Application startup failed due to Vault error');
|
|
188
|
+
throw error;
|
|
189
|
+
}
|
|
190
|
+
else {
|
|
191
|
+
this.logger.warn('Continuing without Vault configuration (VAULT_FAIL_ON_ERROR=false)');
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
static startHotReload(options) {
|
|
197
|
+
this.logger.log(`Starting Vault hot reload with interval: ${options.hotReloadInterval}s`);
|
|
198
|
+
if (this.hotReloadTimer) {
|
|
199
|
+
clearInterval(this.hotReloadTimer);
|
|
200
|
+
}
|
|
201
|
+
this.hotReloadTimer = setInterval(() => __awaiter(this, void 0, void 0, function* () {
|
|
202
|
+
try {
|
|
203
|
+
this.logger.debug('Reloading Vault configuration...');
|
|
204
|
+
const allSecrets = {};
|
|
205
|
+
for (const secretPath of options.secretPaths) {
|
|
206
|
+
const secrets = yield this.readSecrets(this.vaultClient, secretPath, options.apiVersion);
|
|
207
|
+
Object.assign(allSecrets, secrets);
|
|
208
|
+
}
|
|
209
|
+
let changedCount = 0;
|
|
210
|
+
for (const [key, value] of Object.entries(allSecrets)) {
|
|
211
|
+
const newValue = String(value);
|
|
212
|
+
if (process.env[key] !== newValue) {
|
|
213
|
+
this.logger.log(`Configuration changed: ${key}`);
|
|
214
|
+
process.env[key] = newValue;
|
|
215
|
+
changedCount++;
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
if (changedCount > 0) {
|
|
219
|
+
this.logger.log(`Hot reload completed: ${changedCount} configuration(s) updated`);
|
|
220
|
+
}
|
|
221
|
+
else {
|
|
222
|
+
this.logger.debug('Hot reload completed: no changes detected');
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
catch (error) {
|
|
226
|
+
this.logger.error('Failed to reload Vault configuration', error.message);
|
|
227
|
+
}
|
|
228
|
+
}), options.hotReloadInterval * 1000);
|
|
229
|
+
}
|
|
230
|
+
static stopHotReload() {
|
|
231
|
+
if (this.hotReloadTimer) {
|
|
232
|
+
clearInterval(this.hotReloadTimer);
|
|
233
|
+
this.hotReloadTimer = null;
|
|
234
|
+
this.logger.log('Vault hot reload stopped');
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
static getVaultClient() {
|
|
238
|
+
return this.vaultClient;
|
|
239
|
+
}
|
|
240
|
+
static isConnected() {
|
|
241
|
+
return this.vaultClient !== null && this.vaultClient !== undefined;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
exports.VaultConfigLoader = VaultConfigLoader;
|
|
245
|
+
VaultConfigLoader.logger = new common_1.Logger(VaultConfigLoader.name);
|
|
246
|
+
VaultConfigLoader.hotReloadTimer = null;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export declare class VaultConfigService {
|
|
2
|
+
private readonly logger;
|
|
3
|
+
private vaultClient;
|
|
4
|
+
constructor();
|
|
5
|
+
isAvailable(): boolean;
|
|
6
|
+
getSecret(path: string, key?: string): Promise<any>;
|
|
7
|
+
setSecret(path: string, data: Record<string, any>): Promise<void>;
|
|
8
|
+
deleteSecret(path: string): Promise<void>;
|
|
9
|
+
listSecrets(path: string): Promise<string[]>;
|
|
10
|
+
healthCheck(): Promise<boolean>;
|
|
11
|
+
getStatus(): Promise<{
|
|
12
|
+
initialized: boolean;
|
|
13
|
+
sealed: boolean;
|
|
14
|
+
standby: boolean;
|
|
15
|
+
version: string;
|
|
16
|
+
} | null>;
|
|
17
|
+
renewToken(increment?: number): Promise<void>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
12
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
13
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
14
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
15
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
16
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
17
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
18
|
+
});
|
|
19
|
+
};
|
|
20
|
+
var VaultConfigService_1;
|
|
21
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
22
|
+
exports.VaultConfigService = void 0;
|
|
23
|
+
const common_1 = require("@nestjs/common");
|
|
24
|
+
const vault_config_loader_1 = require("./vault-config.loader");
|
|
25
|
+
let VaultConfigService = VaultConfigService_1 = class VaultConfigService {
|
|
26
|
+
constructor() {
|
|
27
|
+
this.logger = new common_1.Logger(VaultConfigService_1.name);
|
|
28
|
+
this.vaultClient = vault_config_loader_1.VaultConfigLoader.getVaultClient();
|
|
29
|
+
if (!this.vaultClient) {
|
|
30
|
+
this.logger.warn('Vault client not initialized. VaultConfigService methods will throw errors.');
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
isAvailable() {
|
|
34
|
+
return vault_config_loader_1.VaultConfigLoader.isConnected();
|
|
35
|
+
}
|
|
36
|
+
getSecret(path, key) {
|
|
37
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
+
if (!this.vaultClient) {
|
|
39
|
+
throw new Error('Vault client not initialized. Check VAULT_ENABLED configuration.');
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const apiVersion = process.env.VAULT_API_VERSION || 'v2';
|
|
43
|
+
const result = yield this.vaultClient.read(path);
|
|
44
|
+
if (!result || !result.data) {
|
|
45
|
+
throw new Error(`No data found at path: ${path}`);
|
|
46
|
+
}
|
|
47
|
+
const data = apiVersion === 'v2' ? result.data.data : result.data;
|
|
48
|
+
if (!data || typeof data !== 'object') {
|
|
49
|
+
throw new Error(`Invalid secret format at path: ${path}`);
|
|
50
|
+
}
|
|
51
|
+
if (key) {
|
|
52
|
+
if (!(key in data)) {
|
|
53
|
+
throw new Error(`Key '${key}' not found in secret at path: ${path}`);
|
|
54
|
+
}
|
|
55
|
+
return data[key];
|
|
56
|
+
}
|
|
57
|
+
return data;
|
|
58
|
+
}
|
|
59
|
+
catch (error) {
|
|
60
|
+
this.logger.error(`Failed to read secret from Vault: ${path}`, error.message);
|
|
61
|
+
throw error;
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
setSecret(path, data) {
|
|
66
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
67
|
+
if (!this.vaultClient) {
|
|
68
|
+
throw new Error('Vault client not initialized. Check VAULT_ENABLED configuration.');
|
|
69
|
+
}
|
|
70
|
+
try {
|
|
71
|
+
const apiVersion = process.env.VAULT_API_VERSION || 'v2';
|
|
72
|
+
if (apiVersion === 'v2') {
|
|
73
|
+
yield this.vaultClient.write(path, { data });
|
|
74
|
+
}
|
|
75
|
+
else {
|
|
76
|
+
yield this.vaultClient.write(path, data);
|
|
77
|
+
}
|
|
78
|
+
this.logger.log(`Successfully wrote secret to Vault: ${path}`);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
this.logger.error(`Failed to write secret to Vault: ${path}`, error.message);
|
|
82
|
+
throw error;
|
|
83
|
+
}
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
deleteSecret(path) {
|
|
87
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
88
|
+
if (!this.vaultClient) {
|
|
89
|
+
throw new Error('Vault client not initialized. Check VAULT_ENABLED configuration.');
|
|
90
|
+
}
|
|
91
|
+
try {
|
|
92
|
+
yield this.vaultClient.delete(path);
|
|
93
|
+
this.logger.log(`Successfully deleted secret from Vault: ${path}`);
|
|
94
|
+
}
|
|
95
|
+
catch (error) {
|
|
96
|
+
this.logger.error(`Failed to delete secret from Vault: ${path}`, error.message);
|
|
97
|
+
throw error;
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
listSecrets(path) {
|
|
102
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
103
|
+
if (!this.vaultClient) {
|
|
104
|
+
throw new Error('Vault client not initialized. Check VAULT_ENABLED configuration.');
|
|
105
|
+
}
|
|
106
|
+
try {
|
|
107
|
+
const result = yield this.vaultClient.list(path);
|
|
108
|
+
if (!result || !result.data || !result.data.keys) {
|
|
109
|
+
return [];
|
|
110
|
+
}
|
|
111
|
+
return result.data.keys;
|
|
112
|
+
}
|
|
113
|
+
catch (error) {
|
|
114
|
+
this.logger.error(`Failed to list secrets from Vault: ${path}`, error.message);
|
|
115
|
+
throw error;
|
|
116
|
+
}
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
healthCheck() {
|
|
120
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
121
|
+
if (!this.vaultClient) {
|
|
122
|
+
return false;
|
|
123
|
+
}
|
|
124
|
+
try {
|
|
125
|
+
const health = yield this.vaultClient.health();
|
|
126
|
+
return health && !health.sealed;
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
this.logger.error('Vault health check failed', error.message);
|
|
130
|
+
return false;
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
}
|
|
134
|
+
getStatus() {
|
|
135
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
136
|
+
if (!this.vaultClient) {
|
|
137
|
+
return null;
|
|
138
|
+
}
|
|
139
|
+
try {
|
|
140
|
+
const health = yield this.vaultClient.health();
|
|
141
|
+
return {
|
|
142
|
+
initialized: health.initialized || false,
|
|
143
|
+
sealed: health.sealed || false,
|
|
144
|
+
standby: health.standby || false,
|
|
145
|
+
version: health.version || 'unknown',
|
|
146
|
+
};
|
|
147
|
+
}
|
|
148
|
+
catch (error) {
|
|
149
|
+
this.logger.error('Failed to get Vault status', error.message);
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}
|
|
154
|
+
renewToken(increment) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
156
|
+
if (!this.vaultClient) {
|
|
157
|
+
throw new Error('Vault client not initialized. Check VAULT_ENABLED configuration.');
|
|
158
|
+
}
|
|
159
|
+
try {
|
|
160
|
+
yield this.vaultClient.tokenRenewSelf({ increment });
|
|
161
|
+
this.logger.log('Vault token renewed successfully');
|
|
162
|
+
}
|
|
163
|
+
catch (error) {
|
|
164
|
+
this.logger.error('Failed to renew Vault token', error.message);
|
|
165
|
+
throw error;
|
|
166
|
+
}
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
exports.VaultConfigService = VaultConfigService;
|
|
171
|
+
exports.VaultConfigService = VaultConfigService = VaultConfigService_1 = __decorate([
|
|
172
|
+
(0, common_1.Injectable)(),
|
|
173
|
+
__metadata("design:paramtypes", [])
|
|
174
|
+
], VaultConfigService);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.VaultModule = void 0;
|
|
10
|
+
const common_1 = require("@nestjs/common");
|
|
11
|
+
const vault_config_service_1 = require("./vault-config.service");
|
|
12
|
+
let VaultModule = class VaultModule {
|
|
13
|
+
};
|
|
14
|
+
exports.VaultModule = VaultModule;
|
|
15
|
+
exports.VaultModule = VaultModule = __decorate([
|
|
16
|
+
(0, common_1.Global)(),
|
|
17
|
+
(0, common_1.Module)({
|
|
18
|
+
providers: [vault_config_service_1.VaultConfigService],
|
|
19
|
+
exports: [vault_config_service_1.VaultConfigService],
|
|
20
|
+
})
|
|
21
|
+
], VaultModule);
|