An API for producing and validating ActivityPub objects.

Overview

ActivityHelper

CI Coverage Status Stability NPM Version JS Standard Style

A library that exports an API for producing and validating ActivityPub objects.

In a federated system bound together by protocols, it's useful to have programmatic access over the content of those protocols. It's one thing to see that a Person type inherits all properties from an Object type, but what properties are those? You can find out with ActivityHelper like this:

const ActivityHelper = require('.')

console.log(ActivityHelper.models.Person.properties)
// [
//   [class Attachment extends BaseProperty],
//   [class AttributedTo extends BaseProperty],
//   [class Audience extends BaseProperty],
//   [class Content extends BaseProperty],
//   [class Context extends BaseProperty],
//   [class ContentMap extends BaseProperty],
//   [class Name extends BaseProperty],
//   [class NameMap extends BaseProperty],
//   [class EndTime extends BaseProperty],
//   [class Generator extends BaseProperty],
//   [class Icon extends BaseProperty],
//   [class Id extends BaseProperty],
//   [class Image extends BaseProperty],
//   [class InReplyTo extends BaseProperty],
//   [class Location extends BaseProperty],
//   [class Preview extends BaseProperty],
//   [class Published extends BaseProperty],
//   [class Replies extends BaseProperty],
//   [class StartTime extends BaseProperty],
//   [class Summary extends BaseProperty],
//   [class SummaryMap extends BaseProperty],
//   [class Tag extends BaseProperty],
//   [class Updated extends BaseProperty],
//   [class Url extends BaseProperty],
//   [class To extends BaseProperty],
//   [class Bto extends BaseProperty],
//   [class Cc extends BaseProperty],
//   [class Bcc extends BaseProperty],
//   [class MediaType extends BaseProperty],
//   [class Duration extends BaseProperty],
//   [class Inbox extends BaseProperty],
//   [class Outbox extends BaseProperty],
//   [class Following extends BaseProperty],
//   [class Followers extends BaseProperty],
//   [class Liked extends BaseProperty],
//   [class Streams extends BaseProperty],
//   [class PreferredUsername extends BaseProperty],
//   [class Endpoints extends BaseProperty]
// ]

Models and properties in ActivityHelper have validators you can use to validate objects encountered during ActivityPub federation. You can even convert those objects into ActivityPub class instances with API.fromObject():

const model = ActivityHelper.fromObject({
  "@context": "https://www.w3.org/ns/activitystreams",
  type: "Object",
  id: "http://www.test.example/object/1",
  name: "A Simple, non-specific object"
})
console.log(model)
> ObjectModel {
>   type: 'Object',
>   id: 'http://www.test.example/object/1',
>   name: 'A Simple, non-specific object'
> }

You can also extend ActivityHelper by writing plugins:

// your_plugin.js
module.exports = function (ActivityHelper) {
  class MyNote extends ActivityHelper.models.Note {
    // your cool features
  }

  ActivityHelper.addContext('https://my.cool.ap.extension/v1', {
    models: [MyNote]
  })
}

// later, elsewhere:
const ActivityHelper = require('activityhelper')
ActivityHelper.plugin(require('./your_plugin'))

console.log(ActivityHelper.models.MyNote)
// [class MyNote extends Note]

Install

TODO

Usage

TODO

This project is very early in development and its API is likely to evolve rapidly. To understand all of what's going on, I suggest you read the source.

Development

To hack on ActivityHelper, check out the issues page. To submit a patch, submit a pull request.

To run the test suite, use npm test in the source directory:

$ git clone garbados/activityhelper
$ cd activityhelper
$ npm i
$ npm test

A formal code of conduct is forthcoming. Pending it, contributions will be moderated at the maintainers' discretion.

License

Apache-2.0

You might also like...

Simple utils to pack arrays, objects and strings to a flat object (and back again).

packrup Simple utils to pack (and unpack) arrays and strings to a flat object. Status: In Development Please report any issues 🐛 Made possible by my

Dec 23, 2022

Basic website that allows users to add/remove books from a list. Achieved using JavaScript objects and arrays, dynamically modifying the DOM and adding basic events.

Awesome Books Basic website that allows users to add/remove books from a list. Achieved using JavaScript objects and arrays, dynamically modifying the

Dec 20, 2022

Visualize the Directed Acyclic Graph that Git creates to connect Commit, Tree and Blob objects internally.

