
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@astropub/webapi
Advanced tools
WebAPI lets you use Web APIs in Node v12, v14, and v16.
npm install @astropub/webapi
import { polyfill } from '@astropub/webapi'
polyfill(globalThis)
const t = new EventTarget()
const e = new CustomEvent('hello')
t.addEventListener('hello', console.log)
t.dispatchEvent(e) // logs `e` event from `t`
These APIs are combined from popular open source projects and configured to share implementation details. This allows their behavior to match browser expectations as well as reduce their combined memory footprint.
You can use WebAPIs as individual exports.
import { AbortController, Blob, Event, EventTarget, File, fetch, Response } from '@astropub/webapi'
You can apply WebAPIs to an object, like globalThis.
import { polyfill } from '@astropub/webapi'
polyfill(globalThis)
The exclude option receives a list of WebAPIs to exclude from polyfilling.
polyfill(globalThis, {
// disables polyfills for setTimeout clearTimeout
exclude: 'setTimeout clearTimeout',
})
The exclude option accepts shorthands to exclude multiple polyfills. These shorthands end with the plus sign (+).
polyfill(globalThis, {
// disables polyfills for setTimeout clearTimeout
exclude: 'Timeout+',
})
polyfill(globalThis, {
// disables polyfills for Node, Window, Document, HTMLElement, etc.
exclude: 'Node+',
})
polyfill(globalThis, {
// disables polyfills for Event, EventTarget, Node, Window, Document, HTMLElement, etc.
exclude: 'Event+',
})
| Shorthand | Excludes |
|---|---|
Blob+ | Blob, File |
Document+ | Document, HTMLDocument |
Element+ | Element, and exclusions from HTMLElement+ |
Event+ | Event, CustomEvent, EventTarget, AbortSignal, MediaQueryList, Window, and exclusions from Node+ |
EventTarget+ | Event, CustomEvent, EventTarget, AbortSignal, MediaQueryList, Window, and exclusions from Node+ |
HTMLElement+ | CustomElementsRegistry, HTMLElement, HTMLBodyElement, HTMLCanvasElement, HTMLDivElement, HTMLHeadElement, HTMLHtmlElement, HTMLImageElement, HTMLStyleElement, HTMLTemplateElement, HTMLUnknownElement, Image |
Node+ | Node, DocumentFragment, ShadowRoot, Document, HTMLDocument, and exclusions from Element+ |
StyleSheet+ | StyleSheet, CSSStyleSheet |
Code original to this project is licensed under the CC0-1.0 License.
Code from abort-controller is licensed under the MIT License (MIT), Copyright Toru Nagashima.
Code from event-target-shim is licensed under the MIT License (MIT), Copyright Toru Nagashima.
Code from fetch-blob is licensed under the MIT License (MIT), Copyright Jimmy Wärting.
Code from formdata-polyfill is licensed under the MIT License (MIT), Copyright Jimmy Wärting.
Code from node-fetch is licensed under the MIT License (MIT), Copyright Node Fetch Team.
Code from web-streams-polyfill is licensed under the MIT License (MIT), Copyright Mattias Buelens and Diwank Singh Tomer.
FAQs
Use Web APIs in Node
The npm package @astropub/webapi receives a total of 309 weekly downloads. As such, @astropub/webapi popularity was classified as not popular.
We found that @astropub/webapi 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
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.