@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
@@ -1,49 +1,66 @@
1
1
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
+
2
3
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
+
3
5
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
6
+
4
7
  var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
8
+
5
9
  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; }
10
+
6
11
  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; }
12
+
7
13
  var Utils = require("../Utils");
14
+
8
15
  var RarityToPercentage = function RarityToPercentage(rarity) {
9
16
  if (!rarity) {
10
17
  return "";
11
18
  }
19
+
12
20
  rarity = rarity.toString();
21
+
13
22
  if (!rarity.includes("/")) {
14
23
  return rarity;
15
24
  }
25
+
16
26
  var _rarity$split = rarity.split("/"),
17
- _rarity$split2 = _slicedToArray(_rarity$split, 2),
18
- numerator = _rarity$split2[0],
19
- denominator = _rarity$split2[1];
27
+ _rarity$split2 = _slicedToArray(_rarity$split, 2),
28
+ numerator = _rarity$split2[0],
29
+ denominator = _rarity$split2[1];
30
+
20
31
  var percentage = 100 * parseInt(numerator) / parseInt(denominator);
32
+
21
33
  if (percentage < 1) {
22
34
  percentage = percentage.toFixed(2);
23
35
  } else {
24
36
  percentage = percentage.toFixed(1).toString().replace(".0", "");
25
37
  }
38
+
26
39
  return percentage;
27
40
  };
41
+
28
42
  var LinkTargetHash = function LinkTargetHash(link) {
29
43
  if (!link) {
30
44
  return;
31
45
  }
46
+
32
47
  if (link["."] && link["."].source) {
33
48
  return link["."].source;
34
49
  }
50
+
35
51
  if (link["/"] && link["/"].startsWith("/qfab/")) {
36
52
  return link["/"].split("/").find(function (segment) {
37
53
  return segment.startsWith("hq__");
38
54
  });
39
55
  }
56
+
40
57
  if (link["."] && link["."].container) {
41
58
  return link["."].container;
42
59
  }
43
60
  };
44
- exports.LinkTargetHash = LinkTargetHash;
45
61
 
46
- // Format NFT or listing result into consistent format
62
+ exports.LinkTargetHash = LinkTargetHash; // Format NFT or listing result into consistent format
63
+
47
64
  var FormatNFTDetails = function FormatNFTDetails(entry) {
48
65
  var isListing = !!entry.id;
49
66
  var metadata = (isListing ? entry.nft : entry.meta) || {};
@@ -61,10 +78,10 @@ var FormatNFTDetails = function FormatNFTDetails(entry) {
61
78
  return account.type === "eth" && account.preferred;
62
79
  }),
63
80
  SolUSDCAccepted: !!paymentAccounts.find(function (account) {
64
- return account.type === "eth";
81
+ return account.type === "sol";
65
82
  }),
66
83
  SolUSDCOnly: !!paymentAccounts.find(function (account) {
67
- return account.type === "eth" && account.preferred;
84
+ return account.type === "sol" && account.preferred;
68
85
  }),
69
86
  TenantId: entry.tenant || entry.tenant_id,
70
87
  ContractAddr: info.contract_addr,
@@ -81,6 +98,7 @@ var FormatNFTDetails = function FormatNFTDetails(entry) {
81
98
  return (s || "").startsWith("hq__");
82
99
  })
83
100
  };
101
+
84
102
  if (isListing) {
85
103
  details = _objectSpread(_objectSpread({}, details), {}, {
86
104
  // Listing specific fields
@@ -95,25 +113,28 @@ var FormatNFTDetails = function FormatNFTDetails(entry) {
95
113
  } else {
96
114
  details.Offers = info.offers || [];
97
115
  }
116
+
98
117
  return {
99
118
  metadata: metadata,
100
119
  details: details
101
120
  };
102
121
  };
122
+
103
123
  exports.FormatNFTDetails = FormatNFTDetails;
124
+
104
125
  var FormatNFTMetadata = function FormatNFTMetadata(walletClient, nft) {
105
- nft.formatted = true;
126
+ nft.formatted = true; // Surface relevant details to top level
106
127
 
107
- // Surface relevant details to top level
108
128
  nft.contractAddress = nft.details.ContractAddr;
109
129
  nft.contractId = nft.details.ContractId;
110
130
  nft.tokenId = nft.details.TokenIdStr;
111
131
  nft.name = nft.metadata.display_name;
132
+
112
133
  if (nft.details.ListingId) {
113
134
  nft.listingId = nft.details.ListingId;
114
- }
135
+ } // Format traits
136
+
115
137
 
116
- // Format traits
117
138
  var FILTERED_ATTRIBUTES = ["Content Fabric Hash", "Creator", "Total Minted Supply"];
118
139
  nft.metadata.attributes = (nft.metadata.attributes || []).filter(function (attribute) {
119
140
  return attribute && !FILTERED_ATTRIBUTES.includes(attribute.trait_type);
@@ -122,25 +143,28 @@ var FormatNFTMetadata = function FormatNFTMetadata(walletClient, nft) {
122
143
  name: trait.trait_type,
123
144
  rarity_percent: RarityToPercentage(trait.rarity)
124
145
  });
125
- });
146
+ }); // Generate embed URLs for additional media
126
147
 
