@eluvio/elv-client-js 3.1.96 → 3.1.97
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +11 -15
- package/dist/ElvClient-node-min.js +13 -17
- package/dist/ElvFrameClient-min.js +9 -13
- package/dist/ElvPermissionsClient-min.js +9 -13
- package/dist/src/AuthorizationClient.js +1980 -2238
- package/dist/src/ContentObjectVerification.js +173 -164
- package/dist/src/Crypto.js +324 -376
- package/dist/src/ElvClient.js +1019 -1182
- package/dist/src/ElvWallet.js +95 -119
- package/dist/src/EthClient.js +896 -1040
- package/dist/src/FrameClient.js +300 -331
- package/dist/src/HttpClient.js +147 -153
- package/dist/src/Id.js +3 -1
- package/dist/src/PermissionsClient.js +1168 -1294
- package/dist/src/RemoteSigner.js +211 -263
- package/dist/src/UserProfileClient.js +1023 -1164
- package/dist/src/Utils.js +197 -209
- package/dist/src/client/ABRPublishing.js +858 -895
- package/dist/src/client/AccessGroups.js +959 -1102
- package/dist/src/client/ContentAccess.js +3434 -3727
- package/dist/src/client/ContentManagement.js +2068 -2252
- package/dist/src/client/Contracts.js +563 -647
- package/dist/src/client/Files.js +1757 -1886
- package/dist/src/client/NFT.js +112 -126
- package/dist/src/client/NTP.js +422 -478
- package/package-lock.json +22001 -0
- package/package.json +1 -1
- package/src/Utils.js +22 -0
|
@@ -1,16 +1,14 @@
|
|
|
1
1
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
2
2
|
|
|
3
|
-
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
4
|
-
|
|
5
3
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
6
4
|
|
|
7
5
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
8
6
|
|
|
9
7
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
10
8
|
|
|
11
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly
|
|
9
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }
|
|
12
10
|
|
|
13
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source =
|
|
11
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
14
12
|
|
|
15
13
|
var UrlJoin = require("url-join");
|
|
16
14
|
|
|
@@ -18,7 +16,9 @@ var _require = require("./Validation"),
|
|
|
18
16
|
ValidatePresence = _require.ValidatePresence,
|
|
19
17
|
ValidatePermission = _require.ValidatePermission;
|
|
20
18
|
|
|
21
|
-
var PermissionsClient =
|
|
19
|
+
var PermissionsClient =
|
|
20
|
+
/*#__PURE__*/
|
|
21
|
+
function () {
|
|
22
22
|
"use strict";
|
|
23
23
|
|
|
24
24
|
/**
|
|
@@ -187,7 +187,7 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
187
187
|
spec.end = _this.FormatDate(permission.end);
|
|
188
188
|
}
|
|
189
189
|
|
|
190
|
-
profileSpec[type].custom_permissions[id] = _objectSpread(
|
|
190
|
+
profileSpec[type].custom_permissions[id] = _objectSpread({}, permission, {}, spec);
|
|
191
191
|
});
|
|
192
192
|
}
|
|
193
193
|
});
|
|
@@ -196,224 +196,220 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
196
196
|
|
|
197
197
|
}, {
|
|
198
198
|
key: "FormatPermission",
|
|
199
|
-
value: function () {
|
|
200
|
-
var
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
199
|
+
value: function FormatPermission(_ref) {
|
|
200
|
+
var policyId, policyWriteToken, permission, subjectSource, subjectType, subjectId, subjectName, subjectNTPId, id, cachedName, contentSpaceLibraryId, permissionSpec;
|
|
201
|
+
return _regeneratorRuntime.async(function FormatPermission$(_context) {
|
|
202
|
+
while (1) {
|
|
203
|
+
switch (_context.prev = _context.next) {
|
|
204
|
+
case 0:
|
|
205
|
+
policyId = _ref.policyId, policyWriteToken = _ref.policyWriteToken, permission = _ref.permission;
|
|
206
|
+
subjectSource = permission.subject.type.startsWith("oauth") ? "oauth" : "fabric";
|
|
207
|
+
_context.t0 = permission.subject.type;
|
|
208
|
+
_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;
|
|
209
|
+
break;
|
|
210
|
+
|
|
211
|
+
case 5:
|
|
212
|
+
subjectType = "ntp";
|
|
213
|
+
subjectId = permission.subject.id;
|
|
214
|
+
return _context.abrupt("break", 20);
|
|
215
|
+
|
|
216
|
+
case 8:
|
|
217
|
+
subjectType = "ntp_subject";
|
|
218
|
+
subjectId = permission.subject.id;
|
|
219
|
+
subjectName = subjectId;
|
|
220
|
+
subjectNTPId = permission.subject.otp_id;
|
|
221
|
+
return _context.abrupt("break", 20);
|
|
222
|
+
|
|
223
|
+
case 13:
|
|
224
|
+
subjectType = "group";
|
|
225
|
+
subjectId = subjectSource === "oauth" ? permission.subject.oauth_id : this.client.utils.HashToAddress(permission.subject.id);
|
|
226
|
+
return _context.abrupt("break", 20);
|
|
227
|
+
|
|
228
|
+
case 16:
|
|
229
|
+
subjectType = "user";
|
|
230
|
+
subjectId = subjectSource === "oauth" ? permission.subject.oauth_id : this.client.utils.HashToAddress(permission.subject.id);
|
|
231
|
+
return _context.abrupt("break", 20);
|
|
232
|
+
|
|
233
|
+
case 19:
|
|
234
|
+
throw Error("Unknown subject type: " + permission.subject.type);
|
|
235
|
+
|
|
236
|
+
case 20:
|
|
237
|
+
id = permission.subject.oauth_id || permission.subject.id;
|
|
238
|
+
cachedName = this.subjectNames[id];
|
|
239
|
+
subjectName = subjectName || cachedName || permission.subject.id;
|
|
240
|
+
|
|
241
|
+
if (!(!cachedName && subjectSource === "fabric")) {
|
|
242
|
+
_context.next = 78;
|
|
210
243
|
break;
|
|
244
|
+
}
|
|
211
245
|
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
case 8:
|
|
218
|
-
subjectType = "ntp_subject";
|
|
219
|
-
subjectId = permission.subject.id;
|
|
220
|
-
subjectName = subjectId;
|
|
221
|
-
subjectNTPId = permission.subject.otp_id;
|
|
222
|
-
return _context.abrupt("break", 20);
|
|
223
|
-
|
|
224
|
-
case 13:
|
|
225
|
-
subjectType = "group";
|
|
226
|
-
subjectId = subjectSource === "oauth" ? permission.subject.oauth_id : this.client.utils.HashToAddress(permission.subject.id);
|
|
227
|
-
return _context.abrupt("break", 20);
|
|
228
|
-
|
|
229
|
-
case 16:
|
|
230
|
-
subjectType = "user";
|
|
231
|
-
subjectId = subjectSource === "oauth" ? permission.subject.oauth_id : this.client.utils.HashToAddress(permission.subject.id);
|
|
232
|
-
return _context.abrupt("break", 20);
|
|
233
|
-
|
|
234
|
-
case 19:
|
|
235
|
-
throw Error("Unknown subject type: " + permission.subject.type);
|
|
236
|
-
|
|
237
|
-
case 20:
|
|
238
|
-
id = permission.subject.oauth_id || permission.subject.id;
|
|
239
|
-
cachedName = this.subjectNames[id];
|
|
240
|
-
subjectName = subjectName || cachedName || permission.subject.id;
|
|
241
|
-
|
|
242
|
-
if (!(!cachedName && subjectSource === "fabric")) {
|
|
243
|
-
_context.next = 74;
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
+
if (!(subjectType === "group")) {
|
|
247
|
+
_context.next = 36;
|
|
248
|
+
break;
|
|
249
|
+
}
|
|
246
250
|
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
break;
|
|
250
|
-
}
|
|
251
|
+
_context.next = 27;
|
|
252
|
+
return _regeneratorRuntime.awrap(this.client.ContentSpaceId());
|
|
251
253
|
|
|
252
|
-
|
|
253
|
-
|
|
254
|
+
case 27:
|
|
255
|
+
contentSpaceLibraryId = _context.sent.replace("ispc", "ilib");
|
|
256
|
+
_context.next = 30;
|
|
257
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
|
|
258
|
+
libraryId: contentSpaceLibraryId,
|
|
259
|
+
objectId: this.client.utils.AddressToObjectId(subjectId),
|
|
260
|
+
metadataSubtree: UrlJoin("public", "name")
|
|
261
|
+
}));
|
|
254
262
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
_context.next = 30;
|
|
258
|
-
return this.client.ContentObjectMetadata({
|
|
259
|
-
libraryId: contentSpaceLibraryId,
|
|
260
|
-
objectId: this.client.utils.AddressToObjectId(subjectId),
|
|
261
|
-
metadataSubtree: UrlJoin("public", "name")
|
|
262
|
-
});
|
|
263
|
+
case 30:
|
|
264
|
+
_context.t1 = _context.sent;
|
|
263
265
|
|
|
264
|
-
|
|
265
|
-
_context.
|
|
266
|
+
if (_context.t1) {
|
|
267
|
+
_context.next = 33;
|
|
268
|
+
break;
|
|
269
|
+
}
|
|
266
270
|
|
|
267
|
-
|
|
268
|
-
_context.next = 33;
|
|
269
|
-
break;
|
|
270
|
-
}
|
|
271
|
+
_context.t1 = subjectId;
|
|
271
272
|
|
|
272
|
-
|
|
273
|
+
case 33:
|
|
274
|
+
subjectName = _context.t1;
|
|
275
|
+
_context.next = 78;
|
|
276
|
+
break;
|
|
273
277
|
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
_context.next =
|
|
278
|
+
case 36:
|
|
279
|
+
if (!(subjectType === "user")) {
|
|
280
|
+
_context.next = 58;
|
|
277
281
|
break;
|
|
282
|
+
}
|
|
278
283
|
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
+
_context.t4 = _regeneratorRuntime;
|
|
285
|
+
_context.t5 = this.client;
|
|
286
|
+
_context.next = 41;
|
|
287
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
288
|
+
objectId: policyId
|
|
289
|
+
}));
|
|
290
|
+
|
|
291
|
+
case 41:
|
|
292
|
+
_context.t6 = _context.sent;
|
|
293
|
+
_context.t7 = policyId;
|
|
294
|
+
_context.t8 = policyWriteToken;
|
|
295
|
+
_context.t9 = UrlJoin("auth_policy_settings", "fabric_users", subjectId);
|
|
296
|
+
_context.t10 = {
|
|
297
|
+
libraryId: _context.t6,
|
|
298
|
+
objectId: _context.t7,
|
|
299
|
+
writeToken: _context.t8,
|
|
300
|
+
metadataSubtree: _context.t9
|
|
301
|
+
};
|
|
302
|
+
_context.t11 = _context.t5.ContentObjectMetadata.call(_context.t5, _context.t10);
|
|
303
|
+
_context.next = 49;
|
|
304
|
+
return _context.t4.awrap.call(_context.t4, _context.t11);
|
|
305
|
+
|
|
306
|
+
case 49:
|
|
307
|
+
_context.t3 = _context.sent;
|
|
308
|
+
|
|
309
|
+
if (_context.t3) {
|
|
310
|
+
_context.next = 52;
|
|
311
|
+
break;
|
|
312
|
+
}
|
|
284
313
|
|
|
285
|
-
|
|
286
|
-
_context.next = 40;
|
|
287
|
-
return this.client.ContentObjectLibraryId({
|
|
288
|
-
objectId: policyId
|
|
289
|
-
});
|
|
314
|
+
_context.t3 = {};
|
|
290
315
|
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
_context.t6 = policyId;
|
|
294
|
-
_context.t7 = policyWriteToken;
|
|
295
|
-
_context.t8 = UrlJoin("auth_policy_settings", "fabric_users", subjectId);
|
|
296
|
-
_context.t9 = {
|
|
297
|
-
libraryId: _context.t5,
|
|
298
|
-
objectId: _context.t6,
|
|
299
|
-
writeToken: _context.t7,
|
|
300
|
-
metadataSubtree: _context.t8
|
|
301
|
-
};
|
|
302
|
-
_context.next = 47;
|
|
303
|
-
return _context.t4.ContentObjectMetadata.call(_context.t4, _context.t9);
|
|
304
|
-
|
|
305
|
-
case 47:
|
|
306
|
-
_context.t3 = _context.sent;
|
|
307
|
-
|
|
308
|
-
if (_context.t3) {
|
|
309
|
-
_context.next = 50;
|
|
310
|
-
break;
|
|
311
|
-
}
|
|
316
|
+
case 52:
|
|
317
|
+
_context.t2 = _context.t3.name;
|
|
312
318
|
|
|
313
|
-
|
|
319
|
+
if (_context.t2) {
|
|
320
|
+
_context.next = 55;
|
|
321
|
+
break;
|
|
322
|
+
}
|
|
314
323
|
|
|
315
|
-
|
|
316
|
-
_context.t2 = _context.t3.name;
|
|
324
|
+
_context.t2 = subjectId;
|
|
317
325
|
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
326
|
+
case 55:
|
|
327
|
+
subjectName = _context.t2;
|
|
328
|
+
_context.next = 78;
|
|
329
|
+
break;
|
|
322
330
|
|
|
323
|
-
|
|
331
|
+
case 58:
|
|
332
|
+
if (!(subjectType === "ntp")) {
|
|
333
|
+
_context.next = 78;
|
|
334
|
+
break;
|
|
335
|
+
}
|
|
324
336
|
|
|
325
|
-
|
|
326
|
-
|
|
337
|
+
_context.t14 = _regeneratorRuntime;
|
|
338
|
+
_context.t15 = this.client;
|
|
339
|
+
_context.next = 63;
|
|
340
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
341
|
+
objectId: policyId
|
|
342
|
+
}));
|
|
343
|
+
|
|
344
|
+
case 63:
|
|
345
|
+
_context.t16 = _context.sent;
|
|
346
|
+
_context.t17 = policyId;
|
|
347
|
+
_context.t18 = policyWriteToken;
|
|
348
|
+
_context.t19 = UrlJoin("auth_policy_settings", "ntp_instances", subjectId);
|
|
349
|
+
_context.t20 = {
|
|
350
|
+
libraryId: _context.t16,
|
|
351
|
+
objectId: _context.t17,
|
|
352
|
+
writeToken: _context.t18,
|
|
353
|
+
metadataSubtree: _context.t19
|
|
354
|
+
};
|
|
355
|
+
_context.t21 = _context.t15.ContentObjectMetadata.call(_context.t15, _context.t20);
|
|
356
|
+
_context.next = 71;
|
|
357
|
+
return _context.t14.awrap.call(_context.t14, _context.t21);
|
|
358
|
+
|
|
359
|
+
case 71:
|
|
360
|
+
_context.t13 = _context.sent;
|
|
361
|
+
|
|
362
|
+
if (_context.t13) {
|
|
327
363
|
_context.next = 74;
|
|
328
364
|
break;
|
|
365
|
+
}
|
|
329
366
|
|
|
330
|
-
|
|
331
|
-
if (!(subjectType === "ntp")) {
|
|
332
|
-
_context.next = 74;
|
|
333
|
-
break;
|
|
334
|
-
}
|
|
335
|
-
|
|
336
|
-
_context.t12 = this.client;
|
|
337
|
-
_context.next = 60;
|
|
338
|
-
return this.client.ContentObjectLibraryId({
|
|
339
|
-
objectId: policyId
|
|
340
|
-
});
|
|
341
|
-
|
|
342
|
-
case 60:
|
|
343
|
-
_context.t13 = _context.sent;
|
|
344
|
-
_context.t14 = policyId;
|
|
345
|
-
_context.t15 = policyWriteToken;
|
|
346
|
-
_context.t16 = UrlJoin("auth_policy_settings", "ntp_instances", subjectId);
|
|
347
|
-
_context.t17 = {
|
|
348
|
-
libraryId: _context.t13,
|
|
349
|
-
objectId: _context.t14,
|
|
350
|
-
writeToken: _context.t15,
|
|
351
|
-
metadataSubtree: _context.t16
|
|
352
|
-
};
|
|
353
|
-
_context.next = 67;
|
|
354
|
-
return _context.t12.ContentObjectMetadata.call(_context.t12, _context.t17);
|
|
355
|
-
|
|
356
|
-
case 67:
|
|
357
|
-
_context.t11 = _context.sent;
|
|
358
|
-
|
|
359
|
-
if (_context.t11) {
|
|
360
|
-
_context.next = 70;
|
|
361
|
-
break;
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
_context.t11 = {};
|
|
367
|
+
_context.t13 = {};
|
|
365
368
|
|
|
366
|
-
|
|
367
|
-
|
|
369
|
+
case 74:
|
|
370
|
+
_context.t12 = _context.t13.name;
|
|
368
371
|
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
372
|
+
if (_context.t12) {
|
|
373
|
+
_context.next = 77;
|
|
374
|
+
break;
|
|
375
|
+
}
|
|
373
376
|
|
|
374
|
-
|
|
377
|
+
_context.t12 = subjectId;
|
|
375
378
|
|
|
376
|
-
|
|
377
|
-
|
|
379
|
+
case 77:
|
|
380
|
+
subjectName = _context.t12;
|
|
378
381
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
382
|
+
case 78:
|
|
383
|
+
this.subjectNames[id] = subjectName;
|
|
384
|
+
permissionSpec = {
|
|
385
|
+
profileName: permission.profile,
|
|
386
|
+
subjectSource: subjectSource,
|
|
387
|
+
subjectType: subjectType,
|
|
388
|
+
subjectId: subjectId,
|
|
389
|
+
subjectName: subjectName
|
|
390
|
+
};
|
|
388
391
|
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
+
if (subjectNTPId) {
|
|
393
|
+
permissionSpec.subjectNTPId = subjectNTPId;
|
|
394
|
+
}
|
|
392
395
|
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
+
if (permission.start) {
|
|
397
|
+
permissionSpec.start = permission.start;
|
|
398
|
+
}
|
|
396
399
|
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
+
if (permission.end) {
|
|
401
|
+
permissionSpec.end = permission.end;
|
|
402
|
+
}
|
|
400
403
|
|
|
401
|
-
|
|
404
|
+
return _context.abrupt("return", permissionSpec);
|
|
402
405
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
}
|
|
406
|
+
case 84:
|
|
407
|
+
case "end":
|
|
408
|
+
return _context.stop();
|
|
407
409
|
}
|
|
408
|
-
}
|
|
409
|
-
})
|
|
410
|
-
|
|
411
|
-
function FormatPermission(_x) {
|
|
412
|
-
return _FormatPermission.apply(this, arguments);
|
|
413
|
-
}
|
|
414
|
-
|
|
415
|
-
return FormatPermission;
|
|
416
|
-
}()
|
|
410
|
+
}
|
|
411
|
+
}, null, this);
|
|
412
|
+
}
|
|
417
413
|
/* Offline draft */
|
|
418
414
|
|
|
419
415
|
/**
|
|
@@ -429,58 +425,50 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
429
425
|
|
|
430
426
|
}, {
|
|
431
427
|
key: "OpenOfflineDraft",
|
|
432
|
-
value: function () {
|
|
433
|
-
var
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
}
|
|
445
|
-
|
|
446
|
-
_context2.next = 4;
|
|
447
|
-
return this.client.ContentObjectLibraryId({
|
|
448
|
-
objectId: policyId
|
|
449
|
-
});
|
|
450
|
-
|
|
451
|
-
case 4:
|
|
452
|
-
policyLibraryId = _context2.sent;
|
|
453
|
-
|
|
454
|
-
case 5:
|
|
455
|
-
_context2.next = 7;
|
|
456
|
-
return this.client.ContentObjectMetadata({
|
|
457
|
-
libraryId: policyLibraryId,
|
|
458
|
-
objectId: policyId,
|
|
459
|
-
writeToken: policyWriteToken
|
|
460
|
-
});
|
|
428
|
+
value: function OpenOfflineDraft(_ref2) {
|
|
429
|
+
var policyId, policyLibraryId, policyWriteToken, meta;
|
|
430
|
+
return _regeneratorRuntime.async(function OpenOfflineDraft$(_context2) {
|
|
431
|
+
while (1) {
|
|
432
|
+
switch (_context2.prev = _context2.next) {
|
|
433
|
+
case 0:
|
|
434
|
+
policyId = _ref2.policyId, policyLibraryId = _ref2.policyLibraryId, policyWriteToken = _ref2.policyWriteToken;
|
|
435
|
+
|
|
436
|
+
if (!(policyLibraryId == null)) {
|
|
437
|
+
_context2.next = 5;
|
|
438
|
+
break;
|
|
439
|
+
}
|
|
461
440
|
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
441
|
+
_context2.next = 4;
|
|
442
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
443
|
+
objectId: policyId
|
|
444
|
+
}));
|
|
445
|
+
|
|
446
|
+
case 4:
|
|
447
|
+
policyLibraryId = _context2.sent;
|
|
448
|
+
|
|
449
|
+
case 5:
|
|
450
|
+
_context2.next = 7;
|
|
451
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
|
|
452
|
+
libraryId: policyLibraryId,
|
|
453
|
+
objectId: policyId,
|
|
454
|
+
writeToken: policyWriteToken
|
|
455
|
+
}));
|
|
456
|
+
|
|
457
|
+
case 7:
|
|
458
|
+
meta = _context2.sent;
|
|
459
|
+
this.drafts[policyId] = {
|
|
460
|
+
meta: meta,
|
|
461
|
+
policyLibraryId: policyLibraryId,
|
|
462
|
+
policyWriteToken: policyWriteToken
|
|
463
|
+
};
|
|
464
|
+
|
|
465
|
+
case 9:
|
|
466
|
+
case "end":
|
|
467
|
+
return _context2.stop();
|
|
474
468
|
}
|
|
475
|
-
}
|
|
476
|
-
})
|
|
477
|
-
|
|
478
|
-
function OpenOfflineDraft(_x2) {
|
|
479
|
-
return _OpenOfflineDraft.apply(this, arguments);
|
|
480
|
-
}
|
|
481
|
-
|
|
482
|
-
return OpenOfflineDraft;
|
|
483
|
-
}()
|
|
469
|
+
}
|
|
470
|
+
}, null, this);
|
|
471
|
+
}
|
|
484
472
|
/**
|
|
485
473
|
* Close an offline draft - copies the metadata stored locally back to the write token's metadata.
|
|
486
474
|
* Does not finalize the write token.
|
|
@@ -492,48 +480,40 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
492
480
|
|
|
493
481
|
}, {
|
|
494
482
|
key: "CloseOfflineDraft",
|
|
495
|
-
value: function () {
|
|
496
|
-
var
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
483
|
+
value: function CloseOfflineDraft(_ref3) {
|
|
484
|
+
var policyId;
|
|
485
|
+
return _regeneratorRuntime.async(function CloseOfflineDraft$(_context3) {
|
|
486
|
+
while (1) {
|
|
487
|
+
switch (_context3.prev = _context3.next) {
|
|
488
|
+
case 0:
|
|
489
|
+
policyId = _ref3.policyId;
|
|
490
|
+
|
|
491
|
+
if (!(this.drafts[policyId] == null)) {
|
|
492
|
+
_context3.next = 3;
|
|
493
|
+
break;
|
|
494
|
+
}
|
|
508
495
|
|
|
509
|
-
|
|
496
|
+
throw Error("No draft open for policyId: " + policyId);
|
|
510
497
|
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
498
|
+
case 3:
|
|
499
|
+
_context3.next = 5;
|
|
500
|
+
return _regeneratorRuntime.awrap(this.client.ReplaceMetadata({
|
|
501
|
+
libraryId: this.drafts[policyId].policyLibraryId,
|
|
502
|
+
objectId: policyId,
|
|
503
|
+
writeToken: this.drafts[policyId].policyWriteToken,
|
|
504
|
+
metadata: this.drafts[policyId].meta
|
|
505
|
+
}));
|
|
519
506
|
|
|
520
|
-
|
|
521
|
-
|
|
507
|
+
case 5:
|
|
508
|
+
this.drafts[policyId] = null;
|
|
522
509
|
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
}
|
|
510
|
+
case 6:
|
|
511
|
+
case "end":
|
|
512
|
+
return _context3.stop();
|
|
527
513
|
}
|
|
528
|
-
}
|
|
529
|
-
})
|
|
530
|
-
|
|
531
|
-
function CloseOfflineDraft(_x3) {
|
|
532
|
-
return _CloseOfflineDraft.apply(this, arguments);
|
|
533
|
-
}
|
|
534
|
-
|
|
535
|
-
return CloseOfflineDraft;
|
|
536
|
-
}()
|
|
514
|
+
}
|
|
515
|
+
}, null, this);
|
|
516
|
+
}
|
|
537
517
|
/* Add / remove overall item permission */
|
|
538
518
|
|
|
539
519
|
/**
|
|
@@ -548,62 +528,56 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
548
528
|
|
|
549
529
|
}, {
|
|
550
530
|
key: "PolicyItems",
|
|
551
|
-
value: function () {
|
|
552
|
-
var
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
531
|
+
value: function PolicyItems(_ref4) {
|
|
532
|
+
var policyId, policyWriteToken;
|
|
533
|
+
return _regeneratorRuntime.async(function PolicyItems$(_context4) {
|
|
534
|
+
while (1) {
|
|
535
|
+
switch (_context4.prev = _context4.next) {
|
|
536
|
+
case 0:
|
|
537
|
+
policyId = _ref4.policyId, policyWriteToken = _ref4.policyWriteToken;
|
|
538
|
+
_context4.t1 = _regeneratorRuntime;
|
|
539
|
+
_context4.t2 = this.client;
|
|
540
|
+
_context4.next = 5;
|
|
541
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
542
|
+
objectId: policyId
|
|
543
|
+
}));
|
|
544
|
+
|
|
545
|
+
case 5:
|
|
546
|
+
_context4.t3 = _context4.sent;
|
|
547
|
+
_context4.t4 = policyId;
|
|
548
|
+
_context4.t5 = policyWriteToken;
|
|
549
|
+
_context4.t6 = ["*/display_title"];
|
|
550
|
+
_context4.t7 = {
|
|
551
|
+
libraryId: _context4.t3,
|
|
552
|
+
objectId: _context4.t4,
|
|
553
|
+
writeToken: _context4.t5,
|
|
554
|
+
metadataSubtree: "auth_policy_spec",
|
|
555
|
+
select: _context4.t6
|
|
556
|
+
};
|
|
557
|
+
_context4.t8 = _context4.t2.ContentObjectMetadata.call(_context4.t2, _context4.t7);
|
|
558
|
+
_context4.next = 13;
|
|
559
|
+
return _context4.t1.awrap.call(_context4.t1, _context4.t8);
|
|
560
|
+
|
|
561
|
+
case 13:
|
|
562
|
+
_context4.t0 = _context4.sent;
|
|
563
|
+
|
|
564
|
+
if (_context4.t0) {
|
|
565
|
+
_context4.next = 16;
|
|
566
|
+
break;
|
|
567
|
+
}
|
|
587
568
|
|
|
588
|
-
|
|
569
|
+
_context4.t0 = {};
|
|
589
570
|
|
|
590
|
-
|
|
591
|
-
|
|
571
|
+
case 16:
|
|
572
|
+
return _context4.abrupt("return", _context4.t0);
|
|
592
573
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
}
|
|
574
|
+
case 17:
|
|
575
|
+
case "end":
|
|
576
|
+
return _context4.stop();
|
|
597
577
|
}
|
|
598
|
-
}
|
|
599
|
-
})
|
|
600
|
-
|
|
601
|
-
function PolicyItems(_x4) {
|
|
602
|
-
return _PolicyItems.apply(this, arguments);
|
|
603
|
-
}
|
|
604
|
-
|
|
605
|
-
return PolicyItems;
|
|
606
|
-
}()
|
|
578
|
+
}
|
|
579
|
+
}, null, this);
|
|
580
|
+
}
|
|
607
581
|
/**
|
|
608
582
|
* Retrieve the full item policy for the given item.
|
|
609
583
|
*
|
|
@@ -617,60 +591,52 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
617
591
|
|
|
618
592
|
}, {
|
|
619
593
|
key: "ItemPolicy",
|
|
620
|
-
value: function () {
|
|
621
|
-
var
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
}
|
|
594
|
+
value: function ItemPolicy(_ref5) {
|
|
595
|
+
var policyId, policyWriteToken, itemId, profiles, permissions;
|
|
596
|
+
return _regeneratorRuntime.async(function ItemPolicy$(_context5) {
|
|
597
|
+
while (1) {
|
|
598
|
+
switch (_context5.prev = _context5.next) {
|
|
599
|
+
case 0:
|
|
600
|
+
policyId = _ref5.policyId, policyWriteToken = _ref5.policyWriteToken, itemId = _ref5.itemId;
|
|
601
|
+
_context5.next = 3;
|
|
602
|
+
return _regeneratorRuntime.awrap(this.ItemProfiles({
|
|
603
|
+
policyId: policyId,
|
|
604
|
+
policyWriteToken: policyWriteToken,
|
|
605
|
+
itemId: itemId
|
|
606
|
+
}));
|
|
607
|
+
|
|
608
|
+
case 3:
|
|
609
|
+
profiles = _context5.sent;
|
|
610
|
+
_context5.next = 6;
|
|
611
|
+
return _regeneratorRuntime.awrap(this.ItemPermissions({
|
|
612
|
+
policyId: policyId,
|
|
613
|
+
policyWriteToken: policyWriteToken,
|
|
614
|
+
itemId: itemId
|
|
615
|
+
}));
|
|
616
|
+
|
|
617
|
+
case 6:
|
|
618
|
+
permissions = _context5.sent;
|
|
619
|
+
|
|
620
|
+
if (!(!profiles || !permissions)) {
|
|
621
|
+
_context5.next = 9;
|
|
622
|
+
break;
|
|
623
|
+
}
|
|
651
624
|
|
|
652
|
-
|
|
625
|
+
return _context5.abrupt("return");
|
|
653
626
|
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
627
|
+
case 9:
|
|
628
|
+
return _context5.abrupt("return", {
|
|
629
|
+
profiles: profiles,
|
|
630
|
+
permissions: permissions
|
|
631
|
+
});
|
|
659
632
|
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
}
|
|
633
|
+
case 10:
|
|
634
|
+
case "end":
|
|
635
|
+
return _context5.stop();
|
|
664
636
|
}
|
|
665
|
-
}
|
|
666
|
-
})
|
|
667
|
-
|
|
668
|
-
function ItemPolicy(_x5) {
|
|
669
|
-
return _ItemPolicy.apply(this, arguments);
|
|
670
|
-
}
|
|
671
|
-
|
|
672
|
-
return ItemPolicy;
|
|
673
|
-
}()
|
|
637
|
+
}
|
|
638
|
+
}, null, this);
|
|
639
|
+
}
|
|
674
640
|
/**
|
|
675
641
|
* Initialize policy for the specified item
|
|
676
642
|
*
|
|
@@ -684,97 +650,93 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
684
650
|
|
|
685
651
|
}, {
|
|
686
652
|
key: "CreateItemPolicy",
|
|
687
|
-
value: function () {
|
|
688
|
-
var
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
_context6.t0 = {};
|
|
729
|
-
|
|
730
|
-
case 17:
|
|
731
|
-
metadata = _context6.t0;
|
|
732
|
-
assetMetadata = (metadata["public"] || {}).asset_metadata || {};
|
|
733
|
-
displayTitle = assetMetadata.display_title || assetMetadata.title || (metadata["public"] || {}).name;
|
|
734
|
-
itemSpec = {
|
|
735
|
-
display_title: displayTitle,
|
|
736
|
-
permissions: [],
|
|
737
|
-
profiles: {}
|
|
738
|
-
};
|
|
739
|
-
Object.keys(profiles).forEach(function (profileName) {
|
|
740
|
-
itemSpec.profiles[profileName] = _this2.FormatProfile(profiles[profileName]);
|
|
741
|
-
});
|
|
742
|
-
_context6.t6 = this.client;
|
|
743
|
-
_context6.next = 25;
|
|
744
|
-
return this.client.ContentObjectLibraryId({
|
|
745
|
-
objectId: policyId
|
|
746
|
-
});
|
|
653
|
+
value: function CreateItemPolicy(_ref6) {
|
|
654
|
+
var _this2 = this;
|
|
655
|
+
|
|
656
|
+
var policyId, policyWriteToken, itemId, _ref6$profiles, profiles, metadata, assetMetadata, displayTitle, itemSpec;
|
|
657
|
+
|
|
658
|
+
return _regeneratorRuntime.async(function CreateItemPolicy$(_context6) {
|
|
659
|
+
while (1) {
|
|
660
|
+
switch (_context6.prev = _context6.next) {
|
|
661
|
+
case 0:
|
|
662
|
+
policyId = _ref6.policyId, policyWriteToken = _ref6.policyWriteToken, itemId = _ref6.itemId, _ref6$profiles = _ref6.profiles, profiles = _ref6$profiles === void 0 ? {} : _ref6$profiles;
|
|
663
|
+
ValidatePresence("policyId", policyId);
|
|
664
|
+
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
665
|
+
ValidatePresence("itemId", itemId);
|
|
666
|
+
ValidatePresence("profiles", profiles);
|
|
667
|
+
_context6.t1 = _regeneratorRuntime;
|
|
668
|
+
_context6.t2 = this.client;
|
|
669
|
+
_context6.next = 9;
|
|
670
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
671
|
+
objectId: itemId
|
|
672
|
+
}));
|
|
673
|
+
|
|
674
|
+
case 9:
|
|
675
|
+
_context6.t3 = _context6.sent;
|
|
676
|
+
_context6.t4 = itemId;
|
|
677
|
+
_context6.t5 = ["public/name", "public/asset_metadata/title", "public/asset_metadata/display_title"];
|
|
678
|
+
_context6.t6 = {
|
|
679
|
+
libraryId: _context6.t3,
|
|
680
|
+
objectId: _context6.t4,
|
|
681
|
+
select: _context6.t5
|
|
682
|
+
};
|
|
683
|
+
_context6.t7 = _context6.t2.ContentObjectMetadata.call(_context6.t2, _context6.t6);
|
|
684
|
+
_context6.next = 16;
|
|
685
|
+
return _context6.t1.awrap.call(_context6.t1, _context6.t7);
|
|
686
|
+
|
|
687
|
+
case 16:
|
|
688
|
+
_context6.t0 = _context6.sent;
|
|
689
|
+
|
|
690
|
+
if (_context6.t0) {
|
|
691
|
+
_context6.next = 19;
|
|
692
|
+
break;
|
|
693
|
+
}
|
|
747
694
|
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
695
|
+
_context6.t0 = {};
|
|
696
|
+
|
|
697
|
+
case 19:
|
|
698
|
+
metadata = _context6.t0;
|
|
699
|
+
assetMetadata = (metadata["public"] || {}).asset_metadata || {};
|
|
700
|
+
displayTitle = assetMetadata.display_title || assetMetadata.title || (metadata["public"] || {}).name;
|
|
701
|
+
itemSpec = {
|
|
702
|
+
display_title: displayTitle,
|
|
703
|
+
permissions: [],
|
|
704
|
+
profiles: {}
|
|
705
|
+
};
|
|
706
|
+
Object.keys(profiles).forEach(function (profileName) {
|
|
707
|
+
itemSpec.profiles[profileName] = _this2.FormatProfile(profiles[profileName]);
|
|
708
|
+
});
|
|
709
|
+
_context6.t8 = _regeneratorRuntime;
|
|
710
|
+
_context6.t9 = this.client;
|
|
711
|
+
_context6.next = 28;
|
|
712
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
713
|
+
objectId: policyId
|
|
714
|
+
}));
|
|
715
|
+
|
|
716
|
+
case 28:
|
|
717
|
+
_context6.t10 = _context6.sent;
|
|
718
|
+
_context6.t11 = policyId;
|
|
719
|
+
_context6.t12 = policyWriteToken;
|
|
720
|
+
_context6.t13 = UrlJoin("auth_policy_spec", itemId);
|
|
721
|
+
_context6.t14 = itemSpec;
|
|
722
|
+
_context6.t15 = {
|
|
723
|
+
libraryId: _context6.t10,
|
|
724
|
+
objectId: _context6.t11,
|
|
725
|
+
writeToken: _context6.t12,
|
|
726
|
+
metadataSubtree: _context6.t13,
|
|
727
|
+
metadata: _context6.t14
|
|
728
|
+
};
|
|
729
|
+
_context6.t16 = _context6.t9.ReplaceMetadata.call(_context6.t9, _context6.t15);
|
|
730
|
+
_context6.next = 37;
|
|
731
|
+
return _context6.t8.awrap.call(_context6.t8, _context6.t16);
|
|
732
|
+
|
|
733
|
+
case 37:
|
|
734
|
+
case "end":
|
|
735
|
+
return _context6.stop();
|
|
768
736
|
}
|
|
769
|
-
}
|
|
770
|
-
})
|
|
771
|
-
|
|
772
|
-
function CreateItemPolicy(_x6) {
|
|
773
|
-
return _CreateItemPolicy.apply(this, arguments);
|
|
774
|
-
}
|
|
775
|
-
|
|
776
|
-
return CreateItemPolicy;
|
|
777
|
-
}()
|
|
737
|
+
}
|
|
738
|
+
}, null, this);
|
|
739
|
+
}
|
|
778
740
|
/**
|
|
779
741
|
* Remove the specified item policy
|
|
780
742
|
*
|
|
@@ -787,51 +749,45 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
787
749
|
|
|
788
750
|
}, {
|
|
789
751
|
key: "RemoveItemPolicy",
|
|
790
|
-
value: function () {
|
|
791
|
-
var
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
752
|
+
value: function RemoveItemPolicy(_ref7) {
|
|
753
|
+
var policyId, policyWriteToken, itemId;
|
|
754
|
+
return _regeneratorRuntime.async(function RemoveItemPolicy$(_context7) {
|
|
755
|
+
while (1) {
|
|
756
|
+
switch (_context7.prev = _context7.next) {
|
|
757
|
+
case 0:
|
|
758
|
+
policyId = _ref7.policyId, policyWriteToken = _ref7.policyWriteToken, itemId = _ref7.itemId;
|
|
759
|
+
ValidatePresence("policyId", policyId);
|
|
760
|
+
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
761
|
+
ValidatePresence("itemId", itemId);
|
|
762
|
+
_context7.t0 = _regeneratorRuntime;
|
|
763
|
+
_context7.t1 = this.client;
|
|
764
|
+
_context7.next = 8;
|
|
765
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
766
|
+
objectId: policyId
|
|
767
|
+
}));
|
|
768
|
+
|
|
769
|
+
case 8:
|
|
770
|
+
_context7.t2 = _context7.sent;
|
|
771
|
+
_context7.t3 = policyId;
|
|
772
|
+
_context7.t4 = policyWriteToken;
|
|
773
|
+
_context7.t5 = UrlJoin("auth_policy_spec", itemId);
|
|
774
|
+
_context7.t6 = {
|
|
775
|
+
libraryId: _context7.t2,
|
|
776
|
+
objectId: _context7.t3,
|
|
777
|
+
writeToken: _context7.t4,
|
|
778
|
+
metadataSubtree: _context7.t5
|
|
779
|
+
};
|
|
780
|
+
_context7.t7 = _context7.t1.DeleteMetadata.call(_context7.t1, _context7.t6);
|
|
781
|
+
_context7.next = 16;
|
|
782
|
+
return _context7.t0.awrap.call(_context7.t0, _context7.t7);
|
|
783
|
+
|
|
784
|
+
case 16:
|
|
785
|
+
case "end":
|
|
786
|
+
return _context7.stop();
|
|
825
787
|
}
|
|
826
|
-
}
|
|
827
|
-
})
|
|
828
|
-
|
|
829
|
-
function RemoveItemPolicy(_x7) {
|
|
830
|
-
return _RemoveItemPolicy.apply(this, arguments);
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
return RemoveItemPolicy;
|
|
834
|
-
}()
|
|
788
|
+
}
|
|
789
|
+
}, null, this);
|
|
790
|
+
}
|
|
835
791
|
/* Get / set / remove profile permissions */
|
|
836
792
|
|
|
837
793
|
/**
|
|
@@ -847,51 +803,45 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
847
803
|
|
|
848
804
|
}, {
|
|
849
805
|
key: "ItemProfiles",
|
|
850
|
-
value: function () {
|
|
851
|
-
var
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
806
|
+
value: function ItemProfiles(_ref8) {
|
|
807
|
+
var policyId, policyWriteToken, itemId, profileName;
|
|
808
|
+
return _regeneratorRuntime.async(function ItemProfiles$(_context8) {
|
|
809
|
+
while (1) {
|
|
810
|
+
switch (_context8.prev = _context8.next) {
|
|
811
|
+
case 0:
|
|
812
|
+
policyId = _ref8.policyId, policyWriteToken = _ref8.policyWriteToken, itemId = _ref8.itemId, profileName = _ref8.profileName;
|
|
813
|
+
_context8.t0 = _regeneratorRuntime;
|
|
814
|
+
_context8.t1 = this.client;
|
|
815
|
+
_context8.next = 5;
|
|
816
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
817
|
+
objectId: policyId
|
|
818
|
+
}));
|
|
819
|
+
|
|
820
|
+
case 5:
|
|
821
|
+
_context8.t2 = _context8.sent;
|
|
822
|
+
_context8.t3 = policyId;
|
|
823
|
+
_context8.t4 = policyWriteToken;
|
|
824
|
+
_context8.t5 = UrlJoin("auth_policy_spec", itemId, "profiles", profileName || "");
|
|
825
|
+
_context8.t6 = {
|
|
826
|
+
libraryId: _context8.t2,
|
|
827
|
+
objectId: _context8.t3,
|
|
828
|
+
writeToken: _context8.t4,
|
|
829
|
+
metadataSubtree: _context8.t5
|
|
830
|
+
};
|
|
831
|
+
_context8.t7 = _context8.t1.ContentObjectMetadata.call(_context8.t1, _context8.t6);
|
|
832
|
+
_context8.next = 13;
|
|
833
|
+
return _context8.t0.awrap.call(_context8.t0, _context8.t7);
|
|
834
|
+
|
|
835
|
+
case 13:
|
|
836
|
+
return _context8.abrupt("return", _context8.sent);
|
|
837
|
+
|
|
838
|
+
case 14:
|
|
839
|
+
case "end":
|
|
840
|
+
return _context8.stop();
|
|
885
841
|
}
|
|
886
|
-
}
|
|
887
|
-
})
|
|
888
|
-
|
|
889
|
-
function ItemProfiles(_x8) {
|
|
890
|
-
return _ItemProfiles.apply(this, arguments);
|
|
891
|
-
}
|
|
892
|
-
|
|
893
|
-
return ItemProfiles;
|
|
894
|
-
}()
|
|
842
|
+
}
|
|
843
|
+
}, null, this);
|
|
844
|
+
}
|
|
895
845
|
/**
|
|
896
846
|
* Create or modify a profile for the specified item policy
|
|
897
847
|
*
|
|
@@ -907,55 +857,49 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
907
857
|
|
|
908
858
|
}, {
|
|
909
859
|
key: "SetProfile",
|
|
910
|
-
value: function () {
|
|
911
|
-
var
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
860
|
+
value: function SetProfile(_ref9) {
|
|
861
|
+
var policyId, policyWriteToken, itemId, profileName, profileSpec;
|
|
862
|
+
return _regeneratorRuntime.async(function SetProfile$(_context9) {
|
|
863
|
+
while (1) {
|
|
864
|
+
switch (_context9.prev = _context9.next) {
|
|
865
|
+
case 0:
|
|
866
|
+
policyId = _ref9.policyId, policyWriteToken = _ref9.policyWriteToken, itemId = _ref9.itemId, profileName = _ref9.profileName, profileSpec = _ref9.profileSpec;
|
|
867
|
+
ValidatePresence("policyId", policyId);
|
|
868
|
+
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
869
|
+
ValidatePresence("itemId", itemId);
|
|
870
|
+
ValidatePresence("profileName", profileName);
|
|
871
|
+
ValidatePresence("profileSpec", profileSpec);
|
|
872
|
+
_context9.t0 = _regeneratorRuntime;
|
|
873
|
+
_context9.t1 = this.client;
|
|
874
|
+
_context9.next = 10;
|
|
875
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
876
|
+
objectId: policyId
|
|
877
|
+
}));
|
|
878
|
+
|
|
879
|
+
case 10:
|
|
880
|
+
_context9.t2 = _context9.sent;
|
|
881
|
+
_context9.t3 = policyId;
|
|
882
|
+
_context9.t4 = policyWriteToken;
|
|
883
|
+
_context9.t5 = UrlJoin("auth_policy_spec", itemId, "profiles", profileName);
|
|
884
|
+
_context9.t6 = this.FormatProfile(profileSpec);
|
|
885
|
+
_context9.t7 = {
|
|
886
|
+
libraryId: _context9.t2,
|
|
887
|
+
objectId: _context9.t3,
|
|
888
|
+
writeToken: _context9.t4,
|
|
889
|
+
metadataSubtree: _context9.t5,
|
|
890
|
+
metadata: _context9.t6
|
|
891
|
+
};
|
|
892
|
+
_context9.t8 = _context9.t1.ReplaceMetadata.call(_context9.t1, _context9.t7);
|
|
893
|
+
_context9.next = 19;
|
|
894
|
+
return _context9.t0.awrap.call(_context9.t0, _context9.t8);
|
|
895
|
+
|
|
896
|
+
case 19:
|
|
897
|
+
case "end":
|
|
898
|
+
return _context9.stop();
|
|
949
899
|
}
|
|
950
|
-
}
|
|
951
|
-
})
|
|
952
|
-
|
|
953
|
-
function SetProfile(_x9) {
|
|
954
|
-
return _SetProfile.apply(this, arguments);
|
|
955
|
-
}
|
|
956
|
-
|
|
957
|
-
return SetProfile;
|
|
958
|
-
}()
|
|
900
|
+
}
|
|
901
|
+
}, null, this);
|
|
902
|
+
}
|
|
959
903
|
/**
|
|
960
904
|
* Remove a profile from the specified item policy
|
|
961
905
|
*
|
|
@@ -971,52 +915,46 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
971
915
|
|
|
972
916
|
}, {
|
|
973
917
|
key: "RemoveProfile",
|
|
974
|
-
value: function () {
|
|
975
|
-
var
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
918
|
+
value: function RemoveProfile(_ref10) {
|
|
919
|
+
var policyId, policyWriteToken, itemId, profileName;
|
|
920
|
+
return _regeneratorRuntime.async(function RemoveProfile$(_context10) {
|
|
921
|
+
while (1) {
|
|
922
|
+
switch (_context10.prev = _context10.next) {
|
|
923
|
+
case 0:
|
|
924
|
+
policyId = _ref10.policyId, policyWriteToken = _ref10.policyWriteToken, itemId = _ref10.itemId, profileName = _ref10.profileName;
|
|
925
|
+
ValidatePresence("policyId", policyId);
|
|
926
|
+
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
927
|
+
ValidatePresence("itemId", itemId);
|
|
928
|
+
ValidatePresence("profileName", profileName);
|
|
929
|
+
_context10.t0 = _regeneratorRuntime;
|
|
930
|
+
_context10.t1 = this.client;
|
|
931
|
+
_context10.next = 9;
|
|
932
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
933
|
+
objectId: policyId
|
|
934
|
+
}));
|
|
935
|
+
|
|
936
|
+
case 9:
|
|
937
|
+
_context10.t2 = _context10.sent;
|
|
938
|
+
_context10.t3 = policyId;
|
|
939
|
+
_context10.t4 = policyWriteToken;
|
|
940
|
+
_context10.t5 = UrlJoin("auth_policy_spec", itemId, "profiles", profileName);
|
|
941
|
+
_context10.t6 = {
|
|
942
|
+
libraryId: _context10.t2,
|
|
943
|
+
objectId: _context10.t3,
|
|
944
|
+
writeToken: _context10.t4,
|
|
945
|
+
metadataSubtree: _context10.t5
|
|
946
|
+
};
|
|
947
|
+
_context10.t7 = _context10.t1.DeleteMetadata.call(_context10.t1, _context10.t6);
|
|
948
|
+
_context10.next = 17;
|
|
949
|
+
return _context10.t0.awrap.call(_context10.t0, _context10.t7);
|
|
950
|
+
|
|
951
|
+
case 17:
|
|
952
|
+
case "end":
|
|
953
|
+
return _context10.stop();
|
|
1010
954
|
}
|
|
1011
|
-
}
|
|
1012
|
-
})
|
|
1013
|
-
|
|
1014
|
-
function RemoveProfile(_x10) {
|
|
1015
|
-
return _RemoveProfile.apply(this, arguments);
|
|
1016
|
-
}
|
|
1017
|
-
|
|
1018
|
-
return RemoveProfile;
|
|
1019
|
-
}()
|
|
955
|
+
}
|
|
956
|
+
}, null, this);
|
|
957
|
+
}
|
|
1020
958
|
/* Get / set / remove subject permissions */
|
|
1021
959
|
|
|
1022
960
|
/**
|
|
@@ -1033,90 +971,76 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1033
971
|
|
|
1034
972
|
}, {
|
|
1035
973
|
key: "ItemPermissions",
|
|
1036
|
-
value: function () {
|
|
1037
|
-
var
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
974
|
+
value: function ItemPermissions(_ref11) {
|
|
975
|
+
var _this3 = this;
|
|
976
|
+
|
|
977
|
+
var policyId, policyWriteToken, itemId, libraryId, permissions;
|
|
978
|
+
return _regeneratorRuntime.async(function ItemPermissions$(_context12) {
|
|
979
|
+
while (1) {
|
|
980
|
+
switch (_context12.prev = _context12.next) {
|
|
981
|
+
case 0:
|
|
982
|
+
policyId = _ref11.policyId, policyWriteToken = _ref11.policyWriteToken, itemId = _ref11.itemId;
|
|
983
|
+
_context12.next = 3;
|
|
984
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
985
|
+
objectId: policyId
|
|
986
|
+
}));
|
|
987
|
+
|
|
988
|
+
case 3:
|
|
989
|
+
libraryId = _context12.sent;
|
|
990
|
+
_context12.next = 6;
|
|
991
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
|
|
992
|
+
libraryId: libraryId,
|
|
993
|
+
objectId: policyId,
|
|
994
|
+
writeToken: policyWriteToken,
|
|
995
|
+
metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions")
|
|
996
|
+
}));
|
|
997
|
+
|
|
998
|
+
case 6:
|
|
999
|
+
_context12.t0 = _context12.sent;
|
|
1000
|
+
|
|
1001
|
+
if (_context12.t0) {
|
|
1002
|
+
_context12.next = 9;
|
|
1003
|
+
break;
|
|
1004
|
+
}
|
|
1050
1005
|
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1006
|
+
_context12.t0 = [];
|
|
1007
|
+
|
|
1008
|
+
case 9:
|
|
1009
|
+
permissions = _context12.t0;
|
|
1010
|
+
_context12.next = 12;
|
|
1011
|
+
return _regeneratorRuntime.awrap(Promise.all(permissions.map(function _callee(permission) {
|
|
1012
|
+
return _regeneratorRuntime.async(function _callee$(_context11) {
|
|
1013
|
+
while (1) {
|
|
1014
|
+
switch (_context11.prev = _context11.next) {
|
|
1015
|
+
case 0:
|
|
1016
|
+
_context11.next = 2;
|
|
1017
|
+
return _regeneratorRuntime.awrap(_this3.FormatPermission({
|
|
1018
|
+
policyId: policyId,
|
|
1019
|
+
policyWriteToken: policyWriteToken,
|
|
1020
|
+
permission: permission
|
|
1021
|
+
}));
|
|
1022
|
+
|
|
1023
|
+
case 2:
|
|
1024
|
+
return _context11.abrupt("return", _context11.sent);
|
|
1025
|
+
|
|
1026
|
+
case 3:
|
|
1027
|
+
case "end":
|
|
1028
|
+
return _context11.stop();
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1059
1031
|
});
|
|
1032
|
+
})));
|
|
1060
1033
|
|
|
1061
|
-
|
|
1062
|
-
|
|
1034
|
+
case 12:
|
|
1035
|
+
return _context12.abrupt("return", _context12.sent);
|
|
1063
1036
|
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
}
|
|
1068
|
-
|
|
1069
|
-
_context12.t0 = [];
|
|
1070
|
-
|
|
1071
|
-
case 9:
|
|
1072
|
-
permissions = _context12.t0;
|
|
1073
|
-
_context12.next = 12;
|
|
1074
|
-
return Promise.all(permissions.map( /*#__PURE__*/function () {
|
|
1075
|
-
var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(permission) {
|
|
1076
|
-
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
1077
|
-
while (1) {
|
|
1078
|
-
switch (_context11.prev = _context11.next) {
|
|
1079
|
-
case 0:
|
|
1080
|
-
_context11.next = 2;
|
|
1081
|
-
return _this3.FormatPermission({
|
|
1082
|
-
policyId: policyId,
|
|
1083
|
-
policyWriteToken: policyWriteToken,
|
|
1084
|
-
permission: permission
|
|
1085
|
-
});
|
|
1086
|
-
|
|
1087
|
-
case 2:
|
|
1088
|
-
return _context11.abrupt("return", _context11.sent);
|
|
1089
|
-
|
|
1090
|
-
case 3:
|
|
1091
|
-
case "end":
|
|
1092
|
-
return _context11.stop();
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
}, _callee11);
|
|
1096
|
-
}));
|
|
1097
|
-
|
|
1098
|
-
return function (_x12) {
|
|
1099
|
-
return _ref12.apply(this, arguments);
|
|
1100
|
-
};
|
|
1101
|
-
}()));
|
|
1102
|
-
|
|
1103
|
-
case 12:
|
|
1104
|
-
return _context12.abrupt("return", _context12.sent);
|
|
1105
|
-
|
|
1106
|
-
case 13:
|
|
1107
|
-
case "end":
|
|
1108
|
-
return _context12.stop();
|
|
1109
|
-
}
|
|
1037
|
+
case 13:
|
|
1038
|
+
case "end":
|
|
1039
|
+
return _context12.stop();
|
|
1110
1040
|
}
|
|
1111
|
-
}
|
|
1112
|
-
})
|
|
1113
|
-
|
|
1114
|
-
function ItemPermissions(_x11) {
|
|
1115
|
-
return _ItemPermissions.apply(this, arguments);
|
|
1116
|
-
}
|
|
1117
|
-
|
|
1118
|
-
return ItemPermissions;
|
|
1119
|
-
}()
|
|
1041
|
+
}
|
|
1042
|
+
}, null, this);
|
|
1043
|
+
}
|
|
1120
1044
|
/**
|
|
1121
1045
|
* Add or modify permission for the specified subject to the specified item policy
|
|
1122
1046
|
*
|
|
@@ -1137,354 +1061,346 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1137
1061
|
|
|
1138
1062
|
}, {
|
|
1139
1063
|
key: "SetPermission",
|
|
1140
|
-
value: function () {
|
|
1141
|
-
var
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
}
|
|
1064
|
+
value: function SetPermission(_ref12) {
|
|
1065
|
+
var policyId, policyWriteToken, itemId, _ref12$subjectSource, subjectSource, _ref12$subjectType, subjectType, subjectName, subjectId, subjectNTPId, profileName, start, end, offlineDraft, policyLibraryId, existingPermissions, index, permissionSpec, subjectInfo, newMeta, userInfo, _newMeta, _userInfo;
|
|
1066
|
+
|
|
1067
|
+
return _regeneratorRuntime.async(function SetPermission$(_context13) {
|
|
1068
|
+
while (1) {
|
|
1069
|
+
switch (_context13.prev = _context13.next) {
|
|
1070
|
+
case 0:
|
|
1071
|
+
policyId = _ref12.policyId, policyWriteToken = _ref12.policyWriteToken, itemId = _ref12.itemId, _ref12$subjectSource = _ref12.subjectSource, subjectSource = _ref12$subjectSource === void 0 ? "fabric" : _ref12$subjectSource, _ref12$subjectType = _ref12.subjectType, subjectType = _ref12$subjectType === void 0 ? "group" : _ref12$subjectType, subjectName = _ref12.subjectName, subjectId = _ref12.subjectId, subjectNTPId = _ref12.subjectNTPId, profileName = _ref12.profileName, start = _ref12.start, end = _ref12.end;
|
|
1072
|
+
ValidatePresence("policyId", policyId);
|
|
1073
|
+
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
1074
|
+
ValidatePresence("itemId", itemId);
|
|
1075
|
+
ValidatePresence("subjectType", subjectType);
|
|
1076
|
+
ValidatePresence("subjectSource", subjectSource);
|
|
1077
|
+
ValidatePresence("subjectId", subjectId);
|
|
1078
|
+
ValidatePresence("profileName", profileName);
|
|
1079
|
+
start = this.FormatDate(start);
|
|
1080
|
+
end = this.FormatDate(end); // Check if we have an open offline draft for this policy
|
|
1081
|
+
|
|
1082
|
+
offlineDraft = this.offline && this.drafts[policyId] != null;
|
|
1083
|
+
policyLibraryId = null;
|
|
1084
|
+
|
|
1085
|
+
if (offlineDraft) {
|
|
1086
|
+
_context13.next = 16;
|
|
1087
|
+
break;
|
|
1088
|
+
}
|
|
1166
1089
|
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1090
|
+
_context13.next = 15;
|
|
1091
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
1092
|
+
objectId: policyId
|
|
1093
|
+
}));
|
|
1171
1094
|
|
|
1172
|
-
|
|
1173
|
-
|
|
1095
|
+
case 15:
|
|
1096
|
+
policyLibraryId = _context13.sent;
|
|
1174
1097
|
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
}
|
|
1098
|
+
case 16:
|
|
1099
|
+
// Allow address to be passed in for fabric subjects, though spec requires iusr/igrp hash
|
|
1100
|
+
if (subjectSource === "fabric") {
|
|
1101
|
+
if (subjectType === "group") {
|
|
1102
|
+
if (!subjectId.startsWith("igrp")) {
|
|
1103
|
+
subjectId = "igrp".concat(this.client.utils.AddressToHash(subjectId));
|
|
1104
|
+
}
|
|
1105
|
+
} else if (subjectType === "user") {
|
|
1106
|
+
if (!subjectId.startsWith("iusr")) {
|
|
1107
|
+
subjectId = "iusr".concat(this.client.utils.AddressToHash(subjectId));
|
|
1186
1108
|
}
|
|
1187
1109
|
}
|
|
1110
|
+
}
|
|
1188
1111
|
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
break;
|
|
1192
|
-
}
|
|
1193
|
-
|
|
1194
|
-
existingPermissions = this.drafts[policyId].meta["auth_policy_spec"][itemId];
|
|
1195
|
-
_context13.next = 24;
|
|
1112
|
+
if (!offlineDraft) {
|
|
1113
|
+
_context13.next = 21;
|
|
1196
1114
|
break;
|
|
1115
|
+
}
|
|
1197
1116
|
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1117
|
+
existingPermissions = this.drafts[policyId].meta["auth_policy_spec"][itemId];
|
|
1118
|
+
_context13.next = 24;
|
|
1119
|
+
break;
|
|
1120
|
+
|
|
1121
|
+
case 21:
|
|
1122
|
+
_context13.next = 23;
|
|
1123
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
|
|
1124
|
+
libraryId: policyLibraryId,
|
|
1125
|
+
objectId: policyId,
|
|
1126
|
+
writeToken: policyWriteToken,
|
|
1127
|
+
metadataSubtree: UrlJoin("auth_policy_spec", itemId)
|
|
1128
|
+
}));
|
|
1129
|
+
|
|
1130
|
+
case 23:
|
|
1131
|
+
existingPermissions = _context13.sent;
|
|
1132
|
+
|
|
1133
|
+
case 24:
|
|
1134
|
+
if (existingPermissions) {
|
|
1135
|
+
_context13.next = 26;
|
|
1136
|
+
break;
|
|
1137
|
+
}
|
|
1217
1138
|
|
|
1218
|
-
|
|
1219
|
-
if (existingPermissions.profiles[profileName]) {
|
|
1220
|
-
_context13.next = 28;
|
|
1221
|
-
break;
|
|
1222
|
-
}
|
|
1139
|
+
throw Error("Unable to add permissions to uninitialized item");
|
|
1223
1140
|
|
|
1224
|
-
|
|
1141
|
+
case 26:
|
|
1142
|
+
if (existingPermissions.profiles[profileName]) {
|
|
1143
|
+
_context13.next = 28;
|
|
1144
|
+
break;
|
|
1145
|
+
}
|
|
1225
1146
|
|
|
1226
|
-
|
|
1227
|
-
index = existingPermissions.permissions.findIndex(function (permission) {
|
|
1228
|
-
if (subjectSource === "fabric") {
|
|
1229
|
-
return permission.subject.id === subjectId;
|
|
1230
|
-
} else {
|
|
1231
|
-
return permission.subject.oauth_id === subjectId;
|
|
1232
|
-
}
|
|
1233
|
-
});
|
|
1147
|
+
throw Error("Profile '".concat(profileName, "' does not exist"));
|
|
1234
1148
|
|
|
1235
|
-
|
|
1236
|
-
|
|
1149
|
+
case 28:
|
|
1150
|
+
index = existingPermissions.permissions.findIndex(function (permission) {
|
|
1151
|
+
if (subjectSource === "fabric") {
|
|
1152
|
+
return permission.subject.id === subjectId;
|
|
1153
|
+
} else {
|
|
1154
|
+
return permission.subject.oauth_id === subjectId;
|
|
1237
1155
|
}
|
|
1156
|
+
});
|
|
1238
1157
|
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
if (start) {
|
|
1244
|
-
permissionSpec.start = start;
|
|
1245
|
-
}
|
|
1158
|
+
if (index < 0) {
|
|
1159
|
+
index = existingPermissions.permissions.length;
|
|
1160
|
+
}
|
|
1246
1161
|
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1162
|
+
permissionSpec = {
|
|
1163
|
+
profile: profileName
|
|
1164
|
+
};
|
|
1250
1165
|
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
}
|
|
1166
|
+
if (start) {
|
|
1167
|
+
permissionSpec.start = start;
|
|
1168
|
+
}
|
|
1255
1169
|
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
}
|
|
1170
|
+
if (end) {
|
|
1171
|
+
permissionSpec.end = end;
|
|
1172
|
+
}
|
|
1260
1173
|
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
type: "group"
|
|
1264
|
-
};
|
|
1265
|
-
_context13.next = 51;
|
|
1174
|
+
if (!(subjectSource === "fabric")) {
|
|
1175
|
+
_context13.next = 53;
|
|
1266
1176
|
break;
|
|
1177
|
+
}
|
|
1267
1178
|
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
_context13.next = 42;
|
|
1271
|
-
break;
|
|
1272
|
-
}
|
|
1273
|
-
|
|
1274
|
-
subjectInfo = {
|
|
1275
|
-
id: subjectId,
|
|
1276
|
-
type: "user"
|
|
1277
|
-
};
|
|
1278
|
-
_context13.next = 51;
|
|
1179
|
+
if (!(subjectType === "group")) {
|
|
1180
|
+
_context13.next = 38;
|
|
1279
1181
|
break;
|
|
1182
|
+
}
|
|
1280
1183
|
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1184
|
+
subjectInfo = {
|
|
1185
|
+
id: subjectId,
|
|
1186
|
+
type: "group"
|
|
1187
|
+
};
|
|
1188
|
+
_context13.next = 51;
|
|
1189
|
+
break;
|
|
1286
1190
|
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
};
|
|
1291
|
-
_context13.next = 51;
|
|
1191
|
+
case 38:
|
|
1192
|
+
if (!(subjectType === "user")) {
|
|
1193
|
+
_context13.next = 42;
|
|
1292
1194
|
break;
|
|
1195
|
+
}
|
|
1293
1196
|
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1197
|
+
subjectInfo = {
|
|
1198
|
+
id: subjectId,
|
|
1199
|
+
type: "user"
|
|
1200
|
+
};
|
|
1201
|
+
_context13.next = 51;
|
|
1202
|
+
break;
|
|
1299
1203
|
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
type: "otp_subject"
|
|
1304
|
-
};
|
|
1305
|
-
_context13.next = 51;
|
|
1204
|
+
case 42:
|
|
1205
|
+
if (!(subjectType === "ntp")) {
|
|
1206
|
+
_context13.next = 46;
|
|
1306
1207
|
break;
|
|
1208
|
+
}
|
|
1307
1209
|
|
|
1308
|
-
|
|
1309
|
-
|
|
1210
|
+
subjectInfo = {
|
|
1211
|
+
id: subjectId,
|
|
1212
|
+
type: "otp"
|
|
1213
|
+
};
|
|
1214
|
+
_context13.next = 51;
|
|
1215
|
+
break;
|
|
1310
1216
|
|
|
1311
|
-
|
|
1312
|
-
|
|
1217
|
+
case 46:
|
|
1218
|
+
if (!(subjectType === "ntp_subject")) {
|
|
1219
|
+
_context13.next = 50;
|
|
1313
1220
|
break;
|
|
1221
|
+
}
|
|
1314
1222
|
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1223
|
+
subjectInfo = {
|
|
1224
|
+
id: subjectId,
|
|
1225
|
+
otp_id: subjectNTPId,
|
|
1226
|
+
type: "otp_subject"
|
|
1227
|
+
};
|
|
1228
|
+
_context13.next = 51;
|
|
1229
|
+
break;
|
|
1320
1230
|
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1231
|
+
case 50:
|
|
1232
|
+
throw Error("Invalid subject type: ".concat(subjectType));
|
|
1233
|
+
|
|
1234
|
+
case 51:
|
|
1235
|
+
_context13.next = 66;
|
|
1236
|
+
break;
|
|
1325
1237
|
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
type: "oauth_group"
|
|
1330
|
-
};
|
|
1331
|
-
_context13.next = 63;
|
|
1238
|
+
case 53:
|
|
1239
|
+
if (!(subjectSource === "oauth")) {
|
|
1240
|
+
_context13.next = 65;
|
|
1332
1241
|
break;
|
|
1242
|
+
}
|
|
1333
1243
|
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
}
|
|
1244
|
+
if (!(subjectType === "group")) {
|
|
1245
|
+
_context13.next = 58;
|
|
1246
|
+
break;
|
|
1247
|
+
}
|
|
1339
1248
|
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1249
|
+
subjectInfo = {
|
|
1250
|
+
id: subjectName,
|
|
1251
|
+
oauth_id: subjectId,
|
|
1252
|
+
type: "oauth_group"
|
|
1253
|
+
};
|
|
1254
|
+
_context13.next = 63;
|
|
1255
|
+
break;
|
|
1256
|
+
|
|
1257
|
+
case 58:
|
|
1258
|
+
if (!(subjectType === "user")) {
|
|
1259
|
+
_context13.next = 62;
|
|
1346
1260
|
break;
|
|
1261
|
+
}
|
|
1347
1262
|
|
|
1348
|
-
|
|
1349
|
-
|
|
1263
|
+
subjectInfo = {
|
|
1264
|
+
id: subjectName,
|
|
1265
|
+
oauth_id: subjectId,
|
|
1266
|
+
type: "oauth_user"
|
|
1267
|
+
};
|
|
1268
|
+
_context13.next = 63;
|
|
1269
|
+
break;
|
|
1350
1270
|
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
break;
|
|
1271
|
+
case 62:
|
|
1272
|
+
throw Error("Invalid subject type: ".concat(subjectType));
|
|
1354
1273
|
|
|
1355
|
-
|
|
1356
|
-
|
|
1274
|
+
case 63:
|
|
1275
|
+
_context13.next = 66;
|
|
1276
|
+
break;
|
|
1357
1277
|
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
existingPermissions.permissions[index] = permissionSpec;
|
|
1278
|
+
case 65:
|
|
1279
|
+
throw Error("Invalid subject source: ".concat(subjectSource));
|
|
1361
1280
|
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
}
|
|
1281
|
+
case 66:
|
|
1282
|
+
permissionSpec.subject = subjectInfo;
|
|
1283
|
+
existingPermissions.permissions[index] = permissionSpec;
|
|
1366
1284
|
|
|
1285
|
+
if (offlineDraft) {
|
|
1367
1286
|
_context13.next = 71;
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
objectId: policyId,
|
|
1371
|
-
writeToken: policyWriteToken,
|
|
1372
|
-
metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions"),
|
|
1373
|
-
metadata: existingPermissions.permissions
|
|
1374
|
-
});
|
|
1375
|
-
|
|
1376
|
-
case 71:
|
|
1377
|
-
if (!(subjectSource === "fabric" && subjectType === "user")) {
|
|
1378
|
-
_context13.next = 85;
|
|
1379
|
-
break;
|
|
1380
|
-
}
|
|
1287
|
+
break;
|
|
1288
|
+
}
|
|
1381
1289
|
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1290
|
+
_context13.next = 71;
|
|
1291
|
+
return _regeneratorRuntime.awrap(this.client.ReplaceMetadata({
|
|
1292
|
+
libraryId: policyLibraryId,
|
|
1293
|
+
objectId: policyId,
|
|
1294
|
+
writeToken: policyWriteToken,
|
|
1295
|
+
metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions"),
|
|
1296
|
+
metadata: existingPermissions.permissions
|
|
1297
|
+
}));
|
|
1298
|
+
|
|
1299
|
+
case 71:
|
|
1300
|
+
if (!(subjectSource === "fabric" && subjectType === "user")) {
|
|
1301
|
+
_context13.next = 85;
|
|
1302
|
+
break;
|
|
1303
|
+
}
|
|
1386
1304
|
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1305
|
+
newMeta = {
|
|
1306
|
+
address: this.client.utils.HashToAddress(subjectId),
|
|
1307
|
+
name: subjectName
|
|
1308
|
+
};
|
|
1391
1309
|
|
|
1392
|
-
|
|
1393
|
-
_context13.next =
|
|
1310
|
+
if (!offlineDraft) {
|
|
1311
|
+
_context13.next = 77;
|
|
1394
1312
|
break;
|
|
1313
|
+
}
|
|
1395
1314
|
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
libraryId: policyLibraryId,
|
|
1400
|
-
objectId: policyId,
|
|
1401
|
-
writeToken: policyWriteToken,
|
|
1402
|
-
metadataSubtree: UrlJoin("auth_policy_settings", "fabric_users", this.client.utils.HashToAddress(subjectId))
|
|
1403
|
-
});
|
|
1315
|
+
this.drafts[policyId].meta["auth_policy_settings"]["fabric_users"][this.client.utils.HashToAddress(subjectId)] = newMeta;
|
|
1316
|
+
_context13.next = 83;
|
|
1317
|
+
break;
|
|
1404
1318
|
|
|
1405
|
-
|
|
1406
|
-
|
|
1319
|
+
case 77:
|
|
1320
|
+
_context13.next = 79;
|
|
1321
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
|
|
1322
|
+
libraryId: policyLibraryId,
|
|
1323
|
+
objectId: policyId,
|
|
1324
|
+
writeToken: policyWriteToken,
|
|
1325
|
+
metadataSubtree: UrlJoin("auth_policy_settings", "fabric_users", this.client.utils.HashToAddress(subjectId))
|
|
1326
|
+
}));
|
|
1407
1327
|
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
break;
|
|
1411
|
-
}
|
|
1328
|
+
case 79:
|
|
1329
|
+
userInfo = _context13.sent;
|
|
1412
1330
|
|
|
1331
|
+
if (userInfo) {
|
|
1413
1332
|
_context13.next = 83;
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
objectId: policyId,
|
|
1417
|
-
writeToken: policyWriteToken,
|
|
1418
|
-
metadataSubtree: UrlJoin("auth_policy_settings", "fabric_users", this.client.utils.HashToAddress(subjectId)),
|
|
1419
|
-
metadata: newMeta
|
|
1420
|
-
});
|
|
1333
|
+
break;
|
|
1334
|
+
}
|
|
1421
1335
|
|
|
1422
|
-
|
|
1336
|
+
_context13.next = 83;
|
|
1337
|
+
return _regeneratorRuntime.awrap(this.client.ReplaceMetadata({
|
|
1338
|
+
libraryId: policyLibraryId,
|
|
1339
|
+
objectId: policyId,
|
|
1340
|
+
writeToken: policyWriteToken,
|
|
1341
|
+
metadataSubtree: UrlJoin("auth_policy_settings", "fabric_users", this.client.utils.HashToAddress(subjectId)),
|
|
1342
|
+
metadata: newMeta
|
|
1343
|
+
}));
|
|
1344
|
+
|
|
1345
|
+
case 83:
|
|
1346
|
+
_context13.next = 97;
|
|
1347
|
+
break;
|
|
1348
|
+
|
|
1349
|
+
case 85:
|
|
1350
|
+
if (!(subjectSource === "fabric" && subjectType === "ntp")) {
|
|
1423
1351
|
_context13.next = 97;
|
|
1424
1352
|
break;
|
|
1353
|
+
}
|
|
1425
1354
|
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
_newMeta = {
|
|
1433
|
-
address: subjectId,
|
|
1434
|
-
ntpId: subjectId,
|
|
1435
|
-
name: subjectName,
|
|
1436
|
-
type: "ntpInstance"
|
|
1437
|
-
};
|
|
1438
|
-
|
|
1439
|
-
if (!offlineDraft) {
|
|
1440
|
-
_context13.next = 91;
|
|
1441
|
-
break;
|
|
1442
|
-
}
|
|
1355
|
+
_newMeta = {
|
|
1356
|
+
address: subjectId,
|
|
1357
|
+
ntpId: subjectId,
|
|
1358
|
+
name: subjectName,
|
|
1359
|
+
type: "ntpInstance"
|
|
1360
|
+
};
|
|
1443
1361
|
|
|
1444
|
-
|
|
1445
|
-
_context13.next =
|
|
1362
|
+
if (!offlineDraft) {
|
|
1363
|
+
_context13.next = 91;
|
|
1446
1364
|
break;
|
|
1365
|
+
}
|
|
1447
1366
|
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
libraryId: policyLibraryId,
|
|
1452
|
-
objectId: policyId,
|
|
1453
|
-
writeToken: policyWriteToken,
|
|
1454
|
-
metadataSubtree: UrlJoin("auth_policy_settings", "ntp_instances", subjectId)
|
|
1455
|
-
});
|
|
1367
|
+
this.drafts[policyId].meta["auth_policy_settings"]["ntp_instances"][subjectId] = _newMeta;
|
|
1368
|
+
_context13.next = 97;
|
|
1369
|
+
break;
|
|
1456
1370
|
|
|
1457
|
-
|
|
1458
|
-
|
|
1371
|
+
case 91:
|
|
1372
|
+
_context13.next = 93;
|
|
1373
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
|
|
1374
|
+
libraryId: policyLibraryId,
|
|
1375
|
+
objectId: policyId,
|
|
1376
|
+
writeToken: policyWriteToken,
|
|
1377
|
+
metadataSubtree: UrlJoin("auth_policy_settings", "ntp_instances", subjectId)
|
|
1378
|
+
}));
|
|
1459
1379
|
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
break;
|
|
1463
|
-
}
|
|
1380
|
+
case 93:
|
|
1381
|
+
_userInfo = _context13.sent;
|
|
1464
1382
|
|
|
1383
|
+
if (_userInfo) {
|
|
1465
1384
|
_context13.next = 97;
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
objectId: policyId,
|
|
1469
|
-
writeToken: policyWriteToken,
|
|
1470
|
-
metadataSubtree: UrlJoin("auth_policy_settings", "ntp_instances", subjectId),
|
|
1471
|
-
metadata: _newMeta
|
|
1472
|
-
});
|
|
1385
|
+
break;
|
|
1386
|
+
}
|
|
1473
1387
|
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1388
|
+
_context13.next = 97;
|
|
1389
|
+
return _regeneratorRuntime.awrap(this.client.ReplaceMetadata({
|
|
1390
|
+
libraryId: policyLibraryId,
|
|
1391
|
+
objectId: policyId,
|
|
1392
|
+
writeToken: policyWriteToken,
|
|
1393
|
+
metadataSubtree: UrlJoin("auth_policy_settings", "ntp_instances", subjectId),
|
|
1394
|
+
metadata: _newMeta
|
|
1395
|
+
}));
|
|
1396
|
+
|
|
1397
|
+
case 97:
|
|
1398
|
+
case "end":
|
|
1399
|
+
return _context13.stop();
|
|
1478
1400
|
}
|
|
1479
|
-
}
|
|
1480
|
-
})
|
|
1481
|
-
|
|
1482
|
-
function SetPermission(_x13) {
|
|
1483
|
-
return _SetPermission.apply(this, arguments);
|
|
1484
|
-
}
|
|
1485
|
-
|
|
1486
|
-
return SetPermission;
|
|
1487
|
-
}()
|
|
1401
|
+
}
|
|
1402
|
+
}, null, this);
|
|
1403
|
+
}
|
|
1488
1404
|
/**
|
|
1489
1405
|
* Remove permission for the specified subject from the specified item policy
|
|
1490
1406
|
*
|
|
@@ -1498,120 +1414,106 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1498
1414
|
|
|
1499
1415
|
}, {
|
|
1500
1416
|
key: "RemovePermission",
|
|
1501
|
-
value: function () {
|
|
1502
|
-
var
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
}
|
|
1537
|
-
|
|
1538
|
-
return _context15.abrupt("return");
|
|
1417
|
+
value: function RemovePermission(_ref13) {
|
|
1418
|
+
var _this4 = this;
|
|
1419
|
+
|
|
1420
|
+
var policyId, policyWriteToken, itemId, subjectId, policyLibraryId, permissions, id;
|
|
1421
|
+
return _regeneratorRuntime.async(function RemovePermission$(_context15) {
|
|
1422
|
+
while (1) {
|
|
1423
|
+
switch (_context15.prev = _context15.next) {
|
|
1424
|
+
case 0:
|
|
1425
|
+
policyId = _ref13.policyId, policyWriteToken = _ref13.policyWriteToken, itemId = _ref13.itemId, subjectId = _ref13.subjectId;
|
|
1426
|
+
ValidatePresence("policyId", policyId);
|
|
1427
|
+
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
1428
|
+
ValidatePresence("itemId", itemId);
|
|
1429
|
+
ValidatePresence("subjectId", subjectId);
|
|
1430
|
+
_context15.next = 7;
|
|
1431
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
1432
|
+
objectId: policyId
|
|
1433
|
+
}));
|
|
1434
|
+
|
|
1435
|
+
case 7:
|
|
1436
|
+
policyLibraryId = _context15.sent;
|
|
1437
|
+
_context15.next = 10;
|
|
1438
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
|
|
1439
|
+
libraryId: policyLibraryId,
|
|
1440
|
+
objectId: policyId,
|
|
1441
|
+
writeToken: policyWriteToken,
|
|
1442
|
+
metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions")
|
|
1443
|
+
}));
|
|
1444
|
+
|
|
1445
|
+
case 10:
|
|
1446
|
+
permissions = _context15.sent;
|
|
1447
|
+
|
|
1448
|
+
if (permissions) {
|
|
1449
|
+
_context15.next = 13;
|
|
1450
|
+
break;
|
|
1451
|
+
}
|
|
1539
1452
|
|
|
1540
|
-
|
|
1541
|
-
if (!subjectId.startsWith("0x")) {
|
|
1542
|
-
_context15.next = 23;
|
|
1543
|
-
break;
|
|
1544
|
-
}
|
|
1453
|
+
return _context15.abrupt("return");
|
|
1545
1454
|
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1455
|
+
case 13:
|
|
1456
|
+
if (!subjectId.startsWith("0x")) {
|
|
1457
|
+
_context15.next = 23;
|
|
1458
|
+
break;
|
|
1459
|
+
}
|
|
1551
1460
|
|
|
1552
|
-
|
|
1553
|
-
|
|
1461
|
+
id = this.client.utils.AddressToObjectId(subjectId);
|
|
1462
|
+
_context15.next = 17;
|
|
1463
|
+
return _regeneratorRuntime.awrap(this.client.AccessType({
|
|
1464
|
+
id: id
|
|
1465
|
+
}));
|
|
1554
1466
|
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
break;
|
|
1558
|
-
}
|
|
1467
|
+
case 17:
|
|
1468
|
+
_context15.t0 = _context15.sent;
|
|
1559
1469
|
|
|
1560
|
-
|
|
1561
|
-
_context15.next =
|
|
1470
|
+
if (!(_context15.t0 === "group")) {
|
|
1471
|
+
_context15.next = 22;
|
|
1562
1472
|
break;
|
|
1473
|
+
}
|
|
1563
1474
|
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
return _this4.client.DeleteMetadata({
|
|
1582
|
-
libraryId: policyLibraryId,
|
|
1583
|
-
objectId: policyId,
|
|
1584
|
-
writeToken: policyWriteToken,
|
|
1585
|
-
metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions", index.toString())
|
|
1586
|
-
});
|
|
1587
|
-
|
|
1588
|
-
case 3:
|
|
1589
|
-
case "end":
|
|
1590
|
-
return _context14.stop();
|
|
1475
|
+
subjectId = "igrp".concat(this.client.utils.AddressToHash(subjectId));
|
|
1476
|
+
_context15.next = 23;
|
|
1477
|
+
break;
|
|
1478
|
+
|
|
1479
|
+
case 22:
|
|
1480
|
+
subjectId = "iusr".concat(this.client.utils.AddressToHash(subjectId));
|
|
1481
|
+
|
|
1482
|
+
case 23:
|
|
1483
|
+
_context15.next = 25;
|
|
1484
|
+
return _regeneratorRuntime.awrap(Promise.all(permissions.map(function _callee2(permission, index) {
|
|
1485
|
+
return _regeneratorRuntime.async(function _callee2$(_context14) {
|
|
1486
|
+
while (1) {
|
|
1487
|
+
switch (_context14.prev = _context14.next) {
|
|
1488
|
+
case 0:
|
|
1489
|
+
if (!(permission.subject.id === subjectId || permission.subject.oauth_id === subjectId)) {
|
|
1490
|
+
_context14.next = 3;
|
|
1491
|
+
break;
|
|
1591
1492
|
}
|
|
1592
|
-
}
|
|
1593
|
-
}, _callee14);
|
|
1594
|
-
}));
|
|
1595
|
-
|
|
1596
|
-
return function (_x15, _x16) {
|
|
1597
|
-
return _ref15.apply(this, arguments);
|
|
1598
|
-
};
|
|
1599
|
-
}()));
|
|
1600
|
-
|
|
1601
|
-
case 25:
|
|
1602
|
-
case "end":
|
|
1603
|
-
return _context15.stop();
|
|
1604
|
-
}
|
|
1605
|
-
}
|
|
1606
|
-
}, _callee15, this);
|
|
1607
|
-
}));
|
|
1608
1493
|
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1494
|
+
_context14.next = 3;
|
|
1495
|
+
return _regeneratorRuntime.awrap(_this4.client.DeleteMetadata({
|
|
1496
|
+
libraryId: policyLibraryId,
|
|
1497
|
+
objectId: policyId,
|
|
1498
|
+
writeToken: policyWriteToken,
|
|
1499
|
+
metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions", index.toString())
|
|
1500
|
+
}));
|
|
1501
|
+
|
|
1502
|
+
case 3:
|
|
1503
|
+
case "end":
|
|
1504
|
+
return _context14.stop();
|
|
1505
|
+
}
|
|
1506
|
+
}
|
|
1507
|
+
});
|
|
1508
|
+
})));
|
|
1612
1509
|
|
|
1613
|
-
|
|
1614
|
-
|
|
1510
|
+
case 25:
|
|
1511
|
+
case "end":
|
|
1512
|
+
return _context15.stop();
|
|
1513
|
+
}
|
|
1514
|
+
}
|
|
1515
|
+
}, null, this);
|
|
1516
|
+
}
|
|
1615
1517
|
/**
|
|
1616
1518
|
* Retrieve all permissions for the specified subject.
|
|
1617
1519
|
*
|
|
@@ -1626,138 +1528,124 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1626
1528
|
|
|
1627
1529
|
}, {
|
|
1628
1530
|
key: "SubjectPermissions",
|
|
1629
|
-
value: function () {
|
|
1630
|
-
var
|
|
1631
|
-
var _this5 = this;
|
|
1632
|
-
|
|
1633
|
-
var policyId, policyWriteToken, subjectId, id, policyLibraryId, policy, allSubjectPermissions, _i, _Object$keys, itemId, itemPermissions, subjectPermissions;
|
|
1634
|
-
|
|
1635
|
-
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1636
|
-
while (1) {
|
|
1637
|
-
switch (_context17.prev = _context17.next) {
|
|
1638
|
-
case 0:
|
|
1639
|
-
policyId = _ref16.policyId, policyWriteToken = _ref16.policyWriteToken, subjectId = _ref16.subjectId;
|
|
1640
|
-
ValidatePresence("policyId", policyId);
|
|
1641
|
-
ValidatePresence("subjectId", subjectId); // Convert address to appropriate ID
|
|
1642
|
-
|
|
1643
|
-
if (!subjectId.startsWith("0x")) {
|
|
1644
|
-
_context17.next = 13;
|
|
1645
|
-
break;
|
|
1646
|
-
}
|
|
1647
|
-
|
|
1648
|
-
id = this.client.utils.AddressToObjectId(subjectId);
|
|
1649
|
-
_context17.next = 7;
|
|
1650
|
-
return this.client.AccessType({
|
|
1651
|
-
id: id
|
|
1652
|
-
});
|
|
1531
|
+
value: function SubjectPermissions(_ref14) {
|
|
1532
|
+
var _this5 = this;
|
|
1653
1533
|
|
|
1654
|
-
|
|
1655
|
-
_context17.t0 = _context17.sent;
|
|
1534
|
+
var policyId, policyWriteToken, subjectId, id, policyLibraryId, policy, allSubjectPermissions, _i, _Object$keys, itemId, itemPermissions, subjectPermissions;
|
|
1656
1535
|
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1536
|
+
return _regeneratorRuntime.async(function SubjectPermissions$(_context17) {
|
|
1537
|
+
while (1) {
|
|
1538
|
+
switch (_context17.prev = _context17.next) {
|
|
1539
|
+
case 0:
|
|
1540
|
+
policyId = _ref14.policyId, policyWriteToken = _ref14.policyWriteToken, subjectId = _ref14.subjectId;
|
|
1541
|
+
ValidatePresence("policyId", policyId);
|
|
1542
|
+
ValidatePresence("subjectId", subjectId); // Convert address to appropriate ID
|
|
1661
1543
|
|
|
1662
|
-
|
|
1544
|
+
if (!subjectId.startsWith("0x")) {
|
|
1663
1545
|
_context17.next = 13;
|
|
1664
1546
|
break;
|
|
1547
|
+
}
|
|
1665
1548
|
|
|
1666
|
-
|
|
1667
|
-
|
|
1549
|
+
id = this.client.utils.AddressToObjectId(subjectId);
|
|
1550
|
+
_context17.next = 7;
|
|
1551
|
+
return _regeneratorRuntime.awrap(this.client.AccessType({
|
|
1552
|
+
id: id
|
|
1553
|
+
}));
|
|
1668
1554
|
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
return this.client.ContentObjectLibraryId({
|
|
1672
|
-
objectId: policyId
|
|
1673
|
-
});
|
|
1674
|
-
|
|
1675
|
-
case 15:
|
|
1676
|
-
policyLibraryId = _context17.sent;
|
|
1677
|
-
_context17.next = 18;
|
|
1678
|
-
return this.client.ContentObjectMetadata({
|
|
1679
|
-
libraryId: policyLibraryId,
|
|
1680
|
-
objectId: policyId,
|
|
1681
|
-
writeToken: policyWriteToken,
|
|
1682
|
-
metadataSubtree: UrlJoin("auth_policy_spec")
|
|
1683
|
-
});
|
|
1555
|
+
case 7:
|
|
1556
|
+
_context17.t0 = _context17.sent;
|
|
1684
1557
|
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1558
|
+
if (!(_context17.t0 === "group")) {
|
|
1559
|
+
_context17.next = 12;
|
|
1560
|
+
break;
|
|
1561
|
+
}
|
|
1689
1562
|
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1563
|
+
subjectId = "igrp".concat(this.client.utils.AddressToHash(subjectId));
|
|
1564
|
+
_context17.next = 13;
|
|
1565
|
+
break;
|
|
1566
|
+
|
|
1567
|
+
case 12:
|
|
1568
|
+
subjectId = "iusr".concat(this.client.utils.AddressToHash(subjectId));
|
|
1569
|
+
|
|
1570
|
+
case 13:
|
|
1571
|
+
_context17.next = 15;
|
|
1572
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectLibraryId({
|
|
1573
|
+
objectId: policyId
|
|
1574
|
+
}));
|
|
1575
|
+
|
|
1576
|
+
case 15:
|
|
1577
|
+
policyLibraryId = _context17.sent;
|
|
1578
|
+
_context17.next = 18;
|
|
1579
|
+
return _regeneratorRuntime.awrap(this.client.ContentObjectMetadata({
|
|
1580
|
+
libraryId: policyLibraryId,
|
|
1581
|
+
objectId: policyId,
|
|
1582
|
+
writeToken: policyWriteToken,
|
|
1583
|
+
metadataSubtree: UrlJoin("auth_policy_spec")
|
|
1584
|
+
}));
|
|
1585
|
+
|
|
1586
|
+
case 18:
|
|
1587
|
+
policy = _context17.sent;
|
|
1588
|
+
allSubjectPermissions = {};
|
|
1589
|
+
_i = 0, _Object$keys = Object.keys(policy);
|
|
1590
|
+
|
|
1591
|
+
case 21:
|
|
1592
|
+
if (!(_i < _Object$keys.length)) {
|
|
1593
|
+
_context17.next = 31;
|
|
1594
|
+
break;
|
|
1595
|
+
}
|
|
1695
1596
|
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1700
|
-
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
}));
|
|
1724
|
-
|
|
1725
|
-
return function (_x18) {
|
|
1726
|
-
return _ref17.apply(this, arguments);
|
|
1727
|
-
};
|
|
1728
|
-
}()));
|
|
1729
|
-
|
|
1730
|
-
case 26:
|
|
1731
|
-
subjectPermissions = _context17.sent;
|
|
1732
|
-
|
|
1733
|
-
if (subjectPermissions.length > 0) {
|
|
1734
|
-
allSubjectPermissions[itemId] = _objectSpread(_objectSpread({}, policy[itemId]), {}, {
|
|
1735
|
-
permissions: subjectPermissions
|
|
1736
|
-
});
|
|
1737
|
-
}
|
|
1597
|
+
itemId = _Object$keys[_i];
|
|
1598
|
+
itemPermissions = policy[itemId].permissions || [];
|
|
1599
|
+
_context17.next = 26;
|
|
1600
|
+
return _regeneratorRuntime.awrap(Promise.all(itemPermissions.filter(function (permission) {
|
|
1601
|
+
return (permission.subject || {}).oauth_id === subjectId || (permission.subject || {}).id === subjectId;
|
|
1602
|
+
}).map(function _callee3(permission) {
|
|
1603
|
+
return _regeneratorRuntime.async(function _callee3$(_context16) {
|
|
1604
|
+
while (1) {
|
|
1605
|
+
switch (_context16.prev = _context16.next) {
|
|
1606
|
+
case 0:
|
|
1607
|
+
_context16.next = 2;
|
|
1608
|
+
return _regeneratorRuntime.awrap(_this5.FormatPermission({
|
|
1609
|
+
policyId: policyId,
|
|
1610
|
+
policyWriteToken: policyWriteToken,
|
|
1611
|
+
permission: permission
|
|
1612
|
+
}));
|
|
1613
|
+
|
|
1614
|
+
case 2:
|
|
1615
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1616
|
+
|
|
1617
|
+
case 3:
|
|
1618
|
+
case "end":
|
|
1619
|
+
return _context16.stop();
|
|
1620
|
+
}
|
|
1621
|
+
}
|
|
1622
|
+
});
|
|
1623
|
+
})));
|
|
1738
1624
|
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
_context17.next = 21;
|
|
1742
|
-
break;
|
|
1625
|
+
case 26:
|
|
1626
|
+
subjectPermissions = _context17.sent;
|
|
1743
1627
|
|
|
1744
|
-
|
|
1745
|
-
|
|
1628
|
+
if (subjectPermissions.length > 0) {
|
|
1629
|
+
allSubjectPermissions[itemId] = _objectSpread({}, policy[itemId], {
|
|
1630
|
+
permissions: subjectPermissions
|
|
1631
|
+
});
|
|
1632
|
+
}
|
|
1746
1633
|
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
}
|
|
1752
|
-
}, _callee17, this);
|
|
1753
|
-
}));
|
|
1634
|
+
case 28:
|
|
1635
|
+
_i++;
|
|
1636
|
+
_context17.next = 21;
|
|
1637
|
+
break;
|
|
1754
1638
|
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
}
|
|
1639
|
+
case 31:
|
|
1640
|
+
return _context17.abrupt("return", allSubjectPermissions);
|
|
1758
1641
|
|
|
1759
|
-
|
|
1760
|
-
|
|
1642
|
+
case 32:
|
|
1643
|
+
case "end":
|
|
1644
|
+
return _context17.stop();
|
|
1645
|
+
}
|
|
1646
|
+
}
|
|
1647
|
+
}, null, this);
|
|
1648
|
+
}
|
|
1761
1649
|
/**
|
|
1762
1650
|
* Remove all permissions for the specified subject.
|
|
1763
1651
|
*
|
|
@@ -1770,70 +1658,56 @@ var PermissionsClient = /*#__PURE__*/function () {
|
|
|
1770
1658
|
|
|
1771
1659
|
}, {
|
|
1772
1660
|
key: "RemoveSubjectPermissions",
|
|
1773
|
-
value: function () {
|
|
1774
|
-
var
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1661
|
+
value: function RemoveSubjectPermissions(_ref15) {
|
|
1662
|
+
var _this6 = this;
|
|
1663
|
+
|
|
1664
|
+
var policyId, policyWriteToken, subjectId, subjectPermissions;
|
|
1665
|
+
return _regeneratorRuntime.async(function RemoveSubjectPermissions$(_context19) {
|
|
1666
|
+
while (1) {
|
|
1667
|
+
switch (_context19.prev = _context19.next) {
|
|
1668
|
+
case 0:
|
|
1669
|
+
policyId = _ref15.policyId, policyWriteToken = _ref15.policyWriteToken, subjectId = _ref15.subjectId;
|
|
1670
|
+
ValidatePresence("policyId", policyId);
|
|
1671
|
+
ValidatePresence("policyWriteToken", policyWriteToken);
|
|
1672
|
+
ValidatePresence("subjectId", subjectId);
|
|
1673
|
+
_context19.next = 6;
|
|
1674
|
+
return _regeneratorRuntime.awrap(this.SubjectPermissions({
|
|
1675
|
+
policyId: policyId,
|
|
1676
|
+
policyWriteToken: policyWriteToken,
|
|
1677
|
+
subjectId: subjectId
|
|
1678
|
+
}));
|
|
1679
|
+
|
|
1680
|
+
case 6:
|
|
1681
|
+
subjectPermissions = _context19.sent;
|
|
1682
|
+
_context19.next = 9;
|
|
1683
|
+
return _regeneratorRuntime.awrap(this.client.utils.LimitedMap(5, Object.keys(subjectPermissions), function _callee4(itemId) {
|
|
1684
|
+
return _regeneratorRuntime.async(function _callee4$(_context18) {
|
|
1685
|
+
while (1) {
|
|
1686
|
+
switch (_context18.prev = _context18.next) {
|
|
1687
|
+
case 0:
|
|
1688
|
+
_context18.next = 2;
|
|
1689
|
+
return _regeneratorRuntime.awrap(_this6.RemovePermission({
|
|
1690
|
+
policyId: policyId,
|
|
1691
|
+
policyWriteToken: policyWriteToken,
|
|
1692
|
+
subjectId: subjectId,
|
|
1693
|
+
itemId: itemId
|
|
1694
|
+
}));
|
|
1695
|
+
|
|
1696
|
+
case 2:
|
|
1697
|
+
case "end":
|
|
1698
|
+
return _context18.stop();
|
|
1699
|
+
}
|
|
1700
|
+
}
|
|
1791
1701
|
});
|
|
1702
|
+
}));
|
|
1792
1703
|
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
return this.client.utils.LimitedMap(5, Object.keys(subjectPermissions), /*#__PURE__*/function () {
|
|
1797
|
-
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(itemId) {
|
|
1798
|
-
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1799
|
-
while (1) {
|
|
1800
|
-
switch (_context18.prev = _context18.next) {
|
|
1801
|
-
case 0:
|
|
1802
|
-
_context18.next = 2;
|
|
1803
|
-
return _this6.RemovePermission({
|
|
1804
|
-
policyId: policyId,
|
|
1805
|
-
policyWriteToken: policyWriteToken,
|
|
1806
|
-
subjectId: subjectId,
|
|
1807
|
-
itemId: itemId
|
|
1808
|
-
});
|
|
1809
|
-
|
|
1810
|
-
case 2:
|
|
1811
|
-
case "end":
|
|
1812
|
-
return _context18.stop();
|
|
1813
|
-
}
|
|
1814
|
-
}
|
|
1815
|
-
}, _callee18);
|
|
1816
|
-
}));
|
|
1817
|
-
|
|
1818
|
-
return function (_x20) {
|
|
1819
|
-
return _ref19.apply(this, arguments);
|
|
1820
|
-
};
|
|
1821
|
-
}());
|
|
1822
|
-
|
|
1823
|
-
case 9:
|
|
1824
|
-
case "end":
|
|
1825
|
-
return _context19.stop();
|
|
1826
|
-
}
|
|
1704
|
+
case 9:
|
|
1705
|
+
case "end":
|
|
1706
|
+
return _context19.stop();
|
|
1827
1707
|
}
|
|
1828
|
-
}
|
|
1829
|
-
})
|
|
1830
|
-
|
|
1831
|
-
function RemoveSubjectPermissions(_x19) {
|
|
1832
|
-
return _RemoveSubjectPermissions.apply(this, arguments);
|
|
1833
|
-
}
|
|
1834
|
-
|
|
1835
|
-
return RemoveSubjectPermissions;
|
|
1836
|
-
}()
|
|
1708
|
+
}
|
|
1709
|
+
}, null, this);
|
|
1710
|
+
}
|
|
1837
1711
|
}]);
|
|
1838
1712
|
|
|
1839
1713
|
return PermissionsClient;
|