@evanp/activitypub-bot 0.13.0 → 0.13.1

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.
Files changed (41) hide show
  1. package/package.json +2 -2
  2. package/.github/dependabot.yml +0 -11
  3. package/.github/workflows/main.yml +0 -34
  4. package/.github/workflows/tag.yml +0 -106
  5. package/.nvmrc +0 -1
  6. package/Dockerfile +0 -17
  7. package/docs/activitypub.bot.drawio +0 -110
  8. package/tests/activitydistributor.test.js +0 -606
  9. package/tests/activityhandler.test.js +0 -2276
  10. package/tests/activitypubclient.test.js +0 -210
  11. package/tests/actorstorage.test.js +0 -283
  12. package/tests/app.test.js +0 -17
  13. package/tests/authorizer.test.js +0 -301
  14. package/tests/bot.donothing.test.js +0 -30
  15. package/tests/bot.ok.test.js +0 -101
  16. package/tests/botcontext.test.js +0 -720
  17. package/tests/botdatastorage.test.js +0 -88
  18. package/tests/botfactory.provincebotfactory.test.js +0 -430
  19. package/tests/digester.test.js +0 -56
  20. package/tests/fixtures/bots.js +0 -27
  21. package/tests/fixtures/eventloggingbot.js +0 -57
  22. package/tests/fixtures/provincebotfactory.js +0 -53
  23. package/tests/httpsignature.test.js +0 -199
  24. package/tests/httpsignatureauthenticator.test.js +0 -463
  25. package/tests/index.test.js +0 -12
  26. package/tests/keystorage.test.js +0 -124
  27. package/tests/microsyntax.test.js +0 -123
  28. package/tests/objectcache.test.js +0 -133
  29. package/tests/objectstorage.test.js +0 -149
  30. package/tests/remotekeystorage.test.js +0 -78
  31. package/tests/routes.actor.test.js +0 -214
  32. package/tests/routes.collection.test.js +0 -310
  33. package/tests/routes.health.test.js +0 -41
  34. package/tests/routes.inbox.test.js +0 -216
  35. package/tests/routes.object.test.js +0 -525
  36. package/tests/routes.server.test.js +0 -69
  37. package/tests/routes.sharedinbox.test.js +0 -473
  38. package/tests/routes.webfinger.test.js +0 -68
  39. package/tests/urlformatter.test.js +0 -164
  40. package/tests/utils/digest.js +0 -7
  41. package/tests/utils/nock.js +0 -499
