all repos — telegram-bot-api @ f3a5b4ed79f60d503c3ae13843e17b51c1361dc5

Golang bindings for the Telegram Bot API

passport.go (view raw)

  1package tgbotapi
  2
  3// PassportRequestInfoConfig allows you to request passport info
  4type PassportRequestInfoConfig struct {
  5	BotID     int            `json:"bot_id"`
  6	Scope     *PassportScope `json:"scope"`
  7	Nonce     string         `json:"nonce"`
  8	PublicKey string         `json:"public_key"`
  9}
 10
 11// PassportScopeElement supports using one or one of several elements.
 12type PassportScopeElement interface {
 13	ScopeType() string
 14}
 15
 16// PassportScope is the requested scopes of data.
 17type PassportScope struct {
 18	V    int                    `json:"v"`
 19	Data []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 {
 29	return "one_of"
 30}
 31
 32// PassportScopeElementOne requires the specified element be provided.
 33type PassportScopeElementOne struct {
 34	Type        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”
 35	Selfie      bool   `json:"selfie"`
 36	Translation bool   `json:"translation"`
 37	NativeNames bool   `json:"native_name"`
 38}
 39
 40// ScopeType is the scope type.
 41func (eo *PassportScopeElementOne) ScopeType() string {
 42	return "one"
 43}
 44
 45type (
 46	// PassportData contains information about Telegram Passport data shared with
 47	// the bot by the user.
 48	PassportData struct {
 49		// Array with information about documents and other Telegram Passport
 50		// elements that was shared with the bot
 51		Data []EncryptedPassportElement `json:"data"`
 52
 53		// Encrypted credentials required to decrypt the data
 54		Credentials *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.
 60	PassportFile struct {
 61		// Unique identifier for this file
 62		FileID string `json:"file_id"`
 63
 64		FileUniqueID string `json:"file_unique_id"`
 65
 66		// File size
 67		FileSize int `json:"file_size"`
 68
 69		// Unix time when the file was uploaded
 70		FileDate 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.
 75	EncryptedPassportElement struct {
 76		// Element type.
 77		Type 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.
 84		Data string `json:"data,omitempty"`
 85
 86		// User's verified phone number, available only for "phone_number" type
 87		PhoneNumber string `json:"phone_number,omitempty"`
 88
 89		// User's verified email address, available only for "email" type
 90		Email 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.
 96		Files []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.
102		FrontSide *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.
107		ReverseSide *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.
113		Selfie *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.
120	EncryptedCredentials 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
124		Data string `json:"data"`
125
126		// Base64-encoded data hash for data authentication
127		Hash string `json:"hash"`
128
129		// Base64-encoded secret, encrypted with the bot's public RSA key,
130		// required for data decryption
131		Secret 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.
136	PassportElementError 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.
141	PassportElementErrorDataField struct {
142		// Error source, must be data
143		Source 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"
148		Type string `json:"type"`
149
150		// Name of the data field which has the error
151		FieldName string `json:"field_name"`
152
153		// Base64-encoded data hash
154		DataHash string `json:"data_hash"`
155
156		// Error message
157		Message 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.
163	PassportElementErrorFrontSide struct {
164		// Error source, must be front_side
165		Source 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"
169		Type string `json:"type"`
170
171		// Base64-encoded hash of the file with the front side of the document
172		FileHash string `json:"file_hash"`
173
174		// Error message
175		Message 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.
181	PassportElementErrorReverseSide struct {
182		// Error source, must be reverse_side
183		Source string `json:"source"`
184
185		// The section of the user's Telegram Passport which has the issue, one
186		// of "driver_license", "identity_card"
187		Type string `json:"type"`
188
189		// Base64-encoded hash of the file with the reverse side of the document
190		FileHash string `json:"file_hash"`
191
192		// Error message
193		Message 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.
199	PassportElementErrorSelfie struct {
200		// Error source, must be selfie
201		Source 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"
205		Type string `json:"type"`
206
207		// Base64-encoded hash of the file with the selfie
208		FileHash string `json:"file_hash"`
209
210		// Error message
211		Message 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.
216	PassportElementErrorFile struct {
217		// Error source, must be a file
218		Source 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"
223		Type string `json:"type"`
224
225		// Base64-encoded file hash
226		FileHash string `json:"file_hash"`
227
228		// Error message
229		Message 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.
235	PassportElementErrorFiles struct {
236		// Error source, must be files
237		Source 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"
242		Type string `json:"type"`
243
244		// List of base64-encoded file hashes
245		FileHashes []string `json:"file_hashes"`
246
247		// Error message
248		Message string `json:"message"`
249	}
250
251	// Credentials contains encrypted data.
252	Credentials struct {
253		Data SecureData `json:"secure_data"`
254		// Nonce the same nonce given in the request
255		Nonce string `json:"nonce"`
256	}
257
258	// SecureData is a map of the fields and their encrypted values.
259	SecureData 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.
273	SecureValue struct {
274		Data        *DataCredentials   `json:"data"`
275		FrontSide   *FileCredentials   `json:"front_side"`
276		ReverseSide *FileCredentials   `json:"reverse_side"`
277		Selfie      *FileCredentials   `json:"selfie"`
278		Translation []*FileCredentials `json:"translation"`
279		Files       []*FileCredentials `json:"files"`
280	}
281
282	// DataCredentials contains information required to decrypt data.
283	DataCredentials struct {
284		// DataHash checksum of encrypted data
285		DataHash string `json:"data_hash"`
286		// Secret of encrypted data
287		Secret string `json:"secret"`
288	}
289
290	// FileCredentials contains information required to decrypt files.
291	FileCredentials struct {
292		// FileHash checksum of encrypted data
293		FileHash string `json:"file_hash"`
294		// Secret of encrypted data
295		Secret string `json:"secret"`
296	}
297
298	// PersonalDetails https://core.telegram.org/passport#personaldetails
299	PersonalDetails struct {
300		FirstName            string `json:"first_name"`
301		LastName             string `json:"last_name"`
302		MiddleName           string `json:"middle_name"`
303		BirthDate            string `json:"birth_date"`
304		Gender               string `json:"gender"`
305		CountryCode          string `json:"country_code"`
306		ResidenceCountryCode string `json:"residence_country_code"`
307		FirstNameNative      string `json:"first_name_native"`
308		LastNameNative       string `json:"last_name_native"`
309		MiddleNameNative     string `json:"middle_name_native"`
310	}
311
312	// IDDocumentData https://core.telegram.org/passport#iddocumentdata
313	IDDocumentData struct {
314		DocumentNumber string `json:"document_no"`
315		ExpiryDate     string `json:"expiry_date"`
316	}
317)