
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.
contexture-client
Advanced tools
The Contexture (aka ContextTree) Client
This library manages the state of a contexture tree to automatically run only the optimal minimal amount of searches possible.
In general, you perform actions
which dispatch
one or more events to an instantiated client, and it reacts by intelligently running searches as needed.
To help people grok the purpose of the this library, this section attempts to explain in terms of mental models that developers are likely to have seen before.
You can think of the client like redux with prebuilt actions and reducers that are async and run searches. Of course, astute readers will realize that model breaks down because a reducer that performs side effects and doesn't return new state isn't a reducer at all.
You can think of the client as a pub/sub system with prebuilt subscribers that can handle specific events. dispatch
is like publish with the internal process/reactor functions acting as subscribers.
The root function takes two parameters, config
and actual tree
instance. It's curried, so you can call it like this:
ContextTree({...config}, tree)
or
ContextTree({...config})(tree)
if you want to pre apply it with config.
The following config options are available:
Name | Type | Default | Description |
---|---|---|---|
service | function | n/a | Required Async function to actually get service results (from the contexture core). An exception will be thrown if this is not passed in. |
types | ClientTypeSpec | exampleTypes | Configuration of available types (documented below) |
debounce | number | 1 | How many milliseconds to globally debounce search |
onResult | (path, response, target) => {} | _.noop | A hook to capture when the client updates a node with results from the server |
allowBlank | boolean | false | Whether or not the client will run blank searches |
debug | boolean | false | Debug mode will log all dispatched events and generally help debugging |
extend | function | F.extendOn | Used to mutate nodes internally |
snapshot | function | _.cloneDeep | Used to take snapshots |
Available types are passed in as config.
This is the general structure:
{
TypeName: {
validate: async node => true || false || throw Exception()
reactors: {
fieldName: 'reactor',
field2...
}
},
Type2....
}
When picking field reactors, you should use the others
reactor for things that are used for filtering (formerly data
properties), and self
for things that are only used to determine that node's context result (formerly config
properties).
NOTE There are a few reserved words you can't use for type properties:
Data and config are special in that you can put properties inside them, and they will automatically have others
or a self
reactor, respectively.
The following methods are exposed on an instantiated client
Name | Signature | Description |
---|---|---|
add | async (path, newNode) -> await searchCompleted | Adds a node to the tree as a child of the specified path. You can await this for when updates settle and relevant searches are completed. |
remove | async path -> await searchCompleted | Removes a node at the specified path. You can await this for when updates settle and relevant searches are completed. |
mutate | async (path, deltas) -> await searchCompleted | Mutates the node at the given path with the new values. You can await this for when updates settle and relevant searches are completed. |
dispatch | async event -> await searchCompleted | A lower level, core method of interaction (called automatically by the actions above). You can await this for when updates settle and relevant searches are completed. |
getNode | [path] -> node | Lookup a node by a path (array of keys). |
serialize | () => tree | Returns a snapshot of the tree without any of the temporary state like updating flags. |
tree | tree | A reference to the internal tree. If you mutate this, you should dispatch an appropriate event. |
For those familiar with the previous client implementation (DataContext
/ContextGroup
), this client has a lot of design improvements:
updating
observable becomes falsey.:construction: More Details Coming Soon. :construction:
dispatch
with relevant event dataupdating
to trueupdating
to falseThe client maintains a flat tree in addition to the actual tree, which is an object mapped using flattenTree
from futil-js
.
The keys are the array paths encoded as a string, currently using a slashEncoder.
This allows path lookups to perform in constant time at O(1)
, drastically speeds up some of the internal tree operations.
FAQs
The Contexture (aka ContextTree) Client
The npm package contexture-client receives a total of 188 weekly downloads. As such, contexture-client popularity was classified as not popular.
We found that contexture-client demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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.