
Research
Security News
Lazarus Strikes npm Again with New Wave of Malicious Packages
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
@swear-js/core
Advanced tools
Core package of SwearJS state manager
Demo application is runnable via npx:
$ npx swear-demo-agnostic
Don't forget to remove created project directory after
$ npm install @swear-js/core
or in case you are using Yarn:
$ yarn add @swear-js/core
First you have to initialize your store.
import { createStore } from "@swear-js/core";
const store = createStore();
Then you have to create
import { createStore } from "@swear-js/core";
const store = createStore();
// This will create swear, and triggers onUpdate everytime it changes
store.subscribe({
swearId: 'count',
defaultState: 0,
onUpdate: (newValue) => {
// You can here trigger things when it updates. You can trigger here your render function, or something
}
});
const decreaseHandler = () => {
store.setSwearValue('count', 'decrease', store.getSwearValue('count') - 1);
};
const increaseHandler = () => {
store.setSwearValue('count', 'increase', store.getSwearValue('count') + 1);
};
You can pass your custom logger to the store, or use @swear-js/logger. Swear-js logger usage:
import { createStore } from "@swear-js/core";
import { swearLogger } from "@swear-js/logger";
const store = createStore({ onPatch: swearLogger });
In order to implement your own logger solution, you just have to keep in mind an API of onPatch
argument of the store.
onPatch
is any callback that get SwearPatch
(you can find it in package) type as an argument.
Simply SwearPatch is:
{
swearId, // String value which gets a name of patched swear state
actionType, // String value which gets a name of a dispatched action
prev, // Previous store state (object)
payload, // Payload passed
next // Current store state
}
Example very-simple implementation of logger:
import { SwearPatch, createStore } from "@swear-js/core";
const logger = ({ swearId, actionType, prev, payload, next }: SwearPatch) => {
console.log(`Swear: ${swearId}, Action: ${actionType}, Payload: ${payload}`);
console.log(`Previous state: ${prev}`, `Current state: ${next}`);
};
const store = createStore({ onPatch: logger });
FAQs
Simple observer state manager
The npm package @swear-js/core receives a total of 1 weekly downloads. As such, @swear-js/core popularity was classified as not popular.
We found that @swear-js/core 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
The Socket Research Team has discovered six new malicious npm packages linked to North Korea’s Lazarus Group, designed to steal credentials and deploy backdoors.
Security News
Socket CEO Feross Aboukhadijeh discusses the open web, open source security, and how Socket tackles software supply chain attacks on The Pair Program podcast.
Security News
Opengrep continues building momentum with the alpha release of its Playground tool, demonstrating the project's rapid evolution just two months after its initial launch.