@regulaforensics/idv 3.4.74-beta → 3.4.86-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.
@@ -8,13 +8,13 @@
8
8
  "start": "expo start"
9
9
  },
10
10
  "dependencies": {
11
- "@regulaforensics/idv": "3.4.74-beta",
11
+ "@regulaforensics/idv": "3.4.86-beta",
12
12
  "@regulaforensics/document-reader": "9.2.621",
13
- "@regulaforensics/face-sdk": "8.1.796",
13
+ "@regulaforensics/face-sdk": "8.1.816",
14
14
  "@regulaforensics/document-reader-core-fullauthrfid": "9.2.1513",
15
15
  "@regulaforensics/face-core-basic": "8.1.422",
16
- "@regulaforensics/idv-module-document-reader": "3.4.54-beta",
17
- "@regulaforensics/idv-module-face": "3.4.55-beta",
16
+ "@regulaforensics/idv-module-document-reader": "3.4.56-beta",
17
+ "@regulaforensics/idv-module-face": "3.4.57-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",
package/ios/CDVIDV.swift CHANGED
@@ -1,29 +1,3 @@
1
- var eventCallbackIds: [String: String] = [:]
2
- private var args: [Any?] = []
3
- private var this: CDVIDV?
4
-
5
- func sendEvent(_ event: String, _ data: Any? = nil) {
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)
16
- }
17
-
18
- func args<T>(_ index: Int) -> T {
19
- return args[index] as! T
20
- }
21
-
22
- func argsNullable<T>(_ index: Int) -> T? {
23
- if (args[index] is NSNull) { return nil }
24
- return args[index] as! T?
25
- }
26
-
27
1
  @objc(CDVIDV)
28
2
  class CDVIDV: CDVPlugin {
29
3
  @objc(exec:)
@@ -41,6 +15,24 @@ class CDVIDV: CDVPlugin {
41
15
  }
42
16
  }
43
17
 
