@sumsub/cordova-idensic-mobile-sdk-plugin 1.36.1 → 1.38.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"])}(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.36.1",
3
+ "version": "1.38.0",
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.36.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.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>
@@ -20,7 +20,6 @@
20
20
  <feature name="SNSMobileSdkCordovaPlugin">
21
21
  <param name="android-package" value="com.sumsub.msdk.plugins.cordova.SNSMobileSdkCordovaPlugin" />
22
22
  </feature>
23
- <preference name="android-targetSdkVersion" value="34" />
24
23
  <preference name="android-compileSdkVersion" value="35" />
25
24
  <preference name="android-buildToolsVersion" value="35.0.0" />
26
25
  </config-file>
@@ -82,7 +81,7 @@
82
81
  <source url="https://cdn.cocoapods.org/"/>
83
82
  </config>
84
83
  <pods>
85
- <pod name="IdensicMobileSDK" spec="=1.36.1" />
84
+ <pod name="IdensicMobileSDK" spec="=1.38.0" />
86
85
  </pods>
87
86
  </podspec>
88
87
 
@@ -14,11 +14,10 @@ allprojects {
14
14
  }
15
15
 
16
16
  dependencies {
17
- implementation "com.sumsub.sns:idensic-mobile-sdk:1.36.1"
18
- // implementation("com.sumsub.sns:idensic-mobile-sdk:1.36.1-release_1.36.1-SNAPSHOT")
19
- implementation "com.sumsub.sns:idensic-mobile-sdk-videoident:1.36.1"
20
- implementation "com.sumsub.sns:idensic-mobile-sdk-eid:1.36.1"
21
- implementation "com.sumsub.sns:idensic-mobile-sdk-nfc:1.36.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"
22
21
 
23
22
  implementation 'com.google.android.material:material:1.8.0'
24
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
  }
