@eluvio/elv-client-js 3.2.4 → 3.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.
Files changed (46) hide show
  1. package/dist/ElvClient-min.js +15 -11
  2. package/dist/ElvClient-node-min.js +17 -13
  3. package/dist/ElvFrameClient-min.js +12 -8
  4. package/dist/ElvPermissionsClient-min.js +13 -9
  5. package/dist/ElvWalletClient-min.js +58 -0
  6. package/dist/ElvWalletClient-node-min.js +78 -0
  7. package/dist/src/AuthorizationClient.js +2248 -1990
  8. package/dist/src/ContentObjectVerification.js +164 -173
  9. package/dist/src/Crypto.js +376 -324
  10. package/dist/src/ElvClient.js +1198 -1019
  11. package/dist/src/ElvWallet.js +119 -95
  12. package/dist/src/EthClient.js +1040 -896
  13. package/dist/src/FrameClient.js +331 -300
  14. package/dist/src/HttpClient.js +153 -147
  15. package/dist/src/Id.js +1 -3
  16. package/dist/src/PermissionsClient.js +1294 -1168
  17. package/dist/src/RemoteSigner.js +263 -211
  18. package/dist/src/UserProfileClient.js +1164 -1023
  19. package/dist/src/Utils.js +229 -184
  20. package/dist/src/client/ABRPublishing.js +895 -858
  21. package/dist/src/client/AccessGroups.js +1102 -959
  22. package/dist/src/client/ContentAccess.js +3724 -3431
  23. package/dist/src/client/ContentManagement.js +2252 -2068
  24. package/dist/src/client/Contracts.js +647 -563
  25. package/dist/src/client/Files.js +1886 -1757
  26. package/dist/src/client/NFT.js +126 -112
  27. package/dist/src/client/NTP.js +478 -422
  28. package/dist/src/index.js +11 -0
  29. package/dist/src/marketplaceClient/ClientMethods.js +1918 -0
  30. package/dist/src/marketplaceClient/Configuration.js +29 -0
  31. package/dist/src/marketplaceClient/Utils.js +304 -0
  32. package/dist/src/marketplaceClient/index.js +1553 -0
  33. package/dist/src/walletClient/ClientMethods.js +2080 -0
  34. package/dist/src/walletClient/Configuration.js +29 -0
  35. package/dist/src/walletClient/Utils.js +304 -0
  36. package/dist/src/walletClient/index.js +1770 -0
  37. package/package.json +8 -4
  38. package/src/ElvClient.js +5 -2
  39. package/src/Utils.js +22 -4
  40. package/src/index.js +7 -0
  41. package/src/walletClient/ClientMethods.js +1111 -0
  42. package/src/walletClient/Configuration.js +40 -0
  43. package/src/walletClient/README.md +191 -0
  44. package/src/walletClient/Utils.js +234 -0
  45. package/src/walletClient/index.js +977 -0
  46. package/testScripts/TestMarketplaceClient.js +25 -0
@@ -1,5 +1,7 @@
1
1
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
2
 
3
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
+
3
5
  /**
4
6
  * Methods for creating and managing NTP instances and tickets
5
7
  *
@@ -62,68 +64,74 @@ var FormatNTPInfo = function FormatNTPInfo(info) {
62
64
  */
63
65
 
64
66
 
65
- exports.CreateNTPInstance = function _callee(_ref) {
66
- var _this = this;
67
-
68
- var tenantId, objectId, groupAddresses, _ref$ntpClass, ntpClass, _ref$maxTickets, maxTickets, _ref$maxRedemptions, maxRedemptions, startTime, endTime, _ref$ticketLength, ticketLength, paramsJSON, groupIds;
69
-
70
- return _regeneratorRuntime.async(function _callee$(_context) {
71
- while (1) {
72
- switch (_context.prev = _context.next) {
73
- case 0:
74
- 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;
75
- ValidatePresence("tenantId", tenantId);
76
- ValidatePresence("objectId or groupAddresses", objectId || groupAddresses);
77
-
78
- if (objectId) {
79
- ValidateObject(objectId);
80
- }
81
-
82
- if (groupAddresses) {
83
- groupAddresses.forEach(function (address) {
84
- return ValidateAddress(address);
67
+ exports.CreateNTPInstance = /*#__PURE__*/function () {
68
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
69
+ var _this = this;
70
+
71
+ var tenantId, objectId, groupAddresses, _ref$ntpClass, ntpClass, _ref$maxTickets, maxTickets, _ref$maxRedemptions, maxRedemptions, startTime, endTime, _ref$ticketLength, ticketLength, paramsJSON, groupIds;
72
+
73
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
74
+ while (1) {
75
+ switch (_context.prev = _context.next) {
76
+ case 0:
77
+ 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;
78
+ ValidatePresence("tenantId", tenantId);
79
+ ValidatePresence("objectId or groupAddresses", objectId || groupAddresses);
80
+
81
+ if (objectId) {
82
+ ValidateObject(objectId);
83
+ }
84
+
85
+ if (groupAddresses) {
86
+ groupAddresses.forEach(function (address) {
87
+ return ValidateAddress(address);
88
+ });
89
+ }
90
+
91
+ startTime = ValidateDate(startTime);
92
+ endTime = ValidateDate(endTime);
93
+ paramsJSON = ["ntp:".concat(parseInt(maxRedemptions)), "sen:".concat(parseInt(ticketLength))];
94
+
95
+ if (objectId) {
96
+ paramsJSON.push("qid:".concat(objectId));
97
+ } else if (groupAddresses) {
98
+ groupIds = groupAddresses.map(function (address) {
99
+ return "igrp".concat(_this.utils.AddressToHash(address));
100
+ });
101
+ paramsJSON.push("gid:".concat(groupIds.join(",")));
102
+ }
103
+
104
+ if (startTime) {
105
+ paramsJSON.push("vat:".concat(startTime));
106
+ }
107
+
108
+ if (endTime) {
109
+ paramsJSON.push("exp:".concat(endTime));
110
+ }
111
+
112
+ _context.next = 13;
113
+ return this.authClient.MakeKMSCall({
114
+ tenantId: tenantId,
115
+ methodName: "elv_createOTPInstance",
116
+ params: [tenantId, ntpClass, JSON.stringify(paramsJSON), parseInt(maxTickets), Date.now()],
117
+ paramTypes: ["string", "int", "string", "int", "int"]
85
118
  });
86
- }
87
119
 
88
- startTime = ValidateDate(startTime);
89
- endTime = ValidateDate(endTime);
90
- paramsJSON = ["ntp:".concat(parseInt(maxRedemptions)), "sen:".concat(parseInt(ticketLength))];
120
+ case 13:
121
+ return _context.abrupt("return", _context.sent);
91
122
 
92
- if (objectId) {
93
- paramsJSON.push("qid:".concat(objectId));
94
- } else if (groupAddresses) {
95
- groupIds = groupAddresses.map(function (address) {
96
- return "igrp".concat(_this.utils.AddressToHash(address));
97
- });
98
- paramsJSON.push("gid:".concat(groupIds.join(",")));
99
- }
100
-
101
- if (startTime) {
102
- paramsJSON.push("vat:".concat(startTime));
103
- }
104
-
105
- if (endTime) {
106
- paramsJSON.push("exp:".concat(endTime));
107
- }
108
-
109
- _context.next = 13;
110
- return _regeneratorRuntime.awrap(this.authClient.MakeKMSCall({
111
- tenantId: tenantId,
112
- methodName: "elv_createOTPInstance",
113
- params: [tenantId, ntpClass, JSON.stringify(paramsJSON), parseInt(maxTickets), Date.now()],
114
- paramTypes: ["string", "int", "string", "int", "int"]
115
- }));
116
-
117
- case 13:
118
- return _context.abrupt("return", _context.sent);
119
-
120
- case 14:
121
- case "end":
122
- return _context.stop();
123
+ case 14:
124
+ case "end":
125
+ return _context.stop();
126
+ }
123
127
  }
124
- }
125
- }, null, this);
126
- };
128
+ }, _callee, this);
129
+ }));
130
+
131
+ return function (_x) {
132
+ return _ref2.apply(this, arguments);
133
+ };
134
+ }();
127
135
  /**
128
136
  * Update the attributes of the specified NTP instance. Only the specified attributes will be updated ; others will be unchanged.
129
137
  *
@@ -140,56 +148,62 @@ exports.CreateNTPInstance = function _callee(_ref) {
140
148
  */
141
149
 
142
150
 
