@eluvio/elv-client-js 4.0.5 → 4.0.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 (43) hide show
  1. package/dist/ElvClient-min.js +12 -11
  2. package/dist/ElvClient-node-min.js +12 -11
  3. package/dist/ElvFrameClient-min.js +12 -11
  4. package/dist/ElvPermissionsClient-min.js +10 -9
  5. package/dist/ElvWalletClient-min.js +12 -11
  6. package/dist/ElvWalletClient-node-min.js +11 -10
  7. package/dist/src/AuthorizationClient.js +1556 -2077
  8. package/dist/src/ContentObjectVerification.js +134 -185
  9. package/dist/src/Crypto.js +225 -322
  10. package/dist/src/ElvClient.js +823 -1117
  11. package/dist/src/ElvWallet.js +64 -106
  12. package/dist/src/EthClient.js +719 -974
  13. package/dist/src/FrameClient.js +222 -318
  14. package/dist/src/HttpClient.js +112 -154
  15. package/dist/src/Id.js +1 -6
  16. package/dist/src/LogMessage.js +4 -8
  17. package/dist/src/PermissionsClient.js +973 -1271
  18. package/dist/src/RemoteSigner.js +161 -232
  19. package/dist/src/UserProfileClient.js +781 -1038
  20. package/dist/src/Utils.js +160 -302
  21. package/dist/src/Validation.js +2 -17
  22. package/dist/src/client/ABRPublishing.js +772 -942
  23. package/dist/src/client/AccessGroups.js +849 -1095
  24. package/dist/src/client/ContentAccess.js +3263 -4132
  25. package/dist/src/client/ContentManagement.js +1811 -2283
  26. package/dist/src/client/Contracts.js +468 -614
  27. package/dist/src/client/Files.js +1505 -1845
  28. package/dist/src/client/NFT.js +94 -116
  29. package/dist/src/client/NTP.js +326 -425
  30. package/dist/src/index.js +2 -5
  31. package/dist/src/walletClient/ClientMethods.js +1348 -1735
  32. package/dist/src/walletClient/Configuration.js +4 -2
  33. package/dist/src/walletClient/Notifications.js +98 -127
  34. package/dist/src/walletClient/Profile.js +184 -246
  35. package/dist/src/walletClient/Utils.js +76 -122
  36. package/dist/src/walletClient/index.js +1168 -1493
  37. package/package.json +2 -2
  38. package/src/Crypto.js +1 -1
  39. package/src/ElvClient.js +1 -3
  40. package/src/Utils.js +1 -1
  41. package/testScripts/Test.js +0 -1
  42. package/utilities/NFTIngest.js +527 -0
  43. package/utilities/lib/concerns/LocalFile.js +2 -1
@@ -1,15 +1,9 @@
1
1
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
-
3
2
  var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
4
-
5
3
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
6
-
7
4
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
8
-
9
5
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
-
11
6
  function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
12
-
13
7
  /**
14
8
  * Methods for accessing and managing access groups
15
9
  *
@@ -22,189 +16,157 @@ const AccessGroupContract = require("../contracts/BaseAccessControlGroup");
22
16
  const AccessIndexorContract = require("../contracts/AccessIndexor");
23
17
 
24
18
  */
19
+
25
20
  var _require = require("../Validation"),
26
- ValidatePresence = _require.ValidatePresence,
27
- ValidateLibrary = _require.ValidateLibrary,
28
- ValidateObject = _require.ValidateObject,
29
- ValidateAddress = _require.ValidateAddress;
21
+ ValidatePresence = _require.ValidatePresence,
22
+ ValidateLibrary = _require.ValidateLibrary,
23
+ ValidateObject = _require.ValidateObject,
24
+ ValidateAddress = _require.ValidateAddress;
25
+
30
26
  /**
31
27
  * Retrieve a list of all available access groups
32
28
  *
33
29
  * @methodGroup Access Groups
34
30
  * @return {Promise<Array>} - List of access groups
35
31
  */
36
-
37
-
38
32
  exports.ListAccessGroups = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
39
33
  var _this = this;
40
-
41
34
  var addresses, groups;
42
35
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
43
- while (1) {
44
- switch (_context2.prev = _context2.next) {
45
- case 0:
46
- _context2.next = 2;
47
- return this.Collection({
48
- collectionType: "accessGroups"
49
- });
50
-
51
- case 2:
52
- addresses = _context2.sent.map(function (address) {
53
- return _this.utils.FormatAddress(address);
54
- });
55
- _context2.next = 5;
56
- return this.utils.LimitedMap(5, addresses, /*#__PURE__*/function () {
57
- var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(address) {
58
- var id, meta;
59
- return _regeneratorRuntime.wrap(function _callee$(_context) {
60
- while (1) {
61
- switch (_context.prev = _context.next) {
62
- case 0:
63
- id = _this.utils.AddressToHash(address);
64
- _context.next = 3;
65
- return _this.ContentObjectMetadata({
66
- libraryId: _this.contentSpaceLibraryId,
67
- objectId: "iq__".concat(id)
68
- });
69
-
70
- case 3:
71
- _context.t0 = _context.sent;
72
-
73
- if (_context.t0) {
74
- _context.next = 6;
75
- break;
76
- }
77
-
78
- _context.t0 = {};
79
-
80
- case 6:
81
- meta = _context.t0;
82
- return _context.abrupt("return", {
83
- address: address,
84
- id: "igrp".concat(id),
85
- meta: meta
86
- });
87
-
88
- case 8:
89
- case "end":
90
- return _context.stop();
36
+ while (1) switch (_context2.prev = _context2.next) {
37
+ case 0:
38
+ _context2.next = 2;
39
+ return this.Collection({
40
+ collectionType: "accessGroups"
41
+ });
42
+ case 2:
43
+ addresses = _context2.sent.map(function (address) {
44
+ return _this.utils.FormatAddress(address);
45
+ });
46
+ _context2.next = 5;
47
+ return this.utils.LimitedMap(5, addresses, /*#__PURE__*/function () {
48
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(address) {
49
+ var id, meta;
50
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
51
+ while (1) switch (_context.prev = _context.next) {
52
+ case 0:
53
+ id = _this.utils.AddressToHash(address);
54
+ _context.next = 3;
55
+ return _this.ContentObjectMetadata({
56
+ libraryId: _this.contentSpaceLibraryId,
57
+ objectId: "iq__".concat(id)
58
+ });
59
+ case 3:
60
+ _context.t0 = _context.sent;
61
+ if (_context.t0) {
62
+ _context.next = 6;
63
+ break;
91
64
  }
92
- }
93
- }, _callee);
94
- }));
95
-
96
- return function (_x) {
97
- return _ref2.apply(this, arguments);
98
- };
99
- }());
100
-
101
- case 5:
102
- groups = _context2.sent;
103
- return _context2.abrupt("return", groups.sort(function (a, b) {
104
- var name1 = (a.meta["public"] || {}).name || "zz__".concat(a.address);
105
- var name2 = (b.meta["public"] || {}).name || "zz__".concat(b.address);
106
- return name1 < name2 ? -1 : 1;
65
+ _context.t0 = {};
66
+ case 6:
67
+ meta = _context.t0;
68
+ return _context.abrupt("return", {
69
+ address: address,
70
+ id: "igrp".concat(id),
71
+ meta: meta
72
+ });
73
+ case 8:
74
+ case "end":
75
+ return _context.stop();
76
+ }
77
+ }, _callee);
107
78
  }));
108
-
109
- case 7:
110
- case "end":
111
- return _context2.stop();
112
- }
79
+ return function (_x) {
80
+ return _ref2.apply(this, arguments);
81
+ };
82
+ }());
83
+ case 5:
84
+ groups = _context2.sent;
85
+ return _context2.abrupt("return", groups.sort(function (a, b) {
86
+ var name1 = (a.meta["public"] || {}).name || "zz__".concat(a.address);
87
+ var name2 = (b.meta["public"] || {}).name || "zz__".concat(b.address);
88
+ return name1 < name2 ? -1 : 1;
89
+ }));
90
+ case 7:
91
+ case "end":
92
+ return _context2.stop();
113
93
  }
114
94
  }, _callee2, this);
115
95
  }));
116
-
117
96
  exports.SetGroupPermission = /*#__PURE__*/function () {
118
97
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
119
98
  var groupAddress, objectId, permission, _ref3$remove, remove, groupInfo, objectInfo, event;
120
-
121
99
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
122
- while (1) {
123
- switch (_context3.prev = _context3.next) {
124
- case 0:
125
- groupAddress = _ref3.groupAddress, objectId = _ref3.objectId, permission = _ref3.permission, _ref3$remove = _ref3.remove, remove = _ref3$remove === void 0 ? false : _ref3$remove;
126
- _context3.next = 3;
127
- return this.authClient.ContractInfo({
128
- address: groupAddress
129
- });
130
-
131
- case 3:
132
- groupInfo = _context3.sent;
133
- _context3.next = 6;
134
- return this.authClient.ContractInfo({
135
- id: objectId
136
- });
137
-
138
- case 6:
139
- objectInfo = _context3.sent;
140
-
141
- if (!(Object.keys(groupInfo).length === 0)) {
142
- _context3.next = 9;
143
- break;
144
- }
145
-
146
- throw Error("No information returned for group address ".concat(groupAddress));
147
-
148
- case 9:
149
- if (!(!objectInfo.isV3 && objectInfo.accessType === this.authClient.ACCESS_TYPES.GROUP)) {
150
- _context3.next = 17;
151
- break;
152
- }
153
-
154
- if (!groupInfo.isV3) {
155
- _context3.next = 12;
156
- break;
157
- }
158
-
159
- throw Error("Unable to map V3 group to V2 object");
160
-
161
- case 12:
162
- _context3.next = 14;
163
- return this.CallContractMethodAndWait({
164
- contractAddress: groupAddress,
165
- methodName: "setAccessGroupRights",
166
- methodArgs: [this.utils.HashToAddress(objectId), permission === "manage" ? 2 : permission === "access" ? 1 : 0, permission === "none" || remove ? 0 : 2]
167
- });
168
-
169
- case 14:
170
- event = _context3.sent;
171
- _context3.next = 20;
100
+ while (1) switch (_context3.prev = _context3.next) {
101
+ case 0:
102
+ groupAddress = _ref3.groupAddress, objectId = _ref3.objectId, permission = _ref3.permission, _ref3$remove = _ref3.remove, remove = _ref3$remove === void 0 ? false : _ref3$remove;
103
+ _context3.next = 3;
104
+ return this.authClient.ContractInfo({
105
+ address: groupAddress
106
+ });
107
+ case 3:
108
+ groupInfo = _context3.sent;
109
+ _context3.next = 6;
110
+ return this.authClient.ContractInfo({
111
+ id: objectId
112
+ });
113
+ case 6:
114
+ objectInfo = _context3.sent;
115
+ if (!(Object.keys(groupInfo).length === 0)) {
116
+ _context3.next = 9;
172
117
  break;
173
-
174
- case 17:
175
- _context3.next = 19;
176
- return this.CallContractMethodAndWait({
177
- contractAddress: this.utils.HashToAddress(objectId),
178
- methodName: "setRights",
179
- methodArgs: [groupAddress, permission === "manage" ? 2 : permission === "access" ? 1 : 0, permission === "none" || remove ? 0 : 2]
180
- });
181
-
182
- case 19:
183
- event = _context3.sent;
184
-
185
- case 20:
186
- _context3.next = 22;
187
- return this.ExtractEventFromLogs({
188
- abi: groupInfo.abi,
189
- event: event,
190
- eventName: "RightsChanged"
191
- });
192
-
193
- case 22:
194
- return _context3.abrupt("return", _context3.sent);
195
-
196
- case 23:
197
- case "end":
198
- return _context3.stop();
199
- }
118
+ }
119
+ throw Error("No information returned for group address ".concat(groupAddress));
120
+ case 9:
121
+ if (!(!objectInfo.isV3 && objectInfo.accessType === this.authClient.ACCESS_TYPES.GROUP)) {
122
+ _context3.next = 17;
123
+ break;
124
+ }
125
+ if (!groupInfo.isV3) {
126
+ _context3.next = 12;
127
+ break;
128
+ }
129
+ throw Error("Unable to map V3 group to V2 object");
130
+ case 12:
131
+ _context3.next = 14;
132
+ return this.CallContractMethodAndWait({
133
+ contractAddress: groupAddress,
134
+ methodName: "setAccessGroupRights",
135
+ methodArgs: [this.utils.HashToAddress(objectId), permission === "manage" ? 2 : permission === "access" ? 1 : 0, permission === "none" || remove ? 0 : 2]
136
+ });
137
+ case 14:
138
+ event = _context3.sent;
139
+ _context3.next = 20;
140
+ break;
141
+ case 17:
142
+ _context3.next = 19;
143
+ return this.CallContractMethodAndWait({
144
+ contractAddress: this.utils.HashToAddress(objectId),
145
+ methodName: "setRights",
146
+ methodArgs: [groupAddress, permission === "manage" ? 2 : permission === "access" ? 1 : 0, permission === "none" || remove ? 0 : 2]
147
+ });
148
+ case 19:
149
+ event = _context3.sent;
150
+ case 20:
151
+ _context3.next = 22;
152
+ return this.ExtractEventFromLogs({
153
+ abi: groupInfo.abi,
154
+ event: event,
155
+ eventName: "RightsChanged"
156
+ });
157
+ case 22:
158
+ return _context3.abrupt("return", _context3.sent);
159
+ case 23:
160
+ case "end":
161
+ return _context3.stop();
200
162
  }
201
163
  }, _callee3, this);
