mirror of
https://github.com/status-im/status-keycard-go.git
synced 2025-01-19 02:42:50 +00:00
add login flow
This commit is contained in:
parent
f284636027
commit
22e2f8a743
@ -92,5 +92,6 @@ func main() {
|
|||||||
|
|
||||||
testFlow(skg.GetAppInfo, skg.FlowParams{})
|
testFlow(skg.GetAppInfo, skg.FlowParams{})
|
||||||
testFlow(skg.RecoverAccount, skg.FlowParams{skg.PIN: "234567"})
|
testFlow(skg.RecoverAccount, skg.FlowParams{skg.PIN: "234567"})
|
||||||
|
testFlow(skg.Login, skg.FlowParams{})
|
||||||
testFlow(skg.UnpairThis, skg.FlowParams{skg.PIN: correctPIN})
|
testFlow(skg.UnpairThis, skg.FlowParams{skg.PIN: correctPIN})
|
||||||
}
|
}
|
||||||
|
16
flow.go
16
flow.go
@ -216,7 +216,9 @@ func (f *KeycardFlow) connectedFlow() (FlowStatus, error) {
|
|||||||
case GetAppInfo:
|
case GetAppInfo:
|
||||||
return f.getAppInfoFlow(kc)
|
return f.getAppInfoFlow(kc)
|
||||||
case RecoverAccount:
|
case RecoverAccount:
|
||||||
return f.recoverAccountFlow(kc)
|
return f.exportKeysFlow(kc, true)
|
||||||
|
case Login:
|
||||||
|
return f.exportKeysFlow(kc, false)
|
||||||
case UnpairThis:
|
case UnpairThis:
|
||||||
return f.unpairThisFlow(kc)
|
return f.unpairThisFlow(kc)
|
||||||
default:
|
default:
|
||||||
@ -228,7 +230,7 @@ func (f *KeycardFlow) getAppInfoFlow(kc *keycardContext) (FlowStatus, error) {
|
|||||||
return FlowStatus{ErrorKey: ErrorOK, AppInfo: toAppInfo(kc.cmdSet.ApplicationInfo)}, nil
|
return FlowStatus{ErrorKey: ErrorOK, AppInfo: toAppInfo(kc.cmdSet.ApplicationInfo)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (f *KeycardFlow) recoverAccountFlow(kc *keycardContext) (FlowStatus, error) {
|
func (f *KeycardFlow) exportKeysFlow(kc *keycardContext, recover bool) (FlowStatus, error) {
|
||||||
err := f.requireKeys()
|
err := f.requireKeys()
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -241,7 +243,7 @@ func (f *KeycardFlow) recoverAccountFlow(kc *keycardContext) (FlowStatus, error)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
result := FlowStatus{}
|
result := FlowStatus{KeyUID: f.cardInfo.keyUID}
|
||||||
|
|
||||||
key, err := f.exportKey(kc, encryptionPath, false)
|
key, err := f.exportKey(kc, encryptionPath, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -255,6 +257,13 @@ func (f *KeycardFlow) recoverAccountFlow(kc *keycardContext) (FlowStatus, error)
|
|||||||
}
|
}
|
||||||
result[WhisperKey] = key
|
result[WhisperKey] = key
|
||||||
|
|
||||||
|
if recover {
|
||||||
|
key, err = f.exportKey(kc, eip1581Path, true)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
result[EIP1581Key] = key
|
||||||
|
|
||||||
key, err = f.exportKey(kc, walletRoothPath, true)
|
key, err = f.exportKey(kc, walletRoothPath, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@ -272,6 +281,7 @@ func (f *KeycardFlow) recoverAccountFlow(kc *keycardContext) (FlowStatus, error)
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
result[MasterKey] = key
|
result[MasterKey] = key
|
||||||
|
}
|
||||||
|
|
||||||
return result, nil
|
return result, nil
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user