@opentok/client 2.35.0-alpha.26 → 2.35.0-alpha.27

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.
@@ -598,11 +598,14 @@ declare namespace OT {
598
598
  connection?: Connection;
599
599
  sessionId: string;
600
600
 
601
- connect(token: string, callback: (error?: OTError) => void): void;
602
- disconnect(): void;
601
+ connect: {
602
+ (token: string, callback: (error?: OTError) => void): Session;
603
+ promise: (token: string) => Promise<Session>;
604
+ }
605
+ disconnect(): Promise<void>;
603
606
  disableForceMute(): Promise<void>;
604
- forceDisconnect(connection: Connection, callback: (error?: OTError) => void): void;
605
- forceUnpublish(stream: Stream, callback: (error?: OTError) => void): void;
607
+ forceDisconnect(connection: Connection, callback: (error?: OTError) => void): Promise<void>;
608
+ forceUnpublish(stream: Stream, callback: (error?: OTError) => void): Promise<void>;
606
609
  forceMuteStream(stream: Stream): Promise<void>;
607
610
  forceMuteAll(excludedStreams?: Stream[]): Promise<void>;
608
611
  getPublisherForStream(stream: Stream): Publisher | undefined;
@@ -615,7 +618,7 @@ declare namespace OT {
615
618
  signal(
616
619
  signal: { type?: string, data?: string, to?: Connection, retryAfterReconnect?: boolean },
617
620
  callback?: (error?: OTError) => void
618
- ): void;
621
+ ): Promise<void>;
619
622
 
620
623
  subscribe(
621
624
  stream: Stream,
@@ -1,11 +1,11 @@
1
1
  /**
2
- * @license OpenTok.js 2.35.0 e629a49d4
2
+ * @license OpenTok.js 2.35.0 87f6a8fb6
3
3
  *
4
4
  * Copyright (c) 2010-2026 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: Fri, 22 May 2026 09:55:51 GMT
8
+ * Date: Fri, 22 May 2026 18:11:26 GMT
9
9
  */
10
10
 
11
11
  (function webpackUniversalModuleDefinition(root, factory) {
@@ -41891,7 +41891,7 @@ function staticConfigFactory(_temp) {
41891
41891
  _ref$axios = _ref.axios,
41892
41892
  axios = _ref$axios === void 0 ? _axios.default : _ref$axios,
41893
41893
  _ref$properties = _ref.properties,
41894
- properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"e629a49d4","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","vonageApiURL":""} : _ref$properties;
41894
+ properties = _ref$properties === void 0 ? {"version":"v2.35.0","buildHash":"87f6a8fb6","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","vonageApiURL":""} : _ref$properties;
41895
41895
  /** @type builtInConfig */
41896
41896
  const builtInConfig = (0, _cloneDeep.default)(properties);
41897
41897
  /**
@@ -70568,6 +70568,26 @@ function SessionFactory(deps) {
70568
70568
  return _this;
70569
70569
  };
70570
70570
 
70571
+ /**
70572
+ * The <code>connect</code> function is also available in a promisified flavour.
70573
+ * This function will resolve to a session object at the moment the event
70574
+ * <code>sessionConnected</code> happens if there were no errors.
70575
+ */
70576
+ this.connect.promise = function () {
70577
+ for (var _len3 = arguments.length, args = new Array(_len3), _key3 = 0; _key3 < _len3; _key3++) {
70578
+ args[_key3] = arguments[_key3];
70579
+ }
70580
+ return new Promise((resolve, reject) => {
70581
+ const session = _this.connect(...args, error => {
70582
+ if (error) {
70583
+ reject(error);
70584
+ } else {
70585
+ resolve(session);
70586
+ }
70587
+ });
70588
+ });
70589
+ };
70590
+
70571
70591
  /**
70572
70592
  * Disconnects from the Vonage Video API session.
70573
70593
  *
@@ -70618,29 +70638,39 @@ function SessionFactory(deps) {
70618
70638
  * Dispatched on other clients if streams are lost as a result of the session disconnecting.
70619
70639
  * </p>
70620
70640
  *
70641
+ * @returns {Promise<void>} A promise that will resolve when the sessionDisconnected event gets fired
70642
+ *
70621
70643
  * @method #disconnect
70622
70644
  * @memberOf Session
70623
70645
  */
70624
70646
  this.disconnect = function () {
70625
- if (this._singlePeerConnectionController) {
70626
- this._singlePeerConnectionController.destroy();
70627
- this._singlePeerConnectionController = null;
70628
- }
70629
- if (cpuPressureMonitor) {
70630
- cpuPressureMonitor.stopMonitoring();
70631
- }
70632
- if (_socket && _socket.isNot('disconnected')) {
70633
- if (_socket.isNot('disconnecting')) {
70634
- if (!_socket.isNot('connecting')) {
70635
- this.logConnectivityEvent('Cancel');
70647
+ return new Promise((resolve, reject) => {
70648
+ try {
70649
+ if (this._singlePeerConnectionController) {
70650
+ this._singlePeerConnectionController.destroy();
70651
+ this._singlePeerConnectionController = null;
70652
+ }
70653
+ if (cpuPressureMonitor) {
70654
+ cpuPressureMonitor.stopMonitoring();
70655
+ }
70656
+ if (_socket && _socket.isNot('disconnected')) {
70657
+ if (_socket.isNot('disconnecting')) {
70658
+ if (!_socket.isNot('connecting')) {
70659
+ this.logConnectivityEvent('Cancel');
70660
+ }
70661
+ setState('disconnecting');
70662
+ _socket.disconnect();
70663
+ this.off('gsmCallEnded', gsmCallEndedHandler);
70664
+ }
70665
+ this.once('sessionDisconnected', resolve);
70666
+ } else {
70667
+ reset();
70668
+ resolve();
70636
70669
  }
70637
- setState('disconnecting');
70638
- _socket.disconnect();
70639
- this.off('gsmCallEnded', gsmCallEndedHandler);
70670
+ } catch (err) {
70671
+ reject(err);
70640
70672
  }
70641
- } else {
70642
- reset();
70643
- }
70673
+ });
70644
70674
  };
70645
70675
  this.destroy = function () {
70646
70676
  this.streams.destroy();
@@ -72019,62 +72049,68 @@ function SessionFactory(deps) {
72019
72049
  * and the signal was sent. It does <i>not</i> indicate that the signal was successfully
72020
72050
  * received by any of the intended recipients.
72021
72051
  *
72052
+ * @returns {Promise<void>} A promise that resolves when the signal has been sent
72053
+ *
72022
72054
  * @method #signal
72023
72055
  * @memberOf Session
72024
72056
  * @see <a href="#event:signal">signal</a> and <a href="#event:signal:type">signal:type</a> events
72025
72057
  */
72026
72058
  this.signal = function (options, completion) {
72027
- let _options = options;
72028
- let _completion = completion || function () {};
72029
- if ((0, _isFunction.default)(_options)) {
72030
- _completion = _options;
72031
- _options = null;
72032
- }
72033
- if (!this.isConnected()) {
72034
- const notConnectedErrorMsg = 'Unable to send signal - you are not connected to the session.';
72035
- dispatchOTError(otError(errors.NOT_CONNECTED, new Error(notConnectedErrorMsg), 500), _completion);
72036
- return;
72037
- }
72038
- function getErrorNameFromCode(code) {
72039
- switch (code) {
72040
- case 400:
72041
- case 413:
72042
- return errors.INVALID_PARAMETER;
72043
- case 429:
72044
- return errors.RATE_LIMIT_EXCEEDED;
72045
- case 404:
72046
- return errors.NOT_FOUND;
72047
- case 500:
72048
- return errors.NOT_CONNECTED;
72049
- case 403:
72050
- return errors.PERMISSION_DENIED;
72051
- case 2001:
72052
- return errors.UNEXPECTED_SERVER_RESPONSE;
72053
- default:
72054
- return undefined;
72059
+ return new Promise((resolve, reject) => {
72060
+ let _options = options;
72061
+ let _completion = completion || function () {};
72062
+ if ((0, _isFunction.default)(_options)) {
72063
+ _completion = _options;
72064
+ _options = null;
72065
+ }
72066
+ const errorCallback = function errorCallback() {
72067
+ _completion(...arguments);
72068
+ reject(...arguments);
72069
+ };
72070
+ if (!this.isConnected()) {
72071
+ const notConnectedErrorMsg = 'Unable to send signal - you are not connected to the session.';
72072
+ dispatchOTError(otError(errors.NOT_CONNECTED, new Error(notConnectedErrorMsg), 500), errorCallback);
72073
+ return;
72055
72074
  }
72056
- }
72057
- if (!_socket) {
72058
- dispatchSocketIsNullError('signal', _completion);
72059
- return;
72060
- }
72061
- _socket.signal(_options, function (error) {
72062
- if (error) {
72063
- const errorName = getErrorNameFromCode(error.code);
72064
- if (errorName) {
72065
- error = otError(errorName, new Error(error.message), error.code);
72075
+ function getErrorNameFromCode(code) {
72076
+ switch (code) {
72077
+ case 400:
72078
+ case 413:
72079
+ return errors.INVALID_PARAMETER;
72080
+ case 429:
72081
+ return errors.RATE_LIMIT_EXCEEDED;
72082
+ case 404:
72083
+ return errors.NOT_FOUND;
72084
+ case 500:
72085
+ return errors.NOT_CONNECTED;
72086
+ case 403:
72087
+ return errors.PERMISSION_DENIED;
72088
+ case 2001:
72089
+ return errors.UNEXPECTED_SERVER_RESPONSE;
72090
+ default:
72091
+ return undefined;
72066
72092
  }
72067
- _completion(error);
72093
+ }
72094
+ if (!_socket) {
72095
+ dispatchSocketIsNullError('signal', errorCallback);
72068
72096
  return;
72069
72097
  }
72070
- for (var _len3 = arguments.length, args = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
72071
- args[_key3 - 1] = arguments[_key3];
72098
+ _socket.signal(_options, error => {
72099
+ if (error) {
72100
+ const errorName = getErrorNameFromCode(error.code);
72101
+ if (errorName) {
72102
+ error = otError(errorName, new Error(error.message), error.code);
72103
+ }
72104
+ errorCallback(error);
72105
+ return;
72106
+ }
72107
+ _completion();
72108
+ resolve();
72109
+ }, this.logEvent);
72110
+ if (options && options.data && typeof options.data !== 'string') {
72111
+ _logging.warn('Signaling of anything other than Strings is deprecated. ' + 'Please update the data property to be a string.');
72072
72112
  }
72073
- _completion(error, ...args);
72074
- }, this.logEvent);
72075
- if (options && options.data && typeof options.data !== 'string') {
72076
- _logging.warn('Signaling of anything other than Strings is deprecated. ' + 'Please update the data property to be a string.');
72077
- }
72113
+ });
72078
72114
  };
72079
72115
 
72080
72116
  /**
@@ -72155,40 +72191,49 @@ function SessionFactory(deps) {
72155
72191
  * });
72156
72192
  * </pre>
72157
72193
  *
72194
+ * @returns {Promise<void>} A promise that resolves when the disconnection happens
72195
+ *
72158
72196
  * @method #forceDisconnect
72159
72197
  * @memberOf Session
72160
72198
  */
72161
72199
 
72162
72200
  this.forceDisconnect = function (connectionOrConnectionId, completionHandler) {
72163
- if (!this.isConnected()) {
72164
- const notConnectedErrorMsg = 'Cannot call forceDisconnect(). You are not ' + 'connected to the session.';
72165
- dispatchOTError(otError(errors.NOT_CONNECTED, new Error(notConnectedErrorMsg), ExceptionCodes.NOT_CONNECTED), completionHandler);
72166
- return;
72167
- }
72168
- const connectionId = typeof connectionOrConnectionId === 'string' ? connectionOrConnectionId : connectionOrConnectionId.id;
72169
- const invalidParameterErrorMsg = 'Invalid Parameter. Check that you have passed valid parameter values into the method call.';
72170
- if (!connectionId) {
72171
- dispatchOTError(otError(errors.INVALID_PARAMETER, new Error(invalidParameterErrorMsg), ExceptionCodes.INVALID_PARAMETER), completionHandler);
72172
- return;
72173
- }
72174
- const notPermittedErrorMsg = 'This token does not allow forceDisconnect. ' + 'The role must be at least `moderator` to enable this functionality';
72175
- if (!permittedTo('forceDisconnect')) {
72176
- dispatchOTError(otError(errors.PERMISSION_DENIED, new Error(notPermittedErrorMsg), ExceptionCodes.UNABLE_TO_FORCE_DISCONNECT), completionHandler);
72177
- return;
72178
- }
72179
- if (!_socket) {
72180
- dispatchSocketIsNullError('forceDisconnect', completionHandler);
72181
- return;
72201
+ if (completionHandler === void 0) {
72202
+ completionHandler = () => {};
72182
72203
  }
72183
- _socket.forceDisconnect(connectionId, function (err) {
72184
- if (err) {
72185
- dispatchOTError(otError(errors.INVALID_PARAMETER, new Error(invalidParameterErrorMsg), ExceptionCodes.INVALID_PARAMETER), completionHandler);
72186
- } else if (completionHandler && (0, _isFunction.default)(completionHandler)) {
72187
- for (var _len4 = arguments.length, args = new Array(_len4 > 1 ? _len4 - 1 : 0), _key4 = 1; _key4 < _len4; _key4++) {
72188
- args[_key4 - 1] = arguments[_key4];
72189
- }
72190
- completionHandler(err, ...args);
72204
+ return new Promise((resolve, reject) => {
72205
+ const errorCallback = function errorCallback() {
72206
+ if (typeof completionHandler === 'function') completionHandler(...arguments);
72207
+ reject(...arguments);
72208
+ };
72209
+ if (!this.isConnected()) {
72210
+ const notConnectedErrorMsg = 'Cannot call forceDisconnect(). You are not ' + 'connected to the session.';
72211
+ dispatchOTError(otError(errors.NOT_CONNECTED, new Error(notConnectedErrorMsg), ExceptionCodes.NOT_CONNECTED), errorCallback);
72212
+ return;
72213
+ }
72214
+ const connectionId = typeof connectionOrConnectionId === 'string' ? connectionOrConnectionId : connectionOrConnectionId.id;
72215
+ const invalidParameterErrorMsg = 'Invalid Parameter. Check that you have passed valid parameter values into the method call.';
72216
+ if (!connectionId) {
72217
+ dispatchOTError(otError(errors.INVALID_PARAMETER, new Error(invalidParameterErrorMsg), ExceptionCodes.INVALID_PARAMETER), errorCallback);
72218
+ return;
72219
+ }
72220
+ const notPermittedErrorMsg = 'This token does not allow forceDisconnect. ' + 'The role must be at least `moderator` to enable this functionality';
72221
+ if (!permittedTo('forceDisconnect')) {
72222
+ dispatchOTError(otError(errors.PERMISSION_DENIED, new Error(notPermittedErrorMsg), ExceptionCodes.UNABLE_TO_FORCE_DISCONNECT), errorCallback);
72223
+ return;
72191
72224
  }
72225
+ if (!_socket) {
72226
+ dispatchSocketIsNullError('forceDisconnect', errorCallback);
72227
+ return;
72228
+ }
72229
+ _socket.forceDisconnect(connectionId, err => {
72230
+ if (err) {
72231
+ dispatchOTError(otError(errors.INVALID_PARAMETER, new Error(invalidParameterErrorMsg), ExceptionCodes.INVALID_PARAMETER), errorCallback);
72232
+ } else {
72233
+ completionHandler();
72234
+ resolve();
72235
+ }
72236
+ });
72192
72237
  });
72193
72238
  };
72194
72239
 
@@ -72246,6 +72291,8 @@ function SessionFactory(deps) {
72246
72291
  * });
72247
72292
  * </pre>
72248
72293
  *
72294
+ * @returns {Promise<void>} A promise that resolves when the unpublish happens
72295
+ *
72249
72296
  * @method #forceUnpublish
72250
72297
  * @memberOf Session
72251
72298
  */
@@ -72254,61 +72301,68 @@ function SessionFactory(deps) {
72254
72301
  if (completionHandler === void 0) {
72255
72302
  completionHandler = () => {};
72256
72303
  }
72257
- const dispatchError = err => dispatchOTError(otError(err.name, new Error(err.msg), err.code), completionHandler);
72258
- const invalidParameterError = {
72259
- msg: 'Invalid Parameter. Check that you have passed valid parameter values into the method call.',
72260
- code: ExceptionCodes.INVALID_PARAMETER,
72261
- name: errors.INVALID_PARAMETER
72262
- };
72263
- const notConnectedError = {
72264
- msg: 'Cannot call forceUnpublish(). You are not connected to the session.',
72265
- code: ExceptionCodes.NOT_CONNECTED,
72266
- name: errors.NOT_CONNECTED
72267
- };
72268
- const notPermittedError = {
72269
- msg: 'This token does not allow forceUnpublish. The role must be at least `moderator` to enable this ' + 'functionality',
72270
- code: ExceptionCodes.UNABLE_TO_FORCE_UNPUBLISH,
72271
- name: errors.PERMISSION_DENIED
72272
- };
72273
- const notFoundError = {
72274
- msg: 'The stream does not exist.',
72275
- name: errors.NOT_FOUND
72276
- };
72277
- const unexpectedError = {
72278
- msg: 'An unexpected error occurred.',
72279
- name: errors.UNEXPECTED_SERVER_RESPONSE,
72280
- code: ExceptionCodes.UNEXPECTED_SERVER_RESPONSE
72281
- };
72282
- if (!streamOrStreamId) {
72283
- dispatchError(invalidParameterError);
72284
- return;
72285
- }
72286
- if (!_this.isConnected()) {
72287
- dispatchError(notConnectedError);
72288
- return;
72289
- }
72290
- const stream = getStream(streamOrStreamId);
72291
- if (!permittedTo('forceUnpublish')) {
72292
- // if this throws an error the handleJsException won't occur
72293
- dispatchError(notPermittedError);
72294
- return;
72295
- }
72296
- if (!_socket) {
72297
- dispatchSocketIsNullError('forceUnpublish', completionHandler);
72298
- return;
72299
- }
72300
- _socket.forceUnpublish(stream.id, err => {
72301
- if (!err) {
72302
- completionHandler(null);
72304
+ return new Promise((resolve, reject) => {
72305
+ const errorCallback = function errorCallback() {
72306
+ if (typeof completionHandler === 'function') completionHandler(...arguments);
72307
+ reject(...arguments);
72308
+ };
72309
+ const dispatchError = err => dispatchOTError(otError(err.name, new Error(err.msg), err.code), errorCallback);
72310
+ const invalidParameterError = {
72311
+ msg: 'Invalid Parameter. Check that you have passed valid parameter values into the method call.',
72312
+ code: ExceptionCodes.INVALID_PARAMETER,
72313
+ name: errors.INVALID_PARAMETER
72314
+ };
72315
+ const notConnectedError = {
72316
+ msg: 'Cannot call forceUnpublish(). You are not connected to the session.',
72317
+ code: ExceptionCodes.NOT_CONNECTED,
72318
+ name: errors.NOT_CONNECTED
72319
+ };
72320
+ const notPermittedError = {
72321
+ msg: 'This token does not allow forceUnpublish. The role must be at least `moderator` to enable this ' + 'functionality',
72322
+ code: ExceptionCodes.UNABLE_TO_FORCE_UNPUBLISH,
72323
+ name: errors.PERMISSION_DENIED
72324
+ };
72325
+ const notFoundError = {
72326
+ msg: 'The stream does not exist.',
72327
+ name: errors.NOT_FOUND
72328
+ };
72329
+ const unexpectedError = {
72330
+ msg: 'An unexpected error occurred.',
72331
+ name: errors.UNEXPECTED_SERVER_RESPONSE,
72332
+ code: ExceptionCodes.UNEXPECTED_SERVER_RESPONSE
72333
+ };
72334
+ if (!streamOrStreamId) {
72335
+ dispatchError(invalidParameterError);
72336
+ return;
72337
+ }
72338
+ if (!_this.isConnected()) {
72339
+ dispatchError(notConnectedError);
72303
72340
  return;
72304
72341
  }
72305
- if (err.code === '404') {
72306
- dispatchError(notFoundError);
72307
- } else if (err.code === '403') {
72342
+ const stream = getStream(streamOrStreamId);
72343
+ if (!permittedTo('forceUnpublish')) {
72344
+ // if this throws an error the handleJsException won't occur
72308
72345
  dispatchError(notPermittedError);
72309
- } else {
72310
- dispatchError(unexpectedError);
72346
+ return;
72347
+ }
72348
+ if (!_socket) {
72349
+ dispatchSocketIsNullError('forceUnpublish', errorCallback);
72350
+ return;
72311
72351
  }
72352
+ _socket.forceUnpublish(stream.id, err => {
72353
+ if (!err) {
72354
+ completionHandler();
72355
+ resolve();
72356
+ return;
72357
+ }
72358
+ if (err.code === '404') {
72359
+ dispatchError(notFoundError);
72360
+ } else if (err.code === '403') {
72361
+ dispatchError(notPermittedError);
72362
+ } else {
72363
+ dispatchError(unexpectedError);
72364
+ }
72365
+ });
72312
72366
  });
72313
72367
  };
72314
72368