Skip to content

Commit

Permalink
revert validation function async signature to use boxed pin future
Browse files Browse the repository at this point in the history
Signed-off-by: Ryan Tate <ryan.michael.tate@gmail.com>
  • Loading branch information
Ryanmtate committed Aug 20, 2024
1 parent f490b8b commit 347259d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
8 changes: 4 additions & 4 deletions src/verifier/mod.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use std::{fmt::Debug, future::Future, sync::Arc};
use std::{fmt::Debug, future::Future, pin::Pin, sync::Arc};

use anyhow::{bail, Context, Result};
use client::Client;
Expand Down Expand Up @@ -119,12 +119,12 @@ impl Verifier {
validator_function: F,
) -> Result<()>
where
F: FnOnce(Session, AuthorizationResponse) -> Fut,
Fut: Future<Output = Result<Outcome>>,
F: FnOnce(Session, AuthorizationResponse) -> Pin<Box<Fut>>,
Fut: Future<Output = Outcome>,
{
let session = self.session_store.get_session(reference).await?;

let outcome = validator_function(session, authorization_response).await?;
let outcome = validator_function(session, authorization_response).await;

self.session_store
.update_status(reference, Status::Complete(outcome))
Expand Down
23 changes: 12 additions & 11 deletions tests/jwt_vc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,17 +159,18 @@ impl AsyncHttpClient for MockHttpClient {
id.parse().context("failed to parse id")?,
AuthorizationResponse::from_x_www_form_urlencoded(body)
.context("failed to parse authorization response request")?,
|session, auth_response| async move {
session
.presentation_definition
.validate_authorization_response(&auth_response)
.await?;

println!("Session: {:?}", session);
println!("Auth Response: {:?}", auth_response);

Ok(Outcome::Success {
info: serde_json::Value::Null,
|session, auth_response| {
Box::pin(async move {
match session
.presentation_definition
.validate_authorization_response(&auth_response)
.await
{
Ok(_) => Outcome::Success {
info: serde_json::Value::Null,
},
Err(e) => Outcome::Error { cause: Arc::new(e) },
}
})
},
)
Expand Down

0 comments on commit 347259d

Please sign in to comment.