Socket
Socket
Sign inDemoInstall

saucelabs

Package Overview
Dependencies
6
Maintainers
4
Versions
121
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 4.0.2 to 4.1.0

build/commands/sc.js

2

build/cli.js

@@ -19,3 +19,3 @@ "use strict";

const run = () => {
let argv = _yargs.default.usage(_constants.USAGE).epilog(_constants.EPILOG).demandCommand().help();
let argv = _yargs.default.usage(_constants.USAGE).epilog(_constants.EPILOG).demandCommand().commandDir('commands').help().version(_constants.SAUCE_VERSION_NOTE);

@@ -22,0 +22,0 @@ for (const [commandName, options] of _constants.PROTOCOL_MAP) {

@@ -6,6 +6,16 @@ "use strict";

});
exports.CLI_PARAMS = exports.EPILOG = exports.USAGE = exports.TO_STRING_TAG = exports.SYMBOL_ITERATOR = exports.SYMBOL_TOSTRING = exports.SYMBOL_INSPECT = exports.REGION_MAPPING = exports.DEFAULT_OPTIONS = exports.JOB_ASSET_NAMES = exports.PARAMETERS_MAP = exports.PROTOCOL_MAP = void 0;
exports.SC_CLOSE_TIMEOUT = exports.SC_CLOSE_MESSAGE = exports.SC_READY_MESSAGE = exports.SC_PARAMS_TO_STRIP = exports.SC_CLI_PARAM_KEYS = exports.SAUCE_CONNECT_CLI_PARAMS = exports.CLI_PARAMS = exports.EPILOG = exports.USAGE = exports.TO_STRING_TAG = exports.SYMBOL_ITERATOR = exports.SYMBOL_TOSTRING = exports.SYMBOL_INSPECT = exports.REGION_MAPPING = exports.DEFAULT_OPTIONS = exports.JOB_ASSET_NAMES = exports.PARAMETERS_MAP = exports.PROTOCOL_MAP = exports.SAUCE_VERSION_NOTE = exports.SAUCE_CONNECT_DISTS = exports.SAUCE_CONNECT_BASE = exports.SAUCE_CONNECT_VERSION = void 0;
var _changeCase = require("change-case");
var _package = require("../package.json");
const SAUCE_CONNECT_VERSION = '4.5.4';
exports.SAUCE_CONNECT_VERSION = SAUCE_CONNECT_VERSION;
const SAUCE_CONNECT_BASE = 'https://saucelabs.com/downloads';
exports.SAUCE_CONNECT_BASE = SAUCE_CONNECT_BASE;
const SAUCE_CONNECT_DISTS = [[`${SAUCE_CONNECT_BASE}/sc-${SAUCE_CONNECT_VERSION}-osx.zip`, 'darwin'], [`${SAUCE_CONNECT_BASE}/sc-${SAUCE_CONNECT_VERSION}-win32.zip`, 'win32'], [`${SAUCE_CONNECT_BASE}/sc-${SAUCE_CONNECT_VERSION}-linux.tar.gz`, 'linux', 'x64'], [`${SAUCE_CONNECT_BASE}/sc-${SAUCE_CONNECT_VERSION}_linux32.tar.gz`, 'linux']];
exports.SAUCE_CONNECT_DISTS = SAUCE_CONNECT_DISTS;
const SAUCE_VERSION_NOTE = `node-saucelabs v${_package.version}\nSauce Connect v${SAUCE_CONNECT_VERSION}`;
exports.SAUCE_VERSION_NOTE = SAUCE_VERSION_NOTE;
const protocols = [require('../apis/sauce.json'), require('../apis/rdc.json'), require('../apis/performance.json')];

