@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.
Files changed (77) hide show
  1. package/README.md +2 -8
  2. package/RNIDV.podspec +3 -3
  3. package/android/CVDIDV.kt +3 -0
  4. package/android/build.gradle +2 -11
  5. package/android/cordova.gradle +2 -2
  6. package/android/src/main/java/com/regula/plugin/idv/JSONConstructor.kt +32 -0
  7. package/android/src/main/java/com/regula/plugin/idv/Main.kt +21 -1
  8. package/android/src/main/java/com/regula/plugin/idv/RNIDVModule.kt +3 -0
  9. package/examples/capacitor/android/build.gradle +1 -1
  10. package/examples/capacitor/index.tsx +5 -5
  11. package/examples/capacitor/ios/App/App.xcodeproj/project.pbxproj +4 -0
  12. package/examples/capacitor/package-lock.json +3350 -0
  13. package/examples/capacitor/package.json +7 -7
  14. package/examples/capacitor/src/main.html +9 -30
  15. package/examples/capacitor/src/main.tsx +115 -1
  16. package/examples/ionic/README.md +2 -2
  17. package/examples/ionic/config.xml +1 -0
  18. package/examples/ionic/index.tsx +5 -1
  19. package/examples/ionic/package-lock.json +16573 -0
  20. package/examples/ionic/package.json +19 -19
  21. package/examples/ionic/src/main.html +9 -30
  22. package/examples/ionic/src/main.tsx +115 -1
  23. package/examples/react_native/README.md +2 -2
  24. package/examples/react_native/index.html +5 -4
  25. package/examples/react_native/package-lock.json +8996 -0
  26. package/examples/react_native/package.json +7 -7
  27. package/examples/react_native/scripts/setup.sh +3 -0
  28. package/examples/react_native/src/main.html +9 -30
  29. package/examples/react_native/src/main.tsx +115 -1
  30. package/ios/CVDIDV.swift +24 -45
  31. package/ios/JSONConstructor.swift +24 -2
  32. package/ios/Main.swift +28 -12
  33. package/ios/RNIDV.m +11 -0
  34. package/ios/RNIDV.swift +30 -55
  35. package/ios/Utils.swift +0 -4
  36. package/package.json +1 -1
  37. package/plugin.xml +6 -5
  38. package/test/json.tsx +49 -0
  39. package/test/package-lock.json +1 -1
  40. package/test/test.tsx +14 -2
  41. package/www/capacitor/config/api_key_connection_config.js +32 -0
  42. package/www/capacitor/config/credentials_connection_config.js +32 -0
  43. package/www/capacitor/config/prepare_workflow_config.js +20 -0
  44. package/www/capacitor/config/send_data_config.js +28 -0
  45. package/www/capacitor/config/start_session_config.js +24 -0
  46. package/www/capacitor/config/start_workflow_config.js +24 -0
  47. package/www/capacitor/config/token_connection_config.js +20 -0
  48. package/www/capacitor/index.js +113 -1
  49. package/www/capacitor/internal/bridge.js +19 -8
  50. package/www/capacitor/model/workflow.js +28 -0
  51. package/www/capacitor/model/workflow_result.js +21 -0
  52. package/www/capacitor/model/workflow_step.js +19 -0
  53. package/www/cordova.js +559 -16
  54. package/www/react-native/config/api_key_connection_config.js +32 -0
  55. package/www/react-native/config/credentials_connection_config.js +32 -0
  56. package/www/react-native/config/prepare_workflow_config.js +20 -0
  57. package/www/react-native/config/send_data_config.js +28 -0
  58. package/www/react-native/config/start_session_config.js +24 -0
  59. package/www/react-native/config/start_workflow_config.js +24 -0
  60. package/www/react-native/config/token_connection_config.js +20 -0
  61. package/www/react-native/index.js +113 -1
  62. package/www/react-native/internal/bridge.js +19 -8
  63. package/www/react-native/model/workflow.js +28 -0
  64. package/www/react-native/model/workflow_result.js +21 -0
  65. package/www/react-native/model/workflow_step.js +19 -0
  66. package/www/types/config/api_key_connection_config.d.ts +6 -0
  67. package/www/types/config/credentials_connection_config.d.ts +6 -0
  68. package/www/types/config/prepare_workflow_config.d.ts +3 -0
  69. package/www/types/config/send_data_config.d.ts +5 -0
  70. package/www/types/config/start_session_config.d.ts +4 -0
  71. package/www/types/config/start_workflow_config.d.ts +4 -0
  72. package/www/types/config/token_connection_config.d.ts +3 -0
  73. package/www/types/index.d.ts +49 -0
  74. package/www/types/model/workflow.d.ts +9 -0
  75. package/www/types/model/workflow_result.d.ts +8 -0
  76. package/www/types/model/workflow_step.d.ts +6 -0
  77. package/ios/FlutterIDVPlugin.swift +0 -72
