@eluvio/elv-client-js 4.0.100 → 4.0.102

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.
Files changed (40) hide show
  1. package/dist/ElvClient-min.js +14 -15
  2. package/dist/ElvClient-node-min.js +13 -14
  3. package/dist/ElvFrameClient-min.js +10 -10
  4. package/dist/ElvPermissionsClient-min.js +9 -9
  5. package/dist/ElvWalletClient-min.js +14 -15
  6. package/dist/ElvWalletClient-node-min.js +13 -14
  7. package/dist/src/AuthorizationClient.js +12 -9
  8. package/dist/src/ContentObjectAudit.js +3 -3
  9. package/dist/src/ContentObjectVerification.js +3 -3
  10. package/dist/src/Crypto.js +2 -2
  11. package/dist/src/ElvClient.js +74 -67
  12. package/dist/src/ElvWallet.js +5 -7
  13. package/dist/src/EthClient.js +9 -8
  14. package/dist/src/FrameClient.js +10 -9
  15. package/dist/src/HttpClient.js +2 -1
  16. package/dist/src/Id.js +2 -1
  17. package/dist/src/PermissionsClient.js +19 -31
  18. package/dist/src/RemoteSigner.js +8 -6
  19. package/dist/src/UserProfileClient.js +19 -35
  20. package/dist/src/Utils.js +3 -2
  21. package/dist/src/client/ABRPublishing.js +2 -2
  22. package/dist/src/client/AccessGroups.js +2 -2
  23. package/dist/src/client/ContentAccess.js +620 -548
  24. package/dist/src/client/ContentManagement.js +3 -3
  25. package/dist/src/client/Contracts.js +2 -2
  26. package/dist/src/client/Files.js +2 -2
  27. package/dist/src/client/LiveConf.js +9 -3
  28. package/dist/src/client/LiveStream.js +33 -39
  29. package/dist/src/client/NFT.js +2 -2
  30. package/dist/src/walletClient/ClientMethods.js +2 -2
  31. package/dist/src/walletClient/Profile.js +2 -2
  32. package/dist/src/walletClient/Utils.js +2 -2
  33. package/dist/src/walletClient/index.js +14 -17
  34. package/package.json +1 -1
  35. package/src/ElvClient.js +43 -14
  36. package/src/FrameClient.js +1 -0
  37. package/src/client/ContentAccess.js +55 -1
  38. package/src/client/LiveConf.js +5 -0
  39. package/src/client/LiveStream.js +2 -10
  40. package/testScripts/Test.js +1 -9
package/src/ElvClient.js CHANGED
@@ -70,7 +70,11 @@ class ElvClient {
70
70
  this.authClient,
71
71
  this.ethClient,
72
72
  this.HttpClient,
73
- this.userProfileClient].forEach(setDebug);
73
+ this.AuthHttpClient,
74
+ this.FileServiceHttpClient,
75
+ this.SearchHttpClient,
76
+ this.userProfileClient
77
+ ].forEach(setDebug);
74
78
 
