Newer
Older
getAccountSecret,
getAccountId,
const { getBoConsent, deleteBoConsent } = __webpack_require__(1563)
const { terminateContract } = __webpack_require__(1684)
const { getAccountForDelete } = __webpack_require__(1691)
const moment = __webpack_require__(1379)
__webpack_require__(1516)
const { isLocal, isDev } = __webpack_require__(1692)
const Sentry = __webpack_require__(1601)
moment.locale('fr') // set the language
moment.tz.setDefault('Europe/Paris') // set the timezone
async function onDeleteAccount() {
241016
241017
241018
241019
241020
241021
241022
241023
241024
241025
241026
241027
241028
241029
241030
241031
241032
241033
241034
241035
241036
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
241054
241055
241056
241057
241058
241059
241060
241061
241062
241063
241064
241065
241066
241067
241068
241069
// 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 }
/***/ }),
/***/ ((module, __unused_webpack_exports, __webpack_require__) => {
const { log } = __webpack_require__(1)
const { isLocal } = __webpack_require__(1692)
const Sentry = __webpack_require__(1601)
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)
241151
241152
241153
241154
241155
241156
241157
241158
241159
241160
241161
241162
241163
241164
241165
241166
241167
241168
241169
241170
241171
241172
241173
241174
241175
241176
241177
241178
241179
241180
241181
241182
241183
241184
241185
241186
241187
241188
241189
241190
241191
241192
241193
241194
241195
241196
241197
241198
241199
241200
241201
241202
241203
241204
241205
241206
241207
241208
241209
241210
241211
241212
241213
}
}
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] });
/******/ }
/******/ }
/******/ };
/******/ })();
/******/
241214
241215
241216
241217
241218
241219
241220
241221
241222
241223
241224
241225
241226
241227
241228
/******/ /* 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;
/******/ };
/******/ })();
/******/
241229
241230
241231
241232
241233
241234
241235
241236
241237
241238
241239
241240
241241
241242
241243
241244
241245
241246
241247
241248
241249
241250
241251
241252
241253
241254
241255
241256
241257
241258
/******/ /* 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 = 1731);