Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@aztec/typed-data

Package Overview
Dependencies
Maintainers
5
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@aztec/typed-data - npm Package Compare versions

Comparing version 1.0.2 to 1.1.0

54

lib/index.js

@@ -11,2 +11,10 @@ "use strict";

function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _nonIterableRest(); }
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance"); }
function _iterableToArrayLimit(arr, i) { if (!(Symbol.iterator in Object(arr) || Object.prototype.toString.call(arr) === "[object Arguments]")) { return; } var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
/**

@@ -18,2 +26,6 @@ * Module to construct ECDSA messages for structured data,

*/
var ethAbi = require('ethereumjs-abi');
var ethUtil = require('ethereumjs-util');
var AbiCoder = require('web3-eth-abi');

@@ -56,3 +68,4 @@

if (type.includes('[')) {
return "".concat(acc).concat(sliceKeccak256(AbiCoder.encodeParameter(type, message[name])));
var arrayRawEncoding = signer.encodeArray(type, message[name]);
return "".concat(acc).concat(arrayRawEncoding);
}

@@ -64,2 +77,31 @@

/**
* Encode an array, according to the method used by MetaMask. Code adapted from MetaMask's
* encodeData() method in the eth-sig-util module - https://github.com/MetaMask/eth-sig-util/blob/master/index.js
*
* @method encodeArray
* @param {String} type - type of the data structure to be encoded
* @param {Array} data - array data to be encoded
*/
signer.encodeArray = function encodeArray(type, data) {
var arrayElementAtomicType = type.slice(0, type.lastIndexOf('['));
var typeValuePairs = data.map(function (item) {
return [arrayElementAtomicType, item];
});
var arrayElementTypes = typeValuePairs.map(function (_ref2) {
var _ref3 = _slicedToArray(_ref2, 1),
individualType = _ref3[0];
return individualType;
});
var arrayValueTypes = typeValuePairs.map(function (_ref4) {
var _ref5 = _slicedToArray(_ref4, 2),
value = _ref5[1];
return value;
});
return ethUtil.sha3(ethAbi.rawEncode(arrayElementTypes, arrayValueTypes)).toString('hex');
};
/**
* Create 'type' component of a struct

@@ -78,4 +120,4 @@ *

var findTypes = function findTypes(type) {
return [type].concat(types[type].reduce(function (acc, _ref2) {
var typeKey = _ref2.type;
return [type].concat(types[type].reduce(function (acc, _ref6) {
var typeKey = _ref6.type;

@@ -95,5 +137,5 @@ if (types[typeKey] && acc.indexOf(typeKey) === -1) {

})).reduce(function (acc, key) {
return "".concat(acc).concat(key, "(").concat(types[key].reduce(function (iacc, _ref3) {
var name = _ref3.name,
type = _ref3.type;
return "".concat(acc).concat(key, "(").concat(types[key].reduce(function (iacc, _ref7) {
var name = _ref7.name,
type = _ref7.type;
return "".concat(iacc).concat(type, " ").concat(name, ",");

@@ -100,0 +142,0 @@ }, '').slice(0, -1), ")");

14

package.json
{
"name": "@aztec/typed-data",
"description": "JavaScript library for working with typed structured data as defined by EIP-712",
"version": "1.0.2",
"version": "1.1.0",
"author": "AZTEC",

@@ -10,3 +10,3 @@ "bugs": {

"dependencies": {
"web3-utils": "1.2.1"
"web3-utils": "1.2.4"
},

@@ -23,2 +23,3 @@ "devDependencies": {

"eslint-plugin-import": "^2.16.0",
"eth-sig-util": "^2.5.2",
"mocha": "^6.0.2",

@@ -50,9 +51,12 @@ "shx": "^0.3.2"

"scripts": {
"build:dev": "yarn clean && babel --copy-files --out-dir ./lib --root-mode upward ./src",
"build": "yarn clean && babel --copy-files --out-dir ./lib --root-mode upward ./src",
"build:prod": "yarn clean && babel --copy-files --out-dir ./lib --root-mode upward ./src",
"build:prod": "yarn build",
"clean": "shx rm -rf ./lib",
"lint": "eslint --ignore-path ../../.eslintignore .",
"has:changed": "bash ../monorepo-scripts/ci/hasChanged.sh typed-data",
"test": "mocha ./test --bail --colors --exit --recursive --reporter spec --timeout 0 --trace-warnings",
"watch": "yarn build --watch"
}
"watch": "yarn build:dev --watch"
},
"peerDependencies": {}
}
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