@eluvio/elv-client-js 3.1.92 → 3.1.95

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 (35) hide show
  1. package/dist/ElvClient-min.js +15 -11
  2. package/dist/ElvClient-node-min.js +17 -13
  3. package/dist/ElvFrameClient-min.js +13 -9
  4. package/dist/ElvPermissionsClient-min.js +13 -9
  5. package/dist/src/AuthorizationClient.js +2248 -1990
  6. package/dist/src/ContentObjectVerification.js +164 -173
  7. package/dist/src/Crypto.js +376 -324
  8. package/dist/src/ElvClient.js +1214 -938
  9. package/dist/src/ElvWallet.js +119 -95
  10. package/dist/src/EthClient.js +1040 -896
  11. package/dist/src/FrameClient.js +331 -300
  12. package/dist/src/HttpClient.js +153 -147
  13. package/dist/src/Id.js +1 -3
  14. package/dist/src/PermissionsClient.js +1294 -1168
  15. package/dist/src/RemoteSigner.js +260 -200
  16. package/dist/src/UserProfileClient.js +1168 -1014
  17. package/dist/src/Utils.js +382 -178
  18. package/dist/src/client/ABRPublishing.js +895 -856
  19. package/dist/src/client/AccessGroups.js +1102 -959
  20. package/dist/src/client/ContentAccess.js +3737 -3427
  21. package/dist/src/client/ContentManagement.js +2255 -2063
  22. package/dist/src/client/Contracts.js +647 -563
  23. package/dist/src/client/Files.js +1886 -1757
  24. package/dist/src/client/NFT.js +127 -158
  25. package/dist/src/client/NTP.js +478 -422
  26. package/package.json +2 -1
  27. package/src/ElvClient.js +62 -1
  28. package/src/RemoteSigner.js +22 -18
  29. package/src/Utils.js +119 -0
  30. package/src/client/ABRPublishing.js +2 -1
  31. package/src/client/NFT.js +14 -49
  32. package/testScripts/Test.js +0 -19
  33. package/testScripts/VariantABRProfile.js +45 -0
  34. package/utilities/SimpleIngest.js +245 -0
  35. package/package-lock.json +0 -12650
@@ -4,9 +4,11 @@ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
4
4
 
5
5
  var _regeneratorRuntime = require("@babel/runtime/regenerator");
6
6
 
7
- 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; }
7
+ var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
8
8
 
9
- 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; }
9
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
+
11
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
10
12
 
11
13
  /**
12
14
  * Methods for managing content types, libraries and objects
@@ -34,55 +36,61 @@ var _require = require("../Validation"),
34
36
  ValidateParameters = _require.ValidateParameters,
35
37
  ValidatePresence = _require.ValidatePresence;
36
38
 
37
- exports.SetVisibility = function _callee(_ref) {
38
- var id, visibility, hasSetVisibility, event;
39
- return _regeneratorRuntime.async(function _callee$(_context) {
40
- while (1) {
41
- switch (_context.prev = _context.next) {
42
- case 0:
43
- id = _ref.id, visibility = _ref.visibility;
44
- this.Log("Setting visibility ".concat(visibility, " on ").concat(id));
45
- _context.next = 4;
46
- return _regeneratorRuntime.awrap(this.authClient.ContractHasMethod({
47
- contractAddress: this.utils.HashToAddress(id),
48
- methodName: "setVisibility"
49
- }));
50
-
51
- case 4:
52
- hasSetVisibility = _context.sent;
53
-
54
- if (hasSetVisibility) {
55
- _context.next = 7;
56
- break;
57
- }
58
-
59
- return _context.abrupt("return");
60
-
61
- case 7:
62
- _context.next = 9;
63
- return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
64
- contractAddress: this.utils.HashToAddress(id),
65
- methodName: "setVisibility",
66
- methodArgs: [visibility]
67
- }));
68
-
69
- case 9:
70
- event = _context.sent;
71
- _context.next = 12;
72
- return _regeneratorRuntime.awrap(new Promise(function (resolve) {
73
- return setTimeout(resolve, 5000);
74
- }));
75
-
76
- case 12:
77
- return _context.abrupt("return", event);
78
-
79
- case 13:
80
- case "end":
81
- return _context.stop();
39
+ exports.SetVisibility = /*#__PURE__*/function () {
40
+ var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
41
+ var id, visibility, hasSetVisibility, event;
42
+ return _regeneratorRuntime.wrap(function _callee$(_context) {
43
+ while (1) {
44
+ switch (_context.prev = _context.next) {
45
+ case 0:
46
+ id = _ref.id, visibility = _ref.visibility;
47
+ this.Log("Setting visibility ".concat(visibility, " on ").concat(id));
48
+ _context.next = 4;
49
+ return this.authClient.ContractHasMethod({
50
+ contractAddress: this.utils.HashToAddress(id),
51
+ methodName: "setVisibility"
52
+ });
53
+
54
+ case 4:
55
+ hasSetVisibility = _context.sent;
56
+
57
+ if (hasSetVisibility) {
58
+ _context.next = 7;
59
+ break;
60
+ }
61
+
62
+ return _context.abrupt("return");
63
+
64
+ case 7:
65
+ _context.next = 9;
66
+ return this.CallContractMethodAndWait({
67
+ contractAddress: this.utils.HashToAddress(id),
68
+ methodName: "setVisibility",
69
+ methodArgs: [visibility]
70
+ });
71
+
72
+ case 9:
73
+ event = _context.sent;
74
+ _context.next = 12;
75
+ return new Promise(function (resolve) {
76
+ return setTimeout(resolve, 5000);
77
+ });
78
+
79
+ case 12:
80
+ return _context.abrupt("return", event);
81
+
82
+ case 13:
83
+ case "end":
84
+ return _context.stop();
85
+ }
82
86
  }
83
- }
84
- }, null, this);
85
- };
87
+ }, _callee, this);
88
+ }));
89
+
90
+ return function (_x) {
91
+ return _ref2.apply(this, arguments);
92
+ };
93
+ }();
86
94
  /**
87
95
  * Set the current permission level for the specified object. See client.permissionLevels for all available permissions.
88
96
  *
@@ -95,206 +103,220 @@ exports.SetVisibility = function _callee(_ref) {
95
103
  */
96
104
 
97
105
 
98
- exports.SetPermission = function _callee2(_ref2) {
99
- var _this = this;
106
+ exports.SetPermission = /*#__PURE__*/function () {
107
+ var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
108
+ var _this = this;
100
109
 
101
- var objectId, permission, writeToken, permissionSettings, settings, libraryId, statusCode, kmsAddress, kmsConkKey, kmsConk, finalize;
102
- return _regeneratorRuntime.async(function _callee2$(_context3) {
103
- while (1) {
104
- switch (_context3.prev = _context3.next) {
105
- case 0:
106
- objectId = _ref2.objectId, permission = _ref2.permission, writeToken = _ref2.writeToken;
107
- ValidateObject(objectId);
108
- ValidatePresence("permission", permission);
109
- permissionSettings = this.permissionLevels[permission];
110
+ var objectId, permission, writeToken, permissionSettings, settings, libraryId, statusCode, kmsAddress, kmsConkKey, kmsConk, finalize;
111
+ return _regeneratorRuntime.wrap(function _callee3$(_context3) {
112
+ while (1) {
113
+ switch (_context3.prev = _context3.next) {
114
+ case 0:
115
+ objectId = _ref3.objectId, permission = _ref3.permission, writeToken = _ref3.writeToken;
116
+ ValidateObject(objectId);
117
+ ValidatePresence("permission", permission);
118
+ permissionSettings = this.permissionLevels[permission];
110
119
 
111
- if (permissionSettings) {
112
- _context3.next = 6;
113
- break;
114
- }
120
+ if (permissionSettings) {
121
+ _context3.next = 6;
122
+ break;
123
+ }
115
124
 
116
- throw Error("Unknown permission level: " + permission);
125
+ throw Error("Unknown permission level: " + permission);
117
126
 
118
- case 6:
119
- _context3.next = 8;
120
- return _regeneratorRuntime.awrap(this.AccessType({
121
- id: objectId
122
- }));
127
+ case 6:
128
+ _context3.next = 8;
129
+ return this.AccessType({
130
+ id: objectId
131
+ });
123
132
 
124
- case 8:
125
- _context3.t0 = _context3.sent;
126
- _context3.t1 = this.authClient.ACCESS_TYPES.OBJECT;
133
+ case 8:
134
+ _context3.t0 = _context3.sent;
135
+ _context3.t1 = this.authClient.ACCESS_TYPES.OBJECT;
127
136
 
128
- if (!(_context3.t0 !== _context3.t1)) {
129
- _context3.next = 12;
130
- break;
131
- }
132
-
133
- throw Error("Permission only valid for normal content objects: " + objectId);
134
-
135
- case 12:
136
- settings = permissionSettings.settings;
137
- _context3.next = 15;
138
- return _regeneratorRuntime.awrap(this.ContentObjectLibraryId({
139
- objectId: objectId
140
- }));
141
-
142
- case 15:
143
- libraryId = _context3.sent;
144
- _context3.next = 18;
145
- return _regeneratorRuntime.awrap(this.SetVisibility({
146
- id: objectId,
147
- visibility: settings.visibility
148
- }));
149
-
150
- case 18:
151
- _context3.next = 20;
152
- return _regeneratorRuntime.awrap(this.CallContractMethod({
153
- contractAddress: this.utils.HashToAddress(objectId),
154
- methodName: "statusCode"
155
- }));
156
-
157
- case 20:
158
- statusCode = _context3.sent;
159
-
160
- if (!(statusCode !== settings.statusCode)) {
137
+ if (!(_context3.t0 !== _context3.t1)) {
138
+ _context3.next = 12;
139
+ break;
140
+ }
141
+
142
+ throw Error("Permission only valid for normal content objects: " + objectId);
143
+
144
+ case 12:
145
+ settings = permissionSettings.settings;
146
+ _context3.next = 15;
147
+ return this.ContentObjectLibraryId({
148
+ objectId: objectId
149
+ });
150
+
151
+ case 15:
152
+ libraryId = _context3.sent;
153
+ _context3.next = 18;
154
+ return this.SetVisibility({
155
+ id: objectId,
156
+ visibility: settings.visibility
157
+ });
158
+
159
+ case 18:
160
+ _context3.next = 20;
161
+ return this.CallContractMethod({
162
+ contractAddress: this.utils.HashToAddress(objectId),
163
+ methodName: "statusCode"
164
+ });
165
+
166
+ case 20:
167
+ statusCode = _context3.sent;
168
+
169
+ if (!(statusCode !== settings.statusCode)) {
170
+ _context3.next = 29;
171
+ break;
172
+ }
173
+
174
+ if (!(settings.statusCode < 0)) {
175
+ _context3.next = 27;
176
+ break;
177
+ }
178
+
179
+ _context3.next = 25;
180
+ return this.CallContractMethod({
181
+ contractAddress: this.utils.HashToAddress(objectId),
182
+ methodName: "setStatusCode",
183
+ methodArgs: [-1]
184
+ });
185
+
186
+ case 25:
161
187
  _context3.next = 29;
162
188
  break;
163
- }
164
189
 
165
- if (!(settings.statusCode < 0)) {
166
- _context3.next = 27;
167
- break;
168
- }
169
-
170
- _context3.next = 25;
171
- return _regeneratorRuntime.awrap(this.CallContractMethod({
172
- contractAddress: this.utils.HashToAddress(objectId),
173
- methodName: "setStatusCode",
174
- methodArgs: [-1]
175
- }));
176
-
177
- case 25:
178
- _context3.next = 29;
179
- break;
180
-
181
- case 27:
182
- _context3.next = 29;
183
- return _regeneratorRuntime.awrap(this.CallContractMethod({
184
- contractAddress: this.utils.HashToAddress(objectId),
185
- methodName: "publish"
186
- }));
187
-
188
- case 29:
189
- _context3.next = 31;
190
- return _regeneratorRuntime.awrap(this.CallContractMethod({
191
- contractAddress: this.utils.HashToAddress(objectId),
192
- methodName: "addressKMS"
193
- }));
194
-
195
- case 31:
196
- kmsAddress = _context3.sent;
197
- kmsConkKey = "eluv.caps.ikms".concat(this.utils.AddressToHash(kmsAddress));
198
- _context3.next = 35;
199
- return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
200
- libraryId: libraryId,
201
- objectId: objectId,
202
- metadataSubtree: kmsConkKey
203
- }));
204
-
205
- case 35:
206
- kmsConk = _context3.sent;
207
-
208
- if (!(kmsConk && !settings.kmsConk)) {
209
- _context3.next = 41;
210
- break;
211
- }
212
-
213
- _context3.next = 39;
214
- return _regeneratorRuntime.awrap(this.EditAndFinalizeContentObject({
215
- libraryId: libraryId,
216
- objectId: objectId,
217
- commitMessage: "Remove encryption conk",
218
- callback: function callback(_ref3) {
219
- var writeToken;
220
- return _regeneratorRuntime.async(function callback$(_context2) {
221
- while (1) {
222
- switch (_context2.prev = _context2.next) {
223
- case 0:
224
- writeToken = _ref3.writeToken;
225
- _context2.next = 3;
226
- return _regeneratorRuntime.awrap(_this.DeleteMetadata({
227
- libraryId: libraryId,
228
- objectId: objectId,
229
- writeToken: writeToken,
230
- metadataSubtree: kmsConkKey
231
- }));
190
+ case 27:
191
+ _context3.next = 29;
192
+ return this.CallContractMethod({
193
+ contractAddress: this.utils.HashToAddress(objectId),
194
+ methodName: "publish"
195
+ });
232
196
 
233
- case 3:
234
- case "end":
235
- return _context2.stop();
236
- }
237
- }
238
- });
197
+ case 29:
198
+ _context3.next = 31;
199
+ return this.CallContractMethod({
200
+ contractAddress: this.utils.HashToAddress(objectId),
201
+ methodName: "addressKMS"
202
+ });
203
+
204
+ case 31:
205
+ kmsAddress = _context3.sent;
206
+ kmsConkKey = "eluv.caps.ikms".concat(this.utils.AddressToHash(kmsAddress));
207
+ _context3.next = 35;
208
+ return this.ContentObjectMetadata({
209
+ libraryId: libraryId,
210
+ objectId: objectId,
211
+ metadataSubtree: kmsConkKey
212
+ });
213
+
214
+ case 35:
215
+ kmsConk = _context3.sent;
216
+
217
+ if (!(kmsConk && !settings.kmsConk)) {
218
+ _context3.next = 41;
219
+ break;
239
220
  }
240
- }));
241
221
 
242
- case 39:
243
- _context3.next = 52;
244
- break;
222
+ _context3.next = 39;
223
+ return this.EditAndFinalizeContentObject({
224
+ libraryId: libraryId,
225
+ objectId: objectId,
226
+ commitMessage: "Remove encryption conk",
227
+ callback: function () {
228
+ var _callback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5) {
229
+ var writeToken;
230
+ return _regeneratorRuntime.wrap(function _callee2$(_context2) {
231
+ while (1) {
232
+ switch (_context2.prev = _context2.next) {
233
+ case 0:
234
+ writeToken = _ref5.writeToken;
235
+ _context2.next = 3;
236
+ return _this.DeleteMetadata({
237
+ libraryId: libraryId,
238
+ objectId: objectId,
239
+ writeToken: writeToken,
240
+ metadataSubtree: kmsConkKey
241
+ });
242
+
243
+ case 3:
244
+ case "end":
245
+ return _context2.stop();
246
+ }
247
+ }
248
+ }, _callee2);
249
+ }));
250
+
251
+ function callback(_x3) {
252
+ return _callback.apply(this, arguments);
253
+ }
254
+
255
+ return callback;
256
+ }()
257
+ });
245
258
 
246
- case 41:
247
- if (!(!kmsConk && settings.kmsConk)) {
259
+ case 39:
248
260
  _context3.next = 52;
249
261
  break;
250
- }
251
262
 
252
- finalize = !writeToken;
263
+ case 41:
264
+ if (!(!kmsConk && settings.kmsConk)) {
265
+ _context3.next = 52;
266
+ break;
267
+ }
268
+
269
+ finalize = !writeToken;
270
+
271
+ if (writeToken) {
272
+ _context3.next = 47;
273
+ break;
274
+ }
275
+
276
+ _context3.next = 46;
277
+ return this.EditContentObject({
278
+ libraryId: libraryId,
279
+ objectId: objectId
280
+ });
281
+
282
+ case 46:
283
+ writeToken = _context3.sent.writeToken;
284
+
285
+ case 47:
286
+ _context3.next = 49;
287
+ return this.CreateEncryptionConk({
288
+ libraryId: libraryId,
289
+ objectId: objectId,
290
+ writeToken: writeToken,
291
+ createKMSConk: true
292
+ });
293
+
294
+ case 49:
295
+ if (!finalize) {
296
+ _context3.next = 52;
297
+ break;
298
+ }
253
299
 
254
- if (writeToken) {
255
- _context3.next = 47;
256
- break;
257
- }
258
-
259
- _context3.next = 46;
260
- return _regeneratorRuntime.awrap(this.EditContentObject({
261
- libraryId: libraryId,
262
- objectId: objectId
263
- }));
264
-
265
- case 46:
266
- writeToken = _context3.sent.writeToken;
267
-
268
- case 47:
269
- _context3.next = 49;
270
- return _regeneratorRuntime.awrap(this.CreateEncryptionConk({
271
- libraryId: libraryId,
272
- objectId: objectId,
273
- writeToken: writeToken,
274
- createKMSConk: true
275
- }));
276
-
277
- case 49:
278
- if (!finalize) {
279
300
  _context3.next = 52;
280
- break;
281
- }
282
-
283
- _context3.next = 52;
284
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
285
- libraryId: libraryId,
286
- objectId: objectId,
287
- writeToken: writeToken,
288
- commitMessage: "Set permissions to ".concat(permission)
289
- }));
290
-
291
- case 52:
292
- case "end":
293
- return _context3.stop();
301
+ return this.FinalizeContentObject({
302
+ libraryId: libraryId,
303
+ objectId: objectId,
304
+ writeToken: writeToken,
305
+ commitMessage: "Set permissions to ".concat(permission)
306
+ });
307
+
308
+ case 52:
309
+ case "end":
310
+ return _context3.stop();
311
+ }
294
312
  }
295
- }
296
- }, null, this);
297
- };
313
+ }, _callee3, this);
314
+ }));
315
+
316
+ return function (_x2) {
317
+ return _ref4.apply(this, arguments);
318
+ };
319
+ }();
298
320
  /* Content Type Creation */
299
321
 
300
322
  /**
@@ -317,117 +339,121 @@ exports.SetPermission = function _callee2(_ref2) {
317
339
  */
318
340
 
319
341
 
