Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

convert-vapid-public-key

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convert-vapid-public-key

[![GitHub Actions status](https://github.com/screendriver/convert-vapid-public-key/workflows/CI/badge.svg)](https://github.com/screendriver/convert-vapid-public-key/actions) [![codecov](https://codecov.io/gh/screendriver/convert-vapid-public-key/branch/ma

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
218
increased by9%
Maintainers
1
Weekly downloads
 
Created
Source

convert-vapid-public-key

GitHub Actions status codecov semantic-release

To subscribe to Web Push Notifications you have to provide an Base64 application server key that needs to be converted to an Uint8Array. This package helps you with the conversion from a Base64 string to an Uint8Array.

Installation 🏗

$ npm install --save convert-vapid-public-key

or if you use Yarn 🐈

$ yarn add convert-vapid-public-key

Usage 🔨

import convertVapidKey from "convert-vapid-public-key";

async function subscribe() {
	const registration = await navigator.serviceWorker.register("service-worker.js");
	const subscribeOptions = {
		userVisibleOnly: true,
		applicationServerKey: convertVapidKey("<your-base64-vapid-public-key>"),
	};
	const pushSubscription = await registration.pushManager.subscribe(subscribeOptions);
	// ...
}

Keywords

FAQs

Package last updated on 16 Jul 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc