Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use array as preferred for credential types #628

Merged
merged 5 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading