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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@cauth/prisma

v0.1.0

Published

Prisma integration for CAuth authentication system.

Readme

@cauth/prisma

Prisma integration for CAuth authentication system.

Features

  • Prisma Integration: Database provider for CAuth using Prisma
  • Type Safety: Full TypeScript support with Prisma Client
  • Schema Support: Ready-to-use Prisma schema for authentication
  • Account Management: User account CRUD operations
  • Token Management: Refresh token handling
  • OTP Support: One-time password functionality

Installation

npm install @cauth/prisma @cauth/core @prisma/client
# or
yarn add @cauth/prisma @cauth/core @prisma/client
# or
pnpm add @cauth/prisma @cauth/core @prisma/client

Quick Start

  1. Add the authentication models to your Prisma schema:
model Auth {
  id            String   @id @default(uuid())
  phoneNumber   String?  @unique
  email         String?  @unique
  role          String
  passwordHash  String
  lastLogin     DateTime
  refreshTokens String[]
  createdAt     DateTime @default(now())
  updatedAt     DateTime @updatedAt
  user          User?
  otp Otp?

  @@map("auth")
}

model Otp {
  id        String     @id
  auth      Auth       @relation(fields: [id], references: [id])
  code      String
  purpose   OtpPurpose
  expiresAt DateTime
  isUsed    Boolean
  createdAt DateTime   @default(now())
  updatedAt DateTime   @updatedAt

  @@map("otp")
}

// ADD AS MANY PURPOSES YOU WISH, BUT DON'T REMOVE RESET_PASSWORD AND LOGIN
enum OtpPurpose {
  LOGIN
  RESET_PASSWORD
  ACTION
}
  1. Generate Prisma Client:
npx prisma generate
  1. Use with CAuth:
import { PrismaClient } from '@prisma/client';
import { CAuth } from '@cauth/core';
import { PrismaProvider } from '@cauth/prisma';
import { ExpressContractor } from '@cauth/express';

const prisma = new PrismaClient();

const auth = CAuth({
  roles: ['USER', 'ADMIN'],
  dbContractor: new PrismaProvider(prisma),
  routeContractor: new ExpressContractor(),
  jwtConfig: {
    accessTokenSecret: process.env.ACCESS_TOKEN_SECRET!,
    refreshTokenSecret: process.env.REFRESH_TOKEN_SECRET!,
  }
});

API Reference

PrismaProvider

The PrismaProvider class implements the DatabaseContract interface:

class PrismaProvider implements DatabaseContract {
  constructor(prisma: PrismaClient);

  // Account Management
  findAccountById<T>({ id, select }: { id: string; select?: any }): Promise<T | undefined>;
  findAccountWithCredential<T>({ email, phoneNumber, select }: { email?: string; phoneNumber?: string; select?: any }): Promise<T | undefined>;
  createAccount<T>({ data, select }: { data: any; select?: any }): Promise<T>;
  updateAccount<T>({ id, data, select }: { id: string; data: any; select?: any }): Promise<T>;
  deleteAccount({ id }: { id: string }): Promise<void>;

  // Token Management
  updateAccountLogin<T>({ id, refreshToken, select }: { id: string; refreshToken: string; select?: any }): Promise<T>;
  removeAndAddRefreshToken({ id, refreshToken, newRefreshToken, select }: { id: string; refreshToken: string; newRefreshToken?: string; select?: any }): Promise<any>;

  // OTP Management
  createOTP<T>({ config }: { config: CAuthOptions }, { id, purpose }: { id: string; purpose: OtpPurpose }): Promise<T>;
  verifyOTP<T>({ id, code, purpose }: { id: string; code: string; purpose: OtpPurpose }): Promise<T>;
}

Development

Prerequisites

  • Node.js >= 18
  • TypeScript >= 5.9
  • Prisma >= 5.0

Building

pnpm install
pnpm build

License

MIT License - see LICENSE file for details.

Support

For issues and feature requests, please visit the GitHub repository.