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