@eluvio/elv-client-js 4.0.11 → 4.0.13

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 (111) hide show
  1. package/dist/.keep +0 -0
  2. package/dist/ElvClient-min.js +11 -10
  3. package/dist/ElvClient-node-min.js +11 -10
  4. package/dist/ElvFrameClient-min.js +11 -10
  5. package/dist/ElvPermissionsClient-min.js +10 -9
  6. package/dist/ElvWalletClient-min.js +10 -9
  7. package/dist/ElvWalletClient-node-min.js +10 -9
  8. package/dist/src/AuthorizationClient.js +1555 -2076
  9. package/dist/src/ContentObjectVerification.js +134 -185
  10. package/dist/src/Crypto.js +224 -319
  11. package/dist/src/ElvClient.js +822 -1114
  12. package/dist/src/ElvWallet.js +64 -106
  13. package/dist/src/EthClient.js +719 -974
  14. package/dist/src/FrameClient.js +223 -319
  15. package/dist/src/HttpClient.js +117 -156
  16. package/dist/src/Id.js +1 -6
  17. package/dist/src/LogMessage.js +4 -8
  18. package/dist/src/PermissionsClient.js +973 -1271
  19. package/dist/src/RemoteSigner.js +161 -232
  20. package/dist/src/UserProfileClient.js +781 -1038
  21. package/dist/src/Utils.js +159 -299
  22. package/dist/src/Validation.js +2 -17
  23. package/dist/src/client/ABRPublishing.js +828 -958
  24. package/dist/src/client/AccessGroups.js +849 -1095
  25. package/dist/src/client/ContentAccess.js +3323 -4195
  26. package/dist/src/client/ContentManagement.js +1818 -2290
  27. package/dist/src/client/Contracts.js +468 -614
  28. package/dist/src/client/Files.js +1506 -1846
  29. package/dist/src/client/NFT.js +94 -116
  30. package/dist/src/client/NTP.js +326 -425
  31. package/dist/src/index.js +2 -5
  32. package/dist/src/walletClient/ClientMethods.js +1368 -1763
  33. package/dist/src/walletClient/Configuration.js +5 -3
  34. package/dist/src/walletClient/Notifications.js +98 -127
  35. package/dist/src/walletClient/Profile.js +184 -246
  36. package/dist/src/walletClient/Utils.js +76 -122
  37. package/dist/src/walletClient/index.js +1171 -1496
  38. package/package.json +4 -21
  39. package/src/FrameClient.js +1 -0
  40. package/src/HttpClient.js +4 -2
  41. package/src/client/ABRPublishing.js +126 -105
  42. package/src/client/ContentAccess.js +1 -0
  43. package/src/client/ContentManagement.js +4 -2
  44. package/src/walletClient/Configuration.js +3 -2
  45. package/dist/AccessClient-min.js +0 -54
  46. package/dist/AccessClient-node-min.js +0 -74
  47. package/dist/src/AccessClient.js +0 -798
  48. package/dist/src/LimitedMap.js +0 -120
  49. package/dist/src/client/Access.js +0 -1
  50. package/dist/src/client/Management.js +0 -1606
  51. package/dist/src/contracts/AccessIndexor.js +0 -831
  52. package/dist/src/contracts/Accessible.js +0 -31
  53. package/dist/src/contracts/AdmgrAdvertisement.js +0 -695
  54. package/dist/src/contracts/AdmgrCampaign.js +0 -648
  55. package/dist/src/contracts/AdmgrCampaignManager.js +0 -493
  56. package/dist/src/contracts/AdmgrCommercialOffering.js +0 -622
  57. package/dist/src/contracts/AdmgrCommercialOfferingManager.js +0 -413
  58. package/dist/src/contracts/AdmgrMarketPlace.js +0 -413
  59. package/dist/src/contracts/AvailsDelivery.js +0 -535
  60. package/dist/src/contracts/BaseAccessControlGroup.js +0 -1221
  61. package/dist/src/contracts/BaseAccessWallet.js +0 -1575
  62. package/dist/src/contracts/BaseAccessWalletFactory.js +0 -93
  63. package/dist/src/contracts/BaseContent.js +0 -1104
  64. package/dist/src/contracts/BaseContentFactory.js +0 -99
  65. package/dist/src/contracts/BaseContentFactoryExt.js +0 -219
  66. package/dist/src/contracts/BaseContentSpace.js +0 -1346
  67. package/dist/src/contracts/BaseContentType.js +0 -353
  68. package/dist/src/contracts/BaseFactory.js +0 -107
  69. package/dist/src/contracts/BaseGroupFactory.js +0 -93
  70. package/dist/src/contracts/BaseLibrary.js +0 -1035
  71. package/dist/src/contracts/BaseLibraryFactory.js +0 -96
  72. package/dist/src/contracts/Certifyer.js +0 -87
  73. package/dist/src/contracts/Container.js +0 -543
  74. package/dist/src/contracts/Content.js +0 -432
  75. package/dist/src/contracts/Editable.js +0 -295
  76. package/dist/src/contracts/FactorySpace.js +0 -57
  77. package/dist/src/contracts/KmsSpace.js +0 -52
  78. package/dist/src/contracts/LvProvider.js +0 -512
  79. package/dist/src/contracts/LvRecordableStream.js +0 -1026
  80. package/dist/src/contracts/LvRecording.js +0 -627
  81. package/dist/src/contracts/LvStreamRightsHolder.js +0 -551
  82. package/dist/src/contracts/MetaObject.js +0 -110
  83. package/dist/src/contracts/Node.js +0 -167
  84. package/dist/src/contracts/NodeSpace.js +0 -18
  85. package/dist/src/contracts/NodeSpaceImpl.js +0 -273
  86. package/dist/src/contracts/Ownable.js +0 -87
  87. package/dist/src/contracts/PaymentService.js +0 -616
  88. package/dist/src/contracts/Precompile.js +0 -15
  89. package/dist/src/contracts/SampleContentAdMarketplace.js +0 -564
  90. package/dist/src/contracts/SampleContentAdvertising.js +0 -444
  91. package/dist/src/contracts/SampleContentHelloWorld.js +0 -459
  92. package/dist/src/contracts/SampleContentLicensing.js +0 -618
  93. package/dist/src/contracts/SampleContentSigned.js +0 -447
  94. package/dist/src/contracts/SampleInstance.js +0 -438
  95. package/dist/src/contracts/SampleInstanceFactory.js +0 -451
  96. package/dist/src/contracts/Transactable.js +0 -82
  97. package/dist/src/contracts/UserSpace.js +0 -18
  98. package/dist/src/contracts/UserSpaceImpl.js +0 -43
  99. package/dist/src/contracts/Utils.js +0 -18
  100. package/dist/src/contracts/Verifier.js +0 -53
  101. package/dist/src/contracts/strings.js +0 -4
  102. package/dist/src/contracts/v2/BaseContentFactoryExt.js +0 -219
  103. package/dist/src/contracts/v2/FactorySpace.js +0 -57
  104. package/dist/src/contracts/v2/KmsSpace.js +0 -52
  105. package/dist/src/contracts/v2/NodeSpaceImpl.js +0 -273
  106. package/dist/src/contracts/v2/UserSpaceImpl.js +0 -43
  107. package/dist/src/marketplaceClient/ClientMethods.js +0 -1918
  108. package/dist/src/marketplaceClient/Configuration.js +0 -29
  109. package/dist/src/marketplaceClient/Utils.js +0 -304
  110. package/dist/src/marketplaceClient/index.js +0 -1553
  111. package/utilities/ListAccessGroups.js +0 -34
@@ -1,70 +1,51 @@
1
1
  var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
2
-
3
2
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4
-
5
3
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
6
-
7
4
  var _typeof = require("@babel/runtime/helpers/typeof");
8
-
9
5
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
10
-
11
6
  var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
12
-
13
7
  var _createClass = require("@babel/runtime/helpers/createClass");
14
-
15
8
  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; }
16
-
17
9
  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; }
18
-
19
10
  var _require = require("../ElvClient"),
20
- ElvClient = _require.ElvClient;
21
-
11
+ ElvClient = _require.ElvClient;
22
12
  var Configuration = require("./Configuration");
23
-
24
13
  var _require2 = require("./Utils"),
25
- LinkTargetHash = _require2.LinkTargetHash,
26
- FormatNFT = _require2.FormatNFT,
27
- ActionPopup = _require2.ActionPopup;
28
-
14
+ LinkTargetHash = _require2.LinkTargetHash,
15
+ FormatNFT = _require2.FormatNFT,
16
+ ActionPopup = _require2.ActionPopup;
29
17
  var HTTPClient = require("../HttpClient");
30
-
31
18
  var UrlJoin = require("url-join");
32
-
33
19
  var Utils = require("../Utils");
34
-
35
20
  var Ethers = require("ethers");
36
-
37
21
  var inBrowser = typeof window !== "undefined";
38
22
  var embedded = inBrowser && window.top !== window.self;
39
23
  var localStorageAvailable = false;
40
-
41
24
  try {
42
25
  typeof localStorage !== "undefined" && localStorage.getItem("test");
43
- localStorageAvailable = true; // eslint-disable-next-line no-empty
26
+ localStorageAvailable = true;
27
+ // eslint-disable-next-line no-empty
44
28
  } catch (error) {}
29
+
45
30
  /**
46
31
  * Use the <a href="#.Initialize">Initialize</a> method to initialize a new client.
47
32
  *
48
33
  *
49
34
  * See the Modules section on the sidebar for all client methods unrelated to login and authorization
50
35
  */
51
-
52
-
53
36
  var ElvWalletClient = /*#__PURE__*/function () {
54
37
  "use strict";
55
38
 
56
39
  function ElvWalletClient(_ref) {
57
40
  var appId = _ref.appId,
58
- client = _ref.client,
59
- network = _ref.network,
60
- mode = _ref.mode,
61
- localization = _ref.localization,
62
- marketplaceInfo = _ref.marketplaceInfo,
63
- previewMarketplaceHash = _ref.previewMarketplaceHash,
64
- storeAuthToken = _ref.storeAuthToken;
65
-
41
+ client = _ref.client,
42
+ network = _ref.network,
43
+ mode = _ref.mode,
44
+ localization = _ref.localization,
45
+ marketplaceInfo = _ref.marketplaceInfo,
46
+ previewMarketplaceHash = _ref.previewMarketplaceHash,
47
+ storeAuthToken = _ref.storeAuthToken;
66
48
  _classCallCheck(this, ElvWalletClient);
67
-
68
49
  this.appId = appId;
69
50
  this.client = client;
70
51
  this.loggedIn = false;
@@ -86,19 +67,18 @@ var ElvWalletClient = /*#__PURE__*/function () {
86
67
  this.stateStoreUrls = Configuration[network].stateStoreUrls;
87
68
  this.stateStoreClient = new HTTPClient({
88
69
  uris: this.stateStoreUrls
89
- }); // Caches
70
+ });
90
71
 
72
+ // Caches
91
73
  this.cachedMarketplaces = {};
92
74
  this.cachedCSS = {};
93
75
  this.utils = client.utils;
94
76
  }
95
-
96
77
  _createClass(ElvWalletClient, [{
97
78
  key: "Log",
98
79
  value: function Log(message) {
99
80
  var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
100
81
  var errorObject = arguments.length > 2 ? arguments[2] : undefined;
101
-
102
82
  if (error) {
103
83
  // eslint-disable-next-line no-console
104
84
  console.error("Eluvio Wallet Client:", message);
@@ -106,12 +86,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
106
86
  // eslint-disable-next-line no-console
107
87
  console.log("Eluvio Wallet Client:", message);
108
88
  }
109
-
110
89
  if (errorObject) {
111
90
  // eslint-disable-next-line no-console
112
91
  console.error(errorObject);
113
92
  }
114
93
  }
94
+
115
95
  /**
116
96
  * Initialize the wallet client.
117
97
  *
@@ -129,11 +109,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
129
109
  *
130
110
  * @returns {Promise<ElvWalletClient>}
131
111
  */
132
-
133
112
  }, {
134
113
  key: "CanSign",
135
- value:
136
- /* Login and authorization */
114
+ value: /* Login and authorization */
137
115
 
138
116
  /**
139
117
  * Check if this client can sign without opening a popup.
@@ -147,9 +125,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
147
125
  if (!this.loggedIn) {
148
126
  return false;
149
127
  }
150
-
151
128
  return !!this.__authorization.clusterToken || inBrowser && !!(this.UserInfo().walletName.toLowerCase() === "metamask" && window.ethereum && window.ethereum.isMetaMask && window.ethereum.chainId);
152
129
  }
130
+
153
131
  /**
154
132
  * <b><i>Requires login</i></b>
155
133
  *
@@ -167,169 +145,136 @@ var ElvWalletClient = /*#__PURE__*/function () {
167
145
  *
168
146
  * @returns {Promise<string>} - The signature of the message
169
147
  */
170
-
171
148
  }, {
172
149
  key: "PersonalSign",
173
150
  value: function () {
174
151
  var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
175
152
  var message, parameters, url;
176
153
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
177
- while (1) {
178
- switch (_context3.prev = _context3.next) {
179
- case 0:
180
- message = _ref2.message;
181
-
182
- if (this.loggedIn) {
183
- _context3.next = 3;
184
- break;
185
- }
186
-
187
- throw Error("ElvWalletClient: Unable to perform signature - Not logged in");
188
-
189
- case 3:
190
- if (!this.CanSign()) {
191
- _context3.next = 19;
192
- break;
193
- }
194
-
195
- if (!this.__authorization.clusterToken) {
196
- _context3.next = 12;
197
- break;
198
- }
199
-
200
- // Custodial wallet sign
201
- message = _typeof(message) === "object" ? JSON.stringify(message) : message;
202
- message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
203
- _context3.next = 9;
204
- return this.client.authClient.Sign(message);
205
-
206
- case 9:
207
- return _context3.abrupt("return", _context3.sent);
208
-
209
- case 12:
210
- if (!(this.UserInfo().walletName.toLowerCase() === "metamask")) {
211
- _context3.next = 16;
212
- break;
213
- }
214
-
215
- return _context3.abrupt("return", this.SignMetamask({
216
- message: message,
217
- address: this.UserAddress()
218
- }));
219
-
220
- case 16:
221
- throw Error("ElvWalletClient: Unable to sign");
222
-
223
- case 17:
154
+ while (1) switch (_context3.prev = _context3.next) {
155
+ case 0:
156
+ message = _ref2.message;
157
+ if (this.loggedIn) {
158
+ _context3.next = 3;
159
+ break;
160
+ }
161
+ throw Error("ElvWalletClient: Unable to perform signature - Not logged in");
162
+ case 3:
163
+ if (!this.CanSign()) {
164
+ _context3.next = 19;
165
+ break;
166
+ }
167
+ if (!this.__authorization.clusterToken) {
168
+ _context3.next = 12;
169
+ break;
170
+ }
171
+ // Custodial wallet sign
172
+
173
+ message = _typeof(message) === "object" ? JSON.stringify(message) : message;
174
+ message = Ethers.utils.keccak256(Buffer.from("\x19Ethereum Signed Message:\n".concat(message.length).concat(message), "utf-8"));
175
+ _context3.next = 9;
176
+ return this.client.authClient.Sign(message);
177
+ case 9:
178
+ return _context3.abrupt("return", _context3.sent);
179
+ case 12:
180
+ if (!(this.UserInfo().walletName.toLowerCase() === "metamask")) {
181
+ _context3.next = 16;
182
+ break;
183
+ }
184
+ return _context3.abrupt("return", this.SignMetamask({
185
+ message: message,
186
+ address: this.UserAddress()
187
+ }));
188
+ case 16:
189
+ throw Error("ElvWalletClient: Unable to sign");
190
+ case 17:
191
+ _context3.next = 21;
192
+ break;
193
+ case 19:
194
+ if (inBrowser) {
224
195
  _context3.next = 21;
225
196
  break;
226
-
227
- case 19:
228
- if (inBrowser) {
229
- _context3.next = 21;
230
- break;
231
- }
232
-
233
- throw Error("ElvWalletClient: Unable to sign");
234
-
235
- case 21:
236
- parameters = {
237
- action: "personal-sign",
238
- message: message,
239
- logIn: true
240
- };
241
- url = new URL(this.appUrl);
242
- url.hash = UrlJoin("/action", "sign", Utils.B58(JSON.stringify(parameters)));
243
- url.searchParams.set("origin", window.location.origin);
244
-
245
- if (!(!embedded && window.location.origin === url.origin)) {
246
- _context3.next = 27;
247
- break;
248
- }
249
-
250
- throw Error("ElvWalletClient: Unable to sign");
251
-
252
- case 27:
253
- _context3.next = 29;
254
- return new Promise( /*#__PURE__*/function () {
255
- var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve, reject) {
256
- return _regeneratorRuntime.wrap(function _callee2$(_context2) {
257
- while (1) {
258
- switch (_context2.prev = _context2.next) {
259
- case 0:
260
- _context2.next = 2;
261
- return ActionPopup({
262
- mode: "tab",
263
- url: url.toString(),
264
- onCancel: function onCancel() {
265
- return reject("User cancelled sign");
266
- },
267
- onMessage: function () {
268
- var _onMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event, Close) {
269
- return _regeneratorRuntime.wrap(function _callee$(_context) {
270
- while (1) {
271
- switch (_context.prev = _context.next) {
272
- case 0:
273
- if (!(!event || !event.data || event.data.type !== "FlowResponse")) {
274
- _context.next = 2;
275
- break;
276
- }
277
-
278
- return _context.abrupt("return");
279
-
280
- case 2:
281
- try {
282
- resolve(event.data.response);
283
- } catch (error) {
284
- reject(error);
285
- } finally {
286
- Close();
287
- }
288
-
289
- case 3:
290
- case "end":
291
- return _context.stop();
292
- }
197
+ }
198
+ throw Error("ElvWalletClient: Unable to sign");
199
+ case 21:
200
+ parameters = {
201
+ action: "personal-sign",
202
+ message: message,
203
+ logIn: true
204
+ };
205
+ url = new URL(this.appUrl);
206
+ url.hash = UrlJoin("/action", "sign", Utils.B58(JSON.stringify(parameters)));
207
+ url.searchParams.set("origin", window.location.origin);
208
+ if (!(!embedded && window.location.origin === url.origin)) {
209
+ _context3.next = 27;
210
+ break;
211
+ }
212
+ throw Error("ElvWalletClient: Unable to sign");
213
+ case 27:
214
+ _context3.next = 29;
215
+ return new Promise( /*#__PURE__*/function () {
216
+ var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(resolve, reject) {
217
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
218
+ while (1) switch (_context2.prev = _context2.next) {
219
+ case 0:
220
+ _context2.next = 2;
221
+ return ActionPopup({
222
+ mode: "tab",
223
+ url: url.toString(),
224
+ onCancel: function onCancel() {
225
+ return reject("User cancelled sign");
226
+ },
227
+ onMessage: function () {
228
+ var _onMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(event, Close) {
229
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
230
+ while (1) switch (_context.prev = _context.next) {
231
+ case 0:
232
+ if (!(!event || !event.data || event.data.type !== "FlowResponse")) {
233
+ _context.next = 2;
234
+ break;
293
235
  }
294
- }, _callee);
295
- }));
296
-
297
- function onMessage(_x4, _x5) {
298
- return _onMessage.apply(this, arguments);
236
+ return _context.abrupt("return");
237
+ case 2:
238
+ try {
239
+ resolve(event.data.response);
240
+ } catch (error) {
241
+ reject(error);
242
+ } finally {
243
+ Close();
244
+ }
245
+ case 3:
246
+ case "end":
247
+ return _context.stop();
299
248
  }
300
-
301
- return onMessage;
302
- }()
303
- });
304
-
305
- case 2:
306
- case "end":
307
- return _context2.stop();
308
- }
309
- }
310
- }, _callee2);
311
- }));
312
-
313
- return function (_x2, _x3) {
314
- return _ref3.apply(this, arguments);
315
- };
316
- }());
317
-
318
- case 29:
319
- return _context3.abrupt("return", _context3.sent);
320
-
321
- case 30:
322
- case "end":
323
- return _context3.stop();
324
- }
249
+ }, _callee);
250
+ }));
251
+ function onMessage(_x4, _x5) {
252
+ return _onMessage.apply(this, arguments);
253
+ }
254
+ return onMessage;
255
+ }()
256
+ });
257
+ case 2:
258
+ case "end":
259
+ return _context2.stop();
260
+ }
261
+ }, _callee2);
262
+ }));
263
+ return function (_x2, _x3) {
264
+ return _ref3.apply(this, arguments);
265
+ };
266
+ }());
267
+ case 29:
268
+ return _context3.abrupt("return", _context3.sent);
269
+ case 30:
270
+ case "end":
271
+ return _context3.stop();
325
272
  }
