@eluvio/elv-client-js 4.0.42 → 4.0.44

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@eluvio/elv-client-js",
3
- "version": "4.0.42",
3
+ "version": "4.0.44",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
@@ -52,7 +52,7 @@
52
52
  ],
53
53
  "dependencies": {
54
54
  "@babel/runtime": "^7.8.4",
55
- "@eluvio/crypto": ">=1.0.12",
55
+ "@eluvio/crypto": "1.1.0",
56
56
  "@eluvio/elv-abr-profile": "^1.0.0",
57
57
  "@sindresorhus/slugify": "^1.1.0",
58
58
  "babel-loader": "^8.0.6",
@@ -84,6 +84,7 @@
84
84
  "path": "^0.12.7",
85
85
  "prompt": "^1.1.0",
86
86
  "ramda": "^0.27.1",
87
+ "readable-stream": "^4.4.2",
87
88
  "shell-escape": "^0.2.0",
88
89
  "sjcl": "^1.0.8",
89
90
  "typedarray": "0.0.6",
package/src/Crypto.js CHANGED
@@ -1,28 +1,19 @@
1
1
  if(typeof globalThis.Buffer === "undefined") { globalThis.Buffer = require("buffer/").Buffer; }
2
2
 
3
3
  const bs58 = require("bs58");
4
- const Stream = require("stream");
4
+ const Stream = require("readable-stream");
5
5
  const Utils = require("./Utils");
6
6
 
7
+ if(!globalThis.process) {
8
+ globalThis.process = require("process/browser");
9
+ }
10
+
7
11
  if(typeof crypto === "undefined") {
8
12
  const crypto = require("crypto");
9
13
  crypto.getRandomValues = arr => crypto.randomBytes(arr.length);
10
14
  globalThis.crypto = crypto;
11
15
  }
12
16
 
13
- let ElvCrypto;
14
- switch(Utils.Platform()) {
15
- case Utils.PLATFORM_REACT_NATIVE:
16
- ElvCrypto = require("@eluvio/crypto/dist/elv-crypto.bundle.externals").default;
17
- break;
18
- case Utils.PLATFORM_WEB:
19
- ElvCrypto = require("@eluvio/crypto/dist/elv-crypto.bundle.externals").default;
20
- break;
21
- default:
22
- ElvCrypto = require("@eluvio/crypto/dist/elv-crypto.bundle.node").default;
23
- break;
24
- }
25
-
26
17
  /**
27
18
  * @namespace
28
19
  * @description This namespace contains cryptographic helper methods to encrypt and decrypt
@@ -32,6 +23,7 @@ const Crypto = {
32
23
  ElvCrypto: async () => {
33
24
  try {
34
25
  if(!Crypto.elvCrypto) {
26
+ const ElvCrypto = (await import("@eluvio/crypto")).default;
35
27
  Crypto.elvCrypto = await new ElvCrypto().init();
36
28
  }
37
29
 
package/src/ElvClient.js CHANGED
@@ -579,6 +579,16 @@ class ElvClient {
579
579
  };
580
580
  }
581
581
 
582
+ WriteTokenNodeUrl({writeToken}) {
583
+ const nodeUrl = this.HttpClient.draftURIs[writeToken];
584
+
585
+ return nodeUrl ? nodeUrl.toString() : undefined;
586
+ }
587
+
588
+ RecordWriteToken({writeToken, fabricNodeUrl}) {
589
+ this.HttpClient.RecordWriteToken(writeToken, fabricNodeUrl);
590
+ }
591
+
582
592
  /* Wallet and signers */
583
593
 
584
594
  /**
@@ -428,6 +428,7 @@ class FrameClient {
428
428
  "MergeMetadata",
429
429
  "MetadataAuth",
430
430
  "MintNFT",
431
+ "MoveFiles",
431
432
  "NetworkInfo",
432
433
  "NodeId",
433
434
  "Nodes",
@@ -440,6 +441,7 @@ class FrameClient {
440
441
  "PublicRep",
441
442
  "PublishContentVersion",
442
443
  "QParts",
444
+ "RecordWriteToken",
443
445
  "RedeemCode",
444
446
  "RemoveAccessGroupManager",
445
447
  "RemoveAccessGroupMember",
@@ -623,7 +623,7 @@ exports.LROStatus = async function({libraryId, objectId}) {
623
623
 
624
624
  const lroDraft = await this.LRODraftInfo({libraryId, objectId});
625
625
 
626
- this.HttpClient.RecordWriteToken(lroDraft.write_token, lroDraft.node);
626
+ this.RecordWriteToken({writeToken: lroDraft.write_token, fabricNodeUrl: lroDraft.node});
627
627
 
628
628
  return await this.ContentObjectMetadata({
629
629
  libraryId,
@@ -652,7 +652,7 @@ exports.FinalizeABRMezzanine = async function({libraryId, objectId, preFinalizeF
652
652
  const lroDraft = await this.LRODraftInfo({libraryId, objectId});
653
653
 
654
654
  // tell http client what node to contact for this write token
655
- this.HttpClient.RecordWriteToken(lroDraft.write_token, lroDraft.node);
655
+ this.RecordWriteToken({writeToken: lroDraft.write_token, fabricNodeUrl: lroDraft.node});
656
656
 
657
657
  const lastJobOfferingsInfo = await this.ContentObjectMetadata({
658
658
  libraryId,
@@ -187,7 +187,7 @@ exports.CreateContentType = async function({name, metadata={}, bitcode}) {
187
187
  const createResponse = await this.utils.ResponseToJson(rawCreateResponse);
188
188
 
189
189
  // Record the node used in creating this write token
190
- this.HttpClient.RecordWriteToken(createResponse.write_token, nodeUrl);
190
+ this.RecordWriteToken({writeToken: createResponse.write_token, fabricNodeUrl: nodeUrl});
191
191
 
192
192
  await this.ReplaceMetadata({
193
193
  libraryId: this.contentSpaceLibraryId,
@@ -611,7 +611,7 @@ exports.CreateContentObject = async function({libraryId, objectId, options={}})
611
611
  const createResponse = await this.utils.ResponseToJson(rawCreateResponse);
612
612
 
613
613
  // Record the node used in creating this write token
614
- this.HttpClient.RecordWriteToken(createResponse.write_token, nodeUrl);
614
+ this.RecordWriteToken({writeToken: createResponse.write_token, fabricNodeUrl: nodeUrl});
615
615
 
616
616
  createResponse.writeToken = createResponse.write_token;
617
617
  createResponse.objectId = createResponse.id;
@@ -782,7 +782,7 @@ exports.EditContentObject = async function({libraryId, objectId, options={}}) {
782
782
  const editResponse = await this.utils.ResponseToJson(rawEditResponse);
783
783
 
784
784
  // Record the node used in creating this write token
785
- this.HttpClient.RecordWriteToken(editResponse.write_token, nodeUrl);
785
+ this.RecordWriteToken({writeToken: editResponse.write_token, fabricNodeUrl: nodeUrl});
786
786
 
787
787
  editResponse.writeToken = editResponse.write_token;
788
788
  editResponse.objectId = editResponse.id;
@@ -603,6 +603,29 @@ exports.CreateFileDirectories = async function({libraryId, objectId, writeToken,
603
603
  await this.CreateFileUploadJob({libraryId, objectId, writeToken, ops});
604
604
  };
605
605
 
606
+ /**
607
+ * Move or rename the specified list of files/directories
608
+ *
609
+ * @memberof module:ElvClient/Files+Parts
610
+ * @methodGroup Files
611
+ * @namedParams
612
+ * @param {string} libraryId - ID of the library
613
+ * @param {string} objectId - ID of the object
614
+ * @param {string} writeToken - Write token of the draft
615
+ * @param {Array<string>} filePaths - List of file paths to move. Format: ```[ { "path": "original/path", to: "new/path" } ]```
616
+ */
617
+ exports.MoveFiles = async function({libraryId, objectId, writeToken, filePaths}) {
618
+ ValidateParameters({libraryId, objectId});
619
+ ValidateWriteToken(writeToken);
620
+
621
+ this.Log(`Moving Files: ${libraryId} ${objectId} ${writeToken}`);
622
+ this.Log(filePaths);
623
+
624
+ const ops = filePaths.map(({path, to}) => ({op: "move", copy_move_source_path: path, path: to}));
625
+
626
+ await this.CreateFileUploadJob({libraryId, objectId, writeToken, ops});
627
+ };
628
+
606
629
  /**
607
630
  * Delete the specified list of files/directories
608
631
  *