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

@rc-tool/unified-auth-sdk

v0.3.2

Published

Lightweight client SDK for Unified Auth hosted services.

Readme

@rc-tool/unified-auth-sdk

Unified Auth core SDK. It provides a black-box service client plus Better Auth helpers for the Auth Service runtime.

The package does not render the hosted login page and does not implement OAuth callbacks or sessions itself. Use @rc-tool/unified-auth-hosted-service when a business app wants to mount the SDK login page and /api/auth/* routes on its own origin.

Install

pnpm add @rc-tool/unified-auth-sdk

For an embedded Better Auth service:

pnpm add @rc-tool/unified-auth-sdk @rc-tool/unified-auth-hosted-service better-auth drizzle-orm

Client Boundary

import { createAuthServiceClient } from "@rc-tool/unified-auth-sdk/service-client";
import config from "@/unified-auth.config";

export const authClient = createAuthServiceClient({ config });

const user = await authClient.getCurrentUser();
const session = await authClient.getSession();
const context = await authClient.getAuthContext();

createAuthServiceClient({ config }) reads the app id, Auth origin, and redirect URI from unified-auth.config.ts.

Generate login/logout URLs:

authClient.getLoginURL({ provider: "feishu" });
authClient.getLogoutURL();

The SDK returns identity only:

  • AuthUser.id, email, name, avatarUrl, metadata
  • AuthSession.id, userId, clientId, expiresAt
  • AuthContext with { user, session }

Business apps should keep workspace/team/member/role/project data in their own tables and reference AuthUser.id.

Better Auth Server

import { createAuthServer } from "@rc-tool/unified-auth-sdk/server";
import { db } from "@/db";
import config from "@/unified-auth.config";

export const auth = createAuthServer({
  config,
  database: db,
});

createAuthServer wraps the latest Better Auth API used by this repo:

  • Drizzle adapter for the auth database.
  • Better Auth admin plugin.
  • Better Auth genericOAuth plugin for Feishu.
  • Built-in Better Auth social providers for Google and GitHub.
  • Auth origin, Better Auth secret, and trusted origins from unified-auth.config.ts.
  • Internal standard Better Auth Drizzle schema, selected by realm.

Provider credentials and Better Auth secret should come from the business project's own secret source, typically by referencing process.env inside unified-auth.config.ts.

Provider callback URLs should use Better Auth routes:

  • Feishu generic OAuth: /api/auth/oauth2/callback/feishu
  • Google: /api/auth/callback/google
  • GitHub: /api/auth/callback/github

Next Helper

import { createNextAuthHandlers } from "@rc-tool/unified-auth-sdk/next";
import { db } from "@/db";
import config from "@/unified-auth.config";

export const { GET, POST, auth } = createNextAuthHandlers({
  config,
  database: db,
});

realm: "a" maps to PostgreSQL schema auth_a: two business apps using the same realm share users and sessions; different realms get separate Better Auth table sets in the same database. Advanced users can still pass schema explicitly, but normal business apps should not write or maintain Better Auth schema files.

The hosted-service CLI can create and verify those tables:

pnpm dlx @rc-tool/unified-auth-hosted-service db migrate
pnpm dlx @rc-tool/unified-auth-hosted-service doctor

db migrate reads unified-auth.config.ts, derives the same realm, and compares the real PostgreSQL structure instead of relying on a migration history table.

Better Auth Client Helper

import { createAuthClient } from "@rc-tool/unified-auth-sdk/client";
import config from "@/unified-auth.config";

export const authClient = createAuthClient({
  baseURL: config.auth?.origin ?? config.app?.origin,
});

Hosted Login

import {
  createHostedAuthLoginPageComponent,
  createHostedAuthRouteHandlers,
} from "@rc-tool/unified-auth-hosted-service";
import { auth } from "@/lib/auth/server";
import config from "@/unified-auth.config";

const LoginPage = createHostedAuthLoginPageComponent({
  brandName: "AI PM",
  primaryProvider: "feishu",
  providers: ["feishu", "google", "github"],
});

export const hostedAuth = createHostedAuthRouteHandlers({
  auth,
  config,
  loginPageComponent: LoginPage,
});

Local Commands

pnpm typecheck
pnpm test
pnpm build