diff --git a/1.index.js b/1.index.js index e9dbdc035c153c898fa6f95dfecba0d41e9e5894..81aa8c5746e929c57301d04e96adfa42f346a5ac 100644 --- a/1.index.js +++ b/1.index.js @@ -3,7 +3,7 @@ exports.id = 1; exports.ids = [1]; exports.modules = { -/***/ 2154: +/***/ 2149: /***/ (function(__unused_webpack_module, exports, __webpack_require__) { @@ -19,7 +19,7 @@ exports.FetchInstrumentation = void 0; * compliance with the BSD 2-Clause License. * */ -const node_diagnostics_channel_1 = __importDefault(__webpack_require__(2155)); +const node_diagnostics_channel_1 = __importDefault(__webpack_require__(2150)); const semantic_conventions_1 = __webpack_require__(195); const api_1 = __webpack_require__(59); function getMessage(error) { diff --git a/index.js b/index.js index 51f72fecfc941b041076b6f55fd965521e6977d2..01a24ada332abe03dc48f88798c19a2a225960f7 100644 --- a/index.js +++ b/index.js @@ -18,16 +18,17 @@ __webpack_require__(2133) moment.locale('fr') // set the language moment.tz.setDefault('Europe/Paris') // set the timezone const Sentry = __webpack_require__(2) -const { getAuthToken, getConsents } = __webpack_require__(2136) -const { handleConsents, createConsent } = __webpack_require__(2148) -const { rangeDate } = __webpack_require__(2151) +const { getConsents } = __webpack_require__(2136) +const { handleConsents, createConsent } = __webpack_require__(2143) +const { rangeDate } = __webpack_require__(2146) const { aggregateMonthlyLoad, filterFirstMonthlyLoad, aggregateYearlyLoad, filterFirstYearlyLoad, -} = __webpack_require__(2152) -const { formatData } = __webpack_require__(2153) +} = __webpack_require__(2147) +const { formatData } = __webpack_require__(2148) +const { getGRDFAccessToken } = __webpack_require__(2145) const NO_DATA = process.env.NO_DATA === 'true' const manualExecution = process.env.COZY_JOB_MANUAL_EXECUTION === 'true' @@ -70,15 +71,11 @@ async function start(fields, cozyParameters) { let boToken = '' let boBaseUrl = '' - let grdfId = '' - let grdfSecret = '' if (cozyParameters && Object.keys(cozyParameters).length !== 0) { log('debug', 'Found COZY_PARAMETERS') boToken = cozyParameters.secret.boToken boBaseUrl = cozyParameters.secret.boBaseUrl - grdfId = cozyParameters.secret.client_id - grdfSecret = cozyParameters.secret.client_secret } const boUrlGRDF = new URL('/api/grdf', boBaseUrl).href @@ -88,7 +85,7 @@ async function start(fields, cozyParameters) { throw errors.USER_ACTION_NEEDED } log('info', `using PCE: ${pce}`) - const { access_token } = await getAuthToken(grdfId, grdfSecret) + const { access_token } = await getGRDFAccessToken(boUrlGRDF, boToken) const consents = await getConsents(access_token, pce) const noValidConsent = await handleConsents(consents, boUrlGRDF, boToken) @@ -42090,7 +42087,7 @@ const _nativeNodeFetchIntegration = ((options = {}) => { } try { - const pkg = await __webpack_require__.e(/* import() */ 1).then(__webpack_require__.t.bind(__webpack_require__, 2154, 23)); + const pkg = await __webpack_require__.e(/* import() */ 1).then(__webpack_require__.t.bind(__webpack_require__, 2149, 23)); const { FetchInstrumentation } = pkg; class SentryNodeFetchInstrumentation extends FetchInstrumentation { @@ -43287,7 +43284,7 @@ const localVariablesAsyncIntegration = core.defineIntegration((( async function startInspector() { // We load inspector dynamically because on some platforms Node is built without inspector support - const inspector = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 2156, 23)); + const inspector = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 2151, 23)); if (!inspector.url()) { inspector.open(0); } @@ -43530,7 +43527,7 @@ class AsyncSession { return orDefault; } - const inspector = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 2156, 23)); + const inspector = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 2151, 23)); return new AsyncSession(new inspector.Session()); } @@ -44395,7 +44392,7 @@ async function _startWorker( }; if (options.captureStackTrace) { - const inspector = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 2156, 23)); + const inspector = await Promise.resolve(/* import() */).then(__webpack_require__.t.bind(__webpack_require__, 2151, 23)); if (!inspector.url()) { inspector.open(0); } @@ -57353,7 +57350,7 @@ exports.instrumentNodeSchedule = instrumentNodeSchedule; /***/ ((module) => { "use strict"; -module.exports = JSON.parse('{"name":"grdf","version":"2.0.3","engines":{"node":">=16.0.0"},"description":"","repository":{"type":"git","url":"https://forge.grandlyon.com/web-et-numerique/llle_project/grdf-konnector.git"},"keywords":[],"author":"Grand Lyon","license":"AGPL-3.0","main":"./src/index.js","jest":{"setupFiles":["./setupTests.js"]},"scripts":{"start":"node ./src/index.js","dev":"cozy-konnector-dev","standalone":"COZY_JOB_MANUAL_EXECUTION=true cozy-konnector-standalone","standalone-no-data":"NO_DATA=true cozy-konnector-standalone src/index.js","onDeleteAccount:standalone":"cozy-konnector-standalone src/onDeleteAccount.js","onDeleteAccount":"cozy-konnector-dev src/onDeleteAccount.js","pretest":"npm run clean","test:cov":"jest --coverage","test":"jest","release":"standard-version --no-verify","clean":"rm -rf ./data","build":"webpack","lint":"eslint --fix .","deploy":"git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build}","deploy-dev":"git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build-dev}","deploy-test":"git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build-test}","travisDeployKey":"./bin/generate_travis_deploy_key"},"dependencies":{"@sentry/node":"^8.17.0","@sentry/tracing":"^7.113.0","axios":"^1.7.2","cozy-client":"48.7.0","cozy-konnector-libs":"5.11.0","moment":"^2.30.1","moment-timezone":"^0.5.45","qs":"^6.12.1"},"devDependencies":{"cozy-jobs-cli":"2.4.2","cozy-konnector-build":"1.7.0","jest":"^29.7.0","jest-junit":"^16.0.0","standard-version":"^9.5.0"}}'); +module.exports = JSON.parse('{"name":"grdf","version":"2.0.3","engines":{"node":">=16.0.0"},"description":"","repository":{"type":"git","url":"https://forge.grandlyon.com/web-et-numerique/llle_project/grdf-konnector.git"},"keywords":[],"author":"Grand Lyon","license":"AGPL-3.0","main":"./src/index.js","jest":{"setupFiles":["./setupTests.js"]},"scripts":{"start":"node ./src/index.js","dev":"cozy-konnector-dev","standalone":"COZY_JOB_MANUAL_EXECUTION=true cozy-konnector-standalone","standalone-no-data":"NO_DATA=true cozy-konnector-standalone src/index.js","onDeleteAccount:standalone":"cozy-konnector-standalone src/onDeleteAccount.js","onDeleteAccount":"cozy-konnector-dev src/onDeleteAccount.js","pretest":"npm run clean","test:cov":"jest --coverage","test":"jest","release":"standard-version --no-verify","clean":"rm -rf ./data","build":"webpack","lint":"eslint --fix .","deploy":"git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build}","deploy-dev":"git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build-dev}","deploy-test":"git-directory-deploy --directory build/ --branch ${DEPLOY_BRANCH:-build-test}","travisDeployKey":"./bin/generate_travis_deploy_key"},"dependencies":{"@sentry/node":"^8.17.0","@sentry/tracing":"^7.113.0","axios":"^1.7.2","cozy-client":"48.7.0","cozy-konnector-libs":"5.11.0","moment":"^2.30.1","moment-timezone":"^0.5.45"},"devDependencies":{"cozy-jobs-cli":"2.4.2","cozy-konnector-build":"1.7.0","jest":"^29.7.0","jest-junit":"^16.0.0","standard-version":"^9.5.0"}}'); /***/ }), /* 593 */ @@ -276118,43 +276115,8 @@ module.exports = JSON.parse('{"version":"2024a","zones":["Africa/Abidjan|LMT GMT // @ts-check const { default: Axios } = __webpack_require__(2137) const { errors, log } = __webpack_require__(594) -const qs = __webpack_require__(2143) const Sentry = __webpack_require__(2) -/** - * - * @param {string} client_id - * @param {string} client_secret - * @returns {Promise<{ access_token: string, scope: string, token_type: string, expires_in: number }>} - */ -async function getAuthToken(client_id, client_secret) { - log('info', 'getAuthToken') - const body = { - scope: '/adict/v2', - grant_type: 'client_credentials', - client_id: client_id, - client_secret: client_secret, - } - try { - const response = await Axios({ - method: 'POST', - url: 'https://adict-connexion.grdf.fr/oauth2/aus5y2ta2uEHjCWIR417/v1/token', - headers: { 'content-type': 'application/x-www-form-urlencoded' }, - data: qs.stringify(body), - }) - - return response.data - } catch (error) { - log('error', 'Error inside getAuthToken', error) - Sentry.captureException('Error while getting auth token', { - tags: { - section: 'getAuthToken', - }, - }) - throw errors.VENDOR_DOWN - } -} - /** * * @param {string} bearerToken @@ -276244,7 +276206,7 @@ async function createGRDFConsent({ } } -module.exports = { createGRDFConsent, getAuthToken, getConsents } +module.exports = { createGRDFConsent, getConsents } /***/ }), @@ -282300,987 +282262,11 @@ module.exports = function () { /* 2143 */ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { -"use strict"; - - -var stringify = __webpack_require__(2144); -var parse = __webpack_require__(2147); -var formats = __webpack_require__(2146); - -module.exports = { - formats: formats, - parse: parse, - stringify: stringify -}; - - -/***/ }), -/* 2144 */ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; - - -var getSideChannel = __webpack_require__(913); -var utils = __webpack_require__(2145); -var formats = __webpack_require__(2146); -var has = Object.prototype.hasOwnProperty; - -var arrayPrefixGenerators = { - brackets: function brackets(prefix) { - return prefix + '[]'; - }, - comma: 'comma', - indices: function indices(prefix, key) { - return prefix + '[' + key + ']'; - }, - repeat: function repeat(prefix) { - return prefix; - } -}; - -var isArray = Array.isArray; -var push = Array.prototype.push; -var pushToArray = function (arr, valueOrArray) { - push.apply(arr, isArray(valueOrArray) ? valueOrArray : [valueOrArray]); -}; - -var toISO = Date.prototype.toISOString; - -var defaultFormat = formats['default']; -var defaults = { - addQueryPrefix: false, - allowDots: false, - allowEmptyArrays: false, - arrayFormat: 'indices', - charset: 'utf-8', - charsetSentinel: false, - delimiter: '&', - encode: true, - encodeDotInKeys: false, - encoder: utils.encode, - encodeValuesOnly: false, - format: defaultFormat, - formatter: formats.formatters[defaultFormat], - // deprecated - indices: false, - serializeDate: function serializeDate(date) { - return toISO.call(date); - }, - skipNulls: false, - strictNullHandling: false -}; - -var isNonNullishPrimitive = function isNonNullishPrimitive(v) { - return typeof v === 'string' - || typeof v === 'number' - || typeof v === 'boolean' - || typeof v === 'symbol' - || typeof v === 'bigint'; -}; - -var sentinel = {}; - -var stringify = function stringify( - object, - prefix, - generateArrayPrefix, - commaRoundTrip, - allowEmptyArrays, - strictNullHandling, - skipNulls, - encodeDotInKeys, - encoder, - filter, - sort, - allowDots, - serializeDate, - format, - formatter, - encodeValuesOnly, - charset, - sideChannel -) { - var obj = object; - - var tmpSc = sideChannel; - var step = 0; - var findFlag = false; - while ((tmpSc = tmpSc.get(sentinel)) !== void undefined && !findFlag) { - // Where object last appeared in the ref tree - var pos = tmpSc.get(object); - step += 1; - if (typeof pos !== 'undefined') { - if (pos === step) { - throw new RangeError('Cyclic object value'); - } else { - findFlag = true; // Break while - } - } - if (typeof tmpSc.get(sentinel) === 'undefined') { - step = 0; - } - } - - if (typeof filter === 'function') { - obj = filter(prefix, obj); - } else if (obj instanceof Date) { - obj = serializeDate(obj); - } else if (generateArrayPrefix === 'comma' && isArray(obj)) { - obj = utils.maybeMap(obj, function (value) { - if (value instanceof Date) { - return serializeDate(value); - } - return value; - }); - } - - if (obj === null) { - if (strictNullHandling) { - return encoder && !encodeValuesOnly ? encoder(prefix, defaults.encoder, charset, 'key', format) : prefix; - } - - obj = ''; - } - - if (isNonNullishPrimitive(obj) || utils.isBuffer(obj)) { - if (encoder) { - var keyValue = encodeValuesOnly ? prefix : encoder(prefix, defaults.encoder, charset, 'key', format); - return [formatter(keyValue) + '=' + formatter(encoder(obj, defaults.encoder, charset, 'value', format))]; - } - return [formatter(prefix) + '=' + formatter(String(obj))]; - } - - var values = []; - - if (typeof obj === 'undefined') { - return values; - } - - var objKeys; - if (generateArrayPrefix === 'comma' && isArray(obj)) { - // we need to join elements in - if (encodeValuesOnly && encoder) { - obj = utils.maybeMap(obj, encoder); - } - objKeys = [{ value: obj.length > 0 ? obj.join(',') || null : void undefined }]; - } else if (isArray(filter)) { - objKeys = filter; - } else { - var keys = Object.keys(obj); - objKeys = sort ? keys.sort(sort) : keys; - } - - var encodedPrefix = encodeDotInKeys ? prefix.replace(/\./g, '%2E') : prefix; - - var adjustedPrefix = commaRoundTrip && isArray(obj) && obj.length === 1 ? encodedPrefix + '[]' : encodedPrefix; - - if (allowEmptyArrays && isArray(obj) && obj.length === 0) { - return adjustedPrefix + '[]'; - } - - for (var j = 0; j < objKeys.length; ++j) { - var key = objKeys[j]; - var value = typeof key === 'object' && typeof key.value !== 'undefined' ? key.value : obj[key]; - - if (skipNulls && value === null) { - continue; - } - - var encodedKey = allowDots && encodeDotInKeys ? key.replace(/\./g, '%2E') : key; - var keyPrefix = isArray(obj) - ? typeof generateArrayPrefix === 'function' ? generateArrayPrefix(adjustedPrefix, encodedKey) : adjustedPrefix - : adjustedPrefix + (allowDots ? '.' + encodedKey : '[' + encodedKey + ']'); - - sideChannel.set(object, step); - var valueSideChannel = getSideChannel(); - valueSideChannel.set(sentinel, sideChannel); - pushToArray(values, stringify( - value, - keyPrefix, - generateArrayPrefix, - commaRoundTrip, - allowEmptyArrays, - strictNullHandling, - skipNulls, - encodeDotInKeys, - generateArrayPrefix === 'comma' && encodeValuesOnly && isArray(obj) ? null : encoder, - filter, - sort, - allowDots, - serializeDate, - format, - formatter, - encodeValuesOnly, - charset, - valueSideChannel - )); - } - - return values; -}; - -var normalizeStringifyOptions = function normalizeStringifyOptions(opts) { - if (!opts) { - return defaults; - } - - if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') { - throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided'); - } - - if (typeof opts.encodeDotInKeys !== 'undefined' && typeof opts.encodeDotInKeys !== 'boolean') { - throw new TypeError('`encodeDotInKeys` option can only be `true` or `false`, when provided'); - } - - if (opts.encoder !== null && typeof opts.encoder !== 'undefined' && typeof opts.encoder !== 'function') { - throw new TypeError('Encoder has to be a function.'); - } - - var charset = opts.charset || defaults.charset; - if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { - throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); - } - - var format = formats['default']; - if (typeof opts.format !== 'undefined') { - if (!has.call(formats.formatters, opts.format)) { - throw new TypeError('Unknown format option provided.'); - } - format = opts.format; - } - var formatter = formats.formatters[format]; - - var filter = defaults.filter; - if (typeof opts.filter === 'function' || isArray(opts.filter)) { - filter = opts.filter; - } - - var arrayFormat; - if (opts.arrayFormat in arrayPrefixGenerators) { - arrayFormat = opts.arrayFormat; - } else if ('indices' in opts) { - arrayFormat = opts.indices ? 'indices' : 'repeat'; - } else { - arrayFormat = defaults.arrayFormat; - } - - if ('commaRoundTrip' in opts && typeof opts.commaRoundTrip !== 'boolean') { - throw new TypeError('`commaRoundTrip` must be a boolean, or absent'); - } - - var allowDots = typeof opts.allowDots === 'undefined' ? opts.encodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots; - - return { - addQueryPrefix: typeof opts.addQueryPrefix === 'boolean' ? opts.addQueryPrefix : defaults.addQueryPrefix, - allowDots: allowDots, - allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays, - arrayFormat: arrayFormat, - charset: charset, - charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, - commaRoundTrip: opts.commaRoundTrip, - delimiter: typeof opts.delimiter === 'undefined' ? defaults.delimiter : opts.delimiter, - encode: typeof opts.encode === 'boolean' ? opts.encode : defaults.encode, - encodeDotInKeys: typeof opts.encodeDotInKeys === 'boolean' ? opts.encodeDotInKeys : defaults.encodeDotInKeys, - encoder: typeof opts.encoder === 'function' ? opts.encoder : defaults.encoder, - encodeValuesOnly: typeof opts.encodeValuesOnly === 'boolean' ? opts.encodeValuesOnly : defaults.encodeValuesOnly, - filter: filter, - format: format, - formatter: formatter, - serializeDate: typeof opts.serializeDate === 'function' ? opts.serializeDate : defaults.serializeDate, - skipNulls: typeof opts.skipNulls === 'boolean' ? opts.skipNulls : defaults.skipNulls, - sort: typeof opts.sort === 'function' ? opts.sort : null, - strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling - }; -}; - -module.exports = function (object, opts) { - var obj = object; - var options = normalizeStringifyOptions(opts); - - var objKeys; - var filter; - - if (typeof options.filter === 'function') { - filter = options.filter; - obj = filter('', obj); - } else if (isArray(options.filter)) { - filter = options.filter; - objKeys = filter; - } - - var keys = []; - - if (typeof obj !== 'object' || obj === null) { - return ''; - } - - var generateArrayPrefix = arrayPrefixGenerators[options.arrayFormat]; - var commaRoundTrip = generateArrayPrefix === 'comma' && options.commaRoundTrip; - - if (!objKeys) { - objKeys = Object.keys(obj); - } - - if (options.sort) { - objKeys.sort(options.sort); - } - - var sideChannel = getSideChannel(); - for (var i = 0; i < objKeys.length; ++i) { - var key = objKeys[i]; - - if (options.skipNulls && obj[key] === null) { - continue; - } - pushToArray(keys, stringify( - obj[key], - key, - generateArrayPrefix, - commaRoundTrip, - options.allowEmptyArrays, - options.strictNullHandling, - options.skipNulls, - options.encodeDotInKeys, - options.encode ? options.encoder : null, - options.filter, - options.sort, - options.allowDots, - options.serializeDate, - options.format, - options.formatter, - options.encodeValuesOnly, - options.charset, - sideChannel - )); - } - - var joined = keys.join(options.delimiter); - var prefix = options.addQueryPrefix === true ? '?' : ''; - - if (options.charsetSentinel) { - if (options.charset === 'iso-8859-1') { - // encodeURIComponent('✓'), the "numeric entity" representation of a checkmark - prefix += 'utf8=%26%2310003%3B&'; - } else { - // encodeURIComponent('✓') - prefix += 'utf8=%E2%9C%93&'; - } - } - - return joined.length > 0 ? prefix + joined : ''; -}; - - -/***/ }), -/* 2145 */ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; - - -var formats = __webpack_require__(2146); - -var has = Object.prototype.hasOwnProperty; -var isArray = Array.isArray; - -var hexTable = (function () { - var array = []; - for (var i = 0; i < 256; ++i) { - array.push('%' + ((i < 16 ? '0' : '') + i.toString(16)).toUpperCase()); - } - - return array; -}()); - -var compactQueue = function compactQueue(queue) { - while (queue.length > 1) { - var item = queue.pop(); - var obj = item.obj[item.prop]; - - if (isArray(obj)) { - var compacted = []; - - for (var j = 0; j < obj.length; ++j) { - if (typeof obj[j] !== 'undefined') { - compacted.push(obj[j]); - } - } - - item.obj[item.prop] = compacted; - } - } -}; - -var arrayToObject = function arrayToObject(source, options) { - var obj = options && options.plainObjects ? Object.create(null) : {}; - for (var i = 0; i < source.length; ++i) { - if (typeof source[i] !== 'undefined') { - obj[i] = source[i]; - } - } - - return obj; -}; - -var merge = function merge(target, source, options) { - /* eslint no-param-reassign: 0 */ - if (!source) { - return target; - } - - if (typeof source !== 'object') { - if (isArray(target)) { - target.push(source); - } else if (target && typeof target === 'object') { - if ((options && (options.plainObjects || options.allowPrototypes)) || !has.call(Object.prototype, source)) { - target[source] = true; - } - } else { - return [target, source]; - } - - return target; - } - - if (!target || typeof target !== 'object') { - return [target].concat(source); - } - - var mergeTarget = target; - if (isArray(target) && !isArray(source)) { - mergeTarget = arrayToObject(target, options); - } - - if (isArray(target) && isArray(source)) { - source.forEach(function (item, i) { - if (has.call(target, i)) { - var targetItem = target[i]; - if (targetItem && typeof targetItem === 'object' && item && typeof item === 'object') { - target[i] = merge(targetItem, item, options); - } else { - target.push(item); - } - } else { - target[i] = item; - } - }); - return target; - } - - return Object.keys(source).reduce(function (acc, key) { - var value = source[key]; - - if (has.call(acc, key)) { - acc[key] = merge(acc[key], value, options); - } else { - acc[key] = value; - } - return acc; - }, mergeTarget); -}; - -var assign = function assignSingleSource(target, source) { - return Object.keys(source).reduce(function (acc, key) { - acc[key] = source[key]; - return acc; - }, target); -}; - -var decode = function (str, decoder, charset) { - var strWithoutPlus = str.replace(/\+/g, ' '); - if (charset === 'iso-8859-1') { - // unescape never throws, no try...catch needed: - return strWithoutPlus.replace(/%[0-9a-f]{2}/gi, unescape); - } - // utf-8 - try { - return decodeURIComponent(strWithoutPlus); - } catch (e) { - return strWithoutPlus; - } -}; - -var limit = 1024; - -/* eslint operator-linebreak: [2, "before"] */ - -var encode = function encode(str, defaultEncoder, charset, kind, format) { - // This code was originally written by Brian White (mscdex) for the io.js core querystring library. - // It has been adapted here for stricter adherence to RFC 3986 - if (str.length === 0) { - return str; - } - - var string = str; - if (typeof str === 'symbol') { - string = Symbol.prototype.toString.call(str); - } else if (typeof str !== 'string') { - string = String(str); - } - - if (charset === 'iso-8859-1') { - return escape(string).replace(/%u[0-9a-f]{4}/gi, function ($0) { - return '%26%23' + parseInt($0.slice(2), 16) + '%3B'; - }); - } - - var out = ''; - for (var j = 0; j < string.length; j += limit) { - var segment = string.length >= limit ? string.slice(j, j + limit) : string; - var arr = []; - - for (var i = 0; i < segment.length; ++i) { - var c = segment.charCodeAt(i); - if ( - c === 0x2D // - - || c === 0x2E // . - || c === 0x5F // _ - || c === 0x7E // ~ - || (c >= 0x30 && c <= 0x39) // 0-9 - || (c >= 0x41 && c <= 0x5A) // a-z - || (c >= 0x61 && c <= 0x7A) // A-Z - || (format === formats.RFC1738 && (c === 0x28 || c === 0x29)) // ( ) - ) { - arr[arr.length] = segment.charAt(i); - continue; - } - - if (c < 0x80) { - arr[arr.length] = hexTable[c]; - continue; - } - - if (c < 0x800) { - arr[arr.length] = hexTable[0xC0 | (c >> 6)] - + hexTable[0x80 | (c & 0x3F)]; - continue; - } - - if (c < 0xD800 || c >= 0xE000) { - arr[arr.length] = hexTable[0xE0 | (c >> 12)] - + hexTable[0x80 | ((c >> 6) & 0x3F)] - + hexTable[0x80 | (c & 0x3F)]; - continue; - } - - i += 1; - c = 0x10000 + (((c & 0x3FF) << 10) | (segment.charCodeAt(i) & 0x3FF)); - - arr[arr.length] = hexTable[0xF0 | (c >> 18)] - + hexTable[0x80 | ((c >> 12) & 0x3F)] - + hexTable[0x80 | ((c >> 6) & 0x3F)] - + hexTable[0x80 | (c & 0x3F)]; - } - - out += arr.join(''); - } - - return out; -}; - -var compact = function compact(value) { - var queue = [{ obj: { o: value }, prop: 'o' }]; - var refs = []; - - for (var i = 0; i < queue.length; ++i) { - var item = queue[i]; - var obj = item.obj[item.prop]; - - var keys = Object.keys(obj); - for (var j = 0; j < keys.length; ++j) { - var key = keys[j]; - var val = obj[key]; - if (typeof val === 'object' && val !== null && refs.indexOf(val) === -1) { - queue.push({ obj: obj, prop: key }); - refs.push(val); - } - } - } - - compactQueue(queue); - - return value; -}; - -var isRegExp = function isRegExp(obj) { - return Object.prototype.toString.call(obj) === '[object RegExp]'; -}; - -var isBuffer = function isBuffer(obj) { - if (!obj || typeof obj !== 'object') { - return false; - } - - return !!(obj.constructor && obj.constructor.isBuffer && obj.constructor.isBuffer(obj)); -}; - -var combine = function combine(a, b) { - return [].concat(a, b); -}; - -var maybeMap = function maybeMap(val, fn) { - if (isArray(val)) { - var mapped = []; - for (var i = 0; i < val.length; i += 1) { - mapped.push(fn(val[i])); - } - return mapped; - } - return fn(val); -}; - -module.exports = { - arrayToObject: arrayToObject, - assign: assign, - combine: combine, - compact: compact, - decode: decode, - encode: encode, - isBuffer: isBuffer, - isRegExp: isRegExp, - maybeMap: maybeMap, - merge: merge -}; - - -/***/ }), -/* 2146 */ -/***/ ((module) => { - -"use strict"; - - -var replace = String.prototype.replace; -var percentTwenties = /%20/g; - -var Format = { - RFC1738: 'RFC1738', - RFC3986: 'RFC3986' -}; - -module.exports = { - 'default': Format.RFC3986, - formatters: { - RFC1738: function (value) { - return replace.call(value, percentTwenties, '+'); - }, - RFC3986: function (value) { - return String(value); - } - }, - RFC1738: Format.RFC1738, - RFC3986: Format.RFC3986 -}; - - -/***/ }), -/* 2147 */ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - -"use strict"; - - -var utils = __webpack_require__(2145); - -var has = Object.prototype.hasOwnProperty; -var isArray = Array.isArray; - -var defaults = { - allowDots: false, - allowEmptyArrays: false, - allowPrototypes: false, - allowSparse: false, - arrayLimit: 20, - charset: 'utf-8', - charsetSentinel: false, - comma: false, - decodeDotInKeys: false, - decoder: utils.decode, - delimiter: '&', - depth: 5, - duplicates: 'combine', - ignoreQueryPrefix: false, - interpretNumericEntities: false, - parameterLimit: 1000, - parseArrays: true, - plainObjects: false, - strictNullHandling: false -}; - -var interpretNumericEntities = function (str) { - return str.replace(/&#(\d+);/g, function ($0, numberStr) { - return String.fromCharCode(parseInt(numberStr, 10)); - }); -}; - -var parseArrayValue = function (val, options) { - if (val && typeof val === 'string' && options.comma && val.indexOf(',') > -1) { - return val.split(','); - } - - return val; -}; - -// This is what browsers will submit when the ✓ character occurs in an -// application/x-www-form-urlencoded body and the encoding of the page containing -// the form is iso-8859-1, or when the submitted form has an accept-charset -// attribute of iso-8859-1. Presumably also with other charsets that do not contain -// the ✓ character, such as us-ascii. -var isoSentinel = 'utf8=%26%2310003%3B'; // encodeURIComponent('✓') - -// These are the percent-encoded utf-8 octets representing a checkmark, indicating that the request actually is utf-8 encoded. -var charsetSentinel = 'utf8=%E2%9C%93'; // encodeURIComponent('✓') - -var parseValues = function parseQueryStringValues(str, options) { - var obj = { __proto__: null }; - - var cleanStr = options.ignoreQueryPrefix ? str.replace(/^\?/, '') : str; - cleanStr = cleanStr.replace(/%5B/gi, '[').replace(/%5D/gi, ']'); - var limit = options.parameterLimit === Infinity ? undefined : options.parameterLimit; - var parts = cleanStr.split(options.delimiter, limit); - var skipIndex = -1; // Keep track of where the utf8 sentinel was found - var i; - - var charset = options.charset; - if (options.charsetSentinel) { - for (i = 0; i < parts.length; ++i) { - if (parts[i].indexOf('utf8=') === 0) { - if (parts[i] === charsetSentinel) { - charset = 'utf-8'; - } else if (parts[i] === isoSentinel) { - charset = 'iso-8859-1'; - } - skipIndex = i; - i = parts.length; // The eslint settings do not allow break; - } - } - } - - for (i = 0; i < parts.length; ++i) { - if (i === skipIndex) { - continue; - } - var part = parts[i]; - - var bracketEqualsPos = part.indexOf(']='); - var pos = bracketEqualsPos === -1 ? part.indexOf('=') : bracketEqualsPos + 1; - - var key, val; - if (pos === -1) { - key = options.decoder(part, defaults.decoder, charset, 'key'); - val = options.strictNullHandling ? null : ''; - } else { - key = options.decoder(part.slice(0, pos), defaults.decoder, charset, 'key'); - val = utils.maybeMap( - parseArrayValue(part.slice(pos + 1), options), - function (encodedVal) { - return options.decoder(encodedVal, defaults.decoder, charset, 'value'); - } - ); - } - - if (val && options.interpretNumericEntities && charset === 'iso-8859-1') { - val = interpretNumericEntities(val); - } - - if (part.indexOf('[]=') > -1) { - val = isArray(val) ? [val] : val; - } - - var existing = has.call(obj, key); - if (existing && options.duplicates === 'combine') { - obj[key] = utils.combine(obj[key], val); - } else if (!existing || options.duplicates === 'last') { - obj[key] = val; - } - } - - return obj; -}; - -var parseObject = function (chain, val, options, valuesParsed) { - var leaf = valuesParsed ? val : parseArrayValue(val, options); - - for (var i = chain.length - 1; i >= 0; --i) { - var obj; - var root = chain[i]; - - if (root === '[]' && options.parseArrays) { - obj = options.allowEmptyArrays && (leaf === '' || (options.strictNullHandling && leaf === null)) - ? [] - : [].concat(leaf); - } else { - obj = options.plainObjects ? Object.create(null) : {}; - var cleanRoot = root.charAt(0) === '[' && root.charAt(root.length - 1) === ']' ? root.slice(1, -1) : root; - var decodedRoot = options.decodeDotInKeys ? cleanRoot.replace(/%2E/g, '.') : cleanRoot; - var index = parseInt(decodedRoot, 10); - if (!options.parseArrays && decodedRoot === '') { - obj = { 0: leaf }; - } else if ( - !isNaN(index) - && root !== decodedRoot - && String(index) === decodedRoot - && index >= 0 - && (options.parseArrays && index <= options.arrayLimit) - ) { - obj = []; - obj[index] = leaf; - } else if (decodedRoot !== '__proto__') { - obj[decodedRoot] = leaf; - } - } - - leaf = obj; - } - - return leaf; -}; - -var parseKeys = function parseQueryStringKeys(givenKey, val, options, valuesParsed) { - if (!givenKey) { - return; - } - - // Transform dot notation to bracket notation - var key = options.allowDots ? givenKey.replace(/\.([^.[]+)/g, '[$1]') : givenKey; - - // The regex chunks - - var brackets = /(\[[^[\]]*])/; - var child = /(\[[^[\]]*])/g; - - // Get the parent - - var segment = options.depth > 0 && brackets.exec(key); - var parent = segment ? key.slice(0, segment.index) : key; - - // Stash the parent if it exists - - var keys = []; - if (parent) { - // If we aren't using plain objects, optionally prefix keys that would overwrite object prototype properties - if (!options.plainObjects && has.call(Object.prototype, parent)) { - if (!options.allowPrototypes) { - return; - } - } - - keys.push(parent); - } - - // Loop through children appending to the array until we hit depth - - var i = 0; - while (options.depth > 0 && (segment = child.exec(key)) !== null && i < options.depth) { - i += 1; - if (!options.plainObjects && has.call(Object.prototype, segment[1].slice(1, -1))) { - if (!options.allowPrototypes) { - return; - } - } - keys.push(segment[1]); - } - - // If there's a remainder, just add whatever is left - - if (segment) { - keys.push('[' + key.slice(segment.index) + ']'); - } - - return parseObject(keys, val, options, valuesParsed); -}; - -var normalizeParseOptions = function normalizeParseOptions(opts) { - if (!opts) { - return defaults; - } - - if (typeof opts.allowEmptyArrays !== 'undefined' && typeof opts.allowEmptyArrays !== 'boolean') { - throw new TypeError('`allowEmptyArrays` option can only be `true` or `false`, when provided'); - } - - if (typeof opts.decodeDotInKeys !== 'undefined' && typeof opts.decodeDotInKeys !== 'boolean') { - throw new TypeError('`decodeDotInKeys` option can only be `true` or `false`, when provided'); - } - - if (opts.decoder !== null && typeof opts.decoder !== 'undefined' && typeof opts.decoder !== 'function') { - throw new TypeError('Decoder has to be a function.'); - } - - if (typeof opts.charset !== 'undefined' && opts.charset !== 'utf-8' && opts.charset !== 'iso-8859-1') { - throw new TypeError('The charset option must be either utf-8, iso-8859-1, or undefined'); - } - var charset = typeof opts.charset === 'undefined' ? defaults.charset : opts.charset; - - var duplicates = typeof opts.duplicates === 'undefined' ? defaults.duplicates : opts.duplicates; - - if (duplicates !== 'combine' && duplicates !== 'first' && duplicates !== 'last') { - throw new TypeError('The duplicates option must be either combine, first, or last'); - } - - var allowDots = typeof opts.allowDots === 'undefined' ? opts.decodeDotInKeys === true ? true : defaults.allowDots : !!opts.allowDots; - - return { - allowDots: allowDots, - allowEmptyArrays: typeof opts.allowEmptyArrays === 'boolean' ? !!opts.allowEmptyArrays : defaults.allowEmptyArrays, - allowPrototypes: typeof opts.allowPrototypes === 'boolean' ? opts.allowPrototypes : defaults.allowPrototypes, - allowSparse: typeof opts.allowSparse === 'boolean' ? opts.allowSparse : defaults.allowSparse, - arrayLimit: typeof opts.arrayLimit === 'number' ? opts.arrayLimit : defaults.arrayLimit, - charset: charset, - charsetSentinel: typeof opts.charsetSentinel === 'boolean' ? opts.charsetSentinel : defaults.charsetSentinel, - comma: typeof opts.comma === 'boolean' ? opts.comma : defaults.comma, - decodeDotInKeys: typeof opts.decodeDotInKeys === 'boolean' ? opts.decodeDotInKeys : defaults.decodeDotInKeys, - decoder: typeof opts.decoder === 'function' ? opts.decoder : defaults.decoder, - delimiter: typeof opts.delimiter === 'string' || utils.isRegExp(opts.delimiter) ? opts.delimiter : defaults.delimiter, - // eslint-disable-next-line no-implicit-coercion, no-extra-parens - depth: (typeof opts.depth === 'number' || opts.depth === false) ? +opts.depth : defaults.depth, - duplicates: duplicates, - ignoreQueryPrefix: opts.ignoreQueryPrefix === true, - interpretNumericEntities: typeof opts.interpretNumericEntities === 'boolean' ? opts.interpretNumericEntities : defaults.interpretNumericEntities, - parameterLimit: typeof opts.parameterLimit === 'number' ? opts.parameterLimit : defaults.parameterLimit, - parseArrays: opts.parseArrays !== false, - plainObjects: typeof opts.plainObjects === 'boolean' ? opts.plainObjects : defaults.plainObjects, - strictNullHandling: typeof opts.strictNullHandling === 'boolean' ? opts.strictNullHandling : defaults.strictNullHandling - }; -}; - -module.exports = function (str, opts) { - var options = normalizeParseOptions(opts); - - if (str === '' || str === null || typeof str === 'undefined') { - return options.plainObjects ? Object.create(null) : {}; - } - - var tempObj = typeof str === 'string' ? parseValues(str, options) : str; - var obj = options.plainObjects ? Object.create(null) : {}; - - // Iterate over the keys and setup the new object - - var keys = Object.keys(tempObj); - for (var i = 0; i < keys.length; ++i) { - var key = keys[i]; - var newObj = parseKeys(key, tempObj[key], options, typeof str === 'string'); - obj = utils.merge(obj, newObj, options); - } - - if (options.allowSparse === true) { - return obj; - } - - return utils.compact(obj); -}; - - -/***/ }), -/* 2148 */ -/***/ ((module, __unused_webpack_exports, __webpack_require__) => { - // @ts-check const { log, errors } = __webpack_require__(594) -const { getAccount, saveAccountData } = __webpack_require__(2149) -const { deleteBoConsent, createBoConsent } = __webpack_require__(2150) +const { getAccount, saveAccountData } = __webpack_require__(2144) +const { deleteBoConsent, createBoConsent } = __webpack_require__(2145) const moment = __webpack_require__(1994) const { isLocal } = __webpack_require__(593) const { createGRDFConsent } = __webpack_require__(2136) @@ -283424,7 +282410,7 @@ module.exports = { handleConsents, createConsent } /***/ }), -/* 2149 */ +/* 2144 */ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const { log, updateOrCreate } = __webpack_require__(594) @@ -283478,7 +282464,7 @@ module.exports = { getAccount, saveAccountData } /***/ }), -/* 2150 */ +/* 2145 */ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { // @ts-check @@ -283486,6 +282472,36 @@ const { log, errors } = __webpack_require__(594) const { default: axios } = __webpack_require__(2137) const Sentry = __webpack_require__(2) +/** + * Fetches the GRDF access token from the back office + * @param boUrlGRDF: string, + * @param boToken: string, + * @returns {Promise<{access_token: string, fetched_at: string}>} + */ +async function getGRDFAccessToken(boUrlGRDF, boToken) { + log('info', `Query getGRDFAccessToken`) + + const headers = { + headers: { + Authorization: `Bearer ${boToken}`, + }, + } + try { + const { data } = await axios.get(`${boUrlGRDF}/access-token`, headers) + return data + } catch (err) { + const errorMessage = + 'Error while getting GRDF access token : ' + err.message + log('error', errorMessage) + Sentry.captureException(errorMessage, { + tags: { + section: 'getGRDFAccessToken', + }, + }) + throw new Error(errors.MAINTENANCE) + } +} + /** * @param {{ * boUrlGRDF: string, @@ -283577,11 +282593,12 @@ async function deleteBoConsent({ boUrlGRDF, boToken, consentId }) { module.exports = { createBoConsent, deleteBoConsent, + getGRDFAccessToken, } /***/ }), -/* 2151 */ +/* 2146 */ /***/ ((module) => { const APP_NAME = `konnector-grdfgrandlyon` @@ -283613,11 +282630,11 @@ module.exports = { /***/ }), -/* 2152 */ +/* 2147 */ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const { cozyClient } = __webpack_require__(594) -const { rangeDate } = __webpack_require__(2151) +const { rangeDate } = __webpack_require__(2146) /** * Aggregates the load data by month, summing the load of each day for each month. @@ -283745,7 +282762,7 @@ module.exports = { /***/ }), -/* 2153 */ +/* 2148 */ /***/ ((module, __unused_webpack_exports, __webpack_require__) => { const moment = __webpack_require__(1994) @@ -283781,15 +282798,15 @@ module.exports = { /***/ }), -/* 2154 */, -/* 2155 */ +/* 2149 */, +/* 2150 */ /***/ ((module) => { "use strict"; module.exports = require("node:diagnostics_channel"); /***/ }), -/* 2156 */ +/* 2151 */ /***/ ((module) => { "use strict";