assentify-sdk-react-native 0.0.32 → 0.0.34

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.
Files changed (60) hide show
  1. package/README.md +7 -0
  2. package/android/build.gradle +3 -1
  3. package/android/src/main/java/com/assentifysdk/AssentifySdkModule.kt +26 -3
  4. package/android/src/main/java/com/assentifysdk/FaceMatchActivity.kt +78 -20
  5. package/android/src/main/java/com/assentifysdk/ScanIDActivity.kt +194 -67
  6. package/android/src/main/java/com/assentifysdk/ScanOtherActivity.kt +80 -19
  7. package/android/src/main/java/com/assentifysdk/ScanPassportActivity.kt +79 -23
  8. package/android/src/main/res/drawable/button_rounded_background.xml +4 -4
  9. package/android/src/main/res/layout/activity_face_scan.xml +234 -219
  10. package/android/src/main/res/layout/activity_scan.xml +116 -0
  11. package/assentify-sdk.podspec +1 -1
  12. package/ios/NativeAssentifySdk.mm +6 -0
  13. package/ios/NativeAssentifySdk.swift +24 -7
  14. package/ios/UIComponents/RNPassportScanner.swift +4 -0
  15. package/ios/View/FaceMatchController.swift +49 -8
  16. package/ios/View/IDCardController.swift +104 -25
  17. package/ios/View/OtherController.swift +49 -11
  18. package/ios/View/PassportController.swift +57 -13
  19. package/ios/View/UI.swift +192 -36
  20. package/lib/commonjs/AssentifyProvider.js +12 -4
  21. package/lib/commonjs/AssentifyProvider.js.map +1 -1
  22. package/lib/commonjs/AssentifyWrapper.js +2 -2
  23. package/lib/commonjs/AssentifyWrapper.js.map +1 -1
  24. package/lib/commonjs/DoneFlags.js +14 -0
  25. package/lib/commonjs/DoneFlags.js.map +1 -0
  26. package/lib/commonjs/index.js +12 -0
  27. package/lib/commonjs/index.js.map +1 -1
  28. package/lib/module/AssentifyProvider.js +12 -4
  29. package/lib/module/AssentifyProvider.js.map +1 -1
  30. package/lib/module/AssentifyWrapper.js +2 -2
  31. package/lib/module/AssentifyWrapper.js.map +1 -1
  32. package/lib/module/DoneFlags.js +8 -0
  33. package/lib/module/DoneFlags.js.map +1 -0
  34. package/lib/module/index.js +1 -0
  35. package/lib/module/index.js.map +1 -1
  36. package/lib/typescript/example/src/Home.d.ts.map +1 -1
  37. package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts.map +1 -1
  38. package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts +1 -1
  39. package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts.map +1 -1
  40. package/lib/typescript/lib/commonjs/DoneFlags.d.ts +9 -0
  41. package/lib/typescript/lib/commonjs/DoneFlags.d.ts.map +1 -0
  42. package/lib/typescript/lib/module/AssentifyProvider.d.ts.map +1 -1
  43. package/lib/typescript/lib/module/AssentifyWrapper.d.ts +1 -1
  44. package/lib/typescript/lib/module/AssentifyWrapper.d.ts.map +1 -1
  45. package/lib/typescript/lib/module/DoneFlags.d.ts +8 -0
  46. package/lib/typescript/lib/module/DoneFlags.d.ts.map +1 -0
  47. package/lib/typescript/lib/module/index.d.ts +2 -1
  48. package/lib/typescript/lib/module/index.d.ts.map +1 -1
  49. package/lib/typescript/src/AssentifyProvider.d.ts.map +1 -1
  50. package/lib/typescript/src/AssentifyWrapper.d.ts +1 -1
  51. package/lib/typescript/src/AssentifyWrapper.d.ts.map +1 -1
  52. package/lib/typescript/src/DoneFlags.d.ts +9 -0
  53. package/lib/typescript/src/DoneFlags.d.ts.map +1 -0
  54. package/lib/typescript/src/index.d.ts +2 -1
  55. package/lib/typescript/src/index.d.ts.map +1 -1
  56. package/package.json +1 -1
  57. package/src/AssentifyProvider.tsx +11 -4
  58. package/src/AssentifyWrapper.ts +13 -1
  59. package/src/DoneFlags.ts +11 -0
  60. package/src/index.ts +1 -0
