@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
@@ -39,6 +39,7 @@ var mockSubmitRegistrationMetric = jest.fn();
39
39
  var mockEmitterCb = jest.fn();
40
40
  var mockRestoreCb = jest.fn();
41
41
  var mock429RetryCb = jest.fn();
42
+ var mockSessionSupersededCb = jest.fn();
42
43
  var webex = (0, _testUtil.getTestUtilsWebex)();
43
44
  _SDKConnector.default.setWebex(webex);
44
45
  webex.internal.metrics.submitClientMetrics = mockSubmitRegistrationMetric;
@@ -65,6 +66,28 @@ describe('Mobius service discovery tests', function () {
65
66
  expect(filteredUris.primary[0]).toBe(defaultMobiusUrl + callingContext);
66
67
  expect(filteredUris.backup.length).toBe(0);
67
68
  });
69
+ it('filterMobiusUris drops untrusted wss hosts', function () {
70
+ var defaultMobiusUrl = 'https://mobius.webex.com/api/v1/calling/web';
71
+ var discoveryResponse = (0, _testUtil.getMobiusDiscoveryResponse)();
72
+ discoveryResponse.primary.wss = ['wss://mobius-dfw.webex.com/socket', 'wss://evil.example.com/socket'];
73
+ discoveryResponse.backup.wss = ['wss://mobius-sjc.webex.com/socket', 'wss://attacker.example.org/socket'];
74
+ var filteredUris = (0, _Utils.filterMobiusUris)(discoveryResponse, defaultMobiusUrl);
75
+ expect(filteredUris.primaryWss).toHaveLength(1);
76
+ expect(filteredUris.primaryWss[0]).toBe('wss://mobius-dfw.webex.com/socket');
77
+ expect(filteredUris.backupWss).toHaveLength(1);
78
+ expect(filteredUris.backupWss[0]).toBe('wss://mobius-sjc.webex.com/socket');
79
+ });
80
+ it('filterMobiusUris drops malformed/unparseable wss hosts', function () {
81
+ var defaultMobiusUrl = 'https://mobius.webex.com/api/v1/calling/web';
82
+ var discoveryResponse = (0, _testUtil.getMobiusDiscoveryResponse)();
83
+ discoveryResponse.primary.wss = ['wss://mobius-dfw.webex.com/socket', 'wss://', 'not a url'];
84
+ discoveryResponse.backup.wss = ['not a url', 'wss://mobius-sjc.webex.com/socket'];
85
+ var filteredUris = (0, _Utils.filterMobiusUris)(discoveryResponse, defaultMobiusUrl);
86
+ expect(filteredUris.primaryWss).toHaveLength(1);
87
+ expect(filteredUris.primaryWss[0]).toBe('wss://mobius-dfw.webex.com/socket');
88
+ expect(filteredUris.backupWss).toHaveLength(1);
89
+ expect(filteredUris.backupWss[0]).toBe('wss://mobius-sjc.webex.com/socket');
90
+ });
68
91
  });
