type DriftTolerance = [ number , number ] ; function verifyTime ( utcNotBefore , utcNotOnOrAfter , drift = [ 0 , 0 ] ) { const now = new Date ( ) ; if ( ! utcNotBefore && ! utcNotOnOrAfter ) { console . warn ( 'You intend to have time validation however the document doesn\'t include the valid range.' ) ; return true ; } let notBeforeLocal = null ; let notOnOrAfterLocal = null ; const [ notBeforeDrift , notOnOrAfterDrift ] = drift ; if ( utcNotBefore && ! utcNotOnOrAfter ) { notBeforeLocal = new Date ( utcNotBefore ) ; return + notBeforeLocal + notBeforeDrift <= + now ; } if ( ! utcNotBefore && utcNotOnOrAfter ) { notOnOrAfterLocal = new Date ( utcNotOnOrAfter ) ; return + now < + notOnOrAfterLocal + notOnOrAfterDrift ; } notBeforeLocal = new Date ( utcNotBefore ! ) ; notOnOrAfterLocal = new Date ( utcNotOnOrAfter ! ) ; return ( + notBeforeLocal + notBeforeDrift <= + now && + now < + notOnOrAfterLocal + notOnOrAfterDrift ) ; } export { verifyTime } ;