320
- exports.CreateContentType = function _callee3(_ref4) {
321
- var name, _ref4$metadata, metadata, bitcode, _ref5, contractAddress, objectId, path, createResponse, uploadResponse;
322
-
323
- return _regeneratorRuntime.async(function _callee3$(_context4) {
324
- while (1) {
325
- switch (_context4.prev = _context4.next) {
326
- case 0:
327
- name = _ref4.name, _ref4$metadata = _ref4.metadata, metadata = _ref4$metadata === void 0 ? {} : _ref4$metadata, bitcode = _ref4.bitcode;
328
- this.Log("Creating content type: ".concat(name));
329
- metadata.name = name;
330
- metadata["public"] = _objectSpread({
331
- name: name
332
- }, metadata["public"] || {});
333
- _context4.next = 6;
334
- return _regeneratorRuntime.awrap(this.authClient.CreateContentType());
335
-
336
- case 6:
337
- _ref5 = _context4.sent;
338
- contractAddress = _ref5.contractAddress;
339
- objectId = this.utils.AddressToObjectId(contractAddress);
340
- _context4.next = 11;
341
- return _regeneratorRuntime.awrap(this.SetVisibility({
342
- id: objectId,
343
- visibility: 1
344
- }));
345
-
346
- case 11:
347
- path = UrlJoin("qlibs", this.contentSpaceLibraryId, "qid", objectId);
348
- this.Log("Created type: ".concat(contractAddress, " ").concat(objectId));
349
- /* Create object, upload bitcode and finalize */
350
-
351
- _context4.t0 = _regeneratorRuntime;
352
- _context4.t1 = this.utils;
353
- _context4.t2 = this.HttpClient;
354
- _context4.next = 18;
355
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
356
- libraryId: this.contentSpaceLibraryId,
357
- objectId: objectId,
358
- update: true
359
- }));
360
-
361
- case 18:
362
- _context4.t3 = _context4.sent;
363
- _context4.t4 = path;
364
- _context4.t5 = {
365
- headers: _context4.t3,
366
- method: "POST",
367
- path: _context4.t4
368
- };
369
- _context4.t6 = _context4.t2.Request.call(_context4.t2, _context4.t5);
370
- _context4.t7 = _context4.t1.ResponseToJson.call(_context4.t1, _context4.t6);
371
- _context4.next = 25;
372
- return _context4.t0.awrap.call(_context4.t0, _context4.t7);
373
-
374
- case 25:
375
- createResponse = _context4.sent;
376
- // Record the node used in creating this write token
377
- this.HttpClient.RecordWriteToken(createResponse.write_token);
378
- _context4.next = 29;
379
- return _regeneratorRuntime.awrap(this.ReplaceMetadata({
380
- libraryId: this.contentSpaceLibraryId,
381
- objectId: objectId,
382
- writeToken: createResponse.write_token,
383
- metadata: metadata
384
- }));
385
-
386
- case 29:
387
- if (!bitcode) {
342
+ exports.CreateContentType = /*#__PURE__*/function () {
343
+ var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref6) {
344
+ var name, _ref6$metadata, metadata, bitcode, _yield$this$authClien, contractAddress, objectId, path, createResponse, uploadResponse;
345
+
346
+ return _regeneratorRuntime.wrap(function _callee4$(_context4) {
347
+ while (1) {
348
+ switch (_context4.prev = _context4.next) {
349
+ case 0:
350
+ name = _ref6.name, _ref6$metadata = _ref6.metadata, metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata, bitcode = _ref6.bitcode;
351
+ this.Log("Creating content type: ".concat(name));
352
+ metadata.name = name;
353
+ metadata["public"] = _objectSpread({
354
+ name: name
355
+ }, metadata["public"] || {});
356
+ _context4.next = 6;
357
+ return this.authClient.CreateContentType();
358
+
359
+ case 6:
360
+ _yield$this$authClien = _context4.sent;
361
+ contractAddress = _yield$this$authClien.contractAddress;
362
+ objectId = this.utils.AddressToObjectId(contractAddress);
363
+ _context4.next = 11;
364
+ return this.SetVisibility({
365
+ id: objectId,
366
+ visibility: 1
367
+ });
368
+
369
+ case 11:
370
+ path = UrlJoin("qlibs", this.contentSpaceLibraryId, "qid", objectId);
371
+ this.Log("Created type: ".concat(contractAddress, " ").concat(objectId));
372
+ /* Create object, upload bitcode and finalize */
373
+
374
+ _context4.t0 = this.utils;
375
+ _context4.t1 = this.HttpClient;
376
+ _context4.next = 17;
377
+ return this.authClient.AuthorizationHeader({
378
+ libraryId: this.contentSpaceLibraryId,
379
+ objectId: objectId,
380
+ update: true
381
+ });
382
+
383
+ case 17:
384
+ _context4.t2 = _context4.sent;
385
+ _context4.t3 = path;
386
+ _context4.t4 = {
387
+ headers: _context4.t2,
388
+ method: "POST",
389
+ path: _context4.t3
390
+ };
391
+ _context4.t5 = _context4.t1.Request.call(_context4.t1, _context4.t4);
392
+ _context4.next = 23;
393
+ return _context4.t0.ResponseToJson.call(_context4.t0, _context4.t5);
394
+
395
+ case 23:
396
+ createResponse = _context4.sent;
397
+ // Record the node used in creating this write token
398
+ this.HttpClient.RecordWriteToken(createResponse.write_token);
399
+ _context4.next = 27;
400
+ return this.ReplaceMetadata({
401
+ libraryId: this.contentSpaceLibraryId,
402
+ objectId: objectId,
403
+ writeToken: createResponse.write_token,
404
+ metadata: metadata
405
+ });
406
+
407
+ case 27:
408
+ if (!bitcode) {
409
+ _context4.next = 33;
410
+ break;
411
+ }
412
+
413
+ _context4.next = 30;
414
+ return this.UploadPart({
415
+ libraryId: this.contentSpaceLibraryId,
416
+ objectId: objectId,
417
+ writeToken: createResponse.write_token,
418
+ data: bitcode,
419
+ encrypted: false
420
+ });
421
+
422
+ case 30:
423
+ uploadResponse = _context4.sent;
424
+ _context4.next = 33;
425
+ return this.ReplaceMetadata({
426
+ libraryId: this.contentSpaceLibraryId,
427
+ objectId: objectId,
428
+ writeToken: createResponse.write_token,
429
+ metadataSubtree: "bitcode_part",
430
+ metadata: uploadResponse.part.hash
431
+ });
432
+
433
+ case 33:
388
434
  _context4.next = 35;
389
- break;
390
- }
391
-
392
- _context4.next = 32;
393
- return _regeneratorRuntime.awrap(this.UploadPart({
394
- libraryId: this.contentSpaceLibraryId,
395
- objectId: objectId,
396
- writeToken: createResponse.write_token,
397
- data: bitcode,
398
- encrypted: false
399
- }));
400
-
401
- case 32:
402
- uploadResponse = _context4.sent;
403
- _context4.next = 35;
404
- return _regeneratorRuntime.awrap(this.ReplaceMetadata({
405
- libraryId: this.contentSpaceLibraryId,
406
- objectId: objectId,
407
- writeToken: createResponse.write_token,
408
- metadataSubtree: "bitcode_part",
409
- metadata: uploadResponse.part.hash
410
- }));
411
-
412
- case 35:
413
- _context4.next = 37;
414
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
415
- libraryId: this.contentSpaceLibraryId,
416
- objectId: objectId,
417
- writeToken: createResponse.write_token,
418
- commitMessage: "Create content type"
419
- }));
420
-
421
- case 37:
422
- return _context4.abrupt("return", objectId);
423
-
424
- case 38:
425
- case "end":
426
- return _context4.stop();
435
+ return this.FinalizeContentObject({
436
+ libraryId: this.contentSpaceLibraryId,
437
+ objectId: objectId,
438
+ writeToken: createResponse.write_token,
439
+ commitMessage: "Create content type"
440
+ });
441
+
442
+ case 35:
443
+ return _context4.abrupt("return", objectId);
444
+
445
+ case 36:
446
+ case "end":
447
+ return _context4.stop();
448
+ }
427
449
  }
428
- }
429
- }, null, this);
430
- };
450
+ }, _callee4, this);
451
+ }));
452
+
453
+ return function (_x4) {
454
+ return _ref7.apply(this, arguments);
455
+ };
456
+ }();
431
457
  /* Library creation and deletion */
432
458
 
433
459
  /**
@@ -453,129 +479,143 @@ exports.CreateContentType = function _callee3(_ref4) {
453
479
  */
454
480
 
455
481
 
456
- exports.CreateContentLibrary = function _callee4(_ref6) {
457
- var name, description, image, imageName, _ref6$metadata, metadata, kmsId, tenantId, _ref7, contractAddress, libraryId, objectId, editResponse;
482
+ exports.CreateContentLibrary = /*#__PURE__*/function () {
483
+ var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
484
+ var name, description, image, imageName, _ref8$metadata, metadata, kmsId, tenantId, _yield$this$authClien2, contractAddress, libraryId, objectId, editResponse;
458
485
 
459
- return _regeneratorRuntime.async(function _callee4$(_context5) {
460
- while (1) {
461
- switch (_context5.prev = _context5.next) {
462
- case 0:
463
- name = _ref6.name, description = _ref6.description, image = _ref6.image, imageName = _ref6.imageName, _ref6$metadata = _ref6.metadata, metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata, kmsId = _ref6.kmsId, tenantId = _ref6.tenantId;
486
+ return _regeneratorRuntime.wrap(function _callee5$(_context5) {
487
+ while (1) {
488
+ switch (_context5.prev = _context5.next) {
489
+ case 0:
490
+ name = _ref8.name, description = _ref8.description, image = _ref8.image, imageName = _ref8.imageName, _ref8$metadata = _ref8.metadata, metadata = _ref8$metadata === void 0 ? {} : _ref8$metadata, kmsId = _ref8.kmsId, tenantId = _ref8.tenantId;
464
491
 
465
- if (kmsId) {
466
- _context5.next = 9;
467
- break;
468
- }
469
-
470
- _context5.t0 = "ikms";
471
- _context5.t1 = this.utils;
472
- _context5.next = 6;
473
- return _regeneratorRuntime.awrap(this.DefaultKMSAddress());
474
-
475
- case 6:
476
- _context5.t2 = _context5.sent;
477
- _context5.t3 = _context5.t1.AddressToHash.call(_context5.t1, _context5.t2);
478
- kmsId = _context5.t0.concat.call(_context5.t0, _context5.t3);
479
-
480
- case 9:
481
- this.Log("Creating content library");
482
- this.Log("KMS ID: ".concat(kmsId));
483
- _context5.next = 13;
484
- return _regeneratorRuntime.awrap(this.authClient.CreateContentLibrary({
485
- kmsId: kmsId
486
- }));
487
-
488
- case 13:
489
- _ref7 = _context5.sent;
490
- contractAddress = _ref7.contractAddress;
491
-
492
- if (tenantId) {
493
- _context5.next = 19;
494
- break;
495
- }
492
+ if (kmsId) {
493
+ _context5.next = 9;
494
+ break;
495
+ }
496
496
 
497
- _context5.next = 18;
498
- return _regeneratorRuntime.awrap(this.userProfileClient.TenantId());
497
+ _context5.t0 = "ikms";
498
+ _context5.t1 = this.utils;
499
+ _context5.next = 6;
500
+ return this.DefaultKMSAddress();
501
+
502
+ case 6:
503
+ _context5.t2 = _context5.sent;
504
+ _context5.t3 = _context5.t1.AddressToHash.call(_context5.t1, _context5.t2);
505
+ kmsId = _context5.t0.concat.call(_context5.t0, _context5.t3);
506
+
507
+ case 9:
508
+ this.Log("Creating content library");
509
+ this.Log("KMS ID: ".concat(kmsId));
510
+ _context5.next = 13;
511
+ return this.authClient.CreateContentLibrary({
512
+ kmsId: kmsId
513
+ });
499
514
 
500
- case 18:
501
- tenantId = _context5.sent;
515
+ case 13:
516
+ _yield$this$authClien2 = _context5.sent;
517
+ contractAddress = _yield$this$authClien2.contractAddress;
502
518
 
503
- case 19:
504
- if (!tenantId) {
505
- _context5.next = 22;
506
- break;
507
- }
508
-
509
- _context5.next = 22;
510
- return _regeneratorRuntime.awrap(this.CallContractMethod({
511
- contractAddress: contractAddress,
512
- methodName: "putMeta",
513
- methodArgs: ["_tenantId", tenantId]
514
- }));
515
-
516
- case 22:
517
- metadata = _objectSpread({}, metadata, {
518
- name: name,
519
- description: description,
520
- "public": {
519
+ if (tenantId) {
520
+ _context5.next = 19;
521
+ break;
522
+ }
523
+
524
+ _context5.next = 18;
525
+ return this.userProfileClient.TenantId();
526
+
527
+ case 18:
528
+ tenantId = _context5.sent;
529
+
530
+ case 19:
531
+ if (!tenantId) {
532
+ _context5.next = 24;
533
+ break;
534
+ }
535
+
536
+ if (this.utils.ValidHash(tenantId)) {
537
+ _context5.next = 22;
538
+ break;
539
+ }
540
+
541
+ throw Error("Invalid tenant ID: ".concat(tenantId));
542
+
543
+ case 22:
544
+ _context5.next = 24;
545
+ return this.CallContractMethod({
546
+ contractAddress: contractAddress,
547
+ methodName: "putMeta",
548
+ methodArgs: ["_tenantId", tenantId]
549
+ });
550
+
551
+ case 24:
552
+ metadata = _objectSpread(_objectSpread({}, metadata), {}, {
521
553
  name: name,
522
- description: description
554
+ description: description,
555
+ "public": {
556
+ name: name,
557
+ description: description
558
+ }
559
+ });
560
+ libraryId = this.utils.AddressToLibraryId(contractAddress);
561
+ this.Log("Library ID: ".concat(libraryId));
562
+ this.Log("Contract address: ".concat(contractAddress)); // Set library content object type and metadata on automatically created library object
563
+
564
+ objectId = libraryId.replace("ilib", "iq__");
565
+ _context5.next = 31;
566
+ return this.EditContentObject({
567
+ libraryId: libraryId,
568
+ objectId: objectId
569
+ });
570
+
571
+ case 31:
572
+ editResponse = _context5.sent;
573
+ _context5.next = 34;
574
+ return this.ReplaceMetadata({
575
+ libraryId: libraryId,
576
+ objectId: objectId,
577
+ metadata: metadata,
578
+ writeToken: editResponse.write_token
579
+ });
580
+
581
+ case 34:
582
+ _context5.next = 36;
583
+ return this.FinalizeContentObject({
584
+ libraryId: libraryId,
585
+ objectId: objectId,
586
+ writeToken: editResponse.write_token,
587
+ commitMessage: "Create library"
588
+ });
589
+
590
+ case 36:
591
+ if (!image) {
592
+ _context5.next = 39;
593
+ break;
523
594
  }
524
- });
525
- libraryId = this.utils.AddressToLibraryId(contractAddress);
526
- this.Log("Library ID: ".concat(libraryId));
527
- this.Log("Contract address: ".concat(contractAddress)); // Set library content object type and metadata on automatically created library object
528
-
529
- objectId = libraryId.replace("ilib", "iq__");
530
- _context5.next = 29;
531
- return _regeneratorRuntime.awrap(this.EditContentObject({
532
- libraryId: libraryId,
533
- objectId: objectId
534
- }));
535
-
536
- case 29:
537
- editResponse = _context5.sent;
538
- _context5.next = 32;
539
- return _regeneratorRuntime.awrap(this.ReplaceMetadata({
540
- libraryId: libraryId,
541
- objectId: objectId,
542
- metadata: metadata,
543
- writeToken: editResponse.write_token
544
- }));
545
-
546
- case 32:
547
- _context5.next = 34;
548
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
549
- libraryId: libraryId,
550
- objectId: objectId,
551
- writeToken: editResponse.write_token,
552
- commitMessage: "Create library"
553
- }));
554
-
555
- case 34:
556
- if (!image) {
557
- _context5.next = 37;
558
- break;
559
- }
560
-
561
- _context5.next = 37;
562
- return _regeneratorRuntime.awrap(this.SetContentLibraryImage({
563
- libraryId: libraryId,
564
- image: image,
565
- imageName: imageName
566
- }));
567
-
568
- case 37:
569
- this.Log("Library ".concat(libraryId, " created"));
570
- return _context5.abrupt("return", libraryId);
571
-
572
- case 39:
573
- case "end":
574
- return _context5.stop();
595
+
596
+ _context5.next = 39;
597
+ return this.SetContentLibraryImage({
598
+ libraryId: libraryId,
599
+ image: image,
600
+ imageName: imageName
601
+ });
602
+
603
+ case 39:
604
+ this.Log("Library ".concat(libraryId, " created"));
605
+ return _context5.abrupt("return", libraryId);
606
+
607
+ case 41:
608
+ case "end":
609
+ return _context5.stop();
610
+ }
575
611
  }
576
- }
577
- }, null, this);
578
- };
612
+ }, _callee5, this);
613
+ }));
614
+
615
+ return function (_x5) {
616
+ return _ref9.apply(this, arguments);
617
+ };
618
+ }();
579
619
  /**
580
620
  * Set the image associated with this library
581
621
  *
@@ -588,30 +628,36 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
588
628
  */
589
629
 
590
630
 
591
- exports.SetContentLibraryImage = function _callee5(_ref8) {
592
- var libraryId, writeToken, image, imageName, objectId;
593
- return _regeneratorRuntime.async(function _callee5$(_context6) {
594
- while (1) {
595
- switch (_context6.prev = _context6.next) {
596
- case 0:
597
- libraryId = _ref8.libraryId, writeToken = _ref8.writeToken, image = _ref8.image, imageName = _ref8.imageName;
598
- ValidateLibrary(libraryId);
599
- objectId = libraryId.replace("ilib", "iq__");
600
- return _context6.abrupt("return", this.SetContentObjectImage({
601
- libraryId: libraryId,
602
- objectId: objectId,
603
- writeToken: writeToken,
604
- image: image,
605
- imageName: imageName
606
- }));
607
-
608
- case 4:
609
- case "end":
610
- return _context6.stop();
631
+ exports.SetContentLibraryImage = /*#__PURE__*/function () {
632
+ var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref10) {
633
+ var libraryId, writeToken, image, imageName, objectId;
634
+ return _regeneratorRuntime.wrap(function _callee6$(_context6) {
635
+ while (1) {
636
+ switch (_context6.prev = _context6.next) {
637
+ case 0:
638
+ libraryId = _ref10.libraryId, writeToken = _ref10.writeToken, image = _ref10.image, imageName = _ref10.imageName;
639
+ ValidateLibrary(libraryId);
640
+ objectId = libraryId.replace("ilib", "iq__");
641
+ return _context6.abrupt("return", this.SetContentObjectImage({
642
+ libraryId: libraryId,
643
+ objectId: objectId,
644
+ writeToken: writeToken,
645
+ image: image,
646
+ imageName: imageName
647
+ }));
648
+
649
+ case 4:
650
+ case "end":
651
+ return _context6.stop();
652
+ }
611
653
  }
612
- }
613
- }, null, this);
614
- };
654
+ }, _callee6, this);
655
+ }));
656
+
657
+ return function (_x6) {
658
+ return _ref11.apply(this, arguments);
659
+ };
660
+ }();
615
661
  /**
616
662
  * Set the image associated with this object
617
663
  *
@@ -626,70 +672,76 @@ exports.SetContentLibraryImage = function _callee5(_ref8) {
626
672
  */
627
673
 
628
674
 
629
- exports.SetContentObjectImage = function _callee6(_ref9) {
630
- var libraryId, objectId, writeToken, image, imageName, _ref9$imagePath, imagePath, type, mimeType;
631
-
632
- return _regeneratorRuntime.async(function _callee6$(_context7) {
633
- while (1) {
634
- switch (_context7.prev = _context7.next) {
635
- case 0:
636
- libraryId = _ref9.libraryId, objectId = _ref9.objectId, writeToken = _ref9.writeToken, image = _ref9.image, imageName = _ref9.imageName, _ref9$imagePath = _ref9.imagePath, imagePath = _ref9$imagePath === void 0 ? "public/display_image" : _ref9$imagePath;
637
- ValidateParameters({
638
- libraryId: libraryId,
639
- objectId: objectId
640
- });
641
- ValidateWriteToken(writeToken);
642
- ValidatePresence("image", image);
643
- imageName = imageName || "display_image";
644
-
645
- if (!(_typeof(image) === "object")) {
646
- _context7.next = 9;
647
- break;
648
- }
649
-
650
- _context7.next = 8;
651
- return _regeneratorRuntime.awrap(new Response(image).arrayBuffer());
652
-
653
- case 8:
654
- image = _context7.sent;
655
-
656
- case 9:
657
- // Determine image type
658
- type = ImageType(image);
659
- mimeType = ["jpg", "jpeg", "png", "gif", "webp"].includes(type.ext) ? type.mime : "image/*";
660
- _context7.next = 13;
661
- return _regeneratorRuntime.awrap(this.UploadFiles({
662
- libraryId: libraryId,
663
- objectId: objectId,
664
- writeToken: writeToken,
665
- encrypted: false,
666
- fileInfo: [{
667
- path: imageName,
668
- mime_type: mimeType,
669
- size: image.size || image.length || image.byteLength,
670
- data: image
671
- }]
672
- }));
673
-
674
- case 13:
675
- _context7.next = 15;
676
- return _regeneratorRuntime.awrap(this.ReplaceMetadata({
677
- libraryId: libraryId,
678
- objectId: objectId,
679
- writeToken: writeToken,
680
- metadataSubtree: imagePath,
681
- metadata: {
682
- "/": "./files/".concat(imageName)
675
+ exports.SetContentObjectImage = /*#__PURE__*/function () {
676
+ var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref12) {
677
+ var libraryId, objectId, writeToken, image, imageName, _ref12$imagePath, imagePath, type, mimeType;
678
+
679
+ return _regeneratorRuntime.wrap(function _callee7$(_context7) {
680
+ while (1) {
681
+ switch (_context7.prev = _context7.next) {
682
+ case 0:
683
+ libraryId = _ref12.libraryId, objectId = _ref12.objectId, writeToken = _ref12.writeToken, image = _ref12.image, imageName = _ref12.imageName, _ref12$imagePath = _ref12.imagePath, imagePath = _ref12$imagePath === void 0 ? "public/display_image" : _ref12$imagePath;
684
+ ValidateParameters({
685
+ libraryId: libraryId,
686
+ objectId: objectId
687
+ });
688
+ ValidateWriteToken(writeToken);
689
+ ValidatePresence("image", image);
690
+ imageName = imageName || "display_image";
691
+
692
+ if (!(_typeof(image) === "object")) {
693
+ _context7.next = 9;
694
+ break;
683
695
  }
684
- }));
685
696
 
686
- case 15:
687
- case "end":
688
- return _context7.stop();
697
+ _context7.next = 8;
698
+ return new Response(image).arrayBuffer();
699
+
700
+ case 8:
701
+ image = _context7.sent;
702
+
703
+ case 9:
704
+ // Determine image type
705
+ type = ImageType(image);
706
+ mimeType = ["jpg", "jpeg", "png", "gif", "webp"].includes(type.ext) ? type.mime : "image/*";
707
+ _context7.next = 13;
708
+ return this.UploadFiles({
709
+ libraryId: libraryId,
710
+ objectId: objectId,
711
+ writeToken: writeToken,
712
+ encrypted: false,
713
+ fileInfo: [{
714
+ path: imageName,
715
+ mime_type: mimeType,
716
+ size: image.size || image.length || image.byteLength,
717
+ data: image
718
+ }]
719
+ });
720
+
721
+ case 13:
722
+ _context7.next = 15;
723
+ return this.ReplaceMetadata({
724
+ libraryId: libraryId,
725
+ objectId: objectId,
726
+ writeToken: writeToken,
727
+ metadataSubtree: imagePath,
728
+ metadata: {
729
+ "/": "./files/".concat(imageName)
730
+ }
731
+ });
732
+
733
+ case 15:
734
+ case "end":
735
+ return _context7.stop();
736
+ }
689
737
  }
690
- }
691
- }, null, this);
692
- };
738
+ }, _callee7, this);
739
+ }));
740
+
741
+ return function (_x7) {
742
+ return _ref13.apply(this, arguments);
743
+ };
744
+ }();
693
745
  /**
694
746
  * NOT YET SUPPORTED - Delete the specified content library
695
747
  *
@@ -700,39 +752,45 @@ exports.SetContentObjectImage = function _callee6(_ref9) {
700
752
  */
701
753
 
702
754
 
