@eluvio/elv-client-js 3.2.4 → 3.2.5

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 (46) 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 +12 -8
  4. package/dist/ElvPermissionsClient-min.js +13 -9
  5. package/dist/ElvWalletClient-min.js +58 -0
  6. package/dist/ElvWalletClient-node-min.js +78 -0
  7. package/dist/src/AuthorizationClient.js +2248 -1990
  8. package/dist/src/ContentObjectVerification.js +164 -173
  9. package/dist/src/Crypto.js +376 -324
  10. package/dist/src/ElvClient.js +1185 -1019
  11. package/dist/src/ElvWallet.js +119 -95
  12. package/dist/src/EthClient.js +1040 -896
  13. package/dist/src/FrameClient.js +331 -300
  14. package/dist/src/HttpClient.js +153 -147
  15. package/dist/src/Id.js +1 -3
  16. package/dist/src/PermissionsClient.js +1294 -1168
  17. package/dist/src/RemoteSigner.js +263 -211
  18. package/dist/src/UserProfileClient.js +1164 -1023
  19. package/dist/src/Utils.js +229 -184
  20. package/dist/src/client/ABRPublishing.js +895 -858
  21. package/dist/src/client/AccessGroups.js +1102 -959
  22. package/dist/src/client/ContentAccess.js +3724 -3431
  23. package/dist/src/client/ContentManagement.js +2252 -2068
  24. package/dist/src/client/Contracts.js +647 -563
  25. package/dist/src/client/Files.js +1886 -1757
  26. package/dist/src/client/NFT.js +126 -112
  27. package/dist/src/client/NTP.js +478 -422
  28. package/dist/src/index.js +11 -0
  29. package/dist/src/marketplaceClient/ClientMethods.js +1918 -0
  30. package/dist/src/marketplaceClient/Configuration.js +29 -0
  31. package/dist/src/marketplaceClient/Utils.js +304 -0
  32. package/dist/src/marketplaceClient/index.js +1553 -0
  33. package/dist/src/walletClient/ClientMethods.js +1978 -0
  34. package/dist/src/walletClient/Configuration.js +29 -0
  35. package/dist/src/walletClient/Utils.js +304 -0
  36. package/dist/src/walletClient/index.js +1571 -0
  37. package/package.json +8 -4
  38. package/src/ElvClient.js +4 -1
  39. package/src/Utils.js +22 -4
  40. package/src/index.js +7 -0
  41. package/src/walletClient/ClientMethods.js +1048 -0
  42. package/src/walletClient/Configuration.js +40 -0
  43. package/src/walletClient/README.md +185 -0
  44. package/src/walletClient/Utils.js +234 -0
  45. package/src/walletClient/index.js +884 -0
  46. package/testScripts/TestMarketplaceClient.js +25 -0
@@ -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,137 +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
+
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
+ });
514
+
515
+ case 13:
516
+ _yield$this$authClien2 = _context5.sent;
517
+ contractAddress = _yield$this$authClien2.contractAddress;
518
+
519
+ if (tenantId) {
520
+ _context5.next = 19;
521
+ break;
522
+ }
496
523
 
497
- _context5.next = 18;
498
- return _regeneratorRuntime.awrap(this.userProfileClient.TenantId());
524
+ _context5.next = 18;
525
+ return this.userProfileClient.TenantId();
499
526
 
500
- case 18:
501
- tenantId = _context5.sent;
527
+ case 18:
528
+ tenantId = _context5.sent;
502
529
 
503
- case 19:
504
- if (!tenantId) {
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:
505
544
  _context5.next = 24;
506
- break;
507
- }
545
+ return this.CallContractMethod({
546
+ contractAddress: contractAddress,
547
+ methodName: "putMeta",
548
+ methodArgs: ["_tenantId", tenantId]
549
+ });
508
550
 
509
- if (this.utils.ValidHash(tenantId)) {
510
- _context5.next = 22;
511
- break;
512
- }
513
-
514
- throw Error("Invalid tenant ID: ".concat(tenantId));
515
-
516
- case 22:
517
- _context5.next = 24;
518
- return _regeneratorRuntime.awrap(this.CallContractMethod({
519
- contractAddress: contractAddress,
520
- methodName: "putMeta",
521
- methodArgs: ["_tenantId", tenantId]
522
- }));
523
-
524
- case 24:
525
- metadata = _objectSpread({}, metadata, {
526
- name: name,
527
- description: description,
528
- "public": {
551
+ case 24:
552
+ metadata = _objectSpread(_objectSpread({}, metadata), {}, {
529
553
  name: name,
530
- 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;
531
594
  }
532
- });
533
- libraryId = this.utils.AddressToLibraryId(contractAddress);
534
- this.Log("Library ID: ".concat(libraryId));
535
- this.Log("Contract address: ".concat(contractAddress)); // Set library content object type and metadata on automatically created library object
536
-
537
- objectId = libraryId.replace("ilib", "iq__");
538
- _context5.next = 31;
539
- return _regeneratorRuntime.awrap(this.EditContentObject({
540
- libraryId: libraryId,
541
- objectId: objectId
542
- }));
543
-
544
- case 31:
545
- editResponse = _context5.sent;
546
- _context5.next = 34;
547
- return _regeneratorRuntime.awrap(this.ReplaceMetadata({
548
- libraryId: libraryId,
549
- objectId: objectId,
550
- metadata: metadata,
551
- writeToken: editResponse.write_token
552
- }));
553
-
554
- case 34:
555
- _context5.next = 36;
556
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
557
- libraryId: libraryId,
558
- objectId: objectId,
559
- writeToken: editResponse.write_token,
560
- commitMessage: "Create library"
561
- }));
562
-
563
- case 36:
564
- if (!image) {
595
+
565
596
  _context5.next = 39;
566
- break;
567
- }
568
-
569
- _context5.next = 39;
570
- return _regeneratorRuntime.awrap(this.SetContentLibraryImage({
571
- libraryId: libraryId,
572
- image: image,
573
- imageName: imageName
574
- }));
575
-
576
- case 39:
577
- this.Log("Library ".concat(libraryId, " created"));
578
- return _context5.abrupt("return", libraryId);
579
-
580
- case 41:
581
- case "end":
582
- return _context5.stop();
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
+ }
583
611
  }
584
- }
585
- }, null, this);
586
- };
612
+ }, _callee5, this);
613
+ }));
614
+
615
+ return function (_x5) {
616
+ return _ref9.apply(this, arguments);
617
+ };
618
+ }();
587
619
  /**
588
620
  * Set the image associated with this library
589
621
  *
@@ -596,30 +628,36 @@ exports.CreateContentLibrary = function _callee4(_ref6) {
596
628
  */
597
629
 
598
630
 
599
- exports.SetContentLibraryImage = function _callee5(_ref8) {
600
- var libraryId, writeToken, image, imageName, objectId;
601
- return _regeneratorRuntime.async(function _callee5$(_context6) {
602
- while (1) {
603
- switch (_context6.prev = _context6.next) {
604
- case 0:
605
- libraryId = _ref8.libraryId, writeToken = _ref8.writeToken, image = _ref8.image, imageName = _ref8.imageName;
606
- ValidateLibrary(libraryId);
607
- objectId = libraryId.replace("ilib", "iq__");
608
- return _context6.abrupt("return", this.SetContentObjectImage({
609
- libraryId: libraryId,
610
- objectId: objectId,
611
- writeToken: writeToken,
612
- image: image,
613
- imageName: imageName
614
- }));
615
-
616
- case 4:
617
- case "end":
618
- 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
+ }
619
653
  }
620
- }
621
- }, null, this);
622
- };
654
+ }, _callee6, this);
655
+ }));
656
+
657
+ return function (_x6) {
658
+ return _ref11.apply(this, arguments);
659
+ };
660
+ }();
623
661
  /**
624
662
  * Set the image associated with this object
625
663
  *
@@ -634,70 +672,76 @@ exports.SetContentLibraryImage = function _callee5(_ref8) {
634
672
  */
635
673
 
636
674
 
637
- exports.SetContentObjectImage = function _callee6(_ref9) {
638
- var libraryId, objectId, writeToken, image, imageName, _ref9$imagePath, imagePath, type, mimeType;
639
-
640
- return _regeneratorRuntime.async(function _callee6$(_context7) {
641
- while (1) {
642
- switch (_context7.prev = _context7.next) {
643
- case 0:
644
- 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;
645
- ValidateParameters({
646
- libraryId: libraryId,
647
- objectId: objectId
648
- });
649
- ValidateWriteToken(writeToken);
650
- ValidatePresence("image", image);
651
- imageName = imageName || "display_image";
652
-
653
- if (!(_typeof(image) === "object")) {
654
- _context7.next = 9;
655
- break;
656
- }
657
-
658
- _context7.next = 8;
659
- return _regeneratorRuntime.awrap(new Response(image).arrayBuffer());
660
-
661
- case 8:
662
- image = _context7.sent;
663
-
664
- case 9:
665
- // Determine image type
666
- type = ImageType(image);
667
- mimeType = ["jpg", "jpeg", "png", "gif", "webp"].includes(type.ext) ? type.mime : "image/*";
668
- _context7.next = 13;
669
- return _regeneratorRuntime.awrap(this.UploadFiles({
670
- libraryId: libraryId,
671
- objectId: objectId,
672
- writeToken: writeToken,
673
- encrypted: false,
674
- fileInfo: [{
675
- path: imageName,
676
- mime_type: mimeType,
677
- size: image.size || image.length || image.byteLength,
678
- data: image
679
- }]
680
- }));
681
-
682
- case 13:
683
- _context7.next = 15;
684
- return _regeneratorRuntime.awrap(this.ReplaceMetadata({
685
- libraryId: libraryId,
686
- objectId: objectId,
687
- writeToken: writeToken,
688
- metadataSubtree: imagePath,
689
- metadata: {
690
- "/": "./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;
691
695
  }
692
- }));
693
696
 
694
- case 15:
695
- case "end":
696
- 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
+ }
697
737
  }
698
- }
699
- }, null, this);
700
- };
738
+ }, _callee7, this);
739
+ }));
740
+
741
+ return function (_x7) {
742
+ return _ref13.apply(this, arguments);
743
+ };
744
+ }();
701
745
  /**
702
746
  * NOT YET SUPPORTED - Delete the specified content library
703
747
  *
@@ -708,39 +752,45 @@ exports.SetContentObjectImage = function _callee6(_ref9) {
708
752
  */
709
753
 
710
754
 
