@exodus/hw-ledger 2.9.3 → 2.9.5
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 +13 -0
- package/lib/atoms/index.d.ts +5 -1
- package/lib/atoms/index.js +3 -1
- package/lib/index.d.ts +6 -7
- package/lib/module/assets/applications.js +1 -1
- package/lib/module/assets/utils/xpub.js +1 -1
- package/lib/module/discovery.d.ts +6 -2
- package/lib/module/discovery.js +33 -2
- package/lib/plugin/index.d.ts +6 -7
- package/lib/plugin/index.js +3 -26
- package/lib/redux/index.d.ts +2 -2
- package/lib/redux/initial-state.d.ts +1 -4
- package/lib/redux/selectors/bluetoothStatus.d.ts +1 -1
- package/lib/redux/selectors/index.d.ts +1 -1
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
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
|
+
## [2.9.5](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@2.9.4...@exodus/hw-ledger@2.9.5) (2024-08-16)
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
- bluetooth on scan ([#8457](https://github.com/ExodusMovement/exodus-hydra/issues/8457)) ([c6cef7a](https://github.com/ExodusMovement/exodus-hydra/commit/c6cef7a19dad315bdbe8e01ea353f108348d48e3))
|
|
11
|
+
- use safe alloc ([#8467](https://github.com/ExodusMovement/exodus-hydra/issues/8467)) ([926ef36](https://github.com/ExodusMovement/exodus-hydra/commit/926ef36d1478e8fea290b56eabab5c807e7e6695))
|
|
12
|
+
|
|
13
|
+
## [2.9.4](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@2.9.3...@exodus/hw-ledger@2.9.4) (2024-08-14)
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
- EVM clear signing for NFTs ([#8402](https://github.com/ExodusMovement/exodus-hydra/issues/8402)) ([8fe5815](https://github.com/ExodusMovement/exodus-hydra/commit/8fe58152fdf12516cdf1f13fc3f91186eefd9028))
|
|
18
|
+
|
|
6
19
|
## [2.9.3](https://github.com/ExodusMovement/exodus-hydra/compare/@exodus/hw-ledger@2.9.2...@exodus/hw-ledger@2.9.3) (2024-08-08)
|
|
7
20
|
|
|
8
21
|
### Bug Fixes
|
package/lib/atoms/index.d.ts
CHANGED
|
@@ -1,7 +1,11 @@
|
|
|
1
|
+
export type BluetoothStatus = {
|
|
2
|
+
type: 'Unknown' | 'Resetting' | 'Unsupported' | 'Unauthorized' | 'PoweredOff' | 'PoweredOn';
|
|
3
|
+
available: boolean;
|
|
4
|
+
};
|
|
1
5
|
export declare const bluetoothStatusAtomDefinition: {
|
|
2
6
|
readonly id: "bluetoothStatusAtom";
|
|
3
7
|
readonly type: "atom";
|
|
4
|
-
readonly factory: () => import("@exodus/atoms").Atom<
|
|
8
|
+
readonly factory: () => import("@exodus/atoms").Atom<BluetoothStatus>;
|
|
5
9
|
readonly dependencies: readonly [];
|
|
6
10
|
readonly public: true;
|
|
7
11
|
};
|
package/lib/atoms/index.js
CHANGED
|
@@ -2,7 +2,9 @@ import { createInMemoryAtom } from '@exodus/atoms';
|
|
|
2
2
|
export const bluetoothStatusAtomDefinition = {
|
|
3
3
|
id: 'bluetoothStatusAtom',
|
|
4
4
|
type: 'atom',
|
|
5
|
-
factory: () => createInMemoryAtom({
|
|
5
|
+
factory: () => createInMemoryAtom({
|
|
6
|
+
defaultValue: { type: 'Unknown', available: false },
|
|
7
|
+
}),
|
|
6
8
|
dependencies: [],
|
|
7
9
|
public: true,
|
|
8
10
|
};
|
package/lib/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ declare const hardwareWalletLedger: ({ bluetoothScannerTimeout, }?: Partial<HwLe
|
|
|
5
5
|
readonly definition: {
|
|
6
6
|
readonly id: "bluetoothStatusAtom";
|
|
7
7
|
readonly type: "atom";
|
|
8
|
-
readonly factory: () => import("libraries/atoms/lib").Atom<
|
|
8
|
+
readonly factory: () => import("libraries/atoms/lib").Atom<import("./atoms").BluetoothStatus>;
|
|
9
9
|
readonly dependencies: readonly [];
|
|
10
10
|
readonly public: true;
|
|
11
11
|
};
|
|
@@ -21,18 +21,17 @@ declare const hardwareWalletLedger: ({ bluetoothScannerTimeout, }?: Partial<HwLe
|
|
|
21
21
|
readonly definition: {
|
|
22
22
|
readonly id: "hardwareWalletLedgerPlugin";
|
|
23
23
|
readonly type: "plugin";
|
|
24
|
-
readonly factory: ({
|
|
25
|
-
|
|
26
|
-
transportsFactories: import("./module/types").TransportFactories;
|
|
27
|
-
bluetoothStatusAtom: import("libraries/atoms/lib").Atom<import("./redux/initial-state").BluetoothStatus>;
|
|
24
|
+
readonly factory: ({ bluetoothStatusAtom, bluetoothScanningAtom, ledgerDiscovery, port, }: {
|
|
25
|
+
bluetoothStatusAtom: import("libraries/atoms/lib").Atom<import("./atoms").BluetoothStatus>;
|
|
28
26
|
bluetoothScanningAtom: import("libraries/atoms/lib").Atom<boolean>;
|
|
27
|
+
ledgerDiscovery: import("./module").LedgerDiscovery;
|
|
29
28
|
port: import("./shared/types").Port;
|
|
30
29
|
}) => {
|
|
31
30
|
onUnlock: () => void;
|
|
32
31
|
onLoad: () => void;
|
|
33
32
|
onStop: () => void;
|
|
34
33
|
};
|
|
35
|
-
readonly dependencies: readonly ["
|
|
34
|
+
readonly dependencies: readonly ["bluetoothStatusAtom", "bluetoothScanningAtom", "ledgerDiscovery", "port"];
|
|
36
35
|
readonly public: true;
|
|
37
36
|
};
|
|
38
37
|
}, {
|
|
@@ -40,7 +39,7 @@ declare const hardwareWalletLedger: ({ bluetoothScannerTimeout, }?: Partial<HwLe
|
|
|
40
39
|
readonly id: "ledgerDiscovery";
|
|
41
40
|
readonly type: "module";
|
|
42
41
|
readonly factory: (deps: import("./module").Dependencies) => import("./module").LedgerDiscovery;
|
|
43
|
-
readonly dependencies: readonly ["config", "logger", "transportsFactories", "bluetoothScanningAtom"];
|
|
42
|
+
readonly dependencies: readonly ["config", "logger", "transportsFactories", "bluetoothStatusAtom", "bluetoothScanningAtom"];
|
|
44
43
|
readonly public: true;
|
|
45
44
|
};
|
|
46
45
|
readonly config: {
|
|
@@ -2,7 +2,7 @@ import bs58check from 'bs58check';
|
|
|
2
2
|
export function buildFauxXPUB(publicKey, chainCode) {
|
|
3
3
|
const LEN = 78;
|
|
4
4
|
const XPUB_PREFIX = 0x04_88_b2_1e;
|
|
5
|
-
const buffer = Buffer.
|
|
5
|
+
const buffer = Buffer.alloc(LEN);
|
|
6
6
|
const fingerprint = 0x00_00_00_00;
|
|
7
7
|
const depth = 0;
|
|
8
8
|
const index = 0;
|
|
@@ -2,25 +2,29 @@ import { Logger } from '../shared/types';
|
|
|
2
2
|
import type { Atom } from '@exodus/atoms';
|
|
3
3
|
import type { HardwareWalletDescriptor, HardwareWalletDiscovery } from '@exodus/hw-common';
|
|
4
4
|
import type { HwLedgerConfig, TransportFactories } from './types';
|
|
5
|
+
import type { BluetoothStatus } from '../atoms';
|
|
5
6
|
export type Dependencies = {
|
|
6
7
|
config: HwLedgerConfig;
|
|
7
8
|
logger: Logger;
|
|
8
9
|
transportsFactories: TransportFactories;
|
|
10
|
+
bluetoothStatusAtom: Atom<BluetoothStatus>;
|
|
9
11
|
bluetoothScanningAtom: Atom<boolean>;
|
|
10
12
|
};
|
|
11
13
|
export declare class LedgerDiscovery implements HardwareWalletDiscovery {
|
|
12
14
|
#private;
|
|
13
|
-
constructor({ config, logger, transportsFactories, bluetoothScanningAtom }: Dependencies);
|
|
15
|
+
constructor({ config, logger, transportsFactories, bluetoothStatusAtom, bluetoothScanningAtom, }: Dependencies);
|
|
16
|
+
start: () => void;
|
|
14
17
|
scan: () => Promise<void>;
|
|
15
18
|
stopScan: (clearDevices?: boolean) => void;
|
|
16
19
|
list: () => Promise<HardwareWalletDescriptor[]>;
|
|
17
20
|
getFirstDevice: () => Promise<import("@exodus/hw-common").HardwareWalletDevice<import("@exodus/hw-common").Message>>;
|
|
21
|
+
stop: () => Promise<void>;
|
|
18
22
|
}
|
|
19
23
|
declare const _default: {
|
|
20
24
|
readonly id: "ledgerDiscovery";
|
|
21
25
|
readonly type: "module";
|
|
22
26
|
readonly factory: (deps: Dependencies) => LedgerDiscovery;
|
|
23
|
-
readonly dependencies: readonly ["config", "logger", "transportsFactories", "bluetoothScanningAtom"];
|
|
27
|
+
readonly dependencies: readonly ["config", "logger", "transportsFactories", "bluetoothStatusAtom", "bluetoothScanningAtom"];
|
|
24
28
|
readonly public: true;
|
|
25
29
|
};
|
|
26
30
|
export default _default;
|
package/lib/module/discovery.js
CHANGED
|
@@ -7,11 +7,14 @@ export class LedgerDiscovery {
|
|
|
7
7
|
#logger;
|
|
8
8
|
#transportsFactories;
|
|
9
9
|
#scannerTimeout;
|
|
10
|
+
#statusBluetooth;
|
|
11
|
+
#bluetoothStatusAtom;
|
|
10
12
|
#scannerBluetooth;
|
|
11
13
|
#bluetoothScanningAtom;
|
|
12
14
|
#discoveredBluetoothDevices = Object.create(null);
|
|
13
|
-
constructor({ config, logger, transportsFactories, bluetoothScanningAtom }) {
|
|
15
|
+
constructor({ config, logger, transportsFactories, bluetoothStatusAtom, bluetoothScanningAtom, }) {
|
|
14
16
|
this.#logger = logger;
|
|
17
|
+
this.#bluetoothStatusAtom = bluetoothStatusAtom;
|
|
15
18
|
this.#bluetoothScanningAtom = bluetoothScanningAtom;
|
|
16
19
|
if (!(typeof transportsFactories === 'object' &&
|
|
17
20
|
Object.keys(transportsFactories).length > 0 &&
|
|
@@ -26,7 +29,26 @@ export class LedgerDiscovery {
|
|
|
26
29
|
this.#transportsFactories = transportsFactories;
|
|
27
30
|
this.#scannerTimeout = config.bluetoothScannerTimeout;
|
|
28
31
|
}
|
|
32
|
+
start = () => {
|
|
33
|
+
if (!this.#transportsFactories.bluetooth)
|
|
34
|
+
return;
|
|
35
|
+
if (this.#statusBluetooth)
|
|
36
|
+
return;
|
|
37
|
+
if (this.#transportsFactories.bluetooth.observeState) {
|
|
38
|
+
this.#statusBluetooth = this.#transportsFactories.bluetooth.observeState({
|
|
39
|
+
next: ({ type, available }) => this.#bluetoothStatusAtom.set({ type, available }),
|
|
40
|
+
error: (error) => this.#logger.error(error),
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
else if (this.#transportsFactories.bluetooth.observeAvailability) {
|
|
44
|
+
this.#statusBluetooth = this.#transportsFactories.bluetooth.observeAvailability({
|
|
45
|
+
next: (available) => this.#bluetoothStatusAtom.set({ type: 'Unknown', available }),
|
|
46
|
+
error: (error) => this.#logger.error(error),
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
};
|
|
29
50
|
scan = async () => {
|
|
51
|
+
this.start();
|
|
30
52
|
return new Promise((resolve, reject) => {
|
|
31
53
|
if (this.#transportsFactories.bluetooth) {
|
|
32
54
|
this.stopScan(true);
|
|
@@ -123,12 +145,21 @@ export class LedgerDiscovery {
|
|
|
123
145
|
}
|
|
124
146
|
throw new NoDeviceFoundError();
|
|
125
147
|
};
|
|
148
|
+
stop = async () => {
|
|
149
|
+
this.#statusBluetooth?.unsubscribe();
|
|
150
|
+
};
|
|
126
151
|
}
|
|
127
152
|
const createLedgerDiscovery = (deps) => new LedgerDiscovery({ ...deps });
|
|
128
153
|
export default {
|
|
129
154
|
id: MODULE_ID,
|
|
130
155
|
type: 'module',
|
|
131
156
|
factory: createLedgerDiscovery,
|
|
132
|
-
dependencies: [
|
|
157
|
+
dependencies: [
|
|
158
|
+
'config',
|
|
159
|
+
'logger',
|
|
160
|
+
'transportsFactories',
|
|
161
|
+
'bluetoothStatusAtom',
|
|
162
|
+
'bluetoothScanningAtom',
|
|
163
|
+
],
|
|
133
164
|
public: true,
|
|
134
165
|
};
|
package/lib/plugin/index.d.ts
CHANGED
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
import type { Atom } from '@exodus/atoms';
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import {
|
|
2
|
+
import type { Port } from '../shared/types';
|
|
3
|
+
import type { BluetoothStatus } from '../atoms';
|
|
4
|
+
import type { LedgerDiscovery } from '../module';
|
|
5
5
|
declare const hardwareWalletLedgerPluginDefinition: {
|
|
6
6
|
readonly id: "hardwareWalletLedgerPlugin";
|
|
7
7
|
readonly type: "plugin";
|
|
8
|
-
readonly factory: ({
|
|
9
|
-
logger: Logger;
|
|
10
|
-
transportsFactories: TransportFactories;
|
|
8
|
+
readonly factory: ({ bluetoothStatusAtom, bluetoothScanningAtom, ledgerDiscovery, port, }: {
|
|
11
9
|
bluetoothStatusAtom: Atom<BluetoothStatus>;
|
|
12
10
|
bluetoothScanningAtom: Atom<boolean>;
|
|
11
|
+
ledgerDiscovery: LedgerDiscovery;
|
|
13
12
|
port: Port;
|
|
14
13
|
}) => {
|
|
15
14
|
onUnlock: () => void;
|
|
16
15
|
onLoad: () => void;
|
|
17
16
|
onStop: () => void;
|
|
18
17
|
};
|
|
19
|
-
readonly dependencies: readonly ["
|
|
18
|
+
readonly dependencies: readonly ["bluetoothStatusAtom", "bluetoothScanningAtom", "ledgerDiscovery", "port"];
|
|
20
19
|
readonly public: true;
|
|
21
20
|
};
|
|
22
21
|
export default hardwareWalletLedgerPluginDefinition;
|
package/lib/plugin/index.js
CHANGED
|
@@ -1,33 +1,16 @@
|
|
|
1
1
|
import { createAtomObserver } from '@exodus/atoms';
|
|
2
|
-
const createHardwareWalletLedgerPlugin = ({
|
|
3
|
-
let subscription;
|
|
2
|
+
const createHardwareWalletLedgerPlugin = ({ bluetoothStatusAtom, bluetoothScanningAtom, ledgerDiscovery, port, }) => {
|
|
4
3
|
const observers = [
|
|
5
4
|
createAtomObserver({ atom: bluetoothStatusAtom, port, event: 'bluetoothStatus' }),
|
|
6
5
|
createAtomObserver({ atom: bluetoothScanningAtom, port, event: 'bluetoothScanning' }),
|
|
7
6
|
];
|
|
8
7
|
observers.forEach((observer) => observer.register());
|
|
9
8
|
const start = () => {
|
|
10
|
-
if (!transportsFactories.bluetooth)
|
|
11
|
-
return;
|
|
12
|
-
if (subscription)
|
|
13
|
-
return;
|
|
14
|
-
if (transportsFactories.bluetooth.observeState) {
|
|
15
|
-
subscription = transportsFactories.bluetooth.observeState({
|
|
16
|
-
next: ({ type, available }) => bluetoothStatusAtom.set({ type, available }),
|
|
17
|
-
error: (error) => logger.error(error),
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
else if (transportsFactories.bluetooth.observeAvailability) {
|
|
21
|
-
subscription = transportsFactories.bluetooth.observeAvailability({
|
|
22
|
-
next: (available) => bluetoothStatusAtom.set({ type: 'Unknown', available }),
|
|
23
|
-
error: (error) => logger.error(error),
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
9
|
observers.forEach((observer) => observer.start());
|
|
27
10
|
};
|
|
28
11
|
const stop = () => {
|
|
29
12
|
observers.forEach((observer) => observer.unregister());
|
|
30
|
-
|
|
13
|
+
ledgerDiscovery.stop();
|
|
31
14
|
};
|
|
32
15
|
const onUnlock = () => {
|
|
33
16
|
start();
|
|
@@ -44,13 +27,7 @@ const hardwareWalletLedgerPluginDefinition = {
|
|
|
44
27
|
id: 'hardwareWalletLedgerPlugin',
|
|
45
28
|
type: 'plugin',
|
|
46
29
|
factory: createHardwareWalletLedgerPlugin,
|
|
47
|
-
dependencies: [
|
|
48
|
-
'logger',
|
|
49
|
-
'transportsFactories',
|
|
50
|
-
'bluetoothStatusAtom',
|
|
51
|
-
'bluetoothScanningAtom',
|
|
52
|
-
'port',
|
|
53
|
-
],
|
|
30
|
+
dependencies: ['bluetoothStatusAtom', 'bluetoothScanningAtom', 'ledgerDiscovery', 'port'],
|
|
54
31
|
public: true,
|
|
55
32
|
};
|
|
56
33
|
export default hardwareWalletLedgerPluginDefinition;
|
package/lib/redux/index.d.ts
CHANGED
|
@@ -10,12 +10,12 @@ declare const exchangeReduxDefinition: {
|
|
|
10
10
|
};
|
|
11
11
|
readonly bluetoothScanning: (state: LedgerHardwareWalletState, payload: boolean) => {
|
|
12
12
|
bluetoothScanning: boolean;
|
|
13
|
-
bluetoothStatus: import("
|
|
13
|
+
bluetoothStatus: import("../atoms").BluetoothStatus;
|
|
14
14
|
};
|
|
15
15
|
};
|
|
16
16
|
readonly selectorDefinitions: ({
|
|
17
17
|
readonly id: "bluetoothStatus";
|
|
18
|
-
readonly resultFunction: (state: LedgerHardwareWalletState) => import("
|
|
18
|
+
readonly resultFunction: (state: LedgerHardwareWalletState) => import("../atoms").BluetoothStatus;
|
|
19
19
|
readonly dependencies: readonly [{
|
|
20
20
|
readonly selector: string;
|
|
21
21
|
}];
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
type: 'Unknown' | 'Resetting' | 'Unsupported' | 'Unauthorized' | 'PoweredOff' | 'PoweredOn';
|
|
3
|
-
available: boolean;
|
|
4
|
-
};
|
|
1
|
+
import type { BluetoothStatus } from '../atoms';
|
|
5
2
|
export type LedgerHardwareWalletState = {
|
|
6
3
|
bluetoothStatus: BluetoothStatus;
|
|
7
4
|
bluetoothScanning: boolean;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { LedgerHardwareWalletState } from '../initial-state';
|
|
2
2
|
declare const bluetoothStatusSelectorDefinition: {
|
|
3
3
|
readonly id: "bluetoothStatus";
|
|
4
|
-
readonly resultFunction: (state: LedgerHardwareWalletState) => import("
|
|
4
|
+
readonly resultFunction: (state: LedgerHardwareWalletState) => import("../../atoms").BluetoothStatus;
|
|
5
5
|
readonly dependencies: readonly [{
|
|
6
6
|
readonly selector: string;
|
|
7
7
|
}];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
declare const ledgerSelectors: ({
|
|
2
2
|
readonly id: "bluetoothStatus";
|
|
3
|
-
readonly resultFunction: (state: import("../initial-state").LedgerHardwareWalletState) => import("
|
|
3
|
+
readonly resultFunction: (state: import("../initial-state").LedgerHardwareWalletState) => import("../../atoms").BluetoothStatus;
|
|
4
4
|
readonly dependencies: readonly [{
|
|
5
5
|
readonly selector: string;
|
|
6
6
|
}];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@exodus/hw-ledger",
|
|
3
|
-
"version": "2.9.
|
|
3
|
+
"version": "2.9.5",
|
|
4
4
|
"description": "The ledger module",
|
|
5
5
|
"author": "Exodus Movement, Inc.",
|
|
6
6
|
"repository": {
|
|
@@ -71,5 +71,5 @@
|
|
|
71
71
|
"tiny-secp256k1": "^2.2.3",
|
|
72
72
|
"ts-jest": "^29.0.3"
|
|
73
73
|
},
|
|
74
|
-
"gitHead": "
|
|
74
|
+
"gitHead": "6133e25d4d50f7737703294bdbb0699af419c0a7"
|
|
75
75
|
}
|