@eluvio/elv-client-js 4.0.11 → 4.0.13

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 (111) hide show
  1. package/dist/.keep +0 -0
  2. package/dist/ElvClient-min.js +11 -10
  3. package/dist/ElvClient-node-min.js +11 -10
  4. package/dist/ElvFrameClient-min.js +11 -10
  5. package/dist/ElvPermissionsClient-min.js +10 -9
  6. package/dist/ElvWalletClient-min.js +10 -9
  7. package/dist/ElvWalletClient-node-min.js +10 -9
  8. package/dist/src/AuthorizationClient.js +1555 -2076
  9. package/dist/src/ContentObjectVerification.js +134 -185
  10. package/dist/src/Crypto.js +224 -319
  11. package/dist/src/ElvClient.js +822 -1114
  12. package/dist/src/ElvWallet.js +64 -106
  13. package/dist/src/EthClient.js +719 -974
  14. package/dist/src/FrameClient.js +223 -319
  15. package/dist/src/HttpClient.js +117 -156
  16. package/dist/src/Id.js +1 -6
  17. package/dist/src/LogMessage.js +4 -8
  18. package/dist/src/PermissionsClient.js +973 -1271
  19. package/dist/src/RemoteSigner.js +161 -232
  20. package/dist/src/UserProfileClient.js +781 -1038
  21. package/dist/src/Utils.js +159 -299
  22. package/dist/src/Validation.js +2 -17
  23. package/dist/src/client/ABRPublishing.js +828 -958
  24. package/dist/src/client/AccessGroups.js +849 -1095
  25. package/dist/src/client/ContentAccess.js +3323 -4195
  26. package/dist/src/client/ContentManagement.js +1818 -2290
  27. package/dist/src/client/Contracts.js +468 -614
  28. package/dist/src/client/Files.js +1506 -1846
  29. package/dist/src/client/NFT.js +94 -116
  30. package/dist/src/client/NTP.js +326 -425
  31. package/dist/src/index.js +2 -5
  32. package/dist/src/walletClient/ClientMethods.js +1368 -1763
  33. package/dist/src/walletClient/Configuration.js +5 -3
  34. package/dist/src/walletClient/Notifications.js +98 -127
  35. package/dist/src/walletClient/Profile.js +184 -246
  36. package/dist/src/walletClient/Utils.js +76 -122
  37. package/dist/src/walletClient/index.js +1171 -1496
  38. package/package.json +4 -21
  39. package/src/FrameClient.js +1 -0
  40. package/src/HttpClient.js +4 -2
  41. package/src/client/ABRPublishing.js +126 -105
  42. package/src/client/ContentAccess.js +1 -0
  43. package/src/client/ContentManagement.js +4 -2
  44. package/src/walletClient/Configuration.js +3 -2
  45. package/dist/AccessClient-min.js +0 -54
  46. package/dist/AccessClient-node-min.js +0 -74
  47. package/dist/src/AccessClient.js +0 -798
  48. package/dist/src/LimitedMap.js +0 -120
  49. package/dist/src/client/Access.js +0 -1
  50. package/dist/src/client/Management.js +0 -1606
  51. package/dist/src/contracts/AccessIndexor.js +0 -831
  52. package/dist/src/contracts/Accessible.js +0 -31
  53. package/dist/src/contracts/AdmgrAdvertisement.js +0 -695
  54. package/dist/src/contracts/AdmgrCampaign.js +0 -648
  55. package/dist/src/contracts/AdmgrCampaignManager.js +0 -493
  56. package/dist/src/contracts/AdmgrCommercialOffering.js +0 -622
  57. package/dist/src/contracts/AdmgrCommercialOfferingManager.js +0 -413
  58. package/dist/src/contracts/AdmgrMarketPlace.js +0 -413
  59. package/dist/src/contracts/AvailsDelivery.js +0 -535
  60. package/dist/src/contracts/BaseAccessControlGroup.js +0 -1221
  61. package/dist/src/contracts/BaseAccessWallet.js +0 -1575
  62. package/dist/src/contracts/BaseAccessWalletFactory.js +0 -93
  63. package/dist/src/contracts/BaseContent.js +0 -1104
  64. package/dist/src/contracts/BaseContentFactory.js +0 -99
  65. package/dist/src/contracts/BaseContentFactoryExt.js +0 -219
  66. package/dist/src/contracts/BaseContentSpace.js +0 -1346
  67. package/dist/src/contracts/BaseContentType.js +0 -353
  68. package/dist/src/contracts/BaseFactory.js +0 -107
  69. package/dist/src/contracts/BaseGroupFactory.js +0 -93
  70. package/dist/src/contracts/BaseLibrary.js +0 -1035
  71. package/dist/src/contracts/BaseLibraryFactory.js +0 -96
  72. package/dist/src/contracts/Certifyer.js +0 -87
  73. package/dist/src/contracts/Container.js +0 -543
  74. package/dist/src/contracts/Content.js +0 -432
  75. package/dist/src/contracts/Editable.js +0 -295
  76. package/dist/src/contracts/FactorySpace.js +0 -57
  77. package/dist/src/contracts/KmsSpace.js +0 -52
  78. package/dist/src/contracts/LvProvider.js +0 -512
  79. package/dist/src/contracts/LvRecordableStream.js +0 -1026
  80. package/dist/src/contracts/LvRecording.js +0 -627
  81. package/dist/src/contracts/LvStreamRightsHolder.js +0 -551
  82. package/dist/src/contracts/MetaObject.js +0 -110
  83. package/dist/src/contracts/Node.js +0 -167
  84. package/dist/src/contracts/NodeSpace.js +0 -18
  85. package/dist/src/contracts/NodeSpaceImpl.js +0 -273
  86. package/dist/src/contracts/Ownable.js +0 -87
  87. package/dist/src/contracts/PaymentService.js +0 -616
  88. package/dist/src/contracts/Precompile.js +0 -15
  89. package/dist/src/contracts/SampleContentAdMarketplace.js +0 -564
  90. package/dist/src/contracts/SampleContentAdvertising.js +0 -444
  91. package/dist/src/contracts/SampleContentHelloWorld.js +0 -459
  92. package/dist/src/contracts/SampleContentLicensing.js +0 -618
  93. package/dist/src/contracts/SampleContentSigned.js +0 -447
  94. package/dist/src/contracts/SampleInstance.js +0 -438
  95. package/dist/src/contracts/SampleInstanceFactory.js +0 -451
  96. package/dist/src/contracts/Transactable.js +0 -82
  97. package/dist/src/contracts/UserSpace.js +0 -18
  98. package/dist/src/contracts/UserSpaceImpl.js +0 -43
  99. package/dist/src/contracts/Utils.js +0 -18
  100. package/dist/src/contracts/Verifier.js +0 -53
  101. package/dist/src/contracts/strings.js +0 -4
  102. package/dist/src/contracts/v2/BaseContentFactoryExt.js +0 -219
  103. package/dist/src/contracts/v2/FactorySpace.js +0 -57
  104. package/dist/src/contracts/v2/KmsSpace.js +0 -52
  105. package/dist/src/contracts/v2/NodeSpaceImpl.js +0 -273
  106. package/dist/src/contracts/v2/UserSpaceImpl.js +0 -43
  107. package/dist/src/marketplaceClient/ClientMethods.js +0 -1918
  108. package/dist/src/marketplaceClient/Configuration.js +0 -29
  109. package/dist/src/marketplaceClient/Utils.js +0 -304
  110. package/dist/src/marketplaceClient/index.js +0 -1553
  111. package/utilities/ListAccessGroups.js +0 -34
