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