Socket
Socket
Sign inDemoInstall

@metamask/eth-sig-util

Package Overview
Dependencies
Maintainers
9
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/eth-sig-util - npm Package Compare versions

Comparing version 5.0.2 to 5.0.3

10

dist/sign-typed-data.d.ts

@@ -157,2 +157,11 @@ /// <reference types="node" />

/**
* Create a EIP-712 Domain Hash.
* This hash is used at the top of the EIP-712 encoding.
*
* @param typedData - The typed message to hash.
* @param version - The EIP-712 version the encoding should comply with.
* @returns The hash of the domain object.
*/
declare function eip712DomainHash<T extends MessageTypes>(typedData: TypedMessage<T>, version: SignTypedDataVersion.V3 | SignTypedDataVersion.V4): Buffer;
/**
* Hash a typed message according to EIP-712. The returned message starts with the EIP-712 prefix,

@@ -181,2 +190,3 @@ * which is "1901", followed by the hash of the domain separator, then the data (if any).

eip712Hash: typeof eip712Hash;
eip712DomainHash: typeof eip712DomainHash;
};

@@ -183,0 +193,0 @@ /**

23

dist/sign-typed-data.js

@@ -198,3 +198,6 @@ "use strict";

validateVersion(version, [SignTypedDataVersion.V3, SignTypedDataVersion.V4]);
return (0, util_1.arrToBufArr)((0, keccak_1.keccak256)(encodeData(primaryType, data, types, version)));
const encoded = encodeData(primaryType, data, types, version);
const hashed = (0, keccak_1.keccak256)(encoded);
const buf = (0, util_1.arrToBufArr)(hashed);
return buf;
}

@@ -231,2 +234,17 @@ /**

/**
* Create a EIP-712 Domain Hash.
* This hash is used at the top of the EIP-712 encoding.
*
* @param typedData - The typed message to hash.
* @param version - The EIP-712 version the encoding should comply with.
* @returns The hash of the domain object.
*/
function eip712DomainHash(typedData, version) {
validateVersion(version, [SignTypedDataVersion.V3, SignTypedDataVersion.V4]);
const sanitizedData = sanitizeData(typedData);
const { domain } = sanitizedData;
const domainType = { EIP712Domain: sanitizedData.types.EIP712Domain };
return hashStruct('EIP712Domain', domain, domainType, version);
}
/**
* Hash a typed message according to EIP-712. The returned message starts with the EIP-712 prefix,

@@ -247,3 +265,3 @@ * which is "1901", followed by the hash of the domain separator, then the data (if any).

const parts = [Buffer.from('1901', 'hex')];
parts.push(hashStruct('EIP712Domain', sanitizedData.domain, sanitizedData.types, version));
parts.push(eip712DomainHash(typedData, version));
if (sanitizedData.primaryType !== 'EIP712Domain') {

@@ -267,2 +285,3 @@ parts.push(hashStruct(

eip712Hash,
eip712DomainHash,
};

@@ -269,0 +288,0 @@ /**

8

package.json
{
"name": "@metamask/eth-sig-util",
"version": "5.0.2",
"version": "5.0.3",
"description": "A few useful functions for signing ethereum data",

@@ -42,5 +42,5 @@ "keywords": [

"dependencies": {
"@ethereumjs/util": "^8.0.0",
"@ethereumjs/util": "^8.0.6",
"bn.js": "^4.11.8",
"ethereum-cryptography": "^1.1.2",
"ethereum-cryptography": "^2.0.0",
"ethjs-util": "^0.1.6",

@@ -52,3 +52,3 @@ "tweetnacl": "^1.0.3",

"@lavamoat/allow-scripts": "^2.0.3",
"@metamask/auto-changelog": "^2.6.1",
"@metamask/auto-changelog": "^3.1.0",
"@metamask/eslint-config": "^9.0.0",

@@ -55,0 +55,0 @@ "@metamask/eslint-config-jest": "^9.0.0",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc