go-tg-screenshot-bot
317 строк · 11.5 Кб
1package tgbotapi
2
3// PassportRequestInfoConfig allows you to request passport info
4type PassportRequestInfoConfig struct {
5BotID int `json:"bot_id"`
6Scope *PassportScope `json:"scope"`
7Nonce string `json:"nonce"`
8PublicKey string `json:"public_key"`
9}
10
11// PassportScopeElement supports using one or one of several elements.
12type PassportScopeElement interface {
13ScopeType() string
14}
15
16// PassportScope is the requested scopes of data.
17type PassportScope struct {
18V int `json:"v"`
19Data []PassportScopeElement `json:"data"`
20}
21
22// PassportScopeElementOneOfSeveral allows you to request any one of the
23// requested documents.
24type PassportScopeElementOneOfSeveral struct {
25}
26
27// ScopeType is the scope type.
28func (eo *PassportScopeElementOneOfSeveral) ScopeType() string {
29return "one_of"
30}
31
32// PassportScopeElementOne requires the specified element be provided.
33type PassportScopeElementOne struct {
34Type string `json:"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”
35Selfie bool `json:"selfie"`
36Translation bool `json:"translation"`
37NativeNames bool `json:"native_name"`
38}
39
40// ScopeType is the scope type.
41func (eo *PassportScopeElementOne) ScopeType() string {
42return "one"
43}
44
45type (
46// PassportData contains information about Telegram Passport data shared with
47// the bot by the user.
48PassportData struct {
49// Array with information about documents and other Telegram Passport
50// elements that was shared with the bot
51Data []EncryptedPassportElement `json:"data"`
52
53// Encrypted credentials required to decrypt the data
54Credentials *EncryptedCredentials `json:"credentials"`
55}
56
57// PassportFile represents a file uploaded to Telegram Passport. Currently, all
58// Telegram Passport files are in JPEG format when decrypted and don't exceed
59// 10MB.
60PassportFile struct {
61// Unique identifier for this file
62FileID string `json:"file_id"`
63
64FileUniqueID string `json:"file_unique_id"`
65
66// File size
67FileSize int `json:"file_size"`
68
69// Unix time when the file was uploaded
70FileDate int64 `json:"file_date"`
71}
72
73// EncryptedPassportElement contains information about documents or other
74// Telegram Passport elements shared with the bot by the user.
75EncryptedPassportElement struct {
76// Element type.
77Type string `json:"type"`
78
79// Base64-encoded encrypted Telegram Passport element data provided by
80// the user, available for "personal_details", "passport",
81// "driver_license", "identity_card", "identity_passport" and "address"
82// types. Can be decrypted and verified using the accompanying
83// EncryptedCredentials.
84Data string `json:"data,omitempty"`
85
86// User's verified phone number, available only for "phone_number" type
87PhoneNumber string `json:"phone_number,omitempty"`
88
89// User's verified email address, available only for "email" type
90Email string `json:"email,omitempty"`
91
92// Array of encrypted files with documents provided by the user,
93// available for "utility_bill", "bank_statement", "rental_agreement",
94// "passport_registration" and "temporary_registration" types. Files can
95// be decrypted and verified using the accompanying EncryptedCredentials.
96Files []PassportFile `json:"files,omitempty"`
97
98// Encrypted file with the front side of the document, provided by the
99// user. Available for "passport", "driver_license", "identity_card" and
100// "internal_passport". The file can be decrypted and verified using the
101// accompanying EncryptedCredentials.
102FrontSide *PassportFile `json:"front_side,omitempty"`
103
104// Encrypted file with the reverse side of the document, provided by the
105// user. Available for "driver_license" and "identity_card". The file can
106// be decrypted and verified using the accompanying EncryptedCredentials.
107ReverseSide *PassportFile `json:"reverse_side,omitempty"`
108
109// Encrypted file with the selfie of the user holding a document,
110// provided by the user; available for "passport", "driver_license",
111// "identity_card" and "internal_passport". The file can be decrypted
112// and verified using the accompanying EncryptedCredentials.
113Selfie *PassportFile `json:"selfie,omitempty"`
114}
115
116// EncryptedCredentials contains data required for decrypting and
117// authenticating EncryptedPassportElement. See the Telegram Passport
118// Documentation for a complete description of the data decryption and
119// authentication processes.
120EncryptedCredentials struct {
121// Base64-encoded encrypted JSON-serialized data with unique user's
122// payload, data hashes and secrets required for EncryptedPassportElement
123// decryption and authentication
124Data string `json:"data"`
125
126// Base64-encoded data hash for data authentication
127Hash string `json:"hash"`
128
129// Base64-encoded secret, encrypted with the bot's public RSA key,
130// required for data decryption
131Secret string `json:"secret"`
132}
133
134// PassportElementError represents an error in the Telegram Passport element
135// which was submitted that should be resolved by the user.
136PassportElementError interface{}
137
138// PassportElementErrorDataField represents an issue in one of the data
139// fields that was provided by the user. The error is considered resolved
140// when the field's value changes.
141PassportElementErrorDataField struct {
142// Error source, must be data
143Source string `json:"source"`
144
145// The section of the user's Telegram Passport which has the error, one
146// of "personal_details", "passport", "driver_license", "identity_card",
147// "internal_passport", "address"
148Type string `json:"type"`
149
150// Name of the data field which has the error
151FieldName string `json:"field_name"`
152
153// Base64-encoded data hash
154DataHash string `json:"data_hash"`
155
156// Error message
157Message string `json:"message"`
158}
159
160// PassportElementErrorFrontSide represents an issue with the front side of
161// a document. The error is considered resolved when the file with the front
162// side of the document changes.
163PassportElementErrorFrontSide struct {
164// Error source, must be front_side
165Source string `json:"source"`
166
167// The section of the user's Telegram Passport which has the issue, one
168// of "passport", "driver_license", "identity_card", "internal_passport"
169Type string `json:"type"`
170
171// Base64-encoded hash of the file with the front side of the document
172FileHash string `json:"file_hash"`
173
174// Error message
175Message string `json:"message"`
176}
177
178// PassportElementErrorReverseSide represents an issue with the reverse side
179// of a document. The error is considered resolved when the file with reverse
180// side of the document changes.
181PassportElementErrorReverseSide struct {
182// Error source, must be reverse_side
183Source string `json:"source"`
184
185// The section of the user's Telegram Passport which has the issue, one
186// of "driver_license", "identity_card"
187Type string `json:"type"`
188
189// Base64-encoded hash of the file with the reverse side of the document
190FileHash string `json:"file_hash"`
191
192// Error message
193Message string `json:"message"`
194}
195
196// PassportElementErrorSelfie represents an issue with the selfie with a
197// document. The error is considered resolved when the file with the selfie
198// changes.
199PassportElementErrorSelfie struct {
200// Error source, must be selfie
201Source string `json:"source"`
202
203// The section of the user's Telegram Passport which has the issue, one
204// of "passport", "driver_license", "identity_card", "internal_passport"
205Type string `json:"type"`
206
207// Base64-encoded hash of the file with the selfie
208FileHash string `json:"file_hash"`
209
210// Error message
211Message string `json:"message"`
212}
213
214// PassportElementErrorFile represents an issue with a document scan. The
215// error is considered resolved when the file with the document scan changes.
216PassportElementErrorFile struct {
217// Error source, must be a file
218Source string `json:"source"`
219
220// The section of the user's Telegram Passport which has the issue, one
221// of "utility_bill", "bank_statement", "rental_agreement",
222// "passport_registration", "temporary_registration"
223Type string `json:"type"`
224
225// Base64-encoded file hash
226FileHash string `json:"file_hash"`
227
228// Error message
229Message string `json:"message"`
230}
231
232// PassportElementErrorFiles represents an issue with a list of scans. The
233// error is considered resolved when the list of files containing the scans
234// changes.
235PassportElementErrorFiles struct {
236// Error source, must be files
237Source string `json:"source"`
238
239// The section of the user's Telegram Passport which has the issue, one
240// of "utility_bill", "bank_statement", "rental_agreement",
241// "passport_registration", "temporary_registration"
242Type string `json:"type"`
243
244// List of base64-encoded file hashes
245FileHashes []string `json:"file_hashes"`
246
247// Error message
248Message string `json:"message"`
249}
250
251// Credentials contains encrypted data.
252Credentials struct {
253Data SecureData `json:"secure_data"`
254// Nonce the same nonce given in the request
255Nonce string `json:"nonce"`
256}
257
258// SecureData is a map of the fields and their encrypted values.
259SecureData map[string]*SecureValue
260// PersonalDetails *SecureValue `json:"personal_details"`
261// Passport *SecureValue `json:"passport"`
262// InternalPassport *SecureValue `json:"internal_passport"`
263// DriverLicense *SecureValue `json:"driver_license"`
264// IdentityCard *SecureValue `json:"identity_card"`
265// Address *SecureValue `json:"address"`
266// UtilityBill *SecureValue `json:"utility_bill"`
267// BankStatement *SecureValue `json:"bank_statement"`
268// RentalAgreement *SecureValue `json:"rental_agreement"`
269// PassportRegistration *SecureValue `json:"passport_registration"`
270// TemporaryRegistration *SecureValue `json:"temporary_registration"`
271
272// SecureValue contains encrypted values for a SecureData item.
273SecureValue struct {
274Data *DataCredentials `json:"data"`
275FrontSide *FileCredentials `json:"front_side"`
276ReverseSide *FileCredentials `json:"reverse_side"`
277Selfie *FileCredentials `json:"selfie"`
278Translation []*FileCredentials `json:"translation"`
279Files []*FileCredentials `json:"files"`
280}
281
282// DataCredentials contains information required to decrypt data.
283DataCredentials struct {
284// DataHash checksum of encrypted data
285DataHash string `json:"data_hash"`
286// Secret of encrypted data
287Secret string `json:"secret"`
288}
289
290// FileCredentials contains information required to decrypt files.
291FileCredentials struct {
292// FileHash checksum of encrypted data
293FileHash string `json:"file_hash"`
294// Secret of encrypted data
295Secret string `json:"secret"`
296}
297
298// PersonalDetails https://core.telegram.org/passport#personaldetails
299PersonalDetails struct {
300FirstName string `json:"first_name"`
301LastName string `json:"last_name"`
302MiddleName string `json:"middle_name"`
303BirthDate string `json:"birth_date"`
304Gender string `json:"gender"`
305CountryCode string `json:"country_code"`
306ResidenceCountryCode string `json:"residence_country_code"`
307FirstNameNative string `json:"first_name_native"`
308LastNameNative string `json:"last_name_native"`
309MiddleNameNative string `json:"middle_name_native"`
310}
311
312// IDDocumentData https://core.telegram.org/passport#iddocumentdata
313IDDocumentData struct {
314DocumentNumber string `json:"document_no"`
315ExpiryDate string `json:"expiry_date"`
316}
317)
318