push

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 14 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

FCM HTTP v1 — the Android leg of the push channel. Same contract as the APNs sender: a thin alert payload that wakes the app to fetch, never the vault's metadata. Service-account JSON in envs; OAuth2 JWT-bearer to mint send tokens — no firebase-admin dependency.

Package push sends wake-ups to registered phone devices. Two flows share the channel: an approval ask filed at the deny edge (the agent waits on the human's phone) and ops pages (monitor findings reaching the operator's lock screen instead of an unread inbox).

The payload is deliberately thin — type + ids + a generic title. No item names, no org data, no secrets: the message crosses Apple's or Google's servers, and a push should wake the app to fetch, not carry the vault's metadata through a third party.

APNs is token-auth (.p8 + key id + team id — the Apple-issued key, minted in the developer portal, held as envs). Unconfigured envs mean a nil sender and silent no-op: pushes are a wake channel, not the durable part — the request row and the email path carry the truth.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsUnregistered

func IsUnregistered(err error) bool

IsUnregistered reports whether a send error means a dead token — APNs' BadDeviceToken/Unregistered reasons.

func IsUnregisteredFCM

func IsUnregisteredFCM(err error) bool

IsUnregisteredFCM reports whether the send error means the token's dead — FCM's UNREGISTERED, or a 404 which is the same verdict.

Types

type Config

type Config struct {
	Key      string // .p8 PEM contents — the Railway-able shape
	KeyPath  string // or a path to the .p8 file (local dev)
	KeyID    string
	TeamID   string
	BundleID string // e.g. nyc.veil.phone
	Prod     bool   // production APNs host; false = sandbox
}

Config is the APNs token-auth setup. Zero-value is a disabled sender.

func ConfigFromEnv

func ConfigFromEnv() Config

ConfigFromEnv reads the APNS wiring. Key or KeyPath plus the ids set = configured.

func (Config) Enabled

func (c Config) Enabled() bool

Enabled reports whether the env carries a complete APNs setup.

type DeviceStore

type DeviceStore interface {
	PushDevices(orgID string) ([]protocol.PushDevice, error)
	DeletePushDevice(orgID, token string) error
}

DeviceStore is the narrow read/write the Pusher needs — store.Store satisfies it, and so does a thin pool adapter for the monitor cron.

type FCMConfig

type FCMConfig struct {
	// ServiceAccount is the credential JSON's contents (env-friendly,
	// same shape as the APNs .p8). ServiceAccountPath reads the file.
	ServiceAccount     string
	ServiceAccountPath string
}

FCMConfig is the Android push setup — a Firebase service account's JSON plus the project it mints sends for. Zero-value is disabled.

func FCMConfigFromEnv

func FCMConfigFromEnv() FCMConfig

FCMConfigFromEnv reads the FCM wiring.

func (FCMConfig) Enabled

func (c FCMConfig) Enabled() bool

Enabled reports whether the env carries a service account to send with.

type MultiSender

type MultiSender struct {
	APNS Sender
	FCM  Sender
}

MultiSender routes each device to its platform's sender — apns now, fcm when Android registers tokens.

func (*MultiSender) Send

func (m *MultiSender) Send(ctx context.Context, d protocol.PushDevice, title, body string, data map[string]string) error

type PoolDevices

type PoolDevices struct {
	Pool *pgxpool.Pool
}

PoolDevices adapts a pgx pool to DeviceStore — the monitor cron has a pool, not a full Store.

func (PoolDevices) DeletePushDevice

func (d PoolDevices) DeletePushDevice(orgID, token string) error

func (PoolDevices) PushDevices

func (d PoolDevices) PushDevices(orgID string) ([]protocol.PushDevice, error)

type Pusher

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

Pusher fans one notify out to every registered device of an org and prunes dead tokens — APNs reporting Unregistered means the device re-registers or is gone, and keeping it only wastes sends.

func New

func New(s DeviceStore, sender Sender) *Pusher

New returns a Pusher over the org's registered devices. Sender nil = pushes are no-ops (envs unset, or a store that can't push).

func (*Pusher) NotifyOps

func (p *Pusher) NotifyOps(ctx context.Context, orgID string, findings []string) error

NotifyOps pages an org's devices with monitor findings — the ops plane's own channel (findings arrive by name; the device is the page).

func (*Pusher) NotifyRequest

func (p *Pusher) NotifyRequest(ctx context.Context, req protocol.ApprovalRequest) error

NotifyRequest implements the app's RequestNotify shape — an approval ask wakes every registered device of the org.

type Sender

type Sender interface {
	Send(ctx context.Context, d protocol.PushDevice, title, body string, data map[string]string) error
}

Sender delivers one wake-up to one device. Implementations exist per platform (apns now; fcm when an Android build registers tokens).

func NewAPNSSender

func NewAPNSSender(c Config) (Sender, error)

NewAPNSSender builds the APNs sender from the config — nil when unconfigured so callers can hold a nil Sender.

func NewFCMSender

func NewFCMSender(c FCMConfig) (Sender, error)

NewFCMSender builds the Android sender — nil when unconfigured.

Jump to

Keyboard shortcuts

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