@@ -1,22 +1,18 @@
1
1
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
-
3
2
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
4
-
5
3
  /**
6
4
  * Methods for creating and managing NTP instances and tickets
7
5
  *
8
6
  * @module ElvClient/NTP
9
7
  */
10
- var UrlJoin = require("url-join");
11
8
 
9
+ var UrlJoin = require("url-join");
12
10
  var Ethers = require("ethers");
13
-
14
11
  var _require = require("../Validation"),
15
- ValidateAddress = _require.ValidateAddress,
16
- ValidateDate = _require.ValidateDate,
17
- ValidateObject = _require.ValidateObject,
18
- ValidatePresence = _require.ValidatePresence;
19
-
12
+ ValidateAddress = _require.ValidateAddress,
13
+ ValidateDate = _require.ValidateDate,
14
+ ValidateObject = _require.ValidateObject,
15
+ ValidatePresence = _require.ValidatePresence;
20
16
  var FormatNTPInfo = function FormatNTPInfo(info) {
21
17
  var params = info.pm || {};
22
18
  var response = {
@@ -32,13 +28,12 @@ var FormatNTPInfo = function FormatNTPInfo(info) {
32
28
  maxRedemptions: params.ntp,
33
29
  maxTickets: info.mx
34
30
  };
35
-
36
31
  if (typeof info.cnt !== "undefined") {
37
32
  response.issuedTickets = info.cnt;
38
33
  }
39
-
40
34
  return response;
41
35
  };
36
+
42
37
  /**
43
38
  * Issue an n-time-password (NTP) instance. This instance contains a specification for the tickets (AKA codes) to be issued, including
44
39
  * the target(s) to be authorized, how many tickets can be issued, and when and how many times tickets can be redeemed.
@@ -62,76 +57,61 @@ var FormatNTPInfo = function FormatNTPInfo(info) {
62
57
  *
63
58
  * @return {Promise<string>} - The ID of the NTP instance. This ID can be used when issuing tickets (See IssueNTPCode)
64
59
  */
65
-
66
-
67
60
  exports.CreateNTPInstance = /*#__PURE__*/function () {
68
61
  var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
69
62
  var _this = this;
70
-
71
63
  var tenantId, objectId, groupAddresses, _ref$ntpClass, ntpClass, _ref$maxTickets, maxTickets, _ref$maxRedemptions, maxRedemptions, startTime, endTime, _ref$ticketLength, ticketLength, paramsJSON, groupIds;
72
-
73
64
  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"]
65
+ while (1) switch (_context.prev = _context.next) {
66
+ case 0:
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;
68
+ ValidatePresence("tenantId", tenantId);
69
+ ValidatePresence("objectId or groupAddresses", objectId || groupAddresses);
70
+ if (objectId) {
71
+ ValidateObject(objectId);
72
+ }
73
+ if (groupAddresses) {
74
+ groupAddresses.forEach(function (address) {
75
+ return ValidateAddress(address);
118
76
  });
119
-
120
- case 13:
121
- return _context.abrupt("return", _context.sent);
122
-
123
- case 14:
124
- case "end":
125
- return _context.stop();
126
- }
77
+ }
78
+ startTime = ValidateDate(startTime);
79
+ endTime = ValidateDate(endTime);
80
+ paramsJSON = ["ntp:".concat(parseInt(maxRedemptions)), "sen:".concat(parseInt(ticketLength))];
81
+ if (objectId) {
82
+ paramsJSON.push("qid:".concat(objectId));
83
+ } else if (groupAddresses) {
84
+ groupIds = groupAddresses.map(function (address) {
85
+ return "igrp".concat(_this.utils.AddressToHash(address));
86
+ });
87
+ paramsJSON.push("gid:".concat(groupIds.join(",")));
88
+ }
89
+ if (startTime) {
90
+ paramsJSON.push("vat:".concat(startTime));
91
+ }
92
+ if (endTime) {
93
+ paramsJSON.push("exp:".concat(endTime));
94
+ }
95
+ _context.next = 13;
96
+ return this.authClient.MakeKMSCall({
97
+ tenantId: tenantId,
98
+ methodName: "elv_createOTPInstance",
99
+ params: [tenantId, ntpClass, JSON.stringify(paramsJSON), parseInt(maxTickets), Date.now()],
100
+ paramTypes: ["string", "int", "string", "int", "int"]
101
+ });
102
+ case 13:
103
+ return _context.abrupt("return", _context.sent);
104
+ case 14:
105
+ case "end":
106
+ return _context.stop();
127
107
  }
128
108
  }, _callee, this);
