@eluvio/elv-client-js 4.0.17 → 4.0.19

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.
@@ -422,7 +422,7 @@ var FrameClient = /*#__PURE__*/function () {
422
422
  }, {
423
423
  key: "FileMethods",
424
424
  value: function FileMethods() {
425
- return ["DownloadFile", "DownloadPart", "UpdateContentObjectGraph", "UploadFiles", "UploadFilesFromS3", "UploadPart", "UploadPartChunk"];
425
+ return ["CreateFileUploadJob", "DownloadEncrypted", "DownloadFile", "DownloadPart", "FinalizeUploadJob", "UpdateContentObjectGraph", "UploadFileData", "UploadFiles", "UploadFilesFromS3", "UploadJobStatus", "UploadPart", "UploadPartChunk", "UploadStatus"];
426
426
  }
427
427
  }]);
428
428
  return FrameClient;
@@ -558,8 +558,10 @@ exports.UploadFiles = /*#__PURE__*/function () {
558
558
  return function UploadJob(_x4, _x5) {
559
559
  return _ref8.apply(this, arguments);
560
560
  };
561
- }(); // Preparing jobs is done asyncronously
562
- PrepareJobs();
561
+ }(); // Preparing jobs is done asynchronously
562
+ PrepareJobs()["catch"](function (e) {
563
+ throw e;
564
+ });
563
565
 
564
566
  // Upload the first several chunks in sequence, to determine average upload rate
565
567
  rateTestJobs = Math.min(3, jobs.length);
@@ -768,7 +770,7 @@ exports.UploadJobStatus = /*#__PURE__*/function () {
768
770
  }();
769
771
  exports.UploadFileData = /*#__PURE__*/function () {
770
772
  var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref16) {
771
- var libraryId, objectId, writeToken, uploadId, jobId, fileData, path;
773
+ var libraryId, objectId, writeToken, uploadId, jobId, fileData, retries, jobStatus, path;
772
774
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
773
775
  while (1) switch (_context10.prev = _context10.next) {
774
776
  case 0:
@@ -778,6 +780,29 @@ exports.UploadFileData = /*#__PURE__*/function () {
778
780
  objectId: objectId
779
781
  });
780
782
  ValidateWriteToken(writeToken);
783
+ retries = 0;
784
+ case 4:
785
+ _context10.prev = 4;
786
+ _context10.next = 7;
787
+ return this.UploadJobStatus({
788
+ libraryId: libraryId,
789
+ objectId: objectId,
790
+ writeToken: writeToken,
791
+ uploadId: uploadId,
792
+ jobId: jobId
793
+ });
794
+ case 7:
795
+ jobStatus = _context10.sent;
796
+ if (!(jobStatus.rem === 0)) {
797
+ _context10.next = 12;
798
+ break;
799
+ }
800
+ return _context10.abrupt("return");
801
+ case 12:
802
+ if (jobStatus.skip) {
803
+ fileData = fileData.slice(jobStatus.skip);
804
+ }
805
+ case 13:
781
806
  path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
782
807
  _context10.t0 = this.utils;
783
808
  _context10.t1 = this.HttpClient;
@@ -787,13 +812,13 @@ exports.UploadFileData = /*#__PURE__*/function () {
787
812
  _context10.t5 = {
788
813
  "Content-type": "application/octet-stream"
789
814
  };
790
- _context10.next = 12;
815
+ _context10.next = 22;
791
816
  return this.authClient.AuthorizationHeader({
792
817
  libraryId: libraryId,
793
818
  objectId: objectId,
794
819
  update: true
795
820
  });
796
- case 12:
821
+ case 22:
797
822
  _context10.t6 = _context10.sent;
798
823
  _context10.t7 = (0, _context10.t4)(_context10.t5, _context10.t6);
799
824
  _context10.t8 = {
@@ -805,13 +830,35 @@ exports.UploadFileData = /*#__PURE__*/function () {
805
830
  failover: false
806
831
  };
807
832
  _context10.t9 = _context10.t1.Request.call(_context10.t1, _context10.t8);
808
- _context10.next = 18;
833
+ _context10.next = 28;
809
834
  return _context10.t0.ResponseToJson.call(_context10.t0, _context10.t9);
810
- case 18:
835
+ case 28:
836
+ return _context10.abrupt("return", _context10.sent);
837
+ case 31:
838
+ _context10.prev = 31;
839
+ _context10.t10 = _context10["catch"](4);
840
+ this.Log(_context10.t10, true);
841
+ retries += 1;
842
+ if (!(retries >= 5)) {
843
+ _context10.next = 37;
844
+ break;
845
+ }
846
+ throw _context10.t10;
847
+ case 37:
848
+ _context10.next = 39;
849
+ return new Promise(function (resolve) {
850
+ return setTimeout(resolve, 10 * retries * 1000);
851
+ });
852
+ case 39:
853
+ if (retries < 5) {
854
+ _context10.next = 4;
855
+ break;
856
+ }
857
+ case 40:
811
858
  case "end":
812
859
  return _context10.stop();
813
860
  }
814
- }, _callee10, this);
861
+ }, _callee10, this, [[4, 31]]);
815
862
  }));