@@ -111,6 +121,6 @@ const protocolFlattened = new Map();

}, {
alias: 'h',
name: 'headless',
default: DEFAULT_OPTIONS.headless,
description: 'if set to true you are accessing the headless Sauce instances (this discards the `region` option)'
description: 'if set to true you are accessing the headless Sauce instances (this discards the `region` option)',
boolean: true
}, {

@@ -122,2 +132,141 @@ alias: 'p',

}];
exports.CLI_PARAMS = CLI_PARAMS;
exports.CLI_PARAMS = CLI_PARAMS;
const CLI_PARAM_KEYS = CLI_PARAMS.map(param => param.name);
const CLI_PARAM_ALIASES = CLI_PARAMS.map(param => param.alias).filter(Boolean);
const SAUCE_CONNECT_CLI_PARAMS = [{
alias: 'a',
name: 'auth',
description: 'Perform basic authentication when an URL on <host:port> asks for a username and password.'
}, {
name: 'cainfo',
description: 'CA certificate bundle to use for verifying REST connections. (default "/usr/local/etc/openssl/cert.pem")'
}, {
name: 'capath',
description: 'Directory of CA certs to use for verifying REST connections. (default "/etc/ssl/certs")'
}, {
alias: 'c',
name: 'config-file',
description: 'Path to YAML config file. Please refer to https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Command+Line+Reference for a sample configuration file.'
}, {
alias: 'D',
name: 'direct-domains',
description: 'Comma-separated list of domains. Requests whose host matches one of these will be relayed directly through the internet, instead of through the tunnel.'
}, {
name: 'dns',
description: 'Use specified name server. To specify multiple servers, separate them with comma. Use IP addresses, optionally with a port number, the two separated by a colon. Example: --dns 8.8.8.8,8.8.4.4:53'
}, {
name: 'doctor',
description: 'Perform checks to detect possible misconfiguration or problems.'
}, {
alias: 'F',
name: 'fast-fail-regexps',
description: 'Comma-separated list of regular expressions. Requests matching one of these will get dropped instantly and will not go through the tunnel.'
}, {
alias: 'z',
name: 'log-stats',
description: 'Log statistics about HTTP traffic every <seconds>.',
type: 'number'
}, {
alias: 'l',
name: 'logfile',
description: 'Specify custom logfile.'
}, {
name: 'max-logsize',
description: 'Rotate logfile after reaching <bytes> size. Disabled by default.',
type: 'number'
}, {
alias: 'M',
name: 'max-missed-acks',
description: 'The maximum amount of keepalive acks that can be missed before the client will trigger a reconnect. (default 30)',
type: 'number',
default: 30
}, {
name: 'metrics-address',
description: 'host:port for the internal web server used to expose client side metrics. (default "localhost:8888")'
}, {
name: 'no-autodetect',
description: 'Disable the autodetection of proxy settings.'
}, {
alias: 'N',
name: 'no-proxy-caching',
description: 'Disable caching in Sauce Connect. All requests will be sent through the tunnel.'
}, {
name: 'no-remove-colliding-tunnels',
description: 'Don\'t remove identified tunnels with the same name, or any other default tunnels if this is a default tunnel. Jobs will be distributed between these tunnels, enabling load balancing and high availability. By default, colliding tunnels will be removed when Sauce Connect is starting up.'
}, {
alias: 'B',
name: 'no-ssl-bump-domains',
description: 'Comma-separated list of domains. Requests whose host matches one of these will not be SSL re-encrypted.'
}, {
name: 'pac',
description: 'Proxy autoconfiguration. Can be an http(s) or local file:// (absolute path only) URI.'
}, {
alias: 'd',
name: 'pidfile',
description: 'File that will be created with the pid of the process.'
}, {
alias: 'T',
name: 'proxy-tunnel',
description: 'Use the proxy configured with -p for the tunnel connection.'
}, {
alias: 'w',
name: 'proxy-userpwd',
description: 'Username and password required to access the proxy configured with -p.'
}, {
alias: 'f',
name: 'readyfile',
description: 'File that will be touched to signal when tunnel is ready.'
}, {
alias: 'x',
name: 'rest-url',
description: 'Advanced feature: Connect to Sauce REST API at alternative URL. Use only if directed to do so by Sauce Labs support. (default "https://saucelabs.com/rest/v1")'
}, {
alias: 'X',
name: 'scproxy-port',
description: 'Port on which scproxy will be listening.'
}, {
name: 'scproxy-read-limit',
description: 'Rate limit reads in scproxy to X bytes per second. This option can be used to adjust local network transfer rate in order not to overload the tunnel connection.'
}, {
name: 'scproxy-write-limit',
description: 'Rate limit writes in scproxy to X bytes per second. This option can be used to adjust local network transfer rate in order not to overload the tunnel connection.'
}, {
alias: 'P',
name: 'se-port',
description: 'Port on which Sauce Connect\'s Selenium relay will listen for requests. Selenium commands reaching Connect on this port will be relayed to Sauce Labs securely and reliably through Connect\'s tunnel (default 4445)',
type: 'number',
default: 4445
}, {
alias: 's',
name: 'shared-tunnel',
description: 'Let sub-accounts of the tunnel owner use the tunnel if requested.'
}, {
name: 'tunnel-cainfo',
description: 'CA certificate bundle to use for verifying tunnel connections. (default "/usr/local/etc/openssl/cert.pem")'
}, {
name: 'tunnel-capath',
description: 'Directory of CA certs to use for verifying tunnel connections. (default "/etc/ssl/certs")'
}, {
name: 'tunnel-cert',
description: 'Specify certificate to use for the tunnel connection, either public or private. Default: private. (default "private")'
}, {
alias: 't',
name: 'tunnel-domains',
description: 'Inverse of \'--direct-domains\'. Only requests for domains in this list will be sent through the tunnel. Overrides \'--direct-domains\'.'
}, {
alias: 'i',
name: 'tunnel-identifier',
description: 'Don\'t automatically assign jobs to this tunnel. Jobs will use it only by explicitly providing the right identifier.'
}];
exports.SAUCE_CONNECT_CLI_PARAMS = SAUCE_CONNECT_CLI_PARAMS;
const SAUCE_CONNECT_CLI_PARAM_ALIASES = SAUCE_CONNECT_CLI_PARAMS.map(param => param.alias).filter(Boolean);
const SC_CLI_PARAM_KEYS = SAUCE_CONNECT_CLI_PARAMS.map(param => param.name);
exports.SC_CLI_PARAM_KEYS = SC_CLI_PARAM_KEYS;
const SC_PARAMS_TO_STRIP = [...CLI_PARAM_KEYS, ...CLI_PARAM_ALIASES, ...SAUCE_CONNECT_CLI_PARAM_ALIASES];
exports.SC_PARAMS_TO_STRIP = SC_PARAMS_TO_STRIP;
const SC_READY_MESSAGE = 'Sauce Connect is up, you may start your tests';
exports.SC_READY_MESSAGE = SC_READY_MESSAGE;
const SC_CLOSE_MESSAGE = 'Goodbye';
exports.SC_CLOSE_MESSAGE = SC_CLOSE_MESSAGE;
const SC_CLOSE_TIMEOUT = 5000;
exports.SC_CLOSE_TIMEOUT = SC_CLOSE_TIMEOUT;

