@eluvio/elv-client-js 3.1.96 → 3.2.1

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 (44) hide show
  1. package/dist/ElvClient-min.js +11 -15
  2. package/dist/ElvClient-node-min.js +13 -17
  3. package/dist/ElvFrameClient-min.js +9 -13
  4. package/dist/ElvPermissionsClient-min.js +9 -13
  5. package/dist/src/AuthorizationClient.js +1980 -2238
  6. package/dist/src/ContentObjectVerification.js +173 -164
  7. package/dist/src/Crypto.js +324 -376
  8. package/dist/src/ElvClient.js +1022 -1182
  9. package/dist/src/ElvWallet.js +95 -119
  10. package/dist/src/EthClient.js +896 -1040
  11. package/dist/src/FrameClient.js +300 -331
  12. package/dist/src/HttpClient.js +147 -153
  13. package/dist/src/Id.js +3 -1
  14. package/dist/src/PermissionsClient.js +1168 -1294
  15. package/dist/src/RemoteSigner.js +211 -263
  16. package/dist/src/UserProfileClient.js +1023 -1164
  17. package/dist/src/Utils.js +217 -212
  18. package/dist/src/client/ABRPublishing.js +858 -895
  19. package/dist/src/client/AccessGroups.js +959 -1102
  20. package/dist/src/client/ContentAccess.js +3434 -3727
  21. package/dist/src/client/ContentManagement.js +2068 -2252
  22. package/dist/src/client/Contracts.js +563 -647
  23. package/dist/src/client/Files.js +1757 -1886
  24. package/dist/src/client/NFT.js +112 -126
  25. package/dist/src/client/NTP.js +422 -478
  26. package/dist/src/index.js +11 -0
  27. package/dist/src/marketplaceClient/ClientMethods.js +1918 -0
  28. package/dist/src/marketplaceClient/Configuration.js +29 -0
  29. package/dist/src/marketplaceClient/Utils.js +304 -0
  30. package/dist/src/marketplaceClient/index.js +1553 -0
  31. package/dist/src/walletClient/ClientMethods.js +1828 -0
  32. package/dist/src/walletClient/Configuration.js +29 -0
  33. package/dist/src/walletClient/Utils.js +290 -0
  34. package/dist/src/walletClient/index.js +1459 -0
  35. package/package.json +5 -3
  36. package/src/ElvClient.js +4 -1
  37. package/src/Utils.js +44 -3
  38. package/src/index.js +7 -0
  39. package/src/walletClient/ClientMethods.js +1016 -0
  40. package/src/walletClient/Configuration.js +40 -0
  41. package/src/walletClient/README.md +185 -0
  42. package/src/walletClient/Utils.js +234 -0
  43. package/src/walletClient/index.js +884 -0
  44. package/testScripts/TestMarketplaceClient.js +25 -0
package/package.json CHANGED
@@ -1,15 +1,17 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "3.1.96",
3
+ "version": "3.2.1",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
- "main": "src/ElvClient.js",
5
+ "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
7
7
  "license": "MIT",
8
8
  "homepage": "https://github.com/eluv-io/elv-client-js",
