@eluvio/elv-client-js 4.0.146 → 4.1.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.
Files changed (48) hide show
  1. package/dist/ElvClient-min.js +2 -68
  2. package/dist/ElvClient-min.js.LICENSE.txt +72 -0
  3. package/dist/ElvClient-node-min.js +2 -67
  4. package/dist/ElvClient-node-min.js.LICENSE.txt +72 -0
  5. package/dist/ElvFrameClient-min.js +2 -60
  6. package/dist/ElvFrameClient-min.js.LICENSE.txt +72 -0
  7. package/dist/ElvPermissionsClient-min.js +2 -60
  8. package/dist/ElvPermissionsClient-min.js.LICENSE.txt +72 -0
  9. package/dist/ElvWalletClient-min.js +2 -68
  10. package/dist/ElvWalletClient-min.js.LICENSE.txt +72 -0
  11. package/dist/ElvWalletClient-node-min.js +2 -67
  12. package/dist/ElvWalletClient-node-min.js.LICENSE.txt +72 -0
  13. package/dist/src/AuthorizationClient.js +704 -703
  14. package/dist/src/ContentObjectAudit.js +56 -56
  15. package/dist/src/Crypto.js +85 -86
  16. package/dist/src/ElvClient.js +483 -471
  17. package/dist/src/ElvWallet.js +23 -23
  18. package/dist/src/EthClient.js +308 -307
  19. package/dist/src/FrameClient.js +62 -62
  20. package/dist/src/HttpClient.js +59 -58
  21. package/dist/src/PermissionsClient.js +470 -470
  22. package/dist/src/RemoteSigner.js +77 -76
  23. package/dist/src/UserProfileClient.js +357 -354
  24. package/dist/src/Utils.js +65 -64
  25. package/dist/src/Validation.js +10 -10
  26. package/dist/src/client/ABRPublishing.js +237 -237
  27. package/dist/src/client/AccessGroups.js +477 -474
  28. package/dist/src/client/ContentAccess.js +1749 -1802
  29. package/dist/src/client/ContentManagement.js +871 -871
  30. package/dist/src/client/Contracts.js +575 -578
  31. package/dist/src/client/Files.js +700 -684
  32. package/dist/src/client/LiveStream.js +659 -650
  33. package/dist/src/client/NFT.js +14 -14
  34. package/dist/src/client/NTP.js +84 -84
  35. package/dist/src/client/Shares.js +49 -49
  36. package/dist/src/walletClient/ClientMethods.js +977 -951
  37. package/dist/src/walletClient/Notifications.js +14 -14
  38. package/dist/src/walletClient/Profile.js +66 -66
  39. package/dist/src/walletClient/Utils.js +15 -15
  40. package/dist/src/walletClient/index.js +557 -550
  41. package/package.json +17 -16
  42. package/src/ElvClient.js +1 -0
  43. package/src/FrameClient.js +12 -0
  44. package/src/client/AccessGroups.js +1 -1
  45. package/src/client/ContentAccess.js +44 -71
  46. package/testScripts/Test.js +5 -1
  47. package/webpack.config.js +10 -13
  48. package/dist/src/ContentObjectVerification.js +0 -281
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.146",
3
+ "version": "4.1.0",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -14,13 +14,13 @@
14
14
  "build-wallet-client-docs": "./node_modules/.bin/jsdoc --configure ./.jsdoc-mc.json --readme ./src/walletClient/README.md",
15
15
  "build-dist": "node ./node_modules/@babel/cli/bin/babel.js --source-type=unambiguous --presets=@babel/preset-env --plugins @babel/plugin-transform-runtime src --out-dir dist/src",
16
16
  "build-contracts": "node build/BuildContracts.js",
