@fedify/fedify 2.1.30 → 2.1.32

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 (104) hide show
  1. package/dist/attachment-arrays-DZ4JHJD8.mjs +111 -0
  2. package/dist/{builder-CTpfuuVp.mjs → builder--sc-rozj.mjs} +3 -3
  3. package/dist/callback-BARPujV7.d.mts +2388 -0
  4. package/dist/{client-CAM_bQXx.d.cts → client-9DPcy_Yx.d.ts} +16 -1
  5. package/dist/{client-CSddvgWN.d.ts → client-B3ruDgWg.d.cts} +16 -1
  6. package/dist/{client-CjDMsn4a.mjs → client-cpPaW7Ww.mjs} +189 -65
  7. package/dist/compat/attachment-arrays.test.d.mts +2 -0
  8. package/dist/compat/attachment-arrays.test.mjs +254 -0
  9. package/dist/compat/mod.d.cts +1 -1
  10. package/dist/compat/mod.d.ts +1 -1
  11. package/dist/compat/transformers.test.mjs +1 -1
  12. package/dist/{context-DLLaDau8.d.ts → context-DE2YrQwM.d.ts} +56 -13
  13. package/dist/{context-BNwv9Q1v.d.cts → context-y6ZUQCMf.d.cts} +56 -13
  14. package/dist/{deno-BATJ1hq6.mjs → deno-L23b3Hba.mjs} +1 -1
  15. package/dist/docloader-DUXr9k_O.mjs +124 -0
  16. package/dist/federation/attachment-responses.test.d.mts +2 -0
  17. package/dist/federation/attachment-responses.test.mjs +182 -0
  18. package/dist/federation/builder.test.mjs +1 -1
  19. package/dist/federation/collection.test.mjs +1 -1
  20. package/dist/federation/delivery-attachments.test.d.mts +2 -0
  21. package/dist/federation/delivery-attachments.test.mjs +280 -0
  22. package/dist/federation/handler.test.mjs +208 -16
  23. package/dist/federation/idempotency.test.mjs +2 -2
  24. package/dist/federation/inbox.test.mjs +1 -1
  25. package/dist/federation/middleware.test.mjs +1559 -26
  26. package/dist/federation/mod.cjs +1 -1
  27. package/dist/federation/mod.d.cts +2 -2
  28. package/dist/federation/mod.d.ts +2 -2
  29. package/dist/federation/mod.js +1 -1
  30. package/dist/federation/negotiation.test.mjs +1 -1
  31. package/dist/federation/retry.test.mjs +1 -1
  32. package/dist/federation/send.test.mjs +723 -68
  33. package/dist/federation/temporal.test.mjs +25 -1
  34. package/dist/federation/webfinger.test.mjs +1 -1
  35. package/dist/{http-CK3efjgM.js → http-BtbMAgTA.js} +176 -105
  36. package/dist/{http-Dl00HXr4.d.ts → http-C8qLHs_Z.d.cts} +3 -4
  37. package/dist/{http-BoR1M3W7.cjs → http-D5woFKA_.cjs} +177 -106
  38. package/dist/{http-DqZhyEso.d.cts → http-D8WmcRAF.d.ts} +3 -4
  39. package/dist/{http-Bjd6I92u.mjs → http-HX6wVyJh.mjs} +198 -98
  40. package/dist/{inbox-9MlBGgs9.mjs → inbox-CL7A0HXT.mjs} +1 -1
  41. package/dist/{key-ClQh9Qqh.mjs → key-Dai3f5yI.mjs} +3 -2
  42. package/dist/{kv-cache-BxSx_Iyp.cjs → kv-cache-B0V_e231.cjs} +59 -17
  43. package/dist/{kv-cache-ImApO425.js → kv-cache-BsDg-cT8.js} +60 -18
  44. package/dist/{ld-Crg0Xmwr.mjs → ld-DN6x1iZ8.mjs} +153 -21
  45. package/dist/ld-signature-DoZcbsZR.mjs +23 -0
  46. package/dist/{middleware-jL9p9V9G.cjs → middleware-Cl6k5Hrm.cjs} +1 -1
  47. package/dist/{middleware-CmD3lpy4.cjs → middleware-CrfRuKCf.cjs} +728 -143
  48. package/dist/{middleware-CE0b69gj.mjs → middleware-DiquMgtt.mjs} +444 -115
  49. package/dist/{middleware-C2AJFk8W.js → middleware-DunNtbo9.js} +727 -143
  50. package/dist/{middleware-Bi5D6DBT.mjs → middleware-SnQS8eIb.mjs} +1 -1
  51. package/dist/{mod-DiuFTYUt.d.cts → mod-CehHJOV4.d.cts} +30 -13
  52. package/dist/{mod-CWJNbyju.d.ts → mod-DLJpnqdw.d.ts} +1 -1
  53. package/dist/{mod-BLDHhuW0.d.ts → mod-Mh3oIuRK.d.ts} +30 -13
  54. package/dist/{mod-DNEgTI8M.d.ts → mod-REfljt0T.d.ts} +4 -9
  55. package/dist/{mod-Cn9GJ5ex.d.cts → mod-UvIGUHqW.d.cts} +4 -9
  56. package/dist/{mod-BmlfRBmU.d.cts → mod-sTa1Zzxk.d.cts} +1 -1
  57. package/dist/mod.cjs +5 -5
  58. package/dist/mod.d.cts +8 -8
  59. package/dist/mod.d.ts +8 -8
  60. package/dist/mod.js +5 -5
  61. package/dist/nodeinfo/client.test.mjs +764 -19
  62. package/dist/nodeinfo/handler.test.mjs +1 -1
  63. package/dist/nodeinfo/mod.cjs +1 -1
  64. package/dist/nodeinfo/mod.d.cts +1 -1
  65. package/dist/nodeinfo/mod.d.ts +1 -1
  66. package/dist/nodeinfo/mod.js +1 -1
  67. package/dist/nodeinfo/types.test.mjs +1 -1
  68. package/dist/otel/exporter.test.mjs +292 -30
  69. package/dist/otel/mod.cjs +36 -30
  70. package/dist/otel/mod.d.cts +13 -0
  71. package/dist/otel/mod.d.ts +13 -0
  72. package/dist/otel/mod.js +36 -30
  73. package/dist/{owner-BRoKojK1.mjs → owner-DwyDorZI.mjs} +2 -2
  74. package/dist/{proof-CHXVlsH_.cjs → proof-Be-4K4jn.cjs} +193 -46
  75. package/dist/{proof-DMIAezxz.mjs → proof-DYjmyrHh.mjs} +38 -13
  76. package/dist/{proof-7R4s10TJ.js → proof-Du4-5SHY.js} +187 -46
  77. package/dist/send-BGSfQkIK.mjs +416 -0
  78. package/dist/sig/http.test.mjs +506 -2
  79. package/dist/sig/key-types.test.d.mts +218 -0
  80. package/dist/sig/key-types.test.mjs +8 -0
  81. package/dist/sig/key.test.mjs +2 -2
  82. package/dist/sig/ld.test.mjs +573 -8
  83. package/dist/sig/mod.cjs +2 -2
  84. package/dist/sig/mod.d.cts +3 -3
  85. package/dist/sig/mod.d.ts +3 -3
  86. package/dist/sig/mod.js +2 -2
  87. package/dist/sig/owner.test.mjs +1 -1
  88. package/dist/sig/proof.test.mjs +95 -3
  89. package/dist/{temporal-DR0JahMu.mjs → temporal-CNCchWly.mjs} +3 -5
  90. package/dist/testing/mod.d.mts +1 -2177
  91. package/dist/{types-DRPjmHVV.cjs → types-B5wRhemi.cjs} +187 -63
  92. package/dist/{types-miAYfiGO.js → types-CXy2lRVU.js} +188 -64
  93. package/dist/utils/docloader.test.mjs +316 -32
  94. package/dist/utils/mod.cjs +1 -1
  95. package/dist/utils/mod.d.cts +1 -1
  96. package/dist/utils/mod.d.ts +1 -1
  97. package/dist/utils/mod.js +1 -1
  98. package/package.json +7 -7
  99. package/dist/docloader-OLWc7P2D.mjs +0 -82
  100. package/dist/send-BHIt_8ia.mjs +0 -260
  101. /package/dist/{collection-BD6-SZ6O.mjs → collection-DnoYNwBC.mjs} +0 -0
  102. /package/dist/{negotiation-BehA2uul.mjs → negotiation-xb0QR3u_.mjs} +0 -0
  103. /package/dist/{retry-B_E3V_Dx.mjs → retry-CI1flGDD.mjs} +0 -0
  104. /package/dist/{types-DCP0WLdt.mjs → types-s4mCTGkT.mjs} +0 -0