326
273
  }, _callee3, this);
327
274
  }));
328
-
329
275
  function PersonalSign(_x) {
330
276
  return _PersonalSign.apply(this, arguments);
331
277
  }
332
-
333
278
  return PersonalSign;
334
279
  }()
335
280
  /**
@@ -353,181 +298,143 @@ var ElvWalletClient = /*#__PURE__*/function () {
353
298
  *
354
299
  * @throws - If using the popup flow and the user closes the popup, this method will throw an error.
355
300
  */
356
-
357
301
  }, {
358
302
  key: "LogIn",
359
303
  value: function () {
360
304
  var _LogIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref4) {
361
305
  var _this = this;
362
-
363
306
  var _ref4$method, method, provider, _ref4$mode, mode, callbackUrl, marketplaceParams, _ref4$clearLogin, clearLogin, callback, loginUrl;
364
-
365
307
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
366
- while (1) {
367
- switch (_context6.prev = _context6.next) {
368
- case 0:
369
- _ref4$method = _ref4.method, method = _ref4$method === void 0 ? "redirect" : _ref4$method, provider = _ref4.provider, _ref4$mode = _ref4.mode, mode = _ref4$mode === void 0 ? "login" : _ref4$mode, callbackUrl = _ref4.callbackUrl, marketplaceParams = _ref4.marketplaceParams, _ref4$clearLogin = _ref4.clearLogin, clearLogin = _ref4$clearLogin === void 0 ? false : _ref4$clearLogin, callback = _ref4.callback;
370
- loginUrl = new URL(this.appUrl);
371
- loginUrl.hash = "/login";
372
- loginUrl.searchParams.set("origin", window.location.origin);
373
- loginUrl.searchParams.set("action", "login");
374
-
375
- if (provider) {
376
- loginUrl.searchParams.set("provider", provider);
377
- }
378
-
379
- if (mode) {
380
- loginUrl.searchParams.set("mode", mode);
381
- }
382
-
383
- if (!marketplaceParams) {
384
- _context6.next = 15;
385
- break;
386
- }
387
-
388
- _context6.t0 = loginUrl.searchParams;
389
- _context6.next = 11;
390
- return this.MarketplaceInfo({
391
- marketplaceParams: marketplaceParams
392
- });
393
-
394
- case 11:
395
- _context6.t1 = _context6.sent.marketplaceHash;
396
-
397
- _context6.t0.set.call(_context6.t0, "mid", _context6.t1);
398
-
399
- _context6.next = 16;
308
+ while (1) switch (_context6.prev = _context6.next) {
309
+ case 0:
310
+ _ref4$method = _ref4.method, method = _ref4$method === void 0 ? "redirect" : _ref4$method, provider = _ref4.provider, _ref4$mode = _ref4.mode, mode = _ref4$mode === void 0 ? "login" : _ref4$mode, callbackUrl = _ref4.callbackUrl, marketplaceParams = _ref4.marketplaceParams, _ref4$clearLogin = _ref4.clearLogin, clearLogin = _ref4$clearLogin === void 0 ? false : _ref4$clearLogin, callback = _ref4.callback;
311
+ loginUrl = new URL(this.appUrl);
312
+ loginUrl.hash = "/login";
313
+ loginUrl.searchParams.set("origin", window.location.origin);
314
+ loginUrl.searchParams.set("action", "login");
315
+ if (provider) {
316
+ loginUrl.searchParams.set("provider", provider);
317
+ }
318
+ if (mode) {
319
+ loginUrl.searchParams.set("mode", mode);
320
+ }
321
+ if (!marketplaceParams) {
322
+ _context6.next = 15;
400
323
  break;
401
-
402
- case 15:
403
- if ((this.selectedMarketplaceInfo || {}).marketplaceHash) {
404
- loginUrl.searchParams.set("mid", this.selectedMarketplaceInfo.marketplaceHash);
405
- }
406
-
407
- case 16:
408
- if (clearLogin) {
409
- loginUrl.searchParams.set("clear", "");
410
- }
411
-
412
- if (!(method === "redirect")) {
413
- _context6.next = 24;
414
- break;
415
- }
416
-
417
- loginUrl.searchParams.set("response", "redirect");
418
- loginUrl.searchParams.set("source", "origin");
419
- loginUrl.searchParams.set("redirect", callbackUrl);
420
- window.location = loginUrl;
421
- _context6.next = 28;
324
+ }
325
+ _context6.t0 = loginUrl.searchParams;
326
+ _context6.next = 11;
327
+ return this.MarketplaceInfo({
328
+ marketplaceParams: marketplaceParams
329
+ });
330
+ case 11:
331
+ _context6.t1 = _context6.sent.marketplaceHash;
332
+ _context6.t0.set.call(_context6.t0, "mid", _context6.t1);
333
+ _context6.next = 16;
334
+ break;
335
+ case 15:
336
+ if ((this.selectedMarketplaceInfo || {}).marketplaceHash) {
337
+ loginUrl.searchParams.set("mid", this.selectedMarketplaceInfo.marketplaceHash);
338
+ }
339
+ case 16:
340
+ if (clearLogin) {
341
+ loginUrl.searchParams.set("clear", "");
342
+ }
343
+ if (!(method === "redirect")) {
344
+ _context6.next = 24;
422
345
  break;
423
-
424
- case 24:
425
- loginUrl.searchParams.set("response", "message");
426
- loginUrl.searchParams.set("source", "parent");
427
- _context6.next = 28;
428
- return new Promise( /*#__PURE__*/function () {
429
- var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(resolve, reject) {
430
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
431
- while (1) {
432
- switch (_context5.prev = _context5.next) {
433
- case 0:
434
- _context5.next = 2;
435
- return ActionPopup({
436
- mode: "tab",
437
- url: loginUrl.toString(),
438
- onCancel: function onCancel() {
439
- return reject("User cancelled login");
440
- },
441
- onMessage: function () {
442
- var _onMessage2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(event, Close) {
443
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
444
- while (1) {
445
- switch (_context4.prev = _context4.next) {
446
- case 0:
447
- if (!(!event || !event.data || event.data.type !== "LoginResponse")) {
448
- _context4.next = 2;
449
- break;
450
- }
451
-
452
- return _context4.abrupt("return");
453
-
454
- case 2:
455
- _context4.prev = 2;
456
-
457
- if (!callback) {
458
- _context4.next = 8;
459
- break;
460
- }
461
-
462
- _context4.next = 6;
463
- return callback(event.data.params);
464
-
465
- case 6:
466
- _context4.next = 10;
467
- break;
468
-
469
- case 8:
470
- _context4.next = 10;
471
- return _this.Authenticate({
472
- token: event.data.params.clientSigningToken || event.data.params.clientAuthToken
473
- });
474
-
475
- case 10:
476
- resolve();
477
- _context4.next = 16;
478
- break;
479
-
480
- case 13:
481
- _context4.prev = 13;
482
- _context4.t0 = _context4["catch"](2);
483
- reject(_context4.t0);
484
-
485
- case 16:
486
- _context4.prev = 16;
487
- Close();
488
- return _context4.finish(16);
489
-
490
- case 19:
491
- case "end":
492
- return _context4.stop();
493
- }
346
+ }
347
+ loginUrl.searchParams.set("response", "redirect");
348
+ loginUrl.searchParams.set("source", "origin");
349
+ loginUrl.searchParams.set("redirect", callbackUrl);
350
+ window.location = loginUrl;
351
+ _context6.next = 28;
352
+ break;
353
+ case 24:
354
+ loginUrl.searchParams.set("response", "message");
355
+ loginUrl.searchParams.set("source", "parent");
356
+ _context6.next = 28;
357
+ return new Promise( /*#__PURE__*/function () {
358
+ var _ref5 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(resolve, reject) {
359
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
360
+ while (1) switch (_context5.prev = _context5.next) {
361
+ case 0:
362
+ _context5.next = 2;
363
+ return ActionPopup({
364
+ mode: "tab",
365
+ url: loginUrl.toString(),
366
+ onCancel: function onCancel() {
367
+ return reject("User cancelled login");
368
+ },
369
+ onMessage: function () {
370
+ var _onMessage2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(event, Close) {
371
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
372
+ while (1) switch (_context4.prev = _context4.next) {
373
+ case 0:
374
+ if (!(!event || !event.data || event.data.type !== "LoginResponse")) {
375
+ _context4.next = 2;
376
+ break;
494
377
  }
495
- }, _callee4, null, [[2, 13, 16, 19]]);
496
- }));
497
-
498
- function onMessage(_x9, _x10) {
499
- return _onMessage2.apply(this, arguments);
378
+ return _context4.abrupt("return");
379
+ case 2:
380
+ _context4.prev = 2;
381
+ if (!callback) {
382
+ _context4.next = 8;
383
+ break;
384
+ }
385
+ _context4.next = 6;
386
+ return callback(event.data.params);
387
+ case 6:
388
+ _context4.next = 10;
389
+ break;
390
+ case 8:
391
+ _context4.next = 10;
392
+ return _this.Authenticate({
393
+ token: event.data.params.clientSigningToken || event.data.params.clientAuthToken
394
+ });
395
+ case 10:
396
+ resolve();
397
+ _context4.next = 16;
398
+ break;
399
+ case 13:
400
+ _context4.prev = 13;
401
+ _context4.t0 = _context4["catch"](2);
402
+ reject(_context4.t0);
403
+ case 16:
404
+ _context4.prev = 16;
405
+ Close();
406
+ return _context4.finish(16);
407
+ case 19:
408
+ case "end":
409
+ return _context4.stop();
500
410
  }
501
-
502
- return onMessage;
503
- }()
504
- });
505
-
506
- case 2:
507
- case "end":
508
- return _context5.stop();
509
- }
510
- }
511
- }, _callee5);
512
- }));
513
-
514
- return function (_x7, _x8) {
515
- return _ref5.apply(this, arguments);
516
- };
517
- }());
518
-
519
- case 28:
520
- case "end":
521
- return _context6.stop();
522
- }
411
+ }, _callee4, null, [[2, 13, 16, 19]]);
412
+ }));
413
+ function onMessage(_x9, _x10) {
414
+ return _onMessage2.apply(this, arguments);
415
+ }
416
+ return onMessage;
417
+ }()
418
+ });
419
+ case 2:
420
+ case "end":
421
+ return _context5.stop();
422
+ }
423
+ }, _callee5);
424
+ }));
425
+ return function (_x7, _x8) {
426
+ return _ref5.apply(this, arguments);
427
+ };
428
+ }());
429
+ case 28:
430
+ case "end":
431
+ return _context6.stop();
523
432
  }
524
433
  }, _callee6, this);
525
434
  }));
526
-
527
435
  function LogIn(_x6) {
528
436
  return _LogIn.apply(this, arguments);
529
437
  }
530
-
531
438
  return LogIn;
532
439
  }()
533
440
  /**
@@ -535,20 +442,22 @@ var ElvWalletClient = /*#__PURE__*/function () {
535
442
  *
536
443
  * @methodGroup Login
537
444
  */
538
-
539
445
  }, {
540
446
  key: "LogOut",
541
447
  value: function LogOut() {
542
448
  this.__authorization = {};
543
449
  this.loggedIn = false;
544
- this.cachedMarketplaces = {}; // Delete saved auth token
450
+ this.cachedMarketplaces = {};
545
451
 
452
+ // Delete saved auth token
546
453
  if (localStorageAvailable) {
547
454
  try {
548
- localStorage.removeItem("__elv-token-".concat(this.network)); // eslint-disable-next-line no-empty
455
+ localStorage.removeItem("__elv-token-".concat(this.network));
456
+ // eslint-disable-next-line no-empty
549
457
  } catch (error) {}
550
458
  }
551
459
  }
460
+
552
461
  /**
553
462
  * Authenticate with an ElvWalletClient authorization token
554
463
  *
@@ -556,65 +465,53 @@ var ElvWalletClient = /*#__PURE__*/function () {
556
465
  * @namedParams
557
466
  * @param {string} token - A previously generated ElvWalletClient authorization token;
558
467
  */
559
-
560
468
  }, {
561
469
  key: "Authenticate",
562
470
  value: function () {
563
471
  var _Authenticate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref6) {
564
472
  var token, decodedToken;
565
473
  return _regeneratorRuntime.wrap(function _callee7$(_context7) {
566
- while (1) {
567
- switch (_context7.prev = _context7.next) {
568
- case 0:
569
- token = _ref6.token;
570
- _context7.prev = 1;
571
- decodedToken = JSON.parse(this.utils.FromB58ToStr(token)) || {};
572
- _context7.next = 8;
474
+ while (1) switch (_context7.prev = _context7.next) {
475
+ case 0:
476
+ token = _ref6.token;
477
+ _context7.prev = 1;
478
+ decodedToken = JSON.parse(this.utils.FromB58ToStr(token)) || {};
479
+ _context7.next = 8;
480
+ break;
481
+ case 5:
482
+ _context7.prev = 5;
483
+ _context7.t0 = _context7["catch"](1);
484
+ throw new Error("Invalid authorization token " + token);
485
+ case 8:
486
+ if (!(!decodedToken.expiresAt || Date.now() > decodedToken.expiresAt)) {
487
+ _context7.next = 10;
573
488
  break;
574
-
575
- case 5:
576
- _context7.prev = 5;
577
- _context7.t0 = _context7["catch"](1);
578
- throw new Error("Invalid authorization token " + token);
579
-
580
- case 8:
581
- if (!(!decodedToken.expiresAt || Date.now() > decodedToken.expiresAt)) {
582
- _context7.next = 10;
583
- break;
584
- }
585
-
586
- throw Error("ElvWalletClient: Provided authorization token has expired");
587
-
588
- case 10:
589
- if (!decodedToken.clusterToken) {
590
- _context7.next = 13;
591
- break;
592
- }
593
-
489
+ }
490
+ throw Error("ElvWalletClient: Provided authorization token has expired");
491
+ case 10:
492
+ if (!decodedToken.clusterToken) {
594
493
  _context7.next = 13;
595
- return this.client.SetRemoteSigner({
596
- authToken: decodedToken.clusterToken,
597
- signerURIs: decodedToken.signerURIs
598
- });
599
-
600
- case 13:
601
- this.client.SetStaticToken({
602
- token: decodedToken.fabricToken
603
- });
604
- return _context7.abrupt("return", this.SetAuthorization(_objectSpread({}, decodedToken)));
605
-
606
- case 15:
607
- case "end":
608
- return _context7.stop();
609
- }
494
+ break;
495
+ }
496
+ _context7.next = 13;
497
+ return this.client.SetRemoteSigner({
498
+ authToken: decodedToken.clusterToken,
499
+ signerURIs: decodedToken.signerURIs
500
+ });
501
+ case 13:
502
+ this.client.SetStaticToken({
503
+ token: decodedToken.fabricToken
504
+ });
505
+ return _context7.abrupt("return", this.SetAuthorization(_objectSpread({}, decodedToken)));
506
+ case 15:
507
+ case "end":
508
+ return _context7.stop();
610
509
  }
611
510
  }, _callee7, this, [[1, 5]]);
612
511
  }));
613
-
614
512
  function Authenticate(_x11) {
615
513
  return _Authenticate.apply(this, arguments);
616
514
  }
617
-
618
515
  return Authenticate;
619
516
  }()
620
517
  /**
@@ -636,111 +533,94 @@ var ElvWalletClient = /*#__PURE__*/function () {
636
533
  * - signingToken - Identical to `authToken`, but also includes the ability to perform arbitrary signatures with the custodial wallet. This token should be protected and should not be
637
534
  * shared with third parties.
638
535
  */
639
-
640
536
  }, {
641
537
  key: "AuthenticateOAuth",
642
538
  value: function () {
643
539
  var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref7) {
644
540
  var idToken, tenantId, email, signerURIs, _ref7$shareEmail, shareEmail, tokenDuration, expiresAt, fabricToken, address, decodedToken;
645
-
646
541
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
647
- while (1) {
648
- switch (_context8.prev = _context8.next) {
649
- case 0:
650
- idToken = _ref7.idToken, tenantId = _ref7.tenantId, email = _ref7.email, signerURIs = _ref7.signerURIs, _ref7$shareEmail = _ref7.shareEmail, shareEmail = _ref7$shareEmail === void 0 ? false : _ref7$shareEmail;
651
- tokenDuration = 24;
652
-
653
- if (!(!tenantId && this.selectedMarketplaceInfo)) {
654
- _context8.next = 6;
655
- break;
656
- }
657
-
658
- _context8.next = 5;
659
- return this.AvailableMarketplaces();
660
-
661
- case 5:
662
- tenantId = this.selectedMarketplaceInfo.tenantId;
663
-
664
- case 6:
665
- _context8.next = 8;
666
- return this.client.SetRemoteSigner({
667
- idToken: idToken,
668
- tenantId: tenantId,
669
- signerURIs: signerURIs,
670
- extraData: {
671
- share_email: shareEmail
672
- },
673
- unsignedPublicAuth: true
674
- });
675
-
676
- case 8:
677
- expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
678
- _context8.next = 11;
679
- return this.client.CreateFabricToken({
680
- duration: tokenDuration * 60 * 60 * 1000
681
- });
682
-
683
- case 11:
684
- fabricToken = _context8.sent;
685
- address = this.client.utils.FormatAddress(this.client.CurrentAccountAddress());
686
-
687
- if (email) {
688
- _context8.next = 22;
689
- break;
690
- }
691
-
692
- _context8.prev = 14;
693
- decodedToken = JSON.parse(this.utils.FromB64URL(idToken.split(".")[1]));
694
- email = decodedToken.email;
542
+ while (1) switch (_context8.prev = _context8.next) {
543
+ case 0:
544
+ idToken = _ref7.idToken, tenantId = _ref7.tenantId, email = _ref7.email, signerURIs = _ref7.signerURIs, _ref7$shareEmail = _ref7.shareEmail, shareEmail = _ref7$shareEmail === void 0 ? false : _ref7$shareEmail;
545
+ tokenDuration = 24;
546
+ if (!(!tenantId && this.selectedMarketplaceInfo)) {
547
+ _context8.next = 6;
548
+ break;
549
+ }
550
+ _context8.next = 5;
551
+ return this.AvailableMarketplaces();
552
+ case 5:
553
+ tenantId = this.selectedMarketplaceInfo.tenantId;
554
+ case 6:
555
+ _context8.next = 8;
556
+ return this.client.SetRemoteSigner({
557
+ idToken: idToken,
558
+ tenantId: tenantId,
559
+ signerURIs: signerURIs,
560
+ extraData: {
561
+ share_email: shareEmail
562
+ },
563
+ unsignedPublicAuth: true
564
+ });
565
+ case 8:
566
+ expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
567
+ _context8.next = 11;
568
+ return this.client.CreateFabricToken({
569
+ duration: tokenDuration * 60 * 60 * 1000
570
+ });
571
+ case 11:
572
+ fabricToken = _context8.sent;
573
+ address = this.client.utils.FormatAddress(this.client.CurrentAccountAddress());
574
+ if (email) {
695
575
  _context8.next = 22;
696
576
  break;
697
-
698
- case 19:
699
- _context8.prev = 19;
700
- _context8.t0 = _context8["catch"](14);
701
- throw Error("Failed to decode ID token");
702
-
703
- case 22:
704
- this.client.SetStaticToken({
705
- token: fabricToken
706
- });
707
- return _context8.abrupt("return", {
708
- authToken: this.SetAuthorization({
709
- fabricToken: fabricToken,
710
- tenantId: tenantId,
711
- address: address,
712
- email: email,
713
- expiresAt: expiresAt,
714
- signerURIs: signerURIs,
715
- walletType: "Custodial",
716
- walletName: "Eluvio",
717
- register: true
718
- }),
719
- signingToken: this.SetAuthorization({
720
- clusterToken: this.client.signer.authToken,
721
- fabricToken: fabricToken,
722
- tenantId: tenantId,
723
- address: address,
724
- email: email,
725
- expiresAt: expiresAt,
726
- signerURIs: signerURIs,
727
- walletType: "Custodial",
728
- walletName: "Eluvio"
729
- })
730
- });
731
-
732
- case 24:
733
- case "end":
734
- return _context8.stop();
735
- }
577
+ }
578
+ _context8.prev = 14;
579
+ decodedToken = JSON.parse(this.utils.FromB64URL(idToken.split(".")[1]));
580
+ email = decodedToken.email;
581
+ _context8.next = 22;
582
+ break;
583
+ case 19:
584
+ _context8.prev = 19;
585
+ _context8.t0 = _context8["catch"](14);
586
+ throw Error("Failed to decode ID token");
587
+ case 22:
588
+ this.client.SetStaticToken({
589
+ token: fabricToken
590
+ });
591
+ return _context8.abrupt("return", {
592
+ authToken: this.SetAuthorization({
593
+ fabricToken: fabricToken,
594
+ tenantId: tenantId,
595
+ address: address,
596
+ email: email,
597
+ expiresAt: expiresAt,
598
+ signerURIs: signerURIs,
599
+ walletType: "Custodial",
600
+ walletName: "Eluvio",
601
+ register: true
602
+ }),
603
+ signingToken: this.SetAuthorization({
604
+ clusterToken: this.client.signer.authToken,
605
+ fabricToken: fabricToken,
606
+ tenantId: tenantId,
607
+ address: address,
608
+ email: email,
609
+ expiresAt: expiresAt,
610
+ signerURIs: signerURIs,
611
+ walletType: "Custodial",
612
+ walletName: "Eluvio"
613
+ })
614
+ });
615
+ case 24:
616
+ case "end":
617
+ return _context8.stop();
736
618
  }
737
619
  }, _callee8, this, [[14, 19]]);
738
620
  }));
739
-
740
621
  function AuthenticateOAuth(_x12) {
741
622
  return _AuthenticateOAuth.apply(this, arguments);
742
623
  }
743
-
744
624
  return AuthenticateOAuth;
745
625
  }()
746
626
  /**
@@ -756,85 +636,68 @@ var ElvWalletClient = /*#__PURE__*/function () {
756
636
  * @returns {Promise<string>} - Returns an authorization token that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
757
637
  * Save this token to avoid having to reauthenticate. This token expires after 24 hours.
758
638
  */
759
-
760
639
  }, {
761
640
  key: "AuthenticateExternalWallet",
762
641
  value: function () {
763
642
  var _AuthenticateExternalWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref8) {
764
643
  var _this2 = this;
765
-
766
644
  var address, _ref8$tokenDuration, tokenDuration, _ref8$walletName, walletName, Sign, expiresAt, fabricToken;
767
-
768
645
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
769
- while (1) {
770
- switch (_context10.prev = _context10.next) {
771
- case 0:
772
- address = _ref8.address, _ref8$tokenDuration = _ref8.tokenDuration, tokenDuration = _ref8$tokenDuration === void 0 ? 24 : _ref8$tokenDuration, _ref8$walletName = _ref8.walletName, walletName = _ref8$walletName === void 0 ? "Metamask" : _ref8$walletName, Sign = _ref8.Sign;
773
-
774
- if (!address) {
775
- address = window.ethereum.selectedAddress;
776
- }
777
-
778
- address = this.utils.FormatAddress(address);
779
-
780
- if (!Sign) {
781
- Sign = /*#__PURE__*/function () {
782
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(message) {
783
- return _regeneratorRuntime.wrap(function _callee9$(_context9) {
784
- while (1) {
785
- switch (_context9.prev = _context9.next) {
786
- case 0:
787
- return _context9.abrupt("return", _this2.SignMetamask({
788
- message: message,
789
- address: address
790
- }));
791
-
792
- case 1:
793
- case "end":
794
- return _context9.stop();
795
- }
796
- }
797
- }, _callee9);
798
- }));
799
-
800
- return function Sign(_x14) {
801
- return _ref9.apply(this, arguments);
802
- };
803
- }();
804
- }
805
-
806
- expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
807
- _context10.next = 7;
808
- return this.client.CreateFabricToken({
809
- address: address,
810
- duration: tokenDuration * 60 * 60 * 1000,
811
- Sign: Sign,
812
- addEthereumPrefix: false
813
- });
814
-
815
- case 7:
816
- fabricToken = _context10.sent;
817
- return _context10.abrupt("return", this.SetAuthorization({
818
- fabricToken: fabricToken,
819
- address: address,
820
- expiresAt: expiresAt,
821
- walletType: "External",
822
- walletName: walletName,
823
- register: true
824
- }));
825
-
826
- case 9:
827
- case "end":
828
- return _context10.stop();
829
- }
646
+ while (1) switch (_context10.prev = _context10.next) {
647
+ case 0:
648
+ address = _ref8.address, _ref8$tokenDuration = _ref8.tokenDuration, tokenDuration = _ref8$tokenDuration === void 0 ? 24 : _ref8$tokenDuration, _ref8$walletName = _ref8.walletName, walletName = _ref8$walletName === void 0 ? "Metamask" : _ref8$walletName, Sign = _ref8.Sign;
649
+ if (!address) {
650
+ address = window.ethereum.selectedAddress;
651
+ }
652
+ address = this.utils.FormatAddress(address);
653
+ if (!Sign) {
654
+ Sign = /*#__PURE__*/function () {
655
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(message) {
656
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
657
+ while (1) switch (_context9.prev = _context9.next) {
658
+ case 0:
659
+ return _context9.abrupt("return", _this2.SignMetamask({
660
+ message: message,
661
+ address: address
662
+ }));
663
+ case 1:
664
+ case "end":
665
+ return _context9.stop();
666
+ }
667
+ }, _callee9);
668
+ }));
669
+ return function Sign(_x14) {
670
+ return _ref9.apply(this, arguments);
671
+ };
672
+ }();
673
+ }
674
+ expiresAt = Date.now() + tokenDuration * 60 * 60 * 1000;
675
+ _context10.next = 7;
676
+ return this.client.CreateFabricToken({
677
+ address: address,
678
+ duration: tokenDuration * 60 * 60 * 1000,
679
+ Sign: Sign,
680
+ addEthereumPrefix: false
681
+ });
682
+ case 7:
683
+ fabricToken = _context10.sent;
684
+ return _context10.abrupt("return", this.SetAuthorization({
685
+ fabricToken: fabricToken,
686
+ address: address,
687
+ expiresAt: expiresAt,
688
+ walletType: "External",
689
+ walletName: walletName,
690
+ register: true
691
+ }));
692
+ case 9:
693
+ case "end":
694
+ return _context10.stop();
830
695
  }
831
696
  }, _callee10, this);
832
697
  }));
833
-
834
698
  function AuthenticateExternalWallet(_x13) {
835
699
  return _AuthenticateExternalWallet.apply(this, arguments);
836
700
  }
837
-
838
701
  return AuthenticateExternalWallet;
839
702
  }()
