diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 3db08726a..1e411379b 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,14 +1,14 @@ PODS: - lottie-ios (4.4.3) - netfox (1.21.0) - - Sentry (8.31.1): - - Sentry/Core (= 8.31.1) - - Sentry/Core (8.31.1) + - Sentry (8.32.0): + - Sentry/Core (= 8.32.0) + - Sentry/Core (8.32.0) - SmileID (10.2.5): - lottie-ios (~> 4.4.2) - - Zip (~> 2.1.0) + - ZIPFoundation (~> 0.9) - SwiftLint (0.55.1) - - Zip (2.1.2) + - ZIPFoundation (0.9.19) DEPENDENCIES: - netfox @@ -22,7 +22,7 @@ SPEC REPOS: - netfox - Sentry - SwiftLint - - Zip + - ZIPFoundation EXTERNAL SOURCES: SmileID: @@ -31,10 +31,10 @@ EXTERNAL SOURCES: SPEC CHECKSUMS: lottie-ios: fcb5e73e17ba4c983140b7d21095c834b3087418 netfox: 9d5cc727fe7576c4c7688a2504618a156b7d44b7 - Sentry: 9c1188876ea1291d1a9db4b38c3f17ebd8e6985e - SmileID: 09d42fdc65cd4d2b0d33fd33e14e8c85a189a64b + Sentry: 96ae1dcdf01a644bc3a3b1dc279cecaf48a833fb + SmileID: d10c749a7ed7ccfa6eeb83bc3ae564d81f298414 SwiftLint: 3fe909719babe5537c552ee8181c0031392be933 - Zip: b3fef584b147b6e582b2256a9815c897d60ddc67 + ZIPFoundation: b8c29ea7ae353b309bc810586181fd073cb3312c PODFILE CHECKSUM: 8f7be2cf75babf479684f1e21d344f4c640486be diff --git a/Package.resolved b/Package.resolved index 70f67360c..1d8b42aa1 100644 --- a/Package.resolved +++ b/Package.resolved @@ -3,19 +3,19 @@ { "identity" : "lottie-spm", "kind" : "remoteSourceControl", - "location" : "https://github.com/airbnb/lottie-spm.git", + "location" : "https://github.com/airbnb/lottie-spm", "state" : { - "revision" : "1d29eccc24cc8b75bff9f6804155112c0ffc9605", - "version" : "4.4.3" + "revision" : "b842598f1295f3ffa1475b1580672d1fe5b83580", + "version" : "4.5.0" } }, { - "identity" : "zip", + "identity" : "zipfoundation", "kind" : "remoteSourceControl", - "location" : "https://github.com/marmelroy/Zip", + "location" : "https://github.com/weichsel/ZIPFoundation.git", "state" : { - "revision" : "67fa55813b9e7b3b9acee9c0ae501def28746d76", - "version" : "2.1.2" + "revision" : "02b6abe5f6eef7e3cbd5f247c5cc24e246efcfe0", + "version" : "0.9.19" } } ], diff --git a/Package.swift b/Package.swift index 3cee388bd..1de24f30d 100644 --- a/Package.swift +++ b/Package.swift @@ -13,13 +13,13 @@ let package = Package( ) ], dependencies: [ - .package(url: "https://github.com/marmelroy/Zip", .upToNextMajor(from: "2.1.0")), + .package(url: "https://github.com/weichsel/ZIPFoundation.git", .upToNextMajor(from: "0.9.0")), .package(url: "https://github.com/airbnb/lottie-spm", from: "4.4.2") ], targets: [ .target( name: "SmileID", - dependencies: ["Zip", .product(name: "Lottie", package: "lottie-spm")], + dependencies: ["ZIPFoundation", .product(name: "Lottie", package: "lottie-spm")], path: "Sources/SmileID", resources: [.process("Resources")] ), diff --git a/SmileID.podspec b/SmileID.podspec index 84acbc933..f58984cbb 100644 --- a/SmileID.podspec +++ b/SmileID.podspec @@ -7,7 +7,7 @@ Pod::Spec.new do |s| s.author = { 'Japhet' => 'japhet@usesmileid.com', 'Juma Allan' => 'juma@usesmileid.com', 'Vansh Gandhi' => 'vansh@usesmileid.com'} s.source = { :git => "https://github.com/smileidentity/ios.git", :tag => "v10.2.5" } s.ios.deployment_target = '13.0' - s.dependency 'Zip', '~> 2.1.0' + s.dependency 'ZIPFoundation', '~> 0.9' s.dependency 'lottie-ios', '~> 4.4.2' s.swift_version = '5.5' s.source_files = 'Sources/SmileID/Classes/**/*' diff --git a/Sources/SmileID/Classes/BiometricKYC/OrchestratedBiometricKycViewModel.swift b/Sources/SmileID/Classes/BiometricKYC/OrchestratedBiometricKycViewModel.swift index 7b024c997..ad1b76827 100644 --- a/Sources/SmileID/Classes/BiometricKYC/OrchestratedBiometricKycViewModel.swift +++ b/Sources/SmileID/Classes/BiometricKYC/OrchestratedBiometricKycViewModel.swift @@ -78,10 +78,9 @@ internal class OrchestratedBiometricKycViewModel: ObservableObject { selfie: selfieImage, livenessImages: livenessImages ) - let zipUrl = try LocalStorage.zipFiles( + let zipData = try LocalStorage.zipFiles( at: livenessImages + [selfieImage] + [infoJson] ) - let zip = try Data(contentsOf: zipUrl) let authRequest = AuthenticationRequest( jobType: .biometricKyc, enrollment: false, @@ -123,7 +122,7 @@ internal class OrchestratedBiometricKycViewModel: ObservableObject { } } _ = try await SmileID.api.upload( - zip: zip, + zip: zipData, to: prepUploadResponse.uploadUrl ) didSubmitBiometricJob = true diff --git a/Sources/SmileID/Classes/DocumentVerification/Model/OrchestratedDocumentVerificationViewModel.swift b/Sources/SmileID/Classes/DocumentVerification/Model/OrchestratedDocumentVerificationViewModel.swift index 504a42bb6..93d605648 100644 --- a/Sources/SmileID/Classes/DocumentVerification/Model/OrchestratedDocumentVerificationViewModel.swift +++ b/Sources/SmileID/Classes/DocumentVerification/Model/OrchestratedDocumentVerificationViewModel.swift @@ -154,8 +154,7 @@ internal class IOrchestratedDocumentVerificationViewModel: Obse livenessImages: livenessFiles ) allFiles.append(info) - let zipUrl = try LocalStorage.zipFiles(at: allFiles) - zip = try Data(contentsOf: zipUrl) + let zipData = try LocalStorage.zipFiles(at: allFiles) self.savedFiles = DocumentCaptureResultStore( allFiles: allFiles, documentFront: frontDocumentUrl, @@ -202,7 +201,7 @@ internal class IOrchestratedDocumentVerificationViewModel: Obse } } _ = try await SmileID.api.upload( - zip: zip, + zip: zipData, to: prepUploadResponse.uploadUrl ) didSubmitJob = true diff --git a/Sources/SmileID/Classes/Helpers/LocalStorage.swift b/Sources/SmileID/Classes/Helpers/LocalStorage.swift index cac5e06c1..e8020cef3 100644 --- a/Sources/SmileID/Classes/Helpers/LocalStorage.swift +++ b/Sources/SmileID/Classes/Helpers/LocalStorage.swift @@ -1,5 +1,5 @@ import Foundation -import Zip +import ZIPFoundation public class LocalStorage { private static let defaultFolderName = "SmileID" @@ -300,23 +300,12 @@ public class LocalStorage { } } - // todo - rework this as we change zip library - public static func toZip( - uploadRequest: UploadRequest, - to folder: String = "sid-\(UUID().uuidString)" - ) throws -> URL { - try createDirectory(at: defaultDirectory) - let destinationFolder = try defaultDirectory.appendingPathComponent(folder) - let jsonData = try jsonEncoder.encode(uploadRequest) - let jsonUrl = try write(jsonData, to: destinationFolder.appendingPathComponent("info.json")) - let imageUrls = uploadRequest.images.map { imageInfo in - destinationFolder.appendingPathComponent(imageInfo.fileName) + public static func zipFiles(at urls: [URL]) throws -> Data { + let archive = try Archive(accessMode: .create) + for url in urls { + try archive.addEntry(with: url.lastPathComponent, fileURL: url) } - return try zipFiles(at: [jsonUrl] + imageUrls) - } - - public static func zipFiles(at urls: [URL]) throws -> URL { - try Zip.quickZipFiles(urls, fileName: "upload") + return archive.data! } private static func delete(at url: URL) throws { diff --git a/Sources/SmileID/Classes/SmileID.swift b/Sources/SmileID/Classes/SmileID.swift index ea66eb4cd..85047ec20 100644 --- a/Sources/SmileID/Classes/SmileID.swift +++ b/Sources/SmileID/Classes/SmileID.swift @@ -169,10 +169,9 @@ public class SmileID { } catch { throw error } - let zipUrl = try LocalStorage.zipFiles(at: allFiles) - zip = try Data(contentsOf: zipUrl) + let zipData = try LocalStorage.zipFiles(at: allFiles) _ = try await SmileID.api.upload( - zip: zip, + zip: zipData, to: prepUploadResponse.uploadUrl ) if deleteFilesOnSuccess {