@eluvio/elv-client-js 4.0.112 → 4.0.114

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