17
- "build-frame-client": "webpack -p --progress --entry ./dist/src/FrameClient.js --output-filename ElvFrameClient-min.js --devtool none --optimize-minimize && mv test/bundle-analysis/index.html test/bundle-analysis/frame-client.html",
18
- "build-permissions-client": "webpack -p --progress --entry ./dist/src/PermissionsClient.js --output-filename ElvPermissionsClient-min.js --devtool none --optimize-minimize && mv test/bundle-analysis/index.html test/bundle-analysis/permissions-client.html",
19
- "build-wallet-client-web": "webpack -p --progress --mode production --entry ./dist/src/walletClient/index.js --target web --output-filename ElvWalletClient-min.js --devtool none --optimize-minimize && mv test/bundle-analysis/index.html test/bundle-analysis/wallet-client.html",
20
- "build-wallet-client-node": "webpack -p --progress --mode production --entry ./dist/src/walletClient/index.js --target node --output-filename ElvWalletClient-node-min.js --devtool none --optimize-minimize && mv test/bundle-analysis/index.html test/bundle-analysis/wallet-client.html",
17
+ "build-frame-client": "webpack --mode=production --progress --entry ./dist/src/FrameClient.js --output-filename ElvFrameClient-min.js && mv test/bundle-analysis/index.html test/bundle-analysis/frame-client.html",
18
+ "build-permissions-client": "webpack --mode=production --progress --entry ./dist/src/PermissionsClient.js --output-filename ElvPermissionsClient-min.js && mv test/bundle-analysis/index.html test/bundle-analysis/permissions-client.html",
19
+ "build-wallet-client-web": "webpack --mode=production --progress --mode production --entry ./dist/src/walletClient/index.js --target web --output-filename ElvWalletClient-min.js && mv test/bundle-analysis/index.html test/bundle-analysis/wallet-client.html",
20
+ "build-wallet-client-node": "webpack --mode=production --progress --mode production --entry ./dist/src/walletClient/index.js --target node --output-filename ElvWalletClient-node-min.js && mv test/bundle-analysis/index.html test/bundle-analysis/wallet-client.html",
21
21
  "build-prod": "npm run build-web && npm run build-node",
22
- "build-web": "webpack --progress --mode production --target web --output-filename ElvClient-min.js --devtool none && mv test/bundle-analysis/index.html test/bundle-analysis/web.html",
23
- "build-node": "webpack --progress --mode production --target node --output-filename ElvClient-node-min.js --devtool none && mv test/bundle-analysis/index.html test/bundle-analysis/node.html",
22
+ "build-web": "webpack --progress --mode production --target web --output-filename ElvClient-min.js && mv test/bundle-analysis/index.html test/bundle-analysis/web.html",
23
+ "build-node": "webpack --progress --mode production --target node --output-filename ElvClient-node-min.js && mv test/bundle-analysis/index.html test/bundle-analysis/node.html",
24
24
  "build-dev": "npm run build-web-dev && npm run build-node-dev",
25
25
  "build-web-dev": "webpack --progress --target web --output-filename ElvClient-min-dev.js",
26
26
  "build-node-dev": "webpack --progress --target node --output-filename ElvClient-node-min-dev.js",
@@ -66,6 +66,7 @@
66
66
  "columnify": "^1.5.4",
67
67
  "country-codes-list": "^1.6.8",
68
68
  "crocks": "^0.12.4",
69
+ "crypto-browserify": "^3.12.1",
69
70
  "deep-equal": "^1.0.1",
70
71
  "ellipsize": "^0.1.0",
71
72
  "ethers": "^5.7.2",
@@ -90,7 +91,6 @@
90
91
  "shell-escape": "^0.2.0",
91
92
  "sjcl": "^1.0.8",
92
93
  "typedarray": "0.0.6",
93
- "unorm": "^1.5.0",
94
94
  "urijs": "^1.19.10",
95
95
  "url-join": "^4.0.0",
96
96
  "uuid": "^8.3.2",
@@ -98,27 +98,28 @@
98
98
  "yargs": "^16.2.0"
99
99
  },
