Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
save-as-file
Advanced tools
A simple fn to save a file to disk.
You can install this package from NPM:
npm add save-as-file
Or with Yarn:
yarn add save-as-file
For CDN, you can use unpkg:
https://unpkg.com/save-as-file/dist/bundles/save-as-file.umd.min.js
The global namespace for save-as-file is saveAsFile
:
const json = JSON.stringify({ping: true});
const file = new File([json], {type: 'application/json'});
saveAsFile(file, 'test.json');
Save a File to disk:
import saveFile from 'save-as-file';
const json = JSON.stringify({ping: true});
const file = new File([json], {type: 'application/json'});
saveFile(file, 'test.json');
NOTE: We create a temporary data uri for File/Blob objects which we revoke after 1 minute. If you need to download a large file which may take longer than 1 minute to download, use the 3rd argument to increase this timeout:
import saveFile from 'save-as-file';
const json = JSON.stringify({ping: true});
const file = new File([json], {type: 'application/json'});
saveFile(file, 'test.json', 1000 * 60 * 10 /* 10 mins */);
Save a File to disk:
const saveFile = require('save-as-file');
const json = JSON.stringify({ping: true});
const file = new File([json], {type: 'application/json'});
saveFile(file, 'test.json');
You can expect this lib to run wherever the href download attribute is supported.
If you wish to contribute, please use the following guidelines:
[ci skip]
in commit messages to skip a buildFAQs
A simple fn to save a file to disk
The npm package save-as-file receives a total of 172 weekly downloads. As such, save-as-file popularity was classified as not popular.
We found that save-as-file 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
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.