jwt

package
v0.1.1-experimental.5 Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2024 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const EthereumJWTLength = 32

JWTLength defines the length of the JWT byte array to be 32 bytes as defined the Engine API specification. https://github.com/ethereum/execution-apis/blob/main/src/engine/authentication.md

Variables

View Source
var (
	// ErrLengthMismatch is returned when a JWT secret length is not as
	// expected.
	ErrLengthMismatch = errors.New(
		"JWT secret length mismatch")

	// ErrContainsIllegalCharacter is returned when a JWT secret contains
	// illegal characters.
	ErrContainsIllegalCharacter = errors.New(
		"JWT secret contains illegal character(s)")
)
View Source
var HexRegexp = regexp.MustCompile(`^(?:0x)?[0-9a-fA-F]*$`)

HexRegexp is a regular expression to match hexadecimal characters.

Functions

This section is empty.

Types

type Secret

type Secret [EthereumJWTLength]byte

Secret represents a JSON Web Token as a fixed-size byte array.

func LoadFromFile

func LoadFromFile(filepath string) (*Secret, error)

LoadFromFile reads the JWT secret from a file and returns it.

func NewFromHex

func NewFromHex(hexStr string) (*Secret, error)

NewFromHex creates a new JWT secret from a hexadecimal string.

func NewRandom

func NewRandom() (*Secret, error)

NewRandom creates a new random JWT secret.

func (*Secret) BuildSignedJWT

func (s *Secret) BuildSignedJWT() (string, error)

BuildSignedJWT builds a signed JWT from the provided JWT secret.

func (*Secret) Bytes

func (s *Secret) Bytes() []byte

Bytes returns the JWT secret as a byte array.

func (*Secret) Hex

func (s *Secret) Hex() string

Hex returns the JWT secret as a hexadecimal string.

func (*Secret) String

func (s *Secret) String() string

String returns the JWT secret as a string with the first 8 characters visible and the rest masked out for security.

Jump to

Keyboard shortcuts

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