chore(@desktop/keycard): keyPairForAuthentication replaced by keyPairForProcessing

This commit is contained in:
Sale Djenic 2022-12-28 15:57:13 +01:00 committed by saledjenic
parent e34aac0a0f
commit 1bc9deef47
4 changed files with 20 additions and 63 deletions

View File

@ -158,7 +158,7 @@ proc preStateActivities[T](self: Module[T], currFlowType: FlowType, nextStateTyp
self.controller.setCurrentKeycardStateToLocked(flowEvent.instanceUID) self.controller.setCurrentKeycardStateToLocked(flowEvent.instanceUID)
if currFlowType == FlowType.Authentication: if currFlowType == FlowType.Authentication:
self.view.setLockedPropForKeyPairForAuthentication(nextStateType == StateType.MaxPinRetriesReached) self.view.setLockedPropForKeyPairForProcessing(nextStateType == StateType.MaxPinRetriesReached)
if currFlowType == FlowType.UnlockKeycard: if currFlowType == FlowType.UnlockKeycard:
if nextStateType == StateType.UnlockKeycardOptions: if nextStateType == StateType.UnlockKeycardOptions:
@ -353,7 +353,7 @@ proc prepareKeyPairItemForAuthentication[T](self: Module[T], keyUid: string) =
item.setImage("") item.setImage("")
item.setIcon("keycard") item.setIcon("keycard")
item.setPairType(KeyPairType.Unknown.int) item.setPairType(KeyPairType.Unknown.int)
self.view.setKeyPairForAuthentication(item) self.view.setKeyPairForProcessing(item)
method setKeyPairForProcessing*[T](self: Module[T], item: KeyPairItem) = method setKeyPairForProcessing*[T](self: Module[T], item: KeyPairItem) =
if item.isNil: if item.isNil:
@ -500,8 +500,9 @@ proc updateKeyPairItemIfDataAreKnown[T](self: Module[T], address: string, item:
return true return true
return false return false
method updateKeyPairForProcessing*[T](self: Module[T], cardMetadata: CardMetadata) = proc buildKeyPairItemBasedOnCardMetadata[T](self: Module[T], cardMetadata: CardMetadata):
var item = newKeyPairItem(keyUid = "", tuple[item: KeyPairItem, knownKeyPair: bool] =
result.item = newKeyPairItem(keyUid = "",
pubKey = "", pubKey = "",
locked = false, locked = false,
name = cardMetadata.name, name = cardMetadata.name,
@ -509,13 +510,16 @@ method updateKeyPairForProcessing*[T](self: Module[T], cardMetadata: CardMetadat
icon = "keycard", icon = "keycard",
pairType = KeyPairType.Unknown, pairType = KeyPairType.Unknown,
derivedFrom = "") derivedFrom = "")
var knownKeyPair = true result.knownKeyPair = true
for wa in cardMetadata.walletAccounts: for wa in cardMetadata.walletAccounts:
if self.updateKeyPairItemIfDataAreKnown(wa.address, item): if self.updateKeyPairItemIfDataAreKnown(wa.address, result.item):
continue continue
let balance = self.controller.getCurrencyBalanceForAddress(wa.address) let balance = self.controller.getCurrencyBalanceForAddress(wa.address)
knownKeyPair = false result.knownKeyPair = false
item.addAccount(newKeyPairAccountItem(name = "", wa.path, wa.address, pubKey = "", emoji = "", color = self.generateRandomColor(), icon = "wallet", balance)) result.item.addAccount(newKeyPairAccountItem(name = "", wa.path, wa.address, pubKey = "", emoji = "", color = self.generateRandomColor(), icon = "wallet", balance))
method updateKeyPairForProcessing*[T](self: Module[T], cardMetadata: CardMetadata) =
let(item, knownKeyPair) = self.buildKeyPairItemBasedOnCardMetadata(cardMetadata)
self.view.setKeyPairStoredOnKeycardIsKnown(knownKeyPair) self.view.setKeyPairStoredOnKeycardIsKnown(knownKeyPair)
self.view.setKeyPairForProcessing(item) self.view.setKeyPairForProcessing(item)

View File

@ -12,8 +12,6 @@ QtObject:
keyPairModel: KeyPairModel keyPairModel: KeyPairModel
keyPairModelVariant: QVariant keyPairModelVariant: QVariant
keyPairStoredOnKeycardIsKnown: bool keyPairStoredOnKeycardIsKnown: bool
keyPairForAuthentication: KeyPairItem
keyPairForAuthenticationVariant: QVariant
keyPairForProcessing: KeyPairItem keyPairForProcessing: KeyPairItem
keyPairForProcessingVariant: QVariant keyPairForProcessingVariant: QVariant
keycardData: string # used to temporary store the data coming from keycard, depends on current state different data may be stored keycardData: string # used to temporary store the data coming from keycard, depends on current state different data may be stored
@ -26,10 +24,6 @@ QtObject:
self.keyPairModel.delete self.keyPairModel.delete
if not self.keyPairModelVariant.isNil: if not self.keyPairModelVariant.isNil:
self.keyPairModelVariant.delete self.keyPairModelVariant.delete
if not self.keyPairForAuthentication.isNil:
self.keyPairForAuthentication.delete
if not self.keyPairForAuthenticationVariant.isNil:
self.keyPairForAuthenticationVariant.delete
if not self.keyPairForProcessing.isNil: if not self.keyPairForProcessing.isNil:
self.keyPairForProcessing.delete self.keyPairForProcessing.delete
if not self.keyPairForProcessingVariant.isNil: if not self.keyPairForProcessingVariant.isNil:
@ -127,23 +121,6 @@ QtObject:
proc setKeyPairStoredOnKeycardIsKnown*(self: View, value: bool) = proc setKeyPairStoredOnKeycardIsKnown*(self: View, value: bool) =
self.keyPairStoredOnKeycardIsKnown = value self.keyPairStoredOnKeycardIsKnown = value
proc getKeyPairForAuthentication*(self: View): QVariant {.slot.} =
if self.keyPairForAuthenticationVariant.isNil:
return newQVariant()
return self.keyPairForAuthenticationVariant
QtProperty[QVariant] keyPairForAuthentication:
read = getKeyPairForAuthentication
proc setKeyPairForAuthentication*(self: View, item: KeyPairItem) =
if self.keyPairForAuthentication.isNil:
self.keyPairForAuthentication = newKeyPairItem()
if self.keyPairForAuthenticationVariant.isNil:
self.keyPairForAuthenticationVariant = newQVariant(self.keyPairForAuthentication)
self.keyPairForAuthentication.setItem(item)
proc setLockedPropForKeyPairForAuthentication*(self: View, locked: bool) =
if self.keyPairForAuthentication.isNil:
return
self.keyPairForAuthentication.setLocked(locked)
proc getKeyPairForProcessing*(self: View): KeyPairItem = proc getKeyPairForProcessing*(self: View): KeyPairItem =
return self.keyPairForProcessing return self.keyPairForProcessing
proc getKeyPairForProcessingAsVariant*(self: View): QVariant {.slot.} = proc getKeyPairForProcessingAsVariant*(self: View): QVariant {.slot.} =
@ -158,6 +135,10 @@ QtObject:
if self.keyPairForProcessingVariant.isNil: if self.keyPairForProcessingVariant.isNil:
self.keyPairForProcessingVariant = newQVariant(self.keyPairForProcessing) self.keyPairForProcessingVariant = newQVariant(self.keyPairForProcessing)
self.keyPairForProcessing.setItem(item) self.keyPairForProcessing.setItem(item)
proc setLockedPropForKeyPairForProcessing*(self: View, locked: bool) =
if self.keyPairForProcessing.isNil:
return
self.keyPairForProcessing.setLocked(locked)
proc setPin*(self: View, value: string) {.slot.} = proc setPin*(self: View, value: string) {.slot.} =
self.delegate.setPin(value) self.delegate.setPin(value)

View File

@ -74,20 +74,6 @@ Item {
} }
} }
Component {
id: keyPairForAuthenticationComponent
KeyPairItem {
keyPairType: root.sharedKeycardModule.keyPairForAuthentication.pairType
keyPairPubKey: root.sharedKeycardModule.keyPairForAuthentication.pubKey
keyPairName: root.sharedKeycardModule.keyPairForAuthentication.name
keyPairIcon: root.sharedKeycardModule.keyPairForAuthentication.icon
keyPairImage: root.sharedKeycardModule.keyPairForAuthentication.image
keyPairDerivedFrom: root.sharedKeycardModule.keyPairForAuthentication.derivedFrom
keyPairAccounts: root.sharedKeycardModule.keyPairForAuthentication.accounts
keyPairCardLocked: root.sharedKeycardModule.keyPairForAuthentication.locked
}
}
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
anchors.topMargin: Style.current.xlPadding anchors.topMargin: Style.current.xlPadding
@ -192,8 +178,8 @@ Item {
} }
} }
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.authentication && if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.authentication &&
!!root.sharedKeycardModule.keyPairForAuthentication && !!root.sharedKeycardModule.keyPairForProcessing &&
root.sharedKeycardModule.keyPairForAuthentication.name !== "") { root.sharedKeycardModule.keyPairForProcessing.name !== "") {
if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted || if(root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.keycardInserted ||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.insertKeycard ||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.readingKeycard ||
@ -349,7 +335,7 @@ Item {
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinFailed || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinFailed ||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinInvalid || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.biometricsPinInvalid ||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeycard) {
return keyPairForAuthenticationComponent return keyPairForProcessingComponent
} }
} }
if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) { if (root.sharedKeycardModule.currentState.flowType === Constants.keycardSharedFlow.displayKeycardContent) {

View File

@ -77,20 +77,6 @@ Item {
} }
} }
Component {
id: keyPairForAuthenticationComponent
KeyPairItem {
keyPairType: root.sharedKeycardModule.keyPairForAuthentication.pairType
keyPairPubKey: root.sharedKeycardModule.keyPairForAuthentication.pubKey
keyPairName: root.sharedKeycardModule.keyPairForAuthentication.name
keyPairIcon: root.sharedKeycardModule.keyPairForAuthentication.icon
keyPairImage: root.sharedKeycardModule.keyPairForAuthentication.image
keyPairDerivedFrom: root.sharedKeycardModule.keyPairForAuthentication.derivedFrom
keyPairAccounts: root.sharedKeycardModule.keyPairForAuthentication.accounts
keyPairCardLocked: root.sharedKeycardModule.keyPairForAuthentication.locked
}
}
ColumnLayout { ColumnLayout {
anchors.fill: parent anchors.fill: parent
anchors.topMargin: Style.current.xlPadding anchors.topMargin: Style.current.xlPadding
@ -210,7 +196,7 @@ Item {
if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterPin || if (root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.enterPin ||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongPin || root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongPin ||
root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeychainPin) { root.sharedKeycardModule.currentState.stateType === Constants.keycardSharedState.wrongKeychainPin) {
return keyPairForAuthenticationComponent return keyPairForProcessingComponent
} }
} }