From 4b960753668cc296667fc96fdaa4e02292a98c1a Mon Sep 17 00:00:00 2001 From: Tiago Nascimento Date: Fri, 14 Oct 2022 12:50:46 -0300 Subject: [PATCH] Remove TODO; Add serde_jcs::to_string unwrap handling in generate Signed-off-by: Tiago Nascimento --- did-jwk/src/lib.rs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/did-jwk/src/lib.rs b/did-jwk/src/lib.rs index def5c1adb..3cc919016 100644 --- a/did-jwk/src/lib.rs +++ b/did-jwk/src/lib.rs @@ -39,7 +39,6 @@ impl DIDResolver for DIDJWK { let data = match multibase::Base::decode(&multibase::Base::Base64Url, method_specific_id) { Ok(data) => data, Err(_err) => { - // TODO: pass through these errors somehow return ( ResolutionMetadata { error: Some(ERROR_INVALID_DID.to_string()), @@ -131,7 +130,12 @@ impl DIDMethod for DIDJWK { _ => return None, }; let jwk = jwk.to_public(); - let jwk = serde_jcs::to_string(&jwk).unwrap(); + let jwk = if let Ok(jwk) = serde_jcs::to_string(&jwk) { + jwk + } else { + return None; + }; + let did = "did:jwk:".to_string() + &multibase::encode(multibase::Base::Base64Url, &jwk)[1..]; Some(did)