@opentok/client 2.27.5 → 2.27.6

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.
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license OpenTok.js 2.27.5 3cc5fc6
2
+ * @license OpenTok.js 2.27.6 cf306f8
3
3
  *
4
4
  * Copyright (c) 2010-2024 TokBox, Inc.
5
5
  * Subject to the applicable Software Development Kit (SDK) License Agreement:
6
6
  * https://www.vonage.com/legal/communications-apis/terms-of-use/
7
7
  *
8
- * Date: Thu, 16 May 2024 22:31:56 GMT
8
+ * Date: Wed, 05 Jun 2024 14:03:04 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -7922,7 +7922,7 @@ const logging = (0, _log.default)('StaticConfig');
7922
7922
  */
7923
7923
 
7924
7924
  /** @type builtInConfig */
7925
- const builtInConfig = (0, _cloneDeep.default)({"version":"v2.27.5","buildHash":"3cc5fc6","minimumVersion":{"firefox":52,"chrome":49},"debug":false,"websiteURL":"http://www.tokbox.com","configURL":"https://config.opentok.com","ipWhitelistConfigURL":"","cdnURL":"","loggingURL":"https://hlg.tokbox.com/prod","apiURL":"https://anvil.opentok.com"});
7925
+ const builtInConfig = (0, _cloneDeep.default)({"version":"v2.27.6","buildHash":"cf306f8","minimumVersion":{"firefox":52,"chrome":49},"debug":false,"websiteURL":"http://www.tokbox.com","configURL":"https://config.opentok.com","ipWhitelistConfigURL":"","cdnURL":"","loggingURL":"https://hlg.tokbox.com/prod","apiURL":"https://anvil.opentok.com"});
7926
7926
  const whitelistAllowedRuntimeProperties = (0, _pick.default)(['apiURL', 'assetURL', 'cdnURL', 'sessionInfoOverrides', 'loggingURL']);
7927
7927
  const liveConfigMap = {
7928
7928
  apiUrl: 'apiURL',
@@ -9699,33 +9699,40 @@ function PeerConnectionFactory(deps) {
9699
9699
  return _regenerator.default.wrap(function _callee4$(_context4) {
9700
9700
  while (1) switch (_context4.prev = _context4.next) {
9701
9701
  case 0:
9702
- _context4.next = 2;
9702
+ if (api.iceConnectionStateIsConnected()) {
9703
+ _context4.next = 3;
9704
+ break;
9705
+ }
9706
+ api.once('iceConnected', () => api.startDecryption(connectionId, transceiver));
9707
+ return _context4.abrupt("return");
9708
+ case 3:
9709
+ _context4.next = 5;
9703
9710
  return extractSenderId({
9704
9711
  sessionId,
9705
9712
  connectionId
9706
9713
  });
9707
- case 2:
9714
+ case 5:
9708
9715
  senderId = _context4.sent;
9709
9716
  receiver = transceiver.receiver;
9710
- _context4.next = 6;
9711
- return getOrCreateSFrameReceiverClient(connectionId);
9712
- case 6:
9717
+ _context4.next = 9;
9718
+ return getOrCreateSFrameReceiverClient(senderId);
9719
+ case 9:
9713
9720
  sFrameReceiverClient = _context4.sent;
9714
- _context4.prev = 7;
9715
- _context4.next = 10;
9721
+ _context4.prev = 10;
9722
+ _context4.next = 13;
9716
9723
  return sFrameReceiverClient == null ? void 0 : sFrameReceiverClient.decrypt(senderId, receiver);
9717
- case 10:
9718
- _context4.next = 15;
9724
+ case 13:
9725
+ _context4.next = 18;
9719
9726
  break;
9720
- case 12:
9721
- _context4.prev = 12;
9722
- _context4.t0 = _context4["catch"](7);
9723
- logging.error(_context4.t0);
9724
9727
  case 15:
9728
+ _context4.prev = 15;
9729
+ _context4.t0 = _context4["catch"](10);
9730
+ logging.error(_context4.t0);
9731
+ case 18:
9725
9732
  case "end":
9726
9733
  return _context4.stop();
9727
9734
  }
9728
- }, _callee4, null, [[7, 12]]);
9735
+ }, _callee4, null, [[10, 15]]);
9729
9736
  }));
