Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
superagent-proxy
Advanced tools
The superagent-proxy npm package is an extension for the SuperAgent HTTP client library that allows you to route HTTP requests through a proxy server. This can be useful for various purposes such as bypassing network restrictions, anonymizing requests, or testing applications in different network environments.
HTTP Proxy
This feature allows you to route HTTP requests through an HTTP proxy server. The code sample demonstrates how to make a GET request to 'http://example.com' through an HTTP proxy server running at 'http://proxy-server:8080'.
const superagent = require('superagent');
require('superagent-proxy')(superagent);
superagent
.get('http://example.com')
.proxy('http://proxy-server:8080')
.end((err, res) => {
if (err) {
console.error(err);
} else {
console.log(res.body);
}
});
HTTPS Proxy
This feature allows you to route HTTPS requests through an HTTPS proxy server. The code sample demonstrates how to make a GET request to 'https://example.com' through an HTTPS proxy server running at 'https://proxy-server:8080'.
const superagent = require('superagent');
require('superagent-proxy')(superagent);
superagent
.get('https://example.com')
.proxy('https://proxy-server:8080')
.end((err, res) => {
if (err) {
console.error(err);
} else {
console.log(res.body);
}
});
SOCKS Proxy
This feature allows you to route HTTP requests through a SOCKS proxy server. The code sample demonstrates how to make a GET request to 'http://example.com' through a SOCKS proxy server running at 'socks5://proxy-server:1080'.
const superagent = require('superagent');
require('superagent-proxy')(superagent);
superagent
.get('http://example.com')
.proxy('socks5://proxy-server:1080')
.end((err, res) => {
if (err) {
console.error(err);
} else {
console.log(res.body);
}
});
Axios is a promise-based HTTP client for the browser and Node.js. It supports making requests through a proxy by configuring the proxy settings in the request options. Compared to superagent-proxy, Axios is more widely used and has built-in support for proxies without needing an additional package.
Request is a simplified HTTP client for Node.js with support for proxies. It allows you to configure proxy settings directly in the request options. Although the request package is deprecated, it is still widely used and offers similar proxy functionalities as superagent-proxy.
Node-fetch is a lightweight module that brings window.fetch to Node.js. It supports making requests through a proxy by using the 'http-proxy-agent' or 'https-proxy-agent' packages. Compared to superagent-proxy, node-fetch requires additional configuration for proxy support but is a minimalistic and modern alternative.
Request#proxy(uri)
superagent extensionThis module extends superagent
's Request
class with
a .proxy(uri)
function. This allows you to proxy the HTTP request through a
proxy of some kind.
It is backed by the proxy-agent
module, so see
its README for more details.
Install with npm
:
$ npm install superagent-proxy
var request = require('superagent');
// extend with Request#proxy()
require('superagent-proxy')(request);
// HTTP, HTTPS, or SOCKS proxy to use
var proxy = process.env.http_proxy || 'http://168.63.43.102:3128';
request
.get(process.argv[2] || 'https://encrypted.google.com/')
.proxy(proxy)
.end(onresponse);
function onresponse (err, res) {
if (err) {
console.log(err);
} else {
console.log(res.status, res.headers);
console.log(res.body);
}
}
(The MIT License)
Copyright (c) 2013 Nathan Rajlich <nathan@tootallnate.net>
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the 'Software'), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
FAQs
`Request#proxy(uri)` superagent extension
The npm package superagent-proxy receives a total of 215,416 weekly downloads. As such, superagent-proxy popularity was classified as popular.
We found that superagent-proxy 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
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.