1
0
Fork 0
mirror of https://github.com/imjasonh/webpush synced 2026-07-09 08:47:05 +00:00
webpush/vapid/vapid.go
copilot-swe-agent[bot] 78bd40dc88 Implement Web Push API Go library with VAPID support and pluggable storage
Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com>
2025-11-24 21:19:16 +00:00

18 lines
584 B
Go

// Package vapid provides VAPID (Voluntary Application Server Identification)
// utilities for Web Push.
package vapid
import (
"encoding/base64"
)
// ApplicationServerKey returns the VAPID public key formatted for use with
// the JavaScript PushManager.subscribe() method.
func ApplicationServerKey(publicKey []byte) string {
return base64.RawURLEncoding.EncodeToString(publicKey)
}
// DecodeApplicationServerKey decodes a base64 URL-encoded application server key.
func DecodeApplicationServerKey(key string) ([]byte, error) {
return base64.RawURLEncoding.DecodeString(key)
}