129
109
  }));
130
-
131
110
  return function (_x) {
132
111
  return _ref2.apply(this, arguments);
133
112
  };
134
113
  }();
114
+
135
115
  /**
136
116
  * Update the attributes of the specified NTP instance. Only the specified attributes will be updated ; others will be unchanged.
137
117
  *
@@ -146,64 +126,52 @@ exports.CreateNTPInstance = /*#__PURE__*/function () {
146
126
  *
147
127
  * @return {Object} - Info about the NTP Instance
148
128
  */
149
-
150
-
151
129
  exports.UpdateNTPInstance = /*#__PURE__*/function () {
152
130
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref3) {
153
131
  var tenantId, ntpId, _ref3$maxTickets, maxTickets, _ref3$maxRedemptions, maxRedemptions, startTime, endTime, paramsJSON, _yield$this$authClien, Ret;
154
-
155
132
  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
- }
133
+ while (1) switch (_context2.prev = _context2.next) {
134
+ case 0:
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;
136
+ ValidatePresence("tenantId", tenantId);
137
+ ValidatePresence("ntpId", ntpId);
138
+ startTime = ValidateDate(startTime);
139
+ endTime = ValidateDate(endTime);
140
+ paramsJSON = [];
141
+ if (maxRedemptions) {
142
+ paramsJSON.push("ntp:".concat(parseInt(maxRedemptions)));
143
+ }
144
+ if (startTime) {
145
+ paramsJSON.push("vat:".concat(startTime));
146
+ }
147
+ if (endTime) {
148
+ paramsJSON.push("exp:".concat(endTime));
149
+ }
150
+ if (maxTickets) {
151
+ paramsJSON.push("max:".concat(parseInt(maxTickets)));
152
+ }
153
+ _context2.next = 12;
154
+ return this.authClient.MakeKMSCall({
155
+ tenantId: tenantId,
156
+ methodName: "elv_updateOTPInstance",
157
+ params: [tenantId, ntpId, "update", JSON.stringify(paramsJSON), Date.now()],
158
+ paramTypes: ["string", "string", "string", "string", "int"]
159
+ });
160
+ case 12:
161
+ _yield$this$authClien = _context2.sent;
162
+ Ret = _yield$this$authClien.Ret;
163
+ return _context2.abrupt("return", FormatNTPInfo(JSON.parse(Ret)));
164
+ case 15:
165
+ case "end":
166
+ return _context2.stop();
199
167
  }
200
168
  }, _callee2, this);
