UNPKG

caplib

Version:

Credentialless Authentication Protocol Library for Web Applications

57 lines (50 loc) 1.9 kB
export { c as createAuthHandler } from '../wallet-auth-N0r0iYmG.js'; import { U as User, N as NewUserData } from '../types-B5TgxFMm.js'; import { NextRequest, NextResponse } from 'next/server'; import 'react'; interface DatabaseInterface { initialize(): Promise<void>; findUser(walletAddress: string): Promise<User | null>; createUser(userData: NewUserData): Promise<User>; updateUser(walletAddress: string, updates: Partial<User>): Promise<User | null>; deleteUser(walletAddress: string): Promise<boolean>; close(): Promise<void>; } declare class EncryptedJSONDatabase implements DatabaseInterface { private static instance; private dbPath; private data; private initialized; private encryptionKey; private constructor(); static getInstance(dbPath?: string): EncryptedJSONDatabase; private encrypt; private decrypt; private ensureDirectoryExists; private loadData; private saveData; initialize(): Promise<void>; findUser(walletAddress: string): Promise<User | null>; createUser(userData: NewUserData): Promise<User>; updateUser(walletAddress: string, updates: Partial<User>): Promise<User | null>; deleteUser(walletAddress: string): Promise<boolean>; close(): Promise<void>; } declare const db: EncryptedJSONDatabase; /** * Gets available user roles from environment variables */ declare function getAvailableRoles(): string[]; /** * Gets the default user role from environment variables */ declare function getDefaultRole(): string; /** * Validates if a role exists in the available roles */ declare function isValidRole(role: string): boolean; declare function GET(_req: NextRequest): Promise<NextResponse<{ roles: string[]; defaultRole: string; }>>; export { type DatabaseInterface, EncryptedJSONDatabase, db, getAvailableRoles, getDefaultRole, GET as getRoles, isValidRole };