nuxt-users
Version:
A comprehensive user management module for Nuxt 3 and Nuxt 4 applications with authentication, authorization, database support, and CLI tools
34 lines (33 loc) • 1.28 kB
TypeScript
import { OAuth2Client } from 'google-auth-library';
import type { ModuleOptions, User, GoogleOAuthOptions } from 'nuxt-users/utils';
export interface GoogleUserInfo {
id: string;
email: string;
name: string;
picture?: string;
verified_email: boolean;
}
/**
* Create Google OAuth2 client
*/
export declare function createGoogleOAuth2Client(options: GoogleOAuthOptions, callbackUrl: string): OAuth2Client;
/**
* Generate authorization URL for Google OAuth
*/
export declare function getGoogleAuthUrl(oauth2Client: OAuth2Client, options: GoogleOAuthOptions): string;
/**
* Exchange authorization code for tokens and get user info
*/
export declare function getGoogleUserFromCode(oauth2Client: OAuth2Client, code: string): Promise<GoogleUserInfo>;
/**
* Generate a secure random password for OAuth users
*/
export declare function generateSecurePassword(): Promise<string>;
/**
* Find or create user from Google OAuth data
*/
export declare function findOrCreateGoogleUser(googleUser: GoogleUserInfo, moduleOptions: ModuleOptions): Promise<User | null>;
/**
* Create authentication token for user (reusing existing logic)
*/
export declare function createAuthTokenForUser(user: User, moduleOptions: ModuleOptions, rememberMe?: boolean): Promise<string>;