@twilio/mcs-client 0.6.0-rc.9 → 0.6.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/builds/lib.js CHANGED
@@ -34,6 +34,7 @@ require('core-js/modules/es.string.starts-with.js');
34
34
  require('core-js/modules/es.array.reduce.js');
35
35
  require('core-js/modules/es.regexp.exec.js');
36
36
  require('core-js/modules/es.string.split.js');
37
+ require('core-js/modules/es.string.replace.js');
37
38
  require('core-js/modules/es.json.stringify.js');
38
39
  require('core-js/modules/es.object.assign.js');
39
40
  require('core-js/modules/web.url.js');
@@ -666,13 +667,13 @@ class Transport {
666
667
  return;
667
668
  }
668
669
 
669
- var headers = parseResponseHeaders(xhr.getAllResponseHeaders());
670
+ var responseHeaders = parseResponseHeaders(xhr.getAllResponseHeaders());
670
671
  var body = extractBody(xhr);
671
672
 
672
673
  if (200 <= xhr.status && xhr.status < 300) {
673
674
  resolve({
674
675
  status: xhr.status,
675
- headers,
676
+ headers: responseHeaders,
676
677
  body
677
678
  });
678
679
  } else {
@@ -682,13 +683,19 @@ class Transport {
682
683
  var bodyRepresentation;
683
684
 
684
685
  if (typeof body === "string") {
685
- bodyRepresentation = body && body.split("\n", 2).length === 1 ? body : "";
686
+ if (body && body.split("\n", 2).length === 1) bodyRepresentation = body;else {
687
+ var _body$replace$split$f;
688
+
689
+ // TODO: RTDSDK-3716: investigate why body is HTML string
690
+ var errorInfo = (_body$replace$split$f = body.replace(/<.*?>/g, "").split(/\r\n/g).filter(str => str.length)[0]) === null || _body$replace$split$f === void 0 ? void 0 : _body$replace$split$f.split(" ");
691
+ bodyRepresentation = (errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.length) > 2 ? errorInfo === null || errorInfo === void 0 ? void 0 : errorInfo.slice(1).join(" ") : "";
692
+ }
686
693
  } else {
687
694
  bodyRepresentation = JSON.stringify(body);
688
695
  }
689
696
 
690
697
  var message = "".concat(xhr.status, ": [").concat(status, "] ").concat(bodyRepresentation);
691
- reject(new TransportError(message, xhr.status, body, status, headers));
698
+ reject(new TransportError(message, xhr.status, body, status, responseHeaders));
692
699
  }
693
700
  };
694
701
 
@@ -953,7 +960,7 @@ class Network {
953
960
 
954
961
  }
955
962
 
956
- var version = "0.6.0-rc.9";
963
+ var version = "0.6.1";
957
964
 
958
965
  var _class;
959
966
  var log = Logger.scope("");