@eluvio/elv-client-js 4.2.22 → 4.2.23

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.
@@ -732,7 +732,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
732
732
  key: "GenerateChannelContentToken",
733
733
  value: function () {
734
734
  var _GenerateChannelContentToken = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref8) {
735
- var objectId, versionHash, issuer, code, email, audienceData, context, oauthToken, _ref8$value, value, token, tenantId, kmsAddress, stateChannelApi, additionalParams;
735
+ var objectId, versionHash, issuer, code, email, audienceData, context, oauthToken, _ref8$value, value, token, tenantId, kmsAddress, stateChannelApi, additionalParams, payload, signature, multiSig;
736
736
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
737
737
  while (1) switch (_context7.prev = _context7.next) {
738
738
  case 0:
@@ -828,7 +828,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
828
828
  case 40:
829
829
  // Pull target object from token so token can be cached
830
830
  objectId = JSON.parse(Utils.FromB64(token)).qid;
831
- _context7.next = 49;
831
+ _context7.next = 54;
832
832
  break;
833
833
  case 43:
834
834
  // State channel API
@@ -850,8 +850,14 @@ var AuthorizationClient = /*#__PURE__*/function () {
850
850
  additionalParams: additionalParams
851
851
  });
852
852
  case 48:
853
- token = _context7.sent;
854
- case 49:
853
+ payload = _context7.sent;
854
+ _context7.next = 51;
855
+ return this.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(payload)));
856
+ case 51:
857
+ signature = _context7.sent;
858
+ multiSig = Utils.FormatSignature(signature);
859
+ token = "".concat(payload, ".").concat(Utils.B64(multiSig));
860
+ case 54:
855
861
  if (!this.noCache) {
856
862
  this.channelContentTokens[objectId] = {
857
863
  token: token,
@@ -859,7 +865,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
859
865
  };
860
866
  }
861
867
  return _context7.abrupt("return", token);
862
- case 51:
868
+ case 56:
863
869
  case "end":
864
870
  return _context7.stop();
865
871
  }
@@ -1769,8 +1775,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
1769
1775
  throw Error("No KMS info set for ".concat(versionHash || objectId || "default KMS"));
1770
1776
  case 15:
1771
1777
  kmsHttpClient = new HttpClient({
1772
- uris: kmsUrls,
1773
- networkName: this.client.networkName
1778
+ uris: kmsUrls
1774
1779
  });
1775
1780
  _context24.next = 18;
