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

Fix the presentation submission in the oid4vp-rs e2e test. #8

Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
10611a8
wip: use ssi 0.8.1, debugging e2e test using did resolver
Ryanmtate Aug 8, 2024
7ea4c50
wip: use VerificationMethodDIDResolver for DIDClient constructor
Ryanmtate Aug 8, 2024
7b3ced0
remove unused imports
Ryanmtate Aug 8, 2024
4a77347
wip: debugging did resolver jwk not found in e2e flow
Ryanmtate Aug 9, 2024
48e152e
feat/improve-presentation-exchange-support-in-oid4vp-rs
Ryanmtate Aug 9, 2024
26e62f1
add getter methods for presentation definition member fields
Ryanmtate Aug 9, 2024
8c47808
fix broken links in documentation
Ryanmtate Aug 9, 2024
de5db7d
update presentation submission implementation
Ryanmtate Aug 10, 2024
24845c7
fix test cases. todo: update test cases to use newly created interfac…
Ryanmtate Aug 10, 2024
5036a69
update json schema validator to use anyhow result type
Ryanmtate Aug 10, 2024
ac8e904
merge presentation exchange updates
Ryanmtate Aug 11, 2024
6fe4d46
wip: use latest implementation changes, update tests
Ryanmtate Aug 12, 2024
6d29442
fix verification method did resolver tests
Ryanmtate Aug 12, 2024
e885a4c
wip: remove unused imports
Ryanmtate Aug 12, 2024
3996946
add ClaimFormat type
Ryanmtate Aug 12, 2024
4e841cc
add regex support for string pattern matching
Ryanmtate Aug 12, 2024
edcc8a2
revert uuid presentation definition id type to string
Ryanmtate Aug 12, 2024
23e589a
fix: ensure negation of regex pattern match for error
Ryanmtate Aug 12, 2024
1527933
add 'other' variante to claim format type
Ryanmtate Aug 12, 2024
8ed8828
remove commented out code
Ryanmtate Aug 12, 2024
97b3462
merge presentation exchange updates
Ryanmtate Aug 12, 2024
dcdde5c
use ssi sub-crates instead of main ssi dependency
Ryanmtate Aug 12, 2024
1a2af67
add jwt_vc_json and jwt_vp_json claim formats
Ryanmtate Aug 12, 2024
61043a9
wip: construct verifiable presentation for e2e test
Ryanmtate Aug 13, 2024
24497dd
wip: perform validation on presentation submission
Ryanmtate Aug 13, 2024
3423d13
ensure range exclusive values are checked; fix inclusive range values
Ryanmtate Aug 13, 2024
7bd0660
ensure enum values are parsed in alpha descending order
Ryanmtate Aug 13, 2024
ce60c03
wip: verify authorized response presentation submission
Ryanmtate Aug 14, 2024
cd22624
ensure json schema validator adheres to the specification
Ryanmtate Aug 14, 2024
26dda42
ensure json schema validator adheres to the specification
Ryanmtate Aug 14, 2024
d188434
add unit tests for schema validator
Ryanmtate Aug 14, 2024
89db3b2
use serde default value for constraints field if not found during des…
Ryanmtate Aug 14, 2024
0ec29b3
merge schema validator changes
Ryanmtate Aug 14, 2024
d478103
remove unused imports
Ryanmtate Aug 14, 2024
5e65c4e
Merge branch 'main' into fix/fix-the-presentation-submission-in-the-o…
Ryanmtate Aug 14, 2024
e276d6a
remove unsed imports in test files
Ryanmtate Aug 14, 2024
3d93a0e
update vp token
Ryanmtate Aug 14, 2024
0843f66
rebase with main
Ryanmtate Aug 14, 2024
b7d8083
resolve merge conflict; remove schema validator and replace with json…
Ryanmtate Aug 16, 2024
096d383
remove unused dependencies
Ryanmtate Aug 16, 2024
f82fa26
add rand crate and provide random nonce method using Rng trait
Ryanmtate Aug 20, 2024
b07b715
remove todos and update comments, use JWKResolver instead of Verifica…
Ryanmtate Aug 20, 2024
fcb4ed9
fix clippy warnings
Ryanmtate Aug 20, 2024
1398cad
verify jwt in validate_authorization_response presentation definition…
Ryanmtate Aug 20, 2024
be2bbed
Update tests/e2e.rs
Ryanmtate Aug 20, 2024
32a49b7
update descriptor map nested path in e2e example
Ryanmtate Aug 20, 2024
d050355
remove dependency patches
Ryanmtate Aug 20, 2024
4a0217b
add paths to example for input descriptor constraints field
Ryanmtate Aug 20, 2024
9997486
use top level json path for jwt_vp_json
Ryanmtate Aug 20, 2024
2a93750
Update src/verifier/client.rs
Ryanmtate Aug 20, 2024
f490b8b
rebase
Ryanmtate Aug 20, 2024
347259d
revert validation function async signature to use boxed pin future
Ryanmtate Aug 20, 2024
05d550e
add helper methods
Ryanmtate Aug 22, 2024
129d22c
debug: jwt claim signing does not include public key
Ryanmtate Aug 22, 2024
a3bf215
make request signer methods return a result
Ryanmtate Aug 22, 2024
7733f65
refactor presentation exchange file into smaller modules
Ryanmtate Aug 23, 2024
54c0f79
fix clippy warnings
Ryanmtate Aug 23, 2024
efd5773
Merge branch 'main' into fix/fix-the-presentation-submission-in-the-o…
Ryanmtate Aug 23, 2024
a7aed11
fix outcome error cause
Ryanmtate Aug 23, 2024
2e453ca
add credential format and add requested fields helper method to input…
Ryanmtate Aug 26, 2024
a3bfdcb
Update src/core/presentation_definition.rs
Ryanmtate Aug 27, 2024
7a337ae
Update src/core/presentation_definition.rs
Ryanmtate Aug 27, 2024
76e3a3a
wip: add notes on required fields parsing
Ryanmtate Aug 27, 2024
51e11e8
update vp token base64 encoding and check for multiple vp payloads
Ryanmtate Aug 28, 2024
65e1b11
move validation to auth response impl instead of presentation definit…
Ryanmtate Aug 28, 2024
d0c7439
remove feature gated non-optional deps
Ryanmtate Aug 28, 2024
033fd5e
remove cfg features
Ryanmtate Aug 28, 2024
d98d2a4
wip: handle groups in presentation definition, input descriptor tests
Ryanmtate Aug 28, 2024
915b922
remove cfg feature tags
Ryanmtate Aug 28, 2024
3d7b1f5
remove extraneous metadata helper methods; use UntypedObject for dere…
Ryanmtate Aug 28, 2024
e9b33df
add submission requirement check for presentation validation
Ryanmtate Aug 29, 2024
64f87eb
add validate method to vp token; ensure submission requirement all ru…
Ryanmtate Aug 29, 2024
d3dce7f
add vp token validate unencoded method. fix minor todos.
Ryanmtate Aug 29, 2024
458ff5f
Update Cargo.toml
Ryanmtate Sep 12, 2024
165b1c7
fix other claim format serde
Ryanmtate Sep 12, 2024
0e0f985
use Vec::is_empty versus Option::is_none for various serialization fi…
Ryanmtate Sep 13, 2024
b8e9141
revert to use of ClaimFormatMap to pass presentation defintion test s…
Ryanmtate Sep 13, 2024
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
19 changes: 13 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,27 +9,28 @@ repository = "https://github.com/spruceid/oidc4vp-rs/"
documentation = "https://docs.rs/oid4vp/"

[features]
default = []
reqwest = ["dep:reqwest"]
p256 = ["dep:p256"]
rand = ["dep:rand"]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unnecessary feature overhead, rand is already in the dependency tree through the ssi crates. And reqwest is too as of adding jsonschema, so we can remove that feature too. p256 should be optional, but with the ssi refactor it looks like that is always imported through ssi-dids, even with --no-default-features. I think that is a bug, but we can remove it as a feature for now.

Copy link
Contributor Author

@Ryanmtate Ryanmtate Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we want the ability to pass in a reference to an existing RNG? e.g.

impl Nonce {
    pub fn random(rng: &mut impl rand::Rng, len: u8) -> Self {
        use rand::distributions::Alphanumeric;

        Self((0..len).map(|_| rng.sample(Alphanumeric) as char).collect())
    }
}

I don't know if this is a common case where an RNG is already initialized and could be passed in.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't see p256 as a re-export from ssi-dids for 0.2.0: https://docs.rs/ssi-dids/latest/ssi_dids/#reexports

I also don't see rand as a re-export from jsonschema: https://docs.rs/jsonschema/latest/jsonschema/#reexports

How are these libraries used from dependencies, if they are not re-exported?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

$ cargo tree -i rand
rand v0.8.5
├── num-bigint-dig v0.8.4
│   └── rsa v0.6.1
│       └── ssi-jwk v0.2.1
...
$ cargo tree -i [email protected]
reqwest v0.12.5
└── jsonschema v0.18.0
$ cargo tree -i p256
p256 v0.13.2
├── did-method-key v0.2.2
│   [dev-dependencies]
│   └── oid4vp v0.1.0 (/Users/jacob/Documents/git/oidc4vp-rs)
│       [dev-dependencies]
│       └── oid4vp v0.1.0 (/Users/jacob/Documents/git/oidc4vp-rs) (*)
├── did-method-key v0.3.0
│   └── ssi-dids v0.2.0
...

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How are these libraries used from dependencies, if they are not re-exported?

