@idnow/react-idcheckio 8.1.9 → 9.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +23 -45
  2. package/android/build.gradle +2 -2
  3. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  4. package/android/gradle/wrapper/gradle-wrapper.properties +7 -0
  5. package/android/src/main/java/com/idnowreactidcheckio/{IdnowReactIdcheckioModule.kt → IDCheckIOBridgeModule.kt} +25 -27
  6. package/android/src/main/java/com/idnowreactidcheckio/IdnowReactIdcheckioActivity.kt +17 -15
  7. package/android/src/main/java/com/idnowreactidcheckio/IdnowReactIdcheckioPackage.kt +1 -1
  8. package/android/src/main/java/com/idnowreactidcheckio/bean/ExtractionReact.kt +4 -4
  9. package/android/src/main/java/com/idnowreactidcheckio/bean/IntegrityCheckReact.kt +2 -2
  10. package/android/src/main/java/com/idnowreactidcheckio/bean/OnlineContextEnum.kt +9 -0
  11. package/android/src/main/java/com/idnowreactidcheckio/bean/ParamsEnum.kt +1 -2
  12. package/android/src/main/java/com/idnowreactidcheckio/utils/Mapper.kt +17 -53
  13. package/app.plugin.js +19 -0
  14. package/idnow-react-idcheckio.podspec +5 -24
  15. package/ios/IDCheckIOBridgeModule.m +29 -0
  16. package/ios/IDCheckIOBridgeModule.swift +106 -0
  17. package/ios/Models/ParamsEnum.swift +0 -1
  18. package/ios/Utils/Mapper.swift +16 -38
  19. package/package.json +7 -3
  20. package/plugins/addSPMDependency.js +119 -0
  21. package/plugins/copyNativeFiles.js +135 -0
  22. package/release-public.sh +2 -2
  23. package/src/index.d.ts +6 -33
  24. package/src/index.js +36 -58
  25. package/android/src/main/java/com/idnowreactidcheckio/bean/Theme.kt +0 -29
  26. package/android/src/main/java/com/idnowreactidcheckio/bean/ThemeEnum.kt +0 -13
  27. package/ios/IdnowReactIdcheckio-Bridging-Header.h +0 -2
  28. package/ios/IdnowReactIdcheckio.mm +0 -29
  29. package/ios/IdnowReactIdcheckio.swift +0 -131
  30. package/ios/Models/ThemeEnum.swift +0 -20
  31. package/ios/Models/ThemeReact.swift +0 -32
package/src/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  import { NativeModules, Platform } from 'react-native';
2
+ const { IDCheckIOBridgeModule } = NativeModules;
2
3
 
3
4
  const LINKING_ERROR =
4
5
  `The package '@idnow/react-idcheckio' doesn't seem to be linked. Make sure: \n\n` +
@@ -6,61 +7,60 @@ const LINKING_ERROR =
6
7
  '- You rebuilt the app after installing the package\n' +
7
8
  '- You are not using Expo Go\n';
8
9
 
9
- const IdnowReactIdcheckio = NativeModules.IdnowReactIdcheckio
10
- ? NativeModules.IdnowReactIdcheckio
10
+ const IdnowReactIdcheckio = NativeModules.IDCheckIOBridgeModule
11
+ ? NativeModules.IDCheckIOBridgeModule
11
12
  : new Proxy(
12
- {},
13
- {
14
- get() {
15
- throw new Error(LINKING_ERROR);
16
- },
17
- }
18
- );
13
+ {},
14
+ {
15
+ get() {
16
+ throw new Error(LINKING_ERROR);
17
+ },
18
+ }
19
+ );
19
20
 
20
21
  export function preload(extractData) {
21
22
  IdnowReactIdcheckio.preload(extractData);
22
23
  };
23
24
 
24
25
 
