@bytexbyte/berifyme-react-sdk 1.0.16 → 1.0.19

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.
Files changed (79) hide show
  1. package/dist/BerifymeModal/index.js +20 -12
  2. package/dist/api/api.js +39 -4
  3. package/dist/components/AllSet/index.js +36 -40
  4. package/dist/components/Login/authid/authid.js +26 -17
  5. package/dist/components/Login/authid/index.js +1 -6
  6. package/dist/components/Login/clearAllSet.js +2 -6
  7. package/dist/components/Login/incode/Login.js +3 -3
  8. package/dist/components/OnBoarding/authId/index.js +29 -15
  9. package/dist/components/OnBoarding/clear/clearAllSet.js +2 -6
  10. package/dist/components/OnBoarding/incode/SelectType.js +7 -3
  11. package/dist/components/OnBoarding/incode/index.js +37 -32
  12. package/dist/components/OnBoarding/vender/grid/authIdGrid.js +1 -1
  13. package/dist/components/OnBoarding/vender/grid/clearGrid.js +1 -1
  14. package/dist/components/OnBoarding/vender/grid/incodeGrid.js +1 -1
  15. package/dist/components/OnBoarding/vender/grid/sumsubGrid.js +1 -1
  16. package/dist/components/OnBoarding/vender/grid/veriffGrid.js +1 -1
  17. package/dist/components/OnBoarding/vender/grid/yotiGrid.js +1 -1
  18. package/dist/components/QrcodeExpired.js +1 -1
  19. package/dist/components/SendSns/index.js +40 -34
  20. package/dist/components/SessionInterrupted.js +1 -1
  21. package/dist/components/SnapMatch/ExceptionView.js +22 -0
  22. package/dist/components/SnapMatch/LangSelector.js +26 -0
  23. package/dist/components/SnapMatch/SnapMatchStep.js +122 -0
  24. package/dist/components/SnapMatch/SuccessView.js +22 -0
  25. package/dist/components/SnapMatch/TryAgainView.js +19 -0
  26. package/dist/components/SnapMatch/index.js +271 -0
  27. package/dist/components/SnapMatch/translations.js +32 -0
  28. package/dist/components/SomethingWrong.js +41 -0
  29. package/dist/components/VerifyWithPhoneNumber/NewUser/index.js +4 -4
  30. package/dist/components/VerifyWithPhoneNumber/User/index.js +13 -10
  31. package/dist/index.js +6 -1
  32. package/dist/types/api/api.d.ts +7 -1
  33. package/dist/types/components/AllSet/index.d.ts +2 -1
  34. package/dist/types/components/Login/authid/authid.d.ts +1 -1
  35. package/dist/types/components/Login/authid/index.d.ts +1 -0
  36. package/dist/types/components/Login/clearAllSet.d.ts +1 -0
  37. package/dist/types/components/OnBoarding/clear/clearAllSet.d.ts +1 -0
  38. package/dist/types/components/OnBoarding/incode/SelectType.d.ts +2 -1
  39. package/dist/types/components/OnBoarding/incode/index.d.ts +2 -0
  40. package/dist/types/components/SnapMatch/ExceptionView.d.ts +11 -0
  41. package/dist/types/components/SnapMatch/LangSelector.d.ts +11 -0
  42. package/dist/types/components/SnapMatch/SnapMatchStep.d.ts +23 -0
  43. package/dist/types/components/SnapMatch/SuccessView.d.ts +11 -0
  44. package/dist/types/components/SnapMatch/TryAgainView.d.ts +11 -0
  45. package/dist/types/components/SnapMatch/index.d.ts +17 -0
  46. package/dist/types/components/SnapMatch/translations.d.ts +54 -0
  47. package/dist/types/components/SomethingWrong.d.ts +7 -0
  48. package/dist/types/index.d.ts +6 -1
  49. package/dist/types/vender/incode/incode.d.ts +6 -2
  50. package/dist/types/vender/incode/translations/en.d.ts +2638 -0
  51. package/dist/types/vender/incode/translations/zh-TW.d.ts +2634 -0
  52. package/dist/vender/incode/incode.js +81 -5
  53. package/dist/vender/incode/translations/en.js +2638 -0
  54. package/dist/vender/incode/translations/zh-TW.js +2634 -0
  55. package/package.json +5 -2
  56. package/dist/components/Login/sumsub/index.js +0 -212
  57. package/dist/components/Login/veriff/Login.js +0 -168
  58. package/dist/components/Login/veriff/index.js +0 -14
  59. package/dist/components/Login/yoti/Login.js +0 -245
  60. package/dist/components/Login/yoti/index.js +0 -14
  61. package/dist/components/OnBoarding/sumsub/index.js +0 -183
  62. package/dist/components/OnBoarding/veriff/index.js +0 -152
  63. package/dist/components/OnBoarding/yoti/OnBoarding.js +0 -238
  64. package/dist/components/OnBoarding/yoti/index.js +0 -14
  65. package/dist/components/TryAgain.js +0 -16
  66. package/dist/components/TryAgainInModal.js +0 -15
  67. package/dist/event.js +0 -18
  68. package/dist/types/components/Login/sumsub/index.d.ts +0 -10
  69. package/dist/types/components/Login/veriff/Login.d.ts +0 -12
  70. package/dist/types/components/Login/veriff/index.d.ts +0 -11
  71. package/dist/types/components/Login/yoti/Login.d.ts +0 -11
  72. package/dist/types/components/Login/yoti/index.d.ts +0 -10
  73. package/dist/types/components/OnBoarding/sumsub/index.d.ts +0 -10
  74. package/dist/types/components/OnBoarding/veriff/index.d.ts +0 -11
  75. package/dist/types/components/OnBoarding/yoti/OnBoarding.d.ts +0 -12
  76. package/dist/types/components/OnBoarding/yoti/index.d.ts +0 -11
  77. package/dist/types/components/TryAgain.d.ts +0 -6
  78. package/dist/types/components/TryAgainInModal.d.ts +0 -6
  79. package/dist/types/event.d.ts +0 -9
