From d88c5e030a1449f5d92042675015e7494c1539be Mon Sep 17 00:00:00 2001 From: David Rivera Date: Mon, 24 Apr 2017 16:31:47 -0600 Subject: [PATCH] Allow storing secure cookies (HTTPS) --- CHANGELOG.md | 10 +++++++++- README.md | 17 +++++++++-------- dist/proxy-storage.js | 29 ++++++++++++++++++++++------- dist/proxy-storage.min.js | 4 ++-- dist/proxy-storage.min.map | 2 +- package.json | 2 +- src/cookie-storage.js | 27 +++++++++++++++++++++------ 7 files changed, 65 insertions(+), 26 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d4deb17..0da0630 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,13 +2,21 @@ +## 2.1.3 + +### Improvements + +1. Allow storing secure cookies (HTTPS). The property `secure` is available through the `options` parameter for `setItem()` and `removeItem()` + +--- + ## 2.1.2 ### Improvements 1. Added the `options` parameter to the API method `removeItem()`, in order to allow passing metadata to the cookie to delete. When using `"cookieStorage"` the new signature is: `instance.removeItem(key, options)` -1. Checks if the cookie was created on `setItem()`, or delete it if the domain or path are not valid. +1. When calling `setItem()`, checks if the cookie was created, or deletes it if the domain or path are not valid. --- diff --git a/README.md b/README.md index af5645e..d311163 100644 --- a/README.md +++ b/README.md @@ -59,7 +59,7 @@ $ yarn add proxy-storage - + ``` In the above case, [`proxyStorage`](#api) is included as a global object @@ -295,6 +295,7 @@ Where the **`options`** parameter is an `object` with the following properties: - `domain`_`{string}`_: the domain or subdomain where the cookie will be valid. - `path`_`{string}`_: relative path where the cookie is valid. _Default `"/"`_ +- `secure`_`{boolean}`_: if provided, sets a secure cookie (HTTPS). - `expires`_`{Date, object}`_: the expiration date of the cookie. You can pass an object describing the expiration: - `date`_`{Date}`_: if provided, this date will be applied, otherwise the @@ -323,12 +324,13 @@ cookieStore.setItem('activity', data, { }); cookieStore.setItem('testing1', true, { - path: '/profile', - expires: new Date('2018/03/06'), + secure: true, + path: '/jherax', + expires: new Date('2017/12/31'), }); cookieStore.setItem('testing2', [1,4,7], { - domain: '.wordpress.com', + domain: '.github.com', expires: { days: 1 }, }); @@ -426,9 +428,8 @@ function clearAllStorages() { The [`WebStorage`](#webstorage) class exposes the static member `interceptors` which lets you to register callback functions upon the prototype methods -`setItem`, `getItem`, `removeItem`, and `clear`. -It is very useful when you need to perform an action to intercept the value -to read, write, or delete. +`setItem`, `getItem`, `removeItem`, and `clear`. It is very useful when you +need to perform an action to intercept the value to read, write, or delete. - **`WebStorage.interceptors`**`(command, action)`: adds an interceptor to the API method. @@ -473,7 +474,7 @@ WebStorage.interceptors('removeItem', (key/*, options*/) => { }); // uses the default storage mechanism (usually localStorage) -storage.setItem('storage-test', { id: 1040, text: 'it works!' }); +storage.setItem('storage-test', {id: 1040, text: 'it works!'}); let data = storage.getItem('storage-test'); console.log(data); diff --git a/dist/proxy-storage.js b/dist/proxy-storage.js index 18aaf49..e938ade 100644 --- a/dist/proxy-storage.js +++ b/dist/proxy-storage.js @@ -1,4 +1,4 @@ -/*! proxyStorage@v2.1.2. Jherax 2017. Visit https://github.com/jherax/proxy-storage */ +/*! proxyStorage@v2.1.3. Jherax 2017. Visit https://github.com/jherax/proxy-storage */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -562,7 +562,7 @@ function buildExpirationString(date) { /** * @private * - * Builds the string for the cookie's metadata. + * Builds the string for the cookie metadata. * * @param {string} key: name of the metadata * @param {object} data: metadata of the cookie @@ -570,7 +570,23 @@ function buildExpirationString(date) { */ function buildMetadataFor(key, data) { if (!data[key]) return ''; - return '; ' + key + '=' + data[key]; + return ';' + key + '=' + data[key]; +} + +/** + * @private + * + * Builds the whole string for the cookie metadata. + * + * @param {object} data: metadata of the cookie + * @return {string} + */ +function formatMetadata(data) { + var expires = buildMetadataFor('expires', data); + var domain = buildMetadataFor('domain', data); + var path = buildMetadataFor('path', data); + var secure = data.secure ? ';secure' : ''; + return '' + expires + domain + path + secure; } /** @@ -608,10 +624,9 @@ function cookieStorage() { if (options.domain && typeof options.domain === 'string') { metadata.domain = options.domain.trim(); } - var expires = buildMetadataFor('expires', metadata); - var domain = buildMetadataFor('domain', metadata); - var path = buildMetadataFor('path', metadata); - var cookie = key + '=' + encodeURIComponent(value) + expires + domain + path; + if (options.secure === true) metadata.secure = true; + var cookie = key + '=' + encodeURIComponent(value) + formatMetadata(metadata); + // TODO: should encodeURIComponent(key) ? $cookie.set(cookie); }, getItem: function getItem(key) { diff --git a/dist/proxy-storage.min.js b/dist/proxy-storage.min.js index 69956cc..a79b151 100644 --- a/dist/proxy-storage.min.js +++ b/dist/proxy-storage.min.js @@ -1,3 +1,3 @@ -/*! proxyStorage@v2.1.2. Jherax 2017. Visit https://github.com/jherax/proxy-storage */ -!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.proxyStorage=t():e.proxyStorage=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,n){"use strict";function o(e){return"[object Object]"===Object.prototype.toString.call(e)}function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},e),n=t.date instanceof Date?t.date:new Date;return+t.minutes&&n.setMinutes(n.getMinutes()+t.minutes),+t.hours&&n.setHours(n.getHours()+t.hours),+t.days&&n.setDate(n.getDate()+t.days),+t.months&&n.setMonth(n.getMonth()+t.months),+t.years&&n.setFullYear(n.getFullYear()+t.years),n}function i(e,t,n){var o={configurable:!1,enumerable:!1,writable:!1};"undefined"!=typeof n&&(o.value=n),Object.defineProperty(e,t,o)}function a(e){if(null==e||""===e)throw new Error("The key provided can not be empty")}Object.defineProperty(t,"__esModule",{value:!0}),t.isObject=o,t.alterDate=r,t.setProperty=i,t.checkEmpty=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.isAvailable={localStorage:!1,sessionStorage:!1,cookieStorage:!1,memoryStorage:!0}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t=arguments.length,n=Array(t>1?t-1:0),o=1;o-1&&(t=o.substring(0,n),e.removeItem(t.trim()))})},initialize:function(){s.get().split(";").forEach(function(t){var n=t.indexOf("="),o=t.substring(0,n).trim(),r=t.substring(n+1).trim();o&&(e[o]=decodeURIComponent(r))}),delete e.initialize}};return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=a;var u=n(0),s={get:function(){return document.cookie},set:function(e){document.cookie=e},data:{}}},function(e,t,n){"use strict";function o(){try{var e=JSON.parse(window.self.name);if(e&&"object"===("undefined"==typeof e?"undefined":a(e)))return e}catch(e){return{}}}function r(e){var t=JSON.stringify(e);window.self.name=t}function i(){var e=o(),t={setItem:function(t,n){e[t]=n,r(e)},getItem:function(t){var n=e[t];return void 0===n?null:n},removeItem:function(t){delete e[t],r(e)},clear:function(){Object.keys(e).forEach(function(t){return delete e[t]}),r(e)},initialize:function(){Object.assign(t,e),delete t.initialize}};return t}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=i},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){if(!e.initialize)return e;for(var t in e)"initialize"!==t&&(0,l.setProperty)(e,t);return e.initialize(),e}Object.defineProperty(t,"__esModule",{value:!0}),t.proxy=void 0;var i=n(3),a=o(i),u=n(4),s=o(u),l=n(0);t.proxy={localStorage:window.localStorage,sessionStorage:window.sessionStorage,cookieStorage:r((0,a.default)()),memoryStorage:r((0,s.default)())}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){var t=u.proxy[e],n="__proxy-storage__";try{return t.setItem(n,n),t.removeItem(n),!0}catch(e){return!1}}function i(e){return l.isAvailable[e]&&(u.webStorageSettings.default=e,f.set(e)),l.isAvailable[e]}function a(){l.isAvailable.localStorage=r("localStorage"),l.isAvailable.sessionStorage=r("sessionStorage"),l.isAvailable.cookieStorage=r("cookieStorage"),u.webStorageSettings.isAvailable=l.isAvailable,Object.keys(l.isAvailable).some(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.isAvailable=t.configStorage=t.WebStorage=t.default=void 0;var u=n(2),s=o(u),l=n(1),c=null,f={get:function(){return c.__storage__},set:function(e){if(!Object.prototype.hasOwnProperty.call(u.proxy,e))throw new Error('Storage type "'+e+'" is not valid');t.default=c=new s.default(e)}};a(),t.default=c,t.WebStorage=s.default,t.configStorage=f,t.isAvailable=l.isAvailable}])}); +/*! proxyStorage@v2.1.3. Jherax 2017. Visit https://github.com/jherax/proxy-storage */ +!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.proxyStorage=t():e.proxyStorage=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={i:o,l:!1,exports:{}};return e[o].call(r.exports,r,r.exports,t),r.l=!0,r.exports}var n={};return t.m=e,t.c=n,t.i=function(e){return e},t.d=function(e,n,o){t.o(e,n)||Object.defineProperty(e,n,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=6)}([function(e,t,n){"use strict";function o(e){return"[object Object]"===Object.prototype.toString.call(e)}function r(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},e),n=t.date instanceof Date?t.date:new Date;return+t.minutes&&n.setMinutes(n.getMinutes()+t.minutes),+t.hours&&n.setHours(n.getHours()+t.hours),+t.days&&n.setDate(n.getDate()+t.days),+t.months&&n.setMonth(n.getMonth()+t.months),+t.years&&n.setFullYear(n.getFullYear()+t.years),n}function i(e,t,n){var o={configurable:!1,enumerable:!1,writable:!1};"undefined"!=typeof n&&(o.value=n),Object.defineProperty(e,t,o)}function a(e){if(null==e||""===e)throw new Error("The key provided can not be empty")}Object.defineProperty(t,"__esModule",{value:!0}),t.isObject=o,t.alterDate=r,t.setProperty=i,t.checkEmpty=a},function(e,t,n){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.isAvailable={localStorage:!1,sessionStorage:!1,cookieStorage:!1,memoryStorage:!0}},function(e,t,n){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function r(e){for(var t=arguments.length,n=Array(t>1?t-1:0),o=1;o-1&&(t=o.substring(0,n),e.removeItem(t.trim()))})},initialize:function(){c.get().split(";").forEach(function(t){var n=t.indexOf("="),o=t.substring(0,n).trim(),r=t.substring(n+1).trim();o&&(e[o]=decodeURIComponent(r))}),delete e.initialize}};return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=u;var s=n(0),c={get:function(){return document.cookie},set:function(e){document.cookie=e},data:{}}},function(e,t,n){"use strict";function o(){try{var e=JSON.parse(window.self.name);if(e&&"object"===("undefined"==typeof e?"undefined":a(e)))return e}catch(e){return{}}}function r(e){var t=JSON.stringify(e);window.self.name=t}function i(){var e=o(),t={setItem:function(t,n){e[t]=n,r(e)},getItem:function(t){var n=e[t];return void 0===n?null:n},removeItem:function(t){delete e[t],r(e)},clear:function(){Object.keys(e).forEach(function(t){return delete e[t]}),r(e)},initialize:function(){Object.assign(t,e),delete t.initialize}};return t}Object.defineProperty(t,"__esModule",{value:!0});var a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e};t.default=i},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){if(!e.initialize)return e;for(var t in e)"initialize"!==t&&(0,c.setProperty)(e,t);return e.initialize(),e}Object.defineProperty(t,"__esModule",{value:!0}),t.proxy=void 0;var i=n(3),a=o(i),u=n(4),s=o(u),c=n(0);t.proxy={localStorage:window.localStorage,sessionStorage:window.sessionStorage,cookieStorage:r((0,a.default)()),memoryStorage:r((0,s.default)())}},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}function r(e){var t=u.proxy[e],n="__proxy-storage__";try{return t.setItem(n,n),t.removeItem(n),!0}catch(e){return!1}}function i(e){return c.isAvailable[e]&&(u.webStorageSettings.default=e,f.set(e)),c.isAvailable[e]}function a(){c.isAvailable.localStorage=r("localStorage"),c.isAvailable.sessionStorage=r("sessionStorage"),c.isAvailable.cookieStorage=r("cookieStorage"),u.webStorageSettings.isAvailable=c.isAvailable,Object.keys(c.isAvailable).some(i)}Object.defineProperty(t,"__esModule",{value:!0}),t.isAvailable=t.configStorage=t.WebStorage=t.default=void 0;var u=n(2),s=o(u),c=n(1),l=null,f={get:function(){return l.__storage__},set:function(e){if(!Object.prototype.hasOwnProperty.call(u.proxy,e))throw new Error('Storage type "'+e+'" is not valid');t.default=l=new s.default(e)}};a(),t.default=l,t.WebStorage=s.default,t.configStorage=f,t.isAvailable=c.isAvailable}])}); //# sourceMappingURL=proxy-storage.min.map \ No newline at end of file diff --git a/dist/proxy-storage.min.map b/dist/proxy-storage.min.map index c9a890f..95cf231 100644 --- a/dist/proxy-storage.min.map +++ b/dist/proxy-storage.min.map @@ -1 +1 @@ -{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///proxy-storage.min.js","webpack:///webpack/bootstrap 4bef309fee7da4d719d8","webpack:///./src/utils.js","webpack:///./src/is-available.js","webpack:///./src/web-storage.js","webpack:///./src/cookie-storage.js","webpack:///./src/memory-storage.js","webpack:///./src/proxy-mechanism.js","webpack:///./src/proxy-storage.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","isObject","toString","alterDate","options","arguments","length","undefined","opt","assign","date","Date","minutes","setMinutes","getMinutes","hours","setHours","getHours","days","setDate","getDate","months","setMonth","getMonth","years","setFullYear","getFullYear","setProperty","obj","descriptor","writable","checkEmpty","key","Error","isAvailable","localStorage","sessionStorage","cookieStorage","memoryStorage","_classCallCheck","instance","Constructor","TypeError","executeInterceptors","command","_len","args","Array","_key","shift","_typeof","JSON","parse","stringify","_interceptors","reduce","val","action","transformed","concat","tryParse","parsed","e","copyKeys","storage","keys","forEach","storageAvailable","storageType","webStorageSettings","console","warn","default","proxy","_createClass","defineProperties","target","props","protoProps","staticProps","Symbol","iterator","constructor","_proxyMechanism","_utils","_isAvailable","_instances","setItem","getItem","removeItem","clear","bannedKeys","WebStorage","cachedInstance","__storage__","test","v","_this","push","buildExpirationString","expires","toUTCString","buildMetadataFor","data","findCookie","cookie","nameEQ","trim","indexOf","api","path","$cookie","metadata","domain","encodeURIComponent","set","split","find","substring","decodeURIComponent","indexEQ","initialize","index","document","getStoreFromWindow","store","window","self","setStoreToWindow","hashtable","_interopRequireDefault","initApi","prop","_cookieStorage","_cookieStorage2","_memoryStorage","_memoryStorage2","isStorageAvailable","storageObj","_webStorage","configStorage","init","some","_webStorage2"],"mappings":";CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,aAAAD,IAEAD,EAAA,aAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,G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6E,KAAPoB,EAAAnD,aAAyB4G,KAAK3E,GRysBhC/E,OAAOC,eAAepB,EAAS,cAC7Bc,OAAO,IAETd,EAAQiE,YAAcjE,EAAQ2K,cAAgB3K,EAAQ2H,WAAa3H,EAAQuG,QAAUjE,MQnyBrF,IAAAoI,GAAApK,EAAA,GRuyBIwK,EAAeb,EAAuBS,GQtyB1CtD,EAAA9G,EAAA,GASIyF,EAAU,KASR4E,GACJpJ,IADoB,WAElB,MAAOwE,GAAQ8B,aASjBqB,IAXoB,SAWhB/C,GACF,IAAKhF,OAAOS,UAAUC,eAAelB,KAAhC+J,EAAAlE,MAA4CL,GAC/C,KAAM,IAAInC,OAAJ,iBAA2BmC,EAA3B,iBAERnG,GA6DeuG,QA7DfR,EAAU,GAAA+E,GAAAvE,QAAeJ,IAwD7ByE,KRg0BA5K,EQ3zBmBuG,QAAXR,ER4zBR/F,EQ5zB4B2H,WR4zBPmD,EAAavE,QAClCvG,EQ7zBwC2K,gBR8zBxC3K,EQ9zBuDiE,YR8zBjCmD,EAAanD","file":"proxy-storage.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"proxyStorage\"] = factory();\n\telse\n\t\troot[\"proxyStorage\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"proxyStorage\"] = factory();\n\telse\n\t\troot[\"proxyStorage\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 6);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.isObject = isObject;\nexports.alterDate = alterDate;\nexports.setProperty = setProperty;\nexports.checkEmpty = checkEmpty;\n/**\n * Determines whether a value is a plain object.\n *\n * @param {any} value: the object to test\n * @return {boolean}\n */\nfunction isObject(value) {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * Adds or subtracts date portions to the given date and returns the new date.\n *\n * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2\n *\n * @param {object} options: It contains the date parts to add or remove, and can have the following properties:\n * - {Date} date: if provided, this date will be affected, otherwise the current date will be used.\n * - {number} minutes: minutes to add/subtract\n * - {number} hours: hours to add/subtract\n * - {number} days: days to add/subtract\n * - {number} months: months to add/subtract\n * - {number} years: years to add/subtract\n * @return {Date}\n */\nfunction alterDate() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n var opt = Object.assign({}, options);\n var d = opt.date instanceof Date ? opt.date : new Date();\n if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes);\n if (+opt.hours) d.setHours(d.getHours() + opt.hours);\n if (+opt.days) d.setDate(d.getDate() + opt.days);\n if (+opt.months) d.setMonth(d.getMonth() + opt.months);\n if (+opt.years) d.setFullYear(d.getFullYear() + opt.years);\n return d;\n}\n\n/**\n * Creates a non-enumerable read-only property.\n *\n * @param {object} obj: the object to add the property\n * @param {string} name: the name of the property\n * @param {any} value: the value of the property\n * @return {void}\n */\nfunction setProperty(obj, name, value) {\n var descriptor = {\n configurable: false,\n enumerable: false,\n writable: false\n };\n if (typeof value !== 'undefined') {\n descriptor.value = value;\n }\n Object.defineProperty(obj, name, descriptor);\n}\n\n/**\n * Validates if the key is not empty.\n * (null, undefined or empty string)\n *\n * @param {string} key: keyname of an element in the storage mechanism\n * @return {void}\n */\nfunction checkEmpty(key) {\n if (key == null || key === '') {\n throw new Error('The key provided can not be empty');\n }\n}\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n/**\n * @public\n *\n * Used to determine which storage mechanisms are available.\n *\n * @type {object}\n */\nvar isAvailable = exports.isAvailable = {\n localStorage: false,\n sessionStorage: false,\n cookieStorage: false,\n memoryStorage: true };\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.proxy = exports.webStorageSettings = exports.default = undefined;\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _proxyMechanism = __webpack_require__(5);\n\nvar _utils = __webpack_require__(0);\n\nvar _isAvailable = __webpack_require__(1);\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * @private\n *\n * Keeps WebStorage instances by type as singletons.\n *\n * @type {object}\n */\nvar _instances = {};\n\n/**\n * @private\n *\n * Stores the interceptors for WebStorage methods.\n *\n * @type {object}\n */\nvar _interceptors = {\n setItem: [],\n getItem: [],\n removeItem: [],\n clear: []\n};\n\n/**\n * @private\n *\n * Keys not allowed for cookies.\n *\n * @type {RegExp}\n */\nvar bannedKeys = /^(?:expires|max-age|path|domain|secure)$/i;\n\n/**\n * @private\n *\n * Executes the interceptors for a WebStorage method and\n * allows the transformation in chain of the value passed through.\n *\n * @param {string} command: name of the method to intercept\n * @return {any}\n */\nfunction executeInterceptors(command) {\n for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n var key = args.shift();\n var value = args.shift();\n if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {\n // clone the object to prevent mutations\n value = JSON.parse(JSON.stringify(value));\n }\n return _interceptors[command].reduce(function (val, action) {\n var transformed = action.apply(undefined, [key, val].concat(args));\n if (transformed == null) return val;\n return transformed;\n }, value);\n}\n\n/**\n * @private\n *\n * Try to parse a value\n *\n * @param {string} value: the value to parse\n * @return {any}\n */\nfunction tryParse(value) {\n var parsed = void 0;\n try {\n parsed = JSON.parse(value);\n } catch (e) {\n parsed = value;\n }\n return parsed;\n}\n\n/**\n * @private\n *\n * Copies all existing keys in the WebStorage instance.\n *\n * @param {WebStorage} instance: the instance to where copy the keys\n * @param {object} storage: the storage mechanism\n * @return {void}\n */\nfunction copyKeys(instance, storage) {\n Object.keys(storage).forEach(function (key) {\n instance[key] = tryParse(storage[key]);\n });\n}\n\n/**\n * @public\n *\n * Allows to validate if a storage mechanism is valid\n *\n * @type {object}\n */\nvar webStorageSettings = {\n default: null,\n isAvailable: _isAvailable.isAvailable\n};\n\n/**\n * @private\n *\n * Validates if the storage mechanism is available and can be used safely.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {string}\n */\nfunction storageAvailable(storageType) {\n if (webStorageSettings.isAvailable[storageType]) return storageType;\n console.warn(storageType + ' is not available. Falling back to ' + webStorageSettings.default); // eslint-disable-line\n return webStorageSettings.default;\n}\n\n/**\n * @public\n *\n * Implementation of the Web Storage interface.\n * It saves and retrieves values as JSON.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {class}\n */\n\nvar WebStorage = function () {\n\n /**\n * Creates an instance of WebStorage.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n *\n * @memberOf WebStorage\n */\n function WebStorage(storageType) {\n _classCallCheck(this, WebStorage);\n\n if (!Object.prototype.hasOwnProperty.call(_proxyMechanism.proxy, storageType)) {\n throw new Error('Storage type \"' + storageType + '\" is not valid');\n }\n // gets the requested storage mechanism\n var storage = _proxyMechanism.proxy[storageType];\n // if the storage is not available, sets the default\n storageType = storageAvailable(storageType);\n // keeps only one instance by storageType (singleton)\n var cachedInstance = _instances[storageType];\n if (cachedInstance) {\n copyKeys(cachedInstance, storage);\n return cachedInstance;\n }\n (0, _utils.setProperty)(this, '__storage__', storageType);\n // copies all existing keys in the storage mechanism\n copyKeys(this, storage);\n _instances[storageType] = this;\n }\n\n /**\n * Stores a value given a key name.\n *\n * @param {string} key: keyname of the storage\n * @param {any} value: data to save in the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n\n\n _createClass(WebStorage, [{\n key: 'setItem',\n value: function setItem(key, value, options) {\n (0, _utils.checkEmpty)(key);\n var storageType = this.__storage__;\n if (storageType === 'cookieStorage' && bannedKeys.test(key)) {\n throw new Error('The key is a reserved word, therefore not allowed');\n }\n var v = executeInterceptors('setItem', key, value, options);\n if (v !== undefined) value = v;\n this[key] = value;\n // prevents converting strings to JSON to avoid extra quotes\n if (typeof value !== 'string') value = JSON.stringify(value);\n _proxyMechanism.proxy[storageType].setItem(key, value, options);\n // checks if the cookie was created, or delete it if the domain or path are not valid\n if (storageType === 'cookieStorage' && _proxyMechanism.proxy[storageType].getItem(key) === null) {\n delete this[key];\n }\n }\n\n /**\n * Retrieves a value by its key name.\n *\n * @param {string} key: keyname of the storage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n\n }, {\n key: 'getItem',\n value: function getItem(key) {\n (0, _utils.checkEmpty)(key);\n var value = _proxyMechanism.proxy[this.__storage__].getItem(key);\n if (value == null) {\n delete this[key];\n value = null;\n } else {\n value = tryParse(value);\n this[key] = value;\n }\n var v = executeInterceptors('getItem', key, value);\n if (v !== undefined) value = v;\n return value;\n }\n\n /**\n * Deletes a key from the storage.\n *\n * @param {string} key: keyname of the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n\n }, {\n key: 'removeItem',\n value: function removeItem(key, options) {\n (0, _utils.checkEmpty)(key);\n executeInterceptors('removeItem', key, options);\n delete this[key];\n _proxyMechanism.proxy[this.__storage__].removeItem(key, options);\n }\n\n /**\n * Removes all keys from the storage.\n *\n * @return {void}\n *\n * @memberOf WebStorage\n */\n\n }, {\n key: 'clear',\n value: function clear() {\n var _this = this;\n\n executeInterceptors('clear');\n Object.keys(this).forEach(function (key) {\n delete _this[key];\n }, this);\n _proxyMechanism.proxy[this.__storage__].clear();\n }\n\n /**\n * Gets the number of data items stored in the Storage object.\n *\n * @readonly\n *\n * @memberOf WebStorage\n */\n\n }, {\n key: 'length',\n get: function get() {\n return Object.keys(this).length;\n }\n\n /**\n * Adds an interceptor to a WebStorage method.\n *\n * @param {string} command: name of the API method to intercept\n * @param {function} action: callback executed when the API method is called\n * @return {void}\n *\n * @memberOf WebStorage\n */\n\n }], [{\n key: 'interceptors',\n value: function interceptors(command, action) {\n if (command in _interceptors && typeof action === 'function') {\n _interceptors[command].push(action);\n }\n }\n }]);\n\n return WebStorage;\n}();\n\n/**\n * @public API\n */\n\n\nexports.default = WebStorage;\nexports.webStorageSettings = webStorageSettings;\nexports.proxy = _proxyMechanism.proxy;\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = cookieStorage;\n\nvar _utils = __webpack_require__(0);\n\n/**\n * @private\n *\n * Proxy for document.cookie\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie\n *\n * @type {object}\n */\nvar $cookie = {\n get: function get() {\n return document.cookie;\n },\n set: function set(value) {\n document.cookie = value;\n },\n data: {} };\n\n/**\n * @private\n *\n * Builds the expiration for the cookie.\n *\n * @see utils.alterDate(options)\n *\n * @param {Date|object} date: the expiration date\n * @return {string}\n */\nfunction buildExpirationString(date) {\n var expires = date instanceof Date ? (0, _utils.alterDate)({ date: date }) : (0, _utils.alterDate)(date);\n return expires.toUTCString();\n}\n\n/**\n * @private\n *\n * Builds the string for the cookie's metadata.\n *\n * @param {string} key: name of the metadata\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction buildMetadataFor(key, data) {\n if (!data[key]) return '';\n return '; ' + key + '=' + data[key];\n}\n\n/**\n * @private\n *\n * Finds an element in the array.\n *\n * @param {string} cookie: key=value\n * @return {boolean}\n */\nfunction findCookie(cookie) {\n var nameEQ = this.toString();\n // prevent leading spaces before the key\n return cookie.trim().indexOf(nameEQ) === 0;\n}\n\n/**\n * @public\n *\n * Create, read, and delete elements from document.cookie,\n * and implements the Web Storage interface.\n *\n * @return {object}\n */\nfunction cookieStorage() {\n var api = {\n setItem: function setItem(key, value, options) {\n options = Object.assign({ path: '/' }, options);\n // keep track of the metadata associated to the cookie\n $cookie.data[key] = { path: options.path };\n var metadata = $cookie.data[key];\n if ((0, _utils.isObject)(options.expires) || options.expires instanceof Date) {\n metadata.expires = buildExpirationString(options.expires);\n }\n if (options.domain && typeof options.domain === 'string') {\n metadata.domain = options.domain.trim();\n }\n var expires = buildMetadataFor('expires', metadata);\n var domain = buildMetadataFor('domain', metadata);\n var path = buildMetadataFor('path', metadata);\n var cookie = key + '=' + encodeURIComponent(value) + expires + domain + path;\n $cookie.set(cookie);\n },\n getItem: function getItem(key) {\n var value = null;\n var nameEQ = key + '=';\n var cookie = $cookie.get().split(';').find(findCookie, nameEQ);\n if (cookie) {\n // prevent leading spaces before the key name\n value = cookie.trim().substring(nameEQ.length, cookie.length);\n value = decodeURIComponent(value);\n }\n if (value === null) delete $cookie.data[key];\n return value;\n },\n removeItem: function removeItem(key, options) {\n var metadata = Object.assign({}, $cookie.data[key], options);\n metadata.expires = { days: -1 };\n api.setItem(key, '', metadata);\n delete $cookie.data[key];\n },\n clear: function clear() {\n var key = void 0,\n indexEQ = void 0; // eslint-disable-line\n $cookie.get().split(';').forEach(function (cookie) {\n indexEQ = cookie.indexOf('=');\n if (indexEQ > -1) {\n key = cookie.substring(0, indexEQ);\n // prevent leading spaces before the key\n api.removeItem(key.trim());\n }\n });\n },\n initialize: function initialize() {\n // copies all existing elements in the storage\n $cookie.get().split(';').forEach(function (cookie) {\n var index = cookie.indexOf('=');\n var key = cookie.substring(0, index).trim();\n var value = cookie.substring(index + 1).trim();\n if (key) api[key] = decodeURIComponent(value);\n });\n // this method is removed after being invoked\n // because is not part of the Web Storage interface\n delete api.initialize;\n }\n };\n return api;\n}\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nexports.default = memoryStorage;\n/**\n * @private\n *\n * Gets the hashtable-store from the current window.\n *\n * @return {object}\n */\nfunction getStoreFromWindow() {\n // eslint-disable-line\n try {\n var store = JSON.parse(window.self.name);\n if (store && (typeof store === 'undefined' ? 'undefined' : _typeof(store)) === 'object') return store;\n } catch (e) {\n return {};\n }\n}\n\n/**\n * @private\n *\n * Saves the hashtable-store in the current window.\n *\n * @param {object} hashtable: {key,value} pairs stored in memoryStorage\n * @return {void}\n */\nfunction setStoreToWindow(hashtable) {\n var store = JSON.stringify(hashtable);\n window.self.name = store;\n}\n\n/**\n * @public\n *\n * Create, read, and delete elements from memory, and implements\n * the Web Storage interface. It also adds a hack to persist\n * the storage in the session for the current tab (browser).\n *\n * @return {object}\n */\nfunction memoryStorage() {\n var hashtable = getStoreFromWindow();\n var api = {\n setItem: function setItem(key, value) {\n hashtable[key] = value;\n setStoreToWindow(hashtable);\n },\n getItem: function getItem(key) {\n var value = hashtable[key];\n return value === undefined ? null : value;\n },\n removeItem: function removeItem(key) {\n delete hashtable[key];\n setStoreToWindow(hashtable);\n },\n clear: function clear() {\n Object.keys(hashtable).forEach(function (key) {\n return delete hashtable[key];\n });\n setStoreToWindow(hashtable);\n },\n initialize: function initialize() {\n // copies all existing elements in the storage\n Object.assign(api, hashtable);\n // this method is removed after being invoked\n // because is not part of the Web Storage interface\n delete api.initialize;\n }\n };\n return api;\n}\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.proxy = undefined;\n\nvar _cookieStorage = __webpack_require__(3);\n\nvar _cookieStorage2 = _interopRequireDefault(_cookieStorage);\n\nvar _memoryStorage = __webpack_require__(4);\n\nvar _memoryStorage2 = _interopRequireDefault(_memoryStorage);\n\nvar _utils = __webpack_require__(0);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * @private\n *\n * Copy the current items in the storage mechanism.\n *\n * @param {object} api: the storage mechanism to initialize\n * @return {object}\n */\nfunction initApi(api) {\n if (!api.initialize) return api;\n // sets API members to read-only and non-enumerable\n for (var prop in api) {\n // eslint-disable-line\n if (prop !== 'initialize') {\n (0, _utils.setProperty)(api, prop);\n }\n }\n api.initialize();\n return api;\n}\n\n/**\n * @public\n *\n * Proxy for the storage mechanisms.\n * All members implement the Web Storage interface.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {object}\n */\nvar proxy = exports.proxy = {\n localStorage: window.localStorage,\n sessionStorage: window.sessionStorage,\n cookieStorage: initApi((0, _cookieStorage2.default)()),\n memoryStorage: initApi((0, _memoryStorage2.default)())\n};\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.isAvailable = exports.configStorage = exports.WebStorage = exports.default = undefined;\n\nvar _webStorage = __webpack_require__(2);\n\nvar _webStorage2 = _interopRequireDefault(_webStorage);\n\nvar _isAvailable = __webpack_require__(1);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * @public\n *\n * Current storage mechanism.\n *\n * @type {object}\n */\n/**\n * This library uses an adapter that implements the Web Storage interface,\n * which is very useful to deal with the lack of compatibility between\n * document.cookie and localStorage and sessionStorage.\n *\n * It also provides a memoryStorage fallback that stores the data in memory\n * when all of above mechanisms are not available.\n *\n * Author: David Rivera\n * Github: https://github.com/jherax\n * License: \"MIT\"\n *\n * You can fork this project on github:\n * https://github.com/jherax/proxy-storage.git\n */\n\nvar storage = null;\n\n/**\n * @public\n *\n * Get/Set the storage mechanism to use by default.\n *\n * @type {object}\n */\nvar configStorage = {\n get: function get() {\n return storage.__storage__;\n },\n\n\n /**\n * Sets the storage mechanism to use by default.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {void}\n */\n set: function set(storageType) {\n if (!Object.prototype.hasOwnProperty.call(_webStorage.proxy, storageType)) {\n throw new Error('Storage type \"' + storageType + '\" is not valid');\n }\n exports.default = storage = new _webStorage2.default(storageType);\n }\n};\n\n/**\n * @private\n *\n * Checks whether a storage mechanism is available.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {boolean}\n */\nfunction isStorageAvailable(storageType) {\n var storageObj = _webStorage.proxy[storageType];\n var data = '__proxy-storage__';\n try {\n storageObj.setItem(data, data);\n storageObj.removeItem(data);\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * @private\n *\n * Sets the first or default storage available.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {boolean}\n */\nfunction storageAvailable(storageType) {\n if (_isAvailable.isAvailable[storageType]) {\n _webStorage.webStorageSettings.default = storageType;\n configStorage.set(storageType);\n }\n return _isAvailable.isAvailable[storageType];\n}\n\n/**\n * @private\n *\n * Initializes the module.\n *\n * @return {void}\n */\nfunction init() {\n _isAvailable.isAvailable.localStorage = isStorageAvailable('localStorage');\n _isAvailable.isAvailable.sessionStorage = isStorageAvailable('sessionStorage');\n _isAvailable.isAvailable.cookieStorage = isStorageAvailable('cookieStorage');\n _webStorage.webStorageSettings.isAvailable = _isAvailable.isAvailable;\n // sets the default storage mechanism available\n Object.keys(_isAvailable.isAvailable).some(storageAvailable);\n}\n\ninit();\n\n/**\n * @public API\n */\nexports.default = storage;\nexports.WebStorage = _webStorage2.default;\nexports.configStorage = configStorage;\nexports.isAvailable = _isAvailable.isAvailable;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// proxy-storage.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 6);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 4bef309fee7da4d719d8","/**\n * Determines whether a value is a plain object.\n *\n * @param {any} value: the object to test\n * @return {boolean}\n */\nexport function isObject(value) {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * Adds or subtracts date portions to the given date and returns the new date.\n *\n * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2\n *\n * @param {object} options: It contains the date parts to add or remove, and can have the following properties:\n * - {Date} date: if provided, this date will be affected, otherwise the current date will be used.\n * - {number} minutes: minutes to add/subtract\n * - {number} hours: hours to add/subtract\n * - {number} days: days to add/subtract\n * - {number} months: months to add/subtract\n * - {number} years: years to add/subtract\n * @return {Date}\n */\nexport function alterDate(options = {}) {\n const opt = Object.assign({}, options);\n const d = opt.date instanceof Date ? opt.date : new Date();\n if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes);\n if (+opt.hours) d.setHours(d.getHours() + opt.hours);\n if (+opt.days) d.setDate(d.getDate() + opt.days);\n if (+opt.months) d.setMonth(d.getMonth() + opt.months);\n if (+opt.years) d.setFullYear(d.getFullYear() + opt.years);\n return d;\n}\n\n/**\n * Creates a non-enumerable read-only property.\n *\n * @param {object} obj: the object to add the property\n * @param {string} name: the name of the property\n * @param {any} value: the value of the property\n * @return {void}\n */\nexport function setProperty(obj, name, value) {\n const descriptor = {\n configurable: false,\n enumerable: false,\n writable: false,\n };\n if (typeof value !== 'undefined') {\n descriptor.value = value;\n }\n Object.defineProperty(obj, name, descriptor);\n}\n\n/**\n * Validates if the key is not empty.\n * (null, undefined or empty string)\n *\n * @param {string} key: keyname of an element in the storage mechanism\n * @return {void}\n */\nexport function checkEmpty(key) {\n if (key == null || key === '') {\n throw new Error('The key provided can not be empty');\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils.js","/**\n * @public\n *\n * Used to determine which storage mechanisms are available.\n *\n * @type {object}\n */\nexport const isAvailable = {\n localStorage: false,\n sessionStorage: false,\n cookieStorage: false,\n memoryStorage: true, // fallback storage\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/is-available.js","import {proxy} from './proxy-mechanism';\nimport {setProperty, checkEmpty} from './utils';\nimport {isAvailable} from './is-available';\n\n/**\n * @private\n *\n * Keeps WebStorage instances by type as singletons.\n *\n * @type {object}\n */\nconst _instances = {};\n\n/**\n * @private\n *\n * Stores the interceptors for WebStorage methods.\n *\n * @type {object}\n */\nconst _interceptors = {\n setItem: [],\n getItem: [],\n removeItem: [],\n clear: [],\n};\n\n/**\n * @private\n *\n * Keys not allowed for cookies.\n *\n * @type {RegExp}\n */\nconst bannedKeys = /^(?:expires|max-age|path|domain|secure)$/i;\n\n/**\n * @private\n *\n * Executes the interceptors for a WebStorage method and\n * allows the transformation in chain of the value passed through.\n *\n * @param {string} command: name of the method to intercept\n * @return {any}\n */\nfunction executeInterceptors(command, ...args) {\n const key = args.shift();\n let value = args.shift();\n if (value && typeof value === 'object') {\n // clone the object to prevent mutations\n value = JSON.parse(JSON.stringify(value));\n }\n return _interceptors[command].reduce((val, action) => {\n const transformed = action(key, val, ...args);\n if (transformed == null) return val;\n return transformed;\n }, value);\n}\n\n/**\n * @private\n *\n * Try to parse a value\n *\n * @param {string} value: the value to parse\n * @return {any}\n */\nfunction tryParse(value) {\n let parsed;\n try {\n parsed = JSON.parse(value);\n } catch (e) {\n parsed = value;\n }\n return parsed;\n}\n\n/**\n * @private\n *\n * Copies all existing keys in the WebStorage instance.\n *\n * @param {WebStorage} instance: the instance to where copy the keys\n * @param {object} storage: the storage mechanism\n * @return {void}\n */\nfunction copyKeys(instance, storage) {\n Object.keys(storage).forEach((key) => {\n instance[key] = tryParse(storage[key]);\n });\n}\n\n/**\n * @public\n *\n * Allows to validate if a storage mechanism is valid\n *\n * @type {object}\n */\nconst webStorageSettings = {\n default: null,\n isAvailable,\n};\n\n/**\n * @private\n *\n * Validates if the storage mechanism is available and can be used safely.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {string}\n */\nfunction storageAvailable(storageType) {\n if (webStorageSettings.isAvailable[storageType]) return storageType;\n console.warn(`${storageType} is not available. Falling back to ${webStorageSettings.default}`); // eslint-disable-line\n return webStorageSettings.default;\n}\n\n/**\n * @public\n *\n * Implementation of the Web Storage interface.\n * It saves and retrieves values as JSON.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {class}\n */\nclass WebStorage {\n\n /**\n * Creates an instance of WebStorage.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n *\n * @memberOf WebStorage\n */\n constructor(storageType) {\n if (!Object.prototype.hasOwnProperty.call(proxy, storageType)) {\n throw new Error(`Storage type \"${storageType}\" is not valid`);\n }\n // gets the requested storage mechanism\n const storage = proxy[storageType];\n // if the storage is not available, sets the default\n storageType = storageAvailable(storageType);\n // keeps only one instance by storageType (singleton)\n const cachedInstance = _instances[storageType];\n if (cachedInstance) {\n copyKeys(cachedInstance, storage);\n return cachedInstance;\n }\n setProperty(this, '__storage__', storageType);\n // copies all existing keys in the storage mechanism\n copyKeys(this, storage);\n _instances[storageType] = this;\n }\n\n /**\n * Stores a value given a key name.\n *\n * @param {string} key: keyname of the storage\n * @param {any} value: data to save in the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n setItem(key, value, options) {\n checkEmpty(key);\n const storageType = this.__storage__;\n if (storageType === 'cookieStorage' && bannedKeys.test(key)) {\n throw new Error('The key is a reserved word, therefore not allowed');\n }\n const v = executeInterceptors('setItem', key, value, options);\n if (v !== undefined) value = v;\n this[key] = value;\n // prevents converting strings to JSON to avoid extra quotes\n if (typeof value !== 'string') value = JSON.stringify(value);\n proxy[storageType].setItem(key, value, options);\n // checks if the cookie was created, or delete it if the domain or path are not valid\n if (storageType === 'cookieStorage' && proxy[storageType].getItem(key) === null) {\n delete this[key];\n }\n }\n\n /**\n * Retrieves a value by its key name.\n *\n * @param {string} key: keyname of the storage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n getItem(key) {\n checkEmpty(key);\n let value = proxy[this.__storage__].getItem(key);\n if (value == null) {\n delete this[key];\n value = null;\n } else {\n value = tryParse(value);\n this[key] = value;\n }\n const v = executeInterceptors('getItem', key, value);\n if (v !== undefined) value = v;\n return value;\n }\n\n /**\n * Deletes a key from the storage.\n *\n * @param {string} key: keyname of the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n removeItem(key, options) {\n checkEmpty(key);\n executeInterceptors('removeItem', key, options);\n delete this[key];\n proxy[this.__storage__].removeItem(key, options);\n }\n\n /**\n * Removes all keys from the storage.\n *\n * @return {void}\n *\n * @memberOf WebStorage\n */\n clear() {\n executeInterceptors('clear');\n Object.keys(this).forEach((key) => {\n delete this[key];\n }, this);\n proxy[this.__storage__].clear();\n }\n\n /**\n * Gets the number of data items stored in the Storage object.\n *\n * @readonly\n *\n * @memberOf WebStorage\n */\n get length() {\n return Object.keys(this).length;\n }\n\n /**\n * Adds an interceptor to a WebStorage method.\n *\n * @param {string} command: name of the API method to intercept\n * @param {function} action: callback executed when the API method is called\n * @return {void}\n *\n * @memberOf WebStorage\n */\n static interceptors(command, action) {\n if (command in _interceptors && typeof action === 'function') {\n _interceptors[command].push(action);\n }\n }\n}\n\n/**\n * @public API\n */\nexport {WebStorage as default, webStorageSettings, proxy};\n\n\n\n// WEBPACK FOOTER //\n// ./src/web-storage.js","import {alterDate, isObject} from './utils';\n\n/**\n * @private\n *\n * Proxy for document.cookie\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie\n *\n * @type {object}\n */\nconst $cookie = {\n get: () => document.cookie,\n set: (value) => {\n document.cookie = value;\n },\n data: {}, // metadata associated to the cookies\n};\n\n/**\n * @private\n *\n * Builds the expiration for the cookie.\n *\n * @see utils.alterDate(options)\n *\n * @param {Date|object} date: the expiration date\n * @return {string}\n */\nfunction buildExpirationString(date) {\n const expires = (date instanceof Date ?\n alterDate({date}) :\n alterDate(date)\n );\n return expires.toUTCString();\n}\n\n/**\n * @private\n *\n * Builds the string for the cookie's metadata.\n *\n * @param {string} key: name of the metadata\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction buildMetadataFor(key, data) {\n if (!data[key]) return '';\n return `; ${key}=${data[key]}`;\n}\n\n/**\n * @private\n *\n * Finds an element in the array.\n *\n * @param {string} cookie: key=value\n * @return {boolean}\n */\nfunction findCookie(cookie) {\n const nameEQ = this.toString();\n // prevent leading spaces before the key\n return cookie.trim().indexOf(nameEQ) === 0;\n}\n\n/**\n * @public\n *\n * Create, read, and delete elements from document.cookie,\n * and implements the Web Storage interface.\n *\n * @return {object}\n */\nexport default function cookieStorage() {\n const api = {\n\n setItem(key, value, options) {\n options = Object.assign({path: '/'}, options);\n // keep track of the metadata associated to the cookie\n $cookie.data[key] = {path: options.path};\n const metadata = $cookie.data[key];\n if (isObject(options.expires) || options.expires instanceof Date) {\n metadata.expires = buildExpirationString(options.expires);\n }\n if (options.domain && typeof options.domain === 'string') {\n metadata.domain = options.domain.trim();\n }\n const expires = buildMetadataFor('expires', metadata);\n const domain = buildMetadataFor('domain', metadata);\n const path = buildMetadataFor('path', metadata);\n const cookie = `${key}=${encodeURIComponent(value)}${expires}${domain}${path}`;\n $cookie.set(cookie);\n },\n\n getItem(key) {\n let value = null;\n const nameEQ = `${key}=`;\n const cookie = $cookie.get().split(';').find(findCookie, nameEQ);\n if (cookie) {\n // prevent leading spaces before the key name\n value = cookie.trim().substring(nameEQ.length, cookie.length);\n value = decodeURIComponent(value);\n }\n if (value === null) delete $cookie.data[key];\n return value;\n },\n\n removeItem(key, options) {\n const metadata = Object.assign({}, $cookie.data[key], options);\n metadata.expires = {days: -1};\n api.setItem(key, '', metadata);\n delete $cookie.data[key];\n },\n\n clear() {\n let key, indexEQ; // eslint-disable-line\n $cookie.get().split(';').forEach((cookie) => {\n indexEQ = cookie.indexOf('=');\n if (indexEQ > -1) {\n key = cookie.substring(0, indexEQ);\n // prevent leading spaces before the key\n api.removeItem(key.trim());\n }\n });\n },\n\n initialize() {\n // copies all existing elements in the storage\n $cookie.get().split(';').forEach((cookie) => {\n const index = cookie.indexOf('=');\n const key = cookie.substring(0, index).trim();\n const value = cookie.substring(index + 1).trim();\n if (key) api[key] = decodeURIComponent(value);\n });\n // this method is removed after being invoked\n // because is not part of the Web Storage interface\n delete api.initialize;\n },\n };\n return api;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/cookie-storage.js","/**\n * @private\n *\n * Gets the hashtable-store from the current window.\n *\n * @return {object}\n */\nfunction getStoreFromWindow() { // eslint-disable-line\n try {\n const store = JSON.parse(window.self.name);\n if (store && typeof store === 'object') return store;\n } catch (e) {\n return {};\n }\n}\n\n/**\n * @private\n *\n * Saves the hashtable-store in the current window.\n *\n * @param {object} hashtable: {key,value} pairs stored in memoryStorage\n * @return {void}\n */\nfunction setStoreToWindow(hashtable) {\n const store = JSON.stringify(hashtable);\n window.self.name = store;\n}\n\n/**\n * @public\n *\n * Create, read, and delete elements from memory, and implements\n * the Web Storage interface. It also adds a hack to persist\n * the storage in the session for the current tab (browser).\n *\n * @return {object}\n */\nexport default function memoryStorage() {\n const hashtable = getStoreFromWindow();\n const api = {\n\n setItem(key, value) {\n hashtable[key] = value;\n setStoreToWindow(hashtable);\n },\n\n getItem(key) {\n const value = hashtable[key];\n return value === undefined ? null : value;\n },\n\n removeItem(key) {\n delete hashtable[key];\n setStoreToWindow(hashtable);\n },\n\n clear() {\n Object.keys(hashtable).forEach(key => delete hashtable[key]);\n setStoreToWindow(hashtable);\n },\n\n initialize() {\n // copies all existing elements in the storage\n Object.assign(api, hashtable);\n // this method is removed after being invoked\n // because is not part of the Web Storage interface\n delete api.initialize;\n },\n };\n return api;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/memory-storage.js","import cookieStorage from './cookie-storage';\nimport memoryStorage from './memory-storage';\nimport {setProperty} from './utils';\n\n/**\n * @private\n *\n * Copy the current items in the storage mechanism.\n *\n * @param {object} api: the storage mechanism to initialize\n * @return {object}\n */\nfunction initApi(api) {\n if (!api.initialize) return api;\n // sets API members to read-only and non-enumerable\n for (let prop in api) { // eslint-disable-line\n if (prop !== 'initialize') {\n setProperty(api, prop);\n }\n }\n api.initialize();\n return api;\n}\n\n/**\n * @public\n *\n * Proxy for the storage mechanisms.\n * All members implement the Web Storage interface.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {object}\n */\nexport const proxy = {\n localStorage: window.localStorage,\n sessionStorage: window.sessionStorage,\n cookieStorage: initApi(cookieStorage()),\n memoryStorage: initApi(memoryStorage()),\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/proxy-mechanism.js","/**\n * This library uses an adapter that implements the Web Storage interface,\n * which is very useful to deal with the lack of compatibility between\n * document.cookie and localStorage and sessionStorage.\n *\n * It also provides a memoryStorage fallback that stores the data in memory\n * when all of above mechanisms are not available.\n *\n * Author: David Rivera\n * Github: https://github.com/jherax\n * License: \"MIT\"\n *\n * You can fork this project on github:\n * https://github.com/jherax/proxy-storage.git\n */\n\nimport WebStorage, {proxy, webStorageSettings} from './web-storage';\nimport {isAvailable} from './is-available';\n\n/**\n * @public\n *\n * Current storage mechanism.\n *\n * @type {object}\n */\nlet storage = null;\n\n/**\n * @public\n *\n * Get/Set the storage mechanism to use by default.\n *\n * @type {object}\n */\nconst configStorage = {\n get() {\n return storage.__storage__;\n },\n\n /**\n * Sets the storage mechanism to use by default.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {void}\n */\n set(storageType) {\n if (!Object.prototype.hasOwnProperty.call(proxy, storageType)) {\n throw new Error(`Storage type \"${storageType}\" is not valid`);\n }\n storage = new WebStorage(storageType);\n },\n};\n\n/**\n * @private\n *\n * Checks whether a storage mechanism is available.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {boolean}\n */\nfunction isStorageAvailable(storageType) {\n const storageObj = proxy[storageType];\n const data = '__proxy-storage__';\n try {\n storageObj.setItem(data, data);\n storageObj.removeItem(data);\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * @private\n *\n * Sets the first or default storage available.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {boolean}\n */\nfunction storageAvailable(storageType) {\n if (isAvailable[storageType]) {\n webStorageSettings.default = storageType;\n configStorage.set(storageType);\n }\n return isAvailable[storageType];\n}\n\n/**\n * @private\n *\n * Initializes the module.\n *\n * @return {void}\n */\nfunction init() {\n isAvailable.localStorage = isStorageAvailable('localStorage');\n isAvailable.sessionStorage = isStorageAvailable('sessionStorage');\n isAvailable.cookieStorage = isStorageAvailable('cookieStorage');\n webStorageSettings.isAvailable = isAvailable;\n // sets the default storage mechanism available\n Object.keys(isAvailable).some(storageAvailable);\n}\n\ninit();\n\n/**\n * @public API\n */\nexport {storage as default, WebStorage, configStorage, isAvailable};\n\n\n\n// WEBPACK FOOTER //\n// ./src/proxy-storage.js"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///proxy-storage.min.js","webpack:///webpack/bootstrap bfb2c265a05630000505","webpack:///./src/utils.js","webpack:///./src/is-available.js","webpack:///./src/web-storage.js","webpack:///./src/cookie-storage.js","webpack:///./src/memory-storage.js","webpack:///./src/proxy-mechanism.js","webpack:///./src/proxy-storage.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","value","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","isObject","toString","alterDate","options","arguments","length","undefined","opt","assign","date","Date","minutes","setMinutes","getMinutes","hours","setHours","getHours","days","setDate","getDate","months","setMonth","getMonth","years","setFullYear","getFullYear","setProperty","obj","descriptor","writable","checkEmpty","key","Error","isAvailable","localStorage","sessionStorage","cookieStorage","memoryStorage","_classCallCheck","instance","Constructor","TypeError","executeInterceptors","command","_len","args","Array","_key","shift","_typeof","JSON","parse","stringify","_interceptors","reduce","val","action","transformed","concat","tryParse","parsed","e","copyKeys","storage","keys","forEach","storageAvailable","storageType","webStorageSettings","console","warn","default","proxy","_createClass","defineProperties","target","props","protoProps","staticProps","Symbol","iterator","constructor","_proxyMechanism","_utils","_isAvailable","_instances","setItem","getItem","removeItem","clear","bannedKeys","WebStorage","cachedInstance","__storage__","test","v","_this","push","buildExpirationString","expires","toUTCString","buildMetadataFor","data","formatMetadata","domain","path","secure","findCookie","cookie","nameEQ","trim","indexOf","api","$cookie","metadata","encodeURIComponent","set","split","find","substring","decodeURIComponent","indexEQ","initialize","index","document","getStoreFromWindow","store","window","self","setStoreToWindow","hashtable","_interopRequireDefault","initApi","prop","_cookieStorage","_cookieStorage2","_memoryStorage","_memoryStorage2","isStorageAvailable","storageObj","_webStorage","configStorage","init","some","_webStorage2"],"mappings":";CAAA,SAAAA,EAAAC,GACA,gBAAAC,UAAA,gBAAAC,QACAA,OAAAD,QAAAD,IACA,kBAAAG,gBAAAC,IACAD,UAAAH,GACA,gBAAAC,SACAA,QAAA,aAAAD,IAEAD,EAAA,aAAAC,KACCK,KAAA,WACD,MCAgB,UAAUC,GCN1B,QAAAC,GAAAC,GAGA,GAAAC,EAAAD,GACA,MAAAC,GAAAD,GAAAP,OAGA,IAAAC,GAAAO,EAAAD,IACAE,EAAAF,EACAG,GAAA,EACAV,WAUA,OANAK,GAAAE,GAAAI,KAAAV,EAAAD,QAAAC,IAAAD,QAAAM,GAGAL,EAAAS,GAAA,EAGAT,EAAAD,QAvBA,GAAAQ,KA+DA,OAnCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAG,EAAA,SAAAK,GAA2C,MAAAA,IAG3CR,EAAAS,EAAA,SAAAf,EAAAgB,EAAAC,GACAX,EAAAY,EAAAlB,EAAAgB,IACAG,OAAAC,eAAApB,EAAAgB,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAX,EAAAkB,EAAA,SAAAvB,GACA,GAAAgB,GAAAhB,KAAAwB,WACA,WAA2B,MAAAxB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAK,GAAAS,EAAAE,EAAA,IAAAA,GACAA,GAIAX,EAAAY,EAAA,SAAAQ,EAAAC,GAAsD,MAAAR,QAAAS,UAAAC,eAAAlB,KAAAe,EAAAC,IAGtDrB,EAAAwB,EAAA,GAGAxB,IAAAyB,EAAA,KDgBM,SAAU9B,EAAQD,EAASM,GAEjC,YE5EO,SAAS0B,GAASlB,GACvB,MAAiD,oBAA1CK,OAAOS,UAAUK,SAAStB,KAAKG,GAiBjC,QAASoB,KAAwB,GAAdC,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4C,QAAS5C,GQ5wBvF,QAAS+G,GAAmBvE,GAC1B,GAAMwE,GAAaC,EAAApE,MAAML,GACnBmC,EAAO,mBACb,KAGE,MAFAqC,GAAWrD,QAAQgB,EAAMA,GACzBqC,EAAWnD,WAAWc,IACf,EACP,MAAOzC,GACP,OAAO,GAYX,QAASK,GAAiBC,GAKxB,MAJIiB,GAAAnD,YAAYkC,KACdyE,EAAAxE,mBAAmBG,QAAUJ,EAC7B0E,EAAczB,IAAIjD,IAEbiB,EAAAnD,YAAYkC,GAUrB,QAAS2E,KACP1D,EAAAnD,YAAYC,aAAewG,EAAmB,gBAC9CtD,EAAAnD,YAAYE,eAAiBuG,EAAmB,kBAChDtD,EAAAnD,YAAYG,cAAgBsG,EAAmB,iBAC/CE,EAAAxE,mBAAmBnC,YAAnBmD,EAAAnD,YAEA9C,OAAO6E,KAAPoB,EAAAnD,aAAyB8G,KAAK7E,GRwtBhC/E,OAAOC,eAAepB,EAAS,cAC7Bc,OAAO,IAETd,EAAQiE,YAAcjE,EAAQ6K,cAAgB7K,EAAQ2H,WAAa3H,EAAQuG,QAAUjE,MQlzBrF,IAAAsI,GAAAtK,EAAA,GRszBI0K,EAAeb,EAAuBS,GQrzB1CxD,EAAA9G,EAAA,GASIyF,EAAU,KASR8E,GACJtJ,IADoB,WAElB,MAAOwE,GAAQ8B,aASjBuB,IAXoB,SAWhBjD,GACF,IAAKhF,OAAOS,UAAUC,eAAelB,KAAhCiK,EAAApE,MAA4CL,GAC/C,KAAM,IAAInC,OAAJ,iBAA2BmC,EAA3B,iBAERnG,GA6DeuG,QA7DfR,EAAU,GAAAiF,GAAAzE,QAAeJ,IAwD7B2E,KR+0BA9K,EQ10BmBuG,QAAXR,ER20BR/F,EQ30B4B2H,WR20BPqD,EAAazE,QAClCvG,EQ50BwC6K,gBR60BxC7K,EQ70BuDiE,YR60BjCmD,EAAanD","file":"proxy-storage.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"proxyStorage\"] = factory();\n\telse\n\t\troot[\"proxyStorage\"] = factory();\n})(this, function() {\nreturn \n\n\n// WEBPACK FOOTER //\n// webpack/universalModuleDefinition","(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"proxyStorage\"] = factory();\n\telse\n\t\troot[\"proxyStorage\"] = factory();\n})(this, function() {\nreturn /******/ (function(modules) { // webpackBootstrap\n/******/ \t// The module cache\n/******/ \tvar installedModules = {};\n/******/\n/******/ \t// The require function\n/******/ \tfunction __webpack_require__(moduleId) {\n/******/\n/******/ \t\t// Check if module is in cache\n/******/ \t\tif(installedModules[moduleId])\n/******/ \t\t\treturn installedModules[moduleId].exports;\n/******/\n/******/ \t\t// Create a new module (and put it into the cache)\n/******/ \t\tvar module = installedModules[moduleId] = {\n/******/ \t\t\ti: moduleId,\n/******/ \t\t\tl: false,\n/******/ \t\t\texports: {}\n/******/ \t\t};\n/******/\n/******/ \t\t// Execute the module function\n/******/ \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n/******/\n/******/ \t\t// Flag the module as loaded\n/******/ \t\tmodule.l = true;\n/******/\n/******/ \t\t// Return the exports of the module\n/******/ \t\treturn module.exports;\n/******/ \t}\n/******/\n/******/\n/******/ \t// expose the modules object (__webpack_modules__)\n/******/ \t__webpack_require__.m = modules;\n/******/\n/******/ \t// expose the module cache\n/******/ \t__webpack_require__.c = installedModules;\n/******/\n/******/ \t// identity function for calling harmony imports with the correct context\n/******/ \t__webpack_require__.i = function(value) { return value; };\n/******/\n/******/ \t// define getter function for harmony exports\n/******/ \t__webpack_require__.d = function(exports, name, getter) {\n/******/ \t\tif(!__webpack_require__.o(exports, name)) {\n/******/ \t\t\tObject.defineProperty(exports, name, {\n/******/ \t\t\t\tconfigurable: false,\n/******/ \t\t\t\tenumerable: true,\n/******/ \t\t\t\tget: getter\n/******/ \t\t\t});\n/******/ \t\t}\n/******/ \t};\n/******/\n/******/ \t// getDefaultExport function for compatibility with non-harmony modules\n/******/ \t__webpack_require__.n = function(module) {\n/******/ \t\tvar getter = module && module.__esModule ?\n/******/ \t\t\tfunction getDefault() { return module['default']; } :\n/******/ \t\t\tfunction getModuleExports() { return module; };\n/******/ \t\t__webpack_require__.d(getter, 'a', getter);\n/******/ \t\treturn getter;\n/******/ \t};\n/******/\n/******/ \t// Object.prototype.hasOwnProperty.call\n/******/ \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n/******/\n/******/ \t// __webpack_public_path__\n/******/ \t__webpack_require__.p = \"\";\n/******/\n/******/ \t// Load entry module and return exports\n/******/ \treturn __webpack_require__(__webpack_require__.s = 6);\n/******/ })\n/************************************************************************/\n/******/ ([\n/* 0 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.isObject = isObject;\nexports.alterDate = alterDate;\nexports.setProperty = setProperty;\nexports.checkEmpty = checkEmpty;\n/**\n * Determines whether a value is a plain object.\n *\n * @param {any} value: the object to test\n * @return {boolean}\n */\nfunction isObject(value) {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * Adds or subtracts date portions to the given date and returns the new date.\n *\n * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2\n *\n * @param {object} options: It contains the date parts to add or remove, and can have the following properties:\n * - {Date} date: if provided, this date will be affected, otherwise the current date will be used.\n * - {number} minutes: minutes to add/subtract\n * - {number} hours: hours to add/subtract\n * - {number} days: days to add/subtract\n * - {number} months: months to add/subtract\n * - {number} years: years to add/subtract\n * @return {Date}\n */\nfunction alterDate() {\n var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n var opt = Object.assign({}, options);\n var d = opt.date instanceof Date ? opt.date : new Date();\n if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes);\n if (+opt.hours) d.setHours(d.getHours() + opt.hours);\n if (+opt.days) d.setDate(d.getDate() + opt.days);\n if (+opt.months) d.setMonth(d.getMonth() + opt.months);\n if (+opt.years) d.setFullYear(d.getFullYear() + opt.years);\n return d;\n}\n\n/**\n * Creates a non-enumerable read-only property.\n *\n * @param {object} obj: the object to add the property\n * @param {string} name: the name of the property\n * @param {any} value: the value of the property\n * @return {void}\n */\nfunction setProperty(obj, name, value) {\n var descriptor = {\n configurable: false,\n enumerable: false,\n writable: false\n };\n if (typeof value !== 'undefined') {\n descriptor.value = value;\n }\n Object.defineProperty(obj, name, descriptor);\n}\n\n/**\n * Validates if the key is not empty.\n * (null, undefined or empty string)\n *\n * @param {string} key: keyname of an element in the storage mechanism\n * @return {void}\n */\nfunction checkEmpty(key) {\n if (key == null || key === '') {\n throw new Error('The key provided can not be empty');\n }\n}\n\n/***/ }),\n/* 1 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n/**\n * @public\n *\n * Used to determine which storage mechanisms are available.\n *\n * @type {object}\n */\nvar isAvailable = exports.isAvailable = {\n localStorage: false,\n sessionStorage: false,\n cookieStorage: false,\n memoryStorage: true };\n\n/***/ }),\n/* 2 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.proxy = exports.webStorageSettings = exports.default = undefined;\n\nvar _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if (\"value\" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nvar _proxyMechanism = __webpack_require__(5);\n\nvar _utils = __webpack_require__(0);\n\nvar _isAvailable = __webpack_require__(1);\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * @private\n *\n * Keeps WebStorage instances by type as singletons.\n *\n * @type {object}\n */\nvar _instances = {};\n\n/**\n * @private\n *\n * Stores the interceptors for WebStorage methods.\n *\n * @type {object}\n */\nvar _interceptors = {\n setItem: [],\n getItem: [],\n removeItem: [],\n clear: []\n};\n\n/**\n * @private\n *\n * Keys not allowed for cookies.\n *\n * @type {RegExp}\n */\nvar bannedKeys = /^(?:expires|max-age|path|domain|secure)$/i;\n\n/**\n * @private\n *\n * Executes the interceptors for a WebStorage method and\n * allows the transformation in chain of the value passed through.\n *\n * @param {string} command: name of the method to intercept\n * @return {any}\n */\nfunction executeInterceptors(command) {\n for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {\n args[_key - 1] = arguments[_key];\n }\n\n var key = args.shift();\n var value = args.shift();\n if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') {\n // clone the object to prevent mutations\n value = JSON.parse(JSON.stringify(value));\n }\n return _interceptors[command].reduce(function (val, action) {\n var transformed = action.apply(undefined, [key, val].concat(args));\n if (transformed == null) return val;\n return transformed;\n }, value);\n}\n\n/**\n * @private\n *\n * Try to parse a value\n *\n * @param {string} value: the value to parse\n * @return {any}\n */\nfunction tryParse(value) {\n var parsed = void 0;\n try {\n parsed = JSON.parse(value);\n } catch (e) {\n parsed = value;\n }\n return parsed;\n}\n\n/**\n * @private\n *\n * Copies all existing keys in the WebStorage instance.\n *\n * @param {WebStorage} instance: the instance to where copy the keys\n * @param {object} storage: the storage mechanism\n * @return {void}\n */\nfunction copyKeys(instance, storage) {\n Object.keys(storage).forEach(function (key) {\n instance[key] = tryParse(storage[key]);\n });\n}\n\n/**\n * @public\n *\n * Allows to validate if a storage mechanism is valid\n *\n * @type {object}\n */\nvar webStorageSettings = {\n default: null,\n isAvailable: _isAvailable.isAvailable\n};\n\n/**\n * @private\n *\n * Validates if the storage mechanism is available and can be used safely.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {string}\n */\nfunction storageAvailable(storageType) {\n if (webStorageSettings.isAvailable[storageType]) return storageType;\n console.warn(storageType + ' is not available. Falling back to ' + webStorageSettings.default); // eslint-disable-line\n return webStorageSettings.default;\n}\n\n/**\n * @public\n *\n * Implementation of the Web Storage interface.\n * It saves and retrieves values as JSON.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {class}\n */\n\nvar WebStorage = function () {\n\n /**\n * Creates an instance of WebStorage.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n *\n * @memberOf WebStorage\n */\n function WebStorage(storageType) {\n _classCallCheck(this, WebStorage);\n\n if (!Object.prototype.hasOwnProperty.call(_proxyMechanism.proxy, storageType)) {\n throw new Error('Storage type \"' + storageType + '\" is not valid');\n }\n // gets the requested storage mechanism\n var storage = _proxyMechanism.proxy[storageType];\n // if the storage is not available, sets the default\n storageType = storageAvailable(storageType);\n // keeps only one instance by storageType (singleton)\n var cachedInstance = _instances[storageType];\n if (cachedInstance) {\n copyKeys(cachedInstance, storage);\n return cachedInstance;\n }\n (0, _utils.setProperty)(this, '__storage__', storageType);\n // copies all existing keys in the storage mechanism\n copyKeys(this, storage);\n _instances[storageType] = this;\n }\n\n /**\n * Stores a value given a key name.\n *\n * @param {string} key: keyname of the storage\n * @param {any} value: data to save in the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n\n\n _createClass(WebStorage, [{\n key: 'setItem',\n value: function setItem(key, value, options) {\n (0, _utils.checkEmpty)(key);\n var storageType = this.__storage__;\n if (storageType === 'cookieStorage' && bannedKeys.test(key)) {\n throw new Error('The key is a reserved word, therefore not allowed');\n }\n var v = executeInterceptors('setItem', key, value, options);\n if (v !== undefined) value = v;\n this[key] = value;\n // prevents converting strings to JSON to avoid extra quotes\n if (typeof value !== 'string') value = JSON.stringify(value);\n _proxyMechanism.proxy[storageType].setItem(key, value, options);\n // checks if the cookie was created, or delete it if the domain or path are not valid\n if (storageType === 'cookieStorage' && _proxyMechanism.proxy[storageType].getItem(key) === null) {\n delete this[key];\n }\n }\n\n /**\n * Retrieves a value by its key name.\n *\n * @param {string} key: keyname of the storage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n\n }, {\n key: 'getItem',\n value: function getItem(key) {\n (0, _utils.checkEmpty)(key);\n var value = _proxyMechanism.proxy[this.__storage__].getItem(key);\n if (value == null) {\n delete this[key];\n value = null;\n } else {\n value = tryParse(value);\n this[key] = value;\n }\n var v = executeInterceptors('getItem', key, value);\n if (v !== undefined) value = v;\n return value;\n }\n\n /**\n * Deletes a key from the storage.\n *\n * @param {string} key: keyname of the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n\n }, {\n key: 'removeItem',\n value: function removeItem(key, options) {\n (0, _utils.checkEmpty)(key);\n executeInterceptors('removeItem', key, options);\n delete this[key];\n _proxyMechanism.proxy[this.__storage__].removeItem(key, options);\n }\n\n /**\n * Removes all keys from the storage.\n *\n * @return {void}\n *\n * @memberOf WebStorage\n */\n\n }, {\n key: 'clear',\n value: function clear() {\n var _this = this;\n\n executeInterceptors('clear');\n Object.keys(this).forEach(function (key) {\n delete _this[key];\n }, this);\n _proxyMechanism.proxy[this.__storage__].clear();\n }\n\n /**\n * Gets the number of data items stored in the Storage object.\n *\n * @readonly\n *\n * @memberOf WebStorage\n */\n\n }, {\n key: 'length',\n get: function get() {\n return Object.keys(this).length;\n }\n\n /**\n * Adds an interceptor to a WebStorage method.\n *\n * @param {string} command: name of the API method to intercept\n * @param {function} action: callback executed when the API method is called\n * @return {void}\n *\n * @memberOf WebStorage\n */\n\n }], [{\n key: 'interceptors',\n value: function interceptors(command, action) {\n if (command in _interceptors && typeof action === 'function') {\n _interceptors[command].push(action);\n }\n }\n }]);\n\n return WebStorage;\n}();\n\n/**\n * @public API\n */\n\n\nexports.default = WebStorage;\nexports.webStorageSettings = webStorageSettings;\nexports.proxy = _proxyMechanism.proxy;\n\n/***/ }),\n/* 3 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = cookieStorage;\n\nvar _utils = __webpack_require__(0);\n\n/**\n * @private\n *\n * Proxy for document.cookie\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie\n *\n * @type {object}\n */\nvar $cookie = {\n get: function get() {\n return document.cookie;\n },\n set: function set(value) {\n document.cookie = value;\n },\n data: {} };\n\n/**\n * @private\n *\n * Builds the expiration for the cookie.\n *\n * @see utils.alterDate(options)\n *\n * @param {Date|object} date: the expiration date\n * @return {string}\n */\nfunction buildExpirationString(date) {\n var expires = date instanceof Date ? (0, _utils.alterDate)({ date: date }) : (0, _utils.alterDate)(date);\n return expires.toUTCString();\n}\n\n/**\n * @private\n *\n * Builds the string for the cookie metadata.\n *\n * @param {string} key: name of the metadata\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction buildMetadataFor(key, data) {\n if (!data[key]) return '';\n return ';' + key + '=' + data[key];\n}\n\n/**\n * @private\n *\n * Builds the whole string for the cookie metadata.\n *\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction formatMetadata(data) {\n var expires = buildMetadataFor('expires', data);\n var domain = buildMetadataFor('domain', data);\n var path = buildMetadataFor('path', data);\n var secure = data.secure ? ';secure' : '';\n return '' + expires + domain + path + secure;\n}\n\n/**\n * @private\n *\n * Finds an element in the array.\n *\n * @param {string} cookie: key=value\n * @return {boolean}\n */\nfunction findCookie(cookie) {\n var nameEQ = this.toString();\n // prevent leading spaces before the key\n return cookie.trim().indexOf(nameEQ) === 0;\n}\n\n/**\n * @public\n *\n * Create, read, and delete elements from document.cookie,\n * and implements the Web Storage interface.\n *\n * @return {object}\n */\nfunction cookieStorage() {\n var api = {\n setItem: function setItem(key, value, options) {\n options = Object.assign({ path: '/' }, options);\n // keep track of the metadata associated to the cookie\n $cookie.data[key] = { path: options.path };\n var metadata = $cookie.data[key];\n if ((0, _utils.isObject)(options.expires) || options.expires instanceof Date) {\n metadata.expires = buildExpirationString(options.expires);\n }\n if (options.domain && typeof options.domain === 'string') {\n metadata.domain = options.domain.trim();\n }\n if (options.secure === true) metadata.secure = true;\n var cookie = key + '=' + encodeURIComponent(value) + formatMetadata(metadata);\n // TODO: should encodeURIComponent(key) ?\n $cookie.set(cookie);\n },\n getItem: function getItem(key) {\n var value = null;\n var nameEQ = key + '=';\n var cookie = $cookie.get().split(';').find(findCookie, nameEQ);\n if (cookie) {\n // prevent leading spaces before the key name\n value = cookie.trim().substring(nameEQ.length, cookie.length);\n value = decodeURIComponent(value);\n }\n if (value === null) delete $cookie.data[key];\n return value;\n },\n removeItem: function removeItem(key, options) {\n var metadata = Object.assign({}, $cookie.data[key], options);\n metadata.expires = { days: -1 };\n api.setItem(key, '', metadata);\n delete $cookie.data[key];\n },\n clear: function clear() {\n var key = void 0,\n indexEQ = void 0; // eslint-disable-line\n $cookie.get().split(';').forEach(function (cookie) {\n indexEQ = cookie.indexOf('=');\n if (indexEQ > -1) {\n key = cookie.substring(0, indexEQ);\n // prevent leading spaces before the key\n api.removeItem(key.trim());\n }\n });\n },\n initialize: function initialize() {\n // copies all existing elements in the storage\n $cookie.get().split(';').forEach(function (cookie) {\n var index = cookie.indexOf('=');\n var key = cookie.substring(0, index).trim();\n var value = cookie.substring(index + 1).trim();\n if (key) api[key] = decodeURIComponent(value);\n });\n // this method is removed after being invoked\n // because is not part of the Web Storage interface\n delete api.initialize;\n }\n };\n return api;\n}\n\n/***/ }),\n/* 4 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\n\nvar _typeof = typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; };\n\nexports.default = memoryStorage;\n/**\n * @private\n *\n * Gets the hashtable-store from the current window.\n *\n * @return {object}\n */\nfunction getStoreFromWindow() {\n // eslint-disable-line\n try {\n var store = JSON.parse(window.self.name);\n if (store && (typeof store === 'undefined' ? 'undefined' : _typeof(store)) === 'object') return store;\n } catch (e) {\n return {};\n }\n}\n\n/**\n * @private\n *\n * Saves the hashtable-store in the current window.\n *\n * @param {object} hashtable: {key,value} pairs stored in memoryStorage\n * @return {void}\n */\nfunction setStoreToWindow(hashtable) {\n var store = JSON.stringify(hashtable);\n window.self.name = store;\n}\n\n/**\n * @public\n *\n * Create, read, and delete elements from memory, and implements\n * the Web Storage interface. It also adds a hack to persist\n * the storage in the session for the current tab (browser).\n *\n * @return {object}\n */\nfunction memoryStorage() {\n var hashtable = getStoreFromWindow();\n var api = {\n setItem: function setItem(key, value) {\n hashtable[key] = value;\n setStoreToWindow(hashtable);\n },\n getItem: function getItem(key) {\n var value = hashtable[key];\n return value === undefined ? null : value;\n },\n removeItem: function removeItem(key) {\n delete hashtable[key];\n setStoreToWindow(hashtable);\n },\n clear: function clear() {\n Object.keys(hashtable).forEach(function (key) {\n return delete hashtable[key];\n });\n setStoreToWindow(hashtable);\n },\n initialize: function initialize() {\n // copies all existing elements in the storage\n Object.assign(api, hashtable);\n // this method is removed after being invoked\n // because is not part of the Web Storage interface\n delete api.initialize;\n }\n };\n return api;\n}\n\n/***/ }),\n/* 5 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.proxy = undefined;\n\nvar _cookieStorage = __webpack_require__(3);\n\nvar _cookieStorage2 = _interopRequireDefault(_cookieStorage);\n\nvar _memoryStorage = __webpack_require__(4);\n\nvar _memoryStorage2 = _interopRequireDefault(_memoryStorage);\n\nvar _utils = __webpack_require__(0);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * @private\n *\n * Copy the current items in the storage mechanism.\n *\n * @param {object} api: the storage mechanism to initialize\n * @return {object}\n */\nfunction initApi(api) {\n if (!api.initialize) return api;\n // sets API members to read-only and non-enumerable\n for (var prop in api) {\n // eslint-disable-line\n if (prop !== 'initialize') {\n (0, _utils.setProperty)(api, prop);\n }\n }\n api.initialize();\n return api;\n}\n\n/**\n * @public\n *\n * Proxy for the storage mechanisms.\n * All members implement the Web Storage interface.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {object}\n */\nvar proxy = exports.proxy = {\n localStorage: window.localStorage,\n sessionStorage: window.sessionStorage,\n cookieStorage: initApi((0, _cookieStorage2.default)()),\n memoryStorage: initApi((0, _memoryStorage2.default)())\n};\n\n/***/ }),\n/* 6 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.isAvailable = exports.configStorage = exports.WebStorage = exports.default = undefined;\n\nvar _webStorage = __webpack_require__(2);\n\nvar _webStorage2 = _interopRequireDefault(_webStorage);\n\nvar _isAvailable = __webpack_require__(1);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\n\n/**\n * @public\n *\n * Current storage mechanism.\n *\n * @type {object}\n */\n/**\n * This library uses an adapter that implements the Web Storage interface,\n * which is very useful to deal with the lack of compatibility between\n * document.cookie and localStorage and sessionStorage.\n *\n * It also provides a memoryStorage fallback that stores the data in memory\n * when all of above mechanisms are not available.\n *\n * Author: David Rivera\n * Github: https://github.com/jherax\n * License: \"MIT\"\n *\n * You can fork this project on github:\n * https://github.com/jherax/proxy-storage.git\n */\n\nvar storage = null;\n\n/**\n * @public\n *\n * Get/Set the storage mechanism to use by default.\n *\n * @type {object}\n */\nvar configStorage = {\n get: function get() {\n return storage.__storage__;\n },\n\n\n /**\n * Sets the storage mechanism to use by default.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {void}\n */\n set: function set(storageType) {\n if (!Object.prototype.hasOwnProperty.call(_webStorage.proxy, storageType)) {\n throw new Error('Storage type \"' + storageType + '\" is not valid');\n }\n exports.default = storage = new _webStorage2.default(storageType);\n }\n};\n\n/**\n * @private\n *\n * Checks whether a storage mechanism is available.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {boolean}\n */\nfunction isStorageAvailable(storageType) {\n var storageObj = _webStorage.proxy[storageType];\n var data = '__proxy-storage__';\n try {\n storageObj.setItem(data, data);\n storageObj.removeItem(data);\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * @private\n *\n * Sets the first or default storage available.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {boolean}\n */\nfunction storageAvailable(storageType) {\n if (_isAvailable.isAvailable[storageType]) {\n _webStorage.webStorageSettings.default = storageType;\n configStorage.set(storageType);\n }\n return _isAvailable.isAvailable[storageType];\n}\n\n/**\n * @private\n *\n * Initializes the module.\n *\n * @return {void}\n */\nfunction init() {\n _isAvailable.isAvailable.localStorage = isStorageAvailable('localStorage');\n _isAvailable.isAvailable.sessionStorage = isStorageAvailable('sessionStorage');\n _isAvailable.isAvailable.cookieStorage = isStorageAvailable('cookieStorage');\n _webStorage.webStorageSettings.isAvailable = _isAvailable.isAvailable;\n // sets the default storage mechanism available\n Object.keys(_isAvailable.isAvailable).some(storageAvailable);\n}\n\ninit();\n\n/**\n * @public API\n */\nexports.default = storage;\nexports.WebStorage = _webStorage2.default;\nexports.configStorage = configStorage;\nexports.isAvailable = _isAvailable.isAvailable;\n\n/***/ })\n/******/ ]);\n});\n\n\n// WEBPACK FOOTER //\n// proxy-storage.min.js"," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// identity function for calling harmony imports with the correct context\n \t__webpack_require__.i = function(value) { return value; };\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, {\n \t\t\t\tconfigurable: false,\n \t\t\t\tenumerable: true,\n \t\t\t\tget: getter\n \t\t\t});\n \t\t}\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 6);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap bfb2c265a05630000505","/**\n * Determines whether a value is a plain object.\n *\n * @param {any} value: the object to test\n * @return {boolean}\n */\nexport function isObject(value) {\n return Object.prototype.toString.call(value) === '[object Object]';\n}\n\n/**\n * Adds or subtracts date portions to the given date and returns the new date.\n *\n * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2\n *\n * @param {object} options: It contains the date parts to add or remove, and can have the following properties:\n * - {Date} date: if provided, this date will be affected, otherwise the current date will be used.\n * - {number} minutes: minutes to add/subtract\n * - {number} hours: hours to add/subtract\n * - {number} days: days to add/subtract\n * - {number} months: months to add/subtract\n * - {number} years: years to add/subtract\n * @return {Date}\n */\nexport function alterDate(options = {}) {\n const opt = Object.assign({}, options);\n const d = opt.date instanceof Date ? opt.date : new Date();\n if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes);\n if (+opt.hours) d.setHours(d.getHours() + opt.hours);\n if (+opt.days) d.setDate(d.getDate() + opt.days);\n if (+opt.months) d.setMonth(d.getMonth() + opt.months);\n if (+opt.years) d.setFullYear(d.getFullYear() + opt.years);\n return d;\n}\n\n/**\n * Creates a non-enumerable read-only property.\n *\n * @param {object} obj: the object to add the property\n * @param {string} name: the name of the property\n * @param {any} value: the value of the property\n * @return {void}\n */\nexport function setProperty(obj, name, value) {\n const descriptor = {\n configurable: false,\n enumerable: false,\n writable: false,\n };\n if (typeof value !== 'undefined') {\n descriptor.value = value;\n }\n Object.defineProperty(obj, name, descriptor);\n}\n\n/**\n * Validates if the key is not empty.\n * (null, undefined or empty string)\n *\n * @param {string} key: keyname of an element in the storage mechanism\n * @return {void}\n */\nexport function checkEmpty(key) {\n if (key == null || key === '') {\n throw new Error('The key provided can not be empty');\n }\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/utils.js","/**\n * @public\n *\n * Used to determine which storage mechanisms are available.\n *\n * @type {object}\n */\nexport const isAvailable = {\n localStorage: false,\n sessionStorage: false,\n cookieStorage: false,\n memoryStorage: true, // fallback storage\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/is-available.js","import {proxy} from './proxy-mechanism';\nimport {setProperty, checkEmpty} from './utils';\nimport {isAvailable} from './is-available';\n\n/**\n * @private\n *\n * Keeps WebStorage instances by type as singletons.\n *\n * @type {object}\n */\nconst _instances = {};\n\n/**\n * @private\n *\n * Stores the interceptors for WebStorage methods.\n *\n * @type {object}\n */\nconst _interceptors = {\n setItem: [],\n getItem: [],\n removeItem: [],\n clear: [],\n};\n\n/**\n * @private\n *\n * Keys not allowed for cookies.\n *\n * @type {RegExp}\n */\nconst bannedKeys = /^(?:expires|max-age|path|domain|secure)$/i;\n\n/**\n * @private\n *\n * Executes the interceptors for a WebStorage method and\n * allows the transformation in chain of the value passed through.\n *\n * @param {string} command: name of the method to intercept\n * @return {any}\n */\nfunction executeInterceptors(command, ...args) {\n const key = args.shift();\n let value = args.shift();\n if (value && typeof value === 'object') {\n // clone the object to prevent mutations\n value = JSON.parse(JSON.stringify(value));\n }\n return _interceptors[command].reduce((val, action) => {\n const transformed = action(key, val, ...args);\n if (transformed == null) return val;\n return transformed;\n }, value);\n}\n\n/**\n * @private\n *\n * Try to parse a value\n *\n * @param {string} value: the value to parse\n * @return {any}\n */\nfunction tryParse(value) {\n let parsed;\n try {\n parsed = JSON.parse(value);\n } catch (e) {\n parsed = value;\n }\n return parsed;\n}\n\n/**\n * @private\n *\n * Copies all existing keys in the WebStorage instance.\n *\n * @param {WebStorage} instance: the instance to where copy the keys\n * @param {object} storage: the storage mechanism\n * @return {void}\n */\nfunction copyKeys(instance, storage) {\n Object.keys(storage).forEach((key) => {\n instance[key] = tryParse(storage[key]);\n });\n}\n\n/**\n * @public\n *\n * Allows to validate if a storage mechanism is valid\n *\n * @type {object}\n */\nconst webStorageSettings = {\n default: null,\n isAvailable,\n};\n\n/**\n * @private\n *\n * Validates if the storage mechanism is available and can be used safely.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {string}\n */\nfunction storageAvailable(storageType) {\n if (webStorageSettings.isAvailable[storageType]) return storageType;\n console.warn(`${storageType} is not available. Falling back to ${webStorageSettings.default}`); // eslint-disable-line\n return webStorageSettings.default;\n}\n\n/**\n * @public\n *\n * Implementation of the Web Storage interface.\n * It saves and retrieves values as JSON.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {class}\n */\nclass WebStorage {\n\n /**\n * Creates an instance of WebStorage.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n *\n * @memberOf WebStorage\n */\n constructor(storageType) {\n if (!Object.prototype.hasOwnProperty.call(proxy, storageType)) {\n throw new Error(`Storage type \"${storageType}\" is not valid`);\n }\n // gets the requested storage mechanism\n const storage = proxy[storageType];\n // if the storage is not available, sets the default\n storageType = storageAvailable(storageType);\n // keeps only one instance by storageType (singleton)\n const cachedInstance = _instances[storageType];\n if (cachedInstance) {\n copyKeys(cachedInstance, storage);\n return cachedInstance;\n }\n setProperty(this, '__storage__', storageType);\n // copies all existing keys in the storage mechanism\n copyKeys(this, storage);\n _instances[storageType] = this;\n }\n\n /**\n * Stores a value given a key name.\n *\n * @param {string} key: keyname of the storage\n * @param {any} value: data to save in the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n setItem(key, value, options) {\n checkEmpty(key);\n const storageType = this.__storage__;\n if (storageType === 'cookieStorage' && bannedKeys.test(key)) {\n throw new Error('The key is a reserved word, therefore not allowed');\n }\n const v = executeInterceptors('setItem', key, value, options);\n if (v !== undefined) value = v;\n this[key] = value;\n // prevents converting strings to JSON to avoid extra quotes\n if (typeof value !== 'string') value = JSON.stringify(value);\n proxy[storageType].setItem(key, value, options);\n // checks if the cookie was created, or delete it if the domain or path are not valid\n if (storageType === 'cookieStorage' && proxy[storageType].getItem(key) === null) {\n delete this[key];\n }\n }\n\n /**\n * Retrieves a value by its key name.\n *\n * @param {string} key: keyname of the storage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n getItem(key) {\n checkEmpty(key);\n let value = proxy[this.__storage__].getItem(key);\n if (value == null) {\n delete this[key];\n value = null;\n } else {\n value = tryParse(value);\n this[key] = value;\n }\n const v = executeInterceptors('getItem', key, value);\n if (v !== undefined) value = v;\n return value;\n }\n\n /**\n * Deletes a key from the storage.\n *\n * @param {string} key: keyname of the storage\n * @param {object} options: additional options for cookieStorage\n * @return {void}\n *\n * @memberOf WebStorage\n */\n removeItem(key, options) {\n checkEmpty(key);\n executeInterceptors('removeItem', key, options);\n delete this[key];\n proxy[this.__storage__].removeItem(key, options);\n }\n\n /**\n * Removes all keys from the storage.\n *\n * @return {void}\n *\n * @memberOf WebStorage\n */\n clear() {\n executeInterceptors('clear');\n Object.keys(this).forEach((key) => {\n delete this[key];\n }, this);\n proxy[this.__storage__].clear();\n }\n\n /**\n * Gets the number of data items stored in the Storage object.\n *\n * @readonly\n *\n * @memberOf WebStorage\n */\n get length() {\n return Object.keys(this).length;\n }\n\n /**\n * Adds an interceptor to a WebStorage method.\n *\n * @param {string} command: name of the API method to intercept\n * @param {function} action: callback executed when the API method is called\n * @return {void}\n *\n * @memberOf WebStorage\n */\n static interceptors(command, action) {\n if (command in _interceptors && typeof action === 'function') {\n _interceptors[command].push(action);\n }\n }\n}\n\n/**\n * @public API\n */\nexport {WebStorage as default, webStorageSettings, proxy};\n\n\n\n// WEBPACK FOOTER //\n// ./src/web-storage.js","import {alterDate, isObject} from './utils';\n\n/**\n * @private\n *\n * Proxy for document.cookie\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie\n *\n * @type {object}\n */\nconst $cookie = {\n get: () => document.cookie,\n set: (value) => {\n document.cookie = value;\n },\n data: {}, // metadata associated to the cookies\n};\n\n/**\n * @private\n *\n * Builds the expiration for the cookie.\n *\n * @see utils.alterDate(options)\n *\n * @param {Date|object} date: the expiration date\n * @return {string}\n */\nfunction buildExpirationString(date) {\n const expires = (date instanceof Date ?\n alterDate({date}) :\n alterDate(date)\n );\n return expires.toUTCString();\n}\n\n/**\n * @private\n *\n * Builds the string for the cookie metadata.\n *\n * @param {string} key: name of the metadata\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction buildMetadataFor(key, data) {\n if (!data[key]) return '';\n return `;${key}=${data[key]}`;\n}\n\n/**\n * @private\n *\n * Builds the whole string for the cookie metadata.\n *\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nfunction formatMetadata(data) {\n const expires = buildMetadataFor('expires', data);\n const domain = buildMetadataFor('domain', data);\n const path = buildMetadataFor('path', data);\n const secure = data.secure ? ';secure' : '';\n return `${expires}${domain}${path}${secure}`;\n}\n\n/**\n * @private\n *\n * Finds an element in the array.\n *\n * @param {string} cookie: key=value\n * @return {boolean}\n */\nfunction findCookie(cookie) {\n const nameEQ = this.toString();\n // prevent leading spaces before the key\n return cookie.trim().indexOf(nameEQ) === 0;\n}\n\n/**\n * @public\n *\n * Create, read, and delete elements from document.cookie,\n * and implements the Web Storage interface.\n *\n * @return {object}\n */\nexport default function cookieStorage() {\n const api = {\n\n setItem(key, value, options) {\n options = Object.assign({path: '/'}, options);\n // keep track of the metadata associated to the cookie\n $cookie.data[key] = {path: options.path};\n const metadata = $cookie.data[key];\n if (isObject(options.expires) || options.expires instanceof Date) {\n metadata.expires = buildExpirationString(options.expires);\n }\n if (options.domain && typeof options.domain === 'string') {\n metadata.domain = options.domain.trim();\n }\n if (options.secure === true) metadata.secure = true;\n const cookie = `${key}=${encodeURIComponent(value)}${formatMetadata(metadata)}`;\n // TODO: should encodeURIComponent(key) ?\n $cookie.set(cookie);\n },\n\n getItem(key) {\n let value = null;\n const nameEQ = `${key}=`;\n const cookie = $cookie.get().split(';').find(findCookie, nameEQ);\n if (cookie) {\n // prevent leading spaces before the key name\n value = cookie.trim().substring(nameEQ.length, cookie.length);\n value = decodeURIComponent(value);\n }\n if (value === null) delete $cookie.data[key];\n return value;\n },\n\n removeItem(key, options) {\n const metadata = Object.assign({}, $cookie.data[key], options);\n metadata.expires = {days: -1};\n api.setItem(key, '', metadata);\n delete $cookie.data[key];\n },\n\n clear() {\n let key, indexEQ; // eslint-disable-line\n $cookie.get().split(';').forEach((cookie) => {\n indexEQ = cookie.indexOf('=');\n if (indexEQ > -1) {\n key = cookie.substring(0, indexEQ);\n // prevent leading spaces before the key\n api.removeItem(key.trim());\n }\n });\n },\n\n initialize() {\n // copies all existing elements in the storage\n $cookie.get().split(';').forEach((cookie) => {\n const index = cookie.indexOf('=');\n const key = cookie.substring(0, index).trim();\n const value = cookie.substring(index + 1).trim();\n if (key) api[key] = decodeURIComponent(value);\n });\n // this method is removed after being invoked\n // because is not part of the Web Storage interface\n delete api.initialize;\n },\n };\n return api;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/cookie-storage.js","/**\n * @private\n *\n * Gets the hashtable-store from the current window.\n *\n * @return {object}\n */\nfunction getStoreFromWindow() { // eslint-disable-line\n try {\n const store = JSON.parse(window.self.name);\n if (store && typeof store === 'object') return store;\n } catch (e) {\n return {};\n }\n}\n\n/**\n * @private\n *\n * Saves the hashtable-store in the current window.\n *\n * @param {object} hashtable: {key,value} pairs stored in memoryStorage\n * @return {void}\n */\nfunction setStoreToWindow(hashtable) {\n const store = JSON.stringify(hashtable);\n window.self.name = store;\n}\n\n/**\n * @public\n *\n * Create, read, and delete elements from memory, and implements\n * the Web Storage interface. It also adds a hack to persist\n * the storage in the session for the current tab (browser).\n *\n * @return {object}\n */\nexport default function memoryStorage() {\n const hashtable = getStoreFromWindow();\n const api = {\n\n setItem(key, value) {\n hashtable[key] = value;\n setStoreToWindow(hashtable);\n },\n\n getItem(key) {\n const value = hashtable[key];\n return value === undefined ? null : value;\n },\n\n removeItem(key) {\n delete hashtable[key];\n setStoreToWindow(hashtable);\n },\n\n clear() {\n Object.keys(hashtable).forEach(key => delete hashtable[key]);\n setStoreToWindow(hashtable);\n },\n\n initialize() {\n // copies all existing elements in the storage\n Object.assign(api, hashtable);\n // this method is removed after being invoked\n // because is not part of the Web Storage interface\n delete api.initialize;\n },\n };\n return api;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/memory-storage.js","import cookieStorage from './cookie-storage';\nimport memoryStorage from './memory-storage';\nimport {setProperty} from './utils';\n\n/**\n * @private\n *\n * Copy the current items in the storage mechanism.\n *\n * @param {object} api: the storage mechanism to initialize\n * @return {object}\n */\nfunction initApi(api) {\n if (!api.initialize) return api;\n // sets API members to read-only and non-enumerable\n for (let prop in api) { // eslint-disable-line\n if (prop !== 'initialize') {\n setProperty(api, prop);\n }\n }\n api.initialize();\n return api;\n}\n\n/**\n * @public\n *\n * Proxy for the storage mechanisms.\n * All members implement the Web Storage interface.\n *\n * @see\n * https://developer.mozilla.org/en-US/docs/Web/API/Storage\n *\n * @type {object}\n */\nexport const proxy = {\n localStorage: window.localStorage,\n sessionStorage: window.sessionStorage,\n cookieStorage: initApi(cookieStorage()),\n memoryStorage: initApi(memoryStorage()),\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/proxy-mechanism.js","/**\n * This library uses an adapter that implements the Web Storage interface,\n * which is very useful to deal with the lack of compatibility between\n * document.cookie and localStorage and sessionStorage.\n *\n * It also provides a memoryStorage fallback that stores the data in memory\n * when all of above mechanisms are not available.\n *\n * Author: David Rivera\n * Github: https://github.com/jherax\n * License: \"MIT\"\n *\n * You can fork this project on github:\n * https://github.com/jherax/proxy-storage.git\n */\n\nimport WebStorage, {proxy, webStorageSettings} from './web-storage';\nimport {isAvailable} from './is-available';\n\n/**\n * @public\n *\n * Current storage mechanism.\n *\n * @type {object}\n */\nlet storage = null;\n\n/**\n * @public\n *\n * Get/Set the storage mechanism to use by default.\n *\n * @type {object}\n */\nconst configStorage = {\n get() {\n return storage.__storage__;\n },\n\n /**\n * Sets the storage mechanism to use by default.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {void}\n */\n set(storageType) {\n if (!Object.prototype.hasOwnProperty.call(proxy, storageType)) {\n throw new Error(`Storage type \"${storageType}\" is not valid`);\n }\n storage = new WebStorage(storageType);\n },\n};\n\n/**\n * @private\n *\n * Checks whether a storage mechanism is available.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {boolean}\n */\nfunction isStorageAvailable(storageType) {\n const storageObj = proxy[storageType];\n const data = '__proxy-storage__';\n try {\n storageObj.setItem(data, data);\n storageObj.removeItem(data);\n return true;\n } catch (e) {\n return false;\n }\n}\n\n/**\n * @private\n *\n * Sets the first or default storage available.\n *\n * @param {string} storageType: it can be \"localStorage\", \"sessionStorage\", \"cookieStorage\", or \"memoryStorage\"\n * @return {boolean}\n */\nfunction storageAvailable(storageType) {\n if (isAvailable[storageType]) {\n webStorageSettings.default = storageType;\n configStorage.set(storageType);\n }\n return isAvailable[storageType];\n}\n\n/**\n * @private\n *\n * Initializes the module.\n *\n * @return {void}\n */\nfunction init() {\n isAvailable.localStorage = isStorageAvailable('localStorage');\n isAvailable.sessionStorage = isStorageAvailable('sessionStorage');\n isAvailable.cookieStorage = isStorageAvailable('cookieStorage');\n webStorageSettings.isAvailable = isAvailable;\n // sets the default storage mechanism available\n Object.keys(isAvailable).some(storageAvailable);\n}\n\ninit();\n\n/**\n * @public API\n */\nexport {storage as default, WebStorage, configStorage, isAvailable};\n\n\n\n// WEBPACK FOOTER //\n// ./src/proxy-storage.js"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 906517c..5c949ea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "proxy-storage", - "version": "2.1.2", + "version": "2.1.3", "description": "Storage mechanism that implements the Web Storage interface", "author": "David Rivera ", "main": "dist/proxy-storage.js", diff --git a/src/cookie-storage.js b/src/cookie-storage.js index 0537e8b..f75f6a8 100644 --- a/src/cookie-storage.js +++ b/src/cookie-storage.js @@ -39,7 +39,7 @@ function buildExpirationString(date) { /** * @private * - * Builds the string for the cookie's metadata. + * Builds the string for the cookie metadata. * * @param {string} key: name of the metadata * @param {object} data: metadata of the cookie @@ -47,7 +47,23 @@ function buildExpirationString(date) { */ function buildMetadataFor(key, data) { if (!data[key]) return ''; - return `; ${key}=${data[key]}`; + return `;${key}=${data[key]}`; +} + +/** + * @private + * + * Builds the whole string for the cookie metadata. + * + * @param {object} data: metadata of the cookie + * @return {string} + */ +function formatMetadata(data) { + const expires = buildMetadataFor('expires', data); + const domain = buildMetadataFor('domain', data); + const path = buildMetadataFor('path', data); + const secure = data.secure ? ';secure' : ''; + return `${expires}${domain}${path}${secure}`; } /** @@ -86,10 +102,9 @@ export default function cookieStorage() { if (options.domain && typeof options.domain === 'string') { metadata.domain = options.domain.trim(); } - const expires = buildMetadataFor('expires', metadata); - const domain = buildMetadataFor('domain', metadata); - const path = buildMetadataFor('path', metadata); - const cookie = `${key}=${encodeURIComponent(value)}${expires}${domain}${path}`; + if (options.secure === true) metadata.secure = true; + const cookie = `${key}=${encodeURIComponent(value)}${formatMetadata(metadata)}`; + // TODO: should encodeURIComponent(key) ? $cookie.set(cookie); },