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

@metamask/eth-ledger-bridge-keyring

Package Overview
Dependencies
Maintainers
7
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@metamask/eth-ledger-bridge-keyring - npm Package Compare versions

Comparing version 0.4.0 to 0.5.0

50

index.js

@@ -288,3 +288,3 @@ const { EventEmitter } = require('events')

} else {
reject(new Error(payload.error || 'Ledger: Uknown error while signing message'))
reject(new Error(payload.error || 'Ledger: Unknown error while signing message'))
}

@@ -313,4 +313,48 @@ })

signTypedData () {
throw new Error('Not supported on this device')
async signTypedData (withAccount, data, options = {}) {
const isV4 = options.version === 'V4'
if (!isV4) {
throw new Error('Ledger: Only version 4 of typed data signing is supported')
}
const {
domain,
types,
primaryType,
message,
} = sigUtil.TypedDataUtils.sanitizeData(data)
const domainSeparatorHex = sigUtil.TypedDataUtils.hashStruct('EIP712Domain', domain, types, isV4).toString('hex')
const hashStructMessageHex = sigUtil.TypedDataUtils.hashStruct(primaryType, message, types, isV4).toString('hex')
const hdPath = await this.unlockAccountByAddress(withAccount)
const { success, payload } = await new Promise((resolve) => {
this._sendMessage({
action: 'ledger-sign-typed-data',
params: {
hdPath,
domainSeparatorHex,
hashStructMessageHex,
},
},
(result) => resolve(result))
})
if (success) {
let v = payload.v - 27
v = v.toString(16)
if (v.length < 2) {
v = `0${v}`
}
const signature = `0x${payload.r}${payload.s}${v}`
const addressSignedWith = sigUtil.recoverTypedSignature_v4({
data,
sig: signature,
})
if (ethUtil.toChecksumAddress(addressSignedWith) !== ethUtil.toChecksumAddress(withAccount)) {
throw new Error('Ledger: The signature doesnt match the right address')
}
return signature
}
throw new Error(payload.error || 'Ledger: Unknown error while signing message')
}

@@ -317,0 +361,0 @@

4

package.json
{
"name": "@metamask/eth-ledger-bridge-keyring",
"version": "0.4.0",
"version": "0.5.0",
"description": "A MetaMask compatible keyring, for ledger hardware wallets",

@@ -41,3 +41,3 @@ "main": "index.js",

"dependencies": {
"eth-sig-util": "^1.4.2",
"eth-sig-util": "^2.0.0",
"ethereumjs-tx": "^1.3.4",

@@ -44,0 +44,0 @@ "ethereumjs-util": "^7.0.9",

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