diff --git a/acceptance-tests/features/friend_chatting.feature b/acceptance-tests/features/friend_chatting.feature new file mode 100644 index 00000000..eb732885 --- /dev/null +++ b/acceptance-tests/features/friend_chatting.feature @@ -0,0 +1,13 @@ +Feature: Can I send a message to a friend? + I want to know if i'm chatting with the right friend + + Scenario Outline: Could the user check if he is chatting with the right friend + Given I'm using the chat app + When I want to start chatting with my friend "" + Then "" is the right person to send the message + + Examples: + | friend | + | pruebaes5b | + | martinreycristina | + | srcharlystar | \ No newline at end of file diff --git a/acceptance-tests/features/is_it_friday_yet.feature b/acceptance-tests/features/is_it_friday_yet.feature deleted file mode 100644 index eaa0bc92..00000000 --- a/acceptance-tests/features/is_it_friday_yet.feature +++ /dev/null @@ -1,13 +0,0 @@ -Feature: Is it Friday yet? - Everybody wants to know when it's Friday - - Scenario Outline: Today is or is not Friday - Given today is "" - When I ask whether it's Friday yet - Then I should be told "" - - Examples: - | day | answer | - | Friday | TGIF | - | Sunday | Nope | - | anything else! | Nope | \ No newline at end of file diff --git a/acceptance-tests/features/recieve_message.feature b/acceptance-tests/features/recieve_message.feature index 6578ecfa..4d63bbd6 100644 --- a/acceptance-tests/features/recieve_message.feature +++ b/acceptance-tests/features/recieve_message.feature @@ -3,10 +3,5 @@ Feature: Can I recieve a message from a friend? Scenario Outline: Could the user recieve a message from a friend Given I'm using the chat app - When I'm chatting with "martinreycristina" - Then I recieve a message "Hi!" from my friend "martinreycristina" - - Examples: - | friend | me | - | Send "Hi" | I can read "Hi" | - | Send "How are you?" | I can read "How are you" | \ No newline at end of file + When I'm chatting with "pruebaes5b" + Then I recieve a message "Hi!" from my friend "pruebaes5b" \ No newline at end of file diff --git a/acceptance-tests/features/send_message.feature b/acceptance-tests/features/send_message.feature index 324fdb3c..b4f167d1 100644 --- a/acceptance-tests/features/send_message.feature +++ b/acceptance-tests/features/send_message.feature @@ -2,12 +2,12 @@ Feature: Can I send a message to a friend? I want to know if I can send a message to a contact Scenario Outline: Could the user send a message to a friend - Given I'm using the chat + Given I'm using the chat app When I send a message "" to a friend Then My friend gets the message "" Examples: - | sender | reciever | - | Hi | Hello | - | How are you? | Fine thanks and you? | - | Fine too | Cool | \ No newline at end of file + | message | friend | + | hi | pruebaes5b | + | how are you? | martinreycristina | + | good thanks | srcharlystar | \ No newline at end of file diff --git a/acceptance-tests/features/step_definitions/stepdefs.js b/acceptance-tests/features/step_definitions/stepdefs.js index a4f8589f..754244ac 100644 --- a/acceptance-tests/features/step_definitions/stepdefs.js +++ b/acceptance-tests/features/step_definitions/stepdefs.js @@ -2,78 +2,47 @@ const assert = require('assert'); const { Given, When, Then } = require('cucumber'); const chatManager1 = require("../../../src/chat/scripts/chatManager.js"); const chatManager2 = require("../../../src/chat/scripts/chatManager.js"); -const fc = require("solid-file-client"); // <<<<<-------------------------------- -const OK = 1; // <<<<<-------------------------------- -function isItFriday(today) { - if (today === "Friday") { - return "TGIF"; - } else { - return "Nope"; - } -} - -Given('today is {string}', function (givenDay) { - this.today = givenDay; -}); - -When('I ask whether it\'s Friday yet', function () { - this.actualAnswer = isItFriday(this.today); -}); - -Then('I should be told {string}', function (expectedAnswer) { - assert.equal(this.actualAnswer, expectedAnswer); -}); - -Given('I\'m using the chat', function() { - chatManager1.INFO.user="jandrolaviana"; - chatManager1.INFO.receiver="pruebaes5b"; +// SEND MESSAGE +Given('I\'m using the chat app', function() { + chatManager1.INFO.user = "jandrolaviana"; // ME + chatManager1.INFO.receiver = "pruebaes5b"; // MY FRIEND + chatManager1.MESSAGES.userMSG = ["Hey my friend", "Good thanks"]; + chatManager1.MESSAGES.friendMSG = ["Hi!", "How are you?"]; }); -When('I send a message {string} to a friend', async function(message) { - chatManager1.sendMessage = function() { return message; } - this.reply = await chatManager1.sendMessage(message); +When('I send a message {string} to a friend', function(message) { + chatManager1.sendMessage = function() { return true; } + this.reply = chatManager1.sendMessage(message); }); Then('My friend gets the message {string}', function(message) { - assert.equal(this.reply, message); -}); - -Given('I\'m using the chat app', function() { - chatManager1.INFO.user="jandrolaviana"; // ME - chatManager1.INFO.receiver="pruebaes5b"; // MY FRIEND - chatManager1.MESSAGES.userMSG=["Hey my friend", "Good thanks"]; - chatManager1.MESSAGES.friendMSG=["Hi!", "How are you?"]; - - chatManager2.INFO.user="jandrolaviana"; // ME - chatManager2.INFO.receiver="martinreycristina"; // MY FRIEND - chatManager2.MESSAGES.userMSG=["Hey Cristina", "Good thanks"]; - chatManager2.MESSAGES.friendMSG=["Hi!", "How are you?"]; + assert.equal(this.reply, true); }); +// RECEIVE MESSAGE When('I\'m chatting with {string}', async function(friendName) { - var ok = false; - if(chatManager1.INFO.receiver === friendName) - ok = true; - else if(chatManager2.INFO.receiver === friendName) - ok = true; - assert.equal(ok, true); + assert.equal(chatManager1.INFO.receiver === friendName, true); }); Then('I recieve a message {string} from my friend {string}', function(message, friendName) { - var ok = containsMessageAndFriend(chatManager1, message, friendName); - if(ok === true) - assert.equal(ok, true); - else { - ok = containsMessageAndFriend(chatManager2, message, friendName); - assert.equal(ok, true); - } + assert.equal(containsMessageAndFriend(chatManager1, message, friendName), true); }); function containsMessageAndFriend(cm, message, friendName) { - var i; - for(i=0; i empty list\r\n if(ToLog)\r\n console.log(\"User Folder do not exist\");\r\n\t\t\tMESSAGES.userMSG = [];\r\n }\r\n\t\t\r\n //Receiver folder\r\n //check new conversation (folder Exists)\r\n //Object folder readed -> get Files list\r\n\t\tvar receiverFolder = await readFolder(rFolder);\r\n //console.log(receiverFolder);\r\n\t\tif(receiverFolder){\r\n if(ToLog)\r\n console.log(\"Receiver folder exist\");\r\n MESSAGES.friendMSG = receiverFolder.files;\r\n }else{\r\n //Nothing to read -> empty list\r\n if(ToLog)\r\n console.log(\"User folder do not exist\");\r\n\t\t\tMESSAGES.friendMSG = [];\r\n }\r\n\r\n //Order las 10(n) msg by time order (file.mtime=TimeStamp)\r\n\tvar u = 0;\r\n\tvar f = 0;\r\n MESSAGES.toShow = [];\r\n if(ToLog)\r\n console.log(\"Read msgs\");\r\n\tfor(var i = 0; i < 100 && (u < MESSAGES.userMSG.length || f < MESSAGES.friendMSG.length) ; i++){\r\n\t\tif(!(f < MESSAGES.friendMSG.length)){\r\n\t\t\tMESSAGES.toShow[i] = INFO.userName + \": \" + await readMessage(uFolder+MESSAGES.userMSG[u].name);\r\n\t\t\tu++;\r\n\t\t}else if(!(u < MESSAGES.userMSG.length)){\r\n\t\t\tMESSAGES.toShow[i] = INFO.receiverName + \": \" + await readMessage(rFolder+MESSAGES.friendMSG[f].name);\r\n\t\t\tf++;\r\n\t\t}else if(MESSAGES.userMSG[u].mtime < MESSAGES.friendMSG[f].mtime){\r\n\t\t\tMESSAGES.toShow[i] = INFO.userName + \": \" + await readMessage(uFolder+MESSAGES.userMSG[u].name);\r\n\t\t\tu++;\r\n\t\t}else{\r\n\t\t\tMESSAGES.toShow[i] = INFO.receiverName + \": \" + await readMessage(rFolder+MESSAGES.friendMSG[f].name);\r\n\t\t\tf++;\r\n\t\t}\t\t\t\r\n\t}\r\n \r\n\treturn MESSAGES.toShow;\r\n}\r\n\r\nmodule.exports = {\r\n ToLog: ToLog,\r\n sendMessage: sendMessage,\r\n receiveMessages: receiveMessages,\r\n INFO: INFO,\r\n\tcreateFolder : createChatFolder,\r\n\treadFolder : readFolder,\r\n\tdeleteFolder : deleteFolder,\r\n\tcreateFile : writeMessage,\r\n\treadFile : readMessage,\r\n\tdeleteFile : deleteMessage\r\n}\r\n\r\n\r\n//POD utility funcs\r\n\r\nasync function createChatFolder(url) {\r\n await fileClient.createFolder(url).then(success => {\r\n if(ToLog)\r\n console.log(`Created folder ${url}.`);\r\n }, err => {\r\n\t\t console.log(err);\r\n\t });\r\n}\r\n\r\nasync function readFolder(url){\r\n return await fileClient.readFolder(url).then(folder => {\r\n if(ToLog)\r\n console.log(`Read ${folder.name}, it has ${folder.files.length} files.`);\r\n return folder;\r\n }, err => console.log(err) );\r\n}\r\n\r\nasync function deleteFolder(url){\r\n\tawait fileClient.deleteFolder(url).then(success => {\r\n if(ToLog)\r\n console.log(`Deleted ${url}.`);\r\n\t}, err => console.log(err) );\r\n}\r\n\r\nasync function writeMessage(url,content){\r\n await fileClient.createFile(url,content,\"text/plain\").then( fileCreated => {\r\n if(ToLog)\r\n console.log(`Created file ${fileCreated}.`);\r\n }, err => console.log(err) );\r\n}\r\n\r\nasync function readMessage(url){\r\n\treturn await fileClient.readFile(url).then( body => {\r\n if(ToLog)\r\n console.log(`File\tcontent is : ${body}.`);\r\n\t return body;\r\n\t}, err => console.log(err) );\r\n}\r\n\r\nasync function updateMessage(url){\r\n\tawait fileClient.updateFile( url, newContent, contentType ).then( success => {\r\n\t\tif(ToLog)\r\n console.log( `Updated ${url}.`)\r\n\t}, err => console.log(err) );\r\n}\r\n\r\nasync function deleteMessage(url){\r\n\tawait fileClient.deleteFile(url).then(success => {\r\n\t if(ToLog)\r\n console.log(`Deleted ${url}.`);\r\n\t}, err => console.log(err) );\r\n}\n\n//# sourceURL=webpack:///./src/chat/scripts/chatManager.js?"); +eval("const fileClient = __webpack_require__(/*! solid-file-client */ \"./node_modules/solid-file-client/dist/browser/solid-file-client.bundle.js\");\r\nconst ToLog = true;\r\n\r\nvar INFO = \r\n{\r\n user: \"\",\r\n userName: \"\" ,\r\n userURI:\"\" ,\r\n receiver:\"\" ,\r\n receiverName:\"\" ,\r\n receiverURI:\"\"\r\n}\r\n\r\nvar MESSAGES = {\r\n\tuserMSG: [],\r\n\tfriendMSG: [],\r\n\ttoShow: []\r\n}\r\n\r\n//SEND Message function login\r\nasync function sendMessage(text){\r\n //Define folders name\r\n var solidChat=INFO.userURI+\"public/SolidChat/\";\r\n var folder= solidChat+INFO.receiverName.replace(/ /g, \"-\")+\"/\";\r\n\t\r\n //Check Folder SolidChat\r\n if(ToLog)\r\n console.log(\"Check SolidChat Exist\")\r\n try{\r\n var err = await readFolder(solidChat);\r\n if(!err){\r\n if(ToLog)\r\n console.log(\"Solid-chat folder doesnt exist\");\r\n throw(\"error\")\r\n }\r\n }catch(error){\r\n //New Solid-Chat folder\r\n await createChatFolder(solidChat);\r\n if(ToLog)\r\n console.log(\"Solid-chat folder created\");\r\n }\r\n \r\n //IF folder doesnt exist: create new user folder\r\n if(ToLog)\r\n console.log(\"Check user:\"+INFO.receiverName+\" folder\")\r\n try{\r\n var err2 = await readFolder(folder);\r\n if(!err2){\r\n if(ToLog)\r\n console.log(\"Folder doesnt exist\");\r\n throw(\"error\")\r\n }\r\n }catch(error){\r\n //New Folder:\r\n await createChatFolder(folder);\r\n if(ToLog)\r\n console.log('User folder created');\r\n }\r\n\r\n //WritingMessage\r\n if(ToLog)\r\n console.log(\"Writting message: \"+text);\r\n await writeMessage(folder+\"/\"+(new Date().getTime()), text);\r\n\treturn true;\r\n}\r\n\r\n//TO-DO\r\nasync function receiveMessages(){\r\n if(ToLog)\r\n console.log(\"ReceivingMessages\")\r\n\t//Define folders name\r\n var uFolder=INFO.userURI+\"public/SolidChat/\"+INFO.receiverName.trim().replace(/ /g, \"-\")+\"/\";\r\n\tvar rFolder=INFO.receiverURI+\"public/SolidChat/\"+INFO.userName.trim().replace(/ /g, \"-\")+\"/\";\r\n\r\n //User folder\r\n //check new conversation (folder Exists) \r\n var userFolder = await readFolder(uFolder);\r\n\r\n //console.log(userFolder);\r\n\t\tif(userFolder){\r\n if(ToLog)\r\n console.log(\"User folder exist\");\r\n MESSAGES.userMSG = userFolder.files;\r\n }else{\r\n //Nothing to read -> empty list\r\n if(ToLog)\r\n console.log(\"User Folder do not exist\");\r\n\t\t\tMESSAGES.userMSG = [];\r\n }\r\n\t\t\r\n //Receiver folder\r\n //check new conversation (folder Exists)\r\n //Object folder readed -> get Files list\r\n\t\tvar receiverFolder = await readFolder(rFolder);\r\n //console.log(receiverFolder);\r\n\t\tif(receiverFolder){\r\n if(ToLog)\r\n console.log(\"Receiver folder exist\");\r\n MESSAGES.friendMSG = receiverFolder.files;\r\n }else{\r\n //Nothing to read -> empty list\r\n if(ToLog)\r\n console.log(\"User folder do not exist\");\r\n\t\t\tMESSAGES.friendMSG = [];\r\n }\r\n\r\n //Order las 10(n) msg by time order (file.mtime=TimeStamp)\r\n\tvar u = 0;\r\n\tvar f = 0;\r\n MESSAGES.toShow = [];\r\n if(ToLog)\r\n console.log(\"Read msgs\");\r\n\tfor(var i = 0; i < 100 && (u < MESSAGES.userMSG.length || f < MESSAGES.friendMSG.length) ; i++){\r\n\t\tif(!(f < MESSAGES.friendMSG.length)){\r\n\t\t\tMESSAGES.toShow[i] = INFO.userName + \": \" + await readMessage(uFolder+MESSAGES.userMSG[u].name);\r\n\t\t\tu++;\r\n\t\t}else if(!(u < MESSAGES.userMSG.length)){\r\n\t\t\tMESSAGES.toShow[i] = INFO.receiverName + \": \" + await readMessage(rFolder+MESSAGES.friendMSG[f].name);\r\n\t\t\tf++;\r\n\t\t}else if(MESSAGES.userMSG[u].mtime < MESSAGES.friendMSG[f].mtime){\r\n\t\t\tMESSAGES.toShow[i] = INFO.userName + \": \" + await readMessage(uFolder+MESSAGES.userMSG[u].name);\r\n\t\t\tu++;\r\n\t\t}else{\r\n\t\t\tMESSAGES.toShow[i] = INFO.receiverName + \": \" + await readMessage(rFolder+MESSAGES.friendMSG[f].name);\r\n\t\t\tf++;\r\n\t\t}\t\t\t\r\n\t}\r\n \r\n\treturn MESSAGES.toShow;\r\n}\r\n\r\nmodule.exports = {\r\n ToLog: ToLog,\r\n sendMessage: sendMessage,\r\n receiveMessages: receiveMessages,\r\n INFO: INFO,\r\n\tMESSAGES: MESSAGES,\r\n\tcreateFolder : createChatFolder,\r\n\treadFolder : readFolder,\r\n\tdeleteFolder : deleteFolder,\r\n\tcreateFile : writeMessage,\r\n\treadFile : readMessage,\r\n\tdeleteFile : deleteMessage\r\n}\r\n\r\n\r\n//POD utility funcs\r\n\r\nasync function createChatFolder(url) {\r\n await fileClient.createFolder(url).then(success => {\r\n if(ToLog)\r\n console.log(`Created folder ${url}.`);\r\n }, err => {\r\n\t\t console.log(err);\r\n\t });\r\n}\r\n\r\nasync function readFolder(url){\r\n return await fileClient.readFolder(url).then(folder => {\r\n if(ToLog)\r\n console.log(`Read ${folder.name}, it has ${folder.files.length} files.`);\r\n return folder;\r\n }, err => console.log(err) );\r\n}\r\n\r\nasync function deleteFolder(url){\r\n\tawait fileClient.deleteFolder(url).then(success => {\r\n if(ToLog)\r\n console.log(`Deleted ${url}.`);\r\n\t}, err => console.log(err) );\r\n}\r\n\r\nasync function writeMessage(url,content){\r\n await fileClient.createFile(url,content,\"text/plain\").then( fileCreated => {\r\n if(ToLog)\r\n console.log(`Created file ${fileCreated}.`);\r\n }, err => console.log(err) );\r\n}\r\n\r\nasync function readMessage(url){\r\n\treturn await fileClient.readFile(url).then( body => {\r\n if(ToLog)\r\n console.log(`File\tcontent is : ${body}.`);\r\n\t return body;\r\n\t}, err => console.log(err) );\r\n}\r\n\r\nasync function updateMessage(url){\r\n\tawait fileClient.updateFile( url, newContent, contentType ).then( success => {\r\n\t\tif(ToLog)\r\n console.log( `Updated ${url}.`)\r\n\t}, err => console.log(err) );\r\n}\r\n\r\nasync function deleteMessage(url){\r\n\tawait fileClient.deleteFile(url).then(success => {\r\n\t if(ToLog)\r\n console.log(`Deleted ${url}.`);\r\n\t}, err => console.log(err) );\r\n}\n\n//# sourceURL=webpack:///./src/chat/scripts/chatManager.js?"); /***/ }), diff --git a/src/chat/scripts/chatManager.js b/src/chat/scripts/chatManager.js index b7f4c70c..bbb0d3c0 100644 --- a/src/chat/scripts/chatManager.js +++ b/src/chat/scripts/chatManager.js @@ -61,6 +61,7 @@ async function sendMessage(text){ if(ToLog) console.log("Writting message: "+text); await writeMessage(folder+"/"+(new Date().getTime()), text); + return true; } //TO-DO diff --git a/src/index.js b/src/index.js new file mode 100644 index 00000000..a0d999a3 --- /dev/null +++ b/src/index.js @@ -0,0 +1,4124 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) { +/******/ return installedModules[moduleId].exports; +/******/ } +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ i: moduleId, +/******/ l: false, +/******/ exports: {} +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.l = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // define getter function for harmony exports +/******/ __webpack_require__.d = function(exports, name, getter) { +/******/ if(!__webpack_require__.o(exports, name)) { +/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); +/******/ } +/******/ }; +/******/ +/******/ // define __esModule on exports +/******/ __webpack_require__.r = function(exports) { +/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { +/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); +/******/ } +/******/ Object.defineProperty(exports, '__esModule', { value: true }); +/******/ }; +/******/ +/******/ // create a fake namespace object +/******/ // mode & 1: value is a module id, require it +/******/ // mode & 2: merge all properties of value into the ns +/******/ // mode & 4: return value when already ns object +/******/ // mode & 8|1: behave like require +/******/ __webpack_require__.t = function(value, mode) { +/******/ if(mode & 1) value = __webpack_require__(value); +/******/ if(mode & 8) return value; +/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; +/******/ var ns = Object.create(null); +/******/ __webpack_require__.r(ns); +/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); +/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); +/******/ return ns; +/******/ }; +/******/ +/******/ // getDefaultExport function for compatibility with non-harmony modules +/******/ __webpack_require__.n = function(module) { +/******/ var getter = module && module.__esModule ? +/******/ function getDefault() { return module['default']; } : +/******/ function getModuleExports() { return module; }; +/******/ __webpack_require__.d(getter, 'a', getter); +/******/ return getter; +/******/ }; +/******/ +/******/ // Object.prototype.hasOwnProperty.call +/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = ""; +/******/ +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(__webpack_require__.s = "./src/scripts/main.js"); +/******/ }) +/************************************************************************/ +/******/ ({ + +/***/ "./node_modules/@solid/cli/src/IdentityManager.js": +/*!********************************************************!*\ + !*** ./node_modules/@solid/cli/src/IdentityManager.js ***! + \********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("class IdentityManager {\n constructor(providers = {}) {\n this._providers = providers;\n }\n\n addProviderSettings(providerSettings) {\n const url = providerSettings.provider.url;\n const provider = this._providers[url] || (this._providers[url] = {});\n provider.providerSettings = providerSettings;\n }\n\n getProviderSettings(url) {\n return this._providers[url] && this._providers[url].providerSettings;\n }\n\n addSession(providerSettings, username, session) {\n this.getSessions(providerSettings)[username] = session;\n }\n\n getSession(providerSettings, username) {\n return this.getSessions(providerSettings)[username];\n }\n\n getSessions(providerSettings) {\n const url = providerSettings.provider.url;\n const provider = this._providers[url] || (this._providers[url] = {});\n const sessions = provider.sessions || (provider.sessions = {});\n return sessions;\n }\n\n toJSON() {\n return JSON.stringify({\n providers: this._providers,\n });\n }\n\n static fromJSON(json) {\n const { providers } = JSON.parse(json);\n return new IdentityManager(providers || {});\n }\n}\n\nmodule.exports = IdentityManager;\n\n\n//# sourceURL=webpack:///./node_modules/@solid/cli/src/IdentityManager.js?"); + +/***/ }), + +/***/ "./node_modules/@solid/cli/src/SolidClient.js": +/*!****************************************************!*\ + !*** ./node_modules/@solid/cli/src/SolidClient.js ***! + \****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("const { resolve, parse: parseUrl } = __webpack_require__(/*! url */ \"./node_modules/url/url.js\");\nconst https = __webpack_require__(/*! https */ \"./node_modules/https-browserify/index.js\");\nconst querystring = __webpack_require__(/*! querystring */ \"./node_modules/querystring-es3/index.js\");\nconst RelyingParty = __webpack_require__(/*! @trust/oidc-rp */ \"./node_modules/@trust/oidc-rp/src/index.js\");\nconst PoPToken = __webpack_require__(/*! @trust/oidc-rp/lib/PoPToken */ \"./node_modules/@trust/oidc-rp/lib/PoPToken.js\");\n\n// Fake redirect URL\nconst redirectUrl = 'http://example.org/';\n\nclass SolidClient {\n constructor({ identityManager }) {\n this._identityManager = identityManager;\n }\n\n /**\n * Logs the user in with the given identity provider\n *\n * @param identityProvider string The URL of the identity provider\n * @param credentials object An object with username and password keys\n *\n * @returns Promise A session for the given user\n */\n async login(identityProvider, credentials) {\n // Obtain a relying party\n const relyingParty = await this.getRelyingParty(identityProvider);\n\n // Load or create a session\n const username = credentials.username;\n let session = this._identityManager.getSession(relyingParty, username);\n if (!session || this.isExpired(session)) {\n session = await this.createSession(relyingParty, credentials);\n this._identityManager.addSession(relyingParty, username, session);\n }\n return session;\n }\n\n /**\n * Logs the user in with the given identity provider\n *\n * @param relyingParty RelyingParty The relying party\n * @param credentials object An object with username and password keys\n *\n * @returns Promise A session for the given user\n */\n async createSession(relyingParty, credentials) {\n // Obtain the authorization URL\n const authData = {};\n const authUrl = await relyingParty.createRequest({ redirect_uri: redirectUrl }, authData);\n\n // Perform the login\n const loginParams = await this.getLoginParams(authUrl);\n const accessUrl = await this.performLogin(loginParams.loginUrl, loginParams, credentials);\n const session = await relyingParty.validateResponse(accessUrl, authData);\n\n return session;\n }\n\n /**\n * Creates an access token for the given URL.\n *\n * @param url string\n * @param session Session\n *\n * @returns Promise An access token\n */\n async createToken(url, session) {\n return PoPToken.issueFor(url, session);\n }\n\n /**\n * Obtains a relying party for the given identity provider.\n *\n * @param identityProvider string The URL of the identity provider\n *\n * @returns Promise A relying party\n */\n async getRelyingParty(identityProvider) {\n // Try to load an existing relying party\n let relyingParty;\n const providerSettings = this._identityManager.getProviderSettings(identityProvider);\n if (providerSettings) {\n relyingParty = RelyingParty.from(providerSettings);\n }\n // Create a new relying party\n else {\n relyingParty = await this.registerRelyingParty(identityProvider);\n this._identityManager.addProviderSettings(relyingParty);\n }\n return relyingParty;\n }\n\n /**\n * Registers a relying party for the given identity provider.\n *\n * @param identityProvider string The URL of the identity provider\n *\n * @returns Promise A relying party\n */\n async registerRelyingParty(identityProvider) {\n const responseType = 'id_token token';\n const registration = {\n issuer: identityProvider,\n grant_types: ['implicit'],\n redirect_uris: [redirectUrl],\n response_types: [responseType],\n scope: 'openid profile',\n };\n const options = {\n defaults: {\n authenticate: {\n redirect_uri: redirectUrl,\n response_type: responseType,\n },\n },\n };\n return RelyingParty.register(identityProvider, registration, options);\n }\n\n /**\n * Obtains the login parameters through the given authentication URL.\n *\n * @param authUrl String The authentication URL\n *\n * @returns Promise A key/value object of login parameters\n */\n async getLoginParams(authUrl) {\n // Retrieve the login page in HTML\n const authorizationPage = await this.fetch(authUrl);\n const loginPageUrl = resolve(authUrl, authorizationPage.headers.location);\n const loginPage = await this.fetch(loginPageUrl);\n\n // Extract the password form's target URL\n const passwordForm = loginPage.body.match(//)[0];\n const loginUrl = resolve(loginPageUrl, passwordForm.match(/action=\"([^\"]+)\"/)[1]);\n\n // Extract the password form's hidden fields\n const loginParams = { loginUrl };\n let match, inputRegex = / An access URL.\n */\n async performLogin(loginUrl, loginParams, credentials) {\n // Set the credentials\n loginParams.username = credentials.username;\n loginParams.password = credentials.password;\n\n // Perform the login POST request\n const options = parseUrl(loginUrl);\n const postData = querystring.stringify(loginParams);\n options.method = 'POST';\n options.headers = {\n 'Content-Type': 'application/x-www-form-urlencoded',\n 'Content-Length': postData.length,\n };\n const loginResponse = await this.fetch(options, postData);\n\n // Verify the login was successful\n if (loginResponse.statusCode !== 302) {\n const message = loginResponse.body.match(/(.*?)<\\/strong>/);\n const cause = message ? message[1] : 'unknown cause';\n throw new Error(`Could not log in: ${cause}`);\n }\n\n // Redirect to the authentication page, passing the session cookie\n const authUrl = loginResponse.headers.location;\n const cookie = loginResponse.headers['set-cookie'][0].replace(/;.*/, '');\n const authResponse = await this.fetch(Object.assign(parseUrl(authUrl), {\n headers: { cookie },\n }));\n\n // Obtain the access URL from the redirected response\n const accessUrl = authResponse.headers.location;\n return accessUrl;\n }\n\n /**\n * Fetches the given resource over HTTP.\n *\n * @param options object The request options\n * @param data? string The request body\n *\n * @returns Promise The HTTP response with a body property\n */\n fetch(options, data) {\n return new Promise((resolve, reject) => {\n const request = https.request(options);\n request.end(data);\n request.on('response', response => {\n response.body = '';\n response.on('data', data => response.body += data);\n response.on('end', () => resolve(response));\n });\n request.on('error', reject);\n });\n }\n\n /**\n * Determines whether the session has expired.\n *\n * @param session object The session\n *\n * @returns boolean Whether the session has expired\n */\n isExpired(session) {\n const now = Date.now() / 1000;\n const expiry = session.idClaims && session.idClaims.exp || 0;\n return expiry < now;\n }\n}\n\nmodule.exports = SolidClient;\n\n\n//# sourceURL=webpack:///./node_modules/@solid/cli/src/SolidClient.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/algorithms/HMAC.js": +/*!*********************************************************!*\ + !*** ./node_modules/@trust/jose/lib/algorithms/HMAC.js ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\n\n/**\n * Dependencies\n * @ignore\n */\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar base64url = __webpack_require__(/*! base64url */ \"./node_modules/base64url/index.js\");\nvar crypto = __webpack_require__(/*! @trust/webcrypto */ \"@trust/webcrypto\");\nvar TextEncoder = __webpack_require__(/*! ../text-encoder */ \"./node_modules/@trust/jose/lib/text-encoder/index.js\"\n\n/**\n * HMAC with SHA-2 Functions\n */\n);\nvar HMAC = function () {\n\n /**\n * Constructor\n *\n * @param {string} bitlength\n */\n function HMAC(params) {\n _classCallCheck(this, HMAC);\n\n this.params = params;\n }\n\n /**\n * Sign\n *\n * @description\n * Generate a hash-based message authentication code for a\n * given input and key. Enforce the key length is equal to\n * or greater than the bitlength.\n *\n * @param {CryptoKey} key\n * @param {string} data\n *\n * @returns {string}\n */\n\n\n _createClass(HMAC, [{\n key: 'sign',\n value: function sign(key, data) {\n var algorithm = this.params;\n\n // TODO: validate key length\n\n data = new TextEncoder().encode(data);\n\n return crypto.subtle.sign(algorithm, key, data).then(function (signature) {\n return base64url(Buffer.from(signature));\n });\n }\n\n /**\n * Verify\n *\n * @description\n * Verify a digital signature for a given input and private key.\n *\n * @param {CryptoKey} key\n * @param {string} signature\n * @param {string} data\n *\n * @returns {Boolean}\n */\n\n }, {\n key: 'verify',\n value: function verify(key, signature, data) {\n var algorithm = this.params;\n\n if (typeof signature === 'string') {\n signature = Uint8Array.from(base64url.toBuffer(signature));\n }\n\n if (typeof data === 'string') {\n data = new TextEncoder().encode(data);\n }\n\n return crypto.subtle.verify(algorithm, key, signature, data);\n }\n\n /**\n * Assert Sufficient Key Length\n *\n * @description Assert that the key length is sufficient\n * @param {string} key\n */\n\n }, {\n key: 'assertSufficientKeyLength',\n value: function assertSufficientKeyLength(key) {\n if (key.length < this.bitlength) {\n throw new Error('The key is too short.');\n }\n }\n }]);\n\n return HMAC;\n}();\n\n/**\n * Export\n */\n\n\nmodule.exports = HMAC;\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/algorithms/HMAC.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/algorithms/NONE.js": +/*!*********************************************************!*\ + !*** ./node_modules/@trust/jose/lib/algorithms/NONE.js ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * None\n */\nvar None = function () {\n function None() {\n _classCallCheck(this, None);\n }\n\n _createClass(None, [{\n key: 'sign',\n\n /**\n * sign\n */\n value: function sign() {\n return Promise.resolve('');\n }\n\n /**\n * verify\n */\n\n }, {\n key: 'verify',\n value: function verify() {\n // this will never get called. but you looked.\n }\n }]);\n\n return None;\n}();\n\n/**\n * Export\n */\n\n\nmodule.exports = None;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/algorithms/NONE.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/algorithms/RSASSA-PKCS1-v1_5.js": +/*!**********************************************************************!*\ + !*** ./node_modules/@trust/jose/lib/algorithms/RSASSA-PKCS1-v1_5.js ***! + \**********************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {\n\n/**\n * Dependencies\n * @ignore\n */\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar base64url = __webpack_require__(/*! base64url */ \"./node_modules/base64url/index.js\");\nvar crypto = __webpack_require__(/*! @trust/webcrypto */ \"@trust/webcrypto\");\nvar TextEncoder = __webpack_require__(/*! ../text-encoder */ \"./node_modules/@trust/jose/lib/text-encoder/index.js\"\n\n/**\n * RSASSA-PKCS1-v1_5\n */\n);\nvar RSASSA_PKCS1_v1_5 = function () {\n\n /**\n * constructor\n *\n * @param {string} bitlength\n */\n function RSASSA_PKCS1_v1_5(params) {\n _classCallCheck(this, RSASSA_PKCS1_v1_5);\n\n this.params = params;\n }\n\n /**\n * sign\n *\n * @description\n * Generate a digital signature for a given input and private key.\n *\n * @param {CryptoKey} key\n * @param {BufferSource} data\n *\n * @returns {Promise}\n */\n\n\n _createClass(RSASSA_PKCS1_v1_5, [{\n key: 'sign',\n value: function sign(key, data) {\n var algorithm = this.params;\n\n // TODO\n //if (!this.sufficientKeySize()) {\n // return Promise.reject(\n // new Error(\n // 'A key size of 2048 bits or larger must be used with RSASSA-PKCS1-v1_5'\n // )\n // )\n //}\n\n data = new TextEncoder().encode(data);\n\n return crypto.subtle.sign(algorithm, key, data).then(function (signature) {\n return base64url(Buffer.from(signature));\n });\n }\n\n /**\n * verify\n *\n * @description\n * Verify a digital signature for a given input and private key.\n *\n * @param {CryptoKey} key\n * @param {BufferSource} signature\n * @param {BufferSource} data\n *\n * @returns {Promise}\n */\n\n }, {\n key: 'verify',\n value: function verify(key, signature, data) {\n var algorithm = this.params;\n\n if (typeof signature === 'string') {\n signature = Uint8Array.from(base64url.toBuffer(signature));\n }\n\n if (typeof data === 'string') {\n data = new TextEncoder().encode(data);\n }\n // ...\n\n return crypto.subtle.verify(algorithm, key, signature, data);\n }\n\n /**\n * importKey\n *\n * @param {JWK} key\n * @returns {Promise}\n */\n\n }, {\n key: 'importKey',\n value: function importKey(key) {\n var jwk = Object.assign({}, key);\n var algorithm = this.params;\n var usages = key['key_ops'] || [];\n\n if (key.use === 'sig') {\n usages.push('verify');\n }\n\n if (key.use === 'enc') {\n // TODO: handle encryption keys\n return Promise.resolve(key);\n }\n\n if (key.key_ops) {\n usages = key.key_ops;\n }\n\n return crypto.subtle.importKey('jwk', jwk, algorithm, true, usages).then(function (cryptoKey) {\n Object.defineProperty(jwk, 'cryptoKey', {\n enumerable: false,\n value: cryptoKey\n });\n\n return jwk;\n });\n }\n }]);\n\n return RSASSA_PKCS1_v1_5;\n}();\n\n/**\n * Export\n */\n\n\nmodule.exports = RSASSA_PKCS1_v1_5;\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/algorithms/RSASSA-PKCS1-v1_5.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/algorithms/SupportedAlgorithms.js": +/*!************************************************************************!*\ + !*** ./node_modules/@trust/jose/lib/algorithms/SupportedAlgorithms.js ***! + \************************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * Dependencies\n */\nvar NotSupportedError = __webpack_require__(/*! ../errors/NotSupportedError */ \"./node_modules/@trust/jose/lib/errors/NotSupportedError.js\"\n\n/**\n * Operations\n */\n);var operations = ['sign', 'verify', 'encrypt', 'decrypt', 'importKey'];\n\n/**\n * SupportedAlgorithms\n */\n\nvar SupportedAlgorithms = function () {\n\n /**\n * constructor\n */\n function SupportedAlgorithms() {\n var _this = this;\n\n _classCallCheck(this, SupportedAlgorithms);\n\n operations.forEach(function (op) {\n _this[op] = {};\n });\n }\n\n /**\n * Supported Operations\n */\n\n\n _createClass(SupportedAlgorithms, [{\n key: 'define',\n\n\n /**\n * define\n *\n * @description\n * Register Web Crypto API algorithm parameter for an algorithm\n * and operation.\n *\n * @param {string} alg\n * @param {string} op\n * @param {Object} argument\n */\n value: function define(alg, op, argument) {\n var registeredAlgorithms = this[op];\n registeredAlgorithms[alg] = argument;\n }\n\n /**\n * normalize\n *\n * @description\n * Map JWA alg name to Web Crypto API algorithm parameter\n *\n * @param {string} op\n * @param {Object} alg\n *\n * @returns {Object}\n */\n\n }, {\n key: 'normalize',\n value: function normalize(op, alg) {\n var registeredAlgorithms = this[op];\n\n if (!registeredAlgorithms) {\n return new SyntaxError(); // what kind of error should this be?\n }\n\n var argument = registeredAlgorithms[alg];\n\n if (!argument) {\n return new NotSupportedError(alg);\n }\n\n return argument;\n }\n }], [{\n key: 'operations',\n get: function get() {\n return operations;\n }\n }]);\n\n return SupportedAlgorithms;\n}();\n\n/**\n * Export\n */\n\n\nmodule.exports = SupportedAlgorithms;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/algorithms/SupportedAlgorithms.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/algorithms/index.js": +/*!**********************************************************!*\ + !*** ./node_modules/@trust/jose/lib/algorithms/index.js ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Local dependencies\n */\nvar None = __webpack_require__(/*! ./NONE */ \"./node_modules/@trust/jose/lib/algorithms/NONE.js\");\nvar HMAC = __webpack_require__(/*! ./HMAC */ \"./node_modules/@trust/jose/lib/algorithms/HMAC.js\");\nvar RSASSA_PKCS1_v1_5 = __webpack_require__(/*! ./RSASSA-PKCS1-v1_5 */ \"./node_modules/@trust/jose/lib/algorithms/RSASSA-PKCS1-v1_5.js\");\nvar SupportedAlgorithms = __webpack_require__(/*! ./SupportedAlgorithms */ \"./node_modules/@trust/jose/lib/algorithms/SupportedAlgorithms.js\"\n\n/**\n * Register Supported Algorithms\n */\n);var supportedAlgorithms = new SupportedAlgorithms();\n\n/**\n * Sign\n */\nsupportedAlgorithms.define('HS256', 'sign', new HMAC({\n name: 'HMAC',\n hash: {\n name: 'SHA-256'\n }\n}));\n\nsupportedAlgorithms.define('HS384', 'sign', new HMAC({\n name: 'HMAC',\n hash: {\n name: 'SHA-384'\n }\n}));\n\nsupportedAlgorithms.define('HS512', 'sign', new HMAC({\n name: 'HMAC',\n hash: {\n name: 'SHA-512'\n }\n}));\n\nsupportedAlgorithms.define('RS256', 'sign', new RSASSA_PKCS1_v1_5({\n name: 'RSASSA-PKCS1-v1_5',\n hash: {\n name: 'SHA-256'\n }\n}));\n\nsupportedAlgorithms.define('RS384', 'sign', new RSASSA_PKCS1_v1_5({\n name: 'RSASSA-PKCS1-v1_5',\n hash: {\n name: 'SHA-384'\n }\n}));\n\nsupportedAlgorithms.define('RS512', 'sign', new RSASSA_PKCS1_v1_5({\n name: 'RSASSA-PKCS1-v1_5',\n hash: {\n name: 'SHA-512'\n }\n})\n//supportedAlgorithms.define('ES256', 'sign', {})\n//supportedAlgorithms.define('ES384', 'sign', {})\n//supportedAlgorithms.define('ES512', 'sign', {})\n//supportedAlgorithms.define('PS256', 'sign', {})\n//supportedAlgorithms.define('PS384', 'sign', {})\n//supportedAlgorithms.define('PS512', 'sign', {})\n\n);supportedAlgorithms.define('none', 'sign', new None({\n // nothing goes here\n})\n\n/**\n * Verify\n */\n);supportedAlgorithms.define('HS256', 'verify', new HMAC({\n name: 'HMAC',\n hash: {\n name: 'SHA-256'\n }\n}));\n\nsupportedAlgorithms.define('HS384', 'verify', new HMAC({\n name: 'HMAC',\n hash: {\n name: 'SHA-384'\n }\n}));\n\nsupportedAlgorithms.define('HS512', 'verify', new HMAC({\n name: 'HMAC',\n hash: {\n name: 'SHA-512'\n }\n}));\n\nsupportedAlgorithms.define('RS256', 'verify', new RSASSA_PKCS1_v1_5({\n name: 'RSASSA-PKCS1-v1_5',\n hash: {\n name: 'SHA-256'\n }\n}));\n\nsupportedAlgorithms.define('RS384', 'verify', new RSASSA_PKCS1_v1_5({\n name: 'RSASSA-PKCS1-v1_5',\n hash: {\n name: 'SHA-384'\n }\n}));\n\nsupportedAlgorithms.define('RS512', 'verify', new RSASSA_PKCS1_v1_5({\n name: 'RSASSA-PKCS1-v1_5',\n hash: {\n name: 'SHA-512'\n }\n})\n//supportedAlgorithms.define('ES256', 'verify', {})\n//supportedAlgorithms.define('ES384', 'verify', {})\n//supportedAlgorithms.define('ES512', 'verify', {})\n//supportedAlgorithms.define('PS256', 'verify', {})\n//supportedAlgorithms.define('PS384', 'verify', {})\n//supportedAlgorithms.define('PS512', 'verify', {})\n\n);supportedAlgorithms.define('none', 'verify', new None({\n // nothing goes here\n}));\n\nsupportedAlgorithms.define('RS256', 'importKey', new RSASSA_PKCS1_v1_5({\n name: 'RSASSA-PKCS1-v1_5',\n hash: {\n name: 'SHA-256'\n }\n}));\n\nsupportedAlgorithms.define('RS384', 'importKey', new RSASSA_PKCS1_v1_5({\n name: 'RSASSA-PKCS1-v1_5',\n hash: {\n name: 'SHA-384'\n }\n}));\n\nsupportedAlgorithms.define('RS512', 'importKey', new RSASSA_PKCS1_v1_5({\n name: 'RSASSA-PKCS1-v1_5',\n hash: {\n name: 'SHA-512'\n }\n})\n\n/**\n * Export\n */\n);module.exports = supportedAlgorithms;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/algorithms/index.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/errors/DataError.js": +/*!**********************************************************!*\ + !*** ./node_modules/@trust/jose/lib/errors/DataError.js ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n/**\n * DataError\n */\nvar DataError = function (_Error) {\n _inherits(DataError, _Error);\n\n function DataError(message) {\n _classCallCheck(this, DataError);\n\n return _possibleConstructorReturn(this, (DataError.__proto__ || Object.getPrototypeOf(DataError)).call(this, message));\n }\n\n return DataError;\n}(Error);\n\n/**\n * Export\n */\n\n\nmodule.exports = DataError;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/errors/DataError.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/errors/NotSupportedError.js": +/*!******************************************************************!*\ + !*** ./node_modules/@trust/jose/lib/errors/NotSupportedError.js ***! + \******************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n/**\n * NotSupportedError\n */\nvar NotSupportedError = function (_Error) {\n _inherits(NotSupportedError, _Error);\n\n function NotSupportedError(alg) {\n _classCallCheck(this, NotSupportedError);\n\n var _this = _possibleConstructorReturn(this, (NotSupportedError.__proto__ || Object.getPrototypeOf(NotSupportedError)).call(this));\n\n _this.message = alg + \" is not a supported algorithm\";\n return _this;\n }\n\n return NotSupportedError;\n}(Error);\n\n/**\n * Export\n */\n\n\nmodule.exports = NotSupportedError;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/errors/NotSupportedError.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/errors/index.js": +/*!******************************************************!*\ + !*** ./node_modules/@trust/jose/lib/errors/index.js ***! + \******************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nmodule.exports = {\n DataError: __webpack_require__(/*! ./DataError */ \"./node_modules/@trust/jose/lib/errors/DataError.js\"),\n NotSupportedError: __webpack_require__(/*! ./NotSupportedError */ \"./node_modules/@trust/jose/lib/errors/NotSupportedError.js\")\n};\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/errors/index.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/formats/index.js": +/*!*******************************************************!*\ + !*** ./node_modules/@trust/jose/lib/formats/index.js ***! + \*******************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Package dependencies\n */\nvar _require = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\"\n\n/**\n * Format extensions\n */\n),\n Formats = _require.Formats;\n\nFormats.register('StringOrURI', new RegExp());\nFormats.register('NumericDate', new RegExp());\nFormats.register('URI', new RegExp());\nFormats.register('url', new RegExp());\nFormats.register('base64', new RegExp());\nFormats.register('base64url', new RegExp());\nFormats.register('MediaType', new RegExp());\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/formats/index.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/index.js": +/*!***********************************************!*\ + !*** ./node_modules/@trust/jose/lib/index.js ***! + \***********************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * @module JSON Object Signing and Encryption (JOSE)\n */\nvar JWA = __webpack_require__(/*! ./jose/JWA */ \"./node_modules/@trust/jose/lib/jose/JWA.js\");\nvar JWK = __webpack_require__(/*! ./jose/JWK */ \"./node_modules/@trust/jose/lib/jose/JWK.js\");\nvar JWKSet = __webpack_require__(/*! ./jose/JWKSet */ \"./node_modules/@trust/jose/lib/jose/JWKSet.js\");\nvar JWT = __webpack_require__(/*! ./jose/JWT */ \"./node_modules/@trust/jose/lib/jose/JWT.js\");\nvar JWS = __webpack_require__(/*! ./jose/JWS */ \"./node_modules/@trust/jose/lib/jose/JWS.js\");\nvar Base64URLSchema = __webpack_require__(/*! ./schemas/Base64URLSchema */ \"./node_modules/@trust/jose/lib/schemas/Base64URLSchema.js\");\nvar JOSEHeaderSchema = __webpack_require__(/*! ./schemas/JOSEHeaderSchema */ \"./node_modules/@trust/jose/lib/schemas/JOSEHeaderSchema.js\");\nvar JWKSchema = __webpack_require__(/*! ./schemas/JWKSchema */ \"./node_modules/@trust/jose/lib/schemas/JWKSchema.js\");\nvar JWKSetSchema = __webpack_require__(/*! ./schemas/JWKSetSchema */ \"./node_modules/@trust/jose/lib/schemas/JWKSetSchema.js\");\nvar JWTClaimsSetSchema = __webpack_require__(/*! ./schemas/JWTClaimsSetSchema */ \"./node_modules/@trust/jose/lib/schemas/JWTClaimsSetSchema.js\");\nvar JWTSchema = __webpack_require__(/*! ./schemas/JWTSchema */ \"./node_modules/@trust/jose/lib/schemas/JWTSchema.js\"\n\n/**\n * Export\n */\n);module.exports = {\n JWA: JWA,\n JWK: JWK,\n JWKSet: JWKSet,\n JWT: JWT,\n JWS: JWS,\n Base64URLSchema: Base64URLSchema,\n JOSEHeaderSchema: JOSEHeaderSchema,\n JWKSchema: JWKSchema,\n JWKSetSchema: JWKSetSchema,\n JWTClaimsSetSchema: JWTClaimsSetSchema,\n JWTSchema: JWTSchema\n};\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/index.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/jose/JWA.js": +/*!**************************************************!*\ + !*** ./node_modules/@trust/jose/lib/jose/JWA.js ***! + \**************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * Dependencies\n *\n * TODO\n * - switch between Node.js webcrypto package and browser implementation\n */\nvar base64url = __webpack_require__(/*! base64url */ \"./node_modules/base64url/index.js\");\nvar supportedAlgorithms = __webpack_require__(/*! ../algorithms */ \"./node_modules/@trust/jose/lib/algorithms/index.js\");\n\nvar _require = __webpack_require__(/*! ../errors */ \"./node_modules/@trust/jose/lib/errors/index.js\"\n\n/**\n * JWA\n * https://tools.ietf.org/html/rfc7518\n */\n),\n NotSupportedError = _require.NotSupportedError;\n\nvar JWA = function () {\n function JWA() {\n _classCallCheck(this, JWA);\n }\n\n _createClass(JWA, null, [{\n key: 'sign',\n\n\n /**\n * Sign\n *\n * @description\n * Create a digital signature.\n *\n * @param {string} alg\n * @param {CryptoKey} key\n * @param {string|Buffer} data\n *\n * @return {Promise}\n */\n value: function sign(alg, key, data) {\n // normalize the algorithm\n var normalizedAlgorithm = supportedAlgorithms.normalize('sign', alg\n\n // validate algorithm is supported\n );if (normalizedAlgorithm instanceof Error) {\n return Promise.reject(new NotSupportedError(alg));\n }\n\n // validate type of key\n // TODO\n // - is the key suitable for the algorithm?\n // - does that get validated in webcrypto?\n //if (key instanceof CryptoKey) {\n // return Promise.reject(new InvalidKeyError())\n //}\n\n // sign the data\n return normalizedAlgorithm.sign(key, data);\n }\n\n /**\n * Verify\n *\n * @description\n * Verify a digital signature.\n *\n * @param {string} alg\n * @param {CryptoKey} privateKey\n * @param {string|Buffer} signature\n * @param {string|Buffer} data\n *\n * @return {Promise}\n */\n\n }, {\n key: 'verify',\n value: function verify(alg, key, signature, data) {\n var normalizedAlgorithm = supportedAlgorithms.normalize('verify', alg);\n\n if (normalizedAlgorithm instanceof Error) {\n return Promise.reject(new NotSupportedError(alg));\n }\n\n // TODO\n // validate publicKey\n\n // verify the signature\n return normalizedAlgorithm.verify(key, signature, data);\n }\n\n /**\n * Encrypt\n */\n\n /**\n * Decrypt\n */\n\n /**\n * Import\n */\n\n }, {\n key: 'importKey',\n value: function importKey(key) {\n var normalizedAlgorithm = supportedAlgorithms.normalize('importKey', key.alg);\n return normalizedAlgorithm.importKey(key);\n }\n }]);\n\n return JWA;\n}();\n\n/**\n * Export\n */\n\n\nmodule.exports = JWA;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/jose/JWA.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/jose/JWK.js": +/*!**************************************************!*\ + !*** ./node_modules/@trust/jose/lib/jose/JWK.js ***! + \**************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Dependencies\n * @ignore\n */\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar _require = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\"),\n JSONDocument = _require.JSONDocument;\n\nvar JWKSchema = __webpack_require__(/*! ../schemas/JWKSchema */ \"./node_modules/@trust/jose/lib/schemas/JWKSchema.js\");\nvar JWA = __webpack_require__(/*! ./JWA */ \"./node_modules/@trust/jose/lib/jose/JWA.js\"\n\n/**\n * JWK Class\n */\n);\nvar JWK = function (_JSONDocument) {\n _inherits(JWK, _JSONDocument);\n\n function JWK() {\n _classCallCheck(this, JWK);\n\n return _possibleConstructorReturn(this, (JWK.__proto__ || Object.getPrototypeOf(JWK)).apply(this, arguments));\n }\n\n _createClass(JWK, null, [{\n key: 'importKey',\n\n\n /**\n * importKey\n *\n * TODO:\n * - should this be on JWA?\n */\n value: function importKey(jwk) {\n return JWA.importKey(jwk);\n }\n }, {\n key: 'schema',\n\n\n /**\n * Schema\n */\n get: function get() {\n return JWKSchema;\n }\n }]);\n\n return JWK;\n}(JSONDocument);\n\n/**\n * Export\n */\n\n\nmodule.exports = JWK;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/jose/JWK.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/jose/JWKSet.js": +/*!*****************************************************!*\ + !*** ./node_modules/@trust/jose/lib/jose/JWKSet.js ***! + \*****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Dependencies\n */\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar _require = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\"),\n JSONDocument = _require.JSONDocument;\n\nvar JWKSetSchema = __webpack_require__(/*! ../schemas/JWKSetSchema */ \"./node_modules/@trust/jose/lib/schemas/JWKSetSchema.js\");\nvar JWK = __webpack_require__(/*! ./JWK */ \"./node_modules/@trust/jose/lib/jose/JWK.js\"\n\n/**\n * JWKSet\n *\n * @class\n * JWKSet represents a JSON Web Key Set as described in Section 5 of RFC 7517:\n * https://tools.ietf.org/html/rfc7517#section-5\n */\n);\nvar JWKSet = function (_JSONDocument) {\n _inherits(JWKSet, _JSONDocument);\n\n function JWKSet() {\n _classCallCheck(this, JWKSet);\n\n return _possibleConstructorReturn(this, (JWKSet.__proto__ || Object.getPrototypeOf(JWKSet)).apply(this, arguments));\n }\n\n _createClass(JWKSet, null, [{\n key: 'importKeys',\n\n\n /**\n * importKeys\n */\n value: function importKeys(jwks) {\n var validation = this.schema.validate(jwks);\n\n if (!validation.valid) {\n return Promise.reject(new Error('Invalid JWKSet: ' + JSON.stringify(validation, null, 2)));\n }\n\n if (!jwks.keys) {\n return Promise.reject(new Error('Cannot import JWKSet: keys property is empty'));\n }\n\n var imported = void 0,\n importing = void 0;\n\n try {\n imported = new JWKSet(jwks);\n importing = jwks.keys.map(function (key) {\n return JWK.importKey(key);\n });\n } catch (err) {\n return Promise.reject(err);\n }\n\n return Promise.all(importing).then(function (keys) {\n imported.keys = keys;\n return imported;\n });\n }\n }, {\n key: 'schema',\n\n\n /**\n * schema\n */\n get: function get() {\n return JWKSetSchema;\n }\n }]);\n\n return JWKSet;\n}(JSONDocument);\n\n/**\n * Export\n */\n\n\nmodule.exports = JWKSet;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/jose/JWKSet.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/jose/JWS.js": +/*!**************************************************!*\ + !*** ./node_modules/@trust/jose/lib/jose/JWS.js ***! + \**************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nvar _slicedToArray = function () { function sliceIterator(arr, i) { var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i[\"return\"]) _i[\"return\"](); } finally { if (_d) throw _e; } } return _arr; } return function (arr, i) { if (Array.isArray(arr)) { return arr; } else if (Symbol.iterator in Object(arr)) { return sliceIterator(arr, i); } else { throw new TypeError(\"Invalid attempt to destructure non-iterable instance\"); } }; }();\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\n/**\n * Dependencies\n */\nvar base64url = __webpack_require__(/*! base64url */ \"./node_modules/base64url/index.js\");\nvar JWA = __webpack_require__(/*! ./JWA */ \"./node_modules/@trust/jose/lib/jose/JWA.js\");\n\nvar _require = __webpack_require__(/*! ../errors */ \"./node_modules/@trust/jose/lib/errors/index.js\"\n\n/**\n * JWS\n */\n),\n DataError = _require.DataError;\n\nvar JWS = function () {\n function JWS() {\n _classCallCheck(this, JWS);\n }\n\n _createClass(JWS, null, [{\n key: 'sign',\n\n\n /**\n * sign\n *\n * @description\n * Encode a JWT instance\n *\n * @param {Object} token\n * @returns {Promise}\n */\n value: function sign(token) {\n var payload = base64url(JSON.stringify(token.payload)\n\n // compact serialization\n );if (token.serialization === 'compact') {\n var key = token.key,\n alg = token.header.alg;\n\n var header = base64url(JSON.stringify(token.header));\n var data = header + '.' + payload;\n\n return JWA.sign(alg, key, data).then(function (signature) {\n return data + '.' + signature;\n });\n }\n\n // JSON serialization\n if (token.serialization === 'json') {}\n\n // Flattened serialization\n if (token.serialization === 'flattened') {}\n\n return Promise.reject(new DataError('Unsupported serialization'));\n }\n\n /**\n * verify\n */\n\n }, {\n key: 'verify',\n value: function verify(jwt) {\n // multiple signatures\n if (jwt.signatures) {\n // ...\n }\n\n var key = jwt.key,\n signature = jwt.signature,\n alg = jwt.header.alg;\n\n // one signature\n\n if (jwt.signature) {\n var _jwt$segments = _slicedToArray(jwt.segments, 2),\n header = _jwt$segments[0],\n payload = _jwt$segments[1];\n\n var data = header + '.' + payload;\n\n if (alg === 'none') {\n return Promise.reject(new DataError('Signature provided to verify with alg: none'));\n }\n\n return JWA.verify(alg, key, signature, data).then(function (verified) {\n jwt.verified = verified;\n return verified;\n });\n }\n\n if (alg === 'none') {\n if (!key && !signature) {\n jwt.verified = true;\n\n return Promise.resolve(true);\n }\n\n if (key) {\n return Promise.reject(new DataError('Key provided to verify signature with alg: none'));\n }\n }\n\n // no signatures to verify\n return Promise.reject(new DataError('Missing signature(s)'));\n }\n }]);\n\n return JWS;\n}();\n\n/**\n * Export\n */\n\n\nmodule.exports = JWS;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/jose/JWS.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/jose/JWT.js": +/*!**************************************************!*\ + !*** ./node_modules/@trust/jose/lib/jose/JWT.js ***! + \**************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\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 _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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\n/**\n * Dependencies\n */\nvar base64url = __webpack_require__(/*! base64url */ \"./node_modules/base64url/index.js\");\n\nvar _require = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\"),\n JSONDocument = _require.JSONDocument;\n\nvar JWTSchema = __webpack_require__(/*! ../schemas/JWTSchema */ \"./node_modules/@trust/jose/lib/schemas/JWTSchema.js\");\nvar JWS = __webpack_require__(/*! ./JWS */ \"./node_modules/@trust/jose/lib/jose/JWS.js\");\nvar DataError = __webpack_require__(/*! ../errors/DataError */ \"./node_modules/@trust/jose/lib/errors/DataError.js\"\n\n/**\n * JWT\n */\n);\nvar JWT = function (_JSONDocument) {\n _inherits(JWT, _JSONDocument);\n\n function JWT() {\n _classCallCheck(this, JWT);\n\n return _possibleConstructorReturn(this, (JWT.__proto__ || Object.getPrototypeOf(JWT)).apply(this, arguments));\n }\n\n _createClass(JWT, [{\n key: 'isJWE',\n\n\n /**\n * isJWE\n */\n value: function isJWE() {\n return !!this.header.enc;\n }\n\n /**\n * resolveKeys\n */\n\n }, {\n key: 'resolveKeys',\n value: function resolveKeys(jwks) {\n var kid = this.header.kid;\n var keys = void 0,\n match = void 0;\n\n // treat an array as the \"keys\" property of a JWK Set\n if (Array.isArray(jwks)) {\n keys = jwks;\n }\n\n // presence of keys indicates object is a JWK Set\n if (jwks.keys) {\n keys = jwks.keys;\n }\n\n // wrap a plain object they is not a JWK Set in Array\n if (!jwks.keys && (typeof jwks === 'undefined' ? 'undefined' : _typeof(jwks)) === 'object') {\n keys = [jwks];\n }\n\n // ensure there are keys to search\n if (!keys) {\n throw new DataError('Invalid JWK argument');\n }\n\n // match by \"kid\" or \"use\" header\n if (kid) {\n match = keys.find(function (jwk) {\n return jwk.kid === kid;\n });\n } else {\n match = keys.find(function (jwk) {\n return jwk.use === 'sig';\n });\n }\n\n // assign matching key to JWT and return a boolean\n if (match) {\n this.key = match.cryptoKey;\n return true;\n } else {\n return false;\n }\n }\n\n /**\n * encode\n *\n * @description\n * Encode a JWT instance\n *\n * @returns {Promise}\n */\n\n }, {\n key: 'encode',\n value: function encode() {\n // validate\n var validation = this.validate();\n\n if (!validation.valid) {\n return Promise.reject(validation);\n }\n\n var token = this;\n\n if (this.isJWE()) {\n return JWE.encrypt(token);\n } else {\n return JWS.sign(token);\n }\n }\n\n /**\n * verify\n *\n * @description\n * Verify a decoded JWT instance\n *\n * @returns {Promise}\n */\n\n }, {\n key: 'verify',\n value: function verify() {\n var validation = this.validate();\n\n if (!validation.valid) {\n return Promise.reject(validation);\n }\n\n return JWS.verify(this);\n }\n }], [{\n key: 'decode',\n\n\n /**\n * decode\n *\n * @description\n * Decode a JSON Web Token\n *\n * @param {string} data\n * @returns {JWT}\n */\n value: function decode(data) {\n var ExtendedJWT = this;\n var jwt = void 0;\n\n if (typeof data !== 'string') {\n throw new DataError('JWT must be a string');\n }\n\n // JSON of Flattened JSON Serialization\n if (data.startsWith('{')) {\n try {\n data = JSON.parse(data, function () {});\n } catch (error) {\n throw new DataError('Invalid JWT serialization');\n }\n\n if (data.signatures || data.recipients) {\n data.serialization = 'json';\n } else {\n data.serialization = 'flattened';\n }\n\n jwt = new ExtendedJWT(data, { filter: false });\n\n // Compact Serialization\n } else {\n try {\n var serialization = 'compact';\n var segments = data.split('.');\n var length = segments.length;\n\n if (length !== 3 && length !== 5) {\n throw new Error('Malformed JWT');\n }\n\n var header = JSON.parse(base64url.decode(segments[0])\n\n // JSON Web Signature\n );if (length === 3) {\n var type = 'JWS';\n var payload = JSON.parse(base64url.decode(segments[1]));\n var signature = segments[2];\n\n jwt = new ExtendedJWT({ type: type, segments: segments, header: header, payload: payload, signature: signature, serialization: serialization }, { filter: false });\n }\n\n // JSON Web Encryption\n if (length === 5) {\n //let type = 'JWE'\n //let [protected, encryption_key, iv, ciphertext, tag] = segments\n\n //jwt = new ExtendedJWT({\n // type,\n // protected: base64url.decode(JSON.parse(protected)),\n // encryption_key,\n // iv,\n // ciphertext,\n // tag,\n // serialization\n //})\n }\n } catch (error) {\n throw new DataError('Invalid JWT compact serialization');\n }\n }\n\n return jwt;\n }\n\n /**\n * encode\n *\n * @description\n * Encode a JSON Web Token\n *\n * @param {Object} header\n * @param {Object} payload\n * @param {CryptoKey} key\n *\n * @returns {Promise}\n */\n\n }, {\n key: 'encode',\n value: function encode(header, payload, key) {\n var jwt = new JWT(header, payload);\n return jwt.encode(key);\n }\n\n /**\n * verify\n *\n * @description\n *\n * @param {CryptoKey} key\n * @param {string} token\n *\n * @returns {Promise}\n */\n\n }, {\n key: 'verify',\n value: function verify(key, token) {\n var jwt = JWT.decode(token);\n jwt.key = key;\n return jwt.verify().then(function (verified) {\n return jwt;\n });\n }\n }, {\n key: 'schema',\n\n\n /**\n * schema\n */\n get: function get() {\n return JWTSchema;\n }\n }]);\n\n return JWT;\n}(JSONDocument);\n\n/**\n * Export\n */\n\n\nmodule.exports = JWT;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/jose/JWT.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/schemas/Base64URLSchema.js": +/*!*****************************************************************!*\ + !*** ./node_modules/@trust/jose/lib/schemas/Base64URLSchema.js ***! + \*****************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Dependencies\n */\nvar _require = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\"\n\n/**\n * Base64URLSchema\n */\n),\n JSONSchema = _require.JSONSchema;\n\nvar Base64URLSchema = new JSONSchema({\n type: 'string',\n format: 'base64url'\n});\n\n/**\n * Export\n */\nmodule.exports = Base64URLSchema;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/schemas/Base64URLSchema.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/schemas/JOSEHeaderSchema.js": +/*!******************************************************************!*\ + !*** ./node_modules/@trust/jose/lib/schemas/JOSEHeaderSchema.js ***! + \******************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Dependencies\n */\nvar JWKSchema = __webpack_require__(/*! ./JWKSchema */ \"./node_modules/@trust/jose/lib/schemas/JWKSchema.js\");\n\nvar _require = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\"\n\n/**\n * JOSEHeaderSchema\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-5\n *\n * 5. JOSE Header\n *\n * For a JWT object, the members of the JSON object represented by the\n * JOSE Header describe the cryptographic operations applied to the JWT\n * and optionally, additional properties of the JWT. Depending upon\n * whether the JWT is a JWS or JWE, the corresponding rules for the JOSE\n * Header values apply.\n */\n),\n JSONSchema = _require.JSONSchema;\n\nvar JOSEHeaderSchema = new JSONSchema({\n type: 'object',\n properties: {\n\n /**\n * typ\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-5.1\n *\n * 5.1. \"typ\" (Type) Header Parameter\n *\n * The \"typ\" (type) Header Parameter defined by [JWS] and [JWE] is used\n * by JWT applications to declare the media type [IANA.MediaTypes] of\n * this complete JWT. This is intended for use by the JWT application\n * when values that are not JWTs could also be present in an application\n * data structure that can contain a JWT object; the application can use\n * this value to disambiguate among the different kinds of objects that\n * might be present. It will typically not be used by applications when\n * it is already known that the object is a JWT. This parameter is\n * ignored by JWT implementations; any processing of this parameter is\n * performed by the JWT application. If present, it is RECOMMENDED that\n * its value be \"JWT\" to indicate that this object is a JWT. While\n * media type names are not case sensitive, it is RECOMMENDED that \"JWT\"\n * always be spelled using uppercase characters for compatibility with\n * legacy implementations. Use of this Header Parameter is OPTIONAL.\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.9\n *\n * 4.1.9. \"typ\" (Type) Header Parameter\n *\n * The \"typ\" (type) Header Parameter is used by JWS applications to\n * declare the media type [IANA.MediaTypes] of this complete JWS. This\n * is intended for use by the application when more than one kind of\n * object could be present in an application data structure that can\n * contain a JWS; the application can use this value to disambiguate\n * among the different kinds of objects that might be present. It will\n * typically not be used by applications when the kind of object is\n * already known. This parameter is ignored by JWS implementations; any\n * processing of this parameter is performed by the JWS application.\n * Use of this Header Parameter is OPTIONAL.\n *\n * Per RFC 2045 [RFC2045], all media type values, subtype values, and\n * parameter names are case insensitive. However, parameter values are\n * case sensitive unless otherwise specified for the specific parameter.\n *\n * To keep messages compact in common situations, it is RECOMMENDED that\n * producers omit an \"application/\" prefix of a media type value in a\n * \"typ\" Header Parameter when no other '/' appears in the media type\n * value. A recipient using the media type value MUST treat it as if\n * \"application/\" were prepended to any \"typ\" value not containing a\n * '/'. For instance, a \"typ\" value of \"example\" SHOULD be used to\n * represent the \"application/example\" media type, whereas the media\n * type \"application/example;part=\"1/2\"\" cannot be shortened to\n * \"example;part=\"1/2\"\".\n *\n * The \"typ\" value \"JOSE\" can be used by applications to indicate that\n * this object is a JWS or JWE using the JWS Compact Serialization or\n * the JWE Compact Serialization. The \"typ\" value \"JOSE+JSON\" can be\n * used by applications to indicate that this object is a JWS or JWE\n * using the JWS JSON Serialization or the JWE JSON Serialization.\n * Other type values can also be used by applications.\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.11\n *\n * 4.1.11. \"typ\" (Type) Header Parameter\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"typ\" Header Parameter defined in Section 4.1.9 of [JWS], except\n * that the type is that of this complete JWE.\n */\n typ: {\n type: 'string'\n },\n\n /**\n * cty\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-5.2\n *\n * 5.2. \"cty\" (Content Type) Header Parameter\n *\n * The \"cty\" (content type) Header Parameter defined by [JWS] and [JWE]\n * is used by this specification to convey structural information about\n * the JWT.\n *\n * In the normal case in which nested signing or encryption operations\n * are not employed, the use of this Header Parameter is NOT\n * RECOMMENDED. In the case that nested signing or encryption is\n * employed, this Header Parameter MUST be present; in this case, the\n * value MUST be \"JWT\", to indicate that a Nested JWT is carried in this\n * JWT. While media type names are not case sensitive, it is\n * RECOMMENDED that \"JWT\" always be spelled using uppercase characters\n * for compatibility with legacy implementations. See Appendix A.2 for\n * an example of a Nested JWT.\n *\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.10\n *\n * 4.1.10. \"cty\" (Content Type) Header Parameter\n *\n * The \"cty\" (content type) Header Parameter is used by JWS applications\n * to declare the media type [IANA.MediaTypes] of the secured content\n * (the payload). This is intended for use by the application when more\n * than one kind of object could be present in the JWS Payload; the\n * application can use this value to disambiguate among the different\n * kinds of objects that might be present. It will typically not be\n * used by applications when the kind of object is already known. This\n * parameter is ignored by JWS implementations; any processing of this\n * parameter is performed by the JWS application. Use of this Header\n * Parameter is OPTIONAL.\n *\n * Per RFC 2045 [RFC2045], all media type values, subtype values, and\n * parameter names are case insensitive. However, parameter values are\n * case sensitive unless otherwise specified for the specific parameter.\n *\n * To keep messages compact in common situations, it is RECOMMENDED that\n * producers omit an \"application/\" prefix of a media type value in a\n * \"cty\" Header Parameter when no other '/' appears in the media type\n * value. A recipient using the media type value MUST treat it as if\n * \"application/\" were prepended to any \"cty\" value not containing a\n * '/'. For instance, a \"cty\" value of \"example\" SHOULD be used to\n * represent the \"application/example\" media type, whereas the media\n * type \"application/example;part=\"1/2\"\" cannot be shortened to\n * \"example;part=\"1/2\"\".\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.12\n *\n * 4.1.12. \"cty\" (Content Type) Header Parameter\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"cty\" Header Parameter defined in Section 4.1.10 of [JWS], except\n * that the type is that of the secured content (the plaintext).\n */\n cty: {\n type: 'string',\n enum: ['JWT']\n },\n\n /**\n * alg\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.1\n *\n * 4.1.1. \"alg\" (Algorithm) Header Parameter\n *\n * The \"alg\" (algorithm) Header Parameter identifies the cryptographic\n * algorithm used to secure the JWS. The JWS Signature value is not\n * valid if the \"alg\" value does not represent a supported algorithm or\n * if there is not a key for use with that algorithm associated with the\n * party that digitally signed or MACed the content. \"alg\" values\n * should either be registered in the IANA \"JSON Web Signature and\n * Encryption Algorithms\" registry established by [JWA] or be a value\n * that contains a Collision-Resistant Name. The \"alg\" value is a case-\n * sensitive ASCII string containing a StringOrURI value. This Header\n * Parameter MUST be present and MUST be understood and processed by\n * implementations.\n *\n * A list of defined \"alg\" values for this use can be found in the IANA\n * \"JSON Web Signature and Encryption Algorithms\" registry established\n * by [JWA]; the initial contents of this registry are the values\n * defined in Section 3.1 of [JWA].\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.1\n *\n * 4.1.1. \"alg\" (Algorithm) Header Parameter\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"alg\" Header Parameter defined in Section 4.1.1 of [JWS], except\n * that the Header Parameter identifies the cryptographic algorithm used\n * to encrypt or determine the value of the CEK. The encrypted content\n * is not usable if the \"alg\" value does not represent a supported\n * algorithm, or if the recipient does not have a key that can be used\n * with that algorithm.\n *\n * A list of defined \"alg\" values for this use can be found in the IANA\n * \"JSON Web Signature and Encryption Algorithms\" registry established\n * by [JWA]; the initial contents of this registry are the values\n * defined in Section 4.1 of [JWA].\n */\n alg: {\n type: 'string',\n format: 'StringOrURI'\n },\n\n /**\n * jku\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.2\n *\n * 4.1.2. \"jku\" (JWK Set URL) Header Parameter (JWS)\n *\n * The \"jku\" (JWK Set URL) Header Parameter is a URI [RFC3986] that\n * refers to a resource for a set of JSON-encoded public keys, one of\n * which corresponds to the key used to digitally sign the JWS. The\n * keys MUST be encoded as a JWK Set [JWK]. The protocol used to\n * acquire the resource MUST provide integrity protection; an HTTP GET\n * request to retrieve the JWK Set MUST use Transport Layer Security\n * (TLS) [RFC2818] [RFC5246]; and the identity of the server MUST be\n * validated, as per Section 6 of RFC 6125 [RFC6125]. Also, see\n * Section 8 on TLS requirements. Use of this Header Parameter is\n * OPTIONAL.\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.4\n *\n * 4.1.4. \"jku\" (JWK Set URL) Header Parameter (JWE)\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"jku\" Header Parameter defined in Section 4.1.2 of [JWS], except\n * that the JWK Set resource contains the public key to which the JWE\n * was encrypted; this can be used to determine the private key needed\n * to decrypt the JWE.\n */\n jku: {\n type: 'string',\n format: 'URI'\n },\n\n /**\n * jwk\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.3\n *\n * 4.1.3. \"jwk\" (JSON Web Key) Header Parameter\n *\n * The \"jwk\" (JSON Web Key) Header Parameter is the public key that\n * corresponds to the key used to digitally sign the JWS. This key is\n * represented as a JSON Web Key [JWK]. Use of this Header Parameter is\n * OPTIONAL.\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.5\n *\n * 4.1.5. \"jwk\" (JSON Web Key) Header Parameter\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"jwk\" Header Parameter defined in Section 4.1.3 of [JWS], except\n * that the key is the public key to which the JWE was encrypted; this\n * can be used to determine the private key needed to decrypt the JWE.\n */\n //jwk: JWKSchema,\n\n /**\n * kid\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.4\n *\n * 4.1.4. \"kid\" (Key ID) Header Parameter\n *\n * The \"kid\" (key ID) Header Parameter is a hint indicating which key\n * was used to secure the JWS. This parameter allows originators to\n * explicitly signal a change of key to recipients. The structure of\n * the \"kid\" value is unspecified. Its value MUST be a case-sensitive\n * string. Use of this Header Parameter is OPTIONAL.\n *\n * When used with a JWK, the \"kid\" value is used to match a JWK \"kid\"\n * parameter value.\n *\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.6\n *\n * 4.1.6. \"kid\" (Key ID) Header Parameter\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"kid\" Header Parameter defined in Section 4.1.4 of [JWS], except\n * that the key hint references the public key to which the JWE was\n * encrypted; this can be used to determine the private key needed to\n * decrypt the JWE. This parameter allows originators to explicitly\n * signal a change of key to JWE recipients.\n */\n kid: {\n type: 'string'\n },\n\n /**\n * x5u\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.5\n *\n * 4.1.5. \"x5u\" (X.509 URL) Header Parameter\n *\n * The \"x5u\" (X.509 URL) Header Parameter is a URI [RFC3986] that refers\n * to a resource for the X.509 public key certificate or certificate\n * chain [RFC5280] corresponding to the key used to digitally sign the\n * JWS. The identified resource MUST provide a representation of the\n * certificate or certificate chain that conforms to RFC 5280 [RFC5280]\n * in PEM-encoded form, with each certificate delimited as specified in\n * Section 6.1 of RFC 4945 [RFC4945]. The certificate containing the\n * public key corresponding to the key used to digitally sign the JWS\n * MUST be the first certificate. This MAY be followed by additional\n * certificates, with each subsequent certificate being the one used to\n * certify the previous one. The protocol used to acquire the resource\n * MUST provide integrity protection; an HTTP GET request to retrieve\n * the certificate MUST use TLS [RFC2818] [RFC5246]; and the identity of\n * the server MUST be validated, as per Section 6 of RFC 6125 [RFC6125].\n * Also, see Section 8 on TLS requirements. Use of this Header\n * Parameter is OPTIONAL.\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.7\n *\n * 4.1.7. \"x5u\" (X.509 URL) Header Parameter\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"x5u\" Header Parameter defined in Section 4.1.5 of [JWS], except\n * that the X.509 public key certificate or certificate chain [RFC5280]\n * contains the public key to which the JWE was encrypted; this can be\n * used to determine the private key needed to decrypt the JWE.\n */\n x5u: {\n type: 'string',\n format: 'URI'\n },\n\n /**\n * x5c\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.6\n *\n * 4.1.6. \"x5c\" (X.509 Certificate Chain) Header Parameter\n *\n * The \"x5c\" (X.509 certificate chain) Header Parameter contains the\n * X.509 public key certificate or certificate chain [RFC5280]\n * corresponding to the key used to digitally sign the JWS. The\n * certificate or certificate chain is represented as a JSON array of\n * certificate value strings. Each string in the array is a\n * base64-encoded (Section 4 of [RFC4648] -- not base64url-encoded) DER\n * [ITU.X690.2008] PKIX certificate value. The certificate containing\n * the public key corresponding to the key used to digitally sign the\n * JWS MUST be the first certificate. This MAY be followed by\n * additional certificates, with each subsequent certificate being the\n * one used to certify the previous one. The recipient MUST validate\n * the certificate chain according to RFC 5280 [RFC5280] and consider\n * the certificate or certificate chain to be invalid if any validation\n * failure occurs. Use of this Header Parameter is OPTIONAL.\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.8\n *\n * 4.1.8. \"x5c\" (X.509 Certificate Chain) Header Parameter\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"x5c\" Header Parameter defined in Section 4.1.6 of [JWS], except\n * that the X.509 public key certificate or certificate chain [RFC5280]\n * contains the public key to which the JWE was encrypted; this can be\n * used to determine the private key needed to decrypt the JWE.\n */\n x5c: {\n type: 'array',\n items: {\n type: 'string',\n format: 'base64'\n }\n },\n\n /**\n * x5t\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.7\n *\n * 4.1.7. \"x5t\" (X.509 Certificate SHA-1 Thumbprint) Header Parameter\n *\n * The \"x5t\" (X.509 certificate SHA-1 thumbprint) Header Parameter is a\n * base64url-encoded SHA-1 thumbprint (a.k.a. digest) of the DER\n * encoding of the X.509 certificate [RFC5280] corresponding to the key\n * used to digitally sign the JWS. Note that certificate thumbprints\n * are also sometimes known as certificate fingerprints. Use of this\n * Header Parameter is OPTIONAL.\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.9\n *\n * 4.1.9. \"x5t\" (X.509 Certificate SHA-1 Thumbprint) Header Parameter\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"x5t\" Header Parameter defined in Section 4.1.7 of [JWS], except\n * that the certificate referenced by the thumbprint contains the public\n * key to which the JWE was encrypted; this can be used to determine the\n * private key needed to decrypt the JWE. Note that certificate\n * thumbprints are also sometimes known as certificate fingerprints.\n */\n x5t: {\n type: 'string',\n format: 'base64url'\n },\n\n /**\n * x5t#S256\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.8\n *\n * 4.1.8. \"x5t#S256\" (X.509 Certificate SHA-256 Thumbprint) Header\n * Parameter\n *\n * The \"x5t#S256\" (X.509 certificate SHA-256 thumbprint) Header\n * Parameter is a base64url-encoded SHA-256 thumbprint (a.k.a. digest)\n * of the DER encoding of the X.509 certificate [RFC5280] corresponding\n * to the key used to digitally sign the JWS. Note that certificate\n * thumbprints are also sometimes known as certificate fingerprints.\n * Use of this Header Parameter is OPTIONAL.\n *\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.10\n *\n * 4.1.10. \"x5t#S256\" (X.509 Certificate SHA-256 Thumbprint) Header\n * Parameter\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"x5t#S256\" Header Parameter defined in Section 4.1.8 of [JWS],\n * except that the certificate referenced by the thumbprint contains the\n * public key to which the JWE was encrypted; this can be used to\n * determine the private key needed to decrypt the JWE. Note that\n * certificate thumbprints are also sometimes known as certificate\n * fingerprints.\n */\n //'x5t#S256': {\n // type: 'string',\n // format: 'base64url'\n //},\n\n /**\n * crit\n *\n * JSON Web Signature (JWS)\n * https://tools.ietf.org/html/rfc7515#section-4.1.11\n *\n * 4.1.11. \"crit\" (Critical) Header Parameter\n *\n * The \"crit\" (critical) Header Parameter indicates that extensions to\n * this specification and/or [JWA] are being used that MUST be\n * understood and processed. Its value is an array listing the Header\n * Parameter names present in the JOSE Header that use those extensions.\n * If any of the listed extension Header Parameters are not understood\n * and supported by the recipient, then the JWS is invalid. Producers\n * MUST NOT include Header Parameter names defined by this specification\n * or [JWA] for use with JWS, duplicate names, or names that do not\n * occur as Header Parameter names within the JOSE Header in the \"crit\"\n * list. Producers MUST NOT use the empty list \"[]\" as the \"crit\"\n * value. Recipients MAY consider the JWS to be invalid if the critical\n * list contains any Header Parameter names defined by this\n * specification or [JWA] for use with JWS or if any other constraints\n * on its use are violated. When used, this Header Parameter MUST be\n * integrity protected; therefore, it MUST occur only within the JWS\n * Protected Header. Use of this Header Parameter is OPTIONAL. This\n * Header Parameter MUST be understood and processed by implementations.\n *\n * An example use, along with a hypothetical \"exp\" (expiration time)\n * field is:\n *\n * {\"alg\":\"ES256\",\n * \"crit\":[\"exp\"],\n * \"exp\":1363284000\n * }\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.13\n *\n * 4.1.13. \"crit\" (Critical) Header Parameter\n *\n * This parameter has the same meaning, syntax, and processing rules as\n * the \"crit\" Header Parameter defined in Section 4.1.11 of [JWS],\n * except that Header Parameters for a JWE are being referred to, rather\n * than Header Parameters for a JWS.\n */\n crit: {\n type: 'array',\n items: {\n type: 'string'\n },\n minItems: 1\n },\n\n /**\n * enc\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.2\n *\n * 4.1.2. \"enc\" (Encryption Algorithm) Header Parameter\n *\n * The \"enc\" (encryption algorithm) Header Parameter identifies the\n * content encryption algorithm used to perform authenticated encryption\n * on the plaintext to produce the ciphertext and the Authentication\n * Tag. This algorithm MUST be an AEAD algorithm with a specified key\n * length. The encrypted content is not usable if the \"enc\" value does\n * not represent a supported algorithm. \"enc\" values should either be\n * registered in the IANA \"JSON Web Signature and Encryption Algorithms\"\n * registry established by [JWA] or be a value that contains a\n * Collision-Resistant Name. The \"enc\" value is a case-sensitive ASCII\n * string containing a StringOrURI value. This Header Parameter MUST be\n * present and MUST be understood and processed by implementations.\n *\n * A list of defined \"enc\" values for this use can be found in the IANA\n * \"JSON Web Signature and Encryption Algorithms\" registry established\n * by [JWA]; the initial contents of this registry are the values\n * defined in Section 5.1 of [JWA].\n */\n enc: {\n type: 'string',\n format: 'StringOrURI'\n },\n\n /**\n * zip\n *\n * JSON Web Encryption (JWE)\n * https://tools.ietf.org/html/rfc7516#section-4.1.3\n *\n * 4.1.3. \"zip\" (Compression Algorithm) Header Parameter\n *\n * The \"zip\" (compression algorithm) applied to the plaintext before\n * encryption, if any. The \"zip\" value defined by this specification\n * is:\n *\n * o \"DEF\" - Compression with the DEFLATE [RFC1951] algorithm\n *\n * Other values MAY be used. Compression algorithm values can be\n * registered in the IANA \"JSON Web Encryption Compression Algorithms\"\n * registry established by [JWA]. The \"zip\" value is a case-sensitive\n * string. If no \"zip\" parameter is present, no compression is applied\n * to the plaintext before encryption. When used, this Header Parameter\n * MUST be integrity protected; therefore, it MUST occur only within the\n * JWE Protected Header. Use of this Header Parameter is OPTIONAL.\n * This Header Parameter MUST be understood and processed by\n * implementations.\n */\n zip: {\n type: 'string'\n }\n }\n});\n\n/**\n * Export\n */\nmodule.exports = JOSEHeaderSchema;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/schemas/JOSEHeaderSchema.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/schemas/JWKSchema.js": +/*!***********************************************************!*\ + !*** ./node_modules/@trust/jose/lib/schemas/JWKSchema.js ***! + \***********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Dependencies\n * @ignore\n */\n\nvar _require = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\"),\n JSONSchema = _require.JSONSchema;\n\nvar _require2 = __webpack_require__(/*! ../formats */ \"./node_modules/@trust/jose/lib/formats/index.js\"\n\n/**\n * JWK Schema\n */\n),\n BASE64_REGEXP = _require2.BASE64_REGEXP;\n\nvar JWKSchema = new JSONSchema({\n type: 'object',\n properties: {\n\n kty: {\n type: 'string',\n //format: 'case-sensitive',\n enum: ['RSA', 'EC', 'oct'] // other values MAY be used\n },\n\n use: {\n type: 'string',\n //format: 'case-sensitive',\n enum: ['sig', 'enc'] // other values MAY be used\n },\n\n key_ops: {\n type: 'array',\n //format: 'case-sensitive',\n items: {\n enum: ['sign', 'verify', 'encrypt', 'decrypt', 'wrapKey', 'unwrapKey', 'deriveKey', 'deriveBits'] // other values MAY be used\n }\n },\n\n alg: {\n type: 'string',\n //format: 'case-sensitive',\n enum: ['HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512', 'ES256', 'ES384', 'ES512', 'PS256', 'PS384', 'PS512', 'none'] // other values MAY be used\n },\n\n kid: {\n type: 'string'\n },\n\n x5u: {\n type: 'string'\n //format: 'url'\n },\n\n x5c: {\n type: 'array'\n //format: BASE64_REGEXP\n },\n\n x5t: {\n type: 'string'\n //format: BASE64_REGEXP\n }\n\n //'x5t#S256': {\n // type: 'string',\n // //format: BASE64_REGEXP\n //}\n }\n});\n\n/**\n * Export\n */\nmodule.exports = JWKSchema;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/schemas/JWKSchema.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/schemas/JWKSetSchema.js": +/*!**************************************************************!*\ + !*** ./node_modules/@trust/jose/lib/schemas/JWKSetSchema.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Dependencies\n */\n\nvar _require = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\"),\n JSONSchema = _require.JSONSchema;\n\nvar JWKSchema = __webpack_require__(/*! ./JWKSchema */ \"./node_modules/@trust/jose/lib/schemas/JWKSchema.js\"\n\n/**\n * JWKSetSchema\n */\n);var JWKSetSchema = new JSONSchema({\n type: 'object',\n properties: {\n keys: {\n type: 'array',\n items: JWKSchema\n }\n }\n});\n\n/**\n * Export\n */\nmodule.exports = JWKSetSchema;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/schemas/JWKSetSchema.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/schemas/JWTClaimsSetSchema.js": +/*!********************************************************************!*\ + !*** ./node_modules/@trust/jose/lib/schemas/JWTClaimsSetSchema.js ***! + \********************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Dependencies\n */\nvar _require = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\"\n\n/**\n * JWTClaimsSetSchema\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-4\n *\n * 4. JWT Claims\n *\n * The JWT Claims Set represents a JSON object whose members are the\n * claims conveyed by the JWT. The Claim Names within a JWT Claims Set\n * MUST be unique; JWT parsers MUST either reject JWTs with duplicate\n * Claim Names or use a JSON parser that returns only the lexically last\n * duplicate member name, as specified in Section 15.12 (\"The JSON\n * Object\") of ECMAScript 5.1 [ECMAScript].\n *\n * The set of claims that a JWT must contain to be considered valid is\n * context dependent and is outside the scope of this specification.\n * Specific applications of JWTs will require implementations to\n * understand and process some claims in particular ways. However, in\n * the absence of such requirements, all claims that are not understood\n * by implementations MUST be ignored.\n *\n * There are three classes of JWT Claim Names: Registered Claim Names,\n * Public Claim Names, and Private Claim Names.\n */\n),\n JSONSchema = _require.JSONSchema;\n\nvar JWTClaimsSetSchema = new JSONSchema({\n properties: {\n\n /**\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-4.1\n *\n * 4.1. Registered Claim Names\n *\n * The following Claim Names are registered in the IANA \"JSON Web Token\n * Claims\" registry established by Section 10.1. None of the claims\n * defined below are intended to be mandatory to use or implement in all\n * cases, but rather they provide a starting point for a set of useful,\n * interoperable claims. Applications using JWTs should define which\n * specific claims they use and when they are required or optional. All\n * the names are short because a core goal of JWTs is for the\n * representation to be compact.\n */\n\n /**\n * iss\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-4.1.1\n *\n * 4.1.1. \"iss\" (Issuer) Claim\n *\n * The \"iss\" (issuer) claim identifies the principal that issued the\n * JWT. The processing of this claim is generally application specific.\n * The \"iss\" value is a case-sensitive string containing a StringOrURI\n * value. Use of this claim is OPTIONAL.\n */\n iss: {\n type: 'string',\n format: 'StringOrURI'\n },\n\n /**\n * sub\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-4.1.2\n *\n * 4.1.2. \"sub\" (Subject) Claim\n *\n * The \"sub\" (subject) claim identifies the principal that is the\n * subject of the JWT. The claims in a JWT are normally statements\n * about the subject. The subject value MUST either be scoped to be\n * locally unique in the context of the issuer or be globally unique.\n * The processing of this claim is generally application specific. The\n * \"sub\" value is a case-sensitive string containing a StringOrURI\n * value. Use of this claim is OPTIONAL.\n */\n sub: {\n type: 'string',\n format: 'StringOrURI'\n },\n\n /**\n * aud\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-4.1.3\n *\n * 4.1.3. \"aud\" (Audience) Claim\n *\n * The \"aud\" (audience) claim identifies the recipients that the JWT is\n * intended for. Each principal intended to process the JWT MUST\n * identify itself with a value in the audience claim. If the principal\n * processing the claim does not identify itself with a value in the\n * \"aud\" claim when this claim is present, then the JWT MUST be\n * rejected. In the general case, the \"aud\" value is an array of case-\n * sensitive strings, each containing a StringOrURI value. In the\n * special case when the JWT has one audience, the \"aud\" value MAY be a\n * single case-sensitive string containing a StringOrURI value. The\n * interpretation of audience values is generally application specific.\n * Use of this claim is OPTIONAL.\n */\n aud: {\n type: ['array', 'string'],\n format: 'StringOrURI',\n items: {\n format: 'StringOrURI'\n }\n },\n\n /**\n * exp\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-4.1.4\n *\n * 4.1.4. \"exp\" (Expiration Time) Claim\n *\n * The \"exp\" (expiration time) claim identifies the expiration time on\n * or after which the JWT MUST NOT be accepted for processing. The\n * processing of the \"exp\" claim requires that the current date/time\n * MUST be before the expiration date/time listed in the \"exp\" claim.\n *\n * Implementers MAY provide for some small leeway, usually no more than\n * a few minutes, to account for clock skew. Its value MUST be a number\n * containing a NumericDate value. Use of this claim is OPTIONAL.\n *\n */\n exp: {\n type: 'number',\n format: 'NumericDate'\n },\n\n /**\n * nbf\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-4.1.5\n *\n * 4.1.5. \"nbf\" (Not Before) Claim\n *\n * The \"nbf\" (not before) claim identifies the time before which the JWT\n * MUST NOT be accepted for processing. The processing of the \"nbf\"\n * claim requires that the current date/time MUST be after or equal to\n * the not-before date/time listed in the \"nbf\" claim. Implementers MAY\n * provide for some small leeway, usually no more than a few minutes, to\n * account for clock skew. Its value MUST be a number containing a\n * NumericDate value. Use of this claim is OPTIONAL.\n */\n nbf: {\n type: 'number',\n format: 'NumericDate'\n },\n\n /**\n * iat\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-4.1.6\n *\n * 4.1.6. \"iat\" (Issued At) Claim\n *\n * The \"iat\" (issued at) claim identifies the time at which the JWT was\n * issued. This claim can be used to determine the age of the JWT. Its\n * value MUST be a number containing a NumericDate value. Use of this\n * claim is OPTIONAL.\n */\n iat: {\n type: 'number',\n format: 'NumericDate'\n },\n\n /**\n * jti\n *\n * JSON Web Token (JWT)\n * https://tools.ietf.org/html/rfc7519#section-4.1.7\n *\n * 4.1.7. \"jti\" (JWT ID) Claim\n *\n * The \"jti\" (JWT ID) claim provides a unique identifier for the JWT.\n * The identifier value MUST be assigned in a manner that ensures that\n * there is a negligible probability that the same value will be\n * accidentally assigned to a different data object; if the application\n * uses multiple issuers, collisions MUST be prevented among values\n * produced by different issuers as well. The \"jti\" claim can be used\n * to prevent the JWT from being replayed. The \"jti\" value is a case-\n * sensitive string. Use of this claim is OPTIONAL.\n */\n jti: {\n type: 'string'\n }\n }\n});\n\n/**\n * Export\n */\nmodule.exports = JWTClaimsSetSchema;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/schemas/JWTClaimsSetSchema.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/schemas/JWTSchema.js": +/*!***********************************************************!*\ + !*** ./node_modules/@trust/jose/lib/schemas/JWTSchema.js ***! + \***********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Dependencies\n */\nvar Base64URLSchema = __webpack_require__(/*! ./Base64URLSchema */ \"./node_modules/@trust/jose/lib/schemas/Base64URLSchema.js\");\nvar JWTClaimsSetSchema = __webpack_require__(/*! ./JWTClaimsSetSchema */ \"./node_modules/@trust/jose/lib/schemas/JWTClaimsSetSchema.js\");\nvar JOSEHeaderSchema = __webpack_require__(/*! ./JOSEHeaderSchema */ \"./node_modules/@trust/jose/lib/schemas/JOSEHeaderSchema.js\");\n\nvar _require = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\"\n\n/**\n * JWTSchema\n *\n * @description\n * This schema represents all the things a deserialized JWT can be, i.e.,\n * either a JWS or JWE, and any serialization of them. Validation of well-\n * formedness for a given serialization is accomplished at the time of\n * encoding.\n */\n),\n JSONSchema = _require.JSONSchema;\n\nvar JWTSchema = new JSONSchema({\n type: 'object',\n properties: {\n\n /**\n * type\n */\n type: {\n type: 'string',\n enum: ['JWS', 'JWE']\n },\n\n /**\n * segments\n */\n segments: {\n type: 'array'\n },\n\n /**\n * header\n */\n header: JOSEHeaderSchema,\n\n /**\n * protected\n */\n protected: JOSEHeaderSchema,\n\n /**\n * unprotected\n */\n unprotected: JOSEHeaderSchema,\n\n /**\n * iv\n */\n iv: Base64URLSchema,\n\n /**\n * aad\n */\n aad: Base64URLSchema,\n\n /**\n * ciphertext\n */\n ciphertext: Base64URLSchema,\n\n /**\n * tag\n */\n tag: Base64URLSchema,\n\n /**\n * recipients\n */\n recipients: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n header: JOSEHeaderSchema,\n encrypted_key: Base64URLSchema\n }\n }\n },\n\n /**\n * payload\n */\n payload: JWTClaimsSetSchema,\n\n /**\n * signatures\n */\n signatures: {\n type: 'array',\n items: {\n type: 'object',\n properties: {\n protected: JOSEHeaderSchema,\n header: JOSEHeaderSchema,\n signature: Base64URLSchema,\n key: { type: 'object' }\n }\n }\n },\n\n /**\n * signature\n */\n signature: Base64URLSchema,\n\n /**\n * verified\n */\n verified: {\n type: 'boolean',\n default: false\n },\n\n /**\n * key\n */\n key: {\n type: 'object'\n },\n\n /**\n * serialization\n */\n serialization: {\n type: 'string',\n enum: ['compact', 'json', 'flattened'],\n default: 'compact'\n }\n }\n});\n\n/**\n * Export\n */\nmodule.exports = JWTSchema;\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/schemas/JWTSchema.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/jose/lib/text-encoder/index.js": +/*!************************************************************!*\ + !*** ./node_modules/@trust/jose/lib/text-encoder/index.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(global) {\n\nvar TextEncoder = global.TextEncoder ? global.TextEncoder // browser\n: __webpack_require__(/*! text-encoding */ \"text-encoding\").TextEncoder; // node shim\nmodule.exports = TextEncoder;\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack:///./node_modules/@trust/jose/lib/text-encoder/index.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/json-document/lib/Formats.js": +/*!**********************************************************!*\ + !*** ./node_modules/@trust/json-document/lib/Formats.js ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * JSON Schema Formats\n *\n * TODO\n * Is there a good way to express these over multiple lines with comments\n * for easier debugging and auditing?\n */\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar DATETIME_REGEXP = /^\\d\\d\\d\\d-[0-1]\\d-[0-3]\\d[t\\s][0-2]\\d:[0-5]\\d:[0-5]\\d(?:\\.\\d+)?(?:z|[+-]\\d\\d:\\d\\d)$/i;\nvar URI_REGEXP = /^(?:[a-z][a-z0-9+-.]*)?(?:\\:|\\/)\\/?[^\\s]*$/i;\nvar EMAIL_REGEXP = /^[a-z0-9.!#$%&'*+\\/=?^_`{|}~-]+@[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?(?:\\.[a-z0-9](?:[a-z0-9-]{0,61}[a-z0-9])?)*$/i;\nvar IPV4_REGEXP = /^(?:(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)\\.){3}(?:25[0-5]|2[0-4]\\d|[01]?\\d\\d?)$/;\nvar IPV6_REGEXP = /^\\s*(?:(?:(?:[0-9a-f]{1,4}:){7}(?:[0-9a-f]{1,4}|:))|(?:(?:[0-9a-f]{1,4}:){6}(?::[0-9a-f]{1,4}|(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){5}(?:(?:(?::[0-9a-f]{1,4}){1,2})|:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3})|:))|(?:(?:[0-9a-f]{1,4}:){4}(?:(?:(?::[0-9a-f]{1,4}){1,3})|(?:(?::[0-9a-f]{1,4})?:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){3}(?:(?:(?::[0-9a-f]{1,4}){1,4})|(?:(?::[0-9a-f]{1,4}){0,2}:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){2}(?:(?:(?::[0-9a-f]{1,4}){1,5})|(?:(?::[0-9a-f]{1,4}){0,3}:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(?:(?:[0-9a-f]{1,4}:){1}(?:(?:(?::[0-9a-f]{1,4}){1,6})|(?:(?::[0-9a-f]{1,4}){0,4}:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:))|(?::(?:(?:(?::[0-9a-f]{1,4}){1,7})|(?:(?::[0-9a-f]{1,4}){0,5}:(?:(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)(?:\\.(?:25[0-5]|2[0-4]\\d|1\\d\\d|[1-9]?\\d)){3}))|:)))(?:%.+)?\\s*$/i;\nvar HOSTNAME_REGEXP = /^[a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?(\\.[a-z](?:(?:[-0-9a-z]{0,61})?[0-9a-z])?)*$/i;\n\n/**\n * Formats\n */\n\nvar Formats = function () {\n function Formats() {\n _classCallCheck(this, Formats);\n }\n\n _createClass(Formats, [{\n key: 'register',\n\n\n /**\n * Register\n *\n * @description\n * Register a new mapping from named format to RegExp instance\n *\n * TODO\n * We can do some extra validation of the RegExp to\n * ensure it's the acceptable subset of RegExps allowed\n * by JSON Schema.\n *\n * @param {string} name\n * @param {RegExp} pattern\n * @returns {RegExp}\n */\n value: function register(name, pattern) {\n // verify name is a string\n if (typeof name !== 'string') {\n throw new Error('Format name must be a string');\n }\n\n // cast a string to RegExp\n if (typeof pattern === 'string') {\n pattern = new RegExp(pattern);\n }\n\n return this[name] = pattern;\n }\n\n /**\n * Resolve\n *\n * @description\n * Given a format name, return the corresponding registered validation. In the\n * event a format is not registered, throw an error.\n *\n * @param {string} name\n * @returns {RegExp}\n */\n\n }, {\n key: 'resolve',\n value: function resolve(name) {\n var format = this[name];\n\n if (!format) {\n throw new Error('Unknown JSON Schema format.');\n }\n\n return format;\n }\n\n /**\n * Test\n *\n * @description\n * Test that a value conforms to a format.\n *\n * @param {string} name\n * @param {string} value\n * @returns {Boolean}\n */\n\n }, {\n key: 'test',\n value: function test(name, value) {\n var format = this.resolve(name);\n return format.test(value);\n }\n }], [{\n key: 'initialize',\n\n\n /**\n * Initialize\n *\n * @description\n * Create a new Formats instance and register default formats\n *\n * @returns {Formats}\n */\n value: function initialize() {\n var formats = new Formats();\n formats.register('date-time', DATETIME_REGEXP);\n formats.register('uri', URI_REGEXP);\n formats.register('email', EMAIL_REGEXP);\n formats.register('ipv4', IPV4_REGEXP);\n formats.register('ipv6', IPV6_REGEXP);\n formats.register('hostname', HOSTNAME_REGEXP);\n return formats;\n }\n }]);\n\n return Formats;\n}();\n\n/**\n * Export\n */\n\n\nmodule.exports = Formats.initialize();\n\n//# sourceURL=webpack:///./node_modules/@trust/json-document/lib/Formats.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/json-document/lib/Initializer.js": +/*!**************************************************************!*\ + !*** ./node_modules/@trust/json-document/lib/Initializer.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Initializer\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\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar Initializer = function () {\n\n /**\n * constructor\n */\n function Initializer(schema, options) {\n _classCallCheck(this, Initializer);\n\n Object.assign(this, options || {});\n this.root = this.root || this;\n\n this.root.depth = this.root.depth || 1;\n\n if (this.level > this.root.depth) {\n this.root.depth = this.level;\n }\n\n this.level = this.level || 0;\n this.schema = schema;\n }\n\n /**\n * compile (static)\n */\n\n\n _createClass(Initializer, [{\n key: 'compile',\n\n\n /**\n * compile\n */\n value: function compile() {\n var root = this.root,\n depth = this.depth,\n level = this.level;\n\n var declarations = '';\n var body = '';\n\n // traverse the schema and generate code\n body += this.default();\n body += this.properties();\n //body += this.additionalProperties()\n body += this.items();\n //body += this.additionalItems()\n\n\n // value\n body += this.member();\n body += this.item();\n\n // after traversing the schema\n // generate the variable declarations\n if (root === this) {\n for (var i = 1; i <= this.root.depth; i++) {\n declarations += this.declaration(i);\n }\n\n return '\\n options = options || {}\\n\\n if (options.filter === false) {\\n Object.assign(target, JSON.parse(JSON.stringify(source)))\\n }\\n\\n ' + declarations + '\\n ' + body + '\\n ';\n }\n\n return body;\n }\n\n /**\n * declaration\n */\n\n }, {\n key: 'declaration',\n value: function declaration(level) {\n return '\\n var target' + level + '\\n var source' + level + '\\n var count' + level + '\\n ';\n }\n\n /**\n * default\n */\n\n }, {\n key: 'default',\n value: function _default() {\n var schema = this.schema,\n level = this.level,\n key = this.key,\n index = this.index;\n var value = schema.default; // rename default to value because it's a keyword and syntax highlighter breaks\n\n var block = '';\n\n if (schema.hasOwnProperty('default')) {\n\n if (key) {\n block += '\\n target' + level + '[\\'' + key + '\\'] = ' + JSON.stringify(value) + '\\n ';\n }\n\n if (index) {\n block += '\\n target' + level + '[' + index + '] = ' + JSON.stringify(value) + '\\n ';\n }\n\n if (level > 1) {\n block += '\\n count' + level + '++\\n ';\n }\n\n block = '\\n if (options.defaults !== false) {\\n ' + block + '\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * member\n */\n\n }, {\n key: 'member',\n value: function member() {\n var schema = this.schema,\n root = this.root,\n level = this.level,\n key = this.key;\n var properties = schema.properties,\n additionalProperties = schema.additionalProperties,\n items = schema.items,\n additionalItems = schema.additionalItems;\n\n var block = '';\n\n // `key` tells us to treat this subschema as an object member vs an array item\n // and the absence of the other values here indicates we are dealing with a\n // primitive value\n if (key && !properties && !additionalProperties && !items && !additionalItems) {\n\n // first generate the assignment statement\n block += '\\n target' + level + '[\\'' + key + '\\'] = source' + level + '[\\'' + key + '\\']\\n ';\n\n // for nested container objects, add the counter incrementing statement\n if (level > 1) {\n block += '\\n count' + level + '++\\n ';\n }\n\n // wrap the foregoing in a check for presence on the source\n block = '\\n if (source' + level + '.hasOwnProperty(\\'' + key + '\\')) {\\n ' + block + '\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * item\n */\n\n }, {\n key: 'item',\n value: function item() {\n var schema = this.schema,\n root = this.root,\n level = this.level,\n index = this.index;\n var properties = schema.properties,\n additionalProperties = schema.additionalProperties,\n items = schema.items,\n additionalItems = schema.additionalItems;\n\n var block = '';\n\n if (index && !properties && !additionalProperties && !items && !additionalItems) {\n\n block += '\\n target' + level + '[' + index + '] = source' + level + '[' + index + ']\\n ';\n\n if (level > 1) {\n block += '\\n count' + level + '++\\n ';\n }\n\n block = '\\n if (' + index + ' < len) {\\n ' + block + '\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * properties\n */\n\n }, {\n key: 'properties',\n value: function properties() {\n var schema = this.schema,\n root = this.root,\n level = this.level,\n key = this.key,\n index = this.index;\n var properties = schema.properties;\n\n var block = '';\n\n if (properties) {\n Object.keys(properties).forEach(function (key) {\n var subschema = properties[key];\n var initializer = new Initializer(subschema, { key: key, root: root, level: level + 1 });\n\n block += initializer.compile();\n });\n\n // root-level properties boilerplate\n if (root === this) {\n block = '\\n if (typeof source === \\'object\\' && source !== null && !Array.isArray(source)) {\\n if (typeof target !== \\'object\\') {\\n throw new Error(\\'?\\')\\n }\\n\\n source1 = source\\n target1 = target\\n count1 = 0\\n\\n ' + block + '\\n }\\n ';\n\n // nested properties boilerplate\n } else {\n\n if (index) {\n block = '\\n if (' + index + ' < source' + level + '.length || typeof source' + level + '[' + index + '] === \\'object\\') {\\n\\n source' + (level + 1) + ' = source' + level + '[' + index + '] || {}\\n count' + (level + 1) + ' = 0\\n\\n if (' + index + ' < target' + level + '.length || typeof target' + level + '[' + index + '] !== \\'object\\') {\\n target' + (level + 1) + ' = {}\\n if (' + index + ' < source' + level + '.length) {\\n count' + (level + 1) + '++\\n }\\n } else {\\n target' + (level + 1) + ' = target' + level + '[' + index + ']\\n }\\n\\n ' + block + '\\n\\n if (count' + (level + 1) + ' > 0) {\\n target' + level + '[' + index + '] = target' + (level + 1) + '\\n count' + level + '++\\n }\\n\\n } else {\\n target' + level + '[' + index + '] = source' + level + '[' + index + ']\\n count' + level + '++\\n }\\n ';\n }\n\n if (key) {\n block = '\\n if ((typeof source' + level + '[\\'' + key + '\\'] === \\'object\\'\\n && source' + level + '[\\'' + key + '\\'] !== null\\n && !Array.isArray(source' + level + '[\\'' + key + '\\']))\\n || !source' + level + '.hasOwnProperty(\\'' + key + '\\')) {\\n\\n source' + (level + 1) + ' = source' + level + '[\\'' + key + '\\'] || {}\\n count' + (level + 1) + ' = 0\\n\\n if (!target' + level + '.hasOwnProperty(\\'' + key + '\\')\\n || typeof target' + level + '[\\'' + key + '\\'] !== \\'object\\'\\n || target' + level + '[\\'' + key + '\\'] === null\\n || Array.isArray(target' + level + '[\\'' + key + '\\'])) {\\n target' + (level + 1) + ' = {}\\n if (source' + level + '.hasOwnProperty(\\'' + key + '\\')) {\\n count' + (level + 1) + '++\\n }\\n } else {\\n target' + (level + 1) + ' = target' + level + '[\\'' + key + '\\']\\n count' + (level + 1) + '++\\n }\\n\\n ' + block + '\\n\\n if (count' + (level + 1) + ' > 0) {\\n target' + level + '[\\'' + key + '\\'] = target' + (level + 1) + '\\n count' + level + '++\\n }\\n\\n } else {\\n target' + level + '[\\'' + key + '\\'] = source' + level + '[\\'' + key + '\\']\\n count' + level + '++\\n }\\n ';\n }\n }\n }\n\n return block;\n }\n\n /**\n *\n */\n\n }, {\n key: 'additionalProperties',\n value: function additionalProperties() {}\n\n /**\n * items\n */\n\n }, {\n key: 'items',\n value: function items() {\n var schema = this.schema,\n root = this.root,\n level = this.level,\n key = this.key,\n index = this.index;\n var items = schema.items;\n\n var block = '';\n\n if (items) {\n\n if (Array.isArray(items)) {\n // TODO\n //\n //\n //\n //\n //\n // ...\n\n } else if ((typeof items === 'undefined' ? 'undefined' : _typeof(items)) === 'object' && items !== null) {\n var _index = 'i' + (level + 1);\n var initializer = new Initializer(items, { index: _index, root: root, level: level + 1 });\n\n block += '\\n var sLen = source' + (level + 1) + '.length || 0\\n var tLen = target' + (level + 1) + '.length || 0\\n var len = 0\\n\\n if (sLen > len) { len = sLen }\\n // THIS IS WRONG, CAUSED SIMPLE ARRAY INIT TO FAIL (OVERWRITE\\n // EXISTING TARGET VALUES WITH UNDEFINED WHEN SOURCE IS SHORTER THAN\\n // TARGET). LEAVING HERE UNTIL WE FINISH TESTING AND SEE WHY IT MIGHT\\n // HAVE BEEN HERE IN THE FIRST PLACE.\\n //\\n // if (tLen > len) { len = tLen }\\n\\n for (var ' + _index + ' = 0; ' + _index + ' < len; ' + _index + '++) {\\n ' + initializer.compile() + '\\n }\\n ';\n }\n\n // root-level properties boilerplate\n if (root === this) {\n block = '\\n if (Array.isArray(source)) {\\n if (!Array.isArray(target)) {\\n throw new Error(\\'?\\')\\n }\\n\\n source1 = source\\n target1 = target\\n\\n ' + block + '\\n }\\n ';\n\n // nested properties boilerplate\n } else {\n block = '\\n if (Array.isArray(source' + level + '[\\'' + key + '\\']) || !source' + level + '.hasOwnProperty(\\'' + key + '\\')) {\\n\\n source' + (level + 1) + ' = source' + level + '[\\'' + key + '\\'] || []\\n count' + (level + 1) + ' = 0\\n\\n if (!target' + level + '.hasOwnProperty(\\'' + key + '\\') || !Array.isArray(target' + level + '[\\'' + key + '\\'])) {\\n target' + (level + 1) + ' = []\\n if (source' + level + '.hasOwnProperty(\\'' + key + '\\')) {\\n count' + (level + 1) + '++\\n }\\n\\n } else {\\n target' + (level + 1) + ' = target' + level + '[\\'' + key + '\\']\\n count' + (level + 1) + '++\\n }\\n\\n ' + block + '\\n\\n if (count' + (level + 1) + ' > 0) {\\n target' + level + '[\\'' + key + '\\'] = target' + (level + 1) + '\\n count' + level + '++\\n }\\n\\n } else {\\n target' + level + '[\\'' + key + '\\'] = source' + level + '[\\'' + key + '\\']\\n count' + level + '++\\n }\\n ';\n }\n }\n\n return block;\n }\n\n /**\n *\n */\n\n }, {\n key: 'additionalItems',\n value: function additionalItems() {}\n }], [{\n key: 'compile',\n value: function compile(schema) {\n var initializer = new Initializer(schema);\n var block = initializer.compile();\n\n //console.log(beautify(block))\n try {\n return new Function('target', 'source', 'options', block);\n } catch (e) {\n console.log(e, e.stack);\n }\n }\n }]);\n\n return Initializer;\n}();\n\nmodule.exports = Initializer;\n\n//# sourceURL=webpack:///./node_modules/@trust/json-document/lib/Initializer.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/json-document/lib/JSONDocument.js": +/*!***************************************************************!*\ + !*** ./node_modules/@trust/json-document/lib/JSONDocument.js ***! + \***************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Module dependencies\n * @ignore\n */\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar JSONPatch = __webpack_require__(/*! ./JSONPatch */ \"./node_modules/@trust/json-document/lib/JSONPatch.js\");\n\n/**\n * JSONDocument\n *\n * @class\n * JSONDocument is a high level interface that binds together all other features of\n * this package and provides the principle method of data modeling.\n */\n\nvar JSONDocument = function () {\n _createClass(JSONDocument, null, [{\n key: 'schema',\n\n\n /**\n * Schema\n */\n get: function get() {\n throw new Error('Schema must be defined by classes extending JSONDocument');\n }\n\n /**\n * Constructor\n *\n * @param {Object} data\n * @param {Object} options\n */\n\n }]);\n\n function JSONDocument() {\n var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, JSONDocument);\n\n this.initialize(data, options);\n }\n\n /**\n * Initialize\n *\n * @param {Object} data\n * @param {Object} options\n */\n\n\n _createClass(JSONDocument, [{\n key: 'initialize',\n value: function initialize() {\n var data = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n var schema = this.constructor.schema;\n\n schema.initialize(this, data, options);\n }\n\n /**\n * Validate\n *\n * @param {JSONSchema} alternate - OPTIONAL alternate schema\n * @returns {Object}\n */\n\n }, {\n key: 'validate',\n value: function validate(alternate) {\n var schema = this.constructor.schema;\n\n return (alternate || schema).validate(this);\n }\n\n /**\n * Patch\n *\n * @param {Array} ops\n */\n\n }, {\n key: 'patch',\n value: function patch(ops) {\n var patch = new JSONPatch(ops);\n patch.apply(this);\n }\n\n /**\n * Select\n */\n\n }, {\n key: 'select',\n value: function select() {}\n\n /**\n * Project\n *\n * @description\n * Given a mapping, return an object projected from the current instance.\n *\n * @example\n * let schema = new JSONSchema({\n * properties: {\n * foo: { type: 'Array' }\n * }\n * })\n *\n * let mapping = new JSONMapping({\n * '/foo/0': '/bar/baz'\n * })\n *\n * class FooTracker extends JSONDocument {\n * static get schema () { return schema }\n * }\n *\n * let instance = new FooTracker({ foo: ['qux'] })\n * instance.project(mapping)\n * // => { bar: { baz: 'qux' } }\n *\n * @param {JSONMapping} mapping\n * @return {Object}\n */\n\n }, {\n key: 'project',\n value: function project(mapping) {\n return mapping.project(this);\n }\n\n /**\n * Serialize\n *\n * @param {Object} object\n * @returns {string}\n */\n\n }], [{\n key: 'serialize',\n value: function serialize(object) {\n return JSON.stringify(object);\n }\n\n /**\n * Deserialize\n *\n * @param {string} data\n * @return {*}\n */\n\n }, {\n key: 'deserialize',\n value: function deserialize(data) {\n try {\n return JSON.parse(data);\n } catch (e) {\n throw new Error('Failed to parse JSON');\n }\n }\n }]);\n\n return JSONDocument;\n}();\n\n/**\n * Export\n */\n\n\nmodule.exports = JSONDocument;\n\n//# sourceURL=webpack:///./node_modules/@trust/json-document/lib/JSONDocument.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/json-document/lib/JSONMapping.js": +/*!**************************************************************!*\ + !*** ./node_modules/@trust/json-document/lib/JSONMapping.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Module dependencies\n * @ignore\n */\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar JSONPointer = __webpack_require__(/*! ./JSONPointer */ \"./node_modules/@trust/json-document/lib/JSONPointer.js\");\n\n/**\n * JSONPointer mode\n */\nvar RECOVER = 1;\n\n/**\n * JSONMapping\n *\n * @class\n * Defines a means to declaratively translate between object\n * representations using JSON Pointer syntax.\n */\n\nvar JSONMapping = function () {\n\n /**\n * Constructor\n *\n * @description Translate pointers from JSON Strings into Pointer objects\n * @param {Object} mapping\n */\n function JSONMapping(mapping) {\n var _this = this;\n\n _classCallCheck(this, JSONMapping);\n\n Object.defineProperty(this, 'mapping', {\n enumerable: false,\n value: new Map()\n });\n\n Object.keys(mapping).forEach(function (key) {\n var value = mapping[key];\n _this.mapping.set(new JSONPointer(key, RECOVER), new JSONPointer(value, RECOVER));\n });\n }\n\n /**\n * Map\n *\n * @description Assign values from source to target by reading the mapping\n * from right to left.\n * @param {Object} target\n * @param {Object} source\n */\n\n\n _createClass(JSONMapping, [{\n key: 'map',\n value: function map(target, source) {\n this.mapping.forEach(function (right, left) {\n left.add(target, right.get(source));\n });\n }\n\n /**\n * Project\n *\n * @description Assign values from source to target by reading the mapping\n * from left to right.\n * @param {Object} source\n * @param {Object} target\n */\n\n }, {\n key: 'project',\n value: function project(source, target) {\n this.mapping.forEach(function (right, left) {\n right.add(target, left.get(source));\n });\n }\n }]);\n\n return JSONMapping;\n}();\n\n/**\n * Exports\n */\n\n\nmodule.exports = JSONMapping;\n\n//# sourceURL=webpack:///./node_modules/@trust/json-document/lib/JSONMapping.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/json-document/lib/JSONPatch.js": +/*!************************************************************!*\ + !*** ./node_modules/@trust/json-document/lib/JSONPatch.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Module dependencies\n * @ignore\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\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar JSONPointer = __webpack_require__(/*! ./JSONPointer */ \"./node_modules/@trust/json-document/lib/JSONPointer.js\");\n\n/**\n * Modes\n */\nvar THROW = 0;\nvar RECOVER = 1;\nvar SILENT = 2;\n\n/**\n * Operations list\n */\nvar OPERATIONS = ['add', 'remove', 'replace', 'move', 'copy', 'test'];\n\n/**\n * Patch\n *\n * @class\n * Implements RFC 6902: JavaScript Object Notation (JSON) Patch\n * https://tools.ietf.org/html/rfc6902\n */\n\nvar JSONPatch = function () {\n\n /**\n * Constructor\n *\n * @param {Array} ops\n */\n function JSONPatch(ops) {\n _classCallCheck(this, JSONPatch);\n\n this.ops = ops || [];\n }\n\n /**\n * Apply\n *\n * @todo handle errors/roll back\n * @todo protect properties that are private in the schema\n * @todo map JSON Pointers real property names\n *\n * @param {Object} target\n */\n\n\n _createClass(JSONPatch, [{\n key: 'apply',\n value: function apply(target) {\n var _this = this;\n\n this.ops.forEach(function (operation) {\n var op = operation.op;\n\n if (!op) {\n throw new Error('Missing \"op\" in JSON Patch operation');\n }\n\n if (OPERATIONS.indexOf(op) === -1) {\n throw new Error('Invalid \"op\" in JSON Patch operation');\n }\n\n if (!operation.path) {\n throw new Error('Missing \"path\" in JSON Patch operation');\n }\n\n _this[op](operation, target);\n });\n }\n\n /**\n * Add\n *\n * @param {Object} op\n * @param {Object} target\n */\n\n }, {\n key: 'add',\n value: function add(op, target) {\n if (op.value === undefined) {\n throw new Error('Missing \"value\" in JSON Patch add operation');\n }\n\n var pointer = new JSONPointer(op.path, SILENT);\n pointer.add(target, op.value);\n }\n\n /**\n * Remove\n *\n * @param {Object} op\n * @param {Object} target\n */\n\n }, {\n key: 'remove',\n value: function remove(op, target) {\n var pointer = new JSONPointer(op.path);\n pointer.remove(target);\n }\n\n /**\n * Replace\n *\n * @param {Object} op\n * @param {Object} target\n */\n\n }, {\n key: 'replace',\n value: function replace(op, target) {\n if (op.value === undefined) {\n throw new Error('Missing \"value\" in JSON Patch replace operation');\n }\n\n var pointer = new JSONPointer(op.path);\n pointer.replace(target, op.value);\n }\n\n /**\n * Move\n *\n * @param {Object} op\n * @param {Object} target\n */\n\n }, {\n key: 'move',\n value: function move(op, target) {\n if (op.from === undefined) {\n throw new Error('Missing \"from\" in JSON Patch move operation');\n }\n\n if (op.path.match(new RegExp('^' + op.from))) {\n throw new Error('Invalid \"from\" in JSON Patch move operation');\n }\n\n var pointer = new JSONPointer(op.path);\n var from = new JSONPointer(op.from);\n var value = from.get(target);\n\n from.remove(target);\n pointer.add(target, value);\n }\n\n /**\n * Copy\n *\n * @param {Object} op\n * @param {Object} target\n */\n\n }, {\n key: 'copy',\n value: function copy(op, target) {\n if (op.from === undefined) {\n throw new Error('Missing \"from\" in JSON Patch copy operation');\n }\n\n var pointer = new JSONPointer(op.path);\n var from = new JSONPointer(op.from);\n var value = from.get(target);\n\n pointer.add(target, value);\n }\n\n /**\n * Test\n *\n * @param {Object} op\n * @param {Object} target\n */\n\n }, {\n key: 'test',\n value: function test(op, target) {\n if (op.value === undefined) {\n throw new Error('Missing \"value\" in JSON Patch test operation');\n }\n\n var pointer = new JSONPointer(op.path);\n var value = pointer.get(target);\n\n switch (_typeof(op.value)) {\n //case 'string':\n //case 'number':\n //case 'boolean':\n // if (value !== op.value) {\n // throw new Error('Mismatching JSON Patch test value')\n // }\n default:\n if (value !== op.value) {\n throw new Error('Mismatching JSON Patch test value');\n }\n }\n }\n }]);\n\n return JSONPatch;\n}();\n\n/**\n * Exports\n */\n\n\nmodule.exports = JSONPatch;\n\n//# sourceURL=webpack:///./node_modules/@trust/json-document/lib/JSONPatch.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/json-document/lib/JSONPointer.js": +/*!**************************************************************!*\ + !*** ./node_modules/@trust/json-document/lib/JSONPointer.js ***! + \**************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Mode enumeration\n */\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar THROW = 0;\nvar RECOVER = 1;\nvar SILENT = 2;\n\n/**\n * JSONPointer\n *\n * @class\n * Implements RFC 6901: JavaScript Object Notation (JSON) Pointer\n * https://tools.ietf.org/html/rfc6901\n */\n\nvar JSONPointer = function () {\n\n /**\n * Constructor\n */\n function JSONPointer(expr, mode) {\n _classCallCheck(this, JSONPointer);\n\n this.expr = expr;\n this.mode = mode || THROW;\n this.tokens = expr && expr.charAt(0) === '#' ? this.parseURIFragmentIdentifier(expr) : this.parseJSONString(expr);\n }\n\n /**\n * Escape\n */\n\n\n _createClass(JSONPointer, [{\n key: 'escape',\n value: function escape(expr) {\n return expr.replace(/~/g, '~0').replace(/\\//g, '~1');\n }\n\n /**\n * Unescape\n */\n\n }, {\n key: 'unescape',\n value: function unescape(expr) {\n return expr.replace(/~1/g, '/').replace(/~0/g, '~');\n }\n\n /**\n * Parse\n */\n\n }, {\n key: 'parseJSONString',\n\n\n /**\n * Parse JSON String\n *\n * @description Parse an expression into a list of tokens\n * @param {string} expr\n * @returns {Array}\n */\n value: function parseJSONString(expr) {\n if (typeof expr !== 'string') {\n throw new Error('JSON Pointer must be a string');\n }\n\n if (expr === '') {\n return [];\n }\n\n if (expr.charAt(0) !== '/') {\n throw new Error('Invalid JSON Pointer');\n }\n\n if (expr === '/') {\n return [''];\n }\n\n return expr.substr(1).split('/').map(this.unescape);\n }\n\n /**\n * To JSON String\n *\n * @description Render a JSON string representation of a pointer\n * @returns {string}\n */\n\n }, {\n key: 'toJSONString',\n value: function toJSONString() {\n return '/' + this.tokens.map(this.escape).join('/');\n }\n\n /**\n * Parse URI Fragment Identifer\n */\n\n }, {\n key: 'parseURIFragmentIdentifier',\n value: function parseURIFragmentIdentifier(expr) {\n if (typeof expr !== 'string') {\n throw new Error('JSON Pointer must be a string');\n }\n\n if (expr.charAt(0) !== '#') {\n throw new Error('Invalid JSON Pointer URI Fragment Identifier');\n }\n\n return this.parseJSONString(decodeURIComponent(expr.substr(1)));\n }\n\n /**\n * To URI Fragment Identifier\n *\n * @description Render a URI Fragment Identifier representation of a pointer\n * @returns {string}\n */\n\n }, {\n key: 'toURIFragmentIdentifier',\n value: function toURIFragmentIdentifier() {\n var _this = this;\n\n var value = this.tokens.map(function (token) {\n return encodeURIComponent(_this.escape(token));\n }).join('/');\n\n return '#/' + value;\n }\n\n /**\n * Get\n *\n * @description Get a value from the source object referenced by the pointer\n * @param {Object} source\n * @returns {*}\n */\n\n }, {\n key: 'get',\n value: function get(source) {\n var current = source;\n var tokens = this.tokens;\n\n for (var i = 0; i < tokens.length; i++) {\n if (!current || current[tokens[i]] === undefined) {\n if (this.mode !== THROW) {\n return undefined;\n } else {\n throw new Error('Invalid JSON Pointer reference');\n }\n }\n\n current = current[tokens[i]];\n }\n\n return current;\n }\n\n /**\n * Add\n *\n * @description Set a value on a target object referenced by the pointer. Put\n * will insert an array element. To change an existing array elemnent, use\n * `pointer.set()`\n * @param {Object} target\n * @param {*} value\n */\n\n }, {\n key: 'add',\n value: function add(target, value) {\n var tokens = this.tokens;\n var current = target;\n\n // iterate through the tokens\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i];\n\n // set the property on the target location\n if (i === tokens.length - 1) {\n if (token === '-') {\n current.push(value);\n } else if (Array.isArray(current)) {\n current.splice(token, 0, value);\n } else if (value !== undefined) {\n current[token] = value;\n }\n\n // handle missing target location based on \"mode\"\n } else if (!current[token]) {\n switch (this.mode) {\n case THROW:\n throw new Error('Invalid JSON Pointer reference');\n\n case RECOVER:\n current = current[token] = parseInt(token) ? [] : {};\n break;\n\n case SILENT:\n return;\n\n default:\n throw new Error('Invalid pointer mode');\n }\n\n // reference the next object in the path\n } else {\n current = current[token];\n }\n }\n }\n\n /**\n * Replace\n *\n * @description Set a value on a target object referenced by the pointer. Set will\n * overwrite an existing array element at the target location.\n * @param {Object} target\n * @param {*} value\n */\n\n }, {\n key: 'replace',\n value: function replace(target, value) {\n var tokens = this.tokens;\n var current = target;\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i];\n\n if (i === tokens.length - 1) {\n current[token] = value;\n } else if (!current[token]) {\n current = current[token] = parseInt(token) ? [] : {};\n } else {\n current = current[token];\n }\n }\n }\n\n /**\n * Del\n *\n * - if this is an array it should splice the value out\n */\n\n }, {\n key: 'remove',\n value: function remove(target) {\n var tokens = this.tokens;\n var current = target;\n\n for (var i = 0; i < tokens.length; i++) {\n var token = tokens[i];\n\n if (current === undefined || current[token] === undefined) {\n return undefined;\n } else if (Array.isArray(current)) {\n current.splice(token, 1);\n return undefined;\n } else if (i === tokens.length - 1) {\n delete current[token];\n }\n\n current = current[token];\n }\n\n // delete from the target\n }\n }], [{\n key: 'parse',\n value: function parse(expr) {\n return new JSONPointer(expr);\n }\n }]);\n\n return JSONPointer;\n}();\n\n/**\n * Exports\n */\n\n\nmodule.exports = JSONPointer;\n\n//# sourceURL=webpack:///./node_modules/@trust/json-document/lib/JSONPointer.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/json-document/lib/JSONSchema.js": +/*!*************************************************************!*\ + !*** ./node_modules/@trust/json-document/lib/JSONSchema.js ***! + \*************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Module dependencies\n * @ignore\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\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\nfunction _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar Initializer = __webpack_require__(/*! ./Initializer */ \"./node_modules/@trust/json-document/lib/Initializer.js\");\nvar Validator = __webpack_require__(/*! ./Validator */ \"./node_modules/@trust/json-document/lib/Validator.js\");\n\n/**\n * JSONSchema\n *\n * @class\n * Compiles JSON Schema documents to an object with object initialization\n * and validation methods.\n */\n\nvar JSONSchema = function () {\n\n /**\n * Constructor\n *\n * @param {Object} schema\n */\n function JSONSchema(schema) {\n _classCallCheck(this, JSONSchema);\n\n // TODO: optionally parse JSON string?\n Object.assign(this, schema);\n\n // add schema-derived initialize and validate methods\n Object.defineProperties(this, {\n initialize: {\n enumerable: false,\n writeable: false,\n value: Initializer.compile(schema)\n },\n validate: {\n enumerable: false,\n writeable: false,\n value: Validator.compile(schema)\n }\n });\n }\n\n /**\n * Extend\n *\n * @description\n * ...\n * Dear future,\n *\n * This function was meticulously plagiarized from some curious amalgam of\n * stackoverflow posts whilst dozing off at my keyboard, too deprived of REM-\n * sleep to recurse unassisted. If it sucks, you have only yourself to blame.\n *\n * Goodnight.\n *\n * @param {Object} schema\n * @returns {JSONSchema}\n */\n\n\n _createClass(JSONSchema, [{\n key: 'extend',\n value: function extend(schema) {\n function isObject(data) {\n return data && (typeof data === 'undefined' ? 'undefined' : _typeof(data)) === 'object' && data !== null && !Array.isArray(data);\n }\n\n function extender(target, source) {\n var result = Object.assign({}, target);\n if (isObject(target) && isObject(source)) {\n Object.keys(source).forEach(function (key) {\n if (isObject(source[key])) {\n if (!(key in target)) {\n Object.assign(result, _defineProperty({}, key, source[key]));\n } else {\n result[key] = extender(target[key], source[key]);\n }\n } else {\n Object.assign(result, _defineProperty({}, key, source[key]));\n }\n });\n }\n return result;\n }\n\n var descriptor = extender(this, schema);\n return new JSONSchema(descriptor);\n }\n }]);\n\n return JSONSchema;\n}();\n\n/**\n * Export\n */\n\n\nmodule.exports = JSONSchema;\n\n//# sourceURL=webpack:///./node_modules/@trust/json-document/lib/JSONSchema.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/json-document/lib/Validator.js": +/*!************************************************************!*\ + !*** ./node_modules/@trust/json-document/lib/Validator.js ***! + \************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Module dependencies\n * @ignore\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\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nvar formats = __webpack_require__(/*! ./Formats */ \"./node_modules/@trust/json-document/lib/Formats.js\");\n\n/**\n * For variable iterator counter\n *\n * @type {number}\n */\nvar indexCount = 0;\n\n/**\n * Validator\n *\n * Compile an object describing a JSON Schema into a validation function.\n */\n\nvar Validator = function () {\n _createClass(Validator, null, [{\n key: 'compile',\n\n\n /**\n * Compile (static)\n *\n * @description\n * Compile an object describing a JSON Schema into a validation function.\n *\n * @param {Object} schema\n * @returns {Function}\n */\n value: function compile(schema) {\n var validator = new Validator(schema);\n\n var body = '\\n // \"cursor\"\\n let value = data\\n let container\\n let stack = []\\n let top = -1\\n\\n // error state\\n let valid = true\\n let errors = []\\n\\n // complex schema state\\n let initialValidity\\n let anyValid\\n let notValid\\n let countOfValid\\n let initialErrorCount\\n let accumulatedErrorCount\\n\\n // validation code\\n ' + validator.compile() + '\\n\\n // validation result\\n return {\\n valid,\\n errors\\n }\\n ';\n\n return new Function('data', body);\n }\n\n /**\n * Return current iterator index counter and increase value\n *\n * @returns {number}\n */\n\n }, {\n key: 'counter',\n get: function get() {\n return indexCount++;\n }\n\n /**\n * Constructor\n *\n * @param {Object} schema - object representation of a schema\n * @param {string} options - compilation options\n */\n\n }]);\n\n function Validator(schema) {\n var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};\n\n _classCallCheck(this, Validator);\n\n // assign schema to this\n this.schema = schema;\n\n // assign all options to this\n Object.assign(this, options);\n\n // ensure address is defined\n if (!this.address) {\n this.address = '';\n }\n\n // ensure require is boolean\n if (this.require !== true) {\n this.require = false;\n }\n }\n\n /**\n * Compile\n *\n * @description\n * The instance compile method is \"dumb\". It only sequences invocation of\n * more specific compilation methods. It generates code to\n *\n * - read a value from input\n * - validate type(s) of input\n * - validate constraints described by various schema keywords\n *\n * Conditional logic related to code generation is pushed downsteam to\n * type-specific methods.\n */\n\n\n _createClass(Validator, [{\n key: 'compile',\n value: function compile() {\n var block = '';\n\n if (this.require) {\n block += this.required();\n }\n\n // type validation\n block += this.type();\n\n // type specific validation generators\n // null and boolean are covered by this.type()\n // integer should be covered by number and this.type()\n block += this.array();\n block += this.number();\n block += this.object();\n block += this.string();\n\n // non-type-specific validation generators\n block += this.enum();\n block += this.anyOf();\n block += this.allOf();\n block += this.not();\n block += this.oneOf();\n\n return block;\n }\n\n /**\n * push\n */\n\n }, {\n key: 'push',\n value: function push() {\n return '\\n stack.push(value)\\n container = value\\n top++\\n ';\n }\n\n /**\n * pop\n */\n\n }, {\n key: 'pop',\n value: function pop() {\n return '\\n if (stack.length > 1) {\\n top--\\n stack.pop()\\n }\\n\\n value = container = stack[top]\\n ';\n }\n\n /**\n * type\n *\n * @description\n * > An instance matches successfully if its primitive type is one of the\n * > types defined by keyword. Recall: \"number\" includes \"integer\".\n * > JSON Schema Validation Section 5.5.2\n *\n * @returns {string}\n */\n\n }, {\n key: 'type',\n value: function type() {\n var type = this.schema.type,\n address = this.address;\n\n var block = '';\n\n if (type) {\n var types = Array.isArray(type) ? type : [type];\n var conditions = types.map(function (type) {\n // TODO: can we make a mapping object for this to clean it up?\n if (type === 'array') return '!Array.isArray(value)';\n if (type === 'boolean') return 'typeof value !== \\'boolean\\'';\n if (type === 'integer') return '!Number.isInteger(value)';\n if (type === 'null') return 'value !== null';\n if (type === 'number') return 'typeof value !== \\'number\\'';\n if (type === 'object') return '(typeof value !== \\'object\\' || Array.isArray(value) || value === null)';\n if (type === 'string') return 'typeof value !== \\'string\\'';\n }).join(' && ');\n\n block += '\\n // ' + address + ' type checking\\n if (value !== undefined && ' + conditions + ') {\\n valid = false\\n errors.push({\\n keyword: \\'type\\',\\n message: \\'invalid type\\'\\n })\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * Type-specific validations\n *\n * Type checking is optional in JSON Schema, and a schema can allow\n * multiple types. Generated code needs to apply type-specific validations\n * only to appropriate values, and ignore everything else. Type validation\n * itself is handled separately from other validation keywords.\n *\n * The methods `array`, `number`, `object`, `string` generate type-specific\n * validation code blocks, wrapped in a conditional such that they will\n * only be applied to values of that type.\n *\n * For example, the `number` method, given the schema\n *\n * { minimum: 3 }\n *\n * will generate\n *\n * if (typeof value === 'number') {\n * if (value < 3) {\n * valid = false\n * errors.push({ message: '...' })\n * }\n * }\n *\n * Integer values are also numbers, and are validated the same as numbers\n * other than the type validation itself. Therefore no `integer` method is\n * needed.\n */\n\n /**\n * array\n *\n * @description\n * Invoke methods for array-specific keywords and wrap resulting code in\n * type-checking conditional so that any resulting validations are only\n * applied to array values.\n *\n * @returns {string}\n */\n\n }, {\n key: 'array',\n value: function array() {\n var keywords = ['additionalItems', 'items', 'minItems', 'maxItems', 'uniqueItems'];\n var validations = this.validations(keywords);\n var block = '';\n\n if (validations.length > 0) {\n block += '\\n /**\\n * Array validations\\n */\\n if (Array.isArray(value)) {\\n ' + validations + '\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * number\n *\n * @description\n * Invoke methods for number-specific keywords and wrap resulting code in\n * type-checking conditional so that any resulting validations are only\n * applied to number values.\n *\n * @returns {string}\n */\n\n }, {\n key: 'number',\n value: function number() {\n var keywords = ['minimum', 'maximum', 'multipleOf'];\n var validations = this.validations(keywords);\n var block = '';\n\n if (validations.length > 0) {\n block += '\\n /**\\n * Number validations\\n */\\n if (typeof value === \\'number\\') {\\n ' + validations + '\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * object\n *\n * @description\n * Invoke methods for object-specific keywords and wrap resulting code in\n * type-checking conditional so that any resulting validations are only\n * applied to object values.\n *\n * @returns {string}\n */\n\n }, {\n key: 'object',\n value: function object() {\n var keywords = ['maxProperties', 'minProperties', 'additionalProperties', 'properties', 'patternProperties', 'dependencies', 'schemaDependencies', 'propertyDependencies'];\n var validations = this.validations(keywords);\n var block = '';\n\n if (validations.length > 0) {\n block += '\\n /**\\n * Object validations\\n */\\n if (typeof value === \\'object\\' && value !== null && !Array.isArray(value)) {\\n ' + validations + '\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * string\n *\n * @description\n * Invoke methods for string-specific keywords and wrap resulting code in\n * type-checking conditional so that any resulting validations are only\n * applied to string values.\n *\n * @returns {string}\n */\n\n }, {\n key: 'string',\n value: function string() {\n var keywords = ['maxLength', 'minLength', 'pattern', 'format'];\n var validations = this.validations(keywords);\n var block = '';\n\n if (validations.length > 0) {\n block += '\\n /**\\n * String validations\\n */\\n if (typeof value === \\'string\\') {\\n ' + validations + '\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * validations\n *\n * @description\n * Iterate over an array of keywords and invoke code generator methods\n * for each. Concatenate the results together and return. Used by \"type\"\n * methods such as this.array() and this.string()\n *\n * @param {Array} keywords\n * @returns {string}\n */\n\n }, {\n key: 'validations',\n value: function validations(keywords) {\n var _this = this;\n\n var schema = this.schema;\n\n var block = '';\n\n var constraints = Object.keys(schema).filter(function (key) {\n return keywords.indexOf(key) !== -1;\n });\n\n constraints.forEach(function (keyword) {\n block += _this[keyword]();\n });\n\n return block;\n }\n\n /**\n * enum\n *\n * @description\n * > An instance validates successfully against this keyword if its value\n * > is equal to one of the elements in this keyword's array value.\n * > JSON Schema Validation Section 5.5.1\n *\n * @returns {string}\n */\n\n }, {\n key: 'enum',\n value: function _enum() {\n var enumerated = this.schema.enum,\n address = this.address;\n\n var conditions = ['value !== undefined'];\n var block = '';\n\n if (enumerated) {\n enumerated.forEach(function (value) {\n switch (typeof value === 'undefined' ? 'undefined' : _typeof(value)) {\n case 'boolean':\n conditions.push('value !== ' + value);\n break;\n\n case 'number':\n conditions.push('value !== ' + value);\n break;\n\n case 'string':\n conditions.push('value !== \"' + value + '\"');\n break;\n\n case 'object':\n if (value === null) {\n conditions.push('value !== null');\n } else {\n conditions.push('\\'' + JSON.stringify(value) + '\\' !== JSON.stringify(value)');\n }\n break;\n\n default:\n throw new Error('Things are not well in the land of enum');\n\n }\n });\n\n block += '\\n /**\\n * Validate \"' + address + '\" enum\\n */\\n if (' + conditions.join(' && ') + ') {\\n valid = false\\n errors.push({\\n keyword: \\'enum\\',\\n message: JSON.stringify(value) + \\' is not an enumerated value\\'\\n })\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * anyOf\n *\n * @description\n * > An instance validates successfully against this keyword if it\n * > validates successfully against at least one schema defined by this\n * > keyword's value.\n * > JSON Schema Validation Section 5.5.4\n *\n * @returns {string}\n */\n\n }, {\n key: 'anyOf',\n value: function anyOf() {\n var anyOf = this.schema.anyOf,\n address = this.address;\n\n var block = '';\n\n if (Array.isArray(anyOf)) {\n block += '\\n initialValidity = valid\\n initialErrorCount = errors.length\\n anyValid = false\\n ';\n\n anyOf.forEach(function (subschema) {\n var validator = new Validator(subschema, { address: address });\n block += '\\n accumulatedErrorCount = errors.length\\n ' + validator.compile() + '\\n if (accumulatedErrorCount === errors.length) {\\n anyValid = true\\n }\\n ';\n });\n\n block += '\\n if (anyValid === true) {\\n valid = initialValidity\\n errors = errors.slice(0, initialErrorCount)\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * allOf\n *\n * @description\n * > An instance validates successfully against this keyword if it\n * > validates successfully against all schemas defined by this keyword's\n * > value.\n * > JSON Schema Validation Section 5.5.3\n *\n * @returns {string}\n */\n\n }, {\n key: 'allOf',\n value: function allOf() {\n var allOf = this.schema.allOf,\n address = this.address;\n\n var block = '';\n\n if (Array.isArray(allOf)) {\n allOf.forEach(function (subschema) {\n var validator = new Validator(subschema, { address: address });\n block += '\\n ' + validator.compile() + '\\n ';\n });\n }\n\n return block;\n }\n\n /**\n * oneOf\n *\n * @description\n * > An instance validates successfully against this keyword if it\n * > validates successfully against exactly one schema defined by this\n * > keyword's value.\n * > JSON Schema Validation Section 5.5.5\n *\n * @returns {string}\n */\n\n }, {\n key: 'oneOf',\n value: function oneOf() {\n var oneOf = this.schema.oneOf,\n address = this.address;\n\n var block = '';\n\n if (Array.isArray(oneOf)) {\n block += '\\n /**\\n * Validate ' + address + ' oneOf\\n */\\n initialValidity = valid\\n initialErrorCount = errors.length\\n countOfValid = 0\\n ';\n\n oneOf.forEach(function (subschema) {\n var validator = new Validator(subschema, { address: address });\n block += '\\n accumulatedErrorCount = errors.length\\n ' + validator.compile() + '\\n if (accumulatedErrorCount === errors.length) {\\n countOfValid += 1\\n }\\n ';\n });\n\n block += '\\n if (countOfValid === 1) {\\n valid = initialValidity\\n errors = errors.slice(0, initialErrorCount)\\n } else {\\n valid = false\\n errors.push({\\n keyword: \\'oneOf\\',\\n message: \\'what is a reasonable error message for this case?\\'\\n })\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * not\n *\n * @description\n * > An instance is valid against this keyword if it fails to validate\n * > successfully against the schema defined by this keyword.\n * > JSON Schema Validation Section 5.5.6\n *\n * @returns {string}\n */\n\n }, {\n key: 'not',\n value: function not() {\n var not = this.schema.not,\n address = this.address;\n\n var block = '';\n\n if ((typeof not === 'undefined' ? 'undefined' : _typeof(not)) === 'object' && not !== null && !Array.isArray(not)) {\n var subschema = not;\n var validator = new Validator(subschema, { address: address });\n\n block += '\\n /**\\n * NOT\\n */\\n if (value !== undefined) {\\n initialValidity = valid\\n initialErrorCount = errors.length\\n notValid = true\\n\\n accumulatedErrorCount = errors.length\\n\\n ' + validator.compile() + '\\n\\n if (accumulatedErrorCount === errors.length) {\\n notValid = false\\n }\\n\\n if (notValid === true) {\\n valid = initialValidity\\n errors = errors.slice(0, initialErrorCount)\\n } else {\\n valid = false\\n errors = errors.slice(0, initialErrorCount)\\n errors.push({\\n keyword: \\'not\\',\\n message: \\'hmm...\\'\\n })\\n }\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * properties\n *\n * @description\n * Iterate over the `properties` schema property if it is an object. For each\n * key, initialize a new Validator for the subschema represented by the property\n * value and invoke compile. Append the result of compiling each subschema to\n * the block of code being generated.\n *\n * @returns {string}\n */\n\n }, {\n key: 'properties',\n value: function properties() {\n var schema = this.schema,\n address = this.address;\n var properties = schema.properties,\n required = schema.required;\n\n var block = this.push();\n\n // ensure the value of \"required\" schema property is an array\n required = Array.isArray(required) ? required : [];\n\n if ((typeof properties === 'undefined' ? 'undefined' : _typeof(properties)) === 'object') {\n Object.keys(properties).forEach(function (key) {\n var subschema = properties[key];\n var isRequired = required.indexOf(key) !== -1;\n // TODO\n // how should we be calculating these things? should be json pointer?\n // needs a separate function\n var pointer = [address, key].filter(function (segment) {\n return !!segment;\n }).join('.');\n var validation = new Validator(subschema, { address: pointer, require: isRequired });\n\n // read the value\n block += '\\n value = container[\\'' + key + '\\']\\n ';\n\n block += validation.compile();\n });\n }\n\n block += this.pop();\n\n return block;\n }\n\n /**\n * Other Properties\n *\n * @description\n * This method is not for a keyword. It wraps validations for\n * patternProperties and additionalProperties in a single iteration over\n * an object-type value's properties.\n *\n * It should only be invoked once for a given subschema.\n *\n * @returns {string}\n */\n\n }, {\n key: 'otherProperties',\n value: function otherProperties() {\n return '\\n /**\\n * Validate Other Properties\\n */\\n ' + this.push() + '\\n\\n for (let key in container) {\\n value = container[key]\\n matched = false\\n\\n ' + this.patternValidations() + '\\n ' + this.additionalValidations() + '\\n }\\n\\n ' + this.pop() + '\\n ';\n }\n\n /**\n * Pattern Validations\n *\n * @description\n * Generate validation code from a subschema for properties matching a\n * regular expression.\n *\n * @returns {string}\n */\n\n }, {\n key: 'patternValidations',\n value: function patternValidations() {\n var patternProperties = this.schema.patternProperties;\n\n var block = '';\n\n if ((typeof patternProperties === 'undefined' ? 'undefined' : _typeof(patternProperties)) === 'object') {\n Object.keys(patternProperties).forEach(function (pattern) {\n var subschema = patternProperties[pattern];\n var validator = new Validator(subschema);\n block += '\\n if (key.match(\\'' + pattern + '\\')) {\\n matched = true\\n ' + validator.compile() + '\\n }\\n ';\n });\n }\n\n return block;\n }\n\n /**\n * Additional Validations\n *\n * @description\n * Generate validation code, either from a subschema for properties not\n * defined in the schema, or to disallow properties not defined in the\n * schema.\n *\n * @returns {string}\n */\n\n }, {\n key: 'additionalValidations',\n value: function additionalValidations() {\n var _schema = this.schema,\n properties = _schema.properties,\n additionalProperties = _schema.additionalProperties,\n address = this.address;\n\n var validations = '';\n var block = '';\n\n // catch additional unmatched properties\n var conditions = ['matched !== true'];\n\n // ignore defined properties\n Object.keys(properties || {}).forEach(function (key) {\n conditions.push('key !== \\'' + key + '\\'');\n });\n\n // validate additional properties\n if ((typeof additionalProperties === 'undefined' ? 'undefined' : _typeof(additionalProperties)) === 'object') {\n var subschema = additionalProperties;\n var validator = new Validator(subschema, { address: address + '[APKey]' });\n block += '\\n // validate additional properties\\n if (' + conditions.join(' && ') + ') {\\n ' + validator.compile() + '\\n }\\n ';\n }\n\n // error for additional properties\n if (additionalProperties === false) {\n block += '\\n // validate non-presence of additional properties\\n if (' + conditions.join(' && ') + ') {\\n valid = false\\n errors.push({\\n keyword: \\'additionalProperties\\',\\n message: key + \\' is not a defined property\\'\\n })\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * patternProperties\n *\n * @description\n * Generate validation code for properties matching a pattern\n * defined by the property name (key), which must be a string\n * representing a valid regular expression.\n *\n * @returns {string}\n */\n\n }, {\n key: 'patternProperties',\n value: function patternProperties() {\n var block = '';\n\n if (!this.otherPropertiesCalled) {\n this.otherPropertiesCalled = true;\n block += this.otherProperties();\n }\n\n return block;\n }\n\n /**\n * additionalProperties\n *\n * @description\n * Generate validation code for additional properties not defined\n * in the schema, or disallow additional properties if the value of\n * `additionalProperties` in the schema is `false`.\n *\n * @returns {string}\n */\n\n }, {\n key: 'additionalProperties',\n value: function additionalProperties() {\n var block = '';\n\n if (!this.otherPropertiesCalled) {\n this.otherPropertiesCalled = true;\n block += this.otherProperties();\n }\n\n return block;\n }\n\n /**\n * minProperties\n *\n * @description\n * > An object instance is valid against \"minProperties\" if its number of\n * > properties is greater than, or equal to, the value of this keyword.\n * > JSON Schema Validation Section 5.4.2\n *\n * @returns {string}\n */\n\n }, {\n key: 'minProperties',\n value: function minProperties() {\n var minProperties = this.schema.minProperties,\n address = this.address;\n\n\n return '\\n // ' + address + ' min properties\\n if (Object.keys(value).length < ' + minProperties + ') {\\n valid = false\\n errors.push({\\n keyword: \\'minProperties\\',\\n message: \\'too few properties\\'\\n })\\n }\\n ';\n }\n\n /**\n * maxProperties\n *\n * @description\n * > An object instance is valid against \"maxProperties\" if its number of\n * > properties is less than, or equal to, the value of this keyword.\n * > JSON Schema Validation Section 5.4.1\n *\n * @returns {string}\n */\n\n }, {\n key: 'maxProperties',\n value: function maxProperties() {\n var maxProperties = this.schema.maxProperties,\n address = this.address;\n\n\n return '\\n // ' + address + ' max properties\\n if (Object.keys(value).length > ' + maxProperties + ') {\\n valid = false\\n errors.push({\\n keyword: \\'maxProperties\\',\\n message: \\'too many properties\\'\\n })\\n }\\n ';\n }\n\n /**\n * Dependencies\n *\n * @description\n * > For all (name, schema) pair of schema dependencies, if the instance has\n * > a property by this name, then it must also validate successfully against\n * > the schema.\n * >\n * > Note that this is the instance itself which must validate successfully,\n * > not the value associated with the property name.\n * >\n * > For each (name, propertyset) pair of property dependencies, if the\n * > instance has a property by this name, then it must also have properties\n * > with the same names as propertyset.\n * > JSON Schema Validation Section 5.4.5.2\n *\n * @returns {string}\n */\n\n }, {\n key: 'dependencies',\n value: function dependencies() {\n var dependencies = this.schema.dependencies,\n address = this.address;\n\n\n var block = this.push();\n\n if ((typeof dependencies === 'undefined' ? 'undefined' : _typeof(dependencies)) === 'object') {\n Object.keys(dependencies).forEach(function (key) {\n var dependency = dependencies[key];\n var conditions = [];\n\n if (Array.isArray(dependency)) {\n dependency.forEach(function (item) {\n conditions.push('container[\\'' + item + '\\'] === undefined');\n });\n\n block += '\\n if (container[\\'' + key + '\\'] !== undefined && (' + conditions.join(' || ') + ')) {\\n valid = false\\n errors.push({\\n keyword: \\'dependencies\\',\\n message: \\'unmet dependencies\\'\\n })\\n }\\n ';\n } else if ((typeof dependency === 'undefined' ? 'undefined' : _typeof(dependency)) === 'object') {\n var subschema = dependency;\n var validator = new Validator(subschema, { address: address });\n\n block += '\\n if (container[\\'' + key + '\\'] !== undefined) {\\n ' + validator.compile() + '\\n }\\n ';\n }\n });\n }\n\n block += this.pop();\n\n return block;\n }\n\n /**\n * Required\n *\n * @description\n * > An object instance is valid against this keyword if its property set\n * > contains all elements in this keyword's array value.\n * > JSON Schema Validation Section 5.4.3\n *\n * @returns {string}\n */\n\n }, {\n key: 'required',\n value: function required() {\n var properties = this.schema.properties,\n address = this.address;\n\n var block = '';\n\n block += '\\n // validate ' + address + ' presence\\n if (value === undefined) {\\n valid = false\\n errors.push({\\n keyword: \\'required\\',\\n message: \\'is required\\'\\n })\\n }\\n ';\n\n return block;\n }\n\n /**\n * additionalItems\n *\n * @description\n * > Successful validation of an array instance with regards to these two\n * > keywords is determined as follows: if \"items\" is not present, or its\n * > value is an object, validation of the instance always succeeds,\n * > regardless of the value of \"additionalItems\"; if the value of\n * > \"additionalItems\" is boolean value true or an object, validation of\n * > the instance always succeeds; if the value of \"additionalItems\" is\n * > boolean value false and the value of \"items\" is an array, the\n * > instance is valid if its size is less than, or equal to, the size\n * > of \"items\".\n * > JSON Schema Validation Section 5.3.1\n *\n * @returns {string}\n */\n\n }, {\n key: 'additionalItems',\n value: function additionalItems() {\n var _schema2 = this.schema,\n items = _schema2.items,\n additionalItems = _schema2.additionalItems,\n address = this.address;\n\n var block = '';\n\n if (additionalItems === false && Array.isArray(items)) {\n block += '\\n // don\\'t allow additional items\\n if (value.length > ' + items.length + ') {\\n valid = false\\n errors.push({\\n keyword: \\'additionalItems\\',\\n message: \\'additional items not allowed\\'\\n })\\n }\\n ';\n }\n\n if ((typeof additionalItems === 'undefined' ? 'undefined' : _typeof(additionalItems)) === 'object' && additionalItems !== null && Array.isArray(items)) {\n var subschema = additionalItems;\n var validator = new Validator(subschema);\n var counter = Validator.counter;\n\n block += '\\n // additional items\\n ' + this.push() + '\\n\\n for (var i' + counter + ' = ' + items.length + '; i' + counter + ' <= container.length; i' + counter + '++) {\\n value = container[i' + counter + ']\\n ' + validator.compile() + '\\n }\\n\\n ' + this.pop() + '\\n ';\n }\n\n return block;\n }\n\n /**\n * Items\n *\n * @description\n * > Successful validation of an array instance with regards to these two\n * > keywords is determined as follows: if \"items\" is not present, or its\n * > value is an object, validation of the instance always succeeds,\n * > regardless of the value of \"additionalItems\"; if the value of\n * > \"additionalItems\" is boolean value true or an object, validation of\n * > the instance always succeeds; if the value of \"additionalItems\" is\n * > boolean value false and the value of \"items\" is an array, the\n * > instance is valid if its size is less than, or equal to, the size\n * > of \"items\".\n * > JSON Schema Validation Section 5.3.1\n *\n * Code to generate\n *\n * // this outer conditional is generated by this.array()\n * if (Array.isArray(value) {\n * let parent = value\n * for (let i = 0; i < parent.length; i++) {\n * value = parent[i]\n * // other validation code depending on value here\n * }\n * value = parent\n * }\n *\n *\n * @returns {string}\n */\n\n }, {\n key: 'items',\n value: function items() {\n var items = this.schema.items,\n address = this.address;\n\n var block = '';\n\n // if items is an array\n if (Array.isArray(items)) {\n block += this.push();\n\n items.forEach(function (item, index) {\n var subschema = item;\n var validator = new Validator(subschema, { address: address + '[' + index + ']' });\n\n block += '\\n // item #' + index + '\\n value = container[' + index + ']\\n ' + validator.compile() + '\\n ';\n });\n\n block += this.pop();\n\n // if items is an object\n } else if ((typeof items === 'undefined' ? 'undefined' : _typeof(items)) === 'object' && items !== null) {\n var subschema = items;\n var validator = new Validator(subschema);\n var counter = Validator.counter;\n\n block += '\\n // items\\n ' + this.push() + '\\n\\n for (var i' + counter + ' = 0; i' + counter + ' < container.length; i' + counter + '++) {\\n // read array element\\n value = container[i' + counter + ']\\n ' + validator.compile() + '\\n }\\n\\n ' + this.pop() + '\\n ';\n }\n\n return block;\n }\n\n /**\n * minItems\n *\n * @description\n * > An array instance is valid against \"minItems\" if its size is greater\n * > than, or equal to, the value of this keyword.\n * > JSON Schema Validation Section 5.3.3\n *\n * @returns {string}\n */\n\n }, {\n key: 'minItems',\n value: function minItems() {\n var minItems = this.schema.minItems,\n address = this.address;\n\n\n return '\\n // ' + address + ' min items\\n if (value.length < ' + minItems + ') {\\n valid = false\\n errors.push({\\n keyword: \\'minItems\\',\\n message: \\'too few properties\\'\\n })\\n }\\n ';\n }\n\n /**\n * maxItems\n *\n * @description\n * > An array instance is valid against \"maxItems\" if its size is less\n * > than, or equal to, the value of this keyword.\n * > JSON Schema Validation Section 5.3.2\n *\n * @returns {string}\n */\n\n }, {\n key: 'maxItems',\n value: function maxItems() {\n var maxItems = this.schema.maxItems,\n address = this.address;\n\n\n return '\\n // ' + address + ' max items\\n if (value.length > ' + maxItems + ') {\\n valid = false\\n errors.push({\\n keyword: \\'maxItems\\',\\n message: \\'too many properties\\'\\n })\\n }\\n ';\n }\n\n /**\n * uniqueItems\n *\n * @description\n * > If this keyword has boolean value false, the instance validates\n * > successfully. If it has boolean value true, the instance validates\n * > successfully if all of its elements are unique.\n * > JSON Schema Validation Section 5.3.4\n *\n * TODO\n * optimize\n *\n * @returns {string}\n */\n\n }, {\n key: 'uniqueItems',\n value: function uniqueItems() {\n var uniqueItems = this.schema.uniqueItems,\n address = this.address;\n\n var block = '';\n\n if (uniqueItems === true) {\n block += '\\n // validate ' + address + ' unique items\\n let values = value.map(v => JSON.stringify(v)) // TODO: optimize\\n let set = new Set(values)\\n if (values.length !== set.size) {\\n valid = false\\n errors.push({\\n keyword: \\'uniqueItems\\',\\n message: \\'items must be unique\\'\\n })\\n }\\n ';\n }\n\n return block;\n }\n\n /**\n * minLength\n *\n * @description\n * > A string instance is valid against this keyword if its length is\n * > greater than, or equal to, the value of this keyword. The length of\n * > a string instance is defined as the number of its characters as\n * > defined by RFC 4627 [RFC4627].\n * > JSON Schema Validation Section 5.2.2\n *\n * @returns {string}\n */\n\n }, {\n key: 'minLength',\n value: function minLength() {\n var minLength = this.schema.minLength,\n address = this.address;\n\n\n return '\\n // ' + address + ' validate minLength\\n if (Array.from(value).length < ' + minLength + ') {\\n valid = false\\n errors.push({\\n keyword: \\'minLength\\',\\n message: \\'too short\\'\\n })\\n }\\n ';\n }\n\n /**\n * maxLength\n *\n * @description\n * > A string instance is valid against this keyword if its length is less\n * > than, or equal to, the value of this keyword. The length of a string\n * > instance is defined as the number of its characters as defined by\n * > RFC 4627 [RFC4627].\n * > JSON Schema Validation Section 5.2.1\n *\n * @returns {string}\n */\n\n }, {\n key: 'maxLength',\n value: function maxLength() {\n var maxLength = this.schema.maxLength,\n address = this.address;\n\n\n return '\\n // ' + address + ' validate maxLength\\n if (Array.from(value).length > ' + maxLength + ') {\\n valid = false\\n errors.push({\\n keyword: \\'maxLength\\',\\n message: \\'too long\\'\\n })\\n }\\n ';\n }\n\n /**\n * Pattern\n *\n * @description\n * > A string instance is considered valid if the regular expression\n * > matches the instance successfully.\n * > JSON Schema Validation Section 5.2.3\n *\n * @returns {string}\n */\n\n }, {\n key: 'pattern',\n value: function pattern() {\n var pattern = this.schema.pattern,\n address = this.address;\n\n\n if (pattern) {\n return '\\n // ' + address + ' validate pattern\\n if (!value.match(new RegExp(\\'' + pattern + '\\'))) {\\n valid = false\\n errors.push({\\n keyword: \\'pattern\\',\\n message: \\'does not match the required pattern\\'\\n })\\n }\\n ';\n }\n }\n\n /**\n * Format\n *\n * @description\n * > Structural validation alone may be insufficient to validate that\n * > an instance meets all the requirements of an application. The\n * > \"format\" keyword is defined to allow interoperable semantic\n * > validation for a fixed subset of values which are accurately\n * > described by authoritative resources, be they RFCs or other\n * > external specifications.\n * > JSON Schema Validation Section 7.1\n *\n * @returns {string}\n */\n\n }, {\n key: 'format',\n value: function format() {\n var format = this.schema.format,\n address = this.address;\n\n var matcher = formats.resolve(format);\n\n if (matcher) {\n return '\\n // ' + address + ' validate format\\n if (!value.match(' + matcher + ')) {\\n valid = false\\n errors.push({\\n keyword: \\'format\\',\\n message: \\'is not \"' + format + '\" format\\'\\n })\\n }\\n ';\n }\n }\n\n /**\n * Minimum\n *\n * @description\n * > Successful validation depends on the presence and value of\n * > \"exclusiveMinimum\": if \"exclusiveMinimum\" is not present, or has\n * > boolean value false, then the instance is valid if it is greater\n * > than, or equal to, the value of \"minimum\"; if \"exclusiveMinimum\" is\n * > present and has boolean value true, the instance is valid if it is\n * > strictly greater than the value of \"minimum\".\n * > JSON Schema Validation Section 5.1.3\n *\n * @returns {string}\n */\n\n }, {\n key: 'minimum',\n value: function minimum() {\n var _schema3 = this.schema,\n minimum = _schema3.minimum,\n exclusiveMinimum = _schema3.exclusiveMinimum,\n address = this.address;\n\n var operator = exclusiveMinimum === true ? '<=' : '<';\n\n return '\\n // ' + address + ' validate minimum\\n if (value ' + operator + ' ' + minimum + ') {\\n valid = false\\n errors.push({\\n keyword: \\'minimum\\',\\n message: \\'too small\\'\\n })\\n }\\n ';\n }\n\n /**\n * Maximum\n *\n * @description\n * > Successful validation depends on the presence and value of\n * > \"exclusiveMaximum\": if \"exclusiveMaximum\" is not present, or has\n * > boolean value false, then the instance is valid if it is lower than,\n * > or equal to, the value of \"maximum\"; if \"exclusiveMaximum\" has\n * > boolean value true, the instance is valid if it is strictly lower\n * > than the value of \"maximum\".\n * > JSON Schema Validation Section 5.1.2\n *\n * @returns {string}\n */\n\n }, {\n key: 'maximum',\n value: function maximum() {\n var _schema4 = this.schema,\n maximum = _schema4.maximum,\n exclusiveMaximum = _schema4.exclusiveMaximum,\n address = this.address;\n\n var operator = exclusiveMaximum === true ? '>=' : '>';\n\n return '\\n // ' + address + ' validate maximum\\n if (value ' + operator + ' ' + maximum + ') {\\n valid = false\\n errors.push({\\n keyword: \\'maximum\\',\\n message: \\'too large\\'\\n })\\n }\\n ';\n }\n\n /**\n * multipleOf\n *\n * @description\n * > A numeric instance is valid against \"multipleOf\" if the result of\n * > the division of the instance by this keyword's value is an integer.\n * > JSON Schema Validation Section 5.1.1\n *\n * @returns {string}\n */\n\n }, {\n key: 'multipleOf',\n value: function multipleOf() {\n var multipleOf = this.schema.multipleOf;\n\n var block = '';\n\n if (typeof multipleOf === 'number') {\n var length = multipleOf.toString().length;\n var decimals = length - multipleOf.toFixed(0).length - 1;\n var pow = decimals > 0 ? Math.pow(10, decimals) : 1;\n var condition = void 0;\n\n if (decimals > 0) {\n condition = '(value * ' + pow + ') % ' + multipleOf * pow + ' !== 0';\n } else {\n condition = 'value % ' + multipleOf + ' !== 0';\n }\n\n block += '\\n if (' + condition + ') {\\n valid = false\\n errors.push({\\n keyword: \\'multipleOf\\',\\n message: \\'must be a multiple of ' + multipleOf + '\\'\\n })\\n }\\n ';\n }\n\n return block;\n }\n }]);\n\n return Validator;\n}();\n\n/**\n * Export\n */\n\n\nmodule.exports = Validator;\n\n//# sourceURL=webpack:///./node_modules/@trust/json-document/lib/Validator.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/json-document/lib/index.js": +/*!********************************************************!*\ + !*** ./node_modules/@trust/json-document/lib/index.js ***! + \********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nmodule.exports = {\n Formats: __webpack_require__(/*! ./Formats */ \"./node_modules/@trust/json-document/lib/Formats.js\"),\n Initializer: __webpack_require__(/*! ./Initializer */ \"./node_modules/@trust/json-document/lib/Initializer.js\"),\n JSONDocument: __webpack_require__(/*! ./JSONDocument */ \"./node_modules/@trust/json-document/lib/JSONDocument.js\"),\n JSONMapping: __webpack_require__(/*! ./JSONMapping */ \"./node_modules/@trust/json-document/lib/JSONMapping.js\"),\n JSONPatch: __webpack_require__(/*! ./JSONPatch */ \"./node_modules/@trust/json-document/lib/JSONPatch.js\"),\n JSONPointer: __webpack_require__(/*! ./JSONPointer */ \"./node_modules/@trust/json-document/lib/JSONPointer.js\"),\n JSONSchema: __webpack_require__(/*! ./JSONSchema */ \"./node_modules/@trust/json-document/lib/JSONSchema.js\"),\n Validator: __webpack_require__(/*! ./Validator */ \"./node_modules/@trust/json-document/lib/Validator.js\")\n};\n\n//# sourceURL=webpack:///./node_modules/@trust/json-document/lib/index.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/lib/PoPToken.js": +/*!*****************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/lib/PoPToken.js ***! + \*****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\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\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError(\"this hasn't been initialised - super() hasn't been called\"); } return call && (typeof call === \"object\" || typeof call === \"function\") ? call : self; }\n\nfunction _inherits(subClass, superClass) { if (typeof superClass !== \"function\" && superClass !== null) { throw new TypeError(\"Super expression must either be null or a function, not \" + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }\n\nvar _require = __webpack_require__(/*! whatwg-url */ \"whatwg-url\"),\n URL = _require.URL;\n\nvar _require2 = __webpack_require__(/*! @trust/jose */ \"./node_modules/@trust/jose/lib/index.js\"),\n JWT = _require2.JWT,\n JWK = _require2.JWK;\n\nvar DEFAULT_MAX_AGE = 3600; // Default token expiration, in seconds\n\nvar PoPToken = function (_JWT) {\n _inherits(PoPToken, _JWT);\n\n function PoPToken() {\n _classCallCheck(this, PoPToken);\n\n return _possibleConstructorReturn(this, (PoPToken.__proto__ || Object.getPrototypeOf(PoPToken)).apply(this, arguments));\n }\n\n _createClass(PoPToken, null, [{\n key: 'issueFor',\n\n /**\n * @param resourceServerUri {string} RS URI for which this token is intended\n *\n * @param session {Session}\n * @param session.sessionKey {string}\n * @param session.authorization.client_id {string}\n * @param session.authorization.id_token {string}\n *\n * @returns {Promise} PoPToken, encoded as compact JWT\n */\n value: function issueFor(resourceServerUri, session) {\n if (!resourceServerUri) {\n throw new Error('Cannot issue PoPToken - missing resource server URI');\n }\n\n if (!session.sessionKey) {\n throw new Error('Cannot issue PoPToken - missing session key');\n }\n\n if (!session.authorization.id_token) {\n throw new Error('Cannot issue PoPToken - missing id token');\n }\n\n var jwk = JSON.parse(session.sessionKey);\n\n return JWK.importKey(jwk).then(function (importedSessionJwk) {\n var options = {\n aud: new URL(resourceServerUri).origin,\n key: importedSessionJwk,\n iss: session.authorization.client_id,\n id_token: session.authorization.id_token\n };\n\n return PoPToken.issue(options);\n }).then(function (jwt) {\n return jwt.encode();\n });\n }\n\n /**\n * issue\n *\n * @param options {Object}\n * @param options.iss {string} Token issuer (RP client_id)\n * @param options.aud {string|Array} Audience for the token\n * (such as the Resource Server url)\n * @param options.key {JWK} Proof of Possession (private) signing key, see\n * https://tools.ietf.org/html/rfc7800#section-3.1\n *\n * @param options.id_token {string} JWT compact encoded ID Token\n *\n * Optional:\n * @param [options.iat] {number} Issued at timestamp (in seconds)\n * @param [options.max] {number} Max token lifetime in seconds\n *\n * @returns {PoPToken} Proof of Possession Token (JWT instance)\n */\n\n }, {\n key: 'issue',\n value: function issue(options) {\n var aud = options.aud,\n iss = options.iss,\n key = options.key;\n\n\n var alg = key.alg;\n var iat = options.iat || Math.floor(Date.now() / 1000);\n var max = options.max || DEFAULT_MAX_AGE;\n\n var exp = iat + max; // token expiration\n\n var header = { alg: alg };\n var payload = { iss: iss, aud: aud, exp: exp, iat: iat, id_token: options.id_token, token_type: 'pop' };\n\n var jwt = new PoPToken({ header: header, payload: payload, key: key.cryptoKey }, { filter: false });\n\n return jwt;\n }\n }]);\n\n return PoPToken;\n}(JWT);\n\nmodule.exports = PoPToken;\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/lib/PoPToken.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/AuthenticationRequest.js": +/*!******************************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/AuthenticationRequest.js ***! + \******************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(Buffer) {/**\n * Dependencies\n */\nconst assert = __webpack_require__(/*! assert */ \"./node_modules/assert/assert.js\")\nconst base64url = __webpack_require__(/*! base64url */ \"./node_modules/base64url/index.js\")\nconst crypto = __webpack_require__(/*! @trust/webcrypto */ \"@trust/webcrypto\")\nconst { JWT } = __webpack_require__(/*! @trust/jose */ \"./node_modules/@trust/jose/lib/index.js\")\nconst FormUrlEncoded = __webpack_require__(/*! ./FormUrlEncoded */ \"./node_modules/@trust/oidc-rp/src/FormUrlEncoded.js\")\nconst { URL } = __webpack_require__(/*! whatwg-url */ \"whatwg-url\")\n\n/**\n * Authentication Request\n */\nclass AuthenticationRequest {\n /**\n * create\n *\n * @description\n * Create a new authentication request with generated state and nonce,\n * validate presence of required parameters, serialize the request data and\n * persist it to the session, and return a promise for an authentication\n * request URI.\n *\n * @param {RelyingParty} rp – instance of RelyingParty\n * @param {Object} options - optional request parameters\n * @param {Object} session – reference to localStorage or other session object\n *\n * @returns {Promise}\n */\n static create (rp, options, session) {\n const {provider, defaults, registration} = rp\n\n let issuer, endpoint, client, params\n\n return Promise.resolve()\n .then(() => {\n // validate presence of OP configuration, RP client registration,\n // and default parameters\n assert(provider.configuration,\n 'RelyingParty provider OpenID Configuration is missing')\n\n assert(defaults.authenticate,\n 'RelyingParty default authentication parameters are missing')\n\n assert(registration,\n 'RelyingParty client registration is missing')\n\n // define basic elements of the request\n issuer = provider.configuration.issuer\n endpoint = provider.configuration.authorization_endpoint\n client = { client_id: registration.client_id}\n params = Object.assign(defaults.authenticate, client, options)\n\n // validate presence of required configuration and parameters\n assert(issuer,\n 'Missing issuer in provider OpenID Configuration')\n\n assert(endpoint,\n 'Missing authorization_endpoint in provider OpenID Configuration')\n\n assert(params.scope,\n 'Missing scope parameter in authentication request')\n\n assert(params.response_type,\n 'Missing response_type parameter in authentication request')\n\n assert(params.client_id,\n 'Missing client_id parameter in authentication request')\n\n assert(params.redirect_uri,\n 'Missing redirect_uri parameter in authentication request')\n\n // generate state and nonce random octets\n params.state = Array.from(crypto.getRandomValues(new Uint8Array(16)))\n params.nonce = Array.from(crypto.getRandomValues(new Uint8Array(16)))\n\n // hash the state and nonce parameter values\n return Promise.all([\n crypto.subtle.digest({ name: 'SHA-256' }, new Uint8Array(params.state)),\n crypto.subtle.digest({ name: 'SHA-256' }, new Uint8Array(params.nonce))\n ])\n })\n\n // serialize the request with original values, store in session by\n // encoded state param, and replace state/nonce octets with encoded\n // digests\n .then(digests => {\n let state = base64url(Buffer.from(digests[0]))\n let nonce = base64url(Buffer.from(digests[1]))\n let key = `${issuer}/requestHistory/${state}`\n\n // store the request params for response validation\n // with serialized octet values for state and nonce\n session[key] = JSON.stringify(params)\n\n // replace state and nonce octets with base64url encoded digests\n params.state = state\n params.nonce = nonce\n })\n\n .then(() => AuthenticationRequest.generateSessionKeys())\n\n .then(sessionKeys => {\n AuthenticationRequest.storeSessionKeys(sessionKeys, params, session)\n })\n\n // optionally encode a JWT with the request parameters\n // and replace params with `{ request: }\n .then(() => {\n if (provider.configuration.request_parameter_supported) {\n return AuthenticationRequest.encodeRequestParams(params)\n\n .then(encodedParams => { params = encodedParams })\n }\n })\n\n // render the request URI and terminate the algorithm\n .then(() => {\n let url = new URL(endpoint)\n url.search = FormUrlEncoded.encode(params)\n\n return url.href\n })\n }\n\n static generateSessionKeys () {\n return crypto.subtle.generateKey(\n {\n name: \"RSASSA-PKCS1-v1_5\",\n modulusLength: 2048,\n publicExponent: new Uint8Array([0x01, 0x00, 0x01]),\n hash: { name: \"SHA-256\" },\n },\n true,\n [\"sign\", \"verify\"]\n )\n .then((keyPair) => {\n // returns a keypair object\n return Promise.all([\n crypto.subtle.exportKey('jwk', keyPair.publicKey),\n crypto.subtle.exportKey('jwk', keyPair.privateKey)\n ])\n })\n .then(jwkPair => {\n let [ publicJwk, privateJwk ] = jwkPair\n\n return { public: publicJwk, private: privateJwk }\n })\n }\n\n static storeSessionKeys (sessionKeys, params, session) {\n // store the private one in session, public one goes into params\n session['oidc.session.privateKey'] = JSON.stringify(sessionKeys.private)\n params.key = sessionKeys.public\n }\n\n static encodeRequestParams (params) {\n const excludeParams = ['scope', 'client_id', 'response_type', 'state']\n\n const keysToEncode = Object.keys(params).filter(key => !excludeParams.includes(key))\n\n let payload = {}\n\n keysToEncode.forEach(key => {\n payload[key] = params[key]\n })\n\n let requestParamJwt = new JWT({\n header: { alg: 'none' },\n payload\n }, { filter: false })\n\n return requestParamJwt.encode()\n .then(requestParamCompact => {\n let newParams = {\n scope: params['scope'],\n client_id: params['client_id'],\n response_type: params['response_type'],\n request: requestParamCompact,\n state: params['state']\n }\n\n return newParams\n })\n }\n}\n\n/**\n * Export\n */\nmodule.exports = AuthenticationRequest\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/AuthenticationRequest.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/AuthenticationResponse.js": +/*!*******************************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/AuthenticationResponse.js ***! + \*******************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(global, Buffer) {/**\n * Dependencies\n */\nconst { URL } = __webpack_require__(/*! whatwg-url */ \"whatwg-url\")\nconst assert = __webpack_require__(/*! assert */ \"./node_modules/assert/assert.js\")\nconst crypto = __webpack_require__(/*! @trust/webcrypto */ \"@trust/webcrypto\")\nconst base64url = __webpack_require__(/*! base64url */ \"./node_modules/base64url/index.js\")\nconst fetch = __webpack_require__(/*! node-fetch */ \"isomorphic-fetch\")\nconst Headers = fetch.Headers ? fetch.Headers : global.Headers\nconst FormUrlEncoded = __webpack_require__(/*! ./FormUrlEncoded */ \"./node_modules/@trust/oidc-rp/src/FormUrlEncoded.js\")\nconst IDToken = __webpack_require__(/*! ./IDToken */ \"./node_modules/@trust/oidc-rp/src/IDToken.js\")\nconst Session = __webpack_require__(/*! ./Session */ \"./node_modules/@trust/oidc-rp/src/Session.js\")\nconst onHttpError = __webpack_require__(/*! ./onHttpError */ \"./node_modules/@trust/oidc-rp/src/onHttpError.js\")\n\n/**\n * AuthenticationResponse\n */\nclass AuthenticationResponse {\n\n /**\n * validateResponse\n *\n * @description\n * Authentication response validation.\n *\n * @param {string|Object} response\n * @returns {Promise}\n */\n static validateResponse (response) {\n return Promise.resolve(response)\n .then(this.parseResponse)\n .then(this.matchRequest)\n .then(this.validateStateParam)\n .then(this.errorResponse)\n .then(this.validateResponseMode)\n .then(this.validateResponseParams)\n .then(this.exchangeAuthorizationCode)\n .then(this.validateIDToken)\n .then(Session.fromAuthResponse)\n }\n\n /**\n * parseResponse\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static parseResponse (response) {\n let {redirect, body} = response\n\n // response must be either a redirect uri or request body, but not both\n if ((redirect && body) || (!redirect && !body)) {\n throw new Error('Invalid response mode')\n }\n\n // parse redirect uri\n if (redirect) {\n let url = new URL(redirect)\n let {search, hash} = url\n\n if ((search && hash) || (!search && !hash)) {\n throw new Error('Invalid response mode')\n }\n\n if (search) {\n response.params = FormUrlEncoded.decode(search.substring(1))\n response.mode = 'query'\n }\n\n if (hash) {\n response.params = FormUrlEncoded.decode(hash.substring(1))\n response.mode = 'fragment'\n }\n }\n\n // parse request form body\n if (body) {\n response.params = FormUrlEncoded.decode(body)\n response.mode = 'form_post'\n }\n\n return response\n }\n\n /**\n * matchRequest\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static matchRequest (response) {\n let {rp, params, session} = response\n let state = params.state\n let issuer = rp.provider.configuration.issuer\n\n if (!state) {\n throw new Error(\n 'Missing state parameter in authentication response')\n }\n\n let key = `${issuer}/requestHistory/${state}`\n let request = session[key]\n\n if (!request) {\n throw new Error(\n 'Mismatching state parameter in authentication response')\n }\n\n response.request = JSON.parse(request)\n return response\n }\n\n /**\n * validateStateParam\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static validateStateParam (response) {\n let octets = new Uint8Array(response.request.state)\n let encoded = response.params.state\n\n return crypto.subtle.digest({ name: 'SHA-256' }, octets).then(digest => {\n if (encoded !== base64url(Buffer.from(digest))) {\n throw new Error(\n 'Mismatching state parameter in authentication response')\n }\n\n return response\n })\n }\n\n /**\n * errorResponse\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static errorResponse (response) {\n let error = response.params.error\n\n if (error) {\n return Promise.reject(error)\n }\n\n return Promise.resolve(response)\n }\n\n /**\n * validateResponseMode\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static validateResponseMode (response) {\n if (response.request.response_type !== 'code' && response.mode === 'query') {\n throw new Error('Invalid response mode')\n }\n\n return response\n }\n\n /**\n * validateResponseParams\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static validateResponseParams (response) {\n let {request, params} = response\n let expectedParams = request.response_type.split(' ')\n\n if (expectedParams.includes('code')) {\n assert(params.code,\n 'Missing authorization code in authentication response')\n // TODO assert novelty of code\n }\n\n if (expectedParams.includes('id_token')) {\n assert(params.id_token,\n 'Missing id_token in authentication response')\n }\n\n if (expectedParams.includes('token')) {\n assert(params.access_token,\n 'Missing access_token in authentication response')\n\n assert(params.token_type,\n 'Missing token_type in authentication response')\n }\n\n return response\n }\n\n /**\n * exchangeAuthorizationCode\n *\n * @param {Object} response\n * @returns {Promise} response object\n */\n static exchangeAuthorizationCode (response) {\n let {rp, params, request} = response\n let code = params.code\n\n // only exchange the authorization code when the response type is \"code\"\n if (!code || request['response_type'] !== 'code') {\n return Promise.resolve(response)\n }\n\n let {provider, registration} = rp\n let id = registration['client_id']\n let secret = registration['client_secret']\n\n // verify the client is not public\n if (!secret) {\n return Promise.reject(new Error(\n 'Client cannot exchange authorization code because ' +\n 'it is not a confidential client'))\n }\n\n // initialize token request arguments\n let endpoint = provider.configuration.token_endpoint\n let method = 'POST'\n\n // initialize headers\n let headers = new Headers({\n 'Content-Type': 'application/x-www-form-urlencoded'\n })\n\n // initialize the token request parameters\n let bodyContents = {\n 'grant_type': 'authorization_code',\n 'code': code,\n 'redirect_uri': request['redirect_uri']\n }\n\n // determine client authentication method\n let authMethod = registration['token_endpoint_auth_method']\n || 'client_secret_basic'\n\n // client secret basic authentication\n if (authMethod === 'client_secret_basic') {\n let credentials = new Buffer(`${id}:${secret}`).toString('base64')\n headers.set('Authorization', `Basic ${credentials}`)\n }\n\n // client secret post authentication\n if (authMethod === 'client_secret_post') {\n bodyContents['client_id'] = id\n bodyContents['client_secret'] = secret\n }\n\n let body = FormUrlEncoded.encode(bodyContents)\n\n // TODO\n // client_secret_jwt authentication\n // private_key_jwt\n\n // make the token request\n\n return fetch(endpoint, {method, headers, body})\n .then(onHttpError('Error exchanging authorization code'))\n .then(tokenResponse => tokenResponse.json())\n .then(tokenResponse => {\n assert(tokenResponse['access_token'],\n 'Missing access_token in token response')\n\n assert(tokenResponse['token_type'],\n 'Missing token_type in token response')\n\n assert(tokenResponse['id_token'],\n 'Missing id_token in token response')\n\n // anything else?\n\n // IS THIS THE RIGHT THING TO DO HERE?\n response.params = Object.assign(response.params, tokenResponse)\n return response\n })\n }\n\n\n /**\n * validateIDToken\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static validateIDToken (response) {\n // only validate the ID Token if present in the response\n if (!response.params.id_token) {\n return Promise.resolve(response)\n }\n\n return Promise.resolve(response)\n .then(AuthenticationResponse.decryptIDToken)\n .then(AuthenticationResponse.decodeIDToken)\n .then(AuthenticationResponse.validateIssuer)\n .then(AuthenticationResponse.validateAudience)\n .then(AuthenticationResponse.resolveKeys)\n .then(AuthenticationResponse.verifySignature)\n .then(AuthenticationResponse.validateExpires)\n .then(AuthenticationResponse.verifyNonce)\n .then(AuthenticationResponse.validateAcr)\n .then(AuthenticationResponse.validateAuthTime)\n .then(AuthenticationResponse.validateAccessTokenHash)\n .then(AuthenticationResponse.validateAuthorizationCodeHash)\n }\n\n /**\n * decryptIDToken\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static decryptIDToken (response) {\n // TODO\n return Promise.resolve(response)\n }\n\n /**\n * decodeIDToken\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static decodeIDToken (response) {\n let jwt = response.params.id_token\n\n if (jwt) {\n response.decoded = IDToken.decode(jwt)\n }\n\n return response\n }\n\n\n /**\n * validateIssuer\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static validateIssuer (response) {\n let configuration = response.rp.provider.configuration\n let payload = response.decoded.payload\n\n // validate issuer of token matches this relying party's provider\n if (payload.iss !== configuration.issuer) {\n throw new Error('Mismatching issuer in ID Token')\n }\n\n return response\n }\n\n /**\n * validateAudience\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static validateAudience (response) {\n let registration = response.rp.registration\n let {aud, azp} = response.decoded.payload\n\n // validate audience includes this relying party\n if (typeof aud === 'string' && aud !== registration['client_id']) {\n throw new Error('Mismatching audience in id_token')\n }\n\n // validate audience includes this relying party\n if (Array.isArray(aud) && !aud.includes(registration['client_id'])) {\n throw new Error('Mismatching audience in id_token')\n }\n\n // validate authorized party is present if required\n if (Array.isArray(aud) && !azp) {\n throw new Error('Missing azp claim in id_token')\n }\n\n // validate authorized party is this relying party\n if (azp && azp !== registration['client_id']) {\n throw new Error('Mismatching azp claim in id_token')\n }\n\n return response\n }\n\n\n /**\n * resolveKeys\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static resolveKeys (response) {\n let rp = response.rp\n let provider = rp.provider\n let decoded = response.decoded\n\n return Promise.resolve(provider.jwks)\n\n .then(jwks => jwks ? jwks : rp.jwks())\n\n .then(jwks => {\n if (decoded.resolveKeys(jwks)) {\n return Promise.resolve(response)\n } else {\n throw new Error('Cannot resolve signing key for ID Token')\n }\n })\n }\n\n /**\n * verifySignature\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static verifySignature (response) {\n let alg = response.decoded.header.alg\n let registration = response.rp.registration\n let expectedAlgorithm = registration['id_token_signed_response_alg'] || 'RS256'\n\n // validate signing algorithm matches expectation\n if (alg !== expectedAlgorithm) {\n throw new Error(\n `Expected ID Token to be signed with ${expectedAlgorithm}`)\n }\n\n return response.decoded.verify().then(verified => {\n if (!verified) {\n throw new Error('Invalid ID Token signature')\n }\n\n return response\n })\n }\n\n /**\n * validateExpires\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static validateExpires (response) {\n let exp = response.decoded.payload.exp\n\n // validate expiration of token\n if (exp <= Math.floor(Date.now() / 1000)) {\n throw new Error('Expired ID Token')\n }\n\n return response\n }\n\n /**\n * verifyNonce\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static verifyNonce (response) {\n let octets = new Uint8Array(response.request.nonce)\n let nonce = response.decoded.payload.nonce\n\n if (!nonce) {\n throw new Error('Missing nonce in ID Token')\n }\n\n return crypto.subtle.digest({ name: 'SHA-256' }, octets).then(digest => {\n if (nonce !== base64url(Buffer.from(digest))) {\n throw new Error('Mismatching nonce in ID Token')\n }\n\n return response\n })\n }\n\n /**\n * validateAcr\n *\n * @param {Object} response\n * @returns {Object}\n */\n static validateAcr (response) {\n // TODO\n return response\n }\n\n /**\n * validateAuthTime\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static validateAuthTime (response) {\n // TODO\n return response\n }\n\n /**\n * validateAccessTokenHash\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static validateAccessTokenHash (response) {\n // TODO\n return response\n }\n\n /**\n * validateAuthorizationCodeHash\n *\n * @param {Object} response\n * @returns {Promise}\n */\n static validateAuthorizationCodeHash (response) {\n // TODO\n return response\n }\n}\n\n/**\n * Export\n */\nmodule.exports = AuthenticationResponse\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\"), __webpack_require__(/*! ./../../../buffer/index.js */ \"./node_modules/buffer/index.js\").Buffer))\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/AuthenticationResponse.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/FormUrlEncoded.js": +/*!***********************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/FormUrlEncoded.js ***! + \***********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports) { + +eval("/**\n * Dependencies\n */\n\n/**\n * FormUrlEncoded\n */\nclass FormUrlEncoded {\n\n /**\n * Encode\n *\n * @description\n * Represent an object as x-www-form-urlencoded string.\n *\n * @param {Object} data\n * @returns {string}\n */\n static encode (data) {\n let pairs = []\n\n Object.keys(data).forEach(function (key) {\n pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(data[key]))\n })\n\n return pairs.join('&')\n }\n\n /**\n * Decode\n *\n * @description\n * Parse a x-www-form-urlencoded into an object.\n *\n * @param {string} data\n * @returns {Object}\n */\n static decode (data) {\n let obj = {}\n\n data.split('&').forEach(function (property) {\n let pair = property.split('=')\n let key = decodeURIComponent(pair[0])\n let val = decodeURIComponent(pair[1])\n\n obj[key] = val\n })\n\n return obj\n }\n}\n\n/**\n * Export\n */\nmodule.exports = FormUrlEncoded\n\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/FormUrlEncoded.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/IDToken.js": +/*!****************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/IDToken.js ***! + \****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/**\n * Local dependencies\n */\nconst {JWT} = __webpack_require__(/*! @trust/jose */ \"./node_modules/@trust/jose/lib/index.js\")\nconst IDTokenSchema = __webpack_require__(/*! ./IDTokenSchema */ \"./node_modules/@trust/oidc-rp/src/IDTokenSchema.js\")\n\n/**\n * IDToken\n */\nclass IDToken extends JWT {\n\n /**\n * Schema\n */\n static get schema () {\n return IDTokenSchema\n }\n}\n\n/**\n * Export\n */\nmodule.exports = IDToken\n\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/IDToken.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/IDTokenSchema.js": +/*!**********************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/IDTokenSchema.js ***! + \**********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/**\n * Local dependencies\n */\nconst {JWTSchema} = __webpack_require__(/*! @trust/jose */ \"./node_modules/@trust/jose/lib/index.js\")\n\n/**\n * IDToken Schema\n */\nconst IDTokenSchema = JWTSchema.extend({\n properties: {\n\n /**\n * header\n * http://openid.net/specs/openid-connect-core-1_0.html#IDToken\n * ID Tokens SHOULD NOT use the JWS or JWE x5u, x5c, jku, or jwk Header\n * Parameter fields. Instead, references to keys used are communicated in\n * advance using Discovery and Registration parameters, per Section 10.\n */\n header: {\n //not: { required: ['x5u', 'x5c', 'jku', 'jwk'] }\n },\n\n /**\n * payload\n */\n payload: {\n properties: {\n\n /**\n * iss\n *\n * REQUIRED. Issuer Identifier for the Issuer of the response.\n * The iss value is a case sensitive URL using the https scheme\n * that contains scheme, host, and optionally, port number and\n * path components and no query or fragment components.\n */\n iss: { type: 'string', format: 'url' },\n\n /**\n * sub\n *\n * REQUIRED. Subject Identifier. A locally unique and never\n * reassigned identifier within the Issuer for the End-User, which\n * is intended to be consumed by the Client, e.g., 24400320 or\n * AItOawmwtWwcT0k51BayewNvutrJUqsvl6qs7A4. It MUST NOT exceed 255\n * ASCII characters in length. The sub value is a case sensitive\n * string.\n */\n sub: { type: 'string', maxLength: 255 },\n\n /**\n * aud\n *\n * REQUIRED. Audience(s) that this ID Token is intended for. It\n * MUST contain the OAuth 2.0 client_id of the Relying Party as an\n * audience value. It MAY also contain identifiers for other audiences.\n * In the general case, the aud value is an array of case sensitive\n * strings. In the common special case when there is one audience,\n * the aud value MAY be a single case sensitive string.\n */\n // inherited from JWTClaimsSetSchema\n\n /**\n * exp\n *\n * REQUIRED. Expiration time on or after which the ID Token MUST NOT\n * be accepted for processing. The processing of this parameter\n * requires that the current date/time MUST be before the expiration\n * date/time listed in the value. Implementers MAY provide for some\n * small leeway, usually no more than a few minutes, to account for\n * clock skew. Its value is a JSON number representing the number of\n * seconds from 1970-01-01T0:0:0Z as measured in UTC until the\n * date/time. See RFC 3339 [RFC3339] for details regarding date/times\n * in general and UTC in particular.\n */\n // inherited from JWTClaimsSetSchema\n\n /**\n * iat\n *\n * REQUIRED. Time at which the JWT was issued. Its value is a\n * JSON number representing the number of seconds from\n * 1970-01-01T0:0:0Z as measured in UTC until the date/time.\n */\n // inherited from JWTClaimsSetSchema\n\n /**\n * auth_time\n *\n * Time when the End-User authentication occurred. Its value is a\n * JSON number representing the number of seconds from\n * 1970-01-01T0:0:0Z as measured in UTC until the date/time. When a\n * max_age request is made or when auth_time is requested as an\n * Essential Claim, then this Claim is REQUIRED; otherwise, its\n * inclusion is OPTIONAL. (The auth_time Claim semantically\n * corresponds to the OpenID 2.0 PAPE [OpenID.PAPE] auth_time\n * response parameter.)\n */\n auth_time: { type: 'integer', format: 'NumericDate' },\n\n /**\n * nonce\n *\n * String value used to associate a Client session with an ID Token,\n * and to mitigate replay attacks. The value is passed through\n * unmodified from the Authentication Request to the ID Token. If\n * present in the ID Token, Clients MUST verify that the nonce Claim\n * Value is equal to the value of the nonce parameter sent in the\n * Authentication Request. If present in the Authentication Request,\n * Authorization Servers MUST include a nonce Claim in the ID Token\n * with the Claim Value being the nonce value sent in the\n * Authentication Request. Authorization Servers SHOULD perform no\n * other processing on nonce values used. The nonce value is a case\n * sensitive string.\n */\n nonce: { type: 'string' },\n\n /**\n * acr\n *\n * OPTIONAL. Authentication Context Class Reference. String\n * specifying an Authentication Context Class Reference value that\n * identifies the Authentication Context Class that the authentication\n * performed satisfied. The value \"0\" indicates the End-User\n * authentication did not meet the requirements of ISO/IEC 29115\n * [ISO29115] level 1. Authentication using a long-lived browser\n * cookie, for instance, is one example where the use of \"level 0\" is\n * appropriate. Authentications with level 0 SHOULD NOT be used to\n * authorize access to any resource of any monetary value. (This\n * corresponds to the OpenID 2.0 PAPE [OpenID.PAPE] nist_auth_level\n * 0.) An absolute URI or an RFC 6711 [RFC6711] registered name\n * SHOULD be used as the acr value; registered names MUST NOT be used\n * with a different meaning than that which is registered. Parties\n * using this claim will need to agree upon the meanings of the\n * values used, which may be context-specific. The acr value is a\n * case sensitive string.\n */\n acr: { type: 'string' },\n\n /**\n * amr\n * OPTIONAL. Authentication Methods References. JSON array of strings\n * that are identifiers for authentication methods used in the\n * authentication. For instance, values might indicate that both\n * password and OTP authentication methods were used. The definition\n * of particular values to be used in the amr Claim is beyond the\n * scope of this specification. Parties using this claim will need to\n * agree upon the meanings of the values used, which may be context-\n * specific. The amr value is an array of case sensitive strings.\n */\n amr: { type: 'array', items: { type: 'string' } },\n\n /**\n * azp\n * OPTIONAL. Authorized party - the party to which the ID Token was\n * issued. If present, it MUST contain the OAuth 2.0 Client ID of this\n * party. This Claim is only needed when the ID Token has a single\n * audience value and that audience is different than the authorized\n * party. It MAY be included even when the authorized party is the\n * same as the sole audience. The azp value is a case sensitive string\n * containing a StringOrURI value.\n */\n azp: { type: 'string', format: 'StringOrURI' }\n },\n\n /**\n * Required Claims\n */\n required: ['iss', 'sub', 'aud', 'exp', 'iat']\n }\n }\n})\n\n/**\n * Export\n */\nmodule.exports = IDTokenSchema\n\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/IDTokenSchema.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/PoPToken.js": +/*!*****************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/PoPToken.js ***! + \*****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nconst { URL } = __webpack_require__(/*! whatwg-url */ \"whatwg-url\")\nconst {JWT, JWK} = __webpack_require__(/*! @trust/jose */ \"./node_modules/@trust/jose/lib/index.js\")\n\nconst DEFAULT_MAX_AGE = 3600 // Default token expiration, in seconds\n\nclass PoPToken extends JWT {\n /**\n * @param resourceServerUri {string} RS URI for which this token is intended\n *\n * @param session {Session}\n * @param session.sessionKey {string}\n * @param session.authorization.client_id {string}\n * @param session.authorization.id_token {string}\n *\n * @returns {Promise} PoPToken, encoded as compact JWT\n */\n static issueFor (resourceServerUri, session) {\n if (!resourceServerUri) {\n throw new Error('Cannot issue PoPToken - missing resource server URI')\n }\n\n if (!session.sessionKey) {\n throw new Error('Cannot issue PoPToken - missing session key')\n }\n\n if (!session.authorization.id_token) {\n throw new Error('Cannot issue PoPToken - missing id token')\n }\n\n let jwk = JSON.parse(session.sessionKey)\n\n return JWK.importKey(jwk)\n .then(importedSessionJwk => {\n let options = {\n aud: (new URL(resourceServerUri)).origin,\n key: importedSessionJwk,\n iss: session.authorization.client_id,\n id_token: session.authorization.id_token\n }\n\n return PoPToken.issue(options)\n })\n .then(jwt => {\n return jwt.encode()\n })\n }\n\n /**\n * issue\n *\n * @param options {Object}\n * @param options.iss {string} Token issuer (RP client_id)\n * @param options.aud {string|Array} Audience for the token\n * (such as the Resource Server url)\n * @param options.key {JWK} Proof of Possession (private) signing key, see\n * https://tools.ietf.org/html/rfc7800#section-3.1\n *\n * @param options.id_token {string} JWT compact encoded ID Token\n *\n * Optional:\n * @param [options.iat] {number} Issued at timestamp (in seconds)\n * @param [options.max] {number} Max token lifetime in seconds\n *\n * @returns {PoPToken} Proof of Possession Token (JWT instance)\n */\n static issue (options) {\n let { aud, iss, key } = options\n\n let alg = key.alg\n let iat = options.iat || Math.floor(Date.now() / 1000)\n let max = options.max || DEFAULT_MAX_AGE\n\n let exp = iat + max // token expiration\n\n let header = { alg }\n let payload = { iss, aud, exp, iat, id_token: options.id_token, token_type: 'pop' }\n\n let jwt = new PoPToken({ header, payload, key: key.cryptoKey }, { filter: false })\n\n return jwt\n }\n}\n\nmodule.exports = PoPToken\n\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/PoPToken.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/RelyingParty.js": +/*!*********************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/RelyingParty.js ***! + \*********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(global) {/**\n * Dependencies\n */\nconst assert = __webpack_require__(/*! assert */ \"./node_modules/assert/assert.js\")\nconst fetch = __webpack_require__(/*! node-fetch */ \"isomorphic-fetch\")\nconst { URL } = __webpack_require__(/*! whatwg-url */ \"whatwg-url\")\nconst Headers = fetch.Headers ? fetch.Headers : global.Headers\nconst {JSONDocument} = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\")\nconst {JWKSet} = __webpack_require__(/*! @trust/jose */ \"./node_modules/@trust/jose/lib/index.js\")\nconst AuthenticationRequest = __webpack_require__(/*! ./AuthenticationRequest */ \"./node_modules/@trust/oidc-rp/src/AuthenticationRequest.js\")\nconst AuthenticationResponse = __webpack_require__(/*! ./AuthenticationResponse */ \"./node_modules/@trust/oidc-rp/src/AuthenticationResponse.js\")\nconst RelyingPartySchema = __webpack_require__(/*! ./RelyingPartySchema */ \"./node_modules/@trust/oidc-rp/src/RelyingPartySchema.js\")\nconst onHttpError = __webpack_require__(/*! ./onHttpError */ \"./node_modules/@trust/oidc-rp/src/onHttpError.js\")\n\n/**\n * RelyingParty\n *\n * @class\n * Client interface for OpenID Connect Relying Party.\n *\n * @example\n * let client = RelyingParty({\n * provider: {\n * name: 'Anvil Research, Inc.',\n * url: 'https://forge.anvil.io'\n * // configuration\n * // jwks\n * },\n * defaults: {\n * popToken: false,\n * authenticate: {\n * response_type: 'code',\n * display: 'popup',\n * scope: 'openid profile email'\n * },\n * register: {\n * client_name: 'Example',\n * client_uri: 'https://example.com',\n * logo_uri: 'https://example.com/assets/logo.png',\n * redirect_uris: ['https://app.example.com/callback'],\n * response_types: ['code', 'code id_token token'],\n * grant_types: ['authorization_code'],\n * default_max_age: 7200,\n * post_logout_redirect_uris: ['https://app.example.com']\n * },\n * },\n * registration: {\n * // if you have it saved somewhere\n * },\n * store: localStorage || req.session\n * })\n *\n * client.discover() => Promise\n * client.jwks() => Promise\n * client.authenticate()\n * client.authenticateUri()\n * client.validateResponse(uri) => Promise\n * client.userinfo() => Promise\n * client.logout()\n */\nclass RelyingParty extends JSONDocument {\n\n /**\n * Schema\n */\n static get schema () {\n return RelyingPartySchema\n }\n\n /**\n * from\n *\n * @description\n * Create a RelyingParty instance from a previously registered client.\n *\n * @param {Object} data\n * @returns {Promise}\n */\n static from (data) {\n let rp = new RelyingParty(data)\n let validation = rp.validate()\n\n // schema validation\n if (!validation.valid) {\n return Promise.reject(new Error(JSON.stringify(validation)))\n }\n\n let jwks = rp.provider.jwks\n\n // request the JWK Set if missing\n if (!jwks) {\n return rp.jwks().then(() => rp)\n }\n\n // otherwise import the JWK Set to webcrypto\n return JWKSet.importKeys(jwks).then(jwks => {\n rp.provider.jwks = jwks\n return rp\n })\n }\n\n /**\n * register\n *\n * @param issuer {string} Provider URL\n * @param registration {Object} Client dynamic registration options\n * @param options {Object}\n * @param options.defaults\n * @param [options.store] {Session|Storage}\n * @returns {Promise} RelyingParty instance, registered.\n */\n static register (issuer, registration, options) {\n let rp = new RelyingParty({\n provider: { url: issuer },\n defaults: Object.assign({}, options.defaults),\n store: options.store\n })\n\n return Promise.resolve()\n .then(() => rp.discover())\n .then(() => rp.jwks())\n .then(() => rp.register(registration))\n .then(() => rp)\n }\n\n /**\n * Discover\n *\n * @description Fetches the issuer's OpenID Configuration.\n * @returns {Promise} Resolves with the provider configuration response\n */\n discover () {\n try {\n let issuer = this.provider.url\n\n assert(issuer, 'RelyingParty provider must define \"url\"')\n\n let url = new URL(issuer)\n url.pathname = '.well-known/openid-configuration'\n\n return fetch(url.toString())\n .then(onHttpError('Error fetching openid configuration'))\n .then(response => {\n return response.json().then(json => this.provider.configuration = json)\n })\n\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n /**\n * Register\n *\n * @description Register's a client with provider as a Relying Party\n *\n * @param options {Object}\n * @returns {Promise} Resolves with the registration response object\n */\n register (options) {\n try {\n let configuration = this.provider.configuration\n\n assert(configuration, 'OpenID Configuration is not initialized.')\n assert(configuration.registration_endpoint, 'OpenID Configuration is missing registration_endpoint.')\n\n let uri = configuration.registration_endpoint\n let method = 'post'\n let headers = new Headers({ 'Content-Type': 'application/json' })\n let params = this.defaults.register\n let body = JSON.stringify(Object.assign({}, params, options))\n\n return fetch(uri, {method, headers, body})\n .then(onHttpError('Error registering client'))\n .then(response => {\n return response.json().then(json => this.registration = json)\n })\n\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n serialize () {\n return JSON.stringify(this)\n }\n\n /**\n * jwks\n *\n * @description Promises the issuer's JWK Set.\n * @returns {Promise}\n */\n jwks () {\n try {\n let configuration = this.provider.configuration\n\n assert(configuration, 'OpenID Configuration is not initialized.')\n assert(configuration.jwks_uri, 'OpenID Configuration is missing jwks_uri.')\n\n let uri = configuration.jwks_uri\n\n return fetch(uri)\n .then(onHttpError('Error resolving provider keys'))\n .then(response => {\n return response\n .json()\n .then(json => JWKSet.importKeys(json))\n .then(jwks => this.provider.jwks = jwks)\n })\n\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n /**\n * createRequest\n *\n * @param options {Object} Authn request options hashmap\n * @param options.redirect_uri {string}\n * @param options.response_type {string} e.g. 'code' or 'id_token token'\n * @param session {Session|Storage} req.session or localStorage\n * @returns {Promise} Authn request URL\n */\n createRequest (options, session) {\n return AuthenticationRequest.create(this, options, session || this.store)\n }\n\n /**\n * Validate Response\n *\n * @param response {string} req.query or req.body.text\n * @param session {Session|Storage} req.session or localStorage or similar\n * @returns {Promise} Custom response object, with `params` and\n * `mode` properties\n */\n validateResponse (response, session) {\n session = session || this.store\n\n if (response.match(/^http(s?):\\/\\//)) {\n response = { rp: this, redirect: response, session }\n } else {\n response = { rp: this, body: response, session }\n }\n\n return AuthenticationResponse.validateResponse(response)\n }\n\n /**\n * userinfo\n *\n * @description Promises the authenticated user's claims.\n * @returns {Promise}\n */\n userinfo () {\n try {\n let configuration = this.provider.configuration\n\n assert(configuration, 'OpenID Configuration is not initialized.')\n assert(configuration.userinfo_endpoint, 'OpenID Configuration is missing userinfo_endpoint.')\n\n let uri = configuration.userinfo_endpoint\n let access_token = this.store.access_token\n\n assert(access_token, 'Missing access token.')\n\n let headers = new Headers({\n 'Content-Type': 'application/json',\n 'Authorization': `Bearer ${access_token}`\n })\n\n return fetch(uri, {headers})\n .then(onHttpError('Error fetching userinfo'))\n .then(response => response.json())\n\n } catch (error) {\n return Promise.reject(error)\n }\n }\n\n /**\n * Logout\n *\n * @returns {Promise}\n */\n logout () {\n let configuration\n try {\n assert(this.provider, 'OpenID Configuration is not initialized.')\n configuration = this.provider.configuration\n assert(configuration, 'OpenID Configuration is not initialized.')\n assert(configuration.end_session_endpoint,\n 'OpenID Configuration is missing end_session_endpoint.')\n } catch (error) {\n return Promise.reject(error)\n }\n\n this.clearSession()\n\n let uri = configuration.end_session_endpoint\n let method = 'get'\n\n return fetch(uri, {method})\n .then(onHttpError('Error logging out'))\n\n // TODO: Validate `frontchannel_logout_uri` if necessary\n /**\n * frontchannel_logout_uri - OPTIONAL. RP URL that will cause the RP to log\n * itself out when rendered in an iframe by the OP.\n *\n * An `iss` (issuer) query parameter and a `sid`\n * (session ID) query parameter MAY be included by the OP to enable the RP\n * to validate the request and to determine which of the potentially\n * multiple sessions is to be logged out. If a sid (session ID) query\n * parameter is included, an iss (issuer) query parameter MUST also be\n * included.\n * @see https://openid.net/specs/openid-connect-frontchannel-1_0.html#RPLogout\n */\n }\n\n clearSession () {\n let session = this.store\n\n if (!session) { return }\n\n delete session[SESSION_PRIVATE_KEY]\n }\n\n /**\n * @param uri {string} Target Resource Server URI\n * @param idToken {IDToken} ID Token to be embedded in the PoP token\n *\n * @returns {Promise}\n */\n popTokenFor (uri, idToken) {\n return PoPToken.issueFor(uri, idToken)\n }\n}\n\nconst SESSION_PRIVATE_KEY = 'oidc.session.privateKey'\n\nRelyingParty.SESSION_PRIVATE_KEY = SESSION_PRIVATE_KEY\n\nmodule.exports = RelyingParty\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/RelyingParty.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/RelyingPartySchema.js": +/*!***************************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/RelyingPartySchema.js ***! + \***************************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/**\n * Dependencies\n */\nconst {JSONSchema} = __webpack_require__(/*! @trust/json-document */ \"./node_modules/@trust/json-document/lib/index.js\")\n\n/**\n * RelyingParty Schema\n *\n * This schema initializes and verifies Relying Party client configuration.\n * RelyingParty objects can be persisted and rehydrated. By encapsulating this data in\n * it's own class, it's possible to have multiple RP configurations running\n * simultaneously.\n */\nconst RelyingPartySchema = new JSONSchema({\n type: 'object',\n properties: {\n\n /**\n * provider\n *\n * Information about the provider, including issuer URL, human readable name,\n * and any configuration or provider metadata retrieved from the OP.\n */\n provider: {\n type: 'object',\n properties: {\n name: { type: 'string' },\n url: { type: 'string', format: 'uri' },\n // NOTE:\n // OpenID Configuration (discovery response) and JSON Web Keys Set for an\n // issuer can be cached here. However the cache should not be persisted or\n // relied upon.\n //\n configuration: {}, // .well-known/openid-configuration\n jwks: {} // /jwks\n },\n required: ['url']\n },\n\n /**\n * defaults\n *\n * Default request parameters for authentication and dynamic registration requests.\n * These values can be extended or overridden via arguments to the respective\n * request methods.\n *\n * These are part of the relying party client configuration and can be serialized\n * and persisted.\n */\n defaults: {\n type: 'object',\n properties: {\n\n /**\n * Use Proof of Possession token semantics for the ID Token\n */\n popToken: {\n type: 'boolean',\n default: false\n },\n\n /**\n * Default authentication request parameters\n */\n authenticate: {\n type: 'object',\n properties: {\n redirect_uri: {\n type: 'string',\n format: 'uri'\n },\n response_type: {\n type: 'string',\n default: 'id_token token', // browser detection\n enum: [\n 'code',\n 'token',\n 'id_token token',\n 'id_token token code'\n ]\n },\n display: {\n type: 'string',\n default: 'page',\n enum: [\n 'page',\n 'popup'\n ]\n },\n scope: {\n type: ['string', 'array'],\n default: ['openid']\n }\n }\n },\n\n /**\n * Default client registration parameters\n */\n register: {}\n }\n },\n\n /**\n * registration\n *\n * This is the client registration response from dynamic registration. It should\n * always reflect the client configuration on the openid provider. A client access\n * token is stored here\n */\n registration: {},// ClientMetadataSchema\n\n /**\n * store\n */\n store: {\n type: 'object',\n default: {}\n }\n }\n})\n\n/**\n * Export\n */\nmodule.exports = RelyingPartySchema\n\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/RelyingPartySchema.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/Session.js": +/*!****************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/Session.js ***! + \****************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nconst fetch = __webpack_require__(/*! node-fetch */ \"isomorphic-fetch\")\nconst onHttpError = __webpack_require__(/*! ./onHttpError */ \"./node_modules/@trust/oidc-rp/src/onHttpError.js\")\nconst PoPToken = __webpack_require__(/*! ./PoPToken */ \"./node_modules/@trust/oidc-rp/src/PoPToken.js\")\n\nclass Session {\n /**\n * @param options {Object}\n *\n * @param options.credentialType {string} 'access_token' or 'pop_token'\n *\n * @param options.issuer {string} Identity provider (issuer of ID/Access Token)\n *\n * @param options.authorization {object}\n * @param options.authorization.client_id {string} OIDC/OAuth2 client id\n * @param [options.authorization.id_token] {string} Compact-serialized id_token param\n * @param [options.authorization.access_token] {string} Compact-serialized access_token param\n * @param [options.authorization.refresh_token] {string} Compact-serialized refresh_token\n *\n * @param [options.sessionKey] {string} Serialized client session key generated\n * during the Authentication Request, used to issue PoPTokens\n *\n * @param [options.idClaims] {object} Decoded/verified ID Token JWT payload\n *\n * @param [options.accessClaims] {object} Decoded/verified Access Token JWT payload\n */\n constructor (options) {\n this.credentialType = options.credentialType || 'access_token'\n\n this.issuer = options.issuer\n\n this.authorization = options.authorization || {}\n\n this.sessionKey = options.sessionKey\n\n this.idClaims = options.idClaims\n this.accessClaims = options.accessClaims\n }\n\n static from (options) {\n return new Session(options)\n }\n\n /**\n * @param response {AuthenticationResponse}\n *\n * @returns {Session}\n */\n static fromAuthResponse (response) {\n const RelyingParty = __webpack_require__(/*! ./RelyingParty */ \"./node_modules/@trust/oidc-rp/src/RelyingParty.js\") // import here due to circular dep\n\n let payload = response.decoded.payload\n\n let { rp } = response\n\n let registration = rp.registration\n let rpAuthOptions = rp.defaults.authenticate || {}\n\n let credentialType = rpAuthOptions['credential_type'] ||\n rp.defaults.popToken ? 'pop_token' : 'access_token'\n\n let sessionKey = response.session[RelyingParty.SESSION_PRIVATE_KEY]\n\n let options = {\n credentialType,\n sessionKey,\n issuer: payload.iss,\n authorization: {\n client_id: registration['client_id'],\n access_token: response.params['access_token'],\n id_token: response.params['id_token'],\n refresh_token: response.params['refresh_token']\n },\n idClaims: response.decoded && response.decoded.payload,\n }\n\n return Session.from(options)\n }\n\n /**\n * Authenticated fetch() getter\n *\n * @returns {function}\n */\n get fetch () {\n /**\n * fetch() function signature\n *\n * @param url {RequestInfo|string}\n * @param options {object}\n *\n * @returns {Function>}\n */\n return (url, options) => {\n return Promise.resolve()\n\n .then(() => {\n if (this.hasCredentials()) {\n return this.fetchWithCredentials(url, options)\n } else {\n return fetch(url, options)\n }\n })\n\n .then(onHttpError('Error while fetching resource'))\n }\n }\n\n /**\n * bearerTokenFor\n *\n * @param url {string}\n *\n * @returns {Promise}\n */\n bearerTokenFor (url) {\n switch (this.credentialType) {\n case 'pop_token':\n return PoPToken.issueFor(url, this)\n\n default: // 'access_token' etc\n return Promise.resolve(this.authorization[this.credentialType])\n }\n }\n\n /**\n * hasCredentials\n *\n * @returns {boolean}\n */\n hasCredentials () {\n switch (this.credentialType) {\n case 'pop_token':\n return !!this.authorization['id_token']\n\n default: // 'access_token' etc\n return !!this.authorization[this.credentialType]\n }\n }\n\n /**\n * fetchWithCredentials\n *\n * @param url {RequestInfo|string}\n * @param options {object}\n *\n * @returns {Promise}\n */\n fetchWithCredentials (url, options = {}) {\n options.headers = options.headers || {}\n\n return this.bearerTokenFor(url)\n\n .then(token => {\n options.headers.authorization = `Bearer ${token}`\n\n return fetch(url, options)\n })\n }\n}\n\nmodule.exports = Session\n\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/Session.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/index.js": +/*!**************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/index.js ***! + \**************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\nmodule.exports = __webpack_require__(/*! ./RelyingParty */ \"./node_modules/@trust/oidc-rp/src/RelyingParty.js\")\n\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/index.js?"); + +/***/ }), + +/***/ "./node_modules/@trust/oidc-rp/src/onHttpError.js": +/*!********************************************************!*\ + !*** ./node_modules/@trust/oidc-rp/src/onHttpError.js ***! + \********************************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("\n\n/**\n * Throws an error when a fetch response status code indicates a 400 or 500\n * HTTP error. (The whatwg fetch api does not normally reject on http error\n * responses).\n *\n * Usage:\n *\n * ```\n * return fetch(url)\n * .then(onHttpError('Error while fetching resource')\n * .catch(err => console.log(err))\n *\n * // -> 'Error while fetching resource: 404 Not Found' error\n * // if a 404 response is encountered\n * ```\n *\n * @param [message] {string} Optional error message to clarify context\n *\n * @throws {Error} For http status codes > 300\n *\n * @return {Object} fetch response object (passed through if no error)\n */\nfunction onHttpError (message = 'fetch error') {\n return (response) => {\n if (response.status >= 200 && response.status < 300) {\n return response\n }\n\n let errorMessage = `${message}: ${response.status} ${response.statusText}`\n let error = new Error(errorMessage)\n error.response = response\n error.statusCode = response.status\n throw error\n }\n}\n\nmodule.exports = onHttpError\n\n\n//# sourceURL=webpack:///./node_modules/@trust/oidc-rp/src/onHttpError.js?"); + +/***/ }), + +/***/ "./node_modules/assert/assert.js": +/*!***************************************!*\ + !*** ./node_modules/assert/assert.js ***! + \***************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +"use strict"; +eval("/* WEBPACK VAR INJECTION */(function(global) {\n\n// compare and isBuffer taken from https://github.com/feross/buffer/blob/680e9e5e488f22aac27599a57dc844a6315928dd/index.js\n// original notice:\n\n/*!\n * The buffer module from node.js, for the browser.\n *\n * @author Feross Aboukhadijeh \n * @license MIT\n */\nfunction compare(a, b) {\n if (a === b) {\n return 0;\n }\n\n var x = a.length;\n var y = b.length;\n\n for (var i = 0, len = Math.min(x, y); i < len; ++i) {\n if (a[i] !== b[i]) {\n x = a[i];\n y = b[i];\n break;\n }\n }\n\n if (x < y) {\n return -1;\n }\n if (y < x) {\n return 1;\n }\n return 0;\n}\nfunction isBuffer(b) {\n if (global.Buffer && typeof global.Buffer.isBuffer === 'function') {\n return global.Buffer.isBuffer(b);\n }\n return !!(b != null && b._isBuffer);\n}\n\n// based on node assert, original notice:\n\n// http://wiki.commonjs.org/wiki/Unit_Testing/1.0\n//\n// THIS IS NOT TESTED NOR LIKELY TO WORK OUTSIDE V8!\n//\n// Originally from narwhal.js (http://narwhaljs.org)\n// Copyright (c) 2009 Thomas Robinson <280north.com>\n//\n// Permission is hereby granted, free of charge, to any person obtaining a copy\n// of this software and associated documentation files (the 'Software'), to\n// deal in the Software without restriction, including without limitation the\n// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or\n// sell copies of the Software, and to permit persons to whom the Software is\n// furnished to do so, subject to the following conditions:\n//\n// The above copyright notice and this permission notice shall be included in\n// all copies or substantial portions of the Software.\n//\n// THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\n// AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN\n// ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\n// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n\nvar util = __webpack_require__(/*! util/ */ \"./node_modules/node-libs-browser/node_modules/util/util.js\");\nvar hasOwn = Object.prototype.hasOwnProperty;\nvar pSlice = Array.prototype.slice;\nvar functionsHaveNames = (function () {\n return function foo() {}.name === 'foo';\n}());\nfunction pToString (obj) {\n return Object.prototype.toString.call(obj);\n}\nfunction isView(arrbuf) {\n if (isBuffer(arrbuf)) {\n return false;\n }\n if (typeof global.ArrayBuffer !== 'function') {\n return false;\n }\n if (typeof ArrayBuffer.isView === 'function') {\n return ArrayBuffer.isView(arrbuf);\n }\n if (!arrbuf) {\n return false;\n }\n if (arrbuf instanceof DataView) {\n return true;\n }\n if (arrbuf.buffer && arrbuf.buffer instanceof ArrayBuffer) {\n return true;\n }\n return false;\n}\n// 1. The assert module provides functions that throw\n// AssertionError's when particular conditions are not met. The\n// assert module must conform to the following interface.\n\nvar assert = module.exports = ok;\n\n// 2. The AssertionError is defined in assert.\n// new assert.AssertionError({ message: message,\n// actual: actual,\n// expected: expected })\n\nvar regex = /\\s*function\\s+([^\\(\\s]*)\\s*/;\n// based on https://github.com/ljharb/function.prototype.name/blob/adeeeec8bfcc6068b187d7d9fb3d5bb1d3a30899/implementation.js\nfunction getName(func) {\n if (!util.isFunction(func)) {\n return;\n }\n if (functionsHaveNames) {\n return func.name;\n }\n var str = func.toString();\n var match = str.match(regex);\n return match && match[1];\n}\nassert.AssertionError = function AssertionError(options) {\n this.name = 'AssertionError';\n this.actual = options.actual;\n this.expected = options.expected;\n this.operator = options.operator;\n if (options.message) {\n this.message = options.message;\n this.generatedMessage = false;\n } else {\n this.message = getMessage(this);\n this.generatedMessage = true;\n }\n var stackStartFunction = options.stackStartFunction || fail;\n if (Error.captureStackTrace) {\n Error.captureStackTrace(this, stackStartFunction);\n } else {\n // non v8 browsers so we can have a stacktrace\n var err = new Error();\n if (err.stack) {\n var out = err.stack;\n\n // try to strip useless frames\n var fn_name = getName(stackStartFunction);\n var idx = out.indexOf('\\n' + fn_name);\n if (idx >= 0) {\n // once we have located the function frame\n // we need to strip out everything before it (and its line)\n var next_line = out.indexOf('\\n', idx + 1);\n out = out.substring(next_line + 1);\n }\n\n this.stack = out;\n }\n }\n};\n\n// assert.AssertionError instanceof Error\nutil.inherits(assert.AssertionError, Error);\n\nfunction truncate(s, n) {\n if (typeof s === 'string') {\n return s.length < n ? s : s.slice(0, n);\n } else {\n return s;\n }\n}\nfunction inspect(something) {\n if (functionsHaveNames || !util.isFunction(something)) {\n return util.inspect(something);\n }\n var rawname = getName(something);\n var name = rawname ? ': ' + rawname : '';\n return '[Function' + name + ']';\n}\nfunction getMessage(self) {\n return truncate(inspect(self.actual), 128) + ' ' +\n self.operator + ' ' +\n truncate(inspect(self.expected), 128);\n}\n\n// At present only the three keys mentioned above are used and\n// understood by the spec. Implementations or sub modules can pass\n// other keys to the AssertionError's constructor - they will be\n// ignored.\n\n// 3. All of the following functions must throw an AssertionError\n// when a corresponding condition is not met, with a message that\n// may be undefined if not provided. All assertion methods provide\n// both the actual and expected values to the assertion error for\n// display purposes.\n\nfunction fail(actual, expected, message, operator, stackStartFunction) {\n throw new assert.AssertionError({\n message: message,\n actual: actual,\n expected: expected,\n operator: operator,\n stackStartFunction: stackStartFunction\n });\n}\n\n// EXTENSION! allows for well behaved errors defined elsewhere.\nassert.fail = fail;\n\n// 4. Pure assertion tests whether a value is truthy, as determined\n// by !!guard.\n// assert.ok(guard, message_opt);\n// This statement is equivalent to assert.equal(true, !!guard,\n// message_opt);. To test strictly for the value true, use\n// assert.strictEqual(true, guard, message_opt);.\n\nfunction ok(value, message) {\n if (!value) fail(value, true, message, '==', assert.ok);\n}\nassert.ok = ok;\n\n// 5. The equality assertion tests shallow, coercive equality with\n// ==.\n// assert.equal(actual, expected, message_opt);\n\nassert.equal = function equal(actual, expected, message) {\n if (actual != expected) fail(actual, expected, message, '==', assert.equal);\n};\n\n// 6. The non-equality assertion tests for whether two objects are not equal\n// with != assert.notEqual(actual, expected, message_opt);\n\nassert.notEqual = function notEqual(actual, expected, message) {\n if (actual == expected) {\n fail(actual, expected, message, '!=', assert.notEqual);\n }\n};\n\n// 7. The equivalence assertion tests a deep equality relation.\n// assert.deepEqual(actual, expected, message_opt);\n\nassert.deepEqual = function deepEqual(actual, expected, message) {\n if (!_deepEqual(actual, expected, false)) {\n fail(actual, expected, message, 'deepEqual', assert.deepEqual);\n }\n};\n\nassert.deepStrictEqual = function deepStrictEqual(actual, expected, message) {\n if (!_deepEqual(actual, expected, true)) {\n fail(actual, expected, message, 'deepStrictEqual', assert.deepStrictEqual);\n }\n};\n\nfunction _deepEqual(actual, expected, strict, memos) {\n // 7.1. All identical values are equivalent, as determined by ===.\n if (actual === expected) {\n return true;\n } else if (isBuffer(actual) && isBuffer(expected)) {\n return compare(actual, expected) === 0;\n\n // 7.2. If the expected value is a Date object, the actual value is\n // equivalent if it is also a Date object that refers to the same time.\n } else if (util.isDate(actual) && util.isDate(expected)) {\n return actual.getTime() === expected.getTime();\n\n // 7.3 If the expected value is a RegExp object, the actual value is\n // equivalent if it is also a RegExp object with the same source and\n // properties (`global`, `multiline`, `lastIndex`, `ignoreCase`).\n } else if (util.isRegExp(actual) && util.isRegExp(expected)) {\n return actual.source === expected.source &&\n actual.global === expected.global &&\n actual.multiline === expected.multiline &&\n actual.lastIndex === expected.lastIndex &&\n actual.ignoreCase === expected.ignoreCase;\n\n // 7.4. Other pairs that do not both pass typeof value == 'object',\n // equivalence is determined by ==.\n } else if ((actual === null || typeof actual !== 'object') &&\n (expected === null || typeof expected !== 'object')) {\n return strict ? actual === expected : actual == expected;\n\n // If both values are instances of typed arrays, wrap their underlying\n // ArrayBuffers in a Buffer each to increase performance\n // This optimization requires the arrays to have the same type as checked by\n // Object.prototype.toString (aka pToString). Never perform binary\n // comparisons for Float*Arrays, though, since e.g. +0 === -0 but their\n // bit patterns are not identical.\n } else if (isView(actual) && isView(expected) &&\n pToString(actual) === pToString(expected) &&\n !(actual instanceof Float32Array ||\n actual instanceof Float64Array)) {\n return compare(new Uint8Array(actual.buffer),\n new Uint8Array(expected.buffer)) === 0;\n\n // 7.5 For all other Object pairs, including Array objects, equivalence is\n // determined by having the same number of owned properties (as verified\n // with Object.prototype.hasOwnProperty.call), the same set of keys\n // (although not necessarily the same order), equivalent values for every\n // corresponding key, and an identical 'prototype' property. Note: this\n // accounts for both named and indexed properties on Arrays.\n } else if (isBuffer(actual) !== isBuffer(expected)) {\n return false;\n } else {\n memos = memos || {actual: [], expected: []};\n\n var actualIndex = memos.actual.indexOf(actual);\n if (actualIndex !== -1) {\n if (actualIndex === memos.expected.indexOf(expected)) {\n return true;\n }\n }\n\n memos.actual.push(actual);\n memos.expected.push(expected);\n\n return objEquiv(actual, expected, strict, memos);\n }\n}\n\nfunction isArguments(object) {\n return Object.prototype.toString.call(object) == '[object Arguments]';\n}\n\nfunction objEquiv(a, b, strict, actualVisitedObjects) {\n if (a === null || a === undefined || b === null || b === undefined)\n return false;\n // if one is a primitive, the other must be same\n if (util.isPrimitive(a) || util.isPrimitive(b))\n return a === b;\n if (strict && Object.getPrototypeOf(a) !== Object.getPrototypeOf(b))\n return false;\n var aIsArgs = isArguments(a);\n var bIsArgs = isArguments(b);\n if ((aIsArgs && !bIsArgs) || (!aIsArgs && bIsArgs))\n return false;\n if (aIsArgs) {\n a = pSlice.call(a);\n b = pSlice.call(b);\n return _deepEqual(a, b, strict);\n }\n var ka = objectKeys(a);\n var kb = objectKeys(b);\n var key, i;\n // having the same number of owned properties (keys incorporates\n // hasOwnProperty)\n if (ka.length !== kb.length)\n return false;\n //the same set of keys (although not necessarily the same order),\n ka.sort();\n kb.sort();\n //~~~cheap key test\n for (i = ka.length - 1; i >= 0; i--) {\n if (ka[i] !== kb[i])\n return false;\n }\n //equivalent values for every corresponding key, and\n //~~~possibly expensive deep test\n for (i = ka.length - 1; i >= 0; i--) {\n key = ka[i];\n if (!_deepEqual(a[key], b[key], strict, actualVisitedObjects))\n return false;\n }\n return true;\n}\n\n// 8. The non-equivalence assertion tests for any deep inequality.\n// assert.notDeepEqual(actual, expected, message_opt);\n\nassert.notDeepEqual = function notDeepEqual(actual, expected, message) {\n if (_deepEqual(actual, expected, false)) {\n fail(actual, expected, message, 'notDeepEqual', assert.notDeepEqual);\n }\n};\n\nassert.notDeepStrictEqual = notDeepStrictEqual;\nfunction notDeepStrictEqual(actual, expected, message) {\n if (_deepEqual(actual, expected, true)) {\n fail(actual, expected, message, 'notDeepStrictEqual', notDeepStrictEqual);\n }\n}\n\n\n// 9. The strict equality assertion tests strict equality, as determined by ===.\n// assert.strictEqual(actual, expected, message_opt);\n\nassert.strictEqual = function strictEqual(actual, expected, message) {\n if (actual !== expected) {\n fail(actual, expected, message, '===', assert.strictEqual);\n }\n};\n\n// 10. The strict non-equality assertion tests for strict inequality, as\n// determined by !==. assert.notStrictEqual(actual, expected, message_opt);\n\nassert.notStrictEqual = function notStrictEqual(actual, expected, message) {\n if (actual === expected) {\n fail(actual, expected, message, '!==', assert.notStrictEqual);\n }\n};\n\nfunction expectedException(actual, expected) {\n if (!actual || !expected) {\n return false;\n }\n\n if (Object.prototype.toString.call(expected) == '[object RegExp]') {\n return expected.test(actual);\n }\n\n try {\n if (actual instanceof expected) {\n return true;\n }\n } catch (e) {\n // Ignore. The instanceof check doesn't work for arrow functions.\n }\n\n if (Error.isPrototypeOf(expected)) {\n return false;\n }\n\n return expected.call({}, actual) === true;\n}\n\nfunction _tryBlock(block) {\n var error;\n try {\n block();\n } catch (e) {\n error = e;\n }\n return error;\n}\n\nfunction _throws(shouldThrow, block, expected, message) {\n var actual;\n\n if (typeof block !== 'function') {\n throw new TypeError('\"block\" argument must be a function');\n }\n\n if (typeof expected === 'string') {\n message = expected;\n expected = null;\n }\n\n actual = _tryBlock(block);\n\n message = (expected && expected.name ? ' (' + expected.name + ').' : '.') +\n (message ? ' ' + message : '.');\n\n if (shouldThrow && !actual) {\n fail(actual, expected, 'Missing expected exception' + message);\n }\n\n var userProvidedMessage = typeof message === 'string';\n var isUnwantedException = !shouldThrow && util.isError(actual);\n var isUnexpectedException = !shouldThrow && actual && !expected;\n\n if ((isUnwantedException &&\n userProvidedMessage &&\n expectedException(actual, expected)) ||\n isUnexpectedException) {\n fail(actual, expected, 'Got unwanted exception' + message);\n }\n\n if ((shouldThrow && actual && expected &&\n !expectedException(actual, expected)) || (!shouldThrow && actual)) {\n throw actual;\n }\n}\n\n// 11. Expected to throw an error:\n// assert.throws(block, Error_opt, message_opt);\n\nassert.throws = function(block, /*optional*/error, /*optional*/message) {\n _throws(true, block, error, message);\n};\n\n// EXTENSION! This is annoying to write outside this module.\nassert.doesNotThrow = function(block, /*optional*/error, /*optional*/message) {\n _throws(false, block, error, message);\n};\n\nassert.ifError = function(err) { if (err) throw err; };\n\nvar objectKeys = Object.keys || function (obj) {\n var keys = [];\n for (var key in obj) {\n if (hasOwn.call(obj, key)) keys.push(key);\n }\n return keys;\n};\n\n/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../webpack/buildin/global.js */ \"./node_modules/webpack/buildin/global.js\")))\n\n//# sourceURL=webpack:///./node_modules/assert/assert.js?"); + +/***/ }), + +/***/ "./node_modules/async/lib/async.js": +/*!*****************************************!*\ + !*** ./node_modules/async/lib/async.js ***! + \*****************************************/ +/*! no static exports found */ +/***/ (function(module, exports, __webpack_require__) { + +eval("/* WEBPACK VAR INJECTION */(function(process, setImmediate) {var __WEBPACK_AMD_DEFINE_ARRAY__, __WEBPACK_AMD_DEFINE_RESULT__;/*!\n * async\n * https://github.com/caolan/async\n *\n * Copyright 2010-2014 Caolan McMahon\n * Released under the MIT license\n */\n/*jshint onevar: false, indent:4 */\n/*global setImmediate: false, setTimeout: false, console: false */\n(function () {\n\n var async = {};\n\n // global on the server, window in the browser\n var root, previous_async;\n\n root = this;\n if (root != null) {\n previous_async = root.async;\n }\n\n async.noConflict = function () {\n root.async = previous_async;\n return async;\n };\n\n function only_once(fn) {\n var called = false;\n return function() {\n if (called) throw new Error(\"Callback was already called.\");\n called = true;\n fn.apply(root, arguments);\n }\n }\n\n //// cross-browser compatiblity functions ////\n\n var _toString = Object.prototype.toString;\n\n var _isArray = Array.isArray || function (obj) {\n return _toString.call(obj) === '[object Array]';\n };\n\n var _each = function (arr, iterator) {\n for (var i = 0; i < arr.length; i += 1) {\n iterator(arr[i], i, arr);\n }\n };\n\n var _map = function (arr, iterator) {\n if (arr.map) {\n return arr.map(iterator);\n }\n var results = [];\n _each(arr, function (x, i, a) {\n results.push(iterator(x, i, a));\n });\n return results;\n };\n\n var _reduce = function (arr, iterator, memo) {\n if (arr.reduce) {\n return arr.reduce(iterator, memo);\n }\n _each(arr, function (x, i, a) {\n memo = iterator(memo, x, i, a);\n });\n return memo;\n };\n\n var _keys = function (obj) {\n if (Object.keys) {\n return Object.keys(obj);\n }\n var keys = [];\n for (var k in obj) {\n if (obj.hasOwnProperty(k)) {\n keys.push(k);\n }\n }\n return keys;\n };\n\n //// exported async module functions ////\n\n //// nextTick implementation with browser-compatible fallback ////\n if (typeof process === 'undefined' || !(process.nextTick)) {\n if (typeof setImmediate === 'function') {\n async.nextTick = function (fn) {\n // not a direct alias for IE10 compatibility\n setImmediate(fn);\n };\n async.setImmediate = async.nextTick;\n }\n else {\n async.nextTick = function (fn) {\n setTimeout(fn, 0);\n };\n async.setImmediate = async.nextTick;\n }\n }\n else {\n async.nextTick = process.nextTick;\n if (typeof setImmediate !== 'undefined') {\n async.setImmediate = function (fn) {\n // not a direct alias for IE10 compatibility\n setImmediate(fn);\n };\n }\n else {\n async.setImmediate = async.nextTick;\n }\n }\n\n async.each = function (arr, iterator, callback) {\n callback = callback || function () {};\n if (!arr.length) {\n return callback();\n }\n var completed = 0;\n _each(arr, function (x) {\n iterator(x, only_once(done) );\n });\n function done(err) {\n if (err) {\n callback(err);\n callback = function () {};\n }\n else {\n completed += 1;\n if (completed >= arr.length) {\n callback();\n }\n }\n }\n };\n async.forEach = async.each;\n\n async.eachSeries = function (arr, iterator, callback) {\n callback = callback || function () {};\n if (!arr.length) {\n return callback();\n }\n var completed = 0;\n var iterate = function () {\n iterator(arr[completed], function (err) {\n if (err) {\n callback(err);\n callback = function () {};\n }\n else {\n completed += 1;\n if (completed >= arr.length) {\n callback();\n }\n else {\n iterate();\n }\n }\n });\n };\n iterate();\n };\n async.forEachSeries = async.eachSeries;\n\n async.eachLimit = function (arr, limit, iterator, callback) {\n var fn = _eachLimit(limit);\n fn.apply(null, [arr, iterator, callback]);\n };\n async.forEachLimit = async.eachLimit;\n\n var _eachLimit = function (limit) {\n\n return function (arr, iterator, callback) {\n callback = callback || function () {};\n if (!arr.length || limit <= 0) {\n return callback();\n }\n var completed = 0;\n var started = 0;\n var running = 0;\n\n (function replenish () {\n if (completed >= arr.length) {\n return callback();\n }\n\n while (running < limit && started < arr.length) {\n started += 1;\n running += 1;\n iterator(arr[started - 1], function (err) {\n if (err) {\n callback(err);\n callback = function () {};\n }\n else {\n completed += 1;\n running -= 1;\n if (completed >= arr.length) {\n callback();\n }\n else {\n replenish();\n }\n }\n });\n }\n })();\n };\n };\n\n\n var doParallel = function (fn) {\n return function () {\n var args = Array.prototype.slice.call(arguments);\n return fn.apply(null, [async.each].concat(args));\n };\n };\n var doParallelLimit = function(limit, fn) {\n return function () {\n var args = Array.prototype.slice.call(arguments);\n return fn.apply(null, [_eachLimit(limit)].concat(args));\n };\n };\n var doSeries = function (fn) {\n return function () {\n var args = Array.prototype.slice.call(arguments);\n return fn.apply(null, [async.eachSeries].concat(args));\n };\n };\n\n\n var _asyncMap = function (eachfn, arr, iterator, callback) {\n arr = _map(arr, function (x, i) {\n return {index: i, value: x};\n });\n if (!callback) {\n eachfn(arr, function (x, callback) {\n iterator(x.value, function (err) {\n callback(err);\n });\n });\n } else {\n var results = [];\n eachfn(arr, function (x, callback) {\n iterator(x.value, function (err, v) {\n results[x.index] = v;\n callback(err);\n });\n }, function (err) {\n callback(err, results);\n });\n }\n };\n async.map = doParallel(_asyncMap);\n async.mapSeries = doSeries(_asyncMap);\n async.mapLimit = function (arr, limit, iterator, callback) {\n return _mapLimit(limit)(arr, iterator, callback);\n };\n\n var _mapLimit = function(limit) {\n return doParallelLimit(limit, _asyncMap);\n };\n\n // reduce only has a series version, as doing reduce in parallel won't\n // work in many situations.\n async.reduce = function (arr, memo, iterator, callback) {\n async.eachSeries(arr, function (x, callback) {\n iterator(memo, x, function (err, v) {\n memo = v;\n callback(err);\n });\n }, function (err) {\n callback(err, memo);\n });\n };\n // inject alias\n async.inject = async.reduce;\n // foldl alias\n async.foldl = async.reduce;\n\n async.reduceRight = function (arr, memo, iterator, callback) {\n var reversed = _map(arr, function (x) {\n return x;\n }).reverse();\n async.reduce(reversed, memo, iterator, callback);\n };\n // foldr alias\n async.foldr = async.reduceRight;\n\n var _filter = function (eachfn, arr, iterator, callback) {\n var results = [];\n arr = _map(arr, function (x, i) {\n return {index: i, value: x};\n });\n eachfn(arr, function (x, callback) {\n iterator(x.value, function (v) {\n if (v) {\n results.push(x);\n }\n callback();\n });\n }, function (err) {\n callback(_map(results.sort(function (a, b) {\n return a.index - b.index;\n }), function (x) {\n return x.value;\n }));\n });\n };\n async.filter = doParallel(_filter);\n async.filterSeries = doSeries(_filter);\n // select alias\n async.select = async.filter;\n async.selectSeries = async.filterSeries;\n\n var _reject = function (eachfn, arr, iterator, callback) {\n var results = [];\n arr = _map(arr, function (x, i) {\n return {index: i, value: x};\n });\n eachfn(arr, function (x, callback) {\n iterator(x.value, function (v) {\n if (!v) {\n results.push(x);\n }\n callback();\n });\n }, function (err) {\n callback(_map(results.sort(function (a, b) {\n return a.index - b.index;\n }), function (x) {\n return x.value;\n }));\n });\n };\n async.reject = doParallel(_reject);\n async.rejectSeries = doSeries(_reject);\n\n var _detect = function (eachfn, arr, iterator, main_callback) {\n eachfn(arr, function (x, callback) {\n iterator(x, function (result) {\n if (result) {\n main_callback(x);\n main_callback = function () {};\n }\n else {\n callback();\n }\n });\n }, function (err) {\n main_callback();\n });\n };\n async.detect = doParallel(_detect);\n async.detectSeries = doSeries(_detect);\n\n async.some = function (arr, iterator, main_callback) {\n async.each(arr, function (x, callback) {\n iterator(x, function (v) {\n if (v) {\n main_callback(true);\n main_callback = function () {};\n }\n callback();\n });\n }, function (err) {\n main_callback(false);\n });\n };\n // any alias\n async.any = async.some;\n\n async.every = function (arr, iterator, main_callback) {\n async.each(arr, function (x, callback) {\n iterator(x, function (v) {\n if (!v) {\n main_callback(false);\n main_callback = function () {};\n }\n callback();\n });\n }, function (err) {\n main_callback(true);\n });\n };\n // all alias\n async.all = async.every;\n\n async.sortBy = function (arr, iterator, callback) {\n async.map(arr, function (x, callback) {\n iterator(x, function (err, criteria) {\n if (err) {\n callback(err);\n }\n else {\n callback(null, {value: x, criteria: criteria});\n }\n });\n }, function (err, results) {\n if (err) {\n return callback(err);\n }\n else {\n var fn = function (left, right) {\n var a = left.criteria, b = right.criteria;\n return a < b ? -1 : a > b ? 1 : 0;\n };\n callback(null, _map(results.sort(fn), function (x) {\n return x.value;\n }));\n }\n });\n };\n\n async.auto = function (tasks, callback) {\n callback = callback || function () {};\n var keys = _keys(tasks);\n var remainingTasks = keys.length\n if (!remainingTasks) {\n return callback();\n }\n\n var results = {};\n\n var listeners = [];\n var addListener = function (fn) {\n listeners.unshift(fn);\n };\n var removeListener = function (fn) {\n for (var i = 0; i < listeners.length; i += 1) {\n if (listeners[i] === fn) {\n listeners.splice(i, 1);\n return;\n }\n }\n };\n var taskComplete = function () {\n remainingTasks--\n _each(listeners.slice(0), function (fn) {\n fn();\n });\n };\n\n addListener(function () {\n if (!remainingTasks) {\n var theCallback = callback;\n // prevent final callback from calling itself if it errors\n callback = function () {};\n\n theCallback(null, results);\n }\n });\n\n _each(keys, function (k) {\n var task = _isArray(tasks[k]) ? tasks[k]: [tasks[k]];\n var taskCallback = function (err) {\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length <= 1) {\n args = args[0];\n }\n if (err) {\n var safeResults = {};\n _each(_keys(results), function(rkey) {\n safeResults[rkey] = results[rkey];\n });\n safeResults[k] = args;\n callback(err, safeResults);\n // stop subsequent errors hitting callback multiple times\n callback = function () {};\n }\n else {\n results[k] = args;\n async.setImmediate(taskComplete);\n }\n };\n var requires = task.slice(0, Math.abs(task.length - 1)) || [];\n var ready = function () {\n return _reduce(requires, function (a, x) {\n return (a && results.hasOwnProperty(x));\n }, true) && !results.hasOwnProperty(k);\n };\n if (ready()) {\n task[task.length - 1](taskCallback, results);\n }\n else {\n var listener = function () {\n if (ready()) {\n removeListener(listener);\n task[task.length - 1](taskCallback, results);\n }\n };\n addListener(listener);\n }\n });\n };\n\n async.retry = function(times, task, callback) {\n var DEFAULT_TIMES = 5;\n var attempts = [];\n // Use defaults if times not passed\n if (typeof times === 'function') {\n callback = task;\n task = times;\n times = DEFAULT_TIMES;\n }\n // Make sure times is a number\n times = parseInt(times, 10) || DEFAULT_TIMES;\n var wrappedTask = function(wrappedCallback, wrappedResults) {\n var retryAttempt = function(task, finalAttempt) {\n return function(seriesCallback) {\n task(function(err, result){\n seriesCallback(!err || finalAttempt, {err: err, result: result});\n }, wrappedResults);\n };\n };\n while (times) {\n attempts.push(retryAttempt(task, !(times-=1)));\n }\n async.series(attempts, function(done, data){\n data = data[data.length - 1];\n (wrappedCallback || callback)(data.err, data.result);\n });\n }\n // If a callback is passed, run this as a controll flow\n return callback ? wrappedTask() : wrappedTask\n };\n\n async.waterfall = function (tasks, callback) {\n callback = callback || function () {};\n if (!_isArray(tasks)) {\n var err = new Error('First argument to waterfall must be an array of functions');\n return callback(err);\n }\n if (!tasks.length) {\n return callback();\n }\n var wrapIterator = function (iterator) {\n return function (err) {\n if (err) {\n callback.apply(null, arguments);\n callback = function () {};\n }\n else {\n var args = Array.prototype.slice.call(arguments, 1);\n var next = iterator.next();\n if (next) {\n args.push(wrapIterator(next));\n }\n else {\n args.push(callback);\n }\n async.setImmediate(function () {\n iterator.apply(null, args);\n });\n }\n };\n };\n wrapIterator(async.iterator(tasks))();\n };\n\n var _parallel = function(eachfn, tasks, callback) {\n callback = callback || function () {};\n if (_isArray(tasks)) {\n eachfn.map(tasks, function (fn, callback) {\n if (fn) {\n fn(function (err) {\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length <= 1) {\n args = args[0];\n }\n callback.call(null, err, args);\n });\n }\n }, callback);\n }\n else {\n var results = {};\n eachfn.each(_keys(tasks), function (k, callback) {\n tasks[k](function (err) {\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length <= 1) {\n args = args[0];\n }\n results[k] = args;\n callback(err);\n });\n }, function (err) {\n callback(err, results);\n });\n }\n };\n\n async.parallel = function (tasks, callback) {\n _parallel({ map: async.map, each: async.each }, tasks, callback);\n };\n\n async.parallelLimit = function(tasks, limit, callback) {\n _parallel({ map: _mapLimit(limit), each: _eachLimit(limit) }, tasks, callback);\n };\n\n async.series = function (tasks, callback) {\n callback = callback || function () {};\n if (_isArray(tasks)) {\n async.mapSeries(tasks, function (fn, callback) {\n if (fn) {\n fn(function (err) {\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length <= 1) {\n args = args[0];\n }\n callback.call(null, err, args);\n });\n }\n }, callback);\n }\n else {\n var results = {};\n async.eachSeries(_keys(tasks), function (k, callback) {\n tasks[k](function (err) {\n var args = Array.prototype.slice.call(arguments, 1);\n if (args.length <= 1) {\n args = args[0];\n }\n results[k] = args;\n callback(err);\n });\n }, function (err) {\n callback(err, results);\n });\n }\n };\n\n async.iterator = function (tasks) {\n var makeCallback = function (index) {\n var fn = function () {\n if (tasks.length) {\n tasks[index].apply(null, arguments);\n }\n return fn.next();\n };\n fn.next = function () {\n return (index < tasks.length - 1) ? makeCallback(index + 1): null;\n };\n return fn;\n };\n return makeCallback(0);\n };\n\n async.apply = function (fn) {\n var args = Array.prototype.slice.call(arguments, 1);\n return function () {\n return fn.apply(\n null, args.concat(Array.prototype.slice.call(arguments))\n );\n };\n };\n\n var _concat = function (eachfn, arr, fn, callback) {\n var r = [];\n eachfn(arr, function (x, cb) {\n fn(x, function (err, y) {\n r = r.concat(y || []);\n cb(err);\n });\n }, function (err) {\n callback(err, r);\n });\n };\n async.concat = doParallel(_concat);\n async.concatSeries = doSeries(_concat);\n\n async.whilst = function (test, iterator, callback) {\n if (test()) {\n iterator(function (err) {\n if (err) {\n return callback(err);\n }\n async.whilst(test, iterator, callback);\n });\n }\n else {\n callback();\n }\n };\n\n async.doWhilst = function (iterator, test, callback) {\n iterator(function (err) {\n if (err) {\n return callback(err);\n }\n var args = Array.prototype.slice.call(arguments, 1);\n if (test.apply(null, args)) {\n async.doWhilst(iterator, test, callback);\n }\n else {\n callback();\n }\n });\n };\n\n async.until = function (test, iterator, callback) {\n if (!test()) {\n iterator(function (err) {\n if (err) {\n return callback(err);\n }\n async.until(test, iterator, callback);\n });\n }\n else {\n callback();\n }\n };\n\n async.doUntil = function (iterator, test, callback) {\n iterator(function (err) {\n if (err) {\n return callback(err);\n }\n var args = Array.prototype.slice.call(arguments, 1);\n if (!test.apply(null, args)) {\n async.doUntil(iterator, test, callback);\n }\n else {\n callback();\n }\n });\n };\n\n async.queue = function (worker, concurrency) {\n if (concurrency === undefined) {\n concurrency = 1;\n }\n function _insert(q, data, pos, callback) {\n if (!q.started){\n q.started = true;\n }\n if (!_isArray(data)) {\n data = [data];\n }\n if(data.length == 0) {\n // call drain immediately if there are no tasks\n return async.setImmediate(function() {\n if (q.drain) {\n q.drain();\n }\n });\n }\n _each(data, function(task) {\n var item = {\n data: task,\n callback: typeof callback === 'function' ? callback : null\n };\n\n if (pos) {\n q.tasks.unshift(item);\n } else {\n q.tasks.push(item);\n }\n\n if (q.saturated && q.tasks.length === q.concurrency) {\n q.saturated();\n }\n async.setImmediate(q.process);\n });\n }\n\n var workers = 0;\n var q = {\n tasks: [],\n concurrency: concurrency,\n saturated: null,\n empty: null,\n drain: null,\n started: false,\n paused: false,\n push: function (data, callback) {\n _insert(q, data, false, callback);\n },\n kill: function () {\n q.drain = null;\n q.tasks = [];\n },\n unshift: function (data, callback) {\n _insert(q, data, true, callback);\n },\n process: function () {\n if (!q.paused && workers < q.concurrency && q.tasks.length) {\n var task = q.tasks.shift();\n if (q.empty && q.tasks.length === 0) {\n q.empty();\n }\n workers += 1;\n var next = function () {\n workers -= 1;\n if (task.callback) {\n task.callback.apply(task, arguments);\n }\n if (q.drain && q.tasks.length + workers === 0) {\n q.drain();\n }\n q.process();\n };\n var cb = only_once(next);\n worker(task.data, cb);\n }\n },\n length: function () {\n return q.tasks.length;\n },\n running: function () {\n return workers;\n },\n idle: function() {\n return q.tasks.length + workers === 0;\n },\n pause: function () {\n if (q.paused === true) { return; }\n q.paused = true;\n },\n resume: function () {\n if (q.paused === false) { return; }\n q.paused = false;\n // Need to call q.process once per concurrent\n // worker to preserve full concurrency after pause\n for (var w = 1; w <= q.concurrency; w++) {\n async.setImmediate(q.process);\n }\n }\n };\n return q;\n };\n\n async.priorityQueue = function (worker, concurrency) {\n\n function _compareTasks(a, b){\n return a.priority - b.priority;\n };\n\n function _binarySearch(sequence, item, compare) {\n var beg = -1,\n end = sequence.length - 1;\n while (beg < end) {\n var mid = beg + ((end - beg + 1) >>> 1);\n if (compare(item, sequence[mid]) >= 0) {\n beg = mid;\n } else {\n end = mid - 1;\n }\n }\n return beg;\n }\n\n function _insert(q, data, priority, callback) {\n if (!q.started){\n q.started = true;\n }\n if (!_isArray(data)) {\n data = [data];\n }\n if(data.length == 0) {\n // call drain immediately if there are no tasks\n return async.setImmediate(function() {\n if (q.drain) {\n q.drain();\n }\n });\n }\n _each(data, function(task) {\n var item = {\n data: task,\n priority: priority,\n callback: typeof callback === 'function' ? callback : null\n };\n\n q.tasks.splice(_binarySearch(q.tasks, item, _compareTasks) + 1, 0, item);\n\n if (q.saturated && q.tasks.length === q.concurrency) {\n q.saturated();\n }\n async.setImmediate(q.process);\n });\n }\n\n // Start with a normal queue\n var q = async.queue(worker, concurrency);\n\n // Override push to accept second parameter representing priority\n q.push = function (data, priority, callback) {\n _insert(q, data, priority, callback);\n };\n\n // Remove unshift function\n delete q.unshift;\n\n return q;\n };\n\n async.cargo = function (worker, payload) {\n var working = false,\n tasks = [];\n\n var cargo = {\n tasks: tasks,\n payload: payload,\n saturated: null,\n empty: null,\n drain: null,\n drained: true,\n push: function (data, callback) {\n if (!_isArray(data)) {\n data = [data];\n }\n _each(data, function(task) {\n tasks.push({\n data: task,\n callback: typeof callback === 'function' ? callback : null\n });\n cargo.drained = false;\n if (cargo.saturated && tasks.length === payload) {\n cargo.saturated();\n }\n });\n async.setImmediate(cargo.process);\n },\n process: function process() {\n if (working) return;\n if (tasks.length === 0) {\n if(cargo.drain && !cargo.drained) cargo.drain();\n cargo.drained = true;\n return;\n }\n\n var ts = typeof payload === 'number'\n ? tasks.splice(0, payload)\n : tasks.splice(0, tasks.length);\n\n var ds = _map(ts, function (task) {\n return task.data;\n });\n\n if(cargo.empty) cargo.empty();\n working = true;\n worker(ds, function () {\n working = false;\n\n var args = arguments;\n _each(ts, function (data) {\n if (data.callback) {\n data.callback.apply(null, args);\n }\n });\n\n process();\n });\n },\n length: function () {\n return tasks.length;\n },\n running: function () {\n return working;\n }\n };\n return cargo;\n };\n\n var _console_fn = function (name) {\n return function (fn) {\n var args = Array.prototype.slice.call(arguments, 1);\n fn.apply(null, args.concat([function (err) {\n var args = Array.prototype.slice.call(arguments, 1);\n if (typeof console !== 'undefined') {\n if (err) {\n if (console.error) {\n console.error(err);\n }\n }\n else if (console[name]) {\n _each(args, function (x) {\n console[name](x);\n });\n }\n }\n }]));\n };\n };\n async.log = _console_fn('log');\n async.dir = _console_fn('dir');\n /*async.info = _console_fn('info');\n async.warn = _console_fn('warn');\n async.error = _console_fn('error');*/\n\n async.memoize = function (fn, hasher) {\n var memo = {};\n var queues = {};\n hasher = hasher || function (x) {\n return x;\n };\n var memoized = function () {\n var args = Array.prototype.slice.call(arguments);\n var callback = args.pop();\n var key = hasher.apply(null, args);\n if (key in memo) {\n async.nextTick(function () {\n callback.apply(null, memo[key]);\n });\n }\n else if (key in queues) {\n queues[key].push(callback);\n }\n else {\n queues[key] = [callback];\n fn.apply(null, args.concat([function () {\n memo[key] = arguments;\n var q = queues[key];\n delete queues[key];\n for (var i = 0, l = q.length; i < l; i++) {\n q[i].apply(null, arguments);\n }\n }]));\n }\n };\n memoized.memo = memo;\n memoized.unmemoized = fn;\n return memoized;\n };\n\n async.unmemoize = function (fn) {\n return function () {\n return (fn.unmemoized || fn).apply(null, arguments);\n };\n };\n\n async.times = function (count, iterator, callback) {\n var counter = [];\n for (var i = 0; i < count; i++) {\n counter.push(i);\n }\n return async.map(counter, iterator, callback);\n };\n\n async.timesSeries = function (count, iterator, callback) {\n var counter = [];\n for (var i = 0; i < count; i++) {\n counter.push(i);\n }\n return async.mapSeries(counter, iterator, callback);\n };\n\n async.seq = function (/* functions... */) {\n var fns = arguments;\n return function () {\n var that = this;\n var args = Array.prototype.slice.call(arguments);\n var callback = args.pop();\n async.reduce(fns, args, function (newargs, fn, cb) {\n fn.apply(that, newargs.concat([function () {\n var err = arguments[0];\n var nextargs = Array.prototype.slice.call(arguments, 1);\n cb(err, nextargs);\n }]))\n },\n function (err, results) {\n callback.apply(that, [err].concat(results));\n });\n };\n };\n\n async.compose = function (/* functions... */) {\n return async.seq.apply(null, Array.prototype.reverse.call(arguments));\n };\n\n var _applyEach = function (eachfn, fns /*args...*/) {\n var go = function () {\n var that = this;\n var args = Array.prototype.slice.call(arguments);\n var callback = args.pop();\n return eachfn(fns, function (fn, cb) {\n fn.apply(that, args.concat([cb]));\n },\n callback);\n };\n if (arguments.length > 2) {\n var args = Array.prototype.slice.call(arguments, 2);\n return go.apply(this, args);\n }\n else {\n return go;\n }\n };\n async.applyEach = doParallel(_applyEach);\n async.applyEachSeries = doSeries(_applyEach);\n\n async.forever = function (fn, callback) {\n function next(err) {\n if (err) {\n if (callback) {\n return callback(err);\n }\n throw err;\n }\n fn(next);\n }\n next();\n };\n\n // Node.js\n if ( true && module.exports) {\n module.exports = async;\n }\n // AMD / RequireJS\n else if (true) {\n !(__WEBPACK_AMD_DEFINE_ARRAY__ = [], __WEBPACK_AMD_DEFINE_RESULT__ = (function () {\n return async;\n }).apply(exports, __WEBPACK_AMD_DEFINE_ARRAY__),\n\t\t\t\t__WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));\n }\n // included directly via