token

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2021 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Int = iota
	Int64
	Float32
	Float64
	String
	Bool
)
View Source
const LEN_TOKEN_ID = 36

Variables

View Source
var (
	ERR_KEY_EXIST         = errors.New("key exist")
	ERR_KEY_NOT_EXIST     = errors.New("key not exist")
	ERR_KEY_INVALID_TYPE  = errors.New("key invalid type")
	ERR_KEY_INVALID_VALUE = errors.New("key invalid value")
)
View Source
var (
	ERR_SIZE_MORE = errors.New("token size is more than 4 kb")
)

Functions

func ValueConvertNameToType added in v0.2.1

func ValueConvertNameToType(t string) uint8

Types

type Backend added in v0.2.1

type Backend interface {
	Marshal(*Token) (string, error)
	Unmarshal(string) (*Token, error)
}

func NewBackendCryptAES added in v0.2.1

func NewBackendCryptAES(key SecretKey) (Backend, error)

NewBackendCryptAES and returns a new *token.CryptAES. The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256.

func NewBackendJose added in v0.2.1

func NewBackendJose(cfg *JoseConfig, key SecretKey) (Backend, error)

type BackendCryptAES added in v0.2.1

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

func (*BackendCryptAES) Marshal added in v0.2.1

func (c *BackendCryptAES) Marshal(tok *Token) (str string, err error)

func (*BackendCryptAES) Unmarshal added in v0.2.1

func (c *BackendCryptAES) Unmarshal(value string) (tok *Token, err error)

type BackendJose added in v0.2.1

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

func (*BackendJose) Marshal added in v0.2.1

func (j *BackendJose) Marshal(tok *Token) (token string, err error)

func (BackendJose) Unmarshal added in v0.2.1

func (j BackendJose) Unmarshal(token string) (tok *Token, err error)

type Body

type Body struct {
	ID         string            `json:"tok_id"`
	UpTime     int64             `json:"up_time"`
	CreateTime int64             `json:"cr_time"`
	S          map[string]*Value `json:"val"`
	// contains filtered or unexported fields
}

func (Body) MarshalEasyJSON added in v0.2.1

func (v Body) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (Body) MarshalJSON added in v0.2.1

func (v Body) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*Body) UnmarshalEasyJSON added in v0.2.1

func (v *Body) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*Body) UnmarshalJSON added in v0.2.1

func (v *Body) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type Encoder

type Encoder interface {
	NewToken() *Token
	UnmarshalString(string) (*Token, error)
	MarshalString(*Token) (string, error)
}

func NewEncoder

func NewEncoder(backend Backend) Encoder

type JoseConfig added in v0.2.1

type JoseConfig struct {
	// Use jose func `Sign` else `Encrypt`
	Type string

	//Sign config
	SigningAlg string

	//Encrypt config
	EncryptAlg string
	EncryptEnc string

	//Options
	Compress bool
}

type SecretKey added in v0.2.1

type SecretKey []byte

type StandartEncoder added in v0.2.1

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

func (*StandartEncoder) MarshalString added in v0.2.1

func (e *StandartEncoder) MarshalString(tok *Token) (raw string, err error)

func (*StandartEncoder) NewToken added in v0.2.1

func (e *StandartEncoder) NewToken() (tok *Token)

func (*StandartEncoder) UnmarshalString added in v0.2.1

func (e *StandartEncoder) UnmarshalString(str string) (tok *Token, err error)

type Token

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

func (*Token) Delete added in v0.2.1

func (b *Token) Delete(key string) (ok bool, err error)

func (*Token) GetBool added in v0.2.1

func (b *Token) GetBool(key string) (val bool, exist bool, err error)

func (*Token) GetFloat32 added in v0.2.1

func (b *Token) GetFloat32(key string) (val float32, exist bool, err error)

func (*Token) GetFloat64 added in v0.2.1

func (b *Token) GetFloat64(key string) (val float64, exist bool, err error)

func (*Token) GetInt added in v0.2.1

func (b *Token) GetInt(key string) (val int, exist bool, err error)

func (*Token) GetInt64 added in v0.2.1

func (b *Token) GetInt64(key string) (val int64, exist bool, err error)

func (*Token) GetRaw added in v0.2.1

func (b *Token) GetRaw(key string) (val *Value, exist bool, err error)

func (*Token) GetString added in v0.2.1

func (b *Token) GetString(key string) (val string, exist bool, err error)

func (*Token) GetTokenCreateTime added in v0.2.1

func (b *Token) GetTokenCreateTime() int64

func (*Token) GetTokenID added in v0.2.1

func (b *Token) GetTokenID() string

func (*Token) GetTokenUpdateTime added in v0.2.1

func (b *Token) GetTokenUpdateTime() int64

func (*Token) IsKeyExist added in v0.2.1

func (b *Token) IsKeyExist(key string) (exist bool)

func (*Token) Iterator added in v0.2.1

func (b *Token) Iterator(fn func(string, *Value, error))

func (*Token) MarshalString

func (t *Token) MarshalString() (string, error)

func (*Token) SetBool added in v0.2.1

func (b *Token) SetBool(key string, val bool) (err error)

func (*Token) SetFloat32 added in v0.2.1

func (b *Token) SetFloat32(key string, val float32) (err error)

func (*Token) SetFloat64 added in v0.2.1

func (b *Token) SetFloat64(key string, val float64) (err error)

func (*Token) SetInt added in v0.2.1

func (b *Token) SetInt(key string, val int) (err error)

func (*Token) SetInt64 added in v0.2.1

func (b *Token) SetInt64(key string, val int64) (err error)

func (*Token) SetRaw added in v0.2.1

func (b *Token) SetRaw(key string, value interface{}) (err error)

func (*Token) SetString added in v0.2.1

func (b *Token) SetString(key string, val string) (err error)

func (*Token) UpBool added in v0.2.1

func (b *Token) UpBool(key string, val bool) (err error)

func (*Token) UpFloat32 added in v0.2.1

func (b *Token) UpFloat32(key string, val float32) (err error)

func (*Token) UpFloat64 added in v0.2.1

func (b *Token) UpFloat64(key string, val float64) (err error)

func (*Token) UpInt added in v0.2.1

func (b *Token) UpInt(key string, val int) (err error)

func (*Token) UpInt64 added in v0.2.1

func (b *Token) UpInt64(key string, val int64) (err error)

func (*Token) UpRaw added in v0.2.1

func (b *Token) UpRaw(key string, value interface{}) (err error)

func (*Token) UpString added in v0.2.1

func (b *Token) UpString(key string, val string) (err error)

type Value added in v0.2.1

type Value struct {
	Type  uint8       `json:"t"`
	Value interface{} `json:"d"`
}

func (*Value) Cast added in v0.2.1

func (b *Value) Cast() (*Value, error)

Jump to

Keyboard shortcuts

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