@@ -0,0 +1,32 @@
1
+ export class ApiKeyConnectionConfig {
2
+ baseUrl
3
+ apiKey
4
+ ttl
5
+ httpTimeoutMs
6
+
7
+ constructor(params) {
8
+ this.baseUrl = params?.baseUrl
9
+ this.apiKey = params?.apiKey
10
+ this.ttl = params?.ttl
11
+ this.httpTimeoutMs = params?.httpTimeoutMs
12
+ }
13
+
14
+ static fromJson(jsonObject) {
15
+ if (jsonObject == null) return null
16
+ const result = new ApiKeyConnectionConfig()
17
+ result.baseUrl = jsonObject["baseUrl"]
18
+ result.apiKey = jsonObject["apiKey"]
19
+ result.ttl = jsonObject["ttl"]
20
+ result.httpTimeoutMs = jsonObject["httpTimeoutMs"]
21
+ return result
22
+ }
23
+
24
+ toJson() {
25
+ return {
26
+ "baseUrl": this.baseUrl,
27
+ "apiKey": this.apiKey,
28
+ "ttl": this.ttl,
29
+ "httpTimeoutMs": this.httpTimeoutMs,
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,32 @@
1
+ export class CredentialsConnectionConfig {
2
+ baseUrl
3
+ userName
4
+ password
5
+ httpTimeoutMs
6
+
7
+ constructor(params) {
8
+ this.baseUrl = params?.baseUrl
9
+ this.userName = params?.userName
10
+ this.password = params?.password
11
+ this.httpTimeoutMs = params?.httpTimeoutMs
12
+ }
13
+
14
+ static fromJson(jsonObject) {
15
+ if (jsonObject == null) return null
16
+ const result = new CredentialsConnectionConfig()
17
+ result.baseUrl = jsonObject["baseUrl"]
18
+ result.userName = jsonObject["userName"]
19
+ result.password = jsonObject["password"]
20
+ result.httpTimeoutMs = jsonObject["httpTimeoutMs"]
21
+ return result
22
+ }
23
+
24
+ toJson() {
25
+ return {
26
+ "baseUrl": this.baseUrl,
27
+ "userName": this.userName,
28
+ "password": this.password,
29
+ "httpTimeoutMs": this.httpTimeoutMs,
30
+ }
31
+ }
32
+ }
@@ -0,0 +1,20 @@
1
+ export class PrepareWorkflowConfig {
2
+ workflowId
3
+
4
+ constructor(params) {
5
+ this.workflowId = params?.workflowId
6
+ }
7
+
8
+ static fromJson(jsonObject) {
9
+ if (jsonObject == null) return null
10
+ const result = new PrepareWorkflowConfig()
11
+ result.workflowId = jsonObject["workflowId"]
12
+ return result
13
+ }
14
+
15
+ toJson() {
16
+ return {
17
+ "workflowId": this.workflowId,
18
+ }
19
+ }
20
+ }
@@ -0,0 +1,28 @@
1
+ export class SendDataConfig {
2
+ sessionId
3
+ step
4
+ data
5
+
6
+ constructor(params) {
7
+ this.sessionId = params?.sessionId
8
+ this.step = params?.step
9
+ this.data = params?.data
10
+ }
11
+
12
+ static fromJson(jsonObject) {
13
+ if (jsonObject == null) return null
14
+ const result = new SendDataConfig()
15
+ result.sessionId = jsonObject["sessionId"]
16
+ result.step = jsonObject["step"]
17
+ result.data = jsonObject["data"]
18
+ return result
19
+ }
20
+
21
+ toJson() {
22
+ return {
23
+ "sessionId": this.sessionId,
24
+ "step": this.step,
25
+ "data": this.data,
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,24 @@
1
+ export class StartSessionConfig {
2
+ workflowId
3
+ metadata
4
+
5
+ constructor(params) {
6
+ this.workflowId = params?.workflowId
7
+ this.metadata = params?.metadata
8
+ }
9
+
10
+ static fromJson(jsonObject) {
11
+ if (jsonObject == null) return null
12
+ const result = new StartSessionConfig()
13
+ result.workflowId = jsonObject["workflowId"]
14
+ result.metadata = jsonObject["metadata"]
15
+ return result
16
+ }
17
+
18
+ toJson() {
19
+ return {
20
+ "workflowId": this.workflowId,
21
+ "metadata": this.metadata,
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,24 @@
1
+ export class StartWorkflowConfig {
2
+ locale
3
+ metadata
4
+
5
+ constructor(params) {
6
+ this.locale = params?.locale
7
+ this.metadata = params?.metadata
8
+ }
9
+
10
+ static fromJson(jsonObject) {
11
+ if (jsonObject == null) return null
12
+ const result = new StartWorkflowConfig()
13
+ result.locale = jsonObject["locale"]
14
+ result.metadata = jsonObject["metadata"]
15
+ return result
16
+ }
17
+
18
+ toJson() {
19
+ return {
20
+ "locale": this.locale,
21
+ "metadata": this.metadata,
22
+ }
23
+ }
24
+ }
@@ -0,0 +1,20 @@
1
+ export class TokenConnectionConfig {
2
+ url
3
+
4
+ constructor(params) {
5
+ this.url = params?.url
6
+ }
7
+
8
+ static fromJson(jsonObject) {
9
+ if (jsonObject == null) return null
10
+ const result = new TokenConnectionConfig()
11
+ result.url = jsonObject["url"]
12
+ return result
13
+ }
14
+
15
+ toJson() {
16
+ return {
17
+ "url": this.url,
18
+ }
19
+ }
20
+ }
@@ -1,6 +1,118 @@
1
- import { exec } from './internal/bridge'
1
+ import { exec, setDidStartSessionCompletion, setDidEndSessionCompletion, setDidStartRestoreSessionCompletion, setDidContinueRemoteSessionCompletion } from './internal/bridge'
2
+
3
+ import { TokenConnectionConfig } from './config/token_connection_config'
4
+ import { CredentialsConnectionConfig } from './config/credentials_connection_config'
5
+ import { ApiKeyConnectionConfig } from './config/api_key_connection_config'
6
+ import { PrepareWorkflowConfig } from './config/prepare_workflow_config'
7
+ import { StartWorkflowConfig } from './config/start_workflow_config'
8
+ import { StartSessionConfig } from './config/start_session_config'
9
+ import { SendDataConfig } from './config/send_data_config'
10
+ import { Workflow } from './model/workflow'
11
+ import { WorkflowResult } from './model/workflow_result'
12
+ import { WorkflowStep } from './model/workflow_step'
13
+
14
+ export { TokenConnectionConfig, CredentialsConnectionConfig, ApiKeyConnectionConfig, PrepareWorkflowConfig, StartWorkflowConfig, StartSessionConfig, SendDataConfig, Workflow, WorkflowResult, WorkflowStep }
2
15
 
3
16
  export class IDV {
4
17
  static get instance() { return IDV._instance }
5
18
  static _instance = new IDV()
19
+
20
+ setListener(options) {
21
+ const value = options ?? {}
22
+ setDidStartSessionCompletion(value.didStartSession)
23
+ setDidEndSessionCompletion(value.didEndSession)
24
+ setDidStartRestoreSessionCompletion(value.didStartRestoreSession)
25
+ setDidContinueRemoteSessionCompletion(value.didContinueRemoteSession)
26
+ }
27
+
28
+ set sessionRestoreMode(val) {
29
+ exec('setSessionRestoreMode', [val])
30
+ }
31
+
32
+ async getCurrentSessionId() {
33
+ return await exec('getCurrentSessionId', [])
34
+ }
35
+
36
+ async initialize() {
37
+ const response = await exec('initialize', [])
38
+ return completionFromResponse(response)
39
+ }
40
+
41
+ async deinitialize() {
42
+ const response = await exec('deinitialize', [])
43
+ return completionFromResponse(response)
44
+ }
45
+
46
+ async configureWithToken(config) {
47
+ config = ensureInstance(config, TokenConnectionConfig)
48
+ const response = await exec('configureWithToken', [config?.toJson()])
49
+ return completionFromResponse(response, success => success?.map(item => String(item)))
50
+ }
51
+
52
+ async configureWithCredentials(config) {
53
+ config = ensureInstance(config, CredentialsConnectionConfig)
54
+ const response = await exec('configureWithCredentials', [config?.toJson()])
55
+ return completionFromResponse(response)
56
+ }
57
+
58
+ async configureWithApiKey(config) {
59
+ config = ensureInstance(config, ApiKeyConnectionConfig)
60
+ const response = await exec('configureWithApiKey', [config?.toJson()])
61
+ return completionFromResponse(response)
62
+ }
63
+
64
+ async prepareWorkflow(config) {
65
+ config = ensureInstance(config, PrepareWorkflowConfig)
66
+ const response = await exec('prepareWorkflow', [config?.toJson()])
67
+ return completionFromResponse(response, json => Workflow.fromJson(json))
68
+ }
69
+
70
+ async startWorkflow(config) {
71
+ config = ensureInstance(config, StartWorkflowConfig)
72
+ const response = await exec('startWorkflow', [config?.toJson()])
73
+ return completionFromResponse(response, json => WorkflowResult.fromJson(json))
74
+ }
75
+
76
+ async getWorkflows() {
77
+ const response = await exec('getWorkflows', [])
78
+ return completionFromResponse(response, json => {
79
+ const result = []
80
+ if (json != null) for (const item of json) {
81
+ const workflow = Workflow.fromJson(item)
82
+ if (workflow != null) result.push(workflow)
83
+ }
84
+ return result
85
+ })
86
+ }
87
+
88
+ async startSession(config) {
89
+ config = ensureInstance(config, StartSessionConfig)
90
+ const response = await exec('startSession', [config.toJson()])
91
+ return completionFromResponse(response)
92
+ }
93
+
94
+ async sendData(config) {
95
+ config = ensureInstance(config, SendDataConfig)
96
+ const response = await exec('sendData', [config.toJson()])
97
+ return completionFromResponse(response)
98
+ }
99
+ }
100
+
101
+ export const SessionRestoreMode = {
102
+ ENABLED: 0,
103
+ DISABLED: 1,
104
+ }
105
+
106
+ function completionFromResponse(response, transform) {
107
+ const jsonObject = JSON.parse(response)
108
+ let success = jsonObject['success']
109
+ const error = jsonObject['error']
110
+ if (transform != null && success != null) success = transform(success)
111
+ return [success, error]
112
+ }
113
+
114
+ function ensureInstance(value, ctor) {
115
+ if (value == null) return null
116
+ if (value instanceof ctor) return value
117
+ return new ctor(value)
6
118
  }
@@ -7,13 +7,24 @@ export async function exec(name, params) {
7
7
  return RNIDV.exec(name, params)
8
8
  }
9
9
 
10
- function _setEvent(id, completion, fromJson) {
10
+ function setEvent(id, completion, transform) {
11
11
  eventManager.removeAllListeners(id)
12
- if (completion == null) return
13
- if (fromJson == null) eventManager.addListener(id, completion)
14
- else eventManager.addListener(id, data => {
15
- data = fromJson(data)
16
- if (data !== null && typeof data[Symbol.iterator] === 'function') completion(...data)
17
- else completion(data)
18
- })
12
+ if (transform === undefined) transform = func => func
13
+ if (completion !== undefined) eventManager.addListener(id, transform(completion))
14
+ }
15
+
16
+ export function setDidStartSessionCompletion(completion) {
17
+ setEvent('didStartSessionEvent', completion)
18
+ }
19
+
20
+ export function setDidEndSessionCompletion(completion) {
21
+ setEvent('didEndSessionEvent', completion)
22
+ }
23
+
24
+ export function setDidStartRestoreSessionCompletion(completion) {
25
+ setEvent('didStartRestoreSessionEvent', completion)
26
+ }
27
+
28
+ export function setDidContinueRemoteSessionCompletion(completion) {
29
+ setEvent('didContinueRemoteSessionEvent', completion)
19
30
  }
@@ -0,0 +1,28 @@
1
+ export class Workflow {
2
+ id
3
+ name
4
+ description
5
+ version
6
+ defaultLocale
7
+
8
+ static fromJson(jsonObject) {
9
+ if (jsonObject == null) return null
10
+ const result = new Workflow()
11
+ result.id = jsonObject["id"]
12
+ result.name = jsonObject["name"]
13
+ result.description = jsonObject["description"]
14
+ result.version = jsonObject["version"]
15
+ result.defaultLocale = jsonObject["defaultLocale"]
16
+ return result
17
+ }
18
+
19
+ toJson() {
20
+ return {
21
+ "id": this.id,
22
+ "name": this.name,
23
+ "description": this.description,
24
+ "version": this.version,
25
+ "defaultLocale": this.defaultLocale,
26
+ }
27
+ }
28
+ }
@@ -0,0 +1,21 @@
1
+ import { WorkflowStep } from './workflow_step'
2
+
3
+ export class WorkflowResult {
4
+ sessionId
5
+ finalStep
6
+
7
+ static fromJson(jsonObject) {
8
+ if (jsonObject == null) return null
9
+ const result = new WorkflowResult()
10
+ result.sessionId = jsonObject["sessionId"]
11
+ result.finalStep = WorkflowStep.fromJson(jsonObject["finalStep"])
12
+ return result
13
+ }
14
+
15
+ toJson() {
16
+ return {
17
+ "sessionId": this.sessionId,
18
+ "finalStep": this.finalStep?.toJson(),
19
+ }
20
+ }
21
+ }
@@ -0,0 +1,19 @@
1
+ export class WorkflowStep {
2
+ id
3
+ name
4
+
5
+ static fromJson(jsonObject) {
6
+ if (jsonObject == null) return null
7
+ const result = new WorkflowStep()
8
+ result.id = jsonObject["id"]
9
+ result.name = jsonObject["name"]
10
+ return result
11
+ }
12
+
13
+ toJson() {
14
+ return {
15
+ "id": this.id,
16
+ "name": this.name,
17
+ }
18
+ }
19
+ }