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

artifact-sdk

v0.2.0

Published

Browser client SDK for artifact-gateway — secure proxy calls (external APIs, internal APIs, isolated DBs, files, code-run) from AI-generated artifact web apps running in sandboxed iframes.

Readme

artifact-sdk

Browser client SDK for artifact-gateway — the secure proxy for AI-generated artifact web apps.

An AI agent generates an HTML/JS "artifact" that runs in a sandboxed iframe. This SDK lets that artifact make RBAC-scoped, authenticated calls back through the gateway — without ever holding API keys — to:

  • external third-party HTTPS APIs (CORS bypass + server-side credential vault)
  • internal APIs (allowlisted paths)
  • isolated databases (per-user / per-session DuckDB & MongoDB)
  • files (per-user / per-session read/write/list/delete)
  • streaming upstreams (SSE)
  • code execution in a constrained sandbox (run)

The server side is the Python package artifact-gateway.

Install

npm install artifact-sdk

Or load directly in an artifact via CDN (no build step):

<script src="https://cdn.jsdelivr.net/npm/artifact-sdk/dist/artifact-sdk.js"></script>

How it works

The host page (your app) renders the artifact in a sandboxed iframe and, after load, posts an init message:

iframe.contentWindow.postMessage(
  { type: "artifact-gateway:init", token: "<short-lived app JWT>", proxyBase: "/api/app/" },
  "*"
);

Inside the artifact, the SDK captures the token (held in memory only) and exposes window.artifactGateway:

<script src="https://cdn.jsdelivr.net/npm/artifact-sdk/dist/artifact-sdk.js"></script>
<script>
  // The token may arrive after your scripts run — gate calls on _onReady.
  window.artifactGateway._onReady = async () => {
    const r = await window.artifactGateway.external({
      method: "GET",
      url: "https://api.example.com/v1/data",
      credentialId: "my-api-key",      // resolved server-side; never inline secrets
    });
    console.log(r.status, r.body);
  };
</script>

window.ohwise is kept as an alias of window.artifactGateway for OhWise compatibility.

Programmatic (bundlers)

import { createClient } from "artifact-sdk";

const gw = createClient({ token, proxyBase: "/api/app/" });
const rows = await gw.db.userQuery("analytics", "SELECT * FROM events WHERE ts > ?", ["2026-01-01"]);

API

| Call | Purpose | |------|---------| | external({method,url,headers,body,credentialId}) | third-party HTTPS (CORS bypass; secrets via credentialId) | | stream({...}, onChunk) | SSE / token streams | | internal({method,path,body}) | allowlisted internal APIs | | db.userQuery/userExec/sessionQuery/sessionExec(db,sql,params) | isolated DuckDB | | db.find/upsert/delete(collection, …) | isolated MongoDB | | files.write/read/list/delete(path[,content]) (+ session*) | isolated file IO | | run(language, code, stdin) | constrained code execution | | refresh() | re-issue the app token (auto-called on 401) |

Security notes

  • The app token is a short-lived, RBAC-scoped JWT — keep it in memory only, never localStorage.
  • Never embed secrets in the artifact — reference them by credentialId; the gateway injects them server-side from an encrypted vault.
  • All calls are scope-checked at the gateway; external is HTTPS-only; internal is path-allowlisted; DB access is per-user/per-session isolated.

License

Apache-2.0