@eluvio/elv-client-js 4.2.22 → 4.2.24

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.2.22",
3
+ "version": "4.2.24",
4
4
  "description": "Javascript client for the Eluvio Content Fabric",
5
5
  "main": "src/index.js",
6
6
  "author": "Kevin Talmadge",
package/src/Crypto.js CHANGED
@@ -82,7 +82,19 @@ const Crypto = {
82
82
  return Utils.B64(cap);
83
83
  },
84
84
 
85
- async DecryptCap(encryptedCap, privateKey) {
85
+ // accepts either a raw private key string (legacy usage) or a signer
86
+ async DecryptCap(encryptedCap, signerOrPrivateKey) {
87
+ let privateKey;
88
+ if(typeof signerOrPrivateKey === "string") {
89
+ privateKey = signerOrPrivateKey;
90
+ } else if(signerOrPrivateKey && signerOrPrivateKey.remoteSigner) {
91
+ return await signerOrPrivateKey.DecryptCap(encryptedCap);
92
+ } else if(signerOrPrivateKey && typeof signerOrPrivateKey._signingKey === "function") {
93
+ privateKey = signerOrPrivateKey._signingKey().privateKey;
94
+ } else {
95
+ throw Error("Crypto.DecryptCap: second argument must be a signer or a private key string");
96
+ }
97
+
86
98
  const elvCrypto = await Crypto.ElvCrypto();
87
99
  privateKey = new Uint8Array(Buffer.from(privateKey.replace("0x", ""), "hex"));
88
100
 
package/src/ElvClient.js CHANGED
@@ -1348,9 +1348,7 @@ class ElvClient {
1348
1348
 
1349
1349
  ValidatePresence("message", message);
1350
1350
 
1351
- return this.signer.remoteSigner ?
1352
- await this.signer.DecryptCap(message) :
1353
- await this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
1351
+ return await this.Crypto.DecryptCap(message, this.signer);
1354
1352
  }
1355
1353
 
1356
1354
  /**
@@ -449,10 +449,12 @@ class FrameClient {
449
449
  "ObjectCleanup",
450
450
  "OutputsCreate",
451
451
  "OutputsDelete",
452
+ "OutputsDeleteBatch",
452
453
  "OutputsList",
453
454
  "OutputsListItem",
454
455
  "OutputsModify",
455
456
  "OutputsModifyBatch",
457
+ "OutputsReset",
456
458
  "OutputsResolveSrtPullUrls",
457
459
  "OutputsState",
458
460
  "OutputsStop",
@@ -2743,9 +2743,7 @@ exports.CreateEncryptionConk = async function({libraryId, objectId, versionHash,
2743
2743
  });
2744
2744
 
2745
2745
  if(existingUserCap) {
2746
- this.encryptionConks[objectId] = this.signer.remoteSigner ?
2747
- await this.signer.DecryptCap(existingUserCap) :
2748
- await this.Crypto.DecryptCap(existingUserCap, this.signer._signingKey().privateKey);
2746
+ this.encryptionConks[objectId] = await this.Crypto.DecryptCap(existingUserCap, this.signer);
2749
2747
  } else {
2750
2748
  this.encryptionConks[objectId] = await this.Crypto.GeneratePrimaryConk({
2751
2749
  spaceId: this.contentSpaceId,
@@ -2848,9 +2846,7 @@ exports.EncryptionConk = async function({libraryId, objectId, versionHash, write
2848
2846
  });
2849
2847
 
2850
2848
  if(existingUserCap) {
2851
- this.encryptionConks[objectId] = this.signer.remoteSigner ?
2852
- await this.signer.DecryptCap(existingUserCap) :
2853
- await this.Crypto.DecryptCap(existingUserCap, this.signer._signingKey().privateKey);
2849
+ this.encryptionConks[objectId] = await this.Crypto.DecryptCap(existingUserCap, this.signer);
2854
2850
  } else if(writeToken) {
2855
2851
  await this.CreateEncryptionConk({libraryId, objectId, versionHash, writeToken, createKMSConk: false});
2856
2852
  } else {
@@ -680,9 +680,7 @@ exports.CopyContentObject = async function({libraryId, originalVersionHash, opti
680
680
  const userCapKey = `eluv.caps.iusr${this.utils.AddressToHash(this.signer.address)}`;
681
681
 
682
682
  if(metadata[userCapKey]) {
683
- const userConkKey = this.signer.remoteSigner ?
684
- await this.signer.DecryptCap(metadata[userCapKey]) :
685
- await this.Crypto.DecryptCap(metadata[userCapKey], this.signer._signingKey().privateKey);
683
+ const userConkKey = await this.Crypto.DecryptCap(metadata[userCapKey], this.signer);
686
684
  userConkKey.qid = objectId;
687
685
 
688
686
  await this.ReplaceMetadata({
@@ -735,9 +733,7 @@ exports.CreateNonOwnerCap = async function({objectId, libraryId, publicKey, writ
735
733
  throw Error("No user cap found for current user");
736
734
  }
737
735
 
738
- const userConk = this.signer.remoteSigner ?
739
- await this.signer.DecryptCap(userCapValue) :
740
- await this.Crypto.DecryptCap(userCapValue, this.signer._signingKey().privateKey);
736
+ const userConk = await this.Crypto.DecryptCap(userCapValue, this.signer);
741
737
 
742
738
  const publicAddress = this.utils.PublicKeyToAddress(publicKey);
743
739
 
@@ -955,7 +955,7 @@ async function GetTenantGroupAddress({ctx, tenantContractId, groupName}) {
955
955
 
956
956
  return groupAddress;
957
957
  } catch (err) {
958
- this.Log(err);
958
+ ctx.Log(err);
959
959
  throw new Error(`Failed to retrieve ${groupName} group address.`);
960
960
  }
961
961