@idnow/react-idcheckio 7.1.11

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/.gitattributes ADDED
@@ -0,0 +1 @@
1
+ *.pbxproj -text
package/README.md ADDED
@@ -0,0 +1,234 @@
1
+ # IDCheckIO SDK - ReactNative module
2
+
3
+ ## Getting started
4
+
5
+ #### Local setup for react-idcheckio
6
+ See [GitHub documentation](https://github.com/ariadnext/React-Native-SmartSDK/tree/master/react-idcheckio#getting-started) for setting up the local library.
7
+
8
+ ### Install from NPM
9
+ ```
10
+ // with npm
11
+ npm install react-idcheckio
12
+
13
+ // with yarn
14
+ yarn add react-idcheckio
15
+ ```
16
+
17
+ ## Platform specific configuration
18
+
19
+ #### iOS
20
+
21
+ 1. In your project folder, go to your ios directory and open the Podfile :
22
+ - Change the minimum version to at least '10.0'
23
+ - Add the following lines before the target :
24
+ ```
25
+ source 'https://github.com/CocoaPods/Specs.git'
26
+ source 'https://git-externe.rennes.ariadnext.com/idcheckio/axt-podspecs.git'
27
+ ```
28
+ - Add `use_frameworks!` before the `use_native_modules!`
29
+
30
+ 2. Retrieve the sdk using `pod install --repo-update`
31
+ - ⚠️⚠️   You will need to have a .netrc file configurated with our credentials. Check the official documentation for more informations.  ⚠️⚠️
32
+
33
+ 3. In your project, open the `*.plist` file and the two following entries :
34
+ - "Privacy - Camera Usage Description" : "Camera is being used to scan documents"
35
+
36
+ #### Android
37
+
38
+ 1. Insert the following lines inside the dependencies block in `android/app/build.gradle`:
39
+ ```groovy
40
+ implementation 'androidx.multidex:multidex:2.0.1'
41
+ ```
42
+ - In the `android.defaultConfig` block, add the line `multiDexEnabled true`
43
+ - In the `android` block, add the following lines :
44
+ ```groovy
45
+ packagingOptions {
46
+ pickFirst '**/armeabi-v7a/libc++_shared.so'
47
+ pickFirst '**/x86/libc++_shared.so'
48
+ pickFirst '**/arm64-v8a/libc++_shared.so'
49
+ pickFirst '**/x86_64/libc++_shared.so'
50
+ pickFirst '**/x86/libjsc.so'
51
+ pickFirst '**/armeabi-v7a/libjsc.so'
52
+ pickFirst 'META-INF/DEPENDENCIES'
53
+ pickFirst 'META-INF/notice.txt'
54
+ pickFirst 'META-INF/license.txt'
55
+ }
56
+ ```
57
+
58
+ 2. Add a new maven repository to retrieve the sdk from our nexus. If you have in your main `build.gradle` an `allprojects{}` block containing your repositories, add the following lines in it else add them in the plugin's `build.gradle` :
59
+ ```groovy
60
+ maven {
61
+ credentials {
62
+ username = "$YOUR_USERNAME"
63
+ password = "$YOUR_PASSWORD"
64
+ }
65
+ url "https://repoman.rennes.ariadnext.com/content/repositories/com.ariadnext.idcheckio/"
66
+ }
67
+ ```
68
+
69
+ ## Usage
70
+
71
+ 1. Create a file `IdcheckioModule.js` and copy the following lines :
72
+ ```javascript
73
+ 'use strict';
74
+ import { NativeModules } from 'react-native';
75
+ module.exports = NativeModules.IdcheckioModule;
76
+ ```
77
+
78
+ 2. Open your `index.js` or any other files where you want to use the IdcheckioModule and add `import IdcheckioModule from './IdcheckioModule';` to the imports at the top of the file.
79
+
80
+ 3. (Optional) Before starting, the sdk will ask for permissions (`CAMERA`). But you can if you want ask them by youself before using the following method :
81
+ ```javascript
82
+ async requestPermissions() {
83
+ try {
84
+ const granted = await PermissionsAndroid.requestMultiple(
85
+ [PermissionsAndroid.PERMISSIONS.CAMERA]
86
+ )
87
+ if (granted[PermissionsAndroid.PERMISSIONS.CAMERA] === PermissionsAndroid.RESULTS.GRANTED) {} else {
88
+ console.log("Permission denied")
89
+ }
90
+ } catch (err) {
91
+ console.warn(err);
92
+ }
93
+ }
94
+ ```
95
+
96
+ 4. Before doing any call to the sdk, you can use the `preload()` method. It will accelerate the future call the to the capture process. You won't receive any callback when calling this method.
97
+ ```javascript
98
+ preload() {
99
+ IdcheckioModule.preload(true);
100
+ }
101
+ ```
102
+
103
+ 5. Before capturing any document, you need to activate the sdk. To do so, add your activation token on the javascript side and use it to call the `activate()` method.
104
+ ```javascript
105
+ activate() {
106
+ IdcheckioModule.activate(demoToken, true)
107
+ .then(data => {
108
+ this.setState({sdkActivated: true})
109
+ console.log("Activated");
110
+ },
111
+ cause => {
112
+ this.showError(cause);
113
+ })
114
+ .catch(err => {
115
+ console.log(err);
116
+ });
117
+ }
118
+ ```
119
+
120
+ 6. To start the capture of a document, you have to call the start method with your wanted parameters. Check the `Dictionnary.js` file to find some recommandations on the parameters. You will then receive the result in a string that can be parse into a json object.
121
+ ```javascript
122
+ export const paramsIDOffline = new IDCheckioParamsBuilder()
123
+ .setDocType(DocumentType.ID)
124
+ .setOrientation(IDCheckioOrientation.PORTRAIT)
125
+ .setUseHd(false)
126
+ .setConfirmationType(ConfirmationType.DATA_OR_PICTURE)
127
+ .setScanBothSides(ScanBothSides.ENABLED)
128
+ .setSideOneExtraction(new Extraction(Codeline.VALID, FaceDetection.ENABLED))
129
+ .setSideTwoExtraction(new Extraction(Codeline.REJECT, FaceDetection.DISABLED))
130
+ .setLanguage(Language.fr)
131
+ .setManualButtonTimer(10)
132
+ .setMaxPictureFilesize(FileSize.TWO_MEGA_BYTES)
133
+ .setFeedbackLevel(FeedbackLevel.ALL)
134
+ .setAdjustCrop(false)
135
+ .setConfirmAbort(false)
136
+ .build()
137
+
138
+ IdcheckioModule.start(Dictionnary.paramsIDOffline)
139
+ .then(data => {
140
+ results = JSON.parse(data);
141
+ this.response_server(results);
142
+ },
143
+ cause => {
144
+ this.showError(cause);
145
+ })
146
+ .catch(err => {
147
+ console.log(err);
148
+ });
149
+ ```
150
+
151
+ 7. To start an online capture of a document, you have the method the `startOnline()` method. You will receive the result in a string that can be parse into a json object.
152
+ ```javascript
153
+ export const paramsLiveness = new IDCheckioParamsBuilder()
154
+ .setDocType(DocumentType.LIVENESS)
155
+ .setOrientation(IDCheckioOrientation.PORTRAIT)
156
+ .setConfirmAbort(true)
157
+ .build()
158
+
159
+ IdcheckioModule.startOnline(paramsLiveness, onlineContext)
160
+ .then(data => {
161
+ console.log(data);
162
+ let results = JSON.parse(data)
163
+ this.response_server(results);
164
+ },
165
+ cause => {
166
+ this.showError(cause);
167
+ })
168
+ .catch(err => {
169
+ console.log(err);
170
+ });
171
+ ```
172
+
173
+ 8. To just analyze a document, you have the method the `analyze()` method. You will receive the result in a string that can be parse into a json object.
174
+ ```javascript
175
+ analyze(params, onlineContext){
176
+ const options = {
177
+ title: 'Select Document',
178
+ storageOptions: {
179
+ skipBackup: true,
180
+ path: 'images',
181
+ },
182
+ };
183
+
184
+ launchImageLibrary(options, (response) => {
185
+ if (response.didCancel) {
186
+ console.log('User cancelled image picker');
187
+ } else if (response.error) {
188
+ console.log('ImagePicker Error: ', response.error);
189
+ } else if (response.customButton) {
190
+ console.log('User tapped custom button: ', response.customButton);
191
+ } else {
192
+ const source = { uri: response.assets[0].uri };
193
+ // You can also display the image using data:
194
+ // const source = { uri: 'data:image/jpeg;base64,' + response.data };
195
+ IdcheckioModule.analyze(params, source.uri, null, true, onlineContext)
196
+ .then(data => {
197
+ console.log(data);
198
+ let results = JSON.parse(data)
199
+ this.response_server(results);
200
+ },
201
+ cause => {
202
+ this.showError(cause);
203
+ })
204
+ .catch(err => {
205
+ console.log(err);
206
+ });
207
+ }
208
+ });
209
+ }
210
+ ```
211
+
212
+ 9. To handle error, you can parse the message of the error and use this object to do some error handling. To know a bit more about the error system in the sdk, look at `4.2.10. IdcheckioError` in the developer's guide.
213
+ ```javascript
214
+ showError(error) {
215
+ console.log(error);
216
+ var errorMsg = JSON.parse(error.message.replace("\n", "\\n"));
217
+ console.log("cause: " + errorMsg.cause);
218
+ console.log("details: " + errorMsg.details);
219
+ console.log("message: " + errorMsg.message);
220
+ console.log("subCause: " + errorMsg.subCause);
221
+ alert(errorMsg.message);
222
+ }
223
+ ```
224
+
225
+ ## Theming
226
+
227
+ If you want to change the colors of the sdk to match your theme, it's possible !
228
+ You need to first create an IDCheckTheme() object with your own colors and then add it in the builder in the theme parameter.
229
+ ```javascript
230
+ new IDCheckTheme({primaryColor: "#FF0000B7", foregroundColor: "#FFFFFFFF", backgroundColor: "#FFFFFFFF", borderColor: "#FF0000B7"})
231
+ ```
232
+
233
+
234
+ - ✅   To learn more informations on those methods and theirs parameters. Please refer to the official IDCheck.io sdk documentation.
@@ -0,0 +1,15 @@
1
+ Pod::Spec.new do |s|
2
+ s.name = "ReactIdcheckio"
3
+ s.version = "7.1.11"
4
+ s.summary = "React Native plugin for IDCheck.io Mobile SDK for iOS"
5
+ s.homepage = "https://www.github.com//react-idcheckio"
6
+ s.license = { :type => "ISC" }
7
+ s.authors = { "" => "" }
8
+ s.platform = :ios, "10.0"
9
+ s.source = { :path => "." }
10
+ s.source_files = "ios", "ios/**/*.{h,m,swift}"
11
+ s.swift_version = '5.7'
12
+
13
+ s.dependency 'React'
14
+ s.dependency 'IDCheckIOSDK', '~> 7.1.9'
15
+ end
@@ -0,0 +1,17 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <projectDescription>
3
+ <name>android_</name>
4
+ <comment>Project android_ created by Buildship.</comment>
5
+ <projects>
6
+ </projects>
7
+ <buildSpec>
8
+ <buildCommand>
9
+ <name>org.eclipse.buildship.core.gradleprojectbuilder</name>
10
+ <arguments>
11
+ </arguments>
12
+ </buildCommand>
13
+ </buildSpec>
14
+ <natures>
15
+ <nature>org.eclipse.buildship.core.gradleprojectnature</nature>
16
+ </natures>
17
+ </projectDescription>
@@ -0,0 +1,13 @@
1
+ arguments=
2
+ auto.sync=false
3
+ build.scans.enabled=false
4
+ connection.gradle.distribution=GRADLE_DISTRIBUTION(VERSION(5.6.1))
5
+ connection.project.dir=
6
+ eclipse.preferences.version=1
7
+ gradle.user.home=
8
+ java.home=
9
+ jvm.arguments=
10
+ offline.mode=false
11
+ override.workspace.settings=true
12
+ show.console.view=true
13
+ show.executions.view=true
@@ -0,0 +1,51 @@
1
+ buildscript {
2
+ ext.safeExtGet = {prop, fallback ->
3
+ rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
4
+ }
5
+ repositories {
6
+ google()
7
+ jcenter()
8
+ }
9
+
10
+ dependencies {
11
+ // Matches recent template from React Native (0.60)
12
+ // https://github.com/facebook/react-native/blob/0.60-stable/template/android/build.gradle#L16
13
+ classpath("com.android.tools.build:gradle:${safeExtGet('gradlePluginVersion', '3.4.1')}")
14
+ }
15
+ }
16
+
17
+ apply plugin: 'com.android.library'
18
+
19
+ android {
20
+ compileSdkVersion safeExtGet('compileSdkVersion', 31)
21
+
22
+ defaultConfig {
23
+ minSdkVersion safeExtGet('minSdkVersion', 21)
24
+ targetSdkVersion safeExtGet('targetSdkVersion', 31)
25
+ versionCode 1
26
+ multiDexEnabled true
27
+ versionName "1.0"
28
+ }
29
+ }
30
+
31
+ repositories {
32
+ mavenLocal()
33
+ maven {
34
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
35
+ url("$rootDir/../node_modules/react-native/android")
36
+ }
37
+ maven {
38
+ // Android JSC is installed from npm
39
+ url("$rootDir/../node_modules/jsc-android/dist")
40
+ }
41
+ google()
42
+ jcenter()
43
+ maven { url 'https://jitpack.io' }
44
+ }
45
+
46
+ dependencies {
47
+ implementation "com.facebook.react:react-native:${safeExtGet('reactnativeVersion', '+')}"
48
+ implementation('com.ariadnext.android.idcheckio:sdk:7.1.10@aar') {
49
+ transitive = true
50
+ }
51
+ }
@@ -0,0 +1,10 @@
1
+ <?xml version='1.0' encoding='utf-8'?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ package="com.ariadnext.idcheckio">
4
+ <application>
5
+ <activity android:name="com.ariadnext.idcheckio.IdcheckioActivity"
6
+ android:screenOrientation="portrait"
7
+ android:configChanges="orientation|screenSize|uiMode"
8
+ android:exported="true"/>
9
+ </application>
10
+ </manifest>
@@ -0,0 +1,133 @@
1
+ package com.ariadnext.idcheckio;
2
+
3
+ import static com.ariadnext.idcheckio.IdcheckioConst.*;
4
+ import android.content.Intent;
5
+ import android.graphics.Color;
6
+ import android.graphics.drawable.ColorDrawable;
7
+ import android.os.Bundle;
8
+ import android.view.Window;
9
+ import android.widget.FrameLayout;
10
+
11
+ import androidx.annotation.NonNull;
12
+ import androidx.fragment.app.FragmentActivity;
13
+ import com.ariadnext.idcheckio.sdk.bean.DayNightTheme;
14
+ import com.ariadnext.idcheckio.sdk.bean.IpsCustomization;
15
+ import com.ariadnext.idcheckio.sdk.bean.OnlineContext;
16
+ import com.ariadnext.idcheckio.sdk.bean.Orientation;
17
+ import com.ariadnext.idcheckio.sdk.component.Idcheckio;
18
+ import com.ariadnext.idcheckio.sdk.component.IdcheckioView;
19
+ import com.ariadnext.idcheckio.sdk.interfaces.ErrorMsg;
20
+ import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioError;
21
+ import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioErrorKt;
22
+ import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioInteraction;
23
+ import com.ariadnext.idcheckio.sdk.interfaces.IdcheckioInteractionInterface;
24
+ import com.ariadnext.idcheckio.sdk.interfaces.result.IdcheckioResult;
25
+ import com.ariadnext.idcheckio.sdk.interfaces.result.ips.IpsResultCallback;
26
+ import com.ariadnext.idcheckio.sdk.utils.extension.JsonExtensionKt;
27
+
28
+ import org.json.JSONException;
29
+
30
+ import java.util.HashMap;
31
+
32
+
33
+ public class IdcheckioActivity extends FragmentActivity implements IdcheckioInteractionInterface, IpsResultCallback {
34
+ private final static int CONTAINER_ID = 123481562;
35
+
36
+ @Override
37
+ protected void onCreate(@androidx.annotation.Nullable Bundle savedInstanceState) {
38
+ super.onCreate(savedInstanceState);
39
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
40
+ FrameLayout rootLayout = new FrameLayout(this);
41
+ rootLayout.setId(CONTAINER_ID);
42
+ rootLayout.setBackground(new ColorDrawable(Color.BLACK));
43
+ setContentView(rootLayout);
44
+
45
+ Intent intent = getIntent();
46
+ boolean isOnline = intent.getBooleanExtra("isOnline", false);
47
+ boolean isIps = intent.getBooleanExtra("isIps", false);
48
+ if(isIps) {
49
+ String folderUid = intent.getStringExtra(FOLDER_UID);
50
+ folderUid = (folderUid != null)? folderUid : "";
51
+ /*
52
+ * You can update the IpsCustomization with a DayNightTheme to make update the colors of the sdk.
53
+ * You will have more information about the DayNightTheme in the Developers Guide.
54
+ */
55
+ DayNightTheme dayNightTheme = new DayNightTheme(
56
+ R.color.idcheckio_sdk_background_color,
57
+ R.color.idcheckio_sdk_border_color,
58
+ R.color.idcheckio_sdk_secondary_background_color,
59
+ R.color.idcheckio_sdk_primary_color,
60
+ // If you let the title and text color null, it will automatically switch between white and black depending on the background it is on.
61
+ null,
62
+ null
63
+ );
64
+ IpsCustomization ipsCustomization = new IpsCustomization(dayNightTheme, Orientation.AUTOMATIC);
65
+ Idcheckio.startIps(this, folderUid, this, ipsCustomization, null);
66
+ } else if(isOnline) {
67
+ IdcheckioView idcheckioView = pushIdcheckioView((HashMap<String, Object>) intent.getSerializableExtra("PARAMS"));
68
+ String online = intent.getStringExtra("ONLINE");
69
+ OnlineContext onlineContext = null;
70
+ if (online != null && !online.isEmpty()) {
71
+ onlineContext = OnlineContext.createFrom(online);
72
+ }
73
+ idcheckioView.startOnline(onlineContext);
74
+ } else {
75
+ IdcheckioView idcheckioView = pushIdcheckioView((HashMap<String, Object>) intent.getSerializableExtra("PARAMS"));
76
+ idcheckioView.start();
77
+ }
78
+ }
79
+
80
+ /**
81
+ * Retrieve the params from the json.
82
+ * Create an [IdcheckioView], assign the parameters to the view
83
+ * And then push the view in the fragment manager.
84
+ * @param params a hashmap with all the sdk parameters
85
+ * @return the created [IdcheckioView]
86
+ */
87
+ private IdcheckioView pushIdcheckioView(HashMap<String, Object> params){
88
+ IdcheckioView idcheckioView = ParameterUtils.getIDCheckioViewFromCall(params)
89
+ .listener(this)
90
+ .build();
91
+ getSupportFragmentManager().beginTransaction().replace(CONTAINER_ID, idcheckioView).commit();
92
+ return idcheckioView;
93
+ }
94
+
95
+ @Override
96
+ public void onBackPressed(){
97
+ onIdcheckioInteraction(IdcheckioInteraction.ERROR, IdcheckioErrorKt.toErrorMsg(IdcheckioError.CANCELLED_BY_USER,
98
+ "Session cancelled by user.", null));
99
+ }
100
+
101
+ @Override
102
+ public void onIdcheckioInteraction(IdcheckioInteraction idcheckioInteraction, Object data) {
103
+ switch (idcheckioInteraction) {
104
+ case RESULT:
105
+ Intent resultIntent = new Intent();
106
+ resultIntent.putExtra("IDCHECKIO_RESULT", JsonExtensionKt.toJson((IdcheckioResult) data));
107
+ setResult(RESULT_OK, resultIntent);
108
+ finish();
109
+ break;
110
+ case ERROR:
111
+ Intent errorIntent = new Intent();
112
+ if (data != null) {
113
+ errorIntent.putExtra("ERROR_MSG", JsonExtensionKt.toJson((ErrorMsg) data));
114
+ }
115
+ setResult(RESULT_CANCELED, errorIntent);
116
+ finish();
117
+ break;
118
+ default:
119
+ break;
120
+ }
121
+ }
122
+
123
+ @Override
124
+ public void onIpsSessionFailure(@NonNull ErrorMsg errorMsg) {
125
+ onIdcheckioInteraction(IdcheckioInteraction.ERROR, errorMsg);
126
+ }
127
+
128
+ @Override
129
+ public void onIpsSessionSuccess() {
130
+ // Empty success (the sdk give no result on an ips session success)
131
+ onIdcheckioInteraction(IdcheckioInteraction.RESULT, new IdcheckioResult());
132
+ }
133
+ }
@@ -0,0 +1,39 @@
1
+ package com.ariadnext.idcheckio;
2
+
3
+ public class IdcheckioConst {
4
+ public static final String DOCUMENT_TYPE = "docType";
5
+ public static final String CONFIRM_TYPE = "confirmationType";
6
+ public static final String SIDE_1_EXTRACTION = "sideOneExtraction";
7
+ public static final String SIDE_2_EXTRACTION = "sideTwoExtraction";
8
+ public static final String DATA_REQUIREMENT = "codeline";
9
+ public static final String FACE_DETECTION = "faceDetection";
10
+ public static final String SCAN_BOTH_SIDES = "scanBothSides";
11
+ public static final String USE_HD = "useHd";
12
+ public static final String INTEGRITY_CHECK = "integrityCheck";
13
+ public static final String READ_EMRTD = "readEmrtd";
14
+ public static final String DOC_LIVENESS = "docLiveness";
15
+ public static final String ORIENTATION = "orientation";
16
+
17
+ public static final String ONLINE_CONFIG = "onlineConfig";
18
+ public static final String IS_REFERENCE_DOC = "isReferenceDocument";
19
+ public static final String CIS_TYPE = "cisType";
20
+ public static final String FOLDER_UID = "folderUid";
21
+ public static final String BIOMETRIC_CONSENT = "biometricConsent";
22
+ public static final String ENABLE_MANUAL_ANALYSIS = "enableManualAnalysis";
23
+
24
+ public static final String THEME = "theme";
25
+ public static final String PRIMARY_COLOR = "primaryColor";
26
+ public static final String FOREGROUND_COLOR = "foregroundColor";
27
+ public static final String BACKGROUND_COLOR = "backgroundColor";
28
+ public static final String BORDER_COLOR = "borderColor";
29
+ public static final String TEXT_COLOR = "textColor";
30
+ public static final String TITLE_COLOR = "titleColor";
31
+
32
+ public static final String LANGUAGE = "language";
33
+ public static final String MANUAL_BUTTON_TIMER = "manualButtonTimer";
34
+ public static final String MAX_PICTURE_FILESIZE = "maxPictureFilesize";
35
+ public static final String FEEDBACK_LEVEL = "feedbackLevel";
36
+ public static final String ADJUST_CROP = "adjustCrop";
37
+ public static final String CONFIRM_ABORT = "confirmAbort";
38
+ public static final String CAPTURE_MODE = "captureMode";
39
+ }