fix: add WebFinger handle mapper and Ed25519 key pair

1. mapHandle() — tells Fedify how to resolve WebFinger usernames to
   actor identifiers, suppressing the "No actor handle mapper is set"
   warning on every WebFinger lookup.

2. Ed25519 key pair — generated alongside the legacy RSA pair so Fedify
   can create Object Integrity Proofs on outbound activities. RSA is
   kept for HTTP Signatures backward compatibility.
This commit is contained in:
Ricardo
2026-02-19 20:18:16 +01:00
parent 8a03dc9c9d
commit 656b66c780
2 changed files with 18 additions and 5 deletions
+17 -4
View File
@@ -15,6 +15,7 @@ import {
Person, Person,
PropertyValue, PropertyValue,
createFederation, createFederation,
generateCryptoKeyPair,
importSpki, importSpki,
} from "@fedify/fedify"; } from "@fedify/fedify";
import { configure, getConsoleSink } from "@logtape/logtape"; import { configure, getConsoleSink } from "@logtape/logtape";
@@ -134,23 +135,35 @@ export function setupFederation(options) {
return new Person(personOptions); return new Person(personOptions);
}, },
) )
.mapHandle((_ctx, username) => (username === handle ? handle : null))
.setKeyPairsDispatcher(async (ctx, identifier) => { .setKeyPairsDispatcher(async (ctx, identifier) => {
if (identifier !== handle) return []; if (identifier !== handle) return [];
const keyPairs = [];
// Import legacy RSA key pair (for HTTP Signatures compatibility)
const legacyKey = await collections.ap_keys.findOne({}); const legacyKey = await collections.ap_keys.findOne({});
if (legacyKey?.publicKeyPem && legacyKey?.privateKeyPem) { if (legacyKey?.publicKeyPem && legacyKey?.privateKeyPem) {
try { try {
const publicKey = await importSpki(legacyKey.publicKeyPem, "RSA"); const publicKey = await importSpki(legacyKey.publicKeyPem);
const privateKey = await importPkcs8Pem(legacyKey.privateKeyPem); const privateKey = await importPkcs8Pem(legacyKey.privateKeyPem);
return [{ publicKey, privateKey }]; keyPairs.push({ publicKey, privateKey });
} catch { } catch {
console.warn( console.warn(
"[ActivityPub] Could not import legacy RSA keys, generating new key pairs", "[ActivityPub] Could not import legacy RSA keys",
); );
} }
} }
return []; // Generate Ed25519 key pair (for Object Integrity Proofs)
try {
const ed25519 = await generateCryptoKeyPair("Ed25519");
keyPairs.push(ed25519);
} catch (error) {
console.warn("[ActivityPub] Could not generate Ed25519 key pair:", error.message);
}
return keyPairs;
}); });
// --- Inbox listeners --- // --- Inbox listeners ---
+1 -1
View File
@@ -1,6 +1,6 @@
{ {
"name": "@rmdes/indiekit-endpoint-activitypub", "name": "@rmdes/indiekit-endpoint-activitypub",
"version": "1.0.9", "version": "1.0.10",
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.", "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
"keywords": [ "keywords": [
"indiekit", "indiekit",