npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

web-push-testing

v1.1.1

Published

A server that can be run to test against a mocked API endpoint for web push without relying on flaky browser drivers.

Downloads

1,760

Readme

web-push-testing

A server that can be run to test against a mocked API endpoint for web push without relying on flaky browser drivers.

The idea for this was inspired by see, using, and giving up on https://github.com/GoogleChromeLabs/web-push-testing-service.

Test Coverage Status

Features

  • Provides test solution to test both the web application and the notification endpoint part of the Push API
  • Full support for:
    • Subscribing to push messages
    • Sending push messages
    • Retrieving push messages received by endpoint
  • Supports aesgcm & aes128gcm type of push messages
  • Fully runs on localhost as HTTP server
  • Fast & reliable
  • Fully tested

Installation

web-push-testing can be installed directly via npm. It requires node >=15.0.0:

npm install web-push-testing

Usage

Starting the server:

web-push-testing start

Stopping the server:

web-push-testing stop

Note: web-push-testing will default to port 8090

Note: Multiple instances will require using a different port

Setting the port:

web-push-testing --port 8990 start

Get all supported command line arguments:

web-push-testing --help

API

See the documentation under Further Reading in regard to input & output formats. Additional fields are specified in square brackets.

Status

  • URL: http://localhost:8090/status
  • Input: No input
  • Output:
    • Status: 200
    • No body

Subscribe

  • URL: http://localhost:8090/subscribe
  • Input: PushSubscriptionOptions
  • Output:
    {
        data: PushSubscriptionJSON[+clientHash]
    }

Expire subscription

  • URL: http://localhost:8090/expire-subscription/[+clientHash]
  • Input: None (expect for clientHash in URL)
  • Output:
    • Status:
      • 200 for success
      • 400 on error e.g. when subscription does not exist
    • Body:
      • None for success
      • Error return on error

Send push notification

  • URL: PushSubscriptionJSON.endpoint (format: http://localhost:8090/notify/[+clientHash])
  • Headers: See e.g. RFC 8291 on required headers
  • Input: Encrypted payload
  • Output:
    • Status:
      • 201 for success
      • 400 on errors
      • 410 on expired subscriptions
    • Body
      • Error:
        {
            error: { message: err.message }
        }
      • Expired subscription:
        {
            reason: 'Push subscription has unsubscribed or expired.',
        }

Get endpoint notifications

  • URL: http://localhost:8090/get-notifications
  • Input:
    {"clientHash": "YOUR_CLIENT_HASH"}
  • Output:
    • Status: 200, 400 on invalid clientHash
    • Body:
      {
        "data": {
          "messages": [
            message1,
            message2,
            ...
          ]
        }
      }

Further reading