@aslaluroba/help-center-react 3.0.21 → 3.2.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.
package/dist/services.js CHANGED
@@ -3686,7 +3686,6 @@ class ApiService {
3686
3686
  _this2.tokenExpiryTime = currentTime + response.expiresIn;
3687
3687
  return _this2.currentToken;
3688
3688
  } catch (error) {
3689
- console.error('Error getting token:', error);
3690
3689
  throw error;
3691
3690
  }
3692
3691
  }
@@ -3745,7 +3744,6 @@ class ApiService {
3745
3744
  if (this.config.onError) {
3746
3745
  this.config.onError(error instanceof Error ? error : new Error('Unknown error occurred'));
3747
3746
  }
3748
- console.error('API Error:', error);
3749
3747
  }
3750
3748
  }
3751
3749
 
@@ -4357,7 +4355,7 @@ var ably = {exports: {}};
4357
4355
  });
4358
4356
  return _withTimeoutAsync2.apply(this, arguments);
4359
4357
  }
4360
- var version = "2.13.0";
4358
+ var version = "2.15.0";
4361
4359
 
4362
4360
  // src/common/lib/util/defaults.ts
4363
4361
  var agent = "ably-js/" + version;
@@ -4605,10 +4603,10 @@ var ably = {exports: {}};
4605
4603
  };