202
164
  }));
203
-
204
165
  return function (_x2) {
205
166
  return _ref4.apply(this, arguments);
206
167
  };
207
168
  }();
169
+
208
170
  /**
209
171
  * Returns the address of the owner of the specified content object
210
172
  *
@@ -215,38 +177,32 @@ exports.SetGroupPermission = /*#__PURE__*/function () {
215
177
  *
216
178
  * @returns {Promise<string>} - The account address of the owner
217
179
  */
218
-
219
-
220
180
  exports.AccessGroupOwner = /*#__PURE__*/function () {
221
181
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
222
182
  var contractAddress;
223
183
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
224
- while (1) {
225
- switch (_context4.prev = _context4.next) {
226
- case 0:
227
- contractAddress = _ref5.contractAddress;
228
- contractAddress = ValidateAddress(contractAddress);
229
- this.Log("Retrieving owner of access group ".concat(contractAddress));
230
- _context4.next = 5;
231
- return this.authClient.Owner({
232
- address: contractAddress
233
- });
234
-
235
- case 5:
236
- return _context4.abrupt("return", _context4.sent);
237
-
238
- case 6:
239
- case "end":
240
- return _context4.stop();
241
- }
184
+ while (1) switch (_context4.prev = _context4.next) {
185
+ case 0:
186
+ contractAddress = _ref5.contractAddress;
187
+ contractAddress = ValidateAddress(contractAddress);
188
+ this.Log("Retrieving owner of access group ".concat(contractAddress));
189
+ _context4.next = 5;
190
+ return this.authClient.Owner({
191
+ address: contractAddress
192
+ });
193
+ case 5:
194
+ return _context4.abrupt("return", _context4.sent);
195
+ case 6:
196
+ case "end":
197
+ return _context4.stop();
242
198
  }
243
199
  }, _callee4, this);
244
200
  }));
245
-
246
201
  return function (_x3) {
247
202
  return _ref6.apply(this, arguments);
248
203
  };
249
204
  }();
205
+
250
206
  /**
251
207
  * Get a list of addresses of members of the specified group
252
208
  *
@@ -257,75 +213,62 @@ exports.AccessGroupOwner = /*#__PURE__*/function () {
257
213
  *
258
214
  * @return {Promise<Array<string>>} - List of member addresses
259
215
  */
260
-
261
-
262
216
  exports.AccessGroupMembers = /*#__PURE__*/function () {
263
217
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref7) {
264
218
  var _this2 = this;
265
-
266
219
  var contractAddress, length;
267
220
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
268
- while (1) {
269
- switch (_context6.prev = _context6.next) {
270
- case 0:
271
- contractAddress = _ref7.contractAddress;
272
- contractAddress = ValidateAddress(contractAddress);
273
- this.Log("Retrieving members for group ".concat(contractAddress));
274
- _context6.next = 5;
275
- return this.CallContractMethod({
276
- contractAddress: contractAddress,
277
- methodName: "membersNum"
278
- });
279
-
280
- case 5:
281
- length = _context6.sent.toNumber();
282
- _context6.next = 8;
283
- return Promise.all(_toConsumableArray(Array(length)).map( /*#__PURE__*/function () {
284
- var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_, i) {
285
- return _regeneratorRuntime.wrap(function _callee5$(_context5) {
286
- while (1) {
287
- switch (_context5.prev = _context5.next) {
288
- case 0:
289
- _context5.t0 = _this2.utils;
290
- _context5.next = 3;
291
- return _this2.CallContractMethod({
292
- contractAddress: contractAddress,
293
- methodName: "membersList",
294
- methodArgs: [i]
295
- });
296
-
297
- case 3:
298
- _context5.t1 = _context5.sent;
299
- return _context5.abrupt("return", _context5.t0.FormatAddress.call(_context5.t0, _context5.t1));
300
-
301
- case 5:
302
- case "end":
303
- return _context5.stop();
304
- }
305
- }
306
- }, _callee5);
307
- }));
308
-
309
- return function (_x5, _x6) {
310
- return _ref9.apply(this, arguments);
311
- };
312
- }()));
313
-
314
- case 8:
315
- return _context6.abrupt("return", _context6.sent);
316
-
317
- case 9:
318
- case "end":
319
- return _context6.stop();
320
- }
221
+ while (1) switch (_context6.prev = _context6.next) {
222
+ case 0:
223
+ contractAddress = _ref7.contractAddress;
224
+ contractAddress = ValidateAddress(contractAddress);
225
+ this.Log("Retrieving members for group ".concat(contractAddress));
226
+ _context6.next = 5;
227
+ return this.CallContractMethod({
228
+ contractAddress: contractAddress,
229
+ methodName: "membersNum"
230
+ });
231
+ case 5:
232
+ length = _context6.sent.toNumber();
233
+ _context6.next = 8;
234
+ return Promise.all(_toConsumableArray(Array(length)).map( /*#__PURE__*/function () {
235
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_, i) {
236
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
237
+ while (1) switch (_context5.prev = _context5.next) {
238
+ case 0:
239
+ _context5.t0 = _this2.utils;
240
+ _context5.next = 3;
241
+ return _this2.CallContractMethod({
242
+ contractAddress: contractAddress,
243
+ methodName: "membersList",
244
+ methodArgs: [i]
245
+ });
246
+ case 3:
247
+ _context5.t1 = _context5.sent;
248
+ return _context5.abrupt("return", _context5.t0.FormatAddress.call(_context5.t0, _context5.t1));
249
+ case 5:
250
+ case "end":
251
+ return _context5.stop();
252
+ }
253
+ }, _callee5);
254
+ }));
255
+ return function (_x5, _x6) {
256
+ return _ref9.apply(this, arguments);
257
+ };
258
+ }()));
259
+ case 8:
260
+ return _context6.abrupt("return", _context6.sent);
261
+ case 9:
262
+ case "end":
263
+ return _context6.stop();
321
264
  }
322
265
  }, _callee6, this);
323
266
  }));
324
-
325
267
  return function (_x4) {
326
268
  return _ref8.apply(this, arguments);
327
269
  };
328
270
  }();
271
+
329
272
  /**
330
273
  * Get a list of addresses of managers of the specified group
331
274
  *
@@ -336,75 +279,62 @@ exports.AccessGroupMembers = /*#__PURE__*/function () {
336
279
  *
337
280
  * @return {Promise<Array<string>>} - List of manager addresses
338
281
  */
339
-
340
-
341
282
  exports.AccessGroupManagers = /*#__PURE__*/function () {
342
283
  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref10) {
343
284
  var _this3 = this;
344
-
345
285
  var contractAddress, length;
346
286
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
347
- while (1) {
348
- switch (_context8.prev = _context8.next) {
349
- case 0:
350
- contractAddress = _ref10.contractAddress;
351
- contractAddress = ValidateAddress(contractAddress);
352
- this.Log("Retrieving managers for group ".concat(contractAddress));
353
- _context8.next = 5;
354
- return this.CallContractMethod({
355
- contractAddress: contractAddress,
356
- methodName: "managersNum"
357
- });
358
-
359
- case 5:
360
- length = _context8.sent.toNumber();
361
- _context8.next = 8;
362
- return Promise.all(_toConsumableArray(Array(length)).map( /*#__PURE__*/function () {
363
- var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_, i) {
364
- return _regeneratorRuntime.wrap(function _callee7$(_context7) {
365
- while (1) {
366
- switch (_context7.prev = _context7.next) {
367
- case 0:
368
- _context7.t0 = _this3.utils;
369
- _context7.next = 3;
370
- return _this3.CallContractMethod({
371
- contractAddress: contractAddress,
372
- methodName: "managersList",
373
- methodArgs: [i]
374
- });
375
-
376
- case 3:
377
- _context7.t1 = _context7.sent;
378
- return _context7.abrupt("return", _context7.t0.FormatAddress.call(_context7.t0, _context7.t1));
379
-
380
- case 5:
381
- case "end":
382
- return _context7.stop();
383
- }
384
- }
385
- }, _callee7);
386
- }));
387
-
388
- return function (_x8, _x9) {
389
- return _ref12.apply(this, arguments);
390
- };
391
- }()));
392
-
393
- case 8:
394
- return _context8.abrupt("return", _context8.sent);
395
-
396
- case 9:
397
- case "end":
398
- return _context8.stop();
399
- }
287
+ while (1) switch (_context8.prev = _context8.next) {
288
+ case 0:
289
+ contractAddress = _ref10.contractAddress;
290
+ contractAddress = ValidateAddress(contractAddress);
291
+ this.Log("Retrieving managers for group ".concat(contractAddress));
292
+ _context8.next = 5;
293
+ return this.CallContractMethod({
294
+ contractAddress: contractAddress,
295
+ methodName: "managersNum"
296
+ });
297
+ case 5:
298
+ length = _context8.sent.toNumber();
299
+ _context8.next = 8;
300
+ return Promise.all(_toConsumableArray(Array(length)).map( /*#__PURE__*/function () {
301
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_, i) {
302
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
303
+ while (1) switch (_context7.prev = _context7.next) {
304
+ case 0:
305
+ _context7.t0 = _this3.utils;
306
+ _context7.next = 3;
307
+ return _this3.CallContractMethod({
308
+ contractAddress: contractAddress,
309
+ methodName: "managersList",
310
+ methodArgs: [i]
311
+ });
312
+ case 3:
313
+ _context7.t1 = _context7.sent;
314
+ return _context7.abrupt("return", _context7.t0.FormatAddress.call(_context7.t0, _context7.t1));
315
+ case 5:
316
+ case "end":
317
+ return _context7.stop();
318
+ }
319
+ }, _callee7);
320
+ }));
321
+ return function (_x8, _x9) {
322
+ return _ref12.apply(this, arguments);
323
+ };
324
+ }()));
325
+ case 8:
326
+ return _context8.abrupt("return", _context8.sent);
327
+ case 9:
328
+ case "end":
329
+ return _context8.stop();
400
330
  }
401
331
  }, _callee8, this);
402
332
  }));
403
-
404
333
  return function (_x7) {
405
334
  return _ref11.apply(this, arguments);
406
335
  };
407
336
  }();
337
+
408
338
  /**
409
339
  * Create a access group
410
340
  *
@@ -419,77 +349,68 @@ exports.AccessGroupManagers = /*#__PURE__*/function () {
419
349
  *
420
350
  * @returns {Promise<string>} - Contract address of created access group
421
351
  */
422
-
423
-
424
352
  exports.CreateAccessGroup = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
425
353
  var _ref14,
426
- name,
427
- description,
428
- _ref14$metadata,
429
- metadata,
430
- _yield$this$authClien,
431
- contractAddress,
432
- objectId,
433
- editResponse,
434
- _args9 = arguments;
435
-
354
+ name,
355
+ description,
356
+ _ref14$metadata,
357
+ metadata,
358
+ _yield$this$authClien,
359
+ contractAddress,
360
+ objectId,
361
+ editResponse,
362
+ _args9 = arguments;
436
363
  return _regeneratorRuntime.wrap(function _callee9$(_context9) {
437
- while (1) {
438
- switch (_context9.prev = _context9.next) {
439
- case 0:
440
- _ref14 = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {}, name = _ref14.name, description = _ref14.description, _ref14$metadata = _ref14.metadata, metadata = _ref14$metadata === void 0 ? {} : _ref14$metadata;
441
- this.Log("Creating access group: ".concat(name || "", " ").concat(description || ""));
442
- _context9.next = 4;
443
- return this.authClient.CreateAccessGroup();
444
-
445
- case 4:
446
- _yield$this$authClien = _context9.sent;
447
- contractAddress = _yield$this$authClien.contractAddress;
448
- contractAddress = this.utils.FormatAddress(contractAddress);
449
- objectId = this.utils.AddressToObjectId(contractAddress);
450
- this.Log("Access group: ".concat(contractAddress, " ").concat(objectId));
451
- _context9.next = 11;
452
- return this.EditContentObject({
453
- libraryId: this.contentSpaceLibraryId,
454
- objectId: objectId
455
- });
456
-
457
- case 11:
458
- editResponse = _context9.sent;
459
- _context9.next = 14;
460
- return this.ReplaceMetadata({
461
- libraryId: this.contentSpaceLibraryId,
462
- objectId: objectId,
463
- writeToken: editResponse.write_token,
464
- metadata: _objectSpread({
465
- "public": {
466
- name: name,
467
- description: description
468
- },
364
+ while (1) switch (_context9.prev = _context9.next) {
365
+ case 0:
366
+ _ref14 = _args9.length > 0 && _args9[0] !== undefined ? _args9[0] : {}, name = _ref14.name, description = _ref14.description, _ref14$metadata = _ref14.metadata, metadata = _ref14$metadata === void 0 ? {} : _ref14$metadata;
367
+ this.Log("Creating access group: ".concat(name || "", " ").concat(description || ""));
368
+ _context9.next = 4;
369
+ return this.authClient.CreateAccessGroup();
370
+ case 4:
371
+ _yield$this$authClien = _context9.sent;
372
+ contractAddress = _yield$this$authClien.contractAddress;
373
+ contractAddress = this.utils.FormatAddress(contractAddress);
374
+ objectId = this.utils.AddressToObjectId(contractAddress);
375
+ this.Log("Access group: ".concat(contractAddress, " ").concat(objectId));
376
+ _context9.next = 11;
377
+ return this.EditContentObject({
378
+ libraryId: this.contentSpaceLibraryId,
379
+ objectId: objectId
380
+ });
381
+ case 11:
382
+ editResponse = _context9.sent;
383
+ _context9.next = 14;
384
+ return this.ReplaceMetadata({
385
+ libraryId: this.contentSpaceLibraryId,
386
+ objectId: objectId,
387
+ writeToken: editResponse.write_token,
388
+ metadata: _objectSpread({
389
+ "public": {
469
390
  name: name,
470
391
  description: description
471
- }, metadata)
472
- });
473
-
474
- case 14:
475
- _context9.next = 16;
476
- return this.FinalizeContentObject({
477
- libraryId: this.contentSpaceLibraryId,
478
- objectId: objectId,
479
- writeToken: editResponse.write_token,
480
- commitMessage: "Create access group"
481
- });
482
-
483
- case 16:
484
- return _context9.abrupt("return", contractAddress);
485
-
486
- case 17:
487
- case "end":
488
- return _context9.stop();
489
- }
392
+ },
393
+ name: name,
394
+ description: description
395
+ }, metadata)
396
+ });
397
+ case 14:
398
+ _context9.next = 16;
399
+ return this.FinalizeContentObject({
400
+ libraryId: this.contentSpaceLibraryId,
401
+ objectId: objectId,
402
+ writeToken: editResponse.write_token,
403
+ commitMessage: "Create access group"
404
+ });
405
+ case 16:
406
+ return _context9.abrupt("return", contractAddress);
407
+ case 17:
408
+ case "end":
409
+ return _context9.stop();
490
410
  }
491
411
  }, _callee9, this);
492
412
  }));
413
+
493
414
  /**
494
415
  * NOT YET SUPPORTED - Delete an access group
495
416
  *
@@ -500,116 +421,98 @@ exports.CreateAccessGroup = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regene
500
421
  * @namedParams
501
422
  * @param {string} contractAddress - The address of the access group contract
502
423
  */
503
-
504
424
  exports.DeleteAccessGroup = /*#__PURE__*/function () {
505
425
  var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref15) {
506
426
  var contractAddress;
507
427
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
508
- while (1) {
509
- switch (_context10.prev = _context10.next) {
510
- case 0:
511
- contractAddress = _ref15.contractAddress;
512
- throw Error("Not supported");
513
-
514
- case 6:
515
- case "end":
516
- return _context10.stop();
517
- }
428
+ while (1) switch (_context10.prev = _context10.next) {
429
+ case 0:
430
+ contractAddress = _ref15.contractAddress;
431
+ throw Error("Not supported");
432
+ case 6:
433
+ case "end":
434
+ return _context10.stop();
518
435
  }
519
436
  }, _callee10, this);
520
437
  }));
521
-
522
438
  return function (_x10) {
523
439
  return _ref16.apply(this, arguments);
524
440
  };
525
441
  }();
526
-
527
442
  exports.AccessGroupMembershipMethod = /*#__PURE__*/function () {
528
443
  var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref17) {
529
444
  var contractAddress, memberAddress, methodName, eventName, isManager, event, abi, candidate;
530
445
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
531
- while (1) {
532
- switch (_context11.prev = _context11.next) {
533
- case 0:
534
- contractAddress = _ref17.contractAddress, memberAddress = _ref17.memberAddress, methodName = _ref17.methodName, eventName = _ref17.eventName;
535
- contractAddress = ValidateAddress(contractAddress);
536
- memberAddress = ValidateAddress(memberAddress); // Ensure caller is the member being acted upon or a manager/owner of the group
537
-
538
- if (this.utils.EqualAddress(this.signer.address, memberAddress)) {
539
- _context11.next = 9;
540
- break;
541
- }
542
-
543
- _context11.next = 6;
544
- return this.CallContractMethod({
545
- contractAddress: contractAddress,
546
- methodName: "hasManagerAccess",
547
- methodArgs: [this.utils.FormatAddress(this.signer.address)]
548
- });
549
-
550
- case 6:
551
- isManager = _context11.sent;
552
-
553
- if (isManager) {
554
- _context11.next = 9;
555
- break;
556
- }
557
-
558
- throw Error("Manager access required");
559
-
560
- case 9:
561
- this.Log("Calling ".concat(methodName, " on group ").concat(contractAddress, " for user ").concat(memberAddress));
562
- _context11.next = 12;
563
- return this.CallContractMethodAndWait({
564
- contractAddress: contractAddress,
565
- methodName: methodName,
566
- methodArgs: [memberAddress],
567
- eventName: eventName,
568
- eventValue: "candidate"
569
- });
570
-
571
- case 12:
572
- event = _context11.sent;
573
- _context11.next = 15;
574
- return this.ContractAbi({
575
- contractAddress: contractAddress
576
- });
577
-
578
- case 15:
579
- abi = _context11.sent;
580
- candidate = this.ExtractValueFromEvent({
581
- abi: abi,
582
- event: event,
583
- eventName: eventName,
584
- eventValue: "candidate"
585
- });
586
-
587
- if (!(this.utils.FormatAddress(candidate) !== this.utils.FormatAddress(memberAddress))) {
588
- _context11.next = 21;
589
- break;
590
- }
591
-
592
- // eslint-disable-next-line no-console
593
- console.error("Mismatch: " + candidate + " :: " + memberAddress); // eslint-disable-next-line no-console
594
-
595
- console.error("Is target user address wallet created?");
596
- throw Error("Access group method " + methodName + " failed. Is target user address wallet created?");
597
-
598
- case 21:
599
- return _context11.abrupt("return", event.transactionHash);
446
+ while (1) switch (_context11.prev = _context11.next) {
447
+ case 0:
448
+ contractAddress = _ref17.contractAddress, memberAddress = _ref17.memberAddress, methodName = _ref17.methodName, eventName = _ref17.eventName;
449
+ contractAddress = ValidateAddress(contractAddress);
450
+ memberAddress = ValidateAddress(memberAddress);
600
451
 
601
- case 22:
602
- case "end":
603
- return _context11.stop();
604
- }
452
+ // Ensure caller is the member being acted upon or a manager/owner of the group
453
+ if (this.utils.EqualAddress(this.signer.address, memberAddress)) {
454
+ _context11.next = 9;
455
+ break;
456
+ }
457
+ _context11.next = 6;
458
+ return this.CallContractMethod({
459
+ contractAddress: contractAddress,
460
+ methodName: "hasManagerAccess",
461
+ methodArgs: [this.utils.FormatAddress(this.signer.address)]
462
+ });
463
+ case 6:
464
+ isManager = _context11.sent;
465
+ if (isManager) {
466
+ _context11.next = 9;
467
+ break;
468
+ }
469
+ throw Error("Manager access required");
470
+ case 9:
471
+ this.Log("Calling ".concat(methodName, " on group ").concat(contractAddress, " for user ").concat(memberAddress));
472
+ _context11.next = 12;
473
+ return this.CallContractMethodAndWait({
474
+ contractAddress: contractAddress,
475
+ methodName: methodName,
476
+ methodArgs: [memberAddress],
477
+ eventName: eventName,
478
+ eventValue: "candidate"
479
+ });
480
+ case 12:
481
+ event = _context11.sent;
482
+ _context11.next = 15;
483
+ return this.ContractAbi({
484
+ contractAddress: contractAddress
485
+ });
486
+ case 15:
487
+ abi = _context11.sent;
488
+ candidate = this.ExtractValueFromEvent({
489
+ abi: abi,
490
+ event: event,
491
+ eventName: eventName,
492
+ eventValue: "candidate"
493
+ });
494
+ if (!(this.utils.FormatAddress(candidate) !== this.utils.FormatAddress(memberAddress))) {
495
+ _context11.next = 21;
496
+ break;
497
+ }
498
+ // eslint-disable-next-line no-console
499
+ console.error("Mismatch: " + candidate + " :: " + memberAddress);
500
+ // eslint-disable-next-line no-console
501
+ console.error("Is target user address wallet created?");
502
+ throw Error("Access group method " + methodName + " failed. Is target user address wallet created?");
503
+ case 21:
504
+ return _context11.abrupt("return", event.transactionHash);
505
+ case 22:
506
+ case "end":
507
+ return _context11.stop();
605
508
  }
606
509
  }, _callee11, this);
