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.
@endo/promise-kit
Advanced tools
The promise-kit package provides a simple abstraction for creating and managing a promise. It exports, makePromiseKit
which is a utility function used to create a Promise and its associated resolver and rejector functions. This is particularly useful in asynchronous programming, where you might need to create a promise and resolve or reject it at a later point in time.
Note that this serves as a "ponyfill" for Promise.withResolvers
, making certain accommodations to ensure that the resulting promises can pipeline messages through @endo/eventual-send
.
Here’s an example of how makePromiseKit
might be used in an Agoric smart contract or JavaScript program:
import { makePromiseKit } from '@endo/promise-kit';
function asyncOperation() {
const { promise, resolve, reject } = makePromiseKit();
setTimeout(() => {
const success = true; // Simulating success or failure
if (success) {
resolve("Operation successful!");
} else {
reject("Operation failed!");
}
}, 2000);
return promise;
}
async function handleAsyncOperation() {
try {
const result = await asyncOperation();
console.log(result); // "Operation successful!"
} catch (error) {
console.error(error); // "Operation failed!"
}
}
handleAsyncOperation();
You can create multiple promise kits for managing various asynchronous tasks.
const kit1 = makePromiseKit();
const kit2 = makePromiseKit();
kit1.promise.then(value => console.log('Kit 1 resolved with:', value));
kit2.promise.then(value => console.log('Kit 2 resolved with:', value));
kit1.resolve('First success');
kit2.resolve('Second success');
makePromiseKit()
Creates a new promise kit.
Returns
promise
: The promise object.resolve
: The resolve function for the promise.reject
: The reject function for the promise.This package is licensed under the Apache-2.0 License.
FAQs
Helper for making promises
The npm package @endo/promise-kit receives a total of 9,488 weekly downloads. As such, @endo/promise-kit popularity was classified as popular.
We found that @endo/promise-kit 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.
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.