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

vp token from JsonPresentation v2 syntax #41

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
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ reqwest = { version = "0.12.5", features = ["rustls-tls"] }
serde = "1.0.188"
serde_json = "1.0.107"
serde_urlencoded = "0.7.1"
ssi = { version = "0.10", features = ["secp256r1"] }
ssi = { version = "0.10.1", features = ["secp256r1"] }
tokio = "1.32.0"
tracing = "0.1.37"
url = { version = "2.4.1", features = ["serde"] }
Expand Down
22 changes: 21 additions & 1 deletion src/core/response/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,13 @@ use crate::core::object::TypedParameter;
use anyhow::Error;
use serde::{Deserialize, Serialize};
use serde_json::Value as Json;
use ssi::{claims::vc, one_or_many::OneOrManyRef, prelude::AnyJsonPresentation, OneOrMany};
use ssi::{
claims::vc::{self, v2::SpecializedJsonCredential},
json_ld::syntax::Object,
one_or_many::OneOrManyRef,
prelude::AnyJsonPresentation,
OneOrMany,
};

#[derive(Debug, Clone)]
pub struct IdToken(pub String);
Expand Down Expand Up @@ -187,6 +193,20 @@ impl From<vc::v2::syntax::JsonPresentation> for VpTokenItem {
}
}

impl From<vc::v2::syntax::JsonPresentation<SpecializedJsonCredential<Object>>> for VpTokenItem {
fn from(value: vc::v2::syntax::JsonPresentation<SpecializedJsonCredential<Object>>) -> Self {
let serde_json::Value::Object(obj) = serde_json::to_value(value)
// SAFETY: by definition a VCDM2.0 presentation is a JSON object.
.unwrap()
else {
// SAFETY: by definition a VCDM2.0 presentation is a JSON object.
unreachable!()
};

Self::JsonObject(obj)
}
}

impl From<AnyJsonPresentation> for VpTokenItem {
fn from(value: AnyJsonPresentation) -> Self {
let serde_json::Value::Object(obj) = serde_json::to_value(value)
Expand Down
Loading