@dynamic-labs/sdk-react-core
Version:
A React SDK for implementing wallet web3 authentication and authorization to your website.
25 lines (22 loc) • 675 B
JavaScript
'use client'
import { StorageService } from '@dynamic-labs/utils';
import { isAuthTokenExpired } from '../../../context/DynamicContext/helpers/helpers.js';
import { AUTH_TOKEN } from '../../constants/localStorage.js';
import '../../constants/colors.js';
import '../../constants/values.js';
const getAuthToken = () => {
if (typeof window === 'undefined') {
return undefined;
}
const token = StorageService.getItem(AUTH_TOKEN, {
priority: ['secureStorage', 'localStorage'],
});
if (!token) {
return undefined;
}
if (isAuthTokenExpired(token)) {
return undefined;
}
return token;
};
export { getAuthToken };