840
703
  /**
@@ -844,14 +707,12 @@ var ElvWalletClient = /*#__PURE__*/function () {
844
707
  *
845
708
  * @returns {string} - The client auth token
846
709
  */
847
-
848
710
  }, {
849
711
  key: "ClientAuthToken",
850
712
  value: function ClientAuthToken() {
851
713
  if (!this.loggedIn) {
852
714
  return "";
853
715
  }
854
-
855
716
  return this.utils.B58(JSON.stringify(this.__authorization));
856
717
  }
857
718
  }, {
@@ -860,25 +721,23 @@ var ElvWalletClient = /*#__PURE__*/function () {
860
721
  if (!this.loggedIn) {
861
722
  return this.publicStaticToken;
862
723
  }
863
-
864
724
  return this.__authorization.fabricToken;
865
725
  }
866
726
  }, {
867
727
  key: "SetAuthorization",
868
728
  value: function SetAuthorization(_ref10) {
869
729
  var _this3 = this;
870
-
871
730
  var clusterToken = _ref10.clusterToken,
872
- fabricToken = _ref10.fabricToken,
873
- tenantId = _ref10.tenantId,
874
- address = _ref10.address,
875
- email = _ref10.email,
876
- expiresAt = _ref10.expiresAt,
877
- signerURIs = _ref10.signerURIs,
878
- walletType = _ref10.walletType,
879
- walletName = _ref10.walletName,
880
- _ref10$register = _ref10.register,
881
- register = _ref10$register === void 0 ? false : _ref10$register;
731
+ fabricToken = _ref10.fabricToken,
732
+ tenantId = _ref10.tenantId,
733
+ address = _ref10.address,
734
+ email = _ref10.email,
735
+ expiresAt = _ref10.expiresAt,
736
+ signerURIs = _ref10.signerURIs,
737
+ walletType = _ref10.walletType,
738
+ walletName = _ref10.walletName,
739
+ _ref10$register = _ref10.register,
740
+ register = _ref10$register === void 0 ? false : _ref10$register;
882
741
  address = this.client.utils.FormatAddress(address);
883
742
  this.__authorization = {
884
743
  fabricToken: fabricToken,
@@ -889,25 +748,21 @@ var ElvWalletClient = /*#__PURE__*/function () {
889
748
  walletType: walletType,
890
749
  walletName: walletName
891
750
  };
892
-
893
751
  if (clusterToken) {
894
752
  this.__authorization.clusterToken = clusterToken;
895
-
896
753
  if (signerURIs) {
897
754
  this.__authorization.signerURIs = signerURIs;
898
755
  }
899
756
  }
900
-
901
757
  this.loggedIn = true;
902
758
  this.cachedMarketplaces = {};
903
759
  var token = this.ClientAuthToken();
904
-
905
760
  if (this.storeAuthToken && localStorageAvailable) {
906
761
  try {
907
- localStorage.setItem("__elv-token-".concat(this.network), token); // eslint-disable-next-line no-empty
762
+ localStorage.setItem("__elv-token-".concat(this.network), token);
763
+ // eslint-disable-next-line no-empty
908
764
  } catch (error) {}
909
765
  }
910
-
911
766
  if (register) {
912
767
  this.client.authClient.MakeAuthServiceRequest({
913
768
  path: "/as/wlt/register",
@@ -919,7 +774,6 @@ var ElvWalletClient = /*#__PURE__*/function () {
919
774
  _this3.Log("Failed to register account: ", true, error);
920
775
  });
921
776
  }
922
-
923
777
  return token;
924
778
  }
925
779
  }, {
@@ -928,289 +782,244 @@ var ElvWalletClient = /*#__PURE__*/function () {
928
782
  var _SignMetamask = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref11) {
929
783
  var message, address, accounts;
930
784
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
931
- while (1) {
932
- switch (_context11.prev = _context11.next) {
933
- case 0:
934
- message = _ref11.message, address = _ref11.address;
935
-
936
- if (!(!inBrowser || !window.ethereum)) {
937
- _context11.next = 3;
938
- break;
939
- }
940
-
941
- throw Error("ElvWalletClient: Unable to initialize - Metamask not available");
942
-
943
- case 3:
944
- address = address || this.UserAddress();
945
- _context11.next = 6;
946
- return window.ethereum.request({
947
- method: "eth_requestAccounts"
948
- });
949
-
950
- case 6:
951
- accounts = _context11.sent;
952
-
953
- if (!(address && !Utils.EqualAddress(accounts[0], address))) {
954
- _context11.next = 9;
955
- break;
956
- }
957
-
958
- throw Error("ElvWalletClient: Incorrect MetaMask account selected. Expected ".concat(address, ", got ").concat(accounts[0]));
959
-
960
- case 9:
961
- _context11.next = 11;
962
- return window.ethereum.request({
963
- method: "personal_sign",
964
- params: [message, address, ""]
965
- });
966
-
967
- case 11:
968
- return _context11.abrupt("return", _context11.sent);
969
-
970
- case 12:
971
- case "end":
972
- return _context11.stop();
973
- }
785
+ while (1) switch (_context11.prev = _context11.next) {
786
+ case 0:
787
+ message = _ref11.message, address = _ref11.address;
788
+ if (!(!inBrowser || !window.ethereum)) {
789
+ _context11.next = 3;
790
+ break;
791
+ }
792
+ throw Error("ElvWalletClient: Unable to initialize - Metamask not available");
793
+ case 3:
794
+ address = address || this.UserAddress();
795
+ _context11.next = 6;
796
+ return window.ethereum.request({
797
+ method: "eth_requestAccounts"
798
+ });
799
+ case 6:
800
+ accounts = _context11.sent;
801
+ if (!(address && !Utils.EqualAddress(accounts[0], address))) {
802
+ _context11.next = 9;
803
+ break;
804
+ }
805
+ throw Error("ElvWalletClient: Incorrect MetaMask account selected. Expected ".concat(address, ", got ").concat(accounts[0]));
806
+ case 9:
807
+ _context11.next = 11;
808
+ return window.ethereum.request({
809
+ method: "personal_sign",
810
+ params: [message, address, ""]
811
+ });
812
+ case 11:
813
+ return _context11.abrupt("return", _context11.sent);
814
+ case 12:
815
+ case "end":
816
+ return _context11.stop();
974
817
  }
975
818
  }, _callee11, this);
976
819
  }));
977
-
978
820
  function SignMetamask(_x15) {
979
821
  return _SignMetamask.apply(this, arguments);
980
822
  }
981
-
982
823
  return SignMetamask;
983
824
  }() // Internal loading methods
