@dynamic-labs/sdk-react-core 0.19.6 → 0.19.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 +10 -0
- package/package.cjs +1 -1
- package/package.js +1 -1
- package/package.json +9 -9
- package/src/lib/context/DynamicContext/DynamicContext.cjs +15 -12
- package/src/lib/context/DynamicContext/DynamicContext.js +15 -12
- package/src/lib/context/DynamicContext/useCustomerCallbacks/types.d.ts +3 -5
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.cjs +5 -24
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.d.ts +1 -1
- package/src/lib/context/DynamicContext/useCustomerCallbacks/useCustomerCallbacks.js +5 -24
- package/src/lib/utils/functions/walletListBuilder/utils/groupWalletOptions/groupWalletOptions.cjs +5 -3
- package/src/lib/utils/functions/walletListBuilder/utils/groupWalletOptions/groupWalletOptions.js +5 -3
- package/src/lib/views/EmailVerification/EmailVerification.cjs +2 -5
- package/src/lib/views/EmailVerification/EmailVerification.js +2 -5
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.cjs +8 -2
- package/src/lib/views/EmailWalletOTPVerificationView/EmailWalletOTPVerificationView.js +8 -2
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.cjs +6 -2
- package/src/lib/widgets/DynamicWidget/components/EmailOTPConnectorPendingSignModalContent/EmailOTPConnectorPendingSignModalContent.js +6 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
### [0.19.7](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.6...v0.19.7) (2023-12-18)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* prevent duplicated brave wallet connector ([#4208](https://github.com/dynamic-labs/DynamicAuth/issues/4208)) ([dd09a63](https://github.com/dynamic-labs/DynamicAuth/commit/dd09a635bad3afe6314acbaa07a18db3b6540326))
|
|
8
|
+
* call email verification callbacks reliably ([#4176](https://github.com/dynamic-labs/DynamicAuth/issues/4176)) ([dda35c2](https://github.com/dynamic-labs/DynamicAuth/commit/dda35c29e2d990502a3d2d5330e40e3d1bdaa927))
|
|
9
|
+
* ensure wallets group view shows multiple options ([#4184](https://github.com/dynamic-labs/DynamicAuth/issues/4184)) ([#4188](https://github.com/dynamic-labs/DynamicAuth/issues/4188)) ([b3b7542](https://github.com/dynamic-labs/DynamicAuth/commit/b3b75427e8e7f923745f5fd71852f260fca73d5b))
|
|
10
|
+
* enable brave to read the connected network ([#4199](https://github.com/dynamic-labs/DynamicAuth/issues/4199)) ([2d046a4](https://github.com/dynamic-labs/DynamicAuth/commit/2d046a4067be6a8bfb775be6664844f1b6a5c668))
|
|
11
|
+
|
|
2
12
|
### [0.19.6](https://github.com/dynamic-labs/DynamicAuth/compare/v0.19.5...v0.19.6) (2023-12-14)
|
|
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.
|
|
3
|
+
"version": "0.19.7",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/dynamic-labs/DynamicAuth.git",
|
|
@@ -17,14 +17,14 @@
|
|
|
17
17
|
"react-focus-lock": "2.9.2",
|
|
18
18
|
"react-i18next": "^13.2.0",
|
|
19
19
|
"yup": "0.32.11",
|
|
20
|
-
"@dynamic-labs/ethereum": "0.19.
|
|
21
|
-
"@dynamic-labs/logger": "0.19.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "0.19.
|
|
23
|
-
"@dynamic-labs/rpc-providers": "0.19.
|
|
24
|
-
"@dynamic-labs/types": "0.19.
|
|
25
|
-
"@dynamic-labs/utils": "0.19.
|
|
26
|
-
"@dynamic-labs/wallet-book": "0.19.
|
|
27
|
-
"@dynamic-labs/wallet-connector-core": "0.19.
|
|
20
|
+
"@dynamic-labs/ethereum": "0.19.7",
|
|
21
|
+
"@dynamic-labs/logger": "0.19.7",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "0.19.7",
|
|
23
|
+
"@dynamic-labs/rpc-providers": "0.19.7",
|
|
24
|
+
"@dynamic-labs/types": "0.19.7",
|
|
25
|
+
"@dynamic-labs/utils": "0.19.7",
|
|
26
|
+
"@dynamic-labs/wallet-book": "0.19.7",
|
|
27
|
+
"@dynamic-labs/wallet-connector-core": "0.19.7",
|
|
28
28
|
"eventemitter3": "5.0.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -392,24 +392,27 @@ const DynamicContextProvider = ({ children, theme, settings, locale: locale$1, }
|
|
|
392
392
|
helpers.initExpirationTime(handleLogOut);
|
|
393
393
|
}, [handleLogOut]);
|
|
394
394
|
useCustomerAuthFlowCallbacks.useCustomerAuthFlowCallbacks({ eventsCallbacks, showAuthFlow });
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
395
|
+
// "useTieCallbacksToEvents"
|
|
396
|
+
React.useEffect(() => {
|
|
397
|
+
const dynamicEvents = internalEventsRef.current;
|
|
398
|
+
const emailCallback = (result, email) => {
|
|
399
|
+
var _a, _b;
|
|
400
|
+
if (result)
|
|
401
|
+
(_a = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onEmailVerificationSuccess) === null || _a === void 0 ? void 0 : _a.call(eventsCallbacks, email);
|
|
402
|
+
else
|
|
403
|
+
(_b = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onEmailVerificationFailure) === null || _b === void 0 ? void 0 : _b.call(eventsCallbacks, email);
|
|
404
|
+
};
|
|
405
|
+
dynamicEvents.on('emailVerificationResult', emailCallback);
|
|
406
|
+
return () => {
|
|
407
|
+
dynamicEvents.off('emailVerificationResult', emailCallback);
|
|
408
|
+
};
|
|
409
|
+
}, [eventsCallbacks]);
|
|
405
410
|
const { setCallback } = useCustomerCallbacks.useCustomerCallbacks({
|
|
406
411
|
authMode,
|
|
407
412
|
callbacks: {
|
|
408
413
|
onAuthSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onAuthSuccess,
|
|
409
414
|
onBeforeConnectSuccessConfirmation: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onBeforeConnectSuccessConfirmation,
|
|
410
415
|
onConnect: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onConnect,
|
|
411
|
-
onEmailVerificationFailure,
|
|
412
|
-
onEmailVerificationSuccess,
|
|
413
416
|
onEmbeddedWalletCreated: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onEmbeddedWalletCreated,
|
|
414
417
|
onLinkSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLinkSuccess,
|
|
415
418
|
onUserProfileUpdate: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onUserProfileUpdate,
|
|
@@ -388,24 +388,27 @@ const DynamicContextProvider = ({ children, theme, settings, locale, }) => {
|
|
|
388
388
|
initExpirationTime(handleLogOut);
|
|
389
389
|
}, [handleLogOut]);
|
|
390
390
|
useCustomerAuthFlowCallbacks({ eventsCallbacks, showAuthFlow });
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
391
|
+
// "useTieCallbacksToEvents"
|
|
392
|
+
useEffect(() => {
|
|
393
|
+
const dynamicEvents = internalEventsRef.current;
|
|
394
|
+
const emailCallback = (result, email) => {
|
|
395
|
+
var _a, _b;
|
|
396
|
+
if (result)
|
|
397
|
+
(_a = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onEmailVerificationSuccess) === null || _a === void 0 ? void 0 : _a.call(eventsCallbacks, email);
|
|
398
|
+
else
|
|
399
|
+
(_b = eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onEmailVerificationFailure) === null || _b === void 0 ? void 0 : _b.call(eventsCallbacks, email);
|
|
400
|
+
};
|
|
401
|
+
dynamicEvents.on('emailVerificationResult', emailCallback);
|
|
402
|
+
return () => {
|
|
403
|
+
dynamicEvents.off('emailVerificationResult', emailCallback);
|
|
404
|
+
};
|
|
405
|
+
}, [eventsCallbacks]);
|
|
401
406
|
const { setCallback } = useCustomerCallbacks({
|
|
402
407
|
authMode,
|
|
403
408
|
callbacks: {
|
|
404
409
|
onAuthSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onAuthSuccess,
|
|
405
410
|
onBeforeConnectSuccessConfirmation: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onBeforeConnectSuccessConfirmation,
|
|
406
411
|
onConnect: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onConnect,
|
|
407
|
-
onEmailVerificationFailure,
|
|
408
|
-
onEmailVerificationSuccess,
|
|
409
412
|
onEmbeddedWalletCreated: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onEmbeddedWalletCreated,
|
|
410
413
|
onLinkSuccess: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onLinkSuccess,
|
|
411
414
|
onUserProfileUpdate: eventsCallbacks === null || eventsCallbacks === void 0 ? void 0 : eventsCallbacks.onUserProfileUpdate,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api/src/models/JwtVerifiedCredential';
|
|
2
2
|
import { WalletConnectorCore } from '@dynamic-labs/wallet-connector-core';
|
|
3
3
|
import { WalletConnector } from '../../../..';
|
|
4
|
-
import { AuthModeType, OnAuthSuccess, OnBeforeConnectSuccessConfirmation, onConnect,
|
|
4
|
+
import { AuthModeType, OnAuthSuccess, OnBeforeConnectSuccessConfirmation, onConnect, OnEmbeddedWalletCreated, OnUserProfileUpdate, UserProfile, Wallet } from '../../../shared/types';
|
|
5
5
|
import { IDynamicContext } from '../types';
|
|
6
|
-
export type Callback = 'authSuccess' | 'linkSuccess' | '
|
|
6
|
+
export type Callback = 'authSuccess' | 'linkSuccess' | 'userProfileUpdate' | 'connectSuccess' | 'onBeforeConnectSuccessConfirmation' | 'embeddedWalletCreated';
|
|
7
7
|
export type CallbackParams = {
|
|
8
|
-
/** For
|
|
8
|
+
/** For embedded wallet events */
|
|
9
9
|
email?: string;
|
|
10
10
|
verifiedCredential?: JwtVerifiedCredential;
|
|
11
11
|
/** Used to indicate which wallet connector the callback refers to (ex onLinkSuccess) */
|
|
@@ -15,8 +15,6 @@ export type UseCustomerCallbacksArgs = {
|
|
|
15
15
|
authMode: AuthModeType;
|
|
16
16
|
callbacks: {
|
|
17
17
|
onAuthSuccess?: OnAuthSuccess;
|
|
18
|
-
onEmailVerificationSuccess?: OnEmailVerificationSuccess;
|
|
19
|
-
onEmailVerificationFailure?: OnEmailVerificationFailure;
|
|
20
18
|
onConnect?: onConnect;
|
|
21
19
|
onBeforeConnectSuccessConfirmation?: OnBeforeConnectSuccessConfirmation;
|
|
22
20
|
onLinkSuccess?: OnAuthSuccess;
|
|
@@ -19,7 +19,7 @@ require('@dynamic-labs/multi-wallet');
|
|
|
19
19
|
var getAuthToken = require('../../../utils/functions/getAuthToken/getAuthToken.cjs');
|
|
20
20
|
var isConnectOnly = require('../../../utils/hooks/authenticationHooks/helpers/isConnectOnly.cjs');
|
|
21
21
|
|
|
22
|
-
const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate, onConnect,
|
|
22
|
+
const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate, onConnect, onEmbeddedWalletCreated, }, handleLogOut, primaryWallet, selectedWalletConnector, user, isAuthenticated, authMode, setIsVerificationInProgress, }) => {
|
|
23
23
|
const [callbackQueue, setCallbackQueue] = React.useState([]);
|
|
24
24
|
const isConnectOnlyAndCallbackIsConnectSuccess = React.useCallback((next) => isConnectOnly.isConnectOnly(user, authMode) &&
|
|
25
25
|
Boolean(primaryWallet) &&
|
|
@@ -53,7 +53,7 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
53
53
|
setIsVerificationInProgress,
|
|
54
54
|
]);
|
|
55
55
|
const handleNextCallback = React.useCallback((next, authToken, user) => {
|
|
56
|
-
var _a, _b
|
|
56
|
+
var _a, _b;
|
|
57
57
|
switch (next === null || next === void 0 ? void 0 : next.callback) {
|
|
58
58
|
case 'authSuccess': {
|
|
59
59
|
try {
|
|
@@ -72,24 +72,6 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
72
72
|
}
|
|
73
73
|
break;
|
|
74
74
|
}
|
|
75
|
-
case 'emailVerificationFailure': {
|
|
76
|
-
try {
|
|
77
|
-
onEmailVerificationFailure === null || onEmailVerificationFailure === void 0 ? void 0 : onEmailVerificationFailure((_b = (_a = next.params) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : '');
|
|
78
|
-
}
|
|
79
|
-
catch (e) {
|
|
80
|
-
logger.logger.error('Error calling onEmailVerificationFailure: ', e);
|
|
81
|
-
}
|
|
82
|
-
break;
|
|
83
|
-
}
|
|
84
|
-
case 'emailVerificationSuccess': {
|
|
85
|
-
try {
|
|
86
|
-
onEmailVerificationSuccess === null || onEmailVerificationSuccess === void 0 ? void 0 : onEmailVerificationSuccess((_d = (_c = next.params) === null || _c === void 0 ? void 0 : _c.email) !== null && _d !== void 0 ? _d : '');
|
|
87
|
-
}
|
|
88
|
-
catch (e) {
|
|
89
|
-
logger.logger.error('Error calling onEmailVerificationSuccess: ', e);
|
|
90
|
-
}
|
|
91
|
-
break;
|
|
92
|
-
}
|
|
93
75
|
case 'linkSuccess': {
|
|
94
76
|
try {
|
|
95
77
|
onLinkSuccess === null || onLinkSuccess === void 0 ? void 0 : onLinkSuccess({
|
|
@@ -98,7 +80,7 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
98
80
|
isAuthenticated,
|
|
99
81
|
primaryWallet,
|
|
100
82
|
user,
|
|
101
|
-
walletConnector: (
|
|
83
|
+
walletConnector: (_a = next.params) === null || _a === void 0 ? void 0 : _a.walletConnector,
|
|
102
84
|
});
|
|
103
85
|
}
|
|
104
86
|
catch (e) {
|
|
@@ -117,7 +99,7 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
117
99
|
}
|
|
118
100
|
case 'embeddedWalletCreated': {
|
|
119
101
|
try {
|
|
120
|
-
onEmbeddedWalletCreated === null || onEmbeddedWalletCreated === void 0 ? void 0 : onEmbeddedWalletCreated((
|
|
102
|
+
onEmbeddedWalletCreated === null || onEmbeddedWalletCreated === void 0 ? void 0 : onEmbeddedWalletCreated((_b = next.params) === null || _b === void 0 ? void 0 : _b.verifiedCredential);
|
|
121
103
|
}
|
|
122
104
|
catch (e) {
|
|
123
105
|
logger.logger.error('Error calling onEmbeddedWalletCreated: ', e);
|
|
@@ -128,8 +110,7 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
128
110
|
handleLogOut,
|
|
129
111
|
isAuthenticated,
|
|
130
112
|
onAuthSuccess,
|
|
131
|
-
|
|
132
|
-
onEmailVerificationSuccess,
|
|
113
|
+
onEmbeddedWalletCreated,
|
|
133
114
|
onLinkSuccess,
|
|
134
115
|
onUserProfileUpdate,
|
|
135
116
|
primaryWallet,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { SetCallbackType, UseCustomerCallbacksArgs } from './types';
|
|
2
|
-
export declare const useCustomerCallbacks: ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate, onConnect,
|
|
2
|
+
export declare const useCustomerCallbacks: ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate, onConnect, onEmbeddedWalletCreated, }, handleLogOut, primaryWallet, selectedWalletConnector, user, isAuthenticated, authMode, setIsVerificationInProgress, }: UseCustomerCallbacksArgs) => {
|
|
3
3
|
setCallback: SetCallbackType;
|
|
4
4
|
};
|
|
@@ -15,7 +15,7 @@ import '@dynamic-labs/multi-wallet';
|
|
|
15
15
|
import { getAuthToken } from '../../../utils/functions/getAuthToken/getAuthToken.js';
|
|
16
16
|
import { isConnectOnly } from '../../../utils/hooks/authenticationHooks/helpers/isConnectOnly.js';
|
|
17
17
|
|
|
18
|
-
const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate, onConnect,
|
|
18
|
+
const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUserProfileUpdate, onConnect, onEmbeddedWalletCreated, }, handleLogOut, primaryWallet, selectedWalletConnector, user, isAuthenticated, authMode, setIsVerificationInProgress, }) => {
|
|
19
19
|
const [callbackQueue, setCallbackQueue] = useState([]);
|
|
20
20
|
const isConnectOnlyAndCallbackIsConnectSuccess = useCallback((next) => isConnectOnly(user, authMode) &&
|
|
21
21
|
Boolean(primaryWallet) &&
|
|
@@ -49,7 +49,7 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
49
49
|
setIsVerificationInProgress,
|
|
50
50
|
]);
|
|
51
51
|
const handleNextCallback = useCallback((next, authToken, user) => {
|
|
52
|
-
var _a, _b
|
|
52
|
+
var _a, _b;
|
|
53
53
|
switch (next === null || next === void 0 ? void 0 : next.callback) {
|
|
54
54
|
case 'authSuccess': {
|
|
55
55
|
try {
|
|
@@ -68,24 +68,6 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
68
68
|
}
|
|
69
69
|
break;
|
|
70
70
|
}
|
|
71
|
-
case 'emailVerificationFailure': {
|
|
72
|
-
try {
|
|
73
|
-
onEmailVerificationFailure === null || onEmailVerificationFailure === void 0 ? void 0 : onEmailVerificationFailure((_b = (_a = next.params) === null || _a === void 0 ? void 0 : _a.email) !== null && _b !== void 0 ? _b : '');
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
logger.error('Error calling onEmailVerificationFailure: ', e);
|
|
77
|
-
}
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
case 'emailVerificationSuccess': {
|
|
81
|
-
try {
|
|
82
|
-
onEmailVerificationSuccess === null || onEmailVerificationSuccess === void 0 ? void 0 : onEmailVerificationSuccess((_d = (_c = next.params) === null || _c === void 0 ? void 0 : _c.email) !== null && _d !== void 0 ? _d : '');
|
|
83
|
-
}
|
|
84
|
-
catch (e) {
|
|
85
|
-
logger.error('Error calling onEmailVerificationSuccess: ', e);
|
|
86
|
-
}
|
|
87
|
-
break;
|
|
88
|
-
}
|
|
89
71
|
case 'linkSuccess': {
|
|
90
72
|
try {
|
|
91
73
|
onLinkSuccess === null || onLinkSuccess === void 0 ? void 0 : onLinkSuccess({
|
|
@@ -94,7 +76,7 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
94
76
|
isAuthenticated,
|
|
95
77
|
primaryWallet,
|
|
96
78
|
user,
|
|
97
|
-
walletConnector: (
|
|
79
|
+
walletConnector: (_a = next.params) === null || _a === void 0 ? void 0 : _a.walletConnector,
|
|
98
80
|
});
|
|
99
81
|
}
|
|
100
82
|
catch (e) {
|
|
@@ -113,7 +95,7 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
113
95
|
}
|
|
114
96
|
case 'embeddedWalletCreated': {
|
|
115
97
|
try {
|
|
116
|
-
onEmbeddedWalletCreated === null || onEmbeddedWalletCreated === void 0 ? void 0 : onEmbeddedWalletCreated((
|
|
98
|
+
onEmbeddedWalletCreated === null || onEmbeddedWalletCreated === void 0 ? void 0 : onEmbeddedWalletCreated((_b = next.params) === null || _b === void 0 ? void 0 : _b.verifiedCredential);
|
|
117
99
|
}
|
|
118
100
|
catch (e) {
|
|
119
101
|
logger.error('Error calling onEmbeddedWalletCreated: ', e);
|
|
@@ -124,8 +106,7 @@ const useCustomerCallbacks = ({ callbacks: { onAuthSuccess, onLinkSuccess, onUse
|
|
|
124
106
|
handleLogOut,
|
|
125
107
|
isAuthenticated,
|
|
126
108
|
onAuthSuccess,
|
|
127
|
-
|
|
128
|
-
onEmailVerificationSuccess,
|
|
109
|
+
onEmbeddedWalletCreated,
|
|
129
110
|
onLinkSuccess,
|
|
130
111
|
onUserProfileUpdate,
|
|
131
112
|
primaryWallet,
|
package/src/lib/utils/functions/walletListBuilder/utils/groupWalletOptions/groupWalletOptions.cjs
CHANGED
|
@@ -28,9 +28,11 @@ const groupWalletOptions = (walletBook$1, walletOptionList) => {
|
|
|
28
28
|
// Validate if there is any other wallet with the same group
|
|
29
29
|
const isThereWalletOptionWithSameGroup = walletOptionList.some((walletOption) => {
|
|
30
30
|
var _a;
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
31
|
+
const isSameGroup = currentWalletOption.group === walletOption.group;
|
|
32
|
+
const isDifferentKey = currentWalletOption.key !== walletOption.key;
|
|
33
|
+
const hasInjectedConfig = ((_a = walletOption.injectedConfig) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
34
|
+
walletOption.injectedConfig.length > 1;
|
|
35
|
+
return isSameGroup && (hasInjectedConfig || isDifferentKey);
|
|
34
36
|
});
|
|
35
37
|
// Avoid group creation if there only one wallet in group
|
|
36
38
|
if (!isThereWalletOptionWithSameGroup) {
|
package/src/lib/utils/functions/walletListBuilder/utils/groupWalletOptions/groupWalletOptions.js
CHANGED
|
@@ -24,9 +24,11 @@ const groupWalletOptions = (walletBook, walletOptionList) => {
|
|
|
24
24
|
// Validate if there is any other wallet with the same group
|
|
25
25
|
const isThereWalletOptionWithSameGroup = walletOptionList.some((walletOption) => {
|
|
26
26
|
var _a;
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
const isSameGroup = currentWalletOption.group === walletOption.group;
|
|
28
|
+
const isDifferentKey = currentWalletOption.key !== walletOption.key;
|
|
29
|
+
const hasInjectedConfig = ((_a = walletOption.injectedConfig) === null || _a === void 0 ? void 0 : _a.length) &&
|
|
30
|
+
walletOption.injectedConfig.length > 1;
|
|
31
|
+
return isSameGroup && (hasInjectedConfig || isDifferentKey);
|
|
30
32
|
});
|
|
31
33
|
// Avoid group creation if there only one wallet in group
|
|
32
34
|
if (!isThereWalletOptionWithSameGroup) {
|
|
@@ -94,7 +94,7 @@ const EmailVerification = () => {
|
|
|
94
94
|
const { view, setView, goToInitialView } = ViewContext.useViewContext();
|
|
95
95
|
const { error, setError, setErrorMessage } = ErrorContext.useErrorContext();
|
|
96
96
|
const { setExistentAccountData } = AccountExistsContext.useAccountExistsContext();
|
|
97
|
-
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, setIsVerificationInProgress, projectSettings, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
97
|
+
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, setIsVerificationInProgress, projectSettings, internalEvents, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
98
98
|
const { email, verificationUUID, setVerificationUUID } = EmailVerificationContext.useEmailVerificationContext();
|
|
99
99
|
const { loading, setLoading } = LoadingContext.useLoadingContext();
|
|
100
100
|
const { t } = reactI18next.useTranslation();
|
|
@@ -108,10 +108,7 @@ const EmailVerification = () => {
|
|
|
108
108
|
useOnUnmount.useOnUnmount(() => {
|
|
109
109
|
if (!callCallbackOnUnmount.current)
|
|
110
110
|
return;
|
|
111
|
-
|
|
112
|
-
? 'emailVerificationSuccess'
|
|
113
|
-
: 'emailVerificationFailure';
|
|
114
|
-
setCallback(callback, { email: email !== null && email !== void 0 ? email : '' });
|
|
111
|
+
internalEvents.current.emit('emailVerificationResult', isValidatedRef.current, email !== null && email !== void 0 ? email : '');
|
|
115
112
|
});
|
|
116
113
|
useEffectOnce.useEffectOnce(() => {
|
|
117
114
|
// Set verification in progress
|
|
@@ -90,7 +90,7 @@ const EmailVerification = () => {
|
|
|
90
90
|
const { view, setView, goToInitialView } = useViewContext();
|
|
91
91
|
const { error, setError, setErrorMessage } = useErrorContext();
|
|
92
92
|
const { setExistentAccountData } = useAccountExistsContext();
|
|
93
|
-
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, setIsVerificationInProgress, projectSettings, } = useInternalDynamicContext();
|
|
93
|
+
const { environmentId, onboardingOnlyJwt, handleLogOut, authToken, setOnboardingOnlyJwt, setShowAuthFlow, setCallback, setIsVerificationInProgress, projectSettings, internalEvents, } = useInternalDynamicContext();
|
|
94
94
|
const { email, verificationUUID, setVerificationUUID } = useEmailVerificationContext();
|
|
95
95
|
const { loading, setLoading } = useLoadingContext();
|
|
96
96
|
const { t } = useTranslation();
|
|
@@ -104,10 +104,7 @@ const EmailVerification = () => {
|
|
|
104
104
|
useOnUnmount(() => {
|
|
105
105
|
if (!callCallbackOnUnmount.current)
|
|
106
106
|
return;
|
|
107
|
-
|
|
108
|
-
? 'emailVerificationSuccess'
|
|
109
|
-
: 'emailVerificationFailure';
|
|
110
|
-
setCallback(callback, { email: email !== null && email !== void 0 ? email : '' });
|
|
107
|
+
internalEvents.current.emit('emailVerificationResult', isValidatedRef.current, email !== null && email !== void 0 ? email : '');
|
|
111
108
|
});
|
|
112
109
|
useEffectOnce(() => {
|
|
113
110
|
// Set verification in progress
|
|
@@ -63,7 +63,7 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
63
63
|
const { setView } = ViewContext.useViewContext();
|
|
64
64
|
const [error, setError] = React.useState();
|
|
65
65
|
const { t } = reactI18next.useTranslation();
|
|
66
|
-
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
66
|
+
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, internalEvents, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
67
67
|
if (!emailWalletConnector ||
|
|
68
68
|
!walletConnectorCore.isEmailOTPWalletConnector(emailWalletConnector)) {
|
|
69
69
|
throw new Error('Current wallet is not EmailWalletConnector');
|
|
@@ -78,7 +78,13 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
78
78
|
setView('login-with-email-or-wallet');
|
|
79
79
|
};
|
|
80
80
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation.useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
81
|
-
onFailure: (error) =>
|
|
81
|
+
onFailure: (error) => {
|
|
82
|
+
setError(error);
|
|
83
|
+
internalEvents.current.emit('emailVerificationResult', false, email);
|
|
84
|
+
},
|
|
85
|
+
onSuccess: () => {
|
|
86
|
+
internalEvents.current.emit('emailVerificationResult', true, email);
|
|
87
|
+
},
|
|
82
88
|
});
|
|
83
89
|
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, successBannerText: t('dyn_otp_verification.banner_text') }));
|
|
84
90
|
};
|
|
@@ -59,7 +59,7 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
59
59
|
const { setView } = useViewContext();
|
|
60
60
|
const [error, setError] = useState();
|
|
61
61
|
const { t } = useTranslation();
|
|
62
|
-
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, } = useInternalDynamicContext();
|
|
62
|
+
const { selectedWalletConnector: emailWalletConnector, clearStatesOnBackClick, internalEvents, } = useInternalDynamicContext();
|
|
63
63
|
if (!emailWalletConnector ||
|
|
64
64
|
!isEmailOTPWalletConnector(emailWalletConnector)) {
|
|
65
65
|
throw new Error('Current wallet is not EmailWalletConnector');
|
|
@@ -74,7 +74,13 @@ const EmailWalletOTPVerificationView = () => {
|
|
|
74
74
|
setView('login-with-email-or-wallet');
|
|
75
75
|
};
|
|
76
76
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation((otp) => emailWalletConnector.verifyOneTimePassword(otp), {
|
|
77
|
-
onFailure: (error) =>
|
|
77
|
+
onFailure: (error) => {
|
|
78
|
+
setError(error);
|
|
79
|
+
internalEvents.current.emit('emailVerificationResult', false, email);
|
|
80
|
+
},
|
|
81
|
+
onSuccess: () => {
|
|
82
|
+
internalEvents.current.emit('emailVerificationResult', true, email);
|
|
83
|
+
},
|
|
78
84
|
});
|
|
79
85
|
return (jsx(OTPVerificationView, { email: email, error: error, onClickBack: handleBackClick, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined), onClickEditEmail: handleBackClick, successBannerText: t('dyn_otp_verification.banner_text') }));
|
|
80
86
|
};
|
|
@@ -61,14 +61,17 @@ require('../../../../components/InlineWidget/InlineWidget.cjs');
|
|
|
61
61
|
require('../../../../components/MenuList/Dropdown/Dropdown.cjs');
|
|
62
62
|
|
|
63
63
|
const EmailOTPConnectorPendingSignModalContent = ({ walletConnector }) => {
|
|
64
|
-
const { setSelectedWalletWithAction, selectedWalletWithAction, setPrimaryWalletId, setMultiWalletWidgetState, computeConnectedStateForWallets, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
64
|
+
const { setSelectedWalletWithAction, selectedWalletWithAction, setPrimaryWalletId, setMultiWalletWidgetState, computeConnectedStateForWallets, internalEvents, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
65
65
|
const [error, setError] = React.useState();
|
|
66
66
|
const { email } = walletConnector;
|
|
67
67
|
if (!email) {
|
|
68
68
|
throw new Error('EmailOTPConnectorPendingSignModalContent requires a email');
|
|
69
69
|
}
|
|
70
70
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation.useMutation((otp) => walletConnector.verifyOneTimePassword(otp), {
|
|
71
|
-
onFailure: (error) =>
|
|
71
|
+
onFailure: (error) => {
|
|
72
|
+
setError(error);
|
|
73
|
+
internalEvents.current.emit('emailVerificationResult', false, email);
|
|
74
|
+
},
|
|
72
75
|
onSuccess: () => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
73
76
|
if (!selectedWalletWithAction) {
|
|
74
77
|
return;
|
|
@@ -77,6 +80,7 @@ const EmailOTPConnectorPendingSignModalContent = ({ walletConnector }) => {
|
|
|
77
80
|
setMultiWalletWidgetState('idle');
|
|
78
81
|
setSelectedWalletWithAction(null);
|
|
79
82
|
setPrimaryWalletId(selectedWalletWithAction.wallet.id);
|
|
83
|
+
internalEvents.current.emit('emailVerificationResult', true, email);
|
|
80
84
|
}),
|
|
81
85
|
});
|
|
82
86
|
return (jsxRuntime.jsx(OTPVerificationView.OTPVerificationView, { email: email, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined) }));
|
|
@@ -57,14 +57,17 @@ import '../../../../components/InlineWidget/InlineWidget.js';
|
|
|
57
57
|
import '../../../../components/MenuList/Dropdown/Dropdown.js';
|
|
58
58
|
|
|
59
59
|
const EmailOTPConnectorPendingSignModalContent = ({ walletConnector }) => {
|
|
60
|
-
const { setSelectedWalletWithAction, selectedWalletWithAction, setPrimaryWalletId, setMultiWalletWidgetState, computeConnectedStateForWallets, } = useInternalDynamicContext();
|
|
60
|
+
const { setSelectedWalletWithAction, selectedWalletWithAction, setPrimaryWalletId, setMultiWalletWidgetState, computeConnectedStateForWallets, internalEvents, } = useInternalDynamicContext();
|
|
61
61
|
const [error, setError] = useState();
|
|
62
62
|
const { email } = walletConnector;
|
|
63
63
|
if (!email) {
|
|
64
64
|
throw new Error('EmailOTPConnectorPendingSignModalContent requires a email');
|
|
65
65
|
}
|
|
66
66
|
const { data: isValid, isLoading, mutate: onSubmit, } = useMutation((otp) => walletConnector.verifyOneTimePassword(otp), {
|
|
67
|
-
onFailure: (error) =>
|
|
67
|
+
onFailure: (error) => {
|
|
68
|
+
setError(error);
|
|
69
|
+
internalEvents.current.emit('emailVerificationResult', false, email);
|
|
70
|
+
},
|
|
68
71
|
onSuccess: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
72
|
if (!selectedWalletWithAction) {
|
|
70
73
|
return;
|
|
@@ -73,6 +76,7 @@ const EmailOTPConnectorPendingSignModalContent = ({ walletConnector }) => {
|
|
|
73
76
|
setMultiWalletWidgetState('idle');
|
|
74
77
|
setSelectedWalletWithAction(null);
|
|
75
78
|
setPrimaryWalletId(selectedWalletWithAction.wallet.id);
|
|
79
|
+
internalEvents.current.emit('emailVerificationResult', true, email);
|
|
76
80
|
}),
|
|
77
81
|
});
|
|
78
82
|
return (jsx(OTPVerificationView, { email: email, error: error, isLoading: isLoading, onPinComplete: onSubmit, isValid: isValid === true, onPinChange: () => setError(undefined) }));
|