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