webhook

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package webhook provides Wocha webhook signature verification and event parsing.

Verify incoming webhook payloads before processing:

event, err := webhook.Verify(payload, signatureHeader, secret)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SignPayload

func SignPayload(payload []byte, secret string, timestamp time.Time) string

SignPayload creates a signature header for testing. It is not intended for production use.

func VerifySignature

func VerifySignature(payload []byte, signatureHeader, secret string, opts ...VerifyOptions) bool

VerifySignature reports whether the webhook signature is valid.

Types

type Event

type Event struct {
	EventID        string          `json:"event_id"`
	EventType      string          `json:"event_type"`
	Timestamp      string          `json:"timestamp"`
	IdempotencyKey string          `json:"idempotency_key"`
	Data           json.RawMessage `json:"data"`
}

Event is a parsed Wocha webhook event payload.

func Parse

func Parse(payload []byte) (*Event, error)

Parse validates and parses a webhook event payload without signature verification.

func Verify

func Verify(payload []byte, signatureHeader, secret string, opts ...VerifyOptions) (*Event, error)

Verify validates the webhook signature and parses the event payload.

type VerifyOptions

type VerifyOptions struct {
	// Tolerance is the maximum age of the signature timestamp. Default: 5 minutes.
	Tolerance time.Duration
}

VerifyOptions configures webhook signature verification.

Jump to

Keyboard shortcuts

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