@evanp/activitypub-bot 0.26.1 → 0.26.3
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.
|
@@ -49,6 +49,9 @@ export class HTTPSignatureAuthenticator {
|
|
|
49
49
|
try {
|
|
50
50
|
const keyId = this.#signer.keyId(signature)
|
|
51
51
|
const ok = await this.#remoteKeyStorage.getPublicKey(keyId)
|
|
52
|
+
if (!ok) {
|
|
53
|
+
throw createHttpError(400, 'public key not found')
|
|
54
|
+
}
|
|
52
55
|
let owner = ok.owner
|
|
53
56
|
let publicKeyPem = ok.publicKeyPem
|
|
54
57
|
let result = await this.#signer.validate(publicKeyPem, signature, method, originalUrl, headers)
|
package/lib/routes/server.js
CHANGED
|
@@ -5,32 +5,35 @@ const router = express.Router()
|
|
|
5
5
|
|
|
6
6
|
router.get('/', async (req, res) => {
|
|
7
7
|
const fullUrl = `${req.protocol}://${req.get('host')}${req.originalUrl}`
|
|
8
|
+
const sendJson = async () => {
|
|
9
|
+
const { formatter } = req.app.locals
|
|
10
|
+
const server = await as2.import({
|
|
11
|
+
'@context': [
|
|
12
|
+
'https://www.w3.org/ns/activitystreams',
|
|
13
|
+
'https://w3id.org/security/v1'
|
|
14
|
+
],
|
|
15
|
+
id: formatter.format({ server: true }),
|
|
16
|
+
type: 'Service',
|
|
17
|
+
publicKey: formatter.format({ server: true, type: 'publickey' }),
|
|
18
|
+
url: {
|
|
19
|
+
type: 'Link',
|
|
20
|
+
mediaType: 'text/html',
|
|
21
|
+
href: fullUrl
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
const body = await server.export({ useOriginalContext: true })
|
|
25
|
+
res.status(200)
|
|
26
|
+
res.type(as2.mediaType)
|
|
27
|
+
res.json(body)
|
|
28
|
+
}
|
|
8
29
|
res.format({
|
|
9
30
|
html: async () => {
|
|
10
31
|
const { indexFileName } = req.app.locals
|
|
11
32
|
res.sendFile(indexFileName)
|
|
12
33
|
},
|
|
13
|
-
json:
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
'@context': [
|
|
17
|
-
'https://www.w3.org/ns/activitystreams',
|
|
18
|
-
'https://w3id.org/security/v1'
|
|
19
|
-
],
|
|
20
|
-
id: formatter.format({ server: true }),
|
|
21
|
-
type: 'Service',
|
|
22
|
-
publicKey: formatter.format({ server: true, type: 'publickey' }),
|
|
23
|
-
url: {
|
|
24
|
-
type: 'Link',
|
|
25
|
-
mediaType: 'text/html',
|
|
26
|
-
href: fullUrl
|
|
27
|
-
}
|
|
28
|
-
})
|
|
29
|
-
const body = await server.export({ useOriginalContext: true })
|
|
30
|
-
res.status(200)
|
|
31
|
-
res.type(as2.mediaType)
|
|
32
|
-
res.json(body)
|
|
33
|
-
}
|
|
34
|
+
'application/activity+json': sendJson,
|
|
35
|
+
'application/ld+json': sendJson,
|
|
36
|
+
json: sendJson
|
|
34
37
|
})
|
|
35
38
|
})
|
|
36
39
|
|