diff --git a/flow.go b/flow.go index 0fa9432..6a2db4f 100644 --- a/flow.go +++ b/flow.go @@ -237,5 +237,14 @@ func (f *KeycardFlow) unpairThisFlow(kc *keycardContext) (FlowStatus, error) { return nil, err } - return nil, errors.New("not yet implemented") + err = kc.unpairCurrent() + + if isSCardError(err) { + return nil, restartErr() + } else if err != nil { + return nil, err + } + + f.cardInfo.freeSlots++ + return FlowStatus{InstanceUID: f.cardInfo.instanceUID, FreeSlots: f.cardInfo.freeSlots}, err } diff --git a/keycard_context.go b/keycard_context.go index 23d5eba..6abc801 100644 --- a/keycard_context.go +++ b/keycard_context.go @@ -360,6 +360,10 @@ func (kc *keycardContext) unpair(index uint8) error { return nil } +func (kc *keycardContext) unpairCurrent() error { + return kc.unpair(uint8(kc.cmdSet.PairingInfo.Index)) +} + func (kc *keycardContext) getStatusApplication() (*types.ApplicationStatus, error) { <-kc.connected if kc.runErr != nil {