@@ -2,6 +2,8 @@ import { normalizeProviderId } from "@openclaw/model-catalog-core/provider-id";
22import type { OpenClawConfig } from "../../config/types.openclaw.js" ;
33import { createSubsystemLogger } from "../../logging/subsystem.js" ;
44import {
5+ asDateTimestampMs ,
6+ isFutureDateTimestampMs ,
57 positiveSecondsToSafeMilliseconds ,
68 resolveExpiresAtMsFromEpochSeconds ,
79} from "../../shared/number-coercion.js" ;
@@ -812,8 +814,7 @@ export async function markAuthProfileBlockedUntil(params: {
812814 if (
813815 ! profile ||
814816 isAuthCooldownBypassedForProvider ( profile . provider ) ||
815- ! Number . isFinite ( blockedUntil ) ||
816- blockedUntil <= Date . now ( )
817+ ! isFutureDateTimestampMs ( blockedUntil )
817818 ) {
818819 return ;
819820 }
@@ -828,16 +829,16 @@ export async function markAuthProfileBlockedUntil(params: {
828829 if ( ! profile || isAuthCooldownBypassedForProvider ( profile . provider ) ) {
829830 return false ;
830831 }
831- const now = Date . now ( ) ;
832+ const now = asDateTimestampMs ( Date . now ( ) ) ;
833+ if ( now === undefined ) {
834+ return false ;
835+ }
832836 previousStats = freshStore . usageStats ?. [ profileId ] ;
833837 updateTime = now ;
834838 const existingBlockedUntil = previousStats ?. blockedUntil ;
835- const activeBlockedUntil =
836- typeof existingBlockedUntil === "number" &&
837- Number . isFinite ( existingBlockedUntil ) &&
838- existingBlockedUntil > now
839- ? existingBlockedUntil
840- : 0 ;
839+ const activeBlockedUntil = isFutureDateTimestampMs ( existingBlockedUntil , { nowMs : now } )
840+ ? existingBlockedUntil
841+ : 0 ;
841842 nextStats = {
842843 ...previousStats ,
843844 blockedUntil : Math . max ( activeBlockedUntil , blockedUntil ) ,
@@ -876,15 +877,15 @@ export async function markAuthProfileBlockedUntil(params: {
876877 return ;
877878 }
878879
879- const now = Date . now ( ) ;
880+ const now = asDateTimestampMs ( Date . now ( ) ) ;
881+ if ( now === undefined ) {
882+ return ;
883+ }
880884 previousStats = store . usageStats ?. [ profileId ] ;
881885 const existingBlockedUntil = previousStats ?. blockedUntil ;
882- const activeBlockedUntil =
883- typeof existingBlockedUntil === "number" &&
884- Number . isFinite ( existingBlockedUntil ) &&
885- existingBlockedUntil > now
886- ? existingBlockedUntil
887- : 0 ;
886+ const activeBlockedUntil = isFutureDateTimestampMs ( existingBlockedUntil , { nowMs : now } )
887+ ? existingBlockedUntil
888+ : 0 ;
888889 nextStats = {
889890 ...previousStats ,
890891 blockedUntil : Math . max ( activeBlockedUntil , blockedUntil ) ,
0 commit comments