|
1 | 1 | import merge from 'lodash.merge'; |
2 | | -import { log } from '../logger'; |
3 | 2 | import { LaunchContext, LaunchContextOptions } from '../launch-context'; |
4 | 3 | import { BrowserController } from './browser-controller'; |
5 | 4 | import { throwImplementationNeeded } from './utils'; |
6 | 5 | import { UnwrapPromise } from '../utils'; |
7 | 6 |
|
8 | | -// eslint-disable-next-line @typescript-eslint/no-var-requires -- TODO: Type this module, and convert import |
9 | | -const proxyChain = require('proxy-chain'); |
10 | | - |
11 | 7 | /** |
12 | 8 | * Each plugin expects an instance of the object with the `.launch()` property. |
13 | 9 | * For Puppeteer, it is the `puppeteer` module itself, whereas for Playwright |
@@ -177,44 +173,4 @@ export abstract class BrowserPlugin< |
177 | 173 | protected abstract _createController(): BrowserController<Library, LibraryOptions, LaunchResult, NewPageOptions, NewPageResult> { |
178 | 174 | throwImplementationNeeded('_createController'); |
179 | 175 | } |
180 | | - |
181 | | - /** |
182 | | - * Starts proxy-chain server - https://www.npmjs.com/package/proxy-chain#anonymizeproxyproxyurl-callback |
183 | | - * @param proxyUrl Proxy URL with username and password. |
184 | | - * @return URL of the anonymization proxy server that needs to be closed after the proxy is not used anymore. |
185 | | - * @private |
186 | | - */ |
187 | | - protected async _getAnonymizedProxyUrl(proxyUrl: string): Promise<string> { |
188 | | - try { |
189 | | - return await proxyChain.anonymizeProxy(proxyUrl); |
190 | | - } catch (e) { |
191 | | - throw new Error(`BrowserPool: Could not anonymize proxyUrl: ${proxyUrl}. Reason: ${(e as Error).message}.`); |
192 | | - } |
193 | | - } |
194 | | - |
195 | | - /** |
196 | | - * @param proxyUrl Anonymized proxy URL of a running proxy server. |
197 | | - * @private |
198 | | - */ |
199 | | - protected async _closeAnonymizedProxy(proxyUrl: string): Promise<boolean> { |
200 | | - return proxyChain.closeAnonymizedProxy(proxyUrl, true).catch((err: Error) => { |
201 | | - log.debug(`Could not close anonymized proxy server.\nCause:${err.message}`); |
202 | | - }); |
203 | | - } |
204 | | - |
205 | | - /** |
206 | | - * Checks if proxy URL should be anonymized. |
207 | | - * @private |
208 | | - */ |
209 | | - protected _shouldAnonymizeProxy(proxyUrl: string): boolean { |
210 | | - const parsedProxyUrl = proxyChain.parseUrl(proxyUrl); |
211 | | - if (parsedProxyUrl.username || parsedProxyUrl.password) { |
212 | | - if (parsedProxyUrl.scheme !== 'http') { |
213 | | - throw new Error('Invalid "proxyUrl" option: authentication is only supported for HTTP proxy type.'); |
214 | | - } |
215 | | - return true; |
216 | | - } |
217 | | - |
218 | | - return false; |
219 | | - } |
220 | 176 | } |
0 commit comments