@eluvio/elv-client-js 4.0.10 → 4.0.11

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 (40) hide show
  1. package/dist/ElvClient-min.js +10 -11
  2. package/dist/ElvClient-node-min.js +10 -11
  3. package/dist/ElvFrameClient-min.js +10 -11
  4. package/dist/ElvPermissionsClient-min.js +9 -10
  5. package/dist/ElvWalletClient-min.js +9 -10
  6. package/dist/ElvWalletClient-node-min.js +9 -10
  7. package/dist/src/AuthorizationClient.js +2070 -1550
  8. package/dist/src/ContentObjectVerification.js +185 -134
  9. package/dist/src/Crypto.js +319 -224
  10. package/dist/src/ElvClient.js +1114 -822
  11. package/dist/src/ElvWallet.js +106 -64
  12. package/dist/src/EthClient.js +974 -719
  13. package/dist/src/FrameClient.js +318 -222
  14. package/dist/src/HttpClient.js +154 -112
  15. package/dist/src/Id.js +6 -1
  16. package/dist/src/LogMessage.js +8 -4
  17. package/dist/src/PermissionsClient.js +1271 -973
  18. package/dist/src/RemoteSigner.js +232 -161
  19. package/dist/src/UserProfileClient.js +1038 -781
  20. package/dist/src/Utils.js +299 -159
  21. package/dist/src/Validation.js +17 -2
  22. package/dist/src/client/ABRPublishing.js +942 -772
  23. package/dist/src/client/AccessGroups.js +1095 -849
  24. package/dist/src/client/ContentAccess.js +4196 -3323
  25. package/dist/src/client/ContentManagement.js +2288 -1814
  26. package/dist/src/client/Contracts.js +614 -468
  27. package/dist/src/client/Files.js +1831 -1490
  28. package/dist/src/client/NFT.js +116 -94
  29. package/dist/src/client/NTP.js +425 -326
  30. package/dist/src/index.js +5 -2
  31. package/dist/src/walletClient/ClientMethods.js +1763 -1368
  32. package/dist/src/walletClient/Configuration.js +2 -4
  33. package/dist/src/walletClient/Notifications.js +127 -98
  34. package/dist/src/walletClient/Profile.js +246 -184
  35. package/dist/src/walletClient/Utils.js +122 -76
  36. package/dist/src/walletClient/index.js +1496 -1171
  37. package/package.json +1 -1
  38. package/src/AuthorizationClient.js +5 -5
  39. package/src/client/Files.js +1 -1
  40. package/testScripts/CreateMezMonolithic.js +0 -779
@@ -1,9 +1,15 @@
1
1
  var _defineProperty = require("@babel/runtime/helpers/defineProperty");
2
+
2
3
  var _toConsumableArray = require("@babel/runtime/helpers/toConsumableArray");
4
+
3
5
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
6
+
4
7
  var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
8
+
5
9
  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
+
6
11
  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
+
7
13
  /**
8
14
  * Methods for accessing and managing access groups
9
15
  *
@@ -16,157 +22,189 @@ const AccessGroupContract = require("../contracts/BaseAccessControlGroup");
16
22
  const AccessIndexorContract = require("../contracts/AccessIndexor");
17
23
 
18
24
  */
19
-
20
25
  var _require = require("../Validation"),
21
- ValidatePresence = _require.ValidatePresence,
22
- ValidateLibrary = _require.ValidateLibrary,
23
- ValidateObject = _require.ValidateObject,
24
- ValidateAddress = _require.ValidateAddress;
25
-
26
+ ValidatePresence = _require.ValidatePresence,
27
+ ValidateLibrary = _require.ValidateLibrary,
28
+ ValidateObject = _require.ValidateObject,
29
+ ValidateAddress = _require.ValidateAddress;
26
30
  /**
27
31
  * Retrieve a list of all available access groups
28
32
  *
29
33
  * @methodGroup Access Groups
30
34
  * @return {Promise<Array>} - List of access groups
31
35
  */
36
+
37
+
32
38
  exports.ListAccessGroups = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2() {
33
39
  var _this = this;
40
+
34
41
  var addresses, groups;
35
42
  return _regeneratorRuntime.wrap(function _callee2$(_context2) {
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;
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();
64
91
  }
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);
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;
78
107
  }));
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();
108
+
109
+ case 7:
110
+ case "end":
111
+ return _context2.stop();
112
+ }
93
113
  }
