diff --git a/.eslintrc.json b/.eslintrc.json index 3976992..36b0ad7 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -43,8 +43,10 @@ "one-var": [2, { "uninitialized": "always" }], + "one-var-declaration-per-line": [2, "initializations"], "max-len": 0, "no-param-reassign": 0, + "no-use-before-define": 0, "no-underscore-dangle": 0, "object-curly-spacing": [2, "never"], "import/no-mutable-exports": 1, diff --git a/CHANGELOG.md b/CHANGELOG.md index 95fb7cc..64e62cd 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,13 @@ +## 2.3.0 + +### Improvements + +1. Upgraded to Webpack 3, ESLint 4. +1. Refactored and decoupled inner modules. + ## 2.2.0 ### Improvements diff --git a/README.md b/README.md index 33d2b2c..58cef67 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ This library manages an adapter that implements an interface similar to -[Web Storage] to normalize the API for [document.cookie], +[Web Storage] to normalize the API for [document.cookie] to be as [window.localStorage] and [window.sessionStorage]. One of the advantages of this library is that the adapter stores the data @@ -11,18 +11,18 @@ as **JSON**, allowing to save `Object` and `Array` values, which is not the default behavior when using the native `window.localStorage`, `window.sessionStorage` or `document.cookie` storages. -It also provides a new [`memoryStorage`](#storage-or-default) mechanism that -persists the data in memory (current browser tab), even if a forced refresh -is done on the page. It is a mimic of `sessionStorage` and it could be used -as fallback when the other storage mechanisms are not available, for example, -some browsers navigating in private mode. +It also provides a new mechanism -- [`memoryStorage`](#storage-or-default), +that persists the data in memory (for current browser-tab), even if a forced +refresh is done on the page. It is a mimic of `sessionStorage` and it could +be used as fallback when the other storage mechanisms are not available, for +example, some browsers navigating in private mode. Read more about [window.sessionStorage]. Another advantage with **proxy-storage** is that you can register -[interceptors](#interceptors) as callback functions on the -[WebStorage](#webstorage) prototype methods: `setItem`, `getItem`, -`removeItem`, and `clear`, giving you the ability to intercept and -modify the values to read, write, or delete. +[interceptors](#interceptors) as functions for the prototype methods of +[WebStorage](#webstorage) class: `setItem`, `getItem`, `removeItem`, and +`clear`, giving you the ability to intercept and modify the values to read, +write, or delete. ## Content @@ -40,7 +40,7 @@ modify the values to read, write, or delete. ## Installing the library -To include this library into your package manager with `npm` or `yarn` +To include this library into your package manager with `npm` or `yarn`, run: ```shell # with npm @@ -59,7 +59,7 @@ $ yarn add proxy-storage - + ``` In the above case, [`proxyStorage`](#api) is included as a global object @@ -98,7 +98,7 @@ import storage from 'proxy-storage'; // or get some API members import storage, { WebStorage, configStorage } from 'proxy-storage'; -const cookieStore = new WebStorage('memoryStorage'); +const cookieStore = new WebStorage('cookieStorage'); ``` ### AMD @@ -119,7 +119,7 @@ require(['proxy-storage'], function(proxyStorage) { }); ``` -See an example with RequireJS here: http://jsfiddle.net/FdKTn/71/ +See an example with RequireJS here: http://jsfiddle.net/FdKTn/77/ [☗ Back to Index](#content) @@ -131,7 +131,7 @@ as **JSON**, allowing to save and retrieve **primitive**, It also provides a new storage mechanism called **`memoryStorage`** which persists the data in memory (current tab in the browser), even -if a forced refresh is done (similar to `sessionStorage`). +if a forced refresh is done on the page, as `sessionStorage` does. The [`WebStorage`](#webstorage) class has a static member called [`interceptors`](#interceptors) which lets you to register callback @@ -158,7 +158,7 @@ the prototype:
The `options` parameter is used only with instances of `cookieStorage`. Read more details [here](#handling-cookies). - **`clear`**`()`: removes all items from the storage instance. -- **`length`**: gets the number of items stored in the storage instance. +- **`length`**: gets the number of items stored in the instance. The `storage` object is a proxy for the first storage mechanism available, usually `localStorage`, which is established when the library is initialized. @@ -173,22 +173,22 @@ The availability of the storage mechanisms is determined in the following order: of `memoryStorage` is similar to `sessionStorage`, which let you to persist data in the current session (browser tab) -As the `storage` object is a proxy of the first storage mechanism available, -that means if `localStorage` is available to set and retreive data, it will be -used, otherwise, if `localStorage` is not available, then it will try to use -`cookieStorage`, and finally if none of the above are available, then the -`storage` object will handle the `memoryStorage` as fallback. +**Important**: As the `storage` object is a proxy for the first storage +mechanism available, that means if `localStorage` is available to read and +write data, it will be used, otherwise, if `localStorage` is not available, +then `cookieStorage` will be used, and finally if none of the above are +available, `memoryStorage` will be the fallback mechanism. **Example** ```javascript import storage from 'proxy-storage'; -// 'storage' is the default module +// for browser: storage = proxyStorage.default; // use the default storage mechanism, usually localStorage -storage.setItem('qwerty', [{ some: 'object', garbage: true }]); +storage.setItem('qwerty', [{ garbage: true, some: 'object' }]); console.log(storage.getItem('qwerty')); -// [{ some: 'object', garbage: true }] +// [{ garbage: true, some: 'object' }] storage.setItem('persisted', true); storage.setItem('o-really', { status: 'saved' }); @@ -201,8 +201,7 @@ console.log(storage.getItem('qwerty')); // removes all data in the current storage storage.clear(); console.log(`items: ${storage.length}`); -console.log(storage.getItem('o-really')); -// null +// items: 0 ``` **ProTip**: you can override the default storage mechanism by calling @@ -243,7 +242,7 @@ Each instance inherits the following properties:
The `options` parameter is used only with instances of `cookieStorage`. Read more details [here](#handling-cookies). - **`clear`**`()`: removes all items from the storage instance. -- **`length`**: gets the number of items stored in the storage instance. +- **`length`**: gets the number of items stored in the instance. You can create multiple instances of `WebStorage` to handle different storage mechanisms. For example, to store data in `cookies` and also in @@ -251,6 +250,9 @@ storage mechanisms. For example, to store data in `cookies` and also in ```javascript import storage, { WebStorage } from 'proxy-storage'; +// for browser: +// var storage = proxyStorage.default; +// var WebStorage = proxyStorage.WebStorage; // use the default storage mechanism, usually localStorage storage.setItem('tv-show', { name: 'Regular Show' }); @@ -265,13 +267,16 @@ const cookieStore = new WebStorage('cookieStorage'); cookieStore.setItem('character', { name: 'Rigby' }, options); ``` -**Important**: If you request an instance of a storage mechanism that are not +**Important**: If you request an instance of a storage mechanism that is not available, you will get an instance of the first storage mechanism available, -this is in order to keep storing data. It is useful when you rely on a +so you can continue storing data. It is useful when you rely on a specific storage mechanism. Let's see an example: ```javascript import { WebStorage, isAvailable } from 'proxy-storage'; +// for browser: +// var WebStorage = proxyStorage.WebStorage; +// var isAvailable = proxyStorage.isAvailable; // let's suppose the following storage is not available isAvailable.sessionStorage = false; @@ -280,8 +285,8 @@ import { WebStorage, isAvailable } from 'proxy-storage'; // sessionStorage is not available. Falling back to memoryStorage sessionStore.setItem('ulugrun', 3.1415926); - // as sessionStorage is not available, the instance obtained - // is the first storage mechanism available: memoryStorage + // as sessionStorage is not available, the instance + // obtained is the fallback mechanism: memoryStorage console.dir(sessionStore); ``` @@ -290,8 +295,8 @@ import { WebStorage, isAvailable } from 'proxy-storage'; ### Handling cookies When you create an instance of `WebStorage` with `cookieStorage`, the -method `setItem()` receives an optional argument as the last parameter, -it configures the way how the cookie is stored. +method `setItem()` receives an optional argument as the last parameter +that configures the way how the cookie is stored. Signature of `setItem`: @@ -303,7 +308,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, creates a secure cookie, over HTTPS. +- `secure`_`{boolean}`_: if provided, creates a secure cookie over HTTPS. - `expires`_`{Date, object}`_: the cookie expiration date. You can pass an object describing the expiration: - `date`_`{Date}`_: if provided, this date will be applied, otherwise the @@ -318,6 +323,7 @@ Where the **`options`** parameter is an `object` with the following properties: ```javascript import { WebStorage } from 'proxy-storage'; +// for browser: WebStorage = proxyStorage.WebStorage; const cookieStore = new WebStorage('cookieStorage'); @@ -357,12 +363,11 @@ when calling `setItem(key, value, options)` or `removeItem(key, options)`. If you have created the cookie with **proxyStorage**, it will handle the metadata internally, so that you can call `removeItem(key)` with no more -arguments. +arguments. Otherwise you will need to provide the metadata **`path`** or +**`domain`**: ![cookies](https://www.dropbox.com/s/wlvgm0t8xc07me1/cookies-metadata.gif?dl=1) -Otherwise you need to provide the metadata `path` or `domain` as mentioned before: - ```javascript // change the value of an external cookie in /answers cookieStore.setItem('landedAnswers', 999, { @@ -397,7 +402,7 @@ Object.keys(sessionStore).forEach((key) => { console.log(key, sessionStore[key]); }); -// or this way (not recommended) ... +// or this way (not recommended either) for (let key in sessionStore) { console.log(key, sessionStore[key]); } @@ -406,12 +411,12 @@ for (let key in sessionStore) { It is also applied not only when reading, but also when writing to storage: ```javascript -// not recommended: not synchronized +// not recommended: not synchronized with the real storage var title = cookieStorage['title']; var session = cookieStorage.sessionId; cookieStorage['sessionId'] = 'E6URTG5'; -// good practice: sync external changes +// good practice: it is synchronized for external changes var title = cookieStorage.getItem('title'); var session = cookieStorage.getItem('sessionId'); cookieStorage.setItem('sessionId', 'E6URTG5'); @@ -427,6 +432,7 @@ in the storage instance, e.g. ```javascript import { WebStorage } from 'proxy-storage'; +// for browser: WebStorage = proxyStorage.WebStorage; function clearAllStorages() { new WebStorage('localStorage').clear(); @@ -435,6 +441,13 @@ function clearAllStorages() { } ``` +**Important**: When handling `cookieStorage`, the method `clear()` only will +remove the cookies with no metadata or those created through **proxyStorage**. +Take into account that if you want to remove a cookie that was created from +another page, you need to set the `domain` or `path` attributes in the +`options` parameter when calling `removeItem(key, options)`.
+See [handling-cookies](#handling-cookies). + [☗ Back to Index](#content) ### Interceptors @@ -456,6 +469,9 @@ the _value_ passed and returned in each callback. ```javascript import storage, { WebStorage } from 'proxy-storage'; +// for browser: +// var storage = proxyStorage.default; +// var WebStorage = proxyStorage.WebStorage; // adds first interceptor for 'setItem' WebStorage.interceptors('setItem', (key, value/*, options*/) => { @@ -500,11 +516,11 @@ console.log(data); **_@type_ `Object`** -Gets and sets the storage mechanism to use by default. -It contains the following methods: +Sets the [default storage](##storage-or-default) mechanism, or get the current +default storage mechanism. This object contains the following methods: - **`get`**`()`: returns a `string` with the name of the current storage mechanism. -- **`set`**`(storageType)`: sets the current storage mechanism. `storageType` +- **`set`**`(storageType)`: sets the default storage mechanism. `storageType` must be one of the following strings: `"localStorage"`, `"sessionStorage"`, `"cookieStorage"`, or `"memoryStorage"`. If the storage type provided is not valid, it will throw an exception. @@ -513,6 +529,9 @@ It contains the following methods: ```javascript import storage, { configStorage } from 'proxy-storage'; +// for browser: +// var storage = proxyStorage.default; +// var configStorage = proxyStorage.configStorage; // gets the default storage mechanism let storageName = configStorage.get(); @@ -537,12 +556,13 @@ storage.setItem('currentStorage', storageName); **_@type_ `Object`** -Determines which storage mechanisms are available to read, write, or delete. +Determines which storage mechanisms are available to _read, write,_ +or _delete_ data. It contains the following flags: - **`localStorage`**: is set to `true` if the local storage is available. -- **`cookieStorage`**: is set to `true` if the cookie storage is available. +- **`cookieStorage`**: is set to `true` if the document cookies are available. - **`sessionStorage`**: is set to `true` if the session storage is available. - **`memoryStorage`**: always is set to `true`. @@ -648,9 +668,9 @@ repository. See [LICENSE](LICENSE) file for more information. [Web Storage]: https://developer.mozilla.org/en-US/docs/Web/API/Storage +[document.cookie]: https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie [window.localStorage]: https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage [window.sessionStorage]: https://developer.mozilla.org/en-US/docs/Web/API/Window/sessionStorage -[document.cookie]: https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie [UMD]: http://davidbcalhoun.com/2014/what-is-amd-commonjs-and-umd/ [CommonJS]: https://blog.risingstack.com/node-js-at-scale-module-system-commonjs-require/ [ES2015 Export]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export diff --git a/dist/proxy-storage.js b/dist/proxy-storage.js index 485db34..00066f3 100644 --- a/dist/proxy-storage.js +++ b/dist/proxy-storage.js @@ -1,4 +1,4 @@ -/*! proxyStorage@v2.2.0. Jherax 2017. Visit https://github.com/jherax/proxy-storage */ +/*! proxyStorage@v2.3.0. Jherax 2017. Visit https://github.com/jherax/proxy-storage */ (function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); @@ -85,9 +85,9 @@ Object.defineProperty(exports, "__esModule", { value: true }); exports.isObject = isObject; -exports.alterDate = alterDate; -exports.setProperty = setProperty; exports.checkEmpty = checkEmpty; +exports.setProperty = setProperty; +exports.tryParse = tryParse; /** * Determines whether a value is a plain object. * @@ -99,30 +99,16 @@ function isObject(value) { } /** - * Adds or subtracts date portions to the given date and returns the new date. - * - * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2 + * Validates if the key is not empty. + * (null, undefined or empty string) * - * @param {object} options: It contains the date parts to add or remove, and can have the following properties: - * - {Date} date: if provided, this date will be affected, otherwise the current date will be used. - * - {number} minutes: minutes to add/subtract - * - {number} hours: hours to add/subtract - * - {number} days: days to add/subtract - * - {number} months: months to add/subtract - * - {number} years: years to add/subtract - * @return {Date} + * @param {string} key: keyname of an element in the storage mechanism + * @return {void} */ -function alterDate() { - var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; - - var opt = Object.assign({}, options); - var d = opt.date instanceof Date ? opt.date : new Date(); - if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes); - if (+opt.hours) d.setHours(d.getHours() + opt.hours); - if (+opt.days) d.setDate(d.getDate() + opt.days); - if (+opt.months) d.setMonth(d.getMonth() + opt.months); - if (+opt.years) d.setFullYear(d.getFullYear() + opt.years); - return d; +function checkEmpty(key) { + if (key == null || key === '') { + throw new Error('The key provided can not be empty'); + } } /** @@ -146,16 +132,19 @@ function setProperty(obj, name, value) { } /** - * Validates if the key is not empty. - * (null, undefined or empty string) + * Try to parse a value from JSON. * - * @param {string} key: keyname of an element in the storage mechanism - * @return {void} + * @param {string} value: the value to parse + * @return {any} */ -function checkEmpty(key) { - if (key == null || key === '') { - throw new Error('The key provided can not be empty'); +function tryParse(value) { + var parsed = void 0; + try { + parsed = JSON.parse(value); + } catch (e) { + parsed = value; } + return parsed; } /***/ }), @@ -327,14 +316,18 @@ exports.proxy = exports.webStorageSettings = exports.default = undefined; var _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; }; }(); -var _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; }; +var _interceptors = __webpack_require__(4); -var _proxyMechanism = __webpack_require__(4); +var _interceptors2 = _interopRequireDefault(_interceptors); var _utils = __webpack_require__(0); var _isAvailable = __webpack_require__(1); +var _proxyMechanism = __webpack_require__(5); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } /** @@ -344,21 +337,7 @@ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Cons * * @type {object} */ -var _instances = {}; - -/** - * @private - * - * Stores the interceptors for WebStorage methods. - * - * @type {object} - */ -var _interceptors = { - setItem: [], - getItem: [], - removeItem: [], - clear: [] -}; +var INSTANCES = {}; /** * @private @@ -367,66 +346,22 @@ var _interceptors = { * * @type {RegExp} */ -var bannedKeys = /^(?:expires|max-age|path|domain|secure)$/i; - -/** - * @private - * - * Executes the interceptors for a WebStorage method and - * allows the transformation in chain of the value passed through. - * - * @param {string} command: name of the method to intercept - * @return {any} - */ -function executeInterceptors(command) { - for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { - args[_key - 1] = arguments[_key]; - } - - var key = args.shift(); - var value = args.shift(); - if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { - // clone the object to prevent mutations - value = JSON.parse(JSON.stringify(value)); - } - return _interceptors[command].reduce(function (val, action) { - var transformed = action.apply(undefined, [key, val].concat(args)); - if (transformed == null) return val; - return transformed; - }, value); -} - -/** - * @private - * - * Try to parse a value - * - * @param {string} value: the value to parse - * @return {any} - */ -function tryParse(value) { - var parsed = void 0; - try { - parsed = JSON.parse(value); - } catch (e) { - parsed = value; - } - return parsed; -} +var BANNED_KEYS = /^(?:expires|max-age|path|domain|secure)$/i; /** * @private * - * Copies all existing keys in the WebStorage instance. + * Copies all existing keys in the storage. * - * @param {WebStorage} instance: the instance to where copy the keys + * @param {CookieStorage} instance: the object to where copy the keys * @param {object} storage: the storage mechanism - * @return {void} + * @return {object} */ function copyKeys(instance, storage) { Object.keys(storage).forEach(function (key) { - instance[key] = tryParse(storage[key]); + instance[key] = (0, _utils.tryParse)(storage[key]); }); + return instance; } /** @@ -488,15 +423,13 @@ var WebStorage = function () { // if the storage is not available, sets the default storageType = storageAvailable(storageType); // keeps only one instance by storageType (singleton) - var cachedInstance = _instances[storageType]; + var cachedInstance = INSTANCES[storageType]; if (cachedInstance) { - copyKeys(cachedInstance, storage); - return cachedInstance; + return copyKeys(cachedInstance, storage); } (0, _utils.setProperty)(this, '__storage__', storageType); // copies all existing keys in the storage mechanism - copyKeys(this, storage); - _instances[storageType] = this; + INSTANCES[storageType] = copyKeys(this, storage); } /** @@ -516,10 +449,10 @@ var WebStorage = function () { value: function setItem(key, value, options) { (0, _utils.checkEmpty)(key); var storageType = this.__storage__; - if (storageType === 'cookieStorage' && bannedKeys.test(key)) { + if (storageType === 'cookieStorage' && BANNED_KEYS.test(key)) { throw new Error('The key is a reserved word, therefore not allowed'); } - var v = executeInterceptors('setItem', key, value, options); + var v = (0, _interceptors2.default)('setItem', key, value, options); if (v !== undefined) value = v; this[key] = value; // prevents converting strings to JSON to avoid extra quotes @@ -546,13 +479,14 @@ var WebStorage = function () { (0, _utils.checkEmpty)(key); var value = _proxyMechanism.proxy[this.__storage__].getItem(key); if (value == null) { + // null or undefined delete this[key]; value = null; } else { - value = tryParse(value); + value = (0, _utils.tryParse)(value); this[key] = value; } - var v = executeInterceptors('getItem', key, value); + var v = (0, _interceptors2.default)('getItem', key, value); if (v !== undefined) value = v; return value; } @@ -571,7 +505,7 @@ var WebStorage = function () { key: 'removeItem', value: function removeItem(key, options) { (0, _utils.checkEmpty)(key); - executeInterceptors('removeItem', key, options); + (0, _interceptors2.default)('removeItem', key, options); delete this[key]; _proxyMechanism.proxy[this.__storage__].removeItem(key, options); } @@ -589,7 +523,7 @@ var WebStorage = function () { value: function clear() { var _this = this; - executeInterceptors('clear'); + (0, _interceptors2.default)('clear'); Object.keys(this).forEach(function (key) { delete _this[key]; }, this); @@ -623,8 +557,8 @@ var WebStorage = function () { }], [{ key: 'interceptors', value: function interceptors(command, action) { - if (command in _interceptors && typeof action === 'function') { - _interceptors[command].push(action); + if (command in _interceptors.INTERCEPTORS && typeof action === 'function') { + _interceptors.INTERCEPTORS[command].push(action); } } }]); @@ -648,44 +582,72 @@ exports.proxy = _proxyMechanism.proxy; "use strict"; +Object.defineProperty(exports, "__esModule", { + value: true +}); + +var _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; }; + +exports.default = executeInterceptors; +/** + * Stores the interceptors for WebStorage methods. + * + * @type {object} + */ +var INTERCEPTORS = exports.INTERCEPTORS = { + setItem: [], + getItem: [], + removeItem: [], + clear: [] +}; + +/** + * Executes the interceptors for a WebStorage method and allows + * the transformation in chain of the value passed through. + * + * @param {string} command: name of the method to intercept + * @return {any} + */ +function executeInterceptors(command) { + for (var _len = arguments.length, args = Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) { + args[_key - 1] = arguments[_key]; + } + + var key = args.shift(); + var value = args.shift(); + if (value && (typeof value === 'undefined' ? 'undefined' : _typeof(value)) === 'object') { + // clone the object to prevent mutations + value = JSON.parse(JSON.stringify(value)); + } + return INTERCEPTORS[command].reduce(function (val, action) { + var transformed = action.apply(undefined, [key, val].concat(args)); + if (transformed == null) return val; + return transformed; + }, value); +} + +/***/ }), +/* 5 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + Object.defineProperty(exports, "__esModule", { value: true }); exports.proxy = undefined; -var _cookieStorage = __webpack_require__(5); +var _cookieStorage = __webpack_require__(6); var _cookieStorage2 = _interopRequireDefault(_cookieStorage); -var _memoryStorage = __webpack_require__(6); +var _memoryStorage = __webpack_require__(9); var _memoryStorage2 = _interopRequireDefault(_memoryStorage); -var _utils = __webpack_require__(0); - function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } -/** - * @private - * - * Copy the current items in the storage mechanism. - * - * @param {object} api: the storage mechanism to initialize - * @return {object} - */ -function initApi(api) { - if (!api.initialize) return api; - // sets API members to read-only and non-enumerable - for (var prop in api) { - // eslint-disable-line - if (prop !== 'initialize') { - (0, _utils.setProperty)(api, prop); - } - } - api.initialize(); - return api; -} - /** * @public * @@ -700,12 +662,12 @@ function initApi(api) { var proxy = exports.proxy = { localStorage: window.localStorage, sessionStorage: window.sessionStorage, - cookieStorage: initApi((0, _cookieStorage2.default)()), - memoryStorage: initApi((0, _memoryStorage2.default)()) + cookieStorage: (0, _cookieStorage2.default)(), + memoryStorage: (0, _memoryStorage2.default)() }; /***/ }), -/* 5 */ +/* 6 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -714,10 +676,19 @@ var proxy = exports.proxy = { Object.defineProperty(exports, "__esModule", { value: true }); -exports.default = cookieStorage; var _utils = __webpack_require__(0); +var _formatMetadata = __webpack_require__(7); + +var _formatMetadata2 = _interopRequireDefault(_formatMetadata); + +var _expirationDate = __webpack_require__(8); + +var _expirationDate2 = _interopRequireDefault(_expirationDate); + +function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } + /** * @private * @@ -738,51 +709,6 @@ var $cookie = { data: {} // metadata associated to the cookies }; -/** - * @private - * - * Builds the expiration for the cookie. - * - * @see utils.alterDate(options) - * - * @param {Date|object} date: the expiration date - * @return {string} - */ -function buildExpirationString(date) { - var expires = date instanceof Date ? (0, _utils.alterDate)({ date: date }) : (0, _utils.alterDate)(date); - return expires.toUTCString(); -} - -/** - * @private - * - * Builds the string for the cookie metadata. - * - * @param {string} key: name of the metadata - * @param {object} data: metadata of the cookie - * @return {string} - */ -function buildMetadataFor(key, data) { - if (!data[key]) return ''; - 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; -} - /** * @private * @@ -813,13 +739,13 @@ function cookieStorage() { $cookie.data[key] = { path: options.path }; var metadata = $cookie.data[key]; if ((0, _utils.isObject)(options.expires) || options.expires instanceof Date) { - metadata.expires = buildExpirationString(options.expires); + metadata.expires = (0, _expirationDate2.default)(options.expires); } if (options.domain && typeof options.domain === 'string') { metadata.domain = options.domain.trim(); } if (options.secure === true) metadata.secure = true; - var cookie = key + '=' + encodeURIComponent(value) + formatMetadata(metadata); + var cookie = key + '=' + encodeURIComponent(value) + (0, _formatMetadata2.default)(metadata); // TODO: should encodeURIComponent(key) ? $cookie.set(cookie); }, @@ -843,7 +769,7 @@ function cookieStorage() { }, clear: function clear() { var key = void 0, - indexEQ = void 0; // eslint-disable-line + indexEQ = void 0; $cookie.get().split(';').forEach(function (cookie) { indexEQ = cookie.indexOf('='); if (indexEQ > -1) { @@ -852,25 +778,132 @@ function cookieStorage() { api.removeItem(key.trim()); } }); - }, - initialize: function initialize() { - // copies all existing elements in the storage - $cookie.get().split(';').forEach(function (cookie) { - var index = cookie.indexOf('='); - var key = cookie.substring(0, index).trim(); - var value = cookie.substring(index + 1).trim(); - if (key) api[key] = decodeURIComponent(value); - }); - // this method is removed after being invoked - // because is not part of the Web Storage interface - delete api.initialize; } }; + + return initialize(api); +} + +/** + * @private + * + * Copy the current items in the cookie storage. + * + * @param {object} api: the storage mechanism to initialize + * @return {object} + */ +function initialize(api) { + // sets API members to read-only and non-enumerable + for (var prop in api) { + // eslint-disable-line + (0, _utils.setProperty)(api, prop); + } + // copies all existing elements in the storage + $cookie.get().split(';').forEach(function (cookie) { + var index = cookie.indexOf('='); + var key = cookie.substring(0, index).trim(); + var value = cookie.substring(index + 1).trim(); + if (key) api[key] = decodeURIComponent(value); + }); return api; } +/** + * @public API + */ +exports.default = cookieStorage; + /***/ }), -/* 6 */ +/* 7 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = formatMetadata; +/** + * @private + * + * Builds the string for the cookie metadata. + * + * @param {string} key: name of the metadata + * @param {object} data: metadata of the cookie + * @return {string} + */ +function buildMetadataFor(key, data) { + if (!data[key]) return ''; + return ';' + key + '=' + data[key]; +} + +/** + * 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; +} + +/***/ }), +/* 8 */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; + + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = buildExpiration; +/** + * @private + * + * Adds or subtracts date portions to the given date and returns the new date. + * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2 + * + * @param {object} options: It contains the date parts to add or remove, and can have the following properties: + * - {Date} date: if provided, this date will be affected, otherwise the current date will be used. + * - {number} minutes: minutes to add/subtract + * - {number} hours: hours to add/subtract + * - {number} days: days to add/subtract + * - {number} months: months to add/subtract + * - {number} years: years to add/subtract + * @return {Date} + */ +function alterDate() { + var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; + + var opt = Object.assign({}, options); + var d = opt.date instanceof Date ? opt.date : new Date(); + if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes); + if (+opt.hours) d.setHours(d.getHours() + opt.hours); + if (+opt.days) d.setDate(d.getDate() + opt.days); + if (+opt.months) d.setMonth(d.getMonth() + opt.months); + if (+opt.years) d.setFullYear(d.getFullYear() + opt.years); + return d; +} + +/** + * Builds the expiration for the cookie. + * + * @param {Date|object} date: the expiration date + * @return {string} + */ +function buildExpiration(date) { + var expires = date instanceof Date ? alterDate({ date: date }) : alterDate(date); + return expires.toUTCString(); +} + +/***/ }), +/* 9 */ /***/ (function(module, exports, __webpack_require__) { "use strict"; @@ -883,6 +916,9 @@ Object.defineProperty(exports, "__esModule", { var _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; }; exports.default = memoryStorage; + +var _utils = __webpack_require__(0); + /** * @private * @@ -891,13 +927,14 @@ exports.default = memoryStorage; * @return {object} */ function getStoreFromWindow() { - // eslint-disable-line + var store = void 0; try { - var store = JSON.parse(window.self.name); - if (store && (typeof store === 'undefined' ? 'undefined' : _typeof(store)) === 'object') return store; + store = JSON.parse(window.self.name); } catch (e) { return {}; } + if (store && (typeof store === 'undefined' ? 'undefined' : _typeof(store)) === 'object') return store; + return {}; } /** @@ -942,15 +979,29 @@ function memoryStorage() { return delete hashtable[key]; }); setStoreToWindow(hashtable); - }, - initialize: function initialize() { - // copies all existing elements in the storage - Object.assign(api, hashtable); - // this method is removed after being invoked - // because is not part of the Web Storage interface - delete api.initialize; } }; + + return initialize(api, hashtable); +} + +/** + * @private + * + * Copy the current items in the cookie storage. + * + * @param {object} api: the storage mechanism to initialize + * @param {object} hashtable: store from the window tab + * @return {object} + */ +function initialize(api, hashtable) { + // sets API members to read-only and non-enumerable + for (var prop in api) { + // eslint-disable-line + (0, _utils.setProperty)(api, prop); + } + // copies all existing elements in the storage + Object.assign(api, hashtable); return api; } diff --git a/dist/proxy-storage.min.js b/dist/proxy-storage.min.js index d4a49b3..5afcf9e 100644 --- a/dist/proxy-storage.min.js +++ b/dist/proxy-storage.min.js @@ -1,3 +1,3 @@ -/*! proxyStorage@v2.2.0. 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(r){if(o[r])return o[r].exports;var n=o[r]={i:r,l:!1,exports:{}};return e[r].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var o={};return t.m=e,t.c=o,t.d=function(e,o,r){t.o(e,o)||Object.defineProperty(e,o,{configurable:!1,enumerable:!0,get:r})},t.n=function(e){var o=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(o,"a",o),o},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,o){"use strict";function r(e){return"[object Object]"===Object.prototype.toString.call(e)}function n(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},e),o=t.date instanceof Date?t.date:new Date;return+t.minutes&&o.setMinutes(o.getMinutes()+t.minutes),+t.hours&&o.setHours(o.getHours()+t.hours),+t.days&&o.setDate(o.getDate()+t.days),+t.months&&o.setMonth(o.getMonth()+t.months),+t.years&&o.setFullYear(o.getFullYear()+t.years),o}function i(e,t,o){var r={configurable:!1,enumerable:!1,writable:!1};void 0!==o&&(r.value=o),Object.defineProperty(e,t,r)}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=r,t.alterDate=n,t.setProperty=i,t.checkEmpty=a},function(e,t,o){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.isAvailable={localStorage:!1,cookieStorage:!1,sessionStorage:!1,memoryStorage:!0}},function(e,t,o){"use strict";function r(e){var t=i.proxy[e],o="__proxy-storage__";try{t.setItem(o,o),t.removeItem(o)}catch(e){return!1}return!0}function n(e){return u.isAvailable[e]&&(i.webStorageSettings.default=e,c.set(e)),u.isAvailable[e]}Object.defineProperty(t,"__esModule",{value:!0}),t.isAvailable=t.configStorage=t.WebStorage=t.default=void 0;var i=o(3),a=function(e){return e&&e.__esModule?e:{default:e}}(i),u=o(1),s=null,c={get:function(){return s.__storage__},set:function(e){t.default=s=new a.default(e)}};!function(){u.isAvailable.localStorage=r("localStorage"),u.isAvailable.cookieStorage=r("cookieStorage"),u.isAvailable.sessionStorage=r("sessionStorage"),i.webStorageSettings.isAvailable=u.isAvailable,Object.keys(u.isAvailable).some(n)}(),t.default=s,t.WebStorage=a.default,t.configStorage=c,t.isAvailable=u.isAvailable},function(e,t,o){"use strict";function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e){for(var t=arguments.length,o=Array(t>1?t-1:0),r=1;r-1&&(t=r.substring(0,o),e.removeItem(t.trim()))})},initialize:function(){c.get().split(";").forEach(function(t){var o=t.indexOf("="),r=t.substring(0,o).trim(),n=t.substring(o+1).trim();r&&(e[r]=decodeURIComponent(n))}),delete e.initialize}};return e}Object.defineProperty(t,"__esModule",{value:!0}),t.default=u;var s=o(0),c={get:function(){return document.cookie},set:function(e){document.cookie=e},data:{}}},function(e,t,o){"use strict";function r(){try{var e=JSON.parse(window.self.name);if(e&&"object"===(void 0===e?"undefined":a(e)))return e}catch(e){return{}}}function n(e){var t=JSON.stringify(e);window.self.name=t}function i(){var e=r(),t={setItem:function(t,o){e[t]=o,n(e)},getItem:function(t){var o=e[t];return void 0===o?null:o},removeItem:function(t){delete e[t],n(e)},clear:function(){Object.keys(e).forEach(function(t){return delete e[t]}),n(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}])}); +/*! proxyStorage@v2.3.0. 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(r[o])return r[o].exports;var n=r[o]={i:o,l:!1,exports:{}};return e[o].call(n.exports,n,n.exports,t),n.l=!0,n.exports}var r={};return t.m=e,t.c=r,t.d=function(e,r,o){t.o(e,r)||Object.defineProperty(e,r,{configurable:!1,enumerable:!0,get:o})},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},t.p="",t(t.s=2)}([function(e,t,r){"use strict";function o(e){return"[object Object]"===Object.prototype.toString.call(e)}function n(e){if(null==e||""===e)throw new Error("The key provided can not be empty")}function i(e,t,r){var o={configurable:!1,enumerable:!1,writable:!1};void 0!==r&&(o.value=r),Object.defineProperty(e,t,o)}function a(e){var t=void 0;try{t=JSON.parse(e)}catch(r){t=e}return t}Object.defineProperty(t,"__esModule",{value:!0}),t.isObject=o,t.checkEmpty=n,t.setProperty=i,t.tryParse=a},function(e,t,r){"use strict";Object.defineProperty(t,"__esModule",{value:!0});t.isAvailable={localStorage:!1,cookieStorage:!1,sessionStorage:!1,memoryStorage:!0}},function(e,t,r){"use strict";function o(e){var t=i.proxy[e],r="__proxy-storage__";try{t.setItem(r,r),t.removeItem(r)}catch(e){return!1}return!0}function n(e){return u.isAvailable[e]&&(i.webStorageSettings.default=e,c.set(e)),u.isAvailable[e]}Object.defineProperty(t,"__esModule",{value:!0}),t.isAvailable=t.configStorage=t.WebStorage=t.default=void 0;var i=r(3),a=function(e){return e&&e.__esModule?e:{default:e}}(i),u=r(1),s=null,c={get:function(){return s.__storage__},set:function(e){t.default=s=new a.default(e)}};!function(){u.isAvailable.localStorage=o("localStorage"),u.isAvailable.cookieStorage=o("cookieStorage"),u.isAvailable.sessionStorage=o("sessionStorage"),i.webStorageSettings.isAvailable=u.isAvailable,Object.keys(u.isAvailable).some(n)}(),t.default=s,t.WebStorage=a.default,t.configStorage=c,t.isAvailable=u.isAvailable},function(e,t,r){"use strict";function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function n(e,t){return Object.keys(t).forEach(function(r){e[r]=(0,c.tryParse)(t[r])}),e}function i(e){if(p.isAvailable[e])return e;var t="sessionStorage"===e?"memoryStorage":p.default,r=e+" is not available. Falling back to "+t;return console.warn(r),t}Object.defineProperty(t,"__esModule",{value:!0}),t.proxy=t.webStorageSettings=t.default=void 0;var a=function(){function e(e,t){for(var r=0;r1?t-1:0),o=1;o-1&&(t=o.substring(0,r),e.removeItem(t.trim()))})}};return a(e)}function a(e){for(var t in e)(0,u.setProperty)(e,t);return d.get().split(";").forEach(function(t){var r=t.indexOf("="),o=t.substring(0,r).trim(),n=t.substring(r+1).trim();o&&(e[o]=decodeURIComponent(n))}),e}Object.defineProperty(t,"__esModule",{value:!0});var u=r(0),s=r(7),c=o(s),l=r(8),f=o(l),d={get:function(){return document.cookie},set:function(e){document.cookie=e},data:{}};t.default=i},function(e,t,r){"use strict";function o(e,t){return t[e]?";"+e+"="+t[e]:""}function n(e){return""+o("expires",e)+o("domain",e)+o("path",e)+(e.secure?";secure":"")}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,r){"use strict";function o(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:{},t=Object.assign({},e),r=t.date instanceof Date?t.date:new Date;return+t.minutes&&r.setMinutes(r.getMinutes()+t.minutes),+t.hours&&r.setHours(r.getHours()+t.hours),+t.days&&r.setDate(r.getDate()+t.days),+t.months&&r.setMonth(r.getMonth()+t.months),+t.years&&r.setFullYear(r.getFullYear()+t.years),r}function n(e){return o(e instanceof Date?{date:e}:e).toUTCString()}Object.defineProperty(t,"__esModule",{value:!0}),t.default=n},function(e,t,r){"use strict";function o(){var e=void 0;try{e=JSON.parse(window.self.name)}catch(e){return{}}return e&&"object"===(void 0===e?"undefined":u(e))?e:{}}function n(e){var t=JSON.stringify(e);window.self.name=t}function i(){var e=o();return a({setItem:function(t,r){e[t]=r,n(e)},getItem:function(t){var r=e[t];return void 0===r?null:r},removeItem:function(t){delete e[t],n(e)},clear:function(){Object.keys(e).forEach(function(t){return delete e[t]}),n(e)}},e)}function a(e,t){for(var r in e)(0,s.setProperty)(e,r);return Object.assign(e,t),e}Object.defineProperty(t,"__esModule",{value:!0});var u="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;var s=r(0)}])}); //# 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 c75c9f3..6c2a371 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 4fc57594dbc8eb12ca59","webpack:///./src/utils.js","webpack:///./src/is-available.js","webpack:///./src/proxy-storage.js","webpack:///./src/web-storage.js","webpack:///./src/proxy-mechanism.js","webpack:///./src/cookie-storage.js","webpack:///./src/memory-storage.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","isObject","value","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","cookieStorage","sessionStorage","memoryStorage","isStorageAvailable","storageType","storageObj","_webStorage","proxy","data","setItem","removeItem","e","storageAvailable","_isAvailable","webStorageSettings","default","configStorage","set","WebStorage","_webStorage2","storage","__storage__","keys","some","_classCallCheck","instance","Constructor","TypeError","executeInterceptors","command","_len","args","Array","_key","shift","_typeof","JSON","parse","stringify","_interceptors","reduce","val","action","transformed","concat","tryParse","parsed","copyKeys","forEach","fallback","msg","console","warn","_createClass","defineProperties","target","props","protoProps","staticProps","Symbol","iterator","constructor","_proxyMechanism","_utils","_instances","getItem","clear","bannedKeys","cachedInstance","test","v","_this","push","_interopRequireDefault","initApi","api","initialize","prop","_cookieStorage","_cookieStorage2","_memoryStorage","_memoryStorage2","window","buildExpirationString","toUTCString","buildMetadataFor","formatMetadata","secure","findCookie","cookie","nameEQ","trim","indexOf","path","$cookie","metadata","expires","domain","encodeURIComponent","split","find","substring","decodeURIComponent","indexEQ","index","document","getStoreFromWindow","store","self","setStoreToWindow","hashtable"],"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,KA4DA,OAhCAF,GAAAM,EAAAP,EAGAC,EAAAO,EAAAL,EAGAF,EAAAQ,EAAA,SAAAd,EAAAe,EAAAC,GACAV,EAAAW,EAAAjB,EAAAe,IACAG,OAAAC,eAAAnB,EAAAe,GACAK,cAAA,EACAC,YAAA,EACAC,IAAAN,KAMAV,EAAAiB,EAAA,SAAAtB,GACA,GAAAe,GAAAf,KAAAuB,WACA,WAA2B,MAAAvB,GAAA,SAC3B,WAAiC,MAAAA,GAEjC,OADAK,GAAAQ,EAAAE,EAAA,IAAAA,GACAA,GAIAV,EAAAW,EAAA,SAAAQ,EA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cesContent":["(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/******/ \t\t}\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// 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 = 2);\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 cookieStorage: false,\n sessionStorage: false,\n memoryStorage: true // fallback storage\n};\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.isAvailable = exports.configStorage = exports.WebStorage = exports.default = undefined;\n\nvar _webStorage = __webpack_require__(3);\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 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 } catch (e) {\n return false;\n }\n return true;\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.cookieStorage = isStorageAvailable('cookieStorage');\n _isAvailable.isAvailable.sessionStorage = isStorageAvailable('sessionStorage');\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/* 3 */\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__(4);\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 var fallback = storageType === 'sessionStorage' ? 'memoryStorage' : webStorageSettings.default;\n var msg = storageType + ' is not available. Falling back to ' + fallback;\n console.warn(msg); // eslint-disable-line\n return fallback;\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 * 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/* 4 */\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__(5);\n\nvar _cookieStorage2 = _interopRequireDefault(_cookieStorage);\n\nvar _memoryStorage = __webpack_require__(6);\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/* 5 */\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: {} // 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 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/* 6 */\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/******/ ]);\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 \t\t}\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// 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 = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 4fc57594dbc8eb12ca59","/**\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 cookieStorage: false,\n sessionStorage: false,\n memoryStorage: true, // fallback storage\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/is-available.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 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 } catch (e) {\n return false;\n }\n return true;\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.cookieStorage = isStorageAvailable('cookieStorage');\n isAvailable.sessionStorage = isStorageAvailable('sessionStorage');\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","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 const fallback = (storageType === 'sessionStorage' ?\n 'memoryStorage' : webStorageSettings.default);\n const msg = `${storageType} is not available. Falling back to ${fallback}`;\n console.warn(msg); // eslint-disable-line\n return fallback;\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 * 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 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","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"],"sourceRoot":""} \ No newline at end of file +{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///proxy-storage.min.js","webpack:///webpack/bootstrap 325029df45e386b03e14","webpack:///./src/utils.js","webpack:///./src/is-available.js","webpack:///./src/proxy-storage.js","webpack:///./src/web-storage.js","webpack:///./src/interceptors.js","webpack:///./src/proxy-mechanism.js","webpack:///./src/cookie-storage.js","webpack:///./src/format-metadata.js","webpack:///./src/expiration-date.js","webpack:///./src/memory-storage.js"],"names":["root","factory","exports","module","define","amd","this","modules","__webpack_require__","moduleId","installedModules","i","l","call","m","c","d","name","getter","o","Object","defineProperty","configurable","enumerable","get","n","__esModule","object","property","prototype","hasOwnProperty","p","s","isObject","value","toString","checkEmpty","key","Error","setProperty","obj","descriptor","writable","tryParse","parsed","JSON","parse","e","isAvailable","localStorage","cookieStorage","sessionStorage","memoryStorage","isStorageAvailable","storageType","storageObj","_webStorage","proxy","data","setItem","removeItem","storageAvailable","_isAvailable","webStorageSettings","default","configStorage","set","WebStorage","undefined","_webStorage2","storage","__storage__","keys","some","_classCallCheck","instance","Constructor","TypeError","copyKeys","forEach","_utils","fallback","msg","console","warn","_createClass","defineProperties","target","props","length","protoProps","staticProps","_interceptors","_interceptors2","_proxyMechanism","INSTANCES","BANNED_KEYS","cachedInstance","options","test","v","stringify","getItem","_this","clear","command","action","INTERCEPTORS","push","executeInterceptors","_len","arguments","args","Array","_key","shift","_typeof","reduce","val","transformed","concat","Symbol","iterator","constructor","_interopRequireDefault","_cookieStorage","_cookieStorage2","_memoryStorage","_memoryStorage2","window","findCookie","cookie","nameEQ","trim","indexOf","api","assign","path","$cookie","metadata","expires","Date","_expirationDate2","domain","secure","encodeURIComponent","_formatMetadata2","split","find","substring","decodeURIComponent","days","indexEQ","initialize","prop","index","_formatMetadata","_expirationDate","document","buildMetadataFor","formatMetadata","alterDate","opt","date","minutes","setMinutes","getMinutes","hours","setHours","getHours","setDate","getDate","months","setMonth","getMonth","years","setFullYear","getFullYear","buildExpiration","toUTCString","getStoreFromWindow","store","self","setStoreToWindow","hashtable"],"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,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eAAkBW,GAEtQtC,GAAQ8D,QW12BgBZ,CA1CxB,IAAA4B,GAAAxE,EAAA","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/******/ \t\t}\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// 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 = 2);\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.checkEmpty = checkEmpty;\nexports.setProperty = setProperty;\nexports.tryParse = tryParse;\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 * 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 * 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 * Try to parse a value from JSON.\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/* 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 cookieStorage: false,\n sessionStorage: false,\n memoryStorage: true // fallback storage\n};\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.isAvailable = exports.configStorage = exports.WebStorage = exports.default = undefined;\n\nvar _webStorage = __webpack_require__(3);\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 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 } catch (e) {\n return false;\n }\n return true;\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.cookieStorage = isStorageAvailable('cookieStorage');\n _isAvailable.isAvailable.sessionStorage = isStorageAvailable('sessionStorage');\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/* 3 */\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 _interceptors = __webpack_require__(4);\n\nvar _interceptors2 = _interopRequireDefault(_interceptors);\n\nvar _utils = __webpack_require__(0);\n\nvar _isAvailable = __webpack_require__(1);\n\nvar _proxyMechanism = __webpack_require__(5);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\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 * Keys not allowed for cookies.\n *\n * @type {RegExp}\n */\nvar BANNED_KEYS = /^(?:expires|max-age|path|domain|secure)$/i;\n\n/**\n * @private\n *\n * Copies all existing keys in the storage.\n *\n * @param {CookieStorage} instance: the object to where copy the keys\n * @param {object} storage: the storage mechanism\n * @return {object}\n */\nfunction copyKeys(instance, storage) {\n Object.keys(storage).forEach(function (key) {\n instance[key] = (0, _utils.tryParse)(storage[key]);\n });\n return instance;\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 var fallback = storageType === 'sessionStorage' ? 'memoryStorage' : webStorageSettings.default;\n var msg = storageType + ' is not available. Falling back to ' + fallback;\n console.warn(msg); // eslint-disable-line\n return fallback;\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 * 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 return copyKeys(cachedInstance, storage);\n }\n (0, _utils.setProperty)(this, '__storage__', storageType);\n // copies all existing keys in the storage mechanism\n INSTANCES[storageType] = copyKeys(this, storage);\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' && BANNED_KEYS.test(key)) {\n throw new Error('The key is a reserved word, therefore not allowed');\n }\n var v = (0, _interceptors2.default)('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 // null or undefined\n delete this[key];\n value = null;\n } else {\n value = (0, _utils.tryParse)(value);\n this[key] = value;\n }\n var v = (0, _interceptors2.default)('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 (0, _interceptors2.default)('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 (0, _interceptors2.default)('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.INTERCEPTORS && typeof action === 'function') {\n _interceptors.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/* 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 = executeInterceptors;\n/**\n * Stores the interceptors for WebStorage methods.\n *\n * @type {object}\n */\nvar INTERCEPTORS = exports.INTERCEPTORS = {\n setItem: [],\n getItem: [],\n removeItem: [],\n clear: []\n};\n\n/**\n * Executes the interceptors for a WebStorage method and allows\n * 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/* 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__(6);\n\nvar _cookieStorage2 = _interopRequireDefault(_cookieStorage);\n\nvar _memoryStorage = __webpack_require__(9);\n\nvar _memoryStorage2 = _interopRequireDefault(_memoryStorage);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\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: (0, _cookieStorage2.default)(),\n memoryStorage: (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});\n\nvar _utils = __webpack_require__(0);\n\nvar _formatMetadata = __webpack_require__(7);\n\nvar _formatMetadata2 = _interopRequireDefault(_formatMetadata);\n\nvar _expirationDate = __webpack_require__(8);\n\nvar _expirationDate2 = _interopRequireDefault(_expirationDate);\n\nfunction _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }\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: {} // metadata associated to the cookies\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 = (0, _expirationDate2.default)(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) + (0, _formatMetadata2.default)(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;\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 };\n\n return initialize(api);\n}\n\n/**\n * @private\n *\n * Copy the current items in the cookie storage.\n *\n * @param {object} api: the storage mechanism to initialize\n * @return {object}\n */\nfunction initialize(api) {\n // sets API members to read-only and non-enumerable\n for (var prop in api) {\n // eslint-disable-line\n (0, _utils.setProperty)(api, prop);\n }\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 return api;\n}\n\n/**\n * @public API\n */\nexports.default = cookieStorage;\n\n/***/ }),\n/* 7 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = formatMetadata;\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 * 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/* 8 */\n/***/ (function(module, exports, __webpack_require__) {\n\n\"use strict\";\n\n\nObject.defineProperty(exports, \"__esModule\", {\n value: true\n});\nexports.default = buildExpiration;\n/**\n * @private\n *\n * Adds or subtracts date portions to the given date and returns the new date.\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 * Builds the expiration for the cookie.\n *\n * @param {Date|object} date: the expiration date\n * @return {string}\n */\nfunction buildExpiration(date) {\n var expires = date instanceof Date ? alterDate({ date: date }) : alterDate(date);\n return expires.toUTCString();\n}\n\n/***/ }),\n/* 9 */\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\nvar _utils = __webpack_require__(0);\n\n/**\n * @private\n *\n * Gets the hashtable-store from the current window.\n *\n * @return {object}\n */\nfunction getStoreFromWindow() {\n var store = void 0;\n try {\n store = JSON.parse(window.self.name);\n } catch (e) {\n return {};\n }\n if (store && (typeof store === 'undefined' ? 'undefined' : _typeof(store)) === 'object') return store;\n return {};\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 };\n\n return initialize(api, hashtable);\n}\n\n/**\n * @private\n *\n * Copy the current items in the cookie storage.\n *\n * @param {object} api: the storage mechanism to initialize\n * @param {object} hashtable: store from the window tab\n * @return {object}\n */\nfunction initialize(api, hashtable) {\n // sets API members to read-only and non-enumerable\n for (var prop in api) {\n // eslint-disable-line\n (0, _utils.setProperty)(api, prop);\n }\n // copies all existing elements in the storage\n Object.assign(api, hashtable);\n return api;\n}\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 \t\t}\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// 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 = 2);\n\n\n\n// WEBPACK FOOTER //\n// webpack/bootstrap 325029df45e386b03e14","/**\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 * 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 * 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 * Try to parse a value from JSON.\n *\n * @param {string} value: the value to parse\n * @return {any}\n */\nexport function 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\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 cookieStorage: false,\n sessionStorage: false,\n memoryStorage: true, // fallback storage\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/is-available.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 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 } catch (e) {\n return false;\n }\n return true;\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.cookieStorage = isStorageAvailable('cookieStorage');\n isAvailable.sessionStorage = isStorageAvailable('sessionStorage');\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","import executeInterceptors, {INTERCEPTORS} from './interceptors';\nimport {setProperty, checkEmpty, tryParse} from './utils';\nimport {isAvailable} from './is-available';\nimport {proxy} from './proxy-mechanism';\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 * Keys not allowed for cookies.\n *\n * @type {RegExp}\n */\nconst BANNED_KEYS = /^(?:expires|max-age|path|domain|secure)$/i;\n\n/**\n * @private\n *\n * Copies all existing keys in the storage.\n *\n * @param {CookieStorage} instance: the object to where copy the keys\n * @param {object} storage: the storage mechanism\n * @return {object}\n */\nfunction copyKeys(instance, storage) {\n Object.keys(storage).forEach((key) => {\n instance[key] = tryParse(storage[key]);\n });\n return instance;\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 const fallback =\n storageType === 'sessionStorage' ? 'memoryStorage' : webStorageSettings.default;\n const msg = `${storageType} is not available. Falling back to ${fallback}`;\n console.warn(msg); // eslint-disable-line\n return fallback;\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 * 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 return copyKeys(cachedInstance, storage);\n }\n setProperty(this, '__storage__', storageType);\n // copies all existing keys in the storage mechanism\n INSTANCES[storageType] = copyKeys(this, storage);\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' && BANNED_KEYS.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) { // null or undefined\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","/**\n * Stores the interceptors for WebStorage methods.\n *\n * @type {object}\n */\nexport const INTERCEPTORS = {\n setItem: [],\n getItem: [],\n removeItem: [],\n clear: [],\n};\n\n/**\n * Executes the interceptors for a WebStorage method and allows\n * the transformation in chain of the value passed through.\n *\n * @param {string} command: name of the method to intercept\n * @return {any}\n */\nexport default function 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\n// WEBPACK FOOTER //\n// ./src/interceptors.js","import cookieStorage from './cookie-storage';\nimport memoryStorage from './memory-storage';\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: cookieStorage(),\n memoryStorage: memoryStorage(),\n};\n\n\n\n// WEBPACK FOOTER //\n// ./src/proxy-mechanism.js","import {isObject, setProperty} from './utils';\nimport formatMetadata from './format-metadata';\nimport buildExpiration from './expiration-date';\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 * 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 */\nfunction 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 = buildExpiration(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;\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\n return initialize(api);\n}\n\n/**\n * @private\n *\n * Copy the current items in the cookie storage.\n *\n * @param {object} api: the storage mechanism to initialize\n * @return {object}\n */\nfunction initialize(api) {\n // sets API members to read-only and non-enumerable\n for (let prop in api) { // eslint-disable-line\n setProperty(api, prop);\n }\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 return api;\n}\n\n/**\n * @public API\n */\nexport default cookieStorage;\n\n\n\n// WEBPACK FOOTER //\n// ./src/cookie-storage.js","/**\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 * Builds the whole string for the cookie metadata.\n *\n * @param {object} data: metadata of the cookie\n * @return {string}\n */\nexport default function 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\n// WEBPACK FOOTER //\n// ./src/format-metadata.js","/**\n * @private\n *\n * Adds or subtracts date portions to the given date and returns the new date.\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(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 * Builds the expiration for the cookie.\n *\n * @param {Date|object} date: the expiration date\n * @return {string}\n */\nexport default function buildExpiration(date) {\n const expires = (date instanceof Date ?\n alterDate({date}) :\n alterDate(date));\n return expires.toUTCString();\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/expiration-date.js","import {setProperty} from './utils';\n\n/**\n * @private\n *\n * Gets the hashtable-store from the current window.\n *\n * @return {object}\n */\nfunction getStoreFromWindow() {\n let store;\n try {\n store = JSON.parse(window.self.name);\n } catch (e) {\n return {};\n }\n if (store && typeof store === 'object') return store;\n return {};\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\n return initialize(api, hashtable);\n}\n\n/**\n * @private\n *\n * Copy the current items in the cookie storage.\n *\n * @param {object} api: the storage mechanism to initialize\n * @param {object} hashtable: store from the window tab\n * @return {object}\n */\nfunction initialize(api, hashtable) {\n // sets API members to read-only and non-enumerable\n for (let prop in api) { // eslint-disable-line\n setProperty(api, prop);\n }\n // copies all existing elements in the storage\n Object.assign(api, hashtable);\n return api;\n}\n\n\n\n// WEBPACK FOOTER //\n// ./src/memory-storage.js"],"sourceRoot":""} \ No newline at end of file diff --git a/package.json b/package.json index 66594e4..68a5b5d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "proxy-storage", - "version": "2.2.0", + "version": "2.3.0", "description": "Normalizes the API for cookies, and localStorage/sessionStorage", "author": "David Rivera ", "main": "dist/proxy-storage.js", @@ -36,14 +36,14 @@ "devDependencies": { "babel-core": "^6.25.0", "babel-eslint": "^7.2.3", - "babel-loader": "^7.1.0", + "babel-loader": "^7.1.1", "babel-preset-es2015": "^6.24.1", "babel-preset-stage-2": "^6.24.1", "clean-webpack-plugin": "^0.1.16", "eslint": "^4.1.1", "eslint-config-airbnb-base": "^11.2.0", "eslint-loader": "^1.8.0", - "eslint-plugin-import": "^2.6.0", + "eslint-plugin-import": "^2.6.1", "webpack": "^3.0.0" }, "babel": { diff --git a/src/cookie-storage.js b/src/cookie-storage.js index f75f6a8..cb64338 100644 --- a/src/cookie-storage.js +++ b/src/cookie-storage.js @@ -1,4 +1,6 @@ -import {alterDate, isObject} from './utils'; +import {isObject, setProperty} from './utils'; +import formatMetadata from './format-metadata'; +import buildExpiration from './expiration-date'; /** * @private @@ -18,54 +20,6 @@ const $cookie = { data: {}, // metadata associated to the cookies }; -/** - * @private - * - * Builds the expiration for the cookie. - * - * @see utils.alterDate(options) - * - * @param {Date|object} date: the expiration date - * @return {string} - */ -function buildExpirationString(date) { - const expires = (date instanceof Date ? - alterDate({date}) : - alterDate(date) - ); - return expires.toUTCString(); -} - -/** - * @private - * - * Builds the string for the cookie metadata. - * - * @param {string} key: name of the metadata - * @param {object} data: metadata of the cookie - * @return {string} - */ -function buildMetadataFor(key, data) { - if (!data[key]) return ''; - 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}`; -} - /** * @private * @@ -88,7 +42,7 @@ function findCookie(cookie) { * * @return {object} */ -export default function cookieStorage() { +function cookieStorage() { const api = { setItem(key, value, options) { @@ -97,7 +51,7 @@ export default function cookieStorage() { $cookie.data[key] = {path: options.path}; const metadata = $cookie.data[key]; if (isObject(options.expires) || options.expires instanceof Date) { - metadata.expires = buildExpirationString(options.expires); + metadata.expires = buildExpiration(options.expires); } if (options.domain && typeof options.domain === 'string') { metadata.domain = options.domain.trim(); @@ -129,7 +83,7 @@ export default function cookieStorage() { }, clear() { - let key, indexEQ; // eslint-disable-line + let key, indexEQ; $cookie.get().split(';').forEach((cookie) => { indexEQ = cookie.indexOf('='); if (indexEQ > -1) { @@ -139,19 +93,35 @@ export default function cookieStorage() { } }); }, - - initialize() { - // copies all existing elements in the storage - $cookie.get().split(';').forEach((cookie) => { - const index = cookie.indexOf('='); - const key = cookie.substring(0, index).trim(); - const value = cookie.substring(index + 1).trim(); - if (key) api[key] = decodeURIComponent(value); - }); - // this method is removed after being invoked - // because is not part of the Web Storage interface - delete api.initialize; - }, }; + + return initialize(api); +} + +/** + * @private + * + * Copy the current items in the cookie storage. + * + * @param {object} api: the storage mechanism to initialize + * @return {object} + */ +function initialize(api) { + // sets API members to read-only and non-enumerable + for (let prop in api) { // eslint-disable-line + setProperty(api, prop); + } + // copies all existing elements in the storage + $cookie.get().split(';').forEach((cookie) => { + const index = cookie.indexOf('='); + const key = cookie.substring(0, index).trim(); + const value = cookie.substring(index + 1).trim(); + if (key) api[key] = decodeURIComponent(value); + }); return api; } + +/** + * @public API + */ +export default cookieStorage; diff --git a/src/expiration-date.js b/src/expiration-date.js new file mode 100644 index 0000000..8e0166f --- /dev/null +++ b/src/expiration-date.js @@ -0,0 +1,38 @@ +/** + * @private + * + * Adds or subtracts date portions to the given date and returns the new date. + * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2 + * + * @param {object} options: It contains the date parts to add or remove, and can have the following properties: + * - {Date} date: if provided, this date will be affected, otherwise the current date will be used. + * - {number} minutes: minutes to add/subtract + * - {number} hours: hours to add/subtract + * - {number} days: days to add/subtract + * - {number} months: months to add/subtract + * - {number} years: years to add/subtract + * @return {Date} + */ +function alterDate(options = {}) { + const opt = Object.assign({}, options); + const d = opt.date instanceof Date ? opt.date : new Date(); + if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes); + if (+opt.hours) d.setHours(d.getHours() + opt.hours); + if (+opt.days) d.setDate(d.getDate() + opt.days); + if (+opt.months) d.setMonth(d.getMonth() + opt.months); + if (+opt.years) d.setFullYear(d.getFullYear() + opt.years); + return d; +} + +/** + * Builds the expiration for the cookie. + * + * @param {Date|object} date: the expiration date + * @return {string} + */ +export default function buildExpiration(date) { + const expires = (date instanceof Date ? + alterDate({date}) : + alterDate(date)); + return expires.toUTCString(); +} diff --git a/src/format-metadata.js b/src/format-metadata.js new file mode 100644 index 0000000..586ac96 --- /dev/null +++ b/src/format-metadata.js @@ -0,0 +1,27 @@ +/** + * @private + * + * Builds the string for the cookie metadata. + * + * @param {string} key: name of the metadata + * @param {object} data: metadata of the cookie + * @return {string} + */ +function buildMetadataFor(key, data) { + if (!data[key]) return ''; + return `;${key}=${data[key]}`; +} + +/** + * Builds the whole string for the cookie metadata. + * + * @param {object} data: metadata of the cookie + * @return {string} + */ +export default 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}`; +} diff --git a/src/interceptors.js b/src/interceptors.js new file mode 100644 index 0000000..09f7315 --- /dev/null +++ b/src/interceptors.js @@ -0,0 +1,32 @@ +/** + * Stores the interceptors for WebStorage methods. + * + * @type {object} + */ +export const INTERCEPTORS = { + setItem: [], + getItem: [], + removeItem: [], + clear: [], +}; + +/** + * Executes the interceptors for a WebStorage method and allows + * the transformation in chain of the value passed through. + * + * @param {string} command: name of the method to intercept + * @return {any} + */ +export default function executeInterceptors(command, ...args) { + const key = args.shift(); + let value = args.shift(); + if (value && typeof value === 'object') { + // clone the object to prevent mutations + value = JSON.parse(JSON.stringify(value)); + } + return INTERCEPTORS[command].reduce((val, action) => { + const transformed = action(key, val, ...args); + if (transformed == null) return val; + return transformed; + }, value); +} diff --git a/src/memory-storage.js b/src/memory-storage.js index a8ed362..ff88725 100644 --- a/src/memory-storage.js +++ b/src/memory-storage.js @@ -1,3 +1,5 @@ +import {setProperty} from './utils'; + /** * @private * @@ -5,13 +7,15 @@ * * @return {object} */ -function getStoreFromWindow() { // eslint-disable-line +function getStoreFromWindow() { + let store; try { - const store = JSON.parse(window.self.name); - if (store && typeof store === 'object') return store; + store = JSON.parse(window.self.name); } catch (e) { return {}; } + if (store && typeof store === 'object') return store; + return {}; } /** @@ -59,14 +63,26 @@ export default function memoryStorage() { Object.keys(hashtable).forEach(key => delete hashtable[key]); setStoreToWindow(hashtable); }, - - initialize() { - // copies all existing elements in the storage - Object.assign(api, hashtable); - // this method is removed after being invoked - // because is not part of the Web Storage interface - delete api.initialize; - }, }; + + return initialize(api, hashtable); +} + +/** + * @private + * + * Copy the current items in the cookie storage. + * + * @param {object} api: the storage mechanism to initialize + * @param {object} hashtable: store from the window tab + * @return {object} + */ +function initialize(api, hashtable) { + // sets API members to read-only and non-enumerable + for (let prop in api) { // eslint-disable-line + setProperty(api, prop); + } + // copies all existing elements in the storage + Object.assign(api, hashtable); return api; } diff --git a/src/proxy-mechanism.js b/src/proxy-mechanism.js index 0913700..8f843a1 100644 --- a/src/proxy-mechanism.js +++ b/src/proxy-mechanism.js @@ -1,26 +1,5 @@ import cookieStorage from './cookie-storage'; import memoryStorage from './memory-storage'; -import {setProperty} from './utils'; - -/** - * @private - * - * Copy the current items in the storage mechanism. - * - * @param {object} api: the storage mechanism to initialize - * @return {object} - */ -function initApi(api) { - if (!api.initialize) return api; - // sets API members to read-only and non-enumerable - for (let prop in api) { // eslint-disable-line - if (prop !== 'initialize') { - setProperty(api, prop); - } - } - api.initialize(); - return api; -} /** * @public @@ -36,6 +15,6 @@ function initApi(api) { export const proxy = { localStorage: window.localStorage, sessionStorage: window.sessionStorage, - cookieStorage: initApi(cookieStorage()), - memoryStorage: initApi(memoryStorage()), + cookieStorage: cookieStorage(), + memoryStorage: memoryStorage(), }; diff --git a/src/utils.js b/src/utils.js index b46c12b..6195289 100644 --- a/src/utils.js +++ b/src/utils.js @@ -9,28 +9,16 @@ export function isObject(value) { } /** - * Adds or subtracts date portions to the given date and returns the new date. - * - * @see https://gist.github.com/jherax/bbc43e479a492cc9cbfc7ccc20c53cd2 + * Validates if the key is not empty. + * (null, undefined or empty string) * - * @param {object} options: It contains the date parts to add or remove, and can have the following properties: - * - {Date} date: if provided, this date will be affected, otherwise the current date will be used. - * - {number} minutes: minutes to add/subtract - * - {number} hours: hours to add/subtract - * - {number} days: days to add/subtract - * - {number} months: months to add/subtract - * - {number} years: years to add/subtract - * @return {Date} + * @param {string} key: keyname of an element in the storage mechanism + * @return {void} */ -export function alterDate(options = {}) { - const opt = Object.assign({}, options); - const d = opt.date instanceof Date ? opt.date : new Date(); - if (+opt.minutes) d.setMinutes(d.getMinutes() + opt.minutes); - if (+opt.hours) d.setHours(d.getHours() + opt.hours); - if (+opt.days) d.setDate(d.getDate() + opt.days); - if (+opt.months) d.setMonth(d.getMonth() + opt.months); - if (+opt.years) d.setFullYear(d.getFullYear() + opt.years); - return d; +export function checkEmpty(key) { + if (key == null || key === '') { + throw new Error('The key provided can not be empty'); + } } /** @@ -54,14 +42,17 @@ export function setProperty(obj, name, value) { } /** - * Validates if the key is not empty. - * (null, undefined or empty string) + * Try to parse a value from JSON. * - * @param {string} key: keyname of an element in the storage mechanism - * @return {void} + * @param {string} value: the value to parse + * @return {any} */ -export function checkEmpty(key) { - if (key == null || key === '') { - throw new Error('The key provided can not be empty'); +export function tryParse(value) { + let parsed; + try { + parsed = JSON.parse(value); + } catch (e) { + parsed = value; } + return parsed; } diff --git a/src/web-storage.js b/src/web-storage.js index 6b3635a..f7fa90b 100644 --- a/src/web-storage.js +++ b/src/web-storage.js @@ -1,6 +1,7 @@ -import {proxy} from './proxy-mechanism'; -import {setProperty, checkEmpty} from './utils'; +import executeInterceptors, {INTERCEPTORS} from './interceptors'; +import {setProperty, checkEmpty, tryParse} from './utils'; import {isAvailable} from './is-available'; +import {proxy} from './proxy-mechanism'; /** * @private @@ -9,21 +10,7 @@ import {isAvailable} from './is-available'; * * @type {object} */ -const _instances = {}; - -/** - * @private - * - * Stores the interceptors for WebStorage methods. - * - * @type {object} - */ -const _interceptors = { - setItem: [], - getItem: [], - removeItem: [], - clear: [], -}; +const INSTANCES = {}; /** * @private @@ -32,62 +19,22 @@ const _interceptors = { * * @type {RegExp} */ -const bannedKeys = /^(?:expires|max-age|path|domain|secure)$/i; - -/** - * @private - * - * Executes the interceptors for a WebStorage method and - * allows the transformation in chain of the value passed through. - * - * @param {string} command: name of the method to intercept - * @return {any} - */ -function executeInterceptors(command, ...args) { - const key = args.shift(); - let value = args.shift(); - if (value && typeof value === 'object') { - // clone the object to prevent mutations - value = JSON.parse(JSON.stringify(value)); - } - return _interceptors[command].reduce((val, action) => { - const transformed = action(key, val, ...args); - if (transformed == null) return val; - return transformed; - }, value); -} - -/** - * @private - * - * Try to parse a value - * - * @param {string} value: the value to parse - * @return {any} - */ -function tryParse(value) { - let parsed; - try { - parsed = JSON.parse(value); - } catch (e) { - parsed = value; - } - return parsed; -} +const BANNED_KEYS = /^(?:expires|max-age|path|domain|secure)$/i; /** * @private * - * Copies all existing keys in the WebStorage instance. + * Copies all existing keys in the storage. * - * @param {WebStorage} instance: the instance to where copy the keys + * @param {CookieStorage} instance: the object to where copy the keys * @param {object} storage: the storage mechanism - * @return {void} + * @return {object} */ function copyKeys(instance, storage) { Object.keys(storage).forEach((key) => { instance[key] = tryParse(storage[key]); }); + return instance; } /** @@ -112,8 +59,8 @@ const webStorageSettings = { */ function storageAvailable(storageType) { if (webStorageSettings.isAvailable[storageType]) return storageType; - const fallback = (storageType === 'sessionStorage' ? - 'memoryStorage' : webStorageSettings.default); + const fallback = + storageType === 'sessionStorage' ? 'memoryStorage' : webStorageSettings.default; const msg = `${storageType} is not available. Falling back to ${fallback}`; console.warn(msg); // eslint-disable-line return fallback; @@ -147,15 +94,13 @@ class WebStorage { // if the storage is not available, sets the default storageType = storageAvailable(storageType); // keeps only one instance by storageType (singleton) - const cachedInstance = _instances[storageType]; + const cachedInstance = INSTANCES[storageType]; if (cachedInstance) { - copyKeys(cachedInstance, storage); - return cachedInstance; + return copyKeys(cachedInstance, storage); } setProperty(this, '__storage__', storageType); // copies all existing keys in the storage mechanism - copyKeys(this, storage); - _instances[storageType] = this; + INSTANCES[storageType] = copyKeys(this, storage); } /** @@ -171,7 +116,7 @@ class WebStorage { setItem(key, value, options) { checkEmpty(key); const storageType = this.__storage__; - if (storageType === 'cookieStorage' && bannedKeys.test(key)) { + if (storageType === 'cookieStorage' && BANNED_KEYS.test(key)) { throw new Error('The key is a reserved word, therefore not allowed'); } const v = executeInterceptors('setItem', key, value, options); @@ -197,7 +142,7 @@ class WebStorage { getItem(key) { checkEmpty(key); let value = proxy[this.__storage__].getItem(key); - if (value == null) { + if (value == null) { // null or undefined delete this[key]; value = null; } else { @@ -261,8 +206,8 @@ class WebStorage { * @memberOf WebStorage */ static interceptors(command, action) { - if (command in _interceptors && typeof action === 'function') { - _interceptors[command].push(action); + if (command in INTERCEPTORS && typeof action === 'function') { + INTERCEPTORS[command].push(action); } } } diff --git a/yarn.lock b/yarn.lock index e048d3e..6ef951c 100644 --- a/yarn.lock +++ b/yarn.lock @@ -346,9 +346,9 @@ babel-helpers@^6.24.1: babel-runtime "^6.22.0" babel-template "^6.24.1" -babel-loader@^7.1.0: - version "7.1.0" - resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.0.tgz#3fbf2581f085774bd9642dca9990e6d6c1491144" +babel-loader@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/babel-loader/-/babel-loader-7.1.1.tgz#b87134c8b12e3e4c2a94e0546085bc680a2b8488" dependencies: find-cache-dir "^1.0.0" loader-utils "^1.0.2" @@ -1295,13 +1295,12 @@ eslint-config-airbnb-base@^11.2.0: version "11.2.0" resolved "https://registry.yarnpkg.com/eslint-config-airbnb-base/-/eslint-config-airbnb-base-11.2.0.tgz#19a9dc4481a26f70904545ec040116876018f853" -eslint-import-resolver-node@^0.2.0: - version "0.2.3" - resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.2.3.tgz#5add8106e8c928db2cba232bcd9efa846e3da16c" +eslint-import-resolver-node@^0.3.1: + version "0.3.1" + resolved "https://registry.yarnpkg.com/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.1.tgz#4422574cde66a9a7b099938ee4d508a199e0e3cc" dependencies: - debug "^2.2.0" - object-assign "^4.0.1" - resolve "^1.1.6" + debug "^2.6.8" + resolve "^1.2.0" eslint-loader@^1.8.0: version "1.8.0" @@ -1320,15 +1319,15 @@ eslint-module-utils@^2.0.0: debug "2.2.0" pkg-dir "^1.0.0" -eslint-plugin-import@^2.6.0: - version "2.6.0" - resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.6.0.tgz#2a4bbad36a078e052a3c830ce3dfbd6b8a12c6e5" +eslint-plugin-import@^2.6.1: + version "2.6.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-import/-/eslint-plugin-import-2.6.1.tgz#f580be62bb809421d46e338372764afcc9f59bf6" dependencies: builtin-modules "^1.1.1" contains-path "^0.1.0" debug "^2.6.8" doctrine "1.5.0" - eslint-import-resolver-node "^0.2.0" + eslint-import-resolver-node "^0.3.1" eslint-module-utils "^2.0.0" has "^1.0.1" lodash.cond "^4.3.0" @@ -2442,6 +2441,10 @@ path-is-inside@^1.0.1, path-is-inside@^1.0.2: version "1.0.2" resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53" +path-parse@^1.0.5: + version "1.0.5" + resolved "https://registry.yarnpkg.com/path-parse/-/path-parse-1.0.5.tgz#3c1adf871ea9cd6c9431b6ea2bd74a0ff055c4c1" + path-type@^1.0.0: version "1.1.0" resolved "https://registry.yarnpkg.com/path-type/-/path-type-1.1.0.tgz#59c44f7ee491da704da415da5a4070ba4f8fe441" @@ -2732,9 +2735,11 @@ resolve-from@^1.0.0: version "1.0.1" resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226" -resolve@^1.1.6: - version "1.1.7" - resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b" +resolve@^1.2.0: + version "1.3.3" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.3.3.tgz#655907c3469a8680dc2de3a275a8fdd69691f0e5" + dependencies: + path-parse "^1.0.5" restore-cursor@^2.0.0: version "2.0.0"