@eluvio/elv-client-js 3.2.4 → 3.2.5

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 (46) hide show
  1. package/dist/ElvClient-min.js +15 -11
  2. package/dist/ElvClient-node-min.js +17 -13
  3. package/dist/ElvFrameClient-min.js +12 -8
  4. package/dist/ElvPermissionsClient-min.js +13 -9
  5. package/dist/ElvWalletClient-min.js +58 -0
  6. package/dist/ElvWalletClient-node-min.js +78 -0
  7. package/dist/src/AuthorizationClient.js +2248 -1990
  8. package/dist/src/ContentObjectVerification.js +164 -173
  9. package/dist/src/Crypto.js +376 -324
  10. package/dist/src/ElvClient.js +1185 -1019
  11. package/dist/src/ElvWallet.js +119 -95
  12. package/dist/src/EthClient.js +1040 -896
  13. package/dist/src/FrameClient.js +331 -300
  14. package/dist/src/HttpClient.js +153 -147
  15. package/dist/src/Id.js +1 -3
  16. package/dist/src/PermissionsClient.js +1294 -1168
  17. package/dist/src/RemoteSigner.js +263 -211
  18. package/dist/src/UserProfileClient.js +1164 -1023
  19. package/dist/src/Utils.js +229 -184
  20. package/dist/src/client/ABRPublishing.js +895 -858
  21. package/dist/src/client/AccessGroups.js +1102 -959
  22. package/dist/src/client/ContentAccess.js +3724 -3431
  23. package/dist/src/client/ContentManagement.js +2252 -2068
  24. package/dist/src/client/Contracts.js +647 -563
  25. package/dist/src/client/Files.js +1886 -1757
  26. package/dist/src/client/NFT.js +126 -112
  27. package/dist/src/client/NTP.js +478 -422
  28. package/dist/src/index.js +11 -0
  29. package/dist/src/marketplaceClient/ClientMethods.js +1918 -0
  30. package/dist/src/marketplaceClient/Configuration.js +29 -0
  31. package/dist/src/marketplaceClient/Utils.js +304 -0
  32. package/dist/src/marketplaceClient/index.js +1553 -0
  33. package/dist/src/walletClient/ClientMethods.js +1978 -0
  34. package/dist/src/walletClient/Configuration.js +29 -0
  35. package/dist/src/walletClient/Utils.js +304 -0
  36. package/dist/src/walletClient/index.js +1571 -0
  37. package/package.json +8 -4
  38. package/src/ElvClient.js +4 -1
  39. package/src/Utils.js +22 -4
  40. package/src/index.js +7 -0
  41. package/src/walletClient/ClientMethods.js +1048 -0
  42. package/src/walletClient/Configuration.js +40 -0
  43. package/src/walletClient/README.md +185 -0
  44. package/src/walletClient/Utils.js +234 -0
  45. package/src/walletClient/index.js +884 -0
  46. package/testScripts/TestMarketplaceClient.js +25 -0
