use serde::{Deserialize, Serialize};
use crate::{
auth::jws::{GrantId, PopNonce},
crypto::PublicKey,
};
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct PopProofClaims {
pub aud: PublicKey,
pub gid: GrantId,
pub nonce: PopNonce,
pub iat: u64,
}
#[cfg(test)]
mod tests {
use crate::{
auth::jws::{GrantId, PopNonce},
crypto::Keypair,
};
use super::*;
#[test]
fn pop_proof_claims_serde_roundtrip() {
let homeserver_kp = Keypair::random();
let claims = PopProofClaims {
aud: homeserver_kp.public_key(),
gid: GrantId::generate(),
nonce: PopNonce::generate(),
iat: 1_700_000_000,
};
let json = serde_json::to_string(&claims).unwrap();
let parsed: PopProofClaims = serde_json::from_str(&json).unwrap();
assert_eq!(claims, parsed);
}
}