We don't need to use the crates from those dependencies, there's just no point gating them behind features if they're already in the dependency tree.


[dependencies]
anyhow = "1.0.75"
async-trait = "0.1.73"
base64 = "0.21.4"
did-web = "0.2.2"
http = "1.1.0"
jsonpath_lib = "0.3.0"
jsonschema = "0.18.0"
p256 = { version = "0.13.2", features = ["jwk"], optional = true }
regex = "1.10.6"
rand = { version = "0.8.5", optional = true }
reqwest = { version = "0.12.5", features = ["rustls-tls"], optional = true }
serde = "1.0.188"
serde_cbor = "0.11.2"
serde_json = "1.0.107"
serde_qs = "0.12.0"
serde_urlencoded = "0.7.1"
ssi = "0.7"
thiserror = "1.0.49"
ssi-claims = "0.1.0"
ssi-dids = "0.2.0"
ssi-jwk = { version = "0.2.1", features = ["secp256r1"] }
ssi-verification-methods = "0.1.1"
tokio = "1.32.0"
tracing = "0.1.37"
url = { version = "2.4.1", features = ["serde"] }
Expand All @@ -46,3 +47,9 @@ uuid = { version = "1.2", features = ["v4", "serde", "js"] }

[target.'cfg(not(target_arch = "wasm32"))'.dependencies]
uuid = { version = "1.2", features = ["v4", "serde"] }

# For Development Purpose, patch the ssi* crates to use the local versions
# [patch.crates-io]
# ssi-claims = { path = "../ssi/crates/claims" }
# ssi-dids = { path = "../ssi/crates/dids" }
# ssi-jwk = { path = "../ssi/crates/jwk" }
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My preference is to keep this out of the Cargo.toml, as it makes assumptions about the developer's directory structure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you have another preference for patching libs? Or just remove the commented code from the Cargo.toml and let the developer add it as necessary?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep the latter.

39 changes: 37 additions & 2 deletions src/core/authorization_request/parameters.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::fmt;
use std::{fmt, ops::Deref};

use crate::core::{
object::{ParsingErrorContext, TypedParameter, UntypedObject},
Expand Down Expand Up @@ -193,7 +193,42 @@ impl TryFrom<Json> for ClientMetadataUri {
}

#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Nonce(pub String);
pub struct Nonce(String);

impl From<String> for Nonce {
fn from(value: String) -> Self {
Self(value)
}
}

impl From<&str> for Nonce {
fn from(value: &str) -> Self {
Self(value.to_string())
}
}

impl Deref for Nonce {
type Target = String;

fn deref(&self) -> &Self::Target {
&self.0
}
}

impl std::fmt::Display for Nonce {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
self.0.fmt(f)
}
}

