auth

package
v0.0.13 Latest Latest
Warning

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

Go to latest
Published: Apr 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventRevoke = "auth-revoke"
	EventError  = "auth-error"
)
View Source
const (
	DefaultSkewMS = 10 * 1000 // 10 seconds skew for token expiry validation
)

Variables

View Source
var (
	ErrTokenUnavailable = errors.New("window.Token is not available")
	ErrTokenMissing     = errors.New("token value is not available")
	ErrTokenInvalid     = errors.New("token value is invalid")
)

Functions

This section is empty.

Types

type Auth

type Auth struct {
	mvc.Observable
	// contains filtered or unexported fields
}

func New

func New(baseUrl string, key string) (*Auth, error)

New binds to window.Auth and returns a JavaScript Auth instance.

func (*Auth) Revoke

func (a *Auth) Revoke() error

Revoke revokes the current token and notifies listeners of the "revoke" event.

func (*Auth) Valid

func (a *Auth) Valid() bool

Valid returns true if the stored token is valid, false otherwise.

type RevokeRequest

type RevokeRequest struct {
	Token string `json:"token"`
}

type Token

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

func NewToken

func NewToken(key string) (*Token, error)

NewToken binds to window.Token and returns a JavaScript Token instance.

func (*Token) Delete

func (t *Token) Delete() (*TokenValue, error)

func (*Token) JSValue

func (t *Token) JSValue() js.Value

func (*Token) Read

func (t *Token) Read() (*TokenValue, error)

func (*Token) Valid

func (t *Token) Valid(value ...*TokenValue) (*TokenValue, error)

func (*Token) Write

func (t *Token) Write(value *TokenValue) (*TokenValue, error)

type TokenValue

type TokenValue struct {
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token,omitempty"`
	TokenType    string `json:"token_type,omitempty"`
	ExpiresIn    int64  `json:"expires_in,omitempty"`
	Expiry       string `json:"expiry,omitempty"`
	StoredAt     string `json:"stored_at,omitempty"`
}

Jump to

Keyboard shortcuts

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