1776
1781
  return kmsHttpClient.Request({
@@ -69,8 +69,7 @@ var ContentObjectAudit = {
69
69
  return s.indexOf(v) === i;
70
70
  });
71
71
  httpClient = new HttpClient({
72
- uris: uris,
73
- networkName: client.networkName
72
+ uris: uris
74
73
  });
75
74
  path = UrlJoin("qlibs", libraryId, "q", versionHash || objectId, live ? "call/live/audit" : "audit");
76
75
  _context.t4 = httpClient;
@@ -20,7 +20,6 @@ var HttpClient = require("./HttpClient");
20
20
  var RemoteSigner = require("./RemoteSigner");
21
21
  var Utils = require("./Utils");
22
22
  var Crypto = require("./Crypto");
23
- var NetworkUrls = require("./NetworkUrls");
24
23
  var _require = require("./LogMessage"),
25
24
  LogMessage = _require.LogMessage;
26
25
  var Pako = require("pako");
@@ -28,6 +27,13 @@ var _require2 = require("./Validation"),
28
27
  ValidatePresence = _require2.ValidatePresence,
29
28
  ValidateWriteToken = _require2.ValidateWriteToken;
30
29
  var UrlJoin = require("url-join");
30
+ var networks = {
31
+ "main": "https://main.net955305.contentfabric.io",
32
+ "demo": "https://demov3.net955210.contentfabric.io",
33
+ "demov3": "https://demov3.net955210.contentfabric.io",
34
+ "local": "http://127.0.0.1:8008/config?qspace=dev&self",
35
+ "test": "https://test.net955203.contentfabric.io"
36
+ };
31
37
  if (Utils.Platform() === Utils.PLATFORM_NODE) {
32
38
  // Define Response in node
33
39
  // eslint-disable-next-line no-global-assign
@@ -254,22 +260,18 @@ var ElvClient = /*#__PURE__*/function () {
254
260
  uris = this.service === "search" ? this.searchURIs : this.fabricURIs;
255
261
  this.HttpClient = new HttpClient({
256
262
  uris: uris,
257
- networkName: this.networkName,
258
263
  debug: this.debug
259
264
  });
260
265
  this.AuthHttpClient = new HttpClient({
261
266
  uris: this.authServiceURIs,
262
- networkName: this.networkName,
263
267
  debug: this.debug
264
268
  });
265
269
  this.FileServiceHttpClient = new HttpClient({
266
270
  uris: this.fileServiceURIs,
267
- networkName: this.networkName,
268
271
  debug: this.debug
269
272
  });
270
273
  this.SearchHttpClient = new HttpClient({
271
274
  uris: this.searchURIs || [],
272
- networkName: this.networkName,
273
275
  debug: this.debug
274
276
  });
275
277
  this.ethClient = new EthClient({
@@ -1487,7 +1489,6 @@ var ElvClient = /*#__PURE__*/function () {
1487
1489
  path = "/ks/jwt/wlt";
1488
1490
  httpClient = new HttpClient({
1489
1491
  uris: this.kmsURIs,
1490
- networkName: this.networkName,
1491
1492
  debug: this.debug
1492
1493
  });
1493
1494
  _context19.next = 22;
@@ -1724,24 +1725,11 @@ var ElvClient = /*#__PURE__*/function () {
1724
1725
  throw "Signer not set";
1725
1726
  case 3:
1726
1727
  ValidatePresence("message", message);
1727
- if (!this.signer.remoteSigner) {
1728
- _context23.next = 10;
1729
- break;
1730
- }
1731
- _context23.next = 7;
1732
- return this.signer.DecryptCap(message);
1733
- case 7:
1734
- _context23.t0 = _context23.sent;
1735
- _context23.next = 13;
1736
- break;
1737
- case 10:
1738
- _context23.next = 12;
1728
+ _context23.next = 6;
1739
1729
  return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
1740
- case 12:
1741
- _context23.t0 = _context23.sent;
1742
- case 13:
1743
- return _context23.abrupt("return", _context23.t0);
1744
- case 14:
1730
+ case 6:
1731
+ return _context23.abrupt("return", _context23.sent);
1732
+ case 7:
1745
1733
  case "end":
1746
1734
  return _context23.stop();
1747
1735
  }
@@ -2031,7 +2019,7 @@ var ElvClient = /*#__PURE__*/function () {
2031
2019
  }, {
2032
2020
  key: "Networks",
2033
2021
  value: function Networks() {
2034
- return Object.assign({}, NetworkUrls);
2022
+ return Object.assign({}, networks);
2035
2023
  }
2036
2024
 
2037
2025
  /**
@@ -2059,7 +2047,7 @@ var ElvClient = /*#__PURE__*/function () {
2059
2047
  while (1) switch (_context28.prev = _context28.next) {
2060
2048
  case 0:
2061
2049
  networkName = _ref31.networkName, region = _ref31.region, clientIP = _ref31.clientIP, trustAuthorityId = _ref31.trustAuthorityId, staticToken = _ref31.staticToken, _ref31$ethereumContra = _ref31.ethereumContractTimeout, ethereumContractTimeout = _ref31$ethereumContra === void 0 ? 10 : _ref31$ethereumContra, _ref31$noCache = _ref31.noCache, noCache = _ref31$noCache === void 0 ? false : _ref31$noCache, _ref31$noAuth = _ref31.noAuth, noAuth = _ref31$noAuth === void 0 ? false : _ref31$noAuth, assumeV3 = _ref31.assumeV3;
2062
- configUrl = this.Networks()[networkName];
2050
+ configUrl = networks[networkName];
2063
2051
  if (configUrl) {
2064
2052
  _context28.next = 4;
2065
2053
  break;
@@ -449,7 +449,7 @@ var FrameClient = /*#__PURE__*/function () {
449
449
  }, {
450
450
  key: "AllowedMethods",
451
451
  value: function AllowedMethods() {
452
- return ["AccessGroupManagers", "AccessGroupMembers", "AccessGroupOwner", "AccessInfo", "AccessRequest", "AccessType", "AddAccessGroupManager", "AddAccessGroupMember", "AddContentLibraryGroup", "AddContentObjectGroupPermission", "AddLibraryContentType", "AssetMetadata", "AuditContentObject", "AuditStream", "AvailableDRMs", "AvailableOfferings", "AwaitPending", "BitmovinPlayoutOptions", "BlockNumber", "CallBitcodeMethod", "CallContractMethod", "CallContractMethodAndWait", "ClearCache", "ClearStaticToken", "Collection", "CollectionTransactions", "ConfigUrl", "ContentLibraries", "ContentLibrary", "ContentLibraryGroupPermissions", "ContentLibraryOwner", "ContentObject", "ContentObjectAccessComplete", "ContentObjectGraph", "ContentObjectGroupPermissions", "ContentObjectImageUrl", "ContentObjectLibraryId", "ContentObjectMetadata", "ContentObjectOwner", "ContentObjectTenantId", "ContentObjectVersions", "ContentObjects", "ContentPart", "ContentParts", "ContentSpaceId", "ContentType", "ContentTypeOwner", "ContentTypes", "ContractAbi", "ContractEvents", "ContractInfo", "ContractMetadata", "ContractName", "CopyContentObject", "CreateABRMezzanine", "CreateAccessGroup", "CreateAndFinalizeContentObject", "CreateAuthorizationToken", "CreateContentLibrary", "CreateContentObject", "CreateContentType", "CreateEncryptionConk", "CreateFabricToken", "CreateFileDirectories", "CreateFileUploadJob", "CreateLinks", "CreateNTPInstance", "CreateNonOwnerCap", "CreatePart", "CreateProductionMaster", "CreateShare", "CreateSignedMessageJSON", "CreateSignedToken", "CreateStaticToken", "CurrentAccountAddress", "CustomContractAddress", "DecodeSignedMessageJSON", "Decrypt", "DecryptECIES", "DefaultKMSAddress", "DeleteAccessGroup", "DeleteContentLibrary", "DeleteContentObject", "DeleteContentVersion", "DeleteFiles", "DeleteMetadata", "DeleteNTPInstance", "DeletePart", "DeleteWriteToken", "DeployContract", "Download", "DownloadEncrypted", "DownloadFile", "DownloadPart", "EditAndFinalizeContentObject", "EditContentObject", "EmbedUrl", "Encrypt", "EncryptECIES", "EncryptionConk", "Events", "ExtractEventFromLogs", "ExtractValueFromEvent", "FabricUrl", "FileUrl", "FinalizeABRMezzanine", "FinalizeContentObject", "FinalizePart", "FinalizeStateChannelAccess", "FinalizeUploadJob", "FormatContractArguments", "GenerateStateChannelToken", "GenerateSignedLinkToken", "GetBalance", "GlobalUrl", "InitializeAuthPolicy", "IssueNTPCode", "IssueSignedNTPCode", "LatestVersionHash", "LibraryContentTypes", "LinkAccessGroupToOauth", "LinkData", "LinkTarget", "LinkUrl", "ListAccessGroups", "ListFiles", "ListNTPInstances", "LRODraftInfo", "LROStatus", "MakeAuthServiceRequest", "MakeFileServiceRequest", "MergeContractMetadata", "MergeMetadata", "MetadataAuth", "MintNFT", "MoveFiles", "NetworkInfo", "NodeId", "Nodes", "NTPInstance", "ObjectCleanup", "OutputsCreate", "OutputsDelete", "OutputsList", "OutputsListItem", "OutputsModify", "OutputsModifyBatch", "OutputsResolveSrtPullUrls", "OutputsState", "OutputsStop", "Permission", "PlayoutOptions", "PlayoutPathResolution", "ProduceMetadataLinks", "Proofs", "PublicRep", "PublishContentVersion", "QParts", "RecordWriteToken", "RedeemCode", "RedeemShareToken", "RemoveAccessGroupManager", "RemoveAccessGroupMember", "RemoveContentObjectGroupPermission", "RemoveContentLibraryGroup", "RemoveLibraryContentType", "Rep", "ReplaceContractMetadata", "ReplaceMetadata", "Request", "ResetRegion", "ResetTenantId", "RevokeShare", "SendFunds", "SetAccessCharge", "StreamApplyProfile", "SetAuth", "SetAuthContext", "SetAuthPolicy", "SetContentLibraryImage", "SetContentObjectImage", "SetCustomContentContract", "SetGroupPermission", "SetNodes", "SetOauthToken", "SetPolicyAuthorization", "SetSignerFromOauthToken", "SetStaticToken", "SetTenantContractId", "SetTenantId", "TenantAdminGroup", "ContentAdminGroup", "TenantUsersGroup", "SetVisibility", "SetPermission", "ShareInfo", "Shares", "SpaceNodes", "StartABRMezzanineJobs", "StreamAddWatermark", "StreamApplyProfile", "StreamAssignProfile", "StreamConfig", "StreamConfigProfile", "StreamConfigProfiles", "StreamCopyToVod", "StreamCreate", "StreamInitialize", "StreamInsertion", "StreamLinkToSite", "StreamListUrls", "StreamRemoveLinkToSite", "StreamRemoveWatermark", "StreamSaveConfigProfile", "StreamSetOfferingAndDRM", "StreamSiteSettings", "StreamStartRecording", "StreamStartOrStopOrReset", "StreamStatus", "StreamStopRecording", "StreamUnassignProfile", "StreamUpdateConfig", "SuspendNTPInstance", "TenantContractId", "TenantId", "UnlinkAccessGroupFromOauth", "UpdateContentObjectGraph", "UpdateNTPInstance", "UpdateShare", "UploadFileData", "UploadFilesFromS3", "UploadJobStatus", "UploadPart", "UploadPartChunk", "UploadStatus", "UseRegion", "Visibility", "WriteTokenNodeUrlLocal", "WriteTokenNodeUrlNetwork"];
452
+ return ["AccessGroupManagers", "AccessGroupMembers", "AccessGroupOwner", "AccessInfo", "AccessRequest", "AccessType", "AddAccessGroupManager", "AddAccessGroupMember", "AddContentLibraryGroup", "AddContentObjectGroupPermission", "AddLibraryContentType", "AssetMetadata", "AuditContentObject", "AuditStream", "AvailableDRMs", "AvailableOfferings", "AwaitPending", "BitmovinPlayoutOptions", "BlockNumber", "CallBitcodeMethod", "CallContractMethod", "CallContractMethodAndWait", "ClearCache", "ClearStaticToken", "Collection", "CollectionTransactions", "ConfigUrl", "ContentLibraries", "ContentLibrary", "ContentLibraryGroupPermissions", "ContentLibraryOwner", "ContentObject", "ContentObjectAccessComplete", "ContentObjectGraph", "ContentObjectGroupPermissions", "ContentObjectImageUrl", "ContentObjectLibraryId", "ContentObjectMetadata", "ContentObjectOwner", "ContentObjectTenantId", "ContentObjectVersions", "ContentObjects", "ContentPart", "ContentParts", "ContentSpaceId", "ContentType", "ContentTypeOwner", "ContentTypes", "ContractAbi", "ContractEvents", "ContractInfo", "ContractMetadata", "ContractName", "CopyContentObject", "CreateABRMezzanine", "CreateAccessGroup", "CreateAndFinalizeContentObject", "CreateAuthorizationToken", "CreateContentLibrary", "CreateContentObject", "CreateContentType", "CreateEncryptionConk", "CreateFabricToken", "CreateFileDirectories", "CreateFileUploadJob", "CreateLinks", "CreateNTPInstance", "CreateNonOwnerCap", "CreatePart", "CreateProductionMaster", "CreateShare", "CreateSignedMessageJSON", "CreateSignedToken", "CreateStaticToken", "CurrentAccountAddress", "CustomContractAddress", "DecodeSignedMessageJSON", "Decrypt", "DecryptECIES", "DefaultKMSAddress", "DeleteAccessGroup", "DeleteContentLibrary", "DeleteContentObject", "DeleteContentVersion", "DeleteFiles", "DeleteMetadata", "DeleteNTPInstance", "DeletePart", "DeleteWriteToken", "DeployContract", "Download", "DownloadEncrypted", "DownloadFile", "DownloadPart", "EditAndFinalizeContentObject", "EditContentObject", "EmbedUrl", "Encrypt", "EncryptECIES", "EncryptionConk", "Events", "ExtractEventFromLogs", "ExtractValueFromEvent", "FabricUrl", "FileUrl", "FinalizeABRMezzanine", "FinalizeContentObject", "FinalizePart", "FinalizeStateChannelAccess", "FinalizeUploadJob", "FormatContractArguments", "GenerateStateChannelToken", "GenerateSignedLinkToken", "GetBalance", "GlobalUrl", "InitializeAuthPolicy", "IssueNTPCode", "IssueSignedNTPCode", "LatestVersionHash", "LibraryContentTypes", "LinkAccessGroupToOauth", "LinkData", "LinkTarget", "LinkUrl", "ListAccessGroups", "ListFiles", "ListNTPInstances", "LRODraftInfo", "LROStatus", "MakeAuthServiceRequest", "MakeFileServiceRequest", "MergeContractMetadata", "MergeMetadata", "MetadataAuth", "MintNFT", "MoveFiles", "NetworkInfo", "NodeId", "Nodes", "NTPInstance", "ObjectCleanup", "Permission", "PlayoutOptions", "PlayoutPathResolution", "ProduceMetadataLinks", "Proofs", "PublicRep", "PublishContentVersion", "QParts", "RecordWriteToken", "RedeemCode", "RedeemShareToken", "RemoveAccessGroupManager", "RemoveAccessGroupMember", "RemoveContentObjectGroupPermission", "RemoveContentLibraryGroup", "RemoveLibraryContentType", "Rep", "ReplaceContractMetadata", "ReplaceMetadata", "Request", "ResetRegion", "ResetTenantId", "RevokeShare", "SendFunds", "SetAccessCharge", "SetAuth", "SetAuthContext", "SetAuthPolicy", "SetContentLibraryImage", "SetContentObjectImage", "SetCustomContentContract", "SetGroupPermission", "SetNodes", "SetOauthToken", "SetPolicyAuthorization", "SetSignerFromOauthToken", "SetStaticToken", "SetTenantContractId", "SetTenantId", "TenantAdminGroup", "ContentAdminGroup", "TenantUsersGroup", "SetVisibility", "SetPermission", "ShareInfo", "Shares", "SpaceNodes", "StartABRMezzanineJobs", "StreamAddWatermark", "StreamConfig", "StreamCopyToVod", "StreamCreate", "StreamInitialize", "StreamInsertion", "StreamListUrls", "StreamRemoveWatermark", "StreamSetOfferingAndDRM", "StreamStatus", "StreamStartOrStopOrReset", "StreamStopSession", "SuspendNTPInstance", "TenantContractId", "TenantId", "UnlinkAccessGroupFromOauth", "UpdateContentObjectGraph", "UpdateNTPInstance", "UpdateShare", "UploadFileData", "UploadFilesFromS3", "UploadJobStatus", "UploadPart", "UploadPartChunk", "UploadStatus", "UseRegion", "Visibility", "WriteTokenNodeUrlLocal", "WriteTokenNodeUrlNetwork"];
453
453
  }
454
454
  }, {
455
455
  key: "AllowedUserProfileMethods",
@@ -7,21 +7,17 @@ var _Fetch = typeof fetch !== "undefined" ? fetch : require("node-fetch")["defau
7
7
  var _require = require("./LogMessage"),
8
8
  LogMessage = _require.LogMessage;
9
9
  var Utils = require("./Utils");
10
- var UrlJoin = require("url-join");
11
- var NetworkUrls = require("./NetworkUrls");
12
10
  var HttpClient = /*#__PURE__*/function () {
13
11
  "use strict";
14
12
 
15
13
  function HttpClient(_ref) {
16
14
  var uris = _ref.uris,
17
- networkName = _ref.networkName,
18
15
  debug = _ref.debug;
19
16
  _classCallCheck(this, HttpClient);
20
17
  this.uris = uris;
21
18
  this.uriIndex = 0;
22
19
  this.debug = debug;
23
20
  this.draftURIs = {};
24
- this.networkName = networkName;
25
21
  this.retries = Math.max(3, uris.length);
26
22
  }
27
23
  _createClass(HttpClient, [{
@@ -71,7 +67,7 @@ var HttpClient = /*#__PURE__*/function () {
71
67
  key: "Request",
72
68
  value: function () {
73
69
  var _Request = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref3) {
74
- var method, path, _ref3$queryParams, queryParams, body, _ref3$bodyType, bodyType, _ref3$headers, headers, _ref3$attempts, attempts, _ref3$allowFailover, allowFailover, _ref3$forceFailover, forceFailover, _ref3$allowRetry, allowRetry, uriIndex, baseURI, writeTokenMatch, writeToken, configUrl, uri, fetchParameters, response, responseType, errorBody, error;
70
+ var method, path, _ref3$queryParams, queryParams, body, _ref3$bodyType, bodyType, _ref3$headers, headers, _ref3$attempts, attempts, _ref3$allowFailover, allowFailover, _ref3$forceFailover, forceFailover, _ref3$allowRetry, allowRetry, uriIndex, baseURI, writeTokenMatch, writeToken, uri, fetchParameters, response, responseType, errorBody, error;
75
71
  return _regeneratorRuntime.wrap(function _callee$(_context) {
76
72
  while (1) switch (_context.prev = _context.next) {
77
73
  case 0:
@@ -79,55 +75,16 @@ var HttpClient = /*#__PURE__*/function () {
79
75
  baseURI = this.BaseURI(uriIndex); // If URL contains a write token, it must go to the correct server and can not fail over
80
76
  writeTokenMatch = path.replace(/^\//, "").match(/(qlibs\/ilib[a-zA-Z0-9]+|q|qid)\/(tqw__[a-zA-Z0-9]+)/);
81
77
  writeToken = writeTokenMatch ? writeTokenMatch[2] : undefined;
82
- if (!writeToken) {
83
- _context.next = 30;
84
- break;
85
- }
86
- allowFailover = false;
87
- if (!this.draftURIs[writeToken]) {
88
- _context.next = 10;
89
- break;
90
- }
91
- // Use saved write token URI
92
- baseURI = this.draftURIs[writeToken];
93
- _context.next = 29;
94
- break;
95
- case 10:
96
- if (!this.networkName) {
97
- _context.next = 28;
98
- break;
99
- }
100
- _context.prev = 11;
101
- configUrl = new URL(NetworkUrls[this.networkName]);
102
- configUrl.pathname = UrlJoin("/s", this.networkName, "nodes");
103
- configUrl.searchParams.set("token", writeToken);
104
- _context.t0 = URI;
105
- _context.next = 18;
106
- return fetch(configUrl);
107
- case 18:
108
- _context.next = 20;
109
- return _context.sent.json();
110
- case 20:
111
- _context.t1 = _context.sent.nodes[0].services.fabric_api.urls[0];
112
- baseURI = new _context.t0(_context.t1);
113
- _context.next = 28;
114
- break;
115
- case 24:
116
- _context.prev = 24;
117
- _context.t2 = _context["catch"](11);
118
- this.Log("Failed to retrieve write token node for " + writeToken);
119
- this.Log(_context.t2);
120
- case 28:
121
- // Save current URI for all future requests involving this write token
122
- this.draftURIs[writeToken] = baseURI;
123
- case 29:
124
- // If write token is present in headers, we may get redirected even if we try and use the right node.
125
- // When a network request is redirected, the authorization header is dropped, which will cause issues.
126
- // Ensure it is present in query params as well
127
- if ((headers.Authorization || headers.authorization) && !queryParams.authorization) {
128
- queryParams.authorization = headers.Authorization || headers.authorization;
78
+ if (writeToken) {
79
+ allowFailover = false;
80
+ if (this.draftURIs[writeToken]) {
81
+ // Use saved write token URI
82
+ baseURI = this.draftURIs[writeToken];
83
+ } else {
84
+ // Save current URI for all future requests involving this write token
85
+ this.draftURIs[writeToken] = baseURI;
86
+ }
129
87
  }
130
- case 30:
131
88
  uri = baseURI.path(path).query(queryParams).hash("");
132
89
  fetchParameters = {
133
90
  method: method,
@@ -144,50 +101,50 @@ var HttpClient = /*#__PURE__*/function () {
144
101
  this.Log("".concat(method, " - ").concat(uri.toString()));
145
102
  this.Log("fetchParameters: ".concat(JSON.stringify(fetchParameters, null, 2)));
146
103
  }
147
- _context.prev = 34;
148
- _context.next = 37;
104
+ _context.prev = 9;
105
+ _context.next = 12;
149
106
  return HttpClient.Fetch(uri.toString(), fetchParameters);
150
- case 37:
107
+ case 12:
151
108
  response = _context.sent;
152
- _context.next = 43;
109
+ _context.next = 18;
153
110
  break;
154
- case 40:
155
- _context.prev = 40;
156
- _context.t3 = _context["catch"](34);
111
+ case 15:
112
+ _context.prev = 15;
113
+ _context.t0 = _context["catch"](9);
157
114
  response = {
158
115
  ok: false,
159
- status: _context.t3 && _context.t3.status || 500,
160
- statusText: "ElvClient Error: " + _context.t3.message,
116
+ status: _context.t0 && _context.t0.status || 500,
117
+ statusText: "ElvClient Error: " + _context.t0.message,
161
118
  url: uri.toString(),
162
- error: _context.t3
119
+ error: _context.t0
163
120
  };
164
- case 43:
121
+ case 18:
165
122
  if (response.ok) {
166
- _context.next = 72;
123
+ _context.next = 47;
167
124
  break;
168
125
  }
169
126
  if (!((parseInt(response.status) >= 500 || forceFailover) && allowRetry && attempts < this.retries)) {
170
- _context.next = 56;
127
+ _context.next = 31;
171
128
  break;
172
129
  }
173
130
  if (!allowFailover) {
174
- _context.next = 50;
131
+ _context.next = 25;
175
132
  break;
176
133
  }
177
134
  // Fail over to alternate node
178
135
  this.uriIndex = (this.uriIndex + 1) % this.uris.length;
179
136
  this.Log("HttpClient failing over from ".concat(baseURI.toString(), ": ").concat(attempts + 1, " attempts"), true);
180
- _context.next = 53;
137
+ _context.next = 28;
181
138
  break;
182
- case 50:
139
+ case 25:
183
140
  // Wait and retry
184
141
  this.Log("HttpClient retrying request from ".concat(baseURI.toString(), ": ").concat(attempts + 1, " attempts"), true);
185
- _context.next = 53;
142
+ _context.next = 28;
186
143
  return new Promise(function (resolve) {
187
144
  return setTimeout(resolve, 1000);
188
145
  });
189
- case 53:
190
- _context.next = 55;
146
+ case 28:
147
+ _context.next = 30;
191
148
  return this.Request({
192
149
  method: method,
193
150
  path: path,
@@ -199,34 +156,34 @@ var HttpClient = /*#__PURE__*/function () {
199
156
  uriIndex: uriIndex,
200
157
  forceFailover: forceFailover
201
158
  });
202
- case 55:
159
+ case 30:
203
160
  return _context.abrupt("return", _context.sent);
204
- case 56:
161
+ case 31:
205
162
  // Parse JSON error if headers indicate JSON
206
163
  responseType = response.headers ? response.headers.get("content-type") || "" : "";
207
164
  errorBody = "";
208
165
  if (!(response.text && response.json)) {
209
- _context.next = 69;
166
+ _context.next = 44;
210
167
  break;
211
168
  }
212
169
  if (!responseType.includes("application/json")) {
213
- _context.next = 65;
170
+ _context.next = 40;
214
171
  break;
215
172
  }
216
- _context.next = 62;
173
+ _context.next = 37;
217
174
  return response.json();
218
- case 62:
219
- _context.t4 = _context.sent;
220
- _context.next = 68;
175
+ case 37:
176
+ _context.t1 = _context.sent;
177
+ _context.next = 43;
221
178
  break;
222
- case 65:
223
- _context.next = 67;
179
+ case 40:
180
+ _context.next = 42;
224
181
  return response.text();
225
- case 67:
226
- _context.t4 = _context.sent;
227
- case 68:
228
- errorBody = _context.t4;
229
- case 69:
182
+ case 42:
183
+ _context.t1 = _context.sent;
184
+ case 43:
185
+ errorBody = _context.t1;
186
+ case 44:
230
187
  error = {
231
188
  name: "ElvHttpClientError",
232
189
  status: response.status,
@@ -239,14 +196,14 @@ var HttpClient = /*#__PURE__*/function () {
239
196
  };
240
197
  if (this.debug) this.Log(JSON.stringify(error, null, 2), true);
241
198
  throw error;
242
- case 72:
199
+ case 47:
243
200
  this.Log("".concat(response.status, " - ").concat(method, " ").concat(uri.toString()));
244
201
  return _context.abrupt("return", response);
245
- case 74:
202
+ case 49:
246
203
  case "end":
247
204
  return _context.stop();
248
205
  }
249
- }, _callee, this, [[11, 24], [34, 40]]);
206
+ }, _callee, this, [[9, 15]]);
250
207
  }));
251
208
  function Request(_x) {
252
209
  return _Request.apply(this, arguments);