Capability first · transport second

TimeGuard.js

Persists and evaluates clock rollback and grace-period state.

SDK 0.5.18Runtime 0.8.12Protocol arcane/1
On this page

Overview

Persists and evaluates clock rollback and grace-period state.

  • Artifact
    TimeGuard.js · esm
  • Classification
    public first party
  • Availability
    Browser / native WebView
  • Normalization
    Time decisions normalized; storage lifecycle mixed.

Import and lifecycle

JavaScript
import timeGuard from '/arcane/modules/TimeGuard.js';

Browser-only import loads DBOPFS/User, attaches user-entity-loaded, and may install window.timeguard when User is ready. Construction reads window.user times; setters mutate window.user fields. checkGracePeriod() logs elapsed milliseconds.

Application-facing behavior: default TimeGuard; installs window.timeguard, emits time-guard-ready; clock methods.

Protocol and host implementation

User + DBOPFS This detail does not widen the application-facing API or grant authority.

Exports, signatures, parameters, and results

BindingFormDeclaration or signatureParameter syntax
defaultdefault · classclass TimeGuard
MemberKindExact public declarationParameter syntax
TimeGuard.constructorconstructorconstructor()
TimeGuard.readyfieldready=false;
TimeGuard.setStoredTimemethodsetStoredTime(time=0)time=0
TimeGuard.setLastSuccessfulCheckTimemethodsetLastSuccessfulCheckTime(time=0)time=0
TimeGuard.checkClockRollbackmethodcheckClockRollback()
TimeGuard.checkGracePeriodmethodcheckGracePeriod()
TimeGuard.PUBLISH_TIME_GUARD_READYmethod[PUBLISH_TIME_GUARD_READY]()
TimeGuard.disposemethoddispose()
TimeGuard.destroymethoddestroy()

Parameter meanings and results

new TimeGuard() returns existing window.timeguard when present; setStoredTime(ms), setLastSuccessfulCheckTime(ms), checkClockRollback(), and checkGracePeriod() return true or throw. Policy uses a six-hour rollback tolerance and 17-day grace.

Events, side effects, and errors

Source-literal CustomEvent dispatches

No source-literal CustomEvent dispatch is part of this artifact.

Lifecycle and event flow

  • Consumes user-entity-loaded.
  • Dispatches time-guard-ready with {db:window.timeguard}.

Direct coded failures

This artifact directly assigns no stable coded failure.

Exported Error subclasses

This artifact exports no Error subclass.

Documented failure behavior

  • Uncoded Error for missing/non-number time, backward successful-check time, rollback beyond six hours, or expired/invalid grace.
  • Browser/storage/User lifecycle errors can propagate.

Availability and capabilities

Browser / native WebView. Time decisions normalized; storage lifecycle mixed.

No direct Core RPC; uses browser/native-WebView User and DBOPFS lifecycle.

Contract example

JavaScript
await import('/arcane/modules/TimeGuard.js');

const guard = window.timeguard?.ready
    ? window.timeguard
    : await new Promise(resolve => window.addEventListener(
        'time-guard-ready',
        event => resolve(event.detail.db),
        {once:true}
    ));
console.log(guard.checkClockRollback());

No direct Core call is claimed for this artifact. Any injected provider or consuming module retains its own documented authority.