eth-sig-util
Advanced tools
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) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
8777
157
0