Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
The dezalgo npm package ensures that a callback is always called asynchronously, and not in the same tick of the event loop that it was added in, even if it is already complete. This is useful for preventing stack overflows and ensuring consistent asynchronous behavior.
Ensuring asynchronous callback execution
This feature wraps a callback function to ensure that it is always called on the next tick of the event loop, even if it could be called immediately.
const dezalgo = require('dezalgo')
const callback = dezalgo((err, data) => {
// This will always run asynchronously
console.log('Callback called asynchronously')
})
// Even if we call it synchronously, it will be deferred
callback(null, 'some data')
This package is similar to dezalgo in that it defers the execution of callbacks to the next tick of the event loop. It also allows for passing arguments to the callback, similar to how 'Function.prototype.apply' works.
The setimmediate package provides a way to execute a function asynchronously as soon as possible, but after the current event loop tick. It is similar to dezalgo but uses a different mechanism (setImmediate) which is a standard part of the Node.js and browser environments.
The async package offers a wide range of functions for working with asynchronous code. One of its utilities, 'async.nextTick', is similar to dezalgo in that it ensures a callback is called on the next tick of the event loop.
Contain async insanity so that the dark pony lord doesn't eat souls
See this blog post.
Pass a callback to dezalgo
and it will ensure that it is always
called in a future tick, and never in this tick.
var dz = require('dezalgo')
var cache = {}
function maybeSync(arg, cb) {
cb = dz(cb)
// this will actually defer to nextTick
if (cache[arg]) cb(null, cache[arg])
fs.readFile(arg, function (er, data) {
// since this is *already* defered, it will call immediately
if (er) cb(er)
cb(null, cache[arg] = data)
})
}
FAQs
Contain async insanity so that the dark pony lord doesn't eat souls
The npm package dezalgo receives a total of 7,764,422 weekly downloads. As such, dezalgo popularity was classified as popular.
We found that dezalgo demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 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
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.