Security News
pnpm 10.0.0 Blocks Lifecycle Scripts by Default
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
messaginghub-client
Advanced tools
Simple BLiP Messaging Hub client for JavaScript
This is a work in progress
See more about BLiP Messaging Hub here
If you are using node.js (or webpack), simply install the messaginghub-client
package from the npm registry.
npm install --save messaginghub-client lime-transport-websocket
However, if you're building for the browser and using vanilla JavaScript, you can install the package via npm and then include the distribution script via a <script>
tag. Note also, that in order to use messaginghub-client
with this setting you must also install and use the lime-js
library:
<script src="./node_modules/lime-js/dist/lime.js" type="text/javascript"></script>
<script src="./node_modules/messaginghub-client/dist/messaginghub-client.js" type="text/javascript"></script>
<script src="./node_modules/lime-transport-websocket/WebSocketTransport.js" type="text/javascript"></script>
Or you can also use the script served by unpkg:
<script src="https://unpkg.com/lime-js" type="text/javascript"></script>
<script src="https://unpkg.com/messaginghub-client" type="text/javascript"></script>
<script src="https://unpkg.com/lime-transport-websocket" type="text/javascript"></script>
import * as MessagingHub from 'messaginghub-client';
import * as WebSocketTransport from 'lime-transport-websocket'
let client = new MessagingHub.ClientBuilder()
.withIdentifier(IDENTIFIER)
.withAccessKey(ACCESS_KEY)
.withTransportFactory(() => new WebSocketTransport())
.build();
The MessagingHubClient class uses transport classes defined according to the Lime procotol specification from the lime-js package. There are a few official packages for Lime transport classes publicly available on NPM and on our Github, but we plan on building more transport classes for node.js and the browser:
In order to use these transport classes in your project you must also include their script files using either npm or unpkg (refer to the How to use section).
client.connectWithKey(identifier, key).then(/* handle connection */);
In order to ensure a connection is available and have no runtime exceptions, one must send messages only after the connection has been established, that is, all sending logic must be written inside the promise handler for the connection method, as shown in the examples below:
client.connectWithKey(identifier, key)
.then(function(session) {
// send a message to some user
var msg = { type: "application/json", content: "Hello, world", to: "my@friend.com" };
client.sendMessage(msg);
});
client.connectWithKey(identifier, key)
.then(function(session) {
// send a "received" notification to some user
var notification = { to: "my@friend.com", event: Lime.NotificationEvent.RECEIVED };
client.sendNotification(notification);
});
client.connectWithKey(identifier, key)
.then(function(session) {
// send a message to some user
var command = { uri: "/ping", method: Lime.CommandMethod.GET };
client.sendCommand(command);
});
client.addMessageReceiver("application/json", function(message) {
// do something
});
client.addNotificationReceiver("received", function(notification) {
// show something
});
The client.addMessageReceiver and client.addNotificationReceiver methods return each a function which, when called, cancels the receiver subscription:
var removeJsonReceiver = client.addMessageReceiver("application/json", handleJson);
// ...
removeJsonReceiver();
Unlike messages and notifications, when command is sent, the response is received when the promise is complete. This response will contain information about the result of the execution of the command sent.
var command = { uri: "/ping", method: Lime.CommandMethod.GET };
client.sendCommand(command)
.then(function(response) {
// handle command repsonse
});
For information on how to contribute to this package, please refer to our Contribution guidelines.
FAQs
Simple Messaging Hub client.
The npm package messaginghub-client receives a total of 7 weekly downloads. As such, messaginghub-client popularity was classified as not popular.
We found that messaginghub-client demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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
pnpm 10 blocks lifecycle scripts by default to improve security, addressing supply chain attack risks but sparking debate over compatibility and workflow changes.
Product
Socket now supports uv.lock files to ensure consistent, secure dependency resolution for Python projects and enhance supply chain security.
Research
Security News
Socket researchers have discovered multiple malicious npm packages targeting Solana private keys, abusing Gmail to exfiltrate the data and drain Solana wallets.