703
- exports.DeleteContentLibrary = function _callee7(_ref10) {
704
- var libraryId, path, authorizationHeader;
705
- return _regeneratorRuntime.async(function _callee7$(_context8) {
706
- while (1) {
707
- switch (_context8.prev = _context8.next) {
708
- case 0:
709
- libraryId = _ref10.libraryId;
710
- throw Error("Not supported");
711
-
712
- case 6:
713
- authorizationHeader = _context8.sent;
714
- _context8.next = 9;
715
- return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
716
- contractAddress: this.utils.HashToAddress(libraryId),
717
- methodName: "kill",
718
- methodArgs: []
719
- }));
720
-
721
- case 9:
722
- _context8.next = 11;
723
- return _regeneratorRuntime.awrap(this.HttpClient.Request({
724
- headers: authorizationHeader,
725
- method: "DELETE",
726
- path: path
727
- }));
728
-
729
- case 11:
730
- case "end":
731
- return _context8.stop();
755
+ exports.DeleteContentLibrary = /*#__PURE__*/function () {
756
+ var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref14) {
757
+ var libraryId, path, authorizationHeader;
758
+ return _regeneratorRuntime.wrap(function _callee8$(_context8) {
759
+ while (1) {
760
+ switch (_context8.prev = _context8.next) {
761
+ case 0:
762
+ libraryId = _ref14.libraryId;
763
+ throw Error("Not supported");
764
+
765
+ case 6:
766
+ authorizationHeader = _context8.sent;
767
+ _context8.next = 9;
768
+ return this.CallContractMethodAndWait({
769
+ contractAddress: this.utils.HashToAddress(libraryId),
770
+ methodName: "kill",
771
+ methodArgs: []
772
+ });
773
+
774
+ case 9:
775
+ _context8.next = 11;
776
+ return this.HttpClient.Request({
777
+ headers: authorizationHeader,
778
+ method: "DELETE",
779
+ path: path
780
+ });
781
+
782
+ case 11:
783
+ case "end":
784
+ return _context8.stop();
785
+ }
732
786
  }
733
- }
734
- }, null, this);
735
- };
787
+ }, _callee8, this);
788
+ }));
789
+
790
+ return function (_x8) {
791
+ return _ref15.apply(this, arguments);
792
+ };
793
+ }();
736
794
  /* Library Content Type Management */
737
795
 
738
796
  /**
@@ -751,56 +809,62 @@ exports.DeleteContentLibrary = function _callee7(_ref10) {
751
809
  */
752
810
 
753
811
 
754
- exports.AddLibraryContentType = function _callee8(_ref11) {
755
- var libraryId, typeId, typeName, typeHash, customContractAddress, type, typeAddress, event;
756
- return _regeneratorRuntime.async(function _callee8$(_context9) {
757
- while (1) {
758
- switch (_context9.prev = _context9.next) {
759
- case 0:
760
- libraryId = _ref11.libraryId, typeId = _ref11.typeId, typeName = _ref11.typeName, typeHash = _ref11.typeHash, customContractAddress = _ref11.customContractAddress;
761
- ValidateLibrary(libraryId);
762
- this.Log("Adding library content type to ".concat(libraryId, ": ").concat(typeId || typeHash || typeName));
812
+ exports.AddLibraryContentType = /*#__PURE__*/function () {
813
+ var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref16) {
814
+ var libraryId, typeId, typeName, typeHash, customContractAddress, type, typeAddress, event;
815
+ return _regeneratorRuntime.wrap(function _callee9$(_context9) {
816
+ while (1) {
817
+ switch (_context9.prev = _context9.next) {
818
+ case 0:
819
+ libraryId = _ref16.libraryId, typeId = _ref16.typeId, typeName = _ref16.typeName, typeHash = _ref16.typeHash, customContractAddress = _ref16.customContractAddress;
820
+ ValidateLibrary(libraryId);
821
+ this.Log("Adding library content type to ".concat(libraryId, ": ").concat(typeId || typeHash || typeName));
763
822
 
764
- if (typeHash) {
765
- typeId = this.utils.DecodeVersionHash(typeHash).objectId;
766
- }
823
+ if (typeHash) {
824
+ typeId = this.utils.DecodeVersionHash(typeHash).objectId;
825
+ }
767
826
 
768
- if (typeId) {
769
- _context9.next = 9;
770
- break;
771
- }
772
-
773
- _context9.next = 7;
774
- return _regeneratorRuntime.awrap(this.ContentType({
775
- name: typeName
776
- }));
777
-
778
- case 7:
779
- type = _context9.sent;
780
- typeId = type.id;
781
-
782
- case 9:
783
- this.Log("Type ID: ".concat(typeId));
784
- typeAddress = this.utils.HashToAddress(typeId);
785
- customContractAddress = customContractAddress || this.utils.nullAddress;
786
- _context9.next = 14;
787
- return _regeneratorRuntime.awrap(this.ethClient.CallContractMethodAndWait({
788
- contractAddress: this.utils.HashToAddress(libraryId),
789
- methodName: "addContentType",
790
- methodArgs: [typeAddress, customContractAddress]
791
- }));
792
-
793
- case 14:
794
- event = _context9.sent;
795
- return _context9.abrupt("return", event.transactionHash);
796
-
797
- case 16:
798
- case "end":
799
- return _context9.stop();
827
+ if (typeId) {
828
+ _context9.next = 9;
829
+ break;
830
+ }
831
+
832
+ _context9.next = 7;
833
+ return this.ContentType({
834
+ name: typeName
835
+ });
836
+
837
+ case 7:
838
+ type = _context9.sent;
839
+ typeId = type.id;
840
+
841
+ case 9:
842
+ this.Log("Type ID: ".concat(typeId));
843
+ typeAddress = this.utils.HashToAddress(typeId);
844
+ customContractAddress = customContractAddress || this.utils.nullAddress;
845
+ _context9.next = 14;
846
+ return this.ethClient.CallContractMethodAndWait({
847
+ contractAddress: this.utils.HashToAddress(libraryId),
848
+ methodName: "addContentType",
849
+ methodArgs: [typeAddress, customContractAddress]
850
+ });
851
+
852
+ case 14:
853
+ event = _context9.sent;
854
+ return _context9.abrupt("return", event.transactionHash);
855
+
856
+ case 16:
857
+ case "end":
858
+ return _context9.stop();
859
+ }
800
860
  }
801
- }
802
- }, null, this);
803
- };
861
+ }, _callee9, this);
862
+ }));
863
+
864
+ return function (_x9) {
865
+ return _ref17.apply(this, arguments);
866
+ };
867
+ }();
804
868
  /**
805
869
  * Remove the specified content type from a library
806
870
  *
@@ -815,55 +879,61 @@ exports.AddLibraryContentType = function _callee8(_ref11) {
815
879
  */
816
880
 
817
881
 
818
- exports.RemoveLibraryContentType = function _callee9(_ref12) {
819
- var libraryId, typeId, typeName, typeHash, type, typeAddress, event;
820
- return _regeneratorRuntime.async(function _callee9$(_context10) {
821
- while (1) {
822
- switch (_context10.prev = _context10.next) {
823
- case 0:
824
- libraryId = _ref12.libraryId, typeId = _ref12.typeId, typeName = _ref12.typeName, typeHash = _ref12.typeHash;
825
- ValidateLibrary(libraryId);
826
- this.Log("Removing library content type from ".concat(libraryId, ": ").concat(typeId || typeHash || typeName));
882
+ exports.RemoveLibraryContentType = /*#__PURE__*/function () {
883
+ var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref18) {
884
+ var libraryId, typeId, typeName, typeHash, type, typeAddress, event;
885
+ return _regeneratorRuntime.wrap(function _callee10$(_context10) {
886
+ while (1) {
887
+ switch (_context10.prev = _context10.next) {
888
+ case 0:
889
+ libraryId = _ref18.libraryId, typeId = _ref18.typeId, typeName = _ref18.typeName, typeHash = _ref18.typeHash;
890
+ ValidateLibrary(libraryId);
891
+ this.Log("Removing library content type from ".concat(libraryId, ": ").concat(typeId || typeHash || typeName));
827
892
 
828
- if (typeHash) {
829
- typeId = this.utils.DecodeVersionHash(typeHash).objectId;
830
- }
893
+ if (typeHash) {
894
+ typeId = this.utils.DecodeVersionHash(typeHash).objectId;
895
+ }
831
896
 
832
- if (typeId) {
833
- _context10.next = 9;
834
- break;
835
- }
836
-
837
- _context10.next = 7;
838
- return _regeneratorRuntime.awrap(this.ContentType({
839
- name: typeName
840
- }));
841
-
842
- case 7:
843
- type = _context10.sent;
844
- typeId = type.id;
845
-
846
- case 9:
847
- this.Log("Type ID: ".concat(typeId));
848
- typeAddress = this.utils.HashToAddress(typeId);
849
- _context10.next = 13;
850
- return _regeneratorRuntime.awrap(this.ethClient.CallContractMethodAndWait({
851
- contractAddress: this.utils.HashToAddress(libraryId),
852
- methodName: "removeContentType",
853
- methodArgs: [typeAddress]
854
- }));
855
-
856
- case 13:
857
- event = _context10.sent;
858
- return _context10.abrupt("return", event.transactionHash);
859
-
860
- case 15:
861
- case "end":
862
- return _context10.stop();
897
+ if (typeId) {
898
+ _context10.next = 9;
899
+ break;
900
+ }
901
+
902
+ _context10.next = 7;
903
+ return this.ContentType({
904
+ name: typeName
905
+ });
906
+
907
+ case 7:
908
+ type = _context10.sent;
909
+ typeId = type.id;
910
+
911
+ case 9:
912
+ this.Log("Type ID: ".concat(typeId));
913
+ typeAddress = this.utils.HashToAddress(typeId);
914
+ _context10.next = 13;
915
+ return this.ethClient.CallContractMethodAndWait({
916
+ contractAddress: this.utils.HashToAddress(libraryId),
917
+ methodName: "removeContentType",
918
+ methodArgs: [typeAddress]
919
+ });
920
+
921
+ case 13:
922
+ event = _context10.sent;
923
+ return _context10.abrupt("return", event.transactionHash);
924
+
925
+ case 15:
926
+ case "end":
927
+ return _context10.stop();
928
+ }
863
929
  }
864
- }
865
- }, null, this);
866
- };
930
+ }, _callee10, this);
931
+ }));
932
+
933
+ return function (_x10) {
934
+ return _ref19.apply(this, arguments);
935
+ };
936
+ }();
867
937
  /* Content object creation, modification, deletion */
868
938
 
869
939
  /**
@@ -886,195 +956,199 @@ exports.RemoveLibraryContentType = function _callee9(_ref12) {
886
956
  */
887
957
 
888
958
 
889
- exports.CreateContentObject = function _callee10(_ref13) {
890
- var libraryId, objectId, _ref13$options, options, typeId, type, currentAccountAddress, canContribute, _ref14, contractAddress, path, createResponse;
959
+ exports.CreateContentObject = /*#__PURE__*/function () {
960
+ var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref20) {
961
+ var libraryId, objectId, _ref20$options, options, typeId, type, currentAccountAddress, canContribute, _yield$this$authClien3, contractAddress, path, createResponse;
891
962
 
892
- return _regeneratorRuntime.async(function _callee10$(_context11) {
893
- while (1) {
894
- switch (_context11.prev = _context11.next) {
895
- case 0:
896
- libraryId = _ref13.libraryId, objectId = _ref13.objectId, _ref13$options = _ref13.options, options = _ref13$options === void 0 ? {} : _ref13$options;
897
- ValidateLibrary(libraryId);
963
+ return _regeneratorRuntime.wrap(function _callee11$(_context11) {
964
+ while (1) {
965
+ switch (_context11.prev = _context11.next) {
966
+ case 0:
967
+ libraryId = _ref20.libraryId, objectId = _ref20.objectId, _ref20$options = _ref20.options, options = _ref20$options === void 0 ? {} : _ref20$options;
968
+ ValidateLibrary(libraryId);
898
969
 
899
- if (objectId) {
900
- ValidateObject(objectId);
901
- }
970
+ if (objectId) {
971
+ ValidateObject(objectId);
972
+ }
902
973
 
903
- this.Log("Creating content object: ".concat(libraryId, " ").concat(objectId || "")); // Look up content type, if specified
974
+ this.Log("Creating content object: ".concat(libraryId, " ").concat(objectId || "")); // Look up content type, if specified
904
975
 
905
- if (!options.type) {
906
- _context11.next = 26;
907
- break;
908
- }
976
+ if (!options.type) {
977
+ _context11.next = 26;
978
+ break;
979
+ }
909
980
 
910
- this.Log("Type specified: ".concat(options.type));
911
- type = options.type;
981
+ this.Log("Type specified: ".concat(options.type));
982
+ type = options.type;
912
983
 
913
- if (!type.startsWith("hq__")) {
914
- _context11.next = 13;
984
+ if (!type.startsWith("hq__")) {
985
+ _context11.next = 13;
986
+ break;
987
+ }
988
+
989
+ _context11.next = 10;
990
+ return this.ContentType({
991
+ versionHash: type
992
+ });
993
+
994
+ case 10:
995
+ type = _context11.sent;
996
+ _context11.next = 22;
915
997
  break;
916
- }
917
998
 
918
- _context11.next = 10;
919
- return _regeneratorRuntime.awrap(this.ContentType({
920
- versionHash: type
921
- }));
999
+ case 13:
1000
+ if (!type.startsWith("iq__")) {
1001
+ _context11.next = 19;
1002
+ break;
1003
+ }
922
1004
 
923
- case 10:
924
- type = _context11.sent;
925
- _context11.next = 22;
926
- break;
1005
+ _context11.next = 16;
1006
+ return this.ContentType({
1007
+ typeId: type
1008
+ });
927
1009
 
928
- case 13:
929
- if (!type.startsWith("iq__")) {
930
- _context11.next = 19;
931
- break;
932
- }
933
-
934
- _context11.next = 16;
935
- return _regeneratorRuntime.awrap(this.ContentType({
936
- typeId: type
937
- }));
938
-
939
- case 16:
940
- type = _context11.sent;
941
- _context11.next = 22;
942
- break;
943
-
944
- case 19:
945
- _context11.next = 21;
946
- return _regeneratorRuntime.awrap(this.ContentType({
947
- name: type
948
- }));
949
-
950
- case 21:
951
- type = _context11.sent;
952
-
953
- case 22:
954
- if (type) {
955
- _context11.next = 24;
1010
+ case 16:
1011
+ type = _context11.sent;
1012
+ _context11.next = 22;
956
1013
  break;
957
- }
958
1014
 
959
- throw Error("Unable to find content type '".concat(options.type, "'"));
1015
+ case 19:
1016
+ _context11.next = 21;
1017
+ return this.ContentType({
1018
+ name: type
1019
+ });
960
1020
 
961
- case 24:
962
- typeId = type.id;
963
- options.type = type.hash;
1021
+ case 21:
1022
+ type = _context11.sent;
964
1023
 
965
- case 26:
966
- if (objectId) {
967
- _context11.next = 44;
968
- break;
969
- }
1024
+ case 22:
1025
+ if (type) {
1026
+ _context11.next = 24;
1027
+ break;
1028
+ }
1029
+
1030
+ throw Error("Unable to find content type '".concat(options.type, "'"));
1031
+
1032
+ case 24:
1033
+ typeId = type.id;
1034
+ options.type = type.hash;
1035
+
1036
+ case 26:
1037
+ if (objectId) {
1038
+ _context11.next = 44;
1039
+ break;
1040
+ }
1041
+
1042
+ _context11.next = 29;
1043
+ return this.CurrentAccountAddress();
1044
+
1045
+ case 29:
1046
+ currentAccountAddress = _context11.sent;
1047
+ _context11.next = 32;
1048
+ return this.CallContractMethod({
1049
+ contractAddress: this.utils.HashToAddress(libraryId),
1050
+ methodName: "canContribute",
1051
+ methodArgs: [currentAccountAddress]
1052
+ });
970
1053
 
971
- _context11.next = 29;
972
- return _regeneratorRuntime.awrap(this.CurrentAccountAddress());
1054
+ case 32:
1055
+ canContribute = _context11.sent;
973
1056
 
974
- case 29:
975
- currentAccountAddress = _context11.sent;
976
- _context11.next = 32;
977
- return _regeneratorRuntime.awrap(this.CallContractMethod({
978
- contractAddress: this.utils.HashToAddress(libraryId),
979
- methodName: "canContribute",
980
- methodArgs: [currentAccountAddress]
981
- }));
1057
+ if (canContribute) {
1058
+ _context11.next = 35;
1059
+ break;
1060
+ }
1061
+
1062
+ throw Error("Current user does not have permission to create content in library ".concat(libraryId));
982
1063
 
983
- case 32:
984
- canContribute = _context11.sent;
1064
+ case 35:
1065
+ this.Log("Deploying contract...");
1066
+ _context11.next = 38;
1067
+ return this.authClient.CreateContentObject({
1068
+ libraryId: libraryId,
1069
+ typeId: typeId
1070
+ });
985
1071
 
986
- if (canContribute) {
987
- _context11.next = 35;
1072
+ case 38:
1073
+ _yield$this$authClien3 = _context11.sent;
1074
+ contractAddress = _yield$this$authClien3.contractAddress;
1075
+ objectId = this.utils.AddressToObjectId(contractAddress);
1076
+ this.Log("Contract deployed: ".concat(contractAddress, " ").concat(objectId));
1077
+ _context11.next = 51;
988
1078
  break;
989
- }
990
-
991
- throw Error("Current user does not have permission to create content in library ".concat(libraryId));
992
-
993
- case 35:
994
- this.Log("Deploying contract...");
995
- _context11.next = 38;
996
- return _regeneratorRuntime.awrap(this.authClient.CreateContentObject({
997
- libraryId: libraryId,
998
- typeId: typeId
999
- }));
1000
-
1001
- case 38:
1002
- _ref14 = _context11.sent;
1003
- contractAddress = _ref14.contractAddress;
1004
- objectId = this.utils.AddressToObjectId(contractAddress);
1005
- this.Log("Contract deployed: ".concat(contractAddress, " ").concat(objectId));
1006
- _context11.next = 51;
1007
- break;
1008
-
1009
- case 44:
1010
- _context11.t0 = this;
1011
- _context11.t1 = "Contract already deployed for contract type: ";
1012
- _context11.next = 48;
1013
- return _regeneratorRuntime.awrap(this.AccessType({
1014
- id: objectId
1015
- }));
1016
-
1017
- case 48:
1018
- _context11.t2 = _context11.sent;
1019
- _context11.t3 = _context11.t1.concat.call(_context11.t1, _context11.t2);
1020
-
1021
- _context11.t0.Log.call(_context11.t0, _context11.t3);
1022
-
1023
- case 51:
1024
- if (!options.visibility) {
1079
+
1080
+ case 44:
1081
+ _context11.t0 = this;
1082
+ _context11.t1 = "Contract already deployed for contract type: ";
1083
+ _context11.next = 48;
1084
+ return this.AccessType({
1085
+ id: objectId
1086
+ });
1087
+
1088
+ case 48:
1089
+ _context11.t2 = _context11.sent;
1090
+ _context11.t3 = _context11.t1.concat.call(_context11.t1, _context11.t2);
1091
+
1092
+ _context11.t0.Log.call(_context11.t0, _context11.t3);
1093
+
1094
+ case 51:
1095
+ if (!options.visibility) {
1096
+ _context11.next = 55;
1097
+ break;
1098
+ }
1099
+
1100
+ this.Log("Setting visibility to ".concat(options.visibility));
1025
1101
  _context11.next = 55;
1026
- break;
1027
- }
1028
-
1029
- this.Log("Setting visibility to ".concat(options.visibility));
1030
- _context11.next = 55;
1031
- return _regeneratorRuntime.awrap(this.SetVisibility({
1032
- id: objectId,
1033
- visibility: options.visibility
1034
- }));
1035
-
1036
- case 55:
1037
- path = UrlJoin("qid", objectId);
1038
- _context11.t4 = _regeneratorRuntime;
1039
- _context11.t5 = this.utils;
1040
- _context11.t6 = this.HttpClient;
1041
- _context11.next = 61;
1042
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
1043
- libraryId: libraryId,
1044
- objectId: objectId,
1045
- update: true
1046
- }));
1047
-
1048
- case 61:
1049
- _context11.t7 = _context11.sent;
1050
- _context11.t8 = path;
1051
- _context11.t9 = options;
1052
- _context11.t10 = {
1053
- headers: _context11.t7,
1054
- method: "POST",
1055
- path: _context11.t8,
1056
- body: _context11.t9
1057
- };
1058
- _context11.t11 = _context11.t6.Request.call(_context11.t6, _context11.t10);
1059
- _context11.t12 = _context11.t5.ResponseToJson.call(_context11.t5, _context11.t11);
1060
- _context11.next = 69;
1061
- return _context11.t4.awrap.call(_context11.t4, _context11.t12);
1062
-
1063
- case 69:
1064
- createResponse = _context11.sent;
1065
- // Record the node used in creating this write token
1066
- this.HttpClient.RecordWriteToken(createResponse.write_token);
1067
- createResponse.writeToken = createResponse.write_token;
1068
- createResponse.objectId = createResponse.id;
1069
- return _context11.abrupt("return", createResponse);
1070
-
1071
- case 74:
1072
- case "end":
1073
- return _context11.stop();
1102
+ return this.SetVisibility({
1103
+ id: objectId,
1104
+ visibility: options.visibility
1105
+ });
1106
+
1107
+ case 55:
1108
+ path = UrlJoin("qid", objectId);
1109
+ _context11.t4 = this.utils;
1110
+ _context11.t5 = this.HttpClient;
1111
+ _context11.next = 60;
1112
+ return this.authClient.AuthorizationHeader({
1113
+ libraryId: libraryId,
1114
+ objectId: objectId,
1115
+ update: true
1116
+ });
1117
+
1118
+ case 60:
1119
+ _context11.t6 = _context11.sent;
1120
+ _context11.t7 = path;
1121
+ _context11.t8 = options;
1122
+ _context11.t9 = {
1123
+ headers: _context11.t6,
1124
+ method: "POST",
1125
+ path: _context11.t7,
1126
+ body: _context11.t8
1127
+ };
1128
+ _context11.t10 = _context11.t5.Request.call(_context11.t5, _context11.t9);
1129
+ _context11.next = 67;
1130
+ return _context11.t4.ResponseToJson.call(_context11.t4, _context11.t10);
1131
+
1132
+ case 67:
1133
+ createResponse = _context11.sent;
1134
+ // Record the node used in creating this write token
1135
+ this.HttpClient.RecordWriteToken(createResponse.write_token);
1136
+ createResponse.writeToken = createResponse.write_token;
1137
+ createResponse.objectId = createResponse.id;
1138
+ return _context11.abrupt("return", createResponse);
1139
+
1140
+ case 72:
1141
+ case "end":
1142
+ return _context11.stop();
1143
+ }
1074
1144
  }
1075
- }
1076
- }, null, this);
1077
- };
1145
+ }, _callee11, this);
1146
+ }));
1147
+
1148
+ return function (_x11) {
1149
+ return _ref21.apply(this, arguments);
1150
+ };
1151
+ }();
1078
1152
  /**
1079
1153
  * Create a new content object draft from an existing content object version.
1080
1154
  *
@@ -1095,156 +1169,168 @@ exports.CreateContentObject = function _callee10(_ref13) {
1095
1169
  */
