Skip to content

Commit

Permalink
feat: create Presentations using raw Credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
nanderstabel committed Oct 29, 2024
1 parent abcc6b9 commit ebdbeda
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions agent_api_rest/src/holder/holder/presentations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ use axum::{
Json,
};
use hyper::StatusCode;
use identity_credential::credential::Jwt;
use serde::{Deserialize, Serialize};
use serde_json::{json, Value};
use tracing::info;
Expand Down Expand Up @@ -43,19 +44,24 @@ pub(crate) async fn presentation(State(state): State<HolderState>, Path(presenta
#[derive(Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PresentationsEndpointRequest {
#[serde(default)]
pub credential_ids: Vec<String>,
#[serde(default)]
pub credentials: Vec<Jwt>,
}

#[axum_macros::debug_handler]
pub(crate) async fn post_presentations(State(state): State<HolderState>, Json(payload): Json<Value>) -> Response {
info!("Request Body: {}", payload);

let Ok(PresentationsEndpointRequest { credential_ids }) = serde_json::from_value(payload) else {
let Ok(PresentationsEndpointRequest {
credential_ids,
mut credentials,
}) = serde_json::from_value(payload)
else {
return (StatusCode::BAD_REQUEST, "invalid payload").into_response();
};

let mut credentials = vec![];

// Get all the credentials.
for credential_id in credential_ids {
match query_handler(&credential_id, &state.query.holder_credential).await {
Expand Down

0 comments on commit ebdbeda

Please sign in to comment.