* Check which transport protocols are supported by the browser and return the\r
* transport type according to the following priorities: Bluetooth, USB, HID.\r
*/\r
- static checkBrowserSupport (): void {\r
+ static get isUnsupported (): boolean {\r
console.log('Checking browser Ledger support...')\r
- if (typeof globalThis.navigator?.bluetooth?.getDevices === 'function') {\r
- this.DynamicTransport = TransportBLE\r
- }\r
if (typeof globalThis.navigator?.usb?.getDevices === 'function') {\r
this.DynamicTransport = TransportUSB\r
+ return false\r
+ }\r
+ if (typeof globalThis.navigator?.bluetooth?.getDevices === 'function') {\r
+ this.DynamicTransport = TransportBLE\r
+ return false\r
}\r
if (typeof globalThis.navigator?.hid?.getDevices === 'function') {\r
this.DynamicTransport = TransportHID\r
+ return false\r
}\r
+ return true\r
}\r
\r
/**\r
*/\r
static async create (): Promise<LedgerWallet> {\r
try {\r
+ if (this.isUnsupported) throw new Error('Browser is unsupported')\r
const id = await Entropy.create(16)\r
LedgerWallet.#isInternal = true\r
const wallet = new this(id)\r
await SafeWorker.request<boolean>({\r
store: 'Wallet',\r
method: 'destroy',\r
- name: this.id\r
+ names: this.id\r
})\r
} catch (err) {\r
console.error(err)\r
*/
export declare class LedgerWallet extends Wallet {
#private
- get listenTimeout (): 30000
- get openTimeout (): 3000
- get status (): DeviceStatus
- DynamicTransport: typeof TransportBLE | typeof TransportUSB | typeof TransportHID
- private constructor ()
+ static DynamicTransport: typeof TransportBLE | typeof TransportUSB | typeof TransportHID
+ static get listenTimeout (): 30000
+ static get openTimeout (): 3000
/**
* Check which transport protocols are supported by the browser and return the
* transport type according to the following priorities: Bluetooth, USB, HID.
*/
- static checkBrowserSupport (): typeof TransportBLE | typeof TransportUSB | typeof TransportHID
+ static get isUnsupported (): boolean
/**
* Creates a new Ledger hardware wallet communication layer by dynamically
* importing the ledger.js service.
* @returns {LedgerWallet} A wallet containing accounts and a Ledger device communication object
*/
static create (): Promise<LedgerWallet>
+ get status (): DeviceStatus
+ private constructor ()
/**
* Check if the Nano app is currently open and set device status accordingly.
*
* allow garbage collection.
*/
destroy (): Promise<void>
- init (): Promise<void>
/**
* Revokes permission granted by the user to access the Ledger device.
*
const rpc = new Rpc(env.NODE_URL ?? '', env.API_KEY_NAME)
-let isUnsupported = true
-try {
- LedgerWallet.checkBrowserSupport()
- isUnsupported = false
-} catch {}
-
/**
* HID interactions require user gestures, so to reduce clicks, the variables
* shared among tests like wallet and account are declared at the top-level.
*/
await Promise.all([
/* node:coverage disable */
- suite('Ledger hardware wallet', { skip: false || isNode || isUnsupported }, async () => {
+ suite('Ledger hardware wallet', { skip: false || isNode || LedgerWallet.isUnsupported }, async () => {
let wallet, account, openBlock, sendBlock, receiveBlock