diff --git a/CHANGELOG.md b/CHANGELOG.md index 29a9cc43f..dccdbe08a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ # Release Notes +## 10.2.4 + +#### Fixed +* Partner params fix on v2 endpoints + ## 10.2.3 #### Added diff --git a/Example/Podfile.lock b/Example/Podfile.lock index ffc78f9bc..4b51ccb5a 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -4,7 +4,7 @@ PODS: - Sentry (8.31.1): - Sentry/Core (= 8.31.1) - Sentry/Core (8.31.1) - - SmileID (10.2.3): + - SmileID (10.2.4): - lottie-ios (~> 4.4.2) - Zip (~> 2.1.0) - SwiftLint (0.55.1) @@ -32,7 +32,7 @@ SPEC CHECKSUMS: lottie-ios: fcb5e73e17ba4c983140b7d21095c834b3087418 netfox: 9d5cc727fe7576c4c7688a2504618a156b7d44b7 Sentry: 9c1188876ea1291d1a9db4b38c3f17ebd8e6985e - SmileID: b3537761dcf70005ed0ad412836a14d866c8c55e + SmileID: d36a5ed65e9c2ee44b5199bc97bb0f174834c326 SwiftLint: 3fe909719babe5537c552ee8181c0031392be933 Zip: b3fef584b147b6e582b2256a9815c897d60ddc67 diff --git a/SmileID.podspec b/SmileID.podspec index 8d8785db5..45bd48c76 100644 --- a/SmileID.podspec +++ b/SmileID.podspec @@ -1,11 +1,11 @@ Pod::Spec.new do |s| s.name = 'SmileID' - s.version = '10.2.3' + s.version = '10.2.4' s.summary = 'The Official Smile Identity iOS SDK.' s.homepage = 'https://docs.usesmileid.com/integration-options/mobile/ios-v10-beta' s.license = { :type => 'MIT', :file => 'LICENSE' } 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.3" } + s.source = { :git => "https://github.com/smileidentity/ios.git", :tag => "v10.2.4" } s.ios.deployment_target = '13.0' s.dependency 'Zip', '~> 2.1.0' s.dependency 'lottie-ios', '~> 4.4.2' diff --git a/Sources/SmileID/Classes/Networking/ServiceRunnable.swift b/Sources/SmileID/Classes/Networking/ServiceRunnable.swift index 6e32bc841..c54fdc474 100644 --- a/Sources/SmileID/Classes/Networking/ServiceRunnable.swift +++ b/Sources/SmileID/Classes/Networking/ServiceRunnable.swift @@ -224,87 +224,91 @@ extension ServiceRunnable { // swiftlint:disable line_length cyclomatic_complexity func createMultiPartRequestData( - selfieImage: MultipartBody, - livenessImages: [MultipartBody], - userId: String?, - partnerParams: [String: String]?, - callbackUrl: String?, - sandboxResult: Int?, - allowNewEnroll: Bool?, - boundary: String - ) -> Data { - let lineBreak = "\r\n" - var body = Data() - - // Append parameters if available - if let parameters = partnerParams { - for (key, value) in parameters { - if let valueData = "\(value)\(lineBreak)".data(using: .utf8) { - body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) - body.append("Content-Disposition: form-data; name=\"\(key)\"\(lineBreak + lineBreak)".data(using: .utf8)!) - body.append(valueData) - } - } - } - - // Append userId if available - if let userId = userId { - if let valueData = "\(userId)\(lineBreak)".data(using: .utf8) { - body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) - body.append("Content-Disposition: form-data; name=\"user_id\"\(lineBreak + lineBreak)".data(using: .utf8)!) - body.append(valueData) + selfieImage: MultipartBody, + livenessImages: [MultipartBody], + userId: String?, + partnerParams: [String: String]?, + callbackUrl: String?, + sandboxResult: Int?, + allowNewEnroll: Bool?, + boundary: String + ) -> Data { + let lineBreak = "\r\n" + var body = Data() + + // Append parameters if available + if let parameters = partnerParams { + if let boundaryData = "--\(boundary)\(lineBreak)".data(using: .utf8), + let dispositionData = "Content-Disposition: form-data; name=\"partner_params\"\(lineBreak)".data(using: .utf8), + let contentTypeData = "Content-Type: application/json\(lineBreak + lineBreak)".data(using: .utf8), + let lineBreakData = lineBreak.data(using: .utf8) { + body.append(boundaryData) + body.append(dispositionData) + body.append(contentTypeData) + + if let jsonData = try? JSONSerialization.data(withJSONObject: parameters, options: []) { + body.append(jsonData) + body.append(lineBreakData) } } + } - // Append callbackUrl if available - if let callbackUrl = callbackUrl { - if let valueData = "\(callbackUrl)\(lineBreak)".data(using: .utf8) { - body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) - body.append("Content-Disposition: form-data; name=\"callback_url\"\(lineBreak + lineBreak)".data(using: .utf8)!) - body.append(valueData) - } + // Append userId if available + if let userId = userId { + if let valueData = "\(userId)\(lineBreak)".data(using: .utf8) { + body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) + body.append("Content-Disposition: form-data; name=\"user_id\"\(lineBreak + lineBreak)".data(using: .utf8)!) + body.append(valueData) } + } - // Append sandboxResult if available - if let sandboxResult = sandboxResult { - let sandboxResultString = "\(sandboxResult)" - if let valueData = "\(sandboxResultString)\(lineBreak)".data(using: .utf8) { - body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) - body.append("Content-Disposition: form-data; name=\"sandbox_result\"\(lineBreak + lineBreak)".data(using: .utf8)!) - body.append(valueData) - } + // Append callbackUrl if available + if let callbackUrl = callbackUrl { + if let valueData = "\(callbackUrl)\(lineBreak)".data(using: .utf8) { + body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) + body.append("Content-Disposition: form-data; name=\"callback_url\"\(lineBreak + lineBreak)".data(using: .utf8)!) + body.append(valueData) } + } - // Append allowNewEnroll if available - if let allowNewEnroll = allowNewEnroll { - let allowNewEnrollString = "\(allowNewEnroll)" - if let valueData = "\(allowNewEnrollString)\(lineBreak)".data(using: .utf8) { - body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) - body.append("Content-Disposition: form-data; name=\"allow_new_enroll\"\(lineBreak + lineBreak)".data(using: .utf8)!) - body.append(valueData) - } + // Append sandboxResult if available + if let sandboxResult = sandboxResult { + let sandboxResultString = "\(sandboxResult)" + if let valueData = "\(sandboxResultString)\(lineBreak)".data(using: .utf8) { + body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) + body.append("Content-Disposition: form-data; name=\"sandbox_result\"\(lineBreak + lineBreak)".data(using: .utf8)!) + body.append(valueData) } + } - // Append liveness media files - for item in livenessImages { + // Append allowNewEnroll if available + if let allowNewEnroll = allowNewEnroll { + let allowNewEnrollString = "\(allowNewEnroll)" + if let valueData = "\(allowNewEnrollString)\(lineBreak)".data(using: .utf8) { body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) - body.append("Content-Disposition: form-data; name=\"\("liveness_images")\"; filename=\"\(item.filename)\"\(lineBreak)".data(using: .utf8)!) - body.append("Content-Type: \(item.mimeType)\(lineBreak + lineBreak)".data(using: .utf8)!) - body.append(item.data) - body.append(lineBreak.data(using: .utf8)!) + body.append("Content-Disposition: form-data; name=\"allow_new_enroll\"\(lineBreak + lineBreak)".data(using: .utf8)!) + body.append(valueData) } + } - // Append selfie media file + // Append liveness media files + for item in livenessImages { body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) - body.append("Content-Disposition: form-data; name=\"\("selfie_image")\"; filename=\"\(selfieImage.filename)\"\(lineBreak)".data(using: .utf8)!) - body.append("Content-Type: \(selfieImage.mimeType)\(lineBreak + lineBreak)".data(using: .utf8)!) - body.append(selfieImage.data) + body.append("Content-Disposition: form-data; name=\"\("liveness_images")\"; filename=\"\(item.filename)\"\(lineBreak)".data(using: .utf8)!) + body.append("Content-Type: \(item.mimeType)\(lineBreak + lineBreak)".data(using: .utf8)!) + body.append(item.data) body.append(lineBreak.data(using: .utf8)!) - - // Append final boundary - body.append("--\(boundary)--\(lineBreak)".data(using: .utf8)!) - - return body } + // Append selfie media file + body.append("--\(boundary)\(lineBreak)".data(using: .utf8)!) + body.append("Content-Disposition: form-data; name=\"\("selfie_image")\"; filename=\"\(selfieImage.filename)\"\(lineBreak)".data(using: .utf8)!) + body.append("Content-Type: \(selfieImage.mimeType)\(lineBreak + lineBreak)".data(using: .utf8)!) + body.append(selfieImage.data) + body.append(lineBreak.data(using: .utf8)!) + + // Append final boundary + body.append("--\(boundary)--\(lineBreak)".data(using: .utf8)!) + return body + } } diff --git a/Sources/SmileID/Classes/SmileID.swift b/Sources/SmileID/Classes/SmileID.swift index 08230495d..fedecc6e7 100644 --- a/Sources/SmileID/Classes/SmileID.swift +++ b/Sources/SmileID/Classes/SmileID.swift @@ -3,7 +3,7 @@ import SwiftUI import UIKit public class SmileID { - public static let version = "10.2.3" + public static let version = "10.2.4" @Injected var injectedApi: SmileIDServiceable public static var configuration: Config { config }