607
510
  }));
608
-
609
511
  return function (_x11) {
610
512
  return _ref18.apply(this, arguments);
611
513
  };
612
514
  }();
515
+
613
516
  /**
614
517
  * Add a member to the access group at the specified contract address. This client's signer must
615
518
  * be a manager of the access group.
@@ -622,41 +525,35 @@ exports.AccessGroupMembershipMethod = /*#__PURE__*/function () {
622
525
  *
623
526
  * @returns {Promise<string>} - The transaction hash of the call to the grantAccess method
624
527
  */
625
-
626
-
627
528
  exports.AddAccessGroupMember = /*#__PURE__*/function () {
628
529
  var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref19) {
629
530
  var contractAddress, memberAddress;
630
531
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
631
- while (1) {
632
- switch (_context12.prev = _context12.next) {
633
- case 0:
634
- contractAddress = _ref19.contractAddress, memberAddress = _ref19.memberAddress;
635
- contractAddress = ValidateAddress(contractAddress);
636
- memberAddress = ValidateAddress(memberAddress);
637
- _context12.next = 5;
638
- return this.AccessGroupMembershipMethod({
639
- contractAddress: contractAddress,
640
- memberAddress: memberAddress,
641
- methodName: "grantAccess",
642
- eventName: "MemberAdded"
643
- });
644
-
645
- case 5:
646
- return _context12.abrupt("return", _context12.sent);
647
-
648
- case 6:
649
- case "end":
650
- return _context12.stop();
651
- }
532
+ while (1) switch (_context12.prev = _context12.next) {
533
+ case 0:
534
+ contractAddress = _ref19.contractAddress, memberAddress = _ref19.memberAddress;
535
+ contractAddress = ValidateAddress(contractAddress);
536
+ memberAddress = ValidateAddress(memberAddress);
537
+ _context12.next = 5;
538
+ return this.AccessGroupMembershipMethod({
539
+ contractAddress: contractAddress,
540
+ memberAddress: memberAddress,
541
+ methodName: "grantAccess",
542
+ eventName: "MemberAdded"
543
+ });
544
+ case 5:
545
+ return _context12.abrupt("return", _context12.sent);
546
+ case 6:
547
+ case "end":
548
+ return _context12.stop();
652
549
  }
653
550
  }, _callee12, this);
654
551
  }));
655
-
656
552
  return function (_x12) {
657
553
  return _ref20.apply(this, arguments);
658
554
  };
659
555
  }();
556
+
660
557
  /**
661
558
  * Remove a member from the access group at the specified contract address. This client's signer must
662
559
  * be a manager of the access group.
@@ -669,41 +566,35 @@ exports.AddAccessGroupMember = /*#__PURE__*/function () {
669
566
  *
670
567
  * @returns {Promise<string>} - The transaction hash of the call to the revokeAccess method
671
568
  */
672
-
673
-
674
569
  exports.RemoveAccessGroupMember = /*#__PURE__*/function () {
675
570
  var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref21) {
676
571
  var contractAddress, memberAddress;
677
572
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
678
- while (1) {
679
- switch (_context13.prev = _context13.next) {
680
- case 0:
681
- contractAddress = _ref21.contractAddress, memberAddress = _ref21.memberAddress;
682
- contractAddress = ValidateAddress(contractAddress);
683
- memberAddress = ValidateAddress(memberAddress);
684
- _context13.next = 5;
685
- return this.AccessGroupMembershipMethod({
686
- contractAddress: contractAddress,
687
- memberAddress: memberAddress,
688
- methodName: "revokeAccess",
689
- eventName: "MemberRevoked"
690
- });
691
-
692
- case 5:
693
- return _context13.abrupt("return", _context13.sent);
694
-
695
- case 6:
696
- case "end":
697
- return _context13.stop();
698
- }
573
+ while (1) switch (_context13.prev = _context13.next) {
574
+ case 0:
575
+ contractAddress = _ref21.contractAddress, memberAddress = _ref21.memberAddress;
576
+ contractAddress = ValidateAddress(contractAddress);
577
+ memberAddress = ValidateAddress(memberAddress);
578
+ _context13.next = 5;
579
+ return this.AccessGroupMembershipMethod({
580
+ contractAddress: contractAddress,
581
+ memberAddress: memberAddress,
582
+ methodName: "revokeAccess",
583
+ eventName: "MemberRevoked"
584
+ });
585
+ case 5:
586
+ return _context13.abrupt("return", _context13.sent);
587
+ case 6:
588
+ case "end":
589
+ return _context13.stop();
699
590
  }
700
591
  }, _callee13, this);
701
592
  }));
702
-
703
593
  return function (_x13) {
704
594
  return _ref22.apply(this, arguments);
705
595
  };
706
596
  }();
597
+
707
598
  /**
708
599
  * Add a manager to the access group at the specified contract address. This client's signer must
709
600
  * be a manager of the access group.
@@ -716,41 +607,35 @@ exports.RemoveAccessGroupMember = /*#__PURE__*/function () {
716
607
  *
717
608
  * @returns {Promise<string>} - The transaction hash of the call to the grantManagerAccess method
718
609
  */
719
-
720
-
721
610
  exports.AddAccessGroupManager = /*#__PURE__*/function () {
722
611
  var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref23) {
723
612
  var contractAddress, memberAddress;
724
613
  return _regeneratorRuntime.wrap(function _callee14$(_context14) {
725
- while (1) {
726
- switch (_context14.prev = _context14.next) {
727
- case 0:
728
- contractAddress = _ref23.contractAddress, memberAddress = _ref23.memberAddress;
729
- contractAddress = ValidateAddress(contractAddress);
730
- memberAddress = ValidateAddress(memberAddress);
731
- _context14.next = 5;
732
- return this.AccessGroupMembershipMethod({
733
- contractAddress: contractAddress,
734
- memberAddress: memberAddress,
735
- methodName: "grantManagerAccess",
736
- eventName: "ManagerAccessGranted"
737
- });
738
-
739
- case 5:
740
- return _context14.abrupt("return", _context14.sent);
741
-
742
- case 6:
743
- case "end":
744
- return _context14.stop();
745
- }
614
+ while (1) switch (_context14.prev = _context14.next) {
615
+ case 0:
616
+ contractAddress = _ref23.contractAddress, memberAddress = _ref23.memberAddress;
617
+ contractAddress = ValidateAddress(contractAddress);
618
+ memberAddress = ValidateAddress(memberAddress);
619
+ _context14.next = 5;
620
+ return this.AccessGroupMembershipMethod({
621
+ contractAddress: contractAddress,
622
+ memberAddress: memberAddress,
623
+ methodName: "grantManagerAccess",
624
+ eventName: "ManagerAccessGranted"
625
+ });
626
+ case 5:
627
+ return _context14.abrupt("return", _context14.sent);
628
+ case 6:
629
+ case "end":
630
+ return _context14.stop();
746
631
  }
747
632
  }, _callee14, this);
748
633
  }));
749
-
750
634
  return function (_x14) {
751
635
  return _ref24.apply(this, arguments);
752
636
  };
753
637
  }();
638
+
754
639
  /**
755
640
  * Remove a manager from the access group at the specified contract address. This client's signer must
756
641
  * be a manager of the access group.
@@ -763,41 +648,35 @@ exports.AddAccessGroupManager = /*#__PURE__*/function () {
763
648
  *
764
649
  * @returns {Promise<string>} - The transaction hash of the call to the revokeManagerAccess method
765
650
  */
766
-
767
-
768
651
  exports.RemoveAccessGroupManager = /*#__PURE__*/function () {
769
652
  var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref25) {
770
653
  var contractAddress, memberAddress;
771
654
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
772
- while (1) {
773
- switch (_context15.prev = _context15.next) {
774
- case 0:
775
- contractAddress = _ref25.contractAddress, memberAddress = _ref25.memberAddress;
776
- contractAddress = ValidateAddress(contractAddress);
777
- memberAddress = ValidateAddress(memberAddress);
778
- _context15.next = 5;
779
- return this.AccessGroupMembershipMethod({
780
- contractAddress: contractAddress,
781
- memberAddress: memberAddress,
782
- methodName: "revokeManagerAccess",
783
- eventName: "ManagerAccessRevoked"
784
- });
785
-
786
- case 5:
787
- return _context15.abrupt("return", _context15.sent);
788
-
789
- case 6:
790
- case "end":
791
- return _context15.stop();
792
- }
655
+ while (1) switch (_context15.prev = _context15.next) {
656
+ case 0:
657
+ contractAddress = _ref25.contractAddress, memberAddress = _ref25.memberAddress;
658
+ contractAddress = ValidateAddress(contractAddress);
659
+ memberAddress = ValidateAddress(memberAddress);
660
+ _context15.next = 5;
661
+ return this.AccessGroupMembershipMethod({
662
+ contractAddress: contractAddress,
663
+ memberAddress: memberAddress,
664
+ methodName: "revokeManagerAccess",
665
+ eventName: "ManagerAccessRevoked"
666
+ });
667
+ case 5:
668
+ return _context15.abrupt("return", _context15.sent);
669
+ case 6:
670
+ case "end":
671
+ return _context15.stop();
793
672
  }
794
673
  }, _callee15, this);
795
674
  }));
796
-
797
675
  return function (_x15) {
798
676
  return _ref26.apply(this, arguments);
799
677
  };
800
678
  }();
679
+
801
680
  /**
802
681
  * List all of the groups with permissions on the specified library.
803
682
  *
@@ -810,128 +689,104 @@ exports.RemoveAccessGroupManager = /*#__PURE__*/function () {
810
689
  * @return {Promise<Object>} - Object mapping group addresses to permissions, as an array
811
690
  * - Example: { "0x0": ["accessor", "contributor"], ...}
812
691
  */
813
-
814
-
815
692
  exports.ContentLibraryGroupPermissions = /*#__PURE__*/function () {
816
693
  var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref27) {
817
694
  var _this4 = this;
818
-
819
695
  var libraryId, _ref27$permissions, permissions, libraryPermissions;
820
-
821
696
  return _regeneratorRuntime.wrap(function _callee18$(_context18) {
822
- while (1) {
823
- switch (_context18.prev = _context18.next) {
824
- case 0:
825
- libraryId = _ref27.libraryId, _ref27$permissions = _ref27.permissions, permissions = _ref27$permissions === void 0 ? [] : _ref27$permissions;
826
- ValidateLibrary(libraryId);
827
- libraryPermissions = {};
828
-
829
- if (!permissions || permissions.length === 0) {
830
- permissions = ["accessor", "contributor", "reviewer"];
831
- } else {
832
- // Format and validate specified permissions
833
- permissions = permissions.map(function (permission) {
834
- permission = permission.toLowerCase();
835
-
836
- if (!["accessor", "contributor", "reviewer"].includes(permission)) {
837
- throw Error("Invalid permission: ".concat(permission));
697
+ while (1) switch (_context18.prev = _context18.next) {
698
+ case 0:
699
+ libraryId = _ref27.libraryId, _ref27$permissions = _ref27.permissions, permissions = _ref27$permissions === void 0 ? [] : _ref27$permissions;
700
+ ValidateLibrary(libraryId);
701
+ libraryPermissions = {};
702
+ if (!permissions || permissions.length === 0) {
703
+ permissions = ["accessor", "contributor", "reviewer"];
704
+ } else {
705
+ // Format and validate specified permissions
706
+ permissions = permissions.map(function (permission) {
707
+ permission = permission.toLowerCase();
708
+ if (!["accessor", "contributor", "reviewer"].includes(permission)) {
709
+ throw Error("Invalid permission: ".concat(permission));
710
+ }
711
+ return permission;
712
+ });
713
+ }
714
+ this.Log("Retrieving ".concat(permissions.join(", "), " group(s) for library ").concat(libraryId));
715
+ _context18.next = 7;
716
+ return Promise.all(permissions.map( /*#__PURE__*/function () {
717
+ var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(type) {
718
+ var numGroups, accessGroupAddresses;
719
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
720
+ while (1) switch (_context17.prev = _context17.next) {
721
+ case 0:
722
+ _context17.next = 2;
723
+ return _this4.CallContractMethod({
724
+ contractAddress: _this4.utils.HashToAddress(libraryId),
725
+ methodName: type + "GroupsLength"
726
+ });
727
+ case 2:
728
+ numGroups = _context17.sent;
729
+ numGroups = parseInt(numGroups._hex, 16);
730
+ _context17.next = 6;
731
+ return _this4.utils.LimitedMap(3, _toConsumableArray(Array(numGroups).keys()), /*#__PURE__*/function () {
732
+ var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(i) {
733
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
734
+ while (1) switch (_context16.prev = _context16.next) {
735
+ case 0:
736
+ _context16.prev = 0;
737
+ _context16.t0 = _this4.utils;
738
+ _context16.next = 4;
739
+ return _this4.CallContractMethod({
740
+ contractAddress: _this4.utils.HashToAddress(libraryId),
741
+ methodName: type + "Groups",
742
+ methodArgs: [i]
743
+ });
744
+ case 4:
745
+ _context16.t1 = _context16.sent;
746
+ return _context16.abrupt("return", _context16.t0.FormatAddress.call(_context16.t0, _context16.t1));
747
+ case 8:
748
+ _context16.prev = 8;
749
+ _context16.t2 = _context16["catch"](0);
750
+ // eslint-disable-next-line no-console
751
+ console.error(_context16.t2);
752
+ case 11:
753
+ case "end":
754
+ return _context16.stop();
755
+ }
756
+ }, _callee16, null, [[0, 8]]);
757
+ }));
758
+ return function (_x18) {
759
+ return _ref30.apply(this, arguments);
760
+ };
761
+ }());
762
+ case 6:
763
+ accessGroupAddresses = _context17.sent;
764
+ accessGroupAddresses.forEach(function (address) {
765
+ return libraryPermissions[address] = [].concat(_toConsumableArray(libraryPermissions[address] || []), [type]).sort();
766
+ });
767
+ case 8:
768
+ case "end":
769
+ return _context17.stop();
838
770
  }
839
-
840
- return permission;
841
- });
842
- }
843
-
844
- this.Log("Retrieving ".concat(permissions.join(", "), " group(s) for library ").concat(libraryId));
845
- _context18.next = 7;
846
- return Promise.all(permissions.map( /*#__PURE__*/function () {
847
- var _ref29 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(type) {
848
- var numGroups, accessGroupAddresses;
849
- return _regeneratorRuntime.wrap(function _callee17$(_context17) {
850
- while (1) {
851
- switch (_context17.prev = _context17.next) {
852
- case 0:
853
- _context17.next = 2;
854
- return _this4.CallContractMethod({
855
- contractAddress: _this4.utils.HashToAddress(libraryId),
856
- methodName: type + "GroupsLength"
857
- });
858
-
859
- case 2:
860
- numGroups = _context17.sent;
861
- numGroups = parseInt(numGroups._hex, 16);
862
- _context17.next = 6;
863
- return _this4.utils.LimitedMap(3, _toConsumableArray(Array(numGroups).keys()), /*#__PURE__*/function () {
864
- var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(i) {
865
- return _regeneratorRuntime.wrap(function _callee16$(_context16) {
866
- while (1) {
867
- switch (_context16.prev = _context16.next) {
868
- case 0:
869
- _context16.prev = 0;
870
- _context16.t0 = _this4.utils;
871
- _context16.next = 4;
872
- return _this4.CallContractMethod({
873
- contractAddress: _this4.utils.HashToAddress(libraryId),
874
- methodName: type + "Groups",
875
- methodArgs: [i]
876
- });
877
-
878
- case 4:
879
- _context16.t1 = _context16.sent;
880
- return _context16.abrupt("return", _context16.t0.FormatAddress.call(_context16.t0, _context16.t1));
881
-
882
- case 8:
883
- _context16.prev = 8;
884
- _context16.t2 = _context16["catch"](0);
885
- // eslint-disable-next-line no-console
886
- console.error(_context16.t2);
887
-
888
- case 11:
889
- case "end":
890
- return _context16.stop();
891
- }
892
- }
893
- }, _callee16, null, [[0, 8]]);
894
- }));
895
-
896
- return function (_x18) {
897
- return _ref30.apply(this, arguments);
898
- };
899
- }());
900
-
901
- case 6:
902
- accessGroupAddresses = _context17.sent;
903
- accessGroupAddresses.forEach(function (address) {
904
- return libraryPermissions[address] = [].concat(_toConsumableArray(libraryPermissions[address] || []), [type]).sort();
905
- });
906
-
907
- case 8:
908
- case "end":
909
- return _context17.stop();
910
- }
911
- }
912
- }, _callee17);
913
- }));
914
-
915
- return function (_x17) {
916
- return _ref29.apply(this, arguments);
917
- };
918
- }()));
919
-
920
- case 7:
921
- return _context18.abrupt("return", libraryPermissions);
922
-
923
- case 8:
924
- case "end":
925
- return _context18.stop();
926
- }
771
+ }, _callee17);
772
+ }));
773
+ return function (_x17) {
774
+ return _ref29.apply(this, arguments);
775
+ };
776
+ }()));
777
+ case 7:
778
+ return _context18.abrupt("return", libraryPermissions);
779
+ case 8:
780
+ case "end":
781
+ return _context18.stop();
927
782
  }
928
783
  }, _callee18, this);
929
784
  }));
930
-
931
785
  return function (_x16) {
932
786
  return _ref28.apply(this, arguments);
933
787
  };
934
788
  }();
789
+
935
790
  /**
936
791
  * Add accessor, contributor or reviewer permissions for the specified group on the specified library
937
792
  *
@@ -942,82 +797,68 @@ exports.ContentLibraryGroupPermissions = /*#__PURE__*/function () {
942
797
  * @param {string} groupAddress - The address of the group
943
798
  * @param {string} permission - The type of permission to add ("accessor", "contributor", "reviewer")
944
799
  */
945
-
946
-
947
800
  exports.AddContentLibraryGroup = /*#__PURE__*/function () {
948
801
  var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref31) {
949
802
  var libraryId, groupAddress, permission, existingPermissions, event, abi;
950
803
  return _regeneratorRuntime.wrap(function _callee19$(_context19) {
951
- while (1) {
952
- switch (_context19.prev = _context19.next) {
953
- case 0:
954
- libraryId = _ref31.libraryId, groupAddress = _ref31.groupAddress, permission = _ref31.permission;
955
- ValidateLibrary(libraryId);
956
- groupAddress = ValidateAddress(groupAddress);
957
-
958
- if (["accessor", "contributor", "reviewer"].includes(permission.toLowerCase())) {
959
- _context19.next = 5;
960
- break;
961
- }
962
-
963
- throw Error("Invalid group type: ".concat(permission));
964
-
965
- case 5:
966
- this.Log("Adding ".concat(permission, " group ").concat(groupAddress, " to library ").concat(libraryId));
967
- _context19.next = 8;
968
- return this.ContentLibraryGroupPermissions({
969
- libraryId: libraryId,
970
- permissions: [permission]
971
- });
972
-
973
- case 8:
974
- existingPermissions = _context19.sent;
975
-
976
- if (!existingPermissions[groupAddress]) {
977
- _context19.next = 11;
978
- break;
979
- }
980
-
981
- return _context19.abrupt("return");
982
-
983
- case 11:
984
- // Capitalize permission to match method and event names
985
- permission = permission.charAt(0).toUpperCase() + permission.substr(1).toLowerCase();
986
- _context19.next = 14;
987
- return this.CallContractMethodAndWait({
988
- contractAddress: this.utils.HashToAddress(libraryId),
989
- methodName: "add".concat(permission, "Group"),
990
- methodArgs: [groupAddress]
991
- });
992
-
993
- case 14:
994
- event = _context19.sent;
995
- _context19.next = 17;
996
- return this.ContractAbi({
997
- id: libraryId
998
- });
999
-
1000
- case 17:
1001
- abi = _context19.sent;
1002
- _context19.next = 20;
1003
- return this.ExtractEventFromLogs({
1004
- abi: abi,
1005
- event: event,
1006
- eventName: "".concat(permission, "GroupAdded")
1007
- });
1008
-
1009
- case 20:
1010
- case "end":
1011
- return _context19.stop();
1012
- }
804
+ while (1) switch (_context19.prev = _context19.next) {
805
+ case 0:
806
+ libraryId = _ref31.libraryId, groupAddress = _ref31.groupAddress, permission = _ref31.permission;
807
+ ValidateLibrary(libraryId);
808
+ groupAddress = ValidateAddress(groupAddress);
809
+ if (["accessor", "contributor", "reviewer"].includes(permission.toLowerCase())) {
810
+ _context19.next = 5;
811
+ break;
812
+ }
813
+ throw Error("Invalid group type: ".concat(permission));
814
+ case 5:
815
+ this.Log("Adding ".concat(permission, " group ").concat(groupAddress, " to library ").concat(libraryId));
816
+ _context19.next = 8;
817
+ return this.ContentLibraryGroupPermissions({
818
+ libraryId: libraryId,
819
+ permissions: [permission]
820
+ });
821
+ case 8:
822
+ existingPermissions = _context19.sent;
823
+ if (!existingPermissions[groupAddress]) {
824
+ _context19.next = 11;
825
+ break;
826
+ }
827
+ return _context19.abrupt("return");
828
+ case 11:
829
+ // Capitalize permission to match method and event names
830
+ permission = permission.charAt(0).toUpperCase() + permission.substr(1).toLowerCase();
831
+ _context19.next = 14;
832
+ return this.CallContractMethodAndWait({
833
+ contractAddress: this.utils.HashToAddress(libraryId),
834
+ methodName: "add".concat(permission, "Group"),
835
+ methodArgs: [groupAddress]
836
+ });
837
+ case 14:
838
+ event = _context19.sent;
839
+ _context19.next = 17;
840
+ return this.ContractAbi({
841
+ id: libraryId
842
+ });
843
+ case 17:
844
+ abi = _context19.sent;
845
+ _context19.next = 20;
846
+ return this.ExtractEventFromLogs({
847
+ abi: abi,
848
+ event: event,
849
+ eventName: "".concat(permission, "GroupAdded")
850
+ });
851
+ case 20:
852
+ case "end":
853
+ return _context19.stop();
1013
854
  }
1014
855
  }, _callee19, this);
1015
856
  }));
1016
-
1017
857
  return function (_x19) {
1018
858
  return _ref32.apply(this, arguments);
1019
859
  };
1020
860
  }();
861
+
1021
862
  /**
1022
863
  * Remove accessor, contributor or reviewer permissions for the specified group on the specified library
1023
864
  *
@@ -1028,82 +869,68 @@ exports.AddContentLibraryGroup = /*#__PURE__*/function () {
1028
869
  * @param {string} groupAddress - The address of the group
1029
870
  * @param {string} permission - The type of permission to remove ("accessor", "contributor", "reviewer")
1030
871
  */
1031
-
1032
-
1033
872
  exports.RemoveContentLibraryGroup = /*#__PURE__*/function () {
1034
873
  var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref33) {
1035
874
  var libraryId, groupAddress, permission, existingPermissions, event, abi;
1036
875
  return _regeneratorRuntime.wrap(function _callee20$(_context20) {
1037
- while (1) {
1038
- switch (_context20.prev = _context20.next) {
1039
- case 0:
1040
- libraryId = _ref33.libraryId, groupAddress = _ref33.groupAddress, permission = _ref33.permission;
1041
- ValidateLibrary(libraryId);
1042
- groupAddress = ValidateAddress(groupAddress);
1043
-
1044
- if (["accessor", "contributor", "reviewer"].includes(permission.toLowerCase())) {
1045
- _context20.next = 5;
1046
- break;
1047
- }
1048
-
1049
- throw Error("Invalid group type: ".concat(permission));
1050
-
1051
- case 5:
1052
- this.Log("Removing ".concat(permission, " group ").concat(groupAddress, " from library ").concat(libraryId));
1053
- _context20.next = 8;
1054
- return this.ContentLibraryGroupPermissions({
1055
- libraryId: libraryId,
1056
- permissions: [permission]
1057
- });
1058
-
1059
- case 8:
1060
- existingPermissions = _context20.sent;
1061
-
1062
- if (existingPermissions[groupAddress]) {
1063
- _context20.next = 11;
1064
- break;
1065
- }
1066
-
1067
- return _context20.abrupt("return");
1068
-
1069
- case 11:
1070
- // Capitalize permission to match method and event names
1071
- permission = permission.charAt(0).toUpperCase() + permission.substr(1).toLowerCase();
1072
- _context20.next = 14;
1073
- return this.CallContractMethodAndWait({
1074
- contractAddress: this.utils.HashToAddress(libraryId),
1075
- methodName: "remove".concat(permission, "Group"),
1076
- methodArgs: [groupAddress]
1077
- });
1078
-
1079
- case 14:
1080
- event = _context20.sent;
1081
- _context20.next = 17;
1082
- return this.ContractAbi({
1083
- id: libraryId
1084
- });
1085
-
1086
- case 17:
1087
- abi = _context20.sent;
1088
- _context20.next = 20;
1089
- return this.ExtractEventFromLogs({
1090
- abi: abi,
1091
- event: event,
1092
- eventName: "".concat(permission, "GroupRemoved")
1093
- });
1094
-
1095
- case 20:
1096
- case "end":
1097
- return _context20.stop();
1098
- }
876
+ while (1) switch (_context20.prev = _context20.next) {
877
+ case 0:
878
+ libraryId = _ref33.libraryId, groupAddress = _ref33.groupAddress, permission = _ref33.permission;
879
+ ValidateLibrary(libraryId);
880
+ groupAddress = ValidateAddress(groupAddress);
881
+ if (["accessor", "contributor", "reviewer"].includes(permission.toLowerCase())) {
882
+ _context20.next = 5;
883
+ break;
884
+ }
885
+ throw Error("Invalid group type: ".concat(permission));
886
+ case 5:
887
+ this.Log("Removing ".concat(permission, " group ").concat(groupAddress, " from library ").concat(libraryId));
888
+ _context20.next = 8;
889
+ return this.ContentLibraryGroupPermissions({
890
+ libraryId: libraryId,
891
+ permissions: [permission]
892
+ });
893
+ case 8:
894
+ existingPermissions = _context20.sent;
895
+ if (existingPermissions[groupAddress]) {
896
+ _context20.next = 11;
897
+ break;
898
+ }
899
+ return _context20.abrupt("return");
900
+ case 11:
901
+ // Capitalize permission to match method and event names
902
+ permission = permission.charAt(0).toUpperCase() + permission.substr(1).toLowerCase();
903
+ _context20.next = 14;
904
+ return this.CallContractMethodAndWait({
905
+ contractAddress: this.utils.HashToAddress(libraryId),
906
+ methodName: "remove".concat(permission, "Group"),
907
+ methodArgs: [groupAddress]
908
+ });
909
+ case 14:
910
+ event = _context20.sent;
911
+ _context20.next = 17;
912
+ return this.ContractAbi({
913
+ id: libraryId
914
+ });
915
+ case 17:
916
+ abi = _context20.sent;
917
+ _context20.next = 20;
918
+ return this.ExtractEventFromLogs({
919
+ abi: abi,
920
+ event: event,
921
+ eventName: "".concat(permission, "GroupRemoved")
922
+ });
923
+ case 20:
924
+ case "end":
925
+ return _context20.stop();
1099
926
  }
1100
927
  }, _callee20, this);
1101
928
  }));
1102
-
1103
929
  return function (_x20) {
1104
930
  return _ref34.apply(this, arguments);
1105
931
  };
1106
932
  }();
