@huatek/ghostkey-prisma-adapter
v0.1.8
Published
Prisma/PostgreSQL adapter for GhostKey Auth.
Downloads
27
Readme
@huatek/ghostkey-prisma-adapter
Prisma/PostgreSQL adapter for GhostKey Auth.
This package implements the DatabaseAdapter contract using Prisma and ships a base Prisma schema for GhostKey tables.
Install
npm install @huatek/ghostkey-prisma-adapter @prisma/client
npm install -D prismaUsage
import { PrismaClient } from "@prisma/client";
import { createPrismaAdapter } from "@huatek/ghostkey-prisma-adapter";
const prisma = new PrismaClient();
const adapter = createPrismaAdapter(prisma);Schema
The package exports the schema file at:
@huatek/ghostkey-prisma-adapter/schemaIn this repository, the source schema is:
packages/adapters/prisma/prisma/schema.prismaIt includes:
GhostKeyUserGhostKeyDeviceGhostKeyChallengeGhostKeySessionGhostKeyRecoveryKeyGhostKeyKnownNetworkGhostKeyTrustedLocationGhostKeyAuditLog
GhostKeySession also stores trusted-session binding fields:
boundIpHashboundUserAgentHashboundDeviceFingerprintHashlastRiskScorelastSeenAtdelegatedByUserIdpermissions
Migration
Copy the GhostKey models into your app schema and run:
npx prisma migrate dev --name add_ghostkey_auth
npx prisma generateNotes
- PostgreSQL is the initial supported database target.
- Refresh token hashes, challenge state, known networks, trusted locations and audit logs are persisted here.
- Redis can be added separately for cache/rate limit acceleration.
