assentify-sdk-react-native 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (195) hide show
  1. package/LICENSE +3 -0
  2. package/README.md +65 -0
  3. package/android/build.gradle +111 -0
  4. package/android/gradle.properties +9 -0
  5. package/android/src/main/AndroidManifest.xml +55 -0
  6. package/android/src/main/java/com/assentifysdk/AndroidProgressBarModule.kt +33 -0
  7. package/android/src/main/java/com/assentifysdk/AssentifySdkBaseModule.kt +39 -0
  8. package/android/src/main/java/com/assentifysdk/AssentifySdkModule.kt +432 -0
  9. package/android/src/main/java/com/assentifysdk/AssentifySdkPackage.kt +19 -0
  10. package/android/src/main/java/com/assentifysdk/FaceMatchActivity.kt +309 -0
  11. package/android/src/main/java/com/assentifysdk/ImageToBase64Converter.kt +40 -0
  12. package/android/src/main/java/com/assentifysdk/ReactApplicationContextObject.kt +14 -0
  13. package/android/src/main/java/com/assentifysdk/ScanIDActivity.kt +431 -0
  14. package/android/src/main/java/com/assentifysdk/ScanOtherActivity.kt +328 -0
  15. package/android/src/main/java/com/assentifysdk/ScanPassportActivity.kt +364 -0
  16. package/android/src/main/java/com/assentifysdk/StepsKeys.kt +91 -0
  17. package/android/src/main/res/drawable/back_icon.png +0 -0
  18. package/android/src/main/res/drawable/button_rounded_background.xml +6 -0
  19. package/android/src/main/res/drawable/card.gif +0 -0
  20. package/android/src/main/res/drawable/expire.png +0 -0
  21. package/android/src/main/res/drawable/id.gif +0 -0
  22. package/android/src/main/res/drawable/id_warning.png +0 -0
  23. package/android/src/main/res/drawable/info_icon.png +0 -0
  24. package/android/src/main/res/drawable/info_rounded_background.xml +6 -0
  25. package/android/src/main/res/drawable/passport.gif +0 -0
  26. package/android/src/main/res/drawable/rounded_background.xml +3 -0
  27. package/android/src/main/res/drawable/sending.png +0 -0
  28. package/android/src/main/res/drawable/warning.png +0 -0
  29. package/android/src/main/res/drawable/zoom_in.png +0 -0
  30. package/android/src/main/res/drawable/zoom_out.png +0 -0
  31. package/android/src/main/res/layout/activity_face_scan.xml +242 -0
  32. package/android/src/main/res/layout/activity_scan.xml +297 -0
  33. package/android/src/main/res/raw/sending_video.MP4 +0 -0
  34. package/android/src/main/res/values/colors.xml +8 -0
  35. package/android/src/main/res/values/strings.xml +3 -0
  36. package/android/src/main/res/values/styles.xml +4 -0
  37. package/assentify-sdk.podspec +43 -0
  38. package/ios/AssentifySdkBaseModule.swift +15 -0
  39. package/ios/Info.plist +27 -0
  40. package/ios/NativeAssentifySdk-Bridging-Header.h +3 -0
  41. package/ios/NativeAssentifySdk.mm +45 -0
  42. package/ios/NativeAssentifySdk.swift +460 -0
  43. package/ios/Resources/card.gif +0 -0
  44. package/ios/Resources/expire.png +0 -0
  45. package/ios/Resources/id.gif +0 -0
  46. package/ios/Resources/id_warning.png +0 -0
  47. package/ios/Resources/info_icon.png +0 -0
  48. package/ios/Resources/passport.gif +0 -0
  49. package/ios/Resources/sending.png +0 -0
  50. package/ios/Resources/warning.png +0 -0
  51. package/ios/Resources/zoom_in.png +0 -0
  52. package/ios/Resources/zoom_out.png +0 -0
  53. package/ios/UIComponents/RNIOSProgressBar.h +4 -0
  54. package/ios/UIComponents/RNIOSProgressBar.m +34 -0
  55. package/ios/UIComponents/RNPassportScanner.m +26 -0
  56. package/ios/UIComponents/RNPassportScanner.swift +245 -0
  57. package/ios/UIComponents/RNTMapManager.h +4 -0
  58. package/ios/UIComponents/RNTMapManager.m +19 -0
  59. package/ios/View/DataDecoder.swift +469 -0
  60. package/ios/View/FaceMatchController.swift +258 -0
  61. package/ios/View/IDCardController.swift +360 -0
  62. package/ios/View/OtherController.swift +283 -0
  63. package/ios/View/PassportController.swift +302 -0
  64. package/ios/View/UI.swift +298 -0
  65. package/lib/commonjs/AssentifyProvider.js +202 -0
  66. package/lib/commonjs/AssentifyProvider.js.map +1 -0
  67. package/lib/commonjs/AssentifyWrapper.js +76 -0
  68. package/lib/commonjs/AssentifyWrapper.js.map +1 -0
  69. package/lib/commonjs/Language.js +27 -0
  70. package/lib/commonjs/Language.js.map +1 -0
  71. package/lib/commonjs/helpers/index.js +2 -0
  72. package/lib/commonjs/helpers/index.js.map +1 -0
  73. package/lib/commonjs/helpers/parsers/FaceMatchParser.js +27 -0
  74. package/lib/commonjs/helpers/parsers/FaceMatchParser.js.map +1 -0
  75. package/lib/commonjs/helpers/parsers/IDCardParser.js +25 -0
  76. package/lib/commonjs/helpers/parsers/IDCardParser.js.map +1 -0
  77. package/lib/commonjs/helpers/parsers/OtherIDParser.js +29 -0
  78. package/lib/commonjs/helpers/parsers/OtherIDParser.js.map +1 -0
  79. package/lib/commonjs/helpers/parsers/PassportParser.js +25 -0
  80. package/lib/commonjs/helpers/parsers/PassportParser.js.map +1 -0
  81. package/lib/commonjs/index.js +49 -0
  82. package/lib/commonjs/index.js.map +1 -0
  83. package/lib/commonjs/types.js +42 -0
  84. package/lib/commonjs/types.js.map +1 -0
  85. package/lib/module/AssentifyProvider.js +193 -0
  86. package/lib/module/AssentifyProvider.js.map +1 -0
  87. package/lib/module/AssentifyWrapper.js +70 -0
  88. package/lib/module/AssentifyWrapper.js.map +1 -0
  89. package/lib/module/Language.js +21 -0
  90. package/lib/module/Language.js.map +1 -0
  91. package/lib/module/helpers/index.js +2 -0
  92. package/lib/module/helpers/index.js.map +1 -0
  93. package/lib/module/helpers/parsers/FaceMatchParser.js +21 -0
  94. package/lib/module/helpers/parsers/FaceMatchParser.js.map +1 -0
  95. package/lib/module/helpers/parsers/IDCardParser.js +19 -0
  96. package/lib/module/helpers/parsers/IDCardParser.js.map +1 -0
  97. package/lib/module/helpers/parsers/OtherIDParser.js +23 -0
  98. package/lib/module/helpers/parsers/OtherIDParser.js.map +1 -0
  99. package/lib/module/helpers/parsers/PassportParser.js +19 -0
  100. package/lib/module/helpers/parsers/PassportParser.js.map +1 -0
  101. package/lib/module/index.js +6 -0
  102. package/lib/module/index.js.map +1 -0
  103. package/lib/module/types.js +36 -0
  104. package/lib/module/types.js.map +1 -0
  105. package/lib/typescript/babel.config.d.ts +3 -0
  106. package/lib/typescript/babel.config.d.ts.map +1 -0
  107. package/lib/typescript/commitlint.config.d.ts +7 -0
  108. package/lib/typescript/commitlint.config.d.ts.map +1 -0
  109. package/lib/typescript/example/babel.config.d.ts +8 -0
  110. package/lib/typescript/example/babel.config.d.ts.map +1 -0
  111. package/lib/typescript/example/index.d.ts +2 -0
  112. package/lib/typescript/example/index.d.ts.map +1 -0
  113. package/lib/typescript/example/jest.config.d.ts +2 -0
  114. package/lib/typescript/example/jest.config.d.ts.map +1 -0
  115. package/lib/typescript/example/metro.config.d.ts +3 -0
  116. package/lib/typescript/example/metro.config.d.ts.map +1 -0
  117. package/lib/typescript/example/react-native.config.d.ts +6 -0
  118. package/lib/typescript/example/react-native.config.d.ts.map +1 -0
  119. package/lib/typescript/example/src/App.d.ts +3 -0
  120. package/lib/typescript/example/src/App.d.ts.map +1 -0
  121. package/lib/typescript/example/src/Home.d.ts +4 -0
  122. package/lib/typescript/example/src/Home.d.ts.map +1 -0
  123. package/lib/typescript/example/src/navigator.d.ts +4 -0
  124. package/lib/typescript/example/src/navigator.d.ts.map +1 -0
  125. package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts +3 -0
  126. package/lib/typescript/lib/commonjs/AssentifyProvider.d.ts.map +1 -0
  127. package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts +11 -0
  128. package/lib/typescript/lib/commonjs/AssentifyWrapper.d.ts.map +1 -0
  129. package/lib/typescript/lib/commonjs/Language.d.ts +22 -0
  130. package/lib/typescript/lib/commonjs/Language.d.ts.map +1 -0
  131. package/lib/typescript/lib/commonjs/helpers/index.d.ts +1 -0
  132. package/lib/typescript/lib/commonjs/helpers/index.d.ts.map +1 -0
  133. package/lib/typescript/lib/commonjs/helpers/parsers/FaceMatchParser.d.ts +12 -0
  134. package/lib/typescript/lib/commonjs/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
  135. package/lib/typescript/lib/commonjs/helpers/parsers/IDCardParser.d.ts +11 -0
  136. package/lib/typescript/lib/commonjs/helpers/parsers/IDCardParser.d.ts.map +1 -0
  137. package/lib/typescript/lib/commonjs/helpers/parsers/OtherIDParser.d.ts +13 -0
  138. package/lib/typescript/lib/commonjs/helpers/parsers/OtherIDParser.d.ts.map +1 -0
  139. package/lib/typescript/lib/commonjs/helpers/parsers/PassportParser.d.ts +11 -0
  140. package/lib/typescript/lib/commonjs/helpers/parsers/PassportParser.d.ts.map +1 -0
  141. package/lib/typescript/lib/commonjs/index.d.ts +2 -0
  142. package/lib/typescript/lib/commonjs/index.d.ts.map +1 -0
  143. package/lib/typescript/lib/commonjs/types.d.ts +18 -0
  144. package/lib/typescript/lib/commonjs/types.d.ts.map +1 -0
  145. package/lib/typescript/lib/module/AssentifyProvider.d.ts +3 -0
  146. package/lib/typescript/lib/module/AssentifyProvider.d.ts.map +1 -0
  147. package/lib/typescript/lib/module/AssentifyWrapper.d.ts +10 -0
  148. package/lib/typescript/lib/module/AssentifyWrapper.d.ts.map +1 -0
  149. package/lib/typescript/lib/module/Language.d.ts +21 -0
  150. package/lib/typescript/lib/module/Language.d.ts.map +1 -0
  151. package/lib/typescript/lib/module/helpers/index.d.ts +1 -0
  152. package/lib/typescript/lib/module/helpers/index.d.ts.map +1 -0
  153. package/lib/typescript/lib/module/helpers/parsers/FaceMatchParser.d.ts +11 -0
  154. package/lib/typescript/lib/module/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
  155. package/lib/typescript/lib/module/helpers/parsers/IDCardParser.d.ts +10 -0
  156. package/lib/typescript/lib/module/helpers/parsers/IDCardParser.d.ts.map +1 -0
  157. package/lib/typescript/lib/module/helpers/parsers/OtherIDParser.d.ts +12 -0
  158. package/lib/typescript/lib/module/helpers/parsers/OtherIDParser.d.ts.map +1 -0
  159. package/lib/typescript/lib/module/helpers/parsers/PassportParser.d.ts +10 -0
  160. package/lib/typescript/lib/module/helpers/parsers/PassportParser.d.ts.map +1 -0
  161. package/lib/typescript/lib/module/index.d.ts +12 -0
  162. package/lib/typescript/lib/module/index.d.ts.map +1 -0
  163. package/lib/typescript/lib/module/types.d.ts +17 -0
  164. package/lib/typescript/lib/module/types.d.ts.map +1 -0
  165. package/lib/typescript/src/AssentifyProvider.d.ts +4 -0
  166. package/lib/typescript/src/AssentifyProvider.d.ts.map +1 -0
  167. package/lib/typescript/src/AssentifyWrapper.d.ts +12 -0
  168. package/lib/typescript/src/AssentifyWrapper.d.ts.map +1 -0
  169. package/lib/typescript/src/Language.d.ts +22 -0
  170. package/lib/typescript/src/Language.d.ts.map +1 -0
  171. package/lib/typescript/src/helpers/index.d.ts +1 -0
  172. package/lib/typescript/src/helpers/index.d.ts.map +1 -0
  173. package/lib/typescript/src/helpers/parsers/FaceMatchParser.d.ts +4 -0
  174. package/lib/typescript/src/helpers/parsers/FaceMatchParser.d.ts.map +1 -0
  175. package/lib/typescript/src/helpers/parsers/IDCardParser.d.ts +4 -0
  176. package/lib/typescript/src/helpers/parsers/IDCardParser.d.ts.map +1 -0
  177. package/lib/typescript/src/helpers/parsers/OtherIDParser.d.ts +4 -0
  178. package/lib/typescript/src/helpers/parsers/OtherIDParser.d.ts.map +1 -0
  179. package/lib/typescript/src/helpers/parsers/PassportParser.d.ts +4 -0
  180. package/lib/typescript/src/helpers/parsers/PassportParser.d.ts.map +1 -0
  181. package/lib/typescript/src/index.d.ts +12 -0
  182. package/lib/typescript/src/index.d.ts.map +1 -0
  183. package/lib/typescript/src/types.d.ts +308 -0
  184. package/lib/typescript/src/types.d.ts.map +1 -0
  185. package/package.json +201 -0
  186. package/src/AssentifyProvider.tsx +189 -0
  187. package/src/AssentifyWrapper.ts +142 -0
  188. package/src/Language.ts +22 -0
  189. package/src/helpers/index.ts +1 -0
  190. package/src/helpers/parsers/FaceMatchParser.ts +28 -0
  191. package/src/helpers/parsers/IDCardParser.ts +27 -0
  192. package/src/helpers/parsers/OtherIDParser.ts +31 -0
  193. package/src/helpers/parsers/PassportParser.ts +27 -0
  194. package/src/index.ts +6 -0
  195. package/src/types.ts +373 -0
