@eluvio/elv-client-js 4.0.26 → 4.0.27

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.
@@ -1429,43 +1429,66 @@ var ElvClient = /*#__PURE__*/function () {
1429
1429
  }
1430
1430
  _context20.prev = 3;
1431
1431
  method = message.calledMethod;
1432
+ if (!(message.module === "walletClient")) {
1433
+ _context20.next = 15;
1434
+ break;
1435
+ }
1436
+ if (this.walletClient) {
1437
+ _context20.next = 8;
1438
+ break;
1439
+ }
1440
+ throw Error("Wallet client not set");
1441
+ case 8:
1442
+ if (!this.walletClient.ForbiddenMethods().includes(method)) {
1443
+ _context20.next = 10;
1444
+ break;
1445
+ }
1446
+ throw Error("Invalid user profile method: " + method);
1447
+ case 10:
1448
+ _context20.next = 12;
1449
+ return this.walletClient[method](message.args);
1450
+ case 12:
1451
+ methodResults = _context20.sent;
1452
+ _context20.next = 28;
1453
+ break;
1454
+ case 15:
1432
1455
  if (!(message.module === "userProfileClient")) {
1433
- _context20.next = 13;
1456
+ _context20.next = 23;
1434
1457
  break;
1435
1458
  }
1436
1459
  if (this.userProfileClient.FrameAllowedMethods().includes(method)) {
1437
- _context20.next = 8;
1460
+ _context20.next = 18;
1438
1461
  break;
1439
1462
  }
1440
1463
  throw Error("Invalid user profile method: " + method);
1441
- case 8:
1442
- _context20.next = 10;
1464
+ case 18:
1465
+ _context20.next = 20;
1443
1466
  return this.userProfileClient[method](message.args);
1444
- case 10:
1467
+ case 20:
1445
1468
  methodResults = _context20.sent;
1446
- _context20.next = 18;
1469
+ _context20.next = 28;
1447
1470
  break;
1448
- case 13:
1471
+ case 23:
1449
1472
  if (this.FrameAllowedMethods().includes(method)) {
1450
- _context20.next = 15;
1473
+ _context20.next = 25;
1451
1474
  break;
1452
1475
  }
1453
1476
  throw Error("Invalid method: " + method);
1454
- case 15:
1455
- _context20.next = 17;
1477
+ case 25:
1478
+ _context20.next = 27;
1456
1479
  return this[method](message.args);
1457
- case 17:
1480
+ case 27:
1458
1481
  methodResults = _context20.sent;
1459
- case 18:
1482
+ case 28:
1460
1483
  Respond(this.utils.MakeClonable({
1461
1484
  type: "ElvFrameResponse",
1462
1485
  requestId: message.requestId,
1463
1486
  response: methodResults
1464
1487
  }));
1465
- _context20.next = 27;
1488
+ _context20.next = 37;
1466
1489
  break;
1467
- case 21:
1468
- _context20.prev = 21;
1490
+ case 31:
1491
+ _context20.prev = 31;
1469
1492
  _context20.t0 = _context20["catch"](3);
1470
1493
  // eslint-disable-next-line no-console
1471
1494
  this.Log("Frame Message Error:\n Method: ".concat(message.calledMethod, "\n Arguments: ").concat(JSON.stringify(message.args, null, 2), "\n Error: ").concat(_typeof(_context20.t0) === "object" ? JSON.stringify(_context20.t0, null, 2) : _context20.t0), true);
@@ -1478,11 +1501,11 @@ var ElvClient = /*#__PURE__*/function () {
1478
1501
  requestId: message.requestId,
1479
1502
  error: responseError
1480
1503
  }));
1481
- case 27:
1504
+ case 37:
1482
1505
  case "end":
1483
1506
  return _context20.stop();
1484
1507
  }
1485
- }, _callee20, this, [[3, 21]]);
1508
+ }, _callee20, this, [[3, 31]]);
1486
1509
  }));
