@regulaforensics/idv 3.2.26-beta → 3.2.59-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/README.md +2 -8
  2. package/RNIDV.podspec +2 -2
  3. package/android/build.gradle +1 -10
  4. package/android/cordova.gradle +1 -1
  5. package/examples/capacitor/android/build.gradle +1 -1
  6. package/examples/capacitor/package-lock.json +3350 -0
  7. package/examples/capacitor/package.json +4 -4
  8. package/examples/capacitor/src/main.html +8 -29
  9. package/examples/capacitor/src/main.tsx +115 -1
  10. package/examples/ionic/README.md +2 -2
  11. package/examples/ionic/config.xml +1 -0
  12. package/examples/ionic/package-lock.json +14261 -0
  13. package/examples/ionic/package.json +7 -7
  14. package/examples/ionic/src/main.html +8 -29
  15. package/examples/ionic/src/main.tsx +115 -1
  16. package/examples/react_native/README.md +2 -2
  17. package/examples/react_native/package-lock.json +8996 -0
  18. package/examples/react_native/package.json +4 -4
  19. package/examples/react_native/scripts/setup.sh +3 -0
  20. package/examples/react_native/src/main.html +8 -29
  21. package/examples/react_native/src/main.tsx +115 -1
  22. package/ios/CVDIDV.swift +6 -50
  23. package/ios/RNIDV.swift +4 -52
  24. package/package.json +1 -1
  25. package/plugin.xml +5 -4
  26. package/test/json.tsx +40 -0
  27. package/test/package-lock.json +1 -1
  28. package/test/test.tsx +12 -2
  29. package/www/capacitor/config/api_key_connection_config.js +32 -0
  30. package/www/capacitor/config/credentials_connection_config.js +32 -0
  31. package/www/capacitor/config/prepare_workflow_config.js +20 -0
  32. package/www/capacitor/config/start_workflow_config.js +24 -0
  33. package/www/capacitor/config/token_connection_config.js +20 -0
  34. package/www/capacitor/index.js +105 -1
  35. package/www/capacitor/internal/bridge.js +19 -8
  36. package/www/capacitor/model/workflow.js +28 -0
  37. package/www/capacitor/model/workflow_result.js +21 -0
  38. package/www/capacitor/model/workflow_step.js +19 -0
  39. package/www/cordova.js +455 -10
  40. package/www/react-native/config/api_key_connection_config.js +32 -0
  41. package/www/react-native/config/credentials_connection_config.js +32 -0
  42. package/www/react-native/config/prepare_workflow_config.js +20 -0
  43. package/www/react-native/config/start_workflow_config.js +24 -0
  44. package/www/react-native/config/token_connection_config.js +20 -0
  45. package/www/react-native/index.js +105 -1
  46. package/www/react-native/internal/bridge.js +19 -8
  47. package/www/react-native/model/workflow.js +28 -0
  48. package/www/react-native/model/workflow_result.js +21 -0
  49. package/www/react-native/model/workflow_step.js +19 -0
  50. package/www/types/config/api_key_connection_config.d.ts +6 -0
  51. package/www/types/config/credentials_connection_config.d.ts +6 -0
  52. package/www/types/config/prepare_workflow_config.d.ts +3 -0
  53. package/www/types/config/start_workflow_config.d.ts +4 -0
  54. package/www/types/config/token_connection_config.d.ts +3 -0
  55. package/www/types/index.d.ts +50 -0
  56. package/www/types/model/workflow.d.ts +9 -0
  57. package/www/types/model/workflow_result.d.ts +8 -0
  58. package/www/types/model/workflow_step.d.ts +6 -0
  59. package/ios/FlutterIDVPlugin.swift +0 -72
@@ -1,6 +1,110 @@
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 { Workflow } from './model/workflow'
9
+ import { WorkflowResult } from './model/workflow_result'
10
+
11
+ export { TokenConnectionConfig }
12
+ export { CredentialsConnectionConfig }
13
+ export { ApiKeyConnectionConfig }
14
+ export { PrepareWorkflowConfig }
15
+ export { StartWorkflowConfig }
16
+ export { Workflow }
17
+ export { WorkflowResult }
18
+ export { WorkflowStep } from './model/workflow_step'
2
19
 
3
20
  export class IDV {
4
21
  static get instance() { return IDV._instance }
5
22
  static _instance = new IDV()
23
+
24
+ setListener(options) {
25
+ const value = options ?? {}
26
+ setDidStartSessionCompletion(value.didStartSession)
27
+ setDidEndSessionCompletion(value.didEndSession)
28
+ setDidStartRestoreSessionCompletion(value.didStartRestoreSession)
29
+ setDidContinueRemoteSessionCompletion(value.didContinueRemoteSession)
30
+ }
31
+
32
+ set sessionRestoreMode(val) {
33
+ exec('setSessionRestoreMode', [val])
34
+ }
35
+
36
+ async getCurrentSessionId() {
37
+ return await exec('getCurrentSessionId', [])
38
+ }
39
+
40
+ async initialize() {
41
+ const response = await exec('initialize', [])
42
+ return completionFromResponse(response)
43
+ }
44
+
45
+ async deinitialize() {
46
+ const response = await exec('deinitialize', [])
47
+ return completionFromResponse(response)
48
+ }
49
+
50
+ async configureWithToken(config) {
51
+ config = ensureInstance(config, TokenConnectionConfig)
52
+ const response = await exec('configureWithToken', [config?.toJson()])
53
+ return completionFromResponse(response, success => success?.map(item => String(item)))
54
+ }
55
+
56
+ async configureWithCredentials(config) {
57
+ config = ensureInstance(config, CredentialsConnectionConfig)
58
+ const response = await exec('configureWithCredentials', [config?.toJson()])
59
+ return completionFromResponse(response)
60
+ }
61
+
62
+ async configureWithApiKey(config) {
63
+ config = ensureInstance(config, ApiKeyConnectionConfig)
64
+ const response = await exec('configureWithApiKey', [config?.toJson()])
65
+ return completionFromResponse(response)
66
+ }
67
+
68
+ async prepareWorkflow(config) {
69
+ config = ensureInstance(config, PrepareWorkflowConfig)
70
+ const response = await exec('prepareWorkflow', [config?.toJson()])
71
+ return completionFromResponse(response, json => Workflow.fromJson(json))
72
+ }
73
+
74
+ async startWorkflow(config) {
75
+ config = ensureInstance(config, StartWorkflowConfig)
76
+ const response = await exec('startWorkflow', [config?.toJson()])
77
+ return completionFromResponse(response, json => WorkflowResult.fromJson(json))
78
+ }
79
+
80
+ async getWorkflows() {
81
+ const response = await exec('getWorkflows', [])
82
+ return completionFromResponse(response, json => {
83
+ const result = []
84
+ if (json != null) for (const item of json) {
85
+ const workflow = Workflow.fromJson(item)
86
+ if (workflow != null) result.push(workflow)
87
+ }
88
+ return result
89
+ })
90
+ }
91
+ }
92
+
93
+ export const SessionRestoreMode = {
94
+ ENABLED: 0,
95
+ DISABLED: 1,
96
+ }
97
+
98
+ function completionFromResponse(response, transform) {
99
+ const jsonObject = JSON.parse(response)
100
+ let success = jsonObject['success']
101
+ const error = jsonObject['error']
102
+ if (transform != null && success != null) success = transform(success)
103
+ return [success, error]
104
+ }
105
+
106
+ function ensureInstance(value, ctor) {
107
+ if (value == null) return null
108
+ if (value instanceof ctor) return value
109
+ return new ctor(value)
6
110
  }
@@ -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
+ }