@@ -0,0 +1,432 @@
1
+ package com.assentifysdk
2
+
3
+ import com.assentify.sdk.AssentifySdk
4
+ import com.assentify.sdk.AssentifySdkCallback
5
+ import com.assentify.sdk.AssentifySdkObject
6
+ import BlockLoaderKeys
7
+ import StepsName
8
+ import com.assentify.sdk.RemoteClient.Models.SubmitRequestModel
9
+ import WrapUpKeys
10
+ import android.content.Context
11
+ import android.content.Intent
12
+ import android.os.Handler
13
+ import android.os.Looper
14
+ import android.util.Log
15
+ import com.assentify.sdk.Core.Constants.EnvironmentalConditions
16
+ import com.assentify.sdk.RemoteClient.Models.ConfigModel
17
+ import com.assentify.sdk.RemoteClient.Models.StepDefinitions
18
+ import com.assentify.sdk.RemoteClient.Models.TemplatesByCountry
19
+ import com.assentify.sdk.RemoteClient.Models.encodeTemplatesByCountryToJson
20
+ import com.assentify.sdk.SubmitData.SubmitDataCallback
21
+ import com.facebook.react.bridge.Arguments
22
+ import com.facebook.react.bridge.ReactApplicationContext
23
+ import com.facebook.react.bridge.ReactMethod
24
+ import com.facebook.react.bridge.ReadableMap
25
+ import com.facebook.react.bridge.ReadableType
26
+ import com.google.gson.Gson
27
+ import com.google.gson.reflect.TypeToken
28
+ import java.text.SimpleDateFormat
29
+ import java.util.Date
30
+ import java.util.Locale
31
+ import java.util.TimeZone
32
+ import com.assentify.sdk.RemoteClient.Models.KycDocumentDetails
33
+ import ImageToBase64Converter
34
+
35
+ class AssentifySdkModule(context: ReactApplicationContext) :
36
+ AssentifySdkBaseModule(context), AssentifySdkCallback, SubmitDataCallback {
37
+
38
+ private lateinit var assentifySdk: AssentifySdk
39
+ private lateinit var timeStarted: String
40
+ private lateinit var apiKey: String
41
+ private lateinit var configModel: ConfigModel
42
+ private val mainHandler = Handler(Looper.getMainLooper())
43
+ private lateinit var environmentalConditions: EnvironmentalConditions
44
+ private lateinit var templatesByCountry: List<TemplatesByCountry>
45
+
46
+ @ReactMethod
47
+ fun initialize(
48
+ apiKey: String,
49
+ tenantIdentifier: String,
50
+ instanceHash: String,
51
+ processMrz: Boolean? = null,
52
+ storeCapturedDocument: Boolean? = null,
53
+ performLivenessDocument: Boolean? = null,
54
+ performLivenessFace: Boolean? = null,
55
+ storeImageStream: Boolean? = null,
56
+ saveCapturedVideoID: Boolean? = null,
57
+ saveCapturedVideoFace: Boolean? = null,
58
+ ENV_CustomColor: String? = null,
59
+ enableDetect: Boolean = true,
60
+ enableGuide: Boolean = true,
61
+ ) {
62
+ try {
63
+ if (apiKey.isNullOrBlank() ||
64
+ tenantIdentifier.isNullOrBlank() ||
65
+ instanceHash.isNullOrBlank()
66
+ ) {
67
+ Log.e(NAME, "apiKey, tenantIdentifier and instanceHash are mandatory parameters")
68
+ return
69
+ }
70
+
71
+ this.apiKey = apiKey
72
+ println("initialize - Assentify SDK initialize")
73
+ println("apiKey: $apiKey")
74
+ println("tenantIdentifier: $tenantIdentifier")
75
+ println("processMrz: ${processMrz.toString()}")
76
+ println("storeCapturedDocument: ${storeCapturedDocument.toString()}")
77
+ println("performLivenessDocument: ${performLivenessDocument.toString()}")
78
+ println("performLivenessFace: ${performLivenessFace.toString()}")
79
+ println("storeImageStream: ${storeImageStream.toString()}")
80
+ println("saveCapturedVideoID: ${saveCapturedVideoID.toString()}")
81
+ println("ENV_CustomColor: $ENV_CustomColor")
82
+ println("enableDetect: $enableDetect")
83
+ println("enableGuide: $enableGuide")
84
+
85
+ environmentalConditions =
86
+ EnvironmentalConditions(
87
+ enableDetect,
88
+ enableGuide,
89
+ 500.0f,
90
+ 00.0f,
91
+ 50.0f,
92
+ 100.0f,
93
+ "#ffffff",
94
+ ENV_CustomColor ?: "#f5a103",
95
+ )
96
+
97
+ val eventResultMap = Arguments.createMap().apply {
98
+ putBoolean("assentifySdkInitStart", true)
99
+ }
100
+ sendEvent("AppResult", eventResultMap)
101
+
102
+ val sharedPreferences =
103
+ reactApplicationContext.getSharedPreferences("BlockLoaders", Context.MODE_PRIVATE)
104
+ val editor = sharedPreferences.edit()
105
+ editor.putString("instanceHash", instanceHash)
106
+ editor.apply()
107
+
108
+ assentifySdk =
109
+ AssentifySdk(
110
+ apiKey,
111
+ tenantIdentifier,
112
+ instanceHash,
113
+ environmentalConditions,
114
+ this,
115
+ processMrz,
116
+ storeCapturedDocument,
117
+ performLivenessDocument,
118
+ performLivenessFace,
119
+ storeImageStream,
120
+ saveCapturedVideoID,
121
+ saveCapturedVideoFace
122
+ )
123
+ } catch (e: Exception) {
124
+ Log.e(NAME, e.toString())
125
+ }
126
+ }
127
+
128
+ @ReactMethod
129
+ fun startScanPassport(language: String) {
130
+ timeStarted = getCurrentDateTimeUTC();
131
+ /** Nav To Passport Scan Page */
132
+ val intent = Intent(reactApplicationContext, ScanPassportActivity::class.java)
133
+ if (intent.resolveActivity(reactApplicationContext.packageManager) !== null) {
134
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
135
+ intent.putExtra("holdHandColor", environmentalConditions.HoldHandColor)
136
+ intent.putExtra("processingColor", environmentalConditions.CustomColor)
137
+ intent.putExtra("language", language)
138
+ intent.putExtra("showCountDown", true)
139
+ intent.putExtra("apiKey", this.apiKey)
140
+ reactApplicationContext?.startActivity(intent)
141
+ }
142
+ }
143
+
144
+ @ReactMethod
145
+ fun startScanOtherIDPage(language: String) {
146
+ timeStarted = getCurrentDateTimeUTC();
147
+ /** Nav To Other Scan Page */
148
+ val intent = Intent(currentActivity, ScanOtherActivity::class.java)
149
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
150
+ intent.putExtra("holdHandColor", environmentalConditions.HoldHandColor)
151
+ intent.putExtra("processingColor", environmentalConditions.CustomColor)
152
+ intent.putExtra("language", language)
153
+ intent.putExtra("showCountDown", true)
154
+ intent.putExtra("apiKey", this.apiKey)
155
+ currentActivity?.startActivity(intent)
156
+ }
157
+
158
+ @ReactMethod
159
+ fun startScanIDPage(
160
+ jsonStringKycDocumentDetails: String,
161
+ language: String,
162
+ flippingCard: Boolean,
163
+ ) {
164
+ timeStarted = getCurrentDateTimeUTC();
165
+ try {
166
+ /** Nav To ID Scan Page */
167
+ val intent = Intent(currentActivity, ScanIDActivity::class.java)
168
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK)
169
+ intent.putExtra("holdHandColor", environmentalConditions.HoldHandColor)
170
+ intent.putExtra("processingColor", environmentalConditions.CustomColor)
171
+ intent.putExtra("kycDocumentDetails", jsonStringKycDocumentDetails)
172
+ intent.putExtra("language", language)
173
+ intent.putExtra("flippingCard", flippingCard)
174
+ intent.putExtra("title", getIdTitle(jsonStringKycDocumentDetails!!))
175
+ intent.putExtra("showCountDown", true)
176
+ intent.putExtra("apiKey", this.apiKey)
177
+ currentActivity?.startActivity(intent)
178
+ } catch (e: Exception) {
179
+ Log.e(NAME, e.toString())
180
+ }
181
+ }
182
+
183
+ @ReactMethod
184
+ fun startFaceMatch(imageUrl:String,showCountDown: Boolean) {
185
+ /** Nav To Face Match Page **/
186
+ var base64Image = ImageToBase64Converter(apiKey).execute(imageUrl).get()
187
+ val sharedPreferences = reactApplicationContext.getSharedPreferences("FaceMatch",
188
+ Context.MODE_PRIVATE)
189
+ val editor = sharedPreferences.edit()
190
+ editor.putString("Base64SecondImage", base64Image)
191
+ editor.apply()
192
+ val intent = Intent(reactApplicationContext, FaceMatchActivity::class.java)
193
+ intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
194
+ intent.putExtra("holdHandColor", environmentalConditions.HoldHandColor)
195
+ intent.putExtra("processingColor", environmentalConditions.CustomColor)
196
+ intent.putExtra("showCountDown", showCountDown)
197
+ currentActivity?.startActivity(intent)
198
+ }
199
+
200
+ override fun onAssentifySdkInitError(message: String) {
201
+ mainHandler.post {
202
+ val eventResultMap = Arguments.createMap().apply {
203
+ putBoolean("assentifySdkInitSuccess", false)
204
+ }
205
+ sendEvent("AppResult", eventResultMap)
206
+ }
207
+ }
208
+
209
+ override fun onAssentifySdkInitSuccess(configModel: ConfigModel) {
210
+ mainHandler.post {
211
+ try {
212
+ val documentCaptureStepModelPreferences =
213
+ reactApplicationContext.getSharedPreferences(
214
+ "DocumentCaptureStepModel",
215
+ Context.MODE_PRIVATE
216
+ )
217
+ documentCaptureStepModelPreferences.edit().clear().apply()
218
+
219
+ val sharedPreferences =
220
+ reactApplicationContext.getSharedPreferences("StepDefinitions", Context.MODE_PRIVATE)
221
+ val editor = sharedPreferences.edit()
222
+ val gson = Gson()
223
+ val json: String = gson.toJson(configModel.stepDefinitions)
224
+ editor.putString("Steps", json)
225
+ editor.apply()
226
+
227
+ /** Store React Application Context */
228
+ AssentifySdkObject.setAssentifySdkObject(assentifySdk)
229
+ ReactApplicationContextObject.setReactApplicationContextObject(reactApplicationContext)
230
+
231
+ /** Send Event */
232
+ // val eventResultMap = Arguments.createMap().apply {
233
+ // putBoolean("assentifySdkInitSuccess", true);
234
+ // }
235
+ // sendEvent("AppResult", eventResultMap)
236
+ this.configModel = configModel;
237
+ templatesByCountry = assentifySdk.getTemplates();
238
+
239
+ val eventResultMap =
240
+ Arguments.createMap().apply {
241
+ val jsonString = encodeTemplatesByCountryToJson(templatesByCountry)
242
+ putBoolean("assentifySdkInitSuccess", true)
243
+ putString("AssentifySdkHasTemplates", jsonString)
244
+ }
245
+ sendEvent("AppResult", eventResultMap)
246
+ } catch (e: Exception) {
247
+ showErrorMessage(e.toString())
248
+ }
249
+ }
250
+ }
251
+
252
+ @ReactMethod
253
+ fun submitData(data: ReadableMap? = null) {
254
+
255
+ mainHandler.post {
256
+ val mapData = readableMapToMap(data!!)
257
+
258
+ val sharedDefinitions =
259
+ reactApplicationContext.getSharedPreferences("BlockLoaders", Context.MODE_PRIVATE)
260
+ val instanceHashStr = sharedDefinitions.getString("instanceHash", "")!!
261
+
262
+
263
+ var wrapUp: SubmitRequestModel? = null
264
+ var blockLoader: SubmitRequestModel? = null
265
+
266
+ val sharedStepDefinitions =
267
+ reactApplicationContext.getSharedPreferences("StepDefinitions", Context.MODE_PRIVATE)
268
+ val gson = Gson()
269
+ val json: String = sharedStepDefinitions.getString("Steps", "")!!
270
+ val steps: List<StepDefinitions>? =
271
+ gson.fromJson(json, object : TypeToken<List<StepDefinitions>>() {}.type)
272
+
273
+ steps!!.forEach { item ->
274
+ // ** WrapUp *//
275
+ if (item.stepDefinition == StepsName.WrapUp) {
276
+ val values: MutableMap<String, String> = mutableMapOf()
277
+ item.outputProperties.forEach { property ->
278
+ if (property.key.contains(WrapUpKeys.TimeEnded)) {
279
+ values.put(property.key, getCurrentDateTimeUTC())
280
+ }
281
+ }
282
+ wrapUp = SubmitRequestModel(item.stepId, StepsName.WrapUp, values)
283
+ }
284
+ // ** BlockLoader *//
285
+ if (item.stepDefinition == StepsName.BlockLoader) {
286
+ val values: MutableMap<String, String> = mutableMapOf()
287
+ item.outputProperties.forEach { property ->
288
+ if (property.key.contains(BlockLoaderKeys.TimeStarted)) {
289
+ values.put(property.key, timeStarted)
290
+ }
291
+ if (property.key.contains(BlockLoaderKeys.DeviceName)) {
292
+ values.put(property.key, "Android")
293
+ }
294
+ if (property.key.contains(BlockLoaderKeys.Application)) {
295
+ values.put(property.key, configModel.instanceId)
296
+ }
297
+ if (property.key.contains(BlockLoaderKeys.FlowName)) {
298
+ values.put(property.key, configModel.flowName)
299
+ }
300
+ if (property.key.contains(BlockLoaderKeys.UserAgent)) {
301
+ values.put(property.key, "SDK")
302
+ }
303
+ if (property.key.contains(BlockLoaderKeys.InstanceHash)) {
304
+ values.put(property.key, configModel.instanceHash)
305
+ }
306
+ if (property.key.contains(BlockLoaderKeys.InteractionID)) {
307
+ values.put(property.key, configModel.instanceId)
308
+ }
309
+ for ((keyData, valueData) in mapData) {
310
+ if (property.key.contains(keyData)) {
311
+ values.put(property.key, valueData.toString())
312
+ }
313
+ }
314
+ }
315
+
316
+ blockLoader = SubmitRequestModel(item.stepId, StepsName.BlockLoader, values)
317
+ }
318
+ }
319
+
320
+ // ** Doc *//
321
+ val sharedStepDefinitionsDoc =
322
+ reactApplicationContext.getSharedPreferences(
323
+ "DocumentCaptureStepModel",
324
+ Context.MODE_PRIVATE
325
+ )
326
+ val gsonSharedStepDefinitionsDoc = Gson()
327
+ val jsonSharedStepDefinitionsDoc: String =
328
+ sharedStepDefinitionsDoc.getString("DocumentCaptureStep", "")!!
329
+ val sharedStepDefinitionsStepDoc: SubmitRequestModel =
330
+ gsonSharedStepDefinitionsDoc.fromJson(
331
+ jsonSharedStepDefinitionsDoc,
332
+ object : TypeToken<SubmitRequestModel>() {}.type
333
+ )
334
+
335
+ // ** Face *//
336
+ val sharedStepDefinitionsFace =
337
+ reactApplicationContext.getSharedPreferences("FaceMatchStepModel", Context.MODE_PRIVATE)
338
+ val gsonSharedStepDefinitionsFace = Gson()
339
+ val jsonSharedStepDefinitionsFace: String =
340
+ sharedStepDefinitionsFace.getString("FaceMatchStep", "")!!
341
+ val sharedStepDefinitionsStepFace: SubmitRequestModel =
342
+ gsonSharedStepDefinitionsFace.fromJson(
343
+ jsonSharedStepDefinitionsFace,
344
+ object : TypeToken<SubmitRequestModel>() {}.type
345
+ )
346
+
347
+ var submitRequestList: MutableList<SubmitRequestModel> = mutableListOf()
348
+ submitRequestList.add(sharedStepDefinitionsStepDoc)
349
+ submitRequestList.add(sharedStepDefinitionsStepFace)
350
+ submitRequestList.add(wrapUp!!)
351
+ submitRequestList.add(blockLoader!!)
352
+
353
+
354
+
355
+ assentifySdk.startSubmitData(this@AssentifySdkModule, submitRequestList)
356
+ }
357
+ }
358
+
359
+ /** Submit Data Functions */
360
+ override fun onSubmitError(message: String) {
361
+ val eventResultMap =
362
+ Arguments.createMap().apply {
363
+ putBoolean("success", false)
364
+ }
365
+ sendEvent("SubmitResult", eventResultMap)
366
+ }
367
+
368
+ override fun onSubmitSuccess(message: String) {
369
+ val eventResultMap =
370
+ Arguments.createMap().apply {
371
+ putBoolean("success", true)
372
+ }
373
+ sendEvent("SubmitResult", eventResultMap)
374
+ }
375
+
376
+ fun getCurrentDateTimeUTC(): String {
377
+ val currentDate = Date()
378
+
379
+ val dateFormat = SimpleDateFormat("dd/MM/yyyy HH:mm:ss", Locale.getDefault())
380
+ dateFormat.timeZone = TimeZone.getTimeZone("UTC")
381
+
382
+ return dateFormat.format(currentDate)
383
+ }
384
+
385
+ @ReactMethod
386
+ fun addListener(eventName: String) {
387
+ // Keep: Required for RN built in Event Emitter Calls.
388
+ }
389
+
390
+ @ReactMethod
391
+ fun removeListeners(count: Int) {
392
+ // Keep: Required for RN built in Event Emitter Calls.
393
+ }
394
+
395
+ private fun readableMapToMap(readableMap: ReadableMap): Map<String, Any> {
396
+ val iterator = readableMap.keySetIterator()
397
+ val resultMap = mutableMapOf<String, Any>()
398
+
399
+ while (iterator.hasNextKey()) {
400
+ val key = iterator.nextKey()
401
+ when (readableMap.getType(key)) {
402
+ ReadableType.Null -> resultMap[key] = ""
403
+ ReadableType.Boolean -> resultMap[key] = readableMap.getBoolean(key)
404
+ ReadableType.Number -> resultMap[key] = readableMap.getDouble(key)
405
+ ReadableType.String -> resultMap[key] = readableMap.getString(key)!!
406
+ ReadableType.Map -> resultMap[key] = readableMapToMap(readableMap.getMap(key)!!)
407
+ else -> {}
408
+ }
409
+ }
410
+ return resultMap
411
+ }
412
+
413
+ private fun getIdTitle(jsonStringKycDocumentDetails: String): String {
414
+ var title = "";
415
+ val gson = Gson()
416
+ val listType = object : TypeToken<List<KycDocumentDetails>>() {}.type
417
+ val kycDocumentDetails: List<KycDocumentDetails> =
418
+ gson.fromJson(jsonStringKycDocumentDetails, listType)
419
+
420
+ templatesByCountry.forEach { it ->
421
+ it.templates.forEach { template ->
422
+ if (template.kycDocumentDetails.isNotEmpty()) {
423
+ if (kycDocumentDetails[0].templateProcessingKeyInformation == template.kycDocumentDetails[0].templateProcessingKeyInformation) {
424
+ title = template.kycDocumentType;
425
+ }
426
+ }
427
+
428
+ }
429
+ }
430
+ return title;
431
+ }
432
+ }
@@ -0,0 +1,19 @@
1
+ package com.assentifysdk
2
+
3
+ import com.facebook.react.ReactPackage
4
+ import com.facebook.react.bridge.NativeModule
5
+ import com.facebook.react.bridge.ReactApplicationContext
6
+ import com.facebook.react.uimanager.ViewManager
7
+
8
+
9
+ class AssentifySdkPackage : ReactPackage {
10
+ override fun createNativeModules(reactContext: ReactApplicationContext): List<NativeModule> {
11
+ return listOf(AssentifySdkModule(reactContext))
12
+ }
13
+
14
+ override fun createViewManagers(reactContext: ReactApplicationContext): List<ViewManager<*, *>> {
15
+ return listOf<ViewManager<*, *>>(
16
+ AndroidProgressBarModule()
17
+ )
18
+ }
19
+ }