@regulaforensics/idv 3.2.23-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.
- package/README.md +36 -0
- package/RNIDV.podspec +21 -0
- package/android/CVDIDV.kt +48 -0
- package/android/build.gradle +41 -0
- package/android/cordova.gradle +20 -0
- package/android/src/main/java/com/regula/plugin/idv/JSONConstructor.kt +135 -0
- package/android/src/main/java/com/regula/plugin/idv/Main.kt +124 -0
- package/android/src/main/java/com/regula/plugin/idv/RNIDVModule.kt +71 -0
- package/android/src/main/java/com/regula/plugin/idv/Utils.kt +60 -0
- package/examples/capacitor/README.md +15 -0
- package/examples/capacitor/android/app/build.gradle +50 -0
- package/examples/capacitor/android/app/capacitor.build.gradle +22 -0
- package/examples/capacitor/android/app/proguard-rules.pro +21 -0
- package/examples/capacitor/android/app/src/main/AndroidManifest.xml +26 -0
- package/examples/capacitor/android/app/src/main/assets/Regula/.gitkeep +0 -0
- package/examples/capacitor/android/app/src/main/java/com/regula/example/idv/capacitor/MainActivity.java +5 -0
- package/examples/capacitor/android/app/src/main/res/drawable/ic_launcher.png +0 -0
- package/examples/capacitor/android/app/src/main/res/drawable/ic_launcher_foreground.png +0 -0
- package/examples/capacitor/android/app/src/main/res/drawable/ic_launcher_round.png +0 -0
- package/examples/capacitor/android/app/src/main/res/drawable/launcher.xml +4 -0
- package/examples/capacitor/android/app/src/main/res/drawable/launcher_round.xml +4 -0
- package/examples/capacitor/android/app/src/main/res/drawable/splash.png +0 -0
- package/examples/capacitor/android/app/src/main/res/layout/activity_main.xml +12 -0
- package/examples/capacitor/android/app/src/main/res/values/styles.xml +22 -0
- package/examples/capacitor/android/build.gradle +30 -0
- package/examples/capacitor/android/capacitor.settings.gradle +15 -0
- package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.jar +0 -0
- package/examples/capacitor/android/gradle/wrapper/gradle-wrapper.properties +7 -0
- package/examples/capacitor/android/gradle.properties +22 -0
- package/examples/capacitor/android/gradlew +252 -0
- package/examples/capacitor/android/gradlew.bat +94 -0
- package/examples/capacitor/android/settings.gradle +5 -0
- package/examples/capacitor/android/variables.gradle +16 -0
- package/examples/capacitor/index.html +5 -0
- package/examples/capacitor/index.tsx +16 -0
- package/examples/capacitor/ionic.config.json +7 -0
- package/examples/capacitor/ios/App/App/App.entitlements +10 -0
- package/examples/capacitor/ios/App/App/AppDelegate.swift +49 -0
- package/examples/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png +0 -0
- package/examples/capacitor/ios/App/App/Assets.xcassets/AppIcon.appiconset/Contents.json +14 -0
- package/examples/capacitor/ios/App/App/Assets.xcassets/Contents.json +6 -0
- package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/Contents.json +23 -0
- package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-1.png +0 -0
- package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732-2.png +0 -0
- package/examples/capacitor/ios/App/App/Assets.xcassets/Splash.imageset/splash-2732x2732.png +0 -0
- package/examples/capacitor/ios/App/App/Base.lproj/LaunchScreen.storyboard +32 -0
- package/examples/capacitor/ios/App/App/Base.lproj/Main.storyboard +19 -0
- package/examples/capacitor/ios/App/App/Info.plist +65 -0
- package/examples/capacitor/ios/App/App.xcodeproj/project.pbxproj +414 -0
- package/examples/capacitor/ios/App/App.xcodeproj/project.xcworkspace/contents.xcworkspacedata +7 -0
- package/examples/capacitor/ios/App/App.xcworkspace/contents.xcworkspacedata +10 -0
- package/examples/capacitor/ios/App/App.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
- package/examples/capacitor/ios/App/Podfile +26 -0
- package/examples/capacitor/package.json +27 -0
- package/examples/capacitor/public/assets/.gitkeep +0 -0
- package/examples/capacitor/scripts/android.sh +9 -0
- package/examples/capacitor/scripts/ios.sh +8 -0
- package/examples/capacitor/scripts/setup.sh +14 -0
- package/examples/capacitor/src/main.css +148 -0
- package/examples/capacitor/src/main.html +38 -0
- package/examples/capacitor/src/main.tsx +10 -0
- package/examples/capacitor/tsconfig.json +5 -0
- package/examples/capacitor/vite.config.ts +17 -0
- package/examples/ionic/README.md +15 -0
- package/examples/ionic/angular.json +39 -0
- package/examples/ionic/assets/.gitkeep +0 -0
- package/examples/ionic/config.xml +59 -0
- package/examples/ionic/images/icon.png +0 -0
- package/examples/ionic/index.html +19 -0
- package/examples/ionic/index.tsx +28 -0
- package/examples/ionic/ionic.config.json +7 -0
- package/examples/ionic/package.json +46 -0
- package/examples/ionic/scripts/android.sh +8 -0
- package/examples/ionic/scripts/ios.sh +8 -0
- package/examples/ionic/scripts/setup.sh +8 -0
- package/examples/ionic/src/main.css +148 -0
- package/examples/ionic/src/main.html +38 -0
- package/examples/ionic/src/main.tsx +10 -0
- package/examples/ionic/tsconfig.json +14 -0
- package/examples/react_native/README.md +15 -0
- package/examples/react_native/app.config.ts +46 -0
- package/examples/react_native/assets/.gitkeep +0 -0
- package/examples/react_native/images/icon.png +0 -0
- package/examples/react_native/index.html +11 -0
- package/examples/react_native/index.tsx +63 -0
- package/examples/react_native/metro.config.js +7 -0
- package/examples/react_native/package.json +29 -0
- package/examples/react_native/scripts/android.sh +13 -0
- package/examples/react_native/scripts/ios.sh +12 -0
- package/examples/react_native/scripts/setup.sh +9 -0
- package/examples/react_native/src/main.css +148 -0
- package/examples/react_native/src/main.html +38 -0
- package/examples/react_native/src/main.tsx +10 -0
- package/ios/CVDIDV.swift +72 -0
- package/ios/FlutterIDVPlugin.swift +72 -0
- package/ios/JSONConstructor.swift +134 -0
- package/ios/Main.swift +89 -0
- package/ios/RNIDV.swift +72 -0
- package/ios/Utils.swift +56 -0
- package/package.json +38 -0
- package/plugin.xml +45 -0
- package/test/json.tsx +0 -0
- package/test/package-lock.json +584 -0
- package/test/package.json +9 -0
- package/test/test.tsx +3 -0
- package/test/utils.tsx +38 -0
- package/www/capacitor/index.js +6 -0
- package/www/capacitor/internal/bridge.js +19 -0
- package/www/capacitor/internal/cordova.js +17 -0
- package/www/cordova.js +150 -0
- package/www/react-native/index.js +6 -0
- package/www/react-native/internal/bridge.js +19 -0
- package/www/types/index.d.ts +12 -0
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
import IDVSDK
|
|
4
|
+
import IDVModule
|
|
5
|
+
|
|
6
|
+
public func generateCompletion(_ value: Any?, _ error: IDVModule.BaseError?) -> [String: Any?] {
|
|
7
|
+
return [
|
|
8
|
+
"success": value,
|
|
9
|
+
"error": error?.fullChain
|
|
10
|
+
]
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// MARK: - Config
|
|
14
|
+
|
|
15
|
+
public func credentialsConnectionConfigFromJSON(_ data: [String: Any?]) -> CredentialsConnectionConfig {
|
|
16
|
+
let result = CredentialsConnectionConfig (userName: data["userName"] as! String,
|
|
17
|
+
password: data["password"] as! String,
|
|
18
|
+
baseURL: data["baseUrl"] as! String)
|
|
19
|
+
if let httpTimeoutMs = data["httpTimeoutMs"] as? NSNumber { result.httpTimeoutMs = httpTimeoutMs }
|
|
20
|
+
return result
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
public func generateCredentialsConnectionConfig(_ data: CredentialsConnectionConfig) -> [String: Any?] {
|
|
24
|
+
return [
|
|
25
|
+
"baseUrl": data.baseURL,
|
|
26
|
+
"userName": data.userName,
|
|
27
|
+
"password": data.password,
|
|
28
|
+
"httpTimeoutMs": data.httpTimeoutMs,
|
|
29
|
+
]
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
public func tokenConnectionConfigFromJSON(_ data: [String: Any?]) -> TokenConnectionConfig {
|
|
33
|
+
return TokenConnectionConfig(url: data["url"] as! String)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public func generateTokenConnectionConfig(_ data: TokenConnectionConfig) -> [String: Any?] {
|
|
37
|
+
return [
|
|
38
|
+
"url": data.url
|
|
39
|
+
]
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
public func apiKeyConnectionConfigFromJSON(_ data: [String: Any?]) -> ApiKeyConnectionConfig {
|
|
43
|
+
let result = ApiKeyConnectionConfig(apiKey: data["apiKey"] as! String,
|
|
44
|
+
baseURL: data["baseUrl"] as! String,
|
|
45
|
+
ttl: data["ttl"] as? NSNumber)
|
|
46
|
+
if let httpTimeoutMs = data["httpTimeoutMs"] as? NSNumber { result.httpTimeoutMs = httpTimeoutMs }
|
|
47
|
+
return result
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
public func generateApiKeyConnectionConfig(_ data: ApiKeyConnectionConfig) -> [String: Any?] {
|
|
51
|
+
return [
|
|
52
|
+
"baseUrl": data.baseURL,
|
|
53
|
+
"apiKey": data.apiKey,
|
|
54
|
+
"ttl": data.ttl,
|
|
55
|
+
"httpTimeoutMs": data.httpTimeoutMs,
|
|
56
|
+
]
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public func prepareWorkflowConfigFromJSON(_ data: [String: Any?]) -> PrepareWorkflowConfig {
|
|
60
|
+
return PrepareWorkflowConfig(workflowId: data["workflowId"] as! String)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
public func generatePrepareWorkflowConfig(_ data: PrepareWorkflowConfig) -> [String: Any?] {
|
|
64
|
+
return [
|
|
65
|
+
"workflowId": data.workflowId
|
|
66
|
+
]
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
public func startWorkflowConfigFromJSON(input: [String: Any?]?) -> StartWorkflowConfig {
|
|
70
|
+
let result = StartWorkflowConfig.default()
|
|
71
|
+
guard let data = input else { return result }
|
|
72
|
+
|
|
73
|
+
if let locale = data["locale"] as? String { result.locale = locale }
|
|
74
|
+
if let metadata = data["metadata"] as? [String: Any] { result.metadata = metadata }
|
|
75
|
+
|
|
76
|
+
return result
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
public func generateStartWorkflowConfig(_ data: StartWorkflowConfig) -> [String: Any?] {
|
|
80
|
+
return [
|
|
81
|
+
"locale": data.locale,
|
|
82
|
+
"metadata": data.metadata
|
|
83
|
+
]
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
// MARK: - Model
|
|
87
|
+
|
|
88
|
+
public func workflowFromJSON(_ input: [String: Any?]?) -> Workflow? {
|
|
89
|
+
guard var it = input else { return nil }
|
|
90
|
+
it["client"] = [String: Any]()
|
|
91
|
+
it["steps"] = [WorkflowStep]()
|
|
92
|
+
it["_description"] = it["description"]
|
|
93
|
+
return try! Workflow(from: it.toDecoder())
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public func generateWorkflow(_ input: Workflow?) -> [String: Any?]? {
|
|
97
|
+
guard let it = input else { return nil }
|
|
98
|
+
return [
|
|
99
|
+
"id": it.id,
|
|
100
|
+
"name": it.name,
|
|
101
|
+
"version": it.version,
|
|
102
|
+
"description": it._description,
|
|
103
|
+
"defaultLocale": it.defaultLocale
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
public func workflowStepFromJSON(_ input: [String: Any?]?) -> WorkflowStep? {
|
|
108
|
+
guard var it = input else { return nil }
|
|
109
|
+
it["type"] = ""
|
|
110
|
+
it["final"] = false
|
|
111
|
+
it["client"] = [String: Any]()
|
|
112
|
+
return try! WorkflowStep(from: it.toDecoder())
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
public func generateWorkflowStep(_ input: WorkflowStep?) -> [String: Any?]? {
|
|
116
|
+
guard let it = input else { return nil }
|
|
117
|
+
return [
|
|
118
|
+
"id": it.id,
|
|
119
|
+
"name": it.name
|
|
120
|
+
]
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
public func workflowResultFromJSON(_ input: [String: Any?]?) -> WorkflowResult? {
|
|
124
|
+
guard let it = input else { return nil }
|
|
125
|
+
return try! WorkflowResult(from: it.toDecoder())
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
public func generateWorkflowResult(_ input: WorkflowResult?) -> [String: Any?]? {
|
|
129
|
+
guard let it = input else { return nil }
|
|
130
|
+
return [
|
|
131
|
+
"sessionId": it.sessionId,
|
|
132
|
+
"finalStep": generateWorkflowStep(it.finalStep)
|
|
133
|
+
]
|
|
134
|
+
}
|
package/ios/Main.swift
ADDED
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
import IDVSDK
|
|
4
|
+
|
|
5
|
+
let didStartSessionEvent = "didStartSessionEvent"
|
|
6
|
+
let didEndSessionEvent = "didEndSessionEvent"
|
|
7
|
+
let didStartRestoreSessionEvent = "didStartRestoreSessionEvent"
|
|
8
|
+
let didContinueRemoteSessionEvent = "didContinueRemoteSessionEvent"
|
|
9
|
+
|
|
10
|
+
func methodCall(_ method: String, _ callback: @escaping Callback) {
|
|
11
|
+
switch (method) {
|
|
12
|
+
case("setSessionRestoreMode"): IDV.shared.sessionRestoreMode = SessionRestoreMode(rawValue: args(0))!
|
|
13
|
+
case("getCurrentSessionId"): callback(IDV.shared.currentSessionId)
|
|
14
|
+
case ("initialize"): initialize(callback)
|
|
15
|
+
case("deinitialize"): deinitialize(callback)
|
|
16
|
+
case("configureWithToken"): configureWithToken(callback, args(0))
|
|
17
|
+
case("configureWithCredentials"): configureWithCredentials(callback, args(0))
|
|
18
|
+
case("configureWithApiKey"): configureWithApiKey(callback, args(0))
|
|
19
|
+
case("prepareWorkflow"): prepareWorkflow(callback, args(0))
|
|
20
|
+
case("startWorkflow"): startWorkflow(callback, argsNullable(0))
|
|
21
|
+
case("getWorkflows"): getWorkflows(callback)
|
|
22
|
+
default: break
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
// MARK: - Implementation
|
|
27
|
+
|
|
28
|
+
func initialize(_ callback: @escaping Callback) {
|
|
29
|
+
IDV.shared.initialize(config: IDVInitConfig(), completion: { result in
|
|
30
|
+
IDV.shared.delegate = delegate
|
|
31
|
+
callback(generateCompletion(result.isSuccess, result.failureOrNil))
|
|
32
|
+
})
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
func deinitialize(_ callback: @escaping Callback) {
|
|
36
|
+
IDV.shared.deinitialize(completion: { result in
|
|
37
|
+
callback(generateCompletion(result.isSuccess, result.failureOrNil))
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
func configureWithToken(_ callback: @escaping Callback, _ data: [String: Any?]) {
|
|
42
|
+
IDV.shared.configure(with: tokenConnectionConfigFromJSON(data), completion: { result in
|
|
43
|
+
callback(generateCompletion(result.successOrNil, result.failureOrNil))
|
|
44
|
+
})
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
func configureWithCredentials(_ callback: @escaping Callback, _ data: [String: Any?]) {
|
|
48
|
+
IDV.shared.configure(with: credentialsConnectionConfigFromJSON(data), completion: { result in
|
|
49
|
+
callback(generateCompletion(result.isSuccess, result.failureOrNil))
|
|
50
|
+
})
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
func configureWithApiKey(_ callback: @escaping Callback, _ data: [String: Any?]) {
|
|
54
|
+
IDV.shared.configure(with: apiKeyConnectionConfigFromJSON(data), completion: { result in
|
|
55
|
+
callback(generateCompletion(result.isSuccess, result.failureOrNil))
|
|
56
|
+
})
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
func prepareWorkflow(_ callback: @escaping Callback, _ data: [String: Any?]) {
|
|
60
|
+
IDV.shared.prepareWorkflow(by: prepareWorkflowConfigFromJSON(data), completion: { result in
|
|
61
|
+
callback(generateCompletion(generateWorkflow(result.successOrNil), result.failureOrNil))
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
func startWorkflow(_ callback: @escaping Callback, _ data: [String: Any?]?) {
|
|
66
|
+
IDV.shared.startWorkflow(presenter: rootViewController()!,
|
|
67
|
+
config: startWorkflowConfigFromJSON(input: data),
|
|
68
|
+
completion: { result in
|
|
69
|
+
callback(generateCompletion(generateWorkflowResult(result.successOrNil), result.failureOrNil))
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
func getWorkflows(_ callback: @escaping Callback) {
|
|
74
|
+
IDV.shared.getWorkflows(completion: { result in
|
|
75
|
+
callback(generateCompletion(result.successOrNil?.compactMap { generateWorkflow($0) },
|
|
76
|
+
result.failureOrNil))
|
|
77
|
+
})
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
// MARK: - WeakReference
|
|
82
|
+
|
|
83
|
+
class IDVDelegate: IDVSDK.IDVDelegate {
|
|
84
|
+
func didStartNewSession(idv: IDV) { sendEvent(didStartSessionEvent) }
|
|
85
|
+
func didEndSession(idv: IDV) { sendEvent(didEndSessionEvent) }
|
|
86
|
+
func didStartRestoreSession(idv: IDV) { sendEvent(didStartRestoreSessionEvent) }
|
|
87
|
+
func didContinueRemoteSession(idv: IDV) { sendEvent(didContinueRemoteSessionEvent) }
|
|
88
|
+
}
|
|
89
|
+
let delegate = IDVDelegate()
|
package/ios/RNIDV.swift
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import Flutter
|
|
2
|
+
import UIKit
|
|
3
|
+
|
|
4
|
+
let channelID = "flutter_idv"
|
|
5
|
+
var eventSinks: [String: FlutterEventSink] = [:]
|
|
6
|
+
|
|
7
|
+
private var args: [Any?] = []
|
|
8
|
+
|
|
9
|
+
func sendEvent(_ event: String, _ data: Any? = nil) {
|
|
10
|
+
DispatchQueue.main.async {
|
|
11
|
+
if let sink = eventSinks[event] {
|
|
12
|
+
sink(data.toSendable())
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
func args<T>(_ index: Int) -> T {
|
|
18
|
+
return args[index] as! T
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
func argsNullable<T>(_ index: Int) -> T? {
|
|
22
|
+
if (args[index] is NSNull) { return nil }
|
|
23
|
+
return args[index] as! T?
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
public class FlutterIDVPlugin: NSObject, FlutterPlugin {
|
|
27
|
+
public static func register(with registrar: FlutterPluginRegistrar) {
|
|
28
|
+
func setupEventChannel(_ eventId: String) {
|
|
29
|
+
let channel = FlutterEventChannel(name: "\(channelID)/event/\(eventId)", binaryMessenger: registrar.messenger())
|
|
30
|
+
channel.setStreamHandler(GenericStreamHandler(eventId))
|
|
31
|
+
}
|
|
32
|
+
setupEventChannel(didStartSessionEvent);
|
|
33
|
+
setupEventChannel(didEndSessionEvent);
|
|
34
|
+
setupEventChannel(didStartRestoreSessionEvent);
|
|
35
|
+
setupEventChannel(didContinueRemoteSessionEvent);
|
|
36
|
+
|
|
37
|
+
let channel = FlutterMethodChannel(name: "\(channelID)/method", binaryMessenger: registrar.messenger())
|
|
38
|
+
registrar.addMethodCallDelegate(FlutterIDVPlugin(), channel: channel)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public func handle(_ call: FlutterMethodCall, result: @escaping FlutterResult) {
|
|
42
|
+
args = call.arguments as! [Any?]
|
|
43
|
+
methodCall(call.method, { data in result(data.toSendable()) })
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class GenericStreamHandler: NSObject, FlutterStreamHandler {
|
|
48
|
+
private let eventId: String
|
|
49
|
+
|
|
50
|
+
public init(_ eventId: String) {
|
|
51
|
+
self.eventId = eventId
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
public func onListen(withArguments arguments: Any?, eventSink: @escaping FlutterEventSink) -> FlutterError? {
|
|
55
|
+
eventSinks[eventId] = eventSink
|
|
56
|
+
return nil
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
public func onCancel(withArguments arguments: Any?) -> FlutterError? {
|
|
60
|
+
eventSinks[eventId] = nil
|
|
61
|
+
return nil
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
let rootViewController: () -> UIViewController? = {
|
|
66
|
+
for window in UIApplication.shared.windows {
|
|
67
|
+
if window.isKeyWindow {
|
|
68
|
+
return window.rootViewController
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return nil
|
|
72
|
+
}
|
package/ios/Utils.swift
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import Foundation
|
|
2
|
+
import UIKit
|
|
3
|
+
import IDVSDK
|
|
4
|
+
|
|
5
|
+
public typealias Callback = (Any?) -> Void
|
|
6
|
+
|
|
7
|
+
extension Any? {
|
|
8
|
+
func toSendable() -> Any {
|
|
9
|
+
guard let self else { return NSNull() }
|
|
10
|
+
if self is [String: Any?] || self is [Any?] {
|
|
11
|
+
let data = try! JSONSerialization.data(withJSONObject: fixNulls(self), options: .prettyPrinted)
|
|
12
|
+
return String(data: data, encoding: .utf8)!
|
|
13
|
+
}
|
|
14
|
+
return self
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
func fixNulls(_ value: Any?) -> Any {
|
|
19
|
+
guard let value else { return NSNull() }
|
|
20
|
+
switch value {
|
|
21
|
+
case let value as [String: Any?]:
|
|
22
|
+
var dict = [String: Any]()
|
|
23
|
+
for (k, v) in value { dict[k] = fixNulls(v) }
|
|
24
|
+
return dict
|
|
25
|
+
case let value as [Any?]: return value.map { fixNulls($0) }
|
|
26
|
+
default: return value
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
extension [String: Any?] {
|
|
31
|
+
func toDecoder() -> Decoder {
|
|
32
|
+
let data = try! JSONSerialization.data(withJSONObject: fixNulls(self), options: .prettyPrinted)
|
|
33
|
+
return try! JSONDecoder().decode(DecoderWrapper.self, from: data).decoder
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
struct DecoderWrapper: Decodable {
|
|
37
|
+
let decoder: Decoder
|
|
38
|
+
init(from decoder: Decoder) { self.decoder = decoder }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
extension Result {
|
|
42
|
+
var successOrNil: Success? {
|
|
43
|
+
if case .success(let value) = self { return value }
|
|
44
|
+
else { return nil }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
var failureOrNil: Failure? {
|
|
48
|
+
if case .failure(let error) = self { return error }
|
|
49
|
+
else { return nil }
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
var isSuccess: Bool {
|
|
53
|
+
if case .success = self { return true }
|
|
54
|
+
else { return false }
|
|
55
|
+
}
|
|
56
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@regulaforensics/idv",
|
|
3
|
+
"version": "3.2.23-beta",
|
|
4
|
+
"description": "This is an npm module for Regula IDV, which unifies access to all Regula products. This plugin makes possible to use it with react-native, cordova and capacitor applications. Supports Android and iOS.",
|
|
5
|
+
"main": "www/react-native/index.js",
|
|
6
|
+
"module": "www/capacitor/index.js",
|
|
7
|
+
"types": "www/types/index.d.ts",
|
|
8
|
+
"cordova": {
|
|
9
|
+
"id": "@regulaforensics/idv",
|
|
10
|
+
"platforms": [
|
|
11
|
+
"ios",
|
|
12
|
+
"android"
|
|
13
|
+
]
|
|
14
|
+
},
|
|
15
|
+
"keywords": [
|
|
16
|
+
"react",
|
|
17
|
+
"react-native",
|
|
18
|
+
"ionic",
|
|
19
|
+
"capacitor",
|
|
20
|
+
"cordova",
|
|
21
|
+
"face",
|
|
22
|
+
"reader",
|
|
23
|
+
"scanner",
|
|
24
|
+
"regula",
|
|
25
|
+
"platform",
|
|
26
|
+
"idv"
|
|
27
|
+
],
|
|
28
|
+
"author": "RegulaForensics",
|
|
29
|
+
"license": "commercial",
|
|
30
|
+
"repository": {
|
|
31
|
+
"type": "git",
|
|
32
|
+
"url": "git+https://github.com/regulaforensics/npm-idv.git"
|
|
33
|
+
},
|
|
34
|
+
"homepage": "https://mobile.regulaforensics.com",
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public"
|
|
37
|
+
}
|
|
38
|
+
}
|
package/plugin.xml
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
+
<plugin id="@regulaforensics/idv" version="3.2.23-beta" xmlns="http://apache.org/cordova/ns/plugins/1.0">
|
|
3
|
+
<name>IDV</name>
|
|
4
|
+
<description>Cordova plugin for Regula IDV</description>
|
|
5
|
+
<license>commercial</license>
|
|
6
|
+
<keywords>cordova,face,reader,scanner,regula,platform,idv</keywords>
|
|
7
|
+
|
|
8
|
+
<js-module name="IDVPlugin" src="www/cordova.js">
|
|
9
|
+
<clobbers target="IDVPlugin" />
|
|
10
|
+
</js-module>
|
|
11
|
+
|
|
12
|
+
<platform name="ios">
|
|
13
|
+
<config-file target="config.xml" parent="/widget">
|
|
14
|
+
<feature name="IDV">
|
|
15
|
+
<param name="ios-package" value="CVDIDV" />
|
|
16
|
+
</feature>
|
|
17
|
+
<preference name="deployment-target" value="14.0" />
|
|
18
|
+
</config-file>
|
|
19
|
+
<header-file src="ios/CVDIDV.swift" />
|
|
20
|
+
<source-file src="ios/Main.swift" />
|
|
21
|
+
<header-file src="ios/JSONConstructor.swift" />
|
|
22
|
+
<header-file src="ios/Utils.swift" />
|
|
23
|
+
<podspec>
|
|
24
|
+
<config>
|
|
25
|
+
<source url="https://github.com/CocoaPods/Specs.git" />
|
|
26
|
+
</config>
|
|
27
|
+
<pods>
|
|
28
|
+
<pod name="IDVSDK" spec="3.1.1492" />
|
|
29
|
+
</pods>
|
|
30
|
+
</podspec>
|
|
31
|
+
</platform>
|
|
32
|
+
|
|
33
|
+
<platform name="android">
|
|
34
|
+
<config-file parent="/*" target="res/xml/config.xml">
|
|
35
|
+
<feature name="IDV">
|
|
36
|
+
<param name="android-package" value="com.regula.plugin.idv.CVDIDV" />
|
|
37
|
+
</feature>
|
|
38
|
+
</config-file>
|
|
39
|
+
<framework src="android/cordova.gradle" custom="true" type="gradleReference" />
|
|
40
|
+
<source-file src="android/CVDIDV.kt" target-dir="java/com.regula.plugin.idv" />
|
|
41
|
+
<source-file src="android/src/main/java/com/regula/plugin/idv/Main.kt" target-dir="java/com.regula.plugin.idv" />
|
|
42
|
+
<source-file src="android/src/main/java/com/regula/plugin/idv/JSONConstructor.kt" target-dir="java/com.regula.plugin.idv" />
|
|
43
|
+
<source-file src="android/src/main/java/com/regula/plugin/idv/Utils.kt" target-dir="java/com.regula.plugin.idv" />
|
|
44
|
+
</platform>
|
|
45
|
+
</plugin>
|
package/test/json.tsx
ADDED
|
File without changes
|