@fedify/fedify 1.9.0-pr.443.1682 → 1.9.0-pr.455.1742

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 (138) hide show
  1. package/dist/{actor-sT_gcgkl.d.ts → actor-C1Euqngb.d.ts} +1 -1
  2. package/dist/{actor-DNoKtm0e.js → actor-CL8lYYUx.js} +1 -1
  3. package/dist/{actor-BfM4acO7.js → actor-CYnaKz6k.js} +6169 -2946
  4. package/dist/{actor-C84MVjvg.cjs → actor-D_0j9hMV.cjs} +6169 -2946
  5. package/dist/{actor-D8GmZX63.d.cts → actor-Ydzhc8dj.d.cts} +1 -1
  6. package/dist/{authdocloader-BZ3wxRbU.cjs → authdocloader-AGT1bvSf.cjs} +3 -3
  7. package/dist/{authdocloader-BMUj-LDP.js → authdocloader-BlVoSqyh.js} +3 -3
  8. package/dist/{authdocloader-CSF0HpUd.js → authdocloader-CRuH00Tu.js} +3 -3
  9. package/dist/{builder-DbzYJjYW.js → builder-CqMKWEN0.js} +14 -8
  10. package/dist/{client-BXo-ifnJ.js → client-BM12q1DJ.js} +1 -1
  11. package/dist/compat/mod.d.cts +7 -7
  12. package/dist/compat/mod.d.ts +7 -7
  13. package/dist/compat/transformers.test.js +16 -16
  14. package/dist/{context-Cp-kboln.d.ts → context-CXUibY4L.d.ts} +179 -116
  15. package/dist/{context-BkqGJwLI.d.cts → context-CwUAkopp.d.cts} +179 -116
  16. package/dist/{docloader-vwID5KeD.js → docloader-BggS4E4F.js} +1 -1
  17. package/dist/{docloader-C8VNT_Xq.cjs → docloader-CLtA3Ji8.cjs} +1 -1
  18. package/dist/{esm-BrKG8Ydq.js → esm-B3jpomik.js} +1 -1
  19. package/dist/federation/builder.test.js +5 -5
  20. package/dist/federation/collection.test.js +3 -3
  21. package/dist/federation/handler.test.js +17 -17
  22. package/dist/federation/idempotency.test.d.ts +3 -0
  23. package/dist/federation/idempotency.test.js +202 -0
  24. package/dist/federation/inbox.test.js +4 -4
  25. package/dist/federation/keycache.test.js +4 -4
  26. package/dist/federation/kv.test.js +3 -3
  27. package/dist/federation/middleware.test.js +18 -18
  28. package/dist/federation/mod.cjs +10 -10
  29. package/dist/federation/mod.d.cts +7 -7
  30. package/dist/federation/mod.d.ts +7 -7
  31. package/dist/federation/mod.js +10 -10
  32. package/dist/federation/mq.test.js +3 -3
  33. package/dist/federation/retry.test.js +3 -3
  34. package/dist/federation/router.test.js +3 -3
  35. package/dist/federation/send.test.js +10 -10
  36. package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
  37. package/dist/{http-D21OQwhJ.cjs → http-2m_h3SPQ.cjs} +3 -3
  38. package/dist/{http-B9UPBFJz.d.cts → http-B1_DzfAU.d.cts} +1 -1
  39. package/dist/{http-1S7OolRE.js → http-D53H7oqD.js} +3 -3
  40. package/dist/{http-PJ3EklL0.js → http-DNkYeLxx.js} +2 -2
  41. package/dist/{http-BGqh2jzk.d.ts → http-wsGR6KkT.d.ts} +1 -1
  42. package/dist/{inbox-4wLOWRkP.js → inbox-FbqGLKha.js} +29 -7
  43. package/dist/{key-CH7qaiOX.js → key-B42BY6RL.js} +2 -2
  44. package/dist/{key-7YeppNTi.js → key-BVNVEpXg.js} +2 -2
  45. package/dist/key-CYO3d3Bc.cjs +10 -0
  46. package/dist/{key-Bt6aeupK.cjs → key-CZzEU9nv.cjs} +2 -2
  47. package/dist/{key-DTUnLJZM.js → key-Dj6-orIK.js} +3 -3
  48. package/dist/{key-DbudJOUz.js → key-NaBDH7FK.js} +4 -4
  49. package/dist/{keycache-OXZYOWra.js → keycache-BLtGOP6f.js} +1 -1
  50. package/dist/{keys-DMbcSHvH.js → keys-BO3n2h_L.js} +1 -1
  51. package/dist/{ld-BLx5h_2L.js → ld-CMWQXDty.js} +2 -2
  52. package/dist/{lookup-B8X3pPjF.js → lookup-B5jlZrQb.js} +21 -12
  53. package/dist/{lookup-BQHLqqvB.cjs → lookup-BsOmKssB.cjs} +1 -1
  54. package/dist/{lookup-tJvVI01W.js → lookup-C-jJgyrW.js} +1 -1
  55. package/dist/middleware-BV1L9XDk.cjs +17 -0
  56. package/dist/{middleware-DpNXnRa6.js → middleware-CNAH05Vn.js} +78 -47
  57. package/dist/middleware-Cr46LoSG.js +26 -0
  58. package/dist/middleware-DAFFQX5e.js +17 -0
  59. package/dist/{middleware-BN1ZyxrJ.cjs → middleware-DOd67qPG.cjs} +78 -47
  60. package/dist/{middleware-CPgUeSYU.js → middleware-lg47b3mK.js} +43 -40
  61. package/dist/{mod-DxjZ8kbs.d.cts → mod-BUbqxBev.d.cts} +19 -1
  62. package/dist/{mod-OfRtcQo1.d.ts → mod-BcObK1Lz.d.ts} +2 -2
  63. package/dist/{mod-CnEwcmyF.d.ts → mod-CDObsV1d.d.ts} +19 -1
  64. package/dist/{mod-TsyIDkKn.d.ts → mod-CIbqfZW0.d.ts} +1 -1
  65. package/dist/{mod-Cuem8g-I.d.ts → mod-DgcYoyZK.d.ts} +2 -2
  66. package/dist/{mod-bscaBAIo.d.cts → mod-Dt-G9ZOS.d.cts} +1 -1
  67. package/dist/{mod-BihGJmMM.d.cts → mod-fjqfsrty.d.cts} +2 -2
  68. package/dist/{mod-Ds5wiXHw.d.cts → mod-mXx9V0q5.d.cts} +2 -2
  69. package/dist/mod.cjs +10 -10
  70. package/dist/mod.d.cts +10 -10
  71. package/dist/mod.d.ts +10 -10
  72. package/dist/mod.js +10 -10
  73. package/dist/nodeinfo/client.test.js +5 -5
  74. package/dist/nodeinfo/handler.test.js +16 -16
  75. package/dist/nodeinfo/mod.cjs +2 -2
  76. package/dist/nodeinfo/mod.js +2 -2
  77. package/dist/nodeinfo/semver.test.js +3 -3
  78. package/dist/nodeinfo/types.test.js +3 -3
  79. package/dist/{owner-BYxDl2qi.d.cts → owner-6KSEp9eV.d.cts} +2 -2
  80. package/dist/{owner-DOUl7e-t.d.ts → owner-BbeUDvOu.d.ts} +2 -2
  81. package/dist/{owner-DeXz0uXj.js → owner-Ch2ApIpq.js} +2 -2
  82. package/dist/{proof-1YMXAyHu.cjs → proof-BtqGVz24.cjs} +3 -3
  83. package/dist/{proof-C5AaUlDb.js → proof-Cge6SysA.js} +3 -3
  84. package/dist/{proof-DEbHE-Rp.js → proof-DaD7vIAi.js} +2 -2
  85. package/dist/runtime/authdocloader.test.js +9 -9
  86. package/dist/runtime/docloader.test.js +4 -4
  87. package/dist/runtime/key.test.js +5 -5
  88. package/dist/runtime/langstr.test.js +3 -3
  89. package/dist/runtime/link.test.js +3 -3
  90. package/dist/runtime/mod.cjs +6 -6
  91. package/dist/runtime/mod.d.cts +3 -3
  92. package/dist/runtime/mod.d.ts +3 -3
  93. package/dist/runtime/mod.js +6 -6
  94. package/dist/runtime/multibase/multibase.test.js +3 -3
  95. package/dist/runtime/url.test.js +3 -3
  96. package/dist/{send-ZLr2Fq_j.js → send-DE79ptpc.js} +2 -2
  97. package/dist/sig/http.test.js +8 -8
  98. package/dist/sig/key.test.js +6 -6
  99. package/dist/sig/ld.test.js +7 -7
  100. package/dist/sig/mod.cjs +6 -6
  101. package/dist/sig/mod.d.cts +5 -5
  102. package/dist/sig/mod.d.ts +5 -5
  103. package/dist/sig/mod.js +6 -6
  104. package/dist/sig/owner.test.js +7 -7
  105. package/dist/sig/proof.test.js +7 -7
  106. package/dist/testing/docloader.test.js +3 -3
  107. package/dist/testing/mod.d.ts +341 -379
  108. package/dist/testing/mod.js +3 -3
  109. package/dist/{testing-CyBcyXDK.js → testing-Bh2wmeXp.js} +2 -2
  110. package/dist/{type-C9v8GMO6.js → type-Du-WE8NC.js} +6297 -3074
  111. package/dist/{types-B2Gwh9uw.cjs → types-B1n1v8Fa.cjs} +1 -1
  112. package/dist/{types-KhFFD-xZ.js → types-ChEbJU3f.js} +1 -1
  113. package/dist/vocab/actor.test.js +5 -5
  114. package/dist/vocab/lookup.test.js +255 -5
  115. package/dist/vocab/mod.cjs +4 -4
  116. package/dist/vocab/mod.d.cts +3 -3
  117. package/dist/vocab/mod.d.ts +3 -3
  118. package/dist/vocab/mod.js +4 -4
  119. package/dist/vocab/type.test.js +3 -3
  120. package/dist/vocab/vocab.test.js +395 -24
  121. package/dist/{vocab-BW6SWH9P.d.ts → vocab-CDHNj5zp.d.ts} +158 -497
  122. package/dist/{vocab-qpRpljdS.d.cts → vocab-Cfs0937i.d.cts} +158 -497
  123. package/dist/{vocab-95nbu41B.cjs → vocab-DY3aCxLN.cjs} +23 -14
  124. package/dist/{vocab-DUIA4PK3.js → vocab-Q8XBm9oV.js} +23 -14
  125. package/dist/webfinger/handler.test.js +16 -16
  126. package/dist/webfinger/lookup.test.js +4 -4
  127. package/dist/webfinger/mod.cjs +2 -2
  128. package/dist/webfinger/mod.js +2 -2
  129. package/dist/x/cfworkers.test.js +3 -3
  130. package/dist/x/hono.d.cts +6 -6
  131. package/dist/x/hono.d.ts +6 -6
  132. package/dist/x/sveltekit.d.cts +6 -6
  133. package/dist/x/sveltekit.d.ts +6 -6
  134. package/package.json +1 -1
  135. package/dist/key-C-eEPc5P.cjs +0 -10
  136. package/dist/middleware-BKKzirBh.cjs +0 -17
  137. package/dist/middleware-D9dqPUdF.js +0 -17
  138. package/dist/middleware-ofHkiPKA.js +0 -26
@@ -4,15 +4,15 @@
4
4
 
5
5
  const require_chunk = require('./chunk-DqRYRqnO.cjs');
6
6
  const require_transformers = require('./transformers-CoBS-oFG.cjs');
7
- const require_docloader = require('./docloader-C8VNT_Xq.cjs');
8
- const require_actor = require('./actor-C84MVjvg.cjs');
9
- const require_lookup = require('./lookup-BQHLqqvB.cjs');
10
- const require_key = require('./key-Bt6aeupK.cjs');
11
- const require_http = require('./http-D21OQwhJ.cjs');
12
- const require_proof = require('./proof-1YMXAyHu.cjs');
13
- const require_types = require('./types-B2Gwh9uw.cjs');
14
- const require_authdocloader = require('./authdocloader-BZ3wxRbU.cjs');
15
- const require_vocab = require('./vocab-95nbu41B.cjs');
7
+ const require_docloader = require('./docloader-CLtA3Ji8.cjs');
8
+ const require_actor = require('./actor-D_0j9hMV.cjs');
9
+ const require_lookup = require('./lookup-BsOmKssB.cjs');
10
+ const require_key = require('./key-CZzEU9nv.cjs');
11
+ const require_http = require('./http-2m_h3SPQ.cjs');
12
+ const require_proof = require('./proof-BtqGVz24.cjs');
13
+ const require_types = require('./types-B1n1v8Fa.cjs');
14
+ const require_authdocloader = require('./authdocloader-AGT1bvSf.cjs');
15
+ const require_vocab = require('./vocab-DY3aCxLN.cjs');
16
16
  const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
17
17
  const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
18
18
  const byte_encodings_hex = require_chunk.__toESM(require("byte-encodings/hex"));
@@ -56,17 +56,39 @@ var InboxListenerSet = class InboxListenerSet {
56
56
  return this.dispatchWithClass(activity)?.listener ?? null;
57
57
  }
58
58
  };
59
- async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider }) {
59
+ let warnedAboutDefaultIdempotency = false;
60
+ async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
60
61
  const logger$1 = (0, __logtape_logtape.getLogger)([
61
62
  "fedify",
62
63
  "federation",
63
64
  "inbox"
64
65
  ]);
65
- const cacheKey = activity.id == null ? null : [
66
- ...kvPrefixes.activityIdempotence,
67
- ctx.origin,
68
- activity.id.href
69
- ];
66
+ let cacheKey = null;
67
+ if (activity.id != null) {
68
+ const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, require_actor.getTypeId(activity).href);
69
+ const strategy = idempotencyStrategy ?? "per-origin";
70
+ if (idempotencyStrategy === void 0 && !warnedAboutDefaultIdempotency) {
71
+ 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().");
72
+ warnedAboutDefaultIdempotency = true;
73
+ }
74
+ let keyString;
75
+ if (typeof strategy === "function") {
76
+ const result = await strategy(inboxContext, activity);
77
+ keyString = result;
78
+ } else switch (strategy) {
79
+ case "global":
80
+ keyString = activity.id.href;
81
+ break;
82
+ case "per-origin":
83
+ keyString = `${ctx.origin}\n${activity.id.href}`;
84
+ break;
85
+ case "per-inbox":
86
+ keyString = `${ctx.origin}\n${activity.id.href}\n${recipient == null ? "sharedInbox" : `inbox\n${recipient}`}`;
87
+ break;
88
+ default: keyString = `${ctx.origin}\n${activity.id.href}`;
89
+ }
90
+ if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
91
+ }
70
92
  if (cacheKey != null) {
71
93
  const cached = await kv.get(cacheKey);
72
94
  if (cached === true) {
@@ -308,6 +330,7 @@ var FederationBuilderImpl = class {
308
330
  inboxListeners;
309
331
  inboxErrorHandler;
310
332
  sharedInboxKeyDispatcher;
333
+ idempotencyStrategy;
311
334
  collectionTypeIds;
312
335
  collectionCallbacks;
313
336
  /**
@@ -322,7 +345,7 @@ var FederationBuilderImpl = class {
322
345
  this.collectionTypeIds = {};
323
346
  }
324
347
  async build(options) {
325
- const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-BKKzirBh.cjs"));
348
+ const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-BV1L9XDk.cjs"));
326
349
  const f = new FederationImpl$1(options);
327
350
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
328
351
  f.router = this.router.clone();
@@ -344,6 +367,7 @@ var FederationBuilderImpl = class {
344
367
  f.inboxListeners = this.inboxListeners?.clone();
345
368
  f.inboxErrorHandler = this.inboxErrorHandler;
346
369
  f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
370
+ f.idempotencyStrategy = this.idempotencyStrategy;
347
371
  return f;
348
372
  }
349
373
  _getTracer() {
@@ -766,15 +790,19 @@ var FederationBuilderImpl = class {
766
790
  setSharedKeyDispatcher: (dispatcher) => {
767
791
  this.sharedInboxKeyDispatcher = dispatcher;
768
792
  return setters;
793
+ },
794
+ withIdempotency: (strategy) => {
795
+ this.idempotencyStrategy = strategy;
796
+ return setters;
769
797
  }
770
798
  };
771
799
  return setters;
772
800
  }
773
- setCollectionDispatcher(name, ...args) {
774
- return this.#setCustomCollectionDispatcher(name, "collection", ...args);
801
+ setCollectionDispatcher(name, itemType, path, dispatcher) {
802
+ return this.#setCustomCollectionDispatcher(name, "collection", itemType, path, dispatcher);
775
803
  }
776
- setOrderedCollectionDispatcher(name, ...args) {
777
- return this.#setCustomCollectionDispatcher(name, "orderedCollection", ...args);
804
+ setOrderedCollectionDispatcher(name, itemType, path, dispatcher) {
805
+ return this.#setCustomCollectionDispatcher(name, "orderedCollection", itemType, path, dispatcher);
778
806
  }
779
807
  #setCustomCollectionDispatcher(name, collectionType, itemType, path, dispatcher) {
780
808
  const strName = String(name);
@@ -1297,7 +1325,8 @@ async function handleInbox(request, options) {
1297
1325
  * @param span The OpenTelemetry span for tracing.
1298
1326
  * @returns A promise that resolves to an HTTP response.
1299
1327
  */
1300
- async function handleInboxInternal(request, { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider }, span) {
1328
+ async function handleInboxInternal(request, parameters, span) {
1329
+ const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
1301
1330
  const logger$1 = (0, __logtape_logtape.getLogger)([
1302
1331
  "fedify",
1303
1332
  "federation",
@@ -1499,7 +1528,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
1499
1528
  kvPrefixes,
1500
1529
  queue,
1501
1530
  span,
1502
- tracerProvider
1531
+ tracerProvider,
1532
+ idempotencyStrategy: parameters.idempotencyStrategy
1503
1533
  });
1504
1534
  if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
1505
1535
  status: 202,
@@ -1529,7 +1559,7 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
1529
1559
  /**
1530
1560
  * Handles a custom collection request.
1531
1561
  * @template TItem The type of items in the collection.
1532
- * @template TParams The parameter names of the requested URL.
1562
+ * @template TParam The parameter names of the requested URL.
1533
1563
  * @template TContext The type of the context, extending {@link RequestContext}.
1534
1564
  * @template TContextData The context data to pass to the `TContext`.
1535
1565
  * @param request The HTTP request.
@@ -1548,7 +1578,7 @@ async function _handleCustomCollection(request, { name, values, context: context
1548
1578
  /**
1549
1579
  * Handles an ordered collection request.
1550
1580
  * @template TItem The type of items in the collection.
1551
- * @template TParams The parameter names of the requested URL.
1581
+ * @template TParam The parameter names of the requested URL.
1552
1582
  * @template TContext The type of the context, extending {@link RequestContext}.
1553
1583
  * @template TContextData The context data to pass to the `TContext`.
1554
1584
  * @param request The HTTP request.
@@ -1569,7 +1599,7 @@ async function _handleOrderedCollection(request, { name, values, context: contex
1569
1599
  * The main flow is on `getCollection`, `dispatch`.
1570
1600
  *
1571
1601
  * @template TItem The type of items in the collection.
1572
- * @template TParams The parameter names of the requested URL.
1602
+ * @template TParam The parameter names of the requested URL.
1573
1603
  * @template TContext The type of the context. {@link Context} or {@link RequestContext}.
1574
1604
  * @template TContextData The context data to pass to the `TContext`.
1575
1605
  * @template TCollection The type of the collection, extending {@link Collection}.
@@ -1603,14 +1633,14 @@ var CustomCollectionHandler = class {
1603
1633
  #collection = null;
1604
1634
  /**
1605
1635
  * Creates a new CustomCollection instance.
1606
- * @param {string} name The name of the collection.
1607
- * @param {TParams} values The parameter values for the collection.
1608
- * @param {TContext} context The request context.
1609
- * @param {CustomCollectionCallbacks} callbacks The collection callbacks.
1610
- * @param {TracerProvider} tracerProvider The tracer provider for telemetry.
1611
- * @param {ConstructorWithTypeId<TCollection>} Collection The Collection constructor.
1612
- * @param {ConstructorWithTypeId<TCollectionPage>} CollectionPage The CollectionPage constructor.
1613
- * @param {(item: TItem) => boolean} filterPredicate Optional filter predicate for items.
1636
+ * @param name The name of the collection.
1637
+ * @param values The parameter values for the collection.
1638
+ * @param context The request context.
1639
+ * @param callbacks The collection callbacks.
1640
+ * @param tracerProvider The tracer provider for telemetry.
1641
+ * @param Collection The Collection constructor.
1642
+ * @param CollectionPage The CollectionPage constructor.
1643
+ * @param filterPredicate Optional filter predicate for items.
1614
1644
  */
1615
1645
  constructor(name, values, context$2, callbacks, tracerProvider = __opentelemetry_api.trace.getTracerProvider(), Collection$1, CollectionPage$1, filterPredicate) {
1616
1646
  this.name = name;
@@ -1735,7 +1765,7 @@ var CustomCollectionHandler = class {
1735
1765
  /**
1736
1766
  * Creates a function to wrap the dispatcher so tracing can be applied.
1737
1767
  * @param params Parameters including cursor and total items.
1738
- * @returns {(span: Span) => Promise<PageItems<TItem>>} A function that handles the span operation.
1768
+ * @returns A function that handles the span operation.
1739
1769
  */
1740
1770
  spanPages = ({ totalItems = null, cursor = null }) => async (span) => {
1741
1771
  try {
@@ -1756,23 +1786,23 @@ var CustomCollectionHandler = class {
1756
1786
  };
1757
1787
  /**
1758
1788
  * Dispatches the collection request to get items.
1759
- * @param {string | null} cursor The cursor for pagination, or null for the first page.
1760
- * @returns {Promise<PageItems<TItem>>} A promise that resolves to the page items.
1789
+ * @param cursor The cursor for pagination, or null for the first page.
1790
+ * @returns A promise that resolves to the page items.
1761
1791
  */
1762
1792
  async dispatch(cursor = null) {
1763
1793
  return await this.#dispatcher(this.context, this.values, cursor) ?? new ItemsNotFoundError().throw();
1764
1794
  }
1765
1795
  /**
1766
1796
  * Filters the items in the collection.
1767
- * @param {TItem[]} items The items to filter.
1768
- * @returns {(Object | Link | URL)[]} The filtered items.
1797
+ * @param items The items to filter.
1798
+ * @returns The filtered items.
1769
1799
  */
1770
1800
  filterItems(items) {
1771
1801
  return filterCollectionItems(items, this.name, this.filterPredicate);
1772
1802
  }
1773
1803
  /**
1774
1804
  * Appends a cursor to the URL if it exists.
1775
- * @param {string | null | undefined} cursor The cursor to append, or null/undefined.
1805
+ * @param cursor The cursor to append, or null/undefined.
1776
1806
  * @returns The URL with cursor appended, or null if cursor is null/undefined.
1777
1807
  */
1778
1808
  appendToUrl(cursor) {
@@ -1780,8 +1810,7 @@ var CustomCollectionHandler = class {
1780
1810
  }
1781
1811
  /**
1782
1812
  * Gets the stored collection or collection page.
1783
- * @returns {Promise<TCollection | TCollectionPage>} A promise that resolves to
1784
- the collection or collection page.
1813
+ * @returns A promise that resolves to the collection or collection page.
1785
1814
  */
1786
1815
  get collection() {
1787
1816
  if (this.#collection === null) this.#collection = this.getCollection();
@@ -1789,8 +1818,8 @@ var CustomCollectionHandler = class {
1789
1818
  }
1790
1819
  /**
1791
1820
  * Gets the total number of items in the collection.
1792
- * @returns {Promise<number | null>} A promise that
1793
- resolves to the total items count, or null if not available.
1821
+ * @returns A promise that resolves to the total items count,
1822
+ * or null if not available.
1794
1823
  */
1795
1824
  get totalItems() {
1796
1825
  if (this.#totalItems === void 0) this.totalItems = this.callbacks.counter?.(this.context, this.values);
@@ -1806,8 +1835,8 @@ var CustomCollectionHandler = class {
1806
1835
  }
1807
1836
  /**
1808
1837
  * Gets the first cursor for pagination.
1809
- * @returns {Promise<string | null>} A promise that resolves to the first cursor,
1810
- or null if not available.
1838
+ * @returns A promise that resolves to the first cursor,
1839
+ * or null if not available.
1811
1840
  */
1812
1841
  get firstCursor() {
1813
1842
  const cursor = this.callbacks.firstCursor?.(this.context, this.values);
@@ -3096,7 +3125,8 @@ var FederationImpl = class extends FederationBuilderImpl {
3096
3125
  onNotFound,
3097
3126
  signatureTimeWindow: this.signatureTimeWindow,
3098
3127
  skipSignatureVerification: this.skipSignatureVerification,
3099
- tracerProvider: this.tracerProvider
3128
+ tracerProvider: this.tracerProvider,
3129
+ idempotencyStrategy: this.idempotencyStrategy
3100
3130
  });
3101
3131
  case "following": return await handleCollection(request, {
3102
3132
  name: "following",
@@ -3846,7 +3876,8 @@ var ContextImpl = class ContextImpl {
3846
3876
  kvPrefixes: this.federation.kvPrefixes,
3847
3877
  queue: this.federation.inboxQueue,
3848
3878
  span,
3849
- tracerProvider: options.tracerProvider ?? this.tracerProvider
3879
+ tracerProvider: options.tracerProvider ?? this.tracerProvider,
3880
+ idempotencyStrategy: this.federation.idempotencyStrategy
3850
3881
  });
3851
3882
  return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
3852
3883
  }
@@ -3,22 +3,22 @@
3
3
  import { URLPattern } from "urlpattern-polyfill";
4
4
  globalThis.addEventListener = () => {};
5
5
 
6
- import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, deno_default, getDocumentLoader, getTypeId, kvCache, lookupWebFinger } from "./type-C9v8GMO6.js";
7
- import { getNodeInfo } from "./client-BXo-ifnJ.js";
8
- import { RouterError, lookupObject, traverseCollection } from "./lookup-B8X3pPjF.js";
6
+ import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, deno_default, getDocumentLoader, getTypeId, kvCache, lookupWebFinger } from "./type-Du-WE8NC.js";
7
+ import { getNodeInfo } from "./client-BM12q1DJ.js";
8
+ import { RouterError, lookupObject, traverseCollection } from "./lookup-B5jlZrQb.js";
9
9
  import { nodeInfoToJson } from "./types-BIgY6c-l.js";
10
- import { exportJwk, importJwk, validateCryptoKey } from "./key-CH7qaiOX.js";
11
- import { verifyRequest } from "./http-PJ3EklL0.js";
12
- import { getAuthenticatedDocumentLoader } from "./authdocloader-BMUj-LDP.js";
13
- import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-BLx5h_2L.js";
14
- import { doesActorOwnKey, getKeyOwner } from "./owner-DeXz0uXj.js";
15
- import { signObject, verifyObject } from "./proof-DEbHE-Rp.js";
16
- import { routeActivity } from "./inbox-4wLOWRkP.js";
17
- import { FederationBuilderImpl } from "./builder-DbzYJjYW.js";
10
+ import { exportJwk, importJwk, validateCryptoKey } from "./key-B42BY6RL.js";
11
+ import { verifyRequest } from "./http-DNkYeLxx.js";
12
+ import { getAuthenticatedDocumentLoader } from "./authdocloader-BlVoSqyh.js";
13
+ import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-CMWQXDty.js";
14
+ import { doesActorOwnKey, getKeyOwner } from "./owner-Ch2ApIpq.js";
15
+ import { signObject, verifyObject } from "./proof-DaD7vIAi.js";
16
+ import { routeActivity } from "./inbox-FbqGLKha.js";
17
+ import { FederationBuilderImpl } from "./builder-CqMKWEN0.js";
18
18
  import { buildCollectionSynchronizationHeader } from "./collection-CSzG2j1P.js";
19
- import { KvKeyCache } from "./keycache-OXZYOWra.js";
19
+ import { KvKeyCache } from "./keycache-BLtGOP6f.js";
20
20
  import { createExponentialBackoffPolicy } from "./retry-D4GJ670a.js";
21
- import { extractInboxes, sendActivity } from "./send-ZLr2Fq_j.js";
21
+ import { extractInboxes, sendActivity } from "./send-DE79ptpc.js";
22
22
  import { getLogger, withContext } from "@logtape/logtape";
23
23
  import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
24
24
  import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_HEADER, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
@@ -671,7 +671,8 @@ async function handleInbox(request, options) {
671
671
  * @param span The OpenTelemetry span for tracing.
672
672
  * @returns A promise that resolves to an HTTP response.
673
673
  */
674
- async function handleInboxInternal(request, { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider }, span) {
674
+ async function handleInboxInternal(request, parameters, span) {
675
+ const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
675
676
  const logger$2 = getLogger([
676
677
  "fedify",
677
678
  "federation",
@@ -873,7 +874,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
873
874
  kvPrefixes,
874
875
  queue,
875
876
  span,
876
- tracerProvider
877
+ tracerProvider,
878
+ idempotencyStrategy: parameters.idempotencyStrategy
877
879
  });
878
880
  if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
879
881
  status: 202,
@@ -903,7 +905,7 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
903
905
  /**
904
906
  * Handles a custom collection request.
905
907
  * @template TItem The type of items in the collection.
906
- * @template TParams The parameter names of the requested URL.
908
+ * @template TParam The parameter names of the requested URL.
907
909
  * @template TContext The type of the context, extending {@link RequestContext}.
908
910
  * @template TContextData The context data to pass to the `TContext`.
909
911
  * @param request The HTTP request.
@@ -922,7 +924,7 @@ async function _handleCustomCollection(request, { name, values, context: context
922
924
  /**
923
925
  * Handles an ordered collection request.
924
926
  * @template TItem The type of items in the collection.
925
- * @template TParams The parameter names of the requested URL.
927
+ * @template TParam The parameter names of the requested URL.
926
928
  * @template TContext The type of the context, extending {@link RequestContext}.
927
929
  * @template TContextData The context data to pass to the `TContext`.
928
930
  * @param request The HTTP request.
@@ -943,7 +945,7 @@ async function _handleOrderedCollection(request, { name, values, context: contex
943
945
  * The main flow is on `getCollection`, `dispatch`.
944
946
  *
945
947
  * @template TItem The type of items in the collection.
946
- * @template TParams The parameter names of the requested URL.
948
+ * @template TParam The parameter names of the requested URL.
947
949
  * @template TContext The type of the context. {@link Context} or {@link RequestContext}.
948
950
  * @template TContextData The context data to pass to the `TContext`.
949
951
  * @template TCollection The type of the collection, extending {@link Collection}.
@@ -977,14 +979,14 @@ var CustomCollectionHandler = class {
977
979
  #collection = null;
978
980
  /**
979
981
  * Creates a new CustomCollection instance.
980
- * @param {string} name The name of the collection.
981
- * @param {TParams} values The parameter values for the collection.
982
- * @param {TContext} context The request context.
983
- * @param {CustomCollectionCallbacks} callbacks The collection callbacks.
984
- * @param {TracerProvider} tracerProvider The tracer provider for telemetry.
985
- * @param {ConstructorWithTypeId<TCollection>} Collection The Collection constructor.
986
- * @param {ConstructorWithTypeId<TCollectionPage>} CollectionPage The CollectionPage constructor.
987
- * @param {(item: TItem) => boolean} filterPredicate Optional filter predicate for items.
982
+ * @param name The name of the collection.
983
+ * @param values The parameter values for the collection.
984
+ * @param context The request context.
985
+ * @param callbacks The collection callbacks.
986
+ * @param tracerProvider The tracer provider for telemetry.
987
+ * @param Collection The Collection constructor.
988
+ * @param CollectionPage The CollectionPage constructor.
989
+ * @param filterPredicate Optional filter predicate for items.
988
990
  */
989
991
  constructor(name, values, context$1, callbacks, tracerProvider = trace.getTracerProvider(), Collection$1, CollectionPage$1, filterPredicate) {
990
992
  this.name = name;
@@ -1109,7 +1111,7 @@ var CustomCollectionHandler = class {
1109
1111
  /**
1110
1112
  * Creates a function to wrap the dispatcher so tracing can be applied.
1111
1113
  * @param params Parameters including cursor and total items.
1112
- * @returns {(span: Span) => Promise<PageItems<TItem>>} A function that handles the span operation.
1114
+ * @returns A function that handles the span operation.
1113
1115
  */
1114
1116
  spanPages = ({ totalItems = null, cursor = null }) => async (span) => {
1115
1117
  try {
@@ -1130,23 +1132,23 @@ var CustomCollectionHandler = class {
1130
1132
  };
1131
1133
  /**
1132
1134
  * Dispatches the collection request to get items.
1133
- * @param {string | null} cursor The cursor for pagination, or null for the first page.
1134
- * @returns {Promise<PageItems<TItem>>} A promise that resolves to the page items.
1135
+ * @param cursor The cursor for pagination, or null for the first page.
1136
+ * @returns A promise that resolves to the page items.
1135
1137
  */
1136
1138
  async dispatch(cursor = null) {
1137
1139
  return await this.#dispatcher(this.context, this.values, cursor) ?? new ItemsNotFoundError().throw();
1138
1140
  }
1139
1141
  /**
1140
1142
  * Filters the items in the collection.
1141
- * @param {TItem[]} items The items to filter.
1142
- * @returns {(Object | Link | URL)[]} The filtered items.
1143
+ * @param items The items to filter.
1144
+ * @returns The filtered items.
1143
1145
  */
1144
1146
  filterItems(items) {
1145
1147
  return filterCollectionItems(items, this.name, this.filterPredicate);
1146
1148
  }
1147
1149
  /**
1148
1150
  * Appends a cursor to the URL if it exists.
1149
- * @param {string | null | undefined} cursor The cursor to append, or null/undefined.
1151
+ * @param cursor The cursor to append, or null/undefined.
1150
1152
  * @returns The URL with cursor appended, or null if cursor is null/undefined.
1151
1153
  */
1152
1154
  appendToUrl(cursor) {
@@ -1154,8 +1156,7 @@ var CustomCollectionHandler = class {
1154
1156
  }
1155
1157
  /**
1156
1158
  * Gets the stored collection or collection page.
1157
- * @returns {Promise<TCollection | TCollectionPage>} A promise that resolves to
1158
- the collection or collection page.
1159
+ * @returns A promise that resolves to the collection or collection page.
1159
1160
  */
1160
1161
  get collection() {
1161
1162
  if (this.#collection === null) this.#collection = this.getCollection();
@@ -1163,8 +1164,8 @@ var CustomCollectionHandler = class {
1163
1164
  }
1164
1165
  /**
1165
1166
  * Gets the total number of items in the collection.
1166
- * @returns {Promise<number | null>} A promise that
1167
- resolves to the total items count, or null if not available.
1167
+ * @returns A promise that resolves to the total items count,
1168
+ * or null if not available.
1168
1169
  */
1169
1170
  get totalItems() {
1170
1171
  if (this.#totalItems === void 0) this.totalItems = this.callbacks.counter?.(this.context, this.values);
@@ -1180,8 +1181,8 @@ var CustomCollectionHandler = class {
1180
1181
  }
1181
1182
  /**
1182
1183
  * Gets the first cursor for pagination.
1183
- * @returns {Promise<string | null>} A promise that resolves to the first cursor,
1184
- or null if not available.
1184
+ * @returns A promise that resolves to the first cursor,
1185
+ * or null if not available.
1185
1186
  */
1186
1187
  get firstCursor() {
1187
1188
  const cursor = this.callbacks.firstCursor?.(this.context, this.values);
@@ -2151,7 +2152,8 @@ var FederationImpl = class extends FederationBuilderImpl {
2151
2152
  onNotFound,
2152
2153
  signatureTimeWindow: this.signatureTimeWindow,
2153
2154
  skipSignatureVerification: this.skipSignatureVerification,
2154
- tracerProvider: this.tracerProvider
2155
+ tracerProvider: this.tracerProvider,
2156
+ idempotencyStrategy: this.idempotencyStrategy
2155
2157
  });
2156
2158
  case "following": return await handleCollection(request, {
2157
2159
  name: "following",
@@ -2901,7 +2903,8 @@ var ContextImpl = class ContextImpl {
2901
2903
  kvPrefixes: this.federation.kvPrefixes,
2902
2904
  queue: this.federation.inboxQueue,
2903
2905
  span,
2904
- tracerProvider: options.tracerProvider ?? this.tracerProvider
2906
+ tracerProvider: options.tracerProvider ?? this.tracerProvider,
2907
+ idempotencyStrategy: this.federation.idempotencyStrategy
2905
2908
  });
2906
2909
  return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
2907
2910
  }
@@ -1,5 +1,5 @@
1
1
  import { DocumentLoader, GetUserAgentOptions } from "./docloader-D-MrRyHl.cjs";
2
- import { Collection, Link, Object as Object$1 } from "./vocab-qpRpljdS.cjs";
2
+ import { Collection, Link, Object as Object$1 } from "./vocab-Cfs0937i.cjs";
3
3
  import { TracerProvider } from "@opentelemetry/api";
4
4
 
5
5
  //#region src/vocab/lookup.d.ts
@@ -18,6 +18,24 @@ interface LookupObjectOptions {
18
18
  * @since 0.8.0
19
19
  */
20
20
  contextLoader?: DocumentLoader;
21
+ /**
22
+ * Whether to allow fetching an object with an `@id` having a different
23
+ * origin than the object's URL. This is not recommended, as it may
24
+ * lead to security issues. Only use this option if you know what you
25
+ * are doing.
26
+ *
27
+ * How to handle the case when an object's `@id` has a different origin
28
+ * than the object's URL:
29
+ *
30
+ * - `"ignore"` (default): Do not return the object, and log a warning.
31
+ * - `"throw"`: Throw an error.
32
+ * - `"trust"`: Bypass the check and return the object anyway. This
33
+ * is not recommended, as it may lead to security issues. Only use
34
+ * this option if you know what you are doing.
35
+ *
36
+ * @since 1.9.0
37
+ */
38
+ crossOrigin?: "ignore" | "throw" | "trust";
21
39
  /**
22
40
  * The options for making `User-Agent` header.
23
41
  * If a string is given, it is used as the `User-Agent` header value.
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { Activity } from "./vocab-BW6SWH9P.js";
4
- import { ActivityTransformer, Context } from "./context-Cp-kboln.js";
3
+ import { Activity } from "./vocab-CDHNj5zp.js";
4
+ import { ActivityTransformer, Context } from "./context-CXUibY4L.js";
5
5
 
6
6
  //#region src/compat/transformers.d.ts
7
7
 
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  import { DocumentLoader, GetUserAgentOptions } from "./docloader-CxWcuWqQ.js";
4
- import { Collection, Link, Object as Object$1 } from "./vocab-BW6SWH9P.js";
4
+ import { Collection, Link, Object as Object$1 } from "./vocab-CDHNj5zp.js";
5
5
  import { TracerProvider } from "@opentelemetry/api";
6
6
 
7
7
  //#region src/vocab/lookup.d.ts
@@ -20,6 +20,24 @@ interface LookupObjectOptions {
20
20
  * @since 0.8.0
21
21
  */
22
22
  contextLoader?: DocumentLoader;
23
+ /**
24
+ * Whether to allow fetching an object with an `@id` having a different
25
+ * origin than the object's URL. This is not recommended, as it may
26
+ * lead to security issues. Only use this option if you know what you
27
+ * are doing.
28
+ *
29
+ * How to handle the case when an object's `@id` has a different origin
30
+ * than the object's URL:
31
+ *
32
+ * - `"ignore"` (default): Do not return the object, and log a warning.
33
+ * - `"throw"`: Throw an error.
34
+ * - `"trust"`: Bypass the check and return the object anyway. This
35
+ * is not recommended, as it may lead to security issues. Only use
36
+ * this option if you know what you are doing.
37
+ *
38
+ * @since 1.9.0
39
+ */
40
+ crossOrigin?: "ignore" | "throw" | "trust";
23
41
  /**
24
42
  * The options for making `User-Agent` header.
25
43
  * If a string is given, it is used as the `User-Agent` header value.
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  import { DocumentLoader, DocumentLoaderFactoryOptions } from "./docloader-CxWcuWqQ.js";
4
- import { HttpMessageSignaturesSpecDeterminer } from "./http-BGqh2jzk.js";
4
+ import { HttpMessageSignaturesSpecDeterminer } from "./http-wsGR6KkT.js";
5
5
  import { TracerProvider } from "@opentelemetry/api";
6
6
 
7
7
  //#region src/runtime/authdocloader.d.ts
@@ -1,8 +1,8 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  import { DocumentLoader } from "./docloader-CxWcuWqQ.js";
4
- import { CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1 } from "./vocab-BW6SWH9P.js";
5
- import { KeyCache } from "./http-BGqh2jzk.js";
4
+ import { CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1 } from "./vocab-CDHNj5zp.js";
5
+ import { KeyCache } from "./http-wsGR6KkT.js";
6
6
  import { TracerProvider } from "@opentelemetry/api";
7
7
 
8
8
  //#region src/sig/ld.d.ts
@@ -1,5 +1,5 @@
1
1
  import { DocumentLoader, DocumentLoaderFactoryOptions } from "./docloader-D-MrRyHl.cjs";
2
- import { HttpMessageSignaturesSpecDeterminer } from "./http-B9UPBFJz.cjs";
2
+ import { HttpMessageSignaturesSpecDeterminer } from "./http-B1_DzfAU.cjs";
3
3
  import { TracerProvider } from "@opentelemetry/api";
4
4
 
5
5
  //#region src/runtime/authdocloader.d.ts
@@ -1,6 +1,6 @@
1
1
  import { DocumentLoader } from "./docloader-D-MrRyHl.cjs";
2
- import { CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1 } from "./vocab-qpRpljdS.cjs";
3
- import { KeyCache } from "./http-B9UPBFJz.cjs";
2
+ import { CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1 } from "./vocab-Cfs0937i.cjs";
3
+ import { KeyCache } from "./http-B1_DzfAU.cjs";
4
4
  import { TracerProvider } from "@opentelemetry/api";
5
5
 
6
6
  //#region src/sig/ld.d.ts
@@ -1,5 +1,5 @@
1
- import { Activity } from "./vocab-qpRpljdS.cjs";
2
- import { ActivityTransformer, Context } from "./context-BkqGJwLI.cjs";
1
+ import { Activity } from "./vocab-Cfs0937i.cjs";
2
+ import { ActivityTransformer, Context } from "./context-CwUAkopp.cjs";
3
3
 
4
4
  //#region src/compat/transformers.d.ts
5
5
 
package/dist/mod.cjs CHANGED
@@ -4,17 +4,17 @@
4
4
 
5
5
  const require_transformers = require('./transformers-CoBS-oFG.cjs');
6
6
  require('./compat-DmDDELst.cjs');
7
- const require_docloader = require('./docloader-C8VNT_Xq.cjs');
8
- const require_actor = require('./actor-C84MVjvg.cjs');
9
- const require_middleware = require('./middleware-BN1ZyxrJ.cjs');
10
- const require_lookup = require('./lookup-BQHLqqvB.cjs');
11
- const require_key = require('./key-Bt6aeupK.cjs');
12
- const require_http = require('./http-D21OQwhJ.cjs');
13
- const require_proof = require('./proof-1YMXAyHu.cjs');
7
+ const require_docloader = require('./docloader-CLtA3Ji8.cjs');
8
+ const require_actor = require('./actor-D_0j9hMV.cjs');
9
+ const require_middleware = require('./middleware-DOd67qPG.cjs');
10
+ const require_lookup = require('./lookup-BsOmKssB.cjs');
11
+ const require_key = require('./key-CZzEU9nv.cjs');
12
+ const require_http = require('./http-2m_h3SPQ.cjs');
13
+ const require_proof = require('./proof-BtqGVz24.cjs');
14
14
  const require_federation = require('./federation-H2_En3j5.cjs');
15
- const require_types = require('./types-B2Gwh9uw.cjs');
16
- const require_authdocloader = require('./authdocloader-BZ3wxRbU.cjs');
17
- const require_vocab = require('./vocab-95nbu41B.cjs');
15
+ const require_types = require('./types-B1n1v8Fa.cjs');
16
+ const require_authdocloader = require('./authdocloader-AGT1bvSf.cjs');
17
+ const require_vocab = require('./vocab-DY3aCxLN.cjs');
18
18
  require('./nodeinfo-Co9lJrWl.cjs');
19
19
  require('./runtime-C58AJWSv.cjs');
20
20
  require('./sig-ByHXzqUi.cjs');