@eluvio/elv-client-js 4.0.145 → 4.0.147

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.
Files changed (40) hide show
  1. package/dist/ElvClient-min.js +14 -15
  2. package/dist/ElvClient-node-min.js +13 -14
  3. package/dist/ElvFrameClient-min.js +10 -10
  4. package/dist/ElvPermissionsClient-min.js +9 -9
  5. package/dist/ElvWalletClient-min.js +14 -15
  6. package/dist/ElvWalletClient-node-min.js +13 -14
  7. package/dist/src/AuthorizationClient.js +12 -9
  8. package/dist/src/ContentObjectAudit.js +3 -3
  9. package/dist/src/ContentObjectVerification.js +3 -3
  10. package/dist/src/Crypto.js +2 -2
  11. package/dist/src/ElvClient.js +30 -49
  12. package/dist/src/ElvWallet.js +5 -7
  13. package/dist/src/EthClient.js +9 -8
  14. package/dist/src/FrameClient.js +9 -8
  15. package/dist/src/HttpClient.js +2 -1
  16. package/dist/src/Id.js +2 -1
  17. package/dist/src/PermissionsClient.js +19 -31
  18. package/dist/src/RemoteSigner.js +8 -6
  19. package/dist/src/UserProfileClient.js +20 -35
  20. package/dist/src/Utils.js +3 -2
  21. package/dist/src/Validation.js +2 -10
  22. package/dist/src/client/ABRPublishing.js +252 -307
  23. package/dist/src/client/AccessGroups.js +2 -2
  24. package/dist/src/client/ContentAccess.js +3 -2
  25. package/dist/src/client/ContentManagement.js +3 -3
  26. package/dist/src/client/Contracts.js +12 -11
  27. package/dist/src/client/Files.js +2 -2
  28. package/dist/src/client/LiveConf.js +5 -3
  29. package/dist/src/client/LiveStream.js +2 -0
  30. package/dist/src/client/NFT.js +2 -2
  31. package/dist/src/client/Shares.js +2 -2
  32. package/dist/src/walletClient/ClientMethods.js +2 -2
  33. package/dist/src/walletClient/Profile.js +2 -2
  34. package/dist/src/walletClient/Utils.js +2 -2
  35. package/dist/src/walletClient/index.js +14 -17
  36. package/package.json +1 -1
  37. package/src/ElvClient.js +1 -0
  38. package/src/FrameClient.js +12 -0
  39. package/src/client/ABRPublishing.js +2 -1
  40. package/src/client/ContentAccess.js +44 -71
@@ -573,18 +573,17 @@ exports.ContentObjects = async function({libraryId, filterOptions={}}) {
573
573
  };
574
574
 
575
575
  /**
576
- * Get a specific content object in the library
576
+ * Get info about a specific content object
577
577
  *
578
578
  * @methodGroup Content Objects
579
579
  * @namedParams
580
- * @param {string=} libraryId - ID of the library
581
580
  * @param {string=} objectId - ID of the object
582
581
  * @param {string=} versionHash - Version hash of the object -- if not specified, latest version is returned
583
582
  * @param {string=} writeToken - Write token for an object draft -- if supplied, versionHash will be ignored
584
583
  *
585
584
  * @returns {Promise<Object>} - Description of content object
586
585
  */
