@eluvio/elv-client-js 3.1.96 → 3.1.97

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