@fedify/fedify 1.9.0-pr.407.1544 → 1.9.0-pr.421.1747

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 (176) hide show
  1. package/dist/{actor-Ch5yFYFG.d.ts → actor-C1Euqngb.d.ts} +1 -1
  2. package/dist/{actor-CeBu8hLy.js → actor-CNV1ck1S.js} +1 -1
  3. package/dist/actor-DaFSkBV-.cjs +42606 -0
  4. package/dist/{actor-BY--uubW.js → actor-J-9oLs-V.js} +6951 -2127
  5. package/dist/actor-Ydzhc8dj.d.cts +128 -0
  6. package/dist/{authdocloader-C89pKQKE.js → authdocloader-D4qQkXT9.js} +6 -6
  7. package/dist/{authdocloader-jHzDqZo2.js → authdocloader-DKEFUico.js} +3 -3
  8. package/dist/authdocloader-DM1vtjbY.cjs +58 -0
  9. package/dist/{builder-ClMKBUks.js → builder-2yBgTZpU.js} +14 -8
  10. package/dist/chunk-DqRYRqnO.cjs +34 -0
  11. package/dist/client-DjT_tegg.d.cts +294 -0
  12. package/dist/{client-DB3mC1oJ.js → client-nAHORZym.js} +1 -1
  13. package/dist/compat/mod.cjs +10 -0
  14. package/dist/compat/mod.d.cts +13 -0
  15. package/dist/compat/mod.d.ts +7 -7
  16. package/dist/compat/mod.js +5 -5
  17. package/dist/compat/transformers.test.js +16 -16
  18. package/dist/compat-DmDDELst.cjs +4 -0
  19. package/dist/compat-nxUqe4Z-.js +4 -0
  20. package/dist/{context-DFruNLny.d.ts → context-CXUibY4L.d.ts} +179 -116
  21. package/dist/context-CwUAkopp.d.cts +2324 -0
  22. package/dist/{docloader-BJTPo7_i.js → docloader-BRrqMbX0.js} +188 -8
  23. package/dist/docloader-D-MrRyHl.d.cts +219 -0
  24. package/dist/docloader-FAn755Ez.cjs +4862 -0
  25. package/dist/{esm-BjUpSZdQ.js → esm-CZDlG8Yt.js} +1 -1
  26. package/dist/federation/builder.test.js +5 -5
  27. package/dist/federation/collection.test.js +3 -3
  28. package/dist/federation/handler.test.js +17 -17
  29. package/dist/federation/idempotency.test.d.ts +3 -0
  30. package/dist/federation/idempotency.test.js +202 -0
  31. package/dist/federation/inbox.test.js +4 -4
  32. package/dist/federation/keycache.test.js +4 -4
  33. package/dist/federation/kv.test.js +4 -3
  34. package/dist/federation/middleware.test.js +18 -18
  35. package/dist/federation/mod.cjs +29 -0
  36. package/dist/federation/mod.d.cts +13 -0
  37. package/dist/federation/mod.d.ts +7 -7
  38. package/dist/federation/mod.js +15 -15
  39. package/dist/federation/mq.test.js +3 -3
  40. package/dist/federation/retry.test.js +3 -3
  41. package/dist/federation/router.test.js +3 -3
  42. package/dist/federation/send.test.js +10 -10
  43. package/dist/{federation-CMX7WzeL.js → federation-D1U8YY9t.js} +3 -3
  44. package/dist/federation-H2_En3j5.cjs +244 -0
  45. package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
  46. package/dist/{http-sU0Wj-tv.js → http-B0Rp4UOp.js} +7 -7
  47. package/dist/http-B1_DzfAU.d.cts +253 -0
  48. package/dist/{http-3pAI0mqb.js → http-CyMjXkYA.js} +3 -3
  49. package/dist/http-D7xo4v5M.cjs +826 -0
  50. package/dist/{http-D8Q4xH0d.d.ts → http-wsGR6KkT.d.ts} +1 -1
  51. package/dist/{inbox-Dg825gXU.js → inbox-CAt-VuhL.js} +29 -7
  52. package/dist/key-BZBF55sg.cjs +10 -0
  53. package/dist/key-CKScBmP1.js +10 -0
  54. package/dist/{key-l5QMtRss.js → key-D7A24D7c.js} +5 -5
  55. package/dist/key-DFZ_CvG0.cjs +290 -0
  56. package/dist/{key-RzI0hV7H.js → key-DbX-_KvI.js} +2 -2
  57. package/dist/{key-BWgRsIwz.js → key-uBD0-2wc.js} +3 -3
  58. package/dist/{keycache-BGlP5YTm.js → keycache-DVVM5m9f.js} +1 -1
  59. package/dist/{keys-BRbwmdDJ.js → keys-Hl2h0ZG0.js} +1 -1
  60. package/dist/kv-63Cil1MD.d.cts +81 -0
  61. package/dist/{ld-C9E9DPBz.js → ld-e-G3iYdn.js} +4 -4
  62. package/dist/{lookup-oZxe6kZr.js → lookup-DNGo5BR6.js} +21 -12
  63. package/dist/lookup-DSSOyhz2.cjs +137 -0
  64. package/dist/{lookup-CN62_yPh.js → lookup-Zzj9McvA.js} +4 -4
  65. package/dist/{middleware-extU7qDB.js → middleware-4mR2kSKQ.js} +96 -65
  66. package/dist/middleware-B-YooLeX.cjs +17 -0
  67. package/dist/middleware-BG51vY-0.js +17 -0
  68. package/dist/{middleware-jQ1GPh2U.js → middleware-BWW4nCk1.js} +57 -54
  69. package/dist/middleware-CVb0KXM7.cjs +4271 -0
  70. package/dist/middleware-DXunR6sJ.js +26 -0
  71. package/dist/mod-BUbqxBev.d.cts +307 -0
  72. package/dist/{mod-CiXjux2r.d.ts → mod-BcObK1Lz.d.ts} +2 -2
  73. package/dist/mod-C2tOeRkN.d.cts +1 -0
  74. package/dist/{mod-Cy6pkZSn.d.ts → mod-CDObsV1d.d.ts} +19 -1
  75. package/dist/{mod-BAuhKa9d.d.ts → mod-CIbqfZW0.d.ts} +1 -1
  76. package/dist/{mod-B7Pc0I7F.d.ts → mod-DgcYoyZK.d.ts} +2 -2
  77. package/dist/mod-Dt-G9ZOS.d.cts +102 -0
  78. package/dist/mod-FZd39qVq.d.cts +1 -0
  79. package/dist/mod-fjqfsrty.d.cts +266 -0
  80. package/dist/mod-jQ4OODsl.d.cts +113 -0
  81. package/dist/mod-mXx9V0q5.d.cts +80 -0
  82. package/dist/mod.cjs +152 -0
  83. package/dist/mod.d.cts +17 -0
  84. package/dist/mod.d.ts +10 -10
  85. package/dist/mod.js +20 -20
  86. package/dist/mq-B7R1Q-M5.d.cts +140 -0
  87. package/dist/nodeinfo/client.test.js +5 -5
  88. package/dist/nodeinfo/handler.test.js +16 -16
  89. package/dist/nodeinfo/mod.cjs +13 -0
  90. package/dist/nodeinfo/mod.d.cts +5 -0
  91. package/dist/nodeinfo/mod.js +6 -6
  92. package/dist/nodeinfo/semver.test.js +3 -3
  93. package/dist/nodeinfo/types.test.js +3 -3
  94. package/dist/nodeinfo-Co9lJrWl.cjs +4 -0
  95. package/dist/nodeinfo-DfycQ8Wf.js +4 -0
  96. package/dist/owner-6KSEp9eV.d.cts +67 -0
  97. package/dist/{owner-D38zBIMc.d.ts → owner-BbeUDvOu.d.ts} +2 -2
  98. package/dist/{owner-B836JKuZ.js → owner-C4sPn9c4.js} +2 -2
  99. package/dist/{proof-D63mA1Rv.js → proof-C3QoDkRC.js} +3 -3
  100. package/dist/proof-DT8hWqV6.cjs +673 -0
  101. package/dist/{proof-DLwnfKak.js → proof-iy7cOAt6.js} +9 -9
  102. package/dist/runtime/authdocloader.test.js +9 -9
  103. package/dist/runtime/docloader.test.js +4 -4
  104. package/dist/runtime/key.test.js +5 -5
  105. package/dist/runtime/langstr.test.js +3 -3
  106. package/dist/runtime/link.test.d.ts +3 -0
  107. package/dist/runtime/link.test.js +61 -0
  108. package/dist/runtime/mod.cjs +25 -0
  109. package/dist/runtime/mod.d.cts +6 -0
  110. package/dist/runtime/mod.d.ts +3 -3
  111. package/dist/runtime/mod.js +10 -10
  112. package/dist/runtime/multibase/multibase.test.js +3 -3
  113. package/dist/runtime/url.test.js +3 -3
  114. package/dist/runtime-C58AJWSv.cjs +4 -0
  115. package/dist/runtime-DPYEDf-o.js +4 -0
  116. package/dist/{send-CE9GFSCd.js → send-BOn6IbzV.js} +2 -2
  117. package/dist/sig/http.test.js +9 -9
  118. package/dist/sig/key.test.js +6 -6
  119. package/dist/sig/ld.test.js +7 -7
  120. package/dist/sig/mod.cjs +30 -0
  121. package/dist/sig/mod.d.cts +8 -0
  122. package/dist/sig/mod.d.ts +5 -5
  123. package/dist/sig/mod.js +10 -10
  124. package/dist/sig/owner.test.js +7 -7
  125. package/dist/sig/proof.test.js +7 -7
  126. package/dist/sig-ByHXzqUi.cjs +4 -0
  127. package/dist/sig-Cj3tk-ig.js +4 -0
  128. package/dist/testing/docloader.test.js +3 -3
  129. package/dist/testing/mod.d.ts +385 -110
  130. package/dist/testing/mod.js +3 -3
  131. package/dist/{testing-B2tgn0a4.js → testing-DaKcIaFF.js} +2 -2
  132. package/dist/{transformers-Dna8Fg7k.js → transformers-BFT6d7J5.js} +3 -3
  133. package/dist/transformers-CoBS-oFG.cjs +116 -0
  134. package/dist/{type-OboVsUha.js → type-D50ufokc.js} +7261 -2257
  135. package/dist/{types-BLr6AjjI.js → types-BCmRSiaD.js} +4 -4
  136. package/dist/types-wG2EuWYS.cjs +488 -0
  137. package/dist/vocab/actor.test.js +5 -5
  138. package/dist/vocab/lookup.test.js +255 -5
  139. package/dist/vocab/mod.cjs +87 -0
  140. package/dist/vocab/mod.d.cts +6 -0
  141. package/dist/vocab/mod.d.ts +3 -3
  142. package/dist/vocab/mod.js +7 -7
  143. package/dist/vocab/type.test.js +3 -3
  144. package/dist/vocab/vocab.test.js +433 -9
  145. package/dist/vocab-B_AjsPE2.cjs +291 -0
  146. package/dist/{vocab-BEEm2I6u.d.ts → vocab-CDHNj5zp.d.ts} +290 -0
  147. package/dist/vocab-Cfs0937i.d.cts +14919 -0
  148. package/dist/{vocab-Z7alheNv.js → vocab-CtBL6Aur.js} +26 -17
  149. package/dist/webfinger/handler.test.js +16 -16
  150. package/dist/webfinger/lookup.test.js +4 -4
  151. package/dist/webfinger/mod.cjs +9 -0
  152. package/dist/webfinger/mod.d.cts +4 -0
  153. package/dist/webfinger/mod.js +6 -6
  154. package/dist/webfinger-BjOEdFPs.cjs +4 -0
  155. package/dist/webfinger-De_bU0iE.js +4 -0
  156. package/dist/x/cfworkers.cjs +100 -0
  157. package/dist/x/cfworkers.d.cts +59 -0
  158. package/dist/x/cfworkers.js +3 -3
  159. package/dist/x/cfworkers.test.js +3 -3
  160. package/dist/x/hono.cjs +61 -0
  161. package/dist/x/hono.d.cts +54 -0
  162. package/dist/x/hono.d.ts +6 -6
  163. package/dist/x/hono.js +3 -3
  164. package/dist/x/sveltekit.cjs +69 -0
  165. package/dist/x/sveltekit.d.cts +46 -0
  166. package/dist/x/sveltekit.d.ts +6 -6
  167. package/dist/x/sveltekit.js +3 -3
  168. package/package.json +68 -13
  169. package/dist/compat-Bb5myD13.js +0 -4
  170. package/dist/key-_XZAOE9D.js +0 -10
  171. package/dist/middleware-Ccahu3ql.js +0 -26
  172. package/dist/middleware-fO804EqJ.js +0 -17
  173. package/dist/nodeinfo-CyEbLjHs.js +0 -4
  174. package/dist/runtime-BSkOVUWM.js +0 -4
  175. package/dist/sig-BXJO--F9.js +0 -4
  176. package/dist/webfinger-C3GIyXIg.js +0 -4