@@ -0,0 +1,29 @@
1
+ var WalletConfiguration = {
2
+ demo: {
3
+ configUrl: "https://demov3.net955210.contentfabric.io/config",
4
+ staging: {
5
+ siteId: "iq__2gkNh8CCZqFFnoRpEUmz7P3PaBQG",
6
+ purchaseMode: "develop",
7
+ appUrl: "https://core.test.contentfabric.io/wallet-demo"
8
+ }
9
+ },
10
+ main: {
11
+ configUrl: "https://main.net955305.contentfabric.io/config",
12
+ staging: {
13
+ siteId: "iq__inauxD1KLyKWPHargCWjdCh2ayr",
14
+ purchaseMode: "production",
15
+ appUrl: "https://core.test.contentfabric.io/wallet"
16
+ },
17
+ production: {
18
+ siteId: "iq__suqRJUt2vmXsyiWS5ZaSGwtFU9R",
19
+ purchaseMode: "production",
20
+ appUrl: "https://wallet.contentfabric.io"
21
+ }
22
+ },
23
+ __MARKETPLACE_ORDER: ["dolly-marketplace", "oc-marketplace", "maskverse-marketplace", "emp-marketplace", "marketplace-elevenation", "indieflix-marketplace", "angels-airwaves-marketplace"]
24
+ }; // No production environment on demo
25
+
26
+ WalletConfiguration.demo.production = WalletConfiguration.demo.staging; // Allow demo to be referred to as demov3
27
+
28
+ WalletConfiguration.demov3 = WalletConfiguration.demo;
29
+ module.exports = WalletConfiguration;
@@ -0,0 +1,304 @@
1
+ var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
+
3
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
+
5
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
6
+
7
+ var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
8
+
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
+
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
+
13
+ var Utils = require("../Utils");
14
+
15
+ var RarityToPercentage = function RarityToPercentage(rarity) {
16
+ if (!rarity) {
17
+ return "";
18
+ }
19
+
20
+ rarity = rarity.toString();
21
+
22
+ if (!rarity.includes("/")) {
23
+ return rarity;
24
+ }
25
+
26
+ var _rarity$split = rarity.split("/"),
27
+ _rarity$split2 = _slicedToArray(_rarity$split, 2),
28
+ numerator = _rarity$split2[0],
29
+ denominator = _rarity$split2[1];
30
+
31
+ var percentage = 100 * parseInt(numerator) / parseInt(denominator);
32
+
33
+ if (percentage < 1) {
34
+ percentage = percentage.toFixed(2);
35
+ } else {
36
+ percentage = percentage.toFixed(1).toString().replace(".0", "");
37
+ }
38
+
39
+ return percentage;
40
+ }; // Format NFT or listing result into consistent format
41
+
42
+
43
+ var FormatNFTDetails = function FormatNFTDetails(entry) {
44
+ var isListing = !!entry.id;
45
+ var metadata = (isListing ? entry.nft : entry.meta) || {};
46
+ var info = isListing ? entry.info : entry;
47
+ var details = {
48
+ USDCAccepted: !!(entry.accepts || []).find(function (entry) {
49
+ return entry.type === "sol";
50
+ }),
51
+ USDCOnly: ((entry.accepts || []).find(function (entry) {
52
+ return entry.type === "sol";
53
+ }) || {}).preferred,
54
+ TenantId: entry.tenant || entry.tenant_id,
55
+ ContractAddr: info.contract_addr,
56
+ ContractId: "ictr".concat(Utils.AddressToHash(info.contract_addr)),
57
+ ContractName: info.contract_name,
58
+ Cap: info.cap,
59
+ TokenIdStr: info.token_id_str,
60
+ TokenUri: info.token_uri,
61
+ TokenOrdinal: info.ordinal,
62
+ TokenHold: info.hold,
63
+ TokenHoldDate: info.hold ? new Date(parseInt(info.hold) * 1000) : undefined,
64
+ TokenOwner: info.token_owner ? Utils.FormatAddress(info.token_owner) : "",
65
+ VersionHash: (info.token_uri || "").split("/").find(function (s) {
66
+ return (s || "").startsWith("hq__");
67
+ })
68
+ };
69
+
70
+ if (isListing) {
71
+ details = _objectSpread(_objectSpread({}, details), {}, {
72
+ // Listing specific fields
73
+ ListingId: entry.id,
74
+ CreatedAt: entry.created * 1000,
75
+ UpdatedAt: entry.updated * 1000,
76
+ CheckoutLockedUntil: entry.checkout ? entry.checkout * 1000 : undefined,
77
+ SellerAddress: Utils.FormatAddress(entry.seller),
78
+ Price: entry.price,
79
+ Fee: entry.fee
80
+ });
81
+ }
82
+
83
+ return {
84
+ metadata: metadata,
85
+ details: details
86
+ };
87
+ };
88
+
89
+ exports.FormatNFTDetails = FormatNFTDetails;
90
+
91
+ var FormatNFTMetadata = function FormatNFTMetadata(nft) {
92
+ nft.formatted = true; // Surface relevant details to top level
93
+
94
+ nft.contractAddress = nft.details.ContractAddr;
95
+ nft.contractId = nft.details.ContractId;
96
+ nft.tokenId = nft.details.TokenIdStr;
97
+ nft.name = nft.metadata.display_name;
98
+
99
+ if (nft.details.ListingId) {
100
+ nft.listingId = nft.details.ListingId;
101
+ } // Format traits
102
+
103
+
104
+ var FILTERED_ATTRIBUTES = ["Content Fabric Hash", "Creator", "Total Minted Supply"];
105
+ nft.metadata.attributes = (nft.metadata.attributes || []).filter(function (attribute) {
106
+ return attribute && !FILTERED_ATTRIBUTES.includes(attribute.trait_type);
107
+ }).map(function (trait) {
108
+ return _objectSpread(_objectSpread({}, trait), {}, {
109
+ name: trait.trait_type,
110
+ rarity_percent: RarityToPercentage(trait.rarity)
111
+ });
112
+ }); // Generate embed URLs for additional media
113
+
114
+ if (nft.metadata.additional_media) {
115
+ nft.metadata.additional_media = nft.metadata.additional_media.map(function (media) {
116
+ try {
117
+ // Generate embed URLs for additional media
118
+ var mediaType = (media.media_type || "").toLowerCase();
119
+
120
+ if (mediaType === "image") {
121
+ return _objectSpread(_objectSpread({}, media), {}, {
122
+ embed_url: media.media_file.url
123
+ });
124
+ }
125
+
126
+ var embedUrl = new URL("https://embed.v3.contentfabric.io");
127
+ embedUrl.searchParams.set("p", "");
128
+ embedUrl.searchParams.set("net", rootStore.network === "demo" ? "demo" : "main");
129
+ embedUrl.searchParams.set("ath", rootStore.authToken);
130
+
131
+ if (mediaType === "video") {
132
+ embedUrl.searchParams.set("vid", LinkTargetHash(media.media_link));
133
+ embedUrl.searchParams.set("ct", "h");
134
+ embedUrl.searchParams.set("ap", "");
135
+ } else if (mediaType === "ebook") {
136
+ embedUrl.searchParams.set("type", "ebook");
137
+ embedUrl.searchParams.set("vid", media.media_file["."].container);
138
+ embedUrl.searchParams.set("murl", btoa(media.media_file.url));
139
+ }
140
+
141
+ return _objectSpread(_objectSpread({}, media), {}, {
142
+ embed_url: embedUrl.toString()
143
+ });
144
+ } catch (error) {
145
+ return media;
146
+ }
147
+ });
148
+ } // Generate embed URLs for pack opening animations
149
+
150
+
151
+ ["open_animation", "open_animation__mobile", "reveal_animation", "reveal_animation_mobile"].forEach(function (key) {
152
+ try {
153
+ if (nft.metadata.pack_options && nft.metadata.pack_options[key]) {
154
+ var embedUrl = new URL("https://embed.v3.contentfabric.io");
155
+ embedUrl.searchParams.set("p", "");
156
+ embedUrl.searchParams.set("net", rootStore.network === "demo" ? "demo" : "main");
157
+ embedUrl.searchParams.set("ath", rootStore.authToken || rootStore.staticToken);
158
+ embedUrl.searchParams.set("vid", LinkTargetHash(nft.metadata.pack_options[key]));
159
+ embedUrl.searchParams.set("ap", "");
160
+
161
+ if (!key.startsWith("reveal")) {
162
+ embedUrl.searchParams.set("m", "");
163
+ embedUrl.searchParams.set("lp", "");
164
+ }
165
+
166
+ nft.metadata.pack_options["".concat(key, "_embed_url")] = embedUrl.toString();
167
+ } // eslint-disable-next-line no-empty
168
+
169
+ } catch (error) {}
170
+ });
171
+ return nft;
172
+ };
173
+
174
+ exports.FormatNFTMetadata = FormatNFTMetadata;
175
+
176
+ exports.FormatNFT = function (item) {
177
+ return FormatNFTMetadata(FormatNFTDetails(item));
178
+ };
179
+
180
+ exports.LinkTargetHash = function (link) {
181
+ if (!link) {
182
+ return;
183
+ }
184
+
185
+ if (link["."] && link["."].source) {
186
+ return link["."].source;
187
+ }
188
+
189
+ if (link["/"] && link["/"].startsWith("/qfab/")) {
190
+ return link["/"].split("/").find(function (segment) {
191
+ return segment.startsWith("hq__");
192
+ });
193
+ }
194
+
195
+ if (link["."] && link["."].container) {
196
+ return link["."].container;
197
+ }
198
+ }; // https://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen
199
+
200
+
201
+ var Popup = function Popup(_ref) {
202
+ var url = _ref.url,
203
+ title = _ref.title,
204
+ w = _ref.w,
205
+ h = _ref.h;
206
+ // Fixes dual-screen position
207
+ var dualScreenLeft = window.screenLeft || window.screenX;
208
+ var dualScreenTop = window.screenTop || window.screenY;
209
+ var width = window.innerWidth || document.documentElement.clientWidth || screen.width;
210
+ var height = window.innerHeight || document.documentElement.clientHeight || screen.height;
211
+ var systemZoom = width / window.screen.availWidth;
212
+ var left = (width - w) / 2 / systemZoom + dualScreenLeft;
213
+ var top = (height - h) / 2 / systemZoom + dualScreenTop;
214
+ var newWindow = window.open(url, title, "\n width=".concat(w / systemZoom, ",\n height=").concat(h / systemZoom, ",\n top=").concat(top, ",\n left=").concat(left, "\n "));
215
+ if (window.focus) newWindow.focus();
216
+ return newWindow;
217
+ };
218
+
219
+ exports.ActionPopup = /*#__PURE__*/function () {
220
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
221
+ var _ref2$mode, mode, url, onMessage, onCancel;
222
+
223
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
224
+ while (1) {
225
+ switch (_context3.prev = _context3.next) {
226
+ case 0:
227
+ _ref2$mode = _ref2.mode, mode = _ref2$mode === void 0 ? "tab" : _ref2$mode, url = _ref2.url, onMessage = _ref2.onMessage, onCancel = _ref2.onCancel;
228
+ _context3.next = 3;
229
+ return new Promise(function (resolve) {
230
+ var newWindow = mode === "popup" ? Popup({
231
+ url: url,
232
+ title: "Eluvio Media Wallet",
233
+ w: 500,
234
+ h: 850
235
+ }) : window.open(url);
236
+ var closeCheck = setInterval( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee() {
237
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
238
+ while (1) {
239
+ switch (_context.prev = _context.next) {
240
+ case 0:
241
+ if (!newWindow.closed) {
242
+ _context.next = 6;
243
+ break;
244
+ }
245
+
246
+ clearInterval(closeCheck);
247
+
248
+ if (!onCancel) {
249
+ _context.next = 5;
250
+ break;
251
+ }
252
+
253
+ _context.next = 5;
254
+ return onCancel();
255
+
256
+ case 5:
257
+ resolve();
258
+
259
+ case 6:
260
+ case "end":
261
+ return _context.stop();
262
+ }
263
+ }
264
+ }, _callee);
265
+ })), 500);
266
+ window.addEventListener("message", /*#__PURE__*/function () {
267
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(event) {
268
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
269
+ while (1) {
270
+ switch (_context2.prev = _context2.next) {
271
+ case 0:
272
+ _context2.next = 2;
273
+ return onMessage(event, function () {
274
+ clearInterval(closeCheck);
275
+ newWindow.close();
276
+ resolve();
277
+ });
278
+
279
+ case 2:
280
+ case "end":
281
+ return _context2.stop();
282
+ }
283
+ }
284
+ }, _callee2);
285
+ }));
286
+
287
+ return function (_x2) {
288
+ return _ref5.apply(this, arguments);
289
+ };
290
+ }());
291
+ });
292
+
293
+ case 3:
294
+ case "end":
295
+ return _context3.stop();
296
+ }
297
+ }
298
+ }, _callee3);
299
+ }));
300
+
301
+ return function (_x) {
302
+ return _ref3.apply(this, arguments);
303
+ };
304
+ }();