MCPcopy Create free account
hub / github.com/clockworklabs/SpacetimeDB / decode_encoded_token

Function decode_encoded_token

crates/client-api/src/auth.rs:295–310  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

293 // Make sure that when we encode TokenClaims, we can decode to get the expected identity.
294 #[tokio::test]
295 async fn decode_encoded_token() -> Result<(), anyhow::Error> {
296 let kp = JwtKeys::generate()?;
297
298 let claims = TokenClaims {
299 issuer: "localhost".into(),
300 subject: "test-subject".into(),
301 audience: ["spacetimedb".into()].into(),
302 extra: None,
303 };
304 let id = claims.id();
305 let (_, token) = claims.encode_and_sign(&kp.private)?;
306 let decoded = kp.public.validate_token(&token).await?;
307
308 assert_eq!(decoded.identity, id);
309 Ok(())
310 }
311
312 fn to_hashmap(value: serde_json::Value) -> HashMap<Box<str>, serde_json::Value> {
313 let mut map = HashMap::new();

Callers

nothing calls this directly

Calls 5

encode_and_signMethod · 0.80
generateFunction · 0.50
OkFunction · 0.50
idMethod · 0.45
validate_tokenMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…