
Security News
/Research
Wallet-Draining npm Package Impersonates Nodemailer to Hijack Crypto Transactions
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
@pdedg/promise-retry
Advanced tools
promise-retry A promise retry executor with exponential backoff strategy. Comes with fetch retry out of the box
Install the package:
npm i @pdedg/promise-retry
A promise retry executor
// Simple execution
import { promiseRetry } from '@pdedg/promise-retry';
const run = () => new Promise((resolve, reject) => reject());
promiseRetry(run); // will execute rejected promise by default 3 times and after will trow error
// With custom delay strategy
import { promiseRetry } from '@pdedg/promise-retry';
const options = {
retries: 5,
retryOn: (err) => true,
delay: (err) => err.attempt * 1000,
onFailedAttempt: (err) => console.log(err.status)
}
const run = () => new Promise((resolve, reject) => reject());
promiseRetry(run);
/*
Will result of: 5 executions of failed promise ( retryOn is set to all ways true ).
On each attempt it will execute the onFailedAttempt, and will use linear delay between executions ( last will be 5s delay )
*/
Wraps a fetch request with retry, by default it will retry on the following http status [408, 503, 504] and on request-timeout error.
// Simple execution
import { fetchRetry } from '@pdedg/promise-retry';
const fetch = () => new Promise((resolve, reject) => reject());
fetchRetry(fetch, '/end-point', { delay: 100 }); // Will execute 3 fetch calls with 100 / 200 / 400 delay and eventually an error will be thrown.
// With custom options
import { fetchRetry } from '@pdedg/promise-retry';
const options = {
retries: 2,
retryOnResolved: (res) => {
if (res.status === 300) {
throw new Error('Cannot handle 300 status.')
}
},
}
const fetch = () => new Promise((resolve, reject) => resolve({ status: 300 }));
fetchRetry(fetch, '/end-point', options)
/*
Will result of: 2 executions of resolved promises, that will be rejected by the validate resolved method.
eventually, it will throw an error.
*/
FAQs
Promise with retry executor
The npm package @pdedg/promise-retry receives a total of 3 weekly downloads. As such, @pdedg/promise-retry popularity was classified as not popular.
We found that @pdedg/promise-retry 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
Malicious npm package impersonates Nodemailer and drains wallets by hijacking crypto transactions across multiple blockchains.
Security News
This episode explores the hard problem of reachability analysis, from static analysis limits to handling dynamic languages and massive dependency trees.
Security News
/Research
Malicious Nx npm versions stole secrets and wallet info using AI CLI tools; Socket’s AI scanner detected the supply chain attack and flagged the malware.