
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
rsmq-iterator
Advanced tools
An async iterator for a RedisSMQ message queue.
The application must initialise a RedisSMQ client and give it to the QueueIterator.
The RedisSMQ client must have the realtime
option set to true
as the iterator will
subscribe to receive messages
// index.js
import RedisSMQ from "rsmq";
import QueueIterator from "rsmq-iterator";
const rsmq = new RedisSMQ({
/* host, port, ... */
realtime: true
});
QueueIterator.rsmq(rsmq);
Create a class for the queue
// MyQueue.js
import QueueIterator from "rsmq-iterator";
export default class MyQueue extends QueueIterator {}
The class can be used to send messages to the queue
// somewhere.js
import MyQueue from "./MyQueue";
async function send(foo) {
const job = await new MyQueue({ foo });
const { id } = job.info();
console.log(id);
}
send("a message");
The send()
method can also be used to send messages to the queue
// somewhere.js
import MyQueue from "./MyQueue";
const myQueue = new MyQueue();
async function send(foo) {
const job = await myQueue.send({ foo });
const { id } = job.info();
console.log(id);
}
send("a message");
The class instance can be used to receive messages from the queue
// somewhere-else.js
import MyQueue from "./MyQueue";
async function main() {
for await (const job of new MyQueue()) {
const { id } = job.info();
console.log(id, job.data.foo);
await job.done();
}
}
main();
To create the queue use the createQueue
method from the RedisSMQ client.
// migration.js
const rsmq = new RedisSMQ({
/* host, port, ... */
});
rsmq.createQueue({ qname: "MyQueue" });
The behaviour of the iterator can be customised
// MyQueue.js
import QueueIterator from "rsmq-iterator";
class MyQueue extends QueueIterator {
// (optional) override the name of the queue to send/receive messages to/from
// defaults to the class name
queueName = "MyQueue";
// (optional) custom message serialization
// the default is JSON.stringify
async serialize(message) {
return super.serialize(message);
}
// (optional) custom message serialization
// the default is JSON.parse
async deserialize(message) {
return super.deserialize(message);
}
}
FAQs
An async iterator for a RedisSMQ message queue
We found that rsmq-iterator 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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.