diff --git a/package-lock.json b/package-lock.json index 59df32aa83..2d9af1dce6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -19,7 +19,7 @@ "@koa/router": "^12.0.0", "@ndhoule/extend": "^2.0.0", "@pyroscope/nodejs": "^0.2.6", - "@rudderstack/integrations-lib": "^0.1.8", + "@rudderstack/integrations-lib": "file:../rudder-integrations-lib", "@rudderstack/workflow-engine": "^0.6.9", "ajv": "^8.12.0", "ajv-draft-04": "^1.0.0", @@ -114,6 +114,39 @@ "typescript": "^5.0.4" } }, + "../rudder-integrations-lib": { + "version": "0.1.10", + "license": "MIT", + "dependencies": { + "@rudderstack/workflow-engine": "^0.5.7", + "axios": "^1.4.0", + "axios-mock-adapter": "^1.22.0", + "crypto": "^1.0.1", + "get-value": "^3.0.1", + "handlebars": "^4.7.8", + "lodash": "^4.17.21", + "moment": "^2.29.4", + "moment-timezone": "^0.5.43", + "set-value": "^4.1.0", + "sha256": "^0.2.0", + "tslib": "^2.4.0", + "winston": "^3.11.0" + }, + "devDependencies": { + "@types/get-value": "^3.0.3", + "@types/jest": "^29.5.4", + "@types/lodash": "^4.14.195", + "@types/node": "^20.3.3", + "@types/set-value": "^4.0.1", + "@types/sha256": "^0.2.0", + "jest": "^29.4.3", + "pre-commit": "^1.2.2", + "prettier": "^2.8.4", + "ts-jest": "^29.0.5", + "ts-node": "^10.9.1", + "typescript": "^5.1.6" + } + }, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", @@ -4432,71 +4465,8 @@ } }, "node_modules/@rudderstack/integrations-lib": { - "version": "0.1.9", - "resolved": "https://registry.npmjs.org/@rudderstack/integrations-lib/-/integrations-lib-0.1.9.tgz", - "integrity": "sha512-ROi/LfI7PXqKDrjSig+1Rf2TQ8MgxJGJ7sAD1B0PmRKELQpxK6PLt8QF+vKXl8wYILQu2gwTkZ5o+uwmNKxGzg==", - "dependencies": { - "@rudderstack/workflow-engine": "^0.5.7", - "axios": "^1.4.0", - "axios-mock-adapter": "^1.22.0", - "crypto": "^1.0.1", - "get-value": "^3.0.1", - "handlebars": "^4.7.8", - "lodash": "^4.17.21", - "moment": "^2.29.4", - "moment-timezone": "^0.5.43", - "set-value": "^4.1.0", - "sha256": "^0.2.0", - "tslib": "^2.4.0" - } - }, - "node_modules/@rudderstack/integrations-lib/node_modules/@aws-crypto/sha256-js": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/sha256-js/-/sha256-js-4.0.0.tgz", - "integrity": "sha512-MHGJyjE7TX9aaqXj7zk2ppnFUOhaDs5sP+HtNS0evOxn72c+5njUmyJmpGd7TfyoDznZlHMmdo/xGUdu2NIjNQ==", - "dependencies": { - "@aws-crypto/util": "^4.0.0", - "@aws-sdk/types": "^3.222.0", - "tslib": "^1.11.1" - } - }, - "node_modules/@rudderstack/integrations-lib/node_modules/@aws-crypto/sha256-js/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, - "node_modules/@rudderstack/integrations-lib/node_modules/@aws-crypto/util": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/@aws-crypto/util/-/util-4.0.0.tgz", - "integrity": "sha512-2EnmPy2gsFZ6m8bwUQN4jq+IyXV3quHAcwPOS6ZA3k+geujiqI8aRokO2kFJe+idJ/P3v4qWI186rVMo0+zLDQ==", - "dependencies": { - "@aws-sdk/types": "^3.222.0", - "@aws-sdk/util-utf8-browser": "^3.0.0", - "tslib": "^1.11.1" - } - }, - "node_modules/@rudderstack/integrations-lib/node_modules/@aws-crypto/util/node_modules/tslib": { - "version": "1.14.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.14.1.tgz", - "integrity": "sha512-Xni35NKzjgMrwevysHTCArtLDpPvye8zV/0E4EyYn43P7/7qvQwPh9BGkHewbMulVntbigmcT7rdX3BNo9wRJg==" - }, - "node_modules/@rudderstack/integrations-lib/node_modules/@rudderstack/json-template-engine": { - "version": "0.5.5", - "resolved": "https://registry.npmjs.org/@rudderstack/json-template-engine/-/json-template-engine-0.5.5.tgz", - "integrity": "sha512-p3HdTqgZiJjjZmjaHN2paa1e87ifGE5UjkA4zdvge4bBzJbKKMQNWqRg6I96SwoA+hsxNkW/f9R83SPLU9t7LA==" - }, - "node_modules/@rudderstack/integrations-lib/node_modules/@rudderstack/workflow-engine": { - "version": "0.5.8", - "resolved": "https://registry.npmjs.org/@rudderstack/workflow-engine/-/workflow-engine-0.5.8.tgz", - "integrity": "sha512-H1aCowYqTnOoqJtL9cGDhdhoGNl+KzqmVbSjFmE7n75onZaIMs87+HQyW08jYxS9l1Uo4TL8SAvzFICqFqkBbw==", - "dependencies": { - "@aws-crypto/sha256-js": "^4.0.0", - "@rudderstack/json-template-engine": "^0.5.5", - "js-yaml": "^4.1.0", - "jsonata": "^2.0.3", - "lodash": "^4.17.21", - "object-sizeof": "^2.6.3" - } + "resolved": "../rudder-integrations-lib", + "link": true }, "node_modules/@rudderstack/json-template-engine": { "version": "0.8.2", @@ -6195,6 +6165,7 @@ "version": "1.22.0", "resolved": "https://registry.npmjs.org/axios-mock-adapter/-/axios-mock-adapter-1.22.0.tgz", "integrity": "sha512-dmI0KbkyAhntUR05YY96qg2H6gg0XMl2+qTW0xmYg6Up+BFBAJYRLROMXRdDEL06/Wqwa0TJThAYvFtSFdRCZw==", + "dev": true, "dependencies": { "fast-deep-equal": "^3.1.3", "is-buffer": "^2.0.5" @@ -8549,12 +8520,6 @@ "node": "*" } }, - "node_modules/crypto": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz", - "integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==", - "deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in." - }, "node_modules/crypto-js": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", @@ -12238,6 +12203,7 @@ "version": "2.0.5", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-2.0.5.tgz", "integrity": "sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==", + "dev": true, "funding": [ { "type": "github", diff --git a/package.json b/package.json index 93c97fedda..fc3f8cd042 100644 --- a/package.json +++ b/package.json @@ -64,7 +64,7 @@ "@koa/router": "^12.0.0", "@ndhoule/extend": "^2.0.0", "@pyroscope/nodejs": "^0.2.6", - "@rudderstack/integrations-lib": "^0.1.8", + "@rudderstack/integrations-lib": "file:../rudder-integrations-lib", "@rudderstack/workflow-engine": "^0.6.9", "ajv": "^8.12.0", "ajv-draft-04": "^1.0.0", diff --git a/src/v0/util/facebookUtils/networkHandler.js b/src/v0/util/facebookUtils/networkHandler.js index d19a0e6b70..3dcd252811 100644 --- a/src/v0/util/facebookUtils/networkHandler.js +++ b/src/v0/util/facebookUtils/networkHandler.js @@ -2,7 +2,7 @@ const { isEmpty } = require('lodash'); const get = require('get-value'); const { NetworkError, - UnauthorizedError, + ConfigurationAuthError, isDefinedAndNotNull, } = require('@rudderstack/integrations-lib'); const { @@ -252,10 +252,7 @@ const errorResponseHandler = (destResponse) => { const { error } = response; const { status, errorMessage, stats: errorStatTags } = getStatus(error); if (isDefinedAndNotNull(errorStatTags) && errorStatTags?.errorType === 'accessTokenExpired') { - throw new UnauthorizedError(`${errorMessage}`, status, { - ...response, - status: destResponse.status, - }); + throw new ConfigurationAuthError(`${errorMessage}`); } throw new NetworkError( `${errorMessage || error.message || 'Unknown failure during response transformation'}`, diff --git a/test/integrations/destinations/facebook_pixel/dataDelivery/data.ts b/test/integrations/destinations/facebook_pixel/dataDelivery/data.ts index d4392d8e3b..3eaeb90b9c 100644 --- a/test/integrations/destinations/facebook_pixel/dataDelivery/data.ts +++ b/test/integrations/destinations/facebook_pixel/dataDelivery/data.ts @@ -41,22 +41,14 @@ export const data = [ output: { status: 400, message: 'Invalid OAuth 2.0 access token', - destinationResponse: { - error: { - message: 'The access token could not be decrypted', - type: 'OAuthException', - code: 190, - fbtrace_id: 'fbpixel_trace_id', - }, - status: 500, - }, + destinationResponse: '', statTags: { destType: 'FACEBOOK_PIXEL', - errorCategory: 'network', + errorCategory: 'dataValidation', destinationId: 'Non-determininable', workspaceId: 'Non-determininable', - errorType: 'aborted', - meta: 'unauthorized', + errorType: 'configuration', + meta: 'accessTokenExpired', feature: 'dataDelivery', implementation: 'native', module: 'destination', diff --git a/test/integrations/destinations/fb/dataDelivery/data.ts b/test/integrations/destinations/fb/dataDelivery/data.ts index b97f16d3a6..94a2e2df20 100644 --- a/test/integrations/destinations/fb/dataDelivery/data.ts +++ b/test/integrations/destinations/fb/dataDelivery/data.ts @@ -55,22 +55,14 @@ export const data = [ output: { status: 400, message: 'Invalid OAuth 2.0 access token', - destinationResponse: { - error: { - message: 'The access token could not be decrypted', - type: 'OAuthException', - code: 190, - fbtrace_id: 'fbpixel_trace_id', - }, - status: 500, - }, + destinationResponse: '', statTags: { destType: 'FB', - errorCategory: 'network', + errorCategory: 'dataValidation', destinationId: 'Non-determininable', workspaceId: 'Non-determininable', - errorType: 'aborted', - meta: 'unauthorized', + errorType: 'configuration', + meta: 'accessTokenExpired', feature: 'dataDelivery', implementation: 'native', module: 'destination', diff --git a/test/integrations/destinations/fb_custom_audience/dataDelivery/data.ts b/test/integrations/destinations/fb_custom_audience/dataDelivery/data.ts index a832b5fe1b..cb9fcc9787 100644 --- a/test/integrations/destinations/fb_custom_audience/dataDelivery/data.ts +++ b/test/integrations/destinations/fb_custom_audience/dataDelivery/data.ts @@ -574,7 +574,7 @@ export const data = [ }, { name: 'fb_custom_audience', - description: 'user addition failed due to unavailable audience error', + description: 'user addition failed due expired access token error', feature: 'dataDelivery', module: 'destination', version: 'v0', @@ -614,24 +614,14 @@ export const data = [ status: 400, body: { output: { - destinationResponse: { - error: { - message: - 'Error validating access token: Session has expired on Tuesday, 01-Aug-23 10:12:14 PDT. The current time is Sunday, 28-Jan-24 16:01:17 PST.', - type: 'OAuthException', - code: 190, - error_subcode: 463, - fbtrace_id: 'A3b8C6PpI-kdIOwPwV4PANi', - }, - status: 400, - }, + destinationResponse: '', message: 'Invalid OAuth 2.0 access token', statTags: { destType: 'FB_CUSTOM_AUDIENCE', destinationId: 'Non-determininable', - errorCategory: 'network', - errorType: 'aborted', - meta: 'unauthorized', + errorCategory: 'dataValidation', + errorType: 'configuration', + meta: 'accessTokenExpired', feature: 'dataDelivery', implementation: 'native', module: 'destination',