@aslaluroba/help-center-react 3.2.16 → 3.2.17

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.
@@ -242,7 +242,7 @@ var kindOfTest = type => {
242
242
  var typeOfTest = type => thing => typeof thing === type;
243
243
 
244
244
  /**
245
- * Determine if a value is an Array
245
+ * Determine if a value is a non-null object
246
246
  *
247
247
  * @param {Object} val The value to test
248
248
  *
@@ -394,6 +394,31 @@ var isDate = kindOfTest('Date');
394
394
  */
395
395
  var isFile = kindOfTest('File');
396
396
 
397
+ /**
398
+ * Determine if a value is a React Native Blob
399
+ * React Native "blob": an object with a `uri` attribute. Optionally, it can
400
+ * also have a `name` and `type` attribute to specify filename and content type
401
+ *
402
+ * @see https://github.com/facebook/react-native/blob/26684cf3adf4094eb6c405d345a75bf8c7c0bf88/Libraries/Network/FormData.js#L68-L71
403
+ *
404
+ * @param {*} value The value to test
405
+ *
406
+ * @returns {boolean} True if value is a React Native Blob, otherwise false
407
+ */
408
+ var isReactNativeBlob = value => {
409
+ return !!(value && typeof value.uri !== 'undefined');
410
+ };
411
+
412
+ /**
413
+ * Determine if environment is React Native
414
+ * ReactNative `FormData` has a non-standard `getParts()` method
415
+ *
416
+ * @param {*} formData The formData to test
417
+ *
418
+ * @returns {boolean} True if environment is React Native, otherwise false
419
+ */
420
+ var isReactNative = formData => formData && typeof formData.getParts !== 'undefined';
421
+
397
422
  /**
398
423
  * Determine if a value is a Blob
399
424
  *
@@ -428,9 +453,18 @@ var isStream = val => isObject(val) && isFunction$1(val.pipe);
428
453
  *
429
454
  * @returns {boolean} True if value is an FormData, otherwise false
430
455
  */
456
+ function getGlobal() {
457
+ if (typeof globalThis !== 'undefined') return globalThis;
458
+ if (typeof self !== 'undefined') return self;
459
+ if (typeof window !== 'undefined') return window;
460
+ if (typeof global !== 'undefined') return global;
461
+ return {};
462
+ }
463
+ var G = getGlobal();
464
+ var FormDataCtor = typeof G.FormData !== 'undefined' ? G.FormData : undefined;
431
465
  var isFormData = thing => {
432
466
  var kind;
433
- return thing && (typeof FormData === 'function' && thing instanceof FormData || isFunction$1(thing.append) && ((kind = kindOf(thing)) === 'formdata' ||
467
+ return thing && (FormDataCtor && thing instanceof FormDataCtor || isFunction$1(thing.append) && ((kind = kindOf(thing)) === 'formdata' ||
434
468
  // detect form-data instance
435
469
  kind === 'object' && isFunction$1(thing.toString) && thing.toString() === '[object FormData]'));
436
470
  };
@@ -452,8 +486,9 @@ var [isReadableStream, isRequest, isResponse, isHeaders] = ['ReadableStream', 'R
452
486
  *
453
487
  * @returns {String} The String freed of excess whitespace
454
488
  */
455
- var trim = str => str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
456
-
489
+ var trim = str => {
490
+ return str.trim ? str.trim() : str.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g, '');
491
+ };
457
492
  /**
458
493
  * Iterate over an Array or an Object invoking a function for each item.
459
494
  *
@@ -507,6 +542,15 @@ function forEach(obj, fn) {
507
542
  }
508
543
  }
509
544
  }
545
+
546
+ /**
547
+ * Finds a key in an object, case-insensitive, returning the actual key name.
548
+ * Returns null if the object is a Buffer or if no match is found.
549
+ *
550
+ * @param {Object} obj - The object to search.
551
+ * @param {string} key - The key to find (case-insensitive).
552
+ * @returns {?string} The actual key name if found, otherwise null.
553
+ */
510
554
  function findKey(obj, key) {
511
555
  if (isBuffer(obj)) {
512
556
  return null;
@@ -525,8 +569,8 @@ function findKey(obj, key) {
525
569
  }
526
570
  var _global = (() => {
527
571
  /*eslint no-undef:0*/
528
- if (typeof globalThis !== "undefined") return globalThis;
529
- return typeof self !== "undefined" ? self : typeof window !== 'undefined' ? window : global;
572
+ if (typeof globalThis !== 'undefined') return globalThis;
573
+ return typeof self !== 'undefined' ? self : typeof window !== 'undefined' ? window : global;
530
574
  })();
531
575
  var isContextDefined = context => !isUndefined(context) && context !== _global;
532
576
 
@@ -556,6 +600,10 @@ function merge(/* obj1, obj2, obj3, ... */
556
600
  } = isContextDefined(this) && this || {};
557
601
  var result = {};
558
602
  var assignValue = (val, key) => {
603
+ // Skip dangerous property names to prevent prototype pollution
604
+ if (key === '__proto__' || key === 'constructor' || key === 'prototype') {
605
+ return;
606
+ }
559
607
  var targetKey = caseless && findKey(result, key) || key;
560
608
  if (isPlainObject(result[targetKey]) && isPlainObject(val)) {
561
609
  result[targetKey] = merge(result[targetKey], val);
@@ -618,7 +666,7 @@ var extend = function extend(a, b, thisArg) {
618
666
  * @returns {string} content value without BOM
619
667
  */
620
668
  var stripBOM = content => {
621
- if (content.charCodeAt(0) === 0xFEFF) {
669
+ if (content.charCodeAt(0) === 0xfeff) {
622
670
  content = content.slice(1);
623
671
  }
624
672
  return content;
@@ -824,11 +872,20 @@ var freezeMethods = obj => {
824
872
  }
825
873
  if (!descriptor.set) {
826
874
  descriptor.set = () => {
827
- throw Error('Can not rewrite read-only method \'' + name + '\'');
875
+ throw Error("Can not rewrite read-only method '" + name + "'");
828
876
  };
829
877
  }
830
878
  });
831
879
  };
880
+
881
+ /**
882
+ * Converts an array or a delimited string into an object set with values as keys and true as values.
883
+ * Useful for fast membership checks.
884
+ *
885
+ * @param {Array|string} arrayOrString - The array or string to convert.
886
+ * @param {string} delimiter - The delimiter to use if input is a string.
887
+ * @returns {Object} An object with keys from the array or string, values set to true.
888
+ */
832
889
  var toObjectSet = (arrayOrString, delimiter) => {
833
890
  var obj = {};
834
891
  var define = arr => {
@@ -854,6 +911,13 @@ var toFiniteNumber = (value, defaultValue) => {
854
911
  function isSpecCompliantForm(thing) {
855
912
  return !!(thing && isFunction$1(thing.append) && thing[toStringTag] === 'FormData' && thing[iterator]);
856
913
  }
914
+
915
+ /**
916
+ * Recursively converts an object to a JSON-compatible object, handling circular references and Buffers.
917
+ *
918
+ * @param {Object} obj - The object to convert.
919
+ * @returns {Object} The JSON-compatible object.
920
+ */
857
921
  var toJSONObject = obj => {
858
922
  var stack = new Array(10);
859
923
  var visit = (source, i) => {
@@ -881,18 +945,40 @@ var toJSONObject = obj => {
881
945
  };
882
946
  return visit(obj, 0);
883
947
  };
948
+
949
+ /**
950
+ * Determines if a value is an async function.
951
+ *
952
+ * @param {*} thing - The value to test.
953
+ * @returns {boolean} True if value is an async function, otherwise false.
954
+ */
884
955
  var isAsyncFn = kindOfTest('AsyncFunction');
956
+
957
+ /**
958
+ * Determines if a value is thenable (has then and catch methods).
959
+ *
960
+ * @param {*} thing - The value to test.
961
+ * @returns {boolean} True if value is thenable, otherwise false.
962
+ */
885
963
  var isThenable = thing => thing && (isObject(thing) || isFunction$1(thing)) && isFunction$1(thing.then) && isFunction$1(thing.catch);
886
964
 
887
965
  // original code
888
966
  // https://github.com/DigitalBrainJS/AxiosPromise/blob/16deab13710ec09779922131f3fa5954320f83ab/lib/utils.js#L11-L34
889
967
 
968
+ /**
969
+ * Provides a cross-platform setImmediate implementation.
970
+ * Uses native setImmediate if available, otherwise falls back to postMessage or setTimeout.
971
+ *
972
+ * @param {boolean} setImmediateSupported - Whether setImmediate is supported.
973
+ * @param {boolean} postMessageSupported - Whether postMessage is supported.
974
+ * @returns {Function} A function to schedule a callback asynchronously.
975
+ */
890
976
  var _setImmediate = ((setImmediateSupported, postMessageSupported) => {
891
977
  if (setImmediateSupported) {
892
978
  return setImmediate;
893
979
  }
894
980
  return postMessageSupported ? ((token, callbacks) => {
895
- _global.addEventListener("message", _ref2 => {
981
+ _global.addEventListener('message', _ref2 => {
896
982
  var {
897
983
  source,
898
984
  data
@@ -903,10 +989,17 @@ var _setImmediate = ((setImmediateSupported, postMessageSupported) => {
903
989
  }, false);
904
990
  return cb => {
905
991
  callbacks.push(cb);
906
- _global.postMessage(token, "*");
992
+ _global.postMessage(token, '*');
907
993
  };
908
994
  })("axios@".concat(Math.random()), []) : cb => setTimeout(cb);
909
995
  })(typeof setImmediate === 'function', isFunction$1(_global.postMessage));
996
+
997
+ /**
998
+ * Schedules a microtask or asynchronous callback as soon as possible.
999
+ * Uses queueMicrotask if available, otherwise falls back to process.nextTick or _setImmediate.
1000
+ *
1001
+ * @type {Function}
1002
+ */
910
1003
  var asap = typeof queueMicrotask !== 'undefined' ? queueMicrotask.bind(_global) : typeof process !== 'undefined' && process.nextTick || _setImmediate;
911
1004
 
912
1005
  // *********************
@@ -931,6 +1024,8 @@ var utils$1 = {
931
1024
  isUndefined,
932
1025
  isDate,
933
1026
  isFile,
1027
+ isReactNativeBlob,
1028
+ isReactNative,
934
1029
  isBlob,
935
1030
  isRegExp,
936
1031
  isFunction: isFunction$1,
@@ -978,6 +1073,11 @@ let AxiosError$1 = class AxiosError extends Error {
978
1073
  var axiosError = new AxiosError(error.message, code || error.code, config, request, response);
979
1074
  axiosError.cause = error;
980
1075
  axiosError.name = error.name;
1076
+
1077
+ // Preserve status from the original error if not already set from response
1078
+ if (error.status != null && axiosError.status == null) {
1079
+ axiosError.status = error.status;
1080
+ }
981
1081
  customProps && Object.assign(axiosError, customProps);
982
1082
  return axiosError;
983
1083
  }
@@ -995,6 +1095,16 @@ let AxiosError$1 = class AxiosError extends Error {
995
1095
  */
996
1096
  constructor(message, code, config, request, response) {
997
1097
  super(message);
1098
+
1099
+ // Make message enumerable to maintain backward compatibility
1100
+ // The native Error constructor sets message as non-enumerable,
1101
+ // but axios < v1.13.3 had it as enumerable
1102
+ Object.defineProperty(this, 'message', {
1103
+ value: message,
1104
+ enumerable: true,
1105
+ writable: true,
1106
+ configurable: true
1107
+ });
998
1108
  this.name = 'AxiosError';
999
1109
  this.isAxiosError = true;
1000
1110
  code && (this.code = code);
@@ -1176,6 +1286,10 @@ function toFormData$1(obj, formData, options) {
1176
1286
  */
1177
1287
  function defaultVisitor(value, key, path) {
1178
1288
  var arr = value;
1289
+ if (utils$1.isReactNative(formData) && utils$1.isReactNativeBlob(value)) {
1290
+ formData.append(renderKey(path, key, dots), convertValue(value));
1291
+ return false;
1292
+ }
1179
1293
  if (value && !path && typeof value === 'object') {
1180
1294
  if (utils$1.endsWith(key, '{}')) {
1181
1295
  // eslint-disable-next-line no-param-reassign
@@ -1311,7 +1425,7 @@ function buildURL(url, params, options) {
1311
1425
  serializedParams = utils$1.isURLSearchParams(params) ? params.toString() : new AxiosURLSearchParams(params, _options).toString(_encode);
1312
1426
  }
1313
1427
  if (serializedParams) {
1314
- var hashmarkIndex = url.indexOf("#");
1428
+ var hashmarkIndex = url.indexOf('#');
1315
1429
  if (hashmarkIndex !== -1) {
1316
1430
  url = url.slice(0, hashmarkIndex);
1317
1431
  }
@@ -1390,7 +1504,8 @@ class InterceptorManager {
1390
1504
  var transitionalDefaults = {
1391
1505
  silentJSONParsing: true,
1392
1506
  forcedJSONParsing: true,
1393
- clarifyTimeoutError: false
1507
+ clarifyTimeoutError: false,
1508
+ legacyInterceptorReqResOrdering: true
1394
1509
  };
1395
1510
 
1396
1511
  var URLSearchParams$1 = typeof URLSearchParams !== 'undefined' ? URLSearchParams : AxiosURLSearchParams;
@@ -1654,7 +1769,7 @@ var defaults = {
1654
1769
  },
1655
1770
  headers: {
1656
1771
  common: {
1657
- 'Accept': 'application/json, text/plain, */*',
1772
+ Accept: 'application/json, text/plain, */*',
1658
1773
  'Content-Type': undefined
1659
1774
  }
1660
1775
  }
@@ -1899,7 +2014,7 @@ let AxiosHeaders$1 = class AxiosHeaders {
1899
2014
  }).join('\n');
1900
2015
  }
1901
2016
  getSetCookie() {
1902
- return this.get("set-cookie") || [];
2017
+ return this.get('set-cookie') || [];
1903
2018
  }
1904
2019
  get [Symbol.toStringTag]() {
1905
2020
  return 'AxiosHeaders';
@@ -2193,6 +2308,9 @@ function isAbsoluteURL(url) {
2193
2308
  // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
2194
2309
  // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
2195
2310
  // by any combination of letters, digits, plus, period, or hyphen.
2311
+ if (typeof url !== 'string') {
2312
+ return false;
2313
+ }
2196
2314
  return /^([a-z][a-z\d+\-.]*:)?\/\//i.test(url);
2197
2315
  }
2198
2316
 
@@ -2317,7 +2435,8 @@ function mergeConfig$1(config1, config2) {
2317
2435
  headers: (a, b, prop) => mergeDeepProperties(headersToObject(a), headersToObject(b), prop, true)
2318
2436
  };
2319
2437
  utils$1.forEach(Object.keys(_objectSpread2(_objectSpread2({}, config1), config2)), function computeConfigValue(prop) {
2320
- var merge = mergeMap[prop] || mergeDeepProperties;
2438
+ if (prop === '__proto__' || prop === 'constructor' || prop === 'prototype') return;
2439
+ var merge = utils$1.hasOwnProp(mergeMap, prop) ? mergeMap[prop] : mergeDeepProperties;
2321
2440
  var configValue = merge(config1[prop], config2[prop], prop);
2322
2441
  utils$1.isUndefined(configValue) && merge !== mergeDirectKeys || (config[prop] = configValue);
2323
2442
  });
@@ -2845,7 +2964,7 @@ var factory = env => {
2845
2964
  var _request = new Request(url, {
2846
2965
  method: 'POST',
2847
2966
  body: data,
2848
- duplex: "half"
2967
+ duplex: 'half'
2849
2968
  });
2850
2969
  var contentTypeHeader;
2851
2970
  if (utils$1.isFormData(data) && (contentTypeHeader = _request.headers.get('content-type'))) {
@@ -2862,13 +2981,13 @@ var factory = env => {
2862
2981
 
2863
2982
  // Cloudflare Workers throws when credentials are defined
2864
2983
  // see https://github.com/cloudflare/workerd/issues/902
2865
- var isCredentialsSupported = isRequestSupported && "credentials" in Request.prototype;
2984
+ var isCredentialsSupported = isRequestSupported && 'credentials' in Request.prototype;
2866
2985
  var resolvedOptions = _objectSpread2(_objectSpread2({}, fetchOptions), {}, {
2867
2986
  signal: composedSignal,
2868
2987
  method: method.toUpperCase(),
2869
2988
  headers: headers.normalize().toJSON(),
2870
2989
  body: data,
2871
- duplex: "half",
2990
+ duplex: 'half',
2872
2991
  credentials: isCredentialsSupported ? withCredentials : undefined
2873
2992
  });
2874
2993
  request = isRequestSupported && new Request(url, resolvedOptions);
@@ -2902,11 +3021,11 @@ var factory = env => {
2902
3021
  } catch (err) {
2903
3022
  unsubscribe && unsubscribe();
2904
3023
  if (err && err.name === 'TypeError' && /Load failed|fetch/i.test(err.message)) {
2905
- throw Object.assign(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request), {
3024
+ throw Object.assign(new AxiosError$1('Network Error', AxiosError$1.ERR_NETWORK, config, request, err && err.response), {
2906
3025
  cause: err.cause || err
2907
3026
  });
2908
3027
  }
2909
- throw AxiosError$1.from(err, err && err.code, config, request);
3028
+ throw AxiosError$1.from(err, err && err.code, config, request, err && err.response);
2910
3029
  }
2911
3030
  });
2912
3031
  return function (_x5) {
@@ -2944,7 +3063,7 @@ getFetch();
2944
3063
  * - `http` for Node.js
2945
3064
  * - `xhr` for browsers
2946
3065
  * - `fetch` for fetch API-based requests
2947
- *
3066
+ *
2948
3067
  * @type {Object<string, Function|Object>}
2949
3068
  */
2950
3069
  var knownAdapters = {
@@ -2973,7 +3092,7 @@ utils$1.forEach(knownAdapters, (fn, value) => {
2973
3092
 
2974
3093
  /**
2975
3094
  * Render a rejection reason string for unknown or unsupported adapters
2976
- *
3095
+ *
2977
3096
  * @param {string} reason
2978
3097
  * @returns {string}
2979
3098
  */
@@ -2981,7 +3100,7 @@ var renderReason = reason => "- ".concat(reason);
2981
3100
 
2982
3101
  /**
2983
3102
  * Check if the adapter is resolved (function, null, or false)
2984
- *
3103
+ *
2985
3104
  * @param {Function|null|false} adapter
2986
3105
  * @returns {boolean}
2987
3106
  */
@@ -2991,7 +3110,7 @@ var isResolvedHandle = adapter => utils$1.isFunction(adapter) || adapter === nul
2991
3110
  * Get the first suitable adapter from the provided list.
2992
3111
  * Tries each adapter in order until a supported one is found.
2993
3112
  * Throws an AxiosError if no adapter is suitable.
2994
- *
3113
+ *
2995
3114
  * @param {Array<string|Function>|string|Function} adapters - Adapter(s) by name or function.
2996
3115
  * @param {Object} config - Axios request configuration
2997
3116
  * @throws {AxiosError} If no suitable adapter is available
@@ -3101,7 +3220,7 @@ function dispatchRequest(config) {
3101
3220
  });
3102
3221
  }
3103
3222
 
3104
- var VERSION$1 = "1.13.4";
3223
+ var VERSION$1 = "1.13.6";
3105
3224
 
3106
3225
  var validators$1 = {};
3107
3226
 
@@ -3124,7 +3243,7 @@ var deprecatedWarnings = {};
3124
3243
  */
3125
3244
  validators$1.transitional = function transitional(validator, version, message) {
3126
3245
  function formatMessage(opt, desc) {
3127
- return '[Axios v' + VERSION$1 + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
3246
+ return '[Axios v' + VERSION$1 + "] Transitional option '" + opt + "'" + desc + (message ? '. ' + message : '');
3128
3247
  }
3129
3248
 
3130
3249
  // eslint-disable-next-line func-names
@@ -3257,7 +3376,8 @@ let Axios$1 = class Axios {
3257
3376
  validator.assertOptions(transitional, {
3258
3377
  silentJSONParsing: validators.transitional(validators.boolean),
3259
3378
  forcedJSONParsing: validators.transitional(validators.boolean),
3260
- clarifyTimeoutError: validators.transitional(validators.boolean)
3379
+ clarifyTimeoutError: validators.transitional(validators.boolean),
3380
+ legacyInterceptorReqResOrdering: validators.transitional(validators.boolean)
3261
3381
  }, false);
3262
3382
  }
3263
3383
  if (paramsSerializer != null) {
@@ -3302,7 +3422,13 @@ let Axios$1 = class Axios {
3302
3422
  return;
3303
3423
  }
3304
3424
  synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
3305
- requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3425
+ var transitional = config.transitional || transitionalDefaults;
3426
+ var legacyInterceptorReqResOrdering = transitional && transitional.legacyInterceptorReqResOrdering;
3427
+ if (legacyInterceptorReqResOrdering) {
3428
+ requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
3429
+ } else {
3430
+ requestInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
3431
+ }
3306
3432
  });
3307
3433
  var responseInterceptorChain = [];
3308
3434
  this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
@@ -4094,12 +4220,13 @@ function requireAbly() {
4094
4220
  if (err.statusCode) result += "; statusCode=" + err.statusCode;
4095
4221
  if (err.code) result += "; code=" + err.code;
4096
4222
  if (err.cause) result += "; cause=" + _inspectError(err.cause);
4223
+ if (err.detail && Object.keys(err.detail).length > 0) result += "; detail=" + JSON.stringify(err.detail);
4097
4224
  if (err.href && !(err.message && err.message.indexOf("help.ably.io") > -1)) result += "; see " + err.href + " ";
4098
4225
  result += "]";
4099
4226
  return result;
4100
4227
  }
4101
4228
  var _ErrorInfo2 = class _ErrorInfo extends Error {
4102
- constructor(message, code, statusCode, cause) {
4229
+ constructor(message, code, statusCode, cause, detail) {
4103
4230
  super(message);
4104
4231
  if (typeof Object.setPrototypeOf !== "undefined") {
4105
4232
  Object.setPrototypeOf(this, _ErrorInfo.prototype);
@@ -4107,6 +4234,7 @@ function requireAbly() {
4107
4234
  this.code = code;
4108
4235
  this.statusCode = statusCode;
4109
4236
  this.cause = cause;
4237
+ this.detail = detail;
4110
4238
  }
4111
4239
  toString() {
4112
4240
  return toString(this);
@@ -4115,12 +4243,13 @@ function requireAbly() {
4115
4243
  var {
4116
4244
  message,
4117
4245
  code,
4118
- statusCode
4246
+ statusCode,
4247
+ detail
4119
4248
  } = values;
4120
- if (typeof message !== "string" || typeof code !== "number" || typeof statusCode !== "number") {
4249
+ if (typeof message !== "string" || typeof code !== "number" || typeof statusCode !== "number" || !_isNil(detail) && (typeof detail !== "object" || Array.isArray(detail))) {
4121
4250
  throw new Error("ErrorInfo.fromValues(): invalid values: " + Platform.Config.inspect(values));
4122
4251
  }
4123
- var result = Object.assign(new _ErrorInfo(message, code, statusCode), values);
4252
+ var result = Object.assign(new _ErrorInfo(message, code, statusCode, void 0, detail), values);
4124
4253
  if (result.code && !result.href) {
4125
4254
  result.href = "https://help.ably.io/error/" + result.code;
4126
4255
  }
@@ -4128,7 +4257,7 @@ function requireAbly() {
4128
4257
  }
4129
4258
  };
4130
4259
  var PartialErrorInfo = class _PartialErrorInfo extends Error {
4131
- constructor(message, code, statusCode, cause) {
4260
+ constructor(message, code, statusCode, cause, detail) {
4132
4261
  super(message);
4133
4262
  if (typeof Object.setPrototypeOf !== "undefined") {
4134
4263
  Object.setPrototypeOf(this, _PartialErrorInfo.prototype);
@@ -4136,6 +4265,7 @@ function requireAbly() {
4136
4265
  this.code = code;
4137
4266
  this.statusCode = statusCode;
4138
4267
  this.cause = cause;
4268
+ this.detail = detail;
4139
4269
  }
4140
4270
  toString() {
4141
4271
  return toString(this);
@@ -4144,12 +4274,13 @@ function requireAbly() {
4144
4274
  var {
4145
4275
  message,
4146
4276
  code,
4147
- statusCode
4277
+ statusCode,
4278
+ detail
4148
4279
  } = values;
4149
- if (typeof message !== "string" || !_isNil(code) && typeof code !== "number" || !_isNil(statusCode) && typeof statusCode !== "number") {
4280
+ if (typeof message !== "string" || !_isNil(code) && typeof code !== "number" || !_isNil(statusCode) && typeof statusCode !== "number" || !_isNil(detail) && (typeof detail !== "object" || Array.isArray(detail))) {
4150
4281
  throw new Error("PartialErrorInfo.fromValues(): invalid values: " + Platform.Config.inspect(values));
4151
4282
  }
4152
- var result = Object.assign(new _PartialErrorInfo(message, code, statusCode), values);
4283
+ var result = Object.assign(new _PartialErrorInfo(message, code, statusCode, void 0, detail), values);
4153
4284
  if (result.code && !result.href) {
4154
4285
  result.href = "https://help.ably.io/error/" + result.code;
4155
4286
  }
@@ -4500,7 +4631,7 @@ function requireAbly() {
4500
4631
  }
4501
4632
 
4502
4633
  // package.json
4503
- var version = "2.17.1";
4634
+ var version = "2.21.0";
4504
4635
 
4505
4636
  // src/common/lib/util/defaults.ts
4506
4637
  var agent = "ably-js/" + version;
@@ -4531,7 +4662,7 @@ function requireAbly() {
4531
4662
  httpMaxRetryCount: 3,
4532
4663
  maxMessageSize: 65536,
4533
4664
  version,
4534
- protocolVersion: 5,
4665
+ protocolVersion: 6,
4535
4666
  agent,
4536
4667
  getPort,
4537
4668
  getHttpScheme,
@@ -6131,7 +6262,7 @@ function requireAbly() {
6131
6262
  this.Utils = utils_exports;
6132
6263
  this.EventEmitter = eventemitter_default;
6133
6264
  this.MessageEncoding = MessageEncoding;
6134
- var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j;
6265
+ var _a2, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
6135
6266
  this._additionalHTTPRequestImplementations = (_a2 = options.plugins) != null ? _a2 : null;
6136
6267
  this.logger = new logger_default();
6137
6268
  this.logger.setLog(options.logLevel, options.logHandler);
@@ -6160,6 +6291,7 @@ function requireAbly() {
6160
6291
  this._Crypto = (_f = (_e = options.plugins) == null ? void 0 : _e.Crypto) != null ? _f : null;
6161
6292
  this.__FilteredSubscriptions = (_h = (_g = options.plugins) == null ? void 0 : _g.MessageInteractions) != null ? _h : null;
6162
6293
  this._Annotations = (_j = (_i = options.plugins) == null ? void 0 : _i.Annotations) != null ? _j : null;
6294
+ this._liveObjectsPlugin = (_l = (_k = options.plugins) == null ? void 0 : _k.LiveObjects) != null ? _l : null;
6163
6295
  }
6164
6296
  get rest() {
6165
6297
  if (!this._rest) {
@@ -6642,6 +6774,7 @@ function requireAbly() {
6642
6774
  this.headers = headers;
6643
6775
  this.errorCode = err && err.code;
6644
6776
  this.errorMessage = err && err.message;
6777
+ this.errorDetail = err == null ? void 0 : err.detail;
6645
6778
  }
6646
6779
  toJSON() {
6647
6780
  return {
@@ -6650,7 +6783,8 @@ function requireAbly() {
6650
6783
  success: this.success,
6651
6784
  headers: this.headers,
6652
6785
  errorCode: this.errorCode,
6653
- errorMessage: this.errorMessage
6786
+ errorMessage: this.errorMessage,
6787
+ errorDetail: this.errorDetail
6654
6788
  };
6655
6789
  }
6656
6790
  };
@@ -7338,6 +7472,9 @@ function requireAbly() {
7338
7472
  if (client._Annotations) {
7339
7473
  this._annotations = new client._Annotations.RestAnnotations(this);
7340
7474
  }
7475
+ if (client._liveObjectsPlugin) {
7476
+ this._object = new client._liveObjectsPlugin.RestObject(this);
7477
+ }
7341
7478
  }
7342
7479
  get annotations() {
7343
7480
  if (!this._annotations) {
@@ -7351,6 +7488,12 @@ function requireAbly() {
7351
7488
  }
7352
7489
  return this._push;
7353
7490
  }
7491
+ get object() {
7492
+ if (!this._object) {
7493
+ _throwMissingPluginError("LiveObjects");
7494
+ }
7495
+ return this._object;
7496
+ }
7354
7497
  get logger() {
7355
7498
  return this.client.logger;
7356
7499
  }
@@ -8182,7 +8325,6 @@ function requireAbly() {
8182
8325
  var channelstatechange_default = ChannelStateChange;
8183
8326
 
8184
8327
  // src/common/lib/client/realtimechannel.ts
8185
- var noop = function noop() {};
8186
8328
  function validateChannelOptions(options) {
8187
8329
  if (options && "params" in options && !_isObject(options.params)) {
8188
8330
  return new _ErrorInfo2("options.params must be an object", 4e4, 400);
@@ -8201,7 +8343,7 @@ function requireAbly() {
8201
8343
  }
8202
8344
  var RealtimeChannel = class _RealtimeChannel extends eventemitter_default {
8203
8345
  constructor(client, name, options) {
8204
- var _a2, _b, _c;
8346
+ var _a2, _b;
8205
8347
  super(client.logger);
8206
8348
  this._annotations = null;
8207
8349
  this._mode = 0;
@@ -8258,12 +8400,13 @@ function requireAbly() {
8258
8400
  protocolMessageChannelSerial: null,
8259
8401
  decodeFailureRecoveryInProgress: null
8260
8402
  };
8261
- this._allChannelChanges = new eventemitter_default(this.logger);
8403
+ this._attachedReceived = new eventemitter_default(this.logger);
8404
+ this.internalStateChanges = new eventemitter_default(this.logger);
8262
8405
  if ((_b = client.options.plugins) == null ? void 0 : _b.Push) {
8263
8406
  this._push = new client.options.plugins.Push.PushChannel(this);
8264
8407
  }
8265
- if ((_c = client.options.plugins) == null ? void 0 : _c.LiveObjects) {
8266
- this._object = new client.options.plugins.LiveObjects.RealtimeObject(this);
8408
+ if (client._liveObjectsPlugin) {
8409
+ this._object = new client._liveObjectsPlugin.RealtimeObject(this);
8267
8410
  }
8268
8411
  }
8269
8412
  get presence() {
@@ -8291,6 +8434,14 @@ function requireAbly() {
8291
8434
  }
8292
8435
  return this._object;
8293
8436
  }
8437
+ // Override of EventEmitter method
8438
+ emit(event) {
8439
+ for (var _len0 = arguments.length, args = new Array(_len0 > 1 ? _len0 - 1 : 0), _key0 = 1; _key0 < _len0; _key0++) {
8440
+ args[_key0 - 1] = arguments[_key0];
8441
+ }
8442
+ super.emit(event, ...args);
8443
+ this.internalStateChanges.emit(event, ...args);
8444
+ }
8294
8445
  invalidStateError() {
8295
8446
  return new _ErrorInfo2("Channel operation failed as channel state is " + this.state, 90001, 400, this.errorReason || void 0);
8296
8447
  }
@@ -8315,16 +8466,20 @@ function requireAbly() {
8315
8466
  if (_this67._shouldReattachToSetOptions(options, previousChannelOptions)) {
8316
8467
  _this67.attachImpl();
8317
8468
  return new Promise((resolve, reject) => {
8318
- _this67._allChannelChanges.once(["attached", "update", "detached", "failed"], function (stateChange) {
8319
- switch (this.event) {
8320
- case "update":
8321
- case "attached":
8322
- resolve();
8323
- break;
8324
- default:
8325
- reject(stateChange.reason);
8326
- }
8327
- });
8469
+ var cleanup = () => {
8470
+ _this67._attachedReceived.off(onAttached);
8471
+ _this67.internalStateChanges.off(onFailure);
8472
+ };
8473
+ var onAttached = () => {
8474
+ cleanup();
8475
+ resolve();
8476
+ };
8477
+ var onFailure = stateChange => {
8478
+ cleanup();
8479
+ reject(stateChange.reason);
8480
+ };
8481
+ _this67._attachedReceived.once("attached", onAttached);
8482
+ _this67.internalStateChanges.once(["detached", "failed"], onFailure);
8328
8483
  });
8329
8484
  }
8330
8485
  })();
@@ -8387,10 +8542,7 @@ function requireAbly() {
8387
8542
  messages: wireMessages,
8388
8543
  params: params ? _stringifyValues(params) : void 0
8389
8544
  });
8390
- var res = yield _this68.sendMessage(pm);
8391
- return res || {
8392
- serials: []
8393
- };
8545
+ return _this68.sendAndAwaitAck(pm);
8394
8546
  })();
8395
8547
  }
8396
8548
  throwIfUnpublishableState() {
@@ -8436,7 +8588,7 @@ function requireAbly() {
8436
8588
  if (this.state !== "attaching" || forceReattach) {
8437
8589
  this.requestState("attaching", attachReason);
8438
8590
  }
8439
- this.once(function (stateChange) {
8591
+ this.internalStateChanges.once(function (stateChange) {
8440
8592
  switch (this.event) {
8441
8593
  case "attached":
8442
8594
  callback == null ? void 0 : callback(null, stateChange);
@@ -8471,7 +8623,7 @@ function requireAbly() {
8471
8623
  if (this._lastPayload.decodeFailureRecoveryInProgress) {
8472
8624
  attachMsg.channelSerial = this._lastPayload.protocolMessageChannelSerial;
8473
8625
  }
8474
- this.sendMessage(attachMsg).catch(noop);
8626
+ this.send(attachMsg);
8475
8627
  }
8476
8628
  detach() {
8477
8629
  var _this70 = this;
@@ -8493,7 +8645,7 @@ function requireAbly() {
8493
8645
  _this70.requestState("detaching");
8494
8646
  case "detaching":
8495
8647
  return new Promise((resolve, reject) => {
8496
- _this70.once(function (stateChange) {
8648
+ _this70.internalStateChanges.once(function (stateChange) {
8497
8649
  switch (this.event) {
8498
8650
  case "detached":
8499
8651
  resolve();
@@ -8518,14 +8670,14 @@ function requireAbly() {
8518
8670
  action: actions.DETACH,
8519
8671
  channel: this.name
8520
8672
  });
8521
- this.sendMessage(msg).catch(noop);
8673
+ this.send(msg);
8522
8674
  }
8523
8675
  subscribe() {
8524
8676
  var _arguments3 = arguments,
8525
8677
  _this71 = this;
8526
8678
  return _asyncToGenerator(function* () {
8527
- for (var _len0 = _arguments3.length, args = new Array(_len0), _key0 = 0; _key0 < _len0; _key0++) {
8528
- args[_key0] = _arguments3[_key0];
8679
+ for (var _len1 = _arguments3.length, args = new Array(_len1), _key1 = 0; _key1 < _len1; _key1++) {
8680
+ args[_key1] = _arguments3[_key1];
8529
8681
  }
8530
8682
  var [event, listener] = _RealtimeChannel.processListenerArgs(args);
8531
8683
  if (_this71.state === "failed") {
@@ -8545,8 +8697,8 @@ function requireAbly() {
8545
8697
  }
8546
8698
  unsubscribe() {
8547
8699
  var _a2;
8548
- for (var _len1 = arguments.length, args = new Array(_len1), _key1 = 0; _key1 < _len1; _key1++) {
8549
- args[_key1] = arguments[_key1];
8700
+ for (var _len10 = arguments.length, args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
8701
+ args[_key10] = arguments[_key10];
8550
8702
  }
8551
8703
  var [event, listener] = _RealtimeChannel.processListenerArgs(args);
8552
8704
  if (typeof event === "object" && !listener || ((_a2 = this.filteredSubscriptions) == null ? void 0 : _a2.has(listener))) {
@@ -8575,7 +8727,10 @@ function requireAbly() {
8575
8727
  }
8576
8728
  connectionManager.send(syncMessage);
8577
8729
  }
8578
- sendMessage(msg) {
8730
+ send(msg) {
8731
+ this.connectionManager.send(msg);
8732
+ }
8733
+ sendAndAwaitAck(msg) {
8579
8734
  var _this72 = this;
8580
8735
  return _asyncToGenerator(function* () {
8581
8736
  return new Promise((resolve, reject) => {
@@ -8597,7 +8752,7 @@ function requireAbly() {
8597
8752
  channel: _this73.name,
8598
8753
  presence
8599
8754
  });
8600
- yield _this73.sendMessage(msg);
8755
+ yield _this73.sendAndAwaitAck(msg);
8601
8756
  })();
8602
8757
  }
8603
8758
  sendState(objectMessages) {
@@ -8608,7 +8763,7 @@ function requireAbly() {
8608
8763
  channel: _this74.name,
8609
8764
  state: objectMessages
8610
8765
  });
8611
- yield _this74.sendMessage(msg);
8766
+ return _this74.sendAndAwaitAck(msg);
8612
8767
  })();
8613
8768
  }
8614
8769
  // Access to this method is synchronised by ConnectionManager#processChannelMessage, in order to synchronise access to the state stored in _decodingContext.
@@ -8632,17 +8787,17 @@ function requireAbly() {
8632
8787
  var hasPresence = message.hasFlag("HAS_PRESENCE");
8633
8788
  var hasBacklog = message.hasFlag("HAS_BACKLOG");
8634
8789
  var hasObjects = message.hasFlag("HAS_OBJECTS");
8790
+ _this75._attachedReceived.emit("attached");
8635
8791
  if (_this75.state === "attached") {
8636
8792
  if (!resumed) {
8637
8793
  if (_this75._presence) {
8638
8794
  _this75._presence.onAttached(hasPresence);
8639
8795
  }
8640
- if (_this75._object) {
8641
- _this75._object.onAttached(hasObjects);
8642
- }
8796
+ }
8797
+ if (_this75._object) {
8798
+ _this75._object.onAttached(hasObjects);
8643
8799
  }
8644
8800
  var change = new channelstatechange_default(_this75.state, _this75.state, resumed, hasBacklog, message.error);
8645
- _this75._allChannelChanges.emit("update", change);
8646
8801
  if (!resumed || _this75.channelOptions.updateOnAttached) {
8647
8802
  _this75.emit("update", change);
8648
8803
  }
@@ -8822,7 +8977,6 @@ function requireAbly() {
8822
8977
  this._attachResume = false;
8823
8978
  }
8824
8979
  this.state = state;
8825
- this._allChannelChanges.emit(state, change);
8826
8980
  this.emit(state, change);
8827
8981
  }
8828
8982
  requestState(state, reason) {
@@ -8956,7 +9110,7 @@ function requireAbly() {
8956
9110
  sendUpdate(message, action, operation, params) {
8957
9111
  var _this81 = this;
8958
9112
  return _asyncToGenerator(function* () {
8959
- var _a2, _b;
9113
+ var _a2;
8960
9114
  if (!message.serial) {
8961
9115
  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);
8962
9116
  }
@@ -8972,9 +9126,9 @@ function requireAbly() {
8972
9126
  messages: [wireMessage],
8973
9127
  params: params ? _stringifyValues(params) : void 0
8974
9128
  });
8975
- var publishResponse = yield _this81.sendMessage(pm);
9129
+ var publishResponse = yield _this81.sendAndAwaitAck(pm);
8976
9130
  return {
8977
- versionSerial: (_b = (_a2 = publishResponse == null ? void 0 : publishResponse.serials) == null ? void 0 : _a2[0]) != null ? _b : null
9131
+ versionSerial: (_a2 = publishResponse.serials[0]) != null ? _a2 : null
8978
9132
  };
8979
9133
  })();
8980
9134
  }
@@ -9044,7 +9198,7 @@ function requireAbly() {
9044
9198
  channel: channelName,
9045
9199
  annotations: [wireAnnotation]
9046
9200
  });
9047
- yield _this84.channel.sendMessage(pm);
9201
+ yield _this84.channel.sendAndAwaitAck(pm);
9048
9202
  })();
9049
9203
  }
9050
9204
  delete(msgOrSerial, annotationValues) {
@@ -9058,8 +9212,8 @@ function requireAbly() {
9058
9212
  var _arguments4 = arguments,
9059
9213
  _this86 = this;
9060
9214
  return _asyncToGenerator(function* () {
9061
- for (var _len10 = _arguments4.length, _args = new Array(_len10), _key10 = 0; _key10 < _len10; _key10++) {
9062
- _args[_key10] = _arguments4[_key10];
9215
+ for (var _len11 = _arguments4.length, _args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
9216
+ _args[_key11] = _arguments4[_key11];
9063
9217
  }
9064
9218
  var args = realtimechannel_default.processListenerArgs(_args);
9065
9219
  var event = args[0];
@@ -9078,8 +9232,8 @@ function requireAbly() {
9078
9232
  })();
9079
9233
  }
9080
9234
  unsubscribe() {
9081
- for (var _len11 = arguments.length, _args = new Array(_len11), _key11 = 0; _key11 < _len11; _key11++) {
9082
- _args[_key11] = arguments[_key11];
9235
+ for (var _len12 = arguments.length, _args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
9236
+ _args[_key12] = arguments[_key12];
9083
9237
  }
9084
9238
  var args = realtimechannel_default.processListenerArgs(_args);
9085
9239
  var event = args[0];
@@ -9591,7 +9745,7 @@ function requireAbly() {
9591
9745
  var _a2;
9592
9746
  return typeof Platform.WebStorage !== "undefined" && ((_a2 = Platform.WebStorage) == null ? void 0 : _a2.sessionSupported);
9593
9747
  };
9594
- var noop2 = function noop2() {};
9748
+ var noop = function noop() {};
9595
9749
  var transportPreferenceName = "ably-transport-preference";
9596
9750
  function decodeRecoveryKey(recoveryKey) {
9597
9751
  try {
@@ -10456,7 +10610,7 @@ function requireAbly() {
10456
10610
  this.disconnectAllTransports();
10457
10611
  this.connectWs(transportParams, ++this.connectCounter);
10458
10612
  }
10459
- }).catch(noop2);
10613
+ }).catch(noop);
10460
10614
  }
10461
10615
  if (transportPreference && transportPreference === this.baseTransport || this.baseTransport && !this.webSocketTransportAvailable) {
10462
10616
  this.connectBase(transportParams, connectCount);
@@ -10663,7 +10817,7 @@ function requireAbly() {
10663
10817
  * event queueing
10664
10818
  ******************/
10665
10819
  send(msg, queueEvent, callback) {
10666
- callback = callback || noop2;
10820
+ callback = callback || noop;
10667
10821
  var state = this.state;
10668
10822
  if (state.sendEvents) {
10669
10823
  logger_default.logAction(this.logger, logger_default.LOG_MICRO, "ConnectionManager.send()", "sending event");
@@ -10947,7 +11101,7 @@ function requireAbly() {
10947
11101
  * tell the compiler that these cases are possible so that it forces us to handle them.
10948
11102
  */
10949
11103
  constructor(options) {
10950
- var _a2, _b, _c, _d;
11104
+ var _a2, _b;
10951
11105
  super(defaults_default.objectifyOptions(options, false, "BaseRealtime", logger_default.defaultLogger));
10952
11106
  logger_default.logAction(this.logger, logger_default.LOG_MINOR, "Realtime()", "");
10953
11107
  if (typeof EdgeRuntime === "string") {
@@ -10955,7 +11109,6 @@ function requireAbly() {
10955
11109
  }
10956
11110
  this._additionalTransportImplementations = _BaseRealtime.transportImplementationsFromPlugins(this.options.plugins);
10957
11111
  this._RealtimePresence = (_b = (_a2 = this.options.plugins) == null ? void 0 : _a2.RealtimePresence) != null ? _b : null;
10958
- this._liveObjectsPlugin = (_d = (_c = this.options.plugins) == null ? void 0 : _c.LiveObjects) != null ? _d : null;
10959
11112
  this.connection = new connection_default(this, this.options);
10960
11113
  this._channels = new Channels2(this);
10961
11114
  if (this.options.autoConnect !== false) this.connect();
@@ -11543,8 +11696,8 @@ function requireAbly() {
11543
11696
  var _arguments5 = arguments,
11544
11697
  _this102 = this;
11545
11698
  return _asyncToGenerator(function* () {
11546
- for (var _len12 = _arguments5.length, _args = new Array(_len12), _key12 = 0; _key12 < _len12; _key12++) {
11547
- _args[_key12] = _arguments5[_key12];
11699
+ for (var _len13 = _arguments5.length, _args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
11700
+ _args[_key13] = _arguments5[_key13];
11548
11701
  }
11549
11702
  var args = realtimechannel_default.processListenerArgs(_args);
11550
11703
  var event = args[0];
@@ -11560,8 +11713,8 @@ function requireAbly() {
11560
11713
  })();
11561
11714
  }
11562
11715
  unsubscribe() {
11563
- for (var _len13 = arguments.length, _args = new Array(_len13), _key13 = 0; _key13 < _len13; _key13++) {
11564
- _args[_key13] = arguments[_key13];
11716
+ for (var _len14 = arguments.length, _args = new Array(_len14), _key14 = 0; _key14 < _len14; _key14++) {
11717
+ _args[_key14] = arguments[_key14];
11565
11718
  }
11566
11719
  var args = realtimechannel_default.processListenerArgs(_args);
11567
11720
  var event = args[0];
@@ -12179,7 +12332,7 @@ function requireAbly() {
12179
12332
  try {
12180
12333
  return config.getRandomArrayBuffer((keyLength || DEFAULT_KEYLENGTH) / 8);
12181
12334
  } catch (err) {
12182
- throw new _ErrorInfo2("Failed to generate random key: " + err.message, 400, 5e4, err);
12335
+ throw new _ErrorInfo2("Failed to generate random key: " + err.message, 400, 5e4);
12183
12336
  }
12184
12337
  })();
12185
12338
  }
@@ -12788,7 +12941,7 @@ function requireAbly() {
12788
12941
  return responseBody.error && _ErrorInfo2.fromValues(responseBody.error);
12789
12942
  }
12790
12943
  }
12791
- var noop3 = function noop3() {};
12944
+ var noop2 = function noop2() {};
12792
12945
  var idCounter = 0;
12793
12946
  var pendingRequests = {};
12794
12947
  function getHeader(xhr, header) {
@@ -12984,7 +13137,7 @@ function requireAbly() {
12984
13137
  dispose() {
12985
13138
  var xhr = this.xhr;
12986
13139
  if (xhr) {
12987
- xhr.onreadystatechange = xhr.onerror = xhr.onabort = xhr.ontimeout = noop3;
13140
+ xhr.onreadystatechange = xhr.onerror = xhr.onabort = xhr.ontimeout = noop2;
12988
13141
  this.xhr = null;
12989
13142
  var timer = this.timer;
12990
13143
  if (timer) {