Newer
Older
next(error);
};
}
// TODO (v8 / #5257): Remove this
// eslint-disable-next-line deprecation/deprecation
;
//# sourceMappingURL=handlers.js.map
/***/ }),
/* 1716 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "extractRequestData": () => (/* binding */ extractRequestData),
/* harmony export */ "parseRequest": () => (/* binding */ parseRequest)
/* harmony export */ });
/* harmony import */ var _requestdata_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1705);
246024
246025
246026
246027
246028
246029
246030
246031
246032
246033
246034
246035
246036
246037
246038
246039
246040
246041
246042
246043
246044
246045
246046
246047
246048
246049
246050
246051
246052
246053
246054
246055
246056
246057
246058
246059
246060
246061
246062
246063
246064
246065
246066
246067
246068
/**
* @deprecated `Handlers.ExpressRequest` is deprecated and will be removed in v8. Use `PolymorphicRequest` instead.
*/
/**
* Normalizes data from the request object, accounting for framework differences.
*
* @deprecated `Handlers.extractRequestData` is deprecated and will be removed in v8. Use `extractRequestData` instead.
*
* @param req The request object from which to extract data
* @param keys An optional array of keys to include in the normalized data.
* @returns An object containing normalized request data
*/
function extractRequestData(req, keys) {
return (0,_requestdata_js__WEBPACK_IMPORTED_MODULE_0__.extractRequestData)(req, { include: keys });
}
/**
* Options deciding what parts of the request to use when enhancing an event
*
* @deprecated `Handlers.ParseRequestOptions` is deprecated and will be removed in v8. Use
* `AddRequestDataToEventOptions` in `@sentry/utils` instead.
*/
/**
* Enriches passed event with request data.
*
* @deprecated `Handlers.parseRequest` is deprecated and will be removed in v8. Use `addRequestDataToEvent` instead.
*
* @param event Will be mutated and enriched with req data
* @param req Request object
* @param options object containing flags to enable functionality
* @hidden
*/
function parseRequest(event, req, options = {}) {
return (0,_requestdata_js__WEBPACK_IMPORTED_MODULE_0__.addRequestDataToEvent)(event, req, { include: options });
}
//# sourceMappingURL=requestDataDeprecated.js.map
/***/ }),
/* 1717 */
246070
246071
246072
246073
246074
246075
246076
246077
246078
246079
246080
246081
246082
246083
246084
246085
246086
246087
246088
246089
246090
246091
246092
246093
246094
246095
246096
246097
246098
246099
246100
246101
246102
246103
246104
246105
246106
246107
246108
246109
246110
246111
246112
246113
246114
246115
246116
246117
246118
246119
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "TRACEPARENT_REGEXP": () => (/* binding */ TRACEPARENT_REGEXP),
/* harmony export */ "extractTraceparentData": () => (/* binding */ extractTraceparentData)
/* harmony export */ });
const TRACEPARENT_REGEXP = new RegExp(
'^[ \\t]*' + // whitespace
'([0-9a-f]{32})?' + // trace_id
'-?([0-9a-f]{16})?' + // span_id
'-?([01])?' + // sampled
'[ \\t]*$', // whitespace
);
/**
* Extract transaction context data from a `sentry-trace` header.
*
* @param traceparent Traceparent string
*
* @returns Object containing data from the header, or undefined if traceparent string is malformed
*/
function extractTraceparentData(traceparent) {
const matches = traceparent.match(TRACEPARENT_REGEXP);
if (!traceparent || !matches) {
// empty string or no matches is invalid traceparent data
return undefined;
}
let parentSampled;
if (matches[3] === '1') {
parentSampled = true;
} else if (matches[3] === '0') {
parentSampled = false;
}
return {
traceId: matches[1],
parentSampled,
parentSpanId: matches[2],
};
}
//# sourceMappingURL=tracing.js.map
/***/ }),
/* 1718 */
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
"use strict";
__webpack_require__.r(__webpack_exports__);
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
/* harmony export */ "FunctionToString": () => (/* reexport safe */ _functiontostring_js__WEBPACK_IMPORTED_MODULE_0__.FunctionToString),
/* harmony export */ "InboundFilters": () => (/* reexport safe */ _inboundfilters_js__WEBPACK_IMPORTED_MODULE_1__.InboundFilters)
/* harmony export */ });
/* harmony import */ var _functiontostring_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(1712);
/* harmony import */ var _inboundfilters_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(1711);
//# sourceMappingURL=index.js.map
/***/ }),
/* 1719 */,
/* 1720 */,
/* 1721 */,
/* 1722 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log, errors } = __webpack_require__(1)
const soapRequest = __webpack_require__(1375)
const { parseTags, parseValue } = __webpack_require__(1599)
const { commanderArretServiceSouscritMesures } = __webpack_require__(1600)
const xml2js = __webpack_require__(1557)
const Sentry = __webpack_require__(1639)
246150
246151
246152
246153
246154
246155
246156
246157
246158
246159
246160
246161
246162
246163
246164
246165
246166
246167
246168
246169
246170
246171
246172
246173
246174
246175
246176
246177
246178
246179
246180
246181
246182
246183
246184
/**
* @param {string} url
* @param {string} apiAuthKey
* @param {string} appLogin
* @param {number} pointId
* @param {number} serviceId
* @return {Promise<string>} User contractId
*/
async function terminateContract(
url,
apiAuthKey,
appLogin,
contractId,
pointId,
serviceId
) {
log('info', 'terminateContract')
const sgeHeaders = {
'Content-Type': 'text/xml;charset=UTF-8',
apikey: apiAuthKey,
}
const { response } = await soapRequest({
url: `${url}/enedis_SGE_CommandeArretServiceSouscritMesures/1.0`,
headers: sgeHeaders,
xml: commanderArretServiceSouscritMesures(
appLogin,
contractId,
pointId,
serviceId
),
}).catch(err => {
log('error', 'commanderArretServiceSouscritMesures')
log('error', err)
Sentry.captureException('commanderArretServiceSouscritMesures', err)
246186
246187
246188
246189
246190
246191
246192
246193
246194
246195
246196
246197
246198
246199
246200
246201
246202
246203
246204
throw errors.VENDOR_DOWN
})
const parsedReply = await xml2js.parseStringPromise(response.body, {
tagNameProcessors: [parseTags],
valueProcessors: [parseValue],
explicitArray: false,
})
try {
// We don't need any action on reply for now
if (parsedReply.Envelope.Body.Fault) {
log(
'error',
`Enedis issue ${parsedReply.Envelope.Body.Fault.detail.erreur.resultat.$.code}: ${parsedReply.Envelope.Body.Fault.faultstring}`
)
}
return parsedReply
} catch (error) {
const errorMessage =
'Error while parsing user contract termination: ' + error
log('error', errorMessage)
log('error', `Enedis issue ${JSON.stringify(parsedReply.Envelope.Body)}`)
throw errors.VENDOR_DOWN
}
}
module.exports = { terminateContract }
/***/ }),
/* 1723 */,
/* 1724 */,
/* 1725 */,
/* 1726 */,
/* 1727 */,
/* 1728 */,
/* 1729 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const { log, updateOrCreate } = __webpack_require__(1)
const { isLocal } = __webpack_require__(1730)
const cozyClient = __webpack_require__(485)
async function saveAccountData(accountId, accountData) {
log('info', `saveAccountData: ${accountId}`)
let account = await getAccount(accountId)
log('info', `saveAccountData account: ${JSON.stringify(account)}`)
log(
'info',
`saveAccountData account: ${JSON.stringify({
...account,
data: accountData,
})}`
)
log(
'info',
`saveAccountData account after id: ${JSON.stringify({
...account,
data: accountData,
})}`
)
account = await updateOrCreate(
[{ ...account, data: accountData }],
'io.cozy.accounts',
['account_type']
log('info', `saveAccountData account reply: ${JSON.stringify(account)}`)
/**
* Return account
* @param {string} accountId
* @returns {Account}
*/
async function getAccount(accountId) {
log('info', `getAccount: ${accountId}`)
const accounts = await cozyClient.data.findAll('io.cozy.accounts')
return accounts.filter(account =>
isLocal() ? account._id === accountId : account.account_type === accountId
async function getAccountForDelete(accountId, accountRev) {
log('info', `getAccountForDelete: ${accountId} ${accountRev}`)
const body = await cozyClient.fetchJSON(
'GET',
`/data/io.cozy.accounts/${accountId}?rev=${accountRev}`
)
log('debug', `getAccountForDelete: ${body}`)
return body
}
module.exports = { getAccount, saveAccountData, getAccountForDelete }
/* 1730 */
return (
process.env.NODE_ENV === 'development' ||
process.env.NODE_ENV === 'local' ||
process.env.NODE_ENV === 'standalone'
)
}
/**
* Verify if it's an alpha URL
* @returns {boolean}
*/
function isDev() {
return (
process.env.COZY_URL.includes('alpha') ||
process.env.COZY_URL.includes('cozy.tools')
)
}
module.exports = { isLocal, isDev }
246314
246315
246316
246317
246318
246319
246320
246321
246322
246323
246324
246325
246326
246327
246328
246329
246330
246331
246332
246333
246334
246335
246336
246337
246338
246339
246340
246341
246342
246343
246344
246345
246346
246347
246348
246349
246350
246351
246352
/* 1731 */,
/* 1732 */,
/* 1733 */,
/* 1734 */,
/* 1735 */,
/* 1736 */,
/* 1737 */,
/* 1738 */,
/* 1739 */,
/* 1740 */,
/* 1741 */,
/* 1742 */,
/* 1743 */,
/* 1744 */,
/* 1745 */,
/* 1746 */,
/* 1747 */,
/* 1748 */,
/* 1749 */,
/* 1750 */,
/* 1751 */,
/* 1752 */,
/* 1753 */,
/* 1754 */,
/* 1755 */,
/* 1756 */,
/* 1757 */,
/* 1758 */,
/* 1759 */,
/* 1760 */,
/* 1761 */,
/* 1762 */,
/* 1763 */,
/* 1764 */,
/* 1765 */,
/* 1766 */,
/* 1767 */,
/* 1768 */,
/* 1769 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
// @ts-check
const { log, errors } = __webpack_require__(1)
const {
getAccountRev,
getAccountSecret,
getAccountId,
} = __webpack_require__(1770)
const { getBoConsent, deleteBoConsent } = __webpack_require__(1601)
const { terminateContract } = __webpack_require__(1722)
const { getAccountForDelete } = __webpack_require__(1729)
const moment = __webpack_require__(1417)
__webpack_require__(1554)
const { isLocal, isDev } = __webpack_require__(1730)
const Sentry = __webpack_require__(1639)
moment.locale('fr') // set the language
moment.tz.setDefault('Europe/Paris') // set the timezone
async function onDeleteAccount() {
246374
246375
246376
246377
246378
246379
246380
246381
246382
246383
246384
246385
246386
246387
246388
246389
246390
246391
246392
246393
246394
try {
log('info', 'Deleting account ...')
log('info', 'Getting secrets ...')
const ACCOUNT_ID = getAccountId()
const accountRev = getAccountRev()
if (accountRev) {
log('info', 'Account rev exist')
const accountData = await getAccountForDelete(ACCOUNT_ID, accountRev)
// Parse local info for deletion test
if (isLocal()) {
log('warn', 'Local run')
const fields = JSON.parse(
process.env.COZY_FIELDS ? process.env.COZY_FIELDS : '{}'
)
process.env.COZY_FIELDS = JSON.stringify({
...fields,
...accountData.auth,
})
}
const secrets = getAccountSecret()
const userConsent = await getBoConsent(
secrets.boBaseUrl,
secrets.boToken,
accountData.data.consentId
)
log('info', `isAlpha: ${isDev()}`)
log('info', `userConsent: ${JSON.stringify(userConsent)}`)
if (userConsent.ID && userConsent.pointID) {
log('log', `Consent ${userConsent.ID} found for user`)
if (userConsent.serviceID) {
await deleteBoConsent(
secrets.boBaseUrl,
secrets.boToken,
userConsent.ID
246412
246413
246414
246415
246416
246417
246418
246419
246420
246421
246422
246423
246424
246425
246426
246427
// Verify if it's dev env to prevent delete of real data
if (!isDev()) {
await terminateContract(
secrets.wso2BaseUrl,
secrets.apiToken,
secrets.sgeLogin,
secrets.contractId,
userConsent.pointID,
userConsent.serviceID
)
}
} else {
const errorMessage = `No service id retrieved from BO`
log('error', errorMessage)
Sentry.captureException(errorMessage)
throw errors.VENDOR_DOWN
log('info', 'Deleting account succeed')
} else {
const errorMessage =
'No account revision was found, something went wrong during the deletion of said account'
log('error', errorMessage)
Sentry.captureException(errorMessage)
throw errors.VENDOR_DOWN
}
} catch (error) {
log('debug', 'error catched in onDeleteAccount()', error)
await Sentry.flush()
throw error
}
}
onDeleteAccount().then(
() => {
log('info', `onDeleteAccount: Successfully delete consent and account.`)
},
err => {
const errorMessage = `onDeleteAccount: An error occurred during script: ${err.message}`
log('error', errorMessage)
Sentry.captureException(errorMessage)
throw errors.VENDOR_DOWN
}
)
module.exports = { onDeleteAccount }
/***/ }),
/* 1770 */
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const { log } = __webpack_require__(1)
const { isLocal } = __webpack_require__(1730)
const Sentry = __webpack_require__(1639)
function getAccountId() {
log('info', `getAccountId`)
try {
return JSON.parse(process.env.COZY_FIELDS).account
} catch (err) {
const errorMessage = `You must provide 'account' in COZY_FIELDS: ${err.message}`
Sentry.captureException(errorMessage)
throw new Error(errorMessage)
}
}
function getAccountRev() {
log('info', `getAccountRev`)
log('info', `getAccountRev: ${JSON.stringify(process.env.COZY_FIELDS)}`)
? 'fakeAccountRev'
: JSON.parse(process.env.COZY_FIELDS).account_rev
} catch (err) {
const errorMessage = `You must provide 'account' in COZY_FIELDS: ${err.message}`
Sentry.captureException(errorMessage)
throw new Error(errorMessage)
}
}
/**
* Return account secrets.
* For local testing, change value with values from your konnector-dev-config.json
* @returns {Fields}
log('info', `getAccountSecret`)
? JSON.parse(process.env.COZY_FIELDS)
: JSON.parse(process.env.COZY_PARAMETERS).secret
} catch (err) {
const errorMessage = `You must provide 'account-types' in COZY_PARAMETERS: ${err.message}`
Sentry.captureException(errorMessage)
throw new Error(errorMessage)
246509
246510
246511
246512
246513
246514
246515
246516
246517
246518
246519
246520
246521
246522
246523
246524
246525
246526
246527
246528
246529
246530
246531
246532
246533
246534
246535
246536
246537
246538
246539
246540
246541
246542
246543
246544
246545
246546
246547
246548
246549
246550
246551
246552
246553
246554
246555
246556
246557
246558
246559
246560
246561
246562
246563
246564
246565
246566
246567
246568
246569
246570
246571
}
}
module.exports = { getAccountId, getAccountRev, getAccountSecret }
/***/ })
/******/ ]);
/************************************************************************/
/******/ // The module cache
/******/ var __webpack_module_cache__ = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/ // Check if module is in cache
/******/ var cachedModule = __webpack_module_cache__[moduleId];
/******/ if (cachedModule !== undefined) {
/******/ return cachedModule.exports;
/******/ }
/******/ // Create a new module (and put it into the cache)
/******/ var module = __webpack_module_cache__[moduleId] = {
/******/ id: moduleId,
/******/ loaded: false,
/******/ exports: {}
/******/ };
/******/
/******/ // Execute the module function
/******/ __webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = __webpack_module_cache__;
/******/
/************************************************************************/
/******/ /* webpack/runtime/compat get default export */
/******/ (() => {
/******/ // getDefaultExport function for compatibility with non-harmony modules
/******/ __webpack_require__.n = (module) => {
/******/ var getter = module && module.__esModule ?
/******/ () => (module['default']) :
/******/ () => (module);
/******/ __webpack_require__.d(getter, { a: getter });
/******/ return getter;
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/define property getters */
/******/ (() => {
/******/ // define getter functions for harmony exports
/******/ __webpack_require__.d = (exports, definition) => {
/******/ for(var key in definition) {
/******/ if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
/******/ Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
246572
246573
246574
246575
246576
246577
246578
246579
246580
246581
246582
246583
246584
246585
246586
/******/ /* webpack/runtime/harmony module decorator */
/******/ (() => {
/******/ __webpack_require__.hmd = (module) => {
/******/ module = Object.create(module);
/******/ if (!module.children) module.children = [];
/******/ Object.defineProperty(module, 'exports', {
/******/ enumerable: true,
/******/ set: () => {
/******/ throw new Error('ES Modules may not assign module.exports or exports.*, Use ESM export syntax, instead: ' + module.id);
/******/ }
/******/ });
/******/ return module;
/******/ };
/******/ })();
/******/
246587
246588
246589
246590
246591
246592
246593
246594
246595
246596
246597
246598
246599
246600
246601
246602
246603
246604
246605
246606
246607
246608
246609
246610
246611
246612
246613
246614
246615
246616
/******/ /* webpack/runtime/hasOwnProperty shorthand */
/******/ (() => {
/******/ __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
/******/ })();
/******/
/******/ /* webpack/runtime/make namespace object */
/******/ (() => {
/******/ // define __esModule on exports
/******/ __webpack_require__.r = (exports) => {
/******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
/******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
/******/ }
/******/ Object.defineProperty(exports, '__esModule', { value: true });
/******/ };
/******/ })();
/******/
/******/ /* webpack/runtime/node module decorator */
/******/ (() => {
/******/ __webpack_require__.nmd = (module) => {
/******/ module.paths = [];
/******/ if (!module.children) module.children = [];
/******/ return module;
/******/ };
/******/ })();
/******/
/************************************************************************/
/******/
/******/ // module cache are used so entry inlining is disabled
/******/ // startup
/******/ // Load entry module and return exports
/******/ var __webpack_exports__ = __webpack_require__(__webpack_require__.s = 1769);