@bytexbyte/berifyme-react-sdk 1.0.3 → 1.0.5

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.
@@ -34,38 +34,35 @@ 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 { environmentDomains } from '../lib/environmentDomains';
38
- import { PageStatus } from '../enum';
39
37
  import { Box, CircularProgress, CssBaseline, ThemeProvider } from '@mui/material';
40
38
  import React, { useEffect, useState } from 'react';
41
- import theme from '../components/theme';
39
+ import '../../index.css';
42
40
  import berifymeApi, { initializeBerifymeApi } from '../api/api';
43
- import { incode } from '../vender/incode/incode';
44
41
  import AllSet from '../components/AllSet';
45
- import Modal from './MainModal';
46
- import RedirectToMobile from '../components/RedirectToMobile';
47
- import ScreenRotation from '../components/ScreenRotation';
48
- import TryAgainInModal from '../components/TryAgainInModal';
49
42
  import { createDeveloperLog } from '../components/createDeveloperLog';
50
43
  import { AuthidLogin } from '../components/Login/authid';
51
44
  import { ClearLogin } from '../components/Login/clear';
52
45
  import { ClearLoginAllSet } from '../components/Login/clearAllSet';
53
46
  import { IncodeLogin } from '../components/Login/incode';
54
- //[Wings] import SumsubLogin from './login/sumsub';
55
- //[Wings] import VeriffLogin from './login/veriff';
56
47
  import AuthID from '../components/OnBoarding/authId';
57
48
  import IdOrPassport from '../components/OnBoarding/authId/idOrPassport';
58
49
  import { ClearOnboarding } from '../components/OnBoarding/clear';
59
50
  import { ClearOnboardingAllSet } from '../components/OnBoarding/clear/clearAllSet';
60
51
  import { IncodeOnBoarding } from '../components/OnBoarding/incode';
61
- //[Wings] import SumsubOnBoarding from './onBoarding/sumsub';
62
52
  import Vender from '../components/OnBoarding/vender';
63
- //[Wings] import VeriffOnBoarding from './onBoarding/veriff';
64
- //[Wings] import YotiOnBoarding from './onBoarding/yoti';
53
+ import RedirectToMobile from '../components/RedirectToMobile';
54
+ import ScreenRotation from '../components/ScreenRotation';
65
55
  import SendSns from '../components/SendSns';
56
+ import theme from '../components/theme';
57
+ import TryAgainInModal from '../components/TryAgainInModal';
66
58
  import VerifyNewUser from '../components/VerifyWithPhoneNumber/NewUser';
67
59
  import VerifyUser from '../components/VerifyWithPhoneNumber/User';
68
- import '../../index.css';
60
+ import { PageStatus } from '../enum';
61
+ import { environmentDomains } from '../lib/environmentDomains';
62
+ import { incode } from '../vender/incode/incode';
63
+ import Modal from './MainModal';
64
+ import QrcodeExpired from '../components/QrcodeExpired';
65
+ import SessionInterrupted from '../components/SessionInterrupted';
69
66
  var HomeModal = function (_a) {
70
67
  var apiKeyId = _a.apiKeyId, secretKey = _a.secretKey, redirectUrl = _a.redirectUrl, _b = _a.initialPhoneNumber, initialPhoneNumber = _b === void 0 ? '' : _b, environment = _a.environment, forceQrcode = _a.forceQrcode;
71
68
  var _c = useState(window.innerWidth > window.innerHeight), isLandscape = _c[0], setIsLandscape = _c[1];
@@ -156,6 +153,25 @@ var HomeModal = function (_a) {
156
153
  });
157
154
  });
158
155
  }
