@sumsub/cordova-idensic-mobile-sdk-plugin 1.37.1 → 1.38.1

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"])}(self,e=>{return t={440:t=>{"use strict";t.exports=e},846:(e,t,n)=>{const r=n(440),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}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.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})},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}}}},n={},function e(r){var o=n[r];if(void 0!==o)return o.exports;var i=n[r]={exports:{}};return t[r](i,i.exports,e),i.exports}(846);var t,n});
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"])}(self,e=>{return t={440:t=>{"use strict";t.exports=e},846:(e,t,n)=>{const r=n(440),o="SNSMobileSdkCordovaPlugin",i={onStatusChanged:null,onEvent:null};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}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.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})},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}}}},n={},function e(r){var o=n[r];if(void 0!==o)return o.exports;var i=n[r]={exports:{}};return t[r](i,i.exports,e),i.exports}(846);var t,n});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sumsub/cordova-idensic-mobile-sdk-plugin",
3
- "version": "1.37.1",
3
+ "version": "1.38.1",
4
4
  "description": "Cordova plugin exposing Sumsub SDK",
5
5
  "scripts": {
6
6
  "build": "webpack --mode=production"
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.37.1" 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.38.1" 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>
@@ -81,7 +81,7 @@
81
81
  <source url="https://cdn.cocoapods.org/"/>
82
82
  </config>
83
83
  <pods>
84
- <pod name="IdensicMobileSDK" spec="=1.37.1" />
84
+ <pod name="IdensicMobileSDK" spec="=1.38.1" />
85
85
  </pods>
86
86
  </podspec>
87
87
 
@@ -14,10 +14,10 @@ allprojects {
14
14
  }
15
15
 
16
16
  dependencies {
17
- implementation "com.sumsub.sns:idensic-mobile-sdk:1.37.1"
18
- implementation "com.sumsub.sns:idensic-mobile-sdk-videoident:1.37.1"
19
- implementation "com.sumsub.sns:idensic-mobile-sdk-eid:1.37.1"
20
- implementation "com.sumsub.sns:idensic-mobile-sdk-nfc:1.37.1"
17
+ implementation "com.sumsub.sns:idensic-mobile-sdk:1.38.0"
18
+ implementation "com.sumsub.sns:idensic-mobile-sdk-videoident:1.38.0"
19
+ implementation "com.sumsub.sns:idensic-mobile-sdk-eid:1.38.0"
20
+ implementation "com.sumsub.sns:idensic-mobile-sdk-nfc:1.38.0"
21
21
 
22
22
  implementation 'com.google.android.material:material:1.8.0'
23
23
  }
@@ -10,7 +10,6 @@ import androidx.annotation.Nullable;
10
10
 
11
11
  import com.sumsub.sns.R;
12
12
  import com.sumsub.sns.core.*;
13
- 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;
@@ -31,14 +30,12 @@ import java.util.*;
31
30
  public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
32
31
  private static final String LAUNCH_ACTION = "launchSNSMobileSDK";
33
32
  private static final String NEW_TOKEN_ACTION = "setNewAccessToken";
34
- private static final String ACTION_COMPLETED_ACTION = "onActionResultCompleted";
35
33
  private static final String DISMISS_ACTION = "dismiss";
36
34
 
37
35
  private static final String TAG = "SumSubCordovaPlugin";
38
36
 
39
37
  private static volatile String newAccessToken = null;
40
38
  private static SNSMobileSDK.SDK snsSdk;
41
- private volatile static SNSActionResult actionResultHandlerComplete;
42
39
 
43
40
  @Override
44
41
  public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
@@ -85,10 +82,6 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
85
82
  }
86
83
  });
87
84
  return true;
88
- } else if (ACTION_COMPLETED_ACTION.equalsIgnoreCase(action)) {
89
- String result = args.getJSONObject(0).getString("result");
90
- actionResultHandlerComplete = "cancel".equalsIgnoreCase(result) ? SNSActionResult.Cancel : SNSActionResult.Continue;
91
- return true;
92
85
  } else {
93
86
  callbackContext.error("Method not implemented");
94
87
  return false;
@@ -116,30 +109,6 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
116
109
  });
117
110
  }
118
111
 
119
- private void requestActionResult(String actionId, String answer, String actionType, Boolean allowContinuing) {
120
- cordova.getActivity().runOnUiThread(new Runnable() {
121
- @Override
122
- public void run() {
123
- try {
124
- WebView view = (WebView) webView.getView();
125
- if (view != null) {
126
-
127
- final String func = "window.SNSMobileSDK.sendEvent('onActionResult', { actionId: '" + actionId + "', answer: '" + answer + "', actionType: '" + actionType + ", allowContinuing: '" + allowContinuing + "})";
128
-
129
- view.evaluateJavascript(func, new ValueCallback<String>() {
130
- @Override
131
- public void onReceiveValue(String s) {
132
- // no op
133
- }
134
- });
135
- }
136
- } catch (Exception e) {
137
- Log.e(TAG, "Exception: " + e);
138
- }
139
- }
140
- });
141
- }
142
-
143
112
  private void launchSNSMobileSDK(
144
113
  final String apiUrl,
145
114
  final String accessToken,
@@ -160,29 +129,7 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
160
129
  cordova.getActivity().runOnUiThread(new Runnable() {
161
130
  @Override
162
131
  public void run() {
163
-
164
132
  try {
165
-
166
- final SNSActionResultHandler actionResultHandler = hasHandlers.optBoolean("onActionResult") ?
167
- (actionId, actionType, answer, allowContinuing) -> {
168
- Log.d(TAG, "Calling onActionResult(" + actionId + ", " + answer + ")");
169
- actionResultHandlerComplete = null;
170
- requestActionResult(actionId, answer, actionType, allowContinuing);
171
- int cnt = 0;
172
- while (actionResultHandlerComplete == null) {
173
- try {
174
- Thread.sleep(100);
175
- } catch (InterruptedException e) {
176
- //no op
177
- }
178
- if (++cnt > 100) {
179
- return SNSActionResult.Continue;
180
- }
181
- }
182
- Log.d(TAG, "SumSub: Received: " + actionResultHandlerComplete + ' ' + Thread.currentThread().getName());
183
- return actionResultHandlerComplete;
184
- } : null;
185
-
186
133
  final SNSErrorHandler errorHandler = e -> Log.d(TAG, Log.getStackTraceString(e));
187
134
 
188
135
  final SNSStateChangedHandler stateChangedHandler = (oldState, newState) -> {
@@ -311,7 +258,6 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
311
258
  .withErrorHandler(errorHandler)
312
259
  .withStateChangedHandler(stateChangedHandler)
313
260
  .withCompleteHandler(completeHandler)
314
- .withActionResultHandler(actionResultHandler)
315
261
  .withEventHandler(eventHandler)
316
262
  .withLocale(new Locale(locale))
317
263
  .withSettings(toMap(settings))
@@ -358,13 +304,6 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
358
304
  result.put("status", state != null ? getSDKStateName(state) : "Unknown");
359
305
  result.put("errorType", errorType);
360
306
  result.put("errorMsg", errorMsg);
361
- if (state instanceof SNSSDKState.ActionCompleted) {
362
- final SNSSDKState.ActionCompleted action = (SNSSDKState.ActionCompleted) state;
363
- final JSONObject actionResult = new JSONObject();
364
- actionResult.put("actionId", action.getActionId());
365
- actionResult.put("answer", action.getAnswer());
366
- result.put("actionResult", actionResult);
367
- }
368
307
  } catch (JSONException e) {
369
308
  throw new RuntimeException(e);
370
309
  }
@@ -412,6 +351,4 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
412
351
  }
413
352
  return map;
414
353
  }
415
-
416
-
417
354
  }
@@ -4,9 +4,6 @@
4
4
 
5
5
  - (void)launchSNSMobileSDK:(CDVInvokedUrlCommand*)command;
6
6
  - (void)setNewAccessToken:(CDVInvokedUrlCommand*)command;
7
- - (void)onActionResultCompleted:(CDVInvokedUrlCommand*)command;
8
7
  - (void)dismiss:(CDVInvokedUrlCommand*)command;
9
8
 
10
-
11
-
12
- @end
9
+ @end
@@ -4,7 +4,6 @@
4
4
 
5
5
  @interface SNSMobileSdkCordovaPlugin ()
6
6
  @property (nonatomic, copy) void(^tokenExpirationOnComplete)(NSString * _Nullable newAccessToken);
7
- @property (nonatomic, copy) void(^actionResultHandlerOnComplete)(SNSActionResultHandlerReaction);
8
7
  @property (nonatomic, weak) SNSMobileSDK *sdk;
9
8
  @end
10
9
 
@@ -105,21 +104,6 @@
105
104
  }];
106
105
  }
107
106
 
108
- if (params[@"hasHandlers"][@"onActionResult"]) {
109
-
110
- [sdk actionResultHandler:^(SNSMobileSDK * _Nonnull sdk, SNSActionResult * _Nonnull result, void (^ _Nonnull onComplete)(SNSActionResultHandlerReaction)) {
111
-
112
- weakSelf.actionResultHandlerOnComplete = onComplete;
113
-
114
- [weakSelf sendEventWithName:@"onActionResult" body:@{
115
- @"actionId": result.actionId ?: @"",
116
- @"actionType": result.actionType ?: @"",
117
- @"answer": result.answer ?: @"",
118
- @"allowContinuing": @(result.allowContinuing),
119
- }];
120
- }];
121
- }
122
-
123
107
  if (params[@"theme"]) {
124
108
 
125
109
  sdk.theme = [SNSTheme fromJSON:params[@"theme"]];
@@ -144,23 +128,6 @@
144
128
  });
145
129
  }
146
130
 
147
- - (void)onActionResultCompleted:(CDVInvokedUrlCommand*)command {
148
-
149
- NSDictionary *params = command.arguments.firstObject;
150
-
151
- SNSActionResultHandlerReaction reaction = SNSActionResultHandlerReaction_Continue;
152
- if ([params[@"result"] isEqualToString:@"cancel"]) {
153
- reaction = SNSActionResultHandlerReaction_Cancel;
154
- }
155
-
156
- dispatch_async(dispatch_get_main_queue(), ^{
157
- if (self.actionResultHandlerOnComplete) {
158
- self.actionResultHandlerOnComplete(reaction);
159
- self.actionResultHandlerOnComplete = nil;
160
- }
161
- });
162
- }
163
-
164
131
  - (void)dismiss:(CDVInvokedUrlCommand*)command {
165
132
 
166
133
  [self.sdk dismiss];
@@ -244,17 +211,6 @@
244
211
  result[@"errorType"] = [sdk descriptionForFailReason:sdk.failReason];
245
212
  result[@"errorMsg"] = sdk.verboseStatus;
246
213
  }
247
-
248
- if (sdk.status == SNSMobileSDKStatus_ActionCompleted && sdk.actionResult) {
249
- NSMutableDictionary *actionResult = NSMutableDictionary.new;
250
-
251
- actionResult[@"actionId"] = sdk.actionResult.actionId;
252
- actionResult[@"actionType"] = sdk.actionResult.actionType;
253
- actionResult[@"answer"] = sdk.actionResult.answer;
254
- actionResult[@"allowContinuing"] = @(sdk.actionResult.allowContinuing);
255
-
256
- result[@"actionResult"] = actionResult.copy;
257
- }
258
214
 
259
215
  [self complete:command withResult:result.copy];
260
216
  }