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