
Product
Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
@tanker/file-polyfill
Advanced tools
A well known issue with the JavaScript File
class is the lack of a constructor in some browsers:
new File(['Hi!'], 'file.txt'); // will throw in Edge and Internet Explorer
Using feature detection, this package will either expose a File
polyfill in browsers lacking a proper constructor, or the native File
class in others.
You can safely use this package as a drop-in replacement for the native File
class in all browsers, e.g.:
import FilePolyfill from '@tanker/file-polyfill';
// Get bits from whatever method you want, using fetch() as an example
const response = await fetch('https://your.server.com/path/to/a/dummy.pdf');
const bits = [await response.arrayBuffer()];
// Construct a file in a cross-browser fashion
const file = new FilePolyfill(bits, 'dummy.pdf', { type: 'application/pdf' });
// Check what we've got
file instanceof window.Blob; // true
file instanceof window.File; // true
file instanceof FilePolyfill; // true
file.name; // 'dummy.pdf'
file.type; // 'application/pdf'
file.size; // the size of dummy.pdf
Note that the polyfill is built with a clever class hierarchy so that instances will appear as regular File
and Blob
instances, that can be used with FileReader
and other APIs working with files.
Sponsored by Tanker.
FAQs
A cross-browser polyfill for File with a working constructor
We found that @tanker/file-polyfill demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 5 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.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.
Research
Socket uncovers malicious Rust crates impersonating fast_log to steal Solana and Ethereum wallet keys from source code.
Research
A malicious package uses a QR code as steganography in an innovative technique.