@webex/calling 3.9.0 → 3.10.0-multi-llms.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 (192) hide show
  1. package/dist/CallHistory/CallHistory.js +43 -43
  2. package/dist/CallHistory/CallHistory.js.map +1 -1
  3. package/dist/CallHistory/CallHistory.test.js +157 -152
  4. package/dist/CallHistory/CallHistory.test.js.map +1 -1
  5. package/dist/CallHistory/callHistoryFixtures.js.map +1 -1
  6. package/dist/CallHistory/constants.js.map +1 -1
  7. package/dist/CallHistory/types.js.map +1 -1
  8. package/dist/CallSettings/CallSettings.js +8 -8
  9. package/dist/CallSettings/CallSettings.js.map +1 -1
  10. package/dist/CallSettings/CallSettings.test.js +1 -1
  11. package/dist/CallSettings/CallSettings.test.js.map +1 -1
  12. package/dist/CallSettings/UcmBackendConnector.js +12 -11
  13. package/dist/CallSettings/UcmBackendConnector.js.map +1 -1
  14. package/dist/CallSettings/UcmBackendConnector.test.js +11 -11
  15. package/dist/CallSettings/UcmBackendConnector.test.js.map +1 -1
  16. package/dist/CallSettings/WxCallBackendConnector.js +53 -52
  17. package/dist/CallSettings/WxCallBackendConnector.js.map +1 -1
  18. package/dist/CallSettings/WxCallBackendConnector.test.js +112 -110
  19. package/dist/CallSettings/WxCallBackendConnector.test.js.map +1 -1
  20. package/dist/CallSettings/constants.js.map +1 -1
  21. package/dist/CallSettings/testFixtures.js.map +1 -1
  22. package/dist/CallSettings/types.js.map +1 -1
  23. package/dist/CallingClient/CallingClient.js +458 -203
  24. package/dist/CallingClient/CallingClient.js.map +1 -1
  25. package/dist/CallingClient/CallingClient.test.js +458 -315
  26. package/dist/CallingClient/CallingClient.test.js.map +1 -1
  27. package/dist/CallingClient/callRecordFixtures.js.map +1 -1
  28. package/dist/CallingClient/calling/CallerId/index.js +2 -2
  29. package/dist/CallingClient/calling/CallerId/index.js.map +1 -1
  30. package/dist/CallingClient/calling/CallerId/index.test.js +8 -7
  31. package/dist/CallingClient/calling/CallerId/index.test.js.map +1 -1
  32. package/dist/CallingClient/calling/CallerId/types.js.map +1 -1
  33. package/dist/CallingClient/calling/call.js +406 -373
  34. package/dist/CallingClient/calling/call.js.map +1 -1
  35. package/dist/CallingClient/calling/call.test.js +482 -415
  36. package/dist/CallingClient/calling/call.test.js.map +1 -1
  37. package/dist/CallingClient/calling/callManager.js +3 -4
  38. package/dist/CallingClient/calling/callManager.js.map +1 -1
  39. package/dist/CallingClient/calling/callManager.test.js +68 -69
  40. package/dist/CallingClient/calling/callManager.test.js.map +1 -1
  41. package/dist/CallingClient/calling/index.js.map +1 -1
  42. package/dist/CallingClient/calling/types.js.map +1 -1
  43. package/dist/CallingClient/callingClientFixtures.js.map +1 -1
  44. package/dist/CallingClient/constants.js +9 -6
  45. package/dist/CallingClient/constants.js.map +1 -1
  46. package/dist/CallingClient/line/index.js +10 -11
  47. package/dist/CallingClient/line/index.js.map +1 -1
  48. package/dist/CallingClient/line/line.test.js +10 -9
  49. package/dist/CallingClient/line/line.test.js.map +1 -1
  50. package/dist/CallingClient/line/types.js.map +1 -1
  51. package/dist/CallingClient/registration/index.js.map +1 -1
  52. package/dist/CallingClient/registration/register.js +285 -205
  53. package/dist/CallingClient/registration/register.js.map +1 -1
  54. package/dist/CallingClient/registration/register.test.js +251 -180
  55. package/dist/CallingClient/registration/register.test.js.map +1 -1
  56. package/dist/CallingClient/registration/registerFixtures.js.map +1 -1
  57. package/dist/CallingClient/registration/types.js.map +1 -1
  58. package/dist/CallingClient/registration/webWorker.js +25 -10
  59. package/dist/CallingClient/registration/webWorker.js.map +1 -1
  60. package/dist/CallingClient/registration/webWorker.test.js +85 -38
  61. package/dist/CallingClient/registration/webWorker.test.js.map +1 -1
  62. package/dist/CallingClient/registration/webWorkerStr.js +1 -1
  63. package/dist/CallingClient/registration/webWorkerStr.js.map +1 -1
  64. package/dist/CallingClient/types.js.map +1 -1
  65. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js +142 -0
  66. package/dist/CallingClient/windowsChromiumIceWarmupUtils.js.map +1 -0
  67. package/dist/Contacts/ContactsClient.js +244 -247
  68. package/dist/Contacts/ContactsClient.js.map +1 -1
  69. package/dist/Contacts/ContactsClient.test.js +93 -93
  70. package/dist/Contacts/ContactsClient.test.js.map +1 -1
  71. package/dist/Contacts/constants.js +2 -2
  72. package/dist/Contacts/constants.js.map +1 -1
  73. package/dist/Contacts/contactFixtures.js.map +1 -1
  74. package/dist/Contacts/types.js.map +1 -1
  75. package/dist/Errors/catalog/CallError.js +2 -2
  76. package/dist/Errors/catalog/CallError.js.map +1 -1
  77. package/dist/Errors/catalog/CallingDeviceError.js +2 -2
  78. package/dist/Errors/catalog/CallingDeviceError.js.map +1 -1
  79. package/dist/Errors/catalog/ExtendedError.js +3 -3
  80. package/dist/Errors/catalog/ExtendedError.js.map +1 -1
  81. package/dist/Errors/catalog/LineError.js +2 -2
  82. package/dist/Errors/catalog/LineError.js.map +1 -1
  83. package/dist/Errors/index.js.map +1 -1
  84. package/dist/Errors/types.js.map +1 -1
  85. package/dist/Events/impl/index.js +3 -3
  86. package/dist/Events/impl/index.js.map +1 -1
  87. package/dist/Events/types.js.map +1 -1
  88. package/dist/Logger/index.js +3 -3
  89. package/dist/Logger/index.js.map +1 -1
  90. package/dist/Logger/index.test.js +1 -1
  91. package/dist/Logger/index.test.js.map +1 -1
  92. package/dist/Logger/types.js.map +1 -1
  93. package/dist/Metrics/index.js +221 -104
  94. package/dist/Metrics/index.js.map +1 -1
  95. package/dist/Metrics/index.test.js +112 -23
  96. package/dist/Metrics/index.test.js.map +1 -1
  97. package/dist/Metrics/types.js +15 -1
  98. package/dist/Metrics/types.js.map +1 -1
  99. package/dist/SDKConnector/index.js +0 -1
  100. package/dist/SDKConnector/index.js.map +1 -1
  101. package/dist/SDKConnector/index.test.js.map +1 -1
  102. package/dist/SDKConnector/types.js.map +1 -1
  103. package/dist/SDKConnector/utils.js.map +1 -1
  104. package/dist/SDKConnector/utils.test.js.map +1 -1
  105. package/dist/Voicemail/BroadworksBackendConnector.js +55 -61
  106. package/dist/Voicemail/BroadworksBackendConnector.js.map +1 -1
  107. package/dist/Voicemail/BroadworksBackendConnector.test.js +129 -122
  108. package/dist/Voicemail/BroadworksBackendConnector.test.js.map +1 -1
  109. package/dist/Voicemail/UcmBackendConnector.js +53 -50
  110. package/dist/Voicemail/UcmBackendConnector.js.map +1 -1
  111. package/dist/Voicemail/UcmBackendConnector.test.js +73 -74
  112. package/dist/Voicemail/UcmBackendConnector.test.js.map +1 -1
  113. package/dist/Voicemail/Voicemail.js +89 -113
  114. package/dist/Voicemail/Voicemail.js.map +1 -1
  115. package/dist/Voicemail/Voicemail.test.js +2 -2
  116. package/dist/Voicemail/Voicemail.test.js.map +1 -1
  117. package/dist/Voicemail/WxCallBackendConnector.js +87 -92
  118. package/dist/Voicemail/WxCallBackendConnector.js.map +1 -1
  119. package/dist/Voicemail/WxCallBackendConnector.test.js +228 -203
  120. package/dist/Voicemail/WxCallBackendConnector.test.js.map +1 -1
  121. package/dist/Voicemail/constants.js.map +1 -1
  122. package/dist/Voicemail/types.js.map +1 -1
  123. package/dist/Voicemail/voicemailFixture.js.map +1 -1
  124. package/dist/api.js.map +1 -1
  125. package/dist/common/Utils.js +85 -66
  126. package/dist/common/Utils.js.map +1 -1
  127. package/dist/common/Utils.test.js +113 -123
  128. package/dist/common/Utils.test.js.map +1 -1
  129. package/dist/common/constants.js.map +1 -1
  130. package/dist/common/index.js.map +1 -1
  131. package/dist/common/testUtil.js +1 -1
  132. package/dist/common/testUtil.js.map +1 -1
  133. package/dist/common/types.js.map +1 -1
  134. package/dist/index.js +5 -5
  135. package/dist/index.js.map +1 -1
  136. package/dist/module/CallHistory/CallHistory.js +17 -8
  137. package/dist/module/CallSettings/UcmBackendConnector.js +2 -2
  138. package/dist/module/CallSettings/WxCallBackendConnector.js +14 -14
  139. package/dist/module/CallingClient/CallingClient.js +176 -36
  140. package/dist/module/CallingClient/calling/call.js +92 -62
  141. package/dist/module/CallingClient/constants.js +8 -4
  142. package/dist/module/CallingClient/line/index.js +3 -3
  143. package/dist/module/CallingClient/registration/register.js +37 -13
  144. package/dist/module/CallingClient/registration/webWorker.js +17 -3
  145. package/dist/module/CallingClient/registration/webWorkerStr.js +19 -3
  146. package/dist/module/CallingClient/windowsChromiumIceWarmupUtils.js +59 -0
  147. package/dist/module/Contacts/ContactsClient.js +33 -37
  148. package/dist/module/Contacts/constants.js +1 -1
  149. package/dist/module/Events/impl/index.js +1 -1
  150. package/dist/module/Logger/index.js +2 -2
  151. package/dist/module/Metrics/index.js +142 -55
  152. package/dist/module/Metrics/types.js +14 -0
  153. package/dist/module/Voicemail/BroadworksBackendConnector.js +10 -17
  154. package/dist/module/Voicemail/UcmBackendConnector.js +11 -10
  155. package/dist/module/Voicemail/Voicemail.js +42 -68
  156. package/dist/module/Voicemail/WxCallBackendConnector.js +22 -28
  157. package/dist/module/common/Utils.js +29 -12
  158. package/dist/types/CallHistory/CallHistory.d.ts.map +1 -1
  159. package/dist/types/CallSettings/UcmBackendConnector.d.ts.map +1 -1
  160. package/dist/types/CallSettings/WxCallBackendConnector.d.ts.map +1 -1
  161. package/dist/types/CallingClient/CallingClient.d.ts +12 -1
  162. package/dist/types/CallingClient/CallingClient.d.ts.map +1 -1
  163. package/dist/types/CallingClient/calling/call.d.ts.map +1 -1
  164. package/dist/types/CallingClient/calling/types.d.ts +2 -1
  165. package/dist/types/CallingClient/calling/types.d.ts.map +1 -1
  166. package/dist/types/CallingClient/constants.d.ts +8 -4
  167. package/dist/types/CallingClient/constants.d.ts.map +1 -1
  168. package/dist/types/CallingClient/line/index.d.ts.map +1 -1
  169. package/dist/types/CallingClient/registration/register.d.ts +1 -0
  170. package/dist/types/CallingClient/registration/register.d.ts.map +1 -1
  171. package/dist/types/CallingClient/registration/webWorker.d.ts +2 -1
  172. package/dist/types/CallingClient/registration/webWorker.d.ts.map +1 -1
  173. package/dist/types/CallingClient/registration/webWorkerStr.d.ts +1 -1
  174. package/dist/types/CallingClient/registration/webWorkerStr.d.ts.map +1 -1
  175. package/dist/types/CallingClient/windowsChromiumIceWarmupUtils.d.ts +5 -0
  176. package/dist/types/CallingClient/windowsChromiumIceWarmupUtils.d.ts.map +1 -0
  177. package/dist/types/Contacts/ContactsClient.d.ts.map +1 -1
  178. package/dist/types/Contacts/constants.d.ts +1 -1
  179. package/dist/types/Contacts/constants.d.ts.map +1 -1
  180. package/dist/types/Logger/index.d.ts +1 -2
  181. package/dist/types/Logger/index.d.ts.map +1 -1
  182. package/dist/types/Metrics/index.d.ts.map +1 -1
  183. package/dist/types/Metrics/types.d.ts +18 -3
  184. package/dist/types/Metrics/types.d.ts.map +1 -1
  185. package/dist/types/Voicemail/BroadworksBackendConnector.d.ts.map +1 -1
  186. package/dist/types/Voicemail/UcmBackendConnector.d.ts.map +1 -1
  187. package/dist/types/Voicemail/Voicemail.d.ts.map +1 -1
  188. package/dist/types/Voicemail/WxCallBackendConnector.d.ts.map +1 -1
  189. package/dist/types/common/Utils.d.ts.map +1 -1
  190. package/dist/types/common/types.d.ts +1 -0
  191. package/dist/types/common/types.d.ts.map +1 -1
  192. package/package.json +10 -8
