agentic-qe 2.7.4 → 2.8.0
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 +104 -0
- package/README.md +67 -2
- package/dist/cli/commands/agent/spawn.d.ts +12 -1
- package/dist/cli/commands/agent/spawn.d.ts.map +1 -1
- package/dist/cli/commands/agent/spawn.js +95 -8
- package/dist/cli/commands/agent/spawn.js.map +1 -1
- package/dist/cli/index.js +91 -0
- package/dist/cli/index.js.map +1 -1
- package/dist/core/memory/HNSWVectorMemory.js +1 -1
- package/dist/edge/adapters/BrowserHNSWAdapter.d.ts +134 -0
- package/dist/edge/adapters/BrowserHNSWAdapter.d.ts.map +1 -0
- package/dist/edge/adapters/BrowserHNSWAdapter.js +484 -0
- package/dist/edge/adapters/BrowserHNSWAdapter.js.map +1 -0
- package/dist/edge/adapters/IndexedDBStorage.d.ts +114 -0
- package/dist/edge/adapters/IndexedDBStorage.d.ts.map +1 -0
- package/dist/edge/adapters/IndexedDBStorage.js +478 -0
- package/dist/edge/adapters/IndexedDBStorage.js.map +1 -0
- package/dist/edge/adapters/index.d.ts +12 -0
- package/dist/edge/adapters/index.d.ts.map +1 -0
- package/dist/edge/adapters/index.js +22 -0
- package/dist/edge/adapters/index.js.map +1 -0
- package/dist/edge/browser/BrowserAgent.d.ts +241 -0
- package/dist/edge/browser/BrowserAgent.d.ts.map +1 -0
- package/dist/edge/browser/BrowserAgent.js +743 -0
- package/dist/edge/browser/BrowserAgent.js.map +1 -0
- package/dist/edge/index.d.ts +34 -0
- package/dist/edge/index.d.ts.map +1 -0
- package/dist/edge/index.js +114 -0
- package/dist/edge/index.js.map +1 -0
- package/dist/edge/p2p/coordination/CoordinationManager.d.ts +181 -0
- package/dist/edge/p2p/coordination/CoordinationManager.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/CoordinationManager.js +851 -0
- package/dist/edge/p2p/coordination/CoordinationManager.js.map +1 -0
- package/dist/edge/p2p/coordination/HealthMonitor.d.ts +143 -0
- package/dist/edge/p2p/coordination/HealthMonitor.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/HealthMonitor.js +432 -0
- package/dist/edge/p2p/coordination/HealthMonitor.js.map +1 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.d.ts +146 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.js +783 -0
- package/dist/edge/p2p/coordination/SyncOrchestrator.js.map +1 -0
- package/dist/edge/p2p/coordination/index.d.ts +70 -0
- package/dist/edge/p2p/coordination/index.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/index.js +107 -0
- package/dist/edge/p2p/coordination/index.js.map +1 -0
- package/dist/edge/p2p/coordination/types.d.ts +572 -0
- package/dist/edge/p2p/coordination/types.d.ts.map +1 -0
- package/dist/edge/p2p/coordination/types.js +366 -0
- package/dist/edge/p2p/coordination/types.js.map +1 -0
- package/dist/edge/p2p/crdt/CRDTStore.d.ts +324 -0
- package/dist/edge/p2p/crdt/CRDTStore.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/CRDTStore.js +839 -0
- package/dist/edge/p2p/crdt/CRDTStore.js.map +1 -0
- package/dist/edge/p2p/crdt/GCounter.d.ts +173 -0
- package/dist/edge/p2p/crdt/GCounter.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/GCounter.js +394 -0
- package/dist/edge/p2p/crdt/GCounter.js.map +1 -0
- package/dist/edge/p2p/crdt/LWWRegister.d.ts +200 -0
- package/dist/edge/p2p/crdt/LWWRegister.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/LWWRegister.js +456 -0
- package/dist/edge/p2p/crdt/LWWRegister.js.map +1 -0
- package/dist/edge/p2p/crdt/ORSet.d.ts +232 -0
- package/dist/edge/p2p/crdt/ORSet.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/ORSet.js +723 -0
- package/dist/edge/p2p/crdt/ORSet.js.map +1 -0
- package/dist/edge/p2p/crdt/PatternCRDT.d.ts +366 -0
- package/dist/edge/p2p/crdt/PatternCRDT.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/PatternCRDT.js +838 -0
- package/dist/edge/p2p/crdt/PatternCRDT.js.map +1 -0
- package/dist/edge/p2p/crdt/VectorClock.d.ts +274 -0
- package/dist/edge/p2p/crdt/VectorClock.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/VectorClock.js +499 -0
- package/dist/edge/p2p/crdt/VectorClock.js.map +1 -0
- package/dist/edge/p2p/crdt/index.d.ts +87 -0
- package/dist/edge/p2p/crdt/index.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/index.js +120 -0
- package/dist/edge/p2p/crdt/index.js.map +1 -0
- package/dist/edge/p2p/crdt/types.d.ts +667 -0
- package/dist/edge/p2p/crdt/types.d.ts.map +1 -0
- package/dist/edge/p2p/crdt/types.js +208 -0
- package/dist/edge/p2p/crdt/types.js.map +1 -0
- package/dist/edge/p2p/crypto/Identity.d.ts +139 -0
- package/dist/edge/p2p/crypto/Identity.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/Identity.js +449 -0
- package/dist/edge/p2p/crypto/Identity.js.map +1 -0
- package/dist/edge/p2p/crypto/KeyManager.d.ts +196 -0
- package/dist/edge/p2p/crypto/KeyManager.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/KeyManager.js +576 -0
- package/dist/edge/p2p/crypto/KeyManager.js.map +1 -0
- package/dist/edge/p2p/crypto/Signer.d.ts +164 -0
- package/dist/edge/p2p/crypto/Signer.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/Signer.js +357 -0
- package/dist/edge/p2p/crypto/Signer.js.map +1 -0
- package/dist/edge/p2p/crypto/index.d.ts +90 -0
- package/dist/edge/p2p/crypto/index.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/index.js +158 -0
- package/dist/edge/p2p/crypto/index.js.map +1 -0
- package/dist/edge/p2p/crypto/types.d.ts +217 -0
- package/dist/edge/p2p/crypto/types.d.ts.map +1 -0
- package/dist/edge/p2p/crypto/types.js +42 -0
- package/dist/edge/p2p/crypto/types.js.map +1 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.d.ts +270 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.d.ts.map +1 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.js +824 -0
- package/dist/edge/p2p/federated/FederatedCoordinator.js.map +1 -0
- package/dist/edge/p2p/federated/FederatedRound.d.ts +295 -0
- package/dist/edge/p2p/federated/FederatedRound.d.ts.map +1 -0
- package/dist/edge/p2p/federated/FederatedRound.js +819 -0
- package/dist/edge/p2p/federated/FederatedRound.js.map +1 -0
- package/dist/edge/p2p/federated/GradientAggregator.d.ts +226 -0
- package/dist/edge/p2p/federated/GradientAggregator.d.ts.map +1 -0
- package/dist/edge/p2p/federated/GradientAggregator.js +826 -0
- package/dist/edge/p2p/federated/GradientAggregator.js.map +1 -0
- package/dist/edge/p2p/federated/ModelManager.d.ts +248 -0
- package/dist/edge/p2p/federated/ModelManager.d.ts.map +1 -0
- package/dist/edge/p2p/federated/ModelManager.js +724 -0
- package/dist/edge/p2p/federated/ModelManager.js.map +1 -0
- package/dist/edge/p2p/federated/index.d.ts +65 -0
- package/dist/edge/p2p/federated/index.d.ts.map +1 -0
- package/dist/edge/p2p/federated/index.js +110 -0
- package/dist/edge/p2p/federated/index.js.map +1 -0
- package/dist/edge/p2p/federated/types.d.ts +905 -0
- package/dist/edge/p2p/federated/types.d.ts.map +1 -0
- package/dist/edge/p2p/federated/types.js +339 -0
- package/dist/edge/p2p/federated/types.js.map +1 -0
- package/dist/edge/p2p/index.d.ts +156 -0
- package/dist/edge/p2p/index.d.ts.map +1 -0
- package/dist/edge/p2p/index.js +242 -0
- package/dist/edge/p2p/index.js.map +1 -0
- package/dist/edge/p2p/nat/ConnectivityTester.d.ts +128 -0
- package/dist/edge/p2p/nat/ConnectivityTester.d.ts.map +1 -0
- package/dist/edge/p2p/nat/ConnectivityTester.js +560 -0
- package/dist/edge/p2p/nat/ConnectivityTester.js.map +1 -0
- package/dist/edge/p2p/nat/HolePuncher.d.ts +159 -0
- package/dist/edge/p2p/nat/HolePuncher.d.ts.map +1 -0
- package/dist/edge/p2p/nat/HolePuncher.js +569 -0
- package/dist/edge/p2p/nat/HolePuncher.js.map +1 -0
- package/dist/edge/p2p/nat/NATDetector.d.ts +109 -0
- package/dist/edge/p2p/nat/NATDetector.d.ts.map +1 -0
- package/dist/edge/p2p/nat/NATDetector.js +472 -0
- package/dist/edge/p2p/nat/NATDetector.js.map +1 -0
- package/dist/edge/p2p/nat/TURNManager.d.ts +158 -0
- package/dist/edge/p2p/nat/TURNManager.d.ts.map +1 -0
- package/dist/edge/p2p/nat/TURNManager.js +547 -0
- package/dist/edge/p2p/nat/TURNManager.js.map +1 -0
- package/dist/edge/p2p/nat/index.d.ts +74 -0
- package/dist/edge/p2p/nat/index.d.ts.map +1 -0
- package/dist/edge/p2p/nat/index.js +104 -0
- package/dist/edge/p2p/nat/index.js.map +1 -0
- package/dist/edge/p2p/nat/types.d.ts +583 -0
- package/dist/edge/p2p/nat/types.d.ts.map +1 -0
- package/dist/edge/p2p/nat/types.js +267 -0
- package/dist/edge/p2p/nat/types.js.map +1 -0
- package/dist/edge/p2p/protocol/AgentChannel.d.ts +333 -0
- package/dist/edge/p2p/protocol/AgentChannel.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/AgentChannel.js +914 -0
- package/dist/edge/p2p/protocol/AgentChannel.js.map +1 -0
- package/dist/edge/p2p/protocol/MessageEncoder.d.ts +147 -0
- package/dist/edge/p2p/protocol/MessageEncoder.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/MessageEncoder.js +738 -0
- package/dist/edge/p2p/protocol/MessageEncoder.js.map +1 -0
- package/dist/edge/p2p/protocol/MessageRouter.d.ts +266 -0
- package/dist/edge/p2p/protocol/MessageRouter.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/MessageRouter.js +808 -0
- package/dist/edge/p2p/protocol/MessageRouter.js.map +1 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.d.ts +309 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.js +930 -0
- package/dist/edge/p2p/protocol/ProtocolHandler.js.map +1 -0
- package/dist/edge/p2p/protocol/index.d.ts +114 -0
- package/dist/edge/p2p/protocol/index.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/index.js +206 -0
- package/dist/edge/p2p/protocol/index.js.map +1 -0
- package/dist/edge/p2p/protocol/types.d.ts +737 -0
- package/dist/edge/p2p/protocol/types.d.ts.map +1 -0
- package/dist/edge/p2p/protocol/types.js +490 -0
- package/dist/edge/p2p/protocol/types.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.d.ts +284 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.js +644 -0
- package/dist/edge/p2p/sharing/PatternBroadcaster.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternIndex.d.ts +168 -0
- package/dist/edge/p2p/sharing/PatternIndex.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternIndex.js +781 -0
- package/dist/edge/p2p/sharing/PatternIndex.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternSerializer.d.ts +163 -0
- package/dist/edge/p2p/sharing/PatternSerializer.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternSerializer.js +696 -0
- package/dist/edge/p2p/sharing/PatternSerializer.js.map +1 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.d.ts +242 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.js +859 -0
- package/dist/edge/p2p/sharing/PatternSyncManager.js.map +1 -0
- package/dist/edge/p2p/sharing/index.d.ts +90 -0
- package/dist/edge/p2p/sharing/index.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/index.js +152 -0
- package/dist/edge/p2p/sharing/index.js.map +1 -0
- package/dist/edge/p2p/sharing/types.d.ts +796 -0
- package/dist/edge/p2p/sharing/types.d.ts.map +1 -0
- package/dist/edge/p2p/sharing/types.js +264 -0
- package/dist/edge/p2p/sharing/types.js.map +1 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.d.ts +218 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.js +562 -0
- package/dist/edge/p2p/webrtc/ConnectionPool.js.map +1 -0
- package/dist/edge/p2p/webrtc/ICEManager.d.ts +171 -0
- package/dist/edge/p2p/webrtc/ICEManager.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/ICEManager.js +490 -0
- package/dist/edge/p2p/webrtc/ICEManager.js.map +1 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.d.ts +159 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.js +735 -0
- package/dist/edge/p2p/webrtc/PeerConnectionManager.js.map +1 -0
- package/dist/edge/p2p/webrtc/SignalingClient.d.ts +191 -0
- package/dist/edge/p2p/webrtc/SignalingClient.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/SignalingClient.js +608 -0
- package/dist/edge/p2p/webrtc/SignalingClient.js.map +1 -0
- package/dist/edge/p2p/webrtc/index.d.ts +158 -0
- package/dist/edge/p2p/webrtc/index.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/index.js +164 -0
- package/dist/edge/p2p/webrtc/index.js.map +1 -0
- package/dist/edge/p2p/webrtc/types.d.ts +665 -0
- package/dist/edge/p2p/webrtc/types.d.ts.map +1 -0
- package/dist/edge/p2p/webrtc/types.js +245 -0
- package/dist/edge/p2p/webrtc/types.js.map +1 -0
- package/dist/edge/server/AgentSpawnAPI.d.ts +98 -0
- package/dist/edge/server/AgentSpawnAPI.d.ts.map +1 -0
- package/dist/edge/server/AgentSpawnAPI.js +264 -0
- package/dist/edge/server/AgentSpawnAPI.js.map +1 -0
- package/dist/edge/server/SignalingServer.d.ts +71 -0
- package/dist/edge/server/SignalingServer.d.ts.map +1 -0
- package/dist/edge/server/SignalingServer.js +429 -0
- package/dist/edge/server/SignalingServer.js.map +1 -0
- package/dist/edge/server/index.d.ts +64 -0
- package/dist/edge/server/index.d.ts.map +1 -0
- package/dist/edge/server/index.js +318 -0
- package/dist/edge/server/index.js.map +1 -0
- package/dist/edge/types/browser-agent.types.d.ts +455 -0
- package/dist/edge/types/browser-agent.types.d.ts.map +1 -0
- package/dist/edge/types/browser-agent.types.js +116 -0
- package/dist/edge/types/browser-agent.types.js.map +1 -0
- package/dist/edge/types/index.d.ts +11 -0
- package/dist/edge/types/index.d.ts.map +1 -0
- package/dist/edge/types/index.js +17 -0
- package/dist/edge/types/index.js.map +1 -0
- package/dist/edge/types/storage.types.d.ts +207 -0
- package/dist/edge/types/storage.types.d.ts.map +1 -0
- package/dist/edge/types/storage.types.js +47 -0
- package/dist/edge/types/storage.types.js.map +1 -0
- package/dist/edge/wasm/shims.d.ts +224 -0
- package/dist/edge/wasm/shims.d.ts.map +1 -0
- package/dist/edge/wasm/shims.js +667 -0
- package/dist/edge/wasm/shims.js.map +1 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.d.ts +33 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.d.ts.map +1 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.js +305 -0
- package/dist/mcp/handlers/NewDomainToolsHandler.js.map +1 -0
- package/dist/mcp/handlers/filtered/index.d.ts +15 -19
- package/dist/mcp/handlers/filtered/index.d.ts.map +1 -1
- package/dist/mcp/handlers/filtered/index.js +16 -27
- package/dist/mcp/handlers/filtered/index.js.map +1 -1
- package/dist/mcp/handlers/integration/index.d.ts +5 -4
- package/dist/mcp/handlers/integration/index.d.ts.map +1 -1
- package/dist/mcp/handlers/integration/index.js +7 -7
- package/dist/mcp/handlers/integration/index.js.map +1 -1
- package/dist/mcp/server-instructions.d.ts +1 -1
- package/dist/mcp/server-instructions.js +1 -1
- package/dist/mcp/server.d.ts.map +1 -1
- package/dist/mcp/server.js +14 -0
- package/dist/mcp/server.js.map +1 -1
- package/dist/mcp/tools.d.ts +8 -0
- package/dist/mcp/tools.d.ts.map +1 -1
- package/dist/mcp/tools.js +412 -1
- package/dist/mcp/tools.js.map +1 -1
- package/dist/planning/GOAPPlanner.d.ts +1 -0
- package/dist/planning/GOAPPlanner.d.ts.map +1 -1
- package/dist/planning/GOAPPlanner.js +12 -0
- package/dist/planning/GOAPPlanner.js.map +1 -1
- package/package.json +29 -8
- package/dist/alerting/AlertManager.d.ts +0 -120
- package/dist/alerting/AlertManager.d.ts.map +0 -1
- package/dist/alerting/AlertManager.js +0 -345
- package/dist/alerting/AlertManager.js.map +0 -1
- package/dist/alerting/FeedbackRouter.d.ts +0 -98
- package/dist/alerting/FeedbackRouter.d.ts.map +0 -1
- package/dist/alerting/FeedbackRouter.js +0 -331
- package/dist/alerting/FeedbackRouter.js.map +0 -1
- package/dist/alerting/StrategyApplicator.d.ts +0 -120
- package/dist/alerting/StrategyApplicator.d.ts.map +0 -1
- package/dist/alerting/StrategyApplicator.js +0 -299
- package/dist/alerting/StrategyApplicator.js.map +0 -1
- package/dist/alerting/index.d.ts +0 -68
- package/dist/alerting/index.d.ts.map +0 -1
- package/dist/alerting/index.js +0 -112
- package/dist/alerting/index.js.map +0 -1
- package/dist/alerting/types.d.ts +0 -118
- package/dist/alerting/types.d.ts.map +0 -1
- package/dist/alerting/types.js +0 -11
- package/dist/alerting/types.js.map +0 -1
- package/dist/cli/commands/fleet/backup.d.ts +0 -49
- package/dist/cli/commands/fleet/backup.d.ts.map +0 -1
- package/dist/cli/commands/fleet/backup.js +0 -88
- package/dist/cli/commands/fleet/backup.js.map +0 -1
- package/dist/cli/commands/fleet/health.d.ts +0 -154
- package/dist/cli/commands/fleet/health.d.ts.map +0 -1
- package/dist/cli/commands/fleet/health.js +0 -483
- package/dist/cli/commands/fleet/health.js.map +0 -1
- package/dist/cli/commands/fleet/init.d.ts +0 -11
- package/dist/cli/commands/fleet/init.d.ts.map +0 -1
- package/dist/cli/commands/fleet/init.js +0 -91
- package/dist/cli/commands/fleet/init.js.map +0 -1
- package/dist/cli/commands/fleet/logs.d.ts +0 -21
- package/dist/cli/commands/fleet/logs.d.ts.map +0 -1
- package/dist/cli/commands/fleet/logs.js +0 -267
- package/dist/cli/commands/fleet/logs.js.map +0 -1
- package/dist/cli/commands/fleet/metrics.d.ts +0 -27
- package/dist/cli/commands/fleet/metrics.d.ts.map +0 -1
- package/dist/cli/commands/fleet/metrics.js +0 -369
- package/dist/cli/commands/fleet/metrics.js.map +0 -1
- package/dist/cli/commands/fleet/monitor.d.ts +0 -18
- package/dist/cli/commands/fleet/monitor.d.ts.map +0 -1
- package/dist/cli/commands/fleet/monitor.js +0 -237
- package/dist/cli/commands/fleet/monitor.js.map +0 -1
- package/dist/cli/commands/fleet/optimize.d.ts +0 -42
- package/dist/cli/commands/fleet/optimize.d.ts.map +0 -1
- package/dist/cli/commands/fleet/optimize.js +0 -135
- package/dist/cli/commands/fleet/optimize.js.map +0 -1
- package/dist/cli/commands/fleet/recover.d.ts +0 -22
- package/dist/cli/commands/fleet/recover.d.ts.map +0 -1
- package/dist/cli/commands/fleet/recover.js +0 -99
- package/dist/cli/commands/fleet/recover.js.map +0 -1
- package/dist/cli/commands/fleet/restart.d.ts +0 -18
- package/dist/cli/commands/fleet/restart.d.ts.map +0 -1
- package/dist/cli/commands/fleet/restart.js +0 -290
- package/dist/cli/commands/fleet/restart.js.map +0 -1
- package/dist/cli/commands/fleet/scale.d.ts +0 -9
- package/dist/cli/commands/fleet/scale.d.ts.map +0 -1
- package/dist/cli/commands/fleet/scale.js +0 -77
- package/dist/cli/commands/fleet/scale.js.map +0 -1
- package/dist/cli/commands/fleet/shutdown.d.ts +0 -19
- package/dist/cli/commands/fleet/shutdown.d.ts.map +0 -1
- package/dist/cli/commands/fleet/shutdown.js +0 -307
- package/dist/cli/commands/fleet/shutdown.js.map +0 -1
- package/dist/cli/commands/fleet/status.d.ts +0 -10
- package/dist/cli/commands/fleet/status.d.ts.map +0 -1
- package/dist/cli/commands/fleet/status.js +0 -97
- package/dist/cli/commands/fleet/status.js.map +0 -1
- package/dist/cli/commands/fleet/topology.d.ts +0 -23
- package/dist/cli/commands/fleet/topology.d.ts.map +0 -1
- package/dist/cli/commands/fleet/topology.js +0 -376
- package/dist/cli/commands/fleet/topology.js.map +0 -1
- package/dist/cli/commands/monitor/alerts.d.ts +0 -45
- package/dist/cli/commands/monitor/alerts.d.ts.map +0 -1
- package/dist/cli/commands/monitor/alerts.js +0 -168
- package/dist/cli/commands/monitor/alerts.js.map +0 -1
- package/dist/cli/commands/monitor/analyze.d.ts +0 -49
- package/dist/cli/commands/monitor/analyze.d.ts.map +0 -1
- package/dist/cli/commands/monitor/analyze.js +0 -209
- package/dist/cli/commands/monitor/analyze.js.map +0 -1
- package/dist/cli/commands/monitor/compare.d.ts +0 -38
- package/dist/cli/commands/monitor/compare.d.ts.map +0 -1
- package/dist/cli/commands/monitor/compare.js +0 -177
- package/dist/cli/commands/monitor/compare.js.map +0 -1
- package/dist/cli/commands/monitor/dashboard.d.ts +0 -34
- package/dist/cli/commands/monitor/dashboard.d.ts.map +0 -1
- package/dist/cli/commands/monitor/dashboard.js +0 -157
- package/dist/cli/commands/monitor/dashboard.js.map +0 -1
- package/dist/cli/commands/monitor/export.d.ts +0 -36
- package/dist/cli/commands/monitor/export.d.ts.map +0 -1
- package/dist/cli/commands/monitor/export.js +0 -157
- package/dist/cli/commands/monitor/export.js.map +0 -1
- package/dist/cli/commands/monitor/index.d.ts +0 -11
- package/dist/cli/commands/monitor/index.d.ts.map +0 -1
- package/dist/cli/commands/monitor/index.js +0 -14
- package/dist/cli/commands/monitor/index.js.map +0 -1
- package/dist/cli/commands/quality/baseline.d.ts +0 -27
- package/dist/cli/commands/quality/baseline.d.ts.map +0 -1
- package/dist/cli/commands/quality/baseline.js +0 -124
- package/dist/cli/commands/quality/baseline.js.map +0 -1
- package/dist/cli/commands/quality/compare.d.ts +0 -36
- package/dist/cli/commands/quality/compare.d.ts.map +0 -1
- package/dist/cli/commands/quality/compare.js +0 -136
- package/dist/cli/commands/quality/compare.js.map +0 -1
- package/dist/cli/commands/quality/decision.d.ts +0 -81
- package/dist/cli/commands/quality/decision.d.ts.map +0 -1
- package/dist/cli/commands/quality/decision.js +0 -319
- package/dist/cli/commands/quality/decision.js.map +0 -1
- package/dist/cli/commands/quality/gate.d.ts +0 -47
- package/dist/cli/commands/quality/gate.d.ts.map +0 -1
- package/dist/cli/commands/quality/gate.js +0 -205
- package/dist/cli/commands/quality/gate.js.map +0 -1
- package/dist/cli/commands/quality/index.d.ts +0 -17
- package/dist/cli/commands/quality/index.d.ts.map +0 -1
- package/dist/cli/commands/quality/index.js +0 -41
- package/dist/cli/commands/quality/index.js.map +0 -1
- package/dist/cli/commands/quality/policy.d.ts +0 -57
- package/dist/cli/commands/quality/policy.d.ts.map +0 -1
- package/dist/cli/commands/quality/policy.js +0 -359
- package/dist/cli/commands/quality/policy.js.map +0 -1
- package/dist/cli/commands/quality/risk.d.ts +0 -41
- package/dist/cli/commands/quality/risk.d.ts.map +0 -1
- package/dist/cli/commands/quality/risk.js +0 -255
- package/dist/cli/commands/quality/risk.js.map +0 -1
- package/dist/cli/commands/quality/trends.d.ts +0 -40
- package/dist/cli/commands/quality/trends.d.ts.map +0 -1
- package/dist/cli/commands/quality/trends.js +0 -122
- package/dist/cli/commands/quality/trends.js.map +0 -1
- package/dist/cli/commands/quality/validate.d.ts +0 -44
- package/dist/cli/commands/quality/validate.d.ts.map +0 -1
- package/dist/cli/commands/quality/validate.js +0 -234
- package/dist/cli/commands/quality/validate.js.map +0 -1
- package/dist/cli/commands/test/analyze-failures.d.ts +0 -39
- package/dist/cli/commands/test/analyze-failures.d.ts.map +0 -1
- package/dist/cli/commands/test/analyze-failures.js +0 -113
- package/dist/cli/commands/test/analyze-failures.js.map +0 -1
- package/dist/cli/commands/test/clean.d.ts +0 -3
- package/dist/cli/commands/test/clean.d.ts.map +0 -1
- package/dist/cli/commands/test/clean.js +0 -148
- package/dist/cli/commands/test/clean.js.map +0 -1
- package/dist/cli/commands/test/debug.d.ts +0 -3
- package/dist/cli/commands/test/debug.d.ts.map +0 -1
- package/dist/cli/commands/test/debug.js +0 -167
- package/dist/cli/commands/test/debug.js.map +0 -1
- package/dist/cli/commands/test/diff.d.ts +0 -3
- package/dist/cli/commands/test/diff.d.ts.map +0 -1
- package/dist/cli/commands/test/diff.js +0 -195
- package/dist/cli/commands/test/diff.js.map +0 -1
- package/dist/cli/commands/test/flakiness.d.ts +0 -32
- package/dist/cli/commands/test/flakiness.d.ts.map +0 -1
- package/dist/cli/commands/test/flakiness.js +0 -121
- package/dist/cli/commands/test/flakiness.js.map +0 -1
- package/dist/cli/commands/test/index.d.ts +0 -17
- package/dist/cli/commands/test/index.d.ts.map +0 -1
- package/dist/cli/commands/test/index.js +0 -45
- package/dist/cli/commands/test/index.js.map +0 -1
- package/dist/cli/commands/test/mutate.d.ts +0 -29
- package/dist/cli/commands/test/mutate.d.ts.map +0 -1
- package/dist/cli/commands/test/mutate.js +0 -163
- package/dist/cli/commands/test/mutate.js.map +0 -1
- package/dist/cli/commands/test/parallel.d.ts +0 -3
- package/dist/cli/commands/test/parallel.d.ts.map +0 -1
- package/dist/cli/commands/test/parallel.js +0 -117
- package/dist/cli/commands/test/parallel.js.map +0 -1
- package/dist/cli/commands/test/profile.d.ts +0 -3
- package/dist/cli/commands/test/profile.d.ts.map +0 -1
- package/dist/cli/commands/test/profile.js +0 -156
- package/dist/cli/commands/test/profile.js.map +0 -1
- package/dist/cli/commands/test/queue.d.ts +0 -3
- package/dist/cli/commands/test/queue.d.ts.map +0 -1
- package/dist/cli/commands/test/queue.js +0 -140
- package/dist/cli/commands/test/queue.js.map +0 -1
- package/dist/cli/commands/test/retry.d.ts +0 -3
- package/dist/cli/commands/test/retry.d.ts.map +0 -1
- package/dist/cli/commands/test/retry.js +0 -105
- package/dist/cli/commands/test/retry.js.map +0 -1
- package/dist/cli/commands/test/snapshot.d.ts +0 -3
- package/dist/cli/commands/test/snapshot.d.ts.map +0 -1
- package/dist/cli/commands/test/snapshot.js +0 -176
- package/dist/cli/commands/test/snapshot.js.map +0 -1
- package/dist/cli/commands/test/trace.d.ts +0 -3
- package/dist/cli/commands/test/trace.d.ts.map +0 -1
- package/dist/cli/commands/test/trace.js +0 -137
- package/dist/cli/commands/test/trace.js.map +0 -1
- package/dist/cli/commands/test/watch.d.ts +0 -3
- package/dist/cli/commands/test/watch.d.ts.map +0 -1
- package/dist/cli/commands/test/watch.js +0 -130
- package/dist/cli/commands/test/watch.js.map +0 -1
- package/dist/cli/index-spec.d.ts +0 -3
- package/dist/cli/index-spec.d.ts.map +0 -1
- package/dist/cli/index-spec.js +0 -154
- package/dist/cli/index-spec.js.map +0 -1
- package/dist/cli/index-working.d.ts +0 -7
- package/dist/cli/index-working.d.ts.map +0 -1
- package/dist/cli/index-working.js +0 -617
- package/dist/cli/index-working.js.map +0 -1
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.d.ts +0 -83
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.d.ts.map +0 -1
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.js +0 -130
- package/dist/mcp/handlers/filtered/coverage-analyzer-filtered.js.map +0 -1
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.d.ts +0 -58
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.d.ts.map +0 -1
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.js +0 -84
- package/dist/mcp/handlers/filtered/flaky-detector-filtered.js.map +0 -1
- package/dist/mcp/handlers/filtered/security-scanner-filtered.d.ts +0 -54
- package/dist/mcp/handlers/filtered/security-scanner-filtered.d.ts.map +0 -1
- package/dist/mcp/handlers/filtered/security-scanner-filtered.js +0 -73
- package/dist/mcp/handlers/filtered/security-scanner-filtered.js.map +0 -1
- package/dist/mcp/handlers/integration/contract-validate.d.ts +0 -10
- package/dist/mcp/handlers/integration/contract-validate.d.ts.map +0 -1
- package/dist/mcp/handlers/integration/contract-validate.js +0 -348
- package/dist/mcp/handlers/integration/contract-validate.js.map +0 -1
- package/dist/reporting/ResultAggregator.d.ts +0 -107
- package/dist/reporting/ResultAggregator.d.ts.map +0 -1
- package/dist/reporting/ResultAggregator.js +0 -435
- package/dist/reporting/ResultAggregator.js.map +0 -1
- package/dist/reporting/index.d.ts +0 -48
- package/dist/reporting/index.d.ts.map +0 -1
- package/dist/reporting/index.js +0 -154
- package/dist/reporting/index.js.map +0 -1
- package/dist/reporting/reporters/ControlLoopReporter.d.ts +0 -128
- package/dist/reporting/reporters/ControlLoopReporter.d.ts.map +0 -1
- package/dist/reporting/reporters/ControlLoopReporter.js +0 -417
- package/dist/reporting/reporters/ControlLoopReporter.js.map +0 -1
- package/dist/reporting/reporters/HumanReadableReporter.d.ts +0 -140
- package/dist/reporting/reporters/HumanReadableReporter.d.ts.map +0 -1
- package/dist/reporting/reporters/HumanReadableReporter.js +0 -524
- package/dist/reporting/reporters/HumanReadableReporter.js.map +0 -1
- package/dist/reporting/reporters/JSONReporter.d.ts +0 -251
- package/dist/reporting/reporters/JSONReporter.d.ts.map +0 -1
- package/dist/reporting/reporters/JSONReporter.js +0 -325
- package/dist/reporting/reporters/JSONReporter.js.map +0 -1
- package/dist/reporting/reporters/index.d.ts +0 -14
- package/dist/reporting/reporters/index.d.ts.map +0 -1
- package/dist/reporting/reporters/index.js +0 -19
- package/dist/reporting/reporters/index.js.map +0 -1
- package/dist/reporting/types.d.ts +0 -427
- package/dist/reporting/types.d.ts.map +0 -1
- package/dist/reporting/types.js +0 -12
- package/dist/reporting/types.js.map +0 -1
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TURN Manager for @ruvector/edge P2P
|
|
3
|
+
*
|
|
4
|
+
* Manages TURN server credentials, handles credential refresh, selects optimal
|
|
5
|
+
* TURN servers based on latency, and monitors server health.
|
|
6
|
+
*
|
|
7
|
+
* @module edge/p2p/nat/TURNManager
|
|
8
|
+
* @version 1.0.0
|
|
9
|
+
*/
|
|
10
|
+
import { ICEServer } from '../webrtc/types';
|
|
11
|
+
import { TURNConfig, TURNServerSelection, TURNManagerConfig, NATEventType, NATEventHandler } from './types';
|
|
12
|
+
/**
|
|
13
|
+
* TURN server health status
|
|
14
|
+
*/
|
|
15
|
+
interface TURNServerHealth {
|
|
16
|
+
/** Server configuration */
|
|
17
|
+
server: TURNConfig;
|
|
18
|
+
/** Whether server is healthy */
|
|
19
|
+
healthy: boolean;
|
|
20
|
+
/** Last measured latency in ms */
|
|
21
|
+
latencyMs: number;
|
|
22
|
+
/** Last health check timestamp */
|
|
23
|
+
lastCheckAt: number;
|
|
24
|
+
/** Consecutive failure count */
|
|
25
|
+
failureCount: number;
|
|
26
|
+
/** Last error message */
|
|
27
|
+
lastError?: string;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* TURN Manager - Manages TURN server credentials and selection
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```typescript
|
|
34
|
+
* const turnManager = new TURNManager({
|
|
35
|
+
* servers: [
|
|
36
|
+
* {
|
|
37
|
+
* urls: 'turn:turn1.example.com:3478',
|
|
38
|
+
* username: 'user',
|
|
39
|
+
* credential: 'pass',
|
|
40
|
+
* credentialType: 'password',
|
|
41
|
+
* },
|
|
42
|
+
* ],
|
|
43
|
+
* credentialConfig: {
|
|
44
|
+
* refreshUrl: 'https://api.example.com/turn/credentials',
|
|
45
|
+
* refreshBeforeExpiry: 300000, // 5 minutes
|
|
46
|
+
* maxRetries: 3,
|
|
47
|
+
* retryDelay: 1000,
|
|
48
|
+
* },
|
|
49
|
+
* });
|
|
50
|
+
*
|
|
51
|
+
* // Get optimal TURN server
|
|
52
|
+
* const selection = await turnManager.selectOptimalServer();
|
|
53
|
+
* console.log('Selected server:', selection.server.urls);
|
|
54
|
+
*
|
|
55
|
+
* // Get ICE servers for RTCPeerConnection
|
|
56
|
+
* const iceServers = turnManager.getICEServers();
|
|
57
|
+
* ```
|
|
58
|
+
*/
|
|
59
|
+
export declare class TURNManager {
|
|
60
|
+
private readonly config;
|
|
61
|
+
private serverHealth;
|
|
62
|
+
private credentialStates;
|
|
63
|
+
private eventHandlers;
|
|
64
|
+
private healthCheckInterval?;
|
|
65
|
+
private isDestroyed;
|
|
66
|
+
/**
|
|
67
|
+
* Create a new TURN Manager
|
|
68
|
+
*
|
|
69
|
+
* @param config - Manager configuration
|
|
70
|
+
*/
|
|
71
|
+
constructor(config: TURNManagerConfig);
|
|
72
|
+
/**
|
|
73
|
+
* Select optimal TURN server based on latency
|
|
74
|
+
*
|
|
75
|
+
* @returns Promise resolving to server selection with alternatives
|
|
76
|
+
*/
|
|
77
|
+
selectOptimalServer(): Promise<TURNServerSelection>;
|
|
78
|
+
/**
|
|
79
|
+
* Get ICE servers configuration for RTCPeerConnection
|
|
80
|
+
*
|
|
81
|
+
* @param includeUnhealthy - Include unhealthy servers (default: false)
|
|
82
|
+
* @returns Array of ICE server configurations
|
|
83
|
+
*/
|
|
84
|
+
getICEServers(includeUnhealthy?: boolean): ICEServer[];
|
|
85
|
+
/**
|
|
86
|
+
* Get a specific server's current credentials
|
|
87
|
+
*
|
|
88
|
+
* @param serverUrl - Server URL to get credentials for
|
|
89
|
+
* @returns Server configuration with current credentials or null
|
|
90
|
+
*/
|
|
91
|
+
getServerCredentials(serverUrl: string): TURNConfig | null;
|
|
92
|
+
/**
|
|
93
|
+
* Manually refresh credentials for a server
|
|
94
|
+
*
|
|
95
|
+
* @param serverUrl - Server URL to refresh credentials for
|
|
96
|
+
* @returns Promise resolving to refreshed credentials
|
|
97
|
+
*/
|
|
98
|
+
refreshCredentials(serverUrl: string): Promise<TURNConfig>;
|
|
99
|
+
/**
|
|
100
|
+
* Add a new TURN server to the manager
|
|
101
|
+
*
|
|
102
|
+
* @param server - Server configuration to add
|
|
103
|
+
*/
|
|
104
|
+
addServer(server: TURNConfig): void;
|
|
105
|
+
/**
|
|
106
|
+
* Remove a TURN server from the manager
|
|
107
|
+
*
|
|
108
|
+
* @param serverUrl - Server URL to remove
|
|
109
|
+
*/
|
|
110
|
+
removeServer(serverUrl: string): void;
|
|
111
|
+
/**
|
|
112
|
+
* Get server health status
|
|
113
|
+
*
|
|
114
|
+
* @param serverUrl - Server URL to check
|
|
115
|
+
* @returns Health status or null if not found
|
|
116
|
+
*/
|
|
117
|
+
getServerHealth(serverUrl: string): TURNServerHealth | null;
|
|
118
|
+
/**
|
|
119
|
+
* Get all server health statuses
|
|
120
|
+
*
|
|
121
|
+
* @returns Map of server URLs to health statuses
|
|
122
|
+
*/
|
|
123
|
+
getAllServerHealth(): Map<string, TURNServerHealth>;
|
|
124
|
+
/**
|
|
125
|
+
* Force health check for all servers
|
|
126
|
+
*/
|
|
127
|
+
checkAllServersHealth(): Promise<void>;
|
|
128
|
+
/**
|
|
129
|
+
* Register event handler
|
|
130
|
+
*
|
|
131
|
+
* @param type - Event type to handle
|
|
132
|
+
* @param handler - Event handler function
|
|
133
|
+
* @returns Unsubscribe function
|
|
134
|
+
*/
|
|
135
|
+
on<T>(type: NATEventType, handler: NATEventHandler<T>): () => void;
|
|
136
|
+
/**
|
|
137
|
+
* Get current configuration
|
|
138
|
+
*/
|
|
139
|
+
getConfig(): TURNManagerConfig;
|
|
140
|
+
/**
|
|
141
|
+
* Destroy the manager and cleanup resources
|
|
142
|
+
*/
|
|
143
|
+
destroy(): void;
|
|
144
|
+
private getServerUrl;
|
|
145
|
+
private getHealthyServers;
|
|
146
|
+
private testServerLatencies;
|
|
147
|
+
private measureLatency;
|
|
148
|
+
private testTurnConnectivity;
|
|
149
|
+
private checkServerHealth;
|
|
150
|
+
private startHealthMonitoring;
|
|
151
|
+
private scheduleCredentialRefresh;
|
|
152
|
+
private fetchNewCredentials;
|
|
153
|
+
private doCredentialFetch;
|
|
154
|
+
private delay;
|
|
155
|
+
private emitEvent;
|
|
156
|
+
}
|
|
157
|
+
export default TURNManager;
|
|
158
|
+
//# sourceMappingURL=TURNManager.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TURNManager.d.ts","sourceRoot":"","sources":["../../../../src/edge/p2p/nat/TURNManager.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EACL,UAAU,EAGV,mBAAmB,EACnB,iBAAiB,EACjB,YAAY,EAEZ,eAAe,EAEhB,MAAM,SAAS,CAAC;AAEjB;;GAEG;AACH,UAAU,gBAAgB;IACxB,2BAA2B;IAC3B,MAAM,EAAE,UAAU,CAAC;IACnB,gCAAgC;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,kCAAkC;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,kCAAkC;IAClC,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,YAAY,EAAE,MAAM,CAAC;IACrB,yBAAyB;IACzB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAgBD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAoB;IAC3C,OAAO,CAAC,YAAY,CAA4C;IAChE,OAAO,CAAC,gBAAgB,CAA2C;IACnE,OAAO,CAAC,aAAa,CAAsD;IAC3E,OAAO,CAAC,mBAAmB,CAAC,CAAiC;IAC7D,OAAO,CAAC,WAAW,CAAkB;IAErC;;;;OAIG;gBACS,MAAM,EAAE,iBAAiB;IAqCrC;;;;OAIG;IACU,mBAAmB,IAAI,OAAO,CAAC,mBAAmB,CAAC;IAwBhE;;;;;OAKG;IACI,aAAa,CAAC,gBAAgB,GAAE,OAAe,GAAG,SAAS,EAAE;IAapE;;;;;OAKG;IACI,oBAAoB,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,GAAG,IAAI;IAKjE;;;;;OAKG;IACU,kBAAkB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAavE;;;;OAIG;IACI,SAAS,CAAC,MAAM,EAAE,UAAU,GAAG,IAAI;IA0B1C;;;;OAIG;IACI,YAAY,CAAC,SAAS,EAAE,MAAM,GAAG,IAAI;IAkB5C;;;;;OAKG;IACI,eAAe,CAAC,SAAS,EAAE,MAAM,GAAG,gBAAgB,GAAG,IAAI;IAIlE;;;;OAIG;IACI,kBAAkB,IAAI,GAAG,CAAC,MAAM,EAAE,gBAAgB,CAAC;IAI1D;;OAEG;IACU,qBAAqB,IAAI,OAAO,CAAC,IAAI,CAAC;IAKnD;;;;;;OAMG;IACI,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,YAAY,EAAE,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAAG,MAAM,IAAI;IAQzE;;OAEG;IACI,SAAS,IAAI,iBAAiB;IAIrC;;OAEG;IACI,OAAO,IAAI,IAAI;IAyBtB,OAAO,CAAC,YAAY;IAIpB,OAAO,CAAC,iBAAiB;YAUX,mBAAmB;YA2BnB,cAAc;YAWd,oBAAoB;YAwEpB,iBAAiB;IA4B/B,OAAO,CAAC,qBAAqB;IAU7B,OAAO,CAAC,yBAAyB;YA6BnB,mBAAmB;YA2EnB,iBAAiB;IA2C/B,OAAO,CAAC,KAAK;IAIb,OAAO,CAAC,SAAS;CAiBlB;AAED,eAAe,WAAW,CAAC"}
|
|
@@ -0,0 +1,547 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* TURN Manager for @ruvector/edge P2P
|
|
4
|
+
*
|
|
5
|
+
* Manages TURN server credentials, handles credential refresh, selects optimal
|
|
6
|
+
* TURN servers based on latency, and monitors server health.
|
|
7
|
+
*
|
|
8
|
+
* @module edge/p2p/nat/TURNManager
|
|
9
|
+
* @version 1.0.0
|
|
10
|
+
*/
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.TURNManager = void 0;
|
|
13
|
+
const types_1 = require("./types");
|
|
14
|
+
/**
|
|
15
|
+
* TURN Manager - Manages TURN server credentials and selection
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* const turnManager = new TURNManager({
|
|
20
|
+
* servers: [
|
|
21
|
+
* {
|
|
22
|
+
* urls: 'turn:turn1.example.com:3478',
|
|
23
|
+
* username: 'user',
|
|
24
|
+
* credential: 'pass',
|
|
25
|
+
* credentialType: 'password',
|
|
26
|
+
* },
|
|
27
|
+
* ],
|
|
28
|
+
* credentialConfig: {
|
|
29
|
+
* refreshUrl: 'https://api.example.com/turn/credentials',
|
|
30
|
+
* refreshBeforeExpiry: 300000, // 5 minutes
|
|
31
|
+
* maxRetries: 3,
|
|
32
|
+
* retryDelay: 1000,
|
|
33
|
+
* },
|
|
34
|
+
* });
|
|
35
|
+
*
|
|
36
|
+
* // Get optimal TURN server
|
|
37
|
+
* const selection = await turnManager.selectOptimalServer();
|
|
38
|
+
* console.log('Selected server:', selection.server.urls);
|
|
39
|
+
*
|
|
40
|
+
* // Get ICE servers for RTCPeerConnection
|
|
41
|
+
* const iceServers = turnManager.getICEServers();
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
44
|
+
class TURNManager {
|
|
45
|
+
/**
|
|
46
|
+
* Create a new TURN Manager
|
|
47
|
+
*
|
|
48
|
+
* @param config - Manager configuration
|
|
49
|
+
*/
|
|
50
|
+
constructor(config) {
|
|
51
|
+
this.serverHealth = new Map();
|
|
52
|
+
this.credentialStates = new Map();
|
|
53
|
+
this.eventHandlers = new Map();
|
|
54
|
+
this.isDestroyed = false;
|
|
55
|
+
this.config = {
|
|
56
|
+
...types_1.DEFAULT_TURN_MANAGER_CONFIG,
|
|
57
|
+
...config,
|
|
58
|
+
};
|
|
59
|
+
// Initialize server health tracking
|
|
60
|
+
for (const server of this.config.servers) {
|
|
61
|
+
const url = this.getServerUrl(server);
|
|
62
|
+
this.serverHealth.set(url, {
|
|
63
|
+
server,
|
|
64
|
+
healthy: true, // Assume healthy until proven otherwise
|
|
65
|
+
latencyMs: Infinity,
|
|
66
|
+
lastCheckAt: 0,
|
|
67
|
+
failureCount: 0,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
// Initialize credential states
|
|
71
|
+
for (const server of this.config.servers) {
|
|
72
|
+
if (server.expiresAt) {
|
|
73
|
+
const url = this.getServerUrl(server);
|
|
74
|
+
this.credentialStates.set(url, {
|
|
75
|
+
credentials: server,
|
|
76
|
+
fetchedAt: Date.now(),
|
|
77
|
+
refreshing: false,
|
|
78
|
+
});
|
|
79
|
+
this.scheduleCredentialRefresh(server);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
// Start health monitoring if enabled
|
|
83
|
+
if (this.config.enableHealthMonitoring) {
|
|
84
|
+
this.startHealthMonitoring();
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Select optimal TURN server based on latency
|
|
89
|
+
*
|
|
90
|
+
* @returns Promise resolving to server selection with alternatives
|
|
91
|
+
*/
|
|
92
|
+
async selectOptimalServer() {
|
|
93
|
+
const healthyServers = this.getHealthyServers();
|
|
94
|
+
if (healthyServers.length === 0) {
|
|
95
|
+
throw new Error('No healthy TURN servers available');
|
|
96
|
+
}
|
|
97
|
+
// Test latency to all healthy servers
|
|
98
|
+
const latencyResults = await this.testServerLatencies(healthyServers);
|
|
99
|
+
// Sort by latency
|
|
100
|
+
latencyResults.sort((a, b) => a.latencyMs - b.latencyMs);
|
|
101
|
+
const optimal = latencyResults[0];
|
|
102
|
+
const alternatives = latencyResults.slice(1);
|
|
103
|
+
return {
|
|
104
|
+
server: optimal.server,
|
|
105
|
+
latencyMs: optimal.latencyMs,
|
|
106
|
+
selectedAt: Date.now(),
|
|
107
|
+
alternatives,
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Get ICE servers configuration for RTCPeerConnection
|
|
112
|
+
*
|
|
113
|
+
* @param includeUnhealthy - Include unhealthy servers (default: false)
|
|
114
|
+
* @returns Array of ICE server configurations
|
|
115
|
+
*/
|
|
116
|
+
getICEServers(includeUnhealthy = false) {
|
|
117
|
+
const servers = includeUnhealthy
|
|
118
|
+
? this.config.servers
|
|
119
|
+
: this.getHealthyServers();
|
|
120
|
+
return servers.map((server) => ({
|
|
121
|
+
urls: server.urls,
|
|
122
|
+
username: server.username,
|
|
123
|
+
credential: server.credential,
|
|
124
|
+
credentialType: server.credentialType,
|
|
125
|
+
}));
|
|
126
|
+
}
|
|
127
|
+
/**
|
|
128
|
+
* Get a specific server's current credentials
|
|
129
|
+
*
|
|
130
|
+
* @param serverUrl - Server URL to get credentials for
|
|
131
|
+
* @returns Server configuration with current credentials or null
|
|
132
|
+
*/
|
|
133
|
+
getServerCredentials(serverUrl) {
|
|
134
|
+
const state = this.credentialStates.get(serverUrl);
|
|
135
|
+
return state?.credentials ?? null;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Manually refresh credentials for a server
|
|
139
|
+
*
|
|
140
|
+
* @param serverUrl - Server URL to refresh credentials for
|
|
141
|
+
* @returns Promise resolving to refreshed credentials
|
|
142
|
+
*/
|
|
143
|
+
async refreshCredentials(serverUrl) {
|
|
144
|
+
const state = this.credentialStates.get(serverUrl);
|
|
145
|
+
if (!state) {
|
|
146
|
+
throw new Error(`No credential state for server: ${serverUrl}`);
|
|
147
|
+
}
|
|
148
|
+
if (!this.config.credentialConfig) {
|
|
149
|
+
throw new Error('No credential refresh configuration');
|
|
150
|
+
}
|
|
151
|
+
return this.fetchNewCredentials(serverUrl);
|
|
152
|
+
}
|
|
153
|
+
/**
|
|
154
|
+
* Add a new TURN server to the manager
|
|
155
|
+
*
|
|
156
|
+
* @param server - Server configuration to add
|
|
157
|
+
*/
|
|
158
|
+
addServer(server) {
|
|
159
|
+
const url = this.getServerUrl(server);
|
|
160
|
+
if (this.serverHealth.has(url)) {
|
|
161
|
+
throw new Error(`Server already exists: ${url}`);
|
|
162
|
+
}
|
|
163
|
+
this.config.servers.push(server);
|
|
164
|
+
this.serverHealth.set(url, {
|
|
165
|
+
server,
|
|
166
|
+
healthy: true,
|
|
167
|
+
latencyMs: Infinity,
|
|
168
|
+
lastCheckAt: 0,
|
|
169
|
+
failureCount: 0,
|
|
170
|
+
});
|
|
171
|
+
if (server.expiresAt) {
|
|
172
|
+
this.credentialStates.set(url, {
|
|
173
|
+
credentials: server,
|
|
174
|
+
fetchedAt: Date.now(),
|
|
175
|
+
refreshing: false,
|
|
176
|
+
});
|
|
177
|
+
this.scheduleCredentialRefresh(server);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Remove a TURN server from the manager
|
|
182
|
+
*
|
|
183
|
+
* @param serverUrl - Server URL to remove
|
|
184
|
+
*/
|
|
185
|
+
removeServer(serverUrl) {
|
|
186
|
+
const index = this.config.servers.findIndex((s) => this.getServerUrl(s) === serverUrl);
|
|
187
|
+
if (index !== -1) {
|
|
188
|
+
this.config.servers.splice(index, 1);
|
|
189
|
+
}
|
|
190
|
+
this.serverHealth.delete(serverUrl);
|
|
191
|
+
const state = this.credentialStates.get(serverUrl);
|
|
192
|
+
if (state?.refreshTimer) {
|
|
193
|
+
clearTimeout(state.refreshTimer);
|
|
194
|
+
}
|
|
195
|
+
this.credentialStates.delete(serverUrl);
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Get server health status
|
|
199
|
+
*
|
|
200
|
+
* @param serverUrl - Server URL to check
|
|
201
|
+
* @returns Health status or null if not found
|
|
202
|
+
*/
|
|
203
|
+
getServerHealth(serverUrl) {
|
|
204
|
+
return this.serverHealth.get(serverUrl) ?? null;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Get all server health statuses
|
|
208
|
+
*
|
|
209
|
+
* @returns Map of server URLs to health statuses
|
|
210
|
+
*/
|
|
211
|
+
getAllServerHealth() {
|
|
212
|
+
return new Map(this.serverHealth);
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Force health check for all servers
|
|
216
|
+
*/
|
|
217
|
+
async checkAllServersHealth() {
|
|
218
|
+
const servers = Array.from(this.serverHealth.keys());
|
|
219
|
+
await Promise.all(servers.map((url) => this.checkServerHealth(url)));
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Register event handler
|
|
223
|
+
*
|
|
224
|
+
* @param type - Event type to handle
|
|
225
|
+
* @param handler - Event handler function
|
|
226
|
+
* @returns Unsubscribe function
|
|
227
|
+
*/
|
|
228
|
+
on(type, handler) {
|
|
229
|
+
if (!this.eventHandlers.has(type)) {
|
|
230
|
+
this.eventHandlers.set(type, new Set());
|
|
231
|
+
}
|
|
232
|
+
this.eventHandlers.get(type).add(handler);
|
|
233
|
+
return () => this.eventHandlers.get(type)?.delete(handler);
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Get current configuration
|
|
237
|
+
*/
|
|
238
|
+
getConfig() {
|
|
239
|
+
return { ...this.config };
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* Destroy the manager and cleanup resources
|
|
243
|
+
*/
|
|
244
|
+
destroy() {
|
|
245
|
+
this.isDestroyed = true;
|
|
246
|
+
// Stop health monitoring
|
|
247
|
+
if (this.healthCheckInterval) {
|
|
248
|
+
clearInterval(this.healthCheckInterval);
|
|
249
|
+
this.healthCheckInterval = undefined;
|
|
250
|
+
}
|
|
251
|
+
// Cancel all credential refresh timers
|
|
252
|
+
this.credentialStates.forEach((state) => {
|
|
253
|
+
if (state.refreshTimer) {
|
|
254
|
+
clearTimeout(state.refreshTimer);
|
|
255
|
+
}
|
|
256
|
+
});
|
|
257
|
+
this.credentialStates.clear();
|
|
258
|
+
this.serverHealth.clear();
|
|
259
|
+
this.eventHandlers.clear();
|
|
260
|
+
}
|
|
261
|
+
// ============================================
|
|
262
|
+
// Private Methods
|
|
263
|
+
// ============================================
|
|
264
|
+
getServerUrl(server) {
|
|
265
|
+
return Array.isArray(server.urls) ? server.urls[0] : server.urls;
|
|
266
|
+
}
|
|
267
|
+
getHealthyServers() {
|
|
268
|
+
const healthy = [];
|
|
269
|
+
this.serverHealth.forEach((health) => {
|
|
270
|
+
if (health.healthy) {
|
|
271
|
+
healthy.push(health.server);
|
|
272
|
+
}
|
|
273
|
+
});
|
|
274
|
+
return healthy;
|
|
275
|
+
}
|
|
276
|
+
async testServerLatencies(servers) {
|
|
277
|
+
const results = await Promise.all(servers.map(async (server) => {
|
|
278
|
+
const latencyMs = await this.measureLatency(server);
|
|
279
|
+
return { server, latencyMs };
|
|
280
|
+
}));
|
|
281
|
+
// Update health tracking with new latencies
|
|
282
|
+
for (const result of results) {
|
|
283
|
+
const url = this.getServerUrl(result.server);
|
|
284
|
+
const health = this.serverHealth.get(url);
|
|
285
|
+
if (health) {
|
|
286
|
+
health.latencyMs = result.latencyMs;
|
|
287
|
+
health.lastCheckAt = Date.now();
|
|
288
|
+
if (result.latencyMs < Infinity) {
|
|
289
|
+
health.failureCount = 0;
|
|
290
|
+
health.healthy = true;
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
return results;
|
|
295
|
+
}
|
|
296
|
+
async measureLatency(server) {
|
|
297
|
+
const startTime = performance.now();
|
|
298
|
+
try {
|
|
299
|
+
await this.testTurnConnectivity(server);
|
|
300
|
+
return performance.now() - startTime;
|
|
301
|
+
}
|
|
302
|
+
catch {
|
|
303
|
+
return Infinity;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
async testTurnConnectivity(server) {
|
|
307
|
+
return new Promise((resolve, reject) => {
|
|
308
|
+
if (typeof RTCPeerConnection === 'undefined') {
|
|
309
|
+
reject(new Error('RTCPeerConnection not available'));
|
|
310
|
+
return;
|
|
311
|
+
}
|
|
312
|
+
const iceServer = {
|
|
313
|
+
urls: server.urls,
|
|
314
|
+
username: server.username,
|
|
315
|
+
credential: server.credential,
|
|
316
|
+
};
|
|
317
|
+
const pc = new RTCPeerConnection({
|
|
318
|
+
iceServers: [iceServer],
|
|
319
|
+
iceTransportPolicy: 'relay', // Force TURN usage
|
|
320
|
+
});
|
|
321
|
+
let resolved = false;
|
|
322
|
+
const timeout = setTimeout(() => {
|
|
323
|
+
if (!resolved) {
|
|
324
|
+
resolved = true;
|
|
325
|
+
pc.close();
|
|
326
|
+
reject(new Error('TURN connectivity test timeout'));
|
|
327
|
+
}
|
|
328
|
+
}, this.config.latencyTestTimeout);
|
|
329
|
+
pc.onicecandidate = (event) => {
|
|
330
|
+
if (event.candidate && !resolved) {
|
|
331
|
+
const candidate = event.candidate.candidate;
|
|
332
|
+
// Look for relay candidate indicating TURN works
|
|
333
|
+
if (candidate.includes('typ relay')) {
|
|
334
|
+
resolved = true;
|
|
335
|
+
clearTimeout(timeout);
|
|
336
|
+
pc.close();
|
|
337
|
+
resolve();
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
else if (event.candidate === null && !resolved) {
|
|
341
|
+
// Gathering complete without relay candidate
|
|
342
|
+
resolved = true;
|
|
343
|
+
clearTimeout(timeout);
|
|
344
|
+
pc.close();
|
|
345
|
+
reject(new Error('No relay candidate from TURN server'));
|
|
346
|
+
}
|
|
347
|
+
};
|
|
348
|
+
pc.onicegatheringstatechange = () => {
|
|
349
|
+
if (pc.iceGatheringState === 'complete' && !resolved) {
|
|
350
|
+
resolved = true;
|
|
351
|
+
clearTimeout(timeout);
|
|
352
|
+
pc.close();
|
|
353
|
+
reject(new Error('ICE gathering complete without relay'));
|
|
354
|
+
}
|
|
355
|
+
};
|
|
356
|
+
// Create data channel to trigger ICE gathering
|
|
357
|
+
pc.createDataChannel('turn-test');
|
|
358
|
+
pc.createOffer()
|
|
359
|
+
.then((offer) => pc.setLocalDescription(offer))
|
|
360
|
+
.catch((error) => {
|
|
361
|
+
if (!resolved) {
|
|
362
|
+
resolved = true;
|
|
363
|
+
clearTimeout(timeout);
|
|
364
|
+
pc.close();
|
|
365
|
+
reject(error);
|
|
366
|
+
}
|
|
367
|
+
});
|
|
368
|
+
});
|
|
369
|
+
}
|
|
370
|
+
async checkServerHealth(serverUrl) {
|
|
371
|
+
const health = this.serverHealth.get(serverUrl);
|
|
372
|
+
if (!health)
|
|
373
|
+
return;
|
|
374
|
+
try {
|
|
375
|
+
const latencyMs = await this.measureLatency(health.server);
|
|
376
|
+
if (latencyMs < Infinity) {
|
|
377
|
+
health.healthy = true;
|
|
378
|
+
health.latencyMs = latencyMs;
|
|
379
|
+
health.failureCount = 0;
|
|
380
|
+
health.lastError = undefined;
|
|
381
|
+
}
|
|
382
|
+
else {
|
|
383
|
+
throw new Error('Latency measurement failed');
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
catch (error) {
|
|
387
|
+
health.failureCount++;
|
|
388
|
+
health.lastError = error instanceof Error ? error.message : 'Unknown error';
|
|
389
|
+
// Mark as unhealthy after 3 consecutive failures
|
|
390
|
+
if (health.failureCount >= 3) {
|
|
391
|
+
health.healthy = false;
|
|
392
|
+
}
|
|
393
|
+
}
|
|
394
|
+
health.lastCheckAt = Date.now();
|
|
395
|
+
}
|
|
396
|
+
startHealthMonitoring() {
|
|
397
|
+
if (this.healthCheckInterval)
|
|
398
|
+
return;
|
|
399
|
+
this.healthCheckInterval = setInterval(() => {
|
|
400
|
+
if (!this.isDestroyed) {
|
|
401
|
+
this.checkAllServersHealth();
|
|
402
|
+
}
|
|
403
|
+
}, this.config.healthCheckInterval);
|
|
404
|
+
}
|
|
405
|
+
scheduleCredentialRefresh(server) {
|
|
406
|
+
if (!this.config.credentialConfig || !server.expiresAt)
|
|
407
|
+
return;
|
|
408
|
+
const url = this.getServerUrl(server);
|
|
409
|
+
const state = this.credentialStates.get(url);
|
|
410
|
+
if (!state)
|
|
411
|
+
return;
|
|
412
|
+
// Cancel existing timer
|
|
413
|
+
if (state.refreshTimer) {
|
|
414
|
+
clearTimeout(state.refreshTimer);
|
|
415
|
+
}
|
|
416
|
+
const expiresIn = server.expiresAt - Date.now();
|
|
417
|
+
const refreshIn = Math.max(0, expiresIn - this.config.credentialConfig.refreshBeforeExpiry);
|
|
418
|
+
state.refreshTimer = setTimeout(async () => {
|
|
419
|
+
if (!this.isDestroyed) {
|
|
420
|
+
try {
|
|
421
|
+
await this.fetchNewCredentials(url);
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
console.error(`Failed to refresh credentials for ${url}:`, error);
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
}, refreshIn);
|
|
428
|
+
}
|
|
429
|
+
async fetchNewCredentials(serverUrl) {
|
|
430
|
+
if (!this.config.credentialConfig) {
|
|
431
|
+
throw new Error('No credential refresh configuration');
|
|
432
|
+
}
|
|
433
|
+
const state = this.credentialStates.get(serverUrl);
|
|
434
|
+
if (!state) {
|
|
435
|
+
throw new Error(`No credential state for server: ${serverUrl}`);
|
|
436
|
+
}
|
|
437
|
+
if (state.refreshing) {
|
|
438
|
+
// Wait for ongoing refresh
|
|
439
|
+
return new Promise((resolve, reject) => {
|
|
440
|
+
const checkInterval = setInterval(() => {
|
|
441
|
+
if (!state.refreshing) {
|
|
442
|
+
clearInterval(checkInterval);
|
|
443
|
+
resolve(state.credentials);
|
|
444
|
+
}
|
|
445
|
+
}, 100);
|
|
446
|
+
setTimeout(() => {
|
|
447
|
+
clearInterval(checkInterval);
|
|
448
|
+
reject(new Error('Credential refresh timeout'));
|
|
449
|
+
}, 30000);
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
state.refreshing = true;
|
|
453
|
+
let lastError = null;
|
|
454
|
+
for (let attempt = 0; attempt < this.config.credentialConfig.maxRetries; attempt++) {
|
|
455
|
+
try {
|
|
456
|
+
const newCredentials = await this.doCredentialFetch(serverUrl);
|
|
457
|
+
// Update state
|
|
458
|
+
state.credentials = newCredentials;
|
|
459
|
+
state.fetchedAt = Date.now();
|
|
460
|
+
state.refreshing = false;
|
|
461
|
+
// Update server in config
|
|
462
|
+
const index = this.config.servers.findIndex((s) => this.getServerUrl(s) === serverUrl);
|
|
463
|
+
if (index !== -1) {
|
|
464
|
+
this.config.servers[index] = newCredentials;
|
|
465
|
+
}
|
|
466
|
+
// Update health tracking
|
|
467
|
+
const health = this.serverHealth.get(serverUrl);
|
|
468
|
+
if (health) {
|
|
469
|
+
health.server = newCredentials;
|
|
470
|
+
}
|
|
471
|
+
// Schedule next refresh
|
|
472
|
+
this.scheduleCredentialRefresh(newCredentials);
|
|
473
|
+
this.emitEvent(types_1.NATEventType.CredentialsRefreshed, {
|
|
474
|
+
server: serverUrl,
|
|
475
|
+
expiresAt: newCredentials.expiresAt,
|
|
476
|
+
});
|
|
477
|
+
return newCredentials;
|
|
478
|
+
}
|
|
479
|
+
catch (error) {
|
|
480
|
+
lastError = error instanceof Error ? error : new Error('Unknown error');
|
|
481
|
+
if (attempt < this.config.credentialConfig.maxRetries - 1) {
|
|
482
|
+
await this.delay(this.config.credentialConfig.retryDelay);
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
state.refreshing = false;
|
|
487
|
+
throw lastError ?? new Error('Credential refresh failed');
|
|
488
|
+
}
|
|
489
|
+
async doCredentialFetch(serverUrl) {
|
|
490
|
+
if (!this.config.credentialConfig) {
|
|
491
|
+
throw new Error('No credential configuration');
|
|
492
|
+
}
|
|
493
|
+
const { refreshUrl, authToken } = this.config.credentialConfig;
|
|
494
|
+
const headers = {
|
|
495
|
+
'Content-Type': 'application/json',
|
|
496
|
+
};
|
|
497
|
+
if (authToken) {
|
|
498
|
+
headers['Authorization'] = `Bearer ${authToken}`;
|
|
499
|
+
}
|
|
500
|
+
const response = await fetch(refreshUrl, {
|
|
501
|
+
method: 'POST',
|
|
502
|
+
headers,
|
|
503
|
+
body: JSON.stringify({ server: serverUrl }),
|
|
504
|
+
});
|
|
505
|
+
if (!response.ok) {
|
|
506
|
+
throw new Error(`Credential refresh failed: ${response.status}`);
|
|
507
|
+
}
|
|
508
|
+
const data = await response.json();
|
|
509
|
+
// Validate response
|
|
510
|
+
if (!data.urls || !data.username || !data.credential) {
|
|
511
|
+
throw new Error('Invalid credential response format');
|
|
512
|
+
}
|
|
513
|
+
return {
|
|
514
|
+
urls: data.urls,
|
|
515
|
+
username: data.username,
|
|
516
|
+
credential: data.credential,
|
|
517
|
+
credentialType: data.credentialType || 'password',
|
|
518
|
+
expiresAt: data.expiresAt,
|
|
519
|
+
region: data.region,
|
|
520
|
+
priority: data.priority,
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
delay(ms) {
|
|
524
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
525
|
+
}
|
|
526
|
+
emitEvent(type, data) {
|
|
527
|
+
const handlers = this.eventHandlers.get(type);
|
|
528
|
+
if (handlers) {
|
|
529
|
+
const event = {
|
|
530
|
+
type,
|
|
531
|
+
timestamp: Date.now(),
|
|
532
|
+
data,
|
|
533
|
+
};
|
|
534
|
+
handlers.forEach((handler) => {
|
|
535
|
+
try {
|
|
536
|
+
handler(event);
|
|
537
|
+
}
|
|
538
|
+
catch (error) {
|
|
539
|
+
console.error(`TURN event handler error for ${type}:`, error);
|
|
540
|
+
}
|
|
541
|
+
});
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
}
|
|
545
|
+
exports.TURNManager = TURNManager;
|
|
546
|
+
exports.default = TURNManager;
|
|
547
|
+
//# sourceMappingURL=TURNManager.js.map
|