@buka/nestjs-kit 4.1.6 → 4.1.8

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
@@ -1,5 +1,19 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.1.8](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.1.7...v4.1.8) (2026-05-23)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * 修复dek缓存返回原始数据被删除后缓存损坏的问题 ([5761659](https://github.com/buka-ltd/npm.nestjs-kit/commit/57616596144eaacb9e9488ed26d441f45ef1d9ac))
9
+
10
+ ## [4.1.7](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.1.6...v4.1.7) (2026-05-23)
11
+
12
+
13
+ ### Bug Fixes
14
+
15
+ * 修复预热dek和openbao初始化鉴权冲突的问题 ([4e75b91](https://github.com/buka-ltd/npm.nestjs-kit/commit/4e75b914cfa8d2a503b277215fb88ef0eaef136f))
16
+
3
17
  ## [4.1.6](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.1.5...v4.1.6) (2026-05-23)
4
18
 
5
19
 
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _$_nestjs_common0 from "@nestjs/common";
2
- import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
2
+ import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
3
3
  import { AnyEntity, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
4
4
  import { ValidationOptions } from "class-validator";
5
5
  import { ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
@@ -18347,7 +18347,7 @@ interface GeneratedDek {
18347
18347
  encryptedDek: Buffer;
18348
18348
  kekVersion: number;
18349
18349
  }
18350
- declare class KmsProvider implements OnModuleInit, OnModuleDestroy {
18350
+ declare class KmsProvider implements OnApplicationBootstrap, OnModuleDestroy {
18351
18351
  private readonly openbao;
18352
18352
  private readonly options;
18353
18353
  private readonly logger;
@@ -18357,7 +18357,7 @@ declare class KmsProvider implements OnModuleInit, OnModuleDestroy {
18357
18357
  private dekDecryptingPromises;
18358
18358
  private dekCacheCleanupTimer;
18359
18359
  constructor(openbao: OpenBaoHttpClient, options: EnvelopeEncryptionModuleOptions);
18360
- onModuleInit(): Promise<void>;
18360
+ onApplicationBootstrap(): Promise<void>;
18361
18361
  onModuleDestroy(): void;
18362
18362
  private getOrLoadKekMetadata;
18363
18363
  generateDek(kekId: string, _type: 'aes128-gcm96' | 'aes256-gcm96' | 'chacha20-poly1305'): Promise<GeneratedDek>;
package/dist/index.d.ts CHANGED
@@ -2,7 +2,7 @@ import { ApiPropertyOptions, OpenAPIObject } from "@nestjs/swagger";
2
2
  import * as _$type_fest0 from "type-fest";
3
3
  import { Class, JsonValue, ValueOf } from "type-fest";
4
4
  import * as _$_nestjs_common0 from "@nestjs/common";
5
- import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
5
+ import { ArgumentMetadata, ArgumentsHost, DynamicModule, ExceptionFilter, HttpStatus, OnApplicationBootstrap, OnModuleDestroy, OnModuleInit, PipeTransform, Type, ValidationPipe, ValidationPipeOptions } from "@nestjs/common";
6
6
  import { ValidationOptions } from "class-validator";
7
7
  import { AnyEntity, Config, Cursor, DefineConfig, EmbeddedOptions, EntityManager, EntityName, EnumOptions, Hidden, HiddenProps, ManyToManyOptions, ManyToOneOptions, MikroORM, OneToManyOptions, OneToOneOptions, Opt, OptionalProps, Options, Primary, PrimaryKeyProp, PrimaryProperty, PropertyOptions, QueryOrderMap, Ref } from "@mikro-orm/core";
8
8
  import { Keq, KeqMiddleware, KeqOperation, KeqPathParameterInit, KeqQueryInit, KeqRequest } from "keq";
@@ -18347,7 +18347,7 @@ interface GeneratedDek {
18347
18347
  encryptedDek: Buffer;
18348
18348
  kekVersion: number;
18349
18349
  }
18350
- declare class KmsProvider implements OnModuleInit, OnModuleDestroy {
18350
+ declare class KmsProvider implements OnApplicationBootstrap, OnModuleDestroy {
18351
18351
  private readonly openbao;
18352
18352
  private readonly options;
18353
18353
  private readonly logger;
@@ -18357,7 +18357,7 @@ declare class KmsProvider implements OnModuleInit, OnModuleDestroy {
18357
18357
  private dekDecryptingPromises;
18358
18358
  private dekCacheCleanupTimer;
18359
18359
  constructor(openbao: OpenBaoHttpClient, options: EnvelopeEncryptionModuleOptions);
18360
- onModuleInit(): Promise<void>;
18360
+ onApplicationBootstrap(): Promise<void>;
18361
18361
  onModuleDestroy(): void;
18362
18362
  private getOrLoadKekMetadata;
18363
18363
  generateDek(kekId: string, _type: 'aes128-gcm96' | 'aes256-gcm96' | 'chacha20-poly1305'): Promise<GeneratedDek>;
package/dist/index.js CHANGED
@@ -9435,7 +9435,7 @@ let KmsProvider = _KmsProvider = class KmsProvider {
9435
9435
  this.openbao = openbao;
9436
9436
  this.options = options;
9437
9437
  }
9438
- async onModuleInit() {
9438
+ async onApplicationBootstrap() {
9439
9439
  const keks = this.options.keks ?? [];
9440
9440
  await Promise.all(keks.map((kekId) => this.getOrLoadKekMetadata(kekId)));
9441
9441
  const ttl = this.options.dekCacheTtl ?? 0;
@@ -9490,7 +9490,7 @@ let KmsProvider = _KmsProvider = class KmsProvider {
9490
9490
  const cacheKey = encryptedDek.toString("base64");
9491
9491
  if (ttl > 0) {
9492
9492
  const cached = this.dekCache.get(cacheKey);
9493
- if (cached && cached.expireAt > Date.now()) return Promise.resolve(cached.dek);
9493
+ if (cached && cached.expireAt > Date.now()) return Promise.resolve(Buffer.from(cached.dek));
9494
9494
  const inflight = this.dekDecryptingPromises.get(cacheKey);
9495
9495
  if (inflight) return inflight;
9496
9496
  }
@@ -9507,7 +9507,7 @@ let KmsProvider = _KmsProvider = class KmsProvider {
9507
9507
  });
9508
9508
  const dek = Buffer.from(dekResponse.data.plaintext, "base64");
9509
9509
  if (ttl > 0) this.dekCache.set(cacheKey, {
9510
- dek,
9510
+ dek: Buffer.from(dek),
9511
9511
  expireAt: Date.now() + ttl * 1e3
9512
9512
  });
9513
9513
  return dek;