@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,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 { Button, Grid, Stack, Typography } from "@mui/material";
|
|
38
|
+
import { parsePhoneNumber } from 'libphonenumber-js';
|
|
39
|
+
import React, { useEffect, useState } from "react";
|
|
40
|
+
import berifymeApi from "../../../../api/api";
|
|
41
|
+
import AuthIdGrid from "./authIdGrid";
|
|
42
|
+
import ClearGrid from "./clearGrid";
|
|
43
|
+
import IncodeGrid from "./incodeGrid";
|
|
44
|
+
// import SumsubGrid from "./sumsubGrid";
|
|
45
|
+
// import VeriffGrid from "./veriffGrid";
|
|
46
|
+
// import YotiGrid from "./yotiGrid";
|
|
47
|
+
var getCountryCodeFromPhoneNumber = function (phoneNumber) {
|
|
48
|
+
try {
|
|
49
|
+
var phoneNumberObj = parsePhoneNumber(phoneNumber);
|
|
50
|
+
return phoneNumberObj.country || null;
|
|
51
|
+
}
|
|
52
|
+
catch (error) {
|
|
53
|
+
console.error('Invalid phone number:', error);
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
var VenderGrid = function (_a) {
|
|
58
|
+
var setPageStatus = _a.setPageStatus, setError = _a.setError, user = _a.user, showMore = _a.showMore, setShowMore = _a.setShowMore;
|
|
59
|
+
var _b = useState([]), venderOrder = _b[0], setVenderOrder = _b[1];
|
|
60
|
+
var initializeUserCountryAndOrder = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
61
|
+
var countryCode, orderRes;
|
|
62
|
+
var _a;
|
|
63
|
+
return __generator(this, function (_b) {
|
|
64
|
+
switch (_b.label) {
|
|
65
|
+
case 0:
|
|
66
|
+
if (!(user === null || user === void 0 ? void 0 : user.phoneNumber)) {
|
|
67
|
+
setError('Oops! Something went wrong...');
|
|
68
|
+
return [2 /*return*/];
|
|
69
|
+
}
|
|
70
|
+
countryCode = (_a = getCountryCodeFromPhoneNumber("+".concat(user.phoneNumber))) !== null && _a !== void 0 ? _a : 'US';
|
|
71
|
+
return [4 /*yield*/, berifymeApi.getOrderByCountry({ countryCode: countryCode })];
|
|
72
|
+
case 1:
|
|
73
|
+
orderRes = _b.sent();
|
|
74
|
+
if (orderRes.error) {
|
|
75
|
+
setError(orderRes.error);
|
|
76
|
+
}
|
|
77
|
+
else if (orderRes.order) {
|
|
78
|
+
setVenderOrder(orderRes.order); // 設置顯示順序
|
|
79
|
+
}
|
|
80
|
+
return [2 /*return*/];
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
}); };
|
|
84
|
+
useEffect(function () { initializeUserCountryAndOrder(); }, []);
|
|
85
|
+
// 渲染提供商組件,根據 venderOrder 動態排序
|
|
86
|
+
var renderProviderGrid = function (provider) {
|
|
87
|
+
switch (provider) {
|
|
88
|
+
case 'authid':
|
|
89
|
+
return React.createElement(AuthIdGrid, { setPageStatus: setPageStatus, setError: setError, user: user });
|
|
90
|
+
case 'clear':
|
|
91
|
+
return React.createElement(ClearGrid, { setPageStatus: setPageStatus });
|
|
92
|
+
case 'incode':
|
|
93
|
+
return React.createElement(IncodeGrid, { setPageStatus: setPageStatus });
|
|
94
|
+
// case 'sumsub':
|
|
95
|
+
// return <SumsubGrid setPageStatus={setPageStatus} />;
|
|
96
|
+
// case 'veriff':
|
|
97
|
+
// return <VeriffGrid setPageStatus={setPageStatus} />;
|
|
98
|
+
// case 'yoti':
|
|
99
|
+
// return <YotiGrid setPageStatus={setPageStatus} />;
|
|
100
|
+
default:
|
|
101
|
+
return null;
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
// 根據 showMore 顯示部分或全部項目
|
|
105
|
+
var visibleVenderOrder = showMore ? venderOrder : venderOrder.slice(0, 6);
|
|
106
|
+
return (React.createElement(React.Fragment, null,
|
|
107
|
+
React.createElement(Grid, { container: true }, visibleVenderOrder.map(function (provider) { return renderProviderGrid(provider); })),
|
|
108
|
+
visibleVenderOrder.length > 6 && React.createElement(Stack, { alignItems: "center", justifyContent: "center", mt: 2 },
|
|
109
|
+
React.createElement(Button, { variant: 'outlined', sx: {
|
|
110
|
+
borderRadius: 6,
|
|
111
|
+
textTransform: 'none', // 如果不想強制大寫文字
|
|
112
|
+
px: 2, // 調整內邊距以確保按鈕有適當的空間
|
|
113
|
+
}, onClick: function () {
|
|
114
|
+
setShowMore(function (prev) { return !prev; });
|
|
115
|
+
} },
|
|
116
|
+
React.createElement(Typography, { variant: "body1" }, showMore ? 'Show Less' : 'Show More')))));
|
|
117
|
+
};
|
|
118
|
+
export default VenderGrid;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button, Grid, Stack, Typography } from "@mui/material";
|
|
3
|
+
import theme from "../../../theme";
|
|
4
|
+
var SumsubGrid = function (_a) {
|
|
5
|
+
var setPageStatus = _a.setPageStatus;
|
|
6
|
+
return (React.createElement(React.Fragment, null,
|
|
7
|
+
React.createElement(Grid, { item: true, xs: 6 },
|
|
8
|
+
React.createElement(Button, { fullWidth: true, onClick: function () { setPageStatus(2.3); } },
|
|
9
|
+
React.createElement(Stack, { width: 1, spacing: 1, px: 2, py: 2, bgcolor: theme.palette.grey[100], borderRadius: 6, alignItems: 'center' },
|
|
10
|
+
React.createElement("img", { width: 28, height: 28, src: "/sumsub.svg", alt: "scan" }),
|
|
11
|
+
React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "Sumsub"),
|
|
12
|
+
React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 30s completion"))))));
|
|
13
|
+
};
|
|
14
|
+
export default SumsubGrid;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button, Grid, Stack, Typography } from "@mui/material";
|
|
3
|
+
import theme from "../../../theme";
|
|
4
|
+
var VeriffGrid = function (_a) {
|
|
5
|
+
var setPageStatus = _a.setPageStatus;
|
|
6
|
+
return (React.createElement(React.Fragment, null,
|
|
7
|
+
React.createElement(Grid, { item: true, xs: 6 },
|
|
8
|
+
React.createElement(Button, { fullWidth: true, onClick: function () { setPageStatus(2.4); } },
|
|
9
|
+
React.createElement(Stack, { width: 1, spacing: 1, px: 2, py: 2, bgcolor: theme.palette.grey[100], borderRadius: 6, alignItems: 'center' },
|
|
10
|
+
React.createElement("img", { width: 28, height: 28, src: "/veriff.svg", alt: "scan" }),
|
|
11
|
+
React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "Veriff"),
|
|
12
|
+
React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 30s completion"))))));
|
|
13
|
+
};
|
|
14
|
+
export default VeriffGrid;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { Button, Grid, Stack, Typography } from "@mui/material";
|
|
3
|
+
import theme from "../../../theme";
|
|
4
|
+
var YotiGrid = function (_a) {
|
|
5
|
+
var setPageStatus = _a.setPageStatus;
|
|
6
|
+
return (React.createElement(React.Fragment, null,
|
|
7
|
+
React.createElement(Grid, { item: true, xs: 6 },
|
|
8
|
+
React.createElement(Button, { fullWidth: true, onClick: function () { setPageStatus(2.5); } },
|
|
9
|
+
React.createElement(Stack, { width: 1, spacing: 1, px: 2, py: 2, bgcolor: theme.palette.grey[100], borderRadius: 6, alignItems: 'center' },
|
|
10
|
+
React.createElement("img", { width: 28, height: 28, src: "/yoti.svg", alt: "scan" }),
|
|
11
|
+
React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "Yoti"),
|
|
12
|
+
React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 30s completion"))))));
|
|
13
|
+
};
|
|
14
|
+
export default YotiGrid;
|
|
@@ -0,0 +1,123 @@
|
|
|
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 { Box, CircularProgress, Stack, Typography } from "@mui/material";
|
|
38
|
+
import berifymeApi from "../../../api/api";
|
|
39
|
+
import theme from "../../theme";
|
|
40
|
+
import Footer from "../../Footer";
|
|
41
|
+
import React, { useEffect, useState } from "react";
|
|
42
|
+
import { parsePhoneNumber } from 'libphonenumber-js';
|
|
43
|
+
import { getCountryNameByCode } from "../../../common";
|
|
44
|
+
import LocationOnIcon from '@mui/icons-material/LocationOn';
|
|
45
|
+
import VenderGrid from "./grid";
|
|
46
|
+
var getCountryCodeFromPhoneNumber = function (phoneNumber) {
|
|
47
|
+
try {
|
|
48
|
+
console.log('test phoneNumber', phoneNumber);
|
|
49
|
+
var phoneNumberObj = parsePhoneNumber(phoneNumber);
|
|
50
|
+
console.log('test phoneNumberObj country', phoneNumberObj.country);
|
|
51
|
+
return phoneNumberObj.country || null;
|
|
52
|
+
}
|
|
53
|
+
catch (error) {
|
|
54
|
+
console.error('Invalid phone number:', error);
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
var Vender = function (_a) {
|
|
59
|
+
var setPageStatus = _a.setPageStatus, setError = _a.setError, user = _a.user, setModalHeight = _a.setModalHeight;
|
|
60
|
+
var _b = useState(), venderOrder = _b[0], setVenderOrder = _b[1];
|
|
61
|
+
var _c = useState(''), userCountryName = _c[0], setUserCountryName = _c[1];
|
|
62
|
+
var _d = useState(false), showMore = _d[0], setShowMore = _d[1];
|
|
63
|
+
useEffect(function () {
|
|
64
|
+
if (showMore) {
|
|
65
|
+
setModalHeight('100vh');
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
setModalHeight('80vh');
|
|
69
|
+
}
|
|
70
|
+
}, [showMore]);
|
|
71
|
+
var initializeUserCountryAndOrder = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
72
|
+
var countryCode, countryName, orderRes;
|
|
73
|
+
var _a;
|
|
74
|
+
return __generator(this, function (_b) {
|
|
75
|
+
switch (_b.label) {
|
|
76
|
+
case 0:
|
|
77
|
+
if (!(user === null || user === void 0 ? void 0 : user.phoneNumber)) {
|
|
78
|
+
setError('Oops! Something went wrong...');
|
|
79
|
+
return [2 /*return*/];
|
|
80
|
+
}
|
|
81
|
+
countryCode = (_a = getCountryCodeFromPhoneNumber("+".concat(user.phoneNumber))) !== null && _a !== void 0 ? _a : 'US';
|
|
82
|
+
countryName = getCountryNameByCode(countryCode);
|
|
83
|
+
setUserCountryName(countryName);
|
|
84
|
+
return [4 /*yield*/, berifymeApi.getOrderByCountry({ countryCode: countryCode })];
|
|
85
|
+
case 1:
|
|
86
|
+
orderRes = _b.sent();
|
|
87
|
+
if (orderRes.error) {
|
|
88
|
+
setError(orderRes.error);
|
|
89
|
+
}
|
|
90
|
+
else if (orderRes.order) {
|
|
91
|
+
setVenderOrder(orderRes.order); // 設置顯示順序
|
|
92
|
+
}
|
|
93
|
+
return [2 /*return*/];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}); };
|
|
97
|
+
useEffect(function () { initializeUserCountryAndOrder(); }, []);
|
|
98
|
+
useEffect(function () { console.log('vender order: ', venderOrder); }, [venderOrder]);
|
|
99
|
+
return (React.createElement(Stack, { height: 1, width: 1, justifyContent: 'space-between', overflow: 'auto' },
|
|
100
|
+
React.createElement(Stack, { style: { width: '100%' } },
|
|
101
|
+
React.createElement(Stack, { height: 1, spacing: 4, pt: showMore ? 8 : 2 },
|
|
102
|
+
React.createElement(Stack, { spacing: 4, direction: 'row', alignItems: 'center', justifyContent: 'space-between' },
|
|
103
|
+
React.createElement(Stack, { spacing: 1 },
|
|
104
|
+
React.createElement(Typography, { variant: 'h5', fontWeight: 700 }, "Choose provider"),
|
|
105
|
+
React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light }, "Next: Upload ID and Take Selfie")),
|
|
106
|
+
React.createElement(Box, { position: "relative", display: "inline-flex" },
|
|
107
|
+
React.createElement(CircularProgress, { variant: "determinate", value: 100, sx: { color: '#e0e0e0' }, size: 70 }),
|
|
108
|
+
React.createElement(CircularProgress, { variant: "determinate", value: 50, size: 70, sx: {
|
|
109
|
+
color: '#4caf50',
|
|
110
|
+
position: 'absolute',
|
|
111
|
+
left: 0,
|
|
112
|
+
} }),
|
|
113
|
+
React.createElement(Box, { position: "absolute", top: "50%", left: "50%", sx: { transform: 'translate(-50%, -50%)' } },
|
|
114
|
+
React.createElement(Typography, { variant: "h6", component: "div" }, "1 of 2")))),
|
|
115
|
+
React.createElement(Box, null,
|
|
116
|
+
React.createElement(Stack, { direction: 'row', pb: 2, spacing: 1 },
|
|
117
|
+
React.createElement(Typography, { variant: 'h5', fontWeight: 700 }, "Recommended for"),
|
|
118
|
+
React.createElement(LocationOnIcon, { fontSize: 'small' }),
|
|
119
|
+
React.createElement(Typography, { variant: 'h5', fontWeight: 300 }, userCountryName)),
|
|
120
|
+
React.createElement(VenderGrid, { setPageStatus: setPageStatus, setError: setError, user: user, showMore: showMore, setShowMore: setShowMore })))),
|
|
121
|
+
React.createElement(Footer, null)));
|
|
122
|
+
};
|
|
123
|
+
export default Vender;
|
|
@@ -0,0 +1,139 @@
|
|
|
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 { environmentDomains, environmentWebviewDomains } from "../../lib/environmentDomains";
|
|
38
|
+
import { Box, CircularProgress, Stack, Typography } from "@mui/material";
|
|
39
|
+
import theme from "../theme";
|
|
40
|
+
import QRCode from "react-qr-code";
|
|
41
|
+
import React, { useEffect, useState } from "react";
|
|
42
|
+
import axios from "axios";
|
|
43
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
44
|
+
import Footer from "../Footer";
|
|
45
|
+
import berifymeApi from "../../api/api";
|
|
46
|
+
var RedirectToMobile = function (_a) {
|
|
47
|
+
var token = _a.token, environment = _a.environment;
|
|
48
|
+
var _b = useState(), qrcodeUrl = _b[0], setQrcodeUrl = _b[1];
|
|
49
|
+
var _c = useState(), companyName = _c[0], setCompanyName = _c[1];
|
|
50
|
+
function getCompanyName(token) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
52
|
+
var res;
|
|
53
|
+
return __generator(this, function (_a) {
|
|
54
|
+
switch (_a.label) {
|
|
55
|
+
case 0: return [4 /*yield*/, berifymeApi.thirdParty.checkThirdPartyVerificationToken(token)];
|
|
56
|
+
case 1:
|
|
57
|
+
res = _a.sent();
|
|
58
|
+
if (res.companyName) {
|
|
59
|
+
setCompanyName(res.companyName);
|
|
60
|
+
}
|
|
61
|
+
return [2 /*return*/];
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
useEffect(function () {
|
|
67
|
+
var domain = environmentWebviewDomains[environment];
|
|
68
|
+
var backendDomain = environmentDomains[environment];
|
|
69
|
+
if (!token)
|
|
70
|
+
return;
|
|
71
|
+
getCompanyName(token);
|
|
72
|
+
var desktopRedirectUrlId = uuidv4(); // 生成唯一的desktopRedirectUrlId
|
|
73
|
+
setQrcodeUrl("".concat(domain, "/?token=").concat(token, "&desktopredirecturlid=").concat(desktopRedirectUrlId));
|
|
74
|
+
var fetchStatus = function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
+
var response, data, error_1;
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (_a.label) {
|
|
78
|
+
case 0:
|
|
79
|
+
_a.trys.push([0, 2, , 3]);
|
|
80
|
+
return [4 /*yield*/, axios.get("".concat(backendDomain, "/api/redirectUrl/").concat(desktopRedirectUrlId))];
|
|
81
|
+
case 1:
|
|
82
|
+
response = _a.sent();
|
|
83
|
+
data = response.data;
|
|
84
|
+
if (data.redirectUrl) {
|
|
85
|
+
// 如果後端返回了 redirectURL,立即進行跳轉
|
|
86
|
+
window.location.href = data.redirectUrl;
|
|
87
|
+
}
|
|
88
|
+
return [3 /*break*/, 3];
|
|
89
|
+
case 2:
|
|
90
|
+
error_1 = _a.sent();
|
|
91
|
+
console.error("Polling Error:", error_1);
|
|
92
|
+
return [3 /*break*/, 3];
|
|
93
|
+
case 3: return [2 /*return*/];
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
}); };
|
|
97
|
+
// 設定最大輪詢次數為 60000 次
|
|
98
|
+
var maxPollingCount = 60000;
|
|
99
|
+
var pollingCount = 0;
|
|
100
|
+
// 初次加载时获取状态
|
|
101
|
+
fetchStatus();
|
|
102
|
+
// 每隔3秒進行一次輪詢
|
|
103
|
+
var intervalId = setInterval(function () {
|
|
104
|
+
pollingCount++;
|
|
105
|
+
if (pollingCount >= maxPollingCount) {
|
|
106
|
+
clearInterval(intervalId);
|
|
107
|
+
console.log("Stopped polling after 600 attempts.");
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
fetchStatus();
|
|
111
|
+
}, 3000);
|
|
112
|
+
// 清除輪詢
|
|
113
|
+
return function () { return clearInterval(intervalId); };
|
|
114
|
+
}, [token]);
|
|
115
|
+
return (React.createElement(React.Fragment, null,
|
|
116
|
+
React.createElement(Stack, { maxWidth: 640, mx: 'auto', height: 1, spacing: 4, justifyContent: 'space-between', py: 8 },
|
|
117
|
+
React.createElement(Stack, { direction: 'row' },
|
|
118
|
+
React.createElement(Stack, { spacing: 2 },
|
|
119
|
+
React.createElement(Typography, { variant: "h2", fontWeight: 700 },
|
|
120
|
+
"Scan and Get Berified in ",
|
|
121
|
+
React.createElement("br", null),
|
|
122
|
+
"3-Easy Steps"),
|
|
123
|
+
React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "Scan your unique dynamically-generated QR code to start your verification journey."),
|
|
124
|
+
React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary },
|
|
125
|
+
"Keep this page open. You will be redirected automatically to ",
|
|
126
|
+
companyName,
|
|
127
|
+
" upon successful verification.")),
|
|
128
|
+
React.createElement(Stack, { width: 1, height: 200, alignItems: 'end' }, qrcodeUrl ? React.createElement(QRCode, { value: qrcodeUrl, size: 200 }) :
|
|
129
|
+
React.createElement(Box, { sx: {
|
|
130
|
+
display: 'flex',
|
|
131
|
+
justifyContent: 'center',
|
|
132
|
+
alignItems: 'center',
|
|
133
|
+
height: '100vh',
|
|
134
|
+
background: '#FFFFFF'
|
|
135
|
+
} },
|
|
136
|
+
React.createElement(CircularProgress, null)))),
|
|
137
|
+
React.createElement(Footer, null))));
|
|
138
|
+
};
|
|
139
|
+
export default RedirectToMobile;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Stack, Typography } from "@mui/material";
|
|
2
|
+
import ScreenRotationRoundedIcon from '@mui/icons-material/ScreenRotationRounded';
|
|
3
|
+
import theme from "./theme";
|
|
4
|
+
import React from "react";
|
|
5
|
+
var ScreenRotation = function () {
|
|
6
|
+
return (React.createElement(React.Fragment, null,
|
|
7
|
+
React.createElement(Stack, { width: 1, height: 1, spacing: 2, justifyContent: 'center', alignItems: 'center', pt: 2, color: theme.palette.info.dark },
|
|
8
|
+
React.createElement(ScreenRotationRoundedIcon, { fontSize: "large" }),
|
|
9
|
+
React.createElement(Typography, { variant: "h3" }, "Please turn your device into portrait mode"))));
|
|
10
|
+
};
|
|
11
|
+
export default ScreenRotation;
|