@regulaforensics/face-sdk 8.2.919-rc → 8.2.923-beta

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 (59) hide show
  1. package/RNFaceSDK.podspec +3 -3
  2. package/android/{CVDFaceSDK.kt → CDVFaceSDK.kt} +1 -1
  3. package/android/build.gradle +1 -1
  4. package/android/cordova.gradle +1 -1
  5. package/android/src/main/java/com/regula/plugin/facesdk/Config.kt +4 -0
  6. package/android/src/main/java/com/regula/plugin/facesdk/JSONConstructor.kt +12 -7
  7. package/android/src/main/java/com/regula/plugin/facesdk/Utils.kt +2 -3
  8. package/examples/capacitor/android/app/build.gradle +2 -2
  9. package/examples/capacitor/android/app/capacitor.build.gradle +2 -3
  10. package/examples/capacitor/android/app/src/main/AndroidManifest.xml +1 -1
  11. package/examples/capacitor/android/build.gradle +3 -3
  12. package/examples/capacitor/android/capacitor.settings.gradle +2 -5
  13. package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  14. package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.properties +1 -1
  15. package/examples/capacitor/android/gradlew +4 -5
  16. package/examples/capacitor/android/gradlew.bat +2 -2
  17. package/examples/capacitor/android/variables.gradle +10 -10
  18. package/examples/capacitor/ios/App/App.xcodeproj/project.pbxproj +20 -4
  19. package/examples/capacitor/ios/App/Podfile +5 -1
  20. package/examples/capacitor/ios/App/Podfile.lock +14 -14
  21. package/examples/capacitor/package-lock.json +817 -853
  22. package/examples/capacitor/package.json +17 -17
  23. package/examples/ionic/images/icon.png +0 -0
  24. package/examples/ionic/package-lock.json +8477 -8064
  25. package/examples/ionic/package.json +23 -14
  26. package/examples/ionic/patches/cordova-plugin-ionic-webview+5.0.1.patch +23 -0
  27. package/examples/ionic/scripts/ios.sh +1 -1
  28. package/examples/react_native/package-lock.json +1191 -1473
  29. package/examples/react_native/package.json +2 -2
  30. package/ios/CDVFaceSDK.swift +42 -0
  31. package/ios/Config.swift +245 -0
  32. package/ios/Decoder.swift +934 -0
  33. package/ios/Main.swift +191 -0
  34. package/ios/RNFaceSDK.m +7 -39
  35. package/ios/RNFaceSDK.swift +42 -0
  36. package/ios/Utils.swift +82 -0
  37. package/package.json +1 -1
  38. package/plugin.xml +10 -12
  39. package/test/json.tsx +16 -13
  40. package/test/package-lock.json +1 -1
  41. package/www/capacitor/customization/customization_images.js +47 -39
  42. package/www/capacitor/face_capture/face_capture_config.js +4 -0
  43. package/www/capacitor/liveness/liveness_config.js +4 -0
  44. package/www/cordova.js +55 -39
  45. package/www/react-native/customization/customization_images.js +47 -39
  46. package/www/react-native/face_capture/face_capture_config.js +4 -0
  47. package/www/react-native/liveness/liveness_config.js +4 -0
  48. package/www/types/customization/customization_images.d.ts +1 -0
  49. package/www/types/face_capture/face_capture_config.d.ts +6 -0
  50. package/www/types/liveness/liveness_config.d.ts +7 -0
  51. package/ios/CVDFaceSDK.h +0 -7
  52. package/ios/CVDFaceSDK.m +0 -43
  53. package/ios/RFSWConfig.h +0 -27
  54. package/ios/RFSWConfig.m +0 -199
  55. package/ios/RFSWJSONConstructor.h +0 -135
  56. package/ios/RFSWJSONConstructor.m +0 -985
  57. package/ios/RFSWMain.h +0 -24
  58. package/ios/RFSWMain.m +0 -381
  59. package/ios/RNFaceSDK.h +0 -8
@@ -8,8 +8,8 @@
8
8
  "start": "expo start"
9
9
  },
