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.
npm install @dokieli/notifications
or
yarn install @dokieli/notifications
import { 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);
}
See API Reference and Examples.
ldp:inbox (LDN) and as:inbox (ActivityPub), or client-preferred inbox property.Accept-Post.ldp:contains and as:items, and AS2 pagination.fetch.Help the project grow by sponsoring it on Open Collective or reach out to us.