besper-frontend-site-dev-main
Version:
Professional B-esper Frontend Site - Site-wide integration toolkit for full website bot deployment
115 lines (105 loc) • 3.98 kB
JavaScript
/**
* DEPRECATED: This file is replaced by professionalCookieTokenManager.js
* Keeping for backward compatibility but delegating to the professional version
*/
import professionalTokenManager from './professionalCookieTokenManager.js';
console.warn(
'[CookieToken] DEPRECATED: This cookie token manager is deprecated. Use professionalCookieTokenManager instead.'
);
class CookieTokenManager {
constructor() {
console.warn(
'[CookieToken] DEPRECATED: Use professionalCookieTokenManager instead'
);
// Delegate all operations to the professional version
this.professional = professionalTokenManager;
}
// All methods delegate to professional version
getCookie(cookieName) {
return this.professional.getCookie(cookieName);
}
setCookie(cookieName, value, expiryMs) {
return this.professional.setCookie(cookieName, value, expiryMs);
}
clearCookie(cookieName) {
return this.professional.clearCookie(cookieName);
}
isTokenValid() {
return this.professional.isTokenValid();
}
getTokenSync() {
return this.professional.getTokenSync();
}
async getToken(requestingFunction) {
return this.professional.getToken(requestingFunction);
}
async waitForRefresh(requestingFunction) {
return this.professional.waitForRefresh(requestingFunction);
}
async refreshToken(requestingFunction) {
return this.professional.performAtomicRefresh(requestingFunction);
}
async performTokenRefresh() {
return this.professional.executeTokenRefresh();
}
storeToken(token, lifetimeMs) {
return this.professional.storeToken(token, lifetimeMs);
}
storeUserInfo(userInfo) {
return this.professional.storeUserInfo(userInfo);
}
storeUserInfoFromGlobals() {
return this.professional.storeUserInfoFromGlobals();
}
getUserInfo() {
return this.professional.getUserInfo();
}
isAuthenticated() {
return this.professional.isAuthenticated();
}
clearToken() {
return this.professional.clearAllTokens();
}
async forceRefresh(requestingFunction) {
return this.professional.forceRefresh(requestingFunction);
}
getDebugInfo() {
return this.professional.getDebugInfo();
}
}
// Create deprecated instance that delegates to professional version
const cookieTokenManager = {
// All properties and methods delegate to professional version
...professionalTokenManager,
// Maintain compatibility
getToken: requestingFunction =>
professionalTokenManager.getToken(requestingFunction),
getTokenSync: () => professionalTokenManager.getTokenSync(),
isAuthenticated: () => professionalTokenManager.isAuthenticated(),
getUserInfo: () => professionalTokenManager.getUserInfo(),
clearToken: () => professionalTokenManager.clearAllTokens(),
forceRefresh: requestingFunction =>
professionalTokenManager.forceRefresh(requestingFunction),
getDebugInfo: () => professionalTokenManager.getDebugInfo(),
};
// Export for module use
export default cookieTokenManager;
export { CookieTokenManager };
// Make available globally - DELEGATE TO PROFESSIONAL VERSION
if (typeof window !== 'undefined') {
window.cookieTokenManager = cookieTokenManager;
// SAFE GLOBAL FUNCTIONS - delegate to professional token manager
window.generateToken = requestingFunction =>
professionalTokenManager.getToken(requestingFunction);
window.getValidToken = requestingFunction =>
professionalTokenManager.getToken(requestingFunction);
window.getCurrentToken = () => professionalTokenManager.getTokenSync();
window.isAuthenticated = () => professionalTokenManager.isAuthenticated();
window.getUserInfo = () => professionalTokenManager.getUserInfo();
window.clearToken = () => professionalTokenManager.clearAllTokens();
window.refreshToken = requestingFunction =>
professionalTokenManager.forceRefresh(requestingFunction);
console.log(
'[CookieToken] [WARN] DEPRECATED global functions available - delegating to professionalTokenManager'
);
}