94
114
  }, _callee2, this);
95
115
  }));
116
+
96
117
  exports.SetGroupPermission = /*#__PURE__*/function () {
97
118
  var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
98
119
  var groupAddress, objectId, permission, _ref3$remove, remove, groupInfo, objectInfo, event;
120
+
99
121
  return _regeneratorRuntime.wrap(function _callee3$(_context3) {
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;
117
- break;
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;
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;
127
172
  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();
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
+ }
162
200
  }
163
201
  }, _callee3, this);
164
202
  }));
203
+
165
204
  return function (_x2) {
166
205
  return _ref4.apply(this, arguments);
167
206
  };
168
207
  }();
169
-
170
208
  /**
171
209
  * Returns the address of the owner of the specified content object
172
210
  *
@@ -177,32 +215,38 @@ exports.SetGroupPermission = /*#__PURE__*/function () {
177
215
  *
178
216
  * @returns {Promise<string>} - The account address of the owner
179
217
  */
218
+
219
+
180
220
  exports.AccessGroupOwner = /*#__PURE__*/function () {
181
221
  var _ref6 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref5) {
182
222
  var contractAddress;
183
223
  return _regeneratorRuntime.wrap(function _callee4$(_context4) {
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();
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
+ }
198
242
  }
199
243
  }, _callee4, this);
200
244
  }));
245
+
201
246
  return function (_x3) {
202
247
  return _ref6.apply(this, arguments);
203
248
  };
204
249
  }();
205
-
206
250
  /**
207
251
  * Get a list of addresses of members of the specified group
208
252
  *
@@ -213,62 +257,75 @@ exports.AccessGroupOwner = /*#__PURE__*/function () {
213
257
  *
214
258
  * @return {Promise<Array<string>>} - List of member addresses
215
259
  */
260
+
261
+
216
262
  exports.AccessGroupMembers = /*#__PURE__*/function () {
217
263
  var _ref8 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref7) {
218
264
  var _this2 = this;
265
+
219
266
  var contractAddress, length;
220
267
  return _regeneratorRuntime.wrap(function _callee6$(_context6) {
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();
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
+ }
264
321
  }
265
322
  }, _callee6, this);
266
323
  }));
324
+
267
325
  return function (_x4) {
268
326
  return _ref8.apply(this, arguments);
269
327
  };
270
328
  }();
271
-
272
329
  /**
273
330
  * Get a list of addresses of managers of the specified group
274
331
  *
@@ -279,62 +336,75 @@ exports.AccessGroupMembers = /*#__PURE__*/function () {
279
336
  *
280
337
  * @return {Promise<Array<string>>} - List of manager addresses
281
338
  */
339
+
340
+
282
341
  exports.AccessGroupManagers = /*#__PURE__*/function () {
283
342
  var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref10) {
284
343
  var _this3 = this;
344
+
285
345
  var contractAddress, length;
286
346
  return _regeneratorRuntime.wrap(function _callee8$(_context8) {
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();
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
+ }
330
400
  }
331
401
  }, _callee8, this);
332
402
  }));
403
+
333
404
  return function (_x7) {
334
405
  return _ref11.apply(this, arguments);
335
406
  };
336
407
  }();
337
-
338
408
  /**
339
409
  * Create a access group
340
410
  *
@@ -349,68 +419,77 @@ exports.AccessGroupManagers = /*#__PURE__*/function () {
349
419
  *
350
420
  * @returns {Promise<string>} - Contract address of created access group
351
421
  */
422
+
423
+
352
424
  exports.CreateAccessGroup = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9() {
353
425
  var _ref14,
354
- name,
355
- description,
356
- _ref14$metadata,
357
- metadata,
358
- _yield$this$authClien,
359
- contractAddress,
360
- objectId,
361
- editResponse,
362
- _args9 = arguments;
426
+ name,
427
+ description,
428
+ _ref14$metadata,
429
+ metadata,
430
+ _yield$this$authClien,
431
+ contractAddress,
432
+ objectId,
433
+ editResponse,
434
+ _args9 = arguments;
435
+
363
436
  return _regeneratorRuntime.wrap(function _callee9$(_context9) {
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": {
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
+ },
390
469
  name: name,
391
470
  description: description
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();
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
+ }
410
490
  }
411
491
  }, _callee9, this);
412
492
  }));