1096
1170
 
1097
1171
 
1098
- exports.CopyContentObject = function _callee12(_ref15) {
1099
- var _this2 = this;
1100
-
1101
- var libraryId, originalVersionHash, _ref15$options, options, _ref16, objectId, writeToken, originalObjectId, metadata, permission, userCapKey, isOwner, userConkKey;
1102
-
1103
- return _regeneratorRuntime.async(function _callee12$(_context13) {
1104
- while (1) {
1105
- switch (_context13.prev = _context13.next) {
1106
- case 0:
1107
- libraryId = _ref15.libraryId, originalVersionHash = _ref15.originalVersionHash, _ref15$options = _ref15.options, options = _ref15$options === void 0 ? {} : _ref15$options;
1108
- ValidateLibrary(libraryId);
1109
- ValidateVersion(originalVersionHash);
1110
- options.copy_from = originalVersionHash;
1111
- _context13.next = 6;
1112
- return _regeneratorRuntime.awrap(this.CreateContentObject({
1113
- libraryId: libraryId,
1114
- options: options
1115
- }));
1116
-
1117
- case 6:
1118
- _ref16 = _context13.sent;
1119
- objectId = _ref16.objectId;
1120
- writeToken = _ref16.writeToken;
1121
- originalObjectId = this.utils.DecodeVersionHash(originalVersionHash).objectId;
1122
- _context13.next = 12;
1123
- return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
1124
- versionHash: originalVersionHash
1125
- }));
1126
-
1127
- case 12:
1128
- metadata = _context13.sent;
1129
- _context13.next = 15;
1130
- return _regeneratorRuntime.awrap(this.Permission({
1131
- objectId: originalObjectId
1132
- }));
1133
-
1134
- case 15:
1135
- permission = _context13.sent;
1136
- // User CAP
1137
- userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
1138
-
1139
- if (!metadata[userCapKey]) {
1140
- _context13.next = 40;
1141
- break;
1142
- }
1172
+ exports.CopyContentObject = /*#__PURE__*/function () {
1173
+ var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref22) {
1174
+ var _this2 = this;
1175
+
1176
+ var libraryId, originalVersionHash, _ref22$options, options, _yield$this$CreateCon, objectId, writeToken, originalObjectId, metadata, permission, userCapKey, isOwner, userConkKey;
1177
+
1178
+ return _regeneratorRuntime.wrap(function _callee13$(_context13) {
1179
+ while (1) {
1180
+ switch (_context13.prev = _context13.next) {
1181
+ case 0:
1182
+ libraryId = _ref22.libraryId, originalVersionHash = _ref22.originalVersionHash, _ref22$options = _ref22.options, options = _ref22$options === void 0 ? {} : _ref22$options;
1183
+ ValidateLibrary(libraryId);
1184
+ ValidateVersion(originalVersionHash);
1185
+ options.copy_from = originalVersionHash;
1186
+ _context13.next = 6;
1187
+ return this.CreateContentObject({
1188
+ libraryId: libraryId,
1189
+ options: options
1190
+ });
1191
+
1192
+ case 6:
1193
+ _yield$this$CreateCon = _context13.sent;
1194
+ objectId = _yield$this$CreateCon.objectId;
1195
+ writeToken = _yield$this$CreateCon.writeToken;
1196
+ originalObjectId = this.utils.DecodeVersionHash(originalVersionHash).objectId;
1197
+ _context13.next = 12;
1198
+ return this.ContentObjectMetadata({
1199
+ versionHash: originalVersionHash
1200
+ });
1143
1201
 
1144
- _context13.t0 = this.utils;
1145
- _context13.t1 = this.signer.address;
1146
- _context13.next = 22;
1147
- return _regeneratorRuntime.awrap(this.ContentObjectOwner({
1148
- objectId: originalObjectId
1149
- }));
1202
+ case 12:
1203
+ metadata = _context13.sent;
1204
+ _context13.next = 15;
1205
+ return this.Permission({
1206
+ objectId: originalObjectId
1207
+ });
1150
1208
 
1151
- case 22:
1152
- _context13.t2 = _context13.sent;
1153
- isOwner = _context13.t0.EqualAddress.call(_context13.t0, _context13.t1, _context13.t2);
1209
+ case 15:
1210
+ permission = _context13.sent;
1211
+ // User CAP
1212
+ userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
1154
1213
 
1155
- if (isOwner) {
1156
- _context13.next = 26;
1157
- break;
1158
- }
1159
-
1160
- throw Error("Current user is not owner of object ".concat(metadata));
1161
-
1162
- case 26:
1163
- _context13.next = 28;
1164
- return _regeneratorRuntime.awrap(this.Crypto.DecryptCap(metadata[userCapKey], this.signer.signingKey.privateKey));
1165
-
1166
- case 28:
1167
- userConkKey = _context13.sent;
1168
- userConkKey.qid = objectId;
1169
- _context13.t3 = this;
1170
- _context13.t4 = libraryId;
1171
- _context13.t5 = objectId;
1172
- _context13.t6 = writeToken;
1173
- _context13.t7 = userCapKey;
1174
- _context13.next = 37;
1175
- return _regeneratorRuntime.awrap(this.Crypto.EncryptConk(userConkKey, this.signer.signingKey.publicKey));
1176
-
1177
- case 37:
1178
- _context13.t8 = _context13.sent;
1179
- _context13.t9 = {
1180
- libraryId: _context13.t4,
1181
- objectId: _context13.t5,
1182
- writeToken: _context13.t6,
1183
- metadataSubtree: _context13.t7,
1184
- metadata: _context13.t8
1185
- };
1186
-
1187
- _context13.t3.ReplaceMetadata.call(_context13.t3, _context13.t9);
1188
-
1189
- case 40:
1190
- _context13.next = 42;
1191
- return _regeneratorRuntime.awrap(Promise.all(Object.keys(metadata).filter(function (key) {
1192
- return key.startsWith("eluv.caps.ikms");
1193
- }).map(function _callee11(kmsCapKey) {
1194
- return _regeneratorRuntime.async(function _callee11$(_context12) {
1195
- while (1) {
1196
- switch (_context12.prev = _context12.next) {
1197
- case 0:
1198
- _context12.next = 2;
1199
- return _regeneratorRuntime.awrap(_this2.DeleteMetadata({
1200
- libraryId: libraryId,
1201
- objectId: objectId,
1202
- writeToken: writeToken,
1203
- metadataSubtree: kmsCapKey
1204
- }));
1205
-
1206
- case 2:
1207
- return _context12.abrupt("return", _context12.sent);
1208
-
1209
- case 3:
1210
- case "end":
1211
- return _context12.stop();
1212
- }
1213
- }
1214
+ if (!metadata[userCapKey]) {
1215
+ _context13.next = 40;
1216
+ break;
1217
+ }
1218
+
1219
+ _context13.t0 = this.utils;
1220
+ _context13.t1 = this.signer.address;
1221
+ _context13.next = 22;
1222
+ return this.ContentObjectOwner({
1223
+ objectId: originalObjectId
1214
1224
  });
1215
- })));
1216
1225
 
1217
- case 42:
1218
- if (!(permission !== "owner")) {
1226
+ case 22:
1227
+ _context13.t2 = _context13.sent;
1228
+ isOwner = _context13.t0.EqualAddress.call(_context13.t0, _context13.t1, _context13.t2);
1229
+
1230
+ if (isOwner) {
1231
+ _context13.next = 26;
1232
+ break;
1233
+ }
1234
+
1235
+ throw Error("Current user is not owner of object ".concat(metadata));
1236
+
1237
+ case 26:
1238
+ _context13.next = 28;
1239
+ return this.Crypto.DecryptCap(metadata[userCapKey], this.signer.signingKey.privateKey);
1240
+
1241
+ case 28:
1242
+ userConkKey = _context13.sent;
1243
+ userConkKey.qid = objectId;
1244
+ _context13.t3 = this;
1245
+ _context13.t4 = libraryId;
1246
+ _context13.t5 = objectId;
1247
+ _context13.t6 = writeToken;
1248
+ _context13.t7 = userCapKey;
1249
+ _context13.next = 37;
1250
+ return this.Crypto.EncryptConk(userConkKey, this.signer.signingKey.publicKey);
1251
+
1252
+ case 37:
1253
+ _context13.t8 = _context13.sent;
1254
+ _context13.t9 = {
1255
+ libraryId: _context13.t4,
1256
+ objectId: _context13.t5,
1257
+ writeToken: _context13.t6,
1258
+ metadataSubtree: _context13.t7,
1259
+ metadata: _context13.t8
1260
+ };
1261
+
1262
+ _context13.t3.ReplaceMetadata.call(_context13.t3, _context13.t9);
1263
+
1264
+ case 40:
1265
+ _context13.next = 42;
1266
+ return Promise.all(Object.keys(metadata).filter(function (key) {
1267
+ return key.startsWith("eluv.caps.ikms");
1268
+ }).map( /*#__PURE__*/function () {
1269
+ var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(kmsCapKey) {
1270
+ return _regeneratorRuntime.wrap(function _callee12$(_context12) {
1271
+ while (1) {
1272
+ switch (_context12.prev = _context12.next) {
1273
+ case 0:
1274
+ _context12.next = 2;
1275
+ return _this2.DeleteMetadata({
1276
+ libraryId: libraryId,
1277
+ objectId: objectId,
1278
+ writeToken: writeToken,
1279
+ metadataSubtree: kmsCapKey
1280
+ });
1281
+
1282
+ case 2:
1283
+ return _context12.abrupt("return", _context12.sent);
1284
+
1285
+ case 3:
1286
+ case "end":
1287
+ return _context12.stop();
1288
+ }
1289
+ }
1290
+ }, _callee12);
1291
+ }));
1292
+
1293
+ return function (_x13) {
1294
+ return _ref24.apply(this, arguments);
1295
+ };
1296
+ }()));
1297
+
1298
+ case 42:
1299
+ if (!(permission !== "owner")) {
1300
+ _context13.next = 45;
1301
+ break;
1302
+ }
1303
+
1219
1304
  _context13.next = 45;
1220
- break;
1221
- }
1222
-
1223
- _context13.next = 45;
1224
- return _regeneratorRuntime.awrap(this.SetPermission({
1225
- objectId: objectId,
1226
- permission: permission,
1227
- writeToken: writeToken
1228
- }));
1229
-
1230
- case 45:
1231
- _context13.next = 47;
1232
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
1233
- libraryId: libraryId,
1234
- objectId: objectId,
1235
- writeToken: writeToken
1236
- }));
1237
-
1238
- case 47:
1239
- return _context13.abrupt("return", _context13.sent);
1240
-
1241
- case 48:
1242
- case "end":
1243
- return _context13.stop();
1305
+ return this.SetPermission({
1306
+ objectId: objectId,
1307
+ permission: permission,
1308
+ writeToken: writeToken
1309
+ });
1310
+
1311
+ case 45:
1312
+ _context13.next = 47;
1313
+ return this.FinalizeContentObject({
1314
+ libraryId: libraryId,
1315
+ objectId: objectId,
1316
+ writeToken: writeToken
1317
+ });
1318
+
1319
+ case 47:
1320
+ return _context13.abrupt("return", _context13.sent);
1321
+
1322
+ case 48:
1323
+ case "end":
1324
+ return _context13.stop();
1325
+ }
1244
1326
  }
1245
- }
1246
- }, null, this);
1247
- };
1327
+ }, _callee13, this);
1328
+ }));
1329
+
1330
+ return function (_x12) {
1331
+ return _ref23.apply(this, arguments);
1332
+ };
1333
+ }();
1248
1334
  /**
1249
1335
  * Create a non-owner cap key using the specified public key and address
1250
1336
  *
@@ -1259,89 +1345,95 @@ exports.CopyContentObject = function _callee12(_ref15) {
1259
1345
  */
1260
1346
 
1261
1347
 
1262
- exports.CreateNonOwnerCap = function _callee13(_ref17) {
1263
- var objectId, libraryId, publicKey, writeToken, userCapKey, userCapValue, userConk, publicAddress, targetUserCapKey, targetUserCapValue, finalize;
1264
- return _regeneratorRuntime.async(function _callee13$(_context14) {
1265
- while (1) {
1266
- switch (_context14.prev = _context14.next) {
1267
- case 0:
1268
- objectId = _ref17.objectId, libraryId = _ref17.libraryId, publicKey = _ref17.publicKey, writeToken = _ref17.writeToken;
1269
- userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
1270
- _context14.next = 4;
1271
- return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
1272
- objectId: objectId,
1273
- libraryId: libraryId,
1274
- metadataSubtree: userCapKey
1275
- }));
1276
-
1277
- case 4:
1278
- userCapValue = _context14.sent;
1279
-
1280
- if (userCapValue) {
1281
- _context14.next = 7;
1282
- break;
1283
- }
1348
+ exports.CreateNonOwnerCap = /*#__PURE__*/function () {
1349
+ var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref25) {
1350
+ var objectId, libraryId, publicKey, writeToken, userCapKey, userCapValue, userConk, publicAddress, targetUserCapKey, targetUserCapValue, finalize;
1351
+ return _regeneratorRuntime.wrap(function _callee14$(_context14) {
1352
+ while (1) {
1353
+ switch (_context14.prev = _context14.next) {
1354
+ case 0:
1355
+ objectId = _ref25.objectId, libraryId = _ref25.libraryId, publicKey = _ref25.publicKey, writeToken = _ref25.writeToken;
1356
+ userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
1357
+ _context14.next = 4;
1358
+ return this.ContentObjectMetadata({
1359
+ objectId: objectId,
1360
+ libraryId: libraryId,
1361
+ metadataSubtree: userCapKey
1362
+ });
1284
1363
 
1285
- throw Error("No user cap found for current user");
1364
+ case 4:
1365
+ userCapValue = _context14.sent;
1286
1366
 
1287
- case 7:
1288
- _context14.next = 9;
1289
- return _regeneratorRuntime.awrap(this.Crypto.DecryptCap(userCapValue, this.signer.signingKey.privateKey));
1367
+ if (userCapValue) {
1368
+ _context14.next = 7;
1369
+ break;
1370
+ }
1290
1371
 
1291
- case 9:
1292
- userConk = _context14.sent;
1293
- publicAddress = this.utils.PublicKeyToAddress(publicKey);
1294
- targetUserCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(publicAddress));
1295
- _context14.next = 14;
1296
- return _regeneratorRuntime.awrap(this.Crypto.EncryptConk(userConk, publicKey));
1372
+ throw Error("No user cap found for current user");
1297
1373
 
1298
- case 14:
1299
- targetUserCapValue = _context14.sent;
1300
- finalize = !writeToken;
1374
+ case 7:
1375
+ _context14.next = 9;
1376
+ return this.Crypto.DecryptCap(userCapValue, this.signer.signingKey.privateKey);
1377
+
1378
+ case 9:
1379
+ userConk = _context14.sent;
1380
+ publicAddress = this.utils.PublicKeyToAddress(publicKey);
1381
+ targetUserCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(publicAddress));
1382
+ _context14.next = 14;
1383
+ return this.Crypto.EncryptConk(userConk, publicKey);
1384
+
1385
+ case 14:
1386
+ targetUserCapValue = _context14.sent;
1387
+ finalize = !writeToken;
1388
+
1389
+ if (writeToken) {
1390
+ _context14.next = 20;
1391
+ break;
1392
+ }
1393
+
1394
+ _context14.next = 19;
1395
+ return this.EditContentObject({
1396
+ libraryId: libraryId,
1397
+ objectId: objectId
1398
+ }).writeToken;
1399
+
1400
+ case 19:
1401
+ writeToken = _context14.sent;
1402
+
1403
+ case 20:
1404
+ this.ReplaceMetadata({
1405
+ libraryId: libraryId,
1406
+ objectId: objectId,
1407
+ writeToken: writeToken,
1408
+ metadataSubtree: targetUserCapKey,
1409
+ metadata: targetUserCapValue
1410
+ });
1411
+
1412
+ if (!finalize) {
1413
+ _context14.next = 24;
1414
+ break;
1415
+ }
1301
1416
 
1302
- if (writeToken) {
1303
- _context14.next = 20;
1304
- break;
1305
- }
1306
-
1307
- _context14.next = 19;
1308
- return _regeneratorRuntime.awrap(this.EditContentObject({
1309
- libraryId: libraryId,
1310
- objectId: objectId
1311
- }).writeToken);
1312
-
1313
- case 19:
1314
- writeToken = _context14.sent;
1315
-
1316
- case 20:
1317
- this.ReplaceMetadata({
1318
- libraryId: libraryId,
1319
- objectId: objectId,
1320
- writeToken: writeToken,
1321
- metadataSubtree: targetUserCapKey,
1322
- metadata: targetUserCapValue
1323
- });
1324
-
1325
- if (!finalize) {
1326
1417
  _context14.next = 24;
1327
- break;
1328
- }
1329
-
1330
- _context14.next = 24;
1331
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
1332
- libraryId: libraryId,
1333
- objectId: objectId,
1334
- writeToken: writeToken,
1335
- commitMessage: "Create non-owner cap"
1336
- }));
1337
-
1338
- case 24:
1339
- case "end":
1340
- return _context14.stop();
1418
+ return this.FinalizeContentObject({
1419
+ libraryId: libraryId,
1420
+ objectId: objectId,
1421
+ writeToken: writeToken,
1422
+ commitMessage: "Create non-owner cap"
1423
+ });
1424
+
1425
+ case 24:
1426
+ case "end":
1427
+ return _context14.stop();
1428
+ }
1341
1429
  }
1342
- }
1343
- }, null, this);
1344
- };
1430
+ }, _callee14, this);
1431
+ }));
1432
+
1433
+ return function (_x14) {
1434
+ return _ref26.apply(this, arguments);
1435
+ };
1436
+ }();
1345
1437
  /**
1346
1438
  * Create a new content object draft from an existing object.
1347
1439
  *
@@ -1357,117 +1449,121 @@ exports.CreateNonOwnerCap = function _callee13(_ref17) {
1357
1449
  */
1358
1450
 
1359
1451
 
