Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
exchange-pubsub
Advanced tools
A helper module to simplify @google-cloud/pubsub
npm i --save exchange-pubsub
const pubSub = require('exchange-pubsub');
// Optional:
pubSub.setOptions({
log: console,
defaultSubscribeOptions: {
raw: false,
autoAck: true,
},
});
// simple usage:
pubSub.subscribe('myTopic', msgData => {
// default is only the message.data property from pubsub
console.log(msgData); // should be 'my message' in this example
// optionally return false or a Promise
// if return value resolves to false, message will be nack'd, else ack'd
// (unless autoAck option is disabled)
});
pubSub.publish('myTopic', 'my message')
.then(() => {/* do something */ })
.catch(e => {/* error */ });
The default usage uses the topic as the subscription name which means it will be processed by a single subscriber (if multiple subscribers use the same name).
You can also specify the name manually, or have a random name generated:
// specify subscription name and options:
pubSub.subscribe('myTopic', 'subscription name', {autoAck: false, raw: true}, (msg => {
console.log(msg.data);
msg.ack();
}));
// random subscription name
pubSub.subscribe('myTopic', true, (msgData => {
console.log(msgData);
return Promise.reject(); // force a nack
}));
// CAUTION: careful with binding...
// DON'T DO: pubSub.subscribe('myTopic', true, myClass.function)
// Instead, use one of the following:
pubSub.subscribe('myTopic', 'subName', (msg) => myClass.function(msg));
pubSub.subscribe('myTopic', 'subName', myClass.function.bind(myClass));
Source: demo.js
FAQs
A wrapper to simplify basic pubsub usage
The npm package exchange-pubsub receives a total of 0 weekly downloads. As such, exchange-pubsub popularity was classified as not popular.
We found that exchange-pubsub 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
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.