Skip to content

fix: support autoGetResponse option in card.transmit()#106

Merged
tomkp merged 1 commit intomasterfrom
fix/auto-get-response-105
Dec 29, 2025
Merged

fix: support autoGetResponse option in card.transmit()#106
tomkp merged 1 commit intomasterfrom
fix/auto-get-response-105

Conversation

@tomkp
Copy link
Owner

@tomkp tomkp commented Dec 29, 2025

Summary

The autoGetResponse option in TransmitOptions now works when passed directly to card.transmit():

// This now works!
const response = await card.transmit(apdu, { autoGetResponse: true });

Previously, users had to use the separate transmitWithAutoResponse() function.

Changes

  • Add CardWrapper class that wraps native cards to intercept transmit() calls
  • Devices class now wraps all connected cards with CardWrapper
  • Export CardWrapper and wrapCard for low-level API users who want this functionality
  • Update TransmitOptions.autoGetResponse documentation

How it works

When autoGetResponse: true is passed to transmit(), the wrapper delegates to transmitWithAutoResponse() which handles:

  • SW1=61: Sends GET RESPONSE to retrieve remaining data
  • SW1=6C: Retries with corrected Le value

Fixes #105

Test plan

  • Unit tests for card.transmit() with autoGetResponse: true
  • All existing tests pass (102 tests)

Add CardWrapper class that wraps native Card objects to intercept
transmit() calls and automatically handle T=0 protocol status words
(SW1=61, SW1=6C) when autoGetResponse option is set.

The Devices class now wraps all cards with CardWrapper, making the
autoGetResponse option work directly with card.transmit() instead of
requiring users to call transmitWithAutoResponse() separately.

Fixes #105
@tomkp tomkp merged commit 30f6add into master Dec 29, 2025
9 checks passed
@tomkp tomkp deleted the fix/auto-get-response-105 branch December 29, 2025 17:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

autoGetResponse option doesn't work when passed to card.transmit()

1 participant