mirror of
https://github.com/imjasonh/webpush
synced 2026-07-18 06:25:38 +00:00
Implement Web Push API Go library with VAPID support and pluggable storage
Co-authored-by: imjasonh <210737+imjasonh@users.noreply.github.com>
This commit is contained in:
parent
7d0082c045
commit
78bd40dc88
15 changed files with 2708 additions and 1 deletions
18
vapid/vapid.go
Normal file
18
vapid/vapid.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// 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)
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue