Skip to content
This repository has been archived by the owner on Sep 9, 2024. It is now read-only.

Commit

Permalink
Fix invocation expiry time (#147)
Browse files Browse the repository at this point in the history
* fix invocation expiry time
  • Loading branch information
chunningham authored Jul 5, 2023
1 parent b9cfc33 commit ec3a862
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions sdk/src/session.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use kepler_lib::{
use serde::{Deserialize, Serialize};
use serde_with::{serde_as, DisplayFromStr};
use std::collections::HashMap;
use time::OffsetDateTime;
use time::{ext::NumericalDuration, Duration, OffsetDateTime};

#[serde_as]
#[derive(Deserialize, Clone)]
Expand Down Expand Up @@ -138,13 +138,18 @@ impl Session {
let target = self
.orbit_id
.to_resource(Some(service), Some(path), Some(action));
let now = OffsetDateTime::now_utc();
let nanos = now.nanosecond();
let unix = now.unix_timestamp();
// 60 seconds in the future
let exp = (unix.seconds() + Duration::nanoseconds(nanos.into()) + Duration::MINUTE)
.as_seconds_f64();
make_invocation(
target,
self.delegation_cid,
&self.jwk,
self.verification_method,
// 60 seconds in the future
(OffsetDateTime::now_utc().nanosecond() as f64 / 1e+9_f64) + 60.0,
exp,
None,
None,
)
Expand Down
2 changes: 1 addition & 1 deletion src/kv/store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ impl<B> Store<B> {
}

#[instrument(name = "kv::list", skip_all)]
pub async fn list(&self) -> impl Iterator<Item = Result<Vec<u8>>> + '_ {
pub async fn list(&self) -> impl Iterator<Item = Result<Vec<u8>>> {
let elements = match self.index.elements().await {
Ok(e) => e,
Err(e) => return vec![Err(e)].into_iter(),
Expand Down

0 comments on commit ec3a862

Please sign in to comment.