UNPKG

@feathersjs/client

Version:

A module that consolidates Feathers client modules for REST (jQuery, Request, Superagent) and Websocket (Socket.io, Primus) connections

1,625 lines (1,353 loc) 69.8 kB
(function webpackUniversalModuleDefinition(root, factory) { if(typeof exports === 'object' && typeof module === 'object') module.exports = factory(); else if(typeof define === 'function' && define.amd) define([], factory); else if(typeof exports === 'object') exports["feathers"] = factory(); else root["feathers"] = factory(); })(this, function() { return /******/ (function(modules) { // webpackBootstrap /******/ // The module cache /******/ var installedModules = {}; /******/ /******/ // The require function /******/ function __webpack_require__(moduleId) { /******/ /******/ // Check if module is in cache /******/ if(installedModules[moduleId]) { /******/ return installedModules[moduleId].exports; /******/ } /******/ // Create a new module (and put it into the cache) /******/ var module = installedModules[moduleId] = { /******/ i: moduleId, /******/ l: false, /******/ exports: {} /******/ }; /******/ /******/ // Execute the module function /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); /******/ /******/ // Flag the module as loaded /******/ module.l = true; /******/ /******/ // Return the exports of the module /******/ return module.exports; /******/ } /******/ /******/ /******/ // expose the modules object (__webpack_modules__) /******/ __webpack_require__.m = modules; /******/ /******/ // expose the module cache /******/ __webpack_require__.c = installedModules; /******/ /******/ // define getter function for harmony exports /******/ __webpack_require__.d = function(exports, name, getter) { /******/ if(!__webpack_require__.o(exports, name)) { /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter }); /******/ } /******/ }; /******/ /******/ // define __esModule on exports /******/ __webpack_require__.r = function(exports) { /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) { /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' }); /******/ } /******/ Object.defineProperty(exports, '__esModule', { value: true }); /******/ }; /******/ /******/ // create a fake namespace object /******/ // mode & 1: value is a module id, require it /******/ // mode & 2: merge all properties of value into the ns /******/ // mode & 4: return value when already ns object /******/ // mode & 8|1: behave like require /******/ __webpack_require__.t = function(value, mode) { /******/ if(mode & 1) value = __webpack_require__(value); /******/ if(mode & 8) return value; /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value; /******/ var ns = Object.create(null); /******/ __webpack_require__.r(ns); /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value }); /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key)); /******/ return ns; /******/ }; /******/ /******/ // getDefaultExport function for compatibility with non-harmony modules /******/ __webpack_require__.n = function(module) { /******/ var getter = module && module.__esModule ? /******/ function getDefault() { return module['default']; } : /******/ function getModuleExports() { return module; }; /******/ __webpack_require__.d(getter, 'a', getter); /******/ return getter; /******/ }; /******/ /******/ // Object.prototype.hasOwnProperty.call /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); }; /******/ /******/ // __webpack_public_path__ /******/ __webpack_require__.p = ""; /******/ /******/ /******/ // Load entry module and return exports /******/ return __webpack_require__(__webpack_require__.s = "./src/authentication.js"); /******/ }) /************************************************************************/ /******/ ({ /***/ "../../node_modules/debug/src/browser.js": /*!**************************************************************************************!*\ !*** /Users/daffl/Development/feathersjs/feathers/node_modules/debug/src/browser.js ***! \**************************************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { /* WEBPACK VAR INJECTION */(function(process) {function _typeof(obj) { "@babel/helpers - typeof"; 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); } /* eslint-env browser */ /** * This is the web browser implementation of `debug()`. */ exports.log = log; exports.formatArgs = formatArgs; exports.save = save; exports.load = load; exports.useColors = useColors; exports.storage = localstorage(); /** * Colors. */ exports.colors = ['#0000CC', '#0000FF', '#0033CC', '#0033FF', '#0066CC', '#0066FF', '#0099CC', '#0099FF', '#00CC00', '#00CC33', '#00CC66', '#00CC99', '#00CCCC', '#00CCFF', '#3300CC', '#3300FF', '#3333CC', '#3333FF', '#3366CC', '#3366FF', '#3399CC', '#3399FF', '#33CC00', '#33CC33', '#33CC66', '#33CC99', '#33CCCC', '#33CCFF', '#6600CC', '#6600FF', '#6633CC', '#6633FF', '#66CC00', '#66CC33', '#9900CC', '#9900FF', '#9933CC', '#9933FF', '#99CC00', '#99CC33', '#CC0000', '#CC0033', '#CC0066', '#CC0099', '#CC00CC', '#CC00FF', '#CC3300', '#CC3333', '#CC3366', '#CC3399', '#CC33CC', '#CC33FF', '#CC6600', '#CC6633', '#CC9900', '#CC9933', '#CCCC00', '#CCCC33', '#FF0000', '#FF0033', '#FF0066', '#FF0099', '#FF00CC', '#FF00FF', '#FF3300', '#FF3333', '#FF3366', '#FF3399', '#FF33CC', '#FF33FF', '#FF6600', '#FF6633', '#FF9900', '#FF9933', '#FFCC00', '#FFCC33']; /** * Currently only WebKit-based Web Inspectors, Firefox >= v31, * and the Firebug extension (any Firefox version) are known * to support "%c" CSS customizations. * * TODO: add a `localStorage` variable to explicitly enable/disable colors */ // eslint-disable-next-line complexity function useColors() { // NB: In an Electron preload script, document will be defined but not fully // initialized. Since we know we're in Chrome, we'll just detect this case // explicitly if (typeof window !== 'undefined' && window.process && (window.process.type === 'renderer' || window.process.__nwjs)) { return true; } // Internet Explorer and Edge do not support colors. if (typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/)) { return false; } // Is webkit? http://stackoverflow.com/a/16459606/376773 // document is undefined in react-native: https://github.com/facebook/react-native/pull/1632 return typeof document !== 'undefined' && document.documentElement && document.documentElement.style && document.documentElement.style.WebkitAppearance || // Is firebug? http://stackoverflow.com/a/398120/376773 typeof window !== 'undefined' && window.console && (window.console.firebug || window.console.exception && window.console.table) || // Is firefox >= v31? // https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31 || // Double check webkit in userAgent just in case we are in a worker typeof navigator !== 'undefined' && navigator.userAgent && navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/); } /** * Colorize log arguments if enabled. * * @api public */ function formatArgs(args) { args[0] = (this.useColors ? '%c' : '') + this.namespace + (this.useColors ? ' %c' : ' ') + args[0] + (this.useColors ? '%c ' : ' ') + '+' + module.exports.humanize(this.diff); if (!this.useColors) { return; } var c = 'color: ' + this.color; args.splice(1, 0, c, 'color: inherit'); // The final "%c" is somewhat tricky, because there could be other // arguments passed either before or after the %c, so we need to // figure out the correct index to insert the CSS into var index = 0; var lastC = 0; args[0].replace(/%[a-zA-Z%]/g, function (match) { if (match === '%%') { return; } index++; if (match === '%c') { // We only are interested in the *last* %c // (the user may have provided their own) lastC = index; } }); args.splice(lastC, 0, c); } /** * Invokes `console.log()` when available. * No-op when `console.log` is not a "function". * * @api public */ function log() { var _console; // This hackery is required for IE8/9, where // the `console.log` function doesn't have 'apply' return (typeof console === "undefined" ? "undefined" : _typeof(console)) === 'object' && console.log && (_console = console).log.apply(_console, arguments); } /** * Save `namespaces`. * * @param {String} namespaces * @api private */ function save(namespaces) { try { if (namespaces) { exports.storage.setItem('debug', namespaces); } else { exports.storage.removeItem('debug'); } } catch (error) {// Swallow // XXX (@Qix-) should we be logging these? } } /** * Load `namespaces`. * * @return {String} returns the previously persisted debug modes * @api private */ function load() { var r; try { r = exports.storage.getItem('debug'); } catch (error) {// Swallow // XXX (@Qix-) should we be logging these? } // If debug isn't set in LS, and we're in Electron, try to load $DEBUG if (!r && typeof process !== 'undefined' && 'env' in process) { r = process.env.DEBUG; } return r; } /** * Localstorage attempts to return the localstorage. * * This is necessary because safari throws * when a user disables cookies/localstorage * and you attempt to access it. * * @return {LocalStorage} * @api private */ function localstorage() { try { // TVMLKit (Apple TV JS Runtime) does not have a window object, just localStorage in the global context // The Browser also has localStorage in the global context. return localStorage; } catch (error) {// Swallow // XXX (@Qix-) should we be logging these? } } module.exports = __webpack_require__(/*! ./common */ "../../node_modules/debug/src/common.js")(exports); var formatters = module.exports.formatters; /** * Map %j to `JSON.stringify()`, since no Web Inspectors do that by default. */ formatters.j = function (v) { try { return JSON.stringify(v); } catch (error) { return '[UnexpectedJSONParseError]: ' + error.message; } }; /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../process/browser.js */ "../../node_modules/process/browser.js"))) /***/ }), /***/ "../../node_modules/debug/src/common.js": /*!*************************************************************************************!*\ !*** /Users/daffl/Development/feathersjs/feathers/node_modules/debug/src/common.js ***! \*************************************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); } function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); } function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } /** * This is the common logic for both the Node.js and web browser * implementations of `debug()`. */ function setup(env) { createDebug.debug = createDebug; createDebug.default = createDebug; createDebug.coerce = coerce; createDebug.disable = disable; createDebug.enable = enable; createDebug.enabled = enabled; createDebug.humanize = __webpack_require__(/*! ms */ "../../node_modules/ms/index.js"); Object.keys(env).forEach(function (key) { createDebug[key] = env[key]; }); /** * Active `debug` instances. */ createDebug.instances = []; /** * The currently active debug mode names, and names to skip. */ createDebug.names = []; createDebug.skips = []; /** * Map of special "%n" handling functions, for the debug "format" argument. * * Valid key names are a single, lower or upper-case letter, i.e. "n" and "N". */ createDebug.formatters = {}; /** * Selects a color for a debug namespace * @param {String} namespace The namespace string for the for the debug instance to be colored * @return {Number|String} An ANSI color code for the given namespace * @api private */ function selectColor(namespace) { var hash = 0; for (var i = 0; i < namespace.length; i++) { hash = (hash << 5) - hash + namespace.charCodeAt(i); hash |= 0; // Convert to 32bit integer } return createDebug.colors[Math.abs(hash) % createDebug.colors.length]; } createDebug.selectColor = selectColor; /** * Create a debugger with the given `namespace`. * * @param {String} namespace * @return {Function} * @api public */ function createDebug(namespace) { var prevTime; function debug() { for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) { args[_key] = arguments[_key]; } // Disabled? if (!debug.enabled) { return; } var self = debug; // Set `diff` timestamp var curr = Number(new Date()); var ms = curr - (prevTime || curr); self.diff = ms; self.prev = prevTime; self.curr = curr; prevTime = curr; args[0] = createDebug.coerce(args[0]); if (typeof args[0] !== 'string') { // Anything else let's inspect with %O args.unshift('%O'); } // Apply any `formatters` transformations var index = 0; args[0] = args[0].replace(/%([a-zA-Z%])/g, function (match, format) { // If we encounter an escaped % then don't increase the array index if (match === '%%') { return match; } index++; var formatter = createDebug.formatters[format]; if (typeof formatter === 'function') { var val = args[index]; match = formatter.call(self, val); // Now we need to remove `args[index]` since it's inlined in the `format` args.splice(index, 1); index--; } return match; }); // Apply env-specific formatting (colors, etc.) createDebug.formatArgs.call(self, args); var logFn = self.log || createDebug.log; logFn.apply(self, args); } debug.namespace = namespace; debug.enabled = createDebug.enabled(namespace); debug.useColors = createDebug.useColors(); debug.color = selectColor(namespace); debug.destroy = destroy; debug.extend = extend; // Debug.formatArgs = formatArgs; // debug.rawLog = rawLog; // env-specific initialization logic for debug instances if (typeof createDebug.init === 'function') { createDebug.init(debug); } createDebug.instances.push(debug); return debug; } function destroy() { var index = createDebug.instances.indexOf(this); if (index !== -1) { createDebug.instances.splice(index, 1); return true; } return false; } function extend(namespace, delimiter) { var newDebug = createDebug(this.namespace + (typeof delimiter === 'undefined' ? ':' : delimiter) + namespace); newDebug.log = this.log; return newDebug; } /** * Enables a debug mode by namespaces. This can include modes * separated by a colon and wildcards. * * @param {String} namespaces * @api public */ function enable(namespaces) { createDebug.save(namespaces); createDebug.names = []; createDebug.skips = []; var i; var split = (typeof namespaces === 'string' ? namespaces : '').split(/[\s,]+/); var len = split.length; for (i = 0; i < len; i++) { if (!split[i]) { // ignore empty strings continue; } namespaces = split[i].replace(/\*/g, '.*?'); if (namespaces[0] === '-') { createDebug.skips.push(new RegExp('^' + namespaces.substr(1) + '$')); } else { createDebug.names.push(new RegExp('^' + namespaces + '$')); } } for (i = 0; i < createDebug.instances.length; i++) { var instance = createDebug.instances[i]; instance.enabled = createDebug.enabled(instance.namespace); } } /** * Disable debug output. * * @return {String} namespaces * @api public */ function disable() { var namespaces = [].concat(_toConsumableArray(createDebug.names.map(toNamespace)), _toConsumableArray(createDebug.skips.map(toNamespace).map(function (namespace) { return '-' + namespace; }))).join(','); createDebug.enable(''); return namespaces; } /** * Returns true if the given mode name is enabled, false otherwise. * * @param {String} name * @return {Boolean} * @api public */ function enabled(name) { if (name[name.length - 1] === '*') { return true; } var i; var len; for (i = 0, len = createDebug.skips.length; i < len; i++) { if (createDebug.skips[i].test(name)) { return false; } } for (i = 0, len = createDebug.names.length; i < len; i++) { if (createDebug.names[i].test(name)) { return true; } } return false; } /** * Convert regexp to namespace * * @param {RegExp} regxep * @return {String} namespace * @api private */ function toNamespace(regexp) { return regexp.toString().substring(2, regexp.toString().length - 2).replace(/\.\*\?$/, '*'); } /** * Coerce `val`. * * @param {Mixed} val * @return {Mixed} * @api private */ function coerce(val) { if (val instanceof Error) { return val.stack || val.message; } return val; } createDebug.enable(createDebug.load()); return createDebug; } module.exports = setup; /***/ }), /***/ "../../node_modules/ms/index.js": /*!*****************************************************************************!*\ !*** /Users/daffl/Development/feathersjs/feathers/node_modules/ms/index.js ***! \*****************************************************************************/ /*! no static exports found */ /***/ (function(module, exports) { /** * Helpers. */ var s = 1000; var m = s * 60; var h = m * 60; var d = h * 24; var w = d * 7; var y = d * 365.25; /** * Parse or format the given `val`. * * Options: * * - `long` verbose formatting [false] * * @param {String|Number} val * @param {Object} [options] * @throws {Error} throw an error if val is not a non-empty string or a number * @return {String|Number} * @api public */ module.exports = function(val, options) { options = options || {}; var type = typeof val; if (type === 'string' && val.length > 0) { return parse(val); } else if (type === 'number' && isFinite(val)) { return options.long ? fmtLong(val) : fmtShort(val); } throw new Error( 'val is not a non-empty string or a valid number. val=' + JSON.stringify(val) ); }; /** * Parse the given `str` and return milliseconds. * * @param {String} str * @return {Number} * @api private */ function parse(str) { str = String(str); if (str.length > 100) { return; } var match = /^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec( str ); if (!match) { return; } var n = parseFloat(match[1]); var type = (match[2] || 'ms').toLowerCase(); switch (type) { case 'years': case 'year': case 'yrs': case 'yr': case 'y': return n * y; case 'weeks': case 'week': case 'w': return n * w; case 'days': case 'day': case 'd': return n * d; case 'hours': case 'hour': case 'hrs': case 'hr': case 'h': return n * h; case 'minutes': case 'minute': case 'mins': case 'min': case 'm': return n * m; case 'seconds': case 'second': case 'secs': case 'sec': case 's': return n * s; case 'milliseconds': case 'millisecond': case 'msecs': case 'msec': case 'ms': return n; default: return undefined; } } /** * Short format for `ms`. * * @param {Number} ms * @return {String} * @api private */ function fmtShort(ms) { var msAbs = Math.abs(ms); if (msAbs >= d) { return Math.round(ms / d) + 'd'; } if (msAbs >= h) { return Math.round(ms / h) + 'h'; } if (msAbs >= m) { return Math.round(ms / m) + 'm'; } if (msAbs >= s) { return Math.round(ms / s) + 's'; } return ms + 'ms'; } /** * Long format for `ms`. * * @param {Number} ms * @return {String} * @api private */ function fmtLong(ms) { var msAbs = Math.abs(ms); if (msAbs >= d) { return plural(ms, msAbs, d, 'day'); } if (msAbs >= h) { return plural(ms, msAbs, h, 'hour'); } if (msAbs >= m) { return plural(ms, msAbs, m, 'minute'); } if (msAbs >= s) { return plural(ms, msAbs, s, 'second'); } return ms + ' ms'; } /** * Pluralization helper. */ function plural(ms, msAbs, n, name) { var isPlural = msAbs >= n * 1.5; return Math.round(ms / n) + ' ' + name + (isPlural ? 's' : ''); } /***/ }), /***/ "../../node_modules/process/browser.js": /*!************************************************************************************!*\ !*** /Users/daffl/Development/feathersjs/feathers/node_modules/process/browser.js ***! \************************************************************************************/ /*! no static exports found */ /***/ (function(module, exports) { // shim for using process in browser var process = module.exports = {}; // cached from whatever global is present so that test runners that stub it // don't break things. But we need to wrap it in a try catch in case it is // wrapped in strict mode code which doesn't define any globals. It's inside a // function because try/catches deoptimize in certain engines. var cachedSetTimeout; var cachedClearTimeout; function defaultSetTimout() { throw new Error('setTimeout has not been defined'); } function defaultClearTimeout () { throw new Error('clearTimeout has not been defined'); } (function () { try { if (typeof setTimeout === 'function') { cachedSetTimeout = setTimeout; } else { cachedSetTimeout = defaultSetTimout; } } catch (e) { cachedSetTimeout = defaultSetTimout; } try { if (typeof clearTimeout === 'function') { cachedClearTimeout = clearTimeout; } else { cachedClearTimeout = defaultClearTimeout; } } catch (e) { cachedClearTimeout = defaultClearTimeout; } } ()) function runTimeout(fun) { if (cachedSetTimeout === setTimeout) { //normal enviroments in sane situations return setTimeout(fun, 0); } // if setTimeout wasn't available but was latter defined if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) { cachedSetTimeout = setTimeout; return setTimeout(fun, 0); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedSetTimeout(fun, 0); } catch(e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedSetTimeout.call(null, fun, 0); } catch(e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error return cachedSetTimeout.call(this, fun, 0); } } } function runClearTimeout(marker) { if (cachedClearTimeout === clearTimeout) { //normal enviroments in sane situations return clearTimeout(marker); } // if clearTimeout wasn't available but was latter defined if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) { cachedClearTimeout = clearTimeout; return clearTimeout(marker); } try { // when when somebody has screwed with setTimeout but no I.E. maddness return cachedClearTimeout(marker); } catch (e){ try { // When we are in I.E. but the script has been evaled so I.E. doesn't trust the global object when called normally return cachedClearTimeout.call(null, marker); } catch (e){ // same as above but when it's a version of I.E. that must have the global object for 'this', hopfully our context correct otherwise it will throw a global error. // Some versions of I.E. have different rules for clearTimeout vs setTimeout return cachedClearTimeout.call(this, marker); } } } var queue = []; var draining = false; var currentQueue; var queueIndex = -1; function cleanUpNextTick() { if (!draining || !currentQueue) { return; } draining = false; if (currentQueue.length) { queue = currentQueue.concat(queue); } else { queueIndex = -1; } if (queue.length) { drainQueue(); } } function drainQueue() { if (draining) { return; } var timeout = runTimeout(cleanUpNextTick); draining = true; var len = queue.length; while(len) { currentQueue = queue; queue = []; while (++queueIndex < len) { if (currentQueue) { currentQueue[queueIndex].run(); } } queueIndex = -1; len = queue.length; } currentQueue = null; draining = false; runClearTimeout(timeout); } process.nextTick = function (fun) { var args = new Array(arguments.length - 1); if (arguments.length > 1) { for (var i = 1; i < arguments.length; i++) { args[i - 1] = arguments[i]; } } queue.push(new Item(fun, args)); if (queue.length === 1 && !draining) { runTimeout(drainQueue); } }; // v8 likes predictible objects function Item(fun, array) { this.fun = fun; this.array = array; } Item.prototype.run = function () { this.fun.apply(null, this.array); }; process.title = 'browser'; process.browser = true; process.env = {}; process.argv = []; process.version = ''; // empty string to avoid regexp issues process.versions = {}; function noop() {} process.on = noop; process.addListener = noop; process.once = noop; process.off = noop; process.removeListener = noop; process.removeAllListeners = noop; process.emit = noop; process.prependListener = noop; process.prependOnceListener = noop; process.listeners = function (name) { return [] } process.binding = function (name) { throw new Error('process.binding is not supported'); }; process.cwd = function () { return '/' }; process.chdir = function (dir) { throw new Error('process.chdir is not supported'); }; process.umask = function() { return 0; }; /***/ }), /***/ "../authentication-client/lib/core.js": /*!********************************************!*\ !*** ../authentication-client/lib/core.js ***! \********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); } function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); } function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; } function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; } function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; } Object.defineProperty(exports, "__esModule", { value: true }); exports.AuthenticationClient = void 0; var errors_1 = __webpack_require__(/*! @feathersjs/errors */ "../errors/lib/index.js"); var storage_1 = __webpack_require__(/*! ./storage */ "../authentication-client/lib/storage.js"); var getMatch = function getMatch(location, key) { var regex = new RegExp("(?:&?)".concat(key, "=([^&]*)")); var match = location.hash ? location.hash.match(regex) : null; if (match !== null) { var _match = _slicedToArray(match, 2), value = _match[1]; return [value, regex]; } return [null, regex]; }; var AuthenticationClient = /*#__PURE__*/function () { function AuthenticationClient(app, options) { _classCallCheck(this, AuthenticationClient); var socket = app.io || app.primus; var storage = new storage_1.StorageWrapper(app.get('storage') || options.storage); this.app = app; this.options = options; this.authenticated = false; this.app.set('storage', storage); if (socket) { this.handleSocket(socket); } } _createClass(AuthenticationClient, [{ key: "handleSocket", value: function handleSocket(socket) { var _this = this; // Connection events happen on every reconnect var connected = this.app.io ? 'connect' : 'open'; var disconnected = this.app.io ? 'disconnect' : 'disconnection'; socket.on(disconnected, function () { var authPromise = new Promise(function (resolve) { return socket.once(connected, function () { return resolve(); }); }) // Only reconnect when `reAuthenticate()` or `authenticate()` // has been called explicitly first // Force reauthentication with the server .then(function () { return _this.authenticated ? _this.reAuthenticate(true) : null; }); _this.app.set('authentication', authPromise); }); } }, { key: "getFromLocation", value: function getFromLocation(location) { var _getMatch = getMatch(location, this.options.locationKey), _getMatch2 = _slicedToArray(_getMatch, 2), accessToken = _getMatch2[0], tokenRegex = _getMatch2[1]; if (accessToken !== null) { location.hash = location.hash.replace(tokenRegex, ''); return Promise.resolve(accessToken); } var _getMatch3 = getMatch(location, this.options.locationErrorKey), _getMatch4 = _slicedToArray(_getMatch3, 2), message = _getMatch4[0], errorRegex = _getMatch4[1]; if (message !== null) { location.hash = location.hash.replace(errorRegex, ''); return Promise.reject(new errors_1.NotAuthenticated(decodeURIComponent(message))); } return Promise.resolve(null); } }, { key: "setAccessToken", value: function setAccessToken(accessToken) { return this.storage.setItem(this.options.storageKey, accessToken); } }, { key: "getAccessToken", value: function getAccessToken() { var _this2 = this; return this.storage.getItem(this.options.storageKey).then(function (accessToken) { if (!accessToken && typeof window !== 'undefined' && window.location) { return _this2.getFromLocation(window.location); } return accessToken || null; }); } }, { key: "removeAccessToken", value: function removeAccessToken() { return this.storage.removeItem(this.options.storageKey); } }, { key: "reset", value: function reset() { this.app.set('authentication', null); this.authenticated = false; return Promise.resolve(null); } }, { key: "handleError", value: function handleError(error, type) { var _this3 = this; if (error.code === 401 || error.code === 403) { var promise = this.removeAccessToken().then(function () { return _this3.reset(); }); return type === 'logout' ? promise : promise.then(function () { return Promise.reject(error); }); } return Promise.reject(error); } }, { key: "reAuthenticate", value: function reAuthenticate() { var _this4 = this; var force = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false; // Either returns the authentication state or // tries to re-authenticate with the stored JWT and strategy var authPromise = this.app.get('authentication'); if (!authPromise || force === true) { return this.getAccessToken().then(function (accessToken) { if (!accessToken) { throw new errors_1.NotAuthenticated('No accessToken found in storage'); } return _this4.authenticate({ strategy: _this4.options.jwtStrategy, accessToken: accessToken }); }); } return authPromise; } }, { key: "authenticate", value: function authenticate(authentication, params) { var _this5 = this; if (!authentication) { return this.reAuthenticate(); } var promise = this.service.create(authentication, params).then(function (authResult) { var accessToken = authResult.accessToken; _this5.authenticated = true; _this5.app.emit('login', authResult); _this5.app.emit('authenticated', authResult); return _this5.setAccessToken(accessToken).then(function () { return authResult; }); }).catch(function (error) { return _this5.handleError(error, 'authenticate'); }); this.app.set('authentication', promise); return promise; } }, { key: "logout", value: function logout() { var _this6 = this; return Promise.resolve(this.app.get('authentication')).then(function () { return _this6.service.remove(null).then(function (authResult) { return _this6.removeAccessToken().then(function () { return _this6.reset(); }).then(function () { _this6.app.emit('logout', authResult); return authResult; }); }); }).catch(function (error) { return _this6.handleError(error, 'logout'); }); } }, { key: "service", get: function get() { return this.app.service(this.options.path); } }, { key: "storage", get: function get() { return this.app.get('storage'); } }]); return AuthenticationClient; }(); exports.AuthenticationClient = AuthenticationClient; /***/ }), /***/ "../authentication-client/lib/hooks/authentication.js": /*!************************************************************!*\ !*** ../authentication-client/lib/hooks/authentication.js ***! \************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.authentication = void 0; var commons_1 = __webpack_require__(/*! @feathersjs/commons */ "../commons/lib/index.js"); exports.authentication = function () { return function (context) { var app = context.app, params = context.params, path = context.path, method = context.method, service = context.app.authentication; if (commons_1.stripSlashes(service.options.path) === path && method === 'create') { return context; } return Promise.resolve(app.get('authentication')).then(function (authResult) { if (authResult) { context.params = Object.assign({}, authResult, params); } return context; }); }; }; /***/ }), /***/ "../authentication-client/lib/hooks/index.js": /*!***************************************************!*\ !*** ../authentication-client/lib/hooks/index.js ***! \***************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var authentication_1 = __webpack_require__(/*! ./authentication */ "../authentication-client/lib/hooks/authentication.js"); Object.defineProperty(exports, "authentication", { enumerable: true, get: function get() { return authentication_1.authentication; } }); var populate_header_1 = __webpack_require__(/*! ./populate-header */ "../authentication-client/lib/hooks/populate-header.js"); Object.defineProperty(exports, "populateHeader", { enumerable: true, get: function get() { return populate_header_1.populateHeader; } }); /***/ }), /***/ "../authentication-client/lib/hooks/populate-header.js": /*!*************************************************************!*\ !*** ../authentication-client/lib/hooks/populate-header.js ***! \*************************************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } Object.defineProperty(exports, "__esModule", { value: true }); exports.populateHeader = void 0; exports.populateHeader = function () { return function (context) { var app = context.app, accessToken = context.params.accessToken; var authentication = app.authentication; // Set REST header if necessary if (app.rest && accessToken) { var _authentication$optio = authentication.options, scheme = _authentication$optio.scheme, header = _authentication$optio.header; var authHeader = "".concat(scheme, " ").concat(accessToken); context.params.headers = Object.assign({}, _defineProperty({}, header, authHeader), context.params.headers); } return context; }; }; /***/ }), /***/ "../authentication-client/lib/index.js": /*!*********************************************!*\ !*** ../authentication-client/lib/index.js ***! \*********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; var __createBinding = this && this.__createBinding || (Object.create ? function (o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function get() { return m[k]; } }); } : function (o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; }); var __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function (o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); } : function (o, v) { o["default"] = v; }); var __importStar = this && this.__importStar || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) { if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); } __setModuleDefault(result, mod); return result; }; Object.defineProperty(exports, "__esModule", { value: true }); exports.defaults = exports.defaultStorage = exports.hooks = exports.MemoryStorage = exports.AuthenticationClient = exports.getDefaultStorage = void 0; var core_1 = __webpack_require__(/*! ./core */ "../authentication-client/lib/core.js"); Object.defineProperty(exports, "AuthenticationClient", { enumerable: true, get: function get() { return core_1.AuthenticationClient; } }); var hooks = __importStar(__webpack_require__(/*! ./hooks */ "../authentication-client/lib/hooks/index.js")); exports.hooks = hooks; var storage_1 = __webpack_require__(/*! ./storage */ "../authentication-client/lib/storage.js"); Object.defineProperty(exports, "MemoryStorage", { enumerable: true, get: function get() { return storage_1.MemoryStorage; } }); exports.getDefaultStorage = function () { try { return new storage_1.StorageWrapper(window.localStorage); } catch (error) {} return new storage_1.MemoryStorage(); }; exports.defaultStorage = exports.getDefaultStorage(); exports.defaults = { header: 'Authorization', scheme: 'Bearer', storageKey: 'feathers-jwt', locationKey: 'access_token', locationErrorKey: 'error', jwtStrategy: 'jwt', path: '/authentication', Authentication: core_1.AuthenticationClient, storage: exports.defaultStorage }; var init = function init() { var _options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {}; var options = Object.assign({}, exports.defaults, _options); var Authentication = options.Authentication; return function (app) { var authentication = new Authentication(app, options); app.authentication = authentication; app.authenticate = authentication.authenticate.bind(authentication); app.reAuthenticate = authentication.reAuthenticate.bind(authentication); app.logout = authentication.logout.bind(authentication); app.hooks({ before: { all: [hooks.authentication(), hooks.populateHeader()] } }); }; }; exports.default = init; if (true) { module.exports = Object.assign(init, module.exports); } /***/ }), /***/ "../authentication-client/lib/storage.js": /*!***********************************************!*\ !*** ../authentication-client/lib/storage.js ***! \***********************************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } Object.defineProperty(exports, "__esModule", { value: true }); exports.StorageWrapper = exports.MemoryStorage = void 0; var MemoryStorage = /*#__PURE__*/function () { function MemoryStorage() { _classCallCheck(this, MemoryStorage); this.store = {}; } _createClass(MemoryStorage, [{ key: "getItem", value: function getItem(key) { return Promise.resolve(this.store[key]); } }, { key: "setItem", value: function setItem(key, value) { return Promise.resolve(this.store[key] = value); } }, { key: "removeItem", value: function removeItem(key) { var value = this.store[key]; delete this.store[key]; return Promise.resolve(value); } }]); return MemoryStorage; }(); exports.MemoryStorage = MemoryStorage; var StorageWrapper = /*#__PURE__*/function () { function StorageWrapper(storage) { _classCallCheck(this, StorageWrapper); this.storage = storage; } _createClass(StorageWrapper, [{ key: "getItem", value: function getItem(key) { return Promise.resolve(this.storage.getItem(key)); } }, { key: "setItem", value: function setItem(key, value) { return Promise.resolve(this.storage.setItem(key, value)); } }, { key: "removeItem", value: function removeItem(key) { return Promise.resolve(this.storage.removeItem(key)); } }]); return StorageWrapper; }(); exports.StorageWrapper = StorageWrapper; /***/ }), /***/ "../commons/lib/hooks.js": /*!*******************************!*\ !*** ../commons/lib/hooks.js ***! \*******************************/ /*! no static exports found */ /***/ (function(module, exports, __webpack_require__) { "use strict"; function _typeof(obj) { "@babel/helpers - typeof"; 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); } Object.defineProperty(exports, "__esModule", { value: true }); exports.enableHooks = exports.processHooks = exports.getHooks = exports.isHookObject = exports.convertHookData = exports.makeArguments = exports.defaultMakeArguments = exports.createHookObject = exports.ACTIVATE_HOOKS = void 0; var utils_1 = __webpack_require__(/*! ./utils */ "../commons/lib/utils.js"); var _utils_1$_ = utils_1._, each = _utils_1$_.each, pick = _utils_1$_.pick; exports.ACTIVATE_HOOKS = utils_1.createSymbol('__feathersActivateHooks'); function createHookObject(method) { var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {}; var hook = {}; Object.defineProperty(hook, 'toJSON', { value: function value() { return pick(this, 'type', 'method', 'path', 'params', 'id', 'data', 'result', 'error'); } }); return Object.assign(hook, data, { method: method, // A dynamic getter that returns the path of the service get path() { var app = data.app, service = data.service; if (!service || !app || !app.services) { return null; } return Object.keys(app.services).find(function (path) { return app.services[path] === service; }); } }); } exports.createHookObject = createHookObject; // Fallback used by `makeArguments` which usually won't be used function defaultMakeArguments(hook) { var result = []; if (typeof hook.id !== 'undefined') { result.push(hook.id); } if (hook.data) { result.push(hook.data); } result.push(hook.params || {}); return result; } exports.defaultMakeArguments = defaultMakeArguments; // Turns a hook object back into a list of arguments // to call a service method with function makeArguments(hook) { switch (hook.method) { case 'find': return [hook.params]; case 'get': case 'remove': return [hook.id, hook.params]; case 'update': case 'patch': return [hook.id, hook.data, hook.params]; case 'create': return [hook.data, hook.params]; } return defaultMakeArguments(hook); } exports.makeArguments = makeArguments; // Converts different hook registration formats into the // same internal format function convertHookData(obj) { var hook = {}; if (Array.isArray(obj)) { hook = { all: obj }; } else if (_typeof(obj) !== 'object') { hook = { all: [obj] }; } else { each(obj, function (value, key) { hook[key] = !Array.isArray(value) ? [value] : value; }); } return hook; } exports.convertHookData = convertHookData; // Duck-checks a given object to be a hook object // A valid hook object has `type` and `method` function isHookObject(hookObject) { return _typeof(hookObject) ===