@sumsub/cordova-idensic-mobile-sdk-plugin 1.19.7 → 1.20.3
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.
- package/dist/SNSMobileSDK.js +1 -1
- package/package.json +1 -1
- package/plugin.xml +12 -5
- package/scripts/android/after_plugin_install.js +24 -0
- package/scripts/ios/before_plugin_install.js +23 -9
- package/src/android/build-extras.gradle +4 -5
- package/src/android/build.gradle +3 -11
- package/src/android/src/main/java/com/sumsub/msdk/plugins/cordova/SNSMobileSdkCordovaPlugin.java +42 -27
- package/src/ios/SNSMobileSdkCordovaPlugin.m +8 -0
- package/www/SNSMobileSDK.js +19 -4
package/dist/SNSMobileSDK.js
CHANGED
|
@@ -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
|
|
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}])}));
|
package/package.json
CHANGED
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.
|
|
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">
|
|
3
3
|
|
|
4
4
|
<name>cordova-idensic-mobile-sdk-plugin</name>
|
|
5
5
|
<description>Cordova plugin exposing SumSub Mobile SDK</description>
|
|
@@ -20,9 +20,9 @@
|
|
|
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="
|
|
24
|
-
<preference name="android-compileSdkVersion" value="
|
|
25
|
-
<preference name="android-buildToolsVersion" value="
|
|
23
|
+
<preference name="android-targetSdkVersion" value="33" />
|
|
24
|
+
<preference name="android-compileSdkVersion" value="33" />
|
|
25
|
+
<preference name="android-buildToolsVersion" value="33.0.0" />
|
|
26
26
|
</config-file>
|
|
27
27
|
|
|
28
28
|
<config-file target="AndroidManifest.xml" parent="/*">
|
|
@@ -36,11 +36,14 @@
|
|
|
36
36
|
</config-file>
|
|
37
37
|
<config-file parent="/*" target="AndroidManifest.xml" />
|
|
38
38
|
|
|
39
|
+
<hook type="after_plugin_install" src="scripts/android/after_plugin_install.js" />
|
|
40
|
+
|
|
39
41
|
<!-- source-file -->
|
|
40
42
|
<source-file src="src/android/src/main/java/com/sumsub/msdk/plugins/cordova/SNSMobileSdkCordovaPlugin.java" target-dir="src/main/java/com/sumsub/msdk/plugins/cordova" />
|
|
41
43
|
|
|
42
44
|
<!-- framework h -->
|
|
43
45
|
<framework src="src/android/build-extras.gradle" custom="true" type="gradleReference" />
|
|
46
|
+
|
|
44
47
|
</platform>
|
|
45
48
|
|
|
46
49
|
<platform name="ios">
|
|
@@ -48,6 +51,7 @@
|
|
|
48
51
|
<preference name="CAMERA_USAGE" default="Let us take a photo" />
|
|
49
52
|
<preference name="MICROPHONE_USAGE" default="Time to record a video" />
|
|
50
53
|
<preference name="PHOTO_USAGE" default="Let us pick a photo" />
|
|
54
|
+
<preference name="LOCATION_USAGE" default="Please provide us with your geolocation data to prove your current location" />
|
|
51
55
|
|
|
52
56
|
<config-file target="*-Info.plist" parent="NSCameraUsageDescription">
|
|
53
57
|
<string>$CAMERA_USAGE</string>
|
|
@@ -58,6 +62,9 @@
|
|
|
58
62
|
<config-file target="*-Info.plist" parent="NSPhotoLibraryUsageDescription">
|
|
59
63
|
<string>$PHOTO_USAGE</string>
|
|
60
64
|
</config-file>
|
|
65
|
+
<config-file target="*-Info.plist" parent="NSLocationWhenInUseUsageDescription">
|
|
66
|
+
<string>$LOCATION_USAGE</string>
|
|
67
|
+
</config-file>
|
|
61
68
|
|
|
62
69
|
<config-file target="config.xml" parent="/*">
|
|
63
70
|
<feature name="SNSMobileSdkCordovaPlugin">
|
|
@@ -71,7 +78,7 @@
|
|
|
71
78
|
<source url="https://cdn.cocoapods.org/"/>
|
|
72
79
|
</config>
|
|
73
80
|
<pods>
|
|
74
|
-
<pod name="IdensicMobileSDK" spec="=1.
|
|
81
|
+
<pod name="IdensicMobileSDK" spec="=1.20.2" />
|
|
75
82
|
</pods>
|
|
76
83
|
</podspec>
|
|
77
84
|
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var fs = require('fs');
|
|
4
|
+
|
|
5
|
+
module.exports = function (context) {
|
|
6
|
+
|
|
7
|
+
var withVideoIdent = process.argv.includes('--with-VideoIdent')
|
|
8
|
+
|
|
9
|
+
if (!withVideoIdent) {
|
|
10
|
+
return
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
var gradleExtrasFilePath = './platforms/android/cordova-idensic-mobile-sdk-plugin/SumSubCordova-build-extras.gradle'
|
|
14
|
+
|
|
15
|
+
fs.readFile(gradleExtrasFilePath, 'utf8', function (err,data) {
|
|
16
|
+
|
|
17
|
+
var formatted = data.replace(/^\/\/(\s+implementation\s.+videoident.+)$/m, "$1");
|
|
18
|
+
|
|
19
|
+
fs.writeFile(gradleExtrasFilePath, formatted, 'utf8', function (err) {
|
|
20
|
+
if (err) return console.log(err);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
23
|
+
|
|
24
|
+
}
|
|
@@ -4,18 +4,16 @@ var fs = require('fs');
|
|
|
4
4
|
|
|
5
5
|
module.exports = function (context) {
|
|
6
6
|
|
|
7
|
-
var
|
|
7
|
+
var withMRTDReader = process.argv.includes('--with-MRTDReader')
|
|
8
|
+
var withVideoIdent = process.argv.includes('--with-VideoIdent')
|
|
9
|
+
var withVideoIdentLatest = process.argv.includes('--with-VideoIdent-latest')
|
|
10
|
+
|
|
11
|
+
withVideoIdent = withVideoIdent || withVideoIdentLatest
|
|
8
12
|
|
|
9
|
-
if (!
|
|
13
|
+
if (!withMRTDReader && !withVideoIdent) {
|
|
10
14
|
return
|
|
11
15
|
}
|
|
12
16
|
|
|
13
|
-
// if (process.argv.join("|").indexOf("POD_NAME=") > -1) {
|
|
14
|
-
// POD_NAME = process.argv.join("|").match(/POD_NAME=(.*?)(\||$)/)[1]
|
|
15
|
-
// } else {
|
|
16
|
-
// return
|
|
17
|
-
// }
|
|
18
|
-
|
|
19
17
|
var podfilePath = './platforms/ios/Podfile'
|
|
20
18
|
|
|
21
19
|
fs.stat(podfilePath, function (error, stat) {
|
|
@@ -24,8 +22,24 @@ module.exports = function (context) {
|
|
|
24
22
|
}
|
|
25
23
|
|
|
26
24
|
var podfileContent = fs.readFileSync(podfilePath, 'utf8')
|
|
25
|
+
var podLineRe = /^.*IdensicMobileSDK.*$/m
|
|
26
|
+
|
|
27
|
+
var matches = podfileContent.match(podLineRe)
|
|
28
|
+
if (!matches) {
|
|
29
|
+
return
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
var podLine = matches[0]
|
|
33
|
+
var replaces = [podLine]
|
|
34
|
+
|
|
35
|
+
if (withMRTDReader) {
|
|
36
|
+
replaces.push(podLine.replace(/IdensicMobileSDK/, 'IdensicMobileSDK/MRTDReader'))
|
|
37
|
+
}
|
|
38
|
+
if (withVideoIdent) {
|
|
39
|
+
replaces.push(podLine.replace(/IdensicMobileSDK/, 'IdensicMobileSDK/VideoIdent' + (withVideoIdentLatest ? "-latest" : "")))
|
|
40
|
+
}
|
|
27
41
|
|
|
28
|
-
podfileContent = podfileContent.replace(
|
|
42
|
+
podfileContent = podfileContent.replace(podLineRe, replaces.join("\n"))
|
|
29
43
|
|
|
30
44
|
fs.writeFileSync(podfilePath, podfileContent, 'utf8')
|
|
31
45
|
})
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
buildscript {
|
|
2
2
|
repositories {
|
|
3
3
|
google()
|
|
4
|
-
jcenter()
|
|
5
4
|
mavenCentral()
|
|
6
5
|
}
|
|
7
6
|
}
|
|
@@ -10,13 +9,13 @@ allprojects {
|
|
|
10
9
|
repositories {
|
|
11
10
|
maven { url "https://maven.sumsub.com/repository/maven-public/" }
|
|
12
11
|
google()
|
|
13
|
-
jcenter()
|
|
14
12
|
mavenCentral()
|
|
15
13
|
}
|
|
16
14
|
}
|
|
17
15
|
|
|
18
16
|
dependencies {
|
|
19
|
-
implementation "com.sumsub.sns:idensic-mobile-sdk:1.
|
|
20
|
-
implementation "com.sumsub.sns:idensic-mobile-sdk-prooface:1.
|
|
21
|
-
implementation
|
|
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'
|
|
22
21
|
}
|
package/src/android/build.gradle
CHANGED
|
@@ -2,7 +2,6 @@ buildscript {
|
|
|
2
2
|
apply from: rootProject.file("dependencies.gradle")
|
|
3
3
|
repositories {
|
|
4
4
|
google()
|
|
5
|
-
jcenter()
|
|
6
5
|
mavelCentral()
|
|
7
6
|
}
|
|
8
7
|
dependencies {
|
|
@@ -18,22 +17,18 @@ plugins {
|
|
|
18
17
|
|
|
19
18
|
apply plugin: 'com.android.library'
|
|
20
19
|
|
|
21
|
-
sourceCompatibility = 1.8
|
|
22
|
-
targetCompatibility = 1.8
|
|
23
|
-
|
|
24
20
|
rootProject.allprojects {
|
|
25
21
|
repositories {
|
|
26
22
|
google()
|
|
27
|
-
jcenter()
|
|
28
23
|
maven { url "https://maven.sumsub.com/repository/maven-public/" }
|
|
29
24
|
}
|
|
30
25
|
}
|
|
31
26
|
|
|
32
27
|
android {
|
|
33
|
-
compileSdkVersion
|
|
28
|
+
compileSdkVersion 33
|
|
34
29
|
defaultConfig {
|
|
35
30
|
minSdkVersion 21
|
|
36
|
-
targetSdkVersion
|
|
31
|
+
targetSdkVersion 33
|
|
37
32
|
versionCode 1
|
|
38
33
|
versionName "1.0"
|
|
39
34
|
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
@@ -47,9 +42,6 @@ android {
|
|
|
47
42
|
}
|
|
48
43
|
|
|
49
44
|
dependencies {
|
|
50
|
-
implementation
|
|
51
|
-
implementation "com.sumsub.sns:idensic-mobile-sdk-prooface:1.19.7"
|
|
52
|
-
|
|
53
|
-
implementation 'com.google.android.material:material:1.3.0'
|
|
45
|
+
implementation 'com.google.android.material:material:1.7.0'
|
|
54
46
|
implementation 'org.apache.cordova:framework:8.1.0'
|
|
55
47
|
}
|
package/src/android/src/main/java/com/sumsub/msdk/plugins/cordova/SNSMobileSdkCordovaPlugin.java
CHANGED
|
@@ -4,42 +4,37 @@ import android.content.Intent;
|
|
|
4
4
|
import android.text.TextUtils;
|
|
5
5
|
import android.util.Log;
|
|
6
6
|
import android.webkit.ValueCallback;
|
|
7
|
-
|
|
8
|
-
import
|
|
7
|
+
|
|
8
|
+
import androidx.annotation.Nullable;
|
|
9
|
+
|
|
9
10
|
import com.sumsub.sns.R;
|
|
10
11
|
import com.sumsub.sns.core.SNSActionResult;
|
|
11
12
|
import com.sumsub.sns.core.SNSMobileSDK;
|
|
12
13
|
import com.sumsub.sns.core.data.listener.SNSActionResultHandler;
|
|
13
14
|
import com.sumsub.sns.core.data.listener.SNSCompleteHandler;
|
|
14
15
|
import com.sumsub.sns.core.data.listener.SNSErrorHandler;
|
|
15
|
-
import com.sumsub.sns.core.data.listener.SNSEvent;
|
|
16
16
|
import com.sumsub.sns.core.data.listener.SNSEventHandler;
|
|
17
|
+
import com.sumsub.sns.core.data.listener.SNSIconHandler;
|
|
17
18
|
import com.sumsub.sns.core.data.listener.SNSStateChangedHandler;
|
|
18
|
-
import com.sumsub.sns.core.data.listener.TokenExpirationHandler;
|
|
19
19
|
import com.sumsub.sns.core.data.model.SNSCompletionResult;
|
|
20
|
-
import com.sumsub.sns.core.data.model.
|
|
20
|
+
import com.sumsub.sns.core.data.model.SNSInitConfig;
|
|
21
21
|
import com.sumsub.sns.core.data.model.SNSSDKState;
|
|
22
22
|
import com.sumsub.sns.core.data.model.SNSSupportItem;
|
|
23
|
-
import com.sumsub.sns.core.
|
|
24
|
-
import com.sumsub.sns.core.data.model.SNSInitConfig;
|
|
23
|
+
import com.sumsub.sns.core.theme.SNSCustomizationFileFormat;
|
|
25
24
|
import com.sumsub.sns.prooface.SNSProoface;
|
|
26
25
|
|
|
27
26
|
import org.apache.cordova.CallbackContext;
|
|
28
27
|
import org.apache.cordova.CordovaPlugin;
|
|
29
|
-
import org.jetbrains.annotations.NotNull;
|
|
30
28
|
import org.json.JSONArray;
|
|
31
29
|
import org.json.JSONException;
|
|
32
30
|
import org.json.JSONObject;
|
|
33
31
|
|
|
34
|
-
import java.util
|
|
35
|
-
|
|
36
|
-
import
|
|
37
|
-
import
|
|
38
|
-
import
|
|
39
|
-
import
|
|
40
|
-
import timber.log.Timber;
|
|
41
|
-
|
|
42
|
-
import com.sumsub.sns.core.theme.SNSCustomizationFileFormat;
|
|
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;
|
|
43
38
|
|
|
44
39
|
public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
|
|
45
40
|
private static final String LAUNCH_ACTION = "launchSNSMobileSDK";
|
|
@@ -47,13 +42,15 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
|
|
|
47
42
|
private static final String ACTION_COMPLETED_ACTION = "onActionResultCompleted";
|
|
48
43
|
private static final String DISMISS_ACTION = "dismiss";
|
|
49
44
|
|
|
45
|
+
private static final String TAG = "SumSubCordovaPlugin";
|
|
46
|
+
|
|
50
47
|
private static volatile String newAccessToken = null;
|
|
51
48
|
private static SNSMobileSDK.SDK snsSdk;
|
|
52
49
|
private volatile static SNSActionResult actionResultHandlerComplete;
|
|
53
50
|
|
|
54
51
|
@Override
|
|
55
52
|
public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
|
|
56
|
-
|
|
53
|
+
Log.d(TAG, "execute: " + action + " args: " + args);
|
|
57
54
|
if (action.equals(LAUNCH_ACTION)) {
|
|
58
55
|
if (args.isNull(0)) {
|
|
59
56
|
callbackContext.error("Error: SDK Config object must be provided");
|
|
@@ -73,6 +70,8 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
|
|
|
73
70
|
JSONObject theme = conf.optJSONObject("theme");
|
|
74
71
|
String phone = applicantConf.optString("phone");
|
|
75
72
|
String email = applicantConf.optString("email");
|
|
73
|
+
JSONObject strings = conf.optJSONObject("strings");
|
|
74
|
+
boolean isAnalyticsEnabled = !(conf.has("isAnalyticsEnabled") && !conf.optBoolean("isAnalyticsEnabled"));
|
|
76
75
|
|
|
77
76
|
if (TextUtils.isEmpty(supportEmail)) {
|
|
78
77
|
supportEmail = "support@sumsub.com";
|
|
@@ -85,7 +84,7 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
|
|
|
85
84
|
if (TextUtils.isEmpty(locale)) {
|
|
86
85
|
locale = Locale.getDefault().getLanguage();
|
|
87
86
|
}
|
|
88
|
-
this.launchSNSMobileSDK(apiUrl, flowName, accessToken, supportEmail, email, phone, locale, isDebug, theme, settings, hasHandlers, callbackContext);
|
|
87
|
+
this.launchSNSMobileSDK(apiUrl, flowName, accessToken, supportEmail, email, phone, locale, isDebug, theme, settings, strings, isAnalyticsEnabled, hasHandlers, callbackContext);
|
|
89
88
|
return true;
|
|
90
89
|
} else if (action.equals(NEW_TOKEN_ACTION)) {
|
|
91
90
|
newAccessToken = args.getString(0);
|
|
@@ -139,7 +138,22 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
|
|
|
139
138
|
});
|
|
140
139
|
}
|
|
141
140
|
|
|
142
|
-
private void launchSNSMobileSDK(
|
|
141
|
+
private void launchSNSMobileSDK(
|
|
142
|
+
final String apiUrl,
|
|
143
|
+
final String flowName,
|
|
144
|
+
final String accessToken,
|
|
145
|
+
String supportEmail,
|
|
146
|
+
String email,
|
|
147
|
+
String phone,
|
|
148
|
+
final String locale,
|
|
149
|
+
final boolean isDebug,
|
|
150
|
+
final JSONObject theme,
|
|
151
|
+
final JSONObject settings,
|
|
152
|
+
final JSONObject strings,
|
|
153
|
+
final boolean isAnalyticsEnabled,
|
|
154
|
+
final JSONObject hasHandlers,
|
|
155
|
+
CallbackContext callbackContext
|
|
156
|
+
) {
|
|
143
157
|
|
|
144
158
|
cordova.getActivity().runOnUiThread(new Runnable() {
|
|
145
159
|
@Override
|
|
@@ -149,7 +163,7 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
|
|
|
149
163
|
|
|
150
164
|
final SNSActionResultHandler actionResultHandler = hasHandlers.optBoolean("onActionResult") ?
|
|
151
165
|
(actionId, actionType, answer, allowContinuing) -> {
|
|
152
|
-
|
|
166
|
+
Log.d(TAG, "Calling onActionResult(" + actionId + ", " + answer + ")");
|
|
153
167
|
actionResultHandlerComplete = null;
|
|
154
168
|
requestActionResult(actionId, answer, actionType, allowContinuing);
|
|
155
169
|
int cnt = 0;
|
|
@@ -163,11 +177,11 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
|
|
|
163
177
|
return SNSActionResult.Continue;
|
|
164
178
|
}
|
|
165
179
|
}
|
|
166
|
-
|
|
180
|
+
Log.d(TAG, "SumSub: Received: " + actionResultHandlerComplete + ' ' + Thread.currentThread().getName());
|
|
167
181
|
return actionResultHandlerComplete;
|
|
168
182
|
} : null;
|
|
169
183
|
|
|
170
|
-
final SNSErrorHandler errorHandler = e ->
|
|
184
|
+
final SNSErrorHandler errorHandler = e -> Log.d(TAG, Log.getStackTraceString(e));
|
|
171
185
|
|
|
172
186
|
final SNSStateChangedHandler stateChangedHandler = (oldState, newState) -> {
|
|
173
187
|
final String newStatus = newState.getClass().getSimpleName();
|
|
@@ -237,7 +251,7 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
|
|
|
237
251
|
}
|
|
238
252
|
snsSdk = snsSdkBuilder
|
|
239
253
|
.withAccessToken(accessToken, () -> {
|
|
240
|
-
|
|
254
|
+
Log.d(TAG, "SumSub: calling onTokenExpired!");
|
|
241
255
|
newAccessToken = null;
|
|
242
256
|
requestNewAccessToken();
|
|
243
257
|
int cnt = 0;
|
|
@@ -251,7 +265,7 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
|
|
|
251
265
|
return null;
|
|
252
266
|
}
|
|
253
267
|
}
|
|
254
|
-
|
|
268
|
+
Log.d(TAG, "SumSub: Received new token: " + newAccessToken + ' ' + Thread.currentThread().getName());
|
|
255
269
|
return newAccessToken;
|
|
256
270
|
})
|
|
257
271
|
.withDebug(isDebug)
|
|
@@ -264,11 +278,12 @@ public class SNSMobileSdkCordovaPlugin extends CordovaPlugin {
|
|
|
264
278
|
.withSupportItems(Collections.singletonList(supportItem))
|
|
265
279
|
.withLocale(new Locale(locale))
|
|
266
280
|
.withSettings(toMap(settings))
|
|
267
|
-
.
|
|
281
|
+
.withAnalyticsEnabled(isAnalyticsEnabled)
|
|
282
|
+
.withConf(new SNSInitConfig(email, phone, strings != null ? toMap(strings) : null))
|
|
268
283
|
.build();
|
|
269
284
|
snsSdk.launch();
|
|
270
285
|
} catch (Exception e) {
|
|
271
|
-
|
|
286
|
+
Log.e(TAG, "Exception: " + e);
|
|
272
287
|
callbackContext.error("Error:" + e.getMessage());
|
|
273
288
|
}
|
|
274
289
|
|
|
@@ -56,10 +56,18 @@
|
|
|
56
56
|
sdk.logLevel = SNSLogLevel_Debug;
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
+
if (params[@"isAnalyticsEnabled"]) {
|
|
60
|
+
sdk.isAnalyticsEnabled = [params[@"isAnalyticsEnabled"] boolValue];
|
|
61
|
+
}
|
|
62
|
+
|
|
59
63
|
if (params[@"settings"]) {
|
|
60
64
|
sdk.settings = params[@"settings"];
|
|
61
65
|
}
|
|
62
66
|
|
|
67
|
+
if (params[@"strings"]) {
|
|
68
|
+
sdk.strings = params[@"strings"];
|
|
69
|
+
}
|
|
70
|
+
|
|
63
71
|
if (params[@"applicantConf"][@"email"]) {
|
|
64
72
|
sdk.initialEmail = params[@"applicantConf"][@"email"];
|
|
65
73
|
}
|
package/www/SNSMobileSDK.js
CHANGED
|
@@ -187,6 +187,14 @@ Builder.prototype.withDebug = function (flag) {
|
|
|
187
187
|
return this;
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
+
Builder.prototype.withAnalyticsEnabled = function (flag) {
|
|
191
|
+
if (typeof flag !== 'boolean') {
|
|
192
|
+
throw new Error('Invalid parameter, "withAnalyticsEnabled" expects a boolean');
|
|
193
|
+
}
|
|
194
|
+
this.isAnalyticsEnabled = flag;
|
|
195
|
+
return this;
|
|
196
|
+
}
|
|
197
|
+
|
|
190
198
|
Builder.prototype.withLocale = function (locale) {
|
|
191
199
|
if (typeof locale !== 'string') {
|
|
192
200
|
throw new Error('Invalid parameter, "locale" must be a string');
|
|
@@ -211,6 +219,15 @@ Builder.prototype.withApplicantConf = function (applicantConf) {
|
|
|
211
219
|
return this
|
|
212
220
|
}
|
|
213
221
|
|
|
222
|
+
Builder.prototype.withStrings = function (strings) {
|
|
223
|
+
|
|
224
|
+
if (!strings || typeof strings !== 'object') {
|
|
225
|
+
throw new Error('Invalid parameter, "withStrings" expects a hash')
|
|
226
|
+
}
|
|
227
|
+
this.strings = strings;
|
|
228
|
+
return this
|
|
229
|
+
}
|
|
230
|
+
|
|
214
231
|
Builder.prototype.withTheme = function (theme) {
|
|
215
232
|
if (!theme || typeof theme !== 'object') {
|
|
216
233
|
throw new Error('Invalid parameter, "withTheme" expects a hash')
|
|
@@ -227,10 +244,6 @@ Builder.prototype.withBaseUrl = function (apiUrl) {
|
|
|
227
244
|
return this;
|
|
228
245
|
}
|
|
229
246
|
|
|
230
|
-
Builder.prototype.onTestEnv = function () {
|
|
231
|
-
return this.withBaseUrl("https://test-api.sumsub.com")
|
|
232
|
-
}
|
|
233
|
-
|
|
234
247
|
Builder.prototype.build = function () {
|
|
235
248
|
|
|
236
249
|
var hasHandlers = {}
|
|
@@ -249,6 +262,8 @@ Builder.prototype.build = function () {
|
|
|
249
262
|
supportEmail: this.supportEmail,
|
|
250
263
|
applicantConf: this.applicantConf,
|
|
251
264
|
theme: this.theme,
|
|
265
|
+
strings: this.strings,
|
|
266
|
+
isAnalyticsEnabled: this.isAnalyticsEnabled,
|
|
252
267
|
debug: this.debug
|
|
253
268
|
});
|
|
254
269
|
}
|