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