1
- // Copyright 2020-2023 IOTA Stiftung
1
+ // Copyright 2020-2024 IOTA Stiftung
2
2
// SPDX-License-Identifier: Apache-2.0
3
3
4
- use std:: collections:: BTreeMap ;
5
- use std:: time:: SystemTime ;
6
-
7
- use itertools:: Itertools ;
8
- use serde_json:: Value ;
9
-
10
4
use crate :: Hasher ;
5
+ use itertools:: Itertools ;
11
6
use serde:: Deserialize ;
12
7
use serde:: Serialize ;
8
+ use serde_json:: Value ;
9
+ use std:: collections:: BTreeMap ;
13
10
14
11
/// Claims set for key binding JWT.
15
12
#[ derive( Clone , Debug , Default , PartialEq , Eq , Deserialize , Serialize ) ]
@@ -26,27 +23,10 @@ impl KeyBindingJwtClaims {
26
23
pub const KB_JWT_HEADER_TYP : & ' static str = " kb+jwt" ;
27
24
28
25
/// 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 {
41
27
let disclosures = disclosures. iter ( ) . join ( "~" ) ;
42
28
let sd_jwt = format ! ( "{}~{}~" , jwt, disclosures) ;
43
29
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
- ) ;
50
30
Self {
51
31
iat,
52
32
aud,
0 commit comments