@exodus/hw-ledger 1.1.0 → 1.3.0
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.
- package/CHANGELOG.md +14 -0
- package/lib/index.d.ts +12 -2
- package/lib/index.js +12 -2
- package/lib/{assets → module/assets}/bitcoin.d.ts +9 -2
- package/lib/{assets → module/assets}/ethereum.d.ts +2 -2
- package/lib/{assets → module/assets}/ethereum.js +1 -3
- package/lib/{assets → module/assets}/index.d.ts +4 -2
- package/lib/module/assets/index.js +15 -0
- package/lib/{assets → module/assets}/polygon.d.ts +1 -1
- package/lib/{assets → module/assets}/solana.d.ts +2 -2
- package/lib/{device.d.ts → module/device.d.ts} +3 -0
- package/lib/{device.js → module/device.js} +25 -6
- package/lib/{discovery.d.ts → module/discovery.d.ts} +2 -1
- package/lib/{discovery.js → module/discovery.js} +9 -2
- package/lib/{errors.d.ts → module/errors.d.ts} +4 -0
- package/lib/{errors.js → module/errors.js} +6 -0
- package/lib/module/index.d.ts +2 -0
- package/lib/module/index.js +2 -0
- package/package.json +8 -7
- package/lib/assets/index.js +0 -10
- /package/lib/{assets → module/assets}/bitcoin.js +0 -0
- /package/lib/{assets → module/assets}/polygon.js +0 -0
- /package/lib/{assets → module/assets}/solana.js +0 -0
- /package/lib/{assets → module/assets}/utils.d.ts +0 -0
- /package/lib/{assets → module/assets}/utils.js +0 -0
- /package/lib/{constants.d.ts → module/constants.d.ts} +0 -0
- /package/lib/{constants.js → module/constants.js} +0 -0
- /package/lib/{management → module/management}/application.d.ts +0 -0
- /package/lib/{management → module/management}/application.js +0 -0
- /package/lib/{types.d.ts → module/types.d.ts} +0 -0
- /package/lib/{types.js → module/types.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.3.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@1.2.0...@exodus/hw-ledger@1.3.0) (2023-11-28)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- add ability to retrieve supported, installed and useable assets ([#4901](https://github.com/ExodusMovement/exodus-hydra/issues/4901)) ([d821590](https://github.com/ExodusMovement/exodus-hydra/commit/d82159062aa497c1ae5bbe4362cce8a2aff0cc9c))
|
|
11
|
+
- add generic `Message` type in `SignMessageParams` ([#4895](https://github.com/ExodusMovement/exodus-hydra/issues/4895)) ([fb688ea](https://github.com/ExodusMovement/exodus-hydra/commit/fb688ea071c18a1a041bbd53869f7afdce2c0b1d))
|
|
12
|
+
- add ledger `getFirstDevice` helper ([#4897](https://github.com/ExodusMovement/exodus-hydra/issues/4897)) ([6a2b362](https://github.com/ExodusMovement/exodus-hydra/commit/6a2b362e69b46e0d19be80394ff6f5533f6139ba))
|
|
13
|
+
|
|
14
|
+
## [1.2.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@1.1.0...@exodus/hw-ledger@1.2.0) (2023-11-27)
|
|
15
|
+
|
|
16
|
+
### Features
|
|
17
|
+
|
|
18
|
+
- make hw-ledger a feature ([#4882](https://github.com/ExodusMovement/exodus-hydra/issues/4882)) ([33d93fb](https://github.com/ExodusMovement/exodus-hydra/commit/33d93fb0f4bb507e3788c0450a3e413e79815433))
|
|
19
|
+
|
|
6
20
|
## [1.1.0](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@1.0.0...@exodus/hw-ledger@1.1.0) (2023-08-21)
|
|
7
21
|
|
|
8
22
|
### Features
|
package/lib/index.d.ts
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
declare const hardwareWalletLedger: () => {
|
|
2
|
+
id: string;
|
|
3
|
+
definitions: {
|
|
4
|
+
definition: {
|
|
5
|
+
id: string;
|
|
6
|
+
type: string;
|
|
7
|
+
factory: (deps: import("./module").Dependencies) => import("./module").LedgerDiscovery;
|
|
8
|
+
dependencies: string[];
|
|
9
|
+
};
|
|
10
|
+
}[];
|
|
11
|
+
};
|
|
12
|
+
export default hardwareWalletLedger;
|
package/lib/index.js
CHANGED
|
@@ -1,2 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import ledgerDiscoveryDefinition from './module';
|
|
2
|
+
const hardwareWalletLedger = () => {
|
|
3
|
+
return {
|
|
4
|
+
id: 'hardwareWalletLedger',
|
|
5
|
+
definitions: [
|
|
6
|
+
{
|
|
7
|
+
definition: ledgerDiscoveryDefinition,
|
|
8
|
+
},
|
|
9
|
+
],
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export default hardwareWalletLedger;
|
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
import type Transport from '@ledgerhq/hw-transport';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
2
|
+
import type { Bytes, HardwareWalletAssetHandler } from '@exodus/hw-common';
|
|
3
|
+
export interface BitcoinMessage {
|
|
4
|
+
rawMessage?: Bytes;
|
|
5
|
+
bip322Message?: {
|
|
6
|
+
address: string;
|
|
7
|
+
message: Bytes;
|
|
8
|
+
};
|
|
9
|
+
}
|
|
10
|
+
declare function createHandler(transport: Transport): Promise<HardwareWalletAssetHandler<BitcoinMessage>>;
|
|
4
11
|
declare const metadata: {
|
|
5
12
|
applicationName: string;
|
|
6
13
|
supportedVersions: string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Transport from '@ledgerhq/hw-transport';
|
|
2
|
-
import type {
|
|
3
|
-
declare function createHandler(transport: Transport): Promise<
|
|
2
|
+
import type { HardwareWalletAssetHandler } from '@exodus/hw-common';
|
|
3
|
+
declare function createHandler(transport: Transport): Promise<HardwareWalletAssetHandler>;
|
|
4
4
|
declare const metadata: {
|
|
5
5
|
applicationName: string;
|
|
6
6
|
supportedVersions: string;
|
|
@@ -97,9 +97,7 @@ async function createHandler(transport) {
|
|
|
97
97
|
const { domainSeparator, hashStructMessage } = hashEIP712Message(message.EIP712Message);
|
|
98
98
|
return app.signEIP712HashedMessage(params.derivationPath, domainSeparator.toString('hex'), hashStructMessage.toString('hex'));
|
|
99
99
|
}
|
|
100
|
-
|
|
101
|
-
throw err;
|
|
102
|
-
}
|
|
100
|
+
throw err;
|
|
103
101
|
});
|
|
104
102
|
}
|
|
105
103
|
else {
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type Transport from '@ledgerhq/hw-transport';
|
|
2
|
-
import type {
|
|
3
|
-
type HandlerFactory = (transport: Transport) => Promise<
|
|
2
|
+
import type { HardwareWalletAssetHandler } from '@exodus/hw-common';
|
|
3
|
+
type HandlerFactory = (transport: Transport) => Promise<HardwareWalletAssetHandler>;
|
|
4
4
|
type AssetMetadata = {
|
|
5
5
|
applicationName: string;
|
|
6
6
|
supportedVersions: string;
|
|
7
7
|
handler: HandlerFactory;
|
|
8
8
|
};
|
|
9
9
|
export declare const assetApplications: Record<string, AssetMetadata>;
|
|
10
|
+
export declare const supportedBaseAssetNames: string[];
|
|
11
|
+
export declare const applicationNameToBaseAssetName: Record<string, string>;
|
|
10
12
|
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import bitcoin from './bitcoin';
|
|
2
|
+
import ethereum from './ethereum';
|
|
3
|
+
import polygon from './polygon';
|
|
4
|
+
import solana from './solana';
|
|
5
|
+
export const assetApplications = {
|
|
6
|
+
bitcoin,
|
|
7
|
+
ethereum,
|
|
8
|
+
polygon,
|
|
9
|
+
solana,
|
|
10
|
+
};
|
|
11
|
+
export const supportedBaseAssetNames = Object.keys(assetApplications);
|
|
12
|
+
export const applicationNameToBaseAssetName = Object.entries(assetApplications).reduce((mapping, [assetName, metadata]) => {
|
|
13
|
+
mapping[metadata.applicationName] = assetName;
|
|
14
|
+
return mapping;
|
|
15
|
+
}, Object.create(null));
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const metadata: {
|
|
2
2
|
applicationName: string;
|
|
3
3
|
supportedVersions: string;
|
|
4
|
-
handler: (transport: import("@ledgerhq/hw-transport").default) => Promise<import("
|
|
4
|
+
handler: (transport: import("@ledgerhq/hw-transport").default) => Promise<import("libraries/hw-common/lib").HardwareWalletAssetHandler<import("libraries/hw-common/lib").Message>>;
|
|
5
5
|
};
|
|
6
6
|
export default metadata;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type Transport from '@ledgerhq/hw-transport';
|
|
2
|
-
import type {
|
|
3
|
-
declare function createHandler(transport: Transport): Promise<
|
|
2
|
+
import type { HardwareWalletAssetHandler } from '@exodus/hw-common';
|
|
3
|
+
declare function createHandler(transport: Transport): Promise<HardwareWalletAssetHandler>;
|
|
4
4
|
declare const metadata: {
|
|
5
5
|
applicationName: string;
|
|
6
6
|
supportedVersions: string;
|
|
@@ -8,6 +8,9 @@ export type Dependencies = {
|
|
|
8
8
|
export declare class LedgerDevice implements HardwareWalletDevice {
|
|
9
9
|
#private;
|
|
10
10
|
constructor({ transportFactory, descriptor }: Dependencies);
|
|
11
|
+
listSupportedAssetNames: () => Promise<string[]>;
|
|
12
|
+
listInstalledAssetNames: () => Promise<string[]>;
|
|
13
|
+
listUseableAssetNames: () => Promise<string[]>;
|
|
11
14
|
getAddress: (params: GetAddressParams) => Promise<string>;
|
|
12
15
|
getXPub: (params: GetXPubParams) => Promise<string>;
|
|
13
16
|
getPublicKey: (params: GetPublicKeyParams) => Promise<Readonly<Uint8Array>>;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import semver from 'semver';
|
|
2
2
|
import { AssetUnsupportedError, DeviceLockedError, DeviceConnectionError, UserRefusedError, } from '@exodus/hw-common';
|
|
3
|
-
import { assetApplications } from './assets';
|
|
3
|
+
import { applicationNameToBaseAssetName, assetApplications, supportedBaseAssetNames, } from './assets';
|
|
4
4
|
import applicationFactory from './management/application';
|
|
5
5
|
import { UnsupportedVersionError } from './errors';
|
|
6
6
|
export class LedgerDevice {
|
|
@@ -69,6 +69,27 @@ export class LedgerDevice {
|
|
|
69
69
|
throw new UnsupportedVersionError(desiredApplicationInfo.version, supportedVersions);
|
|
70
70
|
}
|
|
71
71
|
};
|
|
72
|
+
listSupportedAssetNames = async () => {
|
|
73
|
+
return supportedBaseAssetNames;
|
|
74
|
+
};
|
|
75
|
+
listInstalledAssetNames = async () => {
|
|
76
|
+
const { name: applicationName } = await this.#getInformation();
|
|
77
|
+
if (applicationName !== 'BOLOS')
|
|
78
|
+
await this.#quitApplication();
|
|
79
|
+
const installedApplications = await this.#listApplications();
|
|
80
|
+
const installedAssets = [];
|
|
81
|
+
installedApplications.forEach(({ name: applicationName }) => {
|
|
82
|
+
const assetName = applicationNameToBaseAssetName[applicationName];
|
|
83
|
+
if (assetName)
|
|
84
|
+
installedAssets.push(assetName);
|
|
85
|
+
});
|
|
86
|
+
return installedAssets;
|
|
87
|
+
};
|
|
88
|
+
listUseableAssetNames = async () => {
|
|
89
|
+
const { name: applicationName } = await this.#getInformation();
|
|
90
|
+
const assetName = applicationNameToBaseAssetName[applicationName];
|
|
91
|
+
return assetName ? [assetName] : [];
|
|
92
|
+
};
|
|
72
93
|
getAddress = async (params) => {
|
|
73
94
|
await this.#ensureApplicationIsOpened(params.assetName);
|
|
74
95
|
return this.#runInSession(async (transport) => {
|
|
@@ -110,10 +131,10 @@ function transformToCommonError(_err) {
|
|
|
110
131
|
if (err.name === 'LockedDeviceError') {
|
|
111
132
|
return new DeviceLockedError();
|
|
112
133
|
}
|
|
113
|
-
|
|
134
|
+
if (err.name === 'UserRefusedOnDevice') {
|
|
114
135
|
return new UserRefusedError();
|
|
115
136
|
}
|
|
116
|
-
|
|
137
|
+
if ([
|
|
117
138
|
'HwTransportError',
|
|
118
139
|
'TransportError',
|
|
119
140
|
'TransportRaceCondition',
|
|
@@ -123,7 +144,5 @@ function transformToCommonError(_err) {
|
|
|
123
144
|
].includes(err.name)) {
|
|
124
145
|
return new DeviceConnectionError(err);
|
|
125
146
|
}
|
|
126
|
-
|
|
127
|
-
return err;
|
|
128
|
-
}
|
|
147
|
+
return err;
|
|
129
148
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import ExodusModule from '@exodus/module';
|
|
2
|
-
import { Logger } from '
|
|
2
|
+
import { Logger } from '../shared/types';
|
|
3
3
|
import type { HardwareWalletDescriptor, HardwareWalletDiscovery } from '@exodus/hw-common';
|
|
4
4
|
import type { TransportFactory } from './types';
|
|
5
5
|
export type Dependencies = {
|
|
@@ -14,6 +14,7 @@ export declare class LedgerDiscovery extends ExodusModule implements HardwareWal
|
|
|
14
14
|
#private;
|
|
15
15
|
constructor({ logger, transportsFactories }: Dependencies);
|
|
16
16
|
list: () => Promise<HardwareWalletDescriptor[]>;
|
|
17
|
+
getFirstDevice: () => Promise<import("@exodus/hw-common").HardwareWalletDevice>;
|
|
17
18
|
}
|
|
18
19
|
declare const _default: {
|
|
19
20
|
id: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import ExodusModule from '@exodus/module';
|
|
2
2
|
import { APDU_PORT } from './constants';
|
|
3
3
|
import { LedgerDevice } from './device';
|
|
4
|
-
import { UnknownTransportError } from './errors';
|
|
5
|
-
const MODULE_ID = '
|
|
4
|
+
import { NoDeviceFoundError, UnknownTransportError } from './errors';
|
|
5
|
+
const MODULE_ID = 'ledgerDiscovery';
|
|
6
6
|
export class LedgerDiscovery extends ExodusModule {
|
|
7
7
|
#transportsFactories;
|
|
8
8
|
constructor({ logger, transportsFactories }) {
|
|
@@ -48,6 +48,13 @@ export class LedgerDiscovery extends ExodusModule {
|
|
|
48
48
|
}
|
|
49
49
|
return descriptors;
|
|
50
50
|
};
|
|
51
|
+
getFirstDevice = async () => {
|
|
52
|
+
const devices = await this.list();
|
|
53
|
+
if (devices[0]) {
|
|
54
|
+
return devices[0].get();
|
|
55
|
+
}
|
|
56
|
+
throw new NoDeviceFoundError();
|
|
57
|
+
};
|
|
51
58
|
}
|
|
52
59
|
const createLedgerDiscovery = (deps) => new LedgerDiscovery({ ...deps });
|
|
53
60
|
export default {
|
|
@@ -3,6 +3,10 @@ export declare class UnknownTransportError extends HardwareWalletError {
|
|
|
3
3
|
name: string;
|
|
4
4
|
constructor(transportName?: string);
|
|
5
5
|
}
|
|
6
|
+
export declare class NoDeviceFoundError extends HardwareWalletError {
|
|
7
|
+
name: string;
|
|
8
|
+
constructor();
|
|
9
|
+
}
|
|
6
10
|
export declare class UnsupportedVersionError extends HardwareWalletError {
|
|
7
11
|
name: string;
|
|
8
12
|
constructor(actualVersion: string, supportedVersions: string);
|
|
@@ -5,6 +5,12 @@ export class UnknownTransportError extends HardwareWalletError {
|
|
|
5
5
|
super(`unknown transport type ${transportName || ''}`);
|
|
6
6
|
}
|
|
7
7
|
}
|
|
8
|
+
export class NoDeviceFoundError extends HardwareWalletError {
|
|
9
|
+
name = 'NoDeviceFoundError';
|
|
10
|
+
constructor() {
|
|
11
|
+
super(`unable to find a connected device`);
|
|
12
|
+
}
|
|
13
|
+
}
|
|
8
14
|
export class UnsupportedVersionError extends HardwareWalletError {
|
|
9
15
|
name = 'UnsupportedVersionError';
|
|
10
16
|
constructor(actualVersion, supportedVersions) {
|
package/package.json
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/hw-ledger",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
4
4
|
"description": "The ledger module",
|
|
5
5
|
"author": "Exodus Movement Inc.",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
8
8
|
"url": "git+https://github.com/ExodusMovement/exodus-hydra.git"
|
|
9
9
|
},
|
|
10
|
-
"homepage": "https://github.com/ExodusMovement/exodus-hydra/tree/master/
|
|
10
|
+
"homepage": "https://github.com/ExodusMovement/exodus-hydra/tree/master/features/hw-ledger",
|
|
11
11
|
"license": "UNLICENSED",
|
|
12
12
|
"bugs": {
|
|
13
13
|
"url": "https://github.com/ExodusMovement/exodus-hydra/issues?q=is%3Aissue+is%3Aopen+label%3Ahw-ledger"
|
|
14
14
|
},
|
|
15
|
+
"main": "lib/index.js",
|
|
15
16
|
"files": [
|
|
16
17
|
"lib",
|
|
17
18
|
"./README.md",
|
|
@@ -23,14 +24,14 @@
|
|
|
23
24
|
"clean": "tsc --build --clean",
|
|
24
25
|
"test": "jest --testMatch='**/*.unit.test.js' --coverageDirectory coverage/unit",
|
|
25
26
|
"zemu:install": "docker pull zondax/builder-zemu:speculos-745fe46f81cfc18114b94a37beaefb58a09c0fcd",
|
|
26
|
-
"test:integration
|
|
27
|
-
"coverage:merge": "istanbul-combine -p summary -r json-summary -r lcov coverage/integration/coverage-final.json coverage/unit/coverage-final.json",
|
|
27
|
+
"test:integration": "yarn zemu:install && jest --runInBand",
|
|
28
28
|
"lint": "eslint . --ignore-path ../../.gitignore",
|
|
29
29
|
"lint:fix": "yarn lint --fix"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
+
"@exodus/ethersproject-abi": "^5.4.2-exodus.2",
|
|
32
33
|
"@exodus/ethersproject-transactions": "^5.4.2-exodus.0",
|
|
33
|
-
"@exodus/hw-common": "^1.
|
|
34
|
+
"@exodus/hw-common": "^1.2.0",
|
|
34
35
|
"@exodus/secp256k1": "^4.0.2-exodus.0",
|
|
35
36
|
"@ledgerhq/hw-app-eth": "^6.33.6",
|
|
36
37
|
"@ledgerhq/hw-app-solana": "^7.0.10",
|
|
@@ -44,7 +45,7 @@
|
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
47
|
"@exodus/bip32": "^2.0.0",
|
|
47
|
-
"@exodus/module": "^1.2.
|
|
48
|
+
"@exodus/module": "^1.2.2",
|
|
48
49
|
"@ledgerhq/hw-transport-node-hid": "^6.27.17",
|
|
49
50
|
"@ledgerhq/hw-transport-node-speculos": "^6.27.16",
|
|
50
51
|
"@types/bs58": "^4.0.1",
|
|
@@ -61,5 +62,5 @@
|
|
|
61
62
|
"ts-jest": "^29.0.3",
|
|
62
63
|
"typescript": "^4.7.3"
|
|
63
64
|
},
|
|
64
|
-
"gitHead": "
|
|
65
|
+
"gitHead": "7406c4024c15818322f299ff30f2be0686ec3bd8"
|
|
65
66
|
}
|
package/lib/assets/index.js
DELETED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|