Security News
New Python Packaging Proposal Aims to Solve Phantom Dependency Problem with SBOMs
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
@lawcket/react-websocket
Advanced tools
A slim Websocket implementation for React 16+. The libray uses the standard browser WebSocket so 'should' be supported in React-Native.
npm install --save @lawcket/react-websocket
or
yarn add @lawcket/react-websocket
Example:
import React, { useState } from 'react';
import Websocket from '@lawcket/react-websocket';
const Messages = () => {
const [messages, addMessage] = useState([]);
return (
<Websocket
url='wss://...'
retry
onOpen={({ send }) => console.log('open')}
onClose={({ code, reason }) => console.log('closed', code, reason)}
onMessage={({ send, data }) => console.log('message', data)}
onError={(error) => console.log('error', error)} >
{({ send, close }) => {
return (
<pre>{JSON.stringify(messages, null, 2)}</pre>
);
}}
</Websocket>
);
}
Name | Type | Description | Default |
---|---|---|---|
url | string | The websocket url to connect to | |
protocol | string | The protocol for the websocket to use | |
retry | boolean | If an error occurs, should it reconnect | true |
onOpen | function | Notifies when the connection has been opened | |
onMessage | function | Notifies when an incoming message has been received | |
onClose | function | Notifies the connection was closed | |
onError | function | Notifies of an error with the connection, will close the connection |
Parameter | Type | Description |
---|---|---|
send | function(any) | A function to send data to the server |
Parameter | Type | Description |
---|---|---|
data | any | Incoming message (usually stringified JSON data) |
send | function(any) | A function to send data to the server |
Parameter | Type | Description |
---|---|---|
error | Error | The error that occured during connection or usage |
Reference: Close codes & reasons
Parameter | Type | Description |
---|---|---|
code | number | The close code sent by the server |
reason | string | The reason the connection was closed |
FAQs
A slim React websocket implementation
The npm package @lawcket/react-websocket receives a total of 5 weekly downloads. As such, @lawcket/react-websocket popularity was classified as not popular.
We found that @lawcket/react-websocket 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.
Security News
PEP 770 proposes adding SBOM support to Python packages to improve transparency and catch hidden non-Python dependencies that security tools often miss.
Security News
Socket CEO Feross Aboukhadijeh discusses open source security challenges, including zero-day attacks and supply chain risks, on the Cyber Security Council podcast.
Security News
Research
Socket researchers uncover how threat actors weaponize Out-of-Band Application Security Testing (OAST) techniques across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.