@eluvio/elv-client-js 4.2.6 → 4.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +1 -1
- package/dist/ElvClient-node-min.js +1 -1
- package/dist/ElvFrameClient-min.js +1 -1
- package/dist/ElvPermissionsClient-min.js +1 -1
- package/dist/ElvWalletClient-min.js +1 -1
- package/dist/ElvWalletClient-node-min.js +1 -1
- package/dist/src/AuthorizationClient.js +709 -710
- package/dist/src/ContentObjectAudit.js +56 -56
- package/dist/src/Crypto.js +85 -85
- package/dist/src/ElvClient.js +529 -499
- package/dist/src/ElvWallet.js +30 -28
- package/dist/src/EthClient.js +311 -311
- package/dist/src/FrameClient.js +63 -64
- package/dist/src/HttpClient.js +60 -60
- package/dist/src/Id.js +1 -2
- package/dist/src/PermissionsClient.js +499 -487
- package/dist/src/RemoteSigner.js +82 -83
- package/dist/src/UserProfileClient.js +392 -374
- package/dist/src/Utils.js +69 -66
- package/dist/src/Validation.js +10 -10
- package/dist/src/client/ABRPublishing.js +238 -238
- package/dist/src/client/AccessGroups.js +477 -474
- package/dist/src/client/ContentAccess.js +1707 -1711
- package/dist/src/client/ContentManagement.js +871 -871
- package/dist/src/client/Contracts.js +575 -578
- package/dist/src/client/Files.js +700 -684
- package/dist/src/client/LiveConf.js +1 -3
- package/dist/src/client/LiveStream.js +694 -693
- package/dist/src/client/NFT.js +14 -14
- package/dist/src/client/NTP.js +84 -84
- package/dist/src/client/Shares.js +53 -60
- package/dist/src/walletClient/ClientMethods.js +977 -951
- package/dist/src/walletClient/Notifications.js +14 -14
- package/dist/src/walletClient/Profile.js +66 -66
- package/dist/src/walletClient/Utils.js +15 -15
- package/dist/src/walletClient/index.js +572 -562
- package/package.json +1 -1
- package/src/ElvClient.js +1 -1
- package/src/walletClient/index.js +6 -2
- package/dist/src/ContentObjectVerification.js +0 -281
package/dist/src/client/NFT.js
CHANGED
|
@@ -34,9 +34,9 @@ var _require = require("../Validation"),
|
|
|
34
34
|
* @return Promise<Object> - An object containing the address for whom the NFT was minted and the transactionId of the minting request.
|
|
35
35
|
*/
|
|
36
36
|
exports.MintNFT = /*#__PURE__*/function () {
|
|
37
|
-
var _ref2 = _asyncToGenerator(
|
|
37
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
38
38
|
var tenantId, address, marketplaceId, items, _ref$extraData, extraData, requestBody, transactionId, mintSignature;
|
|
39
|
-
return _regeneratorRuntime.wrap(function
|
|
39
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
40
40
|
while (1) switch (_context.prev = _context.next) {
|
|
41
41
|
case 0:
|
|
42
42
|
tenantId = _ref.tenantId, address = _ref.address, marketplaceId = _ref.marketplaceId, items = _ref.items, _ref$extraData = _ref.extraData, extraData = _ref$extraData === void 0 ? {} : _ref$extraData;
|
|
@@ -66,11 +66,11 @@ exports.MintNFT = /*#__PURE__*/function () {
|
|
|
66
66
|
transactionId = this.utils.B58(UUID.parse(UUID.v4()));
|
|
67
67
|
requestBody.ts = Date.now();
|
|
68
68
|
requestBody.trans_id = transactionId;
|
|
69
|
-
_context.next =
|
|
69
|
+
_context.next = 1;
|
|
70
70
|
return this.Sign(JSON.stringify(requestBody));
|
|
71
|
-
case
|
|
71
|
+
case 1:
|
|
72
72
|
mintSignature = _context.sent;
|
|
73
|
-
_context.next =
|
|
73
|
+
_context.next = 2;
|
|
74
74
|
return this.authClient.MakeAuthServiceRequest({
|
|
75
75
|
method: "POST",
|
|
76
76
|
path: UrlJoin("/as/tnt/trans/base", tenantId, marketplaceId),
|
|
@@ -79,12 +79,12 @@ exports.MintNFT = /*#__PURE__*/function () {
|
|
|
79
79
|
"Authorization": "Bearer ".concat(mintSignature)
|
|
80
80
|
}
|
|
81
81
|
});
|
|
82
|
-
case
|
|
82
|
+
case 2:
|
|
83
83
|
return _context.abrupt("return", {
|
|
84
84
|
address: address,
|
|
85
85
|
transactionId: transactionId
|
|
86
86
|
});
|
|
87
|
-
case
|
|
87
|
+
case 3:
|
|
88
88
|
case "end":
|
|
89
89
|
return _context.stop();
|
|
90
90
|
}
|
|
@@ -112,9 +112,9 @@ exports.MintNFT = /*#__PURE__*/function () {
|
|
|
112
112
|
* @return Promise<Array<Object>> - A list of transactions matching the specified filters.
|
|
113
113
|
*/
|
|
114
114
|
exports.CollectionTransactions = /*#__PURE__*/function () {
|
|
115
|
-
var _ref4 = _asyncToGenerator(
|
|
115
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
116
116
|
var tenantId, collectionId, _ref3$filterOptions, filterOptions, ts, queryParams, allowedOptions, path, signature;
|
|
117
|
-
return _regeneratorRuntime.wrap(function
|
|
117
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
118
118
|
while (1) switch (_context2.prev = _context2.next) {
|
|
119
119
|
case 0:
|
|
120
120
|
tenantId = _ref3.tenantId, collectionId = _ref3.collectionId, _ref3$filterOptions = _ref3.filterOptions, filterOptions = _ref3$filterOptions === void 0 ? {} : _ref3$filterOptions;
|
|
@@ -135,11 +135,11 @@ exports.CollectionTransactions = /*#__PURE__*/function () {
|
|
|
135
135
|
}
|
|
136
136
|
});
|
|
137
137
|
path = this.AuthHttpClient.BaseURI().path(UrlJoin("/tnt", "trans", tenantId, collectionId)).query(queryParams).hash("").resource();
|
|
138
|
-
_context2.next =
|
|
138
|
+
_context2.next = 1;
|
|
139
139
|
return this.Sign(path);
|
|
140
|
-
case
|
|
140
|
+
case 1:
|
|
141
141
|
signature = _context2.sent;
|
|
142
|
-
_context2.next =
|
|
142
|
+
_context2.next = 2;
|
|
143
143
|
return this.utils.ResponseToJson(this.authClient.MakeAuthServiceRequest({
|
|
144
144
|
method: "GET",
|
|
145
145
|
path: UrlJoin("as", "tnt", "trans", tenantId, collectionId),
|
|
@@ -148,9 +148,9 @@ exports.CollectionTransactions = /*#__PURE__*/function () {
|
|
|
148
148
|
"Authorization": "Bearer ".concat(signature)
|
|
149
149
|
}
|
|
150
150
|
}));
|
|
151
|
-
case
|
|
151
|
+
case 2:
|
|
152
152
|
return _context2.abrupt("return", _context2.sent);
|
|
153
|
-
case
|
|
153
|
+
case 3:
|
|
154
154
|
case "end":
|
|
155
155
|
return _context2.stop();
|
|
156
156
|
}
|
package/dist/src/client/NTP.js
CHANGED
|
@@ -58,10 +58,10 @@ var FormatNTPInfo = function FormatNTPInfo(info) {
|
|
|
58
58
|
* @return {Promise<string>} - The ID of the NTP instance. This ID can be used when issuing tickets (See IssueNTPCode)
|
|
59
59
|
*/
|
|
60
60
|
exports.CreateNTPInstance = /*#__PURE__*/function () {
|
|
61
|
-
var _ref2 = _asyncToGenerator(
|
|
61
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
62
62
|
var _this = this;
|
|
63
63
|
var tenantId, objectId, groupAddresses, _ref$ntpClass, ntpClass, _ref$maxTickets, maxTickets, _ref$maxRedemptions, maxRedemptions, startTime, endTime, _ref$ticketLength, ticketLength, paramsJSON, groupIds;
|
|
64
|
-
return _regeneratorRuntime.wrap(function
|
|
64
|
+
return _regeneratorRuntime.wrap(function (_context) {
|
|
65
65
|
while (1) switch (_context.prev = _context.next) {
|
|
66
66
|
case 0:
|
|
67
67
|
tenantId = _ref.tenantId, objectId = _ref.objectId, groupAddresses = _ref.groupAddresses, _ref$ntpClass = _ref.ntpClass, ntpClass = _ref$ntpClass === void 0 ? 4 : _ref$ntpClass, _ref$maxTickets = _ref.maxTickets, maxTickets = _ref$maxTickets === void 0 ? 0 : _ref$maxTickets, _ref$maxRedemptions = _ref.maxRedemptions, maxRedemptions = _ref$maxRedemptions === void 0 ? 100 : _ref$maxRedemptions, startTime = _ref.startTime, endTime = _ref.endTime, _ref$ticketLength = _ref.ticketLength, ticketLength = _ref$ticketLength === void 0 ? 6 : _ref$ticketLength;
|
|
@@ -92,16 +92,16 @@ exports.CreateNTPInstance = /*#__PURE__*/function () {
|
|
|
92
92
|
if (endTime) {
|
|
93
93
|
paramsJSON.push("exp:".concat(endTime));
|
|
94
94
|
}
|
|
95
|
-
_context.next =
|
|
95
|
+
_context.next = 1;
|
|
96
96
|
return this.authClient.MakeKMSCall({
|
|
97
97
|
tenantId: tenantId,
|
|
98
98
|
methodName: "elv_createOTPInstance",
|
|
99
99
|
params: [tenantId, ntpClass, JSON.stringify(paramsJSON), parseInt(maxTickets), Date.now()],
|
|
100
100
|
paramTypes: ["string", "int", "string", "int", "int"]
|
|
101
101
|
});
|
|
102
|
-
case
|
|
102
|
+
case 1:
|
|
103
103
|
return _context.abrupt("return", _context.sent);
|
|
104
|
-
case
|
|
104
|
+
case 2:
|
|
105
105
|
case "end":
|
|
106
106
|
return _context.stop();
|
|
107
107
|
}
|
|
@@ -127,9 +127,9 @@ exports.CreateNTPInstance = /*#__PURE__*/function () {
|
|
|
127
127
|
* @return {Object} - Info about the NTP Instance
|
|
128
128
|
*/
|
|
129
129
|
exports.UpdateNTPInstance = /*#__PURE__*/function () {
|
|
130
|
-
var _ref4 = _asyncToGenerator(
|
|
130
|
+
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
|
|
131
131
|
var tenantId, ntpId, _ref3$maxTickets, maxTickets, _ref3$maxRedemptions, maxRedemptions, startTime, endTime, paramsJSON, _yield$this$authClien, Ret;
|
|
132
|
-
return _regeneratorRuntime.wrap(function
|
|
132
|
+
return _regeneratorRuntime.wrap(function (_context2) {
|
|
133
133
|
while (1) switch (_context2.prev = _context2.next) {
|
|
134
134
|
case 0:
|
|
135
135
|
tenantId = _ref3.tenantId, ntpId = _ref3.ntpId, _ref3$maxTickets = _ref3.maxTickets, maxTickets = _ref3$maxTickets === void 0 ? 0 : _ref3$maxTickets, _ref3$maxRedemptions = _ref3.maxRedemptions, maxRedemptions = _ref3$maxRedemptions === void 0 ? 100 : _ref3$maxRedemptions, startTime = _ref3.startTime, endTime = _ref3.endTime;
|
|
@@ -150,18 +150,18 @@ exports.UpdateNTPInstance = /*#__PURE__*/function () {
|
|
|
150
150
|
if (maxTickets) {
|
|
151
151
|
paramsJSON.push("max:".concat(parseInt(maxTickets)));
|
|
152
152
|
}
|
|
153
|
-
_context2.next =
|
|
153
|
+
_context2.next = 1;
|
|
154
154
|
return this.authClient.MakeKMSCall({
|
|
155
155
|
tenantId: tenantId,
|
|
156
156
|
methodName: "elv_updateOTPInstance",
|
|
157
157
|
params: [tenantId, ntpId, "update", JSON.stringify(paramsJSON), Date.now()],
|
|
158
158
|
paramTypes: ["string", "string", "string", "string", "int"]
|
|
159
159
|
});
|
|
160
|
-
case
|
|
160
|
+
case 1:
|
|
161
161
|
_yield$this$authClien = _context2.sent;
|
|
162
162
|
Ret = _yield$this$authClien.Ret;
|
|
163
163
|
return _context2.abrupt("return", FormatNTPInfo(JSON.parse(Ret)));
|
|
164
|
-
case
|
|
164
|
+
case 2:
|
|
165
165
|
case "end":
|
|
166
166
|
return _context2.stop();
|
|
167
167
|
}
|
|
@@ -183,22 +183,22 @@ exports.UpdateNTPInstance = /*#__PURE__*/function () {
|
|
|
183
183
|
* @param {string} ntpId - The ID of the NTP instance
|
|
184
184
|
*/
|
|
185
185
|
exports.SuspendNTPInstance = /*#__PURE__*/function () {
|
|
186
|
-
var _ref6 = _asyncToGenerator(
|
|
186
|
+
var _ref6 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
|
|
187
187
|
var tenantId, ntpId;
|
|
188
|
-
return _regeneratorRuntime.wrap(function
|
|
188
|
+
return _regeneratorRuntime.wrap(function (_context3) {
|
|
189
189
|
while (1) switch (_context3.prev = _context3.next) {
|
|
190
190
|
case 0:
|
|
191
191
|
tenantId = _ref5.tenantId, ntpId = _ref5.ntpId;
|
|
192
192
|
ValidatePresence("tenantId", tenantId);
|
|
193
193
|
ValidatePresence("ntpId", ntpId);
|
|
194
|
-
_context3.next =
|
|
194
|
+
_context3.next = 1;
|
|
195
195
|
return this.authClient.MakeKMSCall({
|
|
196
196
|
tenantId: tenantId,
|
|
197
197
|
methodName: "elv_updateOTPInstance",
|
|
198
198
|
params: [tenantId, ntpId, "cancel", "[]", Date.now()],
|
|
199
199
|
paramTypes: ["string", "string", "string", "string", "int"]
|
|
200
200
|
});
|
|
201
|
-
case
|
|
201
|
+
case 1:
|
|
202
202
|
case "end":
|
|
203
203
|
return _context3.stop();
|
|
204
204
|
}
|
|
@@ -218,22 +218,22 @@ exports.SuspendNTPInstance = /*#__PURE__*/function () {
|
|
|
218
218
|
* @param {string} ntpId - The ID of the NTP instance
|
|
219
219
|
*/
|
|
220
220
|
exports.DeleteNTPInstance = /*#__PURE__*/function () {
|
|
221
|
-
var _ref8 = _asyncToGenerator(
|
|
221
|
+
var _ref8 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref7) {
|
|
222
222
|
var tenantId, ntpId;
|
|
223
|
-
return _regeneratorRuntime.wrap(function
|
|
223
|
+
return _regeneratorRuntime.wrap(function (_context4) {
|
|
224
224
|
while (1) switch (_context4.prev = _context4.next) {
|
|
225
225
|
case 0:
|
|
226
226
|
tenantId = _ref7.tenantId, ntpId = _ref7.ntpId;
|
|
227
227
|
ValidatePresence("tenantId", tenantId);
|
|
228
228
|
ValidatePresence("ntpId", ntpId);
|
|
229
|
-
_context4.next =
|
|
229
|
+
_context4.next = 1;
|
|
230
230
|
return this.authClient.MakeKMSCall({
|
|
231
231
|
tenantId: tenantId,
|
|
232
232
|
methodName: "elv_updateOTPInstance",
|
|
233
233
|
params: [tenantId, ntpId, "delete", "[]", Date.now()],
|
|
234
234
|
paramTypes: ["string", "string", "string", "string", "int"]
|
|
235
235
|
});
|
|
236
|
-
case
|
|
236
|
+
case 1:
|
|
237
237
|
case "end":
|
|
238
238
|
return _context4.stop();
|
|
239
239
|
}
|
|
@@ -256,14 +256,14 @@ exports.DeleteNTPInstance = /*#__PURE__*/function () {
|
|
|
256
256
|
* @return {Object} - List of NTP instances along with pagination information
|
|
257
257
|
*/
|
|
258
258
|
exports.ListNTPInstances = /*#__PURE__*/function () {
|
|
259
|
-
var
|
|
259
|
+
var _ref0 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref9) {
|
|
260
260
|
var tenantId, _ref9$count, count, _ref9$offset, offset, _yield$this$authClien2, Defs, Total;
|
|
261
|
-
return _regeneratorRuntime.wrap(function
|
|
261
|
+
return _regeneratorRuntime.wrap(function (_context5) {
|
|
262
262
|
while (1) switch (_context5.prev = _context5.next) {
|
|
263
263
|
case 0:
|
|
264
264
|
tenantId = _ref9.tenantId, _ref9$count = _ref9.count, count = _ref9$count === void 0 ? 10 : _ref9$count, _ref9$offset = _ref9.offset, offset = _ref9$offset === void 0 ? 0 : _ref9$offset;
|
|
265
265
|
ValidatePresence("tenantId", tenantId);
|
|
266
|
-
_context5.next =
|
|
266
|
+
_context5.next = 1;
|
|
267
267
|
return this.authClient.MakeKMSCall({
|
|
268
268
|
tenantId: tenantId,
|
|
269
269
|
methodName: "elv_listOTPInfo",
|
|
@@ -271,7 +271,7 @@ exports.ListNTPInstances = /*#__PURE__*/function () {
|
|
|
271
271
|
paramTypes: ["string", "int", "int"],
|
|
272
272
|
signature: false
|
|
273
273
|
});
|
|
274
|
-
case
|
|
274
|
+
case 1:
|
|
275
275
|
_yield$this$authClien2 = _context5.sent;
|
|
276
276
|
Defs = _yield$this$authClien2.Defs;
|
|
277
277
|
Total = _yield$this$authClien2.Total;
|
|
@@ -281,14 +281,14 @@ exports.ListNTPInstances = /*#__PURE__*/function () {
|
|
|
281
281
|
end: Math.min(Total, offset + count),
|
|
282
282
|
total: Total
|
|
283
283
|
});
|
|
284
|
-
case
|
|
284
|
+
case 2:
|
|
285
285
|
case "end":
|
|
286
286
|
return _context5.stop();
|
|
287
287
|
}
|
|
288
288
|
}, _callee5, this);
|
|
289
289
|
}));
|
|
290
290
|
return function (_x5) {
|
|
291
|
-
return
|
|
291
|
+
return _ref0.apply(this, arguments);
|
|
292
292
|
};
|
|
293
293
|
}();
|
|
294
294
|
|
|
@@ -303,16 +303,16 @@ exports.ListNTPInstances = /*#__PURE__*/function () {
|
|
|
303
303
|
* @return {Object} - Info about the NTP instance
|
|
304
304
|
*/
|
|
305
305
|
exports.NTPInstance = /*#__PURE__*/function () {
|
|
306
|
-
var
|
|
307
|
-
var tenantId, ntpId;
|
|
308
|
-
return _regeneratorRuntime.wrap(function
|
|
306
|
+
var _ref10 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref1) {
|
|
307
|
+
var tenantId, ntpId, _t, _t2;
|
|
308
|
+
return _regeneratorRuntime.wrap(function (_context6) {
|
|
309
309
|
while (1) switch (_context6.prev = _context6.next) {
|
|
310
310
|
case 0:
|
|
311
|
-
tenantId =
|
|
311
|
+
tenantId = _ref1.tenantId, ntpId = _ref1.ntpId;
|
|
312
312
|
ValidatePresence("tenantId", tenantId);
|
|
313
313
|
ValidatePresence("ntpId", ntpId);
|
|
314
|
-
|
|
315
|
-
_context6.next =
|
|
314
|
+
_t = FormatNTPInfo;
|
|
315
|
+
_context6.next = 1;
|
|
316
316
|
return this.authClient.MakeKMSCall({
|
|
317
317
|
tenantId: tenantId,
|
|
318
318
|
methodName: "elv_getOTPInfo",
|
|
@@ -320,17 +320,17 @@ exports.NTPInstance = /*#__PURE__*/function () {
|
|
|
320
320
|
paramTypes: ["string", "string"],
|
|
321
321
|
signature: false
|
|
322
322
|
});
|
|
323
|
-
case
|
|
324
|
-
|
|
325
|
-
return _context6.abrupt("return", (
|
|
326
|
-
case
|
|
323
|
+
case 1:
|
|
324
|
+
_t2 = _context6.sent;
|
|
325
|
+
return _context6.abrupt("return", _t(_t2));
|
|
326
|
+
case 2:
|
|
327
327
|
case "end":
|
|
328
328
|
return _context6.stop();
|
|
329
329
|
}
|
|
330
330
|
}, _callee6, this);
|
|
331
331
|
}));
|
|
332
332
|
return function (_x6) {
|
|
333
|
-
return
|
|
333
|
+
return _ref10.apply(this, arguments);
|
|
334
334
|
};
|
|
335
335
|
}();
|
|
336
336
|
|
|
@@ -351,12 +351,12 @@ exports.NTPInstance = /*#__PURE__*/function () {
|
|
|
351
351
|
* @return {Promise<Object>} - The generated ticket code and additional information about the ticket.
|
|
352
352
|
*/
|
|
353
353
|
exports.IssueNTPCode = /*#__PURE__*/function () {
|
|
354
|
-
var
|
|
354
|
+
var _ref12 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref11) {
|
|
355
355
|
var tenantId, ntpId, email, maxRedemptions, options, params, paramTypes;
|
|
356
|
-
return _regeneratorRuntime.wrap(function
|
|
356
|
+
return _regeneratorRuntime.wrap(function (_context7) {
|
|
357
357
|
while (1) switch (_context7.prev = _context7.next) {
|
|
358
358
|
case 0:
|
|
359
|
-
tenantId =
|
|
359
|
+
tenantId = _ref11.tenantId, ntpId = _ref11.ntpId, email = _ref11.email, maxRedemptions = _ref11.maxRedemptions;
|
|
360
360
|
ValidatePresence("tenantId", tenantId);
|
|
361
361
|
ValidatePresence("ntpId", ntpId);
|
|
362
362
|
options = [];
|
|
@@ -368,22 +368,22 @@ exports.IssueNTPCode = /*#__PURE__*/function () {
|
|
|
368
368
|
}
|
|
369
369
|
params = [tenantId, ntpId, JSON.stringify(options), Date.now()];
|
|
370
370
|
paramTypes = ["string", "string", "string", "uint"];
|
|
371
|
-
_context7.next =
|
|
371
|
+
_context7.next = 1;
|
|
372
372
|
return this.authClient.MakeKMSCall({
|
|
373
373
|
methodName: "elv_issueOTPCode",
|
|
374
374
|
params: params,
|
|
375
375
|
paramTypes: paramTypes
|
|
376
376
|
});
|
|
377
|
-
case
|
|
377
|
+
case 1:
|
|
378
378
|
return _context7.abrupt("return", _context7.sent);
|
|
379
|
-
case
|
|
379
|
+
case 2:
|
|
380
380
|
case "end":
|
|
381
381
|
return _context7.stop();
|
|
382
382
|
}
|
|
383
383
|
}, _callee7, this);
|
|
384
384
|
}));
|
|
385
385
|
return function (_x7) {
|
|
386
|
-
return
|
|
386
|
+
return _ref12.apply(this, arguments);
|
|
387
387
|
};
|
|
388
388
|
}();
|
|
389
389
|
|
|
@@ -404,41 +404,41 @@ exports.IssueNTPCode = /*#__PURE__*/function () {
|
|
|
404
404
|
* @return {Promise<Object>} - The generated signed ticket code and additional information about the ticket.
|
|
405
405
|
*/
|
|
406
406
|
exports.IssueSignedNTPCode = /*#__PURE__*/function () {
|
|
407
|
-
var
|
|
407
|
+
var _ref14 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref13) {
|
|
408
408
|
var tenantId, ntpId, email, maxRedemptions, result, signature, multiSig;
|
|
409
|
-
return _regeneratorRuntime.wrap(function
|
|
409
|
+
return _regeneratorRuntime.wrap(function (_context8) {
|
|
410
410
|
while (1) switch (_context8.prev = _context8.next) {
|
|
411
411
|
case 0:
|
|
412
|
-
tenantId =
|
|
413
|
-
_context8.next =
|
|
412
|
+
tenantId = _ref13.tenantId, ntpId = _ref13.ntpId, email = _ref13.email, maxRedemptions = _ref13.maxRedemptions;
|
|
413
|
+
_context8.next = 1;
|
|
414
414
|
return this.IssueNTPCode({
|
|
415
415
|
tenantId: tenantId,
|
|
416
416
|
ntpId: ntpId,
|
|
417
417
|
email: email,
|
|
418
418
|
maxRedemptions: maxRedemptions
|
|
419
419
|
});
|
|
420
|
-
case
|
|
420
|
+
case 1:
|
|
421
421
|
result = _context8.sent;
|
|
422
422
|
if (!result.token) {
|
|
423
|
-
_context8.next =
|
|
423
|
+
_context8.next = 3;
|
|
424
424
|
break;
|
|
425
425
|
}
|
|
426
|
-
_context8.next =
|
|
426
|
+
_context8.next = 2;
|
|
427
427
|
return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(result.token)));
|
|
428
|
-
case
|
|
428
|
+
case 2:
|
|
429
429
|
signature = _context8.sent;
|
|
430
430
|
multiSig = this.utils.FormatSignature(signature);
|
|
431
431
|
result.token = "".concat(result.token, ".").concat(this.utils.B64(multiSig));
|
|
432
|
-
case
|
|
432
|
+
case 3:
|
|
433
433
|
return _context8.abrupt("return", result);
|
|
434
|
-
case
|
|
434
|
+
case 4:
|
|
435
435
|
case "end":
|
|
436
436
|
return _context8.stop();
|
|
437
437
|
}
|
|
438
438
|
}, _callee8, this);
|
|
439
439
|
}));
|
|
440
440
|
return function (_x8) {
|
|
441
|
-
return
|
|
441
|
+
return _ref14.apply(this, arguments);
|
|
442
442
|
};
|
|
443
443
|
}();
|
|
444
444
|
|
|
@@ -457,12 +457,12 @@ exports.IssueSignedNTPCode = /*#__PURE__*/function () {
|
|
|
457
457
|
* @return {Promise<string|Object>} - The object ID which the ticket is authorized to, or an object containing the object ID and NTP ID if `includeNTPId` is specified
|
|
458
458
|
*/
|
|
459
459
|
exports.RedeemCode = /*#__PURE__*/function () {
|
|
460
|
-
var
|
|
461
|
-
var issuer, tenantId, ntpId, code, email,
|
|
462
|
-
return _regeneratorRuntime.wrap(function
|
|
460
|
+
var _ref16 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref15) {
|
|
461
|
+
var issuer, tenantId, ntpId, code, email, _ref15$includeNTPId, includeNTPId, wallet, token, response, objectId, libraryId, Hash, codeHash, codeInfo, ak, sites, info, signer, _t3;
|
|
462
|
+
return _regeneratorRuntime.wrap(function (_context9) {
|
|
463
463
|
while (1) switch (_context9.prev = _context9.next) {
|
|
464
464
|
case 0:
|
|
465
|
-
issuer =
|
|
465
|
+
issuer = _ref15.issuer, tenantId = _ref15.tenantId, ntpId = _ref15.ntpId, code = _ref15.code, email = _ref15.email, _ref15$includeNTPId = _ref15.includeNTPId, includeNTPId = _ref15$includeNTPId === void 0 ? false : _ref15$includeNTPId;
|
|
466
466
|
wallet = this.GenerateWallet();
|
|
467
467
|
issuer = issuer || "";
|
|
468
468
|
if (!this.signer) {
|
|
@@ -473,33 +473,33 @@ exports.RedeemCode = /*#__PURE__*/function () {
|
|
|
473
473
|
});
|
|
474
474
|
}
|
|
475
475
|
if (!issuer.startsWith("iq__")) {
|
|
476
|
-
_context9.next =
|
|
476
|
+
_context9.next = 1;
|
|
477
477
|
break;
|
|
478
478
|
}
|
|
479
479
|
ValidateObject(issuer);
|
|
480
|
-
_context9.next =
|
|
480
|
+
_context9.next = 6;
|
|
481
481
|
break;
|
|
482
|
-
case
|
|
482
|
+
case 1:
|
|
483
483
|
if (!(issuer && !issuer.replace(/^\//, "").startsWith("otp/ntp/iten"))) {
|
|
484
|
-
_context9.next =
|
|
484
|
+
_context9.next = 2;
|
|
485
485
|
break;
|
|
486
486
|
}
|
|
487
487
|
throw Error("Invalid issuer: " + issuer);
|
|
488
|
-
case
|
|
488
|
+
case 2:
|
|
489
489
|
// Ticket API
|
|
490
490
|
|
|
491
491
|
ValidatePresence("issuer or tenantId", issuer || tenantId);
|
|
492
492
|
if (!issuer) {
|
|
493
493
|
issuer = UrlJoin("/otp", "ntp", tenantId, ntpId || "");
|
|
494
494
|
}
|
|
495
|
-
_context9.prev =
|
|
496
|
-
_context9.next =
|
|
495
|
+
_context9.prev = 3;
|
|
496
|
+
_context9.next = 4;
|
|
497
497
|
return this.authClient.GenerateChannelContentToken({
|
|
498
498
|
issuer: issuer,
|
|
499
499
|
code: code,
|
|
500
500
|
email: email
|
|
501
501
|
});
|
|
502
|
-
case
|
|
502
|
+
case 4:
|
|
503
503
|
token = _context9.sent;
|
|
504
504
|
this.SetStaticToken({
|
|
505
505
|
token: token
|
|
@@ -509,20 +509,20 @@ exports.RedeemCode = /*#__PURE__*/function () {
|
|
|
509
509
|
objectId: response.qid,
|
|
510
510
|
ntpId: response.oid
|
|
511
511
|
} : response.qid);
|
|
512
|
-
case
|
|
513
|
-
_context9.prev =
|
|
514
|
-
|
|
512
|
+
case 5:
|
|
513
|
+
_context9.prev = 5;
|
|
514
|
+
_t3 = _context9["catch"](3);
|
|
515
515
|
this.Log("Failed to redeem code:", true);
|
|
516
|
-
this.Log(
|
|
517
|
-
throw
|
|
518
|
-
case
|
|
516
|
+
this.Log(_t3, true);
|
|
517
|
+
throw _t3;
|
|
518
|
+
case 6:
|
|
519
519
|
// Site selector
|
|
520
520
|
objectId = issuer;
|
|
521
|
-
_context9.next =
|
|
521
|
+
_context9.next = 7;
|
|
522
522
|
return this.ContentObjectLibraryId({
|
|
523
523
|
objectId: objectId
|
|
524
524
|
});
|
|
525
|
-
case
|
|
525
|
+
case 7:
|
|
526
526
|
libraryId = _context9.sent;
|
|
527
527
|
Hash = function Hash(code) {
|
|
528
528
|
var chars = code.split("").map(function (code) {
|
|
@@ -533,49 +533,49 @@ exports.RedeemCode = /*#__PURE__*/function () {
|
|
|
533
533
|
}, 0).toString();
|
|
534
534
|
};
|
|
535
535
|
codeHash = Hash(code);
|
|
536
|
-
_context9.next =
|
|
536
|
+
_context9.next = 8;
|
|
537
537
|
return this.ContentObjectMetadata({
|
|
538
538
|
libraryId: libraryId,
|
|
539
539
|
objectId: objectId,
|
|
540
540
|
metadataSubtree: "public/codes/".concat(codeHash)
|
|
541
541
|
});
|
|
542
|
-
case
|
|
542
|
+
case 8:
|
|
543
543
|
codeInfo = _context9.sent;
|
|
544
544
|
if (codeInfo) {
|
|
545
|
-
_context9.next =
|
|
545
|
+
_context9.next = 9;
|
|
546
546
|
break;
|
|
547
547
|
}
|
|
548
548
|
this.Log("Code redemption failed:\n\t".concat(issuer, "\n\t").concat(code));
|
|
549
549
|
throw Error("Invalid code: " + code);
|
|
550
|
-
case
|
|
550
|
+
case 9:
|
|
551
551
|
ak = codeInfo.ak, sites = codeInfo.sites, info = codeInfo.info;
|
|
552
|
-
_context9.next =
|
|
552
|
+
_context9.next = 10;
|
|
553
553
|
return wallet.AddAccountFromEncryptedPK({
|
|
554
554
|
encryptedPrivateKey: this.utils.FromB64(ak),
|
|
555
555
|
password: code
|
|
556
556
|
});
|
|
557
|
-
case
|
|
557
|
+
case 10:
|
|
558
558
|
signer = _context9.sent;
|
|
559
559
|
this.SetSigner({
|
|
560
560
|
signer: signer
|
|
561
561
|
});
|
|
562
562
|
|
|
563
563
|
// Ensure wallet is initialized
|
|
564
|
-
_context9.next =
|
|
564
|
+
_context9.next = 11;
|
|
565
565
|
return this.userProfileClient.WalletAddress();
|
|
566
|
-
case
|
|
566
|
+
case 11:
|
|
567
567
|
return _context9.abrupt("return", {
|
|
568
568
|
addr: this.utils.FormatAddress(signer.address),
|
|
569
569
|
sites: sites,
|
|
570
570
|
info: info || {}
|
|
571
571
|
});
|
|
572
|
-
case
|
|
572
|
+
case 12:
|
|
573
573
|
case "end":
|
|
574
574
|
return _context9.stop();
|
|
575
575
|
}
|
|
576
|
-
}, _callee9, this, [[
|
|
576
|
+
}, _callee9, this, [[3, 5]]);
|
|
577
577
|
}));
|
|
578
578
|
return function (_x9) {
|
|
579
|
-
return
|
|
579
|
+
return _ref16.apply(this, arguments);
|
|
580
580
|
};
|
|
581
581
|
}();
|