chromedriver
Advanced tools
Comparing version
@@ -29,6 +29,4 @@ 'use strict'; | ||
(async function install() { | ||
let cdnUrl = process.env.npm_config_chromedriver_cdnurl || process.env.CHROMEDRIVER_CDNURL || 'https://googlechromelabs.github.io'; | ||
const legacyCdnUrl = process.env.npm_config_chromedriver_legacy_cdnurl || process.env.CHROMEDRIVER_LEGACY_CDNURL || 'https://chromedriver.storage.googleapis.com'; | ||
// adapt http://chromedriver.storage.googleapis.com/ | ||
cdnUrl = cdnUrl.replace(/\/+$/, ''); | ||
const cdnUrl = (process.env.npm_config_chromedriver_cdnurl || process.env.CHROMEDRIVER_CDNURL || 'https://googlechromelabs.github.io').replace(/\/+$/, ''); | ||
const legacyCdnUrl = (process.env.npm_config_chromedriver_legacy_cdnurl || process.env.CHROMEDRIVER_LEGACY_CDNURL || 'https://chromedriver.storage.googleapis.com').replace(/\/+$/, ''); | ||
let chromedriverVersion = process.env.npm_config_chromedriver_version || process.env.CHROMEDRIVER_VERSION || helper.version; | ||
@@ -69,3 +67,4 @@ const detectChromedriverVersion = (process.env.npm_config_detect_chromedriver_version || process.env.DETECT_CHROMEDRIVER_VERSION) === 'true'; | ||
console.log('Current existing ChromeDriver binary is unavailable, proceeding with download and extraction.'); | ||
await downloadFile(useLegacyMethod ? legacyCdnUrl : cdnUrl, useLegacyMethod, downloadedFile, chromedriverVersion, platform, detectChromedriverVersion); | ||
const cdnBinariesUrl = (process.env.npm_config_chromedriver_cdnbinariesurl || process.env.CHROMEDRIVER_CDNBINARIESURL || 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing').replace(/\/+$/, ''); | ||
await downloadFile(useLegacyMethod ? legacyCdnUrl : cdnBinariesUrl, useLegacyMethod, downloadedFile, chromedriverVersion, platform, detectChromedriverVersion); | ||
await extractDownload(extractDirectory, chromedriverBinaryFilePath, downloadedFile); | ||
@@ -135,4 +134,3 @@ } | ||
} else { | ||
const dlBaseUrl = 'https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing'; // todo: make this configurable? | ||
const formattedDownloadUrl = `${dlBaseUrl}/${chromedriverVersion}/${platform}/${fileName}`; | ||
const formattedDownloadUrl = `${cdnUrl}/${chromedriverVersion}/${platform}/${fileName}`; | ||
console.log('Downloading from file: ', formattedDownloadUrl); | ||
@@ -139,0 +137,0 @@ await requestBinary(getRequestOptions(formattedDownloadUrl), downloadedFile); |
{ | ||
"name": "chromedriver", | ||
"version": "114.0.2", | ||
"version": "114.0.3", | ||
"keywords": [ | ||
@@ -33,3 +33,3 @@ "chromedriver", | ||
"axios": "^1.4.0", | ||
"compare-versions": "^5.0.3", | ||
"compare-versions": "^6.0.0", | ||
"extract-zip": "^2.0.1", | ||
@@ -41,4 +41,4 @@ "https-proxy-agent": "^5.0.1", | ||
"devDependencies": { | ||
"eslint": "^8.42.0", | ||
"typescript": "^5.1.3" | ||
"eslint": "^8.45.0", | ||
"typescript": "^5.1.6" | ||
}, | ||
@@ -48,2 +48,2 @@ "engines": { | ||
} | ||
} | ||
} |
@@ -39,5 +39,5 @@ # ChromeDriver | ||
Or add property into your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
``` | ||
```ini | ||
chromedriver_force_download=true | ||
@@ -54,21 +54,63 @@ ``` | ||
To use a mirror of the ChromeDriver binaries use npm config property `chromedriver_cdnurl`. | ||
Default is `https://chromedriver.storage.googleapis.com`. | ||
This allows you to use your own endpoints for metadata and binaries. It is useful in air gapped | ||
scenarios or if you have download restrictions, such as firewalls. | ||
This was changed for version 115 and greater | ||
([see details](https://groups.google.com/g/chromedriver-users/c/clpipqvOGjE)), | ||
but implemented in this package starting with version | ||
`114.0.2`. To see the configuration to prior versions check out this | ||
[README.md](https://github.com/giggio/node-chromedriver/tree/114.0.1#custom-binaries-url) | ||
at the latest tag where it was using the legacy urls (`114.0.1`). | ||
### For versions >= 115 | ||
There are two urls that need to be configured, one for metadata and one for binaries. | ||
The one for metadata is the "CDN url", and the one for binaries is the "CDN binaries url". | ||
See [Chrome for Testing](https://googlechromelabs.github.io/chrome-for-testing/) to understand | ||
how these urls work. | ||
Npm config: | ||
For metadata use `chromedriver_cdnurl`. The default is `https://googlechromelabs.github.io`. | ||
For binaries use `chromedriver_cdnurl`. The default is `https://edgedl.me.gvt1.com/edgedl/chrome/chrome-for-testing`. | ||
```shell | ||
npm install chromedriver --chromedriver_cdnurl=https://npmmirror.com/mirrors/chromedriver | ||
npm install chromedriver --chromedriver_cdnurl=https://npmmirror.com/metadata --chromedriver_cdnbinariesurl=https://npmmirror.com/binaries | ||
``` | ||
Or add property into your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
Or add these properties to your [`.npmrc`](https://docs.npmjs.com/cli/configuring-npm/npmrc) file: | ||
```ini | ||
chromedriver_cdnurl=https://npmmirror.com/metadata | ||
chromedriver_cdnbinariesurl=https://npmmirror.com/binaries | ||
``` | ||
chromedriver_cdnurl=https://npmmirror.com/mirrors/chromedriver | ||
Another option is to use the environment variables `CHROMEDRIVER_CDNURL` and `CHROMEDRIVER_CDNBINARIESURL`. | ||
```shell | ||
CHROMEDRIVER_CDNURL=https://npmmirror.com/metadata CHROMEDRIVER_CDNBINARIESURL=https://npmmirror.com/binaries npm install chromedriver | ||
``` | ||
Another option is to use PATH variable `CHROMEDRIVER_CDNURL`. | ||
### For versions < 115 | ||
There is one url to both metadata and binaries. | ||
To use a mirror of the ChromeDriver binaries use npm config property `chromedriver_legacy_cdnurl`. | ||
Default is `https://chromedriver.storage.googleapis.com`. | ||
```shell | ||
CHROMEDRIVER_CDNURL=https://npmmirror.com/mirrors/chromedriver npm install chromedriver | ||
npm install chromedriver --chromedriver_legacy_cdnurl=https://npmmirror.com/mirrors/chromedriver --chromedriver_version=LATEST_114 | ||
``` | ||
Or add a property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file: | ||
```ini | ||
chromedriver_legacy_cdnurl=https://npmmirror.com/mirrors/chromedriver | ||
``` | ||
Another option is to use the environment variable `CHROMEDRIVER_LEGACY_CDNURL`. | ||
```shell | ||
CHROMEDRIVER_LEGACY_CDNURL=https://npmmirror.com/mirrors/chromedriver npm install chromedriver --chromedriver_version=LATEST_114 | ||
``` | ||
## Custom binaries file | ||
@@ -82,5 +124,5 @@ | ||
Or add property into your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
``` | ||
```ini | ||
chromedriver_filepath=/path/to/chromedriver_mac64.zip | ||
@@ -126,5 +168,5 @@ ``` | ||
Or add property into your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
``` | ||
```ini | ||
chromedriver_skip_download=true | ||
@@ -225,5 +267,5 @@ ``` | ||
Or add property into your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
``` | ||
```ini | ||
chromedriver_version=LATEST | ||
@@ -260,5 +302,5 @@ ``` | ||
Or add property into your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
``` | ||
```ini | ||
detect_chromedriver_version=true | ||
@@ -284,5 +326,5 @@ ``` | ||
Or add property into your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
Or add property to your [`.npmrc`](https://docs.npmjs.com/files/npmrc) file. | ||
``` | ||
```ini | ||
include_chromium=true | ||
@@ -289,0 +331,0 @@ ``` |
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 2 instances in 1 package
43411
4.8%370
12.8%472
-0.42%32
6.67%+ Added
- Removed
Updated