UNPKG

polyv-live-cli

Version:

CLI tool for managing PolyV live streaming services.

54 lines 2.24 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.authProvider = exports.DefaultAuthenticationProvider = void 0; const auth_source_manager_1 = require("./auth-source-manager"); class DefaultAuthenticationProvider { constructor(sessionManager, accountManager) { this.sourceManager = new auth_source_manager_1.AuthenticationSourceManager(sessionManager, accountManager); } getAuthenticationContext(options) { const diagnostics = this.sourceManager.getDiagnostics(options); const selectedSource = diagnostics.selectedSource; if (!selectedSource || !this.sourceManager.isCompleteAuthentication(selectedSource)) { return null; } return { source: selectedSource, credentials: { appId: selectedSource.appId, appSecret: selectedSource.appSecret, ...(selectedSource.userId && { userId: selectedSource.userId }), }, diagnostics: { attemptedSources: diagnostics.availableSources.map(s => s.metadata.source), selectedReason: `优先级最高的完整认证源 (优先级 ${selectedSource.priority})`, warnings: diagnostics.warnings, isComplete: true, }, }; } getCredentials(options) { return this.sourceManager.getCredentials(options); } getCurrentSource(options) { return this.sourceManager.getAuthenticationSource(options); } validateAuthentication(source) { return this.sourceManager.isCompleteAuthentication(source); } getStatusMessage(options) { return this.sourceManager.getStatusMessage(options); } getDiagnostics(options) { return this.sourceManager.getDiagnostics(options); } getSourceByType(type, options) { return this.sourceManager.getSourceByType(type, options); } isSourceAvailable(type, options) { return this.sourceManager.isSourceAvailable(type, options); } } exports.DefaultAuthenticationProvider = DefaultAuthenticationProvider; exports.authProvider = new DefaultAuthenticationProvider(); //# sourceMappingURL=auth-provider.js.map