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

@digitalbazaar/vc-html-render-method

v1.0.1

Published

Render Verifiable Credential HTML Render Methods inside a nested, sandboxed iframe.

Readme

@digitalbazaar/vc-html-render-method

Render a Verifiable Credential's HTML Render Method inside a nested, sandboxed iframe — framework-agnostic, and without changing the consuming app's own Content-Security-Policy.

This library implements the html render suite of the W3C VC Render Method specification: an issuer-supplied HTML/CSS/JS template is rendered against a filtered copy of the credential, fully isolated from the host application.

Why a nested iframe?

  • The spec requires the page hosting the template to set a strict CSP (frame-src 'none'). Applying that to a whole application would break other <iframe src>-based features (for example CHAPI).
  • This library instead places the spec's "host page" role inside an iframe it owns, so the strict policy is scoped to that subtree and the consuming app's CSP is never touched.
App (any CSP; CHAPI <iframe src> keeps working)
  |-> host frame (library-owned; srcdoc)  CSP: frame-src 'none'
        |-> template frame  sandbox="allow-scripts", opaque origin
              CSP: default-src data: 'unsafe-inline'
              -> issuer HTML + filtered credential

The issuer template runs at an opaque origin under allow-scripts with no network access; it cannot reach the host frame or the application.

Install

npm install @digitalbazaar/vc-html-render-method

Usage

import {HtmlRenderer, supportsHtml} from '@digitalbazaar/vc-html-render-method';

if(supportsHtml({credential})) {
  const handle = new HtmlRenderer().render({
    mount: document.querySelector('#slot'),
    credential
  });

  // resolves when rendered
  await handle.ready;
  // frame auto-sizes to content
  handle.on('resize', ({height}) => {});
  // tear down when done
  handle.destroy();
}

The template runs at an opaque origin under sandbox="allow-scripts" with no network access, so it cannot reach the host frame or the application. Before the template runs, the credential is filtered to the render method's renderProperty JSON pointers — the template only sees the fields the issuer exposed.

Configuration

new HtmlRenderer(options) holds defaults for every render:

| Option | Type | Default | Description | |---|---|---|---| | timeout | number | 10000 | Milliseconds to wait for a ready/error signal before rejecting; 0 disables. | | sandbox | string | 'allow-scripts' | sandbox attribute for the template frame. | | waitForReady | boolean | false | Require an explicit renderMethodReady(); do not treat frame load as success. | | signalGrace | number | 250 | Milliseconds after load to wait for an explicit signal before treating load as success. |

render({mount, credential, renderMethod?}) returns a handle (renderMethod defaults to the first HTML render method on the credential):

| Member | Description | |---|---| | handle.ready | Promise that resolves on success; rejects on error, timeout, or destroy(). | | handle.element | The rendered <iframe> element. | | handle.on(type, fn) / off(type, fn) | Events: ready, error (Error), resize ({width, height}), loaded. | | handle.destroy() | Remove the iframe and listeners; reject ready if still pending. |

A render method's outputPreference.style (width/height) is honored as a fixed box; otherwise the frame auto-sizes to its content.

Conformance

Conforms to the inline HTML render suite of the specification (experimental, under active development):

  • Security: host frame-src 'none', template sandbox="allow-scripts", wrapper default-src data: 'unsafe-inline', no navigation/network/host access.
  • Wrapper: headless template with the credential in an application/vc data block.
  • Selective disclosure via selectJsonLd over renderProperty.
  • renderMethodReady() handshake over a MessageChannel.
  • outputPreference.style sizing preference.

Roadmap

  • Remote template fetch — only inline data: templates are supported today.
  • digestMultibase template integrity verification (multibase u, SHA-2-256).
  • The template map form {id, mediaType, digestMultibase}.
  • outputPreference.accessMode and preferred mediaType.

Commercial Support

Commercial support for this library is available upon request from Digital Bazaar: [email protected]

License

BSD-3-Clause © Digital Bazaar, Inc.