711
- exports.DeleteContentLibrary = function _callee7(_ref10) {
712
- var libraryId, path, authorizationHeader;
713
- return _regeneratorRuntime.async(function _callee7$(_context8) {
714
- while (1) {
715
- switch (_context8.prev = _context8.next) {
716
- case 0:
717
- libraryId = _ref10.libraryId;
718
- throw Error("Not supported");
719
-
720
- case 6:
721
- authorizationHeader = _context8.sent;
722
- _context8.next = 9;
723
- return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
724
- contractAddress: this.utils.HashToAddress(libraryId),
725
- methodName: "kill",
726
- methodArgs: []
727
- }));
728
-
729
- case 9:
730
- _context8.next = 11;
731
- return _regeneratorRuntime.awrap(this.HttpClient.Request({
732
- headers: authorizationHeader,
733
- method: "DELETE",
734
- path: path
735
- }));
736
-
737
- case 11:
738
- case "end":
739
- 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
+ }
740
786
  }
741
- }
742
- }, null, this);
743
- };
787
+ }, _callee8, this);
788
+ }));
789
+
790
+ return function (_x8) {
791
+ return _ref15.apply(this, arguments);
792
+ };
793
+ }();
744
794
  /* Library Content Type Management */
745
795
 
746
796
  /**
@@ -759,56 +809,62 @@ exports.DeleteContentLibrary = function _callee7(_ref10) {
759
809
  */
760
810
 
761
811
 
762
- exports.AddLibraryContentType = function _callee8(_ref11) {
763
- var libraryId, typeId, typeName, typeHash, customContractAddress, type, typeAddress, event;
764
- return _regeneratorRuntime.async(function _callee8$(_context9) {
765
- while (1) {
766
- switch (_context9.prev = _context9.next) {
767
- case 0:
768
- libraryId = _ref11.libraryId, typeId = _ref11.typeId, typeName = _ref11.typeName, typeHash = _ref11.typeHash, customContractAddress = _ref11.customContractAddress;
769
- ValidateLibrary(libraryId);
770
- 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));
771
822
 
772
- if (typeHash) {
773
- typeId = this.utils.DecodeVersionHash(typeHash).objectId;
774
- }
823
+ if (typeHash) {
824
+ typeId = this.utils.DecodeVersionHash(typeHash).objectId;
825
+ }
775
826
 
776
- if (typeId) {
777
- _context9.next = 9;
778
- break;
779
- }
780
-
781
- _context9.next = 7;
782
- return _regeneratorRuntime.awrap(this.ContentType({
783
- name: typeName
784
- }));
785
-
786
- case 7:
787
- type = _context9.sent;
788
- typeId = type.id;
789
-
790
- case 9:
791
- this.Log("Type ID: ".concat(typeId));
792
- typeAddress = this.utils.HashToAddress(typeId);
793
- customContractAddress = customContractAddress || this.utils.nullAddress;
794
- _context9.next = 14;
795
- return _regeneratorRuntime.awrap(this.ethClient.CallContractMethodAndWait({
796
- contractAddress: this.utils.HashToAddress(libraryId),
797
- methodName: "addContentType",
798
- methodArgs: [typeAddress, customContractAddress]
799
- }));
800
-
801
- case 14:
802
- event = _context9.sent;
803
- return _context9.abrupt("return", event.transactionHash);
804
-
805
- case 16:
806
- case "end":
807
- 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
+ }
808
860
  }
809
- }
810
- }, null, this);
811
- };
861
+ }, _callee9, this);
862
+ }));
863
+
864
+ return function (_x9) {
865
+ return _ref17.apply(this, arguments);
866
+ };
867
+ }();
812
868
  /**
813
869
  * Remove the specified content type from a library
814
870
  *
@@ -823,55 +879,61 @@ exports.AddLibraryContentType = function _callee8(_ref11) {
823
879
  */
824
880
 
825
881
 
826
- exports.RemoveLibraryContentType = function _callee9(_ref12) {
827
- var libraryId, typeId, typeName, typeHash, type, typeAddress, event;
828
- return _regeneratorRuntime.async(function _callee9$(_context10) {
829
- while (1) {
830
- switch (_context10.prev = _context10.next) {
831
- case 0:
832
- libraryId = _ref12.libraryId, typeId = _ref12.typeId, typeName = _ref12.typeName, typeHash = _ref12.typeHash;
833
- ValidateLibrary(libraryId);
834
- 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));
835
892
 
836
- if (typeHash) {
837
- typeId = this.utils.DecodeVersionHash(typeHash).objectId;
838
- }
893
+ if (typeHash) {
894
+ typeId = this.utils.DecodeVersionHash(typeHash).objectId;
895
+ }
839
896
 
840
- if (typeId) {
841
- _context10.next = 9;
842
- break;
843
- }
844
-
845
- _context10.next = 7;
846
- return _regeneratorRuntime.awrap(this.ContentType({
847
- name: typeName
848
- }));
849
-
850
- case 7:
851
- type = _context10.sent;
852
- typeId = type.id;
853
-
854
- case 9:
855
- this.Log("Type ID: ".concat(typeId));
856
- typeAddress = this.utils.HashToAddress(typeId);
857
- _context10.next = 13;
858
- return _regeneratorRuntime.awrap(this.ethClient.CallContractMethodAndWait({
859
- contractAddress: this.utils.HashToAddress(libraryId),
860
- methodName: "removeContentType",
861
- methodArgs: [typeAddress]
862
- }));
863
-
864
- case 13:
865
- event = _context10.sent;
866
- return _context10.abrupt("return", event.transactionHash);
867
-
868
- case 15:
869
- case "end":
870
- 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
+ }
871
929
  }
872
- }
873
- }, null, this);
874
- };
930
+ }, _callee10, this);
931
+ }));
932
+
933
+ return function (_x10) {
934
+ return _ref19.apply(this, arguments);
935
+ };
936
+ }();
875
937
  /* Content object creation, modification, deletion */
876
938
 
877
939
  /**
@@ -894,195 +956,199 @@ exports.RemoveLibraryContentType = function _callee9(_ref12) {
894
956
  */
895
957
 
896
958
 
897
- exports.CreateContentObject = function _callee10(_ref13) {
898
- 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;
899
962
 
900
- return _regeneratorRuntime.async(function _callee10$(_context11) {
901
- while (1) {
902
- switch (_context11.prev = _context11.next) {
903
- case 0:
904
- libraryId = _ref13.libraryId, objectId = _ref13.objectId, _ref13$options = _ref13.options, options = _ref13$options === void 0 ? {} : _ref13$options;
905
- 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);
906
969
 
907
- if (objectId) {
908
- ValidateObject(objectId);
909
- }
970
+ if (objectId) {
971
+ ValidateObject(objectId);
972
+ }
910
973
 
911
- 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
912
975
 
913
- if (!options.type) {
914
- _context11.next = 26;
915
- break;
916
- }
976
+ if (!options.type) {
977
+ _context11.next = 26;
978
+ break;
979
+ }
917
980
 
918
- this.Log("Type specified: ".concat(options.type));
919
- type = options.type;
981
+ this.Log("Type specified: ".concat(options.type));
982
+ type = options.type;
920
983
 
921
- if (!type.startsWith("hq__")) {
922
- _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;
923
997
  break;
924
- }
925
998
 
926
- _context11.next = 10;
927
- return _regeneratorRuntime.awrap(this.ContentType({
928
- versionHash: type
929
- }));
999
+ case 13:
1000
+ if (!type.startsWith("iq__")) {
1001
+ _context11.next = 19;
1002
+ break;
1003
+ }
930
1004
 
931
- case 10:
932
- type = _context11.sent;
933
- _context11.next = 22;
934
- break;
1005
+ _context11.next = 16;
1006
+ return this.ContentType({
1007
+ typeId: type
1008
+ });
935
1009
 
936
- case 13:
937
- if (!type.startsWith("iq__")) {
938
- _context11.next = 19;
939
- break;
940
- }
941
-
942
- _context11.next = 16;
943
- return _regeneratorRuntime.awrap(this.ContentType({
944
- typeId: type
945
- }));
946
-
947
- case 16:
948
- type = _context11.sent;
949
- _context11.next = 22;
950
- break;
951
-
952
- case 19:
953
- _context11.next = 21;
954
- return _regeneratorRuntime.awrap(this.ContentType({
955
- name: type
956
- }));
957
-
958
- case 21:
959
- type = _context11.sent;
960
-
961
- case 22:
962
- if (type) {
963
- _context11.next = 24;
1010
+ case 16:
1011
+ type = _context11.sent;
1012
+ _context11.next = 22;
964
1013
  break;
965
- }
966
1014
 
967
- 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
+ });
968
1020
 
969
- case 24:
970
- typeId = type.id;
971
- options.type = type.hash;
1021
+ case 21:
1022
+ type = _context11.sent;
972
1023
 
973
- case 26:
974
- if (objectId) {
975
- _context11.next = 44;
976
- break;
977
- }
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
+ });
978
1053
 
979
- _context11.next = 29;
980
- return _regeneratorRuntime.awrap(this.CurrentAccountAddress());
1054
+ case 32:
1055
+ canContribute = _context11.sent;
981
1056
 
982
- case 29:
983
- currentAccountAddress = _context11.sent;
984
- _context11.next = 32;
985
- return _regeneratorRuntime.awrap(this.CallContractMethod({
986
- contractAddress: this.utils.HashToAddress(libraryId),
987
- methodName: "canContribute",
988
- methodArgs: [currentAccountAddress]
989
- }));
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));
990
1063
 
991
- case 32:
992
- 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
+ });
993
1071
 
994
- if (canContribute) {
995
- _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;
996
1078
  break;
997
- }
998
-
999
- throw Error("Current user does not have permission to create content in library ".concat(libraryId));
1000
-
1001
- case 35:
1002
- this.Log("Deploying contract...");
1003
- _context11.next = 38;
1004
- return _regeneratorRuntime.awrap(this.authClient.CreateContentObject({
1005
- libraryId: libraryId,
1006
- typeId: typeId
1007
- }));
1008
-
1009
- case 38:
1010
- _ref14 = _context11.sent;
1011
- contractAddress = _ref14.contractAddress;
1012
- objectId = this.utils.AddressToObjectId(contractAddress);
1013
- this.Log("Contract deployed: ".concat(contractAddress, " ").concat(objectId));
1014
- _context11.next = 51;
1015
- break;
1016
-
1017
- case 44:
1018
- _context11.t0 = this;
1019
- _context11.t1 = "Contract already deployed for contract type: ";
1020
- _context11.next = 48;
1021
- return _regeneratorRuntime.awrap(this.AccessType({
1022
- id: objectId
1023
- }));
1024
-
1025
- case 48:
1026
- _context11.t2 = _context11.sent;
1027
- _context11.t3 = _context11.t1.concat.call(_context11.t1, _context11.t2);
1028
-
1029
- _context11.t0.Log.call(_context11.t0, _context11.t3);
1030
-
1031
- case 51:
1032
- 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));
1033
1101
  _context11.next = 55;
1034
- break;
1035
- }
1036
-
1037
- this.Log("Setting visibility to ".concat(options.visibility));
1038
- _context11.next = 55;
1039
- return _regeneratorRuntime.awrap(this.SetVisibility({
1040
- id: objectId,
1041
- visibility: options.visibility
1042
- }));
1043
-
1044
- case 55:
1045
- path = UrlJoin("qid", objectId);
1046
- _context11.t4 = _regeneratorRuntime;
1047
- _context11.t5 = this.utils;
1048
- _context11.t6 = this.HttpClient;
1049
- _context11.next = 61;
1050
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
1051
- libraryId: libraryId,
1052
- objectId: objectId,
1053
- update: true
1054
- }));
1055
-
1056
- case 61:
1057
- _context11.t7 = _context11.sent;
1058
- _context11.t8 = path;
1059
- _context11.t9 = options;
1060
- _context11.t10 = {
1061
- headers: _context11.t7,
1062
- method: "POST",
1063
- path: _context11.t8,
1064
- body: _context11.t9
1065
- };
1066
- _context11.t11 = _context11.t6.Request.call(_context11.t6, _context11.t10);
1067
- _context11.t12 = _context11.t5.ResponseToJson.call(_context11.t5, _context11.t11);
1068
- _context11.next = 69;
1069
- return _context11.t4.awrap.call(_context11.t4, _context11.t12);
1070
-
1071
- case 69:
1072
- createResponse = _context11.sent;
1073
- // Record the node used in creating this write token
1074
- this.HttpClient.RecordWriteToken(createResponse.write_token);
1075
- createResponse.writeToken = createResponse.write_token;
1076
- createResponse.objectId = createResponse.id;
1077
- return _context11.abrupt("return", createResponse);
1078
-
1079
- case 74:
1080
- case "end":
1081
- 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
+ }
1082
1144
  }
1083
- }
1084
- }, null, this);
1085
- };
1145
+ }, _callee11, this);
1146
+ }));
1147
+
1148
+ return function (_x11) {
1149
+ return _ref21.apply(this, arguments);
1150
+ };
1151
+ }();
1086
1152
  /**
1087
1153
  * Create a new content object draft from an existing content object version.
1088
1154
  *
@@ -1103,156 +1169,168 @@ exports.CreateContentObject = function _callee10(_ref13) {
1103
1169
  */
1104
1170
 
1105
1171
 
1106
- exports.CopyContentObject = function _callee12(_ref15) {
1107
- var _this2 = this;
1108
-
1109
- var libraryId, originalVersionHash, _ref15$options, options, _ref16, objectId, writeToken, originalObjectId, metadata, permission, userCapKey, isOwner, userConkKey;
1110
-
1111
- return _regeneratorRuntime.async(function _callee12$(_context13) {
1112
- while (1) {
1113
- switch (_context13.prev = _context13.next) {
1114
- case 0:
1115
- libraryId = _ref15.libraryId, originalVersionHash = _ref15.originalVersionHash, _ref15$options = _ref15.options, options = _ref15$options === void 0 ? {} : _ref15$options;
1116
- ValidateLibrary(libraryId);
1117
- ValidateVersion(originalVersionHash);
1118
- options.copy_from = originalVersionHash;
1119
- _context13.next = 6;
1120
- return _regeneratorRuntime.awrap(this.CreateContentObject({
1121
- libraryId: libraryId,
1122
- options: options
1123
- }));
1124
-
1125
- case 6:
1126
- _ref16 = _context13.sent;
1127
- objectId = _ref16.objectId;
1128
- writeToken = _ref16.writeToken;
1129
- originalObjectId = this.utils.DecodeVersionHash(originalVersionHash).objectId;
1130
- _context13.next = 12;
1131
- return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
1132
- versionHash: originalVersionHash
1133
- }));
1134
-
1135
- case 12:
1136
- metadata = _context13.sent;
1137
- _context13.next = 15;
1138
- return _regeneratorRuntime.awrap(this.Permission({
1139
- objectId: originalObjectId
1140
- }));
1141
-
1142
- case 15:
1143
- permission = _context13.sent;
1144
- // User CAP
1145
- userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
1146
-
1147
- if (!metadata[userCapKey]) {
1148
- _context13.next = 40;
1149
- break;
1150
- }
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
+ });
1151
1201
 
1152
- _context13.t0 = this.utils;
1153
- _context13.t1 = this.signer.address;
1154
- _context13.next = 22;
1155
- return _regeneratorRuntime.awrap(this.ContentObjectOwner({
1156
- objectId: originalObjectId
1157
- }));
1202
+ case 12:
1203
+ metadata = _context13.sent;
1204
+ _context13.next = 15;
1205
+ return this.Permission({
1206
+ objectId: originalObjectId
1207
+ });
1158
1208
 
1159
- case 22:
1160
- _context13.t2 = _context13.sent;
1161
- 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));
1162
1213
 
1163
- if (isOwner) {
1164
- _context13.next = 26;
1165
- break;
1166
- }
1167
-
1168
- throw Error("Current user is not owner of object ".concat(metadata));
1169
-
1170
- case 26:
1171
- _context13.next = 28;
1172
- return _regeneratorRuntime.awrap(this.Crypto.DecryptCap(metadata[userCapKey], this.signer.signingKey.privateKey));
1173
-
1174
- case 28:
1175
- userConkKey = _context13.sent;
1176
- userConkKey.qid = objectId;
1177
- _context13.t3 = this;
1178
- _context13.t4 = libraryId;
1179
- _context13.t5 = objectId;
1180
- _context13.t6 = writeToken;
1181
- _context13.t7 = userCapKey;
1182
- _context13.next = 37;
1183
- return _regeneratorRuntime.awrap(this.Crypto.EncryptConk(userConkKey, this.signer.signingKey.publicKey));
1184
-
1185
- case 37:
1186
- _context13.t8 = _context13.sent;
1187
- _context13.t9 = {
1188
- libraryId: _context13.t4,
1189
- objectId: _context13.t5,
1190
- writeToken: _context13.t6,
1191
- metadataSubtree: _context13.t7,
1192
- metadata: _context13.t8
1193
- };
1194
-
1195
- _context13.t3.ReplaceMetadata.call(_context13.t3, _context13.t9);
1196
-
1197
- case 40:
1198
- _context13.next = 42;
1199
- return _regeneratorRuntime.awrap(Promise.all(Object.keys(metadata).filter(function (key) {
1200
- return key.startsWith("eluv.caps.ikms");
1201
- }).map(function _callee11(kmsCapKey) {
1202
- return _regeneratorRuntime.async(function _callee11$(_context12) {
1203
- while (1) {
1204
- switch (_context12.prev = _context12.next) {
1205
- case 0:
1206
- _context12.next = 2;
1207
- return _regeneratorRuntime.awrap(_this2.DeleteMetadata({
1208
- libraryId: libraryId,
1209
- objectId: objectId,
1210
- writeToken: writeToken,
1211
- metadataSubtree: kmsCapKey
1212
- }));
1213
-
1214
- case 2:
1215
- return _context12.abrupt("return", _context12.sent);
1216
-
1217
- case 3:
1218
- case "end":
1219
- return _context12.stop();
1220
- }
1221
- }
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
1222
1224
  });
1223
- })));
1224
1225
 
1225
- case 42:
1226
- 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
+
1227
1304
  _context13.next = 45;
1228
- break;
1229
- }
1230
-
1231
- _context13.next = 45;
1232
- return _regeneratorRuntime.awrap(this.SetPermission({
1233
- objectId: objectId,
1234
- permission: permission,
1235
- writeToken: writeToken
1236
- }));
1237
-
1238
- case 45:
1239
- _context13.next = 47;
1240
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
1241
- libraryId: libraryId,
1242
- objectId: objectId,
1243
- writeToken: writeToken
1244
- }));
1245
-
1246
- case 47:
1247
- return _context13.abrupt("return", _context13.sent);
1248
-
1249
- case 48:
1250
- case "end":
1251
- 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
+ }
1252
1326
  }
1253
- }
1254
- }, null, this);
1255
- };
1327
+ }, _callee13, this);
1328
+ }));
1329
+
1330
+ return function (_x12) {
1331
+ return _ref23.apply(this, arguments);
1332
+ };
1333
+ }();
1256
1334
  /**
1257
1335
  * Create a non-owner cap key using the specified public key and address
1258
1336
  *
@@ -1267,89 +1345,95 @@ exports.CopyContentObject = function _callee12(_ref15) {
1267
1345
  */
1268
1346
 
1269
1347
 
1270
- exports.CreateNonOwnerCap = function _callee13(_ref17) {
1271
- var objectId, libraryId, publicKey, writeToken, userCapKey, userCapValue, userConk, publicAddress, targetUserCapKey, targetUserCapValue, finalize;
1272
- return _regeneratorRuntime.async(function _callee13$(_context14) {
1273
- while (1) {
1274
- switch (_context14.prev = _context14.next) {
1275
- case 0:
1276
- objectId = _ref17.objectId, libraryId = _ref17.libraryId, publicKey = _ref17.publicKey, writeToken = _ref17.writeToken;
1277
- userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
1278
- _context14.next = 4;
1279
- return _regeneratorRuntime.awrap(this.ContentObjectMetadata({
1280
- objectId: objectId,
1281
- libraryId: libraryId,
1282
- metadataSubtree: userCapKey
1283
- }));
1284
-
1285
- case 4:
1286
- userCapValue = _context14.sent;
1287
-
1288
- if (userCapValue) {
1289
- _context14.next = 7;
1290
- break;
1291
- }
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
+ });
1292
1363
 
1293
- throw Error("No user cap found for current user");
1364
+ case 4:
1365
+ userCapValue = _context14.sent;
1294
1366
 
1295
- case 7:
1296
- _context14.next = 9;
1297
- return _regeneratorRuntime.awrap(this.Crypto.DecryptCap(userCapValue, this.signer.signingKey.privateKey));
1367
+ if (userCapValue) {
1368
+ _context14.next = 7;
1369
+ break;
1370
+ }
1298
1371
 
1299
- case 9:
1300
- userConk = _context14.sent;
1301
- publicAddress = this.utils.PublicKeyToAddress(publicKey);
1302
- targetUserCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(publicAddress));
1303
- _context14.next = 14;
1304
- return _regeneratorRuntime.awrap(this.Crypto.EncryptConk(userConk, publicKey));
1372
+ throw Error("No user cap found for current user");
1305
1373
 
1306
- case 14:
1307
- targetUserCapValue = _context14.sent;
1308
- 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
+ }
1309
1416
 
1310
- if (writeToken) {
1311
- _context14.next = 20;
1312
- break;
1313
- }
1314
-
1315
- _context14.next = 19;
1316
- return _regeneratorRuntime.awrap(this.EditContentObject({
1317
- libraryId: libraryId,
1318
- objectId: objectId
1319
- }).writeToken);
1320
-
1321
- case 19:
1322
- writeToken = _context14.sent;
1323
-
1324
- case 20:
1325
- this.ReplaceMetadata({
1326
- libraryId: libraryId,
1327
- objectId: objectId,
1328
- writeToken: writeToken,
1329
- metadataSubtree: targetUserCapKey,
1330
- metadata: targetUserCapValue
1331
- });
1332
-
1333
- if (!finalize) {
1334
1417
  _context14.next = 24;
1335
- break;
1336
- }
1337
-
1338
- _context14.next = 24;
1339
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
1340
- libraryId: libraryId,
1341
- objectId: objectId,
1342
- writeToken: writeToken,
1343
- commitMessage: "Create non-owner cap"
1344
- }));
1345
-
1346
- case 24:
1347
- case "end":
1348
- 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
+ }
1349
1429
  }
