Skip to content

Latest commit

 

History

History
 
 

hw-transport-mocker

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 

@ledgerhq/hw-transport-mocker

Library for Ledger Hardware Wallets.

Github, Ledger Devs Slack

API

Table of Contents

createTransportRecorder

decorate a real transport and proxy it to record the APDUs.

Parameters

  • DecoratedTransport Class<Transport<any>> : an actual transport class. Like @ledgerhq/hw-transport-webusb
  • recordStore RecordStore : a record store to record the apdu in.

Returns Class<Transport<any>>

createTransportReplayer

create a transport replayer with a record store.

Parameters

Returns Class<Transport<any>>

RecordStoreInvalidSynthax

thrown by the RecordStore.fromString parser.

Parameters

RecordStoreQueueEmpty

thrown by the replayer if the queue is empty

RecordStoreWrongAPDU

thrown by replayer if it meets an unexpected apdu

Parameters

RecordStoreRemainingAPDU

thrown by ensureQueueEmpty

Parameters

RecordStoreOptions

  • autoSkipUnknownApdu: smart mechanism that would skip an apdu un-recognize to the next one that does this is meant to be used when you have refactored/dropped some APDUs it will produces warnings for you to fix the APDUs queue
  • warning: allows to override the warning function (defaults to console.warn)

Properties

RecordStore

a RecordStore is a stateful object that represents a queue of APDUs. It is both used by replayer and recorder transports and is the basic for writing Ledger tests with a mock device.

Parameters

isEmpty

check if there is no more APDUs to replay

recordExchange

Record an APDU (used by createTransportRecorder)

Parameters

replayExchange

Replay an APDU (used by createTransportReplayer)

Parameters

Returns Buffer

ensureQueueEmpty

Check all APDUs was replayed. Throw if it's not the case.

toString

Print out the series of apdus

Returns string

fromString

Create a RecordStore by parsing a string (a series of => HEX\n<= HEX)

Parameters

Returns RecordStore