@bytexbyte/berifyme-react-sdk 1.0.0 → 1.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.
- package/dist/BerifymeModal/index.js +54 -38
- package/dist/api/api.js +40 -4
- package/dist/components/AllSet/index.js +36 -21
- package/dist/components/Login/sumsub/index.js +212 -0
- package/dist/components/Login/veriff/Login.js +168 -0
- package/dist/components/Login/veriff/index.js +14 -0
- package/dist/components/Login/yoti/Login.js +235 -0
- package/dist/components/Login/yoti/index.js +14 -0
- package/dist/components/OnBoarding/authId/index.js +47 -13
- package/dist/components/OnBoarding/sumsub/index.js +183 -0
- package/dist/components/OnBoarding/vender/grid/index.js +9 -9
- package/dist/components/OnBoarding/veriff/index.js +152 -0
- package/dist/components/OnBoarding/yoti/OnBoarding.js +228 -0
- package/dist/components/OnBoarding/yoti/index.js +14 -0
- package/dist/components/SendSns/index.js +18 -13
- package/dist/components/TryAgain.js +4 -5
- package/dist/components/VerifyWithPhoneNumber/NewUser/index.js +8 -8
- package/dist/components/VerifyWithPhoneNumber/User/index.js +17 -12
- package/dist/enum/index.js +6 -0
- package/dist/types/BerifymeModal/index.d.ts +1 -1
- package/dist/types/api/api.d.ts +19 -2
- package/dist/types/components/Login/sumsub/index.d.ts +10 -0
- package/dist/types/components/Login/veriff/Login.d.ts +12 -0
- package/dist/types/components/Login/veriff/index.d.ts +11 -0
- package/dist/types/components/Login/yoti/Login.d.ts +11 -0
- package/dist/types/components/Login/yoti/index.d.ts +10 -0
- package/dist/types/components/OnBoarding/authId/index.d.ts +3 -1
- package/dist/types/components/OnBoarding/sumsub/index.d.ts +10 -0
- package/dist/types/components/OnBoarding/veriff/index.d.ts +11 -0
- package/dist/types/components/OnBoarding/yoti/OnBoarding.d.ts +12 -0
- package/dist/types/components/OnBoarding/yoti/index.d.ts +11 -0
- package/dist/types/components/SendSns/index.d.ts +1 -1
- package/dist/types/components/VerifyWithPhoneNumber/User/index.d.ts +1 -1
- package/dist/types/enum/index.d.ts +6 -0
- package/package.json +1 -1
|
@@ -34,38 +34,39 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
34
34
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
|
-
import { environmentDomains } from '../lib/environmentDomains';
|
|
38
|
-
import { PageStatus } from '../enum';
|
|
39
37
|
import { Box, CircularProgress, CssBaseline, ThemeProvider } from '@mui/material';
|
|
40
38
|
import React, { useEffect, useState } from 'react';
|
|
41
|
-
import
|
|
39
|
+
import '../../index.css';
|
|
42
40
|
import berifymeApi, { initializeBerifymeApi } from '../api/api';
|
|
43
|
-
import { incode } from '../vender/incode/incode';
|
|
44
41
|
import AllSet from '../components/AllSet';
|
|
45
|
-
import Modal from './MainModal';
|
|
46
|
-
import RedirectToMobile from '../components/RedirectToMobile';
|
|
47
|
-
import ScreenRotation from '../components/ScreenRotation';
|
|
48
|
-
import TryAgainInModal from '../components/TryAgainInModal';
|
|
49
42
|
import { createDeveloperLog } from '../components/createDeveloperLog';
|
|
50
43
|
import { AuthidLogin } from '../components/Login/authid';
|
|
51
44
|
import { ClearLogin } from '../components/Login/clear';
|
|
52
45
|
import { ClearLoginAllSet } from '../components/Login/clearAllSet';
|
|
53
46
|
import { IncodeLogin } from '../components/Login/incode';
|
|
54
|
-
|
|
55
|
-
|
|
47
|
+
import SumsubLogin from '../components/Login/sumsub';
|
|
48
|
+
import VeriffLogin from '../components/Login/veriff';
|
|
49
|
+
import YotiLogin from '../components/Login/yoti';
|
|
56
50
|
import AuthID from '../components/OnBoarding/authId';
|
|
57
51
|
import IdOrPassport from '../components/OnBoarding/authId/idOrPassport';
|
|
58
52
|
import { ClearOnboarding } from '../components/OnBoarding/clear';
|
|
59
53
|
import { ClearOnboardingAllSet } from '../components/OnBoarding/clear/clearAllSet';
|
|
60
54
|
import { IncodeOnBoarding } from '../components/OnBoarding/incode';
|
|
61
|
-
|
|
55
|
+
import SumsubOnBoarding from '../components/OnBoarding/sumsub';
|
|
62
56
|
import Vender from '../components/OnBoarding/vender';
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
import VeriffOnBoarding from '../components/OnBoarding/veriff';
|
|
58
|
+
import YotiOnBoarding from '../components/OnBoarding/yoti';
|
|
59
|
+
import RedirectToMobile from '../components/RedirectToMobile';
|
|
60
|
+
import ScreenRotation from '../components/ScreenRotation';
|
|
65
61
|
import SendSns from '../components/SendSns';
|
|
62
|
+
import theme from '../components/theme';
|
|
63
|
+
import TryAgainInModal from '../components/TryAgainInModal';
|
|
66
64
|
import VerifyNewUser from '../components/VerifyWithPhoneNumber/NewUser';
|
|
67
65
|
import VerifyUser from '../components/VerifyWithPhoneNumber/User';
|
|
68
|
-
import '
|
|
66
|
+
import { PageStatus } from '../enum';
|
|
67
|
+
import { environmentDomains } from '../lib/environmentDomains';
|
|
68
|
+
import { incode } from '../vender/incode/incode';
|
|
69
|
+
import Modal from './MainModal';
|
|
69
70
|
var HomeModal = function (_a) {
|
|
70
71
|
var apiKeyId = _a.apiKeyId, secretKey = _a.secretKey, redirectUrl = _a.redirectUrl, _b = _a.initialPhoneNumber, initialPhoneNumber = _b === void 0 ? '' : _b, environment = _a.environment, forceQrcode = _a.forceQrcode;
|
|
71
72
|
var _c = useState(window.innerWidth > window.innerHeight), isLandscape = _c[0], setIsLandscape = _c[1];
|
|
@@ -184,7 +185,7 @@ var HomeModal = function (_a) {
|
|
|
184
185
|
setPageStatus(7);
|
|
185
186
|
}
|
|
186
187
|
else {
|
|
187
|
-
setPageStatus(
|
|
188
|
+
setPageStatus(PageStatus.SendSns);
|
|
188
189
|
}
|
|
189
190
|
}, []);
|
|
190
191
|
useEffect(function () {
|
|
@@ -213,58 +214,61 @@ var HomeModal = function (_a) {
|
|
|
213
214
|
else if (isLandscape) {
|
|
214
215
|
setModalHeight('100vh');
|
|
215
216
|
}
|
|
216
|
-
else if (pageStatus ===
|
|
217
|
+
else if (pageStatus === PageStatus.SendSns) {
|
|
217
218
|
setModalHeight('58vh');
|
|
218
219
|
}
|
|
219
|
-
else if (pageStatus ===
|
|
220
|
+
else if (pageStatus === PageStatus.VerifyNewUser) {
|
|
220
221
|
setModalHeight('64vh');
|
|
221
222
|
}
|
|
222
|
-
else if (pageStatus ===
|
|
223
|
-
setModalHeight('
|
|
223
|
+
else if (pageStatus === PageStatus.AuthIdOnboarding) {
|
|
224
|
+
setModalHeight('100vh');
|
|
224
225
|
}
|
|
225
|
-
else if (pageStatus ===
|
|
226
|
+
else if (pageStatus === PageStatus.ClearLogin) {
|
|
226
227
|
setModalHeight('100vh');
|
|
227
228
|
}
|
|
228
|
-
else if (pageStatus ===
|
|
229
|
+
else if (pageStatus === PageStatus.IncodeLogin) {
|
|
229
230
|
setModalHeight('100vh');
|
|
230
231
|
}
|
|
231
|
-
else if (pageStatus ===
|
|
232
|
+
else if (pageStatus === PageStatus.ClearLoginAllSet) {
|
|
232
233
|
setModalHeight('58vh');
|
|
233
234
|
}
|
|
234
|
-
else if (pageStatus ===
|
|
235
|
+
else if (pageStatus === PageStatus.ClearOnboardingAllSet) {
|
|
235
236
|
setModalHeight('58vh');
|
|
236
237
|
}
|
|
237
|
-
else if (pageStatus ===
|
|
238
|
+
else if (pageStatus === PageStatus.SumsubLogin) {
|
|
238
239
|
setModalHeight('80vh');
|
|
239
240
|
}
|
|
240
|
-
else if (pageStatus ===
|
|
241
|
+
else if (pageStatus === PageStatus.VeriffLogin) {
|
|
241
242
|
setModalHeight('100vh');
|
|
242
243
|
}
|
|
243
|
-
else if (pageStatus ===
|
|
244
|
+
else if (pageStatus === PageStatus.YotiLogin) {
|
|
245
|
+
setModalHeight('80vh');
|
|
246
|
+
}
|
|
247
|
+
else if (pageStatus === PageStatus.Vender) {
|
|
244
248
|
setModalHeight('80vh');
|
|
245
249
|
}
|
|
246
|
-
else if (pageStatus ===
|
|
250
|
+
else if (pageStatus === PageStatus.IdOrPassport) {
|
|
247
251
|
setModalHeight('55vh');
|
|
248
252
|
}
|
|
249
|
-
else if (pageStatus ===
|
|
253
|
+
else if (pageStatus === PageStatus.VerifyUser) {
|
|
250
254
|
setModalHeight('46vh');
|
|
251
255
|
}
|
|
252
|
-
else if (pageStatus ===
|
|
256
|
+
else if (pageStatus === PageStatus.ClearOnboarding) {
|
|
253
257
|
setModalHeight('100vh');
|
|
254
258
|
}
|
|
255
|
-
else if (pageStatus ===
|
|
259
|
+
else if (pageStatus === PageStatus.IncodeOnBoarding) {
|
|
256
260
|
setModalHeight('100vh');
|
|
257
261
|
}
|
|
258
|
-
else if (pageStatus ===
|
|
262
|
+
else if (pageStatus === PageStatus.SumsubOnBoarding) {
|
|
259
263
|
setModalHeight('80vh');
|
|
260
264
|
}
|
|
261
|
-
else if (pageStatus ===
|
|
265
|
+
else if (pageStatus === PageStatus.VeriffOnBoarding) {
|
|
262
266
|
setModalHeight('100vh');
|
|
263
267
|
}
|
|
264
|
-
else if (pageStatus ===
|
|
268
|
+
else if (pageStatus === PageStatus.YotiOnBoarding) {
|
|
265
269
|
setModalHeight('80vh');
|
|
266
270
|
}
|
|
267
|
-
else if (pageStatus ===
|
|
271
|
+
else if (pageStatus === PageStatus.AllSet) {
|
|
268
272
|
setModalHeight('58vh');
|
|
269
273
|
}
|
|
270
274
|
else {
|
|
@@ -310,21 +314,33 @@ var HomeModal = function (_a) {
|
|
|
310
314
|
pageStatus === PageStatus.VerifyUser &&
|
|
311
315
|
React.createElement(VerifyUser, { token: token, inputValue: inputValue, setError: setError, setPageStatus: setPageStatus, setModalHeight: setModalHeight, setUser: setUser, environment: environment }),
|
|
312
316
|
pageStatus === PageStatus.AuthIdOnboarding && user &&
|
|
313
|
-
React.createElement(AuthID, { token: token, goToAllSet: function () { return setPageStatus(
|
|
317
|
+
React.createElement(AuthID, { token: token, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); }, setError: setError, userId: user.id, setUser: setUser, selectedIdType: authIdSelectedIdType, setSelectedIdType: setAuthIdSelectedIdType, setPageStatus: setPageStatus }),
|
|
314
318
|
pageStatus === PageStatus.ClearOnboarding && user &&
|
|
315
319
|
React.createElement(ClearOnboarding, { token: token, user: user, desktopRedirectUrlId: desktopRedirectUrlId }),
|
|
316
320
|
pageStatus === PageStatus.IncodeOnBoarding && user &&
|
|
317
|
-
React.createElement(IncodeOnBoarding, { user: user, setUser: setUser, token: token, goToAllSet: function () { return setPageStatus(
|
|
321
|
+
React.createElement(IncodeOnBoarding, { user: user, setUser: setUser, token: token, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); } }),
|
|
322
|
+
pageStatus === PageStatus.SumsubOnBoarding && user &&
|
|
323
|
+
React.createElement(SumsubOnBoarding, { user: user, setUser: setUser, token: token, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); } }),
|
|
324
|
+
pageStatus === PageStatus.VeriffOnBoarding && user &&
|
|
325
|
+
React.createElement(VeriffOnBoarding, { user: user, setUser: setUser, token: token, goBack: function () { return setPageStatus(1.1); }, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); } }),
|
|
326
|
+
pageStatus === PageStatus.YotiOnBoarding && user &&
|
|
327
|
+
React.createElement(YotiOnBoarding, { user: user, setUser: setUser, token: token, onSuccess: function () { return setPageStatus(PageStatus.AllSet); }, onGoBack: function () { return setPageStatus(1.1); } }),
|
|
318
328
|
pageStatus === PageStatus.AuthidLogin && processedPhoneNumber &&
|
|
319
|
-
React.createElement(AuthidLogin, { token: token, goToAllSet: function () { return setPageStatus(
|
|
329
|
+
React.createElement(AuthidLogin, { token: token, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); }, phoneNumber: processedPhoneNumber, setUser: setUser }),
|
|
320
330
|
pageStatus === PageStatus.ClearLogin &&
|
|
321
331
|
React.createElement(ClearLogin, { token: token, userId: user === null || user === void 0 ? void 0 : user.id, desktopRedirectUrlId: desktopRedirectUrlId }),
|
|
322
332
|
pageStatus === PageStatus.IncodeLogin &&
|
|
323
|
-
React.createElement(IncodeLogin, { token: token, user: user, setUser: setUser, goToAllSet: function () { return setPageStatus(
|
|
333
|
+
React.createElement(IncodeLogin, { token: token, user: user, setUser: setUser, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); } }),
|
|
324
334
|
pageStatus === PageStatus.ClearLoginAllSet &&
|
|
325
335
|
React.createElement(ClearLoginAllSet, { token: token, desktopRedirectUrlId: desktopRedirectUrlId }),
|
|
326
336
|
pageStatus === PageStatus.ClearOnboardingAllSet &&
|
|
327
337
|
React.createElement(ClearOnboardingAllSet, { token: token, desktopRedirectUrlId: desktopRedirectUrlId }),
|
|
338
|
+
pageStatus === PageStatus.SumsubLogin && user &&
|
|
339
|
+
React.createElement(SumsubLogin, { user: user, setUser: setUser, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); }, token: token }),
|
|
340
|
+
pageStatus === PageStatus.VeriffLogin && user &&
|
|
341
|
+
React.createElement(VeriffLogin, { user: user, setUser: setUser, onGoBack: function () { return setPageStatus(PageStatus.SendSns); }, onSuccess: function () { return setPageStatus(PageStatus.AllSet); }, token: token }),
|
|
342
|
+
pageStatus === PageStatus.YotiLogin && user &&
|
|
343
|
+
React.createElement(YotiLogin, { user: user, setUser: setUser, onSuccess: function () { return setPageStatus(PageStatus.AllSet); }, token: token }),
|
|
328
344
|
pageStatus === PageStatus.AllSet &&
|
|
329
345
|
React.createElement(AllSet, { user: user, token: token, desktopRedirectUrlId: desktopRedirectUrlId })))))))));
|
|
330
346
|
};
|
package/dist/api/api.js
CHANGED
|
@@ -1186,12 +1186,12 @@ function getOrderByCountry(_a) {
|
|
|
1186
1186
|
});
|
|
1187
1187
|
});
|
|
1188
1188
|
}
|
|
1189
|
-
function
|
|
1189
|
+
function createYotiIDVSession(_a) {
|
|
1190
1190
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
1191
1191
|
var url;
|
|
1192
1192
|
var phoneNumber = _b.phoneNumber;
|
|
1193
1193
|
return __generator(this, function (_c) {
|
|
1194
|
-
url = "".concat(config.backendDomain, "/api/yoti/
|
|
1194
|
+
url = "".concat(config.backendDomain, "/api/yoti/idvSession");
|
|
1195
1195
|
return [2 /*return*/, axios.post(url, { phoneNumber: phoneNumber })
|
|
1196
1196
|
.then(function (res) {
|
|
1197
1197
|
return res.data;
|
|
@@ -1203,6 +1203,23 @@ function createYotiSession(_a) {
|
|
|
1203
1203
|
});
|
|
1204
1204
|
});
|
|
1205
1205
|
}
|
|
1206
|
+
function createYotiFaceLoginSession(_a) {
|
|
1207
|
+
return __awaiter(this, arguments, void 0, function (_b) {
|
|
1208
|
+
var url;
|
|
1209
|
+
var sessionId = _b.sessionId;
|
|
1210
|
+
return __generator(this, function (_c) {
|
|
1211
|
+
url = "".concat(config.backendDomain, "/api/yoti/faceLoginSession");
|
|
1212
|
+
return [2 /*return*/, axios.post(url, { sessionId: sessionId })
|
|
1213
|
+
.then(function (res) {
|
|
1214
|
+
return res.data;
|
|
1215
|
+
})
|
|
1216
|
+
.catch(function (err) {
|
|
1217
|
+
var _a;
|
|
1218
|
+
return (_a = err.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
1219
|
+
})];
|
|
1220
|
+
});
|
|
1221
|
+
});
|
|
1222
|
+
}
|
|
1206
1223
|
function approveYotiUser(_a) {
|
|
1207
1224
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
1208
1225
|
var url;
|
|
@@ -1220,6 +1237,23 @@ function approveYotiUser(_a) {
|
|
|
1220
1237
|
});
|
|
1221
1238
|
});
|
|
1222
1239
|
}
|
|
1240
|
+
function getYotiFaceLoginResult(_a) {
|
|
1241
|
+
return __awaiter(this, arguments, void 0, function (_b) {
|
|
1242
|
+
var url;
|
|
1243
|
+
var sessionId = _b.sessionId;
|
|
1244
|
+
return __generator(this, function (_c) {
|
|
1245
|
+
url = "".concat(config.backendDomain, "/api/yoti/faceLoginResult");
|
|
1246
|
+
return [2 /*return*/, axios.get(url, { params: { sessionId: sessionId } })
|
|
1247
|
+
.then(function (res) {
|
|
1248
|
+
return res.data;
|
|
1249
|
+
})
|
|
1250
|
+
.catch(function (err) {
|
|
1251
|
+
var _a;
|
|
1252
|
+
return (_a = err.response) === null || _a === void 0 ? void 0 : _a.data;
|
|
1253
|
+
})];
|
|
1254
|
+
});
|
|
1255
|
+
});
|
|
1256
|
+
}
|
|
1223
1257
|
function getUserByYotiId(_a) {
|
|
1224
1258
|
return __awaiter(this, arguments, void 0, function (_b) {
|
|
1225
1259
|
var url;
|
|
@@ -1329,8 +1363,10 @@ var berifymeApi = {
|
|
|
1329
1363
|
getVeriffFaceLoginResult: getVeriffFaceLoginResult
|
|
1330
1364
|
},
|
|
1331
1365
|
yoti: {
|
|
1332
|
-
|
|
1333
|
-
|
|
1366
|
+
createYotiIDVSession: createYotiIDVSession,
|
|
1367
|
+
createYotiFaceLoginSession: createYotiFaceLoginSession,
|
|
1368
|
+
approveYotiUser: approveYotiUser,
|
|
1369
|
+
getYotiFaceLoginResult: getYotiFaceLoginResult
|
|
1334
1370
|
},
|
|
1335
1371
|
getOrderByCountry: getOrderByCountry,
|
|
1336
1372
|
};
|
|
@@ -35,7 +35,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
35
35
|
}
|
|
36
36
|
};
|
|
37
37
|
import React from "react";
|
|
38
|
-
import { Button, Stack, Typography } from "@mui/material";
|
|
38
|
+
import { Box, Button, CircularProgress, Stack, Typography } from "@mui/material";
|
|
39
39
|
import theme from "../theme";
|
|
40
40
|
import GppGoodOutlinedIcon from '@mui/icons-material/GppGoodOutlined';
|
|
41
41
|
import { useSpeedTest } from "../speedTest/SpeedProvider";
|
|
@@ -65,6 +65,8 @@ var AllSet = function (_a) {
|
|
|
65
65
|
var user = _a.user, token = _a.token, desktopRedirectUrlId = _a.desktopRedirectUrlId;
|
|
66
66
|
var _b = useState(''), error = _b[0], setError = _b[1];
|
|
67
67
|
var _c = useState(), desktopStatusMessage = _c[0], setDesktopStatusMessage = _c[1];
|
|
68
|
+
var _d = useState(true), loading = _d[0], setLoading = _d[1];
|
|
69
|
+
var _e = useState(''), redirectUrl = _e[0], setRedirectUrl = _e[1];
|
|
68
70
|
var checkOldDeviceId = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
69
71
|
var deviceId, deviceUser;
|
|
70
72
|
return __generator(this, function (_a) {
|
|
@@ -109,7 +111,7 @@ var AllSet = function (_a) {
|
|
|
109
111
|
startSpeedTest();
|
|
110
112
|
checkAndIssueToken();
|
|
111
113
|
}, []);
|
|
112
|
-
var
|
|
114
|
+
var getRedirectUrl = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
113
115
|
var res;
|
|
114
116
|
return __generator(this, function (_a) {
|
|
115
117
|
switch (_a.label) {
|
|
@@ -127,12 +129,13 @@ var AllSet = function (_a) {
|
|
|
127
129
|
action: 'getRedirectUrl',
|
|
128
130
|
sessionToken: token,
|
|
129
131
|
});
|
|
132
|
+
setLoading(false);
|
|
130
133
|
if (!res.redirectUrl) {
|
|
131
134
|
setError('Oops! Something went wrong...');
|
|
132
135
|
return [2 /*return*/];
|
|
133
136
|
}
|
|
134
137
|
if (desktopRedirectUrlId === undefined) {
|
|
135
|
-
|
|
138
|
+
setRedirectUrl(res.redirectUrl);
|
|
136
139
|
}
|
|
137
140
|
else {
|
|
138
141
|
if (res.heartbeatStopped)
|
|
@@ -144,26 +147,38 @@ var AllSet = function (_a) {
|
|
|
144
147
|
}
|
|
145
148
|
});
|
|
146
149
|
}); };
|
|
150
|
+
useEffect(function () {
|
|
151
|
+
getRedirectUrl();
|
|
152
|
+
}, []);
|
|
147
153
|
return (React.createElement(React.Fragment, null, error ?
|
|
148
154
|
React.createElement(TryAgain, { message: error }) :
|
|
149
|
-
React.createElement(React.Fragment, null,
|
|
150
|
-
React.createElement(
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
155
|
+
React.createElement(React.Fragment, null, loading ?
|
|
156
|
+
React.createElement(Box, { sx: {
|
|
157
|
+
display: 'flex',
|
|
158
|
+
justifyContent: 'center',
|
|
159
|
+
alignItems: 'center',
|
|
160
|
+
height: '100vh',
|
|
161
|
+
background: '#FFFFFF'
|
|
162
|
+
} },
|
|
163
|
+
React.createElement(CircularProgress, null)) :
|
|
164
|
+
React.createElement(React.Fragment, null, desktopStatusMessage ?
|
|
165
|
+
React.createElement(Stack, { height: 1, justifyContent: "center", alignItems: "center" },
|
|
166
|
+
React.createElement(Stack, { alignItems: "center", spacing: 2 },
|
|
157
167
|
React.createElement("img", { width: 40, height: 40, src: "https://staging.berify.me/berify.svg", alt: "berify" }),
|
|
158
|
-
React.createElement(Typography, { variant: "
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
+
React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, desktopStatusMessage)))
|
|
169
|
+
:
|
|
170
|
+
React.createElement(Stack, { height: 1, spacing: 4, justifyContent: 'space-between', py: 4, overflow: 'auto' },
|
|
171
|
+
React.createElement(Stack, { spacing: 2, textAlign: 'center', alignItems: 'center' },
|
|
172
|
+
React.createElement("img", { width: 40, height: 40, src: "https://staging.berify.me/berify.svg", alt: "berify" }),
|
|
173
|
+
React.createElement(Typography, { variant: "h2", fontWeight: 700 },
|
|
174
|
+
"You\u2019re Berified,",
|
|
175
|
+
React.createElement("br", null), user === null || user === void 0 ? void 0 :
|
|
176
|
+
user.fullName),
|
|
177
|
+
React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "Thank you for securely verifying your identity through Berify.me \uD83C\uDF89")),
|
|
178
|
+
React.createElement(Stack, { spacing: 2, alignItems: 'center' },
|
|
179
|
+
React.createElement(Button, { variant: "contained", onClick: function () { window.location.href = redirectUrl; }, sx: { minWidth: 160 } }, "Continue")),
|
|
180
|
+
React.createElement(Stack, { direction: 'row', spacing: 2, textAlign: 'center', justifyContent: 'center', color: theme.palette.text.secondary },
|
|
181
|
+
React.createElement(GppGoodOutlinedIcon, null),
|
|
182
|
+
React.createElement(Typography, { variant: "body1" }, "Securely powered by Berify.me")))))));
|
|
168
183
|
};
|
|
169
184
|
export default AllSet;
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
+
function step(op) {
|
|
15
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
18
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
+
switch (op[0]) {
|
|
20
|
+
case 0: case 1: t = op; break;
|
|
21
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
+
default:
|
|
25
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
+
if (t[2]) _.ops.pop();
|
|
30
|
+
_.trys.pop(); continue;
|
|
31
|
+
}
|
|
32
|
+
op = body.call(thisArg, _);
|
|
33
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
import SumsubWebSdk from '@sumsub/websdk-react';
|
|
38
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
39
|
+
import berifymeApi from '../../../api/api';
|
|
40
|
+
import { delay } from '../../../common';
|
|
41
|
+
import { createDeveloperLog } from '../../createDeveloperLog';
|
|
42
|
+
import TryAgain from '../../TryAgain';
|
|
43
|
+
var OPTIONS = { addViewportTag: false, adaptIframeHeight: true };
|
|
44
|
+
var SumsubLogin = function (_a) {
|
|
45
|
+
var user = _a.user, setUser = _a.setUser, goToAllSet = _a.goToAllSet, token = _a.token;
|
|
46
|
+
var _b = useState(), accessToken = _b[0], setAccessToken = _b[1];
|
|
47
|
+
var _c = useState(), externalActionId = _c[0], setExternalActionId = _c[1];
|
|
48
|
+
var _d = useState(), error = _d[0], setError = _d[1];
|
|
49
|
+
var getAccessToken = useCallback((function (phoneNumber) { return __awaiter(void 0, void 0, void 0, function () {
|
|
50
|
+
var accessTokenResponse;
|
|
51
|
+
return __generator(this, function (_a) {
|
|
52
|
+
switch (_a.label) {
|
|
53
|
+
case 0: return [4 /*yield*/, berifymeApi.sumsub.createAccessToken({ phoneNumber: phoneNumber, levelName: 'face-login' })];
|
|
54
|
+
case 1:
|
|
55
|
+
accessTokenResponse = _a.sent();
|
|
56
|
+
if ('error' in accessTokenResponse) {
|
|
57
|
+
console.log('error', accessTokenResponse.error);
|
|
58
|
+
createDeveloperLog({
|
|
59
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
60
|
+
userDataJson: user,
|
|
61
|
+
source: 'FRONTEND',
|
|
62
|
+
action: 'sumsub api',
|
|
63
|
+
sessionToken: token,
|
|
64
|
+
firstDetail: 'createAccessToken',
|
|
65
|
+
secondDetail: accessTokenResponse.error,
|
|
66
|
+
});
|
|
67
|
+
return [2 /*return*/, { token: '' }];
|
|
68
|
+
}
|
|
69
|
+
return [2 /*return*/, accessTokenResponse];
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
}); }), [token, user]);
|
|
73
|
+
var initAccessToken = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
74
|
+
var accessToken;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
if (!user.phoneNumber)
|
|
79
|
+
return [2 /*return*/];
|
|
80
|
+
if (!user.sumsubId)
|
|
81
|
+
return [2 /*return*/];
|
|
82
|
+
return [4 /*yield*/, getAccessToken(user.phoneNumber)];
|
|
83
|
+
case 1:
|
|
84
|
+
accessToken = _a.sent();
|
|
85
|
+
setAccessToken(accessToken.token);
|
|
86
|
+
setExternalActionId(accessToken.externalActionId);
|
|
87
|
+
return [2 /*return*/];
|
|
88
|
+
}
|
|
89
|
+
});
|
|
90
|
+
}); }, [user.phoneNumber, user.sumsubId, getAccessToken]);
|
|
91
|
+
var onSumsubLoginSuccess = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
92
|
+
var faceLoginResult, userResponse;
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
switch (_a.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
if (!user.sumsubId)
|
|
97
|
+
return [2 /*return*/];
|
|
98
|
+
return [4 /*yield*/, berifymeApi.sumsub.getSumsubFaceLoginResult({ sumsubId: user.sumsubId || '', externalActionId: externalActionId || '' })];
|
|
99
|
+
case 1:
|
|
100
|
+
faceLoginResult = _a.sent();
|
|
101
|
+
if ('error' in faceLoginResult) {
|
|
102
|
+
console.error(faceLoginResult.error);
|
|
103
|
+
createDeveloperLog({
|
|
104
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
105
|
+
userDataJson: user,
|
|
106
|
+
source: 'FRONTEND',
|
|
107
|
+
action: 'sumsub api',
|
|
108
|
+
sessionToken: token,
|
|
109
|
+
firstDetail: 'getFaceLoginResult',
|
|
110
|
+
secondDetail: faceLoginResult.error,
|
|
111
|
+
});
|
|
112
|
+
setError('Oops! Something went wrong...');
|
|
113
|
+
return [2 /*return*/];
|
|
114
|
+
}
|
|
115
|
+
if (!faceLoginResult.isVerified) {
|
|
116
|
+
console.error('faceLoginResult.isVerified is false');
|
|
117
|
+
createDeveloperLog({
|
|
118
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
119
|
+
userDataJson: user,
|
|
120
|
+
source: 'FRONTEND',
|
|
121
|
+
action: 'sumsub api',
|
|
122
|
+
sessionToken: token,
|
|
123
|
+
firstDetail: 'getFaceLoginResult',
|
|
124
|
+
secondDetail: 'isVerified is false',
|
|
125
|
+
});
|
|
126
|
+
setError('Face verification failed');
|
|
127
|
+
return [2 /*return*/];
|
|
128
|
+
}
|
|
129
|
+
return [4 /*yield*/, berifymeApi.user.getUserBySumsubId({ sumsubId: user.sumsubId })];
|
|
130
|
+
case 2:
|
|
131
|
+
userResponse = _a.sent();
|
|
132
|
+
if ('error' in userResponse) {
|
|
133
|
+
console.log('error', userResponse.error);
|
|
134
|
+
createDeveloperLog({
|
|
135
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
136
|
+
userDataJson: user,
|
|
137
|
+
source: 'FRONTEND',
|
|
138
|
+
action: 'sumsub api',
|
|
139
|
+
sessionToken: token,
|
|
140
|
+
firstDetail: 'getUserBySumsubId',
|
|
141
|
+
secondDetail: userResponse.error,
|
|
142
|
+
});
|
|
143
|
+
setError('Oops! Something went wrong...');
|
|
144
|
+
return [2 /*return*/];
|
|
145
|
+
}
|
|
146
|
+
setUser(userResponse.user);
|
|
147
|
+
goToAllSet();
|
|
148
|
+
return [2 /*return*/];
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
}); };
|
|
152
|
+
var accessTokenExpirationHandler = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
153
|
+
return __generator(this, function (_a) {
|
|
154
|
+
switch (_a.label) {
|
|
155
|
+
case 0:
|
|
156
|
+
console.log('accessTokenExpirationHandler');
|
|
157
|
+
if (!user.phoneNumber)
|
|
158
|
+
return [2 /*return*/, ''];
|
|
159
|
+
return [4 /*yield*/, getAccessToken(user.phoneNumber)];
|
|
160
|
+
case 1: return [2 /*return*/, _a.sent()];
|
|
161
|
+
}
|
|
162
|
+
});
|
|
163
|
+
}); }, [getAccessToken, user.phoneNumber]);
|
|
164
|
+
var messageHandler = function (type, payload) { return __awaiter(void 0, void 0, void 0, function () {
|
|
165
|
+
var _a;
|
|
166
|
+
return __generator(this, function (_b) {
|
|
167
|
+
switch (_b.label) {
|
|
168
|
+
case 0:
|
|
169
|
+
console.log('onMessage', type, payload);
|
|
170
|
+
createDeveloperLog({
|
|
171
|
+
userId: user === null || user === void 0 ? void 0 : user.id,
|
|
172
|
+
userDataJson: user,
|
|
173
|
+
source: 'FRONTEND',
|
|
174
|
+
action: 'sumsub step',
|
|
175
|
+
sessionToken: token,
|
|
176
|
+
firstDetail: type,
|
|
177
|
+
secondDetail: JSON.stringify(payload),
|
|
178
|
+
});
|
|
179
|
+
if (!(type === 'idCheck.onApplicantActionCompleted')) return [3 /*break*/, 5];
|
|
180
|
+
_a = payload.answer;
|
|
181
|
+
switch (_a) {
|
|
182
|
+
case 'GREEN': return [3 /*break*/, 1];
|
|
183
|
+
case 'RED': return [3 /*break*/, 3];
|
|
184
|
+
}
|
|
185
|
+
return [3 /*break*/, 4];
|
|
186
|
+
case 1: return [4 /*yield*/, delay(1000)];
|
|
187
|
+
case 2:
|
|
188
|
+
_b.sent();
|
|
189
|
+
onSumsubLoginSuccess();
|
|
190
|
+
return [3 /*break*/, 5];
|
|
191
|
+
case 3:
|
|
192
|
+
setError('Face verification failed');
|
|
193
|
+
return [3 /*break*/, 5];
|
|
194
|
+
case 4:
|
|
195
|
+
setError('Oops! Something went wrong...');
|
|
196
|
+
_b.label = 5;
|
|
197
|
+
case 5: return [2 /*return*/];
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
}); };
|
|
201
|
+
var errorHandler = function (error) {
|
|
202
|
+
console.log('onError', error);
|
|
203
|
+
};
|
|
204
|
+
useEffect(function () {
|
|
205
|
+
initAccessToken();
|
|
206
|
+
}, [initAccessToken]);
|
|
207
|
+
if (error || !token)
|
|
208
|
+
return (React.createElement(TryAgain, { message: error }));
|
|
209
|
+
return (React.createElement(React.Fragment, null, accessToken &&
|
|
210
|
+
React.createElement(SumsubWebSdk, { accessToken: accessToken, expirationHandler: accessTokenExpirationHandler, options: OPTIONS, onMessage: messageHandler, onError: errorHandler })));
|
|
211
|
+
};
|
|
212
|
+
export default SumsubLogin;
|