@fedify/fedify 2.1.12 → 2.1.13

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 (89) hide show
  1. package/dist/{builder-D9hlyCx5.mjs → builder-BII9kySt.mjs} +3 -3
  2. package/dist/{chunk-nlSIicah.js → chunk-CRNNMoPX.js} +2 -2
  3. package/dist/{client-z-8dc-e1.d.cts → client-CAM_bQXx.d.cts} +1 -0
  4. package/dist/{client-AtlibPOU.d.ts → client-CSddvgWN.d.ts} +1 -2
  5. package/dist/compat/mod.d.cts +2 -1
  6. package/dist/compat/mod.d.ts +2 -3
  7. package/dist/compat/mod.js +3 -3
  8. package/dist/compat/transformers.test.mjs +1 -1
  9. package/dist/{context-C0fssarc.d.ts → context-BUEOz39K.d.cts} +6 -7
  10. package/dist/{context-LmrZPwti.d.cts → context-CqlKdpQu.d.ts} +6 -5
  11. package/dist/{deno-Ddb3P7G7.mjs → deno-DsYpa8eE.mjs} +1 -1
  12. package/dist/{docloader-CK8tewt1.mjs → docloader-SiTy_uEf.mjs} +2 -2
  13. package/dist/federation/builder.test.mjs +1 -1
  14. package/dist/federation/handler.test.mjs +3 -3
  15. package/dist/federation/idempotency.test.mjs +2 -2
  16. package/dist/federation/inbox.test.mjs +1 -1
  17. package/dist/federation/middleware.test.mjs +6 -6
  18. package/dist/federation/mod.cjs +1 -1
  19. package/dist/federation/mod.d.cts +4 -3
  20. package/dist/federation/mod.d.ts +4 -5
  21. package/dist/federation/mod.js +2 -2
  22. package/dist/federation/send.test.mjs +3 -3
  23. package/dist/federation/webfinger.test.mjs +1 -1
  24. package/dist/{http-CrGuipxe.d.cts → http-BDZeS5om.d.ts} +2 -1
  25. package/dist/{http-qKyJKSnF.js → http-BhNk2Qd4.js} +58 -10
  26. package/dist/{http-aQzN9Ayi.d.ts → http-C87EWkO0.d.cts} +2 -3
  27. package/dist/{http-CmDErAnD.cjs → http-LasosqSl.cjs} +57 -9
  28. package/dist/{http-DRDpStn2.mjs → http-sMWapA1W.mjs} +58 -10
  29. package/dist/{inbox-DTuPJEma.mjs → inbox-Fz4Sd_YF.mjs} +1 -1
  30. package/dist/{key-WSedbAA-.mjs → key-BTwUWGeQ.mjs} +1 -1
  31. package/dist/{kv-CbLNp3zQ.d.cts → kv-D6hNiMTK.d.ts} +1 -0
  32. package/dist/{kv-cache-DNNRFY8u.js → kv-cache-DD4J1hjd.js} +2 -2
  33. package/dist/{kv-cache-B01V7s3h.mjs → kv-cache-FsT1ljhs.mjs} +1 -1
  34. package/dist/{kv-cache-9cdQDeT0.cjs → kv-cache-P8ilpPhX.cjs} +2 -2
  35. package/dist/{kv-GFYnFoOl.d.ts → kv-gJ8LYbxX.d.cts} +1 -3
  36. package/dist/{ld-OBpaLfHR.mjs → ld--_e4kYb3.mjs} +2 -2
  37. package/dist/{middleware-UThUK30x.js → middleware-BmExpfep.js} +7 -7
  38. package/dist/{middleware-DDsnRvFC.mjs → middleware-BwUi2CSK.mjs} +11 -11
  39. package/dist/{middleware-C2c1rlmE.mjs → middleware-CgSiHODB.mjs} +1 -1
  40. package/dist/{middleware-8P6Z15Wq.cjs → middleware-DSO3rlFW.cjs} +1 -1
  41. package/dist/{middleware-DFcgN1cH.cjs → middleware-DtWhE0Tg.cjs} +4 -4
  42. package/dist/{mod-CnwZoDzx.d.ts → mod-2wk2xVOZ.d.cts} +2 -3
  43. package/dist/{mod-B505FZBC.d.cts → mod-BTWFtZwa.d.ts} +4 -3
  44. package/dist/{mod-DoJBjjnO.d.cts → mod-CjiK2zrW.d.ts} +3 -2
  45. package/dist/{mod-DvxszxXC.d.ts → mod-D5YlzzP3.d.cts} +3 -4
  46. package/dist/{mod-Cgpc49fA.d.cts → mod-VlzkKTxt.d.ts} +2 -1
  47. package/dist/{mod-D7PAuO6k.d.ts → mod-dxOnKp2Y.d.cts} +4 -5
  48. package/dist/mod.cjs +4 -4
  49. package/dist/mod.d.cts +9 -8
  50. package/dist/mod.d.ts +9 -10
  51. package/dist/mod.js +9 -9
  52. package/dist/nodeinfo/handler.test.mjs +1 -1
  53. package/dist/nodeinfo/mod.d.cts +2 -1
  54. package/dist/nodeinfo/mod.d.ts +2 -3
  55. package/dist/nodeinfo/mod.js +3 -3
  56. package/dist/otel/mod.d.cts +2 -1
  57. package/dist/otel/mod.d.ts +2 -3
  58. package/dist/otel/mod.js +2 -2
  59. package/dist/{owner-CptqhsOy.d.cts → owner-CnngXDNJ.d.ts} +2 -1
  60. package/dist/{owner-74ARJ5TL.d.ts → owner-DEvZuyOE.d.cts} +2 -3
  61. package/dist/{owner-BceqCVOs.mjs → owner-DHom_kgS.mjs} +2 -2
  62. package/dist/{proof-4NUQlbQV.js → proof-BGeouI6o.js} +2 -2
  63. package/dist/{proof-BojC8L94.mjs → proof-CXFgG-c1.mjs} +2 -2
  64. package/dist/{proof-kuTIVfyZ.cjs → proof-vA6FYR0I.cjs} +1 -1
  65. package/dist/runtime/mod.d.cts +1 -0
  66. package/dist/runtime/mod.d.ts +1 -2
  67. package/dist/runtime/mod.js +3 -3
  68. package/dist/{send-Buz5Gy8x.mjs → send-CPt5iQJ5.mjs} +2 -2
  69. package/dist/sig/http.test.mjs +120 -2
  70. package/dist/sig/key.test.mjs +1 -1
  71. package/dist/sig/ld.test.mjs +2 -2
  72. package/dist/sig/mod.cjs +2 -2
  73. package/dist/sig/mod.d.cts +4 -3
  74. package/dist/sig/mod.d.ts +4 -5
  75. package/dist/sig/mod.js +4 -4
  76. package/dist/sig/owner.test.mjs +1 -1
  77. package/dist/sig/proof.test.mjs +1 -1
  78. package/dist/{transformers-ve6e2xcg.js → transformers-BGMIq1cs.js} +2 -2
  79. package/dist/{types-hvL8ElAs.js → types-CAY3OdLq.js} +2 -2
  80. package/dist/utils/docloader.test.mjs +2 -2
  81. package/dist/utils/kv-cache.test.mjs +1 -1
  82. package/dist/utils/mod.cjs +1 -1
  83. package/dist/utils/mod.d.cts +2 -1
  84. package/dist/utils/mod.d.ts +2 -3
  85. package/dist/utils/mod.js +3 -3
  86. package/dist/vocab/mod.d.cts +1 -0
  87. package/dist/vocab/mod.d.ts +1 -2
  88. package/dist/vocab/mod.js +2 -2
  89. package/package.json +6 -6
