Skip to content

Commit

Permalink
Remove TODO; Add serde_jcs::to_string unwrap handling in generate
Browse files Browse the repository at this point in the history
Signed-off-by: Tiago Nascimento <[email protected]>
  • Loading branch information
theosirian committed Oct 14, 2022
1 parent 6200d0e commit 4b96075
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions did-jwk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 4b96075

Please sign in to comment.