Newer
Older
/******/ (() => { // webpackBootstrap
/******/ var __webpack_modules__ = ([
/* 0 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const {
BaseKonnector,
log,
hydrateAndFilter,
addData,
const soapRequest = __webpack_require__(1337)
const moment = __webpack_require__(1379)
__webpack_require__(1516)
const xml2js = __webpack_require__(1519)
const { buildAggregatedData } = __webpack_require__(1560)
const {
parseSgeXmlData,
formateDataForDoctype,
parseTags,
parseValue,
build-token
committed
parseValueHalfHour,
consultationMesuresDetailleesMaxPower,
consultationMesuresDetaillees,
const {
updateBoConsent,
createBoConsent,
getBoConsent,
deleteBoConsent,
const {
verifyUserIdentity,
activateContract,
verifyContract,
terminateContract,
getContractStartDate,
} = __webpack_require__(1681)
const { getAccount, saveAccountData } = __webpack_require__(1691)
const { isLocal, isDev } = __webpack_require__(1692)
const Sentry = __webpack_require__(1601)
// eslint-disable-next-line
const Tracing = __webpack_require__(1693) // Needed for tracking performance in Sentry
const { version } = __webpack_require__(1730)
moment.locale('fr') // set the language
moment.tz.setDefault('Europe/Paris') // set the timezone
/*** Connector Constants ***/
const manualExecution =
process.env.COZY_JOB_MANUAL_EXECUTION === 'true' ? true : false
let startDailyDate = manualExecution
? moment().subtract(12, 'month')
: moment().subtract(6, 'month')
let startDailyDateString = startDailyDate.format('YYYY-MM-DD')
const startLoadDate = moment().subtract(7, 'day')
const endDate = moment()
const endDateString = endDate.format('YYYY-MM-DD')
const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedissgegrandlyon'
/**
* Sentry
*/
Sentry.init({
dsn:
'https://18747a93401447f2a81b83cd8c4bbbdf@grandlyon.errors.cozycloud.cc/5',
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: isLocal() ? 0 : 1.0,
release: version,
environment: isDev() ? 'development' : 'production',
debug: isDev(),
integrations: [
// enable HTTP calls tracing
new Sentry.Integrations.Http({ tracing: true }),
],
})
/**
* The start function is run by the BaseKonnector instance only when it got all the account
* information (fields). When you run this connector yourself in "standalone" mode or "dev" mode,
* the account information come from ./konnector-dev-config.json file
* cozyParameters are static parameters, independents from the account. Most often, it can be a
* secret api key.
* @param {fields} fields
* @param {{secret: fields}} cozyParameters
*/
try {
log('info', 'Konnector configuration ...')
log('info', `isManual execution: ${manualExecution}`)
const transaction = Sentry.startTransaction({
op: 'konnector',
name: 'SGE Konnector',
})
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
const pointId = parseInt(fields.pointId)
let baseUrl = fields.wso2BaseUrl
let apiAuthKey = fields.apiToken
let contractId = fields.contractId
let sgeLogin = fields.sgeLogin
let boToken = fields.boToken
let boBaseUrl = fields.boBaseUrl
if (cozyParameters && Object.keys(cozyParameters).length !== 0) {
log('debug', 'Found COZY_PARAMETERS')
baseUrl = cozyParameters.secret.wso2BaseUrl
apiAuthKey = cozyParameters.secret.apiToken
contractId = cozyParameters.secret.contractId
sgeLogin = cozyParameters.secret.sgeLogin
boBaseUrl = cozyParameters.secret.boBaseUrl
boToken = cozyParameters.secret.boToken
}
// Prevent missing configuration
if (
!baseUrl ||
!apiAuthKey ||
!contractId ||
!sgeLogin ||
!boToken ||
!boBaseUrl
) {
const errorMessage = 'Missing configuration secrets'
log('error', errorMessage)
Sentry.captureException(errorMessage)
throw errors.VENDOR_DOWN
}
/**
* If it's first start we have to do the following operations:
* - verify pdl are matching
* - BO: create backoffice consent
* - get contract start date and store it
* - activate half-hour
* - BO: update consent with service ID
*/
log('info', 'User Logging...')
if (isFirstStart(await getAccount(ACCOUNT_ID))) {
log('info', 'First start...')
transaction.startChild({ op: 'First start' })
const user = await verifyUserIdentity(
fields,
baseUrl,
apiAuthKey,
sgeLogin
)
let consent = await createBoConsent(
boBaseUrl,
boToken,
pointId,
user.lastname,
user.firstname,
user.address,
user.postalCode,
user.inseeCode,
user.city,
user.hasBeenThroughtSafetyOnBoarding
)
// handle user contract start date in order to properly request data
const userContractStartDate = await getContractStartDate(
startDailyDate = moment(userContractStartDate, 'YYYY-MM-DD')
startDailyDateString = startDailyDate.format('YYYY-MM-DD')
const contractStartDate = moment().format('YYYY-MM-DD')
const contractEndDate = moment()
.add(1, 'year') // SGE force 1 year duration
.format('YYYY-MM-DD')
let serviceId = await verifyContract(
baseUrl,
apiAuthKey,
sgeLogin,
contractId,
user.pointId
)
if (!serviceId) {
serviceId = await activateContract(
baseUrl,
apiAuthKey,
sgeLogin,
contractId,
user.lastname,
user.pointId,
contractStartDate,
contractEndDate
)
}
consent = await updateBoConsent(
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
// Save bo id into account
const accountData = await getAccount(ACCOUNT_ID)
await saveAccountData(ACCOUNT_ID, {
...accountData.data,
consentId: consent.ID,
expirationDate: contractEndDate,
inseeCode: user.inseeCode,
})
} else {
log('info', 'Alternate start...')
transaction.startChild({ op: 'Alternate start' })
const accountData = await getAccount(ACCOUNT_ID)
const userConsent = await getBoConsent(
boBaseUrl,
boToken,
accountData.data.consentId
)
const user = await verifyUserIdentity(
fields,
baseUrl,
apiAuthKey,
sgeLogin,
true,
accountData.data.inseeCode
)
if (!userConsent) {
const errorMessage = 'No user consent found'
log('error', errorMessage)
Sentry.captureException(errorMessage)
throw errors.VENDOR_DOWN
}
const consentEndDate = Date.parse(userConsent.endDate)
const today = Date.now()
if (
user.lastname.toLocaleUpperCase() !==
userConsent.lastname.toLocaleUpperCase() ||
!user ||
consentEndDate < today
) {
await deleteConsent(
userConsent,
baseUrl,
apiAuthKey,
sgeLogin,
contractId,
pointId,
boBaseUrl,
boToken,
consentEndDate < today
)
}
log('info', 'Successfully logged in')
await gatherData(baseUrl, apiAuthKey, sgeLogin, pointId)
transaction.finish()
log('info', 'Konnector success')
} catch (error) {
log('debug', 'error catched in start()', error)
await Sentry.flush()
throw error
}
}
/**
* Delete User Consent
* @param {Consent} userConsent
* @param {string} baseUrl
* @param {string} apiAuthKey
* @param {string} sgeLogin
* @param {string} contractId
* @param {number} pointId
* @param {string} boBaseUrl
* @param {string} boToken
* @param {boolean} isConsentExpired
*/
async function deleteConsent(
userConsent,
baseUrl,
apiAuthKey,
sgeLogin,
contractId,
pointId,
boBaseUrl,
boToken,
isConsentExpired
) {
log('error', `Invalid or not found consent for user`)
Sentry.captureMessage(`Invalid or not found consent for user`)
if (userConsent.serviceID) {
await terminateContract(
baseUrl,
apiAuthKey,
sgeLogin,
contractId,
pointId,
userConsent.serviceID
)
await deleteBoConsent(boBaseUrl, boToken, userConsent.ID || 0)
const errorMessage = `No service id retrieved from BO`
log('error', errorMessage)
Sentry.captureException(errorMessage)
if (isConsentExpired) {
throw errors.USER_ACTION_NEEDED_OAUTH_OUTDATED
}
}
/**
* Main method for gathering data
* @param {string} baseUrl
* @param {string} apiAuthKey
* @param {string} sgeLogin
* @param {number} pointId
*/
async function gatherData(baseUrl, apiAuthKey, sgeLogin, pointId) {
const userContractStartDate = await getContractStartDate(
baseUrl,
apiAuthKey,
sgeLogin,
pointId
)
startDailyDate = moment(userContractStartDate, 'YYYY-MM-DD')
startDailyDateString = startDailyDate.format('YYYY-MM-DD')
await getData(
`${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`,
apiAuthKey,
)
await getMaxPowerData(
`${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`,
apiAuthKey,
)
await getDataHalfHour(
`${baseUrl}/enedis_SGE_ConsultationMesuresDetaillees/1.0`,
apiAuthKey,
/**
* Get hour data
* @param {string} url
* @param {string} apiAuthKey
* @param {string} userLogin
* @param {number} pointId
*/
async function getData(url, apiAuthKey, userLogin, pointId) {
log('info', 'Fetching data')
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
limitStartDate()
const { response } = await soapRequest({
url: url,
headers: sgeHeaders,
xml: consultationMesuresDetaillees(
Sentry.captureException('consultationMesuresDetaillees:', err)
return err
})
xml2js.parseString(
response.body,
{
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
},
processData()
)
}
/**
* Get Max power data
* @param {string} url
* @param {string} apiAuthKey
* @param {string} userLogin
* @param {number} pointId
*/
async function getMaxPowerData(url, apiAuthKey, userLogin, pointId) {
log('info', 'Fetching Max Power data')
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
limitStartDate()
const { response } = await soapRequest({
url: url,
headers: sgeHeaders,
xml: consultationMesuresDetailleesMaxPower(
pointId,
userLogin,
startDailyDateString,
endDateString
),
}).catch(err => {
log('error', 'getMaxPowerData')
log('error', err)
return err
})
xml2js.parseString(
response.body,
{
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
},
processData('com.grandlyon.enedis.maxpower')
)
}
/**
* If start date exceed the maximum amount of data we can get with one query
* get only 36 month. Or 12 month if manual execution
* On manual execution, set the start date to one year ago.
*/
function limitStartDate() {
const livingDuration = moment(endDate).diff(startDailyDate, 'months', true)
// We need to prevent case that there is less than 12 month data
if (manualExecution && livingDuration > 12) {
startDailyDate = moment(endDate).subtract(12, 'month')
startDailyDateString = startDailyDate.format('YYYY-MM-DD')
} else if (livingDuration > 36) {
log(
'info',
'Start date exceed 36 month, setting start date to current date minus 36 month'
)
startDailyDate = moment(endDate).subtract(36, 'month')
startDailyDateString = startDailyDate.format('YYYY-MM-DD')
}
}
/**
* Get half-hour data
* @param {string} url
* @param {string} apiAuthKey
* @param {string} userLogin
* @param {number} pointId
*/
async function getDataHalfHour(url, apiAuthKey, userLogin, pointId) {
log('info', 'Fetching data')
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
build-token
committed
// If manual execution, retrieve only 1 week otherwise retrieve 4 weeks
const MAX_HISTO = manualExecution ? 1 : 4
for (var i = 0; i < MAX_HISTO; i++) {
log('info', 'launch process with history')
const incrementedStartDateString = moment(startLoadDate)
.subtract(7 * i, 'day')
.format('YYYY-MM-DD')
const incrementedEndDateString = moment(endDate)
.subtract(7 * i, 'day')
.format('YYYY-MM-DD')
headers: sgeHeaders,
xml: consultationMesuresDetaillees(
incrementedEndDateString,
'COURBE',
'PA'
),
}).catch(err => {
log('error', 'consultationMesuresDetaillees half-hour')
Sentry.captureException('consultationMesuresDetaillees half-hour')
return err
})
xml2js.parseString(
response.body,
{
tagNameProcessors: [parseTags],
build-token
committed
valueProcessors: [parseValueHalfHour],
explicitArray: false,
},
processData('com.grandlyon.enedis.minute')
)
}
}
/**
* Parse data
* @param {string} doctype
* @returns
*/
function processData(doctype = 'com.grandlyon.enedis.day') {
return async (err, result) => {
if (err) {
log('error', err)
Sentry.captureException('error while processing daily data')
log('info', doctype)
try {
const data = parseSgeXmlData(result)
const processedDailyData = await storeData(
await formateDataForDoctype(data),
doctype,
['year', 'month', 'day', 'hour', 'minute']
)
log('info', 'Aggregate enedis daily data for month and year')
log('info', 'Aggregating...')
await aggregateMonthAndYearData(processedDailyData)
}
} catch (e) {
if (doctype === 'com.grandlyon.enedis.minute') {
const errorMessage = `No half-hour activated. Issue: ${result.Envelope.Body.Fault.faultstring}`
Sentry.captureMessage(errorMessage)
log('warn', errorMessage)
}
}
}
/**
* Save data in the right doctype db and prevent duplicated keys
* @param {EnedisKonnectorData[]} data
* @param {string} doctype
* @param {string[]} filterKeys
* @returns {Promise<*>}
*/
async function storeData(data, doctype, filterKeys) {
log('debug', doctype, 'Store into')
const filteredDocuments = await hydrateAndFilter(data, doctype, {
keys: filterKeys,
})
await addData(filteredDocuments, doctype)
return filteredDocuments
}
/**
* Aggregate data from daily data to monthly and yearly data
async function aggregateMonthAndYearData(data) {
// Sum year and month values into object with year or year-month as keys
if (data && data.length > 0) {
let monthData = {}
let yearData = {}
data.forEach(element => {
element.year + '-' + element.month in monthData
? (monthData[element.year + '-' + element.month] += element.load)
: (monthData[element.year + '-' + element.month] = element.load)
element.year in yearData
? (yearData[element.year] += element.load)
: (yearData[element.year] = element.load)
})
// Aggregation for Month data
const aggregatedMonthData = await buildAggregatedData(
await storeData(aggregatedMonthData, 'com.grandlyon.enedis.month', [
// Aggregation for Year data
const aggregatedYearData = await buildAggregatedData(
await storeData(aggregatedYearData, 'com.grandlyon.enedis.year', ['year'])
/**
* @returns {boolean}
*/
function isFirstStart(account) {
if (account && account.data && account.data.consentId) {
log('info', 'Konnector not first start')
return false
}
log('info', 'Konnector first start')
return true
}
/***/ }),
/* 1 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const requestFactory = __webpack_require__(2);
const categorization = __webpack_require__(1232);
BaseKonnector: __webpack_require__(1250),
CookieKonnector: __webpack_require__(1330),
saveFiles: __webpack_require__(1252),
saveBills: __webpack_require__(1251),
saveIdentity: __webpack_require__(1296),
linkBankOperations: __webpack_require__(1273),
addData: __webpack_require__(1272),
htmlToPDF: (__webpack_require__(1331).htmlToPDF),
createCozyPDFDocument: (__webpack_require__(1331).createCozyPDFDocument),
filterData: deprecate(hydrateAndFilter, 'Use hydrateAndFilter now. filterData will be removed in cozy-konnector-libs@4'),
updateOrCreate: __webpack_require__(1295),
request: deprecate(requestFactory, 'Use requestFactory instead of request. It will be removed in cozy-konnector-libs@4'),
requestFactory,
retry: __webpack_require__(1253),
wrapIfSentrySetUp: (__webpack_require__(1297).wrapIfSentrySetUp),
Document: __webpack_require__(1332),
signin: __webpack_require__(1292),
submitForm: __webpack_require__(1292),
scrape: __webpack_require__(1334),
mkdirp: __webpack_require__(1255),
normalizeFilename: __webpack_require__(1335),
solveCaptcha: __webpack_require__(1336),
createCategorizer: categorization.createCategorizer,
categorize: categorization.categorize,
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
};
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
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
// 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
});
}
}
function requestToStrings(type, data) {
const result = {};
if (type === 'request') {
result.oneline = `${data.method} -> ${data.uri} ${data.headers['content-length'] ? 'Content-Length: ' + data.headers['content-length'] : ''}`;
} else if (type === 'response') {
result.oneline = `<- ${data.statusCode} ${data.headers['content-length'] ? 'Content-Length: ' + data.headers['content-length'] : ''}`;
} else {
result.oneline = `<- ${data.statusCode} ${data.uri}`;
}
result.headers = Object.keys(data.headers).map(key => `${key}: ${data.headers[key]}`).join('\n');
result.body = data.body;
return result;
}
function mergeDefaultOptions(options = {}) {
const defaultOptions = {
debug: false,
json: true,
cheerio: false,
headers: {},
followAllRedirects: true
};
if (options.cheerio === true) {
options.json = false;
}
return { ...defaultOptions,
...options
};
}
function transformWithCheerio(body, response, resolveWithFullResponse) {
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
if (resolveWithFullResponse) {
return { ...response,
body: result
};
}
return result;
}
function getRequestOptions({
cheerio,
userAgent,
...options
}) {
const userAgentOption = options.headers['User-Agent'];
return cheerio ? { ...options,
transform: transformWithCheerio,
headers: { ...options.headers,
'User-Agent': userAgentOption ? userAgentOption : userAgent === false ? undefined : DEFAULT_USER_AGENT
}
} : { ...options,
headers: { ...options.headers,
'User-Agent': userAgent ? DEFAULT_USER_AGENT : options.headers['User-Agent']
}
};
}
/***/ }),
/* 4 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
/* module decorator */ module = __webpack_require__.nmd(module);
var Bluebird = (__webpack_require__(5).getNewLibraryCopy)(),
configure = __webpack_require__(42),
stealthyRequire = __webpack_require__(57);
try {
// Load Request freshly - so that users can require an unaltered request instance!
var request = stealthyRequire(__webpack_require__.c, function () {
return __webpack_require__(58);
},
function () {
__webpack_require__(61);
}, module);
} catch (err) {
/* istanbul ignore next */
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/* istanbul ignore next */
console.error(EOL + '###' + EOL + '### The "request" library is not installed automatically anymore.' + EOL + '### But is a dependency of "request-promise".' + EOL + '### Please install it with:' + EOL + '### npm install request --save' + EOL + '###' + EOL);
/* istanbul ignore next */
throw err;
}
Bluebird.config({cancellation: true});
configure({
request: request,
PromiseImpl: Bluebird,
expose: [
'then',
'catch',
'finally',
'cancel',
'promise'
// Would you like to expose more Bluebird methods? Try e.g. `rp(...).promise().tap(...)` first. `.promise()` returns the full-fledged Bluebird promise.
],
constructorMixin: function (resolve, reject, onCancel) {
var self = this;
onCancel(function () {
self.abort();
});
}
});
request.bindCLS = function RP$bindCLS() {
throw new Error('CLS support was dropped. To get it back read: https://github.com/request/request-promise/wiki/Getting-Back-Support-for-Continuation-Local-Storage');
};
module.exports = request;
/***/ }),
/* 5 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
var old;
if (typeof Promise !== "undefined") old = Promise;
function noConflict() {
try { if (Promise === bluebird) Promise = old; }
catch (e) {}
return bluebird;
}
var bluebird = __webpack_require__(6)();
bluebird.noConflict = noConflict;
module.exports = bluebird;
/***/ }),
/* 6 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
"use strict";
module.exports = function() {
var makeSelfResolutionError = function () {
return new TypeError("circular promise resolution chain\u000a\u000a See http://goo.gl/MqrFmX\u000a");
};
var reflectHandler = function() {
return new Promise.PromiseInspection(this._target());
};
var apiRejection = function(msg) {
return Promise.reject(new TypeError(msg));
};
function Proxyable() {}
var UNDEFINED_BINDING = {};
var util = __webpack_require__(7);
util.setReflectHandler(reflectHandler);
var getDomain = function() {
var domain = process.domain;
if (domain === undefined) {
return null;
}