413
-
414
493
  /**
415
494
  * NOT YET SUPPORTED - Delete an access group
416
495
  *
@@ -421,98 +500,116 @@ exports.CreateAccessGroup = /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regene
421
500
  * @namedParams
422
501
  * @param {string} contractAddress - The address of the access group contract
423
502
  */
503
+
424
504
  exports.DeleteAccessGroup = /*#__PURE__*/function () {
425
505
  var _ref16 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref15) {
426
506
  var contractAddress;
427
507
  return _regeneratorRuntime.wrap(function _callee10$(_context10) {
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();
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
+ }
435
518
  }
436
519
  }, _callee10, this);
437
520
  }));
521
+
438
522
  return function (_x10) {
439
523
  return _ref16.apply(this, arguments);
440
524
  };
441
525
  }();
526
+
442
527
  exports.AccessGroupMembershipMethod = /*#__PURE__*/function () {
443
528
  var _ref18 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref17) {
444
529
  var contractAddress, memberAddress, methodName, eventName, isManager, event, abi, candidate;
445
530
  return _regeneratorRuntime.wrap(function _callee11$(_context11) {
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);
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
451
537
 
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();
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);
600
+
601
+ case 22:
602
+ case "end":
603
+ return _context11.stop();
604
+ }
508
605
  }
509
606
  }, _callee11, this);
510
607
  }));
608
+
511
609
  return function (_x11) {
512
610
  return _ref18.apply(this, arguments);
513
611
  };
514
612
  }();
515
-
516
613
  /**
517
614
  * Add a member to the access group at the specified contract address. This client's signer must
518
615
  * be a manager of the access group.
@@ -525,35 +622,41 @@ exports.AccessGroupMembershipMethod = /*#__PURE__*/function () {
525
622
  *
526
623
  * @returns {Promise<string>} - The transaction hash of the call to the grantAccess method
527
624
  */
625
+
626
+
528
627
  exports.AddAccessGroupMember = /*#__PURE__*/function () {
529
628
  var _ref20 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref19) {
530
629
  var contractAddress, memberAddress;
531
630
  return _regeneratorRuntime.wrap(function _callee12$(_context12) {
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();
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
+ }
549
652
  }
550
653
  }, _callee12, this);
551
654
  }));
655
+
552
656
  return function (_x12) {
553
657
  return _ref20.apply(this, arguments);
554
658
  };
555
659
  }();
556
-
557
660
  /**
558
661
  * Remove a member from the access group at the specified contract address. This client's signer must
559
662
  * be a manager of the access group.
@@ -566,35 +669,41 @@ exports.AddAccessGroupMember = /*#__PURE__*/function () {
566
669
  *
567
670
  * @returns {Promise<string>} - The transaction hash of the call to the revokeAccess method
568
671
  */
672
+
673
+
569
674
  exports.RemoveAccessGroupMember = /*#__PURE__*/function () {
570
675
  var _ref22 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref21) {
571
676
  var contractAddress, memberAddress;
572
677
  return _regeneratorRuntime.wrap(function _callee13$(_context13) {
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();
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
+ }
590
699
  }
591
700
  }, _callee13, this);
592
701
  }));
702
+
593
703
  return function (_x13) {
594
704
  return _ref22.apply(this, arguments);
595
705
  };
596
706
  }();
597
-
598
707
  /**
599
708
  * Add a manager to the access group at the specified contract address. This client's signer must
600
709
  * be a manager of the access group.
@@ -607,35 +716,41 @@ exports.RemoveAccessGroupMember = /*#__PURE__*/function () {
607
716
  *
608
717
  * @returns {Promise<string>} - The transaction hash of the call to the grantManagerAccess method
609
718
  */
719
+
720
+
610
721
  exports.AddAccessGroupManager = /*#__PURE__*/function () {
611
722
  var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref23) {
612
723
  var contractAddress, memberAddress;
613
724
  return _regeneratorRuntime.wrap(function _callee14$(_context14) {
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();
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
+ }
631
746
  }
632
747
  }, _callee14, this);
633
748
  }));
749
+
634
750
  return function (_x14) {
635
751
  return _ref24.apply(this, arguments);
636
752
  };
637
753
  }();
