UNPKG

73.2 kBJavaScriptView Raw
1/******/ (function(modules) { // webpackBootstrap
2/******/ // The module cache
3/******/ var installedModules = {};
4/******/
5/******/ // The require function
6/******/ function __webpack_require__(moduleId) {
7/******/
8/******/ // Check if module is in cache
9/******/ if(installedModules[moduleId]) {
10/******/ return installedModules[moduleId].exports;
11/******/ }
12/******/ // Create a new module (and put it into the cache)
13/******/ var module = installedModules[moduleId] = {
14/******/ i: moduleId,
15/******/ l: false,
16/******/ exports: {}
17/******/ };
18/******/
19/******/ // Execute the module function
20/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
21/******/
22/******/ // Flag the module as loaded
23/******/ module.l = true;
24/******/
25/******/ // Return the exports of the module
26/******/ return module.exports;
27/******/ }
28/******/
29/******/
30/******/ // expose the modules object (__webpack_modules__)
31/******/ __webpack_require__.m = modules;
32/******/
33/******/ // expose the module cache
34/******/ __webpack_require__.c = installedModules;
35/******/
36/******/ // define getter function for harmony exports
37/******/ __webpack_require__.d = function(exports, name, getter) {
38/******/ if(!__webpack_require__.o(exports, name)) {
39/******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
40/******/ }
41/******/ };
42/******/
43/******/ // define __esModule on exports
44/******/ __webpack_require__.r = function(exports) {
45/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
46/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
47/******/ }
48/******/ Object.defineProperty(exports, '__esModule', { value: true });
49/******/ };
50/******/
51/******/ // create a fake namespace object
52/******/ // mode & 1: value is a module id, require it
53/******/ // mode & 2: merge all properties of value into the ns
54/******/ // mode & 4: return value when already ns object
55/******/ // mode & 8|1: behave like require
56/******/ __webpack_require__.t = function(value, mode) {
57/******/ if(mode & 1) value = __webpack_require__(value);
58/******/ if(mode & 8) return value;
59/******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
60/******/ var ns = Object.create(null);
61/******/ __webpack_require__.r(ns);
62/******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
63/******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
64/******/ return ns;
65/******/ };
66/******/
67/******/ // getDefaultExport function for compatibility with non-harmony modules
68/******/ __webpack_require__.n = function(module) {
69/******/ var getter = module && module.__esModule ?
70/******/ function getDefault() { return module['default']; } :
71/******/ function getModuleExports() { return module; };
72/******/ __webpack_require__.d(getter, 'a', getter);
73/******/ return getter;
74/******/ };
75/******/
76/******/ // Object.prototype.hasOwnProperty.call
77/******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
78/******/
79/******/ // __webpack_public_path__
80/******/ __webpack_require__.p = "";
81/******/
82/******/
83/******/ // Load entry module and return exports
84/******/ return __webpack_require__(__webpack_require__.s = "./src/index.js");
85/******/ })
86/************************************************************************/
87/******/ ({
88
89/***/ "./node_modules/component-emitter/index.js":
90/*!*************************************************!*\
91 !*** ./node_modules/component-emitter/index.js ***!
92 \*************************************************/
93/*! no static exports found */
94/***/ (function(module, exports, __webpack_require__) {
95
96eval("\r\n/**\r\n * Expose `Emitter`.\r\n */\r\n\r\nif (true) {\r\n module.exports = Emitter;\r\n}\r\n\r\n/**\r\n * Initialize a new `Emitter`.\r\n *\r\n * @api public\r\n */\r\n\r\nfunction Emitter(obj) {\r\n if (obj) return mixin(obj);\r\n};\r\n\r\n/**\r\n * Mixin the emitter properties.\r\n *\r\n * @param {Object} obj\r\n * @return {Object}\r\n * @api private\r\n */\r\n\r\nfunction mixin(obj) {\r\n for (var key in Emitter.prototype) {\r\n obj[key] = Emitter.prototype[key];\r\n }\r\n return obj;\r\n}\r\n\r\n/**\r\n * Listen on the given `event` with `fn`.\r\n *\r\n * @param {String} event\r\n * @param {Function} fn\r\n * @return {Emitter}\r\n * @api public\r\n */\r\n\r\nEmitter.prototype.on =\r\nEmitter.prototype.addEventListener = function(event, fn){\r\n this._callbacks = this._callbacks || {};\r\n (this._callbacks['$' + event] = this._callbacks['$' + event] || [])\r\n .push(fn);\r\n return this;\r\n};\r\n\r\n/**\r\n * Adds an `event` listener that will be invoked a single\r\n * time then automatically removed.\r\n *\r\n * @param {String} event\r\n * @param {Function} fn\r\n * @return {Emitter}\r\n * @api public\r\n */\r\n\r\nEmitter.prototype.once = function(event, fn){\r\n function on() {\r\n this.off(event, on);\r\n fn.apply(this, arguments);\r\n }\r\n\r\n on.fn = fn;\r\n this.on(event, on);\r\n return this;\r\n};\r\n\r\n/**\r\n * Remove the given callback for `event` or all\r\n * registered callbacks.\r\n *\r\n * @param {String} event\r\n * @param {Function} fn\r\n * @return {Emitter}\r\n * @api public\r\n */\r\n\r\nEmitter.prototype.off =\r\nEmitter.prototype.removeListener =\r\nEmitter.prototype.removeAllListeners =\r\nEmitter.prototype.removeEventListener = function(event, fn){\r\n this._callbacks = this._callbacks || {};\r\n\r\n // all\r\n if (0 == arguments.length) {\r\n this._callbacks = {};\r\n return this;\r\n }\r\n\r\n // specific event\r\n var callbacks = this._callbacks['$' + event];\r\n if (!callbacks) return this;\r\n\r\n // remove all handlers\r\n if (1 == arguments.length) {\r\n delete this._callbacks['$' + event];\r\n return this;\r\n }\r\n\r\n // remove specific handler\r\n var cb;\r\n for (var i = 0; i < callbacks.length; i++) {\r\n cb = callbacks[i];\r\n if (cb === fn || cb.fn === fn) {\r\n callbacks.splice(i, 1);\r\n break;\r\n }\r\n }\r\n\r\n // Remove event specific arrays for event types that no\r\n // one is subscribed for to avoid memory leak.\r\n if (callbacks.length === 0) {\r\n delete this._callbacks['$' + event];\r\n }\r\n\r\n return this;\r\n};\r\n\r\n/**\r\n * Emit `event` with the given args.\r\n *\r\n * @param {String} event\r\n * @param {Mixed} ...\r\n * @return {Emitter}\r\n */\r\n\r\nEmitter.prototype.emit = function(event){\r\n this._callbacks = this._callbacks || {};\r\n\r\n var args = new Array(arguments.length - 1)\r\n , callbacks = this._callbacks['$' + event];\r\n\r\n for (var i = 1; i < arguments.length; i++) {\r\n args[i - 1] = arguments[i];\r\n }\r\n\r\n if (callbacks) {\r\n callbacks = callbacks.slice(0);\r\n for (var i = 0, len = callbacks.length; i < len; ++i) {\r\n callbacks[i].apply(this, args);\r\n }\r\n }\r\n\r\n return this;\r\n};\r\n\r\n/**\r\n * Return array of callbacks for `event`.\r\n *\r\n * @param {String} event\r\n * @return {Array}\r\n * @api public\r\n */\r\n\r\nEmitter.prototype.listeners = function(event){\r\n this._callbacks = this._callbacks || {};\r\n return this._callbacks['$' + event] || [];\r\n};\r\n\r\n/**\r\n * Check if this emitter has `event` handlers.\r\n *\r\n * @param {String} event\r\n * @return {Boolean}\r\n * @api public\r\n */\r\n\r\nEmitter.prototype.hasListeners = function(event){\r\n return !! this.listeners(event).length;\r\n};\r\n\n\n//# sourceURL=webpack:///./node_modules/component-emitter/index.js?");
97
98/***/ }),
99
100/***/ "./node_modules/fast-safe-stringify/index.js":
101/*!***************************************************!*\
102 !*** ./node_modules/fast-safe-stringify/index.js ***!
103 \***************************************************/
104/*! no static exports found */
105/***/ (function(module, exports) {
106
107eval("module.exports = stringify\nstringify.default = stringify\nstringify.stable = deterministicStringify\nstringify.stableStringify = deterministicStringify\n\nvar arr = []\n\n// Regular stringify\nfunction stringify (obj, replacer, spacer) {\n decirc(obj, '', [], undefined)\n var res = JSON.stringify(obj, replacer, spacer)\n while (arr.length !== 0) {\n var part = arr.pop()\n part[0][part[1]] = part[2]\n }\n return res\n}\nfunction decirc (val, k, stack, parent) {\n var i\n if (typeof val === 'object' && val !== null) {\n for (i = 0; i < stack.length; i++) {\n if (stack[i] === val) {\n parent[k] = '[Circular]'\n arr.push([parent, k, val])\n return\n }\n }\n stack.push(val)\n // Optimize for Arrays. Big arrays could kill the performance otherwise!\n if (Array.isArray(val)) {\n for (i = 0; i < val.length; i++) {\n decirc(val[i], i, stack, val)\n }\n } else {\n var keys = Object.keys(val)\n for (i = 0; i < keys.length; i++) {\n var key = keys[i]\n decirc(val[key], key, stack, val)\n }\n }\n stack.pop()\n }\n}\n\n// Stable-stringify\nfunction compareFunction (a, b) {\n if (a < b) {\n return -1\n }\n if (a > b) {\n return 1\n }\n return 0\n}\n\nfunction deterministicStringify (obj, replacer, spacer) {\n var tmp = deterministicDecirc(obj, '', [], undefined) || obj\n var res = JSON.stringify(tmp, replacer, spacer)\n while (arr.length !== 0) {\n var part = arr.pop()\n part[0][part[1]] = part[2]\n }\n return res\n}\n\nfunction deterministicDecirc (val, k, stack, parent) {\n var i\n if (typeof val === 'object' && val !== null) {\n for (i = 0; i < stack.length; i++) {\n if (stack[i] === val) {\n parent[k] = '[Circular]'\n arr.push([parent, k, val])\n return\n }\n }\n if (typeof val.toJSON === 'function') {\n return\n }\n stack.push(val)\n // Optimize for Arrays. Big arrays could kill the performance otherwise!\n if (Array.isArray(val)) {\n for (i = 0; i < val.length; i++) {\n deterministicDecirc(val[i], i, stack, val)\n }\n } else {\n // Create a temporary object in the required way\n var tmp = {}\n var keys = Object.keys(val).sort(compareFunction)\n for (i = 0; i < keys.length; i++) {\n var key = keys[i]\n deterministicDecirc(val[key], key, stack, val)\n tmp[key] = val[key]\n }\n if (parent !== undefined) {\n arr.push([parent, k, val])\n parent[k] = tmp\n } else {\n return tmp\n }\n }\n stack.pop()\n }\n}\n\n\n//# sourceURL=webpack:///./node_modules/fast-safe-stringify/index.js?");
108
109/***/ }),
110
111/***/ "./node_modules/superagent/lib/agent-base.js":
112/*!***************************************************!*\
113 !*** ./node_modules/superagent/lib/agent-base.js ***!
114 \***************************************************/
115/*! no static exports found */
116/***/ (function(module, exports, __webpack_require__) {
117
118"use strict";
119eval("\n\nfunction _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _nonIterableSpread(); }\n\nfunction _nonIterableSpread() { throw new TypeError(\"Invalid attempt to spread non-iterable instance\"); }\n\nfunction _iterableToArray(iter) { if (Symbol.iterator in Object(iter) || Object.prototype.toString.call(iter) === \"[object Arguments]\") return Array.from(iter); }\n\nfunction _arrayWithoutHoles(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = new Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } }\n\nfunction Agent() {\n this._defaults = [];\n}\n\n['use', 'on', 'once', 'set', 'query', 'type', 'accept', 'auth', 'withCredentials', 'sortQuery', 'retry', 'ok', 'redirects', 'timeout', 'buffer', 'serialize', 'parse', 'ca', 'key', 'pfx', 'cert'].forEach(function (fn) {\n // Default setting for all requests from this agent\n Agent.prototype[fn] = function () {\n for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {\n args[_key] = arguments[_key];\n }\n\n this._defaults.push({\n fn: fn,\n args: args\n });\n\n return this;\n };\n});\n\nAgent.prototype._setDefaults = function (req) {\n this._defaults.forEach(function (def) {\n req[def.fn].apply(req, _toConsumableArray(def.args));\n });\n};\n\nmodule.exports = Agent;\n\n//# sourceURL=webpack:///./node_modules/superagent/lib/agent-base.js?");
120
121/***/ }),
122
123/***/ "./node_modules/superagent/lib/client.js":
124/*!***********************************************!*\
125 !*** ./node_modules/superagent/lib/client.js ***!
126 \***********************************************/
127/*! no static exports found */
128/***/ (function(module, exports, __webpack_require__) {
129
130"use strict";
131eval("\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n/**\n * Root reference for iframes.\n */\nvar root;\n\nif (typeof window !== 'undefined') {\n // Browser window\n root = window;\n} else if (typeof self === 'undefined') {\n // Other environments\n console.warn('Using browser-only version of superagent in non-browser environment');\n root = void 0;\n} else {\n // Web Worker\n root = self;\n}\n\nvar Emitter = __webpack_require__(/*! component-emitter */ \"./node_modules/component-emitter/index.js\");\n\nvar safeStringify = __webpack_require__(/*! fast-safe-stringify */ \"./node_modules/fast-safe-stringify/index.js\");\n\nvar RequestBase = __webpack_require__(/*! ./request-base */ \"./node_modules/superagent/lib/request-base.js\");\n\nvar isObject = __webpack_require__(/*! ./is-object */ \"./node_modules/superagent/lib/is-object.js\");\n\nvar ResponseBase = __webpack_require__(/*! ./response-base */ \"./node_modules/superagent/lib/response-base.js\");\n\nvar Agent = __webpack_require__(/*! ./agent-base */ \"./node_modules/superagent/lib/agent-base.js\");\n/**\n * Noop.\n */\n\n\nfunction noop() {}\n/**\n * Expose `request`.\n */\n\n\nmodule.exports = function (method, url) {\n // callback\n if (typeof url === 'function') {\n return new exports.Request('GET', method).end(url);\n } // url first\n\n\n if (arguments.length === 1) {\n return new exports.Request('GET', method);\n }\n\n return new exports.Request(method, url);\n};\n\nexports = module.exports;\nvar request = exports;\nexports.Request = Request;\n/**\n * Determine XHR.\n */\n\nrequest.getXHR = function () {\n if (root.XMLHttpRequest && (!root.location || root.location.protocol !== 'file:' || !root.ActiveXObject)) {\n return new XMLHttpRequest();\n }\n\n try {\n return new ActiveXObject('Microsoft.XMLHTTP');\n } catch (err) {}\n\n try {\n return new ActiveXObject('Msxml2.XMLHTTP.6.0');\n } catch (err) {}\n\n try {\n return new ActiveXObject('Msxml2.XMLHTTP.3.0');\n } catch (err) {}\n\n try {\n return new ActiveXObject('Msxml2.XMLHTTP');\n } catch (err) {}\n\n throw new Error('Browser-only version of superagent could not find XHR');\n};\n/**\n * Removes leading and trailing whitespace, added to support IE.\n *\n * @param {String} s\n * @return {String}\n * @api private\n */\n\n\nvar trim = ''.trim ? function (s) {\n return s.trim();\n} : function (s) {\n return s.replace(/(^\\s*|\\s*$)/g, '');\n};\n/**\n * Serialize the given `obj`.\n *\n * @param {Object} obj\n * @return {String}\n * @api private\n */\n\nfunction serialize(obj) {\n if (!isObject(obj)) return obj;\n var pairs = [];\n\n for (var key in obj) {\n if (Object.prototype.hasOwnProperty.call(obj, key)) pushEncodedKeyValuePair(pairs, key, obj[key]);\n }\n\n return pairs.join('&');\n}\n/**\n * Helps 'serialize' with serializing arrays.\n * Mutates the pairs array.\n *\n * @param {Array} pairs\n * @param {String} key\n * @param {Mixed} val\n */\n\n\nfunction pushEncodedKeyValuePair(pairs, key, val) {\n if (val === undefined) return;\n\n if (val === null) {\n pairs.push(encodeURIComponent(key));\n return;\n }\n\n if (Array.isArray(val)) {\n val.forEach(function (v) {\n pushEncodedKeyValuePair(pairs, key, v);\n });\n } else if (isObject(val)) {\n for (var subkey in val) {\n if (Object.prototype.hasOwnProperty.call(val, subkey)) pushEncodedKeyValuePair(pairs, \"\".concat(key, \"[\").concat(subkey, \"]\"), val[subkey]);\n }\n } else {\n pairs.push(encodeURIComponent(key) + '=' + encodeURIComponent(val));\n }\n}\n/**\n * Expose serialization method.\n */\n\n\nrequest.serializeObject = serialize;\n/**\n * Parse the given x-www-form-urlencoded `str`.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseString(str) {\n var obj = {};\n var pairs = str.split('&');\n var pair;\n var pos;\n\n for (var i = 0, len = pairs.length; i < len; ++i) {\n pair = pairs[i];\n pos = pair.indexOf('=');\n\n if (pos === -1) {\n obj[decodeURIComponent(pair)] = '';\n } else {\n obj[decodeURIComponent(pair.slice(0, pos))] = decodeURIComponent(pair.slice(pos + 1));\n }\n }\n\n return obj;\n}\n/**\n * Expose parser.\n */\n\n\nrequest.parseString = parseString;\n/**\n * Default MIME type map.\n *\n * superagent.types.xml = 'application/xml';\n *\n */\n\nrequest.types = {\n html: 'text/html',\n json: 'application/json',\n xml: 'text/xml',\n urlencoded: 'application/x-www-form-urlencoded',\n form: 'application/x-www-form-urlencoded',\n 'form-data': 'application/x-www-form-urlencoded'\n};\n/**\n * Default serialization map.\n *\n * superagent.serialize['application/xml'] = function(obj){\n * return 'generated xml here';\n * };\n *\n */\n\nrequest.serialize = {\n 'application/x-www-form-urlencoded': serialize,\n 'application/json': safeStringify\n};\n/**\n * Default parsers.\n *\n * superagent.parse['application/xml'] = function(str){\n * return { object parsed from str };\n * };\n *\n */\n\nrequest.parse = {\n 'application/x-www-form-urlencoded': parseString,\n 'application/json': JSON.parse\n};\n/**\n * Parse the given header `str` into\n * an object containing the mapped fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\nfunction parseHeader(str) {\n var lines = str.split(/\\r?\\n/);\n var fields = {};\n var index;\n var line;\n var field;\n var val;\n\n for (var i = 0, len = lines.length; i < len; ++i) {\n line = lines[i];\n index = line.indexOf(':');\n\n if (index === -1) {\n // could be empty line, just skip it\n continue;\n }\n\n field = line.slice(0, index).toLowerCase();\n val = trim(line.slice(index + 1));\n fields[field] = val;\n }\n\n return fields;\n}\n/**\n * Check if `mime` is json or has +json structured syntax suffix.\n *\n * @param {String} mime\n * @return {Boolean}\n * @api private\n */\n\n\nfunction isJSON(mime) {\n // should match /json or +json\n // but not /json-seq\n return /[/+]json($|[^-\\w])/.test(mime);\n}\n/**\n * Initialize a new `Response` with the given `xhr`.\n *\n * - set flags (.ok, .error, etc)\n * - parse header\n *\n * Examples:\n *\n * Aliasing `superagent` as `request` is nice:\n *\n * request = superagent;\n *\n * We can use the promise-like API, or pass callbacks:\n *\n * request.get('/').end(function(res){});\n * request.get('/', function(res){});\n *\n * Sending data can be chained:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' })\n * .end(function(res){});\n *\n * Or passed to `.send()`:\n *\n * request\n * .post('/user')\n * .send({ name: 'tj' }, function(res){});\n *\n * Or passed to `.post()`:\n *\n * request\n * .post('/user', { name: 'tj' })\n * .end(function(res){});\n *\n * Or further reduced to a single call for simple cases:\n *\n * request\n * .post('/user', { name: 'tj' }, function(res){});\n *\n * @param {XMLHTTPRequest} xhr\n * @param {Object} options\n * @api private\n */\n\n\nfunction Response(req) {\n this.req = req;\n this.xhr = this.req.xhr; // responseText is accessible only if responseType is '' or 'text' and on older browsers\n\n this.text = this.req.method !== 'HEAD' && (this.xhr.responseType === '' || this.xhr.responseType === 'text') || typeof this.xhr.responseType === 'undefined' ? this.xhr.responseText : null;\n this.statusText = this.req.xhr.statusText;\n var status = this.xhr.status; // handle IE9 bug: http://stackoverflow.com/questions/10046972/msie-returns-status-code-of-1223-for-ajax-request\n\n if (status === 1223) {\n status = 204;\n }\n\n this._setStatusProperties(status);\n\n this.headers = parseHeader(this.xhr.getAllResponseHeaders());\n this.header = this.headers; // getAllResponseHeaders sometimes falsely returns \"\" for CORS requests, but\n // getResponseHeader still works. so we get content-type even if getting\n // other headers fails.\n\n this.header['content-type'] = this.xhr.getResponseHeader('content-type');\n\n this._setHeaderProperties(this.header);\n\n if (this.text === null && req._responseType) {\n this.body = this.xhr.response;\n } else {\n this.body = this.req.method === 'HEAD' ? null : this._parseBody(this.text ? this.text : this.xhr.response);\n }\n} // eslint-disable-next-line new-cap\n\n\nResponseBase(Response.prototype);\n/**\n * Parse the given body `str`.\n *\n * Used for auto-parsing of bodies. Parsers\n * are defined on the `superagent.parse` object.\n *\n * @param {String} str\n * @return {Mixed}\n * @api private\n */\n\nResponse.prototype._parseBody = function (str) {\n var parse = request.parse[this.type];\n\n if (this.req._parser) {\n return this.req._parser(this, str);\n }\n\n if (!parse && isJSON(this.type)) {\n parse = request.parse['application/json'];\n }\n\n return parse && str && (str.length > 0 || str instanceof Object) ? parse(str) : null;\n};\n/**\n * Return an `Error` representative of this response.\n *\n * @return {Error}\n * @api public\n */\n\n\nResponse.prototype.toError = function () {\n var req = this.req;\n var method = req.method;\n var url = req.url;\n var msg = \"cannot \".concat(method, \" \").concat(url, \" (\").concat(this.status, \")\");\n var err = new Error(msg);\n err.status = this.status;\n err.method = method;\n err.url = url;\n return err;\n};\n/**\n * Expose `Response`.\n */\n\n\nrequest.Response = Response;\n/**\n * Initialize a new `Request` with the given `method` and `url`.\n *\n * @param {String} method\n * @param {String} url\n * @api public\n */\n\nfunction Request(method, url) {\n var self = this;\n this._query = this._query || [];\n this.method = method;\n this.url = url;\n this.header = {}; // preserves header name case\n\n this._header = {}; // coerces header names to lowercase\n\n this.on('end', function () {\n var err = null;\n var res = null;\n\n try {\n res = new Response(self);\n } catch (err2) {\n err = new Error('Parser is unable to parse the response');\n err.parse = true;\n err.original = err2; // issue #675: return the raw response if the response parsing fails\n\n if (self.xhr) {\n // ie9 doesn't have 'response' property\n err.rawResponse = typeof self.xhr.responseType === 'undefined' ? self.xhr.responseText : self.xhr.response; // issue #876: return the http status code if the response parsing fails\n\n err.status = self.xhr.status ? self.xhr.status : null;\n err.statusCode = err.status; // backwards-compat only\n } else {\n err.rawResponse = null;\n err.status = null;\n }\n\n return self.callback(err);\n }\n\n self.emit('response', res);\n var new_err;\n\n try {\n if (!self._isResponseOK(res)) {\n new_err = new Error(res.statusText || 'Unsuccessful HTTP response');\n }\n } catch (err2) {\n new_err = err2; // ok() callback can throw\n } // #1000 don't catch errors from the callback to avoid double calling it\n\n\n if (new_err) {\n new_err.original = err;\n new_err.response = res;\n new_err.status = res.status;\n self.callback(new_err, res);\n } else {\n self.callback(null, res);\n }\n });\n}\n/**\n * Mixin `Emitter` and `RequestBase`.\n */\n// eslint-disable-next-line new-cap\n\n\nEmitter(Request.prototype); // eslint-disable-next-line new-cap\n\nRequestBase(Request.prototype);\n/**\n * Set Content-Type to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.xml = 'application/xml';\n *\n * request.post('/')\n * .type('xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * request.post('/')\n * .type('application/xml')\n * .send(xmlstring)\n * .end(callback);\n *\n * @param {String} type\n * @return {Request} for chaining\n * @api public\n */\n\nRequest.prototype.type = function (type) {\n this.set('Content-Type', request.types[type] || type);\n return this;\n};\n/**\n * Set Accept to `type`, mapping values from `request.types`.\n *\n * Examples:\n *\n * superagent.types.json = 'application/json';\n *\n * request.get('/agent')\n * .accept('json')\n * .end(callback);\n *\n * request.get('/agent')\n * .accept('application/json')\n * .end(callback);\n *\n * @param {String} accept\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequest.prototype.accept = function (type) {\n this.set('Accept', request.types[type] || type);\n return this;\n};\n/**\n * Set Authorization field value with `user` and `pass`.\n *\n * @param {String} user\n * @param {String} [pass] optional in case of using 'bearer' as type\n * @param {Object} options with 'type' property 'auto', 'basic' or 'bearer' (default 'basic')\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequest.prototype.auth = function (user, pass, options) {\n if (arguments.length === 1) pass = '';\n\n if (_typeof(pass) === 'object' && pass !== null) {\n // pass is optional and can be replaced with options\n options = pass;\n pass = '';\n }\n\n if (!options) {\n options = {\n type: typeof btoa === 'function' ? 'basic' : 'auto'\n };\n }\n\n var encoder = function encoder(string) {\n if (typeof btoa === 'function') {\n return btoa(string);\n }\n\n throw new Error('Cannot use basic auth, btoa is not a function');\n };\n\n return this._auth(user, pass, options, encoder);\n};\n/**\n * Add query-string `val`.\n *\n * Examples:\n *\n * request.get('/shoes')\n * .query('size=10')\n * .query({ color: 'blue' })\n *\n * @param {Object|String} val\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequest.prototype.query = function (val) {\n if (typeof val !== 'string') val = serialize(val);\n if (val) this._query.push(val);\n return this;\n};\n/**\n * Queue the given `file` as an attachment to the specified `field`,\n * with optional `options` (or filename).\n *\n * ``` js\n * request.post('/upload')\n * .attach('content', new Blob(['<a id=\"a\"><b id=\"b\">hey!</b></a>'], { type: \"text/html\"}))\n * .end(callback);\n * ```\n *\n * @param {String} field\n * @param {Blob|File} file\n * @param {String|Object} options\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequest.prototype.attach = function (field, file, options) {\n if (file) {\n if (this._data) {\n throw new Error(\"superagent can't mix .send() and .attach()\");\n }\n\n this._getFormData().append(field, file, options || file.name);\n }\n\n return this;\n};\n\nRequest.prototype._getFormData = function () {\n if (!this._formData) {\n this._formData = new root.FormData();\n }\n\n return this._formData;\n};\n/**\n * Invoke the callback with `err` and `res`\n * and handle arity check.\n *\n * @param {Error} err\n * @param {Response} res\n * @api private\n */\n\n\nRequest.prototype.callback = function (err, res) {\n if (this._shouldRetry(err, res)) {\n return this._retry();\n }\n\n var fn = this._callback;\n this.clearTimeout();\n\n if (err) {\n if (this._maxRetries) err.retries = this._retries - 1;\n this.emit('error', err);\n }\n\n fn(err, res);\n};\n/**\n * Invoke callback with x-domain error.\n *\n * @api private\n */\n\n\nRequest.prototype.crossDomainError = function () {\n var err = new Error('Request has been terminated\\nPossible causes: the network is offline, Origin is not allowed by Access-Control-Allow-Origin, the page is being unloaded, etc.');\n err.crossDomain = true;\n err.status = this.status;\n err.method = this.method;\n err.url = this.url;\n this.callback(err);\n}; // This only warns, because the request is still likely to work\n\n\nRequest.prototype.agent = function () {\n console.warn('This is not supported in browser version of superagent');\n return this;\n};\n\nRequest.prototype.buffer = Request.prototype.ca;\nRequest.prototype.ca = Request.prototype.agent; // This throws, because it can't send/receive data as expected\n\nRequest.prototype.write = function () {\n throw new Error('Streaming is not supported in browser version of superagent');\n};\n\nRequest.prototype.pipe = Request.prototype.write;\n/**\n * Check if `obj` is a host object,\n * we don't want to serialize these :)\n *\n * @param {Object} obj host object\n * @return {Boolean} is a host object\n * @api private\n */\n\nRequest.prototype._isHost = function (obj) {\n // Native objects stringify to [object File], [object Blob], [object FormData], etc.\n return obj && _typeof(obj) === 'object' && !Array.isArray(obj) && Object.prototype.toString.call(obj) !== '[object Object]';\n};\n/**\n * Initiate request, invoking callback `fn(res)`\n * with an instanceof `Response`.\n *\n * @param {Function} fn\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequest.prototype.end = function (fn) {\n if (this._endCalled) {\n console.warn('Warning: .end() was called twice. This is not supported in superagent');\n }\n\n this._endCalled = true; // store callback\n\n this._callback = fn || noop; // querystring\n\n this._finalizeQueryString();\n\n this._end();\n};\n\nRequest.prototype._setUploadTimeout = function () {\n var self = this; // upload timeout it's wokrs only if deadline timeout is off\n\n if (this._uploadTimeout && !this._uploadTimeoutTimer) {\n this._uploadTimeoutTimer = setTimeout(function () {\n self._timeoutError('Upload timeout of ', self._uploadTimeout, 'ETIMEDOUT');\n }, this._uploadTimeout);\n }\n}; // eslint-disable-next-line complexity\n\n\nRequest.prototype._end = function () {\n if (this._aborted) return this.callback(new Error('The request has been aborted even before .end() was called'));\n var self = this;\n this.xhr = request.getXHR();\n var xhr = this.xhr;\n var data = this._formData || this._data;\n\n this._setTimeouts(); // state change\n\n\n xhr.onreadystatechange = function () {\n var readyState = xhr.readyState;\n\n if (readyState >= 2 && self._responseTimeoutTimer) {\n clearTimeout(self._responseTimeoutTimer);\n }\n\n if (readyState !== 4) {\n return;\n } // In IE9, reads to any property (e.g. status) off of an aborted XHR will\n // result in the error \"Could not complete the operation due to error c00c023f\"\n\n\n var status;\n\n try {\n status = xhr.status;\n } catch (err) {\n status = 0;\n }\n\n if (!status) {\n if (self.timedout || self._aborted) return;\n return self.crossDomainError();\n }\n\n self.emit('end');\n }; // progress\n\n\n var handleProgress = function handleProgress(direction, e) {\n if (e.total > 0) {\n e.percent = e.loaded / e.total * 100;\n\n if (e.percent === 100) {\n clearTimeout(self._uploadTimeoutTimer);\n }\n }\n\n e.direction = direction;\n self.emit('progress', e);\n };\n\n if (this.hasListeners('progress')) {\n try {\n xhr.addEventListener('progress', handleProgress.bind(null, 'download'));\n\n if (xhr.upload) {\n xhr.upload.addEventListener('progress', handleProgress.bind(null, 'upload'));\n }\n } catch (err) {// Accessing xhr.upload fails in IE from a web worker, so just pretend it doesn't exist.\n // Reported here:\n // https://connect.microsoft.com/IE/feedback/details/837245/xmlhttprequest-upload-throws-invalid-argument-when-used-from-web-worker-context\n }\n }\n\n if (xhr.upload) {\n this._setUploadTimeout();\n } // initiate request\n\n\n try {\n if (this.username && this.password) {\n xhr.open(this.method, this.url, true, this.username, this.password);\n } else {\n xhr.open(this.method, this.url, true);\n }\n } catch (err) {\n // see #1149\n return this.callback(err);\n } // CORS\n\n\n if (this._withCredentials) xhr.withCredentials = true; // body\n\n if (!this._formData && this.method !== 'GET' && this.method !== 'HEAD' && typeof data !== 'string' && !this._isHost(data)) {\n // serialize stuff\n var contentType = this._header['content-type'];\n\n var _serialize = this._serializer || request.serialize[contentType ? contentType.split(';')[0] : ''];\n\n if (!_serialize && isJSON(contentType)) {\n _serialize = request.serialize['application/json'];\n }\n\n if (_serialize) data = _serialize(data);\n } // set header fields\n\n\n for (var field in this.header) {\n if (this.header[field] === null) continue;\n if (Object.prototype.hasOwnProperty.call(this.header, field)) xhr.setRequestHeader(field, this.header[field]);\n }\n\n if (this._responseType) {\n xhr.responseType = this._responseType;\n } // send stuff\n\n\n this.emit('request', this); // IE11 xhr.send(undefined) sends 'undefined' string as POST payload (instead of nothing)\n // We need null here if data is undefined\n\n xhr.send(typeof data === 'undefined' ? null : data);\n};\n\nrequest.agent = function () {\n return new Agent();\n};\n\n['GET', 'POST', 'OPTIONS', 'PATCH', 'PUT', 'DELETE'].forEach(function (method) {\n Agent.prototype[method.toLowerCase()] = function (url, fn) {\n var req = new request.Request(method, url);\n\n this._setDefaults(req);\n\n if (fn) {\n req.end(fn);\n }\n\n return req;\n };\n});\nAgent.prototype.del = Agent.prototype.delete;\n/**\n * GET `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} [data] or fn\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\nrequest.get = function (url, data, fn) {\n var req = request('GET', url);\n\n if (typeof data === 'function') {\n fn = data;\n data = null;\n }\n\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n/**\n * HEAD `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} [data] or fn\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\n\nrequest.head = function (url, data, fn) {\n var req = request('HEAD', url);\n\n if (typeof data === 'function') {\n fn = data;\n data = null;\n }\n\n if (data) req.query(data);\n if (fn) req.end(fn);\n return req;\n};\n/**\n * OPTIONS query to `url` with optional callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} [data] or fn\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\n\nrequest.options = function (url, data, fn) {\n var req = request('OPTIONS', url);\n\n if (typeof data === 'function') {\n fn = data;\n data = null;\n }\n\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n/**\n * DELETE `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} [data]\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\n\nfunction del(url, data, fn) {\n var req = request('DELETE', url);\n\n if (typeof data === 'function') {\n fn = data;\n data = null;\n }\n\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n}\n\nrequest.del = del;\nrequest.delete = del;\n/**\n * PATCH `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} [data]\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\nrequest.patch = function (url, data, fn) {\n var req = request('PATCH', url);\n\n if (typeof data === 'function') {\n fn = data;\n data = null;\n }\n\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n/**\n * POST `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed} [data]\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\n\nrequest.post = function (url, data, fn) {\n var req = request('POST', url);\n\n if (typeof data === 'function') {\n fn = data;\n data = null;\n }\n\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n/**\n * PUT `url` with optional `data` and callback `fn(res)`.\n *\n * @param {String} url\n * @param {Mixed|Function} [data] or fn\n * @param {Function} [fn]\n * @return {Request}\n * @api public\n */\n\n\nrequest.put = function (url, data, fn) {\n var req = request('PUT', url);\n\n if (typeof data === 'function') {\n fn = data;\n data = null;\n }\n\n if (data) req.send(data);\n if (fn) req.end(fn);\n return req;\n};\n\n//# sourceURL=webpack:///./node_modules/superagent/lib/client.js?");
132
133/***/ }),
134
135/***/ "./node_modules/superagent/lib/is-object.js":
136/*!**************************************************!*\
137 !*** ./node_modules/superagent/lib/is-object.js ***!
138 \**************************************************/
139/*! no static exports found */
140/***/ (function(module, exports, __webpack_require__) {
141
142"use strict";
143eval("\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n/**\n * Check if `obj` is an object.\n *\n * @param {Object} obj\n * @return {Boolean}\n * @api private\n */\nfunction isObject(obj) {\n return obj !== null && _typeof(obj) === 'object';\n}\n\nmodule.exports = isObject;\n\n//# sourceURL=webpack:///./node_modules/superagent/lib/is-object.js?");
144
145/***/ }),
146
147/***/ "./node_modules/superagent/lib/request-base.js":
148/*!*****************************************************!*\
149 !*** ./node_modules/superagent/lib/request-base.js ***!
150 \*****************************************************/
151/*! no static exports found */
152/***/ (function(module, exports, __webpack_require__) {
153
154"use strict";
155eval("\n\nfunction _typeof(obj) { if (typeof Symbol === \"function\" && typeof Symbol.iterator === \"symbol\") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === \"function\" && obj.constructor === Symbol && obj !== Symbol.prototype ? \"symbol\" : typeof obj; }; } return _typeof(obj); }\n\n/**\n * Module of mixed-in functions shared between node and client code\n */\nvar isObject = __webpack_require__(/*! ./is-object */ \"./node_modules/superagent/lib/is-object.js\");\n/**\n * Expose `RequestBase`.\n */\n\n\nmodule.exports = RequestBase;\n/**\n * Initialize a new `RequestBase`.\n *\n * @api public\n */\n\nfunction RequestBase(obj) {\n if (obj) return mixin(obj);\n}\n/**\n * Mixin the prototype properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\n\nfunction mixin(obj) {\n for (var key in RequestBase.prototype) {\n if (Object.prototype.hasOwnProperty.call(RequestBase.prototype, key)) obj[key] = RequestBase.prototype[key];\n }\n\n return obj;\n}\n/**\n * Clear previous timeout.\n *\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequestBase.prototype.clearTimeout = function () {\n clearTimeout(this._timer);\n clearTimeout(this._responseTimeoutTimer);\n clearTimeout(this._uploadTimeoutTimer);\n delete this._timer;\n delete this._responseTimeoutTimer;\n delete this._uploadTimeoutTimer;\n return this;\n};\n/**\n * Override default response body parser\n *\n * This function will be called to convert incoming data into request.body\n *\n * @param {Function}\n * @api public\n */\n\n\nRequestBase.prototype.parse = function (fn) {\n this._parser = fn;\n return this;\n};\n/**\n * Set format of binary response body.\n * In browser valid formats are 'blob' and 'arraybuffer',\n * which return Blob and ArrayBuffer, respectively.\n *\n * In Node all values result in Buffer.\n *\n * Examples:\n *\n * req.get('/')\n * .responseType('blob')\n * .end(callback);\n *\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequestBase.prototype.responseType = function (val) {\n this._responseType = val;\n return this;\n};\n/**\n * Override default request body serializer\n *\n * This function will be called to convert data set via .send or .attach into payload to send\n *\n * @param {Function}\n * @api public\n */\n\n\nRequestBase.prototype.serialize = function (fn) {\n this._serializer = fn;\n return this;\n};\n/**\n * Set timeouts.\n *\n * - response timeout is time between sending request and receiving the first byte of the response. Includes DNS and connection time.\n * - deadline is the time from start of the request to receiving response body in full. If the deadline is too short large files may not load at all on slow connections.\n * - upload is the time since last bit of data was sent or received. This timeout works only if deadline timeout is off\n *\n * Value of 0 or false means no timeout.\n *\n * @param {Number|Object} ms or {response, deadline}\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequestBase.prototype.timeout = function (options) {\n if (!options || _typeof(options) !== 'object') {\n this._timeout = options;\n this._responseTimeout = 0;\n this._uploadTimeout = 0;\n return this;\n }\n\n for (var option in options) {\n if (Object.prototype.hasOwnProperty.call(options, option)) {\n switch (option) {\n case 'deadline':\n this._timeout = options.deadline;\n break;\n\n case 'response':\n this._responseTimeout = options.response;\n break;\n\n case 'upload':\n this._uploadTimeout = options.upload;\n break;\n\n default:\n console.warn('Unknown timeout option', option);\n }\n }\n }\n\n return this;\n};\n/**\n * Set number of retry attempts on error.\n *\n * Failed requests will be retried 'count' times if timeout or err.code >= 500.\n *\n * @param {Number} count\n * @param {Function} [fn]\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequestBase.prototype.retry = function (count, fn) {\n // Default to 1 if no count passed or true\n if (arguments.length === 0 || count === true) count = 1;\n if (count <= 0) count = 0;\n this._maxRetries = count;\n this._retries = 0;\n this._retryCallback = fn;\n return this;\n};\n\nvar ERROR_CODES = ['ECONNRESET', 'ETIMEDOUT', 'EADDRINFO', 'ESOCKETTIMEDOUT'];\n/**\n * Determine if a request should be retried.\n * (Borrowed from segmentio/superagent-retry)\n *\n * @param {Error} err an error\n * @param {Response} [res] response\n * @returns {Boolean} if segment should be retried\n */\n\nRequestBase.prototype._shouldRetry = function (err, res) {\n if (!this._maxRetries || this._retries++ >= this._maxRetries) {\n return false;\n }\n\n if (this._retryCallback) {\n try {\n var override = this._retryCallback(err, res);\n\n if (override === true) return true;\n if (override === false) return false; // undefined falls back to defaults\n } catch (err2) {\n console.error(err2);\n }\n }\n\n if (res && res.status && res.status >= 500 && res.status !== 501) return true;\n\n if (err) {\n if (err.code && ERROR_CODES.indexOf(err.code) !== -1) return true; // Superagent timeout\n\n if (err.timeout && err.code === 'ECONNABORTED') return true;\n if (err.crossDomain) return true;\n }\n\n return false;\n};\n/**\n * Retry request\n *\n * @return {Request} for chaining\n * @api private\n */\n\n\nRequestBase.prototype._retry = function () {\n this.clearTimeout(); // node\n\n if (this.req) {\n this.req = null;\n this.req = this.request();\n }\n\n this._aborted = false;\n this.timedout = false;\n return this._end();\n};\n/**\n * Promise support\n *\n * @param {Function} resolve\n * @param {Function} [reject]\n * @return {Request}\n */\n\n\nRequestBase.prototype.then = function (resolve, reject) {\n var _this = this;\n\n if (!this._fullfilledPromise) {\n var self = this;\n\n if (this._endCalled) {\n console.warn('Warning: superagent request was sent twice, because both .end() and .then() were called. Never call .end() if you use promises');\n }\n\n this._fullfilledPromise = new Promise(function (resolve, reject) {\n self.on('abort', function () {\n var err = new Error('Aborted');\n err.code = 'ABORTED';\n err.status = _this.status;\n err.method = _this.method;\n err.url = _this.url;\n reject(err);\n });\n self.end(function (err, res) {\n if (err) reject(err);else resolve(res);\n });\n });\n }\n\n return this._fullfilledPromise.then(resolve, reject);\n};\n\nRequestBase.prototype.catch = function (cb) {\n return this.then(undefined, cb);\n};\n/**\n * Allow for extension\n */\n\n\nRequestBase.prototype.use = function (fn) {\n fn(this);\n return this;\n};\n\nRequestBase.prototype.ok = function (cb) {\n if (typeof cb !== 'function') throw new Error('Callback required');\n this._okCallback = cb;\n return this;\n};\n\nRequestBase.prototype._isResponseOK = function (res) {\n if (!res) {\n return false;\n }\n\n if (this._okCallback) {\n return this._okCallback(res);\n }\n\n return res.status >= 200 && res.status < 300;\n};\n/**\n * Get request header `field`.\n * Case-insensitive.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\n\nRequestBase.prototype.get = function (field) {\n return this._header[field.toLowerCase()];\n};\n/**\n * Get case-insensitive header `field` value.\n * This is a deprecated internal API. Use `.get(field)` instead.\n *\n * (getHeader is no longer used internally by the superagent code base)\n *\n * @param {String} field\n * @return {String}\n * @api private\n * @deprecated\n */\n\n\nRequestBase.prototype.getHeader = RequestBase.prototype.get;\n/**\n * Set header `field` to `val`, or multiple fields with one object.\n * Case-insensitive.\n *\n * Examples:\n *\n * req.get('/')\n * .set('Accept', 'application/json')\n * .set('X-API-Key', 'foobar')\n * .end(callback);\n *\n * req.get('/')\n * .set({ Accept: 'application/json', 'X-API-Key': 'foobar' })\n * .end(callback);\n *\n * @param {String|Object} field\n * @param {String} val\n * @return {Request} for chaining\n * @api public\n */\n\nRequestBase.prototype.set = function (field, val) {\n if (isObject(field)) {\n for (var key in field) {\n if (Object.prototype.hasOwnProperty.call(field, key)) this.set(key, field[key]);\n }\n\n return this;\n }\n\n this._header[field.toLowerCase()] = val;\n this.header[field] = val;\n return this;\n}; // eslint-disable-next-line valid-jsdoc\n\n/**\n * Remove header `field`.\n * Case-insensitive.\n *\n * Example:\n *\n * req.get('/')\n * .unset('User-Agent')\n * .end(callback);\n *\n * @param {String} field field name\n */\n\n\nRequestBase.prototype.unset = function (field) {\n delete this._header[field.toLowerCase()];\n delete this.header[field];\n return this;\n};\n/**\n * Write the field `name` and `val`, or multiple fields with one object\n * for \"multipart/form-data\" request bodies.\n *\n * ``` js\n * request.post('/upload')\n * .field('foo', 'bar')\n * .end(callback);\n *\n * request.post('/upload')\n * .field({ foo: 'bar', baz: 'qux' })\n * .end(callback);\n * ```\n *\n * @param {String|Object} name name of field\n * @param {String|Blob|File|Buffer|fs.ReadStream} val value of field\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequestBase.prototype.field = function (name, val) {\n // name should be either a string or an object.\n if (name === null || undefined === name) {\n throw new Error('.field(name, val) name can not be empty');\n }\n\n if (this._data) {\n throw new Error(\".field() can't be used if .send() is used. Please use only .send() or only .field() & .attach()\");\n }\n\n if (isObject(name)) {\n for (var key in name) {\n if (Object.prototype.hasOwnProperty.call(name, key)) this.field(key, name[key]);\n }\n\n return this;\n }\n\n if (Array.isArray(val)) {\n for (var i in val) {\n if (Object.prototype.hasOwnProperty.call(val, i)) this.field(name, val[i]);\n }\n\n return this;\n } // val should be defined now\n\n\n if (val === null || undefined === val) {\n throw new Error('.field(name, val) val can not be empty');\n }\n\n if (typeof val === 'boolean') {\n val = String(val);\n }\n\n this._getFormData().append(name, val);\n\n return this;\n};\n/**\n * Abort the request, and clear potential timeout.\n *\n * @return {Request} request\n * @api public\n */\n\n\nRequestBase.prototype.abort = function () {\n if (this._aborted) {\n return this;\n }\n\n this._aborted = true;\n if (this.xhr) this.xhr.abort(); // browser\n\n if (this.req) this.req.abort(); // node\n\n this.clearTimeout();\n this.emit('abort');\n return this;\n};\n\nRequestBase.prototype._auth = function (user, pass, options, base64Encoder) {\n switch (options.type) {\n case 'basic':\n this.set('Authorization', \"Basic \".concat(base64Encoder(\"\".concat(user, \":\").concat(pass))));\n break;\n\n case 'auto':\n this.username = user;\n this.password = pass;\n break;\n\n case 'bearer':\n // usage would be .auth(accessToken, { type: 'bearer' })\n this.set('Authorization', \"Bearer \".concat(user));\n break;\n\n default:\n break;\n }\n\n return this;\n};\n/**\n * Enable transmission of cookies with x-domain requests.\n *\n * Note that for this to work the origin must not be\n * using \"Access-Control-Allow-Origin\" with a wildcard,\n * and also must set \"Access-Control-Allow-Credentials\"\n * to \"true\".\n *\n * @api public\n */\n\n\nRequestBase.prototype.withCredentials = function (on) {\n // This is browser-only functionality. Node side is no-op.\n if (on === undefined) on = true;\n this._withCredentials = on;\n return this;\n};\n/**\n * Set the max redirects to `n`. Does nothing in browser XHR implementation.\n *\n * @param {Number} n\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequestBase.prototype.redirects = function (n) {\n this._maxRedirects = n;\n return this;\n};\n/**\n * Maximum size of buffered response body, in bytes. Counts uncompressed size.\n * Default 200MB.\n *\n * @param {Number} n number of bytes\n * @return {Request} for chaining\n */\n\n\nRequestBase.prototype.maxResponseSize = function (n) {\n if (typeof n !== 'number') {\n throw new TypeError('Invalid argument');\n }\n\n this._maxResponseSize = n;\n return this;\n};\n/**\n * Convert to a plain javascript object (not JSON string) of scalar properties.\n * Note as this method is designed to return a useful non-this value,\n * it cannot be chained.\n *\n * @return {Object} describing method, url, and data of this request\n * @api public\n */\n\n\nRequestBase.prototype.toJSON = function () {\n return {\n method: this.method,\n url: this.url,\n data: this._data,\n headers: this._header\n };\n};\n/**\n * Send `data` as the request body, defaulting the `.type()` to \"json\" when\n * an object is given.\n *\n * Examples:\n *\n * // manual json\n * request.post('/user')\n * .type('json')\n * .send('{\"name\":\"tj\"}')\n * .end(callback)\n *\n * // auto json\n * request.post('/user')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // manual x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send('name=tj')\n * .end(callback)\n *\n * // auto x-www-form-urlencoded\n * request.post('/user')\n * .type('form')\n * .send({ name: 'tj' })\n * .end(callback)\n *\n * // defaults to x-www-form-urlencoded\n * request.post('/user')\n * .send('name=tobi')\n * .send('species=ferret')\n * .end(callback)\n *\n * @param {String|Object} data\n * @return {Request} for chaining\n * @api public\n */\n// eslint-disable-next-line complexity\n\n\nRequestBase.prototype.send = function (data) {\n var isObj = isObject(data);\n var type = this._header['content-type'];\n\n if (this._formData) {\n throw new Error(\".send() can't be used if .attach() or .field() is used. Please use only .send() or only .field() & .attach()\");\n }\n\n if (isObj && !this._data) {\n if (Array.isArray(data)) {\n this._data = [];\n } else if (!this._isHost(data)) {\n this._data = {};\n }\n } else if (data && this._data && this._isHost(this._data)) {\n throw new Error(\"Can't merge these send calls\");\n } // merge\n\n\n if (isObj && isObject(this._data)) {\n for (var key in data) {\n if (Object.prototype.hasOwnProperty.call(data, key)) this._data[key] = data[key];\n }\n } else if (typeof data === 'string') {\n // default to x-www-form-urlencoded\n if (!type) this.type('form');\n type = this._header['content-type'];\n\n if (type === 'application/x-www-form-urlencoded') {\n this._data = this._data ? \"\".concat(this._data, \"&\").concat(data) : data;\n } else {\n this._data = (this._data || '') + data;\n }\n } else {\n this._data = data;\n }\n\n if (!isObj || this._isHost(data)) {\n return this;\n } // default to json\n\n\n if (!type) this.type('json');\n return this;\n};\n/**\n * Sort `querystring` by the sort function\n *\n *\n * Examples:\n *\n * // default order\n * request.get('/user')\n * .query('name=Nick')\n * .query('search=Manny')\n * .sortQuery()\n * .end(callback)\n *\n * // customized sort function\n * request.get('/user')\n * .query('name=Nick')\n * .query('search=Manny')\n * .sortQuery(function(a, b){\n * return a.length - b.length;\n * })\n * .end(callback)\n *\n *\n * @param {Function} sort\n * @return {Request} for chaining\n * @api public\n */\n\n\nRequestBase.prototype.sortQuery = function (sort) {\n // _sort default to true but otherwise can be a function or boolean\n this._sort = typeof sort === 'undefined' ? true : sort;\n return this;\n};\n/**\n * Compose querystring to append to req.url\n *\n * @api private\n */\n\n\nRequestBase.prototype._finalizeQueryString = function () {\n var query = this._query.join('&');\n\n if (query) {\n this.url += (this.url.indexOf('?') >= 0 ? '&' : '?') + query;\n }\n\n this._query.length = 0; // Makes the call idempotent\n\n if (this._sort) {\n var index = this.url.indexOf('?');\n\n if (index >= 0) {\n var queryArr = this.url.substring(index + 1).split('&');\n\n if (typeof this._sort === 'function') {\n queryArr.sort(this._sort);\n } else {\n queryArr.sort();\n }\n\n this.url = this.url.substring(0, index) + '?' + queryArr.join('&');\n }\n }\n}; // For backwards compat only\n\n\nRequestBase.prototype._appendQueryString = function () {\n console.warn('Unsupported');\n};\n/**\n * Invoke callback with timeout error.\n *\n * @api private\n */\n\n\nRequestBase.prototype._timeoutError = function (reason, timeout, errno) {\n if (this._aborted) {\n return;\n }\n\n var err = new Error(\"\".concat(reason + timeout, \"ms exceeded\"));\n err.timeout = timeout;\n err.code = 'ECONNABORTED';\n err.errno = errno;\n this.timedout = true;\n this.abort();\n this.callback(err);\n};\n\nRequestBase.prototype._setTimeouts = function () {\n var self = this; // deadline\n\n if (this._timeout && !this._timer) {\n this._timer = setTimeout(function () {\n self._timeoutError('Timeout of ', self._timeout, 'ETIME');\n }, this._timeout);\n } // response timeout\n\n\n if (this._responseTimeout && !this._responseTimeoutTimer) {\n this._responseTimeoutTimer = setTimeout(function () {\n self._timeoutError('Response timeout of ', self._responseTimeout, 'ETIMEDOUT');\n }, this._responseTimeout);\n }\n};\n\n//# sourceURL=webpack:///./node_modules/superagent/lib/request-base.js?");
156
157/***/ }),
158
159/***/ "./node_modules/superagent/lib/response-base.js":
160/*!******************************************************!*\
161 !*** ./node_modules/superagent/lib/response-base.js ***!
162 \******************************************************/
163/*! no static exports found */
164/***/ (function(module, exports, __webpack_require__) {
165
166"use strict";
167eval("\n\n/**\n * Module dependencies.\n */\nvar utils = __webpack_require__(/*! ./utils */ \"./node_modules/superagent/lib/utils.js\");\n/**\n * Expose `ResponseBase`.\n */\n\n\nmodule.exports = ResponseBase;\n/**\n * Initialize a new `ResponseBase`.\n *\n * @api public\n */\n\nfunction ResponseBase(obj) {\n if (obj) return mixin(obj);\n}\n/**\n * Mixin the prototype properties.\n *\n * @param {Object} obj\n * @return {Object}\n * @api private\n */\n\n\nfunction mixin(obj) {\n for (var key in ResponseBase.prototype) {\n if (Object.prototype.hasOwnProperty.call(ResponseBase.prototype, key)) obj[key] = ResponseBase.prototype[key];\n }\n\n return obj;\n}\n/**\n * Get case-insensitive `field` value.\n *\n * @param {String} field\n * @return {String}\n * @api public\n */\n\n\nResponseBase.prototype.get = function (field) {\n return this.header[field.toLowerCase()];\n};\n/**\n * Set header related properties:\n *\n * - `.type` the content type without params\n *\n * A response of \"Content-Type: text/plain; charset=utf-8\"\n * will provide you with a `.type` of \"text/plain\".\n *\n * @param {Object} header\n * @api private\n */\n\n\nResponseBase.prototype._setHeaderProperties = function (header) {\n // TODO: moar!\n // TODO: make this a util\n // content-type\n var ct = header['content-type'] || '';\n this.type = utils.type(ct); // params\n\n var params = utils.params(ct);\n\n for (var key in params) {\n if (Object.prototype.hasOwnProperty.call(params, key)) this[key] = params[key];\n }\n\n this.links = {}; // links\n\n try {\n if (header.link) {\n this.links = utils.parseLinks(header.link);\n }\n } catch (err) {// ignore\n }\n};\n/**\n * Set flags such as `.ok` based on `status`.\n *\n * For example a 2xx response will give you a `.ok` of __true__\n * whereas 5xx will be __false__ and `.error` will be __true__. The\n * `.clientError` and `.serverError` are also available to be more\n * specific, and `.statusType` is the class of error ranging from 1..5\n * sometimes useful for mapping respond colors etc.\n *\n * \"sugar\" properties are also defined for common cases. Currently providing:\n *\n * - .noContent\n * - .badRequest\n * - .unauthorized\n * - .notAcceptable\n * - .notFound\n *\n * @param {Number} status\n * @api private\n */\n\n\nResponseBase.prototype._setStatusProperties = function (status) {\n var type = status / 100 | 0; // status / class\n\n this.statusCode = status;\n this.status = this.statusCode;\n this.statusType = type; // basics\n\n this.info = type === 1;\n this.ok = type === 2;\n this.redirect = type === 3;\n this.clientError = type === 4;\n this.serverError = type === 5;\n this.error = type === 4 || type === 5 ? this.toError() : false; // sugar\n\n this.created = status === 201;\n this.accepted = status === 202;\n this.noContent = status === 204;\n this.badRequest = status === 400;\n this.unauthorized = status === 401;\n this.notAcceptable = status === 406;\n this.forbidden = status === 403;\n this.notFound = status === 404;\n this.unprocessableEntity = status === 422;\n};\n\n//# sourceURL=webpack:///./node_modules/superagent/lib/response-base.js?");
168
169/***/ }),
170
171/***/ "./node_modules/superagent/lib/utils.js":
172/*!**********************************************!*\
173 !*** ./node_modules/superagent/lib/utils.js ***!
174 \**********************************************/
175/*! no static exports found */
176/***/ (function(module, exports, __webpack_require__) {
177
178"use strict";
179eval("\n\n/**\n * Return the mime type for the given `str`.\n *\n * @param {String} str\n * @return {String}\n * @api private\n */\nexports.type = function (str) {\n return str.split(/ *; */).shift();\n};\n/**\n * Return header field parameters.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\n\nexports.params = function (str) {\n return str.split(/ *; */).reduce(function (obj, str) {\n var parts = str.split(/ *= */);\n var key = parts.shift();\n var val = parts.shift();\n if (key && val) obj[key] = val;\n return obj;\n }, {});\n};\n/**\n * Parse Link header fields.\n *\n * @param {String} str\n * @return {Object}\n * @api private\n */\n\n\nexports.parseLinks = function (str) {\n return str.split(/ *, */).reduce(function (obj, str) {\n var parts = str.split(/ *; */);\n var url = parts[0].slice(1, -1);\n var rel = parts[1].split(/ *= */)[1].slice(1, -1);\n obj[rel] = url;\n return obj;\n }, {});\n};\n/**\n * Strip content related fields from `header`.\n *\n * @param {Object} header\n * @return {Object} header\n * @api private\n */\n\n\nexports.cleanHeader = function (header, changesOrigin) {\n delete header['content-type'];\n delete header['content-length'];\n delete header['transfer-encoding'];\n delete header.host; // secuirty\n\n if (changesOrigin) {\n delete header.authorization;\n delete header.cookie;\n }\n\n return header;\n};\n\n//# sourceURL=webpack:///./node_modules/superagent/lib/utils.js?");
180
181/***/ }),
182
183/***/ "./src/auth.js":
184/*!*********************!*\
185 !*** ./src/auth.js ***!
186 \*********************/
187/*! exports provided: default */
188/***/ (function(module, __webpack_exports__, __webpack_require__) {
189
190"use strict";
191eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"default\", function() { return Authentication; });\nfunction asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }\n\nfunction _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"next\", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, \"throw\", err); } _next(undefined); }); }; }\n\nfunction _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError(\"Cannot call a class as a function\"); } }\n\nfunction _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); } }\n\nfunction _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }\n\nvar request = __webpack_require__(/*! superagent */ \"./node_modules/superagent/lib/client.js\");\n\nvar Authentication =\n/*#__PURE__*/\nfunction () {\n function Authentication() {\n var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n\n _classCallCheck(this, Authentication);\n\n var authUrl = opts.authUrl,\n clientId = opts.clientId,\n storage = opts.storage,\n loginUrl = opts.loginUrl,\n logoutUrl = opts.logoutUrl,\n userFetchUrl = opts.userFetchUrl,\n accessCheckUrl = opts.accessCheckUrl;\n this.authUrl = authUrl || 'https://moauth.fagbokforlaget.no';\n this.currentUser = undefined;\n this.token = undefined;\n this.clientId = clientId;\n this.storage = storage || window.localStorage;\n this.loginUrl = loginUrl || this.authUrl + '/_auth/login';\n this.logoutUrl = logoutUrl;\n this.userFetchUrl = userFetchUrl || this.authUrl + '/_auth/user?token=';\n this.accessCheckUrl = accessCheckUrl || this.authUrl + '/_auth/access';\n }\n\n _createClass(Authentication, [{\n key: \"_loginUrl\",\n value: function _loginUrl(redirectUrl) {\n var scope = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;\n\n if (!this.loginUrl.includes('?')) {\n this.loginUrl += '?';\n }\n\n return this.loginUrl + '&client_id=' + (this.clientId || 'generic') + '&redirect_url=' + encodeURIComponent(redirectUrl) + '&scope=' + (scope || 'dbok');\n }\n }, {\n key: \"_parseQueryString\",\n value: function _parseQueryString(loc) {\n var pl = /\\+/g;\n var search = /([^&=]+)=?([^&]*)/g;\n\n var decode = function decode(s) {\n return decodeURIComponent(s.replace(pl, ' '));\n };\n\n var urlParams = {};\n var query = loc.substring(1);\n\n if (/\\?/.test(query)) {\n query = query.split('?')[1];\n }\n\n while (1) {\n var match = search.exec(query);\n\n if (!match) {\n break;\n }\n\n urlParams[decode(match[1])] = decode(match[2]);\n }\n\n return urlParams;\n }\n }, {\n key: \"authorize\",\n value: function authorize() {\n var obj = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};\n var redirectUrl = obj.redirectUrl,\n scope = obj.scope;\n window.location = this._loginUrl(redirectUrl || window.location, scope);\n }\n }, {\n key: \"getUser\",\n value: function getUser() {\n var storeUser = this.storage.getItem('user');\n\n if (this.currentUser) {\n return this.currentUser;\n }\n\n if (storeUser) {\n return JSON.parse(storeUser);\n }\n\n return undefined;\n }\n }, {\n key: \"checkToken\",\n value: function checkToken() {\n var _this = this;\n\n var loc = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : window.location.search;\n\n var params = this._parseQueryString(loc);\n\n var self = this;\n self.token = params.token || params.access_token || this.storage.getItem('token') || undefined;\n return new Promise(function (resolve, reject) {\n if (self.isAuthenticated() && self.token && typeof self.token !== 'undefined') {\n resolve(self.getUser());\n }\n\n if (self.token && typeof self.token !== 'undefined') {\n if (window) {\n window.history.replaceState({}, '', window.location.pathname + window.location.hash || '');\n }\n\n self.storage.setItem('token', self.token);\n self.fetchUser(_this.userFetchUrl + encodeURIComponent(self.token)).then(function (user) {\n resolve(user);\n })[\"catch\"](function (err) {\n reject(err);\n });\n } else {\n reject(new Error('access token not found'));\n }\n });\n }\n }, {\n key: \"checkAccess\",\n value: function checkAccess() {\n var _this2 = this;\n\n var productIds = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];\n var token = this.token || this.storage.getItem('token') || undefined;\n var products = Array.isArray(productIds) ? productIds : [productIds];\n var user = this.getUser();\n return new Promise(\n /*#__PURE__*/\n function () {\n var _ref = _asyncToGenerator(\n /*#__PURE__*/\n regeneratorRuntime.mark(function _callee(resolve, reject) {\n var allowedProducts;\n return regeneratorRuntime.wrap(function _callee$(_context) {\n while (1) {\n switch (_context.prev = _context.next) {\n case 0:\n if (!(token && typeof token !== 'undefined')) {\n _context.next = 7;\n break;\n }\n\n _context.next = 3;\n return _this2.fetchAccess(_this2.accessCheckUrl, {\n token: token,\n productIds: products\n });\n\n case 3:\n allowedProducts = _context.sent;\n resolve({\n success: true,\n user: user,\n products: allowedProducts\n });\n _context.next = 8;\n break;\n\n case 7:\n throw new Error('access token not found');\n\n case 8:\n case \"end\":\n return _context.stop();\n }\n }\n }, _callee);\n }));\n\n return function (_x, _x2) {\n return _ref.apply(this, arguments);\n };\n }());\n }\n }, {\n key: \"fetchUser\",\n value: function fetchUser(url) {\n var self = this;\n return new Promise(function (resolve, reject) {\n request.get(url).then(function (response) {\n if (response.statusCode === 200 && response.body) {\n var resp = response.body;\n var user = resp.user || resp.objects[0];\n self.storage.setItem('user', JSON.stringify(user));\n resolve(user);\n } else {\n reject(new Error('authentication failed: Invalid response'));\n }\n })[\"catch\"](function (err) {\n reject(err);\n });\n });\n }\n }, {\n key: \"fetchAccess\",\n value: function fetchAccess(url, body) {\n return new Promise(function (resolve, reject) {\n request.post(url).send(body).set('Accept', 'application/json').then(function (response) {\n if (response.statusCode === 200 && response.body) {\n if (response.body.success) {\n resolve(response.body.products);\n } else {\n reject(new Error('This user does not have access to this product'));\n }\n }\n })[\"catch\"](function (error) {\n reject(error);\n });\n });\n }\n }, {\n key: \"logout\",\n value: function () {\n var _logout = _asyncToGenerator(\n /*#__PURE__*/\n regeneratorRuntime.mark(function _callee2(url) {\n return regeneratorRuntime.wrap(function _callee2$(_context2) {\n while (1) {\n switch (_context2.prev = _context2.next) {\n case 0:\n this.storage.removeItem('user');\n this.storage.removeItem('token');\n url = url || this.logoutUrl;\n if (url) window.location = url;\n\n case 4:\n case \"end\":\n return _context2.stop();\n }\n }\n }, _callee2, this);\n }));\n\n function logout(_x3) {\n return _logout.apply(this, arguments);\n }\n\n return logout;\n }()\n }, {\n key: \"isAuthenticated\",\n value: function isAuthenticated() {\n var user = this.getUser();\n\n if (user) {\n return true;\n }\n\n return false;\n }\n }]);\n\n return Authentication;\n}();\n\n\n\n//# sourceURL=webpack:///./src/auth.js?");
192
193/***/ }),
194
195/***/ "./src/index.js":
196/*!**********************!*\
197 !*** ./src/index.js ***!
198 \**********************/
199/*! exports provided: default */
200/***/ (function(module, __webpack_exports__, __webpack_require__) {
201
202"use strict";
203eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _auth__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./auth */ \"./src/auth.js\");\n\n/* harmony default export */ __webpack_exports__[\"default\"] = (_auth__WEBPACK_IMPORTED_MODULE_0__[\"default\"]);\n\n//# sourceURL=webpack:///./src/index.js?");
204
205/***/ })
206
207/******/ });
\No newline at end of file