816
863
  return function (_x11) {
817
864
  return _ref17.apply(this, arguments);
@@ -2228,8 +2228,22 @@ exports.DropStatus = /*#__PURE__*/function () {
2228
2228
  }();
2229
2229
 
2230
2230
  /* OFFERS */
2231
- // TODO: Document
2232
2231
 
2232
+ /**
2233
+ * Retrieve offers for the specified parameters
2234
+ *
2235
+ * @methodGroup Offers
2236
+ * @namedParams
2237
+ * @param {string=} contractAddress - The address of an NFT contract
2238
+ * @param {string=} tokenId - The token ID of an NFT
2239
+ * @param {string=} buyerAddress - The address of the offerrer
2240
+ * @param {string=} sellerAddress - The address of the offerree
2241
+ * @param {Array<String>=} statuses - Status to filter results by. Allowed values: "ACTIVE", "ACCEPTED", "CANCELLED", "DECLINED", "INVALID"
2242
+ * @param {number} start=0 - The index to start from
2243
+ * @param {number=} limit=10 - The maximum number of results to return
2244
+ *
2245
+ * @returns {Promise<Array<Object>>} - Offers matching the specified filters
2246
+ */
2233
2247
  exports.MarketplaceOffers = /*#__PURE__*/function () {
2234
2248
  var _ref82 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee41(_ref81) {
2235
2249
  var contractAddress, tokenId, buyerAddress, sellerAddress, statuses, _ref81$start, start, _ref81$limit, limit, path, queryParams, offers;
@@ -2281,6 +2295,22 @@ exports.MarketplaceOffers = /*#__PURE__*/function () {
2281
2295
  return _ref82.apply(this, arguments);
2282
2296
  };
2283
2297
  }();
2298
+
2299
+ /**
2300
+ * <b><i>Requires login</i></b>
2301
+ *
2302
+ * Create or update an offer on the specified NFT
2303
+ *
2304
+ * @methodGroup Offers
2305
+ * @namedParams
2306
+ * @param {string} contractAddress - The contract address of the NFT
2307
+ * @param {string} tokenId - The token ID of the NFT
2308
+ * @param {string=} offerId - IF modifying an existing offer, the ID of the offer
2309
+ * @param {number} price - The amount to offer
2310
+ * @param {number=} expiresAt - The time (in epoch ms) the offer will expire
2311
+ *
2312
+ * @returns {Promise<Object>} - Info about the created/updated offer
2313
+ */
2284
2314
  exports.CreateMarketplaceOffer = /*#__PURE__*/function () {
2285
2315
  var _ref84 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee42(_ref83) {
2286
2316
  var contractAddress, tokenId, offerId, price, expiresAt, response;
@@ -2337,6 +2367,16 @@ exports.CreateMarketplaceOffer = /*#__PURE__*/function () {
2337
2367
  return _ref84.apply(this, arguments);
2338
2368
  };
2339
2369
  }();
2370
+
2371
+ /**
2372
+ * <b><i>Requires login</i></b>
2373
+ *
2374
+ * Cancel the specified offer
2375
+ *
2376
+ * @methodGroup Offers
2377
+ * @namedParams
2378
+ * @param {string} offerId - The ID of the offer
2379
+ */
2340
2380
  exports.RemoveMarketplaceOffer = /*#__PURE__*/function () {
2341
2381
  var _ref86 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee43(_ref85) {
2342
2382
  var offerId;
@@ -2364,6 +2404,16 @@ exports.RemoveMarketplaceOffer = /*#__PURE__*/function () {
2364
2404
  return _ref86.apply(this, arguments);
2365
2405
  };
2366
2406
  }();
2407
+
2408
+ /**
2409
+ * <b><i>Requires login</i></b>
2410
+ *
2411
+ * Accept the specified offer
2412
+ *
2413
+ * @methodGroup Offers
2414
+ * @namedParams
2415
+ * @param {string} offerId - The ID of the offer
2416
+ */
2367
2417
  exports.AcceptMarketplaceOffer = /*#__PURE__*/function () {
2368
2418
  var _ref88 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee44(_ref87) {
2369
2419
  var offerId;
@@ -2391,6 +2441,16 @@ exports.AcceptMarketplaceOffer = /*#__PURE__*/function () {
2391
2441
  return _ref88.apply(this, arguments);
2392
2442
  };
2393
2443
  }();
2444
+
2445
+ /**
2446
+ * <b><i>Requires login</i></b>
2447
+ *
2448
+ * Reject the specified offer
2449
+ *
2450
+ * @methodGroup Offers
2451
+ * @namedParams
2452
+ * @param {string} offerId - The ID of the offer
2453
+ */
2394
2454
  exports.RejectMarketplaceOffer = /*#__PURE__*/function () {
2395
2455
  var _ref90 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee45(_ref89) {
2396
2456
  var offerId;
@@ -2417,4 +2477,125 @@ exports.RejectMarketplaceOffer = /*#__PURE__*/function () {
2417
2477
  return function (_x31) {
2418
2478
  return _ref90.apply(this, arguments);
2419
2479
  };
2480
+ }();
2481
+
2482
+ /* Voting */
2483
+
2484
+ /**
2485
+ * Retrieve the current status of the specified voting event
2486
+ *
2487
+ * @methodGroup Voting
2488
+ * @namedParams
2489
+ * @param {string} tenantId - The tenant ID of the marketplace in which the voting event is specified
2490
+ * @param {string} votingEventId - The ID of the voting event
2491
+ *
2492
+ * @returns {Promise<Object>} - Info about the voting event, including the current user's votes and the current total voting tally
2493
+ */
2494
+ exports.VoteStatus = /*#__PURE__*/function () {
2495
+ var _ref92 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee46(_ref91) {
2496
+ var tenantId, votingEventId;
2497
+ return _regeneratorRuntime.wrap(function _callee46$(_context46) {
2498
+ while (1) switch (_context46.prev = _context46.next) {
2499
+ case 0:
2500
+ tenantId = _ref91.tenantId, votingEventId = _ref91.votingEventId;
2501
+ _context46.next = 3;
2502
+ return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
2503
+ path: UrlJoin("as", "votes", tenantId, votingEventId),
2504
+ headers: {
2505
+ Authorization: "Bearer ".concat(this.AuthToken())
2506
+ }
2507
+ }));
2508
+ case 3:
2509
+ return _context46.abrupt("return", _context46.sent);
2510
+ case 4:
2511
+ case "end":
2512
+ return _context46.stop();
2513
+ }
2514
+ }, _callee46, this);
2515
+ }));
2516
+ return function (_x32) {
2517
+ return _ref92.apply(this, arguments);
2518
+ };
2519
+ }();
2520
+
2521
+ /**
2522
+ * <b><i>Requires login</i></b>
2523
+ *
2524
+ * Cast a vote for the specified item in the specified voting event
2525
+ *
2526
+ * @methodGroup Voting
2527
+ * @namedParams
2528
+ * @param {string} tenantId - The tenant ID of the marketplace in which the voting event is specified
2529
+ * @param {string} votingEventId - The ID of the voting event
2530
+ * @param {string} sku - The SKU of the item to vote for
2531
+ *
2532
+ * @returns {Promise<Object>} - Info about the voting event, including the current user's votes and the current total voting tally
2533
+ */
2534
+ exports.CastVote = /*#__PURE__*/function () {
2535
+ var _ref94 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee47(_ref93) {
2536
+ var tenantId, votingEventId, sku;
2537
+ return _regeneratorRuntime.wrap(function _callee47$(_context47) {
2538
+ while (1) switch (_context47.prev = _context47.next) {
2539
+ case 0:
2540
+ tenantId = _ref93.tenantId, votingEventId = _ref93.votingEventId, sku = _ref93.sku;
2541
+ _context47.next = 3;
2542
+ return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
2543
+ path: UrlJoin("as", "votes", tenantId, votingEventId, sku),
2544
+ method: "POST",
2545
+ headers: {
2546
+ Authorization: "Bearer ".concat(this.AuthToken())
2547
+ }
2548
+ }));
2549
+ case 3:
2550
+ return _context47.abrupt("return", _context47.sent);
2551
+ case 4:
2552
+ case "end":
2553
+ return _context47.stop();
2554
+ }
2555
+ }, _callee47, this);
2556
+ }));
2557
+ return function (_x33) {
2558
+ return _ref94.apply(this, arguments);
2559
+ };
2560
+ }();
2561
+
2562
+ /**
2563
+ * <b><i>Requires login</i></b>
2564
+ *
2565
+ * Revoke a previously cast vote for the specified item in the specified voting event
2566
+ *
2567
+ * @methodGroup Voting
2568
+ * @namedParams
2569
+ * @param {string} tenantId - The tenant ID of the marketplace in which the voting event is specified
2570
+ * @param {string} votingEventId - The ID of the voting event
2571
+ * @param {string} sku - The SKU of the item to vote for
2572
+ *
2573
+ * @returns {Promise<Object>} - Info about the voting event, including the current user's votes and the current total voting tally
2574
+ */
2575
+ exports.RevokeVote = /*#__PURE__*/function () {
2576
+ var _ref96 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee48(_ref95) {
2577
+ var tenantId, votingEventId, sku;
2578
+ return _regeneratorRuntime.wrap(function _callee48$(_context48) {
2579
+ while (1) switch (_context48.prev = _context48.next) {
2580
+ case 0:
2581
+ tenantId = _ref95.tenantId, votingEventId = _ref95.votingEventId, sku = _ref95.sku;
2582
+ _context48.next = 3;
2583
+ return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
2584
+ path: UrlJoin("as", "votes", tenantId, votingEventId, sku),
2585
+ method: "DELETE",
2586
+ headers: {
2587
+ Authorization: "Bearer ".concat(this.AuthToken())
2588
+ }
2589
+ }));
2590
+ case 3:
2591
+ return _context48.abrupt("return", _context48.sent);
2592
+ case 4:
2593
+ case "end":
2594
+ return _context48.stop();
2595
+ }
2596
+ }, _callee48, this);
2597
+ }));
2598
+ return function (_x34) {
2599
+ return _ref96.apply(this, arguments);
2600
+ };
2420
2601
  }();
