@bytexbyte/berifyme-react-sdk 1.0.9 → 1.0.10

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.
@@ -345,7 +345,7 @@ var HomeModal = function (_a) {
345
345
  pageStatus === PageStatus.ClearLogin &&
346
346
  React.createElement(ClearLogin, { token: token, userId: user === null || user === void 0 ? void 0 : user.id, desktopRedirectUrlId: desktopRedirectUrlId }),
347
347
  pageStatus === PageStatus.IncodeLogin &&
348
- React.createElement(IncodeLogin, { token: token, user: user, setUser: setUser, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); } }),
348
+ React.createElement(IncodeLogin, { token: token, setError: setError, user: user, setUser: setUser, goToAllSet: function () { return setPageStatus(PageStatus.AllSet); } }),
349
349
  pageStatus === PageStatus.ClearLoginAllSet &&
350
350
  React.createElement(ClearLoginAllSet, { token: token, desktopRedirectUrlId: desktopRedirectUrlId, setPageStatus: setPageStatus }),
351
351
  pageStatus === PageStatus.ClearOnboardingAllSet &&
package/dist/api/api.js CHANGED
@@ -214,11 +214,11 @@ function createBiometricFromProof(_a) {
214
214
  function getAccount(_a) {
215
215
  return __awaiter(this, arguments, void 0, function (_b) {
216
216
  var url, res;
217
- var token = _b.token, phone = _b.phone;
217
+ var token = _b.token, phone = _b.phone, sessionToken = _b.sessionToken;
218
218
  return __generator(this, function (_c) {
219
219
  switch (_c.label) {
220
220
  case 0:
221
- url = "".concat(config.backendDomain, "/api/authid/getAccount?phone=").concat(phone);
221
+ url = "".concat(config.backendDomain, "/api/authid/getAccount?phone=").concat(phone).concat(sessionToken ? "&sessionToken=".concat(sessionToken) : '');
222
222
  return [4 /*yield*/, axios.get(url, {
223
223
  headers: {
224
224
  'Content-Type': 'application/json',
@@ -319,11 +319,11 @@ function searchUser(_a) {
319
319
  function getDocumentDetails(_a) {
320
320
  return __awaiter(this, arguments, void 0, function (_b) {
321
321
  var url, res;
322
- var token = _b.token, operationId = _b.operationId, userId = _b.userId;
322
+ var token = _b.token, operationId = _b.operationId, userId = _b.userId, sessionToken = _b.sessionToken;
323
323
  return __generator(this, function (_c) {
324
324
  switch (_c.label) {
325
325
  case 0:
326
- url = "".concat(config.backendDomain, "/api/authid/getDocumentDetails?operationId=").concat(operationId, "&userId=").concat(userId);
326
+ url = "".concat(config.backendDomain, "/api/authid/getDocumentDetails?operationId=").concat(operationId, "&userId=").concat(userId).concat(sessionToken ? "&sessionToken=".concat(sessionToken) : '');
327
327
  return [4 /*yield*/, axios.get(url, {
328
328
  headers: {
329
329
  'Content-Type': 'application/json',
@@ -395,11 +395,11 @@ function getIncodeFinish(_a) {
395
395
  function getIncodeApprove(_a) {
396
396
  return __awaiter(this, arguments, void 0, function (_b) {
397
397
  var url, res;
398
- var id = _b.id, token = _b.token, uniqueId = _b.uniqueId;
398
+ var id = _b.id, token = _b.token, sessionToken = _b.sessionToken;
399
399
  return __generator(this, function (_c) {
400
400
  switch (_c.label) {
401
401
  case 0:
402
- url = "".concat(config.backendDomain, "/api/incode/approve?id=").concat(id, "&token=").concat(token, "&uniqueId=").concat(uniqueId);
402
+ url = "".concat(config.backendDomain, "/api/incode/approve?id=").concat(id, "&token=").concat(token, "&sessionToken=").concat(sessionToken);
403
403
  console.log('UrlString: ', url);
404
404
  return [4 /*yield*/, axios.get(url)];
405
405
  case 1:
@@ -531,31 +531,14 @@ function getUserBySessionId(_a) {
531
531
  });
532
532
  });
533
533
  }
534
- function getUserByIncodeId(incodeId) {
535
- return __awaiter(this, void 0, void 0, function () {
536
- var url, res;
537
- return __generator(this, function (_a) {
538
- switch (_a.label) {
539
- case 0:
540
- url = "".concat(config.backendDomain, "/api/user/getUserByIncodeId?incodeId=").concat(incodeId);
541
- console.log('UrlString: ', url);
542
- return [4 /*yield*/, axios.get(url)];
543
- case 1:
544
- res = _a.sent();
545
- console.log('UrlRes data: ', res.data);
546
- return [2 /*return*/, res.data];
547
- }
548
- });
549
- });
550
- }
551
- function getUserByClearId(_a) {
534
+ function getUserByIncodeId(_a) {
552
535
  return __awaiter(this, arguments, void 0, function (_b) {
553
536
  var url, res;
554
- var clearId = _b.clearId, token = _b.token;
537
+ var customerId = _b.customerId, interviewId = _b.interviewId, token = _b.token;
555
538
  return __generator(this, function (_c) {
556
539
  switch (_c.label) {
557
540
  case 0:
558
- url = "".concat(config.backendDomain, "/api/user/getUserByClearId?clearId=").concat(clearId).concat(token ? "&token=".concat(token) : '');
541
+ url = "".concat(config.backendDomain, "/api/user/getUserByIncodeId?customerId=").concat(customerId, "&interviewId=").concat(interviewId).concat(token ? "&token=".concat(token) : '');
559
542
  console.log('UrlString: ', url);
560
543
  return [4 /*yield*/, axios.get(url)];
561
544
  case 1:
@@ -1141,7 +1124,6 @@ var berifymeApi = {
1141
1124
  user: {
1142
1125
  getUserBySessionId: getUserBySessionId,
1143
1126
  getUserByIncodeId: getUserByIncodeId,
1144
- getUserByClearId: getUserByClearId,
1145
1127
  getUserBySumsubId: getUserBySumsubId,
1146
1128
  getUserByYotiId: getUserByYotiId,
1147
1129
  getUserVenderByPhone: getUserVenderByPhone,
@@ -104,7 +104,7 @@ var AuthID = function (_a) {
104
104
  });
105
105
  if (!!result.error) return [3 /*break*/, 3];
106
106
  setUrl('');
107
- return [4 /*yield*/, berifymeApi.authID.getAccount({ token: localStorage.getItem('authID_token') || '', phone: phone })];
107
+ return [4 /*yield*/, berifymeApi.authID.getAccount({ token: localStorage.getItem('authID_token') || '', phone: phone, sessionToken: token })];
108
108
  case 2:
109
109
  account = _a.sent();
110
110
  createDeveloperLog({
@@ -44,16 +44,16 @@ import { createAuthenticationLog } from "../../AuthenticationLogs";
44
44
  import { createDeveloperLog } from "../../createDeveloperLog";
45
45
  function LoginComponent(_a) {
46
46
  var _this = this;
47
- var onSuccess = _a.onSuccess, onError = _a.onError, user = _a.user, setUser = _a.setUser, token = _a.token;
47
+ var onSuccess = _a.onSuccess, setError = _a.setError, user = _a.user, setUser = _a.setUser, token = _a.token;
48
48
  var containerRef = useRef(null);
49
49
  var _b = useSpeedTest(), stopSpeedTest = _b.stopSpeedTest, startSpeedTest = _b.startSpeedTest;
50
50
  useEffect(function () { stopSpeedTest(); }, []);
51
- var getBerifymeUser = function (customerId, transactionId) { return __awaiter(_this, void 0, void 0, function () {
51
+ var getBerifymeUser = function (customerId, interviewId, transactionId, token) { return __awaiter(_this, void 0, void 0, function () {
52
52
  var res;
53
53
  var _a;
54
54
  return __generator(this, function (_b) {
55
55
  switch (_b.label) {
56
- case 0: return [4 /*yield*/, berifymeApi.user.getUserByIncodeId(customerId)];
56
+ case 0: return [4 /*yield*/, berifymeApi.user.getUserByIncodeId({ customerId: customerId, interviewId: interviewId, token: token })];
57
57
  case 1:
58
58
  res = _b.sent();
59
59
  createDeveloperLog({
@@ -77,10 +77,10 @@ function LoginComponent(_a) {
77
77
  onSuccess();
78
78
  }
79
79
  else if (res.error) {
80
- onError({ type: res.error });
80
+ setError(res.error);
81
81
  }
82
82
  else {
83
- onError({ type: 'Oops! Something went wrong...' });
83
+ setError('Oops! Something went wrong...');
84
84
  }
85
85
  return [2 /*return*/];
86
86
  }
@@ -94,17 +94,19 @@ function LoginComponent(_a) {
94
94
  switch (_a.label) {
95
95
  case 0:
96
96
  startSpeedTest();
97
- return [4 /*yield*/, getBerifymeUser(response.customerId, response.transactionId)];
97
+ if (!token) return [3 /*break*/, 2];
98
+ return [4 /*yield*/, getBerifymeUser(response.customerId, response.interviewId, response.transactionId, token)];
98
99
  case 1:
99
100
  _a.sent();
100
- return [2 /*return*/];
101
+ _a.label = 2;
102
+ case 2: return [2 /*return*/];
101
103
  }
102
104
  });
103
105
  }); },
104
106
  onError: function (r) {
105
107
  startSpeedTest();
106
108
  console.log('onError: ', r);
107
- onError({ type: 'Oops! Something went wrong...' });
109
+ setError('Oops! Something went wrong...');
108
110
  },
109
111
  stopAtError: true,
110
112
  isOneToOne: true,
@@ -114,9 +116,9 @@ function LoginComponent(_a) {
114
116
  });
115
117
  }
116
118
  else {
117
- onError({ type: 'Oops! Something went wrong...' });
119
+ setError('Oops! Something went wrong...');
118
120
  }
119
- }, [onSuccess, onError]);
121
+ }, [onSuccess, setError]);
120
122
  return React.createElement("div", { ref: containerRef },
121
123
  React.createElement(Box, { sx: {
122
124
  display: 'flex',
@@ -1,16 +1,8 @@
1
1
  import React from "react";
2
- import { useState } from "react";
3
- import TryAgain from "../../TryAgain";
4
2
  import { LoginComponent } from "./Login";
5
3
  var IncodeLogin = function (_a) {
6
- var goToAllSet = _a.goToAllSet, user = _a.user, setUser = _a.setUser, token = _a.token;
7
- var _b = useState(), error = _b[0], setError = _b[1];
8
- function handleError(e) {
9
- setError(e.type);
10
- }
11
- if (error || !token)
12
- return (React.createElement(TryAgain, { message: error }));
4
+ var goToAllSet = _a.goToAllSet, user = _a.user, setUser = _a.setUser, token = _a.token, setError = _a.setError;
13
5
  return (React.createElement(React.Fragment, null,
14
- React.createElement(LoginComponent, { token: token, onError: handleError, onSuccess: goToAllSet, user: user, setUser: setUser })));
6
+ React.createElement(LoginComponent, { token: token, setError: setError, onSuccess: goToAllSet, user: user, setUser: setUser })));
15
7
  };
16
8
  export { IncodeLogin };
@@ -213,7 +213,7 @@ var AuthID = function (_a) {
213
213
  var _a, _b, _c, _d, _e, _f, _g;
214
214
  return __generator(this, function (_h) {
215
215
  switch (_h.label) {
216
- case 0: return [4 /*yield*/, berifymeApi.authID.getDocumentDetails({ token: localStorage.getItem('authID_token') || '', operationId: operationId, userId: userId })];
216
+ case 0: return [4 /*yield*/, berifymeApi.authID.getDocumentDetails({ token: localStorage.getItem('authID_token') || '', operationId: operationId, userId: userId, sessionToken: token })];
217
217
  case 1:
218
218
  document = _h.sent();
219
219
  createDeveloperLog({
@@ -67,12 +67,12 @@ var ClearOnboardingAllSet = function (_a) {
67
67
  setError(approveRes.error);
68
68
  return [2 /*return*/];
69
69
  }
70
- return [4 /*yield*/, berifymeApi.user.getUserByClearId({ clearId: approveRes.clearId, token: token })];
70
+ return [4 /*yield*/, berifymeApi.user.getUserBySessionId({ sessionId: sessionId, token: token })];
71
71
  case 2:
72
72
  res = _c.sent();
73
73
  createDeveloperLog({
74
74
  source: 'FRONTEND',
75
- action: 'clear getUserByClearId',
75
+ action: 'clear getUserBySessionId',
76
76
  sessionToken: token,
77
77
  firstDetail: approveRes.clearId,
78
78
  secondDetail: "user: ".concat(res.user, ", error: ").concat(res.error),
@@ -70,15 +70,15 @@ var IncodeOnBoarding = function (_a) {
70
70
  var _c = useState(""), error = _c[0], setError = _c[1];
71
71
  var _d = useState(null), session = _d[0], setSession = _d[1]; // Stores the Session
72
72
  var isLoaded = useRef(false);
73
- function finishIncodeOnboarding(id, token, uniqueId) {
73
+ function finishIncodeOnboarding(id, token, sessionToken) {
74
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) {
75
+ var incodeRes;
76
+ var _a;
77
+ return __generator(this, function (_b) {
78
+ switch (_b.label) {
79
79
  case 0: return [4 /*yield*/, berifymeApi.incode.getIncodeFinish({ token: token })];
80
80
  case 1:
81
- _c.sent();
81
+ _b.sent();
82
82
  createDeveloperLog({
83
83
  userId: user === null || user === void 0 ? void 0 : user.id,
84
84
  userDataJson: user,
@@ -86,35 +86,22 @@ var IncodeOnBoarding = function (_a) {
86
86
  action: 'incode Onboarding getIncodeFinish',
87
87
  sessionToken: token,
88
88
  });
89
- return [4 /*yield*/, berifymeApi.incode.getIncodeApprove({ id: id, token: token, uniqueId: uniqueId })];
89
+ return [4 /*yield*/, berifymeApi.incode.getIncodeApprove({ id: id, token: token, sessionToken: sessionToken })];
90
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) {
91
+ incodeRes = _b.sent();
92
+ if (incodeRes.error || !incodeRes.user) {
101
93
  setError((_a = incodeRes.error) !== null && _a !== void 0 ? _a : '');
102
94
  return [2 /*return*/, false];
103
95
  }
104
- return [4 /*yield*/, berifymeApi.user.getUserByIncodeId(incodeRes.incodeId)];
105
- case 3:
106
- res = _c.sent();
96
+ setUser(incodeRes.user);
107
97
  createDeveloperLog({
108
- userId: (_b = res.user) === null || _b === void 0 ? void 0 : _b.id,
109
- userDataJson: res.user,
98
+ userId: user === null || user === void 0 ? void 0 : user.id,
99
+ userDataJson: user,
110
100
  source: 'FRONTEND',
111
- action: 'incode getUserByIncodeId',
101
+ action: 'incode getIncodeApprove',
112
102
  sessionToken: token,
113
- firstDetail: "error: ".concat(incodeRes.error)
103
+ firstDetail: "incode user: ".concat(incodeRes.user, ", error: ").concat(incodeRes.error)
114
104
  });
115
- if (!res.user)
116
- return [2 /*return*/, false];
117
- setUser(res.user);
118
105
  return [2 /*return*/, true];
119
106
  }
120
107
  });
@@ -187,8 +174,8 @@ var IncodeOnBoarding = function (_a) {
187
174
  return __generator(this, function (_a) {
188
175
  switch (_a.label) {
189
176
  case 0:
190
- if (!(session && session.uniqueId)) return [3 /*break*/, 2];
191
- return [4 /*yield*/, finishIncodeOnboarding(user.id, session.token, session.uniqueId)];
177
+ if (!(session && session.uniqueId && token)) return [3 /*break*/, 2];
178
+ return [4 /*yield*/, finishIncodeOnboarding(user.id, session.token, token)];
192
179
  case 1:
193
180
  success = _a.sent();
194
181
  if (success) {
@@ -80,7 +80,7 @@ var AuthIdGrid = function (_a) {
80
80
  setPageStatus(1.2);
81
81
  return [3 /*break*/, 5];
82
82
  case 4:
83
- setError('User error');
83
+ setError('The user already exists. Please try a different account.');
84
84
  _a.label = 5;
85
85
  case 5: return [2 /*return*/];
86
86
  }
@@ -126,9 +126,10 @@ declare function createBiometricFromProof({ token, tempId, userId }: {
126
126
  } | {
127
127
  error: string;
128
128
  }>;
129
- declare function getAccount({ token, phone }: {
129
+ declare function getAccount({ token, phone, sessionToken }: {
130
130
  token: string;
131
131
  phone: string;
132
+ sessionToken?: string;
132
133
  }): Promise<{
133
134
  fullName: string;
134
135
  dateOfBirth: string;
@@ -179,10 +180,11 @@ declare function searchUser({ token, operationId }: {
179
180
  operationId: string;
180
181
  error: undefined;
181
182
  }>;
182
- declare function getDocumentDetails({ token, operationId, userId }: {
183
+ declare function getDocumentDetails({ token, operationId, userId, sessionToken }: {
183
184
  token: string;
184
185
  operationId: string;
185
186
  userId: string;
187
+ sessionToken?: string;
186
188
  }): Promise<{
187
189
  details: {
188
190
  Key: string;
@@ -216,12 +218,12 @@ declare function getIncodeFinish({ token }: {
216
218
  token: string;
217
219
  uniqueId: string;
218
220
  }>;
219
- declare function getIncodeApprove({ id, token, uniqueId, }: {
221
+ declare function getIncodeApprove({ id, token, sessionToken, }: {
220
222
  id: string;
221
223
  token: string;
222
- uniqueId: string;
224
+ sessionToken: string;
223
225
  }): Promise<{
224
- incodeId?: string;
226
+ user?: UserWithAgeAndFullName;
225
227
  error?: string;
226
228
  }>;
227
229
  declare function createVerificationSession({ redirectUrl, token }: {
@@ -265,13 +267,10 @@ declare function getUserBySessionId({ sessionId, token }: {
265
267
  user?: UserWithAgeAndFullName;
266
268
  error?: string;
267
269
  }>;
268
- declare function getUserByIncodeId(incodeId: string): Promise<{
269
- user?: UserWithAgeAndFullName;
270
- error?: string;
271
- }>;
272
- declare function getUserByClearId({ clearId, token }: {
273
- clearId: string;
274
- token?: string;
270
+ declare function getUserByIncodeId({ customerId, interviewId, token }: {
271
+ customerId: string;
272
+ interviewId: string;
273
+ token: string;
275
274
  }): Promise<{
276
275
  user?: UserWithAgeAndFullName;
277
276
  error?: string;
@@ -503,7 +502,6 @@ declare const berifymeApi: {
503
502
  user: {
504
503
  getUserBySessionId: typeof getUserBySessionId;
505
504
  getUserByIncodeId: typeof getUserByIncodeId;
506
- getUserByClearId: typeof getUserByClearId;
507
505
  getUserBySumsubId: typeof getUserBySumsubId;
508
506
  getUserByYotiId: typeof getUserByYotiId;
509
507
  getUserVenderByPhone: typeof getUserVenderByPhone;
@@ -1,13 +1,11 @@
1
1
  import React from "react";
2
2
  import { UserWithAgeAndFullName } from "../../../api/api";
3
- declare function LoginComponent({ onSuccess, onError, user, setUser, token, }: ProccessFacePropTypes): React.JSX.Element;
3
+ declare function LoginComponent({ onSuccess, setError, user, setUser, token, }: ProccessFacePropTypes): React.JSX.Element;
4
4
  type ProccessFacePropTypes = {
5
5
  onSuccess: () => void;
6
- onError: (e: {
7
- type: string;
8
- }) => void;
6
+ setError: React.Dispatch<React.SetStateAction<string | undefined>>;
9
7
  user?: UserWithAgeAndFullName;
10
8
  setUser: React.Dispatch<React.SetStateAction<UserWithAgeAndFullName | undefined>>;
11
- token: string;
9
+ token?: string;
12
10
  };
13
11
  export { LoginComponent };
@@ -5,5 +5,6 @@ declare const IncodeLogin: React.FC<{
5
5
  user?: UserWithAgeAndFullName;
6
6
  setUser: React.Dispatch<React.SetStateAction<UserWithAgeAndFullName | undefined>>;
7
7
  token?: string;
8
+ setError: React.Dispatch<React.SetStateAction<string | undefined>>;
8
9
  }>;
9
10
  export { IncodeLogin };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bytexbyte/berifyme-react-sdk",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/types/index.d.ts",