@@ -2,8 +2,8 @@ import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { n as RouterError, t as Router } from "./router-CrMLXoOr.mjs";
5
- import { n as version, t as name } from "./deno-Ddb3P7G7.mjs";
6
- import { t as InboxListenerSet } from "./inbox-DTuPJEma.mjs";
5
+ import { n as version, t as name } from "./deno-DsYpa8eE.mjs";
6
+ import { t as InboxListenerSet } from "./inbox-Fz4Sd_YF.mjs";
7
7
  import { getTypeId } from "@fedify/vocab";
8
8
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
9
9
  import { getLogger } from "@logtape/logtape";
@@ -43,7 +43,7 @@ var FederationBuilderImpl = class {
43
43
  this.collectionTypeIds = {};
44
44
  }
45
45
  async build(options) {
46
- const { FederationImpl } = await import("./middleware-C2c1rlmE.mjs");
46
+ const { FederationImpl } = await import("./middleware-CgSiHODB.mjs");
47
47
  const f = new FederationImpl(options);
48
48
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
49
49
  f.router = this.router.clone();
@@ -1,5 +1,5 @@
1
- import "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
3
  //#region \0rolldown/runtime.js
4
4
  var __defProp = Object.defineProperty;
5
5
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -1,3 +1,4 @@
1
+ /// <reference lib="esnext.temporal" />
1
2
  import { GetUserAgentOptions } from "@fedify/vocab-runtime";
2
3
 
3
4
  //#region src/nodeinfo/types.d.ts
@@ -1,5 +1,4 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
1
+ /// <reference lib="esnext.temporal" />
3
2
  import { GetUserAgentOptions } from "@fedify/vocab-runtime";
4
3
 
5
4
  //#region src/nodeinfo/types.d.ts
@@ -1,4 +1,5 @@
1
- import { Ct as ActivityTransformer, n as Context } from "../context-LmrZPwti.cjs";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { Ct as ActivityTransformer, n as Context } from "../context-BUEOz39K.cjs";
2
3
  import { Activity } from "@fedify/vocab";
3
4
 
4
5
  //#region src/compat/transformers.d.ts
@@ -1,6 +1,5 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
- import { Ct as ActivityTransformer, n as Context } from "../context-C0fssarc.js";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { Ct as ActivityTransformer, n as Context } from "../context-CqlKdpQu.js";
4
3
  import { Activity } from "@fedify/vocab";
5
4
 
6
5
  //#region src/compat/transformers.d.ts
@@ -1,4 +1,4 @@
1
- import "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
3
- import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "../transformers-ve6e2xcg.js";
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
+ import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "../transformers-BGMIq1cs.js";
4
4
  export { actorDehydrator, autoIdAssigner, getDefaultActivityTransformers };
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
6
6
  import { t as assert } from "../assert-ddO5KLpe.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
8
- import { _ as autoIdAssigner, g as actorDehydrator, n as FederationImpl } from "../middleware-DDsnRvFC.mjs";
8
+ import { _ as autoIdAssigner, g as actorDehydrator, n as FederationImpl } from "../middleware-BwUi2CSK.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  import { Follow, Person } from "@fedify/vocab";
11
11
  //#region src/compat/transformers.test.ts
@@ -1,13 +1,12 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
- import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-AtlibPOU.js";
4
- import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-aQzN9Ayi.js";
5
- import { n as GetKeyOwnerOptions } from "./owner-74ARJ5TL.js";
6
- import { n as KvStore, t as KvKey } from "./kv-GFYnFoOl.js";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-CAM_bQXx.cjs";
3
+ import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-C87EWkO0.cjs";
4
+ import { n as GetKeyOwnerOptions } from "./owner-DEvZuyOE.cjs";
5
+ import { n as KvStore, t as KvKey } from "./kv-gJ8LYbxX.cjs";
7
6
  import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, TraverseCollectionOptions } from "@fedify/vocab";
8
- import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
9
7
  import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
10
8
  import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
9
+ import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
11
10
 
12
11
  //#region src/compat/types.d.ts
13
12
  /**
@@ -1,11 +1,12 @@
1
- import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-z-8dc-e1.cjs";
2
- import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-CrGuipxe.cjs";
3
- import { n as GetKeyOwnerOptions } from "./owner-CptqhsOy.cjs";
4
- import { n as KvStore, t as KvKey } from "./kv-CbLNp3zQ.cjs";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-CSddvgWN.js";
3
+ import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-BDZeS5om.js";
4
+ import { n as GetKeyOwnerOptions } from "./owner-CnngXDNJ.js";
5
+ import { n as KvStore, t as KvKey } from "./kv-D6hNiMTK.js";
5
6
  import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, TraverseCollectionOptions } from "@fedify/vocab";
7
+ import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
6
8
  import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
7
9
  import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
8
- import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
9
10
 
10
11
  //#region src/compat/types.d.ts
11
12
  /**
@@ -3,6 +3,6 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  //#region deno.json
5
5
  var name = "@fedify/fedify";
6
- var version = "2.1.12";
6
+ var version = "2.1.13";
7
7
  //#endregion
8
8
  export { version as n, name as t };
@@ -1,8 +1,8 @@
1
1
  import "@js-temporal/polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { o as validateCryptoKey } from "./key-WSedbAA-.mjs";
5
- import { n as doubleKnock } from "./http-DRDpStn2.mjs";
4
+ import { o as validateCryptoKey } from "./key-BTwUWGeQ.mjs";
5
+ import { n as doubleKnock } from "./http-sMWapA1W.mjs";
6
6
  import { curry } from "es-toolkit";
7
7
  import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
8
8
  import { getLogger } from "@logtape/logtape";
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import { a as assertExists } from "../std__assert-Duiq_YC9.mjs";
6
6
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
8
- import { n as createFederationBuilder } from "../builder-D9hlyCx5.mjs";
8
+ import { n as createFederationBuilder } from "../builder-BII9kySt.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  import { Activity, Note, Person } from "@fedify/vocab";
11
11
  //#region src/federation/builder.test.ts
@@ -6,11 +6,11 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-Duiq_YC9.mjs";
7
7
  import { t as assert } from "../assert-ddO5KLpe.mjs";
8
8
  import { r as parseAcceptSignature } from "../accept-Dd__NiUL.mjs";
9
- import { s as signRequest } from "../http-DRDpStn2.mjs";
9
+ import { s as signRequest } from "../http-sMWapA1W.mjs";
10
10
  import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
11
11
  import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
12
- 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-DDsnRvFC.mjs";
13
- import { t as InboxListenerSet } from "../inbox-DTuPJEma.mjs";
12
+ 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-BwUi2CSK.mjs";
13
+ import { t as InboxListenerSet } from "../inbox-Fz4Sd_YF.mjs";
14
14
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
15
15
  import { Create, Note, Person } from "@fedify/vocab";
16
16
  import { FetchError } from "@fedify/vocab-runtime";
@@ -4,9 +4,9 @@ globalThis.addEventListener = () => {};
4
4
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
5
5
  import "../std__assert-Duiq_YC9.mjs";
6
6
  import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
7
- import { n as signObject } from "../proof-BojC8L94.mjs";
7
+ import { n as signObject } from "../proof-CXFgG-c1.mjs";
8
8
  import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
9
- import { a as createFederation } from "../middleware-DDsnRvFC.mjs";
9
+ import { a as createFederation } from "../middleware-BwUi2CSK.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 { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
6
- import { t as InboxListenerSet } from "../inbox-DTuPJEma.mjs";
6
+ import { t as InboxListenerSet } from "../inbox-Fz4Sd_YF.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
@@ -10,14 +10,14 @@ import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
10
10
  import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
11
11
  import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
12
12
  import { t as assert } from "../assert-ddO5KLpe.mjs";
13
- import { l as verifyRequest, s as signRequest } from "../http-DRDpStn2.mjs";
13
+ import { l as verifyRequest, s as signRequest } from "../http-sMWapA1W.mjs";
14
14
  import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
15
- import { t as getAuthenticatedDocumentLoader } from "../docloader-CK8tewt1.mjs";
16
- import { a as signJsonLd, o as verifyJsonLd, r as detachSignature } from "../ld-OBpaLfHR.mjs";
17
- import { t as doesActorOwnKey } from "../owner-BceqCVOs.mjs";
18
- import { n as signObject, r as verifyObject } from "../proof-BojC8L94.mjs";
15
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-SiTy_uEf.mjs";
16
+ import { a as signJsonLd, o as verifyJsonLd, r as detachSignature } from "../ld--_e4kYb3.mjs";
17
+ import { t as doesActorOwnKey } from "../owner-DHom_kgS.mjs";
18
+ import { n as signObject, r as verifyObject } from "../proof-CXFgG-c1.mjs";
19
19
  import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
20
- import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-DDsnRvFC.mjs";
20
+ import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-BwUi2CSK.mjs";
21
21
  import { mockDocumentLoader, test } from "@fedify/fixture";
22
22
  import * as vocab from "@fedify/vocab";
23
23
  import { getTypeId, lookupObject } from "@fedify/vocab";
@@ -2,7 +2,7 @@ const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
4
  require("../chunk-DDcVe30Y.cjs");
5
- const require_middleware = require("../middleware-DFcgN1cH.cjs");
5
+ const require_middleware = require("../middleware-DtWhE0Tg.cjs");
6
6
  let es_toolkit = require("es-toolkit");
7
7
  //#region src/federation/kv.ts
8
8
  /**
@@ -1,4 +1,5 @@
1
- import { $ as ActorKeyPairsDispatcher, A as createFederation, B as RouterRouteResult, C as InboxChallengePolicy, D as FederationKvPrefixes, E as Rfc6570Expression, F as Message, G as InProcessMessageQueueOptions, H as respondWithObject, I as createFederationBuilder, J as MessageQueueListenOptions, K as MessageQueue, L as Router, M as RetryContext, N as RetryPolicy, O as FederationOrigin, P as createExponentialBackoffPolicy, Q as ActorHandleMapper, R as RouterError, S as IdempotencyStrategy, St as digest, T as ObjectCallbackSetters, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as InProcessMessageQueue, X as ActorAliasMapper, Y as ParallelMessageQueue, Z as ActorDispatcher, _ as FederationBuilder, _t as WebFingerLinksDispatcher, a as InboxContext, at as CustomCollectionCursor, b as FederationStartQueueOptions, bt as PageItems, c as RouteActivityOptions, ct as InboxListener, d as ActorCallbackSetters, dt as ObjectDispatcher, et as AuthorizePredicate, f as CollectionCallbackSetters, ft as OutboxErrorHandler, g as Federation, gt as UnverifiedActivityReason, h as Federatable, ht as UnverifiedActivityHandler, i as GetSignedKeyOptions, it as CustomCollectionCounter, j as CreateExponentialBackoffPolicyOptions, k as FederationQueueOptions, l as SendActivityOptions, lt as NodeInfoDispatcher, m as CustomCollectionCallbackSetters, mt as SharedInboxKeyDispatcher, n as Context, nt as CollectionCursor, o as ParseUriResult, ot as CustomCollectionDispatcher, p as ConstructorWithTypeId, pt as OutboxPermanentFailureHandler, q as MessageQueueEnqueueOptions, r as ForwardActivityOptions, rt as CollectionDispatcher, s as RequestContext, st as InboxErrorHandler, t as ActorKeyPair, tt as CollectionCounter, u as SendActivityOptionsForCollection, ut as ObjectAuthorizePredicate, v as FederationFetchOptions, vt as SendActivityError, w as InboxListenerSetters, x as IdempotencyKeyCallback, xt as buildCollectionSynchronizationHeader, y as FederationOptions, yt as SenderKeyPair, z as RouterOptions } from "../context-LmrZPwti.cjs";
2
- import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-CbLNp3zQ.cjs";
3
- import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-Cgpc49fA.cjs";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { $ as ActorKeyPairsDispatcher, A as createFederation, B as RouterRouteResult, C as InboxChallengePolicy, D as FederationKvPrefixes, E as Rfc6570Expression, F as Message, G as InProcessMessageQueueOptions, H as respondWithObject, I as createFederationBuilder, J as MessageQueueListenOptions, K as MessageQueue, L as Router, M as RetryContext, N as RetryPolicy, O as FederationOrigin, P as createExponentialBackoffPolicy, Q as ActorHandleMapper, R as RouterError, S as IdempotencyStrategy, St as digest, T as ObjectCallbackSetters, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as InProcessMessageQueue, X as ActorAliasMapper, Y as ParallelMessageQueue, Z as ActorDispatcher, _ as FederationBuilder, _t as WebFingerLinksDispatcher, a as InboxContext, at as CustomCollectionCursor, b as FederationStartQueueOptions, bt as PageItems, c as RouteActivityOptions, ct as InboxListener, d as ActorCallbackSetters, dt as ObjectDispatcher, et as AuthorizePredicate, f as CollectionCallbackSetters, ft as OutboxErrorHandler, g as Federation, gt as UnverifiedActivityReason, h as Federatable, ht as UnverifiedActivityHandler, i as GetSignedKeyOptions, it as CustomCollectionCounter, j as CreateExponentialBackoffPolicyOptions, k as FederationQueueOptions, l as SendActivityOptions, lt as NodeInfoDispatcher, m as CustomCollectionCallbackSetters, mt as SharedInboxKeyDispatcher, n as Context, nt as CollectionCursor, o as ParseUriResult, ot as CustomCollectionDispatcher, p as ConstructorWithTypeId, pt as OutboxPermanentFailureHandler, q as MessageQueueEnqueueOptions, r as ForwardActivityOptions, rt as CollectionDispatcher, s as RequestContext, st as InboxErrorHandler, t as ActorKeyPair, tt as CollectionCounter, u as SendActivityOptionsForCollection, ut as ObjectAuthorizePredicate, v as FederationFetchOptions, vt as SendActivityError, w as InboxListenerSetters, x as IdempotencyKeyCallback, xt as buildCollectionSynchronizationHeader, y as FederationOptions, yt as SenderKeyPair, z as RouterOptions } from "../context-BUEOz39K.cjs";
3
+ import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-gJ8LYbxX.cjs";
4
+ import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-2wk2xVOZ.cjs";
4
5
  export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,6 +1,5 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
3
- import { $ as ActorKeyPairsDispatcher, A as createFederation, B as RouterRouteResult, C as InboxChallengePolicy, D as FederationKvPrefixes, E as Rfc6570Expression, F as Message, G as InProcessMessageQueueOptions, H as respondWithObject, I as createFederationBuilder, J as MessageQueueListenOptions, K as MessageQueue, L as Router, M as RetryContext, N as RetryPolicy, O as FederationOrigin, P as createExponentialBackoffPolicy, Q as ActorHandleMapper, R as RouterError, S as IdempotencyStrategy, St as digest, T as ObjectCallbackSetters, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as InProcessMessageQueue, X as ActorAliasMapper, Y as ParallelMessageQueue, Z as ActorDispatcher, _ as FederationBuilder, _t as WebFingerLinksDispatcher, a as InboxContext, at as CustomCollectionCursor, b as FederationStartQueueOptions, bt as PageItems, c as RouteActivityOptions, ct as InboxListener, d as ActorCallbackSetters, dt as ObjectDispatcher, et as AuthorizePredicate, f as CollectionCallbackSetters, ft as OutboxErrorHandler, g as Federation, gt as UnverifiedActivityReason, h as Federatable, ht as UnverifiedActivityHandler, i as GetSignedKeyOptions, it as CustomCollectionCounter, j as CreateExponentialBackoffPolicyOptions, k as FederationQueueOptions, l as SendActivityOptions, lt as NodeInfoDispatcher, m as CustomCollectionCallbackSetters, mt as SharedInboxKeyDispatcher, n as Context, nt as CollectionCursor, o as ParseUriResult, ot as CustomCollectionDispatcher, p as ConstructorWithTypeId, pt as OutboxPermanentFailureHandler, q as MessageQueueEnqueueOptions, r as ForwardActivityOptions, rt as CollectionDispatcher, s as RequestContext, st as InboxErrorHandler, t as ActorKeyPair, tt as CollectionCounter, u as SendActivityOptionsForCollection, ut as ObjectAuthorizePredicate, v as FederationFetchOptions, vt as SendActivityError, w as InboxListenerSetters, x as IdempotencyKeyCallback, xt as buildCollectionSynchronizationHeader, y as FederationOptions, yt as SenderKeyPair, z as RouterOptions } from "../context-C0fssarc.js";
4
- import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-GFYnFoOl.js";
5
- import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-CnwZoDzx.js";
1
+ /// <reference lib="esnext.temporal" />
2
+ import { $ as ActorKeyPairsDispatcher, A as createFederation, B as RouterRouteResult, C as InboxChallengePolicy, D as FederationKvPrefixes, E as Rfc6570Expression, F as Message, G as InProcessMessageQueueOptions, H as respondWithObject, I as createFederationBuilder, J as MessageQueueListenOptions, K as MessageQueue, L as Router, M as RetryContext, N as RetryPolicy, O as FederationOrigin, P as createExponentialBackoffPolicy, Q as ActorHandleMapper, R as RouterError, S as IdempotencyStrategy, St as digest, T as ObjectCallbackSetters, U as respondWithObjectIfAcceptable, V as RespondWithObjectOptions, W as InProcessMessageQueue, X as ActorAliasMapper, Y as ParallelMessageQueue, Z as ActorDispatcher, _ as FederationBuilder, _t as WebFingerLinksDispatcher, a as InboxContext, at as CustomCollectionCursor, b as FederationStartQueueOptions, bt as PageItems, c as RouteActivityOptions, ct as InboxListener, d as ActorCallbackSetters, dt as ObjectDispatcher, et as AuthorizePredicate, f as CollectionCallbackSetters, ft as OutboxErrorHandler, g as Federation, gt as UnverifiedActivityReason, h as Federatable, ht as UnverifiedActivityHandler, i as GetSignedKeyOptions, it as CustomCollectionCounter, j as CreateExponentialBackoffPolicyOptions, k as FederationQueueOptions, l as SendActivityOptions, lt as NodeInfoDispatcher, m as CustomCollectionCallbackSetters, mt as SharedInboxKeyDispatcher, n as Context, nt as CollectionCursor, o as ParseUriResult, ot as CustomCollectionDispatcher, p as ConstructorWithTypeId, pt as OutboxPermanentFailureHandler, q as MessageQueueEnqueueOptions, r as ForwardActivityOptions, rt as CollectionDispatcher, s as RequestContext, st as InboxErrorHandler, t as ActorKeyPair, tt as CollectionCounter, u as SendActivityOptionsForCollection, ut as ObjectAuthorizePredicate, v as FederationFetchOptions, vt as SendActivityError, w as InboxListenerSetters, x as IdempotencyKeyCallback, xt as buildCollectionSynchronizationHeader, y as FederationOptions, yt as SenderKeyPair, z as RouterOptions } from "../context-CqlKdpQu.js";
3
+ import { a as MemoryKvStore, i as KvStoreSetOptions, n as KvStore, r as KvStoreListEntry, t as KvKey } from "../kv-D6hNiMTK.js";
4
+ import { n as handleWebFinger, t as WebFingerHandlerParameters } from "../mod-VlzkKTxt.js";
6
5
  export { ActorAliasMapper, ActorCallbackSetters, ActorDispatcher, ActorHandleMapper, ActorKeyPair, ActorKeyPairsDispatcher, AuthorizePredicate, CollectionCallbackSetters, CollectionCounter, CollectionCursor, CollectionDispatcher, ConstructorWithTypeId, Context, CreateExponentialBackoffPolicyOptions, CustomCollectionCallbackSetters, CustomCollectionCounter, CustomCollectionCursor, CustomCollectionDispatcher, Federatable, Federation, FederationBuilder, FederationFetchOptions, FederationKvPrefixes, FederationOptions, FederationOrigin, FederationQueueOptions, FederationStartQueueOptions, ForwardActivityOptions, GetSignedKeyOptions, IdempotencyKeyCallback, IdempotencyStrategy, InProcessMessageQueue, InProcessMessageQueueOptions, InboxChallengePolicy, InboxContext, InboxErrorHandler, InboxListener, InboxListenerSetters, KvKey, KvStore, KvStoreListEntry, KvStoreSetOptions, MemoryKvStore, Message, MessageQueue, MessageQueueEnqueueOptions, MessageQueueListenOptions, NodeInfoDispatcher, ObjectAuthorizePredicate, ObjectCallbackSetters, ObjectDispatcher, OutboxErrorHandler, OutboxPermanentFailureHandler, PageItems, ParallelMessageQueue, ParseUriResult, RequestContext, RespondWithObjectOptions, RetryContext, RetryPolicy, Rfc6570Expression, RouteActivityOptions, Router, RouterError, RouterOptions, RouterRouteResult, SendActivityError, SendActivityOptions, SendActivityOptionsForCollection, SenderKeyPair, SharedInboxKeyDispatcher, UnverifiedActivityHandler, UnverifiedActivityReason, WebFingerHandlerParameters, WebFingerLinksDispatcher, buildCollectionSynchronizationHeader, createExponentialBackoffPolicy, createFederation, createFederationBuilder, digest, handleWebFinger, respondWithObject, respondWithObjectIfAcceptable };
@@ -1,6 +1,6 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
3
- import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-UThUK30x.js";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
+ import { a as createExponentialBackoffPolicy, c as buildCollectionSynchronizationHeader, d as Router, f as RouterError, i as SendActivityError, l as digest, o as respondWithObject, r as handleWebFinger, s as respondWithObjectIfAcceptable, t as createFederation, u as createFederationBuilder } from "../middleware-BmExpfep.js";
4
4
  import { isEqual } from "es-toolkit";
5
5
  //#region src/federation/kv.ts
6
6
  /**
@@ -8,10 +8,10 @@ import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z
8
8
  import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
9
9
  import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
10
10
  import { t as assert } from "../assert-ddO5KLpe.mjs";
11
- import { l as verifyRequest } from "../http-DRDpStn2.mjs";
11
+ import { l as verifyRequest } from "../http-sMWapA1W.mjs";
12
12
  import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
13
- import { t as doesActorOwnKey } from "../owner-BceqCVOs.mjs";
14
- import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-Buz5Gy8x.mjs";
13
+ import { t as doesActorOwnKey } from "../owner-DHom_kgS.mjs";
14
+ import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-CPt5iQJ5.mjs";
15
15
  import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
16
16
  import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
17
17
  //#region src/federation/send.test.ts
@@ -5,7 +5,7 @@ import { n as createRequestContext } from "../context-Juj6bdHC.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
6
6
  import "../std__assert-Duiq_YC9.mjs";
7
7
  import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
8
- import { a as createFederation, o as handleWebFinger } from "../middleware-DDsnRvFC.mjs";
8
+ import { a as createFederation, o as handleWebFinger } from "../middleware-BwUi2CSK.mjs";
9
9
  import { test } from "@fedify/fixture";
10
10
  import { Image, Link, Person } from "@fedify/vocab";
11
11
  //#region src/federation/webfinger.test.ts
@@ -1,6 +1,7 @@
1
+ /// <reference lib="esnext.temporal" />
1
2
  import { CryptographicKey, Multikey } from "@fedify/vocab";
2
- import { DocumentLoader } from "@fedify/vocab-runtime";
3
3
  import { TracerProvider } from "@opentelemetry/api";
4
+ import { DocumentLoader } from "@fedify/vocab-runtime";
4
5
 
5
6
  //#region src/sig/key.d.ts
6
7
  /**
@@ -1,5 +1,5 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
- import "urlpattern-polyfill";
2
+ import { URLPattern } from "urlpattern-polyfill";
3
3
  import { getLogger } from "@logtape/logtape";
4
4
  import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
5
5
  import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
@@ -10,7 +10,7 @@ import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } fro
10
10
  import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
11
11
  //#region deno.json
12
12
  var name = "@fedify/fedify";
13
- var version = "2.1.12";
13
+ var version = "2.1.13";
14
14
  //#endregion
15
15
  //#region src/sig/accept.ts
16
16
  /**
@@ -496,6 +496,7 @@ async function fetchKeyInternal(keyId, cls, options = {}) {
496
496
  //#endregion
497
497
  //#region src/sig/http.ts
498
498
  const DEFAULT_MAX_REDIRECTION = 20;
499
+ const DOUBLE_KNOCK_TRANSPORT_RETRY_DELAY_MS = 100;
499
500
  /**
500
501
  * Signs a request using the given private key.
501
502
  * @param request The request to sign.
@@ -1324,6 +1325,59 @@ function createRedirectRequest(request, location, body) {
1324
1325
  cache: request.cache
1325
1326
  });
1326
1327
  }
1328
+ async function fetchDoubleKnockRequest(request, signedRequest, signal) {
1329
+ const maxAttempts = request.method === "GET" || request.method === "HEAD" ? 2 : 1;
1330
+ for (let attempt = 1;; attempt++) try {
1331
+ return await fetch(signedRequest, {
1332
+ redirect: "manual",
1333
+ signal
1334
+ });
1335
+ } catch (error) {
1336
+ const abortedSignal = getAbortedSignal(signal, request.signal, signedRequest.signal);
1337
+ if (abortedSignal != null) throw getAbortReason(abortedSignal);
1338
+ if (isAbortError(error)) throw error;
1339
+ if (attempt >= maxAttempts) throw createFetchError(request.url, error);
1340
+ await sleep(DOUBLE_KNOCK_TRANSPORT_RETRY_DELAY_MS, signal, request.signal, signedRequest.signal);
1341
+ }
1342
+ }
1343
+ function createFetchError(url, cause) {
1344
+ const error = new FetchError(url, cause instanceof Error ? cause.message : String(cause));
1345
+ error.cause = cause;
1346
+ return error;
1347
+ }
1348
+ function isAbortError(error) {
1349
+ return error instanceof Error && error.name === "AbortError";
1350
+ }
1351
+ async function sleep(ms, ...signals) {
1352
+ const abortSignals = signals.filter((signal) => signal != null);
1353
+ const abortedSignal = getAbortedSignal(...abortSignals);
1354
+ if (abortedSignal != null) throw getAbortReason(abortedSignal);
1355
+ if (abortSignals.length < 1) {
1356
+ await new Promise((resolve) => setTimeout(resolve, ms));
1357
+ return;
1358
+ }
1359
+ await new Promise((resolve, reject) => {
1360
+ const removeAbortListeners = () => {
1361
+ for (const signal of abortSignals) signal.removeEventListener("abort", handleAbort);
1362
+ };
1363
+ const timeout = setTimeout(() => {
1364
+ removeAbortListeners();
1365
+ resolve();
1366
+ }, ms);
1367
+ function handleAbort(event) {
1368
+ clearTimeout(timeout);
1369
+ removeAbortListeners();
1370
+ reject(getAbortReason(event.currentTarget));
1371
+ }
1372
+ for (const signal of abortSignals) signal.addEventListener("abort", handleAbort, { once: true });
1373
+ });
1374
+ }
1375
+ function getAbortedSignal(...signals) {
1376
+ return signals.find((signal) => signal?.aborted);
1377
+ }
1378
+ function getAbortReason(signal) {
1379
+ return signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
1380
+ }
1327
1381
  /**
1328
1382
  * Performs a double-knock request to the given URL. For the details of
1329
1383
  * double-knocking, see
@@ -1349,10 +1403,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
1349
1403
  body
1350
1404
  });
1351
1405
  log?.(signedRequest);
1352
- let response = await fetch(signedRequest, {
1353
- redirect: "manual",
1354
- signal
1355
- });
1406
+ let response = await fetchDoubleKnockRequest(request, signedRequest, signal);
1356
1407
  if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
1357
1408
  if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
1358
1409
  const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
@@ -1427,10 +1478,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
1427
1478
  body
1428
1479
  });
1429
1480
  log?.(signedRequest);
1430
- response = await fetch(signedRequest, {
1431
- redirect: "manual",
1432
- signal
1433
- });
1481
+ response = await fetchDoubleKnockRequest(request, signedRequest, signal);
1434
1482
  if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
1435
1483
  if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
1436
1484
  const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
@@ -1,8 +1,7 @@
1
- import { Temporal } from "@js-temporal/polyfill";
2
- import { URLPattern } from "urlpattern-polyfill";
1
+ /// <reference lib="esnext.temporal" />
3
2
  import { CryptographicKey, Multikey } from "@fedify/vocab";
4
- import { TracerProvider } from "@opentelemetry/api";
5
3
  import { DocumentLoader } from "@fedify/vocab-runtime";
4
+ import { TracerProvider } from "@opentelemetry/api";
6
5
 
7
6
  //#region src/sig/key.d.ts
8
7
  /**
@@ -11,7 +11,7 @@ let _opentelemetry_semantic_conventions = require("@opentelemetry/semantic-conve
11
11
  let byte_encodings_base64 = require("byte-encodings/base64");
12
12
  //#region deno.json
13
13
  var name = "@fedify/fedify";
14
- var version = "2.1.12";
14
+ var version = "2.1.13";
15
15
  //#endregion
16
16
  //#region src/sig/accept.ts
17
17
  /**
@@ -497,6 +497,7 @@ async function fetchKeyInternal(keyId, cls, options = {}) {
497
497
  //#endregion
498
498
  //#region src/sig/http.ts
499
499
  const DEFAULT_MAX_REDIRECTION = 20;
500
+ const DOUBLE_KNOCK_TRANSPORT_RETRY_DELAY_MS = 100;
500
501
  /**
501
502
  * Signs a request using the given private key.
502
503
  * @param request The request to sign.
@@ -1325,6 +1326,59 @@ function createRedirectRequest(request, location, body) {
1325
1326
  cache: request.cache
1326
1327
  });
1327
1328
  }
1329
+ async function fetchDoubleKnockRequest(request, signedRequest, signal) {
1330
+ const maxAttempts = request.method === "GET" || request.method === "HEAD" ? 2 : 1;
1331
+ for (let attempt = 1;; attempt++) try {
1332
+ return await fetch(signedRequest, {
1333
+ redirect: "manual",
1334
+ signal
1335
+ });
1336
+ } catch (error) {
1337
+ const abortedSignal = getAbortedSignal(signal, request.signal, signedRequest.signal);
1338
+ if (abortedSignal != null) throw getAbortReason(abortedSignal);
1339
+ if (isAbortError(error)) throw error;
1340
+ if (attempt >= maxAttempts) throw createFetchError(request.url, error);
1341
+ await sleep(DOUBLE_KNOCK_TRANSPORT_RETRY_DELAY_MS, signal, request.signal, signedRequest.signal);
1342
+ }
1343
+ }
1344
+ function createFetchError(url, cause) {
1345
+ const error = new _fedify_vocab_runtime.FetchError(url, cause instanceof Error ? cause.message : String(cause));
1346
+ error.cause = cause;
1347
+ return error;
1348
+ }
1349
+ function isAbortError(error) {
1350
+ return error instanceof Error && error.name === "AbortError";
1351
+ }
1352
+ async function sleep(ms, ...signals) {
1353
+ const abortSignals = signals.filter((signal) => signal != null);
1354
+ const abortedSignal = getAbortedSignal(...abortSignals);
1355
+ if (abortedSignal != null) throw getAbortReason(abortedSignal);
1356
+ if (abortSignals.length < 1) {
1357
+ await new Promise((resolve) => setTimeout(resolve, ms));
1358
+ return;
1359
+ }
1360
+ await new Promise((resolve, reject) => {
1361
+ const removeAbortListeners = () => {
1362
+ for (const signal of abortSignals) signal.removeEventListener("abort", handleAbort);
1363
+ };
1364
+ const timeout = setTimeout(() => {
1365
+ removeAbortListeners();
1366
+ resolve();
1367
+ }, ms);
1368
+ function handleAbort(event) {
1369
+ clearTimeout(timeout);
1370
+ removeAbortListeners();
1371
+ reject(getAbortReason(event.currentTarget));
1372
+ }
1373
+ for (const signal of abortSignals) signal.addEventListener("abort", handleAbort, { once: true });
1374
+ });
1375
+ }
1376
+ function getAbortedSignal(...signals) {
1377
+ return signals.find((signal) => signal?.aborted);
1378
+ }
1379
+ function getAbortReason(signal) {
1380
+ return signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
1381
+ }
1328
1382
  /**
1329
1383
  * Performs a double-knock request to the given URL. For the details of
1330
1384
  * double-knocking, see
@@ -1350,10 +1404,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
1350
1404
  body
1351
1405
  });
1352
1406
  log?.(signedRequest);
1353
- let response = await fetch(signedRequest, {
1354
- redirect: "manual",
1355
- signal
1356
- });
1407
+ let response = await fetchDoubleKnockRequest(request, signedRequest, signal);
1357
1408
  if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
1358
1409
  if (redirected >= DEFAULT_MAX_REDIRECTION) throw new _fedify_vocab_runtime.FetchError(request.url, `Too many redirections (${redirected + 1})`);
1359
1410
  const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
@@ -1428,10 +1479,7 @@ async function doubleKnockInternal(request, identity, options, redirected = 0, v
1428
1479
  body
1429
1480
  });
1430
1481
  log?.(signedRequest);
1431
- response = await fetch(signedRequest, {
1432
- redirect: "manual",
1433
- signal
1434
- });
1482
+ response = await fetchDoubleKnockRequest(request, signedRequest, signal);
1435
1483
  if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
1436
1484
  if (redirected >= DEFAULT_MAX_REDIRECTION) throw new _fedify_vocab_runtime.FetchError(request.url, `Too many redirections (${redirected + 1})`);
1437
1485
  const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);