@@ -2,6 +2,7 @@ var WalletConfiguration = {
2
2
  demo: {
3
3
  configUrl: "https://demov3.net955210.contentfabric.io/config",
4
4
  stateStoreUrls: ["https://appsvc.svc.eluv.io/dv3"],
5
+ badgerAddress: "0x39e9d567137217e8f7dae73bf168db28d242bb31",
5
6
  staging: {
6
7
  siteLibraryId: "ilib36Wi5fJDLXix8ckL7ZfaAJwJXWGD",
7
8
  siteId: "iq__2gkNh8CCZqFFnoRpEUmz7P3PaBQG",
@@ -12,6 +13,7 @@ var WalletConfiguration = {
12
13
  main: {
13
14
  configUrl: "https://main.net955305.contentfabric.io/config",
14
15
  stateStoreUrls: ["https://appsvc.svc.eluv.io/main"],
16
+ badgerAddress: "0xa042a585bbbac4419ba39c397f35ab749fc470f0",
15
17
  staging: {
16
18
  siteLibraryId: "ilib2GdaYEFxB7HyLPhSDPKMyPLhV8x9",
17
19
  siteId: "iq__inauxD1KLyKWPHargCWjdCh2ayr",
@@ -1,6 +1,9 @@
1
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
1
2
  var _typeof = require("@babel/runtime/helpers/typeof");
2
3
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
3
4
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
5
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
6
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
4
7
  var Utils = require("../Utils");
5
8
  var UrlJoin = require("url-join");
6
9
  var StateStorePath = function StateStorePath(_ref) {
@@ -186,7 +189,7 @@ exports.RemoveProfileMetadata = /*#__PURE__*/function () {
186
189
  }();
187
190
 
188
191
  /**
189
- * Retrieve profile info for the specified user, including address, username and profile image (if set)
192
+ * Retrieve profile info for the specified user, including address, username, profile image (if set) and badges (if any)
190
193
  *
191
194
  * @methodGroup Profile
192
195
  * @param {string=} userAddress - Address of the user
@@ -196,7 +199,7 @@ exports.RemoveProfileMetadata = /*#__PURE__*/function () {
196
199
  */
197
200
  exports.Profile = /*#__PURE__*/function () {
198
201
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref9) {
199
- var userAddress, userName, imageUrl;
202
+ var userAddress, userName, imageUrl, badgeData, badges;
200
203
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
201
204
  while (1) switch (_context4.prev = _context4.next) {
202
205
  case 0:
@@ -239,12 +242,37 @@ exports.Profile = /*#__PURE__*/function () {
239
242
  });
240
243
  case 13:
241
244
  imageUrl = _context4.sent;
245
+ _context4.next = 16;
246
+ return this.ProfileMetadata({
247
+ type: "app",
248
+ mode: "public",
249
+ appId: "elv-badge-srv",
250
+ userAddress: this.badgerAddress,
251
+ key: "badges_".concat(Utils.FormatAddress(userAddress))
252
+ });
253
+ case 16:
254
+ badgeData = _context4.sent;
255
+ badges = [];
256
+ if (badgeData) {
257
+ try {
258
+ badgeData = JSON.parse(badgeData).badges;
259
+ badges = Object.keys(badgeData).map(function (badgeName) {
260
+ return _objectSpread(_objectSpread({}, badgeData[badgeName]), {}, {
261
+ name: badgeName
262
+ });
263
+ });
264
+ } catch (error) {
265
+ this.Log("Failed to load badge info for ".concat(userName || userAddress), true);
266
+ this.Log(error, true);
267
+ }
268
+ }
242
269
  return _context4.abrupt("return", {
243
270
  userAddress: Utils.FormatAddress(userAddress),
244
271
  userName: userName,
245
- imageUrl: imageUrl
272
+ imageUrl: imageUrl,
273
+ badges: badges
246
274
  });
247
- case 15:
275
+ case 20:
248
276
  case "end":
249
277
  return _context4.stop();
250
278
  }
@@ -69,6 +69,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
69
69
  this.stateStoreClient = new HTTPClient({
70
70
  uris: this.stateStoreUrls
71
71
  });
72
+ this.badgerAddress = Configuration[network].badgerAddress;
72
73
 
73
74
  // Caches
74
75
  this.cachedMarketplaces = {};
@@ -1018,7 +1019,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1018
1019
  value: function () {
1019
1020
  var _LoadMarketplace = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(marketplaceParams) {
1020
1021
  var _this5 = this;
1021
- var marketplaceInfo, marketplaceId, marketplaceHashPromise, marketplace;
1022
+ var marketplaceInfo, marketplaceId, marketplaceHash, marketplace;
1022
1023
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1023
1024
  while (1) switch (_context15.prev = _context15.next) {
1024
1025
  case 0:
@@ -1026,17 +1027,20 @@ var ElvWalletClient = /*#__PURE__*/function () {
1026
1027
  marketplaceParams: marketplaceParams
1027
1028
  });
1028
1029
  marketplaceId = marketplaceInfo.marketplaceId;
1029
- marketplaceHashPromise = this.LatestMarketplaceHash({
1030
+ _context15.next = 4;
1031
+ return this.LatestMarketplaceHash({
1030
1032
  marketplaceParams: marketplaceParams
1031
1033
  });
1034
+ case 4:
1035
+ marketplaceHash = _context15.sent;
1032
1036
  if (this.cachedMarketplaces[marketplaceId] && this.cachedMarketplaces[marketplaceId].versionHash !== marketplaceHash) {
1033
1037
  delete this.cachedMarketplaces[marketplaceId];
1034
1038
  }
1035
1039
  if (this.cachedMarketplaces[marketplaceId]) {
1036
- _context15.next = 23;
1040
+ _context15.next = 21;
1037
1041
  break;
1038
1042
  }
1039
- _context15.next = 7;
1043
+ _context15.next = 9;
1040
1044
  return this.client.ContentObjectMetadata({
1041
1045
  libraryId: this.mainSiteLibraryId,
1042
1046
  objectId: this.mainSiteId,
@@ -1049,9 +1053,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
1049
1053
  produceLinkUrls: true,
1050
1054
  authorizationToken: this.publicStaticToken
1051
1055
  });
1052
- case 7:
1056
+ case 9:
1053
1057
  marketplace = _context15.sent;
1054
- _context15.next = 10;
1058
+ _context15.next = 12;
1055
1059
  return Promise.all(marketplace.items.map( /*#__PURE__*/function () {
1056
1060
  var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(item, index) {
1057
1061
  var authorizationToken;
@@ -1101,7 +1105,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
1101
1105
  return _ref13.apply(this, arguments);
1102
1106
  };
1103
1107
  }()));
1104
- case 10:
1108
+ case 12:
1105
1109
  marketplace.items = _context15.sent;
1106
1110
  marketplace.collections = (marketplace.collections || []).map(function (collection, collectionIndex) {
1107
1111
  return _objectSpread(_objectSpread({}, collection), {}, {
@@ -1110,14 +1114,8 @@ var ElvWalletClient = /*#__PURE__*/function () {
1110
1114
  });
1111
1115
  marketplace.retrievedAt = Date.now();
1112
1116
  marketplace.marketplaceId = marketplaceId;
1113
- _context15.next = 16;
1114
- return marketplaceHashPromise;
1115
- case 16:
1116
- marketplace.versionHash = _context15.sent;
1117
- _context15.next = 19;
1118
- return marketplaceHashPromise;
1119
- case 19:
1120
- marketplace.marketplaceHash = _context15.sent;
1117
+ marketplace.versionHash = marketplaceHash;
1118
+ marketplace.marketplaceHash = marketplaceHash;
1121
1119
  if (this.previewMarketplaceId && marketplaceId === this.previewMarketplaceId) {
1122
1120
  marketplace.branding.preview = true;
1123
1121
  }
@@ -1143,9 +1141,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
1143
1141
  } catch (error) {}
1144
1142
  });
1145
1143
  this.cachedMarketplaces[marketplaceId] = marketplace;
1146
- case 23:
1144
+ case 21:
1147
1145
  return _context15.abrupt("return", this.cachedMarketplaces[marketplaceId]);
1148
- case 24:
1146
+ case 22:
1149
1147
  case "end":
1150
1148
  return _context15.stop();
1151
1149
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.17",
3
+ "version": "4.0.19",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -54,7 +54,6 @@ class FrameClient {
54
54
  this.Crypto = Crypto;
55
55
  this.Crypto.ElvCrypto();
56
56
 
57
-
58
57
  // Dynamically defined methods defined in AllowedMethods
59
58
  for(const methodName of this.AllowedMethods()){
60
59
  this[methodName] = async (args) => {
@@ -258,13 +257,19 @@ class FrameClient {
258
257
 
259
258
  static FileMethods() {
260
259
  return [
260
+ "CreateFileUploadJob",
261
+ "DownloadEncrypted",
261
262
  "DownloadFile",
262
263
  "DownloadPart",
264
+ "FinalizeUploadJob",
263
265
  "UpdateContentObjectGraph",
266
+ "UploadFileData",
264
267
  "UploadFiles",
265
268
  "UploadFilesFromS3",
269
+ "UploadJobStatus",
266
270
  "UploadPart",
267
- "UploadPartChunk"
271
+ "UploadPartChunk",
272
+ "UploadStatus"
268
273
  ];
269
274
  }
270
275
 
@@ -403,8 +403,10 @@ exports.UploadFiles = async function({libraryId, objectId, writeToken, fileInfo,
403
403
  }
404
404
  };
405
405
 
406
- // Preparing jobs is done asyncronously
407
- PrepareJobs();
406
+ // Preparing jobs is done asynchronously
407
+ PrepareJobs().catch(e => {
408
+ throw e;
409
+ });
408
410
 
409
411
  // Upload the first several chunks in sequence, to determine average upload rate
410
412
  const rateTestJobs = Math.min(3, jobs.length);
@@ -499,21 +501,45 @@ exports.UploadFileData = async function({libraryId, objectId, writeToken, upload
499
501
  ValidateParameters({libraryId, objectId});
500
502
  ValidateWriteToken(writeToken);
501
503
 
502
- let path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
504
+ let retries = 0;
505
+ do {
506
+ try {
507
+ const jobStatus = await this.UploadJobStatus({libraryId, objectId, writeToken, uploadId, jobId});
503
508
 
504
- await this.utils.ResponseToJson(
505
- this.HttpClient.Request({
506
- method: "POST",
507
- path: path,
508
- body: fileData,
509
- bodyType: "BINARY",
510
- headers: {
511
- "Content-type": "application/octet-stream",
512
- ...(await this.authClient.AuthorizationHeader({libraryId, objectId, update: true}))
513
- },
514
- failover: false
515
- })
516
- );
509
+ if(jobStatus.rem === 0) {
510
+ // Job is actually done
511
+ return;
512
+ } else if(jobStatus.skip) {
513
+ fileData = fileData.slice(jobStatus.skip);
514
+ }
515
+
516
+ let path = UrlJoin("q", writeToken, "file_jobs", uploadId, jobId);
517
+
518
+ return await this.utils.ResponseToJson(
519
+ this.HttpClient.Request({
520
+ method: "POST",
521
+ path: path,
522
+ body: fileData,
523
+ bodyType: "BINARY",
524
+ headers: {
525
+ "Content-type": "application/octet-stream",
526
+ ...(await this.authClient.AuthorizationHeader({libraryId, objectId, update: true}))
527
+ },
528
+ failover: false
529
+ })
530
+ );
531
+ } catch(error){
532
+ this.Log(error, true);
533
+
534
+ retries += 1;
535
+
536
+ if(retries >= 5) {
537
+ throw error;
538
+ }
539
+
540
+ await new Promise(resolve => setTimeout(resolve, 10 * retries * 1000));
541
+ }
542
+ } while(retries < 5);
517
543
  };
518
544
 
519
545
  exports.FinalizeUploadJob = async function({libraryId, objectId, writeToken}) {