201
169
  }));
202
-
203
170
  return function (_x2) {
204
171
  return _ref4.apply(this, arguments);
205
172
  };
206
173
  }();
174
+
207
175
  /**
208
176
  * Suspend the specified NTP instance. All tickets issued for this instance will be considered expired.
209
177
  *
@@ -214,38 +182,33 @@ exports.UpdateNTPInstance = /*#__PURE__*/function () {
214
182
  * @param {string} tenantId - The ID of the tenant in which this NTP instance was created
215
183
  * @param {string} ntpId - The ID of the NTP instance
216
184
  */
217
-
218
-
219
185
  exports.SuspendNTPInstance = /*#__PURE__*/function () {
220
186
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref5) {
221
187
  var tenantId, ntpId;
222
188
  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
- }
189
+ while (1) switch (_context3.prev = _context3.next) {
190
+ case 0:
191
+ tenantId = _ref5.tenantId, ntpId = _ref5.ntpId;
192
+ ValidatePresence("tenantId", tenantId);
193
+ ValidatePresence("ntpId", ntpId);
194
+ _context3.next = 5;
195
+ return this.authClient.MakeKMSCall({
196
+ tenantId: tenantId,
197
+ methodName: "elv_updateOTPInstance",
198
+ params: [tenantId, ntpId, "cancel", "[]", Date.now()],
199
+ paramTypes: ["string", "string", "string", "string", "int"]
200
+ });
201
+ case 5:
202
+ case "end":
203
+ return _context3.stop();
241
204
  }
242
205
  }, _callee3, this);
243
206
  }));
244
-
245
207
  return function (_x3) {
246
208
  return _ref6.apply(this, arguments);
247
209
  };
248
210
  }();
211
+
249
212
  /**
250
213
  * Delete the specified NTP instance. This action cannot be undone.
251
214
  *
@@ -254,38 +217,33 @@ exports.SuspendNTPInstance = /*#__PURE__*/function () {
254
217
  * @param {string} tenantId - The ID of the tenant in which this NTP instance was created
255
218
  * @param {string} ntpId - The ID of the NTP instance
256
219
  */
257
-
258
-
259
220
  exports.DeleteNTPInstance = /*#__PURE__*/function () {
260
221
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref7) {
261
222
  var tenantId, ntpId;
262
223
  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
- }
224
+ while (1) switch (_context4.prev = _context4.next) {
225
+ case 0:
226
+ tenantId = _ref7.tenantId, ntpId = _ref7.ntpId;
227
+ ValidatePresence("tenantId", tenantId);
228
+ ValidatePresence("ntpId", ntpId);
229
+ _context4.next = 5;
230
+ return this.authClient.MakeKMSCall({
231
+ tenantId: tenantId,
232
+ methodName: "elv_updateOTPInstance",
233
+ params: [tenantId, ntpId, "delete", "[]", Date.now()],
234
+ paramTypes: ["string", "string", "string", "string", "int"]
235
+ });
236
+ case 5:
237
+ case "end":
238
+ return _context4.stop();
281
239
  }
282
240
  }, _callee4, this);
