dahlia / fedify

ActivityPub server framework in TypeScript
https://fedify.dev/
MIT License
512 stars 19 forks source link

Properties and a class for FEP-9091 #146

Closed dahlia closed 2 weeks ago

dahlia commented 2 weeks ago

Fedify should have Export class and Actor.service property so that applications can implement FEP-9091.

See also:

dahlia commented 2 weeks ago

According to the DID Core Services section, there could be many more services other than Export. So we may need a base class like DidService (or DidCoreService?) as well.

dahlia commented 2 weeks ago

Vocabularies are added. Here's example code:

import { Export, Person } from "@fedify/fedify";

const person = new Person({
  id: new URL("https://alice-personal-site.example/actor"),
  name: "Alice",
  service: new Export({
    id: new URL("https://alice-personal-site.example/actor#export"),
    endpoint: new URL(
      "https://alice-personal-site.example/actor/accountExport",
    ),
  }),
});

console.log(await person.toJsonLd());

The above code prints the following JSON-LD:

{
  "@context": [
    "https://www.w3.org/ns/activitystreams",
    "https://w3id.org/security/v1",
    "https://w3id.org/security/data-integrity/v1",
    "https://www.w3.org/ns/did/v1",
    "https://w3id.org/security/multikey/v1",
    {
      manuallyApprovesFollowers: "as:manuallyApprovesFollowers",
      toot: "http://joinmastodon.org/ns#",
      featured: { "@id": "toot:featured", "@type": "@id" },
      featuredTags: { "@id": "toot:featuredTags", "@type": "@id" },
      discoverable: "toot:discoverable",
      suspended: "toot:suspended",
      memorial: "toot:memorial",
      indexable: "toot:indexable",
      schema: "http://schema.org#",
      PropertyValue: "schema:PropertyValue",
      value: "schema:value",
      misskey: "https://misskey-hub.net/ns#",
      isCat: "misskey:isCat"
    }
  ],
  id: "https://alice-personal-site.example/actor",
  type: "Person",
  name: "Alice",
  service: {
    id: "https://alice-personal-site.example/actor#export",
    type: "https://w3id.org/fep/9091#Export",
    serviceEndpoint: "https://alice-personal-site.example/actor/accountExport"
  }
}

… which is semantically equivalent to an example from FEP-9091.