1487
1510
  function CallFromFrameMessage(_x16, _x17) {
1488
1511
  return _CallFromFrameMessage.apply(this, arguments);
@@ -14,6 +14,8 @@ var permissionLevels = require("./client/ContentAccess").permissionLevels;
14
14
  var _require = require("./LogMessage"),
15
15
  LogMessage = _require.LogMessage;
16
16
  var Crypto = require("./Crypto");
17
+ var _require2 = require("./walletClient/index"),
18
+ ElvWalletClient = _require2.ElvWalletClient;
17
19
  var FrameClient = /*#__PURE__*/function () {
18
20
  "use strict";
19
21
 
@@ -157,6 +159,57 @@ var FrameClient = /*#__PURE__*/function () {
157
159
  } finally {
158
160
  _iterator2.f();
159
161
  }
162
+ this.walletClient = {};
163
+ var forbiddenMethods = ElvWalletClient.ForbiddenMethods();
164
+ var _iterator3 = _createForOfIteratorHelper(Object.getOwnPropertyNames(ElvWalletClient.prototype)),
165
+ _step3;
166
+ try {
167
+ var _loop3 = function _loop3() {
168
+ var methodName = _step3.value;
169
+ if (forbiddenMethods.includes(methodName)) {
170
+ return "continue";
171
+ }
172
+ _this.walletClient[methodName] = /*#__PURE__*/function () {
173
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(args) {
174
+ var callback;
175
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
176
+ while (1) switch (_context3.prev = _context3.next) {
177
+ case 0:
178
+ callback = args && args.callback;
179
+ if (callback) {
180
+ delete args.callback;
181
+ }
182
+ _context3.next = 4;
183
+ return _this.SendMessage({
184
+ options: {
185
+ module: "walletClient",
186
+ calledMethod: methodName,
187
+ args: _this.utils.MakeClonable(args)
188
+ },
189
+ callback: callback
190
+ });
191
+ case 4:
192
+ return _context3.abrupt("return", _context3.sent);
193
+ case 5:
194
+ case "end":
195
+ return _context3.stop();
196
+ }
197
+ }, _callee3);
198
+ }));
199
+ return function (_x3) {
200
+ return _ref4.apply(this, arguments);
201
+ };
202
+ }();
203
+ };
204
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
205
+ var _ret = _loop3();
206
+ if (_ret === "continue") continue;
207
+ }
208
+ } catch (err) {
209
+ _iterator3.e(err);
210
+ } finally {
211
+ _iterator3.f();
212
+ }
160
213
  }
161
214
 
