UNPKG

besper-frontend-site-dev-main

Version:

Professional B-esper Frontend Site - Site-wide integration toolkit for full website bot deployment

134 lines (116 loc) 4.62 kB
/** * Central Token Manager - DEPRECATED * This file is deprecated in favor of professionalCookieTokenManager.js * Keeping for backward compatibility but all functions now delegate to professionalTokenManager */ console.warn( '[CentralToken] DEPRECATED: centralTokenManager.js is deprecated. Use professionalCookieTokenManager.js instead.' ); // Import the professional token manager import professionalTokenManager from './professionalCookieTokenManager.js'; class CentralTokenManager { constructor() { console.warn( '[CentralToken] DEPRECATED: CentralTokenManager is deprecated. Use ProfessionalCookieTokenManager instead.' ); // Delegate all calls to professionalTokenManager this.professional = professionalTokenManager; } /** * DEPRECATED: Use professionalTokenManager.getToken() instead */ async generateToken(requestingFunction = 'deprecated-call') { console.warn( `[CentralToken] DEPRECATED: generateToken called by ${requestingFunction}. Use professionalTokenManager.getToken() instead.` ); return this.professional.getToken(requestingFunction); } /** * DEPRECATED: Use professionalTokenManager.getToken() instead */ async getValidToken(requestingFunction = 'deprecated-call') { console.warn( `[CentralToken] DEPRECATED: getValidToken called by ${requestingFunction}. Use professionalTokenManager.getToken() instead.` ); return this.professional.getToken(requestingFunction); } /** * DEPRECATED: Use professionalTokenManager.getTokenSync() instead */ getCurrentToken() { console.warn( '[CentralToken] DEPRECATED: getCurrentToken. Use professionalTokenManager.getTokenSync() instead.' ); return this.professional.getTokenSync(); } /** * DEPRECATED: Use professionalTokenManager.isAuthenticated() instead */ isAuthenticated() { return this.professional.isAuthenticated(); } /** * DEPRECATED: Use professionalTokenManager.getUserInfo() instead */ getUserInfo() { return this.professional.getUserInfo(); } /** * DEPRECATED: Use professionalTokenManager.clearAllTokens() instead */ clearToken() { console.warn( '[CentralToken] DEPRECATED: clearToken. Use professionalTokenManager.clearAllTokens() instead.' ); return this.professional.clearAllTokens(); } /** * DEPRECATED: Use professionalTokenManager.forceRefresh() instead */ async refreshToken(requestingFunction = 'deprecated-call') { console.warn( `[CentralToken] DEPRECATED: refreshToken called by ${requestingFunction}. Use professionalTokenManager.forceRefresh() instead.` ); return this.professional.forceRefresh(requestingFunction); } // Additional deprecated methods for compatibility async coordinateTokenRequest(requestingFunction = 'deprecated-call') { console.warn( `[CentralToken] DEPRECATED: coordinateTokenRequest called by ${requestingFunction}. This method is no longer needed with professional tokens.` ); return this.professional.getToken(requestingFunction); } registerSubscriber(_functionName, _callback) { console.warn( '[CentralToken] DEPRECATED: registerSubscriber. Professional tokens do not require subscriptions.' ); return () => {}; // Return empty unsubscribe function } getCoordinationStats() { console.warn( '[CentralToken] DEPRECATED: getCoordinationStats. Use professionalTokenManager.getDebugInfo() instead.' ); return this.professional.getDebugInfo(); } } // Create deprecated instance that delegates to professional version const centralTokenManager = new CentralTokenManager(); // Export for backward compatibility export default centralTokenManager; export { CentralTokenManager }; // DEPRECATED global functions - delegate to professionalTokenManager if (typeof window !== 'undefined') { // Only override if professionalTokenManager hasn't already set them if (!window.generateToken) { 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); } }