utils

package
v1.0.4 Latest Latest
Warning

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

Go to latest
Published: Jul 1, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const SdkSecretHeaderName = "Kobble-Sdk-Secret"

Variables

This section is empty.

Functions

func VerifyJwt

func VerifyJwt(tokenString string, key *ecdsa.PublicKey, options VerifyJwtOptions) (map[string]any, error)

VerifyJwt verifies a JWT token string using the provided public key.

The options parameter allows you to specify which claims to verify.
If the token is valid, the payload is returned as a map[string]any.

Types

type Cache

type Cache[T any] struct {
	// contains filtered or unexported fields
}

func NewCache

func NewCache[T any](config CacheConfig) *Cache[T]

func (*Cache[T]) Get

func (c *Cache[T]) Get(key string) *T

func (*Cache[T]) Set

func (c *Cache[T]) Set(key string, data T, ttl *time.Duration)

type CacheConfig

type CacheConfig struct {
	DefaultTtl *time.Duration
}

type CacheKey

type CacheKey[T any] struct {
	Data      T
	CreatedAt int64
	ExpiresAt *int64
}

type ErrorBase

type ErrorBase struct {
	Name    string
	Message string
	Cause   error
}

func NewErrorBase

func NewErrorBase(name, message string, cause error) *ErrorBase

func (*ErrorBase) Error

func (e *ErrorBase) Error() string

type HttpClient

type HttpClient struct {
	// contains filtered or unexported fields
}

func NewHttpClient

func NewHttpClient(config HttpClientConfig) *HttpClient

func (*HttpClient) GetJson

func (c *HttpClient) GetJson(path string, params map[string]string, result any, expectedStatus int) error

func (*HttpClient) PostJson

func (c *HttpClient) PostJson(path string, payload any, result any, expectedStatus int) error

type HttpClientConfig

type HttpClientConfig struct {
	BaseURL string
	Secret  string
}

type VerifyJwtError

type VerifyJwtError struct {
	Message string
}

func (*VerifyJwtError) Error

func (e *VerifyJwtError) Error() string

type VerifyJwtOptions

type VerifyJwtOptions struct {
	VerifyAud       bool
	VerifyExp       bool
	VerifySignature bool
	VerifyIss       bool
	Iss             string
	Audience        string
	RequiredClaims  []string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL