Security News
Research
Data Theft Repackaged: A Case Study in Malicious Wrapper Packages on npm
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Vast is a simple state utility created to use in Vest. It allows using a similar pattern to React's useState hook to store data.
Note that this is mostly intended to be used within libraries, and not as a consumer facing interface. When paired with a context propagation libraries such as context, it can have pretty powerful capabilities. See Vest for a real life example.
npm i vast
import { createState } from 'vast';
const state = createState(); // Creates a state reference.
const useColor = state.registerStateKey('blue'); // Creates a new key in the state, and gives it an initial value
// You can also pass in a function to use as the initial state
const [color, setColor] = useColor(); // ["blue", Function]
setColor('red'); // set the color to "red"
The next time you will call useColor
the value of color
will be "red"
.
You can also set a computed value by passing in a function:
const [color, setColor] = useColor(); // ["blue", Function]
setColor(currentColor => (color === 'red' ? 'blue' : 'red'));
NOTE This will not let you know what change was made, but only that a key in the state was updated or added:
Simply add an onChange callback to your createState:
const state = createState(() => console.log('the state was updated!'));
Now on every state change, this callback will run.
Alternatively, if you need more granularity, you can subscribe to specific state keys.
If you need to react to specific changes in your state, you can add an onUpdate
callback to those state key registrations:
const useColor = state.registerStateKey(
'red',
(currentState, previousState) => {
console.log(`the color changed from ${previousState} to ${currentState}!`);
},
);
Now, whenever a state update happens in that key, your callback will run, providing the previous and changed value as well.
FAQs
Unknown package
We found that vast demonstrated a healthy version release cadence and project activity because the last version was released less than 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.
Security News
Research
The Socket Research Team breaks down a malicious wrapper package that uses obfuscation to harvest credentials and exfiltrate sensitive data.
Research
Security News
Attackers used a malicious npm package typosquatting a popular ESLint plugin to steal sensitive data, execute commands, and exploit developer systems.
Security News
The Ultralytics' PyPI Package was compromised four times in one weekend through GitHub Actions cache poisoning and failure to rotate previously compromised API tokens.