reorganize code

This commit is contained in:
2024-08-23 10:18:39 -05:00
parent 6a56b2300a
commit dbc8ca3d29
20 changed files with 476 additions and 214 deletions

19
core/model/keypad_size.go Normal file
View File

@@ -0,0 +1,19 @@
package model
type KeypadSize struct {
AttrsPerKey int `json:"attrs_per_key"`
NumbOfKeys int `json:"numb_of_keys"`
}
func (kp *KeypadSize) TotalAttrs() int {
return kp.AttrsPerKey * kp.NumbOfKeys
}
func (kp *KeypadSize) IsDispersable() bool {
return kp.AttrsPerKey <= kp.NumbOfKeys
}
type EncipheredNKode struct {
Code string
Mask string
}

View File

@@ -0,0 +1,21 @@
package model
type NKodePolicy struct {
MaxNkodeLen int `json:"max_nkode_len"`
MinNkodeLen int `json:"min_nkode_len"`
DistinctSets int `json:"distinct_sets"`
DistinctAttributes int `json:"distinct_attributes"`
LockOut int `json:"lock_out"`
Expiration int `json:"expiration"` // seconds, -1 no expiration
}
func NewDefaultNKodePolicy() NKodePolicy {
return NKodePolicy{
MinNkodeLen: 4,
MaxNkodeLen: 10,
DistinctSets: 0,
DistinctAttributes: 4,
LockOut: 5,
Expiration: -1,
}
}

40
core/model/post.go Normal file
View File

@@ -0,0 +1,40 @@
package model
import "github.com/google/uuid"
type NewCustomerPost struct {
KeypadSize KeypadSize `json:"keypad_size"`
NKodePolicy NKodePolicy `json:"nkode_policy"`
}
type GenerateSignupInterfacePost struct {
CustomerId uuid.UUID `json:"customer_id"`
}
type SetNKodePost struct {
Username string `json:"username"`
CustomerId uuid.UUID `json:"customer_id"`
KeySelection []int `json:"key_selection"`
SessionId uuid.UUID `json:"session_id"`
}
type ConfirmNKodePost struct {
CustomerId uuid.UUID `json:"customer_id"`
KeySelection []int `json:"key_selection"`
SessionId uuid.UUID `json:"session_id"`
}
type GetLoginInterfacePost struct {
Username string `json:"username"`
CustomerId uuid.UUID `json:"customer_id"`
}
type LoginPost struct {
CustomerId uuid.UUID `json:"customer_id"`
Username string `json:"username"`
KeySelection []int `json:"key_selection"`
}
type RenewAttributesPost struct {
CustomerId uuid.UUID `json:"customer_id"`
}

20
core/model/response.go Normal file
View File

@@ -0,0 +1,20 @@
package model
import "github.com/google/uuid"
type CreateNewCustomerResp struct {
CustomerId uuid.UUID `json:"customer_id"`
}
type GenerateSignupInterfaceResp struct {
SessionId uuid.UUID `json:"session_id"`
UserInterface []int `json:"user_interface"`
}
type SetNKodeResp struct {
UserInterface []int `json:"user_interface"`
}
type GetLoginInterfaceResp struct {
UserInterface []int `json:"user_interface"`
}