paseto

package
v0.0.6 Latest Latest
Warning

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

Go to latest
Published: May 12, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeGetId

func DecodeGetId(publicKey string, tokenstring string) string

func Encode

func Encode(id string, privateKey string) (string, error)

func EncodeWithStruct

func EncodeWithStruct[T any](id string, data *T, privateKey string) (string, error)

func EncodeWithStructDuration

func EncodeWithStructDuration[T any](id string, data *T, privateKey string, dur ...time.Duration) (string, error)

func EncodeforHours

func EncodeforHours(id string, privateKey string, hours int32) (string, error)

func EncodeforMinutes

func EncodeforMinutes(id string, privateKey string, minutes int32) (string, error)

func EncodeforSeconds

func EncodeforSeconds(id string, privateKey string, seconds int32) (string, error)

func GenerateKey

func GenerateKey() (privateKey, publicKey string)

Types

type PASETO

type PASETO struct {
	Public   string
	Private  string
	Duration time.Duration
}

func NewPASETO

func NewPASETO(publicKey, privateKey string, duration ...time.Duration) PASETO

func (PASETO) Decode

func (p PASETO) Decode(tokenString string, payload any) (err error)

func (PASETO) DecodeGetId

func (p PASETO) DecodeGetId(tokenString string) string

func (PASETO) Encode

func (p PASETO) Encode(id string) (string, error)

func (PASETO) EncodeWithStruct

func (p PASETO) EncodeWithStruct(id string, data any) (string, error)

func (PASETO) EncodeWithStructDuration

func (p PASETO) EncodeWithStructDuration(id string, data any, dur ...time.Duration) (string, error)

func (PASETO) RawDecode

func (p PASETO) RawDecode(tokenString string) (raw []byte, err error)

type Payload

type Payload[T any] struct {
	Id   string    `json:"id"`
	Exp  time.Time `json:"exp"`
	Iat  time.Time `json:"iat"`
	Nbf  time.Time `json:"nbf"`
	Data T         `json:"data"`
}

func Decode

func Decode[T any](publicKey string, tokenString string) (payload Payload[T], err error)

func DecodeWithStruct

func DecodeWithStruct[T any](publicKey string, tokenstring string) (payload Payload[T], err error)

Jump to

Keyboard shortcuts

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