@certiface/sdk 1.0.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 (68) hide show
  1. package/LICENSE +20 -0
  2. package/README.md +966 -0
  3. package/RnSdk.podspec +27 -0
  4. package/android/build.gradle +86 -0
  5. package/android/gradle.properties +6 -0
  6. package/android/src/main/AndroidManifest.xml +2 -0
  7. package/android/src/main/java/br/com/oititec/rn/sdk/RnSdkModule.kt +128 -0
  8. package/android/src/main/java/br/com/oititec/rn/sdk/RnSdkPackage.kt +33 -0
  9. package/android/src/main/java/br/com/oititec/rn/sdk/executor/LivenessExevutor.kt +66 -0
  10. package/android/src/main/java/br/com/oititec/rn/sdk/factories/FacetecThemeFactory.kt +233 -0
  11. package/android/src/main/java/br/com/oititec/rn/sdk/factories/IProovThemeFactory.kt +176 -0
  12. package/android/src/main/java/br/com/oititec/rn/sdk/managers/AssetManager.kt +152 -0
  13. package/android/src/main/java/br/com/oititec/rn/sdk/model/Featues.kt +6 -0
  14. package/android/src/main/java/br/com/oititec/rn/sdk/processors/AssetProcessor.kt +179 -0
  15. package/android/src/main/java/br/com/oititec/rn/sdk/strategy/FacetecStrategy.kt +25 -0
  16. package/android/src/main/java/br/com/oititec/rn/sdk/strategy/IProovStrategy.kt +25 -0
  17. package/android/src/main/java/br/com/oititec/rn/sdk/strategy/LivenessProviderStrategy.kt +16 -0
  18. package/android/src/main/java/br/com/oititec/rn/sdk/theme/FacetecFonts.kt +85 -0
  19. package/android/src/main/java/br/com/oititec/rn/sdk/theme/IProovFonts.kt +52 -0
  20. package/android/src/main/java/br/com/oititec/rn/sdk/utils/AssetProcessor.kt +181 -0
  21. package/android/src/main/res/drawable/backhand_left.xml +20 -0
  22. package/android/src/main/res/drawable/backhand_right.xml +20 -0
  23. package/android/src/main/res/drawable/camera_icon.xml +14 -0
  24. package/android/src/main/res/drawable/close_icon.xml +11 -0
  25. package/android/src/main/res/drawable/error_icon.xml +11 -0
  26. package/android/src/main/res/drawable/neutral_face.xml +11 -0
  27. package/android/src/main/res/drawable/success_icon.xml +11 -0
  28. package/android/src/main/res/font/sixty.ttf +0 -0
  29. package/ios/Extensions/RnSDK+Callbacks.swift +62 -0
  30. package/ios/Extensions/UIColor+Hex.swift +39 -0
  31. package/ios/Resources/Media.xcassets/Contents.json +6 -0
  32. package/ios/Resources/Media.xcassets/shell.imageset/Contents.json +12 -0
  33. package/ios/Resources/Media.xcassets/shell.imageset/shell.png +0 -0
  34. package/ios/Resources/Media.xcassets/test.imageset/Contents.json +12 -0
  35. package/ios/Resources/Media.xcassets/test.imageset/arrow_forward_ios.png +0 -0
  36. package/ios/RnSdk.h +5 -0
  37. package/ios/RnSdk.mm +71 -0
  38. package/ios/RnSdkImpl.swift +91 -0
  39. package/ios/Utils/RnSdkBundle.swift +27 -0
  40. package/ios/Utils/ThemeFactory.swift +424 -0
  41. package/lib/module/@types/result.js +2 -0
  42. package/lib/module/@types/result.js.map +1 -0
  43. package/lib/module/@types/theme.js +41 -0
  44. package/lib/module/@types/theme.js.map +1 -0
  45. package/lib/module/NativeRnSdk.js +5 -0
  46. package/lib/module/NativeRnSdk.js.map +1 -0
  47. package/lib/module/index.js +33 -0
  48. package/lib/module/index.js.map +1 -0
  49. package/lib/module/package.json +1 -0
  50. package/lib/module/utils/AssetProcessor.js +78 -0
  51. package/lib/module/utils/AssetProcessor.js.map +1 -0
  52. package/lib/typescript/package.json +1 -0
  53. package/lib/typescript/src/@types/result.d.ts +17 -0
  54. package/lib/typescript/src/@types/result.d.ts.map +1 -0
  55. package/lib/typescript/src/@types/theme.d.ts +306 -0
  56. package/lib/typescript/src/@types/theme.d.ts.map +1 -0
  57. package/lib/typescript/src/NativeRnSdk.d.ts +9 -0
  58. package/lib/typescript/src/NativeRnSdk.d.ts.map +1 -0
  59. package/lib/typescript/src/index.d.ts +14 -0
  60. package/lib/typescript/src/index.d.ts.map +1 -0
  61. package/lib/typescript/src/utils/AssetProcessor.d.ts +8 -0
  62. package/lib/typescript/src/utils/AssetProcessor.d.ts.map +1 -0
  63. package/package.json +165 -0
  64. package/src/@types/result.ts +19 -0
  65. package/src/@types/theme.ts +346 -0
  66. package/src/NativeRnSdk.ts +18 -0
  67. package/src/index.tsx +54 -0
  68. package/src/utils/AssetProcessor.ts +114 -0