@@ -88,10 +88,11 @@ export class Registration {
88
88
  });
89
89
  }
90
90
  catch (error) {
91
- log.warn(`Delete failed with Mobius ${error}`, {
91
+ log.warn(`Delete failed with Mobius: ${JSON.stringify(error)}`, {
92
92
  file: REGISTRATION_FILE,
93
- method: METHODS.DEREGISTER,
93
+ method: METHODS.DELETE_REGISTRATION,
94
94
  });
95
+ await uploadLogs();
95
96
  }
96
97
  this.setStatus(RegistrationStatus.INACTIVE);
97
98
  this.lineEmitter(LINE_EVENTS.UNREGISTERED);
@@ -121,6 +122,14 @@ export class Registration {
121
122
  }
122
123
  return abort;
123
124
  }
125
+ async handle404KeepaliveFailure(caller) {
126
+ if (caller === KEEPALIVE_UTIL) {
127
+ const abort = await this.attemptRegistrationWithServers(caller);
128
+ if (!abort && !this.isDeviceRegistered()) {
129
+ await this.startFailoverTimer();
130
+ }
131
+ }
132
+ }
124
133
  async handle429Retry(retryAfter, caller) {
125
134
  if (caller === FAILBACK_UTIL) {
126
135
  if (this.failback429RetryAttempts >= REG_FAILBACK_429_MAX_RETRIES) {
@@ -140,6 +149,16 @@ export class Registration {
140
149
  await this.restartRegistration(REG_429_RETRY_UTIL);
141
150
  }
142
151
  }
152
+ else if (caller === KEEPALIVE_UTIL) {
153
+ this.clearKeepaliveTimer();
154
+ setTimeout(async () => {
155
+ log.log(`Resuming keepalive after ${retryAfter} seconds`, {
156
+ file: REGISTRATION_FILE,
157
+ method: REG_429_RETRY_UTIL,
158
+ });
159
+ await this.startKeepaliveTimer(this.deviceInfo.device?.uri, this.deviceInfo.keepaliveInterval, 'UNKNOWN');
160
+ }, retryAfter * 1000);
161
+ }
143
162
  else {
144
163
  this.retryAfter = retryAfter;
145
164
  }
@@ -243,7 +262,7 @@ export class Registration {
243
262
  }
244
263
  }
245
264
  catch (error) {
246
- log.warn(`Ping failed for primary Mobius: ${mobiusUrl} with error: ${error}`, {
265
+ log.warn(`Ping failed for primary Mobius: ${mobiusUrl} with error: ${JSON.stringify(error)}`, {
247
266
  file: REGISTRATION_FILE,
248
267
  method: FAILBACK_UTIL,
249
268
  });
@@ -354,18 +373,18 @@ export class Registration {
354
373
  });
355
374
  await this.mutex.runExclusive(async () => {
356
375
  if (retry) {
357
- log.log('Mercury connection is up again, re-registering with Webex Calling if needed', {
376
+ log.log('Network is up again, re-registering with Webex Calling if needed', {
358
377
  file: REGISTRATION_FILE,
359
- method: this.handleConnectionRestoration.name,
378
+ method: METHODS.HANDLE_CONNECTION_RESTORATION,
360
379
  });
361
380
  this.clearKeepaliveTimer();
362
381
  if (this.isDeviceRegistered()) {
363
382
  await this.deregister();
364
383
  }
365
384
  if (this.activeMobiusUrl) {
366
- const abort = await this.restorePreviousRegistration(this.handleConnectionRestoration.name);
385
+ const abort = await this.restorePreviousRegistration(METHODS.HANDLE_CONNECTION_RESTORATION);
367
386
  if (!abort && !this.isDeviceRegistered()) {
368
- await this.restartRegistration(this.handleConnectionRestoration.name);
387
+ await this.restartRegistration(METHODS.HANDLE_CONNECTION_RESTORATION);
369
388
  }
370
389
  }
371
390
  retry = false;
@@ -433,12 +452,12 @@ export class Registration {
433
452
  const resp = await this.postRegistration(url);
434
453
  this.deviceInfo = resp.body;
435
454
  this.registrationStatus = RegistrationStatus.ACTIVE;
455
+ this.setActiveMobiusUrl(url);
436
456
  this.lineEmitter(LINE_EVENTS.REGISTERED, resp.body);
437
- log.log(`Registration successful for deviceId: ${this.deviceInfo.device?.deviceId} userId: ${this.userId}`, {
457
+ log.log(`Registration successful for deviceId: ${this.deviceInfo.device?.deviceId} userId: ${this.userId} responseTrackingId: ${resp.headers?.trackingid}`, {
438
458
  file: REGISTRATION_FILE,
439
459
  method: METHODS.REGISTER,
440
460
  });
441
- this.setActiveMobiusUrl(url);
442
461
  this.setIntervalValues(this.deviceInfo);
443
462
  this.metricManager.setDeviceInfo(this.deviceInfo);
444
463
  this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION, REG_ACTION.REGISTER, METRIC_TYPE.BEHAVIORAL, caller, serverType, resp.headers?.trackingid ?? '', undefined, undefined);
@@ -466,6 +485,7 @@ export class Registration {
466
485
  }
467
486
  if (abort) {
468
487
  this.setStatus(RegistrationStatus.INACTIVE);
488
+ await uploadLogs();
469
489
  break;
470
490
  }
471
491
  }
@@ -494,7 +514,7 @@ export class Registration {
494
514
  this.webWorker.onmessage = async (event) => {
495
515
  const logContext = {
496
516
  file: REGISTRATION_FILE,
497
- method: this.startKeepaliveTimer.name,
517
+ method: KEEPALIVE_UTIL,
498
518
  };
499
519
  if (event.data.type === WorkerMessageType.KEEPALIVE_SUCCESS) {
500
520
  log.info(`Sent Keepalive, status: ${event.data.statusCode}`, logContext);
@@ -507,17 +527,21 @@ export class Registration {
507
527
  if (finalError) {
508
528
  this.lineEmitter(LINE_EVENTS.ERROR, undefined, clientError);
509
529
  }
510
- this.metricManager.submitRegistrationMetric(METRIC_EVENT.REGISTRATION, REG_ACTION.KEEPALIVE_FAILURE, METRIC_TYPE.BEHAVIORAL, KEEPALIVE_UTIL, serverType, error.headers?.trackingid ?? '', event.data.keepAliveRetryCount, clientError);
511
- }, { method: KEEPALIVE_UTIL, file: REGISTRATION_FILE });
530
+ this.metricManager.submitRegistrationMetric(METRIC_EVENT.KEEPALIVE_ERROR, REG_ACTION.KEEPALIVE_FAILURE, METRIC_TYPE.BEHAVIORAL, KEEPALIVE_UTIL, serverType, error.headers?.trackingid ?? '', event.data.keepAliveRetryCount, clientError);
531
+ }, { method: KEEPALIVE_UTIL, file: REGISTRATION_FILE }, (retryAfter, retryCaller) => this.handle429Retry(retryAfter, retryCaller));
512
532
  if (abort || event.data.keepAliveRetryCount >= RETRY_COUNT_THRESHOLD) {
513
533
  this.failoverImmediately = this.isCCFlow;
514
534
  this.setStatus(RegistrationStatus.INACTIVE);
515
535
  this.clearKeepaliveTimer();
516
536
  this.clearFailbackTimer();
517
537
  this.lineEmitter(LINE_EVENTS.UNREGISTERED);
538
+ await uploadLogs();
518
539
  if (!abort) {
519
540
  await this.reconnectOnFailure(KEEPALIVE_UTIL);
520
541
  }
542
+ else if (error.statusCode === 404) {
543
+ this.handle404KeepaliveFailure(KEEPALIVE_UTIL);
544
+ }
521
545
  }
522
546
  else {
523
547
  this.lineEmitter(LINE_EVENTS.RECONNECTING);
@@ -547,7 +571,7 @@ export class Registration {
547
571
  });
548
572
  }
549
573
  catch (err) {
550
- log.warn(`Delete failed with Mobius: ${err}`, {
574
+ log.warn(`Delete failed with Mobius: ${JSON.stringify(err)}`, {
551
575
  file: REGISTRATION_FILE,
552
576
  method: METHODS.DEREGISTER,
553
577
  });
@@ -1,7 +1,7 @@
1
1
  import { v4 as uuid } from 'uuid';
2
2
  import { HTTP_METHODS, WorkerMessageType } from '../../common/types';
3
3
  let keepaliveTimer;
4
- export const messageHandler = (event) => {
4
+ const messageHandler = (event) => {
5
5
  const { type } = event.data;
6
6
  const postKeepAlive = async (accessToken, deviceUrl, url) => {
7
7
  const response = await fetch(`${url}/status`, {
@@ -14,7 +14,7 @@ export const messageHandler = (event) => {
14
14
  },
15
15
  });
16
16
  if (!response.ok) {
17
- throw new Error(`Keepalive failed with status: ${response.status}`);
17
+ throw response;
18
18
  }
19
19
  return response;
20
20
  };
@@ -39,10 +39,23 @@ export const messageHandler = (event) => {
39
39
  keepAliveRetryCount = 0;
40
40
  }
41
41
  catch (err) {
42
+ const headers = {};
43
+ if (err.headers?.has('Retry-After')) {
44
+ headers['retry-after'] = err.headers.get('Retry-After');
45
+ }
46
+ if (err.headers?.has('Trackingid')) {
47
+ headers['trackingid'] = err.headers.get('Trackingid');
48
+ }
49
+ const error = {
50
+ headers,
51
+ statusCode: err.status,
52
+ statusText: err.statusText,
53
+ type: err.type,
54
+ };
42
55
  keepAliveRetryCount += 1;
43
56
  postMessage({
44
57
  type: WorkerMessageType.KEEPALIVE_FAILURE,
45
- err,
58
+ err: error,
46
59
  keepAliveRetryCount,
47
60
  });
48
61
  }
@@ -57,3 +70,4 @@ export const messageHandler = (event) => {
57
70
  }
58
71
  };
59
72
  self.addEventListener('message', messageHandler);
73
+ export default messageHandler;
@@ -41,7 +41,7 @@ const messageHandler = (event) => {
41
41
  });
42
42
 
43
43
  if (!response.ok) {
44
- throw new Error(\`Keepalive failed with status: \${response.status}\`);
44
+ throw response;
45
45
  }
46
46
 
47
47
  return response;
@@ -69,10 +69,26 @@ const messageHandler = (event) => {
69
69
  }
70
70
  keepAliveRetryCount = 0;
71
71
  } catch (err) {
72
- keepAliveRetryCount += 1;
72
+ let headers = {};
73
+ if(err.headers?.has('Retry-After')) {
74
+ headers['retry-after'] = err.headers.get('Retry-After');
75
+ }
76
+
77
+ if(err.headers?.has('Trackingid')) {
78
+ headers['trackingid'] = err.headers.get('Trackingid');
79
+ }
80
+
81
+ const error = {
82
+ headers,
83
+ statusCode: err.status,
84
+ statusText: err.statusText,
85
+ type: err.type,
86
+ };
87
+
88
+ keepAliveRetryCount += 1
73
89
  self.postMessage({
74
90
  type: WorkerMessageType.KEEPALIVE_FAILURE,
75
- err,
91
+ err: error,
76
92
  keepAliveRetryCount,
77
93
  });
78
94
  }
@@ -0,0 +1,59 @@
1
+ function waitForIceComplete(pc, timeoutMs) {
2
+ return new Promise((resolve) => {
3
+ if (!pc) {
4
+ resolve({ ok: false, reason: 'no-pc' });
5
+ return;
6
+ }
7
+ if (pc.iceGatheringState === 'complete') {
8
+ resolve({ ok: true, reached: 'already' });
9
+ return;
10
+ }
11
+ let done = false;
12
+ const onChange = () => {
13
+ if (pc.iceGatheringState === 'complete' && !done) {
14
+ done = true;
15
+ pc.removeEventListener('icegatheringstatechange', onChange);
16
+ resolve({ ok: true, reached: 'event' });
17
+ }
18
+ };
19
+ pc.addEventListener('icegatheringstatechange', onChange);
20
+ setTimeout(() => {
21
+ if (done)
22
+ return;
23
+ done = true;
24
+ pc.removeEventListener('icegatheringstatechange', onChange);
25
+ resolve({ ok: pc.iceGatheringState === 'complete', reached: 'timeout' });
26
+ }, timeoutMs);
27
+ });
28
+ }
29
+ export default async function windowsChromiumIceWarmup({ iceServers = [], timeoutMs = 1000 }) {
30
+ const pc1 = new RTCPeerConnection({ iceServers, iceCandidatePoolSize: 1 });
31
+ const pc2 = new RTCPeerConnection({ iceServers, iceCandidatePoolSize: 1 });
32
+ const candidates = { pc1: [], pc2: [] };
33
+ pc1.onicecandidate = (e) => {
34
+ if (e.candidate && e.candidate.type !== 'host') {
35
+ candidates.pc1.push(e.candidate);
36
+ }
37
+ };
38
+ await pc1.createDataChannel('warmup');
39
+ await pc1.addTransceiver('audio');
40
+ const offer = await pc1.createOffer();
41
+ await pc1.setLocalDescription(offer);
42
+ await waitForIceComplete(pc1, timeoutMs);
43
+ await pc2.setRemoteDescription(offer);
44
+ pc2.onicecandidate = (e) => {
45
+ if (e.candidate && e.candidate.type !== 'host') {
46
+ candidates.pc2.push(e.candidate);
47
+ }
48
+ };
49
+ const answer = await pc2.createAnswer();
50
+ await pc2.setLocalDescription(answer);
51
+ await pc1.setRemoteDescription(answer);
52
+ await waitForIceComplete(pc2, timeoutMs);
53
+ await Promise.all([
54
+ ...candidates.pc1.map((candidate) => pc2.addIceCandidate(candidate).catch(console.error)),
55
+ ...candidates.pc2.map((candidate) => pc1.addIceCandidate(candidate).catch(console.error)),
56
+ ]);
57
+ pc1.close();
58
+ pc2.close();
59
+ }
@@ -2,7 +2,7 @@ import { FAILURE_MESSAGE, METHOD_START_MESSAGE, SCIM_ENTERPRISE_USER, SCIM_WEBEX
2
2
  import { HTTP_METHODS } from '../common/types';
3
3
  import SDKConnector from '../SDKConnector';
4
4
  import log from '../Logger';
5
- import { CONTACTS_FILE, CONTACTS_SCHEMA, CONTACT_FILTER, DEFAULT_GROUP_NAME, ENCRYPT_FILTER, GROUP_FILTER, METHODS, OR, SCIM_ID_FILTER, USERS, encryptedFields, } from './constants';
5
+ import { CONTACTS_CLIENT, CONTACTS_SCHEMA, CONTACT_FILTER, DEFAULT_GROUP_NAME, ENCRYPT_FILTER, GROUP_FILTER, METHODS, OR, SCIM_ID_FILTER, USERS, encryptedFields, } from './constants';
6
6
  import { ContactType, GroupType, } from './types';
7
7
  import { scimQuery, serviceErrorCodeHandler, uploadLogs } from '../common/Utils';
8
8
  export class ContactsClient {
@@ -22,7 +22,7 @@ export class ContactsClient {
22
22
  this.groups = undefined;
23
23
  this.contacts = undefined;
24
24
  this.defaultGroupId = '';
25
- log.setLogger(logger.level, CONTACTS_FILE);
25
+ log.setLogger(logger.level, CONTACTS_CLIENT);
26
26
  }
27
27
  async decryptContactDetail(encryptionKeyUrl, contactDetails) {
28
28
  const decryptedContactDetail = [...contactDetails];
@@ -130,7 +130,7 @@ export class ContactsClient {
130
130
  }
131
131
  resolveCloudContacts(contactsDataMap, inputList) {
132
132
  const loggerContext = {
133
- file: CONTACTS_FILE,
133
+ file: CONTACTS_CLIENT,
134
134
  method: 'resolveCloudContacts',
135
135
  };
136
136
  const finalContactList = [];
@@ -187,7 +187,7 @@ export class ContactsClient {
187
187
  }
188
188
  async getContacts() {
189
189
  const loggerContext = {
190
- file: CONTACTS_FILE,
190
+ file: CONTACTS_CLIENT,
191
191
  method: METHODS.GET_CONTACTS,
192
192
  };
193
193
  log.info(METHOD_START_MESSAGE, loggerContext);
@@ -198,6 +198,7 @@ export class ContactsClient {
198
198
  uri: `${this.webex.internal.services._serviceUrls.contactsService}/${ENCRYPT_FILTER}/${USERS}/${CONTACT_FILTER}`,
199
199
  method: HTTP_METHODS.GET,
200
200
  });
201
+ log.log(`Response code: ${response.statusCode} and Response trackingId: ${response?.headers?.trackingid}`, loggerContext);
201
202
  const responseBody = response.body;
202
203
  if (!responseBody) {
203
204
  throw new Error(`${response}`);
@@ -249,17 +250,15 @@ export class ContactsClient {
249
250
  return contactResponse;
250
251
  }
251
252
  catch (err) {
252
- const errorInfo = err;
253
- const extendedError = new Error(`Error fetching contacts: ${err}`);
254
- log.error(extendedError, loggerContext);
255
- const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
253
+ log.error(`Error fetching contacts: ${JSON.stringify(err)}`, loggerContext);
254
+ const errorStatus = serviceErrorCodeHandler(err, loggerContext);
256
255
  await uploadLogs();
257
256
  return errorStatus;
258
257
  }
259
258
  }
260
259
  async createNewEncryptionKeyUrl() {
261
260
  const loggerContext = {
262
- file: CONTACTS_FILE,
261
+ file: CONTACTS_CLIENT,
263
262
  method: METHODS.CREATE_NEW_ENCRYPTION_KEY_URL,
264
263
  };
265
264
  log.info(METHOD_START_MESSAGE, loggerContext);
@@ -272,7 +271,7 @@ export class ContactsClient {
272
271
  }
273
272
  async fetchEncryptionKeyUrl() {
274
273
  const loggerContext = {
275
- file: CONTACTS_FILE,
274
+ file: CONTACTS_CLIENT,
276
275
  method: METHODS.FETCH_ENCRYPTION_KEY_URL,
277
276
  };
278
277
  log.info(METHOD_START_MESSAGE, loggerContext);
@@ -287,14 +286,14 @@ export class ContactsClient {
287
286
  }
288
287
  this.encryptionKeyUrl = await this.createNewEncryptionKeyUrl();
289
288
  log.log(`Creating a default group: ${DEFAULT_GROUP_NAME}`, {
290
- file: CONTACTS_FILE,
289
+ file: CONTACTS_CLIENT,
291
290
  method: this.fetchEncryptionKeyUrl.name,
292
291
  });
293
292
  const response = await this.createContactGroup(DEFAULT_GROUP_NAME, this.encryptionKeyUrl);
294
293
  if (response.data.group?.groupId) {
295
294
  this.defaultGroupId = response.data.group?.groupId;
296
295
  log.log(`Successfully created default group with ID: ${this.defaultGroupId}`, {
297
- file: CONTACTS_FILE,
296
+ file: CONTACTS_CLIENT,
298
297
  method: this.fetchEncryptionKeyUrl.name,
299
298
  });
300
299
  }
@@ -302,13 +301,13 @@ export class ContactsClient {
302
301
  }
303
302
  async fetchDefaultGroup() {
304
303
  const loggerContext = {
305
- file: CONTACTS_FILE,
304
+ file: CONTACTS_CLIENT,
306
305
  method: METHODS.FETCH_DEFAULT_GROUP,
307
306
  };
308
307
  log.info(METHOD_START_MESSAGE, loggerContext);
309
308
  if (this.defaultGroupId) {
310
309
  log.log(`Using existing default group with ID: ${this.defaultGroupId}`, {
311
- file: CONTACTS_FILE,
310
+ file: CONTACTS_CLIENT,
312
311
  method: this.fetchDefaultGroup.name,
313
312
  });
314
313
  return this.defaultGroupId;
@@ -318,7 +317,7 @@ export class ContactsClient {
318
317
  if (this.groups[i].displayName === DEFAULT_GROUP_NAME) {
319
318
  this.defaultGroupId = this.groups[i].groupId;
320
319
  log.log(`Found default group with ID: ${this.defaultGroupId}`, {
321
- file: CONTACTS_FILE,
320
+ file: CONTACTS_CLIENT,
322
321
  method: this.fetchDefaultGroup.name,
323
322
  });
324
323
  return this.defaultGroupId;
@@ -326,7 +325,7 @@ export class ContactsClient {
326
325
  }
327
326
  }
328
327
  log.log('No default group found.', {
329
- file: CONTACTS_FILE,
328
+ file: CONTACTS_CLIENT,
330
329
  method: this.fetchDefaultGroup.name,
331
330
  });
332
331
  const response = await this.createContactGroup(DEFAULT_GROUP_NAME);
@@ -334,7 +333,7 @@ export class ContactsClient {
334
333
  if (group) {
335
334
  const groupId = group.groupId;
336
335
  log.log(`Successfully created new default group with ID: ${groupId}`, {
337
- file: CONTACTS_FILE,
336
+ file: CONTACTS_CLIENT,
338
337
  method: this.fetchDefaultGroup.name,
339
338
  });
340
339
  return groupId;
@@ -343,7 +342,7 @@ export class ContactsClient {
343
342
  }
344
343
  async createContactGroup(displayName, encryptionKeyUrl, groupType) {
345
344
  const loggerContext = {
346
- file: CONTACTS_FILE,
345
+ file: CONTACTS_CLIENT,
347
346
  method: METHODS.CREATE_CONTACT_GROUP,
348
347
  };
349
348
  log.info(`${METHOD_START_MESSAGE} with displayName: ${displayName}`, loggerContext);
@@ -377,6 +376,8 @@ export class ContactsClient {
377
376
  method: HTTP_METHODS.POST,
378
377
  body: groupInfo,
379
378
  });
379
+ log.log(`Response code: ${response.statusCode}`, loggerContext);
380
+ log.log(`Response trackingId: ${response?.headers?.trackingid}`, loggerContext);
380
381
  const group = response.body;
381
382
  group.displayName = displayName;
382
383
  const contactResponse = {
@@ -391,17 +392,15 @@ export class ContactsClient {
391
392
  return contactResponse;
392
393
  }
393
394
  catch (err) {
394
- const errorInfo = err;
395
- const extendedError = new Error(`Unable to create contact group: ${err}`);
396
- log.error(extendedError, loggerContext);
397
- const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
395
+ log.error(`Unable to create contact group: ${JSON.stringify(err)}`, loggerContext);
396
+ const errorStatus = serviceErrorCodeHandler(err, loggerContext);
398
397
  await uploadLogs();
399
398
  return errorStatus;
400
399
  }
401
400
  }
402
401
  async deleteContactGroup(groupId) {
403
402
  const loggerContext = {
404
- file: CONTACTS_FILE,
403
+ file: CONTACTS_CLIENT,
405
404
  method: METHODS.DELETE_CONTACT_GROUP,
406
405
  };
407
406
  log.info(`${METHOD_START_MESSAGE} with groupId: ${groupId}`, loggerContext);
@@ -411,6 +410,7 @@ export class ContactsClient {
411
410
  uri: `${this.webex.internal.services._serviceUrls.contactsService}/${ENCRYPT_FILTER}/${USERS}/${GROUP_FILTER}/${groupId}`,
412
411
  method: HTTP_METHODS.DELETE,
413
412
  });
413
+ log.log(`Response trackingId: ${response?.headers?.trackingid}`, loggerContext);
414
414
  const contactResponse = {
415
415
  statusCode: Number(response[STATUS_CODE]),
416
416
  data: {},
@@ -427,17 +427,15 @@ export class ContactsClient {
427
427
  return contactResponse;
428
428
  }
429
429
  catch (err) {
430
- const errorInfo = err;
431
- const extendedError = new Error(`Unable to delete contact group ${groupId}: ${err}`);
432
- log.error(extendedError, loggerContext);
433
- const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
430
+ log.error(`Unable to delete contact group ${groupId}: ${JSON.stringify(err)}`, loggerContext);
431
+ const errorStatus = serviceErrorCodeHandler(err, loggerContext);
434
432
  await uploadLogs();
435
433
  return errorStatus;
436
434
  }
437
435
  }
438
436
  async createContact(contactInfo) {
439
437
  const loggerContext = {
440
- file: CONTACTS_FILE,
438
+ file: CONTACTS_CLIENT,
441
439
  method: METHODS.CREATE_CONTACT,
442
440
  };
443
441
  log.info(`${METHOD_START_MESSAGE} with contactType: ${contactInfo.contactType}`, loggerContext);
@@ -487,6 +485,8 @@ export class ContactsClient {
487
485
  method: HTTP_METHODS.POST,
488
486
  body: requestBody,
489
487
  });
488
+ log.log(`Response code: ${response.statusCode}`, loggerContext);
489
+ log.log(`Response trackingId: ${response?.headers?.trackingid}`, loggerContext);
490
490
  const newContact = response.body;
491
491
  contact.contactId = newContact.contactId;
492
492
  const contactResponse = {
@@ -511,17 +511,15 @@ export class ContactsClient {
511
511
  return contactResponse;
512
512
  }
513
513
  catch (err) {
514
- const errorInfo = err;
515
- const extendedError = new Error(`Failed to create contact: ${err}`);
516
- log.error(extendedError, loggerContext);
517
- const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
514
+ log.error(`Failed to create contact: ${JSON.stringify(err)}`, loggerContext);
515
+ const errorStatus = serviceErrorCodeHandler(err, loggerContext);
518
516
  await uploadLogs();
519
517
  return errorStatus;
520
518
  }
521
519
  }
522
520
  async deleteContact(contactId) {
523
521
  const loggerContext = {
524
- file: CONTACTS_FILE,
522
+ file: CONTACTS_CLIENT,
525
523
  method: METHODS.DELETE_CONTACT,
526
524
  };
527
525
  log.info(`${METHOD_START_MESSAGE} with contactId: ${contactId}`, loggerContext);
@@ -544,10 +542,8 @@ export class ContactsClient {
544
542
  return contactResponse;
545
543
  }
546
544
  catch (err) {
547
- const errorInfo = err;
548
- const extendedError = new Error(`Unable to delete contact ${contactId}: ${err}`);
549
- log.error(extendedError, loggerContext);
550
- const errorStatus = serviceErrorCodeHandler(errorInfo, loggerContext);
545
+ log.error(`Unable to delete contact ${contactId}: ${JSON.stringify(err)}`, loggerContext);
546
+ const errorStatus = serviceErrorCodeHandler(err, loggerContext);
551
547
  await uploadLogs();
552
548
  return errorStatus;
553
549
  }
@@ -1,4 +1,4 @@
1
- export const CONTACTS_FILE = 'Contacts';
1
+ export const CONTACTS_CLIENT = 'ContactsClient';
2
2
  export const CONTACT_FILTER = 'contacts';
3
3
  export const GROUP_FILTER = 'groups';
4
4
  export const ENCRYPT_FILTER = 'encrypt';
@@ -4,7 +4,7 @@ import { LOG_PREFIX } from '../../Logger/types';
4
4
  export class Eventing extends EventEmitter {
5
5
  emit(event, ...args) {
6
6
  const timestamp = new Date().toUTCString();
7
- Logger.info(`${timestamp} ${LOG_PREFIX.EVENT}: ${event.toString()} - event emitted with parameters -> ${args} = `, {
7
+ Logger.info(`${timestamp} ${LOG_PREFIX.EVENT}: ${event.toString()} - event emitted with parameters -> ${args}`, {
8
8
  file: 'Events/impl/index.ts',
9
9
  method: 'emit',
10
10
  });
@@ -101,9 +101,9 @@ const logTrace = (message, context) => {
101
101
  writeToLogger(`${format(context, '[TRACE]')} - ${LOG_PREFIX.MESSAGE}:${message}`, LOGGER.TRACE);
102
102
  }
103
103
  };
104
- const logError = (error, context) => {
104
+ const logError = (errorMsg, context) => {
105
105
  if (currentLogLevel >= LOGGING_LEVEL.error) {
106
- writeToLogger(`${format(context, '[ERROR]')} - !${LOG_PREFIX.ERROR}!${LOG_PREFIX.MESSAGE}:${error.message}`, LOGGER.ERROR);
106
+ writeToLogger(`${format(context, '[ERROR]')} - !${LOG_PREFIX.ERROR}!${LOG_PREFIX.MESSAGE}:${errorMsg}`, LOGGER.ERROR);
107
107
  }
108
108
  };
109
109
  const setWebexLogger = (logger) => {