283
241
  }));
284
-
285
242
  return function (_x4) {
286
243
  return _ref8.apply(this, arguments);
287
244
  };
288
245
  }();
246
+
289
247
  /**
290
248
  * Retrieve info for NTP instances in the specified tenant
291
249
  *
@@ -297,50 +255,43 @@ exports.DeleteNTPInstance = /*#__PURE__*/function () {
297
255
  *
298
256
  * @return {Object} - List of NTP instances along with pagination information
299
257
  */
300
-
301
-
302
258
  exports.ListNTPInstances = /*#__PURE__*/function () {
303
259
  var _ref10 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref9) {
304
260
  var tenantId, _ref9$count, count, _ref9$offset, offset, _yield$this$authClien2, Defs, Total;
305
-
306
261
  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
- }
262
+ while (1) switch (_context5.prev = _context5.next) {
263
+ case 0:
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
+ ValidatePresence("tenantId", tenantId);
266
+ _context5.next = 4;
267
+ return this.authClient.MakeKMSCall({
268
+ tenantId: tenantId,
269
+ methodName: "elv_listOTPInfo",
270
+ params: [tenantId, offset, count],
271
+ paramTypes: ["string", "int", "int"],
272
+ signature: false
273
+ });
274
+ case 4:
275
+ _yield$this$authClien2 = _context5.sent;
276
+ Defs = _yield$this$authClien2.Defs;
277
+ Total = _yield$this$authClien2.Total;
278
+ return _context5.abrupt("return", {
279
+ ntpInstances: Object.values(Defs || {}).map(FormatNTPInfo),
280
+ start: offset,
281
+ end: Math.min(Total, offset + count),
282
+ total: Total
283
+ });
284
+ case 8:
285
+ case "end":
286
+ return _context5.stop();
336
287
  }
337
288
  }, _callee5, this);
338
289
  }));
339
-
340
290
  return function (_x5) {
341
291
  return _ref10.apply(this, arguments);
342
292
  };
343
293
  }();
294
+
344
295
  /**
345
296
  * Retrieve a info about the specified NTP instance
346
297
  *
@@ -351,44 +302,38 @@ exports.ListNTPInstances = /*#__PURE__*/function () {
351
302
  *
352
303
  * @return {Object} - Info about the NTP instance
353
304
  */
354
-
355
-
356
305
  exports.NTPInstance = /*#__PURE__*/function () {
357
306
  var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref11) {
358
307
  var tenantId, ntpId;
359
308
  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
- }
309
+ while (1) switch (_context6.prev = _context6.next) {
310
+ case 0:
311
+ tenantId = _ref11.tenantId, ntpId = _ref11.ntpId;
312
+ ValidatePresence("tenantId", tenantId);
313
+ ValidatePresence("ntpId", ntpId);
314
+ _context6.t0 = FormatNTPInfo;
315
+ _context6.next = 6;
316
+ return this.authClient.MakeKMSCall({
317
+ tenantId: tenantId,
318
+ methodName: "elv_getOTPInfo",
319
+ params: [tenantId, ntpId],
320
+ paramTypes: ["string", "string"],
321
+ signature: false
322
+ });
323
+ case 6:
324
+ _context6.t1 = _context6.sent;
325
+ return _context6.abrupt("return", (0, _context6.t0)(_context6.t1));
326
+ case 8:
327
+ case "end":
328
+ return _context6.stop();
384
329
  }
385
330
  }, _callee6, this);
386
331
  }));
387
-
388
332
  return function (_x6) {
389
333
  return _ref12.apply(this, arguments);
390
334
  };
391
335
  }();
