@webex/contact-center 3.12.0 → 3.13.0-next.1
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/.sdd/manifest.json +887 -0
- package/AGENTS.md +94 -0
- package/ai-docs/ARCHITECTURE.md +168 -0
- package/ai-docs/CONTRACTS.md +64 -0
- package/ai-docs/GETTING_STARTED.md +168 -0
- package/ai-docs/GLOSSARY.md +43 -0
- package/ai-docs/README.md +138 -0
- package/ai-docs/REVIEW_CHECKLIST.md +41 -0
- package/ai-docs/RULES.md +444 -0
- package/ai-docs/SECURITY.md +52 -0
- package/ai-docs/SERVICE_STATE.md +52 -0
- package/ai-docs/SPEC_INDEX.md +65 -0
- package/ai-docs/adr/0001-spec-source-policy.md +55 -0
- package/ai-docs/adr/README.md +8 -0
- package/ai-docs/adr/_adr-template.md +31 -0
- package/ai-docs/contact-center-spec.md +388 -0
- package/ai-docs/features/consult-transfer-list-policy/spec/feature-spec.md +362 -0
- package/ai-docs/features/contact-owner-change-refactor.md +78 -0
- package/ai-docs/features/generated-spec-conformance-fidelity-remediation/spec/feature-spec.md +117 -0
- package/ai-docs/features/residual-warning-coverage-completion/spec/feature-spec.md +203 -0
- package/ai-docs/features/validator-code-fidelity-drift-fix/spec/feature-spec.md +315 -0
- package/ai-docs/patterns/event-driven-patterns.md +485 -0
- package/ai-docs/patterns/testing-patterns.md +480 -0
- package/ai-docs/patterns/typescript-patterns.md +365 -0
- package/ai-docs/templates/README.md +102 -0
- package/ai-docs/templates/documentation/create-agents-md.md +240 -0
- package/ai-docs/templates/documentation/create-architecture-md.md +295 -0
- package/ai-docs/templates/existing-service/bug-fix.md +254 -0
- package/ai-docs/templates/existing-service/feature-enhancement.md +450 -0
- package/ai-docs/templates/new-method/00-master.md +80 -0
- package/ai-docs/templates/new-method/01-requirements.md +232 -0
- package/ai-docs/templates/new-method/02-implementation.md +295 -0
- package/ai-docs/templates/new-method/03-tests.md +201 -0
- package/ai-docs/templates/new-method/04-validation.md +141 -0
- package/ai-docs/templates/new-service/00-master.md +109 -0
- package/ai-docs/templates/new-service/01-pre-questions.md +159 -0
- package/ai-docs/templates/new-service/02-code-generation.md +346 -0
- package/ai-docs/templates/new-service/03-integration.md +178 -0
- package/ai-docs/templates/new-service/04-test-generation.md +205 -0
- package/ai-docs/templates/new-service/05-validation.md +145 -0
- package/dist/cc.js +1102 -47
- package/dist/cc.js.map +1 -1
- package/dist/config.js +13 -0
- package/dist/config.js.map +1 -1
- package/dist/constants.js +46 -3
- package/dist/constants.js.map +1 -1
- package/dist/index.js +86 -17
- package/dist/index.js.map +1 -1
- package/dist/metrics/MetricsManager.js +16 -0
- package/dist/metrics/MetricsManager.js.map +1 -1
- package/dist/metrics/behavioral-events.js +211 -0
- package/dist/metrics/behavioral-events.js.map +1 -1
- package/dist/metrics/constants.js +58 -4
- package/dist/metrics/constants.js.map +1 -1
- package/dist/services/AddressBook.js +18 -15
- package/dist/services/AddressBook.js.map +1 -1
- package/dist/services/AnswerCallOnWebexService.js +202 -0
- package/dist/services/AnswerCallOnWebexService.js.map +1 -0
- package/dist/services/ApiAiAssistant.js +369 -14
- package/dist/services/ApiAiAssistant.js.map +1 -1
- package/dist/services/EntryPoint.js +46 -68
- package/dist/services/EntryPoint.js.map +1 -1
- package/dist/services/Queue.js +27 -22
- package/dist/services/Queue.js.map +1 -1
- package/dist/services/UserPreference.js +427 -0
- package/dist/services/UserPreference.js.map +1 -0
- package/dist/services/WebCallingService.js +287 -37
- package/dist/services/WebCallingService.js.map +1 -1
- package/dist/services/WebexCrossClientService.js +225 -0
- package/dist/services/WebexCrossClientService.js.map +1 -0
- package/dist/services/WxAppTelephonyMercurySync.js +111 -0
- package/dist/services/WxAppTelephonyMercurySync.js.map +1 -0
- package/dist/services/config/Util.js +48 -48
- package/dist/services/config/Util.js.map +1 -1
- package/dist/services/config/constants.js +57 -79
- package/dist/services/config/constants.js.map +1 -1
- package/dist/services/config/index.js +100 -226
- package/dist/services/config/index.js.map +1 -1
- package/dist/services/config/types.js +100 -40
- package/dist/services/config/types.js.map +1 -1
- package/dist/services/constants.js +19 -1
- package/dist/services/constants.js.map +1 -1
- package/dist/services/core/Err.js.map +1 -1
- package/dist/services/core/Utils.js +131 -32
- package/dist/services/core/Utils.js.map +1 -1
- package/dist/services/core/WebexRequest.js +6 -2
- package/dist/services/core/WebexRequest.js.map +1 -1
- package/dist/services/core/aqm-reqs.js +17 -11
- package/dist/services/core/aqm-reqs.js.map +1 -1
- package/dist/services/core/constants.js +9 -1
- package/dist/services/core/constants.js.map +1 -1
- package/dist/services/core/types.js.map +1 -1
- package/dist/services/core/websocket/WebSocketManager.js +26 -6
- package/dist/services/core/websocket/WebSocketManager.js.map +1 -1
- package/dist/services/core/websocket/connection-service.js +3 -1
- package/dist/services/core/websocket/connection-service.js.map +1 -1
- package/dist/services/core/websocket/types.js.map +1 -1
- package/dist/services/index.js +6 -0
- package/dist/services/index.js.map +1 -1
- package/dist/services/task/Task.js +955 -0
- package/dist/services/task/Task.js.map +1 -0
- package/dist/services/task/TaskFactory.js +50 -0
- package/dist/services/task/TaskFactory.js.map +1 -0
- package/dist/services/task/TaskManager.js +1275 -504
- package/dist/services/task/TaskManager.js.map +1 -1
- package/dist/services/task/TaskUtils.js +221 -27
- package/dist/services/task/TaskUtils.js.map +1 -1
- package/dist/services/task/WebexCallingUtils.js +70 -0
- package/dist/services/task/WebexCallingUtils.js.map +1 -0
- package/dist/services/task/constants.js +22 -2
- package/dist/services/task/constants.js.map +1 -1
- package/dist/services/task/contact.js +29 -0
- package/dist/services/task/contact.js.map +1 -1
- package/dist/services/task/dialer.js +78 -0
- package/dist/services/task/dialer.js.map +1 -1
- package/dist/services/task/digital/Digital.js +78 -0
- package/dist/services/task/digital/Digital.js.map +1 -0
- package/dist/services/task/state-machine/TaskStateMachine.js +982 -0
- package/dist/services/task/state-machine/TaskStateMachine.js.map +1 -0
- package/dist/services/task/state-machine/actions.js +572 -0
- package/dist/services/task/state-machine/actions.js.map +1 -0
- package/dist/services/task/state-machine/constants.js +161 -0
- package/dist/services/task/state-machine/constants.js.map +1 -0
- package/dist/services/task/state-machine/guards.js +379 -0
- package/dist/services/task/state-machine/guards.js.map +1 -0
- package/dist/services/task/state-machine/index.js +53 -0
- package/dist/services/task/state-machine/index.js.map +1 -0
- package/dist/services/task/state-machine/types.js +54 -0
- package/dist/services/task/state-machine/types.js.map +1 -0
- package/dist/services/task/state-machine/uiControlsComputer.js +703 -0
- package/dist/services/task/state-machine/uiControlsComputer.js.map +1 -0
- package/dist/services/task/taskDataNormalizer.js +99 -0
- package/dist/services/task/taskDataNormalizer.js.map +1 -0
- package/dist/services/task/types.js +259 -5
- package/dist/services/task/types.js.map +1 -1
- package/dist/services/task/voice/Voice.js +1504 -0
- package/dist/services/task/voice/Voice.js.map +1 -0
- package/dist/services/task/voice/WebRTC.js +152 -0
- package/dist/services/task/voice/WebRTC.js.map +1 -0
- package/dist/services/task/voice/wxAppOfferObservability.js +145 -0
- package/dist/services/task/voice/wxAppOfferObservability.js.map +1 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js +395 -0
- package/dist/services/task/voice/wxAppVoiceMethods.js.map +1 -0
- package/dist/services/wxAppDiagnosticLogging.js +159 -0
- package/dist/services/wxAppDiagnosticLogging.js.map +1 -0
- package/dist/services/wxAppTelephonyUtils.js +19 -0
- package/dist/services/wxAppTelephonyUtils.js.map +1 -0
- package/dist/types/cc.d.ts +222 -10
- package/dist/types/config.d.ts +13 -0
- package/dist/types/constants.d.ts +40 -1
- package/dist/types/index.d.ts +58 -22
- package/dist/types/metrics/MetricsManager.d.ts +6 -0
- package/dist/types/metrics/constants.d.ts +52 -1
- package/dist/types/services/AddressBook.d.ts +2 -1
- package/dist/types/services/AnswerCallOnWebexService.d.ts +38 -0
- package/dist/types/services/ApiAiAssistant.d.ts +67 -5
- package/dist/types/services/EntryPoint.d.ts +7 -5
- package/dist/types/services/Queue.d.ts +5 -3
- package/dist/types/services/UserPreference.d.ts +118 -0
- package/dist/types/services/WebexCrossClientService.d.ts +32 -0
- package/dist/types/services/WxAppTelephonyMercurySync.d.ts +28 -0
- package/dist/types/services/config/Util.d.ts +4 -8
- package/dist/types/services/config/constants.d.ts +49 -76
- package/dist/types/services/config/index.d.ts +16 -64
- package/dist/types/services/config/types.d.ts +252 -114
- package/dist/types/services/constants.d.ts +16 -0
- package/dist/types/services/core/Err.d.ts +6 -0
- package/dist/types/services/core/Utils.d.ts +43 -13
- package/dist/types/services/core/WebexRequest.d.ts +1 -0
- package/dist/types/services/core/constants.d.ts +7 -0
- package/dist/types/services/core/types.d.ts +2 -0
- package/dist/types/services/core/websocket/WebSocketManager.d.ts +2 -0
- package/dist/types/services/core/websocket/types.d.ts +1 -1
- package/dist/types/services/index.d.ts +2 -0
- package/dist/types/services/task/Task.d.ts +186 -0
- package/dist/types/services/task/TaskFactory.d.ts +14 -0
- package/dist/types/services/task/TaskUtils.d.ts +54 -2
- package/dist/types/services/task/WebexCallingUtils.d.ts +11 -0
- package/dist/types/services/task/constants.d.ts +20 -0
- package/dist/types/services/task/contact.d.ts +4 -0
- package/dist/types/services/task/dialer.d.ts +30 -0
- package/dist/types/services/task/digital/Digital.d.ts +23 -0
- package/dist/types/services/task/state-machine/TaskStateMachine.d.ts +1442 -0
- package/dist/types/services/task/state-machine/actions.d.ts +10 -0
- package/dist/types/services/task/state-machine/constants.d.ts +107 -0
- package/dist/types/services/task/state-machine/guards.d.ts +103 -0
- package/dist/types/services/task/state-machine/index.d.ts +13 -0
- package/dist/types/services/task/state-machine/types.d.ts +277 -0
- package/dist/types/services/task/state-machine/uiControlsComputer.d.ts +9 -0
- package/dist/types/services/task/taskDataNormalizer.d.ts +10 -0
- package/dist/types/services/task/types.d.ts +790 -66
- package/dist/types/services/task/voice/Voice.d.ts +241 -0
- package/dist/types/services/task/voice/WebRTC.d.ts +54 -0
- package/dist/types/services/task/voice/wxAppOfferObservability.d.ts +39 -0
- package/dist/types/services/task/voice/wxAppVoiceMethods.d.ts +68 -0
- package/dist/types/services/wxAppDiagnosticLogging.d.ts +63 -0
- package/dist/types/services/wxAppTelephonyUtils.d.ts +5 -0
- package/dist/types/types.d.ts +258 -11
- package/dist/types/utils/PageCache.d.ts +20 -3
- package/dist/types/webex.d.ts +1 -0
- package/dist/types.js +204 -6
- package/dist/types.js.map +1 -1
- package/dist/utils/PageCache.js +19 -5
- package/dist/utils/PageCache.js.map +1 -1
- package/dist/webex.js +22 -2
- package/dist/webex.js.map +1 -1
- package/package.json +16 -12
- package/src/cc.ts +1439 -105
- package/src/config.ts +13 -0
- package/src/constants.ts +53 -1
- package/src/index.ts +72 -16
- package/src/metrics/MetricsManager.ts +16 -0
- package/src/metrics/ai-docs/AGENTS.md +350 -0
- package/src/metrics/ai-docs/ARCHITECTURE.md +338 -0
- package/src/metrics/ai-docs/metrics-spec.md +971 -0
- package/src/metrics/behavioral-events.ts +218 -0
- package/src/metrics/constants.ts +63 -4
- package/src/services/AddressBook.ts +17 -6
- package/src/services/AnswerCallOnWebexService.ts +239 -0
- package/src/services/ApiAiAssistant.ts +494 -15
- package/src/services/EntryPoint.ts +59 -60
- package/src/services/Queue.ts +29 -12
- package/src/services/UserPreference.ts +509 -0
- package/src/services/WebCallingService.ts +362 -40
- package/src/services/WebexCrossClientService.ts +298 -0
- package/src/services/WxAppTelephonyMercurySync.ts +142 -0
- package/src/services/agent/ai-docs/AGENTS.md +240 -0
- package/src/services/agent/ai-docs/ARCHITECTURE.md +304 -0
- package/src/services/agent/ai-docs/agent-spec.md +505 -0
- package/src/services/ai-docs/AGENTS.md +386 -0
- package/src/services/ai-docs/services-spec.md +512 -0
- package/src/services/config/Util.ts +54 -84
- package/src/services/config/ai-docs/AGENTS.md +250 -0
- package/src/services/config/ai-docs/ARCHITECTURE.md +413 -0
- package/src/services/config/ai-docs/config-spec.md +669 -0
- package/src/services/config/constants.ts +64 -86
- package/src/services/config/index.ts +116 -277
- package/src/services/config/types.ts +238 -125
- package/src/services/constants.ts +18 -0
- package/src/services/core/Err.ts +3 -0
- package/src/services/core/Utils.ts +151 -37
- package/src/services/core/WebexRequest.ts +3 -1
- package/src/services/core/ai-docs/AGENTS.md +381 -0
- package/src/services/core/ai-docs/ARCHITECTURE.md +698 -0
- package/src/services/core/ai-docs/core-spec.md +797 -0
- package/src/services/core/aqm-reqs.ts +18 -12
- package/src/services/core/constants.ts +8 -0
- package/src/services/core/types.ts +33 -1
- package/src/services/core/websocket/WebSocketManager.ts +37 -8
- package/src/services/core/websocket/connection-service.ts +5 -1
- package/src/services/core/websocket/types.ts +1 -1
- package/src/services/index.ts +4 -0
- package/src/services/task/Task.ts +1211 -0
- package/src/services/task/TaskFactory.ts +82 -0
- package/src/services/task/TaskManager.ts +1551 -584
- package/src/services/task/TaskUtils.ts +316 -25
- package/src/services/task/WebexCallingUtils.ts +136 -0
- package/src/services/task/ai-docs/AGENTS.md +457 -0
- package/src/services/task/ai-docs/ARCHITECTURE.md +595 -0
- package/src/services/task/ai-docs/task-spec.md +1501 -0
- package/src/services/task/constants.ts +21 -0
- package/src/services/task/contact.ts +30 -0
- package/src/services/task/dialer.ts +80 -0
- package/src/services/task/digital/Digital.ts +102 -0
- package/src/services/task/state-machine/TaskStateMachine.ts +1320 -0
- package/src/services/task/state-machine/actions.ts +741 -0
- package/src/services/task/state-machine/ai-docs/AGENTS.md +460 -0
- package/src/services/task/state-machine/ai-docs/ARCHITECTURE.md +1156 -0
- package/src/services/task/state-machine/ai-docs/task-state-machine-spec.md +2247 -0
- package/src/services/task/state-machine/constants.ts +172 -0
- package/src/services/task/state-machine/guards.ts +442 -0
- package/src/services/task/state-machine/index.ts +28 -0
- package/src/services/task/state-machine/types.ts +258 -0
- package/src/services/task/state-machine/uiControlsComputer.ts +1135 -0
- package/src/services/task/taskDataNormalizer.ts +137 -0
- package/src/services/task/types.ts +974 -70
- package/src/services/task/voice/Voice.ts +1878 -0
- package/src/services/task/voice/WebRTC.ts +194 -0
- package/src/services/task/voice/wxAppOfferObservability.ts +204 -0
- package/src/services/task/voice/wxAppVoiceMethods.ts +575 -0
- package/src/services/wxAppDiagnosticLogging.ts +286 -0
- package/src/services/wxAppTelephonyUtils.ts +14 -0
- package/src/types.ts +323 -13
- package/src/utils/AGENTS.md +289 -0
- package/src/utils/PageCache.ts +38 -5
- package/src/utils/ai-docs/utils-spec.md +391 -0
- package/src/webex.js +10 -0
- package/test/unit/fixtures/aiSummaryTestUtils.ts +40 -0
- package/test/unit/spec/cc.ts +4046 -181
- package/test/unit/spec/index.ts +891 -0
- package/test/unit/spec/logger-proxy.ts +70 -0
- package/test/unit/spec/metrics/MetricsManager.ts +25 -0
- package/test/unit/spec/metrics/behavioral-events.ts +60 -0
- package/test/unit/spec/services/AddressBook.ts +37 -6
- package/test/unit/spec/services/AnswerCallOnWebexService.ts +264 -0
- package/test/unit/spec/services/ApiAiAssistant.ts +442 -23
- package/test/unit/spec/services/EntryPoint.ts +87 -40
- package/test/unit/spec/services/Queue.ts +123 -12
- package/test/unit/spec/services/UserPreference.ts +401 -0
- package/test/unit/spec/services/WebCallingService.ts +484 -49
- package/test/unit/spec/services/WebexCrossClientService.ts +509 -0
- package/test/unit/spec/services/WxAppTelephonyMercurySync.ts +136 -0
- package/test/unit/spec/services/config/Util.ts +501 -0
- package/test/unit/spec/services/config/index.ts +318 -548
- package/test/unit/spec/services/core/Utils.ts +447 -8
- package/test/unit/spec/services/core/WebexRequest.ts +8 -7
- package/test/unit/spec/services/core/aqm-reqs.ts +142 -1
- package/test/unit/spec/services/core/websocket/WebSocketManager.ts +132 -56
- package/test/unit/spec/services/core/websocket/connection-service.ts +3 -1
- package/test/unit/spec/services/task/AutoWrapup.ts +63 -0
- package/test/unit/spec/services/task/Task.ts +2723 -0
- package/test/unit/spec/services/task/TaskFactory.ts +116 -0
- package/test/unit/spec/services/task/TaskManager.ts +4800 -1586
- package/test/unit/spec/services/task/TaskUtils.ts +307 -0
- package/test/unit/spec/services/task/WebexCallingUtils.ts +153 -0
- package/test/unit/spec/services/task/contact.ts +33 -0
- package/test/unit/spec/services/task/dialer.ts +190 -0
- package/test/unit/spec/services/task/digital/Digital.ts +105 -0
- package/test/unit/spec/services/task/state-machine/TaskStateMachine.ts +4060 -0
- package/test/unit/spec/services/task/state-machine/guards.ts +839 -0
- package/test/unit/spec/services/task/state-machine/types.ts +18 -0
- package/test/unit/spec/services/task/state-machine/uiControlsComputer.ts +3101 -0
- package/test/unit/spec/services/task/taskTestUtils.ts +87 -0
- package/test/unit/spec/services/task/voice/Voice.ts +2355 -0
- package/test/unit/spec/services/task/voice/WebRTC.ts +235 -0
- package/test/unit/spec/services/task/voice/wxAppOfferObservability.ts +361 -0
- package/test/unit/spec/services/task/voice/wxAppVoiceMethods.ts +719 -0
- package/test/unit/spec/services/wxAppDiagnosticLogging.ts +179 -0
- package/test/unit/spec/wellnessSampleUtils.ts +288 -0
- package/typedoc.md +1 -1
- package/umd/contact-center.min.js +2 -2
- package/umd/contact-center.min.js.map +1 -1
- package/dist/services/task/index.js +0 -1525
- package/dist/services/task/index.js.map +0 -1
- package/dist/types/services/task/index.d.ts +0 -650
- package/src/services/task/index.ts +0 -1801
- package/test/unit/spec/services/task/index.ts +0 -2184
|
@@ -8,18 +8,40 @@ import {
|
|
|
8
8
|
ServiceIndicator,
|
|
9
9
|
LocalMicrophoneStream,
|
|
10
10
|
CALL_EVENT_KEYS,
|
|
11
|
+
CALLING_CLIENT_EVENT_KEYS,
|
|
12
|
+
MOBIUS_SOCKET_DISCONNECT_REASON,
|
|
11
13
|
LOGGER,
|
|
14
|
+
MobiusSocketDisconnectedEvent,
|
|
15
|
+
LineError,
|
|
12
16
|
} from '@webex/calling';
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
17
|
+
import isEqual from 'lodash/isEqual';
|
|
18
|
+
import {
|
|
19
|
+
LoginOption,
|
|
20
|
+
VoiceConnectionState,
|
|
21
|
+
VOICE_CONNECTION_STATUS,
|
|
22
|
+
VoiceLineStatus,
|
|
23
|
+
VoiceMobiusSocketStatus,
|
|
24
|
+
WebexSDK,
|
|
25
|
+
} from '../types';
|
|
26
|
+
import {VOICE_CONNECTION_EVENTS} from './config/types';
|
|
27
|
+
import {
|
|
28
|
+
DEFAULT_VOICE_CONNECTION_STATE,
|
|
29
|
+
TIMEOUT_DURATION,
|
|
30
|
+
WEB_CALLING_SERVICE_FILE,
|
|
31
|
+
} from '../constants';
|
|
15
32
|
import LoggerProxy from '../logger-proxy';
|
|
16
33
|
import {
|
|
17
34
|
DEFAULT_RTMS_DOMAIN,
|
|
35
|
+
ALLOWED_RTMS_DOMAIN,
|
|
18
36
|
POST_AUTH,
|
|
19
37
|
WCC_CALLING_RTMS_DOMAIN,
|
|
20
38
|
DEREGISTER_WEBCALLING_LINE_MSG,
|
|
21
39
|
METHODS,
|
|
22
40
|
} from './constants';
|
|
41
|
+
import {isAllowedUrlHost} from './core/Utils';
|
|
42
|
+
|
|
43
|
+
// Match RegistrationStatus.ACTIVE; @webex/calling does not export the enum from its public barrel.
|
|
44
|
+
const ACTIVE_REGISTRATION_STATUS = 'active' as LineError['status'];
|
|
23
45
|
|
|
24
46
|
/**
|
|
25
47
|
* WebCallingService provides WebRTC calling functionality for Contact Center agents.
|
|
@@ -57,6 +79,28 @@ export default class WebCallingService extends EventEmitter {
|
|
|
57
79
|
*/
|
|
58
80
|
public loginOption: LoginOption;
|
|
59
81
|
|
|
82
|
+
private browserVoiceRequired = false;
|
|
83
|
+
|
|
84
|
+
private voiceConnectionState: VoiceConnectionState = {...DEFAULT_VOICE_CONNECTION_STATE};
|
|
85
|
+
|
|
86
|
+
private lineReason?: string;
|
|
87
|
+
|
|
88
|
+
private lineRetryable?: boolean;
|
|
89
|
+
|
|
90
|
+
private socketReason?: string;
|
|
91
|
+
|
|
92
|
+
private socketRetryable?: boolean;
|
|
93
|
+
|
|
94
|
+
private rejectRegistration?: (error: Error) => void;
|
|
95
|
+
|
|
96
|
+
private registrationCompleteHandler?: (line: ILine) => void;
|
|
97
|
+
|
|
98
|
+
private incomingCallHandler?: (call: ICall) => void;
|
|
99
|
+
|
|
100
|
+
private registrationGeneration = 0;
|
|
101
|
+
|
|
102
|
+
private registrationListenerCleanup: Array<() => void> = [];
|
|
103
|
+
|
|
60
104
|
/**
|
|
61
105
|
* Map that associates call IDs with task IDs for correlation
|
|
62
106
|
* @private
|
|
@@ -82,6 +126,177 @@ export default class WebCallingService extends EventEmitter {
|
|
|
82
126
|
this.loginOption = loginOption;
|
|
83
127
|
}
|
|
84
128
|
|
|
129
|
+
/** Sets whether the current local login registers a browser voice line. */
|
|
130
|
+
public setBrowserVoiceRequired(required: boolean): void {
|
|
131
|
+
this.browserVoiceRequired = required;
|
|
132
|
+
this.updateVoiceConnectionState({});
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
/**
|
|
136
|
+
* Returns a copy of the latest browser voice state.
|
|
137
|
+
* @returns {VoiceConnectionState} Current voice availability and transport states
|
|
138
|
+
* @public
|
|
139
|
+
*/
|
|
140
|
+
public getVoiceConnectionState(): VoiceConnectionState {
|
|
141
|
+
return {...this.voiceConnectionState};
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* Reports whether the browser line is ready for voice interactions.
|
|
146
|
+
* @returns {boolean} True when browser voice is ready
|
|
147
|
+
* @private
|
|
148
|
+
*/
|
|
149
|
+
public isVoiceReady(): boolean {
|
|
150
|
+
return this.voiceConnectionState.status === VOICE_CONNECTION_STATUS.READY;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
/**
|
|
154
|
+
* Reports whether this login requires browser voice registration.
|
|
155
|
+
* @returns {boolean} True when browser WebRTC is enabled for the current login
|
|
156
|
+
* @private
|
|
157
|
+
*/
|
|
158
|
+
public isBrowserVoiceRequired(): boolean {
|
|
159
|
+
return this.browserVoiceRequired;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
private isLineReady(lineStatus = this.voiceConnectionState.lineStatus): boolean {
|
|
163
|
+
return lineStatus === VoiceLineStatus.REGISTERED || lineStatus === VoiceLineStatus.RECONNECTED;
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
private updateVoiceConnectionState(
|
|
167
|
+
update: Partial<Pick<VoiceConnectionState, 'lineStatus' | 'mobiusSocketStatus'>>
|
|
168
|
+
): void {
|
|
169
|
+
const lineStatus = update.lineStatus ?? this.voiceConnectionState.lineStatus;
|
|
170
|
+
const mobiusSocketStatus =
|
|
171
|
+
update.mobiusSocketStatus ?? this.voiceConnectionState.mobiusSocketStatus;
|
|
172
|
+
let status = VOICE_CONNECTION_STATUS.UNAVAILABLE;
|
|
173
|
+
|
|
174
|
+
if (!this.browserVoiceRequired) {
|
|
175
|
+
status = VOICE_CONNECTION_STATUS.NOT_REQUIRED;
|
|
176
|
+
} else if (
|
|
177
|
+
this.isLineReady(lineStatus) &&
|
|
178
|
+
mobiusSocketStatus !== VoiceMobiusSocketStatus.DISCONNECTED
|
|
179
|
+
) {
|
|
180
|
+
status = VOICE_CONNECTION_STATUS.READY;
|
|
181
|
+
}
|
|
182
|
+
const reason =
|
|
183
|
+
mobiusSocketStatus === VoiceMobiusSocketStatus.DISCONNECTED
|
|
184
|
+
? this.socketReason
|
|
185
|
+
: this.lineReason;
|
|
186
|
+
const retryable =
|
|
187
|
+
mobiusSocketStatus === VoiceMobiusSocketStatus.DISCONNECTED
|
|
188
|
+
? this.socketRetryable
|
|
189
|
+
: this.lineRetryable;
|
|
190
|
+
const nextState: VoiceConnectionState = {
|
|
191
|
+
status,
|
|
192
|
+
lineStatus,
|
|
193
|
+
mobiusSocketStatus,
|
|
194
|
+
...(reason ? {reason} : {}),
|
|
195
|
+
...(retryable !== undefined ? {retryable} : {}),
|
|
196
|
+
};
|
|
197
|
+
|
|
198
|
+
if (isEqual(nextState, this.voiceConnectionState)) {
|
|
199
|
+
return;
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
this.voiceConnectionState = nextState;
|
|
203
|
+
this.emit(VOICE_CONNECTION_EVENTS.STATE_CHANGE, this.getVoiceConnectionState());
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
private addRegistrationListener(
|
|
207
|
+
emitter: ICallingClient | ILine,
|
|
208
|
+
event: string,
|
|
209
|
+
callback: (...args: any[]) => void
|
|
210
|
+
): (...args: any[]) => void {
|
|
211
|
+
const generation = this.registrationGeneration;
|
|
212
|
+
const listener = (...args: any[]) => {
|
|
213
|
+
if (generation === this.registrationGeneration) {
|
|
214
|
+
callback(...args);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
(emitter as any).on(event, listener);
|
|
219
|
+
this.registrationListenerCleanup.push(() => (emitter as any).off?.(event, listener));
|
|
220
|
+
|
|
221
|
+
return listener;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
private async cleanupWebCallingRegistration(): Promise<void> {
|
|
225
|
+
this.registrationGeneration += 1;
|
|
226
|
+
this.rejectRegistration?.(new Error('WebCallingService registration superseded'));
|
|
227
|
+
this.rejectRegistration = undefined;
|
|
228
|
+
this.registrationListenerCleanup.forEach((cleanup) => cleanup());
|
|
229
|
+
this.registrationListenerCleanup = [];
|
|
230
|
+
this.incomingCallHandler = undefined;
|
|
231
|
+
this.registrationCompleteHandler = undefined;
|
|
232
|
+
|
|
233
|
+
const line = this.line;
|
|
234
|
+
this.line = undefined;
|
|
235
|
+
this.callingClient = undefined;
|
|
236
|
+
if (line) {
|
|
237
|
+
await line.deregister();
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
private handleLineConnecting = (): void => {
|
|
242
|
+
this.lineReason = undefined;
|
|
243
|
+
this.lineRetryable = undefined;
|
|
244
|
+
this.updateVoiceConnectionState({lineStatus: VoiceLineStatus.CONNECTING});
|
|
245
|
+
};
|
|
246
|
+
|
|
247
|
+
private handleLineRegistered = (line: ILine): void => {
|
|
248
|
+
this.lineReason = undefined;
|
|
249
|
+
this.lineRetryable = undefined;
|
|
250
|
+
this.updateVoiceConnectionState({lineStatus: VoiceLineStatus.REGISTERED});
|
|
251
|
+
LoggerProxy.log(
|
|
252
|
+
`WxCC-SDK: Desktop registered successfully, mobiusDeviceId: ${line.mobiusDeviceId}`,
|
|
253
|
+
{module: WEB_CALLING_SERVICE_FILE, method: METHODS.REGISTER_WEB_CALLING_LINE}
|
|
254
|
+
);
|
|
255
|
+
};
|
|
256
|
+
|
|
257
|
+
private handleLineReconnecting = (): void => {
|
|
258
|
+
this.lineReason = 'LINE_RECONNECTING';
|
|
259
|
+
this.lineRetryable = true;
|
|
260
|
+
this.updateVoiceConnectionState({lineStatus: VoiceLineStatus.RECONNECTING});
|
|
261
|
+
};
|
|
262
|
+
|
|
263
|
+
private handleLineReconnected = (): void => {
|
|
264
|
+
this.lineReason = undefined;
|
|
265
|
+
this.lineRetryable = undefined;
|
|
266
|
+
this.updateVoiceConnectionState({lineStatus: VoiceLineStatus.RECONNECTED});
|
|
267
|
+
};
|
|
268
|
+
|
|
269
|
+
private handleLineUnregistered = (): void => {
|
|
270
|
+
this.lineReason = 'LINE_UNREGISTERED';
|
|
271
|
+
this.lineRetryable = true;
|
|
272
|
+
this.updateVoiceConnectionState({lineStatus: VoiceLineStatus.UNREGISTERED});
|
|
273
|
+
LoggerProxy.log(`WxCC-SDK: Desktop unregistered successfully`, {
|
|
274
|
+
module: WEB_CALLING_SERVICE_FILE,
|
|
275
|
+
method: METHODS.REGISTER_WEB_CALLING_LINE,
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
|
|
279
|
+
private handleLineError = (error: LineError): void => {
|
|
280
|
+
if (error.status !== ACTIVE_REGISTRATION_STATUS) {
|
|
281
|
+
this.lineReason = error.message || 'LINE_ERROR';
|
|
282
|
+
this.lineRetryable = false;
|
|
283
|
+
this.updateVoiceConnectionState({lineStatus: VoiceLineStatus.ERROR});
|
|
284
|
+
this.rejectRegistration?.(error);
|
|
285
|
+
}
|
|
286
|
+
};
|
|
287
|
+
|
|
288
|
+
private handleMobiusSocketConnected = (): void => {
|
|
289
|
+
this.socketReason = undefined;
|
|
290
|
+
this.socketRetryable = undefined;
|
|
291
|
+
this.updateVoiceConnectionState({mobiusSocketStatus: VoiceMobiusSocketStatus.CONNECTED});
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
private handleMobiusSocketDisconnected = (event: MobiusSocketDisconnectedEvent): void => {
|
|
295
|
+
this.socketReason = `MOBIUS_SOCKET_${event.reason.toUpperCase()}`;
|
|
296
|
+
this.socketRetryable = event.reason === MOBIUS_SOCKET_DISCONNECT_REASON.TRANSIENT;
|
|
297
|
+
this.updateVoiceConnectionState({mobiusSocketStatus: VoiceMobiusSocketStatus.DISCONNECTED});
|
|
298
|
+
};
|
|
299
|
+
|
|
85
300
|
/**
|
|
86
301
|
* Handles remote media track events from the call
|
|
87
302
|
* @param {MediaStreamTrack} track - The media track received
|
|
@@ -141,9 +356,21 @@ export default class WebCallingService extends EventEmitter {
|
|
|
141
356
|
const rtmsURL = this.webex.internal.services.get(WCC_CALLING_RTMS_DOMAIN);
|
|
142
357
|
|
|
143
358
|
try {
|
|
144
|
-
const
|
|
359
|
+
const hostname = new URL(rtmsURL).hostname.toLowerCase();
|
|
360
|
+
|
|
361
|
+
if (!isAllowedUrlHost(rtmsURL, [ALLOWED_RTMS_DOMAIN])) {
|
|
362
|
+
LoggerProxy.error(
|
|
363
|
+
`Non-allow-listed RTMS host from u2c catalogue: ${hostname} so falling back to default domain`,
|
|
364
|
+
{
|
|
365
|
+
module: WEB_CALLING_SERVICE_FILE,
|
|
366
|
+
method: METHODS.GET_RTMS_DOMAIN,
|
|
367
|
+
}
|
|
368
|
+
);
|
|
369
|
+
|
|
370
|
+
return DEFAULT_RTMS_DOMAIN;
|
|
371
|
+
}
|
|
145
372
|
|
|
146
|
-
return
|
|
373
|
+
return hostname;
|
|
147
374
|
} catch (error) {
|
|
148
375
|
LoggerProxy.error(
|
|
149
376
|
`Invalid URL from u2c catalogue: ${rtmsURL} so falling back to default domain`,
|
|
@@ -166,49 +393,133 @@ export default class WebCallingService extends EventEmitter {
|
|
|
166
393
|
* @throws {Error} When registration times out
|
|
167
394
|
*/
|
|
168
395
|
public async registerWebCallingLine(): Promise<void> {
|
|
169
|
-
const
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
},
|
|
175
|
-
serviceData: {
|
|
176
|
-
indicator: ServiceIndicator.CONTACT_CENTER,
|
|
177
|
-
domain: rtmsDomain,
|
|
178
|
-
},
|
|
179
|
-
};
|
|
396
|
+
const registrationGeneration = this.registrationGeneration + 1;
|
|
397
|
+
await this.cleanupWebCallingRegistration();
|
|
398
|
+
if (registrationGeneration !== this.registrationGeneration) {
|
|
399
|
+
return;
|
|
400
|
+
}
|
|
180
401
|
|
|
181
|
-
this.
|
|
182
|
-
this.
|
|
402
|
+
this.lineReason = undefined;
|
|
403
|
+
this.lineRetryable = undefined;
|
|
404
|
+
this.updateVoiceConnectionState({lineStatus: VoiceLineStatus.CONNECTING});
|
|
183
405
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
406
|
+
try {
|
|
407
|
+
const rtmsDomain = await this.getRTMSDomain(); // get the RTMS domain from the u2c catalogue
|
|
408
|
+
if (registrationGeneration !== this.registrationGeneration) {
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
const callingClientConfig = {
|
|
413
|
+
logger: {
|
|
414
|
+
level: LOGGER.INFO,
|
|
415
|
+
},
|
|
416
|
+
serviceData: {
|
|
417
|
+
indicator: ServiceIndicator.CONTACT_CENTER,
|
|
418
|
+
domain: rtmsDomain,
|
|
419
|
+
},
|
|
420
|
+
};
|
|
421
|
+
|
|
422
|
+
const callingClient = await createClient(this.webex as any, callingClientConfig);
|
|
423
|
+
if (registrationGeneration !== this.registrationGeneration) {
|
|
424
|
+
await Object.values(callingClient.getLines())[0]?.deregister();
|
|
425
|
+
|
|
426
|
+
return;
|
|
427
|
+
}
|
|
428
|
+
this.callingClient = callingClient;
|
|
429
|
+
this.line = Object.values(this.callingClient.getLines())[0];
|
|
430
|
+
this.updateVoiceConnectionState({
|
|
431
|
+
mobiusSocketStatus: this.callingClient.isMobiusSocketConnected()
|
|
432
|
+
? VoiceMobiusSocketStatus.CONNECTED
|
|
433
|
+
: VoiceMobiusSocketStatus.NOT_IN_USE,
|
|
188
434
|
});
|
|
189
|
-
});
|
|
190
435
|
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
436
|
+
this.addRegistrationListener(
|
|
437
|
+
this.callingClient,
|
|
438
|
+
CALLING_CLIENT_EVENT_KEYS.MOBIUS_SOCKET_CONNECTED,
|
|
439
|
+
this.handleMobiusSocketConnected
|
|
440
|
+
);
|
|
441
|
+
this.addRegistrationListener(
|
|
442
|
+
this.callingClient,
|
|
443
|
+
CALLING_CLIENT_EVENT_KEYS.MOBIUS_SOCKET_DISCONNECTED,
|
|
444
|
+
this.handleMobiusSocketDisconnected
|
|
445
|
+
);
|
|
196
446
|
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
447
|
+
this.addRegistrationListener(this.line, LINE_EVENTS.CONNECTING, this.handleLineConnecting);
|
|
448
|
+
this.addRegistrationListener(
|
|
449
|
+
this.line,
|
|
450
|
+
LINE_EVENTS.RECONNECTING,
|
|
451
|
+
this.handleLineReconnecting
|
|
452
|
+
);
|
|
453
|
+
this.addRegistrationListener(this.line, LINE_EVENTS.RECONNECTED, this.handleLineReconnected);
|
|
454
|
+
this.addRegistrationListener(
|
|
455
|
+
this.line,
|
|
456
|
+
LINE_EVENTS.UNREGISTERED,
|
|
457
|
+
this.handleLineUnregistered
|
|
458
|
+
);
|
|
459
|
+
this.addRegistrationListener(this.line, LINE_EVENTS.ERROR, this.handleLineError);
|
|
460
|
+
|
|
461
|
+
// Start listening for incoming calls
|
|
462
|
+
this.incomingCallHandler = this.addRegistrationListener(
|
|
463
|
+
this.line,
|
|
464
|
+
LINE_EVENTS.INCOMING_CALL,
|
|
465
|
+
(call: ICall) => {
|
|
466
|
+
this.call = call;
|
|
467
|
+
this.emit(LINE_EVENTS.INCOMING_CALL, call);
|
|
468
|
+
}
|
|
469
|
+
);
|
|
201
470
|
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
471
|
+
await new Promise<void>((resolve, reject) => {
|
|
472
|
+
let timeout: ReturnType<typeof setTimeout> | undefined;
|
|
473
|
+
const finish = (): void => {
|
|
474
|
+
if (timeout) {
|
|
475
|
+
clearTimeout(timeout);
|
|
476
|
+
}
|
|
477
|
+
this.rejectRegistration = undefined;
|
|
478
|
+
if (this.registrationCompleteHandler) {
|
|
479
|
+
this.line.off(LINE_EVENTS.REGISTERED, this.registrationCompleteHandler);
|
|
480
|
+
this.registrationCompleteHandler = undefined;
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
this.rejectRegistration = (error: Error): void => {
|
|
484
|
+
finish();
|
|
485
|
+
reject(error);
|
|
486
|
+
};
|
|
487
|
+
timeout = setTimeout(() => {
|
|
488
|
+
this.lineReason = 'REGISTRATION_TIMEOUT';
|
|
489
|
+
this.lineRetryable = true;
|
|
490
|
+
this.updateVoiceConnectionState({lineStatus: VoiceLineStatus.ERROR});
|
|
491
|
+
this.rejectRegistration?.(new Error('WebCallingService Registration timed out'));
|
|
492
|
+
}, TIMEOUT_DURATION);
|
|
493
|
+
|
|
494
|
+
this.addRegistrationListener(this.line, LINE_EVENTS.REGISTERED, this.handleLineRegistered);
|
|
495
|
+
this.registrationCompleteHandler = this.addRegistrationListener(
|
|
496
|
+
this.line,
|
|
497
|
+
LINE_EVENTS.REGISTERED,
|
|
498
|
+
() => {
|
|
499
|
+
finish();
|
|
500
|
+
resolve();
|
|
501
|
+
}
|
|
207
502
|
);
|
|
208
|
-
|
|
503
|
+
|
|
504
|
+
// ILine declares register() as void, although its implementation is async.
|
|
505
|
+
Promise.resolve(this.line.register()).catch((error: LineError) => {
|
|
506
|
+
if (registrationGeneration === this.registrationGeneration) {
|
|
507
|
+
this.handleLineError(error);
|
|
508
|
+
}
|
|
509
|
+
});
|
|
209
510
|
});
|
|
210
|
-
|
|
211
|
-
|
|
511
|
+
} catch (error) {
|
|
512
|
+
if (registrationGeneration !== this.registrationGeneration) {
|
|
513
|
+
return;
|
|
514
|
+
}
|
|
515
|
+
if (this.voiceConnectionState.lineStatus !== VoiceLineStatus.ERROR) {
|
|
516
|
+
this.lineReason =
|
|
517
|
+
this.lineReason ?? (error instanceof Error ? error.message : 'REGISTRATION_FAILED');
|
|
518
|
+
this.lineRetryable = false;
|
|
519
|
+
this.updateVoiceConnectionState({lineStatus: VoiceLineStatus.ERROR});
|
|
520
|
+
}
|
|
521
|
+
throw error;
|
|
522
|
+
}
|
|
212
523
|
}
|
|
213
524
|
|
|
214
525
|
/**
|
|
@@ -224,7 +535,18 @@ export default class WebCallingService extends EventEmitter {
|
|
|
224
535
|
method: METHODS.DEREGISTER_WEB_CALLING_LINE,
|
|
225
536
|
});
|
|
226
537
|
this.cleanUpCall();
|
|
227
|
-
this.
|
|
538
|
+
await this.cleanupWebCallingRegistration();
|
|
539
|
+
this.lineReason = undefined;
|
|
540
|
+
this.lineRetryable = undefined;
|
|
541
|
+
this.socketReason = undefined;
|
|
542
|
+
this.socketRetryable = undefined;
|
|
543
|
+
this.browserVoiceRequired = false;
|
|
544
|
+
const defaultState: VoiceConnectionState = {...DEFAULT_VOICE_CONNECTION_STATE};
|
|
545
|
+
|
|
546
|
+
if (!isEqual(defaultState, this.voiceConnectionState)) {
|
|
547
|
+
this.voiceConnectionState = defaultState;
|
|
548
|
+
this.emit(VOICE_CONNECTION_EVENTS.STATE_CHANGE, this.getVoiceConnectionState());
|
|
549
|
+
}
|
|
228
550
|
}
|
|
229
551
|
|
|
230
552
|
/**
|