npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

aetherly-embed-guard

v0.1.0

Published

Reverse-proxy + injected guard script that lets you embed third-party video providers in an iframe without the tab-hijack, popup, and top-window redirect ads escaping the sandbox. Zero dependencies, Web Fetch API native.

Readme

aetherly-embed-guard

CI npm version npm downloads License: MIT Bundle size

Reverse-proxy + in-iframe guard script for safely embedding third-party video providers (vidsrc.*, 2embed.*, vidfast.pro, vidlink.pro, etc.) without their popunder, tab-hijack, and top-window-redirect ads escaping the iframe.

Zero dependencies, Web Fetch API native — works in Next.js App Router, Cloudflare Workers, Bun, Deno.

What problem this solves

Most "free embed" providers monetise with aggressive ads that try to:

  1. Open a popunder via window.open(...).
  2. Navigate the parent window via <a target="_top">, location.assign, or a form submission with target="_blank".
  3. Submit form-based clickjacks to attribution networks.
  4. Run script-injected <a> clicks programmatically.

Browser <iframe sandbox> mitigates some of this, but a few providers (notably vidfast.pro, vidlink.pro, embed.su) detect window.frameElement.sandbox and refuse to play if any flags are set. So you can't just sandbox everything.

This package's two-layer fix:

  • Server-side reverse proxy (createEmbedGuardHandler) — fetches the upstream provider HTML, rewrites relative URLs to absolute (against the original origin), and injects a guard <script> at the very top of <head>.
  • Client-side guard script — replaces window.open with a fake-window stub, intercepts and cancels any cross-origin anchor click / form submit, wraps location.assign and location.replace, and re-routes fetch / XMLHttpRequest calls that target the upstream origin back through the proxy (so the player's own runtime API calls keep working).

A separate host list (DEFAULT_TRUSTED_DIRECT_HOSTS) flags the sandbox-sensitive providers so callers can render those direct.

Install

npm install aetherly-embed-guard

Use with Next.js App Router

// app/api/player-proxy/route.ts
import { createEmbedGuardHandler } from 'aetherly-embed-guard';

export const runtime = 'nodejs';
export const dynamic = 'force-dynamic';

export const { GET } = createEmbedGuardHandler({
  proxyPath: '/api/player-proxy',
});

Then point your iframe at /api/player-proxy?url=<encoded upstream>. The proxy will fetch, inject the guard, and return HTML that loads cleanly in a sandboxed iframe.

The trusted-direct exception

vidfast.pro, vidlink.pro, and embed.su will black-screen if rendered in a sandboxed iframe. The recommended client-side flow:

import { isTrustedDirect } from 'aetherly-embed-guard';

function attachIframe(iframe: HTMLIFrameElement, providerUrl: string) {
  if (isTrustedDirect(providerUrl)) {
    // No proxy, no sandbox. Rely on the browser's popup blocker.
    iframe.removeAttribute('sandbox');
    iframe.src = providerUrl;
    return;
  }
  // Sandboxed + proxied (guard script handles the rest).
  iframe.setAttribute(
    'sandbox',
    'allow-scripts allow-same-origin allow-forms allow-presentation allow-pointer-lock allow-orientation-lock allow-modals',
  );
  iframe.src = `/api/player-proxy?url=${encodeURIComponent(providerUrl)}`;
}

Use with Cloudflare Workers

import { createEmbedGuardHandler } from 'aetherly-embed-guard';

const proxy = createEmbedGuardHandler({ proxyPath: '/api/player-proxy' });

export default {
  async fetch(request: Request): Promise<Response> {
    const url = new URL(request.url);
    if (url.pathname === '/api/player-proxy') return proxy.GET(request);
    return new Response('Not found', { status: 404 });
  },
};

Options

createEmbedGuardHandler({
  proxyPath: '/api/player-proxy',
  providerHosts: DEFAULT_PROVIDER_HOST_RULES, // pass your own for a stricter allowlist
  requestTimeoutMs: 12_000,
  retries: 1,
  defaultUserAgent: 'Mozilla/5.0 ...',
  fetchImpl: fetch,
});

Security notes

  • The host allowlist (providerHosts) is load-bearing. Without it, this becomes an open HTTP proxy.
  • The guard script runs inside the proxied document. It cannot prevent every escape (a deeply-nested iframe loading its own document is out of scope), but it stops every common ad-injection pattern those providers have shipped over the last 2+ years.
  • This does not bypass DRM, CDN signing, or geo-restrictions — it's purely a UX hardening layer on top of publicly accessible embed pages.

License

MIT