
Research
Supply Chain Attack on Axios Pulls Malicious Dependency from npm
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.
@knowledgecode/messenger
Advanced tools
This is a Req/Rep Pub/Sub library for the browser.
Messaging between ...
The following messaging are not supported:
via npm:
npm install knowledgecode@messenger --save
This library assumes Promise is available. Running it on unsupported browsers, install a polyfill beforehand.
ES Modules:
import messenger from './esm/messenger.es.js';
messenger.send('topic', { msg: 'hello' });
Manually:
<script src="./messenger.js"></script>
<script>
messenger.send('topic', { msg: 'hello' });
</script>
Send a message (some object) to a topic. This method will return Promise. The 3rd parameter, timeout, is optional. If omit it or set to 0, the Promise will forever wait for reply from the other.
Register a listener to wait for message on a topic. The topic name needs to be unique, listeners other than the first cannot bind on the same topic name. To unbind, call the function that this method will return.
Publish a message (some object) to all the subscribers on a topic. This method won't wait for reply from the subscribers, and won't be failed even there is no subscriber there.
Subscribe message on a topic. To unsubscribe, call the function that this method will return.
In Req / Rep model, we use send() and bind().
At first, using the bind(), server-side waits for messages from clients, with a topic, "addition":
messenger.bind('addition', data => {
return new Promise(resolve => {
resolve(data.x + data.y);
});
});
The Promise may be omitted:
messenger.bind('addition', data => {
return data.x + data.y;
});
Client-side sends a message to the topic. If no one is waiting for messages with the topic, the send() will be failed (Promise will be rejected).
messenger.send('addition', {
x: 2, y: 3
}).then(rep => {
console.log(rep); // 5
});
Use a returned function to unbind the topic.
const unbind = messenger.bind('addition', data => {
return data.x + data.y;
});
// Unbind the "addition" topic.
unbind();
In Pub / Sub model, we use publish() and subscribe().
Use subscribe() to subscribe to a topic.
messenger.subscribe('input', data => {
console.log(`The ${data.key} is input!`); // The h key is input!
});
Use publish() to publish a message to a topic (one or more subscribers). Even there is no subscriber, this method won't be failed. Also this method won't receive any replies from subscribers.
messenger.publish('input', {
key: 'h', shift: false, ctrl: true
});
Use a returned function to unsubscribe from the topic.
const unsubscribe = messenger.subscribe('input', data => {
console.log(`The ${data.key} is input!`); // The h key is input!
});
// Unsubscribe the "input" topic.
unsubscribe();
Chrome, Firefox, Safari, Edge, IE9+
MIT
FAQs
Type-safe Request/Reply and Pub/Sub messaging library for browser applications
The npm package @knowledgecode/messenger receives a total of 3 weekly downloads. As such, @knowledgecode/messenger popularity was classified as not popular.
We found that @knowledgecode/messenger demonstrated a healthy version release cadence and project activity because the last version was released less than 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.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.

Security News
TeamPCP is partnering with ransomware group Vect to turn open source supply chain attacks on tools like Trivy and LiteLLM into large-scale ransomware operations.