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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
/// Data submitted by a user via Telegram Passport.
pub struct PassportData {
/// Array of encrypted passport elements.
pub data: Vec<EncryptedPassportElement>,
/// Encrypted credentials required to decrypt the data.
pub credentials: EncryptedCredentials,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
/// An encrypted element containing Telegram Passport data.
pub struct EncryptedPassportElement {
/// Element type (e.g. `"passport"`, `"email"`, `"phone_number"`).
#[serde(rename = "type")]
pub kind: String,
/// Base64-encoded encrypted Telegram Passport element data.
#[serde(skip_serializing_if = "Option::is_none")]
pub data: Option<String>,
/// User's verified phone number.
#[serde(skip_serializing_if = "Option::is_none")]
pub phone_number: Option<String>,
/// User's verified email address.
#[serde(skip_serializing_if = "Option::is_none")]
pub email: Option<String>,
/// Array of encrypted files with documents.
#[serde(skip_serializing_if = "Option::is_none")]
pub files: Option<Vec<crate::file::PassportFile>>,
/// Encrypted file with the front side of the document.
#[serde(skip_serializing_if = "Option::is_none")]
pub front_side: Option<crate::file::PassportFile>,
/// Encrypted file with the reverse side of the document.
#[serde(skip_serializing_if = "Option::is_none")]
pub reverse_side: Option<crate::file::PassportFile>,
/// Encrypted file with a selfie of the user holding the document.
#[serde(skip_serializing_if = "Option::is_none")]
pub selfie: Option<crate::file::PassportFile>,
/// Array of encrypted files with translated versions of the document.
#[serde(skip_serializing_if = "Option::is_none")]
pub translation: Option<Vec<crate::file::PassportFile>>,
/// Base64-encoded element hash for error validation.
pub hash: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
/// Credentials required to decrypt and authenticate Telegram Passport data.
pub struct EncryptedCredentials {
/// Base64-encoded encrypted JSON credentials.
pub data: String,
/// Base64-encoded data hash for authentication.
pub hash: String,
/// Base64-encoded secret, encrypted with the bot's public RSA key.
pub secret: String,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(tag = "source")]
/// An error in one of the fields provided by the user via Telegram Passport.
pub enum PassportElementError {
/// Error in one of the data fields.
#[serde(rename = "data")]
DataField {
/// Element type that has the error.
r#type: String,
/// Name of the data field with the error.
field_name: String,
/// Base64-encoded data hash.
data_hash: String,
/// Error message.
message: String,
},
/// Error in the front side of the document.
#[serde(rename = "front_side")]
FrontSide {
/// Element type that has the error.
r#type: String,
/// Base64-encoded file hash.
file_hash: String,
/// Error message.
message: String,
},
/// Error in the reverse side of the document.
#[serde(rename = "reverse_side")]
ReverseSide {
/// Element type that has the error.
r#type: String,
/// Base64-encoded file hash.
file_hash: String,
/// Error message.
message: String,
},
/// Error in the selfie photo.
#[serde(rename = "selfie")]
Selfie {
/// Element type that has the error.
r#type: String,
/// Base64-encoded file hash.
file_hash: String,
/// Error message.
message: String,
},
/// Error in one of the uploaded files.
#[serde(rename = "file")]
File {
/// Element type that has the error.
r#type: String,
/// Base64-encoded file hash.
file_hash: String,
/// Error message.
message: String,
},
/// Error in a list of uploaded files.
#[serde(rename = "files")]
Files {
/// Element type that has the error.
r#type: String,
/// Base64-encoded file hashes.
file_hashes: Vec<String>,
/// Error message.
message: String,
},
/// Error in one of the translation files.
#[serde(rename = "translation_file")]
TranslationFile {
/// Element type that has the error.
r#type: String,
/// Base64-encoded file hash.
file_hash: String,
/// Error message.
message: String,
},
/// Error in a list of translation files.
#[serde(rename = "translation_files")]
TranslationFiles {
/// Element type that has the error.
r#type: String,
/// Base64-encoded file hashes.
file_hashes: Vec<String>,
/// Error message.
message: String,
},
/// Error in an unspecified place.
#[serde(rename = "unspecified")]
Unspecified {
/// Element type that has the error.
r#type: String,
/// Base64-encoded element hash.
element_hash: String,
/// Error message.
message: String,
},
}