
Security News
PodRocket Podcast: Inside the Recent npm Supply Chain Attacks
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
@tanker/file-ponyfill
Advanced tools
A common 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
ponyfill 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 { FilePonyfill } from '@tanker/file-ponyfill';
// Get bits from whatever method you want, using fetch() as an example
const response = await fetch('https://your.server.com/path/to/a/report.pdf');
const bits = [await response.arrayBuffer()];
// Construct a file in a cross-browser fashion
const file = new FilePonyfill(bits, 'report.pdf', { type: 'application/pdf' });
// Check what we've got
file instanceof window.Blob; // true
file instanceof window.File; // true
file instanceof FilePonyfill; // true
file.name; // 'report.pdf'
file.type; // 'application/pdf'
file.size; // the size of report.pdf
Note that the ponyfill is built using a clever class hierarchy so that instances will appear as regular File
and Blob
instances, which can safely be read by a FileReader
and used with other APIs working with files
This package is a dependency of the Tanker client SDKs for end-to-end encryption:
Read the documentation to get started.
FAQs
A cross-browser ponyfill for File with a working constructor
The npm package @tanker/file-ponyfill receives a total of 4,395 weekly downloads. As such, @tanker/file-ponyfill popularity was classified as popular.
We found that @tanker/file-ponyfill demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 4 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.
Security News
Socket CEO Feross Aboukhadijeh discusses the recent npm supply chain attacks on PodRocket, covering novel attack vectors and how developers can protect themselves.
Security News
Maintainers back GitHub’s npm security overhaul but raise concerns about CI/CD workflows, enterprise support, and token management.
Product
Socket Firewall is a free tool that blocks malicious packages at install time, giving developers proactive protection against rising supply chain attacks.