@yawlabs/vend-mcp 0.1.0 → 0.1.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/dist/index.d.ts +1 -0
- package/dist/index.js +3 -2
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -42,6 +42,7 @@ export class VendGuard {
|
|
|
42
42
|
errorCacheTtl;
|
|
43
43
|
cached = null;
|
|
44
44
|
cachedAt = 0;
|
|
45
|
+
maxFallbackTtl = 3600_000; // 1 hour max for offline fallback
|
|
45
46
|
hooks;
|
|
46
47
|
constructor(opts) {
|
|
47
48
|
this.apiKey = opts.apiKey;
|
|
@@ -104,8 +105,8 @@ export class VendGuard {
|
|
|
104
105
|
}
|
|
105
106
|
catch (err) {
|
|
106
107
|
this.hooks.onError?.('validate', err);
|
|
107
|
-
// On network error, use previous successful cache if
|
|
108
|
-
if (this.cached?.valid) {
|
|
108
|
+
// On network error, use previous successful cache if not too old
|
|
109
|
+
if (this.cached?.valid && Date.now() - this.cachedAt < this.maxFallbackTtl) {
|
|
109
110
|
this.hooks.onValidate?.(this.cached, true);
|
|
110
111
|
return this.cached;
|
|
111
112
|
}
|