license

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Feb 28, 2026 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package license provides Ed25519-signed license token creation, parsing, and verification.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateKeyPair

func GenerateKeyPair() (ed25519.PublicKey, ed25519.PrivateKey, error)

GenerateKeyPair generates a new Ed25519 key pair using crypto/rand.

func MarshalPrivateKeyPEM

func MarshalPrivateKeyPEM(priv ed25519.PrivateKey) []byte

MarshalPrivateKeyPEM PEM-encodes an Ed25519 private key with type "ED25519 PRIVATE KEY".

func MarshalPublicKeyPEM

func MarshalPublicKeyPEM(pub ed25519.PublicKey) []byte

MarshalPublicKeyPEM PEM-encodes an Ed25519 public key with type "ED25519 PUBLIC KEY".

func UnmarshalPrivateKeyPEM

func UnmarshalPrivateKeyPEM(pemBytes []byte) (ed25519.PrivateKey, error)

UnmarshalPrivateKeyPEM decodes a PEM-encoded Ed25519 private key.

func UnmarshalPublicKeyPEM

func UnmarshalPublicKeyPEM(pemBytes []byte) (ed25519.PublicKey, error)

UnmarshalPublicKeyPEM decodes a PEM-encoded Ed25519 public key.

Types

type LicenseToken

type LicenseToken struct {
	LicenseID    string   `json:"lid"`
	TenantID     string   `json:"tid"`
	Organization string   `json:"org"`
	Tier         string   `json:"tier"`
	Features     []string `json:"feat"`
	MaxWorkflows int      `json:"max_wf"`
	MaxPlugins   int      `json:"max_pl"`
	IssuedAt     int64    `json:"iat"`
	ExpiresAt    int64    `json:"exp"`
	// contains filtered or unexported fields
}

LicenseToken holds the claims embedded in a signed license token.

func Parse

func Parse(tokenStr string) (*LicenseToken, error)

Parse splits tokenStr on dots, decodes the base64url payload, and returns the token. It does NOT verify the signature.

func (*LicenseToken) HasFeature

func (t *LicenseToken) HasFeature(name string) bool

HasFeature returns true if the given feature name is present in the Features slice.

func (*LicenseToken) IsExpired

func (t *LicenseToken) IsExpired() bool

IsExpired returns true if ExpiresAt is in the past.

func (*LicenseToken) Sign

func (t *LicenseToken) Sign(privateKey ed25519.PrivateKey) (string, error)

Sign produces a signed license token string in the format: wflic.v1.<base64url-payload>.<base64url-signature>

func (*LicenseToken) Verify

func (t *LicenseToken) Verify(publicKey ed25519.PublicKey) error

Verify verifies the Ed25519 signature over the wflic.v1.<payload> prefix bytes. The token must have been produced by Parse.

Jump to

Keyboard shortcuts

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