@dynamic-labs/sdk-react-core 2.5.3 → 2.6.1

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 (50) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/package.cjs +2 -2
  3. package/package.js +2 -2
  4. package/package.json +14 -14
  5. package/src/lib/components/QRCode/QRCode.d.ts +15 -0
  6. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +1 -1
  7. package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +1 -1
  8. package/src/lib/config/ApiEndpoint.cjs +6 -20
  9. package/src/lib/config/ApiEndpoint.d.ts +1 -2
  10. package/src/lib/config/ApiEndpoint.js +6 -20
  11. package/src/lib/context/DynamicContext/DynamicContext.cjs +2 -0
  12. package/src/lib/context/DynamicContext/DynamicContext.d.ts +2 -0
  13. package/src/lib/context/DynamicContext/DynamicContext.js +2 -0
  14. package/src/lib/context/DynamicContext/types/SocialSettings.d.ts +7 -0
  15. package/src/lib/context/DynamicContext/types/index.d.ts +2 -0
  16. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.cjs +4 -0
  17. package/src/lib/context/SocialRedirectContext/SocialRedirectContext.js +4 -0
  18. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/index.d.ts +1 -0
  19. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs +150 -0
  20. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.d.ts +7 -0
  21. package/src/lib/context/SocialRedirectContext/hooks/useRedirectSocialHandler/useRedirectSocialHandler.js +146 -0
  22. package/src/lib/data/api/embeddedWallets/embeddedWallets.cjs +1 -1
  23. package/src/lib/data/api/embeddedWallets/embeddedWallets.js +1 -1
  24. package/src/lib/data/api/oauth/oauth.cjs +13 -0
  25. package/src/lib/data/api/oauth/oauth.d.ts +2 -1
  26. package/src/lib/data/api/oauth/oauth.js +13 -1
  27. package/src/lib/shared/utils/hooks/index.d.ts +1 -0
  28. package/src/lib/shared/utils/hooks/useEffectOnceCondition/index.d.ts +1 -0
  29. package/src/lib/shared/utils/hooks/useEffectOnceCondition/useEffectOnceCondition.cjs +26 -0
  30. package/src/lib/shared/utils/hooks/useEffectOnceCondition/useEffectOnceCondition.d.ts +7 -0
  31. package/src/lib/shared/utils/hooks/useEffectOnceCondition/useEffectOnceCondition.js +22 -0
  32. package/src/lib/styles/index.shadow.cjs +1 -1
  33. package/src/lib/styles/index.shadow.js +1 -1
  34. package/src/lib/utils/functions/index.d.ts +1 -0
  35. package/src/lib/utils/functions/socialStorage/index.d.ts +1 -0
  36. package/src/lib/utils/functions/socialStorage/socialStorage.cjs +36 -0
  37. package/src/lib/utils/functions/socialStorage/socialStorage.d.ts +17 -0
  38. package/src/lib/utils/functions/socialStorage/socialStorage.js +29 -0
  39. package/src/lib/utils/hooks/useSocialAuth/apple/connectWithAppleId.cjs +26 -0
  40. package/src/lib/utils/hooks/useSocialAuth/apple/connectWithAppleId.d.ts +7 -0
  41. package/src/lib/utils/hooks/useSocialAuth/apple/connectWithAppleId.js +22 -0
  42. package/src/lib/utils/hooks/useSocialAuth/apple/loadAppleId.cjs +34 -0
  43. package/src/lib/utils/hooks/useSocialAuth/apple/loadAppleId.d.ts +1 -0
  44. package/src/lib/utils/hooks/useSocialAuth/apple/loadAppleId.js +30 -0
  45. package/src/lib/utils/hooks/useSocialAuth/index.d.ts +1 -1
  46. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +85 -27
  47. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +9 -1
  48. package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +90 -32
  49. package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.cjs +1 -2
  50. package/src/lib/widgets/DynamicEmbeddedWidget/DynamicEmbeddedAuthFlow/DynamicEmbeddedAuthFlow.js +1 -2
package/CHANGELOG.md CHANGED
@@ -1,4 +1,13 @@
1
1
 
