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.
##A Simple HowTo:
Include the library
var cometD = require('cometd').cometD();
Subscribe to a topic
cometD.topic = '/topic/exampleTopic';
Add a eventListener
cometD.addEventListener('/topic/exampleTopic', function (topic, message) {});
Start the execution
cometD.init(
{
token: "A optional Bearer token",
url: 'http://urltoyourservice.com/cometd/26.0',
debug: true
}
);
###Multi Subscription
You have two options for subscribe more than one topic. You can use a wildcard in your topic like this:
cometD.topic = '/topic/*';
If you use this, you can add a eventListener to each channel.
cometD.addEventListener('/topic/topic1', function (topic, message) {});
cometD.addEventListener('/topic/topic2', function (topic, message) {});
Or you can use only one handler function. You can also access the topicName:
function myHandler(theTopicName, message){
console.log(theTopicName);
}
cometD.addEventListener('/topic/topic1', myHandler);
cometD.addEventListener('/topic/topic2', myHandler);
Sometime wildcards are not available. But this isn't a problem. The cometD object isn't a singleton. Each Instance has his own cookie.
var topics = ['topic1', 'topic2'];
function myCometDFunction(topic){
var cometD = require('./cometD.js').cometD();
cometD.topic = '/topic/' + topic;
cometD.init(
{
token: "Bearer Token",
url: 'http://aserviceurl.com/cometd/26.0',
debug: true
}
);
cometD.addEventListener('/topic/' + topic, function(topicName, message){});
}
for (var i = 0; i < topics.length; i++) {
myCometDFunction(topics[i]);
}
FAQs
Comet and WebSocket library for web messaging
The npm package cometd receives a total of 9,099 weekly downloads. As such, cometd popularity was classified as popular.
We found that cometd demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.