156
+ function checkDesktopRedirectUrlIdExpired(_a) {
157
+ return __awaiter(this, arguments, void 0, function (_b) {
158
+ var res;
159
+ var token = _b.token, desktopRedirectUrlId = _b.desktopRedirectUrlId;
160
+ return __generator(this, function (_c) {
161
+ switch (_c.label) {
162
+ case 0: return [4 /*yield*/, berifymeApi.thirdParty.checkDesktopRedirectUrlIdExpired({ token: token, desktopRedirectUrlId: desktopRedirectUrlId })];
163
+ case 1:
164
+ res = _c.sent();
165
+ console.log('checkDesktopRedirectUrlIdExpired', res.error);
166
+ if (res.error)
167
+ setPageStatus(PageStatus.QRCodeExpired);
168
+ else
169
+ setPageStatus(PageStatus.SendSns);
170
+ return [2 /*return*/];
171
+ }
172
+ });
173
+ });
174
+ }
159
175
  useEffect(function () {
160
176
  if (incode.isDesktop() || forceQrcode) {
161
177
  setUseQrcode(true);
@@ -181,18 +197,24 @@ var HomeModal = function (_a) {
181
197
  // } else {
182
198
  // setError('Token is required to access this page. Please include a valid token in the URL.');
183
199
  // }
184
- //處理desktop
185
- if (res.desktopRedirectUrlId)
200
+ // 若params有desktopRedirectUrlId, 就設定useState
201
+ if (res.desktopRedirectUrlId) {
186
202
  setDesktopRedirectUrlId(res.desktopRedirectUrlId);
203
+ }
187
204
  // 確定是否為clear callback onboarding or login,是就轉導致對應頁面
205
+ // 然後如果有desktopRedirectUrlId, 檢查有沒有過期, 有就去QrCodeExpired頁面, 沒有就去SendSns
206
+ // 如果沒有desktopRedirectUrlId就照流程去SendSns
188
207
  if (res.callback === 'clear_login') {
189
208
  setPageStatus(6);
190
209
  }
191
210
  else if (res.callback === 'clear_onboarding') {
192
211
  setPageStatus(7);
193
212
  }
213
+ else if (res.desktopRedirectUrlId) {
214
+ checkDesktopRedirectUrlIdExpired({ token: res.token, desktopRedirectUrlId: res.desktopRedirectUrlId });
215
+ }
194
216
  else {
195
- setPageStatus(0);
217
+ setPageStatus(PageStatus.SendSns);
196
218
  }
197
219
  }, []);
198
220
  useEffect(function () {
@@ -221,60 +243,51 @@ var HomeModal = function (_a) {
221
243
  else if (isLandscape) {
222
244
  setModalHeight('100vh');
223
245
  }
224
- else if (pageStatus === 0) {
246
+ else if (pageStatus === PageStatus.SendSns) {
225
247
  setModalHeight('58vh');
226
248
  }
227
- else if (pageStatus === 1) {
249
+ else if (pageStatus === PageStatus.QRCodeExpired) {
250
+ setModalHeight('46vh');
251
+ }
252
+ else if (pageStatus === PageStatus.VerifyNewUser) {
228
253
  setModalHeight('64vh');
229
254
  }
230
- else if (pageStatus === 2) {
231
- setModalHeight('90vh');
255
+ else if (pageStatus === PageStatus.AuthIdOnboarding) {
256
+ setModalHeight('100vh');
232
257
  }
233
- else if (pageStatus === 4) {
258
+ else if (pageStatus === PageStatus.ClearLogin) {
234
259
  setModalHeight('100vh');
235
260
  }
236
- else if (pageStatus === 5) {
261
+ else if (pageStatus === PageStatus.IncodeLogin) {
237
262
  setModalHeight('100vh');
238
263
  }
239
- else if (pageStatus === 6) {
264
+ else if (pageStatus === PageStatus.ClearLoginAllSet) {
240
265
  setModalHeight('58vh');
241
266
  }
242
- else if (pageStatus === 7) {
267
+ else if (pageStatus === PageStatus.ClearOnboardingAllSet) {
243
268
  setModalHeight('58vh');
244
269
  }
245
- else if (pageStatus === 8) {
270
+ else if (pageStatus === PageStatus.Vender) {
246
271
  setModalHeight('80vh');
247
272
  }
248
- else if (pageStatus === 9) {
249
- setModalHeight('100vh');
250
- }
251
- else if (pageStatus === 1.1) {
252
- setModalHeight('80vh');
253
- }
254
- else if (pageStatus === 1.2) {
273
+ else if (pageStatus === PageStatus.IdOrPassport) {
255
274
  setModalHeight('55vh');
256
275
  }
257
- else if (pageStatus === 1.5) {
276
+ else if (pageStatus === PageStatus.VerifyUser) {
258
277
  setModalHeight('46vh');
259
278
  }
260
- else if (pageStatus === 2.1) {
279
+ else if (pageStatus === PageStatus.ClearOnboarding) {
261
280
  setModalHeight('100vh');
262
281
  }
263
- else if (pageStatus === 2.2) {
282
+ else if (pageStatus === PageStatus.IncodeOnBoarding) {
264
283
  setModalHeight('100vh');
265
284
  }
266
- else if (pageStatus === 2.3) {
267
- setModalHeight('80vh');
268
- }
269
- else if (pageStatus === 2.4) {
270
- setModalHeight('100vh');
271
- }
272
- else if (pageStatus === 2.5) {
273
- setModalHeight('80vh');
274
- }
275
- else if (pageStatus === 10) {
285
+ else if (pageStatus === PageStatus.AllSet) {
276
286
  setModalHeight('58vh');
277
287
  }
288
+ else if (pageStatus === PageStatus.SessionInterrupted) {
289
+ setModalHeight('46vh');
290
+ }
278
291
  else {
279
292
  setModalHeight('80vh');
280
293
  }
@@ -307,6 +320,10 @@ var HomeModal = function (_a) {
307
320
  background: '#FFFFFF'
308
321
  } },
309
322
  React.createElement(CircularProgress, null)),
323
+ pageStatus === PageStatus.SessionInterrupted &&
324
+ React.createElement(SessionInterrupted, null),
325
+ pageStatus === PageStatus.QRCodeExpired &&
326
+ React.createElement(QrcodeExpired, null),
310
327
  pageStatus === PageStatus.SendSns &&
311
328
  React.createElement(SendSns, { token: token, inputValue: inputValue, setInputValue: setInputValue, setError: setError, setPageStatus: setPageStatus, setProcessedPhoneNumber: setProcessedPhoneNumber, setModalHeight: setModalHeight, setUser: setUser, environment: environment }),
312
329
  pageStatus === PageStatus.VerifyNewUser &&
@@ -318,22 +335,22 @@ var HomeModal = function (_a) {
318
335
  pageStatus === PageStatus.VerifyUser &&
319
336
  React.createElement(VerifyUser, { token: token, inputValue: inputValue, setError: setError, setPageStatus: setPageStatus, setModalHeight: setModalHeight, setUser: setUser, environment: environment }),
320
337
  pageStatus === PageStatus.AuthIdOnboarding && user &&
321
- React.createElement(AuthID, { token: token, goToAllSet: function () { return setPageStatus(10); }, setError: setError, userId: user.id, setUser: setUser, selectedIdType: authIdSelectedIdType }),
338
+ React.createElement(AuthID, { token: token, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); }, setError: setError, userId: user.id, setUser: setUser, selectedIdType: authIdSelectedIdType, setSelectedIdType: setAuthIdSelectedIdType, setPageStatus: setPageStatus }),
322
339
  pageStatus === PageStatus.ClearOnboarding && user &&
323
340
  React.createElement(ClearOnboarding, { token: token, user: user, desktopRedirectUrlId: desktopRedirectUrlId }),
324
341
  pageStatus === PageStatus.IncodeOnBoarding && user &&
325
- React.createElement(IncodeOnBoarding, { user: user, setUser: setUser, token: token, goToAllSet: function () { return setPageStatus(10); } }),
342
+ React.createElement(IncodeOnBoarding, { user: user, setUser: setUser, token: token, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); } }),
326
343
  pageStatus === PageStatus.AuthidLogin && processedPhoneNumber &&
327
- React.createElement(AuthidLogin, { token: token, goToAllSet: function () { return setPageStatus(10); }, phoneNumber: processedPhoneNumber, setUser: setUser }),
344
+ React.createElement(AuthidLogin, { token: token, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); }, phoneNumber: processedPhoneNumber, setUser: setUser }),
328
345
  pageStatus === PageStatus.ClearLogin &&
329
346
  React.createElement(ClearLogin, { token: token, userId: user === null || user === void 0 ? void 0 : user.id, desktopRedirectUrlId: desktopRedirectUrlId }),
330
347
  pageStatus === PageStatus.IncodeLogin &&
331
- React.createElement(IncodeLogin, { token: token, user: user, setUser: setUser, goToAllSet: function () { return setPageStatus(10); } }),
348
+ React.createElement(IncodeLogin, { token: token, user: user, setUser: setUser, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); } }),
332
349
  pageStatus === PageStatus.ClearLoginAllSet &&
333
- React.createElement(ClearLoginAllSet, { token: token, desktopRedirectUrlId: desktopRedirectUrlId }),
350
+ React.createElement(ClearLoginAllSet, { token: token, desktopRedirectUrlId: desktopRedirectUrlId, setPageStatus: setPageStatus }),
334
351
  pageStatus === PageStatus.ClearOnboardingAllSet &&
335
- React.createElement(ClearOnboardingAllSet, { token: token, desktopRedirectUrlId: desktopRedirectUrlId }),
352
+ React.createElement(ClearOnboardingAllSet, { token: token, desktopRedirectUrlId: desktopRedirectUrlId, setPageStatus: setPageStatus }),
336
353
  pageStatus === PageStatus.AllSet &&
337
- React.createElement(AllSet, { user: user, token: token, desktopRedirectUrlId: desktopRedirectUrlId })))))))));
354
+ React.createElement(AllSet, { user: user, token: token, desktopRedirectUrlId: desktopRedirectUrlId, setPageStatus: setPageStatus })))))))));
338
355
  };
