{"modulePath":"github.com/livekit/protocol","version":"v1.55.0","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package webhook\n\n## Constants\n\n```go\nconst (\n\t// use a custom mime type to ensure signature is checked prior to parsing\n\tContentType      = \"application/webhook+json\"\n\tDefaultUserAgent = \"LiveKit\"\n)\n```\n\n```go\nconst (\n\tEventRoomStarted                  = \"room_started\"\n\tEventRoomFinished                 = \"room_finished\"\n\tEventParticipantJoined            = \"participant_joined\"\n\tEventParticipantLeft              = \"participant_left\"\n\tEventParticipantConnectionAborted = \"participant_connection_aborted\"\n\tEventTrackPublished               = \"track_published\"\n\tEventTrackUnpublished             = \"track_unpublished\"\n\tEventEgressStarted                = \"egress_started\"\n\tEventEgressUpdated                = \"egress_updated\"\n\tEventEgressEnded                  = \"egress_ended\"\n\tEventIngressStarted               = \"ingress_started\"\n\tEventIngressEnded                 = \"ingress_ended\"\n\tEventAgentJobPending              = \"agent_job_pending\"\n\tEventAgentJobStarted              = \"agent_job_started\"\n\tEventAgentJobEnded                = \"agent_job_ended\"\n)\n```\n\n## Variables\n\n```go\nvar (\n\tErrNoAuthHeader    = errors.New(\"authorization header could not be found\")\n\tErrSecretNotFound  = errors.New(\"API secret could not be found\")\n\tErrInvalidChecksum = errors.New(\"could not verify authenticity of message\")\n)\n```\n\n```go\nvar DefaultResourceURLNotifierConfig = ResourceURLNotifierConfig{\n\tMaxAge:   30 * time.Second,\n\tMaxDepth: 200,\n}\n```\n\n```go\nvar DefaultURLNotifierConfig = URLNotifierConfig{\n\tNumWorkers: 10,\n\tQueueSize:  100,\n}\n```\n\n```go\nvar DefaultWebHookConfig = WebHookConfig{\n\tURLNotifier:         DefaultURLNotifierConfig,\n\tResourceURLNotifier: DefaultResourceURLNotifierConfig,\n\tFilterParams:        FilterParams{},\n}\n```\n\n```go\nvar ErrBlockedAddress = errors.New(\"blocked destination address\")\n```\nMarks a destination that the SSRF guard rejects. It threads through the transport's url.Error. Callers can then classify it as permanent.\n\n## Functions\n\n```go\nfunc BlockInternal(_, address string, _ syscall.RawConn) error\n```\n\n```go\nfunc CheckWebhookHost(host string) error\n```\nCheckWebhookHost rejects a URL host that is localhost or a blocked IP literal, so the mistake surfaces when the webhook is saved. Hostnames are only resolved, and checked, when a delivery dials them.\n\n```go\nfunc EventKey(event *livekit.WebhookEvent) string\n```\n\n```go\nfunc IncDispatchDrop(reason string)\n```\n\n```go\nfunc IncDispatchFailure()\n```\n\n```go\nfunc IncDispatchSuccess()\n```\n\n```go\nfunc InitWebhookStats(constLabels prometheus.Labels)\n```\n\n```go\nfunc NewDialControl(blockPrivate bool, blocked, allowed []string) (func(network, address string, c syscall.RawConn) error, error)\n```\nRefuses addresses in blocked, and private ones when blockPrivate is set, unless they are also in allowed.\n\n```go\nfunc Receive(r *http.Request, provider auth.KeyProvider) ([]byte, error)\n```\nReceive reads and verifies incoming webhook is signed with key/secret pair closes body after reading\n\n```go\nfunc ReceiveWebhookEvent(r *http.Request, provider auth.KeyProvider) (*livekit.WebhookEvent, error)\n```\nReceiveWebhookEvent reads and verifies incoming webhook, and returns a parsed WebhookEvent\n\n```go\nfunc RecordQueueLength(queueLength int)\n```\n\n```go\nfunc RedactSendError(text string) string\n```\nRewrites a delivery's SendError for a host whose webhook owners are tenants. A refused or unresolvable destination always gives the same text. In any other error, each address in the private and reserved ranges that BlockInternal refuses becomes a placeholder. Ranges a caller configures are not consulted.\n\n## Types\n\n```go\ntype DefaultNotifier struct {\n\t// contains filtered or unexported fields\n}\n```\n\n```go\nfunc (n *DefaultNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error\n```\n\n```go\nfunc (n *DefaultNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))\n```\n\n```go\nfunc (n *DefaultNotifier) SetFilter(params FilterParams)\n```\n\n```go\nfunc (n *DefaultNotifier) SetKeys(apiKey, apiSecret string)\n```\n\n```go\nfunc (n *DefaultNotifier) Stop(force bool)\n```\n\n```go\ntype FilterParams struct {\n\tIncludeEvents []string `yaml:\"include_events,omitempty\"`\n\tExcludeEvents []string `yaml:\"exclude_events,omitempty\"`\n}\n```\n\n```go\nfunc (p FilterParams) IsAllowed(event string) bool\n```\nIsAllowed reports whether event passes the include/exclude filter. IncludeEvents takes precedence over ExcludeEvents; if neither is set, the event is allowed.\n\n```go\ntype HTTPClientParams struct {\n\tRetryWaitMin  time.Duration\n\tRetryWaitMax  time.Duration\n\tMaxRetries    int\n\tClientTimeout time.Duration\n\tForceIPv4     bool\n\tDialControl   func(network, address string, c syscall.RawConn) error\n\t// receivers pin WAF rules to this, so it must stay stable across releases\n\t// defaults to DefaultUserAgent\n\tUserAgent string\n}\n```\n\n```go\ntype NotifyOption func(*NotifyParams)\n```\n\n```go\nfunc WithExtraWebhooks(wh []*livekit.WebhookConfig) NotifyOption\n```\n\n```go\nfunc WithSecret(secret string) NotifyOption\n```\n\n```go\ntype NotifyParams struct {\n\tExtraWebhooks []*livekit.WebhookConfig\n\tSecret        string\n}\n```\n\n```go\ntype QueuedNotifier interface {\n\tRegisterProcessedHook(f func(ctx context.Context, whi *livekit.WebhookInfo))\n\tSetKeys(apiKey, apiSecret string)\n\tSetFilter(params FilterParams)\n\tQueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error\n\tStop(force bool)\n}\n```\n\n```go\nfunc NewDefaultNotifier(config WebHookConfig, kp auth.KeyProvider) (QueuedNotifier, error)\n```\n\n```go\ntype ResourceURLNotifier struct {\n\t// contains filtered or unexported fields\n}\n```\nResourceURLNotifier is a QueuedNotifier that sends a POST request to a Webhook URL. It queues up events per resource (could be egress, ingress, room, participant, track, etc.) to avoid blocking events of one resource blocking another resource's event(s). It will retry on failure, and will drop events if notification fall too far behind, either in age or queue depth.\n\n```go\nfunc NewResourceURLNotifier(params ResourceURLNotifierParams) *ResourceURLNotifier\n```\n\n```go\nfunc (r *ResourceURLNotifier) IsAllowed(event string) bool\n```\n\n```go\nfunc (r *ResourceURLNotifier) Process(\n\tctx context.Context,\n\tqueuedAt time.Time,\n\tevent *livekit.WebhookEvent,\n\tparams *ResourceURLNotifierParams,\n\tqLen int,\n)\n```\nposter interface\n\n```go\nfunc (r *ResourceURLNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error\n```\n\n```go\nfunc (r *ResourceURLNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))\n```\n\n```go\nfunc (r *ResourceURLNotifier) SetFilter(params FilterParams)\n```\n\n```go\nfunc (r *ResourceURLNotifier) SetKeys(apiKey, apiSecret string)\n```\n\n```go\nfunc (r *ResourceURLNotifier) Stop(force bool)\n```\n\n```go\ntype ResourceURLNotifierConfig struct {\n\tMaxAge   time.Duration `yaml:\"max_age,omitempty\"`\n\tMaxDepth int           `yaml:\"max_depth,omitempty\"`\n}\n```\n\n```go\ntype ResourceURLNotifierParams struct {\n\tHTTPClientParams\n\tLogger     logger.Logger\n\tTimeout    time.Duration\n\tConfig     ResourceURLNotifierConfig\n\tURL        string\n\tAPIKey     string\n\tAPISecret  string\n\tFieldsHook func(whi *livekit.WebhookInfo)\n\tEventKey   func(event *livekit.WebhookEvent) string\n\tFilterParams\n}\n```\n\n```go\ntype URLNotifier struct {\n\t// contains filtered or unexported fields\n}\n```\nURLNotifier is a QueuedNotifier that sends a POST request to a Webhook URL. It will retry on failure, and will drop events if notification fall too far behind\n\n```go\nfunc NewURLNotifier(params URLNotifierParams) *URLNotifier\n```\n\n```go\nfunc (n *URLNotifier) IsAllowed(event string) bool\n```\n\n```go\nfunc (n *URLNotifier) QueueNotify(ctx context.Context, event *livekit.WebhookEvent, opts ...NotifyOption) error\n```\n\n```go\nfunc (n *URLNotifier) RegisterProcessedHook(hook func(ctx context.Context, whi *livekit.WebhookInfo))\n```\n\n```go\nfunc (n *URLNotifier) SetFilter(params FilterParams)\n```\n\n```go\nfunc (n *URLNotifier) SetKeys(apiKey, apiSecret string)\n```\n\n```go\nfunc (n *URLNotifier) Stop(force bool)\n```\n\n```go\ntype URLNotifierConfig struct {\n\tNumWorkers int `yaml:\"num_workers,omitempty\"`\n\tQueueSize  int `yaml:\"queue_size,omitempty\"`\n}\n```\n\n```go\ntype URLNotifierParams struct {\n\tHTTPClientParams\n\tLogger     logger.Logger\n\tConfig     URLNotifierConfig\n\tURL        string\n\tAPIKey     string\n\tAPISecret  string\n\tFieldsHook func(whi *livekit.WebhookInfo)\n\tEventKey   func(event *livekit.WebhookEvent) string\n\tFilterParams\n}\n```\n\n```go\ntype WebHookConfig struct {\n\tURLs                  []string                  `yaml:\"urls,omitempty\"`\n\tAPIKey                string                    `yaml:\"api_key,omitempty\"`\n\tURLNotifier           URLNotifierConfig         `yaml:\"url_notifier,omitempty\"`\n\tResourceURLNotifier   ResourceURLNotifierConfig `yaml:\"resource_url_notifier,omitempty\"`\n\tFilterParams          FilterParams              `yaml:\"filter_params,omitempty\"`\n\tBlockPrivateAddresses bool                      `yaml:\"block_private_addresses,omitempty\"`\n\tBlockedCIDRs          []string                  `yaml:\"blocked_cidrs,omitempty\"`\n\tAllowedCIDRs          []string                  `yaml:\"allowed_cidrs,omitempty\"`\n}\n```\n\n","path":"github.com/livekit/protocol/webhook","name":"webhook","synopsis":"","isRedistributable":true}
