Newer
Older
/***/ }),
/* 1712 */
/***/ (function(module, exports, __webpack_require__) {
var rng = __webpack_require__(262);
var bytesToUuid = __webpack_require__(263);
// **`v1()` - Generate time-based UUID**
//
// Inspired by https://github.com/LiosK/UUID.js
// and http://docs.python.org/library/uuid.html
var _nodeId;
var _clockseq;
// Previous uuid creation time
var _lastMSecs = 0;
var _lastNSecs = 0;
// See https://github.com/broofa/node-uuid for API details
function v1(options, buf, offset) {
var i = buf && offset || 0;
var b = buf || [];
options = options || {};
var node = options.node || _nodeId;
var clockseq = options.clockseq !== undefined ? options.clockseq : _clockseq;
218031
218032
218033
218034
218035
218036
218037
218038
218039
218040
218041
218042
218043
218044
218045
218046
218047
// 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;
}
}
// 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();
// 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;
// Time since last uuid creation (in msecs)
var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
// Per 4.2.1.2, Bump clockseq on clock regression
if (dt < 0 && options.clockseq === undefined) {
clockseq = clockseq + 1 & 0x3fff;
// 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;
}
// 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');
_lastMSecs = msecs;
_lastNSecs = nsecs;
_clockseq = clockseq;
// Per 4.1.4 - Convert from unix epoch to Gregorian epoch
msecs += 12219292800000;
// `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;
// `time_mid`
var tmh = (msecs / 0x100000000 * 10000) & 0xfffffff;
b[i++] = tmh >>> 8 & 0xff;
b[i++] = tmh & 0xff;
// `time_high_and_version`
b[i++] = tmh >>> 24 & 0xf | 0x10; // include version
b[i++] = tmh >>> 16 & 0xff;
// `clock_seq_hi_and_reserved` (Per 4.2.2 - include variant)
b[i++] = clockseq >>> 8 | 0x80;
// `clock_seq_low`
b[i++] = clockseq & 0xff;
// `node`
for (var n = 0; n < 6; ++n) {
b[i + n] = node[n];
return buf ? buf : bytesToUuid(b);
/***/ }),
/* 1713 */
/***/ (function(module, exports) {
module.exports = require("domain");
/***/ }),
/* 1714 */
/***/ (function(module, exports, __webpack_require__) {
218128
218129
218130
218131
218132
218133
218134
218135
218136
218137
218138
218139
218140
218141
218142
218143
218144
218145
218146
218147
218148
218149
218150
218151
218152
218153
218154
218155
218156
218157
218158
218159
218160
218161
218162
218163
218164
218165
218166
218167
218168
218169
218170
218171
218172
218173
218174
218175
218176
218177
218178
218179
218180
218181
218182
218183
218184
218185
218186
218187
218188
218189
218190
218191
218192
218193
218194
218195
218196
218197
218198
218199
218200
218201
218202
218203
218204
218205
218206
218207
218208
218209
218210
218211
218212
218213
218214
218215
218216
218217
218218
218219
218220
218221
218222
218223
218224
218225
218226
218227
218228
218229
218230
218231
218232
218233
218234
218235
218236
218237
218238
218239
218240
218241
218242
218243
218244
218245
218246
218247
218248
218249
218250
218251
218252
218253
218254
218255
218256
218257
218258
218259
218260
218261
218262
218263
218264
218265
218266
218267
218268
218269
218270
218271
218272
218273
218274
218275
218276
218277
218278
218279
218280
218281
218282
218283
218284
218285
218286
218287
(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) {
(function() {
var base64map
= 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/',
crypt = {
// Bit-wise rotation left
rotl: function(n, b) {
return (n << b) | (n >>> (32 - b));
},
// Bit-wise rotation right
rotr: function(n, b) {
return (n << (32 - b)) | (n >>> b);
},
// 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;
}
// Else, assume array and swap all items
for (var i = 0; i < n.length; i++)
n[i] = crypt.endian(n[i]);
return n;
},
// 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;
},
// 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;
},
// 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;
},
// 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('');
},
// 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;
},
// 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('');
},
// Convert a base-64 string to a byte array
base64ToBytes: function(base64) {
// Remove non-base-64 characters
base64 = base64.replace(/[^A-Z0-9+\/]/ig, '');
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;
module.exports = crypt;
})();
/***/ }),
/* 1716 */
/***/ (function(module, exports) {
var charenc = {
// UTF-8 encoding
utf8: {
// Convert a string to a byte array
stringToBytes: function(str) {
return charenc.bin.stringToBytes(unescape(encodeURIComponent(str)));
},
// Convert a byte array to a string
bytesToString: function(bytes) {
return decodeURIComponent(escape(charenc.bin.bytesToString(bytes)));
// 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;
},
// 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('');
}
module.exports = charenc;
/***/ }),
/* 1717 */
/***/ (function(module, exports) {
/*!
* Determine if an object is a Buffer
*
* @author Feross Aboukhadijeh <https://feross.org>
* @license MIT
*/
// 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)
}
function isBuffer (obj) {
return !!obj.constructor && typeof obj.constructor.isBuffer === 'function' && obj.constructor.isBuffer(obj)
// 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))
}
/***/ (function(module, exports, __webpack_require__) {
"use strict";
var utils = __webpack_require__(1705);
var defaultOnConfig = {
console: true,
http: true
};
var defaultConfig = {
console: false,
http: false,
pg: false
};
function instrument(Raven, config) {
if (config === false) {
return;
} else if (config === true) {
config = defaultOnConfig;
} else {
config = utils.extend({}, defaultConfig, config);
Raven.instrumentedOriginals = [];
Raven.instrumentedModules = [];
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);
return origModule;
};
},
Raven.instrumentedOriginals
);
// special case: since console is built-in and app-level code won't require() it, do that here
if (config.console) {
__webpack_require__(1724);
// 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) {
module.exports = require("module");
/***/ (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
};
218562
218563
218564
218565
218566
218567
218568
218569
218570
218571
218572
218573
218574
218575
218576
218577
218578
218579
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;
/***/ }),
/* 1721 */
/***/ (function(module, exports, __webpack_require__) {
var util = __webpack_require__(9);
var utils = __webpack_require__(1705);
module.exports = function(Raven, console, originals) {
var wrapConsoleMethod = function(level) {
if (!(level in console)) {
return;
}
utils.fill(
console,
level,
function(originalConsoleLevel) {
var sentryLevel = level === 'warn' ? 'warning' : level;
return function() {
var args = [].slice.call(arguments);
Raven.captureBreadcrumb({
message: util.format.apply(null, args),
level: sentryLevel,
category: 'console'
});
originalConsoleLevel.apply(console, args);
};
},
originals
);
};
['debug', 'info', 'warn', 'error', 'log'].forEach(wrapConsoleMethod);
return console;
};
/***/ }),
/* 1722 */
/***/ (function(module, exports, __webpack_require__) {
var util = __webpack_require__(9);
var utils = __webpack_require__(1705);
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);
// 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;
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 || '/';
this.__ravenBreadcrumbUrl = protocol + '//' + hostname + port + path;
util.inherits(ClientRequest, OrigClientRequest);
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
}
});
return origEmit.apply(this, arguments);
};
});
utils.fill(
http,
'ClientRequest',
function() {
return ClientRequest;
},
originals
);
// 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
);
utils.fill(
http,
'get',
function() {
return function(options, cb) {
var req = http.request(options, cb);
req.end();
return req;
};
},
originals
);
/***/ }),
/* 1723 */
/***/ (function(module, exports, __webpack_require__) {
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]);
};
module.exports = require("console");
const DOMAIN_REGEXP = /^https?:\/\/([a-zA-Z0-9-.]+)(?::\d{2,5})?\/?$/;
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('.');
};
module.exports = {
getDomain,
getInstance
};
/***/ (function(module, exports, __webpack_require__) {
var before = __webpack_require__(1727);
218778
218779
218780
218781
218782
218783
218784
218785
218786
218787
218788
218789
218790
218791
218792
218793
218794
218795
218796
218797
218798
/**
* 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);
}
/***/ (function(module, exports, __webpack_require__) {
var toInteger = __webpack_require__(921);
/** Error message constants. */
var FUNC_ERROR_TEXT = 'Expected a function';
218812
218813
218814
218815
218816
218817
218818
218819
218820
218821
218822
218823
218824
218825
218826
218827
218828
218829
218830
218831
218832
/**
* 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);
n = toInteger(n);
return function() {
if (--n > 0) {
result = func.apply(this, arguments);
}
if (n <= 1) {
func = undefined;
}
return result;
};
/***/ (function(module, exports, __webpack_require__) {
const log = __webpack_require__(2).namespace('Error Interception');
const handleUncaughtException = err => {
log('critical', err.message, 'uncaught exception');
process.exit(1);
};
const handleUnhandledRejection = err => {
log('critical', err.message, 'unhandled exception');
process.exit(1);
};
const handleSigterm = () => {
log('critical', 'The konnector got a SIGTERM');
process.exit(128 + 15);
};
const handleSigint = () => {
log('critical', 'The konnector got a SIGINT');
process.exit(128 + 2);
};
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
*/
const attachProcessEventHandlers = (prcs = process) => {
if (attached) {
return;
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);
};
};
module.exports = {
attachProcessEventHandlers
};
/***/ }),
/* 1729 */
/***/ (function(module, exports, __webpack_require__) {
const log = __webpack_require__(2).namespace('CookieKonnector');
const BaseKonnector = __webpack_require__(1648);
const requestFactory = __webpack_require__(22);
const {
CookieJar
} = __webpack_require__(80);
218923
218924
218925
218926
218927
218928
218929
218930
218931
218932
218933
218934
218935
218936
218937
218938
218939
218940
218941
218942
218943
218944
218945
218946
218947
218948
218949
218950
218951
218952
218953
218954
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()
* ```
*
*/
218956
218957
218958
218959
218960
218961
218962
218963
218964
218965
218966
218967
218968
218969
218970
218971
218972
218973
218974
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();
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');
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
*/