@eluvio/elv-client-js 4.0.7 → 4.0.9

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 (45) hide show
  1. package/dist/ElvClient-min.js +10 -11
  2. package/dist/ElvClient-node-min.js +10 -11
  3. package/dist/ElvFrameClient-min.js +10 -11
  4. package/dist/ElvPermissionsClient-min.js +9 -10
  5. package/dist/ElvWalletClient-min.js +10 -11
  6. package/dist/ElvWalletClient-node-min.js +9 -10
  7. package/dist/src/AuthorizationClient.js +2069 -1548
  8. package/dist/src/ContentObjectVerification.js +185 -134
  9. package/dist/src/Crypto.js +323 -226
  10. package/dist/src/ElvClient.js +1118 -824
  11. package/dist/src/ElvWallet.js +106 -64
  12. package/dist/src/EthClient.js +974 -719
  13. package/dist/src/FrameClient.js +318 -222
  14. package/dist/src/HttpClient.js +154 -112
  15. package/dist/src/Id.js +6 -1
  16. package/dist/src/LogMessage.js +8 -4
  17. package/dist/src/PermissionsClient.js +1271 -973
  18. package/dist/src/RemoteSigner.js +232 -161
  19. package/dist/src/UserProfileClient.js +1038 -781
  20. package/dist/src/Utils.js +302 -160
  21. package/dist/src/Validation.js +17 -2
  22. package/dist/src/client/ABRPublishing.js +942 -772
  23. package/dist/src/client/AccessGroups.js +1095 -849
  24. package/dist/src/client/ContentAccess.js +4198 -3272
  25. package/dist/src/client/ContentManagement.js +2284 -1812
  26. package/dist/src/client/Contracts.js +614 -468
  27. package/dist/src/client/Files.js +1831 -1491
  28. package/dist/src/client/NFT.js +116 -94
  29. package/dist/src/client/NTP.js +425 -326
  30. package/dist/src/index.js +5 -2
  31. package/dist/src/walletClient/ClientMethods.js +1766 -1350
  32. package/dist/src/walletClient/Configuration.js +2 -4
  33. package/dist/src/walletClient/Notifications.js +127 -98
  34. package/dist/src/walletClient/Profile.js +246 -184
  35. package/dist/src/walletClient/Utils.js +124 -78
  36. package/dist/src/walletClient/index.js +1498 -1169
  37. package/package.json +1 -1
  38. package/src/Crypto.js +2 -2
  39. package/src/ElvClient.js +2 -2
  40. package/src/Utils.js +1 -1
  41. package/src/client/ContentAccess.js +27 -10
  42. package/src/client/Files.js +1 -1
  43. package/src/walletClient/ClientMethods.js +18 -10
  44. package/src/walletClient/Utils.js +2 -2
  45. package/src/walletClient/index.js +7 -2
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.7",
3
+ "version": "4.0.9",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
package/src/Crypto.js CHANGED
@@ -1,4 +1,4 @@
1
- const Buffer = require("buffer/").Buffer;
1
+ if(typeof globalThis.Buffer === "undefined") { globalThis.Buffer = require("buffer/").Buffer; }
2
2
 
3
3
  const bs58 = require("bs58");
4
4
  const Stream = require("stream");
@@ -7,7 +7,7 @@ const Utils = require("./Utils");
7
7
  if(typeof crypto === "undefined") {
8
8
  const crypto = require("crypto");
9
9
  crypto.getRandomValues = arr => crypto.randomBytes(arr.length);
10
- global.crypto = crypto;
10
+ globalThis.crypto = crypto;
11
11
  }
12
12
 
13
13
  let ElvCrypto;
package/src/ElvClient.js CHANGED
@@ -1,4 +1,4 @@
1
- const Buffer = require("buffer/").Buffer;
1
+ if(typeof globalThis.Buffer === "undefined") { globalThis.Buffer = require("buffer/").Buffer; }
2
2
 
3
3
  const URI = require("urijs");
4
4
  const Ethers = require("ethers");