1350
- }
1351
- }, null, this);
1352
- };
1430
+ }, _callee14, this);
1431
+ }));
1432
+
1433
+ return function (_x14) {
1434
+ return _ref26.apply(this, arguments);
1435
+ };
1436
+ }();
1353
1437
  /**
1354
1438
  * Create a new content object draft from an existing object.
1355
1439
  *
@@ -1365,117 +1449,121 @@ exports.CreateNonOwnerCap = function _callee13(_ref17) {
1365
1449
  */
1366
1450
 
1367
1451
 
1368
- exports.EditContentObject = function _callee14(_ref18) {
1369
- 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;
1370
1455
 
1371
- return _regeneratorRuntime.async(function _callee14$(_context15) {
1372
- while (1) {
1373
- switch (_context15.prev = _context15.next) {
1374
- case 0:
1375
- libraryId = _ref18.libraryId, objectId = _ref18.objectId, _ref18$options = _ref18.options, options = _ref18$options === void 0 ? {} : _ref18$options;
1376
- ValidateParameters({
1377
- libraryId: libraryId,
1378
- objectId: objectId
1379
- });
1380
- 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));
1381
1466
 
1382
- if (!("type" in options && options.type)) {
1383
- _context15.next = 23;
1384
- break;
1385
- }
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
+ });
1386
1481
 
1387
- if (!options.type.startsWith("hq__")) {
1388
- _context15.next = 10;
1482
+ case 7:
1483
+ options.type = _context15.sent.hash;
1484
+ _context15.next = 23;
1389
1485
  break;
1390
- }
1391
1486
 
1392
- _context15.next = 7;
1393
- return _regeneratorRuntime.awrap(this.ContentType({
1394
- versionHash: options.type
1395
- }));
1487
+ case 10:
1488
+ if (!options.type.startsWith("iq__")) {
1489
+ _context15.next = 16;
1490
+ break;
1491
+ }
1396
1492
 
1397
- case 7:
1398
- options.type = _context15.sent.hash;
1399
- _context15.next = 23;
1400
- break;
1493
+ _context15.next = 13;
1494
+ return this.ContentType({
1495
+ typeId: options.type
1496
+ });
1401
1497
 
1402
- case 10:
1403
- if (!options.type.startsWith("iq__")) {
1404
- _context15.next = 16;
1498
+ case 13:
1499
+ options.type = _context15.sent.hash;
1500
+ _context15.next = 23;
1405
1501
  break;
1406
- }
1407
1502
 
1408
- _context15.next = 13;
1409
- return _regeneratorRuntime.awrap(this.ContentType({
1410
- typeId: options.type
1411
- }));
1503
+ case 16:
1504
+ if (!options.type) {
1505
+ _context15.next = 22;
1506
+ break;
1507
+ }
1412
1508
 
1413
- case 13:
1414
- options.type = _context15.sent.hash;
1415
- _context15.next = 23;
1416
- break;
1509
+ _context15.next = 19;
1510
+ return this.ContentType({
1511
+ name: options.type
1512
+ });
1417
1513
 
1418
- case 16:
1419
- if (!options.type) {
1420
- _context15.next = 22;
1514
+ case 19:
1515
+ options.type = _context15.sent.hash;
1516
+ _context15.next = 23;
1421
1517
  break;
1422
- }
1423
-
1424
- _context15.next = 19;
1425
- return _regeneratorRuntime.awrap(this.ContentType({
1426
- name: options.type
1427
- }));
1428
-
1429
- case 19:
1430
- options.type = _context15.sent.hash;
1431
- _context15.next = 23;
1432
- break;
1433
-
1434
- case 22:
1435
- options.type = "";
1436
-
1437
- case 23:
1438
- path = UrlJoin("qid", objectId);
1439
- _context15.t0 = _regeneratorRuntime;
1440
- _context15.t1 = this.utils;
1441
- _context15.t2 = this.HttpClient;
1442
- _context15.next = 29;
1443
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
1444
- libraryId: libraryId,
1445
- objectId: objectId,
1446
- update: true
1447
- }));
1448
-
1449
- case 29:
1450
- _context15.t3 = _context15.sent;
1451
- _context15.t4 = path;
1452
- _context15.t5 = options;
1453
- _context15.t6 = {
1454
- headers: _context15.t3,
1455
- method: "POST",
1456
- path: _context15.t4,
1457
- body: _context15.t5
1458
- };
1459
- _context15.t7 = _context15.t2.Request.call(_context15.t2, _context15.t6);
1460
- _context15.t8 = _context15.t1.ResponseToJson.call(_context15.t1, _context15.t7);
1461
- _context15.next = 37;
1462
- return _context15.t0.awrap.call(_context15.t0, _context15.t8);
1463
-
1464
- case 37:
1465
- editResponse = _context15.sent;
1466
- // Record the node used in creating this write token
1467
- this.HttpClient.RecordWriteToken(editResponse.write_token);
1468
- editResponse.writeToken = editResponse.write_token;
1469
- editResponse.objectId = editResponse.id;
1470
- return _context15.abrupt("return", editResponse);
1471
-
1472
- case 42:
1473
- case "end":
1474
- 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
+ }
1475
1559
  }
1476
- }
1477
- }, null, this);
1478
- };
1560
+ }, _callee15, this);
1561
+ }));
1562
+
1563
+ return function (_x15) {
1564
+ return _ref28.apply(this, arguments);
1565
+ };
1566
+ }();
1479
1567
  /**
1480
1568
  * Create and finalize new content object draft from an existing object.
1481
1569
  *
@@ -1504,56 +1592,62 @@ exports.EditContentObject = function _callee14(_ref18) {
1504
1592
  */
1505
1593
 
1506
1594
 
1507
- exports.CreateAndFinalizeContentObject = function _callee15(_ref19) {
1508
- 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
+ });
1509
1609
 
1510
- return _regeneratorRuntime.async(function _callee15$(_context16) {
1511
- while (1) {
1512
- switch (_context16.prev = _context16.next) {
1513
- case 0:
1514
- 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;
1515
- _context16.next = 3;
1516
- return _regeneratorRuntime.awrap(this.CreateContentObject({
1517
- libraryId: libraryId,
1518
- options: options
1519
- }));
1610
+ case 3:
1611
+ args = _context16.sent;
1612
+ id = args.id, writeToken = args.writeToken;
1520
1613
 
1521
- case 3:
1522
- args = _context16.sent;
1523
- id = args.id, writeToken = args.writeToken;
1614
+ if (!callback) {
1615
+ _context16.next = 8;
1616
+ break;
1617
+ }
1524
1618
 
1525
- if (!callback) {
1526
1619
  _context16.next = 8;
1527
- break;
1528
- }
1529
-
1530
- _context16.next = 8;
1531
- return _regeneratorRuntime.awrap(callback({
1532
- objectId: id,
1533
- writeToken: writeToken
1534
- }));
1535
-
1536
- case 8:
1537
- _context16.next = 10;
1538
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
1539
- libraryId: libraryId,
1540
- objectId: id,
1541
- writeToken: writeToken,
1542
- commitMessage: commitMessage,
1543
- publish: publish,
1544
- awaitCommitConfirmation: awaitCommitConfirmation
1545
- }));
1546
-
1547
- case 10:
1548
- return _context16.abrupt("return", _context16.sent);
1549
-
1550
- case 11:
1551
- case "end":
1552
- 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
+ }
1553
1643
  }
1554
- }
1555
- }, null, this);
1556
- };
1644
+ }, _callee16, this);
1645
+ }));
1646
+
1647
+ return function (_x16) {
1648
+ return _ref30.apply(this, arguments);
1649
+ };
1650
+ }();
1557
1651
  /**
1558
1652
  * Create and finalize new content object draft from an existing object.
1559
1653
  *
@@ -1583,169 +1677,187 @@ exports.CreateAndFinalizeContentObject = function _callee15(_ref19) {
1583
1677
  */
1584
1678
 
1585
1679
 
1586
- exports.EditAndFinalizeContentObject = function _callee16(_ref20) {
1587
- 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
+ });
1588
1695
 
