Skip to content

AbdullahDiaa/GoVAPID

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

9 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

GOVAPID

GoDoc codecov Build Status Go Report Card

A micro-package to generate VAPID public and private keys and VAPID authorization headers, required for sending web push notifications. The library only supports VAPID-draft-02+ specification.

Usage

package main

import (
	"fmt"
	"github.com/AbdullahDiaa/govapid"
)

func main() {
	//Generate VAPID keys
	VAPIDkeys, err := govapid.GenerateVAPID()
	if err != nil {
		fmt.Println(err)
	}
	fmt.Printf("Public Key:%s\nPrivate Key:%s", VAPIDkeys.Public, VAPIDkeys.Private)

	//Generate VAPID Authorization header which contains JWT signed token and VAPID public key
	subURL, _ := url.Parse("https://fcm.googleapis.com/fcm/send/d5E6exZV5dM:APA91bHI09qFrkxTShu_pUVk-7ZukjdVhEJeZNUt29hSeBez93KlgXDK6Y9BThZMfWUqGhQ8yiWzYqT1gIGUxA5DVuwuARpJPSzk5XFp3yR1kepLKWOOdIgcAO6GRGoZYngmAFc6oufU")

	claims := map[string]interface{}{
		"aud": fmt.Sprintf("%s://%s", subURL.Scheme, subURL.Host),
		"exp": time.Now().Add(time.Hour * 12).Unix(),
		"sub": "mailto:mail@mail.com"}

	AuthorizationHeader, _ := GenerateVAPIDAuth(VAPIDkeys, claims)
	fmt.Println(AuthorizationHeader)
}

Documentation

You can view detailed documentation here: GoDoc.

Contributing

There are many ways to contribute:

Changelog

View the changelog for the latest updates and changes by version.

License

Apache License 2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

About

πŸ’¬ πŸ” A micro-package to generate VAPID keys and VAPID authorization header, required for sending web push notifications

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages