
Research
Malicious npm Packages Impersonate Flashbots SDKs, Targeting Ethereum Wallet Credentials
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
redux-sockjs
Advanced tools
npm test
for es6 project, babel-preset-stage-0 syntax
import { startReduxServer } from 'redux-sockjs/server'
const channel = startReduxServer({
port: 1000, // port should be same with browser
})
channel.receive(action => {
channel.broadcast(action)
})
import { startReduxClient, actionCreator, middleware as reduxSockjs, createReducer } from 'redux-sockjs'
/* when use actionCreator, the reduxSockjs must be used and vice versa */
const channel = startReduxClient({
port: 1000, // port should be same with server
})
/* channel must bound to createAction first, then use redux middle to create store */
const createAction = actionCreator(channel)
const createUser = createAction('ADD_USER')
const userReducer = createReducer({
'INITIAL_STATE': (state, action) => action.payload,
'ADD_USER': (state, action) => [...state, action.payload],
}, [])
// use reduxPromise before reduxSockjs
const store = createStore(combineReducers({
user: userReducer,
}), applyMiddleware(reduxPromise, reduxSockjs))
channel.on('open', () => {
store.dispatch(createUser({ name: 'bob' }))
})
// it is async, when data send to server and broadcast to browser
// store.getState().user will be [{ name: 'bob' }]
if some server operation take too long, you can use promise action
import { startReduxClient, createAction as actionCreator, middleware as reduxSockjs } from 'redux-sockjs'
/* when use actionCreator, the reduxSockjs must be used and vice versa */
const channel = startReduxClient({
port: 1000, // port should be same with server
})
/* channel must bound to createAction first, then use redux middle to create store */
const createAction = actionCreator(channel)
const createUser = createAction('ADD_USER', true)
const userReducer = createReducer({
'INITIAL_STATE': (state, action) => action.payload,
'ADD_USER': (state, action) => [...state, action.payload],
}, [])
/* use reduxPromise before reduxSockjs */
const store = createStore(combineReducers({
user: userReducer,
}), applyMiddleware(reduxPromise, reduxSockjs))
channel.on('open', async () => {
await store.dispatch(createUser({ name: 'bob' }))
console.log(store.getState().user) // [{ name: 'bob' }]
})
// it is async, when data send to server and broadcast to browser
// store.getState().user will be [{ name: 'bob' }]
if no param, just startServer(), it will use default param as below
startReduxServer({
port = 3000,
ip = '0.0.0.0',
sockjsPrefix = '/sockjs-redux',
log = () => {}, // a function for log of sockjs, reference from [sockjs-node doc](https://github.com/sockjs/sockjs-node)
server, // server should be http.Server instance, if not defined, will use default server created by http.createServer()
// use https.createServer() when needed
})
reduxChannel on server inherites nodejs "events", and has some own method as below
can receive many functions, when receive data, each will be called with data
remove func from receive data functions
send data to client async
broadcast(data)
like send, but send data to all connected client
if no param, just startClient(), it will use default param as below the protocal should correspond to the server protocal
const reduxChannel = startReduxClient({
port = 3000,
domain = '127.0.0.1', // domain or ip
sockjsPrefix = '/sockjs-redux',
protocal = 'http', // http or https
reconnectInterval = 0, // reconnect interval, millisecond
reconnectMax = 0, // reconnect max retry count
})
reduxChannel on client inherites nodejs "events", and has some own method as below
reconnect(interval, maxRetry)
when reconnect, it`s emitter property will be replaced new one
receive(func)
can receive many functions, when receive data, each will be called with data
remove func from receive data functions
send data to server async
receive an return value of startReduxClient return a function to create action
const createAction = actionCreator(reduxChannel)
const actionAddTodo = createAction('ADD_TODO')
FAQs
use sockjs to pub and sub redux action on server and client
The npm package redux-sockjs receives a total of 1 weekly downloads. As such, redux-sockjs popularity was classified as not popular.
We found that redux-sockjs 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
Four npm packages disguised as cryptographic tools steal developer credentials and send them to attacker-controlled Telegram infrastructure.
Security News
Ruby maintainers from Bundler and rbenv teams are building rv to bring Python uv's speed and unified tooling approach to Ruby development.
Security News
Following last week’s supply chain attack, Nx published findings on the GitHub Actions exploit and moved npm publishing to Trusted Publishers.