Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

eshost

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eshost - npm Package Compare versions

Comparing version 3.6.0 to 3.7.0

.eslintrc.json

3

lib/Agent.js
'use strict';
const Path = require('path');
const cp = require('child_process');
class Agent {

@@ -7,0 +4,0 @@ constructor (options) {

@@ -16,3 +16,6 @@ 'use strict';

initialize() {
return Server.start(this.id).then(_ => {
// A method for cancelling the current `evalScript` operation (if any)
this._cancelEval = null;
return Server.start(this.id).then(() => {
this._url = `http://${this.webHost}:${this.webPort}/` +

@@ -22,5 +25,2 @@ `?clientId=${this.id}&shortName=${this.shortName}`;

});
// A method for cancelling the current `evalScript` operation (if any)
this._cancelEval = null;
}

@@ -27,0 +27,0 @@

@@ -17,3 +17,3 @@ 'use strict';

if(!error) { return error };
if (!error) { return error }

@@ -20,0 +20,0 @@ if (error.name === 'JavascriptError') {

@@ -15,3 +15,3 @@ 'use strict';

setBinaryPath(options, path) {
setBinaryPath() {
throw new Error('Cannot set binary path for edge driver');

@@ -18,0 +18,0 @@ }

'use strict';
const WebdriverAgent = require('../WebdriverAgent.js');
const firefox = require('selenium-webdriver/firefox')
const Capabilities = require('selenium-webdriver/lib/capabilities')
const firefox = require('selenium-webdriver/firefox');

@@ -7,0 +6,0 @@ class FirefoxAgent extends WebdriverAgent {

'use strict';
const fs = require('fs');
const temp = require('temp');
const path = require('path');
const isSymlink = require('is-symlink');
const inception = require('../inception');
const runtimePath = require('../runtimePath');
const inception = require('../inception');
const ConsoleAgent = require('../ConsoleAgent');

@@ -11,2 +12,4 @@

let DYLD_FRAMEWORK_PATH = process.env.DYLD_FRAMEWORK_PATH;
// JSC stack frame format:

@@ -25,16 +28,4 @@ // StackFrames: StackFrame+

const scriptStartMarker = '<<< SCRIPT START >>>';
const scriptEndMarker = '<<< SCRIPT END >>>';
const tempScriptFile = temp.path({ suffix: '.js' });
process.addListener('exit', function() {
try { fs.unlinkSync(tempScriptFile); } catch (e) { /* ignore */ }
});
const runtimeStr = inception(
fs.readFileSync(runtimePath.for('jsc'), 'utf8')
.replace('$FILE', JSON.stringify(runtimePath.for('jsc-create')))
.replace('$SCRIPT_FILE', JSON.stringify(tempScriptFile))
.replace('$SCRIPT_START_MARKER', JSON.stringify(scriptStartMarker))
.replace('$SCRIPT_END_MARKER', JSON.stringify(scriptEndMarker))
.replace(/\r?\n/g, '')

@@ -78,46 +69,50 @@ );

class JSCAgent extends ConsoleAgent {
receiveOut(cp, str) {
str = String(str);
constructor(...args) {
super(...args);
let script, out;
if (!this.scriptBuffer) {
// Search for script start marker.
let start = str.indexOf(scriptStartMarker);
if (start === -1) {
out = str;
} else {
out = str.substring(0, start);
/*
See: https://developer.apple.com/legacy/library/documentation/Darwin/Reference/ManPages/man1/dyld.1.html
let scriptStart = start + scriptStartMarker.length;
let scriptEnd = str.indexOf(scriptEndMarker);
if (scriptEnd === -1) {
// Incomplete load script, buffer content in 'scriptBuffer'.
this.scriptBuffer = str.substring(scriptStart);
} else {
script = str.substring(scriptStart, scriptEnd);
This is frustrating, but necessary. DYLD_FRAMEWORK_PATH won't appear
in process.env when node.js scripts are executed as binaries,
ie. have a /usr/bin/env she-bang, because DYLD_* vars are excluded from env output
$ export DYLD_FRAMEWORK_PATH="foo"
$ node -pe process.env.DYLD_FRAMEWORK_PATH
foo
$ env | grep "DYLD_FRAMEWORK_PATH"
(not found, nothing prints)
Still not convinced? The following code shows that even WebKit's own run-jsc
script must do this dance to ensure that DYLD_FRAMEWORK_PATH is set with the
correct path for executing built-from-source jsc:
- https://github.com/WebKit/webkit/blob/026ee0438dd6c9cff16c27eb7ce9eaed2b43491c/Tools/Scripts/run-jsc#L58-L61
- https://github.com/WebKit/webkit/blob/026ee0438dd6c9cff16c27eb7ce9eaed2b43491c/Tools/Scripts/webkitdirs.pm#L786-L789
- https://github.com/WebKit/webkit/blob/026ee0438dd6c9cff16c27eb7ce9eaed2b43491c/Tools/Scripts/webkitdirs.pm#L770-L784
*/
if (DYLD_FRAMEWORK_PATH === undefined) {
if (isSymlink.sync(this.hostPath)) {
let linked = fs.readlinkSync(this.hostPath);
if (linked.includes('WebKit/WebKitBuild')) {
DYLD_FRAMEWORK_PATH = path.dirname(linked);
}
}
} else {
out = '';
// Search script end marker.
let scriptEnd = str.indexOf(scriptEndMarker);
if (scriptEnd === -1) {
this.scriptBuffer += str;
} else {
script = this.scriptBuffer + str.substring(0, scriptEnd);
this.scriptBuffer = null;
if (this.hostPath.includes('WebKit/WebKitBuild')) {
DYLD_FRAMEWORK_PATH = path.dirname(this.hostPath);
}
}
}
if (script) {
fs.writeFile(tempScriptFile, script, err => {
if (err) throw err;
this.cpOptions = {
env: {
DYLD_FRAMEWORK_PATH
}
};
}
// Unblock script execution.
cp.stdin.write('\n');
});
}
return out;
createChildProcess(args = []) {
return super.createChildProcess(args, this.cpOptions);
}

@@ -124,0 +119,0 @@

@@ -7,6 +7,3 @@ 'use strict';

const ConsoleAgent = require('../ConsoleAgent');
const ErrorParser = require('../parseError.js');
const errorRe = /^(.*?):(\d+): ((\w+): (.*))[\w\W]*\3((:?\s+at.*\r?\n)*)$/m;
const runtimeStr = inception(

@@ -13,0 +10,0 @@ fs.readFileSync(runtimePath.for('node'), 'utf8')

'use strict';
const WebDriverAgent = require('../WebdriverAgent');
const { WebDriver, Capabilities } = require('selenium-webdriver');
const { WebDriver } = require('selenium-webdriver');
const swhttp = require('selenium-webdriver/http');

@@ -22,3 +22,3 @@

if (typeof options.webdriverServer !== 'string') {
throw new UnspeciedOptionError('webdriverServer');
throw new UnspecifiedOptionError('webdriverServer');
}

@@ -47,3 +47,2 @@ this.webdriverServer = options.webdriverServer;

_createDriver() {
const url = this.hostPath;
const client = Promise.resolve(new swhttp.HttpClient(this.webdriverServer));

@@ -50,0 +49,0 @@ const executor = new swhttp.Executor(client);

@@ -15,3 +15,3 @@ 'use strict';

setBinaryPath(options, path) {
setBinaryPath() {
throw new Error("Safari agent does not support custom binary paths");

@@ -18,0 +18,0 @@ }

@@ -14,3 +14,3 @@ 'use strict';

this.printCommand = 'print';
this.cpOptions = {};
// Promise for the child process created by the most recent invocation of

@@ -21,4 +21,4 @@ // `evalScript`

createChildProcess(args = []) {
return cp.spawn(this.hostPath, this.args.concat(args));
createChildProcess(args = [], options = {}) {
return cp.spawn(this.hostPath, this.args.concat(args), options);
}

@@ -39,3 +39,3 @@

this._cp = writeFile(tempfile, code)
.then(_ => this.createChildProcess([tempfile]));
.then(() => this.createChildProcess([tempfile]));

@@ -42,0 +42,0 @@ return this._cp.then(child => {

'use strict';
const EventEmitter = require('events');
const http = require('http');

@@ -11,5 +10,2 @@ const io = require('socket.io');

const connections = new Map();
const waitingIds = new Map();
const waitingResults = new Map();
const activeClients = new Set();

@@ -58,3 +54,3 @@ const runtimeHtml = fs.readFileSync(Path.join(__dirname, '../runtimes/browser.html'), 'utf8');

socket.on('print', ({value}) => this.gotStdout(value));
socket.on('execDone', _ => this.gotExecDone());
socket.on('execDone', () => this.gotExecDone());
if (this._onGotSocket) this._onGotSocket(this);

@@ -123,3 +119,3 @@ }

}
}).then(_ => {
}).then(() => {
let currentHandler = SocketHandler.byId.get(id);

@@ -126,0 +122,0 @@ if (!currentHandler) {

@@ -5,19 +5,18 @@ 'use strict';

const Server = require('./Server.js');
const Key = require('selenium-webdriver').Key;
class WebdriverAgent extends BrowserAgent {
setBinaryPath(path) {
setBinaryPath() {
throw new Error('Cannot call abstract method setBinaryPath');
}
setCapabilities(options) { /* default no-op */ }
setCapabilities() { /* default no-op */ }
initialize() {
return super.initialize()
.then(_ => {
.then(() => {
this._driver = this._createDriver()
return this._driver.get(this._url);
})
.then(_ => Server.waitForClientId(this.id))
.then(_ => this)
.then(() => Server.waitForClientId(this.id))
.then(() => this)
.catch(err => {

@@ -54,3 +53,3 @@ this.destroy();

.then(() => Promise.all([quitP, getP]));
return this._restartP.then(_ => {
return this._restartP.then(() => {
this._restartP = null;

@@ -69,3 +68,3 @@ return undefined;

return baseP.then(_ => this._driver.quit()).then(_ => super.destroy());
return baseP.then(() => this._driver.quit()).then(() => super.destroy());
}

@@ -72,0 +71,0 @@ }

{
"name": "eshost",
"version": "3.6.0",
"version": "3.7.0",
"description": "Invoke ECMAScript scripts in any command line JS engine.",

@@ -13,3 +13,4 @@ "main": "lib/eshost.js",

"devDependencies": {
"eslint": "^1.10.2",
"eslint": "^4.18.1",
"hasbin": "^1.2.3",
"mocha": "^2.3.4"

@@ -23,2 +24,3 @@ },

"error-stack-parser": "^1.3.3",
"is-symlink": "^0.1.1",
"selenium-webdriver": "^3.4.0",

@@ -25,0 +27,0 @@ "server-destroy": "^1.0.1",

@@ -7,9 +7,7 @@ var $ = {

var realm = Realm.create();
Realm.eval(realm, this.source);
var $child = Realm.shared;
$child.realm = realm;
$child.source = this.source;
Realm.shared = void 0;
$child.destroy = function () {
var realmId = Realm.createAllowCrossRealmAccess();
var realm = Realm.global(realmId);
Realm.eval(realmId, this.source);
realm.$.source = this.source;
realm.$.destroy = function () {
if (options.destroy) {

@@ -20,10 +18,11 @@ options.destroy();

for(var glob in options.globals) {
$child.setGlobal(glob, options.globals[glob]);
realm.$.global[glob] = options.globals[glob];
}
return $child;
return realm.$;
},
evalScript(code) {
var realmId = typeof this.realm === 'number' ? this.realm : Realm.current();
try {
Realm.eval(this.realm ? this.realm : Realm.current(), code);
Realm.eval(realmId, code);
return { type: 'normal', value: undefined }

@@ -42,4 +41,4 @@ } catch (e) {

IsHTMLDDA() { return {}; },
source: $SOURCE
source: $SOURCE,
realm: Realm.current(),
};
Realm.shared = $;

@@ -0,40 +1,10 @@

/* JavaScriptCore exposes a "$" object to its runtime */
/* Using this["\x24"]; prevents overwrite by ConsoleAgent */
var jsc = this["\x24"];
var $ = {
global: this,
createRealm(options) {
options = options || {};
options.globals = options.globals || {};
var realm;
run(this.file, function(newRealm) {
realm = newRealm;
});
realm.eval(this.source);
realm.$.source = this.source;
realm.$.destroy = function () {
if (options.destroy) {
options.destroy();
}
};
for(var glob in options.globals) {
realm.$.global[glob] = options.globals[glob];
}
return realm.$;
},
evalScript(code, errorCb) {
try {
print(this.scriptStartMarker);
print(code);
print(this.scriptEndMarker);
/* Blocks until the script is written to the file system. */
readline();
load(this.scriptFile);
return { type: 'normal', value: undefined };
} catch (e) {
return { type: 'throw', value: e }
}
},
agent: jsc.agent,
global: jsc.global,
createRealm: jsc.createRealm,
detachArrayBuffer: jsc.detachArrayBuffer,
evalScript: jsc.evalScript,
getGlobal(name) {

@@ -49,6 +19,2 @@ return this.global[name];

source: $SOURCE,
file: $FILE,
scriptFile: $SCRIPT_FILE,
scriptStartMarker: $SCRIPT_START_MARKER,
scriptEndMarker: $SCRIPT_END_MARKER,
};

@@ -36,5 +36,11 @@ var $ = {

destroy() { /* noop */ },
IsHTMLDDA() { return objectEmulatingUndefined(); },
IsHTMLDDA() {
/* objectEmulatingUndefined was replaced by createIsHTMLDDA in newer SpiderMonkey builds. */
if (typeof createIsHTMLDDA === 'function') {
return createIsHTMLDDA();
}
return objectEmulatingUndefined();
},
source: $SOURCE
};

@@ -5,2 +5,3 @@ 'use strict';

const assert = require('assert');
const hasbin = require('hasbin');
const fs = require('fs');

@@ -48,6 +49,7 @@

if (options.hostPath && !fs.existsSync(options.hostPath)) {
throw new Error('Unable to run tests - host not found: ' + options.hostPath);
if (options.hostPath &&
(!hasbin.sync(options.hostPath) && !fs.existsSync(options.hostPath))) {
console.error('Unable to run tests - host not found: ' + options.hostPath);
}
describe(`${type} (${options.hostPath || effectiveType})`, function () {

@@ -460,3 +462,3 @@ this.timeout(20000);

var resultP = agent.evalScript(`while (true) { }; print(2);`);
return timeout(100).then(_ => {
return timeout(100).then(() => {
var stopP = agent.stop();

@@ -483,2 +485,7 @@

if (type === 'ch') {
// Hello! If you come here wondering why this fails
// on your local machine, it's because you're using a
// version of Chakra that was not compiled with support
// for development flags. That's ok! The CI machine
// will check this for you, so don't sweat it.
hostArguments = '-Intl-';

@@ -494,4 +501,4 @@ source = 'print(typeof Intl === "undefined");';

if (type === 'jsc') {
hostArguments = '--useWebAssembly=true';
source = 'print(typeof WebAssembly === "function");';
hostArguments = '--useWebAssembly=false';
source = 'print(typeof WebAssembly === "undefined");';
}

@@ -498,0 +505,0 @@

Sorry, the diff of this file is not supported yet

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