@eluvio/elv-client-js 4.0.114 → 4.0.116

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (129) hide show
  1. package/dist/ElvClient-min.js +68 -0
  2. package/dist/ElvClient-node-min.js +67 -0
  3. package/dist/ElvFrameClient-min.js +60 -0
  4. package/dist/ElvPermissionsClient-min.js +60 -0
  5. package/dist/ElvWalletClient-min.js +68 -0
  6. package/dist/ElvWalletClient-node-min.js +67 -0
  7. package/dist/src/AuthorizationClient.js +2166 -0
  8. package/dist/src/ContentObjectAudit.js +175 -0
  9. package/dist/src/ContentObjectVerification.js +281 -0
  10. package/dist/src/Crypto.js +412 -0
  11. package/dist/src/ElvClient.js +2063 -0
  12. package/dist/src/ElvWallet.js +247 -0
  13. package/dist/src/EthClient.js +1153 -0
  14. package/dist/src/FrameClient.js +484 -0
  15. package/dist/src/HttpClient.js +314 -0
  16. package/dist/src/Id.js +20 -0
  17. package/dist/src/LogMessage.js +25 -0
  18. package/dist/src/PermissionsClient.js +1556 -0
  19. package/dist/src/RemoteSigner.js +383 -0
  20. package/dist/src/UserProfileClient.js +1465 -0
  21. package/dist/src/Utils.js +893 -0
  22. package/dist/src/Validation.js +121 -0
  23. package/dist/src/abr_profiles/abr_profile_live_drm.js +1661 -0
  24. package/dist/src/abr_profiles/abr_profile_live_to_vod.js +1606 -0
  25. package/dist/src/client/ABRPublishing.js +1018 -0
  26. package/dist/src/client/AccessGroups.js +1503 -0
  27. package/dist/src/client/ContentAccess.js +5202 -0
  28. package/dist/src/client/ContentManagement.js +2680 -0
  29. package/dist/src/client/Contracts.js +1520 -0
  30. package/dist/src/client/Files.js +2181 -0
  31. package/dist/src/client/LiveConf.js +567 -0
  32. package/dist/src/client/LiveStream.js +2638 -0
  33. package/dist/src/client/NFT.js +162 -0
  34. package/dist/src/client/NTP.js +581 -0
  35. package/dist/src/contracts/v2/AccessIndexor.js +831 -0
  36. package/dist/src/contracts/v2/Accessible.js +31 -0
  37. package/dist/src/contracts/v2/BaseAccessControlGroup.js +1263 -0
  38. package/dist/src/contracts/v2/BaseAccessWallet.js +1609 -0
  39. package/dist/src/contracts/v2/BaseAccessWalletFactory.js +93 -0
  40. package/dist/src/contracts/v2/BaseContent.js +1076 -0
  41. package/dist/src/contracts/v2/BaseContentFactory.js +219 -0
  42. package/dist/src/contracts/v2/BaseContentSpace.js +1352 -0
  43. package/dist/src/contracts/v2/BaseContentType.js +364 -0
  44. package/dist/src/contracts/v2/BaseFactory.js +107 -0
  45. package/dist/src/contracts/v2/BaseGroupFactory.js +93 -0
  46. package/dist/src/contracts/v2/BaseLibrary.js +1041 -0
  47. package/dist/src/contracts/v2/BaseLibraryFactory.js +96 -0
  48. package/dist/src/contracts/v2/Certifyer.js +86 -0
  49. package/dist/src/contracts/v2/Container.js +540 -0
  50. package/dist/src/contracts/v2/Content.js +443 -0
  51. package/dist/src/contracts/v2/Editable.js +306 -0
  52. package/dist/src/contracts/v2/ExternalUserWallet.js +379 -0
  53. package/dist/src/contracts/v2/IFactorySpace.js +57 -0
  54. package/dist/src/contracts/v2/IKmsSpace.js +52 -0
  55. package/dist/src/contracts/v2/INodeSpace.js +18 -0
  56. package/dist/src/contracts/v2/IUserSpace.js +18 -0
  57. package/dist/src/contracts/v2/LvRecordableStream.js +1037 -0
  58. package/dist/src/contracts/v2/LvRecording.js +627 -0
  59. package/dist/src/contracts/v2/LvStreamRightsHolder.js +562 -0
  60. package/dist/src/contracts/v2/MetaObject.js +119 -0
  61. package/dist/src/contracts/v2/Node.js +167 -0
  62. package/dist/src/contracts/v2/NodeSpace.js +273 -0
  63. package/dist/src/contracts/v2/Ownable.js +87 -0
  64. package/dist/src/contracts/v2/PaymentService.js +627 -0
  65. package/dist/src/contracts/v2/Precompile.js +15 -0
  66. package/dist/src/contracts/v2/Transactable.js +82 -0
  67. package/dist/src/contracts/v2/UserSpace.js +29 -0
  68. package/dist/src/contracts/v2/Utils.js +18 -0
  69. package/dist/src/contracts/v2/Verifier.js +53 -0
  70. package/dist/src/contracts/v2/strings.js +4 -0
  71. package/dist/src/contracts/v3/AccessIndexor.js +774 -0
  72. package/dist/src/contracts/v3/Accessible.js +232 -0
  73. package/dist/src/contracts/v3/Adminable.js +107 -0
  74. package/dist/src/contracts/v3/AvailsDelivery.js +586 -0
  75. package/dist/src/contracts/v3/BaseAccessControlGroup.js +1603 -0
  76. package/dist/src/contracts/v3/BaseAccessWallet.js +1628 -0
  77. package/dist/src/contracts/v3/BaseAccessWalletFactory.js +112 -0
  78. package/dist/src/contracts/v3/BaseContent.js +1312 -0
  79. package/dist/src/contracts/v3/BaseContentFactory.js +183 -0
  80. package/dist/src/contracts/v3/BaseContentFactoryExt.js +175 -0
  81. package/dist/src/contracts/v3/BaseContentSpace.js +1515 -0
  82. package/dist/src/contracts/v3/BaseContentType.js +527 -0
  83. package/dist/src/contracts/v3/BaseFactory.js +126 -0
  84. package/dist/src/contracts/v3/BaseGroupFactory.js +112 -0
  85. package/dist/src/contracts/v3/BaseLibrary.js +1204 -0
  86. package/dist/src/contracts/v3/BaseLibraryFactory.js +115 -0
  87. package/dist/src/contracts/v3/BaseTenantSpace.js +1587 -0
  88. package/dist/src/contracts/v3/Certifyer.js +86 -0
  89. package/dist/src/contracts/v3/Container.js +739 -0
  90. package/dist/src/contracts/v3/Content.js +438 -0
  91. package/dist/src/contracts/v3/CounterObject.js +243 -0
  92. package/dist/src/contracts/v3/Editable.js +519 -0
  93. package/dist/src/contracts/v3/EncToken.js +4 -0
  94. package/dist/src/contracts/v3/ExternalUserWallet.js +587 -0
  95. package/dist/src/contracts/v3/IAdmin.js +18 -0
  96. package/dist/src/contracts/v3/IFactorySpace.js +57 -0
  97. package/dist/src/contracts/v3/IKmsSpace.js +52 -0
  98. package/dist/src/contracts/v3/INodeSpace.js +18 -0
  99. package/dist/src/contracts/v3/IUserSpace.js +32 -0
  100. package/dist/src/contracts/v3/LvRecordableStream.js +1032 -0
  101. package/dist/src/contracts/v3/LvRecording.js +650 -0
  102. package/dist/src/contracts/v3/LvStreamRightsHolder.js +557 -0
  103. package/dist/src/contracts/v3/MetaObject.js +144 -0
  104. package/dist/src/contracts/v3/Node.js +178 -0
  105. package/dist/src/contracts/v3/NodeSpace.js +284 -0
  106. package/dist/src/contracts/v3/Ownable.js +98 -0
  107. package/dist/src/contracts/v3/PaymentService.js +622 -0
  108. package/dist/src/contracts/v3/Precompile.js +26 -0
  109. package/dist/src/contracts/v3/TenantFuncsBase.js +351 -0
  110. package/dist/src/contracts/v3/Transactable.js +82 -0
  111. package/dist/src/contracts/v3/UserSpace.js +43 -0
  112. package/dist/src/contracts/v3/Utils.js +18 -0
  113. package/dist/src/contracts/v3/Verifier.js +53 -0
  114. package/dist/src/contracts/v3/strings.js +4 -0
  115. package/dist/src/contracts/v3b/BaseAccessControlGroup.js +1704 -0
  116. package/dist/src/events/Topics.js +1793 -0
  117. package/dist/src/index.js +8 -0
  118. package/dist/src/walletClient/ClientMethods.js +3102 -0
  119. package/dist/src/walletClient/Configuration.js +38 -0
  120. package/dist/src/walletClient/Notifications.js +168 -0
  121. package/dist/src/walletClient/Profile.js +332 -0
  122. package/dist/src/walletClient/Utils.js +281 -0
  123. package/dist/src/walletClient/index.js +2109 -0
  124. package/package.json +1 -1
  125. package/src/AuthorizationClient.js +24 -16
  126. package/src/ElvClient.js +19 -0
  127. package/src/client/ContentAccess.js +20 -2
  128. package/src/client/LiveConf.js +10 -8
  129. package/src/client/LiveStream.js +6 -4
@@ -0,0 +1,1556 @@
1
+ var _regeneratorRuntime = require("@babel/runtime/regenerator");
2
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
3
+ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4
+ var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
5
+ var _createClass = require("@babel/runtime/helpers/createClass");
6
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
7
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
8
+ var UrlJoin = require("url-join");
9
+ var _require = require("./Validation"),
10
+ ValidatePresence = _require.ValidatePresence,
11
+ ValidatePermission = _require.ValidatePermission;
12
+ var PermissionsClient = /*#__PURE__*/function () {
13
+ "use strict";
14
+
15
+ /**
16
+ * The PermissionsClient is intended to make it easy to setup and maintain permission policies in the fabric.
17
+ *
18
+ * <br/><b>Item Policies</b>:
19
+ * - An item policy is the full specification of the policy for an object. It consists of a set of available profiles and a list of permissions.
20
+ * - The item policy must be initialized using `CreateItemPolicy` before the other modification methods in this client can be used.
21
+ * - The item policy can be retrieved using the `ItemPolicy` method to check if the policy for a particular item has been initialized.
22
+ *
23
+ *
24
+ * <br/><b>Dates</b>:
25
+ *
26
+ * - `start` and `end` can be specified in several places in the policy. These can be provided in any format supported by JavaScript's `new Date(date)` constructor, such as Unix epoch timestamps or ISO timestamps.
27
+ *
28
+ * - Permissions, profiles and custom profile permissions may have start and end times. The effective allowed access is the *most restrictive* combination of applicable start and end times.
29
+ *
30
+ *
31
+ * <br/><b>Subjects</b>:
32
+ *
33
+ * - A subject is a recipient of a permission - namely Fabric and oauth users and groups.
34
+ *
35
+ * - When specifying a subject, both the name and ID must be provided. For Fabric users, the ID is either the user or group address, or the igrp/iusr hash format of the address.
36
+ *
37
+ *
38
+ * <br/><b>Items</b>:
39
+ *
40
+ * - An 'item' in this API is a content object to which permissions are granted. All profiles and permissions are on a per-item basis.
41
+ *
42
+ *
43
+ * <br/><b>Profiles</b>:
44
+ *
45
+ * - Profiles represent a set of permissions that can be applied to a subject (via a 'permission', see below)
46
+ *
47
+ * - A profile may have `start` and `end` times
48
+ *
49
+ * - A profile includes permission specifications for both the assets and the offerings of an item. Both must be specified when creating or modifying a profile.
50
+ *
51
+ * - For both assets and offerings, there is a `default_permission` entry, which can be either `full-access` or `no-access`. This represents the access allowed to the assets and offerings when a permission for the profile is granted, excepting any custom permissions that override it.
52
+ *
53
+ * - For both assets and offerings, a profile may have a `custom_permissions` section, which specifies permissions for specific assets or offerings. These permissions must have a `permission` entry which is either `full-access` or `no-access`, and may have `start` and `end` times.
54
+ *
55
+ *
56
+ * Example Profile Specification:
57
+ "pre-release": {
58
+ "start": "2020-12-10T08:00:00.000Z",
59
+ "end": "2020-12-31T08:00:00.000Z",
60
+ "assets": {
61
+ "custom_permissions": {
62
+ "2wLgQXV5VYvRPZlOEPN0.tif": {
63
+ "start": "2020-09-10T07:00:00.000Z",
64
+ "end": "2020-12-31T08:00:00.000Z",
65
+ "permission": "full-access"
66
+ },
67
+ "781rsItfv8UxrkYgSNhb.tif": {
68
+ "start": "2020-09-10T07:00:00.000Z",
69
+ "end": "2020-12-31T08:00:00.000Z",
70
+ "permission": "full-access"
71
+ },
72
+ "QCVtsOAcUKbA8svZeFRI.tif": {
73
+ "permission": "full-access"
74
+ },
75
+ "QXWQVA7FfUwLlEPlBI1G.tif": {
76
+ "permission": "full-access",
77
+ "start": "2020-09-30T07:00:00.000Z"
78
+ }
79
+ },
80
+ "default_permission": "no-access"
81
+ },
82
+ "offerings": {
83
+ "default_permission": "no-access"
84
+ }
85
+ }
86
+ *
87
+ *
88
+ * <br/><b>Permissions</b>:
89
+ *
90
+ * - A permission represents a grant of an item profile's permissions to a subject.
91
+ *
92
+ * - A permission must have a profile that is present in the item's policy
93
+ *
94
+ * - A permission may have `start` and `end` times. As mentioned above, the effective start and end times of a permission are the *most restrictive* of all applicable start and end times.
95
+ *
96
+ * - A permission must have a subject, which can be either a user or group, either from the Fabric or from an OAuth provider, or an NTP instance or an NTP Subject
97
+ *
98
+ * - A subject must have an ID and a name. In the case of certain OAuth providers, the name may be used as an ID in most cases, but the immutable ID for that subject must be used as the ID. For example, in Okta, a group may be specified by its name "Content Admins", but have the Okta ID "00g102tklfAorixGi4x7". The former should be used as the subjectName, and the latter as the subjectId
99
+ *
100
+ *
101
+ * Example Permission:
102
+ {
103
+ "start": "2021-01-01T08:00:00.000Z",
104
+ "end": "2021-03-31T07:00:00.000Z",
105
+ "profileName": "servicing",
106
+ "subjectSource": "oauth",
107
+ "subjectType": "group",
108
+ "subjectName": "Partner1",
109
+ "subjectId: "00g102uednmwrTihN4x7"
110
+ }
111
+ *
112
+ * @param client - An instance of ElvClient
113
+ * @param {object=} options={offline: false} - Options for the PermissionsClient
114
+ * - offline - If specified, metadata reads and updates will be done with a local copy.
115
+ * Use OpenOfflineDraft and CloseOfflineDraft
116
+ */
117
+ function PermissionsClient(client) {
118
+ var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {
119
+ offline: false
120
+ };
121
+ _classCallCheck(this, PermissionsClient);
122
+ this.client = client;
123
+ this.subjectNames = {};
124
+ this.drafts = {};
125
+ this.offline = options.offline;
126
+ }
127
+ return _createClass(PermissionsClient, [{
128
+ key: "FormatDate",
129
+ value: function FormatDate(date) {
130
+ if (!date) {
131
+ return;
132
+ }
133
+ if (isNaN(new Date(date))) {
134
+ throw Error("Invalid start time: ".concat(date));
135
+ }
136
+ return new Date(date).toISOString();
137
+ }
138
+ }, {
139
+ key: "FormatProfile",
140
+ value: function FormatProfile(profile) {
141
+ var _this = this;
142
+ ValidatePermission(profile.default_permission);
143
+ var profileSpec = {};
144
+ if (profile.start) {
145
+ profileSpec.start = this.FormatDate(profile.start);
146
+ }
147
+ if (profile.end) {
148
+ profileSpec.end = this.FormatDate(profile.end);
149
+ }
150
+ ["assets", "offerings"].forEach(function (type) {
151
+ var typeInfo = profile[type] || {};
152
+ profileSpec[type] = {
153
+ default_permission: typeInfo.default_permission || typeInfo.default_permissions || "no-access"
154
+ };
155
+ if (typeInfo.custom_permissions) {
156
+ profileSpec[type].custom_permissions = {};
157
+ Object.keys(typeInfo.custom_permissions).forEach(function (id) {
158
+ var permission = typeInfo.custom_permissions[id];
159
+ var spec = {
160
+ permission: ValidatePermission(permission.permission)
161
+ };
162
+ if (permission.start) {
163
+ spec.start = _this.FormatDate(permission.start);
164
+ }
165
+ if (permission.end) {
166
+ spec.end = _this.FormatDate(permission.end);
167
+ }
168
+ profileSpec[type].custom_permissions[id] = _objectSpread(_objectSpread({}, permission), spec);
169
+ });
170
+ }
171
+ });
172
+ return profileSpec;
173
+ }
174
+
175
+ // Convert from fabric metadata spec to client spec
176
+ }, {
177
+ key: "FormatPermission",
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 _callee$(_context) {
182
+ while (1) switch (_context.prev = _context.next) {
183
+ case 0:
184
+ policyId = _ref.policyId, policyWriteToken = _ref.policyWriteToken, permission = _ref.permission;
185
+ subjectSource = permission.subject.type.startsWith("oauth") ? "oauth" : "fabric";
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
+ break;
189
+ case 5:
190
+ subjectType = "ntp";
191
+ subjectId = permission.subject.id;
192
+ return _context.abrupt("break", 20);
193
+ case 8:
194
+ subjectType = "ntp_subject";
195
+ subjectId = permission.subject.id;
196
+ subjectName = subjectId;
197
+ subjectNTPId = permission.subject.otp_id;
198
+ return _context.abrupt("break", 20);
199
+ case 13:
200
+ subjectType = "group";
201
+ subjectId = subjectSource === "oauth" ? permission.subject.oauth_id : this.client.utils.HashToAddress(permission.subject.id);
202
+ return _context.abrupt("break", 20);
203
+ case 16:
204
+ subjectType = "user";
205
+ subjectId = subjectSource === "oauth" ? permission.subject.oauth_id : this.client.utils.HashToAddress(permission.subject.id);
206
+ return _context.abrupt("break", 20);
207
+ case 19:
208
+ throw Error("Unknown subject type: " + permission.subject.type);
209
+ case 20:
210
+ id = permission.subject.oauth_id || permission.subject.id;
211
+ cachedName = this.subjectNames[id];
212
+ subjectName = subjectName || cachedName || permission.subject.id;
213
+ if (!(!cachedName && subjectSource === "fabric")) {
214
+ _context.next = 74;
215
+ break;
216
+ }
217
+ if (!(subjectType === "group")) {
218
+ _context.next = 36;
219
+ break;
220
+ }
221
+ _context.next = 27;
222
+ return this.client.ContentSpaceId();
223
+ case 27:
224
+ contentSpaceLibraryId = _context.sent.replace("ispc", "ilib");
225
+ _context.next = 30;
226
+ return this.client.ContentObjectMetadata({
227
+ libraryId: contentSpaceLibraryId,
228
+ objectId: this.client.utils.AddressToObjectId(subjectId),
229
+ metadataSubtree: UrlJoin("public", "name")
230
+ });
231
+ case 30:
232
+ _context.t1 = _context.sent;
233
+ if (_context.t1) {
234
+ _context.next = 33;
235
+ break;
236
+ }
237
+ _context.t1 = subjectId;
238
+ case 33:
239
+ subjectName = _context.t1;
240
+ _context.next = 74;
241
+ break;
242
+ case 36:
243
+ if (!(subjectType === "user")) {
244
+ _context.next = 56;
245
+ break;
246
+ }
247
+ _context.t4 = this.client;
248
+ _context.next = 40;
249
+ return this.client.ContentObjectLibraryId({
250
+ objectId: policyId
251
+ });
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
+ };
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
+ break;
270
+ }
271
+ _context.t3 = {};
272
+ case 50:
273
+ _context.t2 = _context.t3.name;
274
+ if (_context.t2) {
275
+ _context.next = 53;
276
+ break;
277
+ }
278
+ _context.t2 = subjectId;
279
+ case 53:
280
+ subjectName = _context.t2;
281
+ _context.next = 74;
282
+ break;
283
+ case 56:
284
+ if (!(subjectType === "ntp")) {
285
+ _context.next = 74;
286
+ break;
287
+ }
288
+ _context.t12 = this.client;
289
+ _context.next = 60;
290
+ return this.client.ContentObjectLibraryId({
291
+ objectId: policyId
292
+ });
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
+ };
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
+ break;
311
+ }
312
+ _context.t11 = {};
313
+ case 70:
314
+ _context.t10 = _context.t11.name;
315
+ if (_context.t10) {
316
+ _context.next = 73;
317
+ break;
318
+ }
319
+ _context.t10 = subjectId;
320
+ case 73:
321
+ subjectName = _context.t10;
322
+ case 74:
323
+ this.subjectNames[id] = subjectName;
324
+ permissionSpec = {
325
+ profileName: permission.profile,
326
+ subjectSource: subjectSource,
327
+ subjectType: subjectType,
328
+ subjectId: subjectId,
329
+ subjectName: subjectName
330
+ };
331
+ if (subjectNTPId) {
332
+ permissionSpec.subjectNTPId = subjectNTPId;
333
+ }
334
+ if (permission.start) {
335
+ permissionSpec.start = permission.start;
336
+ }
337
+ if (permission.end) {
338
+ permissionSpec.end = permission.end;
339
+ }
340
+ return _context.abrupt("return", permissionSpec);
341
+ case 80:
342
+ case "end":
343
+ return _context.stop();
344
+ }
345
+ }, _callee, this);
346
+ }));
347
+ function FormatPermission(_x) {
348
+ return _FormatPermission.apply(this, arguments);
349
+ }
350
+ return FormatPermission;
351
+ }()
352
+ /* Offline draft */
353
+ /**
354
+ * Open an offline draft - copies object data locally and allows the functions processing this data to operate
355
+ * on the local copy, much faster. Closing the draft will copy the data back to the object's write token.
356
+ *
357
+ * @methodGroup OfflineDraft
358
+ * @namedParams
359
+ * @param {string} policyId - Object ID of the policy
360
+ * @param {string} policyLibraryId - Policy object library ID (optional)
361
+ * @param {string=} policyWriteToken - Write token for the policy object
362
+ */
363
+ }, {
364
+ key: "OpenOfflineDraft",
365
+ value: (function () {
366
+ var _OpenOfflineDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref2) {
367
+ var policyId, policyLibraryId, policyWriteToken, meta;
368
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
369
+ while (1) switch (_context2.prev = _context2.next) {
370
+ case 0:
371
+ policyId = _ref2.policyId, policyLibraryId = _ref2.policyLibraryId, policyWriteToken = _ref2.policyWriteToken;
372
+ if (!(policyLibraryId == null)) {
373
+ _context2.next = 5;
374
+ break;
375
+ }
376
+ _context2.next = 4;
377
+ return this.client.ContentObjectLibraryId({
378
+ objectId: policyId
379
+ });
380
+ case 4:
381
+ policyLibraryId = _context2.sent;
382
+ case 5:
383
+ _context2.next = 7;
384
+ return this.client.ContentObjectMetadata({
385
+ libraryId: policyLibraryId,
386
+ objectId: policyId,
387
+ writeToken: policyWriteToken
388
+ });
389
+ case 7:
390
+ meta = _context2.sent;
391
+ this.drafts[policyId] = {
392
+ meta: meta,
393
+ policyLibraryId: policyLibraryId,
394
+ policyWriteToken: policyWriteToken
395
+ };
396
+ case 9:
397
+ case "end":
398
+ return _context2.stop();
399
+ }
400
+ }, _callee2, this);
401
+ }));
402
+ function OpenOfflineDraft(_x2) {
403
+ return _OpenOfflineDraft.apply(this, arguments);
404
+ }
405
+ return OpenOfflineDraft;
406
+ }()
407
+ /**
408
+ * Close an offline draft - copies the metadata stored locally back to the write token's metadata.
409
+ * Does not finalize the write token.
410
+ *
411
+ * @methodGroup OfflineDraft
412
+ * @namedParams
413
+ * @param {string} policyId - Object ID of the policy
414
+ */
415
+ )
416
+ }, {
417
+ key: "CloseOfflineDraft",
418
+ value: (function () {
419
+ var _CloseOfflineDraft = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
420
+ var policyId;
421
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
422
+ while (1) switch (_context3.prev = _context3.next) {
423
+ case 0:
424
+ policyId = _ref3.policyId;
425
+ if (!(this.drafts[policyId] == null)) {
426
+ _context3.next = 3;
427
+ break;
428
+ }
429
+ throw Error("No draft open for policyId: " + policyId);
430
+ case 3:
431
+ _context3.next = 5;
432
+ return this.client.ReplaceMetadata({
433
+ libraryId: this.drafts[policyId].policyLibraryId,
434
+ objectId: policyId,
435
+ writeToken: this.drafts[policyId].policyWriteToken,
436
+ metadata: this.drafts[policyId].meta
437
+ });
438
+ case 5:
439
+ this.drafts[policyId] = null;
440
+ case 6:
441
+ case "end":
442
+ return _context3.stop();
443
+ }
444
+ }, _callee3, this);
445
+ }));
446
+ function CloseOfflineDraft(_x3) {
447
+ return _CloseOfflineDraft.apply(this, arguments);
448
+ }
449
+ return CloseOfflineDraft;
450
+ }()
451
+ /* Add / remove overall item permission */
452
+ /**
453
+ * Retrieve a list of all items in the specified policy
454
+ *
455
+ * @methodGroup Policies
456
+ * @namedParams
457
+ * @param {string} policyId - Object ID of the policy
458
+ * @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
+ * @return {Promise<Object>} - A mapping of item objectId to the display name of the item
460
+ */
461
+ )
462
+ }, {
463
+ key: "PolicyItems",
464
+ value: (function () {
465
+ var _PolicyItems = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref4) {
466
+ var policyId, policyWriteToken;
467
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
468
+ while (1) switch (_context4.prev = _context4.next) {
469
+ case 0:
470
+ policyId = _ref4.policyId, policyWriteToken = _ref4.policyWriteToken;
471
+ _context4.t1 = this.client;
472
+ _context4.next = 4;
473
+ return this.client.ContentObjectLibraryId({
474
+ objectId: policyId
475
+ });
476
+ case 4:
477
+ _context4.t2 = _context4.sent;
478
+ _context4.t3 = policyId;
479
+ _context4.t4 = policyWriteToken;
480
+ _context4.t5 = ["*/display_title"];
481
+ _context4.t6 = {
482
+ libraryId: _context4.t2,
483
+ objectId: _context4.t3,
484
+ writeToken: _context4.t4,
485
+ metadataSubtree: "auth_policy_spec",
486
+ select: _context4.t5
487
+ };
488
+ _context4.next = 11;
489
+ return _context4.t1.ContentObjectMetadata.call(_context4.t1, _context4.t6);
490
+ case 11:
491
+ _context4.t0 = _context4.sent;
492
+ if (_context4.t0) {
493
+ _context4.next = 14;
494
+ break;
495
+ }
496
+ _context4.t0 = {};
497
+ case 14:
498
+ return _context4.abrupt("return", _context4.t0);
499
+ case 15:
500
+ case "end":
501
+ return _context4.stop();
502
+ }
503
+ }, _callee4, this);
504
+ }));
505
+ function PolicyItems(_x4) {
506
+ return _PolicyItems.apply(this, arguments);
507
+ }
508
+ return PolicyItems;
509
+ }()
510
+ /**
511
+ * Retrieve the full item policy for the given item.
512
+ *
513
+ * @methodGroup Policies
514
+ * @namedParams
515
+ * @param {string} policyId - Object ID of the policy
516
+ * @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
517
+ * @param {string} itemId - Object ID of the item
518
+ * @return {Promise<Object | undefined>} - The policy for the specified item. If none exists, returns undefined
519
+ */
520
+ )
521
+ }, {
522
+ key: "ItemPolicy",
523
+ value: (function () {
524
+ var _ItemPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref5) {
525
+ var policyId, policyWriteToken, itemId, profiles, permissions;
526
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
527
+ while (1) switch (_context5.prev = _context5.next) {
528
+ case 0:
529
+ policyId = _ref5.policyId, policyWriteToken = _ref5.policyWriteToken, itemId = _ref5.itemId;
530
+ _context5.next = 3;
531
+ return this.ItemProfiles({
532
+ policyId: policyId,
533
+ policyWriteToken: policyWriteToken,
534
+ itemId: itemId
535
+ });
536
+ case 3:
537
+ profiles = _context5.sent;
538
+ _context5.next = 6;
539
+ return this.ItemPermissions({
540
+ policyId: policyId,
541
+ policyWriteToken: policyWriteToken,
542
+ itemId: itemId
543
+ });
544
+ case 6:
545
+ permissions = _context5.sent;
546
+ if (!(!profiles || !permissions)) {
547
+ _context5.next = 9;
548
+ break;
549
+ }
550
+ return _context5.abrupt("return");
551
+ case 9:
552
+ return _context5.abrupt("return", {
553
+ profiles: profiles,
554
+ permissions: permissions
555
+ });
556
+ case 10:
557
+ case "end":
558
+ return _context5.stop();
559
+ }
560
+ }, _callee5, this);
561
+ }));
562
+ function ItemPolicy(_x5) {
563
+ return _ItemPolicy.apply(this, arguments);
564
+ }
565
+ return ItemPolicy;
566
+ }()
567
+ /**
568
+ * Initialize policy for the specified item
569
+ *
570
+ * @methodGroup Policies
571
+ * @namedParams
572
+ * @param {string} policyId - Object ID of the policy
573
+ * @param {string} policyWriteToken - Write token for the policy
574
+ * @param {string} itemId - Object ID of the item
575
+ * @param {object=} profiles={} - Profiles to create
576
+ */
577
+ )
578
+ }, {
579
+ key: "CreateItemPolicy",
580
+ value: (function () {
581
+ var _CreateItemPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref6) {
582
+ var _this2 = this;
583
+ var policyId, policyWriteToken, itemId, _ref6$profiles, profiles, metadata, assetMetadata, displayTitle, itemSpec;
584
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
585
+ while (1) switch (_context6.prev = _context6.next) {
586
+ case 0:
587
+ policyId = _ref6.policyId, policyWriteToken = _ref6.policyWriteToken, itemId = _ref6.itemId, _ref6$profiles = _ref6.profiles, profiles = _ref6$profiles === void 0 ? {} : _ref6$profiles;
588
+ ValidatePresence("policyId", policyId);
589
+ ValidatePresence("policyWriteToken", policyWriteToken);
590
+ ValidatePresence("itemId", itemId);
591
+ ValidatePresence("profiles", profiles);
592
+ _context6.t1 = this.client;
593
+ _context6.next = 8;
594
+ return this.client.ContentObjectLibraryId({
595
+ objectId: itemId
596
+ });
597
+ case 8:
598
+ _context6.t2 = _context6.sent;
599
+ _context6.t3 = itemId;
600
+ _context6.t4 = ["public/name", "public/asset_metadata/title", "public/asset_metadata/display_title"];
601
+ _context6.t5 = {
602
+ libraryId: _context6.t2,
603
+ objectId: _context6.t3,
604
+ select: _context6.t4
605
+ };
606
+ _context6.next = 14;
607
+ return _context6.t1.ContentObjectMetadata.call(_context6.t1, _context6.t5);
608
+ case 14:
609
+ _context6.t0 = _context6.sent;
610
+ if (_context6.t0) {
611
+ _context6.next = 17;
612
+ break;
613
+ }
614
+ _context6.t0 = {};
615
+ case 17:
616
+ metadata = _context6.t0;
617
+ assetMetadata = (metadata["public"] || {}).asset_metadata || {};
618
+ displayTitle = assetMetadata.display_title || assetMetadata.title || (metadata["public"] || {}).name;
619
+ itemSpec = {
620
+ display_title: displayTitle,
621
+ permissions: [],
622
+ profiles: {}
623
+ };
624
+ Object.keys(profiles).forEach(function (profileName) {
625
+ itemSpec.profiles[profileName] = _this2.FormatProfile(profiles[profileName]);
626
+ });
627
+ _context6.t6 = this.client;
628
+ _context6.next = 25;
629
+ return this.client.ContentObjectLibraryId({
630
+ objectId: policyId
631
+ });
632
+ case 25:
633
+ _context6.t7 = _context6.sent;
634
+ _context6.t8 = policyId;
635
+ _context6.t9 = policyWriteToken;
636
+ _context6.t10 = UrlJoin("auth_policy_spec", itemId);
637
+ _context6.t11 = itemSpec;
638
+ _context6.t12 = {
639
+ libraryId: _context6.t7,
640
+ objectId: _context6.t8,
641
+ writeToken: _context6.t9,
642
+ metadataSubtree: _context6.t10,
643
+ metadata: _context6.t11
644
+ };
645
+ _context6.next = 33;
646
+ return _context6.t6.ReplaceMetadata.call(_context6.t6, _context6.t12);
647
+ case 33:
648
+ case "end":
649
+ return _context6.stop();
650
+ }
651
+ }, _callee6, this);
652
+ }));
653
+ function CreateItemPolicy(_x6) {
654
+ return _CreateItemPolicy.apply(this, arguments);
655
+ }
656
+ return CreateItemPolicy;
657
+ }()
658
+ /**
659
+ * Remove the specified item policy
660
+ *
661
+ * @methodGroup Policies
662
+ * @namedParams
663
+ * @param {string} policyId - Object ID of the policy
664
+ * @param {string} policyWriteToken - Write token for the policy
665
+ * @param {string} itemId - Object ID of the item
666
+ */
667
+ )
668
+ }, {
669
+ key: "RemoveItemPolicy",
670
+ value: (function () {
671
+ var _RemoveItemPolicy = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref7) {
672
+ var policyId, policyWriteToken, itemId;
673
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
674
+ while (1) switch (_context7.prev = _context7.next) {
675
+ case 0:
676
+ policyId = _ref7.policyId, policyWriteToken = _ref7.policyWriteToken, itemId = _ref7.itemId;
677
+ ValidatePresence("policyId", policyId);
678
+ ValidatePresence("policyWriteToken", policyWriteToken);
679
+ ValidatePresence("itemId", itemId);
680
+ _context7.t0 = this.client;
681
+ _context7.next = 7;
682
+ return this.client.ContentObjectLibraryId({
683
+ objectId: policyId
684
+ });
685
+ case 7:
686
+ _context7.t1 = _context7.sent;
687
+ _context7.t2 = policyId;
688
+ _context7.t3 = policyWriteToken;
689
+ _context7.t4 = UrlJoin("auth_policy_spec", itemId);
690
+ _context7.t5 = {
691
+ libraryId: _context7.t1,
692
+ objectId: _context7.t2,
693
+ writeToken: _context7.t3,
694
+ metadataSubtree: _context7.t4
695
+ };
696
+ _context7.next = 14;
697
+ return _context7.t0.DeleteMetadata.call(_context7.t0, _context7.t5);
698
+ case 14:
699
+ case "end":
700
+ return _context7.stop();
701
+ }
702
+ }, _callee7, this);
703
+ }));
704
+ function RemoveItemPolicy(_x7) {
705
+ return _RemoveItemPolicy.apply(this, arguments);
706
+ }
707
+ return RemoveItemPolicy;
708
+ }()
709
+ /* Get / set / remove profile permissions */
710
+ /**
711
+ * Retrieve profile information on the specified item policy
712
+ *
713
+ * @methodGroup Profiles
714
+ * @namedParams
715
+ * @param {string} policyId - Object ID of the policy
716
+ * @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
717
+ * @param {string} itemId - Object ID of the item
718
+ * @param {string=} profileName - The name of the profile. If not specified, all profiles will be returned
719
+ */
720
+ )
721
+ }, {
722
+ key: "ItemProfiles",
723
+ value: (function () {
724
+ var _ItemProfiles = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref8) {
725
+ var policyId, policyWriteToken, itemId, profileName;
726
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
727
+ while (1) switch (_context8.prev = _context8.next) {
728
+ case 0:
729
+ policyId = _ref8.policyId, policyWriteToken = _ref8.policyWriteToken, itemId = _ref8.itemId, profileName = _ref8.profileName;
730
+ _context8.t0 = this.client;
731
+ _context8.next = 4;
732
+ return this.client.ContentObjectLibraryId({
733
+ objectId: policyId
734
+ });
735
+ case 4:
736
+ _context8.t1 = _context8.sent;
737
+ _context8.t2 = policyId;
738
+ _context8.t3 = policyWriteToken;
739
+ _context8.t4 = UrlJoin("auth_policy_spec", itemId, "profiles", profileName || "");
740
+ _context8.t5 = {
741
+ libraryId: _context8.t1,
742
+ objectId: _context8.t2,
743
+ writeToken: _context8.t3,
744
+ metadataSubtree: _context8.t4
745
+ };
746
+ _context8.next = 11;
747
+ return _context8.t0.ContentObjectMetadata.call(_context8.t0, _context8.t5);
748
+ case 11:
749
+ return _context8.abrupt("return", _context8.sent);
750
+ case 12:
751
+ case "end":
752
+ return _context8.stop();
753
+ }
754
+ }, _callee8, this);
755
+ }));
756
+ function ItemProfiles(_x8) {
757
+ return _ItemProfiles.apply(this, arguments);
758
+ }
759
+ return ItemProfiles;
760
+ }()
761
+ /**
762
+ * Create or modify a profile for the specified item policy
763
+ *
764
+ * @methodGroup Profiles
765
+ * @namedParams
766
+ * @param {string} policyId - Object ID of the policy
767
+ * @param {string} policyWriteToken - Write token for the policy
768
+ * @param {string} itemId - Object ID of the item
769
+ * @param {string} profileName - The name of the profile
770
+ * @param {object} profileSpec - Specification for the profile. If not provided, profile
771
+ * will default to no access for both assets and offerings
772
+ */
773
+ )
774
+ }, {
775
+ key: "SetProfile",
776
+ value: (function () {
777
+ var _SetProfile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref9) {
778
+ var policyId, policyWriteToken, itemId, profileName, profileSpec;
779
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
780
+ while (1) switch (_context9.prev = _context9.next) {
781
+ case 0:
782
+ policyId = _ref9.policyId, policyWriteToken = _ref9.policyWriteToken, itemId = _ref9.itemId, profileName = _ref9.profileName, profileSpec = _ref9.profileSpec;
783
+ ValidatePresence("policyId", policyId);
784
+ ValidatePresence("policyWriteToken", policyWriteToken);
785
+ ValidatePresence("itemId", itemId);
786
+ ValidatePresence("profileName", profileName);
787
+ ValidatePresence("profileSpec", profileSpec);
788
+ _context9.t0 = this.client;
789
+ _context9.next = 9;
790
+ return this.client.ContentObjectLibraryId({
791
+ objectId: policyId
792
+ });
793
+ case 9:
794
+ _context9.t1 = _context9.sent;
795
+ _context9.t2 = policyId;
796
+ _context9.t3 = policyWriteToken;
797
+ _context9.t4 = UrlJoin("auth_policy_spec", itemId, "profiles", profileName);
798
+ _context9.t5 = this.FormatProfile(profileSpec);
799
+ _context9.t6 = {
800
+ libraryId: _context9.t1,
801
+ objectId: _context9.t2,
802
+ writeToken: _context9.t3,
803
+ metadataSubtree: _context9.t4,
804
+ metadata: _context9.t5
805
+ };
806
+ _context9.next = 17;
807
+ return _context9.t0.ReplaceMetadata.call(_context9.t0, _context9.t6);
808
+ case 17:
809
+ case "end":
810
+ return _context9.stop();
811
+ }
812
+ }, _callee9, this);
813
+ }));
814
+ function SetProfile(_x9) {
815
+ return _SetProfile.apply(this, arguments);
816
+ }
817
+ return SetProfile;
818
+ }()
819
+ /**
820
+ * Remove a profile from the specified item policy
821
+ *
822
+ * @methodGroup Profiles
823
+ * @namedParams
824
+ * @param {string} policyId - Object ID of the policy
825
+ * @param {string} policyWriteToken - Write token for the policy
826
+ * @param {string} itemId - Object ID of the item
827
+ * @param {string} profileName - The name of the profile
828
+ * @param {object} profileSpec - Specification for the profile. If not provided, profile
829
+ * will default to no access for both assets and offerings
830
+ */
831
+ )
832
+ }, {
833
+ key: "RemoveProfile",
834
+ value: (function () {
835
+ var _RemoveProfile = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref10) {
836
+ var policyId, policyWriteToken, itemId, profileName;
837
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
838
+ while (1) switch (_context10.prev = _context10.next) {
839
+ case 0:
840
+ policyId = _ref10.policyId, policyWriteToken = _ref10.policyWriteToken, itemId = _ref10.itemId, profileName = _ref10.profileName;
841
+ ValidatePresence("policyId", policyId);
842
+ ValidatePresence("policyWriteToken", policyWriteToken);
843
+ ValidatePresence("itemId", itemId);
844
+ ValidatePresence("profileName", profileName);
845
+ _context10.t0 = this.client;
846
+ _context10.next = 8;
847
+ return this.client.ContentObjectLibraryId({
848
+ objectId: policyId
849
+ });
850
+ case 8:
851
+ _context10.t1 = _context10.sent;
852
+ _context10.t2 = policyId;
853
+ _context10.t3 = policyWriteToken;
854
+ _context10.t4 = UrlJoin("auth_policy_spec", itemId, "profiles", profileName);
855
+ _context10.t5 = {
856
+ libraryId: _context10.t1,
857
+ objectId: _context10.t2,
858
+ writeToken: _context10.t3,
859
+ metadataSubtree: _context10.t4
860
+ };
861
+ _context10.next = 15;
862
+ return _context10.t0.DeleteMetadata.call(_context10.t0, _context10.t5);
863
+ case 15:
864
+ case "end":
865
+ return _context10.stop();
866
+ }
867
+ }, _callee10, this);
868
+ }));
869
+ function RemoveProfile(_x10) {
870
+ return _RemoveProfile.apply(this, arguments);
871
+ }
872
+ return RemoveProfile;
873
+ }()
874
+ /* Get / set / remove subject permissions */
875
+ /**
876
+ * Retrieve the permissions for the specified item policy
877
+ *
878
+ * @methodGroup Permissions
879
+ * @namedParams
880
+ * @param {string} policyId - Object ID of the policy
881
+ * @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
882
+ * @param {string} itemId - Object ID of the item
883
+ *
884
+ * @return {Promise<Array>} - The list of permissions for the specified item
885
+ */
886
+ )
887
+ }, {
888
+ key: "ItemPermissions",
889
+ value: (function () {
890
+ var _ItemPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(_ref11) {
891
+ var _this3 = this;
892
+ var policyId, policyWriteToken, itemId, libraryId, permissions;
893
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
894
+ while (1) switch (_context12.prev = _context12.next) {
895
+ case 0:
896
+ policyId = _ref11.policyId, policyWriteToken = _ref11.policyWriteToken, itemId = _ref11.itemId;
897
+ _context12.next = 3;
898
+ return this.client.ContentObjectLibraryId({
899
+ objectId: policyId
900
+ });
901
+ case 3:
902
+ libraryId = _context12.sent;
903
+ _context12.next = 6;
904
+ return this.client.ContentObjectMetadata({
905
+ libraryId: libraryId,
906
+ objectId: policyId,
907
+ writeToken: policyWriteToken,
908
+ metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions")
909
+ });
910
+ case 6:
911
+ _context12.t0 = _context12.sent;
912
+ if (_context12.t0) {
913
+ _context12.next = 9;
914
+ break;
915
+ }
916
+ _context12.t0 = [];
917
+ case 9:
918
+ permissions = _context12.t0;
919
+ _context12.next = 12;
920
+ return Promise.all(permissions.map( /*#__PURE__*/function () {
921
+ var _ref12 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(permission) {
922
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
923
+ while (1) switch (_context11.prev = _context11.next) {
924
+ case 0:
925
+ _context11.next = 2;
926
+ return _this3.FormatPermission({
927
+ policyId: policyId,
928
+ policyWriteToken: policyWriteToken,
929
+ permission: permission
930
+ });
931
+ case 2:
932
+ return _context11.abrupt("return", _context11.sent);
933
+ case 3:
934
+ case "end":
935
+ return _context11.stop();
936
+ }
937
+ }, _callee11);
938
+ }));
939
+ return function (_x12) {
940
+ return _ref12.apply(this, arguments);
941
+ };
942
+ }()));
943
+ case 12:
944
+ return _context12.abrupt("return", _context12.sent);
945
+ case 13:
946
+ case "end":
947
+ return _context12.stop();
948
+ }
949
+ }, _callee12, this);
950
+ }));
951
+ function ItemPermissions(_x11) {
952
+ return _ItemPermissions.apply(this, arguments);
953
+ }
954
+ return ItemPermissions;
955
+ }()
956
+ /**
957
+ * Add or modify permission for the specified subject to the specified item policy
958
+ *
959
+ * @methodGroup Permissions
960
+ * @namedParams
961
+ * @param {string} policyId - Object ID of the policy
962
+ * @param {string} policyWriteToken - Write token for the policy
963
+ * @param {string} itemId - Object ID of the item
964
+ * @param {string} subjectSource="fabric" - ("fabric" | "oauth") - The source of the subject
965
+ * @param {string} subjectType="group - ("user" | "group" | "ntp" | "ntp_subject") - The type of the subject
966
+ * @param {string=} subjectName - The name of the subject
967
+ * @param {string} subjectId - The ID of the subject
968
+ * @param {string=} subjectNTPId - (For subjectType "ntp_subject") The NTP ID associated with the subject
969
+ * @param {string} profileName - The profile to apply for the permission
970
+ * @param {string | number} start - The start time for the permission
971
+ * @param {string | number} end - The end time for the permission
972
+ */
973
+ )
974
+ }, {
975
+ key: "SetPermission",
976
+ value: (function () {
977
+ var _SetPermission = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref13) {
978
+ 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;
979
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
980
+ while (1) switch (_context13.prev = _context13.next) {
981
+ case 0:
982
+ 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
+ ValidatePresence("policyId", policyId);
984
+ ValidatePresence("policyWriteToken", policyWriteToken);
985
+ ValidatePresence("itemId", itemId);
986
+ ValidatePresence("subjectType", subjectType);
987
+ ValidatePresence("subjectSource", subjectSource);
988
+ ValidatePresence("subjectId", subjectId);
989
+ ValidatePresence("profileName", profileName);
990
+ start = this.FormatDate(start);
991
+ end = this.FormatDate(end);
992
+
993
+ // Check if we have an open offline draft for this policy
994
+ offlineDraft = this.offline && this.drafts[policyId] != null;
995
+ policyLibraryId = null;
996
+ if (offlineDraft) {
997
+ _context13.next = 16;
998
+ break;
999
+ }
1000
+ _context13.next = 15;
1001
+ return this.client.ContentObjectLibraryId({
1002
+ objectId: policyId
1003
+ });
1004
+ case 15:
1005
+ policyLibraryId = _context13.sent;
1006
+ case 16:
1007
+ // Allow address to be passed in for fabric subjects, though spec requires iusr/igrp hash
1008
+ if (subjectSource === "fabric") {
1009
+ if (subjectType === "group") {
1010
+ if (!subjectId.startsWith("igrp")) {
1011
+ subjectId = "igrp".concat(this.client.utils.AddressToHash(subjectId));
1012
+ }
1013
+ } else if (subjectType === "user") {
1014
+ if (!subjectId.startsWith("iusr")) {
1015
+ subjectId = "iusr".concat(this.client.utils.AddressToHash(subjectId));
1016
+ }
1017
+ }
1018
+ }
1019
+ if (!offlineDraft) {
1020
+ _context13.next = 21;
1021
+ break;
1022
+ }
1023
+ existingPermissions = this.drafts[policyId].meta["auth_policy_spec"][itemId];
1024
+ _context13.next = 24;
1025
+ break;
1026
+ case 21:
1027
+ _context13.next = 23;
1028
+ return this.client.ContentObjectMetadata({
1029
+ libraryId: policyLibraryId,
1030
+ objectId: policyId,
1031
+ writeToken: policyWriteToken,
1032
+ metadataSubtree: UrlJoin("auth_policy_spec", itemId)
1033
+ });
1034
+ case 23:
1035
+ existingPermissions = _context13.sent;
1036
+ case 24:
1037
+ if (existingPermissions) {
1038
+ _context13.next = 26;
1039
+ break;
1040
+ }
1041
+ throw Error("Unable to add permissions to uninitialized item");
1042
+ case 26:
1043
+ if (existingPermissions.profiles[profileName]) {
1044
+ _context13.next = 28;
1045
+ break;
1046
+ }
1047
+ throw Error("Profile '".concat(profileName, "' does not exist"));
1048
+ case 28:
1049
+ index = existingPermissions.permissions.findIndex(function (permission) {
1050
+ if (subjectSource === "fabric") {
1051
+ return permission.subject.id === subjectId;
1052
+ } else {
1053
+ return permission.subject.oauth_id === subjectId;
1054
+ }
1055
+ });
1056
+ if (index < 0) {
1057
+ index = existingPermissions.permissions.length;
1058
+ }
1059
+ permissionSpec = {
1060
+ profile: profileName
1061
+ };
1062
+ if (start) {
1063
+ permissionSpec.start = start;
1064
+ }
1065
+ if (end) {
1066
+ permissionSpec.end = end;
1067
+ }
1068
+ if (!(subjectSource === "fabric")) {
1069
+ _context13.next = 53;
1070
+ break;
1071
+ }
1072
+ if (!(subjectType === "group")) {
1073
+ _context13.next = 38;
1074
+ break;
1075
+ }
1076
+ subjectInfo = {
1077
+ id: subjectId,
1078
+ type: "group"
1079
+ };
1080
+ _context13.next = 51;
1081
+ break;
1082
+ case 38:
1083
+ if (!(subjectType === "user")) {
1084
+ _context13.next = 42;
1085
+ break;
1086
+ }
1087
+ subjectInfo = {
1088
+ id: subjectId,
1089
+ type: "user"
1090
+ };
1091
+ _context13.next = 51;
1092
+ break;
1093
+ case 42:
1094
+ if (!(subjectType === "ntp")) {
1095
+ _context13.next = 46;
1096
+ break;
1097
+ }
1098
+ subjectInfo = {
1099
+ id: subjectId,
1100
+ type: "otp"
1101
+ };
1102
+ _context13.next = 51;
1103
+ break;
1104
+ case 46:
1105
+ if (!(subjectType === "ntp_subject")) {
1106
+ _context13.next = 50;
1107
+ break;
1108
+ }
1109
+ subjectInfo = {
1110
+ id: subjectId,
1111
+ otp_id: subjectNTPId,
1112
+ type: "otp_subject"
1113
+ };
1114
+ _context13.next = 51;
1115
+ break;
1116
+ case 50:
1117
+ throw Error("Invalid subject type: ".concat(subjectType));
1118
+ case 51:
1119
+ _context13.next = 66;
1120
+ break;
1121
+ case 53:
1122
+ if (!(subjectSource === "oauth")) {
1123
+ _context13.next = 65;
1124
+ break;
1125
+ }
1126
+ if (!(subjectType === "group")) {
1127
+ _context13.next = 58;
1128
+ break;
1129
+ }
1130
+ subjectInfo = {
1131
+ id: subjectName,
1132
+ oauth_id: subjectId,
1133
+ type: "oauth_group"
1134
+ };
1135
+ _context13.next = 63;
1136
+ break;
1137
+ case 58:
1138
+ if (!(subjectType === "user")) {
1139
+ _context13.next = 62;
1140
+ break;
1141
+ }
1142
+ subjectInfo = {
1143
+ id: subjectName,
1144
+ oauth_id: subjectId,
1145
+ type: "oauth_user"
1146
+ };
1147
+ _context13.next = 63;
1148
+ break;
1149
+ case 62:
1150
+ throw Error("Invalid subject type: ".concat(subjectType));
1151
+ case 63:
1152
+ _context13.next = 66;
1153
+ break;
1154
+ case 65:
1155
+ throw Error("Invalid subject source: ".concat(subjectSource));
1156
+ case 66:
1157
+ permissionSpec.subject = subjectInfo;
1158
+ existingPermissions.permissions[index] = permissionSpec;
1159
+ if (offlineDraft) {
1160
+ _context13.next = 71;
1161
+ break;
1162
+ }
1163
+ _context13.next = 71;
1164
+ return this.client.ReplaceMetadata({
1165
+ libraryId: policyLibraryId,
1166
+ objectId: policyId,
1167
+ writeToken: policyWriteToken,
1168
+ metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions"),
1169
+ metadata: existingPermissions.permissions
1170
+ });
1171
+ case 71:
1172
+ if (!(subjectSource === "fabric" && subjectType === "user")) {
1173
+ _context13.next = 85;
1174
+ break;
1175
+ }
1176
+ newMeta = {
1177
+ address: this.client.utils.HashToAddress(subjectId),
1178
+ name: subjectName
1179
+ };
1180
+ if (!offlineDraft) {
1181
+ _context13.next = 77;
1182
+ break;
1183
+ }
1184
+ this.drafts[policyId].meta["auth_policy_settings"]["fabric_users"][this.client.utils.HashToAddress(subjectId)] = newMeta;
1185
+ _context13.next = 83;
1186
+ break;
1187
+ case 77:
1188
+ _context13.next = 79;
1189
+ return this.client.ContentObjectMetadata({
1190
+ libraryId: policyLibraryId,
1191
+ objectId: policyId,
1192
+ writeToken: policyWriteToken,
1193
+ metadataSubtree: UrlJoin("auth_policy_settings", "fabric_users", this.client.utils.HashToAddress(subjectId))
1194
+ });
1195
+ case 79:
1196
+ userInfo = _context13.sent;
1197
+ if (userInfo) {
1198
+ _context13.next = 83;
1199
+ break;
1200
+ }
1201
+ _context13.next = 83;
1202
+ return this.client.ReplaceMetadata({
1203
+ libraryId: policyLibraryId,
1204
+ objectId: policyId,
1205
+ writeToken: policyWriteToken,
1206
+ metadataSubtree: UrlJoin("auth_policy_settings", "fabric_users", this.client.utils.HashToAddress(subjectId)),
1207
+ metadata: newMeta
1208
+ });
1209
+ case 83:
1210
+ _context13.next = 97;
1211
+ break;
1212
+ case 85:
1213
+ if (!(subjectSource === "fabric" && subjectType === "ntp")) {
1214
+ _context13.next = 97;
1215
+ break;
1216
+ }
1217
+ _newMeta = {
1218
+ address: subjectId,
1219
+ ntpId: subjectId,
1220
+ name: subjectName,
1221
+ type: "ntpInstance"
1222
+ };
1223
+ if (!offlineDraft) {
1224
+ _context13.next = 91;
1225
+ break;
1226
+ }
1227
+ this.drafts[policyId].meta["auth_policy_settings"]["ntp_instances"][subjectId] = _newMeta;
1228
+ _context13.next = 97;
1229
+ break;
1230
+ case 91:
1231
+ _context13.next = 93;
1232
+ return this.client.ContentObjectMetadata({
1233
+ libraryId: policyLibraryId,
1234
+ objectId: policyId,
1235
+ writeToken: policyWriteToken,
1236
+ metadataSubtree: UrlJoin("auth_policy_settings", "ntp_instances", subjectId)
1237
+ });
1238
+ case 93:
1239
+ _userInfo = _context13.sent;
1240
+ if (_userInfo) {
1241
+ _context13.next = 97;
1242
+ break;
1243
+ }
1244
+ _context13.next = 97;
1245
+ return this.client.ReplaceMetadata({
1246
+ libraryId: policyLibraryId,
1247
+ objectId: policyId,
1248
+ writeToken: policyWriteToken,
1249
+ metadataSubtree: UrlJoin("auth_policy_settings", "ntp_instances", subjectId),
1250
+ metadata: _newMeta
1251
+ });
1252
+ case 97:
1253
+ case "end":
1254
+ return _context13.stop();
1255
+ }
1256
+ }, _callee13, this);
1257
+ }));
1258
+ function SetPermission(_x13) {
1259
+ return _SetPermission.apply(this, arguments);
1260
+ }
1261
+ return SetPermission;
1262
+ }()
1263
+ /**
1264
+ * Remove permission for the specified subject from the specified item policy
1265
+ *
1266
+ * @methodGroup Permissions
1267
+ * @namedParams
1268
+ * @param {string} policyId - Object ID of the policy
1269
+ * @param {string} policyWriteToken - Write token for the policy
1270
+ * @param {string} itemId - Object ID of the item
1271
+ * @param {string} subjectId - The ID of the subject
1272
+ */
1273
+ )
1274
+ }, {
1275
+ key: "RemovePermission",
1276
+ value: (function () {
1277
+ var _RemovePermission = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref14) {
1278
+ var _this4 = this;
1279
+ var policyId, policyWriteToken, itemId, subjectId, policyLibraryId, permissions, id;
1280
+ return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1281
+ while (1) switch (_context15.prev = _context15.next) {
1282
+ case 0:
1283
+ policyId = _ref14.policyId, policyWriteToken = _ref14.policyWriteToken, itemId = _ref14.itemId, subjectId = _ref14.subjectId;
1284
+ ValidatePresence("policyId", policyId);
1285
+ ValidatePresence("policyWriteToken", policyWriteToken);
1286
+ ValidatePresence("itemId", itemId);
1287
+ ValidatePresence("subjectId", subjectId);
1288
+ _context15.next = 7;
1289
+ return this.client.ContentObjectLibraryId({
1290
+ objectId: policyId
1291
+ });
1292
+ case 7:
1293
+ policyLibraryId = _context15.sent;
1294
+ _context15.next = 10;
1295
+ return this.client.ContentObjectMetadata({
1296
+ libraryId: policyLibraryId,
1297
+ objectId: policyId,
1298
+ writeToken: policyWriteToken,
1299
+ metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions")
1300
+ });
1301
+ case 10:
1302
+ permissions = _context15.sent;
1303
+ if (permissions) {
1304
+ _context15.next = 13;
1305
+ break;
1306
+ }
1307
+ return _context15.abrupt("return");
1308
+ case 13:
1309
+ if (!subjectId.startsWith("0x")) {
1310
+ _context15.next = 23;
1311
+ break;
1312
+ }
1313
+ id = this.client.utils.AddressToObjectId(subjectId);
1314
+ _context15.next = 17;
1315
+ return this.client.AccessType({
1316
+ id: id
1317
+ });
1318
+ case 17:
1319
+ _context15.t0 = _context15.sent;
1320
+ if (!(_context15.t0 === "group")) {
1321
+ _context15.next = 22;
1322
+ break;
1323
+ }
1324
+ subjectId = "igrp".concat(this.client.utils.AddressToHash(subjectId));
1325
+ _context15.next = 23;
1326
+ break;
1327
+ case 22:
1328
+ subjectId = "iusr".concat(this.client.utils.AddressToHash(subjectId));
1329
+ case 23:
1330
+ _context15.next = 25;
1331
+ return Promise.all(permissions.map( /*#__PURE__*/function () {
1332
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(permission, index) {
1333
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
1334
+ while (1) switch (_context14.prev = _context14.next) {
1335
+ case 0:
1336
+ if (!(permission.subject.id === subjectId || permission.subject.oauth_id === subjectId)) {
1337
+ _context14.next = 3;
1338
+ break;
1339
+ }
1340
+ _context14.next = 3;
1341
+ return _this4.client.DeleteMetadata({
1342
+ libraryId: policyLibraryId,
1343
+ objectId: policyId,
1344
+ writeToken: policyWriteToken,
1345
+ metadataSubtree: UrlJoin("auth_policy_spec", itemId, "permissions", index.toString())
1346
+ });
1347
+ case 3:
1348
+ case "end":
1349
+ return _context14.stop();
1350
+ }
1351
+ }, _callee14);
1352
+ }));
1353
+ return function (_x15, _x16) {
1354
+ return _ref15.apply(this, arguments);
1355
+ };
1356
+ }()));
1357
+ case 25:
1358
+ case "end":
1359
+ return _context15.stop();
1360
+ }
1361
+ }, _callee15, this);
1362
+ }));
1363
+ function RemovePermission(_x14) {
1364
+ return _RemovePermission.apply(this, arguments);
1365
+ }
1366
+ return RemovePermission;
1367
+ }()
1368
+ /**
1369
+ * Retrieve all permissions for the specified subject.
1370
+ *
1371
+ * @methodGroup Permissions
1372
+ * @namedParams
1373
+ * @param {string} policyId - Object ID of the policy
1374
+ * @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
1375
+ * @param {string} subjectId - The ID of the subject
1376
+ *
1377
+ * @returns {Object} - All permissions pertaining to the given subject. Format of result for each item is identical to the format of `ItemPolicy`
1378
+ */
1379
+ )
1380
+ }, {
1381
+ key: "SubjectPermissions",
1382
+ value: (function () {
1383
+ var _SubjectPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref16) {
1384
+ var _this5 = this;
1385
+ var policyId, policyWriteToken, subjectId, id, policyLibraryId, policy, allSubjectPermissions, _i, _Object$keys, itemId, itemPermissions, subjectPermissions;
1386
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
1387
+ while (1) switch (_context17.prev = _context17.next) {
1388
+ case 0:
1389
+ policyId = _ref16.policyId, policyWriteToken = _ref16.policyWriteToken, subjectId = _ref16.subjectId;
1390
+ ValidatePresence("policyId", policyId);
1391
+ ValidatePresence("subjectId", subjectId);
1392
+
1393
+ // Convert address to appropriate ID
1394
+ if (!subjectId.startsWith("0x")) {
1395
+ _context17.next = 13;
1396
+ break;
1397
+ }
1398
+ id = this.client.utils.AddressToObjectId(subjectId);
1399
+ _context17.next = 7;
1400
+ return this.client.AccessType({
1401
+ id: id
1402
+ });
1403
+ case 7:
1404
+ _context17.t0 = _context17.sent;
1405
+ if (!(_context17.t0 === "group")) {
1406
+ _context17.next = 12;
1407
+ break;
1408
+ }
1409
+ subjectId = "igrp".concat(this.client.utils.AddressToHash(subjectId));
1410
+ _context17.next = 13;
1411
+ break;
1412
+ case 12:
1413
+ subjectId = "iusr".concat(this.client.utils.AddressToHash(subjectId));
1414
+ case 13:
1415
+ _context17.next = 15;
1416
+ return this.client.ContentObjectLibraryId({
1417
+ objectId: policyId
1418
+ });
1419
+ case 15:
1420
+ policyLibraryId = _context17.sent;
1421
+ _context17.next = 18;
1422
+ return this.client.ContentObjectMetadata({
1423
+ libraryId: policyLibraryId,
1424
+ objectId: policyId,
1425
+ writeToken: policyWriteToken,
1426
+ metadataSubtree: UrlJoin("auth_policy_spec")
1427
+ });
1428
+ case 18:
1429
+ policy = _context17.sent;
1430
+ allSubjectPermissions = {};
1431
+ _i = 0, _Object$keys = Object.keys(policy);
1432
+ case 21:
1433
+ if (!(_i < _Object$keys.length)) {
1434
+ _context17.next = 31;
1435
+ break;
1436
+ }
1437
+ itemId = _Object$keys[_i];
1438
+ itemPermissions = policy[itemId].permissions || [];
1439
+ _context17.next = 26;
1440
+ return Promise.all(itemPermissions.filter(function (permission) {
1441
+ return (permission.subject || {}).oauth_id === subjectId || (permission.subject || {}).id === subjectId;
1442
+ }).map( /*#__PURE__*/function () {
1443
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(permission) {
1444
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
1445
+ while (1) switch (_context16.prev = _context16.next) {
1446
+ case 0:
1447
+ _context16.next = 2;
1448
+ return _this5.FormatPermission({
1449
+ policyId: policyId,
1450
+ policyWriteToken: policyWriteToken,
1451
+ permission: permission
1452
+ });
1453
+ case 2:
1454
+ return _context16.abrupt("return", _context16.sent);
1455
+ case 3:
1456
+ case "end":
1457
+ return _context16.stop();
1458
+ }
1459
+ }, _callee16);
1460
+ }));
1461
+ return function (_x18) {
1462
+ return _ref17.apply(this, arguments);
1463
+ };
1464
+ }()));
1465
+ case 26:
1466
+ subjectPermissions = _context17.sent;
1467
+ if (subjectPermissions.length > 0) {
1468
+ allSubjectPermissions[itemId] = _objectSpread(_objectSpread({}, policy[itemId]), {}, {
1469
+ permissions: subjectPermissions
1470
+ });
1471
+ }
1472
+ case 28:
1473
+ _i++;
1474
+ _context17.next = 21;
1475
+ break;
1476
+ case 31:
1477
+ return _context17.abrupt("return", allSubjectPermissions);
1478
+ case 32:
1479
+ case "end":
1480
+ return _context17.stop();
1481
+ }
1482
+ }, _callee17, this);
1483
+ }));
1484
+ function SubjectPermissions(_x17) {
1485
+ return _SubjectPermissions.apply(this, arguments);
1486
+ }
1487
+ return SubjectPermissions;
1488
+ }()
1489
+ /**
1490
+ * Remove all permissions for the specified subject.
1491
+ *
1492
+ * @methodGroup Permissions
1493
+ * @namedParams
1494
+ * @param {string} policyId - Object ID of the policy
1495
+ * @param {string} policyWriteToken - Write token for the policy
1496
+ * @param {string} subjectId - The ID of the subject
1497
+ */
1498
+ )
1499
+ }, {
1500
+ key: "RemoveSubjectPermissions",
1501
+ value: (function () {
1502
+ var _RemoveSubjectPermissions = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(_ref18) {
1503
+ var _this6 = this;
1504
+ var policyId, policyWriteToken, subjectId, subjectPermissions;
1505
+ return _regeneratorRuntime.wrap(function _callee19$(_context19) {
1506
+ while (1) switch (_context19.prev = _context19.next) {
1507
+ case 0:
1508
+ policyId = _ref18.policyId, policyWriteToken = _ref18.policyWriteToken, subjectId = _ref18.subjectId;
1509
+ ValidatePresence("policyId", policyId);
1510
+ ValidatePresence("policyWriteToken", policyWriteToken);
1511
+ ValidatePresence("subjectId", subjectId);
1512
+ _context19.next = 6;
1513
+ return this.SubjectPermissions({
1514
+ policyId: policyId,
1515
+ policyWriteToken: policyWriteToken,
1516
+ subjectId: subjectId
1517
+ });
1518
+ case 6:
1519
+ subjectPermissions = _context19.sent;
1520
+ _context19.next = 9;
1521
+ return this.client.utils.LimitedMap(5, Object.keys(subjectPermissions), /*#__PURE__*/function () {
1522
+ var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18(itemId) {
1523
+ return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1524
+ while (1) switch (_context18.prev = _context18.next) {
1525
+ case 0:
1526
+ _context18.next = 2;
1527
+ return _this6.RemovePermission({
1528
+ policyId: policyId,
1529
+ policyWriteToken: policyWriteToken,
1530
+ subjectId: subjectId,
1531
+ itemId: itemId
1532
+ });
1533
+ case 2:
1534
+ case "end":
1535
+ return _context18.stop();
1536
+ }
1537
+ }, _callee18);
1538
+ }));
1539
+ return function (_x20) {
1540
+ return _ref19.apply(this, arguments);
1541
+ };
1542
+ }());
1543
+ case 9:
1544
+ case "end":
1545
+ return _context19.stop();
1546
+ }
1547
+ }, _callee19, this);
1548
+ }));
1549
+ function RemoveSubjectPermissions(_x19) {
1550
+ return _RemoveSubjectPermissions.apply(this, arguments);
1551
+ }
1552
+ return RemoveSubjectPermissions;
1553
+ }())
1554
+ }]);
1555
+ }();
1556
+ module.exports = PermissionsClient;