@rmdes/indiekit-endpoint-activitypub 1.0.8 → 1.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/federation-setup.js +20 -5
- package/package.json +1 -1
package/lib/federation-setup.js
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
* and inbox.js with Fedify's battle-tested implementations.
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
+
import { AsyncLocalStorage } from "node:async_hooks";
|
|
9
10
|
import { Temporal } from "@js-temporal/polyfill";
|
|
10
11
|
import {
|
|
11
12
|
Endpoints,
|
|
@@ -14,9 +15,10 @@ import {
|
|
|
14
15
|
Person,
|
|
15
16
|
PropertyValue,
|
|
16
17
|
createFederation,
|
|
18
|
+
generateCryptoKeyPair,
|
|
17
19
|
importSpki,
|
|
18
20
|
} from "@fedify/fedify";
|
|
19
|
-
import { configure, getConsoleSink
|
|
21
|
+
import { configure, getConsoleSink } from "@logtape/logtape";
|
|
20
22
|
import { MongoKvStore } from "./kv-store.js";
|
|
21
23
|
import { registerInboxListeners } from "./inbox-listeners.js";
|
|
22
24
|
|
|
@@ -45,6 +47,7 @@ export function setupFederation(options) {
|
|
|
45
47
|
if (!_logtapeConfigured) {
|
|
46
48
|
_logtapeConfigured = true;
|
|
47
49
|
configure({
|
|
50
|
+
contextLocalStorage: new AsyncLocalStorage(),
|
|
48
51
|
sinks: {
|
|
49
52
|
console: getConsoleSink(),
|
|
50
53
|
},
|
|
@@ -132,23 +135,35 @@ export function setupFederation(options) {
|
|
|
132
135
|
return new Person(personOptions);
|
|
133
136
|
},
|
|
134
137
|
)
|
|
138
|
+
.mapHandle((_ctx, username) => (username === handle ? handle : null))
|
|
135
139
|
.setKeyPairsDispatcher(async (ctx, identifier) => {
|
|
136
140
|
if (identifier !== handle) return [];
|
|
137
141
|
|
|
142
|
+
const keyPairs = [];
|
|
143
|
+
|
|
144
|
+
// Import legacy RSA key pair (for HTTP Signatures compatibility)
|
|
138
145
|
const legacyKey = await collections.ap_keys.findOne({});
|
|
139
146
|
if (legacyKey?.publicKeyPem && legacyKey?.privateKeyPem) {
|
|
140
147
|
try {
|
|
141
|
-
const publicKey = await importSpki(legacyKey.publicKeyPem
|
|
148
|
+
const publicKey = await importSpki(legacyKey.publicKeyPem);
|
|
142
149
|
const privateKey = await importPkcs8Pem(legacyKey.privateKeyPem);
|
|
143
|
-
|
|
150
|
+
keyPairs.push({ publicKey, privateKey });
|
|
144
151
|
} catch {
|
|
145
152
|
console.warn(
|
|
146
|
-
"[ActivityPub] Could not import legacy RSA keys
|
|
153
|
+
"[ActivityPub] Could not import legacy RSA keys",
|
|
147
154
|
);
|
|
148
155
|
}
|
|
149
156
|
}
|
|
150
157
|
|
|
151
|
-
|
|
158
|
+
// Generate Ed25519 key pair (for Object Integrity Proofs)
|
|
159
|
+
try {
|
|
160
|
+
const ed25519 = await generateCryptoKeyPair("Ed25519");
|
|
161
|
+
keyPairs.push(ed25519);
|
|
162
|
+
} catch (error) {
|
|
163
|
+
console.warn("[ActivityPub] Could not generate Ed25519 key pair:", error.message);
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
return keyPairs;
|
|
152
167
|
});
|
|
153
168
|
|
|
154
169
|
// --- Inbox listeners ---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmdes/indiekit-endpoint-activitypub",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"indiekit",
|