@dynamic-labs/sdk-react-core 4.24.0 → 4.25.0
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 +15 -0
- package/package.cjs +2 -2
- package/package.js +2 -2
- package/package.json +12 -12
- package/src/lib/client/extension/hooks/useSyncVerifyResponseWithStorage/index.d.ts +1 -0
- package/src/lib/client/extension/hooks/useSyncVerifyResponseWithStorage/useSyncVerifyResponseWithStorage.cjs +16 -0
- package/src/lib/client/extension/hooks/useSyncVerifyResponseWithStorage/useSyncVerifyResponseWithStorage.d.ts +1 -0
- package/src/lib/client/extension/hooks/useSyncVerifyResponseWithStorage/useSyncVerifyResponseWithStorage.js +12 -0
- package/src/lib/client/extension/index.d.ts +2 -0
- package/src/lib/client/extension/setVerifyResponseToStorage/index.d.ts +1 -0
- package/src/lib/client/extension/setVerifyResponseToStorage/setVerifyResponseToStorage.cjs +57 -0
- package/src/lib/client/extension/setVerifyResponseToStorage/setVerifyResponseToStorage.d.ts +2 -0
- package/src/lib/client/extension/setVerifyResponseToStorage/setVerifyResponseToStorage.js +53 -0
- package/src/lib/client/extension/storeTokenAndUser/storeTokenAndUser.cjs +10 -31
- package/src/lib/client/extension/storeTokenAndUser/storeTokenAndUser.d.ts +1 -1
- package/src/lib/client/extension/storeTokenAndUser/storeTokenAndUser.js +10 -31
- package/src/lib/context/DynamicContext/DynamicContext.cjs +2 -0
- package/src/lib/context/DynamicContext/DynamicContext.js +2 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs +4 -0
- package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js +4 -0
- package/src/lib/data/api/api.cjs +3 -3
- package/src/lib/data/api/api.js +3 -3
- package/src/lib/events/dynamicEvents.cjs +0 -6
- package/src/lib/events/dynamicEvents.d.ts +3 -1
- package/src/lib/events/dynamicEvents.js +0 -6
- package/src/lib/shared/types/dynamicEventsCallbacks.d.ts +2 -0
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.cjs +1 -1
- package/src/lib/utils/hooks/useIsLoggedIn/useIsLoggedIn.js +1 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.cjs +33 -9
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.d.ts +1 -1
- package/src/lib/utils/hooks/useSocialAuth/useSocialAuth.js +33 -9
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.cjs +5 -2
- package/src/lib/views/EmbeddedReveal/utils/waasExport/waasExport.js +5 -2
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.cjs +3 -22
- package/src/lib/views/LoginView/sections/SocialSignInSection/DynamicSocialSignIn/DynamicSocialSignIn.js +3 -22
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,19 @@
|
|
|
1
1
|
|
|
2
|
+
## [4.25.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.24.0...v4.25.0) (2025-07-17)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Features
|
|
6
|
+
|
|
7
|
+
* add passkey 1fa to react native ([#9167](https://github.com/dynamic-labs/dynamic-auth/issues/9167)) ([8f9b166](https://github.com/dynamic-labs/dynamic-auth/commit/8f9b166de3e0ab329c1539597c350681f1254bfb))
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
### Bug Fixes
|
|
11
|
+
|
|
12
|
+
* add waas iframe retry ([#9185](https://github.com/dynamic-labs/dynamic-auth/issues/9185)) ([ebe40d5](https://github.com/dynamic-labs/dynamic-auth/commit/ebe40d5ecdf214362b013502b4ac1313ba356aeb))
|
|
13
|
+
* ensure storage service defaults to local storage ([#9182](https://github.com/dynamic-labs/dynamic-auth/issues/9182)) ([d6ce48e](https://github.com/dynamic-labs/dynamic-auth/commit/d6ce48e8c1d2edb32d8db41efe3f56b97275c32a))
|
|
14
|
+
* add account address to wallet properties ([#9172](https://github.com/dynamic-labs/dynamic-auth/issues/9172)) ([61de8ca](https://github.com/dynamic-labs/dynamic-auth/commit/61de8caccb95c5d52126283ac7a1ebd5a36aa33c))
|
|
15
|
+
* show hcaptcha for headless social sign in ([#9154](https://github.com/dynamic-labs/dynamic-auth/issues/9154)) ([262b752](https://github.com/dynamic-labs/dynamic-auth/commit/262b75257ec6dcc05f67804b71f7285ec5919f91))
|
|
16
|
+
|
|
2
17
|
## [4.24.0](https://github.com/dynamic-labs/dynamic-auth/compare/v4.23.1...v4.24.0) (2025-07-15)
|
|
3
18
|
|
|
4
19
|
### Features
|
package/package.cjs
CHANGED
|
@@ -3,9 +3,9 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var version = "4.
|
|
6
|
+
var version = "4.25.0";
|
|
7
7
|
var dependencies = {
|
|
8
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
8
|
+
"@dynamic-labs/sdk-api-core": "0.0.718",
|
|
9
9
|
"@dynamic-labs-sdk/client": "0.0.1-alpha.16",
|
|
10
10
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
11
11
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
package/package.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
var version = "4.
|
|
2
|
+
var version = "4.25.0";
|
|
3
3
|
var dependencies = {
|
|
4
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
4
|
+
"@dynamic-labs/sdk-api-core": "0.0.718",
|
|
5
5
|
"@dynamic-labs-sdk/client": "0.0.1-alpha.16",
|
|
6
6
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
7
7
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@dynamic-labs/sdk-react-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.25.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@dynamic-labs/sdk-api-core": "0.0.
|
|
5
|
+
"@dynamic-labs/sdk-api-core": "0.0.718",
|
|
6
6
|
"@dynamic-labs-sdk/client": "0.0.1-alpha.16",
|
|
7
7
|
"@hcaptcha/react-hcaptcha": "1.4.4",
|
|
8
8
|
"@thumbmarkjs/thumbmarkjs": "0.16.0",
|
|
@@ -15,16 +15,16 @@
|
|
|
15
15
|
"yup": "0.32.11",
|
|
16
16
|
"react-international-phone": "4.5.0",
|
|
17
17
|
"bs58": "5.0.0",
|
|
18
|
-
"@dynamic-labs/assert-package-version": "4.
|
|
19
|
-
"@dynamic-labs/iconic": "4.
|
|
20
|
-
"@dynamic-labs/logger": "4.
|
|
21
|
-
"@dynamic-labs/multi-wallet": "4.
|
|
22
|
-
"@dynamic-labs/rpc-providers": "4.
|
|
23
|
-
"@dynamic-labs/store": "4.
|
|
24
|
-
"@dynamic-labs/types": "4.
|
|
25
|
-
"@dynamic-labs/utils": "4.
|
|
26
|
-
"@dynamic-labs/wallet-book": "4.
|
|
27
|
-
"@dynamic-labs/wallet-connector-core": "4.
|
|
18
|
+
"@dynamic-labs/assert-package-version": "4.25.0",
|
|
19
|
+
"@dynamic-labs/iconic": "4.25.0",
|
|
20
|
+
"@dynamic-labs/logger": "4.25.0",
|
|
21
|
+
"@dynamic-labs/multi-wallet": "4.25.0",
|
|
22
|
+
"@dynamic-labs/rpc-providers": "4.25.0",
|
|
23
|
+
"@dynamic-labs/store": "4.25.0",
|
|
24
|
+
"@dynamic-labs/types": "4.25.0",
|
|
25
|
+
"@dynamic-labs/utils": "4.25.0",
|
|
26
|
+
"@dynamic-labs/wallet-book": "4.25.0",
|
|
27
|
+
"@dynamic-labs/wallet-connector-core": "4.25.0",
|
|
28
28
|
"eventemitter3": "5.0.1"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { useSyncVerifyResponseWithStorage } from './useSyncVerifyResponseWithStorage';
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var React = require('react');
|
|
7
|
+
var client$1 = require('@dynamic-labs-sdk/client');
|
|
8
|
+
var client = require('../../../client.cjs');
|
|
9
|
+
var setVerifyResponseToStorage = require('../../setVerifyResponseToStorage/setVerifyResponseToStorage.cjs');
|
|
10
|
+
|
|
11
|
+
const useSyncVerifyResponseWithStorage = () => {
|
|
12
|
+
const client$2 = client.useDynamicClient();
|
|
13
|
+
React.useEffect(() => client$1.onEvent(client$2, 'authenticated', ({ verifyResponse }) => setVerifyResponseToStorage.setVerifyResponseToStorage(verifyResponse)), [client$2]);
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
exports.useSyncVerifyResponseWithStorage = useSyncVerifyResponseWithStorage;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const useSyncVerifyResponseWithStorage: () => void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { onEvent } from '@dynamic-labs-sdk/client';
|
|
4
|
+
import { useDynamicClient } from '../../../client.js';
|
|
5
|
+
import { setVerifyResponseToStorage } from '../../setVerifyResponseToStorage/setVerifyResponseToStorage.js';
|
|
6
|
+
|
|
7
|
+
const useSyncVerifyResponseWithStorage = () => {
|
|
8
|
+
const client = useDynamicClient();
|
|
9
|
+
useEffect(() => onEvent(client, 'authenticated', ({ verifyResponse }) => setVerifyResponseToStorage(verifyResponse)), [client]);
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export { useSyncVerifyResponseWithStorage };
|
|
@@ -3,6 +3,8 @@ export { useClientInitStatus } from './hooks/useClientInitStatus';
|
|
|
3
3
|
export { useInitializeSdkClient } from './hooks/useInitializeSdkClient';
|
|
4
4
|
export { getApiHeaders } from './hooks/useInitializeSdkClient/getApiHeaders';
|
|
5
5
|
export { useSyncProjectSettingsWithVanillaClient } from './hooks/useSyncProjectSettingsWithVanillaClient';
|
|
6
|
+
export { useSyncVerifyResponseWithStorage } from './hooks/useSyncVerifyResponseWithStorage';
|
|
7
|
+
export { setVerifyResponseToStorage } from './setVerifyResponseToStorage';
|
|
6
8
|
export { storeTokenAndUser } from './storeTokenAndUser';
|
|
7
9
|
export { convertSdkUserToUserProfile } from './user/convertSdkUserToUserProfile';
|
|
8
10
|
export { getUserProfile } from './user/getUserProfile';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { setVerifyResponseToStorage } from './setVerifyResponseToStorage';
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
var utils = require('@dynamic-labs/utils');
|
|
7
|
+
var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
8
|
+
require('@dynamic-labs/sdk-api-core');
|
|
9
|
+
var localStorage = require('../../../utils/constants/localStorage.cjs');
|
|
10
|
+
require('../../../utils/constants/colors.cjs');
|
|
11
|
+
var values = require('../../../utils/constants/values.cjs');
|
|
12
|
+
require('../../../../../_virtual/_tslib.cjs');
|
|
13
|
+
require('@dynamic-labs/multi-wallet');
|
|
14
|
+
require('../../../shared/logger.cjs');
|
|
15
|
+
require('react-international-phone');
|
|
16
|
+
require('@dynamic-labs/iconic');
|
|
17
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
18
|
+
require('react');
|
|
19
|
+
require('react/jsx-runtime');
|
|
20
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
21
|
+
require('@dynamic-labs/wallet-book');
|
|
22
|
+
require('../../../shared/consts/index.cjs');
|
|
23
|
+
require('../../../store/state/nonce/nonce.cjs');
|
|
24
|
+
var isCookieEnabled = require('../../../utils/functions/isCookieEnabled/isCookieEnabled.cjs');
|
|
25
|
+
require('@dynamic-labs-sdk/client/core');
|
|
26
|
+
require('@dynamic-labs-sdk/client');
|
|
27
|
+
require('../../client.cjs');
|
|
28
|
+
require('../../../events/dynamicEvents.cjs');
|
|
29
|
+
require('../../../config/ApiEndpoint.cjs');
|
|
30
|
+
require('../../../locale/locale.cjs');
|
|
31
|
+
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
32
|
+
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
33
|
+
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
34
|
+
|
|
35
|
+
const setVerifyResponseToStorage = ({ expiresAt, jwt, minifiedJwt, }) => {
|
|
36
|
+
// expiresAt is always sent back by the backend, regardless of whether jwt/minifiedJwt are sent or not
|
|
37
|
+
if (expiresAt !== undefined) {
|
|
38
|
+
utils.StorageService.setItem(localStorage.AUTH_EXPIRES_AT, expiresAt);
|
|
39
|
+
}
|
|
40
|
+
if (jwt && minifiedJwt) {
|
|
41
|
+
utils.StorageService.setItem(localStorage.AUTH_TOKEN, jwt, {
|
|
42
|
+
priority: ['secureStorage', 'localStorage'],
|
|
43
|
+
});
|
|
44
|
+
utils.StorageService.setItem(localStorage.AUTH_MIN_TOKEN, minifiedJwt, {
|
|
45
|
+
priority: ['secureStorage', 'localStorage'],
|
|
46
|
+
});
|
|
47
|
+
const projectSettings$1 = projectSettings.getProjectSettings();
|
|
48
|
+
if (projectSettings$1 && isCookieEnabled.isCookieEnabled(projectSettings$1)) {
|
|
49
|
+
// if cookie is enabled, but the backend returns a JWT, then use JS to store the cookie
|
|
50
|
+
const expireDate = new Date(expiresAt * 1000).toUTCString();
|
|
51
|
+
const authCookie = `${values.DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${expireDate}; path=/; SameSite=Lax`;
|
|
52
|
+
document.cookie = authCookie;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
exports.setVerifyResponseToStorage = setVerifyResponseToStorage;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import { StorageService } from '@dynamic-labs/utils';
|
|
3
|
+
import { getProjectSettings } from '../../../store/state/projectSettings/projectSettings.js';
|
|
4
|
+
import '@dynamic-labs/sdk-api-core';
|
|
5
|
+
import { AUTH_EXPIRES_AT, AUTH_TOKEN, AUTH_MIN_TOKEN } from '../../../utils/constants/localStorage.js';
|
|
6
|
+
import '../../../utils/constants/colors.js';
|
|
7
|
+
import { DYNAMIC_AUTH_COOKIE_NAME } from '../../../utils/constants/values.js';
|
|
8
|
+
import '../../../../../_virtual/_tslib.js';
|
|
9
|
+
import '@dynamic-labs/multi-wallet';
|
|
10
|
+
import '../../../shared/logger.js';
|
|
11
|
+
import 'react-international-phone';
|
|
12
|
+
import '@dynamic-labs/iconic';
|
|
13
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
14
|
+
import 'react';
|
|
15
|
+
import 'react/jsx-runtime';
|
|
16
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
17
|
+
import '@dynamic-labs/wallet-book';
|
|
18
|
+
import '../../../shared/consts/index.js';
|
|
19
|
+
import '../../../store/state/nonce/nonce.js';
|
|
20
|
+
import { isCookieEnabled } from '../../../utils/functions/isCookieEnabled/isCookieEnabled.js';
|
|
21
|
+
import '@dynamic-labs-sdk/client/core';
|
|
22
|
+
import '@dynamic-labs-sdk/client';
|
|
23
|
+
import '../../client.js';
|
|
24
|
+
import '../../../events/dynamicEvents.js';
|
|
25
|
+
import '../../../config/ApiEndpoint.js';
|
|
26
|
+
import '../../../locale/locale.js';
|
|
27
|
+
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
28
|
+
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
29
|
+
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
30
|
+
|
|
31
|
+
const setVerifyResponseToStorage = ({ expiresAt, jwt, minifiedJwt, }) => {
|
|
32
|
+
// expiresAt is always sent back by the backend, regardless of whether jwt/minifiedJwt are sent or not
|
|
33
|
+
if (expiresAt !== undefined) {
|
|
34
|
+
StorageService.setItem(AUTH_EXPIRES_AT, expiresAt);
|
|
35
|
+
}
|
|
36
|
+
if (jwt && minifiedJwt) {
|
|
37
|
+
StorageService.setItem(AUTH_TOKEN, jwt, {
|
|
38
|
+
priority: ['secureStorage', 'localStorage'],
|
|
39
|
+
});
|
|
40
|
+
StorageService.setItem(AUTH_MIN_TOKEN, minifiedJwt, {
|
|
41
|
+
priority: ['secureStorage', 'localStorage'],
|
|
42
|
+
});
|
|
43
|
+
const projectSettings = getProjectSettings();
|
|
44
|
+
if (projectSettings && isCookieEnabled(projectSettings)) {
|
|
45
|
+
// if cookie is enabled, but the backend returns a JWT, then use JS to store the cookie
|
|
46
|
+
const expireDate = new Date(expiresAt * 1000).toUTCString();
|
|
47
|
+
const authCookie = `${DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${expireDate}; path=/; SameSite=Lax`;
|
|
48
|
+
document.cookie = authCookie;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export { setVerifyResponseToStorage };
|
|
@@ -4,45 +4,24 @@
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
6
|
var core = require('@dynamic-labs-sdk/client/core');
|
|
7
|
-
var utils = require('@dynamic-labs/utils');
|
|
8
|
-
var projectSettings = require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
9
|
-
var localStorage = require('../../../utils/constants/localStorage.cjs');
|
|
10
|
-
var values = require('../../../utils/constants/values.cjs');
|
|
11
|
-
var isCookieEnabled = require('../../../utils/functions/isCookieEnabled/isCookieEnabled.cjs');
|
|
12
7
|
var client = require('../../client.cjs');
|
|
8
|
+
var setVerifyResponseToStorage = require('../setVerifyResponseToStorage/setVerifyResponseToStorage.cjs');
|
|
13
9
|
var convertSdkUserToUserProfile = require('../user/convertSdkUserToUserProfile/convertSdkUserToUserProfile.cjs');
|
|
14
10
|
var raiseUserProfileEvent = require('../user/raiseUserProfileEvent/raiseUserProfileEvent.cjs');
|
|
15
11
|
|
|
16
|
-
const storeTokenAndUser = (
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
utils.StorageService.setItem(localStorage.AUTH_EXPIRES_AT, expiresAt);
|
|
20
|
-
}
|
|
21
|
-
if (jwt && minifiedJwt) {
|
|
22
|
-
utils.StorageService.setItem(localStorage.AUTH_TOKEN, jwt, {
|
|
23
|
-
priority: ['secureStorage', 'localStorage'],
|
|
24
|
-
});
|
|
25
|
-
utils.StorageService.setItem(localStorage.AUTH_MIN_TOKEN, minifiedJwt, {
|
|
26
|
-
priority: ['secureStorage', 'localStorage'],
|
|
27
|
-
});
|
|
28
|
-
const projectSettings$1 = projectSettings.getProjectSettings();
|
|
29
|
-
if (projectSettings$1 && isCookieEnabled.isCookieEnabled(projectSettings$1)) {
|
|
30
|
-
// if cookie is enabled, but the backend returns a JWT, then use JS to store the cookie
|
|
31
|
-
const expireDate = new Date(expiresAt * 1000).toUTCString();
|
|
32
|
-
const authCookie = `${values.DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${expireDate}; path=/; SameSite=Lax`;
|
|
33
|
-
document.cookie = authCookie;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
12
|
+
const storeTokenAndUser = (verifyResponse) => {
|
|
13
|
+
var _a;
|
|
14
|
+
setVerifyResponseToStorage.setVerifyResponseToStorage(verifyResponse);
|
|
36
15
|
const { state } = core.getCore(client.getDynamicClient());
|
|
37
16
|
const oldUser = state.get().user;
|
|
38
17
|
state.set({
|
|
39
|
-
sessionExpiresAt: new Date(expiresAt * 1000),
|
|
40
|
-
token: minifiedJwt !== null &&
|
|
41
|
-
user: user,
|
|
18
|
+
sessionExpiresAt: new Date(verifyResponse.expiresAt * 1000),
|
|
19
|
+
token: (_a = verifyResponse.minifiedJwt) !== null && _a !== void 0 ? _a : null,
|
|
20
|
+
user: verifyResponse.user,
|
|
42
21
|
});
|
|
43
|
-
if (user && oldUser)
|
|
44
|
-
raiseUserProfileEvent.raiseUserProfileEvent({ newUser: user, oldUser });
|
|
45
|
-
return convertSdkUserToUserProfile.convertSdkUserToUserProfile(user);
|
|
22
|
+
if (verifyResponse.user && oldUser)
|
|
23
|
+
raiseUserProfileEvent.raiseUserProfileEvent({ newUser: verifyResponse.user, oldUser });
|
|
24
|
+
return convertSdkUserToUserProfile.convertSdkUserToUserProfile(verifyResponse.user);
|
|
46
25
|
};
|
|
47
26
|
|
|
48
27
|
exports.storeTokenAndUser = storeTokenAndUser;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
import { VerifyResponse } from '@dynamic-labs/sdk-api-core';
|
|
2
|
-
export declare const storeTokenAndUser: (
|
|
2
|
+
export declare const storeTokenAndUser: (verifyResponse: VerifyResponse) => import("dist/packages/types/src").UserProfile;
|
|
@@ -1,44 +1,23 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { getCore } from '@dynamic-labs-sdk/client/core';
|
|
3
|
-
import { StorageService } from '@dynamic-labs/utils';
|
|
4
|
-
import { getProjectSettings } from '../../../store/state/projectSettings/projectSettings.js';
|
|
5
|
-
import { AUTH_EXPIRES_AT, AUTH_TOKEN, AUTH_MIN_TOKEN } from '../../../utils/constants/localStorage.js';
|
|
6
|
-
import { DYNAMIC_AUTH_COOKIE_NAME } from '../../../utils/constants/values.js';
|
|
7
|
-
import { isCookieEnabled } from '../../../utils/functions/isCookieEnabled/isCookieEnabled.js';
|
|
8
3
|
import { getDynamicClient } from '../../client.js';
|
|
4
|
+
import { setVerifyResponseToStorage } from '../setVerifyResponseToStorage/setVerifyResponseToStorage.js';
|
|
9
5
|
import { convertSdkUserToUserProfile } from '../user/convertSdkUserToUserProfile/convertSdkUserToUserProfile.js';
|
|
10
6
|
import { raiseUserProfileEvent } from '../user/raiseUserProfileEvent/raiseUserProfileEvent.js';
|
|
11
7
|
|
|
12
|
-
const storeTokenAndUser = (
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
StorageService.setItem(AUTH_EXPIRES_AT, expiresAt);
|
|
16
|
-
}
|
|
17
|
-
if (jwt && minifiedJwt) {
|
|
18
|
-
StorageService.setItem(AUTH_TOKEN, jwt, {
|
|
19
|
-
priority: ['secureStorage', 'localStorage'],
|
|
20
|
-
});
|
|
21
|
-
StorageService.setItem(AUTH_MIN_TOKEN, minifiedJwt, {
|
|
22
|
-
priority: ['secureStorage', 'localStorage'],
|
|
23
|
-
});
|
|
24
|
-
const projectSettings = getProjectSettings();
|
|
25
|
-
if (projectSettings && isCookieEnabled(projectSettings)) {
|
|
26
|
-
// if cookie is enabled, but the backend returns a JWT, then use JS to store the cookie
|
|
27
|
-
const expireDate = new Date(expiresAt * 1000).toUTCString();
|
|
28
|
-
const authCookie = `${DYNAMIC_AUTH_COOKIE_NAME}=${minifiedJwt}; expires=${expireDate}; path=/; SameSite=Lax`;
|
|
29
|
-
document.cookie = authCookie;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
8
|
+
const storeTokenAndUser = (verifyResponse) => {
|
|
9
|
+
var _a;
|
|
10
|
+
setVerifyResponseToStorage(verifyResponse);
|
|
32
11
|
const { state } = getCore(getDynamicClient());
|
|
33
12
|
const oldUser = state.get().user;
|
|
34
13
|
state.set({
|
|
35
|
-
sessionExpiresAt: new Date(expiresAt * 1000),
|
|
36
|
-
token: minifiedJwt !== null &&
|
|
37
|
-
user: user,
|
|
14
|
+
sessionExpiresAt: new Date(verifyResponse.expiresAt * 1000),
|
|
15
|
+
token: (_a = verifyResponse.minifiedJwt) !== null && _a !== void 0 ? _a : null,
|
|
16
|
+
user: verifyResponse.user,
|
|
38
17
|
});
|
|
39
|
-
if (user && oldUser)
|
|
40
|
-
raiseUserProfileEvent({ newUser: user, oldUser });
|
|
41
|
-
return convertSdkUserToUserProfile(user);
|
|
18
|
+
if (verifyResponse.user && oldUser)
|
|
19
|
+
raiseUserProfileEvent({ newUser: verifyResponse.user, oldUser });
|
|
20
|
+
return convertSdkUserToUserProfile(verifyResponse.user);
|
|
42
21
|
};
|
|
43
22
|
|
|
44
23
|
export { storeTokenAndUser };
|
|
@@ -40,6 +40,7 @@ var primaryWalletId = require('../../store/state/primaryWalletId/primaryWalletId
|
|
|
40
40
|
var connectedWalletsInfo = require('../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
41
41
|
var getMissingChains = require('../../utils/functions/getMissingChains/getMissingChains.cjs');
|
|
42
42
|
var useSyncProjectSettingsWithVanillaClient = require('../../client/extension/hooks/useSyncProjectSettingsWithVanillaClient/useSyncProjectSettingsWithVanillaClient.cjs');
|
|
43
|
+
var useSyncVerifyResponseWithStorage = require('../../client/extension/hooks/useSyncVerifyResponseWithStorage/useSyncVerifyResponseWithStorage.cjs');
|
|
43
44
|
var dynamicEvents = require('../../events/dynamicEvents.cjs');
|
|
44
45
|
var useOnboardingCompleteUser = require('../../client/extension/user/useOnboardingCompleteUser/useOnboardingCompleteUser.cjs');
|
|
45
46
|
var useUser = require('../../client/extension/user/useUser/useUser.cjs');
|
|
@@ -238,6 +239,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
238
239
|
const projectSettings$1 = projectSettings.useProjectSettings();
|
|
239
240
|
// temporary sync project settings with vanilla SDK
|
|
240
241
|
useSyncProjectSettingsWithVanillaClient.useSyncProjectSettingsWithVanillaClient();
|
|
242
|
+
useSyncVerifyResponseWithStorage.useSyncVerifyResponseWithStorage();
|
|
241
243
|
const serverNetworkConfigurations = useNetworkConfigurationsFromProjectSettings.useNetworkConfigurationsFromProjectSettings({
|
|
242
244
|
cosmosNetworkOverrides: (_b = settings$1.overrides) === null || _b === void 0 ? void 0 : _b.cosmosNetworks,
|
|
243
245
|
evmNetworksOverrides: (_c = settings$1.overrides) === null || _c === void 0 ? void 0 : _c.evmNetworks,
|
|
@@ -36,6 +36,7 @@ import { usePrimaryWalletId } from '../../store/state/primaryWalletId/primaryWal
|
|
|
36
36
|
import { resetConnectedWalletsInfo } from '../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
37
37
|
import { getMissingChains } from '../../utils/functions/getMissingChains/getMissingChains.js';
|
|
38
38
|
import { useSyncProjectSettingsWithVanillaClient } from '../../client/extension/hooks/useSyncProjectSettingsWithVanillaClient/useSyncProjectSettingsWithVanillaClient.js';
|
|
39
|
+
import { useSyncVerifyResponseWithStorage } from '../../client/extension/hooks/useSyncVerifyResponseWithStorage/useSyncVerifyResponseWithStorage.js';
|
|
39
40
|
import { dynamicEvents } from '../../events/dynamicEvents.js';
|
|
40
41
|
import { useOnboardingCompleteUserProfile } from '../../client/extension/user/useOnboardingCompleteUser/useOnboardingCompleteUser.js';
|
|
41
42
|
import { useUserProfile } from '../../client/extension/user/useUser/useUser.js';
|
|
@@ -234,6 +235,7 @@ const InnerDynamicContextProvider = (props) => {
|
|
|
234
235
|
const projectSettings = useProjectSettings();
|
|
235
236
|
// temporary sync project settings with vanilla SDK
|
|
236
237
|
useSyncProjectSettingsWithVanillaClient();
|
|
238
|
+
useSyncVerifyResponseWithStorage();
|
|
237
239
|
const serverNetworkConfigurations = useNetworkConfigurationsFromProjectSettings({
|
|
238
240
|
cosmosNetworkOverrides: (_b = settings.overrides) === null || _b === void 0 ? void 0 : _b.cosmosNetworks,
|
|
239
241
|
evmNetworksOverrides: (_c = settings.overrides) === null || _c === void 0 ? void 0 : _c.evmNetworks,
|
package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.cjs
CHANGED
|
@@ -166,6 +166,10 @@ const useTieCallbacksToEvents = ({ clientCallbacks, user, }) => {
|
|
|
166
166
|
var _a;
|
|
167
167
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletTabSelected) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, props);
|
|
168
168
|
});
|
|
169
|
+
useDynamicEvents.useInternalDynamicEvents('walletConnectionFailed', (walletConnector, error) => {
|
|
170
|
+
var _a;
|
|
171
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletConnectionFailed) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, walletConnector, error);
|
|
172
|
+
});
|
|
169
173
|
};
|
|
170
174
|
|
|
171
175
|
exports.useTieCallbacksToEvents = useTieCallbacksToEvents;
|
package/src/lib/context/DynamicContext/hooks/useTieCallbacksToEvents/useTieCallbacksToEvents.js
CHANGED
|
@@ -162,6 +162,10 @@ const useTieCallbacksToEvents = ({ clientCallbacks, user, }) => {
|
|
|
162
162
|
var _a;
|
|
163
163
|
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletTabSelected) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, props);
|
|
164
164
|
});
|
|
165
|
+
useInternalDynamicEvents('walletConnectionFailed', (walletConnector, error) => {
|
|
166
|
+
var _a;
|
|
167
|
+
(_a = clientCallbacks === null || clientCallbacks === void 0 ? void 0 : clientCallbacks.onWalletConnectionFailed) === null || _a === void 0 ? void 0 : _a.call(clientCallbacks, walletConnector, error);
|
|
168
|
+
});
|
|
165
169
|
};
|
|
166
170
|
|
|
167
171
|
export { useTieCallbacksToEvents };
|
package/src/lib/data/api/api.cjs
CHANGED
|
@@ -13,12 +13,10 @@ require('../../../../_virtual/_tslib.cjs');
|
|
|
13
13
|
var getApiHeaders = require('../../client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.cjs');
|
|
14
14
|
require('../../events/dynamicEvents.cjs');
|
|
15
15
|
var projectSettings = require('../../store/state/projectSettings/projectSettings.cjs');
|
|
16
|
+
require('../../utils/constants/colors.cjs');
|
|
16
17
|
require('../../utils/constants/values.cjs');
|
|
17
|
-
var isCookieEnabled = require('../../utils/functions/isCookieEnabled/isCookieEnabled.cjs');
|
|
18
|
-
var ApiEndpoint = require('../../config/ApiEndpoint.cjs');
|
|
19
18
|
require('@dynamic-labs/multi-wallet');
|
|
20
19
|
require('../../shared/logger.cjs');
|
|
21
|
-
require('../../utils/constants/colors.cjs');
|
|
22
20
|
var getMinAuthToken = require('../../utils/functions/getMinAuthToken/getMinAuthToken.cjs');
|
|
23
21
|
require('react-international-phone');
|
|
24
22
|
require('@dynamic-labs/iconic');
|
|
@@ -29,6 +27,8 @@ require('@dynamic-labs/wallet-book');
|
|
|
29
27
|
require('../../shared/consts/index.cjs');
|
|
30
28
|
require('../../store/state/nonce/nonce.cjs');
|
|
31
29
|
var randomString = require('../../utils/functions/randomString/randomString.cjs');
|
|
30
|
+
var isCookieEnabled = require('../../utils/functions/isCookieEnabled/isCookieEnabled.cjs');
|
|
31
|
+
var ApiEndpoint = require('../../config/ApiEndpoint.cjs');
|
|
32
32
|
require('../../locale/locale.cjs');
|
|
33
33
|
require('../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
34
34
|
require('../../store/state/primaryWalletId/primaryWalletId.cjs');
|
package/src/lib/data/api/api.js
CHANGED
|
@@ -9,12 +9,10 @@ import '../../../../_virtual/_tslib.js';
|
|
|
9
9
|
import { getApiHeaders } from '../../client/extension/hooks/useInitializeSdkClient/getApiHeaders/getApiHeaders.js';
|
|
10
10
|
import '../../events/dynamicEvents.js';
|
|
11
11
|
import { getProjectSettings } from '../../store/state/projectSettings/projectSettings.js';
|
|
12
|
+
import '../../utils/constants/colors.js';
|
|
12
13
|
import '../../utils/constants/values.js';
|
|
13
|
-
import { isCookieEnabled } from '../../utils/functions/isCookieEnabled/isCookieEnabled.js';
|
|
14
|
-
import ApiEndpoint from '../../config/ApiEndpoint.js';
|
|
15
14
|
import '@dynamic-labs/multi-wallet';
|
|
16
15
|
import '../../shared/logger.js';
|
|
17
|
-
import '../../utils/constants/colors.js';
|
|
18
16
|
import { getMinAuthToken } from '../../utils/functions/getMinAuthToken/getMinAuthToken.js';
|
|
19
17
|
import 'react-international-phone';
|
|
20
18
|
import '@dynamic-labs/iconic';
|
|
@@ -25,6 +23,8 @@ import '@dynamic-labs/wallet-book';
|
|
|
25
23
|
import '../../shared/consts/index.js';
|
|
26
24
|
import '../../store/state/nonce/nonce.js';
|
|
27
25
|
import { randomString } from '../../utils/functions/randomString/randomString.js';
|
|
26
|
+
import { isCookieEnabled } from '../../utils/functions/isCookieEnabled/isCookieEnabled.js';
|
|
27
|
+
import ApiEndpoint from '../../config/ApiEndpoint.js';
|
|
28
28
|
import '../../locale/locale.js';
|
|
29
29
|
import '../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
30
30
|
import '../../store/state/primaryWalletId/primaryWalletId.js';
|
|
@@ -9,12 +9,6 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
|
|
|
9
9
|
|
|
10
10
|
var EventEmitter__default = /*#__PURE__*/_interopDefaultLegacy(EventEmitter);
|
|
11
11
|
|
|
12
|
-
// ATTENTION
|
|
13
|
-
// Everything below should be made public soon, but we need to plan this out first
|
|
14
|
-
// Main issues:
|
|
15
|
-
// 1. How should we map customer callback names to our dynamic event names?
|
|
16
|
-
// -> Gui's suggestion: breaking change to rename customer callbacks so they fit these events names
|
|
17
|
-
// 2. We would have to remove these callbacks from the useCustomerCallbacks hook
|
|
18
12
|
/** Which events are accessible by our clients */
|
|
19
13
|
const externalEvents = [
|
|
20
14
|
'authFailure',
|
|
@@ -12,8 +12,10 @@ import { UserEvents } from './user';
|
|
|
12
12
|
import { WalletEvents } from './wallets';
|
|
13
13
|
/** Maps internal event names to their listeners */
|
|
14
14
|
export type DynamicEvents = AuthEvents & UIEvents & OTPEvents & WalletEvents & PasskeyEvents & SocialEvents & EmbeddedWalletEvents & MultiWalletInternalEvents & TokenBalancesEvents & UserEvents & FundingEvents;
|
|
15
|
+
type PublicDynamicEvents = Pick<DynamicEvents, typeof externalEvents[number]>;
|
|
15
16
|
/** Which events are accessible by our clients */
|
|
16
17
|
export declare const externalEvents: ("authFailure" | "authInit" | "logout" | "mfaCompletionSuccess" | "mfaCompletionFailure" | "authFlowOpen" | "authFlowClose" | "authFlowCancelled" | "walletTabSelected" | "emailVerificationResult" | "smsVerificationResult" | "walletAdded" | "walletRemoved" | "primaryWalletChanged" | "primaryWalletNetworkChanged" | "userWalletsChanged" | "walletConnectionFailed" | "embeddedWalletCreated" | "walletConnectedForFunding")[];
|
|
17
18
|
export declare const dynamicEvents: EventEmitter<DynamicEvents, any>;
|
|
18
|
-
export declare const publicDynamicEvents: EventEmitter<
|
|
19
|
+
export declare const publicDynamicEvents: EventEmitter<PublicDynamicEvents, any>;
|
|
19
20
|
export type DynamicEventEmitter = typeof dynamicEvents;
|
|
21
|
+
export {};
|
|
@@ -1,12 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import EventEmitter from 'eventemitter3';
|
|
3
3
|
|
|
4
|
-
// ATTENTION
|
|
5
|
-
// Everything below should be made public soon, but we need to plan this out first
|
|
6
|
-
// Main issues:
|
|
7
|
-
// 1. How should we map customer callback names to our dynamic event names?
|
|
8
|
-
// -> Gui's suggestion: breaking change to rename customer callbacks so they fit these events names
|
|
9
|
-
// 2. We would have to remove these callbacks from the useCustomerCallbacks hook
|
|
10
4
|
/** Which events are accessible by our clients */
|
|
11
5
|
const externalEvents = [
|
|
12
6
|
'authFailure',
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { JwtVerifiedCredential } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { AuthEventPayload, OtpDestination, PhoneData, UserProfile } from '@dynamic-labs/types';
|
|
3
|
+
import { WalletConnector } from '@dynamic-labs/wallet-connector-core';
|
|
3
4
|
import { Wallet, WalletListViewTabItem } from './wallets';
|
|
4
5
|
export type DynamicEventsCallbacks = {
|
|
5
6
|
onSignedMessage?: (params: {
|
|
@@ -18,6 +19,7 @@ export type DynamicEventsCallbacks = {
|
|
|
18
19
|
onEmbeddedWalletCreated?: OnEmbeddedWalletCreated;
|
|
19
20
|
onWalletAdded?: OnWalletAdded;
|
|
20
21
|
onWalletRemoved?: OnWalletRemoved;
|
|
22
|
+
onWalletConnectionFailed?: (walletConnector: WalletConnector, error: unknown) => void;
|
|
21
23
|
/**
|
|
22
24
|
* Informs an auth attempt failed.
|
|
23
25
|
* In general triggered when an error occurs or when user cancels out.
|
|
@@ -29,12 +29,12 @@ require('@dynamic-labs-sdk/client/core');
|
|
|
29
29
|
require('@dynamic-labs-sdk/client');
|
|
30
30
|
require('../../../client/client.cjs');
|
|
31
31
|
require('../../../store/state/projectSettings/projectSettings.cjs');
|
|
32
|
+
var usingV3Wallets = require('../../functions/usingV3Wallets/usingV3Wallets.cjs');
|
|
32
33
|
require('../../../config/ApiEndpoint.cjs');
|
|
33
34
|
require('../../../locale/locale.cjs');
|
|
34
35
|
require('../../../store/state/dynamicContextProps/dynamicContextProps.cjs');
|
|
35
36
|
require('../../../store/state/primaryWalletId/primaryWalletId.cjs');
|
|
36
37
|
require('../../../store/state/connectedWalletsInfo/connectedWalletsInfo.cjs');
|
|
37
|
-
var usingV3Wallets = require('../../functions/usingV3Wallets/usingV3Wallets.cjs');
|
|
38
38
|
require('../../../context/AccessDeniedContext/AccessDeniedContext.cjs');
|
|
39
39
|
require('../../../context/AccountExistsContext/AccountExistsContext.cjs');
|
|
40
40
|
require('../../../context/UserWalletsContext/UserWalletsContext.cjs');
|
|
@@ -25,12 +25,12 @@ import '@dynamic-labs-sdk/client/core';
|
|
|
25
25
|
import '@dynamic-labs-sdk/client';
|
|
26
26
|
import '../../../client/client.js';
|
|
27
27
|
import '../../../store/state/projectSettings/projectSettings.js';
|
|
28
|
+
import { usingV3Wallets } from '../../functions/usingV3Wallets/usingV3Wallets.js';
|
|
28
29
|
import '../../../config/ApiEndpoint.js';
|
|
29
30
|
import '../../../locale/locale.js';
|
|
30
31
|
import '../../../store/state/dynamicContextProps/dynamicContextProps.js';
|
|
31
32
|
import '../../../store/state/primaryWalletId/primaryWalletId.js';
|
|
32
33
|
import '../../../store/state/connectedWalletsInfo/connectedWalletsInfo.js';
|
|
33
|
-
import { usingV3Wallets } from '../../functions/usingV3Wallets/usingV3Wallets.js';
|
|
34
34
|
import '../../../context/AccessDeniedContext/AccessDeniedContext.js';
|
|
35
35
|
import '../../../context/AccountExistsContext/AccountExistsContext.js';
|
|
36
36
|
import '../../../context/UserWalletsContext/UserWalletsContext.js';
|
|
@@ -8,6 +8,7 @@ var React = require('react');
|
|
|
8
8
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
9
9
|
var types = require('@dynamic-labs/types');
|
|
10
10
|
var utils = require('@dynamic-labs/utils');
|
|
11
|
+
var CaptchaContext = require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
11
12
|
require('../../../context/DynamicContext/DynamicContext.cjs');
|
|
12
13
|
require('../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
13
14
|
var logger = require('../../../shared/logger.cjs');
|
|
@@ -20,7 +21,6 @@ require('../../constants/colors.cjs');
|
|
|
20
21
|
require('../../constants/values.cjs');
|
|
21
22
|
require('../../../shared/consts/index.cjs');
|
|
22
23
|
var dynamicEvents = require('../../../events/dynamicEvents.cjs');
|
|
23
|
-
require('../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
24
24
|
var ErrorContext = require('../../../context/ErrorContext/ErrorContext.cjs');
|
|
25
25
|
var digestSHA256 = require('../../functions/digestSHA256/digestSHA256.cjs');
|
|
26
26
|
var encodeBase64URL = require('../../functions/encodeBase64URL/encodeBase64URL.cjs');
|
|
@@ -133,6 +133,7 @@ const socialProviders = [
|
|
|
133
133
|
const providersRequiringPkce = ['twitter', 'github'];
|
|
134
134
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
135
135
|
const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
136
|
+
var _a;
|
|
136
137
|
const { environmentId, setShowAuthFlow, socialSettings, projectSettings, redirectUrl: defaultRedirectUrl, } = useInternalDynamicContext.useInternalDynamicContext();
|
|
137
138
|
/**
|
|
138
139
|
* Represents if the SDK will use a popup or redirect for social auth
|
|
@@ -148,6 +149,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
148
149
|
});
|
|
149
150
|
const [isProcessing, setIsProcessing] = React.useState(false);
|
|
150
151
|
const [error, setError] = React.useState();
|
|
152
|
+
const { engageCaptcha } = CaptchaContext.useCaptchaContext();
|
|
151
153
|
const clearError = React.useCallback(() => {
|
|
152
154
|
setError(undefined);
|
|
153
155
|
setContextError(undefined);
|
|
@@ -204,7 +206,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
204
206
|
verifyFunction: () => apiCall(),
|
|
205
207
|
});
|
|
206
208
|
}), [handleError, initAuth, onSettled]);
|
|
207
|
-
const completeConnection = React.useCallback((
|
|
209
|
+
const completeConnection = React.useCallback((_b) => _tslib.__awaiter(void 0, [_b], void 0, function* ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser = false, }) {
|
|
208
210
|
try {
|
|
209
211
|
let sessionPublicKey = undefined;
|
|
210
212
|
utils.tracing.logEvent('oauth', 'completeConnection', utils.tracing.formatObject({
|
|
@@ -277,7 +279,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
277
279
|
shouldRegisterSessionKeysOnSignin,
|
|
278
280
|
signInAccount,
|
|
279
281
|
]);
|
|
280
|
-
const connectWithFarcaster = React.useCallback((authMode_1,
|
|
282
|
+
const connectWithFarcaster = React.useCallback((authMode_1, _c) => _tslib.__awaiter(void 0, [authMode_1, _c], void 0, function* (authMode, { captchaToken, redirectUrl }) {
|
|
281
283
|
let dynamicNonce;
|
|
282
284
|
try {
|
|
283
285
|
dynamicNonce = nonce.consumeNonce();
|
|
@@ -368,8 +370,8 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
368
370
|
shouldRegisterSessionKeysOnSignin,
|
|
369
371
|
signInAccount,
|
|
370
372
|
]);
|
|
371
|
-
const connectSocialAccount = React.useCallback((
|
|
372
|
-
var
|
|
373
|
+
const connectSocialAccount = React.useCallback((_d) => _tslib.__awaiter(void 0, [_d], void 0, function* ({ authMode, provider, validator, captchaToken, triggerFundFromExchangeOnSuccess, redirectUrl, telegramAuthToken, showWidgetAfterConnection, }) {
|
|
374
|
+
var _e, _f;
|
|
373
375
|
clearError();
|
|
374
376
|
setIsProcessing(true);
|
|
375
377
|
if (!authMode) {
|
|
@@ -406,7 +408,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
406
408
|
state,
|
|
407
409
|
triggerFundFromExchangeOnSuccess,
|
|
408
410
|
});
|
|
409
|
-
const loginUrlString = getOauthLoginUrl.getOauthLoginUrl((
|
|
411
|
+
const loginUrlString = getOauthLoginUrl.getOauthLoginUrl((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _e !== void 0 ? _e : [], provider);
|
|
410
412
|
if (!loginUrlString) {
|
|
411
413
|
handleError(provider, types.SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to connect social account: ${provider}`, { raiseAuthFailure: authMode === 'signin' });
|
|
412
414
|
return;
|
|
@@ -422,7 +424,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
422
424
|
const isMobile = utils.isMobile();
|
|
423
425
|
try {
|
|
424
426
|
const authCode = yield utils.Oauth2Service.getOauthCode({
|
|
425
|
-
apiProvider: getProviderByType.getProviderByType((
|
|
427
|
+
apiProvider: getProviderByType.getProviderByType((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _f !== void 0 ? _f : [], provider),
|
|
426
428
|
getOAuthResultFromApi: () => oauth.getOAuthResult(environmentId, provider, {
|
|
427
429
|
state,
|
|
428
430
|
}),
|
|
@@ -476,10 +478,32 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
476
478
|
projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers,
|
|
477
479
|
strategy,
|
|
478
480
|
]);
|
|
481
|
+
const checkCaptchaAndConnect = React.useCallback((props) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
482
|
+
var _g;
|
|
483
|
+
if (!((_g = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.hCaptcha) === null || _g === void 0 ? void 0 : _g.enabled)) {
|
|
484
|
+
connectSocialAccount(props);
|
|
485
|
+
return;
|
|
486
|
+
}
|
|
487
|
+
// Make sure the auth flow is visible
|
|
488
|
+
// it would still be hidden in headless scenarios
|
|
489
|
+
setShowAuthFlow(true, {
|
|
490
|
+
initializeWalletConnect: false,
|
|
491
|
+
performMultiWalletChecks: false,
|
|
492
|
+
});
|
|
493
|
+
engageCaptcha({
|
|
494
|
+
authMethod: 'social',
|
|
495
|
+
onCaptchaSuccess: (captchaToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () { return connectSocialAccount(Object.assign(Object.assign({}, props), { captchaToken })); }),
|
|
496
|
+
});
|
|
497
|
+
}), [
|
|
498
|
+
setShowAuthFlow,
|
|
499
|
+
connectSocialAccount,
|
|
500
|
+
engageCaptcha,
|
|
501
|
+
(_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.hCaptcha) === null || _a === void 0 ? void 0 : _a.enabled,
|
|
502
|
+
]);
|
|
479
503
|
return React.useMemo(() => ({
|
|
480
504
|
checkValidProvider,
|
|
481
505
|
completeConnection,
|
|
482
|
-
connectSocialAccount,
|
|
506
|
+
connectSocialAccount: checkCaptchaAndConnect,
|
|
483
507
|
error,
|
|
484
508
|
handleError,
|
|
485
509
|
isProcessing,
|
|
@@ -488,7 +512,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
488
512
|
}), [
|
|
489
513
|
checkValidProvider,
|
|
490
514
|
completeConnection,
|
|
491
|
-
|
|
515
|
+
checkCaptchaAndConnect,
|
|
492
516
|
error,
|
|
493
517
|
handleError,
|
|
494
518
|
isProcessing,
|
|
@@ -29,7 +29,7 @@ export declare const useSocialAuth: ({ onSettled, onError, onFarcasterUrl, }: Us
|
|
|
29
29
|
telegramAuthToken?: string | undefined;
|
|
30
30
|
forceCreateUser?: boolean | undefined;
|
|
31
31
|
}) => Promise<void>;
|
|
32
|
-
readonly connectSocialAccount: (
|
|
32
|
+
readonly connectSocialAccount: (props: ConnectSocialAccountProps) => Promise<void>;
|
|
33
33
|
readonly error: SocialOAuthError | undefined;
|
|
34
34
|
readonly handleError: (provider: ProviderEnum | undefined, code: SocialOAuthErrorCode, message: string, options?: {
|
|
35
35
|
raiseAuthFailure?: boolean | undefined;
|
|
@@ -4,6 +4,7 @@ import { useMemo, useState, useCallback } from 'react';
|
|
|
4
4
|
import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
5
|
import { SocialOAuthErrorCode } from '@dynamic-labs/types';
|
|
6
6
|
import { SocialAccountAlreadyExistsError, tracing, PlatformService, isMobile, Oauth2Service } from '@dynamic-labs/utils';
|
|
7
|
+
import { useCaptchaContext } from '../../../context/CaptchaContext/CaptchaContext.js';
|
|
7
8
|
import '../../../context/DynamicContext/DynamicContext.js';
|
|
8
9
|
import '../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
9
10
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -16,7 +17,6 @@ import '../../constants/colors.js';
|
|
|
16
17
|
import '../../constants/values.js';
|
|
17
18
|
import '../../../shared/consts/index.js';
|
|
18
19
|
import { dynamicEvents } from '../../../events/dynamicEvents.js';
|
|
19
|
-
import '../../../context/CaptchaContext/CaptchaContext.js';
|
|
20
20
|
import { useErrorContext } from '../../../context/ErrorContext/ErrorContext.js';
|
|
21
21
|
import { digestSHA256 } from '../../functions/digestSHA256/digestSHA256.js';
|
|
22
22
|
import { encodeBase64URL } from '../../functions/encodeBase64URL/encodeBase64URL.js';
|
|
@@ -129,6 +129,7 @@ const socialProviders = [
|
|
|
129
129
|
const providersRequiringPkce = ['twitter', 'github'];
|
|
130
130
|
// Hook to handle common social auth logic (for social linking and social sign in)
|
|
131
131
|
const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
132
|
+
var _a;
|
|
132
133
|
const { environmentId, setShowAuthFlow, socialSettings, projectSettings, redirectUrl: defaultRedirectUrl, } = useInternalDynamicContext();
|
|
133
134
|
/**
|
|
134
135
|
* Represents if the SDK will use a popup or redirect for social auth
|
|
@@ -144,6 +145,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
144
145
|
});
|
|
145
146
|
const [isProcessing, setIsProcessing] = useState(false);
|
|
146
147
|
const [error, setError] = useState();
|
|
148
|
+
const { engageCaptcha } = useCaptchaContext();
|
|
147
149
|
const clearError = useCallback(() => {
|
|
148
150
|
setError(undefined);
|
|
149
151
|
setContextError(undefined);
|
|
@@ -200,7 +202,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
200
202
|
verifyFunction: () => apiCall(),
|
|
201
203
|
});
|
|
202
204
|
}), [handleError, initAuth$1, onSettled]);
|
|
203
|
-
const completeConnection = useCallback((
|
|
205
|
+
const completeConnection = useCallback((_b) => __awaiter(void 0, [_b], void 0, function* ({ authMode, provider, state, authCode, captchaToken, verifier, telegramAuthToken, forceCreateUser = false, }) {
|
|
204
206
|
try {
|
|
205
207
|
let sessionPublicKey = undefined;
|
|
206
208
|
tracing.logEvent('oauth', 'completeConnection', tracing.formatObject({
|
|
@@ -273,7 +275,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
273
275
|
shouldRegisterSessionKeysOnSignin,
|
|
274
276
|
signInAccount,
|
|
275
277
|
]);
|
|
276
|
-
const connectWithFarcaster = useCallback((authMode_1,
|
|
278
|
+
const connectWithFarcaster = useCallback((authMode_1, _c) => __awaiter(void 0, [authMode_1, _c], void 0, function* (authMode, { captchaToken, redirectUrl }) {
|
|
277
279
|
let dynamicNonce;
|
|
278
280
|
try {
|
|
279
281
|
dynamicNonce = consumeNonce();
|
|
@@ -364,8 +366,8 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
364
366
|
shouldRegisterSessionKeysOnSignin,
|
|
365
367
|
signInAccount,
|
|
366
368
|
]);
|
|
367
|
-
const connectSocialAccount = useCallback((
|
|
368
|
-
var
|
|
369
|
+
const connectSocialAccount = useCallback((_d) => __awaiter(void 0, [_d], void 0, function* ({ authMode, provider, validator, captchaToken, triggerFundFromExchangeOnSuccess, redirectUrl, telegramAuthToken, showWidgetAfterConnection, }) {
|
|
370
|
+
var _e, _f;
|
|
369
371
|
clearError();
|
|
370
372
|
setIsProcessing(true);
|
|
371
373
|
if (!authMode) {
|
|
@@ -402,7 +404,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
402
404
|
state,
|
|
403
405
|
triggerFundFromExchangeOnSuccess,
|
|
404
406
|
});
|
|
405
|
-
const loginUrlString = getOauthLoginUrl((
|
|
407
|
+
const loginUrlString = getOauthLoginUrl((_e = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _e !== void 0 ? _e : [], provider);
|
|
406
408
|
if (!loginUrlString) {
|
|
407
409
|
handleError(provider, SocialOAuthErrorCode.NO_OAUTH_URL, `Failed to get login url to connect social account: ${provider}`, { raiseAuthFailure: authMode === 'signin' });
|
|
408
410
|
return;
|
|
@@ -418,7 +420,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
418
420
|
const isMobile$1 = isMobile();
|
|
419
421
|
try {
|
|
420
422
|
const authCode = yield Oauth2Service.getOauthCode({
|
|
421
|
-
apiProvider: getProviderByType((
|
|
423
|
+
apiProvider: getProviderByType((_f = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers) !== null && _f !== void 0 ? _f : [], provider),
|
|
422
424
|
getOAuthResultFromApi: () => getOAuthResult(environmentId, provider, {
|
|
423
425
|
state,
|
|
424
426
|
}),
|
|
@@ -472,10 +474,32 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
472
474
|
projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.providers,
|
|
473
475
|
strategy,
|
|
474
476
|
]);
|
|
477
|
+
const checkCaptchaAndConnect = useCallback((props) => __awaiter(void 0, void 0, void 0, function* () {
|
|
478
|
+
var _g;
|
|
479
|
+
if (!((_g = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.hCaptcha) === null || _g === void 0 ? void 0 : _g.enabled)) {
|
|
480
|
+
connectSocialAccount(props);
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
// Make sure the auth flow is visible
|
|
484
|
+
// it would still be hidden in headless scenarios
|
|
485
|
+
setShowAuthFlow(true, {
|
|
486
|
+
initializeWalletConnect: false,
|
|
487
|
+
performMultiWalletChecks: false,
|
|
488
|
+
});
|
|
489
|
+
engageCaptcha({
|
|
490
|
+
authMethod: 'social',
|
|
491
|
+
onCaptchaSuccess: (captchaToken) => __awaiter(void 0, void 0, void 0, function* () { return connectSocialAccount(Object.assign(Object.assign({}, props), { captchaToken })); }),
|
|
492
|
+
});
|
|
493
|
+
}), [
|
|
494
|
+
setShowAuthFlow,
|
|
495
|
+
connectSocialAccount,
|
|
496
|
+
engageCaptcha,
|
|
497
|
+
(_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.hCaptcha) === null || _a === void 0 ? void 0 : _a.enabled,
|
|
498
|
+
]);
|
|
475
499
|
return useMemo(() => ({
|
|
476
500
|
checkValidProvider,
|
|
477
501
|
completeConnection,
|
|
478
|
-
connectSocialAccount,
|
|
502
|
+
connectSocialAccount: checkCaptchaAndConnect,
|
|
479
503
|
error,
|
|
480
504
|
handleError,
|
|
481
505
|
isProcessing,
|
|
@@ -484,7 +508,7 @@ const useSocialAuth = ({ onSettled, onError, onFarcasterUrl, }) => {
|
|
|
484
508
|
}), [
|
|
485
509
|
checkValidProvider,
|
|
486
510
|
completeConnection,
|
|
487
|
-
|
|
511
|
+
checkCaptchaAndConnect,
|
|
488
512
|
error,
|
|
489
513
|
handleError,
|
|
490
514
|
isProcessing,
|
|
@@ -23,7 +23,10 @@ const handleExportInitCheck = ({ user, wallet, }) => {
|
|
|
23
23
|
throw new utils.InvalidPrimaryWalletOrConnectorError();
|
|
24
24
|
}
|
|
25
25
|
const connector = wallet.connector;
|
|
26
|
-
|
|
26
|
+
let walletProperties = (_c = (_b = user.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('dynamicwaas'))) === null || _c === void 0 ? void 0 : _c.walletProperties;
|
|
27
|
+
if (walletProperties) {
|
|
28
|
+
walletProperties = Object.assign(Object.assign({}, walletProperties), { accountAddress: wallet.address });
|
|
29
|
+
}
|
|
27
30
|
if (!walletProperties) {
|
|
28
31
|
throw new utils.DynamicError('Invalid token!');
|
|
29
32
|
}
|
|
@@ -38,7 +41,7 @@ const exportWaasCredential = (_a) => _tslib.__awaiter(void 0, [_a], void 0, func
|
|
|
38
41
|
wallet,
|
|
39
42
|
});
|
|
40
43
|
yield connector.exportPrivateKey({
|
|
41
|
-
accountAddress: address ||
|
|
44
|
+
accountAddress: address || walletProperties.accountAddress,
|
|
42
45
|
displayContainer: iframeContainer,
|
|
43
46
|
});
|
|
44
47
|
return true;
|
|
@@ -19,7 +19,10 @@ const handleExportInitCheck = ({ user, wallet, }) => {
|
|
|
19
19
|
throw new InvalidPrimaryWalletOrConnectorError();
|
|
20
20
|
}
|
|
21
21
|
const connector = wallet.connector;
|
|
22
|
-
|
|
22
|
+
let walletProperties = (_c = (_b = user.verifiedCredentials) === null || _b === void 0 ? void 0 : _b.find(({ walletName }) => walletName === null || walletName === void 0 ? void 0 : walletName.startsWith('dynamicwaas'))) === null || _c === void 0 ? void 0 : _c.walletProperties;
|
|
23
|
+
if (walletProperties) {
|
|
24
|
+
walletProperties = Object.assign(Object.assign({}, walletProperties), { accountAddress: wallet.address });
|
|
25
|
+
}
|
|
23
26
|
if (!walletProperties) {
|
|
24
27
|
throw new DynamicError('Invalid token!');
|
|
25
28
|
}
|
|
@@ -34,7 +37,7 @@ const exportWaasCredential = (_a) => __awaiter(void 0, [_a], void 0, function* (
|
|
|
34
37
|
wallet,
|
|
35
38
|
});
|
|
36
39
|
yield connector.exportPrivateKey({
|
|
37
|
-
accountAddress: address ||
|
|
40
|
+
accountAddress: address || walletProperties.accountAddress,
|
|
38
41
|
displayContainer: iframeContainer,
|
|
39
42
|
});
|
|
40
43
|
return true;
|
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
|
|
4
4
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
5
|
|
|
6
|
-
var _tslib = require('../../../../../../../_virtual/_tslib.cjs');
|
|
7
6
|
var jsxRuntime = require('react/jsx-runtime');
|
|
8
7
|
var sdkApiCore = require('@dynamic-labs/sdk-api-core');
|
|
9
8
|
require('@dynamic-labs/utils');
|
|
@@ -12,6 +11,7 @@ require('react-i18next');
|
|
|
12
11
|
require('react');
|
|
13
12
|
require('@dynamic-labs/iconic');
|
|
14
13
|
var ViewContext = require('../../../../../context/ViewContext/ViewContext.cjs');
|
|
14
|
+
require('../../../../../../../_virtual/_tslib.cjs');
|
|
15
15
|
require('../../../../../shared/logger.cjs');
|
|
16
16
|
require('@dynamic-labs/wallet-connector-core');
|
|
17
17
|
require('@dynamic-labs/wallet-book');
|
|
@@ -24,7 +24,7 @@ require('../../../../../context/DynamicContext/DynamicContext.cjs');
|
|
|
24
24
|
require('../../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.cjs');
|
|
25
25
|
require('../../../../../store/state/authMode/authMode.cjs');
|
|
26
26
|
var useInternalDynamicContext = require('../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.cjs');
|
|
27
|
-
|
|
27
|
+
require('../../../../../context/CaptchaContext/CaptchaContext.cjs');
|
|
28
28
|
require('../../../../../context/ErrorContext/ErrorContext.cjs');
|
|
29
29
|
require('@dynamic-labs/multi-wallet');
|
|
30
30
|
require('react-international-phone');
|
|
@@ -104,10 +104,9 @@ require('../../../../../components/Popper/PopperContext/PopperContext.cjs');
|
|
|
104
104
|
var SocialSignIn = require('../../../../../components/SocialSignIn/SocialSignIn.cjs');
|
|
105
105
|
|
|
106
106
|
const DynamicSocialSignIn = ({ defaultProvider, numOfItemsToDisplay, collapsedLayout, }) => {
|
|
107
|
-
const { setShowAuthFlow
|
|
107
|
+
const { setShowAuthFlow } = useInternalDynamicContext.useInternalDynamicContext();
|
|
108
108
|
const { setSocialProvider, socialProvider, enabledSocialProviders } = SocialRedirectContext.useSocialRedirectContext();
|
|
109
109
|
const { pushView, clearStackAndPushInitialView } = ViewContext.useViewContext();
|
|
110
|
-
const { engageCaptcha } = CaptchaContext.useCaptchaContext();
|
|
111
110
|
const { isProcessing, connectSocialAccount } = useSocialAuth.useSocialAuth({
|
|
112
111
|
onError: () => {
|
|
113
112
|
clearStackAndPushInitialView();
|
|
@@ -130,26 +129,8 @@ const DynamicSocialSignIn = ({ defaultProvider, numOfItemsToDisplay, collapsedLa
|
|
|
130
129
|
},
|
|
131
130
|
});
|
|
132
131
|
const onSelectProvider = (provider) => {
|
|
133
|
-
var _a;
|
|
134
132
|
const providerEnum = getProviderEnumForSocialSignInProvider.getProviderEnumForSocialSignInProvider(provider);
|
|
135
133
|
setSocialProvider(provider);
|
|
136
|
-
// Captcha Enabled
|
|
137
|
-
if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.hCaptcha) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
138
|
-
engageCaptcha({
|
|
139
|
-
authMethod: 'social',
|
|
140
|
-
onCaptchaSuccess: (captchaToken) => _tslib.__awaiter(void 0, void 0, void 0, function* () {
|
|
141
|
-
pushView('social-redirect-view');
|
|
142
|
-
setShowAuthFlow(true);
|
|
143
|
-
connectSocialAccount({
|
|
144
|
-
authMode: 'signin',
|
|
145
|
-
captchaToken,
|
|
146
|
-
provider: providerEnum,
|
|
147
|
-
});
|
|
148
|
-
}),
|
|
149
|
-
});
|
|
150
|
-
return;
|
|
151
|
-
}
|
|
152
|
-
// No Captcha enabled
|
|
153
134
|
pushView('social-redirect-view');
|
|
154
135
|
setShowAuthFlow(true);
|
|
155
136
|
connectSocialAccount({
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
'use client'
|
|
2
|
-
import { __awaiter } from '../../../../../../../_virtual/_tslib.js';
|
|
3
2
|
import { jsx } from 'react/jsx-runtime';
|
|
4
3
|
import { ProviderEnum } from '@dynamic-labs/sdk-api-core';
|
|
5
4
|
import '@dynamic-labs/utils';
|
|
@@ -8,6 +7,7 @@ import 'react-i18next';
|
|
|
8
7
|
import 'react';
|
|
9
8
|
import '@dynamic-labs/iconic';
|
|
10
9
|
import { useViewContext } from '../../../../../context/ViewContext/ViewContext.js';
|
|
10
|
+
import '../../../../../../../_virtual/_tslib.js';
|
|
11
11
|
import '../../../../../shared/logger.js';
|
|
12
12
|
import '@dynamic-labs/wallet-connector-core';
|
|
13
13
|
import '@dynamic-labs/wallet-book';
|
|
@@ -20,7 +20,7 @@ import '../../../../../context/DynamicContext/DynamicContext.js';
|
|
|
20
20
|
import '../../../../../store/state/loadingAndLifecycle/loadingAndLifecycle.js';
|
|
21
21
|
import '../../../../../store/state/authMode/authMode.js';
|
|
22
22
|
import { useInternalDynamicContext } from '../../../../../context/DynamicContext/useDynamicContext/useInternalDynamicContext/useInternalDynamicContext.js';
|
|
23
|
-
import
|
|
23
|
+
import '../../../../../context/CaptchaContext/CaptchaContext.js';
|
|
24
24
|
import '../../../../../context/ErrorContext/ErrorContext.js';
|
|
25
25
|
import '@dynamic-labs/multi-wallet';
|
|
26
26
|
import 'react-international-phone';
|
|
@@ -100,10 +100,9 @@ import '../../../../../components/Popper/PopperContext/PopperContext.js';
|
|
|
100
100
|
import { SocialSignIn } from '../../../../../components/SocialSignIn/SocialSignIn.js';
|
|
101
101
|
|
|
102
102
|
const DynamicSocialSignIn = ({ defaultProvider, numOfItemsToDisplay, collapsedLayout, }) => {
|
|
103
|
-
const { setShowAuthFlow
|
|
103
|
+
const { setShowAuthFlow } = useInternalDynamicContext();
|
|
104
104
|
const { setSocialProvider, socialProvider, enabledSocialProviders } = useSocialRedirectContext();
|
|
105
105
|
const { pushView, clearStackAndPushInitialView } = useViewContext();
|
|
106
|
-
const { engageCaptcha } = useCaptchaContext();
|
|
107
106
|
const { isProcessing, connectSocialAccount } = useSocialAuth({
|
|
108
107
|
onError: () => {
|
|
109
108
|
clearStackAndPushInitialView();
|
|
@@ -126,26 +125,8 @@ const DynamicSocialSignIn = ({ defaultProvider, numOfItemsToDisplay, collapsedLa
|
|
|
126
125
|
},
|
|
127
126
|
});
|
|
128
127
|
const onSelectProvider = (provider) => {
|
|
129
|
-
var _a;
|
|
130
128
|
const providerEnum = getProviderEnumForSocialSignInProvider(provider);
|
|
131
129
|
setSocialProvider(provider);
|
|
132
|
-
// Captcha Enabled
|
|
133
|
-
if ((_a = projectSettings === null || projectSettings === void 0 ? void 0 : projectSettings.security.hCaptcha) === null || _a === void 0 ? void 0 : _a.enabled) {
|
|
134
|
-
engageCaptcha({
|
|
135
|
-
authMethod: 'social',
|
|
136
|
-
onCaptchaSuccess: (captchaToken) => __awaiter(void 0, void 0, void 0, function* () {
|
|
137
|
-
pushView('social-redirect-view');
|
|
138
|
-
setShowAuthFlow(true);
|
|
139
|
-
connectSocialAccount({
|
|
140
|
-
authMode: 'signin',
|
|
141
|
-
captchaToken,
|
|
142
|
-
provider: providerEnum,
|
|
143
|
-
});
|
|
144
|
-
}),
|
|
145
|
-
});
|
|
146
|
-
return;
|
|
147
|
-
}
|
|
148
|
-
// No Captcha enabled
|
|
149
130
|
pushView('social-redirect-view');
|
|
150
131
|
setShowAuthFlow(true);
|
|
151
132
|
connectSocialAccount({
|