@regulaforensics/face-sdk 8.2.855-nightly → 8.2.856-rc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (46) hide show
  1. package/RNFaceSDK.podspec +4 -4
  2. package/android/{CDVFaceSDK.kt → CVDFaceSDK.kt} +1 -1
  3. package/android/build.gradle +2 -2
  4. package/android/cordova.gradle +2 -2
  5. package/android/src/main/java/com/regula/plugin/facesdk/JSONConstructor.kt +7 -12
  6. package/examples/capacitor/android/app/build.gradle +2 -2
  7. package/examples/capacitor/android/app/capacitor.build.gradle +3 -2
  8. package/examples/capacitor/android/app/src/main/AndroidManifest.xml +1 -1
  9. package/examples/capacitor/android/build.gradle +3 -3
  10. package/examples/capacitor/android/capacitor.settings.gradle +5 -2
  11. package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  12. package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  13. package/examples/capacitor/android/gradlew +5 -4
  14. package/examples/capacitor/android/gradlew.bat +2 -2
  15. package/examples/capacitor/android/variables.gradle +10 -10
  16. package/examples/capacitor/ios/App/App.xcodeproj/project.pbxproj +4 -20
  17. package/examples/capacitor/ios/App/Podfile +1 -5
  18. package/examples/capacitor/ios/App/Podfile.lock +14 -14
  19. package/examples/capacitor/package-lock.json +847 -811
  20. package/examples/capacitor/package.json +17 -17
  21. package/examples/ionic/images/icon.png +0 -0
  22. package/examples/ionic/package-lock.json +2419 -2633
  23. package/examples/ionic/package.json +14 -16
  24. package/examples/ionic/scripts/ios.sh +1 -1
  25. package/examples/react_native/package-lock.json +1443 -1161
  26. package/examples/react_native/package.json +2 -2
  27. package/ios/CVDFaceSDK.h +7 -0
  28. package/ios/CVDFaceSDK.m +43 -0
  29. package/ios/RFSWConfig.h +27 -0
  30. package/ios/RFSWConfig.m +199 -0
  31. package/ios/RFSWJSONConstructor.h +135 -0
  32. package/ios/RFSWJSONConstructor.m +985 -0
  33. package/ios/RFSWMain.h +24 -0
  34. package/ios/RFSWMain.m +381 -0
  35. package/ios/RNFaceSDK.h +8 -0
  36. package/ios/RNFaceSDK.m +39 -7
  37. package/package.json +1 -1
  38. package/plugin.xml +13 -11
  39. package/test/package-lock.json +1 -1
  40. package/examples/ionic/patches/cordova-plugin-ionic-webview+5.0.1.patch +0 -23
  41. package/ios/CDVFaceSDK.swift +0 -42
  42. package/ios/Config.swift +0 -242
  43. package/ios/Decoder.swift +0 -934
  44. package/ios/Main.swift +0 -191
  45. package/ios/RNFaceSDK.swift +0 -42
  46. package/ios/Utils.swift +0 -82
