
Research
Security News
Malicious PyPI Package Exploits Deezer API for Coordinated Music Piracy
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
@qiwi/cyclone
Advanced tools
"State machine" for basic purposes.
There're many redux-state-machine implementations. krasimir/stent is pretty good among others (just opinion). But:
Stent
does not allow to "lock" the execution thread. Therefore impossible to verify that next
step strictly follows (corresponds) by the prev
.If these points are not significant for you, Stent
might be your best choice.
typings/index.d.ts
flow-typed/index.flow.js
should be found by Flow. If not, add [lib]
section to .flowconfig
import {Machine} from '@qiwi/cyclone'
const handler1 = () => {}
const handler2 = () => {}
const opts = {
initialState: 'foo',
initialData: {a: 'AAA'},
transitions: {
'foo>bar': true, // NOTE applies static DEFAULT_HANDLER
'bar>baz': handler1,
'baz>foo': handler2,
'foo>bar>baz>foo': handler1
},
historySize: 5, // default = 10
}
const machine = new Machine(opts)
current
Returns machine state digest:
machine.current() // {state: 'foo', data: {a: 'AAA'}, id: '0.2234...', date: 2018-10-07T16:59:23.644Z}
next
Transits the machine to a new state:
machine.next('bar', {optional: 'args'}, 'for', 'handler')
machine.current() // {state: 'bar', data: {...}, ...}
prev
Reverts the last transition:
machine.current() // {state: 'bar', data: {...}, ...}
machine.prev() // btw, it returns machine ref
machine.current() // {state: 'foo', data: {...}, ...}
lock
/ unlock
Prevents state update.
machine.lock('key')
machine.next('qux', {a: 'a'}) // MachineError: Lock violation
machine.unlock('invalidKey') // MachineError: Invalid unlock key
machine.unlock('key')
DEFAULT_HANDLER('foo', 'bar') // 'bar'
DEFAULT_HANDLER('foo', 'bar', 'baz') // 'baz'
Imagine, Rematch model:
import txn from '../../../../api/txn'
import Machine from '@qiwi/cyclone'
const machine = new Machine({
initialState: 'init',
initialData: {},
transitions: {
'init>loading': true,
'loading>ok': (state, res) => res,
'loading>err': (state, res) => res,
'ok>loading': true,
'err>loading': true
}
})
export default {
state: machine.current(),
reducers: {
next(prev, next, ...payload) {
return machine.next(next, ...payload).current()
}
},
effects: {
async read (opts) {
this.next('loading')
const res = await txn.readList(opts)
this.next('ok', res)
}
}
}
FAQs
"State machine" for basic purposes
We found that @qiwi/cyclone demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 3 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.
Research
Security News
Socket researchers uncovered a malicious PyPI package exploiting Deezer’s API to enable coordinated music piracy through API abuse and C2 server control.
Research
The Socket Research Team discovered a malicious npm package, '@ton-wallet/create', stealing cryptocurrency wallet keys from developers and users in the TON ecosystem.
Security News
Newly introduced telemetry in devenv 1.4 sparked a backlash over privacy concerns, leading to the removal of its AI-powered feature after strong community pushback.