import axios from 'axios'; import { appName, cloudServerUrl, serverAppId } from '../../../Utils.js'; const serverUrl = cloudServerUrl; const appId = serverAppId; const masterKey = process.env.MASTER_KEY; // Constants (adjust to your preference) export const OTP_LENGTH = 6; export const OTP_EXPIRES_MIN = 10; // OTP validity in minutes export const RESEND_COOLDOWN_SEC = 30; // Cooldown between OTP sends export const MAX_ATTEMPTS = 5; // Max allowed wrong attempts export function generateOtp(len = OTP_LENGTH) { // 6-digit numeric OTP (000000–999999, padded) const n = Math.floor(Math.random() * Math.pow(10, len)); return String(n).padStart(len, '0'); } export async function sendDeleteOtpEmail(extUser, otp) { const _extUser = extUser && JSON.parse(JSON.stringify(extUser)); const params = { extUserId: extUser.id, from: appName, recipient: extUser?.get('Email'), subject: 'OTP for Deletion account request', html: `
© ${new Date().getFullYear()} ${appName}. All rights reserved.
|