Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
mesa-js-client
Advanced tools
A simple JavaScript client for connecting to Mesa servers.
Important: mesa-js-client
is only recommended for use in non-Node.js environments. Please use the Client
implementation in @cryb/mesa if you're attempting to connect to a Mesa server from a Node.js environment
This module library is available on the NPM registry. To install, run:
npm i mesa-js-client --save
If you're using Yarn, run:
yarn add mesa-js-client
To install the browser library, copy dist/browser/client.js
and refer to it in your .html
file like so:
<script src="client.js"></script>
mesa-js-server
is also offered via the jsdelivr CDN:
<script src="https://cdn.jsdelivr.net/npm/mesa-js-client@latest/dist/browser/client.js"></script>
The client API is more or less identical to the Client
implementation in @cryb/mesa
, with a few caveats:
mesa-js-client
does not use EventEmitter
in order to inform the application of events. Instead, we use callbacks in the form of:
onConnected: () => void
onMessage: (message: Message) => void
onDisconnected: (code: number, reason: string) => void
onError: (error: Error) => void
The constructor for MesaClient
also allows for options to be passed in:
const client = new MesaClient('ws://localhost:4000', { autoConnect: false })
// With autoConnect set to false, client.connect will now need to be called in order for the connected to begin
client.connect()
mesa-js-client
also supports authentication through the Mesa Authentication API. Once enabled on the server, client-side authentication material can be sent like this:
client.onConnected = async () => {
const user = await client.authenticate({ token: fetchToken() }, { shouldSync: true })
}
The second parameter in the client.authenticate
method is an optional configuration object that can be supplied with information such as shouldSync
, which matches the Mesa usage of sending undelivered messages since the last disconnection
import MesaClient from 'mesa-js-client'
const client = new MesaClient('ws://localhost:4000')
client.onConnected = () => {
console.log('Connected to Mesa server')
}
client.onMessage = ({ opcode, data, type }) => {
console.log('Recieved', opcode, data, type)
switch(type) {
case 'PING':
client.send(0, {}, 'PONG')
break
}
}
client.onDisconnected = (code, reason) => {
console.log('Disconnected', code, reason)
}
client.onError = error => {
console.log('Error', error)
}
<script src="js/mesa-js-client.js"></script>
<script>
const client = new MesaClient("ws://localhost:4000")
client.onConnected = function() {
console.log("Connected to Mesa server")
}
client.onMessage = function({ opcode, data, type }) {
console.log("Recieved", opcode, data, type)
switch(type) {
case "PING":
client.send(0, {}, "PONG")
break
}
}
client.onDisconnected = function(code, reason) {
console.log("Disconnected", code, reason)
}
client.onError = function(error) {
console.log("Error", error)
}
client.connect()
</script>
If you have an issues with mesa-js-client
, please either open a GitHub issue or contact a maintainer
FAQs
JavaScript client for Mesa WebSocket server
We found that mesa-js-client 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.