Skip to content

Commit

Permalink
move expiration date of self issued credential at the end of paramete…
Browse files Browse the repository at this point in the history
…r list (because its optional)
  • Loading branch information
S3bb1 committed Nov 27, 2023
1 parent 034f615 commit efa4e9c
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 13 deletions.
8 changes: 4 additions & 4 deletions src/api/vade_evan_api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1106,8 +1106,8 @@ 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)
/// * `issuer_did` - issuer did for self issued credential
/// * `exp_date` - expiration date, string, e.g. "1722-12-03T14:23:42.120Z" (or `None` if no expiration date is used)
///
/// # Returns
/// * credential as JSON serialized [`BbsCredential`](https://docs.rs/vade_evan_bbs/*/vade_evan_bbs/struct.BbsCredential.html)
Expand Down Expand Up @@ -1135,8 +1135,8 @@ impl VadeEvan {
/// .helper_create_self_issued_credential(
/// SCHEMA_DID,
/// CREDENTIAL_SUBJECT_STR,
/// None,
/// ISSUER_DID,
/// None,
/// )
/// .await?;
///
Expand All @@ -1152,12 +1152,12 @@ impl VadeEvan {
&mut self,
schema_did: &str,
credential_subject_str: &str,
exp_date: Option<&str>,
issuer_did: &str,
exp_date: Option<&str>,
) -> Result<String, VadeEvanError> {
let mut credential = Credential::new(self)?;
credential
.create_self_issued_credential(schema_did, credential_subject_str, exp_date, issuer_did)
.create_self_issued_credential(schema_did, credential_subject_str, issuer_did, exp_date)
.await
.map_err(|err| err.into())
}
Expand Down
4 changes: 2 additions & 2 deletions src/c_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -650,8 +650,8 @@ pub extern "C" fn execute_vade(
.helper_create_self_issued_credential(
arguments_vec.get(0).unwrap_or_else(|| &no_args),
arguments_vec.get(1).unwrap_or_else(|| &no_args),
arguments_vec.get(2).map(|v| v.as_str()),
arguments_vec.get(3).unwrap_or_else(|| &no_args),
arguments_vec.get(2).unwrap_or_else(|| &no_args),
arguments_vec.get(3).map(|v| v.as_str()),
)
.await
.map_err(stringify_vade_evan_error)
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/credential.rs
Original file line number Diff line number Diff line change
Expand Up @@ -382,17 +382,17 @@ 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)
/// * `issuer_did` - issuer did for self issued credential
/// * `exp_date` - expiration date, string, e.g. "1722-12-03T14:23:42.120Z" (or `None` if no expiration date is used)
///
/// # Returns
/// * credential as JSON serialized [`UnsignedBbsCredential`](https://docs.rs/vade_evan_bbs/*/vade_evan_bbs/struct.UnsignedBbsCredential.html)
pub async fn create_self_issued_credential(
&mut self,
schema_did: &str,
credential_subject_str: &str,
exp_date: Option<&str>,
issuer_did: &str,
exp_date: Option<&str>,
) -> Result<String, CredentialError> {
fail_if_not_a_did(schema_did, "schema_did")?;
fail_if_not_a_did(issuer_did, "issuer_did")?;
Expand Down Expand Up @@ -1089,7 +1089,7 @@ mod tests {
let mut credential = Credential::new(&mut vade_evan)?;

match credential
.create_self_issued_credential(schema_did, credential_subject_str, None, subject_id)
.create_self_issued_credential(schema_did, credential_subject_str, subject_id, None)
.await
{
Ok(issued_credential) => {
Expand Down
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -269,8 +269,8 @@ async fn main() -> Result<()> {
.helper_create_self_issued_credential(
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, "issuer_did", None),
get_optional_argument_value(sub_m, "exp_date"),
)
.await?
}
Expand Down Expand Up @@ -449,7 +449,8 @@ fn add_subcommand_helper<'a>(app: App<'a, 'a>) -> Result<App<'a, 'a>> {
.about("Revokes a given credential with vade and updates the revocation list credential.")
.arg(get_clap_argument("credential")?)
.arg(get_clap_argument("update_key")?)
.arg(get_clap_argument("private_key")?)
.arg(get_clap_argument("issuer_public_key_did")?)
.arg(get_clap_argument("issuer_proving_key")?)
);
} else {}
}
Expand Down
4 changes: 2 additions & 2 deletions src/wasm_lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ cfg_if::cfg_if! {
.helper_create_self_issued_credential(
&schema_did,
&credential_subject_str,
exp_date.as_deref(),
&issuer_did,
exp_date.as_deref(),
).await
.map_err(jsify_vade_evan_error)?)
}
Expand Down Expand Up @@ -800,8 +800,8 @@ pub async fn execute_vade(
helper_create_self_issued_credential(
payload.schema_did,
payload.credential_subject_str,
payload.exp_date,
payload.issuer_did,
payload.exp_date,
)
.await
}
Expand Down

0 comments on commit efa4e9c

Please sign in to comment.