
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
A pretty custom hooks for websocket and react.
// npm
npm install --save use-ws
// yarn
yarn add use-ws
import React, { FC, useEffect, useState } from 'react'
import ReactDOM from 'react-dom'
import { createWebSocket, BinaryType } from 'use-ws'
const { WebSocketProvider, WebSocketContext, useWebSocket, useHeartbeat } = createWebSocket({
// required
binaryType: BinaryType.ArrayBuffer, // or BinaryType.Blob
serialize(action, ...data) { ... },
deserialize(packet) { ... },
// optional
heartbeat: {
interval: 10 * 1000,
action: YOUR_HEARTBEAT_CODE,
data: [] // optional
}
})
const App: FC = () => (
<WebSocketProvider
url={YOUR_WEBSOCKET_URL}
middleware={(action, ...data) => { ... }}
onOpen={event => { ... }}
onError={event => { ... }}
onClose={event => { ... }}
>
<User />
</WebSocketProvider>
)
const User: FC = () => {
const websocket = useWebSocket()
const { latestHeartbeat, setData, setNextDelay } = useHeartbeat()
const [id, setId] = useState<string>('')
const [name, setName] = useState<string>('')
// listener settings
useEffect(() => {
const handler = (foo: string, bar?: number) => { ... }
websocket.addListener(YOUR_ACTION_CODE, handler)
websocket.once(YOUR_ACTION_CODE, handler)
websocket.emit(parameter0, parameter1)
return () => {
websocket.removeListener(YOUR_ACTION_CODE, handler)
}
}, [])
// add 100ms per heartbeat
useEffect(() => {
setNextDelay(previousDelay => {
const nextDelay = previousDelay + 100
setData(nextDelay)
return nextDelay
})
}, [latestHeartbeat])
return <div>{name}</div>
}
ReactDOM.render(<App />, document.getElementById('root'))
FAQs
A pretty custom hooks for websocket and react
We found that use-ws 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.