mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-08-26 15:31:12 +00:00
no message
This commit is contained in:
parent
6009a9756c
commit
b6d2a10d12
@ -628,6 +628,12 @@
|
||||
D0E8174A2010E7E300B82BBB /* ChannelAdminEventLogContext.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0E817482010E7E300B82BBB /* ChannelAdminEventLogContext.swift */; };
|
||||
D0E8B8B32044706300605593 /* ForwardGame.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0E8B8B22044706300605593 /* ForwardGame.swift */; };
|
||||
D0E8B8B42044706300605593 /* ForwardGame.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0E8B8B22044706300605593 /* ForwardGame.swift */; };
|
||||
D0EE7FC120986BF400981319 /* SecureIdInternalPassportValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0EE7FC020986BF400981319 /* SecureIdInternalPassportValue.swift */; };
|
||||
D0EE7FC220986BF400981319 /* SecureIdInternalPassportValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0EE7FC020986BF400981319 /* SecureIdInternalPassportValue.swift */; };
|
||||
D0EE7FC420986C5300981319 /* SecureIdPassportRegistrationValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0EE7FC320986C5300981319 /* SecureIdPassportRegistrationValue.swift */; };
|
||||
D0EE7FC520986C5300981319 /* SecureIdPassportRegistrationValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0EE7FC320986C5300981319 /* SecureIdPassportRegistrationValue.swift */; };
|
||||
D0EE7FC72098853100981319 /* SecureIdTemporaryRegistrationValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0EE7FC62098853100981319 /* SecureIdTemporaryRegistrationValue.swift */; };
|
||||
D0EE7FC82098853100981319 /* SecureIdTemporaryRegistrationValue.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0EE7FC62098853100981319 /* SecureIdTemporaryRegistrationValue.swift */; };
|
||||
D0F02CE51E9926C40065DEE2 /* ManagedConfigurationUpdates.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F02CE41E9926C40065DEE2 /* ManagedConfigurationUpdates.swift */; };
|
||||
D0F02CE61E9926C50065DEE2 /* ManagedConfigurationUpdates.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F02CE41E9926C40065DEE2 /* ManagedConfigurationUpdates.swift */; };
|
||||
D0F3A89F1E82C65400B4C64C /* SynchronizeChatInputStateOperation.swift in Sources */ = {isa = PBXBuildFile; fileRef = D0F3A89E1E82C65400B4C64C /* SynchronizeChatInputStateOperation.swift */; };
|
||||
@ -1048,6 +1054,9 @@
|
||||
D0E68768207534C90064BDB2 /* Api0.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Api0.swift; sourceTree = "<group>"; };
|
||||
D0E817482010E7E300B82BBB /* ChannelAdminEventLogContext.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ChannelAdminEventLogContext.swift; sourceTree = "<group>"; };
|
||||
D0E8B8B22044706300605593 /* ForwardGame.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ForwardGame.swift; sourceTree = "<group>"; };
|
||||
D0EE7FC020986BF400981319 /* SecureIdInternalPassportValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureIdInternalPassportValue.swift; sourceTree = "<group>"; };
|
||||
D0EE7FC320986C5300981319 /* SecureIdPassportRegistrationValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureIdPassportRegistrationValue.swift; sourceTree = "<group>"; };
|
||||
D0EE7FC62098853100981319 /* SecureIdTemporaryRegistrationValue.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureIdTemporaryRegistrationValue.swift; sourceTree = "<group>"; };
|
||||
D0F02CE41E9926C40065DEE2 /* ManagedConfigurationUpdates.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManagedConfigurationUpdates.swift; sourceTree = "<group>"; };
|
||||
D0F3A89E1E82C65400B4C64C /* SynchronizeChatInputStateOperation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SynchronizeChatInputStateOperation.swift; sourceTree = "<group>"; };
|
||||
D0F3A8A11E82C65E00B4C64C /* ManagedSynchronizeChatInputStateOperations.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ManagedSynchronizeChatInputStateOperations.swift; sourceTree = "<group>"; };
|
||||
@ -1584,6 +1593,7 @@
|
||||
D093D7ED206413F600BC3599 /* SecureIdDataTypes.swift */,
|
||||
D0E412F3206B9BDC00BEE4A2 /* SecureIdVerificationDocumentReference.swift */,
|
||||
D054648A2073854A002ECC1E /* SecureIdPersonalDetailsValue.swift */,
|
||||
D0EE7FC020986BF400981319 /* SecureIdInternalPassportValue.swift */,
|
||||
D0E412F0206B9BB700BEE4A2 /* SecureIdPassportValue.swift */,
|
||||
D054648D20738626002ECC1E /* SecureIdDriversLicenseValue.swift */,
|
||||
D054649020738653002ECC1E /* SecureIdIDCardValue.swift */,
|
||||
@ -1593,6 +1603,8 @@
|
||||
D054649920738760002ECC1E /* SecureIdRentalAgreementValue.swift */,
|
||||
D093D7F420641A4900BC3599 /* SecureIdPhoneValue.swift */,
|
||||
D093D7F820641AA500BC3599 /* SecureIdEmailValue.swift */,
|
||||
D0EE7FC320986C5300981319 /* SecureIdPassportRegistrationValue.swift */,
|
||||
D0EE7FC62098853100981319 /* SecureIdTemporaryRegistrationValue.swift */,
|
||||
);
|
||||
name = Values;
|
||||
sourceTree = "<group>";
|
||||
@ -1996,6 +2008,7 @@
|
||||
D00D343F1E6ED6E50057B307 /* ConsumableContentMessageAttribute.swift in Sources */,
|
||||
D03B0CE01D62249100955575 /* StoreMessage_Telegram.swift in Sources */,
|
||||
D08774FE1E3E3A3500A97350 /* GlobalNotificationSettings.swift in Sources */,
|
||||
D0EE7FC420986C5300981319 /* SecureIdPassportRegistrationValue.swift in Sources */,
|
||||
D00C7CCF1E3628180080C3D5 /* UpdateCachedChannelParticipants.swift in Sources */,
|
||||
D03B0CB91D62233400955575 /* Either.swift in Sources */,
|
||||
D0D748021E7AE98B00F4B1F6 /* StickerPackInteractiveOperations.swift in Sources */,
|
||||
@ -2022,6 +2035,7 @@
|
||||
D0FC19582020CC4B00FEDBB2 /* TelegramPeerGroupState.swift in Sources */,
|
||||
C205FEA81EB3B75900455808 /* ExportMessageLink.swift in Sources */,
|
||||
D0E305AA1E5BA02D00D7A3A2 /* ChannelBlacklist.swift in Sources */,
|
||||
D0EE7FC72098853100981319 /* SecureIdTemporaryRegistrationValue.swift in Sources */,
|
||||
C22EE61B1E67418000334C38 /* ToggleChannelSignatures.swift in Sources */,
|
||||
D053B3FC1F1651FA00E2D58A /* MonotonicTime.m in Sources */,
|
||||
D073CE601DCB9D14007511FD /* OutgoingMessageInfoAttribute.swift in Sources */,
|
||||
@ -2127,6 +2141,7 @@
|
||||
D042C6831E8D9DF800C863B0 /* Unixtime.swift in Sources */,
|
||||
D0BE383E1E7C5995000079AF /* MediaPool.swift in Sources */,
|
||||
D0C0B58A1ED9DA6B000F4D2C /* ManagedLocalizationUpdatesOperations.swift in Sources */,
|
||||
D0EE7FC120986BF400981319 /* SecureIdInternalPassportValue.swift in Sources */,
|
||||
D03B0D671D631A8B00955575 /* AccountViewTracker.swift in Sources */,
|
||||
D0B843BB1DA7FF30005F29E1 /* NBMetadataCoreTestMapper.m in Sources */,
|
||||
D0E412EA206AD18E00BEE4A2 /* DecryptedResourceData.swift in Sources */,
|
||||
@ -2475,6 +2490,7 @@
|
||||
D050F2601E4A5AD500988324 /* AutoremoveTimeoutMessageAttribute.swift in Sources */,
|
||||
D07E4140208A769D00FCA8F0 /* ProxyServersStatuses.swift in Sources */,
|
||||
D049EAD91E43DAD200A2CD3A /* ManagedRecentStickers.swift in Sources */,
|
||||
D0EE7FC220986BF400981319 /* SecureIdInternalPassportValue.swift in Sources */,
|
||||
D0B418A61D7E0592004562A4 /* CloudFileMediaResource.swift in Sources */,
|
||||
D073CEA51DCBF3F5007511FD /* StickerManagement.swift in Sources */,
|
||||
D03C536D1DAD5CA9004C17B3 /* ApiGroupOrChannel.swift in Sources */,
|
||||
@ -2598,10 +2614,12 @@
|
||||
D050F2641E4A5AEB00988324 /* ManagedSynchronizePinnedChatsOperations.swift in Sources */,
|
||||
D0575AF21E9FFA5D006F2541 /* SynchronizeSavedGifsOperation.swift in Sources */,
|
||||
D0528E661E65C82400E2FEF5 /* UpdateContactName.swift in Sources */,
|
||||
D0EE7FC82098853100981319 /* SecureIdTemporaryRegistrationValue.swift in Sources */,
|
||||
D053B4191F18DE5000E2D58A /* AuthorSignatureMessageAttribute.swift in Sources */,
|
||||
D0F7B1E81E045C87007EB8A5 /* PeerParticipants.swift in Sources */,
|
||||
D0C48F3A1E8138DF0075317D /* ArchivedStickerPacksInfo.swift in Sources */,
|
||||
D049EAD61E43D98500A2CD3A /* RecentMediaItem.swift in Sources */,
|
||||
D0EE7FC520986C5300981319 /* SecureIdPassportRegistrationValue.swift in Sources */,
|
||||
D0C0B58B1ED9DA6B000F4D2C /* ManagedLocalizationUpdatesOperations.swift in Sources */,
|
||||
D0B844331DAB91E0005F29E1 /* NBPhoneNumber.m in Sources */,
|
||||
D001F3F51E128A1C007A8C60 /* PendingMessageManager.swift in Sources */,
|
||||
|
@ -148,7 +148,7 @@ public class UnauthorizedAccount {
|
||||
return self.postbox.modify { modifier -> (LocalizationSettings?, ProxySettings?) in
|
||||
return (modifier.getPreferencesEntry(key: PreferencesKeys.localizationSettings) as? LocalizationSettings, modifier.getPreferencesEntry(key: PreferencesKeys.proxySettings) as? ProxySettings)
|
||||
} |> mapToSignal { (localizationSettings, proxySettings) -> Signal<UnauthorizedAccount, NoError> in
|
||||
return initializedNetwork(arguments: self.networkArguments, supplementary: false, datacenterId: Int(masterDatacenterId), keychain: keychain, basePath: self.basePath, testingEnvironment: self.testingEnvironment, languageCode: localizationSettings?.languageCode, proxySettings: proxySettings)
|
||||
return initializedNetwork(arguments: self.networkArguments, supplementary: false, datacenterId: Int(masterDatacenterId), keychain: keychain, basePath: self.basePath, testingEnvironment: self.testingEnvironment, languageCode: localizationSettings?.languageCode, proxySettings: proxySettings, phoneNumber: nil)
|
||||
|> map { network in
|
||||
let updated = UnauthorizedAccount(networkArguments: self.networkArguments, id: self.id, rootPath: self.rootPath, basePath: self.basePath, testingEnvironment: self.testingEnvironment, postbox: self.postbox, network: network)
|
||||
updated.shouldBeServiceTaskMaster.set(self.shouldBeServiceTaskMaster.get())
|
||||
@ -313,21 +313,26 @@ public func accountWithId(networkArguments: NetworkInitializationArguments, id:
|
||||
if let accountState = accountState {
|
||||
switch accountState {
|
||||
case let unauthorizedState as UnauthorizedAccountState:
|
||||
return initializedNetwork(arguments: networkArguments, supplementary: supplementary, datacenterId: Int(unauthorizedState.masterDatacenterId), keychain: keychain, basePath: path, testingEnvironment: testingEnvironment, languageCode: localizationSettings?.languageCode, proxySettings: proxySettings)
|
||||
return initializedNetwork(arguments: networkArguments, supplementary: supplementary, datacenterId: Int(unauthorizedState.masterDatacenterId), keychain: keychain, basePath: path, testingEnvironment: testingEnvironment, languageCode: localizationSettings?.languageCode, proxySettings: proxySettings, phoneNumber: nil)
|
||||
|> map { network -> AccountResult in
|
||||
return .unauthorized(UnauthorizedAccount(networkArguments: networkArguments, id: id, rootPath: rootPath, basePath: path, testingEnvironment: testingEnvironment, postbox: postbox, network: network, shouldKeepAutoConnection: shouldKeepAutoConnection))
|
||||
}
|
||||
case let authorizedState as AuthorizedAccountState:
|
||||
return initializedNetwork(arguments: networkArguments, supplementary: supplementary, datacenterId: Int(authorizedState.masterDatacenterId), keychain: keychain, basePath: path, testingEnvironment: testingEnvironment, languageCode: localizationSettings?.languageCode, proxySettings: proxySettings)
|
||||
return postbox.modify { modifier -> String? in
|
||||
return (modifier.getPeer(authorizedState.peerId) as? TelegramUser)?.phone
|
||||
}
|
||||
|> mapToSignal { phoneNumber in
|
||||
return initializedNetwork(arguments: networkArguments, supplementary: supplementary, datacenterId: Int(authorizedState.masterDatacenterId), keychain: keychain, basePath: path, testingEnvironment: testingEnvironment, languageCode: localizationSettings?.languageCode, proxySettings: proxySettings, phoneNumber: phoneNumber)
|
||||
|> map { network -> AccountResult in
|
||||
return .authorized(Account(id: id, basePath: path, testingEnvironment: testingEnvironment, postbox: postbox, network: network, peerId: authorizedState.peerId, auxiliaryMethods: auxiliaryMethods))
|
||||
}
|
||||
}
|
||||
case _:
|
||||
assertionFailure("Unexpected accountState \(accountState)")
|
||||
}
|
||||
}
|
||||
|
||||
return initializedNetwork(arguments: networkArguments, supplementary: supplementary, datacenterId: 2, keychain: keychain, basePath: path, testingEnvironment: testingEnvironment, languageCode: localizationSettings?.languageCode, proxySettings: proxySettings)
|
||||
return initializedNetwork(arguments: networkArguments, supplementary: supplementary, datacenterId: 2, keychain: keychain, basePath: path, testingEnvironment: testingEnvironment, languageCode: localizationSettings?.languageCode, proxySettings: proxySettings, phoneNumber: nil)
|
||||
|> map { network -> AccountResult in
|
||||
return .unauthorized(UnauthorizedAccount(networkArguments: networkArguments, id: id, rootPath: rootPath, basePath: path, testingEnvironment: testingEnvironment, postbox: postbox, network: network, shouldKeepAutoConnection: shouldKeepAutoConnection))
|
||||
}
|
||||
|
@ -330,7 +330,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[649453030] = { return Api.messages.MessageEditData.parse_messageEditData($0) }
|
||||
dict[-886477832] = { return Api.LabeledPrice.parse_labeledPrice($0) }
|
||||
dict[-438840932] = { return Api.messages.ChatFull.parse_chatFull($0) }
|
||||
dict[-1059442448] = { return Api.InputSecureValue.parse_inputSecureValue($0) }
|
||||
dict[108557032] = { return Api.InputSecureValue.parse_inputSecureValue($0) }
|
||||
dict[1722786150] = { return Api.help.DeepLinkInfo.parse_deepLinkInfoEmpty($0) }
|
||||
dict[1783556146] = { return Api.help.DeepLinkInfo.parse_deepLinkInfo($0) }
|
||||
dict[-313079300] = { return Api.account.WebAuthorizations.parse_webAuthorizations($0) }
|
||||
@ -347,9 +347,11 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-1038136962] = { return Api.EncryptedFile.parse_encryptedFileEmpty($0) }
|
||||
dict[1248893260] = { return Api.EncryptedFile.parse_encryptedFile($0) }
|
||||
dict[-391902247] = { return Api.SecureValueError.parse_secureValueErrorData($0) }
|
||||
dict[12467706] = { return Api.SecureValueError.parse_secureValueErrorFrontSide($0) }
|
||||
dict[-2037765467] = { return Api.SecureValueError.parse_secureValueErrorReverseSide($0) }
|
||||
dict[-449327402] = { return Api.SecureValueError.parse_secureValueErrorSelfie($0) }
|
||||
dict[2054162547] = { return Api.SecureValueError.parse_secureValueErrorFile($0) }
|
||||
dict[1717706985] = { return Api.SecureValueError.parse_secureValueErrorFiles($0) }
|
||||
dict[-449327402] = { return Api.SecureValueError.parse_secureValueErrorSelfie($0) }
|
||||
dict[1489977929] = { return Api.ChannelBannedRights.parse_channelBannedRights($0) }
|
||||
dict[-1613493288] = { return Api.NotifyPeer.parse_notifyPeer($0) }
|
||||
dict[-1261946036] = { return Api.NotifyPeer.parse_notifyUsers($0) }
|
||||
@ -365,7 +367,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1493171408] = { return Api.HighScore.parse_highScore($0) }
|
||||
dict[-305282981] = { return Api.TopPeer.parse_topPeer($0) }
|
||||
dict[986597452] = { return Api.contacts.Link.parse_link($0) }
|
||||
dict[-331270968] = { return Api.SecureValue.parse_secureValue($0) }
|
||||
dict[-1263225191] = { return Api.SecureValue.parse_secureValue($0) }
|
||||
dict[-316748368] = { return Api.SecureValueHash.parse_secureValueHash($0) }
|
||||
dict[1444661369] = { return Api.ContactBlocked.parse_contactBlocked($0) }
|
||||
dict[-2128698738] = { return Api.auth.CheckedPhone.parse_checkedPhone($0) }
|
||||
@ -543,10 +545,13 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[1034709504] = { return Api.SecureValueType.parse_secureValueTypePassport($0) }
|
||||
dict[115615172] = { return Api.SecureValueType.parse_secureValueTypeDriverLicense($0) }
|
||||
dict[-1596951477] = { return Api.SecureValueType.parse_secureValueTypeIdentityCard($0) }
|
||||
dict[-1717268701] = { return Api.SecureValueType.parse_secureValueTypeInternalPassport($0) }
|
||||
dict[-874308058] = { return Api.SecureValueType.parse_secureValueTypeAddress($0) }
|
||||
dict[-63531698] = { return Api.SecureValueType.parse_secureValueTypeUtilityBill($0) }
|
||||
dict[-1995211763] = { return Api.SecureValueType.parse_secureValueTypeBankStatement($0) }
|
||||
dict[-1954007928] = { return Api.SecureValueType.parse_secureValueTypeRentalAgreement($0) }
|
||||
dict[-1713143702] = { return Api.SecureValueType.parse_secureValueTypePassportRegistration($0) }
|
||||
dict[-368907213] = { return Api.SecureValueType.parse_secureValueTypeTemporaryRegistration($0) }
|
||||
dict[-1289704741] = { return Api.SecureValueType.parse_secureValueTypePhone($0) }
|
||||
dict[-1908627474] = { return Api.SecureValueType.parse_secureValueTypeEmail($0) }
|
||||
dict[1587643126] = { return Api.account.Password.parse_noPassword($0) }
|
||||
|
@ -7110,24 +7110,26 @@ public extension Api {
|
||||
|
||||
}
|
||||
public enum InputSecureValue {
|
||||
case inputSecureValue(flags: Int32, type: Api.SecureValueType, data: Api.SecureData?, files: [Api.InputSecureFile]?, plainData: Api.SecurePlainData?, selfie: Api.InputSecureFile?)
|
||||
case inputSecureValue(flags: Int32, type: Api.SecureValueType, data: Api.SecureData?, frontSide: Api.InputSecureFile?, reverseSide: Api.InputSecureFile?, selfie: Api.InputSecureFile?, files: [Api.InputSecureFile]?, plainData: Api.SecurePlainData?)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .inputSecureValue(let flags, let type, let data, let files, let plainData, let selfie):
|
||||
case .inputSecureValue(let flags, let type, let data, let frontSide, let reverseSide, let selfie, let files, let plainData):
|
||||
if boxed {
|
||||
buffer.appendInt32(-1059442448)
|
||||
buffer.appendInt32(108557032)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
type.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 0) != 0 {data!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261)
|
||||
if Int(flags) & Int(1 << 1) != 0 {frontSide!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 2) != 0 {reverseSide!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 3) != 0 {selfie!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 4) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(files!.count))
|
||||
for item in files! {
|
||||
item.serialize(buffer, true)
|
||||
}}
|
||||
if Int(flags) & Int(1 << 2) != 0 {plainData!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 3) != 0 {selfie!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 5) != 0 {plainData!.serialize(buffer, true)}
|
||||
break
|
||||
}
|
||||
}
|
||||
@ -7143,26 +7145,36 @@ public extension Api {
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
|
||||
_3 = Api.parse(reader, signature: signature) as? Api.SecureData
|
||||
} }
|
||||
var _4: [Api.InputSecureFile]?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputSecureFile.self)
|
||||
var _4: Api.InputSecureFile?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
|
||||
_4 = Api.parse(reader, signature: signature) as? Api.InputSecureFile
|
||||
} }
|
||||
var _5: Api.SecurePlainData?
|
||||
var _5: Api.InputSecureFile?
|
||||
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
|
||||
_5 = Api.parse(reader, signature: signature) as? Api.SecurePlainData
|
||||
_5 = Api.parse(reader, signature: signature) as? Api.InputSecureFile
|
||||
} }
|
||||
var _6: Api.InputSecureFile?
|
||||
if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() {
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.InputSecureFile
|
||||
} }
|
||||
var _7: [Api.InputSecureFile]?
|
||||
if Int(_1!) & Int(1 << 4) != 0 {if let _ = reader.readInt32() {
|
||||
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputSecureFile.self)
|
||||
} }
|
||||
var _8: Api.SecurePlainData?
|
||||
if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() {
|
||||
_8 = Api.parse(reader, signature: signature) as? Api.SecurePlainData
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 {
|
||||
return Api.InputSecureValue.inputSecureValue(flags: _1!, type: _2!, data: _3, files: _4, plainData: _5, selfie: _6)
|
||||
let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil
|
||||
let _c8 = (Int(_1!) & Int(1 << 5) == 0) || _8 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
|
||||
return Api.InputSecureValue.inputSecureValue(flags: _1!, type: _2!, data: _3, frontSide: _4, reverseSide: _5, selfie: _6, files: _7, plainData: _8)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -7399,9 +7411,11 @@ public extension Api {
|
||||
}
|
||||
public enum SecureValueError {
|
||||
case secureValueErrorData(type: Api.SecureValueType, dataHash: Buffer, field: String, text: String)
|
||||
case secureValueErrorFrontSide(type: Api.SecureValueType, fileHash: Buffer, text: String)
|
||||
case secureValueErrorReverseSide(type: Api.SecureValueType, fileHash: Buffer, text: String)
|
||||
case secureValueErrorSelfie(type: Api.SecureValueType, fileHash: Buffer, text: String)
|
||||
case secureValueErrorFile(type: Api.SecureValueType, fileHash: Buffer, text: String)
|
||||
case secureValueErrorFiles(type: Api.SecureValueType, fileHash: [Buffer], text: String)
|
||||
case secureValueErrorSelfie(type: Api.SecureValueType, fileHash: Buffer, text: String)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
@ -7414,6 +7428,30 @@ public extension Api {
|
||||
serializeString(field, buffer: buffer, boxed: false)
|
||||
serializeString(text, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .secureValueErrorFrontSide(let type, let fileHash, let text):
|
||||
if boxed {
|
||||
buffer.appendInt32(12467706)
|
||||
}
|
||||
type.serialize(buffer, true)
|
||||
serializeBytes(fileHash, buffer: buffer, boxed: false)
|
||||
serializeString(text, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .secureValueErrorReverseSide(let type, let fileHash, let text):
|
||||
if boxed {
|
||||
buffer.appendInt32(-2037765467)
|
||||
}
|
||||
type.serialize(buffer, true)
|
||||
serializeBytes(fileHash, buffer: buffer, boxed: false)
|
||||
serializeString(text, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .secureValueErrorSelfie(let type, let fileHash, let text):
|
||||
if boxed {
|
||||
buffer.appendInt32(-449327402)
|
||||
}
|
||||
type.serialize(buffer, true)
|
||||
serializeBytes(fileHash, buffer: buffer, boxed: false)
|
||||
serializeString(text, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .secureValueErrorFile(let type, let fileHash, let text):
|
||||
if boxed {
|
||||
buffer.appendInt32(2054162547)
|
||||
@ -7434,14 +7472,6 @@ public extension Api {
|
||||
}
|
||||
serializeString(text, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .secureValueErrorSelfie(let type, let fileHash, let text):
|
||||
if boxed {
|
||||
buffer.appendInt32(-449327402)
|
||||
}
|
||||
type.serialize(buffer, true)
|
||||
serializeBytes(fileHash, buffer: buffer, boxed: false)
|
||||
serializeString(text, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
@ -7467,6 +7497,63 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
static func parse_secureValueErrorFrontSide(_ reader: BufferReader) -> SecureValueError? {
|
||||
var _1: Api.SecureValueType?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.SecureValueType
|
||||
}
|
||||
var _2: Buffer?
|
||||
_2 = parseBytes(reader)
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.SecureValueError.secureValueErrorFrontSide(type: _1!, fileHash: _2!, text: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
static func parse_secureValueErrorReverseSide(_ reader: BufferReader) -> SecureValueError? {
|
||||
var _1: Api.SecureValueType?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.SecureValueType
|
||||
}
|
||||
var _2: Buffer?
|
||||
_2 = parseBytes(reader)
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.SecureValueError.secureValueErrorReverseSide(type: _1!, fileHash: _2!, text: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
static func parse_secureValueErrorSelfie(_ reader: BufferReader) -> SecureValueError? {
|
||||
var _1: Api.SecureValueType?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.SecureValueType
|
||||
}
|
||||
var _2: Buffer?
|
||||
_2 = parseBytes(reader)
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.SecureValueError.secureValueErrorSelfie(type: _1!, fileHash: _2!, text: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
static func parse_secureValueErrorFile(_ reader: BufferReader) -> SecureValueError? {
|
||||
var _1: Api.SecureValueType?
|
||||
if let signature = reader.readInt32() {
|
||||
@ -7507,25 +7594,6 @@ public extension Api {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
static func parse_secureValueErrorSelfie(_ reader: BufferReader) -> SecureValueError? {
|
||||
var _1: Api.SecureValueType?
|
||||
if let signature = reader.readInt32() {
|
||||
_1 = Api.parse(reader, signature: signature) as? Api.SecureValueType
|
||||
}
|
||||
var _2: Buffer?
|
||||
_2 = parseBytes(reader)
|
||||
var _3: String?
|
||||
_3 = parseString(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.SecureValueError.secureValueErrorSelfie(type: _1!, fileHash: _2!, text: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
public enum ChannelBannedRights {
|
||||
@ -7813,24 +7881,26 @@ public extension Api {
|
||||
|
||||
}
|
||||
public enum SecureValue {
|
||||
case secureValue(flags: Int32, type: Api.SecureValueType, data: Api.SecureData?, files: [Api.SecureFile]?, plainData: Api.SecurePlainData?, selfie: Api.SecureFile?, hash: Buffer)
|
||||
case secureValue(flags: Int32, type: Api.SecureValueType, data: Api.SecureData?, frontSide: Api.SecureFile?, reverseSide: Api.SecureFile?, selfie: Api.SecureFile?, files: [Api.SecureFile]?, plainData: Api.SecurePlainData?, hash: Buffer)
|
||||
|
||||
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
|
||||
switch self {
|
||||
case .secureValue(let flags, let type, let data, let files, let plainData, let selfie, let hash):
|
||||
case .secureValue(let flags, let type, let data, let frontSide, let reverseSide, let selfie, let files, let plainData, let hash):
|
||||
if boxed {
|
||||
buffer.appendInt32(-331270968)
|
||||
buffer.appendInt32(-1263225191)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
type.serialize(buffer, true)
|
||||
if Int(flags) & Int(1 << 0) != 0 {data!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 1) != 0 {buffer.appendInt32(481674261)
|
||||
if Int(flags) & Int(1 << 1) != 0 {frontSide!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 2) != 0 {reverseSide!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 3) != 0 {selfie!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 4) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(files!.count))
|
||||
for item in files! {
|
||||
item.serialize(buffer, true)
|
||||
}}
|
||||
if Int(flags) & Int(1 << 2) != 0 {plainData!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 3) != 0 {selfie!.serialize(buffer, true)}
|
||||
if Int(flags) & Int(1 << 5) != 0 {plainData!.serialize(buffer, true)}
|
||||
serializeBytes(hash, buffer: buffer, boxed: false)
|
||||
break
|
||||
}
|
||||
@ -7847,29 +7917,39 @@ public extension Api {
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
|
||||
_3 = Api.parse(reader, signature: signature) as? Api.SecureData
|
||||
} }
|
||||
var _4: [Api.SecureFile]?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {if let _ = reader.readInt32() {
|
||||
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SecureFile.self)
|
||||
var _4: Api.SecureFile?
|
||||
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
|
||||
_4 = Api.parse(reader, signature: signature) as? Api.SecureFile
|
||||
} }
|
||||
var _5: Api.SecurePlainData?
|
||||
var _5: Api.SecureFile?
|
||||
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
|
||||
_5 = Api.parse(reader, signature: signature) as? Api.SecurePlainData
|
||||
_5 = Api.parse(reader, signature: signature) as? Api.SecureFile
|
||||
} }
|
||||
var _6: Api.SecureFile?
|
||||
if Int(_1!) & Int(1 << 3) != 0 {if let signature = reader.readInt32() {
|
||||
_6 = Api.parse(reader, signature: signature) as? Api.SecureFile
|
||||
} }
|
||||
var _7: Buffer?
|
||||
_7 = parseBytes(reader)
|
||||
var _7: [Api.SecureFile]?
|
||||
if Int(_1!) & Int(1 << 4) != 0 {if let _ = reader.readInt32() {
|
||||
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.SecureFile.self)
|
||||
} }
|
||||
var _8: Api.SecurePlainData?
|
||||
if Int(_1!) & Int(1 << 5) != 0 {if let signature = reader.readInt32() {
|
||||
_8 = Api.parse(reader, signature: signature) as? Api.SecurePlainData
|
||||
} }
|
||||
var _9: Buffer?
|
||||
_9 = parseBytes(reader)
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
let _c4 = (Int(_1!) & Int(1 << 1) == 0) || _4 != nil
|
||||
let _c5 = (Int(_1!) & Int(1 << 2) == 0) || _5 != nil
|
||||
let _c6 = (Int(_1!) & Int(1 << 3) == 0) || _6 != nil
|
||||
let _c7 = _7 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
|
||||
return Api.SecureValue.secureValue(flags: _1!, type: _2!, data: _3, files: _4, plainData: _5, selfie: _6, hash: _7!)
|
||||
let _c7 = (Int(_1!) & Int(1 << 4) == 0) || _7 != nil
|
||||
let _c8 = (Int(_1!) & Int(1 << 5) == 0) || _8 != nil
|
||||
let _c9 = _9 != nil
|
||||
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 {
|
||||
return Api.SecureValue.secureValue(flags: _1!, type: _2!, data: _3, frontSide: _4, reverseSide: _5, selfie: _6, files: _7, plainData: _8, hash: _9!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
@ -11847,10 +11927,13 @@ public extension Api {
|
||||
case secureValueTypePassport
|
||||
case secureValueTypeDriverLicense
|
||||
case secureValueTypeIdentityCard
|
||||
case secureValueTypeInternalPassport
|
||||
case secureValueTypeAddress
|
||||
case secureValueTypeUtilityBill
|
||||
case secureValueTypeBankStatement
|
||||
case secureValueTypeRentalAgreement
|
||||
case secureValueTypePassportRegistration
|
||||
case secureValueTypeTemporaryRegistration
|
||||
case secureValueTypePhone
|
||||
case secureValueTypeEmail
|
||||
|
||||
@ -11879,6 +11962,12 @@ public extension Api {
|
||||
buffer.appendInt32(-1596951477)
|
||||
}
|
||||
|
||||
break
|
||||
case .secureValueTypeInternalPassport:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1717268701)
|
||||
}
|
||||
|
||||
break
|
||||
case .secureValueTypeAddress:
|
||||
if boxed {
|
||||
@ -11903,6 +11992,18 @@ public extension Api {
|
||||
buffer.appendInt32(-1954007928)
|
||||
}
|
||||
|
||||
break
|
||||
case .secureValueTypePassportRegistration:
|
||||
if boxed {
|
||||
buffer.appendInt32(-1713143702)
|
||||
}
|
||||
|
||||
break
|
||||
case .secureValueTypeTemporaryRegistration:
|
||||
if boxed {
|
||||
buffer.appendInt32(-368907213)
|
||||
}
|
||||
|
||||
break
|
||||
case .secureValueTypePhone:
|
||||
if boxed {
|
||||
@ -11931,6 +12032,9 @@ public extension Api {
|
||||
static func parse_secureValueTypeIdentityCard(_ reader: BufferReader) -> SecureValueType? {
|
||||
return Api.SecureValueType.secureValueTypeIdentityCard
|
||||
}
|
||||
static func parse_secureValueTypeInternalPassport(_ reader: BufferReader) -> SecureValueType? {
|
||||
return Api.SecureValueType.secureValueTypeInternalPassport
|
||||
}
|
||||
static func parse_secureValueTypeAddress(_ reader: BufferReader) -> SecureValueType? {
|
||||
return Api.SecureValueType.secureValueTypeAddress
|
||||
}
|
||||
@ -11943,6 +12047,12 @@ public extension Api {
|
||||
static func parse_secureValueTypeRentalAgreement(_ reader: BufferReader) -> SecureValueType? {
|
||||
return Api.SecureValueType.secureValueTypeRentalAgreement
|
||||
}
|
||||
static func parse_secureValueTypePassportRegistration(_ reader: BufferReader) -> SecureValueType? {
|
||||
return Api.SecureValueType.secureValueTypePassportRegistration
|
||||
}
|
||||
static func parse_secureValueTypeTemporaryRegistration(_ reader: BufferReader) -> SecureValueType? {
|
||||
return Api.SecureValueType.secureValueTypeTemporaryRegistration
|
||||
}
|
||||
static func parse_secureValueTypePhone(_ reader: BufferReader) -> SecureValueType? {
|
||||
return Api.SecureValueType.secureValueTypePhone
|
||||
}
|
||||
|
@ -16,12 +16,18 @@ func apiSecureValueType(value: SecureIdValue) -> Api.SecureValueType {
|
||||
type = .secureValueTypePersonalDetails
|
||||
case .passport:
|
||||
type = .secureValueTypePassport
|
||||
case .internalPassport:
|
||||
type = .secureValueTypeInternalPassport
|
||||
case .driversLicense:
|
||||
type = .secureValueTypeDriverLicense
|
||||
case .idCard:
|
||||
type = .secureValueTypeIdentityCard
|
||||
case .address:
|
||||
type = .secureValueTypeAddress
|
||||
case .passportRegistration:
|
||||
type = .secureValueTypePassportRegistration
|
||||
case .temporaryRegistration:
|
||||
type = .secureValueTypeTemporaryRegistration
|
||||
case .bankStatement:
|
||||
type = .secureValueTypeBankStatement
|
||||
case .utilityBill:
|
||||
@ -43,12 +49,18 @@ func apiSecureValueType(key: SecureIdValueKey) -> Api.SecureValueType {
|
||||
type = .secureValueTypePersonalDetails
|
||||
case .passport:
|
||||
type = .secureValueTypePassport
|
||||
case .internalPassport:
|
||||
type = .secureValueTypeInternalPassport
|
||||
case .driversLicense:
|
||||
type = .secureValueTypeDriverLicense
|
||||
case .idCard:
|
||||
type = .secureValueTypeIdentityCard
|
||||
case .address:
|
||||
type = .secureValueTypeAddress
|
||||
case .passportRegistration:
|
||||
type = .secureValueTypePassportRegistration
|
||||
case .temporaryRegistration:
|
||||
type = .secureValueTypeTemporaryRegistration
|
||||
case .bankStatement:
|
||||
type = .secureValueTypeBankStatement
|
||||
case .utilityBill:
|
||||
@ -69,12 +81,18 @@ private func credentialsValueTypeName(value: SecureIdValue) -> String {
|
||||
return "personal_details"
|
||||
case .passport:
|
||||
return "passport"
|
||||
case .internalPassport:
|
||||
return "internal_passport"
|
||||
case .driversLicense:
|
||||
return "driver_license"
|
||||
case .idCard:
|
||||
return "identity_card"
|
||||
case .address:
|
||||
return "address"
|
||||
case .passportRegistration:
|
||||
return "passport_registration"
|
||||
case .temporaryRegistration:
|
||||
return "temporary_registration"
|
||||
case .bankStatement:
|
||||
return "bank_statement"
|
||||
case .utilityBill:
|
||||
|
@ -321,7 +321,7 @@ public struct NetworkInitializationArguments {
|
||||
}
|
||||
}
|
||||
|
||||
func initializedNetwork(arguments: NetworkInitializationArguments, supplementary: Bool, datacenterId: Int, keychain: Keychain, basePath: String, testingEnvironment: Bool, languageCode: String?, proxySettings: ProxySettings?) -> Signal<Network, NoError> {
|
||||
func initializedNetwork(arguments: NetworkInitializationArguments, supplementary: Bool, datacenterId: Int, keychain: Keychain, basePath: String, testingEnvironment: Bool, languageCode: String?, proxySettings: ProxySettings?, phoneNumber: String?) -> Signal<Network, NoError> {
|
||||
return Signal { subscriber in
|
||||
Queue.concurrentDefaultQueue().async {
|
||||
let _ = registeredLoggingFunctions
|
||||
@ -364,7 +364,11 @@ func initializedNetwork(arguments: NetworkInitializationArguments, supplementary
|
||||
}
|
||||
|
||||
context.keychain = keychain
|
||||
context.setDiscoverBackupAddressListSignal(MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context))
|
||||
context.setDiscoverBackupAddressListSignal(MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, phoneNumber: phoneNumber))
|
||||
|
||||
#if DEBUG
|
||||
//let _ = MTBackupAddressSignals.fetchBackupIps(testingEnvironment, currentContext: context, phoneNumber: phoneNumber).start(next: nil)
|
||||
#endif
|
||||
|
||||
let mtProto = MTProto(context: context, datacenterId: datacenterId, usageCalculationInfo: usageCalculationInfo(basePath: basePath, category: nil))!
|
||||
mtProto.useTempAuthKeys = true
|
||||
|
@ -162,7 +162,19 @@ public func updatePeerPhoto(account: Account, peerId: PeerId, resource: MediaRes
|
||||
return .fail(.generic)
|
||||
}
|
||||
}
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public func removeAccountPhoto(network: Network, reference: TelegramMediaImageReference) -> Signal<Void, NoError> {
|
||||
switch reference {
|
||||
case let .cloud(imageId, accessHash):
|
||||
return network.request(Api.functions.photos.deletePhotos(id: [.inputPhoto(id: imageId, accessHash: accessHash)]))
|
||||
|> `catch` { _ -> Signal<[Int64], NoError> in
|
||||
return .single([])
|
||||
}
|
||||
|> mapToSignal { _ -> Signal<Void, NoError> in
|
||||
return .complete()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ private func parseSecureValueType(_ type: Api.SecureValueType, selfie: Bool) ->
|
||||
return .personalDetails
|
||||
case .secureValueTypePassport:
|
||||
return .passport(selfie: selfie)
|
||||
case .secureValueTypeInternalPassport:
|
||||
return .internalPassport(selfie: selfie)
|
||||
case .secureValueTypeDriverLicense:
|
||||
return .driversLicense(selfie: selfie)
|
||||
case .secureValueTypeIdentityCard:
|
||||
@ -35,6 +37,10 @@ private func parseSecureValueType(_ type: Api.SecureValueType, selfie: Bool) ->
|
||||
return .phone
|
||||
case .secureValueTypeEmail:
|
||||
return .email
|
||||
case .secureValueTypePassportRegistration:
|
||||
return .passportRegistration
|
||||
case .secureValueTypeTemporaryRegistration:
|
||||
return .temporaryRegistration(selfie: selfie)
|
||||
}
|
||||
}
|
||||
|
||||
@ -51,15 +57,19 @@ struct ParsedSecureValue {
|
||||
|
||||
func parseSecureValue(context: SecureIdAccessContext, value: Api.SecureValue, errors: [Api.SecureValueError]) -> ParsedSecureValue? {
|
||||
switch value {
|
||||
case let .secureValue(_, type, data, files, plainData, selfie, hash):
|
||||
case let .secureValue(_, type, data, frontSide, reverseSide, selfie, files, plainData, hash):
|
||||
let parsedFileReferences = files.flatMap { $0.compactMap(SecureIdFileReference.init) } ?? []
|
||||
let parsedFiles = parsedFileReferences.map(SecureIdVerificationDocumentReference.remote)
|
||||
let parsedFrontSide = frontSide.flatMap(SecureIdFileReference.init).flatMap(SecureIdVerificationDocumentReference.remote)
|
||||
let parsedBackSide = reverseSide.flatMap(SecureIdFileReference.init).flatMap(SecureIdVerificationDocumentReference.remote)
|
||||
let parsedSelfie = selfie.flatMap(SecureIdFileReference.init).flatMap(SecureIdVerificationDocumentReference.remote)
|
||||
|
||||
let decryptedData: Data?
|
||||
let encryptedMetadata: SecureIdEncryptedValueMetadata?
|
||||
var parsedFileMetadata: [SecureIdEncryptedValueFileMetadata] = []
|
||||
var parsedSelfieMetadata: SecureIdEncryptedValueFileMetadata?
|
||||
var parsedFrontSideMetadata: SecureIdEncryptedValueFileMetadata?
|
||||
var parsedBackSideMetadata: SecureIdEncryptedValueFileMetadata?
|
||||
var contentsId: Data?
|
||||
if let data = data {
|
||||
let (encryptedData, decryptedHash, encryptedSecret) = parseSecureData(data)
|
||||
@ -91,6 +101,20 @@ func parseSecureValue(context: SecureIdAccessContext, value: Api.SecureValue, er
|
||||
|
||||
parsedSelfieMetadata = SecureIdEncryptedValueFileMetadata(hash: parsedSelfie.fileHash, secret: fileSecret)
|
||||
}
|
||||
if let parsedFrontSide = frontSide.flatMap(SecureIdFileReference.init) {
|
||||
guard let fileSecret = decryptedSecureIdFileSecret(context: context, fileHash: parsedFrontSide.fileHash, encryptedSecret: parsedFrontSide.encryptedSecret) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
parsedFrontSideMetadata = SecureIdEncryptedValueFileMetadata(hash: parsedFrontSide.fileHash, secret: fileSecret)
|
||||
}
|
||||
if let parsedBackSide = reverseSide.flatMap(SecureIdFileReference.init) {
|
||||
guard let fileSecret = decryptedSecureIdFileSecret(context: context, fileHash: parsedBackSide.fileHash, encryptedSecret: parsedBackSide.encryptedSecret) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
parsedBackSideMetadata = SecureIdEncryptedValueFileMetadata(hash: parsedBackSide.fileHash, secret: fileSecret)
|
||||
}
|
||||
|
||||
let value: SecureIdValue
|
||||
|
||||
@ -107,15 +131,23 @@ func parseSecureValue(context: SecureIdAccessContext, value: Api.SecureValue, er
|
||||
guard let dict = (try? JSONSerialization.jsonObject(with: decryptedData ?? Data(), options: [])) as? [String: Any] else {
|
||||
return nil
|
||||
}
|
||||
guard let passport = SecureIdPassportValue(dict: dict, fileReferences: parsedFiles, selfieDocument: parsedSelfie) else {
|
||||
guard let passport = SecureIdPassportValue(dict: dict, fileReferences: parsedFiles, selfieDocument: parsedSelfie, frontSideDocument: parsedFrontSide) else {
|
||||
return nil
|
||||
}
|
||||
value = .passport(passport)
|
||||
case .secureValueTypeInternalPassport:
|
||||
guard let dict = (try? JSONSerialization.jsonObject(with: decryptedData ?? Data(), options: [])) as? [String: Any] else {
|
||||
return nil
|
||||
}
|
||||
guard let internalPassport = SecureIdInternalPassportValue(dict: dict, fileReferences: parsedFiles, selfieDocument: parsedSelfie, frontSideDocument: parsedFrontSide) else {
|
||||
return nil
|
||||
}
|
||||
value = .internalPassport(internalPassport)
|
||||
case .secureValueTypeDriverLicense:
|
||||
guard let dict = (try? JSONSerialization.jsonObject(with: decryptedData ?? Data(), options: [])) as? [String: Any] else {
|
||||
return nil
|
||||
}
|
||||
guard let driversLicense = SecureIdDriversLicenseValue(dict: dict, fileReferences: parsedFiles, selfieDocument: parsedSelfie) else {
|
||||
guard let driversLicense = SecureIdDriversLicenseValue(dict: dict, fileReferences: parsedFiles, selfieDocument: parsedSelfie, frontSideDocument: parsedFrontSide, backSideDocument: parsedBackSide) else {
|
||||
return nil
|
||||
}
|
||||
value = .driversLicense(driversLicense)
|
||||
@ -123,7 +155,7 @@ func parseSecureValue(context: SecureIdAccessContext, value: Api.SecureValue, er
|
||||
guard let dict = (try? JSONSerialization.jsonObject(with: decryptedData ?? Data(), options: [])) as? [String: Any] else {
|
||||
return nil
|
||||
}
|
||||
guard let idCard = SecureIdIDCardValue(dict: dict, fileReferences: parsedFiles, selfieDocument: parsedSelfie) else {
|
||||
guard let idCard = SecureIdIDCardValue(dict: dict, fileReferences: parsedFiles, selfieDocument: parsedSelfie, frontSideDocument: parsedFrontSide, backSideDocument: parsedBackSide) else {
|
||||
return nil
|
||||
}
|
||||
value = .idCard(idCard)
|
||||
@ -135,6 +167,16 @@ func parseSecureValue(context: SecureIdAccessContext, value: Api.SecureValue, er
|
||||
return nil
|
||||
}
|
||||
value = .address(address)
|
||||
case .secureValueTypePassportRegistration:
|
||||
guard let passportRegistration = SecureIdPassportRegistrationValue(fileReferences: parsedFiles) else {
|
||||
return nil
|
||||
}
|
||||
value = .passportRegistration(passportRegistration)
|
||||
case .secureValueTypeTemporaryRegistration:
|
||||
guard let temporaryRegistration = SecureIdTemporaryRegistrationValue(fileReferences: parsedFiles) else {
|
||||
return nil
|
||||
}
|
||||
value = .temporaryRegistration(temporaryRegistration)
|
||||
case .secureValueTypeUtilityBill:
|
||||
guard let utilityBill = SecureIdUtilityBillValue(fileReferences: parsedFiles) else {
|
||||
return nil
|
||||
@ -172,7 +214,7 @@ func parseSecureValue(context: SecureIdAccessContext, value: Api.SecureValue, er
|
||||
}
|
||||
}
|
||||
|
||||
return ParsedSecureValue(valueWithContext: SecureIdValueWithContext(value: value, errors: parseSecureIdValueContentErrors(dataHash: contentsId, fileHashes: Set(parsedFileMetadata.map { $0.hash }), selfieHash: parsedSelfieMetadata?.hash, errors: errors), files: parsedFileMetadata, selfie: parsedSelfieMetadata, encryptedMetadata: encryptedMetadata, opaqueHash: hash.makeData()))
|
||||
return ParsedSecureValue(valueWithContext: SecureIdValueWithContext(value: value, errors: parseSecureIdValueContentErrors(dataHash: contentsId, fileHashes: Set(parsedFileMetadata.map { $0.hash }), selfieHash: parsedSelfieMetadata?.hash, frontSideHash: parsedFrontSideMetadata?.hash, backSideHash: parsedBackSideMetadata?.hash, errors: errors), files: parsedFileMetadata, selfie: parsedSelfieMetadata, frontSide: parsedFrontSideMetadata, backSide: parsedBackSideMetadata, encryptedMetadata: encryptedMetadata, opaqueHash: hash.makeData()))
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -100,6 +100,8 @@ private struct InputSecureIdValueData {
|
||||
let type: Api.SecureValueType
|
||||
let dict: [String: Any]?
|
||||
let fileReferences: [SecureIdVerificationDocumentReference]
|
||||
let frontSideReference: SecureIdVerificationDocumentReference?
|
||||
let backSideReference: SecureIdVerificationDocumentReference?
|
||||
let selfieReference: SecureIdVerificationDocumentReference?
|
||||
let publicData: Api.SecurePlainData?
|
||||
}
|
||||
@ -108,32 +110,41 @@ private func inputSecureIdValueData(value: SecureIdValue) -> InputSecureIdValueD
|
||||
switch value {
|
||||
case let .personalDetails(personalDetails):
|
||||
let (dict, fileReferences) = personalDetails.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypePersonalDetails, dict: dict, fileReferences: fileReferences, selfieReference: nil, publicData: nil)
|
||||
return InputSecureIdValueData(type: .secureValueTypePersonalDetails, dict: dict, fileReferences: fileReferences, frontSideReference: nil, backSideReference: nil, selfieReference: nil, publicData: nil)
|
||||
case let .passport(passport):
|
||||
let (dict, fileReferences, selfieReference) = passport.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypePassport, dict: dict, fileReferences: fileReferences, selfieReference: selfieReference, publicData: nil)
|
||||
let (dict, fileReferences, selfieReference, frontSideReference) = passport.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypePassport, dict: dict, fileReferences: fileReferences, frontSideReference: frontSideReference, backSideReference: nil, selfieReference: selfieReference, publicData: nil)
|
||||
case let .internalPassport(internalPassport):
|
||||
let (dict, fileReferences, selfieReference, frontSideReference) = internalPassport.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypeInternalPassport, dict: dict, fileReferences: fileReferences, frontSideReference: frontSideReference, backSideReference: nil, selfieReference: selfieReference, publicData: nil)
|
||||
case let .driversLicense(driversLicense):
|
||||
let (dict, fileReferences, selfieReference) = driversLicense.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypeDriverLicense, dict: dict, fileReferences: fileReferences, selfieReference: selfieReference, publicData: nil)
|
||||
let (dict, fileReferences, selfieReference, frontSideReference, backSideReference) = driversLicense.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypeDriverLicense, dict: dict, fileReferences: fileReferences, frontSideReference: frontSideReference, backSideReference: backSideReference, selfieReference: selfieReference, publicData: nil)
|
||||
case let .idCard(idCard):
|
||||
let (dict, fileReferences, selfieReference) = idCard.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypeIdentityCard, dict: dict, fileReferences: fileReferences, selfieReference: selfieReference, publicData: nil)
|
||||
let (dict, fileReferences, selfieReference, frontSideReference, backSideReference) = idCard.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypeIdentityCard, dict: dict, fileReferences: fileReferences, frontSideReference: frontSideReference, backSideReference: backSideReference, selfieReference: selfieReference, publicData: nil)
|
||||
case let .address(address):
|
||||
let (dict, fileReferences) = address.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypeAddress, dict: dict, fileReferences: fileReferences, selfieReference: nil, publicData: nil)
|
||||
return InputSecureIdValueData(type: .secureValueTypeAddress, dict: dict, fileReferences: fileReferences, frontSideReference: nil, backSideReference: nil, selfieReference: nil, publicData: nil)
|
||||
case let .passportRegistration(passportRegistration):
|
||||
let (dict, fileReferences) = passportRegistration.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypePassportRegistration, dict: dict, fileReferences: fileReferences, frontSideReference: nil, backSideReference: nil, selfieReference: nil, publicData: nil)
|
||||
case let .temporaryRegistration(temporaryRegistration):
|
||||
let (dict, fileReferences) = temporaryRegistration.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypeTemporaryRegistration, dict: dict, fileReferences: fileReferences, frontSideReference: nil, backSideReference: nil, selfieReference: nil, publicData: nil)
|
||||
case let .utilityBill(utilityBill):
|
||||
let (dict, fileReferences) = utilityBill.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypeUtilityBill, dict: dict, fileReferences: fileReferences, selfieReference: nil, publicData: nil)
|
||||
return InputSecureIdValueData(type: .secureValueTypeUtilityBill, dict: dict, fileReferences: fileReferences, frontSideReference: nil, backSideReference: nil, selfieReference: nil, publicData: nil)
|
||||
case let .bankStatement(bankStatement):
|
||||
let (dict, fileReferences) = bankStatement.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypeBankStatement, dict: dict, fileReferences: fileReferences, selfieReference: nil, publicData: nil)
|
||||
return InputSecureIdValueData(type: .secureValueTypeBankStatement, dict: dict, fileReferences: fileReferences, frontSideReference: nil, backSideReference: nil, selfieReference: nil, publicData: nil)
|
||||
case let .rentalAgreement(rentalAgreement):
|
||||
let (dict, fileReferences) = rentalAgreement.serialize()
|
||||
return InputSecureIdValueData(type: .secureValueTypeRentalAgreement, dict: dict, fileReferences: fileReferences, selfieReference: nil, publicData: nil)
|
||||
return InputSecureIdValueData(type: .secureValueTypeRentalAgreement, dict: dict, fileReferences: fileReferences, frontSideReference: nil, backSideReference: nil, selfieReference: nil, publicData: nil)
|
||||
case let .phone(phone):
|
||||
return InputSecureIdValueData(type: .secureValueTypePhone, dict: nil, fileReferences: [], selfieReference: nil, publicData: .securePlainPhone(phone: phone.phone))
|
||||
return InputSecureIdValueData(type: .secureValueTypePhone, dict: nil, fileReferences: [], frontSideReference: nil, backSideReference: nil, selfieReference: nil, publicData: .securePlainPhone(phone: phone.phone))
|
||||
case let .email(email):
|
||||
return InputSecureIdValueData(type: .secureValueTypeEmail, dict: nil, fileReferences: [], selfieReference: nil, publicData: .securePlainEmail(email: email.email))
|
||||
return InputSecureIdValueData(type: .secureValueTypeEmail, dict: nil, fileReferences: [], frontSideReference: nil, backSideReference: nil, selfieReference: nil, publicData: .securePlainEmail(email: email.email))
|
||||
}
|
||||
}
|
||||
|
||||
@ -174,17 +185,23 @@ private func makeInputSecureValue(context: SecureIdAccessContext, value: SecureI
|
||||
if secureData != nil {
|
||||
flags |= 1 << 0
|
||||
}
|
||||
if !files.isEmpty {
|
||||
if inputData.frontSideReference != nil {
|
||||
flags |= 1 << 1
|
||||
}
|
||||
if inputData.publicData != nil {
|
||||
if inputData.backSideReference != nil {
|
||||
flags |= 1 << 2
|
||||
}
|
||||
if inputData.selfieReference != nil {
|
||||
flags |= 1 << 3
|
||||
}
|
||||
if !files.isEmpty {
|
||||
flags |= 1 << 4
|
||||
}
|
||||
if inputData.publicData != nil {
|
||||
flags |= 1 << 5
|
||||
}
|
||||
|
||||
return Api.InputSecureValue.inputSecureValue(flags: flags, type: inputData.type, data: secureData, files: files, plainData: inputData.publicData, selfie: inputData.selfieReference.flatMap(apiInputSecretFile))
|
||||
return Api.InputSecureValue.inputSecureValue(flags: flags, type: inputData.type, data: secureData, frontSide: inputData.frontSideReference.flatMap(apiInputSecretFile), reverseSide: inputData.backSideReference.flatMap(apiInputSecretFile), selfie: inputData.selfieReference.flatMap(apiInputSecretFile), files: files, plainData: inputData.publicData)
|
||||
}
|
||||
|
||||
public func saveSecureIdValue(postbox: Postbox, network: Network, context: SecureIdAccessContext, value: SecureIdValue, uploadedFiles: [Data: Data]) -> Signal<SecureIdValueWithContext, SaveSecureIdValueError> {
|
||||
|
@ -5,12 +5,16 @@ public struct SecureIdDriversLicenseValue: Equatable {
|
||||
public var expiryDate: SecureIdDate?
|
||||
public var verificationDocuments: [SecureIdVerificationDocumentReference]
|
||||
public var selfieDocument: SecureIdVerificationDocumentReference?
|
||||
public var frontSideDocument: SecureIdVerificationDocumentReference?
|
||||
public var backSideDocument: SecureIdVerificationDocumentReference?
|
||||
|
||||
public init(identifier: String, expiryDate: SecureIdDate?, verificationDocuments: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?) {
|
||||
public init(identifier: String, expiryDate: SecureIdDate?, verificationDocuments: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?, frontSideDocument: SecureIdVerificationDocumentReference?, backSideDocument: SecureIdVerificationDocumentReference?) {
|
||||
self.identifier = identifier
|
||||
self.expiryDate = expiryDate
|
||||
self.verificationDocuments = verificationDocuments
|
||||
self.selfieDocument = selfieDocument
|
||||
self.frontSideDocument = frontSideDocument
|
||||
self.backSideDocument = backSideDocument
|
||||
}
|
||||
|
||||
public static func ==(lhs: SecureIdDriversLicenseValue, rhs: SecureIdDriversLicenseValue) -> Bool {
|
||||
@ -26,12 +30,18 @@ public struct SecureIdDriversLicenseValue: Equatable {
|
||||
if lhs.selfieDocument != rhs.selfieDocument {
|
||||
return false
|
||||
}
|
||||
if lhs.frontSideDocument != rhs.frontSideDocument {
|
||||
return false
|
||||
}
|
||||
if lhs.backSideDocument != rhs.backSideDocument {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SecureIdDriversLicenseValue {
|
||||
init?(dict: [String: Any], fileReferences: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?) {
|
||||
init?(dict: [String: Any], fileReferences: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?, frontSideDocument: SecureIdVerificationDocumentReference?, backSideDocument: SecureIdVerificationDocumentReference?) {
|
||||
guard let identifier = dict["document_no"] as? String else {
|
||||
return nil
|
||||
}
|
||||
@ -39,16 +49,16 @@ extension SecureIdDriversLicenseValue {
|
||||
|
||||
let verificationDocuments: [SecureIdVerificationDocumentReference] = fileReferences
|
||||
|
||||
self.init(identifier: identifier, expiryDate: expiryDate, verificationDocuments: verificationDocuments, selfieDocument: selfieDocument)
|
||||
self.init(identifier: identifier, expiryDate: expiryDate, verificationDocuments: verificationDocuments, selfieDocument: selfieDocument, frontSideDocument: frontSideDocument, backSideDocument: backSideDocument)
|
||||
}
|
||||
|
||||
func serialize() -> ([String: Any], [SecureIdVerificationDocumentReference], SecureIdVerificationDocumentReference?) {
|
||||
func serialize() -> ([String: Any], [SecureIdVerificationDocumentReference], SecureIdVerificationDocumentReference?, SecureIdVerificationDocumentReference?, SecureIdVerificationDocumentReference?) {
|
||||
var dict: [String: Any] = [:]
|
||||
dict["document_no"] = self.identifier
|
||||
if let expiryDate = self.expiryDate {
|
||||
dict["expiry_date"] = expiryDate.serialize()
|
||||
}
|
||||
|
||||
return (dict, self.verificationDocuments, self.selfieDocument)
|
||||
return (dict, self.verificationDocuments, self.selfieDocument, self.frontSideDocument, self.backSideDocument)
|
||||
}
|
||||
}
|
||||
|
@ -10,12 +10,15 @@ public enum SecureIdRequestedFormField: Equatable {
|
||||
case passport(selfie: Bool)
|
||||
case driversLicense(selfie: Bool)
|
||||
case idCard(selfie: Bool)
|
||||
case internalPassport(selfie: Bool)
|
||||
case passportRegistration
|
||||
case address
|
||||
case utilityBill
|
||||
case bankStatement
|
||||
case rentalAgreement
|
||||
case phone
|
||||
case email
|
||||
case temporaryRegistration(selfie: Bool)
|
||||
}
|
||||
|
||||
public struct SecureIdForm: Equatable {
|
||||
|
@ -5,12 +5,16 @@ public struct SecureIdIDCardValue: Equatable {
|
||||
public var expiryDate: SecureIdDate?
|
||||
public var verificationDocuments: [SecureIdVerificationDocumentReference]
|
||||
public var selfieDocument: SecureIdVerificationDocumentReference?
|
||||
public var frontSideDocument: SecureIdVerificationDocumentReference?
|
||||
public var backSideDocument: SecureIdVerificationDocumentReference?
|
||||
|
||||
public init(identifier: String, expiryDate: SecureIdDate?, verificationDocuments: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?) {
|
||||
public init(identifier: String, expiryDate: SecureIdDate?, verificationDocuments: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?, frontSideDocument: SecureIdVerificationDocumentReference?, backSideDocument: SecureIdVerificationDocumentReference?) {
|
||||
self.identifier = identifier
|
||||
self.expiryDate = expiryDate
|
||||
self.verificationDocuments = verificationDocuments
|
||||
self.selfieDocument = selfieDocument
|
||||
self.frontSideDocument = frontSideDocument
|
||||
self.backSideDocument = backSideDocument
|
||||
}
|
||||
|
||||
public static func ==(lhs: SecureIdIDCardValue, rhs: SecureIdIDCardValue) -> Bool {
|
||||
@ -26,12 +30,18 @@ public struct SecureIdIDCardValue: Equatable {
|
||||
if lhs.selfieDocument != rhs.selfieDocument {
|
||||
return false
|
||||
}
|
||||
if lhs.frontSideDocument != rhs.frontSideDocument {
|
||||
return false
|
||||
}
|
||||
if lhs.backSideDocument != rhs.backSideDocument {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SecureIdIDCardValue {
|
||||
init?(dict: [String: Any], fileReferences: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?) {
|
||||
init?(dict: [String: Any], fileReferences: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?, frontSideDocument: SecureIdVerificationDocumentReference?, backSideDocument: SecureIdVerificationDocumentReference?) {
|
||||
guard let identifier = dict["document_no"] as? String else {
|
||||
return nil
|
||||
}
|
||||
@ -39,16 +49,16 @@ extension SecureIdIDCardValue {
|
||||
|
||||
let verificationDocuments: [SecureIdVerificationDocumentReference] = fileReferences
|
||||
|
||||
self.init(identifier: identifier, expiryDate: expiryDate, verificationDocuments: verificationDocuments, selfieDocument: selfieDocument)
|
||||
self.init(identifier: identifier, expiryDate: expiryDate, verificationDocuments: verificationDocuments, selfieDocument: selfieDocument, frontSideDocument: frontSideDocument, backSideDocument: backSideDocument)
|
||||
}
|
||||
|
||||
func serialize() -> ([String: Any], [SecureIdVerificationDocumentReference], SecureIdVerificationDocumentReference?) {
|
||||
func serialize() -> ([String: Any], [SecureIdVerificationDocumentReference], SecureIdVerificationDocumentReference?, SecureIdVerificationDocumentReference?, SecureIdVerificationDocumentReference?) {
|
||||
var dict: [String: Any] = [:]
|
||||
dict["document_no"] = self.identifier
|
||||
if let expiryDate = self.expiryDate {
|
||||
dict["expiry_date"] = expiryDate.serialize()
|
||||
}
|
||||
|
||||
return (dict, self.verificationDocuments, self.selfieDocument)
|
||||
return (dict, self.verificationDocuments, self.selfieDocument, self.frontSideDocument, self.backSideDocument)
|
||||
}
|
||||
}
|
||||
|
59
TelegramCore/SecureIdInternalPassportValue.swift
Normal file
59
TelegramCore/SecureIdInternalPassportValue.swift
Normal file
@ -0,0 +1,59 @@
|
||||
import Foundation
|
||||
|
||||
public struct SecureIdInternalPassportValue: Equatable {
|
||||
public var identifier: String
|
||||
public var expiryDate: SecureIdDate?
|
||||
public var verificationDocuments: [SecureIdVerificationDocumentReference]
|
||||
public var selfieDocument: SecureIdVerificationDocumentReference?
|
||||
public var frontSideDocument: SecureIdVerificationDocumentReference?
|
||||
|
||||
public init(identifier: String, expiryDate: SecureIdDate?, verificationDocuments: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?, frontSideDocument: SecureIdVerificationDocumentReference?) {
|
||||
self.identifier = identifier
|
||||
self.expiryDate = expiryDate
|
||||
self.verificationDocuments = verificationDocuments
|
||||
self.selfieDocument = selfieDocument
|
||||
self.frontSideDocument = frontSideDocument
|
||||
}
|
||||
|
||||
public static func ==(lhs: SecureIdInternalPassportValue, rhs: SecureIdInternalPassportValue) -> Bool {
|
||||
if lhs.identifier != rhs.identifier {
|
||||
return false
|
||||
}
|
||||
if lhs.expiryDate != rhs.expiryDate {
|
||||
return false
|
||||
}
|
||||
if lhs.verificationDocuments != rhs.verificationDocuments {
|
||||
return false
|
||||
}
|
||||
if lhs.selfieDocument != rhs.selfieDocument {
|
||||
return false
|
||||
}
|
||||
if lhs.frontSideDocument != rhs.frontSideDocument {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SecureIdInternalPassportValue {
|
||||
init?(dict: [String: Any], fileReferences: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?, frontSideDocument: SecureIdVerificationDocumentReference?) {
|
||||
guard let identifier = dict["document_no"] as? String else {
|
||||
return nil
|
||||
}
|
||||
let expiryDate = (dict["expiry_date"] as? String).flatMap(SecureIdDate.init)
|
||||
|
||||
let verificationDocuments: [SecureIdVerificationDocumentReference] = fileReferences
|
||||
|
||||
self.init(identifier: identifier, expiryDate: expiryDate, verificationDocuments: verificationDocuments, selfieDocument: selfieDocument, frontSideDocument: frontSideDocument)
|
||||
}
|
||||
|
||||
func serialize() -> ([String: Any], [SecureIdVerificationDocumentReference], SecureIdVerificationDocumentReference?, SecureIdVerificationDocumentReference?) {
|
||||
var dict: [String: Any] = [:]
|
||||
dict["document_no"] = self.identifier
|
||||
if let expiryDate = self.expiryDate {
|
||||
dict["expiry_date"] = expiryDate.serialize()
|
||||
}
|
||||
|
||||
return (dict, self.verificationDocuments, self.selfieDocument, self.frontSideDocument)
|
||||
}
|
||||
}
|
28
TelegramCore/SecureIdPassportRegistrationValue.swift
Normal file
28
TelegramCore/SecureIdPassportRegistrationValue.swift
Normal file
@ -0,0 +1,28 @@
|
||||
import Foundation
|
||||
|
||||
public struct SecureIdPassportRegistrationValue: Equatable {
|
||||
public var verificationDocuments: [SecureIdVerificationDocumentReference]
|
||||
|
||||
public init(verificationDocuments: [SecureIdVerificationDocumentReference]) {
|
||||
self.verificationDocuments = verificationDocuments
|
||||
}
|
||||
|
||||
public static func ==(lhs: SecureIdPassportRegistrationValue, rhs: SecureIdPassportRegistrationValue) -> Bool {
|
||||
if lhs.verificationDocuments != rhs.verificationDocuments {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SecureIdPassportRegistrationValue {
|
||||
init?(fileReferences: [SecureIdVerificationDocumentReference]) {
|
||||
let verificationDocuments: [SecureIdVerificationDocumentReference] = fileReferences
|
||||
|
||||
self.init(verificationDocuments: verificationDocuments)
|
||||
}
|
||||
|
||||
func serialize() -> ([String: Any], [SecureIdVerificationDocumentReference]) {
|
||||
return ([:], self.verificationDocuments)
|
||||
}
|
||||
}
|
@ -5,12 +5,14 @@ public struct SecureIdPassportValue: Equatable {
|
||||
public var expiryDate: SecureIdDate?
|
||||
public var verificationDocuments: [SecureIdVerificationDocumentReference]
|
||||
public var selfieDocument: SecureIdVerificationDocumentReference?
|
||||
public var frontSideDocument: SecureIdVerificationDocumentReference?
|
||||
|
||||
public init(identifier: String, expiryDate: SecureIdDate?, verificationDocuments: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?) {
|
||||
public init(identifier: String, expiryDate: SecureIdDate?, verificationDocuments: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?, frontSideDocument: SecureIdVerificationDocumentReference?) {
|
||||
self.identifier = identifier
|
||||
self.expiryDate = expiryDate
|
||||
self.verificationDocuments = verificationDocuments
|
||||
self.selfieDocument = selfieDocument
|
||||
self.frontSideDocument = frontSideDocument
|
||||
}
|
||||
|
||||
public static func ==(lhs: SecureIdPassportValue, rhs: SecureIdPassportValue) -> Bool {
|
||||
@ -26,12 +28,15 @@ public struct SecureIdPassportValue: Equatable {
|
||||
if lhs.selfieDocument != rhs.selfieDocument {
|
||||
return false
|
||||
}
|
||||
if lhs.frontSideDocument != rhs.frontSideDocument {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SecureIdPassportValue {
|
||||
init?(dict: [String: Any], fileReferences: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?) {
|
||||
init?(dict: [String: Any], fileReferences: [SecureIdVerificationDocumentReference], selfieDocument: SecureIdVerificationDocumentReference?, frontSideDocument: SecureIdVerificationDocumentReference?) {
|
||||
guard let identifier = dict["document_no"] as? String else {
|
||||
return nil
|
||||
}
|
||||
@ -39,16 +44,16 @@ extension SecureIdPassportValue {
|
||||
|
||||
let verificationDocuments: [SecureIdVerificationDocumentReference] = fileReferences
|
||||
|
||||
self.init(identifier: identifier, expiryDate: expiryDate, verificationDocuments: verificationDocuments, selfieDocument: selfieDocument)
|
||||
self.init(identifier: identifier, expiryDate: expiryDate, verificationDocuments: verificationDocuments, selfieDocument: selfieDocument, frontSideDocument: frontSideDocument)
|
||||
}
|
||||
|
||||
func serialize() -> ([String: Any], [SecureIdVerificationDocumentReference], SecureIdVerificationDocumentReference?) {
|
||||
func serialize() -> ([String: Any], [SecureIdVerificationDocumentReference], SecureIdVerificationDocumentReference?, SecureIdVerificationDocumentReference?) {
|
||||
var dict: [String: Any] = [:]
|
||||
dict["document_no"] = self.identifier
|
||||
if let expiryDate = self.expiryDate {
|
||||
dict["expiry_date"] = expiryDate.serialize()
|
||||
}
|
||||
|
||||
return (dict, self.verificationDocuments, self.selfieDocument)
|
||||
return (dict, self.verificationDocuments, self.selfieDocument, self.frontSideDocument)
|
||||
}
|
||||
}
|
||||
|
28
TelegramCore/SecureIdTemporaryRegistrationValue.swift
Normal file
28
TelegramCore/SecureIdTemporaryRegistrationValue.swift
Normal file
@ -0,0 +1,28 @@
|
||||
import Foundation
|
||||
|
||||
public struct SecureIdTemporaryRegistrationValue: Equatable {
|
||||
public var verificationDocuments: [SecureIdVerificationDocumentReference]
|
||||
|
||||
public init(verificationDocuments: [SecureIdVerificationDocumentReference]) {
|
||||
self.verificationDocuments = verificationDocuments
|
||||
}
|
||||
|
||||
public static func ==(lhs: SecureIdTemporaryRegistrationValue, rhs: SecureIdTemporaryRegistrationValue) -> Bool {
|
||||
if lhs.verificationDocuments != rhs.verificationDocuments {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
extension SecureIdTemporaryRegistrationValue {
|
||||
init?(fileReferences: [SecureIdVerificationDocumentReference]) {
|
||||
let verificationDocuments: [SecureIdVerificationDocumentReference] = fileReferences
|
||||
|
||||
self.init(verificationDocuments: verificationDocuments)
|
||||
}
|
||||
|
||||
func serialize() -> ([String: Any], [SecureIdVerificationDocumentReference]) {
|
||||
return ([:], self.verificationDocuments)
|
||||
}
|
||||
}
|
@ -3,8 +3,11 @@ import Foundation
|
||||
public enum SecureIdValueKey: Int32 {
|
||||
case personalDetails
|
||||
case passport
|
||||
case internalPassport
|
||||
case driversLicense
|
||||
case idCard
|
||||
case passportRegistration
|
||||
case temporaryRegistration
|
||||
case address
|
||||
case utilityBill
|
||||
case bankStatement
|
||||
@ -16,9 +19,12 @@ public enum SecureIdValueKey: Int32 {
|
||||
public enum SecureIdValue: Equatable {
|
||||
case personalDetails(SecureIdPersonalDetailsValue)
|
||||
case passport(SecureIdPassportValue)
|
||||
case internalPassport(SecureIdInternalPassportValue)
|
||||
case driversLicense(SecureIdDriversLicenseValue)
|
||||
case idCard(SecureIdIDCardValue)
|
||||
case address(SecureIdAddressValue)
|
||||
case passportRegistration(SecureIdPassportRegistrationValue)
|
||||
case temporaryRegistration(SecureIdTemporaryRegistrationValue)
|
||||
case utilityBill(SecureIdUtilityBillValue)
|
||||
case bankStatement(SecureIdBankStatementValue)
|
||||
case rentalAgreement(SecureIdRentalAgreementValue)
|
||||
@ -33,6 +39,12 @@ public enum SecureIdValue: Equatable {
|
||||
result.append(selfie)
|
||||
}
|
||||
return result
|
||||
case let .internalPassport(passport):
|
||||
var result = passport.verificationDocuments
|
||||
if let selfie = passport.selfieDocument {
|
||||
result.append(selfie)
|
||||
}
|
||||
return result
|
||||
case let .driversLicense(driversLicense):
|
||||
var result = driversLicense.verificationDocuments
|
||||
if let selfie = driversLicense.selfieDocument {
|
||||
@ -45,6 +57,10 @@ public enum SecureIdValue: Equatable {
|
||||
result.append(selfie)
|
||||
}
|
||||
return result
|
||||
case let .passportRegistration(passportRegistration):
|
||||
return passportRegistration.verificationDocuments
|
||||
case let .temporaryRegistration(passportRegistration):
|
||||
return passportRegistration.verificationDocuments
|
||||
case let .bankStatement(bankStatement):
|
||||
return bankStatement.verificationDocuments
|
||||
case let .utilityBill(utilityBill):
|
||||
@ -62,12 +78,18 @@ public enum SecureIdValue: Equatable {
|
||||
return .personalDetails
|
||||
case .passport:
|
||||
return .passport
|
||||
case .internalPassport:
|
||||
return .internalPassport
|
||||
case .driversLicense:
|
||||
return .driversLicense
|
||||
case .idCard:
|
||||
return .idCard
|
||||
case .address:
|
||||
return .address
|
||||
case .passportRegistration:
|
||||
return .passportRegistration
|
||||
case .temporaryRegistration:
|
||||
return .temporaryRegistration
|
||||
case .utilityBill:
|
||||
return .utilityBill
|
||||
case .bankStatement:
|
||||
@ -80,36 +102,6 @@ public enum SecureIdValue: Equatable {
|
||||
return .email
|
||||
}
|
||||
}
|
||||
|
||||
func serialize() -> ([String: Any], [SecureIdVerificationDocumentReference], SecureIdVerificationDocumentReference?)? {
|
||||
switch self {
|
||||
case let .personalDetails(personalDetails):
|
||||
let (dict, files) = personalDetails.serialize()
|
||||
return (dict, files, nil)
|
||||
case let .passport(passport):
|
||||
return passport.serialize()
|
||||
case let .driversLicense(driversLicense):
|
||||
return driversLicense.serialize()
|
||||
case let .idCard(idCard):
|
||||
return idCard.serialize()
|
||||
case let .address(address):
|
||||
let (dict, files) = address.serialize()
|
||||
return (dict, files, nil)
|
||||
case let .utilityBill(utilityBill):
|
||||
let (dict, files) = utilityBill.serialize()
|
||||
return (dict, files, nil)
|
||||
case let .bankStatement(bankStatement):
|
||||
let (dict, files) = bankStatement.serialize()
|
||||
return (dict, files, nil)
|
||||
case let .rentalAgreement(rentalAgreement):
|
||||
let (dict, files) = rentalAgreement.serialize()
|
||||
return (dict, files, nil)
|
||||
case .phone:
|
||||
return nil
|
||||
case .email:
|
||||
return nil
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct SecureIdEncryptedValueFileMetadata: Equatable {
|
||||
@ -127,14 +119,18 @@ public struct SecureIdValueWithContext: Equatable {
|
||||
public let errors: [SecureIdValueContentErrorKey: SecureIdValueContentError]
|
||||
let files: [SecureIdEncryptedValueFileMetadata]
|
||||
let selfie: SecureIdEncryptedValueFileMetadata?
|
||||
let frontSide: SecureIdEncryptedValueFileMetadata?
|
||||
let backSide: SecureIdEncryptedValueFileMetadata?
|
||||
let encryptedMetadata: SecureIdEncryptedValueMetadata?
|
||||
let opaqueHash: Data
|
||||
|
||||
init(value: SecureIdValue, errors: [SecureIdValueContentErrorKey: SecureIdValueContentError], files: [SecureIdEncryptedValueFileMetadata], selfie: SecureIdEncryptedValueFileMetadata?, encryptedMetadata: SecureIdEncryptedValueMetadata?, opaqueHash: Data) {
|
||||
init(value: SecureIdValue, errors: [SecureIdValueContentErrorKey: SecureIdValueContentError], files: [SecureIdEncryptedValueFileMetadata], selfie: SecureIdEncryptedValueFileMetadata?, frontSide: SecureIdEncryptedValueFileMetadata?, backSide: SecureIdEncryptedValueFileMetadata?, encryptedMetadata: SecureIdEncryptedValueMetadata?, opaqueHash: Data) {
|
||||
self.value = value
|
||||
self.errors = errors
|
||||
self.files = files
|
||||
self.selfie = selfie
|
||||
self.frontSide = frontSide
|
||||
self.backSide = backSide
|
||||
self.encryptedMetadata = encryptedMetadata
|
||||
self.opaqueHash = opaqueHash
|
||||
}
|
||||
@ -144,6 +140,6 @@ public struct SecureIdValueWithContext: Equatable {
|
||||
for key in keys {
|
||||
errors.removeValue(forKey: key)
|
||||
}
|
||||
return SecureIdValueWithContext(value: self.value, errors: errors, files: self.files, selfie: self.selfie, encryptedMetadata: self.encryptedMetadata, opaqueHash: self.opaqueHash)
|
||||
return SecureIdValueWithContext(value: self.value, errors: errors, files: self.files, selfie: self.selfie, frontSide: self.frontSide, backSide: self.backSide, encryptedMetadata: self.encryptedMetadata, opaqueHash: self.opaqueHash)
|
||||
}
|
||||
}
|
||||
|
@ -5,6 +5,8 @@ public enum SecureIdValueContentErrorKey: Hashable {
|
||||
case file(hash: Data)
|
||||
case files(hashes: Set<Data>)
|
||||
case selfie(hash: Data)
|
||||
case frontSide(hash: Data)
|
||||
case backSide(hash: Data)
|
||||
}
|
||||
|
||||
public enum SecureIdValueContentErrorField: Hashable {
|
||||
@ -49,7 +51,7 @@ public enum SecureIdValueContentErrorAddressField: String, Hashable {
|
||||
|
||||
public typealias SecureIdValueContentError = String
|
||||
|
||||
func parseSecureIdValueContentErrors(dataHash: Data?, fileHashes: Set<Data>, selfieHash: Data?, errors: [Api.SecureValueError]) -> [SecureIdValueContentErrorKey: SecureIdValueContentError] {
|
||||
func parseSecureIdValueContentErrors(dataHash: Data?, fileHashes: Set<Data>, selfieHash: Data?, frontSideHash: Data?, backSideHash: Data?, errors: [Api.SecureValueError]) -> [SecureIdValueContentErrorKey: SecureIdValueContentError] {
|
||||
var result: [SecureIdValueContentErrorKey: SecureIdValueContentError] = [:]
|
||||
for error in errors {
|
||||
switch error {
|
||||
@ -99,6 +101,14 @@ func parseSecureIdValueContentErrors(dataHash: Data?, fileHashes: Set<Data>, sel
|
||||
if selfieHash == fileHash.makeData() {
|
||||
result[.selfie(hash: fileHash.makeData())] = text
|
||||
}
|
||||
case .secureValueErrorFrontSide(let type, let fileHash, let text):
|
||||
if frontSideHash == fileHash.makeData() {
|
||||
result[.frontSide(hash: fileHash.makeData())] = text
|
||||
}
|
||||
case .secureValueErrorReverseSide(let type, let fileHash, let text):
|
||||
if backSideHash == fileHash.makeData() {
|
||||
result[.backSide(hash: fileHash.makeData())] = text
|
||||
}
|
||||
}
|
||||
}
|
||||
return result
|
||||
|
@ -23,6 +23,9 @@ public enum SentSecureValueType: Int32 {
|
||||
case rentalAgreement = 7
|
||||
case phone = 8
|
||||
case email = 9
|
||||
case internalPassport = 10
|
||||
case passportRegistration = 11
|
||||
case temporaryRegistration = 12
|
||||
}
|
||||
|
||||
public enum TelegramMediaActionType: PostboxCoding, Equatable {
|
||||
@ -431,6 +434,12 @@ extension SentSecureValueType {
|
||||
self = .phone
|
||||
case .secureValueTypeEmail:
|
||||
self = .email
|
||||
case .secureValueTypeInternalPassport:
|
||||
self = .internalPassport
|
||||
case .secureValueTypePassportRegistration:
|
||||
self = .passportRegistration
|
||||
case .secureValueTypeTemporaryRegistration:
|
||||
self = .temporaryRegistration
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user