diff --git a/oid4vc-core/src/jwt.rs b/oid4vc-core/src/jwt.rs index c0c2c640..20cd1e2f 100644 --- a/oid4vc-core/src/jwt.rs +++ b/oid4vc-core/src/jwt.rs @@ -50,20 +50,21 @@ where Ok(jsonwebtoken::decode::(jwt, &key, &validation)?.claims) } -pub fn encode(signer: Arc, header: Header, claims: C, subject_syntax_type: &str) -> Result +pub async fn encode(signer: Arc, header: Header, claims: C, subject_syntax_type: &str) -> Result where C: Serialize, S: Sign + ?Sized, { let kid = signer .key_id(subject_syntax_type) + .await .ok_or(anyhow!("No key identifier found."))?; let jwt = JsonWebToken::new(header, claims).kid(kid); let message = [base64_url_encode(&jwt.header)?, base64_url_encode(&jwt.payload)?].join("."); - let proof_value = signer.sign(&message, subject_syntax_type)?; + let proof_value = signer.sign(&message, subject_syntax_type).await?; let signature = base64_url::encode(proof_value.as_slice()); let message = [message, signature].join("."); Ok(message) @@ -97,7 +98,9 @@ mod tests { "nonce": "nonce", }); let subject = TestSubject::new("did:test:123".to_string(), "key_id".to_string()).unwrap(); - let encoded = encode(Arc::new(subject), Header::new(Algorithm::EdDSA), claims, "did:test").unwrap(); + let encoded = encode(Arc::new(subject), Header::new(Algorithm::EdDSA), claims, "did:test") + .await + .unwrap(); let verifier = MockVerifier::new(); let (kid, algorithm) = extract_header(&encoded).unwrap();