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 🙏

© 2025 – Pkg Stats / Ryan Hefner

webmention-verifier

v1.2.0

Published

A node.js webmention verifier

Readme

webmention-verifier

A Node.js webmention verifier

Installation

npm install webmention-verifier

Usage

Webmention Verifier will mostly verify webmentions per the W3c specification. Mostly.

const wmverifier = require('webmention-verifier');

module.exports = async function () {
  const webmention = await wmverifier(source, target[, acceptableHosts]);
}

It will:

  • ✅ Verify that source and target are valid URLs (must)
  • ✅ Reject the request if source and target are not the same URL (must)
  • ✅ Perform a GET request on source and confirm source mentions target (must)
  • ✅ Handle arbitrary microformats (IE <a class="u-arbitrary" href="http://your-site.com">)
  • ✅ Handle sources with no microformats (added in v1.1)

It can:

  • ✅ Check if receiver is a valid resource to accept webmentions for target (should)

It wont:

  • ❌ Process the request asynchronously (more below) (should)
  • ❌ Limit the number of redirects during the GET request on source (should)
  • ❌ Store the webmention anywhere
  • ❌ Check source against a blocklist (I will add this at some point)

Inputs

  • source: (String) URL of the source of the webmention
  • target: (String) URL of the target of the webmention
  • acceptableHosts: (Array of strings, optional) domains that are accepted by this webmention receiver. Should not include protocols (https://). Example: ['www.timculverhouse.com', 'timculverhouse.com', 'sub-domain.domain.tld']

Outputs

Returns an object with properties:

  • statusCode: (Numeric) 400 for rejected webmentions, 200 for verified webmentions
  • body: (String) Description of the status code
  • webmention: (False || Object) False if rejected, otherwise a JF2 object (see below)

The webmention will be a JF2 object, which will have all discovered microformat properties, as well as:

  • wm-source: Equal to source
  • wm-target: Equal to target
  • wm-property: Equal to the type of webmention ("in-reply-to","like-of","arbitrary-value")
  • wm-verified: The date-time the webmention was verified

Synchronous vs Asynchronous processing

This verifier does all it's check synchronously. This is not recommended by the spec, but it is not capable of knowing how to form a location URL for you to respond to the sender with. So it doesn't do that.

It would be possible to add an option to have the verifier respond in an async matter (do what it can without fetching, respond with a code, and you handle the location URL crafting on your end while it finishes up verification);.

Example

HTML (source = https://www.example.com/post.html, target = "https://www.duckduckgo.com"):

<html>
  <head>
    <title>Single h-Entry</title>
  </head>
  <body>
    <article class="h-entry">
      <h1 class="p-name">Article Title</h1>
      <section class="e-content">
      <a href="https://www.duckduckgo.com" class="u-in-reply-to">DuckDuckgo</a>
      This is some content
    </section>
    </article>
    <a href="https://www.example.com/virginia-woolf.html" rel="author">about Virginia Woolf</a>
  </body>
</html>

Javascript:

const wmverifier = require('webmention-verifier');

module.exports = async function() {
  const res = await wmverifier('https://www.example.com/some-post', 'https://www.duckduckgo.com');

  console.log(res);
}
/* Output
{
  statusCode: 200,
  body: 'Webmention verified',
  webmention: {
    type: 'entry',
    name: 'Article Title',
    content: {
      html: '\n' +
        '      <a href="https://www.duckduckgo.com" class="u-in-reply-to">DuckDuckgo</a>\n' +
        '      This is some content\n' +
        '    ',
      text: 'DuckDuckgo\n      This is some content'
    },
    'in-reply-to': 'https://www.duckduckgo.com',
    'wm-property': 'in-reply-to',
    'wm-target': 'https://www.duckduckgo.com',
    'wm-source': 'https://www.example.com/post.html',
    'wm-verified': '2021-06-22T14:28:25.229Z',
    author: {
      type: 'card',
      url: 'https://www.example.com/virginia-woolf.html',
      photo: 'https://www.example.com/images/virginia-woolf.jpg',
      name: 'Virginia Woolf'
    }
  }
}
*/

If we change the call to wmverifierto be a different target to trigger a rejection, we get:

var res = wmverifier('https://www.example.com/some-post', 'https://www.not-mentioned.com');

console.log(res);
/* Output
{
  statusCode: 400,
  body: 'Source does not mention target',
  webmention: false
}
*/

Things to do on your end

  1. Assign an ID webmention.io uses "wm-id" as the key, and I would stick with that. However you decide to do that is up to you (hash, increment, etc)
  2. Store your webmention somewhere A database, a file, anywhere.
  3. Check if the received webmention already exists, and act accordingly In theory, there should only be a single combination of target and source, so if you already have a mention to a target from a source, the newly received mention for that combination could be an update, a deletion, or a duplicate send. Don't store two, find the existing mention and act accordingly. I recommend adding a property on the first receipt of a webmention for wm-received, the date-time the webmention was first received. Webmention-verifier will update wm-verified every time the webmention is verified, which could be frequently depending on how senders send webmentions.
  4. Return the statusCode and body to the sender

Future Features

  • blocklist support
  • pingback support