diff --git a/TelegramCore/GrantSecureIdAccess.swift b/TelegramCore/GrantSecureIdAccess.swift index 55b044c66b..b7a3d0eef8 100644 --- a/TelegramCore/GrantSecureIdAccess.swift +++ b/TelegramCore/GrantSecureIdAccess.swift @@ -132,7 +132,18 @@ private func generateCredentials(values: [SecureIdValueWithContext], opaquePaylo "secret": selfie.secret.base64EncodedString() ] as [String: Any] } - + if let frontside = value.frontSide { + valueDict["front_side"] = [ + "file_hash": frontside.hash.base64EncodedString(), + "secret": frontside.secret.base64EncodedString() + ] as [String: Any] + } + if let backside = value.backSide { + valueDict["reverse_side"] = [ + "file_hash": backside.hash.base64EncodedString(), + "secret": backside.secret.base64EncodedString() + ] as [String: Any] + } if !valueDict.isEmpty { secureData[credentialsValueTypeName(value: value.value)] = valueDict } @@ -191,7 +202,7 @@ public func grantSecureIdAccess(network: Network, peerId: PeerId, publicKey: Str } return network.request(Api.functions.account.acceptAuthorization(botId: peerId.id, scope: scope, publicKey: publicKey, valueHashes: valueHashes, credentials: .secureCredentialsEncrypted(data: Buffer(data: encryptedCredentialsData), hash: Buffer(data: decryptedCredentialsHash), secret: Buffer(data: encryptedSecretData)))) - |> mapError { _ -> GrantSecureIdAccessError in + |> mapError { error -> GrantSecureIdAccessError in return .generic } |> mapToSignal { _ -> Signal in diff --git a/TelegramCore/RequestSecureIdForm.swift b/TelegramCore/RequestSecureIdForm.swift index 7938183c35..38b5909b8e 100644 --- a/TelegramCore/RequestSecureIdForm.swift +++ b/TelegramCore/RequestSecureIdForm.swift @@ -41,7 +41,7 @@ private func parseSecureValueType(_ type: Api.SecureValueType, selfie: Bool) -> case .secureValueTypePassportRegistration: return .passportRegistration case .secureValueTypeTemporaryRegistration: - return .temporaryRegistration(selfie: selfie) + return .temporaryRegistration } } diff --git a/TelegramCore/SecureIdDataTypes.swift b/TelegramCore/SecureIdDataTypes.swift index 9899376dd7..fa3a0624e0 100644 --- a/TelegramCore/SecureIdDataTypes.swift +++ b/TelegramCore/SecureIdDataTypes.swift @@ -1,10 +1,14 @@ import Foundation public struct SecureIdDate: Equatable { - public let timestamp: Int32 - - public init(timestamp: Int32) { - self.timestamp = timestamp + public let day: Int32 + public let month: Int32 + public let year: Int32 + + public init(day: Int32, month: Int32, year: Int32) { + self.day = day + self.month = month + self.year = year } } @@ -66,13 +70,11 @@ private let dateFormatter: DateFormatter = { extension SecureIdDate { init?(serializedString: String) { - guard let date = dateFormatter.date(from: serializedString) else { - return nil - } - self.init(timestamp: Int32(date.timeIntervalSince1970)) + let data = serializedString.components(separatedBy: ".") + self.init(day: Int32(data[0])!, month: Int32(data[1])!, year: Int32(data[2])!) } func serialize() -> String { - return dateFormatter.string(from: Date(timeIntervalSince1970: Double(self.timestamp))) + return "\(day).\(month).\(year)" } } diff --git a/TelegramCore/SecureIdForm.swift b/TelegramCore/SecureIdForm.swift index c7f5a5de28..f53feb2ebb 100644 --- a/TelegramCore/SecureIdForm.swift +++ b/TelegramCore/SecureIdForm.swift @@ -18,7 +18,7 @@ public enum SecureIdRequestedFormField: Equatable { case rentalAgreement case phone case email - case temporaryRegistration(selfie: Bool) + case temporaryRegistration } public struct SecureIdForm: Equatable {