autopush

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 1, 2025 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const MOZILLA_PUSH_SERVICE = "wss://push.services.mozilla.com"

Variables

This section is empty.

Functions

This section is empty.

Types

type Ack

type Ack struct {
	Type    MessageType `json:"messageType"`
	Updates []AckUpdate `json:"updates"`
}

type AckUpdate

type AckUpdate struct {
	ChannelID string `json:"channelID"`
	Version   string `json:"version"`
}

type AutoPushClient

type AutoPushClient struct {
	*websocket.WebSocketClient
	// contains filtered or unexported fields
}

func NewAutoPushClient

func NewAutoPushClient() (ap *AutoPushClient, ch chan Notification)

func (*AutoPushClient) Decrypt

func (c *AutoPushClient) Decrypt(
	curve ecdh.Curve,
	authSecret []byte,
	useragentPrivateKey *ecdh.PrivateKey,
	notification Notification,
) (*webpush.WebPushPayload, error)

func (*AutoPushClient) Hello

func (c *AutoPushClient) Hello(uaid string, channelIDs []string) (HelloResponse, error)

func (*AutoPushClient) Register

func (c *AutoPushClient) Register(channelID string, vapidKey string) (RegisterResponse, error)

func (*AutoPushClient) Unregister

func (c *AutoPushClient) Unregister(channelID string) (UnregisterResponse, error)

type HelloRequest

type HelloRequest struct {
	Type       MessageType `json:"messageType"`
	UAID       string      `json:"uaid"`
	ChannelIDs []string    `json:"channelIDs"`
	UseWebPush bool        `json:"use_webpush,omitempty"`
}

type HelloResponse

type HelloResponse struct {
	Type       MessageType `json:"messageType"`
	UAID       string      `json:"uaid"`
	Status     Status      `json:"status"`
	UseWebPush bool        `json:"use_webpush,omitempty"`
}

type Message

type Message struct {
	Type MessageType `json:"messageType"`
}

type MessageType

type MessageType string
const (
	PING         MessageType = "ping"
	ACK          MessageType = "ack"
	HELLO        MessageType = "hello"
	REGISTER     MessageType = "register"
	UNREGISTER   MessageType = "unregister"
	NOTIFICATION MessageType = "notification"
)

type Notification

type Notification struct {
	Type      MessageType         `json:"messageType"`
	ChannelID string              `json:"channelID"`
	Version   string              `json:"version"`
	Data      string              `json:"data"`
	Headers   NotificationHeaders `json:"headers"`
}

type NotificationHeaders

type NotificationHeaders struct {
	Encryption string `json:"encryption"`
	CryptoKey  string `json:"crypto_key"`
	Encoding   string `json:"encoding"`
}

type RegisterRequest

type RegisterRequest struct {
	Type      MessageType `json:"messageType"`
	ChannelID string      `json:"channelID"`
	Key       string      `json:"key"`
}

type RegisterResponse

type RegisterResponse struct {
	Type         MessageType `json:"messageType"`
	ChannelID    string      `json:"channelID"`
	Status       Status      `json:"status"`
	PushEndpoint string      `json:"pushEndpoint"`
}

type Status

type Status int
const (
	OK           Status = 200
	CONFLICT     Status = 409
	SERVER_ERROR Status = 500
)

type UnregisterRequest

type UnregisterRequest struct {
	Type      MessageType `json:"messageType"`
	ChannelID string      `json:"channelID"`
}

type UnregisterResponse

type UnregisterResponse struct {
	Type      MessageType `json:"messageType"`
	ChannelID string      `json:"channelID"`
	Status    Status      `json:"status"`
}

Jump to

Keyboard shortcuts

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