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