Skip to main content
This release is 23 versions behind 1.4.1 — the latest version of @fedify/fedify. Jump to latest

Built and signed on GitHub Actions

An ActivityPub/fediverse server framework

This package works with Node.js, Deno, Bun
This package works with Node.js
This package works with Deno
This package works with Bun
JSR Score
94%
Published
3 months ago (1.2.0)

A set of type-safe object mappings for the Activity Vocabulary.

Each class in this module represents a type of object in the Activity Vocabulary. For example, the Note class represents the Note type in the Activity Vocabulary.

There are two ways to instnatiate an object of a class in this module. The first way is to use the constructor of the class. For example:

const note = new Note({
  attributedTo: new URL("https://example.com/user"),
  content: "Hello, world!",
});
const create = new Create({
  actor: new URL("https://example.com/user"),
  object: note,
});

The second way is to deserialize an object from a JSON-LD document using the fromJsonLd() method of the class. For example:

const create = await Create.fromJsonLd({
  "@context": "https://www.w3.org/ns/activitystreams",
  "type": "Create",
  "actor": "https://example.com/user",
  "object": {
    "type": "Note",
    "attributedTo": "https://example.com/user",
    "content": "Hello, world!",
  },
});

In order to serialize an object to a JSON-LD document, use the toJsonLd() method of the object. For example:

const jsonLd = await create.toJsonLd();

Note that both fromJsonLd() and toJsonLd() are asynchronous methods that return a Promise.

Classes

c
Accept

Indicates that the actor accepts the object. The target property can be used in certain circumstances to indicate the context into which the object has been accepted.

c
Activity

An Activity is a subtype of Object that describes some form of action that may happen, is currently happening, or has already happened. The Activity type itself serves as an abstract base type for all types of activities. It is important to note that the Activity type itself does not carry any specific semantics about the kind of action being taken.

c
Add

Indicates that the actor has added the object to the target. If the target property is not explicitly specified, the target would need to be determined implicitly by context. The origin can be used to identify the context from which the object originated.

c
Announce

Indicates that the actor is calling the target's attention the object.

c
Arrive

An IntransitiveActivity that indicates that the actor has arrived at the location. The origin can be used to identify the context from which the actor originated. The target typically has no defined meaning.

c
Article

Represents any kind of multi-paragraph written work.

c
c
Block

Indicates that the actor is blocking the object. Blocking is a stronger form of Ignore. The typical use is to support social systems that allow one user to block activities or content of other users. The target and origin typically have no defined meaning.

c
ChatMessage

ChatMessages are the messages sent in 1-on-1 chats. They are similar to Notes, but the addressing is done by having a single AP actor in the to field. Addressing multiple actors is not allowed. These messages are always private, there is no public version of them. They are created with a Create activity.

c
CollectionPage

Used to represent distinct subsets of items from a Collection. Refer to the Activity Streams 2.0 Core for a complete description of the CollectionPage object.

c
Create

Indicates that the actor has created the object.

c
DataIntegrityProof

A proof that can be added to any activity or object, allowing recipients to verify the identity of the actor and the integrity of the data.

c
Delete

Indicates that the actor has deleted the object. If specified, the origin indicates the context from which the object was deleted.

c
DidService

Means of communicating or interacting with the DID subject or associated entities via one or more service endpoints. Examples include discovery services, agent services, social networking services, file storage services, and verifiable credential repository services.

c
Dislike

Indicates that the actor dislikes the object.

c
Flag

Indicates that the actor is "flagging" the object. Flagging is defined in the sense common to many social platforms as reporting content as being inappropriate for any number of reasons.

c
Follow

Indicates that the actor is "following" the object. Following is defined in the sense typically used within Social systems in which the actor is interested in any activity performed by or on the object. The target and origin typically have no defined meaning.

c
Ignore

Indicates that the actor is ignoring the object. The target and origin typically have no defined meaning.

c
IntransitiveActivity

Instances of IntransitiveActivity are a subtype of Activity representing intransitive actions. The object property is therefore inappropriate for these activities.

c
Invite

A specialization of Offer in which the actor is extending an invitation for the object to the target.

