@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,57 @@
|
|
|
1
|
+
import React, { createContext, useContext,
|
|
2
|
+
// useEffect, useState,
|
|
3
|
+
} from 'react';
|
|
4
|
+
// import { useNavigate } from 'react-router-dom';
|
|
5
|
+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
|
6
|
+
// import { ReactInternetSpeedMeter } from 'react-internet-meter';
|
|
7
|
+
var SpeedContext = createContext({
|
|
8
|
+
speed: null,
|
|
9
|
+
stopSpeedTest: function () { },
|
|
10
|
+
startSpeedTest: function () { },
|
|
11
|
+
});
|
|
12
|
+
export var SpeedProvider = function (_a) {
|
|
13
|
+
var children = _a.children;
|
|
14
|
+
// const navigate = useNavigate();
|
|
15
|
+
// const [lowSpeedCount, setLowSpeedCount] = useState(0);
|
|
16
|
+
// const [speed, setSpeed] = useState<string | null>(null);
|
|
17
|
+
var speed = null;
|
|
18
|
+
// const [isSpeedTestEnabled, setIsSpeedTestEnabled] = useState(true);
|
|
19
|
+
var stopSpeedTest = function () {
|
|
20
|
+
// setLowSpeedCount(0);
|
|
21
|
+
// setIsSpeedTestEnabled(false);
|
|
22
|
+
};
|
|
23
|
+
var startSpeedTest = function () {
|
|
24
|
+
// setLowSpeedCount(0);
|
|
25
|
+
// setIsSpeedTestEnabled(true);
|
|
26
|
+
};
|
|
27
|
+
// const handleNetworkTest = (speed: string) => {
|
|
28
|
+
// console.log('speed', speed);
|
|
29
|
+
// setSpeed(speed); // 更新 speed 狀態
|
|
30
|
+
// const threshold = 12;
|
|
31
|
+
// if (Number(speed) < threshold) {
|
|
32
|
+
// setLowSpeedCount(prevCount => prevCount + 1);
|
|
33
|
+
// } else {
|
|
34
|
+
// setLowSpeedCount(0);
|
|
35
|
+
// }
|
|
36
|
+
// }
|
|
37
|
+
// useEffect(() => {
|
|
38
|
+
// console.log('lowSpeedCount: ', lowSpeedCount, ' isSpeedTestEnabled: ', isSpeedTestEnabled);
|
|
39
|
+
// console.log('isSpeedTestEnabled: ', isSpeedTestEnabled);
|
|
40
|
+
// if (isSpeedTestEnabled && lowSpeedCount >= 3 && location.pathname !== '/networkError') {
|
|
41
|
+
// navigate('/networkError');
|
|
42
|
+
// }
|
|
43
|
+
// }, [lowSpeedCount, isSpeedTestEnabled]);
|
|
44
|
+
// useEffect(() => {
|
|
45
|
+
// const checkNetworkStatus = () => {
|
|
46
|
+
// if (!navigator.onLine && location.pathname !== '/networkError') {
|
|
47
|
+
// navigate('/networkError');
|
|
48
|
+
// }
|
|
49
|
+
// };
|
|
50
|
+
// const interval = setInterval(() => {
|
|
51
|
+
// checkNetworkStatus();
|
|
52
|
+
// }, 5000);
|
|
53
|
+
// return () => clearInterval(interval);
|
|
54
|
+
// }, []);
|
|
55
|
+
return (React.createElement(SpeedContext.Provider, { value: { speed: speed, stopSpeedTest: stopSpeedTest, startSpeedTest: startSpeedTest } }, children));
|
|
56
|
+
};
|
|
57
|
+
export var useSpeedTest = function () { return useContext(SpeedContext); };
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createTheme } from '@mui/material';
|
|
2
|
+
var theme = createTheme({
|
|
3
|
+
breakpoints: {
|
|
4
|
+
values: {
|
|
5
|
+
xs: 0,
|
|
6
|
+
sm: 600,
|
|
7
|
+
md: 768,
|
|
8
|
+
mdlg: 960,
|
|
9
|
+
lg: 1200,
|
|
10
|
+
xl: 1440,
|
|
11
|
+
xxl: 1728,
|
|
12
|
+
xxxl: 2200
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
typography: {
|
|
16
|
+
allVariants: {
|
|
17
|
+
fontFamily: 'Inter, roboto, system-ui, Avenir, Helvetica, Arial, sans-serif',
|
|
18
|
+
textTransform: 'none',
|
|
19
|
+
letterSpacing: 0,
|
|
20
|
+
},
|
|
21
|
+
h1: {
|
|
22
|
+
fontSize: '2.5rem',
|
|
23
|
+
fontWeight: 700,
|
|
24
|
+
lineHeight: '3rem',
|
|
25
|
+
},
|
|
26
|
+
h2: {
|
|
27
|
+
fontSize: '1.5rem',
|
|
28
|
+
fontWeight: 500,
|
|
29
|
+
lineHeight: '2.5rem',
|
|
30
|
+
},
|
|
31
|
+
h3: {
|
|
32
|
+
fontSize: '1.25rem',
|
|
33
|
+
fontWeight: 500,
|
|
34
|
+
lineHeight: '1.75rem'
|
|
35
|
+
},
|
|
36
|
+
h4: {
|
|
37
|
+
fontSize: '1rem',
|
|
38
|
+
fontWeight: 500,
|
|
39
|
+
lineHeight: '1.5rem'
|
|
40
|
+
},
|
|
41
|
+
h5: {
|
|
42
|
+
fontSize: '1rem',
|
|
43
|
+
fontWeight: 500,
|
|
44
|
+
lineHeight: '1.5rem'
|
|
45
|
+
},
|
|
46
|
+
h6: {
|
|
47
|
+
fontSize: '0.75rem',
|
|
48
|
+
fontWeight: 500,
|
|
49
|
+
lineHeight: '1rem'
|
|
50
|
+
},
|
|
51
|
+
body1: {
|
|
52
|
+
fontSize: '1rem',
|
|
53
|
+
fontWeight: 500,
|
|
54
|
+
lineHeight: '1.5rem'
|
|
55
|
+
},
|
|
56
|
+
body2: {
|
|
57
|
+
fontSize: '0.75rem',
|
|
58
|
+
fontWeight: 500,
|
|
59
|
+
lineHeight: '1.2rem'
|
|
60
|
+
},
|
|
61
|
+
subtitle2: {
|
|
62
|
+
fontSize: '0.5rem',
|
|
63
|
+
fontWeight: 500,
|
|
64
|
+
lineHeight: '0.8rem'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
palette: {
|
|
68
|
+
primary: {
|
|
69
|
+
main: '#000000',
|
|
70
|
+
},
|
|
71
|
+
secondary: {
|
|
72
|
+
light: '#E5F6FD',
|
|
73
|
+
main: '#4faef7',
|
|
74
|
+
dark: '#014361',
|
|
75
|
+
contrastText: 'white'
|
|
76
|
+
},
|
|
77
|
+
success: {
|
|
78
|
+
main: '#2CD483'
|
|
79
|
+
},
|
|
80
|
+
info: {
|
|
81
|
+
main: '#808080',
|
|
82
|
+
dark: '#000000',
|
|
83
|
+
light: '#696969'
|
|
84
|
+
},
|
|
85
|
+
text: {
|
|
86
|
+
primary: '#000000',
|
|
87
|
+
secondary: '#696969'
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
components: {
|
|
91
|
+
MuiButton: {
|
|
92
|
+
styleOverrides: {
|
|
93
|
+
root: {
|
|
94
|
+
fontWeight: 700,
|
|
95
|
+
borderRadius: 40
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
MuiOutlinedInput: {
|
|
100
|
+
styleOverrides: {
|
|
101
|
+
root: {
|
|
102
|
+
background: '#f7f7f7',
|
|
103
|
+
'& fieldset': {
|
|
104
|
+
borderColor: '#f7f7f7',
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
MuiFormControlLabel: {
|
|
110
|
+
styleOverrides: {
|
|
111
|
+
root: {
|
|
112
|
+
'& .MuiFormControlLabel-asterisk ': {
|
|
113
|
+
display: 'none'
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
export default theme;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export var Environment;
|
|
2
|
+
(function (Environment) {
|
|
3
|
+
Environment["Sandbox"] = "sandbox";
|
|
4
|
+
Environment["Staging"] = "staging";
|
|
5
|
+
Environment["Idv"] = "idv";
|
|
6
|
+
})(Environment || (Environment = {}));
|
|
7
|
+
export var PageStatus;
|
|
8
|
+
(function (PageStatus) {
|
|
9
|
+
PageStatus[PageStatus["Loading"] = -1] = "Loading";
|
|
10
|
+
PageStatus[PageStatus["SendSns"] = 0] = "SendSns";
|
|
11
|
+
PageStatus[PageStatus["VerifyNewUser"] = 1] = "VerifyNewUser";
|
|
12
|
+
PageStatus[PageStatus["Vender"] = 1.1] = "Vender";
|
|
13
|
+
PageStatus[PageStatus["IdOrPassport"] = 1.2] = "IdOrPassport";
|
|
14
|
+
PageStatus[PageStatus["VerifyUser"] = 1.5] = "VerifyUser";
|
|
15
|
+
PageStatus[PageStatus["AuthIdOnboarding"] = 2] = "AuthIdOnboarding";
|
|
16
|
+
PageStatus[PageStatus["ClearOnboarding"] = 2.1] = "ClearOnboarding";
|
|
17
|
+
PageStatus[PageStatus["IncodeOnBoarding"] = 2.2] = "IncodeOnBoarding";
|
|
18
|
+
PageStatus[PageStatus["AuthidLogin"] = 3] = "AuthidLogin";
|
|
19
|
+
PageStatus[PageStatus["ClearLogin"] = 4] = "ClearLogin";
|
|
20
|
+
PageStatus[PageStatus["IncodeLogin"] = 5] = "IncodeLogin";
|
|
21
|
+
PageStatus[PageStatus["ClearLoginAllSet"] = 6] = "ClearLoginAllSet";
|
|
22
|
+
PageStatus[PageStatus["ClearOnboardingAllSet"] = 7] = "ClearOnboardingAllSet";
|
|
23
|
+
PageStatus[PageStatus["AllSet"] = 10] = "AllSet";
|
|
24
|
+
})(PageStatus || (PageStatus = {}));
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
var _a, _b;
|
|
2
|
+
import { Environment } from "../enum";
|
|
3
|
+
export var environmentDomains = (_a = {},
|
|
4
|
+
_a[Environment.Sandbox] = 'https://sandbox-backend.berify.me',
|
|
5
|
+
_a[Environment.Staging] = 'https://staging-backend.berify.me',
|
|
6
|
+
_a[Environment.Idv] = 'https://backend.berify.me',
|
|
7
|
+
_a);
|
|
8
|
+
export var environmentWebviewDomains = (_b = {},
|
|
9
|
+
_b[Environment.Sandbox] = 'https://sandbox.berify.me',
|
|
10
|
+
_b[Environment.Staging] = 'https://staging.berify.me',
|
|
11
|
+
_b[Environment.Idv] = 'https://idv.berify.me',
|
|
12
|
+
_b);
|
|
@@ -0,0 +1,158 @@
|
|
|
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 { startRegistration, startAuthentication, } from '@simplewebauthn/browser';
|
|
38
|
+
//[web] const backendDomainEnv = import.meta.env.VITE_BACKEND_DOMAIN as string;
|
|
39
|
+
//[web] const frontendDomainEnv = import.meta.env.VITE_DOMAIN as string;
|
|
40
|
+
//[web] const frontendDomainNameEnv = import.meta.env.VITE_DOMAIN_NAME as string;
|
|
41
|
+
var handleRegister = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
42
|
+
var response, res, attResp, verificationResponse, error_1;
|
|
43
|
+
var phoneNumber = _b.phoneNumber, backendDomain = _b.backendDomain, frontendDomain = _b.frontendDomain, frontendDomainName = _b.frontendDomainName;
|
|
44
|
+
return __generator(this, function (_c) {
|
|
45
|
+
switch (_c.label) {
|
|
46
|
+
case 0:
|
|
47
|
+
_c.trys.push([0, 5, 6, 7]);
|
|
48
|
+
// 強制將網頁窗口焦點
|
|
49
|
+
window.focus();
|
|
50
|
+
return [4 /*yield*/, fetch("".concat(backendDomain, "/api/webauthn/get-registration-options"), {
|
|
51
|
+
method: 'POST',
|
|
52
|
+
headers: { 'Content-Type': 'application/json' },
|
|
53
|
+
body: JSON.stringify({ phoneNumber: phoneNumber, expectedOrigin: frontendDomain, expectedRPID: frontendDomainName }),
|
|
54
|
+
})];
|
|
55
|
+
case 1:
|
|
56
|
+
response = _c.sent();
|
|
57
|
+
return [4 /*yield*/, response.json()];
|
|
58
|
+
case 2:
|
|
59
|
+
res = _c.sent();
|
|
60
|
+
console.log('res: ', res);
|
|
61
|
+
return [4 /*yield*/, startRegistration(res)];
|
|
62
|
+
case 3:
|
|
63
|
+
attResp = _c.sent();
|
|
64
|
+
console.log('attResp', JSON.stringify({ attResp: attResp }));
|
|
65
|
+
return [4 /*yield*/, fetch("".concat(backendDomain, "/api/webauthn/verify-registration"), {
|
|
66
|
+
method: 'POST',
|
|
67
|
+
headers: { 'Content-Type': 'application/json' },
|
|
68
|
+
body: JSON.stringify({ attResp: attResp, phoneNumber: phoneNumber, expectedOrigin: frontendDomain, expectedRPID: frontendDomainName }),
|
|
69
|
+
})];
|
|
70
|
+
case 4:
|
|
71
|
+
verificationResponse = _c.sent();
|
|
72
|
+
if (verificationResponse.ok) {
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
}
|
|
76
|
+
return [3 /*break*/, 7];
|
|
77
|
+
case 5:
|
|
78
|
+
error_1 = _c.sent();
|
|
79
|
+
// 檢查是否是用戶取消 WebAuthn 的錯誤
|
|
80
|
+
if (error_1.name === 'NotAllowedError') {
|
|
81
|
+
console.error('User cancelled WebAuthn registration.');
|
|
82
|
+
// 在這裡你可以執行任何需要的邏輯,例如顯示提示信息
|
|
83
|
+
}
|
|
84
|
+
else {
|
|
85
|
+
console.error('Error during registration:', error_1);
|
|
86
|
+
}
|
|
87
|
+
return [3 /*break*/, 7];
|
|
88
|
+
case 6:
|
|
89
|
+
console.log('Registration process finished.');
|
|
90
|
+
return [7 /*endfinally*/];
|
|
91
|
+
case 7: return [2 /*return*/];
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}); };
|
|
95
|
+
var handleLogin = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
|
|
96
|
+
var response, authOptions, authResp, verificationResponse, responseJson, error_2;
|
|
97
|
+
var phoneNumber = _b.phoneNumber, backendDomain = _b.backendDomain, frontendDomain = _b.frontendDomain, frontendDomainName = _b.frontendDomainName;
|
|
98
|
+
return __generator(this, function (_c) {
|
|
99
|
+
switch (_c.label) {
|
|
100
|
+
case 0:
|
|
101
|
+
_c.trys.push([0, 8, 9, 10]);
|
|
102
|
+
// 強制將網頁窗口焦點
|
|
103
|
+
window.focus();
|
|
104
|
+
return [4 /*yield*/, fetch("".concat(backendDomain, "/api/webauthn/get-authentication-options"), {
|
|
105
|
+
method: 'POST',
|
|
106
|
+
headers: { 'Content-Type': 'application/json' },
|
|
107
|
+
body: JSON.stringify({ phoneNumber: phoneNumber, expectedOrigin: frontendDomain, expectedRPID: frontendDomainName }),
|
|
108
|
+
})];
|
|
109
|
+
case 1:
|
|
110
|
+
response = _c.sent();
|
|
111
|
+
if (!response.ok)
|
|
112
|
+
return [2 /*return*/, { user: undefined, success: false }];
|
|
113
|
+
return [4 /*yield*/, response.json()];
|
|
114
|
+
case 2:
|
|
115
|
+
authOptions = _c.sent();
|
|
116
|
+
console.log('authOptions: ', authOptions);
|
|
117
|
+
return [4 /*yield*/, startAuthentication(authOptions)];
|
|
118
|
+
case 3:
|
|
119
|
+
authResp = _c.sent();
|
|
120
|
+
console.log('authResp', JSON.stringify({ authResp: authResp }));
|
|
121
|
+
return [4 /*yield*/, fetch("".concat(backendDomain, "/api/webauthn/verify-authentication"), {
|
|
122
|
+
method: 'POST',
|
|
123
|
+
headers: { 'Content-Type': 'application/json' },
|
|
124
|
+
body: JSON.stringify({ authResp: authResp, phoneNumber: phoneNumber, expectedOrigin: frontendDomain, expectedRPID: frontendDomainName }),
|
|
125
|
+
})];
|
|
126
|
+
case 4:
|
|
127
|
+
verificationResponse = _c.sent();
|
|
128
|
+
if (!verificationResponse.ok) return [3 /*break*/, 6];
|
|
129
|
+
console.log('Login successful!');
|
|
130
|
+
return [4 /*yield*/, verificationResponse.json()];
|
|
131
|
+
case 5:
|
|
132
|
+
responseJson = _c.sent();
|
|
133
|
+
return [2 /*return*/, { user: responseJson.user, success: true }];
|
|
134
|
+
case 6:
|
|
135
|
+
console.error('Authentication verification failed.');
|
|
136
|
+
return [2 /*return*/, { user: undefined, success: false }];
|
|
137
|
+
case 7: return [3 /*break*/, 10];
|
|
138
|
+
case 8:
|
|
139
|
+
error_2 = _c.sent();
|
|
140
|
+
if (error_2.name === 'NotAllowedError') {
|
|
141
|
+
console.error('User cancelled WebAuthn login.');
|
|
142
|
+
}
|
|
143
|
+
else {
|
|
144
|
+
console.error('Error during authentication:', error_2);
|
|
145
|
+
}
|
|
146
|
+
return [2 /*return*/, { user: undefined, success: false }];
|
|
147
|
+
case 9:
|
|
148
|
+
console.log('Authentication process finished.');
|
|
149
|
+
return [7 /*endfinally*/];
|
|
150
|
+
case 10: return [2 /*return*/];
|
|
151
|
+
}
|
|
152
|
+
});
|
|
153
|
+
}); };
|
|
154
|
+
var webauthn = {
|
|
155
|
+
login: handleLogin,
|
|
156
|
+
register: handleRegister,
|
|
157
|
+
};
|
|
158
|
+
export default webauthn;
|
package/dist/state.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// src/state.ts
|
|
2
|
+
var SDKState = /** @class */ (function () {
|
|
3
|
+
function SDKState() {
|
|
4
|
+
this.data = {};
|
|
5
|
+
}
|
|
6
|
+
SDKState.getInstance = function () {
|
|
7
|
+
if (!SDKState.instance) {
|
|
8
|
+
SDKState.instance = new SDKState();
|
|
9
|
+
}
|
|
10
|
+
return SDKState.instance;
|
|
11
|
+
};
|
|
12
|
+
SDKState.prototype.set = function (key, value) {
|
|
13
|
+
this.data[key] = value;
|
|
14
|
+
};
|
|
15
|
+
SDKState.prototype.get = function (key) {
|
|
16
|
+
return this.data[key];
|
|
17
|
+
};
|
|
18
|
+
SDKState.prototype.getAll = function () {
|
|
19
|
+
return this.data;
|
|
20
|
+
};
|
|
21
|
+
return SDKState;
|
|
22
|
+
}());
|
|
23
|
+
export var sdkState = SDKState.getInstance();
|
package/dist/theme.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import { createTheme } from '@mui/material';
|
|
2
|
+
var theme = createTheme({
|
|
3
|
+
breakpoints: {
|
|
4
|
+
values: {
|
|
5
|
+
xs: 0,
|
|
6
|
+
sm: 600,
|
|
7
|
+
md: 768,
|
|
8
|
+
mdlg: 960,
|
|
9
|
+
lg: 1200,
|
|
10
|
+
xl: 1440,
|
|
11
|
+
xxl: 1728,
|
|
12
|
+
xxxl: 2200
|
|
13
|
+
},
|
|
14
|
+
},
|
|
15
|
+
typography: {
|
|
16
|
+
allVariants: {
|
|
17
|
+
fontFamily: 'Inter, roboto, system-ui, Avenir, Helvetica, Arial, sans-serif',
|
|
18
|
+
textTransform: 'none',
|
|
19
|
+
letterSpacing: 0,
|
|
20
|
+
},
|
|
21
|
+
h1: {
|
|
22
|
+
fontSize: '2.5rem',
|
|
23
|
+
fontWeight: 700,
|
|
24
|
+
lineHeight: '3rem',
|
|
25
|
+
},
|
|
26
|
+
h2: {
|
|
27
|
+
fontSize: '1.5rem',
|
|
28
|
+
fontWeight: 400,
|
|
29
|
+
lineHeight: '2.5rem',
|
|
30
|
+
},
|
|
31
|
+
h3: {
|
|
32
|
+
fontSize: '1.25rem',
|
|
33
|
+
fontWeight: 400,
|
|
34
|
+
lineHeight: '1.75rem'
|
|
35
|
+
},
|
|
36
|
+
h4: {
|
|
37
|
+
fontSize: '1rem',
|
|
38
|
+
fontWeight: 400,
|
|
39
|
+
lineHeight: '1.5rem'
|
|
40
|
+
},
|
|
41
|
+
h5: {
|
|
42
|
+
fontSize: '1rem',
|
|
43
|
+
fontWeight: 400,
|
|
44
|
+
lineHeight: '1.5rem'
|
|
45
|
+
},
|
|
46
|
+
h6: {
|
|
47
|
+
fontSize: '0.75rem',
|
|
48
|
+
fontWeight: 400,
|
|
49
|
+
lineHeight: '1rem'
|
|
50
|
+
},
|
|
51
|
+
body1: {
|
|
52
|
+
fontSize: '1rem',
|
|
53
|
+
fontWeight: 400,
|
|
54
|
+
lineHeight: '1.5rem'
|
|
55
|
+
},
|
|
56
|
+
body2: {
|
|
57
|
+
fontSize: '0.75rem',
|
|
58
|
+
fontWeight: 400,
|
|
59
|
+
lineHeight: '1.2rem'
|
|
60
|
+
},
|
|
61
|
+
subtitle2: {
|
|
62
|
+
fontSize: '0.5rem',
|
|
63
|
+
fontWeight: 400,
|
|
64
|
+
lineHeight: '0.8rem'
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
palette: {
|
|
68
|
+
primary: {
|
|
69
|
+
main: '#000000',
|
|
70
|
+
},
|
|
71
|
+
secondary: {
|
|
72
|
+
light: '#E5F6FD',
|
|
73
|
+
main: '#4faef7',
|
|
74
|
+
dark: '#014361',
|
|
75
|
+
contrastText: 'white'
|
|
76
|
+
},
|
|
77
|
+
success: {
|
|
78
|
+
main: '#2CD483'
|
|
79
|
+
},
|
|
80
|
+
info: {
|
|
81
|
+
main: '#808080',
|
|
82
|
+
dark: '#000000',
|
|
83
|
+
light: '#696969'
|
|
84
|
+
},
|
|
85
|
+
text: {
|
|
86
|
+
primary: '#000000',
|
|
87
|
+
secondary: '#696969'
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
components: {
|
|
91
|
+
MuiButton: {
|
|
92
|
+
styleOverrides: {
|
|
93
|
+
root: {
|
|
94
|
+
fontWeight: 700,
|
|
95
|
+
borderRadius: 40
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
},
|
|
99
|
+
MuiOutlinedInput: {
|
|
100
|
+
styleOverrides: {
|
|
101
|
+
root: {
|
|
102
|
+
background: '#f7f7f7',
|
|
103
|
+
'& fieldset': {
|
|
104
|
+
borderColor: '#f7f7f7',
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
MuiFormControlLabel: {
|
|
110
|
+
styleOverrides: {
|
|
111
|
+
root: {
|
|
112
|
+
'& .MuiFormControlLabel-asterisk ': {
|
|
113
|
+
display: 'none'
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
export default theme;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Environment } from '../enum';
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import '../../index.css';
|
|
4
|
+
declare const HomeModal: React.FC<{
|
|
5
|
+
apiKeyId: string;
|
|
6
|
+
secretKey: string;
|
|
7
|
+
redirectUrl: string;
|
|
8
|
+
initialPhoneNumber?: string;
|
|
9
|
+
environment: Environment;
|
|
10
|
+
forceQrcode?: boolean;
|
|
11
|
+
}>;
|
|
12
|
+
export default HomeModal;
|