oidc-jwt-client
Advanced tools
Comparing version 4.0.5-develop.4 to 4.0.5-develop.5
@@ -5,5 +5,8 @@ 'use strict'; | ||
var getLocalStorageSize = require('./utils/getLocalStorageSize.js'); | ||
var isQuotaExceeded = require('./utils/isQuotaExceeded.js'); | ||
var isSSR = require('./utils/isSSR.js'); | ||
var parseJson = require('./utils/parseJson.js'); | ||
/* eslint-disable max-len */ | ||
var Storage = /** @class */ (function () { | ||
@@ -21,3 +24,16 @@ function Storage() { | ||
return; | ||
return localStorage.setItem(key, JSON.stringify(value)); | ||
try { | ||
return localStorage.setItem(key, JSON.stringify(value)); | ||
} | ||
catch (error) { | ||
var entries = Object.entries(localStorage).map(function (_a) { | ||
var key = _a[0], value = _a[1]; | ||
return key + ":" + value.length; | ||
}); | ||
var storageSize = getLocalStorageSize.getLocalStorageSize(); | ||
if (isQuotaExceeded.isQuotaExceeded(error)) { | ||
throw new Error("LocalStorage full for key: \"" + key + "\" and value: \"" + JSON.stringify(value) + "\" - entries: " + JSON.stringify(entries) + " - error: " + error + " - size: " + storageSize); | ||
} | ||
throw new Error("LocalStorage failed for key: \"" + key + "\" and value: \"" + JSON.stringify(value) + "\" - entries: " + JSON.stringify(entries) + " - error: " + error); | ||
} | ||
}; | ||
@@ -24,0 +40,0 @@ Storage.unset = function (key) { |
@@ -0,4 +1,7 @@ | ||
import { getLocalStorageSize } from './utils/getLocalStorageSize.js'; | ||
import { isQuotaExceeded } from './utils/isQuotaExceeded.js'; | ||
import { isSSR } from './utils/isSSR.js'; | ||
import { parseJson } from './utils/parseJson.js'; | ||
/* eslint-disable max-len */ | ||
var Storage = /** @class */ (function () { | ||
@@ -16,3 +19,16 @@ function Storage() { | ||
return; | ||
return localStorage.setItem(key, JSON.stringify(value)); | ||
try { | ||
return localStorage.setItem(key, JSON.stringify(value)); | ||
} | ||
catch (error) { | ||
var entries = Object.entries(localStorage).map(function (_a) { | ||
var key = _a[0], value = _a[1]; | ||
return key + ":" + value.length; | ||
}); | ||
var storageSize = getLocalStorageSize(); | ||
if (isQuotaExceeded(error)) { | ||
throw new Error("LocalStorage full for key: \"" + key + "\" and value: \"" + JSON.stringify(value) + "\" - entries: " + JSON.stringify(entries) + " - error: " + error + " - size: " + storageSize); | ||
} | ||
throw new Error("LocalStorage failed for key: \"" + key + "\" and value: \"" + JSON.stringify(value) + "\" - entries: " + JSON.stringify(entries) + " - error: " + error); | ||
} | ||
}; | ||
@@ -19,0 +35,0 @@ Storage.unset = function (key) { |
{ | ||
"name": "oidc-jwt-client", | ||
"version": "4.0.5-develop.4", | ||
"version": "4.0.5-develop.5", | ||
"description": "Fetch JWTs for API access from oidc-jwt-provider", | ||
@@ -5,0 +5,0 @@ "sideEffects": false, |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
152063
63
1494