You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

browserstack-local

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

browserstack-local - npm Package Compare versions

Comparing version

to
1.5.6

22

lib/download.js
const https = require('https'),
fs = require('fs'),
HttpsProxyAgent = require('https-proxy-agent'),
url = require('url');
url = require('url'),
zlib = require('zlib');

@@ -20,3 +21,3 @@ const binaryPath = process.argv[2], httpPath = process.argv[3], proxyHost = process.argv[4], proxyPort = process.argv[5], useCaCertificate = process.argv[6];

} catch(err) {
console.log("failed to read cert file", err)
console.log('failed to read cert file', err);
}

@@ -26,4 +27,19 @@ }

options.headers = Object.assign({}, options.headers, {
'accept-encoding': 'gzip, *',
'user-agent': process.env.USER_AGENT,
});
https.get(options, function (response) {
response.pipe(fileStream);
const contentEncoding = response.headers['content-encoding'];
if (typeof contentEncoding === 'string' && contentEncoding.match(/gzip/i)) {
if (process.env.BROWSERSTACK_LOCAL_DEBUG_GZIP) {
console.info('Using gzip in ' + options.headers['user-agent']);
}
response.pipe(zlib.createGunzip()).pipe(fileStream);
} else {
response.pipe(fileStream);
}
response.on('error', function(err) {

@@ -30,0 +46,0 @@ console.error('Got Error in binary download response', err);

39

lib/LocalBinary.js

@@ -7,5 +7,9 @@ var https = require('https'),

childProcess = require('child_process'),
zlib = require('zlib'),
HttpsProxyAgent = require('https-proxy-agent'),
version = require('../package.json').version,
LocalError = require('./LocalError');
const packageName = 'browserstack-local-nodejs';
function LocalBinary(){

@@ -16,15 +20,17 @@ this.hostOS = process.platform;

this.getDownloadPath = function () {
let sourceURL = 'https://www.browserstack.com/local-testing/downloads/binaries/';
if(this.hostOS.match(/darwin|mac os/i)){
return 'https://www.browserstack.com/local-testing/downloads/binaries/BrowserStackLocal-darwin-x64';
return sourceURL + 'BrowserStackLocal-darwin-x64';
} else if(this.hostOS.match(/mswin|msys|mingw|cygwin|bccwin|wince|emc|win32/i)) {
this.windows = true;
return 'https://www.browserstack.com/local-testing/downloads/binaries/BrowserStackLocal.exe';
return sourceURL + 'BrowserStackLocal.exe';
} else {
if(this.is64bits) {
if(this.isAlpine())
return 'https://www.browserstack.com/local-testing/downloads/binaries/BrowserStackLocal-alpine';
return sourceURL + 'BrowserStackLocal-alpine';
else
return 'https://www.browserstack.com/local-testing/downloads/binaries/BrowserStackLocal-linux-x64';
return sourceURL + 'BrowserStackLocal-linux-x64';
} else {
return 'https://www.browserstack.com/local-testing/downloads/binaries/BrowserStackLocal-linux-ia32';
return sourceURL + 'BrowserStackLocal-linux-ia32';
}

@@ -86,3 +92,5 @@ }

try{
const obj = childProcess.spawnSync(cmd, opts);
const userAgent = [packageName, version].join('/');
const env = Object.assign({ 'USER_AGENT': userAgent }, process.env);
const obj = childProcess.spawnSync(cmd, opts, { env: env });
let output;

@@ -128,8 +136,23 @@ if(obj.stdout.length > 0) {

} catch(err) {
console.log("failed to read cert file", err)
console.log('failed to read cert file', err);
}
}
options.headers = Object.assign({}, options.headers, {
'accept-encoding': 'gzip, *',
'user-agent': [packageName, version].join('/'),
});
https.get(options, function (response) {
response.pipe(fileStream);
const contentEncoding = response.headers['content-encoding'];
if (typeof contentEncoding === 'string' && contentEncoding.match(/gzip/i)) {
if (process.env.BROWSERSTACK_LOCAL_DEBUG_GZIP) {
console.info('Using gzip in ' + options.headers['user-agent']);
}
response.pipe(zlib.createGunzip()).pipe(fileStream);
} else {
response.pipe(fileStream);
}
response.on('error', function(err) {

@@ -136,0 +159,0 @@ console.error('Got Error in binary download response', err);

{
"name": "browserstack-local",
"version": "1.5.5",
"version": "1.5.6",
"description": "Nodejs bindings for BrowserStack Local",

@@ -5,0 +5,0 @@ "engine": "^0.10.44",