@dokieli/notifications
v1.1.0
Published
W3C Linked Data Notifications (LDN) implementation of the Sender and Consumer roles, using the Activity Vocabulary and ActivityStreams 2.0 (AS2) as compacted JSON-LD, with support for HTML+RDFa serialization. The library allows clients to use their own pa
Readme
@dokieli/notifications
W3C Linked Data Notifications (LDN) implementation of Sender and Consumer roles, and implements Activity Vocabulary and Activity Streams 2.0 (AS2) compacted JSON-LD, with support for HTML+RDFa serialization. The library allows clients to use their own parsers and own notification payloads.
License
- Source code is licensed under the Apache License, Version 2.0.
- Unless otherwise noted, images and other media assets are licensed under the Creative Commons Attribution 4.0 International.
Installation
npm install @dokieli/notificationsor
yarn install @dokieli/notificationsimport { createNotification, serializeNotificationToJSONLD, serializeNotificationToHTML, sendNotification } from '@dokieli/notifications';
const notification = createNotification({
type: 'Announce',
actor: { id: 'https://example.org/profile#me', name: 'Virginia' },
object: 'https://example.org/annotations/1',
target: 'https://example.org/article'
});
const jsonld = serializeNotificationToJSONLD(notification);
const html = serializeNotificationToHTML(notification);
/* Discovers the target's inbox, negotiates via Accept-Post, serializes, POSTs */
const result = await sendNotification('https://example.org/article', notification);import { getNotifications } from '@dokieli/notifications';
for await (const { iri, notification } of getNotifications('https://example.org/inbox/')) {
console.log(iri, notification?.type);
}Documentation
See API Reference and Examples.
Features
- Built-in inbox discovery for
ldp:inbox(LDN) andas:inbox(ActivityPub), or client-preferred inbox property. - Sending server-supported media types for notifications by checking
Accept-Post. - Support for reading inbox items via
ldp:containsandas:items, and AS2 pagination. - Activity Streams 2.0 notification model, serialized to JSON-LD and HTML+RDFa.
- Embedding caller-supplied object payloads verbatim (JSON-LD or HTML+RDFa).
- Authentication left to the caller via an injected
fetch. - Built-in JSON-LD processing.
- Support for reading additional serializations via a caller-supplied parser.
Specifications
Supported By
- This project was funded by NLnet (2025-09–2026-08) as part of NLnet Dokieli Collaborative.
Support the project
Help the project grow by sponsoring it on Open Collective or reach out to us.