impl Nonce {
#[cfg(feature = "rand")]
pub fn random(rng: &mut impl rand::Rng) -> Self {
use rand::distributions::Alphanumeric;

Self((0..16).map(|_| rng.sample(Alphanumeric) as char).collect())
}
}

impl TypedParameter for Nonce {
const KEY: &'static str = "nonce";
Expand Down
14 changes: 8 additions & 6 deletions src/core/authorization_request/verification/did.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,18 @@ use crate::core::{
use anyhow::{bail, Context, Result};
use base64::prelude::*;
use serde_json::{Map, Value as Json};
use ssi::did_resolve::{resolve_key, DIDResolver};

use ssi_jwk::JWKResolver;

/// Default implementation of request validation for `client_id_scheme` `did`.
pub async fn verify_with_resolver(
wallet_metadata: &WalletMetadata,
request_object: &AuthorizationRequestObject,
request_jwt: String,
trusted_dids: Option<&[String]>,
resolver: &dyn DIDResolver,
resolver: impl JWKResolver,
) -> Result<()> {
let (headers_b64, _, _) = ssi::jws::split_jws(&request_jwt)?;
let (headers_b64, _, _) = ssi_claims::jws::split_jws(&request_jwt)?;

let headers_json_bytes = BASE64_URL_SAFE_NO_PAD
.decode(headers_b64)
Expand Down Expand Up @@ -64,11 +65,12 @@ pub async fn verify_with_resolver(
}
}

let jwk = resolve_key(&kid, resolver)
let jwk = resolver
.fetch_public_jwk(Some(&kid))
.await
.context("unable to resolve verification method from 'kid' header")?;
.context("unable to resolve key from verification method")?;

let _: Json = ssi::jwt::decode_verify(&request_jwt, &jwk)
let _: Json = ssi_claims::jwt::decode_verify(&request_jwt, &jwk)
.context("request signature could not be verified")?;

Ok(())
Expand Down
7 changes: 4 additions & 3 deletions src/core/authorization_request/verification/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,10 @@ pub(crate) async fn verify_request<W: Wallet + ?Sized>(
wallet: &W,
jwt: String,
) -> Result<AuthorizationRequestObject> {
let request: AuthorizationRequestObject = ssi::jwt::decode_unverified::<UntypedObject>(&jwt)
.context("unable to decode Authorization Request Object JWT")?
.try_into()?;
let request: AuthorizationRequestObject =
ssi_claims::jwt::decode_unverified::<UntypedObject>(&jwt)
.context("unable to decode Authorization Request Object JWT")?
.try_into()?;

validate_request_against_metadata(wallet, &request).await?;

Expand Down
2 changes: 1 addition & 1 deletion src/core/authorization_request/verification/x509_san.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ pub fn validate<V: Verifier>(
trusted_roots: Option<&[Certificate]>,
) -> Result<()> {
let client_id = request_object.client_id().0.as_str();
let (headers_b64, body_b64, sig_b64) = ssi::jws::split_jws(&request_jwt)?;
let (headers_b64, body_b64, sig_b64) = ssi_claims::jws::split_jws(&request_jwt)?;

let headers_json_bytes = BASE64_URL_SAFE_NO_PAD
.decode(headers_b64)
Expand Down
29 changes: 19 additions & 10 deletions src/core/metadata/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ use std::ops::{Deref, DerefMut};
use anyhow::Error;
use parameters::wallet::{RequestObjectSigningAlgValuesSupported, ResponseTypesSupported};
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value as Json};
use ssi_jwk::Algorithm;

use crate::presentation_exchange::{ClaimFormatDesignation, ClaimFormatMap, ClaimFormatPayload};

use self::parameters::wallet::{AuthorizationEndpoint, VpFormatsSupported};

Expand Down Expand Up @@ -39,6 +41,11 @@ impl WalletMetadata {
&self.2
}

/// Returns whether the claim format is supported.
pub fn is_claim_format_supported(&self, designation: &ClaimFormatDesignation) -> bool {
self.vp_formats_supported().0.contains_key(designation)
}

/// The static wallet metadata bound to `openid4vp:`:
/// ```json
/// {
Expand All @@ -65,19 +72,21 @@ impl WalletMetadata {

let response_types_supported = ResponseTypesSupported(vec![ResponseType::VpToken]);

let mut format_definition = Map::new();
format_definition.insert(
"alg_values_supported".to_owned(),
Json::Array(vec![Json::String("ES256".to_owned())]),
let alg_values_supported = vec![Algorithm::ES256.to_string()];

let mut vp_formats_supported = ClaimFormatMap::new();
vp_formats_supported.insert(
ClaimFormatDesignation::JwtVpJson,
ClaimFormatPayload::AlgValuesSupported(alg_values_supported.clone()),
);
vp_formats_supported.insert(
ClaimFormatDesignation::JwtVcJson,
ClaimFormatPayload::AlgValuesSupported(alg_values_supported.clone()),
);
let format_definition = Json::Object(format_definition);
let mut vp_formats_supported = Map::new();
vp_formats_supported.insert("jwt_vp_json".to_owned(), format_definition.clone());
vp_formats_supported.insert("jwt_vc_json".to_owned(), format_definition.clone());
let vp_formats_supported = VpFormatsSupported(vp_formats_supported);

let request_object_signing_alg_values_supported =
RequestObjectSigningAlgValuesSupported(vec!["ES256".to_owned()]);
RequestObjectSigningAlgValuesSupported(alg_values_supported);

let mut object = UntypedObject::default();

Expand Down
32 changes: 21 additions & 11 deletions src/core/metadata/parameters/verifier.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use anyhow::Error;
use serde::Deserialize;
use anyhow::{Context, Error};
use serde::{Deserialize, Serialize};
use serde_json::{Map, Value as Json};

use crate::core::object::TypedParameter;
use crate::{core::object::TypedParameter, presentation_exchange::ClaimFormatMap};

#[derive(Debug, Clone, Deserialize)]
pub struct VpFormats(pub Map<String, Json>);
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct VpFormats(pub ClaimFormatMap);

impl TypedParameter for VpFormats {
const KEY: &'static str = "vp_formats";
Expand All @@ -19,9 +19,11 @@ impl TryFrom<Json> for VpFormats {
}
}

impl From<VpFormats> for Json {
fn from(value: VpFormats) -> Json {
value.0.into()
impl TryFrom<VpFormats> for Json {
type Error = Error;

fn try_from(value: VpFormats) -> Result<Json, Self::Error> {
serde_json::to_value(value.0).context("Failed to serialize VpFormats")
}
}

Expand Down Expand Up @@ -119,6 +121,7 @@ mod test {
use serde_json::json;

use crate::core::object::UntypedObject;
use crate::presentation_exchange::{ClaimFormatDesignation, ClaimFormatPayload};

use super::*;

Expand Down Expand Up @@ -148,9 +151,16 @@ mod test {

#[test]
fn vp_formats() {
let VpFormats(fnd) = metadata().get().unwrap().unwrap();
let exp = json!({"mso_mdoc": {}}).as_object().unwrap().clone();
assert_eq!(fnd, exp)
let VpFormats(formats) = metadata().get().unwrap().unwrap();

let mso_doc = formats
.get(&ClaimFormatDesignation::MsoMDoc)
.expect("failed to find mso doc");

assert_eq!(
mso_doc,
&ClaimFormatPayload::Json(serde_json::Value::Object(Default::default()))
)
}

#[test]
Expand Down
32 changes: 20 additions & 12 deletions src/core/metadata/parameters/wallet.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
use crate::core::{
authorization_request::parameters::{ClientIdScheme, ResponseType},
object::TypedParameter,
use crate::{
core::{
authorization_request::parameters::{ClientIdScheme, ResponseType},
object::TypedParameter,
},
presentation_exchange::ClaimFormatMap,
};
use anyhow::{bail, Error, Result};
use serde_json::{Map, Value as Json};
use serde_json::Value as Json;
use url::Url;

#[derive(Debug, Clone)]
Expand Down Expand Up @@ -134,7 +137,7 @@ impl From<RequestObjectSigningAlgValuesSupported> for Json {

// TODO: Better types
#[derive(Debug, Clone)]
Ryanmtate marked this conversation as resolved.
Show resolved Hide resolved
pub struct VpFormatsSupported(pub Map<String, Json>);
pub struct VpFormatsSupported(pub ClaimFormatMap);

impl TypedParameter for VpFormatsSupported {
const KEY: &'static str = "vp_formats_supported";
Expand All @@ -144,13 +147,15 @@ impl TryFrom<Json> for VpFormatsSupported {
type Error = Error;

fn try_from(value: Json) -> Result<Self, Self::Error> {
Ok(Self(serde_json::from_value(value)?))
serde_json::from_value(value).map(Self).map_err(Into::into)
}
}

impl From<VpFormatsSupported> for Json {
fn from(value: VpFormatsSupported) -> Json {
Json::Object(value.0)
impl TryFrom<VpFormatsSupported> for Json {
type Error = Error;

fn try_from(value: VpFormatsSupported) -> Result<Json, Self::Error> {
serde_json::to_value(value.0).map_err(Into::into)
}
}

Expand Down Expand Up @@ -200,7 +205,10 @@ impl From<AuthorizationEncryptionEncValuesSupported> for Json {
mod test {
use serde_json::json;

use crate::core::object::UntypedObject;
use crate::{
core::object::UntypedObject,
presentation_exchange::{ClaimFormatDesignation, ClaimFormatPayload},
};

use super::*;

Expand Down Expand Up @@ -277,8 +285,8 @@ mod test {
let VpFormatsSupported(mut m) = metadata().get().unwrap().unwrap();
assert_eq!(m.len(), 1);
assert_eq!(
m.remove("mso_mdoc").unwrap(),
Json::Object(Default::default())
m.remove(&ClaimFormatDesignation::MsoMDoc).unwrap(),
ClaimFormatPayload::Json(serde_json::Value::Object(Default::default()))
);
}

Expand Down
17 changes: 10 additions & 7 deletions src/core/object/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ pub struct UntypedObject(pub(crate) Map<String, Json>);
// TODO: Replace anyhow error type.
/// A strongly typed parameter that can represent metadata entries or request parameters.
pub trait TypedParameter:
TryFrom<Json, Error = anyhow::Error> + Into<Json> + Clone + std::fmt::Debug
TryFrom<Json, Error = anyhow::Error> + TryInto<Json> + Clone + std::fmt::Debug
Ryanmtate marked this conversation as resolved.
Show resolved Hide resolved
{
const KEY: &'static str;
}
Expand Down Expand Up @@ -51,12 +51,15 @@ impl UntypedObject {
/// # Errors
/// Returns an error if there was already an entry in the Object, but it could not be parsed from JSON.
pub fn insert<T: TypedParameter>(&mut self, t: T) -> Option<Result<T>> {
Some(
self.0
.insert(T::KEY.to_owned(), t.into())?
.try_into()
.map_err(Into::into),
)
match t.try_into() {
Err(_) => Some(Err(Error::msg("failed to parse typed parameter"))),
Ok(value) => Some(
self.0
.insert(T::KEY.to_owned(), value)?
.try_into()
.map_err(Into::into),
),
}
}

/// Flatten the structure for posting as a form.
Expand Down
10 changes: 10 additions & 0 deletions src/core/response/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,16 @@ impl UnencodedAuthorizationResponse {
serde_urlencoded::to_string(inner.flatten_for_form()?)
.context("failed to encode response as 'application/x-www-form-urlencoded'")
}

/// Return the Verifiable Presentation Token.
pub fn vp_token(&self) -> &VpToken {
&self.1
}

/// Return the Presentation Submission.
pub fn presentation_submission(&self) -> &PresentationSubmission {
&self.2
}
}

#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down
1 change: 1 addition & 0 deletions src/holder/mod.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
pub mod verifiable_presentation_builder;
Loading
Loading