@bytexbyte/berifyme-react-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.
- package/README.md +20 -0
- package/dist/BerifymeModal/MainModal.js +29 -0
- package/dist/BerifymeModal/index.js +331 -0
- package/dist/api/api.js +1337 -0
- package/dist/api/client.js +21 -0
- package/dist/api/index.js +96 -0
- package/dist/common.js +216 -0
- package/dist/components/AllSet/index.js +169 -0
- package/dist/components/AuthenticationLogs.js +148 -0
- package/dist/components/Clear.js +107 -0
- package/dist/components/Footer/index.js +11 -0
- package/dist/components/Layout.js +9 -0
- package/dist/components/Login/authid/authid.js +196 -0
- package/dist/components/Login/authid/index.js +13 -0
- package/dist/components/Login/clear.js +35 -0
- package/dist/components/Login/clearAllSet.js +96 -0
- package/dist/components/Login/incode/Login.js +129 -0
- package/dist/components/Login/incode/index.js +16 -0
- package/dist/components/OnBoarding/authId/authIdSelectType.js +82 -0
- package/dist/components/OnBoarding/authId/idOrPassport.js +30 -0
- package/dist/components/OnBoarding/authId/index.js +323 -0
- package/dist/components/OnBoarding/clear/clearAllSet.js +118 -0
- package/dist/components/OnBoarding/clear/index.js +36 -0
- package/dist/components/OnBoarding/incode/BackId.js +25 -0
- package/dist/components/OnBoarding/incode/FinishOnboarding.js +26 -0
- package/dist/components/OnBoarding/incode/FrontId.js +27 -0
- package/dist/components/OnBoarding/incode/Passport.js +27 -0
- package/dist/components/OnBoarding/incode/ProcessFace.js +22 -0
- package/dist/components/OnBoarding/incode/ProcessId.js +22 -0
- package/dist/components/OnBoarding/incode/SelectType.js +68 -0
- package/dist/components/OnBoarding/incode/Selfie.js +25 -0
- package/dist/components/OnBoarding/incode/Steps.js +7 -0
- package/dist/components/OnBoarding/incode/UserConsent.js +30 -0
- package/dist/components/OnBoarding/incode/index.js +234 -0
- package/dist/components/OnBoarding/vender/grid/authIdGrid.js +94 -0
- package/dist/components/OnBoarding/vender/grid/clearGrid.js +14 -0
- package/dist/components/OnBoarding/vender/grid/incodeGrid.js +14 -0
- package/dist/components/OnBoarding/vender/grid/index.js +118 -0
- package/dist/components/OnBoarding/vender/grid/sumsubGrid.js +14 -0
- package/dist/components/OnBoarding/vender/grid/veriffGrid.js +14 -0
- package/dist/components/OnBoarding/vender/grid/yotiGrid.js +14 -0
- package/dist/components/OnBoarding/vender/index.js +123 -0
- package/dist/components/RedirectToMobile/index.js +139 -0
- package/dist/components/ScreenRotation.js +11 -0
- package/dist/components/SendSns/index.js +341 -0
- package/dist/components/SendSns/style.css +1 -0
- package/dist/components/TryAgain.js +16 -0
- package/dist/components/TryAgainInModal.js +15 -0
- package/dist/components/VerifyWithPhoneNumber/NewUser/index.js +189 -0
- package/dist/components/VerifyWithPhoneNumber/User/index.js +322 -0
- package/dist/components/createDeveloperLog.js +60 -0
- package/dist/components/phoneNumberProcesser.js +32 -0
- package/dist/components/speedTest/SpeedProvider.js +57 -0
- package/dist/components/theme.js +120 -0
- package/dist/enum/index.js +24 -0
- package/dist/index.js +7 -0
- package/dist/lib/environmentDomains.js +12 -0
- package/dist/lib/webauthb.js +158 -0
- package/dist/state.js +23 -0
- package/dist/theme.js +120 -0
- package/dist/types/BerifymeModal/MainModal.d.ts +7 -0
- package/dist/types/BerifymeModal/index.d.ts +12 -0
- package/dist/types/api/api.d.ts +606 -0
- package/dist/types/api/client.d.ts +2 -0
- package/dist/types/api/index.d.ts +16 -0
- package/dist/types/common.d.ts +3 -0
- package/dist/types/components/AllSet/index.d.ts +8 -0
- package/dist/types/components/AuthenticationLogs.d.ts +19 -0
- package/dist/types/components/Clear.d.ts +9 -0
- package/dist/types/components/Footer/index.d.ts +3 -0
- package/dist/types/components/Layout.d.ts +5 -0
- package/dist/types/components/Login/authid/authid.d.ts +11 -0
- package/dist/types/components/Login/authid/index.d.ts +9 -0
- package/dist/types/components/Login/clear.d.ts +7 -0
- package/dist/types/components/Login/clearAllSet.d.ts +6 -0
- package/dist/types/components/Login/incode/Login.d.ts +13 -0
- package/dist/types/components/Login/incode/index.d.ts +9 -0
- package/dist/types/components/OnBoarding/authId/authIdSelectType.d.ts +6 -0
- package/dist/types/components/OnBoarding/authId/idOrPassport.d.ts +7 -0
- package/dist/types/components/OnBoarding/authId/index.d.ts +11 -0
- package/dist/types/components/OnBoarding/clear/clearAllSet.d.ts +6 -0
- package/dist/types/components/OnBoarding/clear/index.d.ts +8 -0
- package/dist/types/components/OnBoarding/incode/BackId.d.ts +11 -0
- package/dist/types/components/OnBoarding/incode/FinishOnboarding.d.ts +11 -0
- package/dist/types/components/OnBoarding/incode/FrontId.d.ts +10 -0
- package/dist/types/components/OnBoarding/incode/Passport.d.ts +10 -0
- package/dist/types/components/OnBoarding/incode/ProcessFace.d.ts +11 -0
- package/dist/types/components/OnBoarding/incode/ProcessId.d.ts +11 -0
- package/dist/types/components/OnBoarding/incode/SelectType.d.ts +6 -0
- package/dist/types/components/OnBoarding/incode/Selfie.d.ts +11 -0
- package/dist/types/components/OnBoarding/incode/Steps.d.ts +7 -0
- package/dist/types/components/OnBoarding/incode/UserConsent.d.ts +8 -0
- package/dist/types/components/OnBoarding/incode/index.d.ts +9 -0
- package/dist/types/components/OnBoarding/vender/grid/authIdGrid.d.ts +8 -0
- package/dist/types/components/OnBoarding/vender/grid/clearGrid.d.ts +5 -0
- package/dist/types/components/OnBoarding/vender/grid/incodeGrid.d.ts +5 -0
- package/dist/types/components/OnBoarding/vender/grid/index.d.ts +10 -0
- package/dist/types/components/OnBoarding/vender/grid/sumsubGrid.d.ts +5 -0
- package/dist/types/components/OnBoarding/vender/grid/veriffGrid.d.ts +5 -0
- package/dist/types/components/OnBoarding/vender/grid/yotiGrid.d.ts +5 -0
- package/dist/types/components/OnBoarding/vender/index.d.ts +9 -0
- package/dist/types/components/RedirectToMobile/index.d.ts +7 -0
- package/dist/types/components/ScreenRotation.d.ts +3 -0
- package/dist/types/components/SendSns/index.d.ts +16 -0
- package/dist/types/components/TryAgain.d.ts +6 -0
- package/dist/types/components/TryAgainInModal.d.ts +6 -0
- package/dist/types/components/VerifyWithPhoneNumber/NewUser/index.d.ts +11 -0
- package/dist/types/components/VerifyWithPhoneNumber/User/index.d.ts +13 -0
- package/dist/types/components/createDeveloperLog.d.ts +11 -0
- package/dist/types/components/phoneNumberProcesser.d.ts +6 -0
- package/dist/types/components/speedTest/SpeedProvider.d.ts +9 -0
- package/dist/types/components/theme.d.ts +9 -0
- package/dist/types/enum/index.d.ts +22 -0
- package/dist/types/index.d.ts +12 -0
- package/dist/types/lib/environmentDomains.d.ts +7 -0
- package/dist/types/lib/webauthb.d.ts +18 -0
- package/dist/types/state.d.ts +11 -0
- package/dist/types/theme.d.ts +9 -0
- package/dist/types/vender/incode/incode.d.ts +8 -0
- package/dist/vender/incode/incode.js +13 -0
- package/index.css +52 -0
- package/package.json +49 -0
- package/public/US-UK_Add_to_Apple_Wallet_RGB_101421.svg +259 -0
- package/public/berify-title.webp +0 -0
- package/public/clearme.svg +39 -0
- package/public/idme.svg +13 -0
- package/public/incode.svg +9 -0
- package/public/scan.svg +8 -0
- package/public/trackablehealth-one-logo-1024x229.jpg +0 -0
|
@@ -0,0 +1,82 @@
|
|
|
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 React from "react";
|
|
38
|
+
import { Button, Stack, Typography } from "@mui/material";
|
|
39
|
+
import { useEffect, useState } from "react";
|
|
40
|
+
import berifymeApi from "../../../api/api";
|
|
41
|
+
import theme from "../../theme";
|
|
42
|
+
var AuthIdSelectType = function (_a) {
|
|
43
|
+
var setSelectedIdType = _a.setSelectedIdType, setError = _a.setError;
|
|
44
|
+
var _b = useState([]), idTypes = _b[0], setIdTypes = _b[1];
|
|
45
|
+
var initTypeButton = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
46
|
+
var result, documentTypes, filteredDocuments;
|
|
47
|
+
return __generator(this, function (_a) {
|
|
48
|
+
switch (_a.label) {
|
|
49
|
+
case 0: return [4 /*yield*/, berifymeApi.authID.getIdDocumentTypes({ token: localStorage.getItem('authID_token') || '' })];
|
|
50
|
+
case 1:
|
|
51
|
+
result = _a.sent();
|
|
52
|
+
if (result.error) {
|
|
53
|
+
setError(result.error);
|
|
54
|
+
return [2 /*return*/];
|
|
55
|
+
}
|
|
56
|
+
if (result.idTypes) {
|
|
57
|
+
console.log(result.idTypes);
|
|
58
|
+
documentTypes = result.idTypes;
|
|
59
|
+
filteredDocuments = [
|
|
60
|
+
documentTypes.find(function (doc) { return doc.Name === "40"; }),
|
|
61
|
+
documentTypes.find(function (doc) { return doc.Name === "5"; })
|
|
62
|
+
];
|
|
63
|
+
setIdTypes(filteredDocuments);
|
|
64
|
+
}
|
|
65
|
+
return [2 /*return*/];
|
|
66
|
+
}
|
|
67
|
+
});
|
|
68
|
+
}); };
|
|
69
|
+
useEffect(function () {
|
|
70
|
+
initTypeButton();
|
|
71
|
+
}, []);
|
|
72
|
+
useEffect(function () {
|
|
73
|
+
console.log(idTypes);
|
|
74
|
+
}, [idTypes]);
|
|
75
|
+
return (React.createElement(Stack, { spacing: 2, alignItems: 'center' },
|
|
76
|
+
idTypes[0] && React.createElement(Button, { fullWidth: true, sx: { p: 2, maxWidth: 200, bgcolor: theme.palette.secondary.dark }, variant: "contained", color: 'secondary', onClick: function () { return setSelectedIdType(idTypes[0].Name); } },
|
|
77
|
+
React.createElement(Typography, { variant: "h5", fontWeight: 700 }, "Upload ID")),
|
|
78
|
+
idTypes[1] && React.createElement(Typography, { variant: "h5", fontWeight: 700, color: theme.palette.text.secondary }, "OR"),
|
|
79
|
+
idTypes[1] && React.createElement(Button, { fullWidth: true, sx: { p: 2, maxWidth: 200, bgcolor: theme.palette.secondary.dark }, variant: "contained", color: 'secondary', onClick: function () { return setSelectedIdType(idTypes[1].Name); } },
|
|
80
|
+
React.createElement(Typography, { variant: "h5", fontWeight: 700 }, "Upload Passport"))));
|
|
81
|
+
};
|
|
82
|
+
export default AuthIdSelectType;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Box, CircularProgress, IconButton, Stack, Typography } from "@mui/material";
|
|
3
|
+
import theme from "../../theme";
|
|
4
|
+
import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded';
|
|
5
|
+
import AuthIdSelectType from "./authIdSelectType";
|
|
6
|
+
import Footer from "../../Footer";
|
|
7
|
+
var IdOrPassport = function (_a) {
|
|
8
|
+
var setError = _a.setError, setPageStatus = _a.setPageStatus, setSelectedIdType = _a.setSelectedIdType;
|
|
9
|
+
return (React.createElement(Stack, { height: 1, width: 1, justifyContent: 'space-between', overflow: 'auto', pb: 6 },
|
|
10
|
+
React.createElement(Stack, { style: { width: '100%' }, pb: 2 },
|
|
11
|
+
React.createElement(Stack, { height: 1, spacing: 2, pt: 3 },
|
|
12
|
+
React.createElement(Stack, { direction: 'row' },
|
|
13
|
+
React.createElement(IconButton, { color: 'primary', onClick: function () { setPageStatus(1.1); } },
|
|
14
|
+
React.createElement(ArrowBackRoundedIcon, null))),
|
|
15
|
+
React.createElement(Stack, { spacing: 4, direction: 'row', alignItems: 'center', justifyContent: 'space-between' },
|
|
16
|
+
React.createElement(Stack, { spacing: 1 },
|
|
17
|
+
React.createElement(Typography, { variant: 'h3', fontWeight: 700 }, "Upload ID and Take Selfie"),
|
|
18
|
+
React.createElement(Typography, { variant: 'h4', color: theme.palette.info.light }, "Next: Congrats, you\u2019re Berified!")),
|
|
19
|
+
React.createElement(Box, { position: "relative", display: "inline-flex" },
|
|
20
|
+
React.createElement(CircularProgress, { variant: "determinate", value: 100, size: 70, sx: {
|
|
21
|
+
color: '#4caf50',
|
|
22
|
+
left: 0,
|
|
23
|
+
} }),
|
|
24
|
+
React.createElement(Box, { position: "absolute", top: "50%", left: "50%", sx: { transform: 'translate(-50%, -50%)' } },
|
|
25
|
+
React.createElement(Typography, { variant: "h6", component: "div" }, "2 of 2")))),
|
|
26
|
+
React.createElement(Stack, { pt: 3 },
|
|
27
|
+
React.createElement(AuthIdSelectType, { setSelectedIdType: setSelectedIdType, setError: setError })))),
|
|
28
|
+
React.createElement(Footer, null)));
|
|
29
|
+
};
|
|
30
|
+
export default IdOrPassport;
|
|
@@ -0,0 +1,323 @@
|
|
|
1
|
+
var __assign = (this && this.__assign) || function () {
|
|
2
|
+
__assign = Object.assign || function(t) {
|
|
3
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
4
|
+
s = arguments[i];
|
|
5
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
6
|
+
t[p] = s[p];
|
|
7
|
+
}
|
|
8
|
+
return t;
|
|
9
|
+
};
|
|
10
|
+
return __assign.apply(this, arguments);
|
|
11
|
+
};
|
|
12
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
13
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
14
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
15
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
16
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
17
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
18
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
19
|
+
});
|
|
20
|
+
};
|
|
21
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
22
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
23
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
24
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
25
|
+
function step(op) {
|
|
26
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
27
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
28
|
+
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;
|
|
29
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
30
|
+
switch (op[0]) {
|
|
31
|
+
case 0: case 1: t = op; break;
|
|
32
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
33
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
34
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
35
|
+
default:
|
|
36
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
37
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
38
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
39
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
40
|
+
if (t[2]) _.ops.pop();
|
|
41
|
+
_.trys.pop(); continue;
|
|
42
|
+
}
|
|
43
|
+
op = body.call(thisArg, _);
|
|
44
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
45
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
import React from "react";
|
|
49
|
+
import AuthIDComponent from "@authid/react-component";
|
|
50
|
+
import { Box, CircularProgress } from "@mui/material";
|
|
51
|
+
import { useEffect, useState } from "react";
|
|
52
|
+
import berifymeApi, { ActionType } from "../../../api/api";
|
|
53
|
+
import { useSpeedTest } from "../../speedTest/SpeedProvider";
|
|
54
|
+
import { createAuthenticationLog, updateAuthenticationLog } from "../../AuthenticationLogs";
|
|
55
|
+
import { createDeveloperLog } from "../../createDeveloperLog";
|
|
56
|
+
var AuthID = function (_a) {
|
|
57
|
+
var goToAllSet = _a.goToAllSet, setError = _a.setError, userId = _a.userId, setUser = _a.setUser, selectedIdType = _a.selectedIdType, token = _a.token;
|
|
58
|
+
var _b = useState(''), operationId = _b[0], setOperationId = _b[1];
|
|
59
|
+
var _c = useState(''), url = _c[0], setUrl = _c[1];
|
|
60
|
+
var stopSpeedTest = useSpeedTest().stopSpeedTest;
|
|
61
|
+
useEffect(function () { stopSpeedTest(); }, []);
|
|
62
|
+
//第零部 準備URL
|
|
63
|
+
var proofUser = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
64
|
+
var proofResult;
|
|
65
|
+
return __generator(this, function (_a) {
|
|
66
|
+
switch (_a.label) {
|
|
67
|
+
case 0: return [4 /*yield*/, berifymeApi.authID.proofUser({ token: localStorage.getItem('authID_token') || '', userId: userId, idType: selectedIdType })];
|
|
68
|
+
case 1:
|
|
69
|
+
proofResult = _a.sent();
|
|
70
|
+
createDeveloperLog({
|
|
71
|
+
userId: userId,
|
|
72
|
+
source: 'FRONTEND',
|
|
73
|
+
action: 'authId proofResult',
|
|
74
|
+
sessionToken: token,
|
|
75
|
+
firstDetail: selectedIdType,
|
|
76
|
+
secondDetail: "OperationId: ".concat(proofResult.OperationId, ", OneTimeSecret: ").concat(proofResult.OneTimeSecret)
|
|
77
|
+
});
|
|
78
|
+
if (proofResult.OperationId && proofResult.OneTimeSecret) {
|
|
79
|
+
setOperationId(proofResult.OperationId);
|
|
80
|
+
//這裡設定好OperationId, 這次的驗證
|
|
81
|
+
if (token)
|
|
82
|
+
createAuthenticationLog({
|
|
83
|
+
actionType: ActionType.ONBOARDING,
|
|
84
|
+
userId: userId,
|
|
85
|
+
vender: 'Berify.me',
|
|
86
|
+
token: token,
|
|
87
|
+
transactionId: proofResult.OperationId,
|
|
88
|
+
});
|
|
89
|
+
setUrl(proofResult.url);
|
|
90
|
+
// setUrl(`https://id.authid.ai/?i=${proofResult.OperationId}&s=${proofResult.OneTimeSecret}`);
|
|
91
|
+
}
|
|
92
|
+
return [2 /*return*/];
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
}); };
|
|
96
|
+
//第一步 確認status
|
|
97
|
+
var getProofTransactionStatus = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
98
|
+
var result;
|
|
99
|
+
return __generator(this, function (_a) {
|
|
100
|
+
switch (_a.label) {
|
|
101
|
+
case 0: return [4 /*yield*/, berifymeApi.authID.getProofTransactionStatus({ token: localStorage.getItem('authID_token') || '', operationId: operationId, userId: userId })];
|
|
102
|
+
case 1:
|
|
103
|
+
result = _a.sent();
|
|
104
|
+
createDeveloperLog({
|
|
105
|
+
userId: userId,
|
|
106
|
+
source: 'FRONTEND',
|
|
107
|
+
action: 'authId getProofTransactionStatus',
|
|
108
|
+
sessionToken: token,
|
|
109
|
+
firstDetail: "operationId: ".concat(operationId),
|
|
110
|
+
secondDetail: "status: ".concat(result.status, ", error: ").concat(result.error)
|
|
111
|
+
});
|
|
112
|
+
if (result.error || result.status === 0) {
|
|
113
|
+
setError(result.error);
|
|
114
|
+
return [2 /*return*/];
|
|
115
|
+
}
|
|
116
|
+
if (result.status === 1) {
|
|
117
|
+
getDocumentDetails();
|
|
118
|
+
}
|
|
119
|
+
return [2 /*return*/];
|
|
120
|
+
}
|
|
121
|
+
});
|
|
122
|
+
}); };
|
|
123
|
+
//第二步 確認證件是否成功
|
|
124
|
+
var getDocumentDetails = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
125
|
+
var document;
|
|
126
|
+
return __generator(this, function (_a) {
|
|
127
|
+
switch (_a.label) {
|
|
128
|
+
case 0: return [4 /*yield*/, berifymeApi.authID.getDocumentDetails({ token: localStorage.getItem('authID_token') || '', operationId: operationId, userId: userId })];
|
|
129
|
+
case 1:
|
|
130
|
+
document = _a.sent();
|
|
131
|
+
createDeveloperLog({
|
|
132
|
+
userId: userId,
|
|
133
|
+
source: 'FRONTEND',
|
|
134
|
+
action: 'authId getDocumentDetails first time',
|
|
135
|
+
sessionToken: token,
|
|
136
|
+
firstDetail: "operationId: ".concat(operationId),
|
|
137
|
+
secondDetail: "error: ".concat(document.error)
|
|
138
|
+
});
|
|
139
|
+
if (document.error) {
|
|
140
|
+
if (document.error === 'Face not match') {
|
|
141
|
+
setError('Failed to verify your identity. Please try again.');
|
|
142
|
+
return [2 /*return*/];
|
|
143
|
+
}
|
|
144
|
+
if (document.error === 'ID Expired') {
|
|
145
|
+
setError('Your identity has expired. Please try again.');
|
|
146
|
+
return [2 /*return*/];
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
if (document.details) {
|
|
150
|
+
getProofTransactionTempId();
|
|
151
|
+
}
|
|
152
|
+
return [2 /*return*/];
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
}); };
|
|
156
|
+
//第三步 獲取臨時ID
|
|
157
|
+
var getProofTransactionTempId = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
158
|
+
var result;
|
|
159
|
+
return __generator(this, function (_a) {
|
|
160
|
+
switch (_a.label) {
|
|
161
|
+
case 0: return [4 /*yield*/, berifymeApi.authID.getProofTransactionTempId({ token: localStorage.getItem('authID_token') || '', operationId: operationId, userId: userId })];
|
|
162
|
+
case 1:
|
|
163
|
+
result = _a.sent();
|
|
164
|
+
createDeveloperLog({
|
|
165
|
+
userId: userId,
|
|
166
|
+
source: 'FRONTEND',
|
|
167
|
+
action: 'authId getProofTransactionTempId',
|
|
168
|
+
sessionToken: token,
|
|
169
|
+
firstDetail: "operationId: ".concat(operationId),
|
|
170
|
+
secondDetail: "TempId: ".concat(result.TempId, ", error: ").concat(result.error)
|
|
171
|
+
});
|
|
172
|
+
if (result.error) {
|
|
173
|
+
setError(result.error);
|
|
174
|
+
return [2 /*return*/];
|
|
175
|
+
}
|
|
176
|
+
if (!result.TempId) return [3 /*break*/, 3];
|
|
177
|
+
return [4 /*yield*/, createBiometricFromProof(result.TempId)];
|
|
178
|
+
case 2:
|
|
179
|
+
_a.sent();
|
|
180
|
+
_a.label = 3;
|
|
181
|
+
case 3: return [2 /*return*/];
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
}); };
|
|
185
|
+
//第四步 寫入資料
|
|
186
|
+
var createBiometricFromProof = function (tempId) { return __awaiter(void 0, void 0, void 0, function () {
|
|
187
|
+
var result;
|
|
188
|
+
return __generator(this, function (_a) {
|
|
189
|
+
switch (_a.label) {
|
|
190
|
+
case 0: return [4 /*yield*/, berifymeApi.authID.createBiometricFromProof({ token: localStorage.getItem('authID_token') || '', tempId: tempId, userId: userId })];
|
|
191
|
+
case 1:
|
|
192
|
+
result = _a.sent();
|
|
193
|
+
createDeveloperLog({
|
|
194
|
+
userId: userId,
|
|
195
|
+
source: 'FRONTEND',
|
|
196
|
+
action: 'authId createBiometricFromProof',
|
|
197
|
+
sessionToken: token,
|
|
198
|
+
firstDetail: "operationId: ".concat(operationId),
|
|
199
|
+
secondDetail: "error: ".concat(result.error)
|
|
200
|
+
});
|
|
201
|
+
if (result.error) {
|
|
202
|
+
setError(result.error);
|
|
203
|
+
return [2 /*return*/];
|
|
204
|
+
}
|
|
205
|
+
setUrl('');
|
|
206
|
+
setTimeout(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
207
|
+
var document, documentType;
|
|
208
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
209
|
+
return __generator(this, function (_h) {
|
|
210
|
+
switch (_h.label) {
|
|
211
|
+
case 0: return [4 /*yield*/, berifymeApi.authID.getDocumentDetails({ token: localStorage.getItem('authID_token') || '', operationId: operationId, userId: userId })];
|
|
212
|
+
case 1:
|
|
213
|
+
document = _h.sent();
|
|
214
|
+
createDeveloperLog({
|
|
215
|
+
userId: userId,
|
|
216
|
+
source: 'FRONTEND',
|
|
217
|
+
action: 'authId getDocumentDetails second time',
|
|
218
|
+
sessionToken: token,
|
|
219
|
+
firstDetail: "operationId: ".concat(operationId),
|
|
220
|
+
secondDetail: "error: ".concat(document.error)
|
|
221
|
+
});
|
|
222
|
+
if (document.error) {
|
|
223
|
+
if (document.error === 'Face not match') {
|
|
224
|
+
setError('Failed to verify your identity. Please try again.');
|
|
225
|
+
return [2 /*return*/];
|
|
226
|
+
}
|
|
227
|
+
if (document.error === 'ID Expired') {
|
|
228
|
+
setError('Your identity has expired. Please try again.');
|
|
229
|
+
return [2 /*return*/];
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
if (!document.details) return [3 /*break*/, 3];
|
|
233
|
+
documentType = (_a = document.details.find(function (item) { return item.Key === 'Page1Name'; })) === null || _a === void 0 ? void 0 : _a.Value;
|
|
234
|
+
return [4 /*yield*/, berifymeApi.authID.updateAccount(localStorage.getItem('authID_token') || '', {
|
|
235
|
+
phone: document.phone,
|
|
236
|
+
fullName: ((_b = document.details.find(function (item) { return item.Key === 'NameOfHolder'; })) === null || _b === void 0 ? void 0 : _b.Value) || '',
|
|
237
|
+
dateOfBirth: ((_c = document.details.find(function (item) { return item.Key === 'DateOfBirth'; })) === null || _c === void 0 ? void 0 : _c.Value) || '',
|
|
238
|
+
issuingCountry: ((_d = document.details.find(function (item) { return item.Key === 'issuer'; })) === null || _d === void 0 ? void 0 : _d.Value) || '',
|
|
239
|
+
gender: ((_e = document.details.find(function (item) { return item.Key === 'Sex'; })) === null || _e === void 0 ? void 0 : _e.Value) || '',
|
|
240
|
+
dateOfExpiry: ((_f = document.details.find(function (item) { return item.Key === 'DateOfExpiry'; })) === null || _f === void 0 ? void 0 : _f.Value) || '',
|
|
241
|
+
documentType: (documentType === null || documentType === void 0 ? void 0 : documentType.includes('Passport')) ? 'Passport' : 'ID'
|
|
242
|
+
})];
|
|
243
|
+
case 2:
|
|
244
|
+
_h.sent();
|
|
245
|
+
createDeveloperLog({
|
|
246
|
+
userId: userId,
|
|
247
|
+
source: 'FRONTEND',
|
|
248
|
+
action: 'authId updateAccount and go to allset page',
|
|
249
|
+
sessionToken: token,
|
|
250
|
+
firstDetail: "operationId: ".concat(operationId),
|
|
251
|
+
});
|
|
252
|
+
if (setUser) {
|
|
253
|
+
setUser(function (prev) {
|
|
254
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
255
|
+
return (__assign(__assign({}, prev), { id: userId, fullName: (_a = document.details.find(function (item) { return item.Key === 'NameOfHolder'; })) === null || _a === void 0 ? void 0 : _a.Value, phoneNumber: document.phone, isActive: (_b = prev === null || prev === void 0 ? void 0 : prev.isActive) !== null && _b !== void 0 ? _b : null, email: (_c = prev === null || prev === void 0 ? void 0 : prev.email) !== null && _c !== void 0 ? _c : null, authIDAccountNumber: (_d = prev === null || prev === void 0 ? void 0 : prev.authIDAccountNumber) !== null && _d !== void 0 ? _d : null, incodeId: (_e = prev === null || prev === void 0 ? void 0 : prev.incodeId) !== null && _e !== void 0 ? _e : null, clearId: (_f = prev === null || prev === void 0 ? void 0 : prev.clearId) !== null && _f !== void 0 ? _f : null, idmeId: (_g = prev === null || prev === void 0 ? void 0 : prev.idmeId) !== null && _g !== void 0 ? _g : null, sumsubId: (_h = prev === null || prev === void 0 ? void 0 : prev.sumsubId) !== null && _h !== void 0 ? _h : null, veriffId: (_j = prev === null || prev === void 0 ? void 0 : prev.veriffId) !== null && _j !== void 0 ? _j : null, yotiId: (_k = prev === null || prev === void 0 ? void 0 : prev.yotiId) !== null && _k !== void 0 ? _k : null, age: (_l = prev === null || prev === void 0 ? void 0 : prev.age) !== null && _l !== void 0 ? _l : null, birthDate: (_m = prev === null || prev === void 0 ? void 0 : prev.birthDate) !== null && _m !== void 0 ? _m : null }));
|
|
256
|
+
});
|
|
257
|
+
updateAuthenticationLog({ isPass: true, transactionId: operationId });
|
|
258
|
+
goToAllSet();
|
|
259
|
+
}
|
|
260
|
+
window.ReactNativeWebView.postMessage(JSON.stringify({
|
|
261
|
+
event: 'onSuccess', user: {
|
|
262
|
+
id: userId,
|
|
263
|
+
fullName: (_g = document.details.find(function (item) { return item.Key === 'NameOfHolder'; })) === null || _g === void 0 ? void 0 : _g.Value,
|
|
264
|
+
phoneNumber: document.phone,
|
|
265
|
+
isActive: null,
|
|
266
|
+
email: null,
|
|
267
|
+
authIDAccountNumber: null,
|
|
268
|
+
incodeId: null,
|
|
269
|
+
clearId: null,
|
|
270
|
+
idmeId: null,
|
|
271
|
+
age: null,
|
|
272
|
+
birthDate: null,
|
|
273
|
+
transactionId: operationId,
|
|
274
|
+
},
|
|
275
|
+
}));
|
|
276
|
+
_h.label = 3;
|
|
277
|
+
case 3: return [2 /*return*/];
|
|
278
|
+
}
|
|
279
|
+
});
|
|
280
|
+
}); }, 1000);
|
|
281
|
+
return [2 /*return*/];
|
|
282
|
+
}
|
|
283
|
+
});
|
|
284
|
+
}); };
|
|
285
|
+
//初始與監聽
|
|
286
|
+
useEffect(function () { if (selectedIdType !== '')
|
|
287
|
+
proofUser(); }, [selectedIdType]);
|
|
288
|
+
useEffect(function () {
|
|
289
|
+
if (url) {
|
|
290
|
+
window.addEventListener('message', function (e) {
|
|
291
|
+
if (e.data.type === 'authid:page') {
|
|
292
|
+
console.log(e.data);
|
|
293
|
+
if (e.data.pageName === 'verifiedPage') {
|
|
294
|
+
setTimeout(function () {
|
|
295
|
+
getProofTransactionStatus();
|
|
296
|
+
}, 1000);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
});
|
|
300
|
+
}
|
|
301
|
+
else {
|
|
302
|
+
window.removeEventListener('message', function (e) {
|
|
303
|
+
console.log('remove message', e.data);
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
return function () {
|
|
307
|
+
window.removeEventListener('message', function (e) {
|
|
308
|
+
console.log('remove message', e.data);
|
|
309
|
+
});
|
|
310
|
+
};
|
|
311
|
+
}, [url]);
|
|
312
|
+
return (React.createElement(React.Fragment, null, React.createElement(React.Fragment, null, url
|
|
313
|
+
? React.createElement(AuthIDComponent, { url: url, webauth: true })
|
|
314
|
+
: React.createElement(Box, { sx: {
|
|
315
|
+
display: 'flex',
|
|
316
|
+
justifyContent: 'center',
|
|
317
|
+
alignItems: 'center',
|
|
318
|
+
height: '100vh',
|
|
319
|
+
background: '#FFFFFF'
|
|
320
|
+
} },
|
|
321
|
+
React.createElement(CircularProgress, null)))));
|
|
322
|
+
};
|
|
323
|
+
export default AuthID;
|
|
@@ -0,0 +1,118 @@
|
|
|
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 React from "react";
|
|
38
|
+
import { useEffect, useState } from "react";
|
|
39
|
+
import berifymeApi from "../../../api/api";
|
|
40
|
+
import { Box, CircularProgress } from "@mui/material";
|
|
41
|
+
import AllSet from "../../AllSet";
|
|
42
|
+
import TryAgain from "../../TryAgain";
|
|
43
|
+
import { updateAuthenticationLog } from "../../AuthenticationLogs";
|
|
44
|
+
import { createDeveloperLog } from "../../createDeveloperLog";
|
|
45
|
+
var ClearOnboardingAllSet = function (_a) {
|
|
46
|
+
var token = _a.token, desktopRedirectUrlId = _a.desktopRedirectUrlId;
|
|
47
|
+
var _b = useState(), user = _b[0], setUser = _b[1]; // berifyme user
|
|
48
|
+
var _c = useState(), error = _c[0], setError = _c[1];
|
|
49
|
+
var approve = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
50
|
+
var approveRes, res;
|
|
51
|
+
var id = _b.id, sessionId = _b.sessionId;
|
|
52
|
+
return __generator(this, function (_c) {
|
|
53
|
+
switch (_c.label) {
|
|
54
|
+
case 0: return [4 /*yield*/, berifymeApi.clear.getClearApprove({ id: id, sessionId: sessionId })];
|
|
55
|
+
case 1:
|
|
56
|
+
approveRes = _c.sent();
|
|
57
|
+
createDeveloperLog({
|
|
58
|
+
source: 'FRONTEND',
|
|
59
|
+
action: 'clear approveRes',
|
|
60
|
+
sessionToken: token,
|
|
61
|
+
firstDetail: sessionId,
|
|
62
|
+
secondDetail: "clearID: ".concat(approveRes.clearId, ", error: ").concat(approveRes.error),
|
|
63
|
+
});
|
|
64
|
+
if (!approveRes)
|
|
65
|
+
setError('Please try again.');
|
|
66
|
+
if (!approveRes.clearId) {
|
|
67
|
+
setError(approveRes.error);
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
}
|
|
70
|
+
return [4 /*yield*/, berifymeApi.user.getUserByClearId(approveRes.clearId)];
|
|
71
|
+
case 2:
|
|
72
|
+
res = _c.sent();
|
|
73
|
+
createDeveloperLog({
|
|
74
|
+
source: 'FRONTEND',
|
|
75
|
+
action: 'clear getUserByClearId',
|
|
76
|
+
sessionToken: token,
|
|
77
|
+
firstDetail: approveRes.clearId,
|
|
78
|
+
secondDetail: "user: ".concat(res.user, ", error: ").concat(res.error),
|
|
79
|
+
});
|
|
80
|
+
setUser(res.user);
|
|
81
|
+
updateAuthenticationLog({
|
|
82
|
+
isPass: true,
|
|
83
|
+
clearSessionId: sessionId,
|
|
84
|
+
});
|
|
85
|
+
return [2 /*return*/];
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}); };
|
|
89
|
+
function getUrlParams() {
|
|
90
|
+
var searchParams = new URLSearchParams(window.location.search);
|
|
91
|
+
return {
|
|
92
|
+
clearOnboardingCallbackUserId: searchParams.get('userId'),
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
useEffect(function () {
|
|
96
|
+
var res = getUrlParams();
|
|
97
|
+
if (!res.clearOnboardingCallbackUserId) {
|
|
98
|
+
setError('Missing callback user Id');
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
var sessionId = localStorage.getItem('clear_session_id');
|
|
102
|
+
if (!sessionId)
|
|
103
|
+
return;
|
|
104
|
+
approve({ id: res.clearOnboardingCallbackUserId, sessionId: sessionId });
|
|
105
|
+
}, []);
|
|
106
|
+
if (error)
|
|
107
|
+
return (React.createElement(TryAgain, { message: error }));
|
|
108
|
+
return (React.createElement(React.Fragment, null, user ? React.createElement(AllSet, { user: user, token: token, desktopRedirectUrlId: desktopRedirectUrlId }) :
|
|
109
|
+
React.createElement(Box, { sx: {
|
|
110
|
+
display: 'flex',
|
|
111
|
+
justifyContent: 'center',
|
|
112
|
+
alignItems: 'center',
|
|
113
|
+
height: '100vh',
|
|
114
|
+
background: '#FFFFFF'
|
|
115
|
+
} },
|
|
116
|
+
React.createElement(CircularProgress, null))));
|
|
117
|
+
};
|
|
118
|
+
export { ClearOnboardingAllSet };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import CircularProgress from '@mui/material/CircularProgress';
|
|
2
|
+
import { Box } from "@mui/material";
|
|
3
|
+
import Clear from '../../Clear';
|
|
4
|
+
import { ActionType } from "../../../api/api";
|
|
5
|
+
import React, { useEffect, useState } from 'react';
|
|
6
|
+
//[web] const domain = import.meta.env.VITE_DOMAIN as string;
|
|
7
|
+
var ClearOnboarding = function (_a) {
|
|
8
|
+
var token = _a.token, user = _a.user, desktopRedirectUrlId = _a.desktopRedirectUrlId;
|
|
9
|
+
var _b = useState(null), redirectUrl = _b[0], setRedirectUrl = _b[1];
|
|
10
|
+
useEffect(function () {
|
|
11
|
+
var _a;
|
|
12
|
+
// 使用 URL 物件來處理 URL 和查詢參數
|
|
13
|
+
var domain = window.location.href;
|
|
14
|
+
var url = new URL(domain);
|
|
15
|
+
if (token) {
|
|
16
|
+
url.searchParams.append('callback', 'clear_onboarding');
|
|
17
|
+
url.searchParams.append('token', token);
|
|
18
|
+
url.searchParams.append('userId', (_a = user === null || user === void 0 ? void 0 : user.id) !== null && _a !== void 0 ? _a : '');
|
|
19
|
+
if (desktopRedirectUrlId)
|
|
20
|
+
url.searchParams.append('desktopRedirectUrlId', desktopRedirectUrlId);
|
|
21
|
+
}
|
|
22
|
+
setRedirectUrl(url.toString());
|
|
23
|
+
}, [token, user]); // 依賴 token 和 user 變化時重新運行 useEffect
|
|
24
|
+
return (React.createElement(React.Fragment, null,
|
|
25
|
+
token && redirectUrl && user.id &&
|
|
26
|
+
React.createElement(Clear, { actionType: ActionType.ONBOARDING, userId: user.id, token: token, redirectUrl: redirectUrl }),
|
|
27
|
+
React.createElement(Box, { sx: {
|
|
28
|
+
display: 'flex',
|
|
29
|
+
justifyContent: 'center',
|
|
30
|
+
alignItems: 'center',
|
|
31
|
+
height: '100vh',
|
|
32
|
+
background: '#FFFFFF'
|
|
33
|
+
} },
|
|
34
|
+
React.createElement(CircularProgress, null))));
|
|
35
|
+
};
|
|
36
|
+
export { ClearOnboarding };
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
import { incode } from "../../../vender/incode/incode";
|
|
3
|
+
import React from "react";
|
|
4
|
+
var BackId = function (_a) {
|
|
5
|
+
var session = _a.session, onSuccess = _a.onSuccess, onError = _a.onError;
|
|
6
|
+
var containerRef = useRef(null);
|
|
7
|
+
var isMounted = useRef(false);
|
|
8
|
+
useEffect(function () {
|
|
9
|
+
if (isMounted.current) {
|
|
10
|
+
return;
|
|
11
|
+
}
|
|
12
|
+
incode.renderCamera("back", containerRef.current, {
|
|
13
|
+
onSuccess: onSuccess,
|
|
14
|
+
onError: function () { return onError({ type: "Couldn't Capture Back Id" }); },
|
|
15
|
+
token: session,
|
|
16
|
+
numberOfTries: 3,
|
|
17
|
+
showTutorial: false,
|
|
18
|
+
showCustomCameraPermissionScreen: true,
|
|
19
|
+
showDoublePermissionsRequest: true,
|
|
20
|
+
});
|
|
21
|
+
isMounted.current = true;
|
|
22
|
+
}, [session, onSuccess, onError]);
|
|
23
|
+
return React.createElement("div", { ref: containerRef });
|
|
24
|
+
};
|
|
25
|
+
export { BackId };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { incode } from "../../../vender/incode/incode";
|
|
3
|
+
import React from "react";
|
|
4
|
+
import { Box, CircularProgress } from "@mui/material";
|
|
5
|
+
import { useSpeedTest } from "../../speedTest/SpeedProvider";
|
|
6
|
+
function FinishOnboarding(_a) {
|
|
7
|
+
var session = _a.session, onSuccess = _a.onSuccess, onError = _a.onError;
|
|
8
|
+
var startSpeedTest = useSpeedTest().startSpeedTest;
|
|
9
|
+
useEffect(function () {
|
|
10
|
+
void incode.getFinishStatus(null, { token: session.token }).then(function () {
|
|
11
|
+
startSpeedTest();
|
|
12
|
+
onSuccess();
|
|
13
|
+
}).catch(function (error) {
|
|
14
|
+
startSpeedTest();
|
|
15
|
+
onError({ type: error });
|
|
16
|
+
});
|
|
17
|
+
}, [session, onSuccess, onError]);
|
|
18
|
+
return React.createElement(Box, { sx: {
|
|
19
|
+
display: 'flex',
|
|
20
|
+
justifyContent: 'center',
|
|
21
|
+
alignItems: 'center',
|
|
22
|
+
height: '100vh'
|
|
23
|
+
} },
|
|
24
|
+
React.createElement(CircularProgress, null));
|
|
25
|
+
}
|
|
26
|
+
export { FinishOnboarding };
|