1360
- exports.EditContentObject = function _callee14(_ref18) {
1361
- var libraryId, objectId, _ref18$options, options, path, editResponse;
1452
+ exports.EditContentObject = /*#__PURE__*/function () {
1453
+ var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref27) {
1454
+ var libraryId, objectId, _ref27$options, options, path, editResponse;
1362
1455
 
1363
- return _regeneratorRuntime.async(function _callee14$(_context15) {
1364
- while (1) {
1365
- switch (_context15.prev = _context15.next) {
1366
- case 0:
1367
- libraryId = _ref18.libraryId, objectId = _ref18.objectId, _ref18$options = _ref18.options, options = _ref18$options === void 0 ? {} : _ref18$options;
1368
- ValidateParameters({
1369
- libraryId: libraryId,
1370
- objectId: objectId
1371
- });
1372
- this.Log("Opening content draft: ".concat(libraryId, " ").concat(objectId));
1456
+ return _regeneratorRuntime.wrap(function _callee15$(_context15) {
1457
+ while (1) {
1458
+ switch (_context15.prev = _context15.next) {
1459
+ case 0:
1460
+ libraryId = _ref27.libraryId, objectId = _ref27.objectId, _ref27$options = _ref27.options, options = _ref27$options === void 0 ? {} : _ref27$options;
1461
+ ValidateParameters({
1462
+ libraryId: libraryId,
1463
+ objectId: objectId
1464
+ });
1465
+ this.Log("Opening content draft: ".concat(libraryId, " ").concat(objectId));
1373
1466
 
1374
- if (!("type" in options && options.type)) {
1375
- _context15.next = 23;
1376
- break;
1377
- }
1467
+ if (!("type" in options && options.type)) {
1468
+ _context15.next = 23;
1469
+ break;
1470
+ }
1471
+
1472
+ if (!options.type.startsWith("hq__")) {
1473
+ _context15.next = 10;
1474
+ break;
1475
+ }
1476
+
1477
+ _context15.next = 7;
1478
+ return this.ContentType({
1479
+ versionHash: options.type
1480
+ });
1378
1481
 
1379
- if (!options.type.startsWith("hq__")) {
1380
- _context15.next = 10;
1482
+ case 7:
1483
+ options.type = _context15.sent.hash;
1484
+ _context15.next = 23;
1381
1485
  break;
1382
- }
1383
1486
 
1384
- _context15.next = 7;
1385
- return _regeneratorRuntime.awrap(this.ContentType({
1386
- versionHash: options.type
1387
- }));
1487
+ case 10:
1488
+ if (!options.type.startsWith("iq__")) {
1489
+ _context15.next = 16;
1490
+ break;
1491
+ }
1388
1492
 
1389
- case 7:
1390
- options.type = _context15.sent.hash;
1391
- _context15.next = 23;
1392
- break;
1493
+ _context15.next = 13;
1494
+ return this.ContentType({
1495
+ typeId: options.type
1496
+ });
1393
1497
 
1394
- case 10:
1395
- if (!options.type.startsWith("iq__")) {
1396
- _context15.next = 16;
1498
+ case 13:
1499
+ options.type = _context15.sent.hash;
1500
+ _context15.next = 23;
1397
1501
  break;
1398
- }
1399
1502
 
1400
- _context15.next = 13;
1401
- return _regeneratorRuntime.awrap(this.ContentType({
1402
- typeId: options.type
1403
- }));
1503
+ case 16:
1504
+ if (!options.type) {
1505
+ _context15.next = 22;
1506
+ break;
1507
+ }
1404
1508
 
1405
- case 13:
1406
- options.type = _context15.sent.hash;
1407
- _context15.next = 23;
1408
- break;
1509
+ _context15.next = 19;
1510
+ return this.ContentType({
1511
+ name: options.type
1512
+ });
1409
1513
 
1410
- case 16:
1411
- if (!options.type) {
1412
- _context15.next = 22;
1514
+ case 19:
1515
+ options.type = _context15.sent.hash;
1516
+ _context15.next = 23;
1413
1517
  break;
1414
- }
1415
-
1416
- _context15.next = 19;
1417
- return _regeneratorRuntime.awrap(this.ContentType({
1418
- name: options.type
1419
- }));
1420
-
1421
- case 19:
1422
- options.type = _context15.sent.hash;
1423
- _context15.next = 23;
1424
- break;
1425
-
1426
- case 22:
1427
- options.type = "";
1428
-
1429
- case 23:
1430
- path = UrlJoin("qid", objectId);
1431
- _context15.t0 = _regeneratorRuntime;
1432
- _context15.t1 = this.utils;
1433
- _context15.t2 = this.HttpClient;
1434
- _context15.next = 29;
1435
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
1436
- libraryId: libraryId,
1437
- objectId: objectId,
1438
- update: true
1439
- }));
1440
-
1441
- case 29:
1442
- _context15.t3 = _context15.sent;
1443
- _context15.t4 = path;
1444
- _context15.t5 = options;
1445
- _context15.t6 = {
1446
- headers: _context15.t3,
1447
- method: "POST",
1448
- path: _context15.t4,
1449
- body: _context15.t5
1450
- };
1451
- _context15.t7 = _context15.t2.Request.call(_context15.t2, _context15.t6);
1452
- _context15.t8 = _context15.t1.ResponseToJson.call(_context15.t1, _context15.t7);
1453
- _context15.next = 37;
1454
- return _context15.t0.awrap.call(_context15.t0, _context15.t8);
1455
-
1456
- case 37:
1457
- editResponse = _context15.sent;
1458
- // Record the node used in creating this write token
1459
- this.HttpClient.RecordWriteToken(editResponse.write_token);
1460
- editResponse.writeToken = editResponse.write_token;
1461
- editResponse.objectId = editResponse.id;
1462
- return _context15.abrupt("return", editResponse);
1463
-
1464
- case 42:
1465
- case "end":
1466
- return _context15.stop();
1518
+
1519
+ case 22:
1520
+ options.type = "";
1521
+
1522
+ case 23:
1523
+ path = UrlJoin("qid", objectId);
1524
+ _context15.t0 = this.utils;
1525
+ _context15.t1 = this.HttpClient;
1526
+ _context15.next = 28;
1527
+ return this.authClient.AuthorizationHeader({
1528
+ libraryId: libraryId,
1529
+ objectId: objectId,
1530
+ update: true
1531
+ });
1532
+
1533
+ case 28:
1534
+ _context15.t2 = _context15.sent;
1535
+ _context15.t3 = path;
1536
+ _context15.t4 = options;
1537
+ _context15.t5 = {
1538
+ headers: _context15.t2,
1539
+ method: "POST",
1540
+ path: _context15.t3,
1541
+ body: _context15.t4
1542
+ };
1543
+ _context15.t6 = _context15.t1.Request.call(_context15.t1, _context15.t5);
1544
+ _context15.next = 35;
1545
+ return _context15.t0.ResponseToJson.call(_context15.t0, _context15.t6);
1546
+
1547
+ case 35:
1548
+ editResponse = _context15.sent;
1549
+ // Record the node used in creating this write token
1550
+ this.HttpClient.RecordWriteToken(editResponse.write_token);
1551
+ editResponse.writeToken = editResponse.write_token;
1552
+ editResponse.objectId = editResponse.id;
1553
+ return _context15.abrupt("return", editResponse);
1554
+
1555
+ case 40:
1556
+ case "end":
1557
+ return _context15.stop();
1558
+ }
1467
1559
  }
1468
- }
1469
- }, null, this);
1470
- };
1560
+ }, _callee15, this);
1561
+ }));
1562
+
1563
+ return function (_x15) {
1564
+ return _ref28.apply(this, arguments);
1565
+ };
1566
+ }();
1471
1567
  /**
1472
1568
  * Create and finalize new content object draft from an existing object.
1473
1569
  *
@@ -1496,56 +1592,62 @@ exports.EditContentObject = function _callee14(_ref18) {
1496
1592
  */
1497
1593
 
1498
1594
 
1499
- exports.CreateAndFinalizeContentObject = function _callee15(_ref19) {
1500
- var libraryId, callback, _ref19$options, options, _ref19$commitMessage, commitMessage, _ref19$publish, publish, _ref19$awaitCommitCon, awaitCommitConfirmation, args, id, writeToken;
1595
+ exports.CreateAndFinalizeContentObject = /*#__PURE__*/function () {
1596
+ var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref29) {
1597
+ var libraryId, callback, _ref29$options, options, _ref29$commitMessage, commitMessage, _ref29$publish, publish, _ref29$awaitCommitCon, awaitCommitConfirmation, args, id, writeToken;
1598
+
1599
+ return _regeneratorRuntime.wrap(function _callee16$(_context16) {
1600
+ while (1) {
1601
+ switch (_context16.prev = _context16.next) {
1602
+ case 0:
1603
+ libraryId = _ref29.libraryId, callback = _ref29.callback, _ref29$options = _ref29.options, options = _ref29$options === void 0 ? {} : _ref29$options, _ref29$commitMessage = _ref29.commitMessage, commitMessage = _ref29$commitMessage === void 0 ? "" : _ref29$commitMessage, _ref29$publish = _ref29.publish, publish = _ref29$publish === void 0 ? true : _ref29$publish, _ref29$awaitCommitCon = _ref29.awaitCommitConfirmation, awaitCommitConfirmation = _ref29$awaitCommitCon === void 0 ? true : _ref29$awaitCommitCon;
1604
+ _context16.next = 3;
1605
+ return this.CreateContentObject({
1606
+ libraryId: libraryId,
1607
+ options: options
1608
+ });
1501
1609
 
1502
- return _regeneratorRuntime.async(function _callee15$(_context16) {
1503
- while (1) {
1504
- switch (_context16.prev = _context16.next) {
1505
- case 0:
1506
- libraryId = _ref19.libraryId, callback = _ref19.callback, _ref19$options = _ref19.options, options = _ref19$options === void 0 ? {} : _ref19$options, _ref19$commitMessage = _ref19.commitMessage, commitMessage = _ref19$commitMessage === void 0 ? "" : _ref19$commitMessage, _ref19$publish = _ref19.publish, publish = _ref19$publish === void 0 ? true : _ref19$publish, _ref19$awaitCommitCon = _ref19.awaitCommitConfirmation, awaitCommitConfirmation = _ref19$awaitCommitCon === void 0 ? true : _ref19$awaitCommitCon;
1507
- _context16.next = 3;
1508
- return _regeneratorRuntime.awrap(this.CreateContentObject({
1509
- libraryId: libraryId,
1510
- options: options
1511
- }));
1610
+ case 3:
1611
+ args = _context16.sent;
1612
+ id = args.id, writeToken = args.writeToken;
1512
1613
 
1513
- case 3:
1514
- args = _context16.sent;
1515
- id = args.id, writeToken = args.writeToken;
1614
+ if (!callback) {
1615
+ _context16.next = 8;
1616
+ break;
1617
+ }
1516
1618
 
1517
- if (!callback) {
1518
1619
  _context16.next = 8;
1519
- break;
1520
- }
1521
-
1522
- _context16.next = 8;
1523
- return _regeneratorRuntime.awrap(callback({
1524
- objectId: id,
1525
- writeToken: writeToken
1526
- }));
1527
-
1528
- case 8:
1529
- _context16.next = 10;
1530
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
1531
- libraryId: libraryId,
1532
- objectId: id,
1533
- writeToken: writeToken,
1534
- commitMessage: commitMessage,
1535
- publish: publish,
1536
- awaitCommitConfirmation: awaitCommitConfirmation
1537
- }));
1538
-
1539
- case 10:
1540
- return _context16.abrupt("return", _context16.sent);
1541
-
1542
- case 11:
1543
- case "end":
1544
- return _context16.stop();
1620
+ return callback({
1621
+ objectId: id,
1622
+ writeToken: writeToken
1623
+ });
1624
+
1625
+ case 8:
1626
+ _context16.next = 10;
1627
+ return this.FinalizeContentObject({
1628
+ libraryId: libraryId,
1629
+ objectId: id,
1630
+ writeToken: writeToken,
1631
+ commitMessage: commitMessage,
1632
+ publish: publish,
1633
+ awaitCommitConfirmation: awaitCommitConfirmation
1634
+ });
1635
+
1636
+ case 10:
1637
+ return _context16.abrupt("return", _context16.sent);
1638
+
1639
+ case 11:
1640
+ case "end":
1641
+ return _context16.stop();
1642
+ }
1545
1643
  }
1546
- }
1547
- }, null, this);
1548
- };
1644
+ }, _callee16, this);
1645
+ }));
1646
+
1647
+ return function (_x16) {
1648
+ return _ref30.apply(this, arguments);
1649
+ };
1650
+ }();
1549
1651
  /**
1550
1652
  * Create and finalize new content object draft from an existing object.
1551
1653
  *
@@ -1575,169 +1677,187 @@ exports.CreateAndFinalizeContentObject = function _callee15(_ref19) {
1575
1677
  */
1576
1678
 
1577
1679
 
1578
- exports.EditAndFinalizeContentObject = function _callee16(_ref20) {
1579
- var libraryId, objectId, callback, _ref20$options, options, _ref20$commitMessage, commitMessage, _ref20$publish, publish, _ref20$awaitCommitCon, awaitCommitConfirmation, _ref21, writeToken;
1680
+ exports.EditAndFinalizeContentObject = /*#__PURE__*/function () {
1681
+ var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref31) {
1682
+ var libraryId, objectId, callback, _ref31$options, options, _ref31$commitMessage, commitMessage, _ref31$publish, publish, _ref31$awaitCommitCon, awaitCommitConfirmation, _yield$this$EditConte, writeToken;
1683
+
1684
+ return _regeneratorRuntime.wrap(function _callee17$(_context17) {
1685
+ while (1) {
1686
+ switch (_context17.prev = _context17.next) {
1687
+ case 0:
1688
+ libraryId = _ref31.libraryId, objectId = _ref31.objectId, callback = _ref31.callback, _ref31$options = _ref31.options, options = _ref31$options === void 0 ? {} : _ref31$options, _ref31$commitMessage = _ref31.commitMessage, commitMessage = _ref31$commitMessage === void 0 ? "" : _ref31$commitMessage, _ref31$publish = _ref31.publish, publish = _ref31$publish === void 0 ? true : _ref31$publish, _ref31$awaitCommitCon = _ref31.awaitCommitConfirmation, awaitCommitConfirmation = _ref31$awaitCommitCon === void 0 ? true : _ref31$awaitCommitCon;
1689
+ _context17.next = 3;
1690
+ return this.EditContentObject({
1691
+ libraryId: libraryId,
1692
+ objectId: objectId,
1693
+ options: options
1694
+ });
1580
1695
 
1581
- return _regeneratorRuntime.async(function _callee16$(_context17) {
1582
- while (1) {
1583
- switch (_context17.prev = _context17.next) {
1584
- case 0:
1585
- libraryId = _ref20.libraryId, objectId = _ref20.objectId, callback = _ref20.callback, _ref20$options = _ref20.options, options = _ref20$options === void 0 ? {} : _ref20$options, _ref20$commitMessage = _ref20.commitMessage, commitMessage = _ref20$commitMessage === void 0 ? "" : _ref20$commitMessage, _ref20$publish = _ref20.publish, publish = _ref20$publish === void 0 ? true : _ref20$publish, _ref20$awaitCommitCon = _ref20.awaitCommitConfirmation, awaitCommitConfirmation = _ref20$awaitCommitCon === void 0 ? true : _ref20$awaitCommitCon;
1586
- _context17.next = 3;
1587
- return _regeneratorRuntime.awrap(this.EditContentObject({
1588
- libraryId: libraryId,
1589
- objectId: objectId,
1590
- options: options
1591
- }));
1696
+ case 3:
1697
+ _yield$this$EditConte = _context17.sent;
1698
+ writeToken = _yield$this$EditConte.writeToken;
1592
1699
 
1593
- case 3:
1594
- _ref21 = _context17.sent;
1595
- writeToken = _ref21.writeToken;
1700
+ if (!callback) {
1701
+ _context17.next = 8;
1702
+ break;
1703
+ }
1596
1704
 
1597
- if (!callback) {
1598
1705
  _context17.next = 8;
1599
- break;
1600
- }
1601
-
1602
- _context17.next = 8;
1603
- return _regeneratorRuntime.awrap(callback({
1604
- writeToken: writeToken
1605
- }));
1606
-
1607
- case 8:
1608
- _context17.next = 10;
1609
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
1610
- libraryId: libraryId,
1611
- objectId: objectId,
1612
- writeToken: writeToken,
1613
- commitMessage: commitMessage,
1614
- publish: publish,
1615
- awaitCommitConfirmation: awaitCommitConfirmation
1616
- }));
1617
-
1618
- case 10:
1619
- return _context17.abrupt("return", _context17.sent);
1620
-
1621
- case 11:
1622
- case "end":
1623
- return _context17.stop();
1624
- }
1625
- }
1626
- }, null, this);
1627
- };
1628
-
1629
- exports.AwaitPending = function _callee17(objectId) {
1630
- var _this3 = this;
1631
-
1632
- var PendingHash, pending, isWallet, timeout, i;
1633
- return _regeneratorRuntime.async(function _callee17$(_context19) {
1634
- while (1) {
1635
- switch (_context19.prev = _context19.next) {
1636
- case 0:
1637
- PendingHash = function PendingHash() {
1638
- return _regeneratorRuntime.async(function PendingHash$(_context18) {
1639
- while (1) {
1640
- switch (_context18.prev = _context18.next) {
1641
- case 0:
1642
- _context18.next = 2;
1643
- return _regeneratorRuntime.awrap(_this3.CallContractMethod({
1644
- contractAddress: _this3.utils.HashToAddress(objectId),
1645
- methodName: "pendingHash"
1646
- }));
1647
-
1648
- case 2:
1649
- return _context18.abrupt("return", _context18.sent);
1650
-
1651
- case 3:
1652
- case "end":
1653
- return _context18.stop();
1654
- }
1655
- }
1706
+ return callback({
1707
+ writeToken: writeToken
1656
1708
  });
1657
- };
1658
1709
 
1659
- this.Log("Checking for pending commit");
1660
- _context19.next = 4;
1661
- return _regeneratorRuntime.awrap(PendingHash());
1710
+ case 8:
1711
+ _context17.next = 10;
1712
+ return this.FinalizeContentObject({
1713
+ libraryId: libraryId,
1714
+ objectId: objectId,
1715
+ writeToken: writeToken,
1716
+ commitMessage: commitMessage,
1717
+ publish: publish,
1718
+ awaitCommitConfirmation: awaitCommitConfirmation
1719
+ });
1662
1720
 
1663
- case 4:
1664
- pending = _context19.sent;
1721
+ case 10:
1722
+ return _context17.abrupt("return", _context17.sent);
1665
1723
 
1666
- if (pending) {
1667
- _context19.next = 7;
1668
- break;
1669
- }
1724
+ case 11:
1725
+ case "end":
1726
+ return _context17.stop();
1727
+ }
1728
+ }
1729
+ }, _callee17, this);
1730
+ }));
1731
+
1732
+ return function (_x17) {
1733
+ return _ref32.apply(this, arguments);
1734
+ };
1735
+ }();
1736
+
1737
+ exports.AwaitPending = /*#__PURE__*/function () {
1738
+ var _ref33 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(objectId) {
1739
+ var _this3 = this;
1740
+
1741
+ var PendingHash, pending, isWallet, timeout, i;
1742
+ return _regeneratorRuntime.wrap(function _callee19$(_context19) {
1743
+ while (1) {
1744
+ switch (_context19.prev = _context19.next) {
1745
+ case 0:
1746
+ PendingHash = /*#__PURE__*/function () {
1747
+ var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
1748
+ return _regeneratorRuntime.wrap(function _callee18$(_context18) {
1749
+ while (1) {
1750
+ switch (_context18.prev = _context18.next) {
1751
+ case 0:
1752
+ _context18.next = 2;
1753
+ return _this3.CallContractMethod({
1754
+ contractAddress: _this3.utils.HashToAddress(objectId),
1755
+ methodName: "pendingHash"
1756
+ });
1757
+
1758
+ case 2:
1759
+ return _context18.abrupt("return", _context18.sent);
1760
+
1761
+ case 3:
1762
+ case "end":
1763
+ return _context18.stop();
1764
+ }
1765
+ }
1766
+ }, _callee18);
1767
+ }));
1670
1768
 
1671
- return _context19.abrupt("return");
1769
+ return function PendingHash() {
1770
+ return _ref34.apply(this, arguments);
1771
+ };
1772
+ }();
1672
1773
 
1673
- case 7:
1674
- _context19.next = 9;
1675
- return _regeneratorRuntime.awrap(this.authClient.AccessType(objectId));
1774
+ this.Log("Checking for pending commit");
1775
+ _context19.next = 4;
1776
+ return PendingHash();
1676
1777
 
1677
- case 9:
1678
- _context19.t0 = _context19.sent;
1679
- _context19.t1 = this.authClient.ACCESS_TYPES.WALLET;
1680
- isWallet = _context19.t0 === _context19.t1;
1681
- timeout = isWallet ? 3 : 10;
1682
- this.Log("Waiting for pending commit to clear for ".concat(objectId));
1683
- i = 0;
1778
+ case 4:
1779
+ pending = _context19.sent;
1684
1780
 
1685
- case 15:
1686
- if (!(i < timeout)) {
1687
- _context19.next = 25;
1688
- break;
1689
- }
1781
+ if (pending) {
1782
+ _context19.next = 7;
1783
+ break;
1784
+ }
1690
1785
 
1691
- _context19.next = 18;
1692
- return _regeneratorRuntime.awrap(new Promise(function (resolve) {
1693
- return setTimeout(resolve, 1000);
1694
- }));
1786
+ return _context19.abrupt("return");
1695
1787
 
1696
- case 18:
1697
- _context19.next = 20;
1698
- return _regeneratorRuntime.awrap(PendingHash());
1788
+ case 7:
1789
+ _context19.next = 9;
1790
+ return this.authClient.AccessType(objectId);
1699
1791
 
1700
- case 20:
1701
- if (_context19.sent) {
1702
- _context19.next = 22;
1703
- break;
1704
- }
1792
+ case 9:
1793
+ _context19.t0 = _context19.sent;
1794
+ _context19.t1 = this.authClient.ACCESS_TYPES.WALLET;
1795
+ isWallet = _context19.t0 === _context19.t1;
1796
+ timeout = isWallet ? 3 : 10;
1797
+ this.Log("Waiting for pending commit to clear for ".concat(objectId));
1798
+ i = 0;
1799
+
1800
+ case 15:
1801
+ if (!(i < timeout)) {
1802
+ _context19.next = 25;
1803
+ break;
1804
+ }
1805
+
1806
+ _context19.next = 18;
1807
+ return new Promise(function (resolve) {
1808
+ return setTimeout(resolve, 1000);
1809
+ });
1705
1810
 
1706
- return _context19.abrupt("return");
1811
+ case 18:
1812
+ _context19.next = 20;
1813
+ return PendingHash();
1707
1814
 
1708
- case 22:
1709
- i++;
1710
- _context19.next = 15;
1711
- break;
1815
+ case 20:
1816
+ if (_context19.sent) {
1817
+ _context19.next = 22;
1818
+ break;
1819
+ }
1712
1820
 
1713
- case 25:
1714
- if (!isWallet) {
1715
- _context19.next = 31;
1821
+ return _context19.abrupt("return");
1822
+
1823
+ case 22:
1824
+ i++;
1825
+ _context19.next = 15;
1716
1826
  break;
1717
- }
1718
1827
 
1719
- this.Log("Clearing stuck wallet commit", true); // Clear pending commit, it's probably stuck
1828
+ case 25:
1829
+ if (!isWallet) {
1830
+ _context19.next = 31;
1831
+ break;
1832
+ }
1833
+
1834
+ this.Log("Clearing stuck wallet commit", true); // Clear pending commit, it's probably stuck
1720
1835
 
1721
- _context19.next = 29;
1722
- return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
1723
- contractAddress: this.utils.HashToAddress(objectId),
1724
- methodName: "clearPending"
1725
- }));
1836
+ _context19.next = 29;
1837
+ return this.CallContractMethodAndWait({
1838
+ contractAddress: this.utils.HashToAddress(objectId),
1839
+ methodName: "clearPending"
1840
+ });
1726
1841
 
1727
- case 29:
1728
- _context19.next = 32;
1729
- break;
1842
+ case 29:
1843
+ _context19.next = 32;
1844
+ break;
1730
1845
 
1731
- case 31:
1732
- throw Error("Unable to finalize ".concat(objectId, " - Another commit is pending"));
1846
+ case 31:
1847
+ throw Error("Unable to finalize ".concat(objectId, " - Another commit is pending"));
1733
1848
 
1734
- case 32:
1735
- case "end":
1736
- return _context19.stop();
1849
+ case 32:
1850
+ case "end":
1851
+ return _context19.stop();
1852
+ }
1737
1853
  }
1738
- }
1739
- }, null, this);
1740
- };
1854
+ }, _callee19, this);
1855
+ }));
1856
+
1857
+ return function (_x18) {
1858
+ return _ref33.apply(this, arguments);
1859
+ };
1860
+ }();
1741
1861
  /**
1742
1862
  * Finalize content draft
1743
1863
  *
@@ -1753,120 +1873,122 @@ exports.AwaitPending = function _callee17(objectId) {
1753
1873
  */
1754
1874
 
1755
1875
 
