From 034f615a11b7de13bf7504dc36871aee8bbe904c Mon Sep 17 00:00:00 2001 From: S3bb1 <763247+S3bb1@users.noreply.github.com> Date: Mon, 27 Nov 2023 07:19:45 +0100 Subject: [PATCH] change parameter name from subject_did to issuer_did in self issued credential helper --- src/api/vade_evan_api.rs | 15 +++++---------- src/helpers/credential.rs | 24 ++++++++---------------- src/main.rs | 4 ++-- src/wasm_lib.rs | 8 ++++---- 4 files changed, 19 insertions(+), 32 deletions(-) diff --git a/src/api/vade_evan_api.rs b/src/api/vade_evan_api.rs index ca0a943..9c6c655 100644 --- a/src/api/vade_evan_api.rs +++ b/src/api/vade_evan_api.rs @@ -1107,7 +1107,7 @@ impl VadeEvan { /// * `schema_did` - schema to create the credential /// * `credential_subject_str` - JSON string of CredentialSubject structure /// * `exp_date` - expiration date, string, e.g. "1722-12-03T14:23:42.120Z" (or `None` if no expiration date is used) - /// * `subject_did` - subject did for self issued credential + /// * `issuer_did` - issuer did for self issued credential /// /// # Returns /// * credential as JSON serialized [`BbsCredential`](https://docs.rs/vade_evan_bbs/*/vade_evan_bbs/struct.BbsCredential.html) @@ -1127,7 +1127,7 @@ impl VadeEvan { /// "email":"value@x.com" /// } /// }"#; - /// const SUBJECT_DID: &str = "did:evan:EiAee4ixDnSP0eWyp0YFV7Wt9yrZ3w841FNuv9NSLFSCVA"; + /// const ISSUER_DID: &str = "did:evan:EiAee4ixDnSP0eWyp0YFV7Wt9yrZ3w841FNuv9NSLFSCVA"; /// /// async fn example() -> Result<()> { /// let mut vade_evan = VadeEvan::new(VadeEvanConfig { target: DEFAULT_TARGET, signer: DEFAULT_SIGNER })?; @@ -1136,7 +1136,7 @@ impl VadeEvan { /// SCHEMA_DID, /// CREDENTIAL_SUBJECT_STR, /// None, - /// SUBJECT_DID, + /// ISSUER_DID, /// ) /// .await?; /// @@ -1153,16 +1153,11 @@ impl VadeEvan { schema_did: &str, credential_subject_str: &str, exp_date: Option<&str>, - subject_did: &str, + issuer_did: &str, ) -> Result { let mut credential = Credential::new(self)?; credential - .create_self_issued_credential( - schema_did, - credential_subject_str, - exp_date, - subject_did, - ) + .create_self_issued_credential(schema_did, credential_subject_str, exp_date, issuer_did) .await .map_err(|err| err.into()) } diff --git a/src/helpers/credential.rs b/src/helpers/credential.rs index 5f0e9d2..e7b0203 100644 --- a/src/helpers/credential.rs +++ b/src/helpers/credential.rs @@ -8,24 +8,16 @@ use super::shared::{check_for_optional_empty_params, convert_to_nquads, is_did, use bbs::{ prelude::{DeterministicPublicKey, PublicKey}, signature::Signature, - HashElem, - SignatureMessage, + HashElem, SignatureMessage, }; use flate2::read::GzDecoder; use serde::de::DeserializeOwned; use serde_json::{value::Value, Map}; use thiserror::Error; use vade_evan_bbs::{ - BbsCredential, - CredentialDraftOptions, - CredentialSchema, - CredentialStatus, - CredentialSubject, - LdProofVcDetailOptionsCredentialStatusType, - OfferCredentialPayload, - RevocationListCredential, - RevocationListProofKeys, - RevokeCredentialPayload, + BbsCredential, CredentialDraftOptions, CredentialSchema, CredentialStatus, CredentialSubject, + LdProofVcDetailOptionsCredentialStatusType, OfferCredentialPayload, RevocationListCredential, + RevocationListProofKeys, RevokeCredentialPayload, }; #[derive(Error, Debug)] @@ -391,7 +383,7 @@ impl<'a> Credential<'a> { /// * `schema_did` - schema to create the credential /// * `credential_subject_str` - JSON string of CredentialSubject structure /// * `exp_date` - expiration date, string, e.g. "1722-12-03T14:23:42.120Z" (or `None` if no expiration date is used) - /// * `subject_did` - subject did for self issued credential + /// * `issuer_did` - issuer did for self issued credential /// /// # Returns /// * credential as JSON serialized [`UnsignedBbsCredential`](https://docs.rs/vade_evan_bbs/*/vade_evan_bbs/struct.UnsignedBbsCredential.html) @@ -400,10 +392,10 @@ impl<'a> Credential<'a> { schema_did: &str, credential_subject_str: &str, exp_date: Option<&str>, - subject_did: &str, + issuer_did: &str, ) -> Result { fail_if_not_a_did(schema_did, "schema_did")?; - fail_if_not_a_did(subject_did, "subject_did")?; + fail_if_not_a_did(issuer_did, "issuer_did")?; let exp_date = check_for_optional_empty_params(exp_date); let credential_subject: CredentialSubject = serde_json::from_str(credential_subject_str)?; @@ -417,7 +409,7 @@ impl<'a> Credential<'a> { let schema: CredentialSchema = self.get_did_document(schema_did).await?; let draft_credential = schema.to_draft_credential(CredentialDraftOptions { - issuer_did: subject_did.to_owned(), + issuer_did: issuer_did.to_owned(), id: None, issuance_date: None, valid_until, diff --git a/src/main.rs b/src/main.rs index 192a4a0..788c49d 100644 --- a/src/main.rs +++ b/src/main.rs @@ -270,7 +270,7 @@ async fn main() -> Result<()> { get_argument_value(sub_m, "schema_did", None), get_argument_value(sub_m, "credential_subject", None), get_optional_argument_value(sub_m, "exp_date"), - get_argument_value(sub_m, "subject_did", None), + get_argument_value(sub_m, "issuer_did", None), ) .await? } @@ -462,7 +462,7 @@ fn add_subcommand_helper<'a>(app: App<'a, 'a>) -> Result> { .arg(get_clap_argument("schema_did")?) .arg(get_clap_argument("credential_subject")?) .arg(get_clap_argument("exp_date")?) - .arg(get_clap_argument("subject_did")?) + .arg(get_clap_argument("issuer_did")?) ); } else {} } diff --git a/src/wasm_lib.rs b/src/wasm_lib.rs index 1e573d6..1f7110b 100644 --- a/src/wasm_lib.rs +++ b/src/wasm_lib.rs @@ -144,7 +144,7 @@ struct HelperCreateSelfIssuedCredentialPayload { pub schema_did: String, pub credential_subject_str: String, pub exp_date: Option, - pub subject_did: String, + pub issuer_did: String, } #[derive(Serialize, Deserialize)] @@ -433,7 +433,7 @@ cfg_if::cfg_if! { schema_did: String, credential_subject_str: String, exp_date: Option, - subject_did: String, + issuer_did: String, ) -> Result { let mut vade_evan = get_vade_evan(None).map_err(jsify_generic_error)?; Ok(vade_evan @@ -441,7 +441,7 @@ cfg_if::cfg_if! { &schema_did, &credential_subject_str, exp_date.as_deref(), - &subject_did, + &issuer_did, ).await .map_err(jsify_vade_evan_error)?) } @@ -801,7 +801,7 @@ pub async fn execute_vade( payload.schema_did, payload.credential_subject_str, payload.exp_date, - payload.subject_did, + payload.issuer_did, ) .await }