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.
Extends the whatwg fetch
- fetch spec api,
makes it easier to use. Both node & browser supported.
npm install fetch.io
import Fetch from 'fetch.io'
npm install @types/fetch.io
.config() - set options
.set() - set http header
.type() - set content type
.send() - send body data
.query() - set query string
.append() - append form data
.text() - convert response body to string
.json(strict = true) - convert response body to object
(strict JSON mode default)
Function
, a pre-request hook function, returning false
will cancel the requestFunction
, a post-response hook functionFunction
, add a handler for .json()
, to check the response dataString
, url prefixconst request = new Fetch({
prefix: 'http://example.com/api/v1'
})
{
prefix: '',
mode: 'cors',
cache: 'no-cache',
credentials: 'include'
}
request
.get(path)
.config({
credentials: 'omit'
})
.query({
type: 1
})
.query({
name: 'hello'
})
.then(res => {
// fetch response
})
.catch(err => {
// ...
})
request
.get(path)
.json()
.then(body => {
// response body
})
.catch(err => {
// ...
})
request
.get(path)
.text()
.then(body => {
// response body
})
.catch(err => {
// ...
})
request
.post(path)
.send({
type: 1
})
.send({
name: 'hello'
})
.then(res => {
// fetch response
})
.catch(err => {
// ...
})
request
.post(path)
.send('type=1')
.send('name=hello')
.then(res => {
// fetch response
})
.catch(err => {
// ...
})
request
.post(path)
.type('form')
// equal to:
// .type('urlencoded')
// equal to:
// .set('content-type', 'application/x-www-form-urlencoded')
.send({
type: 1,
name: 'hello'
})
.then(res => {
// fetch response
})
.catch(err => {
// ...
})
request
.post(path)
.set({
'content-type': 'application/json'
})
.send({
name: 'hello'
})
.then(res => {
// fetch response
})
.catch(err => {
// ...
})
request
.post(path)
.append('filename', 'user.png')
.append('file': document.querySelector('input[type="file"]')files[0])
.append({reason: 'set user avatar'})
.then(res => {
// fetch response
})
.catch(err => {
// ...
})
MIT
FAQs
extends the whatwg fetch api, makes it easier to use
The npm package fetch.io receives a total of 41 weekly downloads. As such, fetch.io popularity was classified as not popular.
We found that fetch.io demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.
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.