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.
promto
Wrappes A Promise In Timeout.
yarn add promto
async promto(promise: Promise, timeout: number, description: string?): Promise
The package is available by importing its default function:
import promto from 'promto'
async promto(
promise: Promise,
timeout: number,
description: string?,
): Promise
Creates a new promise which will be rejected upon timeout (after N milliseconds). It will be resolved with the promise value or rejected with the promise error when not timed out.
import promto from 'promto'
const makePromise = async (timeout, result) => {
await new Promise((resolve) => {
setTimeout(resolve, timeout || 200)
})
if (result instanceof Error) throw result
return result
}
(async () => {
// ok
const res = await promto(makePromise(50, 'hello'), 100)
console.log(res)
// rejected timeout
try {
await promto(makePromise(150, 'world'), 100)
} catch (err) {
console.log(err.message)
}
// rejected timeout with description
try {
await promto(makePromise(150, 'world'), 100, 'Example')
} catch (err) {
console.log(err.message)
}
// rejected promise
try {
await promto(makePromise(50, new Error('Error in promise')), 100)
} catch (err) {
console.log(err.message)
}
})()
hello
Promise has timed out after 100ms
Example has timed out after 100ms
Error in promise
© Art Deco 2019 | Tech Nation Visa Sucks |
---|
FAQs
Create a promise with a timeout.
We found that promto 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.
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.