638
-
639
754
  /**
640
755
  * Remove a manager from the access group at the specified contract address. This client's signer must
641
756
  * be a manager of the access group.
@@ -648,35 +763,41 @@ exports.AddAccessGroupManager = /*#__PURE__*/function () {
648
763
  *
649
764
  * @returns {Promise<string>} - The transaction hash of the call to the revokeManagerAccess method
650
765
  */
766
+
767
+
651
768
  exports.RemoveAccessGroupManager = /*#__PURE__*/function () {
652
769
  var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref25) {
653
770
  var contractAddress, memberAddress;
654
771
  return _regeneratorRuntime.wrap(function _callee15$(_context15) {
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();
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
+ }
672
793
  }
673
794
  }, _callee15, this);
674
795
  }));
796
+
675
797
  return function (_x15) {
676
798
  return _ref26.apply(this, arguments);
677
799
  };
678
800
  }();
679
-
680
801
  /**
681
802
  * List all of the groups with permissions on the specified library.
682
803
  *
@@ -689,104 +810,128 @@ exports.RemoveAccessGroupManager = /*#__PURE__*/function () {
689
810
  * @return {Promise<Object>} - Object mapping group addresses to permissions, as an array
690
811
  * - Example: { "0x0": ["accessor", "contributor"], ...}
691
812
  */
813
+
814
+
692
815
  exports.ContentLibraryGroupPermissions = /*#__PURE__*/function () {
693
816
  var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(_ref27) {
694
817
  var _this4 = this;
818
+
695
819
  var libraryId, _ref27$permissions, permissions, libraryPermissions;
820
+
696
821
  return _regeneratorRuntime.wrap(function _callee18$(_context18) {
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();
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));
770
838
  }
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();
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
+ }
782
927
  }
783
928
  }, _callee18, this);
784
929
  }));
930
+
785
931
  return function (_x16) {
786
932
  return _ref28.apply(this, arguments);
787
933
  };
788
934
  }();
789
-
790
935
  /**
791
936
  * Add accessor, contributor or reviewer permissions for the specified group on the specified library
792
937
  *
@@ -797,68 +942,82 @@ exports.ContentLibraryGroupPermissions = /*#__PURE__*/function () {
797
942
  * @param {string} groupAddress - The address of the group
798
943
  * @param {string} permission - The type of permission to add ("accessor", "contributor", "reviewer")
799
944
  */
945
+
946
+
800
947
  exports.AddContentLibraryGroup = /*#__PURE__*/function () {
801
948
  var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref31) {
802
949
  var libraryId, groupAddress, permission, existingPermissions, event, abi;
803
950
  return _regeneratorRuntime.wrap(function _callee19$(_context19) {
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();
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
+ }
854
1013
  }
855
1014
  }, _callee19, this);
856
1015
  }));
1016
+
857
1017
  return function (_x19) {
858
1018
  return _ref32.apply(this, arguments);
859
1019
  };
860
1020
  }();
861
-
862
1021
  /**
863
1022
  * Remove accessor, contributor or reviewer permissions for the specified group on the specified library
864
1023
  *
@@ -869,68 +1028,82 @@ exports.AddContentLibraryGroup = /*#__PURE__*/function () {
869
1028
  * @param {string} groupAddress - The address of the group
870
1029
  * @param {string} permission - The type of permission to remove ("accessor", "contributor", "reviewer")
871
1030
  */
1031
+
1032
+
872
1033
  exports.RemoveContentLibraryGroup = /*#__PURE__*/function () {
873
1034
  var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref33) {
874
1035
  var libraryId, groupAddress, permission, existingPermissions, event, abi;
875
1036
  return _regeneratorRuntime.wrap(function _callee20$(_context20) {
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();
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
+ }
926
1099
  }
927
1100
  }, _callee20, this);
928
1101
  }));
1102
+
929
1103
  return function (_x20) {
930
1104
  return _ref34.apply(this, arguments);
931
1105
  };
932
1106
  }();
933
-
934
1107
  /**
935
1108
  * List all of the groups with permissions on the specified object or content type
936
1109
  *
@@ -942,109 +1115,139 @@ exports.RemoveContentLibraryGroup = /*#__PURE__*/function () {
942
1115
  * @return {Promise<Object>} - Object mapping group addresses to permissions, as an array
943
1116
  * - Example: { "0x0": ["see", "access", "manage"], ...}
944
1117
  */
1118
+
1119
+
945
1120
  exports.ContentObjectGroupPermissions = /*#__PURE__*/function () {
946
1121
  var _ref36 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref35) {
947
1122
  var _this5 = this;
1123
+
948
1124
  var objectId, contractAddress, groupAddresses, rightsMethod, groupPermissions;
949
1125
  return _regeneratorRuntime.wrap(function _callee22$(_context22) {
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;
1004
- }
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");
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();
1016
1226
  }
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();
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
+ }
1040
1243
  }
