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

@fedify/fedify@1.3.0-dev.578+6bbdcb1d
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
100%
Published
a week ago (1.3.0-dev.578+6bbdcb1d)
interface Context

A context.

Type Parameters

TContextData

Properties

readonly
origin: string

The origin of the federated server, including the scheme (http:// or https://) and the host (e.g., example.com:8080).

readonly
host: string

The host of the federated server, including the hostname (e.g., example.com) and the port following a colon (e.g., :8080) if it is not the default port for the scheme.

readonly
hostname: string

The hostname of the federated server (e.g., example.com). This is the same as the host without the port.

The user-defined data associated with the context.

readonly
tracerProvider: TracerProvider

The OpenTelemetry tracer provider.

readonly
documentLoader: DocumentLoader

The document loader for loading remote JSON-LD documents.

readonly
contextLoader: DocumentLoader

The context loader for loading remote JSON-LD contexts.

Methods

Builds the URI of the NodeInfo document.

getActorUri(identifier: string): URL

Builds the URI of an actor with the given identifier.

getObjectUri<TObject extends Object>(
cls: (new (...args: any[]) => TObject) & { typeId: URL; },
values: Record<string, string>,
): URL

Builds the URI of an object with the given class and values.

getOutboxUri(identifier: string): URL

Builds the URI of an actor's outbox with the given identifier.

Builds the URI of the shared inbox.

getInboxUri(identifier: string): URL

Builds the URI of an actor's inbox with the given identifier.

Builds the URI of an actor's following collection with the given identifier.

Builds the URI of an actor's followers collection with the given identifier.

getLikedUri(identifier: string): URL

Builds the URI of an actor's liked collection with the given identifier.

Builds the URI of an actor's featured collection with the given identifier.

Builds the URI of an actor's featured tags collection with the given identifier.

parseUri(uri: URL | null): ParseUriResult | null

Determines the type of the URI and extracts the associated data.

Gets the key pairs for an actor.

getDocumentLoader(identity:
{ identifier: string; }
| { username: string; }
| { handle: string; }
): Promise<DocumentLoader>

Gets an authenticated DocumentLoader for the given identity. Note that an authenticated document loader intentionally does not cache the fetched documents.

getDocumentLoader(identity: { keyId: URL; privateKey: CryptoKey; }): DocumentLoader

Gets an authenticated DocumentLoader for the given identity. Note that an authenticated document loader intentionally does not cache the fetched documents.

lookupObject(
identifier: string | URL,
options?: LookupObjectOptions,
): Promise<Object | null>

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

traverseCollection(
collection: Collection,
options?: TraverseCollectionOptions,
): AsyncIterable<Object | Link>

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

sendActivity(
sender:
SenderKeyPair
| SenderKeyPair[]
| { identifier: string; }
| { username: string; }
| { handle: string; }
,
recipients: Recipient | Recipient[],
activity: Activity,
): Promise<void>

Sends an activity to recipients' inboxes.

sendActivity(
sender:
{ identifier: string; }
| { username: string; }
| { handle: string; }
,
recipients: "followers",
activity: Activity,
): Promise<void>

Sends an activity to the outboxes of the sender's followers.

routeActivity(
recipient: string | null,
activity: Activity,
): Promise<boolean>

Manually routes an activity to the appropriate inbox listener.

It is useful for routing an activity that is not received from the network, or for routing an activity that is enclosed in another activity.

Note that the activity will be verified if it has Object Integrity Proofs or is equivalent to the actual remote object. If the activity is not verified, it will be rejected.

Add Package

deno add jsr:@fedify/fedify

Import symbol

import { type Context } from "@fedify/fedify/federation";

---- OR ----

Import directly with a jsr specifier

import { type Context } from "jsr:@fedify/fedify/federation";

Add Package

npx jsr add @fedify/fedify

Import symbol

import { type Context } from "@fedify/fedify/federation";

Add Package

yarn dlx jsr add @fedify/fedify

Import symbol

import { type Context } from "@fedify/fedify/federation";

Add Package

pnpm dlx jsr add @fedify/fedify

Import symbol

import { type Context } from "@fedify/fedify/federation";

Add Package

bunx jsr add @fedify/fedify

Import symbol

import { type Context } from "@fedify/fedify/federation";