all repos — telegram-bot-api @ 9105c34c59802cba482ee90cae261218971f634c

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