tokens

package
v0.0.0-...-c8afd98 Latest Latest
Warning

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

Go to latest
Published: Feb 16, 2022 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrMalformedToken = errors.New("malformed token")

Functions

This section is empty.

Types

type Token

type Token struct {
	ID     []byte `json:"id"`               // bytes 0-5
	Secret []byte `json:"secret,omitempty"` // bytes 6-31
}

func FromBootstrapToken

func FromBootstrapToken(t *core.BootstrapToken) (*Token, error)

func NewToken

func NewToken(source ...io.Reader) *Token

Creates a new token by reading bytes from the given random source. the default source is crypto/rand.Reader.

func ParseHex

func ParseHex(str string) (*Token, error)

func ParseJSON

func ParseJSON(data []byte) (*Token, error)

func (*Token) EncodeHex

func (t *Token) EncodeHex() string

func (*Token) EncodeJSON

func (t *Token) EncodeJSON() []byte

func (*Token) HexID

func (t *Token) HexID() string

func (*Token) HexSecret

func (t *Token) HexSecret() string

func (*Token) Reference

func (t *Token) Reference() *core.Reference

func (*Token) SignDetached

func (t *Token) SignDetached(key interface{}) ([]byte, error)

Signs the token and returns a JWS with the payload detached

func (*Token) ToBootstrapToken

func (t *Token) ToBootstrapToken() *core.BootstrapToken

func (*Token) VerifyDetached

func (t *Token) VerifyDetached(sig []byte, key interface{}) ([]byte, error)

Verifies a JWS with a detached signature. If the signature is valid, also returns the complete message with re-attached payload.

Jump to

Keyboard shortcuts

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