984
-
985
825
  }, {
986
826
  key: "LoadAvailableMarketplaces",
987
827
  value: function () {
988
828
  var _LoadAvailableMarketplaces = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12() {
989
829
  var _this4 = this;
990
-
991
830
  var forceReload,
992
- mainSiteHash,
993
- metadata,
994
- previewTenantSlug,
995
- previewMarketplaceSlug,
996
- previewMarketplaceMetadata,
997
- availableMarketplaces,
998
- availableMarketplacesById,
999
- _args12 = arguments;
831
+ mainSiteHash,
832
+ metadata,
833
+ previewTenantSlug,
834
+ previewMarketplaceSlug,
835
+ previewMarketplaceMetadata,
836
+ availableMarketplaces,
837
+ availableMarketplacesById,
838
+ _args12 = arguments;
1000
839
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
1001
- while (1) {
1002
- switch (_context12.prev = _context12.next) {
1003
- case 0:
1004
- forceReload = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : false;
1005
-
1006
- if (!(!forceReload && Object.keys(this.availableMarketplaces) > 0)) {
1007
- _context12.next = 3;
1008
- break;
1009
- }
1010
-
1011
- return _context12.abrupt("return");
1012
-
1013
- case 3:
1014
- _context12.next = 5;
1015
- return this.client.LatestVersionHash({
1016
- objectId: this.mainSiteId
1017
- });
1018
-
1019
- case 5:
1020
- mainSiteHash = _context12.sent;
1021
- _context12.next = 8;
1022
- return this.client.ContentObjectMetadata({
1023
- versionHash: mainSiteHash,
1024
- metadataSubtree: "public/asset_metadata/tenants",
1025
- resolveLinks: true,
1026
- linkDepthLimit: 2,
1027
- resolveIncludeSource: true,
1028
- resolveIgnoreErrors: true,
1029
- produceLinkUrls: true,
1030
- authorizationToken: this.publicStaticToken,
1031
- noAuth: true,
1032
- select: ["*/.", "*/marketplaces/*/.", "*/marketplaces/*/info/tenant_id", "*/marketplaces/*/info/tenant_name", "*/marketplaces/*/info/branding", "*/marketplaces/*/info/storefront/background", "*/marketplaces/*/info/storefront/background_mobile"],
1033
- remove: ["*/marketplaces/*/info/branding/custom_css"]
840
+ while (1) switch (_context12.prev = _context12.next) {
841
+ case 0:
842
+ forceReload = _args12.length > 0 && _args12[0] !== undefined ? _args12[0] : false;
843
+ if (!(!forceReload && Object.keys(this.availableMarketplaces) > 0)) {
844
+ _context12.next = 3;
845
+ break;
846
+ }
847
+ return _context12.abrupt("return");
848
+ case 3:
849
+ _context12.next = 5;
850
+ return this.client.LatestVersionHash({
851
+ objectId: this.mainSiteId
852
+ });
853
+ case 5:
854
+ mainSiteHash = _context12.sent;
855
+ _context12.next = 8;
856
+ return this.client.ContentObjectMetadata({
857
+ versionHash: mainSiteHash,
858
+ metadataSubtree: "public/asset_metadata/tenants",
859
+ resolveLinks: true,
860
+ linkDepthLimit: 2,
861
+ resolveIncludeSource: true,
862
+ resolveIgnoreErrors: true,
863
+ produceLinkUrls: true,
864
+ authorizationToken: this.publicStaticToken,
865
+ noAuth: true,
866
+ select: ["*/.", "*/marketplaces/*/.", "*/marketplaces/*/info/tenant_id", "*/marketplaces/*/info/tenant_name", "*/marketplaces/*/info/branding", "*/marketplaces/*/info/storefront/background", "*/marketplaces/*/info/storefront/background_mobile"],
867
+ remove: ["*/marketplaces/*/info/branding/custom_css"]
868
+ });
869
+ case 8:
870
+ metadata = _context12.sent;
871
+ if (!this.previewMarketplaceId) {
872
+ _context12.next = 24;
873
+ break;
874
+ }
875
+ previewTenantSlug = "PREVIEW";
876
+ Object.keys(metadata || {}).forEach(function (tenantSlug) {
877
+ return Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(function (marketplaceSlug) {
878
+ var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
879
+ var objectId = _this4.utils.DecodeVersionHash(versionHash).objectId;
880
+ if (objectId === _this4.previewMarketplaceId) {
881
+ // Marketplace exists in site meta
882
+ previewTenantSlug = tenantSlug;
883
+ previewMarketplaceSlug = marketplaceSlug;
884
+
885
+ // Deployed marketplace is same as preview marketplace
886
+ if (versionHash === _this4.previewMarketplaceHash) {
887
+ previewMarketplaceMetadata = metadata[tenantSlug].marketplaces[marketplaceSlug];
888
+ }
889
+ }
1034
890
  });
891
+ });
1035
892
 
1036
- case 8:
1037
- metadata = _context12.sent;
1038
-
1039
- if (!this.previewMarketplaceId) {
1040
- _context12.next = 24;
1041
- break;
1042
- }
1043
-
1044
- previewTenantSlug = "PREVIEW";
1045
- Object.keys(metadata || {}).forEach(function (tenantSlug) {
1046
- return Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(function (marketplaceSlug) {
1047
- var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
1048
-
1049
- var objectId = _this4.utils.DecodeVersionHash(versionHash).objectId;
1050
-
1051
- if (objectId === _this4.previewMarketplaceId) {
1052
- // Marketplace exists in site meta
1053
- previewTenantSlug = tenantSlug;
1054
- previewMarketplaceSlug = marketplaceSlug; // Deployed marketplace is same as preview marketplace
893
+ // Marketplace not present in branch, or preview version is different - Load metadata directly
894
+ if (previewMarketplaceMetadata) {
895
+ _context12.next = 17;
896
+ break;
897
+ }
898
+ _context12.next = 15;
899
+ return this.client.ContentObjectMetadata({
900
+ versionHash: this.previewMarketplaceHash,
901
+ metadataSubtree: "public/asset_metadata",
902
+ produceLinkUrls: true,
903
+ authorizationToken: this.publicStaticToken,
904
+ noAuth: true,
905
+ select: ["slug", "info/tenant_id", "info/tenant_name", "info/branding"],
906
+ remove: ["info/branding/custom_css"]
907
+ });
908
+ case 15:
909
+ previewMarketplaceMetadata = _context12.sent;
910
+ if (!previewMarketplaceSlug) {
911
+ previewMarketplaceSlug = previewMarketplaceMetadata.slug;
912
+ }
913
+ case 17:
914
+ previewMarketplaceMetadata["."] = {
915
+ source: this.previewMarketplaceHash
916
+ };
917
+ previewMarketplaceMetadata.info["."] = {
918
+ source: this.previewMarketplaceHash
919
+ };
920
+ previewMarketplaceMetadata.info.branding.preview = true;
921
+ previewMarketplaceMetadata.info.branding.show = true;
922
+ metadata[previewTenantSlug] = metadata[previewTenantSlug] || {};
923
+ metadata[previewTenantSlug].marketplaces = metadata[previewTenantSlug].marketplaces || {};
924
+ metadata[previewTenantSlug].marketplaces[previewMarketplaceSlug] = previewMarketplaceMetadata;
925
+ case 24:
926
+ availableMarketplaces = _objectSpread({}, this.availableMarketplaces || {});
927
+ availableMarketplacesById = _objectSpread({}, this.availableMarketplacesById || {});
928
+ Object.keys(metadata || {}).forEach(function (tenantSlug) {
929
+ try {
930
+ availableMarketplaces[tenantSlug] = metadata[tenantSlug]["."] ? {
931
+ versionHash: metadata[tenantSlug]["."].source
932
+ } : {};
933
+ Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(function (marketplaceSlug) {
934
+ try {
935
+ var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
936
+ var objectId = _this4.utils.DecodeVersionHash(versionHash).objectId;
937
+ availableMarketplaces[tenantSlug][marketplaceSlug] = _objectSpread(_objectSpread({}, metadata[tenantSlug].marketplaces[marketplaceSlug].info || {}), {}, {
938
+ tenantName: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_name,
939
+ tenantId: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_id,
940
+ tenantSlug: tenantSlug,
941
+ marketplaceSlug: marketplaceSlug,
942
+ marketplaceId: objectId,
943
+ marketplaceHash: versionHash,
944
+ order: Configuration.__MARKETPLACE_ORDER.findIndex(function (slug) {
945
+ return slug === marketplaceSlug;
946
+ })
947
+ });
948
+ availableMarketplacesById[objectId] = availableMarketplaces[tenantSlug][marketplaceSlug];
949
+ _this4.marketplaceHashes[objectId] = versionHash;
1055
950
 
1056
- if (versionHash === _this4.previewMarketplaceHash) {
1057
- previewMarketplaceMetadata = metadata[tenantSlug].marketplaces[marketplaceSlug];
951
+ // Fill out selected marketplace info
952
+ if (_this4.selectedMarketplaceInfo) {
953
+ if (_this4.selectedMarketplaceInfo.tenantSlug === tenantSlug && _this4.selectedMarketplaceInfo.marketplaceSlug === marketplaceSlug || _this4.selectedMarketplaceInfo.marketplaceId === objectId) {
954
+ _this4.selectedMarketplaceInfo = availableMarketplaces[tenantSlug][marketplaceSlug];
955
+ }
1058
956
  }
957
+ } catch (error) {
958
+ _this4.Log("Eluvio Wallet Client: Unable to load info for marketplace ".concat(tenantSlug, "/").concat(marketplaceSlug), true);
1059
959
  }
1060
960
  });
1061
- }); // Marketplace not present in branch, or preview version is different - Load metadata directly
1062
-
1063
- if (previewMarketplaceMetadata) {
1064
- _context12.next = 17;
1065
- break;
961
+ } catch (error) {
962
+ _this4.Log("Eluvio Wallet Client: Failed to load tenant info ".concat(tenantSlug), true, error);
1066
963
  }
1067
-
1068
- _context12.next = 15;
1069
- return this.client.ContentObjectMetadata({
1070
- versionHash: this.previewMarketplaceHash,
1071
- metadataSubtree: "public/asset_metadata",
1072
- produceLinkUrls: true,
1073
- authorizationToken: this.publicStaticToken,
1074
- noAuth: true,
1075
- select: ["slug", "info/tenant_id", "info/tenant_name", "info/branding"],
1076
- remove: ["info/branding/custom_css"]
1077
- });
1078
-
1079
- case 15:
1080
- previewMarketplaceMetadata = _context12.sent;
1081
-
1082
- if (!previewMarketplaceSlug) {
1083
- previewMarketplaceSlug = previewMarketplaceMetadata.slug;
1084
- }
1085
-
1086
- case 17:
1087
- previewMarketplaceMetadata["."] = {
1088
- source: this.previewMarketplaceHash
1089
- };
1090
- previewMarketplaceMetadata.info["."] = {
1091
- source: this.previewMarketplaceHash
1092
- };
1093
- previewMarketplaceMetadata.info.branding.preview = true;
1094
- previewMarketplaceMetadata.info.branding.show = true;
1095
- metadata[previewTenantSlug] = metadata[previewTenantSlug] || {};
1096
- metadata[previewTenantSlug].marketplaces = metadata[previewTenantSlug].marketplaces || {};
1097
- metadata[previewTenantSlug].marketplaces[previewMarketplaceSlug] = previewMarketplaceMetadata;
1098
-
1099
- case 24:
1100
- availableMarketplaces = _objectSpread({}, this.availableMarketplaces || {});
1101
- availableMarketplacesById = _objectSpread({}, this.availableMarketplacesById || {});
1102
- Object.keys(metadata || {}).forEach(function (tenantSlug) {
1103
- try {
1104
- availableMarketplaces[tenantSlug] = metadata[tenantSlug]["."] ? {
1105
- versionHash: metadata[tenantSlug]["."].source
1106
- } : {};
1107
- Object.keys(metadata[tenantSlug].marketplaces || {}).forEach(function (marketplaceSlug) {
1108
- try {
1109
- var versionHash = metadata[tenantSlug].marketplaces[marketplaceSlug]["."].source;
1110
-
1111
- var objectId = _this4.utils.DecodeVersionHash(versionHash).objectId;
1112
-
1113
- availableMarketplaces[tenantSlug][marketplaceSlug] = _objectSpread(_objectSpread({}, metadata[tenantSlug].marketplaces[marketplaceSlug].info || {}), {}, {
1114
- tenantName: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_name,
1115
- tenantId: metadata[tenantSlug].marketplaces[marketplaceSlug].info.tenant_id,
1116
- tenantSlug: tenantSlug,
1117
- marketplaceSlug: marketplaceSlug,
1118
- marketplaceId: objectId,
1119
- marketplaceHash: versionHash,
1120
- order: Configuration.__MARKETPLACE_ORDER.findIndex(function (slug) {
1121
- return slug === marketplaceSlug;
1122
- })
1123
- });
1124
- availableMarketplacesById[objectId] = availableMarketplaces[tenantSlug][marketplaceSlug];
1125
- _this4.marketplaceHashes[objectId] = versionHash; // Fill out selected marketplace info
1126
-
1127
- if (_this4.selectedMarketplaceInfo) {
1128
- if (_this4.selectedMarketplaceInfo.tenantSlug === tenantSlug && _this4.selectedMarketplaceInfo.marketplaceSlug === marketplaceSlug || _this4.selectedMarketplaceInfo.marketplaceId === objectId) {
1129
- _this4.selectedMarketplaceInfo = availableMarketplaces[tenantSlug][marketplaceSlug];
1130
- }
1131
- }
1132
- } catch (error) {
1133
- _this4.Log("Eluvio Wallet Client: Unable to load info for marketplace ".concat(tenantSlug, "/").concat(marketplaceSlug), true);
1134
- }
1135
- });
1136
- } catch (error) {
1137
- _this4.Log("Eluvio Wallet Client: Failed to load tenant info ".concat(tenantSlug), true, error);
1138
- }
1139
- });
1140
- this.availableMarketplaces = availableMarketplaces;
1141
- this.availableMarketplacesById = availableMarketplacesById;
1142
-
1143
- case 29:
1144
- case "end":
1145
- return _context12.stop();
1146
- }
964
+ });
965
+ this.availableMarketplaces = availableMarketplaces;
966
+ this.availableMarketplacesById = availableMarketplacesById;
967
+ case 29:
968
+ case "end":
969
+ return _context12.stop();
1147
970
  }
1148
971
  }, _callee12, this);
1149
972
  }));
1150
-
1151
973
  function LoadAvailableMarketplaces() {
1152
974
  return _LoadAvailableMarketplaces.apply(this, arguments);
1153
975
  }
1154
-
1155
976
  return LoadAvailableMarketplaces;
1156
977
  }() // Get the hash of the currently linked marketplace
1157
-
1158
978
  }, {
1159
979
  key: "LatestMarketplaceHash",
1160
980
  value: function () {
1161
981
  var _LatestMarketplaceHash = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref12) {
1162
982
  var marketplaceParams, marketplaceInfo, mainSiteHash, marketplaceLink;
1163
983
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
1164
- while (1) {
1165
- switch (_context13.prev = _context13.next) {
1166
- case 0:
1167
- marketplaceParams = _ref12.marketplaceParams;
1168
- _context13.next = 3;
1169
- return this.MarketplaceInfo({
1170
- marketplaceParams: marketplaceParams
1171
- });
1172
-
1173
- case 3:
1174
- marketplaceInfo = _context13.sent;
1175
-
1176
- if (!(this.previewMarketplaceId && this.previewMarketplaceId === marketplaceInfo.marketplaceId)) {
1177
- _context13.next = 6;
1178
- break;
1179
- }
1180
-
1181
- return _context13.abrupt("return", this.availableMarketplaces[marketplaceInfo.tenantSlug][marketplaceInfo.marketplaceSlug]["."].source);
1182
-
1183
- case 6:
1184
- _context13.next = 8;
1185
- return this.client.LatestVersionHash({
1186
- objectId: this.mainSiteId
1187
- });
1188
-
1189
- case 8:
1190
- mainSiteHash = _context13.sent;
1191
- _context13.next = 11;
1192
- return this.client.ContentObjectMetadata({
1193
- versionHash: mainSiteHash,
1194
- metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", marketplaceInfo.tenantSlug, "marketplaces", marketplaceInfo.marketplaceSlug),
1195
- resolveLinks: false
1196
- });
1197
-
1198
- case 11:
1199
- marketplaceLink = _context13.sent;
1200
- return _context13.abrupt("return", LinkTargetHash(marketplaceLink));
1201
-
1202
- case 13:
1203
- case "end":
1204
- return _context13.stop();
1205
- }
984
+ while (1) switch (_context13.prev = _context13.next) {
985
+ case 0:
986
+ marketplaceParams = _ref12.marketplaceParams;
987
+ _context13.next = 3;
988
+ return this.MarketplaceInfo({
989
+ marketplaceParams: marketplaceParams
990
+ });
991
+ case 3:
992
+ marketplaceInfo = _context13.sent;
993
+ if (!(this.previewMarketplaceId && this.previewMarketplaceId === marketplaceInfo.marketplaceId)) {
994
+ _context13.next = 6;
995
+ break;
996
+ }
997
+ return _context13.abrupt("return", this.availableMarketplaces[marketplaceInfo.tenantSlug][marketplaceInfo.marketplaceSlug]["."].source);
998
+ case 6:
999
+ _context13.next = 8;
1000
+ return this.client.LatestVersionHash({
1001
+ objectId: this.mainSiteId
1002
+ });
1003
+ case 8:
1004
+ mainSiteHash = _context13.sent;
1005
+ _context13.next = 11;
1006
+ return this.client.ContentObjectMetadata({
1007
+ versionHash: mainSiteHash,
1008
+ metadataSubtree: UrlJoin("/public", "asset_metadata", "tenants", marketplaceInfo.tenantSlug, "marketplaces", marketplaceInfo.marketplaceSlug),
1009
+ resolveLinks: false
1010
+ });
1011
+ case 11:
1012
+ marketplaceLink = _context13.sent;
1013
+ return _context13.abrupt("return", LinkTargetHash(marketplaceLink));
1014
+ case 13:
1015
+ case "end":
1016
+ return _context13.stop();
1206
1017
  }
1207
1018
  }, _callee13, this);
1208
1019
  }));
1209
-
1210
1020
  function LatestMarketplaceHash(_x16) {
1211
1021
  return _LatestMarketplaceHash.apply(this, arguments);
1212
1022
  }
1213
-
1214
1023
  return LatestMarketplaceHash;
1215
1024
  }()
1216
1025
  }, {
@@ -1218,165 +1027,138 @@ var ElvWalletClient = /*#__PURE__*/function () {
1218
1027
  value: function () {
1219
1028
  var _LoadMarketplace = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(marketplaceParams) {
1220
1029
  var _this5 = this;
1221
-
1222
1030
  var marketplaceInfo, marketplaceId, marketplaceHash, marketplace;
1223
1031
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1224
- while (1) {
1225
- switch (_context15.prev = _context15.next) {
1226
- case 0:
1227
- marketplaceInfo = this.MarketplaceInfo({
1228
- marketplaceParams: marketplaceParams
1229
- });
1230
- marketplaceId = marketplaceInfo.marketplaceId;
1231
- _context15.next = 4;
1232
- return this.LatestMarketplaceHash({
1233
- marketplaceParams: marketplaceParams
1234
- });
1235
-
1236
- case 4:
1237
- marketplaceHash = _context15.sent;
1238
-
1239
- if (this.cachedMarketplaces[marketplaceId] && this.cachedMarketplaces[marketplaceId].versionHash !== marketplaceHash) {
1240
- delete this.cachedMarketplaces[marketplaceId];
1241
- }
1242
-
1243
- if (this.cachedMarketplaces[marketplaceId]) {
1244
- _context15.next = 21;
1245
- break;
1246
- }
1247
-
1248
- _context15.next = 9;
1249
- return this.client.ContentObjectMetadata({
1250
- versionHash: marketplaceHash,
1251
- metadataSubtree: "public/asset_metadata/info",
1252
- localizationSubtree: this.localization ? UrlJoin("public", "asset_metadata", "localizations", this.localization, "info") : "",
1253
- linkDepthLimit: 1,
1254
- resolveLinks: true,
1255
- resolveIgnoreErrors: true,
1256
- resolveIncludeSource: true,
1257
- produceLinkUrls: true,
1258
- authorizationToken: this.publicStaticToken
1259
- });
1260
-
1261
- case 9:
1262
- marketplace = _context15.sent;
1263
- _context15.next = 12;
1264
- return Promise.all(marketplace.items.map( /*#__PURE__*/function () {
1265
- var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(item, index) {
1266
- var authorizationToken;
1267
- return _regeneratorRuntime.wrap(function _callee14$(_context14) {
1268
- while (1) {
1269
- switch (_context14.prev = _context14.next) {
1270
- case 0:
1271
- if (!item.requires_permissions) {
1272
- _context14.next = 14;
1273
- break;
1274
- }
1275
-
1276
- if (_this5.loggedIn) {
1277
- _context14.next = 5;
1278
- break;
1279
- }
1280
-
1281
- _context14.next = 4;
1282
- return _this5.client.CreateFabricToken({});
1283
-
1284
- case 4:
1285
- authorizationToken = _context14.sent;
1286
-
1287
- case 5:
1288
- _context14.prev = 5;
1289
- _context14.next = 8;
1290
- return _this5.client.ContentObjectMetadata({
1291
- versionHash: LinkTargetHash(item.nft_template),
1292
- metadataSubtree: "permissioned",
1293
- authorizationToken: authorizationToken
1294
- });
1295
-
1296
- case 8:
1297
- item.authorized = true;
1298
- _context14.next = 14;
1299
- break;
1300
-
1301
- case 11:
1302
- _context14.prev = 11;
1303
- _context14.t0 = _context14["catch"](5);
1304
- item.authorized = false;
1305
-
1306
- case 14:
1307
- item.nftTemplateMetadata = (item.nft_template || {}).nft || {};
1308
- item.nftTemplateHash = ((item.nft_template || {})["."] || {}).source;
1309
- item.itemIndex = index;
1310
- return _context14.abrupt("return", item);
1311
-
1312
- case 18:
1313
- case "end":
1314
- return _context14.stop();
1032
+ while (1) switch (_context15.prev = _context15.next) {
1033
+ case 0:
1034
+ marketplaceInfo = this.MarketplaceInfo({
1035
+ marketplaceParams: marketplaceParams
1036
+ });
1037
+ marketplaceId = marketplaceInfo.marketplaceId;
1038
+ _context15.next = 4;
1039
+ return this.LatestMarketplaceHash({
1040
+ marketplaceParams: marketplaceParams
1041
+ });
1042
+ case 4:
1043
+ marketplaceHash = _context15.sent;
1044
+ if (this.cachedMarketplaces[marketplaceId] && this.cachedMarketplaces[marketplaceId].versionHash !== marketplaceHash) {
1045
+ delete this.cachedMarketplaces[marketplaceId];
1046
+ }
1047
+ if (this.cachedMarketplaces[marketplaceId]) {
1048
+ _context15.next = 21;
1049
+ break;
1050
+ }
1051
+ _context15.next = 9;
1052
+ return this.client.ContentObjectMetadata({
1053
+ versionHash: marketplaceHash,
1054
+ metadataSubtree: "public/asset_metadata/info",
1055
+ localizationSubtree: this.localization ? UrlJoin("public", "asset_metadata", "localizations", this.localization, "info") : "",
1056
+ linkDepthLimit: 1,
1057
+ resolveLinks: true,
1058
+ resolveIgnoreErrors: true,
1059
+ resolveIncludeSource: true,
1060
+ produceLinkUrls: true,
1061
+ authorizationToken: this.publicStaticToken
1062
+ });
1063
+ case 9:
1064
+ marketplace = _context15.sent;
1065
+ _context15.next = 12;
1066
+ return Promise.all(marketplace.items.map( /*#__PURE__*/function () {
1067
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(item, index) {
1068
+ var authorizationToken;
1069
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
1070
+ while (1) switch (_context14.prev = _context14.next) {
1071
+ case 0:
1072
+ if (!item.requires_permissions) {
1073
+ _context14.next = 14;
1074
+ break;
1315
1075
  }
1316
- }
1317
- }, _callee14, null, [[5, 11]]);
1318
- }));
1319
-
1320
- return function (_x18, _x19) {
1321
- return _ref13.apply(this, arguments);
1322
- };
1323
- }()));
1324
-
1325
- case 12:
1326
- marketplace.items = _context15.sent;
1327
- marketplace.collections = (marketplace.collections || []).map(function (collection, collectionIndex) {
1328
- return _objectSpread(_objectSpread({}, collection), {}, {
1329
- collectionIndex: collectionIndex
1330
- });
1331
- });
1332
- marketplace.retrievedAt = Date.now();
1333
- marketplace.marketplaceId = marketplaceId;
1334
- marketplace.versionHash = marketplaceHash;
1335
- marketplace.marketplaceHash = marketplaceHash;
1336
-
1337
- if (this.previewMarketplaceId && marketplaceId === this.previewMarketplaceId) {
1338
- marketplace.branding.preview = true;
1339
- } // Generate embed URLs for pack opening animations
1340
-
1341
-
1342
- ["purchase_animation", "purchase_animation_mobile", "reveal_animation", "reveal_animation_mobile"].forEach(function (key) {
1343
- try {
1344
- if (marketplace.storefront[key]) {
1345
- var embedUrl = new URL("https://embed.v3.contentfabric.io");
1346
- var targetHash = LinkTargetHash(marketplace.storefront[key]);
1347
- embedUrl.searchParams.set("p", "");
1348
- embedUrl.searchParams.set("net", _this5.network === "main" ? "main" : "demo");
1349
- embedUrl.searchParams.set("ath", (_this5.__authorization || {}).authToken || _this5.publicStaticToken);
1350
- embedUrl.searchParams.set("vid", targetHash);
1351
- embedUrl.searchParams.set("ap", "");
1352
-
1353
- if (!key.startsWith("reveal")) {
1354
- embedUrl.searchParams.set("m", "");
1355
- embedUrl.searchParams.set("lp", "");
1356
- }
1357
-
1358
- marketplace.storefront["".concat(key, "_embed_url")] = embedUrl.toString();
1359
- } // eslint-disable-next-line no-empty
1360
-
1361
- } catch (error) {}
1076
+ if (_this5.loggedIn) {
1077
+ _context14.next = 5;
1078
+ break;
1079
+ }
1080
+ _context14.next = 4;
1081
+ return _this5.client.CreateFabricToken({});
1082
+ case 4:
1083
+ authorizationToken = _context14.sent;
1084
+ case 5:
1085
+ _context14.prev = 5;
1086
+ _context14.next = 8;
1087
+ return _this5.client.ContentObjectMetadata({
1088
+ versionHash: LinkTargetHash(item.nft_template),
1089
+ metadataSubtree: "permissioned",
1090
+ authorizationToken: authorizationToken
1091
+ });
1092
+ case 8:
1093
+ item.authorized = true;
1094
+ _context14.next = 14;
1095
+ break;
1096
+ case 11:
1097
+ _context14.prev = 11;
1098
+ _context14.t0 = _context14["catch"](5);
1099
+ item.authorized = false;
1100
+ case 14:
1101
+ item.nftTemplateMetadata = (item.nft_template || {}).nft || {};
1102
+ item.nftTemplateHash = ((item.nft_template || {})["."] || {}).source;
1103
+ item.itemIndex = index;
1104
+ return _context14.abrupt("return", item);
1105
+ case 18:
1106
+ case "end":
1107
+ return _context14.stop();
1108
+ }
1109
+ }, _callee14, null, [[5, 11]]);
1110
+ }));
1111
+ return function (_x18, _x19) {
1112
+ return _ref13.apply(this, arguments);
1113
+ };
1114
+ }()));
1115
+ case 12:
1116
+ marketplace.items = _context15.sent;
1117
+ marketplace.collections = (marketplace.collections || []).map(function (collection, collectionIndex) {
1118
+ return _objectSpread(_objectSpread({}, collection), {}, {
1119
+ collectionIndex: collectionIndex
1362
1120
  });
1363
- this.cachedMarketplaces[marketplaceId] = marketplace;
1364
-
1365
- case 21:
1366
- return _context15.abrupt("return", this.cachedMarketplaces[marketplaceId]);
1367
-
1368
- case 22:
1369
- case "end":
1370
- return _context15.stop();
1371
- }
1121
+ });
1122
+ marketplace.retrievedAt = Date.now();
1123
+ marketplace.marketplaceId = marketplaceId;
1124
+ marketplace.versionHash = marketplaceHash;
1125
+ marketplace.marketplaceHash = marketplaceHash;
1126
+ if (this.previewMarketplaceId && marketplaceId === this.previewMarketplaceId) {
1127
+ marketplace.branding.preview = true;
1128
+ }
1129
+
1130
+ // Generate embed URLs for pack opening animations
1131
+ ["purchase_animation", "purchase_animation_mobile", "reveal_animation", "reveal_animation_mobile"].forEach(function (key) {
1132
+ try {
1133
+ if (marketplace.storefront[key]) {
1134
+ var embedUrl = new URL("https://embed.v3.contentfabric.io");
1135
+ var targetHash = LinkTargetHash(marketplace.storefront[key]);
1136
+ embedUrl.searchParams.set("p", "");
1137
+ embedUrl.searchParams.set("net", _this5.network === "main" ? "main" : "demo");
1138
+ embedUrl.searchParams.set("ath", (_this5.__authorization || {}).authToken || _this5.publicStaticToken);
1139
+ embedUrl.searchParams.set("vid", targetHash);
1140
+ embedUrl.searchParams.set("ap", "");
1141
+ if (!key.startsWith("reveal")) {
1142
+ embedUrl.searchParams.set("m", "");
1143
+ embedUrl.searchParams.set("lp", "");
1144
+ }
1145
+ marketplace.storefront["".concat(key, "_embed_url")] = embedUrl.toString();
1146
+ }
1147
+ // eslint-disable-next-line no-empty
1148
+ } catch (error) {}
1149
+ });
1150
+ this.cachedMarketplaces[marketplaceId] = marketplace;
1151
+ case 21:
1152
+ return _context15.abrupt("return", this.cachedMarketplaces[marketplaceId]);
1153
+ case 22:
1154
+ case "end":
1155
+ return _context15.stop();
1372
1156
  }
1373
1157
  }, _callee15, this);
