Newer
Older
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
/* 0 */,
/* 1 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const requestFactory = __webpack_require__(2);
const hydrateAndFilter = __webpack_require__(353);
const categorization = __webpack_require__(1270);
const log = __webpack_require__(1287);
BaseKonnector: __webpack_require__(1288),
CookieKonnector: __webpack_require__(1368),
errors: __webpack_require__(1294),
saveFiles: __webpack_require__(1290),
saveBills: __webpack_require__(1289),
saveIdentity: __webpack_require__(1334),
linkBankOperations: __webpack_require__(1311),
addData: __webpack_require__(1310),
htmlToPDF: (__webpack_require__(1369).htmlToPDF),
createCozyPDFDocument: (__webpack_require__(1369).createCozyPDFDocument),
filterData: deprecate(hydrateAndFilter, 'Use hydrateAndFilter now. filterData will be removed in cozy-konnector-libs@4'),
updateOrCreate: __webpack_require__(1333),
request: deprecate(requestFactory, 'Use requestFactory instead of request. It will be removed in cozy-konnector-libs@4'),
requestFactory,
retry: __webpack_require__(1291),
wrapIfSentrySetUp: (__webpack_require__(1335).wrapIfSentrySetUp),
Document: __webpack_require__(1370),
signin: __webpack_require__(1330),
submitForm: __webpack_require__(1330),
scrape: __webpack_require__(1372),
mkdirp: __webpack_require__(1293),
normalizeFilename: __webpack_require__(1373),
solveCaptcha: __webpack_require__(1374),
createCategorizer: categorization.createCategorizer,
categorize: categorization.categorize,
manifest: __webpack_require__(953)
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
};
function deprecate(wrapped, message) {
return function () {
log('warn', message);
return wrapped.apply(this, arguments);
};
}
/***/ }),
/* 2 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
module.exports = __webpack_require__(3)["default"];
/***/ }),
/* 3 */
/***/ ((module, exports, __webpack_require__) => {
/**
* This is a function which returns an instance of
* [request-promise](https://www.npmjs.com/package/request-promise) initialized with
* defaults often used in connector development.
*
* ```js
* // Showing defaults
* req = requestFactory({
* cheerio: false,
* jar: true,
* json: true
* })
* ```
*
* Options :
*
* - `cheerio`: will parse automatically the `response.body` in a cheerio instance
*
* ```javascript
* req = requestFactory({ cheerio: true })
* req('http://github.com', $ => {
* const repos = $('#repo_listing .repo')
* })
* ```
*
* - `jar`: is passed to `request` options. Remembers cookies for future use.
* - `json`: will parse the `response.body` as JSON
* - `resolveWithFullResponse`: The full response will be return in the promise. It is compatible
* with cheerio and json options.
*
* ```javascript
* req = requestFactory({
* resolveWithFullResponse: true,
* cheerio: true
* })
* req('http://github.com', response => {
* console.log(response.statusCode)
* const $ = response.body
* const repos = $('#repo_listing .repo')
* })
* ```
* - `debug`: will display request and responses details in error output. Possible values :
* true : display request and response in normal request-debug json format
* 'json' : display request and response in full json format
* 'simple' : display main information about each request and response
* ```
* GET -> http://books.toscrape.com/media/cache/26/0c/260c6ae16bce31c8f8c95daddd9f4a1c.jpg
* <- 200 Content-Length: 7095
* ```
* 'full' : display comple information about each request and response
* ```
* GET -> http://quotes.toscrape.com/login
*
* BEGIN HEADERS
* host: quotes.toscrape.com
* END HEADERS
*
* <- 200 Content-Length: 1869
*
* BEGIN HEADERS
* server: nginx/1.12.1
* ...
* END HEADERS
*
* BEGIN BODY
* <html>....
* END BODY
* ```
*
* You can find the full list of available options in [request-promise](https://github.com/request/request-promise) and [request](https://github.com/request/request) documentations.
*
* @module requestFactory
*/
let request = __webpack_require__(4);
const requestdebug = __webpack_require__(254); // Quickly found more UserAgent here
// https://www.whatismybrowser.com/guides/the-latest-user-agent/
const AGENTS_LIST = ['Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:84.0) Gecko/20100101 Firefox/84.0', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11.1; rv:84.0) Gecko/20100101 Firefox/84.0', 'Mozilla/5.0 (X11; Linux i686; rv:84.0) Gecko/20100101 Firefox/84.0', 'Mozilla/5.0 (Linux x86_64; rv:84.0) Gecko/20100101 Firefox/84.0', 'Mozilla/5.0 (X11; Ubuntu; Linux i686; rv:84.0) Gecko/20100101 Firefox/84.0', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36', 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0.2 Safari/605.1.15', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75', 'Mozilla/5.0 (Macintosh; Intel Mac OS X 11_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.141 Safari/537.36 Edg/87.0.664.75'];
const DEFAULT_USER_AGENT = AGENTS_LIST[Math.floor(Math.random() * AGENTS_LIST.length)];
exports = module.exports = {
default: requestFactory,
mergeDefaultOptions,
transformWithCheerio,
getRequestOptions,
DEFAULT_USER_AGENT
};
function requestFactory({
debug,
...options
} = {
debug: false
}) {
const logFn = setDebugFunction(debug);
debug && requestdebug(request, logFn);
return request.defaults(getRequestOptions(mergeDefaultOptions(options)));
}
function setDebugFunction(debug) {
/* eslint no-console: off */
if (debug === 'simple') {
return (type, data) => console.error(requestToStrings(type, data).oneline);
} else if (debug === 'json') {
return (type, data) => console.error(JSON.stringify({
type,
data
}));
} else if (debug === 'full') {
return (type, data) => {
const {
oneline,
headers,
body
} = requestToStrings(type, data);
console.error(`${oneline}
BEGIN HEADERS
${headers}
END HEADERS
` + (body ? `BEGIN BODY
${body}
END BODY
` : ''));
};
} else if (typeof debug === 'function') {
return (type, data, resp) => debug({
strings: requestToStrings(type, data),
type,
data,
resp
});
}
Loading
Loading full blame...