162
215
  /**
@@ -176,13 +229,13 @@ var FrameClient = /*#__PURE__*/function () {
176
229
  }, {
177
230
  key: "PassRequest",
178
231
  value: function () {
179
- var _PassRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref4) {
232
+ var _PassRequest = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
180
233
  var request, Respond, response, error, callback;
181
- return _regeneratorRuntime.wrap(function _callee3$(_context3) {
182
- while (1) switch (_context3.prev = _context3.next) {
234
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
235
+ while (1) switch (_context4.prev = _context4.next) {
183
236
  case 0:
184
- request = _ref4.request, Respond = _ref4.Respond;
185
- _context3.prev = 1;
237
+ request = _ref5.request, Respond = _ref5.Respond;
238
+ _context4.prev = 1;
186
239
  if (request.callbackId) {
187
240
  callback = function callback(result) {
188
241
  return Respond({
@@ -192,21 +245,21 @@ var FrameClient = /*#__PURE__*/function () {
192
245
  });
193
246
  };
194
247
  }
195
- _context3.next = 5;
248
+ _context4.next = 5;
196
249
  return this.SendMessage({
197
250
  options: request,
198
251
  callback: callback
199
252
  });
200
253
  case 5:
201
- response = _context3.sent;
202
- _context3.next = 11;
254
+ response = _context4.sent;
255
+ _context4.next = 11;
203
256
  break;
204
257
  case 8:
205
- _context3.prev = 8;
206
- _context3.t0 = _context3["catch"](1);
207
- error = _context3.t0;
258
+ _context4.prev = 8;
259
+ _context4.t0 = _context4["catch"](1);
260
+ error = _context4.t0;
208
261
  case 11:
209
- return _context3.abrupt("return", {
262
+ return _context4.abrupt("return", {
210
263
  type: "ElvFrameResponse",
211
264
  requestId: request.requestId,
212
265
  response: response,
@@ -214,11 +267,11 @@ var FrameClient = /*#__PURE__*/function () {
214
267
  });
215
268
  case 12:
216
269
  case "end":
217
- return _context3.stop();
270
+ return _context4.stop();
218
271
  }
219
- }, _callee3, this, [[1, 8]]);
272
+ }, _callee4, this, [[1, 8]]);
220
273
  }));
221
- function PassRequest(_x3) {
274
+ function PassRequest(_x4) {
222
275
  return _PassRequest.apply(this, arguments);
223
276
  }
224
277
  return PassRequest;
@@ -226,12 +279,12 @@ var FrameClient = /*#__PURE__*/function () {
226
279
  }, {
227
280
  key: "SendMessage",
228
281
  value: function () {
229
- var _SendMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
230
- var _ref5$options, options, callback, _ref5$noResponse, noResponse, requestId, callbackId, operation, isFileOperation, timeout;
231
- return _regeneratorRuntime.wrap(function _callee4$(_context4) {
232
- while (1) switch (_context4.prev = _context4.next) {
282
+ var _SendMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref6) {
283
+ var _ref6$options, options, callback, _ref6$noResponse, noResponse, requestId, callbackId, operation, isFileOperation, timeout;
284
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
285
+ while (1) switch (_context5.prev = _context5.next) {
233
286
  case 0:
234
- _ref5$options = _ref5.options, options = _ref5$options === void 0 ? {} : _ref5$options, callback = _ref5.callback, _ref5$noResponse = _ref5.noResponse, noResponse = _ref5$noResponse === void 0 ? false : _ref5$noResponse;
287
+ _ref6$options = _ref6.options, options = _ref6$options === void 0 ? {} : _ref6$options, callback = _ref6.callback, _ref6$noResponse = _ref6.noResponse, noResponse = _ref6$noResponse === void 0 ? false : _ref6$noResponse;
235
288
  requestId = Id.next();
236
289
  if (callback) {
237
290
  callbackId = Id.next();
@@ -244,10 +297,10 @@ var FrameClient = /*#__PURE__*/function () {
244
297
 
245
298
  // No timeout for prompted methods
246
299
  if (!noResponse) {
247
- _context4.next = 6;
300
+ _context5.next = 6;
248
301
  break;
249
302
  }
250
- return _context4.abrupt("return");
303
+ return _context5.abrupt("return");
251
304
  case 6:
252
305
  operation = options.calledMethod || options.operation;
253
306
  isFileOperation = FrameClient.FileMethods().includes(options.calledMethod);
@@ -257,17 +310,17 @@ var FrameClient = /*#__PURE__*/function () {
257
310
  } else if (options.args && options.args.fcTimeout) {
258
311
  timeout = options.args.fcTimeout;
259
312
  }
260
- _context4.next = 12;
313
+ _context5.next = 12;
261
314
  return this.AwaitMessage(requestId, timeout, callback, callbackId, operation);
262
315
  case 12:
263
- return _context4.abrupt("return", _context4.sent);
316
+ return _context5.abrupt("return", _context5.sent);
264
317
  case 13:
265
318
  case "end":
266
- return _context4.stop();
319
+ return _context5.stop();
267
320
  }
268
- }, _callee4, this);
321
+ }, _callee5, this);
269
322
  }));
270
- function SendMessage(_x4) {
323
+ function SendMessage(_x5) {
271
324
  return _SendMessage.apply(this, arguments);
272
325
  }
273
326
  return SendMessage;
@@ -275,11 +328,11 @@ var FrameClient = /*#__PURE__*/function () {
275
328
  }, {
276
329
  key: "AwaitMessage",
277
330
  value: function () {
278
- var _AwaitMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(requestId, timeout, callback, callbackId, operation) {
279
- return _regeneratorRuntime.wrap(function _callee6$(_context6) {
280
- while (1) switch (_context6.prev = _context6.next) {
331
+ var _AwaitMessage = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(requestId, timeout, callback, callbackId, operation) {
332
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
333
+ while (1) switch (_context7.prev = _context7.next) {
281
334
  case 0:
282
- _context6.next = 2;
335
+ _context7.next = 2;
283
336
  return new Promise(function (resolve, reject) {
284
337
  var methodListener;
285
338
 
@@ -323,18 +376,18 @@ var FrameClient = /*#__PURE__*/function () {
323
376
 
324
377
  // Set up final method response listener
325
378
  methodListener = /*#__PURE__*/function () {
326
- var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(event) {
379
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(event) {
327
380
  var message;
328
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
329
- while (1) switch (_context5.prev = _context5.next) {
381
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
382
+ while (1) switch (_context6.prev = _context6.next) {
330
383
  case 0:
331
- _context5.prev = 0;
384
+ _context6.prev = 0;
332
385
  message = event.data;
333
386
  if (!(message.type !== "ElvFrameResponse" || message.requestId !== requestId)) {
334
- _context5.next = 4;
387
+ _context6.next = 4;
335
388
  break;
336
389
  }
337
- return _context5.abrupt("return");
390
+ return _context6.abrupt("return");
338
391
  case 4:
339
392
  clearTimeout(timeoutId);
340
393
  window.removeEventListener("message", methodListener);
@@ -346,25 +399,25 @@ var FrameClient = /*#__PURE__*/function () {
346
399
  } else {
347
400
  resolve(message.response);
348
401
  }
349
- _context5.next = 16;
402
+ _context6.next = 16;
350
403
  break;
351
404
  case 10:
352
- _context5.prev = 10;
353
- _context5.t0 = _context5["catch"](0);
405
+ _context6.prev = 10;
406
+ _context6.t0 = _context6["catch"](0);
354
407
  clearTimeout(timeoutId);
355
408
  window.removeEventListener("message", methodListener);
356
409
  if (callbackListener) {
357
410
  window.removeEventListener("message", callbackListener);
358
411
  }
359
- reject(_context5.t0);
412
+ reject(_context6.t0);
360
413
  case 16:
361
414
  case "end":
362
- return _context5.stop();
415
+ return _context6.stop();
363
416
  }
364
- }, _callee5, null, [[0, 10]]);
417
+ }, _callee6, null, [[0, 10]]);
365
418
  }));
366
- return function methodListener(_x10) {
367
- return _ref6.apply(this, arguments);
419
+ return function methodListener(_x11) {
420
+ return _ref7.apply(this, arguments);
368
421
  };
369
422
  }();
370
423
 
@@ -373,14 +426,14 @@ var FrameClient = /*#__PURE__*/function () {
373
426
  window.addEventListener("message", methodListener);
374
427
  });
375
428
  case 2:
376
- return _context6.abrupt("return", _context6.sent);
429
+ return _context7.abrupt("return", _context7.sent);
377
430
  case 3:
378
431
  case "end":
379
- return _context6.stop();
432
+ return _context7.stop();
380
433
  }
381
- }, _callee6);
434
+ }, _callee7);
382
435
  }));
383
- function AwaitMessage(_x5, _x6, _x7, _x8, _x9) {
436
+ function AwaitMessage(_x6, _x7, _x8, _x9, _x10) {
384
437
  return _AwaitMessage.apply(this, arguments);
385
438
  }
386
439
  return AwaitMessage;
@@ -427,7 +480,7 @@ var FrameClient = /*#__PURE__*/function () {
427
480
  }]);
428
481
  return FrameClient;
429
482
  }();
430
- var _require2 = require("./client/Files"),
431
- UploadFiles = _require2.UploadFiles;
483
+ var _require3 = require("./client/Files"),
484
+ UploadFiles = _require3.UploadFiles;
432
485
  FrameClient.prototype.UploadFiles = UploadFiles;
433
486
  exports.FrameClient = FrameClient;
@@ -75,6 +75,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
75
75
  this.cachedMarketplaces = {};
76
76
  this.cachedCSS = {};
77
77
  this.utils = client.utils;
78
+ this.ForbiddenMethods = ElvWalletClient.ForbiddenMethods;
78
79
  }