1589
- return _regeneratorRuntime.async(function _callee16$(_context17) {
1590
- while (1) {
1591
- switch (_context17.prev = _context17.next) {
1592
- case 0:
1593
- 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;
1594
- _context17.next = 3;
1595
- return _regeneratorRuntime.awrap(this.EditContentObject({
1596
- libraryId: libraryId,
1597
- objectId: objectId,
1598
- options: options
1599
- }));
1696
+ case 3:
1697
+ _yield$this$EditConte = _context17.sent;
1698
+ writeToken = _yield$this$EditConte.writeToken;
1600
1699
 
1601
- case 3:
1602
- _ref21 = _context17.sent;
1603
- writeToken = _ref21.writeToken;
1700
+ if (!callback) {
1701
+ _context17.next = 8;
1702
+ break;
1703
+ }
1604
1704
 
1605
- if (!callback) {
1606
1705
  _context17.next = 8;
1607
- break;
1608
- }
1609
-
1610
- _context17.next = 8;
1611
- return _regeneratorRuntime.awrap(callback({
1612
- writeToken: writeToken
1613
- }));
1614
-
1615
- case 8:
1616
- _context17.next = 10;
1617
- return _regeneratorRuntime.awrap(this.FinalizeContentObject({
1618
- libraryId: libraryId,
1619
- objectId: objectId,
1620
- writeToken: writeToken,
1621
- commitMessage: commitMessage,
1622
- publish: publish,
1623
- awaitCommitConfirmation: awaitCommitConfirmation
1624
- }));
1625
-
1626
- case 10:
1627
- return _context17.abrupt("return", _context17.sent);
1628
-
1629
- case 11:
1630
- case "end":
1631
- return _context17.stop();
1632
- }
1633
- }
1634
- }, null, this);
1635
- };
1636
-
1637
- exports.AwaitPending = function _callee17(objectId) {
1638
- var _this3 = this;
1639
-
1640
- var PendingHash, pending, isWallet, timeout, i;
1641
- return _regeneratorRuntime.async(function _callee17$(_context19) {
1642
- while (1) {
1643
- switch (_context19.prev = _context19.next) {
1644
- case 0:
1645
- PendingHash = function PendingHash() {
1646
- return _regeneratorRuntime.async(function PendingHash$(_context18) {
1647
- while (1) {
1648
- switch (_context18.prev = _context18.next) {
1649
- case 0:
1650
- _context18.next = 2;
1651
- return _regeneratorRuntime.awrap(_this3.CallContractMethod({
1652
- contractAddress: _this3.utils.HashToAddress(objectId),
1653
- methodName: "pendingHash"
1654
- }));
1655
-
1656
- case 2:
1657
- return _context18.abrupt("return", _context18.sent);
1658
-
1659
- case 3:
1660
- case "end":
1661
- return _context18.stop();
1662
- }
1663
- }
1706
+ return callback({
1707
+ writeToken: writeToken
1664
1708
  });
1665
- };
1666
1709
 
1667
- this.Log("Checking for pending commit");
1668
- _context19.next = 4;
1669
- 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
+ });
1670
1720
 
1671
- case 4:
1672
- pending = _context19.sent;
1721
+ case 10:
1722
+ return _context17.abrupt("return", _context17.sent);
1673
1723
 
1674
- if (pending) {
1675
- _context19.next = 7;
1676
- break;
1677
- }
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
+ }));
1678
1768
 
1679
- return _context19.abrupt("return");
1769
+ return function PendingHash() {
1770
+ return _ref34.apply(this, arguments);
1771
+ };
1772
+ }();
1680
1773
 
1681
- case 7:
1682
- _context19.next = 9;
1683
- return _regeneratorRuntime.awrap(this.authClient.AccessType(objectId));
1774
+ this.Log("Checking for pending commit");
1775
+ _context19.next = 4;
1776
+ return PendingHash();
1684
1777
 
1685
- case 9:
1686
- _context19.t0 = _context19.sent;
1687
- _context19.t1 = this.authClient.ACCESS_TYPES.WALLET;
1688
- isWallet = _context19.t0 === _context19.t1;
1689
- timeout = isWallet ? 3 : 10;
1690
- this.Log("Waiting for pending commit to clear for ".concat(objectId));
1691
- i = 0;
1778
+ case 4:
1779
+ pending = _context19.sent;
1692
1780
 
1693
- case 15:
1694
- if (!(i < timeout)) {
1695
- _context19.next = 25;
1696
- break;
1697
- }
1781
+ if (pending) {
1782
+ _context19.next = 7;
1783
+ break;
1784
+ }
1698
1785
 
1699
- _context19.next = 18;
1700
- return _regeneratorRuntime.awrap(new Promise(function (resolve) {
1701
- return setTimeout(resolve, 1000);
1702
- }));
1786
+ return _context19.abrupt("return");
1703
1787
 
1704
- case 18:
1705
- _context19.next = 20;
1706
- return _regeneratorRuntime.awrap(PendingHash());
1788
+ case 7:
1789
+ _context19.next = 9;
1790
+ return this.authClient.AccessType(objectId);
1707
1791
 
1708
- case 20:
1709
- if (_context19.sent) {
1710
- _context19.next = 22;
1711
- break;
1712
- }
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
+ });
1713
1810
 
1714
- return _context19.abrupt("return");
1811
+ case 18:
1812
+ _context19.next = 20;
1813
+ return PendingHash();
1715
1814
 
1716
- case 22:
1717
- i++;
1718
- _context19.next = 15;
1719
- break;
1815
+ case 20:
1816
+ if (_context19.sent) {
1817
+ _context19.next = 22;
1818
+ break;
1819
+ }
1720
1820
 
1721
- case 25:
1722
- if (!isWallet) {
1723
- _context19.next = 31;
1821
+ return _context19.abrupt("return");
1822
+
1823
+ case 22:
1824
+ i++;
1825
+ _context19.next = 15;
1724
1826
  break;
1725
- }
1726
1827
 
1727
- 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
1728
1835
 
1729
- _context19.next = 29;
1730
- return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
1731
- contractAddress: this.utils.HashToAddress(objectId),
1732
- methodName: "clearPending"
1733
- }));
1836
+ _context19.next = 29;
1837
+ return this.CallContractMethodAndWait({
1838
+ contractAddress: this.utils.HashToAddress(objectId),
1839
+ methodName: "clearPending"
1840
+ });
1734
1841
 
1735
- case 29:
1736
- _context19.next = 32;
1737
- break;
1842
+ case 29:
1843
+ _context19.next = 32;
1844
+ break;
1738
1845
 
1739
- case 31:
1740
- 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"));
1741
1848
 
1742
- case 32:
1743
- case "end":
1744
- return _context19.stop();
1849
+ case 32:
1850
+ case "end":
1851
+ return _context19.stop();
1852
+ }
1745
1853
  }
1746
- }
1747
- }, null, this);
1748
- };
1854
+ }, _callee19, this);
1855
+ }));
1856
+
1857
+ return function (_x18) {
1858
+ return _ref33.apply(this, arguments);
1859
+ };
1860
+ }();
1749
1861
  /**
1750
1862
  * Finalize content draft
1751
1863
  *
@@ -1761,120 +1873,122 @@ exports.AwaitPending = function _callee17(objectId) {
1761
1873
  */
1762
1874
 
1763
1875
 
1764
- exports.FinalizeContentObject = function _callee18(_ref22) {
1765
- var libraryId, objectId, writeToken, _ref22$commitMessage, commitMessage, _ref22$publish, publish, _ref22$awaitCommitCon, awaitCommitConfirmation, path, finalizeResponse;
1766
-
1767
- return _regeneratorRuntime.async(function _callee18$(_context20) {
1768
- while (1) {
1769
- switch (_context20.prev = _context20.next) {
1770
- case 0:
1771
- 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;
1772
- ValidateParameters({
1773
- libraryId: libraryId,
1774
- objectId: objectId
1775
- });
1776
- ValidateWriteToken(writeToken);
1777
- _context20.t0 = _regeneratorRuntime;
1778
- _context20.t1 = this;
1779
- _context20.t2 = libraryId;
1780
- _context20.t3 = objectId;
1781
- _context20.t4 = writeToken;
1782
- _context20.t5 = commitMessage;
1783
- _context20.next = 11;
1784
- return _regeneratorRuntime.awrap(this.userProfileClient.UserMetadata({
1785
- metadataSubtree: "public/name"
1786
- }));
1787
-
1788
- case 11:
1789
- _context20.t6 = _context20.sent;
1790
-
1791
- if (_context20.t6) {
1792
- _context20.next = 14;
1793
- break;
1794
- }
1795
-
1796
- _context20.t6 = this.CurrentAccountAddress();
1797
-
1798
- case 14:
1799
- _context20.t7 = _context20.t6;
1800
- _context20.t8 = this.CurrentAccountAddress();
1801
- _context20.t9 = new Date().toISOString();
1802
- _context20.t10 = {
1803
- message: _context20.t5,
1804
- author: _context20.t7,
1805
- author_address: _context20.t8,
1806
- timestamp: _context20.t9
1807
- };
1808
- _context20.t11 = {
1809
- libraryId: _context20.t2,
1810
- objectId: _context20.t3,
1811
- writeToken: _context20.t4,
1812
- metadataSubtree: "commit",
1813
- metadata: _context20.t10
1814
- };
1815
- _context20.t12 = _context20.t1.ReplaceMetadata.call(_context20.t1, _context20.t11);
1816
- _context20.next = 22;
1817
- return _context20.t0.awrap.call(_context20.t0, _context20.t12);
1818
-
1819
- case 22:
1820
- this.Log("Finalizing content draft: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
1821
- _context20.next = 25;
1822
- return _regeneratorRuntime.awrap(this.AwaitPending(objectId));
1823
-
1824
- case 25:
1825
- path = UrlJoin("q", writeToken);
1826
- _context20.t13 = _regeneratorRuntime;
1827
- _context20.t14 = this.utils;
1828
- _context20.t15 = this.HttpClient;
1829
- _context20.next = 31;
1830
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
1831
- libraryId: libraryId,
1832
- objectId: objectId,
1833
- update: true
1834
- }));
1835
-
1836
- case 31:
1837
- _context20.t16 = _context20.sent;
1838
- _context20.t17 = path;
1839
- _context20.t18 = {
1840
- headers: _context20.t16,
1841
- method: "POST",
1842
- path: _context20.t17,
1843
- failover: false
1844
- };
1845
- _context20.t19 = _context20.t15.Request.call(_context20.t15, _context20.t18);
1846
- _context20.t20 = _context20.t14.ResponseToJson.call(_context20.t14, _context20.t19);
1847
- _context20.next = 38;
1848
- return _context20.t13.awrap.call(_context20.t13, _context20.t20);
1849
-
1850
- case 38:
1851
- finalizeResponse = _context20.sent;
1852
- this.Log("Finalized: ".concat(finalizeResponse.hash));
1853
-
1854
- if (!publish) {
1855
- _context20.next = 43;
1856
- break;
1857
- }
1858
-
1859
- _context20.next = 43;
1860
- return _regeneratorRuntime.awrap(this.PublishContentVersion({
1861
- objectId: objectId,
1862
- versionHash: finalizeResponse.hash,
1863
- awaitCommitConfirmation: awaitCommitConfirmation
1864
- }));
1865
-
1866
- case 43:
1867
- // Invalidate cached content type, if this is one.
1868
- delete this.contentTypes[objectId];
1869
- return _context20.abrupt("return", finalizeResponse);
1870
-
1871
- case 45:
1872
- case "end":
1873
- 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
+ }
1874
1984
  }
1875
- }
1876
- }, null, this);
1877
- };
1985
+ }, _callee20, this);
1986
+ }));
1987
+
1988
+ return function (_x19) {
1989
+ return _ref36.apply(this, arguments);
1990
+ };
1991
+ }();
1878
1992
  /**
1879
1993
  * Publish a previously finalized content object version
1880
1994
  *
@@ -1887,140 +2001,145 @@ exports.FinalizeContentObject = function _callee18(_ref22) {
1887
2001
  */
1888
2002
 
1889
2003
 
1890
- exports.PublishContentVersion = function _callee20(_ref23) {
1891
- var _this4 = this;
1892
-
1893
- var objectId, versionHash, _ref23$awaitCommitCon, awaitCommitConfirmation, commit, abi, fromBlock, objectHash, pendingHash;
1894
-
1895
- return _regeneratorRuntime.async(function _callee20$(_context22) {
1896
- while (1) {
1897
- switch (_context22.prev = _context22.next) {
1898
- case 0:
1899
- objectId = _ref23.objectId, versionHash = _ref23.versionHash, _ref23$awaitCommitCon = _ref23.awaitCommitConfirmation, awaitCommitConfirmation = _ref23$awaitCommitCon === void 0 ? true : _ref23$awaitCommitCon;
1900
- versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
1901
- this.Log("Publishing: ".concat(objectId || versionHash));
1902
-
1903
- if (versionHash) {
1904
- objectId = this.utils.DecodeVersionHash(versionHash).objectId;
1905
- }
1906
-
1907
- _context22.next = 6;
1908
- return _regeneratorRuntime.awrap(this.ethClient.CommitContent({
1909
- contentObjectAddress: this.utils.HashToAddress(objectId),
1910
- versionHash: versionHash,
1911
- signer: this.signer
1912
- }));
1913
-
1914
- case 6:
1915
- commit = _context22.sent;
1916
- _context22.next = 9;
1917
- return _regeneratorRuntime.awrap(this.ContractAbi({
1918
- id: objectId
1919
- }));
1920
-
1921
- case 9:
1922
- abi = _context22.sent;
1923
- fromBlock = commit.blockNumber + 1;
1924
- _context22.next = 13;
1925
- return _regeneratorRuntime.awrap(this.ExtractValueFromEvent({
1926
- abi: abi,
1927
- event: commit,
1928
- eventName: "CommitPending",
1929
- eventValue: "objectHash"
1930
- }));
1931
-
1932
- case 13:
1933
- objectHash = _context22.sent;
1934
- _context22.next = 16;
1935
- return _regeneratorRuntime.awrap(this.CallContractMethod({
1936
- contractAddress: this.utils.HashToAddress(objectId),
1937
- methodName: "pendingHash"
1938
- }));
1939
-
1940
- case 16:
1941
- pendingHash = _context22.sent;
1942
-
1943
- if (!(pendingHash && pendingHash !== objectHash)) {
1944
- _context22.next = 19;
1945
- break;
1946
- }
2004
+ exports.PublishContentVersion = /*#__PURE__*/function () {
2005
+ var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref37) {
2006
+ var _this4 = this;
1947
2007
 
1948
- 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;
1949
2009
 
1950
- case 19:
1951
- if (!awaitCommitConfirmation) {
1952
- _context22.next = 22;
1953
- break;
1954
- }
1955
-
1956
- _context22.next = 22;
1957
- return _regeneratorRuntime.awrap(function _callee19() {
1958
- var pollingInterval, events, confirmEvent;
1959
- return _regeneratorRuntime.async(function _callee19$(_context21) {
1960
- while (1) {
1961
- switch (_context21.prev = _context21.next) {
1962
- case 0:
1963
- _this4.Log("Awaiting commit confirmation for ".concat(objectHash));
1964
-
1965
- pollingInterval = _this4.ethClient.Provider().pollingInterval || 500; // eslint-disable-next-line no-constant-condition
1966
-
1967
- case 2:
1968
- if (!true) {
1969
- _context21.next = 14;
1970
- break;
1971
- }
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
+ }
1972
2070
 
1973
- _context21.next = 5;
1974
- return _regeneratorRuntime.awrap(new Promise(function (resolve) {
1975
- return setTimeout(resolve, pollingInterval);
1976
- }));
1977
-
1978
- case 5:
1979
- _context21.next = 7;
1980
- return _regeneratorRuntime.awrap(_this4.ContractEvents({
1981
- contractAddress: _this4.utils.HashToAddress(objectId),
1982
- abi: abi,
1983
- fromBlock: fromBlock,
1984
- count: 1000
1985
- }));
1986
-
1987
- case 7:
1988
- events = _context21.sent;
1989
- confirmEvent = events.find(function (blockEvents) {
1990
- return blockEvents.find(function (event) {
1991
- 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);
1992
2090
  });
1993
- });
1994
2091
 
1995
- if (!confirmEvent) {
1996
- _context21.next = 12;
1997
- break;
1998
- }
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
+ });
1999
2100
 
2000
- // Found confirmation
2001
- _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
+ }
2002
2113
 
2003
- return _context21.abrupt("break", 14);
2114
+ // Found confirmation
2115
+ _this4.Log("Commit confirmed: ".concat(objectHash));
2004
2116
 
2005
- case 12:
2006
- _context21.next = 2;
2007
- break;
2117
+ return _context21.abrupt("break", 14);
2118
+
2119
+ case 12:
2120
+ _context21.next = 2;
2121
+ break;
2008
2122
 
2009
- case 14:
2010
- case "end":
2011
- return _context21.stop();
2123
+ case 14:
2124
+ case "end":
2125
+ return _context21.stop();
2126
+ }
2012
2127
  }
2013
- }
2014
- });
2015
- }());
2128
+ }, _callee21);
2129
+ })(), "t0", 21);
2016
2130
 
2017
- case 22:
2018
- case "end":
2019
- return _context22.stop();
2131
+ case 21:
2132
+ case "end":
2133
+ return _context22.stop();
2134
+ }
2020
2135
  }
2021
- }
2022
- }, null, this);
2023
- };
2136
+ }, _callee22, this);
2137
+ }));
2138
+
2139
+ return function (_x20) {
2140
+ return _ref38.apply(this, arguments);
2141
+ };
2142
+ }();
2024
2143
  /**
2025
2144
  * Delete specified version of the content object
2026
2145
  *
@@ -2030,31 +2149,37 @@ exports.PublishContentVersion = function _callee20(_ref23) {
2030
2149
  */
2031
2150
 
2032
2151
 
2033
- exports.DeleteContentVersion = function _callee21(_ref24) {
2034
- var versionHash, _this$utils$DecodeVer, objectId;
2035
-
2036
- return _regeneratorRuntime.async(function _callee21$(_context23) {
2037
- while (1) {
2038
- switch (_context23.prev = _context23.next) {
2039
- case 0:
2040
- versionHash = _ref24.versionHash;
2041
- ValidateVersion(versionHash);
2042
- this.Log("Deleting content version: ".concat(versionHash));
2043
- _this$utils$DecodeVer = this.utils.DecodeVersionHash(versionHash), objectId = _this$utils$DecodeVer.objectId;
2044
- _context23.next = 6;
2045
- return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
2046
- contractAddress: this.utils.HashToAddress(objectId),
2047
- methodName: "deleteVersion",
2048
- methodArgs: [versionHash]
2049
- }));
2050
-
2051
- case 6:
2052
- case "end":
2053
- 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
+ }
2054
2175
  }
2055
- }
2056
- }, null, this);
2057
- };
2176
+ }, _callee23, this);
2177
+ }));
2178
+
2179
+ return function (_x21) {
2180
+ return _ref40.apply(this, arguments);
2181
+ };
2182
+ }();
2058
2183
  /**
2059
2184
  * Delete specified content object
2060
2185
  *
@@ -2065,32 +2190,38 @@ exports.DeleteContentVersion = function _callee21(_ref24) {
2065
2190
  */
2066
2191
 
2067
2192
 
2068
- exports.DeleteContentObject = function _callee22(_ref25) {
2069
- var libraryId, objectId;
2070
- return _regeneratorRuntime.async(function _callee22$(_context24) {
2071
- while (1) {
2072
- switch (_context24.prev = _context24.next) {
2073
- case 0:
2074
- libraryId = _ref25.libraryId, objectId = _ref25.objectId;
2075
- ValidateParameters({
2076
- libraryId: libraryId,
2077
- objectId: objectId
2078
- });
2079
- this.Log("Deleting content version: ".concat(libraryId, " ").concat(objectId));
2080
- _context24.next = 5;
2081
- return _regeneratorRuntime.awrap(this.CallContractMethodAndWait({
2082
- contractAddress: this.utils.HashToAddress(libraryId),
2083
- methodName: "deleteContent",
2084
- methodArgs: [this.utils.HashToAddress(objectId)]
2085
- }));
2086
-
2087
- case 5:
2088
- case "end":
2089
- 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
+ }
2090
2217
  }
2091
- }
2092
- }, null, this);
2093
- };
2218
+ }, _callee24, this);
2219
+ }));
2220
+
2221
+ return function (_x22) {
2222
+ return _ref42.apply(this, arguments);
2223
+ };
2224
+ }();
2094
2225
  /* Content object metadata */
2095
2226
 
2096
2227
  /**
@@ -2106,53 +2237,57 @@ exports.DeleteContentObject = function _callee22(_ref25) {
2106
2237
  */
2107
2238
 
2108
2239
 
2109
- exports.MergeMetadata = function _callee23(_ref26) {
2110
- var libraryId, objectId, writeToken, _ref26$metadataSubtre, metadataSubtree, _ref26$metadata, metadata, path;
2111
-
2112
- return _regeneratorRuntime.async(function _callee23$(_context25) {
2113
- while (1) {
2114
- switch (_context25.prev = _context25.next) {
2115
- case 0:
2116
- 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;
2117
- ValidateParameters({
2118
- libraryId: libraryId,
2119
- objectId: objectId
2120
- });
2121
- ValidateWriteToken(writeToken);
2122
- this.Log("Merging metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
2123
- this.Log(metadata);
2124
- path = UrlJoin("q", writeToken, "meta", metadataSubtree);
2125
- _context25.t0 = _regeneratorRuntime;
2126
- _context25.t1 = this.HttpClient;
2127
- _context25.next = 10;
2128
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
2129
- libraryId: libraryId,
2130
- objectId: objectId,
2131
- update: true
2132
- }));
2133
-
2134
- case 10:
2135
- _context25.t2 = _context25.sent;
2136
- _context25.t3 = path;
2137
- _context25.t4 = metadata;
2138
- _context25.t5 = {
2139
- headers: _context25.t2,
2140
- method: "POST",
2141
- path: _context25.t3,
2142
- body: _context25.t4,
2143
- failover: false
2144
- };
2145
- _context25.t6 = _context25.t1.Request.call(_context25.t1, _context25.t5);
2146
- _context25.next = 17;
2147
- return _context25.t0.awrap.call(_context25.t0, _context25.t6);
2148
-
2149
- case 17:
2150
- case "end":
2151
- 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
+ }
2152
2283
  }
2153
- }
2154
- }, null, this);
2155
- };
2284
+ }, _callee25, this);
2285
+ }));
2286
+
2287
+ return function (_x23) {
2288
+ return _ref44.apply(this, arguments);
2289
+ };
2290
+ }();
2156
2291
  /**
2157
2292
  * Replace content object metadata with specified metadata
2158
2293
  *
@@ -2166,53 +2301,57 @@ exports.MergeMetadata = function _callee23(_ref26) {
2166
2301
  */
