From 7c0d8d2082e09fc113c3e5fc54ee0947b15aede7 Mon Sep 17 00:00:00 2001 From: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com> Date: Tue, 19 Nov 2024 10:21:55 +0530 Subject: [PATCH 1/6] PAC file support via PERCY_PAC_FILE_PATH env var --- packages/client/src/proxy.js | 48 ++++++++++++++++++++++++++++++++---- 1 file changed, 43 insertions(+), 5 deletions(-) diff --git a/packages/client/src/proxy.js b/packages/client/src/proxy.js index 4f5d133af..427b5152e 100644 --- a/packages/client/src/proxy.js +++ b/packages/client/src/proxy.js @@ -4,10 +4,28 @@ import http from 'http'; import https from 'https'; import logger from '@percy/logger'; import { stripQuotesAndSpaces } from '@percy/env/utils'; +import { PacProxyAgent } from 'pac-proxy-agent'; const CRLF = '\r\n'; const STATUS_REG = /^HTTP\/1.[01] (\d*)/; +// function to create PAC proxy agent +function createPacAgent(pacUrl, options = {}) { + try { + const agent = new PacProxyAgent(pacUrl, { + keepAlive: true, + ...options, + rejectUnauthorized: false + }); + + logger('client:proxy').info(`Successfully loaded PAC file from: ${pacUrl}`); + return agent; + } catch (error) { + logger('client:proxy').error(`Failed to load PAC file, error message: ${error.message}, stack: ${error.stack}`); + throw new Error(`Failed to initialize PAC proxy: ${error.message}`); + } +} + // Returns true if the URL hostname matches any patterns export function hostnameMatches(patterns, url) { let subject = new URL(url); @@ -219,11 +237,31 @@ export function proxyAgentFor(url, options) { let { protocol, hostname } = new URL(url); let cachekey = `${protocol}//${hostname}`; - if (!cache.has(cachekey)) { - cache.set(cachekey, protocol === 'https:' - ? new ProxyHttpsAgent(options) - : new ProxyHttpAgent(options)); + // If we already have a cached agent, return it + if (cache.has(cachekey)) { + return cache.get(cachekey); } - return cache.get(cachekey); + try { + let agent; + const pacUrl = process.env.PERCY_PAC_FILE_PATH; + + // If PAC URL is provided, use PAC proxy + if (pacUrl) { + logger('client:proxy').info(`Using PAC file from: ${pacUrl}`); + agent = createPacAgent(stripQuotesAndSpaces(pacUrl), options); + } else { + // Fall back to other proxy configuration + agent = protocol === 'https:' + ? new ProxyHttpsAgent(options) + : new ProxyHttpAgent(options); + } + + // Cache the created agent + cache.set(cachekey, agent); + return agent; + } catch (error) { + logger('client:proxy').error(`Failed to create proxy agent: ${error.message}`); + throw error; + } } From 51351fbe0839b401128e11a274444c8b35a36175 Mon Sep 17 00:00:00 2001 From: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:40:24 +0530 Subject: [PATCH 2/6] Added pac-proxy-agent lib as dependency --- package.json | 5 +- yarn.lock | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 165 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 68a9ae9f6..be3a68135 100644 --- a/package.json +++ b/package.json @@ -31,13 +31,13 @@ "@babel/eslint-parser": "^7.14.7", "@babel/preset-env": "^7.14.7", "@babel/register": "^7.17.7", - "babel-plugin-transform-import-meta": "^2.2.1", "@rollup/plugin-alias": "^5.1.1", "@rollup/plugin-babel": "^6.0.0", "@rollup/plugin-commonjs": "^21.0.0", "@rollup/plugin-node-resolve": "^15.0.0", "babel-plugin-istanbul": "^6.0.0", "babel-plugin-module-resolver": "^4.1.0", + "babel-plugin-transform-import-meta": "^2.2.1", "cross-env": "^7.0.2", "eslint": "^7.30.0", "eslint-config-standard": "^16.0.2", @@ -59,5 +59,8 @@ "nyc": "^15.1.0", "rollup": "^2.53.2", "tsd": "^0.31.2" + }, + "dependencies": { + "pac-proxy-agent": "^7.0.2" } } diff --git a/yarn.lock b/yarn.lock index 16f8f4fb1..c694874c6 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2248,6 +2248,11 @@ resolved "https://registry.yarnpkg.com/@tootallnate/once/-/once-2.0.0.tgz#f544a148d3ab35801c1f633a7441fd87c2e484bf" integrity sha512-XCuKFP5PS55gnMVu3dty8KPatLqUoy/ZYzDzAGCQ8JNFCkLXzmI7vNHCR+XpbZaMWQK/vQubr7PkYq8g470J/A== +"@tootallnate/quickjs-emscripten@^0.23.0": + version "0.23.0" + resolved "https://registry.yarnpkg.com/@tootallnate/quickjs-emscripten/-/quickjs-emscripten-0.23.0.tgz#db4ecfd499a9765ab24002c3b696d02e6d32a12c" + integrity sha512-C5Mc6rdnsaJDjO3UpGW/CQTHtCKaYlScZTly4JIu97Jxo/odCiH0ITnDXSJPTOrEKk/ycSZ0AOgTmkDtkOsvIA== + "@tsd/typescript@~5.4.3": version "5.4.5" resolved "https://registry.yarnpkg.com/@tsd/typescript/-/typescript-5.4.5.tgz#a7c11d3a97ddfa201f831f4e4270a169a87f7655" @@ -2401,6 +2406,13 @@ agent-base@6, agent-base@^6.0.2: dependencies: debug "4" +agent-base@^7.0.2, agent-base@^7.1.0, agent-base@^7.1.1: + version "7.1.1" + resolved "https://registry.yarnpkg.com/agent-base/-/agent-base-7.1.1.tgz#bdbded7dfb096b751a2a087eeeb9664725b2e317" + integrity sha512-H0TSyFNDMomMNJQBn8wFV5YC/2eJ+VXECwOadZJT554xP6cODZHPX3H9QMQECxvrgiSOP1pHjy1sMWQVYJOUOA== + dependencies: + debug "^4.3.4" + agentkeepalive@^4.2.1: version "4.2.1" resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.2.1.tgz#a7975cbb9f83b367f06c90cc51ff28fe7d499717" @@ -2625,6 +2637,13 @@ asap@^2.0.0: resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46" integrity sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY= +ast-types@^0.13.4: + version "0.13.4" + resolved "https://registry.yarnpkg.com/ast-types/-/ast-types-0.13.4.tgz#ee0d77b343263965ecc3fb62da16e7222b2b6782" + integrity sha512-x1FCFnFifvYDDzTaLII71vG5uvDwgtmDTEVWAxrgeiR8VjMONcCXJx7E+USjDtHlwFmt9MysbqgF9b9Vjr6w+w== + dependencies: + tslib "^2.0.1" + astral-regex@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/astral-regex/-/astral-regex-2.0.0.tgz#483143c567aeed4785759c0865786dc77d7d2e31" @@ -2730,6 +2749,11 @@ base64id@2.0.0, base64id@~2.0.0: resolved "https://registry.yarnpkg.com/base64id/-/base64id-2.0.0.tgz#2770ac6bc47d312af97a8bf9a634342e0cd25cb6" integrity sha512-lGe34o6EHj9y3Kts9R4ZYs/Gr+6N7MCaMlIFA3F1R2O5/m7K06AxfSeO5530PEERE6/WyEg3lsuyw4GHlPZHog== +basic-ftp@^5.0.2: + version "5.0.5" + resolved "https://registry.yarnpkg.com/basic-ftp/-/basic-ftp-5.0.5.tgz#14a474f5fffecca1f4f406f1c26b18f800225ac0" + integrity sha512-4Bcg1P8xhUuqcii/S0Z9wiHIrQVPMermM1any+MX5GeGD7faD3/msQUDGLol9wOcz4/jbg/WJnGqoJF6LiBdtg== + before-after-hook@^2.2.0: version "2.2.2" resolved "https://registry.yarnpkg.com/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e" @@ -3373,6 +3397,11 @@ dargs@^7.0.0: resolved "https://registry.yarnpkg.com/dargs/-/dargs-7.0.0.tgz#04015c41de0bcb69ec84050f3d9be0caf8d6d5cc" integrity sha512-2iy1EkLdlBzQGvbweYRFxmFath8+K7+AKB0TlhHWkNuH+TmovaMH/Wp7V7R4u7f4SnX3OgLsU9t1NI9ioDnUpg== +data-uri-to-buffer@^6.0.2: + version "6.0.2" + resolved "https://registry.yarnpkg.com/data-uri-to-buffer/-/data-uri-to-buffer-6.0.2.tgz#8a58bb67384b261a38ef18bea1810cb01badd28b" + integrity sha512-7hvf7/GW8e86rW0ptuwS3OcBGDjIi6SZva7hCyWC0yYry2cOPmLIjXAUHI6DK2HsnwJd9ifmt57i8eV2n4YNpw== + data-view-buffer@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/data-view-buffer/-/data-view-buffer-1.0.1.tgz#8ea6326efec17a2e42620696e671d7d5a8bc66b2" @@ -3436,6 +3465,13 @@ debug@^3.2.7: dependencies: ms "^2.1.1" +debug@^4.3.4: + version "4.3.7" + resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.7.tgz#87945b4151a011d76d95a198d7111c865c360a52" + integrity sha512-Er2nc/H7RrMXZBFCEim6TCmMk02Z8vLC2Rbi1KEBggpo0fS6l0S1nnapwmIi3yW/+GOJap1Krg4w0Hg80oCqgQ== + dependencies: + ms "^2.1.3" + debuglog@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/debuglog/-/debuglog-1.0.1.tgz#aa24ffb9ac3df9a2351837cfb2d279360cd78492" @@ -3513,6 +3549,15 @@ define-properties@^1.2.0, define-properties@^1.2.1: has-property-descriptors "^1.0.0" object-keys "^1.1.1" +degenerator@^5.0.0: + version "5.0.1" + resolved "https://registry.yarnpkg.com/degenerator/-/degenerator-5.0.1.tgz#9403bf297c6dad9a1ece409b37db27954f91f2f5" + integrity sha512-TllpMR/t0M5sqCXfj85i4XaAzxmS5tVA16dqvdkMwGmzI+dXLXnw3J+3Vdv7VKw+ThlTMboK6i9rnZ6Nntj5CQ== + dependencies: + ast-types "^0.13.4" + escodegen "^2.1.0" + esprima "^4.0.1" + delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" @@ -3907,6 +3952,17 @@ escape-string-regexp@^4.0.0: resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34" integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA== +escodegen@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/escodegen/-/escodegen-2.1.0.tgz#ba93bbb7a43986d29d6041f99f5262da773e2e17" + integrity sha512-2NlIDTwUWJN0mRPQOdtQBzbUHvdGY2P1VXSyU83Q3xKxM7WHX2Ql8dKq782Q9TgQUNOLEzEYu9bzLNj1q88I5w== + dependencies: + esprima "^4.0.1" + estraverse "^5.2.0" + esutils "^2.0.2" + optionalDependencies: + source-map "~0.6.1" + eslint-config-standard@^16.0.2: version "16.0.3" resolved "https://registry.yarnpkg.com/eslint-config-standard/-/eslint-config-standard-16.0.3.tgz#6c8761e544e96c531ff92642eeb87842b8488516" @@ -4088,7 +4144,7 @@ espree@^7.3.0, espree@^7.3.1: acorn-jsx "^5.3.1" eslint-visitor-keys "^1.3.0" -esprima@^4.0.0: +esprima@^4.0.0, esprima@^4.0.1: version "4.0.1" resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.1.tgz#13b04cdb3e6c5d19df91ab6987a8695619b0aa71" integrity sha512-eGuFFw7Upda+g4p+QHvnW0RyTX/SVeJBDM/gCtMARO0cLuT2HcEKnTPvhjV6aGeqrCB/sbNop0Kszm0jsaWU4A== @@ -4402,6 +4458,15 @@ fs-extra@^10.1.0: jsonfile "^6.0.1" universalify "^2.0.0" +fs-extra@^11.2.0: + version "11.2.0" + resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-11.2.0.tgz#e70e17dfad64232287d01929399e0ea7c86b0e5b" + integrity sha512-PmDi3uwK5nFuXh7XDTlVnS17xJS7vW36is2+w3xcv8SVxiB4NyATf4ctkVY5bkSjX0Y4nbvZCq1/EjtEyr9ktw== + dependencies: + graceful-fs "^4.2.0" + jsonfile "^6.0.1" + universalify "^2.0.0" + fs-extra@^9.1.0: version "9.1.0" resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-9.1.0.tgz#5954460c764a8da2094ba3554bf839e6b9a7c86d" @@ -4579,6 +4644,16 @@ get-symbol-description@^1.0.2: es-errors "^1.3.0" get-intrinsic "^1.2.4" +get-uri@^6.0.1: + version "6.0.3" + resolved "https://registry.yarnpkg.com/get-uri/-/get-uri-6.0.3.tgz#0d26697bc13cf91092e519aa63aa60ee5b6f385a" + integrity sha512-BzUrJBS9EcUb4cFol8r4W3v1cPsSyajLSthNkz5BxbpDcHN5tIrM10E2eNvfnvBn3DaT3DUgx0OpsBKkaOpanw== + dependencies: + basic-ftp "^5.0.2" + data-uri-to-buffer "^6.0.2" + debug "^4.3.4" + fs-extra "^11.2.0" + git-raw-commits@^2.0.8: version "2.0.10" resolved "https://registry.yarnpkg.com/git-raw-commits/-/git-raw-commits-2.0.10.tgz#e2255ed9563b1c9c3ea6bd05806410290297bbc1" @@ -4902,6 +4977,14 @@ http-proxy-agent@^5.0.0: agent-base "6" debug "4" +http-proxy-agent@^7.0.0: + version "7.0.2" + resolved "https://registry.yarnpkg.com/http-proxy-agent/-/http-proxy-agent-7.0.2.tgz#9a8b1f246866c028509486585f62b8f2c18c270e" + integrity sha512-T1gkAiYYDWYx3V5Bmyu7HcfcvL7mUrTWiM6yOfa3PIphViJ/gFPbvidQ+veqSOHci/PxBcDabeUNCzpOODJZig== + dependencies: + agent-base "^7.1.0" + debug "^4.3.4" + http-proxy@^1.18.1: version "1.18.1" resolved "https://registry.yarnpkg.com/http-proxy/-/http-proxy-1.18.1.tgz#401541f0534884bbf95260334e72f88ee3976549" @@ -4919,6 +5002,14 @@ https-proxy-agent@^5.0.0: agent-base "6" debug "4" +https-proxy-agent@^7.0.5: + version "7.0.5" + resolved "https://registry.yarnpkg.com/https-proxy-agent/-/https-proxy-agent-7.0.5.tgz#9e8b5013873299e11fab6fd548405da2d6c602b2" + integrity sha512-1e4Wqeblerz+tMKPIq2EMGiiWW1dIjZOksyHWSUm1rmuvw/how9hBHZ38lAGj5ID4Ik6EdkOw7NmWPy6LAwalw== + dependencies: + agent-base "^7.0.2" + debug "4" + human-signals@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/human-signals/-/human-signals-2.1.0.tgz#dc91fcba42e4d06e4abaed33b3e7a3c02f514ea0" @@ -5071,6 +5162,14 @@ internal-slot@^1.0.7: hasown "^2.0.0" side-channel "^1.0.4" +ip-address@^9.0.5: + version "9.0.5" + resolved "https://registry.yarnpkg.com/ip-address/-/ip-address-9.0.5.tgz#117a960819b08780c3bd1f14ef3c1cc1d3f3ea5a" + integrity sha512-zHtQzGojZXTwZTHQqra+ETKd4Sn3vgi7uBmlPoXVWZqYvuKmtI0l/VZTjqGmJY9x88GGOaZ9+G9ES8hC4T4X8g== + dependencies: + jsbn "1.1.0" + sprintf-js "^1.1.3" + ip@^1.1.5: version "1.1.9" resolved "https://registry.yarnpkg.com/ip/-/ip-1.1.9.tgz#8dfbcc99a754d07f425310b86a99546b1151e396" @@ -5512,6 +5611,11 @@ js-yaml@^3.10.0, js-yaml@^3.13.1: argparse "^1.0.7" esprima "^4.0.0" +jsbn@1.1.0: + version "1.1.0" + resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-1.1.0.tgz#b01307cb29b618a1ed26ec79e911f803c4da0040" + integrity sha512-4bYVV3aAMtDTTu4+xsDYa6sy9GyJ69/amsu9sYF2zqjiEoZA5xJi3BrfX3uY+/IekIu7MwdObdbDWpoZdBv3/A== + jsesc@^3.0.2: version "3.0.2" resolved "https://registry.yarnpkg.com/jsesc/-/jsesc-3.0.2.tgz#bb8b09a6597ba426425f2e4a07245c3d00b9343e" @@ -6166,7 +6270,7 @@ ms@2.1.2: resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== -ms@^2.0.0, ms@^2.1.1: +ms@^2.0.0, ms@^2.1.1, ms@^2.1.3: version "2.1.3" resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== @@ -6207,6 +6311,11 @@ neo-async@^2.6.0: resolved "https://registry.yarnpkg.com/neo-async/-/neo-async-2.6.2.tgz#b4aafb93e3aeb2d8174ca53cf163ab7d7308305f" integrity sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw== +netmask@^2.0.2: + version "2.0.2" + resolved "https://registry.yarnpkg.com/netmask/-/netmask-2.0.2.tgz#8b01a07644065d536383835823bc52004ebac5e7" + integrity sha512-dBpDMdxv9Irdq66304OLfEmQ9tbNRFnFTuZiLo+bD+r332bBmMJ8GBLXklIXXgxd3+v9+KUnZaUR5PJMa75Gsg== + node-addon-api@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/node-addon-api/-/node-addon-api-3.2.1.tgz#81325e0a2117789c0128dab65e7e38f07ceba161" @@ -6704,6 +6813,28 @@ p-waterfall@^2.1.1: dependencies: p-reduce "^2.0.0" +pac-proxy-agent@^7.0.2: + version "7.0.2" + resolved "https://registry.yarnpkg.com/pac-proxy-agent/-/pac-proxy-agent-7.0.2.tgz#0fb02496bd9fb8ae7eb11cfd98386daaac442f58" + integrity sha512-BFi3vZnO9X5Qt6NRz7ZOaPja3ic0PhlsmCRYLOpN11+mWBCR6XJDqW5RF3j8jm4WGGQZtBA+bTfxYzeKW73eHg== + dependencies: + "@tootallnate/quickjs-emscripten" "^0.23.0" + agent-base "^7.0.2" + debug "^4.3.4" + get-uri "^6.0.1" + http-proxy-agent "^7.0.0" + https-proxy-agent "^7.0.5" + pac-resolver "^7.0.1" + socks-proxy-agent "^8.0.4" + +pac-resolver@^7.0.1: + version "7.0.1" + resolved "https://registry.yarnpkg.com/pac-resolver/-/pac-resolver-7.0.1.tgz#54675558ea368b64d210fd9c92a640b5f3b8abb6" + integrity sha512-5NPgf87AT2STgwa2ntRMr45jTKrYBGkVU36yT0ig/n/GMAa3oPqhZfIQ2kMEimReg0+t9kZViDVZ83qfVUlckg== + dependencies: + degenerator "^5.0.0" + netmask "^2.0.2" + package-hash@^4.0.0: version "4.0.0" resolved "https://registry.yarnpkg.com/package-hash/-/package-hash-4.0.0.tgz#3537f654665ec3cc38827387fc904c163c54f506" @@ -7592,6 +7723,15 @@ socks-proxy-agent@^7.0.0: debug "^4.3.3" socks "^2.6.2" +socks-proxy-agent@^8.0.4: + version "8.0.4" + resolved "https://registry.yarnpkg.com/socks-proxy-agent/-/socks-proxy-agent-8.0.4.tgz#9071dca17af95f483300316f4b063578fa0db08c" + integrity sha512-GNAq/eg8Udq2x0eNiFkr9gRg5bA7PXEWagQdeRX4cPSG+X/8V38v637gim9bjFptMk1QWsCTr0ttrJEiXbNnRw== + dependencies: + agent-base "^7.1.1" + debug "^4.3.4" + socks "^2.8.3" + socks@^2.6.2: version "2.6.2" resolved "https://registry.yarnpkg.com/socks/-/socks-2.6.2.tgz#ec042d7960073d40d94268ff3bb727dc685f111a" @@ -7600,6 +7740,14 @@ socks@^2.6.2: ip "^1.1.5" smart-buffer "^4.2.0" +socks@^2.8.3: + version "2.8.3" + resolved "https://registry.yarnpkg.com/socks/-/socks-2.8.3.tgz#1ebd0f09c52ba95a09750afe3f3f9f724a800cb5" + integrity sha512-l5x7VUUWbjVFbafGLxPWkYsHIhEvmF85tbIeFZWc8ZPtoMyybuEhL7Jye/ooC4/d48FgOjSJXgsF/AJPYCW8Zw== + dependencies: + ip-address "^9.0.5" + smart-buffer "^4.2.0" + sort-keys@^2.0.0: version "2.0.0" resolved "https://registry.yarnpkg.com/sort-keys/-/sort-keys-2.0.0.tgz#658535584861ec97d730d6cf41822e1f56684128" @@ -7622,7 +7770,7 @@ source-map-support@^0.5.16: buffer-from "^1.0.0" source-map "^0.6.0" -source-map@^0.6.0, source-map@^0.6.1: +source-map@^0.6.0, source-map@^0.6.1, source-map@~0.6.1: version "0.6.1" resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263" integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g== @@ -7684,6 +7832,11 @@ split@^1.0.0: dependencies: through "2" +sprintf-js@^1.1.3: + version "1.1.3" + resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.1.3.tgz#4914b903a2f8b685d17fdf78a70e917e872e444a" + integrity sha512-Oo+0REFV59/rz3gfJNKQiBlwfHaSESl1pcGyABQsnnIfWOFt6JNj5gCog2U6MLZ//IGYD+nA8nI+mTShREReaA== + sprintf-js@~1.0.2: version "1.0.3" resolved "https://registry.yarnpkg.com/sprintf-js/-/sprintf-js-1.0.3.tgz#04e6926f662895354f3dd015203633b857297e2c" @@ -8039,6 +8192,11 @@ tsd@^0.31.2: path-exists "^4.0.0" read-pkg-up "^7.0.0" +tslib@^2.0.1: + version "2.8.1" + resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.8.1.tgz#612efe4ed235d567e8aba5f2a5fab70280ade83f" + integrity sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w== + tslib@^2.1.0, tslib@^2.3.0, tslib@^2.4.0: version "2.4.0" resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.4.0.tgz#7cecaa7f073ce680a05847aa77be941098f36dc3" From 222536e63a78622f5c77779f84d8e73ab355396e Mon Sep 17 00:00:00 2001 From: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:40:44 +0530 Subject: [PATCH 3/6] typo fixes --- packages/core/src/percy.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/packages/core/src/percy.js b/packages/core/src/percy.js index 6276ccb28..2ce2d2f3e 100644 --- a/packages/core/src/percy.js +++ b/packages/core/src/percy.js @@ -5,12 +5,11 @@ import { getProxy } from '@percy/client/utils'; import Browser from './browser.js'; import Pako from 'pako'; import { - base64encode - , + base64encode, generatePromise, yieldAll, - yieldTo - , redactSecrets, + yieldTo, + redactSecrets, detectSystemProxyAndLog } from './utils.js'; From 2317844de15bea4b85a145020cd0349a14aa26d3 Mon Sep 17 00:00:00 2001 From: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com> Date: Tue, 19 Nov 2024 11:54:43 +0530 Subject: [PATCH 4/6] PR comments addressed --- packages/client/src/proxy.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/packages/client/src/proxy.js b/packages/client/src/proxy.js index 427b5152e..911f7a727 100644 --- a/packages/client/src/proxy.js +++ b/packages/client/src/proxy.js @@ -11,11 +11,11 @@ const STATUS_REG = /^HTTP\/1.[01] (\d*)/; // function to create PAC proxy agent function createPacAgent(pacUrl, options = {}) { + pacUrl = stripQuotesAndSpaces(pacUrl); try { const agent = new PacProxyAgent(pacUrl, { keepAlive: true, - ...options, - rejectUnauthorized: false + ...options }); logger('client:proxy').info(`Successfully loaded PAC file from: ${pacUrl}`); @@ -244,12 +244,12 @@ export function proxyAgentFor(url, options) { try { let agent; - const pacUrl = process.env.PERCY_PAC_FILE_PATH; + const pacUrl = process.env.PERCY_PAC_FILE_URL; // If PAC URL is provided, use PAC proxy if (pacUrl) { logger('client:proxy').info(`Using PAC file from: ${pacUrl}`); - agent = createPacAgent(stripQuotesAndSpaces(pacUrl), options); + agent = createPacAgent(pacUrl, options); } else { // Fall back to other proxy configuration agent = protocol === 'https:' From e2934fe0f9716c41367a3e42b211ec0a8e0b190d Mon Sep 17 00:00:00 2001 From: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:01:18 +0530 Subject: [PATCH 5/6] Moved pac-proxy-agent lib dependency to percy client instead of main package --- package.json | 3 --- packages/client/package.json | 1 + packages/client/src/proxy.js | 2 +- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index be3a68135..154d7ae76 100644 --- a/package.json +++ b/package.json @@ -59,8 +59,5 @@ "nyc": "^15.1.0", "rollup": "^2.53.2", "tsd": "^0.31.2" - }, - "dependencies": { - "pac-proxy-agent": "^7.0.2" } } diff --git a/packages/client/package.json b/packages/client/package.json index ac0d5be9a..4ecfcf826 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -35,6 +35,7 @@ "dependencies": { "@percy/env": "1.30.1", "@percy/logger": "1.30.1", + "pac-proxy-agent": "^7.0.2", "pako": "^2.1.0" } } diff --git a/packages/client/src/proxy.js b/packages/client/src/proxy.js index 911f7a727..291928948 100644 --- a/packages/client/src/proxy.js +++ b/packages/client/src/proxy.js @@ -17,7 +17,7 @@ function createPacAgent(pacUrl, options = {}) { keepAlive: true, ...options }); - + logger('client:proxy').info(`Successfully loaded PAC file from: ${pacUrl}`); return agent; } catch (error) { From 68d38858c98e2e120be997e016168c44684b3a84 Mon Sep 17 00:00:00 2001 From: Khushhal Maheshwari <25052873+khushhalm@users.noreply.github.com> Date: Tue, 19 Nov 2024 13:03:25 +0530 Subject: [PATCH 6/6] Resolved conflicts --- packages/client/package.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index 4ecfcf826..82d474aa8 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -1,6 +1,6 @@ { "name": "@percy/client", - "version": "1.30.1", + "version": "1.30.2", "license": "MIT", "repository": { "type": "git", @@ -33,8 +33,8 @@ "test:coverage": "yarn test --coverage" }, "dependencies": { - "@percy/env": "1.30.1", - "@percy/logger": "1.30.1", + "@percy/env": "1.30.2", + "@percy/logger": "1.30.2", "pac-proxy-agent": "^7.0.2", "pako": "^2.1.0" }