This repository has been archived by the owner on Feb 10, 2021. It is now read-only.
forked from bitwala/react-native-idnow
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
95 lines (88 loc) · 2.94 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
import { NativeModules, processColor, Platform } from 'react-native';
export const defaultOptions = {
companyId: '',
showVideoOverviewCheck: true,
showErrorSuccessScreen: false,
transactionToken: 'TST-XXXXX',
ignoreCompanyID: true,
showIdentTokenOnCheckScreen: false,
forceModalPresentation: false,
// environment: 'LIVE', no need to force to use a specific env; Default is to determine this by the token used
// apiHost: null,
// webHost: null,
// websocketHost: null,
// videoHost: null,
// stunHost: null,
// stunPort: null,
appearance: {
// Adjust colors
primaryBrandColor: '#1D4477', // primaryBlue
successColor: '#1ABC9C', // successGreen
failureColor: '#EE4555', // warningRed
proceedButtonBackgroundColor: '#1D4477', // primaryBlue
proceedButtonTextColor: '#FFFFFF', // whitestWhite
photoIdentRetakeButtonBackgroundColor: '#1D4477', // primaryBlue
photoIdentRetakeButtonTextColor: '#FFFFFF', // whitestWhite
// defaultTextColor: '#000',
// textFieldColor: 'grey',
// Adjust statusbar
enableStatusBarStyleLightContent: false,
// Adjust fonts
fontNameRegular: 'HelveticaNeue',
fontNameLight: 'HelveticaNeue-Ligth',
fontNameMedium: 'HelveticaNeue-Bold',
},
};
const prepareOptions = options => {
// TODO refactor
const appearanceOptions = {
...defaultOptions.appearance,
...options.appearance,
};
return {
...defaultOptions,
...options,
appearance: {
...appearanceOptions,
defaultTextColor: processColor(appearanceOptions.defaultTextColor),
primaryBrandColor: processColor(appearanceOptions.primaryBrandColor),
proceedButtonBackgroundColor: processColor(
appearanceOptions.proceedButtonBackgroundColor
),
proceedButtonTextColor: processColor(
appearanceOptions.proceedButtonTextColor
),
photoIdentRetakeButtonBackgroundColor: processColor(
appearanceOptions.photoIdentRetakeButtonBackgroundColor
),
photoIdentRetakeButtonTextColor: processColor(
appearanceOptions.photoIdentRetakeButtonTextColor
),
textFieldColor: processColor(appearanceOptions.textFieldColor),
failureColor: processColor(appearanceOptions.failureColor),
successColor: processColor(appearanceOptions.successColor),
},
};
};
const IDnowManager = {
startVideoIdent(options) {
if (Platform.OS === 'ios') {
return new Promise((resolve, reject) => {
NativeModules.IDnowViewManager.startVideoIdent(
prepareOptions(options),
(...args) => {
const err = args[0];
const resp = args[1];
if (resp && resp.success) {
return resolve(resp);
}
return reject(err || new Error('Internal error'));
}
);
});
} else if (Platform.OS === 'android') {
return NativeModules.RNIdnow.startVideoIdent(prepareOptions(options));
}
},
};
export { IDnowManager };