package/ios/Main.swift DELETED
@@ -1,191 +0,0 @@
1
- import FaceSDK
2
-
3
- let face = FaceSDK.service
4
- let db = face.personDatabase
5
-
6
- let cameraSwitchEvent = "cameraSwitchEvent"
7
- let livenessNotificationEvent = "livenessNotificationEvent"
8
- let videoEncoderCompletionEvent = "video_encoder_completion"
9
- let onCustomButtonTappedEvent = "onCustomButtonTappedEvent"
10
-
11
- func methodCall(_ method: String, _ callback: @escaping Callback) {
12
- switch method {
13
- case("getVersion"): callback(face.version?.encode())
14
- case("getServiceUrl"): callback(face.serviceURL)
15
- case("setServiceUrl"): face.serviceURL = argsNullable(0)
16
- case("getTenant"): callback(face.tenant)
17
- case("setTenant"): face.tenant = argsNullable(0)
18
- case("getEnv"): callback(face.env)
19
- case("setEnv"): face.env = argsNullable(0)
20
- case("getLocale"): callback(face.languageLocaleCode)
21
- case("setLocale"): face.languageLocaleCode = argsNullable(0)
22
- case("setLocalizationDictionary"):
23
- face.localizationHandler = { (argsNullable(0) as [String : String?]?)?[$0] ?? nil }
24
- case("setRequestHeaders"):
25
- headers = argsNullable(0)
26
- face.requestInterceptingDelegate = headersDelegate
27
- case("setCustomization"): setCustomization(args(0))
28
- case("isInitialized"): callback(face.isInitialized)
29
- case("initialize"): face.initialize(
30
- configuration: InitializationConfiguration.decode(argsNullable(0)),
31
- completion: { success, error in
32
- if success {
33
- face.customization.configuration = UIConfiguration.default()
34
- face.videoUploadingDelegate = videoUploadingDelegate
35
- face.faceCaptureDelegate = faceCaptureDelegate
36
- face.livenessDelegate = livenessDelegate
37
- face.customization.actionDelegate = actionDelegate
38
- }
39
- callback(generateInitCompletion(success, error))
40
- })
41
- case("deinitialize"): face.deinitialize()
42
- case("startFaceCapture"): DispatchQueue.main.async {
43
- face.presentFaceCaptureViewController(
44
- from: rootViewController()!,
45
- animated: true,
46
- configuration: FaceCaptureConfiguration.decode(argsNullable(0)),
47
- onCapture: { callback($0.encode()) },
48
- completion: nil)
49
- }
50
- case("stopFaceCapture"): face.stopFaceCaptureViewController()
51
- case("startLiveness"): DispatchQueue.main.async {
52
- face.startLiveness(
53
- from: rootViewController()!,
54
- animated: true,
55
- configuration: LivenessConfiguration.decode(argsNullable(0)),
56
- onLiveness: { callback($0.encode()) },
57
- completion: nil)
58
- }
59
- case("stopLiveness"): face.stopLivenessProcessing()
60
- case("matchFaces"): face.matchFaces(
61
- MatchFacesRequest.decode(args(0)),
62
- configuration: MatchFacesConfiguration.decode(argsNullable(0)),
63
- completion: { callback($0.encode()) })
64
- case("splitComparedFaces"): callback(MatchFacesSimilarityThresholdSplit(
65
- pairs: (args(0) as [[String: Any?]]).compactMap { MatchFacesComparedFacesPair.decode($0) },
66
- bySimilarityThreshold: args(1)).encode())
67
- case("detectFaces"): face.detectFaces(
68
- by: DetectFacesRequest.decode(args(0)),
69
- completion: { callback($0.encode()) })
70
-
71
- // MARK: - PersonDatabase
72
-
73
- case("createPerson"): db.createPerson(
74
- name: args(0),
75
- metadata: argsNullable(1),
76
- groupIds: argsNullable(2),
77
- completion: { callback($0.encode()) }
78
- )
79
- case("updatePerson"): let json = args(0) as [String: Any]
80
- db.getPerson(
81
- personId: json["id"] as! String,
82
- completion: {
83
- guard let person = $0.item else { callback($0.encode()); return }
84
- db.updatePerson(person: person.update(json), completion: { callback($0.encode()) })
85
- })
86
- case("deletePerson"): db.deletePerson(personId: args(0), completion: { callback($0.encode()) })
87
- case("getPerson"): db.getPerson(personId: args(0), completion: { callback($0.encode()) })
88
- case("addPersonImage"): db.addPersonImage(
89
- personId: args(0),
90
- imageUpload: PersonDatabase.ImageUpload.decode(args(1))!,
91
- completion: { callback($0.encode()) })
92
- case("deletePersonImage"): db.deletePersonImage(
93
- personId: args(0),
94
- imageId: args(1),
95
- completion: { callback($0.encode()) })
96
- case("getPersonImage"): db.getPersonImage(
97
- personId: args(0),
98
- imageId: args(1),
99
- completion: { callback(encodeDBItemResponse($0.data?.encode(), $0.error)) })
100
- case("getPersonImages"): db.getPersonImages(personId: args(0), completion: { callback($0.encode())})
101
- case("getPersonImagesForPage"): db.getPersonImages(
102
- personId: args(0),
103
- page: args(1),
104
- size: args(2),
105
- completion: { callback($0.encode()) })
106
- case("createGroup"): db.createGroup(
107
- name: args(0),
108
- metadata: argsNullable(1) as [String: Any]?,
109
- completion: { callback($0.encode()) })
110
- case("updateGroup"): let json = args(0) as [String: Any]
111
- db.getGroups(
112
- groupId: json["id"] as! String,
113
- completion: {
114
- guard let group = $0.item else { callback($0.encode()); return }
115
- db.updateGroup(group: group.update(json), completion: { callback($0.encode()) })
116
- })
117
- case("editPersonsInGroup"): db.editGroupPersons(
118
- groupId: args(0),
119
- request: PersonDatabase.EditGroupPersonsRequest.decode(args(0)),
120
- completion: { callback($0.encode()) })
121
- case("deleteGroup"): db.deleteGroup(groupId: args(0), completion: { callback($0.encode()) })
122
- case("getGroup"): db.getGroups(groupId: args(0), completion: { callback($0.encode()) })
123
- case("getGroups"): db.getGroups(completion: { callback($0.encode()) })
124
- case("getGroupsForPage"): db.getGroups(
125
- page: args(0),
126
- size: args(1),
127
- completion: { callback($0.encode()) })
128
- case("getPersonGroups"): db.getPersonGroups(personId: args(0), completion: { callback($0.encode()) })
129
- case("getPersonGroupsForPage"): db.getPersonGroups(
130
- personId: args(0),
131
- page: args(1),
132
- size: args(2),
133
- completion: { callback($0.encode()) })
134
- case("getPersonsInGroup"): db.getGroupPersons(groupId: args(0), completion: { callback($0.encode()) })
135
- case("getPersonsInGroupForPage"): db.getGroupPersons(
136
- groupId: args(0),
137
- page: args(1),
138
- size: args(2),
139
- completion: { callback($0.encode()) })
140
- case("searchPerson"): db.searchPerson(
141
- searchRequest: PersonDatabase.SearchPersonRequest.decode(args(0)),
142
- completion: { callback(encodeDBItemResponse($0.results?.compactMap{ $0.encode2() }, $0.error)) })
143
- default: break
144
- }
145
- }
146
-
147
- // MARK: - Implementation
148
-
149
- var headers: [String: String]?
150
- let headersDelegate = IURLRequestInterceptingDelegate()
151
- class IURLRequestInterceptingDelegate: NSObject, URLRequestInterceptingDelegate {
152
- func interceptorPrepare(_ request: URLRequest) -> URLRequest? {
153
- guard let headers = headers else { return request }
154
- var req = request
155
- for (key, value) in headers {
156
- req.addValue(value, forHTTPHeaderField: key)
157
- }
158
- return req
159
- }
160
- }
161
-
162
- let videoUploadingDelegate = IVideoUploadingDelegate()
163
- class IVideoUploadingDelegate: NSObject, VideoUploadingDelegate {
164
- func videoUploading(forTransactionId transactionId: String, didFinishedWithSuccess success: Bool) {
165
- sendEvent(videoEncoderCompletionEvent, generateVideoEncoderCompletion(success, transactionId))
166
- }
167
- }
168
-
169
- let faceCaptureDelegate = IFaceCaptureDelegate()
170
- class IFaceCaptureDelegate: NSObject, FaceCaptureDelegate {
171
- func cameraPositionChanged(_ cameraPosition: CameraPosition) {
172
- sendEvent(cameraSwitchEvent, cameraPosition)
173
- }
174
- }
175
-
176
- let livenessDelegate = ILivenessDelegate()
177
- class ILivenessDelegate: NSObject, LivenessDelegate {
178
- func processStatusChanged(_ status: LivenessProcessStatus, result: LivenessResponse?) {
179
- sendEvent(livenessNotificationEvent, generateLivenessNotification(status, result))
180
- }
181
- func cameraPositionChanged(_ cameraPosition: CameraPosition) {
182
- sendEvent(cameraSwitchEvent, cameraPosition)
183
- }
184
- }
185
-
186
- let actionDelegate = ICustomizationActionDelegate()
187
- class ICustomizationActionDelegate: NSObject, FaceSDK.CustomizationActionDelegate {
188
- func onFaceCustomButtonTapped(withTag tag: Int) {
189
- sendEvent(onCustomButtonTappedEvent, tag)
190
- }
191
- }
@@ -1,42 +0,0 @@
1
- import React
2
-
3
- @objc(RNFaceSDK)
4
- public class RNFaceSDK: RCTEventEmitter {
5
- override public func startObserving() { hasListeners = true }
6
- override public func stopObserving() { hasListeners = false }
7
- override public func supportedEvents()->[String] {
8
- return [cameraSwitchEvent,
9
- livenessNotificationEvent,
10
- videoEncoderCompletionEvent,
11
- onCustomButtonTappedEvent];
12
- }
13
-
14
- @objc
15
- func exec(
16
- _ method: String,
17
- newArgs: [Any],
18
- resolve: @escaping RCTPromiseResolveBlock,
19
- reject: @escaping RCTPromiseRejectBlock
20
- ) {
21
- this = self
22
- args = newArgs
23
- methodCall(method, { data in
24
- if firedCallbacks.contains(where: { ($0 as AnyObject) === (resolve as AnyObject) }) { return }
25
- firedCallbacks.append(resolve)
26
- resolve(data.toSendable())
27
- })
28
- }
29
- }
30
-
31
- private var firedCallbacks: [RCTResponseSenderBlock] = []
32
- private var hasListeners: Bool = false
33
- private var this: RNFaceSDK?
34
-
35
- func sendEvent(_ event: String, _ data: Any? = nil) {
36
- guard let plugin = this, hasListeners else { return }
37
- DispatchQueue.main.async {
38
- plugin.sendEvent(withName: event, body: data.toSendable())
39
- }
40
- }
41
-
42
- let rootViewController: () -> UIViewController? = { return RCTPresentedViewController() }
package/ios/Utils.swift DELETED
@@ -1,82 +0,0 @@
1
- public typealias Callback = (Any?) -> Void
2
-
3
- var args: [Any?] = []
4
- func args<T>(_ index: Int) -> T {
5
- return args[index] as! T
6
- }
7
-
8
- func argsNullable<T>(_ index: Int) -> T? {
9
- if args[index] is NSNull { return nil }
10
- return args[index] as! T?
11
- }
12
-
13
- extension Any? {
14
- func toSendable() -> Any {
15
- guard let self else { return NSNull() }
16
- if self is [String: Any?] || self is [Any?] {
17
- let data = try! JSONSerialization.data(withJSONObject: fixNulls(self), options: .prettyPrinted)
18
- return String(data: data, encoding: .utf8)!
19
- }
20
- return self
21
- }
22
- }
23
-
24
- func fixNulls(_ value: Any?) -> Any {
25
- guard let value else { return NSNull() }
26
- switch value {
27
- case let value as [String: Any]:
28
- var dict = [String: Any]()
29
- for (k, v) in value { dict[k] = fixNulls(v) }
30
- return dict
31
- case let value as [Any]: return value.map { fixNulls($0) }
32
- default: return value
33
- }
34
- }
35
-
36
- extension NSObject {
37
- static func allocate() -> NSObject {
38
- return perform(NSSelectorFromString("alloc")).takeUnretainedValue() as! NSObject
39
- }
40
- static func emptyInit<T>() -> T {
41
- return allocate().perform("init".selector()).takeUnretainedValue() as! T
42
- }
43
- }
44
-
45
- extension String {
46
- func selector() -> Selector {
47
- return NSSelectorFromString(self)
48
- }
49
- }
50
-
51
- func privateInit<T, Fn>(
52
- _ allocated: NSObject,
53
- _ selector: Selector,
54
- _ function: Fn.Type,
55
- _ call: (Fn) -> Unmanaged<AnyObject>?
56
- ) -> T {
57
- let f = unsafeBitCast(allocated.method(for: selector), to: function)
58
- return call(f)!.takeUnretainedValue() as! T
59
- }
60
-
61
- extension Data {
62
- static func decode(_ it: Any?) -> Self? {
63
- guard var it = it as? String else { return nil }
64
- if it.hasPrefix("data") { it = String(it[it.index(after: it.firstIndex(of: ",")!)...]) }
65
- return Self(base64Encoded: it)
66
- }
67
-
68
- func encode() -> String {
69
- return self.base64EncodedString()
70
- }
71
- }
72
-
73
- extension UIImage {
74
- static func decode(_ it: Any?) -> Self? {
75
- guard let it = it as? String else { return nil }
76
- return Self(data: Data.decode(it)!)
77
- }
78
-
79
- func encode() -> String {
80
- return self.pngData()!.encode()
81
- }
82
- }