@eluvio/elv-client-js 4.0.85 → 4.0.87
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ElvClient-min.js +12 -13
- package/dist/ElvClient-node-min.js +13 -14
- package/dist/ElvFrameClient-min.js +9 -9
- package/dist/ElvPermissionsClient-min.js +10 -10
- package/dist/ElvWalletClient-min.js +13 -14
- package/dist/ElvWalletClient-node-min.js +13 -14
- package/dist/src/AuthorizationClient.js +5 -4
- package/dist/src/Crypto.js +2 -2
- package/dist/src/ElvClient.js +2 -2
- package/dist/src/EthClient.js +2 -2
- package/dist/src/FrameClient.js +3 -3
- package/dist/src/PermissionsClient.js +2 -2
- package/dist/src/Utils.js +2 -2
- package/dist/src/abr_profiles/abr_profile_live_to_vod.js +0 -7
- package/dist/src/client/ABRPublishing.js +2 -2
- package/dist/src/client/AccessGroups.js +2 -2
- package/dist/src/client/ContentAccess.js +757 -821
- package/dist/src/client/ContentManagement.js +6 -59
- package/dist/src/client/Contracts.js +2 -2
- package/dist/src/client/Files.js +2 -2
- package/dist/src/client/LiveConf.js +35 -144
- package/dist/src/client/LiveStream.js +529 -1054
- 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 +2 -2
- package/package.json +1 -1
- package/src/ContentObjectAudit.js +98 -0
- package/src/ElvClient.js +86 -83
- package/src/FrameClient.js +2 -1
- package/src/HttpClient.js +36 -4
- package/src/RemoteSigner.js +54 -0
- package/src/client/ContentAccess.js +17 -14
- package/src/client/ContentManagement.js +0 -1
- package/src/client/LiveConf.js +13 -13
- package/src/client/LiveStream.js +40 -12
- package/src/walletClient/index.js +40 -13
- package/src/ContentObjectVerification.js +0 -210
package/dist/src/client/NFT.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
2
2
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
3
3
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
4
|
-
function ownKeys(
|
|
5
|
-
function _objectSpread(
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
6
|
/**
|
|
7
7
|
* Methods for creating and managing NFTs
|
|
8
8
|
*
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
2
2
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
3
3
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
4
|
-
function ownKeys(
|
|
5
|
-
function _objectSpread(
|
|
4
|
+
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; }
|
|
5
|
+
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; }
|
|
6
6
|
var Utils = require("../Utils");
|
|
7
7
|
var UrlJoin = require("url-join");
|
|
8
8
|
var _require = require("./Utils"),
|
|
@@ -2,8 +2,8 @@ var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
|
2
2
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
3
3
|
var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
4
4
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
5
|
-
function ownKeys(
|
|
6
|
-
function _objectSpread(
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
var Utils = require("../Utils");
|
|
8
8
|
var UrlJoin = require("url-join");
|
|
9
9
|
var StateStorePath = function StateStorePath(_ref) {
|
|
@@ -2,8 +2,8 @@ var _regeneratorRuntime = require("@babel/runtime/regenerator");
|
|
|
2
2
|
var _asyncToGenerator = require("@babel/runtime/helpers/asyncToGenerator");
|
|
3
3
|
var _defineProperty = require("@babel/runtime/helpers/defineProperty");
|
|
4
4
|
var _slicedToArray = require("@babel/runtime/helpers/slicedToArray");
|
|
5
|
-
function ownKeys(
|
|
6
|
-
function _objectSpread(
|
|
5
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
7
|
var Utils = require("../Utils");
|
|
8
8
|
var RarityToPercentage = function RarityToPercentage(rarity) {
|
|
9
9
|
if (!rarity) {
|
|
@@ -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");
|
package/package.json
CHANGED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
const UrlJoin = require("url-join");
|
|
2
|
+
const HttpClient = require("./HttpClient");
|
|
3
|
+
const UUID = require("uuid").v4;
|
|
4
|
+
|
|
5
|
+
const {ValidateParameters} = require("./Validation");
|
|
6
|
+
|
|
7
|
+
const ContentObjectAudit = {
|
|
8
|
+
async AuditContentObject({client, libraryId, objectId, versionHash, salt, samples, live=false}) {
|
|
9
|
+
if(!salt){
|
|
10
|
+
salt = client.utils.B64(UUID());
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if(!samples) {
|
|
14
|
+
samples = [
|
|
15
|
+
Math.random() * 0.33,
|
|
16
|
+
Math.random() * 0.33 + 0.33,
|
|
17
|
+
Math.random() * 0.33 + 0.66
|
|
18
|
+
];
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Ensure only a max of 3 samples
|
|
22
|
+
samples = samples.slice(0, 3);
|
|
23
|
+
|
|
24
|
+
if(versionHash) {
|
|
25
|
+
objectId = client.utils.DecodeVersionHash(versionHash).objectId;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
if(!libraryId) {
|
|
29
|
+
libraryId = await client.ContentObjectLibraryId({objectId});
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
ValidateParameters({libraryId, objectId, versionHash});
|
|
33
|
+
|
|
34
|
+
let queryParams = {salt, samples};
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
if(live) {
|
|
38
|
+
queryParams.now = Date.now();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
// Test against the node the client is currently using, plus a batch of fresh nodes
|
|
42
|
+
const uris = [
|
|
43
|
+
client.HttpClient.uris[client.HttpClient.uriIndex],
|
|
44
|
+
...(await client.Configuration({
|
|
45
|
+
configUrl: client.configUrl,
|
|
46
|
+
clientIP: client.clientIP,
|
|
47
|
+
region: client.region
|
|
48
|
+
})).fabricURIs
|
|
49
|
+
]
|
|
50
|
+
.filter((v, i, s) => s.indexOf(v) === i);
|
|
51
|
+
|
|
52
|
+
const httpClient = new HttpClient({uris});
|
|
53
|
+
|
|
54
|
+
let path = UrlJoin("qlibs", libraryId, "q", versionHash || objectId, live ? "call/live/audit" : "audit");
|
|
55
|
+
let responses = await httpClient.RequestAll({
|
|
56
|
+
headers: await client.authClient.AuthorizationHeader({libraryId, objectId, versionHash}),
|
|
57
|
+
queryParams: queryParams,
|
|
58
|
+
method: "GET",
|
|
59
|
+
path
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
let auditHash, verified;
|
|
63
|
+
let audits = [];
|
|
64
|
+
for(const response of responses) {
|
|
65
|
+
let url = new URL(response.url);
|
|
66
|
+
let audit = { host: url.hostname };
|
|
67
|
+
|
|
68
|
+
if(!response.ok) {
|
|
69
|
+
audit.error = response;
|
|
70
|
+
audit.errorMessage = response.message || JSON.stringify(response);
|
|
71
|
+
} else {
|
|
72
|
+
let res = await client.utils.ResponseToJson(response);
|
|
73
|
+
if(auditHash === undefined) {
|
|
74
|
+
auditHash = res.audit_hash;
|
|
75
|
+
} else if(res.audit_hash !== auditHash) {
|
|
76
|
+
verified = false;
|
|
77
|
+
} else if(verified === undefined) {
|
|
78
|
+
verified = true;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
audit.audit_hash = res.audit_hash;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
audits.push(audit);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
verified = verified || false;
|
|
88
|
+
|
|
89
|
+
return {
|
|
90
|
+
verified,
|
|
91
|
+
salt,
|
|
92
|
+
samples,
|
|
93
|
+
audits,
|
|
94
|
+
};
|
|
95
|
+
},
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
module.exports = ContentObjectAudit;
|
package/src/ElvClient.js
CHANGED
|
@@ -9,8 +9,6 @@ const EthClient = require("./EthClient");
|
|
|
9
9
|
const UserProfileClient = require("./UserProfileClient");
|
|
10
10
|
const HttpClient = require("./HttpClient");
|
|
11
11
|
const RemoteSigner = require("./RemoteSigner");
|
|
12
|
-
|
|
13
|
-
// const ContentObjectVerification = require("./ContentObjectVerification");
|
|
14
12
|
const Utils = require("./Utils");
|
|
15
13
|
const Crypto = require("./Crypto");
|
|
16
14
|
const {LogMessage} = require("./LogMessage");
|
|
@@ -20,12 +18,13 @@ const Pako = require("pako");
|
|
|
20
18
|
const {
|
|
21
19
|
ValidatePresence
|
|
22
20
|
} = require("./Validation");
|
|
23
|
-
const
|
|
21
|
+
const UrlJoin = require("url-join");
|
|
24
22
|
|
|
25
23
|
const networks = {
|
|
26
24
|
"main": "https://main.net955305.contentfabric.io",
|
|
27
25
|
"demo": "https://demov3.net955210.contentfabric.io",
|
|
28
26
|
"demov3": "https://demov3.net955210.contentfabric.io",
|
|
27
|
+
"local": "http://127.0.0.1:8008/config?qspace=dev&self",
|
|
29
28
|
"test": "https://test.net955203.contentfabric.io"
|
|
30
29
|
};
|
|
31
30
|
|
|
@@ -134,7 +133,7 @@ class ElvClient {
|
|
|
134
133
|
* @param {Array<string>=} searchURIs - A list of full URIs to search service endpoints
|
|
135
134
|
* @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
|
|
136
135
|
* @param {string=} trustAuthorityId - (OAuth) The ID of the trust authority to use for OAuth authentication
|
|
137
|
-
* @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth
|
|
136
|
+
* @param {string=} staticToken - Static token that will be used for all authorization in place of normal auth. Also known as an anonymous token containing the space
|
|
138
137
|
* @param {boolean=} noCache=false - If enabled, blockchain transactions will not be cached
|
|
139
138
|
* @param {boolean=} noAuth=false - If enabled, blockchain authorization will not be performed
|
|
140
139
|
* @param {boolean=} assumeV3=false - If enabled, V3 fabric will be assumed
|
|
@@ -160,6 +159,8 @@ class ElvClient {
|
|
|
160
159
|
assumeV3=false,
|
|
161
160
|
service="default"
|
|
162
161
|
}) {
|
|
162
|
+
this.Configuration = ElvClient.Configuration;
|
|
163
|
+
|
|
163
164
|
this.utils = Utils;
|
|
164
165
|
|
|
165
166
|
this.contentSpaceId = contentSpaceId;
|
|
@@ -274,6 +275,17 @@ class ElvClient {
|
|
|
274
275
|
}
|
|
275
276
|
}
|
|
276
277
|
|
|
278
|
+
/**
|
|
279
|
+
* Return a list of valid Eluvio Content Fabric network names and their associated configuration URLs
|
|
280
|
+
*
|
|
281
|
+
* @methodGroup Miscellaneous
|
|
282
|
+
*
|
|
283
|
+
* @return {Object} - An object using network names as keys and configuration URLs as values.
|
|
284
|
+
*/
|
|
285
|
+
static Networks() {
|
|
286
|
+
return networks;
|
|
287
|
+
}
|
|
288
|
+
|
|
277
289
|
/**
|
|
278
290
|
* Create a new ElvClient for the specified network
|
|
279
291
|
*
|
|
@@ -378,6 +390,8 @@ class ElvClient {
|
|
|
378
390
|
});
|
|
379
391
|
|
|
380
392
|
client.configUrl = configUrl;
|
|
393
|
+
client.region = region;
|
|
394
|
+
client.clientIP = clientIP;
|
|
381
395
|
|
|
382
396
|
return client;
|
|
383
397
|
}
|
|
@@ -457,6 +471,8 @@ class ElvClient {
|
|
|
457
471
|
region
|
|
458
472
|
});
|
|
459
473
|
|
|
474
|
+
this.region = region;
|
|
475
|
+
|
|
460
476
|
this.authServiceURIs = authServiceURIs;
|
|
461
477
|
this.fabricURIs = fabricURIs;
|
|
462
478
|
this.ethereumURIs = ethereumURIs;
|
|
@@ -574,78 +590,65 @@ class ElvClient {
|
|
|
574
590
|
* @param {string=} matchEndpoint - Return node(s) matching the specified endpoint
|
|
575
591
|
* @param {string=} matchNodeId - Return node(s) matching the specified node ID
|
|
576
592
|
*
|
|
577
|
-
* @return {Array<Object
|
|
593
|
+
* @return {Promise<Array<Object>>} - A list of nodes in the space matching the parameters
|
|
578
594
|
*/
|
|
579
595
|
async SpaceNodes({matchEndpoint, matchNodeId}={}) {
|
|
580
|
-
let
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
methodName: "activeNodeAddresses",
|
|
594
|
-
methodArgs: [bigi],
|
|
595
|
-
formatArguments: true
|
|
596
|
-
});
|
|
597
|
-
|
|
598
|
-
let nodeId = this.utils.AddressToNodeId(addr);
|
|
599
|
-
|
|
600
|
-
if(matchNodeId && nodeId !== matchNodeId) {
|
|
601
|
-
return;
|
|
602
|
-
}
|
|
603
|
-
|
|
604
|
-
let locatorsHex = await this.CallContractMethod({
|
|
605
|
-
contractAddress: this.contentSpaceAddress,
|
|
606
|
-
methodName: "activeNodeLocators",
|
|
607
|
-
methodArgs: [bigi]
|
|
608
|
-
});
|
|
609
|
-
|
|
610
|
-
let node = {id: nodeId, endpoints: []};
|
|
596
|
+
let nodes;
|
|
597
|
+
this.SetStaticToken();
|
|
598
|
+
|
|
599
|
+
if(matchEndpoint) {
|
|
600
|
+
({nodes} = await this.utils.ResponseToJson(
|
|
601
|
+
this.HttpClient.Request({
|
|
602
|
+
path: UrlJoin("nodes"),
|
|
603
|
+
method: "GET",
|
|
604
|
+
headers: {
|
|
605
|
+
Authorization: `Bearer ${this.staticToken}`
|
|
606
|
+
}
|
|
607
|
+
})
|
|
608
|
+
));
|
|
611
609
|
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
locatorsHex.slice(2, locatorsHex.length),
|
|
616
|
-
"hex"
|
|
617
|
-
)
|
|
618
|
-
);
|
|
610
|
+
if(!nodes || !Array.isArray(nodes) || nodes.length === 0) {
|
|
611
|
+
return [];
|
|
612
|
+
}
|
|
619
613
|
|
|
614
|
+
return nodes.filter(node => {
|
|
620
615
|
let match = false;
|
|
621
616
|
|
|
622
|
-
if(
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
617
|
+
if(
|
|
618
|
+
node.services &&
|
|
619
|
+
node.services.fabric_api &&
|
|
620
|
+
node.services.fabric_api.urls
|
|
621
|
+
) {
|
|
622
|
+
const results = (node.services.fabric_api.urls || []).find(url => url.includes(matchEndpoint));
|
|
627
623
|
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
624
|
+
if(results) {
|
|
625
|
+
match = true;
|
|
626
|
+
}
|
|
627
|
+
}
|
|
631
628
|
|
|
632
|
-
|
|
633
|
-
|
|
629
|
+
if(matchNodeId && node.id === matchNodeId) {
|
|
630
|
+
match = true;
|
|
631
|
+
}
|
|
634
632
|
|
|
635
|
-
|
|
636
|
-
endpoint = endpoint + ":" + fabArray[i].port;
|
|
637
|
-
}
|
|
633
|
+
this.ClearStaticToken();
|
|
638
634
|
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
635
|
+
return match;
|
|
636
|
+
});
|
|
637
|
+
} else if(matchNodeId) {
|
|
638
|
+
this.SetStaticToken();
|
|
639
|
+
let node = await this.utils.ResponseToJson(
|
|
640
|
+
this.HttpClient.Request({
|
|
641
|
+
path: UrlJoin("nodes", matchNodeId),
|
|
642
|
+
method: "GET",
|
|
643
|
+
headers: {
|
|
644
|
+
Authorization: `Bearer ${this.staticToken}`
|
|
642
645
|
}
|
|
643
|
-
}
|
|
646
|
+
})
|
|
647
|
+
);
|
|
644
648
|
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
.filter(n => n);
|
|
649
|
+
this.ClearStaticToken();
|
|
650
|
+
return [node];
|
|
651
|
+
}
|
|
649
652
|
}
|
|
650
653
|
|
|
651
654
|
/**
|
|
@@ -991,11 +994,11 @@ class ElvClient {
|
|
|
991
994
|
* @param {string} messasge - A JSON object representing the message to sign
|
|
992
995
|
*/
|
|
993
996
|
async CreateSignedMessageJSON({
|
|
994
|
-
|
|
997
|
+
message
|
|
995
998
|
}) {
|
|
996
999
|
|
|
997
1000
|
// Only one kind of signature supported currently
|
|
998
|
-
const type = "mje_" // JSON message, EIP192 signature
|
|
1001
|
+
const type = "mje_"; // JSON message, EIP192 signature
|
|
999
1002
|
|
|
1000
1003
|
const msg = JSON.stringify(message);
|
|
1001
1004
|
const signature = await this.PersonalSign({message: msg, addEthereumPrefix: true});
|
|
@@ -1020,23 +1023,23 @@ class ElvClient {
|
|
|
1020
1023
|
}) {
|
|
1021
1024
|
const type = signedMessage.slice(0,4);
|
|
1022
1025
|
switch(type) {
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1026
|
+
case "mje_":
|
|
1027
|
+
const msgBytes = Utils.FromB58(signedMessage.slice(4));
|
|
1028
|
+
const signature = msgBytes.slice(0, 65);
|
|
1029
|
+
const msg = msgBytes.slice(65);
|
|
1030
|
+
const obj = JSON.parse(msg);
|
|
1031
|
+
|
|
1032
|
+
const prefixedMsgHash = Ethers.utils.keccak256(Buffer.from(`\x19Ethereum Signed Message:\n${msg.length}${msg}`, "utf-8"));
|
|
1033
|
+
const signerAddr = Ethers.utils.recoverAddress(prefixedMsgHash, signature);
|
|
1034
|
+
|
|
1035
|
+
return {
|
|
1036
|
+
type: type,
|
|
1037
|
+
message: obj,
|
|
1038
|
+
signerAddress: signerAddr,
|
|
1039
|
+
signature: "0x" + signature.toString("hex")
|
|
1040
|
+
};
|
|
1041
|
+
default:
|
|
1042
|
+
throw new Error(`Bad message type: ${type}`);
|
|
1040
1043
|
}
|
|
1041
1044
|
}
|
|
1042
1045
|
|
package/src/FrameClient.js
CHANGED
|
@@ -318,6 +318,8 @@ class FrameClient {
|
|
|
318
318
|
"AddContentObjectGroupPermission",
|
|
319
319
|
"AddLibraryContentType",
|
|
320
320
|
"AssetMetadata",
|
|
321
|
+
"AuditContentObject",
|
|
322
|
+
"AuditStream",
|
|
321
323
|
"AvailableDRMs",
|
|
322
324
|
"AvailableOfferings",
|
|
323
325
|
"AwaitPending",
|
|
@@ -497,7 +499,6 @@ class FrameClient {
|
|
|
497
499
|
"UploadPartChunk",
|
|
498
500
|
"UploadStatus",
|
|
499
501
|
"UseRegion",
|
|
500
|
-
"VerifyContentObject",
|
|
501
502
|
"Visibility",
|
|
502
503
|
"WriteTokenNodeUrl"
|
|
503
504
|
];
|
package/src/HttpClient.js
CHANGED
|
@@ -15,8 +15,9 @@ class HttpClient {
|
|
|
15
15
|
this.retries = Math.max(3, uris.length);
|
|
16
16
|
}
|
|
17
17
|
|
|
18
|
-
BaseURI() {
|
|
19
|
-
|
|
18
|
+
BaseURI(uriIndex) {
|
|
19
|
+
if(uriIndex === undefined) { uriIndex = this.uriIndex; }
|
|
20
|
+
return new URI(this.uris[uriIndex]);
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
static Fetch(url, params={}) {
|
|
@@ -59,9 +60,10 @@ class HttpClient {
|
|
|
59
60
|
attempts=0,
|
|
60
61
|
allowFailover=true,
|
|
61
62
|
forceFailover=false,
|
|
62
|
-
allowRetry=true
|
|
63
|
+
allowRetry=true,
|
|
64
|
+
uriIndex
|
|
63
65
|
}) {
|
|
64
|
-
let baseURI = this.BaseURI();
|
|
66
|
+
let baseURI = this.BaseURI(uriIndex);
|
|
65
67
|
|
|
66
68
|
// If URL contains a write token, it must go to the correct server and can not fail over
|
|
67
69
|
const writeTokenMatch = path.replace(/^\//, "").match(/(qlibs\/ilib[a-zA-Z0-9]+|q|qid)\/(tqw__[a-zA-Z0-9]+)/);
|
|
@@ -141,6 +143,7 @@ class HttpClient {
|
|
|
141
143
|
bodyType,
|
|
142
144
|
headers,
|
|
143
145
|
attempts: attempts + 1,
|
|
146
|
+
uriIndex,
|
|
144
147
|
forceFailover
|
|
145
148
|
});
|
|
146
149
|
}
|
|
@@ -176,6 +179,35 @@ class HttpClient {
|
|
|
176
179
|
return response;
|
|
177
180
|
}
|
|
178
181
|
|
|
182
|
+
async RequestAll({
|
|
183
|
+
method,
|
|
184
|
+
path,
|
|
185
|
+
queryParams={},
|
|
186
|
+
body,
|
|
187
|
+
bodyType="JSON",
|
|
188
|
+
headers={},
|
|
189
|
+
}) {
|
|
190
|
+
return await Promise.all(
|
|
191
|
+
Array.from(new Array(this.uris.length).keys())
|
|
192
|
+
.map(async uriIndex => {
|
|
193
|
+
try {
|
|
194
|
+
return await this.Request({
|
|
195
|
+
method,
|
|
196
|
+
path,
|
|
197
|
+
queryParams,
|
|
198
|
+
body,
|
|
199
|
+
bodyType,
|
|
200
|
+
headers,
|
|
201
|
+
allowFailover: false,
|
|
202
|
+
uriIndex
|
|
203
|
+
});
|
|
204
|
+
} catch(error) {
|
|
205
|
+
return error;
|
|
206
|
+
}
|
|
207
|
+
})
|
|
208
|
+
);
|
|
209
|
+
}
|
|
210
|
+
|
|
179
211
|
URL({path, queryParams={}}) {
|
|
180
212
|
let baseURI = this.BaseURI();
|
|
181
213
|
|
package/src/RemoteSigner.js
CHANGED
|
@@ -2,6 +2,7 @@ const Ethers = require("ethers");
|
|
|
2
2
|
const Utils = require("./Utils");
|
|
3
3
|
const HttpClient = require("./HttpClient");
|
|
4
4
|
const UrlJoin = require("url-join");
|
|
5
|
+
const UUID = require("uuid");
|
|
5
6
|
|
|
6
7
|
class RemoteSigner extends Ethers.Signer {
|
|
7
8
|
constructor({
|
|
@@ -72,6 +73,59 @@ class RemoteSigner extends Ethers.Signer {
|
|
|
72
73
|
this.signer = this.provider.getSigner(this.address);
|
|
73
74
|
}
|
|
74
75
|
|
|
76
|
+
async RetrieveCSAT({email, nonce, force=false}) {
|
|
77
|
+
nonce = nonce || Utils.B58(UUID.parse(UUID.v4()));
|
|
78
|
+
|
|
79
|
+
let response = await Utils.ResponseToJson(
|
|
80
|
+
this.HttpClient.Request({
|
|
81
|
+
method: "POST",
|
|
82
|
+
body: {
|
|
83
|
+
email,
|
|
84
|
+
nonce,
|
|
85
|
+
force
|
|
86
|
+
},
|
|
87
|
+
path: UrlJoin("as", "wlt", "sign", "csat"),
|
|
88
|
+
headers: {
|
|
89
|
+
Authorization: `Bearer ${this.authToken}`
|
|
90
|
+
},
|
|
91
|
+
})
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
response.nonce = nonce;
|
|
95
|
+
|
|
96
|
+
return response;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
async CSATStatus({accessToken}) {
|
|
100
|
+
try {
|
|
101
|
+
const response = await Utils.ResponseToJson(
|
|
102
|
+
this.HttpClient.Request({
|
|
103
|
+
method: "POST",
|
|
104
|
+
path: UrlJoin("as", "wlt", "login", "status"),
|
|
105
|
+
headers: {
|
|
106
|
+
Authorization: `Bearer ${accessToken}`
|
|
107
|
+
},
|
|
108
|
+
})
|
|
109
|
+
);
|
|
110
|
+
|
|
111
|
+
return response && response.is_active;
|
|
112
|
+
} catch(error) {
|
|
113
|
+
return !error || error.status !== 403;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
async ReleaseCSAT({accessToken}) {
|
|
118
|
+
return await Utils.ResponseToJson(
|
|
119
|
+
this.HttpClient.Request({
|
|
120
|
+
method: "POST",
|
|
121
|
+
path: UrlJoin("as", "wlt", "login", "release"),
|
|
122
|
+
headers: {
|
|
123
|
+
Authorization: `Bearer ${accessToken}`
|
|
124
|
+
},
|
|
125
|
+
})
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
75
129
|
// Overrides
|
|
76
130
|
|
|
77
131
|
getAddress() {
|
|
@@ -8,6 +8,7 @@ const UrlJoin = require("url-join");
|
|
|
8
8
|
const objectPath = require("object-path");
|
|
9
9
|
|
|
10
10
|
const HttpClient = require("../HttpClient");
|
|
11
|
+
const ContentObjectAudit = require("../ContentObjectAudit");
|
|
11
12
|
|
|
12
13
|
const {
|
|
13
14
|
ValidateLibrary,
|
|
@@ -2322,17 +2323,17 @@ exports.EmbedUrl = async function({
|
|
|
2322
2323
|
break;
|
|
2323
2324
|
case "useTicketCodes":
|
|
2324
2325
|
embedUrl.searchParams.set("ptk", "");
|
|
2325
|
-
if
|
|
2326
|
+
if(options.tenantId) {
|
|
2326
2327
|
embedUrl.searchParams.set("ten", options.tenantId);
|
|
2327
2328
|
}
|
|
2328
|
-
if
|
|
2329
|
+
if(options.ntpId) {
|
|
2329
2330
|
embedUrl.searchParams.set("ntp", options.ntpId);
|
|
2330
2331
|
}
|
|
2331
|
-
if
|
|
2332
|
+
if(options.ticketCode) {
|
|
2332
2333
|
embedUrl.searchParams.set("tk", Buffer.from(options.ticketCode).toString("base64"));
|
|
2333
2334
|
|
|
2334
2335
|
}
|
|
2335
|
-
if
|
|
2336
|
+
if(options.ticketSubject) {
|
|
2336
2337
|
embedUrl.searchParams.set("sbj", Buffer.from(options.ticketSubject).toString("base64"));
|
|
2337
2338
|
}
|
|
2338
2339
|
break;
|
|
@@ -3054,24 +3055,26 @@ exports.Collection = async function({collectionType}) {
|
|
|
3054
3055
|
/* Verification */
|
|
3055
3056
|
|
|
3056
3057
|
/**
|
|
3057
|
-
*
|
|
3058
|
+
* Audit the specified content object against several content fabric nodes
|
|
3058
3059
|
*
|
|
3059
3060
|
* @methodGroup Content Objects
|
|
3060
3061
|
* @namedParams
|
|
3061
|
-
* @param {string} libraryId - ID of the library
|
|
3062
|
-
* @param {string} objectId - ID of the object
|
|
3063
|
-
* @param {string} versionHash -
|
|
3062
|
+
* @param {string=} libraryId - ID of the library
|
|
3063
|
+
* @param {string=} objectId - ID of the object
|
|
3064
|
+
* @param {string=} versionHash - Version hash of the object -- if not specified, latest version is returned
|
|
3065
|
+
* @param {string=} salt - base64-encoded byte sequence for salting the audit hash
|
|
3066
|
+
* @param {Array<number>=} samples - list of percentages (0.0 - <1.0) used for sampling the content part list, up to 3
|
|
3064
3067
|
*
|
|
3065
|
-
* @returns {Promise<Object>} - Response describing
|
|
3068
|
+
* @returns {Promise<Object>} - Response describing audit results
|
|
3066
3069
|
*/
|
|
3067
|
-
exports.
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
return await ContentObjectVerification.VerifyContentObject({
|
|
3070
|
+
exports.AuditContentObject = async function({libraryId, objectId, versionHash, salt, samples}) {
|
|
3071
|
+
return await ContentObjectAudit.AuditContentObject({
|
|
3071
3072
|
client: this,
|
|
3072
3073
|
libraryId,
|
|
3073
3074
|
objectId,
|
|
3074
|
-
versionHash
|
|
3075
|
+
versionHash,
|
|
3076
|
+
salt,
|
|
3077
|
+
samples
|
|
3075
3078
|
});
|
|
3076
3079
|
};
|
|
3077
3080
|
|
|
@@ -1068,7 +1068,6 @@ exports.PublishContentVersion = async function({objectId, versionHash, awaitComm
|
|
|
1068
1068
|
await new Promise(resolve => setTimeout(resolve, pollingInterval));
|
|
1069
1069
|
}
|
|
1070
1070
|
} catch(error) {
|
|
1071
|
-
console.error(error);
|
|
1072
1071
|
if(error.status !== 404) {
|
|
1073
1072
|
throw error;
|
|
1074
1073
|
}
|