status-keycard-go/flow_types.go

126 lines
2.9 KiB
Go
Raw Normal View History

package statuskeycardgo
2021-10-14 13:14:43 +03:00
type FlowType int
2021-10-18 10:19:09 +03:00
type FlowParams map[string]interface{}
type FlowStatus map[string]interface{}
2021-10-15 10:35:01 +03:00
type runState int
2021-10-14 13:14:43 +03:00
2021-10-18 15:47:27 +03:00
type restartError struct{}
2021-10-22 09:32:07 +03:00
type giveupError struct{}
2021-10-18 15:47:27 +03:00
func restartErr() (e *restartError) {
return &restartError{}
}
func (e *restartError) Error() string {
return "restart"
}
2021-10-22 09:32:07 +03:00
func giveupErr() (e *giveupError) {
return &giveupError{}
}
func (e *giveupError) Error() string {
return "giveup"
}
2021-10-14 13:14:43 +03:00
const (
2021-10-15 12:38:06 +03:00
GetAppInfo FlowType = iota
2021-10-15 10:35:01 +03:00
RecoverAccount
LoadAccount
Login
2021-10-22 11:36:25 +03:00
ExportPublic
2021-10-15 10:35:01 +03:00
Sign
2021-10-22 11:36:25 +03:00
ChangePIN
ChangePUK
ChangePairing
2021-10-15 10:35:01 +03:00
UnpairThis
UnpairOthers
DeleteAccountAndUnpair
2022-08-04 11:21:23 +02:00
StoreMetadata
GetMetadata
2021-10-14 13:14:43 +03:00
)
const (
2021-10-15 10:35:01 +03:00
Idle runState = iota
Running
Paused
Resuming
Cancelling
)
const (
2021-10-28 09:52:39 +03:00
FlowResult = "keycard.flow-result"
InsertCard = "keycard.action.insert-card"
CardInserted = "keycard.action.card-inserted"
SwapCard = "keycard.action.swap-card"
EnterPairing = "keycard.action.enter-pairing"
EnterPIN = "keycard.action.enter-pin"
EnterPUK = "keycard.action.enter-puk"
EnterNewPair = "keycard.action.enter-new-pairing"
EnterNewPIN = "keycard.action.enter-new-pin"
EnterNewPUK = "keycard.action.enter-new-puk"
EnterTXHash = "keycard.action.enter-tx-hash"
EnterPath = "keycard.action.enter-bip44-path"
EnterMnemonic = "keycard.action.enter-mnemonic"
2022-08-04 11:21:23 +02:00
EnterName = "keycard.action.enter-cardname"
EnterWallets = "keycard.action.enter-wallets"
2021-10-15 12:38:06 +03:00
)
const (
2021-10-20 11:44:57 +03:00
AppInfo = "application-info"
InstanceUID = "instance-uid"
FactoryReset = "factory reset"
KeyUID = "key-uid"
FreeSlots = "free-pairing-slots"
PINRetries = "pin-retries"
PUKRetries = "puk-retries"
PairingPass = "pairing-pass"
2021-10-22 09:32:07 +03:00
Paired = "paired"
2022-02-07 16:19:32 +01:00
NewPairing = "new-pairing-pass"
DefPairing = "KeycardDefaultPairing"
2021-10-20 11:44:57 +03:00
PIN = "pin"
2021-10-21 10:41:20 +03:00
NewPIN = "new-pin"
PUK = "puk"
NewPUK = "new-puk"
2021-10-21 09:09:20 +03:00
MasterKey = "master-key"
MasterAddr = "master-key-address"
2021-10-21 09:09:20 +03:00
WalleRootKey = "wallet-root-key"
WalletKey = "wallet-key"
EIP1581Key = "eip1581-key"
WhisperKey = "whisper-key"
EncKey = "encryption-key"
2021-10-22 11:49:55 +03:00
ExportedKey = "exported-key"
2021-10-22 09:32:07 +03:00
Mnemonic = "mnemonic"
2022-06-09 11:16:31 +02:00
MnemonicLen = "mnemonic-length"
MnemonicIdxs = "mnemonic-indexes"
2021-10-22 11:36:25 +03:00
TXHash = "tx-hash"
BIP44Path = "bip44-path"
TXSignature = "tx-signature"
2021-10-28 09:52:39 +03:00
Overwrite = "overwrite"
2022-08-04 11:21:23 +02:00
ResolveAddr = "resolve-addresses"
ExportMaster = "export-master-address"
ExportPriv = "export-private"
2022-08-04 11:21:23 +02:00
CardMeta = "card-metadata"
CardName = "card-name"
WalletPaths = "wallet-paths"
2021-10-20 11:44:57 +03:00
)
const (
maxPINRetries = 3
maxPUKRetries = 5
maxFreeSlots = 5
2022-06-09 11:16:31 +02:00
defMnemoLen = 12
2023-09-13 17:16:35 +02:00
defPINLen = 6
defPUKLen = 12
2021-10-14 13:14:43 +03:00
)
2021-10-21 08:48:51 +03:00
const (
masterPath = "m"
walletRoothPath = "m/44'/60'/0'/0"
walletPath = walletRoothPath + "/0"
eip1581Path = "m/43'/60'/1581'"
whisperPath = eip1581Path + "/0'/0"
encryptionPath = eip1581Path + "/1'/0"
)