2167
2302
 
2168
2303
 
2169
- exports.ReplaceMetadata = function _callee24(_ref27) {
2170
- var libraryId, objectId, writeToken, _ref27$metadataSubtre, metadataSubtree, _ref27$metadata, metadata, path;
2171
-
2172
- return _regeneratorRuntime.async(function _callee24$(_context26) {
2173
- while (1) {
2174
- switch (_context26.prev = _context26.next) {
2175
- case 0:
2176
- 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;
2177
- ValidateParameters({
2178
- libraryId: libraryId,
2179
- objectId: objectId
2180
- });
2181
- ValidateWriteToken(writeToken);
2182
- this.Log("Replacing metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
2183
- this.Log(metadata);
2184
- path = UrlJoin("q", writeToken, "meta", metadataSubtree);
2185
- _context26.t0 = _regeneratorRuntime;
2186
- _context26.t1 = this.HttpClient;
2187
- _context26.next = 10;
2188
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
2189
- libraryId: libraryId,
2190
- objectId: objectId,
2191
- update: true
2192
- }));
2193
-
2194
- case 10:
2195
- _context26.t2 = _context26.sent;
2196
- _context26.t3 = path;
2197
- _context26.t4 = metadata;
2198
- _context26.t5 = {
2199
- headers: _context26.t2,
2200
- method: "PUT",
2201
- path: _context26.t3,
2202
- body: _context26.t4,
2203
- failover: false
2204
- };
2205
- _context26.t6 = _context26.t1.Request.call(_context26.t1, _context26.t5);
2206
- _context26.next = 17;
2207
- return _context26.t0.awrap.call(_context26.t0, _context26.t6);
2208
-
2209
- case 17:
2210
- case "end":
2211
- 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
+ }
2212
2347
  }
2213
- }
2214
- }, null, this);
2215
- };
2348
+ }, _callee26, this);
2349
+ }));
2350
+
2351
+ return function (_x24) {
2352
+ return _ref46.apply(this, arguments);
2353
+ };
2354
+ }();
2216
2355
  /**
2217
2356
  * Delete content object metadata of specified subtree
2218
2357
  *
@@ -2226,51 +2365,55 @@ exports.ReplaceMetadata = function _callee24(_ref27) {
2226
2365
  */
2227
2366
 
2228
2367
 
2229
- exports.DeleteMetadata = function _callee25(_ref28) {
2230
- var libraryId, objectId, writeToken, _ref28$metadataSubtre, metadataSubtree, path;
2231
-
2232
- return _regeneratorRuntime.async(function _callee25$(_context27) {
2233
- while (1) {
2234
- switch (_context27.prev = _context27.next) {
2235
- case 0:
2236
- libraryId = _ref28.libraryId, objectId = _ref28.objectId, writeToken = _ref28.writeToken, _ref28$metadataSubtre = _ref28.metadataSubtree, metadataSubtree = _ref28$metadataSubtre === void 0 ? "/" : _ref28$metadataSubtre;
2237
- ValidateParameters({
2238
- libraryId: libraryId,
2239
- objectId: objectId
2240
- });
2241
- ValidateWriteToken(writeToken);
2242
- this.Log("Deleting metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
2243
- this.Log("Subtree: ".concat(metadataSubtree));
2244
- path = UrlJoin("q", writeToken, "meta", metadataSubtree);
2245
- _context27.t0 = _regeneratorRuntime;
2246
- _context27.t1 = this.HttpClient;
2247
- _context27.next = 10;
2248
- return _regeneratorRuntime.awrap(this.authClient.AuthorizationHeader({
2249
- libraryId: libraryId,
2250
- objectId: objectId,
2251
- update: true
2252
- }));
2253
-
2254
- case 10:
2255
- _context27.t2 = _context27.sent;
2256
- _context27.t3 = path;
2257
- _context27.t4 = {
2258
- headers: _context27.t2,
2259
- method: "DELETE",
2260
- path: _context27.t3,
2261
- failover: false
2262
- };
2263
- _context27.t5 = _context27.t1.Request.call(_context27.t1, _context27.t4);
2264
- _context27.next = 16;
2265
- return _context27.t0.awrap.call(_context27.t0, _context27.t5);
2266
-
2267
- case 16:
2268
- case "end":
2269
- 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
+ }
2270
2409
  }
2271
- }
2272
- }, null, this);
2273
- };
2410
+ }, _callee27, this);
2411
+ }));
2412
+
2413
+ return function (_x25) {
2414
+ return _ref48.apply(this, arguments);
2415
+ };
2416
+ }();
2274
2417
  /**
2275
2418
  * Set the access charge for the specified object
2276
2419
  *
@@ -2281,29 +2424,35 @@ exports.DeleteMetadata = function _callee25(_ref28) {
2281
2424
  */
2282
2425
 
2283
2426
 
2284
- exports.SetAccessCharge = function _callee26(_ref29) {
2285
- var objectId, accessCharge;
2286
- return _regeneratorRuntime.async(function _callee26$(_context28) {
2287
- while (1) {
2288
- switch (_context28.prev = _context28.next) {
2289
- case 0:
2290
- objectId = _ref29.objectId, accessCharge = _ref29.accessCharge;
2291
- ValidateObject(objectId);
2292
- this.Log("Setting access charge: ".concat(objectId, " ").concat(accessCharge));
2293
- _context28.next = 5;
2294
- return _regeneratorRuntime.awrap(this.ethClient.CallContractMethodAndWait({
2295
- contractAddress: this.utils.HashToAddress(objectId),
2296
- methodName: "setAccessCharge",
2297
- methodArgs: [this.utils.EtherToWei(accessCharge).toString()]
2298
- }));
2299
-
2300
- case 5:
2301
- case "end":
2302
- 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
+ }
2303
2448
  }
2304
- }
2305
- }, null, this);
2306
- };
2449
+ }, _callee28, this);
2450
+ }));
2451
+
2452
+ return function (_x26) {
2453
+ return _ref50.apply(this, arguments);
2454
+ };
2455
+ }();
2307
2456
  /**
2308
2457
  * Recursively update all auto_update links in the specified object.
2309
2458
  *
@@ -2319,179 +2468,190 @@ exports.SetAccessCharge = function _callee26(_ref29) {
2319
2468
  */
2320
2469
 
2321
2470
 
2322
- exports.UpdateContentObjectGraph = function _callee28(_ref30) {
2323
- var _this5 = this;
2324
-
2325
- var libraryId, objectId, versionHash, callback, total, completed, _loop, _ret;
2326
-
2327
- return _regeneratorRuntime.async(function _callee28$(_context31) {
2328
- while (1) {
2329
- switch (_context31.prev = _context31.next) {
2330
- case 0:
2331
- libraryId = _ref30.libraryId, objectId = _ref30.objectId, versionHash = _ref30.versionHash, callback = _ref30.callback;
2332
- ValidateParameters({
2333
- libraryId: libraryId,
2334
- objectId: objectId,
2335
- versionHash: versionHash
2336
- });
2337
- this.Log("Updating content object graph: ".concat(libraryId || "", " ").concat(objectId || versionHash));
2338
-
2339
- if (versionHash) {
2340
- objectId = this.utils.DecodeVersionHash(versionHash).objectId;
2341
- }
2342
-
2343
- completed = 0; // eslint-disable-next-line no-constant-condition
2344
-
2345
- _loop = function _loop() {
2346
- var graph, currentHash, links, details, name, currentLibraryId, currentObjectId, _ref31, write_token, _ref33, hash;
2347
-
2348
- return _regeneratorRuntime.async(function _loop$(_context30) {
2349
- while (1) {
2350
- switch (_context30.prev = _context30.next) {
2351
- case 0:
2352
- _context30.next = 2;
2353
- return _regeneratorRuntime.awrap(_this5.ContentObjectGraph({
2354
- libraryId: libraryId,
2355
- objectId: objectId,
2356
- versionHash: versionHash,
2357
- autoUpdate: true,
2358
- select: ["name", "public/name", "public/asset_metadata/display_title"]
2359
- }));
2360
-
2361
- case 2:
2362
- graph = _context30.sent;
2363
-
2364
- if (!(Object.keys(graph.auto_updates).length === 0)) {
2365
- _context30.next = 6;
2366
- break;
2367
- }
2471
+ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
2472
+ var _ref52 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(_ref51) {
2473
+ var _this5 = this;
2368
2474
 
2369
- _this5.Log("No more updates required");
2475
+ var libraryId, objectId, versionHash, callback, total, completed, _loop, _ret;
2370
2476
 
2371
- return _context30.abrupt("return", {
2372
- v: void 0
2373
- });
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));
2374
2488
 
2375
- case 6:
2376
- if (!total) {
2377
- total = graph.auto_updates.order.length;
2378
- }
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;
2379
2497
 
2380
- currentHash = graph.auto_updates.order[0];
2381
- links = graph.auto_updates.links[currentHash];
2382
- details = graph.details[currentHash].meta || {};
2383
- name = details["public"] && details["public"].asset_metadata && details["public"].asset_metadata.display_title || details["public"] && details["public"].name || details.name || versionHash || objectId;
2384
- _context30.next = 13;
2385
- return _regeneratorRuntime.awrap(_this5.ContentObjectLibraryId({
2386
- versionHash: currentHash
2387
- }));
2388
-
2389
- case 13:
2390
- currentLibraryId = _context30.sent;
2391
- currentObjectId = _this5.utils.DecodeVersionHash(currentHash).objectId;
2392
-
2393
- if (callback) {
2394
- callback({
2395
- completed: completed,
2396
- total: total,
2397
- 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"]
2398
2509
  });
2399
- }
2400
2510
 
2401
- _this5.Log("Updating links for ".concat(name, " (").concat(currentObjectId, " / ").concat(currentHash, ")"));
2402
-
2403
- _context30.next = 19;
2404
- return _regeneratorRuntime.awrap(_this5.EditContentObject({
2405
- libraryId: currentLibraryId,
2406
- objectId: currentObjectId
2407
- }));
2408
-
2409
- case 19:
2410
- _ref31 = _context30.sent;
2411
- write_token = _ref31.write_token;
2412
- _context30.next = 23;
2413
- return _regeneratorRuntime.awrap(Promise.all(links.map(function _callee27(_ref32) {
2414
- var path, updated;
2415
- return _regeneratorRuntime.async(function _callee27$(_context29) {
2416
- while (1) {
2417
- switch (_context29.prev = _context29.next) {
2418
- case 0:
2419
- path = _ref32.path, updated = _ref32.updated;
2420
- _context29.next = 3;
2421
- return _regeneratorRuntime.awrap(_this5.ReplaceMetadata({
2422
- libraryId: currentLibraryId,
2423
- objectId: currentObjectId,
2424
- writeToken: write_token,
2425
- metadataSubtree: path,
2426
- metadata: updated
2427
- }));
2428
-
2429
- case 3:
2430
- case "end":
2431
- return _context29.stop();
2432
- }
2433
- }
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
2434
2523
  });
2435
- })));
2436
-
2437
- case 23:
2438
- _context30.next = 25;
2439
- return _regeneratorRuntime.awrap(_this5.FinalizeContentObject({
2440
- libraryId: currentLibraryId,
2441
- objectId: currentObjectId,
2442
- writeToken: write_token,
2443
- commitMessage: "Update links"
2444
- }));
2445
-
2446
- case 25:
2447
- _ref33 = _context30.sent;
2448
- hash = _ref33.hash;
2449
-
2450
- // If root object was specified by hash and updated, update hash
2451
- if (currentHash === versionHash) {
2452
- versionHash = hash;
2453
- }
2454
2524
 
2455
- 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, ")"));
2456
2552
 
2457
- case 29:
2458
- case "end":
2459
- 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
+ }
2460
2617
  }
2461
- }
2618
+ }, _loop);
2462
2619
  });
