Closed
Description
fn get_current_timestamp() -> u64
uses SystemTime::now()
to get the current unix timestamp. Unfortunately, SystemTime
functions panic on wasm32-unknown-unknown
.
There are a couple of approaches to fix this:
- Switch to
chrono
for getting the timestamppub fn get_current_timestamp() -> u64 { chrono::Utc::now().timestamp() as u64 }
- In
Validation
, allow the user to supply a timestamp/// Supply a custom timestamp for checking `exp` and `nbf` claims. /// If `None`, will use `SystemTime::now()`. /// /// Defaults to `None`. pub current_timestamp: Option<u64>,
As a long-term solution, I prefer option 2 as it adds no cost, doesn't inflate the dependency tree, and allows for better customization.
Metadata
Metadata
Assignees
Labels
No labels