push

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: Apache-2.0 Imports: 17 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package push is the native mobile-push side of the companion app: a provider-agnostic Sender port plus the APNs adapter (apns.go) that implements it. It carries NO approval authority — a push is only a WAKE ("you have a pending approval"); the approve/deny happens in-app over the authenticated WebSocket, so the signed HITL decision never leaves the daemon. Which devices are reachable is the auth store's (a push token lives on the paired device); this package only delivers to tokens the caller supplies.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type APNS

type APNS struct {
	// contains filtered or unexported fields
}

APNS delivers pushes to Apple Push Notification service over HTTP/2 with a token-based (ES256 JWT) authorization. It implements Sender. The provider auth token is cached and reused up to APNs' one-hour ceiling (regenerated at ~50 minutes). Safe for concurrent use.

func APNSFromEnv

func APNSFromEnv() (*APNS, error)

APNSFromEnv builds the adapter from NOCTURN_APNS_KEY / _KEY_ID / _TEAM_ID / _BUNDLE_ID (and the optional NOCTURN_APNS_PRODUCTION). It returns (nil, nil) when NOCTURN_APNS_KEY is unset — push is simply off — so the caller falls back to a no-op.

func NewAPNS

func NewAPNS(cfg APNSConfig) (*APNS, error)

NewAPNS parses the .p8 signing key and builds the adapter. It fails if the key is missing, not PEM, or not an ECDSA PKCS#8 key.

func (*APNS) Send

func (a *APNS) Send(ctx context.Context, m Message, tokens []string) error

Send delivers m to every token. A token APNs rejects as permanently invalid is reported via OnBadToken. It returns nil if at least one token was delivered, else an error — so a caller can treat "nobody reachable" as fail-closed.

type APNSConfig

type APNSConfig struct {
	Key        string
	KeyID      string
	TeamID     string
	BundleID   string
	Production bool
	OnBadToken func(token string)

	// Host overrides the APNs host:port. Empty selects the live/sandbox host from Production.
	Host string
	// HTTPClient overrides the HTTP/2 client. Nil uses the default, which negotiates HTTP/2 via ALPN.
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

APNSConfig configures the Apple Push adapter. Key is the token-signing key (a PKCS#8 EC private key downloaded from the Apple Developer portal) — either its PEM content or a path to the .p8; KeyID and TeamID identify it; BundleID is the app's bundle identifier (the apns-topic). Production selects the live APNs host vs the sandbox. OnBadToken, if set, is called with any token APNs reports permanently invalid, so the caller can drop it.

type Message

type Message struct {
	Title string
	Body  string
	Data  map[string]string
}

Message is one push to deliver. Title/Body are the user-visible notification; Data is an opaque key/value payload the app reads on tap. It never carries an approval token — resolution is in-app.

type Sender

type Sender interface {
	Send(ctx context.Context, m Message, tokens []string) error
}

Sender delivers a Message to a set of device tokens. The APNs adapter implements it; a nil Sender (no provider configured) means push is simply off.

Jump to

Keyboard shortcuts

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