@@ -0,0 +1,271 @@
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, { useCallback, useEffect, useRef, useState } from "react";
38
+ import { createPortal } from "react-dom";
39
+ import { Box, CircularProgress, ThemeProvider, Typography } from "@mui/material";
40
+ import berifymeApi, { initializeBerifymeApi } from "../../api/api";
41
+ import { environmentDomains } from "../../lib/environmentDomains";
42
+ import theme from "../theme";
43
+ import SnapMatchStep from "./SnapMatchStep";
44
+ import SuccessView from "./SuccessView";
45
+ import TryAgainView from "./TryAgainView";
46
+ import ExceptionView from "./ExceptionView";
47
+ import LangSelector, { LANG_OPTIONS } from "./LangSelector";
48
+ import { getSnapMatchResultTranslations } from "./translations";
49
+ var DEFAULT_ERROR_MESSAGE = "Something went wrong, but we're working on it. Please try again later or contact support for assistance.";
50
+ var DEFAULT_AUTO_REDIRECT_SECONDS = 5;
51
+ var RETURN_TO_SCAN_DELAY_MS = 400;
52
+ var SnapMatch = function (_a) {
53
+ var apiKeyId = _a.apiKeyId, secretKey = _a.secretKey, environment = _a.environment, onSuccess = _a.onSuccess, onError = _a.onError, tokenProp = _a.token, _b = _a.lang, langProp = _b === void 0 ? "en" : _b, _c = _a.autoRedirectSeconds, autoRedirectSeconds = _c === void 0 ? DEFAULT_AUTO_REDIRECT_SECONDS : _c;
54
+ var defaultLang = LANG_OPTIONS.some(function (o) { return o.value === langProp; }) ? langProp : "en";
55
+ var _d = useState(defaultLang), currentLang = _d[0], setCurrentLang = _d[1];
56
+ var _e = useState(0), langChangeKey = _e[0], setLangChangeKey = _e[1];
57
+ var setCurrentLangAndBump = useCallback(function (next) {
58
+ setCurrentLang(next);
59
+ setLangChangeKey(function (k) { return k + 1; });
60
+ }, []);
61
+ var _f = useState("login"), step = _f[0], setStep = _f[1];
62
+ var _g = useState(tokenProp), token = _g[0], setToken = _g[1];
63
+ var _h = useState(), tokenError = _h[0], setTokenError = _h[1];
64
+ var _j = useState(""), errorMessage = _j[0], setErrorMessage = _j[1];
65
+ var _k = useState(), fullName = _k[0], setFullName = _k[1];
66
+ var _l = useState(0), loginKey = _l[0], setLoginKey = _l[1];
67
+ var _m = useState(false), returnLoading = _m[0], setReturnLoading = _m[1];
68
+ var _o = useState(0), countdown = _o[0], setCountdown = _o[1];
69
+ var hasHandledSuccessRef = useRef(false);
70
+ var stepRef = useRef(step);
71
+ var loginKeyRef = useRef(loginKey);
72
+ var onSuccessRef = useRef(onSuccess);
73
+ var onErrorRef = useRef(onError);
74
+ stepRef.current = step;
75
+ loginKeyRef.current = loginKey;
76
+ onSuccessRef.current = onSuccess;
77
+ onErrorRef.current = onError;
78
+ useEffect(function () {
79
+ initializeBerifymeApi({ backendDomain: environmentDomains[environment] });
80
+ }, [environment]);
81
+ useEffect(function () {
82
+ try {
83
+ sessionStorage.clear();
84
+ }
85
+ catch (_a) {
86
+ // ignore
87
+ }
88
+ }, []);
89
+ useEffect(function () {
90
+ if (tokenProp && tokenProp.startsWith("session_")) {
91
+ setToken(tokenProp);
92
+ return;
93
+ }
94
+ if (token)
95
+ return;
96
+ var cancelled = false;
97
+ berifymeApi.thirdParty
98
+ .createSessionTokenWithoutRedirectUrl({ apiKeyId: apiKeyId, secretKey: secretKey })
99
+ .then(function (res) {
100
+ var _a;
101
+ if (cancelled)
102
+ return;
103
+ if (res.sessionToken)
104
+ setToken(res.sessionToken);
105
+ else
106
+ setTokenError((_a = res.error) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_MESSAGE);
107
+ })
108
+ .catch(function () {
109
+ if (!cancelled)
110
+ setTokenError(DEFAULT_ERROR_MESSAGE);
111
+ });
112
+ return function () {
113
+ cancelled = true;
114
+ };
115
+ }, [apiKeyId, secretKey, tokenProp, token]);
116
+ var handleBackToLogin = useCallback(function () {
117
+ if (returnLoading)
118
+ return;
119
+ setReturnLoading(true);
120
+ setErrorMessage("");
121
+ try {
122
+ sessionStorage.clear();
123
+ }
124
+ catch (_a) {
125
+ // ignore
126
+ }
127
+ berifymeApi.thirdParty
128
+ .createSessionTokenWithoutRedirectUrl({ apiKeyId: apiKeyId, secretKey: secretKey })
129
+ .then(function (data) {
130
+ var _a;
131
+ if (data.sessionToken) {
132
+ setToken(data.sessionToken);
133
+ hasHandledSuccessRef.current = false;
134
+ setLoginKey(function (k) { return k + 1; });
135
+ setTimeout(function () {
136
+ setStep("login");
137
+ setReturnLoading(false);
138
+ }, RETURN_TO_SCAN_DELAY_MS);
139
+ }
140
+ else {
141
+ setTokenError((_a = data.error) !== null && _a !== void 0 ? _a : DEFAULT_ERROR_MESSAGE);
142
+ setReturnLoading(false);
143
+ }
144
+ })
145
+ .catch(function () {
146
+ setErrorMessage(getSnapMatchResultTranslations(currentLang).exceptionConnectionError);
147
+ setReturnLoading(false);
148
+ });
149
+ }, [apiKeyId, secretKey, currentLang, returnLoading]);
150
+ var handleRetry = useCallback(function () { return handleBackToLogin(); }, [handleBackToLogin]);
151
+ var handleNextPerson = useCallback(function () {
152
+ setFullName(undefined);
153
+ handleBackToLogin();
154
+ }, [handleBackToLogin]);
155
+ var handleExceptionBack = useCallback(function () { return handleBackToLogin(); }, [handleBackToLogin]);
156
+ useEffect(function () {
157
+ if (step !== "success" && step !== "failure" && step !== "warning")
158
+ return;
159
+ setCountdown(autoRedirectSeconds);
160
+ var t = setTimeout(function () {
161
+ if (step === "success")
162
+ handleNextPerson();
163
+ else if (step === "failure")
164
+ handleRetry();
165
+ else
166
+ handleExceptionBack();
167
+ }, autoRedirectSeconds * 1000);
168
+ return function () { return clearTimeout(t); };
169
+ }, [step, autoRedirectSeconds, handleNextPerson, handleRetry, handleExceptionBack]);
170
+ useEffect(function () {
171
+ if ((step !== "success" && step !== "failure" && step !== "warning") || countdown <= 0)
172
+ return;
173
+ var interval = setInterval(function () {
174
+ setCountdown(function (c) { return (c <= 1 ? 0 : c - 1); });
175
+ }, 1000);
176
+ return function () { return clearInterval(interval); };
177
+ }, [step, countdown]);
178
+ var handleSuccess = useCallback(function (response, options) { return __awaiter(void 0, void 0, void 0, function () {
179
+ var msg, res, msg, _a, msg;
180
+ var _b, _c;
181
+ return __generator(this, function (_d) {
182
+ switch (_d.label) {
183
+ case 0:
184
+ if (stepRef.current !== "login")
185
+ return [2 /*return*/];
186
+ if (options.loginKey !== loginKeyRef.current)
187
+ return [2 /*return*/];
188
+ if (hasHandledSuccessRef.current)
189
+ return [2 /*return*/];
190
+ hasHandledSuccessRef.current = true;
191
+ if (!(response === null || response === void 0 ? void 0 : response.customerId)) {
192
+ msg = getSnapMatchResultTranslations(currentLang).failureDefault;
193
+ setErrorMessage(msg);
194
+ onErrorRef.current(msg);
195
+ setStep("failure");
196
+ return [2 /*return*/];
197
+ }
198
+ _d.label = 1;
199
+ case 1:
200
+ _d.trys.push([1, 3, , 4]);
201
+ return [4 /*yield*/, berifymeApi.user.getUserByIncodeId({
202
+ customerId: response.customerId,
203
+ interviewId: (_b = response.interviewId) !== null && _b !== void 0 ? _b : "",
204
+ token: token,
205
+ })];
206
+ case 2:
207
+ res = _d.sent();
208
+ if (res.user) {
209
+ onSuccessRef.current(res.user);
210
+ if (res.user.fullName)
211
+ setFullName(res.user.fullName);
212
+ setStep("success");
213
+ }
214
+ else {
215
+ msg = (_c = res.error) !== null && _c !== void 0 ? _c : getSnapMatchResultTranslations(currentLang).exceptionDescription;
216
+ setErrorMessage(msg);
217
+ onErrorRef.current(msg);
218
+ setStep("warning");
219
+ }
220
+ return [3 /*break*/, 4];
221
+ case 3:
222
+ _a = _d.sent();
223
+ msg = getSnapMatchResultTranslations(currentLang).exceptionConnectionError;
224
+ setErrorMessage(msg);
225
+ onErrorRef.current(msg);
226
+ setStep("warning");
227
+ return [3 /*break*/, 4];
228
+ case 4: return [2 /*return*/];
229
+ }
230
+ });
231
+ }); }, [currentLang, token]);
232
+ var handleError = useCallback(function () {
233
+ var msg = getSnapMatchResultTranslations(currentLang).failureDefault;
234
+ setErrorMessage(msg);
235
+ onErrorRef.current(msg);
236
+ setStep("failure");
237
+ }, [currentLang]);
238
+ if (tokenError) {
239
+ return (React.createElement(ThemeProvider, { theme: theme },
240
+ React.createElement(Box, { sx: { display: "flex", flexDirection: "column", alignItems: "center", justifyContent: "center", height: "100vh", gap: 2, px: 2 } },
241
+ React.createElement(Typography, { variant: "body1", color: "error", textAlign: "center" }, tokenError))));
242
+ }
243
+ if (!token) {
244
+ return (React.createElement(ThemeProvider, { theme: theme },
245
+ React.createElement(Box, { sx: { display: "flex", justifyContent: "center", alignItems: "center", height: "100vh", background: "#FFFFFF" } },
246
+ React.createElement(CircularProgress, null))));
247
+ }
248
+ if (step === "success") {
249
+ return (React.createElement(ThemeProvider, { theme: theme },
250
+ React.createElement(Box, { sx: { position: "fixed", inset: 0, zIndex: 10000, bgcolor: "background.paper", overflow: "auto" } },
251
+ React.createElement(SuccessView, { lang: currentLang, fullName: fullName, onContinue: handleNextPerson, returnLoading: returnLoading, autoRedirectSeconds: autoRedirectSeconds, countdown: countdown }))));
252
+ }
253
+ if (step === "failure") {
254
+ return (React.createElement(ThemeProvider, { theme: theme },
255
+ React.createElement(Box, { sx: { position: "fixed", inset: 0, zIndex: 10000, bgcolor: "background.paper", overflow: "auto" } },
256
+ React.createElement(TryAgainView, { lang: currentLang, message: errorMessage, onRetry: handleRetry, retryLoading: returnLoading, autoRedirectSeconds: autoRedirectSeconds, countdown: countdown }))));
257
+ }
258
+ if (step === "warning") {
259
+ return (React.createElement(ThemeProvider, { theme: theme },
260
+ React.createElement(Box, { sx: { position: "fixed", inset: 0, zIndex: 10000, bgcolor: "background.paper", overflow: "auto" } },
261
+ React.createElement(ExceptionView, { lang: currentLang, message: errorMessage, onBack: handleExceptionBack, returnLoading: returnLoading, autoRedirectSeconds: autoRedirectSeconds, countdown: countdown }))));
262
+ }
263
+ return (React.createElement(ThemeProvider, { theme: theme },
264
+ typeof document !== "undefined" &&
265
+ createPortal(React.createElement(ThemeProvider, { theme: theme },
266
+ React.createElement(Box, { sx: { position: "fixed", top: 16, right: 16, zIndex: 2147483647, pointerEvents: "auto" } },
267
+ React.createElement(LangSelector, { lang: currentLang, onLangChange: setCurrentLangAndBump }))), document.body),
268
+ React.createElement(Box, { sx: { position: "relative", width: "100%", height: "100%", minHeight: "100vh" } },
269
+ React.createElement(SnapMatchStep, { key: "".concat(currentLang, "-").concat(loginKey, "-").concat(langChangeKey), lang: currentLang, loginKey: loginKey, onSuccess: handleSuccess, onError: handleError }))));
270
+ };
271
+ export default SnapMatch;
@@ -0,0 +1,32 @@
1
+ export var snapMatchResultTranslations = {
2
+ en: {
3
+ successTitle: "Verification successful",
4
+ successDescription: "You have completed identity verification through face recognition.",
5
+ countdownReturn: function (n) { return "".concat(n, " seconds until automatic return to verification"); },
6
+ redirecting: "Redirecting…",
7
+ nextPerson: "Next person",
8
+ failureDefault: "Verification failed. Please try again.",
9
+ retry: "Try again",
10
+ exceptionTitle: "Exception",
11
+ exceptionDescription: "Face verification succeeded but we could not retrieve your information. Please contact staff or try again.",
12
+ exceptionConnectionError: "Connection failed. Please try again later.",
13
+ backToVerification: "Back to verification",
14
+ },
15
+ "zh-TW": {
16
+ successTitle: "驗證成功",
17
+ successDescription: "您已透過人臉辨識完成身份驗證。",
18
+ countdownReturn: function (n) { return "".concat(n, " \u79D2\u5F8C\u81EA\u52D5\u8FD4\u56DE\u9A57\u8B49\u9801\u9762"); },
19
+ redirecting: "即將跳轉…",
20
+ nextPerson: "下一位",
21
+ failureDefault: "驗證失敗,請再試一次。",
22
+ retry: "再試一次",
23
+ exceptionTitle: "異常",
24
+ exceptionDescription: "人臉驗證已通過,但無法取得您的資料,請聯繫工作人員或稍後再試。",
25
+ exceptionConnectionError: "連線失敗,請稍後再試。",
26
+ backToVerification: "返回驗證頁面",
27
+ },
28
+ };
29
+ export function getSnapMatchResultTranslations(lang) {
30
+ var _a;
31
+ return (_a = snapMatchResultTranslations[lang]) !== null && _a !== void 0 ? _a : snapMatchResultTranslations.en;
32
+ }
@@ -0,0 +1,41 @@
1
+ import React from 'react';
2
+ import { Button, Stack, Typography, IconButton } from '@mui/material';
3
+ import ArrowBackIcon from '@mui/icons-material/ArrowBack';
4
+ import Footer from './Footer';
5
+ import { useEffect, useState } from 'react';
6
+ var SomethingWrong = function (_a) {
7
+ var message = _a.message, pressButton = _a.pressButton, venderErrorHandleBack = _a.venderErrorHandleBack;
8
+ var _b = useState(false), isVenderError = _b[0], setIsVenderError = _b[1];
9
+ var handleContinue = function () {
10
+ if (pressButton)
11
+ pressButton();
12
+ else
13
+ window.location.reload();
14
+ };
15
+ useEffect(function () {
16
+ if (message === 'Try again later or choose a different verification provider to proceed.') {
17
+ setIsVenderError(true);
18
+ }
19
+ }, [message]);
20
+ return (React.createElement(Stack, { height: 1, width: 1 },
21
+ isVenderError && (React.createElement(Stack, { width: 1, alignItems: "flex-start", pl: 2, pt: 2 },
22
+ React.createElement(IconButton, { onClick: venderErrorHandleBack },
23
+ React.createElement(ArrowBackIcon, { fontSize: 'large', color: 'primary' })))),
24
+ React.createElement(Stack, { pt: isVenderError ? 0 : 2, height: 1, width: 1, justifyContent: 'space-between', alignItems: 'center' },
25
+ React.createElement(Stack, { spacing: 4 },
26
+ React.createElement(Typography, { variant: "h1", fontWeight: 700, textAlign: "center", sx: { fontSize: { xs: '3.8rem', sm: '4rem' }, lineHeight: 1.2 } }, ':-('),
27
+ React.createElement(Typography, { variant: "h2", fontWeight: 700, textAlign: "center" }, "Oops!"),
28
+ isVenderError &&
29
+ React.createElement(Typography, { variant: "body1", color: "text.secondary", textAlign: "center" }, "Something went wrong."),
30
+ message !== undefined && React.createElement(Typography, { variant: "body1", color: "text.secondary", textAlign: "center" }, message ? message : 'Something went wrong, but we’re working on it. Please try again later or contact support for assistance.')),
31
+ React.createElement(Stack, { spacing: 2, pb: 0, alignItems: 'center' },
32
+ React.createElement(Button, { variant: "contained", color: "primary", onClick: isVenderError ? venderErrorHandleBack : handleContinue, sx: {
33
+ bgcolor: 'black',
34
+ color: 'white',
35
+ borderRadius: '25px',
36
+ py: 1.5,
37
+ width: '120px'
38
+ } }, isVenderError ? 'Go back' : 'Try again'),
39
+ React.createElement(Footer, null)))));
40
+ };
41
+ export default SomethingWrong;
@@ -35,12 +35,12 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
35
35
  }
