v.1.0.0. initial push of license-lib

This commit is contained in:
2025-03-19 09:37:30 -05:00
commit b22a1c973c
20 changed files with 433 additions and 0 deletions

24
client/offline.js Normal file
View File

@@ -0,0 +1,24 @@
// client/offline.js
const CACHE_KEY = 'license_data';
export const cacheLicenseData = (licenseData) => {
localStorage.setItem(CACHE_KEY, JSON.stringify({
data: licenseData,
cachedAt: Date.now(),
}));
};
export const getCachedLicenseData = () => {
const item = localStorage.getItem(CACHE_KEY);
return item ? JSON.parse(item) : null;
};
export const isLicenseCacheValid = () => {
const cache = getCachedLicenseData();
if (!cache) return false;
const cachedAt = cache.cachedAt;
const elapsedDays = (Date.now() - cachedAt) / (1000 * 60 * 60 * 24);
return elapsedDays <= CONFIG.OFFLINE_GRACE_PERIOD_DAYS;
};