@dynamic-labs/sdk-react-core 2.1.0-alpha.5 → 2.1.0-alpha.7
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 +14 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +12 -12
- package/src/index.cjs +6 -0
- package/src/index.d.ts +1 -0
- package/src/index.js +3 -0
- package/src/lib/Main.cjs +2 -0
- package/src/lib/Main.js +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.cjs +17 -5
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +5 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +14 -2
- package/src/lib/context/ErrorBoundary/ErrorBoundary.cjs +64 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundary.d.ts +3 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundary.js +60 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryBase.cjs +40 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryBase.d.ts +14 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryBase.js +36 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryContext.cjs +24 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryContext.d.ts +5 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryContext.js +18 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryExclude.cjs +17 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryExclude.d.ts +4 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryExclude.js +13 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryInclude.cjs +17 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryInclude.d.ts +4 -0
- package/src/lib/context/ErrorBoundary/ErrorBoundaryInclude.js +13 -0
- package/src/lib/context/ErrorBoundary/index.d.ts +3 -0
- package/src/lib/context/ErrorBoundary/types.d.ts +13 -0
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.cjs +27 -34
- package/src/lib/utils/hooks/useEmbeddedWallet/useSecureEnclaveEmbeddedWallet/useSecureEnclaveEmbeddedWallet.js +28 -35
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.1.0-alpha.7](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.6...v2.1.0-alpha.7) (2024-04-25)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* restore embedded wallet session iframe element conflict ([#5474](https://github.com/dynamic-labs/DynamicAuth/issues/5474)) ([c157477](https://github.com/dynamic-labs/DynamicAuth/commit/c157477ea126b3130b13b711796bdd06215e7af1))
|
|
8
|
+
|
|
9
|
+
## [2.1.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.5...v2.1.0-alpha.6) (2024-04-24)
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* embedded wallets headless session control fixes ([#5469](https://github.com/dynamic-labs/DynamicAuth/issues/5469)) ([92e6c35](https://github.com/dynamic-labs/DynamicAuth/commit/92e6c359d2710fd4f5f5a6fedc4acf6c4bab78ba))
|
|
15
|
+
|
|
2
16
|
## [2.1.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.4...v2.1.0-alpha.5) (2024-04-23)
|
|
3
17
|
|
|
4
18
|
|
package/package.cjs
CHANGED
package/package.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.7",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -17,17 +17,17 @@
|
|
|
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.1.0-alpha.
|
|
21
|
-
"@dynamic-labs/logger": "2.1.0-alpha.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "2.1.0-alpha.
|
|
23
|
-
"@dynamic-labs/rpc-provider-ethereum": "2.1.0-alpha.
|
|
24
|
-
"@dynamic-labs/rpc-provider-solana": "2.1.0-alpha.
|
|
25
|
-
"@dynamic-labs/rpc-providers": "2.1.0-alpha.
|
|
26
|
-
"@dynamic-labs/types": "2.1.0-alpha.
|
|
27
|
-
"@dynamic-labs/utils": "2.1.0-alpha.
|
|
28
|
-
"@dynamic-labs/viem-utils": "2.1.0-alpha.
|
|
29
|
-
"@dynamic-labs/wallet-book": "2.1.0-alpha.
|
|
30
|
-
"@dynamic-labs/wallet-connector-core": "2.1.0-alpha.
|
|
20
|
+
"@dynamic-labs/iconic": "2.1.0-alpha.7",
|
|
21
|
+
"@dynamic-labs/logger": "2.1.0-alpha.7",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "2.1.0-alpha.7",
|
|
23
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.1.0-alpha.7",
|
|
24
|
+
"@dynamic-labs/rpc-provider-solana": "2.1.0-alpha.7",
|
|
25
|
+
"@dynamic-labs/rpc-providers": "2.1.0-alpha.7",
|
|
26
|
+
"@dynamic-labs/types": "2.1.0-alpha.7",
|
|
27
|
+
"@dynamic-labs/utils": "2.1.0-alpha.7",
|
|
28
|
+
"@dynamic-labs/viem-utils": "2.1.0-alpha.7",
|
|
29
|
+
"@dynamic-labs/wallet-book": "2.1.0-alpha.7",
|
|
30
|
+
"@dynamic-labs/wallet-connector-core": "2.1.0-alpha.7",
|
|
31
31
|
"eventemitter3": "5.0.1"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
package/src/index.cjs
CHANGED
|
@@ -8,6 +8,9 @@ var version = require('./version.cjs');
|
|
|
8
8
|
var data = require('./lib/views/WalletList/data.cjs');
|
|
9
9
|
var getAuthToken = require('./lib/utils/functions/getAuthToken/getAuthToken.cjs');
|
|
10
10
|
var DynamicContext = require('./lib/context/DynamicContext/DynamicContext.cjs');
|
|
11
|
+
var ErrorBoundary = require('./lib/context/ErrorBoundary/ErrorBoundary.cjs');
|
|
12
|
+
var ErrorBoundaryExclude = require('./lib/context/ErrorBoundary/ErrorBoundaryExclude.cjs');
|
|
13
|
+
var ErrorBoundaryInclude = require('./lib/context/ErrorBoundary/ErrorBoundaryInclude.cjs');
|
|
11
14
|
var useDynamicContext = require('./lib/context/DynamicContext/useDynamicContext/useDynamicContext.cjs');
|
|
12
15
|
require('react');
|
|
13
16
|
var useDynamicScopes = require('./lib/utils/hooks/useDynamicScopes/useDynamicScopes.cjs');
|
|
@@ -149,6 +152,9 @@ exports.getWallets = data.getWallets;
|
|
|
149
152
|
exports.getAuthToken = getAuthToken.getAuthToken;
|
|
150
153
|
exports.DynamicContext = DynamicContext.DynamicContext;
|
|
151
154
|
exports.DynamicContextProvider = DynamicContext.DynamicContextProvider;
|
|
155
|
+
exports.ErrorBoundary = ErrorBoundary.ErrorBoundary;
|
|
156
|
+
exports.ErrorBoundaryExclude = ErrorBoundaryExclude.ErrorBoundaryExclude;
|
|
157
|
+
exports.ErrorBoundaryInclude = ErrorBoundaryInclude.ErrorBoundaryInclude;
|
|
152
158
|
exports.useDynamicContext = useDynamicContext.useDynamicContext;
|
|
153
159
|
exports.useDynamicScopes = useDynamicScopes.useDynamicScopes;
|
|
154
160
|
exports.useUserWallets = UserWalletsContext.useUserWallets;
|
package/src/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ export { VERSION } from './version';
|
|
|
3
3
|
export { getWallets } from './lib/views/WalletList/data';
|
|
4
4
|
export { getAuthToken } from './lib/utils/functions/getAuthToken';
|
|
5
5
|
export { DynamicContextProvider, DynamicContext, } from './lib/context/DynamicContext';
|
|
6
|
+
export { ErrorBoundary, ErrorBoundaryInclude, ErrorBoundaryExclude, } from './lib/context/ErrorBoundary';
|
|
6
7
|
export type { DynamicContextProps } from './lib/context/DynamicContext';
|
|
7
8
|
export { useDynamicContext } from './lib/context/DynamicContext/useDynamicContext';
|
|
8
9
|
export { useDynamicScopes } from './lib/utils/hooks/useDynamicScopes';
|
package/src/index.js
CHANGED
|
@@ -4,6 +4,9 @@ export { VERSION } from './version.js';
|
|
|
4
4
|
export { getWallets } from './lib/views/WalletList/data.js';
|
|
5
5
|
export { getAuthToken } from './lib/utils/functions/getAuthToken/getAuthToken.js';
|
|
6
6
|
export { DynamicContext, DynamicContextProvider } from './lib/context/DynamicContext/DynamicContext.js';
|
|
7
|
+
export { ErrorBoundary } from './lib/context/ErrorBoundary/ErrorBoundary.js';
|
|
8
|
+
export { ErrorBoundaryExclude } from './lib/context/ErrorBoundary/ErrorBoundaryExclude.js';
|
|
9
|
+
export { ErrorBoundaryInclude } from './lib/context/ErrorBoundary/ErrorBoundaryInclude.js';
|
|
7
10
|
export { useDynamicContext } from './lib/context/DynamicContext/useDynamicContext/useDynamicContext.js';
|
|
8
11
|
import 'react';
|
|
9
12
|
export { useDynamicScopes } from './lib/utils/hooks/useDynamicScopes/useDynamicScopes.js';
|
package/src/lib/Main.cjs
CHANGED
|
@@ -23,6 +23,8 @@ var localStorage = require('./shared/utils/classes/storage/localStorage.cjs');
|
|
|
23
23
|
var usePreventPageScroll = require('./shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.cjs');
|
|
24
24
|
var index$1 = require('./shared/consts/index.cjs');
|
|
25
25
|
require('./context/DynamicContext/DynamicContext.cjs');
|
|
26
|
+
require('./context/ErrorBoundary/ErrorBoundaryBase.cjs');
|
|
27
|
+
require('./context/ErrorBoundary/ErrorBoundaryContext.cjs');
|
|
26
28
|
var dynamicEvents = require('./events/dynamicEvents.cjs');
|
|
27
29
|
require('./context/CaptchaContext/CaptchaContext.cjs');
|
|
28
30
|
require('./context/ErrorContext/ErrorContext.cjs');
|
package/src/lib/Main.js
CHANGED
|
@@ -19,6 +19,8 @@ import { LocalStorage } from './shared/utils/classes/storage/localStorage.js';
|
|
|
19
19
|
import { usePreventPageScroll } from './shared/utils/hooks/usePreventPageScroll/usePreventPageScroll.js';
|
|
20
20
|
import { authModalZIndex } from './shared/consts/index.js';
|
|
21
21
|
import './context/DynamicContext/DynamicContext.js';
|
|
22
|
+
import './context/ErrorBoundary/ErrorBoundaryBase.js';
|
|
23
|
+
import './context/ErrorBoundary/ErrorBoundaryContext.js';
|
|
22
24
|
import { dynamicEvents } from './events/dynamicEvents.js';
|
|
23
25
|
import './context/CaptchaContext/CaptchaContext.js';
|
|
24
26
|
import './context/ErrorContext/ErrorContext.js';
|
|
@@ -8,6 +8,7 @@ var jsxRuntime = require('react/jsx-runtime');
|
|
|
8
8
|
var React = require('react');
|
|
9
9
|
var reactI18next = require('react-i18next');
|
|
10
10
|
var iconic = require('@dynamic-labs/iconic');
|
|
11
|
+
var logger = require('@dynamic-labs/logger');
|
|
11
12
|
var utils = require('@dynamic-labs/utils');
|
|
12
13
|
var walletBook = require('@dynamic-labs/wallet-book');
|
|
13
14
|
var walletConnectorCore = require('@dynamic-labs/wallet-connector-core');
|
|
@@ -15,7 +16,7 @@ var app = require('../../app.cjs');
|
|
|
15
16
|
require('../../events/dynamicEvents.cjs');
|
|
16
17
|
var decodeJwt = require('../../shared/utils/functions/decodeJwt/decodeJwt.cjs');
|
|
17
18
|
require('@dynamic-labs/sdk-api-core');
|
|
18
|
-
var logger = require('../../shared/logger.cjs');
|
|
19
|
+
var logger$1 = require('../../shared/logger.cjs');
|
|
19
20
|
var ViewContext = require('../ViewContext/ViewContext.cjs');
|
|
20
21
|
var localStorage$1 = require('../../utils/constants/localStorage.cjs');
|
|
21
22
|
require('../../utils/constants/colors.cjs');
|
|
@@ -110,6 +111,9 @@ var FundingContext = require('../FundingContext/FundingContext.cjs');
|
|
|
110
111
|
var PhantomRedirectContext = require('../PhantomRedirectContext/PhantomRedirectContext.cjs');
|
|
111
112
|
var SendBalanceContext = require('../SendBalanceContext/SendBalanceContext.cjs');
|
|
112
113
|
var UseNetworkValidation = require('../UseNetworkValidation/UseNetworkValidation.cjs');
|
|
114
|
+
var ErrorBoundary = require('../ErrorBoundary/ErrorBoundary.cjs');
|
|
115
|
+
var ErrorBoundaryExclude = require('../ErrorBoundary/ErrorBoundaryExclude.cjs');
|
|
116
|
+
require('../ErrorBoundary/ErrorBoundaryBase.cjs');
|
|
113
117
|
var helpers = require('./helpers/helpers.cjs');
|
|
114
118
|
var useDisplayOrderState = require('./hooks/useDisplayOrderState/useDisplayOrderState.cjs');
|
|
115
119
|
var useEmailLoginState = require('./hooks/useEmailLoginState/useEmailLoginState.cjs');
|
|
@@ -146,10 +150,10 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
146
150
|
if (!environmentId) {
|
|
147
151
|
throw new utils.MissingEnvironmentIdError();
|
|
148
152
|
}
|
|
149
|
-
logger.logger.setLogLevel(logLevel);
|
|
153
|
+
logger$1.logger.setLogLevel(logLevel);
|
|
150
154
|
walletConnectorCore.logger.setLogLevel(logLevel);
|
|
151
155
|
if (environmentId === PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID) {
|
|
152
|
-
logger.logger.warn(`WARNING: DYNAMIC is using a test environment ID ${environmentId}. Please sign up on https://app.dynamic.xyz/ to get your production environment ID.`);
|
|
156
|
+
logger$1.logger.warn(`WARNING: DYNAMIC is using a test environment ID ${environmentId}. Please sign up on https://app.dynamic.xyz/ to get your production environment ID.`);
|
|
153
157
|
}
|
|
154
158
|
ApiEndpoint.setBaseUrl((_b = process.env.DYNAMIC_API_BASE_URL) !== null && _b !== void 0 ? _b : apiBaseUrl);
|
|
155
159
|
localStorage.LocalStorage.setSuffix(localStorageSuffix);
|
|
@@ -167,6 +171,12 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
167
171
|
const [showBridgeWidget, setShowBridgeWidget] = React.useState(false);
|
|
168
172
|
const [isSingleWalletAccount, setIsSingleWalletAccount] = React.useState(false);
|
|
169
173
|
const [user, setUser, removeUser] = useLocalStorage.useLocalStorage(localStorage$1.AUTH_USER, EMPTY_INITIAL_USER, validators.validateAuthUser, [localStorage$1.AUTH_TOKEN]);
|
|
174
|
+
if (user) {
|
|
175
|
+
logger$1.logger.setMetaData('user', user);
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
logger$1.logger.setMetaData('user', undefined);
|
|
179
|
+
}
|
|
170
180
|
const { consumeNonce } = useFetchNonce.useFetchNonce(environmentId);
|
|
171
181
|
const [qrcodeUri, setQrcodeUri] = React.useState('');
|
|
172
182
|
const [desktopUri, setDesktopUri] = React.useState('');
|
|
@@ -676,12 +686,14 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
676
686
|
isAuthenticated: isAuthenticated || Boolean(primaryWallet),
|
|
677
687
|
isBridgeFlow,
|
|
678
688
|
isMultiWalletEnabled: multiWallet,
|
|
679
|
-
}), children: [networkValidationMode === 'always' && jsxRuntime.jsx(UseNetworkValidation.UseNetworkValidation, {}), jsxRuntime.jsx(CaptchaContext.CaptchaContextProvider, { children: jsxRuntime.jsx(AccountExistsContext.AccountExistsContextProvider, { children: jsxRuntime.jsx(WalletContext.WalletContextProvider, { canSync: didConnectedStateLoad, children: jsxRuntime.jsx(PasskeyContext.PasskeyContextProvider, { children: jsxRuntime.jsx(VerificationContext.VerificationProvider, { children: jsxRuntime.jsx(DynamicWidgetContext.DynamicWidgetContextProvider, { children: jsxRuntime.jsx(DynamicBridgeWidgetContext.DynamicBridgeWidgetContextProvider, { children: jsxRuntime.jsx(FundingContext.FundingContextProvider, { children: jsxRuntime.jsx(AccessDeniedContext.AccessDeniedContextProvider, { children: jsxRuntime.jsx(SendBalanceContext.SendBalanceContextProvider, { children: jsxRuntime.jsx(WalletGroupContext.WalletGroupContextProvider, { children: jsxRuntime.jsx(UserFieldEditorContext.UserFieldEditorContextProvider, { children: jsxRuntime.jsx(ConnectWithOtpProvider.ConnectWithOtpProvider, { children: jsxRuntime.jsx(PhantomRedirectContext.PhantomRedirectContextProvider, { children: jsxRuntime.jsxs(SocialRedirectContext.SocialRedirectContextProvider, { children: [jsxRuntime.jsx(app.DynamicAuthFlow, {}), jsxRuntime.jsx(Toolkit.Toolkit, {}), jsxRuntime.jsx(FundingWidget.FundingWidget, {}), jsxRuntime.jsx(SyncEmbeddedWalletAuthFlow.SyncEmbeddedWalletAuthFlow, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) }) }) }) }) })] }) }) }) }) }) }));
|
|
689
|
+
}), children: [networkValidationMode === 'always' && jsxRuntime.jsx(UseNetworkValidation.UseNetworkValidation, {}), jsxRuntime.jsx(CaptchaContext.CaptchaContextProvider, { children: jsxRuntime.jsx(AccountExistsContext.AccountExistsContextProvider, { children: jsxRuntime.jsx(WalletContext.WalletContextProvider, { canSync: didConnectedStateLoad, children: jsxRuntime.jsx(PasskeyContext.PasskeyContextProvider, { children: jsxRuntime.jsx(VerificationContext.VerificationProvider, { children: jsxRuntime.jsx(DynamicWidgetContext.DynamicWidgetContextProvider, { children: jsxRuntime.jsx(DynamicBridgeWidgetContext.DynamicBridgeWidgetContextProvider, { children: jsxRuntime.jsx(FundingContext.FundingContextProvider, { children: jsxRuntime.jsx(AccessDeniedContext.AccessDeniedContextProvider, { children: jsxRuntime.jsx(SendBalanceContext.SendBalanceContextProvider, { children: jsxRuntime.jsx(WalletGroupContext.WalletGroupContextProvider, { children: jsxRuntime.jsx(UserFieldEditorContext.UserFieldEditorContextProvider, { children: jsxRuntime.jsx(ConnectWithOtpProvider.ConnectWithOtpProvider, { children: jsxRuntime.jsx(PhantomRedirectContext.PhantomRedirectContextProvider, { children: jsxRuntime.jsxs(SocialRedirectContext.SocialRedirectContextProvider, { children: [jsxRuntime.jsx(app.DynamicAuthFlow, {}), jsxRuntime.jsx(Toolkit.Toolkit, {}), jsxRuntime.jsx(FundingWidget.FundingWidget, {}), jsxRuntime.jsx(SyncEmbeddedWalletAuthFlow.SyncEmbeddedWalletAuthFlow, {}), confirmationModal, jsxRuntime.jsx(ErrorBoundaryExclude.ErrorBoundaryExclude, { children: children })] }) }) }) }) }) }) }) }) }) }) }) }) }) }) })] }) }) }) }) }) }));
|
|
680
690
|
};
|
|
681
691
|
/** The context provider you need to have access too all of Dynamic's hooks */
|
|
682
692
|
const DynamicContextProvider = (props) => {
|
|
693
|
+
logger.Logger.setEnvironmentId(props.settings.environmentId);
|
|
694
|
+
logger.Logger.setEmitErrors(props.emitErrors);
|
|
683
695
|
useParentDynamicContextGuard.useParentDynamicContextGuard();
|
|
684
|
-
return (jsxRuntime.jsx(ErrorContext.ErrorContextProvider, { children: jsxRuntime.jsx(UserWalletsContext.UserWalletsProvider, { children: jsxRuntime.jsx(FieldsStateContext.FieldsStateProvider, { children: jsxRuntime.jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }) }));
|
|
696
|
+
return (jsxRuntime.jsx(ErrorBoundary.ErrorBoundary, { children: jsxRuntime.jsx(ErrorContext.ErrorContextProvider, { children: jsxRuntime.jsx(UserWalletsContext.UserWalletsProvider, { children: jsxRuntime.jsx(FieldsStateContext.FieldsStateProvider, { children: jsxRuntime.jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }) }) }));
|
|
685
697
|
};
|
|
686
698
|
|
|
687
699
|
exports.DynamicContext = DynamicContext;
|
|
@@ -82,6 +82,11 @@ export interface DynamicContextProps {
|
|
|
82
82
|
walletsFilter?: (options: WalletOption[]) => WalletOption[];
|
|
83
83
|
};
|
|
84
84
|
theme?: ThemeData | ThemeSetting;
|
|
85
|
+
/**
|
|
86
|
+
* Emit errors to Dynamic API for debugging purposes
|
|
87
|
+
* @default true
|
|
88
|
+
*/
|
|
89
|
+
emitErrors?: boolean;
|
|
85
90
|
}
|
|
86
91
|
export declare const DynamicContext: import("react").Context<IDynamicContext | undefined>;
|
|
87
92
|
/** The context provider itself we only use internally */
|
|
@@ -4,6 +4,7 @@ import { jsx, jsxs } from 'react/jsx-runtime';
|
|
|
4
4
|
import { createContext, useState, useRef, useMemo, useEffect, useCallback } from 'react';
|
|
5
5
|
import { I18nextProvider } from 'react-i18next';
|
|
6
6
|
import { getIconicSpriteUrl } from '@dynamic-labs/iconic';
|
|
7
|
+
import { Logger } from '@dynamic-labs/logger';
|
|
7
8
|
import { MissingEnvironmentIdError } from '@dynamic-labs/utils';
|
|
8
9
|
import { useWalletBookCdn, getWalletBookCdnUrl, WalletBookContextProvider } from '@dynamic-labs/wallet-book';
|
|
9
10
|
import { logger as logger$1 } from '@dynamic-labs/wallet-connector-core';
|
|
@@ -106,6 +107,9 @@ import { FundingContextProvider } from '../FundingContext/FundingContext.js';
|
|
|
106
107
|
import { PhantomRedirectContextProvider } from '../PhantomRedirectContext/PhantomRedirectContext.js';
|
|
107
108
|
import { SendBalanceContextProvider } from '../SendBalanceContext/SendBalanceContext.js';
|
|
108
109
|
import { UseNetworkValidation } from '../UseNetworkValidation/UseNetworkValidation.js';
|
|
110
|
+
import { ErrorBoundary } from '../ErrorBoundary/ErrorBoundary.js';
|
|
111
|
+
import { ErrorBoundaryExclude } from '../ErrorBoundary/ErrorBoundaryExclude.js';
|
|
112
|
+
import '../ErrorBoundary/ErrorBoundaryBase.js';
|
|
109
113
|
import { resolveNetworkValidationMode, initExpirationTime, getInitialView, getDeepLinkPreference } from './helpers/helpers.js';
|
|
110
114
|
import { useDisplayOrderState } from './hooks/useDisplayOrderState/useDisplayOrderState.js';
|
|
111
115
|
import { useEmailLoginState } from './hooks/useEmailLoginState/useEmailLoginState.js';
|
|
@@ -163,6 +167,12 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
163
167
|
const [showBridgeWidget, setShowBridgeWidget] = useState(false);
|
|
164
168
|
const [isSingleWalletAccount, setIsSingleWalletAccount] = useState(false);
|
|
165
169
|
const [user, setUser, removeUser] = useLocalStorage(AUTH_USER, EMPTY_INITIAL_USER, validateAuthUser, [AUTH_TOKEN]);
|
|
170
|
+
if (user) {
|
|
171
|
+
logger.setMetaData('user', user);
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
logger.setMetaData('user', undefined);
|
|
175
|
+
}
|
|
166
176
|
const { consumeNonce } = useFetchNonce(environmentId);
|
|
167
177
|
const [qrcodeUri, setQrcodeUri] = useState('');
|
|
168
178
|
const [desktopUri, setDesktopUri] = useState('');
|
|
@@ -672,12 +682,14 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
672
682
|
isAuthenticated: isAuthenticated || Boolean(primaryWallet),
|
|
673
683
|
isBridgeFlow,
|
|
674
684
|
isMultiWalletEnabled: multiWallet,
|
|
675
|
-
}), children: [networkValidationMode === 'always' && jsx(UseNetworkValidation, {}), jsx(CaptchaContextProvider, { children: jsx(AccountExistsContextProvider, { children: jsx(WalletContextProvider, { canSync: didConnectedStateLoad, children: jsx(PasskeyContextProvider, { children: jsx(VerificationProvider, { children: jsx(DynamicWidgetContextProvider, { children: jsx(DynamicBridgeWidgetContextProvider, { children: jsx(FundingContextProvider, { children: jsx(AccessDeniedContextProvider, { children: jsx(SendBalanceContextProvider, { children: jsx(WalletGroupContextProvider, { children: jsx(UserFieldEditorContextProvider, { children: jsx(ConnectWithOtpProvider, { children: jsx(PhantomRedirectContextProvider, { children: jsxs(SocialRedirectContextProvider, { children: [jsx(DynamicAuthFlow, {}), jsx(Toolkit, {}), jsx(FundingWidget, {}), jsx(SyncEmbeddedWalletAuthFlow, {}), confirmationModal, children] }) }) }) }) }) }) }) }) }) }) }) }) }) }) })] }) }) }) }) }) }));
|
|
685
|
+
}), children: [networkValidationMode === 'always' && jsx(UseNetworkValidation, {}), jsx(CaptchaContextProvider, { children: jsx(AccountExistsContextProvider, { children: jsx(WalletContextProvider, { canSync: didConnectedStateLoad, children: jsx(PasskeyContextProvider, { children: jsx(VerificationProvider, { children: jsx(DynamicWidgetContextProvider, { children: jsx(DynamicBridgeWidgetContextProvider, { children: jsx(FundingContextProvider, { children: jsx(AccessDeniedContextProvider, { children: jsx(SendBalanceContextProvider, { children: jsx(WalletGroupContextProvider, { children: jsx(UserFieldEditorContextProvider, { children: jsx(ConnectWithOtpProvider, { children: jsx(PhantomRedirectContextProvider, { children: jsxs(SocialRedirectContextProvider, { children: [jsx(DynamicAuthFlow, {}), jsx(Toolkit, {}), jsx(FundingWidget, {}), jsx(SyncEmbeddedWalletAuthFlow, {}), confirmationModal, jsx(ErrorBoundaryExclude, { children: children })] }) }) }) }) }) }) }) }) }) }) }) }) }) }) })] }) }) }) }) }) }));
|
|
676
686
|
};
|
|
677
687
|
/** The context provider you need to have access too all of Dynamic's hooks */
|
|
678
688
|
const DynamicContextProvider = (props) => {
|
|
689
|
+
Logger.setEnvironmentId(props.settings.environmentId);
|
|
690
|
+
Logger.setEmitErrors(props.emitErrors);
|
|
679
691
|
useParentDynamicContextGuard();
|
|
680
|
-
return (jsx(ErrorContextProvider, { children: jsx(UserWalletsProvider, { children: jsx(FieldsStateProvider, { children: jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }) }));
|
|
692
|
+
return (jsx(ErrorBoundary, { children: jsx(ErrorContextProvider, { children: jsx(UserWalletsProvider, { children: jsx(FieldsStateProvider, { children: jsx(InnerDynamicContextProvider, Object.assign({}, props)) }) }) }) }));
|
|
681
693
|
};
|
|
682
694
|
|
|
683
695
|
export { DynamicContext, DynamicContextProvider, InnerDynamicContextProvider, PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var _tslib = require('../../../../_virtual/_tslib.cjs');
|
|
7
|
+
var jsxRuntime = require('react/jsx-runtime');
|
|
8
|
+
require('@dynamic-labs/sdk-api-core');
|
|
9
|
+
var logger = require('../../shared/logger.cjs');
|
|
10
|
+
require('@dynamic-labs/iconic');
|
|
11
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
12
|
+
require('../ViewContext/ViewContext.cjs');
|
|
13
|
+
require('react');
|
|
14
|
+
require('@dynamic-labs/wallet-book');
|
|
15
|
+
require('../../utils/constants/colors.cjs');
|
|
16
|
+
require('../../utils/constants/values.cjs');
|
|
17
|
+
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
|
+
require('@dynamic-labs/utils');
|
|
19
|
+
require('../../shared/consts/index.cjs');
|
|
20
|
+
var ErrorBoundaryBase = require('./ErrorBoundaryBase.cjs');
|
|
21
|
+
var ErrorBoundaryContext = require('./ErrorBoundaryContext.cjs');
|
|
22
|
+
|
|
23
|
+
class ErrorBoundaryReporter extends ErrorBoundaryBase.ErrorBoundaryBase {
|
|
24
|
+
constructor(props) {
|
|
25
|
+
super(props);
|
|
26
|
+
this.state = { error: null, hasError: false };
|
|
27
|
+
}
|
|
28
|
+
componentDidCatch(error, info) {
|
|
29
|
+
var _a;
|
|
30
|
+
const { onError } = this.props;
|
|
31
|
+
if ((_a = this.context) === null || _a === void 0 ? void 0 : _a.isDynamicSdkError) {
|
|
32
|
+
onError === null || onError === void 0 ? void 0 : onError(error, info);
|
|
33
|
+
logger.logger.error(error, {
|
|
34
|
+
error: {
|
|
35
|
+
bundleStack: error.stack,
|
|
36
|
+
message: error,
|
|
37
|
+
stack: info.componentStack,
|
|
38
|
+
},
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
throw error;
|
|
42
|
+
}
|
|
43
|
+
render() {
|
|
44
|
+
const { children } = this.props;
|
|
45
|
+
const { hasError, error } = this.state;
|
|
46
|
+
if (hasError) {
|
|
47
|
+
ErrorBoundaryContext.assertErrorBoundaryContext(this.context);
|
|
48
|
+
this.context.error = error;
|
|
49
|
+
this.context.hasError = hasError;
|
|
50
|
+
return null;
|
|
51
|
+
}
|
|
52
|
+
return children;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
const ErrorBoundary = (_a) => {
|
|
56
|
+
var { children } = _a, props = _tslib.__rest(_a, ["children"]);
|
|
57
|
+
return (jsxRuntime.jsx(ErrorBoundaryContext.ErrorBoundaryContext.Provider, { value: {
|
|
58
|
+
error: null,
|
|
59
|
+
hasError: false,
|
|
60
|
+
isDynamicSdkError: true,
|
|
61
|
+
}, children: jsxRuntime.jsx(ErrorBoundaryReporter, Object.assign({}, props, { children: children })) }));
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
exports.ErrorBoundary = ErrorBoundary;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { __rest } from '../../../../_virtual/_tslib.js';
|
|
3
|
+
import { jsx } from 'react/jsx-runtime';
|
|
4
|
+
import '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import { logger } from '../../shared/logger.js';
|
|
6
|
+
import '@dynamic-labs/iconic';
|
|
7
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
8
|
+
import '../ViewContext/ViewContext.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import '@dynamic-labs/wallet-book';
|
|
11
|
+
import '../../utils/constants/colors.js';
|
|
12
|
+
import '../../utils/constants/values.js';
|
|
13
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import '@dynamic-labs/utils';
|
|
15
|
+
import '../../shared/consts/index.js';
|
|
16
|
+
import { ErrorBoundaryBase } from './ErrorBoundaryBase.js';
|
|
17
|
+
import { ErrorBoundaryContext, assertErrorBoundaryContext } from './ErrorBoundaryContext.js';
|
|
18
|
+
|
|
19
|
+
class ErrorBoundaryReporter extends ErrorBoundaryBase {
|
|
20
|
+
constructor(props) {
|
|
21
|
+
super(props);
|
|
22
|
+
this.state = { error: null, hasError: false };
|
|
23
|
+
}
|
|
24
|
+
componentDidCatch(error, info) {
|
|
25
|
+
var _a;
|
|
26
|
+
const { onError } = this.props;
|
|
27
|
+
if ((_a = this.context) === null || _a === void 0 ? void 0 : _a.isDynamicSdkError) {
|
|
28
|
+
onError === null || onError === void 0 ? void 0 : onError(error, info);
|
|
29
|
+
logger.error(error, {
|
|
30
|
+
error: {
|
|
31
|
+
bundleStack: error.stack,
|
|
32
|
+
message: error,
|
|
33
|
+
stack: info.componentStack,
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
throw error;
|
|
38
|
+
}
|
|
39
|
+
render() {
|
|
40
|
+
const { children } = this.props;
|
|
41
|
+
const { hasError, error } = this.state;
|
|
42
|
+
if (hasError) {
|
|
43
|
+
assertErrorBoundaryContext(this.context);
|
|
44
|
+
this.context.error = error;
|
|
45
|
+
this.context.hasError = hasError;
|
|
46
|
+
return null;
|
|
47
|
+
}
|
|
48
|
+
return children;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
const ErrorBoundary = (_a) => {
|
|
52
|
+
var { children } = _a, props = __rest(_a, ["children"]);
|
|
53
|
+
return (jsx(ErrorBoundaryContext.Provider, { value: {
|
|
54
|
+
error: null,
|
|
55
|
+
hasError: false,
|
|
56
|
+
isDynamicSdkError: true,
|
|
57
|
+
}, children: jsx(ErrorBoundaryReporter, Object.assign({}, props, { children: children })) }));
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
export { ErrorBoundary };
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var React = require('react');
|
|
7
|
+
require('@dynamic-labs/sdk-api-core');
|
|
8
|
+
var logger = require('../../shared/logger.cjs');
|
|
9
|
+
require('@dynamic-labs/iconic');
|
|
10
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
11
|
+
require('react/jsx-runtime');
|
|
12
|
+
require('../ViewContext/ViewContext.cjs');
|
|
13
|
+
require('@dynamic-labs/wallet-book');
|
|
14
|
+
require('../../utils/constants/colors.cjs');
|
|
15
|
+
require('../../utils/constants/values.cjs');
|
|
16
|
+
require('../../shared/utils/classes/storage/localStorage.cjs');
|
|
17
|
+
require('@dynamic-labs/utils');
|
|
18
|
+
require('../../shared/consts/index.cjs');
|
|
19
|
+
var ErrorContainer = require('../../components/ErrorContainer/ErrorContainer.cjs');
|
|
20
|
+
var ErrorBoundaryContext = require('./ErrorBoundaryContext.cjs');
|
|
21
|
+
|
|
22
|
+
class ErrorBoundaryBase extends React.Component {
|
|
23
|
+
static getDerivedStateFromError(error) {
|
|
24
|
+
return { error, hasError: true };
|
|
25
|
+
}
|
|
26
|
+
renderOrError(children, { isDynamicSdkError }) {
|
|
27
|
+
try {
|
|
28
|
+
ErrorBoundaryContext.assertErrorBoundaryContext(this.context);
|
|
29
|
+
this.context.isDynamicSdkError = isDynamicSdkError;
|
|
30
|
+
}
|
|
31
|
+
catch (e) {
|
|
32
|
+
logger.logger.error(e);
|
|
33
|
+
return React.createElement(ErrorContainer.ErrorContainer, null, 'ErrorBoundary must be used within ErrorBoundaryContext');
|
|
34
|
+
}
|
|
35
|
+
return children;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
ErrorBoundaryBase.contextType = ErrorBoundaryContext.ErrorBoundaryContext;
|
|
39
|
+
|
|
40
|
+
exports.ErrorBoundaryBase = ErrorBoundaryBase;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Component, PropsWithChildren } from 'react';
|
|
2
|
+
import { ErrorBoundaryState } from './types';
|
|
3
|
+
import { ErrorBoundaryContext } from './ErrorBoundaryContext';
|
|
4
|
+
export declare abstract class ErrorBoundaryBase extends Component<PropsWithChildren<any>, ErrorBoundaryState> {
|
|
5
|
+
static contextType: import("react").Context<import("./types").ErrorBoundaryContextType | null>;
|
|
6
|
+
context: React.ContextType<typeof ErrorBoundaryContext>;
|
|
7
|
+
static getDerivedStateFromError(error: Error): {
|
|
8
|
+
error: Error;
|
|
9
|
+
hasError: boolean;
|
|
10
|
+
};
|
|
11
|
+
renderOrError<T>(children: T, { isDynamicSdkError }: {
|
|
12
|
+
isDynamicSdkError: boolean;
|
|
13
|
+
}): T | JSX.Element;
|
|
14
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { Component, createElement } from 'react';
|
|
3
|
+
import '@dynamic-labs/sdk-api-core';
|
|
4
|
+
import { logger } from '../../shared/logger.js';
|
|
5
|
+
import '@dynamic-labs/iconic';
|
|
6
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
7
|
+
import 'react/jsx-runtime';
|
|
8
|
+
import '../ViewContext/ViewContext.js';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import '../../utils/constants/colors.js';
|
|
11
|
+
import '../../utils/constants/values.js';
|
|
12
|
+
import '../../shared/utils/classes/storage/localStorage.js';
|
|
13
|
+
import '@dynamic-labs/utils';
|
|
14
|
+
import '../../shared/consts/index.js';
|
|
15
|
+
import { ErrorContainer } from '../../components/ErrorContainer/ErrorContainer.js';
|
|
16
|
+
import { ErrorBoundaryContext, assertErrorBoundaryContext } from './ErrorBoundaryContext.js';
|
|
17
|
+
|
|
18
|
+
class ErrorBoundaryBase extends Component {
|
|
19
|
+
static getDerivedStateFromError(error) {
|
|
20
|
+
return { error, hasError: true };
|
|
21
|
+
}
|
|
22
|
+
renderOrError(children, { isDynamicSdkError }) {
|
|
23
|
+
try {
|
|
24
|
+
assertErrorBoundaryContext(this.context);
|
|
25
|
+
this.context.isDynamicSdkError = isDynamicSdkError;
|
|
26
|
+
}
|
|
27
|
+
catch (e) {
|
|
28
|
+
logger.error(e);
|
|
29
|
+
return createElement(ErrorContainer, null, 'ErrorBoundary must be used within ErrorBoundaryContext');
|
|
30
|
+
}
|
|
31
|
+
return children;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
ErrorBoundaryBase.contextType = ErrorBoundaryContext;
|
|
35
|
+
|
|
36
|
+
export { ErrorBoundaryBase };
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var React = require('react');
|
|
7
|
+
|
|
8
|
+
/* eslint-disable prefer-arrow/prefer-arrow-functions */
|
|
9
|
+
const ERROR_BOUNDARY_CONTEXT_NOT_FOUND = 'ERROR_BOUNDARY_CONTEXT_NOT_FOUND';
|
|
10
|
+
const ErrorBoundaryContext = React.createContext(null);
|
|
11
|
+
function assertErrorBoundaryContext(value) {
|
|
12
|
+
if (value === null ||
|
|
13
|
+
typeof value.hasError !== 'boolean' ||
|
|
14
|
+
typeof value.error !== 'object' ||
|
|
15
|
+
typeof value.isDynamicSdkError !== 'boolean') {
|
|
16
|
+
const error = new Error('ErrorBoundaryContext not found');
|
|
17
|
+
error.cause = ERROR_BOUNDARY_CONTEXT_NOT_FOUND;
|
|
18
|
+
throw error;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
exports.ERROR_BOUNDARY_CONTEXT_NOT_FOUND = ERROR_BOUNDARY_CONTEXT_NOT_FOUND;
|
|
23
|
+
exports.ErrorBoundaryContext = ErrorBoundaryContext;
|
|
24
|
+
exports.assertErrorBoundaryContext = assertErrorBoundaryContext;
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import { ErrorBoundaryContextType } from './types';
|
|
3
|
+
export declare const ERROR_BOUNDARY_CONTEXT_NOT_FOUND = "ERROR_BOUNDARY_CONTEXT_NOT_FOUND";
|
|
4
|
+
export declare const ErrorBoundaryContext: import("react").Context<ErrorBoundaryContextType | null>;
|
|
5
|
+
export declare function assertErrorBoundaryContext(value: any): asserts value is ErrorBoundaryContextType;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { createContext } from 'react';
|
|
3
|
+
|
|
4
|
+
/* eslint-disable prefer-arrow/prefer-arrow-functions */
|
|
5
|
+
const ERROR_BOUNDARY_CONTEXT_NOT_FOUND = 'ERROR_BOUNDARY_CONTEXT_NOT_FOUND';
|
|
6
|
+
const ErrorBoundaryContext = createContext(null);
|
|
7
|
+
function assertErrorBoundaryContext(value) {
|
|
8
|
+
if (value === null ||
|
|
9
|
+
typeof value.hasError !== 'boolean' ||
|
|
10
|
+
typeof value.error !== 'object' ||
|
|
11
|
+
typeof value.isDynamicSdkError !== 'boolean') {
|
|
12
|
+
const error = new Error('ErrorBoundaryContext not found');
|
|
13
|
+
error.cause = ERROR_BOUNDARY_CONTEXT_NOT_FOUND;
|
|
14
|
+
throw error;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export { ERROR_BOUNDARY_CONTEXT_NOT_FOUND, ErrorBoundaryContext, assertErrorBoundaryContext };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var ErrorBoundaryBase = require('./ErrorBoundaryBase.cjs');
|
|
7
|
+
|
|
8
|
+
class ErrorBoundaryExclude extends ErrorBoundaryBase.ErrorBoundaryBase {
|
|
9
|
+
render() {
|
|
10
|
+
const { children } = this.props;
|
|
11
|
+
return this.renderOrError(children, {
|
|
12
|
+
isDynamicSdkError: false,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.ErrorBoundaryExclude = ErrorBoundaryExclude;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { ErrorBoundaryBase } from './ErrorBoundaryBase.js';
|
|
3
|
+
|
|
4
|
+
class ErrorBoundaryExclude extends ErrorBoundaryBase {
|
|
5
|
+
render() {
|
|
6
|
+
const { children } = this.props;
|
|
7
|
+
return this.renderOrError(children, {
|
|
8
|
+
isDynamicSdkError: false,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { ErrorBoundaryExclude };
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var ErrorBoundaryBase = require('./ErrorBoundaryBase.cjs');
|
|
7
|
+
|
|
8
|
+
class ErrorBoundaryInclude extends ErrorBoundaryBase.ErrorBoundaryBase {
|
|
9
|
+
render() {
|
|
10
|
+
const { children } = this.props;
|
|
11
|
+
return this.renderOrError(children, {
|
|
12
|
+
isDynamicSdkError: true,
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
exports.ErrorBoundaryInclude = ErrorBoundaryInclude;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { ErrorBoundaryBase } from './ErrorBoundaryBase.js';
|
|
3
|
+
|
|
4
|
+
class ErrorBoundaryInclude extends ErrorBoundaryBase {
|
|
5
|
+
render() {
|
|
6
|
+
const { children } = this.props;
|
|
7
|
+
return this.renderOrError(children, {
|
|
8
|
+
isDynamicSdkError: true,
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { ErrorBoundaryInclude };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { ErrorInfo, PropsWithChildren } from 'react';
|
|
2
|
+
export type ErrorBoundaryProps = PropsWithChildren<{
|
|
3
|
+
onError?: (error: Error, info: ErrorInfo) => void;
|
|
4
|
+
}>;
|
|
5
|
+
export type ErrorBoundaryState = {
|
|
6
|
+
hasError: boolean;
|
|
7
|
+
error: Error | null;
|
|
8
|
+
};
|
|
9
|
+
export type ErrorBoundaryContextType = {
|
|
10
|
+
hasError: boolean;
|
|
11
|
+
error: any;
|
|
12
|
+
isDynamicSdkError: boolean;
|
|
13
|
+
};
|
|
@@ -109,7 +109,7 @@ var useInternalDynamicContext = require('../../../../context/DynamicContext/useD
|
|
|
109
109
|
* }
|
|
110
110
|
*/
|
|
111
111
|
const useSecureEnclaveEmbeddedWallet = () => {
|
|
112
|
-
var _a, _b;
|
|
112
|
+
var _a, _b, _c, _d;
|
|
113
113
|
const { projectSettings, onboardingOnlyJwt, primaryWallet, user, environmentId, walletConnectorOptions, setUser, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
114
114
|
const { createTurnkeyWallet } = useTurnkey.useTurnkey();
|
|
115
115
|
const { hasRecoveryEmail } = useIsTurnkeyWallet.useIsTurnkeyWallet();
|
|
@@ -127,12 +127,12 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
127
127
|
* @returns Promise<Wallet | undefined>
|
|
128
128
|
*/
|
|
129
129
|
const createEmbeddedWallet = React.useCallback((chain) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
130
|
-
var
|
|
131
|
-
const jwt = (
|
|
130
|
+
var _e, _f;
|
|
131
|
+
const jwt = (_e = getAuthToken.getAuthToken()) !== null && _e !== void 0 ? _e : onboardingOnlyJwt;
|
|
132
132
|
const { decodedJwt } = validateUserIsLoggedIn.validateUserIsLoggedIn(jwt);
|
|
133
133
|
const userWaletsCredentials = getUserWalletsFromVerifiedCredentials.getUserWalletsFromVerifiedCredentials(jwt);
|
|
134
134
|
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials.findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
|
|
135
|
-
const isManualMode = ((
|
|
135
|
+
const isManualMode = ((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _f === void 0 ? void 0 : _f.automaticEmbeddedWalletCreation) === false;
|
|
136
136
|
// if user has a wallet and it's not embedded,
|
|
137
137
|
// throw error to follow another flow and set up the right wallet
|
|
138
138
|
// However, if the user is in manual mode continue.
|
|
@@ -157,25 +157,26 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
157
157
|
* @param oneTimeCode - optional one-time code parameter. If not informed it tries to restore a session
|
|
158
158
|
* @returns Promise<'session_created' | 'session_restored'> - returns a string indicating the status of the session
|
|
159
159
|
*/
|
|
160
|
-
const createOrRestoreSession = React.useCallback((
|
|
161
|
-
var
|
|
162
|
-
const jwt = (
|
|
160
|
+
const createOrRestoreSession = React.useCallback((_g) => _tslib.__awaiter(void 0, [_g], void 0, function* ({ oneTimeCode }) {
|
|
161
|
+
var _h, _j, _k, _l, _m, _o, _p;
|
|
162
|
+
const jwt = (_h = getAuthToken.getAuthToken()) !== null && _h !== void 0 ? _h : onboardingOnlyJwt;
|
|
163
163
|
const { decodedJwt } = validateUserIsLoggedIn.validateUserIsLoggedIn(jwt);
|
|
164
164
|
const turnkeyRecoveryHandler = getEmbeddedWalletAuthHandler.getEmbeddedWalletAuthHandler(wallet === null || wallet === void 0 ? void 0 : wallet.connector);
|
|
165
165
|
if (turnkeyRecoveryHandler.isSessionActive()) {
|
|
166
166
|
return errors.ACTIVE_SESSION;
|
|
167
167
|
}
|
|
168
168
|
// try to restore session if possible
|
|
169
|
-
if (passkeyRecovery.canRestoreEmbeddedWalletSession((
|
|
169
|
+
if (passkeyRecovery.canRestoreEmbeddedWalletSession((_j = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _j === void 0 ? void 0 : _j.sessionKeyDuration)) {
|
|
170
170
|
try {
|
|
171
|
-
yield passkeyRecovery.restoreEmbeddedWalletSession({
|
|
171
|
+
const sessionRestored = yield passkeyRecovery.restoreEmbeddedWalletSession({
|
|
172
172
|
authToken: jwt,
|
|
173
173
|
iframeContainer: turnkeyAuthIframeContainerRef.current,
|
|
174
174
|
iframeElementId: constants.iframeElementId,
|
|
175
|
-
sessionExpiration: getEmbeddedWalletSessionExpiration.getEmbeddedWalletSessionExpiration((
|
|
175
|
+
sessionExpiration: getEmbeddedWalletSessionExpiration.getEmbeddedWalletSessionExpiration((_l = (_k = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _k === void 0 ? void 0 : _k.embeddedWallets) === null || _l === void 0 ? void 0 : _l.sessionKeyDuration),
|
|
176
176
|
wallet: primaryWallet,
|
|
177
177
|
});
|
|
178
|
-
|
|
178
|
+
if (sessionRestored)
|
|
179
|
+
return errors.SESSION_RESTORED;
|
|
179
180
|
}
|
|
180
181
|
catch (err) {
|
|
181
182
|
logger.logger.error('Failed to restore embedded wallet', err);
|
|
@@ -189,7 +190,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
189
190
|
if (!userHasEmbeddedWallet() || !hasRecoveryEmail) {
|
|
190
191
|
throw new utils.DynamicError('User does not have a secure enclave wallet or a verified email', errors.INVALID_WALLET_DATA);
|
|
191
192
|
}
|
|
192
|
-
const organizationId = (
|
|
193
|
+
const organizationId = (_p = (_o = (_m = decodedJwt.verifiedCredentials) === null || _m === void 0 ? void 0 : _m.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _o === void 0 ? void 0 : _o.walletProperties) === null || _p === void 0 ? void 0 : _p.turnkeySubOrganizationId;
|
|
193
194
|
yield turnkeyRecoveryHandler.verifyRecoveryCode(oneTimeCode, organizationId);
|
|
194
195
|
const sessionSettings = {
|
|
195
196
|
createdAt: new Date().getTime(),
|
|
@@ -217,11 +218,11 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
217
218
|
* displayName: string,
|
|
218
219
|
* }
|
|
219
220
|
*/
|
|
220
|
-
const createPasskey = React.useCallback((
|
|
221
|
-
var
|
|
221
|
+
const createPasskey = React.useCallback((_q) => _tslib.__awaiter(void 0, [_q], void 0, function* ({ oneTimeCode }) {
|
|
222
|
+
var _r, _s, _t;
|
|
222
223
|
const { decodedJwt, jwt } = validateUserIsLoggedIn.validateUserIsLoggedIn(getAuthToken.getAuthToken() || onboardingOnlyJwt);
|
|
223
224
|
validateTurnkeyProviderEnabled.validateTurnkeyProviderEnabled(projectSettings);
|
|
224
|
-
const turnkeyWallet = findTurnkeyWallet.findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (
|
|
225
|
+
const turnkeyWallet = findTurnkeyWallet.findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (_r = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _r === void 0 ? void 0 : _r.chainConfigurations, decodedJwt.verifiedCredentials);
|
|
225
226
|
if (!(turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector)) {
|
|
226
227
|
throw new utils.DynamicError('Wallet connector not found', errors.INVALID_WALLET_DATA);
|
|
227
228
|
}
|
|
@@ -229,7 +230,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
229
230
|
walletConnector.setEmail(user === null || user === void 0 ? void 0 : user.email);
|
|
230
231
|
if (!(user === null || user === void 0 ? void 0 : user.email)) {
|
|
231
232
|
const passkeyIdentifier = (user === null || user === void 0 ? void 0 : user.phoneNumber) ||
|
|
232
|
-
((
|
|
233
|
+
((_s = user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((vc) => vc.oauthDisplayName)) === null || _s === void 0 ? void 0 : _s.oauthDisplayName) ||
|
|
233
234
|
'';
|
|
234
235
|
walletConnector.setPasskeyIdentifier(passkeyIdentifier);
|
|
235
236
|
}
|
|
@@ -239,7 +240,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
239
240
|
if (!(turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.id) || !hasEmailVC) {
|
|
240
241
|
return walletConnector.getWebAuthnAttestation();
|
|
241
242
|
}
|
|
242
|
-
const organizationId = (
|
|
243
|
+
const organizationId = (_t = turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletProperties) === null || _t === void 0 ? void 0 : _t.turnkeySubOrganizationId;
|
|
243
244
|
if (!organizationId) {
|
|
244
245
|
throw new utils.DynamicError('No sub organization id found for the wallet', errors.INVALID_WALLET_DATA);
|
|
245
246
|
}
|
|
@@ -278,8 +279,8 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
278
279
|
* @returns Promise<Passkey[]>
|
|
279
280
|
*/
|
|
280
281
|
const getPasskeys = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
281
|
-
var
|
|
282
|
-
const { jwt } = validateUserIsLoggedIn.validateUserIsLoggedIn((
|
|
282
|
+
var _u;
|
|
283
|
+
const { jwt } = validateUserIsLoggedIn.validateUserIsLoggedIn((_u = getAuthToken.getAuthToken()) !== null && _u !== void 0 ? _u : onboardingOnlyJwt);
|
|
283
284
|
const data = yield embeddedWallets.getUserPasskeys({
|
|
284
285
|
environmentId: environmentId,
|
|
285
286
|
userJwt: jwt,
|
|
@@ -290,26 +291,18 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
290
291
|
* Checks if the embedded wallet session is active
|
|
291
292
|
* @returns boolean
|
|
292
293
|
*/
|
|
293
|
-
const isSessionActive =
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
try {
|
|
297
|
-
const turnkeyAuthenticatorHandler = getEmbeddedWalletAuthHandler.getEmbeddedWalletAuthHandler(wallet === null || wallet === void 0 ? void 0 : wallet.connector);
|
|
298
|
-
return turnkeyAuthenticatorHandler.isSessionActive();
|
|
299
|
-
}
|
|
300
|
-
catch (err) {
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
}, [wallet === null || wallet === void 0 ? void 0 : wallet.connector]);
|
|
294
|
+
const isSessionActive = (_d = ((wallet === null || wallet === void 0 ? void 0 : wallet.connector) &&
|
|
295
|
+
'getAuthenticatorHandler' in wallet.connector &&
|
|
296
|
+
((_c = getEmbeddedWalletAuthHandler.getEmbeddedWalletAuthHandler(wallet.connector)) === null || _c === void 0 ? void 0 : _c.isSessionActive()))) !== null && _d !== void 0 ? _d : false;
|
|
304
297
|
/**
|
|
305
298
|
* Sends a one-time code to the user so they can create a session or add a new passkey
|
|
306
299
|
* @returns Promise<'code_sent'>
|
|
307
300
|
*/
|
|
308
301
|
const sendOneTimeCode = React.useCallback(() => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
309
|
-
var
|
|
310
|
-
const { jwt, decodedJwt } = validateUserIsLoggedIn.validateUserIsLoggedIn((
|
|
302
|
+
var _v, _w, _x;
|
|
303
|
+
const { jwt, decodedJwt } = validateUserIsLoggedIn.validateUserIsLoggedIn((_v = getAuthToken.getAuthToken()) !== null && _v !== void 0 ? _v : onboardingOnlyJwt);
|
|
311
304
|
validateTurnkeyProviderEnabled.validateTurnkeyProviderEnabled(projectSettings);
|
|
312
|
-
const targetTurnkeyWallet = findTurnkeyWallet.findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (
|
|
305
|
+
const targetTurnkeyWallet = findTurnkeyWallet.findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (_w = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _w === void 0 ? void 0 : _w.chainConfigurations, decodedJwt.verifiedCredentials);
|
|
313
306
|
if (!targetTurnkeyWallet || !targetTurnkeyWallet.id) {
|
|
314
307
|
throw new utils.DynamicError('User does not have a valid secure enclave wallet', errors.INVALID_WALLET_DATA);
|
|
315
308
|
}
|
|
@@ -319,7 +312,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
319
312
|
if (isSessionActive) {
|
|
320
313
|
throw new utils.DynamicError('Session is active. No need to create a new one', errors.ACTIVE_SESSION);
|
|
321
314
|
}
|
|
322
|
-
const publicKey = yield turnkeyAuthenticatorHandler.initRecovery('email', turnkeyAuthIframeContainerRef.current,
|
|
315
|
+
const publicKey = yield turnkeyAuthenticatorHandler.initRecovery('email', turnkeyAuthIframeContainerRef.current, constants.iframeElementId, getEmbeddedWalletSessionExpiration.getEmbeddedWalletSessionExpiration((_x = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _x === void 0 ? void 0 : _x.sessionKeyDuration));
|
|
323
316
|
if (!publicKey) {
|
|
324
317
|
throw new utils.DynamicError(errors.ERROR_SENDING_CODE);
|
|
325
318
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { useCallback
|
|
3
|
+
import { useCallback } from 'react';
|
|
4
4
|
import { JwtVerifiedCredentialFormatEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
6
6
|
import '../../../../context/DynamicContext/DynamicContext.js';
|
|
@@ -105,7 +105,7 @@ import { useInternalDynamicContext } from '../../../../context/DynamicContext/us
|
|
|
105
105
|
* }
|
|
106
106
|
*/
|
|
107
107
|
const useSecureEnclaveEmbeddedWallet = () => {
|
|
108
|
-
var _a, _b;
|
|
108
|
+
var _a, _b, _c, _d;
|
|
109
109
|
const { projectSettings, onboardingOnlyJwt, primaryWallet, user, environmentId, walletConnectorOptions, setUser, } = useInternalDynamicContext();
|
|
110
110
|
const { createTurnkeyWallet } = useTurnkey();
|
|
111
111
|
const { hasRecoveryEmail } = useIsTurnkeyWallet();
|
|
@@ -123,12 +123,12 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
123
123
|
* @returns Promise<Wallet | undefined>
|
|
124
124
|
*/
|
|
125
125
|
const createEmbeddedWallet = useCallback((chain) => __awaiter(void 0, void 0, void 0, function* () {
|
|
126
|
-
var
|
|
127
|
-
const jwt = (
|
|
126
|
+
var _e, _f;
|
|
127
|
+
const jwt = (_e = getAuthToken()) !== null && _e !== void 0 ? _e : onboardingOnlyJwt;
|
|
128
128
|
const { decodedJwt } = validateUserIsLoggedIn(jwt);
|
|
129
129
|
const userWaletsCredentials = getUserWalletsFromVerifiedCredentials(jwt);
|
|
130
130
|
const embeddedWalletVerifiedCredential = findEmbeddedWalletFromVerifiedCredentials(jwt, chain);
|
|
131
|
-
const isManualMode = ((
|
|
131
|
+
const isManualMode = ((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _f === void 0 ? void 0 : _f.automaticEmbeddedWalletCreation) === false;
|
|
132
132
|
// if user has a wallet and it's not embedded,
|
|
133
133
|
// throw error to follow another flow and set up the right wallet
|
|
134
134
|
// However, if the user is in manual mode continue.
|
|
@@ -153,25 +153,26 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
153
153
|
* @param oneTimeCode - optional one-time code parameter. If not informed it tries to restore a session
|
|
154
154
|
* @returns Promise<'session_created' | 'session_restored'> - returns a string indicating the status of the session
|
|
155
155
|
*/
|
|
156
|
-
const createOrRestoreSession = useCallback((
|
|
157
|
-
var
|
|
158
|
-
const jwt = (
|
|
156
|
+
const createOrRestoreSession = useCallback((_g) => __awaiter(void 0, [_g], void 0, function* ({ oneTimeCode }) {
|
|
157
|
+
var _h, _j, _k, _l, _m, _o, _p;
|
|
158
|
+
const jwt = (_h = getAuthToken()) !== null && _h !== void 0 ? _h : onboardingOnlyJwt;
|
|
159
159
|
const { decodedJwt } = validateUserIsLoggedIn(jwt);
|
|
160
160
|
const turnkeyRecoveryHandler = getEmbeddedWalletAuthHandler(wallet === null || wallet === void 0 ? void 0 : wallet.connector);
|
|
161
161
|
if (turnkeyRecoveryHandler.isSessionActive()) {
|
|
162
162
|
return ACTIVE_SESSION;
|
|
163
163
|
}
|
|
164
164
|
// try to restore session if possible
|
|
165
|
-
if (canRestoreEmbeddedWalletSession((
|
|
165
|
+
if (canRestoreEmbeddedWalletSession((_j = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _j === void 0 ? void 0 : _j.sessionKeyDuration)) {
|
|
166
166
|
try {
|
|
167
|
-
yield restoreEmbeddedWalletSession({
|
|
167
|
+
const sessionRestored = yield restoreEmbeddedWalletSession({
|
|
168
168
|
authToken: jwt,
|
|
169
169
|
iframeContainer: turnkeyAuthIframeContainerRef.current,
|
|
170
170
|
iframeElementId,
|
|
171
|
-
sessionExpiration: getEmbeddedWalletSessionExpiration((
|
|
171
|
+
sessionExpiration: getEmbeddedWalletSessionExpiration((_l = (_k = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _k === void 0 ? void 0 : _k.embeddedWallets) === null || _l === void 0 ? void 0 : _l.sessionKeyDuration),
|
|
172
172
|
wallet: primaryWallet,
|
|
173
173
|
});
|
|
174
|
-
|
|
174
|
+
if (sessionRestored)
|
|
175
|
+
return SESSION_RESTORED;
|
|
175
176
|
}
|
|
176
177
|
catch (err) {
|
|
177
178
|
logger.error('Failed to restore embedded wallet', err);
|
|
@@ -185,7 +186,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
185
186
|
if (!userHasEmbeddedWallet() || !hasRecoveryEmail) {
|
|
186
187
|
throw new DynamicError('User does not have a secure enclave wallet or a verified email', INVALID_WALLET_DATA);
|
|
187
188
|
}
|
|
188
|
-
const organizationId = (
|
|
189
|
+
const organizationId = (_p = (_o = (_m = decodedJwt.verifiedCredentials) === null || _m === void 0 ? void 0 : _m.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('turnkey'))) === null || _o === void 0 ? void 0 : _o.walletProperties) === null || _p === void 0 ? void 0 : _p.turnkeySubOrganizationId;
|
|
189
190
|
yield turnkeyRecoveryHandler.verifyRecoveryCode(oneTimeCode, organizationId);
|
|
190
191
|
const sessionSettings = {
|
|
191
192
|
createdAt: new Date().getTime(),
|
|
@@ -213,11 +214,11 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
213
214
|
* displayName: string,
|
|
214
215
|
* }
|
|
215
216
|
*/
|
|
216
|
-
const createPasskey = useCallback((
|
|
217
|
-
var
|
|
217
|
+
const createPasskey = useCallback((_q) => __awaiter(void 0, [_q], void 0, function* ({ oneTimeCode }) {
|
|
218
|
+
var _r, _s, _t;
|
|
218
219
|
const { decodedJwt, jwt } = validateUserIsLoggedIn(getAuthToken() || onboardingOnlyJwt);
|
|
219
220
|
validateTurnkeyProviderEnabled(projectSettings);
|
|
220
|
-
const turnkeyWallet = findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (
|
|
221
|
+
const turnkeyWallet = findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (_r = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _r === void 0 ? void 0 : _r.chainConfigurations, decodedJwt.verifiedCredentials);
|
|
221
222
|
if (!(turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletConnector)) {
|
|
222
223
|
throw new DynamicError('Wallet connector not found', INVALID_WALLET_DATA);
|
|
223
224
|
}
|
|
@@ -225,7 +226,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
225
226
|
walletConnector.setEmail(user === null || user === void 0 ? void 0 : user.email);
|
|
226
227
|
if (!(user === null || user === void 0 ? void 0 : user.email)) {
|
|
227
228
|
const passkeyIdentifier = (user === null || user === void 0 ? void 0 : user.phoneNumber) ||
|
|
228
|
-
((
|
|
229
|
+
((_s = user === null || user === void 0 ? void 0 : user.verifiedCredentials.find((vc) => vc.oauthDisplayName)) === null || _s === void 0 ? void 0 : _s.oauthDisplayName) ||
|
|
229
230
|
'';
|
|
230
231
|
walletConnector.setPasskeyIdentifier(passkeyIdentifier);
|
|
231
232
|
}
|
|
@@ -235,7 +236,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
235
236
|
if (!(turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.id) || !hasEmailVC) {
|
|
236
237
|
return walletConnector.getWebAuthnAttestation();
|
|
237
238
|
}
|
|
238
|
-
const organizationId = (
|
|
239
|
+
const organizationId = (_t = turnkeyWallet === null || turnkeyWallet === void 0 ? void 0 : turnkeyWallet.walletProperties) === null || _t === void 0 ? void 0 : _t.turnkeySubOrganizationId;
|
|
239
240
|
if (!organizationId) {
|
|
240
241
|
throw new DynamicError('No sub organization id found for the wallet', INVALID_WALLET_DATA);
|
|
241
242
|
}
|
|
@@ -274,8 +275,8 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
274
275
|
* @returns Promise<Passkey[]>
|
|
275
276
|
*/
|
|
276
277
|
const getPasskeys = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
277
|
-
var
|
|
278
|
-
const { jwt } = validateUserIsLoggedIn((
|
|
278
|
+
var _u;
|
|
279
|
+
const { jwt } = validateUserIsLoggedIn((_u = getAuthToken()) !== null && _u !== void 0 ? _u : onboardingOnlyJwt);
|
|
279
280
|
const data = yield getUserPasskeys({
|
|
280
281
|
environmentId: environmentId,
|
|
281
282
|
userJwt: jwt,
|
|
@@ -286,26 +287,18 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
286
287
|
* Checks if the embedded wallet session is active
|
|
287
288
|
* @returns boolean
|
|
288
289
|
*/
|
|
289
|
-
const isSessionActive =
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
try {
|
|
293
|
-
const turnkeyAuthenticatorHandler = getEmbeddedWalletAuthHandler(wallet === null || wallet === void 0 ? void 0 : wallet.connector);
|
|
294
|
-
return turnkeyAuthenticatorHandler.isSessionActive();
|
|
295
|
-
}
|
|
296
|
-
catch (err) {
|
|
297
|
-
return false;
|
|
298
|
-
}
|
|
299
|
-
}, [wallet === null || wallet === void 0 ? void 0 : wallet.connector]);
|
|
290
|
+
const isSessionActive = (_d = ((wallet === null || wallet === void 0 ? void 0 : wallet.connector) &&
|
|
291
|
+
'getAuthenticatorHandler' in wallet.connector &&
|
|
292
|
+
((_c = getEmbeddedWalletAuthHandler(wallet.connector)) === null || _c === void 0 ? void 0 : _c.isSessionActive()))) !== null && _d !== void 0 ? _d : false;
|
|
300
293
|
/**
|
|
301
294
|
* Sends a one-time code to the user so they can create a session or add a new passkey
|
|
302
295
|
* @returns Promise<'code_sent'>
|
|
303
296
|
*/
|
|
304
297
|
const sendOneTimeCode = useCallback(() => __awaiter(void 0, void 0, void 0, function* () {
|
|
305
|
-
var
|
|
306
|
-
const { jwt, decodedJwt } = validateUserIsLoggedIn((
|
|
298
|
+
var _v, _w, _x;
|
|
299
|
+
const { jwt, decodedJwt } = validateUserIsLoggedIn((_v = getAuthToken()) !== null && _v !== void 0 ? _v : onboardingOnlyJwt);
|
|
307
300
|
validateTurnkeyProviderEnabled(projectSettings);
|
|
308
|
-
const targetTurnkeyWallet = findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (
|
|
301
|
+
const targetTurnkeyWallet = findTurnkeyWalletByPrimaryChain(walletConnectorOptions, (_w = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _w === void 0 ? void 0 : _w.chainConfigurations, decodedJwt.verifiedCredentials);
|
|
309
302
|
if (!targetTurnkeyWallet || !targetTurnkeyWallet.id) {
|
|
310
303
|
throw new DynamicError('User does not have a valid secure enclave wallet', INVALID_WALLET_DATA);
|
|
311
304
|
}
|
|
@@ -315,7 +308,7 @@ const useSecureEnclaveEmbeddedWallet = () => {
|
|
|
315
308
|
if (isSessionActive) {
|
|
316
309
|
throw new DynamicError('Session is active. No need to create a new one', ACTIVE_SESSION);
|
|
317
310
|
}
|
|
318
|
-
const publicKey = yield turnkeyAuthenticatorHandler.initRecovery('email', turnkeyAuthIframeContainerRef.current,
|
|
311
|
+
const publicKey = yield turnkeyAuthenticatorHandler.initRecovery('email', turnkeyAuthIframeContainerRef.current, iframeElementId, getEmbeddedWalletSessionExpiration((_x = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.embeddedWallets) === null || _x === void 0 ? void 0 : _x.sessionKeyDuration));
|
|
319
312
|
if (!publicKey) {
|
|
320
313
|
throw new DynamicError(ERROR_SENDING_CODE);
|
|
321
314
|
}
|