@kohost/api-client 3.0.0-beta.11 → 3.0.0-beta.12

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/esm/defs.js CHANGED
@@ -645,7 +645,7 @@ var require_axios = __commonJS({
645
645
  var isHTMLForm = kindOfTest("HTMLFormElement");
646
646
  var toCamelCase = /* @__PURE__ */ __name((str) => {
647
647
  return str.toLowerCase().replace(
648
- /[_-\s]([a-z\d])(\w*)/g,
648
+ /[-_\s]([a-z\d])(\w*)/g,
649
649
  /* @__PURE__ */ __name(function replacer(m, p1, p2) {
650
650
  return p1.toUpperCase() + p2;
651
651
  }, "replacer")
@@ -699,6 +699,25 @@ var require_axios = __commonJS({
699
699
  value = +value;
700
700
  return Number.isFinite(value) ? value : defaultValue;
701
701
  }, "toFiniteNumber");
702
+ var ALPHA = "abcdefghijklmnopqrstuvwxyz";
703
+ var DIGIT = "0123456789";
704
+ var ALPHABET = {
705
+ DIGIT,
706
+ ALPHA,
707
+ ALPHA_DIGIT: ALPHA + ALPHA.toUpperCase() + DIGIT
708
+ };
709
+ var generateString = /* @__PURE__ */ __name((size = 16, alphabet = ALPHABET.ALPHA_DIGIT) => {
710
+ let str = "";
711
+ const { length } = alphabet;
712
+ while (size--) {
713
+ str += alphabet[Math.random() * length | 0];
714
+ }
715
+ return str;
716
+ }, "generateString");
717
+ function isSpecCompliantForm(thing) {
718
+ return !!(thing && isFunction(thing.append) && thing[Symbol.toStringTag] === "FormData" && thing[Symbol.iterator]);
719
+ }
720
+ __name(isSpecCompliantForm, "isSpecCompliantForm");
702
721
  var toJSONObject = /* @__PURE__ */ __name((obj) => {
703
722
  const stack = new Array(10);
704
723
  const visit = /* @__PURE__ */ __name((source, i) => {
@@ -768,6 +787,9 @@ var require_axios = __commonJS({
768
787
  findKey,
769
788
  global: _global,
770
789
  isContextDefined,
790
+ ALPHABET,
791
+ generateString,
792
+ isSpecCompliantForm,
771
793
  toJSONObject
772
794
  };
773
795
  function AxiosError(message, code, config, request, response) {
@@ -840,8 +862,7 @@ var require_axios = __commonJS({
840
862
  customProps && Object.assign(axiosError, customProps);
841
863
  return axiosError;
842
864
  };
843
- var browser = typeof self == "object" ? self.FormData : window.FormData;
844
- var FormData$2 = browser;
865
+ var httpAdapter = null;
845
866
  function isVisitable(thing) {
846
867
  return utils.isPlainObject(thing) || utils.isArray(thing);
847
868
  }
@@ -866,15 +887,11 @@ var require_axios = __commonJS({
866
887
  var predicates = utils.toFlatObject(utils, {}, null, /* @__PURE__ */ __name(function filter(prop) {
867
888
  return /^is[A-Z]/.test(prop);
868
889
  }, "filter"));
869
- function isSpecCompliant(thing) {
870
- return thing && utils.isFunction(thing.append) && thing[Symbol.toStringTag] === "FormData" && thing[Symbol.iterator];
871
- }
872
- __name(isSpecCompliant, "isSpecCompliant");
873
890
  function toFormData(obj, formData, options) {
874
891
  if (!utils.isObject(obj)) {
875
892
  throw new TypeError("target must be an object");
876
893
  }
877
- formData = formData || new (FormData$2 || FormData)();
894
+ formData = formData || new FormData();
878
895
  options = utils.toFlatObject(options, {
879
896
  metaTokens: true,
880
897
  dots: false,
@@ -887,7 +904,7 @@ var require_axios = __commonJS({
887
904
  const dots = options.dots;
888
905
  const indexes = options.indexes;
889
906
  const _Blob = options.Blob || typeof Blob !== "undefined" && Blob;
890
- const useBlob = _Blob && isSpecCompliant(formData);
907
+ const useBlob = _Blob && utils.isSpecCompliantForm(formData);
891
908
  if (!utils.isFunction(visitor)) {
892
909
  throw new TypeError("visitor must be a function");
893
910
  }
@@ -912,7 +929,7 @@ var require_axios = __commonJS({
912
929
  if (utils.endsWith(key, "{}")) {
913
930
  key = metaTokens ? key : key.slice(0, -2);
914
931
  value = JSON.stringify(value);
915
- } else if (utils.isArray(value) && isFlatArray(value) || (utils.isFileList(value) || utils.endsWith(key, "[]") && (arr = utils.toArray(value)))) {
932
+ } else if (utils.isArray(value) && isFlatArray(value) || (utils.isFileList(value) || utils.endsWith(key, "[]")) && (arr = utils.toArray(value))) {
916
933
  key = removeBrackets(key);
917
934
  arr.forEach(/* @__PURE__ */ __name(function each(el, index) {
918
935
  !(utils.isUndefined(el) || el === null) && formData.append(
@@ -1093,7 +1110,8 @@ var require_axios = __commonJS({
1093
1110
  clarifyTimeoutError: false
1094
1111
  };
1095
1112
  var URLSearchParams$1 = typeof URLSearchParams !== "undefined" ? URLSearchParams : AxiosURLSearchParams;
1096
- var FormData$1 = FormData;
1113
+ var FormData$1 = typeof FormData !== "undefined" ? FormData : null;
1114
+ var Blob$1 = typeof Blob !== "undefined" ? Blob : null;
1097
1115
  var isStandardBrowserEnv = (() => {
1098
1116
  let product;
1099
1117
  if (typeof navigator !== "undefined" && ((product = navigator.product) === "ReactNative" || product === "NativeScript" || product === "NS")) {
@@ -1110,7 +1128,7 @@ var require_axios = __commonJS({
1110
1128
  classes: {
1111
1129
  URLSearchParams: URLSearchParams$1,
1112
1130
  FormData: FormData$1,
1113
- Blob
1131
+ Blob: Blob$1
1114
1132
  },
1115
1133
  isStandardBrowserEnv,
1116
1134
  isStandardBrowserWebWorkerEnv,
@@ -1363,10 +1381,13 @@ var require_axios = __commonJS({
1363
1381
  return /^[-_a-zA-Z]+$/.test(str.trim());
1364
1382
  }
1365
1383
  __name(isValidHeaderName, "isValidHeaderName");
1366
- function matchHeaderValue(context, value, header, filter) {
1384
+ function matchHeaderValue(context, value, header, filter, isHeaderNameFilter) {
1367
1385
  if (utils.isFunction(filter)) {
1368
1386
  return filter.call(this, value, header);
1369
1387
  }
1388
+ if (isHeaderNameFilter) {
1389
+ value = header;
1390
+ }
1370
1391
  if (!utils.isString(value))
1371
1392
  return;
1372
1393
  if (utils.isString(filter)) {
@@ -1448,7 +1469,7 @@ var require_axios = __commonJS({
1448
1469
  header = normalizeHeader(header);
1449
1470
  if (header) {
1450
1471
  const key = utils.findKey(this, header);
1451
- return !!(key && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1472
+ return !!(key && this[key] !== void 0 && (!matcher || matchHeaderValue(this, this[key], key, matcher)));
1452
1473
  }
1453
1474
  return false;
1454
1475
  }
@@ -1473,8 +1494,18 @@ var require_axios = __commonJS({
1473
1494
  }
1474
1495
  return deleted;
1475
1496
  }
1476
- clear() {
1477
- return Object.keys(this).forEach(this.delete.bind(this));
1497
+ clear(matcher) {
1498
+ const keys = Object.keys(this);
1499
+ let i = keys.length;
1500
+ let deleted = false;
1501
+ while (i--) {
1502
+ const key = keys[i];
1503
+ if (!matcher || matchHeaderValue(this, this[key], key, matcher, true)) {
1504
+ delete this[key];
1505
+ deleted = true;
1506
+ }
1507
+ }
1508
+ return deleted;
1478
1509
  }
1479
1510
  normalize(format) {
1480
1511
  const self2 = this;
@@ -1541,7 +1572,7 @@ var require_axios = __commonJS({
1541
1572
  }
1542
1573
  };
1543
1574
  __name(AxiosHeaders, "AxiosHeaders");
1544
- AxiosHeaders.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent"]);
1575
+ AxiosHeaders.accessor(["Content-Type", "Content-Length", "Accept", "Accept-Encoding", "User-Agent", "Authorization"]);
1545
1576
  utils.freezeMethods(AxiosHeaders.prototype);
1546
1577
  utils.freezeMethods(AxiosHeaders);
1547
1578
  var AxiosHeaders$1 = AxiosHeaders;
@@ -1569,7 +1600,6 @@ var require_axios = __commonJS({
1569
1600
  utils.inherits(CanceledError, AxiosError, {
1570
1601
  __CANCEL__: true
1571
1602
  });
1572
- var httpAdapter = null;
1573
1603
  function settle(resolve, reject, response) {
1574
1604
  const validateStatus = response.config.validateStatus;
1575
1605
  if (!response.status || !validateStatus || validateStatus(response.status)) {
@@ -2056,7 +2086,7 @@ var require_axios = __commonJS({
2056
2086
  return config;
2057
2087
  }
2058
2088
  __name(mergeConfig, "mergeConfig");
2059
- var VERSION = "1.2.3";
2089
+ var VERSION = "1.3.4";
2060
2090
  var validators$1 = {};
2061
2091
  ["object", "boolean", "number", "function", "string", "symbol"].forEach((type, i) => {
2062
2092
  validators$1[type] = /* @__PURE__ */ __name(function validator2(thing) {
@@ -2537,6 +2567,10 @@ var require_Client = __commonJS({
2537
2567
  try {
2538
2568
  const expectedError = status >= 400 && status < 500;
2539
2569
  const newTokensNeeded = expectedError && errorType === "TokenExpiredError";
2570
+ if (expectedError && errorMessage === "Phone Verification is required") {
2571
+ this._onPhoneVerificationRequired();
2572
+ return Promise.reject(error);
2573
+ }
2540
2574
  if (expectedError && errorMessage === "Login Required") {
2541
2575
  this._onLoginRequired();
2542
2576
  return Promise.reject(error);
@@ -2577,6 +2611,9 @@ var require_Client = __commonJS({
2577
2611
  _onLoginRequired() {
2578
2612
  this.emit("LoginRequired");
2579
2613
  }
2614
+ _onPhoneVerificationRequired() {
2615
+ this.emit("PhoneVerificationRequired");
2616
+ }
2580
2617
  };
2581
2618
  __name(KohostApiClient, "KohostApiClient");
2582
2619
  module.exports = KohostApiClient;