@eluvio/elv-client-js 4.2.10 → 4.2.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +1 -1
- package/dist/ElvClient-node-min.js +1 -1
- package/dist/ElvFrameClient-min.js +1 -1
- package/dist/ElvPermissionsClient-min.js +1 -1
- package/dist/ElvWalletClient-min.js +1 -1
- package/dist/ElvWalletClient-node-min.js +1 -1
- package/dist/src/AuthorizationClient.js +723 -710
- package/dist/src/ContentObjectAudit.js +56 -56
- package/dist/src/ContentObjectVerification.js +281 -0
- package/dist/src/Crypto.js +85 -85
- package/dist/src/ElvClient.js +500 -530
- package/dist/src/ElvWallet.js +28 -30
- package/dist/src/EthClient.js +311 -311
- package/dist/src/FrameClient.js +64 -63
- package/dist/src/HttpClient.js +60 -60
- package/dist/src/Id.js +2 -1
- package/dist/src/PermissionsClient.js +487 -499
- package/dist/src/RemoteSigner.js +163 -114
- package/dist/src/UserProfileClient.js +374 -392
- package/dist/src/Utils.js +66 -69
- package/dist/src/Validation.js +10 -10
- package/dist/src/client/ABRPublishing.js +238 -238
- package/dist/src/client/AccessGroups.js +474 -477
- package/dist/src/client/ContentAccess.js +1709 -1705
- package/dist/src/client/ContentManagement.js +871 -871
- package/dist/src/client/Contracts.js +578 -575
- package/dist/src/client/Files.js +684 -700
- package/dist/src/client/LiveConf.js +6 -1
- package/dist/src/client/LiveStream.js +686 -723
- package/dist/src/client/NFT.js +14 -14
- package/dist/src/client/NTP.js +84 -84
- package/dist/src/client/Shares.js +60 -53
- package/dist/src/walletClient/ClientMethods.js +951 -977
- package/dist/src/walletClient/Notifications.js +14 -14
- package/dist/src/walletClient/Profile.js +66 -66
- package/dist/src/walletClient/Utils.js +15 -15
- package/dist/src/walletClient/index.js +581 -579
- package/package.json +1 -1
- package/src/client/LiveConf.js +5 -1
- package/src/client/LiveStream.js +9 -39
|
@@ -124,7 +124,7 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
124
124
|
this.drafts = {};
|
|
125
125
|
this.offline = options.offline;
|
|
126
126
|
}
|
|
127
|
-
|
|
127
|
+
_createClass(PermissionsClient, [{
|
|
128
128
|
key: "FormatDate",
|
|
129
129
|
value: function FormatDate(date) {
|
|
130
130
|
if (!date) {
|
|
@@ -176,150 +176,150 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
176
176
|
}, {
|
|
177
177
|
key: "FormatPermission",
|
|
178
178
|
value: function () {
|
|
179
|
-
var _FormatPermission = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
180
|
-
var policyId, policyWriteToken, permission, subjectSource, subjectType, subjectId, subjectName, subjectNTPId, id, cachedName, contentSpaceLibraryId, permissionSpec
|
|
181
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
179
|
+
var _FormatPermission = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
180
|
+
var policyId, policyWriteToken, permission, subjectSource, subjectType, subjectId, subjectName, subjectNTPId, id, cachedName, contentSpaceLibraryId, permissionSpec;
|
|
181
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
182
182
|
while (1) switch (_context.prev = _context.next) {
|
|
183
183
|
case 0:
|
|
184
184
|
policyId = _ref.policyId, policyWriteToken = _ref.policyWriteToken, permission = _ref.permission;
|
|
185
185
|
subjectSource = permission.subject.type.startsWith("oauth") ? "oauth" : "fabric";
|
|
186
|
-
|
|
187
|
-
_context.next =
|
|
186
|
+
_context.t0 = permission.subject.type;
|
|
187
|
+
_context.next = _context.t0 === "otp" ? 5 : _context.t0 === "otp_subject" ? 8 : _context.t0 === "group" ? 13 : _context.t0 === "oauth_group" ? 13 : _context.t0 === "user" ? 16 : _context.t0 === "oauth_user" ? 16 : 19;
|
|
188
188
|
break;
|
|
189
|
-
case
|
|
189
|
+
case 5:
|
|
190
190
|
subjectType = "ntp";
|
|
191
191
|
subjectId = permission.subject.id;
|
|
192
|
-
return _context.abrupt("
|
|
193
|
-
case
|
|
192
|
+
return _context.abrupt("break", 20);
|
|
193
|
+
case 8:
|
|
194
194
|
subjectType = "ntp_subject";
|
|
195
195
|
subjectId = permission.subject.id;
|
|
196
196
|
subjectName = subjectId;
|
|
197
197
|
subjectNTPId = permission.subject.otp_id;
|
|
198
|
-
return _context.abrupt("
|
|
199
|
-
case
|
|
198
|
+
return _context.abrupt("break", 20);
|
|
199
|
+
case 13:
|
|
200
200
|
subjectType = "group";
|
|
201
201
|
subjectId = subjectSource === "oauth" ? permission.subject.oauth_id : this.client.utils.HashToAddress(permission.subject.id);
|
|
202
|
-
return _context.abrupt("
|
|
203
|
-
case
|
|
202
|
+
return _context.abrupt("break", 20);
|
|
203
|
+
case 16:
|
|
204
204
|
subjectType = "user";
|
|
205
205
|
subjectId = subjectSource === "oauth" ? permission.subject.oauth_id : this.client.utils.HashToAddress(permission.subject.id);
|
|
206
|
-
return _context.abrupt("
|
|
207
|
-
case
|
|
206
|
+
return _context.abrupt("break", 20);
|
|
207
|
+
case 19:
|
|
208
208
|
throw Error("Unknown subject type: " + permission.subject.type);
|
|
209
|
-
case
|
|
209
|
+
case 20:
|
|
210
210
|
id = permission.subject.oauth_id || permission.subject.id;
|
|
211
211
|
cachedName = this.subjectNames[id];
|
|
212
212
|
subjectName = subjectName || cachedName || permission.subject.id;
|
|
213
213
|
if (!(!cachedName && subjectSource === "fabric")) {
|
|
214
|
-
_context.next =
|
|
214
|
+
_context.next = 74;
|
|
215
215
|
break;
|
|
216
216
|
}
|
|
217
217
|
if (!(subjectType === "group")) {
|
|
218
|
-
_context.next =
|
|
218
|
+
_context.next = 36;
|
|
219
219
|
break;
|
|
220
220
|
}
|
|
221
|
-
_context.next =
|
|
221
|
+
_context.next = 27;
|
|
222
222
|
return this.client.ContentSpaceId();
|
|
223
|
-
case
|
|
223
|
+
case 27:
|
|
224
224
|
contentSpaceLibraryId = _context.sent.replace("ispc", "ilib");
|
|
225
|
-
_context.next =
|
|
225
|
+
_context.next = 30;
|
|
226
226
|
return this.client.ContentObjectMetadata({
|
|
227
227
|
libraryId: contentSpaceLibraryId,
|
|
228
228
|
objectId: this.client.utils.AddressToObjectId(subjectId),
|
|
229
229
|
metadataSubtree: UrlJoin("public", "name")
|
|
230
230
|
});
|
|
231
|
-
case
|
|
232
|
-
|
|
233
|
-
if (
|
|
234
|
-
_context.next =
|
|
231
|
+
case 30:
|
|
232
|
+
_context.t1 = _context.sent;
|
|
233
|
+
if (_context.t1) {
|
|
234
|
+
_context.next = 33;
|
|
235
235
|
break;
|
|
236
236
|
}
|
|
237
|
-
|
|
238
|
-
case
|
|
239
|
-
subjectName =
|
|
240
|
-
_context.next =
|
|
237
|
+
_context.t1 = subjectId;
|
|
238
|
+
case 33:
|
|
239
|
+
subjectName = _context.t1;
|
|
240
|
+
_context.next = 74;
|
|
241
241
|
break;
|
|
242
|
-
case
|
|
242
|
+
case 36:
|
|
243
243
|
if (!(subjectType === "user")) {
|
|
244
|
-
_context.next =
|
|
244
|
+
_context.next = 56;
|
|
245
245
|
break;
|
|
246
246
|
}
|
|
247
|
-
|
|
248
|
-
_context.next =
|
|
247
|
+
_context.t4 = this.client;
|
|
248
|
+
_context.next = 40;
|
|
249
249
|
return this.client.ContentObjectLibraryId({
|
|
250
250
|
objectId: policyId
|
|
251
251
|
});
|
|
252
|
-
case
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
libraryId:
|
|
259
|
-
objectId:
|
|
260
|
-
writeToken:
|
|
261
|
-
metadataSubtree:
|
|
252
|
+
case 40:
|
|
253
|
+
_context.t5 = _context.sent;
|
|
254
|
+
_context.t6 = policyId;
|
|
255
|
+
_context.t7 = policyWriteToken;
|
|
256
|
+
_context.t8 = UrlJoin("auth_policy_settings", "fabric_users", subjectId);
|
|
257
|
+
_context.t9 = {
|
|
258
|
+
libraryId: _context.t5,
|
|
259
|
+
objectId: _context.t6,
|
|
260
|
+
writeToken: _context.t7,
|
|
261
|
+
metadataSubtree: _context.t8
|
|
262
262
|
};
|
|
263
|
-
_context.next =
|
|
264
|
-
return
|
|
265
|
-
case
|
|
266
|
-
|
|
267
|
-
if (
|
|
268
|
-
_context.next =
|
|
263
|
+
_context.next = 47;
|
|
264
|
+
return _context.t4.ContentObjectMetadata.call(_context.t4, _context.t9);
|
|
265
|
+
case 47:
|
|
266
|
+
_context.t3 = _context.sent;
|
|
267
|
+
if (_context.t3) {
|
|
268
|
+
_context.next = 50;
|
|
269
269
|
break;
|
|
270
270
|
}
|
|
271
|
-
|
|
272
|
-
case
|
|
273
|
-
|
|
274
|
-
if (
|
|
275
|
-
_context.next =
|
|
271
|
+
_context.t3 = {};
|
|
272
|
+
case 50:
|
|
273
|
+
_context.t2 = _context.t3.name;
|
|
274
|
+
if (_context.t2) {
|
|
275
|
+
_context.next = 53;
|
|
276
276
|
break;
|
|
277
277
|
}
|
|
278
|
-
|
|
279
|
-
case
|
|
280
|
-
subjectName =
|
|
281
|
-
_context.next =
|
|
278
|
+
_context.t2 = subjectId;
|
|
279
|
+
case 53:
|
|
280
|
+
subjectName = _context.t2;
|
|
281
|
+
_context.next = 74;
|
|
282
282
|
break;
|
|
283
|
-
case
|
|
283
|
+
case 56:
|
|
284
284
|
if (!(subjectType === "ntp")) {
|
|
285
|
-
_context.next =
|
|
285
|
+
_context.next = 74;
|
|
286
286
|
break;
|
|
287
287
|
}
|
|
288
|
-
|
|
289
|
-
_context.next =
|
|
288
|
+
_context.t12 = this.client;
|
|
289
|
+
_context.next = 60;
|
|
290
290
|
return this.client.ContentObjectLibraryId({
|
|
291
291
|
objectId: policyId
|
|
292
292
|
});
|
|
293
|
-
case
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
libraryId:
|
|
300
|
-
objectId:
|
|
301
|
-
writeToken:
|
|
302
|
-
metadataSubtree:
|
|
293
|
+
case 60:
|
|
294
|
+
_context.t13 = _context.sent;
|
|
295
|
+
_context.t14 = policyId;
|
|
296
|
+
_context.t15 = policyWriteToken;
|
|
297
|
+
_context.t16 = UrlJoin("auth_policy_settings", "ntp_instances", subjectId);
|
|
298
|
+
_context.t17 = {
|
|
299
|
+
libraryId: _context.t13,
|
|
300
|
+
objectId: _context.t14,
|
|
301
|
+
writeToken: _context.t15,
|
|
302
|
+
metadataSubtree: _context.t16
|
|
303
303
|
};
|
|
304
|
-
_context.next =
|
|
305
|
-
return
|
|
306
|
-
case
|
|
307
|
-
|
|
308
|
-
if (
|
|
309
|
-
_context.next =
|
|
304
|
+
_context.next = 67;
|
|
305
|
+
return _context.t12.ContentObjectMetadata.call(_context.t12, _context.t17);
|
|
306
|
+
case 67:
|
|
307
|
+
_context.t11 = _context.sent;
|
|
308
|
+
if (_context.t11) {
|
|
309
|
+
_context.next = 70;
|
|
310
310
|
break;
|
|
311
311
|
}
|
|
312
|
-
|
|
313
|
-
case
|
|
314
|
-
|
|
315
|
-
if (
|
|
316
|
-
_context.next =
|
|
312
|
+
_context.t11 = {};
|
|
313
|
+
case 70:
|
|
314
|
+
_context.t10 = _context.t11.name;
|
|
315
|
+
if (_context.t10) {
|
|
316
|
+
_context.next = 73;
|
|
317
317
|
break;
|
|
318
318
|
}
|
|
319
|
-
|
|
320
|
-
case
|
|
321
|
-
subjectName =
|
|
322
|
-
case
|
|
319
|
+
_context.t10 = subjectId;
|
|
320
|
+
case 73:
|
|
321
|
+
subjectName = _context.t10;
|
|
322
|
+
case 74:
|
|
323
323
|
this.subjectNames[id] = subjectName;
|
|
324
324
|
permissionSpec = {
|
|
325
325
|
profileName: permission.profile,
|
|
@@ -338,7 +338,7 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
338
338
|
permissionSpec.end = permission.end;
|
|
339
339
|
}
|
|
340
340
|
return _context.abrupt("return", permissionSpec);
|
|
341
|
-
case
|
|
341
|
+
case 80:
|
|
342
342
|
case "end":
|
|
343
343
|
return _context.stop();
|
|
344
344
|
}
|
|
@@ -362,38 +362,38 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
362
362
|
*/
|
|
363
363
|
}, {
|
|
364
364
|
key: "OpenOfflineDraft",
|
|
365
|
-
value:
|
|
366
|
-
var _OpenOfflineDraft = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
|
|
365
|
+
value: function () {
|
|
366
|
+
var _OpenOfflineDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
|
|
367
367
|
var policyId, policyLibraryId, policyWriteToken, meta;
|
|
368
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
368
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
369
369
|
while (1) switch (_context2.prev = _context2.next) {
|
|
370
370
|
case 0:
|
|
371
371
|
policyId = _ref2.policyId, policyLibraryId = _ref2.policyLibraryId, policyWriteToken = _ref2.policyWriteToken;
|
|
372
372
|
if (!(policyLibraryId == null)) {
|
|
373
|
-
_context2.next =
|
|
373
|
+
_context2.next = 5;
|
|
374
374
|
break;
|
|
375
375
|
}
|
|
376
|
-
_context2.next =
|
|
376
|
+
_context2.next = 4;
|
|
377
377
|
return this.client.ContentObjectLibraryId({
|
|
378
378
|
objectId: policyId
|
|
379
379
|
});
|
|
380
|
-
case
|
|
380
|
+
case 4:
|
|
381
381
|
policyLibraryId = _context2.sent;
|
|
382
|
-
case
|
|
383
|
-
_context2.next =
|
|
382
|
+
case 5:
|
|
383
|
+
_context2.next = 7;
|
|
384
384
|
return this.client.ContentObjectMetadata({
|
|
385
385
|
libraryId: policyLibraryId,
|
|
386
386
|
objectId: policyId,
|
|
387
387
|
writeToken: policyWriteToken
|
|
388
388
|
});
|
|
389
|
-
case
|
|
389
|
+
case 7:
|
|
390
390
|
meta = _context2.sent;
|
|
391
391
|
this.drafts[policyId] = {
|
|
392
392
|
meta: meta,
|
|
393
393
|
policyLibraryId: policyLibraryId,
|
|
394
394
|
policyWriteToken: policyWriteToken
|
|
395
395
|
};
|
|
396
|
-
case
|
|
396
|
+
case 9:
|
|
397
397
|
case "end":
|
|
398
398
|
return _context2.stop();
|
|
399
399
|
}
|
|
@@ -412,32 +412,31 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
412
412
|
* @namedParams
|
|
413
413
|
* @param {string} policyId - Object ID of the policy
|
|
414
414
|
*/
|
|
415
|
-
)
|
|
416
415
|
}, {
|
|
417
416
|
key: "CloseOfflineDraft",
|
|
418
|
-
value:
|
|
419
|
-
var _CloseOfflineDraft = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
|
|
417
|
+
value: function () {
|
|
418
|
+
var _CloseOfflineDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
|
|
420
419
|
var policyId;
|
|
421
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
420
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
422
421
|
while (1) switch (_context3.prev = _context3.next) {
|
|
423
422
|
case 0:
|
|
424
423
|
policyId = _ref3.policyId;
|
|
425
424
|
if (!(this.drafts[policyId] == null)) {
|
|
426
|
-
_context3.next =
|
|
425
|
+
_context3.next = 3;
|
|
427
426
|
break;
|
|
428
427
|
}
|
|
429
428
|
throw Error("No draft open for policyId: " + policyId);
|
|
430
|
-
case
|
|
431
|
-
_context3.next =
|
|
429
|
+
case 3:
|
|
430
|
+
_context3.next = 5;
|
|
432
431
|
return this.client.ReplaceMetadata({
|
|
433
432
|
libraryId: this.drafts[policyId].policyLibraryId,
|
|
434
433
|
objectId: policyId,
|
|
435
434
|
writeToken: this.drafts[policyId].policyWriteToken,
|
|
436
435
|
metadata: this.drafts[policyId].meta
|
|
437
436
|
});
|
|
438
|
-
case
|
|
437
|
+
case 5:
|
|
439
438
|
this.drafts[policyId] = null;
|
|
440
|
-
case
|
|
439
|
+
case 6:
|
|
441
440
|
case "end":
|
|
442
441
|
return _context3.stop();
|
|
443
442
|
}
|
|
@@ -458,45 +457,44 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
458
457
|
* @param {string=} policyWriteToken - Write token for the policy object - if specified, info will be retrieved from the write draft instead of the last finalized policy object
|
|
459
458
|
* @return {Promise<Object>} - A mapping of item objectId to the display name of the item
|
|
460
459
|
*/
|
|
461
|
-
)
|
|
462
460
|
}, {
|
|
463
461
|
key: "PolicyItems",
|
|
464
|
-
value:
|
|
465
|
-
var _PolicyItems = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref4) {
|
|
466
|
-
var policyId, policyWriteToken
|
|
467
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
462
|
+
value: function () {
|
|
463
|
+
var _PolicyItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref4) {
|
|
464
|
+
var policyId, policyWriteToken;
|
|
465
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
468
466
|
while (1) switch (_context4.prev = _context4.next) {
|
|
469
467
|
case 0:
|
|
470
468
|
policyId = _ref4.policyId, policyWriteToken = _ref4.policyWriteToken;
|
|
471
|
-
|
|
472
|
-
_context4.next =
|
|
469
|
+
_context4.t1 = this.client;
|
|
470
|
+
_context4.next = 4;
|
|
473
471
|
return this.client.ContentObjectLibraryId({
|
|
474
472
|
objectId: policyId
|
|
475
473
|
});
|
|
476
|
-
case
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
libraryId:
|
|
483
|
-
objectId:
|
|
484
|
-
writeToken:
|
|
474
|
+
case 4:
|
|
475
|
+
_context4.t2 = _context4.sent;
|
|
476
|
+
_context4.t3 = policyId;
|
|
477
|
+
_context4.t4 = policyWriteToken;
|
|
478
|
+
_context4.t5 = ["*/display_title"];
|
|
479
|
+
_context4.t6 = {
|
|
480
|
+
libraryId: _context4.t2,
|
|
481
|
+
objectId: _context4.t3,
|
|
482
|
+
writeToken: _context4.t4,
|
|
485
483
|
metadataSubtree: "auth_policy_spec",
|
|
486
|
-
select:
|
|
484
|
+
select: _context4.t5
|
|
487
485
|
};
|
|
488
|
-
_context4.next =
|
|
489
|
-
return
|
|
490
|
-
case
|
|
491
|
-
|
|
492
|
-
if (
|
|
493
|
-
_context4.next =
|
|
486
|
+
_context4.next = 11;
|
|
487
|
+
return _context4.t1.ContentObjectMetadata.call(_context4.t1, _context4.t6);
|
|
488
|
+
case 11:
|
|
489
|
+
_context4.t0 = _context4.sent;
|
|
490
|
+
if (_context4.t0) {
|
|
491
|
+
_context4.next = 14;
|
|
494
492
|
break;
|
|
495
493
|
}
|
|
496
|
-
|
|
497
|
-
case
|
|
498
|
-
return _context4.abrupt("return",
|
|
499
|
-
case
|
|
494
|
+
_context4.t0 = {};
|
|
495
|
+
case 14:
|
|
496
|
+
return _context4.abrupt("return", _context4.t0);
|
|
497
|
+
case 15:
|
|
500
498
|
case "end":
|
|
501
499
|
return _context4.stop();
|
|
502
500
|
}
|
|
@@ -517,43 +515,42 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
517
515
|
* @param {string} itemId - Object ID of the item
|
|
518
516
|
* @return {Promise<Object | undefined>} - The policy for the specified item. If none exists, returns undefined
|
|
519
517
|
*/
|
|
520
|
-
)
|
|
521
518
|
}, {
|
|
522
519
|
key: "ItemPolicy",
|
|
523
|
-
value:
|
|
524
|
-
var _ItemPolicy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
|
|
520
|
+
value: function () {
|
|
521
|
+
var _ItemPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
|
|
525
522
|
var policyId, policyWriteToken, itemId, profiles, permissions;
|
|
526
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
523
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
527
524
|
while (1) switch (_context5.prev = _context5.next) {
|
|
528
525
|
case 0:
|
|
529
526
|
policyId = _ref5.policyId, policyWriteToken = _ref5.policyWriteToken, itemId = _ref5.itemId;
|
|
530
|
-
_context5.next =
|
|
527
|
+
_context5.next = 3;
|
|
531
528
|
return this.ItemProfiles({
|
|
532
529
|
policyId: policyId,
|
|
533
530
|
policyWriteToken: policyWriteToken,
|
|
534
531
|
itemId: itemId
|
|
535
532
|
});
|
|
536
|
-
case
|
|
533
|
+
case 3:
|
|
537
534
|
profiles = _context5.sent;
|
|
538
|
-
_context5.next =
|
|
535
|
+
_context5.next = 6;
|
|
539
536
|
return this.ItemPermissions({
|
|
540
537
|
policyId: policyId,
|
|
541
538
|
policyWriteToken: policyWriteToken,
|
|
542
539
|
itemId: itemId
|
|
543
540
|
});
|
|
544
|
-
case
|
|
541
|
+
case 6:
|
|
545
542
|
permissions = _context5.sent;
|
|
546
543
|
if (!(!profiles || !permissions)) {
|
|
547
|
-
_context5.next =
|
|
544
|
+
_context5.next = 9;
|
|
548
545
|
break;
|
|
549
546
|
}
|
|
550
547
|
return _context5.abrupt("return");
|
|
551
|
-
case
|
|
548
|
+
case 9:
|
|
552
549
|
return _context5.abrupt("return", {
|
|
553
550
|
profiles: profiles,
|
|
554
551
|
permissions: permissions
|
|
555
552
|
});
|
|
556
|
-
case
|
|
553
|
+
case 10:
|
|
557
554
|
case "end":
|
|
558
555
|
return _context5.stop();
|
|
559
556
|
}
|
|
@@ -574,14 +571,13 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
574
571
|
* @param {string} itemId - Object ID of the item
|
|
575
572
|
* @param {object=} profiles={} - Profiles to create
|
|
576
573
|
*/
|
|
577
|
-
)
|
|
578
574
|
}, {
|
|
579
575
|
key: "CreateItemPolicy",
|
|
580
|
-
value:
|
|
581
|
-
var _CreateItemPolicy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref6) {
|
|
576
|
+
value: function () {
|
|
577
|
+
var _CreateItemPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref6) {
|
|
582
578
|
var _this2 = this;
|
|
583
|
-
var policyId, policyWriteToken, itemId, _ref6$profiles, profiles, metadata, assetMetadata, displayTitle, itemSpec
|
|
584
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
579
|
+
var policyId, policyWriteToken, itemId, _ref6$profiles, profiles, metadata, assetMetadata, displayTitle, itemSpec;
|
|
580
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
585
581
|
while (1) switch (_context6.prev = _context6.next) {
|
|
586
582
|
case 0:
|
|
587
583
|
policyId = _ref6.policyId, policyWriteToken = _ref6.policyWriteToken, itemId = _ref6.itemId, _ref6$profiles = _ref6.profiles, profiles = _ref6$profiles === void 0 ? {} : _ref6$profiles;
|
|
@@ -589,31 +585,31 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
589
585
|
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
590
586
|
ValidatePresence("itemId", itemId);
|
|
591
587
|
ValidatePresence("profiles", profiles);
|
|
592
|
-
|
|
593
|
-
_context6.next =
|
|
588
|
+
_context6.t1 = this.client;
|
|
589
|
+
_context6.next = 8;
|
|
594
590
|
return this.client.ContentObjectLibraryId({
|
|
595
591
|
objectId: itemId
|
|
596
592
|
});
|
|
597
|
-
case
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
libraryId:
|
|
603
|
-
objectId:
|
|
604
|
-
select:
|
|
593
|
+
case 8:
|
|
594
|
+
_context6.t2 = _context6.sent;
|
|
595
|
+
_context6.t3 = itemId;
|
|
596
|
+
_context6.t4 = ["public/name", "public/asset_metadata/title", "public/asset_metadata/display_title"];
|
|
597
|
+
_context6.t5 = {
|
|
598
|
+
libraryId: _context6.t2,
|
|
599
|
+
objectId: _context6.t3,
|
|
600
|
+
select: _context6.t4
|
|
605
601
|
};
|
|
606
|
-
_context6.next =
|
|
607
|
-
return
|
|
608
|
-
case
|
|
609
|
-
|
|
610
|
-
if (
|
|
611
|
-
_context6.next =
|
|
602
|
+
_context6.next = 14;
|
|
603
|
+
return _context6.t1.ContentObjectMetadata.call(_context6.t1, _context6.t5);
|
|
604
|
+
case 14:
|
|
605
|
+
_context6.t0 = _context6.sent;
|
|
606
|
+
if (_context6.t0) {
|
|
607
|
+
_context6.next = 17;
|
|
612
608
|
break;
|
|
613
609
|
}
|
|
614
|
-
|
|
615
|
-
case
|
|
616
|
-
metadata =
|
|
610
|
+
_context6.t0 = {};
|
|
611
|
+
case 17:
|
|
612
|
+
metadata = _context6.t0;
|
|
617
613
|
assetMetadata = (metadata["public"] || {}).asset_metadata || {};
|
|
618
614
|
displayTitle = assetMetadata.display_title || assetMetadata.title || (metadata["public"] || {}).name;
|
|
619
615
|
itemSpec = {
|
|
@@ -624,27 +620,27 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
624
620
|
Object.keys(profiles).forEach(function (profileName) {
|
|
625
621
|
itemSpec.profiles[profileName] = _this2.FormatProfile(profiles[profileName]);
|
|
626
622
|
});
|
|
627
|
-
|
|
628
|
-
_context6.next =
|
|
623
|
+
_context6.t6 = this.client;
|
|
624
|
+
_context6.next = 25;
|
|
629
625
|
return this.client.ContentObjectLibraryId({
|
|
630
626
|
objectId: policyId
|
|
631
627
|
});
|
|
632
|
-
case
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
libraryId:
|
|
640
|
-
objectId:
|
|
641
|
-
writeToken:
|
|
642
|
-
metadataSubtree:
|
|
643
|
-
metadata:
|
|
628
|
+
case 25:
|
|
629
|
+
_context6.t7 = _context6.sent;
|
|
630
|
+
_context6.t8 = policyId;
|
|
631
|
+
_context6.t9 = policyWriteToken;
|
|
632
|
+
_context6.t10 = UrlJoin("auth_policy_spec", itemId);
|
|
633
|
+
_context6.t11 = itemSpec;
|
|
634
|
+
_context6.t12 = {
|
|
635
|
+
libraryId: _context6.t7,
|
|
636
|
+
objectId: _context6.t8,
|
|
637
|
+
writeToken: _context6.t9,
|
|
638
|
+
metadataSubtree: _context6.t10,
|
|
639
|
+
metadata: _context6.t11
|
|
644
640
|
};
|
|
645
|
-
_context6.next =
|
|
646
|
-
return
|
|
647
|
-
case
|
|
641
|
+
_context6.next = 33;
|
|
642
|
+
return _context6.t6.ReplaceMetadata.call(_context6.t6, _context6.t12);
|
|
643
|
+
case 33:
|
|
648
644
|
case "end":
|
|
649
645
|
return _context6.stop();
|
|
650
646
|
}
|
|
@@ -664,38 +660,37 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
664
660
|
* @param {string} policyWriteToken - Write token for the policy
|
|
665
661
|
* @param {string} itemId - Object ID of the item
|
|
666
662
|
*/
|
|
667
|
-
)
|
|
668
663
|
}, {
|
|
669
664
|
key: "RemoveItemPolicy",
|
|
670
|
-
value:
|
|
671
|
-
var _RemoveItemPolicy = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref7) {
|
|
672
|
-
var policyId, policyWriteToken, itemId
|
|
673
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
665
|
+
value: function () {
|
|
666
|
+
var _RemoveItemPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref7) {
|
|
667
|
+
var policyId, policyWriteToken, itemId;
|
|
668
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
674
669
|
while (1) switch (_context7.prev = _context7.next) {
|
|
675
670
|
case 0:
|
|
676
671
|
policyId = _ref7.policyId, policyWriteToken = _ref7.policyWriteToken, itemId = _ref7.itemId;
|
|
677
672
|
ValidatePresence("policyId", policyId);
|
|
678
673
|
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
679
674
|
ValidatePresence("itemId", itemId);
|
|
680
|
-
|
|
681
|
-
_context7.next =
|
|
675
|
+
_context7.t0 = this.client;
|
|
676
|
+
_context7.next = 7;
|
|
682
677
|
return this.client.ContentObjectLibraryId({
|
|
683
678
|
objectId: policyId
|
|
684
679
|
});
|
|
685
|
-
case
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
libraryId:
|
|
692
|
-
objectId:
|
|
693
|
-
writeToken:
|
|
694
|
-
metadataSubtree:
|
|
680
|
+
case 7:
|
|
681
|
+
_context7.t1 = _context7.sent;
|
|
682
|
+
_context7.t2 = policyId;
|
|
683
|
+
_context7.t3 = policyWriteToken;
|
|
684
|
+
_context7.t4 = UrlJoin("auth_policy_spec", itemId);
|
|
685
|
+
_context7.t5 = {
|
|
686
|
+
libraryId: _context7.t1,
|
|
687
|
+
objectId: _context7.t2,
|
|
688
|
+
writeToken: _context7.t3,
|
|
689
|
+
metadataSubtree: _context7.t4
|
|
695
690
|
};
|
|
696
|
-
_context7.next =
|
|
697
|
-
return
|
|
698
|
-
case
|
|
691
|
+
_context7.next = 14;
|
|
692
|
+
return _context7.t0.DeleteMetadata.call(_context7.t0, _context7.t5);
|
|
693
|
+
case 14:
|
|
699
694
|
case "end":
|
|
700
695
|
return _context7.stop();
|
|
701
696
|
}
|
|
@@ -717,37 +712,36 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
717
712
|
* @param {string} itemId - Object ID of the item
|
|
718
713
|
* @param {string=} profileName - The name of the profile. If not specified, all profiles will be returned
|
|
719
714
|
*/
|
|
720
|
-
)
|
|
721
715
|
}, {
|
|
722
716
|
key: "ItemProfiles",
|
|
723
|
-
value:
|
|
724
|
-
var _ItemProfiles = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref8) {
|
|
725
|
-
var policyId, policyWriteToken, itemId, profileName
|
|
726
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
717
|
+
value: function () {
|
|
718
|
+
var _ItemProfiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref8) {
|
|
719
|
+
var policyId, policyWriteToken, itemId, profileName;
|
|
720
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
727
721
|
while (1) switch (_context8.prev = _context8.next) {
|
|
728
722
|
case 0:
|
|
729
723
|
policyId = _ref8.policyId, policyWriteToken = _ref8.policyWriteToken, itemId = _ref8.itemId, profileName = _ref8.profileName;
|
|
730
|
-
|
|
731
|
-
_context8.next =
|
|
724
|
+
_context8.t0 = this.client;
|
|
725
|
+
_context8.next = 4;
|
|
732
726
|
return this.client.ContentObjectLibraryId({
|
|
733
727
|
objectId: policyId
|
|
734
728
|
});
|
|
735
|
-
case
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
libraryId:
|
|
742
|
-
objectId:
|
|
743
|
-
writeToken:
|
|
744
|
-
metadataSubtree:
|
|
729
|
+
case 4:
|
|
730
|
+
_context8.t1 = _context8.sent;
|
|
731
|
+
_context8.t2 = policyId;
|
|
732
|
+
_context8.t3 = policyWriteToken;
|
|
733
|
+
_context8.t4 = UrlJoin("auth_policy_spec", itemId, "profiles", profileName || "");
|
|
734
|
+
_context8.t5 = {
|
|
735
|
+
libraryId: _context8.t1,
|
|
736
|
+
objectId: _context8.t2,
|
|
737
|
+
writeToken: _context8.t3,
|
|
738
|
+
metadataSubtree: _context8.t4
|
|
745
739
|
};
|
|
746
|
-
_context8.next =
|
|
747
|
-
return
|
|
748
|
-
case
|
|
740
|
+
_context8.next = 11;
|
|
741
|
+
return _context8.t0.ContentObjectMetadata.call(_context8.t0, _context8.t5);
|
|
742
|
+
case 11:
|
|
749
743
|
return _context8.abrupt("return", _context8.sent);
|
|
750
|
-
case
|
|
744
|
+
case 12:
|
|
751
745
|
case "end":
|
|
752
746
|
return _context8.stop();
|
|
753
747
|
}
|
|
@@ -770,13 +764,12 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
770
764
|
* @param {object} profileSpec - Specification for the profile. If not provided, profile
|
|
771
765
|
* will default to no access for both assets and offerings
|
|
772
766
|
*/
|
|
773
|
-
)
|
|
774
767
|
}, {
|
|
775
768
|
key: "SetProfile",
|
|
776
|
-
value:
|
|
777
|
-
var _SetProfile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref9) {
|
|
778
|
-
var policyId, policyWriteToken, itemId, profileName, profileSpec
|
|
779
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
769
|
+
value: function () {
|
|
770
|
+
var _SetProfile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref9) {
|
|
771
|
+
var policyId, policyWriteToken, itemId, profileName, profileSpec;
|
|
772
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
780
773
|
while (1) switch (_context9.prev = _context9.next) {
|
|
781
774
|
case 0:
|
|
782
775
|
policyId = _ref9.policyId, policyWriteToken = _ref9.policyWriteToken, itemId = _ref9.itemId, profileName = _ref9.profileName, profileSpec = _ref9.profileSpec;
|
|
@@ -785,27 +778,27 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
785
778
|
ValidatePresence("itemId", itemId);
|
|
786
779
|
ValidatePresence("profileName", profileName);
|
|
787
780
|
ValidatePresence("profileSpec", profileSpec);
|
|
788
|
-
|
|
789
|
-
_context9.next =
|
|
781
|
+
_context9.t0 = this.client;
|
|
782
|
+
_context9.next = 9;
|
|
790
783
|
return this.client.ContentObjectLibraryId({
|
|
791
784
|
objectId: policyId
|
|
792
785
|
});
|
|
793
|
-
case
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
libraryId:
|
|
801
|
-
objectId:
|
|
802
|
-
writeToken:
|
|
803
|
-
metadataSubtree:
|
|
804
|
-
metadata:
|
|
786
|
+
case 9:
|
|
787
|
+
_context9.t1 = _context9.sent;
|
|
788
|
+
_context9.t2 = policyId;
|
|
789
|
+
_context9.t3 = policyWriteToken;
|
|
790
|
+
_context9.t4 = UrlJoin("auth_policy_spec", itemId, "profiles", profileName);
|
|
791
|
+
_context9.t5 = this.FormatProfile(profileSpec);
|
|
792
|
+
_context9.t6 = {
|
|
793
|
+
libraryId: _context9.t1,
|
|
794
|
+
objectId: _context9.t2,
|
|
795
|
+
writeToken: _context9.t3,
|
|
796
|
+
metadataSubtree: _context9.t4,
|
|
797
|
+
metadata: _context9.t5
|
|
805
798
|
};
|
|
806
|
-
_context9.next =
|
|
807
|
-
return
|
|
808
|
-
case
|
|
799
|
+
_context9.next = 17;
|
|
800
|
+
return _context9.t0.ReplaceMetadata.call(_context9.t0, _context9.t6);
|
|
801
|
+
case 17:
|
|
809
802
|
case "end":
|
|
810
803
|
return _context9.stop();
|
|
811
804
|
}
|
|
@@ -828,45 +821,44 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
828
821
|
* @param {object} profileSpec - Specification for the profile. If not provided, profile
|
|
829
822
|
* will default to no access for both assets and offerings
|
|
830
823
|
*/
|
|
831
|
-
)
|
|
832
824
|
}, {
|
|
833
825
|
key: "RemoveProfile",
|
|
834
|
-
value:
|
|
835
|
-
var _RemoveProfile = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
836
|
-
var policyId, policyWriteToken, itemId, profileName
|
|
837
|
-
return _regeneratorRuntime.wrap(function (
|
|
838
|
-
while (1) switch (
|
|
826
|
+
value: function () {
|
|
827
|
+
var _RemoveProfile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref10) {
|
|
828
|
+
var policyId, policyWriteToken, itemId, profileName;
|
|
829
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
830
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
839
831
|
case 0:
|
|
840
|
-
policyId =
|
|
832
|
+
policyId = _ref10.policyId, policyWriteToken = _ref10.policyWriteToken, itemId = _ref10.itemId, profileName = _ref10.profileName;
|
|
841
833
|
ValidatePresence("policyId", policyId);
|
|
842
834
|
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
843
835
|
ValidatePresence("itemId", itemId);
|
|
844
836
|
ValidatePresence("profileName", profileName);
|
|
845
|
-
|
|
846
|
-
|
|
837
|
+
_context10.t0 = this.client;
|
|
838
|
+
_context10.next = 8;
|
|
847
839
|
return this.client.ContentObjectLibraryId({
|
|
848
840
|
objectId: policyId
|
|
849
841
|
});
|
|
850
|
-
case
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
libraryId:
|
|
857
|
-
objectId:
|
|
858
|
-
writeToken:
|
|
859
|
-
metadataSubtree:
|
|
842
|
+
case 8:
|
|
843
|
+
_context10.t1 = _context10.sent;
|
|
844
|
+
_context10.t2 = policyId;
|
|
845
|
+
_context10.t3 = policyWriteToken;
|
|
846
|
+
_context10.t4 = UrlJoin("auth_policy_spec", itemId, "profiles", profileName);
|
|
847
|
+
_context10.t5 = {
|
|
848
|
+
libraryId: _context10.t1,
|
|
849
|
+
objectId: _context10.t2,
|
|
850
|
+
writeToken: _context10.t3,
|
|
851
|
+
metadataSubtree: _context10.t4
|
|
860
852
|
};
|
|
861
|
-
|
|
862
|
-
return
|
|
863
|
-
case
|
|
853
|
+
_context10.next = 15;
|
|
854
|
+
return _context10.t0.DeleteMetadata.call(_context10.t0, _context10.t5);
|
|
855
|
+
case 15:
|
|
864
856
|
case "end":
|
|
865
|
-
return
|
|
857
|
+
return _context10.stop();
|
|
866
858
|
}
|
|
867
|
-
},
|
|
859
|
+
}, _callee10, this);
|
|
868
860
|
}));
|
|
869
|
-
function RemoveProfile(
|
|
861
|
+
function RemoveProfile(_x10) {
|
|
870
862
|
return _RemoveProfile.apply(this, arguments);
|
|
871
863
|
}
|
|
872
864
|
return RemoveProfile;
|
|
@@ -883,72 +875,71 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
883
875
|
*
|
|
884
876
|
* @return {Promise<Array>} - The list of permissions for the specified item
|
|
885
877
|
*/
|
|
886
|
-
)
|
|
887
878
|
}, {
|
|
888
879
|
key: "ItemPermissions",
|
|
889
|
-
value:
|
|
890
|
-
var _ItemPermissions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
880
|
+
value: function () {
|
|
881
|
+
var _ItemPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref11) {
|
|
891
882
|
var _this3 = this;
|
|
892
|
-
var policyId, policyWriteToken, itemId, libraryId, permissions
|
|
893
|
-
return _regeneratorRuntime.wrap(function (
|
|
894
|
-
while (1) switch (
|
|
883
|
+
var policyId, policyWriteToken, itemId, libraryId, permissions;
|
|
884
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
885
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
895
886
|
case 0:
|
|
896
|
-
policyId =
|
|
897
|
-
|
|
887
|
+
policyId = _ref11.policyId, policyWriteToken = _ref11.policyWriteToken, itemId = _ref11.itemId;
|
|
888
|
+
_context12.next = 3;
|
|
898
889
|
return this.client.ContentObjectLibraryId({
|
|
899
890
|
objectId: policyId
|
|
900
891
|
});
|
|
901
|
-
case
|
|
902
|
-
libraryId =
|
|
903
|
-
|
|
892
|
+
case 3:
|
|
893
|
+
libraryId = _context12.sent;
|
|
894
|
+
_context12.next = 6;
|
|
904
895
|
return this.client.ContentObjectMetadata({
|
|
905
896
|
libraryId: libraryId,
|
|
906
897
|
objectId: policyId,
|
|
907
898
|
writeToken: policyWriteToken,
|
|
908
899
|
metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions")
|
|
909
900
|
});
|
|
910
|
-
case
|
|
911
|
-
|
|
912
|
-
if (
|
|
913
|
-
|
|
901
|
+
case 6:
|
|
902
|
+
_context12.t0 = _context12.sent;
|
|
903
|
+
if (_context12.t0) {
|
|
904
|
+
_context12.next = 9;
|
|
914
905
|
break;
|
|
915
906
|
}
|
|
916
|
-
|
|
917
|
-
case
|
|
918
|
-
permissions =
|
|
919
|
-
|
|
920
|
-
return Promise.all(permissions.map(/*#__PURE__*/function () {
|
|
921
|
-
var
|
|
922
|
-
return _regeneratorRuntime.wrap(function (
|
|
923
|
-
while (1) switch (
|
|
907
|
+
_context12.t0 = [];
|
|
908
|
+
case 9:
|
|
909
|
+
permissions = _context12.t0;
|
|
910
|
+
_context12.next = 12;
|
|
911
|
+
return Promise.all(permissions.map( /*#__PURE__*/function () {
|
|
912
|
+
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(permission) {
|
|
913
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
914
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
924
915
|
case 0:
|
|
925
|
-
|
|
916
|
+
_context11.next = 2;
|
|
926
917
|
return _this3.FormatPermission({
|
|
927
918
|
policyId: policyId,
|
|
928
919
|
policyWriteToken: policyWriteToken,
|
|
929
920
|
permission: permission
|
|
930
921
|
});
|
|
931
|
-
case 1:
|
|
932
|
-
return _context1.abrupt("return", _context1.sent);
|
|
933
922
|
case 2:
|
|
923
|
+
return _context11.abrupt("return", _context11.sent);
|
|
924
|
+
case 3:
|
|
934
925
|
case "end":
|
|
935
|
-
return
|
|
926
|
+
return _context11.stop();
|
|
936
927
|
}
|
|
937
|
-
},
|
|
928
|
+
}, _callee11);
|
|
938
929
|
}));
|
|
939
|
-
return function (
|
|
940
|
-
return
|
|
930
|
+
return function (_x12) {
|
|
931
|
+
return _ref12.apply(this, arguments);
|
|
941
932
|
};
|
|
942
933
|
}()));
|
|
943
|
-
case
|
|
944
|
-
return
|
|
945
|
-
case
|
|
934
|
+
case 12:
|
|
935
|
+
return _context12.abrupt("return", _context12.sent);
|
|
936
|
+
case 13:
|
|
946
937
|
case "end":
|
|
947
|
-
return
|
|
938
|
+
return _context12.stop();
|
|
948
939
|
}
|
|
949
|
-
},
|
|
940
|
+
}, _callee12, this);
|
|
950
941
|
}));
|
|
951
|
-
function ItemPermissions(
|
|
942
|
+
function ItemPermissions(_x11) {
|
|
952
943
|
return _ItemPermissions.apply(this, arguments);
|
|
953
944
|
}
|
|
954
945
|
return ItemPermissions;
|
|
@@ -970,16 +961,15 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
970
961
|
* @param {string | number} start - The start time for the permission
|
|
971
962
|
* @param {string | number} end - The end time for the permission
|
|
972
963
|
*/
|
|
973
|
-
)
|
|
974
964
|
}, {
|
|
975
965
|
key: "SetPermission",
|
|
976
|
-
value:
|
|
977
|
-
var _SetPermission = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
978
|
-
var policyId, policyWriteToken, itemId,
|
|
979
|
-
return _regeneratorRuntime.wrap(function (
|
|
980
|
-
while (1) switch (
|
|
966
|
+
value: function () {
|
|
967
|
+
var _SetPermission = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref13) {
|
|
968
|
+
var policyId, policyWriteToken, itemId, _ref13$subjectSource, subjectSource, _ref13$subjectType, subjectType, subjectName, subjectId, subjectNTPId, profileName, start, end, offlineDraft, policyLibraryId, existingPermissions, index, permissionSpec, subjectInfo, newMeta, userInfo, _newMeta, _userInfo;
|
|
969
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
970
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
981
971
|
case 0:
|
|
982
|
-
policyId =
|
|
972
|
+
policyId = _ref13.policyId, policyWriteToken = _ref13.policyWriteToken, itemId = _ref13.itemId, _ref13$subjectSource = _ref13.subjectSource, subjectSource = _ref13$subjectSource === void 0 ? "fabric" : _ref13$subjectSource, _ref13$subjectType = _ref13.subjectType, subjectType = _ref13$subjectType === void 0 ? "group" : _ref13$subjectType, subjectName = _ref13.subjectName, subjectId = _ref13.subjectId, subjectNTPId = _ref13.subjectNTPId, profileName = _ref13.profileName, start = _ref13.start, end = _ref13.end;
|
|
983
973
|
ValidatePresence("policyId", policyId);
|
|
984
974
|
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
985
975
|
ValidatePresence("itemId", itemId);
|
|
@@ -994,16 +984,16 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
994
984
|
offlineDraft = this.offline && this.drafts[policyId] != null;
|
|
995
985
|
policyLibraryId = null;
|
|
996
986
|
if (offlineDraft) {
|
|
997
|
-
|
|
987
|
+
_context13.next = 16;
|
|
998
988
|
break;
|
|
999
989
|
}
|
|
1000
|
-
|
|
990
|
+
_context13.next = 15;
|
|
1001
991
|
return this.client.ContentObjectLibraryId({
|
|
1002
992
|
objectId: policyId
|
|
1003
993
|
});
|
|
1004
|
-
case
|
|
1005
|
-
policyLibraryId =
|
|
1006
|
-
case
|
|
994
|
+
case 15:
|
|
995
|
+
policyLibraryId = _context13.sent;
|
|
996
|
+
case 16:
|
|
1007
997
|
// Allow address to be passed in for fabric subjects, though spec requires iusr/igrp hash
|
|
1008
998
|
if (subjectSource === "fabric") {
|
|
1009
999
|
if (subjectType === "group") {
|
|
@@ -1017,35 +1007,35 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1017
1007
|
}
|
|
1018
1008
|
}
|
|
1019
1009
|
if (!offlineDraft) {
|
|
1020
|
-
|
|
1010
|
+
_context13.next = 21;
|
|
1021
1011
|
break;
|
|
1022
1012
|
}
|
|
1023
1013
|
existingPermissions = this.drafts[policyId].meta["auth_policy_spec"][itemId];
|
|
1024
|
-
|
|
1014
|
+
_context13.next = 24;
|
|
1025
1015
|
break;
|
|
1026
|
-
case
|
|
1027
|
-
|
|
1016
|
+
case 21:
|
|
1017
|
+
_context13.next = 23;
|
|
1028
1018
|
return this.client.ContentObjectMetadata({
|
|
1029
1019
|
libraryId: policyLibraryId,
|
|
1030
1020
|
objectId: policyId,
|
|
1031
1021
|
writeToken: policyWriteToken,
|
|
1032
1022
|
metadataSubtree: UrlJoin("auth_policy_spec", itemId)
|
|
1033
1023
|
});
|
|
1034
|
-
case
|
|
1035
|
-
existingPermissions =
|
|
1036
|
-
case
|
|
1024
|
+
case 23:
|
|
1025
|
+
existingPermissions = _context13.sent;
|
|
1026
|
+
case 24:
|
|
1037
1027
|
if (existingPermissions) {
|
|
1038
|
-
|
|
1028
|
+
_context13.next = 26;
|
|
1039
1029
|
break;
|
|
1040
1030
|
}
|
|
1041
1031
|
throw Error("Unable to add permissions to uninitialized item");
|
|
1042
|
-
case
|
|
1032
|
+
case 26:
|
|
1043
1033
|
if (existingPermissions.profiles[profileName]) {
|
|
1044
|
-
|
|
1034
|
+
_context13.next = 28;
|
|
1045
1035
|
break;
|
|
1046
1036
|
}
|
|
1047
1037
|
throw Error("Profile '".concat(profileName, "' does not exist"));
|
|
1048
|
-
case
|
|
1038
|
+
case 28:
|
|
1049
1039
|
index = existingPermissions.permissions.findIndex(function (permission) {
|
|
1050
1040
|
if (subjectSource === "fabric") {
|
|
1051
1041
|
return permission.subject.id === subjectId;
|
|
@@ -1066,44 +1056,44 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1066
1056
|
permissionSpec.end = end;
|
|
1067
1057
|
}
|
|
1068
1058
|
if (!(subjectSource === "fabric")) {
|
|
1069
|
-
|
|
1059
|
+
_context13.next = 53;
|
|
1070
1060
|
break;
|
|
1071
1061
|
}
|
|
1072
1062
|
if (!(subjectType === "group")) {
|
|
1073
|
-
|
|
1063
|
+
_context13.next = 38;
|
|
1074
1064
|
break;
|
|
1075
1065
|
}
|
|
1076
1066
|
subjectInfo = {
|
|
1077
1067
|
id: subjectId,
|
|
1078
1068
|
type: "group"
|
|
1079
1069
|
};
|
|
1080
|
-
|
|
1070
|
+
_context13.next = 51;
|
|
1081
1071
|
break;
|
|
1082
|
-
case
|
|
1072
|
+
case 38:
|
|
1083
1073
|
if (!(subjectType === "user")) {
|
|
1084
|
-
|
|
1074
|
+
_context13.next = 42;
|
|
1085
1075
|
break;
|
|
1086
1076
|
}
|
|
1087
1077
|
subjectInfo = {
|
|
1088
1078
|
id: subjectId,
|
|
1089
1079
|
type: "user"
|
|
1090
1080
|
};
|
|
1091
|
-
|
|
1081
|
+
_context13.next = 51;
|
|
1092
1082
|
break;
|
|
1093
|
-
case
|
|
1083
|
+
case 42:
|
|
1094
1084
|
if (!(subjectType === "ntp")) {
|
|
1095
|
-
|
|
1085
|
+
_context13.next = 46;
|
|
1096
1086
|
break;
|
|
1097
1087
|
}
|
|
1098
1088
|
subjectInfo = {
|
|
1099
1089
|
id: subjectId,
|
|
1100
1090
|
type: "otp"
|
|
1101
1091
|
};
|
|
1102
|
-
|
|
1092
|
+
_context13.next = 51;
|
|
1103
1093
|
break;
|
|
1104
|
-
case
|
|
1094
|
+
case 46:
|
|
1105
1095
|
if (!(subjectType === "ntp_subject")) {
|
|
1106
|
-
|
|
1096
|
+
_context13.next = 50;
|
|
1107
1097
|
break;
|
|
1108
1098
|
}
|
|
1109
1099
|
subjectInfo = {
|
|
@@ -1111,20 +1101,20 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1111
1101
|
otp_id: subjectNTPId,
|
|
1112
1102
|
type: "otp_subject"
|
|
1113
1103
|
};
|
|
1114
|
-
|
|
1104
|
+
_context13.next = 51;
|
|
1115
1105
|
break;
|
|
1116
|
-
case
|
|
1106
|
+
case 50:
|
|
1117
1107
|
throw Error("Invalid subject type: ".concat(subjectType));
|
|
1118
|
-
case
|
|
1119
|
-
|
|
1108
|
+
case 51:
|
|
1109
|
+
_context13.next = 66;
|
|
1120
1110
|
break;
|
|
1121
|
-
case
|
|
1111
|
+
case 53:
|
|
1122
1112
|
if (!(subjectSource === "oauth")) {
|
|
1123
|
-
|
|
1113
|
+
_context13.next = 65;
|
|
1124
1114
|
break;
|
|
1125
1115
|
}
|
|
1126
1116
|
if (!(subjectType === "group")) {
|
|
1127
|
-
|
|
1117
|
+
_context13.next = 58;
|
|
1128
1118
|
break;
|
|
1129
1119
|
}
|
|
1130
1120
|
subjectInfo = {
|
|
@@ -1132,11 +1122,11 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1132
1122
|
oauth_id: subjectId,
|
|
1133
1123
|
type: "oauth_group"
|
|
1134
1124
|
};
|
|
1135
|
-
|
|
1125
|
+
_context13.next = 63;
|
|
1136
1126
|
break;
|
|
1137
|
-
case
|
|
1127
|
+
case 58:
|
|
1138
1128
|
if (!(subjectType === "user")) {
|
|
1139
|
-
|
|
1129
|
+
_context13.next = 62;
|
|
1140
1130
|
break;
|
|
1141
1131
|
}
|
|
1142
1132
|
subjectInfo = {
|
|
@@ -1144,23 +1134,23 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1144
1134
|
oauth_id: subjectId,
|
|
1145
1135
|
type: "oauth_user"
|
|
1146
1136
|
};
|
|
1147
|
-
|
|
1137
|
+
_context13.next = 63;
|
|
1148
1138
|
break;
|
|
1149
|
-
case
|
|
1139
|
+
case 62:
|
|
1150
1140
|
throw Error("Invalid subject type: ".concat(subjectType));
|
|
1151
|
-
case
|
|
1152
|
-
|
|
1141
|
+
case 63:
|
|
1142
|
+
_context13.next = 66;
|
|
1153
1143
|
break;
|
|
1154
|
-
case
|
|
1144
|
+
case 65:
|
|
1155
1145
|
throw Error("Invalid subject source: ".concat(subjectSource));
|
|
1156
|
-
case
|
|
1146
|
+
case 66:
|
|
1157
1147
|
permissionSpec.subject = subjectInfo;
|
|
1158
1148
|
existingPermissions.permissions[index] = permissionSpec;
|
|
1159
1149
|
if (offlineDraft) {
|
|
1160
|
-
|
|
1150
|
+
_context13.next = 71;
|
|
1161
1151
|
break;
|
|
1162
1152
|
}
|
|
1163
|
-
|
|
1153
|
+
_context13.next = 71;
|
|
1164
1154
|
return this.client.ReplaceMetadata({
|
|
1165
1155
|
libraryId: policyLibraryId,
|
|
1166
1156
|
objectId: policyId,
|
|
@@ -1168,9 +1158,9 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1168
1158
|
metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions"),
|
|
1169
1159
|
metadata: existingPermissions.permissions
|
|
1170
1160
|
});
|
|
1171
|
-
case
|
|
1161
|
+
case 71:
|
|
1172
1162
|
if (!(subjectSource === "fabric" && subjectType === "user")) {
|
|
1173
|
-
|
|
1163
|
+
_context13.next = 85;
|
|
1174
1164
|
break;
|
|
1175
1165
|
}
|
|
1176
1166
|
newMeta = {
|
|
@@ -1178,27 +1168,27 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1178
1168
|
name: subjectName
|
|
1179
1169
|
};
|
|
1180
1170
|
if (!offlineDraft) {
|
|
1181
|
-
|
|
1171
|
+
_context13.next = 77;
|
|
1182
1172
|
break;
|
|
1183
1173
|
}
|
|
1184
1174
|
this.drafts[policyId].meta["auth_policy_settings"]["fabric_users"][this.client.utils.HashToAddress(subjectId)] = newMeta;
|
|
1185
|
-
|
|
1175
|
+
_context13.next = 83;
|
|
1186
1176
|
break;
|
|
1187
|
-
case
|
|
1188
|
-
|
|
1177
|
+
case 77:
|
|
1178
|
+
_context13.next = 79;
|
|
1189
1179
|
return this.client.ContentObjectMetadata({
|
|
1190
1180
|
libraryId: policyLibraryId,
|
|
1191
1181
|
objectId: policyId,
|
|
1192
1182
|
writeToken: policyWriteToken,
|
|
1193
1183
|
metadataSubtree: UrlJoin("auth_policy_settings", "fabric_users", this.client.utils.HashToAddress(subjectId))
|
|
1194
1184
|
});
|
|
1195
|
-
case
|
|
1196
|
-
userInfo =
|
|
1185
|
+
case 79:
|
|
1186
|
+
userInfo = _context13.sent;
|
|
1197
1187
|
if (userInfo) {
|
|
1198
|
-
|
|
1188
|
+
_context13.next = 83;
|
|
1199
1189
|
break;
|
|
1200
1190
|
}
|
|
1201
|
-
|
|
1191
|
+
_context13.next = 83;
|
|
1202
1192
|
return this.client.ReplaceMetadata({
|
|
1203
1193
|
libraryId: policyLibraryId,
|
|
1204
1194
|
objectId: policyId,
|
|
@@ -1206,12 +1196,12 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1206
1196
|
metadataSubtree: UrlJoin("auth_policy_settings", "fabric_users", this.client.utils.HashToAddress(subjectId)),
|
|
1207
1197
|
metadata: newMeta
|
|
1208
1198
|
});
|
|
1209
|
-
case
|
|
1210
|
-
|
|
1199
|
+
case 83:
|
|
1200
|
+
_context13.next = 97;
|
|
1211
1201
|
break;
|
|
1212
|
-
case
|
|
1202
|
+
case 85:
|
|
1213
1203
|
if (!(subjectSource === "fabric" && subjectType === "ntp")) {
|
|
1214
|
-
|
|
1204
|
+
_context13.next = 97;
|
|
1215
1205
|
break;
|
|
1216
1206
|
}
|
|
1217
1207
|
_newMeta = {
|
|
@@ -1221,27 +1211,27 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1221
1211
|
type: "ntpInstance"
|
|
1222
1212
|
};
|
|
1223
1213
|
if (!offlineDraft) {
|
|
1224
|
-
|
|
1214
|
+
_context13.next = 91;
|
|
1225
1215
|
break;
|
|
1226
1216
|
}
|
|
1227
1217
|
this.drafts[policyId].meta["auth_policy_settings"]["ntp_instances"][subjectId] = _newMeta;
|
|
1228
|
-
|
|
1218
|
+
_context13.next = 97;
|
|
1229
1219
|
break;
|
|
1230
|
-
case
|
|
1231
|
-
|
|
1220
|
+
case 91:
|
|
1221
|
+
_context13.next = 93;
|
|
1232
1222
|
return this.client.ContentObjectMetadata({
|
|
1233
1223
|
libraryId: policyLibraryId,
|
|
1234
1224
|
objectId: policyId,
|
|
1235
1225
|
writeToken: policyWriteToken,
|
|
1236
1226
|
metadataSubtree: UrlJoin("auth_policy_settings", "ntp_instances", subjectId)
|
|
1237
1227
|
});
|
|
1238
|
-
case
|
|
1239
|
-
_userInfo =
|
|
1228
|
+
case 93:
|
|
1229
|
+
_userInfo = _context13.sent;
|
|
1240
1230
|
if (_userInfo) {
|
|
1241
|
-
|
|
1231
|
+
_context13.next = 97;
|
|
1242
1232
|
break;
|
|
1243
1233
|
}
|
|
1244
|
-
|
|
1234
|
+
_context13.next = 97;
|
|
1245
1235
|
return this.client.ReplaceMetadata({
|
|
1246
1236
|
libraryId: policyLibraryId,
|
|
1247
1237
|
objectId: policyId,
|
|
@@ -1249,13 +1239,13 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1249
1239
|
metadataSubtree: UrlJoin("auth_policy_settings", "ntp_instances", subjectId),
|
|
1250
1240
|
metadata: _newMeta
|
|
1251
1241
|
});
|
|
1252
|
-
case
|
|
1242
|
+
case 97:
|
|
1253
1243
|
case "end":
|
|
1254
|
-
return
|
|
1244
|
+
return _context13.stop();
|
|
1255
1245
|
}
|
|
1256
|
-
},
|
|
1246
|
+
}, _callee13, this);
|
|
1257
1247
|
}));
|
|
1258
|
-
function SetPermission(
|
|
1248
|
+
function SetPermission(_x13) {
|
|
1259
1249
|
return _SetPermission.apply(this, arguments);
|
|
1260
1250
|
}
|
|
1261
1251
|
return SetPermission;
|
|
@@ -1270,97 +1260,96 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1270
1260
|
* @param {string} itemId - Object ID of the item
|
|
1271
1261
|
* @param {string} subjectId - The ID of the subject
|
|
1272
1262
|
*/
|
|
1273
|
-
)
|
|
1274
1263
|
}, {
|
|
1275
1264
|
key: "RemovePermission",
|
|
1276
|
-
value:
|
|
1277
|
-
var _RemovePermission = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1265
|
+
value: function () {
|
|
1266
|
+
var _RemovePermission = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref14) {
|
|
1278
1267
|
var _this4 = this;
|
|
1279
|
-
var policyId, policyWriteToken, itemId, subjectId, policyLibraryId, permissions, id
|
|
1280
|
-
return _regeneratorRuntime.wrap(function (
|
|
1281
|
-
while (1) switch (
|
|
1268
|
+
var policyId, policyWriteToken, itemId, subjectId, policyLibraryId, permissions, id;
|
|
1269
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1270
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1282
1271
|
case 0:
|
|
1283
|
-
policyId =
|
|
1272
|
+
policyId = _ref14.policyId, policyWriteToken = _ref14.policyWriteToken, itemId = _ref14.itemId, subjectId = _ref14.subjectId;
|
|
1284
1273
|
ValidatePresence("policyId", policyId);
|
|
1285
1274
|
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
1286
1275
|
ValidatePresence("itemId", itemId);
|
|
1287
1276
|
ValidatePresence("subjectId", subjectId);
|
|
1288
|
-
|
|
1277
|
+
_context15.next = 7;
|
|
1289
1278
|
return this.client.ContentObjectLibraryId({
|
|
1290
1279
|
objectId: policyId
|
|
1291
1280
|
});
|
|
1292
|
-
case
|
|
1293
|
-
policyLibraryId =
|
|
1294
|
-
|
|
1281
|
+
case 7:
|
|
1282
|
+
policyLibraryId = _context15.sent;
|
|
1283
|
+
_context15.next = 10;
|
|
1295
1284
|
return this.client.ContentObjectMetadata({
|
|
1296
1285
|
libraryId: policyLibraryId,
|
|
1297
1286
|
objectId: policyId,
|
|
1298
1287
|
writeToken: policyWriteToken,
|
|
1299
1288
|
metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions")
|
|
1300
1289
|
});
|
|
1301
|
-
case
|
|
1302
|
-
permissions =
|
|
1290
|
+
case 10:
|
|
1291
|
+
permissions = _context15.sent;
|
|
1303
1292
|
if (permissions) {
|
|
1304
|
-
|
|
1293
|
+
_context15.next = 13;
|
|
1305
1294
|
break;
|
|
1306
1295
|
}
|
|
1307
|
-
return
|
|
1308
|
-
case
|
|
1296
|
+
return _context15.abrupt("return");
|
|
1297
|
+
case 13:
|
|
1309
1298
|
if (!subjectId.startsWith("0x")) {
|
|
1310
|
-
|
|
1299
|
+
_context15.next = 23;
|
|
1311
1300
|
break;
|
|
1312
1301
|
}
|
|
1313
1302
|
id = this.client.utils.AddressToObjectId(subjectId);
|
|
1314
|
-
|
|
1303
|
+
_context15.next = 17;
|
|
1315
1304
|
return this.client.AccessType({
|
|
1316
1305
|
id: id
|
|
1317
1306
|
});
|
|
1318
|
-
case
|
|
1319
|
-
|
|
1320
|
-
if (!(
|
|
1321
|
-
|
|
1307
|
+
case 17:
|
|
1308
|
+
_context15.t0 = _context15.sent;
|
|
1309
|
+
if (!(_context15.t0 === "group")) {
|
|
1310
|
+
_context15.next = 22;
|
|
1322
1311
|
break;
|
|
1323
1312
|
}
|
|
1324
1313
|
subjectId = "igrp".concat(this.client.utils.AddressToHash(subjectId));
|
|
1325
|
-
|
|
1314
|
+
_context15.next = 23;
|
|
1326
1315
|
break;
|
|
1327
|
-
case
|
|
1316
|
+
case 22:
|
|
1328
1317
|
subjectId = "iusr".concat(this.client.utils.AddressToHash(subjectId));
|
|
1329
|
-
case
|
|
1330
|
-
|
|
1331
|
-
return Promise.all(permissions.map(/*#__PURE__*/function () {
|
|
1332
|
-
var
|
|
1333
|
-
return _regeneratorRuntime.wrap(function (
|
|
1334
|
-
while (1) switch (
|
|
1318
|
+
case 23:
|
|
1319
|
+
_context15.next = 25;
|
|
1320
|
+
return Promise.all(permissions.map( /*#__PURE__*/function () {
|
|
1321
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(permission, index) {
|
|
1322
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1323
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1335
1324
|
case 0:
|
|
1336
1325
|
if (!(permission.subject.id === subjectId || permission.subject.oauth_id === subjectId)) {
|
|
1337
|
-
|
|
1326
|
+
_context14.next = 3;
|
|
1338
1327
|
break;
|
|
1339
1328
|
}
|
|
1340
|
-
|
|
1329
|
+
_context14.next = 3;
|
|
1341
1330
|
return _this4.client.DeleteMetadata({
|
|
1342
1331
|
libraryId: policyLibraryId,
|
|
1343
1332
|
objectId: policyId,
|
|
1344
1333
|
writeToken: policyWriteToken,
|
|
1345
1334
|
metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions", index.toString())
|
|
1346
1335
|
});
|
|
1347
|
-
case
|
|
1336
|
+
case 3:
|
|
1348
1337
|
case "end":
|
|
1349
|
-
return
|
|
1338
|
+
return _context14.stop();
|
|
1350
1339
|
}
|
|
1351
|
-
},
|
|
1340
|
+
}, _callee14);
|
|
1352
1341
|
}));
|
|
1353
|
-
return function (
|
|
1354
|
-
return
|
|
1342
|
+
return function (_x15, _x16) {
|
|
1343
|
+
return _ref15.apply(this, arguments);
|
|
1355
1344
|
};
|
|
1356
1345
|
}()));
|
|
1357
|
-
case
|
|
1346
|
+
case 25:
|
|
1358
1347
|
case "end":
|
|
1359
|
-
return
|
|
1348
|
+
return _context15.stop();
|
|
1360
1349
|
}
|
|
1361
|
-
},
|
|
1350
|
+
}, _callee15, this);
|
|
1362
1351
|
}));
|
|
1363
|
-
function RemovePermission(
|
|
1352
|
+
function RemovePermission(_x14) {
|
|
1364
1353
|
return _RemovePermission.apply(this, arguments);
|
|
1365
1354
|
}
|
|
1366
1355
|
return RemovePermission;
|
|
@@ -1376,112 +1365,111 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1376
1365
|
*
|
|
1377
1366
|
* @returns {Object} - All permissions pertaining to the given subject. Format of result for each item is identical to the format of `ItemPolicy`
|
|
1378
1367
|
*/
|
|
1379
|
-
)
|
|
1380
1368
|
}, {
|
|
1381
1369
|
key: "SubjectPermissions",
|
|
1382
|
-
value:
|
|
1383
|
-
var _SubjectPermissions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1370
|
+
value: function () {
|
|
1371
|
+
var _SubjectPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref16) {
|
|
1384
1372
|
var _this5 = this;
|
|
1385
|
-
var policyId, policyWriteToken, subjectId, id, policyLibraryId, policy, allSubjectPermissions, _i, _Object$keys, itemId, itemPermissions, subjectPermissions
|
|
1386
|
-
return _regeneratorRuntime.wrap(function (
|
|
1387
|
-
while (1) switch (
|
|
1373
|
+
var policyId, policyWriteToken, subjectId, id, policyLibraryId, policy, allSubjectPermissions, _i, _Object$keys, itemId, itemPermissions, subjectPermissions;
|
|
1374
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1375
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1388
1376
|
case 0:
|
|
1389
|
-
policyId =
|
|
1377
|
+
policyId = _ref16.policyId, policyWriteToken = _ref16.policyWriteToken, subjectId = _ref16.subjectId;
|
|
1390
1378
|
ValidatePresence("policyId", policyId);
|
|
1391
1379
|
ValidatePresence("subjectId", subjectId);
|
|
1392
1380
|
|
|
1393
1381
|
// Convert address to appropriate ID
|
|
1394
1382
|
if (!subjectId.startsWith("0x")) {
|
|
1395
|
-
|
|
1383
|
+
_context17.next = 13;
|
|
1396
1384
|
break;
|
|
1397
1385
|
}
|
|
1398
1386
|
id = this.client.utils.AddressToObjectId(subjectId);
|
|
1399
|
-
|
|
1387
|
+
_context17.next = 7;
|
|
1400
1388
|
return this.client.AccessType({
|
|
1401
1389
|
id: id
|
|
1402
1390
|
});
|
|
1403
|
-
case
|
|
1404
|
-
|
|
1405
|
-
if (!(
|
|
1406
|
-
|
|
1391
|
+
case 7:
|
|
1392
|
+
_context17.t0 = _context17.sent;
|
|
1393
|
+
if (!(_context17.t0 === "group")) {
|
|
1394
|
+
_context17.next = 12;
|
|
1407
1395
|
break;
|
|
1408
1396
|
}
|
|
1409
1397
|
subjectId = "igrp".concat(this.client.utils.AddressToHash(subjectId));
|
|
1410
|
-
|
|
1398
|
+
_context17.next = 13;
|
|
1411
1399
|
break;
|
|
1412
|
-
case
|
|
1400
|
+
case 12:
|
|
1413
1401
|
subjectId = "iusr".concat(this.client.utils.AddressToHash(subjectId));
|
|
1414
|
-
case
|
|
1415
|
-
|
|
1402
|
+
case 13:
|
|
1403
|
+
_context17.next = 15;
|
|
1416
1404
|
return this.client.ContentObjectLibraryId({
|
|
1417
1405
|
objectId: policyId
|
|
1418
1406
|
});
|
|
1419
|
-
case
|
|
1420
|
-
policyLibraryId =
|
|
1421
|
-
|
|
1407
|
+
case 15:
|
|
1408
|
+
policyLibraryId = _context17.sent;
|
|
1409
|
+
_context17.next = 18;
|
|
1422
1410
|
return this.client.ContentObjectMetadata({
|
|
1423
1411
|
libraryId: policyLibraryId,
|
|
1424
1412
|
objectId: policyId,
|
|
1425
1413
|
writeToken: policyWriteToken,
|
|
1426
1414
|
metadataSubtree: UrlJoin("auth_policy_spec")
|
|
1427
1415
|
});
|
|
1428
|
-
case
|
|
1429
|
-
policy =
|
|
1416
|
+
case 18:
|
|
1417
|
+
policy = _context17.sent;
|
|
1430
1418
|
allSubjectPermissions = {};
|
|
1431
1419
|
_i = 0, _Object$keys = Object.keys(policy);
|
|
1432
|
-
case
|
|
1420
|
+
case 21:
|
|
1433
1421
|
if (!(_i < _Object$keys.length)) {
|
|
1434
|
-
|
|
1422
|
+
_context17.next = 31;
|
|
1435
1423
|
break;
|
|
1436
1424
|
}
|
|
1437
1425
|
itemId = _Object$keys[_i];
|
|
1438
1426
|
itemPermissions = policy[itemId].permissions || [];
|
|
1439
|
-
|
|
1427
|
+
_context17.next = 26;
|
|
1440
1428
|
return Promise.all(itemPermissions.filter(function (permission) {
|
|
1441
1429
|
return (permission.subject || {}).oauth_id === subjectId || (permission.subject || {}).id === subjectId;
|
|
1442
|
-
}).map(/*#__PURE__*/function () {
|
|
1443
|
-
var
|
|
1444
|
-
return _regeneratorRuntime.wrap(function (
|
|
1445
|
-
while (1) switch (
|
|
1430
|
+
}).map( /*#__PURE__*/function () {
|
|
1431
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(permission) {
|
|
1432
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1433
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1446
1434
|
case 0:
|
|
1447
|
-
|
|
1435
|
+
_context16.next = 2;
|
|
1448
1436
|
return _this5.FormatPermission({
|
|
1449
1437
|
policyId: policyId,
|
|
1450
1438
|
policyWriteToken: policyWriteToken,
|
|
1451
1439
|
permission: permission
|
|
1452
1440
|
});
|
|
1453
|
-
case 1:
|
|
1454
|
-
return _context14.abrupt("return", _context14.sent);
|
|
1455
1441
|
case 2:
|
|
1442
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1443
|
+
case 3:
|
|
1456
1444
|
case "end":
|
|
1457
|
-
return
|
|
1445
|
+
return _context16.stop();
|
|
1458
1446
|
}
|
|
1459
|
-
},
|
|
1447
|
+
}, _callee16);
|
|
1460
1448
|
}));
|
|
1461
|
-
return function (
|
|
1462
|
-
return
|
|
1449
|
+
return function (_x18) {
|
|
1450
|
+
return _ref17.apply(this, arguments);
|
|
1463
1451
|
};
|
|
1464
1452
|
}()));
|
|
1465
|
-
case
|
|
1466
|
-
subjectPermissions =
|
|
1453
|
+
case 26:
|
|
1454
|
+
subjectPermissions = _context17.sent;
|
|
1467
1455
|
if (subjectPermissions.length > 0) {
|
|
1468
1456
|
allSubjectPermissions[itemId] = _objectSpread(_objectSpread({}, policy[itemId]), {}, {
|
|
1469
1457
|
permissions: subjectPermissions
|
|
1470
1458
|
});
|
|
1471
1459
|
}
|
|
1472
|
-
case
|
|
1460
|
+
case 28:
|
|
1473
1461
|
_i++;
|
|
1474
|
-
|
|
1462
|
+
_context17.next = 21;
|
|
1475
1463
|
break;
|
|
1476
|
-
case
|
|
1477
|
-
return
|
|
1478
|
-
case
|
|
1464
|
+
case 31:
|
|
1465
|
+
return _context17.abrupt("return", allSubjectPermissions);
|
|
1466
|
+
case 32:
|
|
1479
1467
|
case "end":
|
|
1480
|
-
return
|
|
1468
|
+
return _context17.stop();
|
|
1481
1469
|
}
|
|
1482
|
-
},
|
|
1470
|
+
}, _callee17, this);
|
|
1483
1471
|
}));
|
|
1484
|
-
function SubjectPermissions(
|
|
1472
|
+
function SubjectPermissions(_x17) {
|
|
1485
1473
|
return _SubjectPermissions.apply(this, arguments);
|
|
1486
1474
|
}
|
|
1487
1475
|
return SubjectPermissions;
|
|
@@ -1495,62 +1483,62 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1495
1483
|
* @param {string} policyWriteToken - Write token for the policy
|
|
1496
1484
|
* @param {string} subjectId - The ID of the subject
|
|
1497
1485
|
*/
|
|
1498
|
-
)
|
|
1499
1486
|
}, {
|
|
1500
1487
|
key: "RemoveSubjectPermissions",
|
|
1501
|
-
value:
|
|
1502
|
-
var _RemoveSubjectPermissions = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function
|
|
1488
|
+
value: function () {
|
|
1489
|
+
var _RemoveSubjectPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref18) {
|
|
1503
1490
|
var _this6 = this;
|
|
1504
1491
|
var policyId, policyWriteToken, subjectId, subjectPermissions;
|
|
1505
|
-
return _regeneratorRuntime.wrap(function (
|
|
1506
|
-
while (1) switch (
|
|
1492
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1493
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1507
1494
|
case 0:
|
|
1508
|
-
policyId =
|
|
1495
|
+
policyId = _ref18.policyId, policyWriteToken = _ref18.policyWriteToken, subjectId = _ref18.subjectId;
|
|
1509
1496
|
ValidatePresence("policyId", policyId);
|
|
1510
1497
|
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
1511
1498
|
ValidatePresence("subjectId", subjectId);
|
|
1512
|
-
|
|
1499
|
+
_context19.next = 6;
|
|
1513
1500
|
return this.SubjectPermissions({
|
|
1514
1501
|
policyId: policyId,
|
|
1515
1502
|
policyWriteToken: policyWriteToken,
|
|
1516
1503
|
subjectId: subjectId
|
|
1517
1504
|
});
|
|
1518
|
-
case
|
|
1519
|
-
subjectPermissions =
|
|
1520
|
-
|
|
1505
|
+
case 6:
|
|
1506
|
+
subjectPermissions = _context19.sent;
|
|
1507
|
+
_context19.next = 9;
|
|
1521
1508
|
return this.client.utils.LimitedMap(5, Object.keys(subjectPermissions), /*#__PURE__*/function () {
|
|
1522
|
-
var
|
|
1523
|
-
return _regeneratorRuntime.wrap(function (
|
|
1524
|
-
while (1) switch (
|
|
1509
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(itemId) {
|
|
1510
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1511
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1525
1512
|
case 0:
|
|
1526
|
-
|
|
1513
|
+
_context18.next = 2;
|
|
1527
1514
|
return _this6.RemovePermission({
|
|
1528
1515
|
policyId: policyId,
|
|
1529
1516
|
policyWriteToken: policyWriteToken,
|
|
1530
1517
|
subjectId: subjectId,
|
|
1531
1518
|
itemId: itemId
|
|
1532
1519
|
});
|
|
1533
|
-
case
|
|
1520
|
+
case 2:
|
|
1534
1521
|
case "end":
|
|
1535
|
-
return
|
|
1522
|
+
return _context18.stop();
|
|
1536
1523
|
}
|
|
1537
|
-
},
|
|
1524
|
+
}, _callee18);
|
|
1538
1525
|
}));
|
|
1539
|
-
return function (
|
|
1540
|
-
return
|
|
1526
|
+
return function (_x20) {
|
|
1527
|
+
return _ref19.apply(this, arguments);
|
|
1541
1528
|
};
|
|
1542
1529
|
}());
|
|
1543
|
-
case
|
|
1530
|
+
case 9:
|
|
1544
1531
|
case "end":
|
|
1545
|
-
return
|
|
1532
|
+
return _context19.stop();
|
|
1546
1533
|
}
|
|
1547
|
-
},
|
|
1534
|
+
}, _callee19, this);
|
|
1548
1535
|
}));
|
|
1549
|
-
function RemoveSubjectPermissions(
|
|
1536
|
+
function RemoveSubjectPermissions(_x19) {
|
|
1550
1537
|
return _RemoveSubjectPermissions.apply(this, arguments);
|
|
1551
1538
|
}
|
|
1552
1539
|
return RemoveSubjectPermissions;
|
|
1553
|
-
}()
|
|
1540
|
+
}()
|
|
1554
1541
|
}]);
|
|
1542
|
+
return PermissionsClient;
|
|
1555
1543
|
}();
|
|
1556
1544
|
module.exports = PermissionsClient;
|