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 🙏

© 2024 – Pkg Stats / Ryan Hefner

isolated-iframe

v0.0.0

Published

An experiment in isolating an iFrame from the network using service-workers.

Downloads

2

Readme

Isolated iFrame

An experiment in isolating an iFrame from the network using service-workers.

Based on this thread.

Unlike ses-iframe, I'm aspiring to the simpler goal of just shutting down network access for the whole frame. Not trying to emulate or attenuate network access, just shut it down. If I can get a silent iframe, I can build up functionality from there.

If I get it working, I hope to package up the working parts into a reusable module.

Current API (Unstable!)

This module is under casual experimentation, and currently does not work as intended, and should not be relied on for anything.

That said, here is the current usage, as seen in example.js:

import iframeIsolator from 'iframe-isolator';

// Imagine this HTML is untrusted code:
const malicious_html = `
  HELLO!
<style>
body {
   background: url("http://www.fillmurray.com/200/300")
}
</style>
`;

window.addEventListener('load', ready)

async function ready () {
  const container = document.getElementById('container')

  // First argument is the malicious HTML to inject, the second argument is an element to inject within:
  await iframeIsolator(malicious_html, container)
}

Later I'd love to pass in a props object also, which could ideally include functions for helping the child load and subscribe to updates.

The props object could simply be a read-only JS object that is appended to the child's global scope, but I think it would be even cooler to support passing an asynchronous API object, to allow easy bidirectional communication, maybe using captp-stream over port-stream.

Current Status

  • [x] Parent page starts filtering serviceworker before creating child iframe
  • [x] Parent injects serviceworker registration into child before the untrusted render code.
  • [x] Parent waits for serviceworker registration in child to complete before injecting untrusted render code.
  • [x] Once serviceworker is registered, child requests to non-same-origins are rejected.
  • [ ] Get working on first load
  • [x] Get working on second load on Firefox
  • [ ] Get working on Chrome
  • [ ] Explore getting injection working with srcdoc api.