@webex/calling 3.12.0-mobius-socket.20 → 3.12.0-mobius-socket.22

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.
@@ -75,6 +75,7 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
75
75
  (0, _defineProperty2.default)(_this, "callManager", void 0);
76
76
  (0, _defineProperty2.default)(_this, "metricManager", void 0);
77
77
  (0, _defineProperty2.default)(_this, "sdkConfig", void 0);
78
+ (0, _defineProperty2.default)(_this, "serviceData", void 0);
78
79
  (0, _defineProperty2.default)(_this, "primaryMobiusUris", void 0);
79
80
  (0, _defineProperty2.default)(_this, "backupMobiusUris", void 0);
80
81
  (0, _defineProperty2.default)(_this, "primaryWssMobiusUris", void 0);
@@ -309,15 +310,15 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
309
310
  _this.mutex = new _asyncMutex.Mutex();
310
311
  _this.webex = _this.sdkConnector.getWebex();
311
312
  _this.sdkConfig = config;
312
- var serviceData = (_this$sdkConfig = _this.sdkConfig) !== null && _this$sdkConfig !== void 0 && (_this$sdkConfig$servi = _this$sdkConfig.serviceData) !== null && _this$sdkConfig$servi !== void 0 && _this$sdkConfig$servi.indicator ? _this.sdkConfig.serviceData : {
313
+ _this.serviceData = (_this$sdkConfig = _this.sdkConfig) !== null && _this$sdkConfig !== void 0 && (_this$sdkConfig$servi = _this$sdkConfig.serviceData) !== null && _this$sdkConfig$servi !== void 0 && _this$sdkConfig$servi.indicator ? _this.sdkConfig.serviceData : {
313
314
  indicator: _types3.ServiceIndicator.CALLING,
314
315
  domain: ''
315
316
  };
316
317
  var logLevel = (_this$sdkConfig2 = _this.sdkConfig) !== null && _this$sdkConfig2 !== void 0 && (_this$sdkConfig2$logg = _this$sdkConfig2.logger) !== null && _this$sdkConfig2$logg !== void 0 && _this$sdkConfig2$logg.level ? _this.sdkConfig.logger.level : _types.LOGGER.ERROR;
317
318
  _Logger.default.setLogger(logLevel, _constants2.CALLING_CLIENT_FILE);
318
- (0, _Utils.validateServiceData)(serviceData);
319
- _this.callManager = (0, _callManager.getCallManager)(_this.webex, serviceData.indicator);
320
- _this.metricManager = (0, _Metrics.getMetricManager)(_this.webex, serviceData.indicator);
319
+ (0, _Utils.validateServiceData)(_this.serviceData);
320
+ _this.callManager = (0, _callManager.getCallManager)(_this.webex, _this.serviceData.indicator);
321
+ _this.metricManager = (0, _Metrics.getMetricManager)(_this.webex, _this.serviceData.indicator);
321
322
  _this.mediaEngine = Media;
322
323
  var adaptedLogger = {
323
324
  log: function log() {
@@ -390,7 +391,7 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
390
391
  value: (function () {
391
392
  var _init = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee7() {
392
393
  var _window, _window$navigator;
393
- var loggerContext, ua, _t;
394
+ var loggerContext, ua, _this$sdkConfig3, rtmsDomain, _t;
394
395
  return _regenerator.default.wrap(function (_context7) {
395
396
  while (1) switch (_context7.prev = _context7.next) {
396
397
  case 0:
@@ -447,12 +448,26 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
447
448
  case 6:
448
449
  this.apiRequest.registerMobiusSocketListener(this.handleMobiusAsyncEvent);
449
450
  case 7:
450
- _context7.next = 8;
451
- return this.createLine();
451
+ // Auto-fetch RTMS domain from service catalog for contact-center flows
452
+ if (this.serviceData.indicator === _types3.ServiceIndicator.CONTACT_CENTER && !this.serviceData.domain) {
453
+ rtmsDomain = this.getRTMSDomain();
454
+ this.serviceData.domain = rtmsDomain;
455
+ if ((_this$sdkConfig3 = this.sdkConfig) !== null && _this$sdkConfig3 !== void 0 && _this$sdkConfig3.serviceData) {
456
+ this.sdkConfig.serviceData.domain = this.serviceData.domain;
457
+ }
458
+ }
459
+ if ((0, _Utils.isValidServiceDomain)(this.serviceData)) {
460
+ _context7.next = 8;
461
+ break;
462
+ }
463
+ throw new Error('Invalid service domain.');
452
464
  case 8:
465
+ _context7.next = 9;
466
+ return this.createLine();
467
+ case 9:
453
468
  this.setupNetworkEventListeners();
454
469
  _Logger.default.log('CallingClient initialization complete', loggerContext);
455
- case 9:
470
+ case 10:
456
471
  case "end":
457
472
  return _context7.stop();
458
473
  }
@@ -464,9 +479,38 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
464
479
  return init;
465
480
  }()
466
481
  /**
467
- * Ping a reliable external endpoint with a short timeout to infer connectivity.
482
+ * Retrieves the RTMS domain from the service catalog for contact-center flows.
483
+ *
484
+ * @returns The RTMS domain from catalog when available.
468
485
  */
469
486
  )
487
+ }, {
488
+ key: "getRTMSDomain",
489
+ value: function getRTMSDomain() {
490
+ _Logger.default.info('Fetching RTMS domain from service catalog', {
491
+ file: _constants2.CALLING_CLIENT_FILE,
492
+ method: _constants2.METHODS.GET_RTMS_DOMAIN
493
+ });
494
+ try {
495
+ var rtmsURL = this.webex.internal.services.get(_constants2.WCC_CALLING_RTMS_DOMAIN);
496
+ var url = new URL(rtmsURL);
497
+ _Logger.default.info("RTMS domain resolved from catalog: ".concat(url.hostname), {
498
+ file: _constants2.CALLING_CLIENT_FILE,
499
+ method: _constants2.METHODS.GET_RTMS_DOMAIN
500
+ });
501
+ return url.hostname;
502
+ } catch (error) {
503
+ _Logger.default.warn("Failed to fetch RTMS domain from service catalog: ".concat(error), {
504
+ file: _constants2.CALLING_CLIENT_FILE,
505
+ method: _constants2.METHODS.GET_RTMS_DOMAIN
506
+ });
507
+ return '';
508
+ }
509
+ }
510
+
511
+ /**
512
+ * Ping a reliable external endpoint with a short timeout to infer connectivity.
513
+ */
470
514
  }, {
471
515
  key: "checkNetworkReachability",
472
516
  value: (function () {
@@ -685,12 +729,12 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
685
729
  key: "getMobiusServers",
686
730
  value: (function () {
687
731
  var _getMobiusServers = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee1() {
688
- var _this$sdkConfig3,
689
- _this$sdkConfig3$disc,
690
- _this$sdkConfig4,
732
+ var _this$sdkConfig4,
691
733
  _this$sdkConfig4$disc,
734
+ _this$sdkConfig5,
735
+ _this$sdkConfig5$disc,
692
736
  _this4 = this;
693
- var useDefault, clientRegion, countryCode, _this$sdkConfig5, _this$sdkConfig5$disc, _this$sdkConfig6, _this$sdkConfig6$disc, _this$webex$internal$, regionInfo, _iterator2, _step2, _loop2, _ret, _t6;
737
+ var useDefault, clientRegion, countryCode, _this$sdkConfig6, _this$sdkConfig6$disc, _this$sdkConfig7, _this$sdkConfig7$disc, _this$webex$internal$, regionInfo, _iterator2, _step2, _loop2, _ret, _t6;
694
738
  return _regenerator.default.wrap(function (_context11) {
695
739
  while (1) switch (_context11.prev = _context11.next) {
696
740
  case 0:
@@ -706,31 +750,33 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
706
750
  5. Otherwise send registration
707
751
  */
708
752
  useDefault = false;
709
- if ((_this$sdkConfig3 = this.sdkConfig) !== null && _this$sdkConfig3 !== void 0 && (_this$sdkConfig3$disc = _this$sdkConfig3.discovery) !== null && _this$sdkConfig3$disc !== void 0 && _this$sdkConfig3$disc.country && (_this$sdkConfig4 = this.sdkConfig) !== null && _this$sdkConfig4 !== void 0 && (_this$sdkConfig4$disc = _this$sdkConfig4.discovery) !== null && _this$sdkConfig4$disc !== void 0 && _this$sdkConfig4$disc.region) {
710
- _Logger.default.log('Updating region and country from the SDK config', {
711
- file: _constants2.CALLING_CLIENT_FILE,
712
- method: _constants2.GET_MOBIUS_SERVERS_UTIL
713
- });
714
- clientRegion = (_this$sdkConfig5 = this.sdkConfig) === null || _this$sdkConfig5 === void 0 ? void 0 : (_this$sdkConfig5$disc = _this$sdkConfig5.discovery) === null || _this$sdkConfig5$disc === void 0 ? void 0 : _this$sdkConfig5$disc.region;
715
- countryCode = (_this$sdkConfig6 = this.sdkConfig) === null || _this$sdkConfig6 === void 0 ? void 0 : (_this$sdkConfig6$disc = _this$sdkConfig6.discovery) === null || _this$sdkConfig6$disc === void 0 ? void 0 : _this$sdkConfig6$disc.country;
716
- this.mobiusHost = ((_this$webex$internal$ = this.webex.internal.services._serviceUrls) === null || _this$webex$internal$ === void 0 ? void 0 : _this$webex$internal$.mobius) || this.webex.internal.services.get(this.webex.internal.services._activeServices.mobius);
717
- } else {
718
- _Logger.default.log('Updating region and country through Region discovery', {
719
- file: _constants2.CALLING_CLIENT_FILE,
720
- method: _constants2.GET_MOBIUS_SERVERS_UTIL
721
- });
722
-
723
- // MOBIUS TODO: Remove this later. Added for testing purposes.
724
- // const regionInfo = await this.getClientRegionInfo();
725
- regionInfo = {
726
- clientRegion: 'US-EAST',
727
- countryCode: 'WS-LOAD-TEST'
728
- };
729
- clientRegion = regionInfo.clientRegion;
730
- countryCode = regionInfo.countryCode;
753
+ if (!((_this$sdkConfig4 = this.sdkConfig) !== null && _this$sdkConfig4 !== void 0 && (_this$sdkConfig4$disc = _this$sdkConfig4.discovery) !== null && _this$sdkConfig4$disc !== void 0 && _this$sdkConfig4$disc.country && (_this$sdkConfig5 = this.sdkConfig) !== null && _this$sdkConfig5 !== void 0 && (_this$sdkConfig5$disc = _this$sdkConfig5.discovery) !== null && _this$sdkConfig5$disc !== void 0 && _this$sdkConfig5$disc.region)) {
754
+ _context11.next = 1;
755
+ break;
731
756
  }
757
+ _Logger.default.log('Updating region and country from the SDK config', {
758
+ file: _constants2.CALLING_CLIENT_FILE,
759
+ method: _constants2.GET_MOBIUS_SERVERS_UTIL
760
+ });
761
+ clientRegion = (_this$sdkConfig6 = this.sdkConfig) === null || _this$sdkConfig6 === void 0 ? void 0 : (_this$sdkConfig6$disc = _this$sdkConfig6.discovery) === null || _this$sdkConfig6$disc === void 0 ? void 0 : _this$sdkConfig6$disc.region;
762
+ countryCode = (_this$sdkConfig7 = this.sdkConfig) === null || _this$sdkConfig7 === void 0 ? void 0 : (_this$sdkConfig7$disc = _this$sdkConfig7.discovery) === null || _this$sdkConfig7$disc === void 0 ? void 0 : _this$sdkConfig7$disc.country;
763
+ this.mobiusHost = ((_this$webex$internal$ = this.webex.internal.services._serviceUrls) === null || _this$webex$internal$ === void 0 ? void 0 : _this$webex$internal$.mobius) || this.webex.internal.services.get(this.webex.internal.services._activeServices.mobius);
764
+ _context11.next = 3;
765
+ break;
766
+ case 1:
767
+ _Logger.default.log('Updating region and country through Region discovery', {
768
+ file: _constants2.CALLING_CLIENT_FILE,
769
+ method: _constants2.GET_MOBIUS_SERVERS_UTIL
770
+ });
771
+ _context11.next = 2;
772
+ return this.getClientRegionInfo();
773
+ case 2:
774
+ regionInfo = _context11.sent;
775
+ clientRegion = regionInfo.clientRegion;
776
+ countryCode = regionInfo.countryCode;
777
+ case 3:
732
778
  if (!(clientRegion && countryCode)) {
733
- _context11.next = 9;
779
+ _context11.next = 12;
734
780
  break;
735
781
  }
736
782
  _Logger.default.log("Found Region: ".concat(clientRegion, " and country: ").concat(countryCode, ", going to fetch Mobius server"), {
@@ -738,7 +784,7 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
738
784
  method: _constants2.GET_MOBIUS_SERVERS_UTIL
739
785
  });
740
786
  _iterator2 = _createForOfIteratorHelper(this.mobiusClusters);
741
- _context11.prev = 1;
787
+ _context11.prev = 4;
742
788
  _loop2 = /*#__PURE__*/_regenerator.default.mark(function _loop2() {
743
789
  var mobius, _response$headers3, _response$headers$tra2, _response$headers4, response, mobiusServers, mobiusUris, abort, _t5;
744
790
  return _regenerator.default.wrap(function (_context10) {
@@ -753,9 +799,7 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
753
799
  _context10.prev = 1;
754
800
  _context10.next = 2;
755
801
  return _this4.webex.request({
756
- // uri: `${this.mobiusHost}${URL_ENDPOINT}?regionCode=${clientRegion}&countryCode=${countryCode}`,
757
- // MOBIUS TODO: Remove this later. Added for testing purposes.
758
- uri: 'https://mobius.aload-calling1.ciscospark.com/api/v1/calling/web/?regionCode=US-EAST&countryCode=WS-LOAD-TEST',
802
+ uri: "".concat(_this4.mobiusHost).concat(_constants2.URL_ENDPOINT, "?regionCode=").concat(clientRegion, "&countryCode=").concat(countryCode),
759
803
  method: _types3.HTTP_METHODS.GET,
760
804
  headers: (0, _defineProperty2.default)((0, _defineProperty2.default)({}, _constants2.CISCO_DEVICE_URL, _this4.webex.internal.device.url), _constants2.SPARK_USER_AGENT, _constants2.CALLING_USER_AGENT),
761
805
  service: _types3.ALLOWED_SERVICES.MOBIUS
@@ -817,40 +861,40 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
817
861
  }, _loop2, null, [[1, 3]]);
818
862
  });
819
863
  _iterator2.s();
820
- case 2:
864
+ case 5:
821
865
  if ((_step2 = _iterator2.n()).done) {
822
- _context11.next = 5;
866
+ _context11.next = 8;
823
867
  break;
824
868
  }
825
- return _context11.delegateYield(_loop2(), "t0", 3);
826
- case 3:
869
+ return _context11.delegateYield(_loop2(), "t0", 6);
870
+ case 6:
827
871
  _ret = _context11.t0;
828
872
  if (!(_ret === 0)) {
829
- _context11.next = 4;
873
+ _context11.next = 7;
830
874
  break;
831
875
  }
832
- return _context11.abrupt("continue", 5);
833
- case 4:
834
- _context11.next = 2;
835
- break;
836
- case 5:
837
- _context11.next = 7;
838
- break;
839
- case 6:
840
- _context11.prev = 6;
841
- _t6 = _context11["catch"](1);
842
- _iterator2.e(_t6);
876
+ return _context11.abrupt("continue", 8);
843
877
  case 7:
844
- _context11.prev = 7;
845
- _iterator2.f();
846
- return _context11.finish(7);
878
+ _context11.next = 5;
879
+ break;
847
880
  case 8:
848
881
  _context11.next = 10;
849
882
  break;
850
883
  case 9:
884
+ _context11.prev = 9;
885
+ _t6 = _context11["catch"](4);
886
+ _iterator2.e(_t6);
887
+ case 10:
888
+ _context11.prev = 10;
889
+ _iterator2.f();
890
+ return _context11.finish(10);
891
+ case 11:
892
+ _context11.next = 13;
893
+ break;
894
+ case 12:
851
895
  /* Setting this to true because region info is possibly undefined */
852
896
  useDefault = true;
853
- case 10:
897
+ case 13:
854
898
  /* Use a default URL if Mobius discovery fails either because of region info failure
855
899
  * or because the discovered Mobius couldn't be reached
856
900
  */
@@ -863,11 +907,11 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
863
907
  this.mobiusHost = "https://".concat(this.mobiusClusters[0].host).concat(_constants2.API_V1);
864
908
  this.primaryMobiusUris = ["".concat(this.mobiusHost).concat(_constants2.URL_ENDPOINT)];
865
909
  }
866
- case 11:
910
+ case 14:
867
911
  case "end":
868
912
  return _context11.stop();
869
913
  }
870
- }, _callee1, this, [[1, 6, 7, 8]]);
914
+ }, _callee1, this, [[4, 9, 10, 11]]);
871
915
  }));
872
916
  function getMobiusServers() {
873
917
  return _getMobiusServers.apply(this, arguments);
@@ -1099,7 +1143,7 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
1099
1143
  key: "createLine",
1100
1144
  value: (function () {
1101
1145
  var _createLine = (0, _asyncToGenerator2.default)(/*#__PURE__*/_regenerator.default.mark(function _callee12() {
1102
- var _this$sdkConfig7, _this$sdkConfig8;
1146
+ var _this$sdkConfig8;
1103
1147
  var line;
1104
1148
  return _regenerator.default.wrap(function (_context14) {
1105
1149
  while (1) switch (_context14.prev = _context14.next) {
@@ -1108,7 +1152,7 @@ var CallingClient = exports.CallingClient = /*#__PURE__*/function (_Eventing) {
1108
1152
  file: _constants2.CALLING_CLIENT_FILE,
1109
1153
  method: _constants2.METHODS.CREATE_LINE
1110
1154
  });
1111
- line = new _line.default(this.webex.internal.device.userId, this.webex.internal.device.url, this.mutex, this.apiRequest.isSocketEnabled() ? (0, _Utils.normalizeMobiusUris)(this.primaryWssMobiusUris) : this.primaryMobiusUris, this.apiRequest.isSocketEnabled() ? (0, _Utils.normalizeMobiusUris)(this.backupWssMobiusUris) : this.backupMobiusUris, this.getLoggingLevel(), (_this$sdkConfig7 = this.sdkConfig) === null || _this$sdkConfig7 === void 0 ? void 0 : _this$sdkConfig7.serviceData, (_this$sdkConfig8 = this.sdkConfig) === null || _this$sdkConfig8 === void 0 ? void 0 : _this$sdkConfig8.jwe);
1155
+ line = new _line.default(this.webex.internal.device.userId, this.webex.internal.device.url, this.mutex, this.apiRequest.isSocketEnabled() ? (0, _Utils.normalizeMobiusUris)(this.primaryWssMobiusUris) : this.primaryMobiusUris, this.apiRequest.isSocketEnabled() ? (0, _Utils.normalizeMobiusUris)(this.backupWssMobiusUris) : this.backupMobiusUris, this.getLoggingLevel(), this.serviceData, (_this$sdkConfig8 = this.sdkConfig) === null || _this$sdkConfig8 === void 0 ? void 0 : _this$sdkConfig8.jwe);
1112
1156
  this.lineDict[line.lineId] = line;
1113
1157
  case 1:
1114
1158
  case "end":