@webex/calling 3.12.0-webex-services-ready.4 → 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.
Files changed (124) hide show
  1. package/dist/CallRecording/WxcCallRecordingConnector.js +345 -174
  2. package/dist/CallRecording/WxcCallRecordingConnector.js.map +1 -1
  3. package/dist/CallRecording/WxcCallRecordingConnector.test.js +354 -182
  4. package/dist/CallRecording/WxcCallRecordingConnector.test.js.map +1 -1
  5. package/dist/CallRecording/callRecordingFixtures.js +40 -9
  6. package/dist/CallRecording/callRecordingFixtures.js.map +1 -1
  7. package/dist/CallRecording/constants.js +12 -27
  8. package/dist/CallRecording/constants.js.map +1 -1
  9. package/dist/CallRecording/types.js +21 -16
  10. package/dist/CallRecording/types.js.map +1 -1
  11. package/dist/CallRecording/userhub.js +117 -0
  12. package/dist/CallRecording/userhub.js.map +1 -0
  13. package/dist/CallRecording/utils.js +3 -3
  14. package/dist/CallRecording/utils.js.map +1 -1
  15. package/dist/CallingClient/CallingClient.js +19 -13
  16. package/dist/CallingClient/CallingClient.js.map +1 -1
  17. package/dist/CallingClient/CallingClient.test.js +383 -185
  18. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  19. package/dist/CallingClient/calling/CallerId/index.js +3 -1
  20. package/dist/CallingClient/calling/CallerId/index.js.map +1 -1
  21. package/dist/CallingClient/calling/CallerId/index.test.js +12 -2
  22. package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -1
  23. package/dist/CallingClient/calling/call.js +15 -8
  24. package/dist/CallingClient/calling/call.js.map +1 -1
  25. package/dist/CallingClient/calling/call.test.js +617 -527
  26. package/dist/CallingClient/calling/call.test.js.map +1 -1
  27. package/dist/CallingClient/constants.js +5 -2
  28. package/dist/CallingClient/constants.js.map +1 -1
  29. package/dist/CallingClient/line/index.js +23 -2
  30. package/dist/CallingClient/line/index.js.map +1 -1
  31. package/dist/CallingClient/line/line.test.js +87 -17
  32. package/dist/CallingClient/line/line.test.js.map +1 -1
  33. package/dist/CallingClient/registration/register.js +559 -411
  34. package/dist/CallingClient/registration/register.js.map +1 -1
  35. package/dist/CallingClient/registration/register.test.js +646 -83
  36. package/dist/CallingClient/registration/register.test.js.map +1 -1
  37. package/dist/CallingClient/registration/types.js +26 -0
  38. package/dist/CallingClient/registration/types.js.map +1 -1
  39. package/dist/CallingClient/types.js.map +1 -1
  40. package/dist/Errors/types.js +2 -0
  41. package/dist/Errors/types.js.map +1 -1
  42. package/dist/Events/types.js.map +1 -1
  43. package/dist/SDKConnector/types.js.map +1 -1
  44. package/dist/common/Utils.js +124 -105
  45. package/dist/common/Utils.js.map +1 -1
  46. package/dist/common/Utils.test.js +346 -243
  47. package/dist/common/Utils.test.js.map +1 -1
  48. package/dist/common/callUtils.js +187 -0
  49. package/dist/common/callUtils.js.map +1 -0
  50. package/dist/common/callUtils.test.js +313 -0
  51. package/dist/common/callUtils.test.js.map +1 -0
  52. package/dist/common/constants.js +27 -1
  53. package/dist/common/constants.js.map +1 -1
  54. package/dist/common/index.js +11 -0
  55. package/dist/common/index.js.map +1 -1
  56. package/dist/common/testUtil.js +2 -1
  57. package/dist/common/testUtil.js.map +1 -1
  58. package/dist/mobius-socket/mobius-socket-events.test.js +1 -0
  59. package/dist/mobius-socket/mobius-socket-events.test.js.map +1 -1
  60. package/dist/mobius-socket/mobius-socket.test.js +12 -12
  61. package/dist/mobius-socket/mobius-socket.test.js.map +1 -1
  62. package/dist/mobius-socket/socket/socket-base.js +10 -0
  63. package/dist/mobius-socket/socket/socket-base.js.map +1 -1
  64. package/dist/mobius-socket/socket.test.js +34 -14
  65. package/dist/mobius-socket/socket.test.js.map +1 -1
  66. package/dist/module/CallRecording/WxcCallRecordingConnector.js +155 -63
  67. package/dist/module/CallRecording/callRecordingFixtures.js +38 -8
  68. package/dist/module/CallRecording/constants.js +11 -12
  69. package/dist/module/CallRecording/userhub.js +100 -0
  70. package/dist/module/CallingClient/CallingClient.js +12 -11
  71. package/dist/module/CallingClient/calling/CallerId/index.js +2 -2
  72. package/dist/module/CallingClient/calling/call.js +10 -3
  73. package/dist/module/CallingClient/constants.js +3 -0
  74. package/dist/module/CallingClient/line/index.js +9 -1
  75. package/dist/module/CallingClient/registration/register.js +69 -16
  76. package/dist/module/CallingClient/registration/types.js +5 -1
  77. package/dist/module/Errors/types.js +2 -0
  78. package/dist/module/common/Utils.js +43 -43
  79. package/dist/module/common/callUtils.js +90 -0
  80. package/dist/module/common/constants.js +11 -0
  81. package/dist/module/common/index.js +1 -0
  82. package/dist/module/common/testUtil.js +1 -0
  83. package/dist/module/mobius-socket/socket/socket-base.js +8 -0
  84. package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts +6 -2
  85. package/dist/types/CallRecording/WxcCallRecordingConnector.d.ts.map +1 -1
  86. package/dist/types/CallRecording/callRecordingFixtures.d.ts +95 -4
  87. package/dist/types/CallRecording/callRecordingFixtures.d.ts.map +1 -1
  88. package/dist/types/CallRecording/constants.d.ts +11 -12
  89. package/dist/types/CallRecording/constants.d.ts.map +1 -1
  90. package/dist/types/CallRecording/types.d.ts +11 -3
  91. package/dist/types/CallRecording/types.d.ts.map +1 -1
  92. package/dist/types/CallRecording/userhub.d.ts +44 -0
  93. package/dist/types/CallRecording/userhub.d.ts.map +1 -0
  94. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  95. package/dist/types/CallingClient/calling/CallerId/index.d.ts.map +1 -1
  96. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  97. package/dist/types/CallingClient/constants.d.ts +3 -0
  98. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  99. package/dist/types/CallingClient/line/index.d.ts +2 -1
  100. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  101. package/dist/types/CallingClient/registration/register.d.ts +3 -1
  102. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  103. package/dist/types/CallingClient/registration/types.d.ts +22 -0
  104. package/dist/types/CallingClient/registration/types.d.ts.map +1 -1
  105. package/dist/types/CallingClient/types.d.ts +2 -0
  106. package/dist/types/CallingClient/types.d.ts.map +1 -1
  107. package/dist/types/Errors/types.d.ts +2 -0
  108. package/dist/types/Errors/types.d.ts.map +1 -1
  109. package/dist/types/Events/types.d.ts +1 -1
  110. package/dist/types/Events/types.d.ts.map +1 -1
  111. package/dist/types/SDKConnector/types.d.ts +1 -0
  112. package/dist/types/SDKConnector/types.d.ts.map +1 -1
  113. package/dist/types/common/Utils.d.ts +4 -6
  114. package/dist/types/common/Utils.d.ts.map +1 -1
  115. package/dist/types/common/callUtils.d.ts +6 -0
  116. package/dist/types/common/callUtils.d.ts.map +1 -0
  117. package/dist/types/common/constants.d.ts +6 -0
  118. package/dist/types/common/constants.d.ts.map +1 -1
  119. package/dist/types/common/index.d.ts +1 -0
  120. package/dist/types/common/index.d.ts.map +1 -1
  121. package/dist/types/common/testUtil.d.ts +1 -0
  122. package/dist/types/common/testUtil.d.ts.map +1 -1
  123. package/dist/types/mobius-socket/socket/socket-base.d.ts.map +1 -1
  124. package/package.json +12 -11
