From 986652a1ae19630d5de95a86ed7eb7b01225ff3f Mon Sep 17 00:00:00 2001 From: levlam Date: Wed, 1 Aug 2018 16:52:07 +0300 Subject: [PATCH] Change Telegram Passport API object and function names. GitOrigin-RevId: 8e7d3602146dab76f62aa86f7539187559d2ca92 --- td/generate/scheme/td_api.tl | 248 ++++++++++++++++---------------- td/generate/scheme/td_api.tlo | Bin 130728 -> 130928 bytes td/telegram/MessagesManager.cpp | 4 +- td/telegram/SecureManager.cpp | 88 ++++++------ td/telegram/SecureManager.h | 8 +- td/telegram/SecureValue.cpp | 182 +++++++++++------------ td/telegram/SecureValue.h | 24 ++-- td/telegram/Td.cpp | 12 +- td/telegram/Td.h | 10 +- td/telegram/cli.cpp | 120 ++++++++-------- 10 files changed, 349 insertions(+), 347 deletions(-) diff --git a/td/generate/scheme/td_api.tl b/td/generate/scheme/td_api.tl index 5150ddbe7..fb2e35e86 100644 --- a/td/generate/scheme/td_api.tl +++ b/td/generate/scheme/td_api.tl @@ -109,7 +109,7 @@ authorizationStateClosing = AuthorizationState; authorizationStateClosed = AuthorizationState; -//@description Represents the current state of 2-step verification @has_password True if a 2-step verification password has been set up @password_hint Hint for the password; can be empty @has_recovery_email_address True if a recovery email has been set up @has_passport_data True if some Telegram Passport data has been saved @unconfirmed_recovery_email_address_pattern Pattern of the email address to which a confirmation email was sent +//@description Represents the current state of 2-step verification @has_password True if a 2-step verification password has been set up @password_hint Hint for the password; can be empty @has_recovery_email_address True if a recovery email has been set up @has_passport_data True if some Telegram Passport elements has been saved @unconfirmed_recovery_email_address_pattern Pattern of the email address to which a confirmation email was sent passwordState has_password:Bool password_hint:string has_recovery_email_address:Bool has_passport_data:Bool unconfirmed_recovery_email_address_pattern:string = PasswordState; //@description Contains information about the current recovery email address @recovery_email_address Recovery email address @@ -828,46 +828,46 @@ paymentReceipt date:int32 payments_provider_user_id:int32 invoice:invoice order_ datedFile file:file date:int32 = DatedFile; -//@class PassportDataType @description Contains type of a Telegram Passport data +//@class PassportElementType @description Contains type of a Telegram Passport element -//@description A Telegram Passport data fragment containing the user's personal details -passportDataTypePersonalDetails = PassportDataType; +//@description A Telegram Passport element containing the user's personal details +passportElementTypePersonalDetails = PassportElementType; -//@description A Telegram Passport data fragment containing the user's passport -passportDataTypePassport = PassportDataType; +//@description A Telegram Passport element containing the user's passport +passportElementTypePassport = PassportElementType; -//@description A Telegram Passport data fragment containing the user's driver license -passportDataTypeDriverLicense = PassportDataType; +//@description A Telegram Passport element containing the user's driver license +passportElementTypeDriverLicense = PassportElementType; -//@description A Telegram Passport data fragment containing the user's identity card -passportDataTypeIdentityCard = PassportDataType; +//@description A Telegram Passport element containing the user's identity card +passportElementTypeIdentityCard = PassportElementType; -//@description A Telegram Passport data fragment containing the user's internal passport -passportDataTypeInternalPassport = PassportDataType; +//@description A Telegram Passport element containing the user's internal passport +passportElementTypeInternalPassport = PassportElementType; -//@description A Telegram Passport data fragment containing the user's address -passportDataTypeAddress = PassportDataType; +//@description A Telegram Passport element containing the user's address +passportElementTypeAddress = PassportElementType; -//@description A Telegram Passport data fragment containing the user's utility bill -passportDataTypeUtilityBill = PassportDataType; +//@description A Telegram Passport element containing the user's utility bill +passportElementTypeUtilityBill = PassportElementType; -//@description A Telegram Passport data fragment containing the user's bank statement -passportDataTypeBankStatement = PassportDataType; +//@description A Telegram Passport element containing the user's bank statement +passportElementTypeBankStatement = PassportElementType; -//@description A Telegram Passport data fragment containing the user's rental agreement -passportDataTypeRentalAgreement = PassportDataType; +//@description A Telegram Passport element containing the user's rental agreement +passportElementTypeRentalAgreement = PassportElementType; -//@description A Telegram Passport data fragment containing the user's passport registration -passportDataTypePassportRegistration = PassportDataType; +//@description A Telegram Passport element containing the user's passport registration +passportElementTypePassportRegistration = PassportElementType; -//@description A Telegram Passport data fragment containing the user's temporary registration -passportDataTypeTemporaryRegistration = PassportDataType; +//@description A Telegram Passport element containing the user's temporary registration +passportElementTypeTemporaryRegistration = PassportElementType; -//@description A Telegram Passport data fragment containing a user's phone number -passportDataTypePhoneNumber = PassportDataType; +//@description A Telegram Passport element containing a user's phone number +passportElementTypePhoneNumber = PassportElementType; -//@description A Telegram Passport data fragment containing a user's email address -passportDataTypeEmailAddress = PassportDataType; +//@description A Telegram Passport element containing a user's email address +passportElementTypeEmailAddress = PassportElementType; //@description Represents a date according to the Gregorian calendar @day Day of the month, 1-31 @month Month, 1-12 @year Year, 1-9999 @@ -886,156 +886,156 @@ identityDocument number:string expiry_date:date front_side:datedFile reverse_sid inputIdentityDocument number:string expiry_date:date front_side:InputFile reverse_side:InputFile selfie:InputFile = InputIdentityDocument; -//@class PassportData @description Contains information about a Telegram Passport data +//@class PassportElement @description Contains information about a Telegram Passport element -//@description A Telegram Passport data fragment containing the user's personal details @personal_details Personal details of the user -passportDataPersonalDetails personal_details:personalDetails = PassportData; +//@description A Telegram Passport element containing the user's personal details @personal_details Personal details of the user +passportElementPersonalDetails personal_details:personalDetails = PassportElement; -//@description A Telegram Passport data fragment containing the user's passport @passport Passport -passportDataPassport passport:identityDocument = PassportData; +//@description A Telegram Passport element containing the user's passport @passport Passport +passportElementPassport passport:identityDocument = PassportElement; -//@description A Telegram Passport data fragment containing the user's driver license @driver_license Driver license -passportDataDriverLicense driver_license:identityDocument = PassportData; +//@description A Telegram Passport element containing the user's driver license @driver_license Driver license +passportElementDriverLicense driver_license:identityDocument = PassportElement; -//@description A Telegram Passport data fragment containing the user's identity card @identity_card Identity card -passportDataIdentityCard identity_card:identityDocument = PassportData; +//@description A Telegram Passport element containing the user's identity card @identity_card Identity card +passportElementIdentityCard identity_card:identityDocument = PassportElement; -//@description A Telegram Passport data fragment containing the user's internal passport @internal_passport Internal passport -passportDataInternalPassport internal_passport:identityDocument = PassportData; +//@description A Telegram Passport element containing the user's internal passport @internal_passport Internal passport +passportElementInternalPassport internal_passport:identityDocument = PassportElement; -//@description A Telegram Passport data fragment containing the user's address @address Address -passportDataAddress address:address = PassportData; +//@description A Telegram Passport element containing the user's address @address Address +passportElementAddress address:address = PassportElement; -//@description A Telegram Passport data fragment containing the user's utility bill @files List of files with the utility bill -passportDataUtilityBill files:vector = PassportData; +//@description A Telegram Passport element containing the user's utility bill @files List of files with the utility bill +passportElementUtilityBill files:vector = PassportElement; -//@description A Telegram Passport data fragment containing the user's bank statement @files List of files with the bank statement -passportDataBankStatement files:vector = PassportData; +//@description A Telegram Passport element containing the user's bank statement @files List of files with the bank statement +passportElementBankStatement files:vector = PassportElement; -//@description A Telegram Passport data fragment containing the user's rental agreement @files List of files with the rental agreement -passportDataRentalAgreement files:vector = PassportData; +//@description A Telegram Passport element containing the user's rental agreement @files List of files with the rental agreement +passportElementRentalAgreement files:vector = PassportElement; -//@description A Telegram Passport data fragment containing the user's passport registration pages @files List of files with the passport registration pages -passportDataPassportRegistration files:vector = PassportData; +//@description A Telegram Passport element containing the user's passport registration pages @files List of files with the passport registration pages +passportElementPassportRegistration files:vector = PassportElement; -//@description A Telegram Passport data fragment containing the user's temporary registration @files List of files with the temporary registration -passportDataTemporaryRegistration files:vector = PassportData; +//@description A Telegram Passport element containing the user's temporary registration @files List of files with the temporary registration +passportElementTemporaryRegistration files:vector = PassportElement; -//@description A Telegram Passport data fragment containing the user's phone number @phone_number Phone number -passportDataPhoneNumber phone_number:string = PassportData; +//@description A Telegram Passport element containing the user's phone number @phone_number Phone number +passportElementPhoneNumber phone_number:string = PassportElement; -//@description A Telegram Passport data fragment containing the user's email address @email_address Email address -passportDataEmailAddress email_address:string = PassportData; +//@description A Telegram Passport element containing the user's email address @email_address Email address +passportElementEmailAddress email_address:string = PassportElement; -//@class InputPassportData @description Contains information about a Telegram Passport data to be saved +//@class InputPassportElement @description Contains information about a Telegram Passport element to be saved -//@description A Telegram Passport fragment to be saved containing the user's personal details @personal_details Personal details of the user -inputPassportDataPersonalDetails personal_details:personalDetails = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's personal details @personal_details Personal details of the user +inputPassportElementPersonalDetails personal_details:personalDetails = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's passport @passport The passport to be saved -inputPassportDataPassport passport:inputIdentityDocument = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's passport @passport The passport to be saved +inputPassportElementPassport passport:inputIdentityDocument = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's driver license @driver_license The driver license to be saved -inputPassportDataDriverLicense driver_license:inputIdentityDocument = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's driver license @driver_license The driver license to be saved +inputPassportElementDriverLicense driver_license:inputIdentityDocument = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's identity card @identity_card The identity card to be saved -inputPassportDataIdentityCard identity_card:inputIdentityDocument = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's identity card @identity_card The identity card to be saved +inputPassportElementIdentityCard identity_card:inputIdentityDocument = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's internal passport @internal_passport The internal passport to be saved -inputPassportDataInternalPassport internal_passport:inputIdentityDocument = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's internal passport @internal_passport The internal passport to be saved +inputPassportElementInternalPassport internal_passport:inputIdentityDocument = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's address @address The address to be saved -inputPassportDataAddress address:address = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's address @address The address to be saved +inputPassportElementAddress address:address = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's utility bill @files List of files with the utility bill -inputPassportDataUtilityBill files:vector = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's utility bill @files List of files with the utility bill +inputPassportElementUtilityBill files:vector = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's bank statement @files List of files with the bank statement -inputPassportDataBankStatement files:vector = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's bank statement @files List of files with the bank statement +inputPassportElementBankStatement files:vector = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's rental agreement @files List of files with the rental agreement -inputPassportDataRentalAgreement files:vector = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's rental agreement @files List of files with the rental agreement +inputPassportElementRentalAgreement files:vector = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's passport registration @files List of files with the passport registration -inputPassportDataPassportRegistration files:vector = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's passport registration @files List of files with the passport registration +inputPassportElementPassportRegistration files:vector = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's temporary registration @files List of files with the temporary registration -inputPassportDataTemporaryRegistration files:vector = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's temporary registration @files List of files with the temporary registration +inputPassportElementTemporaryRegistration files:vector = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's phone number @phone_number The phone number to be saved -inputPassportDataPhoneNumber phone_number:string = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's phone number @phone_number The phone number to be saved +inputPassportElementPhoneNumber phone_number:string = InputPassportElement; -//@description A Telegram Passport fragment to be saved containing the user's email address @email_address The email address to be saved -inputPassportDataEmailAddress email_address:string = InputPassportData; +//@description A Telegram Passport element to be saved containing the user's email address @email_address The email address to be saved +inputPassportElementEmailAddress email_address:string = InputPassportElement; -//@description Contains information about all saved Telegram Passport data @data All saved Telegram Passport data -allPassportData data:vector = AllPassportData; +//@description Contains information about saved Telegram Passport elements @elements Telegram Passport elements +passportElements elements:vector = PassportElements; -//@class PassportDataErrorSource @description Contains the description of an error in a Telegram Passport data +//@class PassportElementErrorSource @description Contains the description of an error in a Telegram Passport element //@description One of the data fields contains an error. The error will be considered resolved when the value of the field changes @field_name Field name -passportDataErrorSourceDataField field_name:string = PassportDataErrorSource; +passportElementErrorSourceDataField field_name:string = PassportElementErrorSource; //@description The front side of the document contains an error. The error will be considered resolved when the file with the front side changes -passportDataErrorSourceFrontSide = PassportDataErrorSource; +passportElementErrorSourceFrontSide = PassportElementErrorSource; //@description The reverse side of the document contains an error. The error will be considered resolved when the file with the reverse side changes -passportDataErrorSourceReverseSide = PassportDataErrorSource; +passportElementErrorSourceReverseSide = PassportElementErrorSource; //@description The selfie with the document contains an error. The error will be considered resolved when the file with the selfie changes -passportDataErrorSourceSelfie = PassportDataErrorSource; +passportElementErrorSourceSelfie = PassportElementErrorSource; //@description The file contains an error. The error will be considered resolved when the file changes -passportDataErrorSourceFile = PassportDataErrorSource; +passportElementErrorSourceFile = PassportElementErrorSource; //@description The list of attached files contains an error. The error will be considered resolved when the list of files changes -passportDataErrorSourceFiles = PassportDataErrorSource; +passportElementErrorSourceFiles = PassportElementErrorSource; -//@description Contains the description of an error in Telegram Passport data @type Type of the Telegram Passport data which has the error @message Error message @source Error source -passportDataError type:PassportDataType message:string source:PassportDataErrorSource = PassportDataError; +//@description Contains the description of an error in a Telegram Passport element @type Type of the Telegram Passport element which has the error @message Error message @source Error source +passportElementError type:PassportElementType message:string source:PassportElementErrorSource = PassportElementError; //@description Contains information about a Telegram Passport authorization form that was requested @id Unique identifier of the authorization form -//@required_types Data types that need to be provided to complete the form. If the user has more than one identity document or proof of address document, any one of each can be chosen -//@data Already available data @errors Errors in the data that is already available @is_selfie_required True, if a selfie is required with the identity document @privacy_policy_url URL for the privacy policy of the service; can be empty -passportAuthorizationForm id:int32 required_types:vector data:vector errors:vector is_selfie_required:Bool privacy_policy_url:string = PassportAuthorizationForm; +//@required_types Telegram Passport element types that need to be provided to complete the form. If the user has more than one identity document or proof of address document, any one of each can be chosen +//@elements Already available Telegram Passport elements @errors Errors in the elements that is already available @is_selfie_required True, if a selfie is required with the identity document @privacy_policy_url URL for the privacy policy of the service; can be empty +passportAuthorizationForm id:int32 required_types:vector elements:vector errors:vector is_selfie_required:Bool privacy_policy_url:string = PassportAuthorizationForm; //@description Contains encrypted Telegram Passport data credentials @data The encrypted credentials @hash The decrypted data hash @secret Secret for data decryption, encrypted with service's public key encryptedCredentials data:bytes hash:bytes secret:bytes = EncryptedCredentials; -//@description Contains information about encrypted Telegram Passport data; for bots only @type Type of Telegram Passport data @data Encrypted JSON-encoded data about the user @front_side The front side of an identity document @reverse_side The reverse side of an identity document; may be null @selfie Selfie with the document; may be null @files List of attached files @value Unencrypted data, phone number or email address -encryptedPassportData type:PassportDataType data:bytes front_side:datedFile reverse_side:datedFile selfie:datedFile files:vector value:string = EncryptedPassportData; +//@description Contains information about encrypted Telegram Passport element; for bots only @type Type of Telegram Passport element @data Encrypted JSON-encoded data about the user @front_side The front side of an identity document @reverse_side The reverse side of an identity document; may be null @selfie Selfie with the document; may be null @files List of attached files @value Unencrypted data, phone number or email address +encryptedPassportElement type:PassportElementType data:bytes front_side:datedFile reverse_side:datedFile selfie:datedFile files:vector value:string = EncryptedPassportElement; -//@class InputPassportDataErrorSource @description Contains the description of an error in Telegram Passport data; for bots only +//@class InputPassportElementErrorSource @description Contains the description of an error in Telegram Passport element; for bots only //@description A data field contains an error. The error is considered resolved when the field's value changes @field_name Field name @data_hash Current data hash -inputPassportDataErrorSourceDataField field_name:string data_hash:bytes = InputPassportDataErrorSource; +inputPassportElementErrorSourceDataField field_name:string data_hash:bytes = InputPassportElementErrorSource; //@description The front side of the document contains an error. The error is considered resolved when the file with the document front side changes @file_hash Current hash of the file containing the front side -inputPassportDataErrorSourceFrontSide file_hash:bytes = InputPassportDataErrorSource; +inputPassportElementErrorSourceFrontSide file_hash:bytes = InputPassportElementErrorSource; //@description The reverse side of the document contains an error. The error is considered resolved when the file with the document reverse side changes @file_hash Current hash of the file containing the reverse side -inputPassportDataErrorSourceReverseSide file_hash:bytes = InputPassportDataErrorSource; +inputPassportElementErrorSourceReverseSide file_hash:bytes = InputPassportElementErrorSource; //@description The selfie contains an error. The error is considered resolved when the file with the selfie changes @file_hash Current hash of the file containing the selfie -inputPassportDataErrorSourceSelfie file_hash:bytes = InputPassportDataErrorSource; +inputPassportElementErrorSourceSelfie file_hash:bytes = InputPassportElementErrorSource; //@description The file contains an error. The error is considered resolved when the file changes @file_hash Hash of the file with an error -inputPassportDataErrorSourceFile file_hash:bytes = InputPassportDataErrorSource; +inputPassportElementErrorSourceFile file_hash:bytes = InputPassportElementErrorSource; //@description The list of attached files contains an error. The error is considered resolved when the file list changes @file_hashes Hashes of all files -inputPassportDataErrorSourceFiles file_hashes:vector = InputPassportDataErrorSource; +inputPassportElementErrorSourceFiles file_hashes:vector = InputPassportElementErrorSource; -//@description Contains the description of an error in Telegram Passport data; for bots only @type Type of Telegram Passport data that has the error @message Error message @source Error source -inputPassportDataError type:PassportDataType message:string source:InputPassportDataErrorSource = InputPassportDataError; +//@description Contains the description of an error in Telegram Passport element; for bots only @type Type of Telegram Passport element that has the error @message Error message @source Error source +inputPassportElementError type:PassportElementType message:string source:InputPassportElementErrorSource = InputPassportElementError; //@class MessageContent @description Contains the content of a message @@ -1153,11 +1153,11 @@ messageContactRegistered = MessageContent; //@description The current user has connected a website by logging in using Telegram Login Widget on it @domain_name Domain name of the connected website messageWebsiteConnected domain_name:string = MessageContent; -//@description Telegram Passport data has been sent @types List of data types sent -messagePassportDataSent types:vector = MessageContent; +//@description Telegram Passport data has been sent @types List of Telegram Passport element types sent +messagePassportDataSent types:vector = MessageContent; -//@description Telegram Passport data has been received; for bots only @data List of received Telegram Passport data @credentials Encrypted data credentials -messagePassportDataReceived data:vector credentials:encryptedCredentials = MessageContent; +//@description Telegram Passport data has been received; for bots only @elements List of received Telegram Passport elements @credentials Encrypted data credentials +messagePassportDataReceived elements:vector credentials:encryptedCredentials = MessageContent; //@description Message content that is not supported by the client messageUnsupported = MessageContent; @@ -3168,20 +3168,20 @@ addNetworkStatistics entry:NetworkStatisticsEntry = Ok; resetNetworkStatistics = Ok; -//@description Returns the available Telegram Passport data @type Data type @password Password of the current user -getPassportData type:PassportDataType password:string = PassportData; +//@description Returns the available Telegram Passport element @type Telegram Passport element type @password Password of the current user +getPassportElement type:PassportElementType password:string = PassportElement; -//@description Returns all available Telegram Passport data @password Password of the current user -getAllPassportData password:string = AllPassportData; +//@description Returns all available Telegram Passport elements @password Password of the current user +getAllPassportElements password:string = PassportElements; -//@description Sets Telegram Passport data. May return an error with a message "PHONE_VERIFICATION_NEEDED" or "EMAIL_VERIFICATION_NEEDED" if the chosen phone number or the chosen email address must be verified first @data Input Telegram Passport data @password Password of the current user -setPassportData data:InputPassportData password:string = PassportData; +//@description Sets Telegram Passport element. May return an error with a message "PHONE_VERIFICATION_NEEDED" or "EMAIL_VERIFICATION_NEEDED" if the chosen phone number or the chosen email address must be verified first @element Input Telegram Passport element @password Password of the current user +setPassportElement element:InputPassportElement password:string = PassportElement; -//@description Deletes Telegram Passport data @type Data type -deletePassportData type:PassportDataType = Ok; +//@description Deletes Telegram Passport element @type Element type +deletePassportElement type:PassportElementType = Ok; -//@description Informs a user that some of the Telegram Passport data contains errors; for bots only. The user will not be able to resend data, until the errors are fixed @user_id User identifier @errors The errors -setPassportDataErrors user_id:int32 errors:vector = Ok; +//@description Informs a user that some of the Telegram Passport elements contain errors; for bots only. The user will not be able to resend the elements, until the errors are fixed @user_id User identifier @errors The errors +setPassportElementErrors user_id:int32 errors:vector = Ok; //@description Sends a code to verify a phone number to be added to a user's Telegram Passport @@ -3205,11 +3205,11 @@ resendEmailAddressVerificationCode = EmailAddressAuthenticationCodeInfo; checkEmailAddressVerificationCode code:string = Ok; -//@description Returns a Telegram Passport authorization form for sharing data with a service @bot_user_id User identified of the service's bot @scope Telegram Passport data types requested by the service @public_key Service's public_key @payload Authorization form payload provided by the service @password Password of the current user +//@description Returns a Telegram Passport authorization form for sharing data with a service @bot_user_id User identified of the service's bot @scope Telegram Passport element types requested by the service @public_key Service's public_key @payload Authorization form payload provided by the service @password Password of the current user getPassportAuthorizationForm bot_user_id:int32 scope:string public_key:string payload:string password:string = PassportAuthorizationForm; -//@description Sends a Telegram Passport authorization form, effectively sharing data with the service @autorization_form_id Authorization form identifier @types Types of Telegram Passport data chosen by user to complete the authorization form @password Password of the current user -sendPassportAuthorizationForm autorization_form_id:int32 types:vector password:string = Ok; +//@description Sends a Telegram Passport authorization form, effectively sharing data with the service @autorization_form_id Authorization form identifier @types Types of Telegram Passport elements chosen by user to complete the authorization form @password Password of the current user +sendPassportAuthorizationForm autorization_form_id:int32 types:vector password:string = Ok; //@description Sends phone number confirmation code. Should be called when user presses "https://t.me/confirmphone?phone=*******&hash=**********" or "tg://confirmphone?phone=*******&hash=**********" link @hash Value of the "hash" parameter from the link diff --git a/td/generate/scheme/td_api.tlo b/td/generate/scheme/td_api.tlo index c9c876ba3f5093ce76bb998e43a4e7fbceac7fb4..bb6d70b90cc4f2af8d7eb8ef76a1b65cea6cbc26 100644 GIT binary patch delta 5363 zcma)Ae^gV~9nXb;;Gq~HNRVh^iKjub4v%q5J@FJOOnRg}S;cN=jcZc!2B9IO$#YZd z1gER?%vtodd#&emr7JQk(&5R@aOY@M5Jd%-c-%Qnw6G1Q84n|4*UcYi#1-uKYt zub1!rem?hmzxR8;_w(Mq`!mKTX0$XNJYY@Fd)?GBWGD|-hc|?H&gb$*BB6#bUmoD# ztu#|KZDw=wybpK2SgU_F7+S~6hU>W?uhD28gRgpeX4Ex1BT1`;Gn1ev+n#f0S^K$J%!Ft*gW-deU3zAqJREKa!v(4N z3sz?S<;YyM(bWy>!quE66$gClgWm+R8Lz4hAr3Dmr>fbrO2>>w;K;1}XqEm%W^`MD zr@Rp7jZ?`RO$-_zI+;~D18#BTYSDbKWz+~u{1>!nC~By)Eweqn?R!;jj9B6BSlXP9&WQcS#V5Wl(j$&To(5K zmtGQr=qXd`ji6}zM~f_~1VNq) zi|dy*K_V$`ciLGJ-Sw^c`D!GkK3|xNkmR+t7b}wY-ObihCNF#EC^i{)7`3SJ$=7JmIP~l{l9Sf7-?BLP>Tth@u3;mLd2~>J)JhB`M=j~d5%tYvcyMD8 z+%&9%byru9%>TMuPv>v;&vaE~m00R%vi;LHUU==xj>J-rqZN3-%~TZ@Us+DCovNtUKQBN=M#qdph<%#-O$hu)v8g7-pZSbOqc#Lshz z0-8>_iDmedjXdc31LUEppIW;5De0Adn)yjf*=cGCou)o*r>)bc_KM`LJ5xymIr9+r z)-!}%==vid^t;be%kY1JgD})m6V&zF;IXqb=JB&r=?B7x9pIb9+cofz`C0~KAh_#@ z3C5mCBe>B4LM)h5#iD5CGX!%7NKZ!fQaMO>lOLp;I6g?DFrRBC@B`9mj_DP%Z|}4wnOHERgD^pHyA=km=@m;Zp7VqF9EL!;TQN`+L5h&= z+yAg=E(4P3AF|$z>t%{?>-OyXHk&L)`%Djh?4?&{v0KaNo=LEU&2rt#YpexK$fD-a zYw;q*SQUs%HERV6ixA~b%H$-9yu2s44zhWXNgVJV)&`{fCGbL}OXp<^B?tj6S80Mn= zjpb-W+Lt9+NoghB{RbevGjs=UD_5=n1+ z`PUEDT@Be{dBaVF2!HWmmW1A9kR6>yAU-QZj6r@eNj(uEqK!G5e{wv*|6E6OF^+~ge~>J)NTC*u+1`G zTeSX-IW-(#8kqbxB7Unwl^wys3N4#}U5kR~-nR#|WnoPwxH`e%#jL#AI5O~7mPqyB z+&sS7(3+Fbmn#whyfv`|->%&|J^^cPbXhAC>e1tMmy#I^u`6jbr0AC?KNQ0qBnh^ Nsb0)=SPX)a+7lr9zt{vNgf`O4Vmq40~US_;_FL3qlINm)Q znb1ILV<{SgY?5a}#=%A$Yqci58gy#;p->l!pM%1smXvox zZ%-xSGlSO_XQjEu^Y^9Tt!TyrS;>E?x}wKBz|7)Rsde>x=92N&$~qqdi2`n2-^1ym zL=L4yunpKAHvscGT{;Xxh*bQso8rvc@9*t}0|Gg#+$Fi9h|GgTq$t>TE0L2PQd~L01wh3ufa8ZYysU7i;iRu-}GpH@P| z!sQg| zp-AF8X<4l%dG5Q-e_TT>6-@p%O(SDAs4>$Y*UqdYFj({zjQb@Q6P}bHh}*O3E}5km z!Dg2m7V!lm*rWZ)2jtOK5eP?AB&a-9Dy}8aerhav5xfm3F#g8lyzw168JzD*7B2`e z)>Vl~ebSn3?RlsrxnF8IDYsPj8^S8kV6yH}H1NDM zFfh^Yq)}7pfB}6}57^Pi;D9-djR8fzHK1vW6-=zrO5+CSyJ`L-EiG{e2TfrZ-fkYk z+L7pqpm9iI+dpJlSooj<`r4Ks&PP%DNd#QeCrB#3=NGgjQAlpGchXk05ZkaMX#KFX zYuAU-HnavUXoxi!VV2!NY17(+W;A?E`e+@IX0?n+L+m5czFr@Z#%f2K5a_MZc|EmY z@#ri3hwbztPdzZ9FRTzZCas};%u*npAE}nXDzyHEv`c!Aa3MOX82Orj)vH3d zbL3>F`TIBNM@?a)qRM@VP4pXcx8I2a_VM||iV;M}5(3Y5n1F6tXI2wj%=ox(DNZ0=x8fQFuS5vrIk>J< zj{`89B!X-@6()xwB3Yp(I`+j&PprU+z@LumHR|~Z`9ANbwkqVq43Y>I+z}xg*EH9qNDrkk z5`z_;QNB7#@ri^-Dc-ph1=}OJqJmoC2_+vS`QC#dxecC?vy(|7g_dCCgkA%Yt+N&n z&HzVWdSU9SVl;mJ&pRIq;$UcSCV6Hx*F;=f|4MvWf&tPuM1y>+IsVmUI1-COvO!Tr z;Q95`2Z}^2VHp=4n-5pvC?~Y6{i;q26DhhOEf&&u3S5^+}D7WIry|yl{#3> z)w<#p9`4cd-G69QB$~)GU-=?(Gzif`5>NGq*$RmviK-GtB$9YIzPVYU4&+f4Mx3WX z&KC8m4t(eLMn&d{L}a1F$rj?Wu37hY#rcI?sAe|!qaiSqmB%O&2NGa4G#U=$KYlq! zD7>*j@#LhUA^O2+`zy=w(*T1}mDFf>{(9)<`#IayM79T))@TUNW}bO6SIq}2Y(q5Y z(*xU{A~ePdZ8RKqLv{<1eI=e;{6)H;#(_KkIa`RHF8pK>ZR{LcPuHYK4M!~W@=kjx zowG^L&V^oF;$++mr|@EY+dg`Q21eQ0vyU!MGPvs9SC>>Voa!Gu3jY1Xo7-rM27Yxq z+vuZ9MBBtC{*FHXnA#1!zEzu_B+$qk1AQO7F~nz)>V2HwCip7Y*;#&?es-<)-kYB- z^D|y2C|a7u_uZtOC_eLN^mwA7|JIfy|3bXNzg!977dsDmzpcKedNQxYrK$+TTIlEB V`;z{#2ENDncCR3$?hb8V`hQ0_`Z@pr diff --git a/td/telegram/MessagesManager.cpp b/td/telegram/MessagesManager.cpp index 691867654..77554bd78 100644 --- a/td/telegram/MessagesManager.cpp +++ b/td/telegram/MessagesManager.cpp @@ -9557,12 +9557,12 @@ tl_object_ptr MessagesManager::get_message_content_objec } case MessagePassportDataSent::ID: { const MessagePassportDataSent *m = static_cast(content); - return make_tl_object(get_passport_data_types_object(m->types)); + return make_tl_object(get_passport_element_types_object(m->types)); } case MessagePassportDataReceived::ID: { const MessagePassportDataReceived *m = static_cast(content); return make_tl_object( - get_encrypted_passport_data_object(td_->file_manager_.get(), m->values), + get_encrypted_passport_element_object(td_->file_manager_.get(), m->values), get_encrypted_credentials_object(m->credentials)); } default: diff --git a/td/telegram/SecureManager.cpp b/td/telegram/SecureManager.cpp index 4c792f050..446b9cdae 100644 --- a/td/telegram/SecureManager.cpp +++ b/td/telegram/SecureManager.cpp @@ -49,12 +49,12 @@ class GetSecureValue : public NetQueryCallback { class GetAllSecureValues : public NetQueryCallback { public: - GetAllSecureValues(ActorShared<> parent, std::string password, Promise promise); + GetAllSecureValues(ActorShared<> parent, std::string password, Promise promise); private: ActorShared<> parent_; string password_; - Promise promise_; + Promise promise_; optional> encrypted_secure_values_; optional secret_; @@ -225,8 +225,7 @@ void GetSecureValue::on_result(NetQueryPtr query) { loop(); } -GetAllSecureValues::GetAllSecureValues(ActorShared<> parent, std::string password, - Promise promise) +GetAllSecureValues::GetAllSecureValues(ActorShared<> parent, std::string password, Promise promise) : parent_(std::move(parent)), password_(std::move(password)), promise_(std::move(promise)) { } @@ -262,7 +261,7 @@ void GetAllSecureValues::loop() { } auto secure_values = transform(r_secure_values.move_as_ok(), [](SecureValueWithCredentials &&value) { return std::move(value.value); }); - promise_.set_result(get_all_passport_data_object(file_manager, std::move(secure_values))); + promise_.set_result(get_passport_elements_object(file_manager, std::move(secure_values))); stop(); } @@ -504,7 +503,7 @@ void SetSecureValue::on_result(NetQueryPtr query) { auto *file_manager = G()->td().get_actor_unsafe()->file_manager_.get(); auto encrypted_secure_value = get_encrypted_secure_value(file_manager, std::move(result)); if (encrypted_secure_value.type == SecureValueType::None) { - return on_error(Status::Error(500, "Receive invalid Telegram Passport data")); + return on_error(Status::Error(500, "Receive invalid Telegram Passport element")); } if (secure_value_.files.size() != encrypted_secure_value.files.size()) { return on_error(Status::Error(500, "Different file count")); @@ -667,22 +666,23 @@ class GetPassportAuthorizationForm : public NetQueryCallback { break; } - auto r_passport_data = get_passport_data_object(file_manager, std::move(r_secure_value.move_as_ok().value)); - if (r_passport_data.is_error()) { - LOG(ERROR) << "Failed to get passport data object: " << r_passport_data.error(); + auto r_passport_element = + get_passport_element_object(file_manager, std::move(r_secure_value.move_as_ok().value)); + if (r_passport_element.is_error()) { + LOG(ERROR) << "Failed to get passport element object: " << r_passport_element.error(); break; } - values.push_back(r_passport_data.move_as_ok()); + values.push_back(r_passport_element.move_as_ok()); break; } } - vector> errors; + vector> errors; for (auto &error_ptr : authorization_form_->errors_) { CHECK(error_ptr != nullptr); SecureValueType type = SecureValueType::None; - td_api::object_ptr source; + td_api::object_ptr source; string message; switch (error_ptr->get_id()) { case telegram_api::secureValueErrorData::ID: { @@ -693,42 +693,42 @@ class GetPassportAuthorizationForm : public NetQueryCallback { if (field_name.empty()) { break; } - source = td_api::make_object(std::move(field_name)); + source = td_api::make_object(std::move(field_name)); break; } case telegram_api::secureValueErrorFile::ID: { auto error = move_tl_object_as(error_ptr); type = get_secure_value_type(error->type_); message = std::move(error->text_); - source = td_api::make_object(); + source = td_api::make_object(); break; } case telegram_api::secureValueErrorFiles::ID: { auto error = move_tl_object_as(error_ptr); type = get_secure_value_type(error->type_); message = std::move(error->text_); - source = td_api::make_object(); + source = td_api::make_object(); break; } case telegram_api::secureValueErrorFrontSide::ID: { auto error = move_tl_object_as(error_ptr); type = get_secure_value_type(error->type_); message = std::move(error->text_); - source = td_api::make_object(); + source = td_api::make_object(); break; } case telegram_api::secureValueErrorReverseSide::ID: { auto error = move_tl_object_as(error_ptr); type = get_secure_value_type(error->type_); message = std::move(error->text_); - source = td_api::make_object(); + source = td_api::make_object(); break; } case telegram_api::secureValueErrorSelfie::ID: { auto error = move_tl_object_as(error_ptr); type = get_secure_value_type(error->type_); message = std::move(error->text_); - source = td_api::make_object(); + source = td_api::make_object(); break; } default: @@ -738,12 +738,12 @@ class GetPassportAuthorizationForm : public NetQueryCallback { continue; } - errors.push_back(td_api::make_object(get_passport_data_type_object(type), message, - std::move(source))); + errors.push_back(td_api::make_object(get_passport_element_type_object(type), + message, std::move(source))); } promise_.set_value(make_tl_object( - authorization_form_id_, get_passport_data_types_object(types), std::move(values), std::move(errors), + authorization_form_id_, get_passport_element_types_object(types), std::move(values), std::move(errors), is_selfie_required, authorization_form_->privacy_policy_url_)); stop(); } @@ -759,12 +759,12 @@ void SecureManager::get_secure_value(std::string password, SecureValueType type, return promise.set_error(r_secure_value.move_as_error()); } auto *file_manager = G()->td().get_actor_unsafe()->file_manager_.get(); - auto r_passport_data = get_passport_data_object(file_manager, r_secure_value.move_as_ok().value); - if (r_passport_data.is_error()) { - LOG(ERROR) << "Failed to get passport data object: " << r_passport_data.error(); + auto r_passport_element = get_passport_element_object(file_manager, r_secure_value.move_as_ok().value); + if (r_passport_element.is_error()) { + LOG(ERROR) << "Failed to get passport element object: " << r_passport_element.error(); return promise.set_value(nullptr); } - promise.set_value(r_passport_data.move_as_ok()); + promise.set_value(r_passport_element.move_as_ok()); }); do_get_secure_value(std::move(password), type, std::move(new_promise)); } @@ -776,7 +776,7 @@ void SecureManager::do_get_secure_value(std::string password, SecureValueType ty .release(); } -void SecureManager::get_all_secure_values(std::string password, Promise promise) { +void SecureManager::get_all_secure_values(std::string password, Promise promise) { refcnt_++; create_actor("GetAllSecureValues", actor_shared(), std::move(password), std::move(promise)) .release(); @@ -791,12 +791,12 @@ void SecureManager::set_secure_value(string password, SecureValue secure_value, return promise.set_error(r_secure_value.move_as_error()); } auto *file_manager = G()->td().get_actor_unsafe()->file_manager_.get(); - auto r_passport_data = get_passport_data_object(file_manager, r_secure_value.move_as_ok().value); - if (r_passport_data.is_error()) { - LOG(ERROR) << "Failed to get passport data object: " << r_passport_data.error(); - return promise.set_error(Status::Error(500, "Failed to get passport data object")); + auto r_passport_element = get_passport_element_object(file_manager, r_secure_value.move_as_ok().value); + if (r_passport_element.is_error()) { + LOG(ERROR) << "Failed to get passport element object: " << r_passport_element.error(); + return promise.set_error(Status::Error(500, "Failed to get passport element object")); } - promise.set_value(r_passport_data.move_as_ok()); + promise.set_value(r_passport_element.move_as_ok()); }); set_secure_value_queries_[type] = create_actor("SetSecureValue", actor_shared(), std::move(password), std::move(secure_value), std::move(new_promise)); @@ -820,7 +820,7 @@ void SecureManager::on_delete_secure_value(SecureValueType type, Promise p } void SecureManager::set_secure_value_errors(Td *td, tl_object_ptr input_user, - vector> errors, + vector> errors, Promise promise) { CHECK(td != nullptr); CHECK(input_user != nullptr); @@ -841,8 +841,8 @@ void SecureManager::set_secure_value_errors(Td *td, tl_object_ptrtype_)); switch (error->source_->get_id()) { - case td_api::inputPassportDataErrorSourceDataField::ID: { - auto source = td_api::move_object_as(error->source_); + case td_api::inputPassportElementErrorSourceDataField::ID: { + auto source = td_api::move_object_as(error->source_); if (!clean_input_string(source->field_name_)) { return promise.set_error(Status::Error(400, "Field name must be encoded in UTF-8")); } @@ -851,32 +851,32 @@ void SecureManager::set_secure_value_errors(Td *td, tl_object_ptrdata_hash_), source->field_name_, error->message_)); break; } - case td_api::inputPassportDataErrorSourceFrontSide::ID: { - auto source = td_api::move_object_as(error->source_); + case td_api::inputPassportElementErrorSourceFrontSide::ID: { + auto source = td_api::move_object_as(error->source_); input_errors.push_back(make_tl_object( std::move(type), BufferSlice(source->file_hash_), error->message_)); break; } - case td_api::inputPassportDataErrorSourceReverseSide::ID: { - auto source = td_api::move_object_as(error->source_); + case td_api::inputPassportElementErrorSourceReverseSide::ID: { + auto source = td_api::move_object_as(error->source_); input_errors.push_back(make_tl_object( std::move(type), BufferSlice(source->file_hash_), error->message_)); break; } - case td_api::inputPassportDataErrorSourceSelfie::ID: { - auto source = td_api::move_object_as(error->source_); + case td_api::inputPassportElementErrorSourceSelfie::ID: { + auto source = td_api::move_object_as(error->source_); input_errors.push_back(make_tl_object( std::move(type), BufferSlice(source->file_hash_), error->message_)); break; } - case td_api::inputPassportDataErrorSourceFile::ID: { - auto source = td_api::move_object_as(error->source_); + case td_api::inputPassportElementErrorSourceFile::ID: { + auto source = td_api::move_object_as(error->source_); input_errors.push_back(make_tl_object( std::move(type), BufferSlice(source->file_hash_), error->message_)); break; } - case td_api::inputPassportDataErrorSourceFiles::ID: { - auto source = td_api::move_object_as(error->source_); + case td_api::inputPassportElementErrorSourceFiles::ID: { + auto source = td_api::move_object_as(error->source_); if (source->file_hashes_.empty()) { return promise.set_error(Status::Error(400, "Error hashes must be non-empty")); } diff --git a/td/telegram/SecureManager.h b/td/telegram/SecureManager.h index 3db9ca6ef..19574e992 100644 --- a/td/telegram/SecureManager.h +++ b/td/telegram/SecureManager.h @@ -26,8 +26,8 @@ namespace td { class Td; -using TdApiSecureValue = td_api::object_ptr; -using TdApiAllSecureValues = td_api::object_ptr; +using TdApiSecureValue = td_api::object_ptr; +using TdApiSecureValues = td_api::object_ptr; using TdApiAuthorizationForm = td_api::object_ptr; class SecureManager : public NetQueryCallback { @@ -35,11 +35,11 @@ class SecureManager : public NetQueryCallback { explicit SecureManager(ActorShared<> parent); void get_secure_value(std::string password, SecureValueType type, Promise promise); - void get_all_secure_values(std::string password, Promise promise); + void get_all_secure_values(std::string password, Promise promise); void set_secure_value(string password, SecureValue secure_value, Promise promise); void delete_secure_value(SecureValueType type, Promise promise); void set_secure_value_errors(Td *td, tl_object_ptr input_user, - vector> errors, Promise promise); + vector> errors, Promise promise); void get_passport_authorization_form(string password, UserId bot_user_id, string scope, string public_key, string payload, Promise promise); diff --git a/td/telegram/SecureValue.cpp b/td/telegram/SecureValue.cpp index cb85abb66..3f3685bd4 100644 --- a/td/telegram/SecureValue.cpp +++ b/td/telegram/SecureValue.cpp @@ -101,34 +101,34 @@ SecureValueType get_secure_value_type(const tl_object_ptr &passport_data_type) { - CHECK(passport_data_type != nullptr); - switch (passport_data_type->get_id()) { - case td_api::passportDataTypePersonalDetails::ID: +SecureValueType get_secure_value_type_td_api(const tl_object_ptr &passport_element_type) { + CHECK(passport_element_type != nullptr); + switch (passport_element_type->get_id()) { + case td_api::passportElementTypePersonalDetails::ID: return SecureValueType::PersonalDetails; - case td_api::passportDataTypePassport::ID: + case td_api::passportElementTypePassport::ID: return SecureValueType::Passport; - case td_api::passportDataTypeDriverLicense::ID: + case td_api::passportElementTypeDriverLicense::ID: return SecureValueType::DriverLicense; - case td_api::passportDataTypeIdentityCard::ID: + case td_api::passportElementTypeIdentityCard::ID: return SecureValueType::IdentityCard; - case td_api::passportDataTypeInternalPassport::ID: + case td_api::passportElementTypeInternalPassport::ID: return SecureValueType::InternalPassport; - case td_api::passportDataTypeAddress::ID: + case td_api::passportElementTypeAddress::ID: return SecureValueType::Address; - case td_api::passportDataTypeUtilityBill::ID: + case td_api::passportElementTypeUtilityBill::ID: return SecureValueType::UtilityBill; - case td_api::passportDataTypeBankStatement::ID: + case td_api::passportElementTypeBankStatement::ID: return SecureValueType::BankStatement; - case td_api::passportDataTypeRentalAgreement::ID: + case td_api::passportElementTypeRentalAgreement::ID: return SecureValueType::RentalAgreement; - case td_api::passportDataTypePassportRegistration::ID: + case td_api::passportElementTypePassportRegistration::ID: return SecureValueType::PassportRegistration; - case td_api::passportDataTypeTemporaryRegistration::ID: + case td_api::passportElementTypeTemporaryRegistration::ID: return SecureValueType::TemporaryRegistration; - case td_api::passportDataTypePhoneNumber::ID: + case td_api::passportElementTypePhoneNumber::ID: return SecureValueType::PhoneNumber; - case td_api::passportDataTypeEmailAddress::ID: + case td_api::passportElementTypeEmailAddress::ID: return SecureValueType::EmailAddress; default: UNREACHABLE(); @@ -141,7 +141,7 @@ static vector unique_types(vector types) { for (size_t i = 0; i < size; i++) { for (size_t j = 0; j < i; j++) { if (types[i] == types[j]) { - LOG(ERROR) << "Have duplicate Passport Data type " << types[i] << " at positions " << i << " and " << j; + LOG(ERROR) << "Have duplicate passport element type " << types[i] << " at positions " << i << " and " << j; types[i--] = types[--size]; break; } @@ -157,38 +157,38 @@ vector get_secure_value_types( } vector get_secure_value_types_td_api( - const vector> &secure_value_types) { + const vector> &secure_value_types) { return unique_types(transform(secure_value_types, get_secure_value_type_td_api)); } -td_api::object_ptr get_passport_data_type_object(SecureValueType type) { +td_api::object_ptr get_passport_element_type_object(SecureValueType type) { switch (type) { case SecureValueType::PersonalDetails: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::Passport: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::DriverLicense: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::IdentityCard: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::InternalPassport: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::Address: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::UtilityBill: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::BankStatement: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::RentalAgreement: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::PassportRegistration: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::TemporaryRegistration: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::PhoneNumber: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::EmailAddress: - return td_api::make_object(); + return td_api::make_object(); case SecureValueType::None: default: UNREACHABLE(); @@ -231,9 +231,9 @@ td_api::object_ptr get_input_secure_value_type(Se } } -vector> get_passport_data_types_object( +vector> get_passport_element_types_object( const vector &types) { - return transform(types, get_passport_data_type_object); + return transform(types, get_passport_element_type_object); } string get_secure_value_data_field_name(SecureValueType type, string field_name) { @@ -528,11 +528,11 @@ vector get_encrypted_secure_values( return results; } -td_api::object_ptr get_encrypted_passport_data_object( +td_api::object_ptr get_encrypted_passport_element_object( FileManager *file_manager, const EncryptedSecureValue &value) { bool is_plain = value.data.hash.empty(); - return td_api::make_object( - get_passport_data_type_object(value.type), is_plain ? string() : value.data.data, + return td_api::make_object( + get_passport_element_type_object(value.type), is_plain ? string() : value.data.data, value.front_side.file.file_id.is_valid() ? get_dated_file_object(file_manager, value.front_side) : nullptr, value.reverse_side.file.file_id.is_valid() ? get_dated_file_object(file_manager, value.reverse_side) : nullptr, value.selfie.file.file_id.is_valid() ? get_dated_file_object(file_manager, value.selfie) : nullptr, @@ -581,10 +581,10 @@ telegram_api::object_ptr get_input_secure_value_ get_input_secure_files_object(file_manager, value.files, input_files), std::move(plain_data)); } -vector> get_encrypted_passport_data_object( +vector> get_encrypted_passport_element_object( FileManager *file_manager, const vector &values) { return transform(values, [file_manager](const EncryptedSecureValue &value) { - return get_encrypted_passport_data_object(file_manager, value); + return get_encrypted_passport_element_object(file_manager, value); }); } @@ -907,89 +907,89 @@ static Status check_email_address(string &email_address) { } Result get_secure_value(FileManager *file_manager, - td_api::object_ptr &&input_passport_data) { - if (input_passport_data == nullptr) { - return Status::Error(400, "InputPassportData must not be empty"); + td_api::object_ptr &&input_passport_element) { + if (input_passport_element == nullptr) { + return Status::Error(400, "InputPassportElement must not be empty"); } SecureValue res; - switch (input_passport_data->get_id()) { - case td_api::inputPassportDataPersonalDetails::ID: { - auto input = td_api::move_object_as(input_passport_data); + switch (input_passport_element->get_id()) { + case td_api::inputPassportElementPersonalDetails::ID: { + auto input = td_api::move_object_as(input_passport_element); res.type = SecureValueType::PersonalDetails; TRY_RESULT(personal_details, get_personal_details(std::move(input->personal_details_))); res.data = std::move(personal_details); break; } - case td_api::inputPassportDataPassport::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementPassport::ID: { + auto input = td_api::move_object_as(input_passport_element); return get_identity_document(SecureValueType::Passport, file_manager, std::move(input->passport_), false); } - case td_api::inputPassportDataDriverLicense::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementDriverLicense::ID: { + auto input = td_api::move_object_as(input_passport_element); return get_identity_document(SecureValueType::DriverLicense, file_manager, std::move(input->driver_license_), true); } - case td_api::inputPassportDataIdentityCard::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementIdentityCard::ID: { + auto input = td_api::move_object_as(input_passport_element); return get_identity_document(SecureValueType::IdentityCard, file_manager, std::move(input->identity_card_), true); } - case td_api::inputPassportDataInternalPassport::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementInternalPassport::ID: { + auto input = td_api::move_object_as(input_passport_element); return get_identity_document(SecureValueType::InternalPassport, file_manager, std::move(input->internal_passport_), false); } - case td_api::inputPassportDataAddress::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementAddress::ID: { + auto input = td_api::move_object_as(input_passport_element); res.type = SecureValueType::Address; TRY_RESULT(address, get_address(std::move(input->address_))); res.data = address_to_json(address); break; } - case td_api::inputPassportDataUtilityBill::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementUtilityBill::ID: { + auto input = td_api::move_object_as(input_passport_element); res.type = SecureValueType::UtilityBill; TRY_RESULT(files, get_secure_files(file_manager, std::move(input->files_))); res.files = std::move(files); break; } - case td_api::inputPassportDataBankStatement::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementBankStatement::ID: { + auto input = td_api::move_object_as(input_passport_element); res.type = SecureValueType::BankStatement; TRY_RESULT(files, get_secure_files(file_manager, std::move(input->files_))); res.files = std::move(files); break; } - case td_api::inputPassportDataRentalAgreement::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementRentalAgreement::ID: { + auto input = td_api::move_object_as(input_passport_element); res.type = SecureValueType::RentalAgreement; TRY_RESULT(files, get_secure_files(file_manager, std::move(input->files_))); res.files = std::move(files); break; } - case td_api::inputPassportDataPassportRegistration::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementPassportRegistration::ID: { + auto input = td_api::move_object_as(input_passport_element); res.type = SecureValueType::PassportRegistration; TRY_RESULT(files, get_secure_files(file_manager, std::move(input->files_))); res.files = std::move(files); break; } - case td_api::inputPassportDataTemporaryRegistration::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementTemporaryRegistration::ID: { + auto input = td_api::move_object_as(input_passport_element); res.type = SecureValueType::TemporaryRegistration; TRY_RESULT(files, get_secure_files(file_manager, std::move(input->files_))); res.files = std::move(files); break; } - case td_api::inputPassportDataPhoneNumber::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementPhoneNumber::ID: { + auto input = td_api::move_object_as(input_passport_element); res.type = SecureValueType::PhoneNumber; TRY_STATUS(check_phone_number(input->phone_number_)); res.data = std::move(input->phone_number_); break; } - case td_api::inputPassportDataEmailAddress::ID: { - auto input = td_api::move_object_as(input_passport_data); + case td_api::inputPassportElementEmailAddress::ID: { + auto input = td_api::move_object_as(input_passport_element); res.type = SecureValueType::EmailAddress; TRY_STATUS(check_email_address(input->email_address_)); res.data = std::move(input->email_address_); @@ -1001,32 +1001,32 @@ Result get_secure_value(FileManager *file_manager, return res; } -Result> get_passport_data_object(FileManager *file_manager, - const SecureValue &value) { +Result> get_passport_element_object(FileManager *file_manager, + const SecureValue &value) { switch (value.type) { case SecureValueType::PersonalDetails: { TRY_RESULT(personal_details, get_personal_details_object(value.data)); - return td_api::make_object(std::move(personal_details)); + return td_api::make_object(std::move(personal_details)); } case SecureValueType::Passport: { TRY_RESULT(passport, get_identity_document_object(file_manager, value)); - return td_api::make_object(std::move(passport)); + return td_api::make_object(std::move(passport)); } case SecureValueType::DriverLicense: { TRY_RESULT(driver_license, get_identity_document_object(file_manager, value)); - return td_api::make_object(std::move(driver_license)); + return td_api::make_object(std::move(driver_license)); } case SecureValueType::IdentityCard: { TRY_RESULT(identity_card, get_identity_document_object(file_manager, value)); - return td_api::make_object(std::move(identity_card)); + return td_api::make_object(std::move(identity_card)); } case SecureValueType::InternalPassport: { TRY_RESULT(internal_passport, get_identity_document_object(file_manager, value)); - return td_api::make_object(std::move(internal_passport)); + return td_api::make_object(std::move(internal_passport)); } case SecureValueType::Address: { TRY_RESULT(address, address_from_json(value.data)); - return td_api::make_object(get_address_object(address)); + return td_api::make_object(get_address_object(address)); } case SecureValueType::UtilityBill: case SecureValueType::BankStatement: @@ -1036,27 +1036,27 @@ Result> get_passport_data_object(FileMa auto files = transform( value.files, [file_manager](const DatedFile &file) { return get_dated_file_object(file_manager, file); }); if (value.type == SecureValueType::UtilityBill) { - return td_api::make_object(std::move(files)); + return td_api::make_object(std::move(files)); } if (value.type == SecureValueType::BankStatement) { - return td_api::make_object(std::move(files)); + return td_api::make_object(std::move(files)); } if (value.type == SecureValueType::RentalAgreement) { - return td_api::make_object(std::move(files)); + return td_api::make_object(std::move(files)); } if (value.type == SecureValueType::PassportRegistration) { - return td_api::make_object(std::move(files)); + return td_api::make_object(std::move(files)); } if (value.type == SecureValueType::TemporaryRegistration) { - return td_api::make_object(std::move(files)); + return td_api::make_object(std::move(files)); } UNREACHABLE(); break; } case SecureValueType::PhoneNumber: - return td_api::make_object(value.data); + return td_api::make_object(value.data); case SecureValueType::EmailAddress: - return td_api::make_object(value.data); + return td_api::make_object(value.data); case SecureValueType::None: default: UNREACHABLE(); @@ -1064,21 +1064,21 @@ Result> get_passport_data_object(FileMa } } -td_api::object_ptr get_all_passport_data_object(FileManager *file_manager, - const vector &values) { - vector> result; +td_api::object_ptr get_passport_elements_object(FileManager *file_manager, + const vector &values) { + vector> result; result.reserve(values.size()); for (auto &value : values) { - auto r_obj = get_passport_data_object(file_manager, value); + auto r_obj = get_passport_element_object(file_manager, value); if (r_obj.is_error()) { - LOG(ERROR) << "Can't get passport data object: " << r_obj.error(); + LOG(ERROR) << "Can't get passport element object: " << r_obj.error(); continue; } result.push_back(r_obj.move_as_ok()); } - return td_api::make_object(std::move(result)); + return td_api::make_object(std::move(result)); } static Result> decrypt_secure_file( @@ -1128,7 +1128,7 @@ Result decrypt_secure_value(FileManager *file_manage res_credentials.hash = encrypted_secure_value.hash; switch (encrypted_secure_value.type) { case SecureValueType::None: - return Status::Error("Receive invalid Telegram Passport data"); + return Status::Error("Receive invalid Telegram Passport element"); case SecureValueType::EmailAddress: case SecureValueType::PhoneNumber: res.data = encrypted_secure_value.data.data; diff --git a/td/telegram/SecureValue.h b/td/telegram/SecureValue.h index 7919ac23e..09495a224 100644 --- a/td/telegram/SecureValue.h +++ b/td/telegram/SecureValue.h @@ -44,17 +44,17 @@ enum class SecureValueType : int32 { StringBuilder &operator<<(StringBuilder &string_builder, const SecureValueType &type); SecureValueType get_secure_value_type(const tl_object_ptr &secure_value_type); -SecureValueType get_secure_value_type_td_api(const tl_object_ptr &passport_data_type); +SecureValueType get_secure_value_type_td_api(const tl_object_ptr &passport_element_type); vector get_secure_value_types( const vector> &secure_value_types); vector get_secure_value_types_td_api( - const vector> &secure_value_types); + const vector> &secure_value_types); -td_api::object_ptr get_passport_data_type_object(SecureValueType type); +td_api::object_ptr get_passport_element_type_object(SecureValueType type); td_api::object_ptr get_input_secure_value_type(SecureValueType type); -vector> get_passport_data_types_object( +vector> get_passport_element_types_object( const vector &types); string get_secure_value_data_field_name(SecureValueType type, string field_name); @@ -125,13 +125,13 @@ EncryptedSecureValue get_encrypted_secure_value(FileManager *file_manager, vector get_encrypted_secure_values( FileManager *file_manager, vector> &&secure_values); -td_api::object_ptr get_encrypted_passport_data_object(FileManager *file_manager, - const EncryptedSecureValue &value); +td_api::object_ptr get_encrypted_passport_element_object( + FileManager *file_manager, const EncryptedSecureValue &value); telegram_api::object_ptr get_input_secure_value_object( FileManager *file_manager, const EncryptedSecureValue &value, vector &input_files, optional &front_side, optional &reverse_side, optional &selfie); -vector> get_encrypted_passport_data_object( +vector> get_encrypted_passport_element_object( FileManager *file_manager, const vector &values); struct EncryptedSecureCredentials { @@ -189,13 +189,13 @@ struct SecureValueWithCredentials { }; Result get_secure_value(FileManager *file_manager, - td_api::object_ptr &&input_passport_data); + td_api::object_ptr &&input_passport_element); -Result> get_passport_data_object(FileManager *file_manager, - const SecureValue &value); +Result> get_passport_element_object(FileManager *file_manager, + const SecureValue &value); -td_api::object_ptr get_all_passport_data_object(FileManager *file_manager, - const vector &values); +td_api::object_ptr get_passport_elements_object(FileManager *file_manager, + const vector &values); Result decrypt_secure_value(FileManager *file_manager, const secure_storage::Secret &secret, const EncryptedSecureValue &encrypted_secure_value); diff --git a/td/telegram/Td.cpp b/td/telegram/Td.cpp index 1bec26e9c..ba17a1303 100644 --- a/td/telegram/Td.cpp +++ b/td/telegram/Td.cpp @@ -6304,7 +6304,7 @@ void Td::on_request(uint64 id, const td_api::deleteSavedCredentials &request) { delete_saved_credentials(std::move(promise)); } -void Td::on_request(uint64 id, td_api::getPassportData &request) { +void Td::on_request(uint64 id, td_api::getPassportElement &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.password_); if (request.type_ == nullptr) { @@ -6315,7 +6315,7 @@ void Td::on_request(uint64 id, td_api::getPassportData &request) { get_secure_value_type_td_api(request.type_), std::move(promise)); } -void Td::on_request(uint64 id, td_api::getAllPassportData &request) { +void Td::on_request(uint64 id, td_api::getAllPassportElements &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.password_); CREATE_REQUEST_PROMISE(); @@ -6323,11 +6323,11 @@ void Td::on_request(uint64 id, td_api::getAllPassportData &request) { std::move(promise)); } -void Td::on_request(uint64 id, td_api::setPassportData &request) { +void Td::on_request(uint64 id, td_api::setPassportElement &request) { CHECK_IS_USER(); CLEAN_INPUT_STRING(request.password_); CREATE_REQUEST_PROMISE(); - auto r_secure_value = get_secure_value(file_manager_.get(), std::move(request.data_)); + auto r_secure_value = get_secure_value(file_manager_.get(), std::move(request.element_)); if (r_secure_value.is_error()) { return promise.set_error(r_secure_value.move_as_error()); } @@ -6335,7 +6335,7 @@ void Td::on_request(uint64 id, td_api::setPassportData &request) { r_secure_value.move_as_ok(), std::move(promise)); } -void Td::on_request(uint64 id, const td_api::deletePassportData &request) { +void Td::on_request(uint64 id, const td_api::deletePassportElement &request) { CHECK_IS_USER(); if (request.type_ == nullptr) { return send_error_raw(id, 400, "Type must not be empty"); @@ -6345,7 +6345,7 @@ void Td::on_request(uint64 id, const td_api::deletePassportData &request) { std::move(promise)); } -void Td::on_request(uint64 id, td_api::setPassportDataErrors &request) { +void Td::on_request(uint64 id, td_api::setPassportElementErrors &request) { CHECK_IS_BOT(); UserId user_id(request.user_id_); auto input_user = contacts_manager_->get_input_user(user_id); diff --git a/td/telegram/Td.h b/td/telegram/Td.h index 42b47c53a..99a3a2967 100644 --- a/td/telegram/Td.h +++ b/td/telegram/Td.h @@ -789,15 +789,15 @@ class Td final : public NetQueryCallback { void on_request(uint64 id, const td_api::deleteSavedCredentials &request); - void on_request(uint64 id, td_api::getPassportData &request); + void on_request(uint64 id, td_api::getPassportElement &request); - void on_request(uint64 id, td_api::getAllPassportData &request); + void on_request(uint64 id, td_api::getAllPassportElements &request); - void on_request(uint64 id, td_api::setPassportData &request); + void on_request(uint64 id, td_api::setPassportElement &request); - void on_request(uint64 id, const td_api::deletePassportData &request); + void on_request(uint64 id, const td_api::deletePassportElement &request); - void on_request(uint64 id, td_api::setPassportDataErrors &request); + void on_request(uint64 id, td_api::setPassportElementErrors &request); void on_request(uint64 id, td_api::sendPhoneNumberVerificationCode &request); diff --git a/td/telegram/cli.cpp b/td/telegram/cli.cpp index 70d6af66e..9bc8f10b7 100644 --- a/td/telegram/cli.cpp +++ b/td/telegram/cli.cpp @@ -1031,46 +1031,46 @@ class CliClient final : public Actor { return nullptr; } - static tl_object_ptr as_passport_data_type(Slice passport_data_type) { - if (passport_data_type == "address" || passport_data_type == "a") { - return make_tl_object(); + static tl_object_ptr as_passport_element_type(Slice passport_element_type) { + if (passport_element_type == "address" || passport_element_type == "a") { + return make_tl_object(); } - if (passport_data_type == "email" || passport_data_type == "e") { - return make_tl_object(); + if (passport_element_type == "email" || passport_element_type == "e") { + return make_tl_object(); } - if (passport_data_type == "phone" || passport_data_type == "p") { - return make_tl_object(); + if (passport_element_type == "phone" || passport_element_type == "p") { + return make_tl_object(); } - if (passport_data_type == "pd") { - return make_tl_object(); + if (passport_element_type == "pd") { + return make_tl_object(); } - if (passport_data_type == "dl") { - return make_tl_object(); + if (passport_element_type == "dl") { + return make_tl_object(); } - if (passport_data_type == "ip") { - return make_tl_object(); + if (passport_element_type == "ip") { + return make_tl_object(); } - if (passport_data_type == "ic") { - return make_tl_object(); + if (passport_element_type == "ic") { + return make_tl_object(); } - if (passport_data_type == "ra") { - return make_tl_object(); + if (passport_element_type == "ra") { + return make_tl_object(); } - if (passport_data_type == "pr") { - return make_tl_object(); + if (passport_element_type == "pr") { + return make_tl_object(); } - if (passport_data_type == "tr") { - return make_tl_object(); + if (passport_element_type == "tr") { + return make_tl_object(); } - return make_tl_object(); + return make_tl_object(); } - static auto as_passport_data_types(Slice types, char delimiter = ',') { - return transform(full_split(types, delimiter), [](Slice str) { return as_passport_data_type(str); }); + static auto as_passport_element_types(Slice types, char delimiter = ',') { + return transform(full_split(types, delimiter), [](Slice str) { return as_passport_element_type(str); }); } - static tl_object_ptr as_input_passport_data(string passport_data_type, string arg, - bool with_selfie) { + static tl_object_ptr as_input_passport_element(string passport_element_type, string arg, + bool with_selfie) { vector> input_files; td_api::object_ptr selfie; if (!arg.empty()) { @@ -1084,37 +1084,38 @@ class CliClient final : public Actor { input_files.push_back(as_input_file(file)); } } - if (passport_data_type == "address" || passport_data_type == "a") { - return make_tl_object( + if (passport_element_type == "address" || passport_element_type == "a") { + return make_tl_object( make_tl_object("US", "CA", "Los Angeles", "Washington", "", "90001")); - } else if (passport_data_type == "email" || passport_data_type == "e") { - return make_tl_object(arg); - } else if (passport_data_type == "phone" || passport_data_type == "p") { - return make_tl_object(arg); - } else if (passport_data_type == "pd") { - return make_tl_object(make_tl_object( + } else if (passport_element_type == "email" || passport_element_type == "e") { + return make_tl_object(arg); + } else if (passport_element_type == "phone" || passport_element_type == "p") { + return make_tl_object(arg); + } else if (passport_element_type == "pd") { + return make_tl_object(make_tl_object( "Mike", "Towers", make_tl_object(29, 2, 2000), "male", "US", "GB")); - } else if (passport_data_type == "driver_license" || passport_data_type == "dl") { + } else if (passport_element_type == "driver_license" || passport_element_type == "dl") { if (input_files.size() == 2) { - return make_tl_object(make_tl_object( + return make_tl_object(make_tl_object( "1234567890", make_tl_object(1, 3, 2029), std::move(input_files[0]), std::move(input_files[1]), std::move(selfie))); } - } else if (passport_data_type == "identity_card" || passport_data_type == "ic") { + } else if (passport_element_type == "identity_card" || passport_element_type == "ic") { if (input_files.size() == 2) { - return make_tl_object(make_tl_object( + return make_tl_object(make_tl_object( "1234567890", nullptr, std::move(input_files[0]), std::move(input_files[1]), std::move(selfie))); } - } else if (passport_data_type == "internal_passport" || passport_data_type == "ip") { + } else if (passport_element_type == "internal_passport" || passport_element_type == "ip") { if (input_files.size() == 1) { - return make_tl_object(make_tl_object( - "1234567890", nullptr, std::move(input_files[0]), nullptr, std::move(selfie))); + return make_tl_object( + make_tl_object("1234567890", nullptr, std::move(input_files[0]), nullptr, + std::move(selfie))); } - } else if (passport_data_type == "rental_aggrement" || passport_data_type == "ra") { - return make_tl_object(std::move(input_files)); + } else if (passport_element_type == "rental_aggrement" || passport_element_type == "ra") { + return make_tl_object(std::move(input_files)); } - LOG(ERROR) << "Unsupported passport data type " << passport_data_type; + LOG(ERROR) << "Unsupported passport element type " << passport_element_type; return nullptr; } @@ -1272,7 +1273,7 @@ class CliClient final : public Actor { std::tie(password, args) = split(args); std::tie(id, types) = split(args); send_request(make_tl_object(to_integer(id), - as_passport_data_types(types), password)); + as_passport_element_types(types), password)); } else if (op == "spnvc" || op == "SendPhoneNumberVerificationCode") { send_request(make_tl_object(args, false, false)); } else if (op == "cpnvc" || op == "CheckPhoneNumberVerificationCode") { @@ -1306,25 +1307,26 @@ class CliClient final : public Actor { send_request(make_tl_object()); } else if (op == "ctp" || op == "CreateTemporaryPassword") { send_request(make_tl_object(args, 60 * 6)); - } else if (op == "gpd") { + } else if (op == "gpe") { string password; - string passport_data_type; - std::tie(password, passport_data_type) = split(args); - send_request(make_tl_object(as_passport_data_type(passport_data_type), password)); - } else if (op == "gapd") { + string passport_element_type; + std::tie(password, passport_element_type) = split(args); + send_request( + make_tl_object(as_passport_element_type(passport_element_type), password)); + } else if (op == "gape") { string password = args; - send_request(make_tl_object(password)); - } else if (op == "spd" || op == "spds") { + send_request(make_tl_object(password)); + } else if (op == "spe" || op == "spes") { string password; - string passport_data_type; + string passport_element_type; string arg; std::tie(password, args) = split(args); - std::tie(passport_data_type, arg) = split(args); - send_request(make_tl_object( - as_input_passport_data(passport_data_type, arg, op == "spds"), password)); - } else if (op == "dpd") { - string passport_data_type = args; - send_request(make_tl_object(as_passport_data_type(passport_data_type))); + std::tie(passport_element_type, arg) = split(args); + send_request(make_tl_object( + as_input_passport_element(passport_element_type, arg, op == "spds"), password)); + } else if (op == "dpe") { + string passport_element_type = args; + send_request(make_tl_object(as_passport_element_type(passport_element_type))); } else if (op == "pdu" || op == "processDcUpdate") { string dc_id; string ip_port;