Documentation
¶
Overview ¶
Package qrcode provides QR code generation for GoSPA applications. It integrates with the auth plugin for TOTP/OTP setup and can be used independently for any QR code generation needs.
Index ¶
- func ForOTP(otpURL string, opts ...Option) (string, error)
- func Generate(content string, opts ...Option) (image.Image, error)
- func GenerateBase64(content string, opts ...Option) (string, error)
- func GenerateDataURL(content string, opts ...Option) (string, error)
- func GeneratePNG(content string, opts ...Option) ([]byte, error)
- func GeneratePNGWithLogo(content string, logo image.Image, opts ...Option) ([]byte, error)
- func GenerateWithLogo(content string, logo image.Image, opts ...Option) (image.Image, error)
- type Config
- type Level
- type Option
- type QRCode
- type QRCodePlugin
- func (p *QRCodePlugin) Dependencies() []plugin.Dependency
- func (p *QRCodePlugin) ForOTP(otpURL string, opts ...Option) (string, error)
- func (p *QRCodePlugin) Generate(content string, opts ...Option) (image.Image, error)
- func (p *QRCodePlugin) GenerateDataURL(content string, opts ...Option) (string, error)
- func (p *QRCodePlugin) GeneratePNG(content string, opts ...Option) ([]byte, error)
- func (p *QRCodePlugin) GeneratePNGWithLogo(content string, logo image.Image, opts ...Option) ([]byte, error)
- func (p *QRCodePlugin) GenerateWithLogo(content string, logo image.Image, opts ...Option) (image.Image, error)
- func (p *QRCodePlugin) Init() error
- func (p *QRCodePlugin) Name() string
- func (p *QRCodePlugin) NewQRCode(content string, opts ...Option) *QRCode
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateBase64 ¶
GenerateBase64 generates a base64-encoded PNG QR code.
func GenerateDataURL ¶
GenerateDataURL generates a data URL for the QR code.
func GeneratePNG ¶
GeneratePNG generates a PNG-encoded QR code.
func GeneratePNGWithLogo ¶
GeneratePNGWithLogo generates a PNG QR code with a logo.
Types ¶
type Config ¶
type Config struct {
// Default size in pixels (default: 256).
DefaultSize int `yaml:"default_size" json:"defaultSize"`
// Error correction level: low, medium, quartile, high (default: medium).
DefaultLevel string `yaml:"default_level" json:"defaultLevel"`
}
Config holds plugin configuration from gospa.yaml.
type Option ¶
type Option func(*QRCode)
Option is a functional option for QR code generation.
func WithColors ¶
WithColors sets the foreground and background colors.
type QRCode ¶
type QRCode struct {
Content string
Level Level
Size int
// Module colors
Foreground color.Color
Background color.Color
}
QRCode represents a QR code.
func NewQRCode ¶
NewQRCode creates a new QR code with the given content and options. Uses the default plugin settings.
type QRCodePlugin ¶
type QRCodePlugin struct {
// DefaultSize is the default QR code size in pixels.
DefaultSize int
// DefaultLevel is the default error correction level.
DefaultLevel Level
// DefaultForeground is the default foreground color.
DefaultForeground color.Color
// DefaultBackground is the default background color.
DefaultBackground color.Color
}
QRCodePlugin is the QR code generation plugin for GoSPA.
func NewPlugin ¶
func NewPlugin() *QRCodePlugin
NewPlugin creates a new QR code plugin with default settings.
func NewWithConfig ¶
func NewWithConfig(cfg Config) *QRCodePlugin
NewWithConfig creates a new QR code plugin with configuration.
func (*QRCodePlugin) Dependencies ¶
func (p *QRCodePlugin) Dependencies() []plugin.Dependency
Dependencies returns the plugin dependencies.
func (*QRCodePlugin) ForOTP ¶
func (p *QRCodePlugin) ForOTP(otpURL string, opts ...Option) (string, error)
ForOTP generates a QR code for OTP/TOTP setup. The URL should be in the format: otpauth://totp/Issuer:Account?secret=XXX&issuer=Issuer
func (*QRCodePlugin) GenerateDataURL ¶
func (p *QRCodePlugin) GenerateDataURL(content string, opts ...Option) (string, error)
GenerateDataURL generates a data URL for the QR code.
func (*QRCodePlugin) GeneratePNG ¶
func (p *QRCodePlugin) GeneratePNG(content string, opts ...Option) ([]byte, error)
GeneratePNG generates a PNG-encoded QR code.
func (*QRCodePlugin) GeneratePNGWithLogo ¶
func (p *QRCodePlugin) GeneratePNGWithLogo(content string, logo image.Image, opts ...Option) ([]byte, error)
GeneratePNGWithLogo generates a PNG QR code with a logo.
func (*QRCodePlugin) GenerateWithLogo ¶
func (p *QRCodePlugin) GenerateWithLogo(content string, logo image.Image, opts ...Option) (image.Image, error)
GenerateWithLogo generates a QR code with a logo in the center.