69
92
  describe('Call Tests - keepalive (handleCallEstablished) cases', function () {
70
93
  var logObj = {
@@ -453,6 +476,18 @@ describe('Registration Tests', function () {
453
476
  restoreCbExpected: false,
454
477
  retry429CbExpected: false,
455
478
  logMsg: '400 Bad Request'
479
+ }, {
480
+ name: 'verify 409 error response',
481
+ statusCode: _types2.ERROR_CODE.CONFLICT,
482
+ deviceErrorCode: 0,
483
+ message: _constants.SESSION_SUPERSEDED_MESSAGE,
484
+ errorType: _types2.ERROR_TYPE.SESSION_SUPERSEDED,
485
+ emitterCbExpected: false,
486
+ finalError: true,
487
+ restoreCbExpected: false,
488
+ retry429CbExpected: false,
489
+ sessionSupersededCbExpected: true,
490
+ logMsg: '409 Conflict: session superseded by another device for this user'
456
491
  }, {
457
492
  name: 'verify unknown error response',
458
493
  statusCode: 206,
@@ -478,55 +513,114 @@ describe('Registration Tests', function () {
478
513
  };
479
514
 
480
515
  /* eslint-disable @typescript-eslint/no-explicit-any */
481
- it.each(errorCodes)('%s', function (codeObj) {
482
- var webexPayload = {
483
- statusCode: codeObj.statusCode,
484
- headers: _objectSpread({
485
- trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
486
- }, codeObj.retryAfter && {
487
- 'retry-after': codeObj.retryAfter.toString()
488
- }),
489
- body: {
490
- device: {
491
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
492
- },
493
- userId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
494
- errorCode: codeObj.deviceErrorCode,
495
- devices: [{
496
- deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
497
- uri: 'https://mobius.webex.com/api/v1/calling/web/',
498
- status: 'active',
499
- lastSeen: '2022-04-07T18:00:40Z',
500
- addresses: ['sip:sipAddress@webex.com']
501
- }]
502
- }
503
- };
504
- if (codeObj.customBodyPresent) {
505
- webexPayload.body = codeObj.body;
506
- }
507
- var mockErrorEvent = {
508
- type: codeObj.errorType,
509
- message: codeObj.message,
510
- context: logObj
516
+ it.each(errorCodes)('%s', /*#__PURE__*/function () {
517
+ var _ref8 = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8(codeObj) {
518
+ var webexPayload, mockErrorEvent, callClientError, result;
519
+ return _regenerator.default.wrap(function (_context8) {
520
+ while (1) switch (_context8.prev = _context8.next) {
521
+ case 0:
522
+ webexPayload = {
523
+ statusCode: codeObj.statusCode,
524
+ headers: _objectSpread({
525
+ trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
526
+ }, codeObj.retryAfter && {
527
+ 'retry-after': codeObj.retryAfter.toString()
528
+ }),
529
+ body: {
530
+ device: {
531
+ deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010'
532
+ },
533
+ userId: '8a67806f-fc4d-446b-a131-31e71ea5b0e9',
534
+ errorCode: codeObj.deviceErrorCode,
535
+ devices: [{
536
+ deviceId: '8a67806f-fc4d-446b-a131-31e71ea5b010',
537
+ uri: 'https://mobius.webex.com/api/v1/calling/web/',
538
+ status: 'active',
539
+ lastSeen: '2022-04-07T18:00:40Z',
540
+ addresses: ['sip:sipAddress@webex.com']
541
+ }]
542
+ }
543
+ };
544
+ if (codeObj.customBodyPresent) {
545
+ webexPayload.body = codeObj.body;
546
+ }
547
+ mockErrorEvent = {
548
+ type: codeObj.errorType,
549
+ message: codeObj.message,
550
+ context: logObj
551
+ };
552
+ callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
553
+ _context8.next = 1;
554
+ return (0, _Utils.handleRegistrationErrors)(webexPayload, mockEmitterCb, logObj, {
555
+ retry429Cb: mock429RetryCb,
556
+ restoreRegCb: mockRestoreCb,
557
+ sessionSupersededCb: mockSessionSupersededCb
558
+ });
559
+ case 1:
560
+ result = _context8.sent;
561
+ expect(result.finalError).toBe(codeObj.finalError);
562
+ if (codeObj.emitterCbExpected) {
563
+ expect(mockEmitterCb).toBeCalledOnceWith(callClientError, codeObj.finalError);
564
+ } else {
565
+ expect(mockEmitterCb).not.toHaveBeenCalled();
566
+ }
567
+ if (codeObj.restoreCbExpected) {
568
+ expect(mockRestoreCb).toBeCalledOnceWith(webexPayload.body, logObj.method);
569
+ } else {
570
+ expect(mockRestoreCb).not.toHaveBeenCalled();
571
+ }
572
+ if (codeObj.retry429CbExpected) {
573
+ expect(mock429RetryCb).toBeCalledOnceWith(codeObj.retryAfter, logObj.method);
574
+ } else {
575
+ expect(mock429RetryCb).not.toHaveBeenCalled();
576
+ }
577
+ if (codeObj.sessionSupersededCbExpected) {
578
+ expect(mockSessionSupersededCb).toBeCalledOnceWith(callClientError);
579
+ } else {
580
+ expect(mockSessionSupersededCb).not.toHaveBeenCalled();
581
+ }
582
+ expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(codeObj.statusCode), logObj);
583
+ expect(logSpy).toHaveBeenCalledWith(codeObj.logMsg, logObj);
584
+ case 2:
585
+ case "end":
586
+ return _context8.stop();
587
+ }
588
+ }, _callee8);
589
+ }));
590
+ return function (_x) {
591
+ return _ref8.apply(this, arguments);
511
592
  };
512
- var callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
513
- (0, _Utils.handleRegistrationErrors)(webexPayload, mockEmitterCb, logObj, mock429RetryCb, mockRestoreCb);
514
- if (codeObj.emitterCbExpected) {
515
- expect(mockEmitterCb).toBeCalledOnceWith(callClientError, codeObj.finalError);
516
- }
517
- if (codeObj.restoreCbExpected) {
518
- expect(mockRestoreCb).toBeCalledOnceWith(webexPayload.body, logObj.method);
519
- } else {
520
- expect(mockRestoreCb).not.toHaveBeenCalled();
521
- }
522
- if (codeObj.retry429CbExpected) {
523
- expect(mock429RetryCb).toBeCalledOnceWith(codeObj.retryAfter, logObj.method);
524
- } else {
525
- expect(mock429RetryCb).not.toHaveBeenCalled();
526
- }
527
- expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(codeObj.statusCode), logObj);
528
- expect(logSpy).toHaveBeenCalledWith(codeObj.logMsg, logObj);
529
- });
593
+ }());
594
+ it('verify 409 response for a caller that does not handle a superseded session', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
595
+ var webexPayload, result;
596
+ return _regenerator.default.wrap(function (_context9) {
597
+ while (1) switch (_context9.prev = _context9.next) {
598
+ case 0:
599
+ webexPayload = {
600
+ statusCode: _types2.ERROR_CODE.CONFLICT,
601
+ headers: {
602
+ trackingid: 'webex-js-sdk_b5812e58-7246-4a9b-bf64-831bdf13b0cd_31'
603
+ }
604
+ };
605
+ _context9.next = 1;
606
+ return (0, _Utils.handleRegistrationErrors)(webexPayload, mockEmitterCb, logObj, {
607
+ retry429Cb: mock429RetryCb,
608
+ restoreRegCb: mockRestoreCb
609
+ });
610
+ case 1:
611
+ result = _context9.sent;
612
+ expect(result).toStrictEqual({
613
+ finalError: false,
614
+ shouldDisconnect: false
615
+ });
616
+ expect(mockEmitterCb).not.toHaveBeenCalled();
617
+ expect(logSpy).toHaveBeenCalledWith('409 Conflict: ignored, caller does not handle a superseded session', logObj);
618
+ case 2:
619
+ case "end":
620
+ return _context9.stop();
621
+ }
622
+ }, _callee9);
623
+ })));
530
624
  });
531
625
  describe('CallingClient Error Tests', function () {
532
626
  var logSpy = jest.spyOn(_Logger.default, 'warn');
@@ -537,10 +631,10 @@ describe('CallingClient Error Tests', function () {
537
631
  beforeEach(function () {
538
632
  jest.clearAllMocks();
539
633
  });
540
- it('verify 401 error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee8() {
634
+ it('verify 401 error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
541
635
  var statusCode, message, errorType, finalError, webexPayload, mockErrorEvent, callClientError, result;
542
- return _regenerator.default.wrap(function (_context8) {
543
- while (1) switch (_context8.prev = _context8.next) {
636
+ return _regenerator.default.wrap(function (_context0) {
637
+ while (1) switch (_context0.prev = _context0.next) {
544
638
  case 0:
545
639
  statusCode = _types2.ERROR_CODE.UNAUTHORIZED;
546
640
  message = 'User is unauthorized due to an expired token.';
@@ -565,24 +659,24 @@ describe('CallingClient Error Tests', function () {
565
659
  context: logObj
566
660
  };
567
661
  callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
568
- _context8.next = 1;
662
+ _context0.next = 1;
569
663
  return (0, _Utils.handleCallingClientErrors)(webexPayload, mockEmitterCb, logObj);
570
664
  case 1:
571
- result = _context8.sent;
665
+ result = _context0.sent;
572
666
  expect(mockEmitterCb).toHaveBeenCalledWith(callClientError, finalError);
573
667
  expect(result).toBe(finalError);
574
668
  expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(statusCode), logObj);
575
669
  expect(logSpy).toHaveBeenCalledWith('401 Unauthorized', logObj);
576
670
  case 2:
577
671
  case "end":
578
- return _context8.stop();
672
+ return _context0.stop();
579
673
  }
580
- }, _callee8);
674
+ }, _callee0);
581
675
  })));
582
- it('verify 500 error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee9() {
676
+ it('verify 500 error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
583
677
  var statusCode, message, errorType, finalError, webexPayload, mockErrorEvent, callClientError, result;
584
- return _regenerator.default.wrap(function (_context9) {
585
- while (1) switch (_context9.prev = _context9.next) {
678
+ return _regenerator.default.wrap(function (_context1) {
679
+ while (1) switch (_context1.prev = _context1.next) {
586
680
  case 0:
587
681
  statusCode = _types2.ERROR_CODE.INTERNAL_SERVER_ERROR;
588
682
  message = 'An unknown error occurred while placing the request. Wait a moment and try again.';
@@ -607,24 +701,24 @@ describe('CallingClient Error Tests', function () {
607
701
  context: logObj
608
702
  };
609
703
  callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
610
- _context9.next = 1;
704
+ _context1.next = 1;
611
705
  return (0, _Utils.handleCallingClientErrors)(webexPayload, mockEmitterCb, logObj);
612
706
  case 1:
613
- result = _context9.sent;
707
+ result = _context1.sent;
614
708
  expect(mockEmitterCb).toHaveBeenCalledWith(callClientError, finalError);
615
709
  expect(result).toBe(finalError);
616
710
  expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(statusCode), logObj);
617
711
  expect(logSpy).toHaveBeenCalledWith('500 Internal Server Error', logObj);
618
712
  case 2:
619
713
  case "end":
620
- return _context9.stop();
714
+ return _context1.stop();
621
715
  }
622
- }, _callee9);
716
+ }, _callee1);
623
717
  })));
624
- it('verify unknown error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee0() {
718
+ it('verify unknown error response for calling client', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
625
719
  var statusCode, message, errorType, finalError, webexPayload, mockErrorEvent, callClientError, result;
626
- return _regenerator.default.wrap(function (_context0) {
627
- while (1) switch (_context0.prev = _context0.next) {
720
+ return _regenerator.default.wrap(function (_context10) {
721
+ while (1) switch (_context10.prev = _context10.next) {
628
722
  case 0:
629
723
  statusCode = 206;
630
724
  message = 'Unknown error';
@@ -649,19 +743,19 @@ describe('CallingClient Error Tests', function () {
649
743
  context: logObj
650
744
  };
651
745
  callClientError = new _Errors.CallingClientError(mockErrorEvent.message, mockErrorEvent.context, mockErrorEvent.type, _types.RegistrationStatus.ACTIVE);
652
- _context0.next = 1;
746
+ _context10.next = 1;
653
747
  return (0, _Utils.handleCallingClientErrors)(webexPayload, mockEmitterCb, logObj);
654
748
  case 1:
655
- result = _context0.sent;
749
+ result = _context10.sent;
656
750
  expect(mockEmitterCb).toHaveBeenCalledWith(callClientError, finalError);
657
751
  expect(result).toBe(finalError);
658
752
  expect(logSpy).toHaveBeenCalledWith("Status code: -> ".concat(statusCode), logObj);
659
753
  expect(logSpy).toHaveBeenCalledWith('Unknown Error', logObj);
660
754
  case 2:
661
755
  case "end":
662
- return _context0.stop();
756
+ return _context10.stop();
663
757
  }
664
- }, _callee0);
758
+ }, _callee10);
665
759
  })));
666
760
  });
