@eluvio/elv-client-js 3.1.79 → 3.1.80

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.
@@ -205,7 +205,9 @@ function () {
205
205
  _ref$noCache = _ref.noCache,
206
206
  noCache = _ref$noCache === void 0 ? false : _ref$noCache,
207
207
  _ref$noAuth = _ref.noAuth,
208
- noAuth = _ref$noAuth === void 0 ? false : _ref$noAuth;
208
+ noAuth = _ref$noAuth === void 0 ? false : _ref$noAuth,
209
+ _ref$assumeV = _ref.assumeV3,
210
+ assumeV3 = _ref$assumeV === void 0 ? false : _ref$assumeV;
209
211
 
210
212
  _classCallCheck(this, ElvClient);
211
213
 
@@ -224,6 +226,7 @@ function () {
224
226
  this.trustAuthorityId = trustAuthorityId;
225
227
  this.noCache = noCache;
226
228
  this.noAuth = noAuth;
229
+ this.assumeV3 = assumeV3;
227
230
  this.debug = false;
228
231
  this.InitializeClients({
229
232
  staticToken: staticToken
@@ -1500,13 +1503,13 @@ function () {
1500
1503
  }, {
1501
1504
  key: "FromNetworkName",
1502
1505
  value: function FromNetworkName(_ref22) {
1503
- var networkName, region, trustAuthorityId, staticToken, _ref22$ethereumContra, ethereumContractTimeout, _ref22$noCache, noCache, _ref22$noAuth, noAuth, configUrl;
1506
+ var networkName, region, trustAuthorityId, staticToken, _ref22$ethereumContra, ethereumContractTimeout, _ref22$noCache, noCache, _ref22$noAuth, noAuth, assumeV3, configUrl;
1504
1507
 
1505
1508
  return _regeneratorRuntime.async(function FromNetworkName$(_context19) {
1506
1509
  while (1) {
1507
1510
  switch (_context19.prev = _context19.next) {
1508
1511
  case 0:
1509
- networkName = _ref22.networkName, region = _ref22.region, trustAuthorityId = _ref22.trustAuthorityId, staticToken = _ref22.staticToken, _ref22$ethereumContra = _ref22.ethereumContractTimeout, ethereumContractTimeout = _ref22$ethereumContra === void 0 ? 10 : _ref22$ethereumContra, _ref22$noCache = _ref22.noCache, noCache = _ref22$noCache === void 0 ? false : _ref22$noCache, _ref22$noAuth = _ref22.noAuth, noAuth = _ref22$noAuth === void 0 ? false : _ref22$noAuth;
1512
+ networkName = _ref22.networkName, region = _ref22.region, trustAuthorityId = _ref22.trustAuthorityId, staticToken = _ref22.staticToken, _ref22$ethereumContra = _ref22.ethereumContractTimeout, ethereumContractTimeout = _ref22$ethereumContra === void 0 ? 10 : _ref22$ethereumContra, _ref22$noCache = _ref22.noCache, noCache = _ref22$noCache === void 0 ? false : _ref22$noCache, _ref22$noAuth = _ref22.noAuth, noAuth = _ref22$noAuth === void 0 ? false : _ref22$noAuth, assumeV3 = _ref22.assumeV3;
1510
1513
  configUrl = networks[networkName];
1511
1514
 
1512
1515
  if (configUrl) {
@@ -1525,7 +1528,8 @@ function () {
1525
1528
  staticToken: staticToken,
1526
1529
  ethereumContractTimeout: ethereumContractTimeout,
1527
1530
  noCache: noCache,
1528
- noAuth: noAuth
1531
+ noAuth: noAuth,
1532
+ assumeV3: assumeV3
1529
1533
  }));
1530
1534
 
1531
1535
  case 6:
@@ -1557,13 +1561,13 @@ function () {
1557
1561
  }, {
1558
1562
  key: "FromConfigurationUrl",
1559
1563
  value: function FromConfigurationUrl(_ref23) {
1560
- var configUrl, region, trustAuthorityId, staticToken, _ref23$ethereumContra, ethereumContractTimeout, _ref23$noCache, noCache, _ref23$noAuth, noAuth, _ref24, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fabricVersion, client;
1564
+ var configUrl, region, trustAuthorityId, staticToken, _ref23$ethereumContra, ethereumContractTimeout, _ref23$noCache, noCache, _ref23$noAuth, noAuth, _ref23$assumeV, assumeV3, _ref24, contentSpaceId, networkId, networkName, fabricURIs, ethereumURIs, authServiceURIs, fabricVersion, client;
1561
1565
 
1562
1566
  return _regeneratorRuntime.async(function FromConfigurationUrl$(_context20) {
1563
1567
  while (1) {
1564
1568
  switch (_context20.prev = _context20.next) {
1565
1569
  case 0:
1566
- configUrl = _ref23.configUrl, region = _ref23.region, trustAuthorityId = _ref23.trustAuthorityId, staticToken = _ref23.staticToken, _ref23$ethereumContra = _ref23.ethereumContractTimeout, ethereumContractTimeout = _ref23$ethereumContra === void 0 ? 10 : _ref23$ethereumContra, _ref23$noCache = _ref23.noCache, noCache = _ref23$noCache === void 0 ? false : _ref23$noCache, _ref23$noAuth = _ref23.noAuth, noAuth = _ref23$noAuth === void 0 ? false : _ref23$noAuth;
1570
+ configUrl = _ref23.configUrl, region = _ref23.region, trustAuthorityId = _ref23.trustAuthorityId, staticToken = _ref23.staticToken, _ref23$ethereumContra = _ref23.ethereumContractTimeout, ethereumContractTimeout = _ref23$ethereumContra === void 0 ? 10 : _ref23$ethereumContra, _ref23$noCache = _ref23.noCache, noCache = _ref23$noCache === void 0 ? false : _ref23$noCache, _ref23$noAuth = _ref23.noAuth, noAuth = _ref23$noAuth === void 0 ? false : _ref23$noAuth, _ref23$assumeV = _ref23.assumeV3, assumeV3 = _ref23$assumeV === void 0 ? false : _ref23$assumeV;
1567
1571
  _context20.next = 3;
1568
1572
  return _regeneratorRuntime.awrap(ElvClient.Configuration({
1569
1573
  configUrl: configUrl,
@@ -1591,7 +1595,8 @@ function () {
1591
1595
  trustAuthorityId: trustAuthorityId,
1592
1596
  staticToken: staticToken,
1593
1597
  noCache: noCache,
1594
- noAuth: noAuth
1598
+ noAuth: noAuth,
1599
+ assumeV3: assumeV3
1595
1600
  });
1596
1601
  client.configUrl = configUrl;
1597
1602
  return _context20.abrupt("return", client);
@@ -78,6 +78,8 @@ function () {
78
78
  this.client = client;
79
79
  this.debug = debug;
80
80
  this.userWalletAddresses = {};
81
+ this.walletAddress = undefined;
82
+ this.walletAddressRetrieved = false;
81
83
  }
82
84
 
83
85
  _createClass(UserProfileClient, [{
@@ -242,7 +244,7 @@ function () {
242
244
  case 0:
243
245
  autoCreate = _args2.length > 0 && _args2[0] !== undefined ? _args2[0] : true;
244
246
 
245
- if (!this.walletAddress) {
247
+ if (!(this.walletAddress || this.walletAddressRetrieved)) {
246
248
  _context2.next = 3;
247
249
  break;
248
250
  }
@@ -250,14 +252,18 @@ function () {
250
252
  return _context2.abrupt("return", this.walletAddress);
251
253
 
252
254
  case 3:
253
- _context2.next = 5;
254
- return _regeneratorRuntime.awrap(this.client.CallContractMethod({
255
- contractAddress: Utils.HashToAddress(this.client.contentSpaceId),
256
- methodName: "userWallets",
257
- methodArgs: [this.client.signer.address]
258
- }));
255
+ if (!this.walletAddressPromise) {
256
+ this.walletAddressPromise = this.client.CallContractMethod({
257
+ contractAddress: Utils.HashToAddress(this.client.contentSpaceId),
258
+ methodName: "userWallets",
259
+ methodArgs: [this.client.signer.address]
260
+ });
261
+ }
259
262
 
260
- case 5:
263
+ _context2.next = 6;
264
+ return _regeneratorRuntime.awrap(this.walletAddressPromise);
265
+
266
+ case 6:
261
267
  walletAddress = _context2.sent;
262
268
 
263
269
  if (!Utils.EqualAddress(walletAddress, Utils.nullAddress)) {
@@ -265,17 +271,18 @@ function () {
265
271
  }
266
272
 
267
273
  if (!(!this.walletAddress && autoCreate)) {
268
- _context2.next = 10;
274
+ _context2.next = 11;
269
275
  break;
270
276
  }
271
277
 
272
- _context2.next = 10;
278
+ _context2.next = 11;
273
279
  return _regeneratorRuntime.awrap(this.CreateWallet());
274
280
 
275
- case 10:
281
+ case 11:
282
+ this.walletAddressRetrieved = true;
276
283
  return _context2.abrupt("return", this.walletAddress);
277
284
 
278
- case 11:
285
+ case 13:
279
286
  case "end":
280
287
  return _context2.stop();
281
288
  }
@@ -1443,13 +1443,13 @@ exports.ProduceMetadataLinks = function _callee22(_ref15) {
1443
1443
  };
1444
1444
 
1445
1445
  exports.MetadataAuth = function _callee23(_ref16) {
1446
- var libraryId, objectId, versionHash, _ref16$path, path, _ref16$channelAuth, channelAuth, visibility, accessType, isPublic, noAuth, kmsAddress;
1446
+ var libraryId, objectId, versionHash, _ref16$path, path, _ref16$channelAuth, channelAuth, _ref16$noAuth, noAuth, isPublic, accessType, visibility, kmsAddress;
1447
1447
 
1448
1448
  return _regeneratorRuntime.async(function _callee23$(_context23) {
1449
1449
  while (1) {
1450
1450
  switch (_context23.prev = _context23.next) {
1451
1451
  case 0:
1452
- libraryId = _ref16.libraryId, objectId = _ref16.objectId, versionHash = _ref16.versionHash, _ref16$path = _ref16.path, path = _ref16$path === void 0 ? "/" : _ref16$path, _ref16$channelAuth = _ref16.channelAuth, channelAuth = _ref16$channelAuth === void 0 ? false : _ref16$channelAuth;
1452
+ libraryId = _ref16.libraryId, objectId = _ref16.objectId, versionHash = _ref16.versionHash, _ref16$path = _ref16.path, path = _ref16$path === void 0 ? "/" : _ref16$path, _ref16$channelAuth = _ref16.channelAuth, channelAuth = _ref16$channelAuth === void 0 ? false : _ref16$channelAuth, _ref16$noAuth = _ref16.noAuth, noAuth = _ref16$noAuth === void 0 ? false : _ref16$noAuth;
1453
1453
  ValidateParameters({
1454
1454
  libraryId: libraryId,
1455
1455
  objectId: objectId,
@@ -1460,43 +1460,52 @@ exports.MetadataAuth = function _callee23(_ref16) {
1460
1460
  objectId = this.utils.DecodeVersionHash(versionHash).objectId;
1461
1461
  }
1462
1462
 
1463
- _context23.next = 5;
1463
+ noAuth = this.noAuth || noAuth;
1464
+ isPublic = noAuth;
1465
+
1466
+ if (noAuth) {
1467
+ _context23.next = 14;
1468
+ break;
1469
+ }
1470
+
1471
+ _context23.next = 8;
1464
1472
  return _regeneratorRuntime.awrap(this.Visibility({
1465
1473
  id: objectId
1466
1474
  }));
1467
1475
 
1468
- case 5:
1476
+ case 8:
1469
1477
  visibility = _context23.sent;
1470
- _context23.next = 8;
1478
+ _context23.next = 11;
1471
1479
  return _regeneratorRuntime.awrap(this.AccessType({
1472
1480
  id: objectId
1473
1481
  }));
1474
1482
 
1475
- case 8:
1483
+ case 11:
1476
1484
  accessType = _context23.sent;
1477
1485
  isPublic = (path || "").replace(/^\/+/, "").startsWith("public");
1478
1486
  noAuth = visibility >= 10 || isPublic && visibility >= 1;
1479
1487
 
1488
+ case 14:
1480
1489
  if (!this.oauthToken) {
1481
- _context23.next = 19;
1490
+ _context23.next = 22;
1482
1491
  break;
1483
1492
  }
1484
1493
 
1485
- _context23.next = 14;
1494
+ _context23.next = 17;
1486
1495
  return _regeneratorRuntime.awrap(this.authClient.KMSAddress({
1487
1496
  objectId: objectId,
1488
1497
  versionHash: versionHash
1489
1498
  }));
1490
1499
 
1491
- case 14:
1500
+ case 17:
1492
1501
  kmsAddress = _context23.sent;
1493
1502
 
1494
1503
  if (!(kmsAddress && !this.utils.EqualAddress(kmsAddress, this.utils.nullAddress))) {
1495
- _context23.next = 19;
1504
+ _context23.next = 22;
1496
1505
  break;
1497
1506
  }
1498
1507
 
1499
- _context23.next = 18;
1508
+ _context23.next = 21;
1500
1509
  return _regeneratorRuntime.awrap(this.authClient.AuthorizationToken({
1501
1510
  libraryId: libraryId,
1502
1511
  objectId: objectId,
@@ -1505,35 +1514,35 @@ exports.MetadataAuth = function _callee23(_ref16) {
1505
1514
  oauthToken: this.oauthToken
1506
1515
  }));
1507
1516
 
1508
- case 18:
1517
+ case 21:
1509
1518
  return _context23.abrupt("return", _context23.sent);
1510
1519
 
1511
- case 19:
1520
+ case 22:
1512
1521
  if (!(!this.inaccessibleLibraries[libraryId] && isPublic && accessType === this.authClient.ACCESS_TYPES.OBJECT && !channelAuth)) {
1513
- _context23.next = 47;
1522
+ _context23.next = 50;
1514
1523
  break;
1515
1524
  }
1516
1525
 
1517
- _context23.prev = 20;
1526
+ _context23.prev = 23;
1518
1527
  _context23.t0 = _regeneratorRuntime;
1519
1528
  _context23.t1 = this.authClient;
1520
1529
  _context23.t2 = libraryId;
1521
1530
 
1522
1531
  if (_context23.t2) {
1523
- _context23.next = 28;
1532
+ _context23.next = 31;
1524
1533
  break;
1525
1534
  }
1526
1535
 
1527
- _context23.next = 27;
1536
+ _context23.next = 30;
1528
1537
  return _regeneratorRuntime.awrap(this.ContentObjectLibraryId({
1529
1538
  objectId: objectId,
1530
1539
  versionHash: versionHash
1531
1540
  }));
1532
1541
 
1533
- case 27:
1542
+ case 30:
1534
1543
  _context23.t2 = _context23.sent;
1535
1544
 
1536
- case 28:
1545
+ case 31:
1537
1546
  _context23.t3 = _context23.t2;
1538
1547
  _context23.t4 = noAuth;
1539
1548
  _context23.t5 = {
@@ -1541,23 +1550,23 @@ exports.MetadataAuth = function _callee23(_ref16) {
1541
1550
  noAuth: _context23.t4
1542
1551
  };
1543
1552
  _context23.t6 = _context23.t1.AuthorizationToken.call(_context23.t1, _context23.t5);
1544
- _context23.next = 34;
1553
+ _context23.next = 37;
1545
1554
  return _context23.t0.awrap.call(_context23.t0, _context23.t6);
1546
1555
 
1547
- case 34:
1556
+ case 37:
1548
1557
  return _context23.abrupt("return", _context23.sent);
1549
1558
 
1550
- case 37:
1551
- _context23.prev = 37;
1552
- _context23.t7 = _context23["catch"](20);
1559
+ case 40:
1560
+ _context23.prev = 40;
1561
+ _context23.t7 = _context23["catch"](23);
1553
1562
 
1554
1563
  if (!(_context23.t7.message && _context23.t7.message.toLowerCase().startsWith("access denied"))) {
1555
- _context23.next = 44;
1564
+ _context23.next = 47;
1556
1565
  break;
1557
1566
  }
1558
1567
 
1559
1568
  this.inaccessibleLibraries[libraryId] = true;
1560
- _context23.next = 43;
1569
+ _context23.next = 46;
1561
1570
  return _regeneratorRuntime.awrap(this.authClient.AuthorizationToken({
1562
1571
  libraryId: libraryId,
1563
1572
  objectId: objectId,
@@ -1566,18 +1575,18 @@ exports.MetadataAuth = function _callee23(_ref16) {
1566
1575
  channelAuth: channelAuth
1567
1576
  }));
1568
1577
 
1569
- case 43:
1578
+ case 46:
1570
1579
  return _context23.abrupt("return", _context23.sent);
1571
1580
 
1572
- case 44:
1581
+ case 47:
1573
1582
  throw _context23.t7;
1574
1583
 
1575
- case 45:
1576
- _context23.next = 50;
1584
+ case 48:
1585
+ _context23.next = 53;
1577
1586
  break;
1578
1587
 
1579
- case 47:
1580
- _context23.next = 49;
1588
+ case 50:
1589
+ _context23.next = 52;
1581
1590
  return _regeneratorRuntime.awrap(this.authClient.AuthorizationToken({
1582
1591
  libraryId: libraryId,
1583
1592
  objectId: objectId,
@@ -1586,15 +1595,15 @@ exports.MetadataAuth = function _callee23(_ref16) {
1586
1595
  channelAuth: channelAuth
1587
1596
  }));
1588
1597
 
1589
- case 49:
1598
+ case 52:
1590
1599
  return _context23.abrupt("return", _context23.sent);
1591
1600
 
1592
- case 50:
1601
+ case 53:
1593
1602
  case "end":
1594
1603
  return _context23.stop();
1595
1604
  }
1596
1605
  }
1597
- }, null, this, [[20, 37]]);
1606
+ }, null, this, [[23, 40]]);
1598
1607
  };
1599
1608
  /**
1600
1609
  * Get the metadata of a content object
@@ -1611,6 +1620,7 @@ exports.MetadataAuth = function _callee23(_ref16) {
1611
1620
  * - Note: Selection is relative to "metadataSubtree". For example, metadataSubtree="public" and select=["name", "description"] would select "public/name" and "public/description"
1612
1621
  * @param {Array<string>=} remove - Exclude the specified items from the retrieved metadata
1613
1622
  * @param {string=} authorizationToken - Additional authorization token for this request
1623
+ * @param {string=} noAuth=false - If specified, the normal authorization flow will be skipped. Useful if you know the metadata you're retrieving is publicly accessible
1614
1624
  * @param {boolean=} resolveLinks=false - If specified, links in the metadata will be resolved
1615
1625
  * @param {boolean=} resolveIncludeSource=false - If specified, resolved links will include the hash of the link at the root of the metadata
1616
1626
 
@@ -1638,13 +1648,13 @@ exports.MetadataAuth = function _callee23(_ref16) {
1638
1648
 
1639
1649
 
1640
1650
  exports.ContentObjectMetadata = function _callee24(_ref17) {
1641
- var libraryId, objectId, versionHash, writeToken, _ref17$metadataSubtre, metadataSubtree, _ref17$queryParams, queryParams, _ref17$select, select, _ref17$remove, remove, authorizationToken, _ref17$resolveLinks, resolveLinks, _ref17$resolveInclude, resolveIncludeSource, _ref17$resolveIgnoreE, resolveIgnoreErrors, _ref17$linkDepthLimit, linkDepthLimit, _ref17$produceLinkUrl, produceLinkUrls, path, defaultAuthToken, authTokens, metadata;
1651
+ var libraryId, objectId, versionHash, writeToken, _ref17$metadataSubtre, metadataSubtree, _ref17$queryParams, queryParams, _ref17$select, select, _ref17$remove, remove, authorizationToken, _ref17$noAuth, noAuth, _ref17$resolveLinks, resolveLinks, _ref17$resolveInclude, resolveIncludeSource, _ref17$resolveIgnoreE, resolveIgnoreErrors, _ref17$linkDepthLimit, linkDepthLimit, _ref17$produceLinkUrl, produceLinkUrls, path, defaultAuthToken, authTokens, metadata;
1642
1652
 
1643
1653
  return _regeneratorRuntime.async(function _callee24$(_context24) {
1644
1654
  while (1) {
1645
1655
  switch (_context24.prev = _context24.next) {
1646
1656
  case 0:
1647
- libraryId = _ref17.libraryId, objectId = _ref17.objectId, versionHash = _ref17.versionHash, writeToken = _ref17.writeToken, _ref17$metadataSubtre = _ref17.metadataSubtree, metadataSubtree = _ref17$metadataSubtre === void 0 ? "/" : _ref17$metadataSubtre, _ref17$queryParams = _ref17.queryParams, queryParams = _ref17$queryParams === void 0 ? {} : _ref17$queryParams, _ref17$select = _ref17.select, select = _ref17$select === void 0 ? [] : _ref17$select, _ref17$remove = _ref17.remove, remove = _ref17$remove === void 0 ? [] : _ref17$remove, authorizationToken = _ref17.authorizationToken, _ref17$resolveLinks = _ref17.resolveLinks, resolveLinks = _ref17$resolveLinks === void 0 ? false : _ref17$resolveLinks, _ref17$resolveInclude = _ref17.resolveIncludeSource, resolveIncludeSource = _ref17$resolveInclude === void 0 ? false : _ref17$resolveInclude, _ref17$resolveIgnoreE = _ref17.resolveIgnoreErrors, resolveIgnoreErrors = _ref17$resolveIgnoreE === void 0 ? false : _ref17$resolveIgnoreE, _ref17$linkDepthLimit = _ref17.linkDepthLimit, linkDepthLimit = _ref17$linkDepthLimit === void 0 ? 1 : _ref17$linkDepthLimit, _ref17$produceLinkUrl = _ref17.produceLinkUrls, produceLinkUrls = _ref17$produceLinkUrl === void 0 ? false : _ref17$produceLinkUrl;
1657
+ libraryId = _ref17.libraryId, objectId = _ref17.objectId, versionHash = _ref17.versionHash, writeToken = _ref17.writeToken, _ref17$metadataSubtre = _ref17.metadataSubtree, metadataSubtree = _ref17$metadataSubtre === void 0 ? "/" : _ref17$metadataSubtre, _ref17$queryParams = _ref17.queryParams, queryParams = _ref17$queryParams === void 0 ? {} : _ref17$queryParams, _ref17$select = _ref17.select, select = _ref17$select === void 0 ? [] : _ref17$select, _ref17$remove = _ref17.remove, remove = _ref17$remove === void 0 ? [] : _ref17$remove, authorizationToken = _ref17.authorizationToken, _ref17$noAuth = _ref17.noAuth, noAuth = _ref17$noAuth === void 0 ? false : _ref17$noAuth, _ref17$resolveLinks = _ref17.resolveLinks, resolveLinks = _ref17$resolveLinks === void 0 ? false : _ref17$resolveLinks, _ref17$resolveInclude = _ref17.resolveIncludeSource, resolveIncludeSource = _ref17$resolveInclude === void 0 ? false : _ref17$resolveInclude, _ref17$resolveIgnoreE = _ref17.resolveIgnoreErrors, resolveIgnoreErrors = _ref17$resolveIgnoreE === void 0 ? false : _ref17$resolveIgnoreE, _ref17$linkDepthLimit = _ref17.linkDepthLimit, linkDepthLimit = _ref17$linkDepthLimit === void 0 ? 1 : _ref17$linkDepthLimit, _ref17$produceLinkUrl = _ref17.produceLinkUrls, produceLinkUrls = _ref17$produceLinkUrl === void 0 ? false : _ref17$produceLinkUrl;
1648
1658
  ValidateParameters({
1649
1659
  libraryId: libraryId,
1650
1660
  objectId: objectId,
@@ -1664,7 +1674,8 @@ exports.ContentObjectMetadata = function _callee24(_ref17) {
1664
1674
  libraryId: libraryId,
1665
1675
  objectId: objectId,
1666
1676
  versionHash: versionHash,
1667
- path: metadataSubtree
1677
+ path: metadataSubtree,
1678
+ noAuth: noAuth
1668
1679
  }));
1669
1680
 
1670
1681
  case 8:
@@ -3961,28 +3972,22 @@ exports.LinkUrl = function _callee44(_ref37) {
3961
3972
  }
3962
3973
 
3963
3974
  authorization = [authorizationToken];
3964
-
3965
- if (noAuth) {
3966
- _context44.next = 14;
3967
- break;
3968
- }
3969
-
3970
3975
  _context44.t0 = authorization;
3971
- _context44.next = 12;
3976
+ _context44.next = 11;
3972
3977
  return _regeneratorRuntime.awrap(this.MetadataAuth({
3973
3978
  libraryId: libraryId,
3974
3979
  objectId: objectId,
3975
3980
  versionHash: versionHash,
3976
3981
  path: linkPath,
3977
- channelAuth: channelAuth
3982
+ channelAuth: channelAuth,
3983
+ noAuth: noAuth
3978
3984
  }));
3979
3985
 
3980
- case 12:
3986
+ case 11:
3981
3987
  _context44.t1 = _context44.sent;
3982
3988
 
3983
3989
  _context44.t0.push.call(_context44.t0, _context44.t1);
3984
3990
 
3985
- case 14:
3986
3991
  if (queryParams.authorization) {
3987
3992
  authorization.push(queryParams.authorization);
3988
3993
  }
@@ -4003,7 +4008,7 @@ exports.LinkUrl = function _callee44(_ref37) {
4003
4008
  queryParams: queryParams
4004
4009
  }));
4005
4010
 
4006
- case 18:
4011
+ case 17:
4007
4012
  case "end":
4008
4013
  return _context44.stop();
4009
4014
  }
@@ -880,7 +880,7 @@ exports.RemoveLibraryContentType = function _callee9(_ref12) {
880
880
 
881
881
 
882
882
  exports.CreateContentObject = function _callee10(_ref13) {
883
- var libraryId, objectId, _ref13$options, options, typeId, type, _ref14, contractAddress, path, createResponse;
883
+ var libraryId, objectId, _ref13$options, options, typeId, type, currentAccountAddress, canContribute, _ref14, contractAddress, path, createResponse;
884
884
 
885
885
  return _regeneratorRuntime.async(function _callee10$(_context11) {
886
886
  while (1) {
@@ -957,65 +957,88 @@ exports.CreateContentObject = function _callee10(_ref13) {
957
957
 
958
958
  case 26:
959
959
  if (objectId) {
960
- _context11.next = 36;
960
+ _context11.next = 44;
961
961
  break;
962
962
  }
963
963
 
964
+ _context11.next = 29;
965
+ return _regeneratorRuntime.awrap(this.CurrentAccountAddress());
966
+
967
+ case 29:
968
+ currentAccountAddress = _context11.sent;
969
+ _context11.next = 32;
970
+ return _regeneratorRuntime.awrap(this.CallContractMethod({
971
+ contractAddress: this.utils.HashToAddress(libraryId),
972
+ methodName: "canContribute",
973
+ methodArgs: [currentAccountAddress]
974
+ }));
975
+
976
+ case 32:
977
+ canContribute = _context11.sent;
978
+
979
+ if (canContribute) {
980
+ _context11.next = 35;
981
+ break;
982
+ }
983
+
984
+ throw Error("Current user does not have permission to create content in library ".concat(libraryId));
985
+
986
+ case 35:
964
987
  this.Log("Deploying contract...");
965
- _context11.next = 30;
988
+ _context11.next = 38;
966
989
  return _regeneratorRuntime.awrap(this.authClient.CreateContentObject({
967
990
  libraryId: libraryId,
968
991
  typeId: typeId
969
992
  }));
970
993
 
971
- case 30:
994
+ case 38:
972
995
  _ref14 = _context11.sent;
973
996
  contractAddress = _ref14.contractAddress;
974
997
  objectId = this.utils.AddressToObjectId(contractAddress);
975
998
  this.Log("Contract deployed: ".concat(contractAddress, " ").concat(objectId));
976
- _context11.next = 43;
999
+ _context11.next = 51;
977
1000
  break;
978
1001
 
979
- case 36:
1002
+ case 44:
980
1003
  _context11.t0 = this;
981
1004
  _context11.t1 = "Contract already deployed for contract type: ";
982
- _context11.next = 40;
1005
+ _context11.next = 48;
983
1006
  return _regeneratorRuntime.awrap(this.AccessType({
984
1007
  id: objectId
985
1008
  }));
986
1009
 
987
- case 40:
1010
+ case 48:
988
1011
  _context11.t2 = _context11.sent;
989
1012
  _context11.t3 = _context11.t1.concat.call(_context11.t1, _context11.t2);
990
1013
 
991
1014
  _context11.t0.Log.call(_context11.t0, _context11.t3);
992
1015
 
993
- case 43:
1016
+ case 51:
994
1017
  if (!options.visibility) {
995
- _context11.next = 47;
1018
+ _context11.next = 55;
996
1019
  break;
997
1020
  }
998
1021
 
999
1022
  this.Log("Setting visibility to ".concat(options.visibility));
1000
- _context11.next = 47;
1023
+ _context11.next = 55;
1001
1024
  return _regeneratorRuntime.awrap(this.SetVisibility({
1002
1025
  id: objectId,
1003
1026
  visibility: options.visibility
1004
1027
  }));
1005
1028
 
1006
- case 47:
1029
+ case 55:
1007
1030
  path = UrlJoin("qid", objectId);
1008
1031
  _context11.t4 = _regeneratorRuntime;
1009
1032
  _context11.t5 = this.utils;
1010
1033
  _context11.t6 = this.HttpClient;
1011
- _context11.next = 53;
1034
+ _context11.next = 61;
1012
1035
  return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
1013
1036
  libraryId: libraryId,
1014
1037
  objectId: objectId,
1015
1038
  update: true
1016
1039
  }));
1017
1040
 
1018
- case 53:
1041
+ case 61:
1019
1042
  _context11.t7 = _context11.sent;
1020
1043
  _context11.t8 = path;
1021
1044
  _context11.t9 = options;
@@ -1027,10 +1050,10 @@ exports.CreateContentObject = function _callee10(_ref13) {
1027
1050
  };
1028
1051
  _context11.t11 = _context11.t6.Request.call(_context11.t6, _context11.t10);
1029
1052
  _context11.t12 = _context11.t5.ResponseToJson.call(_context11.t5, _context11.t11);
1030
- _context11.next = 61;
1053
+ _context11.next = 69;
1031
1054
  return _context11.t4.awrap.call(_context11.t4, _context11.t12);
1032
1055
 
1033
- case 61:
1056
+ case 69:
1034
1057
  createResponse = _context11.sent;
1035
1058
  // Record the node used in creating this write token
1036
1059
  this.HttpClient.RecordWriteToken(createResponse.write_token);
@@ -1038,7 +1061,7 @@ exports.CreateContentObject = function _callee10(_ref13) {
1038
1061
  createResponse.objectId = createResponse.id;
1039
1062
  return _context11.abrupt("return", createResponse);
1040
1063
 
1041
- case 66:
1064
+ case 74:
1042
1065
  case "end":
1043
1066
  return _context11.stop();
1044
1067
  }
package/package-lock.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.79",
3
+ "version": "3.1.80",
4
4
  "lockfileVersion": 1,
5
5
  "requires": true,
6
6
  "dependencies": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.79",
3
+ "version": "3.1.80",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/ElvClient.js",
6
6
  "author": "Kevin Talmadge",
@@ -84,6 +84,16 @@ class AuthorizationClient {
84
84
  this.providers = {};
85
85
  }
86
86
 
87
+ CreateStaticToken({libraryId}) {
88
+ let token = { qspace_id: this.client.contentSpaceId };
89
+
90
+ if(libraryId) {
91
+ token.qlib_id = libraryId;
92
+ }
93
+
94
+ return Utils.B64(JSON.stringify(token));
95
+ }
96
+
87
97
  // Return authorization token in appropriate headers
88
98
  async AuthorizationHeader(params) {
89
99
  const authorizationToken = await this.AuthorizationToken(params);
@@ -150,6 +160,10 @@ class AuthorizationClient {
150
160
  oauthToken
151
161
  });
152
162
  } else {
163
+ if(noAuth) {
164
+ return this.CreateStaticToken({libraryId});
165
+ }
166
+
153
167
  authorizationToken = await this.GenerateAuthorizationToken({
154
168
  libraryId,
155
169
  objectId,
@@ -177,7 +191,7 @@ class AuthorizationClient {
177
191
  if(encryption && encryption !== "none" && objectId && await this.AccessType(objectId) === ACCESS_TYPES.OBJECT) {
178
192
  const owner = await this.Owner({id: objectId});
179
193
  const ownerCapKey = `eluv.caps.iusr${Utils.AddressToHash(this.client.signer.address)}`;
180
- const ownerCap = await client.ContentObjectMetadata({libraryId, objectId, metadataSubtree: ownerCapKey});
194
+ const ownerCap = await this.client.ContentObjectMetadata({libraryId, objectId, metadataSubtree: ownerCapKey});
181
195
 
182
196
  if(!Utils.EqualAddress(owner, this.client.signer.address) && !ownerCap) {
183
197
  const cap = await this.ReEncryptionConk({libraryId, objectId});
@@ -613,6 +627,10 @@ class AuthorizationClient {
613
627
  }
614
628
 
615
629
  async IsV3({id}) {
630
+ if(this.client.assumeV3) {
631
+ return true;
632
+ }
633
+
616
634
  const contractName = await this.client.ethClient.ContractName(Utils.HashToAddress(id), true);
617
635
 
618
636
  if(!this.accessVersions[contractName]) {
package/src/ElvClient.js CHANGED
@@ -148,7 +148,8 @@ class ElvClient {
148
148
  trustAuthorityId,
149
149
  staticToken,
150
150
  noCache=false,
151
- noAuth=false
151
+ noAuth=false,
152
+ assumeV3=false
152
153
  }) {
153
154
  this.utils = Utils;
154
155
 
@@ -171,6 +172,7 @@ class ElvClient {
171
172
 
172
173
  this.noCache = noCache;
173
174
  this.noAuth = noAuth;
175
+ this.assumeV3 = assumeV3;
174
176
 
175
177
  this.debug = false;
176
178
 
@@ -270,7 +272,8 @@ class ElvClient {
270
272
  staticToken,
271
273
  ethereumContractTimeout=10,
272
274
  noCache=false,
273
- noAuth=false
275
+ noAuth=false,
276
+ assumeV3
274
277
  }) {
275
278
  const configUrl = networks[networkName];
276
279
 
@@ -283,7 +286,8 @@ class ElvClient {
283
286
  staticToken,
284
287
  ethereumContractTimeout,
285
288
  noCache,
286
- noAuth
289
+ noAuth,
290
+ assumeV3
287
291
  });
288
292
  }
289
293
 
@@ -309,7 +313,8 @@ class ElvClient {
309
313
  staticToken,
310
314
  ethereumContractTimeout=10,
311
315
  noCache=false,
312
- noAuth=false
316
+ noAuth=false,
317
+ assumeV3=false
313
318
  }) {
314
319
  const {
315
320
  contentSpaceId,
@@ -336,7 +341,8 @@ class ElvClient {
336
341
  trustAuthorityId,
337
342
  staticToken,
338
343
  noCache,
339
- noAuth
344
+ noAuth,
345
+ assumeV3
340
346
  });
341
347
 
342
348
  client.configUrl = configUrl;