1041
1244
  }, _callee22, this);
1042
1245
  }));
1246
+
1043
1247
  return function (_x21) {
1044
1248
  return _ref36.apply(this, arguments);
1045
1249
  };
1046
1250
  }();
1047
-
1048
1251
  /**
1049
1252
  * Add a permission on the specified group for the specified object or content type
1050
1253
  *
@@ -1055,49 +1258,61 @@ exports.ContentObjectGroupPermissions = /*#__PURE__*/function () {
1055
1258
  * @param {string} groupAddress - The address of the group
1056
1259
  * @param {string} permission - The type of permission to add ("see", "access", "manage")
1057
1260
  */
1261
+
1262
+
1058
1263
  exports.AddContentObjectGroupPermission = /*#__PURE__*/function () {
1059
1264
  var _ref39 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref38) {
1060
1265
  var objectId, groupAddress, permission;
1061
1266
  return _regeneratorRuntime.wrap(function _callee23$(_context23) {
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();
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
+ }
1093
1308
  }
1094
1309
  }, _callee23, this);
1095
1310
  }));
1311
+
1096
1312
  return function (_x23) {
1097
1313
  return _ref39.apply(this, arguments);
1098
1314
  };
1099
1315
  }();
1100
-
1101
1316
  /**
1102
1317
  * Remove a permission on the specified group for the specified object or content type
1103
1318
  *
@@ -1108,44 +1323,53 @@ exports.AddContentObjectGroupPermission = /*#__PURE__*/function () {
1108
1323
  * @param {string} groupAddress - The address of the group
1109
1324
  * @param {string} permission - The type of permission to remove ("see", "access", "manage")
1110
1325
  */
1326
+
1327
+
1111
1328
  exports.RemoveContentObjectGroupPermission = /*#__PURE__*/function () {
1112
1329
  var _ref41 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref40) {
1113
1330
  var objectId, groupAddress, permission;
1114
1331
  return _regeneratorRuntime.wrap(function _callee24$(_context24) {
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();
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
+ }
1141
1365
  }
1142
1366
  }, _callee24, this);
1143
1367
  }));
1368
+
1144
1369
  return function (_x24) {
1145
1370
  return _ref41.apply(this, arguments);
1146
1371
  };
1147
1372
  }();
1148
-
1149
1373
  /**
1150
1374
  * Link the specified group to an OAuth provider with the specified credentials
1151
1375
  *
@@ -1153,121 +1377,143 @@ exports.RemoveContentObjectGroupPermission = /*#__PURE__*/function () {
1153
1377
  * @param {string} kmsId - The ID of the KMS (or trust authority ID)
1154
1378
  * @param {string | Object} oauthConfig - The configuration for the OAuth settings
1155
1379
  */
1380
+
1381
+
1156
1382
  exports.LinkAccessGroupToOauth = /*#__PURE__*/function () {
1157
1383
  var _ref43 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref42) {
1158
1384
  var groupAddress, kmsId, oauthConfig, _yield$this$authClien2, publicKey, kmsKey, kmsConfig, userKey, userConfig, objectId, writeToken;
1385
+
1159
1386
  return _regeneratorRuntime.wrap(function _callee25$(_context25) {
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();
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
+ }
1238
1478
  }
1239
1479
  }, _callee25, this);
1240
1480
  }));
1481
+
1241
1482
  return function (_x25) {
1242
1483
  return _ref43.apply(this, arguments);
1243
1484
  };
1244
1485
  }();
1245
-
1246
1486
  /**
1247
1487
  * Disable the OAuth linking on the specified access group
1248
1488
  *
1249
1489
  * @param {string} groupAddress - The address of the group
1250
1490
  */
1491
+
1492
+
1251
1493
  exports.UnlinkAccessGroupFromOauth = /*#__PURE__*/function () {
1252
1494
  var _ref45 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref44) {
1253
1495
  var groupAddress;
1254
1496
  return _regeneratorRuntime.wrap(function _callee26$(_context26) {
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();
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
+ }
1268
1513
  }
1269
1514
  }, _callee26, this);
1270
1515
  }));
1516
+
1271
1517
  return function (_x26) {
1272
1518
  return _ref45.apply(this, arguments);
1273
1519
  };