token

package
v0.6.25-beta.2 Latest Latest
Warning

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

Go to latest
Published: May 12, 2023 License: GPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// UCANVersion is the current version of the UCAN spec
	UCANVersion = "0.7.0"
	// UCANVersionKey is the key used in version headers for the UCAN spec
	UCANVersionKey = "ucv"
	// PrfKey denotes "Proofs" in a UCAN. Stored in JWT Claims
	PrfKey = "prf"
	// FctKey denotes "Facts" in a UCAN. Stored in JWT Claims
	FctKey = "fct"
	// AttKey denotes "Attenuations" in a UCAN. Stored in JWT Claims
	AttKey = "att"
	// CapKey indicates a resource Capability. Used in an attenuation
	CapKey = "cap"
)

Variables

View Source
var ErrInvalidToken = errors.New("invalid access token")

ErrInvalidToken indicates an access token is invalid

Functions

func ExtractBearerToken

func ExtractBearerToken(header string) (string, error)

It takes a string, splits it on a space, and returns the second element of the resulting array

func GetClaims

func GetClaims(token *jwt.Token) (*jwt.StandardClaims, bool)

It takes a JWT token and returns the claims from it

func NewUnsignedUCAN

func NewUnsignedUCAN(p crypto.PublicKey, audienceDID string, prf []ucan.Proof, att ucan.Attenuations, fct []ucan.Fact, nbf, exp time.Time) (string, error)

NewUnsignedToken It creates a new token, encodes it, and returns it

Types

type JWT

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

`JWT` is a struct that has a field called `options` of type `JWTOptions`. @property {JWTOptions} options - This is a struct that contains the options for the JWT.

func DefaultNew

func DefaultNew() *JWT

`DefaultNew()` returns a new instance of `JWT` with the default options

func (*JWT) BuildJWTParseMiddleware

func (j *JWT) BuildJWTParseMiddleware(headers string) JWTParserMiddleware

A function that returns a function.

func (*JWT) Generate

func (j *JWT) Generate(doc *did.DidDocument) (string, error)

Creating a new token with the claims of the document.

func (*JWT) Parse

func (j *JWT) Parse(token string) (*jwt.Token, error)

Parses a jwt token if possible and returns as Token type.

type JWTOptions

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

`JWTOptions` is a struct that contains a `[]byte` named `secret`, a `jwt.SigningMethod` named `singingMethod`, and an `int64` named `ttl`. @property {[]byte} secret - This is the secret key used to sign the JWT. @property singingMethod - The signing method used to sign the token. @property {int64} ttl - Time to live in seconds.

func (*JWTOptions) DefaultTestConfig

func (opts *JWTOptions) DefaultTestConfig() JWTOptions

A method that returns a `JWTOptions` struct.

func (*JWTOptions) WithConfig

func (j *JWTOptions) WithConfig(config JWTOptions)

Setting the `options` variable to the `config` variable.

type JWTParserMiddleware

type JWTParserMiddleware = func() error

Jump to

Keyboard shortcuts

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