@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
@@ -34,24 +34,22 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
34
34
  if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
35
  }
36
36
  };
37
- import React from "react";
38
- import { useEffect, useRef, useState } from "react";
39
- import Steps from "./Steps";
40
- import { UserConsent } from "./UserConsent";
41
- import { FrontId } from "./FrontId";
42
- import { BackId } from "./BackId";
43
- import { ProcessId } from "./ProcessId";
44
- import { Selfie } from "./Selfie";
45
- import { ProcessFace } from "./ProcessFace";
46
- import { FinishOnboarding } from "./FinishOnboarding";
47
- import SelectType from "./SelectType";
48
- import { Passport } from "./Passport";
49
37
  import { Box, CircularProgress } from "@mui/material";
50
- import TryAgain from "../../TryAgain";
38
+ import React, { useEffect, useRef, useState } from "react";
51
39
  import berifymeApi, { ActionType } from "../../../api/api";
52
40
  import { createAuthenticationLog, updateAuthenticationLog } from "../../AuthenticationLogs";
53
41
  import { createDeveloperLog } from "../../createDeveloperLog";
42
+ import { BackId } from "./BackId";
43
+ import { FinishOnboarding } from "./FinishOnboarding";
44
+ import { FrontId } from "./FrontId";
45
+ import { Passport } from "./Passport";
46
+ import { ProcessFace } from "./ProcessFace";
54
47
  import { ProcessGlobalWatchlist } from "./processGlobalWatchlist";
