-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(@desktop/keycard):
unlocking
screen for unlock flow
Closes: #9259
- Loading branch information
1 parent
841a37e
commit bc7a4b9
Showing
12 changed files
with
106 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
src/app/modules/shared_modules/keycard_popup/internal/unlock_keycard_failure_state.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
type | ||
UnlockKeycardFailureState* = ref object of State | ||
|
||
proc newUnlockKeycardFailureState*(flowType: FlowType, backState: State): UnlockKeycardFailureState = | ||
result = UnlockKeycardFailureState() | ||
result.setup(flowType, StateType.UnlockKeycardFailure, backState) | ||
|
||
proc delete*(self: UnlockKeycardFailureState) = | ||
self.State.delete | ||
|
||
method executePrePrimaryStateCommand*(self: UnlockKeycardFailureState, controller: Controller) = | ||
if self.flowType == FlowType.UnlockKeycard: | ||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) | ||
|
||
method executeCancelCommand*(self: UnlockKeycardFailureState, controller: Controller) = | ||
if self.flowType == FlowType.UnlockKeycard: | ||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = true) |
52 changes: 52 additions & 0 deletions
52
src/app/modules/shared_modules/keycard_popup/internal/unlocking_keycard_state.nim
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
type | ||
UnlockingKeycardState* = ref object of State | ||
|
||
proc newUnlockingKeycardState*(flowType: FlowType, backState: State): UnlockingKeycardState = | ||
result = UnlockingKeycardState() | ||
result.setup(flowType, StateType.UnlockingKeycard, backState) | ||
|
||
proc delete*(self: UnlockingKeycardState) = | ||
self.State.delete | ||
|
||
method executePrePrimaryStateCommand*(self: UnlockingKeycardState, controller: Controller) = | ||
if self.flowType == FlowType.UnlockKeycard: | ||
if controller.unlockUsingSeedPhrase(): | ||
controller.runGetMetadataFlow() | ||
else: | ||
let (_, flowEvent) = controller.getLastReceivedKeycardData() | ||
controller.updateKeycardUid(flowEvent.keyUid, flowEvent.instanceUID) | ||
|
||
method getNextPrimaryState*(self: UnlockingKeycardState, controller: Controller): State = | ||
if self.flowType == FlowType.UnlockKeycard: | ||
if not controller.unlockUsingSeedPhrase(): | ||
return createState(StateType.UnlockKeycardSuccess, self.flowType, nil) | ||
|
||
method resolveKeycardNextState*(self: UnlockingKeycardState, keycardFlowType: string, keycardEvent: KeycardEvent, | ||
controller: Controller): State = | ||
let state = ensureReaderAndCardPresence(self, keycardFlowType, keycardEvent, controller) | ||
if not state.isNil: | ||
return state | ||
if self.flowType == FlowType.UnlockKeycard: | ||
if controller.unlockUsingSeedPhrase(): | ||
if controller.getCurrentKeycardServiceFlow() == KCSFlowType.GetMetadata: | ||
controller.setMetadataFromKeycard(keycardEvent.cardMetadata) | ||
if keycardFlowType == ResponseTypeValueKeycardFlowResult: | ||
if keycardEvent.error.len == 0: | ||
controller.runLoadAccountFlow(controller.getSeedPhraseLength(), controller.getSeedPhrase(), controller.getPin(), puk = "", | ||
factoryReset = true) | ||
return | ||
if controller.getCurrentKeycardServiceFlow() == KCSFlowType.LoadAccount: | ||
if keycardFlowType == ResponseTypeValueKeycardFlowResult: | ||
if controller.getKeyPairForProcessing().getKeyUid() != keycardEvent.keyUid: | ||
error "load account keyUid and keyUid being unlocked do not match" | ||
controller.terminateCurrentFlow(lastStepInTheCurrentFlow = false) | ||
return | ||
controller.updateKeycardUid(keycardEvent.keyUid, keycardEvent.instanceUID) | ||
let md = controller.getMetadataFromKeycard() | ||
let paths = md.walletAccounts.map(a => a.path) | ||
controller.runStoreMetadataFlow(cardName = md.name, pin = controller.getPin(), walletPaths = paths) | ||
if controller.getCurrentKeycardServiceFlow() == KCSFlowType.StoreMetadata: | ||
if keycardFlowType == ResponseTypeValueKeycardFlowResult and | ||
keycardEvent.instanceUID.len > 0: | ||
return createState(StateType.UnlockKeycardSuccess, self.flowType, nil) | ||
return createState(StateType.UnlockKeycardFailure, self.flowType, nil) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters