Add SMS OTP, harden auth, and fix order/checkout server bugs.
Ship 4-digit OTP with rate-limit attempts, Tehran-safe expiry/rass math, larger JSON body limit for check images, and safer order pricing/status guards. Include rebuilt dist for prebuilt deploy. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Vendored
+5
-10
@@ -1,11 +1,7 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.calculateCheckRass = calculateCheckRass;
|
||||
function startOfDay(date) {
|
||||
const d = new Date(date);
|
||||
d.setHours(0, 0, 0, 0);
|
||||
return d;
|
||||
}
|
||||
const tehran_time_1 = require("./tehran-time");
|
||||
function calculateCheckRass(checks, baseDate = new Date()) {
|
||||
if (checks.length === 0) {
|
||||
return {
|
||||
@@ -17,20 +13,19 @@ function calculateCheckRass(checks, baseDate = new Date()) {
|
||||
rassDate: null,
|
||||
};
|
||||
}
|
||||
const base = startOfDay(baseDate);
|
||||
const base = (0, tehran_time_1.tehranCalendarDay)(baseDate);
|
||||
let totalAmount = 0;
|
||||
let weightedDays = 0;
|
||||
const dueDates = [];
|
||||
for (const check of checks) {
|
||||
const due = startOfDay(new Date(check.dueDate));
|
||||
const due = (0, tehran_time_1.calendarDayOf)(check.dueDate);
|
||||
dueDates.push(due);
|
||||
const days = Math.max(0, Math.round((due.getTime() - base.getTime()) / (1000 * 60 * 60 * 24)));
|
||||
const days = Math.max(0, (0, tehran_time_1.diffInDays)(base, due));
|
||||
totalAmount += check.amount;
|
||||
weightedDays += check.amount * days;
|
||||
}
|
||||
const rassDays = totalAmount > 0 ? Math.round(weightedDays / totalAmount) : 0;
|
||||
const rassDate = new Date(base);
|
||||
rassDate.setDate(rassDate.getDate() + rassDays);
|
||||
const rassDate = (0, tehran_time_1.addDays)(base, rassDays);
|
||||
dueDates.sort((a, b) => a.getTime() - b.getTime());
|
||||
return {
|
||||
checkCount: checks.length,
|
||||
|
||||
Reference in New Issue
Block a user