helper

package
v0.0.0-...-31bdd97 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: Unlicense Imports: 31 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ArrayInterfaceContains

func ArrayInterfaceContains(arr []interface{}, str string) bool

func ArrayStringContains

func ArrayStringContains(arr []string, str string) bool

func CompareArgon2id

func CompareArgon2id(inputPassword, salt, storedHash string) bool

func ComparePassword

func ComparePassword(hashedPassword, password string) bool

func DecryptAES256CBC

func DecryptAES256CBC(encrypted *EncryptedData, key []byte) (string, error)

func DiscordLogger

func DiscordLogger(logTypeParam, titleParam, messageParam, serviceParam string, detailParam map[string]interface{})

func GenerateHMAC

func GenerateHMAC(iv, ciphertext, key []byte) []byte

func GenerateHS256Token

func GenerateHS256Token(secret, key, userID string, data interface{}, duration time.Time) string

func GenerateIV

func GenerateIV() ([]byte, error)

func GenerateRS512Token

func GenerateRS512Token(privateKey, key, userID string, data interface{}, duration time.Time) string

func HashArgon2id

func HashArgon2id(password, salt string) string

func InitApp

func InitApp() error

func IsUUID

func IsUUID(uuid string) bool

func IsValidDeviceCategory

func IsValidDeviceCategory(deviceCategory string) bool

func IsValidDeviceType

func IsValidDeviceType(deviceType string) bool

func JSONMarshal

func JSONMarshal(data interface{}) string

func JSONPrettyLog

func JSONPrettyLog(v interface{})

func JSONUnmarshal

func JSONUnmarshal(data []byte, v interface{}) error

func PKCS7Pad

func PKCS7Pad(data []byte, blockSize int) []byte

func PKCS7Unpad

func PKCS7Unpad(data []byte) ([]byte, error)

func RandomInt

func RandomInt(min int, max int) int

func RandomString

func RandomString(length int) string

func SendResponse

func SendResponse(baseResponse ResponseStruct) (err error)

func Validate

func Validate(body reflect.Type, errors error) interface{}

func ValidateHS256Token

func ValidateHS256Token(secret, token string) (*jwt.Token, error)

func ValidateRS512Token

func ValidateRS512Token(publicKey, token string) (*jwt.Token, error)

func VerifyHMAC

func VerifyHMAC(iv, ciphertext, key []byte, mac string) bool

Types

type BaseResponse

type BaseResponse struct {
	XMLName    xml.Name    `json:"-" xml:"response"`
	StatusCode int         `json:"status_code" xml:"status_code"`
	Message    string      `json:"message" xml:"message"`
	Error      interface{} `json:"error" xml:"error"`
	Data       interface{} `json:"data" xml:"data"`
}

type EncryptedData

type EncryptedData struct {
	IV    string `json:"iv"`
	Value string `json:"value"`
	MAC   string `json:"mac"`
	Tag   string `json:"tag"`
}

func EncryptAES256CBC

func EncryptAES256CBC(plaintext, key []byte) (*EncryptedData, error)

type JwtAuthClaim

type JwtAuthClaim struct {
	TeamSub     []JwtAuthClaimTeamSub `json:"team_sub"`
	Roles       []string              `json:"roles"`
	Permissions []string              `json:"permissions"`
}

type JwtAuthClaimTeamSub

type JwtAuthClaimTeamSub struct {
	Sub         string   `json:"sub"`
	Roles       []string `json:"roles"`
	Permissions []string `json:"permissions"`
}

type JwtRememberClaim

type JwtRememberClaim struct {
	RememberToken string `json:"remember_token"`
}

type ResponseStruct

type ResponseStruct struct {
	Ctx        *fiber.Ctx
	StatusCode int
	Message    string
	Error      interface{}
	Data       interface{}
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