@sumsub/cordova-idensic-mobile-sdk-plugin 1.20.3 → 1.23.0

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.
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("cordova/exec")):"function"==typeof define&&define.amd?define(["cordova/exec"],t):"object"==typeof exports?exports.SNSMobileSDK=t(require("cordova/exec")):e.SNSMobileSDK=t(e["cordova/exec"])}(window,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=0)}([function(e,t,n){const r=n(1),o="SNSMobileSdkCordovaPlugin",i={onStatusChanged:null,onEvent:null,onActionResult:"onActionResultCompleted"};var s=null;function a(e){this.sdkConf=e,this.sdkConf.settings={appFrameworkName:"cordova"}}function l(e,t){return this.apiUrl=e,this.flowName=t,this.debug=!1,this.handlers={},this.applicantConf={},this}a.prototype.dismiss=function(){r(e=>{},e=>{},o,"dismiss",[])},a.prototype.sendEvent=function(e,t){var n=this.sdkConf.handlers[e];if(n){var s=i[e];if(s){var a=function(e,t){r(e=>{},e=>{},o,s,[{error:e,result:t}])};n(t).then(e=>{a(null,e)}).catch(e=>{a(e||new Error("rejected"),null)})}else n(t)}},a.prototype.getNewAccessToken=function(){var e=function(e){r(e=>{},e=>{},o,"setNewAccessToken",[e])};this.sdkConf.tokenExpirationHandler().then(t=>{e(t)}).catch(t=>{console.error(t instanceof Error?t.message:t),e(null)})},a.prototype.launch=function(){let e=this;return console.log("InSumSub",JSON.stringify(this.sdkConf)),new Promise((t,n)=>{s?n(new Error("Aborted since another instance is in use!")):e.sdkConf.accessToken?e.flowName&&!e.sdkConf.apiUrl?n(new Error("API URL is required")):(s=e,r(e=>{s=null,console.log("Promise SumSub Result",JSON.stringify(e)),t(e)},e=>{s=null,console.log("Promise SumSub Error",JSON.stringify(e)),n(e)},o,"launchSNSMobileSDK",[e.sdkConf])):n(new Error("Access token is required"))})},l.prototype.withAccessToken=function(e,t){if(this.accessToken=e,!t||"function"!=typeof t)throw new Error('Invalid parameter, "expirationHandler" must be a function');return this.tokenExpirationHandler=t,this},l.prototype.withHandlers=function(e){if(!e||"object"!=typeof e)throw new Error('Invalid parameter, "withHandlers" expects a hash');return Object.keys(i).forEach(t=>{var n=e[t];if(n){if("function"!=typeof n)throw new Error('Invalid handler, "'+t+'" must be a function');this.handlers[t]=n}}),this},l.prototype.withDebug=function(e){if("boolean"!=typeof e)throw new Error('Invalid parameter, "withDebug" expects a boolean');return this.debug=e,this},l.prototype.withAnalyticsEnabled=function(e){if("boolean"!=typeof e)throw new Error('Invalid parameter, "withAnalyticsEnabled" expects a boolean');return this.isAnalyticsEnabled=e,this},l.prototype.withLocale=function(e){if("string"!=typeof e)throw new Error('Invalid parameter, "locale" must be a string');return this.locale=e,this},l.prototype.withSupportEmail=function(e){if("string"!=typeof e)throw new Error('Invalid parameter, "supportEmail" must be a string');return this.supportEmail=e,this},l.prototype.withApplicantConf=function(e){if(!e||"object"!=typeof e)throw new Error('Invalid parameter, "withApplicantConf" expects a hash');return this.applicantConf=e,this},l.prototype.withStrings=function(e){if(!e||"object"!=typeof e)throw new Error('Invalid parameter, "withStrings" expects a hash');return this.strings=e,this},l.prototype.withTheme=function(e){if(!e||"object"!=typeof e)throw new Error('Invalid parameter, "withTheme" expects a hash');return this.theme=e,this},l.prototype.withBaseUrl=function(e){if("string"!=typeof e)throw new Error('Invalid parameter, "baseUrl" must be a string');return this.apiUrl=e,this},l.prototype.build=function(){var e={};return Object.keys(this.handlers).forEach(t=>{e[t]=!0}),new a({apiUrl:this.apiUrl,flowName:this.flowName,accessToken:this.accessToken,tokenExpirationHandler:this.tokenExpirationHandler,handlers:this.handlers,hasHandlers:e,locale:this.locale,supportEmail:this.supportEmail,applicantConf:this.applicantConf,theme:this.theme,strings:this.strings,isAnalyticsEnabled:this.isAnalyticsEnabled,debug:this.debug})},e.exports={init:function(e,t){return(new l).withAccessToken(e,t)},Builder:function(e,t){return new l(e,t)},getNewAccessToken:function(){s&&s.getNewAccessToken()},sendEvent:function(e,t){s&&s.sendEvent(e,t)},reset:function(){s=null}}},function(t,n){t.exports=e}])}));
1
+ !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("cordova/exec")):"function"==typeof define&&define.amd?define(["cordova/exec"],t):"object"==typeof exports?exports.SNSMobileSDK=t(require("cordova/exec")):e.SNSMobileSDK=t(e["cordova/exec"])}(window,(function(e){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="/",n(n.s=0)}([function(e,t,n){const r=n(1),o="SNSMobileSdkCordovaPlugin",i={onStatusChanged:null,onEvent:null,onActionResult:"onActionResultCompleted"};var s=null;function a(e){this.sdkConf=e,this.sdkConf.settings.appFrameworkName="cordova"}function c(){return this.debug=!1,this.handlers={},this.applicantConf={},this.preferredDocumentDefinitions={},this.autoCloseOnApprove=3,this.settings={},this.disableMLKit=!1,this}a.prototype.dismiss=function(){r(e=>{},e=>{},o,"dismiss",[])},a.prototype.sendEvent=function(e,t){var n=this.sdkConf.handlers[e];if(n){var s=i[e];if(s){var a=function(e,t){r(e=>{},e=>{},o,s,[{error:e,result:t}])};n(t).then(e=>{a(null,e)}).catch(e=>{a(e||new Error("rejected"),null)})}else n(t)}},a.prototype.getNewAccessToken=function(){var e=function(e){r(e=>{},e=>{},o,"setNewAccessToken",[e])};this.sdkConf.tokenExpirationHandler().then(t=>{e(t)}).catch(t=>{console.error(t instanceof Error?t.message:t),e(null)})},a.prototype.launch=function(){let e=this;return console.log("InSumSub",JSON.stringify(this.sdkConf)),new Promise((t,n)=>{s?n(new Error("Aborted since another instance is in use!")):e.sdkConf.accessToken?(s=e,r(e=>{s=null,console.log("Promise SumSub Result",JSON.stringify(e)),t(e)},e=>{s=null,console.log("Promise SumSub Error",JSON.stringify(e)),n(e)},o,"launchSNSMobileSDK",[e.sdkConf])):n(new Error("Access token is required"))})},c.prototype.withAccessToken=function(e,t){if(this.accessToken=e,!t||"function"!=typeof t)throw new Error('Invalid parameter, "expirationHandler" must be a function');return this.tokenExpirationHandler=t,this},c.prototype.withHandlers=function(e){if(!e||"object"!=typeof e)throw new Error('Invalid parameter, "withHandlers" expects a hash');return Object.keys(i).forEach(t=>{var n=e[t];if(n){if("function"!=typeof n)throw new Error('Invalid handler, "'+t+'" must be a function');this.handlers[t]=n}}),this},c.prototype.withDebug=function(e){if("boolean"!=typeof e)throw new Error('Invalid parameter, "withDebug" expects a boolean');return this.debug=e,this},c.prototype.withAnalyticsEnabled=function(e){if("boolean"!=typeof e)throw new Error('Invalid parameter, "withAnalyticsEnabled" expects a boolean');return this.isAnalyticsEnabled=e,this},c.prototype.withLocale=function(e){if("string"!=typeof e)throw new Error('Invalid parameter, "locale" must be a string');return this.locale=e,this},c.prototype.withApplicantConf=function(e){if(!e||"object"!=typeof e)throw new Error('Invalid parameter, "withApplicantConf" expects a hash');return this.applicantConf=e,this},c.prototype.withPreferredDocumentDefinitions=function(e){if(!e||"object"!=typeof e)throw new Error('Invalid parameter, "withPreferredDocumentDefinitions" expects a hash');return this.preferredDocumentDefinitions=e,this},c.prototype.withSettings=function(e){if(!e||"object"!=typeof e)throw new Error('Invalid parameter, "withSettings" expects a hash');return this.settings=e,this},c.prototype.withStrings=function(e){if(!e||"object"!=typeof e)throw new Error('Invalid parameter, "withStrings" expects a hash');return this.strings=e,this},c.prototype.withTheme=function(e){if(!e||"object"!=typeof e)throw new Error('Invalid parameter, "withTheme" expects a hash');return this.theme=e,this},c.prototype.withBaseUrl=function(e){if("string"!=typeof e)throw new Error('Invalid parameter, "baseUrl" must be a string');return this.apiUrl=e,this},c.prototype.withAutoCloseOnApprove=function(e){if("number"!=typeof e)throw new Error('Invalid parameter, "autoCloseOnApprove" expects a number');return this.autoCloseOnApprove=e,this},c.prototype.withDisableMLKit=function(e){if("boolean"!=typeof e)throw new Error('Invalid parameter, "withDisableMLKit" expects a boolean');return this.disableMLKit=e,this},c.prototype.build=function(){var e={};return Object.keys(this.handlers).forEach(t=>{e[t]=!0}),new a({apiUrl:this.apiUrl,accessToken:this.accessToken,tokenExpirationHandler:this.tokenExpirationHandler,handlers:this.handlers,hasHandlers:e,locale:this.locale,applicantConf:this.applicantConf,preferredDocumentDefinitions:this.preferredDocumentDefinitions,settings:this.settings,theme:this.theme,strings:this.strings,isAnalyticsEnabled:this.isAnalyticsEnabled,autoCloseOnApprove:this.autoCloseOnApprove,debug:this.debug,disableMLKit:this.disableMLKit})},e.exports={init:function(e,t){return(new c).withAccessToken(e,t)},getNewAccessToken:function(){s&&s.getNewAccessToken()},sendEvent:function(e,t){s&&s.sendEvent(e,t)},reset:function(){s=null}}},function(t,n){t.exports=e}])}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sumsub/cordova-idensic-mobile-sdk-plugin",
3
- "version": "1.20.3",
3
+ "version": "1.23.0",
4
4
  "description": "Cordova plugin exposing Sumsub SDK",
5
5
  "scripts": {
6
6
  "build": "webpack -p"
package/plugin.xml CHANGED
@@ -1,5 +1,5 @@
1
1
  <?xml version="1.0" encoding="utf-8" ?>
2
- <plugin id="cordova-idensic-mobile-sdk-plugin" version="1.20.3" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
2
+ <plugin id="cordova-idensic-mobile-sdk-plugin" version="1.23.0" xmlns="http://apache.org/cordova/ns/plugins/1.0" xmlns:android="http://schemas.android.com/apk/res/android">
3
3
 
4
4
  <name>cordova-idensic-mobile-sdk-plugin</name>
5
5
  <description>Cordova plugin exposing SumSub Mobile SDK</description>
@@ -78,7 +78,7 @@
78
78
  <source url="https://cdn.cocoapods.org/"/>
79
79
  </config>
80
80
  <pods>
81
- <pod name="IdensicMobileSDK" spec="=1.20.2" />
81
+ <pod name="IdensicMobileSDK" spec="=1.23.0" />
82
82
  </pods>
83
83
  </podspec>
84
84
 
@@ -5,10 +5,12 @@ var fs = require('fs');
5
5
  module.exports = function (context) {
6
6
 
7
7
  var withMRTDReader = process.argv.includes('--with-MRTDReader')
8
+ var withMRTDReaderCompat = process.argv.includes('--with-MRTDReader-compat')
8
9
  var withVideoIdent = process.argv.includes('--with-VideoIdent')
9
10
  var withVideoIdentLatest = process.argv.includes('--with-VideoIdent-latest')
10
11
 
11
- withVideoIdent = withVideoIdent || withVideoIdentLatest
12
+ withMRTDReader = withMRTDReader || withMRTDReaderCompat
13
+ withVideoIdent = withVideoIdent || withVideoIdentLatest
12
14
 
13
15
  if (!withMRTDReader && !withVideoIdent) {
14
16
  return
@@ -33,7 +35,7 @@ module.exports = function (context) {
33
35
  var replaces = [podLine]
34
36
 
35
37
  if (withMRTDReader) {
36
- replaces.push(podLine.replace(/IdensicMobileSDK/, 'IdensicMobileSDK/MRTDReader'))
38
+ replaces.push(podLine.replace(/IdensicMobileSDK/, 'IdensicMobileSDK/MRTDReader' + (withMRTDReaderCompat ? "-compat" : "")))
37
39
  }
38
40
  if (withVideoIdent) {
39
41
  replaces.push(podLine.replace(/IdensicMobileSDK/, 'IdensicMobileSDK/VideoIdent' + (withVideoIdentLatest ? "-latest" : "")))
@@ -14,8 +14,8 @@ allprojects {
14
14
  }
15
15
 
16
16
  dependencies {
17
- implementation "com.sumsub.sns:idensic-mobile-sdk:1.20.3"
18
- implementation "com.sumsub.sns:idensic-mobile-sdk-prooface:1.20.3"
19
- // implementation "com.sumsub.sns:idensic-mobile-sdk-videoident:1.20.3"
20
- implementation 'com.google.android.material:material:1.7.0'
17
+ implementation "com.sumsub.sns:idensic-mobile-sdk:1.23.0"
18
+ implementation "com.sumsub.sns:idensic-mobile-sdk-prooface:1.23.0"
19
+ // implementation "com.sumsub.sns:idensic-mobile-sdk-videoident:1.23.2"
20
+ implementation 'com.google.android.material:material:1.8.0'
21
21
  }
@@ -8,18 +8,14 @@ import android.webkit.ValueCallback;
8
8
  import androidx.annotation.Nullable;
9
9
 
10
10
  import com.sumsub.sns.R;
11
- import com.sumsub.sns.core.SNSActionResult;
12
- import com.sumsub.sns.core.SNSMobileSDK;
11
+ import com.sumsub.sns.core.*;
13
12
  import com.sumsub.sns.core.data.listener.SNSActionResultHandler;
14
13
  import com.sumsub.sns.core.data.listener.SNSCompleteHandler;
15
14
  import com.sumsub.sns.core.data.listener.SNSErrorHandler;
16
15
  import com.sumsub.sns.core.data.listener.SNSEventHandler;
17
16
  import com.sumsub.sns.core.data.listener.SNSIconHandler;
18
17
  import com.sumsub.sns.core.data.listener.SNSStateChangedHandler;
19
- import com.sumsub.sns.core.data.model.SNSCompletionResult;
20
- import com.sumsub.sns.core.data.model.SNSInitConfig;
21
- import com.sumsub.sns.core.data.model.SNSSDKState;
22
- import com.sumsub.sns.core.data.model.SNSSupportItem;
18
+ import com.sumsub.sns.core.data.model.*;
23
19
  import com.sumsub.sns.core.theme.SNSCustomizationFileFormat;
24
20
  import com.sumsub.sns.prooface.SNSProoface;
25
21
 
@@ -29,12 +25,7 @@ import org.json.JSONArray;
29
25
  import org.json.JSONException;
30
26
  import org.json.JSONObject;
31
27
 
32
- import java.util.Arrays;
33
- import java.util.Collections;
34
- import java.util.HashMap;
35
- import java.util.Iterator;
36
- import java.util.Locale;
37
- import java.util.Map;
28
+ import java.util.*;
38
29
 
39
30
  public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
40
31
  private static final String LAUNCH_ACTION = "launchSNSMobileSDK";
@@ -59,9 +50,7 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
59
50
 
60
51
  JSONObject conf = args.getJSONObject(0);
61
52
  String apiUrl = conf.optString("apiUrl");
62
- String flowName = conf.optString("flowName");
63
53
  String accessToken = conf.optString("accessToken");
64
- String supportEmail = conf.optString("supportEmail");
65
54
  String locale = conf.optString("locale");
66
55
  boolean isDebug = conf.optBoolean("debug", false);
67
56
  JSONObject hasHandlers = conf.getJSONObject("hasHandlers");
@@ -71,11 +60,10 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
71
60
  String phone = applicantConf.optString("phone");
72
61
  String email = applicantConf.optString("email");
73
62
  JSONObject strings = conf.optJSONObject("strings");
63
+ JSONObject preferredDocumentDefinitions = conf.getJSONObject("preferredDocumentDefinitions");
74
64
  boolean isAnalyticsEnabled = !(conf.has("isAnalyticsEnabled") && !conf.optBoolean("isAnalyticsEnabled"));
75
-
76
- if (TextUtils.isEmpty(supportEmail)) {
77
- supportEmail = "support@sumsub.com";
78
- }
65
+ int autoCloseOnApprove = conf.optInt("autoCloseOnApprove", 3);
66
+ boolean isDisableMLKit = conf.optBoolean("disableMLKit", false);
79
67
 
80
68
  if (TextUtils.isEmpty(accessToken)) {
81
69
  callbackContext.error("Error: Access token must be provided");
@@ -84,7 +72,7 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
84
72
  if (TextUtils.isEmpty(locale)) {
85
73
  locale = Locale.getDefault().getLanguage();
86
74
  }
87
- this.launchSNSMobileSDK(apiUrl, flowName, accessToken, supportEmail, email, phone, locale, isDebug, theme, settings, strings, isAnalyticsEnabled, hasHandlers, callbackContext);
75
+ this.launchSNSMobileSDK(apiUrl, accessToken, email, phone, locale, isDebug, theme, settings, strings, isAnalyticsEnabled, hasHandlers, preferredDocumentDefinitions, autoCloseOnApprove, isDisableMLKit, callbackContext);
88
76
  return true;
89
77
  } else if (action.equals(NEW_TOKEN_ACTION)) {
90
78
  newAccessToken = args.getString(0);
@@ -140,9 +128,7 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
140
128
 
141
129
  private void launchSNSMobileSDK(
142
130
  final String apiUrl,
143
- final String flowName,
144
131
  final String accessToken,
145
- String supportEmail,
146
132
  String email,
147
133
  String phone,
148
134
  final String locale,
@@ -152,6 +138,9 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
152
138
  final JSONObject strings,
153
139
  final boolean isAnalyticsEnabled,
154
140
  final JSONObject hasHandlers,
141
+ final JSONObject preferredDocumentDefinitions,
142
+ final int autoCloseOnApprove,
143
+ final boolean isDisableMLKit,
155
144
  CallbackContext callbackContext
156
145
  ) {
157
146
 
@@ -226,29 +215,52 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
226
215
  });
227
216
  };
228
217
 
229
- SNSMobileSDK.Builder snsSdkBuilder;
230
- if (flowName.isEmpty()) {
231
- snsSdkBuilder = new SNSMobileSDK.Builder(cordova.getActivity());
232
- } else {
233
- snsSdkBuilder = new SNSMobileSDK.Builder(cordova.getActivity(), null, flowName);
234
- }
218
+ SNSMobileSDK.Builder snsSdkBuilder = new SNSMobileSDK.Builder(cordova.getActivity());
235
219
 
236
220
  if (apiUrl != null && !apiUrl.isEmpty()) {
237
221
  snsSdkBuilder.withBaseUrl(apiUrl);
238
222
  }
239
223
 
240
- final SNSSupportItem supportItem = new SNSSupportItem(
241
- R.string.sns_support_EMAIL_title,
242
- R.string.sns_support_EMAIL_description,
243
- SNSSupportItem.Type.Email,
244
- supportEmail,
245
- null,
246
- SNSIconHandler.SNSCommonIcons.MAIL.getImageName(),
247
- null
248
- );
249
224
  if (theme != null) {
225
+ SNSMobileSDK.INSTANCE.isDebug();
250
226
  snsSdkBuilder.withJsonTheme(theme, SNSCustomizationFileFormat.CORDOVA);
251
227
  }
228
+
229
+ if (preferredDocumentDefinitions != null) {
230
+ Map<String, SNSDocumentDefinition> documents = new HashMap<>();
231
+
232
+ Iterator<String> keys = preferredDocumentDefinitions.keys();
233
+ while (keys.hasNext()) {
234
+ try {
235
+ String key = keys.next();
236
+ JSONObject data = preferredDocumentDefinitions.getJSONObject(key);
237
+ String iDocType = null;
238
+ if (data.has("idDocType")) {
239
+ iDocType = data.getString("idDocType");
240
+ }
241
+ String country = null;
242
+ if (data.has("country")) {
243
+ country = data.getString("country");
244
+ }
245
+ SNSDocumentDefinition documentDefinition = new SNSDocumentDefinition(iDocType, country);
246
+ documents.put(key, documentDefinition);
247
+ } catch (Exception e) {
248
+ Log.e(TAG, "Exception: " + e);
249
+ callbackContext.error("Error:" + e.getMessage());
250
+ }
251
+ }
252
+
253
+ if (!documents.isEmpty()) {
254
+ snsSdkBuilder.withPreferredDocumentDefinitions(documents);
255
+ }
256
+ }
257
+
258
+ List<SNSModule> modules = new ArrayList<>();
259
+ modules.add(new SNSProoface());
260
+ if (isDisableMLKit) {
261
+ modules.add(new SNSCoreModule(SNSCoreModule.FEATURE_DISABLE_MLKIT));
262
+ }
263
+
252
264
  snsSdk = snsSdkBuilder
253
265
  .withAccessToken(accessToken, () -> {
254
266
  Log.d(TAG, "SumSub: calling onTokenExpired!");
@@ -269,17 +281,17 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
269
281
  return newAccessToken;
270
282
  })
271
283
  .withDebug(isDebug)
272
- .withModules(Arrays.asList(new SNSProoface()))
284
+ .withModules(modules)
273
285
  .withErrorHandler(errorHandler)
274
286
  .withStateChangedHandler(stateChangedHandler)
275
287
  .withCompleteHandler(completeHandler)
276
288
  .withActionResultHandler(actionResultHandler)
277
289
  .withEventHandler(eventHandler)
278
- .withSupportItems(Collections.singletonList(supportItem))
279
290
  .withLocale(new Locale(locale))
280
291
  .withSettings(toMap(settings))
281
292
  .withAnalyticsEnabled(isAnalyticsEnabled)
282
293
  .withConf(new SNSInitConfig(email, phone, strings != null ? toMap(strings) : null))
294
+ .withAutoCloseOnApprove(autoCloseOnApprove)
283
295
  .build();
284
296
  snsSdk.launch();
285
297
  } catch (Exception e) {
@@ -364,14 +376,15 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
364
376
  super.onActivityResult(requestCode, resultCode, data);
365
377
  }
366
378
 
367
- public static Map<String, String> toMap(JSONObject jsonobj) throws JSONException {
379
+ public static Map<String, String> toMap(JSONObject jsonobj) throws JSONException {
368
380
  Map<String, String> map = new HashMap<String, String>();
369
381
  Iterator<String> keys = jsonobj.keys();
370
- while(keys.hasNext()) {
382
+ while (keys.hasNext()) {
371
383
  String key = keys.next();
372
- String value = (String)jsonobj.get(key);
384
+ String value = (String) jsonobj.get(key);
373
385
  map.put(key, value);
374
- } return map;
386
+ }
387
+ return map;
375
388
  }
376
389
 
377
390
 
@@ -19,30 +19,16 @@
19
19
  }
20
20
 
21
21
  NSString *apiUrl = params[@"apiUrl"];
22
- NSString *flowName = params[@"flowName"];
23
22
  NSString *accessToken = params[@"accessToken"];
24
23
  NSString *locale = params[@"locale"];
25
24
 
26
- SNSMobileSDK *sdk;
27
-
28
- if (!flowName || flowName.length <= 0) {
29
-
30
- SNSEnvironment environment = (apiUrl && apiUrl.length > 0) ? apiUrl : SNSEnvironmentProduction;
31
-
32
- sdk = [SNSMobileSDK setupWithAccessToken:accessToken
33
- environment:environment];
25
+ SNSEnvironment environment = (apiUrl && apiUrl.length > 0) ? apiUrl : SNSEnvironmentProduction;
34
26
 
35
- if (locale) {
36
- sdk.locale = locale;
37
- }
27
+ SNSMobileSDK *sdk = [SNSMobileSDK setupWithAccessToken:accessToken
28
+ environment:environment];
38
29
 
39
- } else {
40
-
41
- sdk = [SNSMobileSDK setupWithBaseUrl:apiUrl
42
- flowName:flowName
43
- accessToken:accessToken
44
- locale:locale
45
- supportEmail:params[@"supportEmail"]];
30
+ if (locale) {
31
+ sdk.locale = locale;
46
32
  }
47
33
 
48
34
  if (!sdk.isReady) {
@@ -60,6 +46,10 @@
60
46
  sdk.isAnalyticsEnabled = [params[@"isAnalyticsEnabled"] boolValue];
61
47
  }
62
48
 
49
+ if ([params[@"autoCloseOnApprove"] isKindOfClass:NSNumber.class]) {
50
+ [sdk setOnApproveDismissalTimeInterval:[params[@"autoCloseOnApprove"] doubleValue]];
51
+ }
52
+
63
53
  if (params[@"settings"]) {
64
54
  sdk.settings = params[@"settings"];
65
55
  }
@@ -75,6 +65,10 @@
75
65
  sdk.initialPhone = params[@"applicantConf"][@"phone"];
76
66
  }
77
67
 
68
+ if (params[@"preferredDocumentDefinitions"]) {
69
+ [sdk setPreferredDocumentDefinitionsFromJSON: params[@"preferredDocumentDefinitions"]];
70
+ }
71
+
78
72
  __weak SNSMobileSdkCordovaPlugin *weakSelf = self;
79
73
 
80
74
  [sdk tokenExpirationHandler:^(void (^ _Nonnull onComplete)(NSString * _Nullable)) {
@@ -29,10 +29,8 @@ var _currentInstance = null;
29
29
  function SNSMobileSDK(sdkConf) {
30
30
  this.sdkConf = sdkConf
31
31
 
32
- this.sdkConf.settings = {
33
- "appFrameworkName": "cordova",
34
- // "appFrameworkVersion": "..."
35
- }
32
+ this.sdkConf.settings["appFrameworkName"] = "cordova";
33
+ // this.sdkConf.settings["appFrameworkVersion"] = "...";
36
34
  }
37
35
 
38
36
  SNSMobileSDK.prototype.dismiss = function () {
@@ -115,12 +113,9 @@ SNSMobileSDK.prototype.launch = function () {
115
113
  if (_currentInstance) {
116
114
  reject(new Error("Aborted since another instance is in use!"));
117
115
  }
118
- else if (!_that.sdkConf.accessToken) {-0
116
+ else if (!_that.sdkConf.accessToken) {
119
117
  reject(new Error('Access token is required'));
120
118
  }
121
- else if (_that.flowName && !_that.sdkConf.apiUrl) {
122
- reject(new Error('API URL is required'));
123
- }
124
119
  else {
125
120
  _currentInstance = _that
126
121
  exec(
@@ -142,12 +137,14 @@ SNSMobileSDK.prototype.launch = function () {
142
137
  });
143
138
  }
144
139
 
145
- function Builder(apiUrl, flowName) {
146
- this.apiUrl = apiUrl;
147
- this.flowName = flowName;
140
+ function Builder() {
148
141
  this.debug = false;
149
142
  this.handlers = {};
150
143
  this.applicantConf = {};
144
+ this.preferredDocumentDefinitions = {};
145
+ this.autoCloseOnApprove = 3;
146
+ this.settings = {};
147
+ this.disableMLKit = false
151
148
  return this;
152
149
  }
153
150
 
@@ -203,19 +200,27 @@ Builder.prototype.withLocale = function (locale) {
203
200
  return this;
204
201
  }
205
202
 
206
- Builder.prototype.withSupportEmail = function (supportEmail) {
207
- if (typeof supportEmail !== 'string') {
208
- throw new Error('Invalid parameter, "supportEmail" must be a string');
203
+ Builder.prototype.withApplicantConf = function (applicantConf) {
204
+ if (!applicantConf || typeof applicantConf !== 'object') {
205
+ throw new Error('Invalid parameter, "withApplicantConf" expects a hash');
209
206
  }
210
- this.supportEmail = supportEmail;
211
- return this;
207
+ this.applicantConf = applicantConf;
208
+ return this
212
209
  }
213
210
 
214
- Builder.prototype.withApplicantConf = function (applicantConf) {
215
- if (!applicantConf || typeof applicantConf !== 'object') {
216
- throw new Error('Invalid parameter, "withApplicantConf" expects a hash')
211
+ Builder.prototype.withPreferredDocumentDefinitions = function (preferredDocumentDefinitions) {
212
+ if (!preferredDocumentDefinitions || typeof preferredDocumentDefinitions !== 'object') {
213
+ throw new Error('Invalid parameter, "withPreferredDocumentDefinitions" expects a hash');
217
214
  }
218
- this.applicantConf = applicantConf
215
+ this.preferredDocumentDefinitions = preferredDocumentDefinitions;
216
+ return this
217
+ }
218
+
219
+ Builder.prototype.withSettings = function (settings) {
220
+ if (!settings || typeof settings !== 'object') {
221
+ throw new Error('Invalid parameter, "withSettings" expects a hash');
222
+ }
223
+ this.settings = settings;
219
224
  return this
220
225
  }
221
226
 
@@ -244,6 +249,22 @@ Builder.prototype.withBaseUrl = function (apiUrl) {
244
249
  return this;
245
250
  }
246
251
 
252
+ Builder.prototype.withAutoCloseOnApprove = function (autoCloseOnApprove) {
253
+ if (typeof autoCloseOnApprove !== 'number') {
254
+ throw new Error('Invalid parameter, "autoCloseOnApprove" expects a number')
255
+ }
256
+ this.autoCloseOnApprove = autoCloseOnApprove;
257
+ return this
258
+ }
259
+
260
+ Builder.prototype.withDisableMLKit = function (flag) {
261
+ if (typeof flag !== 'boolean') {
262
+ throw new Error('Invalid parameter, "withDisableMLKit" expects a boolean');
263
+ }
264
+ this.disableMLKit = flag;
265
+ return this;
266
+ }
267
+
247
268
  Builder.prototype.build = function () {
248
269
 
249
270
  var hasHandlers = {}
@@ -253,18 +274,20 @@ Builder.prototype.build = function () {
253
274
 
254
275
  return new SNSMobileSDK({
255
276
  apiUrl: this.apiUrl,
256
- flowName: this.flowName,
257
277
  accessToken: this.accessToken,
258
278
  tokenExpirationHandler: this.tokenExpirationHandler,
259
279
  handlers: this.handlers,
260
280
  hasHandlers: hasHandlers,
261
281
  locale: this.locale,
262
- supportEmail: this.supportEmail,
263
282
  applicantConf: this.applicantConf,
283
+ preferredDocumentDefinitions: this.preferredDocumentDefinitions,
284
+ settings: this.settings,
264
285
  theme: this.theme,
265
286
  strings: this.strings,
266
287
  isAnalyticsEnabled: this.isAnalyticsEnabled,
267
- debug: this.debug
288
+ autoCloseOnApprove: this.autoCloseOnApprove,
289
+ debug: this.debug,
290
+ disableMLKit: this.disableMLKit
268
291
  });
269
292
  }
270
293
 
@@ -273,9 +296,6 @@ module.exports = {
273
296
  init: function (accessToken, expirationHandler) {
274
297
  return new Builder().withAccessToken(accessToken, expirationHandler)
275
298
  },
276
- Builder: function (baseUrl, flowName) {
277
- return new Builder(baseUrl, flowName)
278
- },
279
299
  getNewAccessToken: function () {
280
300
  if (_currentInstance) {
281
301
  _currentInstance.getNewAccessToken()