Security News
Input Validation Vulnerabilities Dominate MITRE's 2024 CWE Top 25 List
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
@mangosteen/got-to-temp
Advanced tools
First, use Got to create retryable read stream.
@mangosteen/got-to-temp
then helps you to:
Got
response data to a temp file that is automatically created for youIf there are any failures during download, the temp file is automatically cleaned up.
If there are any errors during download and Got
ran out of retries, the error is propagated via rejected promise.
With npm do:
$ npm install @mangosteen/got-to-temp
import { downloadToTempFile } from '@mangosteen/got-to-temp';
import { DigestStream } from '@mangosteen/digest-stream';
import got from 'got';
import crypto from 'crypto';
(async () => {
// Setup Got with retry
const gotClient = got.extend({
retry: {
limit: 5,
},
});
// If Got runs out of retries, this promise will reject with Got error
const downloadResult = await downloadToTempFile(
// Factory method to create download stream
() => gotClient.stream.get('https://nodejs.org/dist/v14.17.5/node-v14.17.5.tar.gz'),
// Optional factory method to create transform streams
() => [
// We use digest as an example here to show how to compute SHA-256 while
// the file is being downloaded. You may use any other transform streams,
// or simply avoid passing this factory method altogether.
new DigestStream({
digest: crypto.createHash('sha256'),
}),
] as const,
);
// Path to a file in a temp directory containing the downloaded data
console.log(downloadResult.filePath);
// Access the transform stream instances used during download
console.log(
downloadResult.transforms[0].digest().toString('hex'),
);
})();
FAQs
Download HTTP streams to temp files.
We found that @mangosteen/got-to-temp 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
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.
Research
Security News
A threat actor's playbook for exploiting the npm ecosystem was exposed on the dark web, detailing how to build a blockchain-powered botnet.