@eluvio/elv-client-js 4.0.90 → 4.0.92
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 +14 -15
- package/dist/ElvClient-node-min.js +13 -14
- package/dist/ElvFrameClient-min.js +10 -10
- package/dist/ElvPermissionsClient-min.js +9 -9
- package/dist/ElvWalletClient-min.js +14 -15
- package/dist/ElvWalletClient-node-min.js +13 -14
- package/dist/src/AuthorizationClient.js +12 -9
- package/dist/src/ContentObjectAudit.js +51 -39
- package/dist/src/ContentObjectVerification.js +3 -3
- package/dist/src/Crypto.js +2 -2
- package/dist/src/ElvClient.js +28 -47
- package/dist/src/ElvWallet.js +5 -7
- package/dist/src/EthClient.js +9 -8
- package/dist/src/FrameClient.js +9 -8
- package/dist/src/HttpClient.js +2 -1
- package/dist/src/Id.js +2 -1
- package/dist/src/PermissionsClient.js +19 -31
- package/dist/src/RemoteSigner.js +8 -6
- package/dist/src/UserProfileClient.js +19 -35
- package/dist/src/Utils.js +3 -2
- package/dist/src/client/ABRPublishing.js +2 -2
- package/dist/src/client/AccessGroups.js +2 -2
- package/dist/src/client/ContentAccess.js +8 -5
- package/dist/src/client/ContentManagement.js +5 -4
- package/dist/src/client/Contracts.js +2 -2
- package/dist/src/client/Files.js +2 -2
- package/dist/src/client/LiveConf.js +5 -3
- package/dist/src/client/LiveStream.js +7 -3
- package/dist/src/client/NFT.js +2 -2
- package/dist/src/walletClient/ClientMethods.js +2 -2
- package/dist/src/walletClient/Profile.js +2 -2
- package/dist/src/walletClient/Utils.js +2 -2
- package/dist/src/walletClient/index.js +14 -17
- package/package.json +1 -1
- package/src/ContentObjectAudit.js +4 -2
- package/src/client/ContentAccess.js +4 -2
- package/src/client/ContentManagement.js +3 -2
- package/src/client/LiveStream.js +4 -2
- package/testScripts/BasicObjectOperations.js +93 -0
|
@@ -5,8 +5,8 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
5
5
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
6
6
|
var _classCallCheck = require("@babel/runtime/helpers/classCallCheck");
|
|
7
7
|
var _createClass = require("@babel/runtime/helpers/createClass");
|
|
8
|
-
function ownKeys(
|
|
9
|
-
function _objectSpread(
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
10
|
var _require = require("../ElvClient"),
|
|
11
11
|
ElvClient = _require.ElvClient;
|
|
12
12
|
var Configuration = require("./Configuration");
|
|
@@ -77,7 +77,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
77
77
|
this.utils = client.utils;
|
|
78
78
|
this.ForbiddenMethods = ElvWalletClient.ForbiddenMethods;
|
|
79
79
|
}
|
|
80
|
-
|
|
80
|
+
_createClass(ElvWalletClient, [{
|
|
81
81
|
key: "Log",
|
|
82
82
|
value: function Log(message) {
|
|
83
83
|
var error = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
|
|
@@ -134,7 +134,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
134
134
|
*/
|
|
135
135
|
}, {
|
|
136
136
|
key: "PersonalSign",
|
|
137
|
-
value:
|
|
137
|
+
value: function () {
|
|
138
138
|
var _PersonalSign = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee3(_ref2) {
|
|
139
139
|
var message, parameters, url;
|
|
140
140
|
return _regeneratorRuntime.wrap(function _callee3$(_context3) {
|
|
@@ -263,7 +263,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
263
263
|
return _PersonalSign.apply(this, arguments);
|
|
264
264
|
}
|
|
265
265
|
return PersonalSign;
|
|
266
|
-
}()
|
|
266
|
+
}()
|
|
267
267
|
}, {
|
|
268
268
|
key: "LogInURL",
|
|
269
269
|
value: function () {
|
|
@@ -342,7 +342,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
342
342
|
*/
|
|
343
343
|
}, {
|
|
344
344
|
key: "LogIn",
|
|
345
|
-
value:
|
|
345
|
+
value: function () {
|
|
346
346
|
var _LogIn = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee7(_ref5) {
|
|
347
347
|
var _this = this;
|
|
348
348
|
var _ref5$method, method, provider, _ref5$mode, mode, callbackUrl, marketplaceParams, _ref5$clearLogin, clearLogin, callback, loginUrl;
|
|
@@ -461,10 +461,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
461
461
|
*
|
|
462
462
|
* @methodGroup Login
|
|
463
463
|
*/
|
|
464
|
-
)
|
|
465
464
|
}, {
|
|
466
465
|
key: "LogOut",
|
|
467
|
-
value:
|
|
466
|
+
value: function () {
|
|
468
467
|
var _LogOut = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee8() {
|
|
469
468
|
return _regeneratorRuntime.wrap(function _callee8$(_context8) {
|
|
470
469
|
while (1) switch (_context8.prev = _context8.next) {
|
|
@@ -507,7 +506,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
507
506
|
return _LogOut.apply(this, arguments);
|
|
508
507
|
}
|
|
509
508
|
return LogOut;
|
|
510
|
-
}()
|
|
509
|
+
}()
|
|
511
510
|
}, {
|
|
512
511
|
key: "TokenStatus",
|
|
513
512
|
value: function () {
|
|
@@ -547,7 +546,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
547
546
|
*/
|
|
548
547
|
}, {
|
|
549
548
|
key: "Authenticate",
|
|
550
|
-
value:
|
|
549
|
+
value: function () {
|
|
551
550
|
var _Authenticate = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee10(_ref7) {
|
|
552
551
|
var token, decodedToken;
|
|
553
552
|
return _regeneratorRuntime.wrap(function _callee10$(_context10) {
|
|
@@ -613,10 +612,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
613
612
|
* - signingToken - Identical to `authToken`, but also includes the ability to perform arbitrary signatures with the custodial wallet. This token should be protected and should not be
|
|
614
613
|
* shared with third parties.
|
|
615
614
|
*/
|
|
616
|
-
)
|
|
617
615
|
}, {
|
|
618
616
|
key: "AuthenticateOAuth",
|
|
619
|
-
value:
|
|
617
|
+
value: function () {
|
|
620
618
|
var _AuthenticateOAuth = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee11(_ref8) {
|
|
621
619
|
var idToken, tenantId, email, signerURIs, _ref8$shareEmail, shareEmail, _ref8$extraData, extraData, nonce, _ref8$createRemoteTok, createRemoteToken, _ref8$force, force, tokenDuration, fabricToken, expiresAt, tokenResponse, address, decodedToken;
|
|
622
620
|
return _regeneratorRuntime.wrap(function _callee11$(_context11) {
|
|
@@ -743,10 +741,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
743
741
|
* @returns {Promise<string>} - Returns an authorization token that can be used to initialize the client using <a href="#Authenticate">Authenticate</a>.
|
|
744
742
|
* Save this token to avoid having to reauthenticate. This token expires after 24 hours.
|
|
745
743
|
*/
|
|
746
|
-
)
|
|
747
744
|
}, {
|
|
748
745
|
key: "AuthenticateExternalWallet",
|
|
749
|
-
value:
|
|
746
|
+
value: function () {
|
|
750
747
|
var _AuthenticateExternalWallet = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee13(_ref9) {
|
|
751
748
|
var _this2 = this;
|
|
752
749
|
var address, _ref9$tokenDuration, tokenDuration, _ref9$walletName, walletName, Sign, expiresAt, fabricToken;
|
|
@@ -815,7 +812,6 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
815
812
|
*
|
|
816
813
|
* @returns {string} - The client auth token
|
|
817
814
|
*/
|
|
818
|
-
)
|
|
819
815
|
}, {
|
|
820
816
|
key: "ClientAuthToken",
|
|
821
817
|
value: function ClientAuthToken() {
|
|
@@ -1978,7 +1974,7 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
1978
1974
|
*/
|
|
1979
1975
|
}, {
|
|
1980
1976
|
key: "Initialize",
|
|
1981
|
-
value:
|
|
1977
|
+
value: function () {
|
|
1982
1978
|
var _Initialize = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee25(_ref24) {
|
|
1983
1979
|
var client, _ref24$appId, appId, _ref24$network, network, _ref24$mode, mode, localization, marketplaceParams, previewMarketplaceId, _ref24$storeAuthToken, storeAuthToken, _ref24$skipMarketplac, skipMarketplaceLoad, _ref25, tenantSlug, marketplaceSlug, marketplaceId, marketplaceHash, previewMarketplaceHash, walletClient, url, savedToken;
|
|
1984
1980
|
return _regeneratorRuntime.wrap(function _callee25$(_context25) {
|
|
@@ -2096,8 +2092,9 @@ var ElvWalletClient = /*#__PURE__*/function () {
|
|
|
2096
2092
|
return _Initialize.apply(this, arguments);
|
|
2097
2093
|
}
|
|
2098
2094
|
return Initialize;
|
|
2099
|
-
}()
|
|
2095
|
+
}()
|
|
2100
2096
|
}]);
|
|
2097
|
+
return ElvWalletClient;
|
|
2101
2098
|
}();
|
|
2102
2099
|
Object.assign(ElvWalletClient.prototype, require("./ClientMethods"));
|
|
2103
2100
|
Object.assign(ElvWalletClient.prototype, require("./Profile"));
|
package/package.json
CHANGED
|
@@ -5,7 +5,7 @@ const UUID = require("uuid").v4;
|
|
|
5
5
|
const {ValidateParameters} = require("./Validation");
|
|
6
6
|
|
|
7
7
|
const ContentObjectAudit = {
|
|
8
|
-
async AuditContentObject({client, libraryId, objectId, versionHash, salt, samples, live=false}) {
|
|
8
|
+
async AuditContentObject({client, libraryId, objectId, versionHash, salt, samples, live=false, authorizationToken}) {
|
|
9
9
|
if(!salt){
|
|
10
10
|
salt = client.utils.B64(UUID());
|
|
11
11
|
}
|
|
@@ -53,7 +53,9 @@ const ContentObjectAudit = {
|
|
|
53
53
|
|
|
54
54
|
let path = UrlJoin("qlibs", libraryId, "q", versionHash || objectId, live ? "call/live/audit" : "audit");
|
|
55
55
|
let responses = await httpClient.RequestAll({
|
|
56
|
-
headers:
|
|
56
|
+
headers: authorizationToken ?
|
|
57
|
+
{ Authorization: `Bearer ${authorizationToken}`} :
|
|
58
|
+
await client.authClient.AuthorizationHeader({libraryId, objectId, versionHash}),
|
|
57
59
|
queryParams: queryParams,
|
|
58
60
|
method: "GET",
|
|
59
61
|
path
|
|
@@ -3056,17 +3056,19 @@ exports.Collection = async function({collectionType}) {
|
|
|
3056
3056
|
* @param {string=} versionHash - Version hash of the object -- if not specified, latest version is returned
|
|
3057
3057
|
* @param {string=} salt - base64-encoded byte sequence for salting the audit hash
|
|
3058
3058
|
* @param {Array<number>=} samples - list of percentages (0.0 - <1.0) used for sampling the content part list, up to 3
|
|
3059
|
+
* @param {string=} authorizationToken - Additional authorization token for this request
|
|
3059
3060
|
*
|
|
3060
3061
|
* @returns {Promise<Object>} - Response describing audit results
|
|
3061
3062
|
*/
|
|
3062
|
-
exports.AuditContentObject = async function({libraryId, objectId, versionHash, salt, samples}) {
|
|
3063
|
+
exports.AuditContentObject = async function({libraryId, objectId, versionHash, salt, samples, authorizationToken}) {
|
|
3063
3064
|
return await ContentObjectAudit.AuditContentObject({
|
|
3064
3065
|
client: this,
|
|
3065
3066
|
libraryId,
|
|
3066
3067
|
objectId,
|
|
3067
3068
|
versionHash,
|
|
3068
3069
|
salt,
|
|
3069
|
-
samples
|
|
3070
|
+
samples,
|
|
3071
|
+
authorizationToken
|
|
3070
3072
|
});
|
|
3071
3073
|
};
|
|
3072
3074
|
|
|
@@ -1020,7 +1020,8 @@ exports.PublishContentVersion = async function({objectId, versionHash, awaitComm
|
|
|
1020
1020
|
});
|
|
1021
1021
|
|
|
1022
1022
|
const abi = await this.ContractAbi({id: objectId});
|
|
1023
|
-
const fromBlock = commit.blockNumber
|
|
1023
|
+
const fromBlock = commit.blockNumber - 30; // due to block re-org
|
|
1024
|
+
|
|
1024
1025
|
const objectHash = await this.ExtractValueFromEvent({
|
|
1025
1026
|
abi,
|
|
1026
1027
|
event: commit,
|
|
@@ -1049,6 +1050,7 @@ exports.PublishContentVersion = async function({objectId, versionHash, awaitComm
|
|
|
1049
1050
|
contractAddress: this.utils.HashToAddress(objectId),
|
|
1050
1051
|
abi,
|
|
1051
1052
|
fromBlock,
|
|
1053
|
+
topics: [ Ethers.utils.id("VersionConfirm(address,address,string)") ],
|
|
1052
1054
|
count: 1000
|
|
1053
1055
|
});
|
|
1054
1056
|
|
|
@@ -1091,7 +1093,6 @@ exports.PublishContentVersion = async function({objectId, versionHash, awaitComm
|
|
|
1091
1093
|
}
|
|
1092
1094
|
}
|
|
1093
1095
|
}
|
|
1094
|
-
|
|
1095
1096
|
};
|
|
1096
1097
|
|
|
1097
1098
|
/**
|
package/src/client/LiveStream.js
CHANGED
|
@@ -1955,16 +1955,18 @@ exports.StreamAddWatermark = async function({
|
|
|
1955
1955
|
* @param {string=} versionHash - Version hash of the live stream -- if not specified, latest version is returned
|
|
1956
1956
|
* @param {string=} salt - base64-encoded byte sequence for salting the audit hash
|
|
1957
1957
|
* @param {Array<number>=} samples - list of percentages (0.0 - <1.0) used for sampling the content part list, up to 3
|
|
1958
|
+
* @param {string=} authorizationToken - Additional authorization token for this request
|
|
1958
1959
|
*
|
|
1959
1960
|
* @returns {Promise<Object>} - Response describing audit results
|
|
1960
1961
|
*/
|
|
1961
|
-
exports.AuditStream = async function({objectId, versionHash, salt, samples}) {
|
|
1962
|
+
exports.AuditStream = async function({objectId, versionHash, salt, samples, authorizationToken}) {
|
|
1962
1963
|
return await ContentObjectAudit.AuditContentObject({
|
|
1963
1964
|
client: this,
|
|
1964
1965
|
objectId,
|
|
1965
1966
|
versionHash,
|
|
1966
1967
|
salt,
|
|
1967
1968
|
samples,
|
|
1968
|
-
live: true
|
|
1969
|
+
live: true,
|
|
1970
|
+
authorizationToken
|
|
1969
1971
|
});
|
|
1970
1972
|
};
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
/* eslint-disable no-console */
|
|
2
|
+
|
|
3
|
+
const { ElvClient } = require("../src/ElvClient");
|
|
4
|
+
|
|
5
|
+
const configUrl = "https://test.net955205.contentfabric.io/config";
|
|
6
|
+
const libraryId = "ilibE6vhm2YCR6vZCtW9mope6Dbo2Tn"; // to create and edit content
|
|
7
|
+
|
|
8
|
+
const Tool = async () => {
|
|
9
|
+
|
|
10
|
+
const client = await ElvClient.FromConfigurationUrl({configUrl});
|
|
11
|
+
|
|
12
|
+
let wallet = client.GenerateWallet();
|
|
13
|
+
let signer = wallet.AddAccount({
|
|
14
|
+
privateKey: process.env.PRIVATE_KEY
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
client.SetSigner({signer});
|
|
18
|
+
client.ToggleLogging(true);
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
try {
|
|
22
|
+
let start = new Date().getTime();
|
|
23
|
+
const {objectId, writeToken} = await client.CreateContentObject({
|
|
24
|
+
libraryId: libraryId,
|
|
25
|
+
options: {
|
|
26
|
+
meta: {commit: "Create Content-" + start.toString()}
|
|
27
|
+
}
|
|
28
|
+
});
|
|
29
|
+
let end = new Date().getTime();
|
|
30
|
+
let timeDifference = end - start;
|
|
31
|
+
console.log("content object completed after: ", timeDifference, "ms");
|
|
32
|
+
|
|
33
|
+
start = new Date().getTime();
|
|
34
|
+
const {hash} = await client.FinalizeContentObject({
|
|
35
|
+
libraryId,
|
|
36
|
+
objectId,
|
|
37
|
+
writeToken
|
|
38
|
+
});
|
|
39
|
+
end = new Date();
|
|
40
|
+
timeDifference = end - start;
|
|
41
|
+
console.log("finalize object completed after: ", timeDifference, "ms");
|
|
42
|
+
|
|
43
|
+
start = new Date().getTime();
|
|
44
|
+
const editResponse = await client.EditContentObject({
|
|
45
|
+
libraryId,
|
|
46
|
+
objectId,
|
|
47
|
+
});
|
|
48
|
+
end = new Date().getTime();
|
|
49
|
+
timeDifference = end - start;
|
|
50
|
+
console.log("edit object completed after: ", timeDifference, "ms");
|
|
51
|
+
|
|
52
|
+
const metadata = {
|
|
53
|
+
description: "edit content",
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
start = new Date().getTime();
|
|
57
|
+
await client.ReplaceMetadata({
|
|
58
|
+
libraryId,
|
|
59
|
+
objectId,
|
|
60
|
+
writeToken: editResponse.write_token,
|
|
61
|
+
metadata
|
|
62
|
+
});
|
|
63
|
+
end = new Date().getTime();
|
|
64
|
+
timeDifference = end - start;
|
|
65
|
+
console.log("replace metadata completed after: ", timeDifference, "ms");
|
|
66
|
+
|
|
67
|
+
|
|
68
|
+
start = new Date().getTime();
|
|
69
|
+
await client.FinalizeContentObject({
|
|
70
|
+
libraryId,
|
|
71
|
+
objectId,
|
|
72
|
+
writeToken: editResponse.write_token,
|
|
73
|
+
});
|
|
74
|
+
end = new Date().getTime();
|
|
75
|
+
timeDifference = end - start;
|
|
76
|
+
console.log("finalize object completed after: ", timeDifference, "ms");
|
|
77
|
+
|
|
78
|
+
console.log(`\nSuccessfully created new content version: ${hash}`);
|
|
79
|
+
} catch(error) {
|
|
80
|
+
console.error("Error creating content object:");
|
|
81
|
+
console.error(error);
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
const privateKey = process.env.PRIVATE_KEY;
|
|
86
|
+
if(!privateKey) {
|
|
87
|
+
console.error("PRIVATE_KEY environment variable must be specified");
|
|
88
|
+
return;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
Tool();
|
|
92
|
+
|
|
93
|
+
|