25
- export function activate(token, extractData) {
26
- return IdnowReactIdcheckio.activate(token, extractData);
26
+ export async function activate(token, extractData) {
27
+ return await IDCheckIOBridgeModule.activate(token, extractData);
27
28
  };
28
29
 
29
30
 
30
- export function startOnboarding(folderUid, theme) {
31
- return IdnowReactIdcheckio.startOnboarding(folderUid, theme);
31
+ export function startOnboarding(folderUid) {
32
+ return IdnowReactIdcheckio.startOnboarding(folderUid);
32
33
  };
33
34
 
34
35
 
35
- export function start(parameters, onlineContext, theme) {
36
- return IdnowReactIdcheckio.start(parameters, onlineContext, theme)
37
- .then(function(resultString) {
36
+ export function startSession(onlineContext, parameters) {
37
+ return IdnowReactIdcheckio.startSession(onlineContext, parameters)
38
+ .then(function (resultString) {
38
39
  return JSON.parse(resultString);
39
40
  })
40
- .catch(function(error) {
41
+ .catch(function (error) {
41
42
  throw error;
42
43
  });
43
44
  }
44
45
 
45
46
  export class IDCheckioParams {
46
- constructor({docType, orientation, confirmationType, useHd, integrityCheck, captureMode, sideOneExtraction, sideTwoExtraction,
47
- language, manualButtonTimer, adjustCrop, maxPictureFilesize, token, confirmAbort, onlineConfig, overrideWordings}={}){
48
- this.docType = docType
49
- this.orientation = orientation
50
- this.confirmationType = confirmationType
51
- this.useHd = useHd
52
- this.integrityCheck = integrityCheck
53
- this.captureMode = captureMode
54
- this.sideOneExtraction = sideOneExtraction
55
- this.sideTwoExtraction = sideTwoExtraction
56
- this.language = language
57
- this.manualButtonTimer = manualButtonTimer
58
- this.adjustCrop = adjustCrop
59
- this.maxPictureFilesize = maxPictureFilesize
60
- this.token = token
61
- this.confirmAbort = confirmAbort
62
- this.onlineConfig = onlineConfig
63
- this.overrideWordings = overrideWordings
47
+ constructor({ docType, orientation, confirmationType, useHd, integrityCheck, captureMode, sideOneExtraction, sideTwoExtraction,
48
+ language, manualButtonTimer, adjustCrop, maxPictureFilesize, token, confirmAbort, onlineConfig } = {}) {
49
+ this.docType = docType
50
+ this.orientation = orientation
51
+ this.confirmationType = confirmationType
52
+ this.useHd = useHd
53
+ this.integrityCheck = integrityCheck
54
+ this.captureMode = captureMode
55
+ this.sideOneExtraction = sideOneExtraction
56
+ this.sideTwoExtraction = sideTwoExtraction
57
+ this.language = language
58
+ this.manualButtonTimer = manualButtonTimer
59
+ this.adjustCrop = adjustCrop
60
+ this.maxPictureFilesize = maxPictureFilesize
61
+ this.token = token
62
+ this.confirmAbort = confirmAbort
63
+ this.onlineConfig = onlineConfig
64
64
  }
65
65
  }
66
66
 
@@ -125,13 +125,8 @@ export class IDCheckioParamsBuilder {
125
125
  this.onlineConfig = onlineConfig;
126
126
  return this;
127
127
  }
128
- setOverrideWordings(overrideWordings) {
129
- this.overrideWordings = overrideWordings
130
- return this;
131
- }
132
128
  build() {
133
129
  let params = new IDCheckioParams(this);
134
- params.overrideWordings = typeof this.overrideWordings !== 'undefined' ? Object.fromEntries(this.overrideWordings) : undefined;
135
130
  return params;
136
131
  }
137
132
  }
@@ -168,24 +163,6 @@ export class OnlineConfig {
168
163
  }
169
164
  }
170
165
 
171
- export class IDCheckTheme {
172
- constructor({
173
- primaryColor = null,
174
- foregroundColor = null,
175
- backgroundColor = null,
176
- borderColor = null,
177
- textColor = null,
178
- titleColor = null,
179
- }={}){
180
- this.primaryColor = primaryColor;
181
- this.foregroundColor = foregroundColor;
182
- this.backgroundColor = backgroundColor;
183
- this.borderColor = borderColor;
184
- this.textColor = textColor;
185
- this.titleColor = titleColor;
186
- }
187
- }
188
-
189
166
  export const DocumentType = {
190
167
  DISABLED: 'DISABLED',
191
168
  ID: 'ID',
@@ -272,3 +249,4 @@ export const CISType = {
272
249
  OTHER: 'OTHER'
273
250
  };
274
251
 
252
+ export default IDCheckIOBridgeModule;
@@ -1,29 +0,0 @@
1
- package com.idnowreactidcheckio.bean
2
-
3
- import androidx.annotation.ColorRes
4
- import com.ariadnext.idcheckio.sdk.bean.DayNightTheme
5
- import com.ariadnext.idcheckio.sdk.R
6
-
7
- internal data class Theme (
8
- @ColorRes var foregroundColor: Int? = null,
9
- @ColorRes var borderColor: Int? = null,
10
- @ColorRes var backgroundColor: Int? = null,
11
- @ColorRes var primaryColor: Int? = null,
12
- @ColorRes var titleColor: Int? = null,
13
- @ColorRes var textColor: Int? = null) {
14
-
15
- /**
16
- * Map a theme to a DayNightTheme
17
- */
18
- fun toDayNightTheme(): DayNightTheme{
19
- return DayNightTheme(
20
- foregroundColor = foregroundColor ?: R.color.idcheckio_sdk_background_color,
21
- borderColor = borderColor ?: R.color.idcheckio_sdk_border_color,
22
- backgroundColor = backgroundColor ?: R.color.idcheckio_sdk_secondary_background_color,
23
- primaryColor = primaryColor ?: R.color.idcheckio_sdk_primary_color,
24
- textColor = textColor,
25
- titleColor = titleColor
26
- )
27
- }
28
- }
29
-
@@ -1,13 +0,0 @@
1
- package com.idnowreactidcheckio.bean
2
-
3
- /**
4
- * Theme enum to simplify the mapping of a Theme Readable Map.
5
- */
6
- internal enum class ThemeEnum(val jsonValue: String) {
7
- PRIMARY_COLOR("primaryColor"),
8
- BACKGROUND_COLOR("backgroundColor"),
9
- FOREGROUND_COLOR("foregroundColor"),
10
- BORDER_COLOR("borderColor"),
11
- TEXT_COLOR("textColor"),
12
- TITLE_COLOR("titleColor")
13
- }
@@ -1,2 +0,0 @@
1
- #import <React/RCTBridgeModule.h>
2
- #import <React/RCTViewManager.h>
@@ -1,29 +0,0 @@
1
- #import <React/RCTBridgeModule.h>
2
-
3
- @interface RCT_EXTERN_MODULE(IdnowReactIdcheckio, NSObject)
4
-
5
-
6
- RCT_EXTERN_METHOD(preload:(BOOL)extractData)
7
-
8
- RCT_EXTERN_METHOD(activate:(NSString*)token
9
- extractData:(BOOL)extractData
10
- resolver:(RCTPromiseResolveBlock)resolve
11
- rejecter:(RCTPromiseRejectBlock)reject)
12
-
13
- RCT_EXTERN_METHOD(start:(NSDictionary*)params
14
- onlineContext:(NSDictionary*)onlineContext
15
- theme:(NSDictionary*)theme
16
- resolver:(RCTPromiseResolveBlock)resolve
17
- rejecter:(RCTPromiseRejectBlock)reject)
18
-
19
- RCT_EXTERN_METHOD(startOnboarding:(NSString*)folderUid
20
- theme:(NSDictionary*)theme
21
- resolver:(RCTPromiseResolveBlock)resolve
22
- rejecter:(RCTPromiseRejectBlock)reject)
23
-
24
- + (BOOL)requiresMainQueueSetup
25
- {
26
- return NO;
27
- }
28
-
29
- @end
@@ -1,131 +0,0 @@
1
- import IDCheckIOSDK
2
-
3
- @objc(IdnowReactIdcheckio)
4
- class IdnowReactIdcheckio: NSObject {
5
- let tag = "IdnowReactIdcheckio"
6
-
7
- @objc(preload:)
8
- func preload(extractData: Bool) -> Void {
9
- DispatchQueue.main.async {
10
- Idcheckio.shared.preload(extractData: extractData)
11
- }
12
- }
13
-
14
- @objc(activate:extractData:resolver:rejecter:)
15
- func activate(token: String, extractData: Bool, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
16
- DispatchQueue.main.async {
17
- Idcheckio.shared.activate(withToken: token, extractData: extractData) { [weak self] error in
18
- DispatchQueue.main.async {
19
- guard let weakSelf = self else {
20
- IdnowReactIdcheckio.rejectWithContextLost(reject)
21
- return
22
- }
23
- if let error = error {
24
- let jsonError = weakSelf.getErrorJson(error)
25
- reject(weakSelf.tag, jsonError, error)
26
- } else {
27
- resolve("DONE")
28
- }
29
- }
30
- }
31
- }
32
- }
33
-
34
- @objc(start:onlineContext:theme:resolver:rejecter:)
35
- func start(params: Dictionary<String, Any>, onlineContext: Dictionary<String, Any>?, theme: Dictionary<String, Any>?, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
36
- DispatchQueue.main.async {
37
- let (sdkParams, sdkExtraParams) = Mapper.getIdcheckioParams(map: params)
38
- let onlineContextJson = Mapper.dictionaryToJSONString(onlineContext ?? [:]) ?? ""
39
- let onlineContextValue = OnlineContext.from(json: onlineContextJson)
40
- let cleanTheme = theme?.filter { $0.value as? String != nil } as? [String: String]
41
- let idcheckTheme = Mapper.getThemeFromReadableMap(map: cleanTheme)
42
- // Configure SDK
43
- do {
44
- // Set session parameters...
45
- Idcheckio.shared.theme = idcheckTheme
46
- try Idcheckio.shared.setParams(sdkParams)
47
- try Idcheckio.shared.setExtraParams(sdkExtraParams)
48
- } catch {
49
- // setParams(_) and setExtraParams(_) could throw an error if you're trying to apply new parameters while a session is already running
50
- print(error)
51
- }
52
- let idcheckioViewController = IdcheckioViewController()
53
- idcheckioViewController.onlineContext = onlineContextValue
54
- idcheckioViewController.resultCompletion = { [weak self] result in
55
- DispatchQueue.main.async {
56
- idcheckioViewController.dismiss(animated: true) {
57
- guard let weakSelf = self else {
58
- IdnowReactIdcheckio.rejectWithContextLost(reject)
59
- return
60
- }
61
- switch result {
62
- case .success(let idcheckioResult):
63
- // Manage success
64
- if let resultValue = idcheckioResult {
65
- resolve(weakSelf.resultToJSON(resultValue))
66
- } else {
67
- resolve("{}")
68
- }
69
- case .failure(let error):
70
- // Manage failure
71
- let jsonError = weakSelf.getErrorJson(error)
72
- reject(weakSelf.tag, jsonError, error)
73
- }
74
- }
75
- }
76
- }
77
- UIApplication.shared.keyWindow?.rootViewController?.present(idcheckioViewController, animated: true)
78
- }
79
- }
80
-
81
- @objc(startOnboarding:theme:resolver:rejecter:)
82
- func startOnboarding(folderUid: String, theme: Dictionary<String, Any>?, resolve: @escaping RCTPromiseResolveBlock, reject: @escaping RCTPromiseRejectBlock) -> Void {
83
- DispatchQueue.main.async {
84
- let viewController = UIApplication.shared.keyWindow?.rootViewController ?? UIViewController()
85
- let cleanTheme = theme?.filter { $0.value as? String != nil } as? [String: String]
86
- let idcheckTheme = Mapper.getThemeFromReadableMap(map: cleanTheme)
87
- let onboardingCustomization = OnboardingCustomization(theme: idcheckTheme)
88
- Idcheckio.startOnboarding(with: folderUid, from: viewController, onboardingCustomization: onboardingCustomization) { [weak self] resultOnboarding in
89
- DispatchQueue.main.async {
90
- guard let weakSelf = self else {
91
- IdnowReactIdcheckio.rejectWithContextLost(reject)
92
- return
93
- }
94
- switch resultOnboarding {
95
- case .success:
96
- // No data
97
- resolve("SUCCESS")
98
- case .failure(let error):
99
- // Display error information
100
- let jsonError = weakSelf.getErrorJson(error)
101
- reject(weakSelf.tag, jsonError, error)
102
- }
103
- }
104
- }
105
- }
106
- }
107
-
108
- // MARK: - Privates functions
109
- private func resultToJSON(_ result: IdcheckioResult) -> String {
110
- if let jsonData = try? JSONEncoder().encode(result) {
111
- return String(data: jsonData, encoding: .utf8) ?? ""
112
- } else {
113
- return "{}"
114
- }
115
- }
116
-
117
- private func getErrorJson(_ error: Error) -> String {
118
- if let jsonData = try? JSONEncoder().encode(error as! IdcheckioError) {
119
- return String(data: jsonData, encoding: .utf8) ?? ""
120
- } else {
121
- return "{\"message\":\"Internal error.\",\"details\":\"INTERNAL_ERROR\",\"cause\":\"INTERNAL_ERROR\"}"
122
- }
123
- }
124
-
125
- // MARK: - Statics functions
126
- private static func rejectWithContextLost(_ reject: RCTPromiseRejectBlock) {
127
- let currentError = "{\"message\":\"Failed to retrieve Self.\",\"details\":\"CONTEXT_LOST\",\"cause\":\"CONTEXT_LOST\"}"
128
- let objectError = IdcheckioError.deviceError(details: "CONTEXT_LOST", message: "Failed to retrieve Self", subcause: nil)
129
- reject("ERROR", currentError, objectError)
130
- }
131
- }
@@ -1,20 +0,0 @@
1
- //
2
- // ThemeEnum.swift
3
- // idnow-react-idcheckio
4
- //
5
- // Created by Léa Lefeuvre on 11/07/2024.
6
- //
7
-
8
- import Foundation
9
-
10
- /**
11
- * Theme enum to simplify the mapping of a Theme Readable Map.
12
- */
13
- enum ThemeEnum: String {
14
- case PRIMARY_COLOR = "primaryColor"
15
- case BACKGROUND_COLOR = "backgroundColor"
16
- case FOREGROUND_COLOR = "foregroundColor"
17
- case BORDER_COLOR = "borderColor"
18
- case TEXT_COLOR = "textColor"
19
- case TITLE_COLOR = "titleColor"
20
- }
@@ -1,32 +0,0 @@
1
- //
2
- // ThemeReact.swift
3
- // idnow-react-idcheckio
4
- //
5
- // Created by Léa Lefeuvre on 11/07/2024.
6
- //
7
-
8
- import Foundation
9
- import IDCheckIOSDK
10
-
11
- struct ThemeReact {
12
-
13
- var foregroundColor: String? = nil
14
- var borderColor: String? = nil
15
- var backgroundColor: String? = nil
16
- var primaryColor: String? = nil
17
- var titleColor: String? = nil
18
- var textColor: String? = nil
19
-
20
- /**
21
- * Map a theme to a toIDCheckioTheme
22
- */
23
- func toIDCheckioTheme() -> Theme {
24
- let theme = Theme(foregroundColor: UIColor(named: foregroundColor ?? "") ?? ColorAsset.foreground.color,
25
- backgroundColor: UIColor(named: backgroundColor ?? "") ?? ColorAsset.background.color,
26
- borderColor: UIColor(named: borderColor ?? "") ?? ColorAsset.border.color,
27
- primaryColor: UIColor(named: primaryColor ?? "") ?? ColorAsset.primary.color,
28
- titleColor: UIColor(named: titleColor ?? ""),
29
- textColor: UIColor(named: textColor ?? ""))
30
- return theme
31
- }
32
- }