-
Notifications
You must be signed in to change notification settings - Fork 3k
/
Copy pathBaseOnfidoWeb.js
123 lines (118 loc) · 5.18 KB
/
BaseOnfidoWeb.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import _ from 'underscore';
import './index.css';
import lodashGet from 'lodash/get';
import React from 'react';
import * as OnfidoSDK from 'onfido-sdk-ui';
import withLocalize, {withLocalizePropTypes} from '../withLocalize';
import onfidoPropTypes from './onfidoPropTypes';
import CONST from '../../CONST';
import variables from '../../styles/variables';
import themeColors from '../../styles/themes/default';
import fontWeightBold from '../../styles/fontWeight/bold';
import fontFamily from '../../styles/fontFamily';
import Log from '../../libs/Log';
const propTypes = {
...withLocalizePropTypes,
...onfidoPropTypes,
};
class Onfido extends React.Component {
componentDidMount() {
this.onfidoOut = OnfidoSDK.init({
token: this.props.sdkToken,
containerId: CONST.ONFIDO.CONTAINER_ID,
useMemoryHistory: true,
customUI: {
fontFamilyTitle: `${fontFamily.EXP_NEUE}, -apple-system, serif`,
fontFamilySubtitle: `${fontFamily.EXP_NEUE}, -apple-system, serif`,
fontFamilyBody: `${fontFamily.EXP_NEUE}, -apple-system, serif`,
fontSizeTitle: `${variables.fontSizeLarge}px`,
fontWeightTitle: fontWeightBold,
fontWeightSubtitle: 400,
fontSizeSubtitle: `${variables.fontSizeNormal}px`,
colorContentTitle: themeColors.text,
colorContentSubtitle: themeColors.text,
colorContentBody: themeColors.text,
borderRadiusButton: `${variables.buttonBorderRadius}px`,
colorBackgroundSurfaceModal: themeColors.appBG,
colorBorderDocTypeButton: themeColors.border,
colorBorderDocTypeButtonHover: themeColors.link,
colorBackgroundButtonPrimary: themeColors.success,
colorBackgroundButtonPrimaryHover: themeColors.successHover,
colorBackgroundButtonPrimaryActive: themeColors.successHover,
colorBorderButtonPrimary: themeColors.success,
colorContentButtonSecondaryText: themeColors.text,
colorBackgroundButtonSecondary: themeColors.border,
colorBackgroundButtonSecondaryHover: themeColors.icon,
colorBackgroundButtonSecondaryActive: themeColors.icon,
colorBorderButtonSecondary: themeColors.border,
colorBackgroundIcon: themeColors.transparent,
colorContentLinkTextHover: themeColors.appBG,
colorBorderLinkUnderline: themeColors.link,
colorBackgroundLinkHover: themeColors.link,
colorBackgroundLinkActive: themeColors.link,
authAccentColor: themeColors.link,
colorBackgroundInfoPill: themeColors.link,
colorBackgroundSelector: themeColors.appBG,
colorBackgroundDocTypeButton: themeColors.success,
colorBackgroundDocTypeButtonHover: themeColors.successHover,
},
steps: [
{
type: CONST.ONFIDO.TYPE.DOCUMENT,
options: {
useLiveDocumentCapture: true,
forceCrossDevice: true,
hideCountrySelection: true,
country: 'USA',
uploadFallback: false,
documentTypes: {
driving_licence: {
country: 'USA',
},
passport: true,
},
},
},
{
type: CONST.ONFIDO.TYPE.FACE,
options: {
requestedVariant: CONST.ONFIDO.VARIANT.VIDEO,
uploadFallback: false,
},
},
],
smsNumberCountryCode: CONST.ONFIDO.SMS_NUMBER_COUNTRY_CODE.US,
showCountrySelection: false,
onComplete: (data) => {
if (_.isEmpty(data)) {
Log.warn('Onfido completed with no data');
}
this.props.onSuccess(data);
},
onError: (error) => {
const errorMessage = lodashGet(error, 'message', CONST.ERROR.UNKNOWN_ERROR);
const errorType = lodashGet(error, 'type');
Log.hmmm('Onfido error', {errorType, errorMessage});
this.props.onError(errorMessage);
},
onUserExit: (userExitCode) => {
Log.hmmm('Onfido user exits the flow', {userExitCode});
this.props.onUserExit(userExitCode);
},
onModalRequestClose: () => {
Log.hmmm('Onfido user closed the modal');
},
language: this.props.preferredLocale,
});
window.addEventListener('userAnalyticsEvent', (event) => {
Log.hmmm('Receiving Onfido analytic event', event.detail);
});
}
render() {
return (
<div id={CONST.ONFIDO.CONTAINER_ID} />
);
}
}
Onfido.propTypes = propTypes;
export default withLocalize(Onfido);