New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

code-proxy

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-proxy

A debug tool to proxy js code execution from one browser to another.

latest
Source
npmnpm
Version
1.2.22
Version published
Maintainers
1
Created
Source

code-proxy

NPM version Dependencies Status

A Node.js tools that give the ability to execute JavaScript code in one client browser and to get the results in another. Based on HTTP (for static files and sync post requests) and WebSocket (for server-host communications) technologies. Supports CommonJS modules and can be used with Webpack or Browserify on the client-side.

Scheme to illustrate base working principles: scheme

Installation

npm install code-proxy

Use

Start as a standalone server:

node server/main.js

Connect to an existing project:

require('code-proxy')();

// or it's possible to redefine default options
require('code-proxy')({
	portHttp:   8800,
	portWs:     8900,
	retryDelay: 100,
	retryLimit: 30,
	logging:    true
});

Examples

Host client (accepts requests, execute them and send back result of execution):

<script type="text/javascript" src="host.js"></script>
// default host/port/session
var proxy = new ProxyHost();

// prepare for guest call
localStorage.setItem('test', 'localStorage test string on the host');

// test func for remote exec
function doSomething ( param ) {
	return 'some host work with "' + param + '" is done';
}

Guest client (send requests to the host):

<script type="text/javascript" src="guest.js"></script>
// default host/port/session
var proxy = new ProxyGuest();

// examples
proxy.eval('1+1');
proxy.eval('window.navigator.userAgent');
proxy.json('screen');
proxy.call('localStorage.getItem', ['test'], 'localStorage');
proxy.call('doSomething', ['test data']);

Proxy server host/port and session name can be redefined on both host and guest:

var proxy = new ProxyGuest({
	host: '127.0.0.1',
	port: 8800,
	name: 'anonymous'
});

Both host and guest proxy instance have active boolean flag to determine the current connection to the proxy server status.

ProxyHost has some additional options: reconnect and reconnectInterval to automatically try to restore connection on disconnect every 5 seconds. It's active be default.

Keywords

call

FAQs

Package last updated on 31 Aug 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts