@fedify/botkit 0.4.0-dev.181 → 0.4.0-dev.183
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/bot-impl.d.ts +9 -8
- package/dist/bot-impl.d.ts.map +1 -1
- package/dist/bot-impl.js +41 -6
- package/dist/bot-impl.js.map +1 -1
- package/dist/bot-impl.test.js +89 -9
- package/dist/bot-impl.test.js.map +1 -1
- package/dist/bot.d.ts +3 -3
- package/dist/bot.d.ts.map +1 -1
- package/dist/bot.js +2 -3
- package/dist/bot.js.map +1 -1
- package/dist/bot.test.js.map +1 -1
- package/dist/components/FollowButton.d.ts +2 -2
- package/dist/components/Follower.d.ts +1 -1
- package/dist/components/Follower.js +1 -1
- package/dist/components/Follower.js.map +1 -1
- package/dist/components/Message.d.ts.map +1 -1
- package/dist/components/Message.js +3 -3
- package/dist/components/Message.js.map +1 -1
- package/dist/deno.js +3 -2
- package/dist/deno.js.map +1 -1
- package/dist/emoji.d.ts +1 -1
- package/dist/emoji.js.map +1 -1
- package/dist/events.d.ts +1 -1
- package/dist/follow-impl.d.ts +1 -1
- package/dist/follow-impl.js +1 -1
- package/dist/follow-impl.js.map +1 -1
- package/dist/follow-impl.test.js +4 -5
- package/dist/follow-impl.test.js.map +1 -1
- package/dist/follow.d.ts +1 -1
- package/dist/message-impl.d.ts +2 -3
- package/dist/message-impl.d.ts.map +1 -1
- package/dist/message-impl.js +3 -3
- package/dist/message-impl.js.map +1 -1
- package/dist/message-impl.test.js +1 -1
- package/dist/message-impl.test.js.map +1 -1
- package/dist/message.d.ts +3 -4
- package/dist/message.d.ts.map +1 -1
- package/dist/message.js +2 -3
- package/dist/mod.d.ts +3 -3
- package/dist/mod.js +3 -3
- package/dist/pages.d.ts +2 -2
- package/dist/pages.js +1 -1
- package/dist/pages.js.map +1 -1
- package/dist/poll.d.ts +1 -1
- package/dist/reaction.d.ts +1 -1
- package/dist/reaction.js +1 -1
- package/dist/repository.d.ts +1 -1
- package/dist/repository.js +1 -1
- package/dist/repository.js.map +1 -1
- package/dist/repository.test.js +1 -1
- package/dist/repository.test.js.map +1 -1
- package/dist/session-impl.d.ts +2 -1
- package/dist/session-impl.d.ts.map +1 -1
- package/dist/session-impl.js +14 -14
- package/dist/session-impl.js.map +1 -1
- package/dist/session-impl.test.d.ts +1 -1
- package/dist/session-impl.test.js +1 -1
- package/dist/session-impl.test.js.map +1 -1
- package/dist/session.d.ts +3 -3
- package/dist/session.d.ts.map +1 -1
- package/dist/text.d.ts +1 -1
- package/dist/text.js +15 -16
- package/dist/text.js.map +1 -1
- package/dist/text.test.js +22 -19
- package/dist/text.test.js.map +1 -1
- package/package.json +4 -3
package/dist/bot-impl.test.js
CHANGED
|
@@ -5,10 +5,9 @@
|
|
|
5
5
|
import { MemoryRepository } from "./repository.js";
|
|
6
6
|
import { SessionImpl } from "./session-impl.js";
|
|
7
7
|
import { BotImpl } from "./bot-impl.js";
|
|
8
|
-
import { parseSemVer } from "./bot.js";
|
|
9
8
|
import { mention, strong, text } from "./text.js";
|
|
10
9
|
import { MemoryKvStore } from "@fedify/fedify/federation";
|
|
11
|
-
import { Accept, Announce, Article, Collection, Create,
|
|
10
|
+
import { Accept, Announce, Article, Collection, Create, Emoji, EmojiReact, Follow, Image, Like, Mention, Note, PUBLIC_COLLECTION, Person, Place, PropertyValue, Question, Reject, Service, Undo, Update } from "@fedify/vocab";
|
|
12
11
|
import assert from "node:assert";
|
|
13
12
|
import { describe, test } from "node:test";
|
|
14
13
|
|
|
@@ -504,10 +503,21 @@ test("BotImpl.authorizeFollow()", async () => {
|
|
|
504
503
|
object: new URL("https://example.com/ap/actor/john"),
|
|
505
504
|
to: new URL("https://example.com/ap/actor/john")
|
|
506
505
|
}));
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
506
|
+
const setSignedKeyOwner = (owner) => {
|
|
507
|
+
Object.defineProperty(ctx, "getSignedKeyOwner", {
|
|
508
|
+
value: () => Promise.resolve(owner),
|
|
509
|
+
writable: true,
|
|
510
|
+
configurable: true
|
|
511
|
+
});
|
|
512
|
+
};
|
|
513
|
+
setSignedKeyOwner(new Person({ id: new URL("https://example.com/ap/actor/john") }));
|
|
514
|
+
assert.ok(await bot.authorizeFollow(ctx, { id: "b51f6ca8-53e6-4f7d-ac1f-d039e8c6df5a" }));
|
|
515
|
+
setSignedKeyOwner(await new SessionImpl(bot, ctx).getActor());
|
|
516
|
+
assert.ok(await bot.authorizeFollow(ctx, { id: "b51f6ca8-53e6-4f7d-ac1f-d039e8c6df5a" }));
|
|
517
|
+
setSignedKeyOwner(new Person({ id: new URL("https://example.com/ap/actor/alice") }));
|
|
518
|
+
assert.deepStrictEqual(await bot.authorizeFollow(ctx, { id: "b51f6ca8-53e6-4f7d-ac1f-d039e8c6df5a" }), false);
|
|
519
|
+
setSignedKeyOwner(new Person({ id: new URL("https://example.com/ap/actor/john") }));
|
|
520
|
+
assert.deepStrictEqual(await bot.authorizeFollow(ctx, { id: crypto.randomUUID() }), false);
|
|
511
521
|
});
|
|
512
522
|
test("BotImpl.dispatchCreate()", async () => {
|
|
513
523
|
const repository = new MemoryRepository();
|
|
@@ -1460,7 +1470,7 @@ test("BotImpl.dispatchNodeInfo()", () => {
|
|
|
1460
1470
|
username: "bot",
|
|
1461
1471
|
software: {
|
|
1462
1472
|
name: "test",
|
|
1463
|
-
version:
|
|
1473
|
+
version: "1.2.3",
|
|
1464
1474
|
homepage: new URL("https://example.com/"),
|
|
1465
1475
|
repository: new URL("https://git.example.com/")
|
|
1466
1476
|
}
|
|
@@ -1469,7 +1479,7 @@ test("BotImpl.dispatchNodeInfo()", () => {
|
|
|
1469
1479
|
assert.deepStrictEqual(bot.dispatchNodeInfo(ctx), {
|
|
1470
1480
|
software: {
|
|
1471
1481
|
name: "test",
|
|
1472
|
-
version:
|
|
1482
|
+
version: "1.2.3",
|
|
1473
1483
|
homepage: new URL("https://example.com/"),
|
|
1474
1484
|
repository: new URL("https://git.example.com/")
|
|
1475
1485
|
},
|
|
@@ -1505,6 +1515,72 @@ test("BotImpl.fetch()", async () => {
|
|
|
1505
1515
|
const response2 = await botBehindProxy.fetch(request);
|
|
1506
1516
|
assert.deepStrictEqual(response2.status, 200);
|
|
1507
1517
|
});
|
|
1518
|
+
test("BotImpl.fetch() includes FEP-5711 inverse properties", async () => {
|
|
1519
|
+
const repository = new MemoryRepository();
|
|
1520
|
+
const bot = new BotImpl({
|
|
1521
|
+
kv: new MemoryKvStore(),
|
|
1522
|
+
repository,
|
|
1523
|
+
username: "bot",
|
|
1524
|
+
collectionWindow: 1
|
|
1525
|
+
});
|
|
1526
|
+
const actorId = new URL("https://example.com/ap/actor/bot");
|
|
1527
|
+
await repository.addFollower(new URL("https://example.com/actor/1#follow"), new Person({
|
|
1528
|
+
id: new URL("https://example.com/actor/1"),
|
|
1529
|
+
preferredUsername: "john",
|
|
1530
|
+
inbox: new URL("https://example.com/actor/1/inbox")
|
|
1531
|
+
}));
|
|
1532
|
+
await repository.addMessage("78acb1ea-4ac6-46b7-bcd4-3a8965d8126e", new Create({
|
|
1533
|
+
id: new URL("https://example.com/ap/actor/bot/create/78acb1ea-4ac6-46b7-bcd4-3a8965d8126e"),
|
|
1534
|
+
actor: actorId,
|
|
1535
|
+
to: PUBLIC_COLLECTION,
|
|
1536
|
+
cc: new URL("https://example.com/ap/actor/bot/followers"),
|
|
1537
|
+
object: new Note({
|
|
1538
|
+
id: new URL("https://example.com/ap/actor/bot/note/1"),
|
|
1539
|
+
attribution: actorId,
|
|
1540
|
+
to: PUBLIC_COLLECTION,
|
|
1541
|
+
cc: new URL("https://example.com/ap/actor/bot/followers"),
|
|
1542
|
+
content: "Hello, world!",
|
|
1543
|
+
published: Temporal.Instant.from("2025-01-01T00:00:00Z")
|
|
1544
|
+
}),
|
|
1545
|
+
published: Temporal.Instant.from("2025-01-01T00:00:00Z")
|
|
1546
|
+
}));
|
|
1547
|
+
const actorResponse = await bot.fetch(new Request("https://example.com/ap/actor/bot", { headers: { accept: "application/activity+json" } }));
|
|
1548
|
+
assert.deepStrictEqual(actorResponse.status, 200);
|
|
1549
|
+
const actorJson = await actorResponse.json();
|
|
1550
|
+
assert.deepStrictEqual(actorJson.id, actorId.href);
|
|
1551
|
+
assert.deepStrictEqual(actorJson.followers, "https://example.com/ap/actor/bot/followers");
|
|
1552
|
+
assert.deepStrictEqual(actorJson.outbox, "https://example.com/ap/actor/bot/outbox");
|
|
1553
|
+
const outboxResponse = await bot.fetch(new Request("https://example.com/ap/actor/bot/outbox", { headers: { accept: "application/activity+json" } }));
|
|
1554
|
+
assert.deepStrictEqual(outboxResponse.status, 200);
|
|
1555
|
+
const outboxJson = await outboxResponse.json();
|
|
1556
|
+
assert.deepStrictEqual(outboxJson.type, "OrderedCollection");
|
|
1557
|
+
assert.deepStrictEqual(outboxJson.id, "https://example.com/ap/actor/bot/outbox");
|
|
1558
|
+
assert.deepStrictEqual(outboxJson.totalItems, 1);
|
|
1559
|
+
assert.deepStrictEqual(outboxJson.first, "https://example.com/ap/actor/bot/outbox?cursor=");
|
|
1560
|
+
assert.deepStrictEqual(outboxJson.outboxOf, actorId.href);
|
|
1561
|
+
const outboxPageResponse = await bot.fetch(new Request("https://example.com/ap/actor/bot/outbox?cursor=", { headers: { accept: "application/activity+json" } }));
|
|
1562
|
+
assert.deepStrictEqual(outboxPageResponse.status, 200);
|
|
1563
|
+
const outboxPageJson = await outboxPageResponse.json();
|
|
1564
|
+
assert.deepStrictEqual(outboxPageJson.type, "OrderedCollectionPage");
|
|
1565
|
+
assert.deepStrictEqual(outboxPageJson.id, "https://example.com/ap/actor/bot/outbox?cursor=");
|
|
1566
|
+
assert.deepStrictEqual(outboxPageJson.partOf, "https://example.com/ap/actor/bot/outbox");
|
|
1567
|
+
assert.deepStrictEqual(outboxPageJson.outboxOf, actorId.href);
|
|
1568
|
+
const followersResponse = await bot.fetch(new Request("https://example.com/ap/actor/bot/followers", { headers: { accept: "application/activity+json" } }));
|
|
1569
|
+
assert.deepStrictEqual(followersResponse.status, 200);
|
|
1570
|
+
const followersJson = await followersResponse.json();
|
|
1571
|
+
assert.deepStrictEqual(followersJson.type, "OrderedCollection");
|
|
1572
|
+
assert.deepStrictEqual(followersJson.id, "https://example.com/ap/actor/bot/followers");
|
|
1573
|
+
assert.deepStrictEqual(followersJson.totalItems, 1);
|
|
1574
|
+
assert.deepStrictEqual(followersJson.first, "https://example.com/ap/actor/bot/followers?cursor=0");
|
|
1575
|
+
assert.deepStrictEqual(followersJson.followersOf, actorId.href);
|
|
1576
|
+
const followersPageResponse = await bot.fetch(new Request("https://example.com/ap/actor/bot/followers?cursor=0", { headers: { accept: "application/activity+json" } }));
|
|
1577
|
+
assert.deepStrictEqual(followersPageResponse.status, 200);
|
|
1578
|
+
const followersPageJson = await followersPageResponse.json();
|
|
1579
|
+
assert.deepStrictEqual(followersPageJson.type, "OrderedCollectionPage");
|
|
1580
|
+
assert.deepStrictEqual(followersPageJson.id, "https://example.com/ap/actor/bot/followers?cursor=0");
|
|
1581
|
+
assert.deepStrictEqual(followersPageJson.partOf, "https://example.com/ap/actor/bot/followers");
|
|
1582
|
+
assert.deepStrictEqual(followersPageJson.followersOf, actorId.href);
|
|
1583
|
+
});
|
|
1508
1584
|
describe("BotImpl.addCustomEmoji(), BotImpl.addCustomEmojis()", () => {
|
|
1509
1585
|
const bot = new BotImpl({
|
|
1510
1586
|
kv: new MemoryKvStore(),
|
|
@@ -1619,7 +1695,11 @@ test("BotImpl.getFollowersFirstCursor()", () => {
|
|
|
1619
1695
|
});
|
|
1620
1696
|
function createMockInboxContext(bot, origin, recipient) {
|
|
1621
1697
|
const ctx = bot.federation.createContext(new URL(origin), void 0);
|
|
1622
|
-
ctx
|
|
1698
|
+
Object.defineProperty(ctx, "recipient", {
|
|
1699
|
+
value: recipient ?? null,
|
|
1700
|
+
writable: true,
|
|
1701
|
+
configurable: true
|
|
1702
|
+
});
|
|
1623
1703
|
ctx.sentActivities = [];
|
|
1624
1704
|
ctx.sendActivity = (_, recipients, activity) => {
|
|
1625
1705
|
ctx.sentActivities.push({
|