webhook

package
v0.0.0-...-8ffcee5 Latest Latest
Warning

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

Go to latest
Published: May 24, 2024 License: MIT Imports: 8 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTimestampToleranceDurationTooSmall = errors.New("WEBHOOK.TIMESTAMP_TOLERANCE_DURATION.TOO_SMALL.ERROR")
	ErrSignatureMismatch                  = errors.New("WEBHOOK.SIGNATURE_MISMATCH.ERROR")
	ErrMessageTimestampMalformed          = errors.New("WEBHOOK.MESSAGE.TIMESTAMP_MALFORMED.ERROR")
	ErrMessageTimestampTooOld             = errors.New("WEBHOOK.MESSAGE.TIMESTAMP_TOO_OLD.ERROR")
	ErrMessageTimestampTooNew             = errors.New("WEBHOOK.MESSAGE.TIMESTAMP_TOO_NEW.ERROR")
)
View Source
var (
	DefaultKeyNs             = "epsec"
	HeaderId                 = "Webhook-Id"
	HeaderTimestamp          = "Webhook-Timestamp"
	HeaderSignature          = "Webhook-Signature"
	ToleranceDurationDefault = time.Minute * 5
	ToleranceDurationMin     = time.Minute
	MaxKeys                  = 10
)

Functions

This section is empty.

Types

type Option

type Option func(option *Options)

func KeyNamespace

func KeyNamespace(ns string) Option

type Options

type Options struct {
	KeyNamespace string
}

type VerifyOption

type VerifyOption func(option *VerifyOptions)

func TimestampToleranceDuration

func TimestampToleranceDuration(duration time.Duration) VerifyOption

func TimestampToleranceIgnore

func TimestampToleranceIgnore() VerifyOption

type VerifyOptions

type VerifyOptions struct {
	TimestampToleranceIgnore   bool
	TimestampToleranceDuration time.Duration
}

type Webhook

type Webhook interface {
	Sign(id, ts, body string) []string
	Verify(req *http.Request, withOptions ...VerifyOption) error
}

func New

func New(keys []string, withOptions ...Option) (Webhook, error)

Jump to

Keyboard shortcuts

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