2
+ ### [2.6.1](https://github.com/dynamic-labs/DynamicAuth/compare/v2.6.0...v2.6.1) (2024-09-11)
3
+
4
+ ## [2.6.0](https://github.com/dynamic-labs/DynamicAuth/compare/v2.5.3...v2.6.0) (2024-09-03)
5
+
6
+
7
+ ### Features
8
+
9
+ * adds social redirect option and improve apple id login ([#6717](https://github.com/dynamic-labs/DynamicAuth/issues/6717)) ([500e70c](https://github.com/dynamic-labs/DynamicAuth/commit/500e70cb446b75a6264b566c7adc7cd9a0c89264))
10
+
2
11
  ### [2.5.3](https://github.com/dynamic-labs/DynamicAuth/compare/v2.5.2...v2.5.3) (2024-09-02)
3
12
 
4
13
 
package/package.cjs CHANGED
@@ -3,9 +3,9 @@
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
- var version = "2.5.3";
6
+ var version = "2.6.1";
7
7
  var dependencies = {
8
- "@dynamic-labs/sdk-api-core": "0.0.497",
8
+ "@dynamic-labs/sdk-api-core": "0.0.510",
9
9
  "@hcaptcha/react-hcaptcha": "1.4.4",
10
10
  "country-list": "2.3.0",
11
11
  formik: "2.2.9",
package/package.js CHANGED
@@ -1,7 +1,7 @@
1
1
  'use client'
2
- var version = "2.5.3";
2
+ var version = "2.6.1";
3
3
  var dependencies = {
4
- "@dynamic-labs/sdk-api-core": "0.0.497",
4
+ "@dynamic-labs/sdk-api-core": "0.0.510",
5
5
  "@hcaptcha/react-hcaptcha": "1.4.4",
6
6
  "country-list": "2.3.0",
7
7
  formik: "2.2.9",
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@dynamic-labs/sdk-react-core",
3
- "version": "2.5.3",
3
+ "version": "2.6.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
7
7
  "directory": "packages/sdk-react-core"
8
8
  },
9
9
  "dependencies": {
10
- "@dynamic-labs/sdk-api-core": "0.0.497",
10
+ "@dynamic-labs/sdk-api-core": "0.0.510",
11
11
  "@hcaptcha/react-hcaptcha": "1.4.4",
12
12
  "country-list": "2.3.0",
13
13
  "formik": "2.2.9",
@@ -17,18 +17,18 @@
17
17
  "react-i18next": "13.5.0",
18
18
  "yup": "0.32.11",
19
19
  "react-international-phone": "4.2.5",
20
- "@dynamic-labs/iconic": "2.5.3",
21
- "@dynamic-labs/logger": "2.5.3",
22
- "@dynamic-labs/multi-wallet": "2.5.3",
23
- "@dynamic-labs/rpc-provider-ethereum": "2.5.3",
24
- "@dynamic-labs/rpc-provider-solana": "2.5.3",
25
- "@dynamic-labs/rpc-providers": "2.5.3",
26
- "@dynamic-labs/store": "2.5.3",
27
- "@dynamic-labs/types": "2.5.3",
28
- "@dynamic-labs/utils": "2.5.3",
29
- "@dynamic-labs/viem-utils": "2.5.3",
30
- "@dynamic-labs/wallet-book": "2.5.3",
31
- "@dynamic-labs/wallet-connector-core": "2.5.3",
20
+ "@dynamic-labs/iconic": "2.6.1",
21
+ "@dynamic-labs/logger": "2.6.1",
22
+ "@dynamic-labs/multi-wallet": "2.6.1",
23
+ "@dynamic-labs/rpc-provider-ethereum": "2.6.1",
24
+ "@dynamic-labs/rpc-provider-solana": "2.6.1",
25
+ "@dynamic-labs/rpc-providers": "2.6.1",
26
+ "@dynamic-labs/store": "2.6.1",
27
+ "@dynamic-labs/types": "2.6.1",
28
+ "@dynamic-labs/utils": "2.6.1",
29
+ "@dynamic-labs/viem-utils": "2.6.1",
30
+ "@dynamic-labs/wallet-book": "2.6.1",
31
+ "@dynamic-labs/wallet-connector-core": "2.6.1",
32
32
  "eventemitter3": "5.0.1"
33
33
  },
34
34
  "devDependencies": {
@@ -0,0 +1,15 @@
1
+ import { ReactElement } from 'react';
2
+ import { QRCodeErrorCorrectionLevel } from 'qrcode';
3
+ type QRCodeProps = {
4
+ Icon: ReactElement;
5
+ accentColor?: string;
6
+ ecl?: QRCodeErrorCorrectionLevel;
7
+ logoMargin?: number;
8
+ logoSize?: number;
9
+ size?: number;
10
+ value: string;
11
+ walletKey?: string;
12
+ showQrCodeImage?: boolean;
13
+ };
14
+ export declare const QRCode: ({ ecl, Icon, logoMargin, logoSize, size, value, accentColor, walletKey, showQrCodeImage, }: QRCodeProps) => JSX.Element;
15
+ export {};
@@ -108,7 +108,7 @@ const UserProfileSocialAccount = ({ provider, }) => {
108
108
  }, startSlot:
109
109
  // eslint-disable-next-line react/jsx-wrap-multilines
110
110
  jsxRuntime.jsx(Icon.Icon, { color: 'text-tertiary', size: 'small', children: isProviderLinked ? jsxRuntime.jsx(unlink.ReactComponent, {}) : jsxRuntime.jsx(add.ReactComponent, {}) }), children: isProviderLinked ? null : 'Connect' }));
111
- return (jsxRuntime.jsxs("div", { className: 'user-profile-social-account', "data-testid": `social-account-${provider}`, children: [jsxRuntime.jsx("div", { className: 'user-profile-social-account__icon', children: isProviderLinked ? (jsxRuntime.jsx(ConnectedAccountAvatar.ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar })) : (jsxRuntime.jsx(iconic.SocialIcon, { name: provider, variant: iconThemeVariant })) }), jsxRuntime.jsx("div", { className: 'user-profile-social-account__label', children: jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', children: (_a = connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.publicIdentifier) !== null && _a !== void 0 ? _a : providerLabel.providerLabel(getSocialSignInProviderForProviderEnum.getSocialSignInProviderForProviderEnum(provider)) }) }), !isActiveCredential ? renderButton() : null] }));
111
+ return (jsxRuntime.jsxs("div", { className: 'user-profile-social-account', "data-testid": `social-account-${provider}`, children: [jsxRuntime.jsx("div", { className: 'user-profile-social-account__icon', children: isProviderLinked ? (jsxRuntime.jsx(ConnectedAccountAvatar.ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar })) : (jsxRuntime.jsx(iconic.SocialIcon, { name: provider, variant: iconThemeVariant })) }), jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', truncate: true, className: 'user-profile-social-account__label', children: (_a = connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.publicIdentifier) !== null && _a !== void 0 ? _a : providerLabel.providerLabel(getSocialSignInProviderForProviderEnum.getSocialSignInProviderForProviderEnum(provider)) }), !isActiveCredential ? renderButton() : null] }));
112
112
  };
113
113
 
114
114
  exports.UserProfileSocialAccount = UserProfileSocialAccount;
@@ -104,7 +104,7 @@ const UserProfileSocialAccount = ({ provider, }) => {
104
104
  }, startSlot:
105
105
  // eslint-disable-next-line react/jsx-wrap-multilines
106
106
  jsx(Icon, { color: 'text-tertiary', size: 'small', children: isProviderLinked ? jsx(SvgUnlink, {}) : jsx(SvgAdd, {}) }), children: isProviderLinked ? null : 'Connect' }));
107
- return (jsxs("div", { className: 'user-profile-social-account', "data-testid": `social-account-${provider}`, children: [jsx("div", { className: 'user-profile-social-account__icon', children: isProviderLinked ? (jsx(ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar })) : (jsx(SocialIcon, { name: provider, variant: iconThemeVariant })) }), jsx("div", { className: 'user-profile-social-account__label', children: jsx(Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', children: (_a = connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.publicIdentifier) !== null && _a !== void 0 ? _a : providerLabel(getSocialSignInProviderForProviderEnum(provider)) }) }), !isActiveCredential ? renderButton() : null] }));
107
+ return (jsxs("div", { className: 'user-profile-social-account', "data-testid": `social-account-${provider}`, children: [jsx("div", { className: 'user-profile-social-account__icon', children: isProviderLinked ? (jsx(ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar })) : (jsx(SocialIcon, { name: provider, variant: iconThemeVariant })) }), jsx(Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', truncate: true, className: 'user-profile-social-account__label', children: (_a = connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.publicIdentifier) !== null && _a !== void 0 ? _a : providerLabel(getSocialSignInProviderForProviderEnum(provider)) }), !isActiveCredential ? renderButton() : null] }));
108
108
  };
109
109
 
110
110
  export { UserProfileSocialAccount };
@@ -7,35 +7,21 @@ var sdkApiCore = require('@dynamic-labs/sdk-api-core');
7
7
  class ApiEndpoint {
8
8
  }
9
9
  ApiEndpoint.getBaseUrl = () => {
10
- if (!ApiEndpoint.__defined__) {
10
+ if (!ApiEndpoint.__baseUrl__) {
11
11
  throw new Error('ApiEndpoint Base URL has not been initialized');
12
12
  }
13
13
  return ApiEndpoint.__baseUrl__;
14
14
  };
15
15
  ApiEndpoint.setBaseUrl = (baseUrlInput) => {
16
- if (!ApiEndpoint.__defined__) {
17
- if (!baseUrlInput) {
18
- /**
19
- * If the baseUrl is not provided, use the default baseUrl from the sdk-api package
20
- */
21
- ApiEndpoint.__baseUrl__ = new sdkApiCore.Configuration().basePath;
22
- }
23
- else {
24
- ApiEndpoint.__baseUrl__ = baseUrlInput;
25
- }
26
- ApiEndpoint.__defined__ = true;
27
- }
28
- else if (!baseUrlInput && ApiEndpoint.__defined__) {
16
+ if (!baseUrlInput) {
29
17
  /**
30
- * If for some reason (usually in local development), the setBaseUrl is called multiple times with undefined
31
- * And we already have it defined, let's just assume it's a no-op
18
+ * If the baseUrl is not provided, use the default baseUrl from the sdk-api package
32
19
  */
33
- return;
20
+ ApiEndpoint.__baseUrl__ = new sdkApiCore.Configuration().basePath;
34
21
  }
35
- else if (ApiEndpoint.__baseUrl__ !== baseUrlInput) {
36
- throw new Error(`ApiEndpoint baseUrl is already set to ${ApiEndpoint.__baseUrl__}, cannot change it to ${baseUrlInput}`);
22
+ else {
23
+ ApiEndpoint.__baseUrl__ = baseUrlInput;
37
24
  }
38
- Object.freeze(ApiEndpoint);
39
25
  };
40
26
 
41
27
  module.exports = ApiEndpoint;
@@ -1,7 +1,6 @@
1
1
  declare class ApiEndpoint {
2
2
  private static __baseUrl__;
3
- private static __defined__;
4
- static getBaseUrl: () => string | undefined;
3
+ static getBaseUrl: () => string;
5
4
  static setBaseUrl: (baseUrlInput?: string) => void;
6
5
  }
7
6
  export default ApiEndpoint;
@@ -5,35 +5,21 @@ import { Configuration } from '@dynamic-labs/sdk-api-core';
5
5
  class ApiEndpoint {
6
6
  }
7
7
  ApiEndpoint.getBaseUrl = () => {
8
- if (!ApiEndpoint.__defined__) {
8
+ if (!ApiEndpoint.__baseUrl__) {
9
9
  throw new Error('ApiEndpoint Base URL has not been initialized');
10
10
  }
11
11
  return ApiEndpoint.__baseUrl__;
12
12
  };
13
13
  ApiEndpoint.setBaseUrl = (baseUrlInput) => {
14
- if (!ApiEndpoint.__defined__) {
15
- if (!baseUrlInput) {
16
- /**
17
- * If the baseUrl is not provided, use the default baseUrl from the sdk-api package
18
- */
19
- ApiEndpoint.__baseUrl__ = new Configuration().basePath;
20
- }
21
- else {
22
- ApiEndpoint.__baseUrl__ = baseUrlInput;
23
- }
24
- ApiEndpoint.__defined__ = true;
25
- }
26
- else if (!baseUrlInput && ApiEndpoint.__defined__) {
14
+ if (!baseUrlInput) {
27
15
  /**
28
- * If for some reason (usually in local development), the setBaseUrl is called multiple times with undefined
29
- * And we already have it defined, let's just assume it's a no-op
16
+ * If the baseUrl is not provided, use the default baseUrl from the sdk-api package
30
17
  */
31
- return;
18
+ ApiEndpoint.__baseUrl__ = new Configuration().basePath;
32
19
  }
33
- else if (ApiEndpoint.__baseUrl__ !== baseUrlInput) {
34
- throw new Error(`ApiEndpoint baseUrl is already set to ${ApiEndpoint.__baseUrl__}, cannot change it to ${baseUrlInput}`);
20
+ else {
21
+ ApiEndpoint.__baseUrl__ = baseUrlInput;
35
22
  }
36
- Object.freeze(ApiEndpoint);
37
23
  };
38
24
 
39
25
  export { ApiEndpoint as default };
@@ -565,6 +565,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
565
565
  socialMediaLinkText,
566
566
  socialMediaUrl,
567
567
  socialProvidersFilter,
568
+ socialSettings: settings$1.social,
568
569
  tabsItems,
569
570
  termsOfServiceUrl,
570
571
  theme,
@@ -646,6 +647,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
646
647
  removeConnectedWalletsInfo,
647
648
  rpcProviders,
648
649
  sdkHasLoaded,
650
+ settings$1.social,
649
651
  secondaryWallets,
650
652
  selectedTabIndex,
651
653
  selectedTabSettings,
@@ -9,6 +9,7 @@ import { DynamicHandlers } from '../../shared/types/dynamicHandlers';
9
9
  import { SocialNetworkIconType } from '../../utils/functions/getSocialNetworkIcon';
10
10
  import { ThemeData, ThemeSetting } from '../ThemeContext';
11
11
  import { ChainsToConnect, IDynamicContext, NetworkValidationMode, SettingsOverrides } from './types';
12
+ import { SocialSettings } from './types/SocialSettings';
12
13
  export declare const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = "2762a57b-faa4-41ce-9f16-abff9300e2c9";
13
14
  export interface DynamicContextProps {
14
15
  children: ReactNode;
@@ -41,6 +42,7 @@ export interface DynamicContextProps {
41
42
  enableConnectOnlyFallback?: boolean;
42
43
  enableVisitTrackingOnConnectOnly?: boolean;
43
44
  environmentId: string;
45
+ social?: SocialSettings;
44
46
  /**
45
47
  * @deprecated Use events instead
46
48
  */
@@ -561,6 +561,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
561
561
  socialMediaLinkText,
562
562
  socialMediaUrl,
563
563
  socialProvidersFilter,
564
+ socialSettings: settings.social,
564
565
  tabsItems,
565
566
  termsOfServiceUrl,
566
567
  theme,
@@ -642,6 +643,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, enable
642
643
  removeConnectedWalletsInfo,
643
644
  rpcProviders,
644
645
  sdkHasLoaded,
646
+ settings.social,
645
647
  secondaryWallets,
646
648
  selectedTabIndex,
647
649
  selectedTabSettings,
@@ -0,0 +1,7 @@
1
+ export type SocialSettings = {
2
+ /**
3
+ * @description The strategy to use for social auth.
4
+ * @default 'redirect'
5
+ */
6
+ strategy?: 'popup' | 'redirect';
7
+ };
@@ -14,6 +14,7 @@ import { ThemeData, ThemeSetting } from '../../ThemeContext';
14
14
  import { DisplayOrder, SetDisplayOrderPriority, SetShowAuthFlow } from '../hooks';
15
15
  import { SetCallbackType } from '../useCustomerCallbacks';
16
16
  import { SetUserAction } from '../../../store';
17
+ import { SocialSettings } from './SocialSettings';
17
18
  export type ChainsToConnect = {
18
19
  chain: Chain;
19
20
  chainId?: number;
@@ -67,6 +68,7 @@ export interface IDynamicContext {
67
68
  accessDeniedMessagePrimary?: string;
68
69
  accessDeniedMessageSecondary?: string;
69
70
  accountSwitchState: AccountSwitchState;
71
+ socialSettings?: SocialSettings;
70
72
  appLogoUrl?: string;
71
73
  appName?: string;
72
74
  defaultPhoneInputIso2?: CountryIso2;
@@ -80,6 +80,7 @@ require('../PasskeyContext/PasskeyContext.cjs');
80
80
  require('../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
81
81
  require('../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
82
82
  require('../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
83
+ var useRedirectSocialHandler = require('./hooks/useRedirectSocialHandler/useRedirectSocialHandler.cjs');
83
84
 
84
85
  const SocialRedirectContext = React.createContext(undefined);
85
86
  const SocialRedirectContextProvider = ({ children, }) => {
@@ -252,6 +253,9 @@ const SocialRedirectContextProvider = ({ children, }) => {
252
253
  primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id,
253
254
  getCaptchaToken,
254
255
  ]);
256
+ useRedirectSocialHandler.useRedirectSocialHandler({
257
+ setSocialProvider,
258
+ });
255
259
  return (jsxRuntime.jsx(SocialRedirectContext.Provider, { value: {
256
260
  enabledSocialProviders,
257
261
  redirectStatus,
@@ -76,6 +76,7 @@ import '../PasskeyContext/PasskeyContext.js';
76
76
  import '../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.js';
77
77
  import '../../views/TransactionConfirmationView/helpers/transactionErrorMessage.js';
78
78
  import '../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.js';
79
+ import { useRedirectSocialHandler } from './hooks/useRedirectSocialHandler/useRedirectSocialHandler.js';
79
80
 
80
81
  const SocialRedirectContext = createContext(undefined);
81
82
  const SocialRedirectContextProvider = ({ children, }) => {
@@ -248,6 +249,9 @@ const SocialRedirectContextProvider = ({ children, }) => {
248
249
  primaryWallet === null || primaryWallet === void 0 ? void 0 : primaryWallet.id,
249
250
  getCaptchaToken,
250
251
  ]);
252
+ useRedirectSocialHandler({
253
+ setSocialProvider,
254
+ });
251
255
  return (jsx(SocialRedirectContext.Provider, { value: {
252
256
  enabledSocialProviders,
253
257
  redirectStatus,
@@ -0,0 +1 @@
1
+ export { useRedirectSocialHandler } from './useRedirectSocialHandler';
@@ -0,0 +1,150 @@
1
+ 'use client'
2
+ 'use strict';
3
+
4
+ Object.defineProperty(exports, '__esModule', { value: true });
5
+
6
+ var _tslib = require('../../../../../../_virtual/_tslib.cjs');
7
+ var React = require('react');
8
+ require('@dynamic-labs/sdk-api-core');
9
+ require('../../../../shared/logger.cjs');
10
+ require('@dynamic-labs/iconic');
11
+ require('@dynamic-labs/wallet-connector-core');
12
+ require('react/jsx-runtime');
13
+ var ViewContext = require('../../../ViewContext/ViewContext.cjs');
14
+ require('@dynamic-labs/wallet-book');
15
+ var isSSR = require('../../../../shared/utils/functions/isSSR/isSSR.cjs');
16
+ require('../../../../utils/constants/colors.cjs');
17
+ require('../../../../utils/constants/values.cjs');
18
+ require('../../../../shared/utils/classes/storage/localStorage.cjs');
19
+ var useEffectOnce = require('../../../../shared/utils/hooks/useEffectOnce/useEffectOnce.cjs');
20
+ require('@dynamic-labs/logger');
21
+ require('@dynamic-labs/utils');
22
+ var useEffectOnceCondition = require('../../../../shared/utils/hooks/useEffectOnceCondition/useEffectOnceCondition.cjs');
23
+ require('../../../../shared/consts/index.cjs');
24
+ require('../../../DynamicContext/DynamicContext.cjs');
25
+ require('../../../../events/dynamicEvents.cjs');
26
+ require('../../../CaptchaContext/CaptchaContext.cjs');
27
+ require('../../../ErrorContext/ErrorContext.cjs');
28
+ require('@dynamic-labs/multi-wallet');
29
+ require('react-international-phone');
30
+ var getSocialSignInProviderForProviderEnum = require('../../../../utils/functions/getSocialSignInProviderForProviderEnum/getSocialSignInProviderForProviderEnum.cjs');
31
+ require('viem');
32
+ require('viem/chains');
33
+ require('../../../../config/ApiEndpoint.cjs');
34
+ require('@dynamic-labs/store');
35
+ require('../../../../locale/locale.cjs');
36
+ var socialStorage = require('../../../../utils/functions/socialStorage/socialStorage.cjs');
37
+ require('../../../AccessDeniedContext/AccessDeniedContext.cjs');
38
+ require('../../../AccountExistsContext/AccountExistsContext.cjs');
39
+ require('../../../UserWalletsContext/UserWalletsContext.cjs');
40
+ require('../../../VerificationContext/VerificationContext.cjs');
41
+ require('react-dom');
42
+ require('../../../WalletContext/WalletContext.cjs');
43
+ require('../../../ThemeContext/ThemeContext.cjs');
44
+ require('../../../../utils/hooks/useUserUpdateRequest/useUpdateUser/userFieldsSchema.cjs');
45
+ require('@dynamic-labs/types');
46
+ var useSocialAuth = require('../../../../utils/hooks/useSocialAuth/useSocialAuth.cjs');
47
+ require('yup');
48
+ require('../../../MockContext/MockContext.cjs');
49
+ require('../../../../views/CollectUserDataView/useFields.cjs');
50
+ require('../../../FieldsStateContext/FieldsStateContext.cjs');
51
+ require('../../../UserFieldEditorContext/UserFieldEditorContext.cjs');
52
+ require('@dynamic-labs/rpc-providers');
53
+ require('react-i18next');
54
+ require('../../../../components/Accordion/components/AccordionItem/AccordionItem.cjs');
55
+ require('../../../../components/Alert/Alert.cjs');
56
+ require('../../../../components/ShadowDOM/ShadowDOM.cjs');
57
+ require('../../../../components/IconButton/IconButton.cjs');
58
+ require('../../../../components/InlineWidget/InlineWidget.cjs');
59
+ require('../../../../components/Input/Input.cjs');
60
+ require('../../../../components/IsBrowser/IsBrowser.cjs');
61
+ require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
62
+ require('../../../../components/Transition/ZoomTransition/ZoomTransition.cjs');
63
+ require('../../../../components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
64
+ require('../../../../components/Transition/OpacityTransition/OpacityTransition.cjs');
65
+ require('../../../../components/OverlayCard/OverlayCardTarget/OverlayCardTarget.cjs');
66
+ require('../../../../components/PasskeyCreatedSuccessBanner/PasskeyCreatedSuccessBanner.cjs');
67
+ require('../../../../components/Popper/Popper/Popper.cjs');
68
+ require('../../../../components/Popper/PopperContext/PopperContext.cjs');
69
+ require('react-focus-lock');
70
+ require('qrcode');
71
+ require('formik');
72
+ require('../../../../views/WalletList/WalletList.cjs');
73
+ require('../../SocialRedirectContext.cjs');
74
+ require('../../../../widgets/DynamicBridgeWidget/views/WalletsView/components/SecondaryWallets/SecondaryWallets.cjs');
75
+ require('@hcaptcha/react-hcaptcha');
76
+ require('../../../LoadingContext/LoadingContext.cjs');
77
+ var DynamicWidgetContext = require('../../../../widgets/DynamicWidget/context/DynamicWidgetContext.cjs');
78
+ require('../../../FooterAnimationContext/index.cjs');
79
+ require('../../../WalletGroupContext/WalletGroupContext.cjs');
80
+ require('../../../MfaSettingsContext/MfaSettingsContext.cjs');
81
+ require('../../../IpConfigurationContext/IpConfigurationContext.cjs');
82
+ require('../../../PasskeyContext/PasskeyContext.cjs');
83
+ require('../../../../widgets/DynamicWidget/components/DynamicWidgetHeader/DynamicWidgetHeader.cjs');
84
+ require('../../../../views/TransactionConfirmationView/helpers/transactionErrorMessage.cjs');
85
+ require('../../../../widgets/DynamicWidget/views/ManagePasskeysWidgetView/PasskeyCard/PasskeyCard.cjs');
86
+ var useInternalDynamicContext = require('../../../DynamicContext/useDynamicContext/useInternalDynamicContext.cjs');
87
+
88
+ const useRedirectSocialHandler = ({ setSocialProvider, }) => {
89
+ const { setView } = ViewContext.useViewContext();
90
+ const { setDynamicWidgetView } = DynamicWidgetContext.useWidgetContext();
91
+ const [socialStorageItem, setSocialStorageItem] = React.useState(null);
92
+ const { sdkHasLoaded, user, setShowAuthFlow, isRenderingEmbeddedAuthFlow, setShowDynamicUserProfile, } = useInternalDynamicContext.useInternalDynamicContext();
93
+ const { completeConnection } = useSocialAuth.useSocialAuth({
94
+ sessionTimeout: 10000,
95
+ });
96
+ const updateInterfaceStateForSignIn = React.useCallback((socialStorageItem) => {
97
+ const socialSignInProvider = getSocialSignInProviderForProviderEnum.getSocialSignInProviderForProviderEnum(socialStorageItem.provider);
98
+ setSocialProvider(socialSignInProvider);
99
+ setView('social-redirect-view');
100
+ // Only open the auth flow when the embedded widget is not rendered
101
+ if (!isRenderingEmbeddedAuthFlow.current) {
102
+ setShowAuthFlow(true);
103
+ }
104
+ }, [setSocialProvider, setView, isRenderingEmbeddedAuthFlow, setShowAuthFlow]);
105
+ const updateInterfaceStateForLink = React.useCallback(() => {
106
+ setDynamicWidgetView('profile');
107
+ setShowDynamicUserProfile(true);
108
+ }, [setDynamicWidgetView, setShowDynamicUserProfile]);
109
+ useEffectOnce.useEffectOnce(() => {
110
+ // Do not run on server side
111
+ if (isSSR.isSSR())
112
+ return;
113
+ const url = new URL(window.location.href);
114
+ const dynamicOauthState = url.searchParams.get('dynamicOauthState');
115
+ const dynamicOauthCode = url.searchParams.get('dynamicOauthCode');
116
+ if (!dynamicOauthState || !dynamicOauthCode) {
117
+ return;
118
+ }
119
+ const socialStorageItem = socialStorage.searchSocialStorageByState(dynamicOauthState);
120
+ if (!socialStorageItem)
121
+ return;
122
+ // we got back the dynamicOauthCode from the oauth provider, set it here so we can use it to sign in
123
+ socialStorageItem.code = dynamicOauthCode;
124
+ setSocialStorageItem(socialStorageItem);
125
+ // Clear the state from local storage
126
+ socialStorage.deleteSocialStorage(socialStorageItem.provider);
127
+ });
128
+ useEffectOnceCondition.useEffectOnceCondition(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
129
+ if (!socialStorageItem)
130
+ return;
131
+ const authMode = user ? 'link' : 'signin';
132
+ // Update UI to reflect the original state
133
+ if (authMode === 'signin') {
134
+ updateInterfaceStateForSignIn(socialStorageItem);
135
+ }
136
+ else if (authMode === 'link') {
137
+ updateInterfaceStateForLink();
138
+ }
139
+ yield completeConnection({
140
+ authCode: socialStorageItem.code,
141
+ authMode,
142
+ captchaToken: socialStorageItem.captchaToken,
143
+ provider: socialStorageItem.provider,
144
+ state: socialStorageItem.state,
145
+ verifier: socialStorageItem.codeVerifier,
146
+ });
147
+ }), Boolean(socialStorageItem) && sdkHasLoaded);
148
+ };
149
+
150
+ exports.useRedirectSocialHandler = useRedirectSocialHandler;
@@ -0,0 +1,7 @@
1
+ import { Dispatch, SetStateAction } from 'react';
2
+ import { SocialSignInProviderEnum } from '@dynamic-labs/sdk-api-core';
3
+ type UseRedirectSocialHandlerProps = {
4
+ setSocialProvider: Dispatch<SetStateAction<SocialSignInProviderEnum | undefined>>;
5
+ };
6
+ export declare const useRedirectSocialHandler: ({ setSocialProvider, }: UseRedirectSocialHandlerProps) => void;
7
+ export {};