933
+
1107
934
  /**
1108
935
  * List all of the groups with permissions on the specified object or content type
1109
936
  *
@@ -1115,139 +942,109 @@ exports.RemoveContentLibraryGroup = /*#__PURE__*/function () {
1115
942
  * @return {Promise<Object>} - Object mapping group addresses to permissions, as an array
1116
943
  * - Example: { "0x0": ["see", "access", "manage"], ...}
1117
944
  */
1118
-
1119
-
1120
945
  exports.ContentObjectGroupPermissions = /*#__PURE__*/function () {
1121
946
  var _ref36 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref35) {
1122
947
  var _this5 = this;
1123
-
1124
948
  var objectId, contractAddress, groupAddresses, rightsMethod, groupPermissions;
1125
949
  return _regeneratorRuntime.wrap(function _callee22$(_context22) {
1126
- while (1) {
1127
- switch (_context22.prev = _context22.next) {
1128
- case 0:
1129
- objectId = _ref35.objectId;
1130
- ValidateObject(objectId);
1131
- this.Log("Retrieving group permissions for object ".concat(objectId));
1132
- contractAddress = this.utils.HashToAddress(objectId); // Access indexor only available on access groups, so must ask each access group
1133
- // we belong to about this object
1134
-
1135
- _context22.next = 6;
1136
- return this.Collection({
1137
- collectionType: "accessGroups"
1138
- });
1139
-
1140
- case 6:
1141
- groupAddresses = _context22.sent;
1142
- _context22.next = 9;
1143
- return this.AccessType({
1144
- id: objectId
1145
- });
1146
-
1147
- case 9:
1148
- _context22.t0 = _context22.sent;
1149
- _context22.next = _context22.t0 === this.authClient.ACCESS_TYPES.OBJECT ? 12 : _context22.t0 === this.authClient.ACCESS_TYPES.TYPE ? 14 : _context22.t0 === this.authClient.ACCESS_TYPES.GROUP ? 16 : _context22.t0 === this.authClient.ACCESS_TYPES.LIBRARY ? 18 : 19;
1150
- break;
1151
-
1152
- case 12:
1153
- rightsMethod = "getContentObjectRights";
1154
- return _context22.abrupt("break", 19);
1155
-
1156
- case 14:
1157
- rightsMethod = "getContentTypeRights";
1158
- return _context22.abrupt("break", 19);
1159
-
1160
- case 16:
1161
- rightsMethod = "getAccessGroupRights";
1162
- return _context22.abrupt("break", 19);
1163
-
1164
- case 18:
1165
- rightsMethod = "getLibraryRights";
1166
-
1167
- case 19:
1168
- groupPermissions = {};
1169
- _context22.next = 22;
1170
- return Promise.all(groupAddresses.map( /*#__PURE__*/function () {
1171
- var _ref37 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(groupAddress) {
1172
- var permission, permissions;
1173
- return _regeneratorRuntime.wrap(function _callee21$(_context21) {
1174
- while (1) {
1175
- switch (_context21.prev = _context21.next) {
1176
- case 0:
1177
- _context21.prev = 0;
1178
- groupAddress = _this5.utils.FormatAddress(groupAddress);
1179
- _context21.next = 4;
1180
- return _this5.CallContractMethod({
1181
- contractAddress: groupAddress,
1182
- methodName: rightsMethod,
1183
- methodArgs: [contractAddress]
1184
- });
1185
-
1186
- case 4:
1187
- permission = _context21.sent;
1188
-
1189
- if (!(permission === 0)) {
1190
- _context21.next = 7;
1191
- break;
1192
- }
1193
-
1194
- return _context21.abrupt("return");
1195
-
1196
- case 7:
1197
- permissions = [];
1198
-
1199
- if (permission >= 100) {
1200
- permissions.push("manage");
1201
- }
1202
-
1203
- if (permission % 100 >= 10) {
1204
- permissions.push("access");
1205
- }
1206
-
1207
- if (permission % 10 > 0) {
1208
- permissions.push("see");
1209
- }
1210
-
1211
- groupPermissions[groupAddress] = permissions;
1212
- _context21.next = 18;
1213
- break;
1214
-
1215
- case 14:
1216
- _context21.prev = 14;
1217
- _context21.t0 = _context21["catch"](0);
1218
-
1219
- _this5.Log("Failed to retrieve group permissions for ".concat(groupAddress), true);
1220
-
1221
- _this5.Log(_context21.t0, true);
1222
-
1223
- case 18:
1224
- case "end":
1225
- return _context21.stop();
950
+ while (1) switch (_context22.prev = _context22.next) {
951
+ case 0:
952
+ objectId = _ref35.objectId;
953
+ ValidateObject(objectId);
954
+ this.Log("Retrieving group permissions for object ".concat(objectId));
955
+ contractAddress = this.utils.HashToAddress(objectId); // Access indexor only available on access groups, so must ask each access group
956
+ // we belong to about this object
957
+ _context22.next = 6;
958
+ return this.Collection({
959
+ collectionType: "accessGroups"
960
+ });
961
+ case 6:
962
+ groupAddresses = _context22.sent;
963
+ _context22.next = 9;
964
+ return this.AccessType({
965
+ id: objectId
966
+ });
967
+ case 9:
968
+ _context22.t0 = _context22.sent;
969
+ _context22.next = _context22.t0 === this.authClient.ACCESS_TYPES.OBJECT ? 12 : _context22.t0 === this.authClient.ACCESS_TYPES.TYPE ? 14 : _context22.t0 === this.authClient.ACCESS_TYPES.GROUP ? 16 : _context22.t0 === this.authClient.ACCESS_TYPES.LIBRARY ? 18 : 19;
970
+ break;
971
+ case 12:
972
+ rightsMethod = "getContentObjectRights";
973
+ return _context22.abrupt("break", 19);
974
+ case 14:
975
+ rightsMethod = "getContentTypeRights";
976
+ return _context22.abrupt("break", 19);
977
+ case 16:
978
+ rightsMethod = "getAccessGroupRights";
979
+ return _context22.abrupt("break", 19);
980
+ case 18:
981
+ rightsMethod = "getLibraryRights";
982
+ case 19:
983
+ groupPermissions = {};
984
+ _context22.next = 22;
985
+ return Promise.all(groupAddresses.map( /*#__PURE__*/function () {
986
+ var _ref37 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(groupAddress) {
987
+ var permission, permissions;
988
+ return _regeneratorRuntime.wrap(function _callee21$(_context21) {
989
+ while (1) switch (_context21.prev = _context21.next) {
990
+ case 0:
991
+ _context21.prev = 0;
992
+ groupAddress = _this5.utils.FormatAddress(groupAddress);
993
+ _context21.next = 4;
994
+ return _this5.CallContractMethod({
995
+ contractAddress: groupAddress,
996
+ methodName: rightsMethod,
997
+ methodArgs: [contractAddress]
998
+ });
999
+ case 4:
1000
+ permission = _context21.sent;
1001
+ if (!(permission === 0)) {
1002
+ _context21.next = 7;
1003
+ break;
1226
1004
  }
1227
- }
1228
- }, _callee21, null, [[0, 14]]);
1229
- }));
1230
-
1231
- return function (_x22) {
1232
- return _ref37.apply(this, arguments);
1233
- };
1234
- }()));
1235
-
1236
- case 22:
1237
- return _context22.abrupt("return", groupPermissions);
1238
-
1239
- case 23:
1240
- case "end":
1241
- return _context22.stop();
1242
- }
1005
+ return _context21.abrupt("return");
1006
+ case 7:
1007
+ permissions = [];
1008
+ if (permission >= 100) {
1009
+ permissions.push("manage");
1010
+ }
1011
+ if (permission % 100 >= 10) {
1012
+ permissions.push("access");
1013
+ }
1014
+ if (permission % 10 > 0) {
1015
+ permissions.push("see");
1016
+ }
1017
+ groupPermissions[groupAddress] = permissions;
1018
+ _context21.next = 18;
1019
+ break;
1020
+ case 14:
1021
+ _context21.prev = 14;
1022
+ _context21.t0 = _context21["catch"](0);
1023
+ _this5.Log("Failed to retrieve group permissions for ".concat(groupAddress), true);
1024
+ _this5.Log(_context21.t0, true);
1025
+ case 18:
1026
+ case "end":
1027
+ return _context21.stop();
1028
+ }
1029
+ }, _callee21, null, [[0, 14]]);
1030
+ }));
1031
+ return function (_x22) {
1032
+ return _ref37.apply(this, arguments);
1033
+ };
1034
+ }()));
1035
+ case 22:
1036
+ return _context22.abrupt("return", groupPermissions);
1037
+ case 23:
1038
+ case "end":
1039
+ return _context22.stop();
1243
1040
  }
1244
1041
  }, _callee22, this);
1245
1042
  }));
1246
-
1247
1043
  return function (_x21) {
1248
1044
  return _ref36.apply(this, arguments);
1249
1045
  };
1250
1046
  }();
1047
+
1251
1048
  /**
1252
1049
  * Add a permission on the specified group for the specified object or content type
1253
1050
  *
@@ -1258,61 +1055,49 @@ exports.ContentObjectGroupPermissions = /*#__PURE__*/function () {
1258
1055
  * @param {string} groupAddress - The address of the group
1259
1056
  * @param {string} permission - The type of permission to add ("see", "access", "manage")
1260
1057
  */
1261
-
1262
-
1263
1058
  exports.AddContentObjectGroupPermission = /*#__PURE__*/function () {
1264
1059
  var _ref39 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref38) {
1265
1060
  var objectId, groupAddress, permission;
1266
1061
  return _regeneratorRuntime.wrap(function _callee23$(_context23) {
1267
- while (1) {
1268
- switch (_context23.prev = _context23.next) {
1269
- case 0:
1270
- objectId = _ref38.objectId, groupAddress = _ref38.groupAddress, permission = _ref38.permission;
1271
- ValidatePresence("permission", permission);
1272
- ValidateObject(objectId);
1273
- groupAddress = ValidateAddress(groupAddress);
1274
-
1275
- if (!this.utils.EqualAddress(groupAddress, this.utils.HashToAddress(objectId))) {
1276
- _context23.next = 6;
1277
- break;
1278
- }
1279
-
1280
- throw Error("Group rights cannot be set on the same group");
1281
-
1282
- case 6:
1283
- permission = permission.toLowerCase();
1284
-
1285
- if (["see", "access", "manage"].includes(permission)) {
1286
- _context23.next = 9;
1287
- break;
1288
- }
1289
-
1290
- throw Error("Invalid permission type: ".concat(permission));
1291
-
1292
- case 9:
1293
- this.Log("Adding ".concat(permission, " permission to group ").concat(groupAddress, " for ").concat(objectId));
1294
- _context23.next = 12;
1295
- return this.SetGroupPermission({
1296
- groupAddress: groupAddress,
1297
- objectId: objectId,
1298
- permission: permission
1299
- });
1300
-
1301
- case 12:
1302
- return _context23.abrupt("return", _context23.sent);
1303
-
1304
- case 13:
1305
- case "end":
1306
- return _context23.stop();
1307
- }
1062
+ while (1) switch (_context23.prev = _context23.next) {
1063
+ case 0:
1064
+ objectId = _ref38.objectId, groupAddress = _ref38.groupAddress, permission = _ref38.permission;
1065
+ ValidatePresence("permission", permission);
1066
+ ValidateObject(objectId);
1067
+ groupAddress = ValidateAddress(groupAddress);
1068
+ if (!this.utils.EqualAddress(groupAddress, this.utils.HashToAddress(objectId))) {
1069
+ _context23.next = 6;
1070
+ break;
1071
+ }
1072
+ throw Error("Group rights cannot be set on the same group");
1073
+ case 6:
1074
+ permission = permission.toLowerCase();
1075
+ if (["see", "access", "manage"].includes(permission)) {
1076
+ _context23.next = 9;
1077
+ break;
1078
+ }
1079
+ throw Error("Invalid permission type: ".concat(permission));
1080
+ case 9:
1081
+ this.Log("Adding ".concat(permission, " permission to group ").concat(groupAddress, " for ").concat(objectId));
1082
+ _context23.next = 12;
1083
+ return this.SetGroupPermission({
1084
+ groupAddress: groupAddress,
1085
+ objectId: objectId,
1086
+ permission: permission
1087
+ });
1088
+ case 12:
1089
+ return _context23.abrupt("return", _context23.sent);
1090
+ case 13:
1091
+ case "end":
1092
+ return _context23.stop();
1308
1093
  }
1309
1094
  }, _callee23, this);
1310
1095
  }));
1311
-
1312
1096
  return function (_x23) {
1313
1097
  return _ref39.apply(this, arguments);
1314
1098
  };
1315
1099
  }();
1100
+
1316
1101
  /**
1317
1102
  * Remove a permission on the specified group for the specified object or content type
1318
1103
  *
@@ -1323,53 +1108,44 @@ exports.AddContentObjectGroupPermission = /*#__PURE__*/function () {
1323
1108
  * @param {string} groupAddress - The address of the group
1324
1109
  * @param {string} permission - The type of permission to remove ("see", "access", "manage")
1325
1110
  */
1326
-
1327
-
1328
1111
  exports.RemoveContentObjectGroupPermission = /*#__PURE__*/function () {
1329
1112
  var _ref41 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref40) {
1330
1113
  var objectId, groupAddress, permission;
1331
1114
  return _regeneratorRuntime.wrap(function _callee24$(_context24) {
1332
- while (1) {
1333
- switch (_context24.prev = _context24.next) {
1334
- case 0:
1335
- objectId = _ref40.objectId, groupAddress = _ref40.groupAddress, permission = _ref40.permission;
1336
- ValidatePresence("permission", permission);
1337
- ValidateObject(objectId);
1338
- groupAddress = ValidateAddress(groupAddress);
1339
- permission = permission.toLowerCase();
1340
-
1341
- if (["see", "access", "manage"].includes(permission)) {
1342
- _context24.next = 7;
1343
- break;
1344
- }
1345
-
1346
- throw Error("Invalid permission type: ".concat(permission));
1347
-
1348
- case 7:
1349
- this.Log("Removing ".concat(permission, " permission from group ").concat(groupAddress, " for ").concat(objectId));
1350
- _context24.next = 10;
1351
- return this.SetGroupPermission({
1352
- groupAddress: groupAddress,
1353
- objectId: objectId,
1354
- permission: permission,
1355
- remove: true
1356
- });
1357
-
1358
- case 10:
1359
- return _context24.abrupt("return", _context24.sent);
1360
-
1361
- case 11:
1362
- case "end":
1363
- return _context24.stop();
1364
- }
1115
+ while (1) switch (_context24.prev = _context24.next) {
1116
+ case 0:
1117
+ objectId = _ref40.objectId, groupAddress = _ref40.groupAddress, permission = _ref40.permission;
1118
+ ValidatePresence("permission", permission);
1119
+ ValidateObject(objectId);
1120
+ groupAddress = ValidateAddress(groupAddress);
1121
+ permission = permission.toLowerCase();
1122
+ if (["see", "access", "manage"].includes(permission)) {
1123
+ _context24.next = 7;
1124
+ break;
1125
+ }
1126
+ throw Error("Invalid permission type: ".concat(permission));
1127
+ case 7:
1128
+ this.Log("Removing ".concat(permission, " permission from group ").concat(groupAddress, " for ").concat(objectId));
1129
+ _context24.next = 10;
1130
+ return this.SetGroupPermission({
1131
+ groupAddress: groupAddress,
1132
+ objectId: objectId,
1133
+ permission: permission,
1134
+ remove: true
1135
+ });
1136
+ case 10:
1137
+ return _context24.abrupt("return", _context24.sent);
1138
+ case 11:
1139
+ case "end":
1140
+ return _context24.stop();
1365
1141
  }
1366
1142
  }, _callee24, this);
1367
1143
  }));