79
80
  _createClass(ElvWalletClient, [{
80
81
  key: "Log",
@@ -94,23 +95,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
94
95
  }
95
96
  }
96
97
 
97
- /**
98
- * Initialize the wallet client.
99
- *
100
- * Specify tenantSlug and marketplaceSlug to automatically associate this tenant with a particular marketplace.
101
- *
102
- *
103
- * @methodGroup Initialization
104
- * @namedParams
105
- * @param {string} appId - A string identifying your app. This is used for namespacing user profile data.
106
- * @param {string} network=main - Name of the Fabric network to use (`main`, `demo`)
107
- * @param {string} mode=production - Environment to use (`production`, `staging`)
108
- * @param {Object=} marketplaceParams - Marketplace parameters
109
- * @param {boolean=} storeAuthToken=true - If specified, auth tokens will be stored in localstorage (if available)
110
- * @param {Object=} client - Existing instance of ElvClient to use instead of initializing a new one
111
- *
112
- * @returns {Promise<ElvWalletClient>}
113
- */
98
+ // Methods forbidden from usage by FrameClient
114
99
  }, {
115
100
  key: "CanSign",
116
101
  value: /* Login and authorization */
@@ -1527,14 +1512,37 @@ var ElvWalletClient = /*#__PURE__*/function () {
1527
1512
  return MintingStatus;
1528
1513
  }()
1529
1514
  }], [{
1515
+ key: "ForbiddenMethods",
1516
+ value: function ForbiddenMethods() {
1517
+ return ["constructor", "Authenticate", "AuthenticateOAuth", "AuthenticateExternalWallet", "AuthToken", "ClientAuthToken", "Initialize", "Log", "LogIn", "LogOut", "PersonalSign", "SetAuthorization", "SignMetamask"];
1518
+ }
1519
+
1520
+ /**
1521
+ * Initialize the wallet client.
1522
+ *
1523
+ * Specify tenantSlug and marketplaceSlug to automatically associate this tenant with a particular marketplace.
1524
+ *
1525
+ *
1526
+ * @methodGroup Initialization
1527
+ * @namedParams
1528
+ * @param {string} appId - A string identifying your app. This is used for namespacing user profile data.
1529
+ * @param {string} network=main - Name of the Fabric network to use (`main`, `demo`)
1530
+ * @param {string} mode=production - Environment to use (`production`, `staging`)
1531
+ * @param {Object=} marketplaceParams - Marketplace parameters
1532
+ * @param {boolean=} storeAuthToken=true - If specified, auth tokens will be stored in localstorage (if available)
1533
+ * @param {Object=} client - Existing instance of ElvClient to use instead of initializing a new one
1534
+ *
1535
+ * @returns {Promise<ElvWalletClient>}
1536
+ */
1537
+ }, {
1530
1538
  key: "Initialize",
1531
1539
  value: function () {
1532
1540
  var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref18) {
1533
- 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;
1541
+ var client, _ref18$appId, appId, _ref18$network, network, _ref18$mode, mode, localization, marketplaceParams, previewMarketplaceId, _ref18$storeAuthToken, storeAuthToken, _ref18$skipMarketplac, skipMarketplaceLoad, _ref19, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, previewMarketplaceHash, walletClient, url, savedToken;
1534
1542
  return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1535
1543
  while (1) switch (_context18.prev = _context18.next) {
1536
1544
  case 0:
1537
- 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
+ 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, _ref18$skipMarketplac = _ref18.skipMarketplaceLoad, skipMarketplaceLoad = _ref18$skipMarketplac === void 0 ? false : _ref18$skipMarketplac;
1538
1546
  _ref19 = marketplaceParams || {}, tenantSlug = _ref19.tenantSlug, marketplaceSlug = _ref19.marketplaceSlug, marketplaceId = _ref19.marketplaceId, marketplaceHash = _ref19.marketplaceHash;
1539
1547
  if (Configuration[network]) {
1540
1548
  _context18.next = 6;
@@ -1628,11 +1636,15 @@ var ElvWalletClient = /*#__PURE__*/function () {
1628
1636
  _context18.prev = 35;
1629
1637
  _context18.t0 = _context18["catch"](28);
1630
1638
  case 37:
1631
- _context18.next = 39;
1639
+ if (skipMarketplaceLoad) {
1640
+ _context18.next = 40;
1641
+ break;
1642
+ }
1643
+ _context18.next = 40;
1632
1644
  return walletClient.LoadAvailableMarketplaces();
1633
- case 39:
1634
- return _context18.abrupt("return", walletClient);
1635
1645
  case 40:
1646
+ return _context18.abrupt("return", walletClient);
1647
+ case 41:
1636
1648
  case "end":
1637
1649
  return _context18.stop();
1638
1650
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.26",
3
+ "version": "4.0.27",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
package/src/ElvClient.js CHANGED
@@ -1134,7 +1134,17 @@ class ElvClient {
1134
1134
  const method = message.calledMethod;
1135
1135
 
1136
1136
  let methodResults;
1137
- if(message.module === "userProfileClient") {
1137
+ if(message.module === "walletClient") {
1138
+ if(!this.walletClient) {
1139
+ throw Error("Wallet client not set");
1140
+ }
1141
+
1142
+ if(this.walletClient.ForbiddenMethods().includes(method)) {
1143
+ throw Error("Invalid user profile method: " + method);
1144
+ }
1145
+
1146
+ methodResults = await this.walletClient[method](message.args);
1147
+ } else if(message.module === "userProfileClient") {
1138
1148
  if(!this.userProfileClient.FrameAllowedMethods().includes(method)) {
1139
1149
  throw Error("Invalid user profile method: " + method);
1140
1150
  }
@@ -3,6 +3,7 @@ const Utils = require("./Utils");
3
3
  const permissionLevels = require("./client/ContentAccess").permissionLevels;
4
4
  const {LogMessage} = require("./LogMessage");
5
5
  const Crypto = require("./Crypto");
6
+ const { ElvWalletClient } = require("./walletClient/index");
6
7
 
7
8
  class FrameClient {
8
9
  Log(message, error = false) {
@@ -88,6 +89,26 @@ class FrameClient {
88
89
  });
89
90
  };
90
91
  }
92
+
93
+ this.walletClient = {};
94
+ const forbiddenMethods = ElvWalletClient.ForbiddenMethods();
95
+ for(const methodName of Object.getOwnPropertyNames(ElvWalletClient.prototype)) {
96
+ if(forbiddenMethods.includes(methodName)) { continue; }
97
+
98
+ this.walletClient[methodName] = async (args) => {
99
+ let callback = args && args.callback;
100
+ if(callback) { delete args.callback; }
101
+
102
+ return await this.SendMessage({
103
+ options: {
104
+ module: "walletClient",
105
+ calledMethod: methodName,
106
+ args: this.utils.MakeClonable(args)
107
+ },
108
+ callback
109
+ });
110
+ };
111
+ }
91
112
  }
92
113
 
93
114
  /**
@@ -58,6 +58,8 @@ class ElvWalletClient {
58
58
  this.cachedCSS = {};
59
59
 
60
60
  this.utils = client.utils;
61
+
62
+ this.ForbiddenMethods = ElvWalletClient.ForbiddenMethods;
61
63
  }
62
64
 
63
65
  Log(message, error=false, errorObject) {
@@ -75,6 +77,25 @@ class ElvWalletClient {
75
77
  }
76
78
  }
77
79
 
80
+ // Methods forbidden from usage by FrameClient
81
+ static ForbiddenMethods() {
82
+ return [
83
+ "constructor",
84
+ "Authenticate",
85
+ "AuthenticateOAuth",
86
+ "AuthenticateExternalWallet",
87
+ "AuthToken",
88
+ "ClientAuthToken",
89
+ "Initialize",
90
+ "Log",
91
+ "LogIn",
92
+ "LogOut",
93
+ "PersonalSign",
94
+ "SetAuthorization",
95
+ "SignMetamask"
96
+ ];
97
+ }
98
+
78
99
  /**
79
100
  * Initialize the wallet client.
80
101
  *
@@ -100,7 +121,8 @@ class ElvWalletClient {
100
121
  localization,
101
122
  marketplaceParams,
102
123
  previewMarketplaceId,
103
- storeAuthToken=true
124
+ storeAuthToken=true,
125
+ skipMarketplaceLoad=false
104
126
  }) {
105
127
  let { tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash } = (marketplaceParams || {});
106
128
 
@@ -155,7 +177,9 @@ class ElvWalletClient {
155
177
  }
156
178
  }
157
179
 
158
- await walletClient.LoadAvailableMarketplaces();
180
+ if(!skipMarketplaceLoad) {
181
+ await walletClient.LoadAvailableMarketplaces();
182
+ }
159
183
 
160
184
  return walletClient;
161
185
  }