blob: 9a70e21e33fc7a42c9a2474a3f645dcf7e798bcd [file] [log] [blame]
{"remainingRequest":"/Users/jaslan/Development/nifi-fds/angular-url-loader.js!/Users/jaslan/Development/nifi-fds/node_modules/babel-loader/lib/index.js??ref--5-2!/Users/jaslan/Development/nifi-fds/platform/core/common/services/fds-storage.service.js","dependencies":[{"path":"/Users/jaslan/Development/nifi-fds/platform/core/common/services/fds-storage.service.js","mtime":1562689731033},{"path":"/Users/jaslan/Development/nifi-fds/node_modules/cache-loader/dist/cjs.js","mtime":499162500000},{"path":"/Users/jaslan/Development/nifi-fds/angular-url-loader.js","mtime":1562689731025},{"path":"/Users/jaslan/Development/nifi-fds/node_modules/babel-loader/lib/index.js","mtime":499162500000}],"contextDependencies":[],"result":["/*\n * Licensed to the Apache Software Foundation (ASF) under one or more\n * contributor license agreements. See the NOTICE file distributed with\n * this work for additional information regarding copyright ownership.\n * The ASF licenses this file to You under the Apache License, Version 2.0\n * (the \"License\"); you may not use this file except in compliance with\n * the License. You may obtain a copy of the License at\n *\n * http://www.apache.org/licenses/LICENSE-2.0\n *\n * Unless required by applicable law or agreed to in writing, software\n * distributed under the License is distributed on an \"AS IS\" BASIS,\n * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n * See the License for the specific language governing permissions and\n * limitations under the License.\n */\n// Store items for two days before being eligible for removal.\nvar MILLIS_PER_DAY = 86400000;\nvar TWO_DAYS = MILLIS_PER_DAY * 2;\n\nvar isUndefined = function isUndefined(obj) {\n return typeof obj === 'undefined';\n};\n\nvar isNull = function isNull(obj) {\n return obj === null;\n};\n\nvar isDefinedAndNotNull = function isDefinedAndNotNull(obj) {\n return !isUndefined(obj) && !isNull(obj);\n};\n/**\n * Checks the expiration for the specified entry.\n *\n * @param {object} entry\n * @returns {boolean}\n */\n\n\nvar checkExpiration = function checkExpiration(entry) {\n if (isDefinedAndNotNull(entry.expires)) {\n // get the expiration\n var expires = new Date(entry.expires);\n var now = new Date(); // return whether the expiration date has passed\n\n return expires.valueOf() < now.valueOf();\n }\n\n return false;\n};\n/**\n * Gets an enty for the key. The entry expiration is not checked.\n *\n * @param {string} key\n */\n\n\nvar getEntry = function getEntry(key) {\n try {\n // parse the entry\n var entry = JSON.parse(localStorage.getItem(key)); // ensure the entry and item are present\n\n if (isDefinedAndNotNull(entry)) {\n return entry;\n }\n\n return null;\n } catch (e) {\n return null;\n }\n};\n/**\n * FdsStorageService constructor.\n * @constructor\n */\n\n\nfunction FdsStorageService() {}\n\nFdsStorageService.prototype = {\n constructor: FdsStorageService,\n\n /**\n * Initializes the storage. Items will be persisted for two days. Once the scripts runs\n * thereafter, all eligible items will be removed. This strategy does not support persistence.\n */\n init: function init() {\n for (var i = 0; i < localStorage.length; i++) {\n try {\n // get the next item\n var key = localStorage.key(i); // attempt to get the item which will expire if necessary\n\n this.getItem(key);\n } catch (e) {// Do nothing\n }\n }\n },\n\n /**\n * Stores the specified item.\n *\n * @param {string} key\n * @param {object} item\n * @param {integer} expires\n */\n setItem: function setItem(key, item, expires) {\n // calculate the expiration\n expires = isDefinedAndNotNull(expires) ? expires : new Date().valueOf() + TWO_DAYS; // create the entry\n\n var entry = {\n expires: expires,\n item: item\n }; // store the item\n\n localStorage.setItem(key, JSON.stringify(entry));\n },\n\n /**\n * Returns whether there is an entry for this key. This will not check the expiration. If\n * the entry is expired, it will return null on a subsequent getItem invocation.\n *\n * @param {string} key\n * @returns {boolean}\n */\n hasItem: function hasItem(key) {\n return getEntry(key) !== null;\n },\n\n /**\n * Gets the item with the specified key. If an item with this key does\n * not exist, null is returned. If an item exists but cannot be parsed\n * or is malformed/unrecognized, null is returned.\n *\n * @param {type} key\n */\n getItem: function getItem(key) {\n var entry = getEntry(key);\n\n if (entry === null) {\n return null;\n } // if the entry is expired, drop it and return null\n\n\n if (checkExpiration(entry)) {\n this.removeItem(key);\n return null;\n } // if the entry has the specified field return its value\n\n\n if (isDefinedAndNotNull(entry['item'])) {\n return entry['item'];\n }\n\n return null;\n },\n\n /**\n * Gets the expiration for the specified item. This will not check the expiration. If\n * the entry is expired, it will return null on a subsequent getItem invocation.\n *\n * @param {string} key\n * @returns {integer}\n */\n getItemExpiration: function getItemExpiration(key) {\n var entry = getEntry(key);\n\n if (entry === null) {\n return null;\n } // if the entry has the specified field return its value\n\n\n if (isDefinedAndNotNull(entry['expires'])) {\n return entry['expires'];\n }\n\n return null;\n },\n\n /**\n * Extracts the subject from the specified jwt. If the jwt is not as expected\n * an empty string is returned.\n *\n * @param {string} jwt\n * @returns {string}\n */\n getJwtPayload: function getJwtPayload(jwt) {\n if (isDefinedAndNotNull(jwt)) {\n var segments = jwt.split(/\\./);\n\n if (segments.length !== 3) {\n return '';\n }\n\n var rawPayload = window.atob(segments[1]);\n var payload = JSON.parse(rawPayload);\n\n if (isDefinedAndNotNull(payload)) {\n return payload;\n }\n\n return null;\n }\n\n return null;\n },\n\n /**\n * Removes the item with the specified key.\n *\n * @param {type} key\n */\n removeItem: function removeItem(key) {\n localStorage.removeItem(key);\n }\n};\nFdsStorageService.parameters = [];\nexport default FdsStorageService;"]}