
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.
A small XMLHttpRequest wrapper for intercepting or faking responses. The module is plain untranspiled es6.
npm i -S fakexhr
When loaded will take over window.XMLHttpRequest.
The original class will be stored at
window.XMLHttpRequest.original.
The new XMLHttpRequest is baseclassed from the
real one so it will work the same.
The XHR instances will have an extra method called
fake.
The first parameter is the string you want the
response to be. The remaining parameters are the
exact same signature as you will use in xhr.open(..,).
const xhr = new XMLHttpRequest()
xhr.fake('<foo>bar</foo>', 'GET', 'file.xml')
xhr.open('GET', 'file.xml')
xhr.send()
This will fake the xhr.responseText only for this
xhr instance. To fake the responses for all instances
you can use the similarly named static method.
XMLHttpRequest.fake('<foo>bar</foo>', 'GET', 'file.xml')
const xhr = new XMLHttpRequest()
xhr.open('GET', 'file.xml')
xhr.send()
Contrary to hijacking a response, faking it will not
send an actual HTTP request. This also means the fired
events will have the isTrusted property set to false.
To alter an existing request you can hijack it by overloading the same to methods. Simply replace the first parameter with a callback function.
const xhr = new XMLHttpRequest()
xhr.fake(xml=>`<blaat>${xml}</blaat>`, 'GET', 'file.xml')
xhr.open('GET', 'file.xml')
xhr.send()
The same applies to the static method.
FAQs
Fake responses for individual endpoints
We found that fakexhr 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.