Versions in this module Expand all Collapse all v0 v0.2.0 Nov 26, 2026 Changes in this version + const DefaultHost + const DefaultTimeout + const MaxTriggerChannels + const MaxWebhookBody + var ErrConfig = errors.New("hibira: missing setting") + var ErrInvalidWebhook = errors.New("hibira: invalid webhook") + func StatusOf(err error) int + func WriteJSON(w http.ResponseWriter, status int, v any) + type AuthRequest struct + Channel string + SocketID string + func ParseAuthRequest(contentType string, body []byte) (AuthRequest, error) + func ReadAuthRequest(r *http.Request) (AuthRequest, error) + type AuthorizeFunc func(r *http.Request, channel string) (ok bool, member *Member) + type BatchEvent struct + Channel string + Data any + Name string + SocketID string + type ChannelAuth struct + Auth string + ChannelData string + type ChannelInfo struct + Occupied bool + SubscriptionCount int + UserCount int + type ChatMember struct + ReadSeq int64 + Role string + UserID string + type ChatToken struct + ExpiresAt time.Time + Token string + type Client struct + AppID string + HTTPClient *http.Client + Host string + Key string + Now func() time.Time + PushEndpoint string + PushInstanceID string + PushSecretKey string + Secret string + Timeout time.Duration + func FromEnv() *Client + func (c *Client) AddMembers(ctx context.Context, id string, userIDs ...string) (*Conversation, error) + func (c *Client) Approvals() *approvals.Client + func (c *Client) AuthAnswer(a AuthRequest, ok bool, member *Member) (int, any) + func (c *Client) AuthHandler(fn AuthorizeFunc) http.Handler + func (c *Client) AuthenticateUser(socketID string, user User) (*UserAuth, error) + func (c *Client) AuthorizeChannel(channel, socketID string, member *Member) (*ChannelAuth, error) + func (c *Client) Channel(ctx context.Context, channel string, info ...string) (*ChannelInfo, error) + func (c *Client) Channels(ctx context.Context, prefix string, info ...string) (map[string]ChannelInfo, error) + func (c *Client) ChatRequest(ctx context.Context, method, path string, query url.Values, body any, out any) error + func (c *Client) DeleteConversation(ctx context.Context, id string) error + func (c *Client) DeletePushUser(ctx context.Context, userID string) error + func (c *Client) GetConversation(ctx context.Context, id string) (*Conversation, error) + func (c *Client) ListMessages(ctx context.Context, id string, o ListOptions) (*MessagePage, error) + func (c *Client) MarkRead(ctx context.Context, id, userID string, seq int64) (int64, error) + func (c *Client) NewChatToken(ctx context.Context, userID, conversationID string, join bool, ...) (*ChatToken, error) + func (c *Client) Publish(ctx context.Context, e Event) error + func (c *Client) PushToInterests(ctx context.Context, interests []string, body map[string]any) (*PushResult, error) + func (c *Client) PushToUsers(ctx context.Context, userIDs []string, body map[string]any) (*PushResult, error) + func (c *Client) PushToken(userID string, ttl time.Duration) (string, error) + func (c *Client) PutConversation(ctx context.Context, id string, in ConversationInput) (*Conversation, error) + func (c *Client) RemoveMember(ctx context.Context, id, userID string) (*Conversation, error) + func (c *Client) SendMessage(ctx context.Context, id string, in MessageInput) (*SentMessage, error) + func (c *Client) SystemMessage(ctx context.Context, id, text string, metadata any) (*Message, error) + func (c *Client) TerminateUserConnections(ctx context.Context, userID string) error + func (c *Client) Trigger(ctx context.Context, channel, event string, data any) error + func (c *Client) TriggerBatch(ctx context.Context, events []BatchEvent) error + func (c *Client) Typing(ctx context.Context, id, userID string, typing bool) error + func (c *Client) UserAuthAnswer(a AuthRequest, user *User) (int, any) + func (c *Client) UserAuthHandler(fn func(r *http.Request) *User) http.Handler + func (c *Client) UserConversations(ctx context.Context, userID string, limit int, before string) (*ConversationPage, error) + func (c *Client) Users(ctx context.Context, channel string) ([]string, error) + func (c *Client) VerifyWebhook(key, signature string, body []byte) (*Webhook, error) + func (c *Client) WebhookHandler(fn func(r *http.Request, hook *Webhook) error) http.Handler + type Conversation struct + CreatedAt *time.Time + ID string + LastSeq int64 + Members []ChatMember + Metadata json.RawMessage + Name string + Unread int64 + UpdatedAt *time.Time + Watchers []string + type ConversationInput struct + Members []string + Metadata any + Name string + Roles map[string]string + Watchers []string + type ConversationPage struct + Conversations []Conversation + Next string + type Error struct + Body []byte + Message string + Status int + func (e *Error) Error() string + type Event struct + Channels []string + Data any + Name string + SocketID string + type ListOptions struct + After int64 + Last int + Limit int + type Member struct + UserID string + UserInfo any + type Message struct + CreatedAt *time.Time + DeletedAt *time.Time + EditedAt *time.Time + ID string + Kind string + Metadata json.RawMessage + Name string + Reactions map[string][]string + Sender string + Seq int64 + Text string + VisibleTo []string + type MessageInput struct + IdempotencyKey string + Metadata any + Name string + Push string + PushTitle string + PushURL string + Text string + UserID string + VisibleTo []string + type MessagePage struct + LastSeq int64 + Messages []Message + type PushResult struct + PublishID string + type SentMessage struct + Duplicate bool + Message Message + Push json.RawMessage + type User struct + ID string + UserInfo any + Watchlist []string + type UserAuth struct + Auth string + UserData string + type Webhook struct + Events []WebhookEvent + Raw json.RawMessage + TimeMs int64 + type WebhookEvent struct + Channel string + Data string + Event string + Name string + Raw json.RawMessage + SocketID string + UserID string + func (e *WebhookEvent) UnmarshalJSON(b []byte) error v0.1.0 Nov 26, 2026