Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Make a fetch request from a HAR definition.
msw
or fetch-mock
(though the latter does not appear to be maintained).npm install --save fetch-har
import fetchHAR from 'fetch-har';
// const fetchHAR = require('fetch-har');
const har = {
log: {
entries: [
{
request: {
headers: [
{
name: 'Authorization',
value: 'Bearer api-key',
},
{
name: 'Content-Type',
value: 'application/json',
},
],
queryString: [
{ name: 'a', value: 1 },
{ name: 'b', value: 2 },
],
postData: {
mimeType: 'application/json',
text: '{"id":8,"category":{"id":6,"name":"name"},"name":"name"}',
},
method: 'POST',
url: 'http://httpbin.org/post',
},
},
],
},
};
fetchHAR(har)
.then(res => res.json())
.then(console.log);
A custom User-Agent
header to apply to your request. Please note that browsers have their own handling for these headers in fetch()
calls so it may not work everywhere; it will always be sent in Node however.
await fetchHAR(har, { userAgent: 'my-client/1.0' });
An optional object map you can supply to use for multipart/form-data
file uploads in leu of relying on if the HAR you have has data URLs. It supports Node file buffers and the File API.
await fetchHAR(har, {
files: {
'owlbert.png': await fs.readFile('./owlbert.png'),
'file.txt': document.querySelector('#some-file-input').files[0],
},
});
If you don't supply this option fetch-har
will fallback to the data URL present within the supplied HAR. If no files
option is present, and no data URL (via param.value
) is present in the HAR, a fatal exception will be thrown.
This optional argument lets you supply any option that's available to supply to the Request constructor.
await fetchHAR(har, {
init: {
headers: new Headers({
'x-custom-header': 'buster',
}),
},
});
❗ Note that if you supply
body
orcredentials
to this option they may be overridden by what your HAR requires.
FAQs
Make a fetch request from a HAR definition
The npm package fetch-har receives a total of 44,620 weekly downloads. As such, fetch-har popularity was classified as popular.
We found that fetch-har 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’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.