@@ -12,4 +12,8 @@ "use strict";

var _child_process = require("child_process");
var _got = _interopRequireDefault(require("got"));
var _binWrapper = _interopRequireDefault(require("bin-wrapper"));
var _changeCase = require("change-case");

@@ -88,2 +92,10 @@

/**
* provide access to Sauce Connect interface
*/
if (propName === 'startSauceConnect') {
return this._startSauceConnect.bind(this);
}
/**
* allow to return publicly registered class properties

@@ -209,2 +221,69 @@ */

async _startSauceConnect(argv, fromCLI) {
if (!fromCLI) {
for (const [k, v] of Object.entries(argv)) {
if (k.includes('-')) {
continue;
}
argv[k.split(/(?=[A-Z])/).join('-').toLowerCase()] = v;
}
}
const {
host,
basePath
} = _constants.PROTOCOL_MAP.get('listJobs');
const restUrl = (0, _utils.getSauceEndpoint)(host + basePath, this._options.region, this._options.headless) + '/v1';
const args = Object.entries(argv)
/**
* filter out yargs and yargs params
*/
.filter(([k]) => !['_', '$0', ..._constants.SC_PARAMS_TO_STRIP].includes(k))
/**
* remove duplicate params by yargs
*/
.filter(([k]) => !k.match(/[A-Z]/g)).map(([k, v]) => `--${k}=${v}`);
args.push(`--user=${this.username}`);
args.push(`--api-key=${this._accessKey}`);
args.push(`--rest-url=${restUrl}`);
const bin = _constants.SAUCE_CONNECT_DISTS.reduce((bin, dist) => {
bin.src(...dist);
return bin;
}, new _binWrapper.default());
bin.dest(_path.default.join(__dirname, 'bin', 'bin')).use(process.platform.startsWith('win') ? 'sc.exe' : 'sc').version(`v${_constants.SAUCE_CONNECT_VERSION}`);
await bin.run(['--version']);
const cp = (0, _child_process.spawn)(bin.path(), args);
return new Promise((resolve, reject) => {
const close = () => new Promise(resolveClose => {
process.kill(cp.pid, 'SIGINT');
const timeout = setTimeout(resolveClose, _constants.SC_CLOSE_TIMEOUT);
cp.stdout.on('data', data => {
const output = data.toString();
if (output.includes(_constants.SC_CLOSE_MESSAGE)) {
clearTimeout(timeout);
return resolveClose(returnObj);
}
});
});
const returnObj = {
cp,
close
};
cp.stderr.on('data', data => reject(new Error(data.toString())));
cp.stdout.on('data', data => {
if (data.toString().includes(_constants.SC_READY_MESSAGE)) {
return resolve(returnObj);
}
});
process.on('SIGINT', close);
return returnObj;
});
}
async _downloadJobAsset(jobId, assetName, {

@@ -211,0 +290,0 @@ filepath

{
"name": "saucelabs",
"version": "4.0.2",
"version": "4.1.0",
"author": "Christian Bromann <christian@saucelabs.com>",

@@ -25,3 +25,3 @@ "description": "A wrapper around Sauce Labs REST API",

"compile": "babel src -d build",
"eslint": "eslint ./src ./test",
"eslint": "eslint ./src/**/*.js ./tests/**/*.js",
"generate:docs": "babel-node ./scripts/generate-docs",

@@ -43,4 +43,5 @@ "generate:typings": "babel-node ./scripts/generate-typings",

"dependencies": {
"bin-wrapper": "^4.1.0",
"change-case": "^4.1.1",
"got": "^10.6.0",
"got": "^11.1.4",
"hash.js": "^1.1.7",

@@ -51,27 +52,27 @@ "tunnel": "0.0.6",

"devDependencies": {
"@babel/cli": "^7.2.3",
"@babel/core": "^7.1.2",
"@babel/node": "^7.2.2",
"@babel/plugin-proposal-class-properties": "^7.1.0",
"@babel/plugin-proposal-export-default-from": "^7.0.0",
"@babel/plugin-proposal-function-bind": "^7.0.0",
"@babel/plugin-proposal-optional-catch-binding": "^7.2.0",
"@babel/plugin-syntax-export-default-from": "^7.0.0",
"@babel/preset-env": "^7.1.0",
"@babel/register": "^7.0.0",
"babel-core": "^7.0.0-bridge.0",
"babel-eslint": "^10.0.1",
"babel-jest": "^24.1.0",
"babel-plugin-source-map-support": "^2.0.1",
"codecov": "^3.0.0",
"eslint": "^4.7.2",
"eslint-plugin-import": "^2.8.0",
"jest": "^24.1.0",
"np": "^2.18.2",
"@babel/cli": "^7.8.4",
"@babel/core": "^7.9.6",
"@babel/node": "^7.8.7",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-export-default-from": "^7.8.3",
"@babel/plugin-proposal-function-bind": "^7.8.3",
"@babel/plugin-proposal-optional-catch-binding": "^7.8.3",
"@babel/plugin-syntax-export-default-from": "^7.8.3",
"@babel/preset-env": "^7.9.6",
"@babel/register": "^7.9.0",
"babel-core": "^6.26.3",
"babel-eslint": "^10.1.0",
"babel-jest": "^26.0.1",
"babel-plugin-source-map-support": "^2.1.1",
"codecov": "^3.7.0",
"eslint": "^7.0.0",
"eslint-plugin-import": "^2.20.2",
"jest": "^26.0.1",
"np": "^6.2.3",
"npm-run-all": "^4.1.5",
"prettier": "^1.18.2",
"rimraf": "^2.6.2",
"source-map-support": "^0.5.9",
"swagger-typescript-codegen": "^1.10.0",
"typescript": "^3.8.3"
"prettier": "^2.0.5",
"rimraf": "^3.0.2",
"source-map-support": "^0.5.19",
"swagger-typescript-codegen": "^3.0.5",
"typescript": "^3.9.2"
},

@@ -86,3 +87,3 @@ "jest": {

"global": {
"branches": 94,
"branches": 93,
"functions": 100,

@@ -89,0 +90,0 @@ "lines": 96,

@@ -7,3 +7,3 @@ <p align="center">

Wrapper around all Sauce Labs REST APIs for [Node.js](http://nodejs.org/) (v8 or higher) and the browser.
Wrapper around all Sauce Labs REST APIs for [Node.js](http://nodejs.org/) (v8 or higher) including support for [Sauce Connect Proxy](https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy) and TypeScript definitions.

@@ -82,5 +82,5 @@ ## Install

```sh
sl --help
$ sl --help
# show description for specific command
sl listJobs --help
$ sl listJobs --help
```

@@ -91,3 +91,3 @@

```sh
sl updateJob cb-onboarding 690c5877710c422d8be4c622b40c747f "{\"passed\":false}"
$ sl updateJob cb-onboarding 690c5877710c422d8be4c622b40c747f "{\"passed\":false}"
```

@@ -98,4 +98,16 @@

```sh
sl downloadJobAsset 690c5877710c422d8be4c622b40c747f video.mp4 --filepath ./video.mp4
$ sl downloadJobAsset 690c5877710c422d8be4c622b40c747f video.mp4 --filepath ./video.mp4
```
or start Sauce Connect Proxy in EU datacenter:
```sh
$ sl sc --region eu --se-port 4445
# see all available Sauce Connect parameters via:
$ sl sc --help
```
You can see all available Sauce Connect parameters on the [Sauce Labs Wiki Page](https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy+Command-Line+Quick+Reference+Guide).
### As NPM Package

@@ -156,2 +168,18 @@

*/
/**
* start Sauce Connect Proxy
*/
const sc = await api.startSauceConnect({
/**
* see all available parameters here: https://wiki.saucelabs.com/display/DOCS/Sauce+Connect+Proxy+Command-Line+Quick+Reference+Guide
* all parameters have to be applied camel cased instead of with hyphens, e.g.
* to apply the `--se-port` parameter, set:
*/
sePort: 1234
})
// run a test
await sc.close()
})()

@@ -158,0 +186,0 @@ ```

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc