Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
@podium/proxy
Advanced tools
Transparent http proxy. Dynamically mounts proxy targets on an existing HTTP server instance.
Transparent http proxy. Dynamically mounts proxy targets on an existing HTTP server instance.
$ npm install @podium/proxy
Attach a proxy target to an existing Express server.
const express = require('express');
const Proxy = require('@podium/proxy');
// Set up express server
const app = express();
// Set up proxy
const proxy = new Proxy();
// Register remote target(s) on separate namespace
proxy.register({
name: 'bar',
proxy: {
api: 'http://www.external.com/some/path',
},
version: '1.0.0',
content: '/bar',
});
// Attach proxy middleware
app.use(proxy.middleware());
// Start appserver where proxy is attached
app.listen(9999);
Proxy is now mounted on: http://localhost:9999/podium-resource/bar/api
Create a new Proxy instance.
const Proxy = require('@podium/proxy');
const proxy = new Proxy(options);
The constructor takes the following arguments:
An options object containing configuration. The following values can be provided:
pathname
- {String} - Pathname to the root of where the proxy is to be mounted. Default: /
.prefix
- {String} - Prefix used to namespace the proxy so its isolated from other routes in a HTTP server. Appended after pathname. Default: podium-resource
.timeout
- {Number} - Default value, in milliseconds, for how long a request should wait before the connection is terminated. Default: 6000maxAge
- {Number} - Default value, in milliseconds, for how long manifests should be cached. Default: Infinityagent
- {HTTPAgent} - Default HTTP Agent used for all requests.logger
- {Object} - A logger which conforms to the log4j interface. See the docs for abstract logger for more information.The Proxy instance havs the following API:
Registers proxy target(s) by providing a Podium manifest.
Example:
const Proxy = require('@podium/proxy');
// Set up proxy
const proxy = new Proxy();
// Register remote target(s) on separate namespace
proxy.register({
name: 'bar',
proxy: {
api: 'http://www.external.com/some/path',
},
version: '1.0.0',
content: '/bar',
});
A Podium manifest where the proxy
property is given. The proxy
property is an object where the key
identifies the target and the property
is a URI to the target.
Property that exposes a metric stream.
Exposes a single metric called podium_proxy_request
which includes podlet
and proxy
meta fields.
Please see the @metrics/client module for full documentation.
Middleware that mounts the proxy on a Connect middleware compatible HTTP server.
Returns an Array of all loaded manifests ready to be used by .load()
.
Loads an Array of manifests (provided by .dump()
) into the proxy. If any of the items in the loaded Array contains a key which is already in the cache, the entry in the cache will be overwritten.
If any of the entries in the loaded Array are not compatible with the format which .dump()
exports, they will not be inserted into the cache.
Returns an Array with the keys which were inserted into the cache.
To be able to have multible proxy targets in an HTTP server we need to make sure that they do not collide with each other. To prevent so, each proxy target defined is mounted on their own separate namespace in an HTTP server.
The convention for these namespaces is as follow:
{pathname}/{prefix}/{podletName}/{proxyName}/
pathname
argument in the constructor. Defaults to /
.prefix
argument in the constructor. Defaults to podium-resource
.name
value in the manifest. Note: When the proxy module subscribes to receive manifest updates from the Podium Client, this name will be the name a Podlet is registered with in the Podium Client.proxy.name
property defined in the manifest.If one has the following manifest defined in an express server:
const app = require('express')();
const Proxy = require('@podium/proxy');
const proxy = new Proxy();
proxy.register({
name: 'bar',
proxy: {
api: 'http://www.external.com/some/path',
},
version: '1.0.0',
content: '/index.html',
});
app.use(proxy.middleware());
app.listen(8000);
The following proxy targets will be mounted:
If one has the following manifest and overrides the prefix
on the constructor:
const app = require('express')();
const Proxy = require('@podium/proxy');
const proxy = new Proxy({
prefix: '/my-proxy',
});
proxy.register({
name: 'bar',
proxy: {
api: 'http://www.external.com/some/path',
},
version: '1.0.0',
content: '/index.html',
});
app.use(proxy.middleware());
app.listen(8000);
The following proxy targets will be mounted:
If one has the following manifest defined in an express server:
const app = require('express')();
const Proxy = require('@podium/proxy');
const proxy = new Proxy();
proxy.register({
name: 'bar',
proxy: {
api: 'http://www.external.com/some/path',
feed: '/feed',
},
version: '1.0.0',
content: '/index.html',
});
app.use(proxy.middleware());
app.listen(8000);
The following proxy targets will be mounted:
If one has the following manifests defined in an express server:
const app = require('express')();
const Proxy = require('@podium/proxy');
const proxy = new Proxy();
proxy.register({
name: 'bar',
proxy: {
api: 'http://www.external.com/some/path',
feed: '/feed',
},
version: '1.0.0',
content: '/index.html',
});
proxy.register({
name: 'foo',
proxy: {
users: 'http://www.anywhere.com/api',
},
version: '2.0.0',
content: '/index.html',
});
app.use(proxy.middleware());
app.listen(8000);
The following proxy targets will be mounted:
FAQs
Transparent http proxy. Dynamically mounts proxy targets on an existing HTTP server instance.
The npm package @podium/proxy receives a total of 696 weekly downloads. As such, @podium/proxy popularity was classified as not popular.
We found that @podium/proxy demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.