poe-code 3.0.116 → 3.0.117

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.
@@ -1420,7 +1420,12 @@ function defaultMachineIdentity() {
1420
1420
  async function deriveEncryptionKey(getMachineIdentity, salt) {
1421
1421
  const machineIdentity = await getMachineIdentity();
1422
1422
  const secret = `${machineIdentity.hostname}:${machineIdentity.username}`;
1423
- return await new Promise((resolve, reject) => {
1423
+ const cacheKey = `${secret}:${salt}`;
1424
+ const cached = derivedKeyCache.get(cacheKey);
1425
+ if (cached) {
1426
+ return cached;
1427
+ }
1428
+ const keyPromise = new Promise((resolve, reject) => {
1424
1429
  scrypt(secret, salt, ENCRYPTION_KEY_BYTES, (error, derivedKey) => {
1425
1430
  if (error) {
1426
1431
  reject(error);
@@ -1429,6 +1434,8 @@ async function deriveEncryptionKey(getMachineIdentity, salt) {
1429
1434
  resolve(Buffer.from(derivedKey));
1430
1435
  });
1431
1436
  });
1437
+ derivedKeyCache.set(cacheKey, keyPromise);
1438
+ return keyPromise;
1432
1439
  }
1433
1440
  function parseEncryptedDocument(raw) {
1434
1441
  try {
@@ -1460,10 +1467,11 @@ function isNotFoundError(error) {
1460
1467
  error && typeof error === "object" && "code" in error && error.code === "ENOENT"
1461
1468
  );
1462
1469
  }
1463
- var ENCRYPTION_ALGORITHM, ENCRYPTION_VERSION, ENCRYPTION_KEY_BYTES, ENCRYPTION_IV_BYTES, ENCRYPTION_AUTH_TAG_BYTES, ENCRYPTION_FILE_MODE, EncryptedFileStore;
1470
+ var derivedKeyCache, ENCRYPTION_ALGORITHM, ENCRYPTION_VERSION, ENCRYPTION_KEY_BYTES, ENCRYPTION_IV_BYTES, ENCRYPTION_AUTH_TAG_BYTES, ENCRYPTION_FILE_MODE, EncryptedFileStore;
1464
1471
  var init_encrypted_file_store = __esm({
1465
1472
  "packages/auth-store/src/encrypted-file-store.ts"() {
1466
1473
  "use strict";
1474
+ derivedKeyCache = /* @__PURE__ */ new Map();
1467
1475
  ENCRYPTION_ALGORITHM = "aes-256-gcm";
1468
1476
  ENCRYPTION_VERSION = 1;
1469
1477
  ENCRYPTION_KEY_BYTES = 32;