587
- exports.ContentObject = async function({objectId, versionHash, writeToken}) {
586
+ exports.ContentObject = async function({objectId, versionHash, writeToken, noCache}) {
588
587
  this.Log(`Retrieving content object: ${writeToken || versionHash || objectId}`);
589
588
 
590
589
  if(writeToken) {
@@ -595,13 +594,26 @@ exports.ContentObject = async function({objectId, versionHash, writeToken}) {
595
594
 
596
595
  ValidateObject(objectId);
597
596
 
598
- let path = UrlJoin("q", writeToken || versionHash || objectId);
597
+ const id = writeToken || versionHash || objectId;
598
+ if(noCache || !this.objectInfo[id] || Date.now() - this.objectInfo[id].retrievedAt > 30000) {
599
+ let path = UrlJoin("q", id);
600
+ this.objectInfo[id] = {
601
+ retrievedAt: Date.now(),
602
+ info: (
603
+ await this.HttpClient.RequestJsonBody({
604
+ headers: await this.authClient.AuthorizationHeader({objectId, versionHash}),
605
+ method: "GET",
606
+ path: path,
607
+ queryParams: {
608
+ details: true,
609
+ profile: true
610
+ }
611
+ })
612
+ )
613
+ };
614
+ }
599
615
 
600
- return await this.HttpClient.RequestJsonBody({
601
- headers: await this.authClient.AuthorizationHeader({objectId, versionHash}),
602
- method: "GET",
603
- path: path
604
- });
616
+ return this.objectInfo[id].info;
605
617
  };
606
618
 
607
619
  /**
@@ -609,22 +621,21 @@ exports.ContentObject = async function({objectId, versionHash, writeToken}) {
609
621
  *
610
622
  * @methodGroup Content Objects
611
623
  * @namedParams
612
- * @param {string} libraryId
624
+ * @param {string=} objectId - ID of the object
625
+ * @param {string=} versionHash - Version hash of the object
613
626
  *
614
627
  * @returns {Promise<string>} - The account address of the owner
615
628
  */
616
- exports.ContentObjectOwner = async function({objectId}) {
617
- ValidateObject(objectId);
629
+ exports.ContentObjectOwner = async function({objectId, versionHash}) {
630
+ versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
631
+
632
+ if(versionHash) {
633
+ objectId = this.utils.DecodeVersionHash(versionHash).objectId;
634
+ }
618
635
 
619
636
  this.Log(`Retrieving content object owner: ${objectId}`);
620
637
 
621
- return this.utils.FormatAddress(
622
- await this.ethClient.CallContractMethod({
623
- contractAddress: this.utils.HashToAddress(objectId),
624
- methodName: "owner",
625
- methodArgs: []
626
- })
627
- );
638
+ return (await this.ContentObject({objectId, versionHash})).content_profile.owner;
628
639
  };
629
640
 
630
641
  /**
@@ -641,16 +652,18 @@ exports.ContentObjectOwner = async function({objectId}) {
641
652
  exports.ContentObjectTenantId = async function({objectId, versionHash}) {
642
653
  versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
643
654
 
644
- if(versionHash) { objectId = this.utils.DecodeVersionHash(versionHash).objectId; }
655
+ if(versionHash) {
656
+ objectId = this.utils.DecodeVersionHash(versionHash).objectId;
657
+ }
645
658
 
659
+ // Cache results because they will never change
646
660
  if(!this.objectTenantIds[objectId]) {
647
- this.objectTenantIds[objectId] = await this.authClient.MakeElvMasterCall({
648
- methodName: "elv_getTenantById",
649
- params: [
650
- this.contentSpaceId,
651
- objectId
652
- ]
653
- });
661
+ try {
662
+ this.objectTenantIds[objectId] = (await this.ContentObject({objectId, versionHash})).content_profile.tenant_id;
663
+ } catch(error) {
664
+ error.message = `Unable to determine tenant ID for ${versionHash || objectId}`;
665
+ throw error;
666
+ }
654
667
  }
655
668
 
656
669
  return this.objectTenantIds[objectId];
@@ -668,6 +681,8 @@ exports.ContentObjectTenantId = async function({objectId, versionHash}) {
668
681
  * @returns {Promise<string>} - Library ID of the object
669
682
  */
670
683
  exports.ContentObjectLibraryId = async function({objectId, versionHash}) {
684
+ versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
685
+
671
686
  if(versionHash) {
672
687
  objectId = this.utils.DecodeVersionHash(versionHash).objectId;
673
688
  }
@@ -677,7 +692,7 @@ exports.ContentObjectLibraryId = async function({objectId, versionHash}) {
677
692
  try {
678
693
  this.objectLibraryIds[objectId] = (await this.ContentObject({objectId, versionHash})).qlib_id;
679
694
  } catch(error) {
680
- error.message = `Unable to determine latest library for ${versionHash || objectId}`;
695
+ error.message = `Unable to determine library ID for ${versionHash || objectId}`;
681
696
  throw error;
682
697
  }
683
698
  }
@@ -685,48 +700,6 @@ exports.ContentObjectLibraryId = async function({objectId, versionHash}) {
685
700
  return this.objectLibraryIds[objectId];
686
701
  };
687
702
 
688
- exports.ContentObjectLibraryId2 = async function({objectId, versionHash}) {
689
- versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
690
-
691
- if(versionHash) { objectId = this.utils.DecodeVersionHash(versionHash).objectId; }
692
-
693
- switch(await this.authClient.AccessType(objectId)) {
694
- case this.authClient.ACCESS_TYPES.LIBRARY:
695
- return this.utils.AddressToLibraryId(this.utils.HashToAddress(objectId));
696
- case this.authClient.ACCESS_TYPES.OBJECT:
697
- if(!this.objectLibraryIds[objectId]) {
698
- this.Log(`Retrieving content object library ID: ${objectId || versionHash}`);
699
-
700
- this.objectLibraryIds[objectId] = new Promise(async (resolve, reject) => {
701
- try {
702
- resolve(
703
- this.utils.AddressToLibraryId(
704
- await this.CallContractMethod({
705
- contractAddress: this.utils.HashToAddress(objectId),
706
- methodName: "libraryAddress"
707
- })
708
- )
709
- );
710
- } catch(error) {
711
- reject(error);
712
- }
713
- });
714
- }
715
-
716
- try {
717
- return await this.objectLibraryIds[objectId];
718
- } catch(error) {
719
- delete this.objectLibraryIds[objectId];
720
-
721
- throw error;
722
- }
723
- case this.authClient.ACCESS_TYPES.OTHER:
724
- throw Error(`Unable to retrieve library ID for ${versionHash || objectId}: Unknown type. (wrong network or deleted object?)`);
725
- default:
726
- return this.contentSpaceLibraryId;
727
- }
728
- };
729
-
730
703
  exports.ProduceMetadataLinks = async function({
731
704
  libraryId,
732
705
  objectId,
@@ -1103,7 +1076,7 @@ exports.LatestVersionHash = async function({objectId, versionHash}) {
1103
1076
  }
1104
1077
 
1105
1078
  try {
1106
- return (await this.ContentObject({objectId})).hash;
1079
+ return (await this.ContentObject({objectId, noCache: true})).hash;
1107
1080
  } catch(error) {
1108
1081
  error.message = `Unable to determine latest version hash for ${versionHash || objectId}`;
1109
1082
  throw error;