Skip to content

Commit 1460931

Browse files
committed
remove optional iat for KB claims
1 parent db6670d commit 1460931

File tree

1 file changed

+5
-25
lines changed

1 file changed

+5
-25
lines changed

src/key_binding_jwt_claims.rs

Lines changed: 5 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
1-
// Copyright 2020-2023 IOTA Stiftung
1+
// Copyright 2020-2024 IOTA Stiftung
22
// SPDX-License-Identifier: Apache-2.0
33

4-
use std::collections::BTreeMap;
5-
use std::time::SystemTime;
6-
7-
use itertools::Itertools;
8-
use serde_json::Value;
9-
104
use crate::Hasher;
5+
use itertools::Itertools;
116
use serde::Deserialize;
127
use serde::Serialize;
8+
use serde_json::Value;
9+
use std::collections::BTreeMap;
1310

1411
/// Claims set for key binding JWT.
1512
#[derive(Clone, Debug, Default, PartialEq, Eq, Deserialize, Serialize)]
@@ -26,27 +23,10 @@ impl KeyBindingJwtClaims {
2623
pub const KB_JWT_HEADER_TYP: &'static str = " kb+jwt";
2724

2825
/// Creates a new [`KeyBindingJwtClaims`].
29-
/// When `issued_at` is left as None, it will automatically default to the current time.
30-
///
31-
/// # Panic
32-
/// When `issued_at` is set to `None` and the system returns time earlier than `SystemTime::UNIX_EPOCH`.
33-
pub fn new(
34-
hasher: &dyn Hasher,
35-
jwt: String,
36-
disclosures: Vec<String>,
37-
nonce: String,
38-
aud: String,
39-
issued_at: Option<i64>,
40-
) -> Self {
26+
pub fn new(hasher: &dyn Hasher, jwt: String, disclosures: Vec<String>, nonce: String, aud: String, iat: i64) -> Self {
4127
let disclosures = disclosures.iter().join("~");
4228
let sd_jwt = format!("{}~{}~", jwt, disclosures);
4329
let hash = hasher.encoded_digest(&sd_jwt);
44-
let iat = issued_at.unwrap_or(
45-
SystemTime::now()
46-
.duration_since(SystemTime::UNIX_EPOCH)
47-
.expect("system time error")
48-
.as_secs() as i64,
49-
);
5030
Self {
5131
iat,
5232
aud,

0 commit comments

Comments
 (0)