339
356
  export default HomeModal;
package/dist/api/api.js CHANGED
@@ -558,6 +558,29 @@ function checkThirdPartyVerificationToken(token) {
558
558
  });
559
559
  });
560
560
  }
561
+ function checkDesktopRedirectUrlIdExpired(_a) {
562
+ return __awaiter(this, arguments, void 0, function (_b) {
563
+ var url, res;
564
+ var token = _b.token, desktopRedirectUrlId = _b.desktopRedirectUrlId;
565
+ return __generator(this, function (_c) {
566
+ switch (_c.label) {
567
+ case 0:
568
+ url = "".concat(config.backendDomain, "/api/thirdParty/checkDesktopRedirectUrlIdExpired?desktopRedirectUrlId=").concat(desktopRedirectUrlId);
569
+ console.log('UrlString: ', url);
570
+ return [4 /*yield*/, axios.get(url, {
571
+ headers: {
572
+ 'Content-Type': 'application/json',
573
+ 'token': token,
574
+ }
575
+ })];
576
+ case 1:
577
+ res = _c.sent();
578
+ console.log('UrlRes data: ', res.data);
579
+ return [2 /*return*/, res.data];
580
+ }
581
+ });
582
+ });
583
+ }
561
584
  function sendVerifyEmail(email) {
562
585
  return __awaiter(this, void 0, void 0, function () {
563
586
  var url, res;
@@ -1292,6 +1315,7 @@ var berifymeApi = {
1292
1315
  thirdParty: {
1293
1316
  getRedirectUrl: getRedirectUrl,
1294
1317
  checkThirdPartyVerificationToken: checkThirdPartyVerificationToken,
1318
+ checkDesktopRedirectUrlIdExpired: checkDesktopRedirectUrlIdExpired,
1295
1319
  },
1296
1320
  scheduld: {
1297
1321
  initUpdateAdminTokenSchedule: initUpdateAdminTokenSchedule,
@@ -44,6 +44,7 @@ import { useEffect, useState } from "react";
44
44
  import TryAgain from "../TryAgain";
45
45
  import { v4 as uuidv4 } from 'uuid';
46
46
  import { createDeveloperLog } from "../createDeveloperLog";
47
+ import { PageStatus } from "../../enum";
47
48
  var createDeviceId = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
48
49
  var newDeviceId;
49
50
  var userId = _b.userId;
@@ -62,7 +63,7 @@ var createDeviceId = function (_a) { return __awaiter(void 0, [_a], void 0, func
62
63
  });
63
64
  }); };
64
65
  var AllSet = function (_a) {
65
- var user = _a.user, token = _a.token, desktopRedirectUrlId = _a.desktopRedirectUrlId;
66
+ var user = _a.user, token = _a.token, desktopRedirectUrlId = _a.desktopRedirectUrlId, setPageStatus = _a.setPageStatus;
66
67
  var _b = useState(''), error = _b[0], setError = _b[1];
67
68
  var _c = useState(), desktopStatusMessage = _c[0], setDesktopStatusMessage = _c[1];
68
69
  var _d = useState(true), loading = _d[0], setLoading = _d[1];
@@ -137,11 +138,11 @@ var AllSet = function (_a) {
137
138
  if (desktopRedirectUrlId === undefined) {
138
139
  setRedirectUrl(res.redirectUrl);
139
140
  }
141
+ else if (res.heartbeatStopped) {
142
+ setPageStatus(PageStatus.SessionInterrupted);
143
+ }
140
144
  else {
141
- if (res.heartbeatStopped)
142
- setDesktopStatusMessage('Session interrupted. Please retry.');
143
- else
144
- setDesktopStatusMessage('ID verification successful. Continue on your PC.');
145
+ setDesktopStatusMessage('Return to the original window to be redirected to the next page');
145
146
  }
146
147
  return [2 /*return*/];
147
148
  }
@@ -161,24 +162,21 @@ var AllSet = function (_a) {
161
162
  background: '#FFFFFF'
162
163
  } },
163
164
  React.createElement(CircularProgress, null)) :
164
- React.createElement(React.Fragment, null, desktopStatusMessage ?
165
- React.createElement(Stack, { height: 1, justifyContent: "center", alignItems: "center" },
166
- React.createElement(Stack, { alignItems: "center", spacing: 2 },
167
- React.createElement("img", { width: 40, height: 40, src: "https://staging.berify.me/berify.svg", alt: "berify" }),
168
- React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, desktopStatusMessage)))
169
- :
170
- React.createElement(Stack, { height: 1, spacing: 4, justifyContent: 'space-between', py: 4, overflow: 'auto' },
171
- React.createElement(Stack, { spacing: 2, textAlign: 'center', alignItems: 'center' },
172
- React.createElement("img", { width: 40, height: 40, src: "https://staging.berify.me/berify.svg", alt: "berify" }),
173
- React.createElement(Typography, { variant: "h2", fontWeight: 700 },
174
- "You\u2019re Berified,",
175
- React.createElement("br", null), user === null || user === void 0 ? void 0 :
176
- user.fullName),
177
- React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "Thank you for securely verifying your identity through Berify.me \uD83C\uDF89")),
178
- React.createElement(Stack, { spacing: 2, alignItems: 'center' },
179
- React.createElement(Button, { variant: "contained", onClick: function () { window.location.href = redirectUrl; }, sx: { minWidth: 160 } }, "Continue")),
180
- React.createElement(Stack, { direction: 'row', spacing: 2, textAlign: 'center', justifyContent: 'center', color: theme.palette.text.secondary },
181
- React.createElement(GppGoodOutlinedIcon, null),
182
- React.createElement(Typography, { variant: "body1" }, "Securely powered by Berify.me")))))));
165
+ React.createElement(Stack, { height: 1, spacing: 4, justifyContent: 'space-between', py: 4, overflow: 'auto' },
166
+ React.createElement(Stack, { spacing: 2, textAlign: 'center', alignItems: 'center' },
167
+ React.createElement("img", { width: 40, height: 40, src: "https://staging.berify.me/berify.svg", alt: "berify" }),
168
+ React.createElement(Typography, { variant: "h2", fontWeight: 700 },
169
+ "You\u2019re Berified,",
170
+ React.createElement("br", null), user === null || user === void 0 ? void 0 :
171
+ user.fullName),
172
+ React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "Thank you for securely verifying your identity through Berify.me \uD83C\uDF89")),
173
+ desktopStatusMessage ?
174
+ React.createElement(Stack, { py: 4, textAlign: 'center', alignItems: 'center' },
175
+ React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, desktopStatusMessage)) :
176
+ React.createElement(Stack, { spacing: 2, alignItems: 'center' },
177
+ React.createElement(Button, { variant: "contained", onClick: function () { window.location.href = redirectUrl; }, sx: { minWidth: 160 } }, "Continue")),
178
+ React.createElement(Stack, { direction: 'row', spacing: 2, textAlign: 'center', justifyContent: 'center', color: theme.palette.text.secondary },
179
+ React.createElement(GppGoodOutlinedIcon, null),
180
+ React.createElement(Typography, { variant: "body1" }, "Securely powered by Berify.me"))))));
183
181
  };
