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 GenerateTenantURL(baseURL string, tenantID string) (string, error)
- func GetRoutePattern(r *http.Request) string
- func GetTypeName(v interface{}) string
- func GetURLWithScheme(rawURL string) (string, error)
- func Humanize(str string) string
- func IntPtr(i int) *int
- func IsEmpty[T any](v T) bool
- func MapSlice[T any, M any](a []T, f func(T) M) []M
- func ParseBoolQueryParam(r *http.Request, param string) (*bool, error)
- func ParseStrongECPrivateKey(privateKeyStr string) (*ecdsa.PrivateKey, error)
- func ParseStrongECPublicKey(publicKeyStr string) (*ecdsa.PublicKey, error)
- func RandomString(size int, charSetOptions ...string) (string, error)
- func SQLNullString(s string) sql.NullString
- func SignURL(stellarSecretKey string, rawURL string) (string, error)
- func StringPtr(s string) *string
- func TimePtr(t time.Time) *time.Time
- func TrimAndLower(str string) string
- 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 ValidateDateOfBirthVerification(dob string) error
- func ValidateEmail(email string) error
- func ValidateNationalIDVerification(nationalID string) error
- func ValidateNoHTMLNorJSNorCSS(input string) error
- func ValidateOTP(otp string) error
- func ValidatePathIsNotTraversal(p string) error
- func ValidatePhoneNumber(phoneNumberStr string) error
- func ValidatePinVerification(pin string) error
- func ValidateStrongECKeyPair(publicKeyStr, privateKeyStr string) error
- func ValidateURLScheme(link string, scheme ...string) error
- func ValidateYearMonthVerification(yearMonth string) error
- func VerifySignedURL(signedURL string, expectedPublicKey string) (bool, error)
- func VisualBool(b bool) string
- type DefaultPrivateKeyEncrypter
- type NetworkType
- type PrivateKeyEncrypter
- type PrivateKeyEncrypterMock
- type ResultWithTotal
Constants ¶
const ( VerificationFieldPinMinLength = 4 VerificationFieldPinMaxLength = 8 VerificationFieldMaxIdLength = 50 )
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") ErrEmptyEmail = fmt.Errorf("email 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 ParseBoolQueryParam ¶
ParseBoolQueryParam parses a boolean query parameter from an HTTP request.
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 SQLNullString ¶
func SQLNullString(s string) sql.NullString
func TrimAndLower ¶
TrimAndLower trims and lowercases a string.
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 ValidateDateOfBirthVerification ¶
ValidateDateOfBirthVerification will validate the date of birth field for receiver verification.
func ValidateEmail ¶
func ValidateNationalIDVerification ¶
ValidateNationalIDVerification will validate the national id field for receiver verification.
func ValidateNoHTMLNorJSNorCSS ¶
ValidateNoHTMLNorJSNorCSS detects HTML, <script> tags, inline JavaScript, and CSS styles in a string
func ValidateOTP ¶
func ValidatePathIsNotTraversal ¶
ValidatePathIsNotTraversal will validate the given path to ensure it does not contain path traversal.
func ValidatePhoneNumber ¶
func ValidatePinVerification ¶
ValidatePinVerification will validate the pin field for receiver verification.
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).
func ValidateURLScheme ¶
ValidateURLScheme checks if a URL is valid and if it has a valid scheme.
func ValidateYearMonthVerification ¶
ValidateYearMonthVerification will validate the year/month field for receiver verification.
func VerifySignedURL ¶
func VisualBool ¶
Types ¶
type DefaultPrivateKeyEncrypter ¶
type DefaultPrivateKeyEncrypter struct{}
type NetworkType ¶
type NetworkType string
const ( PubnetNetworkType NetworkType = "pubnet" TestnetNetworkType NetworkType = "testnet" )
func AllNetworkTypes ¶
func AllNetworkTypes() []NetworkType
func GetNetworkTypeFromNetworkPassphrase ¶
func GetNetworkTypeFromNetworkPassphrase(networkPassphrase string) (NetworkType, error)
func (NetworkType) IsPubnet ¶
func (n NetworkType) IsPubnet() bool
func (NetworkType) IsTestnet ¶
func (n NetworkType) IsTestnet() bool
func (NetworkType) Validate ¶
func (n NetworkType) Validate() error
type PrivateKeyEncrypter ¶
type PrivateKeyEncrypterMock ¶
func NewPrivateKeyEncrypterMock ¶
func NewPrivateKeyEncrypterMock(t testInterface) *PrivateKeyEncrypterMock
type ResultWithTotal ¶
type ResultWithTotal struct { Total int Result interface{} }
func NewResultWithTotal ¶
func NewResultWithTotal(total int, result interface{}) *ResultWithTotal