Skip to content

Commit a61d51f

Browse files
Merge pull request #40 from Cidaas/development
Development
2 parents 160ffd5 + 930b38f commit a61d51f

File tree

14 files changed

+547
-25
lines changed

14 files changed

+547
-25
lines changed

Cidaas.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = 'Cidaas'
11-
s.version = '1.0.8'
11+
s.version = '1.0.9'
1212
s.summary = 'Native SDK for iOS providing login, registration and verification functionalities'
1313
s.homepage = 'https://github.com/Cidaas/cidaas-sdk-ios-v2'
1414
s.license = { :type => 'MIT', :file => 'LICENSE' }
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
//
2+
// SettingsController.swift
3+
// Cidaas
4+
//
5+
// Created by ganesh on 27/11/18.
6+
//
7+
8+
import Foundation
9+
10+
public class SettingsController {
11+
12+
// shared instance
13+
public static var shared : SettingsController = SettingsController()
14+
15+
// constructor
16+
public init() {
17+
18+
}
19+
20+
// get end points
21+
public func getEndpoints(properties: Dictionary<String, String>, callback: @escaping (Result<EndpointsResponseEntity>) -> Void) {
22+
23+
// null check
24+
if properties["DomainURL"] == "" || properties["DomainURL"] == nil {
25+
let error = WebAuthError.shared.propertyMissingException()
26+
// log error
27+
let loggerMessage = "Read properties failure : " + "Error Code - " + String(describing: error.errorCode) + ", Error Message - " + error.errorMessage + ", Status Code - " + String(describing: error.statusCode)
28+
logw(loggerMessage, cname: "cidaas-sdk-error-log")
29+
30+
DispatchQueue.main.async {
31+
callback(Result.failure(error: error))
32+
}
33+
return
34+
}
35+
36+
// call getEndpoints service
37+
SettingsService.shared.getEndpoints(properties: properties) {
38+
switch $0 {
39+
case .failure(let error):
40+
// log error
41+
let loggerMessage = "Get endpoints service failure : " + "Error Code - " + String(describing: error.errorCode) + ", Error Message - " + error.errorMessage + ", Status Code - " + String(describing: error.statusCode)
42+
logw(loggerMessage, cname: "cidaas-sdk-error-log")
43+
44+
// return failure callback
45+
DispatchQueue.main.async {
46+
callback(Result.failure(error: error))
47+
}
48+
return
49+
case .success(let serviceResponse):
50+
// log success
51+
let loggerMessage = "Get endpoints service success : " + "Authz URL - " + serviceResponse.authorization_endpoint
52+
logw(loggerMessage, cname: "cidaas-sdk-success-log")
53+
54+
// return callback
55+
DispatchQueue.main.async {
56+
callback(Result.success(result: serviceResponse))
57+
}
58+
}
59+
}
60+
}
61+
}

