@bytexbyte/berifyme-react-sdk 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/README.md +20 -0
  2. package/dist/BerifymeModal/MainModal.js +29 -0
  3. package/dist/BerifymeModal/index.js +331 -0
  4. package/dist/api/api.js +1337 -0
  5. package/dist/api/client.js +21 -0
  6. package/dist/api/index.js +96 -0
  7. package/dist/common.js +216 -0
  8. package/dist/components/AllSet/index.js +169 -0
  9. package/dist/components/AuthenticationLogs.js +148 -0
  10. package/dist/components/Clear.js +107 -0
  11. package/dist/components/Footer/index.js +11 -0
  12. package/dist/components/Layout.js +9 -0
  13. package/dist/components/Login/authid/authid.js +196 -0
  14. package/dist/components/Login/authid/index.js +13 -0
  15. package/dist/components/Login/clear.js +35 -0
  16. package/dist/components/Login/clearAllSet.js +96 -0
  17. package/dist/components/Login/incode/Login.js +129 -0
  18. package/dist/components/Login/incode/index.js +16 -0
  19. package/dist/components/OnBoarding/authId/authIdSelectType.js +82 -0
  20. package/dist/components/OnBoarding/authId/idOrPassport.js +30 -0
  21. package/dist/components/OnBoarding/authId/index.js +323 -0
  22. package/dist/components/OnBoarding/clear/clearAllSet.js +118 -0
  23. package/dist/components/OnBoarding/clear/index.js +36 -0
  24. package/dist/components/OnBoarding/incode/BackId.js +25 -0
  25. package/dist/components/OnBoarding/incode/FinishOnboarding.js +26 -0
  26. package/dist/components/OnBoarding/incode/FrontId.js +27 -0
  27. package/dist/components/OnBoarding/incode/Passport.js +27 -0
  28. package/dist/components/OnBoarding/incode/ProcessFace.js +22 -0
  29. package/dist/components/OnBoarding/incode/ProcessId.js +22 -0
  30. package/dist/components/OnBoarding/incode/SelectType.js +68 -0
  31. package/dist/components/OnBoarding/incode/Selfie.js +25 -0
  32. package/dist/components/OnBoarding/incode/Steps.js +7 -0
  33. package/dist/components/OnBoarding/incode/UserConsent.js +30 -0
  34. package/dist/components/OnBoarding/incode/index.js +234 -0
  35. package/dist/components/OnBoarding/vender/grid/authIdGrid.js +94 -0
  36. package/dist/components/OnBoarding/vender/grid/clearGrid.js +14 -0
  37. package/dist/components/OnBoarding/vender/grid/incodeGrid.js +14 -0
  38. package/dist/components/OnBoarding/vender/grid/index.js +118 -0
  39. package/dist/components/OnBoarding/vender/grid/sumsubGrid.js +14 -0
  40. package/dist/components/OnBoarding/vender/grid/veriffGrid.js +14 -0
  41. package/dist/components/OnBoarding/vender/grid/yotiGrid.js +14 -0
  42. package/dist/components/OnBoarding/vender/index.js +123 -0
  43. package/dist/components/RedirectToMobile/index.js +139 -0
  44. package/dist/components/ScreenRotation.js +11 -0
  45. package/dist/components/SendSns/index.js +341 -0
  46. package/dist/components/SendSns/style.css +1 -0
  47. package/dist/components/TryAgain.js +16 -0
  48. package/dist/components/TryAgainInModal.js +15 -0
  49. package/dist/components/VerifyWithPhoneNumber/NewUser/index.js +189 -0
  50. package/dist/components/VerifyWithPhoneNumber/User/index.js +322 -0
  51. package/dist/components/createDeveloperLog.js +60 -0
  52. package/dist/components/phoneNumberProcesser.js +32 -0
  53. package/dist/components/speedTest/SpeedProvider.js +57 -0
  54. package/dist/components/theme.js +120 -0
  55. package/dist/enum/index.js +24 -0
  56. package/dist/index.js +7 -0
  57. package/dist/lib/environmentDomains.js +12 -0
  58. package/dist/lib/webauthb.js +158 -0
  59. package/dist/state.js +23 -0
  60. package/dist/theme.js +120 -0
  61. package/dist/types/BerifymeModal/MainModal.d.ts +7 -0
  62. package/dist/types/BerifymeModal/index.d.ts +12 -0
  63. package/dist/types/api/api.d.ts +606 -0
  64. package/dist/types/api/client.d.ts +2 -0
  65. package/dist/types/api/index.d.ts +16 -0
  66. package/dist/types/common.d.ts +3 -0
  67. package/dist/types/components/AllSet/index.d.ts +8 -0
  68. package/dist/types/components/AuthenticationLogs.d.ts +19 -0
  69. package/dist/types/components/Clear.d.ts +9 -0
  70. package/dist/types/components/Footer/index.d.ts +3 -0
  71. package/dist/types/components/Layout.d.ts +5 -0
  72. package/dist/types/components/Login/authid/authid.d.ts +11 -0
  73. package/dist/types/components/Login/authid/index.d.ts +9 -0
  74. package/dist/types/components/Login/clear.d.ts +7 -0
  75. package/dist/types/components/Login/clearAllSet.d.ts +6 -0
  76. package/dist/types/components/Login/incode/Login.d.ts +13 -0
  77. package/dist/types/components/Login/incode/index.d.ts +9 -0
  78. package/dist/types/components/OnBoarding/authId/authIdSelectType.d.ts +6 -0
  79. package/dist/types/components/OnBoarding/authId/idOrPassport.d.ts +7 -0
  80. package/dist/types/components/OnBoarding/authId/index.d.ts +11 -0
  81. package/dist/types/components/OnBoarding/clear/clearAllSet.d.ts +6 -0
  82. package/dist/types/components/OnBoarding/clear/index.d.ts +8 -0
  83. package/dist/types/components/OnBoarding/incode/BackId.d.ts +11 -0
  84. package/dist/types/components/OnBoarding/incode/FinishOnboarding.d.ts +11 -0
  85. package/dist/types/components/OnBoarding/incode/FrontId.d.ts +10 -0
  86. package/dist/types/components/OnBoarding/incode/Passport.d.ts +10 -0
  87. package/dist/types/components/OnBoarding/incode/ProcessFace.d.ts +11 -0
  88. package/dist/types/components/OnBoarding/incode/ProcessId.d.ts +11 -0
  89. package/dist/types/components/OnBoarding/incode/SelectType.d.ts +6 -0
  90. package/dist/types/components/OnBoarding/incode/Selfie.d.ts +11 -0
  91. package/dist/types/components/OnBoarding/incode/Steps.d.ts +7 -0
  92. package/dist/types/components/OnBoarding/incode/UserConsent.d.ts +8 -0
  93. package/dist/types/components/OnBoarding/incode/index.d.ts +9 -0
  94. package/dist/types/components/OnBoarding/vender/grid/authIdGrid.d.ts +8 -0
  95. package/dist/types/components/OnBoarding/vender/grid/clearGrid.d.ts +5 -0
  96. package/dist/types/components/OnBoarding/vender/grid/incodeGrid.d.ts +5 -0
  97. package/dist/types/components/OnBoarding/vender/grid/index.d.ts +10 -0
  98. package/dist/types/components/OnBoarding/vender/grid/sumsubGrid.d.ts +5 -0
  99. package/dist/types/components/OnBoarding/vender/grid/veriffGrid.d.ts +5 -0
  100. package/dist/types/components/OnBoarding/vender/grid/yotiGrid.d.ts +5 -0
  101. package/dist/types/components/OnBoarding/vender/index.d.ts +9 -0
  102. package/dist/types/components/RedirectToMobile/index.d.ts +7 -0
  103. package/dist/types/components/ScreenRotation.d.ts +3 -0
  104. package/dist/types/components/SendSns/index.d.ts +16 -0
  105. package/dist/types/components/TryAgain.d.ts +6 -0
  106. package/dist/types/components/TryAgainInModal.d.ts +6 -0
  107. package/dist/types/components/VerifyWithPhoneNumber/NewUser/index.d.ts +11 -0
  108. package/dist/types/components/VerifyWithPhoneNumber/User/index.d.ts +13 -0
  109. package/dist/types/components/createDeveloperLog.d.ts +11 -0
  110. package/dist/types/components/phoneNumberProcesser.d.ts +6 -0
  111. package/dist/types/components/speedTest/SpeedProvider.d.ts +9 -0
  112. package/dist/types/components/theme.d.ts +9 -0
  113. package/dist/types/enum/index.d.ts +22 -0
  114. package/dist/types/index.d.ts +12 -0
  115. package/dist/types/lib/environmentDomains.d.ts +7 -0
  116. package/dist/types/lib/webauthb.d.ts +18 -0
  117. package/dist/types/state.d.ts +11 -0
  118. package/dist/types/theme.d.ts +9 -0
  119. package/dist/types/vender/incode/incode.d.ts +8 -0
  120. package/dist/vender/incode/incode.js +13 -0
  121. package/index.css +52 -0
  122. package/package.json +49 -0
  123. package/public/US-UK_Add_to_Apple_Wallet_RGB_101421.svg +259 -0
  124. package/public/berify-title.webp +0 -0
  125. package/public/clearme.svg +39 -0
  126. package/public/idme.svg +13 -0
  127. package/public/incode.svg +9 -0
  128. package/public/scan.svg +8 -0
  129. package/public/trackablehealth-one-logo-1024x229.jpg +0 -0