143
- exports.UpdateNTPInstance = function _callee2(_ref2) {
144
- var tenantId, ntpId, _ref2$maxTickets, maxTickets, _ref2$maxRedemptions, maxRedemptions, startTime, endTime, paramsJSON, _ref3, Ret;
145
-
146
- return _regeneratorRuntime.async(function _callee2$(_context2) {
147
- while (1) {
148
- switch (_context2.prev = _context2.next) {
149
- case 0:
150
- tenantId = _ref2.tenantId, ntpId = _ref2.ntpId, _ref2$maxTickets = _ref2.maxTickets, maxTickets = _ref2$maxTickets === void 0 ? 0 : _ref2$maxTickets, _ref2$maxRedemptions = _ref2.maxRedemptions, maxRedemptions = _ref2$maxRedemptions === void 0 ? 100 : _ref2$maxRedemptions, startTime = _ref2.startTime, endTime = _ref2.endTime;
151
- ValidatePresence("tenantId", tenantId);
152
- ValidatePresence("ntpId", ntpId);
153
- startTime = ValidateDate(startTime);
154
- endTime = ValidateDate(endTime);
155
- paramsJSON = [];
156
-
157
- if (maxRedemptions) {
158
- paramsJSON.push("ntp:".concat(parseInt(maxRedemptions)));
159
- }
160
-
161
- if (startTime) {
162
- paramsJSON.push("vat:".concat(startTime));
163
- }
164
-
165
- if (endTime) {
166
- paramsJSON.push("exp:".concat(endTime));
167
- }
168
-
169
- if (maxTickets) {
170
- paramsJSON.push("max:".concat(parseInt(maxTickets)));
171
- }
172
-
173
- _context2.next = 12;
174
- return _regeneratorRuntime.awrap(this.authClient.MakeKMSCall({
175
- tenantId: tenantId,
176
- methodName: "elv_updateOTPInstance",
177
- params: [tenantId, ntpId, "update", JSON.stringify(paramsJSON), Date.now()],
178
- paramTypes: ["string", "string", "string", "string", "int"]
179
- }));
180
-
181
- case 12:
182
- _ref3 = _context2.sent;
183
- Ret = _ref3.Ret;
184
- return _context2.abrupt("return", FormatNTPInfo(JSON.parse(Ret)));
185
-
186
- case 15:
187
- case "end":
188
- return _context2.stop();
151
+ exports.UpdateNTPInstance = /*#__PURE__*/function () {
152
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
153
+ var tenantId, ntpId, _ref3$maxTickets, maxTickets, _ref3$maxRedemptions, maxRedemptions, startTime, endTime, paramsJSON, _yield$this$authClien, Ret;
154
+
155
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
156
+ while (1) {
157
+ switch (_context2.prev = _context2.next) {
158
+ case 0:
159
+ 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;
160
+ ValidatePresence("tenantId", tenantId);
161
+ ValidatePresence("ntpId", ntpId);
162
+ startTime = ValidateDate(startTime);
163
+ endTime = ValidateDate(endTime);
164
+ paramsJSON = [];
165
+
166
+ if (maxRedemptions) {
167
+ paramsJSON.push("ntp:".concat(parseInt(maxRedemptions)));
168
+ }
169
+
170
+ if (startTime) {
171
+ paramsJSON.push("vat:".concat(startTime));
172
+ }
173
+
174
+ if (endTime) {
175
+ paramsJSON.push("exp:".concat(endTime));
176
+ }
177
+
178
+ if (maxTickets) {
179
+ paramsJSON.push("max:".concat(parseInt(maxTickets)));
180
+ }
181
+
182
+ _context2.next = 12;
183
+ return this.authClient.MakeKMSCall({
184
+ tenantId: tenantId,
185
+ methodName: "elv_updateOTPInstance",
186
+ params: [tenantId, ntpId, "update", JSON.stringify(paramsJSON), Date.now()],
187
+ paramTypes: ["string", "string", "string", "string", "int"]
188
+ });
189
+
190
+ case 12:
191
+ _yield$this$authClien = _context2.sent;
192
+ Ret = _yield$this$authClien.Ret;
193
+ return _context2.abrupt("return", FormatNTPInfo(JSON.parse(Ret)));
194
+
195
+ case 15:
196
+ case "end":
197
+ return _context2.stop();
198
+ }
189
199
  }
190
- }
191
- }, null, this);
192
- };
200
+ }, _callee2, this);
201
+ }));
202
+
203
+ return function (_x2) {
204
+ return _ref4.apply(this, arguments);
205
+ };
206
+ }();
193
207
  /**
194
208
  * Suspend the specified NTP instance. All tickets issued for this instance will be considered expired.
195
209
  *
@@ -202,30 +216,36 @@ exports.UpdateNTPInstance = function _callee2(_ref2) {
202
216
  */
203
217
 
204
218
 
205
- exports.SuspendNTPInstance = function _callee3(_ref4) {
206
- var tenantId, ntpId;
207
- return _regeneratorRuntime.async(function _callee3$(_context3) {
208
- while (1) {
209
- switch (_context3.prev = _context3.next) {
210
- case 0:
211
- tenantId = _ref4.tenantId, ntpId = _ref4.ntpId;
212
- ValidatePresence("tenantId", tenantId);
213
- ValidatePresence("ntpId", ntpId);
214
- _context3.next = 5;
215
- return _regeneratorRuntime.awrap(this.authClient.MakeKMSCall({
216
- tenantId: tenantId,
217
- methodName: "elv_updateOTPInstance",
218
- params: [tenantId, ntpId, "cancel", "[]", Date.now()],
219
- paramTypes: ["string", "string", "string", "string", "int"]
220
- }));
221
-
222
- case 5:
223
- case "end":
224
- return _context3.stop();
219
+ exports.SuspendNTPInstance = /*#__PURE__*/function () {
220
+ var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
221
+ var tenantId, ntpId;
222
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
223
+ while (1) {
224
+ switch (_context3.prev = _context3.next) {
225
+ case 0:
226
+ tenantId = _ref5.tenantId, ntpId = _ref5.ntpId;
227
+ ValidatePresence("tenantId", tenantId);
228
+ ValidatePresence("ntpId", ntpId);
229
+ _context3.next = 5;
230
+ return this.authClient.MakeKMSCall({
231
+ tenantId: tenantId,
232
+ methodName: "elv_updateOTPInstance",
233
+ params: [tenantId, ntpId, "cancel", "[]", Date.now()],
234
+ paramTypes: ["string", "string", "string", "string", "int"]
235
+ });
236
+
237
+ case 5:
238
+ case "end":
239
+ return _context3.stop();
240
+ }
225
241
  }
226
- }
227
- }, null, this);
228
- };
242
+ }, _callee3, this);
243
+ }));
244
+
245
+ return function (_x3) {
246
+ return _ref6.apply(this, arguments);
247
+ };
248
+ }();
229
249
  /**
230
250
  * Delete the specified NTP instance. This action cannot be undone.
231
251
  *
@@ -236,30 +256,36 @@ exports.SuspendNTPInstance = function _callee3(_ref4) {
236
256
  */
