@dynamic-labs/sdk-react-core 0.19.0-alpha.20 → 0.19.0-alpha.21
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/README.md +5 -2
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/index.cjs +2 -0
- package/src/index.d.ts +1 -1
- package/src/index.js +1 -0
- package/src/lib/context/DynamicContext/DynamicContext.d.ts +2 -1
- package/src/lib/context/DynamicContext/types/index.d.ts +4 -1
- package/src/lib/data/api.js +1 -1
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +11 -1
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.d.ts +2 -1
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.19.0-alpha.21](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.20...v0.19.0-alpha.21) (2023-10-23)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### ⚠ BREAKING CHANGES
|
|
6
|
+
|
|
7
|
+
* Restructure the SDK packages (#3623)
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* add support for overriding views ([#3649](https://github.com/dynamic-labs/DynamicAuth/issues/3649)) ([a722a1e](https://github.com/dynamic-labs/DynamicAuth/commit/a722a1e48d71373939e5f692bf215985959e1f0b))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
* Restructure the SDK packages ([#3623](https://github.com/dynamic-labs/DynamicAuth/issues/3623)) ([aff5342](https://github.com/dynamic-labs/DynamicAuth/commit/aff5342f469a91b9092128daf74396c3af47f698))
|
|
15
|
+
|
|
2
16
|
## [0.19.0-alpha.20](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.19...v0.19.0-alpha.20) (2023-10-23)
|
|
3
17
|
|
|
4
18
|
|
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ Dynamic offers smart and beautiful login flows for crypto-native users, simple o
|
|
|
13
13
|
Want a quick overview of some of the powerful features Dynamic offers? check out our product walkthrough video below.
|
|
14
14
|
|
|
15
15
|
<a href="https://www.youtube.com/watch?v=LKP-aJOTxfw
|
|
16
|
-
" target="_blank"><img src="https://user-images.githubusercontent.com/1596208/224676777-5f6ffad2-f2c3-4f49-bc4e-a8643da777cd.jpg"
|
|
16
|
+
" target="_blank"><img src="https://user-images.githubusercontent.com/1596208/224676777-5f6ffad2-f2c3-4f49-bc4e-a8643da777cd.jpg"
|
|
17
17
|
alt="Product walkthrough video" width="1280" /></a>
|
|
18
18
|
|
|
19
19
|
## Getting started
|
|
@@ -27,7 +27,10 @@ Here is a shoterned version of the getting started guide:
|
|
|
27
27
|
3. Configure the SDK
|
|
28
28
|
|
|
29
29
|
```js
|
|
30
|
-
import {
|
|
30
|
+
import {
|
|
31
|
+
DynamicContextProvider,
|
|
32
|
+
DynamicWidget,
|
|
33
|
+
} from '@dynamic-labs/sdk-react-core';
|
|
31
34
|
|
|
32
35
|
const App = () => (
|
|
33
36
|
<DynamicContextProvider
|
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": "0.19.0-alpha.
|
|
3
|
+
"version": "0.19.0-alpha.21",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -17,13 +17,13 @@
|
|
|
17
17
|
"react-focus-lock": "2.9.2",
|
|
18
18
|
"react-i18next": "^13.2.0",
|
|
19
19
|
"yup": "0.32.11",
|
|
20
|
-
"@dynamic-labs/logger": "0.19.0-alpha.
|
|
21
|
-
"@dynamic-labs/multi-wallet": "0.19.0-alpha.
|
|
22
|
-
"@dynamic-labs/rpc-providers": "0.19.0-alpha.
|
|
23
|
-
"@dynamic-labs/types": "0.19.0-alpha.
|
|
24
|
-
"@dynamic-labs/utils": "0.19.0-alpha.
|
|
25
|
-
"@dynamic-labs/wallet-book": "0.19.0-alpha.
|
|
26
|
-
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.
|
|
20
|
+
"@dynamic-labs/logger": "0.19.0-alpha.21",
|
|
21
|
+
"@dynamic-labs/multi-wallet": "0.19.0-alpha.21",
|
|
22
|
+
"@dynamic-labs/rpc-providers": "0.19.0-alpha.21",
|
|
23
|
+
"@dynamic-labs/types": "0.19.0-alpha.21",
|
|
24
|
+
"@dynamic-labs/utils": "0.19.0-alpha.21",
|
|
25
|
+
"@dynamic-labs/wallet-book": "0.19.0-alpha.21",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.21",
|
|
27
27
|
"eventemitter3": "5.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
package/src/index.cjs
CHANGED
|
@@ -117,6 +117,7 @@ require('react-focus-lock');
|
|
|
117
117
|
require('./lib/components/Transition/ZoomTransition/ZoomTransition.cjs');
|
|
118
118
|
require('./lib/components/Transition/SlideInUpTransition/SlideInUpTransition.cjs');
|
|
119
119
|
require('./lib/components/Transition/OpacityTransition/OpacityTransition.cjs');
|
|
120
|
+
var useFetchProjectSettings = require('./lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs');
|
|
120
121
|
require('./lib/config/ApiEndpoint.cjs');
|
|
121
122
|
require('./lib/utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
122
123
|
var isSameWalletName = require('./lib/utils/functions/isSameWalletName/isSameWalletName.cjs');
|
|
@@ -291,6 +292,7 @@ Object.defineProperty(exports, 'DynamicJwtFromJSON', {
|
|
|
291
292
|
get: function () { return sdkApi.DynamicJwtFromJSON; }
|
|
292
293
|
});
|
|
293
294
|
exports.ShadowDOM = ShadowDOM.ShadowDOM;
|
|
295
|
+
exports.useFetchProjectSettings = useFetchProjectSettings.useFetchProjectSettings;
|
|
294
296
|
exports.isSameWalletName = isSameWalletName.isSameWalletName;
|
|
295
297
|
exports.MockContext = MockContext.MockContext;
|
|
296
298
|
exports.MockContextProvider = MockContext.MockContextProvider;
|
package/src/index.d.ts
CHANGED
|
@@ -23,7 +23,7 @@ export { classNames } from './lib/utils/functions/classNames';
|
|
|
23
23
|
export { getNetwork } from './lib/utils/functions/getNetwork';
|
|
24
24
|
export * from './lib/utils/functions/walletFilters';
|
|
25
25
|
export { DynamicWidgetContextProvider } from './lib/widgets/DynamicWidget/context';
|
|
26
|
-
export { useWalletItemActions, useAuthenticateConnectedUser, useSocialAccounts, useEmbeddedWallet, useIsLoggedIn, } from './lib/utils/hooks';
|
|
26
|
+
export { useFetchProjectSettings, useWalletItemActions, useAuthenticateConnectedUser, useSocialAccounts, useEmbeddedWallet, useIsLoggedIn, } from './lib/utils/hooks';
|
|
27
27
|
export { useUserUpdateRequest } from './lib/utils/hooks';
|
|
28
28
|
export { type VerifyEmailCallback, useEmailVerificationRequest, } from './lib/utils/hooks/authenticationHooks/';
|
|
29
29
|
export type { UpdateUserFieldsArg } from './lib/utils/hooks/';
|
package/src/index.js
CHANGED
|
@@ -113,6 +113,7 @@ import 'react-focus-lock';
|
|
|
113
113
|
import './lib/components/Transition/ZoomTransition/ZoomTransition.js';
|
|
114
114
|
import './lib/components/Transition/SlideInUpTransition/SlideInUpTransition.js';
|
|
115
115
|
import './lib/components/Transition/OpacityTransition/OpacityTransition.js';
|
|
116
|
+
export { useFetchProjectSettings } from './lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js';
|
|
116
117
|
import './lib/config/ApiEndpoint.js';
|
|
117
118
|
import './lib/utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
118
119
|
export { isSameWalletName } from './lib/utils/functions/isSameWalletName/isSameWalletName.js';
|
|
@@ -6,11 +6,12 @@ import { Resources } from '../../locale';
|
|
|
6
6
|
import { AccessDeniedCustomButton, AuthModeType, ChainToWalletMap, DynamicEventsCallbacks, WalletOption } from '../../shared';
|
|
7
7
|
import { SocialNetworkIconType } from '../../utils/functions/getSocialNetworkIcon';
|
|
8
8
|
import { ThemeData, ThemeSetting } from '../ThemeContext';
|
|
9
|
-
import { ChainsToConnect, IDynamicContext } from './types';
|
|
9
|
+
import { ChainsToConnect, IDynamicContext, SettingsOverrides } from './types';
|
|
10
10
|
export declare const PUBLIC_PROJECT_LIVE_ENVIRONMENT_ID = "2762a57b-faa4-41ce-9f16-abff9300e2c9";
|
|
11
11
|
export interface DynamicContextProps {
|
|
12
12
|
children: ReactNode;
|
|
13
13
|
settings: {
|
|
14
|
+
overrides?: SettingsOverrides;
|
|
14
15
|
walletsByChain?: ChainsToConnect[];
|
|
15
16
|
accessDeniedMessagePrimary?: string;
|
|
16
17
|
accessDeniedMessageSecondary?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Dispatch, MutableRefObject, ReactNode, SetStateAction } from 'react';
|
|
2
|
-
import { DynamicJwt, NameServiceData, ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
2
|
+
import { DynamicJwt, NameServiceData, ProjectSettings, SdkView } from '@dynamic-labs/sdk-api';
|
|
3
3
|
import { NetworkConfigurationMap, SocialProviderFilter, WalletUiUtils } from '@dynamic-labs/types';
|
|
4
4
|
import { Chain, FetchPublicAddressOpts, WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
5
5
|
import { AccessDeniedCustomButton, AccountSwitchState, AuthModeType, AwaitingSignatureState, ChainToWalletMap, DynamicEventsCallbacks, DynamicRPCProviders, MultiWalletWidgetState, UserProfile, Wallet, WalletOption, WalletWithAction } from '../../../shared';
|
|
@@ -13,6 +13,9 @@ export type ChainsToConnect = {
|
|
|
13
13
|
chain: Chain;
|
|
14
14
|
chainId?: number;
|
|
15
15
|
};
|
|
16
|
+
export type SettingsOverrides = {
|
|
17
|
+
views?: Array<SdkView>;
|
|
18
|
+
};
|
|
16
19
|
export interface IDynamicContext {
|
|
17
20
|
accessDeniedMessagePrimary?: string;
|
|
18
21
|
accessDeniedMessageSecondary?: string;
|
package/src/lib/data/api.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { __awaiter } from '../../../_virtual/_tslib.js';
|
|
2
2
|
import { NoAccessError, AccountExistsError, EmailVerificationError, UserHasAccountWithEmailError, DynamicError, EmailAlreadyExistsError, UsernameAlreadyExistsError, EmailProviderError, WalletUsedError, WalletNotDeployedError, ChainalysisError, GateBlockedError, SocialAccountAlreadyExistsError } from '@dynamic-labs/utils';
|
|
3
|
-
import {
|
|
3
|
+
import { SDKApi, Configuration, UnprocessableEntityErrorCode, ChainEnum, EmbeddedWalletProviderEnum, VerifyRequestFromJSON, WalletProviderEnum, AuthModeEnum } from '@dynamic-labs/sdk-api';
|
|
4
4
|
import { VERSION, API_VERSION } from '../../version.js';
|
|
5
5
|
import ApiEndpoint from '../config/ApiEndpoint.js';
|
|
6
6
|
import { logger } from '../shared/logger.js';
|
|
@@ -30,6 +30,15 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
30
30
|
lsSettings.environmentId !== environmentId) {
|
|
31
31
|
removeLsSettings();
|
|
32
32
|
}
|
|
33
|
+
const overrideSettings = (projectSettings, overrides) => {
|
|
34
|
+
let overrideSettings = projectSettings;
|
|
35
|
+
if (overrides) {
|
|
36
|
+
if (overrides.views) {
|
|
37
|
+
overrideSettings = Object.assign(Object.assign({}, overrideSettings), { sdk: Object.assign(Object.assign({}, projectSettings.sdk), { views: overrides.views }) });
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
return overrideSettings;
|
|
41
|
+
};
|
|
33
42
|
React.useEffect(() => {
|
|
34
43
|
const [connectedWalletData] = localStorage$1.LocalStorage.getFromLS(localStorage.CONNECTED_WALLETS_INFO) || [];
|
|
35
44
|
if (!authToken && !connectedWalletData) {
|
|
@@ -56,11 +65,12 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
56
65
|
.then((response) => {
|
|
57
66
|
if (!response)
|
|
58
67
|
throw new utils.DynamicError('Settings are not defined');
|
|
68
|
+
const settingsWithOverrides = overrideSettings(response, dynamicContextProps.settings.overrides);
|
|
59
69
|
const expiry = new Date().getTime() + 60000 * 5;
|
|
60
70
|
setLsSettings({
|
|
61
71
|
environmentId,
|
|
62
72
|
expiry: expiry,
|
|
63
|
-
settings:
|
|
73
|
+
settings: settingsWithOverrides,
|
|
64
74
|
});
|
|
65
75
|
})
|
|
66
76
|
.catch(() => {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ProjectSettings } from '@dynamic-labs/sdk-api';
|
|
1
2
|
import { DynamicContextProps } from '../../../context/DynamicContext';
|
|
2
3
|
export type fetchProjectSettingsProps = {
|
|
3
4
|
authToken: string | undefined;
|
|
@@ -7,6 +8,6 @@ export type fetchProjectSettingsProps = {
|
|
|
7
8
|
};
|
|
8
9
|
export declare const useFetchProjectSettings: ({ authToken, environmentId, maxRetries, dynamicContextProps, }: fetchProjectSettingsProps) => {
|
|
9
10
|
isLoading: boolean;
|
|
10
|
-
projectSettings:
|
|
11
|
+
projectSettings: ProjectSettings | undefined;
|
|
11
12
|
removeLsSettings: () => void;
|
|
12
13
|
};
|
|
@@ -26,6 +26,15 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
26
26
|
lsSettings.environmentId !== environmentId) {
|
|
27
27
|
removeLsSettings();
|
|
28
28
|
}
|
|
29
|
+
const overrideSettings = (projectSettings, overrides) => {
|
|
30
|
+
let overrideSettings = projectSettings;
|
|
31
|
+
if (overrides) {
|
|
32
|
+
if (overrides.views) {
|
|
33
|
+
overrideSettings = Object.assign(Object.assign({}, overrideSettings), { sdk: Object.assign(Object.assign({}, projectSettings.sdk), { views: overrides.views }) });
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
return overrideSettings;
|
|
37
|
+
};
|
|
29
38
|
useEffect(() => {
|
|
30
39
|
const [connectedWalletData] = LocalStorage.getFromLS(CONNECTED_WALLETS_INFO) || [];
|
|
31
40
|
if (!authToken && !connectedWalletData) {
|
|
@@ -52,11 +61,12 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
52
61
|
.then((response) => {
|
|
53
62
|
if (!response)
|
|
54
63
|
throw new DynamicError('Settings are not defined');
|
|
64
|
+
const settingsWithOverrides = overrideSettings(response, dynamicContextProps.settings.overrides);
|
|
55
65
|
const expiry = new Date().getTime() + 60000 * 5;
|
|
56
66
|
setLsSettings({
|
|
57
67
|
environmentId,
|
|
58
68
|
expiry: expiry,
|
|
59
|
-
settings:
|
|
69
|
+
settings: settingsWithOverrides,
|
|
60
70
|
});
|
|
61
71
|
})
|
|
62
72
|
.catch(() => {
|