Skip to content

Commit

Permalink
use array as preferred for credential types (#628)
Browse files Browse the repository at this point in the history
* use array as preferred for credential types

Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Co-Authored-By: Joey Silberman <joey.silberman@spruceid.com>
Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>

* resolve failing cargo test (doctest)

Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>

* update readme

Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>

* fix eip resolve_vc_issue_verify unit test

Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>

* Update crates/claims/crates/vc/Cargo.toml

---------

Signed-off-by: Ryan Tate <ryan.tate@spruceid.com>
Co-authored-by: Joey Silberman <joey.silberman@spruceid.com>
  • Loading branch information
Ryanmtate and Joey-Silberman authored Dec 11, 2024
1 parent 8edeec1 commit 6e7b3b1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 9 deletions.
7 changes: 4 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,7 @@ yourself.
```rust
use static_iref::uri;
use serde::{Serialize, Deserialize};
use ssi::claims::vc::syntax::NonEmptyVec;
use ssi::prelude::*;

// Defines the shape of our custom claims.
Expand All @@ -183,10 +184,10 @@ let credential = ssi::claims::vc::v1::JsonCredential::<MyCredentialSubject>::new
Some(uri!("https://example.org/#CredentialId").to_owned()), // id
uri!("https://example.org/#Issuer").to_owned().into(), // issuer
DateTime::now(), // issuance date
vec![MyCredentialSubject {
NonEmptyVec::new(MyCredentialSubject {
name: "John Smith".to_owned(),
email: "john.smith@example.org".to_owned()
}]
})
);

// Create a random signing key, and turn its public part into a DID URL.
Expand Down Expand Up @@ -216,7 +217,7 @@ let vc = cryptosuite.sign(
ProofOptions::from_method(verification_method)
).await.expect("signature failed");
```

It is critical that custom claims can be interpreted as Linked-Data. In
the above example this is done by specifying a serialization URL for each
field of `MyCredentialSubject`. This can also be done by creating a custom
Expand Down
5 changes: 4 additions & 1 deletion crates/claims/crates/vc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ educe.workspace = true
base64.workspace = true
bitvec = "0.20"
flate2 = "1.0"
reqwest = { version = "0.11", default-features = false, features = ["json", "rustls-tls"] }
reqwest = { version = "0.11", default-features = false, features = [
"json",
"rustls-tls",
] }
ssi-verification-methods.workspace = true
ssi-dids-core.workspace = true
ssi-data-integrity.workspace = true
Expand Down
2 changes: 1 addition & 1 deletion crates/claims/crates/vc/src/v1/syntax/presentation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ impl RequiredType for PresentationType {
}

impl TypeSerializationPolicy for PresentationType {
const PREFER_ARRAY: bool = false;
const PREFER_ARRAY: bool = true;
}

pub type JsonPresentationTypes<T = ()> = Types<PresentationType, T>;
Expand Down
2 changes: 1 addition & 1 deletion crates/dids/methods/pkh/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1313,7 +1313,7 @@ mod tests {
],
"VerifiablePresentation": [
{ "name": "@context", "type": "string[]" },
{ "name": "type", "type": "string" },
{ "name": "type", "type": "string[]" },
{ "name": "holder", "type": "string" },
{ "name": "verifiableCredential", "type": "VerifiableCredential" },
{ "name": "proof", "type": "Proof" }
Expand Down
7 changes: 4 additions & 3 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@
//! # async fn main() {
//! use static_iref::uri;
//! use serde::{Serialize, Deserialize};
//! use ssi::claims::vc::syntax::NonEmptyVec;
//! use ssi::prelude::*;
//!
//! // Defines the shape of our custom claims.
Expand All @@ -187,10 +188,10 @@
//! Some(uri!("https://example.org/#CredentialId").to_owned()), // id
//! uri!("https://example.org/#Issuer").to_owned().into(), // issuer
//! DateTime::now(), // issuance date
//! vec![MyCredentialSubject {
//! NonEmptyVec::new(MyCredentialSubject {
//! name: "John Smith".to_owned(),
//! email: "john.smith@example.org".to_owned()
//! }]
//! })
//! );
//!
//! // Create a random signing key, and turn its public part into a DID URL.
Expand Down Expand Up @@ -221,7 +222,7 @@
//! ).await.expect("signature failed");
//! # }
//! ```
//!
//!
//! It is critical that custom claims can be interpreted as Linked-Data. In
//! the above example this is done by specifying a serialization URL for each
//! field of `MyCredentialSubject`. This can also be done by creating a custom
Expand Down

0 comments on commit 6e7b3b1

Please sign in to comment.