Skip to content

Commit

Permalink
vp token from JsonPresentation v2 syntax (#41)
Browse files Browse the repository at this point in the history
* Add temporary support for unencoded JWT authorization requests

* Remove unnecessary comment

* Start implementation for VpTokenItem From method for specific JsonPresentation

Signed-off-by: Ryan Tate <[email protected]>
Co-Authored-By: Joey Silberman <[email protected]>

* use ssi 0.10.1 release

Signed-off-by: Ryan Tate <[email protected]>

---------

Signed-off-by: Ryan Tate <[email protected]>
Co-authored-by: Joey Silberman <[email protected]>
Co-authored-by: Ryan Tate <[email protected]>
  • Loading branch information
3 people authored Nov 20, 2024
1 parent d910fe9 commit 9c71c21
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
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

0 comments on commit 9c71c21

Please sign in to comment.