10
10
  "dependencies": {
11
- "@regulaforensics/face-sdk": "8.2.919-rc",
12
- "@regulaforensics/face-core-basic": "8.2.498-rc",
11
+ "@regulaforensics/face-sdk": "8.2.923-beta",
12
+ "@regulaforensics/face-core-basic": "8.1.422",
13
13
  "react-native": "^0.81.4",
14
14
  "react-native-fs": "^2.20.0",
15
15
  "react-native-image-picker": "^8.2.1",
@@ -0,0 +1,42 @@
1
+ @objc(CDVFaceSDK)
2
+ class CDVFaceSDK: CDVPlugin {
3
+ @objc(exec:)
4
+ func exec(_ command: CDVInvokedUrlCommand) {
5
+ this = self
6
+ let method = command.arguments.first as! String
7
+ args = Array(command.arguments.dropFirst())
8
+
9
+ if method == "setEvent" {
10
+ eventCallbackIds[args.first as! String] = command.callbackId
11
+ return
12
+ }
13
+
14
+ methodCall(method, { data in sendEvent(command.callbackId, data) })
15
+ }
16
+ }
17
+
18
+ var this: CDVFaceSDK?
19
+ var eventCallbackIds: [String: String] = [:]
20
+ func sendEvent(_ event: String, _ data: Any? = "") {
21
+ var callbackId = event
22
+ let eventId = eventCallbackIds[event]
23
+ if eventId != nil { callbackId = eventId! }
24
+
25
+ // In this section unreasonable casts and optionals are made to
26
+ // ensure that this code works with both cordova-ios@7 and cordova-ios@8.
27
+ var sendable = data.toSendable()
28
+ if sendable is NSNull { sendable = "" }
29
+ let message = sendable as! String
30
+ let result: CDVPluginResult? = CDVPluginResult(status: CDVCommandStatus.ok, messageAs: message)
31
+ result!.setKeepCallbackAs(true)
32
+
33
+ this!.commandDelegate.send(result!, callbackId: callbackId)
34
+ }
35
+
36
+ let rootViewController: () -> UIViewController? = {
37
+ return UIApplication.shared.connectedScenes
38
+ .compactMap { $0 as? UIWindowScene }
39
+ .flatMap { $0.windows }
40
+ .first { $0.isKeyWindow }?
41
+ .rootViewController
42
+ }
@@ -0,0 +1,245 @@
1
+ import UIKit
2
+ import FaceSDK
3
+
4
+ func setCustomization(_ it: [String: [String: Any]]) {
5
+ for (key, value) in it {
6
+ if key == "uiCustomizationLayer" {
7
+ face.customization.customUILayerJSON = value as [AnyHashable : Any]
8
+ continue
9
+ }
10
+ let dict = (face.customization.configuration!.value(forKey: key) as! NSMutableDictionary)
11
+ for (k, v) in value {
12
+ switch key {
13
+ case("colors"): dict[Int(k)!] = UIColor.decode(v)
14
+ case("fonts"): dict[Int(k)!] = UIFont.decode(v)
15
+ case("images"): dict[k] = UIImage.decode(v)
16
+ default: break
17
+ }
18
+ }
19
+ }
20
+ }
21
+
22
+ public extension FaceCaptureConfiguration {
23
+ static func decode(_ it: Any?) -> Self? {
24
+ guard let it = it as? [String: Any] else { return nil }
25
+ return Self(builder: { builder in
26
+ for (k, v) in it {
27
+ switch k {
28
+ case("copyright"): builder.isCopyright = v as! Bool
29
+ case("cameraSwitchEnabled"): builder.isCameraSwitchButtonEnabled = v as! Bool
30
+ case("closeButtonEnabled"): builder.isCloseButtonEnabled = v as! Bool
31
+ case("torchButtonEnabled"): builder.isTorchButtonEnabled = v as! Bool
32
+ case("vibrateOnSteps"): builder.vibrateOnSteps = v as! Bool
33
+ case("detectOcclusion"): builder.detectOcclusion = v as! Bool
34
+ case("showFaceAnimation"): builder.showFaceAnimation = v as! Bool
35
+ case("preventScreenRecording"): builder.isPreventScreenRecordingEnable = v as! Bool
36
+ case("cameraPositionIOS"): builder.cameraPosition = CameraPosition(rawValue: v as! Int)!
37
+ case("screenOrientation"): builder.screenOrientation = RFSScreenOrientation.decode(v)
38
+ case("timeout"): builder.timeoutInterval = v as? NSNumber
39
+ case("holdStillDuration"): builder.holdStillDuration = v as? NSNumber
40
+ default: break
41
+ }
42
+ }
43
+ })
44
+ }
45
+ func encode() -> [String: Any?] {
46
+ return [
47
+ "copyright": self.isCopyright,
48
+ "cameraSwitchEnabled": self.isCameraSwitchButtonEnabled,
49
+ "closeButtonEnabled": self.isCloseButtonEnabled,
50
+ "torchButtonEnabled": self.isTorchButtonEnabled,
51
+ "vibrateOnSteps": self.vibrateOnSteps,
52
+ "detectOcclusion": self.detectOcclusion,
53
+ "showFaceAnimation": self.showFaceAnimation,
54
+ "preventScreenRecording": self.isPreventScreenRecordingEnable,
55
+ "cameraPositionIOS": self.cameraPosition.rawValue,
56
+ "screenOrientation": self.screenOrientation.encode(),
57
+ "timeout": self.timeoutInterval,
58
+ "holdStillDuration": self.holdStillDuration,
59
+ ]
60
+ }
61
+ }
62
+
63
+ public extension LivenessConfiguration {
64
+ static func decode(_ it: Any?) -> Self? {
65
+ guard let it = it as? [String: Any] else { return nil }
66
+ return Self(builder: { builder in
67
+ for (k, v) in it {
68
+ switch k {
69
+ case("copyright"): builder.isCopyright = v as! Bool
70
+ case("cameraSwitchEnabled"): builder.isCameraSwitchButtonEnabled = v as! Bool
71
+ case("closeButtonEnabled"): builder.isCloseButtonEnabled = v as! Bool
72
+ case("torchButtonEnabled"): builder.isTorchButtonEnabled = v as! Bool
73
+ case("vibrateOnSteps"): builder.vibrateOnSteps = v as! Bool
74
+ case("cameraPositionIOS"): builder.cameraPosition = CameraPosition(rawValue: v as! Int)!
75
+ case("attemptsCount"): builder.attemptsCount = v as! Int
76
+ case("locationTrackingEnabled"): builder.isLocationTrackingEnabled = v as! Bool
77
+ case("preventScreenRecording"): builder.isPreventScreenRecordingEnable = v as! Bool
78
+ case("recordingProcess"): builder.recordingProcess = RecordingProcess(rawValue: v as! Int)!
79
+ case("livenessType"): builder.livenessType = LivenessType(rawValue: v as! Int)!
80
+ case("screenOrientation"): builder.screenOrientation = RFSScreenOrientation.decode(v)
81
+ case("tag"): builder.tag = v as? String
82
+ case("skipStep"): builder.stepSkippingMask = RFSLivenessStepSkip.decode(v)
83
+ case("metadata"): builder.metadata = v as! [String: Any]
84
+ default: break
85
+ }
86
+ }
87
+ })
88
+ }
89
+ func encode() -> [String: Any?] {
90
+ return [
91
+ "copyright": self.isCopyright,
92
+ "cameraSwitchEnabled": self.isCameraSwitchButtonEnabled,
93
+ "closeButtonEnabled": self.isCloseButtonEnabled,
94
+ "torchButtonEnabled": self.isTorchButtonEnabled,
95
+ "vibrateOnSteps": self.vibrateOnSteps,
96
+ "cameraPositionIOS": self.cameraPosition.rawValue,
97
+ "attemptsCount": self.attemptsCount,
98
+ "locationTrackingEnabled": self.isLocationTrackingEnabled,
99
+ "preventScreenRecording": self.isPreventScreenRecordingEnable,
100
+ "recordingProcess": self.recordingProcess.rawValue,
101
+ "livenessType": self.livenessType.rawValue,
102
+ "screenOrientation": self.screenOrientation.encode(),
103
+ "tag": self.tag,
104
+ "skipStep": self.stepSkippingMask.encode(),
105
+ "metadata": self.metadata,
106
+ ]
107
+ }
108
+ }
109
+
110
+ public extension MatchFacesConfiguration {
111
+ static func decode(_ it: Any?) -> Self? {
112
+ guard let it = it as? [String: Any] else { return nil }
113
+ return Self(builder: { builder in
114
+ for (k, v) in it {
115
+ switch k {
116
+ case("processingMode"): builder.processingMode = FaceSDK.ProcessingMode(rawValue: v as! Int)!
117
+ case("locationTrackingEnabled"): builder.isLocationTrackingEnabled = v as! Bool
118
+ default: break
119
+ }
120
+ }
121
+ })
122
+ }
123
+ func encode() -> [String: Any?] {
124
+ return [
125
+ "processingMode": self.processingMode.rawValue,
126
+ "locationTrackingEnabled": self.isLocationTrackingEnabled,
127
+ ]
128
+ }
129
+ }
130
+
131
+ // MARK: - Convetring
132
+
133
+ extension UIColor {
134
+ // Create from a hex integer; supports #RGB, #ARGB, #RRGGBB, #AARRGGBB semantics
135
+ static func decode(_ it: Any?) -> Self? {
136
+ guard let it = it as? Int else { return nil }
137
+ // Build hex string manually to preserve leading zeros when derived from integers
138
+ var value = UInt32(truncatingIfNeeded: it)
139
+ let digits = Array("0123456789ABCDEF")
140
+ var hex = ""
141
+ while value > 0 {
142
+ let d = Int(value % 16)
143
+ hex.insert(digits[d], at: hex.startIndex)
144
+ value /= 16
145
+ }
146
+ if hex.isEmpty { hex = "0" }
147
+ // If length is 5 or 7, pad a leading 0 to restore a lost leading nibble
148
+ if hex.count == 5 || hex.count == 7 { hex = "0" + hex }
149
+ let s = hex.uppercased()
150
+
151
+ let a, r, g, b: CGFloat
152
+ switch s.count {
153
+ case 3: // RGB
154
+ a = 1.0
155
+ r = Self.component(from: s, start: 0, length: 1)
156
+ g = Self.component(from: s, start: 1, length: 1)
157
+ b = Self.component(from: s, start: 2, length: 1)
158
+ case 4: // ARGB
159
+ a = Self.component(from: s, start: 0, length: 1)
160
+ r = Self.component(from: s, start: 1, length: 1)
161
+ g = Self.component(from: s, start: 2, length: 1)
162
+ b = Self.component(from: s, start: 3, length: 1)
163
+ case 6: // RRGGBB
164
+ a = 1.0
165
+ r = Self.component(from: s, start: 0, length: 2)
166
+ g = Self.component(from: s, start: 2, length: 2)
167
+ b = Self.component(from: s, start: 4, length: 2)
168
+ case 8: // AARRGGBB
169
+ a = Self.component(from: s, start: 0, length: 2)
170
+ r = Self.component(from: s, start: 2, length: 2)
171
+ g = Self.component(from: s, start: 4, length: 2)
172
+ b = Self.component(from: s, start: 6, length: 2)
173
+ default:
174
+ assertionFailure("Invalid color value: #\(s). Expected #RGB, #ARGB, #RRGGBB, or #AARRGGBB")
175
+ return nil
176
+ }
177
+ return Self(red: r, green: g, blue: b, alpha: a)
178
+ }
179
+
180
+ // AARRGGBB integer representation as Int
181
+ func encode() -> Int {
182
+ var r: CGFloat = 0, g: CGFloat = 0, b: CGFloat = 0, a: CGFloat = 0
183
+ if !getRed(&r, green: &g, blue: &b, alpha: &a) {
184
+ if let comps = cgColor.components {
185
+ if comps.count == 2 { r = comps[0]; g = comps[0]; b = comps[0]; a = comps[1] }
186
+ else if comps.count >= 4 { r = comps[0]; g = comps[1]; b = comps[2]; a = comps[3] }
187
+ }
188
+ }
189
+ let aa = UInt32(lroundf(Float(a * 255)))
190
+ let rr = UInt32(lroundf(Float(r * 255)))
191
+ let gg = UInt32(lroundf(Float(g * 255)))
192
+ let bb = UInt32(lroundf(Float(b * 255)))
193
+ let composed: UInt32 = (aa << 24) | (rr << 16) | (gg << 8) | bb
194
+ return Int(truncatingIfNeeded: composed)
195
+ }
196
+
197
+ private static func component(from hex: String, start: Int, length: Int) -> CGFloat {
198
+ let startIdx = hex.index(hex.startIndex, offsetBy: start)
199
+ let endIdx = hex.index(startIdx, offsetBy: length)
200
+ let substr = String(hex[startIdx..<endIdx])
201
+ let full = (length == 2) ? substr : substr + substr
202
+ let value = UInt32(full, radix: 16) ?? 0
203
+ return CGFloat(value) / 255.0
204
+ }
205
+ }
206
+
207
+ extension UIFont {
208
+ static func decode(_ it: Any?) -> Self? {
209
+ guard let it = it as? [String: Any] else { return nil }
210
+ return Self(name: it["name"] as! String,
211
+ size: it["size"] as! CGFloat)
212
+ }
213
+ }
214
+
215
+ extension RFSScreenOrientation {
216
+ static func decode(_ it: Any?) -> Self {
217
+ let it = it as! [Int]
218
+ if it.contains(0) && it.contains(1) { return Self(arrayLiteral: .portrait, .landscape) }
219
+ if it.contains(0) { return Self(arrayLiteral: .portrait) }
220
+ if it.contains(1) { return Self(arrayLiteral: .landscape) }
221
+ return Self(arrayLiteral: [])
222
+ }
223
+ func encode() -> [Int] {
224
+ if self == .portrait { return [0] }
225
+ if self == .landscape { return [1] }
226
+ if self == [.portrait, .landscape] { return [0, 1] }
227
+ return []
228
+ }
229
+ }
230
+
231
+ extension RFSLivenessStepSkip {
232
+ static func decode(_ it: Any?) -> Self {
233
+ let it = it as! [Int]
234
+ if it.contains(0) && it.contains(1) { return Self(arrayLiteral: .onboarding, .success) }
235
+ if it.contains(0) { return Self(arrayLiteral: .onboarding) }
236
+ if it.contains(1) { return Self(arrayLiteral: .success) }
237
+ return Self(arrayLiteral: [])
238
+ }
239
+ func encode() -> [Int] {
240
+ if self == .onboarding { return [0] }
241
+ if self == .success { return [1] }
242
+ if self == [.onboarding, .success] { return [0, 1] }
243
+ return []
244
+ }
245
+ }