1368
-
1369
1144
  return function (_x24) {
1370
1145
  return _ref41.apply(this, arguments);
1371
1146
  };
1372
1147
  }();
1148
+
1373
1149
  /**
1374
1150
  * Link the specified group to an OAuth provider with the specified credentials
1375
1151
  *
@@ -1377,143 +1153,121 @@ exports.RemoveContentObjectGroupPermission = /*#__PURE__*/function () {
1377
1153
  * @param {string} kmsId - The ID of the KMS (or trust authority ID)
1378
1154
  * @param {string | Object} oauthConfig - The configuration for the OAuth settings
1379
1155
  */
1380
-
1381
-
1382
1156
  exports.LinkAccessGroupToOauth = /*#__PURE__*/function () {
1383
1157
  var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref42) {
1384
1158
  var groupAddress, kmsId, oauthConfig, _yield$this$authClien2, publicKey, kmsKey, kmsConfig, userKey, userConfig, objectId, writeToken;
1385
-
1386
1159
  return _regeneratorRuntime.wrap(function _callee25$(_context25) {
1387
- while (1) {
1388
- switch (_context25.prev = _context25.next) {
1389
- case 0:
1390
- groupAddress = _ref42.groupAddress, kmsId = _ref42.kmsId, oauthConfig = _ref42.oauthConfig;
1391
- ValidateAddress(groupAddress);
1392
- ValidatePresence("kmsId", kmsId);
1393
- ValidatePresence("oauthConfig", oauthConfig);
1394
-
1395
- if (typeof oauthConfig === "string") {
1396
- oauthConfig = JSON.parse(oauthConfig);
1397
- }
1398
-
1399
- _context25.next = 7;
1400
- return this.authClient.KMSInfo({
1401
- kmsId: kmsId
1402
- });
1403
-
1404
- case 7:
1405
- _yield$this$authClien2 = _context25.sent;
1406
- publicKey = _yield$this$authClien2.publicKey;
1407
- kmsKey = "eluv.jwtv.".concat(kmsId);
1408
- _context25.next = 12;
1409
- return this.Crypto.EncryptConk(oauthConfig, publicKey);
1410
-
1411
- case 12:
1412
- kmsConfig = _context25.sent;
1413
- userKey = "eluv.jwtv.iusr".concat(this.utils.AddressToHash(this.signer.address));
1414
- _context25.next = 16;
1415
- return this.EncryptECIES({
1416
- message: oauthConfig
1417
- });
1418
-
1419
- case 16:
1420
- userConfig = _context25.sent;
1421
- objectId = this.utils.AddressToObjectId(groupAddress);
1422
- _context25.next = 20;
1423
- return this.EditContentObject({
1424
- libraryId: this.contentSpaceLibraryId,
1425
- objectId: objectId
1426
- });
1427
-
1428
- case 20:
1429
- writeToken = _context25.sent.write_token;
1430
- _context25.next = 23;
1431
- return this.ReplaceMetadata({
1432
- libraryId: this.contentSpaceLibraryId,
1433
- objectId: objectId,
1434
- writeToken: writeToken,
1435
- metadataSubtree: kmsKey,
1436
- metadata: kmsConfig
1437
- });
1438
-
1439
- case 23:
1440
- _context25.next = 25;
1441
- return this.ReplaceMetadata({
1442
- libraryId: this.contentSpaceLibraryId,
1443
- objectId: objectId,
1444
- writeToken: writeToken,
1445
- metadataSubtree: userKey,
1446
- metadata: userConfig
1447
- });
1448
-
1449
- case 25:
1450
- _context25.next = 27;
1451
- return this.FinalizeContentObject({
1452
- libraryId: this.contentSpaceLibraryId,
1453
- objectId: objectId,
1454
- writeToken: writeToken,
1455
- commitMessage: "Bind access group to OAuth"
1456
- });
1457
-
1458
- case 27:
1459
- _context25.next = 29;
1460
- return this.CallContractMethodAndWait({
1461
- contractAddress: groupAddress,
1462
- methodName: "setOAuthEnabled",
1463
- methodArgs: [false]
1464
- });
1465
-
1466
- case 29:
1467
- _context25.next = 31;
1468
- return this.CallContractMethodAndWait({
1469
- contractAddress: groupAddress,
1470
- methodName: "setOAuthEnabled",
1471
- methodArgs: [true]
1472
- });
1473
-
1474
- case 31:
1475
- case "end":
1476
- return _context25.stop();
1477
- }
1160
+ while (1) switch (_context25.prev = _context25.next) {
1161
+ case 0:
1162
+ groupAddress = _ref42.groupAddress, kmsId = _ref42.kmsId, oauthConfig = _ref42.oauthConfig;
1163
+ ValidateAddress(groupAddress);
1164
+ ValidatePresence("kmsId", kmsId);
1165
+ ValidatePresence("oauthConfig", oauthConfig);
1166
+ if (typeof oauthConfig === "string") {
1167
+ oauthConfig = JSON.parse(oauthConfig);
1168
+ }
1169
+ _context25.next = 7;
1170
+ return this.authClient.KMSInfo({
1171
+ kmsId: kmsId
1172
+ });
1173
+ case 7:
1174
+ _yield$this$authClien2 = _context25.sent;
1175
+ publicKey = _yield$this$authClien2.publicKey;
1176
+ kmsKey = "eluv.jwtv.".concat(kmsId);
1177
+ _context25.next = 12;
1178
+ return this.Crypto.EncryptConk(oauthConfig, publicKey);
1179
+ case 12:
1180
+ kmsConfig = _context25.sent;
1181
+ userKey = "eluv.jwtv.iusr".concat(this.utils.AddressToHash(this.signer.address));
1182
+ _context25.next = 16;
1183
+ return this.EncryptECIES({
1184
+ message: oauthConfig
1185
+ });
1186
+ case 16:
1187
+ userConfig = _context25.sent;
1188
+ objectId = this.utils.AddressToObjectId(groupAddress);
1189
+ _context25.next = 20;
1190
+ return this.EditContentObject({
1191
+ libraryId: this.contentSpaceLibraryId,
1192
+ objectId: objectId
1193
+ });
1194
+ case 20:
1195
+ writeToken = _context25.sent.write_token;
1196
+ _context25.next = 23;
1197
+ return this.ReplaceMetadata({
1198
+ libraryId: this.contentSpaceLibraryId,
1199
+ objectId: objectId,
1200
+ writeToken: writeToken,
1201
+ metadataSubtree: kmsKey,
1202
+ metadata: kmsConfig
1203
+ });
1204
+ case 23:
1205
+ _context25.next = 25;
1206
+ return this.ReplaceMetadata({
1207
+ libraryId: this.contentSpaceLibraryId,
1208
+ objectId: objectId,
1209
+ writeToken: writeToken,
1210
+ metadataSubtree: userKey,
1211
+ metadata: userConfig
1212
+ });
1213
+ case 25:
1214
+ _context25.next = 27;
1215
+ return this.FinalizeContentObject({
1216
+ libraryId: this.contentSpaceLibraryId,
1217
+ objectId: objectId,
1218
+ writeToken: writeToken,
1219
+ commitMessage: "Bind access group to OAuth"
1220
+ });
1221
+ case 27:
1222
+ _context25.next = 29;
1223
+ return this.CallContractMethodAndWait({
1224
+ contractAddress: groupAddress,
1225
+ methodName: "setOAuthEnabled",
1226
+ methodArgs: [false]
1227
+ });
1228
+ case 29:
1229
+ _context25.next = 31;
1230
+ return this.CallContractMethodAndWait({
1231
+ contractAddress: groupAddress,
1232
+ methodName: "setOAuthEnabled",
1233
+ methodArgs: [true]
1234
+ });
1235
+ case 31:
1236
+ case "end":
1237
+ return _context25.stop();
1478
1238
  }
1479
1239
  }, _callee25, this);
1480
1240
  }));
1481
-
1482
1241
  return function (_x25) {
1483
1242
  return _ref43.apply(this, arguments);
1484
1243
  };
1485
1244
  }();
1245
+
1486
1246
  /**
1487
1247
  * Disable the OAuth linking on the specified access group
1488
1248
  *
1489
1249
  * @param {string} groupAddress - The address of the group
1490
1250
  */
1491
-
1492
-
1493
1251
  exports.UnlinkAccessGroupFromOauth = /*#__PURE__*/function () {
1494
1252
  var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref44) {
1495
1253
  var groupAddress;
1496
1254
  return _regeneratorRuntime.wrap(function _callee26$(_context26) {
1497
- while (1) {
1498
- switch (_context26.prev = _context26.next) {
1499
- case 0:
1500
- groupAddress = _ref44.groupAddress;
1501
- ValidateAddress(groupAddress);
1502
- _context26.next = 4;
1503
- return this.CallContractMethodAndWait({
1504
- contractAddress: groupAddress,
1505
- methodName: "setOAuthEnabled",
1506
- methodArgs: [false]
1507
- });
1508
-
1509
- case 4:
1510
- case "end":
1511
- return _context26.stop();
1512
- }
1255
+ while (1) switch (_context26.prev = _context26.next) {
1256
+ case 0:
1257
+ groupAddress = _ref44.groupAddress;
1258
+ ValidateAddress(groupAddress);
1259
+ _context26.next = 4;
1260
+ return this.CallContractMethodAndWait({
1261
+ contractAddress: groupAddress,
1262
+ methodName: "setOAuthEnabled",
1263
+ methodArgs: [false]
1264
+ });
1265
+ case 4:
1266
+ case "end":
1267
+ return _context26.stop();
1513
1268
  }
1514
1269
  }, _callee26, this);
1515
1270
  }));
1516
-
1517
1271
  return function (_x26) {
1518
1272
  return _ref45.apply(this, arguments);
1519
1273
  };