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