diff --git a/jest.config.js b/jest.config.js index 34da62517..ff927b8a9 100644 --- a/jest.config.js +++ b/jest.config.js @@ -13,4 +13,5 @@ module.exports = { "testPathIgnorePatterns": [ "cypress/integration/standalone.spec.js" ] + , }; \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index edc259d66..9d682f1cd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,9 +9,9 @@ "version": "1.1.2", "license": "ISC", "dependencies": { - "axios": "^0.27.2", + "axios": "^1.6.4", "camelcase": "^6.3.0", - "crypto-js": "^4.1.1", + "crypto-js": "^4.2.0", "isomorphic-base64": "^1.0.2", "joi": "^17.7.0", "loglevel": "^1.8.1", @@ -1751,12 +1751,13 @@ "dev": true }, "node_modules/axios": { - "version": "0.27.2", - "resolved": "https://registry.npmjs.org/axios/-/axios-0.27.2.tgz", - "integrity": "sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==", + "version": "1.6.4", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.4.tgz", + "integrity": "sha512-heJnIs6N4aa1eSthhN9M5ioILu8Wi8vmQW9iHQ9NUvfkJb0lEEDUiIdQNAuBtfUt3FxReaKdpQA5DbmMOqzF/A==", "dependencies": { - "follow-redirects": "^1.14.9", - "form-data": "^4.0.0" + "follow-redirects": "^1.15.4", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" } }, "node_modules/axios-cookiejar-support": { @@ -1791,6 +1792,11 @@ "axios": ">= 0.17.0" } }, + "node_modules/axios/node_modules/proxy-from-env": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz", + "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" + }, "node_modules/babel-jest": { "version": "29.6.0", "resolved": "https://registry.npmjs.org/babel-jest/-/babel-jest-29.6.0.tgz", @@ -2391,9 +2397,9 @@ } }, "node_modules/crypto-js": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.1.1.tgz", - "integrity": "sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw==" + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/crypto-js/-/crypto-js-4.2.0.tgz", + "integrity": "sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==" }, "node_modules/cypress": { "version": "9.7.0", @@ -2943,9 +2949,9 @@ } }, "node_modules/follow-redirects": { - "version": "1.15.2", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.2.tgz", - "integrity": "sha512-VQLG33o04KaQ8uYi2tVNbdrWp1QWxNNea+nmIB4EVM28v0hmP17z7aG1+wAkNzVq4KeXTq3221ye5qTJP91JwA==", + "version": "1.15.5", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.5.tgz", + "integrity": "sha512-vSFWUON1B+yAw1VN4xMfxgn5fTUiaOzAJCKBwIIgT/+7CuGy9+r+5gITvP62j3RmaD5Ph65UaERdOSRGUzZtgw==", "funding": [ { "type": "individual", diff --git a/package.json b/package.json index c40d6b5e6..ac9dbce98 100644 --- a/package.json +++ b/package.json @@ -12,9 +12,9 @@ "author": "Jigar Dafda", "license": "ISC", "dependencies": { - "axios": "^0.27.2", + "axios": "^1.6.4", "camelcase": "^6.3.0", - "crypto-js": "^4.1.1", + "crypto-js": "^4.2.0", "isomorphic-base64": "^1.0.2", "joi": "^17.7.0", "loglevel": "^1.8.1", diff --git a/sdk/common/AxiosHelper.js b/sdk/common/AxiosHelper.js index dc761f1bf..0d291b88d 100644 --- a/sdk/common/AxiosHelper.js +++ b/sdk/common/AxiosHelper.js @@ -1,5 +1,4 @@ -const combineURLs = require("axios/lib/helpers/combineURLs"); -const isAbsoluteURL = require("axios/lib/helpers/isAbsoluteURL"); +const { combineURLs, isAbsoluteURL } = require("./Utility"); const axios = require("axios"); const querystring = require("query-string"); const { sign } = require("./RequestSigner"); diff --git a/sdk/common/Utility.js b/sdk/common/Utility.js index aa84fd094..f7d568c1c 100644 --- a/sdk/common/Utility.js +++ b/sdk/common/Utility.js @@ -80,7 +80,39 @@ function convertActionToUrl(action) { } } +// kept same as axios function +/** + * Determines whether the specified URL is absolute + * + * @param {string} url The URL to test + * + * @returns {boolean} True if the specified URL is absolute, otherwise false + */ +function isAbsoluteURL(url) { + // A URL is considered absolute if it begins with "://" or "//" (protocol-relative URL). + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed + // by any combination of letters, digits, plus, period, or hyphen. + return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url); +} + +/** + * Creates a new URL by combining the specified URLs + * + * @param {string} baseURL The base URL + * @param {string} relativeURL The relative URL + * + * @returns {string} The combined URL + */ +function combineURLs(baseURL, relativeURL) { + return relativeURL + ? baseURL.replace(/\/?\/$/, '') + '/' + relativeURL.replace(/^\/+/, '') + : baseURL; +} + + module.exports = { convertActionToUrl, convertUrlToAction, + isAbsoluteURL, + combineURLs }; diff --git a/sdk/common/curlHelper.js b/sdk/common/curlHelper.js index dfe0e6f0b..b28ef4c64 100644 --- a/sdk/common/curlHelper.js +++ b/sdk/common/curlHelper.js @@ -1,6 +1,5 @@ const qs = require("query-string"); -const combineURLs = require("axios/lib/helpers/combineURLs"); -const isAbsoluteURL = require("axios/lib/helpers/isAbsoluteURL"); +const { combineURLs, isAbsoluteURL } = require("./Utility"); let reqConfig;