667
761
  describe('Call Tests', function () {
@@ -1209,11 +1303,11 @@ describe('resolveContact tests', function () {
1209
1303
  }));
1210
1304
  });
1211
1305
  });
1212
- it('Resolve by userExternalId - SCIM exception', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
1306
+ it('Resolve by userExternalId - SCIM exception', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
1213
1307
  var _callingPartyInfo$use2;
1214
1308
  var callingPartyInfo, warnSpy, webexSpy, displayInfo, query;
1215
- return _regenerator.default.wrap(function (_context1) {
1216
- while (1) switch (_context1.prev = _context1.next) {
1309
+ return _regenerator.default.wrap(function (_context11) {
1310
+ while (1) switch (_context11.prev = _context11.next) {
1217
1311
  case 0:
1218
1312
  callingPartyInfo = {};
1219
1313
  warnSpy = jest.spyOn(_Logger.default, 'warn');
@@ -1223,10 +1317,10 @@ describe('resolveContact tests', function () {
1223
1317
  callingPartyInfo.userExternalId = {
1224
1318
  $: 'userExternalId'
1225
1319
  };
1226
- _context1.next = 1;
1320
+ _context11.next = 1;
1227
1321
  return (0, _Utils.resolveContact)(callingPartyInfo);
1228
1322
  case 1:
1229
- displayInfo = _context1.sent;
1323
+ displayInfo = _context11.sent;
1230
1324
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
1231
1325
  expect(warnSpy).toHaveBeenCalledWith('Error response: - 500', {
1232
1326
  file: _constants.UTILS_FILE,
@@ -1238,15 +1332,15 @@ describe('resolveContact tests', function () {
1238
1332
  }));
1239
1333
  case 2:
1240
1334
  case "end":
1241
- return _context1.stop();
1335
+ return _context11.stop();
1242
1336
  }
1243
- }, _callee1);
1337
+ }, _callee11);
1244
1338
  })));
1245
- it('Resolve by userExternalId - totalResults zero', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee10() {
1339
+ it('Resolve by userExternalId - totalResults zero', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
1246
1340
  var _callingPartyInfo$use3;
1247
1341
  var callingPartyInfo, scimResponse, webexSpy, displayInfo, query;
1248
- return _regenerator.default.wrap(function (_context10) {
1249
- while (1) switch (_context10.prev = _context10.next) {
1342
+ return _regenerator.default.wrap(function (_context12) {
1343
+ while (1) switch (_context12.prev = _context12.next) {
1250
1344
  case 0:
1251
1345
  callingPartyInfo = {};
1252
1346
  scimResponse = (0, _testUtil.getSampleScimResponse)();
@@ -1258,10 +1352,10 @@ describe('resolveContact tests', function () {
1258
1352
  callingPartyInfo.userExternalId = {
1259
1353
  $: 'userExternalId'
1260
1354
  };
1261
- _context10.next = 1;
1355
+ _context12.next = 1;
1262
1356
  return (0, _Utils.resolveContact)(callingPartyInfo);
1263
1357
  case 1:
1264
- displayInfo = _context10.sent;
1358
+ displayInfo = _context12.sent;
1265
1359
  query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use3 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use3 === void 0 ? void 0 : _callingPartyInfo$use3.$, "\""));
1266
1360
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
1267
1361
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
@@ -1270,15 +1364,15 @@ describe('resolveContact tests', function () {
1270
1364
  scimResponse.totalResults = '1';
1271
1365
  case 2:
1272
1366
  case "end":
1273
- return _context10.stop();
1367
+ return _context12.stop();
1274
1368
  }
1275
- }, _callee10);
1369
+ }, _callee12);
1276
1370
  })));
1277
- it('Resolve by userExternalId - no primary number and no phone numbers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee11() {
1371
+ it('Resolve by userExternalId - no primary number and no phone numbers', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
1278
1372
  var _callingPartyInfo$use4, _displayInfo, _displayInfo2;
1279
1373
  var callingPartyInfo, scimResponse, webexSpy, displayInfo, query, phoneNumbers;
1280
- return _regenerator.default.wrap(function (_context11) {
1281
- while (1) switch (_context11.prev = _context11.next) {
1374
+ return _regenerator.default.wrap(function (_context13) {
1375
+ while (1) switch (_context13.prev = _context13.next) {
1282
1376
  case 0:
1283
1377
  callingPartyInfo = {};
1284
1378
  scimResponse = (0, _testUtil.getSampleScimResponse)();
@@ -1290,10 +1384,10 @@ describe('resolveContact tests', function () {
1290
1384
  callingPartyInfo.userExternalId = {
1291
1385
  $: 'userExternalId'
1292
1386
  };
1293
- _context11.next = 1;
1387
+ _context13.next = 1;
1294
1388
  return (0, _Utils.resolveContact)(callingPartyInfo);
1295
1389
  case 1:
1296
- displayInfo = _context11.sent;
1390
+ displayInfo = _context13.sent;
1297
1391
  query = scimUrl + encodeURIComponent("id eq \"".concat((_callingPartyInfo$use4 = callingPartyInfo.userExternalId) === null || _callingPartyInfo$use4 === void 0 ? void 0 : _callingPartyInfo$use4.$, "\""));
1298
1392
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1299
1393
  uri: query
@@ -1309,10 +1403,10 @@ describe('resolveContact tests', function () {
1309
1403
  statusCode: 200,
1310
1404
  body: scimResponse
1311
1405
  });
1312
- _context11.next = 2;
1406
+ _context13.next = 2;
1313
1407
  return (0, _Utils.resolveContact)(callingPartyInfo);
1314
1408
  case 2:
1315
- displayInfo = _context11.sent;
1409
+ displayInfo = _context13.sent;
1316
1410
  expect((_displayInfo2 = displayInfo) === null || _displayInfo2 === void 0 ? void 0 : _displayInfo2.num).toBeUndefined();
1317
1411
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1318
1412
  uri: query
@@ -1320,9 +1414,9 @@ describe('resolveContact tests', function () {
1320
1414
  scimResponse.Resources[0].phoneNumbers = phoneNumbers;
1321
1415
  case 3:
1322
1416
  case "end":
1323
- return _context11.stop();
1417
+ return _context13.stop();
1324
1418
  }
1325
- }, _callee11);
1419
+ }, _callee13);
1326
1420
  })));
1327
1421
  it('Resolve by userExternalId - no photo', function () {
1328
1422
  var callingPartyInfo = {};
@@ -1347,6 +1441,63 @@ describe('resolveContact tests', function () {
1347
1441
  }));
1348
1442
  });
1349
1443
  });
1444
+ it('resolveContact escapes SCIM filter injection in userExternalId', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
1445
+ var callingPartyInfo, injectionPayload, webexSpy, escapedValue, expectedQuery;
1446
+ return _regenerator.default.wrap(function (_context14) {
1447
+ while (1) switch (_context14.prev = _context14.next) {
1448
+ case 0:
1449
+ callingPartyInfo = {};
1450
+ injectionPayload = 'x" or userName pr "';
1451
+ webexSpy = jest.spyOn(webex, 'request').mockResolvedValueOnce({
1452
+ statusCode: 200,
1453
+ body: (0, _testUtil.getSampleScimResponse)()
1454
+ });
1455
+ callingPartyInfo.userExternalId = {
1456
+ $: injectionPayload
1457
+ };
1458
+ _context14.next = 1;
1459
+ return (0, _Utils.resolveContact)(callingPartyInfo);
1460
+ case 1:
1461
+ // After escaping: backslash → \\ then double-quote → \"
1462
+ escapedValue = injectionPayload.replace(/\\/g, '\\\\').replace(/"/g, '\\"');
1463
+ expectedQuery = scimUrl + encodeURIComponent("id eq \"".concat(escapedValue, "\""));
1464
+ expect(webexSpy).toHaveBeenCalledWith(expect.objectContaining({
1465
+ uri: expectedQuery
1466
+ }));
1467
+ case 2:
1468
+ case "end":
1469
+ return _context14.stop();
1470
+ }
1471
+ }, _callee14);
1472
+ })));
1473
+ it('legitimate externalId still resolves', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
1474
+ var callingPartyInfo, legitimateId, webexSpy, expectedQuery;
1475
+ return _regenerator.default.wrap(function (_context15) {
1476
+ while (1) switch (_context15.prev = _context15.next) {
1477
+ case 0:
1478
+ callingPartyInfo = {};
1479
+ legitimateId = '69fde5ad-fb8b-4a1b-9998-b0999e95719b';
1480
+ webexSpy = jest.spyOn(webex, 'request').mockResolvedValueOnce({
1481
+ statusCode: 200,
1482
+ body: (0, _testUtil.getSampleScimResponse)()
1483
+ });
1484
+ callingPartyInfo.userExternalId = {
1485
+ $: legitimateId
1486
+ };
1487
+ _context15.next = 1;
1488
+ return (0, _Utils.resolveContact)(callingPartyInfo);
1489
+ case 1:
1490
+ // A UUID contains no SCIM metacharacters; the query string is unchanged
1491
+ expectedQuery = scimUrl + encodeURIComponent("id eq \"".concat(legitimateId, "\""));
1492
+ expect(webexSpy).toHaveBeenCalledWith(expect.objectContaining({
1493
+ uri: expectedQuery
1494
+ }));
1495
+ case 2:
1496
+ case "end":
1497
+ return _context15.stop();
1498
+ }
1499
+ }, _callee15);
1500
+ })));
1350
1501
  it('Resolve with minimal response from SCIM', function () {
1351
1502
  var callingPartyInfo = {};
1352
1503
  var scimResponse = (0, _testUtil.getSampleMinimumScimResponse)();
@@ -1387,10 +1538,10 @@ describe('resolveContact tests', function () {
1387
1538
  }));
1388
1539
  });
