@metamask-previews/eth-ledger-bridge-keyring 4.1.1-preview-7b3e0a5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/CHANGELOG.md +183 -0
  2. package/LICENSE +15 -0
  3. package/README.md +49 -0
  4. package/package.json +89 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,183 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [4.1.1]
11
+
12
+ ### Fixed
13
+
14
+ - The promise returned by the `init` method now resolves only after iframe has been loaded ([#236](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/236))
15
+ - `updateTransportMethod` will throw an error when called before `init`
16
+
17
+ ## [4.1.0]
18
+
19
+ ### Changed
20
+
21
+ - Refactor error message in `LedgerKeyring` ([#232](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/232))
22
+ - Extend `LedgerMobileBridge` type from `LedgerBridge` ([#233](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/233))
23
+ - Create new `MetaMaskLedgerHwAppEth` instance instead of re-using previous instance ([#231](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/231))
24
+
25
+ ## [4.0.0]
26
+
27
+ ### Added
28
+
29
+ - Add classes `LedgerMobileBridge`, `LedgerTransportMiddleware`, and `MetaMaskLedgerHwAppEth` to support Bluetooth as a HW Ledger Transport option ([#225](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/225))
30
+
31
+ ### Changed
32
+
33
+ - **BREAKING**: The `LedgerKeyring` method `setAccountToUnlock` now only accepts an input of type `number` ([#225](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/225))
34
+ - **BREAKING**: Removed the `chainCode` property from the `GetPublicKeyResponse` type ([#225](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/225))
35
+
36
+ ## [3.0.0]
37
+
38
+ ### Added
39
+
40
+ - Add `getOptions` and `setOptions` methods to `LedgerBridge` interface ([#210](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/210))
41
+
42
+ ### Changed
43
+
44
+ - **BREAKING**: `LedgerIframeBridge` class constructor now takes an options object with `bridgeUrl` ([#210](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/210))
45
+ - **BREAKING**: `LedgerBridge` `init` function now takes no parameters ([#210](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/210))
46
+ - **BREAKING**: `LedgerBridgeKeyringOptions` no longer contain `bridgeUrl` ([#210](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/210))
47
+ - **BREAKING**: `LedgerBridge` interface is now parameterized over its option type ([#210](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/210))
48
+ - Minor performance enhancement ([#211](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/211))
49
+
50
+ ### Fixed
51
+
52
+ - **BREAKING**: `IFrameMessageResponse` now has more restrictive typings (#207) ([#207](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/207))
53
+
54
+ ## [2.0.1]
55
+
56
+ ### Fixed
57
+
58
+ - Fix `invalid rlp data` error for legacy transactions in `2.0.0` ([#212](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/212))
59
+
60
+ ## [2.0.0]
61
+
62
+ ### Changed
63
+
64
+ - **BREAKING**: Remove support for major node versions 14,15,17,19. Minimum Node.js version is now 16. ([#204](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/204))
65
+ - Bump `@metamask/eth-sig-util` from `^6.0.1` to `^7.0.0` ([#205](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/205))
66
+
67
+ ### Fixed
68
+
69
+ - Move `@metamask/utils` from deendencies to devDependencies ([#209](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/209))
70
+
71
+ ## [1.0.1]
72
+
73
+ ### Fixed
74
+
75
+ - Bump dependency `hdkey` from `0.8.0` to `^2.1.0` ([#196](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/196))
76
+ - Replace dependency `eth-sig-util@^2` with `@metamask/eth-sig-util@^6` ([#157](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/157))
77
+ - Replace dependency `ethereumjs-util@^7.0.9` with `@ethereumjs/util@^8.0.0` and `@ethereumjs/rlp` ([#153](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/153))
78
+
79
+ ## [1.0.0]
80
+
81
+ ### Changed
82
+
83
+ - **BREAKING:** Separate the bridge from the keyring ([#156](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/156))
84
+ - The Ledger bridge is now a separate class (`LedgerIframeBridge`), which must be constructed separately from the keyring and passed in as a constructor argument.
85
+ - The bridge initialization has been moved from the keyring constructor to the keyring `init` method. The bridge is expected to be passed to the keyring uninitialized, and the keyring `init` method is expected to be called after keyring construction (before the keyring is used).
86
+ - The keyring constructor no longer accepts keyring state. Instead, any pre-existing keyring state should be passed to the `deserialize` method after construction.
87
+ - **BREAKING:** Export changed from default to named ([#174](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/174))
88
+ - The keyring is exported as `LedgerKeyring`
89
+ - Add TypeScript types ([#174](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/174))
90
+
91
+ ## [0.15.0]
92
+
93
+ ### Changed
94
+
95
+ - **BREAKING:** @ethereumjs/tx upgraded to major version 4, which includes a shift from storing numerical values as BNs to storing them as native BigInts. This is a breaking change for users of this keyring who access the values of the tx object, or that use those tx objects to interact with other libraries that depend on @ethereumsjs/tx versions under 4.0.0. ([#181](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/181))
96
+
97
+ ## [0.14.0]
98
+
99
+ ### Changed
100
+
101
+ - **BREAKING:** The minimum version of Node.js required for this package has been bumped to v14. ([#169](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/169))
102
+
103
+ ### Fixed
104
+
105
+ - Fix incorrect `v` for EIP-712 signatures and `personal_sign` ([#152](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/152))
106
+
107
+ ## [0.13.0]
108
+
109
+ ### Added
110
+
111
+ - hdk.publicKey and hdk.chainCode should not be updated when unlocking using hdPath for an account. ([#146](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/146))
112
+
113
+ ## [0.12.0]
114
+
115
+ ### Added
116
+
117
+ - Add a new `destroy` method which will remove the `message` event listener from window. ([#145](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/145))
118
+
119
+ ## [0.11.0]
120
+
121
+ ### Added
122
+
123
+ - Add a new `isConnected` method which allows determining if the device is last known to be connected. ([#131](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/131))
124
+
125
+ ### Changed
126
+
127
+ - Messaging now runs off of message IDs instead of assuming the response received is from the last message sent, which will not always been true. ([#132](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/132))
128
+
129
+ ## [0.10.0]
130
+
131
+ ### Added
132
+
133
+ - Add a new `attemptMakeApp` method which allows clients to attempt a creation of the Ledger transport for the purposes of detecting/catching potential connection errors. ([#126](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/126))
134
+
135
+ ## [0.9.0]
136
+
137
+ ### Changed
138
+
139
+ - `updateTransportMethod` no longer defaults its parameter to false, and now names the param sent with the `'ledger-update-transport'` message `transportType`. This better is to support the use of an enum, instead of a boolean, for specifying transport preferences. ([#114](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/114))
140
+
141
+ ## [0.8.0]
142
+
143
+ ### Added
144
+
145
+ - Allow ledger-bridge iframe to connect Ledger wia WebHID, when it is supported by the current browser ([#107](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/107))
146
+
147
+ ### Changed
148
+
149
+ - Reject with an Error object if unlocking is not successful ([#104](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/104))
150
+ - Ensure that logs of errors only have a single `Error:` string in the message ([#105](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/105))
151
+
152
+ ## [0.7.0]
153
+
154
+ ### Changed
155
+
156
+ - Remove unused `events` and `ethereumjs-tx` dependencies ([#101](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/101), [#102](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/102))
157
+ - Update eth-ledger-bridge-keyring to support EIP-1559 transactions ([#98](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/98), [#97](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/97), [#96](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/96))
158
+
159
+ ## [0.6.0]
160
+
161
+ ### Added
162
+
163
+ - Support new versions of ethereumjs/tx ([#68](https://github.com/MetaMask/eth-ledger-bridge-keyring/pull/68))
164
+
165
+ [Unreleased]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@4.1.1...HEAD
166
+ [4.1.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@4.1.0...@metamask/eth-ledger-bridge-keyring@4.1.1
167
+ [4.1.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@4.0.0...@metamask/eth-ledger-bridge-keyring@4.1.0
168
+ [4.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@3.0.0...@metamask/eth-ledger-bridge-keyring@4.0.0
169
+ [3.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@2.0.1...@metamask/eth-ledger-bridge-keyring@3.0.0
170
+ [2.0.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@2.0.0...@metamask/eth-ledger-bridge-keyring@2.0.1
171
+ [2.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@1.0.1...@metamask/eth-ledger-bridge-keyring@2.0.0
172
+ [1.0.1]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@1.0.0...@metamask/eth-ledger-bridge-keyring@1.0.1
173
+ [1.0.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@0.15.0...@metamask/eth-ledger-bridge-keyring@1.0.0
174
+ [0.15.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@0.14.0...@metamask/eth-ledger-bridge-keyring@0.15.0
175
+ [0.14.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@0.13.0...@metamask/eth-ledger-bridge-keyring@0.14.0
176
+ [0.13.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@0.12.0...@metamask/eth-ledger-bridge-keyring@0.13.0
177
+ [0.12.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@0.11.0...@metamask/eth-ledger-bridge-keyring@0.12.0
178
+ [0.11.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@0.10.0...@metamask/eth-ledger-bridge-keyring@0.11.0
179
+ [0.10.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@0.9.0...@metamask/eth-ledger-bridge-keyring@0.10.0
180
+ [0.9.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@0.8.0...@metamask/eth-ledger-bridge-keyring@0.9.0
181
+ [0.8.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@0.7.0...@metamask/eth-ledger-bridge-keyring@0.8.0
182
+ [0.7.0]: https://github.com/MetaMask/accounts/compare/@metamask/eth-ledger-bridge-keyring@0.6.0...@metamask/eth-ledger-bridge-keyring@0.7.0
183
+ [0.6.0]: https://github.com/MetaMask/accounts/releases/tag/@metamask/eth-ledger-bridge-keyring@0.6.0
package/LICENSE ADDED
@@ -0,0 +1,15 @@
1
+ ISC License
2
+
3
+ Copyright (c) 2020 MetaMask
4
+
5
+ Permission to use, copy, modify, and/or distribute this software for any
6
+ purpose with or without fee is hereby granted, provided that the above
7
+ copyright notice and this permission notice appear in all copies.
8
+
9
+ THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
10
+ WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
11
+ MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
12
+ ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
13
+ WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
14
+ ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
15
+ OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,49 @@
1
+ # eth-ledger-bridge-keyring [![CircleCI](https://circleci.com/gh/MetaMask/eth-ledger-bridge-keyring.svg?style=svg)](https://circleci.com/gh/MetaMask/eth-ledger-bridge-keyring)
2
+
3
+ An implementation of MetaMask's [Keyring interface](https://github.com/MetaMask/eth-simple-keyring#the-keyring-class-protocol), that uses a Ledger hardware wallet for all cryptographic operations.
4
+
5
+ In most regards, it works in the same way as
6
+ [eth-hd-keyring](https://github.com/MetaMask/eth-hd-keyring), but using a Ledger
7
+ device. However there are a number of differences:
8
+
9
+ - Because the keys are stored in the device, operations that rely on the device
10
+ will fail if there is no Ledger device attached, or a different Ledger device
11
+ is attached.
12
+
13
+ - It does not support the `signMessage`, `signTypedData` or `exportAccount`
14
+ methods, because Ledger devices do not support these operations.
15
+
16
+ - Because extensions have limited access to browser features, there's no easy way to interact wth the Ledger Hardware wallet from the MetaMask extension. This library implements a workaround to those restrictions by injecting (on demand) an iframe to the background page of the extension, (which is hosted [here](https://metamask.github.io/eth-ledger-bridge-keyring/index.html).
17
+
18
+ The iframe is allowed to interact with the Ledger device (since U2F requires SSL and the iframe is hosted under https) using the libraries from [LedgerJS](https://github.com/LedgerHQ/ledgerjs) _hw-app-eth_ and _hw-transport-u2f_ and establishes a two-way communication channel with the extension via postMessage.
19
+
20
+ The iframe code it's hosted in the same repo under the branch [gh-pages](https://github.com/MetaMask/eth-ledger-bridge-keyring/tree/gh-pages) and it's being served via github pages. In the future we might move it under the metamask.io domain.
21
+
22
+ ## Usage
23
+
24
+ In addition to all the known methods from the [Keyring class protocol](https://github.com/MetaMask/eth-simple-keyring#the-keyring-class-protocol),
25
+ there are a few others:
26
+
27
+ - **isUnlocked** : Returns true if we have the public key in memory, which allows to generate the list of accounts at any time
28
+
29
+ - **unlock** : Connects to the Ledger device and exports the extended public key, which is later used to read the available ethereum addresses inside the Ledger account.
30
+
31
+ - **setAccountToUnlock** : the index of the account that you want to unlock in order to use with the signTransaction and signPersonalMessage methods
32
+
33
+ - **getFirstPage** : returns the first ordered set of accounts from the Ledger account
34
+
35
+ - **getNextPage** : returns the next ordered set of accounts from the Ledger account based on the current page
36
+
37
+ - **getPreviousPage** : returns the previous ordered set of accounts from the Ledger account based on the current page
38
+
39
+ - **forgetDevice** : removes all the device info from memory so the next interaction with the keyring will prompt the user to connect the Ledger device and export the account information
40
+
41
+ ## Testing and Linting
42
+
43
+ Run `yarn test` to run the tests once. To run tests on file changes, run `yarn test:watch`.
44
+
45
+ Run `yarn lint` to run the linter, or run `yarn lint:fix` to run the linter and fix any automatically fixable issues.
46
+
47
+ ## Attributions
48
+
49
+ This code was inspired by [eth-ledger-keyring](https://github.com/jamespic/eth-ledger-keyring) and [eth-hd-keyring](https://github.com/MetaMask/eth-hd-keyring)
package/package.json ADDED
@@ -0,0 +1,89 @@
1
+ {
2
+ "name": "@metamask-previews/eth-ledger-bridge-keyring",
3
+ "version": "4.1.1-preview-7b3e0a5",
4
+ "description": "A MetaMask compatible keyring, for ledger hardware wallets",
5
+ "keywords": [
6
+ "ethereum",
7
+ "keyring",
8
+ "ledger",
9
+ "metamask"
10
+ ],
11
+ "homepage": "https://github.com/MetaMask/eth-ledger-bridge-keyring#readme",
12
+ "bugs": {
13
+ "url": "https://github.com/MetaMask/eth-ledger-bridge-keyring/issues"
14
+ },
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "https://github.com/MetaMask/eth-ledger-bridge-keyring.git"
18
+ },
19
+ "license": "ISC",
20
+ "author": "Bruno Barbieri",
21
+ "main": "dist/index.js",
22
+ "types": "dist/index.d.ts",
23
+ "files": [
24
+ "dist/"
25
+ ],
26
+ "scripts": {
27
+ "build": "tsc --build tsconfig.build.json",
28
+ "build:clean": "rimraf dist && yarn build",
29
+ "build:docs": "typedoc",
30
+ "build:force": "tsc --build tsconfig.build.json --force",
31
+ "changelog:update": "../../scripts/update-changelog.sh @metamask/eth-ledger-bridge-keyring",
32
+ "changelog:validate": "../../scripts/validate-changelog.sh @metamask/eth-ledger-bridge-keyring",
33
+ "prepack": "./scripts/prepack.sh",
34
+ "publish:preview": "yarn npm publish --tag preview",
35
+ "test": "jest && jest-it-up",
36
+ "test:clean": "jest --clearCache",
37
+ "test:verbose": "jest --verbose",
38
+ "test:watch": "jest --watch"
39
+ },
40
+ "dependencies": {
41
+ "@ethereumjs/rlp": "^4.0.0",
42
+ "@ethereumjs/tx": "^4.2.0",
43
+ "@ethereumjs/util": "^8.0.0",
44
+ "@ledgerhq/hw-app-eth": "6.26.1",
45
+ "@metamask/eth-sig-util": "^7.0.1",
46
+ "deepmerge": "^4.2.2",
47
+ "hdkey": "^2.1.0"
48
+ },
49
+ "devDependencies": {
50
+ "@ethereumjs/common": "^3.2.0",
51
+ "@lavamoat/allow-scripts": "^2.5.1",
52
+ "@ledgerhq/hw-transport": "^6.24.1",
53
+ "@ledgerhq/types-cryptoassets": "^7.6.0",
54
+ "@ledgerhq/types-devices": "^6.22.4",
55
+ "@metamask/auto-changelog": "^3.1.0",
56
+ "@metamask/utils": "^8.2.0",
57
+ "@types/ethereumjs-tx": "^1.0.1",
58
+ "@types/hdkey": "^2.0.1",
59
+ "@types/jest": "^28.1.6",
60
+ "@types/node": "^16.18.59",
61
+ "@types/web": "^0.0.69",
62
+ "depcheck": "^1.4.3",
63
+ "ethereumjs-tx": "^1.3.4",
64
+ "jest": "^28.1.3",
65
+ "jest-it-up": "^2.2.0",
66
+ "rimraf": "^4.1.2",
67
+ "ts-jest": "^28.0.7",
68
+ "ts-node": "^10.7.0",
69
+ "typedoc": "^0.23.15",
70
+ "typescript": "~4.8.4"
71
+ },
72
+ "engines": {
73
+ "node": "^18.18 || >=20"
74
+ },
75
+ "publishConfig": {
76
+ "access": "public",
77
+ "registry": "https://registry.npmjs.org/"
78
+ },
79
+ "lavamoat": {
80
+ "allowScripts": {
81
+ "@lavamoat/preinstall-always-fail": false,
82
+ "@ledgerhq/hw-app-eth>@ledgerhq/domain-service>eip55>keccak": false,
83
+ "ethereumjs-tx>ethereumjs-util>keccak": false,
84
+ "ethereumjs-tx>ethereumjs-util>secp256k1": false,
85
+ "hdkey>secp256k1": false,
86
+ "ethereumjs-tx>ethereumjs-util>ethereum-cryptography>keccak": false
87
+ }
88
+ }
89
+ }