Socket
Socket
Sign inDemoInstall

selenium-standalone

Package Overview
Dependencies
Maintainers
10
Versions
169
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

selenium-standalone - npm Package Compare versions

Comparing version 8.1.1 to 8.1.2

9

lib/check-started.js

@@ -19,2 +19,3 @@ module.exports = checkStarted;

const DEFAULT_SELENUIM_CHECK_STARTED_PAUSE = 500; // 0.5 second
const GOT_STARTUP_TIMEOUT = 10000; // 10 secs

@@ -29,4 +30,8 @@ const serverStartupTimeoutMS =

responseType: 'json',
timeout: serverStartupTimeoutMS,
retry: 0,
timeout: {
request: GOT_STARTUP_TIMEOUT,
},
retry: {
limit: 0,
},
};

@@ -33,0 +38,0 @@

const tarStream = require('tar-stream');
const os = require('os');
const crypto = require('crypto');
const mkdirp = require('mkdirp');

@@ -83,33 +82,10 @@ const path = require('path');

async function checksum(filepath) {
if (!fs.existsSync(filepath)) {
return null;
}
return new Promise((resolve, reject) => {
const hash = crypto.createHash('md5');
const stream = fs.createReadStream(filepath);
stream.on('error', reject);
stream.on('data', (data) => hash.update(data, 'utf8'));
stream.on('end', () => resolve(hash.digest('hex')));
});
}
async function isUpToDate(url, requestOpts, hash) {
if (!hash) {
async function isUpToDate(url, requestOpts, etag) {
if (!etag) {
return false;
}
/**
* the msedgedriver.azureedge.net endpoint to download edgedriver
* doesn't support the "If-None-Match" header and will always re-download
* it. To prevent this we always assume it is the latest
*/
if (hash && url.includes('edgedriver')) {
return true;
}
const options = merge({}, requestOpts, {
headers: {
'If-None-Match': `"${hash}"`,
'If-None-Match': etag,
},

@@ -260,3 +236,2 @@ });

logInstallSummary,
checksum,
isUpToDate,

@@ -263,0 +238,0 @@ getTempFileName,

/* eslint-disable no-shadow */
module.exports = install;
const fs = require('fs');
const { createWriteStream } = require('fs');
const { readFile, writeFile } = require('fs').promises;
const path = require('path');

@@ -20,3 +21,2 @@ const got = require('got');

logInstallSummary,
checksum,
isUpToDate,

@@ -119,4 +119,10 @@ getTempFileName,

async function onlyInstallMissingFiles(opts) {
const hash = await checksum(opts.to);
const isLatest = await isUpToDate(opts.from, requestOpts, hash);
let etag;
try {
etag = await readFile(`${opts.to}.etag`);
} catch (err) {
// ENOENT means not found which is ok. But anything else re-raise
if (err.code != 'ENOENT') throw err;
}
const isLatest = await isUpToDate(opts.from, requestOpts, etag);

@@ -202,8 +208,3 @@ // File already exists. Prevent download/installation.

return new Promise((resolve, reject) =>
stream
.pipe(fs.createWriteStream(to))
.once('error', (err) => reject(logError('installSingleFile', err)))
.once('finish', resolve)
);
return writeDownloadStream(stream, to);
}

@@ -219,11 +220,3 @@

await new Promise((resolve, reject) => {
const msiWriteStream = fs
.createWriteStream(installerFile)
.once('error', (err) => reject(logError('downloadInstallerFile', err)));
stream.pipe(msiWriteStream);
msiWriteStream.once('finish', resolve);
});
await writeDownloadStream(stream, installerFile, `${to}.etag`);
return runInstaller(installerFile, from, to);

@@ -255,12 +248,3 @@ }

// Store downloaded compressed file
await new Promise((resolve, reject) => {
const gzipWriteStream = fs
.createWriteStream(to)
.once('error', (err) => reject(logError('installGzippedFile', err)));
stream.pipe(gzipWriteStream);
gzipWriteStream.once('finish', resolve);
});
await writeDownloadStream(stream, to);
return uncompressGzippedFile(from, to);

@@ -272,13 +256,3 @@ }

await new Promise((resolve, reject) => {
// Store downloaded compressed file
const zipWriteStream = fs
.createWriteStream(to)
.once('error', (err) => reject(logError('installZippedFile', err)));
stream.pipe(zipWriteStream);
// Uncompress downloaded file
zipWriteStream.once('finish', resolve);
});
await writeDownloadStream(stream, to);
return uncompressDownloadedFile(to);

@@ -328,2 +302,24 @@ }

}
async function writeDownloadStream(stream, to, etagPath = `${to}.etag`) {
const writeEtagPromise = new Promise((resolve, reject) => {
stream.once('response', async (response) => {
try {
await writeFile(etagPath, response.headers.etag);
resolve();
} catch (err) {
reject(err);
}
});
});
const writeFilePromise = new Promise((resolve, reject) => {
const writeStream = createWriteStream(to).once('error', (err) => reject(logError('writeDownloadStream', err)));
stream.pipe(writeStream);
writeStream.once('finish', resolve);
});
return Promise.all([writeEtagPromise, writeFilePromise]);
}
}

@@ -330,0 +326,0 @@

@@ -30,6 +30,2 @@ module.exports = start;

if (!opts.spawnOptions) {
opts.spawnOptions = {};
}
if (!opts.version) {

@@ -46,4 +42,2 @@ opts.version = defaultConfig.version;

) {
opts.seleniumArgs.unshift('false');
opts.seleniumArgs.unshift('--detect-drivers');
opts.seleniumArgs.unshift('standalone');

@@ -128,6 +122,2 @@ }

if (!opts.spawnOptions.stdio) {
opts.spawnOptions.stdio = 'ignore';
}
debug('Spawning Selenium Server process', opts.javaPath, args);

@@ -134,0 +124,0 @@ const selenium = spawn(opts.javaPath, args, opts.spawnOptions);

{
"name": "selenium-standalone",
"version": "8.1.1",
"version": "8.1.2",
"description": "installs a `selenium-standalone` command line to install and start a standalone selenium server",

@@ -66,8 +66,8 @@ "main": "index.js",

"json": "11.0.0",
"mocha": "9.2.2",
"mocha": "10.0.0",
"mversion": "2.0.1",
"npm-run-all": "^4.1.5",
"prettier": "2.6.2",
"release-it": "^14.10.0"
"release-it": "^15.0.0"
}
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc