javascript-solid-server 0.0.64 → 0.0.66
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/package.json +1 -1
- package/src/ap/index.js +1 -1
- package/src/ap/routes/inbox.js +14 -6
- package/src/ap/store.js +1 -1
package/package.json
CHANGED
package/src/ap/index.js
CHANGED
|
@@ -135,7 +135,7 @@ export async function activityPubPlugin(fastify, options = {}) {
|
|
|
135
135
|
version: '2.1',
|
|
136
136
|
software: {
|
|
137
137
|
name: 'jss',
|
|
138
|
-
version: '0.0.
|
|
138
|
+
version: '0.0.66',
|
|
139
139
|
repository: 'https://github.com/JavaScriptSolidServer/JavaScriptSolidServer'
|
|
140
140
|
},
|
|
141
141
|
protocols: ['activitypub', 'solid'],
|
package/src/ap/routes/inbox.js
CHANGED
|
@@ -17,9 +17,10 @@ import { getKeyId } from '../keys.js'
|
|
|
17
17
|
/**
|
|
18
18
|
* Fetch remote actor (with caching)
|
|
19
19
|
* @param {string} id - Actor URL
|
|
20
|
+
* @param {object} log - Logger instance (optional)
|
|
20
21
|
* @returns {Promise<object|null>} Actor object or null
|
|
21
22
|
*/
|
|
22
|
-
async function fetchActor(id) {
|
|
23
|
+
async function fetchActor(id, log) {
|
|
23
24
|
// Strip fragment for fetching
|
|
24
25
|
const fetchUrl = id.replace(/#.*$/, '')
|
|
25
26
|
const cached = getCachedActor(id)
|
|
@@ -27,14 +28,21 @@ async function fetchActor(id) {
|
|
|
27
28
|
|
|
28
29
|
try {
|
|
29
30
|
const response = await fetch(fetchUrl, {
|
|
30
|
-
headers: {
|
|
31
|
+
headers: {
|
|
32
|
+
'Accept': 'application/activity+json',
|
|
33
|
+
'User-Agent': 'JSS/1.0 (+https://github.com/JavaScriptSolidServer/JavaScriptSolidServer)'
|
|
34
|
+
}
|
|
31
35
|
})
|
|
32
|
-
if (!response.ok)
|
|
36
|
+
if (!response.ok) {
|
|
37
|
+
if (log) log.warn(`Actor fetch failed: ${response.status} ${response.statusText} for ${fetchUrl}`)
|
|
38
|
+
return null
|
|
39
|
+
}
|
|
33
40
|
|
|
34
41
|
const actor = await response.json()
|
|
35
42
|
cacheActor(actor)
|
|
36
43
|
return actor
|
|
37
|
-
} catch {
|
|
44
|
+
} catch (err) {
|
|
45
|
+
if (log) log.error(`Actor fetch error for ${fetchUrl}: ${err.message}`)
|
|
38
46
|
return null
|
|
39
47
|
}
|
|
40
48
|
}
|
|
@@ -66,7 +74,7 @@ async function verifySignature(request, body) {
|
|
|
66
74
|
const actorUrl = keyId.replace(/#.*$/, '')
|
|
67
75
|
|
|
68
76
|
// Fetch the actor to get their public key
|
|
69
|
-
const remoteActor = await fetchActor(actorUrl)
|
|
77
|
+
const remoteActor = await fetchActor(actorUrl, request.log)
|
|
70
78
|
if (!remoteActor) {
|
|
71
79
|
return { valid: false, reason: `Could not fetch actor: ${actorUrl}` }
|
|
72
80
|
}
|
|
@@ -185,7 +193,7 @@ export function createInboxHandler(config, keypair) {
|
|
|
185
193
|
* Handle Follow activity
|
|
186
194
|
*/
|
|
187
195
|
async function handleFollow(activity, actorId, profileUrl, keypair, log) {
|
|
188
|
-
const followerActor = await fetchActor(activity.actor)
|
|
196
|
+
const followerActor = await fetchActor(activity.actor, log)
|
|
189
197
|
if (!followerActor) {
|
|
190
198
|
log.warn('Could not fetch follower actor')
|
|
191
199
|
return
|
package/src/ap/store.js
CHANGED
|
@@ -267,7 +267,7 @@ export function getPostCount() {
|
|
|
267
267
|
|
|
268
268
|
export function cacheActor(actor) {
|
|
269
269
|
runStmt(
|
|
270
|
-
|
|
270
|
+
"INSERT OR REPLACE INTO actors (id, data, fetched_at) VALUES (?, ?, datetime('now'))",
|
|
271
271
|
[actor.id, JSON.stringify(actor)]
|
|
272
272
|
)
|
|
273
273
|
}
|