1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//! Defines data models used in JWT encoding and decoding processes.
//!
//! This module contains serializable structures for JWT claims and any additional metadata
//! that may be embedded into a token payload (e.g., user roles, custom fields).
use HashMap;
use ;
use Value;
/// Represents the payload (claims) of a JSON Web Token (JWT).
///
/// This struct contains standard JWT claims such as `sub` (subject) and `exp` (expiration time),
/// along with a flexible map for any additional custom claims via `extra`.
///
/// The `extra` field is flattened during serialization and deserialization,
/// allowing arbitrary key-value pairs to be included at the top level of the JWT payload.
///
/// # Fields
/// * `sub` - Subject of the token, typically representing the user ID.
/// * `exp` - Expiration timestamp of the token, in seconds since Unix epoch.
/// * `extra` - A map for custom claims, allowing additional metadata to be added.
///
/// # Example
/// ```
/// use std::collections::HashMap;
/// use serde_json::json;
/// use lib_service_jwt::model::Claims;
///
/// let mut extra = HashMap::new();
/// extra.insert("role".to_string(), json!("admin"));
///
/// let claims = Claims {
/// sub: "user123".to_string(),
/// exp: 1_720_000_000,
/// extra,
/// };
/// ```