import { betterAuth } from 'better-auth'; import type { DatabaseStore } from '../../store/database-store.js'; import type { MagicLinkIntent } from '../../types/magic-link.js'; import { EmailValidationService, type EmailValidationResult } from '../email/email-validation-service.js'; import { MagicLinkEmailService } from '../email/magic-link-email-service.js'; type BetterAuthInstance = Awaited>; export type MagicLinkSendResult = { sent: true; } | { sent: false; reason: 'user_not_found' | 'not_initialized' | 'invalid_email'; } | { sent: false; reason: 'blocked_email_policy'; blockReason: Extract['reason']; } | { sent: false; reason: 'rate_limited'; waitSeconds: number; }; /** * Handles magic-link generation and sending, with guards for reset of unknown users. * Keeps sendMagicLink callback separate from creation to avoid tight coupling in config. */ export declare class MagicLinkService { private readonly store; private readonly emailService; private readonly baseUrl; private readonly emailValidationService; private static readonly RESEND_COOLDOWN_SECONDS; private readonly logger; private auth?; constructor(store: DatabaseStore, emailService: MagicLinkEmailService, baseUrl: string, emailValidationService?: EmailValidationService); setAuth(auth: BetterAuthInstance): void; /** * sendMagicLink callback for Better Auth plugin. * Builds pre-confirm link and delegates to email service. */ buildSender(): (params: { email: string; token: string; url: string; }) => Promise; /** * sendResetPassword callback for Better Auth emailAndPassword config. * Builds reset-password setup URL and delegates to email service. */ buildResetPasswordSender(): (params: { email: string; token: string; url: string; }) => Promise; /** * Requests magic link for signup/reset. * For reset, silently skips sending if user does not exist. */ requestMagicLink(email: unknown, intent: MagicLinkIntent): Promise; private buildCallbackUrl; private buildPreConfirmLink; private extractIntent; private logMagicLinkAttempt; } export {}; //# sourceMappingURL=magic-link-service.d.ts.map