1756
- exports.FinalizeContentObject = function _callee18(_ref22) {
1757
- var libraryId, objectId, writeToken, _ref22$commitMessage, commitMessage, _ref22$publish, publish, _ref22$awaitCommitCon, awaitCommitConfirmation, path, finalizeResponse;
1758
-
1759
- return _regeneratorRuntime.async(function _callee18$(_context20) {
1760
- while (1) {
1761
- switch (_context20.prev = _context20.next) {
1762
- case 0:
1763
- libraryId = _ref22.libraryId, objectId = _ref22.objectId, writeToken = _ref22.writeToken, _ref22$commitMessage = _ref22.commitMessage, commitMessage = _ref22$commitMessage === void 0 ? "" : _ref22$commitMessage, _ref22$publish = _ref22.publish, publish = _ref22$publish === void 0 ? true : _ref22$publish, _ref22$awaitCommitCon = _ref22.awaitCommitConfirmation, awaitCommitConfirmation = _ref22$awaitCommitCon === void 0 ? true : _ref22$awaitCommitCon;
1764
- ValidateParameters({
1765
- libraryId: libraryId,
1766
- objectId: objectId
1767
- });
1768
- ValidateWriteToken(writeToken);
1769
- _context20.t0 = _regeneratorRuntime;
1770
- _context20.t1 = this;
1771
- _context20.t2 = libraryId;
1772
- _context20.t3 = objectId;
1773
- _context20.t4 = writeToken;
1774
- _context20.t5 = commitMessage;
1775
- _context20.next = 11;
1776
- return _regeneratorRuntime.awrap(this.userProfileClient.UserMetadata({
1777
- metadataSubtree: "public/name"
1778
- }));
1779
-
1780
- case 11:
1781
- _context20.t6 = _context20.sent;
1782
-
1783
- if (_context20.t6) {
1784
- _context20.next = 14;
1785
- break;
1786
- }
1787
-
1788
- _context20.t6 = this.CurrentAccountAddress();
1789
-
1790
- case 14:
1791
- _context20.t7 = _context20.t6;
1792
- _context20.t8 = this.CurrentAccountAddress();
1793
- _context20.t9 = new Date().toISOString();
1794
- _context20.t10 = {
1795
- message: _context20.t5,
1796
- author: _context20.t7,
1797
- author_address: _context20.t8,
1798
- timestamp: _context20.t9
1799
- };
1800
- _context20.t11 = {
1801
- libraryId: _context20.t2,
1802
- objectId: _context20.t3,
1803
- writeToken: _context20.t4,
1804
- metadataSubtree: "commit",
1805
- metadata: _context20.t10
1806
- };
1807
- _context20.t12 = _context20.t1.ReplaceMetadata.call(_context20.t1, _context20.t11);
1808
- _context20.next = 22;
1809
- return _context20.t0.awrap.call(_context20.t0, _context20.t12);
1810
-
1811
- case 22:
1812
- this.Log("Finalizing content draft: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
1813
- _context20.next = 25;
1814
- return _regeneratorRuntime.awrap(this.AwaitPending(objectId));
1815
-
1816
- case 25:
1817
- path = UrlJoin("q", writeToken);
1818
- _context20.t13 = _regeneratorRuntime;
1819
- _context20.t14 = this.utils;
1820
- _context20.t15 = this.HttpClient;
1821
- _context20.next = 31;
1822
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
1823
- libraryId: libraryId,
1824
- objectId: objectId,
1825
- update: true
1826
- }));
1827
-
1828
- case 31:
1829
- _context20.t16 = _context20.sent;
1830
- _context20.t17 = path;
1831
- _context20.t18 = {
1832
- headers: _context20.t16,
1833
- method: "POST",
1834
- path: _context20.t17,
1835
- failover: false
1836
- };
1837
- _context20.t19 = _context20.t15.Request.call(_context20.t15, _context20.t18);
1838
- _context20.t20 = _context20.t14.ResponseToJson.call(_context20.t14, _context20.t19);
1839
- _context20.next = 38;
1840
- return _context20.t13.awrap.call(_context20.t13, _context20.t20);
1841
-
1842
- case 38:
1843
- finalizeResponse = _context20.sent;
1844
- this.Log("Finalized: ".concat(finalizeResponse.hash));
1845
-
1846
- if (!publish) {
1847
- _context20.next = 43;
1848
- break;
1849
- }
1850
-
1851
- _context20.next = 43;
1852
- return _regeneratorRuntime.awrap(this.PublishContentVersion({
1853
- objectId: objectId,
1854
- versionHash: finalizeResponse.hash,
1855
- awaitCommitConfirmation: awaitCommitConfirmation
1856
- }));
1857
-
1858
- case 43:
1859
- // Invalidate cached content type, if this is one.
1860
- delete this.contentTypes[objectId];
1861
- return _context20.abrupt("return", finalizeResponse);
1862
-
1863
- case 45:
1864
- case "end":
1865
- return _context20.stop();
1876
+ exports.FinalizeContentObject = /*#__PURE__*/function () {
1877
+ var _ref36 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref35) {
1878
+ var libraryId, objectId, writeToken, _ref35$commitMessage, commitMessage, _ref35$publish, publish, _ref35$awaitCommitCon, awaitCommitConfirmation, path, finalizeResponse;
1879
+
1880
+ return _regeneratorRuntime.wrap(function _callee20$(_context20) {
1881
+ while (1) {
1882
+ switch (_context20.prev = _context20.next) {
1883
+ case 0:
1884
+ libraryId = _ref35.libraryId, objectId = _ref35.objectId, writeToken = _ref35.writeToken, _ref35$commitMessage = _ref35.commitMessage, commitMessage = _ref35$commitMessage === void 0 ? "" : _ref35$commitMessage, _ref35$publish = _ref35.publish, publish = _ref35$publish === void 0 ? true : _ref35$publish, _ref35$awaitCommitCon = _ref35.awaitCommitConfirmation, awaitCommitConfirmation = _ref35$awaitCommitCon === void 0 ? true : _ref35$awaitCommitCon;
1885
+ ValidateParameters({
1886
+ libraryId: libraryId,
1887
+ objectId: objectId
1888
+ });
1889
+ ValidateWriteToken(writeToken);
1890
+ _context20.t0 = this;
1891
+ _context20.t1 = libraryId;
1892
+ _context20.t2 = objectId;
1893
+ _context20.t3 = writeToken;
1894
+ _context20.t4 = commitMessage;
1895
+ _context20.next = 10;
1896
+ return this.userProfileClient.UserMetadata({
1897
+ metadataSubtree: "public/name"
1898
+ });
1899
+
1900
+ case 10:
1901
+ _context20.t5 = _context20.sent;
1902
+
1903
+ if (_context20.t5) {
1904
+ _context20.next = 13;
1905
+ break;
1906
+ }
1907
+
1908
+ _context20.t5 = this.CurrentAccountAddress();
1909
+
1910
+ case 13:
1911
+ _context20.t6 = _context20.t5;
1912
+ _context20.t7 = this.CurrentAccountAddress();
1913
+ _context20.t8 = new Date().toISOString();
1914
+ _context20.t9 = {
1915
+ message: _context20.t4,
1916
+ author: _context20.t6,
1917
+ author_address: _context20.t7,
1918
+ timestamp: _context20.t8
1919
+ };
1920
+ _context20.t10 = {
1921
+ libraryId: _context20.t1,
1922
+ objectId: _context20.t2,
1923
+ writeToken: _context20.t3,
1924
+ metadataSubtree: "commit",
1925
+ metadata: _context20.t9
1926
+ };
1927
+ _context20.next = 20;
1928
+ return _context20.t0.ReplaceMetadata.call(_context20.t0, _context20.t10);
1929
+
1930
+ case 20:
1931
+ this.Log("Finalizing content draft: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
1932
+ _context20.next = 23;
1933
+ return this.AwaitPending(objectId);
1934
+
1935
+ case 23:
1936
+ path = UrlJoin("q", writeToken);
1937
+ _context20.t11 = this.utils;
1938
+ _context20.t12 = this.HttpClient;
1939
+ _context20.next = 28;
1940
+ return this.authClient.AuthorizationHeader({
1941
+ libraryId: libraryId,
1942
+ objectId: objectId,
1943
+ update: true
1944
+ });
1945
+
1946
+ case 28:
1947
+ _context20.t13 = _context20.sent;
1948
+ _context20.t14 = path;
1949
+ _context20.t15 = {
1950
+ headers: _context20.t13,
1951
+ method: "POST",
1952
+ path: _context20.t14,
1953
+ failover: false
1954
+ };
1955
+ _context20.t16 = _context20.t12.Request.call(_context20.t12, _context20.t15);
1956
+ _context20.next = 34;
1957
+ return _context20.t11.ResponseToJson.call(_context20.t11, _context20.t16);
1958
+
1959
+ case 34:
1960
+ finalizeResponse = _context20.sent;
1961
+ this.Log("Finalized: ".concat(finalizeResponse.hash));
1962
+
1963
+ if (!publish) {
1964
+ _context20.next = 39;
1965
+ break;
1966
+ }
1967
+
1968
+ _context20.next = 39;
1969
+ return this.PublishContentVersion({
1970
+ objectId: objectId,
1971
+ versionHash: finalizeResponse.hash,
1972
+ awaitCommitConfirmation: awaitCommitConfirmation
1973
+ });
1974
+
1975
+ case 39:
1976
+ // Invalidate cached content type, if this is one.
1977
+ delete this.contentTypes[objectId];
1978
+ return _context20.abrupt("return", finalizeResponse);
1979
+
1980
+ case 41:
1981
+ case "end":
1982
+ return _context20.stop();
1983
+ }
1866
1984
  }
1867
- }
1868
- }, null, this);
1869
- };
1985
+ }, _callee20, this);
1986
+ }));
1987
+
1988
+ return function (_x19) {
1989
+ return _ref36.apply(this, arguments);
1990
+ };
1991
+ }();
1870
1992
  /**
1871
1993
  * Publish a previously finalized content object version
1872
1994
  *
@@ -1879,140 +2001,145 @@ exports.FinalizeContentObject = function _callee18(_ref22) {
1879
2001
  */
1880
2002
 
1881
2003
 
1882
- exports.PublishContentVersion = function _callee20(_ref23) {
1883
- var _this4 = this;
1884
-
1885
- var objectId, versionHash, _ref23$awaitCommitCon, awaitCommitConfirmation, commit, abi, fromBlock, objectHash, pendingHash;
1886
-
1887
- return _regeneratorRuntime.async(function _callee20$(_context22) {
1888
- while (1) {
1889
- switch (_context22.prev = _context22.next) {
1890
- case 0:
1891
- objectId = _ref23.objectId, versionHash = _ref23.versionHash, _ref23$awaitCommitCon = _ref23.awaitCommitConfirmation, awaitCommitConfirmation = _ref23$awaitCommitCon === void 0 ? true : _ref23$awaitCommitCon;
1892
- versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
1893
- this.Log("Publishing: ".concat(objectId || versionHash));
1894
-
1895
- if (versionHash) {
1896
- objectId = this.utils.DecodeVersionHash(versionHash).objectId;
1897
- }
1898
-
1899
- _context22.next = 6;
1900
- return _regeneratorRuntime.awrap(this.ethClient.CommitContent({
1901
- contentObjectAddress: this.utils.HashToAddress(objectId),
1902
- versionHash: versionHash,
1903
- signer: this.signer
1904
- }));
1905
-
1906
- case 6:
1907
- commit = _context22.sent;
1908
- _context22.next = 9;
1909
- return _regeneratorRuntime.awrap(this.ContractAbi({
1910
- id: objectId
1911
- }));
1912
-
1913
- case 9:
1914
- abi = _context22.sent;
1915
- fromBlock = commit.blockNumber + 1;
1916
- _context22.next = 13;
1917
- return _regeneratorRuntime.awrap(this.ExtractValueFromEvent({
1918
- abi: abi,
1919
- event: commit,
1920
- eventName: "CommitPending",
1921
- eventValue: "objectHash"
1922
- }));
1923
-
1924
- case 13:
1925
- objectHash = _context22.sent;
1926
- _context22.next = 16;
1927
- return _regeneratorRuntime.awrap(this.CallContractMethod({
1928
- contractAddress: this.utils.HashToAddress(objectId),
1929
- methodName: "pendingHash"
1930
- }));
1931
-
1932
- case 16:
1933
- pendingHash = _context22.sent;
1934
-
1935
- if (!(pendingHash && pendingHash !== objectHash)) {
1936
- _context22.next = 19;
1937
- break;
1938
- }
2004
+ exports.PublishContentVersion = /*#__PURE__*/function () {
2005
+ var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref37) {
2006
+ var _this4 = this;
1939
2007
 
1940
- throw Error("Pending version hash mismatch on ".concat(objectId, ": expected ").concat(objectHash, ", currently ").concat(pendingHash));
2008
+ var objectId, versionHash, _ref37$awaitCommitCon, awaitCommitConfirmation, commit, abi, fromBlock, objectHash, pendingHash;
1941
2009
 
1942
- case 19:
1943
- if (!awaitCommitConfirmation) {
1944
- _context22.next = 22;
1945
- break;
1946
- }
1947
-
1948
- _context22.next = 22;
1949
- return _regeneratorRuntime.awrap(function _callee19() {
1950
- var pollingInterval, events, confirmEvent;
1951
- return _regeneratorRuntime.async(function _callee19$(_context21) {
1952
- while (1) {
1953
- switch (_context21.prev = _context21.next) {
1954
- case 0:
1955
- _this4.Log("Awaiting commit confirmation for ".concat(objectHash));
1956
-
1957
- pollingInterval = _this4.ethClient.Provider().pollingInterval || 500; // eslint-disable-next-line no-constant-condition
1958
-
1959
- case 2:
1960
- if (!true) {
1961
- _context21.next = 14;
1962
- break;
1963
- }
2010
+ return _regeneratorRuntime.wrap(function _callee22$(_context22) {
2011
+ while (1) {
2012
+ switch (_context22.prev = _context22.next) {
2013
+ case 0:
2014
+ objectId = _ref37.objectId, versionHash = _ref37.versionHash, _ref37$awaitCommitCon = _ref37.awaitCommitConfirmation, awaitCommitConfirmation = _ref37$awaitCommitCon === void 0 ? true : _ref37$awaitCommitCon;
2015
+ versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
2016
+ this.Log("Publishing: ".concat(objectId || versionHash));
2017
+
2018
+ if (versionHash) {
2019
+ objectId = this.utils.DecodeVersionHash(versionHash).objectId;
2020
+ }
2021
+
2022
+ _context22.next = 6;
2023
+ return this.ethClient.CommitContent({
2024
+ contentObjectAddress: this.utils.HashToAddress(objectId),
2025
+ versionHash: versionHash,
2026
+ signer: this.signer
2027
+ });
2028
+
2029
+ case 6:
2030
+ commit = _context22.sent;
2031
+ _context22.next = 9;
2032
+ return this.ContractAbi({
2033
+ id: objectId
2034
+ });
2035
+
2036
+ case 9:
2037
+ abi = _context22.sent;
2038
+ fromBlock = commit.blockNumber + 1;
2039
+ _context22.next = 13;
2040
+ return this.ExtractValueFromEvent({
2041
+ abi: abi,
2042
+ event: commit,
2043
+ eventName: "CommitPending",
2044
+ eventValue: "objectHash"
2045
+ });
2046
+
2047
+ case 13:
2048
+ objectHash = _context22.sent;
2049
+ _context22.next = 16;
2050
+ return this.CallContractMethod({
2051
+ contractAddress: this.utils.HashToAddress(objectId),
2052
+ methodName: "pendingHash"
2053
+ });
2054
+
2055
+ case 16:
2056
+ pendingHash = _context22.sent;
2057
+
2058
+ if (!(pendingHash && pendingHash !== objectHash)) {
2059
+ _context22.next = 19;
2060
+ break;
2061
+ }
2062
+
2063
+ throw Error("Pending version hash mismatch on ".concat(objectId, ": expected ").concat(objectHash, ", currently ").concat(pendingHash));
2064
+
2065
+ case 19:
2066
+ if (!awaitCommitConfirmation) {
2067
+ _context22.next = 21;
2068
+ break;
2069
+ }
1964
2070
 
1965
- _context21.next = 5;
1966
- return _regeneratorRuntime.awrap(new Promise(function (resolve) {
1967
- return setTimeout(resolve, pollingInterval);
1968
- }));
1969
-
1970
- case 5:
1971
- _context21.next = 7;
1972
- return _regeneratorRuntime.awrap(_this4.ContractEvents({
1973
- contractAddress: _this4.utils.HashToAddress(objectId),
1974
- abi: abi,
1975
- fromBlock: fromBlock,
1976
- count: 1000
1977
- }));
1978
-
1979
- case 7:
1980
- events = _context21.sent;
1981
- confirmEvent = events.find(function (blockEvents) {
1982
- return blockEvents.find(function (event) {
1983
- return objectHash === (event && event.values && event.values.objectHash);
2071
+ return _context22.delegateYield( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21() {
2072
+ var pollingInterval, events, confirmEvent;
2073
+ return _regeneratorRuntime.wrap(function _callee21$(_context21) {
2074
+ while (1) {
2075
+ switch (_context21.prev = _context21.next) {
2076
+ case 0:
2077
+ _this4.Log("Awaiting commit confirmation for ".concat(objectHash));
2078
+
2079
+ pollingInterval = _this4.ethClient.Provider().pollingInterval || 500; // eslint-disable-next-line no-constant-condition
2080
+
2081
+ case 2:
2082
+ if (!true) {
2083
+ _context21.next = 14;
2084
+ break;
2085
+ }
2086
+
2087
+ _context21.next = 5;
2088
+ return new Promise(function (resolve) {
2089
+ return setTimeout(resolve, pollingInterval);
1984
2090
  });
1985
- });
1986
2091
 
1987
- if (!confirmEvent) {
1988
- _context21.next = 12;
1989
- break;
1990
- }
2092
+ case 5:
2093
+ _context21.next = 7;
2094
+ return _this4.ContractEvents({
2095
+ contractAddress: _this4.utils.HashToAddress(objectId),
2096
+ abi: abi,
2097
+ fromBlock: fromBlock,
2098
+ count: 1000
2099
+ });
1991
2100
 
1992
- // Found confirmation
1993
- _this4.Log("Commit confirmed: ".concat(objectHash));
2101
+ case 7:
2102
+ events = _context21.sent;
2103
+ confirmEvent = events.find(function (blockEvents) {
2104
+ return blockEvents.find(function (event) {
2105
+ return objectHash === (event && event.values && event.values.objectHash);
2106
+ });
2107
+ });
2108
+
2109
+ if (!confirmEvent) {
2110
+ _context21.next = 12;
2111
+ break;
2112
+ }
1994
2113
 
1995
- return _context21.abrupt("break", 14);
2114
+ // Found confirmation
2115
+ _this4.Log("Commit confirmed: ".concat(objectHash));
1996
2116
 
1997
- case 12:
1998
- _context21.next = 2;
1999
- break;
2117
+ return _context21.abrupt("break", 14);
2118
+
2119
+ case 12:
2120
+ _context21.next = 2;
2121
+ break;
2000
2122
 
2001
- case 14:
2002
- case "end":
2003
- return _context21.stop();
2123
+ case 14:
2124
+ case "end":
2125
+ return _context21.stop();
2126
+ }
2004
2127
  }
2005
- }
2006
- });
2007
- }());
2128
+ }, _callee21);
2129
+ })(), "t0", 21);
2008
2130
 
2009
- case 22:
2010
- case "end":
2011
- return _context22.stop();
2131
+ case 21:
2132
+ case "end":
2133
+ return _context22.stop();
2134
+ }
2012
2135
  }
2013
- }
2014
- }, null, this);
2015
- };
2136
+ }, _callee22, this);
2137
+ }));
2138
+
2139
+ return function (_x20) {
2140
+ return _ref38.apply(this, arguments);
2141
+ };
2142
+ }();
2016
2143
  /**
2017
2144
  * Delete specified version of the content object
2018
2145
  *
@@ -2022,31 +2149,37 @@ exports.PublishContentVersion = function _callee20(_ref23) {
2022
2149
  */
2023
2150
 
2024
2151
 
2025
- exports.DeleteContentVersion = function _callee21(_ref24) {
2026
- var versionHash, _this$utils$DecodeVer, objectId;
2027
-
2028
- return _regeneratorRuntime.async(function _callee21$(_context23) {
2029
- while (1) {
2030
- switch (_context23.prev = _context23.next) {
2031
- case 0:
2032
- versionHash = _ref24.versionHash;
2033
- ValidateVersion(versionHash);
2034
- this.Log("Deleting content version: ".concat(versionHash));
2035
- _this$utils$DecodeVer = this.utils.DecodeVersionHash(versionHash), objectId = _this$utils$DecodeVer.objectId;
2036
- _context23.next = 6;
2037
- return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
2038
- contractAddress: this.utils.HashToAddress(objectId),
2039
- methodName: "deleteVersion",
2040
- methodArgs: [versionHash]
2041
- }));
2042
-
2043
- case 6:
2044
- case "end":
2045
- return _context23.stop();
2152
+ exports.DeleteContentVersion = /*#__PURE__*/function () {
2153
+ var _ref40 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref39) {
2154
+ var versionHash, _this$utils$DecodeVer, objectId;
2155
+
2156
+ return _regeneratorRuntime.wrap(function _callee23$(_context23) {
2157
+ while (1) {
2158
+ switch (_context23.prev = _context23.next) {
2159
+ case 0:
2160
+ versionHash = _ref39.versionHash;
2161
+ ValidateVersion(versionHash);
2162
+ this.Log("Deleting content version: ".concat(versionHash));
2163
+ _this$utils$DecodeVer = this.utils.DecodeVersionHash(versionHash), objectId = _this$utils$DecodeVer.objectId;
2164
+ _context23.next = 6;
2165
+ return this.CallContractMethodAndWait({
2166
+ contractAddress: this.utils.HashToAddress(objectId),
2167
+ methodName: "deleteVersion",
2168
+ methodArgs: [versionHash]
2169
+ });
2170
+
2171
+ case 6:
2172
+ case "end":
2173
+ return _context23.stop();
2174
+ }
2046
2175
  }
2047
- }
2048
- }, null, this);
2049
- };
2176
+ }, _callee23, this);
2177
+ }));
2178
+
2179
+ return function (_x21) {
2180
+ return _ref40.apply(this, arguments);
2181
+ };
2182
+ }();
2050
2183
  /**
2051
2184
  * Delete specified content object
2052
2185
  *
@@ -2057,32 +2190,38 @@ exports.DeleteContentVersion = function _callee21(_ref24) {
2057
2190
  */
