@eluvio/elv-client-js 3.1.96 → 3.2.1
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 +11 -15
- package/dist/ElvClient-node-min.js +13 -17
- package/dist/ElvFrameClient-min.js +9 -13
- package/dist/ElvPermissionsClient-min.js +9 -13
- package/dist/src/AuthorizationClient.js +1980 -2238
- package/dist/src/ContentObjectVerification.js +173 -164
- package/dist/src/Crypto.js +324 -376
- package/dist/src/ElvClient.js +1022 -1182
- package/dist/src/ElvWallet.js +95 -119
- package/dist/src/EthClient.js +896 -1040
- package/dist/src/FrameClient.js +300 -331
- package/dist/src/HttpClient.js +147 -153
- package/dist/src/Id.js +3 -1
- package/dist/src/PermissionsClient.js +1168 -1294
- package/dist/src/RemoteSigner.js +211 -263
- package/dist/src/UserProfileClient.js +1023 -1164
- package/dist/src/Utils.js +217 -212
- package/dist/src/client/ABRPublishing.js +858 -895
- package/dist/src/client/AccessGroups.js +959 -1102
- package/dist/src/client/ContentAccess.js +3434 -3727
- package/dist/src/client/ContentManagement.js +2068 -2252
- package/dist/src/client/Contracts.js +563 -647
- package/dist/src/client/Files.js +1757 -1886
- package/dist/src/client/NFT.js +112 -126
- package/dist/src/client/NTP.js +422 -478
- package/dist/src/index.js +11 -0
- package/dist/src/marketplaceClient/ClientMethods.js +1918 -0
- package/dist/src/marketplaceClient/Configuration.js +29 -0
- package/dist/src/marketplaceClient/Utils.js +304 -0
- package/dist/src/marketplaceClient/index.js +1553 -0
- package/dist/src/walletClient/ClientMethods.js +1828 -0
- package/dist/src/walletClient/Configuration.js +29 -0
- package/dist/src/walletClient/Utils.js +290 -0
- package/dist/src/walletClient/index.js +1459 -0
- package/package.json +5 -3
- package/src/ElvClient.js +4 -1
- package/src/Utils.js +44 -3
- package/src/index.js +7 -0
- package/src/walletClient/ClientMethods.js +1016 -0
- package/src/walletClient/Configuration.js +40 -0
- package/src/walletClient/README.md +185 -0
- package/src/walletClient/Utils.js +234 -0
- package/src/walletClient/index.js +884 -0
- package/testScripts/TestMarketplaceClient.js +25 -0
package/dist/src/client/NTP.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
2
2
|
|
|
3
|
-
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
4
|
-
|
|
5
3
|
/**
|
|
6
4
|
* Methods for creating and managing NTP instances and tickets
|
|
7
5
|
*
|
|
@@ -64,74 +62,68 @@ var FormatNTPInfo = function FormatNTPInfo(info) {
|
|
|
64
62
|
*/
|
|
65
63
|
|
|
66
64
|
|
|
67
|
-
exports.CreateNTPInstance =
|
|
68
|
-
var
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
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"]
|
|
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);
|
|
118
85
|
});
|
|
86
|
+
}
|
|
119
87
|
|
|
120
|
-
|
|
121
|
-
|
|
88
|
+
startTime = ValidateDate(startTime);
|
|
89
|
+
endTime = ValidateDate(endTime);
|
|
90
|
+
paramsJSON = ["ntp:".concat(parseInt(maxRedemptions)), "sen:".concat(parseInt(ticketLength))];
|
|
122
91
|
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
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();
|
|
127
123
|
}
|
|
128
|
-
}
|
|
129
|
-
})
|
|
130
|
-
|
|
131
|
-
return function (_x) {
|
|
132
|
-
return _ref2.apply(this, arguments);
|
|
133
|
-
};
|
|
134
|
-
}();
|
|
124
|
+
}
|
|
125
|
+
}, null, this);
|
|
126
|
+
};
|
|
135
127
|
/**
|
|
136
128
|
* Update the attributes of the specified NTP instance. Only the specified attributes will be updated ; others will be unchanged.
|
|
137
129
|
*
|
|
@@ -148,62 +140,56 @@ exports.CreateNTPInstance = /*#__PURE__*/function () {
|
|
|
148
140
|
*/
|
|
149
141
|
|
|
150
142
|
|
|
151
|
-
exports.UpdateNTPInstance =
|
|
152
|
-
var
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
return _context2.stop();
|
|
198
|
-
}
|
|
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();
|
|
199
189
|
}
|
|
200
|
-
}
|
|
201
|
-
})
|
|
202
|
-
|
|
203
|
-
return function (_x2) {
|
|
204
|
-
return _ref4.apply(this, arguments);
|
|
205
|
-
};
|
|
206
|
-
}();
|
|
190
|
+
}
|
|
191
|
+
}, null, this);
|
|
192
|
+
};
|
|
207
193
|
/**
|
|
208
194
|
* Suspend the specified NTP instance. All tickets issued for this instance will be considered expired.
|
|
209
195
|
*
|
|
@@ -216,36 +202,30 @@ exports.UpdateNTPInstance = /*#__PURE__*/function () {
|
|
|
216
202
|
*/
|
|
217
203
|
|
|
218
204
|
|
|
219
|
-
exports.SuspendNTPInstance =
|
|
220
|
-
var
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return _context3.stop();
|
|
240
|
-
}
|
|
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();
|
|
241
225
|
}
|
|
242
|
-
}
|
|
243
|
-
})
|
|
244
|
-
|
|
245
|
-
return function (_x3) {
|
|
246
|
-
return _ref6.apply(this, arguments);
|
|
247
|
-
};
|
|
248
|
-
}();
|
|
226
|
+
}
|
|
227
|
+
}, null, this);
|
|
228
|
+
};
|
|
249
229
|
/**
|
|
250
230
|
* Delete the specified NTP instance. This action cannot be undone.
|
|
251
231
|
*
|
|
@@ -256,36 +236,30 @@ exports.SuspendNTPInstance = /*#__PURE__*/function () {
|
|
|
256
236
|
*/
|
|
257
237
|
|
|
258
238
|
|
|
259
|
-
exports.DeleteNTPInstance =
|
|
260
|
-
var
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
return _context4.stop();
|
|
280
|
-
}
|
|
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();
|
|
281
259
|
}
|
|
282
|
-
}
|
|
283
|
-
})
|
|
284
|
-
|
|
285
|
-
return function (_x4) {
|
|
286
|
-
return _ref8.apply(this, arguments);
|
|
287
|
-
};
|
|
288
|
-
}();
|
|
260
|
+
}
|
|
261
|
+
}, null, this);
|
|
262
|
+
};
|
|
289
263
|
/**
|
|
290
264
|
* Retrieve info for NTP instances in the specified tenant
|
|
291
265
|
*
|
|
@@ -299,48 +273,42 @@ exports.DeleteNTPInstance = /*#__PURE__*/function () {
|
|
|
299
273
|
*/
|
|
300
274
|
|
|
301
275
|
|
|
302
|
-
exports.ListNTPInstances =
|
|
303
|
-
var
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
return _context5.stop();
|
|
335
|
-
}
|
|
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();
|
|
336
308
|
}
|
|
337
|
-
}
|
|
338
|
-
})
|
|
339
|
-
|
|
340
|
-
return function (_x5) {
|
|
341
|
-
return _ref10.apply(this, arguments);
|
|
342
|
-
};
|
|
343
|
-
}();
|
|
309
|
+
}
|
|
310
|
+
}, null, this);
|
|
311
|
+
};
|
|
344
312
|
/**
|
|
345
313
|
* Retrieve a info about the specified NTP instance
|
|
346
314
|
*
|
|
@@ -353,42 +321,36 @@ exports.ListNTPInstances = /*#__PURE__*/function () {
|
|
|
353
321
|
*/
|
|
354
322
|
|
|
355
323
|
|
|
356
|
-
exports.NTPInstance =
|
|
357
|
-
var
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
return _context6.stop();
|
|
383
|
-
}
|
|
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();
|
|
384
350
|
}
|
|
385
|
-
}
|
|
386
|
-
})
|
|
387
|
-
|
|
388
|
-
return function (_x6) {
|
|
389
|
-
return _ref12.apply(this, arguments);
|
|
390
|
-
};
|
|
391
|
-
}();
|
|
351
|
+
}
|
|
352
|
+
}, null, this);
|
|
353
|
+
};
|
|
392
354
|
/**
|
|
393
355
|
* Issue a ticket from the specified NTP ID
|
|
394
356
|
*
|
|
@@ -407,50 +369,44 @@ exports.NTPInstance = /*#__PURE__*/function () {
|
|
|
407
369
|
*/
|
|
408
370
|
|
|
409
371
|
|
|
410
|
-
exports.IssueNTPCode =
|
|
411
|
-
var
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
return _context7.stop();
|
|
445
|
-
}
|
|
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();
|
|
446
406
|
}
|
|
447
|
-
}
|
|
448
|
-
})
|
|
449
|
-
|
|
450
|
-
return function (_x7) {
|
|
451
|
-
return _ref14.apply(this, arguments);
|
|
452
|
-
};
|
|
453
|
-
}();
|
|
407
|
+
}
|
|
408
|
+
}, null, this);
|
|
409
|
+
};
|
|
454
410
|
/**
|
|
455
411
|
* Identical to IssueNTPCode, but the token is also signed by the current user.
|
|
456
412
|
*
|
|
@@ -469,53 +425,47 @@ exports.IssueNTPCode = /*#__PURE__*/function () {
|
|
|
469
425
|
*/
|
|
470
426
|
|
|
471
427
|
|
|
472
|
-
exports.IssueSignedNTPCode =
|
|
473
|
-
var
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
}
|
|
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
|
+
}
|
|
495
450
|
|
|
496
|
-
|
|
497
|
-
|
|
451
|
+
_context8.next = 7;
|
|
452
|
+
return _regeneratorRuntime.awrap(this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(result.token))));
|
|
498
453
|
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
454
|
+
case 7:
|
|
455
|
+
signature = _context8.sent;
|
|
456
|
+
multiSig = this.utils.FormatSignature(signature);
|
|
457
|
+
result.token = "".concat(result.token, ".").concat(this.utils.B64(multiSig));
|
|
503
458
|
|
|
504
|
-
|
|
505
|
-
|
|
459
|
+
case 10:
|
|
460
|
+
return _context8.abrupt("return", result);
|
|
506
461
|
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
}
|
|
462
|
+
case 11:
|
|
463
|
+
case "end":
|
|
464
|
+
return _context8.stop();
|
|
511
465
|
}
|
|
512
|
-
}
|
|
513
|
-
})
|
|
514
|
-
|
|
515
|
-
return function (_x8) {
|
|
516
|
-
return _ref16.apply(this, arguments);
|
|
517
|
-
};
|
|
518
|
-
}();
|
|
466
|
+
}
|
|
467
|
+
}, null, this);
|
|
468
|
+
};
|
|
519
469
|
/**
|
|
520
470
|
* Redeem the specified ticket/code to authorize the client. Must provide either issuer or tenantId and ntpId
|
|
521
471
|
*
|
|
@@ -532,149 +482,143 @@ exports.IssueSignedNTPCode = /*#__PURE__*/function () {
|
|
|
532
482
|
*/
|
|
533
483
|
|
|
534
484
|
|
|
535
|
-
exports.RedeemCode =
|
|
536
|
-
var
|
|
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;
|
|
563
|
-
|
|
564
|
-
case 8:
|
|
565
|
-
if (!(issuer && !issuer.replace(/^\//, "").startsWith("otp/ntp/iten"))) {
|
|
566
|
-
_context9.next = 12;
|
|
567
|
-
break;
|
|
568
|
-
}
|
|
569
|
-
|
|
570
|
-
throw Error("Invalid issuer: " + issuer);
|
|
571
|
-
|
|
572
|
-
case 12:
|
|
573
|
-
// Ticket API
|
|
574
|
-
ValidatePresence("issuer or tenantId", issuer || tenantId);
|
|
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;
|
|
575
487
|
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
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 || "";
|
|
579
495
|
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
email: email
|
|
586
|
-
});
|
|
587
|
-
|
|
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
|
-
});
|
|
613
|
-
|
|
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
|
-
});
|
|
633
|
-
|
|
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
|
|
496
|
+
if (!this.signer) {
|
|
497
|
+
this.SetSigner({
|
|
498
|
+
signer: wallet.AddAccountFromMnemonic({
|
|
499
|
+
mnemonic: wallet.GenerateMnemonic()
|
|
500
|
+
})
|
|
651
501
|
});
|
|
502
|
+
}
|
|
652
503
|
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
}); // Ensure wallet is initialized
|
|
504
|
+
if (!issuer.startsWith("iq__")) {
|
|
505
|
+
_context9.next = 8;
|
|
506
|
+
break;
|
|
507
|
+
}
|
|
658
508
|
|
|
659
|
-
|
|
660
|
-
|
|
509
|
+
ValidateObject(issuer);
|
|
510
|
+
_context9.next = 28;
|
|
511
|
+
break;
|
|
661
512
|
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
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);
|
|
667
569
|
});
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
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();
|
|
673
621
|
}
|
|
674
|
-
}
|
|
675
|
-
})
|
|
676
|
-
|
|
677
|
-
return function (_x9) {
|
|
678
|
-
return _ref18.apply(this, arguments);
|
|
679
|
-
};
|
|
680
|
-
}();
|
|
622
|
+
}
|
|
623
|
+
}, null, this, [[14, 23]]);
|
|
624
|
+
};
|