18
+ var this: CDVIDV?
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
+
44
36
  let rootViewController: () -> UIViewController? = {
45
37
  return UIApplication.shared.connectedScenes
46
38
  .compactMap { $0 as? UIWindowScene }
package/ios/Main.swift CHANGED
@@ -6,7 +6,7 @@ let didStartRestoreSessionEvent = "didStartRestoreSessionEvent"
6
6
  let didContinueRemoteSessionEvent = "didContinueRemoteSessionEvent"
7
7
 
8
8
  func methodCall(_ method: String, _ callback: @escaping Callback) {
9
- switch (method) {
9
+ switch method {
10
10
  case("setSessionRestoreMode"): IDV.shared.sessionRestoreMode = SessionRestoreMode(rawValue: args(0))!
11
11
  case("getCurrentSessionId"): callback(IDV.shared.currentSessionId)
12
12
  case("initialize"): initialize(callback)
package/ios/RNIDV.m CHANGED
@@ -4,7 +4,7 @@
4
4
  @interface RCT_EXTERN_MODULE(RNIDV, RCTEventEmitter)
5
5
 
6
6
  RCT_EXTERN_METHOD(exec: (NSString*)method
7
- args:(NSArray*)args
7
+ newArgs:(NSArray*)newArgs
8
8
  resolve:(RCTPromiseResolveBlock)resolve
9
9
  reject:(RCTPromiseRejectBlock)reject)
10
10
 
package/ios/RNIDV.swift CHANGED
@@ -1,26 +1,5 @@
1
1
  import React
2
2
 
3
- func sendEvent(_ event: String, _ data: Any? = nil) {
4
- guard let plugin = this, hasListeners else { return }
5
- DispatchQueue.main.async {
6
- plugin.sendEvent(withName: event, body: data.toSendable())
7
- }
8
- }
9
-
10
- func args<T>(_ index: Int) -> T {
11
- return mArgs[index] as! T
12
- }
13
-
14
- func argsNullable<T>(_ index: Int) -> T? {
15
- if (mArgs[index] is NSNull) { return nil }
16
- return mArgs[index] as! T?
17
- }
18
-
19
- private var firedCallbacks: [RCTResponseSenderBlock] = []
20
- private var hasListeners: Bool = false
21
- private var this: RNIDV?
22
- private var mArgs: [Any?] = []
23
-
24
3
  @objc(RNIDV)
25
4
  public class RNIDV: RCTEventEmitter {
26
5
  override public func startObserving() { hasListeners = true }
@@ -33,9 +12,9 @@ public class RNIDV: RCTEventEmitter {
33
12
  }
34
13
 
35
14
  @objc
36
- func exec(_ method: String, args: [Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
15
+ func exec(_ method: String, newArgs: [Any], resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) {
37
16
  this = self
38
- mArgs = args
17
+ args = newArgs
39
18
  methodCall(method, { data in
40
19
  if firedCallbacks.contains(where: { ($0 as AnyObject) === (resolve as AnyObject) }) { return }
41
20
  firedCallbacks.append(resolve)
@@ -44,4 +23,15 @@ public class RNIDV: RCTEventEmitter {
44
23
  }
45
24
  }
46
25
 
26
+ private var firedCallbacks: [RCTResponseSenderBlock] = []
27
+ private var hasListeners: Bool = false
28
+ private var this: RNIDV?
29
+
30
+ func sendEvent(_ event: String, _ data: Any? = nil) {
31
+ guard let plugin = this, hasListeners else { return }
32
+ DispatchQueue.main.async {
33
+ plugin.sendEvent(withName: event, body: data.toSendable())
34
+ }
35
+ }
36
+
47
37
  let rootViewController: () -> UIViewController? = { return RCTPresentedViewController() }
package/ios/Utils.swift CHANGED
@@ -1,5 +1,15 @@
1
1
  public typealias Callback = (Any?) -> Void
2
2
 
3
+ var args: [Any?] = []
4
+ func args<T>(_ index: Int) -> T {
5
+ return args[index] as! T
6
+ }
7
+
8
+ func argsNullable<T>(_ index: Int) -> T? {
9
+ if args[index] is NSNull { return nil }
10
+ return args[index] as! T?
11
+ }
12
+
3
13
  extension Any? {
4
14
  func toSendable() -> Any {
5
15
  guard let self else { return NSNull() }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@regulaforensics/idv",
3
- "version": "3.4.74-beta",
3
+ "version": "3.4.86-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.4.74-beta" xmlns="http://apache.org/cordova/ns/plugins/1.0">
2
+ <plugin id="@regulaforensics/idv" version="3.4.86-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>
@@ -26,7 +26,7 @@
26
26
  <source url="https://github.com/CocoaPods/Specs.git" />
27
27
  </config>
28
28
  <pods>
29
- <pod name="IDVSDK" spec="3.3.1715" />
29
+ <pod name="IDVSDK" spec="3.4.1784" />
30
30
  </pods>
31
31
  </podspec>
32
32
  </platform>
@@ -13,7 +13,7 @@
13
13
  },
14
14
  "..": {
15
15
  "name": "@regulaforensics/idv",
16
- "version": "3.4.74-beta",
16
+ "version": "3.4.86-beta",
17
17
  "dev": true,
18
18
  "license": "commercial"
19
19
  },
@@ -1,4 +1,4 @@
1
- import { exec, setDidStartSessionCompletion, setDidEndSessionCompletion, setDidStartRestoreSessionCompletion, setDidContinueRemoteSessionCompletion } from './internal/bridge'
1
+ import { exec, serializeInterface, setDidStartSessionCompletion, setDidEndSessionCompletion, setDidStartRestoreSessionCompletion, setDidContinueRemoteSessionCompletion } from './internal/bridge'
2
2
 
3
3
  import { TokenConnectionConfig } from './config/token_connection_config'
4
4
  import { CredentialsConnectionConfig } from './config/credentials_connection_config'
@@ -44,32 +44,27 @@ export class IDV {
44
44
  }
45
45
 
46
46
  async configureWithToken(config) {
47
- config = ensureInstance(config, TokenConnectionConfig)
48
- const response = await exec('configureWithToken', [config?.toJson()])
47
+ const response = await exec('configureWithToken', [serializeInterface(config, TokenConnectionConfig)])
49
48
  return completionFromResponse(response, success => success?.map(item => String(item)))
50
49
  }
51
50
 
52
51
  async configureWithCredentials(config) {
53
- config = ensureInstance(config, CredentialsConnectionConfig)
54
- const response = await exec('configureWithCredentials', [config?.toJson()])
52
+ const response = await exec('configureWithCredentials', [serializeInterface(config, CredentialsConnectionConfig)])
55
53
  return completionFromResponse(response)
56
54
  }
57
55
 
58
56
  async configureWithApiKey(config) {
59
- config = ensureInstance(config, ApiKeyConnectionConfig)
60
- const response = await exec('configureWithApiKey', [config?.toJson()])
57
+ const response = await exec('configureWithApiKey', [serializeInterface(config, ApiKeyConnectionConfig)])
61
58
  return completionFromResponse(response)
62
59
  }
63
60
 
64
61
  async prepareWorkflow(config) {
65
- config = ensureInstance(config, PrepareWorkflowConfig)
66
- const response = await exec('prepareWorkflow', [config?.toJson()])
62
+ const response = await exec('prepareWorkflow', [serializeInterface(config, PrepareWorkflowConfig)])
67
63
  return completionFromResponse(response, json => Workflow.fromJson(json))
68
64
  }
69
65
 
70
66
  async startWorkflow(config) {
71
- config = ensureInstance(config, StartWorkflowConfig)
72
- const response = await exec('startWorkflow', [config?.toJson()])
67
+ const response = await exec('startWorkflow', [serializeInterface(config, StartWorkflowConfig)])
73
68
  return completionFromResponse(response, json => WorkflowResult.fromJson(json))
74
69
  }
75
70
 
@@ -86,14 +81,12 @@ export class IDV {
86
81
  }
87
82
 
88
83
  async startSession(config) {
89
- config = ensureInstance(config, StartSessionConfig)
90
- const response = await exec('startSession', [config.toJson()])
84
+ const response = await exec('startSession', [serializeInterface(config, StartSessionConfig)])
91
85
  return completionFromResponse(response)
92
86
  }
93
87
 
94
88
  async sendData(config) {
95
- config = ensureInstance(config, SendDataConfig)
96
- const response = await exec('sendData', [config.toJson()])
89
+ const response = await exec('sendData', [serializeInterface(config, SendDataConfig)])
97
90
  return completionFromResponse(response)
98
91
  }
99
92
  }
@@ -110,9 +103,3 @@ function completionFromResponse(response, transform) {
110
103
  if (transform != null && success != null) success = transform(success)
111
104
  return [success, error]
112
105
  }
113
-
114
- function ensureInstance(value, ctor) {
115
- if (value == null) return null
116
- if (value instanceof ctor) return value
117
- return new ctor(value)
118
- }
@@ -7,6 +7,12 @@ export async function exec(name, params) {
7
7
  return RNIDV.exec(name, params)
8
8
  }
9
9
 
10
+ export function serializeInterface(value, ctor) {
11
+ if (value == null) return null
12
+ if (value instanceof ctor) return value.toJson()
13
+ return (new ctor(value)).toJson()
14
+ }
15
+
10
16
  function setEvent(id, completion, transform) {
11
17
  eventManager.removeAllListeners(id)
12
18
  if (transform === undefined) transform = func => func
package/www/cordova.js CHANGED
@@ -289,6 +289,7 @@ class TokenConnectionConfig {
289
289
  __webpack_require__.r(__webpack_exports__);
290
290
  /* harmony export */ __webpack_require__.d(__webpack_exports__, {
291
291
  /* harmony export */ exec: () => (/* binding */ exec),
292
+ /* harmony export */ serializeInterface: () => (/* binding */ serializeInterface),
292
293
  /* harmony export */ setDidContinueRemoteSessionCompletion: () => (/* binding */ setDidContinueRemoteSessionCompletion),
293
294
  /* harmony export */ setDidEndSessionCompletion: () => (/* binding */ setDidEndSessionCompletion),
294
295
  /* harmony export */ setDidStartRestoreSessionCompletion: () => (/* binding */ setDidStartRestoreSessionCompletion),
@@ -304,6 +305,12 @@ async function exec(name, params) {
304
305
  return RNIDV.exec(name, params)
305
306
  }
306
307
 
308
+ function serializeInterface(value, ctor) {
309
+ if (value == null) return null
310
+ if (value instanceof ctor) return value.toJson()
311
+ return (new ctor(value)).toJson()
312
+ }
313
+
307
314
  function setEvent(id, completion, transform) {
308
315
  eventManager.removeAllListeners(id)
309
316
  if (transform === undefined) transform = func => func
@@ -483,12 +490,6 @@ class WorkflowStep {
483
490
  /******/ if (cachedModule !== undefined) {
484
491
  /******/ return cachedModule.exports;
485
492
  /******/ }
486
- /******/ // Check if module exists (development only)
487
- /******/ if (__webpack_modules__[moduleId] === undefined) {
488
- /******/ var e = new Error("Cannot find module '" + moduleId + "'");
489
- /******/ e.code = 'MODULE_NOT_FOUND';
490
- /******/ throw e;
491
- /******/ }
492
493
  /******/ // Create a new module (and put it into the cache)
493
494
  /******/ var module = __webpack_module_cache__[moduleId] = {
494
495
  /******/ // no module.id needed
@@ -497,6 +498,12 @@ class WorkflowStep {
497
498
  /******/ };
498
499
  /******/
499
500
  /******/ // Execute the module function
501
+ /******/ if (!(moduleId in __webpack_modules__)) {
502
+ /******/ delete __webpack_module_cache__[moduleId];
503
+ /******/ var e = new Error("Cannot find module '" + moduleId + "'");
504
+ /******/ e.code = 'MODULE_NOT_FOUND';
505
+ /******/ throw e;
506
+ /******/ }
500
507
  /******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
501
508
  /******/
502
509
  /******/ // Return the exports of the module
@@ -611,32 +618,27 @@ class IDV {
611
618
  }
612
619
 
613
620
  async configureWithToken(config) {
614
- config = ensureInstance(config, _config_token_connection_config__WEBPACK_IMPORTED_MODULE_1__.TokenConnectionConfig)
615
- const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('configureWithToken', [config?.toJson()])
621
+ const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('configureWithToken', [(0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.serializeInterface)(config, _config_token_connection_config__WEBPACK_IMPORTED_MODULE_1__.TokenConnectionConfig)])
616
622
  return completionFromResponse(response, success => success?.map(item => String(item)))
617
623
  }
618
624
 
619
625
  async configureWithCredentials(config) {
620
- config = ensureInstance(config, _config_credentials_connection_config__WEBPACK_IMPORTED_MODULE_2__.CredentialsConnectionConfig)
621
- const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('configureWithCredentials', [config?.toJson()])
626
+ const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('configureWithCredentials', [(0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.serializeInterface)(config, _config_credentials_connection_config__WEBPACK_IMPORTED_MODULE_2__.CredentialsConnectionConfig)])
622
627
  return completionFromResponse(response)
623
628
  }
624
629
 
625
630
  async configureWithApiKey(config) {
626
- config = ensureInstance(config, _config_api_key_connection_config__WEBPACK_IMPORTED_MODULE_3__.ApiKeyConnectionConfig)
627
- const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('configureWithApiKey', [config?.toJson()])
631
+ const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('configureWithApiKey', [(0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.serializeInterface)(config, _config_api_key_connection_config__WEBPACK_IMPORTED_MODULE_3__.ApiKeyConnectionConfig)])
628
632
  return completionFromResponse(response)
629
633
  }
630
634
 
631
635
  async prepareWorkflow(config) {
632
- config = ensureInstance(config, _config_prepare_workflow_config__WEBPACK_IMPORTED_MODULE_4__.PrepareWorkflowConfig)
633
- const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('prepareWorkflow', [config?.toJson()])
636
+ const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('prepareWorkflow', [(0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.serializeInterface)(config, _config_prepare_workflow_config__WEBPACK_IMPORTED_MODULE_4__.PrepareWorkflowConfig)])
634
637
  return completionFromResponse(response, json => _model_workflow__WEBPACK_IMPORTED_MODULE_8__.Workflow.fromJson(json))
635
638
  }
636
639
 
637
640
  async startWorkflow(config) {
638
- config = ensureInstance(config, _config_start_workflow_config__WEBPACK_IMPORTED_MODULE_5__.StartWorkflowConfig)
639
- const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('startWorkflow', [config?.toJson()])
641
+ const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('startWorkflow', [(0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.serializeInterface)(config, _config_start_workflow_config__WEBPACK_IMPORTED_MODULE_5__.StartWorkflowConfig)])
640
642
  return completionFromResponse(response, json => _model_workflow_result__WEBPACK_IMPORTED_MODULE_9__.WorkflowResult.fromJson(json))
641
643
  }
642
644
 
@@ -653,14 +655,12 @@ class IDV {
653
655
  }
654
656
 
655
657
  async startSession(config) {
656
- config = ensureInstance(config, _config_start_session_config__WEBPACK_IMPORTED_MODULE_6__.StartSessionConfig)
657
- const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('startSession', [config.toJson()])
658
+ const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('startSession', [(0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.serializeInterface)(config, _config_start_session_config__WEBPACK_IMPORTED_MODULE_6__.StartSessionConfig)])
658
659
  return completionFromResponse(response)
659
660
  }
660
661
 
661
662
  async sendData(config) {
662
- config = ensureInstance(config, _config_send_data_config__WEBPACK_IMPORTED_MODULE_7__.SendDataConfig)
663
- const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('sendData', [config.toJson()])
663
+ const response = await (0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.exec)('sendData', [(0,_internal_bridge__WEBPACK_IMPORTED_MODULE_0__.serializeInterface)(config, _config_send_data_config__WEBPACK_IMPORTED_MODULE_7__.SendDataConfig)])
664
664
  return completionFromResponse(response)
665
665
  }
666
666
  }
@@ -678,12 +678,6 @@ function completionFromResponse(response, transform) {
678
678
  return [success, error]
679
679
  }
680
680
 
681
- function ensureInstance(value, ctor) {
682
- if (value == null) return null
683
- if (value instanceof ctor) return value
684
- return new ctor(value)
685
- }
686
-
687
681
  })();
688
682
 
689
683
  var __webpack_export_target__ = exports;
@@ -1,4 +1,4 @@
1
- import { exec, setDidStartSessionCompletion, setDidEndSessionCompletion, setDidStartRestoreSessionCompletion, setDidContinueRemoteSessionCompletion } from './internal/bridge'
1
+ import { exec, serializeInterface, setDidStartSessionCompletion, setDidEndSessionCompletion, setDidStartRestoreSessionCompletion, setDidContinueRemoteSessionCompletion } from './internal/bridge'
2
2
 
3
3
  import { TokenConnectionConfig } from './config/token_connection_config'
4
4
  import { CredentialsConnectionConfig } from './config/credentials_connection_config'
@@ -44,32 +44,27 @@ export class IDV {
44
44
  }
45
45
 
46
46
  async configureWithToken(config) {
47
- config = ensureInstance(config, TokenConnectionConfig)
48
- const response = await exec('configureWithToken', [config?.toJson()])
47
+ const response = await exec('configureWithToken', [serializeInterface(config, TokenConnectionConfig)])
49
48
  return completionFromResponse(response, success => success?.map(item => String(item)))
50
49
  }
51
50
 
52
51
  async configureWithCredentials(config) {
53
- config = ensureInstance(config, CredentialsConnectionConfig)
54
- const response = await exec('configureWithCredentials', [config?.toJson()])
52
+ const response = await exec('configureWithCredentials', [serializeInterface(config, CredentialsConnectionConfig)])
55
53
  return completionFromResponse(response)
56
54
  }
57
55
 
58
56
  async configureWithApiKey(config) {
59
- config = ensureInstance(config, ApiKeyConnectionConfig)
60
- const response = await exec('configureWithApiKey', [config?.toJson()])
57
+ const response = await exec('configureWithApiKey', [serializeInterface(config, ApiKeyConnectionConfig)])
61
58
  return completionFromResponse(response)
62
59
  }
63
60
 
64
61
  async prepareWorkflow(config) {
65
- config = ensureInstance(config, PrepareWorkflowConfig)
66
- const response = await exec('prepareWorkflow', [config?.toJson()])
62
+ const response = await exec('prepareWorkflow', [serializeInterface(config, PrepareWorkflowConfig)])
67
63
  return completionFromResponse(response, json => Workflow.fromJson(json))
68
64
  }
69
65
 
70
66
  async startWorkflow(config) {
71
- config = ensureInstance(config, StartWorkflowConfig)
72
- const response = await exec('startWorkflow', [config?.toJson()])
67
+ const response = await exec('startWorkflow', [serializeInterface(config, StartWorkflowConfig)])
73
68
  return completionFromResponse(response, json => WorkflowResult.fromJson(json))
74
69
  }
75
70
 
@@ -86,14 +81,12 @@ export class IDV {
86
81
  }
87
82
 
88
83
  async startSession(config) {
89
- config = ensureInstance(config, StartSessionConfig)
90
- const response = await exec('startSession', [config.toJson()])
84
+ const response = await exec('startSession', [serializeInterface(config, StartSessionConfig)])
91
85
  return completionFromResponse(response)
92
86
  }
93
87
 
94
88
  async sendData(config) {
95
- config = ensureInstance(config, SendDataConfig)
96
- const response = await exec('sendData', [config.toJson()])
89
+ const response = await exec('sendData', [serializeInterface(config, SendDataConfig)])
97
90
  return completionFromResponse(response)
98
91
  }
99
92
  }
@@ -110,9 +103,3 @@ function completionFromResponse(response, transform) {
110
103
  if (transform != null && success != null) success = transform(success)
111
104
  return [success, error]
112
105
  }
113
-
114
- function ensureInstance(value, ctor) {
115
- if (value == null) return null
116
- if (value instanceof ctor) return value
117
- return new ctor(value)
118
- }
@@ -7,6 +7,12 @@ export async function exec(name, params) {
7
7
  return RNIDV.exec(name, params)
8
8
  }
9
9
 
10
+ export function serializeInterface(value, ctor) {
11
+ if (value == null) return null
12
+ if (value instanceof ctor) return value.toJson()
13
+ return (new ctor(value)).toJson()
14
+ }
15
+
10
16
  function setEvent(id, completion, transform) {
11
17
  eventManager.removeAllListeners(id)
12
18
  if (transform === undefined) transform = func => func