127
- // Generate embed URLs for additional media
128
148
  if (nft.metadata.additional_media) {
129
149
  nft.metadata.additional_media = nft.metadata.additional_media.map(function (media) {
130
150
  try {
131
151
  // Generate embed URLs for additional media
132
152
  var mediaType = (media.media_type || "").toLowerCase();
153
+
133
154
  if (mediaType === "image") {
134
155
  return _objectSpread(_objectSpread({}, media), {}, {
135
156
  embed_url: media.media_file.url
136
157
  });
137
158
  }
159
+
138
160
  var embedUrl = new URL("https://embed.v3.contentfabric.io");
139
161
  embedUrl.searchParams.set("p", "");
140
162
  embedUrl.searchParams.set("net", walletClient.network === "demo" ? "demo" : "main");
163
+
141
164
  if (media.requires_permissions) {
142
165
  embedUrl.searchParams.set("ath", walletClient.AuthToken());
143
166
  }
167
+
144
168
  if (["video", "audio"].includes(mediaType)) {
145
169
  embedUrl.searchParams.set("vid", LinkTargetHash(media.media_link));
146
170
  embedUrl.searchParams.set("ct", "h");
@@ -150,6 +174,7 @@ var FormatNFTMetadata = function FormatNFTMetadata(walletClient, nft) {
150
174
  embedUrl.searchParams.set("vid", media.media_file["."].container);
151
175
  embedUrl.searchParams.set("murl", btoa(media.media_file.url));
152
176
  }
177
+
153
178
  return _objectSpread(_objectSpread({}, media), {}, {
154
179
  embed_url: embedUrl.toString()
155
180
  });
@@ -158,9 +183,9 @@ var FormatNFTMetadata = function FormatNFTMetadata(walletClient, nft) {
158
183
  return media;
159
184
  }
160
185
  });
161
- }
186
+ } // Generate embed URLs for pack opening animations
187
+
162
188
 
163
- // Generate embed URLs for pack opening animations
164
189
  ["open_animation", "open_animation__mobile", "reveal_animation", "reveal_animation_mobile"].forEach(function (key) {
165
190
  try {
166
191
  if (nft.metadata.pack_options && nft.metadata.pack_options[key]) {
@@ -169,28 +194,32 @@ var FormatNFTMetadata = function FormatNFTMetadata(walletClient, nft) {
169
194
  embedUrl.searchParams.set("net", walletClient.network === "demo" ? "demo" : "main");
170
195
  embedUrl.searchParams.set("vid", LinkTargetHash(nft.metadata.pack_options[key]));
171
196
  embedUrl.searchParams.set("ap", "");
197
+
172
198
  if (!key.startsWith("reveal")) {
173
199
  embedUrl.searchParams.set("m", "");
174
200
  embedUrl.searchParams.set("lp", "");
175
201
  }
202
+
176
203
  nft.metadata.pack_options["".concat(key, "_embed_url")] = embedUrl.toString();
177
- }
178
- // eslint-disable-next-line no-empty
204
+ } // eslint-disable-next-line no-empty
205
+
179
206
  } catch (error) {}
180
207
  });
181
208
  return nft;
182
209
  };
210
+
183
211
  exports.FormatNFTMetadata = FormatNFTMetadata;
212
+
184
213
  exports.FormatNFT = function (walletClient, item) {
185
214
  return FormatNFTMetadata(walletClient, FormatNFTDetails(item));
186
- };
215
+ }; // https://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen
216
+
187
217
 