package/README.md CHANGED
@@ -92,6 +92,13 @@ yarn add assentify-sdk-react-native
92
92
  ```
93
93
 
94
94
  ## Versions
95
+ **0.0.34**
96
+ - Ability to split the front and back scanning of the IDs
97
+
98
+ **0.0.33**
99
+ - Manual Capture
100
+ - Retry Logic
101
+ - Support Low Capabilities Devices
95
102
 
96
103
  **0.0.32**
97
104
  - Face match improvements
@@ -99,13 +99,15 @@ dependencies {
99
99
  implementation "com.facebook.react:react-native:+"
100
100
  implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
101
101
 
102
- implementation 'com.github.AssentifyLTD:Assentify.SDK.Android:0.0.84'
102
+ implementation 'com.github.AssentifyLTD:Assentify.SDK.Android:0.0.85'
103
103
 
104
104
  /* Assentify Sdk Dependencies */
105
105
  implementation 'com.google.code.gson:gson:2.8.9'
106
106
  implementation 'androidx.navigation:navigation-fragment-ktx:2.7.5'
107
107
  implementation 'androidx.navigation:navigation-ui-ktx:2.7.5'
108
108
  implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.17'
109
+ implementation 'com.squareup.picasso:picasso:2.71828'
110
+
109
111
 
110
112
  }
111
113
 
@@ -47,6 +47,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
47
47
  private lateinit var assentifySdk: AssentifySdk
48
48
  private lateinit var timeStarted: String
49
49
  private lateinit var apiKey: String
50
+ private lateinit var manualClickColor: String
50
51
  private lateinit var configModel: ConfigModel
51
52
  private val mainHandler = Handler(Looper.getMainLooper())
52
53
  private lateinit var environmentalConditions: EnvironmentalConditions
@@ -78,7 +79,13 @@ class AssentifySdkModule(context: ReactApplicationContext) :
78
79
  iOSBrightnessHighThreshold:Int = 255,
79
80
  iOSBrightnessLowThreshold:Int = 50,
80
81
  activeLiveType : String = "NONE",
81
- activeLivenessCheckCount:Int = 0
82
+ activeLivenessCheckCount:Int = 0,
83
+ retryCount:Int = 3,
84
+ faceLivenessRetryCount:Int = 2,
85
+ minRam:Int = 8,
86
+ iOSMinRam:Int = 2,
87
+ minCPUCores:Int = 6,
88
+ manualClickColor: String? = null
82
89
 
83
90
  ) {
84
91
  try {
@@ -91,6 +98,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
91
98
  }
92
99
 
93
100
  this.apiKey = apiKey
101
+ this.manualClickColor = manualClickColor!!
94
102
  val tag = "[ASSENTIFY INIT]"
95
103
 
96
104
  println("$tag ==============================================")
@@ -117,6 +125,12 @@ class AssentifySdkModule(context: ReactApplicationContext) :
117
125
  println("$tag iOSBrightnessLowThreshold: $iOSBrightnessLowThreshold")
118
126
  println("$tag ActiveLiveType: $activeLiveType")
119
127
  println("$tag ActiveLivenessCheckCount: $activeLivenessCheckCount")
128
+ println("$tag RetryCount: $retryCount")
129
+ println("$tag FaceLivenessRetryCount: $faceLivenessRetryCount")
130
+ println("$tag MinRam: $minRam")
131
+ println("$tag iOSMinRam: $iOSMinRam")
132
+ println("$tag MinCPUCores: $minCPUCores")
133
+ println("$tag ManualClickColor: $manualClickColor")
120
134
  println("$tag ==============================================")
121
135
 
122
136
  val typeActive: ActiveLiveType = when (activeLiveType) {
@@ -138,7 +152,11 @@ class AssentifySdkModule(context: ReactApplicationContext) :
138
152
  BRIGHTNESS_HIGH_THRESHOLD = androidBrightnessHighThreshold,
139
153
  BRIGHTNESS_LOW_THRESHOLD = androidBrightnessLowThreshold,
140
154
  activeLiveType = typeActive,
141
- activeLivenessCheckCount = activeLivenessCheckCount
155
+ activeLivenessCheckCount = activeLivenessCheckCount,
156
+ retryCount = retryCount,
157
+ faceLivenessRetryCount = faceLivenessRetryCount ,
158
+ minRam = minRam,
159
+ minCPUCores = minCPUCores
142
160
  )
143
161
 
144
162
  val eventResultMap = Arguments.createMap().apply {
@@ -164,7 +182,8 @@ class AssentifySdkModule(context: ReactApplicationContext) :
164
182
  performLivenessFace,
165
183
  storeImageStream,
166
184
  saveCapturedVideoID,
167
- saveCapturedVideoFace
185
+ saveCapturedVideoFace,
186
+ context = reactApplicationContext
168
187
  )
169
188
  } catch (e: Exception) {
170
189
  Log.e(NAME, e.toString())
@@ -184,6 +203,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
184
203
  intent.putExtra("showCountDown", true)
185
204
  intent.putExtra("apiKey", this.apiKey)
186
205
  intent.putExtra("stepID", stepID)
206
+ intent.putExtra("manualClickColor", this.manualClickColor)
187
207
  reactApplicationContext?.startActivity(intent)
188
208
  }
189
209
  }
@@ -200,6 +220,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
200
220
  intent.putExtra("showCountDown", true)
201
221
  intent.putExtra("apiKey", this.apiKey)
202
222
  intent.putExtra("stepID", stepID)
223
+ intent.putExtra("manualClickColor", this.manualClickColor)
203
224
  currentActivity?.startActivity(intent)
204
225
  }
205
226
 
@@ -224,6 +245,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
224
245
  intent.putExtra("showCountDown", true)
225
246
  intent.putExtra("apiKey", this.apiKey)
226
247
  intent.putExtra("stepID", stepID)
248
+ intent.putExtra("manualClickColor", this.manualClickColor)
227
249
  currentActivity?.startActivity(intent)
228
250
  } catch (e: Exception) {
229
251
  Log.e(NAME, e.toString())
@@ -247,6 +269,7 @@ class AssentifySdkModule(context: ReactApplicationContext) :
247
269
  intent.putExtra("processingColor", environmentalConditions.CustomColor)
248
270
  intent.putExtra("showCountDown", showCountDown)
249
271
  intent.putExtra("stepID", stepID)
272
+ intent.putExtra("manualClickColor", this.manualClickColor)
250
273
  currentActivity?.startActivity(intent)
251
274
  }
252
275
 
@@ -29,12 +29,17 @@ import pl.droidsonroids.gif.GifImageView
29
29
  import com.assentify.sdk.RemoteClient.Models.SubmitRequestModel
30
30
  import android.content.Context
31
31
  import android.content.Intent
32
+ import android.content.res.ColorStateList
33
+ import android.util.Log
32
34
  import com.facebook.react.modules.core.DeviceEventManagerModule
33
35
  import com.facebook.react.bridge.Arguments
34
36
  import com.facebook.react.bridge.ReactApplicationContext
35
37
  import com.assentify.sdk.Core.Constants.BrightnessEvents
36
38
  import com.assentify.sdk.Core.Constants.FaceEvents
37
39
  import com.assentify.sdk.Core.Constants.ActiveLiveEvents
40
+ import com.assentify.sdk.Core.Constants.DoneFlags
41
+ import com.assentify.sdk.FaceMatch.FaceMatchManual
42
+ import com.assentify.sdk.FaceMatch.FaceMatchResult
38
43
 
39
44
  class FaceMatchActivity: AppCompatActivity(),
40
45
  FaceMatchCallback {
@@ -42,6 +47,9 @@ class FaceMatchActivity: AppCompatActivity(),
42
47
  private lateinit var assentifySdk: AssentifySdk
43
48
  private lateinit var reactApplicationContext: ReactApplicationContext
44
49
  private lateinit var faceMatch: FaceMatch
50
+ private lateinit var faceMatchManual: FaceMatchManual
51
+ private var isManual: Boolean = false;
52
+
45
53
  private lateinit var infoText: TextView
46
54
  private lateinit var infoIcon: ImageView
47
55
  private lateinit var infoLayout: LinearLayout
@@ -56,8 +64,9 @@ private lateinit var assentifySdk: AssentifySdk
56
64
  private var showCountDown: Boolean = true;
57
65
  private var start: Boolean = false;
58
66
  private var stepID: Int = -1;
67
+ private lateinit var manualClickColor: String;
59
68
  private var currentActiveLiveEvents: ActiveLiveEvents = ActiveLiveEvents.Good
60
-
69
+ private lateinit var takePhotoButton: Button;
61
70
 
62
71
  override fun onCreate(savedInstanceState: Bundle?) {
63
72
  super.onCreate(savedInstanceState)
@@ -67,8 +76,24 @@ private lateinit var assentifySdk: AssentifySdk
67
76
  showCountDown = intent.getBooleanExtra("showCountDown",true)
68
77
  holdHandColor = intent.getStringExtra("holdHandColor")!!
69
78
  processingColor = intent.getStringExtra("processingColor")!!
79
+ manualClickColor = intent.getStringExtra("manualClickColor")!!
70
80
  stepID = intent.getIntExtra("stepID",-1)!!
71
81
 
82
+ takePhotoButton = findViewById<Button>(R.id.takePhoto)
83
+ takePhotoButton.visibility = View.GONE
84
+ takePhotoButton.setTextColor(Color.parseColor(processingColor))
85
+ takePhotoButton.backgroundTintList = ColorStateList.valueOf(
86
+ Color.parseColor(manualClickColor)
87
+ )
88
+ takePhotoButton.setOnClickListener {
89
+ faceMatchManual.takePicture();
90
+ }
91
+
92
+ infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
93
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
94
+ drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
95
+ infoLayout.setBackground(drawableInfo)
96
+
72
97
  startAssentifySdk()
73
98
 
74
99
  val backButton = findViewById<RelativeLayout>(R.id.backButton)
@@ -79,16 +104,17 @@ private lateinit var assentifySdk: AssentifySdk
79
104
  backButton.setOnClickListener {
80
105
  runOnUiThread {
81
106
  triggerEvent("onBackClick", null)
82
- faceMatch.stopScanning();
107
+ if(isManual){
108
+ faceMatchManual.stopScanning();
109
+ }else{
110
+ faceMatch.stopScanning();
111
+ }
83
112
  finish()
84
113
  }
85
114
  }
86
115
 
87
116
 
88
- infoLayout = findViewById<LinearLayout>(R.id.infoLayout)
89
- val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
90
- drawableInfo?.setColorFilter(Color.parseColor(holdHandColor), PorterDuff.Mode.SRC_ATOP)
91
- infoLayout.setBackground(drawableInfo)
117
+
92
118
 
93
119
 
94
120
  val toolbarTitle = findViewById<TextView>(R.id.toolbar_title)
@@ -119,11 +145,17 @@ private lateinit var assentifySdk: AssentifySdk
119
145
  }
120
146
  }
121
147
 
148
+
149
+
122
150
  }
123
151
 
124
152
  override fun onBackPressed() {
125
153
  triggerEvent("onBackClick", null)
126
- faceMatch.stopScanning();
154
+ if(isManual){
155
+ faceMatchManual.stopScanning();
156
+ }else{
157
+ faceMatch.stopScanning();
158
+ }
127
159
  finish()
128
160
  super.onBackPressed()
129
161
  }
@@ -177,23 +209,44 @@ private lateinit var assentifySdk: AssentifySdk
177
209
  val sharedPreferences = reactApplicationContext.getSharedPreferences("FaceMatch", Context.MODE_PRIVATE)
178
210
  val base64SecondImage = sharedPreferences.getString("Base64SecondImage", "")
179
211
  assentifySdk = AssentifySdkObject.getAssentifySdkObject();
180
- faceMatch = assentifySdk!!.startFaceMatch(
212
+
213
+ when (val result = assentifySdk!!.startFaceMatch(
181
214
  this@FaceMatchActivity,
182
215
  base64SecondImage!!,
183
216
  showCountDown,stepID!!
184
- );
185
- Thread.sleep(500);
186
- var fragmentManager = supportFragmentManager
187
- var transaction = fragmentManager.beginTransaction()
188
- transaction.replace(R.id.fragmentContainer, faceMatch)
189
- transaction.commit()
217
+ )) {
218
+ is FaceMatchResult.Manual -> {
219
+ faceMatchManual = result.data
220
+ isManual =true
221
+ runOnUiThread{
222
+ infoLayout.visibility = View.GONE
223
+ val drawableInfo = getResources().getDrawable(R.drawable.info_rounded_background)
224
+ drawableInfo?.setColorFilter(Color.parseColor(manualClickColor), PorterDuff.Mode.SRC_ATOP)
225
+ takePhotoButton.setBackground(drawableInfo)
226
+ takePhotoButton.visibility = View.VISIBLE
227
+ }
228
+ Thread.sleep(500);
229
+ var fragmentManager = supportFragmentManager
230
+ var transaction = fragmentManager.beginTransaction()
231
+ transaction.replace(R.id.fragmentContainer, result.data)
232
+ transaction.commit()
233
+ }
234
+ is FaceMatchResult.Auto -> {
235
+ faceMatch = result.data
236
+ Thread.sleep(500);
237
+ var fragmentManager = supportFragmentManager
238
+ var transaction = fragmentManager.beginTransaction()
239
+ transaction.replace(R.id.fragmentContainer, result.data)
240
+ transaction.commit()
241
+ }
242
+ }
190
243
  }
191
244
 
192
245
  override fun onError(dataModel: BaseResponseDataModel) {
193
246
  triggerEvent("onError", dataModel)
194
247
  runOnUiThread {
195
248
  start = false;
196
- showPopUpMessage(R.drawable.warning, "Please check your Wi-Fi or mobile data connection", "Let's try again", false)
249
+ showPopUpMessage(R.drawable.warning, "Your internet connection seems unstable. Please check your connection and try again.\n", "Let's try again", false)
197
250
  }
198
251
  }
199
252
 
@@ -219,12 +272,12 @@ private lateinit var assentifySdk: AssentifySdk
219
272
  triggerEvent("onLivenessUpdate", dataModel)
220
273
  runOnUiThread {
221
274
  start = false;
222
- showPopUpMessage(R.drawable.warning, "Liveness Failed", "", false)
275
+ showPopUpMessage(R.drawable.warning, "Please make sure your face is well lit, look directly at the camera, and avoid using photos or videos. Try again", "", false)
223
276
  }
224
277
  }
225
278
 
226
- override fun onComplete(dataModel: FaceResponseModel) {
227
- triggerCompleteEvent("onComplete",dataModel)
279
+ override fun onComplete(dataModel: FaceResponseModel,doneFlag: DoneFlags) {
280
+ triggerCompleteEvent("onComplete",dataModel,doneFlag)
228
281
  /** Data To Submit **/
229
282
  val documentCaptureSharedPreferences =
230
283
  reactApplicationContext.getSharedPreferences("SubmitStepModel", Context.MODE_PRIVATE)
@@ -249,7 +302,11 @@ private lateinit var assentifySdk: AssentifySdk
249
302
 
250
303
  runOnUiThread{
251
304
  start = false
252
- faceMatch.stopScanning();
305
+ if(isManual){
306
+ faceMatchManual.stopScanning();
307
+ }else{
308
+ faceMatch.stopScanning();
309
+ }
253
310
  finish()
254
311
  }
255
312
  }
@@ -350,12 +407,13 @@ private lateinit var assentifySdk: AssentifySdk
350
407
  }
351
408
 
352
409
 
353
- private fun triggerCompleteEvent(eventName:String, dataModel: FaceResponseModel?){
410
+ private fun triggerCompleteEvent(eventName:String, dataModel: FaceResponseModel?,doneFlag: DoneFlags){
354
411
  val eventResultMap = Arguments.createMap().apply {
355
412
  if(dataModel!=null){
356
413
  val gson = Gson()
357
414
  val jsonString = gson.toJson(dataModel.faceExtractedModel!!)
358
415
  putString("FaceMatchDataModel", jsonString)
416
+ putString("DoneFlag", doneFlag.toString())
359
417
  }
360
418
  }
361
419
  reactApplicationContext.getJSModule(DeviceEventManagerModule.RCTDeviceEventEmitter::class.java)