Skip to content

Commit

Permalink
Remove unnecessary Arc<T> type
Browse files Browse the repository at this point in the history
  • Loading branch information
KendallWeihe committed May 11, 2024
1 parent b0791f1 commit d707058
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
4 changes: 2 additions & 2 deletions crates/dids/src/method/jwk.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ impl Create<DidJwkCreateOptions> for DidJwk {
let key_alias = key_manager.generate_private_key(options.curve, Some("0".to_string()))?;
let public_key = key_manager.get_public_key(&key_alias)?;
let public_jwk = public_key.jwk()?;
let jwk_string = serde_json::to_string(public_jwk.as_ref()).map_err(|_| {
let jwk_string = serde_json::to_string(&public_jwk).map_err(|_| {
MethodError::DidCreationFailure("failed to serialize public jwk".to_string())
})?;
let spruce_jwk: SpruceJwk =
Expand All @@ -58,7 +58,7 @@ impl Create<DidJwkCreateOptions> for DidJwk {
id: verification_method_id.clone(),
r#type: "JsonWebKey".to_string(),
controller: uri.clone(),
public_key_jwk: public_jwk.as_ref().clone(),
public_key_jwk: public_jwk.clone(),
};

let document = Document {
Expand Down
7 changes: 5 additions & 2 deletions crates/jws/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,8 @@ mod tests {
&header,
&payload,
)
.unwrap() + "123";
.unwrap()
+ "123";

let result = CompactJws::verify(&compact_jws).await;

Expand Down Expand Up @@ -520,7 +521,9 @@ mod tests {
},
)
.expect("failed to create bearer did");
let invalid_key_id = invalid_bearer_did.document.verification_method[0].id.clone();
let invalid_key_id = invalid_bearer_did.document.verification_method[0]
.id
.clone();

let compact_jws = CompactJws::sign(
&invalid_bearer_did,
Expand Down
6 changes: 3 additions & 3 deletions crates/keys/src/key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ pub enum KeyError {

pub trait Key: Send + Sync {
fn alias(&self) -> Result<String, KeyError>;
fn jwk(&self) -> Result<Arc<Jwk>, KeyError>;
fn jwk(&self) -> Result<Jwk, KeyError>;
}

pub trait PublicKey: Key + Send + Sync {
Expand All @@ -42,8 +42,8 @@ impl Key for Jwk {
Ok(thumbprint)
}

fn jwk(&self) -> Result<Arc<Jwk>, KeyError> {
Ok(Arc::new(self.clone()))
fn jwk(&self) -> Result<Jwk, KeyError> {
Ok(self.clone())
}
}

Expand Down

0 comments on commit d707058

Please sign in to comment.