Versions in this module Expand all Collapse all v0 v0.0.1 Mar 22, 2026 Changes in this version + var ErrAuthElsewhere = errors.New("auth elsewhere") + var ErrExpiredToken = errors.New("token is expired") + var ErrInvalidPrivateKey = errors.New("invalid private cacheKey") + var ErrInvalidPublicKey = errors.New("invalid public cacheKey") + var ErrInvalidSecretKey = errors.New("invalid secret cacheKey") + var ErrInvalidSignAlgorithm = errors.New("invalid sign algorithm") + var ErrInvalidToken = errors.New("token is invalid") + var ErrMissingIdentity = errors.New("identity is missing") + var ErrMissingToken = errors.New("token is missing") + var ErrSignAlgorithmNotMatch = errors.New("sign algorithm does not match") + func IsAuthElsewhere(err error) bool + func IsExpiredToken(err error) bool + func IsIdentityMissing(err error) bool + func IsInvalidSignAlgorithm(err error) bool + func IsInvalidToken(err error) bool + func IsMissingToken(err error) bool + type Http struct + func NewHttp(jwt *JWT) *Http + func (h *Http) DestroyToken(r *http.Request) error + func (h *Http) ExtractIdentity(r *http.Request, ignoreExpired ...bool) (interface{}, error) + func (h *Http) ExtractPayload(r *http.Request, ignoreExpired ...bool) (payload Payload, err error) + func (h *Http) ExtractToken(r *http.Request, ignoreExpired ...bool) (*Token, error) + func (h *Http) Middleware(r *http.Request) (*http.Request, error) + func (h *Http) RefreshToken(r *http.Request, ignoreExpired ...bool) (*Token, error) + type JWT struct + func NewJWT(opts ...Option) (*JWT, error) + func (j *JWT) DestroyIdentity(identity interface{}) error + func (j *JWT) DestroyToken(token string, ignoreExpired ...bool) error + func (j *JWT) ExtractIdentity(token string, ignoreExpired ...bool) (interface{}, error) + func (j *JWT) ExtractPayload(token string, ignoreExpired ...bool) (Payload, error) + func (j *JWT) GenerateToken(payload Payload) (*Token, error) + func (j *JWT) Http() *Http + func (j *JWT) IdentityKey() string + func (j *JWT) RefreshToken(token string, ignoreExpired ...bool) (*Token, error) + type Option func(o *options) + func WithIdentityKey(identityKey string) Option + func WithIssuer(issuer string) Option + func WithLookupLocations(locations string) Option + func WithPublicPrivateKey(publicKey, privateKey string) Option + func WithRefreshDuration(duration int) Option + func WithSecretKey(secretKey string) Option + func WithSignAlgorithm(signAlgorithm SignAlgorithm) Option + func WithStore(store Store) Option + func WithValidDuration(duration int) Option + type Payload map[string]interface + type SignAlgorithm string + const ES256 + const ES384 + const ES512 + const HS256 + const HS384 + const HS512 + const RS256 + const RS384 + const RS512 + func (s SignAlgorithm) String() string + type Store interface + Get func(ctx context.Context, key interface{}) (interface{}, error) + Remove func(ctx context.Context, keys ...interface{}) (value interface{}, err error) + Set func(ctx context.Context, key interface{}, value interface{}, ...) error + type Token struct + ExpiredAt time.Time + RefreshAt time.Time + Token string