UNPKG

95.3 kBSource Map (JSON)View Raw
1{"version":3,"sources":["webpack://moauth/webpack/universalModuleDefinition","webpack://moauth/webpack/bootstrap","webpack://moauth/./node_modules/superagent/lib/is-object.js","webpack://moauth/./node_modules/superagent/lib/client.js","webpack://moauth/./node_modules/component-emitter/index.js","webpack://moauth/./node_modules/fast-safe-stringify/index.js","webpack://moauth/./node_modules/superagent/lib/request-base.js","webpack://moauth/./node_modules/superagent/lib/response-base.js","webpack://moauth/./node_modules/superagent/lib/utils.js","webpack://moauth/./node_modules/superagent/lib/agent-base.js","webpack://moauth/./src/auth.js","webpack://moauth/./src/index.js"],"names":["root","factory","exports","module","define","amd","window","installedModules","__webpack_require__","moduleId","i","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","_typeof","obj","iterator","constructor","self","console","warn","Emitter","safeStringify","RequestBase","isObject","ResponseBase","Agent","noop","method","url","Request","end","arguments","length","request","getXHR","XMLHttpRequest","location","protocol","ActiveXObject","err","Error","trim","replace","serialize","pairs","pushEncodedKeyValuePair","join","val","undefined","Array","isArray","forEach","v","subkey","concat","push","encodeURIComponent","parseString","str","pair","pos","split","len","indexOf","decodeURIComponent","slice","isJSON","mime","test","Response","req","this","xhr","text","responseType","responseText","statusText","status","_setStatusProperties","headers","index","line","field","lines","fields","toLowerCase","parseHeader","getAllResponseHeaders","header","getResponseHeader","_setHeaderProperties","_responseType","body","response","_parseBody","_query","_header","on","new_err","res","err2","parse","original","rawResponse","statusCode","callback","emit","_isResponseOK","del","data","fn","send","serializeObject","types","html","json","xml","urlencoded","form","form-data","application/x-www-form-urlencoded","application/json","JSON","type","_parser","toError","msg","set","accept","auth","user","pass","options","btoa","_auth","string","query","attach","file","_data","_getFormData","append","_formData","FormData","_shouldRetry","_retry","_callback","clearTimeout","_maxRetries","retries","_retries","crossDomainError","crossDomain","agent","buffer","ca","write","pipe","_isHost","toString","_endCalled","_finalizeQueryString","_end","_setUploadTimeout","_uploadTimeout","_uploadTimeoutTimer","setTimeout","_timeoutError","_aborted","_setTimeouts","onreadystatechange","readyState","_responseTimeoutTimer","timedout","handleProgress","direction","e","total","percent","loaded","hasListeners","addEventListener","upload","username","password","open","_withCredentials","withCredentials","contentType","_serialize","_serializer","setRequestHeader","_setDefaults","delete","head","patch","post","put","mixin","event","_callbacks","once","off","apply","removeListener","removeAllListeners","removeEventListener","cb","callbacks","splice","args","listeners","stringify","default","stable","deterministicStringify","stableStringify","arr","replacer","spacer","decirc","k","stack","parent","keys","pop","part","compareFunction","a","b","tmp","deterministicDecirc","toJSON","sort","_timer","timeout","_timeout","_responseTimeout","option","deadline","retry","count","_retryCallback","ERROR_CODES","override","error","code","then","resolve","reject","_this","_fullfilledPromise","Promise","catch","use","ok","_okCallback","getHeader","unset","String","abort","base64Encoder","redirects","_maxRedirects","maxResponseSize","TypeError","_maxResponseSize","isObj","sortQuery","_sort","queryArr","substring","_appendQueryString","reason","errno","utils","ct","params","links","link","parseLinks","statusType","info","redirect","clientError","serverError","created","accepted","noContent","badRequest","unauthorized","notAcceptable","forbidden","notFound","unprocessableEntity","shift","reduce","parts","cleanHeader","changesOrigin","host","authorization","cookie","_toConsumableArray","arr2","_arrayWithoutHoles","iter","from","_iterableToArray","_nonIterableSpread","_defaults","_len","_key","def","require","Authentication","opts","_classCallCheck","authUrl","clientId","storage","loginUrl","logoutUrl","userFetchUrl","accessCheckUrl","currentUser","token","localStorage","redirectUrl","scope","includes","loc","pl","search","decode","urlParams","match","exec","_loginUrl","storeUser","getItem","_parseQueryString","access_token","isAuthenticated","getUser","history","replaceState","pathname","hash","setItem","fetchUser","productIds","_this2","products","allowedProducts","_ref","_asyncToGenerator","regeneratorRuntime","mark","_callee","wrap","_context","prev","next","t0","fetchAccess","t1","sent","t2","checkToken","t3","stop","_x","_x2","resp","objects","success","removeItem"],"mappings":"CAAA,SAAAA,EAAAC,GACA,iBAAAC,SAA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KAAA,iBAcflH,EAAO,IAAIjN,MAAM,2BAdF,yBAAAiU,EAAAU,SAAAZ,EAAA,yBAAZ,gBAAAa,EAAAC,GAAA,OAAAlB,EAAAxJ,MAAApI,KAAAxC,YAAA,sCAmBEH,GACT,IAAIX,EAAOsD,KAEX,OAAO,IAAIqL,QAAQ,SAACJ,EAASC,GAC3BxN,EACGvC,IAAIkC,GACJ2N,KAAK,SAAA1J,GACJ,GAA4B,MAAxBA,EAASW,YAAsBX,EAASD,KAAM,CAChD,IAAI0R,EAAOzR,EAASD,KAChBsC,EAAOoP,EAAKpP,MAAQoP,EAAKC,QAAQ,GAErCtW,EAAK+S,QAAQ6B,QAAQ,OAAQnO,KAAK0F,UAAUlF,IAC5CsH,EAAQtH,QAERuH,EAAO,IAAIjN,MAAM,8CAVvB,MAaS,SAAAD,GACLkN,EAAOlN,2CAKFX,EAAKgE,GAChB,OAAO,IAAIgK,QAAQ,SAACJ,EAASC,GAC3BxN,EACGmK,KAAKxK,GACLmF,KAAKnB,GACLmC,IAAI,SAAU,oBACdwH,KAAK,SAAA1J,GACwB,MAAxBA,EAASW,YAAsBX,EAASD,OACtCC,EAASD,KAAK4R,QAChBhI,EAAQ3J,EAASD,KAAKqQ,UAEtBxG,EAAO,IAAIjN,MAAM,sDATzB,MAaS,SAAA6M,GACLI,EAAOJ,mFAKDzN,kFACZ2C,KAAKyP,QAAQyD,WAAW,QACxBlT,KAAKyP,QAAQyD,WAAW,UAExB7V,EAAMA,GAAO2C,KAAK2P,aAETzV,OAAO2D,SAAWR,gJAM3B,QAFW2C,KAAKiR,+CC5KL7B","file":"moauth.bundle.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"moauth\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"moauth\"] = factory();\n\telse\n\t\troot[\"moauth\"] = factory();\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 1);\n","\"use strict\";\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;","\"use strict\";\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 = require('component-emitter');\n\nvar safeStringify = require('fast-safe-stringify');\n\nvar RequestBase = require('./request-base');\n\nvar isObject = require('./is-object');\n\nvar ResponseBase = require('./response-base');\n\nvar Agent = require('./agent-base');\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};","\r\n/**\r\n * Expose `Emitter`.\r\n */\r\n\r\nif (typeof module !== 'undefined') {\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","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","\"use strict\";\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 = require('./is-object');\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};","\"use strict\";\n\n/**\n * Module dependencies.\n */\nvar utils = require('./utils');\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};","\"use strict\";\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};","\"use strict\";\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;","const request = require('superagent')\n\nexport default class Authentication {\n constructor (opts = {}) {\n let { authUrl, clientId, storage, loginUrl, logoutUrl, userFetchUrl, accessCheckUrl } = opts\n\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 _loginUrl (redirectUrl, scope = undefined) {\n if (!this.loginUrl.includes('?')) {\n this.loginUrl += '?'\n }\n return this.loginUrl + '&client_id=' + (this.clientId || 'generic') + '&redirect_url=' + encodeURIComponent(redirectUrl) + '&scope=' + (scope || 'dbok')\n }\n\n _parseQueryString (loc) {\n const pl = /\\+/g\n const search = /([^&=]+)=?([^&]*)/g\n const decode = function (s) { return decodeURIComponent(s.replace(pl, ' ')) }\n let urlParams = {}\n let query = loc.substring(1)\n\n if (/\\?/.test(query)) {\n query = query.split('?')[1]\n }\n\n while (1) {\n const match = search.exec(query)\n\n if (!match) {\n break\n }\n urlParams[decode(match[1])] = decode(match[2])\n }\n\n return urlParams\n }\n\n authorize (obj = {}) {\n let { redirectUrl, scope } = obj\n\n window.location = this._loginUrl(redirectUrl || window.location, scope)\n }\n\n getUser () {\n let storeUser = this.storage.getItem('user')\n\n if (this.currentUser) {\n return this.currentUser\n }\n if (storeUser) {\n return JSON.parse(storeUser)\n }\n return undefined\n }\n\n checkToken (loc = window.location.search) {\n let params = this._parseQueryString(loc)\n let self = this\n\n self.token = params.token || params.access_token || this.storage.getItem('token') || undefined\n\n return new Promise((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 self.storage.setItem('token', self.token)\n self.fetchUser(this.userFetchUrl + encodeURIComponent(self.token))\n .then((user) => {\n resolve(user)\n })\n .catch((err) => {\n reject(err)\n })\n } else {\n reject(new Error('access token not found'))\n }\n })\n }\n\n checkAccess (productIds, loc = window.location.search) {\n const params = this._parseQueryString(loc)\n const token = params.token || params.access_token || this.storage.getItem('token') || undefined\n const products = Array.isArray(productIds) ? productIds : [productIds]\n const allowedProducts = []\n\n return new Promise(async (resolve, reject) => {\n if (token && typeof token !== 'undefined') {\n try {\n allowedProducts.concat(await this.fetchAccess(this.accessCheckUrl, { token: token, productIds: products }))\n } catch (err) {\n reject(err)\n }\n try {\n const user = await this.checkToken(loc)\n resolve({ user: user, products: allowedProducts })\n } catch (err) {\n reject(err)\n }\n } else {\n reject(new Error('access token not found'))\n }\n })\n }\n\n fetchUser (url) {\n let self = this\n\n return new Promise((resolve, reject) => {\n request\n .get(url)\n .then(response => {\n if (response.statusCode === 200 && response.body) {\n let resp = response.body\n let user = resp.user || resp.objects[0]\n\n self.storage.setItem('user', JSON.stringify(user))\n resolve(user)\n } else {\n reject(new Error('authentication failed: Invalid response'))\n }\n })\n .catch(err => {\n reject(err)\n })\n })\n }\n\n fetchAccess (url, body) {\n return new Promise((resolve, reject) => {\n request\n .post(url)\n .send(body)\n .set('Accept', 'application/json')\n .then(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 })\n .catch(error => {\n reject(error)\n })\n })\n }\n\n async logout (url) {\n this.storage.removeItem('user')\n this.storage.removeItem('token')\n\n url = url || this.logoutUrl\n\n if (url) window.location = url\n }\n\n isAuthenticated () {\n let user = this.getUser()\n\n if (user) {\n return true\n }\n return false\n }\n}\n","import Authentication from './auth'\nexport default Authentication\n"],"sourceRoot":""}
\No newline at end of file