@@ -0,0 +1,27 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { incode } from "../../../vender/incode/incode";
3
+ import React from "react";
4
+ var FrontId = function (_a) {
5
+ var session = _a.session, onSuccess = _a.onSuccess, onError = _a.onError;
6
+ var containerRef = useRef(null);
7
+ var isMounted = useRef(false);
8
+ useEffect(function () {
9
+ if (isMounted.current) {
10
+ return;
11
+ }
12
+ incode.renderCamera("front", containerRef.current, {
13
+ onSuccess: function () {
14
+ onSuccess();
15
+ },
16
+ onError: function () { return onError({ type: "Couldn't Capture FrontId" }); },
17
+ token: session,
18
+ numberOfTries: 3,
19
+ showTutorial: false,
20
+ showCustomCameraPermissionScreen: true,
21
+ showDoublePermissionsRequest: true,
22
+ });
23
+ isMounted.current = true;
24
+ }, [session, onSuccess, onError]);
25
+ return React.createElement("div", { ref: containerRef });
26
+ };
27
+ export { FrontId };
@@ -0,0 +1,27 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { incode } from "../../../vender/incode/incode";
3
+ import React from "react";
4
+ var Passport = function (_a) {
5
+ var session = _a.session, onSuccess = _a.onSuccess, onError = _a.onError;
6
+ var containerRef = useRef(null);
7
+ var isMounted = useRef(false);
8
+ useEffect(function () {
9
+ if (isMounted.current) {
10
+ return;
11
+ }
12
+ incode.renderCamera("passport", containerRef.current, {
13
+ onSuccess: function () {
14
+ onSuccess();
15
+ },
16
+ onError: function () { return onError({ type: "Couldn't Capture FrontId" }); },
17
+ token: session,
18
+ numberOfTries: 3,
19
+ showTutorial: false,
20
+ showCustomCameraPermissionScreen: true,
21
+ showDoublePermissionsRequest: true,
22
+ });
23
+ isMounted.current = true;
24
+ }, [session, onSuccess, onError]);
25
+ return React.createElement("div", { ref: containerRef });
26
+ };
27
+ export { Passport };
@@ -0,0 +1,22 @@
1
+ import { useEffect } from "react";
2
+ import { incode } from "../../../vender/incode/incode";
3
+ import React from "react";
4
+ import { Box, CircularProgress } from "@mui/material";
5
+ function ProcessFace(_a) {
6
+ var session = _a.session, onSuccess = _a.onSuccess, onError = _a.onError;
7
+ useEffect(function () {
8
+ void incode.processFace({ token: session.token }).then(function () {
9
+ onSuccess();
10
+ }).catch(function (error) {
11
+ onError({ type: error });
12
+ });
13
+ }, [session, onSuccess, onError]);
14
+ return React.createElement(Box, { sx: {
15
+ display: 'flex',
16
+ justifyContent: 'center',
17
+ alignItems: 'center',
18
+ height: '100vh'
19
+ } },
20
+ React.createElement(CircularProgress, null));
21
+ }
22
+ export { ProcessFace };
@@ -0,0 +1,22 @@
1
+ import { useEffect } from "react";
2
+ import { incode } from "../../../vender/incode/incode";
3
+ import React from "react";
4
+ import { Box, CircularProgress } from "@mui/material";
5
+ function ProcessId(_a) {
6
+ var session = _a.session, onSuccess = _a.onSuccess, onError = _a.onError;
7
+ useEffect(function () {
8
+ void incode.processId({ token: session.token }).then(function () {
9
+ onSuccess();
10
+ }).catch(function (error) {
11
+ onError({ type: error });
12
+ });
13
+ }, [session, onSuccess, onError]);
14
+ return React.createElement(Box, { sx: {
15
+ display: 'flex',
16
+ justifyContent: 'center',
17
+ alignItems: 'center',
18
+ height: '100vh'
19
+ } },
20
+ React.createElement(CircularProgress, null));
21
+ }
22
+ export { ProcessId };
@@ -0,0 +1,68 @@
1
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
2
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
3
+ return new (P || (P = Promise))(function (resolve, reject) {
4
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
5
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
6
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
7
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
8
+ });
9
+ };
10
+ var __generator = (this && this.__generator) || function (thisArg, body) {
11
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
12
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
13
+ function verb(n) { return function (v) { return step([n, v]); }; }
14
+ function step(op) {
15
+ if (f) throw new TypeError("Generator is already executing.");
16
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
17
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
18
+ if (y = 0, t) op = [op[0] & 2, t.value];
19
+ switch (op[0]) {
20
+ case 0: case 1: t = op; break;
21
+ case 4: _.label++; return { value: op[1], done: false };
22
+ case 5: _.label++; y = op[1]; op = [0]; continue;
23
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
24
+ default:
25
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
26
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
27
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
28
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
29
+ if (t[2]) _.ops.pop();
30
+ _.trys.pop(); continue;
31
+ }
32
+ op = body.call(thisArg, _);
33
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
34
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
35
+ }
36
+ };
37
+ import { Button, Stack, Typography } from "@mui/material";
38
+ import Layout from "../../Layout";
39
+ import React from "react";
40
+ var SelectType = function (_a) {
41
+ var goToID = _a.goToID, goToPassport = _a.goToPassport;
42
+ return (React.createElement(React.Fragment, null,
43
+ React.createElement(Layout, null,
44
+ React.createElement(Stack, { minHeight: 1, width: 1, spacing: 4, maxHeight: 900, py: 20, justifyContent: 'space-between' },
45
+ React.createElement(Stack, { spacing: 2 },
46
+ React.createElement(Stack, { spacing: 1, textAlign: 'center' },
47
+ React.createElement(Typography, { variant: "h3", fontWeight: 700 }, "Select what document you want to scan"))),
48
+ React.createElement(Stack, { spacing: 2, alignItems: 'center' },
49
+ React.createElement(Button, { fullWidth: true, sx: { p: 2, maxWidth: 200 }, variant: "contained", color: 'secondary', onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
50
+ return __generator(this, function (_a) {
51
+ goToID();
52
+ return [2 /*return*/];
53
+ });
54
+ }); } },
55
+ React.createElement(Stack, { direction: 'row', alignItems: 'center', spacing: 2 },
56
+ React.createElement(Stack, { spacing: 1 },
57
+ React.createElement(Typography, { variant: "h5", fontWeight: 700 }, "ID")))),
58
+ React.createElement(Button, { fullWidth: true, sx: { p: 2, maxWidth: 200 }, variant: "contained", color: 'secondary', onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
59
+ return __generator(this, function (_a) {
60
+ goToPassport();
61
+ return [2 /*return*/];
62
+ });
63
+ }); } },
64
+ React.createElement(Stack, { direction: 'row', alignItems: 'center', spacing: 2 },
65
+ React.createElement(Stack, { spacing: 1 },
66
+ React.createElement(Typography, { variant: "h5", fontWeight: 700 }, "Passport")))))))));
67
+ };
68
+ export default SelectType;
@@ -0,0 +1,25 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { incode } from "../../../vender/incode/incode";
3
+ import React from "react";
4
+ function Selfie(_a) {
5
+ var session = _a.session, onSuccess = _a.onSuccess, onError = _a.onError;
6
+ var containerRef = useRef(null);
7
+ var isMounted = useRef(false);
8
+ useEffect(function () {
9
+ if (isMounted.current) {
10
+ return;
11
+ }
12
+ incode.renderCamera("selfie", containerRef.current, {
13
+ onSuccess: onSuccess,
14
+ onError: function () { return onError({ type: "Couldn't Capture Selfie" }); },
15
+ token: session,
16
+ numberOfTries: 3,
17
+ showTutorial: false,
18
+ showCustomCameraPermissionScreen: true,
19
+ showDoublePermissionsRequest: true,
20
+ });
21
+ isMounted.current = true;
22
+ }, [session, onSuccess, onError]);
23
+ return React.createElement("div", { ref: containerRef });
24
+ }
25
+ export { Selfie };
@@ -0,0 +1,7 @@
1
+ import React from "react";
2
+ import { Children, cloneElement } from "react";
3
+ function Steps(_a) {
4
+ var children = _a.children, currentStep = _a.currentStep;
5
+ return (React.createElement(React.Fragment, null, Children.map(children, function (child, index) { return currentStep === index && cloneElement(child); })));
6
+ }
7
+ export default Steps;
@@ -0,0 +1,30 @@
1
+ import { useEffect, useRef } from "react";
2
+ import { incode } from "../../../vender/incode/incode";
3
+ import React from "react";
4
+ import { useSpeedTest } from "../../speedTest/SpeedProvider";
5
+ function UserConsent(_a) {
6
+ var session = _a.session, onSuccess = _a.onSuccess;
7
+ var containerRef = useRef(null);
8
+ var isMounted = useRef(false);
9
+ var stopSpeedTest = useSpeedTest().stopSpeedTest;
10
+ useEffect(function () { stopSpeedTest(); }, []);
11
+ useEffect(function () {
12
+ function captureAndContinue() {
13
+ // Now that the user consented, we can ask for this data
14
+ // Optional but valuable for fraud prevention, hurts conversion
15
+ // incode.sendFingerprint(session);
16
+ // incode.sendGeolocation(session);
17
+ onSuccess();
18
+ }
19
+ if (isMounted.current) {
20
+ return;
21
+ }
22
+ incode.renderUserConsent(containerRef.current, {
23
+ onSuccess: function () { captureAndContinue(); },
24
+ session: session,
25
+ });
26
+ isMounted.current = true;
27
+ }, [session, onSuccess]);
28
+ return React.createElement("div", { ref: containerRef });
29
+ }
30
+ export { UserConsent };
@@ -0,0 +1,234 @@
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 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
+ import { Box, CircularProgress } from "@mui/material";
50
+ import TryAgain from "../../TryAgain";
51
+ import berifymeApi, { ActionType } from "../../../api/api";
52
+ import { createAuthenticationLog, updateAuthenticationLog } from "../../AuthenticationLogs";
53
+ import { createDeveloperLog } from "../../createDeveloperLog";
54
+ function startOnboardingSession(uniqueId) {
55
+ return __awaiter(this, void 0, void 0, function () {
56
+ var res;
57
+ return __generator(this, function (_a) {
58
+ switch (_a.label) {
59
+ case 0: return [4 /*yield*/, berifymeApi.incode.getIncodeStart(uniqueId)];
60
+ case 1:
61
+ res = _a.sent();
62
+ return [2 /*return*/, res];
63
+ }
64
+ });
65
+ });
66
+ }
67
+ var IncodeOnBoarding = function (_a) {
68
+ var user = _a.user, setUser = _a.setUser, goToAllSet = _a.goToAllSet, token = _a.token;
69
+ var _b = useState(0), step = _b[0], setStep = _b[1]; // Store the current step
70
+ var _c = useState(""), error = _c[0], setError = _c[1];
71
+ var _d = useState(null), session = _d[0], setSession = _d[1]; // Stores the Session
72
+ var isLoaded = useRef(false);
73
+ function finishIncodeOnboarding(id, token, uniqueId) {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var incodeRes, res;
76
+ var _a, _b;
77
+ return __generator(this, function (_c) {
78
+ switch (_c.label) {
79
+ case 0: return [4 /*yield*/, berifymeApi.incode.getIncodeFinish({ token: token })];
80
+ case 1:
81
+ _c.sent();
82
+ createDeveloperLog({
83
+ userId: user === null || user === void 0 ? void 0 : user.id,
84
+ userDataJson: user,
85
+ source: 'FRONTEND',
86
+ action: 'incode Onboarding getIncodeFinish',
87
+ sessionToken: token,
88
+ });
89
+ return [4 /*yield*/, berifymeApi.incode.getIncodeApprove({ id: id, token: token, uniqueId: uniqueId })];
90
+ case 2:
91
+ incodeRes = _c.sent();
92
+ createDeveloperLog({
93
+ userId: user === null || user === void 0 ? void 0 : user.id,
94
+ userDataJson: user,
95
+ source: 'FRONTEND',
96
+ action: 'incode getIncodeApprove',
97
+ sessionToken: token,
98
+ firstDetail: "incodeId: ".concat(incodeRes.incodeId, ", error: ").concat(incodeRes.error)
99
+ });
100
+ if (incodeRes.error || !incodeRes.incodeId) {
101
+ setError((_a = incodeRes.error) !== null && _a !== void 0 ? _a : '');
102
+ return [2 /*return*/, false];
103
+ }
104
+ return [4 /*yield*/, berifymeApi.user.getUserByIncodeId(incodeRes.incodeId)];
105
+ case 3:
106
+ res = _c.sent();
107
+ createDeveloperLog({
108
+ userId: (_b = res.user) === null || _b === void 0 ? void 0 : _b.id,
109
+ userDataJson: res.user,
110
+ source: 'FRONTEND',
111
+ action: 'incode getUserByIncodeId',
112
+ sessionToken: token,
113
+ firstDetail: "error: ".concat(incodeRes.error)
114
+ });
115
+ if (!res.user)
116
+ return [2 /*return*/, false];
117
+ setUser(res.user);
118
+ return [2 /*return*/, true];
119
+ }
120
+ });
121
+ });
122
+ }
123
+ function getUrlParams() {
124
+ var searchParams = new URLSearchParams(window.location.search);
125
+ return {
126
+ uniqueId: searchParams.get('uniqueId') || '',
127
+ };
128
+ }
129
+ useEffect(function () {
130
+ if (isLoaded.current)
131
+ return;
132
+ var res = getUrlParams();
133
+ startOnboardingSession(res.uniqueId)
134
+ .then(function (session) { return __awaiter(void 0, void 0, void 0, function () {
135
+ return __generator(this, function (_a) {
136
+ setSession(session);
137
+ if (token) {
138
+ createDeveloperLog({
139
+ userId: user === null || user === void 0 ? void 0 : user.id,
140
+ userDataJson: user,
141
+ source: 'FRONTEND',
142
+ action: 'incode startOnboardingSession',
143
+ sessionToken: token,
144
+ firstDetail: session.interviewId,
145
+ });
146
+ createAuthenticationLog({
147
+ actionType: ActionType.ONBOARDING,
148
+ userId: user.id,
149
+ vender: 'incode',
150
+ token: token,
151
+ incodeSessionId: session.interviewId,
152
+ });
153
+ }
154
+ return [2 /*return*/];
155
+ });
156
+ }); })
157
+ .catch(function (e) { return console.log(e); });
158
+ isLoaded.current = true;
159
+ }, []);
160
+ function goNext() {
161
+ console.log('step: ', step + 1);
162
+ setStep(step + 1);
163
+ createDeveloperLog({
164
+ userId: user === null || user === void 0 ? void 0 : user.id,
165
+ userDataJson: user,
166
+ source: 'FRONTEND',
167
+ action: 'incode step',
168
+ sessionToken: token,
169
+ firstDetail: (step + 1).toString(),
170
+ });
171
+ }
172
+ function goTo(stepToGo) {
173
+ console.log('step go to: ', stepToGo);
174
+ setStep(stepToGo);
175
+ createDeveloperLog({
176
+ userId: user === null || user === void 0 ? void 0 : user.id,
177
+ userDataJson: user,
178
+ source: 'FRONTEND',
179
+ action: 'incode step',
180
+ sessionToken: token,
181
+ firstDetail: stepToGo.toString(),
182
+ });
183
+ }
184
+ function finishOnboarding() {
185
+ return __awaiter(this, void 0, void 0, function () {
186
+ var success;
187
+ return __generator(this, function (_a) {
188
+ switch (_a.label) {
189
+ case 0:
190
+ if (!(session && session.uniqueId)) return [3 /*break*/, 2];
191
+ return [4 /*yield*/, finishIncodeOnboarding(user.id, session.token, session.uniqueId)];
192
+ case 1:
193
+ success = _a.sent();
194
+ if (success) {
195
+ goToAllSet();
196
+ updateAuthenticationLog({
197
+ isPass: true,
198
+ incodeSessionId: session.interviewId,
199
+ });
200
+ }
201
+ else
202
+ setError('Please try again.');
203
+ _a.label = 2;
204
+ case 2: return [2 /*return*/];
205
+ }
206
+ });
207
+ });
208
+ }
209
+ function handleError(e) {
210
+ setError(e.type);
211
+ }
212
+ if (error)
213
+ return (React.createElement(TryAgain, null));
214
+ if (!session)
215
+ return (React.createElement(Box, { sx: {
216
+ display: 'flex',
217
+ justifyContent: 'center',
218
+ alignItems: 'center',
219
+ height: '100vh',
220
+ background: '#FFFFFF'
221
+ } },
222
+ React.createElement(CircularProgress, null)));
223
+ return (React.createElement(React.Fragment, null, user.id && React.createElement(Steps, { currentStep: step },
224
+ React.createElement(UserConsent, { session: session, onSuccess: goNext }),
225
+ React.createElement(SelectType, { goToID: goNext, goToPassport: function () { goTo(4); } }),
226
+ React.createElement(FrontId, { session: session, onError: handleError, onSuccess: goNext }),
227
+ React.createElement(BackId, { session: session, onError: handleError, onSuccess: function () { goTo(5); } }),
228
+ React.createElement(Passport, { session: session, onError: handleError, onSuccess: goNext }),
229
+ React.createElement(ProcessId, { session: session, onError: handleError, onSuccess: goNext }),
230
+ React.createElement(Selfie, { session: session, onError: handleError, onSuccess: goNext }),
231
+ React.createElement(ProcessFace, { session: session, onError: handleError, onSuccess: goNext }),
232
+ React.createElement(FinishOnboarding, { session: session, onError: handleError, onSuccess: finishOnboarding }))));
233
+ };
234
+ export { IncodeOnBoarding };
@@ -0,0 +1,94 @@
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 from "react";
38
+ import { Button, Grid, Stack, Typography } from "@mui/material";
39
+ import berifymeApi from "../../../../api/api";
40
+ import theme from "../../../theme";
41
+ var AuthIdGrid = function (_a) {
42
+ var setPageStatus = _a.setPageStatus, setError = _a.setError, user = _a.user;
43
+ var getAuthIdAccountDetail = function () { return __awaiter(void 0, void 0, void 0, function () {
44
+ var account;
45
+ var _a;
46
+ return __generator(this, function (_b) {
47
+ switch (_b.label) {
48
+ case 0: return [4 /*yield*/, berifymeApi.authID.getAccount({ token: localStorage.getItem('authID_token') || '', phone: (_a = user === null || user === void 0 ? void 0 : user.phoneNumber) !== null && _a !== void 0 ? _a : '' })];
49
+ case 1:
50
+ account = _b.sent();
51
+ return [2 /*return*/, account];
52
+ }
53
+ });
54
+ }); };
55
+ return (React.createElement(React.Fragment, null,
56
+ React.createElement(Grid, { item: true, xs: 6 },
57
+ React.createElement(Button, { fullWidth: true, onClick: function () { return __awaiter(void 0, void 0, void 0, function () {
58
+ var authIdTokenRes, account;
59
+ return __generator(this, function (_a) {
60
+ switch (_a.label) {
61
+ case 0: return [4 /*yield*/, berifymeApi.authID.getAuthIDToken()];
62
+ case 1:
63
+ authIdTokenRes = _a.sent();
64
+ if (!authIdTokenRes.token) {
65
+ setError('Auth id error');
66
+ return [2 /*return*/];
67
+ }
68
+ if (!user) {
69
+ setError('User error');
70
+ return [2 /*return*/];
71
+ }
72
+ return [4 /*yield*/, getAuthIdAccountDetail()];
73
+ case 2:
74
+ account = _a.sent();
75
+ if (!(account.error === 'User data not found.')) return [3 /*break*/, 4];
76
+ return [4 /*yield*/, berifymeApi.authID.createAccount({ token: authIdTokenRes.token || '', userId: user.id })];
77
+ case 3:
78
+ _a.sent();
79
+ localStorage.setItem('authID_token', authIdTokenRes.token);
80
+ setPageStatus(1.2);
81
+ return [3 /*break*/, 5];
82
+ case 4:
83
+ setError('User error');
84
+ _a.label = 5;
85
+ case 5: return [2 /*return*/];
86
+ }
87
+ });
88
+ }); } },
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" }),
91
+ React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "Berify.me"),
92
+ React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 26s completion"))))));
93
+ };
94
+ export default AuthIdGrid;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { Button, Grid, Stack, Typography } from "@mui/material";
3
+ import theme from "../../../theme";
4
+ var ClearGrid = function (_a) {
5
+ var setPageStatus = _a.setPageStatus;
6
+ return (React.createElement(React.Fragment, null,
7
+ React.createElement(Grid, { item: true, xs: 6 },
8
+ React.createElement(Button, { fullWidth: true, onClick: function () { setPageStatus(2.1); } },
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" }),
11
+ React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "CLEAR"),
12
+ React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 60s completion"))))));
13
+ };
14
+ export default ClearGrid;
@@ -0,0 +1,14 @@
1
+ import React from "react";
2
+ import { Button, Grid, Stack, Typography } from "@mui/material";
3
+ import theme from "../../../theme";
4
+ var IncodeGrid = function (_a) {
5
+ var setPageStatus = _a.setPageStatus;
6
+ return (React.createElement(React.Fragment, null,
7
+ React.createElement(Grid, { item: true, xs: 6 },
8
+ React.createElement(Button, { fullWidth: true, onClick: function () { setPageStatus(2.2); } },
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" }),
11
+ React.createElement(Typography, { variant: 'h5', fontWeight: 700, color: 'black' }, "Incode"),
12
+ React.createElement(Typography, { variant: 'body2', color: theme.palette.info.light, fontStyle: 'italic' }, "avg. 30s completion"))))));
13
+ };
14
+ export default IncodeGrid;