@@ -0,0 +1,137 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ const require_chunk = require('./chunk-DqRYRqnO.cjs');
6
+ const require_docloader = require('./docloader-FAn755Ez.cjs');
7
+ const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
8
+ const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
9
+
10
+ //#region src/webfinger/lookup.ts
11
+ const logger = (0, __logtape_logtape.getLogger)([
12
+ "fedify",
13
+ "webfinger",
14
+ "lookup"
15
+ ]);
16
+ const DEFAULT_MAX_REDIRECTION = 5;
17
+ /**
18
+ * Looks up a WebFinger resource.
19
+ * @param resource The resource URL to look up.
20
+ * @param options Extra options for looking up the resource.
21
+ * @returns The resource descriptor, or `null` if not found.
22
+ * @since 0.2.0
23
+ */
24
+ async function lookupWebFinger(resource, options = {}) {
25
+ const tracerProvider = options.tracerProvider ?? __opentelemetry_api.trace.getTracerProvider();
26
+ const tracer = tracerProvider.getTracer(require_docloader.deno_default.name, require_docloader.deno_default.version);
27
+ return await tracer.startActiveSpan("webfinger.lookup", {
28
+ kind: __opentelemetry_api.SpanKind.CLIENT,
29
+ attributes: {
30
+ "webfinger.resource": resource.toString(),
31
+ "webfinger.resource.scheme": typeof resource === "string" ? resource.replace(/:.*$/, "") : resource.protocol.replace(/:$/, "")
32
+ }
33
+ }, async (span) => {
34
+ try {
35
+ const result = await lookupWebFingerInternal(resource, options);
36
+ span.setStatus({ code: result === null ? __opentelemetry_api.SpanStatusCode.ERROR : __opentelemetry_api.SpanStatusCode.OK });
37
+ return result;
38
+ } catch (error) {
39
+ span.setStatus({
40
+ code: __opentelemetry_api.SpanStatusCode.ERROR,
41
+ message: String(error)
42
+ });
43
+ throw error;
44
+ } finally {
45
+ span.end();
46
+ }
47
+ });
48
+ }
49
+ async function lookupWebFingerInternal(resource, options = {}) {
50
+ if (typeof resource === "string") resource = new URL(resource);
51
+ let protocol = "https:";
52
+ let server;
53
+ if (resource.protocol === "acct:") {
54
+ const atPos = resource.pathname.lastIndexOf("@");
55
+ if (atPos < 0) return null;
56
+ server = resource.pathname.substring(atPos + 1);
57
+ if (server === "") return null;
58
+ } else {
59
+ protocol = resource.protocol;
60
+ server = resource.host;
61
+ }
62
+ let url = new URL(`${protocol}//${server}/.well-known/webfinger`);
63
+ url.searchParams.set("resource", resource.href);
64
+ let redirected = 0;
65
+ while (true) {
66
+ logger.debug("Fetching WebFinger resource descriptor from {url}...", { url: url.href });
67
+ let response;
68
+ if (options.allowPrivateAddress !== true) try {
69
+ await require_docloader.validatePublicUrl(url.href);
70
+ } catch (e) {
71
+ if (e instanceof require_docloader.UrlError) {
72
+ logger.error("Invalid URL for WebFinger resource descriptor: {error}", { error: e });
73
+ return null;
74
+ }
75
+ throw e;
76
+ }
77
+ try {
78
+ response = await fetch(url, {
79
+ headers: {
80
+ Accept: "application/jrd+json",
81
+ "User-Agent": typeof options.userAgent === "string" ? options.userAgent : require_docloader.getUserAgent(options.userAgent)
82
+ },
83
+ redirect: "manual",
84
+ signal: options.signal
85
+ });
86
+ } catch (error) {
87
+ logger.debug("Failed to fetch WebFinger resource descriptor: {error}", {
88
+ url: url.href,
89
+ error
90
+ });
91
+ return null;
92
+ }
93
+ if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
94
+ redirected++;
95
+ const maxRedirection = options.maxRedirection ?? DEFAULT_MAX_REDIRECTION;
96
+ if (redirected >= maxRedirection) {
97
+ logger.error("Too many redirections ({redirections}) while fetching WebFinger resource descriptor.", { redirections: redirected });
98
+ return null;
99
+ }
100
+ const redirectedUrl = new URL(response.headers.get("Location"), response.url == null || response.url === "" ? url : response.url);
101
+ if (redirectedUrl.protocol !== url.protocol) {
102
+ logger.error("Redirected to a different protocol ({protocol} to {redirectedProtocol}) while fetching WebFinger resource descriptor.", {
103
+ protocol: url.protocol,
104
+ redirectedProtocol: redirectedUrl.protocol
105
+ });
106
+ return null;
107
+ }
108
+ url = redirectedUrl;
109
+ continue;
110
+ }
111
+ if (!response.ok) {
112
+ logger.debug("Failed to fetch WebFinger resource descriptor: {status} {statusText}.", {
113
+ url: url.href,
114
+ status: response.status,
115
+ statusText: response.statusText
116
+ });
117
+ return null;
118
+ }
119
+ try {
120
+ return await response.json();
121
+ } catch (e) {
122
+ if (e instanceof SyntaxError) {
123
+ logger.debug("Failed to parse WebFinger resource descriptor as JSON: {error}", { error: e });
124
+ return null;
125
+ }
126
+ throw e;
127
+ }
128
+ }
129
+ }
130
+
131
+ //#endregion
132
+ Object.defineProperty(exports, 'lookupWebFinger', {
133
+ enumerable: true,
134
+ get: function () {
135
+ return lookupWebFinger;
136
+ }
137
+ });
@@ -1,8 +1,8 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import { UrlError, deno_default, getUserAgent, validatePublicUrl } from "./docloader-BJTPo7_i.js";
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import { UrlError, deno_default, getUserAgent, validatePublicUrl } from "./docloader-BRrqMbX0.js";
6
6
  import { getLogger } from "@logtape/logtape";
