@dynamic-labs/sdk-react-core 0.17.26 → 0.17.27

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.
package/CHANGELOG.md CHANGED
@@ -1,4 +1,12 @@
1
1
 
2
+ ### [0.17.27](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.26...v0.17.27) (2023-07-26)
3
+
4
+
5
+ ### Bug Fixes
6
+
7
+ * do not proceed to authSuccess if there are still missing fields ([#2726](https://github.com/dynamic-labs/DynamicAuth/issues/2726)) ([e5b8139](https://github.com/dynamic-labs/DynamicAuth/commit/e5b8139bedbcc82f6f42251c5877a97955d90564)), closes [#2740](https://github.com/dynamic-labs/DynamicAuth/issues/2740)
8
+ * WalletConnect bug on fresh session with high latency ([#2669](https://github.com/dynamic-labs/DynamicAuth/issues/2669)) ([0fcb9c9](https://github.com/dynamic-labs/DynamicAuth/commit/0fcb9c969d39dad856ae76b2bdd02368c6c8d64a))
9
+
2
10
  ### [0.17.26](https://github.com/dynamic-labs/DynamicAuth/compare/v0.17.25...v0.17.26) (2023-07-25)
3
11
 
4
12
 
package/package.cjs CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- var version = "0.17.26";
5
+ var version = "0.17.27";
6
6
  var dependencies = {
7
7
  "react-focus-lock": "2.9.2",
8
8
  "@dynamic-labs/iconic": "0.1.23",
package/package.js CHANGED
@@ -1,4 +1,4 @@
1
- var version = "0.17.26";
1
+ var version = "0.17.27";
2
2
  var dependencies = {
3
3
  "react-focus-lock": "2.9.2",
4
4
  "@dynamic-labs/iconic": "0.1.23",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "0.17.26",
3
+ "version": "0.17.27",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/dynamic-labs/DynamicAuth.git",
@@ -16,13 +16,13 @@
16
16
  "formik": "2.2.9",
17
17
  "qrcode": "1.5.1",
18
18
  "ethers": "5.7.2",
19
- "@dynamic-labs/logger": "0.17.26",
20
- "@dynamic-labs/multi-wallet": "0.17.26",
21
- "@dynamic-labs/rpc-providers": "0.17.26",
22
- "@dynamic-labs/types": "0.17.26",
23
- "@dynamic-labs/utils": "0.17.26",
24
- "@dynamic-labs/wallet-book": "0.17.26",
25
- "@dynamic-labs/wallet-connector-core": "0.17.26"
19
+ "@dynamic-labs/logger": "0.17.27",
20
+ "@dynamic-labs/multi-wallet": "0.17.27",
21
+ "@dynamic-labs/rpc-providers": "0.17.27",
22
+ "@dynamic-labs/types": "0.17.27",
23
+ "@dynamic-labs/utils": "0.17.27",
24
+ "@dynamic-labs/wallet-book": "0.17.27",
25
+ "@dynamic-labs/wallet-connector-core": "0.17.27"
26
26
  },
27
27
  "devDependencies": {
28
28
  "semver": "7.3.8"
@@ -11,6 +11,17 @@ var isEmailVerificationRequired = require('../../functions/authenication/isEmail
11
11
  var EmailVerificationContext = require('../../../context/EmailVerificationContext/EmailVerificationContext.cjs');
12
12
  var useEmailVerificationRequest = require('../authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.cjs');
13
13
  var useUpdateUserProfileByJWTCallback = require('../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.cjs');
14
+ var decodeJwt = require('../../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
15
+ require('../../../shared/logger.cjs');
16
+ require('../../../config/LSSuffix.cjs');
17
+ require('@dynamic-labs/iconic');
18
+ require('@dynamic-labs/wallet-connector-core');
19
+ require('react/jsx-runtime');
20
+ require('../../../context/ViewContext/ViewContext.cjs');
21
+ require('@dynamic-labs/utils');
22
+ require('../../constants/colors.cjs');
23
+ require('ethers');
24
+ require('../../../shared/consts/index.cjs');
14
25
 
15
26
  // User Fields Schema without captchaToken and policiesConsent properties
16
27
  const userFieldsSchema = yup.object().shape({
@@ -33,23 +44,27 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
33
44
  const { verifyEmail: verifyEmailFn } = useEmailVerificationRequest.useEmailVerificationRequest();
34
45
  const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
35
46
  const updateUser = React.useCallback((userFields, userEnvironmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
36
- var _a, _b;
47
+ var _a, _b, _c;
37
48
  const validatedUserFields = yield userFieldsSchema.validate(userFields, {
38
49
  stripUnknown: validationSchemaStripUnknown,
39
50
  });
40
51
  const updateUserProfileResponse = yield api.updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, validatedUserFields);
52
+ // check if decoded JWT still somehow has missing fields, we can't proceed if it does
53
+ const decodedJwt = decodeJwt.decodeJwt(updateUserProfileResponse.jwt);
54
+ const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
41
55
  const _isEmailVerificationRequired = isEmailVerificationRequired.isEmailVerificationRequired(updateUserProfileResponse);
42
56
  if (!_isEmailVerificationRequired) {
43
57
  // If email verification is not needed then we can update the user profile immediately.
44
58
  updateUserProfileByJWT(updateUserProfileResponse.jwt);
45
59
  return {
46
- isEmailVerificationRequired: _isEmailVerificationRequired,
60
+ isEmailVerificationRequired: false,
61
+ missingFields,
47
62
  updateUserProfileResponse,
48
63
  };
49
64
  }
50
65
  // We update EmailContext to use this information in the Email Verification view
51
- setEmail((_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.email);
52
- setVerificationUUID((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.verificationUUID);
66
+ setEmail((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.email);
67
+ setVerificationUUID((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.verificationUUID);
53
68
  // DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
54
69
  // VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
55
70
  // setEmail and setVerificationUUID in the above lines will are not visible in this promise.
@@ -58,7 +73,8 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
58
73
  return verifyEmailFn(verificationToken, (_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.verificationUUID);
59
74
  };
60
75
  return {
61
- isEmailVerificationRequired: _isEmailVerificationRequired,
76
+ isEmailVerificationRequired: true,
77
+ missingFields,
62
78
  updateUserProfileResponse,
63
79
  verifyEmailFn: scopedVerifyEmailFn,
64
80
  };
@@ -4,22 +4,26 @@ export declare const useUserUpdateRequestInternal: ({ validationSchemaStripUnkno
4
4
  validationSchemaStripUnknown: boolean;
5
5
  }) => {
6
6
  updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
7
- isEmailVerificationRequired: false;
7
+ isEmailVerificationRequired: boolean;
8
+ missingFields: import("@dynamic-labs/sdk-api").ProjectSettingsKyc[];
8
9
  updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
9
10
  verifyEmailFn?: undefined;
10
11
  } | {
11
- isEmailVerificationRequired: true;
12
+ isEmailVerificationRequired: boolean;
13
+ missingFields: import("@dynamic-labs/sdk-api").ProjectSettingsKyc[];
12
14
  updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
13
15
  verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
14
16
  }>;
15
17
  };
16
18
  export declare const useUserUpdateRequest: () => {
17
19
  updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
18
- isEmailVerificationRequired: false;
20
+ isEmailVerificationRequired: boolean;
21
+ missingFields: import("@dynamic-labs/sdk-api").ProjectSettingsKyc[];
19
22
  updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
20
23
  verifyEmailFn?: undefined;
21
24
  } | {
22
- isEmailVerificationRequired: true;
25
+ isEmailVerificationRequired: boolean;
26
+ missingFields: import("@dynamic-labs/sdk-api").ProjectSettingsKyc[];
23
27
  updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
24
28
  verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
25
29
  }>;
@@ -7,6 +7,17 @@ import { isEmailVerificationRequired } from '../../functions/authenication/isEma
7
7
  import { useEmailVerificationContext } from '../../../context/EmailVerificationContext/EmailVerificationContext.js';
8
8
  import { useEmailVerificationRequest } from '../authenticationHooks/useEmailVerificationRequest/useEmailVerificationRequest.js';
9
9
  import { useUpdateUserProfileByJWTCallback } from '../useUpdateUserProfileByJWTCallback/useUpdateUserProfileByJWTCallback.js';
10
+ import { decodeJwt } from '../../../shared/utils/functions/decodeJwt/decodeJwt.js';
11
+ import '../../../shared/logger.js';
12
+ import '../../../config/LSSuffix.js';
13
+ import '@dynamic-labs/iconic';
14
+ import '@dynamic-labs/wallet-connector-core';
15
+ import 'react/jsx-runtime';
16
+ import '../../../context/ViewContext/ViewContext.js';
17
+ import '@dynamic-labs/utils';
18
+ import '../../constants/colors.js';
19
+ import 'ethers';
20
+ import '../../../shared/consts/index.js';
10
21
 
11
22
  // User Fields Schema without captchaToken and policiesConsent properties
12
23
  const userFieldsSchema = object().shape({
@@ -29,23 +40,27 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
29
40
  const { verifyEmail: verifyEmailFn } = useEmailVerificationRequest();
30
41
  const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
31
42
  const updateUser = useCallback((userFields, userEnvironmentId) => __awaiter(void 0, void 0, void 0, function* () {
32
- var _a, _b;
43
+ var _a, _b, _c;
33
44
  const validatedUserFields = yield userFieldsSchema.validate(userFields, {
34
45
  stripUnknown: validationSchemaStripUnknown,
35
46
  });
36
47
  const updateUserProfileResponse = yield updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, validatedUserFields);
48
+ // check if decoded JWT still somehow has missing fields, we can't proceed if it does
49
+ const decodedJwt = decodeJwt(updateUserProfileResponse.jwt);
50
+ const missingFields = (_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : [];
37
51
  const _isEmailVerificationRequired = isEmailVerificationRequired(updateUserProfileResponse);
38
52
  if (!_isEmailVerificationRequired) {
39
53
  // If email verification is not needed then we can update the user profile immediately.
40
54
  updateUserProfileByJWT(updateUserProfileResponse.jwt);
41
55
  return {
42
- isEmailVerificationRequired: _isEmailVerificationRequired,
56
+ isEmailVerificationRequired: false,
57
+ missingFields,
43
58
  updateUserProfileResponse,
44
59
  };
45
60
  }
46
61
  // We update EmailContext to use this information in the Email Verification view
47
- setEmail((_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.email);
48
- setVerificationUUID((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.verificationUUID);
62
+ setEmail((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.email);
63
+ setVerificationUUID((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.verificationUUID);
49
64
  // DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
50
65
  // VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
51
66
  // setEmail and setVerificationUUID in the above lines will are not visible in this promise.
@@ -54,7 +69,8 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
54
69
  return verifyEmailFn(verificationToken, (_a = updateUserProfileResponse.emailVerification) === null || _a === void 0 ? void 0 : _a.verificationUUID);
55
70
  };
56
71
  return {
57
- isEmailVerificationRequired: _isEmailVerificationRequired,
72
+ isEmailVerificationRequired: true,
73
+ missingFields,
58
74
  updateUserProfileResponse,
59
75
  verifyEmailFn: scopedVerifyEmailFn,
60
76
  };
@@ -46,17 +46,24 @@ var useUserDataForm = require('../../../utils/hooks/useUserDataForm/useUserDataF
46
46
 
47
47
  const OnboardingUserDataForm = ({ children, userProfile, disableSubmit, }) => {
48
48
  const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
49
- const { setView } = ViewContext.useViewContext();
49
+ const { setView, view } = ViewContext.useViewContext();
50
50
  const decodedJwt = decodeJwt.decodeJwt(onboardingOnlyJwt);
51
51
  const { updateUser } = useUserUpdateRequest.useUserUpdateRequestInternal({
52
52
  validationSchemaStripUnknown: false,
53
53
  });
54
54
  const onSubmit = React.useCallback((formValues) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
55
- const { isEmailVerificationRequired } = yield updateUser(formValues);
56
- if (isEmailVerificationRequired) {
55
+ const { isEmailVerificationRequired, missingFields } = yield updateUser(formValues);
56
+ if (isEmailVerificationRequired &&
57
+ missingFields.map((field) => field.name).toString() === 'email') {
57
58
  setView('verify-email');
58
59
  return;
59
60
  }
61
+ else if (missingFields.length > 0) {
62
+ // make sure we capture the fields that are required and still missing!
63
+ // do not change the view, just use the current one
64
+ setView(view);
65
+ return;
66
+ }
60
67
  setShowAuthFlow(false);
61
68
  setCallback('authSuccess');
62
69
  }), [setCallback, setShowAuthFlow, setView, updateUser]);
@@ -42,17 +42,24 @@ import { useUserDataForm } from '../../../utils/hooks/useUserDataForm/useUserDat
42
42
 
43
43
  const OnboardingUserDataForm = ({ children, userProfile, disableSubmit, }) => {
44
44
  const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
45
- const { setView } = useViewContext();
45
+ const { setView, view } = useViewContext();
46
46
  const decodedJwt = decodeJwt(onboardingOnlyJwt);
47
47
  const { updateUser } = useUserUpdateRequestInternal({
48
48
  validationSchemaStripUnknown: false,
49
49
  });
50
50
  const onSubmit = useCallback((formValues) => __awaiter(void 0, void 0, void 0, function* () {
51
- const { isEmailVerificationRequired } = yield updateUser(formValues);
52
- if (isEmailVerificationRequired) {
51
+ const { isEmailVerificationRequired, missingFields } = yield updateUser(formValues);
52
+ if (isEmailVerificationRequired &&
53
+ missingFields.map((field) => field.name).toString() === 'email') {
53
54
  setView('verify-email');
54
55
  return;
55
56
  }
57
+ else if (missingFields.length > 0) {
58
+ // make sure we capture the fields that are required and still missing!
59
+ // do not change the view, just use the current one
60
+ setView(view);
61
+ return;
62
+ }
56
63
  setShowAuthFlow(false);
57
64
  setCallback('authSuccess');
58
65
  }), [setCallback, setShowAuthFlow, setView, updateUser]);