
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
rest-bridge
Advanced tools
Expose REST service in private network to public network, via connector (in private network) and hub (public service).
Expose REST service in private network to public network, via connector (in private network) and hub (public service).

const hub = require('rest-bridge/hub')
let options = {
port: 80
}
hub.create(options).then(() => {
//demo purpose
hub.registry.register({
key: 'demoKey',
description: 'demo connector'
})
}).catch(console.error)
const rbconnector = require('rest-bridge/connector')
process.env.NODE_TLS_REJECT_UNAUTHORIZED = 0
rbconnector.start({
hub: 'ws://localhost', //which hub to connect to
info: { //information of this connector
key: 'demoKey', //the pairing key
id: 'demoConnector'
},
target: 'http://localhost:10762', //the target http service
//additionally, path based routing an be specified using a map,
//regular expression for request path as key, and target as value.
//Example:
/*
routes: {
'/demo': {
target: 'http://localhost:8081'
},
'/products': 'https://www.vmware.com',
'.*': 'https://www.vmware.com'
}
*/
})
const http = require('http')
//To do a rest-bridge call, a pairing key must be specified, so as to distinguish
//which connector to use. The pairing key can be specified either in request
//header, or request path.
//Method 1 - Specify pairing key in header
let options = {
host: 'localhost',
path: '/hello',
headers: {
'x-rest-bridge-key': 'demoKey' //specify which connector we are using
}
}
http.get(options, resp => {
let body = ''
resp.setEncoding('utf8')
.on('data', chunk => body += chunk)
.on('end', () => console.log(body))
}).on('error', console.error)
.end()
//Method 2 - Specify pairing key in request path.
//This method requires a fixed base path to be added
//http.get('http://localhost/rest-bridge-forward/<pairingKey>/hello')
https://github.com/nanw1103/rest-bridge/blob/master/demo/myConfig.js
http://<hub_host>:<management_port>/rest-bridge
[
{
"name": "register",
"method": "post",
"path": "/registry",
"description": "Register a new connector",
"href": "http://localhost/rest-bridge/registry"
},
{
"name": "Delete registered connector",
"method": "delete",
"path": "/registry/<key>",
"description": "Remove a connector",
"href": "http://localhost/rest-bridge/registry/<key>"
},
{
"name": "registry",
"method": "get",
"path": "/registry",
"description": "Get registry information",
"href": "http://localhost/rest-bridge/registry"
},
{
"name": "registry.connector",
"method": "get",
"path": "/registry/<connector-key>",
"description": "Get information of specific connector",
"href": "http://localhost/rest-bridge/registry/<connector-key>"
},
{
"name": "nodes",
"method": "get",
"path": "/nodes",
"description": "Get nodes in this cluster instance",
"href": "http://localhost/rest-bridge/nodes"
},
{
"name": "connectors",
"method": "get",
"path": "/connectors",
"description": "Get connector information. Scope: cluster instance",
"href": "http://localhost/rest-bridge/connectors"
},
{
"name": "stat",
"method": "get",
"path": "/stat",
"description": "Get statistics. Scope: cluster instance",
"href": "http://localhost/rest-bridge/stat"
},
{
"name": "env",
"method": "get",
"path": "/env",
"description": "Get environments. Scope: cluster instance",
"href": "http://localhost/rest-bridge/env"
},
{
"name": "node",
"method": "get",
"path": "/node",
"description": "Get single node info",
"href": "http://localhost/rest-bridge/node"
}
]
Create each hub instance as a cluster, using a shared store:
let hubOptions = {
port: 80,
nodes: require('os').cpus().length,
store: 'fs-store:/efs/rest-bridge-repo'
}
And then create multiple clusters with load balancers, e.g. AWS Elasticbeanstalk + EFS or ElasticCache
Requests will be forwarded internally between the nodes on demand. So clients or connectors only care about connecting to a single service point.

Method 1: In hub options, specify different network interface for management endpoint, client endpoint, and connector endpoint. Use firewall/security group/api gateway to control the access
Method 2: Control context based access on api gateway or load balancer, etc.
Consider adding HTTPS/WSS on your load balancer or API gateway
The storage is used for two purposes:
If there are more than one machine/container, an external shared storage is a must. If there is only one machine (even it has a nodejs cluster), external shared storage is not needed and memory based (or cluster RPC based) internal storage can be used.
Built-in test cases covers basic scenarios as well as stress testing on local computer.
npm i
npm test
FAQs
Expose REST service in private network to public network, via connector (in private network) and hub (public service).
The npm package rest-bridge receives a total of 31 weekly downloads. As such, rest-bridge popularity was classified as not popular.
We found that rest-bridge demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

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.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.