1374
1158
  }));
1375
-
1376
1159
  function LoadMarketplace(_x17) {
1377
1160
  return _LoadMarketplace.apply(this, arguments);
1378
1161
  }
1379
-
1380
1162
  return LoadMarketplace;
1381
1163
  }()
1382
1164
  }, {
@@ -1384,344 +1166,286 @@ var ElvWalletClient = /*#__PURE__*/function () {
1384
1166
  value: function () {
1385
1167
  var _FilteredQuery = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16() {
1386
1168
  var _this6 = this;
1387
-
1388
1169
  var _ref14,
1389
- _ref14$mode,
1390
- mode,
1391
- _ref14$sortBy,
1392
- sortBy,
1393
- _ref14$sortDesc,
1394
- sortDesc,
1395
- filter,
1396
- editionFilters,
1397
- attributeFilters,
1398
- contractAddress,
1399
- tokenId,
1400
- currency,
1401
- marketplaceParams,
1402
- tenantId,
1403
- collectionIndexes,
1404
- priceRange,
1405
- tokenIdRange,
1406
- capLimit,
1407
- userAddress,
1408
- sellerAddress,
1409
- _ref14$lastNDays,
1410
- lastNDays,
1411
- _ref14$includeCheckou,
1412
- includeCheckoutLocked,
1413
- _ref14$start,
1414
- start,
1415
- _ref14$limit,
1416
- limit,
1417
- params,
1418
- marketplaceInfo,
1419
- marketplace,
1420
- filters,
1421
- path,
1422
- _ref16,
1423
- contents,
1424
- paging,
1425
- _args16 = arguments;
1426
-
1170
+ _ref14$mode,
1171
+ mode,
1172
+ _ref14$sortBy,
1173
+ sortBy,
1174
+ _ref14$sortDesc,
1175
+ sortDesc,
1176
+ filter,
1177
+ editionFilters,
1178
+ attributeFilters,
1179
+ contractAddress,
1180
+ tokenId,
1181
+ currency,
1182
+ marketplaceParams,
1183
+ tenantId,
1184
+ collectionIndexes,
1185
+ priceRange,
1186
+ tokenIdRange,
1187
+ capLimit,
1188
+ userAddress,
1189
+ sellerAddress,
1190
+ _ref14$lastNDays,
1191
+ lastNDays,
1192
+ _ref14$includeCheckou,
1193
+ includeCheckoutLocked,
1194
+ _ref14$start,
1195
+ start,
1196
+ _ref14$limit,
1197
+ limit,
1198
+ params,
1199
+ marketplaceInfo,
1200
+ marketplace,
1201
+ filters,
1202
+ path,
1203
+ _ref16,
1204
+ contents,
1205
+ paging,
1206
+ _args16 = arguments;
1427
1207
  return _regeneratorRuntime.wrap(function _callee16$(_context16) {
1428
- while (1) {
1429
- switch (_context16.prev = _context16.next) {
1430
- case 0:
1431
- _ref14 = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {}, _ref14$mode = _ref14.mode, mode = _ref14$mode === void 0 ? "listings" : _ref14$mode, _ref14$sortBy = _ref14.sortBy, sortBy = _ref14$sortBy === void 0 ? "created" : _ref14$sortBy, _ref14$sortDesc = _ref14.sortDesc, sortDesc = _ref14$sortDesc === void 0 ? false : _ref14$sortDesc, filter = _ref14.filter, editionFilters = _ref14.editionFilters, attributeFilters = _ref14.attributeFilters, contractAddress = _ref14.contractAddress, tokenId = _ref14.tokenId, currency = _ref14.currency, marketplaceParams = _ref14.marketplaceParams, tenantId = _ref14.tenantId, collectionIndexes = _ref14.collectionIndexes, priceRange = _ref14.priceRange, tokenIdRange = _ref14.tokenIdRange, capLimit = _ref14.capLimit, userAddress = _ref14.userAddress, sellerAddress = _ref14.sellerAddress, _ref14$lastNDays = _ref14.lastNDays, lastNDays = _ref14$lastNDays === void 0 ? -1 : _ref14$lastNDays, _ref14$includeCheckou = _ref14.includeCheckoutLocked, includeCheckoutLocked = _ref14$includeCheckou === void 0 ? false : _ref14$includeCheckou, _ref14$start = _ref14.start, start = _ref14$start === void 0 ? 0 : _ref14$start, _ref14$limit = _ref14.limit, limit = _ref14$limit === void 0 ? 50 : _ref14$limit;
1432
- collectionIndexes = (collectionIndexes || []).map(function (i) {
1433
- return parseInt(i);
1434
- });
1435
- params = {
1436
- start: start,
1437
- limit: limit,
1438
- sort_descending: sortDesc
1439
- }; // Created isn't a valid sort mode for owned
1440
-
1441
- if (mode === "owned" && sortBy === "created") {
1442
- sortBy = "default";
1443
- }
1444
-
1445
- if (mode !== "leaderboard") {
1446
- params.sort_by = sortBy;
1447
- }
1448
-
1449
- if (mode.includes("listings") && includeCheckoutLocked) {
1450
- params.checkout = true;
1451
- }
1452
-
1453
- if (!marketplaceParams) {
1454
- _context16.next = 14;
1455
- break;
1456
- }
1457
-
1458
- _context16.next = 9;
1459
- return this.MarketplaceInfo({
1460
- marketplaceParams: marketplaceParams
1461
- });
1462
-
1463
- case 9:
1464
- marketplaceInfo = _context16.sent;
1465
-
1466
- if (!(collectionIndexes.length > 0)) {
1467
- _context16.next = 14;
1468
- break;
1469
- }
1470
-
1471
- _context16.next = 13;
1472
- return this.Marketplace({
1473
- marketplaceParams: marketplaceParams
1474
- });
1475
-
1476
- case 13:
1477
- marketplace = _context16.sent;
1478
-
1479
- case 14:
1480
- _context16.prev = 14;
1481
- filters = [];
1482
-
1483
- if (sellerAddress) {
1484
- filters.push("seller:eq:".concat(this.client.utils.FormatAddress(sellerAddress)));
1485
- } else if (userAddress && mode !== "owned") {
1486
- filters.push("addr:eq:".concat(this.client.utils.FormatAddress(userAddress)));
1487
- }
1488
-
1489
- if (marketplace && collectionIndexes.length >= 0) {
1490
- collectionIndexes.forEach(function (collectionIndex) {
1491
- var collection = marketplace.collections[collectionIndex];
1492
- collection.items.forEach(function (sku) {
1493
- if (!sku) {
1494
- return;
1495
- }
1496
-
1497
- var item = marketplace.items.find(function (item) {
1498
- return item.sku === sku;
1499
- });
1500
-
1501
- if (!item) {
1502
- return;
1503
- }
1504
-
1505
- var address = Utils.SafeTraverse(item, "nft_template", "nft", "address");
1506
-
1507
- if (address) {
1508
- filters.push("".concat(mode === "owned" ? "contract_addr" : "contract", ":eq:").concat(Utils.FormatAddress(address)));
1509
- }
1510
- });
1511
- });
1512
- } else if (marketplaceInfo || tenantId) {
1513
- filters.push("tenant:eq:".concat(marketplaceInfo ? marketplaceInfo.tenantId : tenantId));
1514
- }
1515
-
1516
- if (contractAddress) {
1517
- if (mode === "owned") {
1518
- filters.push("contract_addr:eq:".concat(Utils.FormatAddress(contractAddress)));
1519
- } else {
1520
- filters.push("contract:eq:".concat(Utils.FormatAddress(contractAddress)));
1521
- }
1522
-
1523
- if (tokenId) {
1524
- filters.push("token:eq:".concat(tokenId));
1525
- }
1526
- } else if (filter) {
1527
- if (mode.includes("listing")) {
1528
- filters.push("nft/display_name:eq:".concat(filter));
1529
- } else if (mode === "owned") {
1530
- filters.push("meta/display_name:eq:".concat(filter));
1531
- } else {
1532
- filters.push("name:eq:".concat(filter));
1533
- }
1534
- }
1535
-
1536
- if (editionFilters) {
1537
- editionFilters.forEach(function (editionFilter) {
1538
- if (mode.includes("listing")) {
1539
- filters.push("nft/edition_name:eq:".concat(editionFilter));
1540
- } else if (mode === "owned") {
1541
- filters.push("meta:@>:{\"edition_name\":\"".concat(editionFilter, "\"}"));
1542
- params.exact = false;
1543
- } else {
1544
- filters.push("edition:eq:".concat(editionFilter));
1208
+ while (1) switch (_context16.prev = _context16.next) {
1209
+ case 0:
1210
+ _ref14 = _args16.length > 0 && _args16[0] !== undefined ? _args16[0] : {}, _ref14$mode = _ref14.mode, mode = _ref14$mode === void 0 ? "listings" : _ref14$mode, _ref14$sortBy = _ref14.sortBy, sortBy = _ref14$sortBy === void 0 ? "created" : _ref14$sortBy, _ref14$sortDesc = _ref14.sortDesc, sortDesc = _ref14$sortDesc === void 0 ? false : _ref14$sortDesc, filter = _ref14.filter, editionFilters = _ref14.editionFilters, attributeFilters = _ref14.attributeFilters, contractAddress = _ref14.contractAddress, tokenId = _ref14.tokenId, currency = _ref14.currency, marketplaceParams = _ref14.marketplaceParams, tenantId = _ref14.tenantId, collectionIndexes = _ref14.collectionIndexes, priceRange = _ref14.priceRange, tokenIdRange = _ref14.tokenIdRange, capLimit = _ref14.capLimit, userAddress = _ref14.userAddress, sellerAddress = _ref14.sellerAddress, _ref14$lastNDays = _ref14.lastNDays, lastNDays = _ref14$lastNDays === void 0 ? -1 : _ref14$lastNDays, _ref14$includeCheckou = _ref14.includeCheckoutLocked, includeCheckoutLocked = _ref14$includeCheckou === void 0 ? false : _ref14$includeCheckou, _ref14$start = _ref14.start, start = _ref14$start === void 0 ? 0 : _ref14$start, _ref14$limit = _ref14.limit, limit = _ref14$limit === void 0 ? 50 : _ref14$limit;
1211
+ collectionIndexes = (collectionIndexes || []).map(function (i) {
1212
+ return parseInt(i);
1213
+ });
1214
+ params = {
1215
+ start: start,
1216
+ limit: limit,
1217
+ sort_descending: sortDesc
1218
+ }; // Created isn't a valid sort mode for owned
1219
+ if (mode === "owned" && sortBy === "created") {
1220
+ sortBy = "default";
1221
+ }
1222
+ if (mode !== "leaderboard") {
1223
+ params.sort_by = sortBy;
1224
+ }
1225
+ if (mode.includes("listings") && includeCheckoutLocked) {
1226
+ params.checkout = true;
1227
+ }
1228
+ if (!marketplaceParams) {
1229
+ _context16.next = 14;
1230
+ break;
1231
+ }
1232
+ _context16.next = 9;
1233
+ return this.MarketplaceInfo({
1234
+ marketplaceParams: marketplaceParams
1235
+ });
1236
+ case 9:
1237
+ marketplaceInfo = _context16.sent;
1238
+ if (!(collectionIndexes.length > 0)) {
1239
+ _context16.next = 14;
1240
+ break;
1241
+ }
1242
+ _context16.next = 13;
1243
+ return this.Marketplace({
1244
+ marketplaceParams: marketplaceParams
1245
+ });
1246
+ case 13:
1247
+ marketplace = _context16.sent;
1248
+ case 14:
1249
+ _context16.prev = 14;
1250
+ filters = [];
1251
+ if (sellerAddress) {
1252
+ filters.push("seller:eq:".concat(this.client.utils.FormatAddress(sellerAddress)));
1253
+ } else if (userAddress && mode !== "owned") {
1254
+ filters.push("addr:eq:".concat(this.client.utils.FormatAddress(userAddress)));
1255
+ }
1256
+ if (marketplace && collectionIndexes.length >= 0) {
1257
+ collectionIndexes.forEach(function (collectionIndex) {
1258
+ var collection = marketplace.collections[collectionIndex];
1259
+ collection.items.forEach(function (sku) {
1260
+ if (!sku) {
1261
+ return;
1545
1262
  }
1546
- });
1547
- }
1548
-
1549
- if (attributeFilters) {
1550
- attributeFilters.map(function (_ref15) {
1551
- var name = _ref15.name,
1552
- value = _ref15.value;
1553
-
1554
- if (!name || !value) {
1263
+ var item = marketplace.items.find(function (item) {
1264
+ return item.sku === sku;
1265
+ });
1266
+ if (!item) {
1555
1267
  return;
1556
1268
  }
1557
-
1558
- filters.push("nft/attributes/".concat(name, ":eq:").concat(value));
1269
+ var address = Utils.SafeTraverse(item, "nft_template", "nft", "address");
1270
+ if (address) {
1271
+ filters.push("".concat(mode === "owned" ? "contract_addr" : "contract", ":eq:").concat(Utils.FormatAddress(address)));
1272
+ }
1559
1273
  });
1274
+ });
1275
+ } else if (marketplaceInfo || tenantId) {
1276
+ filters.push("tenant:eq:".concat(marketplaceInfo ? marketplaceInfo.tenantId : tenantId));
1277
+ }
1278
+ if (contractAddress) {
1279
+ if (mode === "owned") {
1280
+ filters.push("contract_addr:eq:".concat(Utils.FormatAddress(contractAddress)));
1281
+ } else {
1282
+ filters.push("contract:eq:".concat(Utils.FormatAddress(contractAddress)));
1560
1283
  }
1561
-
1562
- if (currency) {
1563
- filters.push("link_type:eq:sol");
1284
+ if (tokenId) {
1285
+ filters.push("token:eq:".concat(tokenId));
1564
1286
  }
1565
-
1566
- if (lastNDays && lastNDays > 0) {
1567
- filters.push("created:gt:".concat((Date.now() / 1000 - lastNDays * 24 * 60 * 60).toFixed(0)));
1287
+ } else if (filter) {
1288
+ if (mode.includes("listing")) {
1289
+ filters.push("nft/display_name:eq:".concat(filter));
1290
+ } else if (mode === "owned") {
1291
+ filters.push("meta/display_name:eq:".concat(filter));
1292
+ } else {
1293
+ filters.push("name:eq:".concat(filter));
1568
1294
  }
1569
-
1570
- if (priceRange) {
1571
- if (priceRange.min) {
1572
- filters.push("price:ge:".concat(parseFloat(priceRange.min)));
1573
- }
1574
-
1575
- if (priceRange.max) {
1576
- filters.push("price:le:".concat(parseFloat(priceRange.max)));
1577
- }
1578
- }
1579
-
1580
- if (tokenIdRange) {
1581
- if (tokenIdRange.min) {
1582
- filters.push("info/token_id:ge:".concat(parseInt(tokenIdRange.min)));
1295
+ }
1296
+ if (editionFilters) {
1297
+ editionFilters.forEach(function (editionFilter) {
1298
+ if (mode.includes("listing")) {
1299
+ filters.push("nft/edition_name:eq:".concat(editionFilter));
1300
+ } else if (mode === "owned") {
1301
+ filters.push("meta:@>:{\"edition_name\":\"".concat(editionFilter, "\"}"));
1302
+ params.exact = false;
1303
+ } else {
1304
+ filters.push("edition:eq:".concat(editionFilter));
1583
1305
  }
1584
-
1585
- if (tokenIdRange.max) {
1586
- filters.push("info/token_id:le:".concat(parseInt(tokenIdRange.max)));
1306
+ });
1307
+ }
1308
+ if (attributeFilters) {
1309
+ attributeFilters.map(function (_ref15) {
1310
+ var name = _ref15.name,
1311
+ value = _ref15.value;
1312
+ if (!name || !value) {
1313
+ return;
1587
1314
  }
1315
+ filters.push("nft/attributes/".concat(name, ":eq:").concat(value));
1316
+ });
1317
+ }
1318
+ if (currency) {
1319
+ filters.push("link_type:eq:sol");
1320
+ }
1321
+ if (lastNDays && lastNDays > 0) {
1322
+ filters.push("created:gt:".concat((Date.now() / 1000 - lastNDays * 24 * 60 * 60).toFixed(0)));
1323
+ }
1324
+ if (priceRange) {
1325
+ if (priceRange.min) {
1326
+ filters.push("price:ge:".concat(parseFloat(priceRange.min)));
1588
1327
  }
1589
-
1590
- if (capLimit) {
1591
- filters.push("info/cap:le:".concat(parseInt(capLimit)));
1328
+ if (priceRange.max) {
1329
+ filters.push("price:le:".concat(parseFloat(priceRange.max)));
1592
1330
  }
1593
-
1594
- _context16.t0 = mode;
1595
- _context16.next = _context16.t0 === "owned" ? 29 : _context16.t0 === "listings" ? 31 : _context16.t0 === "transfers" ? 33 : _context16.t0 === "sales" ? 37 : _context16.t0 === "listing-stats" ? 41 : _context16.t0 === "sales-stats" ? 43 : _context16.t0 === "leaderboard" ? 46 : 48;
1596
- break;
1597
-
1598
- case 29:
1599
- path = UrlJoin("as", "wlt", userAddress || this.UserAddress());
1600
- return _context16.abrupt("break", 48);
1601
-
1602
- case 31:
1603
- path = UrlJoin("as", "mkt", "f");
1604
- return _context16.abrupt("break", 48);
1605
-
1606
- case 33:
1607
- path = UrlJoin("as", "mkt", "hst", "f");
1608
- filters.push("action:eq:TRANSFERRED");
1609
- filters.push("action:eq:SOLD");
1610
- return _context16.abrupt("break", 48);
1611
-
1612
- case 37:
1613
- path = UrlJoin("as", "mkt", "hst", "f");
1614
- filters.push("action:eq:SOLD");
1615
- filters.push("seller:co:0x");
1616
- return _context16.abrupt("break", 48);
1617
-
1618
- case 41:
1619
- path = UrlJoin("as", "mkt", "stats", "listed");
1620
- return _context16.abrupt("break", 48);
1621
-
1622
- case 43:
1623
- path = UrlJoin("as", "mkt", "stats", "sold");
1624
- filters.push("seller:co:0x");
1625
- return _context16.abrupt("break", 48);
1626
-
1627
- case 46:
1628
- path = UrlJoin("as", "wlt", "leaders");
1629
- return _context16.abrupt("break", 48);
1630
-
1631
- case 48:
1632
- if (filters.length > 0) {
1633
- params.filter = filters;
1331
+ }
1332
+ if (tokenIdRange) {
1333
+ if (tokenIdRange.min) {
1334
+ filters.push("info/token_id:ge:".concat(parseInt(tokenIdRange.min)));
1634
1335
  }
1635
-
1636
- if (!mode.includes("stats")) {
1637
- _context16.next = 53;
1638
- break;
1336
+ if (tokenIdRange.max) {
1337
+ filters.push("info/token_id:le:".concat(parseInt(tokenIdRange.max)));
1639
1338
  }
1640
-
1641
- _context16.next = 52;
1642
- return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
1643
- path: path,
1644
- method: "GET",
1645
- queryParams: params
1646
- }));
1647
-
1648
- case 52:
1649
- return _context16.abrupt("return", _context16.sent);
1650
-
1651
- case 53:
1652
- _context16.t2 = Utils;
1653
- _context16.next = 56;
1654
- return this.client.authClient.MakeAuthServiceRequest({
1655
- path: path,
1656
- method: "GET",
1657
- queryParams: params
1658
- });
1659
-
1660
- case 56:
1661
- _context16.t3 = _context16.sent;
1662
- _context16.next = 59;
1663
- return _context16.t2.ResponseToJson.call(_context16.t2, _context16.t3);
1664
-
1665
- case 59:
1666
- _context16.t1 = _context16.sent;
1667
-
1668
- if (_context16.t1) {
1669
- _context16.next = 62;
1670
- break;
1671
- }
1672
-
1673
- _context16.t1 = [];
1674
-
1675
- case 62:
1676
- _ref16 = _context16.t1;
1677
- contents = _ref16.contents;
1678
- paging = _ref16.paging;
1679
- return _context16.abrupt("return", {
1680
- paging: {
1681
- start: params.start,
1682
- limit: params.limit,
1683
- total: paging.total,
1684
- more: paging.total > start + limit
1685
- },
1686
- results: (contents || []).map(function (item) {
1687
- return ["owned", "listings"].includes(mode) ? FormatNFT(_this6, item) : item;
1688
- })
1689
- });
1690
-
1691
- case 68:
1692
- _context16.prev = 68;
1693
- _context16.t4 = _context16["catch"](14);
1694
-
1695
- if (!(_context16.t4.status && _context16.t4.status.toString() === "404")) {
1696
- _context16.next = 72;
1697
- break;
1698
- }
1699
-
1700
- return _context16.abrupt("return", {
1701
- paging: {
1702
- start: params.start,
1703
- limit: params.limit,
1704
- total: 0,
1705
- more: false
1706
- },
1707
- results: []
1708
- });
1709
-
1710
- case 72:
1711
- throw _context16.t4;
1712
-
1713
- case 73:
1714
- case "end":
1715
- return _context16.stop();
1716
- }
1339
+ }
1340
+ if (capLimit) {
1341
+ filters.push("info/cap:le:".concat(parseInt(capLimit)));
1342
+ }
1343
+ _context16.t0 = mode;
1344
+ _context16.next = _context16.t0 === "owned" ? 29 : _context16.t0 === "listings" ? 31 : _context16.t0 === "transfers" ? 33 : _context16.t0 === "sales" ? 37 : _context16.t0 === "listing-stats" ? 41 : _context16.t0 === "sales-stats" ? 43 : _context16.t0 === "leaderboard" ? 46 : 48;
1345
+ break;
1346
+ case 29:
1347
+ path = UrlJoin("as", "wlt", userAddress || this.UserAddress());
1348
+ return _context16.abrupt("break", 48);
1349
+ case 31:
1350
+ path = UrlJoin("as", "mkt", "f");
1351
+ return _context16.abrupt("break", 48);
1352
+ case 33:
1353
+ path = UrlJoin("as", "mkt", "hst", "f");
1354
+ filters.push("action:eq:TRANSFERRED");
1355
+ filters.push("action:eq:SOLD");
1356
+ return _context16.abrupt("break", 48);
1357
+ case 37:
1358
+ path = UrlJoin("as", "mkt", "hst", "f");
1359
+ filters.push("action:eq:SOLD");
1360
+ filters.push("seller:co:0x");
1361
+ return _context16.abrupt("break", 48);
1362
+ case 41:
1363
+ path = UrlJoin("as", "mkt", "stats", "listed");
1364
+ return _context16.abrupt("break", 48);
1365
+ case 43:
1366
+ path = UrlJoin("as", "mkt", "stats", "sold");
1367
+ filters.push("seller:co:0x");
1368
+ return _context16.abrupt("break", 48);
1369
+ case 46:
1370
+ path = UrlJoin("as", "wlt", "leaders");
1371
+ return _context16.abrupt("break", 48);
1372
+ case 48:
1373
+ if (filters.length > 0) {
1374
+ params.filter = filters;
1375
+ }
1376
+ if (!mode.includes("stats")) {
1377
+ _context16.next = 53;
1378
+ break;
1379
+ }
1380
+ _context16.next = 52;
1381
+ return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
1382
+ path: path,
1383
+ method: "GET",
1384
+ queryParams: params
1385
+ }));
1386
+ case 52:
1387
+ return _context16.abrupt("return", _context16.sent);
1388
+ case 53:
1389
+ _context16.t2 = Utils;
1390
+ _context16.next = 56;
1391
+ return this.client.authClient.MakeAuthServiceRequest({
1392
+ path: path,
1393
+ method: "GET",
1394
+ queryParams: params
1395
+ });
1396
+ case 56:
1397
+ _context16.t3 = _context16.sent;
1398
+ _context16.next = 59;
1399
+ return _context16.t2.ResponseToJson.call(_context16.t2, _context16.t3);
1400
+ case 59:
1401
+ _context16.t1 = _context16.sent;
1402
+ if (_context16.t1) {
1403
+ _context16.next = 62;
1404
+ break;
1405
+ }
1406
+ _context16.t1 = [];
1407
+ case 62:
1408
+ _ref16 = _context16.t1;
1409
+ contents = _ref16.contents;
1410
+ paging = _ref16.paging;
1411
+ return _context16.abrupt("return", {
1412
+ paging: {
1413
+ start: params.start,
1414
+ limit: params.limit,
1415
+ total: paging.total,
1416
+ more: paging.total > start + limit
1417
+ },
1418
+ results: (contents || []).map(function (item) {
1419
+ return ["owned", "listings"].includes(mode) ? FormatNFT(_this6, item) : item;
1420
+ })
1421
+ });
1422
+ case 68:
1423
+ _context16.prev = 68;
1424
+ _context16.t4 = _context16["catch"](14);
1425
+ if (!(_context16.t4.status && _context16.t4.status.toString() === "404")) {
1426
+ _context16.next = 72;
1427
+ break;
1428
+ }
1429
+ return _context16.abrupt("return", {
1430
+ paging: {
1431
+ start: params.start,
1432
+ limit: params.limit,
1433
+ total: 0,
1434
+ more: false
1435
+ },
1436
+ results: []
1437
+ });
1438
+ case 72:
1439
+ throw _context16.t4;
1440
+ case 73:
1441
+ case "end":
1442
+ return _context16.stop();
1717
1443
  }
1718
1444
  }, _callee16, this, [[14, 68]]);
1719
1445
  }));
1720
-
1721
1446
  function FilteredQuery() {
1722
1447
  return _FilteredQuery.apply(this, arguments);
1723
1448
  }
1724
-
1725
1449
  return FilteredQuery;
1726
1450
  }()
1727
1451
  }, {
@@ -1730,99 +1454,83 @@ var ElvWalletClient = /*#__PURE__*/function () {
1730
1454
  var _MintingStatus = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref17) {
1731
1455
  var marketplaceParams, tenantId, marketplaceInfo, response;
1732
1456
  return _regeneratorRuntime.wrap(function _callee17$(_context17) {
1733
- while (1) {
1734
- switch (_context17.prev = _context17.next) {
1735
- case 0:
1736
- marketplaceParams = _ref17.marketplaceParams, tenantId = _ref17.tenantId;
1737
-
1738
- if (tenantId) {
1739
- _context17.next = 6;
1740
- break;
1457
+ while (1) switch (_context17.prev = _context17.next) {
1458
+ case 0:
1459
+ marketplaceParams = _ref17.marketplaceParams, tenantId = _ref17.tenantId;
1460
+ if (tenantId) {
1461
+ _context17.next = 6;
1462
+ break;
1463
+ }
1464
+ _context17.next = 4;
1465
+ return this.MarketplaceInfo({
1466
+ marketplaceParams: marketplaceParams || this.selectedMarketplaceInfo
1467
+ });
1468
+ case 4:
1469
+ marketplaceInfo = _context17.sent;
1470
+ tenantId = marketplaceInfo.tenantId;
1471
+ case 6:
1472
+ _context17.prev = 6;
1473
+ _context17.next = 9;
1474
+ return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
1475
+ path: UrlJoin("as", "wlt", "status", "act", tenantId),
1476
+ method: "GET",
1477
+ headers: {
1478
+ Authorization: "Bearer ".concat(this.AuthToken())
1741
1479
  }
1742
-
1743
- _context17.next = 4;
1744
- return this.MarketplaceInfo({
1745
- marketplaceParams: marketplaceParams || this.selectedMarketplaceInfo
1746
- });
1747
-
1748
- case 4:
1749
- marketplaceInfo = _context17.sent;
1750
- tenantId = marketplaceInfo.tenantId;
1751
-
1752
- case 6:
1753
- _context17.prev = 6;
1754
- _context17.next = 9;
1755
- return Utils.ResponseToJson(this.client.authClient.MakeAuthServiceRequest({
1756
- path: UrlJoin("as", "wlt", "status", "act", tenantId),
1757
- method: "GET",
1758
- headers: {
1759
- Authorization: "Bearer ".concat(this.AuthToken())
1760
- }
1761
- }));
1762
-
1763
- case 9:
1764
- response = _context17.sent;
1765
- return _context17.abrupt("return", response.map(function (status) {
1766
- var _status$op$split = status.op.split(":"),
1767
- _status$op$split2 = _slicedToArray(_status$op$split, 3),
1768
- op = _status$op$split2[0],
1769
- address = _status$op$split2[1],
1770
- id = _status$op$split2[2];
1771
-
1772
- address = address.startsWith("0x") ? Utils.FormatAddress(address) : address;
1773
- var confirmationId, tokenId;
1774
-
1775
- if (op === "nft-buy") {
1776
- confirmationId = id;
1777
- } else if (op === "nft-claim") {
1778
- confirmationId = id;
1779
- status.marketplaceId = address;
1780
-
1781
- if (status.extra && status.extra["0"]) {
1782
- address = status.extra.token_addr;
1783
- tokenId = status.extra.token_id_str;
1784
- }
1785
- } else if (op === "nft-redeem") {
1786
- confirmationId = status.op.split(":").slice(-1)[0];
1787
- } else {
1788
- tokenId = id;
1480
+ }));
1481
+ case 9:
1482
+ response = _context17.sent;
1483
+ return _context17.abrupt("return", response.map(function (status) {
1484
+ var _status$op$split = status.op.split(":"),
1485
+ _status$op$split2 = _slicedToArray(_status$op$split, 3),
1486
+ op = _status$op$split2[0],
1487
+ address = _status$op$split2[1],
1488
+ id = _status$op$split2[2];
1489
+ address = address.startsWith("0x") ? Utils.FormatAddress(address) : address;
1490
+ var confirmationId, tokenId;
1491
+ if (op === "nft-buy") {
1492
+ confirmationId = id;
1493
+ } else if (op === "nft-claim") {
1494
+ confirmationId = id;
1495
+ status.marketplaceId = address;
1496
+ if (status.extra && status.extra["0"]) {
1497
+ address = status.extra.token_addr;
1498
+ tokenId = status.extra.token_id_str;
1789
1499
  }
1790
-
1791
- if (op === "nft-transfer") {
1792
- confirmationId = status.extra && status.extra.trans_id;
1793
- }
1794
-
1795
- return _objectSpread(_objectSpread({}, status), {}, {
1796
- timestamp: new Date(status.ts),
1797
- state: status.state && _typeof(status.state) === "object" ? Object.values(status.state) : status.state,
1798
- extra: status.extra && _typeof(status.extra) === "object" ? Object.values(status.extra) : status.extra,
1799
- confirmationId: confirmationId,
1800
- op: op,
1801
- address: address,
1802
- tokenId: tokenId
1803
- });
1804
- }).sort(function (a, b) {
1805
- return a.ts < b.ts ? 1 : -1;
1806
- }));
1807
-
1808
- case 13:
1809
- _context17.prev = 13;
1810
- _context17.t0 = _context17["catch"](6);
1811
- this.Log("Failed to retrieve minting status", true, _context17.t0);
1812
- return _context17.abrupt("return", []);
1813
-
1814
- case 17:
1815
- case "end":
1816
- return _context17.stop();
1817
- }
1500
+ } else if (op === "nft-redeem") {
1501
+ confirmationId = status.op.split(":").slice(-1)[0];
1502
+ } else {
1503
+ tokenId = id;
1504
+ }
1505
+ if (op === "nft-transfer") {
1506
+ confirmationId = status.extra && status.extra.trans_id;
1507
+ }
1508
+ return _objectSpread(_objectSpread({}, status), {}, {
1509
+ timestamp: new Date(status.ts),
1510
+ state: status.state && _typeof(status.state) === "object" ? Object.values(status.state) : status.state,
1511
+ extra: status.extra && _typeof(status.extra) === "object" ? Object.values(status.extra) : status.extra,
1512
+ confirmationId: confirmationId,
1513
+ op: op,
1514
+ address: address,
1515
+ tokenId: tokenId
1516
+ });
1517
+ }).sort(function (a, b) {
1518
+ return a.ts < b.ts ? 1 : -1;
1519
+ }));
1520
+ case 13:
1521
+ _context17.prev = 13;
1522
+ _context17.t0 = _context17["catch"](6);
1523
+ this.Log("Failed to retrieve minting status", true, _context17.t0);
1524
+ return _context17.abrupt("return", []);
1525
+ case 17:
1526
+ case "end":
1527
+ return _context17.stop();
1818
1528
  }
1819
1529
  }, _callee17, this, [[6, 13]]);
1820
1530
  }));
1821
-
1822
1531
  function MintingStatus(_x20) {
1823
1532
  return _MintingStatus.apply(this, arguments);
1824
1533
  }
1825
-
1826
1534
  return MintingStatus;
1827
1535
  }()
1828
1536
  }], [{
@@ -1830,154 +1538,121 @@ var ElvWalletClient = /*#__PURE__*/function () {
1830
1538
  value: function () {
1831
1539
  var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref18) {
1832
1540
  var client, _ref18$appId, appId, _ref18$network, network, _ref18$mode, mode, localization, marketplaceParams, previewMarketplaceId, _ref18$storeAuthToken, storeAuthToken, _ref19, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, previewMarketplaceHash, walletClient, url, savedToken;
1833
-
1834
1541
  return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1835
- while (1) {
1836
- switch (_context18.prev = _context18.next) {
1837
- case 0:
1838
- client = _ref18.client, _ref18$appId = _ref18.appId, appId = _ref18$appId === void 0 ? "general" : _ref18$appId, _ref18$network = _ref18.network, network = _ref18$network === void 0 ? "main" : _ref18$network, _ref18$mode = _ref18.mode, mode = _ref18$mode === void 0 ? "production" : _ref18$mode, localization = _ref18.localization, marketplaceParams = _ref18.marketplaceParams, previewMarketplaceId = _ref18.previewMarketplaceId, _ref18$storeAuthToken = _ref18.storeAuthToken, storeAuthToken = _ref18$storeAuthToken === void 0 ? true : _ref18$storeAuthToken;
1839
- _ref19 = marketplaceParams || {}, tenantSlug = _ref19.tenantSlug, marketplaceSlug = _ref19.marketplaceSlug, marketplaceId = _ref19.marketplaceId, marketplaceHash = _ref19.marketplaceHash;
1840
-
1841
- if (Configuration[network]) {
1842
- _context18.next = 6;
1843
- break;
1844
- }
1845
-
1846
- throw Error("ElvWalletClient: Invalid network ".concat(network));
1847
-
1848
- case 6:
1849
- if (Configuration[network][mode]) {
1850
- _context18.next = 8;
1851
- break;
1852
- }
1853
-
1854
- throw Error("ElvWalletClient: Invalid mode ".concat(mode));
1855
-
1856
- case 8:
1857
- if (client) {
1858
- _context18.next = 12;
1859
- break;
1860
- }
1861
-
1862
- _context18.next = 11;
1863
- return ElvClient.FromNetworkName({
1864
- networkName: network,
1865
- assumeV3: true
1866
- });
1867
-
1868
- case 11:
1869
- client = _context18.sent;
1870
-
1871
- case 12:
1872
- previewMarketplaceHash = previewMarketplaceId;
1873
-
1874
- if (!(previewMarketplaceHash && !previewMarketplaceHash.startsWith("hq__"))) {
1875
- _context18.next = 17;
1876
- break;
1877
- }
1878
-
1879
- _context18.next = 16;
1880
- return client.LatestVersionHash({
1881
- objectId: previewMarketplaceId
1882
- });
1883
-
1884
- case 16:
1885
- previewMarketplaceHash = _context18.sent;
1886
-
1887
- case 17:
1888
- walletClient = new ElvWalletClient({
1889
- appId: appId,
1890
- client: client,
1891
- network: network,
1892
- mode: mode,
1893
- localization: localization,
1894
- marketplaceInfo: {
1895
- tenantSlug: tenantSlug,
1896
- marketplaceSlug: marketplaceSlug,
1897
- marketplaceId: marketplaceHash ? client.utils.DecodeVersionHash(marketplaceHash).objectId : marketplaceId,
1898
- marketplaceHash: marketplaceHash
1899
- },
1900
- previewMarketplaceHash: previewMarketplaceHash,
1901
- storeAuthToken: storeAuthToken
1902
- });
1903
-
1904
- if (!(inBrowser && window.location && window.location.href)) {
1905
- _context18.next = 37;
1906
- break;
1907
- }
1908
-
1909
- url = new URL(window.location.href);
1910
-
1911
- if (!url.searchParams.get("elvToken")) {
1912
- _context18.next = 27;
1913
- break;
1914
- }
1915
-
1916
- _context18.next = 23;
1917
- return walletClient.Authenticate({
1918
- token: url.searchParams.get("elvToken")
1919
- });
1920
-
1921
- case 23:
1922
- url.searchParams["delete"]("elvToken");
1923
- window.history.replaceState("", "", url);
1542
+ while (1) switch (_context18.prev = _context18.next) {
1543
+ case 0:
1544
+ client = _ref18.client, _ref18$appId = _ref18.appId, appId = _ref18$appId === void 0 ? "general" : _ref18$appId, _ref18$network = _ref18.network, network = _ref18$network === void 0 ? "main" : _ref18$network, _ref18$mode = _ref18.mode, mode = _ref18$mode === void 0 ? "production" : _ref18$mode, localization = _ref18.localization, marketplaceParams = _ref18.marketplaceParams, previewMarketplaceId = _ref18.previewMarketplaceId, _ref18$storeAuthToken = _ref18.storeAuthToken, storeAuthToken = _ref18$storeAuthToken === void 0 ? true : _ref18$storeAuthToken;
1545
+ _ref19 = marketplaceParams || {}, tenantSlug = _ref19.tenantSlug, marketplaceSlug = _ref19.marketplaceSlug, marketplaceId = _ref19.marketplaceId, marketplaceHash = _ref19.marketplaceHash;
1546
+ if (Configuration[network]) {
1547
+ _context18.next = 6;
1548
+ break;
1549
+ }
1550
+ throw Error("ElvWalletClient: Invalid network ".concat(network));
1551
+ case 6:
1552
+ if (Configuration[network][mode]) {
1553
+ _context18.next = 8;
1554
+ break;
1555
+ }
1556
+ throw Error("ElvWalletClient: Invalid mode ".concat(mode));
1557
+ case 8:
1558
+ if (client) {
1559
+ _context18.next = 12;
1560
+ break;
1561
+ }
1562
+ _context18.next = 11;
1563
+ return ElvClient.FromNetworkName({
1564
+ networkName: network,
1565
+ assumeV3: true
1566
+ });
1567
+ case 11:
1568
+ client = _context18.sent;
1569
+ case 12:
1570
+ previewMarketplaceHash = previewMarketplaceId;
1571
+ if (!(previewMarketplaceHash && !previewMarketplaceHash.startsWith("hq__"))) {
1572
+ _context18.next = 17;
1573
+ break;
1574
+ }
1575
+ _context18.next = 16;
1576
+ return client.LatestVersionHash({
1577
+ objectId: previewMarketplaceId
1578
+ });
1579
+ case 16:
1580
+ previewMarketplaceHash = _context18.sent;
1581
+ case 17:
1582
+ walletClient = new ElvWalletClient({
1583
+ appId: appId,
1584
+ client: client,
1585
+ network: network,
1586
+ mode: mode,
1587
+ localization: localization,
1588
+ marketplaceInfo: {
1589
+ tenantSlug: tenantSlug,
1590
+ marketplaceSlug: marketplaceSlug,
1591
+ marketplaceId: marketplaceHash ? client.utils.DecodeVersionHash(marketplaceHash).objectId : marketplaceId,
1592
+ marketplaceHash: marketplaceHash
1593
+ },
1594
+ previewMarketplaceHash: previewMarketplaceHash,
1595
+ storeAuthToken: storeAuthToken
1596
+ });
1597
+ if (!(inBrowser && window.location && window.location.href)) {
1924
1598
  _context18.next = 37;
1925
1599
  break;
1926
-
1927
- case 27:
1928
- if (!(storeAuthToken && localStorageAvailable)) {
1929
- _context18.next = 37;
1930
- break;
1931
- }
1932
-
1933
- _context18.prev = 28;
1934
- // Load saved auth token
1935
- savedToken = localStorage.getItem("__elv-token-".concat(network));
1936
-
1937
- if (!savedToken) {
1938
- _context18.next = 33;
1939
- break;
1940
- }
1941
-
1942
- _context18.next = 33;
1943
- return walletClient.Authenticate({
1944
- token: savedToken
1945
- });
1946
-
1947
- case 33:
1600
+ }
1601
+ url = new URL(window.location.href);
1602
+ if (!url.searchParams.get("elvToken")) {
1603
+ _context18.next = 27;
1604
+ break;
1605
+ }
1606
+ _context18.next = 23;
1607
+ return walletClient.Authenticate({
1608
+ token: url.searchParams.get("elvToken")
1609
+ });
1610
+ case 23:
1611
+ url.searchParams["delete"]("elvToken");
1612
+ window.history.replaceState("", "", url);
1613
+ _context18.next = 37;
1614
+ break;
1615
+ case 27:
1616
+ if (!(storeAuthToken && localStorageAvailable)) {
1948
1617
  _context18.next = 37;
1949
1618
  break;
1950
-
1951
- case 35:
1952
- _context18.prev = 35;
1953
- _context18.t0 = _context18["catch"](28);
1954
-
1955
- case 37:
1956
- _context18.next = 39;
1957
- return walletClient.LoadAvailableMarketplaces();
1958
-
1959
- case 39:
1960
- return _context18.abrupt("return", walletClient);
1961
-
1962
- case 40:
1963
- case "end":
1964
- return _context18.stop();
1965
- }
1619
+ }
1620
+ _context18.prev = 28;
1621
+ // Load saved auth token
1622
+ savedToken = localStorage.getItem("__elv-token-".concat(network));
1623
+ if (!savedToken) {
1624
+ _context18.next = 33;
1625
+ break;
1626
+ }
1627
+ _context18.next = 33;
1628
+ return walletClient.Authenticate({
1629
+ token: savedToken
1630
+ });
1631
+ case 33:
1632
+ _context18.next = 37;
1633
+ break;
1634
+ case 35:
1635
+ _context18.prev = 35;
1636
+ _context18.t0 = _context18["catch"](28);
1637
+ case 37:
1638
+ _context18.next = 39;
1639
+ return walletClient.LoadAvailableMarketplaces();
1640
+ case 39:
1641
+ return _context18.abrupt("return", walletClient);
1642
+ case 40:
1643
+ case "end":
1644
+ return _context18.stop();
1966
1645
  }
1967
1646
  }, _callee18, null, [[28, 35]]);
1968
1647
  }));
1969
-
1970
1648
  function Initialize(_x21) {
1971
1649
  return _Initialize.apply(this, arguments);
1972
1650
  }
1973
-
1974
1651
  return Initialize;
1975
1652
  }()
1976
1653
  }]);
1977
-
1978
1654
  return ElvWalletClient;
1979
1655
  }();
1980
-
1981
1656
  Object.assign(ElvWalletClient.prototype, require("./ClientMethods"));
1982
1657
  Object.assign(ElvWalletClient.prototype, require("./Profile"));
1983
1658
  Object.assign(ElvWalletClient.prototype, require("./Notifications"));