@dynamic-labs/sdk-react-core 0.19.0-alpha.5 → 0.19.0-alpha.6
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 +16 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +9 -9
- package/src/lib/components/UserProfile/UserProfile.cjs +1 -1
- package/src/lib/components/UserProfile/UserProfile.js +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs +1 -1
- package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js +1 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.cjs +1 -1
- package/src/lib/utils/functions/createUserProfile/createUserProfile.js +1 -1
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.cjs +4 -4
- package/src/lib/utils/hooks/multiWallet/useSyncPrimaryWallet/useSyncPrimaryWallet.js +4 -4
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.cjs +14 -16
- package/src/lib/utils/hooks/useConnectWallet/useConnectWallet.js +15 -17
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.cjs +1 -6
- package/src/lib/utils/hooks/useSocialAccounts/useSocialAccounts.js +1 -6
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.cjs +15 -10
- package/src/lib/utils/hooks/useVerifyWallet/useVerifyWallet.js +15 -10
- package/src/lib/views/LoginView/useLoginView.cjs +12 -3
- package/src/lib/views/LoginView/useLoginView.js +12 -3
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,20 @@
|
|
|
1
1
|
|
|
2
|
+
## [0.19.0-alpha.6](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.5...v0.19.0-alpha.6) (2023-08-25)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* optionally split up email and social and change their display order in login view ([#3125](https://github.com/dynamic-labs/DynamicAuth/issues/3125)) ([ee82d26](https://github.com/dynamic-labs/DynamicAuth/commit/ee82d264eb3cb7f4ca7eb33369ef5409fe6860e4))
|
|
8
|
+
* post a connection request for second wallet ([#3113](https://github.com/dynamic-labs/DynamicAuth/issues/3113)) ([630aefa](https://github.com/dynamic-labs/DynamicAuth/commit/630aefa5ce83278082db1e3cd419c03e4fd081c7))
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
### Bug Fixes
|
|
12
|
+
|
|
13
|
+
* fix bug where user was not able to confirm last wallet transfer ([#3102](https://github.com/dynamic-labs/DynamicAuth/issues/3102)) ([453b4c2](https://github.com/dynamic-labs/DynamicAuth/commit/453b4c20ea8f09d92dda11cdf92ddab562096d6f))
|
|
14
|
+
* fix github social linking icon on dark mode ([#3126](https://github.com/dynamic-labs/DynamicAuth/issues/3126)) ([6a8f3e3](https://github.com/dynamic-labs/DynamicAuth/commit/6a8f3e3d6e43d76b428e169fd5ead9ee0e2ec43d))
|
|
15
|
+
* fix issue with detecting oauth window closed before finishing linking ([#3124](https://github.com/dynamic-labs/DynamicAuth/issues/3124)) ([6a80ee9](https://github.com/dynamic-labs/DynamicAuth/commit/6a80ee97deb54e5b62bf2285d71b03c36802c5d2))
|
|
16
|
+
* stop calling handleLogOut prematurely ([#3135](https://github.com/dynamic-labs/DynamicAuth/issues/3135)) ([e7c81ad](https://github.com/dynamic-labs/DynamicAuth/commit/e7c81ad7e9e9cff03e5d2ca1e0fb7cfea083d06e))
|
|
17
|
+
|
|
2
18
|
## [0.19.0-alpha.5](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.0-alpha.4...v0.19.0-alpha.5) (2023-08-24)
|
|
3
19
|
|
|
4
20
|
|
package/package.cjs
CHANGED
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
var version = "0.19.0-alpha.
|
|
5
|
+
var version = "0.19.0-alpha.6";
|
|
6
6
|
var dependencies = {
|
|
7
7
|
"react-focus-lock": "2.9.2",
|
|
8
8
|
"@dynamic-labs/iconic": "0.1.27",
|
|
9
|
-
"@dynamic-labs/sdk-api": "0.0.
|
|
9
|
+
"@dynamic-labs/sdk-api": "0.0.270",
|
|
10
10
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
11
11
|
"country-list": "2.3.0",
|
|
12
12
|
yup: "0.32.11",
|
package/package.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var version = "0.19.0-alpha.
|
|
1
|
+
var version = "0.19.0-alpha.6";
|
|
2
2
|
var dependencies = {
|
|
3
3
|
"react-focus-lock": "2.9.2",
|
|
4
4
|
"@dynamic-labs/iconic": "0.1.27",
|
|
5
|
-
"@dynamic-labs/sdk-api": "0.0.
|
|
5
|
+
"@dynamic-labs/sdk-api": "0.0.270",
|
|
6
6
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
7
7
|
"country-list": "2.3.0",
|
|
8
8
|
yup: "0.32.11",
|
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.6",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -9,20 +9,20 @@
|
|
|
9
9
|
"dependencies": {
|
|
10
10
|
"react-focus-lock": "2.9.2",
|
|
11
11
|
"@dynamic-labs/iconic": "0.1.27",
|
|
12
|
-
"@dynamic-labs/sdk-api": "0.0.
|
|
12
|
+
"@dynamic-labs/sdk-api": "0.0.270",
|
|
13
13
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
14
14
|
"country-list": "2.3.0",
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"formik": "2.2.9",
|
|
17
17
|
"qrcode": "1.5.1",
|
|
18
18
|
"ethers": "5.7.2",
|
|
19
|
-
"@dynamic-labs/logger": "0.19.0-alpha.
|
|
20
|
-
"@dynamic-labs/multi-wallet": "0.19.0-alpha.
|
|
21
|
-
"@dynamic-labs/rpc-providers": "0.19.0-alpha.
|
|
22
|
-
"@dynamic-labs/types": "0.19.0-alpha.
|
|
23
|
-
"@dynamic-labs/utils": "0.19.0-alpha.
|
|
24
|
-
"@dynamic-labs/wallet-book": "0.19.0-alpha.
|
|
25
|
-
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.
|
|
19
|
+
"@dynamic-labs/logger": "0.19.0-alpha.6",
|
|
20
|
+
"@dynamic-labs/multi-wallet": "0.19.0-alpha.6",
|
|
21
|
+
"@dynamic-labs/rpc-providers": "0.19.0-alpha.6",
|
|
22
|
+
"@dynamic-labs/types": "0.19.0-alpha.6",
|
|
23
|
+
"@dynamic-labs/utils": "0.19.0-alpha.6",
|
|
24
|
+
"@dynamic-labs/wallet-book": "0.19.0-alpha.6",
|
|
25
|
+
"@dynamic-labs/wallet-connector-core": "0.19.0-alpha.6",
|
|
26
26
|
"eventemitter3": "5.0.1"
|
|
27
27
|
},
|
|
28
28
|
"devDependencies": {
|
|
@@ -43,7 +43,7 @@ const UserProfile = ({ rootClassName }) => {
|
|
|
43
43
|
const { label } = index$1.getValueByKey(fieldsConfig.fieldsConfig, name);
|
|
44
44
|
const value = mapFieldKeyToValue(name);
|
|
45
45
|
return (jsxRuntime.jsx(UserProfileField.UserProfileField, { name: name, label: label, value: value }, name));
|
|
46
|
-
}) })) }))), (providers === null || providers === void 0 ? void 0 : providers.length) > 0 && (jsxRuntime.jsx(UserProfileSection.UserProfileSection, Object.assign({ title: 'Social accounts' }, { children: jsxRuntime.jsx("div", Object.assign({ className: 'user-profile__social-accounts' }, { children: providers.map(({
|
|
46
|
+
}) })) }))), (providers === null || providers === void 0 ? void 0 : providers.length) > 0 && (jsxRuntime.jsx(UserProfileSection.UserProfileSection, Object.assign({ title: 'Social accounts' }, { children: jsxRuntime.jsx("div", Object.assign({ className: 'user-profile__social-accounts' }, { children: providers.map(({ provider }) => (jsxRuntime.jsx(UserProfileSocialAccount.UserProfileSocialAccount, { provider: provider }, provider))) })) })))] })));
|
|
47
47
|
};
|
|
48
48
|
|
|
49
49
|
exports.UserProfile = UserProfile;
|
|
@@ -39,7 +39,7 @@ const UserProfile = ({ rootClassName }) => {
|
|
|
39
39
|
const { label } = getValueByKey(fieldsConfig, name);
|
|
40
40
|
const value = mapFieldKeyToValue(name);
|
|
41
41
|
return (jsx(UserProfileField, { name: name, label: label, value: value }, name));
|
|
42
|
-
}) })) }))), (providers === null || providers === void 0 ? void 0 : providers.length) > 0 && (jsx(UserProfileSection, Object.assign({ title: 'Social accounts' }, { children: jsx("div", Object.assign({ className: 'user-profile__social-accounts' }, { children: providers.map(({
|
|
42
|
+
}) })) }))), (providers === null || providers === void 0 ? void 0 : providers.length) > 0 && (jsx(UserProfileSection, Object.assign({ title: 'Social accounts' }, { children: jsx("div", Object.assign({ className: 'user-profile__social-accounts' }, { children: providers.map(({ provider }) => (jsx(UserProfileSocialAccount, { provider: provider }, provider))) })) })))] })));
|
|
43
43
|
};
|
|
44
44
|
|
|
45
45
|
export { UserProfile };
|
package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.cjs
CHANGED
|
@@ -60,7 +60,7 @@ const UserProfileSocialAccount = ({ provider, }) => {
|
|
|
60
60
|
const isProviderLinked = isLinked(provider);
|
|
61
61
|
const connectedAccountInfo = getLinkedAccountInformation(provider);
|
|
62
62
|
const iconThemeVariant = useIconThemeVariant.useIconThemeVariant();
|
|
63
|
-
return (jsxRuntime.jsxs("div", Object.assign({ className: 'user-profile-social-account', "data-testid": `social-account-${provider}` }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'user-profile-social-account__icon' }, { children: isProviderLinked ? (jsxRuntime.jsx(ConnectedAccountAvatar.ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar
|
|
63
|
+
return (jsxRuntime.jsxs("div", Object.assign({ className: 'user-profile-social-account', "data-testid": `social-account-${provider}` }, { children: [jsxRuntime.jsx("div", Object.assign({ className: 'user-profile-social-account__icon' }, { children: isProviderLinked ? (jsxRuntime.jsx(ConnectedAccountAvatar.ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar })) : (jsxRuntime.jsx(iconic.SocialIcon, { name: provider, variant: iconThemeVariant })) })), jsxRuntime.jsx("div", Object.assign({ className: 'user-profile-social-account__label' }, { children: jsxRuntime.jsx(Typography.Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary' }, { children: (_a = connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.publicIdentifier) !== null && _a !== void 0 ? _a : helpers.capitalize(provider) })) })), isProviderLinked ? (jsxRuntime.jsx(Button.Button, { buttonClassName: 'user-profile-social-account__button', buttonVariant: 'secondary', buttonRounded: 'small', buttonPadding: 'none', onClick: () => unlinkSocialAccount(provider), loading: isProcessing, dataTestId: 'social-account-disconnect-button', typographyProps: {
|
|
64
64
|
color: 'secondary',
|
|
65
65
|
variant: 'button_tertiary',
|
|
66
66
|
}, startSlot:
|
package/src/lib/components/UserProfile/parts/UserProfileSocialAccount/UserProfileSocialAccount.js
CHANGED
|
@@ -56,7 +56,7 @@ const UserProfileSocialAccount = ({ provider, }) => {
|
|
|
56
56
|
const isProviderLinked = isLinked(provider);
|
|
57
57
|
const connectedAccountInfo = getLinkedAccountInformation(provider);
|
|
58
58
|
const iconThemeVariant = useIconThemeVariant();
|
|
59
|
-
return (jsxs("div", Object.assign({ className: 'user-profile-social-account', "data-testid": `social-account-${provider}` }, { children: [jsx("div", Object.assign({ className: 'user-profile-social-account__icon' }, { children: isProviderLinked ? (jsx(ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar
|
|
59
|
+
return (jsxs("div", Object.assign({ className: 'user-profile-social-account', "data-testid": `social-account-${provider}` }, { children: [jsx("div", Object.assign({ className: 'user-profile-social-account__icon' }, { children: isProviderLinked ? (jsx(ConnectedAccountAvatar, { provider: provider, avatarUrl: connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.avatar })) : (jsx(SocialIcon, { name: provider, variant: iconThemeVariant })) })), jsx("div", Object.assign({ className: 'user-profile-social-account__label' }, { children: jsx(Typography, Object.assign({ weight: 'medium', variant: 'body_normal', color: 'primary' }, { children: (_a = connectedAccountInfo === null || connectedAccountInfo === void 0 ? void 0 : connectedAccountInfo.publicIdentifier) !== null && _a !== void 0 ? _a : capitalize(provider) })) })), isProviderLinked ? (jsx(Button, { buttonClassName: 'user-profile-social-account__button', buttonVariant: 'secondary', buttonRounded: 'small', buttonPadding: 'none', onClick: () => unlinkSocialAccount(provider), loading: isProcessing, dataTestId: 'social-account-disconnect-button', typographyProps: {
|
|
60
60
|
color: 'secondary',
|
|
61
61
|
variant: 'button_tertiary',
|
|
62
62
|
}, startSlot:
|
|
@@ -29,7 +29,7 @@ const createUserProfile = (decodedJwt) => {
|
|
|
29
29
|
team: decodedJwt.team,
|
|
30
30
|
username: decodedJwt.username,
|
|
31
31
|
};
|
|
32
|
-
const userProfile = Object.assign({ chain: wallet === null || wallet === void 0 ? void 0 : wallet.chain, ens: wallet === null || wallet === void 0 ? void 0 : wallet.nameService, environmentId: decodedJwt.environmentId, isAuthenticatedWithAWallet: ((_a = index.lastAuthenticatedAccount(decodedJwt)) === null || _a === void 0 ? void 0 : _a.format) === 'blockchain', lastVerifiedCredentialId: decodedJwt.lastVerifiedCredentialId, lists: decodedJwt.lists, newUser: decodedJwt.newUser, scope: decodedJwt.scope, sessionId: decodedJwt.sid, userId: decodedJwt.sub, verifiedCredentials: decodedJwt.verifiedCredentials || [], wallet: wallet === null || wallet === void 0 ? void 0 : wallet.walletName }, kyc);
|
|
32
|
+
const userProfile = Object.assign({ chain: wallet === null || wallet === void 0 ? void 0 : wallet.chain, ens: wallet === null || wallet === void 0 ? void 0 : wallet.nameService, environmentId: decodedJwt.environmentId, isAuthenticatedWithAWallet: ((_a = index.lastAuthenticatedAccount(decodedJwt)) === null || _a === void 0 ? void 0 : _a.format) === 'blockchain', lastVerifiedCredentialId: decodedJwt.lastVerifiedCredentialId, lists: decodedJwt.lists, metadata: decodedJwt.metadata, newUser: decodedJwt.newUser, scope: decodedJwt.scope, sessionId: decodedJwt.sid, userId: decodedJwt.sub, verifiedCredentials: decodedJwt.verifiedCredentials || [], wallet: wallet === null || wallet === void 0 ? void 0 : wallet.walletName }, kyc);
|
|
33
33
|
return userProfile;
|
|
34
34
|
};
|
|
35
35
|
|
|
@@ -25,7 +25,7 @@ const createUserProfile = (decodedJwt) => {
|
|
|
25
25
|
team: decodedJwt.team,
|
|
26
26
|
username: decodedJwt.username,
|
|
27
27
|
};
|
|
28
|
-
const userProfile = Object.assign({ chain: wallet === null || wallet === void 0 ? void 0 : wallet.chain, ens: wallet === null || wallet === void 0 ? void 0 : wallet.nameService, environmentId: decodedJwt.environmentId, isAuthenticatedWithAWallet: ((_a = lastAuthenticatedAccount(decodedJwt)) === null || _a === void 0 ? void 0 : _a.format) === 'blockchain', lastVerifiedCredentialId: decodedJwt.lastVerifiedCredentialId, lists: decodedJwt.lists, newUser: decodedJwt.newUser, scope: decodedJwt.scope, sessionId: decodedJwt.sid, userId: decodedJwt.sub, verifiedCredentials: decodedJwt.verifiedCredentials || [], wallet: wallet === null || wallet === void 0 ? void 0 : wallet.walletName }, kyc);
|
|
28
|
+
const userProfile = Object.assign({ chain: wallet === null || wallet === void 0 ? void 0 : wallet.chain, ens: wallet === null || wallet === void 0 ? void 0 : wallet.nameService, environmentId: decodedJwt.environmentId, isAuthenticatedWithAWallet: ((_a = lastAuthenticatedAccount(decodedJwt)) === null || _a === void 0 ? void 0 : _a.format) === 'blockchain', lastVerifiedCredentialId: decodedJwt.lastVerifiedCredentialId, lists: decodedJwt.lists, metadata: decodedJwt.metadata, newUser: decodedJwt.newUser, scope: decodedJwt.scope, sessionId: decodedJwt.sid, userId: decodedJwt.sub, verifiedCredentials: decodedJwt.verifiedCredentials || [], wallet: wallet === null || wallet === void 0 ? void 0 : wallet.walletName }, kyc);
|
|
29
29
|
return userProfile;
|
|
30
30
|
};
|
|
31
31
|
|
|
@@ -91,12 +91,12 @@ const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets,
|
|
|
91
91
|
computeConnectedStateForWallets();
|
|
92
92
|
return;
|
|
93
93
|
}
|
|
94
|
-
if (!primaryWallet.connector.isInstalledOnBrowser()) {
|
|
95
|
-
handleLogOut();
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
94
|
// user is logged in (has valid jwt), but no wallet is connected
|
|
99
95
|
if (isAuthenticated && e.code === errors.MISSING_ADDRESS_ERROR) {
|
|
96
|
+
if (!primaryWallet.connector.isInstalledOnBrowser()) {
|
|
97
|
+
handleLogOut();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
100
|
setShowAuthFlow(true);
|
|
101
101
|
setView('wallet-locked-view');
|
|
102
102
|
}
|
|
@@ -87,12 +87,12 @@ const useSyncPrimaryWallet = ({ connectWallet, computeConnectedStateForWallets,
|
|
|
87
87
|
computeConnectedStateForWallets();
|
|
88
88
|
return;
|
|
89
89
|
}
|
|
90
|
-
if (!primaryWallet.connector.isInstalledOnBrowser()) {
|
|
91
|
-
handleLogOut();
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
90
|
// user is logged in (has valid jwt), but no wallet is connected
|
|
95
91
|
if (isAuthenticated && e.code === MISSING_ADDRESS_ERROR) {
|
|
92
|
+
if (!primaryWallet.connector.isInstalledOnBrowser()) {
|
|
93
|
+
handleLogOut();
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
96
|
setShowAuthFlow(true);
|
|
97
97
|
setView('wallet-locked-view');
|
|
98
98
|
}
|
|
@@ -130,8 +130,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
130
130
|
network: currentWalletConnectoNetwork,
|
|
131
131
|
});
|
|
132
132
|
});
|
|
133
|
-
const shouldSkipCreatingVisit =
|
|
134
|
-
connectedWallet, [authMode, connectedWallet, enableVisitTrackingOnConnectOnly]);
|
|
133
|
+
const shouldSkipCreatingVisit = authMode === 'connect-only' && !enableVisitTrackingOnConnectOnly;
|
|
135
134
|
const connectWallet = (walletConnector, fetchPublicAddressOpts, shouldCallCallback = true) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
136
135
|
const publicWalletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
137
136
|
if (!publicWalletAddress) {
|
|
@@ -168,21 +167,20 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
168
167
|
walletConnectorKey: walletConnector.name,
|
|
169
168
|
walletId,
|
|
170
169
|
});
|
|
170
|
+
if (!shouldSkipCreatingVisit) {
|
|
171
|
+
// send information to backend to kick off background jobs
|
|
172
|
+
// so verify/sign on the next step could go by more quickly
|
|
173
|
+
// this is async work, but DO NOT AWAIT
|
|
174
|
+
api.createVisit({
|
|
175
|
+
authMode,
|
|
176
|
+
chain: walletChain || '',
|
|
177
|
+
environmentId,
|
|
178
|
+
publicWalletAddress,
|
|
179
|
+
walletName: walletConnector.name,
|
|
180
|
+
walletProvider: getWalletProvider.getWalletProvider(walletConnector),
|
|
181
|
+
});
|
|
182
|
+
}
|
|
171
183
|
}
|
|
172
|
-
if (shouldSkipCreatingVisit) {
|
|
173
|
-
return Promise.resolve(publicWalletAddress);
|
|
174
|
-
}
|
|
175
|
-
// send information to backend to kick off background jobs
|
|
176
|
-
// so verify/sign on the next step could go by more quickly
|
|
177
|
-
// this is async work, but DO NOT AWAIT
|
|
178
|
-
api.createVisit({
|
|
179
|
-
authMode,
|
|
180
|
-
chain: walletChain || '',
|
|
181
|
-
environmentId,
|
|
182
|
-
publicWalletAddress,
|
|
183
|
-
walletName: walletConnector.name,
|
|
184
|
-
walletProvider: getWalletProvider.getWalletProvider(walletConnector),
|
|
185
|
-
});
|
|
186
184
|
return Promise.resolve(publicWalletAddress);
|
|
187
185
|
});
|
|
188
186
|
const unlinkConnectedWallet = (walletId) => {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
2
|
-
import { useState, useCallback, useEffect
|
|
2
|
+
import { useState, useCallback, useEffect } from 'react';
|
|
3
3
|
import { getWalletConnectorByName, logger } from '@dynamic-labs/wallet-connector-core';
|
|
4
4
|
import '@dynamic-labs/sdk-api';
|
|
5
5
|
import '../../../shared/logger.js';
|
|
@@ -126,8 +126,7 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
126
126
|
network: currentWalletConnectoNetwork,
|
|
127
127
|
});
|
|
128
128
|
});
|
|
129
|
-
const shouldSkipCreatingVisit =
|
|
130
|
-
connectedWallet, [authMode, connectedWallet, enableVisitTrackingOnConnectOnly]);
|
|
129
|
+
const shouldSkipCreatingVisit = authMode === 'connect-only' && !enableVisitTrackingOnConnectOnly;
|
|
131
130
|
const connectWallet = (walletConnector, fetchPublicAddressOpts, shouldCallCallback = true) => __awaiter(void 0, void 0, void 0, function* () {
|
|
132
131
|
const publicWalletAddress = yield walletConnector.fetchPublicAddress(fetchPublicAddressOpts);
|
|
133
132
|
if (!publicWalletAddress) {
|
|
@@ -164,21 +163,20 @@ const useConnectWallet = ({ authMode, clearPrimaryWalletId, enableVisitTrackingO
|
|
|
164
163
|
walletConnectorKey: walletConnector.name,
|
|
165
164
|
walletId,
|
|
166
165
|
});
|
|
166
|
+
if (!shouldSkipCreatingVisit) {
|
|
167
|
+
// send information to backend to kick off background jobs
|
|
168
|
+
// so verify/sign on the next step could go by more quickly
|
|
169
|
+
// this is async work, but DO NOT AWAIT
|
|
170
|
+
createVisit({
|
|
171
|
+
authMode,
|
|
172
|
+
chain: walletChain || '',
|
|
173
|
+
environmentId,
|
|
174
|
+
publicWalletAddress,
|
|
175
|
+
walletName: walletConnector.name,
|
|
176
|
+
walletProvider: getWalletProvider(walletConnector),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
167
179
|
}
|
|
168
|
-
if (shouldSkipCreatingVisit) {
|
|
169
|
-
return Promise.resolve(publicWalletAddress);
|
|
170
|
-
}
|
|
171
|
-
// send information to backend to kick off background jobs
|
|
172
|
-
// so verify/sign on the next step could go by more quickly
|
|
173
|
-
// this is async work, but DO NOT AWAIT
|
|
174
|
-
createVisit({
|
|
175
|
-
authMode,
|
|
176
|
-
chain: walletChain || '',
|
|
177
|
-
environmentId,
|
|
178
|
-
publicWalletAddress,
|
|
179
|
-
walletName: walletConnector.name,
|
|
180
|
-
walletProvider: getWalletProvider(walletConnector),
|
|
181
|
-
});
|
|
182
180
|
return Promise.resolve(publicWalletAddress);
|
|
183
181
|
});
|
|
184
182
|
const unlinkConnectedWallet = (walletId) => {
|
|
@@ -147,6 +147,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
147
147
|
if (!isValidMessage) {
|
|
148
148
|
return;
|
|
149
149
|
}
|
|
150
|
+
setIsProcessing(true);
|
|
150
151
|
if (!((_c = providersWaitingOauthMessages.current) === null || _c === void 0 ? void 0 : _c[provider])) {
|
|
151
152
|
handleError(types.SocialOAuthErrorCode.SESSION_TIMEOUT, `Linking ${provider} account session timeout.`);
|
|
152
153
|
return;
|
|
@@ -201,15 +202,9 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
201
202
|
if (!providersWithoutWindowOpenerRefence.includes(provider)) {
|
|
202
203
|
// For provider that support window.opener, we need to clear all states/listeners when the window is closed
|
|
203
204
|
authWindowInterval.current = setInterval(() => {
|
|
204
|
-
var _a;
|
|
205
205
|
if (!(authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed)) {
|
|
206
206
|
return;
|
|
207
207
|
}
|
|
208
|
-
// window was closed by user, before completing oauth
|
|
209
|
-
if ((_a = providersWaitingOauthMessages.current) === null || _a === void 0 ? void 0 : _a[provider]) {
|
|
210
|
-
clearListeners();
|
|
211
|
-
handleError(types.SocialOAuthErrorCode.OAUTH_WINDOW_CLOSED, `Linking ${provider} account window closed.`);
|
|
212
|
-
}
|
|
213
208
|
clearInterval(authWindowInterval.current);
|
|
214
209
|
setIsProcessing(false);
|
|
215
210
|
});
|
|
@@ -143,6 +143,7 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
143
143
|
if (!isValidMessage) {
|
|
144
144
|
return;
|
|
145
145
|
}
|
|
146
|
+
setIsProcessing(true);
|
|
146
147
|
if (!((_c = providersWaitingOauthMessages.current) === null || _c === void 0 ? void 0 : _c[provider])) {
|
|
147
148
|
handleError(SocialOAuthErrorCode.SESSION_TIMEOUT, `Linking ${provider} account session timeout.`);
|
|
148
149
|
return;
|
|
@@ -197,15 +198,9 @@ const useSocialAccounts = ({ sessionTimeout } = {
|
|
|
197
198
|
if (!providersWithoutWindowOpenerRefence.includes(provider)) {
|
|
198
199
|
// For provider that support window.opener, we need to clear all states/listeners when the window is closed
|
|
199
200
|
authWindowInterval.current = setInterval(() => {
|
|
200
|
-
var _a;
|
|
201
201
|
if (!(authWindow === null || authWindow === void 0 ? void 0 : authWindow.closed)) {
|
|
202
202
|
return;
|
|
203
203
|
}
|
|
204
|
-
// window was closed by user, before completing oauth
|
|
205
|
-
if ((_a = providersWaitingOauthMessages.current) === null || _a === void 0 ? void 0 : _a[provider]) {
|
|
206
|
-
clearListeners();
|
|
207
|
-
handleError(SocialOAuthErrorCode.OAUTH_WINDOW_CLOSED, `Linking ${provider} account window closed.`);
|
|
208
|
-
}
|
|
209
204
|
clearInterval(authWindowInterval.current);
|
|
210
205
|
setIsProcessing(false);
|
|
211
206
|
});
|
|
@@ -90,21 +90,26 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
};
|
|
93
|
+
const handleWalletUsedError = (e) => {
|
|
94
|
+
var _a;
|
|
95
|
+
// This is a special case where the user is trying to link a wallet
|
|
96
|
+
// and the wallet is already linked and we don't want to kill the session.
|
|
97
|
+
setShowAuthFlow(true);
|
|
98
|
+
setView('wallet-used');
|
|
99
|
+
setIsSingleWalletAccount(false);
|
|
100
|
+
if (e.code === 'reassign_wallet_error') {
|
|
101
|
+
if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.preventOrphanedAccounts) {
|
|
102
|
+
setView('wallet-cannot-be-transferred');
|
|
103
|
+
}
|
|
104
|
+
setIsSingleWalletAccount(true);
|
|
105
|
+
}
|
|
106
|
+
};
|
|
93
107
|
const handleError = (e, walletConnector, address, oauth) => {
|
|
94
108
|
removeConnectedWalletsInfo();
|
|
95
109
|
// Ensure auth verification flag is taken down
|
|
96
110
|
setIsVerificationInProgress(false);
|
|
97
|
-
// This is a special case where the user is trying to link a wallet
|
|
98
|
-
// and the wallet is already linked and we don't want to kill the session.
|
|
99
111
|
if (e instanceof utils.WalletUsedError) {
|
|
100
|
-
|
|
101
|
-
setView('wallet-used');
|
|
102
|
-
setIsSingleWalletAccount(false);
|
|
103
|
-
if (e.code === 'reassign_wallet_error') {
|
|
104
|
-
setView('wallet-cannot-be-transferred');
|
|
105
|
-
setIsSingleWalletAccount(true);
|
|
106
|
-
}
|
|
107
|
-
return;
|
|
112
|
+
return handleWalletUsedError(e);
|
|
108
113
|
}
|
|
109
114
|
walletConnector.endSession();
|
|
110
115
|
if (e instanceof utils.ChainalysisError) {
|
|
@@ -86,21 +86,26 @@ const useVerifyWallet = ({ consumeNonce, displaySiweStatement, environmentId, pr
|
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
88
|
};
|
|
89
|
+
const handleWalletUsedError = (e) => {
|
|
90
|
+
var _a;
|
|
91
|
+
// This is a special case where the user is trying to link a wallet
|
|
92
|
+
// and the wallet is already linked and we don't want to kill the session.
|
|
93
|
+
setShowAuthFlow(true);
|
|
94
|
+
setView('wallet-used');
|
|
95
|
+
setIsSingleWalletAccount(false);
|
|
96
|
+
if (e.code === 'reassign_wallet_error') {
|
|
97
|
+
if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk) === null || _a === void 0 ? void 0 : _a.preventOrphanedAccounts) {
|
|
98
|
+
setView('wallet-cannot-be-transferred');
|
|
99
|
+
}
|
|
100
|
+
setIsSingleWalletAccount(true);
|
|
101
|
+
}
|
|
102
|
+
};
|
|
89
103
|
const handleError = (e, walletConnector, address, oauth) => {
|
|
90
104
|
removeConnectedWalletsInfo();
|
|
91
105
|
// Ensure auth verification flag is taken down
|
|
92
106
|
setIsVerificationInProgress(false);
|
|
93
|
-
// This is a special case where the user is trying to link a wallet
|
|
94
|
-
// and the wallet is already linked and we don't want to kill the session.
|
|
95
107
|
if (e instanceof WalletUsedError) {
|
|
96
|
-
|
|
97
|
-
setView('wallet-used');
|
|
98
|
-
setIsSingleWalletAccount(false);
|
|
99
|
-
if (e.code === 'reassign_wallet_error') {
|
|
100
|
-
setView('wallet-cannot-be-transferred');
|
|
101
|
-
setIsSingleWalletAccount(true);
|
|
102
|
-
}
|
|
103
|
-
return;
|
|
108
|
+
return handleWalletUsedError(e);
|
|
104
109
|
}
|
|
105
110
|
walletConnector.endSession();
|
|
106
111
|
if (e instanceof ChainalysisError) {
|
|
@@ -31,18 +31,27 @@ const useLoginView = () => {
|
|
|
31
31
|
* @returns SdkViewSection[]
|
|
32
32
|
*/
|
|
33
33
|
const getEmailViewSectionDefinition = () => {
|
|
34
|
-
var _a, _b, _c;
|
|
34
|
+
var _a, _b, _c, _d;
|
|
35
35
|
const loginViewSections = [
|
|
36
36
|
{
|
|
37
37
|
type: sdkApi.SdkViewSectionType.Email,
|
|
38
38
|
},
|
|
39
39
|
];
|
|
40
|
-
|
|
41
|
-
|
|
40
|
+
const numOfProvidersToDisplay = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.socialSignIn) === null || _a === void 0 ? void 0 : _a.providers) === null || _b === void 0 ? void 0 : _b.filter((provider) => provider.enabled).length;
|
|
41
|
+
if (numOfProvidersToDisplay) {
|
|
42
42
|
loginViewSections.push({
|
|
43
43
|
numOfItemsToDisplay: numOfProvidersToDisplay,
|
|
44
44
|
type: sdkApi.SdkViewSectionType.Social,
|
|
45
45
|
});
|
|
46
|
+
if ((_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design.modal) === null || _c === void 0 ? void 0 : _c.splitEmailAndSocial) {
|
|
47
|
+
loginViewSections.splice(1, 0, {
|
|
48
|
+
label: 'Or',
|
|
49
|
+
type: sdkApi.SdkViewSectionType.Separator,
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
if ((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design.modal) === null || _d === void 0 ? void 0 : _d.socialAboveEmail) {
|
|
54
|
+
loginViewSections.reverse();
|
|
46
55
|
}
|
|
47
56
|
return loginViewSections;
|
|
48
57
|
};
|
|
@@ -27,18 +27,27 @@ const useLoginView = () => {
|
|
|
27
27
|
* @returns SdkViewSection[]
|
|
28
28
|
*/
|
|
29
29
|
const getEmailViewSectionDefinition = () => {
|
|
30
|
-
var _a, _b, _c;
|
|
30
|
+
var _a, _b, _c, _d;
|
|
31
31
|
const loginViewSections = [
|
|
32
32
|
{
|
|
33
33
|
type: SdkViewSectionType.Email,
|
|
34
34
|
},
|
|
35
35
|
];
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
const numOfProvidersToDisplay = (_b = (_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.sdk.socialSignIn) === null || _a === void 0 ? void 0 : _a.providers) === null || _b === void 0 ? void 0 : _b.filter((provider) => provider.enabled).length;
|
|
37
|
+
if (numOfProvidersToDisplay) {
|
|
38
38
|
loginViewSections.push({
|
|
39
39
|
numOfItemsToDisplay: numOfProvidersToDisplay,
|
|
40
40
|
type: SdkViewSectionType.Social,
|
|
41
41
|
});
|
|
42
|
+
if ((_c = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design.modal) === null || _c === void 0 ? void 0 : _c.splitEmailAndSocial) {
|
|
43
|
+
loginViewSections.splice(1, 0, {
|
|
44
|
+
label: 'Or',
|
|
45
|
+
type: SdkViewSectionType.Separator,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
if ((_d = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.design.modal) === null || _d === void 0 ? void 0 : _d.socialAboveEmail) {
|
|
50
|
+
loginViewSections.reverse();
|
|
42
51
|
}
|
|
43
52
|
return loginViewSections;
|
|
44
53
|
};
|