@eluvio/elv-client-js 3.2.44 → 4.0.0
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 +17 -9
- package/dist/ElvClient-node-min.js +12 -25
- package/dist/ElvFrameClient-min.js +17 -9
- package/dist/ElvPermissionsClient-min.js +16 -8
- package/dist/ElvWalletClient-min.js +17 -9
- package/dist/ElvWalletClient-node-min.js +12 -25
- package/dist/src/AuthorizationClient.js +6 -6
- package/dist/src/ElvClient.js +3 -3
- package/dist/src/ElvWallet.js +1 -3
- package/dist/src/EthClient.js +21 -12
- package/dist/src/FrameClient.js +10 -7
- package/dist/src/HttpClient.js +3 -3
- package/dist/src/client/ABRPublishing.js +150 -103
- package/dist/src/client/ContentAccess.js +32 -15
- package/dist/src/client/ContentManagement.js +33 -24
- package/dist/src/client/Contracts.js +1 -1
- package/dist/src/walletClient/ClientMethods.js +573 -645
- package/dist/src/walletClient/index.js +47 -43
- package/package.json +2 -2
- package/src/AuthorizationClient.js +6 -6
- package/src/ElvClient.js +3 -2
- package/src/ElvWallet.js +1 -3
- package/src/EthClient.js +19 -10
- package/src/FrameClient.js +10 -2
- package/src/HttpClient.js +3 -3
- package/src/client/ABRPublishing.js +71 -32
- package/src/client/ContentAccess.js +19 -8
- package/src/client/ContentManagement.js +21 -14
- package/src/client/Contracts.js +1 -1
- package/testScripts/Test.js +7 -36
|
@@ -19,6 +19,8 @@ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { va
|
|
|
19
19
|
*/
|
|
20
20
|
var UrlJoin = require("url-join");
|
|
21
21
|
|
|
22
|
+
var objectPath = require("object-path");
|
|
23
|
+
|
|
22
24
|
var HttpClient = require("../HttpClient");
|
|
23
25
|
|
|
24
26
|
var _require = require("../Validation"),
|
|
@@ -1154,6 +1156,7 @@ exports.ContentObjects = /*#__PURE__*/function () {
|
|
|
1154
1156
|
* @param {string=} libraryId - ID of the library
|
|
1155
1157
|
* @param {string=} objectId - ID of the object
|
|
1156
1158
|
* @param {string=} versionHash - Version hash of the object -- if not specified, latest version is returned
|
|
1159
|
+
* @param {string=} writeToken - Write token for an object draft -- if supplied, versionHash will be ignored
|
|
1157
1160
|
*
|
|
1158
1161
|
* @returns {Promise<Object>} - Description of content object
|
|
1159
1162
|
*/
|
|
@@ -1161,24 +1164,24 @@ exports.ContentObjects = /*#__PURE__*/function () {
|
|
|
1161
1164
|
|
|
1162
1165
|
exports.ContentObject = /*#__PURE__*/function () {
|
|
1163
1166
|
var _ref26 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref25) {
|
|
1164
|
-
var libraryId, objectId, versionHash, path;
|
|
1167
|
+
var libraryId, objectId, versionHash, writeToken, path;
|
|
1165
1168
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1166
1169
|
while (1) {
|
|
1167
1170
|
switch (_context15.prev = _context15.next) {
|
|
1168
1171
|
case 0:
|
|
1169
|
-
libraryId = _ref25.libraryId, objectId = _ref25.objectId, versionHash = _ref25.versionHash;
|
|
1172
|
+
libraryId = _ref25.libraryId, objectId = _ref25.objectId, versionHash = _ref25.versionHash, writeToken = _ref25.writeToken;
|
|
1170
1173
|
ValidateParameters({
|
|
1171
1174
|
libraryId: libraryId,
|
|
1172
1175
|
objectId: objectId,
|
|
1173
1176
|
versionHash: versionHash
|
|
1174
1177
|
});
|
|
1175
|
-
this.Log("Retrieving content object: ".concat(libraryId || "", " ").concat(
|
|
1178
|
+
this.Log("Retrieving content object: ".concat(libraryId || "", " ").concat(writeToken || versionHash || objectId));
|
|
1176
1179
|
|
|
1177
1180
|
if (versionHash) {
|
|
1178
1181
|
objectId = this.utils.DecodeVersionHash(versionHash).objectId;
|
|
1179
1182
|
}
|
|
1180
1183
|
|
|
1181
|
-
path = UrlJoin("q", versionHash || objectId);
|
|
1184
|
+
path = UrlJoin("q", writeToken || versionHash || objectId);
|
|
1182
1185
|
_context15.t0 = this.utils;
|
|
1183
1186
|
_context15.t1 = this.HttpClient;
|
|
1184
1187
|
_context15.next = 9;
|
|
@@ -1782,7 +1785,7 @@ exports.MetadataAuth = /*#__PURE__*/function () {
|
|
|
1782
1785
|
|
|
1783
1786
|
exports.ContentObjectMetadata = /*#__PURE__*/function () {
|
|
1784
1787
|
var _ref41 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee24(_ref40) {
|
|
1785
|
-
var libraryId, objectId, versionHash, writeToken, _ref40$metadataSubtre, metadataSubtree, _ref40$queryParams, queryParams, _ref40$select, select, _ref40$remove, remove, authorizationToken, _ref40$noAuth, noAuth, _ref40$resolveLinks, resolveLinks, _ref40$resolveInclude, resolveIncludeSource, _ref40$resolveIgnoreE, resolveIgnoreErrors, _ref40$linkDepthLimit, linkDepthLimit, _ref40$produceLinkUrl, produceLinkUrls, path, defaultAuthToken, authTokens, metadata;
|
|
1788
|
+
var libraryId, objectId, versionHash, writeToken, _ref40$metadataSubtre, metadataSubtree, _ref40$queryParams, queryParams, _ref40$select, select, _ref40$remove, remove, authorizationToken, _ref40$noAuth, noAuth, _ref40$resolveLinks, resolveLinks, _ref40$resolveInclude, resolveIncludeSource, _ref40$resolveIgnoreE, resolveIgnoreErrors, _ref40$linkDepthLimit, linkDepthLimit, _ref40$produceLinkUrl, produceLinkUrls, path, defaultAuthToken, authTokens, metadata, errQwtoken;
|
|
1786
1789
|
|
|
1787
1790
|
return _regeneratorRuntime.wrap(function _callee24$(_context24) {
|
|
1788
1791
|
while (1) {
|
|
@@ -1841,7 +1844,7 @@ exports.ContentObjectMetadata = /*#__PURE__*/function () {
|
|
|
1841
1844
|
|
|
1842
1845
|
case 14:
|
|
1843
1846
|
metadata = _context24.sent;
|
|
1844
|
-
_context24.next =
|
|
1847
|
+
_context24.next = 27;
|
|
1845
1848
|
break;
|
|
1846
1849
|
|
|
1847
1850
|
case 17:
|
|
@@ -1856,18 +1859,32 @@ exports.ContentObjectMetadata = /*#__PURE__*/function () {
|
|
|
1856
1859
|
throw _context24.t0;
|
|
1857
1860
|
|
|
1858
1861
|
case 21:
|
|
1862
|
+
// For a 404 error, check if error was due to write token not found
|
|
1863
|
+
errQwtoken = objectPath.get(_context24.t0.body, "errors[0].cause.cause.cause.qwtoken");
|
|
1864
|
+
|
|
1865
|
+
if (!errQwtoken) {
|
|
1866
|
+
_context24.next = 26;
|
|
1867
|
+
break;
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
throw _context24.t0;
|
|
1871
|
+
|
|
1872
|
+
case 26:
|
|
1873
|
+
// For all other 404 errors (not just 'subtree not found'), suppress error and
|
|
1874
|
+
// return an empty value. (there are function call chains that depend on this behavior,
|
|
1875
|
+
// e.g. CreateABRMezzanine -> CreateEncryptionConk -> ContentObjectMetadata)
|
|
1859
1876
|
metadata = metadataSubtree === "/" ? {} : undefined;
|
|
1860
1877
|
|
|
1861
|
-
case
|
|
1878
|
+
case 27:
|
|
1862
1879
|
if (produceLinkUrls) {
|
|
1863
|
-
_context24.next =
|
|
1880
|
+
_context24.next = 29;
|
|
1864
1881
|
break;
|
|
1865
1882
|
}
|
|
1866
1883
|
|
|
1867
1884
|
return _context24.abrupt("return", metadata);
|
|
1868
1885
|
|
|
1869
|
-
case
|
|
1870
|
-
_context24.next =
|
|
1886
|
+
case 29:
|
|
1887
|
+
_context24.next = 31;
|
|
1871
1888
|
return this.ProduceMetadataLinks({
|
|
1872
1889
|
libraryId: libraryId,
|
|
1873
1890
|
objectId: objectId,
|
|
@@ -1878,10 +1895,10 @@ exports.ContentObjectMetadata = /*#__PURE__*/function () {
|
|
|
1878
1895
|
noAuth: noAuth
|
|
1879
1896
|
});
|
|
1880
1897
|
|
|
1881
|
-
case
|
|
1898
|
+
case 31:
|
|
1882
1899
|
return _context24.abrupt("return", _context24.sent);
|
|
1883
1900
|
|
|
1884
|
-
case
|
|
1901
|
+
case 32:
|
|
1885
1902
|
case "end":
|
|
1886
1903
|
return _context24.stop();
|
|
1887
1904
|
}
|
|
@@ -4375,7 +4392,7 @@ exports.CreateEncryptionConk = /*#__PURE__*/function () {
|
|
|
4375
4392
|
}
|
|
4376
4393
|
|
|
4377
4394
|
_context46.next = 17;
|
|
4378
|
-
return this.Crypto.DecryptCap(existingUserCap, this.signer.
|
|
4395
|
+
return this.Crypto.DecryptCap(existingUserCap, this.signer._signingKey().privateKey);
|
|
4379
4396
|
|
|
4380
4397
|
case 17:
|
|
4381
4398
|
this.encryptionConks[objectId] = _context46.sent;
|
|
@@ -4397,7 +4414,7 @@ exports.CreateEncryptionConk = /*#__PURE__*/function () {
|
|
|
4397
4414
|
_context46.t3 = writeToken;
|
|
4398
4415
|
_context46.t4 = capKey;
|
|
4399
4416
|
_context46.next = 30;
|
|
4400
|
-
return this.Crypto.EncryptConk(this.encryptionConks[objectId], this.signer.
|
|
4417
|
+
return this.Crypto.EncryptConk(this.encryptionConks[objectId], this.signer._signingKey().publicKey);
|
|
4401
4418
|
|
|
4402
4419
|
case 30:
|
|
4403
4420
|
_context46.t5 = _context46.sent;
|
|
@@ -4614,7 +4631,7 @@ exports.EncryptionConk = /*#__PURE__*/function () {
|
|
|
4614
4631
|
}
|
|
4615
4632
|
|
|
4616
4633
|
_context47.next = 29;
|
|
4617
|
-
return this.Crypto.DecryptCap(existingUserCap, this.signer.
|
|
4634
|
+
return this.Crypto.DecryptCap(existingUserCap, this.signer._signingKey().privateKey);
|
|
4618
4635
|
|
|
4619
4636
|
case 29:
|
|
4620
4637
|
this.encryptionConks[objectId] = _context47.sent;
|
|
@@ -1219,7 +1219,7 @@ exports.CopyContentObject = /*#__PURE__*/function () {
|
|
|
1219
1219
|
}
|
|
1220
1220
|
|
|
1221
1221
|
_context13.next = 20;
|
|
1222
|
-
return this.Crypto.DecryptCap(metadata[userCapKey], this.signer.
|
|
1222
|
+
return this.Crypto.DecryptCap(metadata[userCapKey], this.signer._signingKey().privateKey);
|
|
1223
1223
|
|
|
1224
1224
|
case 20:
|
|
1225
1225
|
userConkKey = _context13.sent;
|
|
@@ -1230,7 +1230,7 @@ exports.CopyContentObject = /*#__PURE__*/function () {
|
|
|
1230
1230
|
_context13.t3 = writeToken;
|
|
1231
1231
|
_context13.t4 = userCapKey;
|
|
1232
1232
|
_context13.next = 29;
|
|
1233
|
-
return this.Crypto.EncryptConk(userConkKey, this.signer.
|
|
1233
|
+
return this.Crypto.EncryptConk(userConkKey, this.signer._signingKey().publicKey);
|
|
1234
1234
|
|
|
1235
1235
|
case 29:
|
|
1236
1236
|
_context13.t5 = _context13.sent;
|
|
@@ -1357,7 +1357,7 @@ exports.CreateNonOwnerCap = /*#__PURE__*/function () {
|
|
|
1357
1357
|
|
|
1358
1358
|
case 7:
|
|
1359
1359
|
_context14.next = 9;
|
|
1360
|
-
return this.Crypto.DecryptCap(userCapValue, this.signer.
|
|
1360
|
+
return this.Crypto.DecryptCap(userCapValue, this.signer._signingKey().privateKey);
|
|
1361
1361
|
|
|
1362
1362
|
case 9:
|
|
1363
1363
|
userConk = _context14.sent;
|
|
@@ -1429,13 +1429,13 @@ exports.CreateNonOwnerCap = /*#__PURE__*/function () {
|
|
|
1429
1429
|
* meta: New metadata for the object - will be merged into existing metadata if specified
|
|
1430
1430
|
* type: New type for the object - Object ID, version hash or name of type
|
|
1431
1431
|
*
|
|
1432
|
-
* @returns {Promise<object>} - Response containing the object ID and write token of the draft
|
|
1432
|
+
* @returns {Promise<object>} - Response containing the object ID and write token of the draft, as well as URL of node handling the draft
|
|
1433
1433
|
*/
|
|
1434
1434
|
|
|
1435
1435
|
|
|
1436
1436
|
exports.EditContentObject = /*#__PURE__*/function () {
|
|
1437
1437
|
var _ref28 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee15(_ref27) {
|
|
1438
|
-
var libraryId, objectId, _ref27$options, options, path, editResponse;
|
|
1438
|
+
var libraryId, objectId, _ref27$options, options, path, rawEditResponse, actualUrl, nodeUrl, editResponse;
|
|
1439
1439
|
|
|
1440
1440
|
return _regeneratorRuntime.wrap(function _callee15$(_context15) {
|
|
1441
1441
|
while (1) {
|
|
@@ -1505,38 +1505,47 @@ exports.EditContentObject = /*#__PURE__*/function () {
|
|
|
1505
1505
|
|
|
1506
1506
|
case 23:
|
|
1507
1507
|
path = UrlJoin("qid", objectId);
|
|
1508
|
-
_context15.t0 = this.
|
|
1509
|
-
_context15.
|
|
1510
|
-
_context15.next = 28;
|
|
1508
|
+
_context15.t0 = this.HttpClient;
|
|
1509
|
+
_context15.next = 27;
|
|
1511
1510
|
return this.authClient.AuthorizationHeader({
|
|
1512
1511
|
libraryId: libraryId,
|
|
1513
1512
|
objectId: objectId,
|
|
1514
1513
|
update: true
|
|
1515
1514
|
});
|
|
1516
1515
|
|
|
1517
|
-
case
|
|
1518
|
-
_context15.
|
|
1519
|
-
_context15.
|
|
1520
|
-
_context15.
|
|
1521
|
-
_context15.
|
|
1522
|
-
headers: _context15.
|
|
1516
|
+
case 27:
|
|
1517
|
+
_context15.t1 = _context15.sent;
|
|
1518
|
+
_context15.t2 = path;
|
|
1519
|
+
_context15.t3 = options;
|
|
1520
|
+
_context15.t4 = {
|
|
1521
|
+
headers: _context15.t1,
|
|
1523
1522
|
method: "POST",
|
|
1524
|
-
path: _context15.
|
|
1525
|
-
body: _context15.
|
|
1523
|
+
path: _context15.t2,
|
|
1524
|
+
body: _context15.t3
|
|
1526
1525
|
};
|
|
1527
|
-
_context15.
|
|
1528
|
-
_context15.
|
|
1529
|
-
return _context15.t0.ResponseToJson.call(_context15.t0, _context15.t6);
|
|
1526
|
+
_context15.next = 33;
|
|
1527
|
+
return _context15.t0.Request.call(_context15.t0, _context15.t4);
|
|
1530
1528
|
|
|
1531
|
-
case
|
|
1529
|
+
case 33:
|
|
1530
|
+
rawEditResponse = _context15.sent;
|
|
1531
|
+
actualUrl = new URL(rawEditResponse.url);
|
|
1532
|
+
actualUrl.pathname = "";
|
|
1533
|
+
actualUrl.search = "";
|
|
1534
|
+
actualUrl.hash = "";
|
|
1535
|
+
nodeUrl = actualUrl.href;
|
|
1536
|
+
_context15.next = 41;
|
|
1537
|
+
return this.utils.ResponseToJson(rawEditResponse);
|
|
1538
|
+
|
|
1539
|
+
case 41:
|
|
1532
1540
|
editResponse = _context15.sent;
|
|
1533
1541
|
// Record the node used in creating this write token
|
|
1534
|
-
this.HttpClient.RecordWriteToken(editResponse.write_token);
|
|
1542
|
+
this.HttpClient.RecordWriteToken(editResponse.write_token, nodeUrl);
|
|
1535
1543
|
editResponse.writeToken = editResponse.write_token;
|
|
1536
1544
|
editResponse.objectId = editResponse.id;
|
|
1545
|
+
editResponse.nodeUrl = nodeUrl;
|
|
1537
1546
|
return _context15.abrupt("return", editResponse);
|
|
1538
1547
|
|
|
1539
|
-
case
|
|
1548
|
+
case 47:
|
|
1540
1549
|
case "end":
|
|
1541
1550
|
return _context15.stop();
|
|
1542
1551
|
}
|
|
@@ -2086,7 +2095,7 @@ exports.PublishContentVersion = /*#__PURE__*/function () {
|
|
|
2086
2095
|
events = _context21.sent;
|
|
2087
2096
|
confirmEvent = events.find(function (blockEvents) {
|
|
2088
2097
|
return blockEvents.find(function (event) {
|
|
2089
|
-
return objectHash === (event && event.
|
|
2098
|
+
return objectHash === (event && event.args && event.args.objectHash);
|
|
2090
2099
|
});
|
|
2091
2100
|
});
|
|
2092
2101
|
|
|
@@ -2639,7 +2648,7 @@ exports.UpdateContentObjectGraph = /*#__PURE__*/function () {
|
|
|
2639
2648
|
/**
|
|
2640
2649
|
* Generate a signed link token.
|
|
2641
2650
|
*
|
|
2642
|
-
* @methodGroup
|
|
2651
|
+
* @methodGroup Links
|
|
2643
2652
|
* @namedParams
|
|
2644
2653
|
* @param {string=} containerId - ID of the container object
|
|
2645
2654
|
* @param {string=} versionHash - Version hash of the object
|
|
@@ -813,7 +813,7 @@ exports.ExtractValueFromEvent = function (_ref25) {
|
|
|
813
813
|
eventName: eventName,
|
|
814
814
|
eventValue: eventValue
|
|
815
815
|
});
|
|
816
|
-
return eventLog ? eventLog.
|
|
816
|
+
return eventLog ? eventLog.args[eventValue] : undefined;
|
|
817
817
|
};
|
|
818
818
|
|
|
819
819
|
exports.FormatBlockNumbers = /*#__PURE__*/function () {
|