48
+ import { ProcessId } from "./ProcessId";
49
+ import SelectType from "./SelectType";
50
+ import { Selfie } from "./Selfie";
51
+ import Steps from "./Steps";
52
+ import { UserConsent } from "./UserConsent";
55
53
  function startOnboardingSession(_a) {
56
54
  return __awaiter(this, arguments, void 0, function (_b) {
57
55
  var res;
@@ -67,20 +65,18 @@ function startOnboardingSession(_a) {
67
65
  });
68
66
  }
69
67
  var IncodeOnBoarding = function (_a) {
70
- var user = _a.user, setUser = _a.setUser, goToAllSet = _a.goToAllSet, token = _a.token;
68
+ var user = _a.user, setUser = _a.setUser, goToAllSet = _a.goToAllSet, token = _a.token, setError = _a.setError, onGoBack = _a.onGoBack;
71
69
  var _b = useState(0), step = _b[0], setStep = _b[1]; // Store the current step
72
- var _c = useState(""), error = _c[0], setError = _c[1];
73
- var _d = useState(null), session = _d[0], setSession = _d[1]; // Stores the Session
70
+ var _c = useState(null), session = _c[0], setSession = _c[1]; // Stores the Session
74
71
  var isLoaded = useRef(false);
75
72
  function finishIncodeOnboarding(id, token, sessionToken) {
76
73
  return __awaiter(this, void 0, void 0, function () {
77
- var incodeRes;
78
- var _a;
79
- return __generator(this, function (_b) {
80
- switch (_b.label) {
74
+ var incodeRes, returnBoolean;
75
+ return __generator(this, function (_a) {
76
+ switch (_a.label) {
81
77
  case 0: return [4 /*yield*/, berifymeApi.incode.getIncodeFinish({ token: token })];
82
78
  case 1:
83
- _b.sent();
79
+ _a.sent();
84
80
  createDeveloperLog({
85
81
  userId: user === null || user === void 0 ? void 0 : user.id,
86
82
  userDataJson: user,
@@ -90,21 +86,24 @@ var IncodeOnBoarding = function (_a) {
90
86
  });
91
87
  return [4 /*yield*/, berifymeApi.incode.getIncodeApprove({ id: id, token: token, sessionToken: sessionToken })];
92
88
  case 2:
93
- incodeRes = _b.sent();
89
+ incodeRes = _a.sent();
94
90
  if (incodeRes.error || !incodeRes.user) {
95
- setError((_a = incodeRes.error) !== null && _a !== void 0 ? _a : '');
96
- return [2 /*return*/, false];
91
+ setError('');
92
+ returnBoolean = false;
93
+ }
94
+ else {
95
+ setUser(incodeRes.user);
96
+ returnBoolean = true;
97
97
  }
98
- setUser(incodeRes.user);
99
98
  createDeveloperLog({
100
99
  userId: user === null || user === void 0 ? void 0 : user.id,
101
100
  userDataJson: user,
102
101
  source: 'FRONTEND',
103
102
  action: 'incode getIncodeApprove',
104
103
  sessionToken: token,
105
- firstDetail: "incode user: ".concat(incodeRes.user, ", error: ").concat(incodeRes.error)
104
+ firstDetail: "incode user: ".concat(incodeRes === null || incodeRes === void 0 ? void 0 : incodeRes.user, ", error: ").concat(incodeRes === null || incodeRes === void 0 ? void 0 : incodeRes.error)
106
105
  });
107
- return [2 /*return*/, true];
106
+ return [2 /*return*/, returnBoolean];
108
107
  }
109
108
  });
110
109
  });
@@ -189,7 +188,7 @@ var IncodeOnBoarding = function (_a) {
189
188
  });
190
189
  }
191
190
  else
192
- setError('Please try again.');
191
+ setError('');
193
192
  _a.label = 2;
194
193
  case 2: return [2 /*return*/];
195
194
  }
@@ -197,10 +196,16 @@ var IncodeOnBoarding = function (_a) {
197
196
  });
198
197
  }
199
198
  function handleError(e) {
200
- setError(e.type);
199
+ createDeveloperLog({
200
+ userId: user === null || user === void 0 ? void 0 : user.id,
201
+ userDataJson: user,
202
+ source: 'FRONTEND',
203
+ action: 'incode handleError',
204
+ sessionToken: token,
205
+ firstDetail: "error: ".concat(e.type)
206
+ });
207
+ setError('');
201
208
  }
202
- if (error)
203
- return (React.createElement(TryAgain, { message: "Authentication Failed, Please Try Again." }));
204
209
  if (!session)
205
210
  return (React.createElement(Box, { sx: {
206
211
  display: 'flex',
@@ -212,7 +217,7 @@ var IncodeOnBoarding = function (_a) {
212
217
  React.createElement(CircularProgress, null)));
213
218
  return (React.createElement(React.Fragment, null, user.id && React.createElement(Steps, { currentStep: step },
214
219
  React.createElement(UserConsent, { session: session, onSuccess: goNext }),
215
- React.createElement(SelectType, { goToID: goNext, goToPassport: function () { goTo(4); } }),
220
+ React.createElement(SelectType, { goToID: goNext, goToPassport: function () { goTo(4); }, onCloseButtonClick: onGoBack }),
216
221
  React.createElement(FrontId, { session: session, onError: handleError, onSuccess: goNext }),
217
222
  React.createElement(BackId, { session: session, onError: handleError, onSuccess: function () { goTo(5); } }),
218
223
  React.createElement(Passport, { session: session, onError: handleError, onSuccess: goNext }),
@@ -87,7 +87,7 @@ var AuthIdGrid = function (_a) {
87
87
  });
88
88
  }); } },
89
89
  React.createElement(Stack, { width: 1, spacing: 1, px: 2, py: 2, bgcolor: theme.palette.grey[100], borderRadius: 6, alignItems: 'center' },
90
- React.createElement("img", { width: 36, height: 36, src: "https://staging.berify.me/berify-title.webp", alt: "berify-title.webp" }),
90
+ React.createElement("img", { width: 36, height: 36, src: "https://idv.berify.me/berify-title.webp", alt: "berify-title.webp" }),
91
91
  React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "Berify.me"),
92
92
  React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 26s completion"))))));
93
93
  };
@@ -7,7 +7,7 @@ var ClearGrid = function (_a) {
7
7
  React.createElement(Grid, { item: true, xs: 6 },
8
8
  React.createElement(Button, { fullWidth: true, onClick: function () { setPageStatus(2.1); } },
9
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: 36, height: 36, src: "https://staging.berify.me/clearme.svg", alt: "clearme.svg" }),
10
+ React.createElement("img", { width: 36, height: 36, src: "https://idv.berify.me/clearme.svg", alt: "clearme.svg" }),
11
11
  React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "CLEAR"),
12
12
  React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 60s completion"))))));
13
13
  };
@@ -7,7 +7,7 @@ var IncodeGrid = function (_a) {
7
7
  React.createElement(Grid, { item: true, xs: 6 },
8
8
  React.createElement(Button, { fullWidth: true, onClick: function () { setPageStatus(2.2); } },
9
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: 36, height: 36, src: "https://staging.berify.me/incode.svg", alt: "incode.svg" }),
10
+ React.createElement("img", { width: 36, height: 36, src: "https://idv.berify.me/incode.svg", alt: "incode.svg" }),
11
11
  React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "Incode"),
12
12
  React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 30s completion"))))));
13
13
  };
