Socket
Socket
Sign inDemoInstall

eth-sig-util

Package Overview
Dependencies
44
Maintainers
2
Versions
30
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.2.1 to 1.2.2

19

index.js

@@ -15,5 +15,17 @@ const ethUtil = require('ethereumjs-util')

normalize: function (address) {
if (!address) return
return ethUtil.addHexPrefix(address.toLowerCase())
normalize: function (input) {
if (!input) return
if (typeof input === 'number') {
const buffer = ethUtil.toBuffer(input)
input = ethUtil.bufferToHex(buffer)
}
if (typeof input !== 'string') {
let msg = 'eth-sig-util.normalize() requires hex string or integer input.'
msg += ` received ${typeof input}: ${input}`
throw new Error(msg)
}
return ethUtil.addHexPrefix(input.toLowerCase())
},

@@ -44,3 +56,2 @@

function getPublicKeyFor (msgParams) {
let senderHex
const message = ethUtil.toBuffer(msgParams.data)

@@ -47,0 +58,0 @@ const msgHash = ethUtil.hashPersonalMessage(message)

{
"name": "eth-sig-util",
"version": "1.2.1",
"version": "1.2.2",
"description": "A few useful functions for signing ethereum data",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -19,2 +19,20 @@ const test = require('tape')

test('normalize an integer converts to byte-pair hex', function (t) {
t.plan(1)
const initial = 1
const result = sigUtil.normalize(initial)
t.equal(result, '0x01')
})
test('normalize an unsupported type throws', function (t) {
t.plan(1)
const initial = {}
try {
const result = sigUtil.normalize(initial)
t.ok(false, 'did not throw')
} catch (e) {
t.ok(e, 'should throw')
}
})
test('personalSign and recover', function (t) {

@@ -21,0 +39,0 @@ t.plan(1)

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc