@lunora/storage 1.0.0-alpha.3 → 1.0.0-alpha.4

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/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
1
  export { createBucketStorage } from './packem_shared/createBucketStorage-4Xk7-5CN.mjs';
2
- export { createStorage, scopeKey } from './packem_shared/createStorage-Bs_iJ1Mx.mjs';
2
+ export { createStorage, scopeKey } from './packem_shared/createStorage-DoE7gOqo.mjs';
3
3
  export { buildPresignedUrl } from './packem_shared/buildPresignedUrl-DzPwi1bY.mjs';
4
- export { buildSignedUrl, verifySignedUrl } from './packem_shared/buildSignedUrl-ZzB16yPl.mjs';
4
+ export { buildSignedUrl, verifySignedUrl } from './packem_shared/buildSignedUrl-O-vsHfyW.mjs';
@@ -15,12 +15,19 @@ const fromBase64Url = (input) => {
15
15
  }
16
16
  return bytes;
17
17
  };
18
+ const KEY_CACHE_MAX = 64;
18
19
  const keyCache = /* @__PURE__ */ new Map();
19
20
  const importHmacKey = async (secret) => {
20
21
  const cached = keyCache.get(secret);
21
22
  if (cached) {
22
23
  return cached;
23
24
  }
25
+ if (keyCache.size >= KEY_CACHE_MAX) {
26
+ const oldest = keyCache.keys().next().value;
27
+ if (oldest !== void 0) {
28
+ keyCache.delete(oldest);
29
+ }
30
+ }
24
31
  const keyPromise = crypto.subtle.importKey("raw", textEncoder.encode(secret), { hash: "SHA-256", name: "HMAC" }, false, ["sign", "verify"]);
25
32
  keyCache.set(secret, keyPromise);
26
33
  return keyPromise;
@@ -1,5 +1,5 @@
1
1
  import { buildPresignedUrl } from './buildPresignedUrl-DzPwi1bY.mjs';
2
- import { buildSignedUrl } from './buildSignedUrl-ZzB16yPl.mjs';
2
+ import { buildSignedUrl } from './buildSignedUrl-O-vsHfyW.mjs';
3
3
 
4
4
  const MAX_KEY_LENGTH = 1024;
5
5
  const MAX_LIST_LIMIT = 1e3;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunora/storage",
3
- "version": "1.0.0-alpha.3",
3
+ "version": "1.0.0-alpha.4",
4
4
  "description": "R2-backed storage for Lunora: typed buckets and signed URLs",
5
5
  "keywords": [
6
6
  "cloudflare",