@@ -7,7 +7,7 @@ var SumsubGrid = function (_a) {
7
7
  React.createElement(Grid, { item: true, xs: 6 },
8
8
  React.createElement(Button, { fullWidth: true, onClick: function () { setPageStatus(2.3); } },
9
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" }),
10
+ React.createElement("img", { width: 28, height: 28, src: "https://idv.berify.me/sumsub.svg", alt: "scan" }),
11
11
  React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "Sumsub"),
12
12
  React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 30s completion"))))));
13
13
  };
@@ -7,7 +7,7 @@ var VeriffGrid = function (_a) {
7
7
  React.createElement(Grid, { item: true, xs: 6 },
8
8
  React.createElement(Button, { fullWidth: true, onClick: function () { setPageStatus(2.4); } },
9
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" }),
10
+ React.createElement("img", { width: 28, height: 28, src: "https://idv.berify.me/veriff.svg", alt: "scan" }),
11
11
  React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "Veriff"),
12
12
  React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 30s completion"))))));
13
13
  };
@@ -7,7 +7,7 @@ var YotiGrid = function (_a) {
7
7
  React.createElement(Grid, { item: true, xs: 6 },
8
8
  React.createElement(Button, { fullWidth: true, onClick: function () { setPageStatus(2.5); } },
9
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" }),
10
+ React.createElement("img", { width: 28, height: 28, src: "https://idv.berify.me/yoti.svg", alt: "scan" }),
11
11
  React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "Yoti"),
12
12
  React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 30s completion"))))));
13
13
  };
@@ -6,7 +6,7 @@ var QrcodeExpired = function () {
6
6
  return (React.createElement(React.Fragment, null,
7
7
  React.createElement(Stack, { height: 1, spacing: 4, justifyContent: 'space-between', py: 4, overflow: 'auto' },
8
8
  React.createElement(Stack, { spacing: 2, textAlign: 'center', alignItems: 'center' },
9
- React.createElement("img", { width: 60, height: 60, src: "https://staging.berify.me/errorIcon.png", alt: "berify" }),
9
+ React.createElement("img", { width: 60, height: 60, src: "https://idv.berify.me/errorIcon.png", alt: "berify" }),
10
10
  React.createElement(Typography, { variant: "h2", fontWeight: 700 }, "QR Code Expired"),
11
11
  React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "The QR code is only active for 5 minutes."),
12
12
  React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "Return to the original sign up window to request for a new QR code.")),
@@ -42,6 +42,7 @@ import { useState } from 'react';
42
42
  import PhoneInput from 'react-phone-input-2';
43
43
  import './style.css';
44
44
  import berifymeApi, { ActionType } from '../../api/api';
45
+ import { PageStatus } from '../../enum';
45
46
  import theme from "../theme";
46
47
  import { createAuthenticationLog } from '../AuthenticationLogs';
47
48
  import { createDeveloperLog } from '../createDeveloperLog';
@@ -93,7 +94,7 @@ var SendSns = function (_a) {
93
94
  case 1:
94
95
  getVender = _f.sent();
95
96
  if (getVender.error) {
96
- setError((_a = getVender.error) !== null && _a !== void 0 ? _a : 'Oops! Something went wrong...');
97
+ setError((_a = getVender.error) !== null && _a !== void 0 ? _a : 'Something went wrong, but we’re working on it. Please try again later or contact support for assistance.');
97
98
  setIsLoading(false);
98
99
  createDeveloperLog({
99
100
  source: 'FRONTEND',
@@ -129,7 +130,7 @@ var SendSns = function (_a) {
129
130
  })];
130
131
  case 2:
131
132
  webauthnLogin = _f.sent();
132
- if (!webauthnLogin.success) return [3 /*break*/, 5];
133
+ if (!webauthnLogin.success) return [3 /*break*/, 6];
133
134
  createDeveloperLog({
134
135
  userId: (_d = webauthnLogin.user.id) !== null && _d !== void 0 ? _d : '',
135
136
  source: 'FRONTEND',
@@ -138,10 +139,13 @@ var SendSns = function (_a) {
138
139
  userDataJson: webauthnLogin.user,
139
140
  });
140
141
  setUser(webauthnLogin.user);
142
+ return [4 /*yield*/, berifymeApi.wallet.getWallet({ phoneNumber: processedInputValue })];
143
+ case 3:
144
+ _f.sent();
141
145
  deviceId = localStorage.getItem('deviceId');
142
- if (!(deviceId && token)) return [3 /*break*/, 4];
146
+ if (!(deviceId && token)) return [3 /*break*/, 5];
143
147
  return [4 /*yield*/, berifymeApi.user.checkDeviceId({ phoneNumber: processedInputValue, deviceId: deviceId, token: token })];
144
- case 3:
148
+ case 4:
145
149
  deviceUser = _f.sent();
146
150
  if (deviceUser.user) {
147
151
  createDeveloperLog({
@@ -161,7 +165,7 @@ var SendSns = function (_a) {
161
165
  });
162
166
  setUser(deviceUser.user);
163
167
  setModalHeight('60vh');
164
- setPageStatus(10);
168
+ setPageStatus(PageStatus.AllSet);
165
169
  setIsLoading(false);
166
170
  createDeveloperLog({
167
171
  userId: webauthnLogin.user.id,
@@ -181,8 +185,8 @@ var SendSns = function (_a) {
181
185
  firstDetail: deviceUser.error,
182
186
  secondDetail: "deviceId: ".concat(deviceId),
183
187
  });
184
- _f.label = 4;
185
- case 4:
188
+ _f.label = 5;
189
+ case 5:
186
190
  // const blockchainToken = await berifymeApi.blockchain.getNFTToken({ phoneNumber: processedInputValue });
187
191
  // if (blockchainToken && blockchainToken.nfts.length > 0 && token) {
188
192
  // const blockchainTokenId = blockchainToken.nfts[0].tokenId;
@@ -202,30 +206,33 @@ var SendSns = function (_a) {
202
206
  // }
203
207
  // }
204
208
  if (getVender.vender === 'authid') {
205
- setLogin(3);
209
+ setLogin(PageStatus.AuthidLogin);
206
210
  setModalHeight('50vh');
207
211
  setFullName(getVender.fullName);
208
212
  }
209
213
  else if (getVender.vender === 'clear') {
210
- setLogin(4);
214
+ setLogin(PageStatus.ClearLogin);
211
215
  setModalHeight('50vh');
212
216
  setFullName(getVender.fullName);
213
217
  }
214
218
  else if (getVender.vender === 'incode') {
215
- setLogin(5);
216
- setModalHeight('50vh');
217
- setFullName(getVender.fullName);
218
- }
219
- else if (getVender.vender === 'sumsub') {
220
- setLogin(8);
221
- setModalHeight('50vh');
222
- setFullName(getVender.fullName);
223
- }
224
- else if (getVender.vender === 'veriff') {
225
- setLogin(9);
219
+ setLogin(PageStatus.IncodeLogin);
226
220
  setModalHeight('50vh');
227
221
  setFullName(getVender.fullName);
228
222
  }
223
+ // else if (getVender.vender === 'sumsub') {
224
+ // setLogin(PageStatus.SumsubLogin);
225
+ // setModalHeight('50vh');
226
+ // setFullName(getVender.fullName);
227
+ // } else if (getVender.vender === 'veriff') {
228
+ // setLogin(PageStatus.VeriffLogin);
229
+ // setModalHeight('50vh');
230
+ // setFullName(getVender.fullName);
231
+ // } else if (getVender.vender === 'yoti') {
232
+ // setLogin(PageStatus.YotiLogin);
233
+ // setModalHeight('50vh');
234
+ // setFullName(getVender.fullName);
235
+ // }
229
236
  else {
230
237
  setPageStatus(1.1);
231
238
  // const res = await berifymeApi.auth.sendPhoneNumberCode({phoneNumber: processedInputValue, token});
@@ -242,17 +249,17 @@ var SendSns = function (_a) {
242
249
  secondDetail: 'webauthn success'
243
250
  });
244
251
  return [2 /*return*/];
245
- case 5:
252
+ case 6:
246
253
  createDeveloperLog({
247
254
  source: 'FRONTEND',
248
255
  action: 'webauthnLogin failed',
249
256
  sessionToken: token,
250
257
  });
251
- _f.label = 6;
252
- case 6:
253
- if (!(getVender.vender === null)) return [3 /*break*/, 8];
254
- return [4 /*yield*/, berifymeApi.auth.sendPhoneNumberCode({ phoneNumber: processedInputValue, token: token })];
258
+ _f.label = 7;
255
259
  case 7:
260
+ if (!(getVender.vender === null)) return [3 /*break*/, 9];
261
+ return [4 /*yield*/, berifymeApi.auth.sendPhoneNumberCode({ phoneNumber: processedInputValue, token: token })];
262
+ case 8:
256
263
  res = _f.sent();
257
264
  if (res.success) {
258
265
  setPageStatus(1);
@@ -271,9 +278,9 @@ var SendSns = function (_a) {
271
278
  firstDetail: res.error,
272
279
  });
273
280
  }
274
- return [3 /*break*/, 10];
275
- case 8: return [4 /*yield*/, berifymeApi.auth.sendPhoneNumberCode({ phoneNumber: processedInputValue, token: token })];
276
- case 9:
281
+ return [3 /*break*/, 11];
282
+ case 9: return [4 /*yield*/, berifymeApi.auth.sendPhoneNumberCode({ phoneNumber: processedInputValue, token: token })];
283
+ case 10:
277
284
  res = _f.sent();
278
285
  if (res.success) {
279
286
  setModalHeight('50vh');
@@ -293,8 +300,8 @@ var SendSns = function (_a) {
293
300
  firstDetail: res.error,
294
301
  });
295
302
  }
296
- _f.label = 10;
297
- case 10:
303
+ _f.label = 11;
304
+ case 11:
298
305
  setIsLoading(false);
299
306
  createDeveloperLog({
300
307
  source: 'FRONTEND',
@@ -312,10 +319,9 @@ var SendSns = function (_a) {
312
319
  React.createElement(Stack, { height: 1, spacing: 4, justifyContent: 'space-between', py: 8 },
313
320
  React.createElement(Stack, { spacing: 2, textAlign: 'center', alignItems: 'center' },
314
321
  React.createElement(Typography, { variant: "h1" }, "\uD83D\uDC4B"),
315
- React.createElement(Typography, { variant: "h2", fontWeight: 700 },
316
- "Welcome back,",
317
- React.createElement("br", null)),
318
- React.createElement(Typography, { variant: "h2", fontWeight: 700 }, fullName),
322
+ React.createElement(Stack, null,
323
+ React.createElement(Typography, { variant: "h2", fontWeight: 700 }, "Welcome back,"),
324
+ React.createElement(Typography, { variant: "h2", fontWeight: 700 }, fullName)),
319
325
  React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "Take a selfie to verify your identity.")),
320
326
  React.createElement(Stack, { alignItems: 'center' },
321
327
  React.createElement(Button, { variant: "contained", onClick: function () { setPageStatus(login); }, sx: { minWidth: 160 } }, "Take my selfie")),
@@ -6,7 +6,7 @@ var SessionInterrupted = function () {
6
6
  return (React.createElement(React.Fragment, null,
7
7
  React.createElement(Stack, { height: 1, spacing: 4, justifyContent: 'space-between', py: 4, overflow: 'auto' },
8
8
  React.createElement(Stack, { spacing: 2, textAlign: 'center', alignItems: 'center' },
9
- React.createElement("img", { width: 60, height: 60, src: "https://staging.berify.me/warningIcon.png", alt: "berify" }),
9
+ React.createElement("img", { width: 60, height: 60, src: "https://idv.berify.me/warningIcon.png", alt: "berify" }),
10
10
  React.createElement(Typography, { variant: "h2", fontWeight: 700 }, "Session Interrupted"),
11
11
  React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "The sign-up window on your desktop browser was closed."),
12
12
  React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "Please restart the process on your desktop browser to try again.")),
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+ import { Button, Container, Stack, Typography } from "@mui/material";
3
+ import WarningAmberRoundedIcon from "@mui/icons-material/WarningAmberRounded";
4
+ import { getSnapMatchResultTranslations } from "./translations";
5
+ var ExceptionView = function (_a) {
6
+ var lang = _a.lang, message = _a.message, onBack = _a.onBack, _b = _a.returnLoading, returnLoading = _b === void 0 ? false : _b, _c = _a.autoRedirectSeconds, autoRedirectSeconds = _c === void 0 ? 0 : _c, _d = _a.countdown, countdown = _d === void 0 ? 0 : _d;
7
+ var t = getSnapMatchResultTranslations(lang);
8
+ var handleBack = function () {
9
+ if (onBack)
10
+ onBack();
11
+ else
12
+ window.location.reload();
13
+ };
14
+ return (React.createElement(Container, { maxWidth: "sm", sx: { px: 3 } },
15
+ React.createElement(Stack, { height: "100vh", width: 1, maxHeight: 900, justifyContent: "center", alignItems: "center", spacing: 4 },
16
+ React.createElement(WarningAmberRoundedIcon, { sx: { fontSize: 64, color: "warning.main" }, "aria-hidden": true }),
17
+ React.createElement(Typography, { variant: "h3", fontWeight: 700, textAlign: "center", sx: { whiteSpace: "pre-line" } }, t.exceptionTitle),
18
+ React.createElement(Typography, { variant: "body1", color: "text.secondary", textAlign: "center", sx: { whiteSpace: "pre-line" } }, message !== null && message !== void 0 ? message : t.exceptionDescription),
19
+ autoRedirectSeconds > 0 && (React.createElement(Typography, { variant: "body2", color: "text.secondary", sx: { whiteSpace: "pre-line" } }, countdown > 0 ? t.countdownReturn(countdown) : t.redirecting)),
20
+ React.createElement(Button, { variant: "contained", color: "warning", onClick: handleBack, disabled: returnLoading, fullWidth: true, sx: { whiteSpace: "pre-line" } }, returnLoading ? t.redirecting : t.backToVerification))));
21
+ };
22
+ export default ExceptionView;
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import { Box, Button, Typography } from "@mui/material";
3
+ import TranslateIcon from "@mui/icons-material/Translate";
4
+ export var LANG_OPTIONS = [
5
+ { value: "en", label: "English" },
6
+ { value: "zh-TW", label: "繁體中文" },
7
+ ];
8
+ function LangSelector(_a) {
9
+ var _b, _c;
10
+ var lang = _a.lang, onLangChange = _a.onLangChange;
11
+ var nextLang = lang === "en" ? "zh-TW" : "en";
12
+ var currentLabel = (_c = (_b = LANG_OPTIONS.find(function (o) { return o.value === lang; })) === null || _b === void 0 ? void 0 : _b.label) !== null && _c !== void 0 ? _c : lang;
13
+ return (React.createElement(Box, { sx: {
14
+ position: "fixed",
15
+ top: 16,
16
+ right: 16,
17
+ zIndex: 2147483647,
18
+ pointerEvents: "auto",
19
+ } },
20
+ React.createElement(Button, { variant: "outlined", size: "small", onClick: function () { return onLangChange(nextLang); }, startIcon: React.createElement(TranslateIcon, null), sx: {
21
+ bgcolor: "background.paper",
22
+ "&:hover": { bgcolor: "action.hover" },
23
+ } },
24
+ React.createElement(Typography, { variant: "body2" }, currentLabel))));
25
+ }
26
+ export default LangSelector;
@@ -0,0 +1,122 @@
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, { useEffect, useRef } from "react";
38
+ import { Box, CircularProgress } from "@mui/material";
39
+ import { createIncodeLogin } from "../../vender/incode/incode";
40
+ /** 清空容器前先停止所有 video 的 MediaStream,正確釋放相機,避免 reload 後新頁面無法取得相機或卡在權限 */
41
+ function stopAllMediaStreamsInContainer(container) {
42
+ try {
43
+ container.querySelectorAll("video").forEach(function (el) {
44
+ var src = el.srcObject;
45
+ if (src && typeof src.getTracks === "function") {
46
+ src.getTracks().forEach(function (track) { return track.stop(); });
47
+ }
48
+ });
49
+ }
50
+ catch (_a) {
51
+ // ignore
52
+ }
53
+ }
54
+ /**
55
+ * 直接開啟 Incode SnapMatch(1:N)驗證步驟。
56
+ * 與 Frontend SnapMatchStep 對齊:僅依 lang 建立實例並轉發結果,父層負責 getUserByIncodeId 與 step。
57
+ * 以 key={`${lang}-${loginKey}`} 渲染可強制語系切換/返回時完整重掛載,避免 Incode 翻譯 cache。
58
+ */
59
+ var SnapMatchStep = function (_a) {
60
+ var lang = _a.lang, loginKey = _a.loginKey, onSuccess = _a.onSuccess, onError = _a.onError;
61
+ var containerRef = useRef(null);
62
+ var loginKeyRef = useRef(loginKey);
63
+ loginKeyRef.current = loginKey;
64
+ useEffect(function () {
65
+ var container = containerRef.current;
66
+ if (!container)
67
+ return;
68
+ var cancelled = false;
69
+ var currentKey = loginKeyRef.current;
70
+ // 延遲再掛載,讓上一輪 cleanup(清空容器、釋放相機)完成,避免 Incode 全域 i18n/狀態殘留導致翻譯錯亂
71
+ var delayMs = 120;
72
+ var t = setTimeout(function () {
73
+ if (cancelled)
74
+ return;
75
+ void createIncodeLogin(lang).then(function (instance) {
76
+ var _a;
77
+ if (cancelled || !containerRef.current)
78
+ return;
79
+ instance.renderLogin(container, {
80
+ onSuccess: function (response) { return __awaiter(void 0, void 0, void 0, function () {
81
+ return __generator(this, function (_a) {
82
+ if (cancelled)
83
+ return [2 /*return*/];
84
+ onSuccess({
85
+ customerId: response.customerId,
86
+ interviewId: response.interviewId,
87
+ token: response.token,
88
+ transactionId: response.transactionId,
89
+ }, { loginKey: currentKey });
90
+ return [2 /*return*/];
91
+ });
92
+ }); },
93
+ onError: function () {
94
+ if (cancelled)
95
+ return;
96
+ onError();
97
+ },
98
+ stopAtError: true,
99
+ timeout: 1000 * 60 * 60 * 24,
100
+ });
101
+ if ((_a = instance.i18n) === null || _a === void 0 ? void 0 : _a.changeLanguage) {
102
+ setTimeout(function () {
103
+ var _a, _b;
104
+ if (cancelled)
105
+ return;
106
+ void ((_b = (_a = instance.i18n) === null || _a === void 0 ? void 0 : _a.changeLanguage) === null || _b === void 0 ? void 0 : _b.call(_a, "en"));
107
+ }, 200);
108
+ }
109
+ });
110
+ }, delayMs);
111
+ return function () {
112
+ cancelled = true;
113
+ clearTimeout(t);
114
+ stopAllMediaStreamsInContainer(container);
115
+ container.innerHTML = "";
116
+ };
117
+ }, [lang, loginKey, onSuccess, onError]);
118
+ return (React.createElement("div", { ref: containerRef, style: { width: "100%", height: "100%", minHeight: "100vh" } },
119
+ React.createElement(Box, { sx: { display: "flex", justifyContent: "center", alignItems: "center", height: "100vh", background: "#FFFFFF" } },
120
+ React.createElement(CircularProgress, null))));
121
+ };
122
+ export default SnapMatchStep;
@@ -0,0 +1,22 @@
1
+ import React from "react";
2
+ import { Button, Stack, Typography } from "@mui/material";
3
+ import VerifiedRoundedIcon from "@mui/icons-material/VerifiedRounded";
4
+ import Layout from "../Layout";
5
+ import { getSnapMatchResultTranslations } from "./translations";
6
+ import theme from "../theme";
7
+ var SuccessView = function (_a) {
8
+ var lang = _a.lang, fullName = _a.fullName, onContinue = _a.onContinue, _b = _a.returnLoading, returnLoading = _b === void 0 ? false : _b, _c = _a.autoRedirectSeconds, autoRedirectSeconds = _c === void 0 ? 3 : _c, _d = _a.countdown, countdown = _d === void 0 ? 0 : _d;
9
+ var t = getSnapMatchResultTranslations(lang);
10
+ return (React.createElement(Layout, null,
11
+ React.createElement(Stack, { height: 1, width: 1, maxHeight: 900, justifyContent: "center", alignItems: "center", spacing: 4, py: 4 },
12
+ React.createElement(VerifiedRoundedIcon, { color: "success", sx: { fontSize: 64 } }),
13
+ React.createElement(Typography, { variant: "h1", textAlign: "center", sx: { whiteSpace: "pre-line" } },
14
+ fullName ? "\uD83C\uDF89 ".concat(fullName) : "🎉",
15
+ React.createElement("br", null),
16
+ React.createElement("br", null),
17
+ t.successTitle),
18
+ React.createElement(Typography, { variant: "body1", color: theme.palette.info.light, textAlign: "center", sx: { whiteSpace: "pre-line" } }, t.successDescription),
19
+ autoRedirectSeconds > 0 && (React.createElement(Typography, { variant: "body2", color: theme.palette.info.light, sx: { whiteSpace: "pre-line" } }, countdown > 0 ? t.countdownReturn(countdown) : t.redirecting)),
20
+ React.createElement(Button, { variant: "contained", color: "primary", onClick: function () { return (onContinue ? onContinue() : window.close()); }, disabled: returnLoading, fullWidth: true, sx: { whiteSpace: "pre-line" } }, returnLoading ? t.redirecting : t.nextPerson))));
21
+ };
22
+ export default SuccessView;
@@ -0,0 +1,19 @@
1
+ import React from "react";
2
+ import { Button, Container, Stack, Typography } from "@mui/material";
3
+ import { getSnapMatchResultTranslations } from "./translations";
4
+ var TryAgainView = function (_a) {
5
+ var lang = _a.lang, message = _a.message, onRetry = _a.onRetry, _b = _a.retryLoading, retryLoading = _b === void 0 ? false : _b, _c = _a.autoRedirectSeconds, autoRedirectSeconds = _c === void 0 ? 0 : _c, _d = _a.countdown, countdown = _d === void 0 ? 0 : _d;
6
+ var t = getSnapMatchResultTranslations(lang);
7
+ var handleContinue = function () {
8
+ if (onRetry)
9
+ onRetry();
10
+ else
11
+ window.location.reload();
12
+ };
13
+ return (React.createElement(Container, { maxWidth: "sm", sx: { px: 3 } },
14
+ React.createElement(Stack, { height: "100vh", width: 1, maxHeight: 900, justifyContent: "center", alignItems: "center", spacing: 4 },
15
+ React.createElement(Typography, { variant: "h3", fontWeight: 700, textAlign: "center", sx: { whiteSpace: "pre-line" } }, message !== null && message !== void 0 ? message : t.failureDefault),
16
+ autoRedirectSeconds > 0 && (React.createElement(Typography, { variant: "body2", color: "text.secondary", sx: { whiteSpace: "pre-line" } }, countdown > 0 ? t.countdownReturn(countdown) : t.redirecting)),
17
+ React.createElement(Button, { variant: "contained", color: "primary", onClick: handleContinue, disabled: retryLoading, sx: { whiteSpace: "pre-line" } }, retryLoading ? t.redirecting : t.retry))));
18
+ };
19
+ export default TryAgainView;