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

@lovable.dev/custom-view-server

v0.2.1

Published

Verify Lovable operator assertions on custom-view operator endpoints in published Lovable apps

Readme

@lovable.dev/custom-view-server

Verify Lovable operator assertions on custom-view operator endpoints inside published Lovable apps.

Why

A Lovable custom view (an editor panel for the project's operator) calls the app's own backend endpoints through lovable.data(). That call is proxied server-side by the Lovable API, which checks workspace membership — but the endpoints it targets (e.g. /api/posts) ship as plain routes on the published app, world-callable on public apps.

This package closes that gap. The Lovable API mints a short-lived RS256 operator assertion on the trusted data hop and forwards it via the x-lovable-operator-assertion header. The app verifies the assertion against the project's JWKS and rejects everything else with a 401.

The verification runs on Web Crypto (via jose) and works in Cloudflare Workers (workerd), Node 18+, Bun, and Deno.

Usage

Guard an operator route:

import { requireOperator } from "@lovable.dev/custom-view-server";

export async function handler(request: Request): Promise<Response> {
  const auth = await requireOperator(request);
  if (!auth.ok) return auth.response; // 401, JSON { error, code }

  // auth.claims.sub is the operator's user identity (when present)
  return Response.json({ posts: await listPosts() });
}

The app's own project ID is resolved from the environment Lovable injects (__LOVABLE_PROJECT_ID in process.env for sandbox dev and Node/Bun, the Cloudflare Workers env binding on published apps) — never hardcode it, since remixing copies source verbatim while assertions are minted for the new project. Pass projectId explicitly only to override the environment.

Lower-level building blocks:

import {
  verifyOperatorAssertion, // token string -> claims (throws OperatorAssertionError)
  verifyOperatorRequest, // Request -> claims (throws OperatorAssertionError)
  OPERATOR_ASSERTION_HEADER, // "x-lovable-operator-assertion"
} from "@lovable.dev/custom-view-server";

This package is wired into apps by the Lovable custom-views integration (like the MCP and Lovable Cloud integrations) — apps normally don't hand-configure it.

What is verified

| Check | Detail | | --------- | ------------------------------------------------------------------ | | Signature | RS256 only, against the per-project JWKS | | Issuer | https://api.lovable.dev/oidc/projects/<project_id> | | Audience | lovable-app | | Expiry | exp required (tokens without it are rejected), nbf when present, small clock tolerance (default 5s) | | Marker | principal: "operator" — identity tokens are rejected | | Project | project_id claim must equal the verifying app's own project ID |

The JWKS is fetched from <issuer>/.well-known/jwks.json and cached in-process; pass jwks in the options to verify against an inline key set instead (tests, offline).

Options

interface VerifyOperatorAssertionOptions {
  projectId?: string; // override; resolved from __LOVABLE_PROJECT_ID when omitted
  apiOrigin?: string; // default "https://api.lovable.dev"
  issuer?: string; // issuer override; JWKS follows it (<issuer>/.well-known/jwks.json)
  jwks?: JSONWebKeySet; // inline key set instead of remote fetch
  clockToleranceSec?: number; // default 5
  fetch?: typeof fetch; // custom fetch for the JWKS request
}

Errors

All verification failures throw (or, via requireOperator, return) an OperatorAssertionError with a stable code:

missing_assertion, malformed_assertion, invalid_signature, expired_assertion, wrong_issuer, wrong_audience, wrong_project, not_operator, jwks_unavailable, invalid_assertion.

The 401 response body carries only { error: "unauthorized", code } — never token contents or verification internals.

Security notes

  • Assertions are minted only by the Lovable API after an operator's workspace membership (edit access) is checked; the signing key never leaves Lovable.
  • Request binding (method + path) and assertion TTL are subject to the security review in CA-2032 and may tighten in a future release.