Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Type-safe, DRY and OO redux. Implemented with typescript.
@component
class App {
counter = new Counter();
}
@component
class Counter {
value = 0;
increment() {
this.value = value + 1; // <--- see Important Notice below
}
}
const app = new ReduxApp(new App(), devToolsEnhancer(undefined));
console.log(app.root.counter.value); // 0
console.log(app.store.getState()); // { counter: { value: 0 } }
app.root.counter.increment(); // will dispatch COUNTER.INCREMENT redux action
console.log(app.root.counter.value); // 1
console.log(app.store.getState()); // { counter: { value: 1 } }
You should not mutate the object properties but rather assign them with new values.
That's why we write this.value = value + 1
and not this.value++
.
For each component
decorated class the library generates an underlying Component
object that holds the same properties and method. The new Component object has it's prototype patched and all of it's methods replaced with dispatch() calls.
The generated Component also has a hidden 'REDUCER' property which is assigned to the redux store. The 'REDUCER' property itself is generated from the original object methods, replacing all 'this' values with the current state from the store on each call (using Object.assign and Function.prototype.call).
You can supply the following options to the component
decorator.
class SchemaOptions {
/**
* Add the class name of the object that holds the action to the action name.
* Format: <class name>.<action name>.
* Default value: true.
*/
public actionNamespace?: boolean;
/**
* Use redux style action names. For instance, if a componentSchema defines a
* method called 'incrementCounter' the matching action name will be
* 'INCREMENT_COUNTER'.
* Default value: true.
*/
public uppercaseActions?: boolean;
/**
* By default each component is assigned (with some optimizations) with it's
* relevant sub state on each store change. Set this to false to disable
* this updating process. The store's state will still be updated as usual
* and can always be retrieved using store.getState().
* Default value: true.
*/
public updateState?: boolean;
}
Usage:
@component({ uppercaseActions: false })
class Counter {
value = 0;
increment() { // <-- Will now dispatch 'Counter.increment' instead of 'COUNTER.INCREMENT'. Everything else still works the same, no further change required.
this.value = value + 1;
}
}
Available global options:
class GlobalOptions {
logLevel: LogLevel;
/**
* Global defaults. Options supplied explicitly via the decorator will override options specified here.
*/
schema: SchemaOptions;
}
enum LogLevel {
/**
* Emit no logs
*/
None = 0,
Verbose = 1,
Debug = 2,
/**
* Emit no logs (same as None)
*/
Silent = 10
}
Usage:
ReduxApp.options.logLevel = LogLevel.Debug;
FAQs
Type-safe, DRY and OO redux. Implemented with typescript.
The npm package redux-app receives a total of 0 weekly downloads. As such, redux-app popularity was classified as not popular.
We found that redux-app 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
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.