237
257
 
238
258
 
239
- exports.DeleteNTPInstance = function _callee4(_ref5) {
240
- var tenantId, ntpId;
241
- return _regeneratorRuntime.async(function _callee4$(_context4) {
242
- while (1) {
243
- switch (_context4.prev = _context4.next) {
244
- case 0:
245
- tenantId = _ref5.tenantId, ntpId = _ref5.ntpId;
246
- ValidatePresence("tenantId", tenantId);
247
- ValidatePresence("ntpId", ntpId);
248
- _context4.next = 5;
249
- return _regeneratorRuntime.awrap(this.authClient.MakeKMSCall({
250
- tenantId: tenantId,
251
- methodName: "elv_updateOTPInstance",
252
- params: [tenantId, ntpId, "delete", "[]", Date.now()],
253
- paramTypes: ["string", "string", "string", "string", "int"]
254
- }));
255
-
256
- case 5:
257
- case "end":
258
- return _context4.stop();
259
+ exports.DeleteNTPInstance = /*#__PURE__*/function () {
260
+ var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref7) {
261
+ var tenantId, ntpId;
262
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
263
+ while (1) {
264
+ switch (_context4.prev = _context4.next) {
265
+ case 0:
266
+ tenantId = _ref7.tenantId, ntpId = _ref7.ntpId;
267
+ ValidatePresence("tenantId", tenantId);
268
+ ValidatePresence("ntpId", ntpId);
269
+ _context4.next = 5;
270
+ return this.authClient.MakeKMSCall({
271
+ tenantId: tenantId,
272
+ methodName: "elv_updateOTPInstance",
273
+ params: [tenantId, ntpId, "delete", "[]", Date.now()],
274
+ paramTypes: ["string", "string", "string", "string", "int"]
275
+ });
276
+
277
+ case 5:
278
+ case "end":
279
+ return _context4.stop();
280
+ }
259
281
  }
260
- }
261
- }, null, this);
262
- };
282
+ }, _callee4, this);
283
+ }));
284
+
285
+ return function (_x4) {
286
+ return _ref8.apply(this, arguments);
287
+ };
288
+ }();
263
289
  /**
264
290
  * Retrieve info for NTP instances in the specified tenant
265
291
  *
@@ -273,42 +299,48 @@ exports.DeleteNTPInstance = function _callee4(_ref5) {
273
299
  */
274
300
 
275
301
 
276
- exports.ListNTPInstances = function _callee5(_ref6) {
277
- var tenantId, _ref6$count, count, _ref6$offset, offset, _ref7, Defs, Total;
278
-
279
- return _regeneratorRuntime.async(function _callee5$(_context5) {
280
- while (1) {
281
- switch (_context5.prev = _context5.next) {
282
- case 0:
283
- tenantId = _ref6.tenantId, _ref6$count = _ref6.count, count = _ref6$count === void 0 ? 10 : _ref6$count, _ref6$offset = _ref6.offset, offset = _ref6$offset === void 0 ? 0 : _ref6$offset;
284
- ValidatePresence("tenantId", tenantId);
285
- _context5.next = 4;
286
- return _regeneratorRuntime.awrap(this.authClient.MakeKMSCall({
287
- tenantId: tenantId,
288
- methodName: "elv_listOTPInfo",
289
- params: [tenantId, offset, count],
290
- paramTypes: ["string", "int", "int"],
291
- signature: false
292
- }));
293
-
294
- case 4:
295
- _ref7 = _context5.sent;
296
- Defs = _ref7.Defs;
297
- Total = _ref7.Total;
298
- return _context5.abrupt("return", {
299
- ntpInstances: Object.values(Defs || {}).map(FormatNTPInfo),
300
- start: offset,
301
- end: Math.min(Total, offset + count),
302
- total: Total
303
- });
304
-
305
- case 8:
306
- case "end":
307
- return _context5.stop();
302
+ exports.ListNTPInstances = /*#__PURE__*/function () {
303
+ var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref9) {
304
+ var tenantId, _ref9$count, count, _ref9$offset, offset, _yield$this$authClien2, Defs, Total;
305
+
306
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
307
+ while (1) {
308
+ switch (_context5.prev = _context5.next) {
309
+ case 0:
310
+ 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;
311
+ ValidatePresence("tenantId", tenantId);
312
+ _context5.next = 4;
313
+ return this.authClient.MakeKMSCall({
314
+ tenantId: tenantId,
315
+ methodName: "elv_listOTPInfo",
316
+ params: [tenantId, offset, count],
317
+ paramTypes: ["string", "int", "int"],
318
+ signature: false
319
+ });
320
+
321
+ case 4:
322
+ _yield$this$authClien2 = _context5.sent;
323
+ Defs = _yield$this$authClien2.Defs;
324
+ Total = _yield$this$authClien2.Total;
325
+ return _context5.abrupt("return", {
326
+ ntpInstances: Object.values(Defs || {}).map(FormatNTPInfo),
327
+ start: offset,
328
+ end: Math.min(Total, offset + count),
329
+ total: Total
330
+ });
331
+
332
+ case 8:
333
+ case "end":
334
+ return _context5.stop();
335
+ }
308
336
  }
309
- }
310
- }, null, this);
311
- };
337
+ }, _callee5, this);
338
+ }));
339
+
340
+ return function (_x5) {
341
+ return _ref10.apply(this, arguments);
342
+ };
343
+ }();
312
344
  /**
313
345
  * Retrieve a info about the specified NTP instance
314
346
  *
@@ -321,36 +353,42 @@ exports.ListNTPInstances = function _callee5(_ref6) {
321
353
  */