4606
4604
  function defaultGetHeaders(options) {
4607
4605
  var {
4608
- format = defaultHeadersOptions.format,
4606
+ format,
4609
4607
  protocolVersion = defaultHeadersOptions.protocolVersion
4610
4608
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4611
- var accept = contentTypes[format];
4609
+ var accept = contentTypes[format != null ? format : options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */];
4612
4610
  return {
4613
4611
  accept,
4614
4612
  "X-Ably-Version": protocolVersion.toString(),
@@ -4617,11 +4615,11 @@ var ably = {exports: {}};
4617
4615
  }
4618
4616
  function defaultPostHeaders(options) {
4619
4617
  var {
4620
- format = defaultHeadersOptions.format,
4618
+ format,
4621
4619
  protocolVersion = defaultHeadersOptions.protocolVersion
4622
4620
  } = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
4623
- var contentType;
4624
- var accept = contentType = contentTypes[format];
4621
+ var accept = contentTypes[format != null ? format : options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */];
4622
+ var contentType = accept;
4625
4623
  return {
4626
4624
  accept,
4627
4625
  "content-type": contentType,
@@ -4945,7 +4943,9 @@ var ably = {exports: {}};
4945
4943
  tokenUri = function tokenUri(host) {
4946
4944
  return client.baseUri(host) + path;
4947
4945
  };
4948
- var requestHeaders = defaults_default.defaultPostHeaders(_this3.client.options);
4946
+ var requestHeaders = defaults_default.defaultPostHeaders(_this3.client.options, {
4947
+ format: "json" /* json */
4948
+ });
4949
4949
  if (resolvedAuthOptions.requestHeaders) _mixin(requestHeaders, resolvedAuthOptions.requestHeaders);
4950
4950
  logger_default.logAction(_this3.logger, logger_default.LOG_MICRO, "Auth.requestToken().requestToken", "Sending POST to " + path + "; Token params: " + JSON.stringify(signedTokenParams));
4951
4951
  _whenPromiseSettles(_this3.client.http.do(HttpMethods_default.Post, tokenUri, requestHeaders, JSON.stringify(signedTokenParams), null), (err, result) => err ? tokenCb(err) : tokenCb(result.error, result.body, result.unpacked));
@@ -6637,9 +6637,7 @@ var ably = {exports: {}};
6637
6637
  return _asyncToGenerator(function* () {
6638
6638
  var client = _this26.client;
6639
6639
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6640
- headers = defaults_default.defaultPostHeaders(client.options, {
6641
- format
6642
- }),
6640
+ headers = defaults_default.defaultPostHeaders(client.options),
6643
6641
  params = {};
6644
6642
  var body = _mixin({
6645
6643
  recipient
@@ -6663,9 +6661,7 @@ var ably = {exports: {}};
6663
6661
  var client = _this27.client;
6664
6662
  var body = devicedetails_default.fromValues(device);
6665
6663
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6666
- headers = defaults_default.defaultPostHeaders(client.options, {
6667
- format
6668
- }),
6664
+ headers = defaults_default.defaultPostHeaders(client.options),
6669
6665
  params = {};
6670
6666
  _mixin(headers, client.options.headers);
6671
6667
  if (client.options.pushFullWait) _mixin(params, {
@@ -6681,9 +6677,7 @@ var ably = {exports: {}};
6681
6677
  return _asyncToGenerator(function* () {
6682
6678
  var client = _this28.client,
6683
6679
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6684
- headers = defaults_default.defaultGetHeaders(client.options, {
6685
- format
6686
- }),
6680
+ headers = defaults_default.defaultGetHeaders(client.options),
6687
6681
  deviceId = deviceIdOrDetails.id || deviceIdOrDetails;
6688
6682
  if (typeof deviceId !== "string" || !deviceId.length) {
6689
6683
  throw new _ErrorInfo2("First argument to DeviceRegistrations#get must be a deviceId string or DeviceDetails", 4e4, 400);
@@ -6699,9 +6693,7 @@ var ably = {exports: {}};
6699
6693
  var client = _this29.client,
6700
6694
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6701
6695
  envelope = _this29.client.http.supportsLinkHeaders ? void 0 : format,
6702
- headers = defaults_default.defaultGetHeaders(client.options, {
6703
- format
6704
- });
6696
+ headers = defaults_default.defaultGetHeaders(client.options);
6705
6697
  _mixin(headers, client.options.headers);
6706
6698
  return new paginatedresource_default(client, "/push/deviceRegistrations", headers, envelope, /*#__PURE__*/function () {
6707
6699
  var _ref3 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -6717,10 +6709,7 @@ var ably = {exports: {}};
6717
6709
  var _this30 = this;
6718
6710
  return _asyncToGenerator(function* () {
6719
6711
  var client = _this30.client,
6720
- format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6721
- headers = defaults_default.defaultGetHeaders(client.options, {
6722
- format
6723
- }),
6712
+ headers = defaults_default.defaultGetHeaders(client.options),
6724
6713
  params = {},
6725
6714
  deviceId = deviceIdOrDetails.id || deviceIdOrDetails;
6726
6715
  if (typeof deviceId !== "string" || !deviceId.length) {
@@ -6761,9 +6750,7 @@ var ably = {exports: {}};
6761
6750
  var client = _this32.client;
6762
6751
  var body = pushchannelsubscription_default.fromValues(subscription);
6763
6752
  var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6764
- headers = defaults_default.defaultPostHeaders(client.options, {
6765
- format
6766
- }),
6753
+ headers = defaults_default.defaultPostHeaders(client.options),
6767
6754
  params = {};
6768
6755
  _mixin(headers, client.options.headers);
6769
6756
  if (client.options.pushFullWait) _mixin(params, {
@@ -6780,9 +6767,7 @@ var ably = {exports: {}};
6780
6767
  var client = _this33.client,
6781
6768
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6782
6769
  envelope = _this33.client.http.supportsLinkHeaders ? void 0 : format,
6783
- headers = defaults_default.defaultGetHeaders(client.options, {
6784
- format
6785
- });
6770
+ headers = defaults_default.defaultGetHeaders(client.options);
6786
6771
  _mixin(headers, client.options.headers);
6787
6772
  return new paginatedresource_default(client, "/push/channelSubscriptions", headers, envelope, /*#__PURE__*/function () {
6788
6773
  var _ref4 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -6815,9 +6800,7 @@ var ably = {exports: {}};
6815
6800
  var client = _this35.client,
6816
6801
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6817
6802
  envelope = _this35.client.http.supportsLinkHeaders ? void 0 : format,
6818
- headers = defaults_default.defaultGetHeaders(client.options, {
6819
- format
6820
- });
6803
+ headers = defaults_default.defaultGetHeaders(client.options);
6821
6804
  _mixin(headers, client.options.headers);
6822
6805
  if (client.options.pushFullWait) _mixin(params, {
6823
6806
  fullWait: "true"
@@ -6980,9 +6963,7 @@ var ably = {exports: {}};
6980
6963
  var client = _this38.channel.client,
6981
6964
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
6982
6965
  envelope = _this38.channel.client.http.supportsLinkHeaders ? void 0 : format,
6983
- headers = defaults_default.defaultGetHeaders(client.options, {
6984
- format
6985
- });
6966
+ headers = defaults_default.defaultGetHeaders(client.options);
6986
6967
  _mixin(headers, client.options.headers);
6987
6968
  return new paginatedresource_default(client, _this38.channel.client.rest.presenceMixin.basePath(_this38), headers, envelope, /*#__PURE__*/function () {
6988
6969
  var _ref6 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -7106,6 +7087,21 @@ var ably = {exports: {}};
7106
7087
  } else if (!this.annotations.summary) {
7107
7088
  this.annotations.summary = {};
7108
7089
  }
7090
+ if (this.annotations && this.annotations.summary) {
7091
+ for (var [type, summaryEntry] of Object.entries(this.annotations.summary)) {
7092
+ if (type.endsWith(":distinct.v1") || type.endsWith(":unique.v1") || type.endsWith(":multiple.v1")) {
7093
+ for (var [, entry] of Object.entries(summaryEntry)) {
7094
+ if (!entry.clipped) {
7095
+ entry.clipped = false;
7096
+ }
7097
+ }
7098
+ } else if (type.endsWith(":flag.v1")) {
7099
+ if (!summaryEntry.clipped) {
7100
+ summaryEntry.clipped = false;
7101
+ }
7102
+ }
7103
+ }
7104
+ }
7109
7105
  }
7110
7106
  encode(options) {
7111
7107
  var _this40 = this;
@@ -7255,9 +7251,7 @@ var ably = {exports: {}};
7255
7251
  options = client.options,
7256
7252
  format = options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7257
7253
  idempotentRestPublishing = client.options.idempotentRestPublishing,
7258
- headers = defaults_default.defaultPostHeaders(client.options, {
7259
- format
7260
- });
7254
+ headers = defaults_default.defaultPostHeaders(client.options);
7261
7255
  _mixin(headers, options.headers);
7262
7256
  if (idempotentRestPublishing && allEmptyIds(messages)) {
7263
7257
  var msgIdBase = yield _randomString(MSG_ID_ENTROPY_BYTES);
@@ -7286,6 +7280,38 @@ var ably = {exports: {}};
7286
7280
  return _this46.client.rest.channelMixin.status(_this46);
7287
7281
  })();
7288
7282
  }
7283
+ getMessage(serialOrMessage) {
7284
+ var _this47 = this;
7285
+ return _asyncToGenerator(function* () {
7286
+ logger_default.logAction(_this47.logger, logger_default.LOG_MICRO, "RestChannel.getMessage()", "channel = " + _this47.name);
7287
+ return _this47.client.rest.channelMixin.getMessage(_this47, serialOrMessage);
7288
+ })();
7289
+ }
7290
+ updateMessage(message, operation, params) {
7291
+ var _this48 = this;
7292
+ return _asyncToGenerator(function* () {
7293
+ logger_default.logAction(_this48.logger, logger_default.LOG_MICRO, "RestChannel.updateMessage()", "channel = " + _this48.name);
7294
+ return _this48.client.rest.channelMixin.updateDeleteMessage(_this48, {
7295
+ isDelete: false
7296
+ }, message, operation, params);
7297
+ })();
7298
+ }
7299
+ deleteMessage(message, operation, params) {
7300
+ var _this49 = this;
7301
+ return _asyncToGenerator(function* () {
7302
+ logger_default.logAction(_this49.logger, logger_default.LOG_MICRO, "RestChannel.deleteMessage()", "channel = " + _this49.name);
7303
+ return _this49.client.rest.channelMixin.updateDeleteMessage(_this49, {
7304
+ isDelete: true
7305
+ }, message, operation, params);
7306
+ })();
7307
+ }
7308
+ getMessageVersions(serialOrMessage, params) {
7309
+ var _this50 = this;
7310
+ return _asyncToGenerator(function* () {
7311
+ logger_default.logAction(_this50.logger, logger_default.LOG_MICRO, "RestChannel.getMessageVersions()", "channel = " + _this50.name);
7312
+ return _this50.client.rest.channelMixin.getMessageVersions(_this50, serialOrMessage, params);
7313
+ })();
7314
+ }
7289
7315
  };
7290
7316
  var restchannel_default = RestChannel;
7291
7317
 
@@ -7314,9 +7340,7 @@ var ably = {exports: {}};
7314
7340
  var client = channel.client,
7315
7341
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7316
7342
  envelope = channel.client.http.supportsLinkHeaders ? void 0 : format,
7317
- headers = defaults_default.defaultGetHeaders(client.options, {
7318
- format
7319
- });
7343
+ headers = defaults_default.defaultGetHeaders(client.options);
7320
7344
  _mixin(headers, client.options.headers);
7321
7345
  return new paginatedresource_default(client, this.basePath(channel) + "/messages", headers, envelope, /*#__PURE__*/function () {
7322
7346
  var _ref7 = _asyncToGenerator(function* (body, headers2, unpacked) {
@@ -7329,16 +7353,81 @@ var ably = {exports: {}};
7329
7353
  }()).get(params);
7330
7354
  }
7331
7355
  static status(channel) {
7332
- var _this47 = this;
7356
+ var _this51 = this;
7333
7357
  return _asyncToGenerator(function* () {
7334
7358
  var format = channel.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
7335
- var headers = defaults_default.defaultPostHeaders(channel.client.options, {
7336
- format
7337
- });
7338
- var response = yield resource_default.get(channel.client, _this47.basePath(channel), headers, {}, format, true);
7359
+ var headers = defaults_default.defaultPostHeaders(channel.client.options);
7360
+ var response = yield resource_default.get(channel.client, _this51.basePath(channel), headers, {}, format, true);
7339
7361
  return response.body;
7340
7362
  })();
7341
7363
  }
7364
+ static getMessage(channel, serialOrMessage) {
7365
+ var _this52 = this;
7366
+ return _asyncToGenerator(function* () {
7367
+ var serial = typeof serialOrMessage === "string" ? serialOrMessage : serialOrMessage.serial;
7368
+ if (!serial) {
7369
+ throw new _ErrorInfo2('This message lacks a serial. Make sure you have enabled "Message annotations, updates, and deletes" in channel settings on your dashboard.', 40003, 400);
7370
+ }
7371
+ var client = channel.client;
7372
+ var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
7373
+ var headers = defaults_default.defaultGetHeaders(client.options);
7374
+ _mixin(headers, client.options.headers);
7375
+ var {
7376
+ body,
7377
+ unpacked
7378
+ } = yield resource_default.get(client, _this52.basePath(channel) + "/messages/" + encodeURIComponent(serial), headers, {}, null, true);
7379
+ var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
7380
+ return _fromEncoded2(decoded, channel);
7381
+ })();
7382
+ }
7383
+ static updateDeleteMessage(channel, opts, message, operation, params) {
7384
+ var _this53 = this;
7385
+ return _asyncToGenerator(function* () {
7386
+ if (!message.serial) {
7387
+ throw new _ErrorInfo2('This message lacks a serial and cannot be updated. Make sure you have enabled "Message annotations, updates, and deletes" in channel settings on your dashboard.', 40003, 400);
7388
+ }
7389
+ var client = channel.client;
7390
+ var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
7391
+ var headers = defaults_default.defaultPostHeaders(client.options);
7392
+ _mixin(headers, client.options.headers);
7393
+ var encoded = null;
7394
+ if (message.data !== void 0) {
7395
+ encoded = yield message_default.fromValues(message).encode(channel.channelOptions);
7396
+ }
7397
+ var req = {
7398
+ serial: message.serial,
7399
+ operation,
7400
+ name: message.name,
7401
+ data: encoded && encoded.data,
7402
+ encoding: encoded && encoded.encoding,
7403
+ extras: message.extras
7404
+ };
7405
+ var requestBody = serialize(req, client._MsgPack, format);
7406
+ var method = opts.isDelete ? resource_default.post : resource_default.patch;
7407
+ var pathSuffix = opts.isDelete ? "/delete" : "";
7408
+ yield method(client, _this53.basePath(channel) + "/messages/" + encodeURIComponent(message.serial) + pathSuffix, requestBody, headers, params || {}, null, true);
7409
+ })();
7410
+ }
7411
+ static getMessageVersions(channel, serialOrMessage, params) {
7412
+ var serial = typeof serialOrMessage === "string" ? serialOrMessage : serialOrMessage.serial;
7413
+ if (!serial) {
7414
+ throw new _ErrorInfo2('This message lacks a serial. Make sure you have enabled "Message annotations, updates, and deletes" in channel settings on your dashboard.', 40003, 400);
7415
+ }
7416
+ var client = channel.client;
7417
+ var format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */;
7418
+ var envelope = channel.client.http.supportsLinkHeaders ? void 0 : format;
7419
+ var headers = defaults_default.defaultGetHeaders(client.options);
7420
+ _mixin(headers, client.options.headers);
7421
+ return new paginatedresource_default(client, this.basePath(channel) + "/messages/" + encodeURIComponent(serial) + "/versions", headers, envelope, /*#__PURE__*/function () {
7422
+ var _ref8 = _asyncToGenerator(function* (body, headers2, unpacked) {
7423
+ var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
7424
+ return _fromEncodedArray2(decoded, channel);
7425
+ });
7426
+ return function (_x62, _x63, _x64) {
7427
+ return _ref8.apply(this, arguments);
7428
+ };
7429
+ }()).get(params || {});
7430
+ }
7342
7431
  };
7343
7432
 
7344
7433
  // src/common/lib/client/restpresencemixin.ts
@@ -7347,22 +7436,20 @@ var ably = {exports: {}};
7347
7436
  return RestChannelMixin.basePath(presence.channel) + "/presence";
7348
7437
  }
7349
7438
  static history(presence, params) {
7350
- var _this48 = this;
7439
+ var _this54 = this;
7351
7440
  return _asyncToGenerator(function* () {
7352
7441
  var client = presence.channel.client,
7353
7442
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7354
7443
  envelope = presence.channel.client.http.supportsLinkHeaders ? void 0 : format,
7355
- headers = defaults_default.defaultGetHeaders(client.options, {
7356
- format
7357
- });
7444
+ headers = defaults_default.defaultGetHeaders(client.options);
7358
7445
  _mixin(headers, client.options.headers);
7359
- return new paginatedresource_default(client, _this48.basePath(presence) + "/history", headers, envelope, /*#__PURE__*/function () {
7360
- var _ref8 = _asyncToGenerator(function* (body, headers2, unpacked) {
7446
+ return new paginatedresource_default(client, _this54.basePath(presence) + "/history", headers, envelope, /*#__PURE__*/function () {
7447
+ var _ref9 = _asyncToGenerator(function* (body, headers2, unpacked) {
7361
7448
  var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
7362
7449
  return _fromEncodedArray(decoded, presence.channel);
7363
7450
  });
7364
- return function (_x62, _x63, _x64) {
7365
- return _ref8.apply(this, arguments);
7451
+ return function (_x65, _x66, _x67) {
7452
+ return _ref9.apply(this, arguments);
7366
7453
  };
7367
7454
  }()).get(params);
7368
7455
  })();
@@ -7384,32 +7471,39 @@ var ably = {exports: {}};
7384
7471
  this.push = new push_default(this.client);
7385
7472
  }
7386
7473
  stats(params) {
7387
- var _this49 = this;
7474
+ var _this55 = this;
7388
7475
  return _asyncToGenerator(function* () {
7389
- var headers = defaults_default.defaultGetHeaders(_this49.client.options),
7390
- format = _this49.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7391
- envelope = _this49.client.http.supportsLinkHeaders ? void 0 : format;
7392
- _mixin(headers, _this49.client.options.headers);
7393
- return new paginatedresource_default(_this49.client, "/stats", headers, envelope, function (body, headers2, unpacked) {
7394
- var statsValues = unpacked ? body : JSON.parse(body);
7395
- for (var i = 0; i < statsValues.length; i++) statsValues[i] = stats_default.fromValues(statsValues[i]);
7396
- return statsValues;
7397
- }).get(params);
7476
+ var headers = defaults_default.defaultGetHeaders(_this55.client.options),
7477
+ format = _this55.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7478
+ envelope = _this55.client.http.supportsLinkHeaders ? void 0 : format;
7479
+ _mixin(headers, _this55.client.options.headers);
7480
+ return new paginatedresource_default(_this55.client, "/stats", headers, envelope, /*#__PURE__*/function () {
7481
+ var _ref0 = _asyncToGenerator(function* (body, _, unpacked) {
7482
+ var statsValues = unpacked ? body : _decodeBody(body, _this55.client._MsgPack, format);
7483
+ for (var i = 0; i < statsValues.length; i++) statsValues[i] = stats_default.fromValues(statsValues[i]);
7484
+ return statsValues;
7485
+ });
7486
+ return function (_x68, _x69, _x70) {
7487
+ return _ref0.apply(this, arguments);
7488
+ };
7489
+ }()).get(params);
7398
7490
  })();
7399
7491
  }
7400
7492
  time(params) {
7401
- var _this50 = this;
7493
+ var _this56 = this;
7402
7494
  return _asyncToGenerator(function* () {
7403
- var headers = defaults_default.defaultGetHeaders(_this50.client.options);
7404
- if (_this50.client.options.headers) _mixin(headers, _this50.client.options.headers);
7495
+ var headers = defaults_default.defaultGetHeaders(_this56.client.options, {
7496
+ format: "json" /* json */
7497
+ });
7498
+ if (_this56.client.options.headers) _mixin(headers, _this56.client.options.headers);
7405
7499
  var timeUri = host => {
7406
- return _this50.client.baseUri(host) + "/time";
7500
+ return _this56.client.baseUri(host) + "/time";
7407
7501
  };
7408
7502
  var {
7409
7503
  error,
7410
7504
  body,
7411
7505
  unpacked
7412
- } = yield _this50.client.http.do(HttpMethods_default.Get, timeUri, headers, null, params);
7506
+ } = yield _this56.client.http.do(HttpMethods_default.Get, timeUri, headers, null, params);
7413
7507
  if (error) {
7414
7508
  throw error;
7415
7509
  }
@@ -7418,47 +7512,47 @@ var ably = {exports: {}};
7418
7512
  if (!time) {
7419
7513
  throw new _ErrorInfo2("Internal error (unexpected result type from GET /time)", 5e4, 500);
7420
7514
  }
7421
- _this50.client.serverTimeOffset = time - Date.now();
7515
+ _this56.client.serverTimeOffset = time - Date.now();
7422
7516
  return time;
7423
7517
  })();
7424
7518
  }
7425
7519
  request(method, path, version2, params, body, customHeaders) {
7426
- var _this51 = this;
7520
+ var _this57 = this;
7427
7521
  return _asyncToGenerator(function* () {
7428
7522
  var _a2;
7429
7523
  var [encoder, decoder, format] = (() => {
7430
- if (_this51.client.options.useBinaryProtocol) {
7431
- if (!_this51.client._MsgPack) {
7524
+ if (_this57.client.options.useBinaryProtocol) {
7525
+ if (!_this57.client._MsgPack) {
7432
7526
  _throwMissingPluginError("MsgPack");
7433
7527
  }
7434
- return [_this51.client._MsgPack.encode, _this51.client._MsgPack.decode, "msgpack" /* msgpack */];
7528
+ return [_this57.client._MsgPack.encode, _this57.client._MsgPack.decode, "msgpack" /* msgpack */];
7435
7529
  } else {
7436
7530
  return [JSON.stringify, JSON.parse, "json" /* json */];
7437
7531
  }
7438
7532
  })();
7439
- var envelope = _this51.client.http.supportsLinkHeaders ? void 0 : format;
7533
+ var envelope = _this57.client.http.supportsLinkHeaders ? void 0 : format;
7440
7534
  params = params || {};
7441
7535
  var _method = method.toLowerCase();
7442
- var headers = _method == "get" ? defaults_default.defaultGetHeaders(_this51.client.options, {
7536
+ var headers = _method == "get" ? defaults_default.defaultGetHeaders(_this57.client.options, {
7443
7537
  format,
7444
7538
  protocolVersion: version2
7445
- }) : defaults_default.defaultPostHeaders(_this51.client.options, {
7539
+ }) : defaults_default.defaultPostHeaders(_this57.client.options, {
7446
7540
  format,
7447
7541
  protocolVersion: version2
7448
7542
  });
7449
7543
  if (typeof body !== "string") {
7450
7544
  body = (_a2 = encoder(body)) != null ? _a2 : null;
7451
7545
  }
7452
- _mixin(headers, _this51.client.options.headers);
7546
+ _mixin(headers, _this57.client.options.headers);
7453
7547
  if (customHeaders) {
7454
7548
  _mixin(headers, customHeaders);
7455
7549
  }
7456
- var paginatedResource = new paginatedresource_default(_this51.client, path, headers, envelope, /*#__PURE__*/function () {
7457
- var _ref9 = _asyncToGenerator(function* (resbody, headers2, unpacked) {
7550
+ var paginatedResource = new paginatedresource_default(_this57.client, path, headers, envelope, /*#__PURE__*/function () {
7551
+ var _ref1 = _asyncToGenerator(function* (resbody, headers2, unpacked) {
7458
7552
  return _ensureArray(unpacked ? resbody : decoder(resbody));
7459
7553
  });
7460
- return function (_x65, _x66, _x67) {
7461
- return _ref9.apply(this, arguments);
7554
+ return function (_x71, _x72, _x73) {
7555
+ return _ref1.apply(this, arguments);
7462
7556
  };
7463
7557
  }(), /* useHttpPaginatedResponse: */
7464
7558
  true);
@@ -7473,7 +7567,7 @@ var ably = {exports: {}};
7473
7567
  })();
7474
7568
  }
7475
7569
  batchPublish(specOrSpecs) {
7476
- var _this52 = this;
7570
+ var _this58 = this;
7477
7571
  return _asyncToGenerator(function* () {
7478
7572
  var requestBodyDTO;
7479
7573
  var singleSpecMode;
@@ -7484,14 +7578,12 @@ var ably = {exports: {}};
7484
7578
  requestBodyDTO = [specOrSpecs];
7485
7579
  singleSpecMode = true;
7486
7580
  }
7487
- var format = _this52.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7488
- headers = defaults_default.defaultPostHeaders(_this52.client.options, {
7489
- format
7490
- });
7491
- if (_this52.client.options.headers) _mixin(headers, _this52.client.options.headers);
7492
- var requestBody = _encodeBody(requestBodyDTO, _this52.client._MsgPack, format);
7493
- var response = yield resource_default.post(_this52.client, "/messages", requestBody, headers, {}, null, true);
7494
- var batchResults = response.unpacked ? response.body : _decodeBody(response.body, _this52.client._MsgPack, format);
7581
+ var format = _this58.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7582
+ headers = defaults_default.defaultPostHeaders(_this58.client.options);
7583
+ if (_this58.client.options.headers) _mixin(headers, _this58.client.options.headers);
7584
+ var requestBody = _encodeBody(requestBodyDTO, _this58.client._MsgPack, format);
7585
+ var response = yield resource_default.post(_this58.client, "/messages", requestBody, headers, {}, null, true);
7586
+ var batchResults = response.unpacked ? response.body : _decodeBody(response.body, _this58.client._MsgPack, format);
7495
7587
  if (singleSpecMode) {
7496
7588
  return batchResults[0];
7497
7589
  } else {
@@ -7500,39 +7592,35 @@ var ably = {exports: {}};
7500
7592
  })();
7501
7593
  }
7502
7594
  batchPresence(channels) {
7503
- var _this53 = this;
7595
+ var _this59 = this;
7504
7596
  return _asyncToGenerator(function* () {
7505
- var format = _this53.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7506
- headers = defaults_default.defaultPostHeaders(_this53.client.options, {
7507
- format
7508
- });
7509
- if (_this53.client.options.headers) _mixin(headers, _this53.client.options.headers);
7597
+ var format = _this59.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7598
+ headers = defaults_default.defaultGetHeaders(_this59.client.options);
7599
+ if (_this59.client.options.headers) _mixin(headers, _this59.client.options.headers);
7510
7600
  var channelsParam = channels.join(",");
7511
- var response = yield resource_default.get(_this53.client, "/presence", headers, {
7601
+ var response = yield resource_default.get(_this59.client, "/presence", headers, {
7512
7602
  channels: channelsParam
7513
7603
  }, null, true);
7514
- return response.unpacked ? response.body : _decodeBody(response.body, _this53.client._MsgPack, format);
7604
+ return response.unpacked ? response.body : _decodeBody(response.body, _this59.client._MsgPack, format);
7515
7605
  })();
7516
7606
  }
7517
7607
  revokeTokens(specifiers, options) {
7518
- var _this54 = this;
7608
+ var _this60 = this;
7519
7609
  return _asyncToGenerator(function* () {
7520
- if (useTokenAuth(_this54.client.options)) {
7610
+ if (useTokenAuth(_this60.client.options)) {
7521
7611
  throw new _ErrorInfo2("Cannot revoke tokens when using token auth", 40162, 401);
7522
7612
  }
7523
- var keyName = _this54.client.options.keyName;
7613
+ var keyName = _this60.client.options.keyName;
7524
7614
  var resolvedOptions = options != null ? options : {};
7525
7615
  var requestBodyDTO = __spreadValues({
7526
7616
  targets: specifiers.map(specifier => "".concat(specifier.type, ":").concat(specifier.value))
7527
7617
  }, resolvedOptions);
7528
- var format = _this54.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7529
- headers = defaults_default.defaultPostHeaders(_this54.client.options, {
7530
- format
7531
- });
7532
- if (_this54.client.options.headers) _mixin(headers, _this54.client.options.headers);
7533
- var requestBody = _encodeBody(requestBodyDTO, _this54.client._MsgPack, format);
7534
- var response = yield resource_default.post(_this54.client, "/keys/".concat(keyName, "/revokeTokens"), requestBody, headers, {}, null, true);
7535
- return response.unpacked ? response.body : _decodeBody(response.body, _this54.client._MsgPack, format);
7618
+ var format = _this60.client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7619
+ headers = defaults_default.defaultPostHeaders(_this60.client.options);
7620
+ if (_this60.client.options.headers) _mixin(headers, _this60.client.options.headers);
7621
+ var requestBody = _encodeBody(requestBodyDTO, _this60.client._MsgPack, format);
7622
+ var response = yield resource_default.post(_this60.client, "/keys/".concat(keyName, "/revokeTokens"), requestBody, headers, {}, null, true);
7623
+ return response.unpacked ? response.body : _decodeBody(response.body, _this60.client._MsgPack, format);
7536
7624
  })();
7537
7625
  }
7538
7626
  };
@@ -7616,7 +7704,7 @@ var ably = {exports: {}};
7616
7704
 
7617
7705
  // src/common/lib/types/annotation.ts
7618
7706
  var actions4 = ["annotation.create", "annotation.delete"];
7619
- function fromEncoded3(_x68, _x69, _x70) {
7707
+ function fromEncoded3(_x74, _x75, _x76) {
7620
7708
  return _fromEncoded8.apply(this, arguments);
7621
7709
  }
7622
7710
  function _fromEncoded8() {
@@ -7626,7 +7714,7 @@ var ably = {exports: {}};
7626
7714
  });
7627
7715
  return _fromEncoded8.apply(this, arguments);
7628
7716
  }
7629
- function fromEncodedArray3(_x71, _x72, _x73) {
7717
+ function fromEncodedArray3(_x77, _x78, _x79) {
7630
7718
  return _fromEncodedArray8.apply(this, arguments);
7631
7719
  }
7632
7720
  function _fromEncodedArray8() {
@@ -7637,7 +7725,7 @@ var ably = {exports: {}};
7637
7725
  });
7638
7726
  return _fromEncodedArray8.apply(this, arguments);
7639
7727
  }
7640
- function _fromEncoded3(_x74, _x75) {
7728
+ function _fromEncoded3(_x80, _x81) {
7641
7729
  return _fromEncoded9.apply(this, arguments);
7642
7730
  }
7643
7731
  function _fromEncoded9() {
@@ -7646,7 +7734,7 @@ var ably = {exports: {}};
7646
7734
  });
7647
7735
  return _fromEncoded9.apply(this, arguments);
7648
7736
  }
7649
- function _fromEncodedArray3(_x76, _x77) {
7737
+ function _fromEncodedArray3(_x82, _x83) {
7650
7738
  return _fromEncodedArray9.apply(this, arguments);
7651
7739
  }
7652
7740
  function _fromEncodedArray9() {
@@ -7659,10 +7747,10 @@ var ably = {exports: {}};
7659
7747
  }
7660
7748
  var Annotation = class _Annotation extends BaseMessage {
7661
7749
  encode() {
7662
- var _this55 = this;
7750
+ var _this61 = this;
7663
7751
  return _asyncToGenerator(function* () {
7664
- var res = Object.assign(new WireAnnotation(), _this55, {
7665
- action: actions4.indexOf(_this55.action || "annotation.create")
7752
+ var res = Object.assign(new WireAnnotation(), _this61, {
7753
+ action: actions4.indexOf(_this61.action || "annotation.create")
7666
7754
  });
7667
7755
  return encode(res, {});
7668
7756
  })();
@@ -7691,10 +7779,10 @@ var ably = {exports: {}};
7691
7779
  return values.map(v => _WireAnnotation.fromValues(v));
7692
7780
  }
7693
7781
  decode(channelOptions, logger) {
7694
- var _this56 = this;
7782
+ var _this62 = this;
7695
7783
  return _asyncToGenerator(function* () {
7696
- var res = Object.assign(new Annotation(), __spreadProps(__spreadValues({}, _this56), {
7697
- action: actions4[_this56.action]
7784
+ var res = Object.assign(new Annotation(), __spreadProps(__spreadValues({}, _this62), {
7785
+ action: actions4[_this62.action]
7698
7786
  }));
7699
7787
  try {
7700
7788
  yield decode(res, channelOptions);
@@ -7763,47 +7851,43 @@ var ably = {exports: {}};
7763
7851
  this.channel = channel;
7764
7852
  }
7765
7853
  publish(msgOrSerial, annotationValues) {
7766
- var _this57 = this;
7854
+ var _this63 = this;
7767
7855
  return _asyncToGenerator(function* () {
7768
7856
  var annotation = constructValidateAnnotation(msgOrSerial, annotationValues);
7769
7857
  var wireAnnotation = yield annotation.encode();
7770
- var client = _this57.channel.client,
7858
+ var client = _this63.channel.client,
7771
7859
  options = client.options,
7772
7860
  format = options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7773
- headers = defaults_default.defaultPostHeaders(client.options, {
7774
- format
7775
- }),
7861
+ headers = defaults_default.defaultPostHeaders(client.options),
7776
7862
  params = {};
7777
7863
  _mixin(headers, client.options.headers);
7778
7864
  var requestBody = _encodeBody([wireAnnotation], client._MsgPack, format);
7779
- yield resource_default.post(client, basePathForSerial(_this57.channel, annotation.messageSerial), requestBody, headers, params, null, true);
7865
+ yield resource_default.post(client, basePathForSerial(_this63.channel, annotation.messageSerial), requestBody, headers, params, null, true);
7780
7866
  })();
7781
7867
  }
7782
7868
  delete(msgOrSerial, annotationValues) {
7783
- var _this58 = this;
7869
+ var _this64 = this;
7784
7870
  return _asyncToGenerator(function* () {
7785
7871
  annotationValues.action = "annotation.delete";
7786
- return _this58.publish(msgOrSerial, annotationValues);
7872
+ return _this64.publish(msgOrSerial, annotationValues);
7787
7873
  })();
7788
7874
  }
7789
7875
  get(msgOrSerial, params) {
7790
- var _this59 = this;
7876
+ var _this65 = this;
7791
7877
  return _asyncToGenerator(function* () {
7792
- var client = _this59.channel.client,
7878
+ var client = _this65.channel.client,
7793
7879
  messageSerial = serialFromMsgOrSerial(msgOrSerial),
7794
7880
  format = client.options.useBinaryProtocol ? "msgpack" /* msgpack */ : "json" /* json */,
7795
7881
  envelope = client.http.supportsLinkHeaders ? void 0 : format,
7796
- headers = defaults_default.defaultGetHeaders(client.options, {
7797
- format
7798
- });
7882
+ headers = defaults_default.defaultGetHeaders(client.options);
7799
7883
  _mixin(headers, client.options.headers);
7800
- return new paginatedresource_default(client, basePathForSerial(_this59.channel, messageSerial), headers, envelope, /*#__PURE__*/function () {
7801
- var _ref0 = _asyncToGenerator(function* (body, _, unpacked) {
7884
+ return new paginatedresource_default(client, basePathForSerial(_this65.channel, messageSerial), headers, envelope, /*#__PURE__*/function () {
7885
+ var _ref10 = _asyncToGenerator(function* (body, _, unpacked) {
7802
7886
  var decoded = unpacked ? body : _decodeBody(body, client._MsgPack, format);
7803
- return _fromEncodedArray3(decoded, _this59.channel);
7887
+ return _fromEncodedArray3(decoded, _this65.channel);
7804
7888
  });
7805
- return function (_x78, _x79, _x80) {
7806
- return _ref0.apply(this, arguments);
7889
+ return function (_x84, _x85, _x86) {
7890
+ return _ref10.apply(this, arguments);
7807
7891
  };
7808
7892
  }()).get(params);
7809
7893
  })();
@@ -7974,7 +8058,7 @@ var ably = {exports: {}};
7974
8058
  this._mode = 0;
7975
8059
  this.retryCount = 0;
7976
8060
  this.history = /*#__PURE__*/function () {
7977
- var _ref1 = _asyncToGenerator(function* (params) {
8061
+ var _ref11 = _asyncToGenerator(function* (params) {
7978
8062
  logger_default.logAction(this.logger, logger_default.LOG_MICRO, "RealtimeChannel.history()", "channel = " + this.name);
7979
8063
  var restMixin = this.client.rest.channelMixin;
7980
8064
  if (params && params.untilAttach) {
@@ -7989,8 +8073,8 @@ var ably = {exports: {}};
7989
8073
  }
7990
8074
  return restMixin.history(this, params);
7991
8075
  });
7992
- return function (_x81) {
7993
- return _ref1.apply(this, arguments);
8076
+ return function (_x87) {
8077
+ return _ref11.apply(this, arguments);
7994
8078
  };
7995
8079
  }();
7996
8080
  this.whenState = state => {
@@ -8069,20 +8153,20 @@ var ably = {exports: {}};
8069
8153
  return args;
8070
8154
  }
8071
8155
  setOptions(options) {
8072
- var _this60 = this;
8156
+ var _this66 = this;
8073
8157
  return _asyncToGenerator(function* () {
8074
8158
  var _a2;
8075
- var previousChannelOptions = _this60.channelOptions;
8159
+ var previousChannelOptions = _this66.channelOptions;
8076
8160
  var err = validateChannelOptions(options);
8077
8161
  if (err) {
8078
8162
  throw err;
8079
8163
  }
8080
- _this60.channelOptions = normaliseChannelOptions((_a2 = _this60.client._Crypto) != null ? _a2 : null, _this60.logger, options);
8081
- if (_this60._decodingContext) _this60._decodingContext.channelOptions = _this60.channelOptions;
8082
- if (_this60._shouldReattachToSetOptions(options, previousChannelOptions)) {
8083
- _this60.attachImpl();
8164
+ _this66.channelOptions = normaliseChannelOptions((_a2 = _this66.client._Crypto) != null ? _a2 : null, _this66.logger, options);
8165
+ if (_this66._decodingContext) _this66._decodingContext.channelOptions = _this66.channelOptions;
8166
+ if (_this66._shouldReattachToSetOptions(options, previousChannelOptions)) {
8167
+ _this66.attachImpl();
8084
8168
  return new Promise((resolve, reject) => {
8085
- _this60._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
8169
+ _this66._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
8086
8170
  switch (this.event) {
8087
8171
  case "update":
8088
8172
  case "attached":
@@ -8119,7 +8203,7 @@ var ably = {exports: {}};
8119
8203
  }
8120
8204
  publish() {
8121
8205
  var _arguments2 = arguments,
8122
- _this61 = this;
8206
+ _this67 = this;
8123
8207
  return _asyncToGenerator(function* () {
8124
8208
  var messages;
8125
8209
  var argCount = _arguments2.length;
@@ -8137,20 +8221,20 @@ var ably = {exports: {}};
8137
8221
  data: _arguments2.length <= 1 ? undefined : _arguments2[1]
8138
8222
  })];
8139
8223
  }
8140
- var maxMessageSize = _this61.client.options.maxMessageSize;
8141
- var wireMessages = yield encodeArray(messages, _this61.channelOptions);
8224
+ var maxMessageSize = _this67.client.options.maxMessageSize;
8225
+ var wireMessages = yield encodeArray(messages, _this67.channelOptions);
8142
8226
  var size = getMessagesSize(wireMessages);
8143
8227
  if (size > maxMessageSize) {
8144
8228
  throw new _ErrorInfo2("Maximum size of messages that can be published at once exceeded (was ".concat(size, " bytes; limit is ").concat(maxMessageSize, " bytes)"), 40009, 400);
8145
8229
  }
8146
- _this61.throwIfUnpublishableState();
8147
- logger_default.logAction(_this61.logger, logger_default.LOG_MICRO, "RealtimeChannel.publish()", "sending message; channel state is " + _this61.state + ", message count = " + wireMessages.length);
8230
+ _this67.throwIfUnpublishableState();
8231
+ logger_default.logAction(_this67.logger, logger_default.LOG_MICRO, "RealtimeChannel.publish()", "sending message; channel state is " + _this67.state + ", message count = " + wireMessages.length);
8148
8232
  var pm = fromValues({
8149
8233
  action: actions.MESSAGE,
8150
- channel: _this61.name,
8234
+ channel: _this67.name,
8151
8235
  messages: wireMessages
8152
8236
  });
8153
- return _this61.sendMessage(pm);
8237
+ return _this67.sendMessage(pm);
8154
8238
  })();
8155
8239
  }
8156
8240
  throwIfUnpublishableState() {
@@ -8170,13 +8254,13 @@ var ably = {exports: {}};
8170
8254
  }
8171
8255
  }
8172
8256
  attach() {
8173
- var _this62 = this;
8257
+ var _this68 = this;
8174
8258
  return _asyncToGenerator(function* () {
8175
- if (_this62.state === "attached") {
8259
+ if (_this68.state === "attached") {
8176
8260
  return null;
8177
8261
  }
8178
8262
  return new Promise((resolve, reject) => {
8179
- _this62._attach(false, null, (err, result) => err ? reject(err) : resolve(result));
8263
+ _this68._attach(false, null, (err, result) => err ? reject(err) : resolve(result));
8180
8264
  });
8181
8265
  })();
8182
8266
  }
@@ -8234,25 +8318,25 @@ var ably = {exports: {}};
8234
8318
  this.sendMessage(attachMsg).catch(noop);
8235
8319
  }
8236
8320
  detach() {
8237
- var _this63 = this;
8321
+ var _this69 = this;
8238
8322
  return _asyncToGenerator(function* () {
8239
- var connectionManager = _this63.connectionManager;
8323
+ var connectionManager = _this69.connectionManager;
8240
8324
  if (!connectionManager.activeState()) {
8241
8325
  throw connectionManager.getError();
8242
8326
  }
8243
- switch (_this63.state) {
8327
+ switch (_this69.state) {
8244
8328
  case "suspended":
8245
- _this63.notifyState("detached");
8329
+ _this69.notifyState("detached");
8246
8330
  return;
8247
8331
  case "detached":
8248
8332
  return;
8249
8333
  case "failed":
8250
8334
  throw new _ErrorInfo2("Unable to detach; channel state = failed", 90001, 400);
8251
8335
  default:
8252
- _this63.requestState("detaching");
8336
+ _this69.requestState("detaching");
8253
8337
  case "detaching":
8254
8338
  return new Promise((resolve, reject) => {
8255
- _this63.once(function (stateChange) {
8339
+ _this69.once(function (stateChange) {
8256
8340
  switch (this.event) {
8257
8341
  case "detached":
8258
8342
  resolve();
@@ -8281,22 +8365,22 @@ var ably = {exports: {}};
8281
8365
  }
8282
8366
  subscribe() {
8283
8367
  var _arguments3 = arguments,
8284
- _this64 = this;
8368
+ _this70 = this;
8285
8369
  return _asyncToGenerator(function* () {
8286
8370
  for (var _len0 = _arguments3.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
8287
8371
  args[_key0] = _arguments3[_key0];
8288
8372
  }
8289
8373
  var [event, listener] = _RealtimeChannel.processListenerArgs(args);
8290
- if (_this64.state === "failed") {
8291
- throw _ErrorInfo2.fromValues(_this64.invalidStateError());
8374
+ if (_this70.state === "failed") {
8375
+ throw _ErrorInfo2.fromValues(_this70.invalidStateError());
8292
8376
  }
8293
8377
  if (event && typeof event === "object" && !Array.isArray(event)) {
8294
- _this64.client._FilteredSubscriptions.subscribeFilter(_this64, event, listener);
8378
+ _this70.client._FilteredSubscriptions.subscribeFilter(_this70, event, listener);
8295
8379
  } else {
8296
- _this64.subscriptions.on(event, listener);
8380
+ _this70.subscriptions.on(event, listener);
8297
8381
  }
8298
- if (_this64.channelOptions.attachOnSubscribe !== false) {
8299
- return _this64.attach();
8382
+ if (_this70.channelOptions.attachOnSubscribe !== false) {
8383
+ return _this70.attach();
8300
8384
  } else {
8301
8385
  return null;
8302
8386
  }
@@ -8335,10 +8419,10 @@ var ably = {exports: {}};
8335
8419
  connectionManager.send(syncMessage);
8336
8420
  }
8337
8421
  sendMessage(msg) {
8338
- var _this65 = this;
8422
+ var _this71 = this;
8339
8423
  return _asyncToGenerator(function* () {
8340
8424
  return new Promise((resolve, reject) => {
8341
- _this65.connectionManager.send(msg, _this65.client.options.queueMessages, err => {
8425
+ _this71.connectionManager.send(msg, _this71.client.options.queueMessages, err => {
8342
8426
  if (err) {
8343
8427
  reject(err);
8344
8428
  } else {
@@ -8349,14 +8433,14 @@ var ably = {exports: {}};
8349
8433
  })();
8350
8434
  }
8351
8435
  sendPresence(presence) {
8352
- var _this66 = this;
8436
+ var _this72 = this;
8353
8437
  return _asyncToGenerator(function* () {
8354
8438
  var msg = fromValues({
8355
8439
  action: actions.PRESENCE,
8356
- channel: _this66.name,
8440
+ channel: _this72.name,
8357
8441
  presence
8358
8442
  });
8359
- return _this66.sendMessage(msg);
8443
+ return _this72.sendMessage(msg);
8360
8444
  })();
8361
8445
  }
8362
8446
  sendState(objectMessages) {
@@ -8369,61 +8453,61 @@ var ably = {exports: {}};
8369
8453
  }
8370
8454
  // Access to this method is synchronised by ConnectionManager#processChannelMessage, in order to synchronise access to the state stored in _decodingContext.
8371
8455
  processMessage(message) {
8372
- var _this67 = this;
8456
+ var _this73 = this;
8373
8457
  return _asyncToGenerator(function* () {
8374
8458
  if (message.action === actions.ATTACHED || message.action === actions.MESSAGE || message.action === actions.PRESENCE || message.action === actions.OBJECT || message.action === actions.ANNOTATION) {
8375
- _this67.setChannelSerial(message.channelSerial);
8459
+ _this73.setChannelSerial(message.channelSerial);
8376
8460
  }
8377
8461
  var syncChannelSerial,
8378
8462
  isSync = false;
8379
8463
  switch (message.action) {
8380
8464
  case actions.ATTACHED:
8381
8465
  {
8382
- _this67.properties.attachSerial = message.channelSerial;
8383
- _this67._mode = message.getMode();
8384
- _this67.params = message.params || {};
8466
+ _this73.properties.attachSerial = message.channelSerial;
8467
+ _this73._mode = message.getMode();
8468
+ _this73.params = message.params || {};
8385
8469
  var modesFromFlags = message.decodeModesFromFlags();
8386
- _this67.modes = modesFromFlags && _allToLowerCase(modesFromFlags) || void 0;
8470
+ _this73.modes = modesFromFlags && _allToLowerCase(modesFromFlags) || void 0;
8387
8471
  var resumed = message.hasFlag("RESUMED");
8388
8472
  var hasPresence = message.hasFlag("HAS_PRESENCE");
8389
8473
  var hasBacklog = message.hasFlag("HAS_BACKLOG");
8390
8474
  var hasObjects = message.hasFlag("HAS_OBJECTS");
8391
- if (_this67.state === "attached") {
8475
+ if (_this73.state === "attached") {
8392
8476
  if (!resumed) {
8393
- if (_this67._presence) {
8394
- _this67._presence.onAttached(hasPresence);
8477
+ if (_this73._presence) {
8478
+ _this73._presence.onAttached(hasPresence);
8395
8479
  }
8396
- if (_this67._objects) {
8397
- _this67._objects.onAttached(hasObjects);
8480
+ if (_this73._objects) {
8481
+ _this73._objects.onAttached(hasObjects);
8398
8482
  }
8399
8483
  }
8400
- var change = new channelstatechange_default(_this67.state, _this67.state, resumed, hasBacklog, message.error);
8401
- _this67._allChannelChanges.emit("update", change);
8402
- if (!resumed || _this67.channelOptions.updateOnAttached) {
8403
- _this67.emit("update", change);
8484
+ var change = new channelstatechange_default(_this73.state, _this73.state, resumed, hasBacklog, message.error);
8485
+ _this73._allChannelChanges.emit("update", change);
8486
+ if (!resumed || _this73.channelOptions.updateOnAttached) {
8487
+ _this73.emit("update", change);
8404
8488
  }
8405
- } else if (_this67.state === "detaching") {
8406
- _this67.checkPendingState();
8489
+ } else if (_this73.state === "detaching") {
8490
+ _this73.checkPendingState();
8407
8491
  } else {
8408
- _this67.notifyState("attached", message.error, resumed, hasPresence, hasBacklog, hasObjects);
8492
+ _this73.notifyState("attached", message.error, resumed, hasPresence, hasBacklog, hasObjects);
8409
8493
  }
8410
8494
  break;
8411
8495
  }
8412
8496
  case actions.DETACHED:
8413
8497
  {
8414
8498
  var detachErr = message.error ? _ErrorInfo2.fromValues(message.error) : new _ErrorInfo2("Channel detached", 90001, 404);
8415
- if (_this67.state === "detaching") {
8416
- _this67.notifyState("detached", detachErr);
8417
- } else if (_this67.state === "attaching") {
8418
- _this67.notifyState("suspended", detachErr);
8419
- } else if (_this67.state === "attached" || _this67.state === "suspended") {
8420
- _this67.requestState("attaching", detachErr);
8499
+ if (_this73.state === "detaching") {
8500
+ _this73.notifyState("detached", detachErr);
8501
+ } else if (_this73.state === "attaching") {
8502
+ _this73.notifyState("suspended", detachErr);
8503
+ } else if (_this73.state === "attached" || _this73.state === "suspended") {
8504
+ _this73.requestState("attaching", detachErr);
8421
8505
  }
8422
8506
  break;
8423
8507
  }
8424
8508
  case actions.SYNC:
8425
8509
  isSync = true;
8426
- syncChannelSerial = _this67.syncChannelSerial = message.channelSerial;
8510
+ syncChannelSerial = _this73.syncChannelSerial = message.channelSerial;
8427
8511
  if (!message.presence) break;
8428
8512
  case actions.PRESENCE:
8429
8513
  {
@@ -8431,45 +8515,45 @@ var ably = {exports: {}};
8431
8515
  break;
8432
8516
  }
8433
8517
  populateFieldsFromParent(message);
8434
- var options = _this67.channelOptions;
8435
- if (_this67._presence) {
8518
+ var options = _this73.channelOptions;
8519
+ if (_this73._presence) {
8436
8520
  var presenceMessages = yield Promise.all(message.presence.map(wpm => {
8437
- return wpm.decode(options, _this67.logger);
8521
+ return wpm.decode(options, _this73.logger);
8438
8522
  }));
8439
- _this67._presence.setPresence(presenceMessages, isSync, syncChannelSerial);
8523
+ _this73._presence.setPresence(presenceMessages, isSync, syncChannelSerial);
8440
8524
  }
8441
8525
  break;
8442
8526
  }
8443
8527
  case actions.OBJECT:
8444
8528
  case actions.OBJECT_SYNC:
8445
8529
  {
8446
- if (!_this67._objects || !message.state) {
8530
+ if (!_this73._objects || !message.state) {
8447
8531
  return;
8448
8532
  }
8449
8533
  populateFieldsFromParent(message);
8450
- var format = _this67.client.connection.connectionManager.getActiveTransportFormat();
8451
- var objectMessages = message.state.map(om => om.decode(_this67.client, format));
8534
+ var format = _this73.client.connection.connectionManager.getActiveTransportFormat();
8535
+ var objectMessages = message.state.map(om => om.decode(_this73.client, format));
8452
8536
  if (message.action === actions.OBJECT) {
8453
- _this67._objects.handleObjectMessages(objectMessages);
8537
+ _this73._objects.handleObjectMessages(objectMessages);
8454
8538
  } else {
8455
- _this67._objects.handleObjectSyncMessages(objectMessages, message.channelSerial);
8539
+ _this73._objects.handleObjectSyncMessages(objectMessages, message.channelSerial);
8456
8540
  }
8457
8541
  break;
8458
8542
  }
8459
8543
  case actions.MESSAGE:
8460
8544
  {
8461
- if (_this67.state !== "attached") {
8462
- logger_default.logAction(_this67.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", 'Message "' + message.id + '" skipped as this channel "' + _this67.name + '" state is not "attached" (state is "' + _this67.state + '").');
8545
+ if (_this73.state !== "attached") {
8546
+ logger_default.logAction(_this73.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", 'Message "' + message.id + '" skipped as this channel "' + _this73.name + '" state is not "attached" (state is "' + _this73.state + '").');
8463
8547
  return;
8464
8548
  }
8465
8549
  populateFieldsFromParent(message);
8466
8550
  var encoded = message.messages,
8467
8551
  firstMessage = encoded[0],
8468
8552
  lastMessage = encoded[encoded.length - 1];
8469
- if (firstMessage.extras && firstMessage.extras.delta && firstMessage.extras.delta.from !== _this67._lastPayload.messageId) {
8470
- var msg = 'Delta message decode failure - previous message not available for message "' + message.id + '" on this channel "' + _this67.name + '".';
8471
- logger_default.logAction(_this67.logger, logger_default.LOG_ERROR, "RealtimeChannel.processMessage()", msg);
8472
- _this67._startDecodeFailureRecovery(new _ErrorInfo2(msg, 40018, 400));
8553
+ if (firstMessage.extras && firstMessage.extras.delta && firstMessage.extras.delta.from !== _this73._lastPayload.messageId) {
8554
+ var msg = 'Delta message decode failure - previous message not available for message "' + message.id + '" on this channel "' + _this73.name + '".';
8555
+ logger_default.logAction(_this73.logger, logger_default.LOG_ERROR, "RealtimeChannel.processMessage()", msg);
8556
+ _this73._startDecodeFailureRecovery(new _ErrorInfo2(msg, 40018, 400));
8473
8557
  break;
8474
8558
  }
8475
8559
  var messages = [];
@@ -8477,34 +8561,34 @@ var ably = {exports: {}};
8477
8561
  var {
8478
8562
  decoded,
8479
8563
  err
8480
- } = yield encoded[i].decodeWithErr(_this67._decodingContext, _this67.logger);
8564
+ } = yield encoded[i].decodeWithErr(_this73._decodingContext, _this73.logger);
8481
8565
  messages[i] = decoded;
8482
8566
  if (err) {
8483
8567
  switch (err.code) {
8484
8568
  case 40018:
8485
- _this67._startDecodeFailureRecovery(err);
8569
+ _this73._startDecodeFailureRecovery(err);
8486
8570
  return;
8487
8571
  case 40019:
8488
8572
  case 40021:
8489
- _this67.notifyState("failed", err);
8573
+ _this73.notifyState("failed", err);
8490
8574
  return;
8491
8575
  }
8492
8576
  }
8493
8577
  }
8494
- _this67._lastPayload.messageId = lastMessage.id;
8495
- _this67._lastPayload.protocolMessageChannelSerial = message.channelSerial;
8496
- _this67.onEvent(messages);
8578
+ _this73._lastPayload.messageId = lastMessage.id;
8579
+ _this73._lastPayload.protocolMessageChannelSerial = message.channelSerial;
8580
+ _this73.onEvent(messages);
8497
8581
  break;
8498
8582
  }
8499
8583
  case actions.ANNOTATION:
8500
8584
  {
8501
8585
  populateFieldsFromParent(message);
8502
- var _options = _this67.channelOptions;
8503
- if (_this67._annotations) {
8586
+ var _options = _this73.channelOptions;
8587
+ if (_this73._annotations) {
8504
8588
  var annotations = yield Promise.all((message.annotations || []).map(wpm => {
8505
- return wpm.decode(_options, _this67.logger);
8589
+ return wpm.decode(_options, _this73.logger);
8506
8590
  }));
8507
- _this67._annotations._processIncoming(annotations);
8591
+ _this73._annotations._processIncoming(annotations);
8508
8592
  }
8509
8593
  break;
8510
8594
  }
@@ -8512,14 +8596,14 @@ var ably = {exports: {}};
8512
8596
  {
8513
8597
  var _err = message.error;
8514
8598
  if (_err && _err.code == 80016) {
8515
- _this67.checkPendingState();
8599
+ _this73.checkPendingState();
8516
8600
  } else {
8517
- _this67.notifyState("failed", _ErrorInfo2.fromValues(_err));
8601
+ _this73.notifyState("failed", _ErrorInfo2.fromValues(_err));
8518
8602
  }
8519
8603
  break;
8520
8604
  }
8521
8605
  default:
8522
- logger_default.logAction(_this67.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", "Protocol error: unrecognised message action (" + message.action + ")");
8606
+ logger_default.logAction(_this73.logger, logger_default.LOG_MAJOR, "RealtimeChannel.processMessage()", "Protocol error: unrecognised message action (" + message.action + ")");
8523
8607
  }
8524
8608
  })();
8525
8609
  }
@@ -8675,9 +8759,45 @@ var ably = {exports: {}};
8675
8759
  }
8676
8760
  }
8677
8761
  status() {
8678
- var _this68 = this;
8762
+ var _this74 = this;
8679
8763
  return _asyncToGenerator(function* () {
8680
- return _this68.client.rest.channelMixin.status(_this68);
8764
+ return _this74.client.rest.channelMixin.status(_this74);
8765
+ })();
8766
+ }
8767
+ getMessage(serialOrMessage) {
8768
+ var _this75 = this;
8769
+ return _asyncToGenerator(function* () {
8770
+ logger_default.logAction(_this75.logger, logger_default.LOG_MICRO, "RealtimeChannel.getMessage()", "channel = " + _this75.name);
8771
+ var restMixin = _this75.client.rest.channelMixin;
8772
+ return restMixin.getMessage(_this75, serialOrMessage);
8773
+ })();
8774
+ }
8775
+ updateMessage(message, operation, params) {
8776
+ var _this76 = this;
8777
+ return _asyncToGenerator(function* () {
8778
+ logger_default.logAction(_this76.logger, logger_default.LOG_MICRO, "RealtimeChannel.updateMessage()", "channel = " + _this76.name);
8779
+ var restMixin = _this76.client.rest.channelMixin;
8780
+ return restMixin.updateDeleteMessage(_this76, {
8781
+ isDelete: false
8782
+ }, message, operation, params);
8783
+ })();
8784
+ }
8785
+ deleteMessage(message, operation, params) {
8786
+ var _this77 = this;
8787
+ return _asyncToGenerator(function* () {
8788
+ logger_default.logAction(_this77.logger, logger_default.LOG_MICRO, "RealtimeChannel.deleteMessage()", "channel = " + _this77.name);
8789
+ var restMixin = _this77.client.rest.channelMixin;
8790
+ return restMixin.updateDeleteMessage(_this77, {
8791
+ isDelete: true
8792
+ }, message, operation, params);
8793
+ })();
8794
+ }
8795
+ getMessageVersions(serialOrMessage, params) {
8796
+ var _this78 = this;
8797
+ return _asyncToGenerator(function* () {
8798
+ logger_default.logAction(_this78.logger, logger_default.LOG_MICRO, "RealtimeChannel.getMessageVersions()", "channel = " + _this78.name);
8799
+ var restMixin = _this78.client.rest.channelMixin;
8800
+ return restMixin.getMessageVersions(_this78, serialOrMessage, params);
8681
8801
  })();
8682
8802
  }
8683
8803
  };
@@ -8696,31 +8816,31 @@ var ably = {exports: {}};
8696
8816
  this.subscriptions = new eventemitter_default(this.logger);
8697
8817
  }
8698
8818
  publish(msgOrSerial, annotationValues) {
8699
- var _this69 = this;
8819
+ var _this79 = this;
8700
8820
  return _asyncToGenerator(function* () {
8701
- var channelName = _this69.channel.name;
8821
+ var channelName = _this79.channel.name;
8702
8822
  var annotation = constructValidateAnnotation(msgOrSerial, annotationValues);
8703
8823
  var wireAnnotation = yield annotation.encode();
8704
- _this69.channel.throwIfUnpublishableState();
8705
- logger_default.logAction(_this69.logger, logger_default.LOG_MICRO, "RealtimeAnnotations.publish()", "channelName = " + channelName + ", sending annotation with messageSerial = " + annotation.messageSerial + ", type = " + annotation.type);
8824
+ _this79.channel.throwIfUnpublishableState();
8825
+ logger_default.logAction(_this79.logger, logger_default.LOG_MICRO, "RealtimeAnnotations.publish()", "channelName = " + channelName + ", sending annotation with messageSerial = " + annotation.messageSerial + ", type = " + annotation.type);
8706
8826
  var pm = fromValues({
8707
8827
  action: actions.ANNOTATION,
8708
8828
  channel: channelName,
8709
8829
  annotations: [wireAnnotation]
8710
8830
  });
8711
- return _this69.channel.sendMessage(pm);
8831
+ return _this79.channel.sendMessage(pm);
8712
8832
  })();
8713
8833
  }
8714
8834
  delete(msgOrSerial, annotationValues) {
8715
- var _this70 = this;
8835
+ var _this80 = this;
8716
8836
  return _asyncToGenerator(function* () {
8717
8837
  annotationValues.action = "annotation.delete";
8718
- return _this70.publish(msgOrSerial, annotationValues);
8838
+ return _this80.publish(msgOrSerial, annotationValues);
8719
8839
  })();
8720
8840
  }
8721
8841
  subscribe() {
8722
8842
  var _arguments4 = arguments,
8723
- _this71 = this;
8843
+ _this81 = this;
8724
8844
  return _asyncToGenerator(function* () {
8725
8845
  for (var _len10 = _arguments4.length, _args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
8726
8846
  _args[_key10] = _arguments4[_key10];
@@ -8728,15 +8848,15 @@ var ably = {exports: {}};
8728
8848
  var args = realtimechannel_default.processListenerArgs(_args);
8729
8849
  var event = args[0];
8730
8850
  var listener = args[1];
8731
- var channel = _this71.channel;
8851
+ var channel = _this81.channel;
8732
8852
  if (channel.state === "failed") {
8733
8853
  throw _ErrorInfo2.fromValues(channel.invalidStateError());
8734
8854
  }
8735
- _this71.subscriptions.on(event, listener);
8736
- if (_this71.channel.channelOptions.attachOnSubscribe !== false) {
8855
+ _this81.subscriptions.on(event, listener);
8856
+ if (_this81.channel.channelOptions.attachOnSubscribe !== false) {
8737
8857
  yield channel.attach();
8738
8858
  }
8739
- if ((_this71.channel.state === "attached" && _this71.channel._mode & flags.ANNOTATION_SUBSCRIBE) === 0) {
8859
+ if ((_this81.channel.state === "attached" && _this81.channel._mode & flags.ANNOTATION_SUBSCRIBE) === 0) {
8740
8860
  throw new _ErrorInfo2("You are trying to add an annotation listener, but you haven't requested the annotation_subscribe channel mode in ChannelOptions, so this won't do anything (we only deliver annotations to clients who have explicitly requested them)", 93001, 400);
8741
8861
  }
8742
8862
  })();
@@ -8756,9 +8876,9 @@ var ably = {exports: {}};
8756
8876
  }
8757
8877
  }
8758
8878
  get(msgOrSerial, params) {
8759
- var _this72 = this;
8879
+ var _this82 = this;
8760
8880
  return _asyncToGenerator(function* () {
8761
- return restannotations_default.prototype.get.call(_this72, msgOrSerial, params);
8881
+ return restannotations_default.prototype.get.call(_this82, msgOrSerial, params);
8762
8882
  })();
8763
8883
  }
8764
8884
  };
@@ -10420,23 +10540,23 @@ var ably = {exports: {}};
10420
10540
  }
10421
10541
  }
10422
10542
  processChannelMessage(message) {
10423
- var _this73 = this;
10543
+ var _this83 = this;
10424
10544
  return _asyncToGenerator(function* () {
10425
- yield _this73.realtime.channels.processChannelMessage(message);
10545
+ yield _this83.realtime.channels.processChannelMessage(message);
10426
10546
  })();
10427
10547
  }
10428
10548
  ping() {
10429
- var _this74 = this;
10549
+ var _this84 = this;
10430
10550
  return _asyncToGenerator(function* () {
10431
10551
  var _a2;
10432
- if (_this74.state.state !== "connected") {
10552
+ if (_this84.state.state !== "connected") {
10433
10553
  throw new _ErrorInfo2("Unable to ping service; not connected", 4e4, 400);
10434
10554
  }
10435
- var transport = (_a2 = _this74.activeProtocol) == null ? void 0 : _a2.getTransport();
10555
+ var transport = (_a2 = _this84.activeProtocol) == null ? void 0 : _a2.getTransport();
10436
10556
  if (!transport) {
10437
- throw _this74.getStateError();
10557
+ throw _this84.getStateError();
10438
10558
  }
10439
- logger_default.logAction(_this74.logger, logger_default.LOG_MINOR, "ConnectionManager.ping()", "transport = " + transport);
10559
+ logger_default.logAction(_this84.logger, logger_default.LOG_MINOR, "ConnectionManager.ping()", "transport = " + transport);
10440
10560
  var pingStart = Date.now();
10441
10561
  var id = _cheapRandStr();
10442
10562
  return _withTimeoutAsync(new Promise(resolve => {
@@ -10448,7 +10568,7 @@ var ably = {exports: {}};
10448
10568
  };
10449
10569
  transport.on("heartbeat", onHeartbeat);
10450
10570
  transport.ping(id);
10451
- }), _this74.options.timeouts.realtimeRequestTimeout, "Timeout waiting for heartbeat response");
10571
+ }), _this84.options.timeouts.realtimeRequestTimeout, "Timeout waiting for heartbeat response");
10452
10572
  })();
10453
10573
  }
10454
10574
  abort(error) {
@@ -10597,10 +10717,10 @@ var ably = {exports: {}};
10597
10717
  });
10598
10718
  }
10599
10719
  ping() {
10600
- var _this75 = this;
10720
+ var _this85 = this;
10601
10721
  return _asyncToGenerator(function* () {
10602
- logger_default.logAction(_this75.logger, logger_default.LOG_MINOR, "Connection.ping()", "");
10603
- return _this75.connectionManager.ping();
10722
+ logger_default.logAction(_this85.logger, logger_default.LOG_MINOR, "Connection.ping()", "");
10723
+ return _this85.connectionManager.ping();
10604
10724
  })();
10605
10725
  }
10606
10726
  close() {
@@ -10656,6 +10776,9 @@ var ably = {exports: {}};
10656
10776
  get channels() {
10657
10777
  return this._channels;
10658
10778
  }
10779
+ get clientId() {
10780
+ return this.auth.clientId;
10781
+ }
10659
10782
  connect() {
10660
10783
  logger_default.logAction(this.logger, logger_default.LOG_MINOR, "Realtime.connect()", "");
10661
10784
  this.connection.connect();
@@ -10696,16 +10819,16 @@ var ably = {exports: {}};
10696
10819
  }
10697
10820
  // Access to this method is synchronised by ConnectionManager#processChannelMessage.
10698
10821
  processChannelMessage(msg) {
10699
- var _this76 = this;
10822
+ var _this86 = this;
10700
10823
  return _asyncToGenerator(function* () {
10701
10824
  var channelName = msg.channel;
10702
10825
  if (channelName === void 0) {
10703
- logger_default.logAction(_this76.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event unspecified channel, action = " + msg.action);
10826
+ logger_default.logAction(_this86.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event unspecified channel, action = " + msg.action);
10704
10827
  return;
10705
10828
  }
10706
- var channel = _this76.all[channelName];
10829
+ var channel = _this86.all[channelName];
10707
10830
  if (!channel) {
10708
- logger_default.logAction(_this76.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event for non-existent channel: " + channelName);
10831
+ logger_default.logAction(_this86.logger, logger_default.LOG_ERROR, "Channels.processChannelMessage()", "received event for non-existent channel: " + channelName);
10709
10832
  return;
10710
10833
  }
10711
10834
  yield channel.processMessage(msg);
@@ -10960,43 +11083,43 @@ var ably = {exports: {}};
10960
11083
  this.pendingPresence = [];
10961
11084
  }
10962
11085
  enter(data) {
10963
- var _this77 = this;
11086
+ var _this87 = this;
10964
11087
  return _asyncToGenerator(function* () {
10965
- if (isAnonymousOrWildcard(_this77)) {
11088
+ if (isAnonymousOrWildcard(_this87)) {
10966
11089
  throw new _ErrorInfo2("clientId must be specified to enter a presence channel", 40012, 400);
10967
11090
  }
10968
- return _this77._enterOrUpdateClient(void 0, void 0, data, "enter");
11091
+ return _this87._enterOrUpdateClient(void 0, void 0, data, "enter");
10969
11092
  })();
10970
11093
  }
10971
11094
  update(data) {
10972
- var _this78 = this;
11095
+ var _this88 = this;
10973
11096
  return _asyncToGenerator(function* () {
10974
- if (isAnonymousOrWildcard(_this78)) {
11097
+ if (isAnonymousOrWildcard(_this88)) {
10975
11098
  throw new _ErrorInfo2("clientId must be specified to update presence data", 40012, 400);
10976
11099
  }
10977
- return _this78._enterOrUpdateClient(void 0, void 0, data, "update");
11100
+ return _this88._enterOrUpdateClient(void 0, void 0, data, "update");
10978
11101
  })();
10979
11102
  }
10980
11103
  enterClient(clientId, data) {
10981
- var _this79 = this;
11104
+ var _this89 = this;
10982
11105
  return _asyncToGenerator(function* () {
10983
- return _this79._enterOrUpdateClient(void 0, clientId, data, "enter");
11106
+ return _this89._enterOrUpdateClient(void 0, clientId, data, "enter");
10984
11107
  })();
10985
11108
  }
10986
11109
  updateClient(clientId, data) {
10987
- var _this80 = this;
11110
+ var _this90 = this;
10988
11111
  return _asyncToGenerator(function* () {
10989
- return _this80._enterOrUpdateClient(void 0, clientId, data, "update");
11112
+ return _this90._enterOrUpdateClient(void 0, clientId, data, "update");
10990
11113
  })();
10991
11114
  }
10992
11115
  _enterOrUpdateClient(id, clientId, data, action) {
10993
- var _this81 = this;
11116
+ var _this91 = this;
10994
11117
  return _asyncToGenerator(function* () {
10995
- var channel = _this81.channel;
11118
+ var channel = _this91.channel;
10996
11119
  if (!channel.connectionManager.activeState()) {
10997
11120
  throw channel.connectionManager.getError();
10998
11121
  }
10999
- logger_default.logAction(_this81.logger, logger_default.LOG_MICRO, "RealtimePresence." + action + "Client()", "channel = " + channel.name + ", id = " + id + ", client = " + (clientId || "(implicit) " + getClientId(_this81)));
11122
+ logger_default.logAction(_this91.logger, logger_default.LOG_MICRO, "RealtimePresence." + action + "Client()", "channel = " + channel.name + ", id = " + id + ", client = " + (clientId || "(implicit) " + getClientId(_this91)));
11000
11123
  var presence = presencemessage_default.fromData(data);
11001
11124
  presence.action = action;
11002
11125
  if (id) {
@@ -11014,7 +11137,7 @@ var ably = {exports: {}};
11014
11137
  channel.attach();
11015
11138
  case "attaching":
11016
11139
  return new Promise((resolve, reject) => {
11017
- _this81.pendingPresence.push({
11140
+ _this91.pendingPresence.push({
11018
11141
  presence: wirePresMsg,
11019
11142
  callback: err => err ? reject(err) : resolve()
11020
11143
  });
@@ -11029,22 +11152,22 @@ var ably = {exports: {}};
11029
11152
  })();
11030
11153
  }
11031
11154
  leave(data) {
11032
- var _this82 = this;
11155
+ var _this92 = this;
11033
11156
  return _asyncToGenerator(function* () {
11034
- if (isAnonymousOrWildcard(_this82)) {
11157
+ if (isAnonymousOrWildcard(_this92)) {
11035
11158
  throw new _ErrorInfo2("clientId must have been specified to enter or leave a presence channel", 40012, 400);
11036
11159
  }
11037
- return _this82.leaveClient(void 0, data);
11160
+ return _this92.leaveClient(void 0, data);
11038
11161
  })();
11039
11162
  }
11040
11163
  leaveClient(clientId, data) {
11041
- var _this83 = this;
11164
+ var _this93 = this;
11042
11165
  return _asyncToGenerator(function* () {
11043
- var channel = _this83.channel;
11166
+ var channel = _this93.channel;
11044
11167
  if (!channel.connectionManager.activeState()) {
11045
11168
  throw channel.connectionManager.getError();
11046
11169
  }
11047
- logger_default.logAction(_this83.logger, logger_default.LOG_MICRO, "RealtimePresence.leaveClient()", "leaving; channel = " + _this83.channel.name + ", client = " + clientId);
11170
+ logger_default.logAction(_this93.logger, logger_default.LOG_MICRO, "RealtimePresence.leaveClient()", "leaving; channel = " + _this93.channel.name + ", client = " + clientId);
11048
11171
  var presence = presencemessage_default.fromData(data);
11049
11172
  presence.action = "leave";
11050
11173
  if (clientId) {
@@ -11056,7 +11179,7 @@ var ably = {exports: {}};
11056
11179
  return channel.sendPresence([wirePresMsg]);
11057
11180
  case "attaching":
11058
11181
  return new Promise((resolve, reject) => {
11059
- _this83.pendingPresence.push({
11182
+ _this93.pendingPresence.push({
11060
11183
  presence: wirePresMsg,
11061
11184
  callback: err => err ? reject(err) : resolve()
11062
11185
  });
@@ -11072,14 +11195,14 @@ var ably = {exports: {}};
11072
11195
  })();
11073
11196
  }
11074
11197
  get(params) {
11075
- var _this84 = this;
11198
+ var _this94 = this;
11076
11199
  return _asyncToGenerator(function* () {
11077
11200
  var waitForSync = !params || ("waitForSync" in params ? params.waitForSync : true);
11078
11201
  return new Promise((resolve, reject) => {
11079
11202
  function returnMembers(members) {
11080
11203
  resolve(params ? members.list(params) : members.values());
11081
11204
  }
11082
- if (_this84.channel.state === "suspended") {
11205
+ if (_this94.channel.state === "suspended") {
11083
11206
  if (waitForSync) {
11084
11207
  reject(_ErrorInfo2.fromValues({
11085
11208
  statusCode: 400,
@@ -11087,12 +11210,12 @@ var ably = {exports: {}};
11087
11210
  message: "Presence state is out of sync due to channel being in the SUSPENDED state"
11088
11211
  }));
11089
11212
  } else {
11090
- returnMembers(_this84.members);
11213
+ returnMembers(_this94.members);
11091
11214
  }
11092
11215
  return;
11093
11216
  }
11094
- waitAttached(_this84.channel, err => reject(err), () => {
11095
- var members = _this84.members;
11217
+ waitAttached(_this94.channel, err => reject(err), () => {
11218
+ var members = _this94.members;
11096
11219
  if (waitForSync) {
11097
11220
  members.waitSync(function () {
11098
11221
  returnMembers(members);
@@ -11105,19 +11228,19 @@ var ably = {exports: {}};
11105
11228
  })();
11106
11229
  }
11107
11230
  history(params) {
11108
- var _this85 = this;
11231
+ var _this95 = this;
11109
11232
  return _asyncToGenerator(function* () {
11110
- logger_default.logAction(_this85.logger, logger_default.LOG_MICRO, "RealtimePresence.history()", "channel = " + _this85.name);
11111
- var restMixin = _this85.channel.client.rest.presenceMixin;
11233
+ logger_default.logAction(_this95.logger, logger_default.LOG_MICRO, "RealtimePresence.history()", "channel = " + _this95.name);
11234
+ var restMixin = _this95.channel.client.rest.presenceMixin;
11112
11235
  if (params && params.untilAttach) {
11113
- if (_this85.channel.state === "attached") {
11236
+ if (_this95.channel.state === "attached") {
11114
11237
  delete params.untilAttach;
11115
- params.from_serial = _this85.channel.properties.attachSerial;
11238
+ params.from_serial = _this95.channel.properties.attachSerial;
11116
11239
  } else {
11117
- throw new _ErrorInfo2("option untilAttach requires the channel to be attached, was: " + _this85.channel.state, 4e4, 400);
11240
+ throw new _ErrorInfo2("option untilAttach requires the channel to be attached, was: " + _this95.channel.state, 4e4, 400);
11118
11241
  }
11119
11242
  }
11120
- return restMixin.history(_this85, params);
11243
+ return restMixin.history(_this95, params);
11121
11244
  })();
11122
11245
  }
11123
11246
  setPresence(presenceSet, isSync, syncChannelSerial) {
@@ -11245,7 +11368,7 @@ var ably = {exports: {}};
11245
11368
  }
11246
11369
  subscribe() {
11247
11370
  var _arguments5 = arguments,
11248
- _this86 = this;
11371
+ _this96 = this;
11249
11372
  return _asyncToGenerator(function* () {
11250
11373
  for (var _len12 = _arguments5.length, _args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
11251
11374
  _args[_key12] = _arguments5[_key12];
@@ -11253,11 +11376,11 @@ var ably = {exports: {}};
11253
11376
  var args = realtimechannel_default.processListenerArgs(_args);
11254
11377
  var event = args[0];
11255
11378
  var listener = args[1];
11256
- var channel = _this86.channel;
11379
+ var channel = _this96.channel;
11257
11380
  if (channel.state === "failed") {
11258
11381
  throw _ErrorInfo2.fromValues(channel.invalidStateError());
11259
11382
  }
11260
- _this86.subscriptions.on(event, listener);
11383
+ _this96.subscriptions.on(event, listener);
11261
11384
  if (channel.channelOptions.attachOnSubscribe !== false) {
11262
11385
  yield channel.attach();
11263
11386
  }
@@ -11429,8 +11552,8 @@ var ably = {exports: {}};
11429
11552
  isRef: !!((_f = (_e = m.extras) == null ? void 0 : _e.ref) == null ? void 0 : _f.timeserial),
11430
11553
  clientId: m.clientId
11431
11554
  };
11432
- if (Object.entries(filter).find(_ref10 => {
11433
- var [key, value] = _ref10;
11555
+ if (Object.entries(filter).find(_ref12 => {
11556
+ var [key, value] = _ref12;
11434
11557
  return value !== void 0 ? mapping[key] !== value : false;
11435
11558
  })) {
11436
11559
  return;
@@ -11458,8 +11581,8 @@ var ably = {exports: {}};
11458
11581
  return [];
11459
11582
  }
11460
11583
  if (!realListener && filter) {
11461
- return Array.from(channel.filteredSubscriptions.entries()).map(_ref11 => {
11462
- var [key, filterMaps] = _ref11;
11584
+ return Array.from(channel.filteredSubscriptions.entries()).map(_ref13 => {
11585
+ var [key, filterMaps] = _ref13;
11463
11586
  var _a2;
11464
11587
  var listenerMaps = filterMaps.get(filter);
11465
11588
  filterMaps.delete(filter);
@@ -11931,38 +12054,38 @@ var ably = {exports: {}};
11931
12054
  return output;
11932
12055
  }
11933
12056
  encrypt(plaintext) {
11934
- var _this87 = this;
12057
+ var _this97 = this;
11935
12058
  return _asyncToGenerator(function* () {
11936
- logger_default.logAction(_this87.logger, logger_default.LOG_MICRO, "CBCCipher.encrypt()", "");
11937
- var iv = yield _this87.getIv();
11938
- var cryptoKey = yield crypto.subtle.importKey("raw", _this87.key, _this87.webCryptoAlgorithm, false, ["encrypt"]);
12059
+ logger_default.logAction(_this97.logger, logger_default.LOG_MICRO, "CBCCipher.encrypt()", "");
12060
+ var iv = yield _this97.getIv();
12061
+ var cryptoKey = yield crypto.subtle.importKey("raw", _this97.key, _this97.webCryptoAlgorithm, false, ["encrypt"]);
11939
12062
  var ciphertext = yield crypto.subtle.encrypt({
11940
- name: _this87.webCryptoAlgorithm,
12063
+ name: _this97.webCryptoAlgorithm,
11941
12064
  iv
11942
12065
  }, cryptoKey, plaintext);
11943
- return _this87.concat(iv, ciphertext);
12066
+ return _this97.concat(iv, ciphertext);
11944
12067
  })();
11945
12068
  }
11946
12069
  decrypt(ciphertext) {
11947
- var _this88 = this;
12070
+ var _this98 = this;
11948
12071
  return _asyncToGenerator(function* () {
11949
- logger_default.logAction(_this88.logger, logger_default.LOG_MICRO, "CBCCipher.decrypt()", "");
12072
+ logger_default.logAction(_this98.logger, logger_default.LOG_MICRO, "CBCCipher.decrypt()", "");
11950
12073
  var ciphertextArrayBuffer = bufferUtils.toArrayBuffer(ciphertext);
11951
12074
  var iv = ciphertextArrayBuffer.slice(0, DEFAULT_BLOCKLENGTH);
11952
12075
  var ciphertextBody = ciphertextArrayBuffer.slice(DEFAULT_BLOCKLENGTH);
11953
- var cryptoKey = yield crypto.subtle.importKey("raw", _this88.key, _this88.webCryptoAlgorithm, false, ["decrypt"]);
12076
+ var cryptoKey = yield crypto.subtle.importKey("raw", _this98.key, _this98.webCryptoAlgorithm, false, ["decrypt"]);
11954
12077
  return crypto.subtle.decrypt({
11955
- name: _this88.webCryptoAlgorithm,
12078
+ name: _this98.webCryptoAlgorithm,
11956
12079
  iv
11957
12080
  }, cryptoKey, ciphertextBody);
11958
12081
  })();
11959
12082
  }
11960
12083
  getIv() {
11961
- var _this89 = this;
12084
+ var _this99 = this;
11962
12085
  return _asyncToGenerator(function* () {
11963
- if (_this89.iv) {
11964
- var iv = _this89.iv;
11965
- _this89.iv = null;
12086
+ if (_this99.iv) {
12087
+ var iv = _this99.iv;
12088
+ _this99.iv = null;
11966
12089
  return iv;
11967
12090
  }
11968
12091
  var randomBlock = yield config.getRandomArrayBuffer(DEFAULT_BLOCKLENGTH);
@@ -12009,7 +12132,7 @@ var ably = {exports: {}};
12009
12132
  if (Platform.Config.xhrSupported && xhrRequestImplementation) {
12010
12133
  this.supportsAuthHeaders = true;
12011
12134
  this.Request = /*#__PURE__*/function () {
12012
- var _ref12 = _asyncToGenerator(function* (method, uri, headers, params, body) {
12135
+ var _ref14 = _asyncToGenerator(function* (method, uri, headers, params, body) {
12013
12136
  return new Promise(resolve => {
12014
12137
  var _a3;
12015
12138
  var req = xhrRequestImplementation.createRequest(uri, headers, params, body, XHRStates_default.REQ_SEND, (_a3 = client && client.options.timeouts) != null ? _a3 : null, this.logger, method);
@@ -12023,8 +12146,8 @@ var ably = {exports: {}};
12023
12146
  req.exec();
12024
12147
  });
12025
12148
  });
12026
- return function (_x82, _x83, _x84, _x85, _x86) {
12027
- return _ref12.apply(this, arguments);
12149
+ return function (_x88, _x89, _x90, _x91, _x92) {
12150
+ return _ref14.apply(this, arguments);
12028
12151
  };
12029
12152
  }();
12030
12153
  if (client == null ? void 0 : client.options.disableConnectivityCheck) {
@@ -12049,11 +12172,11 @@ var ably = {exports: {}};
12049
12172
  } else if (Platform.Config.fetchSupported && fetchRequestImplementation) {
12050
12173
  this.supportsAuthHeaders = true;
12051
12174
  this.Request = /*#__PURE__*/function () {
12052
- var _ref15 = _asyncToGenerator(function* (method, uri, headers, params, body) {
12175
+ var _ref17 = _asyncToGenerator(function* (method, uri, headers, params, body) {
12053
12176
  return fetchRequestImplementation(method, client != null ? client : null, uri, headers, params, body);
12054
12177
  });
12055
- return function (_x87, _x88, _x89, _x90, _x91) {
12056
- return _ref15.apply(this, arguments);
12178
+ return function (_x93, _x94, _x95, _x96, _x97) {
12179
+ return _ref17.apply(this, arguments);
12057
12180
  };
12058
12181
  }();
12059
12182
  if (client == null ? void 0 : client.options.disableConnectivityCheck) {
@@ -12084,14 +12207,14 @@ var ably = {exports: {}};
12084
12207
  return (_b = (_a2 = this.client) == null ? void 0 : _a2.logger) != null ? _b : logger_default.defaultLogger;
12085
12208
  }
12086
12209
  doUri(method, uri, headers, body, params) {
12087
- var _this90 = this;
12210
+ var _this100 = this;
12088
12211
  return _asyncToGenerator(function* () {
12089
- if (!_this90.Request) {
12212
+ if (!_this100.Request) {
12090
12213
  return {
12091
12214
  error: new PartialErrorInfo("Request invoked before assigned to", null, 500)
12092
12215
  };
12093
12216
  }
12094
- return _this90.Request(method, uri, headers, params, body);
12217
+ return _this100.Request(method, uri, headers, params, body);
12095
12218
  })();
12096
12219
  }
12097
12220
  shouldFallback(errorInfo) {
@@ -12221,7 +12344,7 @@ var ably = {exports: {}};
12221
12344
  globalObject4.crypto.getRandomValues(byteArray);
12222
12345
  return byteArray.buffer;
12223
12346
  });
12224
- function getRandomArrayBuffer(_x92) {
12347
+ function getRandomArrayBuffer(_x98) {
12225
12348
  return _getRandomArrayBuffer.apply(this, arguments);
12226
12349
  }
12227
12350
  return getRandomArrayBuffer;
@@ -13366,7 +13489,7 @@ var ably = {exports: {}};
13366
13489
  });
13367
13490
  return result;
13368
13491
  }
13369
- function fetchRequest(_x93, _x94, _x95, _x96, _x97, _x98) {
13492
+ function fetchRequest(_x99, _x100, _x101, _x102, _x103, _x104) {
13370
13493
  return _fetchRequest.apply(this, arguments);
13371
13494
  } // src/platform/web/lib/http/request/index.ts
13372
13495
  function _fetchRequest() {
@@ -13562,15 +13685,15 @@ class ClientAblyService {
13562
13685
  _this2.channel = _this2.client.channels.get(roomName);
13563
13686
  // Subscribe to assistant/system responses
13564
13687
  _this2.channel.subscribe('ReceiveMessage', message => {
13565
- var _a, _b, _c, _d;
13688
+ var _a, _b, _c, _d, _e, _f;
13566
13689
  try {
13567
13690
  var messageContent = typeof message.data === 'string' ? message.data : ((_a = message.data) === null || _a === void 0 ? void 0 : _a.content) || ((_b = message.data) === null || _b === void 0 ? void 0 : _b.message);
13568
13691
  var senderType = ((_c = message.data) === null || _c === void 0 ? void 0 : _c.senderType) || 3; // Assistant
13569
- var needsAgent = ((_d = message.data) === null || _d === void 0 ? void 0 : _d.needsAgent) || false;
13570
- onMessageReceived(messageContent, senderType, needsAgent);
13692
+ var needsAgent = ((_d = message.data) === null || _d === void 0 ? void 0 : _d.needsAgent) || ((_e = message.data) === null || _e === void 0 ? void 0 : _e.actionType) == "needs_agent" || false;
13693
+ var attachments = ((_f = message.data) === null || _f === void 0 ? void 0 : _f.attachments) || [];
13694
+ onMessageReceived(messageContent, senderType, needsAgent, attachments);
13571
13695
  } catch (error) {
13572
13696
  // Handle error silently
13573
- console.error('[AblyService] Error processing ReceiveMessage:', error);
13574
13697
  }
13575
13698
  });
13576
13699
  yield _this2.channel.attach();
@@ -13694,10 +13817,10 @@ function _getValidToken() {
13694
13817
  var forceRefresh = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : false;
13695
13818
  var _a;
13696
13819
  if (!getTokenFunction) {
13697
- throw new Error("API module not initialized. Call initializeAPI(getToken) first.");
13820
+ throw new Error('API module not initialized. Call initializeAPI(getToken) first.');
13698
13821
  }
13699
- var storedToken = localStorage.getItem("chatbot-token");
13700
- var storedExpiry = localStorage.getItem("chatbot-token-expiry");
13822
+ var storedToken = localStorage.getItem('chatbot-token');
13823
+ var storedExpiry = localStorage.getItem('chatbot-token-expiry');
13701
13824
  var currentTime = Math.floor(Date.now() / 1000);
13702
13825
  // Add buffer time to prevent token expiry during request
13703
13826
  var bufferTime = 60; // 1 minute buffer
@@ -13707,10 +13830,9 @@ function _getValidToken() {
13707
13830
  var tokenResponse = yield getTokenFunction();
13708
13831
  storedToken = tokenResponse.token;
13709
13832
  storedExpiry = String(currentTime + ((_a = tokenResponse.expiresIn) !== null && _a !== void 0 ? _a : 900));
13710
- localStorage.setItem("chatbot-token", storedToken);
13711
- localStorage.setItem("chatbot-token-expiry", storedExpiry);
13833
+ localStorage.setItem('chatbot-token', storedToken);
13834
+ localStorage.setItem('chatbot-token-expiry', storedExpiry);
13712
13835
  } catch (error) {
13713
- console.error("Failed to refresh token:", error);
13714
13836
  throw error;
13715
13837
  }
13716
13838
  }
@@ -13727,11 +13849,11 @@ function _fetchWithAuth() {
13727
13849
  var headers = new Headers(options.headers);
13728
13850
  try {
13729
13851
  var token = yield getValidToken();
13730
- headers.set("Authorization", "Bearer ".concat(token));
13852
+ headers.set('Authorization', "Bearer ".concat(token));
13731
13853
  // Add performance optimizations
13732
- headers.set("Accept", "application/json");
13733
- headers.set("Accept-Encoding", "gzip, deflate, br");
13734
- headers.set("Connection", "keep-alive");
13854
+ headers.set('Accept', 'application/json');
13855
+ headers.set('Accept-Encoding', 'gzip, deflate, br');
13856
+ headers.set('Connection', 'keep-alive');
13735
13857
  options.headers = headers;
13736
13858
  // Add timeout to prevent hanging requests
13737
13859
  var controller = new AbortController();
@@ -13740,15 +13862,14 @@ function _fetchWithAuth() {
13740
13862
  var response = yield fetch(url, _objectSpread2(_objectSpread2({}, options), {}, {
13741
13863
  signal: controller.signal,
13742
13864
  // Add HTTP/2 optimization hints
13743
- cache: "no-cache",
13744
- mode: "cors"
13865
+ cache: 'no-cache',
13866
+ mode: 'cors'
13745
13867
  }));
13746
13868
  clearTimeout(timeoutId);
13747
13869
  // Handle 401/403 with token refresh
13748
13870
  if ((response.status === 401 || response.status === 403) && retry) {
13749
- console.warn("Token expired, refreshing...");
13750
13871
  var newToken = yield getValidToken(true);
13751
- headers.set("Authorization", "Bearer ".concat(newToken));
13872
+ headers.set('Authorization', "Bearer ".concat(newToken));
13752
13873
  options.headers = headers;
13753
13874
  // Retry the request with new token
13754
13875
  return fetchWithAuth(url, options, false);
@@ -13756,13 +13877,12 @@ function _fetchWithAuth() {
13756
13877
  return response;
13757
13878
  } catch (error) {
13758
13879
  clearTimeout(timeoutId);
13759
- if (error instanceof Error && error.name === "AbortError") {
13760
- throw new Error("Request timeout - please try again");
13880
+ if (error instanceof Error && error.name === 'AbortError') {
13881
+ throw new Error('Request timeout - please try again');
13761
13882
  }
13762
13883
  throw error;
13763
13884
  }
13764
13885
  } catch (error) {
13765
- console.error("Fetch error:", error);
13766
13886
  throw error;
13767
13887
  }
13768
13888
  });
@@ -13802,10 +13922,10 @@ function apiRequest(_x3) {
13802
13922
  }
13803
13923
  function _apiRequest() {
13804
13924
  _apiRequest = _asyncToGenerator(function* (endpoint) {
13805
- var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : "GET";
13925
+ var method = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'GET';
13806
13926
  var body = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : null;
13807
13927
  var options = arguments.length > 3 ? arguments[3] : undefined;
13808
- if (!baseUrl) throw new Error("API not initialized");
13928
+ if (!baseUrl) throw new Error('API not initialized');
13809
13929
  var url = "".concat(baseUrl, "/").concat(endpoint);
13810
13930
  var requestKey = "".concat(method, ":").concat(endpoint, ":").concat(JSON.stringify(body));
13811
13931
  // Check for duplicate in-flight requests
@@ -13814,7 +13934,7 @@ function _apiRequest() {
13814
13934
  return duplicateRequest;
13815
13935
  }
13816
13936
  // Check cache for GET requests (except real-time endpoints)
13817
- if (method === "GET" && options.cache !== false && !endpoint.includes("/send-message")) {
13937
+ if (method === 'GET' && options.cache !== false && !endpoint.includes('/send-message')) {
13818
13938
  var cached = getCachedResponse(requestKey);
13819
13939
  if (cached) {
13820
13940
  return Promise.resolve(cached);
@@ -13823,9 +13943,9 @@ function _apiRequest() {
13823
13943
  var requestOptions = {
13824
13944
  method,
13825
13945
  headers: {
13826
- "Content-Type": "application/json",
13827
- "Cache-Control": method === "GET" ? "max-age=30" : "no-cache",
13828
- "Accept-Language": options.language
13946
+ 'Content-Type': 'application/json',
13947
+ 'Cache-Control': method === 'GET' ? 'max-age=30' : 'no-cache',
13948
+ 'Accept-Language': options.language
13829
13949
  },
13830
13950
  body: body ? JSON.stringify(body) : null
13831
13951
  };
@@ -13833,26 +13953,37 @@ function _apiRequest() {
13833
13953
  try {
13834
13954
  var response = yield fetchWithAuth(url, requestOptions);
13835
13955
  if (!response.ok) {
13836
- var errorMessage = "API request failed";
13956
+ var errorMessage = 'API request failed';
13837
13957
  try {
13838
- var errorData = yield response.json();
13839
- errorMessage = errorData.message || errorMessage;
13840
- } catch (_a) {
13841
- errorMessage = "HTTP ".concat(response.status, ": ").concat(response.statusText);
13958
+ // Clone response before reading to avoid consuming the body
13959
+ var errorResponse = response.clone();
13960
+ var errorData = yield errorResponse.json();
13961
+ errorMessage = errorData.message || errorData.error || errorMessage;
13962
+ } catch (parseError) {
13963
+ // If JSON parsing fails, try to get text
13964
+ try {
13965
+ var _errorResponse = response.clone();
13966
+ var errorText = yield _errorResponse.text();
13967
+ errorMessage = errorText || "HTTP ".concat(response.status, ": ").concat(response.statusText);
13968
+ } catch (_a) {
13969
+ errorMessage = "HTTP ".concat(response.status, ": ").concat(response.statusText);
13970
+ }
13842
13971
  }
13843
13972
  throw new Error(errorMessage);
13844
13973
  }
13845
13974
  // Cache successful GET responses
13846
- if (method === "GET" && options.cache !== false) {
13975
+ // Note: We clone before caching to avoid consuming the original response body
13976
+ if (method === 'GET' && options.cache !== false) {
13847
13977
  var responseData = response.clone();
13848
13978
  var data = yield responseData.json();
13849
13979
  setCachedResponse(requestKey, {
13850
13980
  json: () => Promise.resolve(data)
13851
13981
  });
13852
13982
  }
13983
+ // Return the original response - it's body hasn't been consumed yet
13984
+ // (we only cloned for caching, and the clone was consumed)
13853
13985
  return response;
13854
13986
  } catch (error) {
13855
- console.error("API request failed for ".concat(endpoint, ":"), error);
13856
13987
  throw error;
13857
13988
  }
13858
13989
  })();