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