-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move session status structs to frontend crate.
This resolves issues with compilation of the dependencies of the main crate for frontend targets.
- Loading branch information
Showing
5 changed files
with
156 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
[package] | ||
name = "oid4vp-frontend" | ||
version = "0.1.0" | ||
edition = "2021" | ||
|
||
[dependencies] | ||
serde = "1.0" | ||
serde_json = "1.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
//! OID4VP library data structures that are needed on the frontend, without all of the other | ||
//! dependencies that can cause compilation issues with web targets. | ||
use serde::{Deserialize, Serialize}; | ||
use serde_json::Value as Json; | ||
|
||
/// Status of an OID4VP session. | ||
#[derive(Debug, Clone, PartialEq, PartialOrd, Serialize, Deserialize)] | ||
pub enum Status { | ||
/// Wallet has been sent the request by reference, waiting for the wallet to request the request. | ||
SentRequestByReference, | ||
/// Wallet has received the request, waiting on the wallet to process the request. | ||
SentRequest, | ||
/// Verifier has received the response and is now processing it. | ||
ReceivedResponse, | ||
/// Verifier has finished processing the response. | ||
Complete(Outcome), | ||
} | ||
|
||
/// Outcome of an OID4VP session. | ||
#[derive(Debug, Clone, Serialize, Deserialize)] | ||
pub enum Outcome { | ||
/// An error occurred during response processing. | ||
Error { cause: String }, | ||
/// The authorization response did not pass verification. | ||
Failure { reason: String }, | ||
/// The authorization response is verified. | ||
Success { info: Json }, | ||
} | ||
|
||
impl PartialEq for Outcome { | ||
fn eq(&self, other: &Self) -> bool { | ||
core::mem::discriminant(self) == core::mem::discriminant(other) | ||
} | ||
} | ||
|
||
impl Outcome { | ||
fn ordering(&self) -> u8 { | ||
match self { | ||
Outcome::Error { .. } => 0, | ||
Outcome::Failure { .. } => 1, | ||
Outcome::Success { .. } => 2, | ||
} | ||
} | ||
} | ||
|
||
impl PartialOrd for Outcome { | ||
fn partial_cmp(&self, other: &Self) -> Option<std::cmp::Ordering> { | ||
self.ordering().partial_cmp(&other.ordering()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters