Skip to main content

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
5 days ago (1.4.1)
function actorDehydrator
actorDehydrator<TContextData>(
activity: Activity,
_context: Context<TContextData>,
): Activity

An activity transformer that dehydrates the actor property of an activity so that it only contains the actor's URI. For example, suppose we have an activity like this:

import { Follow, Person } from "@fedify/fedify/vocab";
const input = new Follow({
  id: new URL("http://example.com/activities/1"),
  actor: new Person({
    id: new URL("http://example.com/actors/1"),
    name: "Alice",
    preferredUsername: "alice",
  }),
  object: new Person({
    id: new URL("http://example.com/actors/2"),
    name: "Bob",
    preferredUsername: "bob",
  }),
});

The result of applying this transformer would be:

import { Follow, Person } from "@fedify/fedify/vocab";
const output = new Follow({
  id: new URL("http://example.com/activities/1"),
  actor: new URL("http://example.com/actors/1"),
  object: new Person({
    id: new URL("http://example.com/actors/2"),
    name: "Bob",
    preferredUsername: "bob",
  }),
});

As some ActivityPub implementations like Threads fail to deal with inlined actor objects, this transformer can be used to work around this issue.

Type Parameters

TContextData

The type of the context data.

Parameters

activity: Activity

The activity to dehydrate the actor property of.

_context: Context<TContextData>

Return Type

Activity

The dehydrated activity.

Add Package

deno add jsr:@fedify/fedify

Import symbol

import { actorDehydrator } from "@fedify/fedify/compat";

---- OR ----

Import directly with a jsr specifier

import { actorDehydrator } from "jsr:@fedify/fedify/compat";

Add Package

npx jsr add @fedify/fedify

Import symbol

import { actorDehydrator } from "@fedify/fedify/compat";

Add Package

yarn dlx jsr add @fedify/fedify

Import symbol

import { actorDehydrator } from "@fedify/fedify/compat";

Add Package

pnpm dlx jsr add @fedify/fedify

Import symbol

import { actorDehydrator } from "@fedify/fedify/compat";

Add Package

bunx jsr add @fedify/fedify

Import symbol

import { actorDehydrator } from "@fedify/fedify/compat";