diff --git a/ausweis-example/app/index.tsx b/ausweis-example/app/index.tsx index ade561a..efc878a 100644 --- a/ausweis-example/app/index.tsx +++ b/ausweis-example/app/index.tsx @@ -25,7 +25,7 @@ export default function App() { new AusweisAuthFlow({ debug: true, // Can set to true to allow simulator cards - allowSimulatorCard: false, + allowSimulatorCard: true, onEnterPin: ({ attemptsRemaining }) => { // Mock incorrect pin entry return attemptsRemaining === 1 ? '123456' : '123123' diff --git a/src/AusweisAuthFlow.ts b/src/AusweisAuthFlow.ts index 1e3aca0..4b4e5ac 100644 --- a/src/AusweisAuthFlow.ts +++ b/src/AusweisAuthFlow.ts @@ -246,16 +246,15 @@ export class AusweisAuthFlow { if (message.msg === 'READER') { // If card is empty object the card is unknown, we see that as no card attached for this flow const isSimulator = message.name === 'Simulator' + + // Return early if simulator not allowed. As we don't want to emit events related to that + if (isSimulator && !this.options.allowSimulatorCard) return + const isCardAttached = message.attached && (isSimulator || (message.card !== null && message.card !== undefined && Object.keys(message.card).length > 0)) if (isSimulator) this.isSimulatorCardAttached = isCardAttached - console.log({ - isCardAttached, - isSimulator, - isSimulatorCardAttached: this.isSimulatorCardAttached, - }) this.options.onCardAttachedChanged?.({ isCardAttached, @@ -270,11 +269,12 @@ export class AusweisAuthFlow { } if (message.msg === 'INSERT_CARD') { - if (this.options.allowSimulatorCard && this.isSimulatorCardAttached) { + if (this.options.allowSimulatorCard) { this.sendCommand({ cmd: 'SET_CARD', name: 'Simulator', }) + this.isSimulatorCardAttached = true return } this.options.onAttachCard?.()