Visualize the Directed Acyclic Graph that Git creates to connect Commit, Tree and Blob objects internally.

Git Graph Visualize the Directed Acyclic Graph that Git creates to connect Commit, Tree and Blob objects. Hosted at HarshKapadia2.github.io/git-graph.

Aug 21, 2022

Binary-encoded serialization of JavaScript objects with generator-based parser and serializer

YaBSON Schemaless binary-encoded serialization of JavaScript objects with generator-based parser and serializer This library is designed to transfer l

Aug 9, 2022

Functions and objects that make it easier to add fields to Portable Text editors for accessibility meta information, like language changes or abbreviations.

Porta11y Porta11y is a collection of accessibility-focused annotations, decorators and validators for Sanity’s Portable Text editor. Portable Text is

Aug 25, 2022

This is a basic app that allows user add/remove books from a list of books. It was created by using JavaScript arrays and objects to dynamically modify the DOM.

Awesome-Books This application lets you compile a dynamic collection of books using JavaScript. It is a single page app. You enter your book title & a

Oct 24, 2022

A simple in-memory time-based cache for both objects and function execution.

What is this? A simple in-memory time-based cache for both objects and function execution. How do I install it? You can install it by using the follow

Dec 15, 2022

Json-parser - A parser for json-objects without dependencies

Json Parser This is a experimental tool that I create for educational purposes, it's based in the jq works With this tool you can parse json-like stri

Jan 3, 2022

Hierarchical Converter for Array of Objects

Conversor HierĂĄrquico para Array de Objetos - Hierarchical Converter to Array of Objects Docker-compose Cria a interface network e containers indicado

Jan 27, 2022
Owner
Diana Thayer
Python / JS dev. I try my best.
Diana Thayer
Grupprojekt för kurserna 'Javascript med Ramverk' och 'Agil Utveckling'

JavaScript-med-Ramverk-Laboration-3 Grupprojektet för kurserna Javascript med Ramverk och Agil Utveckling. Utvecklingsguide För information om hur utv

Svante Jonsson IT-Högskolan 3 May 18, 2022
Hemsida för personer i Sverige som kan och vill erbjuda boende till mÀnniskor pÄ flykt

Getting Started with Create React App This project was bootstrapped with Create React App. Available Scripts In the project directory, you can run: np

null 4 May 3, 2022
Kurs-repo för kursen Webbserver och Databaser

Webbserver och databaser This repository is meant for CME students to access exercises and codealongs that happen throughout the course. I hope you wi

null 14 Jan 3, 2023
🌐 Text Input Component for validating and formatting international phone numbers.

React Native Intl Phone Field Try the Expo Snack ?? ?? Demo It's a javascript-only (no native code) component that can run in iOS, Android, Expo & Re

Ivanka Todorova 24 Jul 8, 2022
A jQuery-free general purpose library for building credit card forms, validating inputs and formatting numbers.

A jQuery-free general purpose library for building credit card forms, validating inputs and formatting numbers.

Jesse Pollak 528 Dec 30, 2022
Fully-typed utilities for defining, validating and building your document

zhead Typed utilities for defining, validating and building best-practice document <head>'s. Status: Pre-release Please report any issues ?? Made poss

Harlan Wilton 70 Dec 21, 2022
A JavaScript plugin for entering and validating international telephone numbers

International Telephone Input A JavaScript plugin for entering and validating international telephone numbers. It adds a flag dropdown to any input, d

Jack O'Connor 6.6k Dec 30, 2022
Little Javascript / Typescript library for validating format of string like email, url, password...

String-Validators Little Javascript / Typescript library for validating format of string like email, url, password... Signaler un Bug · Proposer une F

J.Delauney 3 Oct 14, 2022
Functional-style Cloudflare Durable Objects with direct API calls from Cloudflare Workers and TypeScript support.

durable-apis Simplifies usage of Cloudflare Durable Objects, allowing a functional programming style or class style, lightweight object definitions, a

Dabble 12 Jan 2, 2023
This project will be a basic website that allows users to add/remove books from a list. The main objective is to understand how to use JavaScript objects and arrays and dynamically modify the DOM and add basic events.

Awesome-books Awesome Books This project will be a basic website that allows users to add/remove books from a list. This project is part of the Microv

Aleksandra Ujvari 10 Oct 3, 2022