-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
passport.ts
232 lines (219 loc) · 11.4 KB
/
passport.ts
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
/** Describes Telegram Passport data shared with the bot by the user. */
export interface PassportData {
/** Array with information about documents and other Telegram Passport elements that was shared with the bot */
data: EncryptedPassportElement[];
/** Encrypted credentials required to decrypt the data */
credentials: EncryptedCredentials;
}
/** This object represents a file uploaded to Telegram Passport. Currently all Telegram Passport files are in JPEG format when decrypted and don't exceed 10MB. */
export interface PassportFile {
/** Identifier for this file, which can be used to download or reuse the file */
file_id: string;
/** Unique identifier for this file, which is supposed to be the same over time and for different bots. Can't be used to download or reuse the file. */
file_unique_id: string;
/** File size in bytes */
file_size: number;
/** Unix time when the file was uploaded */
file_date: number;
}
/** Describes documents or other Telegram Passport elements shared with the bot by the user. */
export interface EncryptedPassportElement {
/** Element type. One of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration”, “phone_number”, “email”. */
type:
| "personal_details"
| "passport"
| "driver_license"
| "identity_card"
| "internal_passport"
| "address"
| "utility_bill"
| "bank_statement"
| "rental_agreement"
| "passport_registration"
| "temporary_registration"
| "phone_number"
| "email";
/** Base64-encoded encrypted Telegram Passport element data provided by the user, available for “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport” and “address” types. Can be decrypted and verified using the accompanying EncryptedCredentials. */
data?: string;
/** User's verified phone number, available only for “phone_number” type */
phone_number?: string;
/** User's verified email address, available only for “email” type */
email?: string;
/** Array of encrypted files with documents provided by the user, available for “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. */
files?: PassportFile[];
/** Encrypted file with the front side of the document, provided by the user. Available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */
front_side?: PassportFile;
/** Encrypted file with the reverse side of the document, provided by the user. Available for “driver_license” and “identity_card”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */
reverse_side?: PassportFile;
/** Encrypted file with the selfie of the user holding a document, provided by the user; available for “passport”, “driver_license”, “identity_card” and “internal_passport”. The file can be decrypted and verified using the accompanying EncryptedCredentials. */
selfie?: PassportFile;
/** Array of encrypted files with translated versions of documents provided by the user. Available if requested for “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration” and “temporary_registration” types. Files can be decrypted and verified using the accompanying EncryptedCredentials. */
translation?: PassportFile[];
/** Base64-encoded element hash for using in PassportElementErrorUnspecified */
hash: string;
}
/** Describes data required for decrypting and authenticating EncryptedPassportElement. See the Telegram Passport Documentation for a complete description of the data decryption and authentication processes. */
export interface EncryptedCredentials {
/** Base64-encoded encrypted JSON-serialized data with unique user's payload, data hashes and secrets required for EncryptedPassportElement decryption and authentication */
data: string;
/** Base64-encoded data hash for data authentication */
hash: string;
/** Base64-encoded secret, encrypted with the bot's public RSA key, required for data decryption */
secret: string;
}
/** This object represents an error in the Telegram Passport element which was submitted that should be resolved by the user. It should be one of:
- PassportElementErrorDataField
- PassportElementErrorFrontSide
- PassportElementErrorReverseSide
- PassportElementErrorSelfie
- PassportElementErrorFile
- PassportElementErrorFiles
- PassportElementErrorTranslationFile
- PassportElementErrorTranslationFiles
- PassportElementErrorUnspecified
*/
export type PassportElementError =
| PassportElementErrorDataField
| PassportElementErrorFrontSide
| PassportElementErrorReverseSide
| PassportElementErrorSelfie
| PassportElementErrorFile
| PassportElementErrorFiles
| PassportElementErrorTranslationFile
| PassportElementErrorTranslationFiles
| PassportElementErrorUnspecified;
/** Represents an issue in one of the data fields that was provided by the user. The error is considered resolved when the field's value changes. */
export interface PassportElementErrorDataField {
/** Error source, must be data */
source: "data";
/** The section of the user's Telegram Passport which has the error, one of “personal_details”, “passport”, “driver_license”, “identity_card”, “internal_passport”, “address” */
type:
| "personal_details"
| "passport"
| "driver_license"
| "identity_card"
| "internal_passport"
| "address";
/** Name of the data field which has the error */
field_name: string;
/** Base64-encoded data hash */
data_hash: string;
/** Error message */
message: string;
}
/** Represents an issue with the front side of a document. The error is considered resolved when the file with the front side of the document changes. */
export interface PassportElementErrorFrontSide {
/** Error source, must be front_side */
source: "front_side";
/** The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport” */
type: "passport" | "driver_license" | "identity_card" | "internal_passport";
/** Base64-encoded hash of the file with the front side of the document */
file_hash: string;
/** Error message */
message: string;
}
/** Represents an issue with the reverse side of a document. The error is considered resolved when the file with reverse side of the document changes. */
export interface PassportElementErrorReverseSide {
/** Error source, must be reverse_side */
source: "reverse_side";
/** The section of the user's Telegram Passport which has the issue, one of “driver_license”, “identity_card” */
type: "driver_license" | "identity_card";
/** Base64-encoded hash of the file with the reverse side of the document */
file_hash: string;
/** Error message */
message: string;
}
/** Represents an issue with the selfie with a document. The error is considered resolved when the file with the selfie changes. */
export interface PassportElementErrorSelfie {
/** Error source, must be selfie */
source: "selfie";
/** The section of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport” */
type: "passport" | "driver_license" | "identity_card" | "internal_passport";
/** Base64-encoded hash of the file with the selfie */
file_hash: string;
/** Error message */
message: string;
}
/** Represents an issue with a document scan. The error is considered resolved when the file with the document scan changes. */
export interface PassportElementErrorFile {
/** Error source, must be file */
source: "file";
/** The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */
type:
| "utility_bill"
| "bank_statement"
| "rental_agreement"
| "passport_registration"
| "temporary_registration";
/** Base64-encoded file hash */
file_hash: string;
/** Error message */
message: string;
}
/** Represents an issue with a list of scans. The error is considered resolved when the list of files containing the scans changes. */
export interface PassportElementErrorFiles {
/** Error source, must be files */
source: "files";
/** The section of the user's Telegram Passport which has the issue, one of “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */
type:
| "utility_bill"
| "bank_statement"
| "rental_agreement"
| "passport_registration"
| "temporary_registration";
/** List of base64-encoded file hashes */
file_hashes: string[];
/** Error message */
message: string;
}
/** Represents an issue with one of the files that constitute the translation of a document. The error is considered resolved when the file changes. */
export interface PassportElementErrorTranslationFile {
/** Error source, must be translation_file */
source: "translation_file";
/** Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */
type:
| "passport"
| "driver_license"
| "identity_card"
| "internal_passport"
| "utility_bill"
| "bank_statement"
| "rental_agreement"
| "passport_registration"
| "temporary_registration";
/** Base64-encoded file hash */
file_hash: string;
/** Error message */
message: string;
}
/** Represents an issue with the translated version of a document. The error is considered resolved when a file with the document translation change. */
export interface PassportElementErrorTranslationFiles {
/** Error source, must be translation_files */
source: "translation_files";
/** Type of element of the user's Telegram Passport which has the issue, one of “passport”, “driver_license”, “identity_card”, “internal_passport”, “utility_bill”, “bank_statement”, “rental_agreement”, “passport_registration”, “temporary_registration” */
type:
| "passport"
| "driver_license"
| "identity_card"
| "internal_passport"
| "utility_bill"
| "bank_statement"
| "rental_agreement"
| "passport_registration"
| "temporary_registration";
/** List of base64-encoded file hashes */
file_hashes: string[];
/** Error message */
message: string;
}
/** Represents an issue in an unspecified place. The error is considered resolved when new data is added. */
export interface PassportElementErrorUnspecified {
/** Error source, must be unspecified */
source: "unspecified";
/** Type of element of the user's Telegram Passport which has the issue */
type: string;
/** Base64-encoded element hash */
element_hash: string;
/** Error message */
message: string;
}