@@ -0,0 +1,346 @@
1
+ export enum LivenessProvider {
2
+ FACETEC = 'FACETEC',
3
+ IPROOV = 'IPROOV',
4
+ }
5
+
6
+ export enum Environment {
7
+ HML = 'HML',
8
+ PRD = 'PRD',
9
+ }
10
+
11
+ /**
12
+ * Facetec Theme
13
+ */
14
+
15
+ export interface FacetecColors {
16
+ readyScreenHeader?: string;
17
+ readyScreenSubtext?: string;
18
+ readyScreenTextBackground?: string;
19
+ readyScreenOvalFill?: string;
20
+ resultScreenMessage?: string;
21
+ resultScreenUploadProgressBarFill?: string;
22
+ resultScreenUploadProgressBarTrack?: string;
23
+ resultScreenForeground?: string;
24
+ resultScreenBackground?: string;
25
+ resultScreenActivityIndicator?: string;
26
+ resultScreenResultAnimationBackground?: string;
27
+ resultScreenResultAnimationForeground?: string;
28
+ retryScreenHeader?: string;
29
+ retryScreenSubtext?: string;
30
+ retryScreenImageBorder?: string;
31
+ retryScreenOvalStroke?: string;
32
+ feedbackMessage?: string;
33
+ feedbackBarBackground?: string;
34
+ guidanceButtonTextNormal?: string;
35
+ guidanceButtonTextHighlight?: string;
36
+ guidanceButtonTextDisabled?: string;
37
+ guidanceButtonBackgroundNormal?: string;
38
+ guidanceButtonBackgroundHighlight?: string;
39
+ guidanceButtonBackgroundDisabled?: string;
40
+ guidanceButtonBorder?: string;
41
+ guidanceForeground?: string;
42
+ guidanceBackground?: string;
43
+ frameBackground?: string;
44
+ frameBorder?: string;
45
+ ovalStroke?: string;
46
+ ovalProgressFirst?: string;
47
+ ovalProgressSecond?: string;
48
+ overlayBackground?: string;
49
+ }
50
+
51
+ export interface FacetecTexts {
52
+ // Ready Screen
53
+ readyHeader1?: string;
54
+ readyHeader2?: string;
55
+ readyMessage1?: string;
56
+ readyMessage2?: string;
57
+ readyButton?: string;
58
+
59
+ retryHeader?: string;
60
+ retrySubheader?: string;
61
+ retryMessageSmile?: string;
62
+ retryMessageLighting?: string;
63
+ retryMessageContrast?: string;
64
+ retryYourPicture?: string;
65
+ retryIdealPicture?: string;
66
+ retryButton?: string;
67
+
68
+ resultUploadMessage?: string;
69
+ resultSuccessMessage?: string;
70
+
71
+ feedbackLookStraightInOval?: string;
72
+ feedbackCenterFace?: string;
73
+ feedbackFaceNotFound?: string;
74
+ feedbackFaceNotLookingStraightAhead?: string;
75
+ feedbackFaceNotUpright?: string;
76
+ feedbackHoldSteady?: string;
77
+ feedbackMovePhoneAway?: string;
78
+ feedbackMovePhoneCloser?: string;
79
+ feedbackMovePhoneToEyeLevel?: string;
80
+ feedbackUseEvenLighting?: string;
81
+ feedbackFrameYourFace?: string;
82
+ feedbackHoldSteady1?: string;
83
+ feedbackHoldSteady2?: string;
84
+ feedbackHoldSteady3?: string;
85
+ feedbackRemoveDarkGlasses?: string;
86
+ feedbackNeutralExpression?: string;
87
+ feedbackConditionsTooBright?: string;
88
+ feedbackBrightenYourEnvironment?: string;
89
+ }
90
+
91
+ export interface FacetecFonts {
92
+ readyScreenHeader?: string;
93
+ readyScreenSubtext?: string;
94
+ resultScreenMessage?: string;
95
+ retryScreenHeader?: string;
96
+ retryScreenSubtext?: string;
97
+ feedbackMessage?: string;
98
+ guidanceHeader?: string;
99
+ guidanceSubtext?: string;
100
+ guidanceButton?: string;
101
+ }
102
+
103
+ export interface FacetecAssets {
104
+ overlayBrandImage?: string;
105
+ cancelButtonIcon?: string;
106
+ resultScreenCustomActivityIndicatorImage?: string;
107
+ }
108
+
109
+ export interface FacetecTheme {
110
+ colors?: FacetecColors;
111
+ texts?: FacetecTexts;
112
+ fonts?: FacetecFonts;
113
+ assets?: FacetecAssets;
114
+ }
115
+
116
+ /**
117
+ * IProov Theme
118
+ */
119
+
120
+ export interface IProovColors {
121
+ closeButtonIcon?: string;
122
+ title?: string;
123
+ titleBackground?: string;
124
+ promptText?: string;
125
+ promptBackground?: string;
126
+ background?: string;
127
+ ovalReady?: string;
128
+ ovalNotReady?: string;
129
+ ovalCapturing?: string;
130
+ ovalCompleted?: string;
131
+ filterLineDrawingForeground?: string;
132
+ filterLineDrawingBackground?: string;
133
+ }
134
+
135
+ export interface IProovTexts {
136
+ title?: string;
137
+ }
138
+
139
+ export interface IProovAssets {
140
+ closeButtonIcon?: string;
141
+ logoImage?: string;
142
+ }
143
+
144
+ export interface IProovFonts {
145
+ instructionsTitleFont?: string;
146
+ instructionsCaptionFont?: string;
147
+ instructionsDocumentTypesInstructionsFont?: string;
148
+ instructionsDocumentTipsInstructionsFont?: string;
149
+ instructionsButtonFont?: string;
150
+ permissionTitleFont?: string;
151
+ permissionCaptionFont?: string;
152
+ permissionButtonFont?: string;
153
+ resultMessageFont?: string;
154
+ resultRetryButtonFont?: string;
155
+ }
156
+
157
+ export interface IProovTheme {
158
+ colors?: IProovColors;
159
+ texts?: IProovTexts;
160
+ assets?: IProovAssets;
161
+ fonts?: IProovFonts;
162
+ }
163
+
164
+ /**
165
+ * Instructions Theme
166
+ */
167
+
168
+ export interface InstructionsThemeColors {
169
+ statusBar?: string;
170
+ background?: string;
171
+ backButtonIcon?: string;
172
+ backButtonBackground?: string;
173
+ backButtonBorder?: string;
174
+ bottomSheet?: string;
175
+ title?: string;
176
+ caption?: string;
177
+ firstInstructionTitle?: string;
178
+ secondInstructionTitle?: string;
179
+ continueButtonText?: string;
180
+ continueButtonBackground?: string;
181
+ continueButtonBorder?: string;
182
+ }
183
+
184
+ export interface InstructionsThemeTexts {
185
+ title?: string;
186
+ caption?: string;
187
+ firstInstruction?: string;
188
+ secondInstruction?: string;
189
+ continueButton?: string;
190
+ }
191
+
192
+ export interface InstructionsThemeAssets {
193
+ backButtonIcon?: string;
194
+ contextImage?: string;
195
+ firstInstructionIcon?: string;
196
+ secondInstructionIcon?: string;
197
+ }
198
+
199
+ export interface InstructionsThemeFonts {
200
+ title?: string;
201
+ caption?: string;
202
+ firstInstructionTitle?: string;
203
+ secondInstructionTitle?: string;
204
+ continueButton?: string;
205
+ }
206
+
207
+ export interface InstructionsConfiguration {
208
+ showInstructionScreen?: boolean;
209
+ }
210
+
211
+ export interface InstructionsTheme {
212
+ configuration?: InstructionsConfiguration;
213
+ colors?: InstructionsThemeColors;
214
+ texts?: InstructionsThemeTexts;
215
+ assets?: InstructionsThemeAssets;
216
+ fonts?: InstructionsThemeFonts;
217
+ }
218
+
219
+ /**
220
+ * Permission Theme
221
+ */
222
+
223
+ export interface PermissionThemeColors {
224
+ statusBar?: string;
225
+ background?: string;
226
+ backButtonIcon?: string;
227
+ backButtonBackground?: string;
228
+ backButtonBorder?: string;
229
+ cameraImage?: string;
230
+ title?: string;
231
+ caption?: string;
232
+ checkPermissionButtonText?: string;
233
+ checkPermissionButtonBackground?: string;
234
+ checkPermissionButtonBorder?: string;
235
+ bottomSheet?: string;
236
+ bottomSheetTitle?: string;
237
+ bottomSheetCaption?: string;
238
+ openSettingsButtonText?: string;
239
+ openSettingsButtonBackground?: string;
240
+ openSettingsButtonBorder?: string;
241
+ closeButtonText?: string;
242
+ closeButtonBackground?: string;
243
+ closeButtonBorder?: string;
244
+ }
245
+
246
+ export interface PermissionThemeTexts {
247
+ title?: string;
248
+ caption?: string;
249
+ checkPermissionButton?: string;
250
+ bottomSheetTitle?: string;
251
+ bottomSheetCaption?: string;
252
+ openSettingsButton?: string;
253
+ closeButton?: string;
254
+ }
255
+
256
+ export interface PermissionThemeAssets {
257
+ backButtonIcon?: string;
258
+ cameraImage?: string;
259
+ }
260
+
261
+ export interface PermissionThemeFonts {
262
+ title?: string;
263
+ caption?: string;
264
+ checkPermissionButton?: string;
265
+ bottomSheetTitle?: string;
266
+ bottomSheetCaption?: string;
267
+ opentSettingsButton?: string;
268
+ closeButton?: string;
269
+ }
270
+
271
+ export interface PermissionTheme {
272
+ colors?: PermissionThemeColors;
273
+ texts?: PermissionThemeTexts;
274
+ assets?: PermissionThemeAssets;
275
+ fonts?: PermissionThemeFonts;
276
+ }
277
+
278
+ /**
279
+ * Processing Theme
280
+ */
281
+
282
+ export interface ProcessingThemeColors {
283
+ statusBar?: string;
284
+ background?: string;
285
+ loading?: string;
286
+ }
287
+
288
+ export interface ProcessingTheme {
289
+ colors?: ProcessingThemeColors;
290
+ }
291
+
292
+ /**
293
+ * Result Theme
294
+ */
295
+
296
+ export interface ResultThemeColors {
297
+ successStatusBar?: string;
298
+ successBackground?: string;
299
+ successText?: string;
300
+ errorStatusBar?: string;
301
+ errorBackground?: string;
302
+ errorText?: string;
303
+ retryBackground?: string;
304
+ retryText?: string;
305
+ retryButtonText?: string;
306
+ retryButtonBackground?: string;
307
+ retryButtonBorder?: string;
308
+ }
309
+
310
+ export interface ResultThemeTexts {
311
+ success?: string;
312
+ error?: string;
313
+ retryButton?: string;
314
+ }
315
+
316
+ export interface ResultThemeAssets {
317
+ successImage?: string;
318
+ errorImage?: string;
319
+ retryImage?: string;
320
+ }
321
+
322
+ export interface ResultThemeFonts {
323
+ text?: string;
324
+ retryButton?: string;
325
+ }
326
+
327
+ export interface ResultTheme {
328
+ colors?: ResultThemeColors;
329
+ texts?: ResultThemeTexts;
330
+ assets?: ResultThemeAssets;
331
+ fonts?: ResultThemeFonts;
332
+ }
333
+
334
+ /**
335
+ * Oiti Theme
336
+ */
337
+
338
+ export interface OitiTheme {
339
+ provider?: LivenessProvider;
340
+ facetec?: FacetecTheme;
341
+ iproov?: IProovTheme;
342
+ instructions?: InstructionsTheme;
343
+ permission?: PermissionTheme;
344
+ processing?: ProcessingTheme;
345
+ result?: ResultTheme;
346
+ }
@@ -0,0 +1,18 @@
1
+ import type { TurboModule } from 'react-native';
2
+ import { TurboModuleRegistry } from 'react-native';
3
+
4
+ export interface Spec extends TurboModule {
5
+ checkCameraPermission(): Promise<boolean>;
6
+ requestCameraPermission(): Promise<boolean>;
7
+ startJourney(
8
+ appKey: string,
9
+ environment: string,
10
+ provider: string,
11
+ onSuccess: (data: string) => void,
12
+ onError: (error: string) => void,
13
+ isCustomEnabled?: boolean,
14
+ theme?: Object
15
+ ): void;
16
+ }
17
+
18
+ export default TurboModuleRegistry.getEnforcing<Spec>('RnSdk');
package/src/index.tsx ADDED
@@ -0,0 +1,54 @@
1
+ import OitiSDK from './NativeRnSdk';
2
+ import type { LivenessProvider, OitiTheme } from './@types/theme';
3
+
4
+ import type { LivenessResponse, LivenessResult } from './@types/result';
5
+ import type { Environment } from './@types/theme';
6
+
7
+ function checkCameraPermission(): Promise<boolean> {
8
+ return OitiSDK.checkCameraPermission();
9
+ }
10
+
11
+ function requestCameraPermission(): Promise<boolean> {
12
+ return OitiSDK.requestCameraPermission();
13
+ }
14
+
15
+ async function startJourney(
16
+ appKey: string,
17
+ environment: Environment,
18
+ provider: LivenessProvider,
19
+ isCustomEnabled?: boolean,
20
+ theme?: OitiTheme
21
+ ): Promise<LivenessResult> {
22
+ return new Promise((resolve, reject) => {
23
+ OitiSDK.startJourney(
24
+ appKey,
25
+ environment,
26
+ provider,
27
+ (data: string) => {
28
+ try {
29
+ const parsedResponse: LivenessResponse = JSON.parse(data);
30
+
31
+ if (parsedResponse.status === 'success') {
32
+ resolve(parsedResponse.result);
33
+ } else {
34
+ reject(new Error(parsedResponse.message));
35
+ }
36
+ } catch (parseError) {
37
+ reject(new Error(`Failed to parse response: ${parseError}`));
38
+ }
39
+ },
40
+ (error: string) => reject(new Error(error)),
41
+ isCustomEnabled,
42
+ theme as Object
43
+ );
44
+ });
45
+ }
46
+
47
+ export const CertifaceSDK = {
48
+ checkCameraPermission,
49
+ requestCameraPermission,
50
+ startJourney,
51
+ };
52
+
53
+ export * from './@types/theme';
54
+ export * from './@types/result';
@@ -0,0 +1,114 @@
1
+ import { Image } from 'react-native';
2
+
3
+ export class AssetProcessor {
4
+ static async processThemeAssets(theme: any): Promise<any> {
5
+ if (!theme) return theme;
6
+
7
+ const processedTheme = JSON.parse(JSON.stringify(theme));
8
+
9
+ if (processedTheme.instructions?.assets) {
10
+ processedTheme.instructions.assets = await this.processInstructionsAssets(
11
+ processedTheme.instructions.assets
12
+ );
13
+ }
14
+
15
+ if (processedTheme.iproov?.assets) {
16
+ processedTheme.iproov.assets = await this.processIProovAssets(
17
+ processedTheme.iproov.assets
18
+ );
19
+ }
20
+
21
+ if (processedTheme.facetec?.assets) {
22
+ processedTheme.facetec.assets = await this.processFacetecAssets(
23
+ processedTheme.facetec.assets
24
+ );
25
+ }
26
+
27
+ return processedTheme;
28
+ }
29
+
30
+ private static async processInstructionsAssets(assets: any): Promise<any> {
31
+ const processedAssets: any = {};
32
+
33
+ if (assets.logo) {
34
+ processedAssets.logo = await this.convertAssetToBase64(assets.logo);
35
+ }
36
+
37
+ return processedAssets;
38
+ }
39
+
40
+ private static async processIProovAssets(assets: any): Promise<any> {
41
+ const processedAssets: any = {};
42
+
43
+ if (assets.logo) {
44
+ processedAssets.logo = await this.convertAssetToBase64(assets.logo);
45
+ }
46
+
47
+ if (assets.closeButton) {
48
+ processedAssets.closeButton = await this.convertAssetToBase64(
49
+ assets.closeButton
50
+ );
51
+ }
52
+
53
+ return processedAssets;
54
+ }
55
+
56
+ private static async processFacetecAssets(assets: any): Promise<any> {
57
+ const processedAssets: any = {};
58
+
59
+ if (assets.overlayBrandingImage) {
60
+ processedAssets.overlayBrandingImage = await this.convertAssetToBase64(
61
+ assets.overlayBrandingImage
62
+ );
63
+ }
64
+
65
+ if (assets.cancelButtonCustomImage) {
66
+ processedAssets.cancelButtonCustomImage = await this.convertAssetToBase64(
67
+ assets.cancelButtonCustomImage
68
+ );
69
+ }
70
+
71
+ if (assets.resultScreenCustomActivityIndicatorImage) {
72
+ processedAssets.resultScreenCustomActivityIndicatorImage =
73
+ await this.convertAssetToBase64(
74
+ assets.resultScreenCustomActivityIndicatorImage
75
+ );
76
+ }
77
+
78
+ return processedAssets;
79
+ }
80
+
81
+ private static async convertAssetToBase64(asset: any): Promise<string> {
82
+ return new Promise((resolve, reject) => {
83
+ if (typeof asset === 'string') {
84
+ resolve(asset);
85
+ return;
86
+ }
87
+
88
+ const assetSource = Image.resolveAssetSource(asset);
89
+ if (!assetSource) {
90
+ reject(new Error('Failed to resolve asset source'));
91
+ return;
92
+ }
93
+
94
+ fetch(assetSource.uri)
95
+ .then((response) => response.blob())
96
+ .then((blob) => {
97
+ const reader = new FileReader();
98
+ reader.onload = () => {
99
+ if (typeof reader.result === 'string') {
100
+ resolve(reader.result);
101
+ } else {
102
+ reject(new Error('Failed to convert asset to base64'));
103
+ }
104
+ };
105
+ reader.onerror = () => reject(new Error('Failed to read asset blob'));
106
+ reader.readAsDataURL(blob);
107
+ })
108
+ .catch((error) => {
109
+ console.warn('Failed to convert asset to base64, using URI:', error);
110
+ resolve(assetSource.uri);
111
+ });
112
+ });
113
+ }
114
+ }