@@ -13,8 +13,6 @@ export const RECORDING_ONE = {
13
13
  status: RecordingStatus.AVAILABLE,
14
14
  ownerId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
15
15
  ownerEmail: 'owner@cisco.com',
16
- ownerType: 'user',
17
- storageRegion: 'US',
18
16
  serviceData: {
19
17
  locationId: 'loc-1',
20
18
  callSessionId: CALL_SESSION_ID,
@@ -32,28 +30,60 @@ export const RECORDING_TWO = {
32
30
  status: RecordingStatus.AVAILABLE,
33
31
  ownerId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
34
32
  ownerEmail: 'owner@cisco.com',
35
- ownerType: 'user',
36
- storageRegion: 'US',
37
33
  serviceData: {
38
34
  locationId: 'loc-1',
39
35
  callSessionId: 'ffffffff-9999-8888-7777-666666666666',
40
36
  },
41
37
  };
38
+ export const MOCK_USERHUB_RECORDING_ONE = {
39
+ recordUUID: RECORDING_ONE.id,
40
+ title: RECORDING_ONE.topic,
41
+ ownerID: RECORDING_ONE.ownerId,
42
+ ownerEmail: RECORDING_ONE.ownerEmail,
43
+ durationMS: 65000,
44
+ status: 'available',
45
+ format: 'MP3',
46
+ sizeByte: 1048576,
47
+ appCreateTime: '2024-05-01 10:01:05',
48
+ startRecordingTime: '2024-05-01 10:00:00',
49
+ callingData: {
50
+ locationID: 'loc-1',
51
+ callSessionID: CALL_SESSION_ID,
52
+ personality: 'originator',
53
+ callingName: 'Mark',
54
+ calledName: 'Alice',
55
+ },
56
+ recordingPlaybackLinks: {
57
+ transcriptPlaybackLink: 'https://nbr.example/transcript.txt',
58
+ audioPlaybackLink: 'https://nbr.example/audio',
59
+ },
60
+ aiAssistantData: {
61
+ suggestedNoteUrl: 'https://aibridge.example/notes',
62
+ },
63
+ };
64
+ export const MOCK_USERHUB_RECORDING_TWO = {
65
+ recordUUID: RECORDING_TWO.id,
66
+ title: RECORDING_TWO.topic,
67
+ callingData: {
68
+ locationID: 'loc-1',
69
+ callSessionID: RECORDING_TWO.serviceData?.callSessionId,
70
+ },
71
+ };
42
72
  export const MOCK_RECORDING_LIST_BODY = {
43
73
  statusCode: 200,
44
74
  body: {
45
- items: [RECORDING_ONE, RECORDING_TWO],
75
+ recordings: [MOCK_USERHUB_RECORDING_ONE, MOCK_USERHUB_RECORDING_TWO],
46
76
  },
47
77
  };
48
78
  export const MOCK_EMPTY_RECORDING_LIST_BODY = {
49
79
  statusCode: 200,
50
80
  body: {
51
- items: [],
81
+ recordings: [],
52
82
  },
53
83
  };
54
84
  export const MOCK_RECORDING_BODY = {
55
85
  statusCode: 200,
56
- body: RECORDING_ONE,
86
+ body: MOCK_USERHUB_RECORDING_ONE,
57
87
  };
58
88
  export const RECORDING_OWNER_ID = '8a67806f-fc4d-446b-a131-31e71ea5b0e9';
59
89
  export const RECORDING_REMOTE_PARTY_ID = '0fea4a63-4e27-46ee-99c3-2472cb12bf68';
@@ -95,7 +125,7 @@ export const MOCK_RECORDING_METADATA = {
95
125
  };
96
126
  export const MOCK_RECORDING_METADATA_BODY = {
97
127
  statusCode: 200,
98
- body: MOCK_RECORDING_METADATA,
128
+ body: MOCK_USERHUB_RECORDING_ONE,
99
129
  };
100
130
  export const ERROR_DETAILS_400 = {
101
131
  statusCode: 400,
@@ -1,20 +1,19 @@
1
1
  export const CALL_RECORDING_FILE = 'CallRecording';
2
- export const CONVERGED_RECORDINGS = 'convergedRecordings';
3
2
  export const SOFT_DELETE = 'softDelete';
4
- export const METADATA = 'metadata';
5
- export const FROM = 'from';
6
- export const TO = 'to';
3
+ export const USERHUB_SERVICE_NAME = 'webex-user-hub-service';
4
+ export const USERHUB_RECORDINGS_PATH = 'webappng/api/v1/hub/convergedRecordings';
5
+ export const ORDER_TYPE = 'orderType';
6
+ export const ORDER_BY = 'orderBy';
7
+ export const CATEGORY = 'category';
8
+ export const OFFSET = 'offset';
9
+ export const LIMIT = 'limit';
10
+ export const DEFAULT_ORDER_TYPE = 'DESC';
11
+ export const DEFAULT_ORDER_BY = 'appCreateTime';
12
+ export const DEFAULT_CATEGORY = 'calling';
13
+ export const DEFAULT_OFFSET = '0';
7
14
  export const STATUS = 'status';
8
- export const MAX = 'max';
9
- export const SERVICE_TYPE = 'serviceType';
10
- export const FORMAT = 'format';
11
- export const OWNER_TYPE = 'ownerType';
12
- export const STORAGE_REGION = 'storageRegion';
13
- export const LOCATION_ID = 'locationId';
14
- export const TOPIC = 'topic';
15
15
  export const DEFAULT_STATUS = 'available';
16
16
  export const DEFAULT_MAX = 30;
17
- export const DEFAULT_NUMBER_OF_DAYS = 30;
18
17
  export const WEBEX_USER_REQUEST_HEADER = 'WebexUserRequest';
19
18
  export const RECORDING_NOT_FOUND_MESSAGE = 'No recordings found for the given call session id.';
20
19
  export const METHODS = {
@@ -0,0 +1,100 @@
1
+ import { USERHUB_RECORDINGS_PATH } from './constants';
2
+ import { RecordingStatus } from './types';
3
+ export function joinUserhubRecordingsUrl(baseUrl) {
4
+ const trimmed = (baseUrl || '').replace(/\/+$/, '');
5
+ if (!trimmed) {
6
+ return '';
7
+ }
8
+ if (trimmed.includes(`/${USERHUB_RECORDINGS_PATH}`)) {
9
+ return trimmed.replace(/\/+$/, '');
10
+ }
11
+ if (trimmed.endsWith('/webappng/api/v1')) {
12
+ return `${trimmed}/hub/convergedRecordings`;
13
+ }
14
+ if (trimmed.endsWith('/webappng')) {
15
+ return `${trimmed}/api/v1/hub/convergedRecordings`;
16
+ }
17
+ return `${trimmed}/${USERHUB_RECORDINGS_PATH}`;
18
+ }
19
+ export function unwrapUserhubRecording(body) {
20
+ if (!body || typeof body !== 'object') {
21
+ return {};
22
+ }
23
+ if ('recording' in body && body.recording && typeof body.recording === 'object') {
24
+ return body.recording;
25
+ }
26
+ return body;
27
+ }
28
+ function toIsoTime(value) {
29
+ const raw = (value ?? '').trim();
30
+ if (!raw) {
31
+ return undefined;
32
+ }
33
+ const normalized = raw.includes(' ') && !raw.includes('T')
34
+ ? `${raw.replace(' ', 'T')}${/Z|[+-]\d{2}:?\d{2}$/.test(raw) ? '' : 'Z'}`
35
+ : raw;
36
+ const parsed = Date.parse(normalized);
37
+ return Number.isNaN(parsed) ? raw : new Date(parsed).toISOString();
38
+ }
39
+ function mapPersonality(value) {
40
+ const personality = (value ?? '').trim().toLowerCase();
41
+ if (personality === 'terminator' || personality === 'terminating' || personality === 'callee') {
42
+ return 'terminator';
43
+ }
44
+ if (personality === 'originator' || personality === 'originating' || personality === 'caller') {
45
+ return 'originator';
46
+ }
47
+ return undefined;
48
+ }
49
+ export function mapUserhubRecording(item) {
50
+ const id = (item.recordUUID || item.id || '').trim();
51
+ const callingData = item.callingData;
52
+ const personality = mapPersonality(callingData?.personality);
53
+ const durationSeconds = typeof item.durationSeconds === 'number'
54
+ ? item.durationSeconds
55
+ : Math.round(Number(item.durationMS ?? 0) / 1000);
56
+ return {
57
+ id,
58
+ topic: (item.title || item.topic || '').trim() || undefined,
59
+ createTime: toIsoTime(item.appCreateTime),
60
+ timeRecorded: toIsoTime(item.startRecordingTime || item.appCreateTime),
61
+ format: item.format,
62
+ serviceType: 'calling',
63
+ durationSeconds: Number.isFinite(durationSeconds) ? durationSeconds : undefined,
64
+ sizeBytes: item.sizeByte,
65
+ status: (item.status ?? '').toLowerCase() === RecordingStatus.DELETED
66
+ ? RecordingStatus.DELETED
67
+ : RecordingStatus.AVAILABLE,
68
+ ownerId: item.ownerID,
69
+ ownerEmail: item.ownerEmail,
70
+ recordingPlaybackLinks: item.recordingPlaybackLinks,
71
+ aiAssistantData: item.aiAssistantData,
72
+ serviceData: {
73
+ locationId: callingData?.locationID,
74
+ callSessionId: callingData?.callSessionID,
75
+ personality,
76
+ callingParty: {
77
+ actor: { type: callingData?.callingActorType, id: callingData?.callingActorID },
78
+ name: callingData?.callingName,
79
+ number: callingData?.callingNumber,
80
+ },
81
+ calledParty: {
82
+ actor: { type: callingData?.calledActorType, id: callingData?.calledActorID },
83
+ name: callingData?.calledName,
84
+ number: callingData?.calledNumber,
85
+ },
86
+ },
87
+ };
88
+ }
89
+ export function mapUserhubMetadata(item) {
90
+ const recording = mapUserhubRecording(item);
91
+ return {
92
+ id: recording.id,
93
+ callSessionId: recording.serviceData?.callSessionId,
94
+ owner: {
95
+ ownerID: recording.ownerId,
96
+ ownerEmail: recording.ownerEmail,
97
+ },
98
+ serviceData: recording.serviceData,
99
+ };
100
+ }
@@ -316,6 +316,9 @@ export class CallingClient extends Eventing {
316
316
  let useDefault = false;
317
317
  let clientRegion;
318
318
  let countryCode;
319
+ this.mobiusHost =
320
+ this.webex.internal.services._serviceUrls?.mobius ||
321
+ this.webex.internal.services.get(this.webex.internal.services._activeServices.mobius);
319
322
  if (this.sdkConfig?.discovery?.country && this.sdkConfig?.discovery?.region) {
320
323
  log.log('Updating region and country from the SDK config', {
321
324
  file: CALLING_CLIENT_FILE,
@@ -323,9 +326,6 @@ export class CallingClient extends Eventing {
323
326
  });
324
327
  clientRegion = this.sdkConfig?.discovery?.region;
325
328
  countryCode = this.sdkConfig?.discovery?.country;
326
- this.mobiusHost =
327
- this.webex.internal.services._serviceUrls?.mobius ||
328
- this.webex.internal.services.get(this.webex.internal.services._activeServices.mobius);
329
329
  }
330
330
  else {
331
331
  log.log('Updating region and country through Region discovery', {
@@ -341,13 +341,14 @@ export class CallingClient extends Eventing {
341
341
  file: CALLING_CLIENT_FILE,
342
342
  method: GET_MOBIUS_SERVERS_UTIL,
343
343
  });
344
- for (const mobius of this.mobiusClusters) {
345
- if (mobius.host) {
346
- this.mobiusHost = `https://${mobius.host}${API_V1}`;
347
- }
348
- else {
349
- this.mobiusHost = mobius;
350
- }
344
+ const candidateHosts = [
345
+ ...new Set([
346
+ ...(this.mobiusHost ? [this.mobiusHost] : []),
347
+ ...this.mobiusClusters.map((mobius) => mobius.host ? `https://${mobius.host}${API_V1}` : mobius),
348
+ ]),
349
+ ];
350
+ for (const host of candidateHosts) {
351
+ this.mobiusHost = host;
351
352
  try {
352
353
  const response = await this.webex.request({
353
354
  uri: `${this.mobiusHost}${URL_ENDPOINT}?regionCode=${clientRegion}&countryCode=${countryCode}`,
@@ -517,7 +518,7 @@ export class CallingClient extends Eventing {
517
518
  const backupUris = socketEnabled && this.backupWssMobiusUris.length
518
519
  ? normalizeMobiusUris(this.backupWssMobiusUris)
519
520
  : this.backupMobiusUris;
520
- const line = new Line(this.webex.internal.device.userId, this.webex.internal.device.url, this.mutex, primaryUris, backupUris, this.getLoggingLevel(), this.serviceData, this.sdkConfig?.jwe);
521
+ const line = new Line(this.webex.internal.device.userId, this.webex.internal.device.url, this.mutex, primaryUris, backupUris, this.getLoggingLevel(), this.serviceData, this.sdkConfig?.jwe, this.sdkConfig?.localAudioStream);
521
522
  this.lineDict[line.lineId] = line;
522
523
  }
523
524
  getLines() {
@@ -1,7 +1,7 @@
1
1
  import log from '../../../Logger/index';
2
2
  import { CALLER_ID_FILE, VALID_PHONE_REGEX } from '../../constants';
3
3
  import SDKConnector from '../../../SDKConnector';
4
- import { resolveCallerIdDisplay } from '../../../common';
4
+ import { resolveCallerIdDisplay, escapeScimFilterValue } from '../../../common';
5
5
  export class CallerId {
6
6
  webex;
7
7
  callerInfo;
@@ -63,7 +63,7 @@ export class CallerId {
63
63
  file: CALLER_ID_FILE,
64
64
  method: 'parseRemotePartyInfo',
65
65
  });
66
- this.resolveCallerId(`id eq "${externalId}"`);
66
+ this.resolveCallerId(`id eq "${escapeScimFilterValue(externalId)}"`);
67
67
  }
68
68
  else {
69
69
  log.warn(`externalId not found!`, {
@@ -4,7 +4,8 @@ import { v4 as uuid } from 'uuid';
4
4
  import { EffectEvent } from '@webex/media-helpers';
5
5
  import { RtcMetrics } from '@webex/internal-plugin-metrics';
6
6
  import { ERROR_LAYER, ERROR_TYPE } from '../../Errors/types';
7
- import { handleCallErrors, modifySdpForIPv4, parseMediaQualityStatistics, serviceErrorCodeHandler, uploadLogs, } from '../../common/Utils';
7
+ import { handleCallErrors, parseMediaQualityStatistics, serviceErrorCodeHandler, uploadLogs, } from '../../common/Utils';
8
+ import { getHostIpsFromSdp, modifySdpForIPv4 } from '../../common/callUtils';
8
9
  import { ALLOWED_SERVICES, CallDirection, HTTP_METHODS, } from '../../common/types';
9
10
  import { createCallError } from '../../Errors/catalog/CallError';
10
11
  import { CALL_ENDPOINT_RESOURCE, CALL_FILE, CALL_HOLD_SERVICE, CALL_STATUS_RESOURCE, CALL_TRANSFER_SERVICE, CALLING_USER_AGENT, CALLS_ENDPOINT_RESOURCE, CISCO_DEVICE_URL, DEFAULT_LOCAL_CALL_ID, DEFAULT_SESSION_TIMER, DEVICES_ENDPOINT_RESOURCE, HOLD_ENDPOINT, ICE_CANDIDATES_TIMEOUT, ICE_LITE_CANDIDATES_TIMEOUT, INITIAL_SEQ_NUMBER, MAX_CALL_KEEPALIVE_RETRY_COUNT, MEDIA_ENDPOINT_RESOURCE, METHODS, NOISE_REDUCTION_EFFECT, RESUME_ENDPOINT, SPARK_USER_AGENT, SUPPLEMENTARY_SERVICES_TIMEOUT, TRANSFER_ENDPOINT, } from '../constants';
@@ -1639,6 +1640,7 @@ export class Call extends Eventing {
1639
1640
  }
1640
1641
  }
1641
1642
  post = async (roapMessage) => {
1643
+ const hostIps = getHostIpsFromSdp(roapMessage?.sdp);
1642
1644
  const basePayload = {
1643
1645
  device: {
1644
1646
  deviceId: this.deviceId,
@@ -1648,6 +1650,7 @@ export class Call extends Eventing {
1648
1650
  roap: roapMessage,
1649
1651
  mediaId: uuid(),
1650
1652
  },
1653
+ hostIps,
1651
1654
  };
1652
1655
  return this.apiRequest.makeRequest({
1653
1656
  uri: `${this.mobiusUrl}${DEVICES_ENDPOINT_RESOURCE}/${this.deviceId}/${CALL_ENDPOINT_RESOURCE}`,
@@ -1852,6 +1855,7 @@ export class Call extends Eventing {
1852
1855
  file: CALL_FILE,
1853
1856
  method: METHODS.POST_MEDIA,
1854
1857
  });
1858
+ const hostIps = getHostIpsFromSdp(roapMessage?.sdp);
1855
1859
  return this.apiRequest.makeRequest({
1856
1860
  uri: `${this.mobiusUrl}${DEVICES_ENDPOINT_RESOURCE}/${this.deviceId}/${CALLS_ENDPOINT_RESOURCE}/${this.callId}/${MEDIA_ENDPOINT_RESOURCE}`,
1857
1861
  method: HTTP_METHODS.POST,
@@ -1870,6 +1874,7 @@ export class Call extends Eventing {
1870
1874
  roap: roapMessage,
1871
1875
  mediaId: uuid(),
1872
1876
  },
1877
+ hostIps,
1873
1878
  },
1874
1879
  });
1875
1880
  }
@@ -1910,7 +1915,7 @@ export class Call extends Eventing {
1910
1915
  registerEffectListener = (addedEffect) => {
1911
1916
  if (this.localAudioStream) {
1912
1917
  const effect = this.localAudioStream.getEffectByKind(NOISE_REDUCTION_EFFECT);
1913
- if (effect === addedEffect) {
1918
+ if (effect && effect === addedEffect) {
1914
1919
  effect.on(EffectEvent.Enabled, this.onEffectEnabled);
1915
1920
  effect.on(EffectEvent.Disabled, this.onEffectDisabled);
1916
1921
  }
@@ -1954,7 +1959,9 @@ export class Call extends Eventing {
1954
1959
  deviceId: this.deviceId,
1955
1960
  correlationId: this.correlationId,
1956
1961
  },
1957
- callId: this.callId,
1962
+ callId: this.callId.includes(DEFAULT_LOCAL_CALL_ID)
1963
+ ? this.callId.replace(`${DEFAULT_LOCAL_CALL_ID}_`, '')
1964
+ : this.callId,
1958
1965
  metrics: disconnectMetrics,
1959
1966
  causecode: this.disconnectReason.code,
1960
1967
  cause: this.disconnectReason.cause,
@@ -63,6 +63,7 @@ export const WEBEX = 'webex';
63
63
  export const WEBEX_WEB_CLIENT = 'webex-web-client';
64
64
  export const CALLER_ID_FILE = 'CallerId';
65
65
  export const UTILS_FILE = 'src/common/Utils.ts';
66
+ export const CALL_UTILS_FILE = 'src/common/callUtils.ts';
66
67
  export const CALLING_CLIENT_FILE = 'CallingClient';
67
68
  export const LINE_FILE = 'line';
68
69
  export const CALL_FILE = 'call';
@@ -132,6 +133,7 @@ export const ACTIVE_MOBIUS_STORAGE_KEY = 'wxc-active-mobius';
132
133
  export const ICE_CANDIDATES_TIMEOUT = 3000;
133
134
  export const ICE_LITE_CANDIDATES_TIMEOUT = 500;
134
135
  export const WCC_CALLING_RTMS_DOMAIN = 'wcc-calling-rtms-domain';
136
+ export const SESSION_SUPERSEDED_MESSAGE = 'This calling session has been superseded by another registration for the same user, for example calling opened in another browser tab or device. Calling is no longer available on this session.';
135
137
  export const METHODS = {
136
138
  CONSTRUCTOR: 'constructor',
137
139
  CREATE_CALL: 'createCall',
@@ -252,6 +254,7 @@ export const METHODS = {
252
254
  RESTART_REGISTRATION: 'restartRegistration',
253
255
  TRIGGER_REGISTRATION: 'triggerRegistration',
254
256
  HANDLE_404_KEEPALIVE_FAILURE: 'handle404KeepaliveFailure',
257
+ HANDLE_409_KEEPALIVE_FAILURE: 'handle409KeepaliveFailure',
255
258
  INITIATE_FAILBACK: 'initiateFailback',
256
259
  EXECUTE_FAILBACK: 'executeFailback',
257
260
  GET_RTMS_DOMAIN: 'getRTMSDomain',
@@ -8,6 +8,7 @@ import { createRegistration } from '../registration';
8
8
  import { Eventing } from '../../Events/impl';
9
9
  import { LineError } from '../../Errors/catalog/LineError';
10
10
  import { validateServiceData } from '../../common';
11
+ import { discoverHostIps } from '../../common/callUtils';
11
12
  import SDKConnector from '../../SDKConnector';
12
13
  import { LINE_EVENT_KEYS } from '../../Events/types';
13
14
  import { getCallManager } from '../calling/callManager';
@@ -37,7 +38,8 @@ export default class Line extends Eventing {
37
38
  serviceData;
38
39
  #primaryMobiusUris;
39
40
  #backupMobiusUris;
40
- constructor(userId, clientDeviceUri, mutex, primaryMobiusUris, backupMobiusUris, logLevel, serviceDataConfig, jwe, phoneNumber, extension, voicemail) {
41
+ #localAudioStream;
42
+ constructor(userId, clientDeviceUri, mutex, primaryMobiusUris, backupMobiusUris, logLevel, serviceDataConfig, jwe, localAudioStream, phoneNumber, extension, voicemail) {
41
43
  super();
42
44
  this.lineId = uuid();
43
45
  this.userId = userId;
@@ -50,6 +52,7 @@ export default class Line extends Eventing {
50
52
  this.#mutex = mutex;
51
53
  this.#primaryMobiusUris = primaryMobiusUris;
52
54
  this.#backupMobiusUris = backupMobiusUris;
55
+ this.#localAudioStream = localAudioStream;
53
56
  this.serviceData = serviceDataConfig?.indicator
54
57
  ? serviceDataConfig
55
58
  : { indicator: ServiceIndicator.CALLING, domain: '' };
@@ -64,6 +67,9 @@ export default class Line extends Eventing {
64
67
  file: LINE_FILE,
65
68
  method: METHODS.REGISTER,
66
69
  });
70
+ if (this.#localAudioStream) {
71
+ await discoverHostIps(this.#localAudioStream);
72
+ }
67
73
  await this.#mutex.runExclusive(async () => {
68
74
  this.emit(LINE_EVENTS.CONNECTING);
69
75
  this.registration.setMobiusServers(this.#primaryMobiusUris, this.#backupMobiusUris);
@@ -107,6 +113,8 @@ export default class Line extends Eventing {
107
113
  }
108
114
  break;
109
115
  case LINE_EVENTS.UNREGISTERED:
116
+ this.emit(event, lineError);
117
+ break;
110
118
  case LINE_EVENTS.RECONNECTED:
111
119
  case LINE_EVENTS.RECONNECTING:
112
120
  this.emit(event);
@@ -1,14 +1,16 @@
1
1
  import { METHOD_START_MESSAGE } from '../../common/constants';
2
- import { emitFinalFailure, handleRegistrationErrors, uploadLogs } from '../../common';
2
+ import { emitFinalFailure, getHostIps, handleRegistrationErrors, uploadLogs } from '../../common';
3
3
  import webWorkerStr from './webWorkerStr';
4
4
  import { METRIC_EVENT, METRIC_TYPE, REG_ACTION, } from '../../Metrics/types';
5
5
  import { getMetricManager } from '../../Metrics';
6
6
  import { getCallManager } from '../calling';
7
7
  import log from '../../Logger';
8
+ import { HARD_STOP_REASON } from './types';
8
9
  import SDKConnector from '../../SDKConnector';
9
10
  import { ALLOWED_SERVICES, HTTP_METHODS, RegistrationStatus, ServiceIndicator, WorkerMessageType, } from '../../common/types';
10
- import { CALLING_USER_AGENT, CISCO_DEVICE_URL, DEVICES_ENDPOINT_RESOURCE, SPARK_USER_AGENT, BASE_REG_RETRY_TIMER_VAL_IN_SEC, BASE_REG_TIMER_MFACTOR, SEC_TO_MSEC_MFACTOR, REG_RANDOM_T_FACTOR_UPPER_LIMIT, REG_TRY_BACKUP_TIMER_VAL_IN_SEC, MINUTES_TO_SEC_MFACTOR, REG_429_RETRY_UTIL, REG_FAILBACK_429_MAX_RETRIES, FAILBACK_UTIL, REGISTRATION_FILE, DEFAULT_REHOMING_INTERVAL_MIN, DEFAULT_REHOMING_INTERVAL_MAX, DEFAULT_KEEPALIVE_INTERVAL, FAILOVER_UTIL, REGISTER_UTIL, RETRY_TIMER_UPPER_LIMIT, KEEPALIVE_UTIL, REGISTRATION_UTIL, METHODS, URL_ENDPOINT, RECONNECT_ON_FAILURE_UTIL, FAILOVER_CACHE_PREFIX, } from '../constants';
11
+ import { CALLING_USER_AGENT, CISCO_DEVICE_URL, DEVICES_ENDPOINT_RESOURCE, SPARK_USER_AGENT, BASE_REG_RETRY_TIMER_VAL_IN_SEC, BASE_REG_TIMER_MFACTOR, SEC_TO_MSEC_MFACTOR, REG_RANDOM_T_FACTOR_UPPER_LIMIT, REG_TRY_BACKUP_TIMER_VAL_IN_SEC, MINUTES_TO_SEC_MFACTOR, REG_429_RETRY_UTIL, FAILBACK_UTIL, REGISTRATION_FILE, DEFAULT_REHOMING_INTERVAL_MIN, DEFAULT_REHOMING_INTERVAL_MAX, DEFAULT_KEEPALIVE_INTERVAL, FAILOVER_UTIL, REGISTER_UTIL, RETRY_TIMER_UPPER_LIMIT, KEEPALIVE_UTIL, REGISTRATION_UTIL, METHODS, URL_ENDPOINT, RECONNECT_ON_FAILURE_UTIL, FAILOVER_CACHE_PREFIX, REG_FAILBACK_429_MAX_RETRIES, } from '../constants';
11
12
  import { LINE_EVENTS } from '../line/types';
13
+ import { ERROR_CODE } from '../../Errors/types';
12
14
  import { APIRequest } from '../utils/request';
13
15
  export class Registration {
14
16
  sdkConnector;
@@ -36,6 +38,7 @@ export class Registration {
36
38
  retryAfter;
37
39
  scheduled429Retry = false;
38
40
  webWorker;
41
+ sessionSuperseded = false;
39
42
  apiRequest;
40
43
  constructor(webex, serviceData, mutex, lineEmitter, logLevel, jwe) {
41
44
  this.jwe = jwe;
@@ -167,10 +170,12 @@ export class Registration {
167
170
  return response;
168
171
  }
169
172
  async postRegistration(url) {
173
+ const hostIps = getHostIps();
170
174
  const deviceInfo = {
171
175
  userId: this.userId,
172
176
  clientDeviceUri: this.webex.internal.device.url,
173
177
  serviceData: this.jwe ? { ...this.serviceData, jwe: this.jwe } : this.serviceData,
178
+ hostIps,
174
179
  };
175
180
  return this.apiRequest.makeRequest({
176
181
  uri: `${url}device`,
@@ -241,6 +246,21 @@ export class Registration {
241
246
  }
242
247
  }
243
248
  }
249
+ async handle409KeepaliveFailure(lineError, error, serverType, keepaliveRetryCount) {
250
+ const loggerContext = {
251
+ file: REGISTRATION_FILE,
252
+ method: METHODS.HANDLE_409_KEEPALIVE_FAILURE,
253
+ };
254
+ this.sessionSuperseded = true;
255
+ log.warn(`Stopping keepalive without re-registration, session superseded by another device for this user - keepaliveRetryCount: ${keepaliveRetryCount}`, loggerContext);
256
+ this.clearKeepaliveTimer();
257
+ this.metricManager.submitRegistrationMetric(METRIC_EVENT.KEEPALIVE_ERROR, REG_ACTION.KEEPALIVE_FAILURE, METRIC_TYPE.BEHAVIORAL, METHODS.HANDLE_409_KEEPALIVE_FAILURE, serverType, error.headers?.trackingid ?? '', keepaliveRetryCount, lineError);
258
+ await this.registrationCleanup(METHODS.HANDLE_409_KEEPALIVE_FAILURE, {
259
+ reason: HARD_STOP_REASON.SESSION_SUPERSEDED,
260
+ error: lineError,
261
+ });
262
+ await uploadLogs();
263
+ }
244
264
  async handle429Retry(retryAfter, caller) {
245
265
  if (caller === FAILBACK_UTIL) {
246
266
  if (this.failback429RetryAttempts >= REG_FAILBACK_429_MAX_RETRIES) {
@@ -589,6 +609,7 @@ export class Registration {
589
609
  method: METHODS.TRIGGER_REGISTRATION,
590
610
  };
591
611
  log.info(METHOD_START_MESSAGE, loggerContext);
612
+ this.sessionSuperseded = false;
592
613
  if (await this.resumeFailover()) {
593
614
  log.info('Registration trigger handled by resumeFailover path', loggerContext);
594
615
  return;
@@ -609,6 +630,13 @@ export class Registration {
609
630
  file: REGISTRATION_FILE,
610
631
  method: REGISTER_UTIL,
611
632
  };
633
+ if (this.sessionSuperseded) {
634
+ log.warn(`Session superseded, skipping registration attempt - caller: ${caller}`, {
635
+ file: REGISTRATION_FILE,
636
+ method: caller,
637
+ });
638
+ return true;
639
+ }
612
640
  let abort = false;
613
641
  this.retryAfter = undefined;
614
642
  let connectedWebSocketUrl;
@@ -660,7 +688,10 @@ export class Registration {
660
688
  this.lineEmitter(LINE_EVENTS.UNREGISTERED);
661
689
  }
662
690
  this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION_ERROR, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, caller, serverType, body.headers?.trackingid ?? '', undefined, clientError);
663
- }, { method: caller, file: REGISTRATION_FILE }, (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller), this.restoreRegistrationCallBack(), servers.length);
691
+ }, { method: caller, file: REGISTRATION_FILE }, {
692
+ retry429Cb: (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller),
693
+ restoreRegCb: this.restoreRegistrationCallBack(),
694
+ }, servers.length);
664
695
  abort = finalError;
665
696
  if (this.registrationStatus === RegistrationStatus.ACTIVE) {
666
697
  log.info(`[${caller}] : Device is already restored, active mobius url: ${this.activeMobiusUrl}`, loggerContext);
@@ -692,22 +723,32 @@ export class Registration {
692
723
  if (!this.webWorker) {
693
724
  const blob = new Blob([webWorkerStr], { type: 'application/javascript' });
694
725
  const blobUrl = URL.createObjectURL(blob);
695
- this.webWorker = new Worker(blobUrl);
726
+ const worker = new Worker(blobUrl);
727
+ this.webWorker = worker;
696
728
  URL.revokeObjectURL(blobUrl);
697
- this.webWorker.postMessage({
729
+ worker.postMessage({
698
730
  type: WorkerMessageType.START_KEEPALIVE,
699
731
  interval,
700
732
  retryCountThreshold: RETRY_COUNT_THRESHOLD,
701
733
  });
702
- this.webWorker.onmessage = async (event) => {
734
+ const isCurrentWorker = () => this.webWorker === worker;
735
+ worker.onmessage = async (event) => {
703
736
  const logContext = {
704
737
  file: REGISTRATION_FILE,
705
738
  method: KEEPALIVE_UTIL,
706
739
  };
740
+ if (!isCurrentWorker()) {
741
+ log.info('Ignoring message from a replaced keepalive worker', logContext);
742
+ return;
743
+ }
707
744
  if (event.data.type === WorkerMessageType.SEND_KEEPALIVE) {
708
745
  try {
709
746
  const res = await this.postKeepAlive(String(this.webex.internal.device.url), url);
710
- this.webWorker?.postMessage({
747
+ if (!isCurrentWorker()) {
748
+ log.info('Discarding keepalive result of a replaced worker', logContext);
749
+ return;
750
+ }
751
+ worker.postMessage({
711
752
  type: WorkerMessageType.KEEPALIVE_RESULT,
712
753
  statusCode: res.statusCode,
713
754
  });
@@ -722,7 +763,11 @@ export class Registration {
722
763
  statusText: err.statusText,
723
764
  type: err.type,
724
765
  };
725
- this.webWorker?.postMessage({
766
+ if (!isCurrentWorker()) {
767
+ log.info(`Discarding keepalive failure of a replaced worker, status -> ${error.statusCode}`, logContext);
768
+ return;
769
+ }
770
+ worker.postMessage({
726
771
  type: WorkerMessageType.KEEPALIVE_RESULT,
727
772
  err: error,
728
773
  });
@@ -740,7 +785,13 @@ export class Registration {
740
785
  this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
741
786
  }
742
787
  this.metricManager.submitRegistrationMetric(METRIC_EVENT.KEEPALIVE_ERROR, REG_ACTION.KEEPALIVE_FAILURE, METRIC_TYPE.BEHAVIORAL, KEEPALIVE_UTIL, serverType, error.headers?.trackingid ?? '', event.data.keepAliveRetryCount, clientError);
743
- }, { method: KEEPALIVE_UTIL, file: REGISTRATION_FILE }, (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller));
788
+ }, { method: KEEPALIVE_UTIL, file: REGISTRATION_FILE }, {
789
+ retry429Cb: (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller),
790
+ sessionSupersededCb: (clientError) => this.handle409KeepaliveFailure(clientError, error, serverType, event.data.keepAliveRetryCount),
791
+ });
792
+ if (abort && Number(error.statusCode) === ERROR_CODE.CONFLICT) {
793
+ return;
794
+ }
744
795
  if (abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD) {
745
796
  this.failoverImmediately = this.isCCFlow;
746
797
  this.setStatus(RegistrationStatus.INACTIVE);
@@ -852,14 +903,16 @@ export class Registration {
852
903
  log.info(`Registration down received - trackingId: ${event?.trackingId ?? 'unknown'}, eventId: ${event?.eventId ?? 'unknown'}`, loggerContext);
853
904
  const [activeCall] = Object.values(this.callManager.getActiveCalls());
854
905
  activeCall?.end();
855
- await this.performRegistrationDownCleanup(METHODS.HANDLE_REGISTRATION_DOWN_EVENT);
906
+ await this.registrationCleanup(METHODS.HANDLE_REGISTRATION_DOWN_EVENT, {
907
+ reason: HARD_STOP_REASON.REGISTRATION_DOWN,
908
+ });
856
909
  }
857
- async performRegistrationDownCleanup(caller) {
910
+ async registrationCleanup(caller, hardStop) {
858
911
  const loggerContext = {
859
912
  file: REGISTRATION_FILE,
860
- method: METHODS.HANDLE_REGISTRATION_DOWN_EVENT,
913
+ method: caller,
861
914
  };
862
- log.info(`[${caller}] : Running registration-down cleanup`, loggerContext);
915
+ log.info(`[${caller}] : Running ${hardStop.reason} cleanup`, loggerContext);
863
916
  await this.mutex.runExclusive(async () => {
864
917
  this.clearFailbackTimer();
865
918
  this.clearKeepaliveTimer();
@@ -876,13 +929,13 @@ export class Registration {
876
929
  code: 3050,
877
930
  reason: 'done (permanent)',
878
931
  });
879
- log.log('Mobius socket disconnect complete after registration-down', loggerContext);
932
+ log.log(`Mobius socket disconnect complete after ${hardStop.reason}`, loggerContext);
880
933
  }
881
934
  catch (err) {
882
- log.warn(`Mobius socket disconnect failed after registration-down: ${String(err)}`, loggerContext);
935
+ log.warn(`Mobius socket disconnect failed after ${hardStop.reason}: ${String(err)}`, loggerContext);
883
936
  }
884
937
  }
885
- this.lineEmitter(LINE_EVENTS.UNREGISTERED);
938
+ this.lineEmitter(LINE_EVENTS.UNREGISTERED, undefined, hardStop.error);
886
939
  });
887
940
  }
888
941
  }
@@ -1 +1,5 @@
1
- export {};
1
+ export var HARD_STOP_REASON;
2
+ (function (HARD_STOP_REASON) {
3
+ HARD_STOP_REASON["REGISTRATION_DOWN"] = "registration-down";
4
+ HARD_STOP_REASON["SESSION_SUPERSEDED"] = "session-superseded";
5
+ })(HARD_STOP_REASON || (HARD_STOP_REASON = {}));
@@ -12,6 +12,7 @@ export var ERROR_TYPE;
12
12
  ERROR_TYPE["NOT_FOUND"] = "not_found";
13
13
  ERROR_TYPE["REGISTRATION_ERROR"] = "registration_error";
14
14
  ERROR_TYPE["SERVICE_UNAVAILABLE"] = "service_unavailable";
15
+ ERROR_TYPE["SESSION_SUPERSEDED"] = "session_superseded";
15
16
  ERROR_TYPE["TIMEOUT"] = "timeout";
16
17
  ERROR_TYPE["TOKEN_ERROR"] = "token_error";
17
18
  ERROR_TYPE["TOO_MANY_REQUESTS"] = "too_many_requests";
@@ -22,6 +23,7 @@ export var ERROR_CODE;
22
23
  ERROR_CODE[ERROR_CODE["UNAUTHORIZED"] = 401] = "UNAUTHORIZED";
23
24
  ERROR_CODE[ERROR_CODE["FORBIDDEN"] = 403] = "FORBIDDEN";
24
25
  ERROR_CODE[ERROR_CODE["DEVICE_NOT_FOUND"] = 404] = "DEVICE_NOT_FOUND";
26
+ ERROR_CODE[ERROR_CODE["CONFLICT"] = 409] = "CONFLICT";
25
27
  ERROR_CODE[ERROR_CODE["INTERNAL_SERVER_ERROR"] = 500] = "INTERNAL_SERVER_ERROR";
26
28
  ERROR_CODE[ERROR_CODE["NOT_IMPLEMENTED"] = 501] = "NOT_IMPLEMENTED";
27
29
  ERROR_CODE[ERROR_CODE["SERVICE_UNAVAILABLE"] = 503] = "SERVICE_UNAVAILABLE";