import { EmailVerificationService, User } from '../types.js'; import { Knex } from 'knex'; export interface PlunkVerificationConfig { apiKey: string; fromEmail: string; fromName?: string; templateId?: string; tokenExpiryMinutes?: number; /** * Token expiry time for password reset tokens in minutes * Default: 60 minutes (1 hour) */ resetTokenExpiryMinutes?: number; /** * Whether to use nodemailer for sending emails * If true, smtpConfig must be provided */ useNodemailer?: boolean; /** * SMTP configuration for nodemailer */ smtpConfig?: { host: string; port: number; secure: boolean; auth: { user: string; pass: string; }; }; /** * Template ID for password reset emails (Plunk) */ passwordResetTemplateId?: string; /** * Function to generate HTML email content for verification emails * If provided, this will be used instead of the built-in templates */ generateHtmlEmail?: (params: { name: string; token: string; expiresInMinutes: number; verificationUrl?: string; }) => Promise | string; /** * Whether to use the built-in JSX-Email templates * If true, the service will use the JSX-Email templates when possible * Default: true */ useJsxTemplates?: boolean; /** * Function to generate HTML email content for password reset emails * If provided, this will be used instead of the default template */ generatePasswordResetEmail?: (params: { name: string; token: string; resetUrl: string; }) => Promise | string; /** * Base URL for verification links * If provided, a full verification URL will be generated and passed to the email template * Example: https://example.com/verify?token= */ verificationUrlBase?: string; /** * Base URL for password reset links * If provided, a full reset URL will be generated and passed to the email template * Example: https://example.com/reset-password?token= */ resetUrlBase?: string; /** * Query parameter name for the token in verification and reset URLs * Default: 'token' */ tokenQueryParam?: string; /** * Additional query parameters to include in verification and reset URLs * Example: { redirect: '/dashboard' } */ additionalQueryParams?: Record; } export declare class PlunkEmailVerificationService implements EmailVerificationService { private readonly tableName; private readonly tokenExpiryMinutes; private transporter; private knex; private config; constructor(knex: Knex, config: PlunkVerificationConfig); /** * Generate a verification URL for the given token * @param token The verification token * @param userId Optional user ID to include in the URL * @returns The full verification URL or undefined if no base URL is configured */ generateVerificationUrl(token: string, userId?: string): string | undefined; /** * Generate a password reset URL for the given token * @param token The reset token * @param userId Optional user ID to include in the URL * @returns The full reset URL or undefined if no base URL is configured */ generateResetUrl(token: string, userId?: string): string | undefined; /** * Build a URL with the given parameters * @param baseUrl The base URL * @param token The token to include * @param userId Optional user ID to include * @param tokenParam The query parameter name for the token * @param additionalParams Additional query parameters to include * @returns The full URL */ private buildUrl; /** * Send a verification email to the user * @param email The recipient's email address * @param user The user object * @param customVerificationUrlBase Optional custom base URL for verification link * @returns The generated verification token */ sendVerificationEmail(email: string, user: User, customVerificationUrlBase?: string): Promise; verifyEmail(email: string, token: string, user: User): Promise; /** * Send a password reset email * @param email The recipient's email address * @param user The user object * @param resetUrl The URL for password reset (optional if resetUrlBase is configured) * @param customResetUrlBase Optional custom base URL for reset link (takes precedence over resetUrl and resetUrlBase) * @returns The generated token */ sendPasswordResetEmail(email: string, user: User, resetUrl?: string, customResetUrlBase?: string): Promise; /** * Verify a password reset token * @param token The reset token * @param userId The user ID * @returns True if the token is valid, false otherwise */ verifyPasswordResetToken(token: string, userId: string): Promise; /** * Consume a password reset token (mark it as used) * @param token The reset token * @param userId The user ID * @returns True if the token was found and consumed, false otherwise */ consumePasswordResetToken(token: string, userId: string): Promise; } //# sourceMappingURL=plunk-verification.service.d.ts.map