336
+
392
337
  /**
393
338
  * Issue a ticket from the specified NTP ID
394
339
  *
@@ -405,52 +350,43 @@ exports.NTPInstance = /*#__PURE__*/function () {
405
350
  *
406
351
  * @return {Promise<Object>} - The generated ticket code and additional information about the ticket.
407
352
  */
408
-
409
-
410
353
  exports.IssueNTPCode = /*#__PURE__*/function () {
411
354
  var _ref14 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref13) {
412
355
  var tenantId, ntpId, email, maxRedemptions, options, params, paramTypes;
413
356
  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
- }
357
+ while (1) switch (_context7.prev = _context7.next) {
358
+ case 0:
359
+ tenantId = _ref13.tenantId, ntpId = _ref13.ntpId, email = _ref13.email, maxRedemptions = _ref13.maxRedemptions;
360
+ ValidatePresence("tenantId", tenantId);
361
+ ValidatePresence("ntpId", ntpId);
362
+ options = [];
363
+ if (email) {
364
+ options.push("eml:".concat(email));
365
+ }
366
+ if (maxRedemptions) {
367
+ options.push("cnt:".concat(parseInt(maxRedemptions)));
368
+ }
369
+ params = [tenantId, ntpId, JSON.stringify(options), Date.now()];
370
+ paramTypes = ["string", "string", "string", "uint"];
371
+ _context7.next = 10;
372
+ return this.authClient.MakeKMSCall({
373
+ methodName: "elv_issueOTPCode",
374
+ params: params,
375
+ paramTypes: paramTypes
376
+ });
377
+ case 10:
378
+ return _context7.abrupt("return", _context7.sent);
379
+ case 11:
380
+ case "end":
381
+ return _context7.stop();
446
382
  }
447
383
  }, _callee7, this);
448
384
  }));
449
-
450
385
  return function (_x7) {
451
386
  return _ref14.apply(this, arguments);
452
387
  };
453
388
  }();
389
+
454
390
  /**
455
391
  * Identical to IssueNTPCode, but the token is also signed by the current user.
456
392
  *
@@ -467,55 +403,45 @@ exports.IssueNTPCode = /*#__PURE__*/function () {
467
403
  *
468
404
  * @return {Promise<Object>} - The generated signed ticket code and additional information about the ticket.
469
405
  */
470
-
471
-
472
406
  exports.IssueSignedNTPCode = /*#__PURE__*/function () {
473
407
  var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref15) {
474
408
  var tenantId, ntpId, email, maxRedemptions, result, signature, multiSig;
475
409
  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
- });
487
-
488
- case 3:
489
- result = _context8.sent;
490
-
491
- if (!result.token) {
492
- _context8.next = 10;
493
- break;
494
- }
495
-
496
- _context8.next = 7;
497
- return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(result.token)));
498
-
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
- }
410
+ while (1) switch (_context8.prev = _context8.next) {
411
+ case 0:
412
+ tenantId = _ref15.tenantId, ntpId = _ref15.ntpId, email = _ref15.email, maxRedemptions = _ref15.maxRedemptions;
413
+ _context8.next = 3;
414
+ return this.IssueNTPCode({
415
+ tenantId: tenantId,
416
+ ntpId: ntpId,
417
+ email: email,
418
+ maxRedemptions: maxRedemptions
419
+ });
420
+ case 3:
421
+ result = _context8.sent;
422
+ if (!result.token) {
423
+ _context8.next = 10;
424
+ break;
425
+ }
426
+ _context8.next = 7;
427
+ return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(result.token)));
428
+ case 7:
429
+ signature = _context8.sent;
430
+ multiSig = this.utils.FormatSignature(signature);
431
+ result.token = "".concat(result.token, ".").concat(this.utils.B64(multiSig));
432
+ case 10:
433
+ return _context8.abrupt("return", result);
434
+ case 11:
435
+ case "end":
436
+ return _context8.stop();
511
437
  }
512
438
  }, _callee8, this);
513
439
  }));
514
-
515
440
  return function (_x8) {
516
441
  return _ref16.apply(this, arguments);
517
442
  };
518
443
  }();
444
+
519
445
  /**
520
446
  * Redeem the specified ticket/code to authorize the client. Must provide either issuer or tenantId and ntpId
521
447
  *
@@ -530,150 +456,125 @@ exports.IssueSignedNTPCode = /*#__PURE__*/function () {
530
456
  *
531
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
532
458
  */
533
-
534
-
535
459
  exports.RedeemCode = /*#__PURE__*/function () {
536
460
  var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref17) {
537
461
  var issuer, tenantId, ntpId, code, email, _ref17$includeNTPId, includeNTPId, wallet, token, response, objectId, libraryId, Hash, codeHash, codeInfo, ak, sites, info, signer;
538
-
539
462
  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);
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
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
651
- });
652
-
653
- case 43:
654
- signer = _context9.sent;
463
+ while (1) switch (_context9.prev = _context9.next) {
464
+ case 0:
465
+ 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;
466
+ wallet = this.GenerateWallet();
467
+ issuer = issuer || "";
468
+ if (!this.signer) {
655
469
  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 || {}
470
+ signer: wallet.AddAccountFromMnemonic({
471
+ mnemonic: wallet.GenerateMnemonic()
472
+ })
667
473
  });
