Skip to content
Snippets Groups Projects
index.js 8.75 MiB
Newer Older
  • Learn to ignore specific revisions
  • /***/ }),
    /* 1712 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var rng = __webpack_require__(262);
    var bytesToUuid = __webpack_require__(263);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    // **`v1()` - Generate time-based UUID**
    //
    // Inspired by https://github.com/LiosK/UUID.js
    // and http://docs.python.org/library/uuid.html
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var _nodeId;
    var _clockseq;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    // Previous uuid creation time
    var _lastMSecs = 0;
    var _lastNSecs = 0;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    // See https://github.com/broofa/node-uuid for API details
    function v1(options, buf, offset) {
      var i = buf && offset || 0;
      var b = buf || [];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      options = options || {};
      var node = options.node || _nodeId;
      var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // node and clockseq need to be initialized to random values if they're not
      // specified.  We do this lazily to minimize issues related to insufficient
      // system entropy.  See #189
      if (node == null || clockseq == null) {
        var seedBytes = rng();
        if (node == null) {
          // Per 4.5, create and 48-bit node id, (47 random bits + multicast bit = 1)
          node = _nodeId = [
            seedBytes[0] | 0x01,
            seedBytes[1], seedBytes[2], seedBytes[3], seedBytes[4], seedBytes[5]
          ];
        }
        if (clockseq == null) {
          // Per 4.2.2, randomize (14 bit) clockseq
          clockseq = _clockseq = (seedBytes[6] << 8 | seedBytes[7]) & 0x3fff;
        }
      }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // UUID timestamps are 100 nano-second units since the Gregorian epoch,
      // (1582-10-15 00:00).  JSNumbers aren't precise enough for this, so
      // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
      // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
      var msecs = options.msecs !== undefined ? options.msecs : new Date().getTime();
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // Per 4.2.1.2, use count of uuid's generated during the current clock
      // cycle to simulate higher resolution clock
      var nsecs = options.nsecs !== undefined ? options.nsecs : _lastNSecs + 1;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // Time since last uuid creation (in msecs)
      var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // Per 4.2.1.2, Bump clockseq on clock regression
      if (dt < 0 && options.clockseq === undefined) {
        clockseq = clockseq + 1 & 0x3fff;
    
    Romain CREY's avatar
    Romain CREY committed
      }
    
    
      // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
      // time interval
      if ((dt < 0 || msecs > _lastMSecs) && options.nsecs === undefined) {
        nsecs = 0;
      }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // Per 4.2.1.2 Throw error if too many uuids are requested
      if (nsecs >= 10000) {
        throw new Error('uuid.v1(): Can\'t create more than 10M uuids/sec');
    
    Romain CREY's avatar
    Romain CREY committed
      }
    
    
      _lastMSecs = msecs;
      _lastNSecs = nsecs;
      _clockseq = clockseq;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
      msecs += 12219292800000;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // `time_low`
      var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
      b[i++] = tl >>> 24 & 0xff;
      b[i++] = tl >>> 16 & 0xff;
      b[i++] = tl >>> 8 & 0xff;
      b[i++] = tl & 0xff;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // `time_mid`
      var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
      b[i++] = tmh >>> 8 & 0xff;
      b[i++] = tmh & 0xff;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // `time_high_and_version`
      b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
      b[i++] = tmh >>> 16 & 0xff;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
      b[i++] = clockseq >>> 8 | 0x80;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // `clock_seq_low`
      b[i++] = clockseq & 0xff;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // `node`
      for (var n = 0; n < 6; ++n) {
        b[i + n] = node[n];
    
    Romain CREY's avatar
    Romain CREY committed
      }
    
    
      return buf ? buf : bytesToUuid(b);
    
    Romain CREY's avatar
    Romain CREY committed
    }
    
    
    module.exports = v1;
    
    /***/ }),
    /* 1713 */
    /***/ (function(module, exports) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = require("domain");
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    /* 1714 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    (function(){
      var crypt = __webpack_require__(1715),
          utf8 = __webpack_require__(1716).utf8,
          isBuffer = __webpack_require__(1717),
          bin = __webpack_require__(1716).bin,
    
      // The core
      md5 = function (message, options) {
        // Convert to byte array
        if (message.constructor == String)
          if (options && options.encoding === 'binary')
            message = bin.stringToBytes(message);
          else
            message = utf8.stringToBytes(message);
        else if (isBuffer(message))
          message = Array.prototype.slice.call(message, 0);
        else if (!Array.isArray(message))
          message = message.toString();
        // else, assume byte array already
    
        var m = crypt.bytesToWords(message),
            l = message.length * 8,
            a =  1732584193,
            b = -271733879,
            c = -1732584194,
            d =  271733878;
    
        // Swap endian
        for (var i = 0; i < m.length; i++) {
          m[i] = ((m[i] <<  8) | (m[i] >>> 24)) & 0x00FF00FF |
                 ((m[i] << 24) | (m[i] >>>  8)) & 0xFF00FF00;
        }
    
        // Padding
        m[l >>> 5] |= 0x80 << (l % 32);
        m[(((l + 64) >>> 9) << 4) + 14] = l;
    
        // Method shortcuts
        var FF = md5._ff,
            GG = md5._gg,
            HH = md5._hh,
            II = md5._ii;
    
        for (var i = 0; i < m.length; i += 16) {
    
          var aa = a,
              bb = b,
              cc = c,
              dd = d;
    
          a = FF(a, b, c, d, m[i+ 0],  7, -680876936);
          d = FF(d, a, b, c, m[i+ 1], 12, -389564586);
          c = FF(c, d, a, b, m[i+ 2], 17,  606105819);
          b = FF(b, c, d, a, m[i+ 3], 22, -1044525330);
          a = FF(a, b, c, d, m[i+ 4],  7, -176418897);
          d = FF(d, a, b, c, m[i+ 5], 12,  1200080426);
          c = FF(c, d, a, b, m[i+ 6], 17, -1473231341);
          b = FF(b, c, d, a, m[i+ 7], 22, -45705983);
          a = FF(a, b, c, d, m[i+ 8],  7,  1770035416);
          d = FF(d, a, b, c, m[i+ 9], 12, -1958414417);
          c = FF(c, d, a, b, m[i+10], 17, -42063);
          b = FF(b, c, d, a, m[i+11], 22, -1990404162);
          a = FF(a, b, c, d, m[i+12],  7,  1804603682);
          d = FF(d, a, b, c, m[i+13], 12, -40341101);
          c = FF(c, d, a, b, m[i+14], 17, -1502002290);
          b = FF(b, c, d, a, m[i+15], 22,  1236535329);
    
          a = GG(a, b, c, d, m[i+ 1],  5, -165796510);
          d = GG(d, a, b, c, m[i+ 6],  9, -1069501632);
          c = GG(c, d, a, b, m[i+11], 14,  643717713);
          b = GG(b, c, d, a, m[i+ 0], 20, -373897302);
          a = GG(a, b, c, d, m[i+ 5],  5, -701558691);
          d = GG(d, a, b, c, m[i+10],  9,  38016083);
          c = GG(c, d, a, b, m[i+15], 14, -660478335);
          b = GG(b, c, d, a, m[i+ 4], 20, -405537848);
          a = GG(a, b, c, d, m[i+ 9],  5,  568446438);
          d = GG(d, a, b, c, m[i+14],  9, -1019803690);
          c = GG(c, d, a, b, m[i+ 3], 14, -187363961);
          b = GG(b, c, d, a, m[i+ 8], 20,  1163531501);
          a = GG(a, b, c, d, m[i+13],  5, -1444681467);
          d = GG(d, a, b, c, m[i+ 2],  9, -51403784);
          c = GG(c, d, a, b, m[i+ 7], 14,  1735328473);
          b = GG(b, c, d, a, m[i+12], 20, -1926607734);
    
          a = HH(a, b, c, d, m[i+ 5],  4, -378558);
          d = HH(d, a, b, c, m[i+ 8], 11, -2022574463);
          c = HH(c, d, a, b, m[i+11], 16,  1839030562);
          b = HH(b, c, d, a, m[i+14], 23, -35309556);
          a = HH(a, b, c, d, m[i+ 1],  4, -1530992060);
          d = HH(d, a, b, c, m[i+ 4], 11,  1272893353);
          c = HH(c, d, a, b, m[i+ 7], 16, -155497632);
          b = HH(b, c, d, a, m[i+10], 23, -1094730640);
          a = HH(a, b, c, d, m[i+13],  4,  681279174);
          d = HH(d, a, b, c, m[i+ 0], 11, -358537222);
          c = HH(c, d, a, b, m[i+ 3], 16, -722521979);
          b = HH(b, c, d, a, m[i+ 6], 23,  76029189);
          a = HH(a, b, c, d, m[i+ 9],  4, -640364487);
          d = HH(d, a, b, c, m[i+12], 11, -421815835);
          c = HH(c, d, a, b, m[i+15], 16,  530742520);
          b = HH(b, c, d, a, m[i+ 2], 23, -995338651);
    
          a = II(a, b, c, d, m[i+ 0],  6, -198630844);
          d = II(d, a, b, c, m[i+ 7], 10,  1126891415);
          c = II(c, d, a, b, m[i+14], 15, -1416354905);
          b = II(b, c, d, a, m[i+ 5], 21, -57434055);
          a = II(a, b, c, d, m[i+12],  6,  1700485571);
          d = II(d, a, b, c, m[i+ 3], 10, -1894986606);
          c = II(c, d, a, b, m[i+10], 15, -1051523);
          b = II(b, c, d, a, m[i+ 1], 21, -2054922799);
          a = II(a, b, c, d, m[i+ 8],  6,  1873313359);
          d = II(d, a, b, c, m[i+15], 10, -30611744);
          c = II(c, d, a, b, m[i+ 6], 15, -1560198380);
          b = II(b, c, d, a, m[i+13], 21,  1309151649);
          a = II(a, b, c, d, m[i+ 4],  6, -145523070);
          d = II(d, a, b, c, m[i+11], 10, -1120210379);
          c = II(c, d, a, b, m[i+ 2], 15,  718787259);
          b = II(b, c, d, a, m[i+ 9], 21, -343485551);
    
          a = (a + aa) >>> 0;
          b = (b + bb) >>> 0;
          c = (c + cc) >>> 0;
          d = (d + dd) >>> 0;
        }
    
        return crypt.endian([a, b, c, d]);
      };
    
      // Auxiliary functions
      md5._ff  = function (a, b, c, d, x, s, t) {
        var n = a + (b & c | ~b & d) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
      };
      md5._gg  = function (a, b, c, d, x, s, t) {
        var n = a + (b & d | c & ~d) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
      };
      md5._hh  = function (a, b, c, d, x, s, t) {
        var n = a + (b ^ c ^ d) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
      };
      md5._ii  = function (a, b, c, d, x, s, t) {
        var n = a + (c ^ (b | ~d)) + (x >>> 0) + t;
        return ((n << s) | (n >>> (32 - s))) + b;
      };
    
      // Package private blocksize
      md5._blocksize = 16;
      md5._digestsize = 16;
    
      module.exports = function (message, options) {
        if (message === undefined || message === null)
          throw new Error('Illegal argument ' + message);
    
        var digestbytes = crypt.wordsToBytes(md5(message, options));
        return options && options.asBytes ? digestbytes :
            options && options.asString ? bin.bytesToString(digestbytes) :
            crypt.bytesToHex(digestbytes);
      };
    
    })();
    
    /***/ }),
    /* 1715 */
    /***/ (function(module, exports) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    (function() {
      var base64map
          = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      crypt = {
        // Bit-wise rotation left
        rotl: function(n, b) {
          return (n << b) | (n >>> (32 - b));
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Bit-wise rotation right
        rotr: function(n, b) {
          return (n << (32 - b)) | (n >>> b);
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Swap big-endian to little-endian and vice versa
        endian: function(n) {
          // If number given, swap endian
          if (n.constructor == Number) {
            return crypt.rotl(n, 8) & 0x00FF00FF | crypt.rotl(n, 24) & 0xFF00FF00;
          }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
          // Else, assume array and swap all items
          for (var i = 0; i < n.length; i++)
            n[i] = crypt.endian(n[i]);
          return n;
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Generate an array of any length of random bytes
        randomBytes: function(n) {
          for (var bytes = []; n > 0; n--)
            bytes.push(Math.floor(Math.random() * 256));
          return bytes;
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Convert a byte array to big-endian 32-bit words
        bytesToWords: function(bytes) {
          for (var words = [], i = 0, b = 0; i < bytes.length; i++, b += 8)
            words[b >>> 5] |= bytes[i] << (24 - b % 32);
          return words;
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Convert big-endian 32-bit words to a byte array
        wordsToBytes: function(words) {
          for (var bytes = [], b = 0; b < words.length * 32; b += 8)
            bytes.push((words[b >>> 5] >>> (24 - b % 32)) & 0xFF);
          return bytes;
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Convert a byte array to a hex string
        bytesToHex: function(bytes) {
          for (var hex = [], i = 0; i < bytes.length; i++) {
            hex.push((bytes[i] >>> 4).toString(16));
            hex.push((bytes[i] & 0xF).toString(16));
          }
          return hex.join('');
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Convert a hex string to a byte array
        hexToBytes: function(hex) {
          for (var bytes = [], c = 0; c < hex.length; c += 2)
            bytes.push(parseInt(hex.substr(c, 2), 16));
          return bytes;
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Convert a byte array to a base-64 string
        bytesToBase64: function(bytes) {
          for (var base64 = [], i = 0; i < bytes.length; i += 3) {
            var triplet = (bytes[i] << 16) | (bytes[i + 1] << 8) | bytes[i + 2];
            for (var j = 0; j < 4; j++)
              if (i * 8 + j * 6 <= bytes.length * 8)
                base64.push(base64map.charAt((triplet >>> 6 * (3 - j)) & 0x3F));
              else
                base64.push('=');
          }
          return base64.join('');
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Convert a base-64 string to a byte array
        base64ToBytes: function(base64) {
          // Remove non-base-64 characters
          base64 = base64.replace(/[^A-Z0-9+\/]/ig, '');
    
    Romain CREY's avatar
    Romain CREY committed
    
    
          for (var bytes = [], i = 0, imod4 = 0; i < base64.length;
              imod4 = ++i % 4) {
            if (imod4 == 0) continue;
            bytes.push(((base64map.indexOf(base64.charAt(i - 1))
                & (Math.pow(2, -2 * imod4 + 8) - 1)) << (imod4 * 2))
                | (base64map.indexOf(base64.charAt(i)) >>> (6 - imod4 * 2)));
          }
          return bytes;
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      module.exports = crypt;
    })();
    
    /***/ }),
    /* 1716 */
    /***/ (function(module, exports) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var charenc = {
      // UTF-8 encoding
      utf8: {
        // Convert a string to a byte array
        stringToBytes: function(str) {
          return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Convert a byte array to a string
        bytesToString: function(bytes) {
          return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // Binary encoding
      bin: {
        // Convert a string to a byte array
        stringToBytes: function(str) {
          for (var bytes = [], i = 0; i < str.length; i++)
            bytes.push(str.charCodeAt(i) & 0xFF);
          return bytes;
        },
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // Convert a byte array to a string
        bytesToString: function(bytes) {
          for (var str = [], i = 0; i < bytes.length; i++)
            str.push(String.fromCharCode(bytes[i]));
          return str.join('');
        }
    
    Romain CREY's avatar
    Romain CREY committed
      }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = charenc;
    
    /***/ }),
    /* 1717 */
    /***/ (function(module, exports) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /*!
     * Determine if an object is a Buffer
     *
     * @author   Feross Aboukhadijeh <https://feross.org>
     * @license  MIT
     */
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    // The _isBuffer check is for Safari 5-7 support, because it's missing
    // Object.prototype.constructor. Remove this eventually
    module.exports = function (obj) {
      return obj != null && (isBuffer(obj) || isSlowBuffer(obj) || !!obj._isBuffer)
    }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function isBuffer (obj) {
      return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
    
    Romain CREY's avatar
    Romain CREY committed
    }
    
    
    // For Node v0.10 support. Remove this eventually.
    function isSlowBuffer (obj) {
      return typeof obj.readFloatLE === 'function' && typeof obj.slice === 'function' && isBuffer(obj.slice(0, 0))
    }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    "use strict";
    
    
    
    var utils = __webpack_require__(1705);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var defaultOnConfig = {
      console: true,
      http: true
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var defaultConfig = {
      console: false,
      http: false,
      pg: false
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    function instrument(Raven, config) {
      if (config === false) {
        return;
      } else if (config === true) {
        config = defaultOnConfig;
      } else {
        config = utils.extend({}, defaultConfig, config);
    
    Romain CREY's avatar
    Romain CREY committed
      }
    
    
      Raven.instrumentedOriginals = [];
      Raven.instrumentedModules = [];
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      var Module = __webpack_require__(1719);
      utils.fill(
        Module,
        '_load',
        function(origLoad) {
          return function(moduleId, parent, isMain) {
            var origModule = origLoad.apply(this, arguments);
            if (config[moduleId] && Raven.instrumentedModules.indexOf(moduleId) === -1) {
              Raven.instrumentedModules.push(moduleId);
              return __webpack_require__(1720)("./" + moduleId)(Raven, origModule, Raven.instrumentedOriginals);
    
    Romain CREY's avatar
    Romain CREY committed
            }
    
            return origModule;
          };
        },
        Raven.instrumentedOriginals
      );
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // special case: since console is built-in and app-level code won't require() it, do that here
      if (config.console) {
        __webpack_require__(1724);
    
    Romain CREY's avatar
    Romain CREY committed
      }
    
    
      // observation: when the https module does its own require('http'), it *does not* hit our hooked require to instrument http on the fly
      // but if we've previously instrumented http, https *does* get our already-instrumented version
      // this is because raven's transports are required before this instrumentation takes place, which loads https (and http)
      // so module cache will have uninstrumented http; proactively loading it here ensures instrumented version is in module cache
      // alternatively we could refactor to load our transports later, but this is easier and doesn't have much drawback
      if (config.http) {
        __webpack_require__(97);
    
    function deinstrument(Raven) {
      if (!Raven.instrumentedOriginals) return;
      var original;
      // eslint-disable-next-line no-cond-assign
      while ((original = Raven.instrumentedOriginals.shift())) {
        var obj = original[0];
        var name = original[1];
        var orig = original[2];
        obj[name] = orig;
    
    module.exports = {
      instrument: instrument,
      deinstrument: deinstrument
    };
    
    /***/ }),
    /* 1719 */
    /***/ (function(module, exports) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = require("module");
    
    Romain CREY's avatar
    Romain CREY committed
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    
    var map = {
    	"./console": 1721,
    	"./console.js": 1721,
    	"./http": 1722,
    	"./http.js": 1722,
    	"./instrumentor": 1718,
    	"./instrumentor.js": 1718,
    	"./pg": 1723,
    	"./pg.js": 1723
    };
    
    function webpackContext(req) {
    	var id = webpackContextResolve(req);
    	return __webpack_require__(id);
    }
    function webpackContextResolve(req) {
    	if(!__webpack_require__.o(map, req)) {
    		var e = new Error("Cannot find module '" + req + "'");
    		e.code = 'MODULE_NOT_FOUND';
    		throw e;
    	}
    	return map[req];
    }
    webpackContext.keys = function webpackContextKeys() {
    	return Object.keys(map);
    };
    webpackContext.resolve = webpackContextResolve;
    module.exports = webpackContext;
    webpackContext.id = 1720;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    /* 1721 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var util = __webpack_require__(9);
    var utils = __webpack_require__(1705);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = function(Raven, console, originals) {
      var wrapConsoleMethod = function(level) {
        if (!(level in console)) {
          return;
        }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        utils.fill(
          console,
          level,
          function(originalConsoleLevel) {
            var sentryLevel = level === 'warn' ? 'warning' : level;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
            return function() {
              var args = [].slice.call(arguments);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
              Raven.captureBreadcrumb({
                message: util.format.apply(null, args),
                level: sentryLevel,
                category: 'console'
              });
    
    Romain CREY's avatar
    Romain CREY committed
    
    
              originalConsoleLevel.apply(console, args);
            };
          },
          originals
        );
      };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      ['debug', 'info', 'warn', 'error', 'log'].forEach(wrapConsoleMethod);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    /* 1722 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    var util = __webpack_require__(9);
    var utils = __webpack_require__(1705);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = function(Raven, http, originals) {
      var OrigClientRequest = http.ClientRequest;
      var ClientRequest = function(options, cb) {
        // Note: this won't capture a breadcrumb if a response never comes
        // It would be useful to know if that was the case, though, so
        // todo: revisit to see if we can capture sth indicating response never came
        // possibility: capture one breadcrumb for "req sent" and one for "res recvd"
        // seems excessive but solves the problem and *is* strictly more information
        // could be useful for weird response sequencing bug scenarios
        OrigClientRequest.call(this, options, cb);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        // We could just always reconstruct this from this.agent, this._headers, this.path, etc
        // but certain other http-instrumenting libraries (like nock, which we use for tests) fail to
        // maintain the guarantee that after calling OrigClientRequest, those fields will be populated
        if (typeof options === 'string') {
          this.__ravenBreadcrumbUrl = options;
    
    Romain CREY's avatar
    Romain CREY committed
        } else {
    
          var protocol = options.protocol || '';
          var hostname = options.hostname || options.host || '';
          // Don't log standard :80 (http) and :443 (https) ports to reduce the noise
          var port =
            !options.port || options.port === 80 || options.port === 443
              ? ''
              : ':' + options.port;
          var path = options.path || '/';
    
    Romain CREY's avatar
    Romain CREY committed
    
    
          this.__ravenBreadcrumbUrl = protocol + '//' + hostname + port + path;
    
    Romain CREY's avatar
    Romain CREY committed
        }
      };
    
      util.inherits(ClientRequest, OrigClientRequest);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      utils.fill(ClientRequest.prototype, 'emit', function(origEmit) {
        return function(evt, maybeResp) {
          if (evt === 'response' && this.__ravenBreadcrumbUrl) {
            if (!Raven.dsn || this.__ravenBreadcrumbUrl.indexOf(Raven.dsn.host) === -1) {
              Raven.captureBreadcrumb({
                type: 'http',
                category: 'http',
                data: {
                  method: this.method,
                  url: this.__ravenBreadcrumbUrl,
                  status_code: maybeResp.statusCode
                }
              });
    
    Romain CREY's avatar
    Romain CREY committed
            }
          }
    
          return origEmit.apply(this, arguments);
        };
      });
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      utils.fill(
        http,
        'ClientRequest',
        function() {
          return ClientRequest;
        },
        originals
      );
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      // http.request orig refs module-internal ClientRequest, not exported one, so
      // it still points at orig ClientRequest after our monkeypatch; these reimpls
      // just get that reference updated to use our new ClientRequest
      utils.fill(
        http,
        'request',
        function() {
          return function(options, cb) {
            return new http.ClientRequest(options, cb);
          };
        },
        originals
      );
    
    Romain CREY's avatar
    Romain CREY committed
    
    
      utils.fill(
        http,
        'get',
        function() {
          return function(options, cb) {
            var req = http.request(options, cb);
            req.end();
            return req;
          };
        },
        originals
      );
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    /* 1723 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = function(Raven, pg, originals) {
      // Using fill helper here is hard because of `this` binding
      var origQuery = pg.Connection.prototype.query;
      pg.Connection.prototype.query = function(text) {
        Raven.captureBreadcrumb({
          category: 'postgres',
          message: text
        });
        origQuery.call(this, text);
      };
      // todo thread this through
      // originals.push([pg.Connection.prototype, 'query', origQuery]);
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports) {
    
    
    module.exports = require("console");
    
    Romain CREY's avatar
    Romain CREY committed
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports) {
    
    
    const DOMAIN_REGEXP = /^https?:\/\/([a-zA-Z0-9-.]+)(?::\d{2,5})?\/?$/;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const getDomain = cozyUrl => {
      cozyUrl = cozyUrl || process.env.COZY_URL;
      return cozyUrl.match(DOMAIN_REGEXP)[1].split('.').slice(-2).join('.');
    };
    
    const getInstance = cozyUrl => {
      cozyUrl = cozyUrl || process.env.COZY_URL;
      return cozyUrl.match(DOMAIN_REGEXP)[1].split('.').slice(-3).join('.');
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = {
      getDomain,
      getInstance
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    
    var before = __webpack_require__(1727);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /**
     * Creates a function that is restricted to invoking `func` once. Repeat calls
     * to the function return the value of the first invocation. The `func` is
     * invoked with the `this` binding and arguments of the created function.
     *
     * @static
     * @memberOf _
     * @since 0.1.0
     * @category Function
     * @param {Function} func The function to restrict.
     * @returns {Function} Returns the new restricted function.
     * @example
     *
     * var initialize = _.once(createApplication);
     * initialize();
     * initialize();
     * // => `createApplication` is invoked once
     */
    function once(func) {
      return before(2, func);
    }
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = once;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    
    var toInteger = __webpack_require__(921);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /** Error message constants. */
    var FUNC_ERROR_TEXT = 'Expected a function';
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /**
     * Creates a function that invokes `func`, with the `this` binding and arguments
     * of the created function, while it's called less than `n` times. Subsequent
     * calls to the created function return the result of the last `func` invocation.
     *
     * @static
     * @memberOf _
     * @since 3.0.0
     * @category Function
     * @param {number} n The number of calls at which `func` is no longer invoked.
     * @param {Function} func The function to restrict.
     * @returns {Function} Returns the new restricted function.
     * @example
     *
     * jQuery(element).on('click', _.before(5, addContactToList));
     * // => Allows adding up to 4 contacts to the list.
     */
    function before(n, func) {
      var result;
      if (typeof func != 'function') {
        throw new TypeError(FUNC_ERROR_TEXT);
    
    Romain CREY's avatar
    Romain CREY committed
      }
    
      n = toInteger(n);
      return function() {
        if (--n > 0) {
          result = func.apply(this, arguments);
        }
        if (n <= 1) {
          func = undefined;
        }
        return result;
      };
    
    Romain CREY's avatar
    Romain CREY committed
    }
    
    
    module.exports = before;
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    
    Romain CREY's avatar
    Romain CREY committed
    /***/ (function(module, exports, __webpack_require__) {
    
    
    const log = __webpack_require__(2).namespace('Error Interception');
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const handleUncaughtException = err => {
      log('critical', err.message, 'uncaught exception');
      process.exit(1);
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const handleUnhandledRejection = err => {
      log('critical', err.message, 'unhandled exception');
      process.exit(1);
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const handleSigterm = () => {
      log('critical', 'The konnector got a SIGTERM');
      process.exit(128 + 15);
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const handleSigint = () => {
      log('critical', 'The konnector got a SIGINT');
      process.exit(128 + 2);
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    let attached = false;
    /**
     * Attach event handlers to catch uncaught exceptions/rejections and signals.
     * Log them as critical and exit the process accordingly.
     * If the cleanup function has not been called, calling again the function
     * is a no-op.
     *
     * @param  {object} prcs - Process object, default to current process
     * @returns {Function} When called, removes the signal handlers
     */
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const attachProcessEventHandlers = (prcs = process) => {
      if (attached) {
        return;
    
    Romain CREY's avatar
    Romain CREY committed
      }
    
    
      attached = true;
      prcs.on('uncaughtException', handleUncaughtException);
      prcs.on('unhandledRejection', handleUnhandledRejection);
      prcs.on('SIGTERM', handleSigterm);
      prcs.on('SIGINT', handleSigint);
      return () => {
        attached = false;
        prcs.removeEventListener('uncaughtException', handleUncaughtException);
        prcs.removeEventListener('unhandledRejection', handleUnhandledRejection);
        prcs.removeEventListener('SIGTERM', handleSigterm);
        prcs.removeEventListener('SIGINT', handleSigint);
      };
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    module.exports = {
      attachProcessEventHandlers
    };
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    /***/ }),
    /* 1729 */
    /***/ (function(module, exports, __webpack_require__) {
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const log = __webpack_require__(2).namespace('CookieKonnector');
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const BaseKonnector = __webpack_require__(1648);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const requestFactory = __webpack_require__(22);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const {
      CookieJar
    } = __webpack_require__(80);
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    const JAR_ACCOUNT_KEY = 'session';
    /**
     * @class
     * Connector base class extending BaseKonnector which handles cookie session in a central way
     * It also handles saving cookie session in the account and automatically restore it for the next
     * connector run.
     * All cozy-konnector-libs tools using request are proposed as methods of this class to force them
     * to use the central cookie which can be saved/restored.
     * You need at least the `GET` and `PUT` permissions on `io.cozy.accounts` in your manifest to allow
     * it to save/restore cookies
     *
     * @example
     * ```javascript
     * const { CookieKonnector } = require('cozy-konnector-libs')
     * class MyConnector extends CookieKonnector {
     *   async fetch(fields) {
     *      // the code of your connector
     *      await this.request('https://...')
     *   }
     *   async testSession() {
     *      const $ = await this.request('https://...')
     *      return $('')
     *   }
     * }
     * const connector = new MyKonnector({
     *   cheerio: true,
     *   json: false
     * })
     * connector.run()
     * ```
     *
     */
    
    Romain CREY's avatar
    Romain CREY committed
    
    
    class CookieKonnector extends BaseKonnector {
      /**
       * Constructor
       *
       * @param  {Function} requestFactoryOptions    - Option object passed to requestFactory to
       * initialize this.request. It is still possible to change this.request doing :
       *
       * ```javascript
       * this.request = this.requestFactory(...)
       * ```
       *
       * Please not you have to run the connector yourself doing :
       *
       * ```javascript
       * connector.run()
       * ```
       */
      constructor(requestFactoryOptions) {
        super();
    
    Romain CREY's avatar
    Romain CREY committed
    
    
        if (!this.testSession) {
          throw new Error('Could not find a testSession method. CookieKonnector needs it to test if a session is valid. Please implement it');
    
    Romain CREY's avatar
    Romain CREY committed
        }
    
    
        this._jar = requestFactory().jar();
        this.request = this.requestFactory(requestFactoryOptions);
      }
      /**
       * Initializes the current connector with data coming from the associated account
       * and also the session
       *
       * @returns {Promise} with the fields as an object
       */
    
      async initAttributes(cozyFields, account) {
        await super.initAttributes(cozyFields, account);
        await this.initSession();
      }
      /**
       * Hook called when the connector is ended
       */