Skip to content

Commit

Permalink
fix: partner params for v2 endpoints fix (#204)
Browse files Browse the repository at this point in the history
* fix: partner params for v2 endpoints fix

* remove force unwrapping on partner params

* fix: lint issues

* chore: bump version to 10.2.4
  • Loading branch information
JNdhlovu authored Jul 23, 2024
1 parent 611865a commit a53a9f1
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 72 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
# Release Notes
## 10.2.4

#### Fixed
* Partner params fix on v2 endpoints

## 10.2.3

#### Added
Expand Down
4 changes: 2 additions & 2 deletions Example/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -32,7 +32,7 @@ SPEC CHECKSUMS:
lottie-ios: fcb5e73e17ba4c983140b7d21095c834b3087418
netfox: 9d5cc727fe7576c4c7688a2504618a156b7d44b7
Sentry: 9c1188876ea1291d1a9db4b38c3f17ebd8e6985e
SmileID: b3537761dcf70005ed0ad412836a14d866c8c55e
SmileID: d36a5ed65e9c2ee44b5199bc97bb0f174834c326
SwiftLint: 3fe909719babe5537c552ee8181c0031392be933
Zip: b3fef584b147b6e582b2256a9815c897d60ddc67

Expand Down
4 changes: 2 additions & 2 deletions SmileID.podspec
Original file line number Diff line number Diff line change
@@ -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' => '[email protected]', 'Juma Allan' => '[email protected]', 'Vansh Gandhi' => '[email protected]'}
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'
Expand Down
138 changes: 71 additions & 67 deletions Sources/SmileID/Classes/Networking/ServiceRunnable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
2 changes: 1 addition & 1 deletion Sources/SmileID/Classes/SmileID.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 }

Expand Down

0 comments on commit a53a9f1

Please sign in to comment.