Documentation ¶
Index ¶
- Constants
- Variables
- func CalculateExponentialBackoffDuration(retry int) (time.Duration, error)
- func ConvertType[S any, D any](src S) (D, error)
- func Decrypt(message string, passphrase string) (string, error)
- func Encrypt(message string, passphrase string) (string, error)
- func ExponentialBackoffInSeconds(retry int) (time.Duration, error)
- func ExtractTenantNameFromHostName(hostname string) (string, error)
- func FloatToString(inputNum float64) string
- func GetRoutePattern(r *http.Request) string
- func GetTypeName(v interface{}) string
- func GetURLWithScheme(rawURL string) (string, error)
- func IsEmpty[T any](v T) bool
- func MapSlice[T any, M any](a []T, f func(T) M) []M
- func ParseStrongECPrivateKey(privateKeyStr string) (*ecdsa.PrivateKey, error)
- func ParseStrongECPublicKey(publicKeyStr string) (*ecdsa.PublicKey, error)
- func RandomString(size int, charSetOptions ...string) (string, error)
- func SignURL(stellarSecretKey string, rawURL string) (string, error)
- func TruncateString(str string, borderSizeToKeep int) string
- func UnwrapInterfaceToPointer[T any](i interface{}) *T
- func ValidateAmount(amount string) error
- func ValidateDNS(domain string) error
- func ValidateEmail(email string) error
- func ValidateOTP(otp string) error
- func ValidatePhoneNumber(phoneNumberStr string) error
- func ValidateStrongECKeyPair(publicKeyStr, privateKeyStr string) error
- func VerifySignedURL(signedURL string, expectedPublicKey string) (bool, error)
- type NetworkType
- type ResultWithTotal
Constants ¶
const MaxRetryValue = 32
MaxRetryValue defines the max retry value. We need this to avoid memory overflow.
const (
NumberBytes = "0123456789"
)
Variables ¶
var ( ErrInvalidECPrivateKey = fmt.Errorf("invalid private key, make sure your private key is generated with a curve at least as strong as prime256v1") ErrInvalidECPublicKey = fmt.Errorf("invalid public key, make sure your public key is generated with a curve at least as strong as prime256v1") )
var ( ErrInvalidBackoffRetryValue = errors.New("invalid backoff retry value") ErrMaxRetryValueOverflow = errors.New("max retry value overflow") )
var ( ErrInvalidE164PhoneNumber = fmt.Errorf("the provided phone number is not a valid E.164 number") ErrEmptyPhoneNumber = fmt.Errorf("phone number cannot be empty") )
var ErrTenantNameNotFound = errors.New("tenant name not found")
Functions ¶
func CalculateExponentialBackoffDuration ¶
CalculateExponentialBackoffDuration returns exponential value based on the retries in time.Duration.
CalculateExponentialBackoffDuration(1) -> time.Duration(2) CalculateExponentialBackoffDuration(2) -> time.Duration(4) CalculateExponentialBackoffDuration(3) -> time.Duration(8)
func ConvertType ¶
func Encrypt ¶
Encrypt secures a message using the AES GCM cipher mode which requires the use of a passphrase for authentication.
func ExponentialBackoffInSeconds ¶
ExponentialBackoffInSeconds returns the duration in seconds based on the number of retries.
func FloatToString ¶
FloatToString converts a float number to a string with 7 decimal places.
func GetRoutePattern ¶
func GetTypeName ¶
func GetTypeName(v interface{}) string
GetTypeName receives any value and returns the name of its type without the package prefix.
func GetURLWithScheme ¶
func ParseStrongECPrivateKey ¶
func ParseStrongECPrivateKey(privateKeyStr string) (*ecdsa.PrivateKey, error)
ParseStrongECPrivateKey parses a strong elliptic curve private key from a PEM-encoded string. It returns the parsed private key or an error if the key is invalid or not strong enough.
func ParseStrongECPublicKey ¶
ParseStrongECPublicKey parses a strong elliptic curve public key from a PEM-encoded string. It returns the parsed public key or an error if the key is invalid or not strong enough.
func TruncateString ¶
func UnwrapInterfaceToPointer ¶
func UnwrapInterfaceToPointer[T any](i interface{}) *T
UnwrapInterfaceToPointer unwraps an interface to a pointer of the given type.
func ValidateAmount ¶
func ValidateDNS ¶
ValidateDNS will validate the given string as a DNS name.
func ValidateEmail ¶
func ValidateOTP ¶
func ValidatePhoneNumber ¶
func ValidateStrongECKeyPair ¶
ValidateStrongECKeyPair validates if the given public and private keys are a valid EC keypair using a curve that's at least as strong as prime256v1 (P-256).
Types ¶
type NetworkType ¶
type NetworkType string
const ( PubnetNetworkType NetworkType = "pubnet" TestnetNetworkType NetworkType = "testnet" )
func GetNetworkTypeFromNetworkPassphrase ¶
func GetNetworkTypeFromNetworkPassphrase(networkPassphrase string) (NetworkType, error)
type ResultWithTotal ¶
type ResultWithTotal struct { Total int Result interface{} }
func NewResultWithTotal ¶
func NewResultWithTotal(total int, result interface{}) *ResultWithTotal