@eluvio/elv-client-js 4.2.13 → 4.2.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +1 -1
- package/dist/ElvClient-node-min.js +1 -1
- package/dist/ElvFrameClient-min.js +1 -1
- package/dist/ElvPermissionsClient-min.js +1 -1
- package/dist/ElvWalletClient-min.js +1 -1
- package/dist/ElvWalletClient-node-min.js +1 -1
- package/dist/src/AuthorizationClient.js +723 -710
- package/dist/src/ContentObjectAudit.js +56 -56
- package/dist/src/Crypto.js +85 -85
- package/dist/src/ElvClient.js +502 -530
- package/dist/src/ElvWallet.js +28 -30
- package/dist/src/EthClient.js +311 -311
- package/dist/src/FrameClient.js +65 -64
- package/dist/src/HttpClient.js +60 -60
- package/dist/src/Id.js +2 -1
- package/dist/src/PermissionsClient.js +487 -499
- package/dist/src/RemoteSigner.js +178 -123
- package/dist/src/UserProfileClient.js +374 -392
- package/dist/src/Utils.js +66 -69
- package/dist/src/Validation.js +10 -10
- package/dist/src/client/ABRPublishing.js +239 -239
- package/dist/src/client/AccessGroups.js +474 -477
- package/dist/src/client/ContentAccess.js +1713 -1708
- package/dist/src/client/ContentManagement.js +871 -871
- package/dist/src/client/Contracts.js +736 -582
- package/dist/src/client/Files.js +684 -700
- package/dist/src/client/LiveConf.js +6 -1
- package/dist/src/client/LiveStream.js +686 -722
- package/dist/src/client/NFT.js +14 -14
- package/dist/src/client/NTP.js +84 -84
- package/dist/src/client/Shares.js +60 -53
- package/dist/src/walletClient/ClientMethods.js +951 -977
- package/dist/src/walletClient/Notifications.js +14 -14
- package/dist/src/walletClient/Profile.js +66 -66
- package/dist/src/walletClient/Utils.js +15 -15
- package/dist/src/walletClient/index.js +584 -581
- package/package.json +3 -2
- package/src/ElvClient.js +2 -1
- package/src/FrameClient.js +3 -0
- package/src/LogMessage.js +1 -1
- package/src/RemoteSigner.js +17 -3
- package/src/client/ABRPublishing.js +1 -1
- package/src/client/ContentAccess.js +16 -13
- package/src/client/Contracts.js +88 -7
- package/src/walletClient/index.js +15 -4
|
@@ -29,41 +29,41 @@ var _require = require("../Validation"),
|
|
|
29
29
|
ValidateParameters = _require.ValidateParameters,
|
|
30
30
|
ValidatePresence = _require.ValidatePresence;
|
|
31
31
|
exports.SetVisibility = /*#__PURE__*/function () {
|
|
32
|
-
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
32
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee(_ref) {
|
|
33
33
|
var id, visibility, hasSetVisibility, event;
|
|
34
|
-
return _regeneratorRuntime.wrap(function (_context) {
|
|
34
|
+
return _regeneratorRuntime.wrap(function _callee$(_context) {
|
|
35
35
|
while (1) switch (_context.prev = _context.next) {
|
|
36
36
|
case 0:
|
|
37
37
|
id = _ref.id, visibility = _ref.visibility;
|
|
38
38
|
this.Log("Setting visibility ".concat(visibility, " on ").concat(id));
|
|
39
|
-
_context.next =
|
|
39
|
+
_context.next = 4;
|
|
40
40
|
return this.authClient.ContractHasMethod({
|
|
41
41
|
contractAddress: this.utils.HashToAddress(id),
|
|
42
42
|
methodName: "setVisibility"
|
|
43
43
|
});
|
|
44
|
-
case
|
|
44
|
+
case 4:
|
|
45
45
|
hasSetVisibility = _context.sent;
|
|
46
46
|
if (hasSetVisibility) {
|
|
47
|
-
_context.next =
|
|
47
|
+
_context.next = 7;
|
|
48
48
|
break;
|
|
49
49
|
}
|
|
50
50
|
return _context.abrupt("return");
|
|
51
|
-
case
|
|
52
|
-
_context.next =
|
|
51
|
+
case 7:
|
|
52
|
+
_context.next = 9;
|
|
53
53
|
return this.CallContractMethodAndWait({
|
|
54
54
|
contractAddress: this.utils.HashToAddress(id),
|
|
55
55
|
methodName: "setVisibility",
|
|
56
56
|
methodArgs: [visibility]
|
|
57
57
|
});
|
|
58
|
-
case
|
|
58
|
+
case 9:
|
|
59
59
|
event = _context.sent;
|
|
60
|
-
_context.next =
|
|
60
|
+
_context.next = 12;
|
|
61
61
|
return new Promise(function (resolve) {
|
|
62
62
|
return setTimeout(resolve, 5000);
|
|
63
63
|
});
|
|
64
|
-
case
|
|
64
|
+
case 12:
|
|
65
65
|
return _context.abrupt("return", event);
|
|
66
|
-
case
|
|
66
|
+
case 13:
|
|
67
67
|
case "end":
|
|
68
68
|
return _context.stop();
|
|
69
69
|
}
|
|
@@ -85,10 +85,10 @@ exports.SetVisibility = /*#__PURE__*/function () {
|
|
|
85
85
|
* @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
|
|
86
86
|
*/
|
|
87
87
|
exports.SetPermission = /*#__PURE__*/function () {
|
|
88
|
-
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
|
|
88
|
+
var _ref4 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref3) {
|
|
89
89
|
var _this = this;
|
|
90
|
-
var objectId, permission, writeToken, permissionSettings, settings, libraryId, statusCode, kmsAddress, kmsConkKey, kmsConk, finalize
|
|
91
|
-
return _regeneratorRuntime.wrap(function (_context3) {
|
|
90
|
+
var objectId, permission, writeToken, permissionSettings, settings, libraryId, statusCode, kmsAddress, kmsConkKey, kmsConk, finalize;
|
|
91
|
+
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
92
92
|
while (1) switch (_context3.prev = _context3.next) {
|
|
93
93
|
case 0:
|
|
94
94
|
objectId = _ref3.objectId, permission = _ref3.permission, writeToken = _ref3.writeToken;
|
|
@@ -96,108 +96,108 @@ exports.SetPermission = /*#__PURE__*/function () {
|
|
|
96
96
|
ValidatePresence("permission", permission);
|
|
97
97
|
permissionSettings = this.permissionLevels[permission];
|
|
98
98
|
if (permissionSettings) {
|
|
99
|
-
_context3.next =
|
|
99
|
+
_context3.next = 6;
|
|
100
100
|
break;
|
|
101
101
|
}
|
|
102
102
|
throw Error("Unknown permission level: " + permission);
|
|
103
|
-
case
|
|
104
|
-
_context3.next =
|
|
103
|
+
case 6:
|
|
104
|
+
_context3.next = 8;
|
|
105
105
|
return this.AccessType({
|
|
106
106
|
id: objectId
|
|
107
107
|
});
|
|
108
|
-
case
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
if (!(
|
|
112
|
-
_context3.next =
|
|
108
|
+
case 8:
|
|
109
|
+
_context3.t0 = _context3.sent;
|
|
110
|
+
_context3.t1 = this.authClient.ACCESS_TYPES.OBJECT;
|
|
111
|
+
if (!(_context3.t0 !== _context3.t1)) {
|
|
112
|
+
_context3.next = 12;
|
|
113
113
|
break;
|
|
114
114
|
}
|
|
115
115
|
throw Error("Permission only valid for normal content objects: " + objectId);
|
|
116
|
-
case
|
|
116
|
+
case 12:
|
|
117
117
|
settings = permissionSettings.settings;
|
|
118
|
-
_context3.next =
|
|
118
|
+
_context3.next = 15;
|
|
119
119
|
return this.ContentObjectLibraryId({
|
|
120
120
|
objectId: objectId
|
|
121
121
|
});
|
|
122
|
-
case
|
|
122
|
+
case 15:
|
|
123
123
|
libraryId = _context3.sent;
|
|
124
|
-
_context3.next =
|
|
124
|
+
_context3.next = 18;
|
|
125
125
|
return this.SetVisibility({
|
|
126
126
|
id: objectId,
|
|
127
127
|
visibility: settings.visibility
|
|
128
128
|
});
|
|
129
|
-
case
|
|
130
|
-
_context3.next =
|
|
129
|
+
case 18:
|
|
130
|
+
_context3.next = 20;
|
|
131
131
|
return this.CallContractMethod({
|
|
132
132
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
133
133
|
methodName: "statusCode"
|
|
134
134
|
});
|
|
135
|
-
case
|
|
135
|
+
case 20:
|
|
136
136
|
statusCode = _context3.sent;
|
|
137
137
|
if (!(statusCode !== settings.statusCode)) {
|
|
138
|
-
_context3.next =
|
|
138
|
+
_context3.next = 29;
|
|
139
139
|
break;
|
|
140
140
|
}
|
|
141
141
|
if (!(settings.statusCode < 0)) {
|
|
142
|
-
_context3.next =
|
|
142
|
+
_context3.next = 27;
|
|
143
143
|
break;
|
|
144
144
|
}
|
|
145
|
-
_context3.next =
|
|
145
|
+
_context3.next = 25;
|
|
146
146
|
return this.CallContractMethod({
|
|
147
147
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
148
148
|
methodName: "setStatusCode",
|
|
149
149
|
methodArgs: [-1]
|
|
150
150
|
});
|
|
151
|
-
case
|
|
152
|
-
_context3.next =
|
|
151
|
+
case 25:
|
|
152
|
+
_context3.next = 29;
|
|
153
153
|
break;
|
|
154
|
-
case
|
|
155
|
-
_context3.next =
|
|
154
|
+
case 27:
|
|
155
|
+
_context3.next = 29;
|
|
156
156
|
return this.CallContractMethod({
|
|
157
157
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
158
158
|
methodName: "publish"
|
|
159
159
|
});
|
|
160
|
-
case
|
|
161
|
-
_context3.next =
|
|
160
|
+
case 29:
|
|
161
|
+
_context3.next = 31;
|
|
162
162
|
return this.CallContractMethod({
|
|
163
163
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
164
164
|
methodName: "addressKMS"
|
|
165
165
|
});
|
|
166
|
-
case
|
|
166
|
+
case 31:
|
|
167
167
|
kmsAddress = _context3.sent;
|
|
168
168
|
kmsConkKey = "eluv.caps.ikms".concat(this.utils.AddressToHash(kmsAddress));
|
|
169
|
-
_context3.next =
|
|
169
|
+
_context3.next = 35;
|
|
170
170
|
return this.ContentObjectMetadata({
|
|
171
171
|
libraryId: libraryId,
|
|
172
172
|
objectId: objectId,
|
|
173
173
|
metadataSubtree: kmsConkKey
|
|
174
174
|
});
|
|
175
|
-
case
|
|
175
|
+
case 35:
|
|
176
176
|
kmsConk = _context3.sent;
|
|
177
177
|
if (!(kmsConk && !settings.kmsConk)) {
|
|
178
|
-
_context3.next =
|
|
178
|
+
_context3.next = 41;
|
|
179
179
|
break;
|
|
180
180
|
}
|
|
181
|
-
_context3.next =
|
|
181
|
+
_context3.next = 39;
|
|
182
182
|
return this.EditAndFinalizeContentObject({
|
|
183
183
|
libraryId: libraryId,
|
|
184
184
|
objectId: objectId,
|
|
185
185
|
commitMessage: "Remove encryption conk",
|
|
186
186
|
callback: function () {
|
|
187
|
-
var _callback = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5) {
|
|
187
|
+
var _callback = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee2(_ref5) {
|
|
188
188
|
var writeToken;
|
|
189
|
-
return _regeneratorRuntime.wrap(function (_context2) {
|
|
189
|
+
return _regeneratorRuntime.wrap(function _callee2$(_context2) {
|
|
190
190
|
while (1) switch (_context2.prev = _context2.next) {
|
|
191
191
|
case 0:
|
|
192
192
|
writeToken = _ref5.writeToken;
|
|
193
|
-
_context2.next =
|
|
193
|
+
_context2.next = 3;
|
|
194
194
|
return _this.DeleteMetadata({
|
|
195
195
|
libraryId: libraryId,
|
|
196
196
|
objectId: objectId,
|
|
197
197
|
writeToken: writeToken,
|
|
198
198
|
metadataSubtree: kmsConkKey
|
|
199
199
|
});
|
|
200
|
-
case
|
|
200
|
+
case 3:
|
|
201
201
|
case "end":
|
|
202
202
|
return _context2.stop();
|
|
203
203
|
}
|
|
@@ -209,47 +209,47 @@ exports.SetPermission = /*#__PURE__*/function () {
|
|
|
209
209
|
return callback;
|
|
210
210
|
}()
|
|
211
211
|
});
|
|
212
|
-
case
|
|
213
|
-
_context3.next =
|
|
212
|
+
case 39:
|
|
213
|
+
_context3.next = 52;
|
|
214
214
|
break;
|
|
215
|
-
case
|
|
215
|
+
case 41:
|
|
216
216
|
if (!(!kmsConk && settings.kmsConk)) {
|
|
217
|
-
_context3.next =
|
|
217
|
+
_context3.next = 52;
|
|
218
218
|
break;
|
|
219
219
|
}
|
|
220
220
|
finalize = !writeToken;
|
|
221
221
|
if (writeToken) {
|
|
222
|
-
_context3.next =
|
|
222
|
+
_context3.next = 47;
|
|
223
223
|
break;
|
|
224
224
|
}
|
|
225
|
-
_context3.next =
|
|
225
|
+
_context3.next = 46;
|
|
226
226
|
return this.EditContentObject({
|
|
227
227
|
libraryId: libraryId,
|
|
228
228
|
objectId: objectId
|
|
229
229
|
});
|
|
230
|
-
case
|
|
230
|
+
case 46:
|
|
231
231
|
writeToken = _context3.sent.writeToken;
|
|
232
|
-
case
|
|
233
|
-
_context3.next =
|
|
232
|
+
case 47:
|
|
233
|
+
_context3.next = 49;
|
|
234
234
|
return this.CreateEncryptionConk({
|
|
235
235
|
libraryId: libraryId,
|
|
236
236
|
objectId: objectId,
|
|
237
237
|
writeToken: writeToken,
|
|
238
238
|
createKMSConk: true
|
|
239
239
|
});
|
|
240
|
-
case
|
|
240
|
+
case 49:
|
|
241
241
|
if (!finalize) {
|
|
242
|
-
_context3.next =
|
|
242
|
+
_context3.next = 52;
|
|
243
243
|
break;
|
|
244
244
|
}
|
|
245
|
-
_context3.next =
|
|
245
|
+
_context3.next = 52;
|
|
246
246
|
return this.FinalizeContentObject({
|
|
247
247
|
libraryId: libraryId,
|
|
248
248
|
objectId: objectId,
|
|
249
249
|
writeToken: writeToken,
|
|
250
250
|
commitMessage: "Set permissions to ".concat(permission)
|
|
251
251
|
});
|
|
252
|
-
case
|
|
252
|
+
case 52:
|
|
253
253
|
case "end":
|
|
254
254
|
return _context3.stop();
|
|
255
255
|
}
|
|
@@ -281,9 +281,9 @@ exports.SetPermission = /*#__PURE__*/function () {
|
|
|
281
281
|
* @returns {Promise<string>} - Object ID of created content type
|
|
282
282
|
*/
|
|
283
283
|
exports.CreateContentType = /*#__PURE__*/function () {
|
|
284
|
-
var _ref7 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref6) {
|
|
285
|
-
var name, _ref6$metadata, metadata, bitcode, _yield$this$authClien, contractAddress, objectId, path, rawCreateResponse, nodeUrl, createResponse, uploadResponse, tenantContractId
|
|
286
|
-
return _regeneratorRuntime.wrap(function (_context4) {
|
|
284
|
+
var _ref7 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee4(_ref6) {
|
|
285
|
+
var name, _ref6$metadata, metadata, bitcode, _yield$this$authClien, contractAddress, objectId, path, rawCreateResponse, nodeUrl, createResponse, uploadResponse, tenantContractId;
|
|
286
|
+
return _regeneratorRuntime.wrap(function _callee4$(_context4) {
|
|
287
287
|
while (1) switch (_context4.prev = _context4.next) {
|
|
288
288
|
case 0:
|
|
289
289
|
name = _ref6.name, _ref6$metadata = _ref6.metadata, metadata = _ref6$metadata === void 0 ? {} : _ref6$metadata, bitcode = _ref6.bitcode;
|
|
@@ -292,66 +292,66 @@ exports.CreateContentType = /*#__PURE__*/function () {
|
|
|
292
292
|
metadata["public"] = _objectSpread({
|
|
293
293
|
name: name
|
|
294
294
|
}, metadata["public"] || {});
|
|
295
|
-
_context4.next =
|
|
295
|
+
_context4.next = 6;
|
|
296
296
|
return this.authClient.CreateContentType();
|
|
297
|
-
case
|
|
297
|
+
case 6:
|
|
298
298
|
_yield$this$authClien = _context4.sent;
|
|
299
299
|
contractAddress = _yield$this$authClien.contractAddress;
|
|
300
300
|
objectId = this.utils.AddressToObjectId(contractAddress);
|
|
301
|
-
_context4.next =
|
|
301
|
+
_context4.next = 11;
|
|
302
302
|
return this.SetVisibility({
|
|
303
303
|
id: objectId,
|
|
304
304
|
visibility: 1
|
|
305
305
|
});
|
|
306
|
-
case
|
|
306
|
+
case 11:
|
|
307
307
|
path = UrlJoin("qlibs", this.contentSpaceLibraryId, "qid", objectId);
|
|
308
308
|
this.Log("Created type: ".concat(contractAddress, " ").concat(objectId));
|
|
309
309
|
|
|
310
310
|
/* Create object, upload bitcode and finalize */
|
|
311
|
-
|
|
312
|
-
_context4.next =
|
|
311
|
+
_context4.t0 = this.HttpClient;
|
|
312
|
+
_context4.next = 16;
|
|
313
313
|
return this.authClient.AuthorizationHeader({
|
|
314
314
|
libraryId: this.contentSpaceLibraryId,
|
|
315
315
|
objectId: objectId,
|
|
316
316
|
update: true
|
|
317
317
|
});
|
|
318
|
-
case
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
headers:
|
|
318
|
+
case 16:
|
|
319
|
+
_context4.t1 = _context4.sent;
|
|
320
|
+
_context4.t2 = path;
|
|
321
|
+
_context4.t3 = {
|
|
322
|
+
headers: _context4.t1,
|
|
323
323
|
method: "POST",
|
|
324
|
-
path:
|
|
324
|
+
path: _context4.t2
|
|
325
325
|
};
|
|
326
|
-
_context4.next =
|
|
327
|
-
return
|
|
328
|
-
case
|
|
326
|
+
_context4.next = 21;
|
|
327
|
+
return _context4.t0.Request.call(_context4.t0, _context4.t3);
|
|
328
|
+
case 21:
|
|
329
329
|
rawCreateResponse = _context4.sent;
|
|
330
330
|
// extract the url for the node that handled the request
|
|
331
331
|
// TODO: remove/simplify after we start using /nodes API call to get node URLs for write tokens
|
|
332
332
|
nodeUrl = new URL(rawCreateResponse.url).origin;
|
|
333
|
-
_context4.next =
|
|
333
|
+
_context4.next = 25;
|
|
334
334
|
return this.utils.ResponseToJson(rawCreateResponse, this.HttpClient.debug, this.HttpClient.Log.bind(this.HttpClient));
|
|
335
|
-
case
|
|
335
|
+
case 25:
|
|
336
336
|
createResponse = _context4.sent;
|
|
337
337
|
// Record the node used in creating this write token
|
|
338
338
|
this.RecordWriteToken({
|
|
339
339
|
writeToken: createResponse.write_token,
|
|
340
340
|
fabricNodeUrl: nodeUrl
|
|
341
341
|
});
|
|
342
|
-
_context4.next =
|
|
342
|
+
_context4.next = 29;
|
|
343
343
|
return this.ReplaceMetadata({
|
|
344
344
|
libraryId: this.contentSpaceLibraryId,
|
|
345
345
|
objectId: objectId,
|
|
346
346
|
writeToken: createResponse.write_token,
|
|
347
347
|
metadata: metadata
|
|
348
348
|
});
|
|
349
|
-
case
|
|
349
|
+
case 29:
|
|
350
350
|
if (!bitcode) {
|
|
351
|
-
_context4.next =
|
|
351
|
+
_context4.next = 35;
|
|
352
352
|
break;
|
|
353
353
|
}
|
|
354
|
-
_context4.next =
|
|
354
|
+
_context4.next = 32;
|
|
355
355
|
return this.UploadPart({
|
|
356
356
|
libraryId: this.contentSpaceLibraryId,
|
|
357
357
|
objectId: objectId,
|
|
@@ -359,9 +359,9 @@ exports.CreateContentType = /*#__PURE__*/function () {
|
|
|
359
359
|
data: bitcode,
|
|
360
360
|
encrypted: false
|
|
361
361
|
});
|
|
362
|
-
case
|
|
362
|
+
case 32:
|
|
363
363
|
uploadResponse = _context4.sent;
|
|
364
|
-
_context4.next =
|
|
364
|
+
_context4.next = 35;
|
|
365
365
|
return this.ReplaceMetadata({
|
|
366
366
|
libraryId: this.contentSpaceLibraryId,
|
|
367
367
|
objectId: objectId,
|
|
@@ -369,33 +369,33 @@ exports.CreateContentType = /*#__PURE__*/function () {
|
|
|
369
369
|
metadataSubtree: "bitcode_part",
|
|
370
370
|
metadata: uploadResponse.part.hash
|
|
371
371
|
});
|
|
372
|
-
case
|
|
373
|
-
_context4.next =
|
|
372
|
+
case 35:
|
|
373
|
+
_context4.next = 37;
|
|
374
374
|
return this.FinalizeContentObject({
|
|
375
375
|
libraryId: this.contentSpaceLibraryId,
|
|
376
376
|
objectId: objectId,
|
|
377
377
|
writeToken: createResponse.write_token,
|
|
378
378
|
commitMessage: "Create content type"
|
|
379
379
|
});
|
|
380
|
-
case
|
|
381
|
-
_context4.next =
|
|
380
|
+
case 37:
|
|
381
|
+
_context4.next = 39;
|
|
382
382
|
return this.userProfileClient.TenantContractId();
|
|
383
|
-
case
|
|
383
|
+
case 39:
|
|
384
384
|
tenantContractId = _context4.sent;
|
|
385
385
|
if (!tenantContractId) {
|
|
386
|
-
_context4.next =
|
|
386
|
+
_context4.next = 44;
|
|
387
387
|
break;
|
|
388
388
|
}
|
|
389
|
-
_context4.next =
|
|
389
|
+
_context4.next = 43;
|
|
390
390
|
return this.SetTenantContractId({
|
|
391
391
|
contractAddress: contractAddress,
|
|
392
392
|
tenantContractId: tenantContractId
|
|
393
393
|
});
|
|
394
|
-
case
|
|
394
|
+
case 43:
|
|
395
395
|
this.Log("tenant_contract_id set for ".concat(objectId));
|
|
396
|
-
case
|
|
396
|
+
case 44:
|
|
397
397
|
return _context4.abrupt("return", objectId);
|
|
398
|
-
case
|
|
398
|
+
case 45:
|
|
399
399
|
case "end":
|
|
400
400
|
return _context4.stop();
|
|
401
401
|
}
|
|
@@ -430,32 +430,32 @@ exports.CreateContentType = /*#__PURE__*/function () {
|
|
|
430
430
|
* @returns {Promise<string>} - Library ID of created library
|
|
431
431
|
*/
|
|
432
432
|
exports.CreateContentLibrary = /*#__PURE__*/function () {
|
|
433
|
-
var _ref9 = _asyncToGenerator(/*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
|
|
434
|
-
var name, description, image, imageName, _ref8$metadata, metadata, kmsId, tenantContractId, _yield$this$authClien2, contractAddress, libraryId, objectId, editResponse
|
|
435
|
-
return _regeneratorRuntime.wrap(function (_context5) {
|
|
433
|
+
var _ref9 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee5(_ref8) {
|
|
434
|
+
var name, description, image, imageName, _ref8$metadata, metadata, kmsId, tenantContractId, _yield$this$authClien2, contractAddress, libraryId, objectId, editResponse;
|
|
435
|
+
return _regeneratorRuntime.wrap(function _callee5$(_context5) {
|
|
436
436
|
while (1) switch (_context5.prev = _context5.next) {
|
|
437
437
|
case 0:
|
|
438
438
|
name = _ref8.name, description = _ref8.description, image = _ref8.image, imageName = _ref8.imageName, _ref8$metadata = _ref8.metadata, metadata = _ref8$metadata === void 0 ? {} : _ref8$metadata, kmsId = _ref8.kmsId, tenantContractId = _ref8.tenantContractId;
|
|
439
439
|
if (kmsId) {
|
|
440
|
-
_context5.next =
|
|
440
|
+
_context5.next = 9;
|
|
441
441
|
break;
|
|
442
442
|
}
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
_context5.next =
|
|
443
|
+
_context5.t0 = "ikms";
|
|
444
|
+
_context5.t1 = this.utils;
|
|
445
|
+
_context5.next = 6;
|
|
446
446
|
return this.DefaultKMSAddress();
|
|
447
|
-
case
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
kmsId =
|
|
451
|
-
case
|
|
447
|
+
case 6:
|
|
448
|
+
_context5.t2 = _context5.sent;
|
|
449
|
+
_context5.t3 = _context5.t1.AddressToHash.call(_context5.t1, _context5.t2);
|
|
450
|
+
kmsId = _context5.t0.concat.call(_context5.t0, _context5.t3);
|
|
451
|
+
case 9:
|
|
452
452
|
this.Log("Creating content library");
|
|
453
453
|
this.Log("KMS ID: ".concat(kmsId));
|
|
454
|
-
_context5.next =
|
|
454
|
+
_context5.next = 13;
|
|
455
455
|
return this.authClient.CreateContentLibrary({
|
|
456
456
|
kmsId: kmsId
|
|
457
457
|
});
|
|
458
|
-
case
|
|
458
|
+
case 13:
|
|
459
459
|
_yield$this$authClien2 = _context5.sent;
|
|
460
460
|
contractAddress = _yield$this$authClien2.contractAddress;
|
|
461
461
|
metadata = _objectSpread(_objectSpread({}, metadata), {}, {
|
|
@@ -472,64 +472,64 @@ exports.CreateContentLibrary = /*#__PURE__*/function () {
|
|
|
472
472
|
|
|
473
473
|
// Set library content object type and metadata on automatically created library object
|
|
474
474
|
objectId = libraryId.replace("ilib", "iq__");
|
|
475
|
-
_context5.next =
|
|
475
|
+
_context5.next = 22;
|
|
476
476
|
return this.EditContentObject({
|
|
477
477
|
libraryId: libraryId,
|
|
478
478
|
objectId: objectId
|
|
479
479
|
});
|
|
480
|
-
case
|
|
480
|
+
case 22:
|
|
481
481
|
editResponse = _context5.sent;
|
|
482
|
-
_context5.next =
|
|
482
|
+
_context5.next = 25;
|
|
483
483
|
return this.ReplaceMetadata({
|
|
484
484
|
libraryId: libraryId,
|
|
485
485
|
objectId: objectId,
|
|
486
486
|
metadata: metadata,
|
|
487
487
|
writeToken: editResponse.write_token
|
|
488
488
|
});
|
|
489
|
-
case
|
|
490
|
-
_context5.next =
|
|
489
|
+
case 25:
|
|
490
|
+
_context5.next = 27;
|
|
491
491
|
return this.FinalizeContentObject({
|
|
492
492
|
libraryId: libraryId,
|
|
493
493
|
objectId: objectId,
|
|
494
494
|
writeToken: editResponse.write_token,
|
|
495
495
|
commitMessage: "Create library"
|
|
496
496
|
});
|
|
497
|
-
case
|
|
497
|
+
case 27:
|
|
498
498
|
if (!image) {
|
|
499
|
-
_context5.next =
|
|
499
|
+
_context5.next = 30;
|
|
500
500
|
break;
|
|
501
501
|
}
|
|
502
|
-
_context5.next =
|
|
502
|
+
_context5.next = 30;
|
|
503
503
|
return this.SetContentLibraryImage({
|
|
504
504
|
libraryId: libraryId,
|
|
505
505
|
image: image,
|
|
506
506
|
imageName: imageName
|
|
507
507
|
});
|
|
508
|
-
case
|
|
508
|
+
case 30:
|
|
509
509
|
if (tenantContractId) {
|
|
510
|
-
_context5.next =
|
|
510
|
+
_context5.next = 34;
|
|
511
511
|
break;
|
|
512
512
|
}
|
|
513
|
-
_context5.next =
|
|
513
|
+
_context5.next = 33;
|
|
514
514
|
return this.userProfileClient.TenantContractId();
|
|
515
|
-
case
|
|
515
|
+
case 33:
|
|
516
516
|
tenantContractId = _context5.sent;
|
|
517
|
-
case
|
|
517
|
+
case 34:
|
|
518
518
|
if (!tenantContractId) {
|
|
519
|
-
_context5.next =
|
|
519
|
+
_context5.next = 38;
|
|
520
520
|
break;
|
|
521
521
|
}
|
|
522
|
-
_context5.next =
|
|
522
|
+
_context5.next = 37;
|
|
523
523
|
return this.SetTenantContractId({
|
|
524
524
|
contractAddress: contractAddress,
|
|
525
525
|
tenantContractId: tenantContractId
|
|
526
526
|
});
|
|
527
|
-
case
|
|
527
|
+
case 37:
|
|
528
528
|
this.Log("tenant_contract_id set for ".concat(contractAddress));
|
|
529
|
-
case
|
|
529
|
+
case 38:
|
|
530
530
|
this.Log("Library ".concat(libraryId, " created"));
|
|
531
531
|
return _context5.abrupt("return", libraryId);
|
|
532
|
-
case
|
|
532
|
+
case 40:
|
|
533
533
|
case "end":
|
|
534
534
|
return _context5.stop();
|
|
535
535
|
}
|
|
@@ -551,12 +551,12 @@ exports.CreateContentLibrary = /*#__PURE__*/function () {
|
|
|
551
551
|
* @param {string=} imageName - Name of the image file
|
|
552
552
|
*/
|
|
553
553
|
exports.SetContentLibraryImage = /*#__PURE__*/function () {
|
|
554
|
-
var
|
|
554
|
+
var _ref11 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref10) {
|
|
555
555
|
var libraryId, writeToken, image, imageName, objectId;
|
|
556
|
-
return _regeneratorRuntime.wrap(function (_context6) {
|
|
556
|
+
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
557
557
|
while (1) switch (_context6.prev = _context6.next) {
|
|
558
558
|
case 0:
|
|
559
|
-
libraryId =
|
|
559
|
+
libraryId = _ref10.libraryId, writeToken = _ref10.writeToken, image = _ref10.image, imageName = _ref10.imageName;
|
|
560
560
|
ValidateLibrary(libraryId);
|
|
561
561
|
objectId = libraryId.replace("ilib", "iq__");
|
|
562
562
|
return _context6.abrupt("return", this.SetContentObjectImage({
|
|
@@ -566,14 +566,14 @@ exports.SetContentLibraryImage = /*#__PURE__*/function () {
|
|
|
566
566
|
image: image,
|
|
567
567
|
imageName: imageName
|
|
568
568
|
}));
|
|
569
|
-
case
|
|
569
|
+
case 4:
|
|
570
570
|
case "end":
|
|
571
571
|
return _context6.stop();
|
|
572
572
|
}
|
|
573
573
|
}, _callee6, this);
|
|
574
574
|
}));
|
|
575
575
|
return function (_x6) {
|
|
576
|
-
return
|
|
576
|
+
return _ref11.apply(this, arguments);
|
|
577
577
|
};
|
|
578
578
|
}();
|
|
579
579
|
|
|
@@ -590,12 +590,12 @@ exports.SetContentLibraryImage = /*#__PURE__*/function () {
|
|
|
590
590
|
* @param {string=} imagePath=public/display_image - Metadata path of the image link (default is recommended)
|
|
591
591
|
*/
|
|
592
592
|
exports.SetContentObjectImage = /*#__PURE__*/function () {
|
|
593
|
-
var
|
|
594
|
-
var libraryId, objectId, writeToken, image, imageName,
|
|
595
|
-
return _regeneratorRuntime.wrap(function (_context7) {
|
|
593
|
+
var _ref13 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref12) {
|
|
594
|
+
var libraryId, objectId, writeToken, image, imageName, _ref12$imagePath, imagePath;
|
|
595
|
+
return _regeneratorRuntime.wrap(function _callee7$(_context7) {
|
|
596
596
|
while (1) switch (_context7.prev = _context7.next) {
|
|
597
597
|
case 0:
|
|
598
|
-
libraryId =
|
|
598
|
+
libraryId = _ref12.libraryId, objectId = _ref12.objectId, writeToken = _ref12.writeToken, image = _ref12.image, imageName = _ref12.imageName, _ref12$imagePath = _ref12.imagePath, imagePath = _ref12$imagePath === void 0 ? "public/display_image" : _ref12$imagePath;
|
|
599
599
|
ValidateParameters({
|
|
600
600
|
libraryId: libraryId,
|
|
601
601
|
objectId: objectId
|
|
@@ -604,15 +604,15 @@ exports.SetContentObjectImage = /*#__PURE__*/function () {
|
|
|
604
604
|
ValidatePresence("image", image);
|
|
605
605
|
imageName = imageName || "display_image";
|
|
606
606
|
if (!(_typeof(image) === "object")) {
|
|
607
|
-
_context7.next =
|
|
607
|
+
_context7.next = 9;
|
|
608
608
|
break;
|
|
609
609
|
}
|
|
610
|
-
_context7.next =
|
|
610
|
+
_context7.next = 8;
|
|
611
611
|
return new Response(image).arrayBuffer();
|
|
612
|
-
case
|
|
612
|
+
case 8:
|
|
613
613
|
image = _context7.sent;
|
|
614
|
-
case
|
|
615
|
-
_context7.next =
|
|
614
|
+
case 9:
|
|
615
|
+
_context7.next = 11;
|
|
616
616
|
return this.UploadFiles({
|
|
617
617
|
libraryId: libraryId,
|
|
618
618
|
objectId: objectId,
|
|
@@ -625,8 +625,8 @@ exports.SetContentObjectImage = /*#__PURE__*/function () {
|
|
|
625
625
|
data: image
|
|
626
626
|
}]
|
|
627
627
|
});
|
|
628
|
-
case
|
|
629
|
-
_context7.next =
|
|
628
|
+
case 11:
|
|
629
|
+
_context7.next = 13;
|
|
630
630
|
return this.ReplaceMetadata({
|
|
631
631
|
libraryId: libraryId,
|
|
632
632
|
objectId: objectId,
|
|
@@ -636,14 +636,14 @@ exports.SetContentObjectImage = /*#__PURE__*/function () {
|
|
|
636
636
|
"/": "./files/".concat(imageName)
|
|
637
637
|
}
|
|
638
638
|
});
|
|
639
|
-
case
|
|
639
|
+
case 13:
|
|
640
640
|
case "end":
|
|
641
641
|
return _context7.stop();
|
|
642
642
|
}
|
|
643
643
|
}, _callee7, this);
|
|
644
644
|
}));
|
|
645
645
|
return function (_x7) {
|
|
646
|
-
return
|
|
646
|
+
return _ref13.apply(this, arguments);
|
|
647
647
|
};
|
|
648
648
|
}();
|
|
649
649
|
|
|
@@ -656,21 +656,21 @@ exports.SetContentObjectImage = /*#__PURE__*/function () {
|
|
|
656
656
|
* @param {string} libraryId - ID of the library to delete
|
|
657
657
|
*/
|
|
658
658
|
exports.DeleteContentLibrary = /*#__PURE__*/function () {
|
|
659
|
-
var
|
|
659
|
+
var _ref15 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8(_ref14) {
|
|
660
660
|
var libraryId;
|
|
661
|
-
return _regeneratorRuntime.wrap(function (_context8) {
|
|
661
|
+
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
662
662
|
while (1) switch (_context8.prev = _context8.next) {
|
|
663
663
|
case 0:
|
|
664
|
-
libraryId =
|
|
664
|
+
libraryId = _ref14.libraryId;
|
|
665
665
|
throw Error("Delete library not supported. (".concat(libraryId, ")"));
|
|
666
|
-
case
|
|
666
|
+
case 2:
|
|
667
667
|
case "end":
|
|
668
668
|
return _context8.stop();
|
|
669
669
|
}
|
|
670
670
|
}, _callee8);
|
|
671
671
|
}));
|
|
672
672
|
return function (_x8) {
|
|
673
|
-
return
|
|
673
|
+
return _ref15.apply(this, arguments);
|
|
674
674
|
};
|
|
675
675
|
}();
|
|
676
676
|
|
|
@@ -691,49 +691,49 @@ exports.DeleteContentLibrary = /*#__PURE__*/function () {
|
|
|
691
691
|
* @returns {Promise<string>} - Hash of the addContentType transaction
|
|
692
692
|
*/
|
|
693
693
|
exports.AddLibraryContentType = /*#__PURE__*/function () {
|
|
694
|
-
var
|
|
694
|
+
var _ref17 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee9(_ref16) {
|
|
695
695
|
var libraryId, typeId, typeName, typeHash, customContractAddress, type, typeAddress, event;
|
|
696
|
-
return _regeneratorRuntime.wrap(function (_context9) {
|
|
696
|
+
return _regeneratorRuntime.wrap(function _callee9$(_context9) {
|
|
697
697
|
while (1) switch (_context9.prev = _context9.next) {
|
|
698
698
|
case 0:
|
|
699
|
-
libraryId =
|
|
699
|
+
libraryId = _ref16.libraryId, typeId = _ref16.typeId, typeName = _ref16.typeName, typeHash = _ref16.typeHash, customContractAddress = _ref16.customContractAddress;
|
|
700
700
|
ValidateLibrary(libraryId);
|
|
701
701
|
this.Log("Adding library content type to ".concat(libraryId, ": ").concat(typeId || typeHash || typeName));
|
|
702
702
|
if (typeHash) {
|
|
703
703
|
typeId = this.utils.DecodeVersionHash(typeHash).objectId;
|
|
704
704
|
}
|
|
705
705
|
if (typeId) {
|
|
706
|
-
_context9.next =
|
|
706
|
+
_context9.next = 9;
|
|
707
707
|
break;
|
|
708
708
|
}
|
|
709
|
-
_context9.next =
|
|
709
|
+
_context9.next = 7;
|
|
710
710
|
return this.ContentType({
|
|
711
711
|
name: typeName
|
|
712
712
|
});
|
|
713
|
-
case
|
|
713
|
+
case 7:
|
|
714
714
|
type = _context9.sent;
|
|
715
715
|
typeId = type.id;
|
|
716
|
-
case
|
|
716
|
+
case 9:
|
|
717
717
|
this.Log("Type ID: ".concat(typeId));
|
|
718
718
|
typeAddress = this.utils.HashToAddress(typeId);
|
|
719
719
|
customContractAddress = customContractAddress || this.utils.nullAddress;
|
|
720
|
-
_context9.next =
|
|
720
|
+
_context9.next = 14;
|
|
721
721
|
return this.ethClient.CallContractMethodAndWait({
|
|
722
722
|
contractAddress: this.utils.HashToAddress(libraryId),
|
|
723
723
|
methodName: "addContentType",
|
|
724
724
|
methodArgs: [typeAddress, customContractAddress]
|
|
725
725
|
});
|
|
726
|
-
case
|
|
726
|
+
case 14:
|
|
727
727
|
event = _context9.sent;
|
|
728
728
|
return _context9.abrupt("return", event.transactionHash);
|
|
729
|
-
case
|
|
729
|
+
case 16:
|
|
730
730
|
case "end":
|
|
731
731
|
return _context9.stop();
|
|
732
732
|
}
|
|
733
733
|
}, _callee9, this);
|
|
734
734
|
}));
|
|
735
735
|
return function (_x9) {
|
|
736
|
-
return
|
|
736
|
+
return _ref17.apply(this, arguments);
|
|
737
737
|
};
|
|
738
738
|
}();
|
|
739
739
|
|
|
@@ -750,48 +750,48 @@ exports.AddLibraryContentType = /*#__PURE__*/function () {
|
|
|
750
750
|
* @returns {Promise<string>} - Hash of the removeContentType transaction
|
|
751
751
|
*/
|
|
752
752
|
exports.RemoveLibraryContentType = /*#__PURE__*/function () {
|
|
753
|
-
var
|
|
753
|
+
var _ref19 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref18) {
|
|
754
754
|
var libraryId, typeId, typeName, typeHash, type, typeAddress, event;
|
|
755
|
-
return _regeneratorRuntime.wrap(function (
|
|
756
|
-
while (1) switch (
|
|
755
|
+
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
756
|
+
while (1) switch (_context10.prev = _context10.next) {
|
|
757
757
|
case 0:
|
|
758
|
-
libraryId =
|
|
758
|
+
libraryId = _ref18.libraryId, typeId = _ref18.typeId, typeName = _ref18.typeName, typeHash = _ref18.typeHash;
|
|
759
759
|
ValidateLibrary(libraryId);
|
|
760
760
|
this.Log("Removing library content type from ".concat(libraryId, ": ").concat(typeId || typeHash || typeName));
|
|
761
761
|
if (typeHash) {
|
|
762
762
|
typeId = this.utils.DecodeVersionHash(typeHash).objectId;
|
|
763
763
|
}
|
|
764
764
|
if (typeId) {
|
|
765
|
-
|
|
765
|
+
_context10.next = 9;
|
|
766
766
|
break;
|
|
767
767
|
}
|
|
768
|
-
|
|
768
|
+
_context10.next = 7;
|
|
769
769
|
return this.ContentType({
|
|
770
770
|
name: typeName
|
|
771
771
|
});
|
|
772
|
-
case
|
|
773
|
-
type =
|
|
772
|
+
case 7:
|
|
773
|
+
type = _context10.sent;
|
|
774
774
|
typeId = type.id;
|
|
775
|
-
case
|
|
775
|
+
case 9:
|
|
776
776
|
this.Log("Type ID: ".concat(typeId));
|
|
777
777
|
typeAddress = this.utils.HashToAddress(typeId);
|
|
778
|
-
|
|
778
|
+
_context10.next = 13;
|
|
779
779
|
return this.ethClient.CallContractMethodAndWait({
|
|
780
780
|
contractAddress: this.utils.HashToAddress(libraryId),
|
|
781
781
|
methodName: "removeContentType",
|
|
782
782
|
methodArgs: [typeAddress]
|
|
783
783
|
});
|
|
784
|
-
case
|
|
785
|
-
event =
|
|
786
|
-
return
|
|
787
|
-
case
|
|
784
|
+
case 13:
|
|
785
|
+
event = _context10.sent;
|
|
786
|
+
return _context10.abrupt("return", event.transactionHash);
|
|
787
|
+
case 15:
|
|
788
788
|
case "end":
|
|
789
|
-
return
|
|
789
|
+
return _context10.stop();
|
|
790
790
|
}
|
|
791
|
-
},
|
|
791
|
+
}, _callee10, this);
|
|
792
792
|
}));
|
|
793
|
-
return function (
|
|
794
|
-
return
|
|
793
|
+
return function (_x10) {
|
|
794
|
+
return _ref19.apply(this, arguments);
|
|
795
795
|
};
|
|
796
796
|
}();
|
|
797
797
|
|
|
@@ -820,176 +820,176 @@ exports.RemoveLibraryContentType = /*#__PURE__*/function () {
|
|
|
820
820
|
* @returns {Promise<Object>} - Response containing the object ID and write token of the draft, as well as the url of the node that created the write token.
|
|
821
821
|
*/
|
|
822
822
|
exports.CreateContentObject = /*#__PURE__*/function () {
|
|
823
|
-
var
|
|
824
|
-
var libraryId, objectId,
|
|
825
|
-
return _regeneratorRuntime.wrap(function (
|
|
826
|
-
while (1) switch (
|
|
823
|
+
var _ref21 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref20) {
|
|
824
|
+
var libraryId, objectId, _ref20$options, options, typeId, type, currentAccountAddress, canContribute, _yield$this$authClien3, contractAddress, path, rawCreateResponse, nodeUrl, createResponse;
|
|
825
|
+
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
826
|
+
while (1) switch (_context11.prev = _context11.next) {
|
|
827
827
|
case 0:
|
|
828
|
-
libraryId =
|
|
828
|
+
libraryId = _ref20.libraryId, objectId = _ref20.objectId, _ref20$options = _ref20.options, options = _ref20$options === void 0 ? {} : _ref20$options;
|
|
829
829
|
ValidateLibrary(libraryId);
|
|
830
830
|
if (objectId) {
|
|
831
831
|
ValidateObject(objectId);
|
|
832
832
|
}
|
|
833
833
|
this.Log("Creating content object: ".concat(libraryId, " ").concat(objectId || ""));
|
|
834
834
|
if (!(options.noEncryptionConk && options.createKMSConk)) {
|
|
835
|
-
|
|
835
|
+
_context11.next = 6;
|
|
836
836
|
break;
|
|
837
837
|
}
|
|
838
838
|
throw new Error("Incompatible options: noEncryptionConk and createKMSConk both set to true");
|
|
839
|
-
case
|
|
839
|
+
case 6:
|
|
840
840
|
if (!options.type) {
|
|
841
|
-
|
|
841
|
+
_context11.next = 28;
|
|
842
842
|
break;
|
|
843
843
|
}
|
|
844
844
|
this.Log("Type specified: ".concat(options.type));
|
|
845
845
|
type = options.type;
|
|
846
846
|
if (!type.startsWith("hq__")) {
|
|
847
|
-
|
|
847
|
+
_context11.next = 15;
|
|
848
848
|
break;
|
|
849
849
|
}
|
|
850
|
-
|
|
850
|
+
_context11.next = 12;
|
|
851
851
|
return this.ContentType({
|
|
852
852
|
versionHash: type
|
|
853
853
|
});
|
|
854
|
-
case
|
|
855
|
-
type =
|
|
856
|
-
|
|
854
|
+
case 12:
|
|
855
|
+
type = _context11.sent;
|
|
856
|
+
_context11.next = 24;
|
|
857
857
|
break;
|
|
858
|
-
case
|
|
858
|
+
case 15:
|
|
859
859
|
if (!type.startsWith("iq__")) {
|
|
860
|
-
|
|
860
|
+
_context11.next = 21;
|
|
861
861
|
break;
|
|
862
862
|
}
|
|
863
|
-
|
|
863
|
+
_context11.next = 18;
|
|
864
864
|
return this.ContentType({
|
|
865
865
|
typeId: type
|
|
866
866
|
});
|
|
867
|
-
case
|
|
868
|
-
type =
|
|
869
|
-
|
|
867
|
+
case 18:
|
|
868
|
+
type = _context11.sent;
|
|
869
|
+
_context11.next = 24;
|
|
870
870
|
break;
|
|
871
|
-
case
|
|
872
|
-
|
|
871
|
+
case 21:
|
|
872
|
+
_context11.next = 23;
|
|
873
873
|
return this.ContentType({
|
|
874
874
|
name: type
|
|
875
875
|
});
|
|
876
|
-
case
|
|
877
|
-
type =
|
|
878
|
-
case
|
|
876
|
+
case 23:
|
|
877
|
+
type = _context11.sent;
|
|
878
|
+
case 24:
|
|
879
879
|
if (type) {
|
|
880
|
-
|
|
880
|
+
_context11.next = 26;
|
|
881
881
|
break;
|
|
882
882
|
}
|
|
883
883
|
throw Error("Unable to find content type '".concat(options.type, "'"));
|
|
884
|
-
case
|
|
884
|
+
case 26:
|
|
885
885
|
typeId = type.id;
|
|
886
886
|
options.type = type.hash;
|
|
887
|
-
case
|
|
887
|
+
case 28:
|
|
888
888
|
if (objectId) {
|
|
889
|
-
|
|
889
|
+
_context11.next = 46;
|
|
890
890
|
break;
|
|
891
891
|
}
|
|
892
|
-
|
|
892
|
+
_context11.next = 31;
|
|
893
893
|
return this.CurrentAccountAddress();
|
|
894
|
-
case
|
|
895
|
-
currentAccountAddress =
|
|
896
|
-
|
|
894
|
+
case 31:
|
|
895
|
+
currentAccountAddress = _context11.sent;
|
|
896
|
+
_context11.next = 34;
|
|
897
897
|
return this.CallContractMethod({
|
|
898
898
|
contractAddress: this.utils.HashToAddress(libraryId),
|
|
899
899
|
methodName: "canContribute",
|
|
900
900
|
methodArgs: [currentAccountAddress]
|
|
901
901
|
});
|
|
902
|
-
case
|
|
903
|
-
canContribute =
|
|
902
|
+
case 34:
|
|
903
|
+
canContribute = _context11.sent;
|
|
904
904
|
if (canContribute) {
|
|
905
|
-
|
|
905
|
+
_context11.next = 37;
|
|
906
906
|
break;
|
|
907
907
|
}
|
|
908
908
|
throw Error("Current user does not have permission to create content in library ".concat(libraryId));
|
|
909
|
-
case
|
|
909
|
+
case 37:
|
|
910
910
|
this.Log("Deploying contract...");
|
|
911
|
-
|
|
911
|
+
_context11.next = 40;
|
|
912
912
|
return this.authClient.CreateContentObject({
|
|
913
913
|
libraryId: libraryId,
|
|
914
914
|
typeId: typeId
|
|
915
915
|
});
|
|
916
|
-
case
|
|
917
|
-
_yield$this$authClien3 =
|
|
916
|
+
case 40:
|
|
917
|
+
_yield$this$authClien3 = _context11.sent;
|
|
918
918
|
contractAddress = _yield$this$authClien3.contractAddress;
|
|
919
919
|
objectId = this.utils.AddressToObjectId(contractAddress);
|
|
920
920
|
this.Log("Contract deployed: ".concat(contractAddress, " ").concat(objectId));
|
|
921
|
-
|
|
921
|
+
_context11.next = 53;
|
|
922
922
|
break;
|
|
923
|
-
case
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
923
|
+
case 46:
|
|
924
|
+
_context11.t0 = this;
|
|
925
|
+
_context11.t1 = "Contract already deployed for contract type: ";
|
|
926
|
+
_context11.next = 50;
|
|
927
927
|
return this.AccessType({
|
|
928
928
|
id: objectId
|
|
929
929
|
});
|
|
930
|
-
case
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
case
|
|
930
|
+
case 50:
|
|
931
|
+
_context11.t2 = _context11.sent;
|
|
932
|
+
_context11.t3 = _context11.t1.concat.call(_context11.t1, _context11.t2);
|
|
933
|
+
_context11.t0.Log.call(_context11.t0, _context11.t3);
|
|
934
|
+
case 53:
|
|
935
935
|
if (!options.visibility) {
|
|
936
|
-
|
|
936
|
+
_context11.next = 57;
|
|
937
937
|
break;
|
|
938
938
|
}
|
|
939
939
|
this.Log("Setting visibility to ".concat(options.visibility));
|
|
940
|
-
|
|
940
|
+
_context11.next = 57;
|
|
941
941
|
return this.SetVisibility({
|
|
942
942
|
id: objectId,
|
|
943
943
|
visibility: options.visibility
|
|
944
944
|
});
|
|
945
|
-
case
|
|
945
|
+
case 57:
|
|
946
946
|
path = UrlJoin("qid", objectId);
|
|
947
|
-
|
|
948
|
-
|
|
947
|
+
_context11.t4 = this.HttpClient;
|
|
948
|
+
_context11.next = 61;
|
|
949
949
|
return this.authClient.AuthorizationHeader({
|
|
950
950
|
libraryId: libraryId,
|
|
951
951
|
objectId: objectId,
|
|
952
952
|
update: true
|
|
953
953
|
});
|
|
954
|
-
case
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
954
|
+
case 61:
|
|
955
|
+
_context11.t5 = _context11.sent;
|
|
956
|
+
_context11.t6 = path;
|
|
957
|
+
_context11.t7 = {
|
|
958
958
|
// filter out options not recognized by server (noEncryptionConk, createKMSConk)
|
|
959
959
|
type: options.type,
|
|
960
960
|
meta: options.meta,
|
|
961
961
|
copy_from: options.copy_from
|
|
962
962
|
};
|
|
963
|
-
|
|
964
|
-
headers:
|
|
963
|
+
_context11.t8 = {
|
|
964
|
+
headers: _context11.t5,
|
|
965
965
|
method: "POST",
|
|
966
|
-
path:
|
|
967
|
-
body:
|
|
966
|
+
path: _context11.t6,
|
|
967
|
+
body: _context11.t7
|
|
968
968
|
};
|
|
969
|
-
|
|
970
|
-
return
|
|
971
|
-
case
|
|
972
|
-
rawCreateResponse =
|
|
969
|
+
_context11.next = 67;
|
|
970
|
+
return _context11.t4.Request.call(_context11.t4, _context11.t8);
|
|
971
|
+
case 67:
|
|
972
|
+
rawCreateResponse = _context11.sent;
|
|
973
973
|
// extract the url for the node that handled the request
|
|
974
974
|
// (not strictly needed now that we can quickly look up node URL for a write token,
|
|
975
975
|
// but still convenient)
|
|
976
976
|
nodeUrl = new URL(rawCreateResponse.url).origin;
|
|
977
|
-
|
|
977
|
+
_context11.next = 71;
|
|
978
978
|
return this.utils.ResponseToJson(rawCreateResponse, this.HttpClient.debug, this.HttpClient.Log.bind(this.HttpClient));
|
|
979
|
-
case
|
|
980
|
-
createResponse =
|
|
979
|
+
case 71:
|
|
980
|
+
createResponse = _context11.sent;
|
|
981
981
|
if (options.noEncryptionConk) {
|
|
982
|
-
|
|
982
|
+
_context11.next = 75;
|
|
983
983
|
break;
|
|
984
984
|
}
|
|
985
|
-
|
|
985
|
+
_context11.next = 75;
|
|
986
986
|
return this.CreateEncryptionConk({
|
|
987
987
|
libraryId: libraryId,
|
|
988
988
|
objectId: objectId,
|
|
989
989
|
writeToken: createResponse.write_token,
|
|
990
990
|
createKMSConk: !!options.createKMSConk // make sure `undefined` gets converted to `false`
|
|
991
991
|
});
|
|
992
|
-
case
|
|
992
|
+
case 75:
|
|
993
993
|
// Record the node used in creating this write token
|
|
994
994
|
this.RecordWriteToken({
|
|
995
995
|
writeToken: createResponse.write_token,
|
|
@@ -998,15 +998,15 @@ exports.CreateContentObject = /*#__PURE__*/function () {
|
|
|
998
998
|
createResponse.writeToken = createResponse.write_token;
|
|
999
999
|
createResponse.objectId = createResponse.id;
|
|
1000
1000
|
createResponse.nodeUrl = nodeUrl;
|
|
1001
|
-
return
|
|
1002
|
-
case
|
|
1001
|
+
return _context11.abrupt("return", createResponse);
|
|
1002
|
+
case 80:
|
|
1003
1003
|
case "end":
|
|
1004
|
-
return
|
|
1004
|
+
return _context11.stop();
|
|
1005
1005
|
}
|
|
1006
|
-
},
|
|
1006
|
+
}, _callee11, this);
|
|
1007
1007
|
}));
|
|
1008
|
-
return function (
|
|
1009
|
-
return
|
|
1008
|
+
return function (_x11) {
|
|
1009
|
+
return _ref21.apply(this, arguments);
|
|
1010
1010
|
};
|
|
1011
1011
|
}();
|
|
1012
1012
|
|
|
@@ -1029,124 +1029,124 @@ exports.CreateContentObject = /*#__PURE__*/function () {
|
|
|
1029
1029
|
* @returns {Promise<Object>} - Response containing the object ID and write token of the draft
|
|
1030
1030
|
*/
|
|
1031
1031
|
exports.CopyContentObject = /*#__PURE__*/function () {
|
|
1032
|
-
var
|
|
1032
|
+
var _ref23 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref22) {
|
|
1033
1033
|
var _this2 = this;
|
|
1034
|
-
var libraryId, originalVersionHash,
|
|
1035
|
-
return _regeneratorRuntime.wrap(function (
|
|
1036
|
-
while (1) switch (
|
|
1034
|
+
var libraryId, originalVersionHash, _ref22$options, options, _yield$this$CreateCon, objectId, writeToken, originalObjectId, metadata, permission, userCapKey, userConkKey;
|
|
1035
|
+
return _regeneratorRuntime.wrap(function _callee13$(_context13) {
|
|
1036
|
+
while (1) switch (_context13.prev = _context13.next) {
|
|
1037
1037
|
case 0:
|
|
1038
|
-
libraryId =
|
|
1038
|
+
libraryId = _ref22.libraryId, originalVersionHash = _ref22.originalVersionHash, _ref22$options = _ref22.options, options = _ref22$options === void 0 ? {} : _ref22$options;
|
|
1039
1039
|
ValidateLibrary(libraryId);
|
|
1040
1040
|
ValidateVersion(originalVersionHash);
|
|
1041
1041
|
options.copy_from = originalVersionHash;
|
|
1042
|
-
|
|
1042
|
+
_context13.next = 6;
|
|
1043
1043
|
return this.CreateContentObject({
|
|
1044
1044
|
libraryId: libraryId,
|
|
1045
1045
|
options: options
|
|
1046
1046
|
});
|
|
1047
|
-
case
|
|
1048
|
-
_yield$this$CreateCon =
|
|
1047
|
+
case 6:
|
|
1048
|
+
_yield$this$CreateCon = _context13.sent;
|
|
1049
1049
|
objectId = _yield$this$CreateCon.objectId;
|
|
1050
1050
|
writeToken = _yield$this$CreateCon.writeToken;
|
|
1051
1051
|
originalObjectId = this.utils.DecodeVersionHash(originalVersionHash).objectId;
|
|
1052
|
-
|
|
1052
|
+
_context13.next = 12;
|
|
1053
1053
|
return this.ContentObjectMetadata({
|
|
1054
1054
|
versionHash: originalVersionHash
|
|
1055
1055
|
});
|
|
1056
|
-
case
|
|
1057
|
-
metadata =
|
|
1058
|
-
|
|
1056
|
+
case 12:
|
|
1057
|
+
metadata = _context13.sent;
|
|
1058
|
+
_context13.next = 15;
|
|
1059
1059
|
return this.Permission({
|
|
1060
1060
|
objectId: originalObjectId
|
|
1061
1061
|
});
|
|
1062
|
-
case
|
|
1063
|
-
permission =
|
|
1062
|
+
case 15:
|
|
1063
|
+
permission = _context13.sent;
|
|
1064
1064
|
// User CAP
|
|
1065
1065
|
userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
|
|
1066
1066
|
if (!metadata[userCapKey]) {
|
|
1067
|
-
|
|
1067
|
+
_context13.next = 33;
|
|
1068
1068
|
break;
|
|
1069
1069
|
}
|
|
1070
|
-
|
|
1070
|
+
_context13.next = 20;
|
|
1071
1071
|
return this.Crypto.DecryptCap(metadata[userCapKey], this.signer._signingKey().privateKey);
|
|
1072
|
-
case
|
|
1073
|
-
userConkKey =
|
|
1072
|
+
case 20:
|
|
1073
|
+
userConkKey = _context13.sent;
|
|
1074
1074
|
userConkKey.qid = objectId;
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1075
|
+
_context13.t0 = this;
|
|
1076
|
+
_context13.t1 = libraryId;
|
|
1077
|
+
_context13.t2 = objectId;
|
|
1078
|
+
_context13.t3 = writeToken;
|
|
1079
|
+
_context13.t4 = userCapKey;
|
|
1080
|
+
_context13.next = 29;
|
|
1081
1081
|
return this.Crypto.EncryptConk(userConkKey, this.signer._signingKey().publicKey);
|
|
1082
|
-
case
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
libraryId:
|
|
1086
|
-
objectId:
|
|
1087
|
-
writeToken:
|
|
1088
|
-
metadataSubtree:
|
|
1089
|
-
metadata:
|
|
1082
|
+
case 29:
|
|
1083
|
+
_context13.t5 = _context13.sent;
|
|
1084
|
+
_context13.t6 = {
|
|
1085
|
+
libraryId: _context13.t1,
|
|
1086
|
+
objectId: _context13.t2,
|
|
1087
|
+
writeToken: _context13.t3,
|
|
1088
|
+
metadataSubtree: _context13.t4,
|
|
1089
|
+
metadata: _context13.t5
|
|
1090
1090
|
};
|
|
1091
|
-
|
|
1092
|
-
return
|
|
1093
|
-
case
|
|
1094
|
-
|
|
1091
|
+
_context13.next = 33;
|
|
1092
|
+
return _context13.t0.ReplaceMetadata.call(_context13.t0, _context13.t6);
|
|
1093
|
+
case 33:
|
|
1094
|
+
_context13.next = 35;
|
|
1095
1095
|
return Promise.all(Object.keys(metadata).filter(function (key) {
|
|
1096
1096
|
return key.startsWith("eluv.caps.ikms");
|
|
1097
|
-
}).map(/*#__PURE__*/function () {
|
|
1098
|
-
var
|
|
1099
|
-
return _regeneratorRuntime.wrap(function (
|
|
1100
|
-
while (1) switch (
|
|
1097
|
+
}).map( /*#__PURE__*/function () {
|
|
1098
|
+
var _ref24 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee12(kmsCapKey) {
|
|
1099
|
+
return _regeneratorRuntime.wrap(function _callee12$(_context12) {
|
|
1100
|
+
while (1) switch (_context12.prev = _context12.next) {
|
|
1101
1101
|
case 0:
|
|
1102
|
-
|
|
1102
|
+
_context12.next = 2;
|
|
1103
1103
|
return _this2.DeleteMetadata({
|
|
1104
1104
|
libraryId: libraryId,
|
|
1105
1105
|
objectId: objectId,
|
|
1106
1106
|
writeToken: writeToken,
|
|
1107
1107
|
metadataSubtree: kmsCapKey
|
|
1108
1108
|
});
|
|
1109
|
-
case 1:
|
|
1110
|
-
return _context10.abrupt("return", _context10.sent);
|
|
1111
1109
|
case 2:
|
|
1110
|
+
return _context12.abrupt("return", _context12.sent);
|
|
1111
|
+
case 3:
|
|
1112
1112
|
case "end":
|
|
1113
|
-
return
|
|
1113
|
+
return _context12.stop();
|
|
1114
1114
|
}
|
|
1115
|
-
},
|
|
1115
|
+
}, _callee12);
|
|
1116
1116
|
}));
|
|
1117
|
-
return function (
|
|
1118
|
-
return
|
|
1117
|
+
return function (_x13) {
|
|
1118
|
+
return _ref24.apply(this, arguments);
|
|
1119
1119
|
};
|
|
1120
1120
|
}()));
|
|
1121
|
-
case
|
|
1121
|
+
case 35:
|
|
1122
1122
|
if (!(permission !== "owner")) {
|
|
1123
|
-
|
|
1123
|
+
_context13.next = 38;
|
|
1124
1124
|
break;
|
|
1125
1125
|
}
|
|
1126
|
-
|
|
1126
|
+
_context13.next = 38;
|
|
1127
1127
|
return this.CreateEncryptionConk({
|
|
1128
1128
|
libraryId: libraryId,
|
|
1129
1129
|
objectId: objectId,
|
|
1130
1130
|
writeToken: writeToken,
|
|
1131
1131
|
createKMSConk: true
|
|
1132
1132
|
});
|
|
1133
|
-
case
|
|
1134
|
-
|
|
1133
|
+
case 38:
|
|
1134
|
+
_context13.next = 40;
|
|
1135
1135
|
return this.FinalizeContentObject({
|
|
1136
1136
|
libraryId: libraryId,
|
|
1137
1137
|
objectId: objectId,
|
|
1138
1138
|
writeToken: writeToken
|
|
1139
1139
|
});
|
|
1140
|
-
case
|
|
1141
|
-
return
|
|
1142
|
-
case
|
|
1140
|
+
case 40:
|
|
1141
|
+
return _context13.abrupt("return", _context13.sent);
|
|
1142
|
+
case 41:
|
|
1143
1143
|
case "end":
|
|
1144
|
-
return
|
|
1144
|
+
return _context13.stop();
|
|
1145
1145
|
}
|
|
1146
|
-
},
|
|
1146
|
+
}, _callee13, this);
|
|
1147
1147
|
}));
|
|
1148
|
-
return function (
|
|
1149
|
-
return
|
|
1148
|
+
return function (_x12) {
|
|
1149
|
+
return _ref23.apply(this, arguments);
|
|
1150
1150
|
};
|
|
1151
1151
|
}();
|
|
1152
1152
|
|
|
@@ -1163,50 +1163,50 @@ exports.CopyContentObject = /*#__PURE__*/function () {
|
|
|
1163
1163
|
* @returns {Promise<Object>}
|
|
1164
1164
|
*/
|
|
1165
1165
|
exports.CreateNonOwnerCap = /*#__PURE__*/function () {
|
|
1166
|
-
var
|
|
1166
|
+
var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee14(_ref25) {
|
|
1167
1167
|
var objectId, libraryId, publicKey, writeToken, userCapKey, userCapValue, userConk, publicAddress, targetUserCapKey, targetUserCapValue, finalize;
|
|
1168
|
-
return _regeneratorRuntime.wrap(function (
|
|
1169
|
-
while (1) switch (
|
|
1168
|
+
return _regeneratorRuntime.wrap(function _callee14$(_context14) {
|
|
1169
|
+
while (1) switch (_context14.prev = _context14.next) {
|
|
1170
1170
|
case 0:
|
|
1171
|
-
objectId =
|
|
1171
|
+
objectId = _ref25.objectId, libraryId = _ref25.libraryId, publicKey = _ref25.publicKey, writeToken = _ref25.writeToken;
|
|
1172
1172
|
userCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(this.signer.address));
|
|
1173
|
-
|
|
1173
|
+
_context14.next = 4;
|
|
1174
1174
|
return this.ContentObjectMetadata({
|
|
1175
1175
|
objectId: objectId,
|
|
1176
1176
|
libraryId: libraryId,
|
|
1177
1177
|
metadataSubtree: userCapKey
|
|
1178
1178
|
});
|
|
1179
|
-
case
|
|
1180
|
-
userCapValue =
|
|
1179
|
+
case 4:
|
|
1180
|
+
userCapValue = _context14.sent;
|
|
1181
1181
|
if (userCapValue) {
|
|
1182
|
-
|
|
1182
|
+
_context14.next = 7;
|
|
1183
1183
|
break;
|
|
1184
1184
|
}
|
|
1185
1185
|
throw Error("No user cap found for current user");
|
|
1186
|
-
case
|
|
1187
|
-
|
|
1186
|
+
case 7:
|
|
1187
|
+
_context14.next = 9;
|
|
1188
1188
|
return this.Crypto.DecryptCap(userCapValue, this.signer._signingKey().privateKey);
|
|
1189
|
-
case
|
|
1190
|
-
userConk =
|
|
1189
|
+
case 9:
|
|
1190
|
+
userConk = _context14.sent;
|
|
1191
1191
|
publicAddress = this.utils.PublicKeyToAddress(publicKey);
|
|
1192
1192
|
targetUserCapKey = "eluv.caps.iusr".concat(this.utils.AddressToHash(publicAddress));
|
|
1193
|
-
|
|
1193
|
+
_context14.next = 14;
|
|
1194
1194
|
return this.Crypto.EncryptConk(userConk, publicKey);
|
|
1195
|
-
case
|
|
1196
|
-
targetUserCapValue =
|
|
1195
|
+
case 14:
|
|
1196
|
+
targetUserCapValue = _context14.sent;
|
|
1197
1197
|
finalize = !writeToken;
|
|
1198
1198
|
if (writeToken) {
|
|
1199
|
-
|
|
1199
|
+
_context14.next = 20;
|
|
1200
1200
|
break;
|
|
1201
1201
|
}
|
|
1202
|
-
|
|
1202
|
+
_context14.next = 19;
|
|
1203
1203
|
return this.EditContentObject({
|
|
1204
1204
|
libraryId: libraryId,
|
|
1205
1205
|
objectId: objectId
|
|
1206
1206
|
}).writeToken;
|
|
1207
|
-
case
|
|
1208
|
-
writeToken =
|
|
1209
|
-
case
|
|
1207
|
+
case 19:
|
|
1208
|
+
writeToken = _context14.sent;
|
|
1209
|
+
case 20:
|
|
1210
1210
|
this.ReplaceMetadata({
|
|
1211
1211
|
libraryId: libraryId,
|
|
1212
1212
|
objectId: objectId,
|
|
@@ -1215,24 +1215,24 @@ exports.CreateNonOwnerCap = /*#__PURE__*/function () {
|
|
|
1215
1215
|
metadata: targetUserCapValue
|
|
1216
1216
|
});
|
|
1217
1217
|
if (!finalize) {
|
|
1218
|
-
|
|
1218
|
+
_context14.next = 24;
|
|
1219
1219
|
break;
|
|
1220
1220
|
}
|
|
1221
|
-
|
|
1221
|
+
_context14.next = 24;
|
|
1222
1222
|
return this.FinalizeContentObject({
|
|
1223
1223
|
libraryId: libraryId,
|
|
1224
1224
|
objectId: objectId,
|
|
1225
1225
|
writeToken: writeToken,
|
|
1226
1226
|
commitMessage: "Create non-owner cap"
|
|
1227
1227
|
});
|
|
1228
|
-
case
|
|
1228
|
+
case 24:
|
|
1229
1229
|
case "end":
|
|
1230
|
-
return
|
|
1230
|
+
return _context14.stop();
|
|
1231
1231
|
}
|
|
1232
|
-
},
|
|
1232
|
+
}, _callee14, this);
|
|
1233
1233
|
}));
|
|
1234
|
-
return function (
|
|
1235
|
-
return
|
|
1234
|
+
return function (_x14) {
|
|
1235
|
+
return _ref26.apply(this, arguments);
|
|
1236
1236
|
};
|
|
1237
1237
|
}();
|
|
1238
1238
|
|
|
@@ -1250,91 +1250,91 @@ exports.CreateNonOwnerCap = /*#__PURE__*/function () {
|
|
|
1250
1250
|
* @returns {Promise<object>} - Response containing the object ID and write token of the draft, as well as URL of node handling the draft
|
|
1251
1251
|
*/
|
|
1252
1252
|
exports.EditContentObject = /*#__PURE__*/function () {
|
|
1253
|
-
var
|
|
1254
|
-
var libraryId, objectId,
|
|
1255
|
-
return _regeneratorRuntime.wrap(function (
|
|
1256
|
-
while (1) switch (
|
|
1253
|
+
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref27) {
|
|
1254
|
+
var libraryId, objectId, _ref27$options, options, path, rawEditResponse, nodeUrl, editResponse;
|
|
1255
|
+
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1256
|
+
while (1) switch (_context15.prev = _context15.next) {
|
|
1257
1257
|
case 0:
|
|
1258
|
-
libraryId =
|
|
1258
|
+
libraryId = _ref27.libraryId, objectId = _ref27.objectId, _ref27$options = _ref27.options, options = _ref27$options === void 0 ? {} : _ref27$options;
|
|
1259
1259
|
ValidateParameters({
|
|
1260
1260
|
libraryId: libraryId,
|
|
1261
1261
|
objectId: objectId
|
|
1262
1262
|
});
|
|
1263
1263
|
this.Log("Opening content draft: ".concat(libraryId, " ").concat(objectId));
|
|
1264
1264
|
if (!("type" in options && options.type)) {
|
|
1265
|
-
|
|
1265
|
+
_context15.next = 23;
|
|
1266
1266
|
break;
|
|
1267
1267
|
}
|
|
1268
1268
|
if (!options.type.startsWith("hq__")) {
|
|
1269
|
-
|
|
1269
|
+
_context15.next = 10;
|
|
1270
1270
|
break;
|
|
1271
1271
|
}
|
|
1272
|
-
|
|
1272
|
+
_context15.next = 7;
|
|
1273
1273
|
return this.ContentType({
|
|
1274
1274
|
versionHash: options.type
|
|
1275
1275
|
});
|
|
1276
|
-
case
|
|
1277
|
-
options.type =
|
|
1278
|
-
|
|
1276
|
+
case 7:
|
|
1277
|
+
options.type = _context15.sent.hash;
|
|
1278
|
+
_context15.next = 23;
|
|
1279
1279
|
break;
|
|
1280
|
-
case
|
|
1280
|
+
case 10:
|
|
1281
1281
|
if (!options.type.startsWith("iq__")) {
|
|
1282
|
-
|
|
1282
|
+
_context15.next = 16;
|
|
1283
1283
|
break;
|
|
1284
1284
|
}
|
|
1285
|
-
|
|
1285
|
+
_context15.next = 13;
|
|
1286
1286
|
return this.ContentType({
|
|
1287
1287
|
typeId: options.type
|
|
1288
1288
|
});
|
|
1289
|
-
case
|
|
1290
|
-
options.type =
|
|
1291
|
-
|
|
1289
|
+
case 13:
|
|
1290
|
+
options.type = _context15.sent.hash;
|
|
1291
|
+
_context15.next = 23;
|
|
1292
1292
|
break;
|
|
1293
|
-
case
|
|
1293
|
+
case 16:
|
|
1294
1294
|
if (!options.type) {
|
|
1295
|
-
|
|
1295
|
+
_context15.next = 22;
|
|
1296
1296
|
break;
|
|
1297
1297
|
}
|
|
1298
|
-
|
|
1298
|
+
_context15.next = 19;
|
|
1299
1299
|
return this.ContentType({
|
|
1300
1300
|
name: options.type
|
|
1301
1301
|
});
|
|
1302
|
-
case
|
|
1303
|
-
options.type =
|
|
1304
|
-
|
|
1302
|
+
case 19:
|
|
1303
|
+
options.type = _context15.sent.hash;
|
|
1304
|
+
_context15.next = 23;
|
|
1305
1305
|
break;
|
|
1306
|
-
case
|
|
1306
|
+
case 22:
|
|
1307
1307
|
options.type = "";
|
|
1308
|
-
case
|
|
1308
|
+
case 23:
|
|
1309
1309
|
path = UrlJoin("qid", objectId);
|
|
1310
|
-
|
|
1311
|
-
|
|
1310
|
+
_context15.t0 = this.HttpClient;
|
|
1311
|
+
_context15.next = 27;
|
|
1312
1312
|
return this.authClient.AuthorizationHeader({
|
|
1313
1313
|
libraryId: libraryId,
|
|
1314
1314
|
objectId: objectId,
|
|
1315
1315
|
update: true
|
|
1316
1316
|
});
|
|
1317
|
-
case
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
headers:
|
|
1317
|
+
case 27:
|
|
1318
|
+
_context15.t1 = _context15.sent;
|
|
1319
|
+
_context15.t2 = path;
|
|
1320
|
+
_context15.t3 = options;
|
|
1321
|
+
_context15.t4 = {
|
|
1322
|
+
headers: _context15.t1,
|
|
1323
1323
|
method: "POST",
|
|
1324
|
-
path:
|
|
1325
|
-
body:
|
|
1324
|
+
path: _context15.t2,
|
|
1325
|
+
body: _context15.t3
|
|
1326
1326
|
};
|
|
1327
|
-
|
|
1328
|
-
return
|
|
1329
|
-
case
|
|
1330
|
-
rawEditResponse =
|
|
1327
|
+
_context15.next = 33;
|
|
1328
|
+
return _context15.t0.Request.call(_context15.t0, _context15.t4);
|
|
1329
|
+
case 33:
|
|
1330
|
+
rawEditResponse = _context15.sent;
|
|
1331
1331
|
// extract the url for the node that handled the request
|
|
1332
1332
|
// TODO: remove/simplify after we start using /nodes API call to get node URLs for write tokens
|
|
1333
1333
|
nodeUrl = new URL(rawEditResponse.url).origin;
|
|
1334
|
-
|
|
1334
|
+
_context15.next = 37;
|
|
1335
1335
|
return this.utils.ResponseToJson(rawEditResponse, this.HttpClient.debug, this.HttpClient.Log.bind(this.HttpClient));
|
|
1336
|
-
case
|
|
1337
|
-
editResponse =
|
|
1336
|
+
case 37:
|
|
1337
|
+
editResponse = _context15.sent;
|
|
1338
1338
|
// Record the node used in creating this write token
|
|
1339
1339
|
this.RecordWriteToken({
|
|
1340
1340
|
writeToken: editResponse.write_token,
|
|
@@ -1343,15 +1343,15 @@ exports.EditContentObject = /*#__PURE__*/function () {
|
|
|
1343
1343
|
editResponse.writeToken = editResponse.write_token;
|
|
1344
1344
|
editResponse.objectId = editResponse.id;
|
|
1345
1345
|
editResponse.nodeUrl = nodeUrl;
|
|
1346
|
-
return
|
|
1347
|
-
case
|
|
1346
|
+
return _context15.abrupt("return", editResponse);
|
|
1347
|
+
case 43:
|
|
1348
1348
|
case "end":
|
|
1349
|
-
return
|
|
1349
|
+
return _context15.stop();
|
|
1350
1350
|
}
|
|
1351
|
-
},
|
|
1351
|
+
}, _callee15, this);
|
|
1352
1352
|
}));
|
|
1353
|
-
return function (
|
|
1354
|
-
return
|
|
1353
|
+
return function (_x15) {
|
|
1354
|
+
return _ref28.apply(this, arguments);
|
|
1355
1355
|
};
|
|
1356
1356
|
}();
|
|
1357
1357
|
|
|
@@ -1382,31 +1382,31 @@ exports.EditContentObject = /*#__PURE__*/function () {
|
|
|
1382
1382
|
* @returns {Promise<object>} - Response from FinalizeContentObject
|
|
1383
1383
|
*/
|
|
1384
1384
|
exports.CreateAndFinalizeContentObject = /*#__PURE__*/function () {
|
|
1385
|
-
var
|
|
1386
|
-
var libraryId, callback,
|
|
1387
|
-
return _regeneratorRuntime.wrap(function (
|
|
1388
|
-
while (1) switch (
|
|
1385
|
+
var _ref30 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee16(_ref29) {
|
|
1386
|
+
var libraryId, callback, _ref29$options, options, _ref29$commitMessage, commitMessage, _ref29$publish, publish, _ref29$awaitCommitCon, awaitCommitConfirmation, args, id, writeToken;
|
|
1387
|
+
return _regeneratorRuntime.wrap(function _callee16$(_context16) {
|
|
1388
|
+
while (1) switch (_context16.prev = _context16.next) {
|
|
1389
1389
|
case 0:
|
|
1390
|
-
libraryId =
|
|
1391
|
-
|
|
1390
|
+
libraryId = _ref29.libraryId, callback = _ref29.callback, _ref29$options = _ref29.options, options = _ref29$options === void 0 ? {} : _ref29$options, _ref29$commitMessage = _ref29.commitMessage, commitMessage = _ref29$commitMessage === void 0 ? "" : _ref29$commitMessage, _ref29$publish = _ref29.publish, publish = _ref29$publish === void 0 ? true : _ref29$publish, _ref29$awaitCommitCon = _ref29.awaitCommitConfirmation, awaitCommitConfirmation = _ref29$awaitCommitCon === void 0 ? true : _ref29$awaitCommitCon;
|
|
1391
|
+
_context16.next = 3;
|
|
1392
1392
|
return this.CreateContentObject({
|
|
1393
1393
|
libraryId: libraryId,
|
|
1394
1394
|
options: options
|
|
1395
1395
|
});
|
|
1396
|
-
case
|
|
1397
|
-
args =
|
|
1396
|
+
case 3:
|
|
1397
|
+
args = _context16.sent;
|
|
1398
1398
|
id = args.id, writeToken = args.writeToken;
|
|
1399
1399
|
if (!callback) {
|
|
1400
|
-
|
|
1400
|
+
_context16.next = 8;
|
|
1401
1401
|
break;
|
|
1402
1402
|
}
|
|
1403
|
-
|
|
1403
|
+
_context16.next = 8;
|
|
1404
1404
|
return callback({
|
|
1405
1405
|
objectId: id,
|
|
1406
1406
|
writeToken: writeToken
|
|
1407
1407
|
});
|
|
1408
|
-
case
|
|
1409
|
-
|
|
1408
|
+
case 8:
|
|
1409
|
+
_context16.next = 10;
|
|
1410
1410
|
return this.FinalizeContentObject({
|
|
1411
1411
|
libraryId: libraryId,
|
|
1412
1412
|
objectId: id,
|
|
@@ -1415,16 +1415,16 @@ exports.CreateAndFinalizeContentObject = /*#__PURE__*/function () {
|
|
|
1415
1415
|
publish: publish,
|
|
1416
1416
|
awaitCommitConfirmation: awaitCommitConfirmation
|
|
1417
1417
|
});
|
|
1418
|
-
case
|
|
1419
|
-
return
|
|
1420
|
-
case
|
|
1418
|
+
case 10:
|
|
1419
|
+
return _context16.abrupt("return", _context16.sent);
|
|
1420
|
+
case 11:
|
|
1421
1421
|
case "end":
|
|
1422
|
-
return
|
|
1422
|
+
return _context16.stop();
|
|
1423
1423
|
}
|
|
1424
|
-
},
|
|
1424
|
+
}, _callee16, this);
|
|
1425
1425
|
}));
|
|
1426
|
-
return function (
|
|
1427
|
-
return
|
|
1426
|
+
return function (_x16) {
|
|
1427
|
+
return _ref30.apply(this, arguments);
|
|
1428
1428
|
};
|
|
1429
1429
|
}();
|
|
1430
1430
|
|
|
@@ -1456,31 +1456,31 @@ exports.CreateAndFinalizeContentObject = /*#__PURE__*/function () {
|
|
|
1456
1456
|
* @returns {Promise<object>} - Response from FinalizeContentObject
|
|
1457
1457
|
*/
|
|
1458
1458
|
exports.EditAndFinalizeContentObject = /*#__PURE__*/function () {
|
|
1459
|
-
var
|
|
1460
|
-
var libraryId, objectId, callback,
|
|
1461
|
-
return _regeneratorRuntime.wrap(function (
|
|
1462
|
-
while (1) switch (
|
|
1459
|
+
var _ref32 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee17(_ref31) {
|
|
1460
|
+
var libraryId, objectId, callback, _ref31$options, options, _ref31$commitMessage, commitMessage, _ref31$publish, publish, _ref31$awaitCommitCon, awaitCommitConfirmation, _yield$this$EditConte, writeToken;
|
|
1461
|
+
return _regeneratorRuntime.wrap(function _callee17$(_context17) {
|
|
1462
|
+
while (1) switch (_context17.prev = _context17.next) {
|
|
1463
1463
|
case 0:
|
|
1464
|
-
libraryId =
|
|
1465
|
-
|
|
1464
|
+
libraryId = _ref31.libraryId, objectId = _ref31.objectId, callback = _ref31.callback, _ref31$options = _ref31.options, options = _ref31$options === void 0 ? {} : _ref31$options, _ref31$commitMessage = _ref31.commitMessage, commitMessage = _ref31$commitMessage === void 0 ? "" : _ref31$commitMessage, _ref31$publish = _ref31.publish, publish = _ref31$publish === void 0 ? true : _ref31$publish, _ref31$awaitCommitCon = _ref31.awaitCommitConfirmation, awaitCommitConfirmation = _ref31$awaitCommitCon === void 0 ? true : _ref31$awaitCommitCon;
|
|
1465
|
+
_context17.next = 3;
|
|
1466
1466
|
return this.EditContentObject({
|
|
1467
1467
|
libraryId: libraryId,
|
|
1468
1468
|
objectId: objectId,
|
|
1469
1469
|
options: options
|
|
1470
1470
|
});
|
|
1471
|
-
case
|
|
1472
|
-
_yield$this$EditConte =
|
|
1471
|
+
case 3:
|
|
1472
|
+
_yield$this$EditConte = _context17.sent;
|
|
1473
1473
|
writeToken = _yield$this$EditConte.writeToken;
|
|
1474
1474
|
if (!callback) {
|
|
1475
|
-
|
|
1475
|
+
_context17.next = 8;
|
|
1476
1476
|
break;
|
|
1477
1477
|
}
|
|
1478
|
-
|
|
1478
|
+
_context17.next = 8;
|
|
1479
1479
|
return callback({
|
|
1480
1480
|
writeToken: writeToken
|
|
1481
1481
|
});
|
|
1482
|
-
case
|
|
1483
|
-
|
|
1482
|
+
case 8:
|
|
1483
|
+
_context17.next = 10;
|
|
1484
1484
|
return this.FinalizeContentObject({
|
|
1485
1485
|
libraryId: libraryId,
|
|
1486
1486
|
objectId: objectId,
|
|
@@ -1489,114 +1489,114 @@ exports.EditAndFinalizeContentObject = /*#__PURE__*/function () {
|
|
|
1489
1489
|
publish: publish,
|
|
1490
1490
|
awaitCommitConfirmation: awaitCommitConfirmation
|
|
1491
1491
|
});
|
|
1492
|
-
case
|
|
1493
|
-
return
|
|
1494
|
-
case
|
|
1492
|
+
case 10:
|
|
1493
|
+
return _context17.abrupt("return", _context17.sent);
|
|
1494
|
+
case 11:
|
|
1495
1495
|
case "end":
|
|
1496
|
-
return
|
|
1496
|
+
return _context17.stop();
|
|
1497
1497
|
}
|
|
1498
|
-
},
|
|
1498
|
+
}, _callee17, this);
|
|
1499
1499
|
}));
|
|
1500
|
-
return function (
|
|
1501
|
-
return
|
|
1500
|
+
return function (_x17) {
|
|
1501
|
+
return _ref32.apply(this, arguments);
|
|
1502
1502
|
};
|
|
1503
1503
|
}();
|
|
1504
1504
|
exports.AwaitPending = /*#__PURE__*/function () {
|
|
1505
|
-
var
|
|
1505
|
+
var _ref33 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee19(objectId) {
|
|
1506
1506
|
var _this3 = this;
|
|
1507
|
-
var PendingHash, pending, isWallet, timeout, i
|
|
1508
|
-
return _regeneratorRuntime.wrap(function (
|
|
1509
|
-
while (1) switch (
|
|
1507
|
+
var PendingHash, pending, isWallet, timeout, i;
|
|
1508
|
+
return _regeneratorRuntime.wrap(function _callee19$(_context19) {
|
|
1509
|
+
while (1) switch (_context19.prev = _context19.next) {
|
|
1510
1510
|
case 0:
|
|
1511
1511
|
PendingHash = /*#__PURE__*/function () {
|
|
1512
|
-
var
|
|
1513
|
-
return _regeneratorRuntime.wrap(function (
|
|
1514
|
-
while (1) switch (
|
|
1512
|
+
var _ref34 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee18() {
|
|
1513
|
+
return _regeneratorRuntime.wrap(function _callee18$(_context18) {
|
|
1514
|
+
while (1) switch (_context18.prev = _context18.next) {
|
|
1515
1515
|
case 0:
|
|
1516
|
-
|
|
1516
|
+
_context18.next = 2;
|
|
1517
1517
|
return _this3.CallContractMethod({
|
|
1518
1518
|
contractAddress: _this3.utils.HashToAddress(objectId),
|
|
1519
1519
|
methodName: "pendingHash"
|
|
1520
1520
|
});
|
|
1521
|
-
case 1:
|
|
1522
|
-
return _context16.abrupt("return", _context16.sent);
|
|
1523
1521
|
case 2:
|
|
1522
|
+
return _context18.abrupt("return", _context18.sent);
|
|
1523
|
+
case 3:
|
|
1524
1524
|
case "end":
|
|
1525
|
-
return
|
|
1525
|
+
return _context18.stop();
|
|
1526
1526
|
}
|
|
1527
|
-
},
|
|
1527
|
+
}, _callee18);
|
|
1528
1528
|
}));
|
|
1529
1529
|
return function PendingHash() {
|
|
1530
|
-
return
|
|
1530
|
+
return _ref34.apply(this, arguments);
|
|
1531
1531
|
};
|
|
1532
1532
|
}();
|
|
1533
1533
|
this.Log("Checking for pending commit");
|
|
1534
|
-
|
|
1534
|
+
_context19.next = 4;
|
|
1535
1535
|
return PendingHash();
|
|
1536
|
-
case
|
|
1537
|
-
pending =
|
|
1536
|
+
case 4:
|
|
1537
|
+
pending = _context19.sent;
|
|
1538
1538
|
if (pending) {
|
|
1539
|
-
|
|
1539
|
+
_context19.next = 7;
|
|
1540
1540
|
break;
|
|
1541
1541
|
}
|
|
1542
|
-
return
|
|
1543
|
-
case
|
|
1544
|
-
|
|
1542
|
+
return _context19.abrupt("return");
|
|
1543
|
+
case 7:
|
|
1544
|
+
_context19.next = 9;
|
|
1545
1545
|
return this.authClient.AccessType(objectId);
|
|
1546
|
-
case
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
isWallet =
|
|
1546
|
+
case 9:
|
|
1547
|
+
_context19.t0 = _context19.sent;
|
|
1548
|
+
_context19.t1 = this.authClient.ACCESS_TYPES.WALLET;
|
|
1549
|
+
isWallet = _context19.t0 === _context19.t1;
|
|
1550
1550
|
timeout = isWallet ? 3 : 10;
|
|
1551
1551
|
this.Log("Waiting for pending commit to clear for ".concat(objectId));
|
|
1552
1552
|
i = 0;
|
|
1553
|
-
case
|
|
1553
|
+
case 15:
|
|
1554
1554
|
if (!(i < timeout)) {
|
|
1555
|
-
|
|
1555
|
+
_context19.next = 25;
|
|
1556
1556
|
break;
|
|
1557
1557
|
}
|
|
1558
|
-
|
|
1558
|
+
_context19.next = 18;
|
|
1559
1559
|
return new Promise(function (resolve) {
|
|
1560
1560
|
return setTimeout(resolve, 1000);
|
|
1561
1561
|
});
|
|
1562
|
-
case
|
|
1563
|
-
|
|
1562
|
+
case 18:
|
|
1563
|
+
_context19.next = 20;
|
|
1564
1564
|
return PendingHash();
|
|
1565
|
-
case
|
|
1566
|
-
if (
|
|
1567
|
-
|
|
1565
|
+
case 20:
|
|
1566
|
+
if (_context19.sent) {
|
|
1567
|
+
_context19.next = 22;
|
|
1568
1568
|
break;
|
|
1569
1569
|
}
|
|
1570
|
-
return
|
|
1571
|
-
case
|
|
1570
|
+
return _context19.abrupt("return");
|
|
1571
|
+
case 22:
|
|
1572
1572
|
i++;
|
|
1573
|
-
|
|
1573
|
+
_context19.next = 15;
|
|
1574
1574
|
break;
|
|
1575
|
-
case
|
|
1575
|
+
case 25:
|
|
1576
1576
|
if (!isWallet) {
|
|
1577
|
-
|
|
1577
|
+
_context19.next = 31;
|
|
1578
1578
|
break;
|
|
1579
1579
|
}
|
|
1580
1580
|
this.Log("Clearing stuck wallet commit", true);
|
|
1581
1581
|
// Clear pending commit, it's probably stuck
|
|
1582
|
-
|
|
1582
|
+
_context19.next = 29;
|
|
1583
1583
|
return this.CallContractMethodAndWait({
|
|
1584
1584
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
1585
1585
|
methodName: "clearPending"
|
|
1586
1586
|
});
|
|
1587
|
-
case
|
|
1588
|
-
|
|
1587
|
+
case 29:
|
|
1588
|
+
_context19.next = 32;
|
|
1589
1589
|
break;
|
|
1590
|
-
case
|
|
1590
|
+
case 31:
|
|
1591
1591
|
throw Error("Unable to finalize ".concat(objectId, " - Another commit is pending"));
|
|
1592
|
-
case
|
|
1592
|
+
case 32:
|
|
1593
1593
|
case "end":
|
|
1594
|
-
return
|
|
1594
|
+
return _context19.stop();
|
|
1595
1595
|
}
|
|
1596
|
-
},
|
|
1596
|
+
}, _callee19, this);
|
|
1597
1597
|
}));
|
|
1598
|
-
return function (
|
|
1599
|
-
return
|
|
1598
|
+
return function (_x18) {
|
|
1599
|
+
return _ref33.apply(this, arguments);
|
|
1600
1600
|
};
|
|
1601
1601
|
}();
|
|
1602
1602
|
|
|
@@ -1614,101 +1614,101 @@ exports.AwaitPending = /*#__PURE__*/function () {
|
|
|
1614
1614
|
* Irrelevant if not publishing.
|
|
1615
1615
|
*/
|
|
1616
1616
|
exports.FinalizeContentObject = /*#__PURE__*/function () {
|
|
1617
|
-
var
|
|
1618
|
-
var libraryId, objectId, writeToken,
|
|
1619
|
-
return _regeneratorRuntime.wrap(function (
|
|
1620
|
-
while (1) switch (
|
|
1617
|
+
var _ref36 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee20(_ref35) {
|
|
1618
|
+
var libraryId, objectId, writeToken, _ref35$commitMessage, commitMessage, _ref35$publish, publish, _ref35$awaitCommitCon, awaitCommitConfirmation, path, finalizeResponse;
|
|
1619
|
+
return _regeneratorRuntime.wrap(function _callee20$(_context20) {
|
|
1620
|
+
while (1) switch (_context20.prev = _context20.next) {
|
|
1621
1621
|
case 0:
|
|
1622
|
-
libraryId =
|
|
1622
|
+
libraryId = _ref35.libraryId, objectId = _ref35.objectId, writeToken = _ref35.writeToken, _ref35$commitMessage = _ref35.commitMessage, commitMessage = _ref35$commitMessage === void 0 ? "" : _ref35$commitMessage, _ref35$publish = _ref35.publish, publish = _ref35$publish === void 0 ? true : _ref35$publish, _ref35$awaitCommitCon = _ref35.awaitCommitConfirmation, awaitCommitConfirmation = _ref35$awaitCommitCon === void 0 ? true : _ref35$awaitCommitCon;
|
|
1623
1623
|
ValidateParameters({
|
|
1624
1624
|
libraryId: libraryId,
|
|
1625
1625
|
objectId: objectId
|
|
1626
1626
|
});
|
|
1627
1627
|
ValidateWriteToken(writeToken);
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1628
|
+
_context20.t0 = this;
|
|
1629
|
+
_context20.t1 = libraryId;
|
|
1630
|
+
_context20.t2 = objectId;
|
|
1631
|
+
_context20.t3 = writeToken;
|
|
1632
|
+
_context20.t4 = commitMessage;
|
|
1633
|
+
_context20.next = 10;
|
|
1634
1634
|
return this.userProfileClient.UserMetadata({
|
|
1635
1635
|
metadataSubtree: "public/name"
|
|
1636
1636
|
});
|
|
1637
|
-
case
|
|
1638
|
-
|
|
1639
|
-
if (
|
|
1640
|
-
|
|
1637
|
+
case 10:
|
|
1638
|
+
_context20.t5 = _context20.sent;
|
|
1639
|
+
if (_context20.t5) {
|
|
1640
|
+
_context20.next = 13;
|
|
1641
1641
|
break;
|
|
1642
1642
|
}
|
|
1643
|
-
|
|
1644
|
-
case
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
message:
|
|
1650
|
-
author:
|
|
1651
|
-
author_address:
|
|
1652
|
-
timestamp:
|
|
1643
|
+
_context20.t5 = this.CurrentAccountAddress();
|
|
1644
|
+
case 13:
|
|
1645
|
+
_context20.t6 = _context20.t5;
|
|
1646
|
+
_context20.t7 = this.CurrentAccountAddress();
|
|
1647
|
+
_context20.t8 = new Date().toISOString();
|
|
1648
|
+
_context20.t9 = {
|
|
1649
|
+
message: _context20.t4,
|
|
1650
|
+
author: _context20.t6,
|
|
1651
|
+
author_address: _context20.t7,
|
|
1652
|
+
timestamp: _context20.t8
|
|
1653
1653
|
};
|
|
1654
|
-
|
|
1655
|
-
libraryId:
|
|
1656
|
-
objectId:
|
|
1657
|
-
writeToken:
|
|
1654
|
+
_context20.t10 = {
|
|
1655
|
+
libraryId: _context20.t1,
|
|
1656
|
+
objectId: _context20.t2,
|
|
1657
|
+
writeToken: _context20.t3,
|
|
1658
1658
|
metadataSubtree: "commit",
|
|
1659
|
-
metadata:
|
|
1659
|
+
metadata: _context20.t9
|
|
1660
1660
|
};
|
|
1661
|
-
|
|
1662
|
-
return
|
|
1663
|
-
case
|
|
1661
|
+
_context20.next = 20;
|
|
1662
|
+
return _context20.t0.ReplaceMetadata.call(_context20.t0, _context20.t10);
|
|
1663
|
+
case 20:
|
|
1664
1664
|
this.Log("Finalizing content draft: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken));
|
|
1665
|
-
|
|
1665
|
+
_context20.next = 23;
|
|
1666
1666
|
return this.AwaitPending(objectId);
|
|
1667
|
-
case
|
|
1667
|
+
case 23:
|
|
1668
1668
|
path = UrlJoin("q", writeToken);
|
|
1669
|
-
|
|
1670
|
-
|
|
1669
|
+
_context20.t11 = this.HttpClient;
|
|
1670
|
+
_context20.next = 27;
|
|
1671
1671
|
return this.authClient.AuthorizationHeader({
|
|
1672
1672
|
libraryId: libraryId,
|
|
1673
1673
|
objectId: objectId,
|
|
1674
1674
|
update: true
|
|
1675
1675
|
});
|
|
1676
|
-
case
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
headers:
|
|
1676
|
+
case 27:
|
|
1677
|
+
_context20.t12 = _context20.sent;
|
|
1678
|
+
_context20.t13 = path;
|
|
1679
|
+
_context20.t14 = {
|
|
1680
|
+
headers: _context20.t12,
|
|
1681
1681
|
method: "POST",
|
|
1682
|
-
path:
|
|
1682
|
+
path: _context20.t13,
|
|
1683
1683
|
allowFailover: false
|
|
1684
1684
|
};
|
|
1685
|
-
|
|
1686
|
-
return
|
|
1687
|
-
case
|
|
1688
|
-
finalizeResponse =
|
|
1685
|
+
_context20.next = 32;
|
|
1686
|
+
return _context20.t11.RequestJsonBody.call(_context20.t11, _context20.t14);
|
|
1687
|
+
case 32:
|
|
1688
|
+
finalizeResponse = _context20.sent;
|
|
1689
1689
|
this.Log("Finalized: ".concat(finalizeResponse.hash));
|
|
1690
1690
|
if (!publish) {
|
|
1691
|
-
|
|
1691
|
+
_context20.next = 37;
|
|
1692
1692
|
break;
|
|
1693
1693
|
}
|
|
1694
|
-
|
|
1694
|
+
_context20.next = 37;
|
|
1695
1695
|
return this.PublishContentVersion({
|
|
1696
1696
|
objectId: objectId,
|
|
1697
1697
|
versionHash: finalizeResponse.hash,
|
|
1698
1698
|
awaitCommitConfirmation: awaitCommitConfirmation
|
|
1699
1699
|
});
|
|
1700
|
-
case
|
|
1700
|
+
case 37:
|
|
1701
1701
|
// Invalidate cached content type, if this is one.
|
|
1702
1702
|
delete this.contentTypes[objectId];
|
|
1703
|
-
return
|
|
1704
|
-
case
|
|
1703
|
+
return _context20.abrupt("return", finalizeResponse);
|
|
1704
|
+
case 39:
|
|
1705
1705
|
case "end":
|
|
1706
|
-
return
|
|
1706
|
+
return _context20.stop();
|
|
1707
1707
|
}
|
|
1708
|
-
},
|
|
1708
|
+
}, _callee20, this);
|
|
1709
1709
|
}));
|
|
1710
|
-
return function (
|
|
1711
|
-
return
|
|
1710
|
+
return function (_x19) {
|
|
1711
|
+
return _ref36.apply(this, arguments);
|
|
1712
1712
|
};
|
|
1713
1713
|
}();
|
|
1714
1714
|
|
|
@@ -1723,177 +1723,177 @@ exports.FinalizeContentObject = /*#__PURE__*/function () {
|
|
|
1723
1723
|
* @param {boolean=} awaitCommitConfirmation=true - If specified, will wait for the publish commit to be confirmed.
|
|
1724
1724
|
*/
|
|
1725
1725
|
exports.PublishContentVersion = /*#__PURE__*/function () {
|
|
1726
|
-
var
|
|
1727
|
-
var objectId, versionHash,
|
|
1728
|
-
return _regeneratorRuntime.wrap(function (
|
|
1729
|
-
while (1) switch (
|
|
1726
|
+
var _ref38 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee21(_ref37) {
|
|
1727
|
+
var objectId, versionHash, _ref37$awaitCommitCon, awaitCommitConfirmation, commit, abi, fromBlock, objectHash, pendingHash, pollingInterval, events, confirmEvent, _pollingInterval, tries, h;
|
|
1728
|
+
return _regeneratorRuntime.wrap(function _callee21$(_context21) {
|
|
1729
|
+
while (1) switch (_context21.prev = _context21.next) {
|
|
1730
1730
|
case 0:
|
|
1731
|
-
objectId =
|
|
1731
|
+
objectId = _ref37.objectId, versionHash = _ref37.versionHash, _ref37$awaitCommitCon = _ref37.awaitCommitConfirmation, awaitCommitConfirmation = _ref37$awaitCommitCon === void 0 ? true : _ref37$awaitCommitCon;
|
|
1732
1732
|
versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
|
|
1733
1733
|
this.Log("Publishing: ".concat(objectId || versionHash));
|
|
1734
1734
|
if (versionHash) {
|
|
1735
1735
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1736
1736
|
}
|
|
1737
|
-
|
|
1737
|
+
_context21.next = 6;
|
|
1738
1738
|
return this.ethClient.CommitContent({
|
|
1739
1739
|
contentObjectAddress: this.utils.HashToAddress(objectId),
|
|
1740
1740
|
versionHash: versionHash,
|
|
1741
1741
|
signer: this.signer
|
|
1742
1742
|
});
|
|
1743
|
-
case
|
|
1744
|
-
commit =
|
|
1745
|
-
|
|
1743
|
+
case 6:
|
|
1744
|
+
commit = _context21.sent;
|
|
1745
|
+
_context21.next = 9;
|
|
1746
1746
|
return this.ContractAbi({
|
|
1747
1747
|
id: objectId
|
|
1748
1748
|
});
|
|
1749
|
-
case
|
|
1750
|
-
abi =
|
|
1749
|
+
case 9:
|
|
1750
|
+
abi = _context21.sent;
|
|
1751
1751
|
fromBlock = commit.blockNumber - 30; // due to block re-org
|
|
1752
|
-
|
|
1752
|
+
_context21.next = 13;
|
|
1753
1753
|
return this.ExtractValueFromEvent({
|
|
1754
1754
|
abi: abi,
|
|
1755
1755
|
event: commit,
|
|
1756
1756
|
eventName: "CommitPending",
|
|
1757
1757
|
eventValue: "objectHash"
|
|
1758
1758
|
});
|
|
1759
|
-
case
|
|
1760
|
-
objectHash =
|
|
1761
|
-
|
|
1759
|
+
case 13:
|
|
1760
|
+
objectHash = _context21.sent;
|
|
1761
|
+
_context21.next = 16;
|
|
1762
1762
|
return this.CallContractMethod({
|
|
1763
1763
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
1764
1764
|
methodName: "pendingHash"
|
|
1765
1765
|
});
|
|
1766
|
-
case
|
|
1767
|
-
pendingHash =
|
|
1766
|
+
case 16:
|
|
1767
|
+
pendingHash = _context21.sent;
|
|
1768
1768
|
if (!(pendingHash && pendingHash !== objectHash)) {
|
|
1769
|
-
|
|
1769
|
+
_context21.next = 19;
|
|
1770
1770
|
break;
|
|
1771
1771
|
}
|
|
1772
1772
|
throw Error("Pending version hash mismatch on ".concat(objectId, ": expected ").concat(objectHash, ", currently ").concat(pendingHash));
|
|
1773
|
-
case
|
|
1773
|
+
case 19:
|
|
1774
1774
|
if (!awaitCommitConfirmation) {
|
|
1775
|
-
|
|
1775
|
+
_context21.next = 48;
|
|
1776
1776
|
break;
|
|
1777
1777
|
}
|
|
1778
1778
|
this.Log("Awaiting commit confirmation for ".concat(objectHash));
|
|
1779
1779
|
pollingInterval = this.ethClient.Provider().pollingInterval || 500; // eslint-disable-next-line no-constant-condition
|
|
1780
|
-
case
|
|
1780
|
+
case 22:
|
|
1781
1781
|
if (!true) {
|
|
1782
|
-
|
|
1782
|
+
_context21.next = 48;
|
|
1783
1783
|
break;
|
|
1784
1784
|
}
|
|
1785
|
-
|
|
1785
|
+
_context21.next = 25;
|
|
1786
1786
|
return new Promise(function (resolve) {
|
|
1787
1787
|
return setTimeout(resolve, pollingInterval);
|
|
1788
1788
|
});
|
|
1789
|
-
case
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1789
|
+
case 25:
|
|
1790
|
+
_context21.t0 = this;
|
|
1791
|
+
_context21.t1 = this.utils.HashToAddress(objectId);
|
|
1792
|
+
_context21.t2 = abi;
|
|
1793
|
+
_context21.t3 = fromBlock;
|
|
1794
|
+
_context21.next = 31;
|
|
1795
1795
|
return this.authClient.IsV3({
|
|
1796
1796
|
id: objectId
|
|
1797
1797
|
});
|
|
1798
|
-
case
|
|
1799
|
-
if (!
|
|
1800
|
-
|
|
1798
|
+
case 31:
|
|
1799
|
+
if (!_context21.sent) {
|
|
1800
|
+
_context21.next = 35;
|
|
1801
1801
|
break;
|
|
1802
1802
|
}
|
|
1803
|
-
|
|
1804
|
-
|
|
1803
|
+
_context21.t4 = Ethers.utils.id("VersionConfirm(address,address,string)");
|
|
1804
|
+
_context21.next = 36;
|
|
1805
1805
|
break;
|
|
1806
|
-
case
|
|
1807
|
-
|
|
1808
|
-
case
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
contractAddress:
|
|
1813
|
-
abi:
|
|
1814
|
-
fromBlock:
|
|
1815
|
-
topics:
|
|
1806
|
+
case 35:
|
|
1807
|
+
_context21.t4 = Ethers.utils.id("VersionConfirm(address,string)");
|
|
1808
|
+
case 36:
|
|
1809
|
+
_context21.t5 = _context21.t4;
|
|
1810
|
+
_context21.t6 = [_context21.t5];
|
|
1811
|
+
_context21.t7 = {
|
|
1812
|
+
contractAddress: _context21.t1,
|
|
1813
|
+
abi: _context21.t2,
|
|
1814
|
+
fromBlock: _context21.t3,
|
|
1815
|
+
topics: _context21.t6,
|
|
1816
1816
|
count: 1000
|
|
1817
1817
|
};
|
|
1818
|
-
|
|
1819
|
-
return
|
|
1820
|
-
case
|
|
1821
|
-
events =
|
|
1818
|
+
_context21.next = 41;
|
|
1819
|
+
return _context21.t0.ContractEvents.call(_context21.t0, _context21.t7);
|
|
1820
|
+
case 41:
|
|
1821
|
+
events = _context21.sent;
|
|
1822
1822
|
confirmEvent = events.find(function (blockEvents) {
|
|
1823
1823
|
return blockEvents.find(function (event) {
|
|
1824
1824
|
return objectHash === (event && event.args && event.args.objectHash);
|
|
1825
1825
|
});
|
|
1826
1826
|
});
|
|
1827
1827
|
if (!confirmEvent) {
|
|
1828
|
-
|
|
1828
|
+
_context21.next = 46;
|
|
1829
1829
|
break;
|
|
1830
1830
|
}
|
|
1831
1831
|
// Found confirmation
|
|
1832
1832
|
this.Log("Commit confirmed on chain: ".concat(objectHash));
|
|
1833
|
-
return
|
|
1834
|
-
case
|
|
1835
|
-
|
|
1833
|
+
return _context21.abrupt("break", 48);
|
|
1834
|
+
case 46:
|
|
1835
|
+
_context21.next = 22;
|
|
1836
1836
|
break;
|
|
1837
|
-
case
|
|
1837
|
+
case 48:
|
|
1838
1838
|
if (!awaitCommitConfirmation) {
|
|
1839
|
-
|
|
1839
|
+
_context21.next = 76;
|
|
1840
1840
|
break;
|
|
1841
1841
|
}
|
|
1842
1842
|
_pollingInterval = 500; // ms
|
|
1843
1843
|
tries = 20;
|
|
1844
|
-
case
|
|
1844
|
+
case 51:
|
|
1845
1845
|
if (!(tries > 0)) {
|
|
1846
|
-
|
|
1846
|
+
_context21.next = 76;
|
|
1847
1847
|
break;
|
|
1848
1848
|
}
|
|
1849
1849
|
h = void 0;
|
|
1850
|
-
|
|
1851
|
-
|
|
1850
|
+
_context21.prev = 53;
|
|
1851
|
+
_context21.next = 56;
|
|
1852
1852
|
return this.LatestVersionHash({
|
|
1853
1853
|
objectId: objectId
|
|
1854
1854
|
});
|
|
1855
|
-
case
|
|
1856
|
-
h =
|
|
1855
|
+
case 56:
|
|
1856
|
+
h = _context21.sent;
|
|
1857
1857
|
if (!(h === versionHash)) {
|
|
1858
|
-
|
|
1858
|
+
_context21.next = 62;
|
|
1859
1859
|
break;
|
|
1860
1860
|
}
|
|
1861
1861
|
this.Log("Commit confirmed on fabric node: ".concat(versionHash));
|
|
1862
|
-
return
|
|
1863
|
-
case
|
|
1862
|
+
return _context21.abrupt("break", 76);
|
|
1863
|
+
case 62:
|
|
1864
1864
|
tries--;
|
|
1865
|
-
|
|
1865
|
+
_context21.next = 65;
|
|
1866
1866
|
return new Promise(function (resolve) {
|
|
1867
1867
|
return setTimeout(resolve, _pollingInterval);
|
|
1868
1868
|
});
|
|
1869
|
-
case
|
|
1870
|
-
|
|
1869
|
+
case 65:
|
|
1870
|
+
_context21.next = 74;
|
|
1871
1871
|
break;
|
|
1872
|
-
case
|
|
1873
|
-
|
|
1874
|
-
|
|
1875
|
-
if (!(
|
|
1876
|
-
|
|
1872
|
+
case 67:
|
|
1873
|
+
_context21.prev = 67;
|
|
1874
|
+
_context21.t8 = _context21["catch"](53);
|
|
1875
|
+
if (!(_context21.t8.status !== 404)) {
|
|
1876
|
+
_context21.next = 71;
|
|
1877
1877
|
break;
|
|
1878
1878
|
}
|
|
1879
|
-
throw
|
|
1880
|
-
case
|
|
1879
|
+
throw _context21.t8;
|
|
1880
|
+
case 71:
|
|
1881
1881
|
tries--;
|
|
1882
|
-
|
|
1882
|
+
_context21.next = 74;
|
|
1883
1883
|
return new Promise(function (resolve) {
|
|
1884
1884
|
return setTimeout(resolve, _pollingInterval);
|
|
1885
1885
|
});
|
|
1886
|
-
case
|
|
1887
|
-
|
|
1886
|
+
case 74:
|
|
1887
|
+
_context21.next = 51;
|
|
1888
1888
|
break;
|
|
1889
|
-
case
|
|
1889
|
+
case 76:
|
|
1890
1890
|
case "end":
|
|
1891
|
-
return
|
|
1891
|
+
return _context21.stop();
|
|
1892
1892
|
}
|
|
1893
|
-
},
|
|
1893
|
+
}, _callee21, this, [[53, 67]]);
|
|
1894
1894
|
}));
|
|
1895
|
-
return function (
|
|
1896
|
-
return
|
|
1895
|
+
return function (_x20) {
|
|
1896
|
+
return _ref38.apply(this, arguments);
|
|
1897
1897
|
};
|
|
1898
1898
|
}();
|
|
1899
1899
|
|
|
@@ -1905,29 +1905,29 @@ exports.PublishContentVersion = /*#__PURE__*/function () {
|
|
|
1905
1905
|
* @param {string=} versionHash - Hash of the object version - if not specified, most recent version will be deleted
|
|
1906
1906
|
*/
|
|
1907
1907
|
exports.DeleteContentVersion = /*#__PURE__*/function () {
|
|
1908
|
-
var
|
|
1908
|
+
var _ref40 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee22(_ref39) {
|
|
1909
1909
|
var versionHash, _this$utils$DecodeVer, objectId;
|
|
1910
|
-
return _regeneratorRuntime.wrap(function (
|
|
1911
|
-
while (1) switch (
|
|
1910
|
+
return _regeneratorRuntime.wrap(function _callee22$(_context22) {
|
|
1911
|
+
while (1) switch (_context22.prev = _context22.next) {
|
|
1912
1912
|
case 0:
|
|
1913
|
-
versionHash =
|
|
1913
|
+
versionHash = _ref39.versionHash;
|
|
1914
1914
|
ValidateVersion(versionHash);
|
|
1915
1915
|
this.Log("Deleting content version: ".concat(versionHash));
|
|
1916
1916
|
_this$utils$DecodeVer = this.utils.DecodeVersionHash(versionHash), objectId = _this$utils$DecodeVer.objectId;
|
|
1917
|
-
|
|
1917
|
+
_context22.next = 6;
|
|
1918
1918
|
return this.CallContractMethodAndWait({
|
|
1919
1919
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
1920
1920
|
methodName: "deleteVersion",
|
|
1921
1921
|
methodArgs: [versionHash]
|
|
1922
1922
|
});
|
|
1923
|
-
case
|
|
1923
|
+
case 6:
|
|
1924
1924
|
case "end":
|
|
1925
|
-
return
|
|
1925
|
+
return _context22.stop();
|
|
1926
1926
|
}
|
|
1927
|
-
},
|
|
1927
|
+
}, _callee22, this);
|
|
1928
1928
|
}));
|
|
1929
|
-
return function (
|
|
1930
|
-
return
|
|
1929
|
+
return function (_x21) {
|
|
1930
|
+
return _ref40.apply(this, arguments);
|
|
1931
1931
|
};
|
|
1932
1932
|
}();
|
|
1933
1933
|
|
|
@@ -1940,31 +1940,31 @@ exports.DeleteContentVersion = /*#__PURE__*/function () {
|
|
|
1940
1940
|
* @param {string} objectId - ID of the object
|
|
1941
1941
|
*/
|
|
1942
1942
|
exports.DeleteContentObject = /*#__PURE__*/function () {
|
|
1943
|
-
var
|
|
1943
|
+
var _ref42 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee23(_ref41) {
|
|
1944
1944
|
var libraryId, objectId;
|
|
1945
|
-
return _regeneratorRuntime.wrap(function (
|
|
1946
|
-
while (1) switch (
|
|
1945
|
+
return _regeneratorRuntime.wrap(function _callee23$(_context23) {
|
|
1946
|
+
while (1) switch (_context23.prev = _context23.next) {
|
|
1947
1947
|
case 0:
|
|
1948
|
-
libraryId =
|
|
1948
|
+
libraryId = _ref41.libraryId, objectId = _ref41.objectId;
|
|
1949
1949
|
ValidateParameters({
|
|
1950
1950
|
libraryId: libraryId,
|
|
1951
1951
|
objectId: objectId
|
|
1952
1952
|
});
|
|
1953
1953
|
this.Log("Deleting content version: ".concat(libraryId, " ").concat(objectId));
|
|
1954
|
-
|
|
1954
|
+
_context23.next = 5;
|
|
1955
1955
|
return this.CallContractMethodAndWait({
|
|
1956
1956
|
contractAddress: this.utils.HashToAddress(libraryId),
|
|
1957
1957
|
methodName: "deleteContent",
|
|
1958
1958
|
methodArgs: [this.utils.HashToAddress(objectId)]
|
|
1959
1959
|
});
|
|
1960
|
-
case
|
|
1960
|
+
case 5:
|
|
1961
1961
|
case "end":
|
|
1962
|
-
return
|
|
1962
|
+
return _context23.stop();
|
|
1963
1963
|
}
|
|
1964
|
-
},
|
|
1964
|
+
}, _callee23, this);
|
|
1965
1965
|
}));
|
|
1966
|
-
return function (
|
|
1967
|
-
return
|
|
1966
|
+
return function (_x22) {
|
|
1967
|
+
return _ref42.apply(this, arguments);
|
|
1968
1968
|
};
|
|
1969
1969
|
}();
|
|
1970
1970
|
|
|
@@ -1982,12 +1982,12 @@ exports.DeleteContentObject = /*#__PURE__*/function () {
|
|
|
1982
1982
|
* @param {string=} metadataSubtree - Subtree of the object metadata to modify
|
|
1983
1983
|
*/
|
|
1984
1984
|
exports.MergeMetadata = /*#__PURE__*/function () {
|
|
1985
|
-
var
|
|
1986
|
-
var libraryId, objectId, writeToken,
|
|
1987
|
-
return _regeneratorRuntime.wrap(function (
|
|
1988
|
-
while (1) switch (
|
|
1985
|
+
var _ref44 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref43) {
|
|
1986
|
+
var libraryId, objectId, writeToken, _ref43$metadataSubtre, metadataSubtree, _ref43$metadata, metadata, path;
|
|
1987
|
+
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
1988
|
+
while (1) switch (_context24.prev = _context24.next) {
|
|
1989
1989
|
case 0:
|
|
1990
|
-
libraryId =
|
|
1990
|
+
libraryId = _ref43.libraryId, objectId = _ref43.objectId, writeToken = _ref43.writeToken, _ref43$metadataSubtre = _ref43.metadataSubtree, metadataSubtree = _ref43$metadataSubtre === void 0 ? "/" : _ref43$metadataSubtre, _ref43$metadata = _ref43.metadata, metadata = _ref43$metadata === void 0 ? {} : _ref43$metadata;
|
|
1991
1991
|
ValidateParameters({
|
|
1992
1992
|
libraryId: libraryId,
|
|
1993
1993
|
objectId: objectId
|
|
@@ -1996,34 +1996,34 @@ exports.MergeMetadata = /*#__PURE__*/function () {
|
|
|
1996
1996
|
this.Log("Merging metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
|
|
1997
1997
|
this.Log(metadata);
|
|
1998
1998
|
path = UrlJoin("q", writeToken, "meta", metadataSubtree);
|
|
1999
|
-
|
|
2000
|
-
|
|
1999
|
+
_context24.t0 = this.HttpClient;
|
|
2000
|
+
_context24.next = 9;
|
|
2001
2001
|
return this.authClient.AuthorizationHeader({
|
|
2002
2002
|
libraryId: libraryId,
|
|
2003
2003
|
objectId: objectId,
|
|
2004
2004
|
update: true
|
|
2005
2005
|
});
|
|
2006
|
-
case
|
|
2007
|
-
|
|
2008
|
-
|
|
2009
|
-
|
|
2010
|
-
|
|
2011
|
-
headers:
|
|
2006
|
+
case 9:
|
|
2007
|
+
_context24.t1 = _context24.sent;
|
|
2008
|
+
_context24.t2 = path;
|
|
2009
|
+
_context24.t3 = metadata;
|
|
2010
|
+
_context24.t4 = {
|
|
2011
|
+
headers: _context24.t1,
|
|
2012
2012
|
method: "POST",
|
|
2013
|
-
path:
|
|
2014
|
-
body:
|
|
2013
|
+
path: _context24.t2,
|
|
2014
|
+
body: _context24.t3,
|
|
2015
2015
|
allowFailover: false
|
|
2016
2016
|
};
|
|
2017
|
-
|
|
2018
|
-
return
|
|
2019
|
-
case
|
|
2017
|
+
_context24.next = 15;
|
|
2018
|
+
return _context24.t0.Request.call(_context24.t0, _context24.t4);
|
|
2019
|
+
case 15:
|
|
2020
2020
|
case "end":
|
|
2021
|
-
return
|
|
2021
|
+
return _context24.stop();
|
|
2022
2022
|
}
|
|
2023
|
-
},
|
|
2023
|
+
}, _callee24, this);
|
|
2024
2024
|
}));
|
|
2025
|
-
return function (
|
|
2026
|
-
return
|
|
2025
|
+
return function (_x23) {
|
|
2026
|
+
return _ref44.apply(this, arguments);
|
|
2027
2027
|
};
|
|
2028
2028
|
}();
|
|
2029
2029
|
|
|
@@ -2039,12 +2039,12 @@ exports.MergeMetadata = /*#__PURE__*/function () {
|
|
|
2039
2039
|
* @param {string=} metadataSubtree - Subtree of the object metadata to modify
|
|
2040
2040
|
*/
|
|
2041
2041
|
exports.ReplaceMetadata = /*#__PURE__*/function () {
|
|
2042
|
-
var
|
|
2043
|
-
var libraryId, objectId, writeToken,
|
|
2044
|
-
return _regeneratorRuntime.wrap(function (
|
|
2045
|
-
while (1) switch (
|
|
2042
|
+
var _ref46 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref45) {
|
|
2043
|
+
var libraryId, objectId, writeToken, _ref45$metadataSubtre, metadataSubtree, _ref45$metadata, metadata, path;
|
|
2044
|
+
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
2045
|
+
while (1) switch (_context25.prev = _context25.next) {
|
|
2046
2046
|
case 0:
|
|
2047
|
-
libraryId =
|
|
2047
|
+
libraryId = _ref45.libraryId, objectId = _ref45.objectId, writeToken = _ref45.writeToken, _ref45$metadataSubtre = _ref45.metadataSubtree, metadataSubtree = _ref45$metadataSubtre === void 0 ? "/" : _ref45$metadataSubtre, _ref45$metadata = _ref45.metadata, metadata = _ref45$metadata === void 0 ? {} : _ref45$metadata;
|
|
2048
2048
|
ValidateParameters({
|
|
2049
2049
|
libraryId: libraryId,
|
|
2050
2050
|
objectId: objectId
|
|
@@ -2053,34 +2053,34 @@ exports.ReplaceMetadata = /*#__PURE__*/function () {
|
|
|
2053
2053
|
this.Log("Replacing metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
|
|
2054
2054
|
this.Log(metadata);
|
|
2055
2055
|
path = UrlJoin("q", writeToken, "meta", metadataSubtree);
|
|
2056
|
-
|
|
2057
|
-
|
|
2056
|
+
_context25.t0 = this.HttpClient;
|
|
2057
|
+
_context25.next = 9;
|
|
2058
2058
|
return this.authClient.AuthorizationHeader({
|
|
2059
2059
|
libraryId: libraryId,
|
|
2060
2060
|
objectId: objectId,
|
|
2061
2061
|
update: true
|
|
2062
2062
|
});
|
|
2063
|
-
case
|
|
2064
|
-
|
|
2065
|
-
|
|
2066
|
-
|
|
2067
|
-
|
|
2068
|
-
headers:
|
|
2063
|
+
case 9:
|
|
2064
|
+
_context25.t1 = _context25.sent;
|
|
2065
|
+
_context25.t2 = path;
|
|
2066
|
+
_context25.t3 = metadata;
|
|
2067
|
+
_context25.t4 = {
|
|
2068
|
+
headers: _context25.t1,
|
|
2069
2069
|
method: "PUT",
|
|
2070
|
-
path:
|
|
2071
|
-
body:
|
|
2070
|
+
path: _context25.t2,
|
|
2071
|
+
body: _context25.t3,
|
|
2072
2072
|
allowFailover: false
|
|
2073
2073
|
};
|
|
2074
|
-
|
|
2075
|
-
return
|
|
2076
|
-
case
|
|
2074
|
+
_context25.next = 15;
|
|
2075
|
+
return _context25.t0.Request.call(_context25.t0, _context25.t4);
|
|
2076
|
+
case 15:
|
|
2077
2077
|
case "end":
|
|
2078
|
-
return
|
|
2078
|
+
return _context25.stop();
|
|
2079
2079
|
}
|
|
2080
|
-
},
|
|
2080
|
+
}, _callee25, this);
|
|
2081
2081
|
}));
|
|
2082
|
-
return function (
|
|
2083
|
-
return
|
|
2082
|
+
return function (_x24) {
|
|
2083
|
+
return _ref46.apply(this, arguments);
|
|
2084
2084
|
};
|
|
2085
2085
|
}();
|
|
2086
2086
|
|
|
@@ -2096,12 +2096,12 @@ exports.ReplaceMetadata = /*#__PURE__*/function () {
|
|
|
2096
2096
|
* - if not specified, all metadata will be deleted
|
|
2097
2097
|
*/
|
|
2098
2098
|
exports.DeleteMetadata = /*#__PURE__*/function () {
|
|
2099
|
-
var
|
|
2100
|
-
var libraryId, objectId, writeToken,
|
|
2101
|
-
return _regeneratorRuntime.wrap(function (
|
|
2102
|
-
while (1) switch (
|
|
2099
|
+
var _ref48 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee26(_ref47) {
|
|
2100
|
+
var libraryId, objectId, writeToken, _ref47$metadataSubtre, metadataSubtree, path;
|
|
2101
|
+
return _regeneratorRuntime.wrap(function _callee26$(_context26) {
|
|
2102
|
+
while (1) switch (_context26.prev = _context26.next) {
|
|
2103
2103
|
case 0:
|
|
2104
|
-
libraryId =
|
|
2104
|
+
libraryId = _ref47.libraryId, objectId = _ref47.objectId, writeToken = _ref47.writeToken, _ref47$metadataSubtre = _ref47.metadataSubtree, metadataSubtree = _ref47$metadataSubtre === void 0 ? "/" : _ref47$metadataSubtre;
|
|
2105
2105
|
ValidateParameters({
|
|
2106
2106
|
libraryId: libraryId,
|
|
2107
2107
|
objectId: objectId
|
|
@@ -2110,32 +2110,32 @@ exports.DeleteMetadata = /*#__PURE__*/function () {
|
|
|
2110
2110
|
this.Log("Deleting metadata: ".concat(libraryId, " ").concat(objectId, " ").concat(writeToken, "\n Subtree: ").concat(metadataSubtree));
|
|
2111
2111
|
this.Log("Subtree: ".concat(metadataSubtree));
|
|
2112
2112
|
path = UrlJoin("q", writeToken, "meta", metadataSubtree);
|
|
2113
|
-
|
|
2114
|
-
|
|
2113
|
+
_context26.t0 = this.HttpClient;
|
|
2114
|
+
_context26.next = 9;
|
|
2115
2115
|
return this.authClient.AuthorizationHeader({
|
|
2116
2116
|
libraryId: libraryId,
|
|
2117
2117
|
objectId: objectId,
|
|
2118
2118
|
update: true
|
|
2119
2119
|
});
|
|
2120
|
-
case
|
|
2121
|
-
|
|
2122
|
-
|
|
2123
|
-
|
|
2124
|
-
headers:
|
|
2120
|
+
case 9:
|
|
2121
|
+
_context26.t1 = _context26.sent;
|
|
2122
|
+
_context26.t2 = path;
|
|
2123
|
+
_context26.t3 = {
|
|
2124
|
+
headers: _context26.t1,
|
|
2125
2125
|
method: "DELETE",
|
|
2126
|
-
path:
|
|
2126
|
+
path: _context26.t2,
|
|
2127
2127
|
allowFailover: false
|
|
2128
2128
|
};
|
|
2129
|
-
|
|
2130
|
-
return
|
|
2131
|
-
case
|
|
2129
|
+
_context26.next = 14;
|
|
2130
|
+
return _context26.t0.Request.call(_context26.t0, _context26.t3);
|
|
2131
|
+
case 14:
|
|
2132
2132
|
case "end":
|
|
2133
|
-
return
|
|
2133
|
+
return _context26.stop();
|
|
2134
2134
|
}
|
|
2135
|
-
},
|
|
2135
|
+
}, _callee26, this);
|
|
2136
2136
|
}));
|
|
2137
|
-
return function (
|
|
2138
|
-
return
|
|
2137
|
+
return function (_x25) {
|
|
2138
|
+
return _ref48.apply(this, arguments);
|
|
2139
2139
|
};
|
|
2140
2140
|
}();
|
|
2141
2141
|
|
|
@@ -2148,28 +2148,28 @@ exports.DeleteMetadata = /*#__PURE__*/function () {
|
|
|
2148
2148
|
* @param {number | string} accessCharge - The new access charge, in ether
|
|
2149
2149
|
*/
|
|
2150
2150
|
exports.SetAccessCharge = /*#__PURE__*/function () {
|
|
2151
|
-
var
|
|
2151
|
+
var _ref50 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee27(_ref49) {
|
|
2152
2152
|
var objectId, accessCharge;
|
|
2153
|
-
return _regeneratorRuntime.wrap(function (
|
|
2154
|
-
while (1) switch (
|
|
2153
|
+
return _regeneratorRuntime.wrap(function _callee27$(_context27) {
|
|
2154
|
+
while (1) switch (_context27.prev = _context27.next) {
|
|
2155
2155
|
case 0:
|
|
2156
|
-
objectId =
|
|
2156
|
+
objectId = _ref49.objectId, accessCharge = _ref49.accessCharge;
|
|
2157
2157
|
ValidateObject(objectId);
|
|
2158
2158
|
this.Log("Setting access charge: ".concat(objectId, " ").concat(accessCharge));
|
|
2159
|
-
|
|
2159
|
+
_context27.next = 5;
|
|
2160
2160
|
return this.ethClient.CallContractMethodAndWait({
|
|
2161
2161
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
2162
2162
|
methodName: "setAccessCharge",
|
|
2163
2163
|
methodArgs: [this.utils.EtherToWei(accessCharge).toString()]
|
|
2164
2164
|
});
|
|
2165
|
-
case
|
|
2165
|
+
case 5:
|
|
2166
2166
|
case "end":
|
|
2167
|
-
return
|
|
2167
|
+
return _context27.stop();
|
|
2168
2168
|
}
|
|
2169
|
-
},
|
|
2169
|
+
}, _callee27, this);
|
|
2170
2170
|
}));
|
|
2171
|
-
return function (
|
|
2172
|
-
return
|
|
2171
|
+
return function (_x26) {
|
|
2172
|
+
return _ref50.apply(this, arguments);
|
|
2173
2173
|
};
|
|
2174
2174
|
}();
|
|
2175
2175
|
|
|
@@ -2187,13 +2187,13 @@ exports.SetAccessCharge = /*#__PURE__*/function () {
|
|
|
2187
2187
|
* - Format: {completed: number, total: number, action: string}
|
|
2188
2188
|
*/
|
|
2189
2189
|
exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
|
|
2190
|
-
var
|
|
2190
|
+
var _ref52 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee29(_ref51) {
|
|
2191
2191
|
var _this4 = this;
|
|
2192
2192
|
var libraryId, objectId, versionHash, callback, total, completed, _loop, _ret;
|
|
2193
|
-
return _regeneratorRuntime.wrap(function (
|
|
2194
|
-
while (1) switch (
|
|
2193
|
+
return _regeneratorRuntime.wrap(function _callee29$(_context30) {
|
|
2194
|
+
while (1) switch (_context30.prev = _context30.next) {
|
|
2195
2195
|
case 0:
|
|
2196
|
-
libraryId =
|
|
2196
|
+
libraryId = _ref51.libraryId, objectId = _ref51.objectId, versionHash = _ref51.versionHash, callback = _ref51.callback;
|
|
2197
2197
|
ValidateParameters({
|
|
2198
2198
|
libraryId: libraryId,
|
|
2199
2199
|
objectId: objectId,
|
|
@@ -2206,10 +2206,10 @@ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
|
|
|
2206
2206
|
completed = 0; // eslint-disable-next-line no-constant-condition
|
|
2207
2207
|
_loop = /*#__PURE__*/_regeneratorRuntime.mark(function _loop() {
|
|
2208
2208
|
var graph, currentHash, links, details, name, currentLibraryId, currentObjectId, _yield$_this4$EditCon, write_token, _yield$_this4$Finaliz, hash;
|
|
2209
|
-
return _regeneratorRuntime.wrap(function (
|
|
2210
|
-
while (1) switch (
|
|
2209
|
+
return _regeneratorRuntime.wrap(function _loop$(_context29) {
|
|
2210
|
+
while (1) switch (_context29.prev = _context29.next) {
|
|
2211
2211
|
case 0:
|
|
2212
|
-
|
|
2212
|
+
_context29.next = 2;
|
|
2213
2213
|
return _this4.ContentObjectGraph({
|
|
2214
2214
|
libraryId: libraryId,
|
|
2215
2215
|
objectId: objectId,
|
|
@@ -2217,17 +2217,17 @@ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
|
|
|
2217
2217
|
autoUpdate: true,
|
|
2218
2218
|
select: ["name", "public/name", "public/asset_metadata/display_title"]
|
|
2219
2219
|
});
|
|
2220
|
-
case
|
|
2221
|
-
graph =
|
|
2220
|
+
case 2:
|
|
2221
|
+
graph = _context29.sent;
|
|
2222
2222
|
if (!(Object.keys(graph.auto_updates).length === 0)) {
|
|
2223
|
-
|
|
2223
|
+
_context29.next = 6;
|
|
2224
2224
|
break;
|
|
2225
2225
|
}
|
|
2226
2226
|
_this4.Log("No more updates required");
|
|
2227
|
-
return
|
|
2227
|
+
return _context29.abrupt("return", {
|
|
2228
2228
|
v: void 0
|
|
2229
2229
|
});
|
|
2230
|
-
case
|
|
2230
|
+
case 6:
|
|
2231
2231
|
if (!total) {
|
|
2232
2232
|
total = graph.auto_updates.order.length;
|
|
2233
2233
|
}
|
|
@@ -2235,12 +2235,12 @@ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
|
|
|
2235
2235
|
links = graph.auto_updates.links[currentHash];
|
|
2236
2236
|
details = graph.details[currentHash].meta || {};
|
|
2237
2237
|
name = details["public"] && details["public"].asset_metadata && details["public"].asset_metadata.display_title || details["public"] && details["public"].name || details.name || versionHash || objectId;
|
|
2238
|
-
|
|
2238
|
+
_context29.next = 13;
|
|
2239
2239
|
return _this4.ContentObjectLibraryId({
|
|
2240
2240
|
versionHash: currentHash
|
|
2241
2241
|
});
|
|
2242
|
-
case
|
|
2243
|
-
currentLibraryId =
|
|
2242
|
+
case 13:
|
|
2243
|
+
currentLibraryId = _context29.sent;
|
|
2244
2244
|
currentObjectId = _this4.utils.DecodeVersionHash(currentHash).objectId;
|
|
2245
2245
|
if (callback) {
|
|
2246
2246
|
callback({
|
|
@@ -2250,23 +2250,23 @@ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
|
|
|
2250
2250
|
});
|
|
2251
2251
|
}
|
|
2252
2252
|
_this4.Log("Updating links for ".concat(name, " (").concat(currentObjectId, " / ").concat(currentHash, ")"));
|
|
2253
|
-
|
|
2253
|
+
_context29.next = 19;
|
|
2254
2254
|
return _this4.EditContentObject({
|
|
2255
2255
|
libraryId: currentLibraryId,
|
|
2256
2256
|
objectId: currentObjectId
|
|
2257
2257
|
});
|
|
2258
|
-
case
|
|
2259
|
-
_yield$_this4$EditCon =
|
|
2258
|
+
case 19:
|
|
2259
|
+
_yield$_this4$EditCon = _context29.sent;
|
|
2260
2260
|
write_token = _yield$_this4$EditCon.write_token;
|
|
2261
|
-
|
|
2262
|
-
return Promise.all(links.map(/*#__PURE__*/function () {
|
|
2263
|
-
var
|
|
2261
|
+
_context29.next = 23;
|
|
2262
|
+
return Promise.all(links.map( /*#__PURE__*/function () {
|
|
2263
|
+
var _ref54 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee28(_ref53) {
|
|
2264
2264
|
var path, updated;
|
|
2265
|
-
return _regeneratorRuntime.wrap(function (
|
|
2266
|
-
while (1) switch (
|
|
2265
|
+
return _regeneratorRuntime.wrap(function _callee28$(_context28) {
|
|
2266
|
+
while (1) switch (_context28.prev = _context28.next) {
|
|
2267
2267
|
case 0:
|
|
2268
|
-
path =
|
|
2269
|
-
|
|
2268
|
+
path = _ref53.path, updated = _ref53.updated;
|
|
2269
|
+
_context28.next = 3;
|
|
2270
2270
|
return _this4.ReplaceMetadata({
|
|
2271
2271
|
libraryId: currentLibraryId,
|
|
2272
2272
|
objectId: currentObjectId,
|
|
@@ -2274,62 +2274,62 @@ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
|
|
|
2274
2274
|
metadataSubtree: path,
|
|
2275
2275
|
metadata: updated
|
|
2276
2276
|
});
|
|
2277
|
-
case
|
|
2277
|
+
case 3:
|
|
2278
2278
|
case "end":
|
|
2279
|
-
return
|
|
2279
|
+
return _context28.stop();
|
|
2280
2280
|
}
|
|
2281
|
-
},
|
|
2281
|
+
}, _callee28);
|
|
2282
2282
|
}));
|
|
2283
|
-
return function (
|
|
2284
|
-
return
|
|
2283
|
+
return function (_x28) {
|
|
2284
|
+
return _ref54.apply(this, arguments);
|
|
2285
2285
|
};
|
|
2286
2286
|
}()));
|
|
2287
|
-
case
|
|
2288
|
-
|
|
2287
|
+
case 23:
|
|
2288
|
+
_context29.next = 25;
|
|
2289
2289
|
return _this4.FinalizeContentObject({
|
|
2290
2290
|
libraryId: currentLibraryId,
|
|
2291
2291
|
objectId: currentObjectId,
|
|
2292
2292
|
writeToken: write_token,
|
|
2293
2293
|
commitMessage: "Update links"
|
|
2294
2294
|
});
|
|
2295
|
-
case
|
|
2296
|
-
_yield$_this4$Finaliz =
|
|
2295
|
+
case 25:
|
|
2296
|
+
_yield$_this4$Finaliz = _context29.sent;
|
|
2297
2297
|
hash = _yield$_this4$Finaliz.hash;
|
|
2298
2298
|
// If root object was specified by hash and updated, update hash
|
|
2299
2299
|
if (currentHash === versionHash) {
|
|
2300
2300
|
versionHash = hash;
|
|
2301
2301
|
}
|
|
2302
2302
|
completed += 1;
|
|
2303
|
-
case
|
|
2303
|
+
case 29:
|
|
2304
2304
|
case "end":
|
|
2305
|
-
return
|
|
2305
|
+
return _context29.stop();
|
|
2306
2306
|
}
|
|
2307
2307
|
}, _loop);
|
|
2308
2308
|
});
|
|
2309
|
-
case
|
|
2309
|
+
case 6:
|
|
2310
2310
|
if (!1) {
|
|
2311
|
-
|
|
2311
|
+
_context30.next = 13;
|
|
2312
2312
|
break;
|
|
2313
2313
|
}
|
|
2314
|
-
return
|
|
2315
|
-
case
|
|
2316
|
-
_ret =
|
|
2314
|
+
return _context30.delegateYield(_loop(), "t0", 8);
|
|
2315
|
+
case 8:
|
|
2316
|
+
_ret = _context30.t0;
|
|
2317
2317
|
if (!_ret) {
|
|
2318
|
-
|
|
2318
|
+
_context30.next = 11;
|
|
2319
2319
|
break;
|
|
2320
2320
|
}
|
|
2321
|
-
return
|
|
2322
|
-
case
|
|
2323
|
-
|
|
2321
|
+
return _context30.abrupt("return", _ret.v);
|
|
2322
|
+
case 11:
|
|
2323
|
+
_context30.next = 6;
|
|
2324
2324
|
break;
|
|
2325
|
-
case
|
|
2325
|
+
case 13:
|
|
2326
2326
|
case "end":
|
|
2327
|
-
return
|
|
2327
|
+
return _context30.stop();
|
|
2328
2328
|
}
|
|
2329
|
-
},
|
|
2329
|
+
}, _callee29, this);
|
|
2330
2330
|
}));
|
|
2331
|
-
return function (
|
|
2332
|
-
return
|
|
2331
|
+
return function (_x27) {
|
|
2332
|
+
return _ref52.apply(this, arguments);
|
|
2333
2333
|
};
|
|
2334
2334
|
}();
|
|
2335
2335
|
|
|
@@ -2346,74 +2346,74 @@ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
|
|
|
2346
2346
|
* @return {Promise<string>} - The state channel token
|
|
2347
2347
|
*/
|
|
2348
2348
|
exports.GenerateSignedLinkToken = /*#__PURE__*/function () {
|
|
2349
|
-
var
|
|
2350
|
-
var containerId, versionHash, link, duration, canEdit, _this$utils$DecodeVer2, objectId, signerAddress, token, compressedToken, signature
|
|
2351
|
-
return _regeneratorRuntime.wrap(function (
|
|
2352
|
-
while (1) switch (
|
|
2349
|
+
var _ref56 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee30(_ref55) {
|
|
2350
|
+
var containerId, versionHash, link, duration, canEdit, _this$utils$DecodeVer2, objectId, signerAddress, token, compressedToken, signature;
|
|
2351
|
+
return _regeneratorRuntime.wrap(function _callee30$(_context31) {
|
|
2352
|
+
while (1) switch (_context31.prev = _context31.next) {
|
|
2353
2353
|
case 0:
|
|
2354
|
-
containerId =
|
|
2354
|
+
containerId = _ref55.containerId, versionHash = _ref55.versionHash, link = _ref55.link, duration = _ref55.duration;
|
|
2355
2355
|
ValidateObject(containerId);
|
|
2356
|
-
|
|
2356
|
+
_context31.next = 4;
|
|
2357
2357
|
return this.CallContractMethod({
|
|
2358
2358
|
contractAddress: this.utils.HashToAddress(containerId),
|
|
2359
2359
|
methodName: "canEdit"
|
|
2360
2360
|
});
|
|
2361
|
-
case
|
|
2362
|
-
canEdit =
|
|
2361
|
+
case 4:
|
|
2362
|
+
canEdit = _context31.sent;
|
|
2363
2363
|
_this$utils$DecodeVer2 = this.utils.DecodeVersionHash(versionHash), objectId = _this$utils$DecodeVer2.objectId;
|
|
2364
2364
|
if (canEdit) {
|
|
2365
|
-
|
|
2365
|
+
_context31.next = 8;
|
|
2366
2366
|
break;
|
|
2367
2367
|
}
|
|
2368
2368
|
throw Error("Current user does not have permission to edit content object ".concat(objectId));
|
|
2369
|
-
case
|
|
2369
|
+
case 8:
|
|
2370
2370
|
signerAddress = this.CurrentAccountAddress();
|
|
2371
|
-
|
|
2372
|
-
|
|
2371
|
+
_context31.t0 = this.utils.B64(signerAddress.replace("0x", ""), "hex");
|
|
2372
|
+
_context31.next = 12;
|
|
2373
2373
|
return this.ContentSpaceId();
|
|
2374
|
-
case
|
|
2375
|
-
|
|
2376
|
-
|
|
2374
|
+
case 12:
|
|
2375
|
+
_context31.t1 = _context31.sent;
|
|
2376
|
+
_context31.next = 15;
|
|
2377
2377
|
return this.ContentObjectLibraryId({
|
|
2378
2378
|
objectId: objectId
|
|
2379
2379
|
});
|
|
2380
|
-
case
|
|
2381
|
-
|
|
2382
|
-
|
|
2383
|
-
|
|
2384
|
-
|
|
2385
|
-
|
|
2386
|
-
|
|
2380
|
+
case 15:
|
|
2381
|
+
_context31.t2 = _context31.sent;
|
|
2382
|
+
_context31.t3 = objectId;
|
|
2383
|
+
_context31.t4 = "iusr".concat(this.utils.AddressToHash(signerAddress));
|
|
2384
|
+
_context31.t5 = Date.now();
|
|
2385
|
+
_context31.t6 = duration ? Date.now() + duration : undefined;
|
|
2386
|
+
_context31.t7 = {
|
|
2387
2387
|
elv: {
|
|
2388
2388
|
lnk: link,
|
|
2389
2389
|
src: containerId
|
|
2390
2390
|
}
|
|
2391
2391
|
};
|
|
2392
2392
|
token = {
|
|
2393
|
-
adr:
|
|
2394
|
-
spc:
|
|
2395
|
-
lib:
|
|
2396
|
-
qid:
|
|
2397
|
-
sub:
|
|
2393
|
+
adr: _context31.t0,
|
|
2394
|
+
spc: _context31.t1,
|
|
2395
|
+
lib: _context31.t2,
|
|
2396
|
+
qid: _context31.t3,
|
|
2397
|
+
sub: _context31.t4,
|
|
2398
2398
|
gra: "read",
|
|
2399
|
-
iat:
|
|
2400
|
-
exp:
|
|
2401
|
-
ctx:
|
|
2399
|
+
iat: _context31.t5,
|
|
2400
|
+
exp: _context31.t6,
|
|
2401
|
+
ctx: _context31.t7
|
|
2402
2402
|
};
|
|
2403
2403
|
compressedToken = Pako.deflateRaw(Buffer.from(JSON.stringify(token), "utf-8"));
|
|
2404
|
-
|
|
2404
|
+
_context31.next = 25;
|
|
2405
2405
|
return this.authClient.Sign(Ethers.utils.keccak256(compressedToken));
|
|
2406
|
-
case
|
|
2407
|
-
signature =
|
|
2408
|
-
return
|
|
2409
|
-
case
|
|
2406
|
+
case 25:
|
|
2407
|
+
signature = _context31.sent;
|
|
2408
|
+
return _context31.abrupt("return", "aslsjc".concat(this.utils.B58(Buffer.concat([Buffer.from(signature.replace(/^0x/, ""), "hex"), Buffer.from(compressedToken)]))));
|
|
2409
|
+
case 27:
|
|
2410
2410
|
case "end":
|
|
2411
|
-
return
|
|
2411
|
+
return _context31.stop();
|
|
2412
2412
|
}
|
|
2413
|
-
},
|
|
2413
|
+
}, _callee30, this);
|
|
2414
2414
|
}));
|
|
2415
|
-
return function (
|
|
2416
|
-
return
|
|
2415
|
+
return function (_x29) {
|
|
2416
|
+
return _ref56.apply(this, arguments);
|
|
2417
2417
|
};
|
|
2418
2418
|
}();
|
|
2419
2419
|
|
|
@@ -2443,24 +2443,24 @@ exports.GenerateSignedLinkToken = /*#__PURE__*/function () {
|
|
|
2443
2443
|
* @param {Array<Object>} links - Link specifications
|
|
2444
2444
|
*/
|
|
2445
2445
|
exports.CreateLinks = /*#__PURE__*/function () {
|
|
2446
|
-
var
|
|
2446
|
+
var _ref58 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee32(_ref57) {
|
|
2447
2447
|
var _this5 = this;
|
|
2448
|
-
var libraryId, objectId, writeToken,
|
|
2449
|
-
return _regeneratorRuntime.wrap(function (
|
|
2450
|
-
while (1) switch (
|
|
2448
|
+
var libraryId, objectId, writeToken, _ref57$links, links;
|
|
2449
|
+
return _regeneratorRuntime.wrap(function _callee32$(_context33) {
|
|
2450
|
+
while (1) switch (_context33.prev = _context33.next) {
|
|
2451
2451
|
case 0:
|
|
2452
|
-
libraryId =
|
|
2452
|
+
libraryId = _ref57.libraryId, objectId = _ref57.objectId, writeToken = _ref57.writeToken, _ref57$links = _ref57.links, links = _ref57$links === void 0 ? [] : _ref57$links;
|
|
2453
2453
|
ValidateParameters({
|
|
2454
2454
|
libraryId: libraryId,
|
|
2455
2455
|
objectId: objectId
|
|
2456
2456
|
});
|
|
2457
2457
|
ValidateWriteToken(writeToken);
|
|
2458
|
-
|
|
2458
|
+
_context33.next = 5;
|
|
2459
2459
|
return this.utils.LimitedMap(10, links, /*#__PURE__*/function () {
|
|
2460
|
-
var
|
|
2460
|
+
var _ref59 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee31(info) {
|
|
2461
2461
|
var path, type, target, authTarget, link, linkMetadata;
|
|
2462
|
-
return _regeneratorRuntime.wrap(function (
|
|
2463
|
-
while (1) switch (
|
|
2462
|
+
return _regeneratorRuntime.wrap(function _callee31$(_context32) {
|
|
2463
|
+
while (1) switch (_context32.prev = _context32.next) {
|
|
2464
2464
|
case 0:
|
|
2465
2465
|
path = info.path.replace(/^([/.])+/, "");
|
|
2466
2466
|
type = (info.type || "file") === "file" ? "files" : info.type;
|
|
@@ -2486,35 +2486,35 @@ exports.CreateLinks = /*#__PURE__*/function () {
|
|
|
2486
2486
|
|
|
2487
2487
|
// Sign link
|
|
2488
2488
|
if (!info.authContainer) {
|
|
2489
|
-
|
|
2489
|
+
_context32.next = 17;
|
|
2490
2490
|
break;
|
|
2491
2491
|
}
|
|
2492
|
-
|
|
2492
|
+
_context32.next = 10;
|
|
2493
2493
|
return _this5.ContentObjectMetadata({
|
|
2494
2494
|
libraryId: libraryId,
|
|
2495
2495
|
objectId: objectId,
|
|
2496
2496
|
metadataSubtree: path
|
|
2497
2497
|
});
|
|
2498
|
-
case
|
|
2499
|
-
linkMetadata =
|
|
2498
|
+
case 10:
|
|
2499
|
+
linkMetadata = _context32.sent;
|
|
2500
2500
|
if (linkMetadata) {
|
|
2501
2501
|
link = linkMetadata;
|
|
2502
2502
|
}
|
|
2503
2503
|
if (!link["."]) link["."] = {};
|
|
2504
2504
|
if (linkMetadata["."]["authorization"]) {
|
|
2505
|
-
|
|
2505
|
+
_context32.next = 17;
|
|
2506
2506
|
break;
|
|
2507
2507
|
}
|
|
2508
|
-
|
|
2508
|
+
_context32.next = 16;
|
|
2509
2509
|
return _this5.GenerateSignedLinkToken({
|
|
2510
2510
|
containerId: info.authContainer,
|
|
2511
2511
|
versionHash: info.targetHash,
|
|
2512
2512
|
link: "./".concat(type, "/").concat(authTarget)
|
|
2513
2513
|
});
|
|
2514
|
-
case
|
|
2515
|
-
link["."]["authorization"] =
|
|
2516
|
-
case
|
|
2517
|
-
|
|
2514
|
+
case 16:
|
|
2515
|
+
link["."]["authorization"] = _context32.sent;
|
|
2516
|
+
case 17:
|
|
2517
|
+
_context32.next = 19;
|
|
2518
2518
|
return _this5.ReplaceMetadata({
|
|
2519
2519
|
libraryId: libraryId,
|
|
2520
2520
|
objectId: objectId,
|
|
@@ -2522,24 +2522,24 @@ exports.CreateLinks = /*#__PURE__*/function () {
|
|
|
2522
2522
|
metadataSubtree: path,
|
|
2523
2523
|
metadata: link
|
|
2524
2524
|
});
|
|
2525
|
-
case
|
|
2525
|
+
case 19:
|
|
2526
2526
|
case "end":
|
|
2527
|
-
return
|
|
2527
|
+
return _context32.stop();
|
|
2528
2528
|
}
|
|
2529
|
-
},
|
|
2529
|
+
}, _callee31);
|
|
2530
2530
|
}));
|
|
2531
|
-
return function (
|
|
2532
|
-
return
|
|
2531
|
+
return function (_x31) {
|
|
2532
|
+
return _ref59.apply(this, arguments);
|
|
2533
2533
|
};
|
|
2534
2534
|
}());
|
|
2535
|
-
case
|
|
2535
|
+
case 5:
|
|
2536
2536
|
case "end":
|
|
2537
|
-
return
|
|
2537
|
+
return _context33.stop();
|
|
2538
2538
|
}
|
|
2539
|
-
},
|
|
2539
|
+
}, _callee32, this);
|
|
2540
2540
|
}));
|
|
2541
|
-
return function (
|
|
2542
|
-
return
|
|
2541
|
+
return function (_x30) {
|
|
2542
|
+
return _ref58.apply(this, arguments);
|
|
2543
2543
|
};
|
|
2544
2544
|
}();
|
|
2545
2545
|
|
|
@@ -2558,12 +2558,12 @@ exports.CreateLinks = /*#__PURE__*/function () {
|
|
|
2558
2558
|
* @param {string=} id - The ID of the policy
|
|
2559
2559
|
*/
|
|
2560
2560
|
exports.InitializeAuthPolicy = /*#__PURE__*/function () {
|
|
2561
|
-
var
|
|
2562
|
-
var libraryId, objectId, writeToken,
|
|
2563
|
-
return _regeneratorRuntime.wrap(function (
|
|
2564
|
-
while (1) switch (
|
|
2561
|
+
var _ref61 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee33(_ref60) {
|
|
2562
|
+
var libraryId, objectId, writeToken, _ref60$target, target, body, version, description, id, authPolicy, string;
|
|
2563
|
+
return _regeneratorRuntime.wrap(function _callee33$(_context34) {
|
|
2564
|
+
while (1) switch (_context34.prev = _context34.next) {
|
|
2565
2565
|
case 0:
|
|
2566
|
-
libraryId =
|
|
2566
|
+
libraryId = _ref60.libraryId, objectId = _ref60.objectId, writeToken = _ref60.writeToken, _ref60$target = _ref60.target, target = _ref60$target === void 0 ? "auth_policy_spec" : _ref60$target, body = _ref60.body, version = _ref60.version, description = _ref60.description, id = _ref60.id;
|
|
2567
2567
|
authPolicy = {
|
|
2568
2568
|
type: "epl-ast",
|
|
2569
2569
|
version: version,
|
|
@@ -2576,13 +2576,13 @@ exports.InitializeAuthPolicy = /*#__PURE__*/function () {
|
|
|
2576
2576
|
id: id || ""
|
|
2577
2577
|
};
|
|
2578
2578
|
string = "".concat(authPolicy.type, "|").concat(authPolicy.version, "|").concat(authPolicy.body, "|").concat(authPolicy.data["/"]);
|
|
2579
|
-
|
|
2580
|
-
|
|
2579
|
+
_context34.t0 = this.utils;
|
|
2580
|
+
_context34.next = 6;
|
|
2581
2581
|
return this.authClient.Sign(Ethers.utils.keccak256(Ethers.utils.toUtf8Bytes(string)));
|
|
2582
|
-
case
|
|
2583
|
-
|
|
2584
|
-
authPolicy.signature =
|
|
2585
|
-
|
|
2582
|
+
case 6:
|
|
2583
|
+
_context34.t1 = _context34.sent;
|
|
2584
|
+
authPolicy.signature = _context34.t0.FormatSignature.call(_context34.t0, _context34.t1);
|
|
2585
|
+
_context34.next = 10;
|
|
2586
2586
|
return this.ReplaceMetadata({
|
|
2587
2587
|
libraryId: libraryId,
|
|
2588
2588
|
objectId: objectId,
|
|
@@ -2590,20 +2590,20 @@ exports.InitializeAuthPolicy = /*#__PURE__*/function () {
|
|
|
2590
2590
|
metadataSubtree: "auth_policy",
|
|
2591
2591
|
metadata: authPolicy
|
|
2592
2592
|
});
|
|
2593
|
-
case
|
|
2594
|
-
|
|
2593
|
+
case 10:
|
|
2594
|
+
_context34.next = 12;
|
|
2595
2595
|
return this.SetAuthPolicy({
|
|
2596
2596
|
objectId: objectId,
|
|
2597
2597
|
policyId: objectId
|
|
2598
2598
|
});
|
|
2599
|
-
case
|
|
2599
|
+
case 12:
|
|
2600
2600
|
case "end":
|
|
2601
|
-
return
|
|
2601
|
+
return _context34.stop();
|
|
2602
2602
|
}
|
|
2603
|
-
},
|
|
2603
|
+
}, _callee33, this);
|
|
2604
2604
|
}));
|
|
2605
|
-
return function (
|
|
2606
|
-
return
|
|
2605
|
+
return function (_x32) {
|
|
2606
|
+
return _ref61.apply(this, arguments);
|
|
2607
2607
|
};
|
|
2608
2608
|
}();
|
|
2609
2609
|
|
|
@@ -2616,13 +2616,13 @@ exports.InitializeAuthPolicy = /*#__PURE__*/function () {
|
|
|
2616
2616
|
* @param {string} policyId - The ID of the policy
|
|
2617
2617
|
*/
|
|
2618
2618
|
exports.SetAuthPolicy = /*#__PURE__*/function () {
|
|
2619
|
-
var
|
|
2619
|
+
var _ref63 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee34(_ref62) {
|
|
2620
2620
|
var objectId, policyId;
|
|
2621
|
-
return _regeneratorRuntime.wrap(function (
|
|
2622
|
-
while (1) switch (
|
|
2621
|
+
return _regeneratorRuntime.wrap(function _callee34$(_context35) {
|
|
2622
|
+
while (1) switch (_context35.prev = _context35.next) {
|
|
2623
2623
|
case 0:
|
|
2624
|
-
objectId =
|
|
2625
|
-
|
|
2624
|
+
objectId = _ref62.objectId, policyId = _ref62.policyId;
|
|
2625
|
+
_context35.next = 3;
|
|
2626
2626
|
return this.MergeContractMetadata({
|
|
2627
2627
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
2628
2628
|
metadataKey: "_AUTH_CONTEXT",
|
|
@@ -2630,14 +2630,14 @@ exports.SetAuthPolicy = /*#__PURE__*/function () {
|
|
|
2630
2630
|
"elv:delegation-id": policyId
|
|
2631
2631
|
}
|
|
2632
2632
|
});
|
|
2633
|
-
case
|
|
2633
|
+
case 3:
|
|
2634
2634
|
case "end":
|
|
2635
|
-
return
|
|
2635
|
+
return _context35.stop();
|
|
2636
2636
|
}
|
|
2637
|
-
},
|
|
2637
|
+
}, _callee34, this);
|
|
2638
2638
|
}));
|
|
2639
|
-
return function (
|
|
2640
|
-
return
|
|
2639
|
+
return function (_x33) {
|
|
2640
|
+
return _ref63.apply(this, arguments);
|
|
2641
2641
|
};
|
|
2642
2642
|
}();
|
|
2643
2643
|
|
|
@@ -2650,47 +2650,47 @@ exports.SetAuthPolicy = /*#__PURE__*/function () {
|
|
|
2650
2650
|
* @param {string} writeToken - Write token to delete
|
|
2651
2651
|
*/
|
|
2652
2652
|
exports.DeleteWriteToken = /*#__PURE__*/function () {
|
|
2653
|
-
var
|
|
2653
|
+
var _ref65 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee35(_ref64) {
|
|
2654
2654
|
var writeToken, objectId, libraryId, path, authorizationHeader;
|
|
2655
|
-
return _regeneratorRuntime.wrap(function (
|
|
2656
|
-
while (1) switch (
|
|
2655
|
+
return _regeneratorRuntime.wrap(function _callee35$(_context36) {
|
|
2656
|
+
while (1) switch (_context36.prev = _context36.next) {
|
|
2657
2657
|
case 0:
|
|
2658
|
-
writeToken =
|
|
2658
|
+
writeToken = _ref64.writeToken;
|
|
2659
2659
|
ValidateWriteToken(writeToken);
|
|
2660
2660
|
objectId = this.utils.DecodeWriteToken(writeToken).objectId;
|
|
2661
|
-
|
|
2661
|
+
_context36.next = 5;
|
|
2662
2662
|
return this.ContentObjectLibraryId({
|
|
2663
2663
|
objectId: objectId
|
|
2664
2664
|
});
|
|
2665
|
-
case
|
|
2666
|
-
libraryId =
|
|
2665
|
+
case 5:
|
|
2666
|
+
libraryId = _context36.sent;
|
|
2667
2667
|
path = UrlJoin("qlibs", libraryId, "q", writeToken);
|
|
2668
|
-
|
|
2668
|
+
_context36.next = 9;
|
|
2669
2669
|
return this.authClient.AuthorizationHeader({
|
|
2670
2670
|
objectId: objectId,
|
|
2671
2671
|
update: true
|
|
2672
2672
|
});
|
|
2673
|
-
case
|
|
2674
|
-
authorizationHeader =
|
|
2675
|
-
|
|
2673
|
+
case 9:
|
|
2674
|
+
authorizationHeader = _context36.sent;
|
|
2675
|
+
_context36.next = 12;
|
|
2676
2676
|
return this.HttpClient.Request({
|
|
2677
2677
|
headers: authorizationHeader,
|
|
2678
2678
|
method: "DELETE",
|
|
2679
2679
|
path: path,
|
|
2680
2680
|
allowFailover: false
|
|
2681
2681
|
});
|
|
2682
|
-
case
|
|
2683
|
-
|
|
2682
|
+
case 12:
|
|
2683
|
+
_context36.next = 14;
|
|
2684
2684
|
return this.HttpClient.ClearWriteToken({
|
|
2685
2685
|
writeToken: writeToken
|
|
2686
2686
|
});
|
|
2687
|
-
case
|
|
2687
|
+
case 14:
|
|
2688
2688
|
case "end":
|
|
2689
|
-
return
|
|
2689
|
+
return _context36.stop();
|
|
2690
2690
|
}
|
|
2691
|
-
},
|
|
2691
|
+
}, _callee35, this);
|
|
2692
2692
|
}));
|
|
2693
|
-
return function (
|
|
2694
|
-
return
|
|
2693
|
+
return function (_x34) {
|
|
2694
|
+
return _ref65.apply(this, arguments);
|
|
2695
2695
|
};
|
|
2696
2696
|
}();
|