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

@yantra-app/cloud-auth-js

v0.2.0

Published

Yantra Cloud Auth JS — zero-config auth for Yantra-generated apps; drop-in for @lovable.dev/cloud-auth-js

Readme

@yantra-app/cloud-auth-js

Zero-config auth SDK for Yantra-generated apps — the Yantra equivalent of Lovable's @lovable.dev/cloud-auth-js (yantra-app issue #434).

Apps get Google/social sign-in without creating their own OAuth credentials: the flow is brokered through the central better-auth server, which holds platform-level provider credentials.

How it works

App (any domain)                Better Auth server (auth2.cdebase.dev)
────────────────                ──────────────────────────────────────
signInWithOAuth('google')
  → GET /~oauth/initiate ─────▶ validates redirect_uri origin,
                                sets signed state cookie,
                                302 → Google (platform credentials)
                                     │
                     Google ◀────────┘
                        │ callback
                        ▼
                 /api/auth/callback/google  (better-auth session)
                        │
                        ▼
                 /~oauth/callback
                   top-level  → 302 app#access_token=…&refresh_token=…&state=…
                   iframe     → popup postMessage {type:'authorization_response', …}
  • access_token — JWT signed by the server's jwt plugin. Verify with the public JWKS at /api/auth/jwks (stateless, any backend).
  • refresh_token — opaque session credential; exchange at POST /~oauth/token.

Usage (generated apps)

import { createYantraAuth } from "@yantra-app/cloud-auth-js";

const auth = createYantraAuth({
  // Relative by default (edge-proxied). Absolute URL to talk to the server directly:
  oauthBrokerUrl: "https://auth2.cdebase.dev/~oauth/initiate",
});

// Social (redirect at top level, popup+postMessage inside builder preview iframes)
await auth.signInWithOAuth("google");

// Email/password
await auth.signUpWithEmail({ name, email, password });
await auth.signInWithEmail({ email, password });

auth.getUser();          // decoded JWT payload
await auth.refreshSession();
await auth.signOut();

Templates for scaffolding into generated apps are in templates/ (integrations/yantra/index.ts wrapper + pages/AuthPage.tsx).

Replacing @lovable.dev/cloud-auth-js (drop-in)

The package exports Lovable's exact API surface (createLovableAuth, LovableAuth, LovableAuthConfig, same SignInWithOAuthResult shapes), so a Lovable-generated app can switch to the Yantra auth server three ways:

  1. Zero code changes — npm alias. In the generated app's package.json:

    "@lovable.dev/cloud-auth-js": "npm:@yantra-app/cloud-auth-js@^0.2.0"

    (or file:/tarball URL while unpublished). The auto-generated src/integrations/lovable/index.ts keeps working as-is.

  2. Change the import. Swap @lovable.dev/cloud-auth-js@yantra-app/cloud-auth-js in src/integrations/lovable/index.ts (a ready-made copy is in templates/integrations/lovable/index.ts).

  3. Full Yantra integration. Scaffold templates/integrations/yantra/ and drop supabase auth entirely.

Because the generated file calls createLovableAuth() with no arguments, point the SDK at your server one of these ways (checked in order):

<!-- index.html — works with the npm-alias path, no source changes -->
<script>window.__YANTRA_AUTH_URL__ = "https://auth-l0g8a.cdebase.dev";</script>
# Vite env (build-time)
VITE_YANTRA_AUTH_BROKER_URL=https://auth-l0g8a.cdebase.dev

A bare origin works — /~oauth/initiate is appended automatically. The app's origin must be in the server's BROKER_ALLOWED_ORIGINS (broker.allowedOrigins in the helm values; wildcards like https://*.pages.dev are supported).

Compat notes:

  • createLovableAuth() leaves the redirect-return URL fragment alone (like Lovable's SDK) so supabase-js detectSessionInUrl can consume it; createYantraAuth() consumes it into localStorage itself.
  • The generated integration passes our tokens to supabase.auth.setSession(). supabase-js stores them without verifying the signature, so the client-side session works; per-app Supabase data calls only authenticate once the Supabase stack is configured to trust this server's JWKS (/api/auth/jwks) as a third-party issuer.

Server configuration

The broker lives in the better-auth server app (app/src/broker.ts):

  • BROKER_ALLOWED_ORIGINS — CSV of app origins allowed as redirect_uri targets; supports wildcards (https://*.pages.dev). TRUSTED_ORIGINS are always included.
  • Social providers come from the existing socialProviderConfig table (admin UI → Connections) or env credentials.
  • Requires the jwt plugin (enabled by default).

Roadmap (issue #434)

  • [x] Broker endpoints + SDK + templates (MVP, central user pool)
  • [ ] Edge interception of /~oauth/* (Cloudflare Pages Function for webbuilder; sub-path proxy route for e2b/ui-host previews) so apps need zero config
  • [ ] Per-app tenant user pools (@adminide-stack tenant provisioning)
  • [ ] Per-app origin registration at deploy time (replace BROKER_ALLOWED_ORIGINS)
  • [ ] Mobile deep-link flow