@@ -4,20 +4,23 @@ globalThis.addEventListener = () => {};
4
4
  import { n as createRequestContext, t as createInboxContext } from "../context-Juj6bdHC.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-DflMZha5.mjs";
7
+ import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
7
8
  import { t as assert } from "../assert-BhQd8QHP.mjs";
8
9
  import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
9
10
  import { r as parseAcceptSignature } from "../accept-BavzedPB.mjs";
10
- import { a as generateCryptoKeyPair } from "../key-ClQh9Qqh.mjs";
11
- import { s as signRequest } from "../http-Bjd6I92u.mjs";
11
+ import { a as generateCryptoKeyPair } from "../key-Dai3f5yI.mjs";
12
+ import { c as signRequest } from "../http-HX6wVyJh.mjs";
12
13
  import { a as rsaPrivateKey3, c as rsaPublicKey3, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
13
14
  import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
14
- import { a as compactJsonLd, f as signJsonLd } from "../ld-Crg0Xmwr.mjs";
15
- import { n as signObject } from "../proof-DMIAezxz.mjs";
16
- import { a as createFederation, c as handleCollection, d as handleObject, f as respondWithObject, l as handleCustomCollection, p as respondWithObjectIfAcceptable, s as handleActor, u as handleInbox } from "../middleware-CE0b69gj.mjs";
17
- import { t as InboxListenerSet } from "../inbox-9MlBGgs9.mjs";
15
+ import { a as compactJsonLd, m as signJsonLd } from "../ld-DN6x1iZ8.mjs";
16
+ import { t as ldSignatureWithoutCreated } from "../ld-signature-DoZcbsZR.mjs";
17
+ import { n as signObject } from "../proof-DYjmyrHh.mjs";
18
+ import { a as createFederation, c as handleCollection, d as handleObject, f as respondWithObject, l as handleCustomCollection, p as respondWithObjectIfAcceptable, s as handleActor, u as handleInbox } from "../middleware-DiquMgtt.mjs";
19
+ import { t as InboxListenerSet } from "../inbox-CL7A0HXT.mjs";
18
20
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
19
21
  import { Create, CryptographicKey, Multikey, Note, Person } from "@fedify/vocab";
20
22
  import { FetchError } from "@fedify/vocab-runtime";
23
+ import { configure, reset } from "@logtape/logtape";
21
24
  //#region src/federation/handler.test.ts
22
25
  test("handleActor()", async () => {
23
26
  let context = createRequestContext({
@@ -537,8 +540,8 @@ test("handleCollection()", async () => {
537
540
  assertEquals(response.status, 200);
538
541
  assertEquals(response.headers.get("Content-Type"), "application/activity+json");
539
542
  const createCtx = [
540
- "https://w3id.org/identity/v1",
541
543
  "https://www.w3.org/ns/activitystreams",
544
+ "https://w3id.org/security/v1",
542
545
  "https://w3id.org/security/data-integrity/v1",
543
546
  "https://gotosocial.org/ns",
544
547
  {
@@ -583,7 +586,13 @@ test("handleCollection()", async () => {
583
586
  "@id": "fedibird:emojiReactions",
584
587
  "@type": "@id"
585
588
  }
586
- }
589
+ },
590
+ { orderedItems: {
591
+ "@id": "https://www.w3.org/ns/activitystreams#items",
592
+ "@type": "@id",
593
+ "@container": "@list",
594
+ "@context": null
595
+ } }
587
596
  ],
588
597
  id: "https://example.com/users/someone",
589
598
  type: "OrderedCollection",
@@ -667,7 +676,13 @@ test("handleCollection()", async () => {
667
676
  "@id": "fedibird:emojiReactions",
668
677
  "@type": "@id"
669
678
  }
670
- }
679
+ },
680
+ { orderedItems: {
681
+ "@id": "https://www.w3.org/ns/activitystreams#items",
682
+ "@type": "@id",
683
+ "@container": "@list",
684
+ "@context": null
685
+ } }
671
686
  ],
672
687
  id: "https://example.com/users/someone",
673
688
  type: "OrderedCollection",
@@ -785,7 +800,13 @@ test("handleCollection()", async () => {
785
800
  "@id": "fedibird:emojiReactions",
786
801
  "@type": "@id"
787
802
  }
788
- }
803
+ },
804
+ { orderedItems: {
805
+ "@id": "https://www.w3.org/ns/activitystreams#items",
806
+ "@type": "@id",
807
+ "@container": "@list",
808
+ "@context": null
809
+ } }
789
810
  ],
790
811
  id: "https://example.com/users/someone?cursor=0",
791
812
  type: "OrderedCollectionPage",
@@ -844,7 +865,13 @@ test("handleCollection()", async () => {
844
865
  "@id": "fedibird:emojiReactions",
845
866
  "@type": "@id"
846
867
  }
847
- }
868
+ },
869
+ { orderedItems: {
870
+ "@id": "https://www.w3.org/ns/activitystreams#items",
871
+ "@type": "@id",
872
+ "@container": "@list",
873
+ "@context": null
874
+ } }
848
875
  ],
849
876
  id: "https://example.com/users/someone?cursor=2",
850
877
  type: "OrderedCollectionPage",
@@ -2121,6 +2148,166 @@ test("handleInbox()", async () => {
2121
2148
  assertEquals(onNotFoundCalled, null);
2122
2149
  assertEquals(response.status, 400);
2123
2150
  });
2151
+ test("handleInbox() verifies Linked Data signatures without created", async (t) => {
2152
+ const inserted = structuredClone(ldSignatureWithoutCreated);
2153
+ const withTimestamp = {
2154
+ ...inserted,
2155
+ signature: {
2156
+ ...inserted.signature,
2157
+ created: "2024-09-12T16:50:46Z"
2158
+ }
2159
+ };
2160
+ const tampered = structuredClone(ldSignatureWithoutCreated);
2161
+ tampered.object.content = "tampered";
2162
+ const invalid = structuredClone(ldSignatureWithoutCreated);
2163
+ invalid.signature.signatureValue = "AAAA";
2164
+ const { signature: _, ...unsigned } = ldSignatureWithoutCreated;
2165
+ for (const [name, body, expected] of [
2166
+ [
2167
+ "valid LD-only",
2168
+ ldSignatureWithoutCreated,
2169
+ 202
2170
+ ],
2171
+ [
2172
+ "inserted created",
2173
+ withTimestamp,
2174
+ 401
2175
+ ],
2176
+ [
2177
+ "tampered content",
2178
+ tampered,
2179
+ 401
2180
+ ],
2181
+ [
2182
+ "invalid signature",
2183
+ invalid,
2184
+ 401
2185
+ ],
2186
+ [
2187
+ "unsigned",
2188
+ unsigned,
2189
+ 401
2190
+ ],
2191
+ [
2192
+ "malformed created",
2193
+ {
2194
+ ...ldSignatureWithoutCreated,
2195
+ signature: {
2196
+ ...ldSignatureWithoutCreated.signature,
2197
+ created: 123
2198
+ }
2199
+ },
2200
+ 401
2201
+ ],
2202
+ [
2203
+ "malformed creator",
2204
+ {
2205
+ ...ldSignatureWithoutCreated,
2206
+ signature: {
2207
+ ...ldSignatureWithoutCreated.signature,
2208
+ creator: {}
2209
+ }
2210
+ },
2211
+ 401
2212
+ ],
2213
+ [
2214
+ "malformed null",
2215
+ {
2216
+ ...ldSignatureWithoutCreated,
2217
+ signature: null
2218
+ },
2219
+ 401
2220
+ ],
2221
+ [
2222
+ "malformed array",
2223
+ {
2224
+ ...ldSignatureWithoutCreated,
2225
+ signature: []
2226
+ },
2227
+ 401
2228
+ ],
2229
+ [
2230
+ "malformed primitive",
2231
+ {
2232
+ ...ldSignatureWithoutCreated,
2233
+ signature: "secret"
2234
+ },
2235
+ 401
2236
+ ]
2237
+ ]) await t.step(name, async () => {
2238
+ const kv = new MemoryKvStore();
2239
+ const federation = createFederation({ kv });
2240
+ const request = new Request("https://example.com/inbox", {
2241
+ method: "POST",
2242
+ body: JSON.stringify(body)
2243
+ });
2244
+ const context = createRequestContext({
2245
+ federation,
2246
+ request,
2247
+ url: new URL(request.url),
2248
+ data: void 0,
2249
+ documentLoader: mockDocumentLoader,
2250
+ contextLoader: mockDocumentLoader
2251
+ });
2252
+ let deliveries = 0;
2253
+ const inboxListeners = new InboxListenerSet();
2254
+ inboxListeners.add(Create, () => {
2255
+ deliveries++;
2256
+ });
2257
+ const records = [];
2258
+ await configure({
2259
+ sinks: { buffer: (record) => records.push(record) },
2260
+ loggers: [{
2261
+ category: ["fedify"],
2262
+ sinks: ["buffer"],
2263
+ lowestLevel: "debug"
2264
+ }, {
2265
+ category: ["logtape", "meta"],
2266
+ sinks: []
2267
+ }],
2268
+ reset: true
2269
+ });
2270
+ try {
2271
+ assertEquals((await handleInbox(request, {
2272
+ recipient: null,
2273
+ context,
2274
+ inboxContextFactory() {
2275
+ return createInboxContext({
2276
+ ...context,
2277
+ clone: void 0
2278
+ });
2279
+ },
2280
+ kv,
2281
+ kvPrefixes: {
2282
+ activityIdempotence: ["_fedify", "activityIdempotence"],
2283
+ publicKey: ["_fedify", "publicKey"],
2284
+ acceptSignatureNonce: ["_fedify", "acceptSignatureNonce"]
2285
+ },
2286
+ actorDispatcher: () => null,
2287
+ inboxListeners,
2288
+ onNotFound: () => new Response("Not found", { status: 404 }),
2289
+ signatureTimeWindow: { minutes: 5 },
2290
+ skipSignatureVerification: false
2291
+ })).status, expected);
2292
+ assertEquals(deliveries, expected === 202 ? 1 : 0);
2293
+ const malformedRecords = records.filter((r) => r.rawMessage === "Linked Data Signature has an unsupported shape: {signatureKind}; properties: {signatureProperties}.");
2294
+ assertEquals(malformedRecords.length, name.startsWith("malformed") ? 1 : 0);
2295
+ for (const record of malformedRecords) {
2296
+ assertEquals(record.category, [
2297
+ "fedify",
2298
+ "federation",
2299
+ "inbox"
2300
+ ]);
2301
+ assertEquals(record.level, "debug");
2302
+ assertFalse(JSON.stringify(record).includes(ldSignatureWithoutCreated.signature.creator));
2303
+ assertFalse(JSON.stringify(record).includes(ldSignatureWithoutCreated.signature.signatureValue));
2304
+ assertFalse(JSON.stringify(record).includes("secret"));
2305
+ }
2306
+ } finally {
2307
+ await reset();
2308
+ }
2309
+ });
2310
+ });
2124
2311
  test("handleInbox() preserves the raw signed payload for inboxContextFactory", async () => {
2125
2312
  const federation = createFederation({ kv: new MemoryKvStore() });
2126
2313
  const remoteContextUrl = "https://remote.example/contexts/ext";
@@ -2844,8 +3031,8 @@ test("handleCustomCollection()", async () => {
2844
3031
  assertEquals(response.status, 200);
2845
3032
  assertEquals(response.headers.get("Content-Type"), "application/activity+json");
2846
3033
  const createCtx = [
2847
- "https://w3id.org/identity/v1",
2848
3034
  "https://www.w3.org/ns/activitystreams",
3035
+ "https://w3id.org/security/v1",
2849
3036
  "https://w3id.org/security/data-integrity/v1",
2850
3037
  "https://gotosocial.org/ns",
2851
3038
  {
@@ -2891,8 +3078,13 @@ test("handleCustomCollection()", async () => {
2891
3078
  }
2892
3079
  }
2893
3080
  ];
3081
+ const ITEM_CONTEXT = [...CONTEXT, { items: {
3082
+ "@id": "https://www.w3.org/ns/activitystreams#items",
3083
+ "@type": "@id",
3084
+ "@context": null
3085
+ } }];
2894
3086
  assertEquals(await response.json(), {
2895
- "@context": CONTEXT,
3087
+ "@context": ITEM_CONTEXT,
2896
3088
  id: "https://example.com/",
2897
3089
  type: "Collection",
2898
3090
  items: [
@@ -2947,7 +3139,7 @@ test("handleCustomCollection()", async () => {
2947
3139
  assertEquals(response.status, 200);
2948
3140
  assertEquals(response.headers.get("Content-Type"), "application/activity+json");
2949
3141
  assertEquals(await response.json(), {
2950
- "@context": CONTEXT,
3142
+ "@context": ITEM_CONTEXT,
2951
3143
  id: "https://example.com/",
2952
3144
  type: "Collection",
2953
3145
  items: [
@@ -3005,7 +3197,7 @@ test("handleCustomCollection()", async () => {
3005
3197
  assertEquals(response.status, 200);
3006
3198
  assertEquals(response.headers.get("Content-Type"), "application/activity+json");
3007
3199
  assertEquals(await response.json(), {
3008
- "@context": CONTEXT,
3200
+ "@context": ITEM_CONTEXT,
3009
3201
  id: "https://example.com/?cursor=0",
3010
3202
  type: "CollectionPage",
3011
3203
  partOf: "https://example.com/",
@@ -3034,7 +3226,7 @@ test("handleCustomCollection()", async () => {
3034
3226
  assertEquals(response.status, 200);
3035
3227
  assertEquals(response.headers.get("Content-Type"), "application/activity+json");
3036
3228
  assertEquals(await response.json(), {
3037
- "@context": CONTEXT,
3229
+ "@context": ITEM_CONTEXT,
3038
3230
  id: "https://example.com/?cursor=2",
3039
3231
  type: "CollectionPage",
3040
3232
  partOf: "https://example.com/",
@@ -5,8 +5,8 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import "../std__assert-DflMZha5.mjs";
6
6
  import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
8
- import { n as signObject } from "../proof-DMIAezxz.mjs";
9
- import { a as createFederation } from "../middleware-CE0b69gj.mjs";
8
+ import { n as signObject } from "../proof-DYjmyrHh.mjs";
9
+ import { a as createFederation } from "../middleware-DiquMgtt.mjs";
10
10
  import { mockDocumentLoader, test } from "@fedify/fixture";
11
11
  import { Create, Follow, Person } from "@fedify/vocab";
12
12
  //#region src/federation/idempotency.test.ts
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
6
- import { n as actorsHaveSameOrigin, t as InboxListenerSet } from "../inbox-9MlBGgs9.mjs";
6
+ import { n as actorsHaveSameOrigin, t as InboxListenerSet } from "../inbox-CL7A0HXT.mjs";
7
7
  import { test } from "@fedify/fixture";
8
8
  import { Activity, Create, Invite, Offer, Update } from "@fedify/vocab";
9
9
  //#region src/federation/inbox.test.ts