9730
9737
  return function (_x3, _x4) {
9731
9738
  return _ref6.apply(this, arguments);
@@ -9733,24 +9740,16 @@ function PeerConnectionFactory(deps) {
9733
9740
  }();
9734
9741
  _readyToCompleteOffer.resolve();
9735
9742
  const getOrCreateSFrameReceiverClient = /*#__PURE__*/function () {
9736
- var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(connectionId) {
9737
- var sFrameSenderId;
9743
+ var _ref7 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee6(sFrameSenderId) {
9738
9744
  return _regenerator.default.wrap(function _callee6$(_context6) {
9739
9745
  while (1) switch (_context6.prev = _context6.next) {
9740
9746
  case 0:
9741
- _context6.next = 2;
9742
- return extractSenderId({
9743
- sessionId,
9744
- connectionId
9745
- });
9746
- case 2:
9747
- sFrameSenderId = _context6.sent;
9748
9747
  if (!asyncSFrameReceiverClients[sFrameSenderId]) {
9749
- _context6.next = 5;
9748
+ _context6.next = 2;
9750
9749
  break;
9751
9750
  }
9752
9751
  return _context6.abrupt("return", asyncSFrameReceiverClients[sFrameSenderId]);
9753
- case 5:
9752
+ case 2:
9754
9753
  asyncSFrameReceiverClients[sFrameSenderId] = new Promise( /*#__PURE__*/function () {
9755
9754
  var _ref8 = (0, _asyncToGenerator2.default)( /*#__PURE__*/_regenerator.default.mark(function _callee5(resolve) {
9756
9755
  var sharedKey, sFrameReceiverClient;
@@ -9794,7 +9793,7 @@ function PeerConnectionFactory(deps) {
9794
9793
  };
9795
9794
  }());
9796
9795
  return _context6.abrupt("return", asyncSFrameReceiverClients[sFrameSenderId]);
9797
- case 7:
9796
+ case 4:
9798
9797
  case "end":
9799
9798
  return _context6.stop();
9800
9799
  }
@@ -16904,7 +16903,6 @@ function PublisherFactory(_ref) {
16904
16903
  }
16905
16904
  /** @type {WidgetView|null} */
16906
16905
  let widgetView;
16907
- let lastRequestedStreamId;
16908
16906
  let webRTCStream;
16909
16907
  let publishStartTime;
16910
16908
  let microphone;
@@ -16932,17 +16930,18 @@ function PublisherFactory(_ref) {
16932
16930
  /** @type IntervalRunnerDefault | undefined */
16933
16931
  let connectivityAttemptPinger;
16934
16932
 
16935
- // previousSession mimics the publisher.session variable except it's never set to null
16933
+ // _session mimics the publisher.session variable except it's never set to null
16936
16934
  // this allows analytics to refer to it in cases where we disconnect/destroy
16937
16935
  // and go to log analytics and publisher.session has been set to null
16938
- let previousSession;
16936
+ let _session;
16939
16937
  const _options = options,
16940
16938
  _enableSenderStats = _options._enableSenderStats;
16941
- const getLastSession = () => this.session || previousSession || {
16939
+ const getSession = () => this.session || _session || {
16942
16940
  isConnected() {
16943
16941
  return false;
16944
16942
  }
16945
16943
  };
16944
+ const getStreamId = () => this.streamId || '';
16946
16945
  const streamChannels = [];
16947
16946
  const mediaProcessor = new MediaProcessor();
16948
16947
  const amrAudioTrackProcessor = new _amrAudioTrackProcessor.default();
@@ -16966,8 +16965,8 @@ function PublisherFactory(_ref) {
16966
16965
  });
16967
16966
  function getCommonAnalyticsFields() {
16968
16967
  return {
16969
- connectionId: getLastSession().isConnected() ? getLastSession().connection.connectionId : null,
16970
- streamId: lastRequestedStreamId,
16968
+ connectionId: getSession().isConnected() ? getSession().connection.connectionId : null,
16969
+ streamId: getStreamId(),
16971
16970
  widgetType: 'Publisher'
16972
16971
  };
16973
16972
  }
@@ -17278,7 +17277,7 @@ function PublisherFactory(_ref) {
17278
17277
  peerId,
17279
17278
  widgetType: 'Publisher',
17280
17279
  connectionId: this.session && this.session.isConnected() ? this.session.connection.connectionId : null,
17281
- streamId: lastRequestedStreamId,
17280
+ streamId: this.streamId,
17282
17281
  width: widgetView.width,
17283
17282
  height: widgetView.height,
17284
17283
  audioTrack: webRTCStream && webRTCStream.getAudioTracks().length > 0,
@@ -17558,7 +17557,6 @@ function PublisherFactory(_ref) {
17558
17557
  // Disconnect immediately, rather than wait for the WebSocket to
17559
17558
  // reply to our destroyStream message.
17560
17559
  this.disconnect();
17561
- this.session = null;
17562
17560
 
17563
17561
  // We're back to being a stand-alone publisher again.
17564
17562
  if (!state.isDestroyed()) {
@@ -18031,6 +18029,7 @@ function PublisherFactory(_ref) {
18031
18029
  this.stream = null;
18032
18030
  loaded = false;
18033
18031
  this.session = null;
18032
+ this.streamId = null;
18034
18033
  if (!state.isDestroyed()) {
18035
18034
  state.set('NotPublishing');
18036
18035
  }
@@ -20501,15 +20500,22 @@ function PublisherFactory(_ref) {
20501
20500
  }))();
20502
20501
  },
20503
20502
  publishToSession: (session, analyticsReplacement) => {
20503
+ // Check if it is already publishing, i.e. 'PublishingToSession' or 'Publishing'
20504
+ // - 'PublishingToSession' is the state we are establishing the Publisher with Rumor.
20505
+ // - 'Publishing' is the state of publishing to the platform.
20506
+ const isAlreadyPublishing = state.current === 'PublishingToSession' || state.isPublishing();
20507
+ if (isAlreadyPublishing) {
20508
+ logging.warn(`This publisher is already publishing to the session. If you want to
20509
+ republish, please unpublish first.`);
20510
+ return Promise.resolve();
20511
+ }
20504
20512
  if (analyticsReplacement) {
20505
20513
  analytics = analyticsReplacement;
20506
20514
  }
20507
20515
  // Add session property to Publisher
20508
- previousSession = session;
20509
20516
  this.session = session;
20510
- const requestedStreamId = (0, _uuid.default)();
20511
- lastRequestedStreamId = requestedStreamId;
20512
- this.streamId = requestedStreamId;
20517
+ _session = session;
20518
+ this.streamId = (0, _uuid.default)();
20513
20519
  logConnectivityEvent('Attempt', {
20514
20520
  dataChannels: properties.channels,
20515
20521
  properties: (0, _whitelistPublisherProperties.default)(properties)
@@ -20647,8 +20653,6 @@ function PublisherFactory(_ref) {
20647
20653
  type: 'audio',
20648
20654
  active: properties.publishAudio
20649
20655
  }));
20650
- }
20651
- if (didRequestAudio && hasAudioTrack) {
20652
20656
  streamChannels.push(new StreamChannel({
20653
20657
  id: 'caption1',
20654
20658
  type: 'data',
@@ -20684,7 +20688,7 @@ function PublisherFactory(_ref) {
20684
20688
  const streamId = maybeStream.streamId,
20685
20689
  message = maybeStream.message;
20686
20690
  logging.debug('publishToSession: rumor stream id created:', streamId, '(this is different from stream#created, which requires media to actually be ' + 'flowing for mantis sessions)');
20687
- if (streamId !== requestedStreamId) {
20691
+ if (streamId !== this.streamId) {
20688
20692
  throw new Error('streamId response does not match request');
20689
20693
  }
20690
20694
  this.streamId = streamId;
@@ -20730,14 +20734,13 @@ function PublisherFactory(_ref) {
20730
20734
  const err = new Error(createErrorFromReason());
20731
20735
  this.trigger('publishComplete', otError(reason === 'mediaStopped' ? Errors.MEDIA_ENDED : Errors.CANCEL, err));
20732
20736
  }
20733
- this.session = null;
20734
20737
  logAnalyticsEvent('unpublish', 'Success');
20735
20738
  this._.streamDestroyed(reason);
20736
20739
  return this;
20737
20740
  },
20738
20741
  unpublishStreamFromSession: (stream, session, reason) => {
20739
- if (!lastRequestedStreamId || stream.id !== lastRequestedStreamId) {
20740
- logging.warn(`The publisher ${guid} is trying to destroy a stream ${stream.id} that is not attached to it (it has ${lastRequestedStreamId || 'no stream'} attached to it)`);
20742
+ if (stream.id !== this.streamId) {
20743
+ logging.warn(`The publisher ${guid} is trying to destroy a stream ${stream.id} that is not attached to it`);
20741
20744
  return this;
20742
20745
  }
20743
20746
  return this._.unpublishFromSession(session, reason);
@@ -65021,7 +65024,7 @@ function SessionFactory(deps) {
65021
65024
  * @method #publish
65022
65025
  * @memberOf Session
65023
65026
  */
65024
- this.publish = function (publisher, properties, completionHandler) {
65027
+ this.publish = (publisher, properties, completionHandler) => {
65025
65028
  if (typeof publisher === 'function') {
65026
65029
  completionHandler = publisher;
65027
65030
  publisher = undefined;
@@ -65059,11 +65062,15 @@ function SessionFactory(deps) {
65059
65062
  return null;
65060
65063
  }
65061
65064
 
65062
- // If the user has passed in an ID of a element then we create a new publisher.
65063
- if (!publisher || typeof publisher === 'string' || OTHelpers.isElementNode(publisher)) {
65064
- // Initiate a new Publisher with the new session credentials
65065
- publisher = initPublisher(publisher, properties);
65066
- } else if (publisher instanceof Publisher) {
65065
+ // If the user has passed in an ID or an element then we create a new publisher.
65066
+ const shouldInitPublisher = !publisher || typeof publisher === 'string' || OTHelpers.isElementNode(publisher);
65067
+ // If publisher is an instance of Publisher we use that Publisher.
65068
+ const shouldUsePublisher = publisher instanceof Publisher;
65069
+ if (!shouldInitPublisher && !shouldUsePublisher) {
65070
+ dispatchOTError(otError(errors.INVALID_PARAMETER, new Error('Session.publish :: First parameter passed in is neither a ' + 'string nor an instance of the Publisher'), ExceptionCodes.UNABLE_TO_PUBLISH), completionHandler);
65071
+ return undefined;
65072
+ }
65073
+ if (shouldUsePublisher) {
65067
65074
  // If the publisher already has a session attached to it we can
65068
65075
  if ('session' in publisher && publisher.session && 'sessionId' in publisher.session) {
65069
65076
  // send a warning message that we can't publish again.
@@ -65072,26 +65079,23 @@ function SessionFactory(deps) {
65072
65079
  } else {
65073
65080
  _logging.warn(`Cannot publish ${publisher.guid()} publisher already attached to ${publisher.session.sessionId}. Please call session.unpublish(publisher) first.`);
65074
65081
  }
65082
+ completionHandler(null, publisher);
65083
+ return publisher;
65075
65084
  }
65076
- } else {
65077
- dispatchOTError(otError(errors.INVALID_PARAMETER, new Error('Session.publish :: First parameter passed in is neither a ' + 'string nor an instance of the Publisher'), ExceptionCodes.UNABLE_TO_PUBLISH), completionHandler);
65078
- return undefined;
65085
+ } else if (shouldInitPublisher) {
65086
+ // Initiate a new Publisher with the new session credentials
65087
+ publisher = initPublisher(publisher, properties);
65079
65088
  }
65080
65089
  if (_muteOnEntry) {
65081
65090
  publisher._.forceMuteAudio();
65082
65091
  }
65083
65092
 
65084
65093
  // Add publisher reference to the session
65085
- publisher._.publishToSession(this, analytics).catch(err => {
65094
+ publisher._.publishToSession(this, analytics).then(() => completionHandler(null, publisher), err => {
65086
65095
  err.message = `Session.publish :: ${err.message}`;
65087
65096
  _logging.error(err.code, err.message);
65088
- throw err;
65089
- }).then(() => publisher).then(function () {
65090
- for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
65091
- args[_key3] = arguments[_key3];
65092
- }
65093
- return completionHandler(null, ...args);
65094
- }, err => completionHandler(err));
65097
+ completionHandler(err);
65098
+ });
65095
65099
 
65096
65100
  // return the embed publisher
65097
65101
  return publisher;
@@ -66223,8 +66227,8 @@ function SessionFactory(deps) {
66223
66227
  _completion(error);
66224
66228
  return;
66225
66229
  }
66226
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
66227
- args[_key4 - 1] = arguments[_key4];
66230
+ for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
66231
+ args[_key3 - 1] = arguments[_key3];
66228
66232
  }
66229
66233
  _completion(error, ...args);
66230
66234
  }, this.logEvent);
@@ -66336,8 +66340,8 @@ function SessionFactory(deps) {
66336
66340
  if (err) {
66337
66341
  dispatchOTError(otError(errors.INVALID_PARAMETER, new Error(invalidParameterErrorMsg), ExceptionCodes.INVALID_PARAMETER), completionHandler);
66338
66342
  } else if (completionHandler && (0, _isFunction.default)(completionHandler)) {
66339
- for (var _len5 = arguments.length, args = new Array(_len5 > 1 ? _len5 - 1 : 0), _key5 = 1; _key5 < _len5; _key5++) {
66340
- args[_key5 - 1] = arguments[_key5];
66343
+ for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
66344
+ args[_key4 - 1] = arguments[_key4];
66341
66345
  }
66342
66346
  completionHandler(err, ...args);
66343
66347
  }