75
79
  if(enable) {
76
80
  this.Log(
@@ -78,7 +82,8 @@ class ElvClient {
78
82
  Content Space: ${this.contentSpaceId}
79
83
  Fabric URLs: [\n\t\t${this.fabricURIs.join(", \n\t\t")}\n\t]
80
84
  Ethereum URLs: [\n\t\t${this.ethereumURIs.join(", \n\t\t")}\n\t]
81
- Auth Service URLs: [\n\t\t${this.authServiceURIs.join(", \n\t\t")}\n\t]
85
+ Auth Service URLs: [\\n\\t\\t${this.authServiceURIs.join(", \n\t\t")}\\n\\t]
86
+ File Service URLs: [\\n\\t\\t${this.fileServiceURIs.join(", \n\t\t")}\\n\\t]
82
87
  `
83
88
  );
84
89
  }
@@ -130,6 +135,7 @@ class ElvClient {
130
135
  * @param {Array<string>} fabricURIs - A list of full URIs to content fabric nodes
131
136
  * @param {Array<string>} ethereumURIs - A list of full URIs to ethereum nodes
132
137
  * @param {Array<string>} authServiceURIs - A list of full URIs to auth service endpoints
138
+ * @param {Array<string>} fileServiceURIs - A list of full URIs to file service endpoints
133
139
  * @param {Array<string>=} searchURIs - A list of full URIs to search service endpoints
134
140
  * @param {number=} ethereumContractTimeout=10 - Number of seconds to wait for contract calls
135
141
  * @param {string=} trustAuthorityId - (OAuth) The ID of the trust authority to use for OAuth authentication
@@ -150,6 +156,7 @@ class ElvClient {
150
156
  fabricURIs,
151
157
  ethereumURIs,
152
158
  authServiceURIs,
159
+ fileServiceURIs,
153
160
  searchURIs,
154
161
  ethereumContractTimeout = 10,
155
162
  trustAuthorityId,
@@ -175,6 +182,7 @@ class ElvClient {
175
182
 
176
183
  this.fabricURIs = fabricURIs;
177
184
  this.authServiceURIs = authServiceURIs;
185
+ this.fileServiceURIs = fileServiceURIs || fabricURIs;
178
186
  this.ethereumURIs = ethereumURIs;
179
187
  this.searchURIs = searchURIs;
180
188
  this.ethereumContractTimeout = ethereumContractTimeout;
@@ -249,6 +257,11 @@ class ElvClient {
249
257
  authServiceURIs = authServiceURIs.filter(filterHTTPS);
250
258
  }
251
259
 
260
+ let fileServiceURIs = fabricInfo.network.services.file_service || fabricURIs;
261
+ if(fileServiceURIs.find(filterHTTPS)) {
262
+ fileServiceURIs = fileServiceURIs.filter(filterHTTPS);
263
+ }
264
+
252
265
  const searchURIs = fabricInfo.network.services.search || [];
253
266
 
254
267
  const fabricVersion = Math.max(...(fabricInfo.network.api_versions || [2]));
@@ -261,6 +274,7 @@ class ElvClient {
261
274
  fabricURIs,
262
275
  ethereumURIs,
263
276
  authServiceURIs,
277
+ fileServiceURIs,
264
278
  kmsURIs: kmsUrls,
265
279
  searchURIs,
266
280
  fabricVersion
@@ -364,6 +378,7 @@ class ElvClient {
364
378
  fabricURIs,
365
379
  ethereumURIs,
366
380
  authServiceURIs,
381
+ fileServiceURIs,
367
382
  searchURIs,
368
383
  fabricVersion
369
384
  } = await ElvClient.Configuration({
@@ -380,6 +395,7 @@ class ElvClient {
380
395
  fabricURIs,
381
396
  ethereumURIs,
382
397
  authServiceURIs,
398
+ fileServiceURIs,
383
399
  searchURIs,
384
400
  ethereumContractTimeout,
385
401
  trustAuthorityId,
@@ -410,6 +426,7 @@ class ElvClient {
410
426
  const uris = this.service === "search" ? this.searchURIs : this.fabricURIs;
411
427
  this.HttpClient = new HttpClient({uris, debug: this.debug});
412
428
  this.AuthHttpClient = new HttpClient({uris: this.authServiceURIs, debug: this.debug});
429
+ this.FileServiceHttpClient = new HttpClient({uris: this.fileServiceURIs, debug: this.debug});
413
430
  this.SearchHttpClient = new HttpClient({uris: this.searchURIs || [], debug: this.debug});
414
431
  this.ethClient = new EthClient({client: this, uris: this.ethereumURIs, networkId: this.networkId, debug: this.debug, timeout: this.ethereumContractTimeout});
415
432
 
@@ -466,27 +483,26 @@ class ElvClient {
466
483
  throw Error("Unable to change region: Configuration URL not set");
467
484
  }
468
485
 
469
- const {fabricURIs, ethereumURIs, authServiceURIs, searchURIs} = await ElvClient.Configuration({
486
+ const {fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs} = await ElvClient.Configuration({
470
487
  configUrl: this.configUrl,
471
488
  region
472
489
  });
473
490
 
474
491
  this.region = region;
475
492
 
476
- this.authServiceURIs = authServiceURIs;
477
- this.fabricURIs = fabricURIs;
478
- this.ethereumURIs = ethereumURIs;
479
- this.searchURIs = searchURIs;
480
-
481
- this.HttpClient.uris = fabricURIs;
482
- this.HttpClient.uriIndex = 0;
483
-
484
- this.ethClient.ethereumURIs = ethereumURIs;
485
- this.ethClient.ethereumURIIndex = 0;
493
+ this.SetNodes({
494
+ fabricURIs,
495
+ ethereumURIs,
496
+ authServiceURIs,
497
+ fileServiceURIs,
498
+ searchURIs
499
+ });
486
500
 
487
501
  return {
488
502
  fabricURIs,
489
503
  ethereumURIs,
504
+ fileServiceURIs,
505
+ authServiceURIs,
490
506
  searchURIs
491
507
  };
492
508
  }
@@ -541,6 +557,7 @@ class ElvClient {
541
557
  fabricURIs: this.fabricURIs,
542
558
  ethereumURIs: this.ethereumURIs,
543
559
  authServiceURIs: this.authServiceURIs,
560
+ fileServiceURIs: this.fileServiceURIs,
544
561
  searchURIs: this.searchURIs
545
562
  };
546
563
  }
@@ -552,11 +569,12 @@ class ElvClient {
552
569
  * @param {Array<string>=} fabricURIs - A list of URLs for the fabric, in preference order
553
570
  * @param {Array<string>=} ethereumURIs - A list of URLs for the blockchain, in preference order
554
571
  * @param {Array<string>=} authServiceURIs - A list of URLs for the auth service, in preference order
572
+ * @param {Array<string>=} fileServiceURIs - A list of URLs for file service jobs, in preference order
555
573
  * @param {Array<string>=} searchURIs - A list of URLs for the search nodes, in preference order
556
574
  *
557
575
  * @methodGroup Nodes
558
576
  */
559
- SetNodes({fabricURIs, ethereumURIs, authServiceURIs, searchURIs}) {
577
+ SetNodes({fabricURIs, ethereumURIs, authServiceURIs, fileServiceURIs, searchURIs}) {
560
578
  if(fabricURIs) {
561
579
  this.fabricURIs = fabricURIs;
562
580
 
@@ -573,12 +591,23 @@ class ElvClient {
573
591
 
574
592
  if(authServiceURIs) {
575
593
  this.authServiceURIs = authServiceURIs;
594
+
576
595
  this.AuthHttpClient.uris = authServiceURIs;
577
596
  this.AuthHttpClient.uriIndex = 0;
578
597
  }
579
598
 
599
+ if(fileServiceURIs) {
600
+ this.fileServiceURIs = fileServiceURIs;
601
+
602
+ this.FileServiceHttpClient.uris = fileServiceURIs;
603
+ this.FileServiceHttpClient.uriIndex = 0;
604
+ }
605
+
580
606
  if(searchURIs) {
581
607
  this.searchURIs = searchURIs;
608
+
609
+ this.SearchHttpClient.uris = searchURIs;
610
+ this.SearchHttpClient.uriIndex = 0;
582
611
  }
583
612
  }
584
613
 
@@ -430,6 +430,7 @@ class FrameClient {
430
430
  "LRODraftInfo",
431
431
  "LROStatus",
432
432
  "MakeAuthServiceRequest",
433
+ "MakeFileServiceRequest",
433
434
  "MergeContractMetadata",
434
435
  "MergeMetadata",
435
436
  "MetadataAuth",
@@ -1900,6 +1900,58 @@ exports.GlobalUrl = async function({
1900
1900
  return url.toString();
1901
1901
  };
1902
1902
 
1903
+ exports.MakeFileServiceRequest = async function({
1904
+ libraryId,
1905
+ objectId,
1906
+ versionHash,
1907
+ writeToken,
1908
+ path,
1909
+ method="GET",
1910
+ queryParams={},
1911
+ body,
1912
+ bodyType="JSON",
1913
+ format="json",
1914
+ headers={},
1915
+ authorizationToken
1916
+ }) {
1917
+ if(versionHash) { objectId = this.utils.DecodeVersionHash(versionHash).objectId; }
1918
+
1919
+ if(objectId && !libraryId) {
1920
+ libraryId = await this.ContentObjectLibraryId({objectId});
1921
+ }
1922
+
1923
+ ValidateParameters({libraryId, objectId, versionHash});
1924
+
1925
+ let queryPath = UrlJoin("q", writeToken || versionHash || objectId, path);
1926
+
1927
+ if(libraryId && !versionHash) {
1928
+ queryPath = UrlJoin("qlibs", libraryId, queryPath);
1929
+ }
1930
+
1931
+ let authorization = [
1932
+ authorizationToken,
1933
+ await this.authClient.AuthorizationToken({objectId})
1934
+ ]
1935
+ .flat()
1936
+ .filter(token => token);
1937
+
1938
+ headers.Authorization = headers.Authorization || authorization.map(token => `Bearer ${token}`);
1939
+
1940
+ return this.utils.ResponseToFormat(
1941
+ format,
1942
+ await this.FileServiceHttpClient.Request({
1943
+ body,
1944
+ bodyType,
1945
+ headers,
1946
+ method,
1947
+ path: queryPath,
1948
+ queryParams
1949
+ }),
1950
+ this.FileServiceHttpClient.debug,
1951
+ this.FileServiceHttpClient.Log.bind(this.FileServiceHttpClient)
1952
+ );
1953
+ };
1954
+
1903
1955
 
1904
1956
  /**
1905
1957
  * Call the specified bitcode method on the specified object
@@ -1939,7 +1991,7 @@ exports.CallBitcodeMethod = async function({
1939
1991
 
1940
1992
  let path = UrlJoin("q", writeToken || versionHash || objectId, "call", method);
1941
1993
 
1942
- if(libraryId) {
1994
+ if(libraryId && !versionHash) {
1943
1995
  path = UrlJoin("qlibs", libraryId, path);
1944
1996
  }
1945
1997
 
@@ -2153,6 +2205,8 @@ exports.FabricUrl = async function({
2153
2205
  httpClient = this.SearchHttpClient;
2154
2206
  } else if(service === "auth") {
2155
2207
  httpClient = this.AuthHttpClient;
2208
+ } else if(service === "files") {
2209
+ httpClient = this.FileServiceHttpClient;
2156
2210
  }
2157
2211
 
2158
2212
  return httpClient.URL({
@@ -74,6 +74,7 @@ const LiveconfTemplate = {
74
74
  part_ttl: 3600,
75
75
  playout_type: "live",
76
76
  source_timescale: null,
77
+ reconnect_timeout: 600,
77
78
  xc_params: {
78
79
  audio_bitrate: 384000,
79
80
  audio_index: [
@@ -459,6 +460,10 @@ class LiveConf {
459
460
  conf.live_recording.recording_config.recording_params.xc_params.connection_timeout = customSettings.connection_timeout;
460
461
  }
461
462
 
463
+ if(customSettings.reconnect_timeout) {
464
+ conf.live_recording.recording_config.recording_params.reconnect_timeout = customSettings.reconnect_timeout;
465
+ }
466
+
462
467
  // Fill in specifics for protocol
463
468
  switch(this.probeKind()) {
464
469
  case "udp":
@@ -1357,7 +1357,7 @@ exports.StreamConfig = async function({name, customSettings={}, probeMetadata})
1357
1357
  const hostName = new URL(parsedName).hostname;
1358
1358
  const streamUrl = new URL(userConfig.url);
1359
1359
 
1360
- console.log("Retrieving nodes - matching", hostName);
1360
+ this.Log(`Retrieving nodes - matching: ${hostName}`);
1361
1361
  let nodes = await this.SpaceNodes({matchEndpoint: hostName});
1362
1362
  if(nodes.length < 1) {
1363
1363
  status.error = "No node matching stream URL " + streamUrl.href;
@@ -1375,12 +1375,7 @@ exports.StreamConfig = async function({name, customSettings={}, probeMetadata})
1375
1375
 
1376
1376
  // Probe the stream
1377
1377
  probe = {};
1378
- const controller = new AbortController();
1379
- const timeoutId = setTimeout(() => {
1380
- controller.abort();
1381
- }, 60 * 1000); // milliseconds
1382
1378
  try {
1383
-
1384
1379
  let probeUrl = await this.Rep({
1385
1380
  libraryId,
1386
1381
  objectId,
@@ -1393,13 +1388,10 @@ exports.StreamConfig = async function({name, customSettings={}, probeMetadata})
1393
1388
  "filename": streamUrl.href,
1394
1389
  "listen": true
1395
1390
  }),
1396
- method: "POST",
1397
- signal: controller.signal
1391
+ method: "POST"
1398
1392
  })
1399
1393
  );
1400
1394
 
1401
- if(probe) { clearTimeout(timeoutId); }
1402
-
1403
1395
  if(probe.errors) {
1404
1396
  throw probe.errors[0];
1405
1397
  }
@@ -9,9 +9,6 @@ const Test = async () => {
9
9
  const client = await ElvClient.FromNetworkName({
10
10
  networkName: "demo"
11
11
  });
12
- // const client = await ElvClient.FromConfigurationUrl({
13
- // configUrl: "http://localhost:8008/config?qspace=demov3&self"
14
- // });
15
12
 
16
13
  const wallet = client.GenerateWallet();
17
14
  const signer = wallet.AddAccount({
@@ -20,12 +17,7 @@ const Test = async () => {
20
17
 
21
18
  client.SetSigner({signer});
22
19
 
23
- const versionHash = "";
24
-
25
- const url = await client.FabricUrl({
26
- versionHash
27
- });
28
- console.log("url", url)
20
+ console.log(await client.ContentLibraries());
29
21
  } catch(error) {
30
22
  console.error(error);
31
23
  console.error(JSON.stringify(error, null, 2));