UNPKG

@remcostoeten/fync

Version:

Unified TypeScript library for 9 popular APIs with consistent functional architecture

95 lines 3.11 kB
/** * Complete OAuth2 + Drizzle ORM Integration Example for Next.js * * This example demonstrates how to integrate fync OAuth2 authentication * with Drizzle ORM in a Next.js application following modular architecture. * * Features: * - GitHub & Google OAuth2 authentication * - User session management with Drizzle ORM * - Refresh token handling * - Modular architecture following your design principles * - Type-safe database operations * - Middleware for protected routes */ import type { NextRequest } from 'next/server'; export declare const users: any; export declare const accounts: any; export declare const sessions: any; export type User = typeof users.$inferSelect; export type NewUser = typeof users.$inferInsert; export type Account = typeof accounts.$inferSelect; export type NewAccount = typeof accounts.$inferInsert; export type Session = typeof sessions.$inferSelect; export type NewSession = typeof sessions.$inferInsert; export declare const db: any; export declare const githubOAuth: any; export declare const googleOAuth: any; export declare class AuthService { /** * Create or update user from GitHub OAuth */ static handleGitHubCallback(code: string, state?: string): Promise<{ user: any; session: any; tokens: any; }>; /** * Create or update user from Google OAuth */ static handleGoogleCallback(code: string, codeVerifier?: string): Promise<{ user: any; session: any; tokens: any; }>; /** * Refresh access token for a user account */ static refreshAccessToken(userId: string, provider: 'github' | 'google'): Promise<any>; /** * Validate and refresh token if needed */ static getValidAccessToken(userId: string, provider: 'github' | 'google'): Promise<any>; /** * Create or update user */ private static upsertUser; /** * Create or update account */ private static upsertAccount; /** * Create a new session */ private static createSession; /** * Get session with user */ static getSessionWithUser(sessionId: string): Promise<any>; /** * Delete session (logout) */ static deleteSession(sessionId: string): Promise<void>; /** * Revoke OAuth tokens and delete account */ static revokeAccount(userId: string, provider: 'github' | 'google'): Promise<void>; } export declare function GET(): Promise<Response>; export declare function GitHubCallbackHandler(request: NextRequest): Promise<Response>; export declare function GoogleAuthHandler(): Promise<Response>; export declare function GoogleCallbackHandler(request: NextRequest): Promise<Response>; export declare function authMiddleware(request: NextRequest): Promise<any>; export declare function GitHubIntegrationExample({ userId }: { userId: string; }): Promise<{ user: any; repos: any; }>; export declare function GoogleCalendarExample({ userId }: { userId: string; }): Promise<{ events: any; calendars: any; }>; //# sourceMappingURL=oauth-drizzle-nextjs.d.ts.map