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