322
354
 
323
355
 
324
- exports.NTPInstance = function _callee6(_ref8) {
325
- var tenantId, ntpId;
326
- return _regeneratorRuntime.async(function _callee6$(_context6) {
327
- while (1) {
328
- switch (_context6.prev = _context6.next) {
329
- case 0:
330
- tenantId = _ref8.tenantId, ntpId = _ref8.ntpId;
331
- ValidatePresence("tenantId", tenantId);
332
- ValidatePresence("ntpId", ntpId);
333
- _context6.t0 = FormatNTPInfo;
334
- _context6.next = 6;
335
- return _regeneratorRuntime.awrap(this.authClient.MakeKMSCall({
336
- tenantId: tenantId,
337
- methodName: "elv_getOTPInfo",
338
- params: [tenantId, ntpId],
339
- paramTypes: ["string", "string"],
340
- signature: false
341
- }));
342
-
343
- case 6:
344
- _context6.t1 = _context6.sent;
345
- return _context6.abrupt("return", (0, _context6.t0)(_context6.t1));
346
-
347
- case 8:
348
- case "end":
349
- return _context6.stop();
356
+ exports.NTPInstance = /*#__PURE__*/function () {
357
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref11) {
358
+ var tenantId, ntpId;
359
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
360
+ while (1) {
361
+ switch (_context6.prev = _context6.next) {
362
+ case 0:
363
+ tenantId = _ref11.tenantId, ntpId = _ref11.ntpId;
364
+ ValidatePresence("tenantId", tenantId);
365
+ ValidatePresence("ntpId", ntpId);
366
+ _context6.t0 = FormatNTPInfo;
367
+ _context6.next = 6;
368
+ return this.authClient.MakeKMSCall({
369
+ tenantId: tenantId,
370
+ methodName: "elv_getOTPInfo",
371
+ params: [tenantId, ntpId],
372
+ paramTypes: ["string", "string"],
373
+ signature: false
374
+ });
375
+
376
+ case 6:
377
+ _context6.t1 = _context6.sent;
378
+ return _context6.abrupt("return", (0, _context6.t0)(_context6.t1));
379
+
380
+ case 8:
381
+ case "end":
382
+ return _context6.stop();
383
+ }
350
384
  }
351
- }
352
- }, null, this);
353
- };
385
+ }, _callee6, this);
386
+ }));
387
+
388
+ return function (_x6) {
389
+ return _ref12.apply(this, arguments);
390
+ };
391
+ }();
354
392
  /**
355
393
  * Issue a ticket from the specified NTP ID
356
394
  *
@@ -369,44 +407,50 @@ exports.NTPInstance = function _callee6(_ref8) {
369
407
  */
370
408
 
371
409
 
