import { Email } from '@convex-dev/auth/providers/Email';
import { Resend as ResendAPI } from 'resend';
import { alphabet, generateRandomString } from 'oslo/crypto';
type Locale = 'en' | 'ko';
const emailTemplates: Record<Locale, { subject: string; text: (token: string) => string }> = {
en: { subject: 'Verify your email', text: (token) => `Code: ${token}` },
ko: { subject: '이메일 인증', text: (token) => `코드: ${token}` },
};
export const ResendOTP = Email({
id: 'resend-otp',
apiKey: process.env.AUTH_RESEND_KEY,
async generateVerificationToken() { return generateRandomString(8, alphabet('0-9')); },
async sendVerificationRequest({ identifier: email, provider, token }) {
const template = emailTemplates['en']; // Hardcoded, no locale support
const resend = new ResendAPI(provider.apiKey);
await resend.emails.send({ from: 'Auth <onboarding@resend.dev>', to: [email], subject: template.subject, text: template.text(token) });
},
});
import { Email } from '@convex-dev/auth/providers/Email';
import { Resend as ResendAPI } from 'resend';
import { alphabet, generateRandomString } from 'oslo/crypto';
type Locale = 'en' | 'ko';
const emailTemplates: Record<Locale, { subject: string; text: (token: string) => string }> = {
en: { subject: 'Verify your email', text: (token) => `Code: ${token}` },
ko: { subject: '이메일 인증', text: (token) => `코드: ${token}` },
};
export const ResendOTP = Email({
id: 'resend-otp',
apiKey: process.env.AUTH_RESEND_KEY,
async generateVerificationToken() { return generateRandomString(8, alphabet('0-9')); },
async sendVerificationRequest({ identifier: email, provider, token }) {
const template = emailTemplates['en']; // Hardcoded, no locale support
const resend = new ResendAPI(provider.apiKey);
await resend.emails.send({ from: 'Auth <onboarding@resend.dev>', to: [email], subject: template.subject, text: template.text(token) });
},
});