@dynamic-labs/sdk-react-core 0.18.0-RC.17 → 0.18.0-RC.18

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.18.0-RC.18](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.17...v0.18.0-RC.18) (2023-07-24)
3
+
4
+ ### Bug Fixes
5
+
6
+ * do not call connectSuccess when already connected ([#2705](https://github.com/dynamic-labs/DynamicAuth/issues/2705)) ([12a65fb](https://github.com/dynamic-labs/DynamicAuth/commit/12a65fb5e59a38de0f5fb0e7eab3ce3d558f201f))
7
+ * do not proceed to authSuccess if there are still missing fields ([#2712](https://github.com/dynamic-labs/DynamicAuth/issues/2712)) ([2fb10ed](https://github.com/dynamic-labs/DynamicAuth/commit/2fb10ed7f9c28476d61856887b517bdae10b80f4))
8
+ * add legacy safari detection ([#2733](https://github.com/dynamic-labs/DynamicAuth/issues/2733)) ([1b21c57](https://github.com/dynamic-labs/DynamicAuth/commit/1b21c57c1fd7c458f499cc09ef60364c314b0464))
9
+
2
10
  ## [0.18.0-RC.17](https://github.com/dynamic-labs/DynamicAuth/compare/v0.18.0-RC.16...v0.18.0-RC.17) (2023-07-24)
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.18.0-RC.17";
5
+ var version = "0.18.0-RC.18";
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.18.0-RC.17";
1
+ var version = "0.18.0-RC.18";
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.18.0-RC.17",
3
+ "version": "0.18.0-RC.18",
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.18.0-RC.17",
20
- "@dynamic-labs/multi-wallet": "0.18.0-RC.17",
21
- "@dynamic-labs/rpc-providers": "0.18.0-RC.17",
22
- "@dynamic-labs/types": "0.18.0-RC.17",
23
- "@dynamic-labs/utils": "0.18.0-RC.17",
24
- "@dynamic-labs/wallet-book": "0.18.0-RC.17",
25
- "@dynamic-labs/wallet-connector-core": "0.18.0-RC.17"
19
+ "@dynamic-labs/logger": "0.18.0-RC.18",
20
+ "@dynamic-labs/multi-wallet": "0.18.0-RC.18",
21
+ "@dynamic-labs/rpc-providers": "0.18.0-RC.18",
22
+ "@dynamic-labs/types": "0.18.0-RC.18",
23
+ "@dynamic-labs/utils": "0.18.0-RC.18",
24
+ "@dynamic-labs/wallet-book": "0.18.0-RC.18",
25
+ "@dynamic-labs/wallet-connector-core": "0.18.0-RC.18"
26
26
  },
27
27
  "devDependencies": {
28
28
  "semver": "7.3.8"
@@ -355,7 +355,6 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
355
355
  onLinkSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLinkSuccess,
356
356
  onUserProfileUpdate: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onUserProfileUpdate,
357
357
  },
358
- connectedWallets,
359
358
  handleLogOut,
360
359
  isAuthenticated,
361
360
  ongoingVerifications,
@@ -351,7 +351,6 @@ const DynamicContextProvider = ({ children, theme, settings, }) => {
351
351
  onLinkSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLinkSuccess,
352
352
  onUserProfileUpdate: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onUserProfileUpdate,
353
353
  },
354
- connectedWallets,
355
354
  handleLogOut,
356
355
  isAuthenticated,
357
356
  ongoingVerifications,
@@ -15,6 +15,5 @@ export type UseCustomerCallbacksArgs = {
15
15
  primaryWallet: Wallet | null;
16
16
  selectedWalletConnector: WalletConnector | null;
17
17
  user: UserProfile | undefined;
18
- connectedWallets: Wallet[];
19
18
  ongoingVerifications: IOngoingVerifications;
20
19
  };
@@ -32,7 +32,7 @@ const useConnectAndSign = () => {
32
32
  const { setView, goToInitialView } = ViewContext.useViewContext();
33
33
  const { setErrorMessage } = ErrorContext.useErrorContext();
34
34
  const { captchaToken } = CaptchaContext.useCaptchaContext();
35
- const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, ongoingVerifications, } = useInternalDynamicContext.useInternalDynamicContext();
35
+ const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, ongoingVerifications, isUserConnected, } = useInternalDynamicContext.useInternalDynamicContext();
36
36
  const { handleWalletsToConnect } = useHandleWalletsToConnect.useHandleWalletsToConnect();
37
37
  const verifyWallet = useVerifyWallet.useVerifyWallet({
38
38
  consumeNonce,
@@ -56,7 +56,6 @@ const useConnectAndSign = () => {
56
56
  }
57
57
  }
58
58
  const publicWalletAddress = yield connectWallet(walletConnector, fetchPublicAddressOpts);
59
- setCallback('connectSuccess');
60
59
  const walletNetwork = yield walletConnector.getNetwork();
61
60
  const usesSupportedNetwork = isSupportedNetwork.isSupportedNetwork({
62
61
  network: walletNetwork,
@@ -71,8 +70,12 @@ const useConnectAndSign = () => {
71
70
  if (isConnectOnly.isConnectOnly(user, authMode)) {
72
71
  localStorage.LocalStorage.setToLS(localStorage$1.LAST_USED_WALLET, walletConnector.name);
73
72
  handleWalletsToConnect();
73
+ if (!isUserConnected) {
74
+ setCallback('connectSuccess');
75
+ }
74
76
  return;
75
77
  }
78
+ setCallback('connectSuccess');
76
79
  if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.hCaptcha) === null || _a === void 0 ? void 0 : _a.enabled) {
77
80
  setView('captcha');
78
81
  return;
@@ -28,7 +28,7 @@ const useConnectAndSign = () => {
28
28
  const { setView, goToInitialView } = useViewContext();
29
29
  const { setErrorMessage } = useErrorContext();
30
30
  const { captchaToken } = useCaptchaContext();
31
- const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, ongoingVerifications, } = useInternalDynamicContext();
31
+ const { authMode, connectWallet, consumeNonce, displayTermsOfService, environmentId, projectSettings, setIsSingleWalletAccount, user, walletUiUtils, setCallback, ongoingVerifications, isUserConnected, } = useInternalDynamicContext();
32
32
  const { handleWalletsToConnect } = useHandleWalletsToConnect();
33
33
  const verifyWallet = useVerifyWallet({
34
34
  consumeNonce,
@@ -52,7 +52,6 @@ const useConnectAndSign = () => {
52
52
  }
53
53
  }
54
54
  const publicWalletAddress = yield connectWallet(walletConnector, fetchPublicAddressOpts);
55
- setCallback('connectSuccess');
56
55
  const walletNetwork = yield walletConnector.getNetwork();
57
56
  const usesSupportedNetwork = isSupportedNetwork({
58
57
  network: walletNetwork,
@@ -67,8 +66,12 @@ const useConnectAndSign = () => {
67
66
  if (isConnectOnly(user, authMode)) {
68
67
  LocalStorage.setToLS(LAST_USED_WALLET, walletConnector.name);
69
68
  handleWalletsToConnect();
69
+ if (!isUserConnected) {
70
+ setCallback('connectSuccess');
71
+ }
70
72
  return;
71
73
  }
74
+ setCallback('connectSuccess');
72
75
  if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.hCaptcha) === null || _a === void 0 ? void 0 : _a.enabled) {
73
76
  setView('captcha');
74
77
  return;
@@ -11,6 +11,18 @@ 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('@dynamic-labs/iconic');
16
+ require('@dynamic-labs/wallet-connector-core');
17
+ require('react/jsx-runtime');
18
+ require('../../../context/ViewContext/ViewContext.cjs');
19
+ require('../../../shared/logger.cjs');
20
+ require('@dynamic-labs/wallet-book');
21
+ require('@dynamic-labs/utils');
22
+ require('../../constants/colors.cjs');
23
+ require('../../../shared/utils/classes/storage/localStorage.cjs');
24
+ require('ethers');
25
+ require('../../../shared/consts/index.cjs');
14
26
 
15
27
  // User Fields Schema without captchaToken and policiesConsent properties
16
28
  const userFieldsSchema = yup.object().shape({
@@ -33,11 +45,14 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
33
45
  const { verifyEmail: verifyEmailFn } = useEmailVerificationRequest.useEmailVerificationRequest();
34
46
  const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback.useUpdateUserProfileByJWTCallback();
35
47
  const updateUser = React.useCallback((userFields, userEnvironmentId) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
36
- var _a, _b;
48
+ var _a, _b, _c;
37
49
  const validatedUserFields = yield userFieldsSchema.validate(userFields, {
38
50
  stripUnknown: validationSchemaStripUnknown,
39
51
  });
40
52
  const updateUserProfileResponse = yield api.updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, validatedUserFields);
53
+ // check if decoded JWT still somehow has missing fields, we can't proceed if it does
54
+ const decodedJwt = decodeJwt.decodeJwt(updateUserProfileResponse.jwt);
55
+ const userProfileHasMissingFields = ((_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : []).length > 0;
41
56
  const _isEmailVerificationRequired = isEmailVerificationRequired.isEmailVerificationRequired(updateUserProfileResponse);
42
57
  if (!_isEmailVerificationRequired) {
43
58
  // If email verification is not needed then we can update the user profile immediately.
@@ -45,11 +60,12 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
45
60
  return {
46
61
  isEmailVerificationRequired: _isEmailVerificationRequired,
47
62
  updateUserProfileResponse,
63
+ userProfileHasMissingFields,
48
64
  };
49
65
  }
50
66
  // 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);
67
+ setEmail((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.email);
68
+ setVerificationUUID((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.verificationUUID);
53
69
  // DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
54
70
  // VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
55
71
  // setEmail and setVerificationUUID in the above lines will are not visible in this promise.
@@ -60,6 +76,7 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
60
76
  return {
61
77
  isEmailVerificationRequired: _isEmailVerificationRequired,
62
78
  updateUserProfileResponse,
79
+ userProfileHasMissingFields,
63
80
  verifyEmailFn: scopedVerifyEmailFn,
64
81
  };
65
82
  }), [
@@ -6,10 +6,12 @@ export declare const useUserUpdateRequestInternal: ({ validationSchemaStripUnkno
6
6
  updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
7
7
  isEmailVerificationRequired: false;
8
8
  updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
9
+ userProfileHasMissingFields: boolean;
9
10
  verifyEmailFn?: undefined;
10
11
  } | {
11
12
  isEmailVerificationRequired: true;
12
13
  updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
14
+ userProfileHasMissingFields: boolean;
13
15
  verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
14
16
  }>;
15
17
  };
@@ -17,10 +19,12 @@ export declare const useUserUpdateRequest: () => {
17
19
  updateUser: (userFields: UpdateUserFieldsArg, userEnvironmentId?: string) => Promise<{
18
20
  isEmailVerificationRequired: false;
19
21
  updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
22
+ userProfileHasMissingFields: boolean;
20
23
  verifyEmailFn?: undefined;
21
24
  } | {
22
25
  isEmailVerificationRequired: true;
23
26
  updateUserProfileResponse: import("@dynamic-labs/sdk-api").UpdateSelfResponse;
27
+ userProfileHasMissingFields: boolean;
24
28
  verifyEmailFn: (verificationToken: string) => Promise<import("@dynamic-labs/sdk-api").UpdateSelfResponse>;
25
29
  }>;
26
30
  };
@@ -7,6 +7,18 @@ 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 '@dynamic-labs/iconic';
12
+ import '@dynamic-labs/wallet-connector-core';
13
+ import 'react/jsx-runtime';
14
+ import '../../../context/ViewContext/ViewContext.js';
15
+ import '../../../shared/logger.js';
16
+ import '@dynamic-labs/wallet-book';
17
+ import '@dynamic-labs/utils';
18
+ import '../../constants/colors.js';
19
+ import '../../../shared/utils/classes/storage/localStorage.js';
20
+ import 'ethers';
21
+ import '../../../shared/consts/index.js';
10
22
 
11
23
  // User Fields Schema without captchaToken and policiesConsent properties
12
24
  const userFieldsSchema = object().shape({
@@ -29,11 +41,14 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
29
41
  const { verifyEmail: verifyEmailFn } = useEmailVerificationRequest();
30
42
  const { updateUserProfileByJWT } = useUpdateUserProfileByJWTCallback();
31
43
  const updateUser = useCallback((userFields, userEnvironmentId) => __awaiter(void 0, void 0, void 0, function* () {
32
- var _a, _b;
44
+ var _a, _b, _c;
33
45
  const validatedUserFields = yield userFieldsSchema.validate(userFields, {
34
46
  stripUnknown: validationSchemaStripUnknown,
35
47
  });
36
48
  const updateUserProfileResponse = yield updateUserProfileFields(jwtToken, userEnvironmentId || environmentId, validatedUserFields);
49
+ // check if decoded JWT still somehow has missing fields, we can't proceed if it does
50
+ const decodedJwt = decodeJwt(updateUserProfileResponse.jwt);
51
+ const userProfileHasMissingFields = ((_a = decodedJwt === null || decodedJwt === void 0 ? void 0 : decodedJwt.missingFields) !== null && _a !== void 0 ? _a : []).length > 0;
37
52
  const _isEmailVerificationRequired = isEmailVerificationRequired(updateUserProfileResponse);
38
53
  if (!_isEmailVerificationRequired) {
39
54
  // If email verification is not needed then we can update the user profile immediately.
@@ -41,11 +56,12 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
41
56
  return {
42
57
  isEmailVerificationRequired: _isEmailVerificationRequired,
43
58
  updateUserProfileResponse,
59
+ userProfileHasMissingFields,
44
60
  };
45
61
  }
46
62
  // 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);
63
+ setEmail((_b = updateUserProfileResponse.emailVerification) === null || _b === void 0 ? void 0 : _b.email);
64
+ setVerificationUUID((_c = updateUserProfileResponse.emailVerification) === null || _c === void 0 ? void 0 : _c.verificationUUID);
49
65
  // DYN-2046 - Customers have the opportunity to programmatically use our email verification and profile editing.
50
66
  // VerifyEmailFN was scoped to bypass the problem with memoization of the state at the beginning of Promise.
51
67
  // setEmail and setVerificationUUID in the above lines will are not visible in this promise.
@@ -56,6 +72,7 @@ const useUserUpdateRequestInternal = ({ validationSchemaStripUnknown, }) => {
56
72
  return {
57
73
  isEmailVerificationRequired: _isEmailVerificationRequired,
58
74
  updateUserProfileResponse,
75
+ userProfileHasMissingFields,
59
76
  verifyEmailFn: scopedVerifyEmailFn,
60
77
  };
61
78
  }), [
@@ -48,13 +48,19 @@ var useUserDataForm = require('../../../utils/hooks/useUserDataForm/useUserDataF
48
48
 
49
49
  const OnboardingUserDataForm = ({ children, userProfile, disableSubmit, }) => {
50
50
  const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext.useInternalDynamicContext();
51
- const { setView } = ViewContext.useViewContext();
51
+ const { setView, view } = ViewContext.useViewContext();
52
52
  const decodedJwt = decodeJwt.decodeJwt(onboardingOnlyJwt);
53
53
  const { updateUser } = useUserUpdateRequest.useUserUpdateRequestInternal({
54
54
  validationSchemaStripUnknown: false,
55
55
  });
56
56
  const onSubmit = React.useCallback((formValues) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
57
- const { isEmailVerificationRequired } = yield updateUser(formValues);
57
+ const { isEmailVerificationRequired, userProfileHasMissingFields } = yield updateUser(formValues);
58
+ if (userProfileHasMissingFields) {
59
+ // make sure we capture the fields that are required and still missing!
60
+ // do not change the view, just use the current one
61
+ setView(view);
62
+ return;
63
+ }
58
64
  if (isEmailVerificationRequired) {
59
65
  setView('verify-email');
60
66
  return;
@@ -44,13 +44,19 @@ import { useUserDataForm } from '../../../utils/hooks/useUserDataForm/useUserDat
44
44
 
45
45
  const OnboardingUserDataForm = ({ children, userProfile, disableSubmit, }) => {
46
46
  const { policiesConsentInnerComponent, onboardingOnlyJwt, setShowAuthFlow, setCallback, } = useInternalDynamicContext();
47
- const { setView } = useViewContext();
47
+ const { setView, view } = useViewContext();
48
48
  const decodedJwt = decodeJwt(onboardingOnlyJwt);
49
49
  const { updateUser } = useUserUpdateRequestInternal({
50
50
  validationSchemaStripUnknown: false,
51
51
  });
52
52
  const onSubmit = useCallback((formValues) => __awaiter(void 0, void 0, void 0, function* () {
53
- const { isEmailVerificationRequired } = yield updateUser(formValues);
53
+ const { isEmailVerificationRequired, userProfileHasMissingFields } = yield updateUser(formValues);
54
+ if (userProfileHasMissingFields) {
55
+ // make sure we capture the fields that are required and still missing!
56
+ // do not change the view, just use the current one
57
+ setView(view);
58
+ return;
59
+ }
54
60
  if (isEmailVerificationRequired) {
55
61
  setView('verify-email');
56
62
  return;