license

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// PublicKey is the public key used for verifying license
	PublicKey = ""
	// PrivateKey is the private key used for signing license
	PrivateKey = ""
)
View Source
var (
	ErrSignatureInvalid = errors.New("signature is invalid")
	ErrPublicKeyMissing = errors.New("public key is missing")
	ErrPublicKeyInvalid = errors.New("public key is invalid")
	ErrLicenseExpired   = errors.New("license is expired")
)

Functions

This section is empty.

Types

type License

type License struct {
	ID        string    `json:"id"`
	Plan      string    `json:"plan"`
	Customer  string    `json:"customer"`
	ExpiredAt time.Time `json:"expired_at"`
	CreatedAt time.Time `json:"created_at"`
	Version   string    `json:"version"`
	Signature string    `json:"signature"`
	// contains filtered or unexported fields
}

func New

func New() *License

New returns a default license

func NewFree

func NewFree() *License

NewFree returns a free license

func ParseLicense

func ParseLicense(licenseJSON string) (*License, error)

func (*License) Expired

func (l *License) Expired() bool

func (*License) GetLicense

func (l *License) GetLicense() string

func (*License) Sign

func (l *License) Sign() error

Sign signs the license

func (*License) SignProperties

func (l *License) SignProperties(props Properties) error

func (*License) String

func (l *License) String() string

func (*License) Validate

func (l *License) Validate() error

Validate validates license

type Properties

type Properties map[string]interface{}

func ParseProperties

func ParseProperties(str string) (Properties, error)

func (Properties) Delete

func (props Properties) Delete(key string)

func (Properties) GetString

func (props Properties) GetString(key string) string

func (Properties) JSON

func (props Properties) JSON() (string, error)

func (Properties) Set

func (props Properties) Set(key string, value string)

type Signer

type Signer struct {
	PrivateKey []byte
}

func NewSigner

func NewSigner(privateKey string) (*Signer, error)

func (*Signer) Sign

func (s *Signer) Sign(message string) string

type Verifier

type Verifier struct {
	PublicKey []byte
}

func NewVerifier

func NewVerifier(publicKey string) (*Verifier, error)

func (*Verifier) Verify

func (v *Verifier) Verify(message, signature []byte) bool

Jump to

Keyboard shortcuts

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