100
100
  "devDependencies": {
101
- "@babel/cli": "^7.4.4",
101
+ "@babel/cli": "^7.28.0",
102
102
  "@babel/plugin-transform-runtime": "^7.8.3",
103
103
  "@babel/preset-env": "^7.4.5",
104
+ "@jsdoc/salty": "^0.2.9",
104
105
  "chai": "^4.2.0",
105
106
  "chai-as-promised": "^7.1.1",
106
107
  "chrono-node": "^2.3.1",
107
108
  "colors": "^1.4.0",
108
109
  "copy-webpack-plugin": "^6.0.2",
109
- "eslint": "^5.15.0",
110
+ "eslint": "^9.32.0",
110
111
  "eslint-plugin-html": "^5.0.0",
111
112
  "jsdoc": "^4.0.0",
112
- "mocha": "^8.2.1",
113
+ "jsdom": "^26.1.0",
113
114
  "moment": "^2.27.0",
114
115
  "raw-loader": "^0.5.1",
115
116
  "shell-quote": "^1.7.2",
116
117
  "showdown": "^1.9.1",
117
118
  "simple-mock": "^0.8.0",
118
- "taffydb": "^2.7.3",
119
- "webpack": "^4.20.2",
120
- "webpack-bundle-analyzer": "^3.3.2",
121
- "webpack-cli": "^3.1.2",
122
- "window": "^4.2.7"
119
+ "stream-browserify": "^3.0.0",
120
+ "vm-browserify": "^1.1.2",
121
+ "webpack": "^5.101.0",
122
+ "webpack-bundle-analyzer": "^4.10.2",
123
+ "webpack-cli": "^6.0.1"
123
124
  }
124
125
  }
