Skip to content

Commit

Permalink
Expose AuthenticationRequest and AuthenticationResponse initializers (#…
Browse files Browse the repository at this point in the history
…57)

* Expose auth requests and response initializers

* Bump version

* Make properties public

* Update CHANGELOG.md

* Fix lint errors

* Pr suggestions
  • Loading branch information
JubrilO authored Aug 8, 2023
1 parent 3b1bc03 commit 0a6ceec
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 37 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
## 10.0.0-beta04

### Changed
- Expose `AuthenticationRequest` and `AuthenticationResponse` initializers and properties

## 10.0.0-beta03

### Changed
- Set default value for config param on `initilize` method
- Set default value for config param on `initialize` method
- Expose initializers for `PartnerParams` and `EnhancedKycAsycResponse` models

## 10.0.0-beta02
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ release notes

Full documentation is available at https://docs.smileidentity.com/integration-options/mobile

The [sample app](example/smileid) included in
The [sample app](Example) included in
this repo is a good reference implementation

#### 0. Requirements
Expand All @@ -36,7 +36,7 @@ You can add SmileID as a dependency by adding it to the `dependencies` value of

```swift
dependencies: [
.package(url: "https://github.com/smileidentity/ios.git", .upToNextMajor(from: "10.0.0-beta.01"))
.package(url: "https://github.com/smileidentity/ios.git", .upToNextMajor(from: "10.0.0-beta04"))
]
```

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.0.0-beta03'
s.version = '10.0.0-beta04'
s.summary = 'The Official Smile Identity iOS SDK.'
s.homepage = "https://docs.smileidentity.com/mobile/ios"
s.license = { :type => 'MIT', :file => 'LICENSE' }
s.author = { 'Jubril O' => 'jubril@smileidentity.com', 'Japhet' => 'japhet@smileidentity.com'}
s.source = { :git => "https://github.com/smileidentity/ios.git", :tag => "v10.0.0-beta03" }
s.source = { :git => "https://github.com/smileidentity/ios.git", :tag => "v10.0.0-beta04" }
s.ios.deployment_target = '13.0'
s.dependency 'Zip', '~> 2.1.0'
s.swift_version = '5.5'
Expand Down
64 changes: 37 additions & 27 deletions Sources/SmileID/Classes/Networking/Models/Authentication.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import Foundation

public struct AuthenticationRequest: Codable {
var jobType: JobType
var enrollment: Bool
var updateEnrolledImage: Bool?
var jobId: String?
var userId: String?
internal var signature = true
internal var production = !SmileID.useSandbox
internal var partnerId = SmileID.config.partnerId
internal var authToken = SmileID.config.authToken
public var jobType: JobType
public var enrollment: Bool
public var updateEnrolledImage: Bool?
public var jobId: String?
public var userId: String?
public var signature = true
public var production = !SmileID.useSandbox
public var partnerId = SmileID.config.partnerId
public var authToken = SmileID.config.authToken

enum CodingKeys: String, CodingKey {
case jobType = "job_type"
Expand All @@ -22,25 +22,25 @@ public struct AuthenticationRequest: Codable {
case partnerId = "partner_id"
case authToken = "auth_token"
}
}

public extension AuthenticationRequest {
init(jobType: JobType, enrollment: Bool, updateEnrolledImage: Bool, jobId: String, userId: String) {
self.init(jobType: jobType,
enrollment: enrollment,
updateEnrolledImage: updateEnrolledImage,
jobId: jobId,
userId: userId,
signature: true)
}

init(jobType: JobType, enrollment: Bool, userId: String, jobId: String) {
self.init(jobType: jobType,
enrollment: enrollment,
updateEnrolledImage: nil,
jobId: jobId,
userId: userId,
signature: true)
public init(jobType: JobType,
enrollment: Bool,
updateEnrolledImage: Bool? = nil,
jobId: String?,
userId: String?,
signature: Bool = true,
production: Bool = !SmileID.useSandbox,
partnerId: String = SmileID.config.partnerId,
authToken: String = SmileID.config.authToken) {
self.jobType = jobType
self.enrollment = enrollment
self.updateEnrolledImage = updateEnrolledImage
self.jobId = jobId
self.userId = userId
self.signature = signature
self.production = production
self.partnerId = partnerId
self.authToken = authToken
}
}

Expand All @@ -50,6 +50,16 @@ public struct AuthenticationResponse: Decodable {
public var timestamp: String
public var partnerParams: PartnerParams

public init(success: Bool,
signature: String,
timestamp: String,
partnerParams: PartnerParams) {
self.success = success
self.signature = signature
self.timestamp = timestamp
self.partnerParams = partnerParams
}

enum CodingKeys: String, CodingKey {
case success
case signature
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,8 +417,8 @@ final class SelfieCaptureViewModel: ObservableObject {
let jobType = isEnroll ? JobType.smartSelfieEnrollment : JobType.smartSelfieAuthentication
let authRequest = AuthenticationRequest(jobType: jobType,
enrollment: isEnroll,
userId: userId,
jobId: jobId)
jobId: jobId,
userId: userId)

SmileID.api.authenticate(request: authRequest)
.flatMap { authResponse in
Expand Down
7 changes: 4 additions & 3 deletions Sources/SmileID/Classes/SmileID.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// swiftlint:disable force_try
import Foundation
import UIKit
import SwiftUI
Expand All @@ -22,9 +23,9 @@ public class SmileID {
}()

private init() {}
public static let version = "10.0.0-beta03"
internal static var config: Config!
internal static var useSandbox = true
public static let version = "10.0.0-beta04"
public private(set) static var config: Config!
public private(set) static var useSandbox = true
public private(set) static var theme: SmileIdTheme = DefaultTheme()

public class func initialize(config: Config = try! Config(url: Bundle.main.url(forResource: "smile_config",
Expand Down

0 comments on commit 0a6ceec

Please sign in to comment.