7
7
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
8
8
 
@@ -1,17 +1,17 @@
1
1
 
2
- import { Temporal } from "@js-temporal/polyfill";
3
- import { URLPattern } from "urlpattern-polyfill";
4
-
5
- import { getDefaultActivityTransformers } from "./transformers-Dna8Fg7k.js";
6
- import { deno_default, getDocumentLoader, kvCache } from "./docloader-BJTPo7_i.js";
7
- import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-BY--uubW.js";
8
- import { lookupWebFinger } from "./lookup-CN62_yPh.js";
9
- import { exportJwk, importJwk, validateCryptoKey } from "./key-l5QMtRss.js";
10
- import { doubleKnock, verifyRequest } from "./http-sU0Wj-tv.js";
11
- import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-DLwnfKak.js";
12
- import { getNodeInfo, nodeInfoToJson } from "./types-BLr6AjjI.js";
13
- import { getAuthenticatedDocumentLoader } from "./authdocloader-C89pKQKE.js";
14
- import { lookupObject, traverseCollection } from "./vocab-Z7alheNv.js";
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import { getDefaultActivityTransformers } from "./transformers-BFT6d7J5.js";
6
+ import { deno_default, getDocumentLoader, kvCache } from "./docloader-BRrqMbX0.js";
7
+ import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-J-9oLs-V.js";
8
+ import { lookupWebFinger } from "./lookup-Zzj9McvA.js";
9
+ import { exportJwk, importJwk, validateCryptoKey } from "./key-D7A24D7c.js";
10
+ import { doubleKnock, verifyRequest } from "./http-B0Rp4UOp.js";
11
+ import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-iy7cOAt6.js";
12
+ import { getNodeInfo, nodeInfoToJson } from "./types-BCmRSiaD.js";
13
+ import { getAuthenticatedDocumentLoader } from "./authdocloader-D4qQkXT9.js";
14
+ import { lookupObject, traverseCollection } from "./vocab-CtBL6Aur.js";
15
15
  import { getLogger, withContext } from "@logtape/logtape";