372
- exports.IssueNTPCode = function _callee7(_ref9) {
373
- var tenantId, ntpId, email, maxRedemptions, options, params, paramTypes;
374
- return _regeneratorRuntime.async(function _callee7$(_context7) {
375
- while (1) {
376
- switch (_context7.prev = _context7.next) {
377
- case 0:
378
- tenantId = _ref9.tenantId, ntpId = _ref9.ntpId, email = _ref9.email, maxRedemptions = _ref9.maxRedemptions;
379
- ValidatePresence("tenantId", tenantId);
380
- ValidatePresence("ntpId", ntpId);
381
- options = [];
382
-
383
- if (email) {
384
- options.push("eml:".concat(email));
385
- }
386
-
387
- if (maxRedemptions) {
388
- options.push("cnt:".concat(parseInt(maxRedemptions)));
389
- }
390
-
391
- params = [tenantId, ntpId, JSON.stringify(options), Date.now()];
392
- paramTypes = ["string", "string", "string", "uint"];
393
- _context7.next = 10;
394
- return _regeneratorRuntime.awrap(this.authClient.MakeKMSCall({
395
- methodName: "elv_issueOTPCode",
396
- params: params,
397
- paramTypes: paramTypes
398
- }));
399
-
400
- case 10:
401
- return _context7.abrupt("return", _context7.sent);
402
-
403
- case 11:
404
- case "end":
405
- return _context7.stop();
410
+ exports.IssueNTPCode = /*#__PURE__*/function () {
411
+ var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref13) {
412
+ var tenantId, ntpId, email, maxRedemptions, options, params, paramTypes;
413
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
414
+ while (1) {
415
+ switch (_context7.prev = _context7.next) {
416
+ case 0:
417
+ tenantId = _ref13.tenantId, ntpId = _ref13.ntpId, email = _ref13.email, maxRedemptions = _ref13.maxRedemptions;
418
+ ValidatePresence("tenantId", tenantId);
419
+ ValidatePresence("ntpId", ntpId);
420
+ options = [];
421
+
422
+ if (email) {
423
+ options.push("eml:".concat(email));
424
+ }
425
+
426
+ if (maxRedemptions) {
427
+ options.push("cnt:".concat(parseInt(maxRedemptions)));
428
+ }
429
+
430
+ params = [tenantId, ntpId, JSON.stringify(options), Date.now()];
431
+ paramTypes = ["string", "string", "string", "uint"];
432
+ _context7.next = 10;
433
+ return this.authClient.MakeKMSCall({
434
+ methodName: "elv_issueOTPCode",
435
+ params: params,
436
+ paramTypes: paramTypes
437
+ });
438
+
439
+ case 10:
440
+ return _context7.abrupt("return", _context7.sent);
441
+
442
+ case 11:
443
+ case "end":
444
+ return _context7.stop();
445
+ }
406
446
  }
407
- }
408
- }, null, this);
409
- };
447
+ }, _callee7, this);
448
+ }));
449
+
450
+ return function (_x7) {
451
+ return _ref14.apply(this, arguments);
452
+ };
453
+ }();
410
454
  /**
411
455
  * Identical to IssueNTPCode, but the token is also signed by the current user.
412
456
  *
@@ -425,47 +469,53 @@ exports.IssueNTPCode = function _callee7(_ref9) {
425
469
  */
426
470
 
427
471
 
428
- exports.IssueSignedNTPCode = function _callee8(_ref10) {
429
- var tenantId, ntpId, email, maxRedemptions, result, signature, multiSig;
430
- return _regeneratorRuntime.async(function _callee8$(_context8) {
431
- while (1) {
432
- switch (_context8.prev = _context8.next) {
433
- case 0:
434
- tenantId = _ref10.tenantId, ntpId = _ref10.ntpId, email = _ref10.email, maxRedemptions = _ref10.maxRedemptions;
435
- _context8.next = 3;
436
- return _regeneratorRuntime.awrap(this.IssueNTPCode({
437
- tenantId: tenantId,
438
- ntpId: ntpId,
439
- email: email,
440
- maxRedemptions: maxRedemptions
441
- }));
442
-
443
- case 3:
444
- result = _context8.sent;
445
-
446
- if (!result.token) {
447
- _context8.next = 10;
448
- break;
449
- }
472
+ exports.IssueSignedNTPCode = /*#__PURE__*/function () {
473
+ var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref15) {
474
+ var tenantId, ntpId, email, maxRedemptions, result, signature, multiSig;
475
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
476
+ while (1) {
477
+ switch (_context8.prev = _context8.next) {
478
+ case 0:
479
+ tenantId = _ref15.tenantId, ntpId = _ref15.ntpId, email = _ref15.email, maxRedemptions = _ref15.maxRedemptions;
480
+ _context8.next = 3;
481
+ return this.IssueNTPCode({
482
+ tenantId: tenantId,
483
+ ntpId: ntpId,
484
+ email: email,
485
+ maxRedemptions: maxRedemptions
486
+ });
450
487
 
451
- _context8.next = 7;
452
- return _regeneratorRuntime.awrap(this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(result.token))));
488
+ case 3:
489
+ result = _context8.sent;
453
490
 
454
- case 7:
455
- signature = _context8.sent;
456
- multiSig = this.utils.FormatSignature(signature);
457
- result.token = "".concat(result.token, ".").concat(this.utils.B64(multiSig));
491
+ if (!result.token) {
492
+ _context8.next = 10;
493
+ break;
494
+ }
458
495
 
459
- case 10:
460
- return _context8.abrupt("return", result);
496
+ _context8.next = 7;
497
+ return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(result.token)));
461
498
 
462
- case 11:
463
- case "end":
464
- return _context8.stop();
499
+ case 7:
500
+ signature = _context8.sent;
501
+ multiSig = this.utils.FormatSignature(signature);
502
+ result.token = "".concat(result.token, ".").concat(this.utils.B64(multiSig));
503
+
504
+ case 10:
505
+ return _context8.abrupt("return", result);
506
+
507
+ case 11:
508
+ case "end":
509
+ return _context8.stop();
510
+ }
465
511
  }
466
- }
467
- }, null, this);
468
- };
512
+ }, _callee8, this);
513
+ }));
514
+
515
+ return function (_x8) {
516
+ return _ref16.apply(this, arguments);
517
+ };
518
+ }();
469
519
  /**
470
520
  * Redeem the specified ticket/code to authorize the client. Must provide either issuer or tenantId and ntpId
471
521
  *
@@ -482,143 +532,149 @@ exports.IssueSignedNTPCode = function _callee8(_ref10) {
482
532
  */