@@ -31,7 +31,7 @@ const networks = {
31
31
  if(Utils.Platform() === Utils.PLATFORM_NODE) {
32
32
  // Define Response in node
33
33
  // eslint-disable-next-line no-global-assign
34
- global.Response = (require("node-fetch")).Response;
34
+ globalThis.Response = (require("node-fetch")).Response;
35
35
  }
36
36
 
37
37
  /**
package/src/Utils.js CHANGED
@@ -1,4 +1,4 @@
1
- const Buffer = require("buffer/").Buffer;
1
+ if(typeof globalThis.Buffer === "undefined") { globalThis.Buffer = require("buffer/").Buffer; }
2
2
 
3
3
  const bs58 = require("bs58");
4
4
  const BigNumber = require("bignumber.js").default;
@@ -874,6 +874,7 @@ exports.ContentObjectMetadata = async function({
874
874
  versionHash,
875
875
  writeToken,
876
876
  metadataSubtree="/",
877
+ localizationSubtree,
877
878
  queryParams={},
878
879
  select=[],
879
880
  remove=[],
@@ -940,17 +941,33 @@ exports.ContentObjectMetadata = async function({
940
941
  }
941
942
  }
942
943
 
943
- if(!produceLinkUrls) { return metadata; }
944
+ if(produceLinkUrls) {
945
+ metadata = await this.ProduceMetadataLinks({
946
+ libraryId,
947
+ objectId,
948
+ versionHash,
949
+ path: metadataSubtree,
950
+ metadata,
951
+ authorizationToken,
952
+ noAuth
953
+ });
954
+ }
944
955
 
945
- return await this.ProduceMetadataLinks({
946
- libraryId,
947
- objectId,
948
- versionHash,
949
- path: metadataSubtree,
950
- metadata,
951
- authorizationToken,
952
- noAuth
953
- });
956
+ if(!localizationSubtree) { return metadata; }
957
+
958
+ try {
959
+ const localizedMetadata = await this.ContentObjectMetadata({
960
+ ...arguments[0],
961
+ metadataSubtree: localizationSubtree,
962
+ localizationSubtree: undefined
963
+ });
964
+
965
+ return MergeWith({}, metadata, localizedMetadata, (a, b) => b === null || b === "" ? a : undefined);
966
+ } catch(error) {
967
+ this.Log(error, true);
968
+
969
+ return metadata;
970
+ }
954
971
  };
955
972
 
956
973
 
@@ -10,7 +10,7 @@ let fs;
10
10
  if(Utils.Platform() === Utils.PLATFORM_NODE) {
11
11
  // Define Response in node
12
12
  // eslint-disable-next-line no-global-assign
13
- global.Response = (require("node-fetch")).Response;
13
+ globalThis.Response = (require("node-fetch")).Response;
14
14
  fs = require("fs");
15
15
  }
16
16
 
@@ -1,6 +1,7 @@
1
1
  const Utils = require("../Utils");
2
2
  const UrlJoin = require("url-join");
3
3
  const {FormatNFTDetails, FormatNFTMetadata, FormatNFT} = require("./Utils");
4
+ const MergeWith = require("lodash/mergeWith");
4
5
 
5
6
  /**
6
7
  * Methods
@@ -571,16 +572,23 @@ exports.NFT = async function({tokenId, contractAddress}) {
571
572
  )
572
573
  );
573
574
 
574
- nft.metadata = {
575
- ...(
576
- (await this.client.ContentObjectMetadata({
577
- versionHash: nft.details.VersionHash,
578
- metadataSubtree: "public/asset_metadata/nft",
579
- produceLinkUrls: true
580
- })) || {}
581
- ),
582
- ...(nft.metadata || {})
583
- };
575
+ const assetMetadata = (await this.client.ContentObjectMetadata({
576
+ versionHash: nft.details.VersionHash,
577
+ metadataSubtree: "public/asset_metadata/nft",
578
+ produceLinkUrls: true
579
+ })) || {};
580
+
581
+ nft.metadata = MergeWith({}, assetMetadata, nft.metadata, (a, b) => b === null || b === "" ? a : undefined);
582
+
583
+ if(this.localization) {
584
+ const localizedMetadata = (await this.client.ContentObjectMetadata({
585
+ versionHash: nft.details.VersionHash,
586
+ metadataSubtree: UrlJoin("public", "asset_metadata", "localizations", this.localization, "nft"),
587
+ produceLinkUrls: true
588
+ })) || {};
589
+
590
+ nft.metadata = MergeWith({}, nft.metadata, localizedMetadata, (a, b) => b === null || b === "" ? a : undefined);
591
+ }
584
592
 
585
593
  nft.config = await this.TenantConfiguration({contractAddress});
586
594
 
@@ -55,8 +55,8 @@ const FormatNFTDetails = function(entry) {
55
55
  USDCOnly: !!paymentAccounts.find(entry => entry.preferred),
56
56
  EthUSDCAccepted: !!paymentAccounts.find(account => account.type === "eth"),
57
57
  EthUSDCOnly: !!paymentAccounts.find(account => account.type === "eth" && account.preferred),
58
- SolUSDCAccepted: !!paymentAccounts.find(account => account.type === "eth"),
59
- SolUSDCOnly: !!paymentAccounts.find(account => account.type === "eth" && account.preferred),
58
+ SolUSDCAccepted: !!paymentAccounts.find(account => account.type === "sol"),
59
+ SolUSDCOnly: !!paymentAccounts.find(account => account.type === "sol" && account.preferred),
60
60
 
61
61
  TenantId: entry.tenant || entry.tenant_id,
62
62
  ContractAddr: info.contract_addr,
@@ -23,12 +23,14 @@ try {
23
23
  * See the Modules section on the sidebar for all client methods unrelated to login and authorization
24
24
  */
25
25
  class ElvWalletClient {
26
- constructor({appId, client, network, mode, marketplaceInfo, previewMarketplaceHash, storeAuthToken}) {
26
+ constructor({appId, client, network, mode, localization, marketplaceInfo, previewMarketplaceHash, storeAuthToken}) {
27
27
  this.appId = appId;
28
28
 
29
29
  this.client = client;
30
30
  this.loggedIn = false;
31
31
 
32
+ this.localization = localization;
33
+
32
34
  this.network = network;
33
35
  this.mode = mode;
34
36
  this.purchaseMode = Configuration[network][mode].purchaseMode;
@@ -93,6 +95,7 @@ class ElvWalletClient {
93
95
  appId="general",
94
96
  network="main",
95
97
  mode="production",
98
+ localization,
96
99
  marketplaceParams,
97
100
  previewMarketplaceId,
98
101
  storeAuthToken=true
@@ -119,6 +122,7 @@ class ElvWalletClient {
119
122
  client,
120
123
  network,
121
124
  mode,
125
+ localization,
122
126
  marketplaceInfo: {
123
127
  tenantSlug,
124
128
  marketplaceSlug,
@@ -756,6 +760,7 @@ class ElvWalletClient {
756
760
  let marketplace = await this.client.ContentObjectMetadata({
757
761
  versionHash: marketplaceHash,
758
762
  metadataSubtree: "public/asset_metadata/info",
763
+ localizationSubtree: this.localization ? UrlJoin("public", "asset_metadata", "localizations", this.localization, "info") : "",
759
764
  linkDepthLimit: 1,
760
765
  resolveLinks: true,
761
766
  resolveIgnoreErrors: true,
@@ -810,7 +815,7 @@ class ElvWalletClient {
810
815
  }
811
816
 
812
817
  // Generate embed URLs for pack opening animations
813
- ["purchase_animation", "purchase_animation__mobile", "reveal_animation", "reveal_animation_mobile"].forEach(key => {
818
+ ["purchase_animation", "purchase_animation_mobile", "reveal_animation", "reveal_animation_mobile"].forEach(key => {
814
819
  try {
815
820
  if(marketplace.storefront[key]) {
816
821
  let embedUrl = new URL("https://embed.v3.contentfabric.io");