@metamask/eth-json-rpc-middleware
Advanced tools
Comparing version 15.0.1 to 15.1.0
@@ -9,2 +9,6 @@ # Changelog | ||
## [15.1.0] | ||
### Changed | ||
- Improved validation of primary type for signTypedDataV3 and signTypedDataV4 ([#350](https://github.com/MetaMask/eth-json-rpc-middleware/pull/350)) | ||
## [15.0.1] | ||
@@ -229,3 +233,4 @@ ### Changed | ||
[Unreleased]: https://github.com/MetaMask/eth-json-rpc-middleware/compare/v15.0.1...HEAD | ||
[Unreleased]: https://github.com/MetaMask/eth-json-rpc-middleware/compare/v15.1.0...HEAD | ||
[15.1.0]: https://github.com/MetaMask/eth-json-rpc-middleware/compare/v15.0.1...v15.1.0 | ||
[15.0.1]: https://github.com/MetaMask/eth-json-rpc-middleware/compare/v15.0.0...v15.0.1 | ||
@@ -232,0 +237,0 @@ [15.0.0]: https://github.com/MetaMask/eth-json-rpc-middleware/compare/v14.0.2...v15.0.0 |
@@ -31,2 +31,3 @@ "use strict"; | ||
const utils_1 = require("@metamask/utils"); | ||
const common_1 = require("./utils/common"); | ||
const normalize_1 = require("./utils/normalize"); | ||
@@ -124,2 +125,3 @@ function createWalletMiddleware({ getAccounts, processDecryptMessage, processEncryptionPublicKey, processPersonalMessage, processTransaction, processSignTransaction, processTypedMessage, processTypedMessageV3, processTypedMessageV4, }) { | ||
const message = (0, normalize_1.normalizeTypedMessage)(params[1]); | ||
validatePrimaryType(message); | ||
validateVerifyingContract(message); | ||
@@ -147,2 +149,3 @@ const version = 'V3'; | ||
const message = (0, normalize_1.normalizeTypedMessage)(params[1]); | ||
validatePrimaryType(message); | ||
validateVerifyingContract(message); | ||
@@ -276,2 +279,20 @@ const version = 'V4'; | ||
/** | ||
* Validates primary of typedSignMessage, to ensure that it's type definition is present in message. | ||
* | ||
* @param data - The data passed in typedSign request. | ||
*/ | ||
function validatePrimaryType(data) { | ||
const { primaryType, types } = (0, normalize_1.parseTypedMessage)(data); | ||
if (!types) { | ||
throw rpc_errors_1.rpcErrors.invalidInput(); | ||
} | ||
// Primary type can be an array. | ||
const baseType = (0, common_1.stripArrayTypeIfPresent)(primaryType); | ||
// Return if the base type is not defined in the types | ||
const baseTypeDefinitions = types[baseType]; | ||
if (!baseTypeDefinitions) { | ||
throw rpc_errors_1.rpcErrors.invalidInput(); | ||
} | ||
} | ||
/** | ||
* Validates verifyingContract of typedSignMessage. | ||
@@ -278,0 +299,0 @@ * |
{ | ||
"name": "@metamask/eth-json-rpc-middleware", | ||
"version": "15.0.1", | ||
"version": "15.1.0", | ||
"description": "Ethereum-related json-rpc-engine middleware.", | ||
@@ -5,0 +5,0 @@ "repository": { |
Sorry, the diff of this file is not supported yet
176228
55
1571