Skip to main content

Class: HWTransport

Transport defines the generic interface to share between node/u2f impl A Descriptor is a parametric type that is up to be determined for the implementation. it can be for instance an ID, an file path, a URL,...

Hierarchy

Constructors

constructor

new HWTransport()

Properties

_appAPIlock

_appAPIlock: null | string

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:150


_events

_events: EventEmitter

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:104


deviceModel

deviceModel: undefined | null | DeviceModel

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:43


exchangeAtomicImpl

exchangeAtomicImpl: (f: () => Promise<void | Buffer>) => Promise<void | Buffer>

Type declaration

▸ (f): Promise<void | Buffer>

Parameters
NameType
f() => Promise<void | Buffer>
Returns

Promise<void | Buffer>

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:148


exchangeBusyPromise

exchangeBusyPromise: undefined | null | Promise<void>

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:147


exchangeTimeout

exchangeTimeout: number

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:41


send

send: (cla: number, ins: number, p1: number, p2: number, data?: Buffer, statusList?: number[]) => Promise<Buffer>

Type declaration

▸ (cla, ins, p1, p2, data?, statusList?): Promise<Buffer>

wrapper on top of exchange to simplify work of the implementation.

Parameters
NameTypeDescription
clanumber
insnumber
p1number
p2number
data?Buffer
statusList?number[]is a list of accepted status code (shorts). [0x9000] by default
Returns

Promise<Buffer>

a Promise of response buffer

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:138


unresponsiveTimeout

unresponsiveTimeout: number

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:42


ErrorMessage_ListenTimeout

Static ErrorMessage_ListenTimeout: string

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:152


ErrorMessage_NoDeviceFound

Static ErrorMessage_NoDeviceFound: string

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:153


isSupported

Static Readonly isSupported: () => Promise<boolean>

Type declaration

▸ (): Promise<boolean>

Statically check if a transport is supported on the user's platform/browser.

Returns

Promise<boolean>

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:47


list

Static Readonly list: () => Promise<any[]>

Type declaration

▸ (): Promise<any[]>

List once all available descriptors. For a better granularity, checkout listen().

Example

TransportFoo.list().then(descriptors => ...)
Returns

Promise<any[]>

a promise of descriptors

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:54


listen

Static Readonly listen: (observer: Readonly<{ complete: () => unknown ; error: (e: unknown) => unknown ; next: (event: DescriptorEvent<any>) => unknown }>) => Subscription

Type declaration

▸ (observer): Subscription

Listen all device events for a given Transport. The method takes an Obverver of DescriptorEvent and returns a Subscription (according to Observable paradigm https://github.com/tc39/proposal-observable ) a DescriptorEvent is a { descriptor, type } object. type can be "add" or "remove" and descriptor is a value you can pass to open(descriptor). each listen() call will first emit all potential device already connected and then will emit events can come over times, for instance if you plug a USB device after listen() or a bluetooth device become discoverable.

Example

const sub = TransportFoo.listen({
next: e => {
if (e.type==="add") {
sub.unsubscribe();
const transport = await TransportFoo.open(e.descriptor);
...
}
},
error: error => {},
complete: () => {}
})
Parameters
NameTypeDescription
observerReadonly<{ complete: () => unknown ; error: (e: unknown) => unknown ; next: (event: DescriptorEvent<any>) => unknown }>is an object with a next, error and complete function (compatible with observer pattern)
Returns

Subscription

a Subscription object on which you can .unsubscribe() to stop listening descriptors.

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:75


open

Static Readonly open: (descriptor?: any, timeout?: number) => Promise<HWTransport>

Type declaration

▸ (descriptor?, timeout?): Promise<HWTransport>

attempt to create a Transport instance with potentially a descriptor.

Example

TransportFoo.open(descriptor).then(transport => ...)
Parameters
NameType
descriptor?any
timeout?number
Returns

Promise<HWTransport>

a Promise of Transport instance

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:84

Methods

close

close(): Promise<void>

close the exchange with the device.

Returns

Promise<void>

a Promise that ends when the transport is closed.

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:103


decorateAppAPIMethod

decorateAppAPIMethod<R, A>(methodName, f, ctx, scrambleKey): (...args: A) => Promise<R>

Type parameters

NameType
RR
Aextends any[]

Parameters

NameType
methodNamestring
f(...args: A) => Promise<R>
ctxany
scrambleKeystring

Returns

fn

▸ (...args): Promise<R>

Parameters
NameType
...argsA
Returns

Promise<R>

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:151


decorateAppAPIMethods

decorateAppAPIMethods(self, methods, scrambleKey): void

Parameters

NameType
selfRecord<string, any>
methodsstring[]
scrambleKeystring

Returns

void

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:149


emit

emit(event, ...args): void

Parameters

NameType
eventstring
...argsany

Returns

void

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:115


exchange

exchange(_apdu): Promise<Buffer>

low level api to communicate with the device This method is for implementations to implement but should not be directly called. Instead, the recommanded way is to use send() method

Parameters

NameType
_apduBuffer

Returns

Promise<Buffer>

a Promise of response data

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:92


off

off(eventName, cb): void

Stop listening to an event on an instance of transport.

Parameters

NameType
eventNamestring
cb(...args: any[]) => any

Returns

void

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:114


on

on(eventName, cb): void

Listen to an event on an instance of transport. Transport implementation can have specific events. Here is the common events:

  • "disconnect" : triggered if Transport is disconnected

Parameters

NameType
eventNamestring
cb(...args: any[]) => any

Returns

void

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:110


setDebugMode

setDebugMode(): void

Enable or not logs of the binary exchange

Returns

void

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:119


setExchangeTimeout

setExchangeTimeout(exchangeTimeout): void

Set a timeout (in milliseconds) for the exchange call. Only some transport might implement it. (e.g. U2F)

Parameters

NameType
exchangeTimeoutnumber

Returns

void

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:123


setExchangeUnresponsiveTimeout

setExchangeUnresponsiveTimeout(unresponsiveTimeout): void

Define the delay before emitting "unresponsive" on an exchange that does not respond

Parameters

NameType
unresponsiveTimeoutnumber

Returns

void

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:127


setScrambleKey

setScrambleKey(_key): void

set the "scramble key" for the next exchanges with the device. Each App can have a different scramble key and they internally will set it at instanciation.

Parameters

NameType
_keystring

Returns

void

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:98


create

Static create(openTimeout?, listenTimeout?): Promise<HWTransport>

create() allows to open the first descriptor available or throw if there is none or if timeout is reached. This is a light helper, alternative to using listen() and open() (that you may need for any more advanced usecase)

Example

TransportFoo.create().then(transport => ...)

Parameters

NameType
openTimeout?number
listenTimeout?number

Returns

Promise<HWTransport>

Defined in

node_modules/.pnpm/@ledgerhq+hw-transport@6.27.10/node_modules/@ledgerhq/hw-transport/lib/Transport.d.ts:146