@@ -1,297 +0,0 @@
1
- #!/usr/bin/env ruby
2
- # frozen_string_literal: true
3
-
4
- require 'optparse'
5
-
6
- # Usage:
7
- # scripts/bump_version <new_version> [--ios=IOS_VERSION] [--android=ANDROID_VERSION]
8
- #
9
- # Examples:
10
- # scripts/bump_version 1.36.0
11
- # scripts/bump_version 1.36.0 --ios=1.34.0
12
- # scripts/bump_version 1.36.0 --android=1.35.0
13
- # scripts/bump_version 1.36.0 --ios=1.34.0 --android=1.35.0
14
-
15
- options = {}
16
- parser = OptionParser.new do |opts|
17
- opts.banner = "Usage: #{$PROGRAM_NAME} <new_version> [options]"
18
- opts.on("--ios=VERSION", "Override iOS version") do |v|
19
- options[:ios] = v
20
- end
21
- opts.on("--android=VERSION", "Override Android version") do |v|
22
- options[:android] = v
23
- end
24
- end
25
-
26
- parser.parse!
27
- abort parser.help if ARGV.empty?
28
-
29
- new_version = ARGV[0]
30
- ios_version = options[:ios] || new_version
31
- android_version = options[:android] || new_version
32
- android_version_code = new_version.gsub(/\.(\d{1})(?!\d)/, '0$1').gsub(/\D/, '')
33
-
34
- PATTERNS = [
35
- {
36
- file: "demo/plugins/cordova-idensic-mobile-sdk-plugin/src/android/build-extras.gradle",
37
- platform: :android,
38
- pattern: /(implementation "com\.sumsub\.sns:idensic-mobile-sdk(-videoident|-eid|-nfc)?:)([\d.]+)(")/,
39
- replacement: ->(match, ver) {
40
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(4)}"
41
- }
42
- },
43
- {
44
- file: "demo/platforms/android/cordova-idensic-mobile-sdk-plugin/SumSubCordova-build-extras.gradle",
45
- platform: :android,
46
- pattern: /(implementation "com\.sumsub\.sns:idensic-mobile-sdk(-videoident|-eid|-nfc)?:)([\d.]+)(")/,
47
- replacement: ->(match, ver) {
48
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(4)}"
49
- }
50
- },
51
- {
52
- file: "src/android/build-extras.gradle",
53
- platform: :android,
54
- pattern: /(implementation "com\.sumsub\.sns:idensic-mobile-sdk(-videoident|-eid|-nfc)?:)([\d.]+)(")/,
55
- replacement: ->(match, ver) {
56
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(4)}"
57
- }
58
- },
59
- {
60
- file: "demo/platforms/ios/SumSubCordova.xcodeproj/project.pbxproj",
61
- platform: :all,
62
- pattern: /(\s*MARKETING_VERSION\s*=\s*)([\d.]+)(;)/,
63
- replacement: ->(match, ver) {
64
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
65
- }
66
- },
67
- {
68
- file: "demo/platforms/ios/SumSubCordova.xcodeproj/project.pbxproj",
69
- platform: :all,
70
- pattern: /(\s*CURRENT_PROJECT_VERSION\s*=\s*)([\d.]+)(;)/,
71
- replacement: ->(match, ver) {
72
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
73
- }
74
- },
75
- {
76
- file: "demo/platforms/android/android.json",
77
- platform: :all,
78
- pattern: /(\s*"cordova-idensic-mobile-sdk-plugin"\s*:\s*")([\d.]+)(",?)/,
79
- replacement: ->(match, ver) {
80
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
81
- }
82
- },
83
- {
84
- file: "demo/platforms/ios/platform_www/cordova_plugins.js",
85
- platform: :all,
86
- pattern: /(\s*"cordova-idensic-mobile-sdk-plugin"\s*:\s*")([\d.]+)(")/,
87
- replacement: ->(match, ver) {
88
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
89
- }
90
- },
91
- {
92
- file: "demo/platforms/android/platform_www/cordova_plugins.js",
93
- platform: :all,
94
- pattern: /(\s*"cordova-idensic-mobile-sdk-plugin"\s*:\s*")([\d.]+)(")/,
95
- replacement: ->(match, ver) {
96
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
97
- }
98
- },
99
- {
100
- file: "demo/plugins/cordova-idensic-mobile-sdk-plugin/package.json",
101
- platform: :all,
102
- pattern: /(\s*"version"\s*:\s*")([\d.]+)(")/,
103
- replacement: ->(match, ver) {
104
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
105
- }
106
- },
107
- {
108
- file: "demo/package.json",
109
- platform: :all,
110
- pattern: /(\s*"version"\s*:\s*")([\d.]+)(",)/,
111
- replacement: ->(match, ver) {
112
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
113
- }
114
- },
115
- {
116
- file: "package.json",
117
- platform: :all,
118
- pattern: /(\s*"version"\s*:\s*")([\d.]+)(",)/,
119
- replacement: ->(match, ver) {
120
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
121
- }
122
- },
123
- {
124
- file: "demo/platforms/ios/pods.json",
125
- platform: :ios,
126
- pattern: /(\s*"spec"\s*:\s*"=)([\d.]+)(",)/,
127
- replacement: ->(match, ver) {
128
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
129
- }
130
- },
131
- {
132
- file: "demo/platforms/ios/ios.json",
133
- platform: :all,
134
- pattern: /(\s*"cordova-idensic-mobile-sdk-plugin"\s*:\s*"=?)([\d.]+)(")/,
135
- replacement: ->(match, ver) {
136
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
137
- }
138
- },
139
- {
140
- file: "demo/platforms/ios/Podfile",
141
- platform: :ios,
142
- pattern: /(pod.*', '=)([\d.]+)(')/,
143
- replacement: ->(match, ver) {
144
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
145
- }
146
- },
147
- {
148
- file: "demo/config.xml",
149
- platform: :all,
150
- pattern: /(<widget .*version=")([\d.]+)(")/,
151
- replacement: ->(match, ver) {
152
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
153
- }
154
- },
155
- {
156
- file: "plugin.xml",
157
- platform: :ios,
158
- pattern: /(<pod name="IdensicMobileSDK" spec="=)([\d.]+)(")/,
159
- replacement: ->(match, ver) {
160
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
161
- }
162
- },
163
- {
164
- file: "demo/platforms/android/app/src/main/AndroidManifest.xml",
165
- platform: :all,
166
- pattern: /(android:versionName=")([\d.]+)(")/,
167
- replacement: ->(match, ver) {
168
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
169
- }
170
- },
171
- {
172
- file: "plugin.xml",
173
- platform: :all,
174
- pattern: /(<plugin.*?version=")([\d.]+)(")/,
175
- replacement: ->(match, ver) {
176
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
177
- }
178
- },
179
- {
180
- file: "demo/plugins/cordova-idensic-mobile-sdk-plugin/plugin.xml",
181
- platform: :all,
182
- pattern: /(plugin.*?version=")([\d.]+)(")/,
183
- replacement: ->(match, ver) {
184
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
185
- }
186
- },
187
- {
188
- file: "demo/plugins/cordova-idensic-mobile-sdk-plugin/plugin.xml",
189
- platform: :ios,
190
- pattern: /(<pod name="IdensicMobileSDK" spec="=)([\d.]+)(")/,
191
- replacement: ->(match, ver) {
192
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
193
- }
194
- },
195
- {
196
- file: "demo/platforms/ios/SumSubCordova/config.xml",
197
- platform: :all,
198
- pattern: /(widget.*?version=")([\d.]+)(")/,
199
- replacement: ->(match, ver) {
200
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
201
- }
202
- },
203
- {
204
- file: "demo/platforms/android/app/src/main/res/xml/config.xml",
205
- platform: :all,
206
- pattern: /(widget.*?version=")([\d.]+)(")/,
207
- replacement: ->(match, ver) {
208
- "#{Regexp.last_match(1)}#{ver}#{Regexp.last_match(3)}"
209
- }
210
- },
211
-
212
-
213
- {
214
- file: "demo/config.xml",
215
- platform: :all,
216
- pattern: /(widget.*?android-versionCode=")([\d.]+)(")/,
217
- replacement: ->(match, ver) {
218
- "#{Regexp.last_match(1)}#{android_version_code}#{Regexp.last_match(3)}"
219
- }
220
- },
221
- {
222
- file: "demo/platforms/android/app/src/main/AndroidManifest.xml",
223
- platform: :all,
224
- pattern: /(manifest.*?android:versionCode=")([\d.]+)(")/,
225
- replacement: ->(match, ver) {
226
- "#{Regexp.last_match(1)}#{android_version_code}#{Regexp.last_match(3)}"
227
- }
228
- },
229
- {
230
- file: "demo/platforms/android/app/src/main/res/xml/config.xml",
231
- platform: :all,
232
- pattern: /(widget.*?android-versionCode=")([\d.]+)(")/,
233
- replacement: ->(match, ver) {
234
- "#{Regexp.last_match(1)}#{android_version_code}#{Regexp.last_match(3)}"
235
- }
236
- },
237
- {
238
- file: "demo/platforms/ios/SumSubCordova/config.xml",
239
- platform: :all,
240
- pattern: /(widget.*?android-versionCode=")([\d.]+)(")/,
241
- replacement: ->(match, ver) {
242
- "#{Regexp.last_match(1)}#{android_version_code}#{Regexp.last_match(3)}"
243
- }
244
- }
245
- ]
246
-
247
- PATTERNS.each do |entry|
248
- file_path = entry[:file]
249
- platform = entry[:platform]
250
-
251
- unless File.exist?(file_path)
252
- warn "Warning: File #{file_path} not found; skipping."
253
- next
254
- end
255
-
256
- version_used =
257
- case platform
258
- when :ios then ios_version
259
- when :android then android_version
260
- else new_version
261
- end
262
-
263
- file_data = File.read(file_path)
264
- updated_data = file_data.gsub(entry[:pattern]) do |match|
265
- entry[:replacement].call(match, version_used)
266
- end
267
-
268
- if updated_data != file_data
269
- File.write(file_path, updated_data)
270
- puts "Updated #{file_path}"
271
- end
272
- end
273
-
274
- unless system("/usr/libexec/PlistBuddy -c \"Set :CFBundleVersion #{new_version}\" 'demo/platforms/ios/SumSubCordova/SumSubCordova-Info.plist'")
275
- abort("Error: Failed to update plist.".red)
276
- end
277
-
278
- unless system("/usr/libexec/PlistBuddy -c \"Set :CFBundleShortVersionString #{new_version}\" 'demo/platforms/ios/SumSubCordova/SumSubCordova-Info.plist'")
279
- abort("Error: Failed to update plist.".red)
280
- end
281
-
282
- system("npm install")
283
-
284
- Dir.chdir("demo") do
285
- system("bundle install")
286
- system("npm install")
287
-
288
- system("cd platforms/ios && bundle exec pod update IdensicMobileSDK")
289
- end
290
-
291
- changed_files = PATTERNS.map { |entry| entry[:file] }.uniq
292
- changed_files << "demo/platform/ios/Podfile.lock"
293
-
294
- system("git add #{changed_files.join(' ')}")
295
- system("git commit -m 'Bump version to #{new_version}'")
296
-
297
- puts "Done updating version to #{new_version}"
@@ -1,47 +0,0 @@
1
- buildscript {
2
- apply from: rootProject.file("dependencies.gradle")
3
- repositories {
4
- google()
5
- mavelCentral()
6
- }
7
- dependencies {
8
- classpath deps.build.androidPlugin
9
- classpath deps.build.kotlinPlugin
10
- classpath deps.build.butterknifePlugin
11
- }
12
- }
13
-
14
- plugins {
15
- id "maven"
16
- }
17
-
18
- apply plugin: 'com.android.library'
19
-
20
- rootProject.allprojects {
21
- repositories {
22
- google()
23
- maven { url "https://maven.sumsub.com/repository/maven-public/" }
24
- }
25
- }
26
-
27
- android {
28
- compileSdkVersion 35
29
- defaultConfig {
30
- minSdkVersion 23
31
- targetSdkVersion 35
32
- versionCode 1
33
- versionName "1.0"
34
- testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
35
- }
36
- buildTypes {
37
- release {
38
- minifyEnabled false
39
- proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
40
- }
41
- }
42
- }
43
-
44
- dependencies {
45
- implementation 'com.google.android.material:material:1.7.0'
46
- implementation 'org.apache.cordova:framework:8.1.0'
47
- }
@@ -1,172 +0,0 @@
1
- #!/usr/bin/env sh
2
-
3
- ##############################################################################
4
- ##
5
- ## Gradle start up script for UN*X
6
- ##
7
- ##############################################################################
8
-
9
- # Attempt to set APP_HOME
10
- # Resolve links: $0 may be a link
11
- PRG="$0"
12
- # Need this for relative symlinks.
13
- while [ -h "$PRG" ] ; do
14
- ls=`ls -ld "$PRG"`
15
- link=`expr "$ls" : '.*-> \(.*\)$'`
16
- if expr "$link" : '/.*' > /dev/null; then
17
- PRG="$link"
18
- else
19
- PRG=`dirname "$PRG"`"/$link"
20
- fi
21
- done
22
- SAVED="`pwd`"
23
- cd "`dirname \"$PRG\"`/" >/dev/null
24
- APP_HOME="`pwd -P`"
25
- cd "$SAVED" >/dev/null
26
-
27
- APP_NAME="Gradle"
28
- APP_BASE_NAME=`basename "$0"`
29
-
30
- # Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
31
- DEFAULT_JVM_OPTS=""
32
-
33
- # Use the maximum available, or set MAX_FD != -1 to use that value.
34
- MAX_FD="maximum"
35
-
36
- warn () {
37
- echo "$*"
38
- }
39
-
40
- die () {
41
- echo
42
- echo "$*"
43
- echo
44
- exit 1
45
- }
46
-
47
- # OS specific support (must be 'true' or 'false').
48
- cygwin=false
49
- msys=false
50
- darwin=false
51
- nonstop=false
52
- case "`uname`" in
53
- CYGWIN* )
54
- cygwin=true
55
- ;;
56
- Darwin* )
57
- darwin=true
58
- ;;
59
- MINGW* )
60
- msys=true
61
- ;;
62
- NONSTOP* )
63
- nonstop=true
64
- ;;
65
- esac
66
-
67
- CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
68
-
69
- # Determine the Java command to use to start the JVM.
70
- if [ -n "$JAVA_HOME" ] ; then
71
- if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
72
- # IBM's JDK on AIX uses strange locations for the executables
73
- JAVACMD="$JAVA_HOME/jre/sh/java"
74
- else
75
- JAVACMD="$JAVA_HOME/bin/java"
76
- fi
77
- if [ ! -x "$JAVACMD" ] ; then
78
- die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
79
-
80
- Please set the JAVA_HOME variable in your environment to match the
81
- location of your Java installation."
82
- fi
83
- else
84
- JAVACMD="java"
85
- which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
86
-
87
- Please set the JAVA_HOME variable in your environment to match the
88
- location of your Java installation."
89
- fi
90
-
91
- # Increase the maximum file descriptors if we can.
92
- if [ "$cygwin" = "false" -a "$darwin" = "false" -a "$nonstop" = "false" ] ; then
93
- MAX_FD_LIMIT=`ulimit -H -n`
94
- if [ $? -eq 0 ] ; then
95
- if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
96
- MAX_FD="$MAX_FD_LIMIT"
97
- fi
98
- ulimit -n $MAX_FD
99
- if [ $? -ne 0 ] ; then
100
- warn "Could not set maximum file descriptor limit: $MAX_FD"
101
- fi
102
- else
103
- warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
104
- fi
105
- fi
106
-
107
- # For Darwin, add options to specify how the application appears in the dock
108
- if $darwin; then
109
- GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
110
- fi
111
-
112
- # For Cygwin, switch paths to Windows format before running java
113
- if $cygwin ; then
114
- APP_HOME=`cygpath --path --mixed "$APP_HOME"`
115
- CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
116
- JAVACMD=`cygpath --unix "$JAVACMD"`
117
-
118
- # We build the pattern for arguments to be converted via cygpath
119
- ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
120
- SEP=""
121
- for dir in $ROOTDIRSRAW ; do
122
- ROOTDIRS="$ROOTDIRS$SEP$dir"
123
- SEP="|"
124
- done
125
- OURCYGPATTERN="(^($ROOTDIRS))"
126
- # Add a user-defined pattern to the cygpath arguments
127
- if [ "$GRADLE_CYGPATTERN" != "" ] ; then
128
- OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
129
- fi
130
- # Now convert the arguments - kludge to limit ourselves to /bin/sh
131
- i=0
132
- for arg in "$@" ; do
133
- CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
134
- CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
135
-
136
- if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
137
- eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
138
- else
139
- eval `echo args$i`="\"$arg\""
140
- fi
141
- i=$((i+1))
142
- done
143
- case $i in
144
- (0) set -- ;;
145
- (1) set -- "$args0" ;;
146
- (2) set -- "$args0" "$args1" ;;
147
- (3) set -- "$args0" "$args1" "$args2" ;;
148
- (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
149
- (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
150
- (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
151
- (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
152
- (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
153
- (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
154
- esac
155
- fi
156
-
157
- # Escape application args
158
- save () {
159
- for i do printf %s\\n "$i" | sed "s/'/'\\\\''/g;1s/^/'/;\$s/\$/' \\\\/" ; done
160
- echo " "
161
- }
162
- APP_ARGS=$(save "$@")
163
-
164
- # Collect all arguments for the java command, following the shell quoting and substitution rules
165
- eval set -- $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS "\"-Dorg.gradle.appname=$APP_BASE_NAME\"" -classpath "\"$CLASSPATH\"" org.gradle.wrapper.GradleWrapperMain "$APP_ARGS"
166
-
167
- # by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
168
- if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
169
- cd "$(dirname "$0")"
170
- fi
171
-
172
- exec "$JAVACMD" "$@"
@@ -1,84 +0,0 @@
1
- @if "%DEBUG%" == "" @echo off
2
- @rem ##########################################################################
3
- @rem
4
- @rem Gradle startup script for Windows
5
- @rem
6
- @rem ##########################################################################
7
-
8
- @rem Set local scope for the variables with windows NT shell
9
- if "%OS%"=="Windows_NT" setlocal
10
-
11
- set DIRNAME=%~dp0
12
- if "%DIRNAME%" == "" set DIRNAME=.
13
- set APP_BASE_NAME=%~n0
14
- set APP_HOME=%DIRNAME%
15
-
16
- @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17
- set DEFAULT_JVM_OPTS=
18
-
19
- @rem Find java.exe
20
- if defined JAVA_HOME goto findJavaFromJavaHome
21
-
22
- set JAVA_EXE=java.exe
23
- %JAVA_EXE% -version >NUL 2>&1
24
- if "%ERRORLEVEL%" == "0" goto init
25
-
26
- echo.
27
- echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28
- echo.
29
- echo Please set the JAVA_HOME variable in your environment to match the
30
- echo location of your Java installation.
31
-
32
- goto fail
33
-
34
- :findJavaFromJavaHome
35
- set JAVA_HOME=%JAVA_HOME:"=%
36
- set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37
-
38
- if exist "%JAVA_EXE%" goto init
39
-
40
- echo.
41
- echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42
- echo.
43
- echo Please set the JAVA_HOME variable in your environment to match the
44
- echo location of your Java installation.
45
-
46
- goto fail
47
-
48
- :init
49
- @rem Get command-line arguments, handling Windows variants
50
-
51
- if not "%OS%" == "Windows_NT" goto win9xME_args
52
-
53
- :win9xME_args
54
- @rem Slurp the command line arguments.
55
- set CMD_LINE_ARGS=
56
- set _SKIP=2
57
-
58
- :win9xME_args_slurp
59
- if "x%~1" == "x" goto execute
60
-
61
- set CMD_LINE_ARGS=%*
62
-
63
- :execute
64
- @rem Setup the command line
65
-
66
- set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67
-
68
- @rem Execute Gradle
69
- "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70
-
71
- :end
72
- @rem End local scope for the variables with windows NT shell
73
- if "%ERRORLEVEL%"=="0" goto mainEnd
74
-
75
- :fail
76
- rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77
- rem the _cmd.exe /c_ return code!
78
- if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79
- exit /b 1
80
-
81
- :mainEnd
82
- if "%OS%"=="Windows_NT" endlocal
83
-
84
- :omega
@@ -1,302 +0,0 @@
1
- // eslint-disable-next-line import/no-unresolved
2
- const exec = require('cordova/exec');
3
-
4
- const PLUGIN_NAME = 'SNSMobileSdkCordovaPlugin';
5
-
6
- const LAUNCH_SUMSUB_SDK_ACTION = 'launchSNSMobileSDK';
7
- const SET_NEW_TOKEN_SUMSUB_SDK_ACTION = 'setNewAccessToken';
8
- const DISMISS_ACTION = 'dismiss';
9
-
10
- const SUMSUB_SDK_HANDLERS = {
11
- 'onStatusChanged': null,
12
- 'onEvent': null,
13
- 'onActionResult': 'onActionResultCompleted'
14
- }
15
-
16
- /*
17
- SNSMobileSDK.Builder(apiUrl)
18
- .withAccessToken($token, () => { return new Promise((resolve, reject) => { resolve("..."); })
19
- .withModules([..., ...])
20
- .withDebug(true)
21
- .withHandlers({
22
- onCompleted: () => {},
23
- onError: () => {}
24
- }).launch()
25
- */
26
-
27
- var _currentInstance = null;
28
-
29
- function SNSMobileSDK(sdkConf) {
30
- this.sdkConf = sdkConf
31
-
32
- this.sdkConf.settings["appFrameworkName"] = "cordova";
33
- // this.sdkConf.settings["appFrameworkVersion"] = "...";
34
- }
35
-
36
- SNSMobileSDK.prototype.dismiss = function () {
37
- exec(
38
- (result) => {
39
- },
40
- (error) => {
41
- },
42
- PLUGIN_NAME,
43
- DISMISS_ACTION,
44
- []
45
- );
46
- }
47
-
48
- SNSMobileSDK.prototype.sendEvent = function (name, event) {
49
- var handler = this.sdkConf.handlers[name];
50
-
51
- if (!handler) {
52
- return;
53
- }
54
-
55
- var completionAction = SUMSUB_SDK_HANDLERS[name];
56
-
57
- if (!completionAction) {
58
- handler(event);
59
- return;
60
- }
61
-
62
- var onComplete = function (error, result) {
63
- exec(
64
- (result) => {
65
- },
66
- (error) => {
67
- },
68
- PLUGIN_NAME,
69
- completionAction,
70
- [{
71
- "error": error,
72
- "result": result
73
- }]
74
- );
75
- }
76
-
77
- handler(event)
78
- .then(result => {
79
- onComplete(null, result)
80
- })
81
- .catch(error => {
82
- onComplete(error || new Error("rejected"), null)
83
- })
84
- }
85
-
86
- SNSMobileSDK.prototype.getNewAccessToken = function () {
87
- var onComplete = function (newToken) {
88
- exec(
89
- (result) => {
90
- },
91
- (error) => {
92
- },
93
- PLUGIN_NAME,
94
- SET_NEW_TOKEN_SUMSUB_SDK_ACTION,
95
- [newToken]
96
- );
97
- }
98
-
99
- this.sdkConf.tokenExpirationHandler()
100
- .then(newToken => {
101
- onComplete(newToken)
102
- })
103
- .catch(err => {
104
- console.error(err instanceof Error ? err.message : err)
105
- onComplete(null)
106
- })
107
- }
108
-
109
- SNSMobileSDK.prototype.launch = function () {
110
- let _that = this;
111
- console.log("InSumSub", JSON.stringify(this.sdkConf));
112
- return new Promise((resolve, reject) => {
113
- if (_currentInstance) {
114
- reject(new Error("Aborted since another instance is in use!"));
115
- }
116
- else if (!_that.sdkConf.accessToken) {
117
- reject(new Error('Access token is required'));
118
- }
119
- else {
120
- _currentInstance = _that
121
- exec(
122
- (result) => {
123
- _currentInstance = null
124
- console.log("Promise SumSub Result", JSON.stringify(result));
125
- resolve(result);
126
- },
127
- (error) => {
128
- _currentInstance = null
129
- console.log("Promise SumSub Error", JSON.stringify(error));
130
- reject(error);
131
- },
132
- PLUGIN_NAME,
133
- LAUNCH_SUMSUB_SDK_ACTION,
134
- [_that.sdkConf],
135
- );
136
- }
137
- });
138
- }
139
-
140
- function Builder() {
141
- this.debug = false;
142
- this.handlers = {};
143
- this.applicantConf = {};
144
- this.preferredDocumentDefinitions = {};
145
- this.autoCloseOnApprove = 3;
146
- this.settings = {};
147
- return this;
148
- }
149
-
150
- Builder.prototype.withAccessToken = function (accessToken, expirationHandler) {
151
- this.accessToken = accessToken
152
- if (!expirationHandler || typeof expirationHandler !== 'function') {
153
- throw new Error('Invalid parameter, "expirationHandler" must be a function')
154
- }
155
- this.tokenExpirationHandler = expirationHandler
156
- return this
157
- }
158
-
159
- Builder.prototype.withHandlers = function (handlers) {
160
-
161
- if (!handlers || typeof handlers !== 'object') {
162
- throw new Error('Invalid parameter, "withHandlers" expects a hash')
163
- }
164
-
165
- Object.keys(SUMSUB_SDK_HANDLERS).forEach(name => {
166
- var handler = handlers[name];
167
- if (handler) {
168
- if (typeof handler !== 'function') {
169
- throw new Error('Invalid handler, "'+name+'" must be a function')
170
- }
171
- this.handlers[name] = handler;
172
- }
173
- })
174
-
175
- return this
176
- }
177
-
178
- Builder.prototype.withDebug = function (flag) {
179
- if (typeof flag !== 'boolean') {
180
- throw new Error('Invalid parameter, "withDebug" expects a boolean');
181
- }
182
- this.debug = flag;
183
- return this;
184
- }
185
-
186
- Builder.prototype.withAnalyticsEnabled = function (flag) {
187
- if (typeof flag !== 'boolean') {
188
- throw new Error('Invalid parameter, "withAnalyticsEnabled" expects a boolean');
189
- }
190
- this.isAnalyticsEnabled = flag;
191
- return this;
192
- }
193
-
194
- Builder.prototype.withLocale = function (locale) {
195
- if (typeof locale !== 'string') {
196
- throw new Error('Invalid parameter, "locale" must be a string');
197
- }
198
- this.locale = locale;
199
- return this;
200
- }
201
-
202
- Builder.prototype.withApplicantConf = function (applicantConf) {
203
- if (!applicantConf || typeof applicantConf !== 'object') {
204
- throw new Error('Invalid parameter, "withApplicantConf" expects a hash');
205
- }
206
- this.applicantConf = applicantConf;
207
- return this
208
- }
209
-
210
- Builder.prototype.withPreferredDocumentDefinitions = function (preferredDocumentDefinitions) {
211
- if (!preferredDocumentDefinitions || typeof preferredDocumentDefinitions !== 'object') {
212
- throw new Error('Invalid parameter, "withPreferredDocumentDefinitions" expects a hash');
213
- }
214
- this.preferredDocumentDefinitions = preferredDocumentDefinitions;
215
- return this
216
- }
217
-
218
- Builder.prototype.withSettings = function (settings) {
219
- if (!settings || typeof settings !== 'object') {
220
- throw new Error('Invalid parameter, "withSettings" expects a hash');
221
- }
222
- this.settings = settings;
223
- return this
224
- }
225
-
226
- Builder.prototype.withStrings = function (strings) {
227
-
228
- if (!strings || typeof strings !== 'object') {
229
- throw new Error('Invalid parameter, "withStrings" expects a hash')
230
- }
231
- this.strings = strings;
232
- return this
233
- }
234
-
235
- Builder.prototype.withTheme = function (theme) {
236
- if (!theme || typeof theme !== 'object') {
237
- throw new Error('Invalid parameter, "withTheme" expects a hash')
238
- }
239
- this.theme = theme;
240
- return this
241
- }
242
-
243
- Builder.prototype.withBaseUrl = function (apiUrl) {
244
- if (typeof apiUrl !== 'string') {
245
- throw new Error('Invalid parameter, "baseUrl" must be a string');
246
- }
247
- this.apiUrl = apiUrl;
248
- return this;
249
- }
250
-
251
- Builder.prototype.withAutoCloseOnApprove = function (autoCloseOnApprove) {
252
- if (typeof autoCloseOnApprove !== 'number') {
253
- throw new Error('Invalid parameter, "autoCloseOnApprove" expects a number')
254
- }
255
- this.autoCloseOnApprove = autoCloseOnApprove;
256
- return this
257
- }
258
-
259
- Builder.prototype.build = function () {
260
-
261
- var hasHandlers = {}
262
- Object.keys(this.handlers).forEach(name => {
263
- hasHandlers[name] = true;
264
- })
265
-
266
- return new SNSMobileSDK({
267
- apiUrl: this.apiUrl,
268
- accessToken: this.accessToken,
269
- tokenExpirationHandler: this.tokenExpirationHandler,
270
- handlers: this.handlers,
271
- hasHandlers: hasHandlers,
272
- locale: this.locale,
273
- applicantConf: this.applicantConf,
274
- preferredDocumentDefinitions: this.preferredDocumentDefinitions,
275
- settings: this.settings,
276
- theme: this.theme,
277
- strings: this.strings,
278
- isAnalyticsEnabled: this.isAnalyticsEnabled,
279
- autoCloseOnApprove: this.autoCloseOnApprove,
280
- debug: this.debug,
281
- });
282
- }
283
-
284
-
285
- module.exports = {
286
- init: function (accessToken, expirationHandler) {
287
- return new Builder().withAccessToken(accessToken, expirationHandler)
288
- },
289
- getNewAccessToken: function () {
290
- if (_currentInstance) {
291
- _currentInstance.getNewAccessToken()
292
- }
293
- },
294
- sendEvent: function (name, event) {
295
- if (_currentInstance) {
296
- _currentInstance.sendEvent(name, event)
297
- }
298
- },
299
- reset: function() {
300
- _currentInstance = null
301
- }
302
- };