Loading packages/fedify/src/federation/builder.ts +9 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import type { ObjectAuthorizePredicate, ObjectDispatcher, SharedInboxKeyDispatcher, WebFingerLinkDispatcher, } from "./callback.ts"; import type { Context, RequestContext } from "./context.ts"; import type { Loading @@ -48,6 +49,7 @@ export class FederationBuilderImpl<TContextData> router: Router; actorCallbacks?: ActorCallbacks<TContextData>; nodeInfoDispatcher?: NodeInfoDispatcher<TContextData>; webFingerDispatcher?: WebFingerLinkDispatcher<TContextData>; objectCallbacks: Record<string, ObjectCallbacks<TContextData, string>>; objectTypeIds: Record< string, Loading Loading @@ -148,6 +150,7 @@ export class FederationBuilderImpl<TContextData> ? undefined : { ...this.actorCallbacks }; f.nodeInfoDispatcher = this.nodeInfoDispatcher; f.webFingerDispatcher = this.webFingerDispatcher; f.objectCallbacks = { ...this.objectCallbacks }; f.objectTypeIds = { ...this.objectTypeIds }; f.inboxPath = this.inboxPath; Loading Loading @@ -491,6 +494,12 @@ export class FederationBuilderImpl<TContextData> this.nodeInfoDispatcher = dispatcher; } setWebFingerLinkDispatcher( dispatcher: WebFingerLinkDispatcher<TContextData>, ): void { this.webFingerDispatcher = dispatcher; } setObjectDispatcher<TObject extends Object, TParam extends string>( // deno-lint-ignore no-explicit-any cls: (new (...args: any[]) => TObject) & { typeId: URL }, Loading packages/fedify/src/federation/callback.ts +10 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import type { NodeInfo } from "../nodeinfo/types.ts"; import type { Actor } from "../vocab/actor.ts"; import type { Activity, CryptographicKey } from "../vocab/mod.ts"; import type { Object } from "../vocab/vocab.ts"; import type { Link } from "../webfinger/mod.ts"; import type { PageItems } from "./collection.ts"; import type { Context, InboxContext, RequestContext } from "./context.ts"; import type { SenderKeyPair } from "./send.ts"; Loading @@ -15,6 +16,15 @@ export type NodeInfoDispatcher<TContextData> = ( context: RequestContext<TContextData>, ) => NodeInfo | Promise<NodeInfo>; /** * A callback that dispatches a array of {@link Link}. * * @template TContextData The context data to pass to the {@link Context}. */ export type WebFingerLinkDispatcher<TContextData> = ( context: RequestContext<TContextData>, ) => Link[] | Promise<Link[]>; /** * A callback that dispatches an {@link Actor} object. * Loading packages/fedify/src/federation/federation.ts +9 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import type { ObjectDispatcher, OutboxErrorHandler, SharedInboxKeyDispatcher, WebFingerLinkDispatcher, } from "./callback.ts"; import type { Context, RequestContext } from "./context.ts"; import type { KvStore } from "./kv.ts"; Loading Loading @@ -79,6 +80,14 @@ export interface Federatable<TContextData> { dispatcher: NodeInfoDispatcher<TContextData>, ): void; /** * Registers a links dispatcher to WebFinger * @param dispatcher A links dispatcher callback to register. */ setWebFingerLinkDispatcher( dispatcher: WebFingerLinkDispatcher<TContextData>, ): void; /** * Registers an actor dispatcher. * Loading Loading
packages/fedify/src/federation/builder.ts +9 −0 Original line number Diff line number Diff line Loading @@ -22,6 +22,7 @@ import type { ObjectAuthorizePredicate, ObjectDispatcher, SharedInboxKeyDispatcher, WebFingerLinkDispatcher, } from "./callback.ts"; import type { Context, RequestContext } from "./context.ts"; import type { Loading @@ -48,6 +49,7 @@ export class FederationBuilderImpl<TContextData> router: Router; actorCallbacks?: ActorCallbacks<TContextData>; nodeInfoDispatcher?: NodeInfoDispatcher<TContextData>; webFingerDispatcher?: WebFingerLinkDispatcher<TContextData>; objectCallbacks: Record<string, ObjectCallbacks<TContextData, string>>; objectTypeIds: Record< string, Loading Loading @@ -148,6 +150,7 @@ export class FederationBuilderImpl<TContextData> ? undefined : { ...this.actorCallbacks }; f.nodeInfoDispatcher = this.nodeInfoDispatcher; f.webFingerDispatcher = this.webFingerDispatcher; f.objectCallbacks = { ...this.objectCallbacks }; f.objectTypeIds = { ...this.objectTypeIds }; f.inboxPath = this.inboxPath; Loading Loading @@ -491,6 +494,12 @@ export class FederationBuilderImpl<TContextData> this.nodeInfoDispatcher = dispatcher; } setWebFingerLinkDispatcher( dispatcher: WebFingerLinkDispatcher<TContextData>, ): void { this.webFingerDispatcher = dispatcher; } setObjectDispatcher<TObject extends Object, TParam extends string>( // deno-lint-ignore no-explicit-any cls: (new (...args: any[]) => TObject) & { typeId: URL }, Loading
packages/fedify/src/federation/callback.ts +10 −0 Original line number Diff line number Diff line Loading @@ -2,6 +2,7 @@ import type { NodeInfo } from "../nodeinfo/types.ts"; import type { Actor } from "../vocab/actor.ts"; import type { Activity, CryptographicKey } from "../vocab/mod.ts"; import type { Object } from "../vocab/vocab.ts"; import type { Link } from "../webfinger/mod.ts"; import type { PageItems } from "./collection.ts"; import type { Context, InboxContext, RequestContext } from "./context.ts"; import type { SenderKeyPair } from "./send.ts"; Loading @@ -15,6 +16,15 @@ export type NodeInfoDispatcher<TContextData> = ( context: RequestContext<TContextData>, ) => NodeInfo | Promise<NodeInfo>; /** * A callback that dispatches a array of {@link Link}. * * @template TContextData The context data to pass to the {@link Context}. */ export type WebFingerLinkDispatcher<TContextData> = ( context: RequestContext<TContextData>, ) => Link[] | Promise<Link[]>; /** * A callback that dispatches an {@link Actor} object. * Loading
packages/fedify/src/federation/federation.ts +9 −0 Original line number Diff line number Diff line Loading @@ -28,6 +28,7 @@ import type { ObjectDispatcher, OutboxErrorHandler, SharedInboxKeyDispatcher, WebFingerLinkDispatcher, } from "./callback.ts"; import type { Context, RequestContext } from "./context.ts"; import type { KvStore } from "./kv.ts"; Loading Loading @@ -79,6 +80,14 @@ export interface Federatable<TContextData> { dispatcher: NodeInfoDispatcher<TContextData>, ): void; /** * Registers a links dispatcher to WebFinger * @param dispatcher A links dispatcher callback to register. */ setWebFingerLinkDispatcher( dispatcher: WebFingerLinkDispatcher<TContextData>, ): void; /** * Registers an actor dispatcher. * Loading