MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / extract_exp_from_token

Function extract_exp_from_token

nodedb/src/control/server/sync/security.rs:112–120  ·  view source on GitHub ↗

Extract the `exp` claim from a JWT without full validation.

(token: &str)

Source from the content-addressed store, hash-verified

110
111/// Extract the `exp` claim from a JWT without full validation.
112fn extract_exp_from_token(token: &str) -> Option<u64> {
113 let parts: Vec<&str> = token.split('.').collect();
114 if parts.len() != 3 {
115 return None;
116 }
117 let payload = base64_url_decode(parts[1])?;
118 let claims: serde_json::Value = sonic_rs::from_slice(&payload).ok()?;
119 claims.get("exp")?.as_u64()
120}
121
122/// Reason a sync delta was silently rejected.
123#[derive(Debug, Clone)]

Callers 2

validate_upgrade_tokenFunction · 0.85

Calls 6

base64_url_decodeFunction · 0.85
collectMethod · 0.80
lenMethod · 0.45
okMethod · 0.45
as_u64Method · 0.45
getMethod · 0.45

Tested by

no test coverage detected