Unverified Commit 3a666e9c authored by Hong Minhee's avatar Hong Minhee
Browse files

Shared inbox key dispatcher may return null

parent d847634b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -165,6 +165,10 @@ federation
  });
~~~~

> [!NOTE]
> If a shared inbox key dispatcher returns `null`, the default `documentLoader`,
> which is not authenticated, is used for the shared inbox.

[authorized fetch]: https://swicg.github.io/activitypub-http-signature/#authorized-fetch
[instance actor]: https://seb.jambor.dev/posts/understanding-activitypub-part-4-threads/#the-instance-actor

+3 −2
Original line number Diff line number Diff line
@@ -136,7 +136,7 @@ export type InboxErrorHandler<TContextData> = (
 * @param context The request context.
 * @returns The handle of the actor or the key pair for the authenticated
 *          document loader of the {@link Context} passed to the shared inbox
 *          listener.
 *          listener.  If `null` is returned, the request is not authorized.
 * @since 0.11.0
 */
export type SharedInboxKeyDispatcher<TContextData> = (
@@ -144,7 +144,8 @@ export type SharedInboxKeyDispatcher<TContextData> = (
) =>
  | SenderKeyPair
  | { handle: string }
  | Promise<SenderKeyPair | { handle: string }>;
  | null
  | Promise<SenderKeyPair | { handle: string } | null>;

/**
 * A callback that handles errors during outbox processing.
+7 −5
Original line number Diff line number Diff line
@@ -1417,12 +1417,14 @@ export class Federation<TContextData> {
      case "sharedInbox":
        if (routeName !== "inbox" && this.#sharedInboxKeyDispatcher != null) {
          const identity = await this.#sharedInboxKeyDispatcher(context);
          if (identity != null) {
            context = this.#createContext(request, contextData, {
              documentLoader: "handle" in identity
                ? await context.getDocumentLoader(identity)
                : context.getDocumentLoader(identity),
            });
          }
        }
        return await handleInbox(request, {
          handle: route.values.handle ?? null,
          context,