@buka/nestjs-kit 4.9.0 → 4.9.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/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [4.9.1](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.9.0...v4.9.1) (2026-11-30)
4
+
5
+
6
+ ### Bug Fixes
7
+
8
+ * 并发解密共享 DEK 时不再被清零 ([63d3395](https://github.com/buka-ltd/npm.nestjs-kit/commit/63d33958f3c1c1b097fcb82fb28d8ac34d9378d4))
9
+
3
10
  ## [4.9.0](https://github.com/buka-ltd/npm.nestjs-kit/compare/v4.8.0...v4.9.0) (2026-11-28)
4
11
 
5
12
 
package/dist/index.js CHANGED
@@ -8286,14 +8286,17 @@ let EnvelopeEncryptionV1Cipher = _EnvelopeEncryptionV1Cipher = class EnvelopeEnc
8286
8286
  }
8287
8287
  async decrypt(cmd) {
8288
8288
  if (cmd.payload.cipherVersion !== this.version) throw new Error(`Cipher version mismatch: expected ${this.version}, got ${cmd.payload.cipherVersion}`);
8289
- const dek = await this.kmsProvider.decryptDek(cmd.envelope.kekId, cmd.envelope.kekVersion, cmd.envelope.dek);
8290
- const decipher = (0, crypto$1.createDecipheriv)(this.algorithm, dek, cmd.payload.cipherIv, { authTagLength: 16 });
8291
- const aad = this.buildAad(cmd.envelope.kekId, cmd.extraAad);
8292
- decipher.setAAD(aad);
8293
- decipher.setAuthTag(cmd.payload.cipherTag);
8294
- const decrypted = Buffer.concat([decipher.update(cmd.payload.ciphertext), decipher.final()]);
8295
- dek.fill(0);
8296
- return decrypted;
8289
+ const sharedDek = await this.kmsProvider.decryptDek(cmd.envelope.kekId, cmd.envelope.kekVersion, cmd.envelope.dek);
8290
+ const dek = Buffer.from(sharedDek);
8291
+ try {
8292
+ const decipher = (0, crypto$1.createDecipheriv)(this.algorithm, dek, cmd.payload.cipherIv, { authTagLength: 16 });
8293
+ const aad = this.buildAad(cmd.envelope.kekId, cmd.extraAad);
8294
+ decipher.setAAD(aad);
8295
+ decipher.setAuthTag(cmd.payload.cipherTag);
8296
+ return Buffer.concat([decipher.update(cmd.payload.ciphertext), decipher.final()]);
8297
+ } finally {
8298
+ dek.fill(0);
8299
+ }
8297
8300
  }
8298
8301
  };
8299
8302
  EnvelopeEncryptionV1Cipher = _EnvelopeEncryptionV1Cipher = __decorate([(0, _nestjs_common.Injectable)(), __decorateMetadata("design:paramtypes", [typeof (_ref$1 = typeof KmsProvider !== "undefined" && KmsProvider) === "function" ? _ref$1 : Object])], EnvelopeEncryptionV1Cipher);