@rmdes/indiekit-endpoint-activitypub 0.1.10 → 1.0.0
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/index.js +155 -174
- package/lib/controllers/migrate.js +23 -5
- package/lib/controllers/profile.js +71 -0
- package/lib/federation-bridge.js +119 -0
- package/lib/federation-setup.js +321 -0
- package/lib/inbox-listeners.js +215 -0
- package/lib/jf2-to-as2.js +262 -63
- package/lib/kv-store.js +55 -0
- package/locales/en.json +18 -0
- package/package.json +2 -1
- package/views/activitypub-dashboard.njk +4 -0
- package/views/activitypub-profile.njk +74 -0
- package/lib/actor.js +0 -75
- package/lib/federation.js +0 -410
- package/lib/inbox.js +0 -291
- package/lib/keys.js +0 -39
- package/lib/webfinger.js +0 -43
package/lib/keys.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import { generateKeyPair } from "node:crypto";
|
|
2
|
-
import { promisify } from "node:util";
|
|
3
|
-
|
|
4
|
-
const generateKeyPairAsync = promisify(generateKeyPair);
|
|
5
|
-
|
|
6
|
-
/**
|
|
7
|
-
* Get or create an RSA 2048-bit key pair for the ActivityPub actor.
|
|
8
|
-
* Keys are stored in the ap_keys MongoDB collection so they persist
|
|
9
|
-
* across server restarts — a stable key pair is essential for federation
|
|
10
|
-
* since remote servers cache the public key for signature verification.
|
|
11
|
-
*
|
|
12
|
-
* @param {Collection} collection - MongoDB ap_keys collection
|
|
13
|
-
* @param {string} actorUrl - Actor URL (used as the key document identifier)
|
|
14
|
-
* @returns {Promise<{publicKeyPem: string, privateKeyPem: string}>}
|
|
15
|
-
*/
|
|
16
|
-
export async function getOrCreateKeyPair(collection, actorUrl) {
|
|
17
|
-
const existing = await collection.findOne({ actorUrl });
|
|
18
|
-
if (existing) {
|
|
19
|
-
return {
|
|
20
|
-
publicKeyPem: existing.publicKeyPem,
|
|
21
|
-
privateKeyPem: existing.privateKeyPem,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const { publicKey, privateKey } = await generateKeyPairAsync("rsa", {
|
|
26
|
-
modulusLength: 2048,
|
|
27
|
-
publicKeyEncoding: { type: "spki", format: "pem" },
|
|
28
|
-
privateKeyEncoding: { type: "pkcs8", format: "pem" },
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
await collection.insertOne({
|
|
32
|
-
actorUrl,
|
|
33
|
-
publicKeyPem: publicKey,
|
|
34
|
-
privateKeyPem: privateKey,
|
|
35
|
-
createdAt: new Date().toISOString(),
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return { publicKeyPem: publicKey, privateKeyPem: privateKey };
|
|
39
|
-
}
|
package/lib/webfinger.js
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Handle WebFinger resource resolution.
|
|
3
|
-
*
|
|
4
|
-
* WebFinger is the discovery mechanism for ActivityPub — when someone
|
|
5
|
-
* searches for @rick@rmendes.net, their server queries:
|
|
6
|
-
* GET /.well-known/webfinger?resource=acct:rick@rmendes.net
|
|
7
|
-
*
|
|
8
|
-
* We return a JRD (JSON Resource Descriptor) pointing to the actor URL
|
|
9
|
-
* so the remote server can then fetch the full actor document.
|
|
10
|
-
*
|
|
11
|
-
* @param {string} resource - The resource query (e.g. "acct:rick@rmendes.net")
|
|
12
|
-
* @param {object} options
|
|
13
|
-
* @param {string} options.handle - Actor handle (e.g. "rick")
|
|
14
|
-
* @param {string} options.hostname - Publication hostname (e.g. "rmendes.net")
|
|
15
|
-
* @param {string} options.actorUrl - Full actor URL (e.g. "https://rmendes.net/")
|
|
16
|
-
* @returns {object|null} JRD response object, or null if resource doesn't match
|
|
17
|
-
*/
|
|
18
|
-
export function handleWebFinger(resource, options) {
|
|
19
|
-
const { handle, hostname, actorUrl } = options;
|
|
20
|
-
const expectedAcct = `acct:${handle}@${hostname}`;
|
|
21
|
-
|
|
22
|
-
// Match both "acct:rick@rmendes.net" and the actor URL itself
|
|
23
|
-
if (resource !== expectedAcct && resource !== actorUrl) {
|
|
24
|
-
return null;
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
return {
|
|
28
|
-
subject: expectedAcct,
|
|
29
|
-
aliases: [actorUrl],
|
|
30
|
-
links: [
|
|
31
|
-
{
|
|
32
|
-
rel: "self",
|
|
33
|
-
type: "application/activity+json",
|
|
34
|
-
href: actorUrl,
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
rel: "http://webfinger.net/rel/profile-page",
|
|
38
|
-
type: "text/html",
|
|
39
|
-
href: actorUrl,
|
|
40
|
-
},
|
|
41
|
-
],
|
|
42
|
-
};
|
|
43
|
-
}
|