@dynamic-labs/sdk-react-core 0.19.0-alpha.22 → 0.19.0-alpha.23
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 +10 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +8 -8
- package/src/index.cjs +0 -2
- package/src/index.d.ts +1 -1
- package/src/index.js +0 -1
- package/src/lib/components/SocialSignIn/SocialSignIn.cjs +2 -1
- package/src/lib/components/SocialSignIn/SocialSignIn.js +2 -1
- package/src/lib/data/api.js +1 -1
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.cjs +10 -3
- package/src/lib/utils/hooks/useFetchProjectSettings/useFetchProjectSettings.js +11 -4
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +12 -10
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +12 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.19.0-alpha.23](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.22...v0.19.0-alpha.23) (2023-10-24)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* better handling of CB wallet disconnect + upgrade to 3.7.2 ([#3659](https://github.com/dynamic-labs/DynamicAuth/issues/3659)) ([42a0857](https://github.com/dynamic-labs/DynamicAuth/commit/42a0857c66101cde901661e844c66ba324ff641b))
|
|
8
|
+
* calculate the settings override in real time ([#3671](https://github.com/dynamic-labs/DynamicAuth/issues/3671)) ([06cf28d](https://github.com/dynamic-labs/DynamicAuth/commit/06cf28d4dc29dda21312691985ed1b903d3120cc))
|
|
9
|
+
* handle rp.id edgecases for private domains due to webauthn restrictions on scoping to them ([#3658](https://github.com/dynamic-labs/DynamicAuth/issues/3658)) ([7067bc5](https://github.com/dynamic-labs/DynamicAuth/commit/7067bc5110afb8a010f13c2b2e0170faaa840995))
|
|
10
|
+
* twitter origin check should also look for current window location origin ([#3676](https://github.com/dynamic-labs/DynamicAuth/issues/3676)) ([6c30989](https://github.com/dynamic-labs/DynamicAuth/commit/6c30989d4cde3516a177f6290b5376c5d4c61cbc))
|
|
11
|
+
|
|
2
12
|
## [0.19.0-alpha.22](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.21...v0.19.0-alpha.22) (2023-10-23)
|
|
3
13
|
|
|
4
14
|
|
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.23",
|
|
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.23",
|
|
21
|
+
"@dynamic-labs/multi-wallet": "0.19.0-alpha.23",
|
|
22
|
+
"@dynamic-labs/rpc-providers": "0.19.0-alpha.23",
|
|
23
|
+
"@dynamic-labs/types": "0.19.0-alpha.23",
|
|
24
|
+
"@dynamic-labs/utils": "0.19.0-alpha.23",
|
|
25
|
+
"@dynamic-labs/wallet-book": "0.19.0-alpha.23",
|
|
26
|
+
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.23",
|
|
27
27
|
"eventemitter3": "5.0.1"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
package/src/index.cjs
CHANGED
|
@@ -117,7 +117,6 @@ 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');
|
|
121
120
|
require('./lib/config/ApiEndpoint.cjs');
|
|
122
121
|
require('./lib/utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.cjs');
|
|
123
122
|
var isSameWalletName = require('./lib/utils/functions/isSameWalletName/isSameWalletName.cjs');
|
|
@@ -292,7 +291,6 @@ Object.defineProperty(exports, 'DynamicJwtFromJSON', {
|
|
|
292
291
|
get: function () { return sdkApi.DynamicJwtFromJSON; }
|
|
293
292
|
});
|
|
294
293
|
exports.ShadowDOM = ShadowDOM.ShadowDOM;
|
|
295
|
-
exports.useFetchProjectSettings = useFetchProjectSettings.useFetchProjectSettings;
|
|
296
294
|
exports.isSameWalletName = isSameWalletName.isSameWalletName;
|
|
297
295
|
exports.MockContext = MockContext.MockContext;
|
|
298
296
|
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 {
|
|
26
|
+
export { 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,7 +113,6 @@ 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';
|
|
117
116
|
import './lib/config/ApiEndpoint.js';
|
|
118
117
|
import './lib/utils/hooks/useWallets/utils/verifyMagicIsSetup/verifyMagicIsSetup.js';
|
|
119
118
|
export { isSameWalletName } from './lib/utils/functions/isSameWalletName/isSameWalletName.js';
|
|
@@ -101,7 +101,8 @@ const SocialSignIn = ({ providers, onSelectProvider, isLoading, selectedProvider
|
|
|
101
101
|
jsxRuntime.jsx(iconic.SocialIcon, { name: getProviderAsString(provider), variant: iconThemeVariant }), isSpinning: selectedProvider === provider, iconSize: 32 }), !insideCard && fullWidth && (jsxRuntime.jsxs(Typography.Typography, { variant: 'button_primary', children: ["Connect with ", capitalize.capitalize(getProviderAsString(provider))] }))] }, getProviderAsString(provider)));
|
|
102
102
|
return (jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [jsxRuntime.jsxs("div", { className: 'social-sign-in', style: {
|
|
103
103
|
'--number-of-social-grid-items': numberOfSocialGridItems,
|
|
104
|
-
}, "data-testid": testId, children: [defaultProvider && renderProviderItem(defaultProvider, true), socialProvidersToDisplayInline.map((provider) => renderProviderItem(provider, socialProvidersToDisplayInline.length <
|
|
104
|
+
}, "data-testid": testId, children: [defaultProvider && renderProviderItem(defaultProvider, true), socialProvidersToDisplayInline.map((provider) => renderProviderItem(provider, socialProvidersToDisplayInline.length <
|
|
105
|
+
4 - (defaultProvider ? 1 : 0))), showCardButton && (jsxRuntime.jsx(IconListTile.IconListTile, { dataTestId: 'show-more-options', onClick: () => setShowCard(true), className: 'social-sign-in--tile', children: jsxRuntime.jsx(Icon.Icon, { color: 'text-primary', children: jsxRuntime.jsx(dotsHorizontal.ReactComponent, {}) }) }, 'show-more-options'))] }), jsxRuntime.jsx(OverlayCard.OverlayCard, { isOpen: showCard, onClickOverlay: closeCard, children: jsxRuntime.jsxs("div", { className: 'social-sign-in--card', children: [jsxRuntime.jsx(ModalHeader.ModalHeader, { trailing: closeButton, children: jsxRuntime.jsx(Typography.Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span', children: "Choose a social account" }) }), jsxRuntime.jsx("div", { className: 'social-sign-in--card--body', children: providers.map((provider) => renderProviderItem(provider, false, true)) })] }) })] }));
|
|
105
106
|
};
|
|
106
107
|
|
|
107
108
|
exports.SocialSignIn = SocialSignIn;
|
|
@@ -97,7 +97,8 @@ const SocialSignIn = ({ providers, onSelectProvider, isLoading, selectedProvider
|
|
|
97
97
|
jsx(SocialIcon, { name: getProviderAsString(provider), variant: iconThemeVariant }), isSpinning: selectedProvider === provider, iconSize: 32 }), !insideCard && fullWidth && (jsxs(Typography, { variant: 'button_primary', children: ["Connect with ", capitalize(getProviderAsString(provider))] }))] }, getProviderAsString(provider)));
|
|
98
98
|
return (jsxs(Fragment, { children: [jsxs("div", { className: 'social-sign-in', style: {
|
|
99
99
|
'--number-of-social-grid-items': numberOfSocialGridItems,
|
|
100
|
-
}, "data-testid": testId, children: [defaultProvider && renderProviderItem(defaultProvider, true), socialProvidersToDisplayInline.map((provider) => renderProviderItem(provider, socialProvidersToDisplayInline.length <
|
|
100
|
+
}, "data-testid": testId, children: [defaultProvider && renderProviderItem(defaultProvider, true), socialProvidersToDisplayInline.map((provider) => renderProviderItem(provider, socialProvidersToDisplayInline.length <
|
|
101
|
+
4 - (defaultProvider ? 1 : 0))), showCardButton && (jsx(IconListTile, { dataTestId: 'show-more-options', onClick: () => setShowCard(true), className: 'social-sign-in--tile', children: jsx(Icon, { color: 'text-primary', children: jsx(SvgDotsHorizontal, {}) }) }, 'show-more-options'))] }), jsx(OverlayCard, { isOpen: showCard, onClickOverlay: closeCard, children: jsxs("div", { className: 'social-sign-in--card', children: [jsx(ModalHeader, { trailing: closeButton, children: jsx(Typography, { weight: 'medium', variant: 'body_normal', color: 'primary', as: 'span', children: "Choose a social account" }) }), jsx("div", { className: 'social-sign-in--card--body', children: providers.map((provider) => renderProviderItem(provider, false, true)) })] }) })] }));
|
|
101
102
|
};
|
|
102
103
|
|
|
103
104
|
export { SocialSignIn };
|
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 { UnprocessableEntityErrorCode, ChainEnum, EmbeddedWalletProviderEnum, SDKApi, Configuration, 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';
|
|
@@ -31,6 +31,9 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
31
31
|
removeLsSettings();
|
|
32
32
|
}
|
|
33
33
|
const overrideSettings = (projectSettings, overrides) => {
|
|
34
|
+
if (!projectSettings) {
|
|
35
|
+
return undefined;
|
|
36
|
+
}
|
|
34
37
|
let overrideSettings = projectSettings;
|
|
35
38
|
if (overrides) {
|
|
36
39
|
if (overrides.views) {
|
|
@@ -65,12 +68,11 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
65
68
|
.then((response) => {
|
|
66
69
|
if (!response)
|
|
67
70
|
throw new utils.DynamicError('Settings are not defined');
|
|
68
|
-
const settingsWithOverrides = overrideSettings(response, dynamicContextProps.settings.overrides);
|
|
69
71
|
const expiry = new Date().getTime() + 60000 * 5;
|
|
70
72
|
setLsSettings({
|
|
71
73
|
environmentId,
|
|
72
74
|
expiry: expiry,
|
|
73
|
-
settings:
|
|
75
|
+
settings: response,
|
|
74
76
|
});
|
|
75
77
|
})
|
|
76
78
|
.catch(() => {
|
|
@@ -81,7 +83,12 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
81
83
|
});
|
|
82
84
|
}
|
|
83
85
|
}, [environmentId, isLoading, lsSettingsExists, maxRetries, retries]);
|
|
84
|
-
|
|
86
|
+
const settingsWithOverride = React.useMemo(() => overrideSettings(lsSettings === null || lsSettings === void 0 ? void 0 : lsSettings.settings, dynamicContextProps.settings.overrides), [lsSettings === null || lsSettings === void 0 ? void 0 : lsSettings.settings, dynamicContextProps.settings.overrides]);
|
|
87
|
+
return {
|
|
88
|
+
isLoading,
|
|
89
|
+
projectSettings: settingsWithOverride,
|
|
90
|
+
removeLsSettings,
|
|
91
|
+
};
|
|
85
92
|
};
|
|
86
93
|
|
|
87
94
|
exports.useFetchProjectSettings = useFetchProjectSettings;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useState, useEffect } from 'react';
|
|
1
|
+
import { useState, useEffect, useMemo } from 'react';
|
|
2
2
|
import { DynamicError } from '@dynamic-labs/utils';
|
|
3
3
|
import { sendDynamicProps, fetchProjectSettings } from '../../../data/api.js';
|
|
4
4
|
import '@dynamic-labs/sdk-api';
|
|
@@ -27,6 +27,9 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
27
27
|
removeLsSettings();
|
|
28
28
|
}
|
|
29
29
|
const overrideSettings = (projectSettings, overrides) => {
|
|
30
|
+
if (!projectSettings) {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
30
33
|
let overrideSettings = projectSettings;
|
|
31
34
|
if (overrides) {
|
|
32
35
|
if (overrides.views) {
|
|
@@ -61,12 +64,11 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
61
64
|
.then((response) => {
|
|
62
65
|
if (!response)
|
|
63
66
|
throw new DynamicError('Settings are not defined');
|
|
64
|
-
const settingsWithOverrides = overrideSettings(response, dynamicContextProps.settings.overrides);
|
|
65
67
|
const expiry = new Date().getTime() + 60000 * 5;
|
|
66
68
|
setLsSettings({
|
|
67
69
|
environmentId,
|
|
68
70
|
expiry: expiry,
|
|
69
|
-
settings:
|
|
71
|
+
settings: response,
|
|
70
72
|
});
|
|
71
73
|
})
|
|
72
74
|
.catch(() => {
|
|
@@ -77,7 +79,12 @@ const useFetchProjectSettings = ({ authToken, environmentId, maxRetries = 2, dyn
|
|
|
77
79
|
});
|
|
78
80
|
}
|
|
79
81
|
}, [environmentId, isLoading, lsSettingsExists, maxRetries, retries]);
|
|
80
|
-
|
|
82
|
+
const settingsWithOverride = useMemo(() => overrideSettings(lsSettings === null || lsSettings === void 0 ? void 0 : lsSettings.settings, dynamicContextProps.settings.overrides), [lsSettings === null || lsSettings === void 0 ? void 0 : lsSettings.settings, dynamicContextProps.settings.overrides]);
|
|
83
|
+
return {
|
|
84
|
+
isLoading,
|
|
85
|
+
projectSettings: settingsWithOverride,
|
|
86
|
+
removeLsSettings,
|
|
87
|
+
};
|
|
81
88
|
};
|
|
82
89
|
|
|
83
90
|
export { useFetchProjectSettings };
|
|
@@ -194,16 +194,18 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
194
194
|
if (!(apiProvider === null || apiProvider === void 0 ? void 0 : apiProvider.redirectUrl)) {
|
|
195
195
|
return;
|
|
196
196
|
}
|
|
197
|
-
let expectedOrigin =
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
error
|
|
205
|
-
|
|
206
|
-
|
|
197
|
+
let expectedOrigin = window.location.origin;
|
|
198
|
+
if (!providersWithoutWindowOpenerRefence.includes(provider)) {
|
|
199
|
+
try {
|
|
200
|
+
const redirectUri = new URL(apiProvider.redirectUrl);
|
|
201
|
+
expectedOrigin = redirectUri.origin;
|
|
202
|
+
}
|
|
203
|
+
catch (e) {
|
|
204
|
+
logger.logger.error('Failed to parse social provider redirect url', {
|
|
205
|
+
error: e,
|
|
206
|
+
});
|
|
207
|
+
return;
|
|
208
|
+
}
|
|
207
209
|
}
|
|
208
210
|
const isExpectedOrigin = event.origin === expectedOrigin;
|
|
209
211
|
const isValidMessage = isAuthorizationMessage &&
|
|
@@ -190,16 +190,18 @@ const useSocialAuth = ({ sessionTimeout, authMode, onSettled, onError, }) => {
|
|
|
190
190
|
if (!(apiProvider === null || apiProvider === void 0 ? void 0 : apiProvider.redirectUrl)) {
|
|
191
191
|
return;
|
|
192
192
|
}
|
|
193
|
-
let expectedOrigin =
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
error
|
|
201
|
-
|
|
202
|
-
|
|
193
|
+
let expectedOrigin = window.location.origin;
|
|
194
|
+
if (!providersWithoutWindowOpenerRefence.includes(provider)) {
|
|
195
|
+
try {
|
|
196
|
+
const redirectUri = new URL(apiProvider.redirectUrl);
|
|
197
|
+
expectedOrigin = redirectUri.origin;
|
|
198
|
+
}
|
|
199
|
+
catch (e) {
|
|
200
|
+
logger.error('Failed to parse social provider redirect url', {
|
|
201
|
+
error: e,
|
|
202
|
+
});
|
|
203
|
+
return;
|
|
204
|
+
}
|
|
203
205
|
}
|
|
204
206
|
const isExpectedOrigin = event.origin === expectedOrigin;
|
|
205
207
|
const isValidMessage = isAuthorizationMessage &&
|