c
Join

Indicates that the actor has joined the object. The target and origin typically have no defined meaning.

c
Leave

Indicates that the actor has left the object. The target and origin typically have no meaning.

c
Like

Indicates that the actor likes, recommends or endorses the object. The target and origin typically have no defined meaning.

c
Listen

Indicates that the actor has listened to the object.

c
Move

Indicates that the actor has moved object from origin to target. If the origin or target are not specified, either can be determined by context.

c
Note

Represents a short written work typically less than a single paragraph in length.

c
Offer

Indicates that the actor is offering the object. If specified, the target indicates the entity to which the object is being offered.

c
OrderedCollection

A subtype of Collection in which members of the logical collection are assumed to always be strictly ordered.

c
OrderedCollectionPage

Used to represent ordered subsets of items from an OrderedCollection. Refer to the Activity Streams 2.0 Core for a complete description of the OrderedCollectionPage object.

c
Profile

A Profile is a content object that describes another Object, typically used to describe Actor Type objects. The Profile.describes property is used to reference the object being described by the profile.

c
Question

Represents a question being asked. Question objects are an extension of IntransitiveActivity. That is, the Question object is an Activity, but the direct object is the question itself and therefore it would not contain an object property.

c
Read

Indicates that the actor has read the object.

c
Reject

Indicates that the actor is rejecting the object. The target and origin typically have no defined meaning.

c
Relationship

Describes a relationship between two individuals. The Relationship.subject and Relationship.object properties are used to identify the connected individuals.

c
Remove

Indicates that the actor is removing the object. If specified, the origin indicates the context from which the object is being removed.

c
TentativeAccept

A specialization of Accept indicating that the acceptance is tentative.

c
TentativeReject

A specialization of Reject in which the rejection is considered tentative.

c
Tombstone

A Tombstone represents a content object that has been deleted. It can be used in Collections to signify that there used to be an object at this position, but it has been deleted.

c
Travel

Indicates that the actor is traveling to target from origin. Travel is an IntransitiveObject whose actor specifies the direct object. If the target or origin are not specified, either can be determined by context.

c
Undo

Indicates that the actor is undoing the object. In most cases, the object will be an Activity describing some previously performed action (for instance, a person may have previously "liked" an article but, for whatever reason, might choose to undo that like at some later point in time).

c
Update

Indicates that the actor has updated the object. Note, however, that this vocabulary does not define a mechanism for describing the actual set of modifications made to object.

c
View

Indicates that the actor has viewed the object.

Functions

f
getActorClassByTypeName

Gets the actor class by the given type name.

f
getActorHandle

Gets the actor handle, of the form @username@domain, from the given actor or an actor URI.

f
getActorTypeName

Gets the type name of the given actor.

f
isActor

Checks if the given object is an Actor.

f
lookupObject

Looks up an ActivityStreams object by its URI (including acct: URIs) or a fediverse handle (e.g., @user@server or user@server).

f
normalizeActorHandle

Normalizes the given actor handle.

f
traverseCollection

Traverses a collection, yielding each item in the collection. If the collection is paginated, it will fetch the next page automatically.

Interfaces

Type Aliases

T
Actor

Actor types are Object types that are capable of performing activities.

T
ActorTypeName

A string representation of an actor type name.

Variables

v
PUBLIC_COLLECTION

The special public collection for public addressing. Do not mutate this object.

Add Package

deno add jsr:@fedify/fedify

Import symbol

import * as mod from "@fedify/fedify/vocab";

---- OR ----

Import directly with a jsr specifier

import * as mod from "jsr:@fedify/fedify/vocab";

Add Package

npx jsr add @fedify/fedify

Import symbol

import * as mod from "@fedify/fedify/vocab";

Add Package

yarn dlx jsr add @fedify/fedify

Import symbol

import * as mod from "@fedify/fedify/vocab";

Add Package

pnpm dlx jsr add @fedify/fedify

Import symbol

import * as mod from "@fedify/fedify/vocab";

Add Package

bunx jsr add @fedify/fedify

Import symbol

import * as mod from "@fedify/fedify/vocab";