@fedify/relay 2.4.0-dev.1995 → 2.4.0-dev.2027
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/dist/litepub.test.js +34 -22
- package/dist/mastodon.test.js +33 -21
- package/dist/{types-C_5jld-p.js → types-DxkJkX6J.js} +21877 -21875
- package/package.json +4 -4
package/dist/litepub.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-
|
|
4
|
+
import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-DxkJkX6J.js";
|
|
5
5
|
import { MemoryKvStore, signRequest } from "@fedify/fedify";
|
|
6
6
|
import { createRelay } from "@fedify/relay";
|
|
7
7
|
import { deepStrictEqual, ok, strictEqual } from "node:assert";
|
|
@@ -17,7 +17,7 @@ const mockDocumentLoader = async (url) => {
|
|
|
17
17
|
id: url,
|
|
18
18
|
type: "Person",
|
|
19
19
|
preferredUsername: "alice",
|
|
20
|
-
inbox:
|
|
20
|
+
inbox: aliceInbox,
|
|
21
21
|
publicKey: {
|
|
22
22
|
id: "https://remote.example.com/users/alice#main-key",
|
|
23
23
|
owner: url.replace(/#main-key$/, ""),
|
|
@@ -73,6 +73,7 @@ const davePublicKey = {
|
|
|
73
73
|
...rsaKeyPair.publicKey
|
|
74
74
|
};
|
|
75
75
|
const INBOX_PREFIX = "https://[2001:db8:1::";
|
|
76
|
+
const aliceInbox = `${INBOX_PREFIX}4]/users/alice/inbox`;
|
|
76
77
|
const daveInbox = `${INBOX_PREFIX}1]/users/dave/inbox`;
|
|
77
78
|
const pendingInbox = `${INBOX_PREFIX}2]/users/bob/inbox`;
|
|
78
79
|
const acceptedInbox = `${INBOX_PREFIX}3]/users/carol/inbox`;
|
|
@@ -82,6 +83,15 @@ function recordInbox(inbox) {
|
|
|
82
83
|
recorders.set(inbox, recorded);
|
|
83
84
|
return recorded;
|
|
84
85
|
}
|
|
86
|
+
const aliceDeliveries = recordInbox(aliceInbox);
|
|
87
|
+
function assertAcceptDelivered(follow, deliveries = aliceDeliveries) {
|
|
88
|
+
const accepts = deliveries.filter(({ body }) => body.type === "Accept" && body.object?.id === follow.id?.href);
|
|
89
|
+
strictEqual(accepts.length, 1, "Expected exactly one Accept for this Follow");
|
|
90
|
+
strictEqual(accepts[0].method, "POST");
|
|
91
|
+
strictEqual(accepts[0].body.actor, "https://relay.example.com/users/relay");
|
|
92
|
+
strictEqual(accepts[0].body.object.type, "Follow");
|
|
93
|
+
strictEqual(accepts[0].body.object.actor.id, follow.actorId?.href);
|
|
94
|
+
}
|
|
85
95
|
const nextFetch = globalThis.fetch;
|
|
86
96
|
globalThis.fetch = (async (input, init) => {
|
|
87
97
|
const request = input instanceof Request ? input : new Request(input, init);
|
|
@@ -229,7 +239,7 @@ describe("LitePubRelay", () => {
|
|
|
229
239
|
inbox: new URL(daveInbox)
|
|
230
240
|
});
|
|
231
241
|
const followActivity = new Follow({
|
|
232
|
-
id: new URL(
|
|
242
|
+
id: new URL(`https://remote.example.com/activities/follow/${crypto.randomUUID()}`),
|
|
233
243
|
actor: follower.id,
|
|
234
244
|
object: new URL("https://relay.example.com/users/relay")
|
|
235
245
|
});
|
|
@@ -240,8 +250,8 @@ describe("LitePubRelay", () => {
|
|
|
240
250
|
});
|
|
241
251
|
request = await signRequest(request, rsaKeyPair.privateKey, davePublicKey.id);
|
|
242
252
|
const deliveredActivities = recordInbox(daveInbox);
|
|
243
|
-
|
|
244
|
-
|
|
253
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
254
|
+
assertAcceptDelivered(followActivity, deliveredActivities);
|
|
245
255
|
strictEqual(handlerCalled, true);
|
|
246
256
|
ok(handlerActor);
|
|
247
257
|
const followerData = await kv.get(["follower", "https://remote.example.com/users/dave"]);
|
|
@@ -267,7 +277,7 @@ describe("LitePubRelay", () => {
|
|
|
267
277
|
const follower = new Person({
|
|
268
278
|
id: new URL("https://remote.example.com/users/alice"),
|
|
269
279
|
preferredUsername: "alice",
|
|
270
|
-
inbox: new URL(
|
|
280
|
+
inbox: new URL(aliceInbox)
|
|
271
281
|
});
|
|
272
282
|
const followActivity = new Follow({
|
|
273
283
|
id: new URL("https://remote.example.com/activities/follow/1"),
|
|
@@ -280,7 +290,7 @@ describe("LitePubRelay", () => {
|
|
|
280
290
|
body: JSON.stringify(await followActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
281
291
|
});
|
|
282
292
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
283
|
-
await relay.fetch(request);
|
|
293
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
284
294
|
strictEqual(await kv.get(["follower", "https://remote.example.com/users/alice"]), void 0);
|
|
285
295
|
});
|
|
286
296
|
test("handles public Follow activity", async () => {
|
|
@@ -295,10 +305,10 @@ describe("LitePubRelay", () => {
|
|
|
295
305
|
const follower = new Person({
|
|
296
306
|
id: new URL("https://remote.example.com/users/alice"),
|
|
297
307
|
preferredUsername: "alice",
|
|
298
|
-
inbox: new URL(
|
|
308
|
+
inbox: new URL(aliceInbox)
|
|
299
309
|
});
|
|
300
310
|
const followActivity = new Follow({
|
|
301
|
-
id: new URL(
|
|
311
|
+
id: new URL(`https://remote.example.com/activities/follow/${crypto.randomUUID()}`),
|
|
302
312
|
actor: follower.id,
|
|
303
313
|
object: new URL("https://www.w3.org/ns/activitystreams#Public")
|
|
304
314
|
});
|
|
@@ -308,7 +318,8 @@ describe("LitePubRelay", () => {
|
|
|
308
318
|
body: JSON.stringify(await followActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
309
319
|
});
|
|
310
320
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
311
|
-
await relay.fetch(request);
|
|
321
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
322
|
+
assertAcceptDelivered(followActivity);
|
|
312
323
|
const followerData = await kv.get(["follower", "https://remote.example.com/users/alice"]);
|
|
313
324
|
ok(isRelayFollowerData(followerData));
|
|
314
325
|
strictEqual(followerData.state, "pending");
|
|
@@ -332,7 +343,7 @@ describe("LitePubRelay", () => {
|
|
|
332
343
|
body: JSON.stringify(await followActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
333
344
|
});
|
|
334
345
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
335
|
-
await relay.fetch(request);
|
|
346
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
336
347
|
strictEqual(await kv.get(["follower", "https://remote.example.com/users/alice"]), void 0);
|
|
337
348
|
});
|
|
338
349
|
test("replaces malformed follower data on Follow", async () => {
|
|
@@ -368,7 +379,7 @@ describe("LitePubRelay", () => {
|
|
|
368
379
|
});
|
|
369
380
|
strictEqual(await relay.getFollower(followerId), null);
|
|
370
381
|
const followActivity = new Follow({
|
|
371
|
-
id: new URL(
|
|
382
|
+
id: new URL(`https://remote.example.com/activities/follow/${crypto.randomUUID()}`),
|
|
372
383
|
actor: new URL(followerId),
|
|
373
384
|
object: new URL("https://relay.example.com/users/relay")
|
|
374
385
|
});
|
|
@@ -378,7 +389,8 @@ describe("LitePubRelay", () => {
|
|
|
378
389
|
body: JSON.stringify(await followActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
379
390
|
});
|
|
380
391
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
381
|
-
await relay.fetch(request);
|
|
392
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
393
|
+
assertAcceptDelivered(followActivity);
|
|
382
394
|
strictEqual(handlerCallCount, 1);
|
|
383
395
|
const follower = await relay.getFollower(followerId);
|
|
384
396
|
ok(follower);
|
|
@@ -402,7 +414,7 @@ describe("LitePubRelay", () => {
|
|
|
402
414
|
const follower = new Person({
|
|
403
415
|
id: new URL("https://remote.example.com/users/alice"),
|
|
404
416
|
preferredUsername: "alice",
|
|
405
|
-
inbox: new URL(
|
|
417
|
+
inbox: new URL(aliceInbox)
|
|
406
418
|
});
|
|
407
419
|
await kv.set(["follower", "https://remote.example.com/users/alice"], {
|
|
408
420
|
actor: await follower.toJsonLd(),
|
|
@@ -419,7 +431,7 @@ describe("LitePubRelay", () => {
|
|
|
419
431
|
body: JSON.stringify(await followActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
420
432
|
});
|
|
421
433
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
422
|
-
await relay.fetch(request);
|
|
434
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
423
435
|
strictEqual(handlerCallCount, 0);
|
|
424
436
|
const followerData = await kv.get(["follower", "https://remote.example.com/users/alice"]);
|
|
425
437
|
ok(isRelayFollowerData(followerData));
|
|
@@ -430,7 +442,7 @@ describe("LitePubRelay", () => {
|
|
|
430
442
|
const follower = new Person({
|
|
431
443
|
id: new URL("https://remote.example.com/users/alice"),
|
|
432
444
|
preferredUsername: "alice",
|
|
433
|
-
inbox: new URL(
|
|
445
|
+
inbox: new URL(aliceInbox)
|
|
434
446
|
});
|
|
435
447
|
await kv.set(["follower", "https://remote.example.com/users/alice"], {
|
|
436
448
|
actor: await follower.toJsonLd(),
|
|
@@ -459,7 +471,7 @@ describe("LitePubRelay", () => {
|
|
|
459
471
|
body: JSON.stringify(await acceptActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
460
472
|
});
|
|
461
473
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
462
|
-
await relay.fetch(request);
|
|
474
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
463
475
|
const followerData = await kv.get(["follower", "https://remote.example.com/users/alice"]);
|
|
464
476
|
ok(isRelayFollowerData(followerData));
|
|
465
477
|
strictEqual(followerData.state, "accepted");
|
|
@@ -507,7 +519,7 @@ describe("LitePubRelay", () => {
|
|
|
507
519
|
body: JSON.stringify(await acceptActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
508
520
|
});
|
|
509
521
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
510
|
-
await relay.fetch(request);
|
|
522
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
511
523
|
deepStrictEqual(await kv.get(["follower", followerId]), invalidRow);
|
|
512
524
|
}
|
|
513
525
|
});
|
|
@@ -517,7 +529,7 @@ describe("LitePubRelay", () => {
|
|
|
517
529
|
const follower = new Person({
|
|
518
530
|
id: new URL(followerId),
|
|
519
531
|
preferredUsername: "alice",
|
|
520
|
-
inbox: new URL(
|
|
532
|
+
inbox: new URL(aliceInbox)
|
|
521
533
|
});
|
|
522
534
|
await kv.set(["follower", followerId], {
|
|
523
535
|
actor: await follower.toJsonLd(),
|
|
@@ -546,7 +558,7 @@ describe("LitePubRelay", () => {
|
|
|
546
558
|
body: JSON.stringify(await undoActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
547
559
|
});
|
|
548
560
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
549
|
-
await relay.fetch(request);
|
|
561
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
550
562
|
strictEqual(await kv.get(["follower", followerId]), void 0);
|
|
551
563
|
});
|
|
552
564
|
test("handles Create activity with Announce forwarding", async () => {
|
|
@@ -555,7 +567,7 @@ describe("LitePubRelay", () => {
|
|
|
555
567
|
const follower = new Person({
|
|
556
568
|
id: new URL(followerId),
|
|
557
569
|
preferredUsername: "alice",
|
|
558
|
-
inbox: new URL(
|
|
570
|
+
inbox: new URL(aliceInbox)
|
|
559
571
|
});
|
|
560
572
|
await kv.set(["follower", followerId], {
|
|
561
573
|
actor: await follower.toJsonLd(),
|
|
@@ -858,7 +870,7 @@ describe("LitePubRelay", () => {
|
|
|
858
870
|
id: new URL(followerId),
|
|
859
871
|
preferredUsername: "alice",
|
|
860
872
|
name: "Alice Wonderland",
|
|
861
|
-
inbox: new URL(
|
|
873
|
+
inbox: new URL(aliceInbox)
|
|
862
874
|
});
|
|
863
875
|
await kv.set(["follower", followerId], {
|
|
864
876
|
actor: await follower.toJsonLd(),
|
package/dist/mastodon.test.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-
|
|
4
|
+
import { n as exportSpki, r as getDocumentLoader, t as isRelayFollowerData } from "./types-DxkJkX6J.js";
|
|
5
5
|
import { MemoryKvStore, signJsonLd, signRequest } from "@fedify/fedify";
|
|
6
6
|
import { createRelay } from "@fedify/relay";
|
|
7
7
|
import { deepStrictEqual, ok, strictEqual } from "node:assert";
|
|
@@ -17,7 +17,7 @@ const mockDocumentLoader = async (url) => {
|
|
|
17
17
|
id: url,
|
|
18
18
|
type: "Person",
|
|
19
19
|
preferredUsername: "alice",
|
|
20
|
-
inbox:
|
|
20
|
+
inbox: aliceInbox,
|
|
21
21
|
publicKey: {
|
|
22
22
|
id: "https://remote.example.com/users/alice#main-key",
|
|
23
23
|
owner: url.replace(/#main-key$/, ""),
|
|
@@ -53,6 +53,7 @@ const rsaPublicKey = {
|
|
|
53
53
|
...rsaKeyPair.publicKey
|
|
54
54
|
};
|
|
55
55
|
const INBOX_PREFIX = "https://[2001:db8:2::";
|
|
56
|
+
const aliceInbox = `${INBOX_PREFIX}2]/users/alice/inbox`;
|
|
56
57
|
const followerInbox = `${INBOX_PREFIX}1]/users/bob/inbox`;
|
|
57
58
|
const recorders = /* @__PURE__ */ new Map();
|
|
58
59
|
function recordInbox(inbox) {
|
|
@@ -60,6 +61,15 @@ function recordInbox(inbox) {
|
|
|
60
61
|
recorders.set(inbox, recorded);
|
|
61
62
|
return recorded;
|
|
62
63
|
}
|
|
64
|
+
const aliceDeliveries = recordInbox(aliceInbox);
|
|
65
|
+
function assertAcceptDelivered(follow, deliveries = aliceDeliveries) {
|
|
66
|
+
const accepts = deliveries.filter(({ body }) => body.type === "Accept" && body.object?.id === follow.id?.href);
|
|
67
|
+
strictEqual(accepts.length, 1, "Expected exactly one Accept for this Follow");
|
|
68
|
+
strictEqual(accepts[0].method, "POST");
|
|
69
|
+
strictEqual(accepts[0].body.actor, "https://relay.example.com/users/relay");
|
|
70
|
+
strictEqual(accepts[0].body.object.type, "Follow");
|
|
71
|
+
strictEqual(accepts[0].body.object.actor.id, follow.actorId?.href);
|
|
72
|
+
}
|
|
63
73
|
const nextFetch = globalThis.fetch;
|
|
64
74
|
globalThis.fetch = (async (input, init) => {
|
|
65
75
|
const request = input instanceof Request ? input : new Request(input, init);
|
|
@@ -173,7 +183,7 @@ describe("MastodonRelay", () => {
|
|
|
173
183
|
const follower = new Person({
|
|
174
184
|
id: new URL(followerId),
|
|
175
185
|
preferredUsername: "alice",
|
|
176
|
-
inbox: new URL(
|
|
186
|
+
inbox: new URL(aliceInbox)
|
|
177
187
|
});
|
|
178
188
|
await kv.set(["follower", followerId], {
|
|
179
189
|
actor: await follower.toJsonLd(),
|
|
@@ -187,7 +197,7 @@ describe("MastodonRelay", () => {
|
|
|
187
197
|
const follower = new Person({
|
|
188
198
|
id: new URL(followerId),
|
|
189
199
|
preferredUsername: "alice",
|
|
190
|
-
inbox: new URL(
|
|
200
|
+
inbox: new URL(aliceInbox)
|
|
191
201
|
});
|
|
192
202
|
await kv.set(["follower", followerId], {
|
|
193
203
|
actor: await follower.toJsonLd(),
|
|
@@ -256,10 +266,10 @@ describe("MastodonRelay", () => {
|
|
|
256
266
|
const follower = new Person({
|
|
257
267
|
id: new URL("https://remote.example.com/users/alice"),
|
|
258
268
|
preferredUsername: "alice",
|
|
259
|
-
inbox: new URL(
|
|
269
|
+
inbox: new URL(aliceInbox)
|
|
260
270
|
});
|
|
261
271
|
const followActivity = new Follow({
|
|
262
|
-
id: new URL(
|
|
272
|
+
id: new URL(`https://remote.example.com/activities/follow/${crypto.randomUUID()}`),
|
|
263
273
|
actor: follower.id,
|
|
264
274
|
object: new URL("https://relay.example.com/users/relay")
|
|
265
275
|
});
|
|
@@ -269,7 +279,8 @@ describe("MastodonRelay", () => {
|
|
|
269
279
|
body: JSON.stringify(await followActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
270
280
|
});
|
|
271
281
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
272
|
-
await relay.fetch(request);
|
|
282
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
283
|
+
assertAcceptDelivered(followActivity);
|
|
273
284
|
strictEqual(handlerCalled, true);
|
|
274
285
|
ok(handlerActor);
|
|
275
286
|
const followerData = await kv.get(["follower", "https://remote.example.com/users/alice"]);
|
|
@@ -290,7 +301,7 @@ describe("MastodonRelay", () => {
|
|
|
290
301
|
const follower = new Person({
|
|
291
302
|
id: new URL("https://remote.example.com/users/alice"),
|
|
292
303
|
preferredUsername: "alice",
|
|
293
|
-
inbox: new URL(
|
|
304
|
+
inbox: new URL(aliceInbox)
|
|
294
305
|
});
|
|
295
306
|
const followActivity = new Follow({
|
|
296
307
|
id: new URL("https://remote.example.com/activities/follow/1"),
|
|
@@ -303,7 +314,7 @@ describe("MastodonRelay", () => {
|
|
|
303
314
|
body: JSON.stringify(await followActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
304
315
|
});
|
|
305
316
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
306
|
-
await relay.fetch(request);
|
|
317
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
307
318
|
strictEqual(await kv.get(["follower", "https://remote.example.com/users/alice"]), void 0);
|
|
308
319
|
});
|
|
309
320
|
test("handles Undo Follow activity", async () => {
|
|
@@ -312,7 +323,7 @@ describe("MastodonRelay", () => {
|
|
|
312
323
|
const follower = new Person({
|
|
313
324
|
id: new URL(followerId),
|
|
314
325
|
preferredUsername: "alice",
|
|
315
|
-
inbox: new URL(
|
|
326
|
+
inbox: new URL(aliceInbox)
|
|
316
327
|
});
|
|
317
328
|
const followActivityId = "https://remote.example.com/activities/follow/1";
|
|
318
329
|
await kv.set(["follower", followerId], {
|
|
@@ -342,7 +353,7 @@ describe("MastodonRelay", () => {
|
|
|
342
353
|
body: JSON.stringify(await undoActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
343
354
|
});
|
|
344
355
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
345
|
-
await relay.fetch(request);
|
|
356
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
346
357
|
strictEqual(await kv.get(["follower", followerId]), void 0);
|
|
347
358
|
});
|
|
348
359
|
test("handles Create activity forwarding", async () => {
|
|
@@ -351,7 +362,7 @@ describe("MastodonRelay", () => {
|
|
|
351
362
|
const follower = new Person({
|
|
352
363
|
id: new URL(followerId),
|
|
353
364
|
preferredUsername: "alice",
|
|
354
|
-
inbox: new URL(
|
|
365
|
+
inbox: new URL(aliceInbox)
|
|
355
366
|
});
|
|
356
367
|
await kv.set(["follower", followerId], {
|
|
357
368
|
actor: await follower.toJsonLd(),
|
|
@@ -508,7 +519,7 @@ describe("MastodonRelay", () => {
|
|
|
508
519
|
body: JSON.stringify(await followActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
509
520
|
});
|
|
510
521
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
511
|
-
await relay.fetch(request);
|
|
522
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
512
523
|
strictEqual(await kv.get(["follower", "https://remote.example.com/users/alice"]), void 0);
|
|
513
524
|
});
|
|
514
525
|
test("handles public Follow activity", async () => {
|
|
@@ -523,10 +534,10 @@ describe("MastodonRelay", () => {
|
|
|
523
534
|
const follower = new Person({
|
|
524
535
|
id: new URL("https://remote.example.com/users/alice"),
|
|
525
536
|
preferredUsername: "alice",
|
|
526
|
-
inbox: new URL(
|
|
537
|
+
inbox: new URL(aliceInbox)
|
|
527
538
|
});
|
|
528
539
|
const followActivity = new Follow({
|
|
529
|
-
id: new URL(
|
|
540
|
+
id: new URL(`https://remote.example.com/activities/follow/${crypto.randomUUID()}`),
|
|
530
541
|
actor: follower.id,
|
|
531
542
|
object: new URL("https://www.w3.org/ns/activitystreams#Public")
|
|
532
543
|
});
|
|
@@ -536,7 +547,8 @@ describe("MastodonRelay", () => {
|
|
|
536
547
|
body: JSON.stringify(await followActivity.toJsonLd({ contextLoader: mockDocumentLoader }))
|
|
537
548
|
});
|
|
538
549
|
request = await signRequest(request, rsaKeyPair.privateKey, rsaPublicKey.id);
|
|
539
|
-
await relay.fetch(request);
|
|
550
|
+
strictEqual((await relay.fetch(request)).status, 202);
|
|
551
|
+
assertAcceptDelivered(followActivity);
|
|
540
552
|
ok(await kv.get(["follower", "https://remote.example.com/users/alice"]));
|
|
541
553
|
});
|
|
542
554
|
test("list() returns empty when no followers exist", async () => {
|
|
@@ -609,7 +621,7 @@ describe("MastodonRelay", () => {
|
|
|
609
621
|
id: new URL(followerId),
|
|
610
622
|
preferredUsername: "alice",
|
|
611
623
|
name: "Alice Wonderland",
|
|
612
|
-
inbox: new URL(
|
|
624
|
+
inbox: new URL(aliceInbox)
|
|
613
625
|
});
|
|
614
626
|
await kv.set(["follower", followerId], {
|
|
615
627
|
actor: await follower.toJsonLd(),
|
|
@@ -636,12 +648,12 @@ describe("MastodonRelay", () => {
|
|
|
636
648
|
const follower1 = new Person({
|
|
637
649
|
id: new URL("https://remote.example.com/users/alice"),
|
|
638
650
|
preferredUsername: "alice",
|
|
639
|
-
inbox: new URL(
|
|
651
|
+
inbox: new URL(aliceInbox)
|
|
640
652
|
});
|
|
641
653
|
const follower2 = new Person({
|
|
642
654
|
id: new URL("https://remote.example.com/users/bob"),
|
|
643
655
|
preferredUsername: "bob",
|
|
644
|
-
inbox: new URL(
|
|
656
|
+
inbox: new URL(`${INBOX_PREFIX}3]/users/bob/inbox`)
|
|
645
657
|
});
|
|
646
658
|
await kv.set(["follower", "https://remote.example.com/users/alice"], {
|
|
647
659
|
actor: await follower1.toJsonLd(),
|
|
@@ -678,7 +690,7 @@ describe("MastodonRelay", () => {
|
|
|
678
690
|
const follower = new Person({
|
|
679
691
|
id: new URL("https://remote.example.com/users/alice"),
|
|
680
692
|
preferredUsername: "alice",
|
|
681
|
-
inbox: new URL(
|
|
693
|
+
inbox: new URL(aliceInbox)
|
|
682
694
|
});
|
|
683
695
|
await kv.set(["follower", "https://remote.example.com/users/alice"], {
|
|
684
696
|
actor: await follower.toJsonLd(),
|
|
@@ -690,7 +702,7 @@ describe("MastodonRelay", () => {
|
|
|
690
702
|
strictEqual(result.state, "accepted");
|
|
691
703
|
ok(result.actor);
|
|
692
704
|
strictEqual(result.actor.preferredUsername, "alice");
|
|
693
|
-
strictEqual(result.actor.inboxId?.href,
|
|
705
|
+
strictEqual(result.actor.inboxId?.href, aliceInbox);
|
|
694
706
|
strictEqual(await relay.getFollower("https://remote.example.com/users/nonexistent"), null);
|
|
695
707
|
});
|
|
696
708
|
});
|