From f06e4ec53354a5902b060eaf2479a87b0979e4c6 Mon Sep 17 00:00:00 2001 From: build-token <build-token> Date: Thu, 29 Sep 2022 03:12:32 +0000 Subject: [PATCH] publish: fix(deps): update dependency cozy-jobs-cli to v1.19.2 generated from commit e04e69c50448fa7b9f80ef8305cb38176fb66be7 --- index.js | 41 ++++++++++++---------------- onDeleteAccount.js | 68 ++++++++++++++-------------------------------- package.json | 6 ++-- 3 files changed, 41 insertions(+), 74 deletions(-) diff --git a/index.js b/index.js index 24e6273..87d4454 100644 --- a/index.js +++ b/index.js @@ -173,6 +173,7 @@ async function start(fields, cozyParameters) { await saveAccountData(this.accountId, { ...accountData.data, consentId: consent.ID, + inseeCode: user.inseeCode, }) } else { log('info', 'Alternate start...') @@ -187,7 +188,8 @@ async function start(fields, cozyParameters) { baseUrl, apiAuthKey, sgeLogin, - true + true, + accountData.data.inseeCode ) if (!userConsent) { @@ -228421,9 +228423,14 @@ async function verifyUserIdentity( baseUrl, apiAuthKey, loginUtilisateur, - isAlternateStart = false + isAlternateStart = false, + inseeCode = '' ) { - const inseeCode = await getInseeCode(fields.postalCode, fields.city) + // If first start get InseeCode + log('debug', 'verifyUserIdentity') + if (!isAlternateStart) { + inseeCode = await getInseeCode(fields.postalCode, fields.city) + } const pdl = await findUserPdl( `${baseUrl}/enedis_SDE_recherche-point/1.0`, @@ -228522,6 +228529,11 @@ async function saveAccountData(accountId, accountData) { return 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') @@ -228530,18 +228542,7 @@ async function getAccount(accountId) { )[0] } -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 } +module.exports = { getAccount, saveAccountData } /***/ }), @@ -228556,15 +228557,7 @@ function isLocal() { ) } -/** - * Verify if it's an alpha URL - * @returns {boolean} - */ -function isAlpha() { - return process.env.COZY_URL.includes('alpha') -} - -module.exports = { isLocal, isAlpha } +module.exports = { isLocal } /***/ }) diff --git a/onDeleteAccount.js b/onDeleteAccount.js index b77b00b..db90e76 100644 --- a/onDeleteAccount.js +++ b/onDeleteAccount.js @@ -227423,6 +227423,11 @@ async function saveAccountData(accountId, accountData) { return 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') @@ -227431,18 +227436,7 @@ async function getAccount(accountId) { )[0] } -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 } +module.exports = { getAccount, saveAccountData } /***/ }), @@ -227457,15 +227451,7 @@ function isLocal() { ) } -/** - * Verify if it's an alpha URL - * @returns {boolean} - */ -function isAlpha() { - return process.env.COZY_URL.includes('alpha') -} - -module.exports = { isLocal, isAlpha } +module.exports = { isLocal } /***/ }), @@ -227474,33 +227460,28 @@ module.exports = { isLocal, isAlpha } // @ts-check const { log, errors } = __webpack_require__(1) -const { - getAccountRev, - getAccountSecret, - getAccountId, -} = __webpack_require__(1607) +const { getAccountRev, getAccountSecret } = __webpack_require__(1607) const { getBoConsent, deleteBoConsent } = __webpack_require__(1557) const { terminateContract } = __webpack_require__(1598) -const { getAccountForDelete } = __webpack_require__(1604) +const { getAccount } = __webpack_require__(1604) const moment = __webpack_require__(1373) __webpack_require__(1510) moment.locale('fr') // set the language moment.tz.setDefault('Europe/Paris') // set the timezone -const { isLocal, isAlpha } = __webpack_require__(1605) -// const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedis-sge-grandlyon' +const { isLocal } = __webpack_require__(1605) +const ACCOUNT_ID = isLocal() ? 'default_account_id' : 'enedis-sge-grandlyon' async function onDeleteAccount() { 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) + const accountData = await getAccount(ACCOUNT_ID) // Parse local info for deletion test if (isLocal()) { - log('warn', 'Local run') const fields = JSON.parse( process.env.COZY_FIELDS ? process.env.COZY_FIELDS : '{}' ) @@ -227516,8 +227497,6 @@ async function onDeleteAccount() { accountData.data.consentId ) - log('info', `isAlpha: ${isAlpha()}`) - log('info', `userConsent: ${JSON.stringify(userConsent)}`) if (userConsent.ID && userConsent.pointID) { log('log', `Consent ${userConsent.ID} found for user`) if (userConsent.serviceID) { @@ -227526,17 +227505,14 @@ async function onDeleteAccount() { secrets.boToken, userConsent.ID ) - // Verify if it's dev env to prevent delete of real data - if (!isAlpha()) { - await terminateContract( - secrets.wso2BaseUrl, - secrets.apiToken, - secrets.sgeLogin, - secrets.contractId, - userConsent.pointID, - userConsent.serviceID - ) - } + await terminateContract( + secrets.wso2BaseUrl, + secrets.apiToken, + secrets.sgeLogin, + secrets.contractId, + userConsent.pointID, + userConsent.serviceID + ) } else { log('error', `No service id retrieved from BO`) throw errors.VENDOR_DOWN @@ -227587,7 +227563,6 @@ function getAccountId() { function getAccountRev() { log('info', `getAccountRev`) - log('info', `getAccountRev: ${JSON.stringify(process.env.COZY_FIELDS)}`) try { return isLocal() ? 'fakeAccountRev' @@ -227603,7 +227578,6 @@ function getAccountRev() { * @returns {Fields} */ function getAccountSecret() { - log('info', `getAccountSecret`) try { return isLocal() ? JSON.parse(process.env.COZY_FIELDS) diff --git a/package.json b/package.json index 3bab086..2e0bba1 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { - "name": "enedissgekonnector", - "version": "1.0.1", + "name": "enedis-sge-konnector", + "version": "1.0.0", "description": "", "repository": { "type": "https", @@ -54,7 +54,7 @@ "xml2js": "^0.4.23" }, "devDependencies": { - "cozy-jobs-cli": "1.19.1", + "cozy-jobs-cli": "1.19.2", "cozy-konnector-build": "1.3.4", "eslint-config-cozy-app": "1.3.3", "eslint-plugin-prettier": "^4.0.0", -- GitLab