2463
- };
2464
2620
 
2465
- case 6:
2466
- if (!1) {
2467
- _context31.next = 14;
2468
- break;
2469
- }
2621
+ case 6:
2622
+ if (!1) {
2623
+ _context31.next = 13;
2624
+ break;
2625
+ }
2470
2626
 
2471
- _context31.next = 9;
2472
- return _regeneratorRuntime.awrap(_loop());
2627
+ return _context31.delegateYield(_loop(), "t0", 8);
2473
2628
 
2474
- case 9:
2475
- _ret = _context31.sent;
2629
+ case 8:
2630
+ _ret = _context31.t0;
2476
2631
 
2477
- if (!(_typeof(_ret) === "object")) {
2478
- _context31.next = 12;
2479
- break;
2480
- }
2632
+ if (!(_typeof(_ret) === "object")) {
2633
+ _context31.next = 11;
2634
+ break;
2635
+ }
2481
2636
 
2482
- return _context31.abrupt("return", _ret.v);
2637
+ return _context31.abrupt("return", _ret.v);
2483
2638
 
2484
- case 12:
2485
- _context31.next = 6;
2486
- break;
2639
+ case 11:
2640
+ _context31.next = 6;
2641
+ break;
2487
2642
 
2488
- case 14:
2489
- case "end":
2490
- return _context31.stop();
2643
+ case 13:
2644
+ case "end":
2645
+ return _context31.stop();
2646
+ }
2491
2647
  }
2492
- }
2493
- }, null, this);
2494
- };
2648
+ }, _callee30, this);
2649
+ }));
2650
+
2651
+ return function (_x27) {
2652
+ return _ref52.apply(this, arguments);
2653
+ };
2654
+ }();
2495
2655
  /**
2496
2656
  * Create links to files, metadata and/or representations of this or or other
2497
2657
  * content objects.
@@ -2518,79 +2678,91 @@ exports.UpdateContentObjectGraph = function _callee28(_ref30) {
2518
2678
  */
2519
2679
 
2520
2680
 
2521
- exports.CreateLinks = function _callee30(_ref34) {
2522
- var _this6 = this;
2523
-
2524
- var libraryId, objectId, writeToken, _ref34$links, links;
2525
-
2526
- return _regeneratorRuntime.async(function _callee30$(_context33) {
2527
- while (1) {
2528
- switch (_context33.prev = _context33.next) {
2529
- case 0:
2530
- libraryId = _ref34.libraryId, objectId = _ref34.objectId, writeToken = _ref34.writeToken, _ref34$links = _ref34.links, links = _ref34$links === void 0 ? [] : _ref34$links;
2531
- ValidateParameters({
2532
- libraryId: libraryId,
2533
- objectId: objectId
2534
- });
2535
- ValidateWriteToken(writeToken);
2536
- _context33.next = 5;
2537
- return _regeneratorRuntime.awrap(this.utils.LimitedMap(10, links, function _callee29(info) {
2538
- var path, type, target, link;
2539
- return _regeneratorRuntime.async(function _callee29$(_context32) {
2540
- while (1) {
2541
- switch (_context32.prev = _context32.next) {
2542
- case 0:
2543
- path = info.path.replace(/^(\/|\.)+/, "");
2544
- type = (info.type || "file") === "file" ? "files" : info.type;
2545
-
2546
- if (type === "metadata") {
2547
- type = "meta";
2548
- }
2681
+ exports.CreateLinks = /*#__PURE__*/function () {
2682
+ var _ref56 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(_ref55) {
2683
+ var _this6 = this;
2549
2684
 
2550
- target = info.target.replace(/^(\/|\.)+/, "");
2685
+ var libraryId, objectId, writeToken, _ref55$links, links;
2551
2686
 
2552
- if (info.targetHash) {
2553
- target = "/qfab/".concat(info.targetHash, "/").concat(type, "/").concat(target);
2554
- } else {
2555
- target = "./".concat(type, "/").concat(target);
2556
- }
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
+ }
2557
2711
 
2558
- link = {
2559
- "/": target
2560
- };
2712
+ target = info.target.replace(/^(\/|\.)+/, "");
2561
2713
 
2562
- if (info.autoUpdate) {
2563
- link["."] = {
2564
- auto_update: {
2565
- tag: "latest"
2714
+ if (info.targetHash) {
2715
+ target = "/qfab/".concat(info.targetHash, "/").concat(type, "/").concat(target);
2716
+ } else {
2717
+ target = "./".concat(type, "/").concat(target);
2566
2718
  }
2567
- };
2568
- }
2569
2719
 
2570
- _context32.next = 9;
2571
- return _regeneratorRuntime.awrap(_this6.ReplaceMetadata({
2572
- libraryId: libraryId,
2573
- objectId: objectId,
2574
- writeToken: writeToken,
2575
- metadataSubtree: path,
2576
- metadata: link
2577
- }));
2578
-
2579
- case 9:
2580
- case "end":
2581
- return _context32.stop();
2582
- }
2583
- }
2584
- });
2585
- }));
2720
+ link = {
2721
+ "/": target
2722
+ };
2586
2723
 
2587
- case 5:
2588
- case "end":
2589
- 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
+ }
2590
2758
  }
2591
- }
2592
- }, null, this);
2593
- };
2759
+ }, _callee32, this);
2760
+ }));
2761
+
2762
+ return function (_x29) {
2763
+ return _ref56.apply(this, arguments);
2764
+ };
2765
+ }();
2594
2766
  /**
2595
2767
  * Initialize or replace the signed auth policy for the specified object
2596
2768
  *
@@ -2607,56 +2779,62 @@ exports.CreateLinks = function _callee30(_ref34) {
2607
2779
  */
2608
2780
 
2609
2781
 
2610
- exports.InitializeAuthPolicy = function _callee31(_ref35) {
2611
- var libraryId, objectId, writeToken, _ref35$target, target, body, version, description, id, authPolicy, string;
2612
-
2613
- return _regeneratorRuntime.async(function _callee31$(_context34) {
2614
- while (1) {
2615
- switch (_context34.prev = _context34.next) {
2616
- case 0:
2617
- 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;
2618
- authPolicy = {
2619
- type: "epl-ast",
2620
- version: version,
2621
- body: body,
2622
- data: {
2623
- "/": UrlJoin(".", "meta", target)
2624
- },
2625
- signer: "iusr".concat(this.utils.AddressToHash(this.signer.address)),
2626
- description: description || "",
2627
- id: id || ""
2628
- };
2629
- string = "".concat(authPolicy.type, "|").concat(authPolicy.version, "|").concat(authPolicy.body, "|").concat(authPolicy.data["/"]);
2630
- _context34.t0 = this.utils;
2631
- _context34.next = 6;
2632
- return _regeneratorRuntime.awrap(this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string))));
2633
-
2634
- case 6:
2635
- _context34.t1 = _context34.sent;
2636
- authPolicy.signature = _context34.t0.FormatSignature.call(_context34.t0, _context34.t1);
2637
- _context34.next = 10;
2638
- return _regeneratorRuntime.awrap(this.ReplaceMetadata({
2639
- libraryId: libraryId,
2640
- objectId: objectId,
2641
- writeToken: writeToken,
2642
- metadataSubtree: "auth_policy",
2643
- metadata: authPolicy
2644
- }));
2645
-
2646
- case 10:
2647
- _context34.next = 12;
2648
- return _regeneratorRuntime.awrap(this.SetAuthPolicy({
2649
- objectId: objectId,
2650
- policyId: objectId
2651
- }));
2652
-
2653
- case 12:
2654
- case "end":
2655
- 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
+ }
2656
2830
  }
2657
- }
2658
- }, null, this);
2659
- };
2831
+ }, _callee33, this);
2832
+ }));
2833
+
2834
+ return function (_x31) {
2835
+ return _ref59.apply(this, arguments);
2836
+ };
2837
+ }();
2660
2838
  /**
2661
2839
  * Set the authorization policy for the specified object
2662
2840
  *
@@ -2667,26 +2845,32 @@ exports.InitializeAuthPolicy = function _callee31(_ref35) {
2667
2845
  */
2668
2846
 
2669
2847
 
2670
- exports.SetAuthPolicy = function _callee32(_ref36) {
2671
- var objectId, policyId;
2672
- return _regeneratorRuntime.async(function _callee32$(_context35) {
2673
- while (1) {
2674
- switch (_context35.prev = _context35.next) {
2675
- case 0:
2676
- objectId = _ref36.objectId, policyId = _ref36.policyId;
2677
- _context35.next = 3;
2678
- return _regeneratorRuntime.awrap(this.MergeContractMetadata({
2679
- contractAddress: this.utils.HashToAddress(objectId),
2680
- metadataKey: "_AUTH_CONTEXT",
2681
- metadata: {
2682
- "elv:delegation-id": policyId
2683
- }
2684
- }));
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
+ });
2685
2864
 
2686
- case 3:
2687
- case "end":
2688
- return _context35.stop();
2865
+ case 3:
2866
+ case "end":
2867
+ return _context35.stop();
2868
+ }
2689
2869
  }
2690
- }
2691
- }, null, this);
2692
- };
2870
+ }, _callee34, this);
2871
+ }));
2872
+
2873
+ return function (_x32) {
2874
+ return _ref61.apply(this, arguments);
2875
+ };
2876
+ }();