188
- // https://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen
189
218
  var Popup = function Popup(_ref) {
190
219
  var url = _ref.url,
191
- title = _ref.title,
192
- w = _ref.w,
193
- h = _ref.h;
220
+ title = _ref.title,
221
+ w = _ref.w,
222
+ h = _ref.h;
194
223
  // Fixes dual-screen position
195
224
  var dualScreenLeft = window.screenLeft || window.screenX;
196
225
  var dualScreenTop = window.screenTop || window.screenY;
@@ -203,72 +232,89 @@ var Popup = function Popup(_ref) {
203
232
  if (window.focus) newWindow.focus();
204
233
  return newWindow;
205
234
  };
235
+
206
236
  exports.ActionPopup = /*#__PURE__*/function () {
207
237
  var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
208
238
  var _ref2$mode, mode, url, onMessage, onCancel;
239
+
209
240
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
210
- while (1) switch (_context3.prev = _context3.next) {
211
- case 0:
212
- _ref2$mode = _ref2.mode, mode = _ref2$mode === void 0 ? "tab" : _ref2$mode, url = _ref2.url, onMessage = _ref2.onMessage, onCancel = _ref2.onCancel;
213
- _context3.next = 3;
214
- return new Promise(function (resolve) {
215
- var newWindow = mode === "popup" ? Popup({
216
- url: url,
217
- title: "Eluvio Media Wallet",
218
- w: 500,
219
- h: 850
220
- }) : window.open(url);
221
- var closeCheck = setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
222
- return _regeneratorRuntime.wrap(function _callee$(_context) {
223
- while (1) switch (_context.prev = _context.next) {
224
- case 0:
225
- if (!newWindow.closed) {
226
- _context.next = 6;
227
- break;
228
- }
229
- clearInterval(closeCheck);
230
- if (!onCancel) {
231
- _context.next = 5;
232
- break;
233
- }
234
- _context.next = 5;
235
- return onCancel();
236
- case 5:
237
- resolve();
238
- case 6:
239
- case "end":
240
- return _context.stop();
241
- }
242
- }, _callee);
243
- })), 1000);
244
- window.addEventListener("message", /*#__PURE__*/function () {
245
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(event) {
246
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
247
- while (1) switch (_context2.prev = _context2.next) {
248
- case 0:
249
- _context2.next = 2;
250
- return onMessage(event, function () {
241
+ while (1) {
242
+ switch (_context3.prev = _context3.next) {
243
+ case 0:
244
+ _ref2$mode = _ref2.mode, mode = _ref2$mode === void 0 ? "tab" : _ref2$mode, url = _ref2.url, onMessage = _ref2.onMessage, onCancel = _ref2.onCancel;
245
+ _context3.next = 3;
246
+ return new Promise(function (resolve) {
247
+ var newWindow = mode === "popup" ? Popup({
248
+ url: url,
249
+ title: "Eluvio Media Wallet",
250
+ w: 500,
251
+ h: 850
252
+ }) : window.open(url);
253
+ var closeCheck = setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
254
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
255
+ while (1) {
256
+ switch (_context.prev = _context.next) {
257
+ case 0:
258
+ if (!newWindow.closed) {
259
+ _context.next = 6;
260
+ break;
261
+ }
262
+
251
263
  clearInterval(closeCheck);
252
- newWindow.close();
264
+
265
+ if (!onCancel) {
266
+ _context.next = 5;
267
+ break;
268
+ }
269
+
270
+ _context.next = 5;
271
+ return onCancel();
272
+
273
+ case 5:
253
274
  resolve();
254
- });
255
- case 2:
256
- case "end":
257
- return _context2.stop();
275
+
276
+ case 6:
277
+ case "end":
278
+ return _context.stop();
279
+ }
258
280
  }
259
- }, _callee2);
260
- }));
261
- return function (_x2) {
262
- return _ref5.apply(this, arguments);
263
- };
264
- }());
265
- });
266
- case 3:
267
- case "end":
268
- return _context3.stop();
281
+ }, _callee);
282
+ })), 1000);
283
+ window.addEventListener("message", /*#__PURE__*/function () {
284
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(event) {
285
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
286
+ while (1) {
287
+ switch (_context2.prev = _context2.next) {
288
+ case 0:
289
+ _context2.next = 2;
290
+ return onMessage(event, function () {
291
+ clearInterval(closeCheck);
292
+ newWindow.close();
293
+ resolve();
294
+ });
295
+
296
+ case 2:
297
+ case "end":
298
+ return _context2.stop();
299
+ }
300
+ }
301
+ }, _callee2);
302
+ }));
303
+
304
+ return function (_x2) {
305
+ return _ref5.apply(this, arguments);
306
+ };
307
+ }());
308
+ });
309
+
310
+ case 3:
311
+ case "end":
312
+ return _context3.stop();
313
+ }
269
314
  }
270
315
  }, _callee3);
271
316
  }));
317
+
272
318
  return function (_x) {
273
319
  return _ref3.apply(this, arguments);
274
320
  };