1389
1540
  });
1390
- it('Resolve by name - Empty Info', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
1541
+ it('Resolve by name - Empty Info', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
1391
1542
  var callingPartyInfo, peopleListResponse, items, webexSpy, displayInfo;
1392
- return _regenerator.default.wrap(function (_context12) {
1393
- while (1) switch (_context12.prev = _context12.next) {
1543
+ return _regenerator.default.wrap(function (_context16) {
1544
+ while (1) switch (_context16.prev = _context16.next) {
1394
1545
  case 0:
1395
1546
  callingPartyInfo = {};
1396
1547
  peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
@@ -1400,10 +1551,10 @@ describe('resolveContact tests', function () {
1400
1551
  callingPartyInfo.name = {
1401
1552
  $: 'Name'
1402
1553
  };
1403
- _context12.next = 1;
1554
+ _context16.next = 1;
1404
1555
  return (0, _Utils.resolveContact)(callingPartyInfo);
1405
1556
  case 1:
1406
- displayInfo = _context12.sent;
1557
+ displayInfo = _context16.sent;
1407
1558
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toBeUndefined();
1408
1559
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1409
1560
  displayName: 'Name'
@@ -1411,15 +1562,15 @@ describe('resolveContact tests', function () {
1411
1562
  peopleListResponse.items = items;
1412
1563
  case 2:
1413
1564
  case "end":
1414
- return _context12.stop();
1565
+ return _context16.stop();
1415
1566
  }
1416
- }, _callee12);
1567
+ }, _callee16);
1417
1568
  })));
1418
- it('Resolve by name - ID as plain UUID instead of part of URI', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee13() {
1569
+ it('Resolve by name - ID as plain UUID instead of part of URI', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
1419
1570
  var _displayInfo3, _displayInfo4, _displayInfo5, _displayInfo6, _displayInfo7, _displayInfo8;
1420
1571
  var callingPartyInfo, peopleListResponse, id, webexSpy, displayInfo;
1421
- return _regenerator.default.wrap(function (_context13) {
1422
- while (1) switch (_context13.prev = _context13.next) {
1572
+ return _regenerator.default.wrap(function (_context17) {
1573
+ while (1) switch (_context17.prev = _context17.next) {
1423
1574
  case 0:
1424
1575
  callingPartyInfo = {};
1425
1576
  peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
@@ -1430,10 +1581,10 @@ describe('resolveContact tests', function () {
1430
1581
  callingPartyInfo.name = {
1431
1582
  $: 'Name'
1432
1583
  };
1433
- _context13.next = 1;
1584
+ _context17.next = 1;
1434
1585
  return (0, _Utils.resolveContact)(callingPartyInfo);
1435
1586
  case 1:
1436
- displayInfo = _context13.sent;
1587
+ displayInfo = _context17.sent;
1437
1588
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1438
1589
  displayName: 'Name'
1439
1590
  }));
@@ -1446,10 +1597,10 @@ describe('resolveContact tests', function () {
1446
1597
  /* Also test empty id */
1447
1598
  peopleListResponse.items[0].id = '';
1448
1599
  webex.people.list.mockResolvedValueOnce(peopleListResponse);
1449
- _context13.next = 2;
1600
+ _context17.next = 2;
1450
1601
  return (0, _Utils.resolveContact)(callingPartyInfo);
1451
1602
  case 2:
1452
- displayInfo = _context13.sent;
1603
+ displayInfo = _context17.sent;
1453
1604
  expect((_displayInfo7 = displayInfo) === null || _displayInfo7 === void 0 ? void 0 : _displayInfo7.id).toStrictEqual('');
1454
1605
  expect((_displayInfo8 = displayInfo) === null || _displayInfo8 === void 0 ? void 0 : _displayInfo8.name).toStrictEqual(peopleListResponse.items[0].displayName);
1455
1606
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
@@ -1458,14 +1609,14 @@ describe('resolveContact tests', function () {
1458
1609
  peopleListResponse.items[0].id = id;
1459
1610
  case 3:
1460
1611
  case "end":
1461
- return _context13.stop();
1612
+ return _context17.stop();
1462
1613
  }
1463
- }, _callee13);
1614
+ }, _callee17);
1464
1615
  })));
1465
- it('Resolve by name - Phone numbers no match for type - work', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee14() {
1616
+ it('Resolve by name - Phone numbers no match for type - work', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
1466
1617
  var callingPartyInfo, peopleListResponse, phoneNumbers, webexSpy, displayInfo;
1467
- return _regenerator.default.wrap(function (_context14) {
1468
- while (1) switch (_context14.prev = _context14.next) {
1618
+ return _regenerator.default.wrap(function (_context18) {
1619
+ while (1) switch (_context18.prev = _context18.next) {
1469
1620
  case 0:
1470
1621
  callingPartyInfo = {};
1471
1622
  peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
@@ -1476,10 +1627,10 @@ describe('resolveContact tests', function () {
1476
1627
  callingPartyInfo.name = {
1477
1628
  $: 'Name'
1478
1629
  };
1479
- _context14.next = 1;
1630
+ _context18.next = 1;
1480
1631
  return (0, _Utils.resolveContact)(callingPartyInfo);
1481
1632
  case 1:
1482
- displayInfo = _context14.sent;
1633
+ displayInfo = _context18.sent;
1483
1634
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.name).toStrictEqual(peopleListResponse.items[0].displayName);
1484
1635
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.num).toStrictEqual(peopleListResponse.items[0].phoneNumbers[0].value);
1485
1636
  expect(displayInfo === null || displayInfo === void 0 ? void 0 : displayInfo.avatarSrc).toStrictEqual(peopleListResponse.items[0].avatar);
@@ -1489,14 +1640,14 @@ describe('resolveContact tests', function () {
1489
1640
  peopleListResponse.items[0].phoneNumbers = phoneNumbers;
1490
1641
  case 2:
1491
1642
  case "end":
1492
- return _context14.stop();
1643
+ return _context18.stop();
1493
1644
  }
1494
- }, _callee14);
1645
+ }, _callee18);
1495
1646
  })));
1496
- it('Resolve by name - Phone numbers empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee15() {
1647
+ it('Resolve by name - Phone numbers empty', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
1497
1648
  var callingPartyInfo, peopleListResponse, phoneNumbers, webexSpy, displayInfo;
1498
- return _regenerator.default.wrap(function (_context15) {
1499
- while (1) switch (_context15.prev = _context15.next) {
1649
+ return _regenerator.default.wrap(function (_context19) {
1650
+ while (1) switch (_context19.prev = _context19.next) {
1500
1651
  case 0:
1501
1652
  callingPartyInfo = {};
1502
1653
  peopleListResponse = (0, _testUtil.getSamplePeopleListResponse)();
@@ -1506,10 +1657,10 @@ describe('resolveContact tests', function () {
1506
1657
  callingPartyInfo.name = {
1507
1658
  $: 'Name'
1508
1659
  };
1509
- _context15.next = 1;
1660
+ _context19.next = 1;
1510
1661
  return (0, _Utils.resolveContact)(callingPartyInfo);
1511
1662
  case 1:
1512
- displayInfo = _context15.sent;
1663
+ displayInfo = _context19.sent;
1513
1664
  expect(webexSpy).toBeCalledOnceWith(expect.objectContaining({
1514
1665
  displayName: 'Name'
1515
1666
  }));
@@ -1519,9 +1670,9 @@ describe('resolveContact tests', function () {
1519
1670
  peopleListResponse.items[0].phoneNumbers = phoneNumbers;
1520
1671
  case 2:
1521
1672
  case "end":
1522
- return _context15.stop();
1673
+ return _context19.stop();
1523
1674
  }
1524
- }, _callee15);
1675
+ }, _callee19);
1525
1676
  })));
1526
1677
  });
1527
1678
  describe('Store and Fetch voicemail tests', function () {
@@ -1639,40 +1790,40 @@ describe('Infer id from UUID Tests', function () {
1639
1790
  });
1640
1791
  });
1641
1792
  describe('Get endpoint by CALLING_BACKEND tests', function () {
1642
- it('verify invalid calling backend ucm for xsi endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee16() {
1793
+ it('verify invalid calling backend ucm for xsi endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
1643
1794
  var _t;
1644
- return _regenerator.default.wrap(function (_context16) {
1645
- while (1) switch (_context16.prev = _context16.next) {
1795
+ return _regenerator.default.wrap(function (_context20) {
1796
+ while (1) switch (_context20.prev = _context20.next) {
1646
1797
  case 0:
1647
1798
  _t = expect;
1648
- _context16.next = 1;
1799
+ _context20.next = 1;
1649
1800
  return (0, _Utils.getXsiActionEndpoint)(webex, {
1650
1801
  file: 'testFile',
1651
1802
  method: 'testMethod'
1652
1803
  }, _types.CALLING_BACKEND.UCM);
1653
1804
  case 1:
1654
- _t(_context16.sent).toBeInstanceOf(Error);
1805
+ _t(_context20.sent).toBeInstanceOf(Error);
1655
1806
  case 2:
1656
1807
  case "end":
1657
- return _context16.stop();
1808
+ return _context20.stop();
1658
1809
  }
1659
- }, _callee16);
1810
+ }, _callee20);
1660
1811
  })));
1661
- it('verify invalid calling backend wxc for vg endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee17() {
1812
+ it('verify invalid calling backend wxc for vg endpoint', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
1662
1813
  var _t2;
1663
- return _regenerator.default.wrap(function (_context17) {
1664
- while (1) switch (_context17.prev = _context17.next) {
1814
+ return _regenerator.default.wrap(function (_context21) {
1815
+ while (1) switch (_context21.prev = _context21.next) {
1665
1816
  case 0:
1666
1817
  _t2 = expect;
1667
- _context17.next = 1;
1818
+ _context21.next = 1;
1668
1819
  return (0, _Utils.getVgActionEndpoint)(webex, _types.CALLING_BACKEND.WXC);
1669
1820
  case 1:
1670
- _t2(_context17.sent).toBeInstanceOf(Error);
1821
+ _t2(_context21.sent).toBeInstanceOf(Error);
1671
1822
  case 2:
1672
1823
  case "end":
1673
- return _context17.stop();
1824
+ return _context21.stop();
1674
1825
  }
1675
- }, _callee17);
1826
+ }, _callee21);
1676
1827
  })));
1677
1828
  });
1678
1829
  describe('Get XSI Action Endpoint tests', function () {
@@ -1694,10 +1845,10 @@ describe('Get XSI Action Endpoint tests', function () {
1694
1845
  beforeEach(function () {
1695
1846
  mockWebex.request.mockClear();
1696
1847
  });
1697
- it('should return xsiEndpoint for WXC backend using _serviceUrls.hydra', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee18() {
1848
+ it('should return xsiEndpoint for WXC backend using _serviceUrls.hydra', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
1698
1849
  var hydraEndpoint, wxcWebex, result;
1699
- return _regenerator.default.wrap(function (_context18) {
1700
- while (1) switch (_context18.prev = _context18.next) {
1850
+ return _regenerator.default.wrap(function (_context22) {
1851
+ while (1) switch (_context22.prev = _context22.next) {
1701
1852
  case 0:
1702
1853
  hydraEndpoint = 'https://hydra-a.wbx2.com/v1/';
1703
1854
  wxcWebex = {
@@ -1717,10 +1868,10 @@ describe('Get XSI Action Endpoint tests', function () {
1717
1868
  }
1718
1869
  }
1719
1870
  };
1720
- _context18.next = 1;
1871
+ _context22.next = 1;
1721
1872
  return (0, _Utils.getXsiActionEndpoint)(wxcWebex, loggerContext, _types.CALLING_BACKEND.WXC);
1722
1873
  case 1:
1723
- result = _context18.sent;
1874
+ result = _context22.sent;
1724
1875
  expect(wxcWebex.request).toBeCalledOnceWith({
1725
1876
  method: _types.HTTP_METHODS.GET,
1726
1877
  uri: "".concat(hydraEndpoint, "/").concat(_constants2.XSI_ACTION_ENDPOINT_ORG_URL_PARAM)
@@ -1729,14 +1880,14 @@ describe('Get XSI Action Endpoint tests', function () {
1729
1880
  expect(wxcWebex.internal.services.get).not.toHaveBeenCalled();
1730
1881
  case 2:
1731
1882
  case "end":
1732
- return _context18.stop();
1883
+ return _context22.stop();
1733
1884
  }
1734
- }, _callee18);
1885
+ }, _callee22);
1735
1886
  })));
1736
- it('should return xsiEndpoint for WXC backend using services.get when _serviceUrls is undefined', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee19() {
1887
+ it('should return xsiEndpoint for WXC backend using services.get when _serviceUrls is undefined', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
1737
1888
  var hydraEndpoint, activeHydraCluster, wxcWebex, result;
1738
- return _regenerator.default.wrap(function (_context19) {
1739
- while (1) switch (_context19.prev = _context19.next) {
1889
+ return _regenerator.default.wrap(function (_context23) {
1890
+ while (1) switch (_context23.prev = _context23.next) {
1740
1891
  case 0:
1741
1892
  hydraEndpoint = 'https://hydra-a.wbx2.com/v1/';
1742
1893
  activeHydraCluster = 'urn:TEAM:us-east-2_a:hydra';
@@ -1755,10 +1906,10 @@ describe('Get XSI Action Endpoint tests', function () {
1755
1906
  }
1756
1907
  }
1757
1908
  };
1758
- _context19.next = 1;
1909
+ _context23.next = 1;
1759
1910
  return (0, _Utils.getXsiActionEndpoint)(wxcWebex, loggerContext, _types.CALLING_BACKEND.WXC);
1760
1911
  case 1:
1761
- result = _context19.sent;
1912
+ result = _context23.sent;
1762
1913
  expect(wxcWebex.internal.services.get).toBeCalledOnceWith(activeHydraCluster);
1763
1914
  expect(wxcWebex.request).toBeCalledOnceWith({
1764
1915
  method: _types.HTTP_METHODS.GET,
@@ -1767,14 +1918,14 @@ describe('Get XSI Action Endpoint tests', function () {
1767
1918
  expect(result).toBe(expectedXsiEndpoint);
1768
1919
  case 2:
1769
1920
  case "end":
1770
- return _context19.stop();
1921
+ return _context23.stop();
1771
1922
  }
1772
- }, _callee19);
1923
+ }, _callee23);
1773
1924
  })));
1774
- it('should return xsiEndpoint for BWRKS backend when URL ends with /v2.0', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee20() {
1925
+ it('should return xsiEndpoint for BWRKS backend when URL ends with /v2.0', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
1775
1926
  var mockResponse, xsiEndpoint;
1776
- return _regenerator.default.wrap(function (_context20) {
1777
- while (1) switch (_context20.prev = _context20.next) {
1927
+ return _regenerator.default.wrap(function (_context24) {
1928
+ while (1) switch (_context24.prev = _context24.next) {
1778
1929
  case 0:
1779
1930
  mockResponse = {
1780
1931
  body: {
@@ -1786,22 +1937,22 @@ describe('Get XSI Action Endpoint tests', function () {
1786
1937
  }
1787
1938
  };
1788
1939
  mockWebex.request.mockResolvedValue(mockResponse);
1789
- _context20.next = 1;
1940
+ _context24.next = 1;
1790
1941
  return (0, _Utils.getXsiActionEndpoint)(mockWebex, loggerContext, _types.CALLING_BACKEND.BWRKS);
1791
1942
  case 1:
1792
- xsiEndpoint = _context20.sent;
1943
+ xsiEndpoint = _context24.sent;
1793
1944
  expect(mockWebex.request).toHaveBeenCalledTimes(1);
1794
1945
  expect(xsiEndpoint).toBe('https://fake-broadworks-url.com');
1795
1946
  case 2:
1796
1947
  case "end":
1797
- return _context20.stop();
1948
+ return _context24.stop();
1798
1949
  }
1799
- }, _callee20);
1950
+ }, _callee24);
1800
1951
  })));
1801
- it('should return xsiEndpoint for BWRKS backend when URL ends with /v2.0/', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee21() {
1952
+ it('should return xsiEndpoint for BWRKS backend when URL ends with /v2.0/', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
1802
1953
  var mockResponse, xsiEndpoint;
1803
- return _regenerator.default.wrap(function (_context21) {
1804
- while (1) switch (_context21.prev = _context21.next) {
1954
+ return _regenerator.default.wrap(function (_context25) {
1955
+ while (1) switch (_context25.prev = _context25.next) {
1805
1956
  case 0:
1806
1957
  mockResponse = {
1807
1958
  body: {
@@ -1813,22 +1964,22 @@ describe('Get XSI Action Endpoint tests', function () {
1813
1964
  }
1814
1965
  };
1815
1966
  mockWebex.request.mockResolvedValue(mockResponse);
1816
- _context21.next = 1;
1967
+ _context25.next = 1;
1817
1968
  return (0, _Utils.getXsiActionEndpoint)(mockWebex, loggerContext, _types.CALLING_BACKEND.BWRKS);
1818
1969
  case 1:
1819
- xsiEndpoint = _context21.sent;
1970
+ xsiEndpoint = _context25.sent;
1820
1971
  expect(mockWebex.request).toHaveBeenCalledTimes(1);
1821
1972
  expect(xsiEndpoint).toBe('https://fake-broadworks-url.com');
1822
1973
  case 2:
1823
1974
  case "end":
1824
- return _context21.stop();
1975
+ return _context25.stop();
1825
1976
  }
1826
- }, _callee21);
1977
+ }, _callee25);
1827
1978
  })));
1828
- it('should return xsiEndpoint for BWRKS backend when URL does not end with any version', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee22() {
1979
+ it('should return xsiEndpoint for BWRKS backend when URL does not end with any version', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee26() {
1829
1980
  var mockResponse, xsiEndpoint;
1830
- return _regenerator.default.wrap(function (_context22) {
1831
- while (1) switch (_context22.prev = _context22.next) {
1981
+ return _regenerator.default.wrap(function (_context26) {
1982
+ while (1) switch (_context26.prev = _context26.next) {
1832
1983
  case 0:
1833
1984
  mockResponse = {
1834
1985
  body: {
@@ -1840,67 +1991,19 @@ describe('Get XSI Action Endpoint tests', function () {
1840
1991
  }
1841
1992
  };
1842
1993
  mockWebex.request.mockResolvedValue(mockResponse);
1843
- _context22.next = 1;
1994
+ _context26.next = 1;
1844
1995
  return (0, _Utils.getXsiActionEndpoint)(mockWebex, loggerContext, _types.CALLING_BACKEND.BWRKS);
1845
1996
  case 1:
1846
- xsiEndpoint = _context22.sent;
1997
+ xsiEndpoint = _context26.sent;
1847
1998
  expect(mockWebex.request).toHaveBeenCalledTimes(1);
1848
1999
  expect(xsiEndpoint).toBe('https://fake-broadworks-url.com');
1849
2000
  case 2:
1850
2001
  case "end":
1851
- return _context22.stop();
2002
+ return _context26.stop();
1852
2003
  }
1853
- }, _callee22);
2004
+ }, _callee26);
1854
2005
  })));
1855
2006
  });
1856
- describe('modifySdpForIPv4', function () {
1857
- it('should return original SDP if input is empty', function () {
1858
- expect((0, _Utils.modifySdpForIPv4)('')).toBe('');
1859
- });
1860
- it('should return original SDP if there is no IPv6 c= line', function () {
1861
- var sdp = "v=0\no=- 12345 67890 IN IP4 192.168.1.1\n\ns=Test Session";
1862
- expect((0, _Utils.modifySdpForIPv4)(sdp)).toEqual(sdp);
1863
- });
1864
- it('should replace IPv6 c= line with default IPv4 if no IPv4 candidate exists', function () {
1865
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1866
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\na=candidate:2 1 UDP 2122260223 192.1.1.1 3478 typ host generation 0 network-id 1 network-cost 10";
1867
- var result = (0, _Utils.modifySdpForIPv4)(sdp);
1868
- expect(result).toEqual(expectedSdp);
1869
- });
1870
- it('should replace IPv6 c= line with an existing IPv4 candidate address', function () {
1871
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 UDP 2122260223 192.168.1.2 3478 typ host";
1872
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.168.1.2\na=candidate:1 1 UDP 2122260223 192.168.1.2 3478 typ host";
1873
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1874
- });
1875
- it('should correctly handle both UDP and TCP candidates by adding only one IPv4 candidate UDP first', function () {
1876
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\n a=candidate:2 1 TCP 2122260223 2001:db8::2 3479 typ host";
1877
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\na=candidate:2 1 UDP 2122260223 192.1.1.1 3478 typ host generation 0 network-id 1 network-cost 10\na=candidate:2 1 TCP 2122260223 2001:db8::2 3479 typ host\n";
1878
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1879
- });
1880
- it('should correctly handle both UDP and TCP candidates by adding only one IPv4 candidate TCP first', function () {
1881
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n a=candidate:1 1 TCP 2122260223 2001:db8::2 3479 typ host\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1882
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\na=candidate:1 1 TCP 2122260223 2001:db8::2 3479 typ host\na=candidate:2 1 TCP 2122260223 192.1.1.1 3479 typ host generation 0 network-id 1 network-cost 10\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1883
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1884
- });
1885
- it('should replace all IPv6 c= line if multiple exist', function () {
1886
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n c=IN IP6 2001:db8::2\n a=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host";
1887
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.1.1.1\nc=IN IP4 192.1.1.1\na=candidate:1 1 UDP 2122260223 2001:db8::1 3478 typ host\na=candidate:2 1 UDP 2122260223 192.1.1.1 3478 typ host generation 0 network-id 1 network-cost 10";
1888
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1889
- });
1890
- it('should not modify SDP if IPv6 c= line is absent and IPv4 candidate already exists', function () {
1891
- var sdp = "v=0\no=- 12345 67890 IN IP4 192.168.1.1\ns=Test Session\nc=IN IP4 192.168.1.1\na=candidate:1 1 UDP 2122260223 192.168.1.1 3478 typ host";
1892
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(sdp.trim());
1893
- });
1894
- it('should handle malformed SDP gracefully and return unmodified input', function () {
1895
- var malformedSdp = "random text without proper format";
1896
- expect((0, _Utils.modifySdpForIPv4)(malformedSdp).trim()).toEqual(malformedSdp.trim());
1897
- });
1898
- it('should handle an SDP with both IP6 and IP4 c= lines correctly', function () {
1899
- var sdp = "v=0\n o=- 12345 67890 IN IP6 2001:db8::1\n s=Test Session\n c=IN IP6 2001:db8::1\n c=IN IP4 192.168.1.3\n a=candidate:1 1 UDP 2122260223 192.168.1.3 3478 typ host";
1900
- var expectedSdp = "v=0\no=- 12345 67890 IN IP6 2001:db8::1\ns=Test Session\nc=IN IP4 192.168.1.3\nc=IN IP4 192.168.1.3\na=candidate:1 1 UDP 2122260223 192.168.1.3 3478 typ host";
1901
- expect((0, _Utils.modifySdpForIPv4)(sdp).trim()).toEqual(expectedSdp.trim());
1902
- });
1903
- });
1904
2007
  describe('uploadLogs', function () {
1905
2008
  var submitLogsMock;
1906
2009
  beforeEach(function () {
@@ -1920,19 +2023,19 @@ describe('uploadLogs', function () {
1920
2023
  afterEach(function () {
1921
2024
  jest.clearAllMocks();
1922
2025
  });
1923
- it('should upload logs and return the response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee23() {
2026
+ it('should upload logs and return the response', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee27() {
1924
2027
  var mockMetaData, logSpy, result;
1925
- return _regenerator.default.wrap(function (_context23) {
1926
- while (1) switch (_context23.prev = _context23.next) {
2028
+ return _regenerator.default.wrap(function (_context27) {
2029
+ while (1) switch (_context27.prev = _context27.next) {
1927
2030
  case 0:
1928
2031
  mockMetaData = {
1929
2032
  correlationId: 'test-correlation'
1930
2033
  };
1931
2034
  logSpy = jest.spyOn(_Logger.default, 'info');
1932
- _context23.next = 1;
2035
+ _context27.next = 1;
1933
2036
  return (0, _Utils.uploadLogs)(mockMetaData, true);
1934
2037
  case 1:
1935
- result = _context23.sent;
2038
+ result = _context27.sent;
1936
2039
  expect(result).toEqual({
1937
2040
  trackingid: '1234',
1938
2041
  feedbackId: 'mocked-uuid-12345'
@@ -1965,14 +2068,14 @@ describe('uploadLogs', function () {
1965
2068
  });
1966
2069
  case 2:
1967
2070
  case "end":
1968
- return _context23.stop();
2071
+ return _context27.stop();
1969
2072
  }
1970
- }, _callee23);
2073
+ }, _callee27);
1971
2074
  })));
1972
- it('should log and throw an error if the upload fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee24() {
2075
+ it('should log and throw an error if the upload fails', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee28() {
1973
2076
  var mockMetaData, mockError, logSpy, _t3;
1974
- return _regenerator.default.wrap(function (_context24) {
1975
- while (1) switch (_context24.prev = _context24.next) {
2077
+ return _regenerator.default.wrap(function (_context28) {
2078
+ while (1) switch (_context28.prev = _context28.next) {
1976
2079
  case 0:
1977
2080
  mockMetaData = {
1978
2081
  correlationId: 'test-correlation'
@@ -1980,17 +2083,17 @@ describe('uploadLogs', function () {
1980
2083
  mockError = new Error('Upload failed'); // Mock the submitLogs to fail
1981
2084
  submitLogsMock.mockRejectedValueOnce(mockError);
1982
2085
  logSpy = jest.spyOn(_Logger.default, 'error');
1983
- _context24.prev = 1;
1984
- _context24.next = 2;
2086
+ _context28.prev = 1;
2087
+ _context28.next = 2;
1985
2088
  return (0, _Utils.uploadLogs)(mockMetaData, true);
1986
2089
  case 2:
1987
2090
  // If we get here, the test should fail since we expected an exception
1988
2091
  expect(true).toBe(false); // This will fail the test if no exception is thrown
1989
- _context24.next = 4;
2092
+ _context28.next = 4;
1990
2093
  break;
1991
2094
  case 3:
1992
- _context24.prev = 3;
1993
- _t3 = _context24["catch"](1);
2095
+ _context28.prev = 3;
2096
+ _t3 = _context28["catch"](1);
1994
2097
  expect(_t3).toBe(mockError);
1995
2098
  expect(logSpy).toHaveBeenCalledWith("Failed to upload Logs ".concat((0, _stringify.default)(_t3)), {
1996
2099
  file: _constants.UTILS_FILE,
@@ -2017,14 +2120,14 @@ describe('uploadLogs', function () {
2017
2120
  });
2018
2121
  case 4:
2019
2122
  case "end":
2020
- return _context24.stop();
2123
+ return _context28.stop();
2021
2124
  }
2022
- }, _callee24, null, [[1, 3]]);
2125
+ }, _callee28, null, [[1, 3]]);
2023
2126
  })));
2024
- it('should log error and not throw an error if the upload fails with throw exception false', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee25() {
2127
+ it('should log error and not throw an error if the upload fails with throw exception false', /*#__PURE__*/(0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee29() {
2025
2128
  var mockMetaData, mockError, logSpy, result;
2026
- return _regenerator.default.wrap(function (_context25) {
2027
- while (1) switch (_context25.prev = _context25.next) {
2129
+ return _regenerator.default.wrap(function (_context29) {
2130
+ while (1) switch (_context29.prev = _context29.next) {
2028
2131
  case 0:
2029
2132
  mockMetaData = {
2030
2133
  correlationId: 'test-correlation',
@@ -2033,10 +2136,10 @@ describe('uploadLogs', function () {
2033
2136
  mockError = new Error('Upload failed'); // Mock the submitLogs to fail
2034
2137
  submitLogsMock.mockRejectedValueOnce(mockError);
2035
2138
  logSpy = jest.spyOn(_Logger.default, 'error');
2036
- _context25.next = 1;
2139
+ _context29.next = 1;
2037
2140
  return (0, _Utils.uploadLogs)(mockMetaData, false);
2038
2141
  case 1:
2039
- result = _context25.sent;
2142
+ result = _context29.sent;
2040
2143
  expect(result).toBeUndefined();
2041
2144
  expect(logSpy).toHaveBeenCalledWith("Failed to upload Logs ".concat((0, _stringify.default)(mockError)), {
2042
2145
  file: _constants.UTILS_FILE,
@@ -2063,9 +2166,9 @@ describe('uploadLogs', function () {
2063
2166
  });
2064
2167
  case 2:
2065
2168
  case "end":
2066
- return _context25.stop();
2169
+ return _context29.stop();
2067
2170
  }
2068
- }, _callee25);
2171
+ }, _callee29);
2069
2172
  })));
2070
2173
  });
2071
2174
  describe('resolveCallingBackend', function () {