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