9
9
  "scripts": {
10
10
  "bump-version": "npm --git-tag-version --no-commit-hooks version patch",
11
11
  "build": "npm run build-docs && npm run build-dist && npm run build-frame-client && npm run build-permissions-client && npm run build-prod",
12
- "build-docs": "node build/BuildDocs.js && ./node_modules/.bin/jsdoc --configure ./.jsdoc.json --readme README.md",
12
+ "build-docs": "node build/BuildDocs.js && npm run build-client-docs && npm run build-wallet-client-docs",
13
+ "build-client-docs": "./node_modules/.bin/jsdoc --configure ./.jsdoc.json --readme README.md",
14
+ "build-wallet-client-docs": "./node_modules/.bin/jsdoc --configure ./.jsdoc-mc.json --readme ./src/walletClient/README.md",
13
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",
14
16
  "build-contracts": "node build/BuildContracts.js",
15
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",
package/src/ElvClient.js CHANGED
@@ -39,6 +39,9 @@ if(Utils.Platform() === Utils.PLATFORM_NODE) {
39
39
  /**
40
40
  * See the Modules section on the sidebar for details about methods related to interacting with the Fabric.
41
41
  *
42
+ * <br/>
43
+ *
44
+ * For information about the Eluvio Wallet Client, go <a href="wallet-client/index.html">here</a>.
42
45
  */
43
46
  class ElvClient {
44
47
  Log(message, error = false) {
@@ -116,7 +119,7 @@ class ElvClient {
116
119
  /**
117
120
  * Create a new ElvClient
118
121
  *
119
- * NOTE: It is highly recommended to use ElvClient.FromConfiguration to
122
+ * NOTE: It is highly recommended to use the <a href="#.FromConfigurationUrl">FromConfigurationUrl</a> or <a href="#.FromNetworkName">FromNetworkName</a> method
120
123
  * automatically import the client settings from the fabric
121
124
  *
122
125
  * @constructor
package/src/Utils.js CHANGED
@@ -4,6 +4,7 @@ const bs58 = require("bs58");
4
4
  const BigNumber = require("bignumber.js").default;
5
5
  const VarInt = require("varint");
6
6
  const URI = require("urijs");
7
+ const Pako = require("pako");
7
8
 
8
9
  const {
9
10
  keccak256,
@@ -17,14 +18,14 @@ const {
17
18
  *
18
19
  * Utils can be imported separately from the client:
19
20
  *
20
- * const Utils = require("@eluvio/elv-client-js/src/Utils)
21
+ * `const Utils = require("@eluvio/elv-client-js/src/Utils)`
21
22
  *
22
23
  * or
23
24
  *
24
- * import Utils from "@eluvio/elv-client-js/src/Utils"
25
+ * `import Utils from "@eluvio/elv-client-js/src/Utils"`
25
26
  *
26
27
  *
27
- * It can be accessed from ElvClient and FrameClient as client.utils
28
+ * It can be accessed from ElvClient and FrameClient as `client.utils`
28
29
  */
29
30
  const Utils = {
30
31
  name: "Utils",
@@ -150,6 +151,27 @@ const Utils = {
150
151
  };
151
152
  },
152
153
 
154
+
155
+ /**
156
+ * Decode the specified signed token into its component parts
157
+ *
158
+ * @param {string} token - The token to decode
159
+ *
160
+ * @return {Object} - Components of the signed token
161
+ */
162
+ DecodeSignedToken: (token) => {
163
+ const decodedToken = Utils.FromB58(token.slice(6));
164
+ const signature = `0x${decodedToken.slice(0, 65).toString("hex")}`;
165
+
166
+ let payload = JSON.parse(Buffer.from(Pako.inflateRaw(decodedToken.slice(65))).toString("utf-8"));
167
+ payload.adr = Utils.FormatAddress(`0x${Buffer.from(payload.adr, "base64").toString("hex")}`);
168
+
169
+ return {
170
+ payload,
171
+ signature
172
+ };
173
+ },
174
+
153
175
  /**
154
176
  * Decode the specified write token into its component parts
155
177
  *
@@ -420,6 +442,21 @@ const Utils = {
420
442
  return Buffer.from(str, "base64").toString("utf-8");
421
443
  },
422
444
 
445
+ FromB64URL: str => {
446
+ str = str.replace(/-/g, "+").replace(/_/g, "/");
447
+
448
+ const pad = str.length % 4;
449
+ if(pad) {
450
+ if(pad === 1) {
451
+ throw new Error("InvalidLengthError: Input base64url string is the wrong length to determine padding");
452
+ }
453
+
454
+ str += new Array(5-pad).join("=");
455
+ }
456
+
457
+ return Utils.FromB64(str);
458
+ },
459
+
423
460
  B58: arr => {
424
461
  return bs58.encode(Buffer.from(arr));
425
462
  },
@@ -428,6 +465,10 @@ const Utils = {
428
465
  return bs58.decode(str);
429
466
  },
430
467
 
468
+ FromB58ToStr: str => {
469
+ return new TextDecoder().decode(Utils.FromB58(str));
470
+ },
471
+
431
472
  /**
432
473
  * Decode the given fabric authorization token
433
474
  *
package/src/index.js ADDED
@@ -0,0 +1,7 @@
1
+ const {ElvClient} = require("./ElvClient.js");
2
+ const {ElvMarketplaceClient} = require("./walletClient/index.js");
3
+ const Utils = require("./Utils.js");
4
+
5
+ exports.ElvClient = ElvClient;
6
+ exports.ElvMarketplaceClient = ElvMarketplaceClient;
7
+ exports.Utils = Utils;