1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
use crate::{irmaclient::SessionToken, util::TranslatedString};

use serde::{Deserialize, Serialize};

/// Status of an disclosed attribute
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum AttributeStatus {
    #[serde(rename = "PRESENT")]
    Present,
    #[serde(rename = "EXTRA")]
    Extra,
    #[serde(rename = "NULL")]
    Null,
}

/// Status of an IRMA proof
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum ProofStatus {
    #[serde(rename = "VALID")]
    Valid,
    #[serde(rename = "INVALID")]
    Invalid,
    #[serde(rename = "INVALID_TIMESTAMP")]
    InvalidTimestamp,
    #[serde(rename = "UNMATCHED_REQUEST")]
    UnmatchedRequest,
    #[serde(rename = "MISSING_ATTRIBUTES")]
    MissingAttributes,
    #[serde(rename = "EXPIRED")]
    Expired,
}

/// Status of an IRMA session
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum SessionStatus {
    #[serde(rename = "INITIALIZED")]
    Initialized,
    #[serde(rename = "PAIRING")]
    Pairing,
    #[serde(rename = "CONNECTED")]
    Connected,
    #[serde(rename = "CANCELLED")]
    Cancelled,
    #[serde(rename = "DONE")]
    Done,
    #[serde(rename = "TIMEOUT")]
    Timeout,
}

/// Type of an IRMA session
#[derive(Serialize, Deserialize, Debug, Clone)]
pub enum SessionType {
    #[serde(rename = "disclosing")]
    Disclosing,
    #[serde(rename = "signing")]
    Signing,
    #[serde(rename = "issuing")]
    Issuing,
}

/// A disclosed attribute
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct DisclosedAttribute {
    /// The value of the attribute as encoded in the credential
    #[serde(rename = "rawvalue", skip_serializing_if = "Option::is_none")]
    pub raw_value: Option<String>,
    /// A representation of the value that can be used for displaying in UI's of various languages
    #[serde(skip_serializing_if = "Option::is_none")]
    pub value: Option<TranslatedString>,
    /// Identifier of the disclosed attribute
    pub identifier: String,
    /// Additional information on the role of the disclosed attribute in the complete session result
    pub status: AttributeStatus,
}

/// Results of a session
#[derive(Serialize, Deserialize, Debug, Clone)]
pub struct SessionResult {
    /// Token of the session
    pub token: SessionToken,
    #[serde(rename = "type")]
    pub sessiontype: SessionType,
    pub status: SessionStatus,
    #[serde(rename = "proofStatus", skip_serializing_if = "Option::is_none")]
    pub proof_status: Option<ProofStatus>,
    #[serde(skip_serializing_if = "Vec::is_empty")]
    pub disclosed: Vec<Vec<DisclosedAttribute>>,
}