2058
2191
 
2059
2192
 
2060
- exports.DeleteContentObject = function _callee22(_ref25) {
2061
- var libraryId, objectId;
2062
- return _regeneratorRuntime.async(function _callee22$(_context24) {
2063
- while (1) {
2064
- switch (_context24.prev = _context24.next) {
2065
- case 0:
2066
- libraryId = _ref25.libraryId, objectId = _ref25.objectId;
2067
- ValidateParameters({
2068
- libraryId: libraryId,
2069
- objectId: objectId
2070
- });
2071
- this.Log("Deleting content version: ".concat(libraryId, " ").concat(objectId));
2072
- _context24.next = 5;
2073
- return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
2074
- contractAddress: this.utils.HashToAddress(libraryId),
2075
- methodName: "deleteContent",
2076
- methodArgs: [this.utils.HashToAddress(objectId)]
2077
- }));
2078
-
2079
- case 5:
2080
- case "end":
2081
- return _context24.stop();
2193
+ exports.DeleteContentObject = /*#__PURE__*/function () {
2194
+ var _ref42 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref41) {
2195
+ var libraryId, objectId;
2196
+ return _regeneratorRuntime.wrap(function _callee24$(_context24) {
2197
+ while (1) {
2198
+ switch (_context24.prev = _context24.next) {
2199
+ case 0:
2200
+ libraryId = _ref41.libraryId, objectId = _ref41.objectId;
2201
+ ValidateParameters({
2202
+ libraryId: libraryId,
2203
+ objectId: objectId
2204
+ });
2205
+ this.Log("Deleting content version: ".concat(libraryId, " ").concat(objectId));
2206
+ _context24.next = 5;
2207
+ return this.CallContractMethodAndWait({
2208
+ contractAddress: this.utils.HashToAddress(libraryId),
2209
+ methodName: "deleteContent",
2210
+ methodArgs: [this.utils.HashToAddress(objectId)]
2211
+ });
2212
+
2213
+ case 5:
2214
+ case "end":
2215
+ return _context24.stop();
2216
+ }
2082
2217
  }
2083
- }
2084
- }, null, this);
2085
- };
2218
+ }, _callee24, this);
2219
+ }));
2220
+
2221
+ return function (_x22) {
2222
+ return _ref42.apply(this, arguments);
2223
+ };
2224
+ }();
2086
2225
  /* Content object metadata */
2087
2226
 
2088
2227
  /**
@@ -2098,53 +2237,57 @@ exports.DeleteContentObject = function _callee22(_ref25) {
2098
2237
  */
2099
2238
 
2100
2239
 
2101
- exports.MergeMetadata = function _callee23(_ref26) {
2102
- var libraryId, objectId, writeToken, _ref26$metadataSubtre, metadataSubtree, _ref26$metadata, metadata, path;
2103
-
2104
- return _regeneratorRuntime.async(function _callee23$(_context25) {
2105
- while (1) {
2106
- switch (_context25.prev = _context25.next) {
2107
- case 0:
2108
- libraryId = _ref26.libraryId, objectId = _ref26.objectId, writeToken = _ref26.writeToken, _ref26$metadataSubtre = _ref26.metadataSubtree, metadataSubtree = _ref26$metadataSubtre === void 0 ? "/" : _ref26$metadataSubtre, _ref26$metadata = _ref26.metadata, metadata = _ref26$metadata === void 0 ? {} : _ref26$metadata;
2109
- ValidateParameters({
2110
- libraryId: libraryId,
2111
- objectId: objectId
2112
- });
2113
- ValidateWriteToken(writeToken);
2114
- this.Log("Merging metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
2115
- this.Log(metadata);
2116
- path = UrlJoin("q", writeToken, "meta", metadataSubtree);
2117
- _context25.t0 = _regeneratorRuntime;
2118
- _context25.t1 = this.HttpClient;
2119
- _context25.next = 10;
2120
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
2121
- libraryId: libraryId,
2122
- objectId: objectId,
2123
- update: true
2124
- }));
2125
-
2126
- case 10:
2127
- _context25.t2 = _context25.sent;
2128
- _context25.t3 = path;
2129
- _context25.t4 = metadata;
2130
- _context25.t5 = {
2131
- headers: _context25.t2,
2132
- method: "POST",
2133
- path: _context25.t3,
2134
- body: _context25.t4,
2135
- failover: false
2136
- };
2137
- _context25.t6 = _context25.t1.Request.call(_context25.t1, _context25.t5);
2138
- _context25.next = 17;
2139
- return _context25.t0.awrap.call(_context25.t0, _context25.t6);
2140
-
2141
- case 17:
2142
- case "end":
2143
- return _context25.stop();
2240
+ exports.MergeMetadata = /*#__PURE__*/function () {
2241
+ var _ref44 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref43) {
2242
+ var libraryId, objectId, writeToken, _ref43$metadataSubtre, metadataSubtree, _ref43$metadata, metadata, path;
2243
+
2244
+ return _regeneratorRuntime.wrap(function _callee25$(_context25) {
2245
+ while (1) {
2246
+ switch (_context25.prev = _context25.next) {
2247
+ case 0:
2248
+ libraryId = _ref43.libraryId, objectId = _ref43.objectId, writeToken = _ref43.writeToken, _ref43$metadataSubtre = _ref43.metadataSubtree, metadataSubtree = _ref43$metadataSubtre === void 0 ? "/" : _ref43$metadataSubtre, _ref43$metadata = _ref43.metadata, metadata = _ref43$metadata === void 0 ? {} : _ref43$metadata;
2249
+ ValidateParameters({
2250
+ libraryId: libraryId,
2251
+ objectId: objectId
2252
+ });
2253
+ ValidateWriteToken(writeToken);
2254
+ this.Log("Merging metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
2255
+ this.Log(metadata);
2256
+ path = UrlJoin("q", writeToken, "meta", metadataSubtree);
2257
+ _context25.t0 = this.HttpClient;
2258
+ _context25.next = 9;
2259
+ return this.authClient.AuthorizationHeader({
2260
+ libraryId: libraryId,
2261
+ objectId: objectId,
2262
+ update: true
2263
+ });
2264
+
2265
+ case 9:
2266
+ _context25.t1 = _context25.sent;
2267
+ _context25.t2 = path;
2268
+ _context25.t3 = metadata;
2269
+ _context25.t4 = {
2270
+ headers: _context25.t1,
2271
+ method: "POST",
2272
+ path: _context25.t2,
2273
+ body: _context25.t3,
2274
+ failover: false
2275
+ };
2276
+ _context25.next = 15;
2277
+ return _context25.t0.Request.call(_context25.t0, _context25.t4);
2278
+
2279
+ case 15:
2280
+ case "end":
2281
+ return _context25.stop();
2282
+ }
2144
2283
  }
2145
- }
2146
- }, null, this);
2147
- };
2284
+ }, _callee25, this);
2285
+ }));
2286
+
2287
+ return function (_x23) {
2288
+ return _ref44.apply(this, arguments);
2289
+ };
2290
+ }();
2148
2291
  /**
2149
2292
  * Replace content object metadata with specified metadata
2150
2293
  *
@@ -2158,53 +2301,57 @@ exports.MergeMetadata = function _callee23(_ref26) {
2158
2301
  */
2159
2302
 
2160
2303
 
2161
- exports.ReplaceMetadata = function _callee24(_ref27) {
2162
- var libraryId, objectId, writeToken, _ref27$metadataSubtre, metadataSubtree, _ref27$metadata, metadata, path;
2163
-
2164
- return _regeneratorRuntime.async(function _callee24$(_context26) {
2165
- while (1) {
2166
- switch (_context26.prev = _context26.next) {
2167
- case 0:
2168
- libraryId = _ref27.libraryId, objectId = _ref27.objectId, writeToken = _ref27.writeToken, _ref27$metadataSubtre = _ref27.metadataSubtree, metadataSubtree = _ref27$metadataSubtre === void 0 ? "/" : _ref27$metadataSubtre, _ref27$metadata = _ref27.metadata, metadata = _ref27$metadata === void 0 ? {} : _ref27$metadata;
2169
- ValidateParameters({
2170
- libraryId: libraryId,
2171
- objectId: objectId
2172
- });
2173
- ValidateWriteToken(writeToken);
2174
- this.Log("Replacing metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
2175
- this.Log(metadata);
2176
- path = UrlJoin("q", writeToken, "meta", metadataSubtree);
2177
- _context26.t0 = _regeneratorRuntime;
2178
- _context26.t1 = this.HttpClient;
2179
- _context26.next = 10;
2180
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
2181
- libraryId: libraryId,
2182
- objectId: objectId,
2183
- update: true
2184
- }));
2185
-
2186
- case 10:
2187
- _context26.t2 = _context26.sent;
2188
- _context26.t3 = path;
2189
- _context26.t4 = metadata;
2190
- _context26.t5 = {
2191
- headers: _context26.t2,
2192
- method: "PUT",
2193
- path: _context26.t3,
2194
- body: _context26.t4,
2195
- failover: false
2196
- };
2197
- _context26.t6 = _context26.t1.Request.call(_context26.t1, _context26.t5);
2198
- _context26.next = 17;
2199
- return _context26.t0.awrap.call(_context26.t0, _context26.t6);
2200
-
2201
- case 17:
2202
- case "end":
2203
- return _context26.stop();
2304
+ exports.ReplaceMetadata = /*#__PURE__*/function () {
2305
+ var _ref46 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref45) {
2306
+ var libraryId, objectId, writeToken, _ref45$metadataSubtre, metadataSubtree, _ref45$metadata, metadata, path;
2307
+
2308
+ return _regeneratorRuntime.wrap(function _callee26$(_context26) {
2309
+ while (1) {
2310
+ switch (_context26.prev = _context26.next) {
2311
+ case 0:
2312
+ libraryId = _ref45.libraryId, objectId = _ref45.objectId, writeToken = _ref45.writeToken, _ref45$metadataSubtre = _ref45.metadataSubtree, metadataSubtree = _ref45$metadataSubtre === void 0 ? "/" : _ref45$metadataSubtre, _ref45$metadata = _ref45.metadata, metadata = _ref45$metadata === void 0 ? {} : _ref45$metadata;
2313
+ ValidateParameters({
2314
+ libraryId: libraryId,
2315
+ objectId: objectId
2316
+ });
2317
+ ValidateWriteToken(writeToken);
2318
+ this.Log("Replacing metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
2319
+ this.Log(metadata);
2320
+ path = UrlJoin("q", writeToken, "meta", metadataSubtree);
2321
+ _context26.t0 = this.HttpClient;
2322
+ _context26.next = 9;
2323
+ return this.authClient.AuthorizationHeader({
2324
+ libraryId: libraryId,
2325
+ objectId: objectId,
2326
+ update: true
2327
+ });
2328
+
2329
+ case 9:
2330
+ _context26.t1 = _context26.sent;
2331
+ _context26.t2 = path;
2332
+ _context26.t3 = metadata;
2333
+ _context26.t4 = {
2334
+ headers: _context26.t1,
2335
+ method: "PUT",
2336
+ path: _context26.t2,
2337
+ body: _context26.t3,
2338
+ failover: false
2339
+ };
2340
+ _context26.next = 15;
2341
+ return _context26.t0.Request.call(_context26.t0, _context26.t4);
2342
+
2343
+ case 15:
2344
+ case "end":
2345
+ return _context26.stop();
2346
+ }
2204
2347
  }
2205
- }
2206
- }, null, this);
2207
- };
2348
+ }, _callee26, this);
2349
+ }));
2350
+
2351
+ return function (_x24) {
2352
+ return _ref46.apply(this, arguments);
2353
+ };
2354
+ }();
2208
2355
  /**
2209
2356
  * Delete content object metadata of specified subtree
2210
2357
  *
@@ -2218,51 +2365,55 @@ exports.ReplaceMetadata = function _callee24(_ref27) {
2218
2365
  */
2219
2366
 
2220
2367
 
2221
- exports.DeleteMetadata = function _callee25(_ref28) {
2222
- var libraryId, objectId, writeToken, _ref28$metadataSubtre, metadataSubtree, path;
2223
-
2224
- return _regeneratorRuntime.async(function _callee25$(_context27) {
2225
- while (1) {
2226
- switch (_context27.prev = _context27.next) {
2227
- case 0:
2228
- libraryId = _ref28.libraryId, objectId = _ref28.objectId, writeToken = _ref28.writeToken, _ref28$metadataSubtre = _ref28.metadataSubtree, metadataSubtree = _ref28$metadataSubtre === void 0 ? "/" : _ref28$metadataSubtre;
2229
- ValidateParameters({
2230
- libraryId: libraryId,
2231
- objectId: objectId
2232
- });
2233
- ValidateWriteToken(writeToken);
2234
- this.Log("Deleting metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
2235
- this.Log("Subtree: ".concat(metadataSubtree));
2236
- path = UrlJoin("q", writeToken, "meta", metadataSubtree);
2237
- _context27.t0 = _regeneratorRuntime;
2238
- _context27.t1 = this.HttpClient;
2239
- _context27.next = 10;
2240
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
2241
- libraryId: libraryId,
2242
- objectId: objectId,
2243
- update: true
2244
- }));
2245
-
2246
- case 10:
2247
- _context27.t2 = _context27.sent;
2248
- _context27.t3 = path;
2249
- _context27.t4 = {
2250
- headers: _context27.t2,
2251
- method: "DELETE",
2252
- path: _context27.t3,
2253
- failover: false
2254
- };
2255
- _context27.t5 = _context27.t1.Request.call(_context27.t1, _context27.t4);
2256
- _context27.next = 16;
2257
- return _context27.t0.awrap.call(_context27.t0, _context27.t5);
2258
-
2259
- case 16:
2260
- case "end":
2261
- return _context27.stop();
2368
+ exports.DeleteMetadata = /*#__PURE__*/function () {
2369
+ var _ref48 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref47) {
2370
+ var libraryId, objectId, writeToken, _ref47$metadataSubtre, metadataSubtree, path;
2371
+
2372
+ return _regeneratorRuntime.wrap(function _callee27$(_context27) {
2373
+ while (1) {
2374
+ switch (_context27.prev = _context27.next) {
2375
+ case 0:
2376
+ libraryId = _ref47.libraryId, objectId = _ref47.objectId, writeToken = _ref47.writeToken, _ref47$metadataSubtre = _ref47.metadataSubtree, metadataSubtree = _ref47$metadataSubtre === void 0 ? "/" : _ref47$metadataSubtre;
2377
+ ValidateParameters({
2378
+ libraryId: libraryId,
2379
+ objectId: objectId
2380
+ });
2381
+ ValidateWriteToken(writeToken);
2382
+ this.Log("Deleting metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
2383
+ this.Log("Subtree: ".concat(metadataSubtree));
2384
+ path = UrlJoin("q", writeToken, "meta", metadataSubtree);
2385
+ _context27.t0 = this.HttpClient;
2386
+ _context27.next = 9;
2387
+ return this.authClient.AuthorizationHeader({
2388
+ libraryId: libraryId,
2389
+ objectId: objectId,
2390
+ update: true
2391
+ });
2392
+
2393
+ case 9:
2394
+ _context27.t1 = _context27.sent;
2395
+ _context27.t2 = path;
2396
+ _context27.t3 = {
2397
+ headers: _context27.t1,
2398
+ method: "DELETE",
2399
+ path: _context27.t2,
2400
+ failover: false
2401
+ };
2402
+ _context27.next = 14;
2403
+ return _context27.t0.Request.call(_context27.t0, _context27.t3);
2404
+
2405
+ case 14:
2406
+ case "end":
2407
+ return _context27.stop();
2408
+ }
2262
2409
  }
2263
- }
2264
- }, null, this);
2265
- };
2410
+ }, _callee27, this);
2411
+ }));
2412
+
2413
+ return function (_x25) {
2414
+ return _ref48.apply(this, arguments);
2415
+ };
2416
+ }();
2266
2417
  /**
2267
2418
  * Set the access charge for the specified object
2268
2419
  *
@@ -2273,29 +2424,35 @@ exports.DeleteMetadata = function _callee25(_ref28) {
2273
2424
  */
2274
2425
 
2275
2426
 
2276
- exports.SetAccessCharge = function _callee26(_ref29) {
2277
- var objectId, accessCharge;
2278
- return _regeneratorRuntime.async(function _callee26$(_context28) {
2279
- while (1) {
2280
- switch (_context28.prev = _context28.next) {
2281
- case 0:
2282
- objectId = _ref29.objectId, accessCharge = _ref29.accessCharge;
2283
- ValidateObject(objectId);
2284
- this.Log("Setting access charge: ".concat(objectId, " ").concat(accessCharge));
2285
- _context28.next = 5;
2286
- return _regeneratorRuntime.awrap(this.ethClient.CallContractMethodAndWait({
2287
- contractAddress: this.utils.HashToAddress(objectId),
2288
- methodName: "setAccessCharge",
2289
- methodArgs: [this.utils.EtherToWei(accessCharge).toString()]
2290
- }));
2291
-
2292
- case 5:
2293
- case "end":
2294
- return _context28.stop();
2427
+ exports.SetAccessCharge = /*#__PURE__*/function () {
2428
+ var _ref50 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref49) {
2429
+ var objectId, accessCharge;
2430
+ return _regeneratorRuntime.wrap(function _callee28$(_context28) {
2431
+ while (1) {
2432
+ switch (_context28.prev = _context28.next) {
2433
+ case 0:
2434
+ objectId = _ref49.objectId, accessCharge = _ref49.accessCharge;
2435
+ ValidateObject(objectId);
2436
+ this.Log("Setting access charge: ".concat(objectId, " ").concat(accessCharge));
2437
+ _context28.next = 5;
2438
+ return this.ethClient.CallContractMethodAndWait({
2439
+ contractAddress: this.utils.HashToAddress(objectId),
2440
+ methodName: "setAccessCharge",
2441
+ methodArgs: [this.utils.EtherToWei(accessCharge).toString()]
2442
+ });
2443
+
2444
+ case 5:
2445
+ case "end":
2446
+ return _context28.stop();
2447
+ }
2295
2448
  }
2296
- }
2297
- }, null, this);
2298
- };
2449
+ }, _callee28, this);
2450
+ }));
2451
+
2452
+ return function (_x26) {
2453
+ return _ref50.apply(this, arguments);
2454
+ };
2455
+ }();
2299
2456
  /**
2300
2457
  * Recursively update all auto_update links in the specified object.
2301
2458
  *
@@ -2311,179 +2468,190 @@ exports.SetAccessCharge = function _callee26(_ref29) {
2311
2468
  */
2312
2469
 
2313
2470
 
2314
- exports.UpdateContentObjectGraph = function _callee28(_ref30) {
2315
- var _this5 = this;
2316
-
2317
- var libraryId, objectId, versionHash, callback, total, completed, _loop, _ret;
2318
-
2319
- return _regeneratorRuntime.async(function _callee28$(_context31) {
2320
- while (1) {
2321
- switch (_context31.prev = _context31.next) {
2322
- case 0:
2323
- libraryId = _ref30.libraryId, objectId = _ref30.objectId, versionHash = _ref30.versionHash, callback = _ref30.callback;
2324
- ValidateParameters({
2325
- libraryId: libraryId,
2326
- objectId: objectId,
2327
- versionHash: versionHash
2328
- });
2329
- this.Log("Updating content object graph: ".concat(libraryId || "", " ").concat(objectId || versionHash));
2330
-
2331
- if (versionHash) {
2332
- objectId = this.utils.DecodeVersionHash(versionHash).objectId;
2333
- }
2334
-
2335
- completed = 0; // eslint-disable-next-line no-constant-condition
2336
-
2337
- _loop = function _loop() {
2338
- var graph, currentHash, links, details, name, currentLibraryId, currentObjectId, _ref31, write_token, _ref33, hash;
2339
-
2340
- return _regeneratorRuntime.async(function _loop$(_context30) {
2341
- while (1) {
2342
- switch (_context30.prev = _context30.next) {
2343
- case 0:
2344
- _context30.next = 2;
2345
- return _regeneratorRuntime.awrap(_this5.ContentObjectGraph({
2346
- libraryId: libraryId,
2347
- objectId: objectId,
2348
- versionHash: versionHash,
2349
- autoUpdate: true,
2350
- select: ["name", "public/name", "public/asset_metadata/display_title"]
2351
- }));
2352
-
2353
- case 2:
2354
- graph = _context30.sent;
2355
-
2356
- if (!(Object.keys(graph.auto_updates).length === 0)) {
2357
- _context30.next = 6;
2358
- break;
2359
- }
2471
+ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
2472
+ var _ref52 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(_ref51) {
2473
+ var _this5 = this;
2360
2474
 
2361
- _this5.Log("No more updates required");
2475
+ var libraryId, objectId, versionHash, callback, total, completed, _loop, _ret;
2362
2476
 
2363
- return _context30.abrupt("return", {
2364
- v: void 0
2365
- });
2477
+ return _regeneratorRuntime.wrap(function _callee30$(_context31) {
2478
+ while (1) {
2479
+ switch (_context31.prev = _context31.next) {
2480
+ case 0:
2481
+ libraryId = _ref51.libraryId, objectId = _ref51.objectId, versionHash = _ref51.versionHash, callback = _ref51.callback;
2482
+ ValidateParameters({
2483
+ libraryId: libraryId,
2484
+ objectId: objectId,
2485
+ versionHash: versionHash
2486
+ });
2487
+ this.Log("Updating content object graph: ".concat(libraryId || "", " ").concat(objectId || versionHash));
2366
2488
 
2367
- case 6:
2368
- if (!total) {
2369
- total = graph.auto_updates.order.length;
2370
- }
2489
+ if (versionHash) {
2490
+ objectId = this.utils.DecodeVersionHash(versionHash).objectId;
2491
+ }
2492
+
2493
+ completed = 0; // eslint-disable-next-line no-constant-condition
2494
+
2495
+ _loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
2496
+ var graph, currentHash, links, details, name, currentLibraryId, currentObjectId, _yield$_this5$EditCon, write_token, _yield$_this5$Finaliz, hash;
2371
2497
 
2372
- currentHash = graph.auto_updates.order[0];
2373
- links = graph.auto_updates.links[currentHash];
2374
- details = graph.details[currentHash].meta || {};
2375
- name = details["public"] && details["public"].asset_metadata && details["public"].asset_metadata.display_title || details["public"] && details["public"].name || details.name || versionHash || objectId;
2376
- _context30.next = 13;
2377
- return _regeneratorRuntime.awrap(_this5.ContentObjectLibraryId({
2378
- versionHash: currentHash
2379
- }));
2380
-
2381
- case 13:
2382
- currentLibraryId = _context30.sent;
2383
- currentObjectId = _this5.utils.DecodeVersionHash(currentHash).objectId;
2384
-
2385
- if (callback) {
2386
- callback({
2387
- completed: completed,
2388
- total: total,
2389
- action: "Updating ".concat(name, " (").concat(currentObjectId, ")...")
2498
+ return _regeneratorRuntime.wrap(function _loop$(_context30) {
2499
+ while (1) {
2500
+ switch (_context30.prev = _context30.next) {
2501
+ case 0:
2502
+ _context30.next = 2;
2503
+ return _this5.ContentObjectGraph({
2504
+ libraryId: libraryId,
2505
+ objectId: objectId,
2506
+ versionHash: versionHash,
2507
+ autoUpdate: true,
2508
+ select: ["name", "public/name", "public/asset_metadata/display_title"]
2390
2509
  });
2391
- }
2392
2510
 
2393
- _this5.Log("Updating links for ".concat(name, " (").concat(currentObjectId, " / ").concat(currentHash, ")"));
2394
-
2395
- _context30.next = 19;
2396
- return _regeneratorRuntime.awrap(_this5.EditContentObject({
2397
- libraryId: currentLibraryId,
2398
- objectId: currentObjectId
2399
- }));
2400
-
2401
- case 19:
2402
- _ref31 = _context30.sent;
2403
- write_token = _ref31.write_token;
2404
- _context30.next = 23;
2405
- return _regeneratorRuntime.awrap(Promise.all(links.map(function _callee27(_ref32) {
2406
- var path, updated;
2407
- return _regeneratorRuntime.async(function _callee27$(_context29) {
2408
- while (1) {
2409
- switch (_context29.prev = _context29.next) {
2410
- case 0:
2411
- path = _ref32.path, updated = _ref32.updated;
2412
- _context29.next = 3;
2413
- return _regeneratorRuntime.awrap(_this5.ReplaceMetadata({
2414
- libraryId: currentLibraryId,
2415
- objectId: currentObjectId,
2416
- writeToken: write_token,
2417
- metadataSubtree: path,
2418
- metadata: updated
2419
- }));
2420
-
2421
- case 3:
2422
- case "end":
2423
- return _context29.stop();
2424
- }
2425
- }
2511
+ case 2:
2512
+ graph = _context30.sent;
2513
+
2514
+ if (!(Object.keys(graph.auto_updates).length === 0)) {
2515
+ _context30.next = 6;
2516
+ break;
2517
+ }
2518
+
2519
+ _this5.Log("No more updates required");
2520
+
2521
+ return _context30.abrupt("return", {
2522
+ v: void 0
2426
2523
  });
2427
- })));
2428
-
2429
- case 23:
2430
- _context30.next = 25;
2431
- return _regeneratorRuntime.awrap(_this5.FinalizeContentObject({
2432
- libraryId: currentLibraryId,
2433
- objectId: currentObjectId,
2434
- writeToken: write_token,
2435
- commitMessage: "Update links"
2436
- }));
2437
-
2438
- case 25:
2439
- _ref33 = _context30.sent;
2440
- hash = _ref33.hash;
2441
-
2442
- // If root object was specified by hash and updated, update hash
2443
- if (currentHash === versionHash) {
2444
- versionHash = hash;
2445
- }
2446
2524
 
2447
- completed += 1;
2525
+ case 6:
2526
+ if (!total) {
2527
+ total = graph.auto_updates.order.length;
2528
+ }
2529
+
2530
+ currentHash = graph.auto_updates.order[0];
2531
+ links = graph.auto_updates.links[currentHash];
2532
+ details = graph.details[currentHash].meta || {};
2533
+ name = details["public"] && details["public"].asset_metadata && details["public"].asset_metadata.display_title || details["public"] && details["public"].name || details.name || versionHash || objectId;
2534
+ _context30.next = 13;
2535
+ return _this5.ContentObjectLibraryId({
2536
+ versionHash: currentHash
2537
+ });
2538
+
2539
+ case 13:
2540
+ currentLibraryId = _context30.sent;
2541
+ currentObjectId = _this5.utils.DecodeVersionHash(currentHash).objectId;
2542
+
2543
+ if (callback) {
2544
+ callback({
2545
+ completed: completed,
2546
+ total: total,
2547
+ action: "Updating ".concat(name, " (").concat(currentObjectId, ")...")
2548
+ });
2549
+ }
2550
+
2551
+ _this5.Log("Updating links for ".concat(name, " (").concat(currentObjectId, " / ").concat(currentHash, ")"));
2448
2552
 
2449
- case 29:
2450
- case "end":
2451
- return _context30.stop();
2553
+ _context30.next = 19;
2554
+ return _this5.EditContentObject({
2555
+ libraryId: currentLibraryId,
2556
+ objectId: currentObjectId
2557
+ });
2558
+
2559
+ case 19:
2560
+ _yield$_this5$EditCon = _context30.sent;
2561
+ write_token = _yield$_this5$EditCon.write_token;
2562
+ _context30.next = 23;
2563
+ return Promise.all(links.map( /*#__PURE__*/function () {
2564
+ var _ref54 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(_ref53) {
2565
+ var path, updated;
2566
+ return _regeneratorRuntime.wrap(function _callee29$(_context29) {
2567
+ while (1) {
2568
+ switch (_context29.prev = _context29.next) {
2569
+ case 0:
2570
+ path = _ref53.path, updated = _ref53.updated;
2571
+ _context29.next = 3;
2572
+ return _this5.ReplaceMetadata({
2573
+ libraryId: currentLibraryId,
2574
+ objectId: currentObjectId,
2575
+ writeToken: write_token,
2576
+ metadataSubtree: path,
2577
+ metadata: updated
2578
+ });
2579
+
2580
+ case 3:
2581
+ case "end":
2582
+ return _context29.stop();
2583
+ }
2584
+ }
2585
+ }, _callee29);
2586
+ }));
2587
+
2588
+ return function (_x28) {
2589
+ return _ref54.apply(this, arguments);
2590
+ };
2591
+ }()));
2592
+
2593
+ case 23:
2594
+ _context30.next = 25;
2595
+ return _this5.FinalizeContentObject({
2596
+ libraryId: currentLibraryId,
2597
+ objectId: currentObjectId,
2598
+ writeToken: write_token,
2599
+ commitMessage: "Update links"
2600
+ });
2601
+
2602
+ case 25:
2603
+ _yield$_this5$Finaliz = _context30.sent;
2604
+ hash = _yield$_this5$Finaliz.hash;
2605
+
2606
+ // If root object was specified by hash and updated, update hash
2607
+ if (currentHash === versionHash) {
2608
+ versionHash = hash;
2609
+ }
2610
+
2611
+ completed += 1;
2612
+
2613
+ case 29:
2614
+ case "end":
2615
+ return _context30.stop();
2616
+ }
2452
2617
  }
2453
- }
2618
+ }, _loop);
2454
2619
  });
2455
- };
2456
2620
 
2457
- case 6:
2458
- if (!1) {
2459
- _context31.next = 14;
2460
- break;
2461
- }
2621
+ case 6:
2622
+ if (!1) {
2623
+ _context31.next = 13;
2624
+ break;
2625
+ }
2462
2626
 
2463
- _context31.next = 9;
2464
- return _regeneratorRuntime.awrap(_loop());
2627
+ return _context31.delegateYield(_loop(), "t0", 8);
2465
2628
 
2466
- case 9:
2467
- _ret = _context31.sent;
2629
+ case 8:
2630
+ _ret = _context31.t0;
2468
2631
 
2469
- if (!(_typeof(_ret) === "object")) {
2470
- _context31.next = 12;
2471
- break;
2472
- }
2632
+ if (!(_typeof(_ret) === "object")) {
2633
+ _context31.next = 11;
2634
+ break;
2635
+ }
2473
2636
 
2474
- return _context31.abrupt("return", _ret.v);
2637
+ return _context31.abrupt("return", _ret.v);
2475
2638
 
2476
- case 12:
2477
- _context31.next = 6;
2478
- break;
2639
+ case 11:
2640
+ _context31.next = 6;
2641
+ break;
2479
2642
 
2480
- case 14:
2481
- case "end":
2482
- return _context31.stop();
2643
+ case 13:
2644
+ case "end":
2645
+ return _context31.stop();
2646
+ }
2483
2647
  }
2484
- }
2485
- }, null, this);
2486
- };
2648
+ }, _callee30, this);
2649
+ }));
2650
+
2651
+ return function (_x27) {
2652
+ return _ref52.apply(this, arguments);
2653
+ };
2654
+ }();
2487
2655
  /**
2488
2656
  * Create links to files, metadata and/or representations of this or or other
2489
2657
  * content objects.
@@ -2510,79 +2678,91 @@ exports.UpdateContentObjectGraph = function _callee28(_ref30) {
2510
2678
  */
2511
2679
 
2512
2680
 
2513
- exports.CreateLinks = function _callee30(_ref34) {
2514
- var _this6 = this;
2515
-
2516
- var libraryId, objectId, writeToken, _ref34$links, links;
2517
-
2518
- return _regeneratorRuntime.async(function _callee30$(_context33) {
2519
- while (1) {
2520
- switch (_context33.prev = _context33.next) {
2521
- case 0:
2522
- libraryId = _ref34.libraryId, objectId = _ref34.objectId, writeToken = _ref34.writeToken, _ref34$links = _ref34.links, links = _ref34$links === void 0 ? [] : _ref34$links;
2523
- ValidateParameters({
2524
- libraryId: libraryId,
2525
- objectId: objectId
2526
- });
2527
- ValidateWriteToken(writeToken);
2528
- _context33.next = 5;
2529
- return _regeneratorRuntime.awrap(this.utils.LimitedMap(10, links, function _callee29(info) {
2530
- var path, type, target, link;
2531
- return _regeneratorRuntime.async(function _callee29$(_context32) {
2532
- while (1) {
2533
- switch (_context32.prev = _context32.next) {
2534
- case 0:
2535
- path = info.path.replace(/^(\/|\.)+/, "");
2536
- type = (info.type || "file") === "file" ? "files" : info.type;
2537
-
2538
- if (type === "metadata") {
2539
- type = "meta";
2540
- }
2681
+ exports.CreateLinks = /*#__PURE__*/function () {
2682
+ var _ref56 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(_ref55) {
2683
+ var _this6 = this;
2541
2684
 
2542
- target = info.target.replace(/^(\/|\.)+/, "");
2685
+ var libraryId, objectId, writeToken, _ref55$links, links;
2543
2686
 
2544
- if (info.targetHash) {
2545
- target = "/qfab/".concat(info.targetHash, "/").concat(type, "/").concat(target);
2546
- } else {
2547
- target = "./".concat(type, "/").concat(target);
2548
- }
2687
+ return _regeneratorRuntime.wrap(function _callee32$(_context33) {
2688
+ while (1) {
2689
+ switch (_context33.prev = _context33.next) {
2690
+ case 0:
2691
+ libraryId = _ref55.libraryId, objectId = _ref55.objectId, writeToken = _ref55.writeToken, _ref55$links = _ref55.links, links = _ref55$links === void 0 ? [] : _ref55$links;
2692
+ ValidateParameters({
2693
+ libraryId: libraryId,
2694
+ objectId: objectId
2695
+ });
2696
+ ValidateWriteToken(writeToken);
2697
+ _context33.next = 5;
2698
+ return this.utils.LimitedMap(10, links, /*#__PURE__*/function () {
2699
+ var _ref57 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31(info) {
2700
+ var path, type, target, link;
2701
+ return _regeneratorRuntime.wrap(function _callee31$(_context32) {
2702
+ while (1) {
2703
+ switch (_context32.prev = _context32.next) {
2704
+ case 0:
2705
+ path = info.path.replace(/^(\/|\.)+/, "");
2706
+ type = (info.type || "file") === "file" ? "files" : info.type;
2707
+
2708
+ if (type === "metadata") {
2709
+ type = "meta";
2710
+ }
2549
2711
 
2550
- link = {
2551
- "/": target
2552
- };
2712
+ target = info.target.replace(/^(\/|\.)+/, "");
2553
2713
 
2554
- if (info.autoUpdate) {
2555
- link["."] = {
2556
- auto_update: {
2557
- tag: "latest"
2714
+ if (info.targetHash) {
2715
+ target = "/qfab/".concat(info.targetHash, "/").concat(type, "/").concat(target);
2716
+ } else {
2717
+ target = "./".concat(type, "/").concat(target);
2558
2718
  }
2559
- };
2560
- }
2561
2719
 
2562
- _context32.next = 9;
2563
- return _regeneratorRuntime.awrap(_this6.ReplaceMetadata({
2564
- libraryId: libraryId,
2565
- objectId: objectId,
2566
- writeToken: writeToken,
2567
- metadataSubtree: path,
2568
- metadata: link
2569
- }));
2570
-
2571
- case 9:
2572
- case "end":
2573
- return _context32.stop();
2574
- }
2575
- }
2576
- });
2577
- }));
2720
+ link = {
2721
+ "/": target
2722
+ };
2578
2723
 
2579
- case 5:
2580
- case "end":
2581
- return _context33.stop();
2724
+ if (info.autoUpdate) {
2725
+ link["."] = {
2726
+ auto_update: {
2727
+ tag: "latest"
2728
+ }
2729
+ };
2730
+ }
2731
+
2732
+ _context32.next = 9;
2733
+ return _this6.ReplaceMetadata({
2734
+ libraryId: libraryId,
2735
+ objectId: objectId,
2736
+ writeToken: writeToken,
2737
+ metadataSubtree: path,
2738
+ metadata: link
2739
+ });
2740
+
2741
+ case 9:
2742
+ case "end":
2743
+ return _context32.stop();
2744
+ }
2745
+ }
2746
+ }, _callee31);
2747
+ }));
2748
+
2749
+ return function (_x30) {
2750
+ return _ref57.apply(this, arguments);
2751
+ };
2752
+ }());
2753
+
2754
+ case 5:
2755
+ case "end":
2756
+ return _context33.stop();
2757
+ }
2582
2758
  }
2583
- }
2584
- }, null, this);
2585
- };
2759
+ }, _callee32, this);
2760
+ }));
2761
+
2762
+ return function (_x29) {
2763
+ return _ref56.apply(this, arguments);
2764
+ };
2765
+ }();
2586
2766
  /**
2587
2767
  * Initialize or replace the signed auth policy for the specified object
2588
2768
  *
@@ -2599,56 +2779,62 @@ exports.CreateLinks = function _callee30(_ref34) {
2599
2779
  */
2600
2780
 
2601
2781
 
2602
- exports.InitializeAuthPolicy = function _callee31(_ref35) {
2603
- var libraryId, objectId, writeToken, _ref35$target, target, body, version, description, id, authPolicy, string;
2604
-
2605
- return _regeneratorRuntime.async(function _callee31$(_context34) {
2606
- while (1) {
2607
- switch (_context34.prev = _context34.next) {
2608
- case 0:
2609
- libraryId = _ref35.libraryId, objectId = _ref35.objectId, writeToken = _ref35.writeToken, _ref35$target = _ref35.target, target = _ref35$target === void 0 ? "auth_policy_spec" : _ref35$target, body = _ref35.body, version = _ref35.version, description = _ref35.description, id = _ref35.id;
2610
- authPolicy = {
2611
- type: "epl-ast",
2612
- version: version,
2613
- body: body,
2614
- data: {
2615
- "/": UrlJoin(".", "meta", target)
2616
- },
2617
- signer: "iusr".concat(this.utils.AddressToHash(this.signer.address)),
2618
- description: description || "",
2619
- id: id || ""
2620
- };
2621
- string = "".concat(authPolicy.type, "|").concat(authPolicy.version, "|").concat(authPolicy.body, "|").concat(authPolicy.data["/"]);
2622
- _context34.t0 = this.utils;
2623
- _context34.next = 6;
2624
- return _regeneratorRuntime.awrap(this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string))));
2625
-
2626
- case 6:
2627
- _context34.t1 = _context34.sent;
2628
- authPolicy.signature = _context34.t0.FormatSignature.call(_context34.t0, _context34.t1);
2629
- _context34.next = 10;
2630
- return _regeneratorRuntime.awrap(this.ReplaceMetadata({
2631
- libraryId: libraryId,
2632
- objectId: objectId,
2633
- writeToken: writeToken,
2634
- metadataSubtree: "auth_policy",
2635
- metadata: authPolicy
2636
- }));
2637
-
2638
- case 10:
2639
- _context34.next = 12;
2640
- return _regeneratorRuntime.awrap(this.SetAuthPolicy({
2641
- objectId: objectId,
2642
- policyId: objectId
2643
- }));
2644
-
2645
- case 12:
2646
- case "end":
2647
- return _context34.stop();
2782
+ exports.InitializeAuthPolicy = /*#__PURE__*/function () {
2783
+ var _ref59 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33(_ref58) {
2784
+ var libraryId, objectId, writeToken, _ref58$target, target, body, version, description, id, authPolicy, string;
2785
+
2786
+ return _regeneratorRuntime.wrap(function _callee33$(_context34) {
2787
+ while (1) {
2788
+ switch (_context34.prev = _context34.next) {
2789
+ case 0:
2790
+ libraryId = _ref58.libraryId, objectId = _ref58.objectId, writeToken = _ref58.writeToken, _ref58$target = _ref58.target, target = _ref58$target === void 0 ? "auth_policy_spec" : _ref58$target, body = _ref58.body, version = _ref58.version, description = _ref58.description, id = _ref58.id;
2791
+ authPolicy = {
2792
+ type: "epl-ast",
2793
+ version: version,
2794
+ body: body,
2795
+ data: {
2796
+ "/": UrlJoin(".", "meta", target)
2797
+ },
2798
+ signer: "iusr".concat(this.utils.AddressToHash(this.signer.address)),
2799
+ description: description || "",
2800
+ id: id || ""
2801
+ };
2802
+ string = "".concat(authPolicy.type, "|").concat(authPolicy.version, "|").concat(authPolicy.body, "|").concat(authPolicy.data["/"]);
2803
+ _context34.t0 = this.utils;
2804
+ _context34.next = 6;
2805
+ return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
2806
+
2807
+ case 6:
2808
+ _context34.t1 = _context34.sent;
2809
+ authPolicy.signature = _context34.t0.FormatSignature.call(_context34.t0, _context34.t1);
2810
+ _context34.next = 10;
2811
+ return this.ReplaceMetadata({
2812
+ libraryId: libraryId,
2813
+ objectId: objectId,
2814
+ writeToken: writeToken,
2815
+ metadataSubtree: "auth_policy",
2816
+ metadata: authPolicy
2817
+ });
2818
+
2819
+ case 10:
2820
+ _context34.next = 12;
2821
+ return this.SetAuthPolicy({
2822
+ objectId: objectId,
2823
+ policyId: objectId
2824
+ });
2825
+
2826
+ case 12:
2827
+ case "end":
2828
+ return _context34.stop();
2829
+ }
2648
2830
  }
2649
- }
2650
- }, null, this);
2651
- };
2831
+ }, _callee33, this);
2832
+ }));
2833
+
2834
+ return function (_x31) {
2835
+ return _ref59.apply(this, arguments);
2836
+ };
2837
+ }();
2652
2838
  /**
2653
2839
  * Set the authorization policy for the specified object
2654
2840
  *
@@ -2659,26 +2845,32 @@ exports.InitializeAuthPolicy = function _callee31(_ref35) {
2659
2845
  */
2660
2846
 
2661
2847
 
2662
- exports.SetAuthPolicy = function _callee32(_ref36) {
2663
- var objectId, policyId;
2664
- return _regeneratorRuntime.async(function _callee32$(_context35) {
2665
- while (1) {
2666
- switch (_context35.prev = _context35.next) {
2667
- case 0:
2668
- objectId = _ref36.objectId, policyId = _ref36.policyId;
2669
- _context35.next = 3;
2670
- return _regeneratorRuntime.awrap(this.MergeContractMetadata({
2671
- contractAddress: this.utils.HashToAddress(objectId),
2672
- metadataKey: "_AUTH_CONTEXT",
2673
- metadata: {
2674
- "elv:delegation-id": policyId
2675
- }
2676
- }));
2848
+ exports.SetAuthPolicy = /*#__PURE__*/function () {
2849
+ var _ref61 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34(_ref60) {
2850
+ var objectId, policyId;
2851
+ return _regeneratorRuntime.wrap(function _callee34$(_context35) {
2852
+ while (1) {
2853
+ switch (_context35.prev = _context35.next) {
2854
+ case 0:
2855
+ objectId = _ref60.objectId, policyId = _ref60.policyId;
2856
+ _context35.next = 3;
2857
+ return this.MergeContractMetadata({
2858
+ contractAddress: this.utils.HashToAddress(objectId),
2859
+ metadataKey: "_AUTH_CONTEXT",
2860
+ metadata: {
2861
+ "elv:delegation-id": policyId
2862
+ }
2863
+ });
2677
2864
 
2678
- case 3:
2679
- case "end":
2680
- return _context35.stop();
2865
+ case 3:
2866
+ case "end":
2867
+ return _context35.stop();
2868
+ }
2681
2869
  }
2682
- }
2683
- }, null, this);
2684
- };
2870
+ }, _callee34, this);
2871
+ }));
2872
+
2873
+ return function (_x32) {
2874
+ return _ref61.apply(this, arguments);
2875
+ };
2876
+ }();