Cidaas/Classes/Core/Controllers/Repository/Verification/Face/FaceVerificationController.swift

Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,7 @@ public class FaceVerificationController {
281281

282282
// Web to Mobile
283283
// enroll Face from properties
284-
public func enrollFaceRecognition(access_token: String, photo: UIImage, enrollFaceEntity: EnrollFaceEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollFaceResponseEntity>) -> Void) {
284+
public func enrollFaceRecognition(sub: String = "", access_token: String, photo: UIImage, enrollFaceEntity: EnrollFaceEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollFaceResponseEntity>) -> Void) {
285285
// null check
286286
if properties["DomainURL"] == "" || properties["DomainURL"] == nil || properties["ClientId"] == "" || properties["ClientId"] == nil {
287287
let error = WebAuthError.shared.propertyMissingException()
@@ -309,11 +309,42 @@ public class FaceVerificationController {
309309
return
310310
}
311311

312+
if access_token == "" {
313+
if sub == "" {
314+
let error = WebAuthError.shared.propertyMissingException()
315+
error.errorMessage = "access_token or sub must not be empty"
316+
DispatchQueue.main.async {
317+
callback(Result.failure(error: error))
318+
}
319+
return
320+
}
321+
}
322+
312323
// default set intermediate id to empty
313324
Cidaas.intermediate_verifiation_id = intermediate_id
314325
self.verificationType = VerificationTypes.FACE.rawValue
315326
self.authenticationType = AuthenticationTypes.CONFIGURE.rawValue
316327

328+
if access_token == "" {
329+
Cidaas.shared.getAccessToken(sub: sub) {
330+
switch $0 {
331+
case .success(let successResponse):
332+
self.enrollFaceAPI(access_token: successResponse.data.access_token, photo: photo, enrollFaceEntity: enrollFaceEntity, properties: properties, callback: callback)
333+
break
334+
case .failure(let error):
335+
DispatchQueue.main.async {
336+
callback(Result.failure(error: error))
337+
}
338+
break
339+
}
340+
}
341+
}
342+
else {
343+
self.enrollFaceAPI(access_token: access_token, photo: photo, enrollFaceEntity: enrollFaceEntity, properties: properties, callback: callback)
344+
}
345+
}
346+
347+
private func enrollFaceAPI(access_token: String, photo: UIImage, enrollFaceEntity: EnrollFaceEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollFaceResponseEntity>) -> Void) {
317348
// call enroll service
318349
FaceVerificationService.shared.enrollFace(accessToken:access_token, photo: photo, enrollFaceEntity: enrollFaceEntity, properties: properties) {
319350
switch $0 {

Cidaas/Classes/Core/Controllers/Repository/Verification/Pattern/PatternVerificationController.swift

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ public class PatternVerificationController {
294294

295295
// Web to Mobile
296296
// enroll PatternRecognition from properties
297-
public func enrollPatternRecognition(access_token: String, enrollPatternEntity: EnrollPatternEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollPatternResponseEntity>) -> Void) {
297+
public func enrollPatternRecognition(sub: String = "", access_token: String = "", enrollPatternEntity: EnrollPatternEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollPatternResponseEntity>) -> Void) {
298298
// null check
299299
if properties["DomainURL"] == "" || properties["DomainURL"] == nil || properties["ClientId"] == "" || properties["ClientId"] == nil {
300300
let error = WebAuthError.shared.propertyMissingException()
@@ -322,11 +322,42 @@ public class PatternVerificationController {
322322
return
323323
}
324324

325+
if access_token == "" {
326+
if sub == "" {
327+
let error = WebAuthError.shared.propertyMissingException()
328+
error.errorMessage = "access_token or sub must not be empty"
329+
DispatchQueue.main.async {
330+
callback(Result.failure(error: error))
331+
}
332+
return
333+
}
334+
}
335+
325336
// default set intermediate id to empty
326337
Cidaas.intermediate_verifiation_id = intermediate_id
327338
self.verificationType = VerificationTypes.PATTERN.rawValue
328339
self.authenticationType = AuthenticationTypes.CONFIGURE.rawValue
329340

341+
if access_token == "" {
342+
Cidaas.shared.getAccessToken(sub: sub) {
343+
switch $0 {
344+
case .success(let successResponse):
345+
self.enrollPatternAPI(access_token: successResponse.data.access_token, enrollPatternEntity: enrollPatternEntity, properties: properties, callback: callback)
346+
break
347+
case .failure(let error):
348+
DispatchQueue.main.async {
349+
callback(Result.failure(error: error))
350+
}
351+
break
352+
}
353+
}
354+
}
355+
else {
356+
self.enrollPatternAPI(access_token: access_token, enrollPatternEntity: enrollPatternEntity, properties: properties, callback: callback)
357+
}
358+
}
359+
360+
private func enrollPatternAPI(access_token: String, enrollPatternEntity: EnrollPatternEntity, properties: Dictionary<String, String>, callback: @escaping(Result<EnrollPatternResponseEntity>) -> Void) {
330361
// call enroll service
331362
PatternVerificationService.shared.enrollPattern(accessToken:access_token, enrollPatternEntity: enrollPatternEntity, properties: properties) {
332363
switch $0 {
@@ -404,7 +435,6 @@ public class PatternVerificationController {
404435
}
405436
}
406437

407-
408438
// login with pattern recognition from properties
409439
public func loginWithPatternRecognition(pattern: String, email : String, mobile: String, sub: String, trackId: String, requestId: String, usageType: String, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<LoginResponseEntity>) -> Void) {
410440
// null check

Cidaas/Classes/Core/Controllers/Repository/Verification/Push/PushVerificationController.swift

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ public class PushVerificationController {
285285

286286
// Web to Mobile
287287
// enroll push from properties
288-
public func enrollPush(access_token: String, enrollPushEntity: EnrollPushEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollPushResponseEntity>) -> Void) {
288+
public func enrollPush(sub: String = "", access_token: String, enrollPushEntity: EnrollPushEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollPushResponseEntity>) -> Void) {
289289
// null check
290290
if properties["DomainURL"] == "" || properties["DomainURL"] == nil || properties["ClientId"] == "" || properties["ClientId"] == nil {
291291
let error = WebAuthError.shared.propertyMissingException()
@@ -313,11 +313,43 @@ public class PushVerificationController {
313313
return
314314
}
315315

316+
if access_token == "" {
317+
if sub == "" {
318+
let error = WebAuthError.shared.propertyMissingException()
319+
error.errorMessage = "access_token or sub must not be empty"
320+
DispatchQueue.main.async {
321+
callback(Result.failure(error: error))
322+
}
323+
return
324+
}
325+
}
326+
316327
// default set intermediate id to empty
317328
Cidaas.intermediate_verifiation_id = intermediate_id
318329
self.verificationType = VerificationTypes.PUSH.rawValue
319330
self.authenticationType = AuthenticationTypes.CONFIGURE.rawValue
320331

332+
333+
if access_token == "" {
334+
Cidaas.shared.getAccessToken(sub: sub) {
335+
switch $0 {
336+
case .success(let successResponse):
337+
self.enrollPushAPI(access_token: successResponse.data.access_token, enrollPushEntity: enrollPushEntity, properties: properties, callback: callback)
338+
break
339+
case .failure(let error):
340+
DispatchQueue.main.async {
341+
callback(Result.failure(error: error))
342+
}
343+
break
344+
}
345+
}
346+
}
347+
else {
348+
self.enrollPushAPI(access_token: access_token, enrollPushEntity: enrollPushEntity, properties: properties, callback: callback)
349+
}
350+
}
351+
352+
private func enrollPushAPI(access_token: String, enrollPushEntity: EnrollPushEntity, properties: Dictionary<String, String>, callback: @escaping(Result<EnrollPushResponseEntity>) -> Void) {
321353
// call enroll service
322354
PushVerificationService.shared.enrollPush(accessToken:access_token, enrollPushEntity: enrollPushEntity, properties: properties) {
323355
switch $0 {

Cidaas/Classes/Core/Controllers/Repository/Verification/Touch/TouchIdVerificationController.swift

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public class TouchIdVerificationController {
133133
enrollTouchEntity.statusId = self.statusId
134134

135135
// call scanned TouchId service
136-
TouchIdVerificationController.shared.enrollToucId(access_token:tokenResponse.data.access_token, enrollTouchEntity: enrollTouchEntity, properties: properties) {
136+
TouchIdVerificationController.shared.enrollTouchId(access_token:tokenResponse.data.access_token, enrollTouchEntity: enrollTouchEntity, properties: properties) {
137137
switch $0 {
138138
case .failure(let error):
139139
// return failure callback
@@ -283,7 +283,7 @@ public class TouchIdVerificationController {
283283

284284
// Web to Mobile
285285
// enroll Touch Id from properties
286-
public func enrollToucId(access_token: String, enrollTouchEntity: EnrollTouchEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollTouchResponseEntity>) -> Void) {
286+
public func enrollTouchId(sub: String = "", access_token: String, enrollTouchEntity: EnrollTouchEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollTouchResponseEntity>) -> Void) {
287287
// null check
288288
if properties["DomainURL"] == "" || properties["DomainURL"] == nil || properties["ClientId"] == "" || properties["ClientId"] == nil {
289289
let error = WebAuthError.shared.propertyMissingException()
@@ -311,11 +311,42 @@ public class TouchIdVerificationController {
311311
return
312312
}
313313

314+
if access_token == "" {
315+
if sub == "" {
316+
let error = WebAuthError.shared.propertyMissingException()
317+
error.errorMessage = "access_token or sub must not be empty"
318+
DispatchQueue.main.async {
319+
callback(Result.failure(error: error))
320+
}
321+
return
322+
}
323+
}
324+
314325
// default set intermediate id to empty
315326
Cidaas.intermediate_verifiation_id = intermediate_id
316327
self.verificationType = VerificationTypes.TOUCH.rawValue
317328
self.authenticationType = AuthenticationTypes.CONFIGURE.rawValue
318329

330+
if access_token == "" {
331+
Cidaas.shared.getAccessToken(sub: sub) {
332+
switch $0 {
333+
case .success(let successResponse):
334+
self.enrollTouchAPI(access_token: successResponse.data.access_token, enrollTouchEntity: enrollTouchEntity, properties: properties, callback: callback)
335+
break
336+
case .failure(let error):
337+
DispatchQueue.main.async {
338+
callback(Result.failure(error: error))
339+
}
340+
break
341+
}
342+
}
343+
}
344+
else {
345+
self.enrollTouchAPI(access_token: access_token, enrollTouchEntity: enrollTouchEntity, properties: properties, callback: callback)
346+
}
347+
}
348+
349+
private func enrollTouchAPI(access_token: String, enrollTouchEntity: EnrollTouchEntity, properties: Dictionary<String, String>, callback: @escaping(Result<EnrollTouchResponseEntity>) -> Void) {
319350
// call enroll service
320351
TouchIdVerificationService.shared.enrollTouchId(accessToken:access_token, enrollTouchIdEntity: enrollTouchEntity, properties: properties) {
321352
switch $0 {
@@ -393,7 +424,6 @@ public class TouchIdVerificationController {
393424
}
394425
}
395426

396-
397427
// login with TouchId from properties
398428
public func loginWithTouchId(email : String, mobile: String, sub: String, trackId: String, requestId: String, usageType: String, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<LoginResponseEntity>) -> Void) {
399429
// null check

Cidaas/Classes/Core/Controllers/Repository/Verification/Voice/VoiceVerificationController.swift

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public class VoiceVerificationController {
280280

281281
// Web to Mobile
282282
// enroll Voice from properties
283-
public func enrollVoiceRecognition(access_token: String, voice: Data, enrollVoiceEntity: EnrollVoiceEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollVoiceResponseEntity>) -> Void) {
283+
public func enrollVoiceRecognition(sub: String = "", access_token: String, voice: Data, enrollVoiceEntity: EnrollVoiceEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollVoiceResponseEntity>) -> Void) {
284284
// null check
285285
if properties["DomainURL"] == "" || properties["DomainURL"] == nil || properties["ClientId"] == "" || properties["ClientId"] == nil {
286286
let error = WebAuthError.shared.propertyMissingException()
@@ -308,11 +308,42 @@ public class VoiceVerificationController {
308308
return
309309
}
310310

311+
if access_token == "" {
312+
if sub == "" {
313+
let error = WebAuthError.shared.propertyMissingException()
314+
error.errorMessage = "access_token or sub must not be empty"
315+
DispatchQueue.main.async {
316+
callback(Result.failure(error: error))
317+
}
318+
return
319+
}
320+
}
321+
311322
// default set intermediate id to empty
312323
Cidaas.intermediate_verifiation_id = intermediate_id
313324
self.verificationType = VerificationTypes.VOICE.rawValue
314325
self.authenticationType = AuthenticationTypes.CONFIGURE.rawValue
315326

327+
if access_token == "" {
328+
Cidaas.shared.getAccessToken(sub: sub) {
329+
switch $0 {
330+
case .success(let successResponse):
331+
self.enrollVoiceAPI(access_token: successResponse.data.access_token, voice: voice, enrollVoiceEntity: enrollVoiceEntity, properties: properties, callback: callback)
332+
break
333+
case .failure(let error):
334+
DispatchQueue.main.async {
335+
callback(Result.failure(error: error))
336+
}
337+
break
338+
}
339+
}
340+
}
341+
else {
342+
self.enrollVoiceAPI(access_token: access_token, voice: voice, enrollVoiceEntity: enrollVoiceEntity, properties: properties, callback: callback)
343+
}
344+
}
345+
346+
private func enrollVoiceAPI(access_token: String, voice: Data, enrollVoiceEntity: EnrollVoiceEntity, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<EnrollVoiceResponseEntity>) -> Void) {
316347
// call enroll service
317348
VoiceVerificationService.shared.enrollVoice(accessToken:access_token, voice: voice, enrollVoiceEntity: enrollVoiceEntity, properties: properties) {
318349
switch $0 {
@@ -390,7 +421,6 @@ public class VoiceVerificationController {
390421
}
391422
}
392423

393-
394424
// login with Voice from properties
395425
public func loginWithVoice(email : String, mobile: String, sub: String, trackId: String, requestId: String, voice: Data, usageType: String, intermediate_id: String = "", properties: Dictionary<String, String>, callback: @escaping(Result<LoginResponseEntity>) -> Void) {
396426
// null check

Cidaas/Classes/Core/Helpers/Enums/WebAuthErrorCode.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,4 +207,6 @@ public enum WebAuthErrorCode : Int32 {
207207

208208
case EMPTY_DELETE_VERIFICATION_SERVICE = 10172
209209
case DELETE_VERIFICATION_SERVICE_FAILURE = 10173
210+
211+
case END_POINTS_SERVICE_FAILURE = 10174
210212
}

0 commit comments

Comments
 (0)