@regulaforensics/idv 3.2.26-beta → 3.2.68-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 +2 -8
- package/RNIDV.podspec +3 -3
- package/android/CVDIDV.kt +3 -0
- package/android/build.gradle +2 -11
- package/android/cordova.gradle +2 -2
- package/android/src/main/java/com/regula/plugin/idv/JSONConstructor.kt +32 -0
- package/android/src/main/java/com/regula/plugin/idv/Main.kt +21 -1
- package/android/src/main/java/com/regula/plugin/idv/RNIDVModule.kt +3 -0
- package/examples/capacitor/android/build.gradle +1 -1
- package/examples/capacitor/index.tsx +5 -5
- package/examples/capacitor/ios/App/App.xcodeproj/project.pbxproj +4 -0
- package/examples/capacitor/package-lock.json +3350 -0
- package/examples/capacitor/package.json +7 -7
- package/examples/capacitor/src/main.html +9 -30
- package/examples/capacitor/src/main.tsx +115 -1
- package/examples/ionic/README.md +2 -2
- package/examples/ionic/config.xml +1 -0
- package/examples/ionic/index.tsx +5 -1
- package/examples/ionic/package-lock.json +16573 -0
- package/examples/ionic/package.json +19 -19
- package/examples/ionic/src/main.html +9 -30
- package/examples/ionic/src/main.tsx +115 -1
- package/examples/react_native/README.md +2 -2
- package/examples/react_native/index.html +5 -4
- package/examples/react_native/package-lock.json +8996 -0
- package/examples/react_native/package.json +7 -7
- package/examples/react_native/scripts/setup.sh +3 -0
- package/examples/react_native/src/main.html +9 -30
- package/examples/react_native/src/main.tsx +115 -1
- package/ios/CVDIDV.swift +24 -45
- package/ios/JSONConstructor.swift +24 -2
- package/ios/Main.swift +28 -12
- package/ios/RNIDV.m +11 -0
- package/ios/RNIDV.swift +30 -55
- package/ios/Utils.swift +0 -4
- package/package.json +1 -1
- package/plugin.xml +6 -5
- package/test/json.tsx +49 -0
- package/test/package-lock.json +1 -1
- package/test/test.tsx +14 -2
- package/www/capacitor/config/api_key_connection_config.js +32 -0
- package/www/capacitor/config/credentials_connection_config.js +32 -0
- package/www/capacitor/config/prepare_workflow_config.js +20 -0
- package/www/capacitor/config/send_data_config.js +28 -0
- package/www/capacitor/config/start_session_config.js +24 -0
- package/www/capacitor/config/start_workflow_config.js +24 -0
- package/www/capacitor/config/token_connection_config.js +20 -0
- package/www/capacitor/index.js +113 -1
- package/www/capacitor/internal/bridge.js +19 -8
- package/www/capacitor/model/workflow.js +28 -0
- package/www/capacitor/model/workflow_result.js +21 -0
- package/www/capacitor/model/workflow_step.js +19 -0
- package/www/cordova.js +559 -16
- package/www/react-native/config/api_key_connection_config.js +32 -0
- package/www/react-native/config/credentials_connection_config.js +32 -0
- package/www/react-native/config/prepare_workflow_config.js +20 -0
- package/www/react-native/config/send_data_config.js +28 -0
- package/www/react-native/config/start_session_config.js +24 -0
- package/www/react-native/config/start_workflow_config.js +24 -0
- package/www/react-native/config/token_connection_config.js +20 -0
- package/www/react-native/index.js +113 -1
- package/www/react-native/internal/bridge.js +19 -8
- package/www/react-native/model/workflow.js +28 -0
- package/www/react-native/model/workflow_result.js +21 -0
- package/www/react-native/model/workflow_step.js +19 -0
- package/www/types/config/api_key_connection_config.d.ts +6 -0
- package/www/types/config/credentials_connection_config.d.ts +6 -0
- package/www/types/config/prepare_workflow_config.d.ts +3 -0
- package/www/types/config/send_data_config.d.ts +5 -0
- package/www/types/config/start_session_config.d.ts +4 -0
- package/www/types/config/start_workflow_config.d.ts +4 -0
- package/www/types/config/token_connection_config.d.ts +3 -0
- package/www/types/index.d.ts +49 -0
- package/www/types/model/workflow.d.ts +9 -0
- package/www/types/model/workflow_result.d.ts +8 -0
- package/www/types/model/workflow_step.d.ts +6 -0
- package/ios/FlutterIDVPlugin.swift +0 -72
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"start": "expo start"
|
|
9
9
|
},
|
|
10
10
|
"dependencies": {
|
|
11
|
-
"@regulaforensics/idv": "3.2.
|
|
12
|
-
"@regulaforensics/document-reader": "
|
|
13
|
-
"@regulaforensics/face-sdk": "7.
|
|
14
|
-
"@regulaforensics/document-reader-core-fullauthrfid": "
|
|
15
|
-
"@regulaforensics/face-core-basic": "7.
|
|
16
|
-
"@regulaforensics/idv-module-document-reader": "3.2.
|
|
17
|
-
"@regulaforensics/idv-module-face": "3.2.
|
|
11
|
+
"@regulaforensics/idv": "3.2.68-beta",
|
|
12
|
+
"@regulaforensics/document-reader": "9.1.505",
|
|
13
|
+
"@regulaforensics/face-sdk": "7.2.691",
|
|
14
|
+
"@regulaforensics/document-reader-core-fullauthrfid": "9.1.1281",
|
|
15
|
+
"@regulaforensics/face-core-basic": "7.2.265",
|
|
16
|
+
"@regulaforensics/idv-module-document-reader": "3.2.48-beta",
|
|
17
|
+
"@regulaforensics/idv-module-face": "3.2.49-beta",
|
|
18
18
|
"react-native": "^0.81.4",
|
|
19
19
|
"react-native-webview": "^13.16.0",
|
|
20
20
|
"@react-native/metro-config": "^0.81.1",
|
|
@@ -7,3 +7,6 @@ expo prebuild
|
|
|
7
7
|
mkdir -p android/app/src/main/assets/Regula
|
|
8
8
|
mv android/app/src/main/res/raw/regula.license android/app/src/main/assets/Regula/
|
|
9
9
|
mv android/app/src/main/res/raw/db.dat android/app/src/main/assets/Regula/
|
|
10
|
+
|
|
11
|
+
sed -i '' '$a\
|
|
12
|
+
android { buildFeatures { dataBinding true } }' android/app/build.gradle
|
|
@@ -1,38 +1,17 @@
|
|
|
1
1
|
<div class="column" style="height: 100%">
|
|
2
2
|
<div class="column header">
|
|
3
|
-
<span id="status">
|
|
3
|
+
<span id="status">Initializing...</span>
|
|
4
4
|
<div class="column divider"></div>
|
|
5
5
|
</div>
|
|
6
|
-
<div id="
|
|
7
|
-
<
|
|
8
|
-
|
|
9
|
-
<p>Portrait</p>
|
|
10
|
-
<img id="portrait-image" src="images/portrait.png" height="160px" width="120px">
|
|
11
|
-
</div>
|
|
12
|
-
<div class="column" style="padding: 5px;">
|
|
13
|
-
<p>Document image</p>
|
|
14
|
-
<img id="document-image" src="images/document.png" height="160px" width="200px">
|
|
15
|
-
</div>
|
|
16
|
-
</div>
|
|
17
|
-
<div id="scenario-container" class="column no-scroll" style="margin-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
|
|
18
|
-
<div id="scenarios" class="scroll"></div>
|
|
19
|
-
</div>
|
|
20
|
-
<div class="row" style="width: 360px; padding-top: 15px;">
|
|
21
|
-
<span id="rfid-checkbox-description" style="font-size: 18px;width: 100%;">Process rfid reading(unavailable)</span>
|
|
22
|
-
<input id="rfid-checkbox" type="checkbox" style="margin-left: auto;" disabled />
|
|
23
|
-
</div>
|
|
24
|
-
<div class="row">
|
|
25
|
-
<button id="scan" class="button">Scan document</button>
|
|
26
|
-
<button id="recognize" class="button">Scan image</button>
|
|
27
|
-
</div>
|
|
28
|
-
<button id="connect" class="button" style="width: 360px; display: none;">Connect</button>
|
|
29
|
-
<div style="padding-top: 20px;"></div>
|
|
6
|
+
<div id="sub-header" class="column sub-header" style="display: none;">
|
|
7
|
+
<span id="description"></span>
|
|
8
|
+
<div class="column divider"></div>
|
|
30
9
|
</div>
|
|
31
|
-
<div id="
|
|
32
|
-
<
|
|
33
|
-
|
|
34
|
-
<div id="progress"></div>
|
|
10
|
+
<div id="main" class="column no-scroll">
|
|
11
|
+
<div class="column no-scroll" style="padding-top: 15px; background-color: rgba(0, 0, 0, 0.03);">
|
|
12
|
+
<div id="radio-group" class="scroll"></div>
|
|
35
13
|
</div>
|
|
36
|
-
<button id="
|
|
14
|
+
<button id="start-workflow" class="button" style="width: 360px">Start Workflow</button>
|
|
15
|
+
<div style="padding-top: 30px"></div>
|
|
37
16
|
</div>
|
|
38
17
|
</div>
|
|
@@ -1,10 +1,124 @@
|
|
|
1
|
-
import { IDV } from '@regulaforensics/idv'
|
|
1
|
+
import { IDV, Workflow } from '@regulaforensics/idv'
|
|
2
|
+
|
|
3
|
+
enum Configuration { credentials, token, apiKey }
|
|
4
|
+
|
|
5
|
+
const loginType: Configuration = Configuration.credentials
|
|
6
|
+
const baseUrl = "https://idv.regula.app"
|
|
7
|
+
const username = "username_placeholder"
|
|
8
|
+
const password = "password_placeholder"
|
|
9
|
+
const tokenUrl = "token_placeholder"
|
|
10
|
+
const apiKey = "api_key_placeholder"
|
|
2
11
|
|
|
3
12
|
var idv = IDV.instance
|
|
13
|
+
var selectedWorkflow = ""
|
|
14
|
+
var workflowIds: string[] = []
|
|
15
|
+
|
|
16
|
+
async function init() {
|
|
17
|
+
var [_, iError] = await idv.initialize()
|
|
18
|
+
if (handleException(iError, "initialize")) return
|
|
19
|
+
|
|
20
|
+
var success = ({
|
|
21
|
+
[Configuration.credentials]: async () => await configureWithCredentials(),
|
|
22
|
+
[Configuration.token]: async () => await configureWithToken(),
|
|
23
|
+
[Configuration.apiKey]: async () => await configureApiKey(),
|
|
24
|
+
})[loginType]!
|
|
25
|
+
if (!await success()) return
|
|
26
|
+
|
|
27
|
+
var [wfs, error] = await idv.getWorkflows()
|
|
28
|
+
if (handleException(error, "getWorkflows")) return
|
|
29
|
+
if (loginType == Configuration.token) {
|
|
30
|
+
wfs = wfs!.filter((wf: any) => workflowIds.includes(wf.id))
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
setWorkflows(wfs!)
|
|
34
|
+
setStatus("Ready")
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async function configureWithCredentials(): Promise<boolean> {
|
|
38
|
+
var [success, error] = await idv.configureWithCredentials({
|
|
39
|
+
baseUrl: baseUrl,
|
|
40
|
+
userName: username,
|
|
41
|
+
password: password
|
|
42
|
+
})
|
|
43
|
+
handleException(error, "configureWithCredentials")
|
|
44
|
+
return success
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
async function configureWithToken(): Promise<boolean> {
|
|
48
|
+
var [wfIds, error] = await idv.configureWithToken({ url: tokenUrl })
|
|
49
|
+
if (handleException(error, "configureWithToken")) return false
|
|
50
|
+
workflowIds = wfIds!
|
|
51
|
+
return true
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async function configureApiKey(): Promise<boolean> {
|
|
55
|
+
var [success, error] = await idv.configureWithApiKey({ baseUrl, apiKey })
|
|
56
|
+
handleException(error, "configureWithApiKey")
|
|
57
|
+
return success
|
|
58
|
+
}
|
|
4
59
|
|
|
60
|
+
async function startWorkflow(): Promise<void> {
|
|
61
|
+
if (selectedWorkflow.length == 0) return
|
|
62
|
+
setStatus("Preparing Workflow...")
|
|
63
|
+
|
|
64
|
+
var [_, prepareError] = await idv.prepareWorkflow({ workflowId: selectedWorkflow })
|
|
65
|
+
if (handleException(prepareError, "prepareWorkflow")) return
|
|
66
|
+
|
|
67
|
+
var [result, error] = await idv.startWorkflow()
|
|
68
|
+
if (handleException(error, "startWorkflow")) return
|
|
69
|
+
|
|
70
|
+
setStatus("Success")
|
|
71
|
+
setDescription(`SessionID: ${result?.sessionId}`)
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function handleException(error?: string | null, tag?: string): boolean {
|
|
75
|
+
if (error == null) return false
|
|
76
|
+
setStatus(`Error - IDV.${tag}()`)
|
|
77
|
+
setDescription(error)
|
|
78
|
+
console.log(error)
|
|
79
|
+
return true
|
|
80
|
+
}
|
|
5
81
|
|
|
6
82
|
// --------------------------------------------------------------------------------------------------------------------
|
|
7
83
|
|
|
8
84
|
export function main() {
|
|
85
|
+
document.getElementById("start-workflow")!.onclick = () => startWorkflow()
|
|
86
|
+
|
|
87
|
+
init()
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
var setStatus = (data: string) => document.getElementById("status")!.innerHTML = data
|
|
91
|
+
var setDescription = (data: string) => {
|
|
92
|
+
document.getElementById("description")!.innerHTML = data
|
|
93
|
+
document.getElementById("sub-header")!.style.display = data.length > 0 ? "block" : "none"
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
var workflows: Workflow[] = []
|
|
97
|
+
function setWorkflows(data: Workflow[]) {
|
|
98
|
+
var radioGroup = document.getElementById("radio-group")!
|
|
99
|
+
workflows = data
|
|
100
|
+
if (workflows.length != 0) {
|
|
101
|
+
selectedWorkflow = workflows[0].id
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
data.forEach(item => {
|
|
105
|
+
var checked = selectedWorkflow == item.id ? "checked" : ""
|
|
106
|
+
var radioElement = `
|
|
107
|
+
<div class="row radio">
|
|
108
|
+
<input type="radio" name="radio" id="${item.id}" value="${item.id}" ${checked}>
|
|
109
|
+
<span id="${item.id}-caption" style="width: 200px; padding-left: 5px;">${item.name}</span>
|
|
110
|
+
</div>`
|
|
111
|
+
radioGroup.insertAdjacentHTML("beforeend", radioElement)
|
|
112
|
+
})
|
|
9
113
|
|
|
114
|
+
data.forEach(item => {
|
|
115
|
+
var element = document.getElementById(item.id) as HTMLInputElement
|
|
116
|
+
var elementCaption = document.getElementById(item.id + "-caption")!
|
|
117
|
+
var onclick = () => {
|
|
118
|
+
selectedWorkflow = item.id
|
|
119
|
+
element.checked = true
|
|
120
|
+
}
|
|
121
|
+
element.onclick = onclick
|
|
122
|
+
elementCaption.onclick = onclick
|
|
123
|
+
})
|
|
10
124
|
}
|
package/ios/CVDIDV.swift
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
import UIKit
|
|
3
|
-
|
|
4
|
-
let channelID = "flutter_idv"
|
|
5
|
-
var eventSinks: [String: FlutterEventSink] = [:]
|
|
6
|
-
|
|
1
|
+
var eventCallbackIds: [String: String] = [:]
|
|
7
2
|
private var args: [Any?] = []
|
|
3
|
+
private var this: CVDIDV?
|
|
8
4
|
|
|
9
5
|
func sendEvent(_ event: String, _ data: Any? = nil) {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
6
|
+
var callbackId = event
|
|
7
|
+
let eventId = eventCallbackIds[event]
|
|
8
|
+
if eventId != nil { callbackId = eventId! }
|
|
9
|
+
|
|
10
|
+
var sendable = data.toSendable() as Any?
|
|
11
|
+
if sendable is NSNull { sendable = nil }
|
|
12
|
+
let result = CDVPluginResult(status: CDVCommandStatus_OK, messageAs: sendable as! String?)!
|
|
13
|
+
result.setKeepCallbackAs(true)
|
|
14
|
+
|
|
15
|
+
this!.commandDelegate.send(result, callbackId: callbackId)
|
|
15
16
|
}
|
|
16
17
|
|
|
17
18
|
func args<T>(_ index: Int) -> T {
|
|
@@ -23,42 +24,20 @@ func argsNullable<T>(_ index: Int) -> T? {
|
|
|
23
24
|
return args[index] as! T?
|
|
24
25
|
}
|
|
25
26
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
27
|
+
@objc(CVDIDV)
|
|
28
|
+
class CVDIDV: CDVPlugin {
|
|
29
|
+
@objc(exec:)
|
|
30
|
+
func exec(_ command: CDVInvokedUrlCommand) {
|
|
31
|
+
this = self
|
|
32
|
+
let method = command.arguments.first as! String
|
|
33
|
+
args = Array(command.arguments.dropFirst())
|
|
34
|
+
|
|
35
|
+
if method == "setEvent" {
|
|
36
|
+
eventCallbackIds[args.first as! String] = command.callbackId
|
|
37
|
+
return
|
|
31
38
|
}
|
|
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
39
|
|
|
47
|
-
|
|
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
|
|
40
|
+
methodCall(method, { data in sendEvent(command.callbackId, data) })
|
|
62
41
|
}
|
|
63
42
|
}
|
|
64
43
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import UIKit
|
|
3
1
|
import IDVSDK
|
|
4
2
|
import IDVModule
|
|
5
3
|
|
|
@@ -83,6 +81,29 @@ public func generateStartWorkflowConfig(_ data: StartWorkflowConfig) -> [String:
|
|
|
83
81
|
]
|
|
84
82
|
}
|
|
85
83
|
|
|
84
|
+
public func sendDataConfigFromJSON(_ data: [String: Any?]) -> SendDataConfig {
|
|
85
|
+
return SendDataConfig(sessionId: data["sessionId"] as! String, step: data["step"] as! String, data: data["data"] as! [String: Any])
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
public func generateSendDataConfig(_ data: SendDataConfig) -> [String: Any?] {
|
|
89
|
+
return [
|
|
90
|
+
"sessionId": data.sessionId,
|
|
91
|
+
"step": data.step,
|
|
92
|
+
"data": data.data
|
|
93
|
+
]
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
public func startSessionConfigFromJSON(_ data: [String: Any?]) -> StartSessionConfig {
|
|
97
|
+
return StartSessionConfig(workflowId: data["workflowId"] as! String, metadata: data["metadata"] as? [String : Any])
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
public func generateStartSessionConfig(_ data: StartSessionConfig) -> [String: Any?] {
|
|
101
|
+
return [
|
|
102
|
+
"workflowId": data.workflowId,
|
|
103
|
+
"metadata": data.metadata
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
|
|
86
107
|
// MARK: - Model
|
|
87
108
|
|
|
88
109
|
public func workflowFromJSON(_ input: [String: Any?]?) -> Workflow? {
|
|
@@ -90,6 +111,7 @@ public func workflowFromJSON(_ input: [String: Any?]?) -> Workflow? {
|
|
|
90
111
|
it["client"] = [String: Any]()
|
|
91
112
|
it["steps"] = [WorkflowStep]()
|
|
92
113
|
it["_description"] = it["description"]
|
|
114
|
+
it["trackLocation"] = false
|
|
93
115
|
return try! Workflow(from: it.toDecoder())
|
|
94
116
|
}
|
|
95
117
|
|
package/ios/Main.swift
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import Foundation
|
|
2
|
-
import UIKit
|
|
3
1
|
import IDVSDK
|
|
4
2
|
|
|
5
3
|
let didStartSessionEvent = "didStartSessionEvent"
|
|
@@ -11,7 +9,7 @@ func methodCall(_ method: String, _ callback: @escaping Callback) {
|
|
|
11
9
|
switch (method) {
|
|
12
10
|
case("setSessionRestoreMode"): IDV.shared.sessionRestoreMode = SessionRestoreMode(rawValue: args(0))!
|
|
13
11
|
case("getCurrentSessionId"): callback(IDV.shared.currentSessionId)
|
|
14
|
-
case
|
|
12
|
+
case("initialize"): initialize(callback)
|
|
15
13
|
case("deinitialize"): deinitialize(callback)
|
|
16
14
|
case("configureWithToken"): configureWithToken(callback, args(0))
|
|
17
15
|
case("configureWithCredentials"): configureWithCredentials(callback, args(0))
|
|
@@ -19,6 +17,8 @@ func methodCall(_ method: String, _ callback: @escaping Callback) {
|
|
|
19
17
|
case("prepareWorkflow"): prepareWorkflow(callback, args(0))
|
|
20
18
|
case("startWorkflow"): startWorkflow(callback, argsNullable(0))
|
|
21
19
|
case("getWorkflows"): getWorkflows(callback)
|
|
20
|
+
case("startSession"): startSession(callback, args(0))
|
|
21
|
+
case("sendData"): sendData(callback, args(0))
|
|
22
22
|
default: break
|
|
23
23
|
}
|
|
24
24
|
}
|
|
@@ -26,10 +26,12 @@ func methodCall(_ method: String, _ callback: @escaping Callback) {
|
|
|
26
26
|
// MARK: - Implementation
|
|
27
27
|
|
|
28
28
|
func initialize(_ callback: @escaping Callback) {
|
|
29
|
-
|
|
30
|
-
IDV.shared.
|
|
31
|
-
|
|
32
|
-
|
|
29
|
+
DispatchQueue.main.async {
|
|
30
|
+
IDV.shared.initialize(config: IDVInitConfig(), completion: { result in
|
|
31
|
+
IDV.shared.delegate = delegate
|
|
32
|
+
callback(generateCompletion(result.isSuccess, result.failureOrNil))
|
|
33
|
+
})
|
|
34
|
+
}
|
|
33
35
|
}
|
|
34
36
|
|
|
35
37
|
func deinitialize(_ callback: @escaping Callback) {
|
|
@@ -63,11 +65,13 @@ func prepareWorkflow(_ callback: @escaping Callback, _ data: [String: Any?]) {
|
|
|
63
65
|
}
|
|
64
66
|
|
|
65
67
|
func startWorkflow(_ callback: @escaping Callback, _ data: [String: Any?]?) {
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
68
|
+
DispatchQueue.main.async {
|
|
69
|
+
IDV.shared.startWorkflow(presenter: rootViewController()!,
|
|
70
|
+
config: startWorkflowConfigFromJSON(input: data),
|
|
71
|
+
completion: { result in
|
|
72
|
+
callback(generateCompletion(generateWorkflowResult(result.successOrNil), result.failureOrNil))
|
|
73
|
+
})
|
|
74
|
+
}
|
|
71
75
|
}
|
|
72
76
|
|
|
73
77
|
func getWorkflows(_ callback: @escaping Callback) {
|
|
@@ -77,6 +81,18 @@ func getWorkflows(_ callback: @escaping Callback) {
|
|
|
77
81
|
})
|
|
78
82
|
}
|
|
79
83
|
|
|
84
|
+
func startSession(_ callback: @escaping Callback, _ data: [String: Any?]) {
|
|
85
|
+
IDV.shared.startSession(with: startSessionConfigFromJSON(data), completion: { result in
|
|
86
|
+
callback(generateCompletion(result.successOrNil, result.failureOrNil))
|
|
87
|
+
})
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
func sendData(_ callback: @escaping Callback, _ data: [String: Any?]) {
|
|
91
|
+
IDV.shared.sendData(with: sendDataConfigFromJSON(data), completion: { result in
|
|
92
|
+
callback(generateCompletion(result.isSuccess, result.failureOrNil))
|
|
93
|
+
})
|
|
94
|
+
}
|
|
95
|
+
|
|
80
96
|
|
|
81
97
|
// MARK: - WeakReference
|
|
82
98
|
|
package/ios/RNIDV.m
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#import <React/RCTEventEmitter.h>
|
|
2
|
+
#import <React/RCTBridgeModule.h>
|
|
3
|
+
|
|
4
|
+
@interface RCT_EXTERN_MODULE(RNIDV, RCTEventEmitter)
|
|
5
|
+
|
|
6
|
+
RCT_EXTERN_METHOD(exec: (NSString*)method
|
|
7
|
+
args:(NSArray*)args
|
|
8
|
+
resolve:(RCTPromiseResolveBlock)resolve
|
|
9
|
+
reject:(RCTPromiseRejectBlock)reject)
|
|
10
|
+
|
|
11
|
+
@end
|
package/ios/RNIDV.swift
CHANGED
|
@@ -1,72 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import UIKit
|
|
3
|
-
|
|
4
|
-
let channelID = "flutter_idv"
|
|
5
|
-
var eventSinks: [String: FlutterEventSink] = [:]
|
|
6
|
-
|
|
7
|
-
private var args: [Any?] = []
|
|
1
|
+
import React
|
|
8
2
|
|
|
9
3
|
func sendEvent(_ event: String, _ data: Any? = nil) {
|
|
4
|
+
guard let plugin = this, hasListeners else { return }
|
|
10
5
|
DispatchQueue.main.async {
|
|
11
|
-
|
|
12
|
-
sink(data.toSendable())
|
|
13
|
-
}
|
|
6
|
+
plugin.sendEvent(withName: event, body: data.toSendable())
|
|
14
7
|
}
|
|
15
8
|
}
|
|
16
9
|
|
|
17
10
|
func args<T>(_ index: Int) -> T {
|
|
18
|
-
return
|
|
11
|
+
return mArgs[index] as! T
|
|
19
12
|
}
|
|
20
13
|
|
|
21
14
|
func argsNullable<T>(_ index: Int) -> T? {
|
|
22
|
-
if (
|
|
23
|
-
return
|
|
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
|
-
}
|
|
15
|
+
if (mArgs[index] is NSNull) { return nil }
|
|
16
|
+
return mArgs[index] as! T?
|
|
45
17
|
}
|
|
46
18
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
public func
|
|
55
|
-
|
|
56
|
-
|
|
19
|
+
private var firedCallbacks: [RCTResponseSenderBlock] = []
|
|
20
|
+
private var hasListeners: Bool = false
|
|
21
|
+
private var this: RNIDV?
|
|
22
|
+
private var mArgs: [Any?] = []
|
|
23
|
+
|
|
24
|
+
@objc(RNIDV)
|
|
25
|
+
public class RNIDV: RCTEventEmitter {
|
|
26
|
+
override public func startObserving() { hasListeners = true }
|
|
27
|
+
override public func stopObserving() { hasListeners = false }
|
|
28
|
+
override public func supportedEvents()->[String] {
|
|
29
|
+
return [didStartSessionEvent,
|
|
30
|
+
didEndSessionEvent,
|
|
31
|
+
didStartRestoreSessionEvent,
|
|
32
|
+
didContinueRemoteSessionEvent];
|
|
57
33
|
}
|
|
58
34
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
35
|
+
@objc
|
|
36
|
+
func exec(_ method: String, args: [Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
|
|
37
|
+
this = self
|
|
38
|
+
mArgs = args
|
|
39
|
+
methodCall(method, { data in
|
|
40
|
+
if firedCallbacks.contains(where: { ($0 as AnyObject) === (resolve as AnyObject) }) { return }
|
|
41
|
+
firedCallbacks.append(resolve)
|
|
42
|
+
resolve(data.toSendable())
|
|
43
|
+
})
|
|
62
44
|
}
|
|
63
45
|
}
|
|
64
46
|
|
|
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
|
-
}
|
|
47
|
+
let rootViewController: () -> UIViewController? = { return RCTPresentedViewController() }
|
package/ios/Utils.swift
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@regulaforensics/idv",
|
|
3
|
-
"version": "3.2.
|
|
3
|
+
"version": "3.2.68-beta",
|
|
4
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
5
|
"main": "www/react-native/index.js",
|
|
6
6
|
"module": "www/capacitor/index.js",
|
package/plugin.xml
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<?xml version='1.0' encoding='utf-8'?>
|
|
2
|
-
<plugin id="@regulaforensics/idv" version="3.2.
|
|
2
|
+
<plugin id="@regulaforensics/idv" version="3.2.68-beta" xmlns="http://apache.org/cordova/ns/plugins/1.0">
|
|
3
3
|
<name>IDV</name>
|
|
4
4
|
<description>Cordova plugin for Regula IDV</description>
|
|
5
5
|
<license>commercial</license>
|
|
@@ -15,17 +15,18 @@
|
|
|
15
15
|
<param name="ios-package" value="CVDIDV" />
|
|
16
16
|
</feature>
|
|
17
17
|
<preference name="deployment-target" value="14.0" />
|
|
18
|
+
<preference name="SwiftVersion" value="5" />
|
|
18
19
|
</config-file>
|
|
19
|
-
<
|
|
20
|
+
<source-file src="ios/CVDIDV.swift" />
|
|
20
21
|
<source-file src="ios/Main.swift" />
|
|
21
|
-
<
|
|
22
|
-
<
|
|
22
|
+
<source-file src="ios/JSONConstructor.swift" />
|
|
23
|
+
<source-file src="ios/Utils.swift" />
|
|
23
24
|
<podspec>
|
|
24
25
|
<config>
|
|
25
26
|
<source url="https://github.com/CocoaPods/Specs.git" />
|
|
26
27
|
</config>
|
|
27
28
|
<pods>
|
|
28
|
-
<pod name="IDVSDK" spec="3.
|
|
29
|
+
<pod name="IDVSDK" spec="3.2.1670" />
|
|
29
30
|
</pods>
|
|
30
31
|
</podspec>
|
|
31
32
|
</platform>
|
package/test/json.tsx
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
export var credentialsConnectionConfig = {
|
|
2
|
+
"baseUrl": "test3",
|
|
3
|
+
"userName": "test1",
|
|
4
|
+
"password": "test2",
|
|
5
|
+
"httpTimeoutMs": 1,
|
|
6
|
+
}
|
|
7
|
+
export var tokenConnectionConfig = {
|
|
8
|
+
"url": "test1",
|
|
9
|
+
}
|
|
10
|
+
export var apiKeyConnectionConfig = {
|
|
11
|
+
"baseUrl": "test1",
|
|
12
|
+
"apiKey": "test2",
|
|
13
|
+
"ttl": 1,
|
|
14
|
+
"httpTimeoutMs": 2,
|
|
15
|
+
}
|
|
16
|
+
export var prepareWorkflowConfig = {
|
|
17
|
+
"workflowId": "test1",
|
|
18
|
+
}
|
|
19
|
+
export var startWorkflowConfig = {
|
|
20
|
+
"locale": "test1",
|
|
21
|
+
"metadata": {
|
|
22
|
+
"test2": "test3",
|
|
23
|
+
},
|
|
24
|
+
}
|
|
25
|
+
export var startSessionConfig = {
|
|
26
|
+
"workflowId": "test1",
|
|
27
|
+
"metadata": {"test1": 0, "test2": "test3", "test4": true},
|
|
28
|
+
}
|
|
29
|
+
export var sendDataConfig = {
|
|
30
|
+
"sessionId": "test1",
|
|
31
|
+
"step": "test2",
|
|
32
|
+
"data": {"test1": 0, "test2": "test3", "test4": true},
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export var workflow = {
|
|
36
|
+
"id": "test1",
|
|
37
|
+
"name": "test2",
|
|
38
|
+
"version": "test3",
|
|
39
|
+
"description": "test4",
|
|
40
|
+
"defaultLocale": "test5",
|
|
41
|
+
}
|
|
42
|
+
export var workflowStep = {
|
|
43
|
+
"id": "test1",
|
|
44
|
+
"name": "test2",
|
|
45
|
+
}
|
|
46
|
+
export var workflowResult = {
|
|
47
|
+
"sessionId": "test1",
|
|
48
|
+
"finalStep": workflowStep,
|
|
49
|
+
}
|
package/test/package-lock.json
CHANGED
package/test/test.tsx
CHANGED
|
@@ -1,3 +1,15 @@
|
|
|
1
1
|
import { compare } from './utils'
|
|
2
|
-
import { } from '@regulaforensics/idv'
|
|
3
|
-
import { } from './json'
|
|
2
|
+
import { CredentialsConnectionConfig, TokenConnectionConfig, ApiKeyConnectionConfig, PrepareWorkflowConfig, StartWorkflowConfig, Workflow, WorkflowStep, WorkflowResult, StartSessionConfig, SendDataConfig } from '@regulaforensics/idv/www/capacitor'
|
|
3
|
+
import { apiKeyConnectionConfig, credentialsConnectionConfig, prepareWorkflowConfig, startWorkflowConfig, tokenConnectionConfig, workflow, workflowStep, workflowResult, startSessionConfig, sendDataConfig } from './json'
|
|
4
|
+
|
|
5
|
+
compare('credentialsConnectionConfig', credentialsConnectionConfig, CredentialsConnectionConfig.fromJson)
|
|
6
|
+
compare('tokenConnectionConfig', tokenConnectionConfig, TokenConnectionConfig.fromJson)
|
|
7
|
+
compare('apiKeyConnectionConfig', apiKeyConnectionConfig, ApiKeyConnectionConfig.fromJson)
|
|
8
|
+
compare('prepareWorkflowConfig', prepareWorkflowConfig, PrepareWorkflowConfig.fromJson)
|
|
9
|
+
compare('startWorkflowConfig', startWorkflowConfig, StartWorkflowConfig.fromJson)
|
|
10
|
+
compare('startSessionConfig', startSessionConfig, StartSessionConfig.fromJson)
|
|
11
|
+
compare('sendDataConfig', sendDataConfig, SendDataConfig.fromJson)
|
|
12
|
+
|
|
13
|
+
compare('workflow', workflow, Workflow.fromJson);
|
|
14
|
+
compare('workflowStep', workflowStep, WorkflowStep.fromJson);
|
|
15
|
+
compare('workflowResult', workflowResult, WorkflowResult.fromJson);
|