A WebSub Hub implementation in Node.js
- Node: >= 8.0
- Lead Maintainer: Dustin Deus
- Status: In active development
WebSub provides a common mechanism for communication between publishers of any kind of Web content and their subscribers, based on HTTP web hooks. Subscription requests are relayed through hubs, which validate and verify the request. Hubs then distribute new and updated content to subscribers when it becomes available.
Expectations
- Highly performant: A single node can handle thousands of subscriptions.
- Scalable: Scale the hub in minutes. We choose monogdb as distributed storage.
- Efficient: The difference (or "delta") may be computed by the hub and sent to all subscribers.
- Auditing: Documenting the sequence of activities that have affected system by individual publishers/subscribers.
- Standardized We're trying to be full compliant with the W3C WebSub specification.
- Developer friendly Provide an easy interface to configure and use the hub.
Roadmap
- [ ] Discovering the hub and topic URLs by looking at the HTTP headers of the resource URL.
- [ ] Discovering the hub and topic URLs by looking at the contents of the resource URL as an XML document.
- [ ] Discovering the hub and topic URLs by looking at the contents of the resource URL as an HTML document.
- [x] Subscribing to the hub with a callback URL.
- [x] Subscribing to the hub and requesting a specific lease duration.
- [x] Subscribing to the hub with a secret and handling authenticated content distribution.
- [x] Requesting that a subscription is deactivated by sending an unsubscribe request.
- [ ] The Subscriber acknowledges a pending subscription on a validation request.
- [ ] The Subscriber rejects a subscription validation request for an invalid topic URL.
- [ ] The Subscriber returns an HTTP 2xx response when the payload is delivered.
- [ ] The Subscriber verifies the signature for authenticated content distribution requests.
- [ ] The Subscriber rejects the distribution request if the signature does not validate.
- [ ] The Subscriber rejects the distribution request when no signature is present if the subscription was made with a secret.
- [x] The Hub respects the requested lease duration during a subscription request.
- [x] The Hub allows Subscribers to re-request already active subscriptions, extending the lease duration.
- [x] The Hub sends the full contents of the topic URL in the distribution request.
- [ ] The Hub sends a diff of the topic URL for the formats that support it.
- [x] The Hub sends a valid signature for subscriptions that were made with a secret.
Additional roadmap
- [x] Setup testing environment with CI
- [ ] Auditing
- [x] Content distribution over Websocket
- [ ] Benchmarks
Specification
https://w3c.github.io/websub/
Useful links
Getting started
$ docker run -d -p 27017:27017 -p 28017:28017 -e AUTH=no tutum/mongodb
$ npm i -g websub-hub-cli
$ websub-hub-cli -l info -m mongodb://localhost:27017/hub
Play
$ docker run -d -p 27017:27017 -p 28017:28017 -e AUTH=no tutum/mongodb
$ node examples\full-example.js
$ node examples\ws-full-example.js
Test
$ npm run test