16
16
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
17
17
  import { encodeHex } from "byte-encodings/hex";
@@ -55,17 +55,39 @@ var InboxListenerSet = class InboxListenerSet {
55
55
  return this.dispatchWithClass(activity)?.listener ?? null;
56
56
  }
57
57
  };
58
- async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider }) {
58
+ let warnedAboutDefaultIdempotency = false;
59
+ async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
59
60
  const logger$1 = getLogger([
60
61
  "fedify",
61
62
  "federation",
62
63
  "inbox"
63
64
  ]);
64
- const cacheKey = activity.id == null ? null : [
65
- ...kvPrefixes.activityIdempotence,
66
- ctx.origin,
67
- activity.id.href
68
- ];
65
+ let cacheKey = null;
66
+ if (activity.id != null) {
67
+ const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, getTypeId(activity).href);
68
+ const strategy = idempotencyStrategy ?? "per-origin";
69
+ if (idempotencyStrategy === void 0 && !warnedAboutDefaultIdempotency) {
70
+ logger$1.warn("Using default idempotency strategy 'per-origin'. This default will change to 'per-inbox' in Fedify 2.0. Please explicitly set the idempotency strategy using .withIdempotency().");
71
+ warnedAboutDefaultIdempotency = true;
72
+ }
73
+ let keyString;
74
+ if (typeof strategy === "function") {
75
+ const result = await strategy(inboxContext, activity);
76
+ keyString = result;
77
+ } else switch (strategy) {
78
+ case "global":
79
+ keyString = activity.id.href;
80
+ break;
81
+ case "per-origin":
82
+ keyString = `${ctx.origin}\n${activity.id.href}`;
83
+ break;
84
+ case "per-inbox":
85
+ keyString = `${ctx.origin}\n${activity.id.href}\n${recipient == null ? "sharedInbox" : `inbox\n${recipient}`}`;
86
+ break;
87
+ default: keyString = `${ctx.origin}\n${activity.id.href}`;
88
+ }
89
+ if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
90
+ }
69
91
  if (cacheKey != null) {
70
92
  const cached = await kv.get(cacheKey);
71
93
  if (cached === true) {
@@ -307,6 +329,7 @@ var FederationBuilderImpl = class {
307
329
  inboxListeners;
308
330
  inboxErrorHandler;
309
331
  sharedInboxKeyDispatcher;
332
+ idempotencyStrategy;
310
333
  collectionTypeIds;
311
334
  collectionCallbacks;
312
335
  /**
@@ -321,7 +344,7 @@ var FederationBuilderImpl = class {
321
344
  this.collectionTypeIds = {};
322
345
  }
323
346
  async build(options) {
324
- const { FederationImpl: FederationImpl$1 } = await import("./middleware-fO804EqJ.js");
347
+ const { FederationImpl: FederationImpl$1 } = await import("./middleware-BG51vY-0.js");
325
348
  const f = new FederationImpl$1(options);
326
349
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
327
350
  f.router = this.router.clone();
@@ -343,6 +366,7 @@ var FederationBuilderImpl = class {
343
366
  f.inboxListeners = this.inboxListeners?.clone();
344
367
  f.inboxErrorHandler = this.inboxErrorHandler;
345
368
  f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
369
+ f.idempotencyStrategy = this.idempotencyStrategy;
346
370
  return f;
347
371
  }
348
372
  _getTracer() {
@@ -765,15 +789,19 @@ var FederationBuilderImpl = class {
765
789
  setSharedKeyDispatcher: (dispatcher) => {
766
790
  this.sharedInboxKeyDispatcher = dispatcher;
767
791
  return setters;
792
+ },
793
+ withIdempotency: (strategy) => {
794
+ this.idempotencyStrategy = strategy;
795
+ return setters;
768
796
  }
769
797
  };
770
798
  return setters;
771
799
  }
772
- setCollectionDispatcher(name, ...args) {
773
- return this.#setCustomCollectionDispatcher(name, "collection", ...args);
800
+ setCollectionDispatcher(name, itemType, path, dispatcher) {
801
+ return this.#setCustomCollectionDispatcher(name, "collection", itemType, path, dispatcher);
774
802
  }
775
- setOrderedCollectionDispatcher(name, ...args) {
776
- return this.#setCustomCollectionDispatcher(name, "orderedCollection", ...args);
803
+ setOrderedCollectionDispatcher(name, itemType, path, dispatcher) {
804
+ return this.#setCustomCollectionDispatcher(name, "orderedCollection", itemType, path, dispatcher);
777
805
  }
778
806
  #setCustomCollectionDispatcher(name, collectionType, itemType, path, dispatcher) {
779
807
  const strName = String(name);
@@ -1296,7 +1324,8 @@ async function handleInbox(request, options) {
1296
1324
  * @param span The OpenTelemetry span for tracing.
1297
1325
  * @returns A promise that resolves to an HTTP response.
1298
1326
  */
1299
- async function handleInboxInternal(request, { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider }, span) {
1327
+ async function handleInboxInternal(request, parameters, span) {
1328
+ const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
1300
1329
  const logger$1 = getLogger([
1301
1330
  "fedify",
1302
1331
  "federation",
@@ -1498,7 +1527,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
1498
1527
  kvPrefixes,
1499
1528
  queue,
1500
1529
  span,
1501
- tracerProvider
1530
+ tracerProvider,
1531
+ idempotencyStrategy: parameters.idempotencyStrategy
1502
1532
  });
1503
1533
  if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
1504
1534
  status: 202,
@@ -1528,7 +1558,7 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
1528
1558
  /**
1529
1559
  * Handles a custom collection request.
1530
1560
  * @template TItem The type of items in the collection.
1531
- * @template TParams The parameter names of the requested URL.
1561
+ * @template TParam The parameter names of the requested URL.
1532
1562
  * @template TContext The type of the context, extending {@link RequestContext}.
1533
1563
  * @template TContextData The context data to pass to the `TContext`.
1534
1564
  * @param request The HTTP request.
@@ -1547,7 +1577,7 @@ async function _handleCustomCollection(request, { name, values, context: context
1547
1577
  /**
1548
1578
  * Handles an ordered collection request.
1549
1579
  * @template TItem The type of items in the collection.
1550
- * @template TParams The parameter names of the requested URL.
1580
+ * @template TParam The parameter names of the requested URL.
1551
1581
  * @template TContext The type of the context, extending {@link RequestContext}.
1552
1582
  * @template TContextData The context data to pass to the `TContext`.
1553
1583
  * @param request The HTTP request.
@@ -1568,7 +1598,7 @@ async function _handleOrderedCollection(request, { name, values, context: contex
1568
1598
  * The main flow is on `getCollection`, `dispatch`.
1569
1599
  *
1570
1600
  * @template TItem The type of items in the collection.
1571
- * @template TParams The parameter names of the requested URL.
1601
+ * @template TParam The parameter names of the requested URL.
1572
1602
  * @template TContext The type of the context. {@link Context} or {@link RequestContext}.
1573
1603
  * @template TContextData The context data to pass to the `TContext`.
1574
1604
  * @template TCollection The type of the collection, extending {@link Collection}.
@@ -1602,14 +1632,14 @@ var CustomCollectionHandler = class {
1602
1632
  #collection = null;
1603
1633
  /**
1604
1634
  * Creates a new CustomCollection instance.
1605
- * @param {string} name The name of the collection.
1606
- * @param {TParams} values The parameter values for the collection.
1607
- * @param {TContext} context The request context.
1608
- * @param {CustomCollectionCallbacks} callbacks The collection callbacks.
1609
- * @param {TracerProvider} tracerProvider The tracer provider for telemetry.
1610
- * @param {ConstructorWithTypeId<TCollection>} Collection The Collection constructor.
1611
- * @param {ConstructorWithTypeId<TCollectionPage>} CollectionPage The CollectionPage constructor.
1612
- * @param {(item: TItem) => boolean} filterPredicate Optional filter predicate for items.
1635
+ * @param name The name of the collection.
1636
+ * @param values The parameter values for the collection.
1637
+ * @param context The request context.
1638
+ * @param callbacks The collection callbacks.
1639
+ * @param tracerProvider The tracer provider for telemetry.
1640
+ * @param Collection The Collection constructor.
1641
+ * @param CollectionPage The CollectionPage constructor.
1642
+ * @param filterPredicate Optional filter predicate for items.
1613
1643
  */
1614
1644
  constructor(name, values, context$1, callbacks, tracerProvider = trace.getTracerProvider(), Collection$1, CollectionPage$1, filterPredicate) {
1615
1645
  this.name = name;
@@ -1734,7 +1764,7 @@ var CustomCollectionHandler = class {
1734
1764
  /**
1735
1765
  * Creates a function to wrap the dispatcher so tracing can be applied.
1736
1766
  * @param params Parameters including cursor and total items.
1737
- * @returns {(span: Span) => Promise<PageItems<TItem>>} A function that handles the span operation.
1767
+ * @returns A function that handles the span operation.
1738
1768
  */
1739
1769
  spanPages = ({ totalItems = null, cursor = null }) => async (span) => {
1740
1770
  try {
@@ -1755,23 +1785,23 @@ var CustomCollectionHandler = class {
1755
1785
  };
1756
1786
  /**
1757
1787
  * Dispatches the collection request to get items.
1758
- * @param {string | null} cursor The cursor for pagination, or null for the first page.
1759
- * @returns {Promise<PageItems<TItem>>} A promise that resolves to the page items.
1788
+ * @param cursor The cursor for pagination, or null for the first page.
1789
+ * @returns A promise that resolves to the page items.
1760
1790
  */
1761
1791
  async dispatch(cursor = null) {
1762
1792
  return await this.#dispatcher(this.context, this.values, cursor) ?? new ItemsNotFoundError().throw();
1763
1793
  }
1764
1794
  /**
1765
1795
  * Filters the items in the collection.
1766
- * @param {TItem[]} items The items to filter.
1767
- * @returns {(Object | Link | URL)[]} The filtered items.
1796
+ * @param items The items to filter.
1797
+ * @returns The filtered items.
1768
1798
  */
1769
1799
  filterItems(items) {
1770
1800
  return filterCollectionItems(items, this.name, this.filterPredicate);
1771
1801
  }
1772
1802
  /**
1773
1803
  * Appends a cursor to the URL if it exists.
1774
- * @param {string | null | undefined} cursor The cursor to append, or null/undefined.
1804
+ * @param cursor The cursor to append, or null/undefined.
1775
1805
  * @returns The URL with cursor appended, or null if cursor is null/undefined.
1776
1806
  */
1777
1807
  appendToUrl(cursor) {
@@ -1779,8 +1809,7 @@ var CustomCollectionHandler = class {
1779
1809
  }
1780
1810
  /**
1781
1811
  * Gets the stored collection or collection page.
1782
- * @returns {Promise<TCollection | TCollectionPage>} A promise that resolves to
1783
- the collection or collection page.
1812
+ * @returns A promise that resolves to the collection or collection page.
1784
1813
  */
1785
1814
  get collection() {
1786
1815
  if (this.#collection === null) this.#collection = this.getCollection();
@@ -1788,8 +1817,8 @@ var CustomCollectionHandler = class {
1788
1817
  }
1789
1818
  /**
1790
1819
  * Gets the total number of items in the collection.
1791
- * @returns {Promise<number | null>} A promise that
1792
- resolves to the total items count, or null if not available.
1820
+ * @returns A promise that resolves to the total items count,
1821
+ * or null if not available.
1793
1822
  */
1794
1823
  get totalItems() {
1795
1824
  if (this.#totalItems === void 0) this.totalItems = this.callbacks.counter?.(this.context, this.values);
@@ -1805,8 +1834,8 @@ var CustomCollectionHandler = class {
1805
1834
  }
1806
1835
  /**
1807
1836
  * Gets the first cursor for pagination.
1808
- * @returns {Promise<string | null>} A promise that resolves to the first cursor,
1809
- or null if not available.
1837
+ * @returns A promise that resolves to the first cursor,
1838
+ * or null if not available.
1810
1839
  */
1811
1840
  get firstCursor() {
1812
1841
  const cursor = this.callbacks.firstCursor?.(this.context, this.values);
@@ -3095,7 +3124,8 @@ var FederationImpl = class extends FederationBuilderImpl {
3095
3124
  onNotFound,
3096
3125
  signatureTimeWindow: this.signatureTimeWindow,
3097
3126
  skipSignatureVerification: this.skipSignatureVerification,
3098
- tracerProvider: this.tracerProvider
3127
+ tracerProvider: this.tracerProvider,
3128
+ idempotencyStrategy: this.idempotencyStrategy
3099
3129
  });
3100
3130
  case "following": return await handleCollection(request, {
3101
3131
  name: "following",
@@ -3486,15 +3516,16 @@ var ContextImpl = class ContextImpl {
3486
3516
  "actor"
3487
3517
  ]);
3488
3518
  if (this.federation.actorCallbacks?.keyPairsDispatcher == null) throw new Error("No actor key pairs dispatcher registered.");
3489
- const path = this.federation.router.build("actor", {
3490
- identifier,
3491
- handle: identifier
3492
- });
3493
- if (path == null) {
3494
- logger$1.warn("No actor dispatcher registered.");
3495
- return [];
3519
+ let actorUri;
3520
+ try {
3521
+ actorUri = this.getActorUri(identifier);
3522
+ } catch (error) {
3523
+ if (error instanceof RouterError) {
3524
+ logger$1.warn(error.message);
3525
+ return [];
3526
+ }
3527
+ throw error;
3496
3528
  }
3497
- const actorUri = new URL(path, this.canonicalOrigin);
3498
3529
  const keyPairs = await this.federation.actorCallbacks?.keyPairsDispatcher(new ContextImpl({
3499
3530
  ...this,
3500
3531
  invokedFromActorKeyPairsDispatcher: { identifier }
@@ -3655,12 +3686,11 @@ var ContextImpl = class ContextImpl {
3655
3686
  if (identifier == null) throw new Error("If recipients is \"followers\", sender must be an actor identifier or username.");
3656
3687
  expandedRecipients = [];
3657
3688
  for await (const recipient of this.getFollowers(identifier)) expandedRecipients.push(recipient);
3658
- if (options.syncCollection) {
3659
- const collectionId = this.federation.router.build("followers", {
3660
- identifier,
3661
- handle: identifier
3662
- });
3663
- opts.collectionSync = collectionId == null ? void 0 : new URL(collectionId, this.canonicalOrigin).href;
3689
+ if (options.syncCollection) try {
3690
+ opts.collectionSync = this.getFollowersUri(identifier).href;
3691
+ } catch (error) {
3692
+ if (error instanceof RouterError) opts.collectionSync = void 0;
3693
+ else throw error;
3664
3694
  }
3665
3695
  } else expandedRecipients = [recipients];
3666
3696
  span.setAttribute("activitypub.inboxes", expandedRecipients.length);
@@ -3845,7 +3875,8 @@ var ContextImpl = class ContextImpl {
3845
3875
  kvPrefixes: this.federation.kvPrefixes,
3846
3876
  queue: this.federation.inboxQueue,
3847
3877
  span,
3848
- tracerProvider: options.tracerProvider ?? this.tracerProvider
3878
+ tracerProvider: options.tracerProvider ?? this.tracerProvider,
3879
+ idempotencyStrategy: this.federation.idempotencyStrategy
3849
3880
  });
3850
3881
  return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
3851
3882
  }
@@ -0,0 +1,17 @@
1
+
2
+ const { Temporal } = require("@js-temporal/polyfill");
3
+ const { URLPattern } = require("urlpattern-polyfill");
4
+
5
+ require('./transformers-CoBS-oFG.cjs');
6
+ require('./docloader-FAn755Ez.cjs');
7
+ require('./actor-DaFSkBV-.cjs');
8
+ const require_middleware = require('./middleware-CVb0KXM7.cjs');
9
+ require('./lookup-DSSOyhz2.cjs');
10
+ require('./key-DFZ_CvG0.cjs');
11
+ require('./http-D7xo4v5M.cjs');
12
+ require('./proof-DT8hWqV6.cjs');
13
+ require('./types-wG2EuWYS.cjs');
14
+ require('./authdocloader-DM1vtjbY.cjs');
15
+ require('./vocab-B_AjsPE2.cjs');
16
+
17
+ exports.FederationImpl = require_middleware.FederationImpl;
@@ -0,0 +1,17 @@
1
+
2
+ import { Temporal } from "@js-temporal/polyfill";
3
+ import { URLPattern } from "urlpattern-polyfill";
4
+
5
+ import "./transformers-BFT6d7J5.js";
6
+ import "./docloader-BRrqMbX0.js";
7
+ import "./actor-J-9oLs-V.js";
8
+ import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-4mR2kSKQ.js";
9
+ import "./lookup-Zzj9McvA.js";
10
+ import "./key-D7A24D7c.js";
11
+ import "./http-B0Rp4UOp.js";
12
+ import "./proof-iy7cOAt6.js";
13
+ import "./types-BCmRSiaD.js";
14
+ import "./authdocloader-D4qQkXT9.js";
15
+ import "./vocab-CtBL6Aur.js";
16
+
17
+ export { FederationImpl };