webhook

package
v0.1.25 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EventHeader       = "X-Authara-Event"
	DeliveryHeader    = "X-Authara-Delivery"
	DeliverySemantics = "best_effort"

	RetryReasonNetworkError = "network_error"
	RetryReasonHTTP429      = "http_429"
	RetryReasonHTTP5xx      = "http_5xx"
	RetryReasonOtherHTTP4xx = "other_http_4xx"
)
View Source
const (
	SignatureHeader    = "X-Authara-Signature"
	SignaturePrefix    = "sha256="
	SignatureAlgorithm = "hmac-sha256"
	SignatureFormat    = "sha256=<hex>"
)

Variables

View Source
var RetryNotOn = []string{
	RetryReasonOtherHTTP4xx,
}

Functions

func Sign

func Sign(secret string, body []byte) string

Types

type Envelope

type Envelope struct {
	ID        string    `json:"id"`
	Type      EventType `json:"type"`
	CreatedAt time.Time `json:"created_at"`
	Data      any       `json:"data"`
}

func NewOrganizationCreated added in v0.1.24

func NewOrganizationCreated(org domain.Organization, now time.Time) Envelope

func NewOrganizationDeleted added in v0.1.24

func NewOrganizationDeleted(org domain.Organization, now time.Time) Envelope

func NewOrganizationInvitationAccepted added in v0.1.24

func NewOrganizationInvitationAccepted(invitation domain.OrganizationInvitation, now time.Time) Envelope

func NewOrganizationInvitationCreated added in v0.1.24

func NewOrganizationInvitationCreated(invitation domain.OrganizationInvitation, now time.Time) Envelope

func NewOrganizationInvitationRevoked added in v0.1.24

func NewOrganizationInvitationRevoked(invitation domain.OrganizationInvitation, now time.Time) Envelope

func NewOrganizationMembershipCreated added in v0.1.24

func NewOrganizationMembershipCreated(membership domain.OrganizationMembership, now time.Time) Envelope

func NewOrganizationMembershipDeleted added in v0.1.24

func NewOrganizationMembershipDeleted(membership domain.OrganizationMembership, now time.Time) Envelope

func NewOrganizationMembershipUpdated added in v0.1.24

func NewOrganizationMembershipUpdated(membership domain.OrganizationMembership, now time.Time) Envelope

func NewOrganizationUpdated added in v0.1.24

func NewOrganizationUpdated(org domain.Organization, now time.Time) Envelope

func NewUserCreated

func NewUserCreated(userID uuid.UUID, now time.Time) Envelope

func NewUserDeleted

func NewUserDeleted(userID uuid.UUID, now time.Time) Envelope

func NewUserUpdated added in v0.1.24

func NewUserUpdated(userID uuid.UUID, now time.Time) Envelope

type EventType

type EventType string
const (
	EventUserCreated                    EventType = "user.created"
	EventUserUpdated                    EventType = "user.updated"
	EventUserDeleted                    EventType = "user.deleted"
	EventOrganizationCreated            EventType = "organization.created"
	EventOrganizationUpdated            EventType = "organization.updated"
	EventOrganizationDeleted            EventType = "organization.deleted"
	EventOrganizationMembershipCreated  EventType = "organization.membership.created"
	EventOrganizationMembershipUpdated  EventType = "organization.membership.updated"
	EventOrganizationMembershipDeleted  EventType = "organization.membership.deleted"
	EventOrganizationInvitationCreated  EventType = "organization.invitation.created"
	EventOrganizationInvitationAccepted EventType = "organization.invitation.accepted"
	EventOrganizationInvitationRevoked  EventType = "organization.invitation.revoked"
)

type FilteringPublisher

type FilteringPublisher struct {
	Inner   Publisher
	Enabled map[string]struct{}
}

func NewFilteringPublisher

func NewFilteringPublisher(inner Publisher, enabled map[string]struct{}) *FilteringPublisher

func (*FilteringPublisher) Publish

func (p *FilteringPublisher) Publish(ctx context.Context, evt Envelope) error

type NoopPublisher

type NoopPublisher struct{}

func (NoopPublisher) Publish

func (NoopPublisher) Publish(ctx context.Context, evt Envelope) error

type OrganizationData added in v0.1.24

type OrganizationData struct {
	OrganizationID  uuid.UUID  `json:"organization_id"`
	Name            string     `json:"name"`
	Kind            string     `json:"kind"`
	CreatedByUserID *uuid.UUID `json:"created_by_user_id"`
}

type OrganizationInvitationAcceptedData added in v0.1.24

type OrganizationInvitationAcceptedData struct {
	InvitationID     uuid.UUID `json:"invitation_id"`
	OrganizationID   uuid.UUID `json:"organization_id"`
	Email            string    `json:"email"`
	Role             string    `json:"role"`
	AcceptedByUserID uuid.UUID `json:"accepted_by_user_id"`
	AcceptedAt       time.Time `json:"accepted_at"`
}

type OrganizationInvitationCreatedData added in v0.1.24

type OrganizationInvitationCreatedData struct {
	InvitationID    uuid.UUID  `json:"invitation_id"`
	OrganizationID  uuid.UUID  `json:"organization_id"`
	Email           string     `json:"email"`
	Role            string     `json:"role"`
	InvitedByUserID *uuid.UUID `json:"invited_by_user_id"`
	ExpiresAt       time.Time  `json:"expires_at"`
}

type OrganizationInvitationRevokedData added in v0.1.24

type OrganizationInvitationRevokedData struct {
	InvitationID    uuid.UUID  `json:"invitation_id"`
	OrganizationID  uuid.UUID  `json:"organization_id"`
	Email           string     `json:"email"`
	Role            string     `json:"role"`
	RevokedByUserID *uuid.UUID `json:"revoked_by_user_id"`
	RevokedAt       time.Time  `json:"revoked_at"`
}

type OrganizationMembershipData added in v0.1.24

type OrganizationMembershipData struct {
	OrganizationID uuid.UUID `json:"organization_id"`
	UserID         uuid.UUID `json:"user_id"`
	Role           string    `json:"role"`
}

type Publisher

type Publisher interface {
	Publish(ctx context.Context, evt Envelope) error
}

type Sender

type Sender struct {
	URL      string
	Secret   string
	Client   *http.Client
	Attempts int
	Backoff  []time.Duration
}

func NewSender

func NewSender(url, secret string, client *http.Client) *Sender

func (*Sender) Publish

func (s *Sender) Publish(ctx context.Context, evt Envelope) error

type UserData

type UserData struct {
	UserID uuid.UUID `json:"user_id"`
}

Jump to

Keyboard shortcuts

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