@eluvio/elv-client-js 4.0.4 → 4.0.6
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.
- package/dist/ElvClient-min.js +12 -11
- package/dist/ElvClient-node-min.js +12 -17
- package/dist/ElvFrameClient-min.js +12 -11
- package/dist/ElvPermissionsClient-min.js +10 -9
- package/dist/ElvWalletClient-min.js +11 -10
- package/dist/ElvWalletClient-node-min.js +12 -17
- package/dist/src/AuthorizationClient.js +1556 -2077
- package/dist/src/ContentObjectVerification.js +134 -185
- package/dist/src/Crypto.js +225 -322
- package/dist/src/ElvClient.js +823 -1117
- package/dist/src/ElvWallet.js +64 -106
- package/dist/src/EthClient.js +719 -974
- package/dist/src/FrameClient.js +222 -318
- package/dist/src/HttpClient.js +112 -154
- package/dist/src/Id.js +1 -6
- package/dist/src/LogMessage.js +4 -8
- package/dist/src/PermissionsClient.js +973 -1271
- package/dist/src/RemoteSigner.js +161 -232
- package/dist/src/UserProfileClient.js +781 -1038
- package/dist/src/Utils.js +160 -302
- package/dist/src/Validation.js +2 -17
- package/dist/src/client/ABRPublishing.js +772 -942
- package/dist/src/client/AccessGroups.js +849 -1095
- package/dist/src/client/ContentAccess.js +3263 -4132
- package/dist/src/client/ContentManagement.js +1811 -2283
- package/dist/src/client/Contracts.js +468 -614
- package/dist/src/client/Files.js +1505 -1845
- package/dist/src/client/NFT.js +94 -116
- package/dist/src/client/NTP.js +326 -425
- package/dist/src/index.js +2 -5
- package/dist/src/walletClient/ClientMethods.js +1412 -1551
- package/dist/src/walletClient/Configuration.js +4 -2
- package/dist/src/walletClient/Notifications.js +98 -127
- package/dist/src/walletClient/Profile.js +184 -246
- package/dist/src/walletClient/Utils.js +76 -122
- package/dist/src/walletClient/index.js +1169 -1493
- package/package.json +3 -2
- package/src/Crypto.js +1 -1
- package/src/ElvClient.js +1 -3
- package/src/Utils.js +1 -1
- package/src/walletClient/ClientMethods.js +133 -11
- package/src/walletClient/index.js +1 -0
- package/testScripts/Test.js +0 -1
- package/utilities/NFTIngest.js +527 -0
- package/utilities/lib/concerns/LocalFile.js +2 -1
|
@@ -1,66 +1,49 @@
|
|
|
1
1
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
2
|
-
|
|
3
2
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
4
|
-
|
|
5
3
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
6
|
-
|
|
7
4
|
var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
|
|
8
|
-
|
|
9
5
|
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
6
|
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
7
|
var Utils = require("../Utils");
|
|
14
|
-
|
|
15
8
|
var RarityToPercentage = function RarityToPercentage(rarity) {
|
|
16
9
|
if (!rarity) {
|
|
17
10
|
return "";
|
|
18
11
|
}
|
|
19
|
-
|
|
20
12
|
rarity = rarity.toString();
|
|
21
|
-
|
|
22
13
|
if (!rarity.includes("/")) {
|
|
23
14
|
return rarity;
|
|
24
15
|
}
|
|
25
|
-
|
|
26
16
|
var _rarity$split = rarity.split("/"),
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
17
|
+
_rarity$split2 = _slicedToArray(_rarity$split, 2),
|
|
18
|
+
numerator = _rarity$split2[0],
|
|
19
|
+
denominator = _rarity$split2[1];
|
|
31
20
|
var percentage = 100 * parseInt(numerator) / parseInt(denominator);
|
|
32
|
-
|
|
33
21
|
if (percentage < 1) {
|
|
34
22
|
percentage = percentage.toFixed(2);
|
|
35
23
|
} else {
|
|
36
24
|
percentage = percentage.toFixed(1).toString().replace(".0", "");
|
|
37
25
|
}
|
|
38
|
-
|
|
39
26
|
return percentage;
|
|
40
27
|
};
|
|
41
|
-
|
|
42
28
|
var LinkTargetHash = function LinkTargetHash(link) {
|
|
43
29
|
if (!link) {
|
|
44
30
|
return;
|
|
45
31
|
}
|
|
46
|
-
|
|
47
32
|
if (link["."] && link["."].source) {
|
|
48
33
|
return link["."].source;
|
|
49
34
|
}
|
|
50
|
-
|
|
51
35
|
if (link["/"] && link["/"].startsWith("/qfab/")) {
|
|
52
36
|
return link["/"].split("/").find(function (segment) {
|
|
53
37
|
return segment.startsWith("hq__");
|
|
54
38
|
});
|
|
55
39
|
}
|
|
56
|
-
|
|
57
40
|
if (link["."] && link["."].container) {
|
|
58
41
|
return link["."].container;
|
|
59
42
|
}
|
|
60
43
|
};
|
|
44
|
+
exports.LinkTargetHash = LinkTargetHash;
|
|
61
45
|
|
|
62
|
-
|
|
63
|
-
|
|
46
|
+
// Format NFT or listing result into consistent format
|
|
64
47
|
var FormatNFTDetails = function FormatNFTDetails(entry) {
|
|
65
48
|
var isListing = !!entry.id;
|
|
66
49
|
var metadata = (isListing ? entry.nft : entry.meta) || {};
|
|
@@ -98,7 +81,6 @@ var FormatNFTDetails = function FormatNFTDetails(entry) {
|
|
|
98
81
|
return (s || "").startsWith("hq__");
|
|
99
82
|
})
|
|
100
83
|
};
|
|
101
|
-
|
|
102
84
|
if (isListing) {
|
|
103
85
|
details = _objectSpread(_objectSpread({}, details), {}, {
|
|
104
86
|
// Listing specific fields
|
|
@@ -113,28 +95,25 @@ var FormatNFTDetails = function FormatNFTDetails(entry) {
|
|
|
113
95
|
} else {
|
|
114
96
|
details.Offers = info.offers || [];
|
|
115
97
|
}
|
|
116
|
-
|
|
117
98
|
return {
|
|
118
99
|
metadata: metadata,
|
|
119
100
|
details: details
|
|
120
101
|
};
|
|
121
102
|
};
|
|
122
|
-
|
|
123
103
|
exports.FormatNFTDetails = FormatNFTDetails;
|
|
124
|
-
|
|
125
104
|
var FormatNFTMetadata = function FormatNFTMetadata(walletClient, nft) {
|
|
126
|
-
nft.formatted = true;
|
|
105
|
+
nft.formatted = true;
|
|
127
106
|
|
|
107
|
+
// Surface relevant details to top level
|
|
128
108
|
nft.contractAddress = nft.details.ContractAddr;
|
|
129
109
|
nft.contractId = nft.details.ContractId;
|
|
130
110
|
nft.tokenId = nft.details.TokenIdStr;
|
|
131
111
|
nft.name = nft.metadata.display_name;
|
|
132
|
-
|
|
133
112
|
if (nft.details.ListingId) {
|
|
134
113
|
nft.listingId = nft.details.ListingId;
|
|
135
|
-
}
|
|
136
|
-
|
|
114
|
+
}
|
|
137
115
|
|
|
116
|
+
// Format traits
|
|
138
117
|
var FILTERED_ATTRIBUTES = ["Content Fabric Hash", "Creator", "Total Minted Supply"];
|
|
139
118
|
nft.metadata.attributes = (nft.metadata.attributes || []).filter(function (attribute) {
|
|
140
119
|
return attribute && !FILTERED_ATTRIBUTES.includes(attribute.trait_type);
|
|
@@ -143,28 +122,25 @@ var FormatNFTMetadata = function FormatNFTMetadata(walletClient, nft) {
|
|
|
143
122
|
name: trait.trait_type,
|
|
144
123
|
rarity_percent: RarityToPercentage(trait.rarity)
|
|
145
124
|
});
|
|
146
|
-
});
|
|
125
|
+
});
|
|
147
126
|
|
|
127
|
+
// Generate embed URLs for additional media
|
|
148
128
|
if (nft.metadata.additional_media) {
|
|
149
129
|
nft.metadata.additional_media = nft.metadata.additional_media.map(function (media) {
|
|
150
130
|
try {
|
|
151
131
|
// Generate embed URLs for additional media
|
|
152
132
|
var mediaType = (media.media_type || "").toLowerCase();
|
|
153
|
-
|
|
154
133
|
if (mediaType === "image") {
|
|
155
134
|
return _objectSpread(_objectSpread({}, media), {}, {
|
|
156
135
|
embed_url: media.media_file.url
|
|
157
136
|
});
|
|
158
137
|
}
|
|
159
|
-
|
|
160
138
|
var embedUrl = new URL("https://embed.v3.contentfabric.io");
|
|
161
139
|
embedUrl.searchParams.set("p", "");
|
|
162
140
|
embedUrl.searchParams.set("net", walletClient.network === "demo" ? "demo" : "main");
|
|
163
|
-
|
|
164
141
|
if (media.requires_permissions) {
|
|
165
142
|
embedUrl.searchParams.set("ath", walletClient.AuthToken());
|
|
166
143
|
}
|
|
167
|
-
|
|
168
144
|
if (["video", "audio"].includes(mediaType)) {
|
|
169
145
|
embedUrl.searchParams.set("vid", LinkTargetHash(media.media_link));
|
|
170
146
|
embedUrl.searchParams.set("ct", "h");
|
|
@@ -174,7 +150,6 @@ var FormatNFTMetadata = function FormatNFTMetadata(walletClient, nft) {
|
|
|
174
150
|
embedUrl.searchParams.set("vid", media.media_file["."].container);
|
|
175
151
|
embedUrl.searchParams.set("murl", btoa(media.media_file.url));
|
|
176
152
|
}
|
|
177
|
-
|
|
178
153
|
return _objectSpread(_objectSpread({}, media), {}, {
|
|
179
154
|
embed_url: embedUrl.toString()
|
|
180
155
|
});
|
|
@@ -183,9 +158,9 @@ var FormatNFTMetadata = function FormatNFTMetadata(walletClient, nft) {
|
|
|
183
158
|
return media;
|
|
184
159
|
}
|
|
185
160
|
});
|
|
186
|
-
}
|
|
187
|
-
|
|
161
|
+
}
|
|
188
162
|
|
|
163
|
+
// Generate embed URLs for pack opening animations
|
|
189
164
|
["open_animation", "open_animation__mobile", "reveal_animation", "reveal_animation_mobile"].forEach(function (key) {
|
|
190
165
|
try {
|
|
191
166
|
if (nft.metadata.pack_options && nft.metadata.pack_options[key]) {
|
|
@@ -194,32 +169,28 @@ var FormatNFTMetadata = function FormatNFTMetadata(walletClient, nft) {
|
|
|
194
169
|
embedUrl.searchParams.set("net", walletClient.network === "demo" ? "demo" : "main");
|
|
195
170
|
embedUrl.searchParams.set("vid", LinkTargetHash(nft.metadata.pack_options[key]));
|
|
196
171
|
embedUrl.searchParams.set("ap", "");
|
|
197
|
-
|
|
198
172
|
if (!key.startsWith("reveal")) {
|
|
199
173
|
embedUrl.searchParams.set("m", "");
|
|
200
174
|
embedUrl.searchParams.set("lp", "");
|
|
201
175
|
}
|
|
202
|
-
|
|
203
176
|
nft.metadata.pack_options["".concat(key, "_embed_url")] = embedUrl.toString();
|
|
204
|
-
}
|
|
205
|
-
|
|
177
|
+
}
|
|
178
|
+
// eslint-disable-next-line no-empty
|
|
206
179
|
} catch (error) {}
|
|
207
180
|
});
|
|
208
181
|
return nft;
|
|
209
182
|
};
|
|
210
|
-
|
|
211
183
|
exports.FormatNFTMetadata = FormatNFTMetadata;
|
|
212
|
-
|
|
213
184
|
exports.FormatNFT = function (walletClient, item) {
|
|
214
185
|
return FormatNFTMetadata(walletClient, FormatNFTDetails(item));
|
|
215
|
-
};
|
|
216
|
-
|
|
186
|
+
};
|
|
217
187
|
|
|
188
|
+
// https://stackoverflow.com/questions/4068373/center-a-popup-window-on-screen
|
|
218
189
|
var Popup = function Popup(_ref) {
|
|
219
190
|
var url = _ref.url,
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
191
|
+
title = _ref.title,
|
|
192
|
+
w = _ref.w,
|
|
193
|
+
h = _ref.h;
|
|
223
194
|
// Fixes dual-screen position
|
|
224
195
|
var dualScreenLeft = window.screenLeft || window.screenX;
|
|
225
196
|
var dualScreenTop = window.screenTop || window.screenY;
|
|
@@ -232,89 +203,72 @@ var Popup = function Popup(_ref) {
|
|
|
232
203
|
if (window.focus) newWindow.focus();
|
|
233
204
|
return newWindow;
|
|
234
205
|
};
|
|
235
|
-
|
|
236
206
|
exports.ActionPopup = /*#__PURE__*/function () {
|
|
237
207
|
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
|
|
238
208
|
var _ref2$mode, mode, url, onMessage, onCancel;
|
|
239
|
-
|
|
240
209
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
241
|
-
while (1) {
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
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 () {
|
|
263
251
|
clearInterval(closeCheck);
|
|
264
|
-
|
|
265
|
-
if (!onCancel) {
|
|
266
|
-
_context.next = 5;
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
|
|
270
|
-
_context.next = 5;
|
|
271
|
-
return onCancel();
|
|
272
|
-
|
|
273
|
-
case 5:
|
|
252
|
+
newWindow.close();
|
|
274
253
|
resolve();
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
}
|
|
254
|
+
});
|
|
255
|
+
case 2:
|
|
256
|
+
case "end":
|
|
257
|
+
return _context2.stop();
|
|
280
258
|
}
|
|
281
|
-
},
|
|
282
|
-
}))
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
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
|
-
}
|
|
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();
|
|
314
269
|
}
|
|
315
270
|
}, _callee3);
|
|
316
271
|
}));
|
|
317
|
-
|
|
318
272
|
return function (_x) {
|
|
319
273
|
return _ref3.apply(this, arguments);
|
|
320
274
|
};
|