MCPcopy Create free account
hub / github.com/Commit-Boost/commit-boost-client / create_jwt

Function create_jwt

crates/common/src/utils.rs:347–358  ·  view source on GitHub ↗

Create a JWT for the given module id with expiration

(module_id: &ModuleId, secret: &str)

Source from the content-addressed store, hash-verified

345
346/// Create a JWT for the given module id with expiration
347pub fn create_jwt(module_id: &ModuleId, secret: &str) -> eyre::Result<Jwt> {
348 jsonwebtoken::encode(
349 &jsonwebtoken::Header::default(),
350 &JwtClaims {
351 module: module_id.to_string(),
352 exp: jsonwebtoken::get_current_timestamp() + SIGNER_JWT_EXPIRATION,
353 },
354 &jsonwebtoken::EncodingKey::from_secret(secret.as_ref()),
355 )
356 .map_err(Into::into)
357 .map(Jwt::from)
358}
359
360/// Decode a JWT and return the module id. IMPORTANT: This function does not
361/// validate the JWT, it only obtains the module id from the claims.

Callers 6

test_jwt_validationFunction · 0.85
newMethod · 0.85
refresh_jwtMethod · 0.85

Calls

no outgoing calls

Tested by 4

test_jwt_validationFunction · 0.68