@eluvio/elv-client-js 3.2.45 → 4.0.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.
- package/dist/ElvClient-min.js +17 -9
- package/dist/ElvClient-node-min.js +12 -25
- package/dist/ElvFrameClient-min.js +17 -9
- package/dist/ElvPermissionsClient-min.js +16 -8
- package/dist/ElvWalletClient-min.js +17 -9
- package/dist/ElvWalletClient-node-min.js +12 -25
- package/dist/src/AuthorizationClient.js +6 -6
- package/dist/src/ElvClient.js +3 -3
- package/dist/src/ElvWallet.js +1 -3
- package/dist/src/EthClient.js +21 -12
- package/dist/src/FrameClient.js +10 -7
- package/dist/src/client/ContentAccess.js +3 -3
- package/dist/src/client/ContentManagement.js +4 -4
- package/dist/src/client/Contracts.js +1 -1
- package/package.json +2 -2
- package/src/AuthorizationClient.js +6 -6
- package/src/ElvClient.js +3 -2
- package/src/ElvWallet.js +1 -3
- package/src/EthClient.js +19 -10
- package/src/FrameClient.js +10 -2
- package/src/client/ContentAccess.js +3 -3
- package/src/client/ContentManagement.js +4 -4
- package/src/client/Contracts.js +1 -1
- package/testScripts/Test.js +7 -36
|
@@ -353,7 +353,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
353
353
|
addr: Utils.FormatAddress(this.client.signer && this.client.signer.address || "")
|
|
354
354
|
};
|
|
355
355
|
|
|
356
|
-
if (
|
|
356
|
+
if (!update) {
|
|
357
357
|
_context3.next = 29;
|
|
358
358
|
break;
|
|
359
359
|
}
|
|
@@ -602,8 +602,8 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
602
602
|
}; // Save request ID if present
|
|
603
603
|
|
|
604
604
|
accessRequest.logs.some(function (log) {
|
|
605
|
-
if (log.
|
|
606
|
-
_this.requestIds[address] = (log.
|
|
605
|
+
if (log.args && (log.args.requestID || log.args.requestNonce)) {
|
|
606
|
+
_this.requestIds[address] = (log.args.requestID || log.args.requestNonce || "").toString().replace(/^0x/, "");
|
|
607
607
|
return true;
|
|
608
608
|
}
|
|
609
609
|
});
|
|
@@ -1231,11 +1231,11 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1231
1231
|
if (!isV3) {
|
|
1232
1232
|
if (args && args.length > 0) {
|
|
1233
1233
|
// Inject public key of requester
|
|
1234
|
-
args[1] = this.client.signer.
|
|
1234
|
+
args[1] = this.client.signer._signingKey ? this.client.signer._signingKey().publicKey : "";
|
|
1235
1235
|
} else {
|
|
1236
1236
|
// Set default args
|
|
1237
1237
|
args = [0, // Access level
|
|
1238
|
-
this.client.signer.
|
|
1238
|
+
this.client.signer._signingKey ? this.client.signer._signingKey().publicKey : "", // Public key of requester
|
|
1239
1239
|
publicKey, //cap.public_key,
|
|
1240
1240
|
[], // Custom values
|
|
1241
1241
|
[] // Stakeholders
|
|
@@ -1607,7 +1607,7 @@ var AuthorizationClient = /*#__PURE__*/function () {
|
|
|
1607
1607
|
|
|
1608
1608
|
case 7:
|
|
1609
1609
|
_context17.next = 9;
|
|
1610
|
-
return this.client.signer.
|
|
1610
|
+
return this.client.signer._signingKey().signDigest(message);
|
|
1611
1611
|
|
|
1612
1612
|
case 9:
|
|
1613
1613
|
_context17.t1 = _context17.sent;
|
package/dist/src/ElvClient.js
CHANGED
|
@@ -1479,7 +1479,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1479
1479
|
case 3:
|
|
1480
1480
|
ValidatePresence("message", message);
|
|
1481
1481
|
_context17.next = 6;
|
|
1482
|
-
return this.Crypto.EncryptConk(message, publicKey || this.signer.
|
|
1482
|
+
return this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
|
|
1483
1483
|
|
|
1484
1484
|
case 6:
|
|
1485
1485
|
return _context17.abrupt("return", _context17.sent);
|
|
@@ -1528,7 +1528,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1528
1528
|
case 3:
|
|
1529
1529
|
ValidatePresence("message", message);
|
|
1530
1530
|
_context18.next = 6;
|
|
1531
|
-
return this.Crypto.DecryptCap(message, this.signer.
|
|
1531
|
+
return this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
|
|
1532
1532
|
|
|
1533
1533
|
case 6:
|
|
1534
1534
|
return _context18.abrupt("return", _context18.sent);
|
|
@@ -1598,7 +1598,7 @@ var ElvClient = /*#__PURE__*/function () {
|
|
|
1598
1598
|
value: function FrameAllowedMethods() {
|
|
1599
1599
|
var _this2 = this;
|
|
1600
1600
|
|
|
1601
|
-
var forbiddenMethods = ["constructor", "AccessGroupMembershipMethod", "CallFromFrameMessage", "ClearSigner", "CreateAccount", "EnableMethodLogging", "FormatBlockNumbers", "FrameAllowedMethods", "FromConfigurationUrl", "GenerateWallet", "InitializeClients", "Log", "SetRemoteSigner", "SetSigner", "SetSignerFromWeb3Provider", "Sign", "ToggleLogging"];
|
|
1601
|
+
var forbiddenMethods = ["constructor", "AccessGroupMembershipMethod", "CallFromFrameMessage", "ClearSigner", "CreateAccount", "EnableMethodLogging", "FormatBlockNumbers", "FrameAllowedMethods", "FromConfigurationUrl", "GenerateWallet", "InitializeClients", "Log", "PersonalSign", "SetRemoteSigner", "SetSigner", "SetSignerFromWeb3Provider", "Sign", "ToggleLogging"];
|
|
1602
1602
|
return Object.getOwnPropertyNames(Object.getPrototypeOf(this)).filter(function (method) {
|
|
1603
1603
|
return typeof _this2[method] === "function" && !forbiddenMethods.includes(method);
|
|
1604
1604
|
});
|
package/dist/src/ElvWallet.js
CHANGED
|
@@ -19,8 +19,6 @@ var ElvWallet = /*#__PURE__*/function () {
|
|
|
19
19
|
* NOTE: It is recommended to initialize wallets from the ElvClient, not using this constructor
|
|
20
20
|
*
|
|
21
21
|
* @see ElvClient#GenerateWallet()
|
|
22
|
-
*
|
|
23
|
-
* @param {string} providerUrl - URL of blockchain provider
|
|
24
22
|
*/
|
|
25
23
|
function ElvWallet(provider) {
|
|
26
24
|
_classCallCheck(this, ElvWallet);
|
|
@@ -38,7 +36,7 @@ var ElvWallet = /*#__PURE__*/function () {
|
|
|
38
36
|
_createClass(ElvWallet, [{
|
|
39
37
|
key: "GenerateMnemonic",
|
|
40
38
|
value: function GenerateMnemonic() {
|
|
41
|
-
return Ethers.
|
|
39
|
+
return Ethers.Wallet.createRandom().mnemonic.phrase;
|
|
42
40
|
}
|
|
43
41
|
/**
|
|
44
42
|
* Generate a private key from the given mnemonic
|
package/dist/src/EthClient.js
CHANGED
|
@@ -71,8 +71,7 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
71
71
|
this.HttpClient = new HttpClient({
|
|
72
72
|
uris: this.ethereumURIs,
|
|
73
73
|
debug: this.debug
|
|
74
|
-
});
|
|
75
|
-
Ethers.errors.setLogLevel("error");
|
|
74
|
+
}); //Ethers.errors.setLogLevel("error");
|
|
76
75
|
}
|
|
77
76
|
|
|
78
77
|
_createClass(EthClient, [{
|
|
@@ -429,7 +428,7 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
429
428
|
key: "CallContractMethod",
|
|
430
429
|
value: function () {
|
|
431
430
|
var _CallContractMethod = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime.mark(function _callee6(_ref9) {
|
|
432
|
-
var contract, contractAddress, abi, methodName, _ref9$methodArgs, methodArgs, value, _ref9$overrides, overrides, _ref9$formatArguments, formatArguments, _ref9$cacheContract, cacheContract, _ref9$overrideCachedC, overrideCachedContract, methodAbi, result, success, _contract
|
|
431
|
+
var contract, contractAddress, abi, methodName, _ref9$methodArgs, methodArgs, value, _ref9$overrides, overrides, _ref9$formatArguments, formatArguments, _ref9$cacheContract, cacheContract, _ref9$overrideCachedC, overrideCachedContract, methodAbi, result, success, _contract, latestBlock;
|
|
433
432
|
|
|
434
433
|
return _regeneratorRuntime.wrap(function _callee6$(_context6) {
|
|
435
434
|
while (1) {
|
|
@@ -457,7 +456,7 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
457
456
|
cacheContract: cacheContract,
|
|
458
457
|
overrideCachedContract: overrideCachedContract
|
|
459
458
|
});
|
|
460
|
-
abi = contract["interface"].
|
|
459
|
+
abi = contract["interface"].fragments; // Automatically format contract arguments
|
|
461
460
|
|
|
462
461
|
if (formatArguments) {
|
|
463
462
|
methodArgs = this.FormatContractArguments({
|
|
@@ -481,7 +480,7 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
481
480
|
|
|
482
481
|
case 11:
|
|
483
482
|
this.Log("Calling contract method:\n Provider: ".concat(this.Provider().connection.url, "\n Address: ").concat(contract.address, "\n Method: ").concat(methodName, "\n Args: [").concat(methodArgs.join(", "), "]"));
|
|
484
|
-
methodAbi = contract["interface"].
|
|
483
|
+
methodAbi = contract["interface"].fragments.find(function (method) {
|
|
485
484
|
return method.name === methodName;
|
|
486
485
|
}); // Lock if performing a transaction
|
|
487
486
|
|
|
@@ -520,7 +519,7 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
520
519
|
|
|
521
520
|
_context6.prev = 23;
|
|
522
521
|
_context6.next = 26;
|
|
523
|
-
return (_contract
|
|
522
|
+
return (_contract = contract)[methodName].apply(_contract, _toConsumableArray(methodArgs).concat([overrides]));
|
|
524
523
|
|
|
525
524
|
case 26:
|
|
526
525
|
result = _context6.sent;
|
|
@@ -673,7 +672,13 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
673
672
|
}
|
|
674
673
|
|
|
675
674
|
methodEvent.logs = methodEvent.logs.map(function (log) {
|
|
676
|
-
|
|
675
|
+
var parsedLogs = {};
|
|
676
|
+
|
|
677
|
+
try {
|
|
678
|
+
parsedLogs = contract["interface"].parseLog(log); // eslint-disable-next-line no-empty
|
|
679
|
+
} catch (error) {}
|
|
680
|
+
|
|
681
|
+
return _objectSpread(_objectSpread({}, log), parsedLogs);
|
|
677
682
|
});
|
|
678
683
|
return _context7.abrupt("break", 25);
|
|
679
684
|
|
|
@@ -766,11 +771,15 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
766
771
|
try {
|
|
767
772
|
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
768
773
|
var log = _step.value;
|
|
769
|
-
var parsedLog = contractInterface.parseLog(log);
|
|
770
774
|
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
775
|
+
try {
|
|
776
|
+
var parsedLog = contractInterface.parseLog(log);
|
|
777
|
+
|
|
778
|
+
if (parsedLog && parsedLog.name === eventName) {
|
|
779
|
+
return parsedLog;
|
|
780
|
+
} // eslint-disable-next-line no-empty
|
|
781
|
+
|
|
782
|
+
} catch (error) {}
|
|
774
783
|
}
|
|
775
784
|
} catch (err) {
|
|
776
785
|
_iterator.e(err);
|
|
@@ -821,7 +830,7 @@ var EthClient = /*#__PURE__*/function () {
|
|
|
821
830
|
throw Error("".concat(methodName, " failed - Log not present in transaction"));
|
|
822
831
|
|
|
823
832
|
case 10:
|
|
824
|
-
newContractAddress = eventLog.
|
|
833
|
+
newContractAddress = eventLog.args[eventValue];
|
|
825
834
|
return _context9.abrupt("return", {
|
|
826
835
|
contractAddress: Utils.FormatAddress(newContractAddress),
|
|
827
836
|
transactionHash: event.transactionHash
|
package/dist/src/FrameClient.js
CHANGED
|
@@ -480,19 +480,22 @@ var FrameClient = /*#__PURE__*/function () {
|
|
|
480
480
|
}() // List of methods that may require a prompt - these should have an unlimited timeout period
|
|
481
481
|
|
|
482
482
|
}, {
|
|
483
|
-
key: "
|
|
484
|
-
value: // List of
|
|
483
|
+
key: "OverriddenMethods",
|
|
484
|
+
value: // List of methods that are defined separately in FrameClient
|
|
485
|
+
function OverriddenMethods() {
|
|
486
|
+
return ["UploadFiles"];
|
|
487
|
+
} // List of allowed methods available to frames
|
|
485
488
|
// This should match ElvClient.FrameAvailableMethods()
|
|
486
489
|
// ElvClient will also reject any disallowed methods
|
|
487
490
|
|
|
488
491
|
/**
|
|
489
492
|
* @returns {Array<string>} - List of ElvClient methods available to a FrameClient
|
|
490
493
|
*/
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
"UploadFilesFromS3", "UploadJobStatus", "UploadPart", "UploadPartChunk", "UploadStatus", "UseRegion", "VerifyContentObject", "Visibility"];
|
|
494
|
+
|
|
495
|
+
}, {
|
|
496
|
+
key: "AllowedMethods",
|
|
497
|
+
value: function AllowedMethods() {
|
|
498
|
+
return ["AccessGroupManagers", "AccessGroupMembers", "AccessGroupOwner", "AccessInfo", "AccessRequest", "AccessType", "AddAccessGroupManager", "AddAccessGroupMember", "AddContentLibraryGroup", "AddContentObjectGroupPermission", "AddLibraryContentType", "AssetMetadata", "AvailableDRMs", "AvailableOfferings", "AwaitPending", "BitmovinPlayoutOptions", "BlockNumber", "CallBitcodeMethod", "CallContractMethod", "CallContractMethodAndWait", "ClearCache", "ClearStaticToken", "Collection", "CollectionTransactions", "ConfigUrl", "ContentLibraries", "ContentLibrary", "ContentLibraryGroupPermissions", "ContentLibraryOwner", "ContentObject", "ContentObjectAccessComplete", "ContentObjectGraph", "ContentObjectGroupPermissions", "ContentObjectImageUrl", "ContentObjectLibraryId", "ContentObjectMetadata", "ContentObjectOwner", "ContentObjectTenantId", "ContentObjectVersions", "ContentObjects", "ContentPart", "ContentParts", "ContentSpaceId", "ContentType", "ContentTypeOwner", "ContentTypes", "ContractAbi", "ContractEvents", "ContractMetadata", "ContractName", "CopyContentObject", "CreateABRMezzanine", "CreateAccessGroup", "CreateAndFinalizeContentObject", "CreateContentLibrary", "CreateContentObject", "CreateContentType", "CreateEncryptionConk", "CreateFabricToken", "CreateFileDirectories", "CreateFileUploadJob", "CreateLinks", "CreateNTPInstance", "CreateNonOwnerCap", "CreatePart", "CreateProductionMaster", "CreateSignedToken", "CurrentAccountAddress", "CustomContractAddress", "Decrypt", "DecryptECIES", "DefaultKMSAddress", "DeleteAccessGroup", "DeleteContentLibrary", "DeleteContentObject", "DeleteContentVersion", "DeleteFiles", "DeleteMetadata", "DeleteNTPInstance", "DeletePart", "DeployContract", "Download", "DownloadEncrypted", "DownloadFile", "DownloadPart", "EditAndFinalizeContentObject", "EditContentObject", "Encrypt", "EncryptECIES", "EncryptionConk", "Events", "ExtractEventFromLogs", "ExtractValueFromEvent", "FabricUrl", "FileUrl", "FinalizeABRMezzanine", "FinalizeContentObject", "FinalizePart", "FinalizeStateChannelAccess", "FinalizeUploadJob", "FormatContractArguments", "GenerateStateChannelToken", "GenerateSignedLinkToken", "GetBalance", "InitializeAuthPolicy", "IssueNTPCode", "IssueSignedNTPCode", "LatestVersionHash", "LibraryContentTypes", "LinkAccessGroupToOauth", "LinkData", "LinkTarget", "LinkUrl", "ListAccessGroups", "ListFiles", "ListNTPInstances", "LROStatus", "MergeContractMetadata", "MergeMetadata", "MetadataAuth", "MintNFT", "NetworkInfo", "NodeId", "Nodes", "NTPInstance", "Permission", "PlayoutOptions", "PlayoutPathResolution", "ProduceMetadataLinks", "Proofs", "PublicRep", "PublishContentVersion", "QParts", "RedeemCode", "RemoveAccessGroupManager", "RemoveAccessGroupMember", "RemoveContentObjectGroupPermission", "RemoveContentLibraryGroup", "RemoveLibraryContentType", "Rep", "ReplaceContractMetadata", "ReplaceMetadata", "Request", "ResetRegion", "SendFunds", "SetAccessCharge", "SetAuth", "SetAuthContext", "SetAuthPolicy", "SetContentLibraryImage", "SetContentObjectImage", "SetCustomContentContract", "SetGroupPermission", "SetNodes", "SetOauthToken", "SetPolicyAuthorization", "SetSignerFromOauthToken", "SetStaticToken", "SetVisibility", "SetPermission", "StartABRMezzanineJobs", "SuspendNTPInstance", "UnlinkAccessGroupFromOauth", "UpdateContentObjectGraph", "UpdateNTPInstance", "UploadFileData", "UploadFilesFromS3", "UploadJobStatus", "UploadPart", "UploadPartChunk", "UploadStatus", "UseRegion", "VerifyContentObject", "Visibility"];
|
|
496
499
|
}
|
|
497
500
|
}, {
|
|
498
501
|
key: "AllowedUserProfileMethods",
|
|
@@ -4392,7 +4392,7 @@ exports.CreateEncryptionConk = /*#__PURE__*/function () {
|
|
|
4392
4392
|
}
|
|
4393
4393
|
|
|
4394
4394
|
_context46.next = 17;
|
|
4395
|
-
return this.Crypto.DecryptCap(existingUserCap, this.signer.
|
|
4395
|
+
return this.Crypto.DecryptCap(existingUserCap, this.signer._signingKey().privateKey);
|
|
4396
4396
|
|
|
4397
4397
|
case 17:
|
|
4398
4398
|
this.encryptionConks[objectId] = _context46.sent;
|
|
@@ -4414,7 +4414,7 @@ exports.CreateEncryptionConk = /*#__PURE__*/function () {
|
|
|
4414
4414
|
_context46.t3 = writeToken;
|
|
4415
4415
|
_context46.t4 = capKey;
|
|
4416
4416
|
_context46.next = 30;
|
|
4417
|
-
return this.Crypto.EncryptConk(this.encryptionConks[objectId], this.signer.
|
|
4417
|
+
return this.Crypto.EncryptConk(this.encryptionConks[objectId], this.signer._signingKey().publicKey);
|
|
4418
4418
|
|
|
4419
4419
|
case 30:
|
|
4420
4420
|
_context46.t5 = _context46.sent;
|
|
@@ -4631,7 +4631,7 @@ exports.EncryptionConk = /*#__PURE__*/function () {
|
|
|
4631
4631
|
}
|
|
4632
4632
|
|
|
4633
4633
|
_context47.next = 29;
|
|
4634
|
-
return this.Crypto.DecryptCap(existingUserCap, this.signer.
|
|
4634
|
+
return this.Crypto.DecryptCap(existingUserCap, this.signer._signingKey().privateKey);
|
|
4635
4635
|
|
|
4636
4636
|
case 29:
|
|
4637
4637
|
this.encryptionConks[objectId] = _context47.sent;
|
|
@@ -1219,7 +1219,7 @@ exports.CopyContentObject = /*#__PURE__*/function () {
|
|
|
1219
1219
|
}
|
|
1220
1220
|
|
|
1221
1221
|
_context13.next = 20;
|
|
1222
|
-
return this.Crypto.DecryptCap(metadata[userCapKey], this.signer.
|
|
1222
|
+
return this.Crypto.DecryptCap(metadata[userCapKey], this.signer._signingKey().privateKey);
|
|
1223
1223
|
|
|
1224
1224
|
case 20:
|
|
1225
1225
|
userConkKey = _context13.sent;
|
|
@@ -1230,7 +1230,7 @@ exports.CopyContentObject = /*#__PURE__*/function () {
|
|
|
1230
1230
|
_context13.t3 = writeToken;
|
|
1231
1231
|
_context13.t4 = userCapKey;
|
|
1232
1232
|
_context13.next = 29;
|
|
1233
|
-
return this.Crypto.EncryptConk(userConkKey, this.signer.
|
|
1233
|
+
return this.Crypto.EncryptConk(userConkKey, this.signer._signingKey().publicKey);
|
|
1234
1234
|
|
|
1235
1235
|
case 29:
|
|
1236
1236
|
_context13.t5 = _context13.sent;
|
|
@@ -1357,7 +1357,7 @@ exports.CreateNonOwnerCap = /*#__PURE__*/function () {
|
|
|
1357
1357
|
|
|
1358
1358
|
case 7:
|
|
1359
1359
|
_context14.next = 9;
|
|
1360
|
-
return this.Crypto.DecryptCap(userCapValue, this.signer.
|
|
1360
|
+
return this.Crypto.DecryptCap(userCapValue, this.signer._signingKey().privateKey);
|
|
1361
1361
|
|
|
1362
1362
|
case 9:
|
|
1363
1363
|
userConk = _context14.sent;
|
|
@@ -2095,7 +2095,7 @@ exports.PublishContentVersion = /*#__PURE__*/function () {
|
|
|
2095
2095
|
events = _context21.sent;
|
|
2096
2096
|
confirmEvent = events.find(function (blockEvents) {
|
|
2097
2097
|
return blockEvents.find(function (event) {
|
|
2098
|
-
return objectHash === (event && event.
|
|
2098
|
+
return objectHash === (event && event.args && event.args.objectHash);
|
|
2099
2099
|
});
|
|
2100
2100
|
});
|
|
2101
2101
|
|
|
@@ -813,7 +813,7 @@ exports.ExtractValueFromEvent = function (_ref25) {
|
|
|
813
813
|
eventName: eventName,
|
|
814
814
|
eventValue: eventValue
|
|
815
815
|
});
|
|
816
|
-
return eventLog ? eventLog.
|
|
816
|
+
return eventLog ? eventLog.args[eventValue] : undefined;
|
|
817
817
|
};
|
|
818
818
|
|
|
819
819
|
exports.FormatBlockNumbers = /*#__PURE__*/function () {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@eluvio/elv-client-js",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0",
|
|
4
4
|
"description": "Javascript client for the Eluvio Content Fabric",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"author": "Kevin Talmadge",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"crocks": "^0.12.4",
|
|
75
75
|
"deep-equal": "^1.0.1",
|
|
76
76
|
"ellipsize": "^0.1.0",
|
|
77
|
-
"ethers": "^
|
|
77
|
+
"ethers": "^5.7.2",
|
|
78
78
|
"fraction.js": "^4.0.12",
|
|
79
79
|
"hash.js": "^1.1.7",
|
|
80
80
|
"image-type": "^4.1.0",
|
|
@@ -204,7 +204,7 @@ class AuthorizationClient {
|
|
|
204
204
|
addr: Utils.FormatAddress(((this.client.signer && this.client.signer.address) || ""))
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
if(
|
|
207
|
+
if(update) {
|
|
208
208
|
const { transactionHash } = await this.MakeAccessRequest({
|
|
209
209
|
libraryId,
|
|
210
210
|
objectId,
|
|
@@ -344,8 +344,8 @@ class AuthorizationClient {
|
|
|
344
344
|
|
|
345
345
|
// Save request ID if present
|
|
346
346
|
accessRequest.logs.some(log => {
|
|
347
|
-
if(log.
|
|
348
|
-
this.requestIds[address] = (log.
|
|
347
|
+
if(log.args && (log.args.requestID || log.args.requestNonce)) {
|
|
348
|
+
this.requestIds[address] = (log.args.requestID || log.args.requestNonce || "").toString().replace(/^0x/, "");
|
|
349
349
|
return true;
|
|
350
350
|
}
|
|
351
351
|
});
|
|
@@ -653,12 +653,12 @@ class AuthorizationClient {
|
|
|
653
653
|
if(!isV3) {
|
|
654
654
|
if(args && args.length > 0) {
|
|
655
655
|
// Inject public key of requester
|
|
656
|
-
args[1] = this.client.signer.
|
|
656
|
+
args[1] = this.client.signer._signingKey ? this.client.signer._signingKey().publicKey : "";
|
|
657
657
|
} else {
|
|
658
658
|
// Set default args
|
|
659
659
|
args = [
|
|
660
660
|
0, // Access level
|
|
661
|
-
this.client.signer.
|
|
661
|
+
this.client.signer._signingKey ? this.client.signer._signingKey().publicKey : "", // Public key of requester
|
|
662
662
|
publicKey, //cap.public_key,
|
|
663
663
|
[], // Custom values
|
|
664
664
|
[] // Stakeholders
|
|
@@ -803,7 +803,7 @@ class AuthorizationClient {
|
|
|
803
803
|
return await Ethers.utils.joinSignature(
|
|
804
804
|
this.client.signer.signDigest ?
|
|
805
805
|
await this.client.signer.signDigest(message) :
|
|
806
|
-
await this.client.signer.
|
|
806
|
+
await this.client.signer._signingKey().signDigest(message)
|
|
807
807
|
);
|
|
808
808
|
}
|
|
809
809
|
|
package/src/ElvClient.js
CHANGED
|
@@ -998,7 +998,7 @@ class ElvClient {
|
|
|
998
998
|
|
|
999
999
|
ValidatePresence("message", message);
|
|
1000
1000
|
|
|
1001
|
-
return await this.Crypto.EncryptConk(message, publicKey || this.signer.
|
|
1001
|
+
return await this.Crypto.EncryptConk(message, publicKey || this.signer._signingKey().publicKey);
|
|
1002
1002
|
}
|
|
1003
1003
|
|
|
1004
1004
|
/**
|
|
@@ -1016,7 +1016,7 @@ class ElvClient {
|
|
|
1016
1016
|
|
|
1017
1017
|
ValidatePresence("message", message);
|
|
1018
1018
|
|
|
1019
|
-
return await this.Crypto.DecryptCap(message, this.signer.
|
|
1019
|
+
return await this.Crypto.DecryptCap(message, this.signer._signingKey().privateKey);
|
|
1020
1020
|
}
|
|
1021
1021
|
|
|
1022
1022
|
/**
|
|
@@ -1061,6 +1061,7 @@ class ElvClient {
|
|
|
1061
1061
|
"GenerateWallet",
|
|
1062
1062
|
"InitializeClients",
|
|
1063
1063
|
"Log",
|
|
1064
|
+
"PersonalSign",
|
|
1064
1065
|
"SetRemoteSigner",
|
|
1065
1066
|
"SetSigner",
|
|
1066
1067
|
"SetSignerFromWeb3Provider",
|
package/src/ElvWallet.js
CHANGED
|
@@ -7,8 +7,6 @@ class ElvWallet {
|
|
|
7
7
|
* NOTE: It is recommended to initialize wallets from the ElvClient, not using this constructor
|
|
8
8
|
*
|
|
9
9
|
* @see ElvClient#GenerateWallet()
|
|
10
|
-
*
|
|
11
|
-
* @param {string} providerUrl - URL of blockchain provider
|
|
12
10
|
*/
|
|
13
11
|
constructor(provider) {
|
|
14
12
|
this.provider = provider;
|
|
@@ -21,7 +19,7 @@ class ElvWallet {
|
|
|
21
19
|
* @returns {string} - Space-separated list of random words
|
|
22
20
|
*/
|
|
23
21
|
GenerateMnemonic() {
|
|
24
|
-
return Ethers.
|
|
22
|
+
return Ethers.Wallet.createRandom().mnemonic.phrase;
|
|
25
23
|
}
|
|
26
24
|
|
|
27
25
|
/**
|
package/src/EthClient.js
CHANGED
|
@@ -39,7 +39,7 @@ class EthClient {
|
|
|
39
39
|
// HTTP client for making misc calls to elv-master
|
|
40
40
|
this.HttpClient = new HttpClient({uris: this.ethereumURIs, debug: this.debug});
|
|
41
41
|
|
|
42
|
-
Ethers.errors.setLogLevel("error");
|
|
42
|
+
//Ethers.errors.setLogLevel("error");
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
SetEthereumURIs(uris) {
|
|
@@ -234,7 +234,7 @@ class EthClient {
|
|
|
234
234
|
|
|
235
235
|
contract = contract || this.Contract({contractAddress, abi, cacheContract, overrideCachedContract});
|
|
236
236
|
|
|
237
|
-
abi = contract.interface.
|
|
237
|
+
abi = contract.interface.fragments;
|
|
238
238
|
|
|
239
239
|
// Automatically format contract arguments
|
|
240
240
|
if(formatArguments) {
|
|
@@ -262,7 +262,7 @@ class EthClient {
|
|
|
262
262
|
Args: [${methodArgs.join(", ")}]`
|
|
263
263
|
);
|
|
264
264
|
|
|
265
|
-
const methodAbi = contract.interface.
|
|
265
|
+
const methodAbi = contract.interface.fragments.find(method => method.name === methodName);
|
|
266
266
|
|
|
267
267
|
// Lock if performing a transaction
|
|
268
268
|
if(!methodAbi || !methodAbi.constant) {
|
|
@@ -278,7 +278,7 @@ class EthClient {
|
|
|
278
278
|
let success = false;
|
|
279
279
|
while(!success) {
|
|
280
280
|
try {
|
|
281
|
-
result = await contract
|
|
281
|
+
result = await contract[methodName](...methodArgs, overrides);
|
|
282
282
|
success = true;
|
|
283
283
|
} catch(error) {
|
|
284
284
|
if(error.code === -32000 || error.code === "REPLACEMENT_UNDERPRICED") {
|
|
@@ -343,9 +343,15 @@ class EthClient {
|
|
|
343
343
|
|
|
344
344
|
if(methodEvent) {
|
|
345
345
|
methodEvent.logs = methodEvent.logs.map(log => {
|
|
346
|
+
let parsedLogs = {};
|
|
347
|
+
try {
|
|
348
|
+
parsedLogs = contract.interface.parseLog(log);
|
|
349
|
+
// eslint-disable-next-line no-empty
|
|
350
|
+
} catch(error) {}
|
|
351
|
+
|
|
346
352
|
return {
|
|
347
353
|
...log,
|
|
348
|
-
...
|
|
354
|
+
...parsedLogs
|
|
349
355
|
};
|
|
350
356
|
});
|
|
351
357
|
|
|
@@ -378,10 +384,13 @@ class EthClient {
|
|
|
378
384
|
const contractInterface = new Ethers.utils.Interface(abi);
|
|
379
385
|
// Loop through logs to find the desired log
|
|
380
386
|
for(const log of event.logs) {
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
387
|
+
try {
|
|
388
|
+
const parsedLog = contractInterface.parseLog(log);
|
|
389
|
+
if(parsedLog && parsedLog.name === eventName) {
|
|
390
|
+
return parsedLog;
|
|
391
|
+
}
|
|
392
|
+
// eslint-disable-next-line no-empty
|
|
393
|
+
} catch(error) {}
|
|
385
394
|
}
|
|
386
395
|
}
|
|
387
396
|
|
|
@@ -400,7 +409,7 @@ class EthClient {
|
|
|
400
409
|
throw Error(`${methodName} failed - Log not present in transaction`);
|
|
401
410
|
}
|
|
402
411
|
|
|
403
|
-
const newContractAddress = eventLog.
|
|
412
|
+
const newContractAddress = eventLog.args[eventValue];
|
|
404
413
|
|
|
405
414
|
return {
|
|
406
415
|
contractAddress: Utils.FormatAddress(newContractAddress),
|
package/src/FrameClient.js
CHANGED
|
@@ -243,7 +243,7 @@ class FrameClient {
|
|
|
243
243
|
"DeleteUserMetadata",
|
|
244
244
|
"MergeUserMetadata",
|
|
245
245
|
"ReplaceUserMetadata",
|
|
246
|
-
"UserMetadata"
|
|
246
|
+
"UserMetadata",
|
|
247
247
|
];
|
|
248
248
|
}
|
|
249
249
|
|
|
@@ -268,6 +268,13 @@ class FrameClient {
|
|
|
268
268
|
];
|
|
269
269
|
}
|
|
270
270
|
|
|
271
|
+
// List of methods that are defined separately in FrameClient
|
|
272
|
+
OverriddenMethods() {
|
|
273
|
+
return [
|
|
274
|
+
"UploadFiles"
|
|
275
|
+
];
|
|
276
|
+
}
|
|
277
|
+
|
|
271
278
|
// List of allowed methods available to frames
|
|
272
279
|
// This should match ElvClient.FrameAvailableMethods()
|
|
273
280
|
// ElvClient will also reject any disallowed methods
|
|
@@ -334,6 +341,7 @@ class FrameClient {
|
|
|
334
341
|
"CreateContentObject",
|
|
335
342
|
"CreateContentType",
|
|
336
343
|
"CreateEncryptionConk",
|
|
344
|
+
"CreateFabricToken",
|
|
337
345
|
"CreateFileDirectories",
|
|
338
346
|
"CreateFileUploadJob",
|
|
339
347
|
"CreateLinks",
|
|
@@ -377,6 +385,7 @@ class FrameClient {
|
|
|
377
385
|
"FinalizeUploadJob",
|
|
378
386
|
"FormatContractArguments",
|
|
379
387
|
"GenerateStateChannelToken",
|
|
388
|
+
"GenerateSignedLinkToken",
|
|
380
389
|
"GetBalance",
|
|
381
390
|
"InitializeAuthPolicy",
|
|
382
391
|
"IssueNTPCode",
|
|
@@ -440,7 +449,6 @@ class FrameClient {
|
|
|
440
449
|
"UpdateContentObjectGraph",
|
|
441
450
|
"UpdateNTPInstance",
|
|
442
451
|
"UploadFileData",
|
|
443
|
-
/*"UploadFiles",*/ //Override
|
|
444
452
|
"UploadFilesFromS3",
|
|
445
453
|
"UploadJobStatus",
|
|
446
454
|
"UploadPart",
|
|
@@ -2372,7 +2372,7 @@ exports.CreateEncryptionConk = async function({libraryId, objectId, versionHash,
|
|
|
2372
2372
|
});
|
|
2373
2373
|
|
|
2374
2374
|
if(existingUserCap) {
|
|
2375
|
-
this.encryptionConks[objectId] = await this.Crypto.DecryptCap(existingUserCap, this.signer.
|
|
2375
|
+
this.encryptionConks[objectId] = await this.Crypto.DecryptCap(existingUserCap, this.signer._signingKey().privateKey);
|
|
2376
2376
|
} else {
|
|
2377
2377
|
this.encryptionConks[objectId] = await this.Crypto.GeneratePrimaryConk({
|
|
2378
2378
|
spaceId: this.contentSpaceId,
|
|
@@ -2384,7 +2384,7 @@ exports.CreateEncryptionConk = async function({libraryId, objectId, versionHash,
|
|
|
2384
2384
|
objectId,
|
|
2385
2385
|
writeToken,
|
|
2386
2386
|
metadataSubtree: capKey,
|
|
2387
|
-
metadata: await this.Crypto.EncryptConk(this.encryptionConks[objectId], this.signer.
|
|
2387
|
+
metadata: await this.Crypto.EncryptConk(this.encryptionConks[objectId], this.signer._signingKey().publicKey)
|
|
2388
2388
|
});
|
|
2389
2389
|
}
|
|
2390
2390
|
|
|
@@ -2475,7 +2475,7 @@ exports.EncryptionConk = async function({libraryId, objectId, versionHash, write
|
|
|
2475
2475
|
});
|
|
2476
2476
|
|
|
2477
2477
|
if(existingUserCap) {
|
|
2478
|
-
this.encryptionConks[objectId] = await this.Crypto.DecryptCap(existingUserCap, this.signer.
|
|
2478
|
+
this.encryptionConks[objectId] = await this.Crypto.DecryptCap(existingUserCap, this.signer._signingKey().privateKey);
|
|
2479
2479
|
} else if(writeToken) {
|
|
2480
2480
|
await this.CreateEncryptionConk({libraryId, objectId, versionHash, writeToken, createKMSConk: false});
|
|
2481
2481
|
} else {
|
|
@@ -656,7 +656,7 @@ exports.CopyContentObject = async function({libraryId, originalVersionHash, opti
|
|
|
656
656
|
const userCapKey = `eluv.caps.iusr${this.utils.AddressToHash(this.signer.address)}`;
|
|
657
657
|
|
|
658
658
|
if(metadata[userCapKey]) {
|
|
659
|
-
const userConkKey = await this.Crypto.DecryptCap(metadata[userCapKey], this.signer.
|
|
659
|
+
const userConkKey = await this.Crypto.DecryptCap(metadata[userCapKey], this.signer._signingKey().privateKey);
|
|
660
660
|
userConkKey.qid = objectId;
|
|
661
661
|
|
|
662
662
|
await this.ReplaceMetadata({
|
|
@@ -664,7 +664,7 @@ exports.CopyContentObject = async function({libraryId, originalVersionHash, opti
|
|
|
664
664
|
objectId,
|
|
665
665
|
writeToken,
|
|
666
666
|
metadataSubtree: userCapKey,
|
|
667
|
-
metadata: await this.Crypto.EncryptConk(userConkKey, this.signer.
|
|
667
|
+
metadata: await this.Crypto.EncryptConk(userConkKey, this.signer._signingKey().publicKey)
|
|
668
668
|
});
|
|
669
669
|
}
|
|
670
670
|
|
|
@@ -709,7 +709,7 @@ exports.CreateNonOwnerCap = async function({objectId, libraryId, publicKey, writ
|
|
|
709
709
|
throw Error("No user cap found for current user");
|
|
710
710
|
}
|
|
711
711
|
|
|
712
|
-
const userConk = await this.Crypto.DecryptCap(userCapValue, this.signer.
|
|
712
|
+
const userConk = await this.Crypto.DecryptCap(userCapValue, this.signer._signingKey().privateKey);
|
|
713
713
|
|
|
714
714
|
const publicAddress = this.utils.PublicKeyToAddress(publicKey);
|
|
715
715
|
|
|
@@ -1052,7 +1052,7 @@ exports.PublishContentVersion = async function({objectId, versionHash, awaitComm
|
|
|
1052
1052
|
});
|
|
1053
1053
|
|
|
1054
1054
|
const confirmEvent = events.find(blockEvents =>
|
|
1055
|
-
blockEvents.find(event => objectHash === (event && event.
|
|
1055
|
+
blockEvents.find(event => objectHash === (event && event.args && event.args.objectHash))
|
|
1056
1056
|
);
|
|
1057
1057
|
|
|
1058
1058
|
if(confirmEvent) {
|
package/src/client/Contracts.js
CHANGED
|
@@ -455,7 +455,7 @@ exports.ExtractEventFromLogs = function({abi, event, eventName}) {
|
|
|
455
455
|
*/
|
|
456
456
|
exports.ExtractValueFromEvent = function({abi, event, eventName, eventValue}) {
|
|
457
457
|
const eventLog = this.ethClient.ExtractEventFromLogs({abi, event, eventName, eventValue});
|
|
458
|
-
return eventLog ? eventLog.
|
|
458
|
+
return eventLog ? eventLog.args[eventValue] : undefined;
|
|
459
459
|
};
|
|
460
460
|
|
|
461
461
|
exports.FormatBlockNumbers = async function({fromBlock, toBlock, count=10}) {
|