Documentation ¶
Index ¶
- Constants
- Variables
- func CompareHashAndPassword(hashedPassword, password, salt []byte) bool
- func ContainsLowercase(s string) bool
- func ContainsNumber(s string) bool
- func ContainsSpecialChar(s string) bool
- func ContainsUppercase(s string) bool
- func ContainsWhitespace(s string) bool
- func GenerateOTP() ([]string, error)
- func GeneratePassword(n int) (string, error)
- func GenerateSalt(n int) (salt []byte, err error)
- func GenerateSlug(n int) (string, error)
- func GenerateUserCredentials(password []byte) (hash, salt []byte, err error)
- func HashToken(token string) []byte
- func HideEmail(email string) string
- func HidePhone(phone string) string
- func RespondWithError(c *fiber.Ctx, statusCode int, detail string, fieldErrors map[string][]string, ...) error
- type ErrorResponseBody
- type VaultsErrorResponseBody
Constants ¶
View Source
const ( AuthFirstFactor string = "auth_first_factor" AuthSecondFactor string = "auth_second_factor" CreateAccount string = "create_account" LogoutAccount string = "logout_account" TestAuthReq string = "test_auth_req" RetrieveUser string = "retrieve_user" VerifyEmailTry string = "verify_email_try" VerifyEmailConfirm string = "verify_email_confirm" VerifyPhoneTry string = "verify_phone_try" VerifyPhoneConfirm string = "verify_phone_confirm" // vaults CreateUser string = "create_user" CreateVault string = "create_vault" CreateEntry string = "create_entry" CreateSecret string = "create_secret" ListVaults string = "list_vaults" RetrieveVault string = "retrieve_vault" RetrieveEntry string = "retrieve_entry" UpdateVault string = "update_vault" UpdateEntry string = "update_entry" UpdateSecret string = "update_secret" MoveSecret string = "move_secret" DeleteVault string = "delete_vault" DeleteEntry string = "delete_entry" DeleteSecret string = "delete_secret" )
View Source
const ( ErrorBadRequest string = "Bad request." ErrorToken string = "Invalid token." ErrorMFAToken string = "Invalid MFA token." ErrorPhoneOTP string = "Invalid phone OTP." ErrorServer string = "Oops, something went wrong!" ErrorDiffEmail string = "Oops, failed to create account - try using a different email address or phone number." ErrorFailedLogin string = "Oops, failed to log in - try again!" ErrorAuthenticate string = "Oops, failed to authenticate - try again!" )
View Source
const ( ErrorClientOperation string = "Non-matching client operation header." ErrorParse string = "Failed to parse request body." ErrorAcctName string = "Invalid `name`." ErrorAcctEmail string = "Invalid `email`." ErrorAcctPW string = "Invalid `password`." ErrorAcctPhone string = "Invalid `phone_number`." ErrorNonMatchPW string = "Non-matching password inputs." ErrorCreateUser string = "Failed create user transaction." ErrorVaultsCreateUser string = "Failed vaults API create_user." ErrorVaultsCreateVault string = "Failed vaults API create_vault." ErrorVaultsListVaults string = "Failed vaults API list_vaults." ErrorVaultsRetrieveVault string = "Failed vaults API retrieve_vault." ErrorVaultsUpdateVault string = "Failed vaults API update_vault." ErrorVaultsDeleteVault string = "Failed vaults API delete_vault." ErrorVaultsCreateEntry string = "Failed vaults API create_entry." ErrorVaultsRetrieveEntry string = "Failed vaults API retrieve_entry." ErrorVaultsUpdateEntry string = "Failed vaults API update_entry." ErrorVaultsDeleteEntry string = "Failed vaults API delete_entry." ErrorVaultsCreateSecret string = "Failed vaults API create_secret." ErrorVaultsUpdateSecret string = "Failed vaults API update_secret." ErrorVaultsMoveSecret string = "Failed vaults API move_secret." ErrorVaultsDeleteSecret string = "Failed vaults API delete_secret." ErrorVaultsDeleteUser string = "Failed vaults API delete_user." ErrorFailedDB string = "Failed DB operation." ErrorNoRowsAffected string = "result.RowsAffected == 0" ErrorIPMismatch string = "Different IP addresses." ErrorBadClient string = "Client did something it shouldn't have." ErrorParams string = "Invalid URL parameters." ErrorUserContext string = "Invalid user context." ErrorAlreadyVerified string = "User already verified" )
View Source
const DIGITS string = "0123456789"
View Source
const LOWERCASE_LETTERS string = "abcdefghijklmnopqrstuvwxyz"
View Source
const OTP_ALPHABET = UPPERCASE_LETTERS + LOWERCASE_LETTERS + DIGITS
View Source
const PASSWORD_ALPHABET = OTP_ALPHABET + SPECIAL_CHARS
View Source
const SLUG_ALPHABET = OTP_ALPHABET + "_-"
View Source
const SPECIAL_CHARS string = "`~!@#$%^&*()-=_+,./<>?;':\"[]\\{}|"
View Source
const UPPERCASE_LETTERS string = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Variables ¶
View Source
var ( EmailRegexp = regexp.MustCompile("^[\u00BF-\u1FFF\u2C00-\uD7FF\\w\\.\\+\\-]+@[\u00BF-\u1FFF\u2C00-\uD7FF\\w\\-]+(\\.[\u00BF-\u1FFF\u2C00-\uD7FF\\w\\-]+)+$") NameRegexp = regexp.MustCompile(`^[\\u00BF-\\u1FFF\\u2C00-\\uD7FF\w \-\,\.\']{1,50}$`) PhoneRegexp = regexp.MustCompile(`^\+[1-9]\d{1,14}$`) HexEncodedKeyRegexp = regexp.MustCompile(`^[A-Fa-f0-9]{64}$`) SlugRegexp = regexp.MustCompile(`^[\w-]{16}$`) TokenRegexp = regexp.MustCompile(`^[\w-]{80}$`) RowsRegexp = regexp.MustCompile(`^result.RowsAffected \([0-9]+\) > 1$`) AuthHeaderRegexp = regexp.MustCompile(`^[Tt]oken [\w-]{80}$`) TokenNullRegexp = regexp.MustCompile(`^[Tt]oken (null)?$`) UniqueConstraintRegexp = regexp.MustCompile(`(UNIQUE constraint failed: users\.(email_address|phone_number)|ERROR: duplicate key value violates unique constraint "users_(email_address|phone_number)_key")`) )
Functions ¶
func CompareHashAndPassword ¶
func ContainsLowercase ¶
func ContainsNumber ¶
func ContainsSpecialChar ¶
func ContainsUppercase ¶
func ContainsWhitespace ¶
func GenerateOTP ¶
func GeneratePassword ¶
func GenerateSalt ¶
func GenerateSlug ¶
func GenerateUserCredentials ¶
Types ¶
type ErrorResponseBody ¶
Click to show internal directories.
Click to hide internal directories.