483
533
 
484
534
 
485
- exports.RedeemCode = function _callee9(_ref11) {
486
- var issuer, tenantId, ntpId, code, email, _ref11$includeNTPId, includeNTPId, wallet, token, response, objectId, libraryId, Hash, codeHash, codeInfo, ak, sites, info, signer;
535
+ exports.RedeemCode = /*#__PURE__*/function () {
536
+ var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref17) {
537
+ var issuer, tenantId, ntpId, code, email, _ref17$includeNTPId, includeNTPId, wallet, token, response, objectId, libraryId, Hash, codeHash, codeInfo, ak, sites, info, signer;
538
+
539
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
540
+ while (1) {
541
+ switch (_context9.prev = _context9.next) {
542
+ case 0:
543
+ issuer = _ref17.issuer, tenantId = _ref17.tenantId, ntpId = _ref17.ntpId, code = _ref17.code, email = _ref17.email, _ref17$includeNTPId = _ref17.includeNTPId, includeNTPId = _ref17$includeNTPId === void 0 ? false : _ref17$includeNTPId;
544
+ wallet = this.GenerateWallet();
545
+ issuer = issuer || "";
546
+
547
+ if (!this.signer) {
548
+ this.SetSigner({
549
+ signer: wallet.AddAccountFromMnemonic({
550
+ mnemonic: wallet.GenerateMnemonic()
551
+ })
552
+ });
553
+ }
554
+
555
+ if (!issuer.startsWith("iq__")) {
556
+ _context9.next = 8;
557
+ break;
558
+ }
559
+
560
+ ValidateObject(issuer);
561
+ _context9.next = 28;
562
+ break;
487
563
 
488
- return _regeneratorRuntime.async(function _callee9$(_context9) {
489
- while (1) {
490
- switch (_context9.prev = _context9.next) {
491
- case 0:
492
- issuer = _ref11.issuer, tenantId = _ref11.tenantId, ntpId = _ref11.ntpId, code = _ref11.code, email = _ref11.email, _ref11$includeNTPId = _ref11.includeNTPId, includeNTPId = _ref11$includeNTPId === void 0 ? false : _ref11$includeNTPId;
493
- wallet = this.GenerateWallet();
494
- issuer = issuer || "";
564
+ case 8:
565
+ if (!(issuer && !issuer.replace(/^\//, "").startsWith("otp/ntp/iten"))) {
566
+ _context9.next = 12;
567
+ break;
568
+ }
495
569
 
496
- if (!this.signer) {
497
- this.SetSigner({
498
- signer: wallet.AddAccountFromMnemonic({
499
- mnemonic: wallet.GenerateMnemonic()
500
- })
570
+ throw Error("Invalid issuer: " + issuer);
571
+
572
+ case 12:
573
+ // Ticket API
574
+ ValidatePresence("issuer or tenantId", issuer || tenantId);
575
+
576
+ if (!issuer) {
577
+ issuer = UrlJoin("/otp", "ntp", tenantId, ntpId || "");
578
+ }
579
+
580
+ _context9.prev = 14;
581
+ _context9.next = 17;
582
+ return this.authClient.GenerateChannelContentToken({
583
+ issuer: issuer,
584
+ code: code,
585
+ email: email
501
586
  });
502
- }
503
587
 
504
- if (!issuer.startsWith("iq__")) {
505
- _context9.next = 8;
506
- break;
507
- }
588
+ case 17:
589
+ token = _context9.sent;
590
+ this.SetStaticToken({
591
+ token: token
592
+ });
593
+ response = JSON.parse(this.utils.FromB64(token));
594
+ return _context9.abrupt("return", includeNTPId ? {
595
+ objectId: response.qid,
596
+ ntpId: response.oid
597
+ } : response.qid);
598
+
599
+ case 23:
600
+ _context9.prev = 23;
601
+ _context9.t0 = _context9["catch"](14);
602
+ this.Log("Failed to redeem code:", true);
603
+ this.Log(_context9.t0, true);
604
+ throw _context9.t0;
605
+
606
+ case 28:
607
+ // Site selector
608
+ objectId = issuer;
609
+ _context9.next = 31;
610
+ return this.ContentObjectLibraryId({
611
+ objectId: objectId
612
+ });
508
613
 
509
- ValidateObject(issuer);
510
- _context9.next = 28;
511
- break;
614
+ case 31:
615
+ libraryId = _context9.sent;
616
+
617
+ Hash = function Hash(code) {
618
+ var chars = code.split("").map(function (code) {
619
+ return code.charCodeAt(0);
620
+ });
621
+ return chars.reduce(function (sum, _char, i) {
622
+ return chars[i + 1] ? sum * 2 + _char * chars[i + 1] * (i + 1) : sum + _char;
623
+ }, 0).toString();
624
+ };
625
+
626
+ codeHash = Hash(code);
627
+ _context9.next = 36;
628
+ return this.ContentObjectMetadata({
629
+ libraryId: libraryId,
630
+ objectId: objectId,
631
+ metadataSubtree: "public/codes/".concat(codeHash)
632
+ });
512
633
 
513
- case 8:
514
- if (!(issuer && !issuer.replace(/^\//, "").startsWith("otp/ntp/iten"))) {
515
- _context9.next = 12;
516
- break;
517
- }
518
-
519
- throw Error("Invalid issuer: " + issuer);
520
-
521
- case 12:
522
- // Ticket API
523
- ValidatePresence("issuer or tenantId", issuer || tenantId);
524
-
525
- if (!issuer) {
526
- issuer = UrlJoin("/otp", "ntp", tenantId, ntpId || "");
527
- }
528
-
529
- _context9.prev = 14;
530
- _context9.next = 17;
531
- return _regeneratorRuntime.awrap(this.authClient.GenerateChannelContentToken({
532
- issuer: issuer,
533
- code: code,
534
- email: email
535
- }));
536
-
537
- case 17:
538
- token = _context9.sent;
539
- this.SetStaticToken({
540
- token: token
541
- });
542
- response = JSON.parse(this.utils.FromB64(token));
543
- return _context9.abrupt("return", includeNTPId ? {
544
- objectId: response.qid,
545
- ntpId: response.oid
546
- } : response.qid);
547
-
548
- case 23:
549
- _context9.prev = 23;
550
- _context9.t0 = _context9["catch"](14);
551
- this.Log("Failed to redeem code:", true);
552
- this.Log(_context9.t0, true);
553
- throw _context9.t0;
554
-
555
- case 28:
556
- // Site selector
557
- objectId = issuer;
558
- _context9.next = 31;
559
- return _regeneratorRuntime.awrap(this.ContentObjectLibraryId({
560
- objectId: objectId
561
- }));
562
-
563
- case 31:
564
- libraryId = _context9.sent;
565
-
566
- Hash = function Hash(code) {
567
- var chars = code.split("").map(function (code) {
568
- return code.charCodeAt(0);
634
+ case 36:
635
+ codeInfo = _context9.sent;
636
+
637
+ if (codeInfo) {
638
+ _context9.next = 40;
639
+ break;
640
+ }
641
+
642
+ this.Log("Code redemption failed:\n\t".concat(issuer, "\n\t").concat(code));
643
+ throw Error("Invalid code: " + code);
644
+
645
+ case 40:
646
+ ak = codeInfo.ak, sites = codeInfo.sites, info = codeInfo.info;
647
+ _context9.next = 43;
648
+ return wallet.AddAccountFromEncryptedPK({
649
+ encryptedPrivateKey: this.utils.FromB64(ak),
650
+ password: code
569
651
  });
570
- return chars.reduce(function (sum, _char, i) {
571
- return chars[i + 1] ? sum * 2 + _char * chars[i + 1] * (i + 1) : sum + _char;
572
- }, 0).toString();
573
- };
574
-
575
- codeHash = Hash(code);
576
- _context9.next = 36;
577
- return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
578
- libraryId: libraryId,
579
- objectId: objectId,
580
- metadataSubtree: "public/codes/".concat(codeHash)
581
- }));
582
-
583
- case 36:
584
- codeInfo = _context9.sent;
585
-
586
- if (codeInfo) {
587
- _context9.next = 40;
588
- break;
589
- }
590
-
591
- this.Log("Code redemption failed:\n\t".concat(issuer, "\n\t").concat(code));
592
- throw Error("Invalid code: " + code);
593
-
594
- case 40:
595
- ak = codeInfo.ak, sites = codeInfo.sites, info = codeInfo.info;
596
- _context9.next = 43;
597
- return _regeneratorRuntime.awrap(wallet.AddAccountFromEncryptedPK({
598
- encryptedPrivateKey: this.utils.FromB64(ak),
599
- password: code
600
- }));
601
-
602
- case 43:
603
- signer = _context9.sent;
604
- this.SetSigner({
605
- signer: signer
606
- }); // Ensure wallet is initialized
607
-
608
- _context9.next = 47;
609
- return _regeneratorRuntime.awrap(this.userProfileClient.WalletAddress());
610
-
611
- case 47:
612
- return _context9.abrupt("return", {
613
- addr: this.utils.FormatAddress(signer.address),
614
- sites: sites,
615
- info: info || {}
616
- });
617
-
618
- case 48:
619
- case "end":
620
- return _context9.stop();
652
+
653
+ case 43:
654
+ signer = _context9.sent;
655
+ this.SetSigner({
656
+ signer: signer
657
+ }); // Ensure wallet is initialized
658
+
659
+ _context9.next = 47;
660
+ return this.userProfileClient.WalletAddress();
661
+
662
+ case 47:
663
+ return _context9.abrupt("return", {
664
+ addr: this.utils.FormatAddress(signer.address),
665
+ sites: sites,
666
+ info: info || {}
667
+ });
668
+
669
+ case 48:
670
+ case "end":
671
+ return _context9.stop();
672
+ }
621
673
  }
622
- }
623
- }, null, this, [[14, 23]]);
624
- };
674
+ }, _callee9, this, [[14, 23]]);
675
+ }));
676
+
677
+ return function (_x9) {
678
+ return _ref18.apply(this, arguments);
679
+ };
680
+ }();