184
182
  export default AllSet;
@@ -43,7 +43,7 @@ import TryAgain from "../TryAgain";
43
43
  import { updateAuthenticationLog } from "../AuthenticationLogs";
44
44
  import { createDeveloperLog } from "../createDeveloperLog";
45
45
  var ClearLoginAllSet = function (_a) {
46
- var token = _a.token, desktopRedirectUrlId = _a.desktopRedirectUrlId;
46
+ var token = _a.token, desktopRedirectUrlId = _a.desktopRedirectUrlId, setPageStatus = _a.setPageStatus;
47
47
  var _b = useState(), user = _b[0], setUser = _b[1]; // berifyme user
48
48
  var _c = useState(), error = _c[0], setError = _c[1];
49
49
  var getUserBySessionId = function (sessionId) { return __awaiter(void 0, void 0, void 0, function () {
@@ -83,7 +83,7 @@ var ClearLoginAllSet = function (_a) {
83
83
  }, []);
84
84
  if (error)
85
85
  return (React.createElement(TryAgain, { message: error }));
86
- return (React.createElement(React.Fragment, null, user ? React.createElement(AllSet, { user: user, token: token, desktopRedirectUrlId: desktopRedirectUrlId }) :
86
+ return (React.createElement(React.Fragment, null, user ? React.createElement(AllSet, { user: user, token: token, desktopRedirectUrlId: desktopRedirectUrlId, setPageStatus: setPageStatus }) :
87
87
  React.createElement(Box, { sx: {
88
88
  display: 'flex',
89
89
  justifyContent: 'center',
@@ -40,13 +40,15 @@ import { useEffect, useState } from "react";
40
40
  import berifymeApi from "../../../api/api";
41
41
  import theme from "../../theme";
42
42
  var AuthIdSelectType = function (_a) {
43
- var setSelectedIdType = _a.setSelectedIdType, setError = _a.setError;
43
+ var setSelectedIdType = _a.setSelectedIdType, setError = _a.setError, setPageStatus = _a.setPageStatus;
44
44
  var _b = useState([]), idTypes = _b[0], setIdTypes = _b[1];
45
45
  var initTypeButton = function () { return __awaiter(void 0, void 0, void 0, function () {
46
46
  var result, documentTypes, filteredDocuments;
47
47
  return __generator(this, function (_a) {
48
48
  switch (_a.label) {
49
- case 0: return [4 /*yield*/, berifymeApi.authID.getIdDocumentTypes({ token: localStorage.getItem('authID_token') || '' })];
49
+ case 0:
50
+ setSelectedIdType('');
51
+ return [4 /*yield*/, berifymeApi.authID.getIdDocumentTypes({ token: localStorage.getItem('authID_token') || '' })];
50
52
  case 1:
51
53
  result = _a.sent();
52
54
  if (result.error) {
@@ -73,10 +75,12 @@ var AuthIdSelectType = function (_a) {
73
75
  console.log(idTypes);
74
76
  }, [idTypes]);
75
77
  return (React.createElement(Stack, { spacing: 2, alignItems: 'center' },
76
- idTypes[0] && React.createElement(Button, { fullWidth: true, sx: { p: 2, maxWidth: 200, bgcolor: theme.palette.secondary.dark }, variant: "contained", color: 'secondary', onClick: function () { return setSelectedIdType(idTypes[0].Name); } },
78
+ idTypes[0] && React.createElement(Button, { fullWidth: true, sx: { p: 2, maxWidth: 200, bgcolor: theme.palette.secondary.dark }, variant: "contained", color: 'secondary', onClick: function () { if (setPageStatus)
79
+ setPageStatus(-1); setSelectedIdType(idTypes[0].Name); } },
77
80
  React.createElement(Typography, { variant: "h5", fontWeight: 700 }, "Upload ID")),
78
81
  idTypes[1] && React.createElement(Typography, { variant: "h5", fontWeight: 700, color: theme.palette.text.secondary }, "OR"),
79
- idTypes[1] && React.createElement(Button, { fullWidth: true, sx: { p: 2, maxWidth: 200, bgcolor: theme.palette.secondary.dark }, variant: "contained", color: 'secondary', onClick: function () { return setSelectedIdType(idTypes[1].Name); } },
82
+ idTypes[1] && React.createElement(Button, { fullWidth: true, sx: { p: 2, maxWidth: 200, bgcolor: theme.palette.secondary.dark }, variant: "contained", color: 'secondary', onClick: function () { if (setPageStatus)
83
+ setPageStatus(-1); setSelectedIdType(idTypes[1].Name); } },
80
84
  React.createElement(Typography, { variant: "h5", fontWeight: 700 }, "Upload Passport"))));
81
85
  };
82
86
  export default AuthIdSelectType;
@@ -47,16 +47,20 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
47
47
  };
48
48
  import React from "react";
49
49
  import AuthIDComponent from "@authid/react-component";
50
- import { Box, CircularProgress } from "@mui/material";
51
- import { useEffect, useState } from "react";
50
+ import { Box, CircularProgress, Stack, Typography } from "@mui/material";
51
+ import { useEffect, useRef, useState } from "react";
52
52
  import berifymeApi, { ActionType } from "../../../api/api";
53
53
  import { useSpeedTest } from "../../speedTest/SpeedProvider";
54
54
  import { createAuthenticationLog, updateAuthenticationLog } from "../../AuthenticationLogs";
55
55
  import { createDeveloperLog } from "../../createDeveloperLog";
56
+ import AuthIdSelectType from "./authIdSelectType";
57
+ import theme from "../../../theme";
56
58
  var AuthID = function (_a) {
57
- var goToAllSet = _a.goToAllSet, setError = _a.setError, userId = _a.userId, setUser = _a.setUser, selectedIdType = _a.selectedIdType, token = _a.token;
59
+ var goToAllSet = _a.goToAllSet, setError = _a.setError, userId = _a.userId, setUser = _a.setUser, selectedIdType = _a.selectedIdType, setSelectedIdType = _a.setSelectedIdType, token = _a.token, setPageStatus = _a.setPageStatus;
58
60
  var _b = useState(''), operationId = _b[0], setOperationId = _b[1];
59
61
  var _c = useState(''), url = _c[0], setUrl = _c[1];
62
+ var _d = useState(false), showIdOrPassport = _d[0], setShowIdOrPassport = _d[1];
63
+ var docErrorCount = useRef(0);
60
64
  var stopSpeedTest = useSpeedTest().stopSpeedTest;
61
65
  useEffect(function () { stopSpeedTest(); }, []);
62
66
  //第零部 準備URL
@@ -283,8 +287,11 @@ var AuthID = function (_a) {
283
287
  });
284
288
  }); };
285
289
  //初始與監聽
286
- useEffect(function () { if (selectedIdType !== '')
287
- proofUser(); }, [selectedIdType]);
290
+ useEffect(function () {
291
+ docErrorCount.current = 0;
292
+ if (selectedIdType !== '')
293
+ proofUser();
294
+ }, [selectedIdType]);
288
295
  useEffect(function () {
289
296
  if (url) {
290
297
  window.addEventListener('message', function (e) {
@@ -295,6 +302,13 @@ var AuthID = function (_a) {
295
302
  getProofTransactionStatus();
296
303
  }, 1000);
297
304
  }
305
+ if (e.data.pageName === 'documentFailedPage') {
306
+ docErrorCount.current += 1;
307
+ if (docErrorCount.current >= 3) {
308
+ setShowIdOrPassport(true);
309
+ }
310
+ }
311
+ console.log('e.data.pageName: ', e.data.pageName);
298
312
  }
299
313
  });
300
314
  }
@@ -309,15 +323,30 @@ var AuthID = function (_a) {
309
323
  });
310
324
  };
311
325
  }, [url]);
312
- return (React.createElement(React.Fragment, null, React.createElement(React.Fragment, null, url
313
- ? React.createElement(AuthIDComponent, { url: url, webauth: true })
314
- : React.createElement(Box, { sx: {
315
- display: 'flex',
316
- justifyContent: 'center',
317
- alignItems: 'center',
318
- height: '100vh',
319
- background: '#FFFFFF'
320
- } },
321
- React.createElement(CircularProgress, null)))));
326
+ useEffect(function () {
327
+ console.log('error count: ', docErrorCount.current);
328
+ }, [docErrorCount.current]);
329
+ return (React.createElement(React.Fragment, null,
330
+ url ?
331
+ React.createElement(AuthIDComponent, { url: url, webauth: true })
332
+ : React.createElement(Box, { sx: {
333
+ display: 'flex',
334
+ justifyContent: 'center',
335
+ alignItems: 'center',
336
+ height: '100vh',
337
+ background: '#FFFFFF'
338
+ } },
339
+ React.createElement(CircularProgress, null)),
340
+ showIdOrPassport &&
341
+ React.createElement(Box, { sx: {
342
+ position: 'fixed',
343
+ bottom: 0, left: 0,
344
+ width: '100%', height: '36%',
345
+ background: '#fff', textAlign: 'center',
346
+ padding: '16px', zIndex: 1000, // 确保覆盖其他内容
347
+ } },
348
+ React.createElement(Stack, { spacing: 3, height: 1, justifyContent: 'center' },
349
+ React.createElement(Typography, { variant: "body1", sx: { fontWeight: 'bold' }, color: theme.palette.text.secondary }, "Having trouble?"),
350
+ React.createElement(AuthIdSelectType, { setSelectedIdType: setSelectedIdType, setError: setError, setPageStatus: setPageStatus })))));
322
351
  };
323
352
  export default AuthID;
@@ -43,7 +43,7 @@ import TryAgain from "../../TryAgain";
43
43
  import { updateAuthenticationLog } from "../../AuthenticationLogs";
44
44
  import { createDeveloperLog } from "../../createDeveloperLog";
45
45
  var ClearOnboardingAllSet = function (_a) {
46
- var token = _a.token, desktopRedirectUrlId = _a.desktopRedirectUrlId;
46
+ var token = _a.token, desktopRedirectUrlId = _a.desktopRedirectUrlId, setPageStatus = _a.setPageStatus;
47
47
  var _b = useState(), user = _b[0], setUser = _b[1]; // berifyme user
48
48
  var _c = useState(), error = _c[0], setError = _c[1];
49
49
  var approve = function (_a) { return __awaiter(void 0, [_a], void 0, function (_b) {
@@ -105,7 +105,7 @@ var ClearOnboardingAllSet = function (_a) {
105
105
  }, []);
106
106
  if (error)
107
107
  return (React.createElement(TryAgain, { message: error }));
108
- return (React.createElement(React.Fragment, null, user ? React.createElement(AllSet, { user: user, token: token, desktopRedirectUrlId: desktopRedirectUrlId }) :
108
+ return (React.createElement(React.Fragment, null, user ? React.createElement(AllSet, { user: user, token: token, desktopRedirectUrlId: desktopRedirectUrlId, setPageStatus: setPageStatus }) :
109
109
  React.createElement(Box, { sx: {
110
110
  display: 'flex',
111
111
  justifyContent: 'center',
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { Stack, Typography } from "@mui/material";
3
+ import theme from "../theme";
4
+ import GppGoodOutlinedIcon from '@mui/icons-material/GppGoodOutlined';
5
+ var QrcodeExpired = function () {
6
+ return (React.createElement(React.Fragment, null,
7
+ React.createElement(Stack, { height: 1, spacing: 4, justifyContent: 'space-between', py: 4, overflow: 'auto' },
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" }),
10
+ React.createElement(Typography, { variant: "h2", fontWeight: 700 }, "QR Code Expired"),
11
+ React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "The QR code is only active for 5 minutes."),
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.")),
13
+ React.createElement(Stack, { direction: 'row', spacing: 2, textAlign: 'center', justifyContent: 'center', color: theme.palette.text.secondary },
14
+ React.createElement(GppGoodOutlinedIcon, null),
15
+ React.createElement(Typography, { variant: "body1" }, "Securely powered by Berify.me")))));
16
+ };
17
+ export default QrcodeExpired;
@@ -0,0 +1,17 @@
1
+ import React from "react";
2
+ import { Stack, Typography } from "@mui/material";
3
+ import theme from "../theme";
4
+ import GppGoodOutlinedIcon from '@mui/icons-material/GppGoodOutlined';
5
+ var SessionInterrupted = function () {
6
+ return (React.createElement(React.Fragment, null,
7
+ React.createElement(Stack, { height: 1, spacing: 4, justifyContent: 'space-between', py: 4, overflow: 'auto' },
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" }),
10
+ React.createElement(Typography, { variant: "h2", fontWeight: 700 }, "Session Interrupted"),
11
+ React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "The sign-up window on your desktop browser was closed."),
12
+ React.createElement(Typography, { variant: "body1", color: theme.palette.text.secondary }, "Please restart the process on your desktop browser to try again.")),
13
+ React.createElement(Stack, { direction: 'row', spacing: 2, textAlign: 'center', justifyContent: 'center', color: theme.palette.text.secondary },
14
+ React.createElement(GppGoodOutlinedIcon, null),
15
+ React.createElement(Typography, { variant: "body1" }, "Securely powered by Berify.me")))));
16
+ };
17
+ export default SessionInterrupted;
@@ -6,6 +6,8 @@ export var Environment;
6
6
  })(Environment || (Environment = {}));
7
7
  export var PageStatus;
8
8
  (function (PageStatus) {
9
+ PageStatus[PageStatus["SessionInterrupted"] = -3] = "SessionInterrupted";
10
+ PageStatus[PageStatus["QRCodeExpired"] = -2] = "QRCodeExpired";
9
11
  PageStatus[PageStatus["Loading"] = -1] = "Loading";
10
12
  PageStatus[PageStatus["SendSns"] = 0] = "SendSns";
11
13
  PageStatus[PageStatus["VerifyNewUser"] = 1] = "VerifyNewUser";
@@ -1,6 +1,6 @@
1
- import { Environment } from '../enum';
2
1
  import React from 'react';
3
2
  import '../../index.css';
3
+ import { Environment } from '../enum';
4
4
  declare const HomeModal: React.FC<{
5
5
  apiKeyId: string;
6
6
  secretKey: string;
@@ -275,6 +275,12 @@ declare function checkThirdPartyVerificationToken(token: string): Promise<{
275
275
  companyName?: string | null;
276
276
  error?: string;
277
277
  }>;
278
+ declare function checkDesktopRedirectUrlIdExpired({ token, desktopRedirectUrlId }: {
279
+ token: string;
280
+ desktopRedirectUrlId: string;
281
+ }): Promise<{
282
+ error?: string;
283
+ }>;
278
284
  declare function sendVerifyEmail(email: string): Promise<{
279
285
  success: boolean;
280
286
  error?: string;
@@ -561,6 +567,7 @@ declare const berifymeApi: {
561
567
  thirdParty: {
562
568
  getRedirectUrl: typeof getRedirectUrl;
563
569
  checkThirdPartyVerificationToken: typeof checkThirdPartyVerificationToken;
570
+ checkDesktopRedirectUrlIdExpired: typeof checkDesktopRedirectUrlIdExpired;
564
571
  };
565
572
  scheduld: {
566
573
  initUpdateAdminTokenSchedule: typeof initUpdateAdminTokenSchedule;
@@ -1,8 +1,9 @@
1
1
  import React from "react";
2
2
  import { User } from "../../api/api";
3
- declare const AllSet: ({ user, token, desktopRedirectUrlId }: {
3
+ declare const AllSet: ({ user, token, desktopRedirectUrlId, setPageStatus }: {
4
4
  user: User | undefined;
5
5
  token: string | undefined;
6
6
  desktopRedirectUrlId?: string;
7
+ setPageStatus: React.Dispatch<React.SetStateAction<number>>;
7
8
  }) => React.JSX.Element;
8
9
  export default AllSet;
@@ -2,5 +2,6 @@ import React from "react";
2
2
  declare const ClearLoginAllSet: React.FC<{
3
3
  token?: string;
4
4
  desktopRedirectUrlId?: string;
5
+ setPageStatus: React.Dispatch<React.SetStateAction<number>>;
5
6
  }>;
6
7
  export { ClearLoginAllSet };
@@ -1,6 +1,7 @@
1
1
  import React from "react";
2
- declare const AuthIdSelectType: ({ setSelectedIdType, setError, }: {
2
+ declare const AuthIdSelectType: ({ setSelectedIdType, setError, setPageStatus, }: {
3
3
  setSelectedIdType: React.Dispatch<React.SetStateAction<string>>;
4
4
  setError: React.Dispatch<React.SetStateAction<string | undefined>>;
5
+ setPageStatus?: React.Dispatch<React.SetStateAction<number>>;
5
6
  }) => React.JSX.Element;
6
7
  export default AuthIdSelectType;
@@ -1,11 +1,13 @@
1
1
  import React from "react";
2
2
  import { UserWithAgeAndFullName } from "../../../api/api";
3
- declare const AuthID: ({ goToAllSet, setError, userId, setUser, selectedIdType, token }: {
3
+ declare const AuthID: ({ goToAllSet, setError, userId, setUser, selectedIdType, setSelectedIdType, token, setPageStatus }: {
4
4
  goToAllSet: () => void;
5
5
  setError: React.Dispatch<React.SetStateAction<string | undefined>>;
6
6
  userId: string;
7
7
  setUser?: React.Dispatch<React.SetStateAction<UserWithAgeAndFullName | undefined>>;
8
8
  selectedIdType: string;
9
+ setSelectedIdType: React.Dispatch<React.SetStateAction<string>>;
9
10
  token?: string;
11
+ setPageStatus?: React.Dispatch<React.SetStateAction<number>>;
10
12
  }) => React.JSX.Element;
11
13
  export default AuthID;
@@ -2,5 +2,6 @@ import React from "react";
2
2
  declare const ClearOnboardingAllSet: React.FC<{
3
3
  token?: string;
4
4
  desktopRedirectUrlId?: string;
5
+ setPageStatus: React.Dispatch<React.SetStateAction<number>>;
5
6
  }>;
6
7
  export { ClearOnboardingAllSet };
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const QrcodeExpired: () => React.JSX.Element;
3
+ export default QrcodeExpired;
@@ -0,0 +1,3 @@
1
+ import React from "react";
2
+ declare const SessionInterrupted: () => React.JSX.Element;
3
+ export default SessionInterrupted;
@@ -4,6 +4,8 @@ export declare enum Environment {
4
4
  Idv = "idv"
5
5
  }
6
6
  export declare enum PageStatus {
7
+ SessionInterrupted = -3,
8
+ QRCodeExpired = -2,
7
9
  Loading = -1,
8
10
  SendSns = 0,
9
11
  VerifyNewUser = 1,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytexbyte/berifyme-react-sdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",
@@ -8,7 +8,8 @@
8
8
  "test": "echo \"Error: no test specified\" && exit 1",
9
9
  "build": "tsc && copyfiles -u 1 'src/**/*.{css,svg}' dist",
10
10
  "webpack": "webpack",
11
- "esbuild": "node esbuild.config.js"
11
+ "esbuild": "node esbuild.config.js",
12
+ "release": "yarn build && npm publish"
12
13
  },
13
14
  "keywords": [],
14
15
  "author": "",