@@ -1,216 +0,0 @@
1
- import { describe, it, before } from 'node:test'
2
- import assert from 'node:assert'
3
- import as2 from '../lib/activitystreams.js'
4
- import request from 'supertest'
5
-
6
- import { makeApp } from '../lib/app.js'
7
-
8
- import { nockSetup, nockSignature, nockFormat } from './utils/nock.js'
9
- import { makeDigest } from './utils/digest.js'
10
- import bots from './fixtures/bots.js'
11
-
12
- describe('routes.inbox', async () => {
13
- const host = 'activitypubbot.test'
14
- const origin = `https://${host}`
15
- const databaseUrl = 'sqlite::memory:'
16
- let app = null
17
-
18
- before(async () => {
19
- nockSetup('social.example')
20
- app = await makeApp(databaseUrl, origin, bots, 'silent')
21
- })
22
-
23
- describe('GET /user/{botid}/inbox', async () => {
24
- let response = null
25
- it('should work without an error', async () => {
26
- response = await request(app).get('/user/ok/inbox')
27
- })
28
- it('should return 403 Forbidden', async () => {
29
- assert.strictEqual(response.status, 403)
30
- })
31
- it('should return Problem Details JSON', async () => {
32
- assert.strictEqual(response.type, 'application/problem+json')
33
- })
34
- it('should return an object', async () => {
35
- assert.strictEqual(typeof response.body, 'object')
36
- })
37
- it('should return an object with a type', async () => {
38
- assert.strictEqual(typeof response.body.type, 'string')
39
- })
40
- it('should return an object with an type matching the request', async () => {
41
- assert.strictEqual(response.body.type, 'about:blank')
42
- })
43
- it('should return an object with a title', async () => {
44
- assert.strictEqual(typeof response.body.title, 'string')
45
- })
46
- it('should return an object with a title matching the request', async () => {
47
- assert.strictEqual(response.body.title, 'Forbidden')
48
- })
49
- it('should return an object with a status', async () => {
50
- assert.strictEqual(typeof response.body.status, 'number')
51
- })
52
- it('should return an object with a status matching the request', async () => {
53
- assert.strictEqual(response.body.status, 403)
54
- })
55
- it('should return an object with a detail', async () => {
56
- assert.strictEqual(typeof response.body.detail, 'string')
57
- })
58
- it('should return an object with a detail matching the request', async () => {
59
- assert.strictEqual(response.body.detail, 'No access to inbox collection')
60
- })
61
- })
62
-
63
- describe('GET /user/{botid}/inbox/1', async () => {
64
- let response = null
65
- it('should work without an error', async () => {
66
- response = await request(app).get('/user/ok/inbox/1')
67
- })
68
- it('should return 403 Forbidden', async () => {
69
- assert.strictEqual(response.status, 403)
70
- })
71
- it('should return Problem Details JSON', async () => {
72
- assert.strictEqual(response.type, 'application/problem+json')
73
- })
74
- it('should return an object', async () => {
75
- assert.strictEqual(typeof response.body, 'object')
76
- })
77
- it('should return an object with a type', async () => {
78
- assert.strictEqual(typeof response.body.type, 'string')
79
- })
80
- it('should return an object with an type matching the request', async () => {
81
- assert.strictEqual(response.body.type, 'about:blank')
82
- })
83
- it('should return an object with a title', async () => {
84
- assert.strictEqual(typeof response.body.title, 'string')
85
- })
86
- it('should return an object with a title matching the request', async () => {
87
- assert.strictEqual(response.body.title, 'Forbidden')
88
- })
89
- it('should return an object with a status', async () => {
90
- assert.strictEqual(typeof response.body.status, 'number')
91
- })
92
- it('should return an object with a status matching the request', async () => {
93
- assert.strictEqual(response.body.status, 403)
94
- })
95
- it('should return an object with a detail', async () => {
96
- assert.strictEqual(typeof response.body.detail, 'string')
97
- })
98
- it('should return an object with a detail matching the request', async () => {
99
- assert.strictEqual(response.body.detail, 'No access to inbox collection')
100
- })
101
- })
102
-
103
- describe('can handle an incoming activity', async () => {
104
- const username = 'actor1'
105
- const botName = 'test0'
106
- const path = `/user/${botName}/inbox`
107
- const url = `${origin}${path}`
108
- const date = new Date().toUTCString()
109
- const activity = await as2.import({
110
- type: 'Activity',
111
- actor: nockFormat({ username }),
112
- id: nockFormat({ username, type: 'activity', num: 1 })
113
- })
114
- const body = await activity.write()
115
- const digest = makeDigest(body)
116
- const signature = await nockSignature({
117
- method: 'POST',
118
- username,
119
- url,
120
- digest,
121
- date
122
- })
123
- let response = null
124
- it('should work without an error', async () => {
125
- response = await request(app)
126
- .post(path)
127
- .send(body)
128
- .set('Signature', signature)
129
- .set('Date', date)
130
- .set('Host', host)
131
- .set('Digest', digest)
132
- .set('Content-Type', 'application/activity+json')
133
- assert.ok(response)
134
- await app.onIdle()
135
- })
136
- it('should return a 200 status', async () => {
137
- assert.strictEqual(response.status, 200)
138
- })
139
- it('should appear in the inbox', async () => {
140
- const { actorStorage } = app.locals
141
- assert.strictEqual(
142
- true,
143
- await actorStorage.isInCollection(
144
- botName,
145
- 'inbox',
146
- activity
147
- )
148
- )
149
- })
150
- })
151
-
152
- describe('can handle a duplicate incoming activity', async () => {
153
- const username = 'actor2'
154
- const botName = 'test1'
155
- const path = `/user/${botName}/inbox`
156
- const url = `${origin}${path}`
157
- const date = new Date().toUTCString()
158
- const activity = await as2.import({
159
- type: 'Activity',
160
- actor: nockFormat({ username }),
161
- id: nockFormat({ username, type: 'activity', num: 2 }),
162
- to: 'as:Public'
163
- })
164
- const body = await activity.write()
165
- const digest = makeDigest(body)
166
- const signature = await nockSignature({
167
- method: 'POST',
168
- username,
169
- url,
170
- digest,
171
- date
172
- })
173
- let response = null
174
- it('should work without an error', async () => {
175
- response = await request(app)
176
- .post(path)
177
- .send(body)
178
- .set('Signature', signature)
179
- .set('Date', date)
180
- .set('Host', host)
181
- .set('Digest', digest)
182
- .set('Content-Type', 'application/activity+json')
183
- assert.ok(response)
184
- await app.onIdle()
185
- })
186
- it('should return a 200 status', async () => {
187
- assert.strictEqual(response.status, 200)
188
- })
189
- it('should appear in the inbox', async () => {
190
- const { actorStorage } = app.locals
191
- assert.strictEqual(
192
- true,
193
- await actorStorage.isInCollection(
194
- botName,
195
- 'inbox',
196
- activity
197
- )
198
- )
199
- })
200
- it('should fail the second time', async () => {
201
- response = await request(app)
202
- .post(path)
203
- .send(body)
204
- .set('Signature', signature)
205
- .set('Date', date)
206
- .set('Host', host)
207
- .set('Digest', digest)
208
- .set('Content-Type', 'application/activity+json')
209
- assert.ok(response)
210
- await app.onIdle()
211
- })
212
- it('should return a 400 status', async () => {
213
- assert.strictEqual(response.status, 400)
214
- })
215
- })
216
- })