package notify import ( "encoding/base64" webpush "github.com/SherClockHolmes/webpush-go" ) // GenerateVAPIDKeys generates a VAPID key pair for web push notifications. // Returns the base64url-encoded public and private keys. // Note: webpush.GenerateVAPIDKeys returns (privateKey, publicKey) — we swap here. func GenerateVAPIDKeys() (publicKey, privateKey string, err error) { privateKey, publicKey, err = webpush.GenerateVAPIDKeys() return } // ValidateVAPIDPublicKey reports whether key is a valid VAPID public key: // a base64url-encoded 65-byte uncompressed P-256 point (starts with 0x04). func ValidateVAPIDPublicKey(key string) bool { b, err := base64.RawURLEncoding.DecodeString(key) if err != nil { return false } return len(b) == 65 && b[0] == 0x04 }