@evanp/activitypub-bot 0.27.1 → 0.28.2

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.
@@ -4,37 +4,32 @@ import as2 from '../activitystreams.js'
4
4
  const router = express.Router()
5
5
 
6
6
  router.get('/', async (req, res) => {
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
- }
29
- res.format({
30
- html: async () => {
31
- const { indexFileName } = req.app.locals
32
- res.sendFile(indexFileName)
33
- },
34
- 'application/activity+json': sendJson,
35
- 'application/ld+json': sendJson,
36
- json: sendJson
7
+ const { indexFileName } = req.app.locals
8
+ res.type('html')
9
+ res.sendFile(indexFileName)
10
+ })
11
+
12
+ router.get('/actor', async (req, res) => {
13
+ const homepage = `${req.protocol}://${req.get('host')}/`
14
+ const { formatter } = req.app.locals
15
+ const server = await as2.import({
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: homepage
27
+ }
37
28
  })
29
+ const body = await server.export({ useOriginalContext: true })
30
+ res.status(200)
31
+ res.type(as2.mediaType)
32
+ res.json(body)
38
33
  })
39
34
 
40
35
  router.get('/publickey', async (req, res) => {
@@ -41,7 +41,7 @@ export class UrlFormatter {
41
41
  }
42
42
  // For the base case, we want a trailing slash.
43
43
  if (url === this.#origin) {
44
- url = `${url}/`
44
+ url = `${url}/actor`
45
45
  }
46
46
  return url
47
47
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@evanp/activitypub-bot",
3
- "version": "0.27.1",
3
+ "version": "0.28.2",
4
4
  "description": "server-side ActivityPub bot framework",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -55,7 +55,7 @@
55
55
  "optionalDependencies": {
56
56
  "mysql2": "^3.9.1",
57
57
  "pg": "^8.16.3",
58
- "sqlite3": "^5.1.7"
58
+ "sqlite3": "^6.0.1"
59
59
  },
60
60
  "engines": {
61
61
  "node": "^20 || ^22 || ^24 || ^25"