668
-
669
- case 48:
670
- case "end":
671
- return _context9.stop();
672
- }
474
+ }
475
+ if (!issuer.startsWith("iq__")) {
476
+ _context9.next = 8;
477
+ break;
478
+ }
479
+ ValidateObject(issuer);
480
+ _context9.next = 28;
481
+ break;
482
+ case 8:
483
+ if (!(issuer && !issuer.replace(/^\//, "").startsWith("otp/ntp/iten"))) {
484
+ _context9.next = 12;
485
+ break;
486
+ }
487
+ throw Error("Invalid issuer: " + issuer);
488
+ case 12:
489
+ // Ticket API
490
+
491
+ ValidatePresence("issuer or tenantId", issuer || tenantId);
492
+ if (!issuer) {
493
+ issuer = UrlJoin("/otp", "ntp", tenantId, ntpId || "");
494
+ }
495
+ _context9.prev = 14;
496
+ _context9.next = 17;
497
+ return this.authClient.GenerateChannelContentToken({
498
+ issuer: issuer,
499
+ code: code,
500
+ email: email
501
+ });
502
+ case 17:
503
+ token = _context9.sent;
504
+ this.SetStaticToken({
505
+ token: token
506
+ });
507
+ response = JSON.parse(this.utils.FromB64(token));
508
+ return _context9.abrupt("return", includeNTPId ? {
509
+ objectId: response.qid,
510
+ ntpId: response.oid
511
+ } : response.qid);
512
+ case 23:
513
+ _context9.prev = 23;
514
+ _context9.t0 = _context9["catch"](14);
515
+ this.Log("Failed to redeem code:", true);
516
+ this.Log(_context9.t0, true);
517
+ throw _context9.t0;
518
+ case 28:
519
+ // Site selector
520
+ objectId = issuer;
521
+ _context9.next = 31;
522
+ return this.ContentObjectLibraryId({
523
+ objectId: objectId
524
+ });
525
+ case 31:
526
+ libraryId = _context9.sent;
527
+ Hash = function Hash(code) {
528
+ var chars = code.split("").map(function (code) {
529
+ return code.charCodeAt(0);
530
+ });
531
+ return chars.reduce(function (sum, _char, i) {
532
+ return chars[i + 1] ? sum * 2 + _char * chars[i + 1] * (i + 1) : sum + _char;
533
+ }, 0).toString();
534
+ };
535
+ codeHash = Hash(code);
536
+ _context9.next = 36;
537
+ return this.ContentObjectMetadata({
538
+ libraryId: libraryId,
539
+ objectId: objectId,
540
+ metadataSubtree: "public/codes/".concat(codeHash)
541
+ });
542
+ case 36:
543
+ codeInfo = _context9.sent;
544
+ if (codeInfo) {
545
+ _context9.next = 40;
546
+ break;
547
+ }
548
+ this.Log("Code redemption failed:\n\t".concat(issuer, "\n\t").concat(code));
549
+ throw Error("Invalid code: " + code);
550
+ case 40:
551
+ ak = codeInfo.ak, sites = codeInfo.sites, info = codeInfo.info;
552
+ _context9.next = 43;
553
+ return wallet.AddAccountFromEncryptedPK({
554
+ encryptedPrivateKey: this.utils.FromB64(ak),
555
+ password: code
556
+ });
557
+ case 43:
558
+ signer = _context9.sent;
559
+ this.SetSigner({
560
+ signer: signer
561
+ });
562
+
563
+ // Ensure wallet is initialized
564
+ _context9.next = 47;
565
+ return this.userProfileClient.WalletAddress();
566
+ case 47:
567
+ return _context9.abrupt("return", {
568
+ addr: this.utils.FormatAddress(signer.address),
569
+ sites: sites,
570
+ info: info || {}
571
+ });
572
+ case 48:
573
+ case "end":
574
+ return _context9.stop();
673
575
  }
674
576
  }, _callee9, this, [[14, 23]]);
675
577
  }));
676
-
677
578
  return function (_x9) {
678
579
  return _ref18.apply(this, arguments);
679
580
  };