@dynamic-labs/sdk-react-core 2.1.0-alpha.29 → 2.1.0-alpha.30
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 +13 -13
- package/src/lib/context/DynamicContext/DynamicContext.cjs +1 -1
- package/src/lib/context/DynamicContext/DynamicContext.js +1 -1
- package/src/lib/context/DynamicContext/helpers/helpers.cjs +4 -9
- package/src/lib/context/DynamicContext/helpers/helpers.js +4 -9
- package/src/lib/store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.cjs +4 -1
- package/src/lib/store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.d.ts +2 -6
- package/src/lib/store/utils/storeAuthTokenAndUser/storeAuthTokenAndUser.js +4 -1
- package/src/lib/utils/constants/localStorage.cjs +2 -0
- package/src/lib/utils/constants/localStorage.d.ts +1 -0
- package/src/lib/utils/constants/localStorage.js +2 -1
- package/src/lib/utils/functions/getExpiresAt/getExpiresAt.cjs +23 -0
- package/src/lib/utils/functions/getExpiresAt/getExpiresAt.d.ts +1 -0
- package/src/lib/utils/functions/getExpiresAt/getExpiresAt.js +19 -0
- package/src/lib/utils/functions/getExpiresAt/index.d.ts +1 -0
- package/src/lib/utils/functions/index.d.ts +2 -0
- package/src/lib/utils/functions/storeExpiresAt/index.d.ts +1 -0
- package/src/lib/utils/functions/storeExpiresAt/storeExpiresAt.cjs +25 -0
- package/src/lib/utils/functions/storeExpiresAt/storeExpiresAt.d.ts +1 -0
- package/src/lib/utils/functions/storeExpiresAt/storeExpiresAt.js +21 -0
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.cjs +1 -0
- package/src/lib/utils/hooks/useUserAuth/useUserAuth.js +1 -0
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.cjs +6 -4
- package/src/lib/utils/hooks/useValidateSession/useValidateSession.js +7 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
|
|
2
|
+
## [2.1.0-alpha.30](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.29...v2.1.0-alpha.30) (2024-05-31)
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
### Bug Fixes
|
|
6
|
+
|
|
7
|
+
* ensure initExpirationTime is called automatically after authenticating ([#5797](https://github.com/dynamic-labs/DynamicAuth/issues/5797)) ([87eb802](https://github.com/dynamic-labs/DynamicAuth/commit/87eb802e0c2d3af2ca116e07099bfef426d30a1f))
|
|
8
|
+
* initExpirationTime should use expiresAt from storage ([#5799](https://github.com/dynamic-labs/DynamicAuth/issues/5799)) ([384ed17](https://github.com/dynamic-labs/DynamicAuth/commit/384ed1747d9b813ac0d34aaee36eb6480cb256d3))
|
|
9
|
+
* only run useValidateSession once on rerender ([#5795](https://github.com/dynamic-labs/DynamicAuth/issues/5795)) ([ba4446d](https://github.com/dynamic-labs/DynamicAuth/commit/ba4446df95726248b877a84def959cabe81ad9b6))
|
|
10
|
+
* store expiresAt timestamp from VerifyResponse in local storage for use in initExpirationTime ([#5796](https://github.com/dynamic-labs/DynamicAuth/issues/5796)) ([5f8aaeb](https://github.com/dynamic-labs/DynamicAuth/commit/5f8aaeb1cd45b10cb007f9eac25d18f50f142d8f))
|
|
11
|
+
|
|
2
12
|
## [2.1.0-alpha.29](https://github.com/dynamic-labs/DynamicAuth/compare/v2.1.0-alpha.28...v2.1.0-alpha.29) (2024-05-30)
|
|
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": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.30",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/dynamic-labs/dynamic-auth.git",
|
|
@@ -17,18 +17,18 @@
|
|
|
17
17
|
"react-i18next": "13.5.0",
|
|
18
18
|
"yup": "0.32.11",
|
|
19
19
|
"react-international-phone": "4.2.5",
|
|
20
|
-
"@dynamic-labs/iconic": "2.1.0-alpha.
|
|
21
|
-
"@dynamic-labs/logger": "2.1.0-alpha.
|
|
22
|
-
"@dynamic-labs/multi-wallet": "2.1.0-alpha.
|
|
23
|
-
"@dynamic-labs/rpc-provider-ethereum": "2.1.0-alpha.
|
|
24
|
-
"@dynamic-labs/rpc-provider-solana": "2.1.0-alpha.
|
|
25
|
-
"@dynamic-labs/rpc-providers": "2.1.0-alpha.
|
|
26
|
-
"@dynamic-labs/store": "2.1.0-alpha.
|
|
27
|
-
"@dynamic-labs/types": "2.1.0-alpha.
|
|
28
|
-
"@dynamic-labs/utils": "2.1.0-alpha.
|
|
29
|
-
"@dynamic-labs/viem-utils": "2.1.0-alpha.
|
|
30
|
-
"@dynamic-labs/wallet-book": "2.1.0-alpha.
|
|
31
|
-
"@dynamic-labs/wallet-connector-core": "2.1.0-alpha.
|
|
20
|
+
"@dynamic-labs/iconic": "2.1.0-alpha.30",
|
|
21
|
+
"@dynamic-labs/logger": "2.1.0-alpha.30",
|
|
22
|
+
"@dynamic-labs/multi-wallet": "2.1.0-alpha.30",
|
|
23
|
+
"@dynamic-labs/rpc-provider-ethereum": "2.1.0-alpha.30",
|
|
24
|
+
"@dynamic-labs/rpc-provider-solana": "2.1.0-alpha.30",
|
|
25
|
+
"@dynamic-labs/rpc-providers": "2.1.0-alpha.30",
|
|
26
|
+
"@dynamic-labs/store": "2.1.0-alpha.30",
|
|
27
|
+
"@dynamic-labs/types": "2.1.0-alpha.30",
|
|
28
|
+
"@dynamic-labs/utils": "2.1.0-alpha.30",
|
|
29
|
+
"@dynamic-labs/viem-utils": "2.1.0-alpha.30",
|
|
30
|
+
"@dynamic-labs/wallet-book": "2.1.0-alpha.30",
|
|
31
|
+
"@dynamic-labs/wallet-connector-core": "2.1.0-alpha.30",
|
|
32
32
|
"eventemitter3": "5.0.1"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
@@ -371,7 +371,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings: settings$1, lo
|
|
|
371
371
|
});
|
|
372
372
|
React.useEffect(() => {
|
|
373
373
|
helpers.initExpirationTime(handleLogOut);
|
|
374
|
-
}, [handleLogOut]);
|
|
374
|
+
}, [handleLogOut, isAuthenticated]);
|
|
375
375
|
const { setCallback } = useCustomerCallbacks.useCustomerCallbacks({
|
|
376
376
|
callbacks: {
|
|
377
377
|
onAuthSuccess: events === null || events === void 0 ? void 0 : events.onAuthSuccess,
|
|
@@ -367,7 +367,7 @@ const InnerDynamicContextProvider = ({ children, theme, settings, locale, }) =>
|
|
|
367
367
|
});
|
|
368
368
|
useEffect(() => {
|
|
369
369
|
initExpirationTime(handleLogOut);
|
|
370
|
-
}, [handleLogOut]);
|
|
370
|
+
}, [handleLogOut, isAuthenticated]);
|
|
371
371
|
const { setCallback } = useCustomerCallbacks({
|
|
372
372
|
callbacks: {
|
|
373
373
|
onAuthSuccess: events === null || events === void 0 ? void 0 : events.onAuthSuccess,
|
|
@@ -18,7 +18,7 @@ require('../../../utils/constants/values.cjs');
|
|
|
18
18
|
var localStorage = require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
19
19
|
require('@dynamic-labs/sdk-api-core');
|
|
20
20
|
require('@dynamic-labs/utils');
|
|
21
|
-
var
|
|
21
|
+
var getExpiresAt = require('../../../utils/functions/getExpiresAt/getExpiresAt.cjs');
|
|
22
22
|
|
|
23
23
|
let logoutTimer;
|
|
24
24
|
let dynamicContextSettingsTimer;
|
|
@@ -47,15 +47,10 @@ const isTokenExpired = (decoded) => {
|
|
|
47
47
|
return false;
|
|
48
48
|
};
|
|
49
49
|
const initExpirationTime = (logout) => {
|
|
50
|
-
const
|
|
51
|
-
if (!
|
|
50
|
+
const expiresAt = getExpiresAt.getExpiresAt();
|
|
51
|
+
if (!expiresAt)
|
|
52
52
|
return clearTimeout(logoutTimer);
|
|
53
|
-
const
|
|
54
|
-
if (!tokenExp) {
|
|
55
|
-
clearTimeout(logoutTimer);
|
|
56
|
-
return logout();
|
|
57
|
-
}
|
|
58
|
-
const expirationTime = new Date(tokenExp * 1000).getTime();
|
|
53
|
+
const expirationTime = new Date(expiresAt * 1000).getTime();
|
|
59
54
|
const currentTime = new Date().getTime();
|
|
60
55
|
if (currentTime >= expirationTime) {
|
|
61
56
|
clearTimeout(logoutTimer);
|
|
@@ -14,7 +14,7 @@ import '../../../utils/constants/values.js';
|
|
|
14
14
|
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
15
15
|
import '@dynamic-labs/sdk-api-core';
|
|
16
16
|
import '@dynamic-labs/utils';
|
|
17
|
-
import {
|
|
17
|
+
import { getExpiresAt } from '../../../utils/functions/getExpiresAt/getExpiresAt.js';
|
|
18
18
|
|
|
19
19
|
let logoutTimer;
|
|
20
20
|
let dynamicContextSettingsTimer;
|
|
@@ -43,15 +43,10 @@ const isTokenExpired = (decoded) => {
|
|
|
43
43
|
return false;
|
|
44
44
|
};
|
|
45
45
|
const initExpirationTime = (logout) => {
|
|
46
|
-
const
|
|
47
|
-
if (!
|
|
46
|
+
const expiresAt = getExpiresAt();
|
|
47
|
+
if (!expiresAt)
|
|
48
48
|
return clearTimeout(logoutTimer);
|
|
49
|
-
const
|
|
50
|
-
if (!tokenExp) {
|
|
51
|
-
clearTimeout(logoutTimer);
|
|
52
|
-
return logout();
|
|
53
|
-
}
|
|
54
|
-
const expirationTime = new Date(tokenExp * 1000).getTime();
|
|
49
|
+
const expirationTime = new Date(expiresAt * 1000).getTime();
|
|
55
50
|
const currentTime = new Date().getTime();
|
|
56
51
|
if (currentTime >= expirationTime) {
|
|
57
52
|
clearTimeout(logoutTimer);
|
|
@@ -26,8 +26,11 @@ require('viem/chains');
|
|
|
26
26
|
require('../../../config/ApiEndpoint.cjs');
|
|
27
27
|
var userActions = require('../../actions/userActions/userActions.cjs');
|
|
28
28
|
require('../../../locale/locale.cjs');
|
|
29
|
+
var storeExpiresAt = require('../../../utils/functions/storeExpiresAt/storeExpiresAt.cjs');
|
|
29
30
|
|
|
30
|
-
const storeAuthTokenAndUser = ({ user, jwt, minifiedJwt, }) => {
|
|
31
|
+
const storeAuthTokenAndUser = ({ user, jwt, minifiedJwt, expiresAt, }) => {
|
|
32
|
+
// expiresAt is always sent back by the backend, regardless of whether jwt/minifiedJwt are sent or not
|
|
33
|
+
storeExpiresAt.storeExpiresAt(expiresAt);
|
|
31
34
|
if (jwt && minifiedJwt) {
|
|
32
35
|
index.storeAuthToken(jwt, minifiedJwt);
|
|
33
36
|
}
|
|
@@ -1,7 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { VerifyResponse } from '@dynamic-labs/sdk-api-core';
|
|
2
2
|
import { UserProfile } from '../../../..';
|
|
3
|
-
export declare const storeAuthTokenAndUser: ({ user, jwt, minifiedJwt, }:
|
|
4
|
-
user: SdkUser;
|
|
5
|
-
jwt?: string;
|
|
6
|
-
minifiedJwt?: string;
|
|
7
|
-
}) => UserProfile;
|
|
3
|
+
export declare const storeAuthTokenAndUser: ({ user, jwt, minifiedJwt, expiresAt, }: VerifyResponse) => UserProfile;
|
|
@@ -22,8 +22,11 @@ import 'viem/chains';
|
|
|
22
22
|
import '../../../config/ApiEndpoint.js';
|
|
23
23
|
import { setUser } from '../../actions/userActions/userActions.js';
|
|
24
24
|
import '../../../locale/locale.js';
|
|
25
|
+
import { storeExpiresAt } from '../../../utils/functions/storeExpiresAt/storeExpiresAt.js';
|
|
25
26
|
|
|
26
|
-
const storeAuthTokenAndUser = ({ user, jwt, minifiedJwt, }) => {
|
|
27
|
+
const storeAuthTokenAndUser = ({ user, jwt, minifiedJwt, expiresAt, }) => {
|
|
28
|
+
// expiresAt is always sent back by the backend, regardless of whether jwt/minifiedJwt are sent or not
|
|
29
|
+
storeExpiresAt(expiresAt);
|
|
27
30
|
if (jwt && minifiedJwt) {
|
|
28
31
|
storeAuthToken(jwt, minifiedJwt);
|
|
29
32
|
}
|
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, '__esModule', { value: true });
|
|
|
5
5
|
|
|
6
6
|
const AUTH_TOKEN = 'dynamic_authentication_token';
|
|
7
7
|
const AUTH_MIN_TOKEN = 'dynamic_min_authentication_token';
|
|
8
|
+
const AUTH_EXPIRES_AT = 'dynamic_auth_expires_at';
|
|
8
9
|
const LAST_USED_WALLET = 'dynamic_last_used_wallet';
|
|
9
10
|
const NONCE_STORAGE_KEY = 'dynamic_nonce';
|
|
10
11
|
const PRIMARY_WALLET_ID = 'dynamic_primary_wallet_id';
|
|
@@ -26,6 +27,7 @@ const PHONE_INPUT_DEFAULT_COUNTRY = 'dynamic_phone_input_default_country';
|
|
|
26
27
|
const PHANTOM_SIGNATURE_STATE = 'phantom_verification_type';
|
|
27
28
|
const STORE_STORAGE_KEY = 'dynamic_store';
|
|
28
29
|
|
|
30
|
+
exports.AUTH_EXPIRES_AT = AUTH_EXPIRES_AT;
|
|
29
31
|
exports.AUTH_MIN_TOKEN = AUTH_MIN_TOKEN;
|
|
30
32
|
exports.AUTH_MODE = AUTH_MODE;
|
|
31
33
|
exports.AUTH_TOKEN = AUTH_TOKEN;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
export declare const AUTH_TOKEN = "dynamic_authentication_token";
|
|
2
2
|
export declare const AUTH_MIN_TOKEN = "dynamic_min_authentication_token";
|
|
3
|
+
export declare const AUTH_EXPIRES_AT = "dynamic_auth_expires_at";
|
|
3
4
|
export declare const LAST_USED_WALLET = "dynamic_last_used_wallet";
|
|
4
5
|
export declare const NETWORKS_STORAGE_KEY = "dynamic_networks";
|
|
5
6
|
export declare const NONCE_STORAGE_KEY = "dynamic_nonce";
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
const AUTH_TOKEN = 'dynamic_authentication_token';
|
|
3
3
|
const AUTH_MIN_TOKEN = 'dynamic_min_authentication_token';
|
|
4
|
+
const AUTH_EXPIRES_AT = 'dynamic_auth_expires_at';
|
|
4
5
|
const LAST_USED_WALLET = 'dynamic_last_used_wallet';
|
|
5
6
|
const NONCE_STORAGE_KEY = 'dynamic_nonce';
|
|
6
7
|
const PRIMARY_WALLET_ID = 'dynamic_primary_wallet_id';
|
|
@@ -22,4 +23,4 @@ const PHONE_INPUT_DEFAULT_COUNTRY = 'dynamic_phone_input_default_country';
|
|
|
22
23
|
const PHANTOM_SIGNATURE_STATE = 'phantom_verification_type';
|
|
23
24
|
const STORE_STORAGE_KEY = 'dynamic_store';
|
|
24
25
|
|
|
25
|
-
export { AUTH_MIN_TOKEN, AUTH_MODE, AUTH_TOKEN, BRIDGE_ONBOARDING_COMPLETED, CONNECTED_WALLETS_INFO, CONNECTED_WALLET_NAME_SERVICE, COOKIE_ENABLED_KEY, DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, EMBEDDED_WALLET_SECURE_BANNER, EMBEDDED_WALLET_SESSION_SETTINGS, LAST_USED_WALLET, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, NONCE_STORAGE_KEY, PHANTOM_SIGNATURE_STATE, PHONE_INPUT_DEFAULT_COUNTRY, PRIMARY_WALLET_ID, STORE_STORAGE_KEY, WAGMI_LAST_SESSION_SETTINGS, WALLET_PICKER_SEARCH_KEY };
|
|
26
|
+
export { AUTH_EXPIRES_AT, AUTH_MIN_TOKEN, AUTH_MODE, AUTH_TOKEN, BRIDGE_ONBOARDING_COMPLETED, CONNECTED_WALLETS_INFO, CONNECTED_WALLET_NAME_SERVICE, COOKIE_ENABLED_KEY, DYNAMIC_CONTEXT_LAST_SESSION_SETTINGS, EMBEDDED_WALLET_SECURE_BANNER, EMBEDDED_WALLET_SESSION_SETTINGS, LAST_USED_WALLET, NEWTOWEB3_WALLET_EXTENSION_FLAG_KEY, NONCE_STORAGE_KEY, PHANTOM_SIGNATURE_STATE, PHONE_INPUT_DEFAULT_COUNTRY, PRIMARY_WALLET_ID, STORE_STORAGE_KEY, WAGMI_LAST_SESSION_SETTINGS, WALLET_PICKER_SEARCH_KEY };
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
require('../../../shared/logger.cjs');
|
|
8
|
+
require('@dynamic-labs/iconic');
|
|
9
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
10
|
+
require('react/jsx-runtime');
|
|
11
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
12
|
+
require('react');
|
|
13
|
+
require('@dynamic-labs/wallet-book');
|
|
14
|
+
var localStorage$1 = require('../../constants/localStorage.cjs');
|
|
15
|
+
require('../../constants/colors.cjs');
|
|
16
|
+
require('../../constants/values.cjs');
|
|
17
|
+
var localStorage = require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
|
+
require('@dynamic-labs/utils');
|
|
19
|
+
require('../../../shared/consts/index.cjs');
|
|
20
|
+
|
|
21
|
+
const getExpiresAt = () => localStorage.LocalStorage.getFromLS(localStorage$1.AUTH_EXPIRES_AT);
|
|
22
|
+
|
|
23
|
+
exports.getExpiresAt = getExpiresAt;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const getExpiresAt: () => any;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import '../../../shared/logger.js';
|
|
4
|
+
import '@dynamic-labs/iconic';
|
|
5
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import 'react/jsx-runtime';
|
|
7
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
8
|
+
import 'react';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import { AUTH_EXPIRES_AT } from '../../constants/localStorage.js';
|
|
11
|
+
import '../../constants/colors.js';
|
|
12
|
+
import '../../constants/values.js';
|
|
13
|
+
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import '@dynamic-labs/utils';
|
|
15
|
+
import '../../../shared/consts/index.js';
|
|
16
|
+
|
|
17
|
+
const getExpiresAt = () => LocalStorage.getFromLS(AUTH_EXPIRES_AT);
|
|
18
|
+
|
|
19
|
+
export { getExpiresAt };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { getExpiresAt } from './getExpiresAt';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { storeExpiresAt } from './storeExpiresAt';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
'use strict';
|
|
3
|
+
|
|
4
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
5
|
+
|
|
6
|
+
require('@dynamic-labs/sdk-api-core');
|
|
7
|
+
require('../../../shared/logger.cjs');
|
|
8
|
+
require('@dynamic-labs/iconic');
|
|
9
|
+
require('@dynamic-labs/wallet-connector-core');
|
|
10
|
+
require('react/jsx-runtime');
|
|
11
|
+
require('../../../context/ViewContext/ViewContext.cjs');
|
|
12
|
+
require('react');
|
|
13
|
+
require('@dynamic-labs/wallet-book');
|
|
14
|
+
var localStorage$1 = require('../../constants/localStorage.cjs');
|
|
15
|
+
require('../../constants/colors.cjs');
|
|
16
|
+
require('../../constants/values.cjs');
|
|
17
|
+
var localStorage = require('../../../shared/utils/classes/storage/localStorage.cjs');
|
|
18
|
+
require('@dynamic-labs/utils');
|
|
19
|
+
require('../../../shared/consts/index.cjs');
|
|
20
|
+
|
|
21
|
+
const storeExpiresAt = (expiresAt) => {
|
|
22
|
+
localStorage.LocalStorage.setToLS(localStorage$1.AUTH_EXPIRES_AT, expiresAt);
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
exports.storeExpiresAt = storeExpiresAt;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const storeExpiresAt: (expiresAt: number) => void;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import '@dynamic-labs/sdk-api-core';
|
|
3
|
+
import '../../../shared/logger.js';
|
|
4
|
+
import '@dynamic-labs/iconic';
|
|
5
|
+
import '@dynamic-labs/wallet-connector-core';
|
|
6
|
+
import 'react/jsx-runtime';
|
|
7
|
+
import '../../../context/ViewContext/ViewContext.js';
|
|
8
|
+
import 'react';
|
|
9
|
+
import '@dynamic-labs/wallet-book';
|
|
10
|
+
import { AUTH_EXPIRES_AT } from '../../constants/localStorage.js';
|
|
11
|
+
import '../../constants/colors.js';
|
|
12
|
+
import '../../constants/values.js';
|
|
13
|
+
import { LocalStorage } from '../../../shared/utils/classes/storage/localStorage.js';
|
|
14
|
+
import '@dynamic-labs/utils';
|
|
15
|
+
import '../../../shared/consts/index.js';
|
|
16
|
+
|
|
17
|
+
const storeExpiresAt = (expiresAt) => {
|
|
18
|
+
LocalStorage.setToLS(AUTH_EXPIRES_AT, expiresAt);
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
export { storeExpiresAt };
|
|
@@ -236,6 +236,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
236
236
|
const { updateUserProfileResponse, isSmsVerificationRequired, isEmailVerificationRequired, missingFields, } = yield updateJwtFunction();
|
|
237
237
|
onValidUpdatedJwt === null || onValidUpdatedJwt === void 0 ? void 0 : onValidUpdatedJwt();
|
|
238
238
|
const updatedUser = storeAuthTokenAndUser.storeAuthTokenAndUser({
|
|
239
|
+
expiresAt: updateUserProfileResponse.expiresAt,
|
|
239
240
|
jwt: updateUserProfileResponse.jwt,
|
|
240
241
|
minifiedJwt: updateUserProfileResponse.minifiedJwt,
|
|
241
242
|
user: updateUserProfileResponse.user,
|
|
@@ -232,6 +232,7 @@ const useUserAuth = ({ authMethod, }) => {
|
|
|
232
232
|
const { updateUserProfileResponse, isSmsVerificationRequired, isEmailVerificationRequired, missingFields, } = yield updateJwtFunction();
|
|
233
233
|
onValidUpdatedJwt === null || onValidUpdatedJwt === void 0 ? void 0 : onValidUpdatedJwt();
|
|
234
234
|
const updatedUser = storeAuthTokenAndUser({
|
|
235
|
+
expiresAt: updateUserProfileResponse.expiresAt,
|
|
235
236
|
jwt: updateUserProfileResponse.jwt,
|
|
236
237
|
minifiedJwt: updateUserProfileResponse.minifiedJwt,
|
|
237
238
|
user: updateUserProfileResponse.user,
|
|
@@ -126,10 +126,12 @@ const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
|
126
126
|
});
|
|
127
127
|
storeActions.setEnvironment(environmentId);
|
|
128
128
|
});
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
129
|
+
React.useEffect(() => {
|
|
130
|
+
if (!hasLoggedOut) {
|
|
131
|
+
handleStoreAndEnvironemntMismatch();
|
|
132
|
+
handleUserDataOutOfSync();
|
|
133
|
+
}
|
|
134
|
+
}, [hasLoggedOut]);
|
|
133
135
|
return { setHasLoggedOut };
|
|
134
136
|
};
|
|
135
137
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import { __awaiter } from '../../../../../_virtual/_tslib.js';
|
|
3
|
-
import { useState } from 'react';
|
|
3
|
+
import { useState, useEffect } from 'react';
|
|
4
4
|
import { CookieInvalidError } from '@dynamic-labs/utils';
|
|
5
5
|
import '@dynamic-labs/sdk-api-core';
|
|
6
6
|
import { logger } from '../../../shared/logger.js';
|
|
@@ -122,10 +122,12 @@ const useValidateSession = ({ environmentId, handleLogOut }) => {
|
|
|
122
122
|
});
|
|
123
123
|
setEnvironment(environmentId);
|
|
124
124
|
});
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
125
|
+
useEffect(() => {
|
|
126
|
+
if (!hasLoggedOut) {
|
|
127
|
+
handleStoreAndEnvironemntMismatch();
|
|
128
|
+
handleUserDataOutOfSync();
|
|
129
|
+
}
|
|
130
|
+
}, [hasLoggedOut]);
|
|
129
131
|
return { setHasLoggedOut };
|
|
130
132
|
};
|
|
131
133
|
|