mirror of
https://github.com/status-im/status-keycard-go.git
synced 2025-01-18 18:31:56 +00:00
implement delete flow
This commit is contained in:
parent
28232c5ed3
commit
5e24a8571d
46
flow.go
46
flow.go
@ -382,9 +382,51 @@ func (f *KeycardFlow) unpairThisFlow(kc *keycardContext) (FlowStatus, error) {
|
||||
}
|
||||
|
||||
func (f *KeycardFlow) unpairOthersFlow(kc *keycardContext) (FlowStatus, error) {
|
||||
return nil, errors.New("not implemented yet")
|
||||
err := f.openSCAndAuthenticate(kc, true)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
for i := 0; i < maxFreeSlots; i++ {
|
||||
if i == kc.cmdSet.PairingInfo.Index {
|
||||
continue
|
||||
}
|
||||
|
||||
err = f.unpair(kc, i)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f.cardInfo.freeSlots++
|
||||
}
|
||||
|
||||
return FlowStatus{InstanceUID: f.cardInfo.instanceUID, FreeSlots: f.cardInfo.freeSlots}, nil
|
||||
}
|
||||
|
||||
func (f *KeycardFlow) deleteUnpairFlow(kc *keycardContext) (FlowStatus, error) {
|
||||
return nil, errors.New("not implemented yet")
|
||||
err := f.openSCAndAuthenticate(kc, true)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
err = f.removeKey(kc)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f.cardInfo.keyUID = ""
|
||||
|
||||
err = f.unpairCurrent(kc)
|
||||
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f.cardInfo.freeSlots++
|
||||
|
||||
return FlowStatus{InstanceUID: f.cardInfo.instanceUID, KeyUID: f.cardInfo.keyUID, FreeSlots: f.cardInfo.freeSlots}, nil
|
||||
}
|
||||
|
@ -250,6 +250,26 @@ func (f *KeycardFlow) unpairCurrent(kc *keycardContext) error {
|
||||
return err
|
||||
}
|
||||
|
||||
func (f *KeycardFlow) unpair(kc *keycardContext, idx int) error {
|
||||
err := kc.unpair(uint8(idx))
|
||||
|
||||
if isSCardError(err) {
|
||||
return restartErr()
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (f *KeycardFlow) removeKey(kc *keycardContext) error {
|
||||
err := kc.removeKey()
|
||||
|
||||
if isSCardError(err) {
|
||||
return restartErr()
|
||||
}
|
||||
|
||||
return err
|
||||
}
|
||||
|
||||
func (f *KeycardFlow) exportKey(kc *keycardContext, path string, onlyPublic bool) (*KeyPair, error) {
|
||||
keyPair, err := kc.exportKey(true, false, onlyPublic, path)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user