package/src/ElvClient.js CHANGED
@@ -422,6 +422,7 @@ class ElvClient {
422
422
  this.contentTypes = {};
423
423
  this.encryptionConks = {};
424
424
  this.stateChannelAccess = {};
425
+ this.objectInfo = {};
425
426
  this.objectTenantIds = {};
426
427
  this.objectLibraryIds = {};
427
428
  this.objectImageUrls = {};
@@ -377,10 +377,12 @@ class FrameClient {
377
377
  "CreatePart",
378
378
  "CreateProductionMaster",
379
379
  "CreateShare",
380
+ "CreateSignedMessageJSON",
380
381
  "CreateSignedToken",
381
382
  "CreateStaticToken",
382
383
  "CurrentAccountAddress",
383
384
  "CustomContractAddress",
385
+ "DecodeSignedMessageJSON",
384
386
  "Decrypt",
385
387
  "DecryptECIES",
386
388
  "DefaultKMSAddress",
@@ -444,6 +446,7 @@ class FrameClient {
444
446
  "NodeId",
445
447
  "Nodes",
446
448
  "NTPInstance",
449
+ "ObjectCleanup",
447
450
  "Permission",
448
451
  "PlayoutOptions",
449
452
  "PlayoutPathResolution",
@@ -465,6 +468,7 @@ class FrameClient {
465
468
  "ReplaceMetadata",
466
469
  "Request",
467
470
  "ResetRegion",
471
+ "ResetTenantId",
468
472
  "RevokeShare",
469
473
  "SendFunds",
470
474
  "SetAccessCharge",
@@ -480,8 +484,11 @@ class FrameClient {
480
484
  "SetPolicyAuthorization",
481
485
  "SetSignerFromOauthToken",
482
486
  "SetStaticToken",
487
+ "SetTenantContractId",
488
+ "SetTenantId",
483
489
  "SetVisibility",
484
490
  "SetPermission",
491
+ "ShareInfo",
485
492
  "Shares",
486
493
  "SpaceNodes",
487
494
  "StartABRMezzanineJobs",
@@ -493,10 +500,13 @@ class FrameClient {
493
500
  "StreamInsertion",
494
501
  "StreamListUrls",
495
502
  "StreamRemoveWatermark",
503
+ "StreamSetOfferingAndDRM",
496
504
  "StreamStatus",
497
505
  "StreamStartOrStopOrReset",
498
506
  "StreamStopSession",
499
507
  "SuspendNTPInstance",
508
+ "TenantContractId",
509
+ "TenantId",
500
510
  "UnlinkAccessGroupFromOauth",
501
511
  "UpdateContentObjectGraph",
502
512
  "UpdateNTPInstance",
@@ -523,6 +533,8 @@ class FrameClient {
523
533
  "MergeUserMetadata",
524
534
  "PublicUserMetadata",
525
535
  "ReplaceUserMetadata",
536
+ "ResetTenantId",
537
+ "SetTenantContractId",
526
538
  "TenantContractId",
527
539
  "TenantId",
528
540
  "UserMetadata",
@@ -941,4 +941,4 @@ exports.UnlinkAccessGroupFromOauth = async function({groupAddress}) {
941
941
  methodName: "setOAuthEnabled",
942
942
  methodArgs: [false]
943
943
  });
944
- };
944
+ };
@@ -573,18 +573,17 @@ exports.ContentObjects = async function({libraryId, filterOptions={}}) {
573
573
  };
574
574
 
575
575
  /**
576
- * Get a specific content object in the library
576
+ * Get info about a specific content object
577
577
  *
578
578
  * @methodGroup Content Objects
579
579
  * @namedParams
580
- * @param {string=} libraryId - ID of the library
581
580
  * @param {string=} objectId - ID of the object
582
581
  * @param {string=} versionHash - Version hash of the object -- if not specified, latest version is returned
583
582
  * @param {string=} writeToken - Write token for an object draft -- if supplied, versionHash will be ignored
584
583
  *
585
584
  * @returns {Promise<Object>} - Description of content object
586
585
  */
587
- exports.ContentObject = async function({objectId, versionHash, writeToken}) {
586
+ exports.ContentObject = async function({objectId, versionHash, writeToken, noCache}) {
588
587
  this.Log(`Retrieving content object: ${writeToken || versionHash || objectId}`);
589
588
 
590
589
  if(writeToken) {
@@ -595,13 +594,26 @@ exports.ContentObject = async function({objectId, versionHash, writeToken}) {
595
594
 
596
595
  ValidateObject(objectId);
597
596
 
598
- let path = UrlJoin("q", writeToken || versionHash || objectId);
597
+ const id = writeToken || versionHash || objectId;
598
+ if(noCache || !this.objectInfo[id] || Date.now() - this.objectInfo[id].retrievedAt > 30000) {
599
+ let path = UrlJoin("q", id);
600
+ this.objectInfo[id] = {
601
+ retrievedAt: Date.now(),
602
+ info: (
603
+ await this.HttpClient.RequestJsonBody({
604
+ headers: await this.authClient.AuthorizationHeader({objectId, versionHash}),
605
+ method: "GET",
606
+ path: path,
607
+ queryParams: {
608
+ details: true,
609
+ profile: true
610
+ }
611
+ })
612
+ )
613
+ };
614
+ }
599
615
 
600
- return await this.HttpClient.RequestJsonBody({
601
- headers: await this.authClient.AuthorizationHeader({objectId, versionHash}),
602
- method: "GET",
603
- path: path
604
- });
616
+ return this.objectInfo[id].info;
605
617
  };
606
618
 
607
619
  /**
@@ -609,22 +621,21 @@ exports.ContentObject = async function({objectId, versionHash, writeToken}) {
609
621
  *
610
622
  * @methodGroup Content Objects
611
623
  * @namedParams
612
- * @param {string} libraryId
624
+ * @param {string=} objectId - ID of the object
625
+ * @param {string=} versionHash - Version hash of the object
613
626
  *
614
627
  * @returns {Promise<string>} - The account address of the owner
615
628
  */
616
- exports.ContentObjectOwner = async function({objectId}) {
617
- ValidateObject(objectId);
629
+ exports.ContentObjectOwner = async function({objectId, versionHash}) {
630
+ versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
631
+
632
+ if(versionHash) {
633
+ objectId = this.utils.DecodeVersionHash(versionHash).objectId;
634
+ }
618
635
 
619
636
  this.Log(`Retrieving content object owner: ${objectId}`);
620
637
 
621
- return this.utils.FormatAddress(
622
- await this.ethClient.CallContractMethod({
623
- contractAddress: this.utils.HashToAddress(objectId),
624
- methodName: "owner",
625
- methodArgs: []
626
- })
627
- );
638
+ return (await this.ContentObject({objectId, versionHash})).content_profile.owner;
628
639
  };
629
640
 
630
641
  /**
@@ -641,16 +652,18 @@ exports.ContentObjectOwner = async function({objectId}) {
641
652
  exports.ContentObjectTenantId = async function({objectId, versionHash}) {
642
653
  versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
643
654
 
644
- if(versionHash) { objectId = this.utils.DecodeVersionHash(versionHash).objectId; }
655
+ if(versionHash) {
656
+ objectId = this.utils.DecodeVersionHash(versionHash).objectId;
657
+ }
645
658
 
659
+ // Cache results because they will never change
646
660
  if(!this.objectTenantIds[objectId]) {
647
- this.objectTenantIds[objectId] = await this.authClient.MakeElvMasterCall({
648
- methodName: "elv_getTenantById",
649
- params: [
650
- this.contentSpaceId,
651
- objectId
652
- ]
653
- });
661
+ try {
662
+ this.objectTenantIds[objectId] = (await this.ContentObject({objectId, versionHash})).content_profile.tenant_id;
663
+ } catch(error) {
664
+ error.message = `Unable to determine tenant ID for ${versionHash || objectId}`;
665
+ throw error;
666
+ }
654
667
  }
655
668
 
656
669
  return this.objectTenantIds[objectId];
@@ -668,6 +681,8 @@ exports.ContentObjectTenantId = async function({objectId, versionHash}) {
668
681
  * @returns {Promise<string>} - Library ID of the object
669
682
  */
670
683
  exports.ContentObjectLibraryId = async function({objectId, versionHash}) {
684
+ versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
685
+
671
686
  if(versionHash) {
672
687
  objectId = this.utils.DecodeVersionHash(versionHash).objectId;
673
688
  }
@@ -677,7 +692,7 @@ exports.ContentObjectLibraryId = async function({objectId, versionHash}) {
677
692
  try {
678
693
  this.objectLibraryIds[objectId] = (await this.ContentObject({objectId, versionHash})).qlib_id;
679
694
  } catch(error) {
680
- error.message = `Unable to determine latest library for ${versionHash || objectId}`;
695
+ error.message = `Unable to determine library ID for ${versionHash || objectId}`;
681
696
  throw error;
682
697
  }
683
698
  }
@@ -685,48 +700,6 @@ exports.ContentObjectLibraryId = async function({objectId, versionHash}) {
685
700
  return this.objectLibraryIds[objectId];
686
701
  };
687
702
 
688
- exports.ContentObjectLibraryId2 = async function({objectId, versionHash}) {
689
- versionHash ? ValidateVersion(versionHash) : ValidateObject(objectId);
690
-
691
- if(versionHash) { objectId = this.utils.DecodeVersionHash(versionHash).objectId; }
692
-
693
- switch(await this.authClient.AccessType(objectId)) {
694
- case this.authClient.ACCESS_TYPES.LIBRARY:
695
- return this.utils.AddressToLibraryId(this.utils.HashToAddress(objectId));
696
- case this.authClient.ACCESS_TYPES.OBJECT:
697
- if(!this.objectLibraryIds[objectId]) {
698
- this.Log(`Retrieving content object library ID: ${objectId || versionHash}`);
699
-
700
- this.objectLibraryIds[objectId] = new Promise(async (resolve, reject) => {
701
- try {
702
- resolve(
703
- this.utils.AddressToLibraryId(
704
- await this.CallContractMethod({
705
- contractAddress: this.utils.HashToAddress(objectId),
706
- methodName: "libraryAddress"
707
- })
708
- )
709
- );
710
- } catch(error) {
711
- reject(error);
712
- }
713
- });
714
- }
715
-
716
- try {
717
- return await this.objectLibraryIds[objectId];
718
- } catch(error) {
719
- delete this.objectLibraryIds[objectId];
720
-
721
- throw error;
722
- }
723
- case this.authClient.ACCESS_TYPES.OTHER:
724
- throw Error(`Unable to retrieve library ID for ${versionHash || objectId}: Unknown type. (wrong network or deleted object?)`);
725
- default:
726
- return this.contentSpaceLibraryId;
727
- }
728
- };
729
-
730
703
  exports.ProduceMetadataLinks = async function({
731
704
  libraryId,
732
705
  objectId,
@@ -1103,7 +1076,7 @@ exports.LatestVersionHash = async function({objectId, versionHash}) {
1103
1076
  }
1104
1077
 
1105
1078
  try {
1106
- return (await this.ContentObject({objectId})).hash;
1079
+ return (await this.ContentObject({objectId, noCache: true})).hash;
1107
1080
  } catch(error) {
1108
1081
  error.message = `Unable to determine latest version hash for ${versionHash || objectId}`;
1109
1082
  throw error;
@@ -1,10 +1,14 @@
1
- const { ElvClient } = require("../src/ElvClient");
1
+ const { ElvClient } = require("../src/index");
2
2
  const { ElvWalletClient } = require("../src/walletClient/index");
3
3
  const ClientConfiguration = require("../TestConfiguration.json");
4
4
  const fs = require("fs");
5
5
  const HttpClient = require("../src/HttpClient");
6
+ //const NodeFetch = require("node-fetch");
6
7
 
7
8
  const Test = async () => {
9
+ // For some reason, fetch isn't defined for ethers in the build node version, need to set this
10
+ //globalThis.fetch = NodeFetch;
11
+
8
12
  try {
9
13
  const client = await ElvClient.FromNetworkName({
10
14
  networkName: "demo"
package/webpack.config.js CHANGED
@@ -15,42 +15,39 @@ let plugins = [
15
15
  new webpack.optimize.LimitChunkCountPlugin({
16
16
  maxChunks: 1,
17
17
  }),
18
- new webpack.IgnorePlugin(/unorm/),
19
18
  new BundleAnalyzerPlugin({
20
19
  analyzerMode: "static",
21
20
  reportFilename: path.resolve(path.join(__dirname, "test", "bundle-analysis", "index.html")),
22
21
  openAnalyzer: false
23
- })
22
+ }),
23
+ new webpack.IgnorePlugin({resourceRegExp: /window/})
24
24
  ];
25
25
 
26
- plugins.push(new webpack.IgnorePlugin(/window/));
27
-
28
- // Exclude node-fetch for web build
29
26
  if(cmdOpts["target"] !== "node") {
30
- plugins.push(new webpack.IgnorePlugin(/node-fetch-polyfill/));
31
- plugins.push(new webpack.IgnorePlugin(/@eluvio\/crypto\/dist\/elv-crypto.bundle.node/));
27
+ plugins.push(new webpack.IgnorePlugin({resourceRegExp: /@eluvio\/crypto\/dist\/elv-crypto.bundle.node/}));
32
28
  } else {
33
- plugins.push(new webpack.IgnorePlugin(/@eluvio\/crypto\/dist\/elv-crypto.bundle.js/));
29
+ plugins.push(new webpack.IgnorePlugin({resourceRegExp: /@eluvio\/crypto\/dist\/elv-crypto.bundle.js/}));
34
30
  }
35
31
 
36
32
  module.exports = {
37
- entry: "./dist/src/ElvClient.js",
33
+ entry: "./src/ElvClient.js",
38
34
  output: {
39
35
  path: path.resolve(__dirname, "dist"),
40
36
  filename: "ElvClient-min-dev.js",
41
37
  libraryTarget: "umd"
42
38
  },
43
- node: {
44
- fs: "empty"
45
- },
46
39
  resolve: {
47
40
  alias: {
48
41
  // Force webpack to use *one* copy of bn.js instead of 8
49
42
  "bn.js": path.resolve(path.join(__dirname, "node_modules", "bn.js"))
43
+ },
44
+ fallback: {
45
+ "crypto": require.resolve("crypto-browserify"),
46
+ "stream": require.resolve("stream-browserify"),
47
+ "vm": require.resolve("vm-browserify")
50
48
  }
51
49
  },
52
50
  mode: "development",
53
- devtool: cmdOpts["mode"] === "production" ? "" : "source-map",
54
51
  plugins: plugins,
55
52
  module: {
56
53
  noParse: [