Files
go-nkode/core/constants.go
2024-10-19 16:36:47 -05:00

86 lines
4.0 KiB
Go

package core
import (
"errors"
"net/http"
)
var (
ErrInvalidNKodeLength = errors.New("invalid nKode length")
ErrInvalidNKodeIdx = errors.New("invalid passcode attribute index")
ErrTooFewDistinctSet = errors.New("too few distinct sets")
ErrTooFewDistinctAttributes = errors.New("too few distinct attributes")
ErrEmailAlreadySent = errors.New("email already sent")
ErrClaimExpOrNil = errors.New("claim expired or nil")
ErrInvalidJwt = errors.New("invalid jwt")
ErrInvalidKeypadDimensions = errors.New("keypad dimensions out of range")
ErrUserAlreadyExists = errors.New("user already exists")
ErrSignupSessionDNE = errors.New("signup session does not exist")
ErrUserForCustomerDNE = errors.New("user does not exist")
ErrRefreshTokenInvalid = errors.New("refresh token invalid")
ErrCustomerDne = errors.New("customer does not exist")
ErrSvgDne = errors.New("svg ")
ErrStoppingDatabase = errors.New("stopping database")
ErrSqliteTx = errors.New("sqlite begin, exec, query, or commit error. see logs")
ErrEmptySvgTable = errors.New("empty svg_icon table")
ErrKeyIndexOutOfRange = errors.New("one or more keys is out of range")
ErrAttributeIndexOutOfRange = errors.New("attribute index out of range")
ErrInternalValidKeyEntry = errors.New("internal validation error")
ErrUserMaskTooLong = errors.New("user mask length exceeds max nkode length")
ErrInterfaceNotDispersible = errors.New("interface is not dispersible")
ErrIncompleteUserSignupSession = errors.New("incomplete user signup session")
ErrSetConfirmSignupMismatch = errors.New("set and confirm nkode are not the same")
ErrKeypadIsNotDispersible = errors.New("keypad is not dispersible")
ErrInvalidNKode = errors.New("invalid nKode")
ErrStringIsNotAnSVG = errors.New("string is not an svg")
)
var HttpErrMap = map[error]int{
ErrInvalidNKodeLength: http.StatusBadRequest,
ErrInvalidNKodeIdx: http.StatusBadRequest,
ErrTooFewDistinctSet: http.StatusBadRequest,
ErrTooFewDistinctAttributes: http.StatusBadRequest,
ErrEmailAlreadySent: http.StatusBadRequest,
ErrClaimExpOrNil: http.StatusForbidden,
ErrInvalidJwt: http.StatusForbidden,
ErrInvalidKeypadDimensions: http.StatusBadRequest,
ErrUserAlreadyExists: http.StatusBadRequest,
ErrSignupSessionDNE: http.StatusBadRequest,
ErrUserForCustomerDNE: http.StatusBadRequest,
ErrRefreshTokenInvalid: http.StatusForbidden,
ErrCustomerDne: http.StatusBadRequest,
ErrSvgDne: http.StatusBadRequest,
ErrStoppingDatabase: http.StatusInternalServerError,
ErrSqliteTx: http.StatusInternalServerError,
ErrEmptySvgTable: http.StatusInternalServerError,
ErrKeyIndexOutOfRange: http.StatusBadRequest,
ErrAttributeIndexOutOfRange: http.StatusInternalServerError,
ErrInternalValidKeyEntry: http.StatusInternalServerError,
ErrUserMaskTooLong: http.StatusInternalServerError,
ErrInterfaceNotDispersible: http.StatusInternalServerError,
ErrIncompleteUserSignupSession: http.StatusBadRequest,
ErrSetConfirmSignupMismatch: http.StatusBadRequest,
ErrKeypadIsNotDispersible: http.StatusInternalServerError,
ErrInvalidNKode: http.StatusBadRequest,
ErrStringIsNotAnSVG: http.StatusInternalServerError,
}
var SetColors = []RGBColor{
{0, 0, 0}, // Black
{255, 0, 0}, // Red
{0, 128, 0}, // Dark Green
{0, 0, 255}, // Blue
{244, 200, 60}, // Yellow
{255, 0, 255}, // Magenta
{0, 200, 200}, // Cyan
{127, 0, 127}, // Purple
{232, 92, 13}, // Orange
{0, 127, 127}, // Teal
{127, 127, 0}, // Olive
{127, 0, 0}, // Dark Red
{128, 128, 128}, // Gray
{228, 102, 102}, // Dark Purple
{185, 17, 240}, // Salmon
{16, 200, 100}, // Green
}