36
36
  };
37
37
  import React from "react";
38
+ import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded';
39
+ import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
38
40
  import { Box, CircularProgress, IconButton, Input, Stack, Typography } from "@mui/material";
39
- import theme from "../../theme";
40
41
  import { useEffect, useState } from "react";
41
42
  import berifymeApi from "../../../api/api";
42
- import ArrowBackRoundedIcon from '@mui/icons-material/ArrowBackRounded';
43
- import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined';
43
+ import theme from "../../theme";
44
44
  import Footer from "../../Footer";
45
45
  import webauthn from "../../../lib/webauthb";
46
46
  import { environmentDomains } from "../../../lib/environmentDomains";
@@ -118,7 +118,7 @@ var VerifyNewUser = function (_a) {
118
118
  }
119
119
  if (!res.user) {
120
120
  setLoading(false);
121
- setErrorMessage('Oops! Something went wrong...');
121
+ setErrorMessage('Something went wrong, but we’re working on it. Please try again later or contact support for assistance.');
122
122
  return [2 /*return*/];
123
123
  }
124
124
  setErrorMessage('');
@@ -91,7 +91,7 @@ var VerifyUser = function (_a) {
91
91
  processedInputValue = processPhoneNumber(processedInputValue);
92
92
  value = e.target.value;
93
93
  setCode(value);
94
- if (!(value.length === 6)) return [3 /*break*/, 6];
94
+ if (!(value.length === 6)) return [3 /*break*/, 7];
95
95
  e.target.blur();
96
96
  setLoading(true);
97
97
  createDeveloperLog({
@@ -126,6 +126,9 @@ var VerifyUser = function (_a) {
126
126
  }
127
127
  setErrorMessage('');
128
128
  setUser(res.user);
129
+ return [4 /*yield*/, berifymeApi.wallet.getWallet({ phoneNumber: processedInputValue })];
130
+ case 2:
131
+ _m.sent();
129
132
  urlString = window.location.href;
130
133
  url = new URL(urlString);
131
134
  return [4 /*yield*/, webauthn.register({
@@ -135,7 +138,7 @@ var VerifyUser = function (_a) {
135
138
  frontendDomain: "".concat(url.protocol, "//").concat(url.host),
136
139
  frontendDomainName: url.host,
137
140
  })];
138
- case 2:
141
+ case 3:
139
142
  _m.sent();
140
143
  createDeveloperLog({
141
144
  userId: (_b = res.user) === null || _b === void 0 ? void 0 : _b.id,
@@ -145,9 +148,9 @@ var VerifyUser = function (_a) {
145
148
  sessionToken: token,
146
149
  });
147
150
  deviceId = localStorage.getItem('deviceId');
148
- if (!(deviceId && token)) return [3 /*break*/, 4];
151
+ if (!(deviceId && token)) return [3 /*break*/, 5];
149
152
  return [4 /*yield*/, berifymeApi.user.checkDeviceId({ phoneNumber: processedInputValue, deviceId: deviceId, token: token })];
150
- case 3:
153
+ case 4:
151
154
  deviceUser = _m.sent();
152
155
  if (deviceUser.user) {
153
156
  createDeveloperLog({
@@ -185,12 +188,12 @@ var VerifyUser = function (_a) {
185
188
  firstDetail: deviceUser.error,
186
189
  secondDetail: "deviceId: ".concat(deviceId),
187
190
  });
188
- _m.label = 4;
189
- case 4: return [4 /*yield*/, berifymeApi.user.getUserVenderByPhone({ phoneNumber: processedInputValue, token: token })];
190
- case 5:
191
+ _m.label = 5;
192
+ case 5: return [4 /*yield*/, berifymeApi.user.getUserVenderByPhone({ phoneNumber: processedInputValue, token: token })];
193
+ case 6:
191
194
  getVender = _m.sent();
192
195
  if (getVender.error) {
193
- setError((_e = getVender.error) !== null && _e !== void 0 ? _e : 'Oops! Something went wrong...');
196
+ setError((_e = getVender.error) !== null && _e !== void 0 ? _e : 'Something went wrong, but we’re working on it. Please try again later or contact support for assistance.');
194
197
  setLoading(false);
195
198
  createDeveloperLog({
196
199
  userId: (_f = res.user) === null || _f === void 0 ? void 0 : _f.id,
@@ -252,8 +255,8 @@ var VerifyUser = function (_a) {
252
255
  firstDetail: processedInputValue,
253
256
  secondDetail: 'webauthn success'
254
257
  });
255
- _m.label = 6;
256
- case 6: return [2 /*return*/];
258
+ _m.label = 7;
259
+ case 7: return [2 /*return*/];
257
260
  }
258
261
  });
259
262
  }); };
package/dist/index.js CHANGED
@@ -1,7 +1,12 @@
1
1
  // src/index.ts
2
2
  import { Environment } from "./enum";
3
3
  import BerifymeModal from "./BerifymeModal/";
4
- export var berifyme = {
4
+ import SnapMatch from "./components/SnapMatch/";
5
+ var berifyme = {
5
6
  environment: Environment,
6
7
  modal: BerifymeModal,
8
+ /** SnapMatch(1:N 人臉辨識):可單獨使用,傳入 onSuccess / onError 取得結果 */
9
+ snapMatch: SnapMatch,
7
10
  };
11
+ export default berifyme;
12
+ export { berifyme };
@@ -356,7 +356,7 @@ declare function generateAppleWalletPass({ id, fullName, birthDate }: {
356
356
  }>;
357
357
  interface CreateSessionTokenResponse {
358
358
  sessionToken?: string;
359
- companyLogo?: string;
359
+ companyLogo?: string | null;
360
360
  error?: string;
361
361
  }
362
362
  declare function createSessionToken({ apiKeyId, secretKey, redirectUrl, }: {
@@ -364,6 +364,11 @@ declare function createSessionToken({ apiKeyId, secretKey, redirectUrl, }: {
364
364
  secretKey: string;
365
365
  redirectUrl: string;
366
366
  }): Promise<CreateSessionTokenResponse>;
367
+ /** SnapMatch(1:N)用:建立 session token(無 redirectUrl),回傳 sessionToken(session_ 前綴) */
368
+ declare function createSessionTokenWithoutRedirectUrl({ apiKeyId, secretKey, }: {
369
+ apiKeyId: string;
370
+ secretKey: string;
371
+ }): Promise<CreateSessionTokenResponse>;
367
372
  declare function createAuthenticationLogs({ actionType, token, userId, vender, os, browser, device, transactionId, incodeSessionId, clearSessionId, isPass, }: {
368
373
  actionType: ActionType;
369
374
  token: string;
@@ -537,6 +542,7 @@ declare const berifymeApi: {
537
542
  getRedirectUrl: typeof getRedirectUrl;
538
543
  checkThirdPartyVerificationToken: typeof checkThirdPartyVerificationToken;
539
544
  checkDesktopRedirectUrlIdExpired: typeof checkDesktopRedirectUrlIdExpired;
545
+ createSessionTokenWithoutRedirectUrl: typeof createSessionTokenWithoutRedirectUrl;
540
546
  };
541
547
  scheduld: {
542
548
  initUpdateAdminTokenSchedule: typeof initUpdateAdminTokenSchedule;
@@ -1,9 +1,10 @@
1
1
  import React from "react";
2
2
  import { User } from "../../api/api";
3
- declare const AllSet: ({ user, token, desktopRedirectUrlId, setPageStatus }: {
3
+ declare const AllSet: ({ user, token, desktopRedirectUrlId, setPageStatus, setError, }: {
4
4
  user: User | undefined;
5
5
  token: string | undefined;
6
6
  desktopRedirectUrlId?: string;
7
7
  setPageStatus: React.Dispatch<React.SetStateAction<number>>;
8
+ setError: React.Dispatch<React.SetStateAction<string | undefined>>;
8
9
  }) => React.JSX.Element;
9
10
  export default AllSet;
@@ -6,6 +6,6 @@ declare const AuthID: ({ phone, setError, goRedirect, goToTryAgain, setUser, tok
6
6
  goRedirect: () => void;
7
7
  goToTryAgain: () => void;
8
8
  setUser: React.Dispatch<React.SetStateAction<UserWithAgeAndFullName | undefined>>;
9
- token: string;
9
+ token?: string;
10
10
  }) => React.JSX.Element;
11
11
  export default AuthID;
@@ -5,5 +5,6 @@ declare const AuthidLogin: React.FC<{
5
5
  phoneNumber: string;
6
6
  setUser: React.Dispatch<React.SetStateAction<UserWithAgeAndFullName | undefined>>;
7
7
  token?: string;
8
+ setError: React.Dispatch<React.SetStateAction<string | undefined>>;
8
9
  }>;
9
10
  export { AuthidLogin };
@@ -3,5 +3,6 @@ declare const ClearLoginAllSet: React.FC<{
3
3
  token?: string;
4
4
  desktopRedirectUrlId?: string;
5
5
  setPageStatus: React.Dispatch<React.SetStateAction<number>>;
6
+ setError: React.Dispatch<React.SetStateAction<string | undefined>>;
6
7
  }>;
7
8
  export { ClearLoginAllSet };
@@ -3,5 +3,6 @@ declare const ClearOnboardingAllSet: React.FC<{
3
3
  token?: string;
4
4
  desktopRedirectUrlId?: string;
5
5
  setPageStatus: React.Dispatch<React.SetStateAction<number>>;
6
+ setError: React.Dispatch<React.SetStateAction<string | undefined>>;
6
7
  }>;
7
8
  export { ClearOnboardingAllSet };
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
- declare const SelectType: ({ goToID, goToPassport, }: {
2
+ declare const SelectType: ({ goToID, goToPassport, onCloseButtonClick, }: {
3
3
  goToID: () => void;
4
4
  goToPassport: () => void;
5
+ onCloseButtonClick: () => void;
5
6
  }) => React.JSX.Element;
6
7
  export default SelectType;
@@ -5,5 +5,7 @@ declare const IncodeOnBoarding: React.FC<{
5
5
  setUser: React.Dispatch<React.SetStateAction<UserWithAgeAndFullName | undefined>>;
6
6
  goToAllSet: () => void;
7
7
  token?: string;
8
+ setError: React.Dispatch<React.SetStateAction<string | undefined>>;
9
+ onGoBack: () => void;
8
10
  }>;
9
11
  export { IncodeOnBoarding };
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ type ExceptionViewProps = {
3
+ lang: string;
4
+ message?: string;
5
+ onBack?: () => void;
6
+ returnLoading?: boolean;
7
+ autoRedirectSeconds?: number;
8
+ countdown?: number;
9
+ };
10
+ declare const ExceptionView: ({ lang, message, onBack, returnLoading, autoRedirectSeconds, countdown, }: ExceptionViewProps) => React.JSX.Element;
11
+ export default ExceptionView;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ export declare const LANG_OPTIONS: {
3
+ value: string;
4
+ label: string;
5
+ }[];
6
+ type LangSelectorProps = {
7
+ lang: string;
8
+ onLangChange: (lang: string) => void;
9
+ };
10
+ declare function LangSelector({ lang, onLangChange }: LangSelectorProps): React.JSX.Element;
11
+ export default LangSelector;
@@ -0,0 +1,23 @@
1
+ import React from "react";
2
+ export type SnapMatchSuccessResponse = {
3
+ customerId: string;
4
+ interviewId?: string;
5
+ token?: string;
6
+ transactionId?: string;
7
+ };
8
+ export type SnapMatchOnSuccessOptions = {
9
+ loginKey: number;
10
+ };
11
+ type SnapMatchStepProps = {
12
+ lang: string;
13
+ loginKey: number;
14
+ onSuccess: (response: SnapMatchSuccessResponse, options: SnapMatchOnSuccessOptions) => void;
15
+ onError: () => void;
16
+ };
17
+ /**
18
+ * 直接開啟 Incode SnapMatch(1:N)驗證步驟。
19
+ * 與 Frontend SnapMatchStep 對齊:僅依 lang 建立實例並轉發結果,父層負責 getUserByIncodeId 與 step。
20
+ * 以 key={`${lang}-${loginKey}`} 渲染可強制語系切換/返回時完整重掛載,避免 Incode 翻譯 cache。
21
+ */
22
+ declare const SnapMatchStep: React.FC<SnapMatchStepProps>;
23
+ export default SnapMatchStep;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ type SuccessViewProps = {
3
+ lang: string;
4
+ fullName?: string;
5
+ onContinue?: () => void;
6
+ returnLoading?: boolean;
7
+ autoRedirectSeconds?: number;
8
+ countdown?: number;
9
+ };
10
+ declare const SuccessView: React.FC<SuccessViewProps>;
11
+ export default SuccessView;
@@ -0,0 +1,11 @@
1
+ import React from "react";
2
+ type TryAgainViewProps = {
3
+ lang: string;
4
+ message?: string;
5
+ onRetry?: () => void;
6
+ retryLoading?: boolean;
7
+ autoRedirectSeconds?: number;
8
+ countdown?: number;
9
+ };
10
+ declare const TryAgainView: ({ lang, message, onRetry, retryLoading, autoRedirectSeconds, countdown, }: TryAgainViewProps) => React.JSX.Element;
11
+ export default TryAgainView;
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { UserWithAgeAndFullName } from "../../api/api";
3
+ import { Environment } from "../../enum";
4
+ export type SnapMatchProps = {
5
+ apiKeyId: string;
6
+ secretKey: string;
7
+ environment: Environment;
8
+ onSuccess: (user: UserWithAgeAndFullName) => void;
9
+ onError: (message: string) => void;
10
+ token?: string;
11
+ /** 預設語系(掃描與結果頁),'en' | 'zh-TW',預設 'en';可於掃描時用按鈕切換中/英 */
12
+ lang?: string;
13
+ /** 結果頁顯示後自動返回掃臉的秒數,0 表示不自動跳轉,預設 5 */
14
+ autoRedirectSeconds?: number;
15
+ };
16
+ declare const SnapMatch: React.FC<SnapMatchProps>;
17
+ export default SnapMatch;