Documentation
¶
Overview ¶
Package push is the native mobile-push side of the companion app: a provider-agnostic Sender port plus its adapters, APNs for iOS (apns.go) and Firebase Cloud Messaging for Android (fcm.go). 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 ¶
APNSFromEnv builds the adapter from NOCTURN_APNS_KEY / _KEY_ID / _TEAM_ID / _BUNDLE_ID (and the optional NOCTURN_APNS_PRODUCTION), reporting permanently invalid tokens to onBadToken. 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.
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 FCM ¶ added in v0.5.0
type FCM struct {
// contains filtered or unexported fields
}
FCM delivers pushes to Android devices through the FCM HTTP v1 API, authenticated as a service account. The access token is minted from the account's key and refreshed by x/oauth2 before it expires; no Google SDK is involved.
func FCMFromEnv ¶ added in v0.5.0
FCMFromEnv builds the adapter from NOCTURN_FCM_CREDENTIALS (the service account JSON, or a path to it), reporting unregistered tokens to onBadToken. It returns nil, nil when the variable is unset: Android push is simply off.
func NewFCM ¶ added in v0.5.0
NewFCM reads the service account and builds the adapter. It fails if the credentials are missing, not a service account key, or lack a project id, an email or a private key.
type FCMConfig ¶ added in v0.5.0
type FCMConfig struct {
Credentials string
OnBadToken func(token string)
// Endpoint overrides the send URL (tests); %s is replaced with the project id.
Endpoint string
// TokenURL overrides the service account's token endpoint (tests).
TokenURL string
// HTTPClient overrides the client for both the token exchange and the sends.
HTTPClient *http.Client
}
FCMConfig configures the Firebase Cloud Messaging adapter, which reaches Android devices. Credentials is a Firebase service account key (the JSON a project's console downloads), either its content or a path to the file; the project id and the signing key are read from it. OnBadToken, if set, is called with any token FCM reports as no longer registered, so the caller can drop it.