Nebulous Pumpkin Moons

    convert-vapid-public-key
    TypeScript icon, indicating that this package has built-in type declarations

    1.1.0 • Public • Published

    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);
        // ...
    }

    Install

    npm i convert-vapid-public-key

    DownloadsWeekly Downloads

    160

    Version

    1.1.0

    License

    MIT

    Unpacked Size

    6.54 kB

    Total Files

    9

    Last publish

    Collaborators

    • screendriver