@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-
|
|
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-
|
|
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;
|