{"version": 3,"file": "heartbeat.min.js","sources":[ "webpack://heartbeat/webpack/universalModuleDefinition", "webpack://heartbeat/webpack/bootstrap", "webpack://heartbeat/./src/tools.js", "webpack://heartbeat/./src/heartbeat.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(\"heartbeat\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"heartbeat\"] = factory();\n\telse\n\t\troot[\"heartbeat\"] = factory();\n})(window, function() {\nreturn ", " \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// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\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\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n", "export function getValueFromQuery(key) {\n let queryString = window.location.search;\n if (queryString[0] === '?') {\n queryString = queryString.substring(1);\n }\n const query = queryString.split('&');\n let i;\n for (i = 0; i < query.length; i += 1) {\n const keyval = query[i].split('=');\n if (keyval[0] === key) {\n return keyval[1];\n }\n }\n return '';\n}\n\nexport function getPlidFromQuery() {\n return getValueFromQuery('plid');\n}\n\nexport function getSubdomain() {\n const { hostname } = window.location;\n const topHost = getHost();\n return hostname.replace(`.${topHost}`, '');\n}\n\nexport function getHost() {\n const sliceIndex = window.location.hostname.includes('co.uk') ? -3 : -2;\n return window.location.hostname.split('.').slice(sliceIndex).join('.');\n}\n\nexport function getPath() {\n return encodeURIComponent(window.location.pathname + window.location.search);\n}\n\nexport function getPort() {\n return window.location.port;\n}\n\nexport function buildRedirect() {\n const app = getSubdomain();\n const host = getHost();\n const path = getPath();\n const port = getPort();\n const plid = getPlidFromQuery();\n let ssoUrl = `https://sso.${host}/logout?realm=idp&app=${app}&path=${path}&to_generic=true`;\n if (port) {\n ssoUrl += `&port=${port}`;\n }\n if (plid) {\n if (Number(plid) !== 1) {\n ssoUrl += `&plid=${plid}`;\n }\n }\n return ssoUrl;\n}\n\nexport function getCookie(name, defaultValue = '') {\n const cookieArray = document.cookie.split(';');\n for (let i = 0; i < cookieArray.length; i++) {\n const cookieObj = cookieArray[i].split('=');\n const key = cookieObj[0].trim();\n if (key === name) {\n return decodeURIComponent(cookieObj[1]);\n }\n }\n return defaultValue;\n}\n\nexport function writeCookie(name, value, domain, maxAge = 31536000) {\n const cookieValue = encodeURIComponent(value);\n const docCookie = `${name}=${cookieValue};domain=${domain};max-age=${maxAge};path=/`;\n document.cookie = docCookie;\n return docCookie;\n}\n", "import * as tools from './tools';\n\nexport function handleVatResult(result, host) {\n if (result.status === 401) {\n const ssoRedirect = tools.buildRedirect();\n window.location.assign(ssoRedirect);\n } else if (result.status === 201) {\n const currentTime = Date.now();\n tools.writeCookie('info_idp_vat_time', currentTime, host);\n }\n return result;\n}\n\nexport function checkVat() {\n const timestamp = Number(tools.getCookie('info_idp_vat_time', 0));\n const now = Date.now();\n const delta = now - timestamp;\n const fourMinsInSeconds = 60 * 1000 * 4;\n\n if (delta >= fourMinsInSeconds) {\n const data = { infotoken: 'true', realm: 'idp' };\n const headers = {\n 'Accept': 'application/json',\n 'Content-Type': 'application/json'\n };\n const fetchArgs = { method: 'POST', headers: headers, body: JSON.stringify(data), credentials: 'include' };\n const host = tools.getHost();\n return fetch(`https://sso.${host}/v1/api/token/ui_heartbeat`, fetchArgs).then((response) => {return handleVatResult(response, host);});\n }\n}\n\nexport function main() {\n if (!window.disableHeartbeat) {\n const loginInfoCookie = tools.getCookie('info_idp');\n if (loginInfoCookie) {\n _handleHeartbeat(loginInfoCookie);\n }\n }\n}\n\nfunction _handleHeartbeat(loginInfoCookie) {\n const loginInfo = JSON.parse(loginInfoCookie);\n const authType = loginInfo.auth;\n if (authType === 'basic') {\n const realm = loginInfo.typ;\n if (realm === 'idp') {\n let heartbeat = true;\n const { plid } = loginInfo;\n const queryPlid = tools.getPlidFromQuery();\n if (queryPlid) {\n if (Number(plid) !== Number(queryPlid)) {\n heartbeat = false;\n }\n }\n if (heartbeat) {\n const oneMin = 60 * 1000;\n setInterval(checkVat, oneMin);\n return checkVat();\n }\n }\n }\n}\n\nmain();\n" ], "names": [ "webpackUniversalModuleDefinition", "root", "factory", "exports", "module", "define", "amd", "window", "installedModules", "__webpack_require__", "m", "getPlidFromQuery", "getValueFromQuery", "key", "queryString", "location", "search", "substring", "i", "query", "split", "length", "keyval", "getHost", "sliceIndex", "hostname", "includes", "slice", "join", "buildRedirect", "app", "getSubdomain", "topHost", "replace", "concat", "host", "path", "getPath", "encodeURIComponent", "pathname", "port", "getPort", "plid", "ssoUrl", "getCookie", "name", "defaultValue", "arguments", "undefined", "cookieArray", "document", "cookie", "cookieObj", "trim", "decodeURIComponent", "handleVatResult", "result", "status", "ssoRedirect", "assign", "writeCookie", "value", "domain", "maxAge", "cookieValue", "docCookie", "Date", "now", "checkVat", "timestamp", "fetchArgs", "method", "headers", "Accept", "Content-Type", "body", "JSON", "stringify", "infotoken", "realm", "credentials", "fetch", "then", "response", "main", "disableHeartbeat", "loginInfoCookie", "_handleHeartbeat", "loginInfo", "parse", "auth", "typ", "heartbeat", "queryPlid", "setInterval", "c", "d", "getter", "o", "Object", "defineProperty", "configurable", "enumerable", "get", "r", "n", "__esModule", "object", "property", "prototype", "hasOwnProperty", "call", "p", "s", "moduleId", "l", "modules" ], "mappings": "CAAA,SAAAA,EAAAC,EAAAC,GACA,iBAAAC,SAAA,iBAAAC,OACAA,OAAAD,QAAAD,IACA,mBAAAG,QAAAA,OAAAC,IACAD,OAAA,YAAA,GAAAH,GACA,iBAAAC,QACAA,QAAA,aAAAD,IAEAD,EAAA,aAAAC,IARA,CASCK,OAAA,WACD,OCTAC,EAAA,GA4BAC,EAAAC,kCCbO,SAASC,IACd,OAjBK,SAASC,EAAkBC,GAChC,IAAIC,EAAcP,OAAOQ,SAASC,OACX,MAAnBF,EAAY,KACdA,EAAcA,EAAYG,UAAU,IAEtC,IACIC,EADEC,EAAQL,EAAYM,MAAM,KAEhC,IAAKF,EAAI,EAAGA,EAAIC,EAAME,OAAQH,GAAK,EAAG,CACpC,IAAMI,EAASH,EAAMD,GAAGE,MAAM,KAC9B,GAAIE,EAAO,KAAOT,EAChB,OAAOS,EAAO,GAGlB,MAAO,GAIAV,CAAkB,QASpB,SAASW,IACd,IAAMC,EAAajB,OAAOQ,SAASU,SAASC,SAAS,UAAY,GAAK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