@fedify/fedify 2.2.18 → 2.2.20
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{builder-DAbQyxmb.mjs → builder-BolQ56ab.mjs} +2 -2
- package/dist/{client-CAM_bQXx.d.cts → client-BIBzqEIp.d.cts} +0 -1
- package/dist/{client-9F_u23dc.mjs → client-DhxaVgOv.mjs} +113 -64
- package/dist/{client-CSddvgWN.d.ts → client-jE7oGvRh.d.ts} +0 -1
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{context-tJbL_Hkw.d.cts → context-CFQGaq5x.d.cts} +28 -2
- package/dist/{context-OkwEpc3-.d.ts → context-DdbLVV_k.d.ts} +28 -2
- package/dist/{deno-JUTr6LYC.mjs → deno-BUj4roJc.mjs} +1 -1
- package/dist/docloader-CbtF_0cD.mjs +125 -0
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +5 -5
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/keycache.test.mjs +18 -7
- package/dist/federation/middleware.test.mjs +389 -28
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +1 -1
- package/dist/federation/send.test.mjs +445 -70
- package/dist/federation/temporal.test.mjs +1 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{http-Dl00HXr4.d.ts → http-9IFUxdkp.d.cts} +1 -2
- package/dist/{http-OSYYhKM8.js → http-C5g_VrA_.js} +188 -105
- package/dist/{http-lCmKCZBI.mjs → http-CQMVisM0.mjs} +195 -97
- package/dist/{http-DEH_eppX.cjs → http-D8I7LBfx.cjs} +189 -106
- package/dist/{http-DqZhyEso.d.cts → http-SbfezERn.d.ts} +1 -2
- package/dist/{inbox-DMATfdEI.mjs → inbox-CD8IDILN.mjs} +1 -1
- package/dist/{key-D0ahOVjf.mjs → key-C3o3DGap.mjs} +17 -3
- package/dist/{keycache-Dkc_sflV.mjs → keycache-BimEQucx.mjs} +1 -1
- package/dist/{kv-cache-B7X4p1y7.js → kv-cache-CSKXXleR.js} +60 -16
- package/dist/{kv-cache-CPEV_4nZ.cjs → kv-cache-DC9LcfoC.cjs} +59 -15
- package/dist/{ld-CJOXIehz.mjs → ld-ijSr-0AB.mjs} +2 -2
- package/dist/{middleware-CHoUjmJm.mjs → middleware-CYAaUTi5.mjs} +79 -39
- package/dist/{middleware-QcuVRA-q.cjs → middleware-DNueR0GD.cjs} +185 -60
- package/dist/{middleware-D3hx1aiI.cjs → middleware-DmcY2TWS.cjs} +1 -1
- package/dist/{middleware-aNUajYPY.js → middleware-sjhz30sm.js} +185 -60
- package/dist/{middleware-BgGJEcdp.mjs → middleware-yqqfI7oJ.mjs} +1 -1
- package/dist/{mod-B6LmugJ4.d.ts → mod-BRnwh2oy.d.ts} +2 -8
- package/dist/{mod-D2JyWtW3.d.cts → mod-BYWp77-z.d.cts} +1 -1
- package/dist/{mod-DQGjRJUG.d.ts → mod-BuRRdsfD.d.ts} +1 -1
- package/dist/{mod-ej_rLx8h.d.ts → mod-CM5_J_cx.d.ts} +1 -1
- package/dist/{mod-a6kmB8xD.d.cts → mod-CVSKw-5H.d.cts} +1 -1
- package/dist/{mod-V2vDnYNu.d.cts → mod-Co7LEK9X.d.cts} +2 -8
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +6 -6
- package/dist/mod.d.ts +6 -6
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +337 -19
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.d.cts +1 -1
- package/dist/nodeinfo/mod.d.ts +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/otel/exporter.test.mjs +292 -30
- package/dist/otel/mod.cjs +36 -30
- package/dist/otel/mod.d.cts +13 -0
- package/dist/otel/mod.d.ts +13 -0
- package/dist/otel/mod.js +36 -30
- package/dist/{owner-BUTMEkbn.mjs → owner-B8kXzD0q.mjs} +2 -2
- package/dist/{proof-DS1Zl6BX.mjs → proof-CBQOjOgA.mjs} +2 -2
- package/dist/{proof-Bm3xyn3D.js → proof-DKX6nASL.js} +1 -1
- package/dist/{proof-BeY7TsiS.cjs → proof-qiuGJCD7.cjs} +1 -1
- package/dist/{send-fnPrh9Zm.mjs → send-DRpisX_f.mjs} +117 -32
- package/dist/sig/http.test.mjs +529 -3
- package/dist/sig/key.test.mjs +197 -3
- package/dist/sig/ld.test.mjs +47 -2
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +2 -2
- package/dist/sig/mod.d.ts +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +46 -1
- package/dist/sig/proof.test.mjs +52 -1
- package/dist/{temporal-Biz6zK6e.mjs → temporal-BQGEINad.mjs} +1 -1
- package/dist/testing/mod.d.mts +26 -1
- package/dist/{types-miAYfiGO.js → types-B1_pRFE_.js} +112 -63
- package/dist/{types-DRPjmHVV.cjs → types-DOvyymM4.cjs} +111 -62
- package/dist/utils/docloader.test.mjs +382 -34
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -6
- package/dist/docloader-BGjq1F5U.mjs +0 -81
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
2
|
import { Actor, CryptographicKey, Multikey } from "@fedify/vocab";
|
|
3
|
-
import { TracerProvider } from "@opentelemetry/api";
|
|
4
3
|
import { DocumentLoader } from "@fedify/vocab-runtime";
|
|
5
|
-
|
|
4
|
+
import { TracerProvider } from "@opentelemetry/api";
|
|
6
5
|
//#region src/sig/key.d.ts
|
|
7
6
|
/**
|
|
8
7
|
* Generates a key pair which is appropriate for Fedify.
|
|
@@ -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.2.
|
|
13
|
+
var version = "2.2.20";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/sig/accept.ts
|
|
16
16
|
/**
|
|
@@ -291,16 +291,23 @@ async function importJwk(jwk, type) {
|
|
|
291
291
|
/**
|
|
292
292
|
* Fetches the document that the given actor URI dereferences to, and returns
|
|
293
293
|
* the actor only if the host that served the document is authoritative for
|
|
294
|
-
* the id the document claims.
|
|
294
|
+
* the id the document claims, and that id is the actor that was asked for.
|
|
295
295
|
*
|
|
296
296
|
* Only the origin that serves an actor id can speak for it. Without that
|
|
297
297
|
* rule any host could serve a document describing somebody else's actor—and
|
|
298
298
|
* listing its own keys as that actor's.
|
|
299
299
|
*
|
|
300
|
+
* The returned actor always has exactly the requested `actorId` as its `id`.
|
|
301
|
+
* A document loader follows redirects and alternate document links, so the
|
|
302
|
+
* document an actor id leads to may describe a different actor altogether,
|
|
303
|
+
* on the same origin or on another; accepting it would attribute that other
|
|
304
|
+
* actor's keys to the requested one. See GHSA-8863-8468-7hq7.
|
|
305
|
+
*
|
|
300
306
|
* @param actorId The URI of the actor to fetch.
|
|
301
307
|
* @param options Options for fetching the document.
|
|
302
308
|
* @returns The actor, or `null` if the document cannot be fetched, is not an
|
|
303
|
-
* actor,
|
|
309
|
+
* actor, belongs to another origin, or describes an actor other
|
|
310
|
+
* than the requested one.
|
|
304
311
|
* @internal
|
|
305
312
|
*/
|
|
306
313
|
async function fetchActorDocument(actorId, options = {}) {
|
|
@@ -355,6 +362,13 @@ async function fetchActorDocumentInternal(actorId, options, propagateContextFetc
|
|
|
355
362
|
});
|
|
356
363
|
return null;
|
|
357
364
|
}
|
|
365
|
+
if (object.id.href !== actorId.href) {
|
|
366
|
+
logger.debug("The document fetched for the actor {actorId} is the actor {documentActorId} instead; refusing to treat it as the requested actor's document.", {
|
|
367
|
+
actorId: actorId.href,
|
|
368
|
+
documentActorId: object.id.href
|
|
369
|
+
});
|
|
370
|
+
return null;
|
|
371
|
+
}
|
|
358
372
|
return object;
|
|
359
373
|
}
|
|
360
374
|
/**
|
|
@@ -1583,10 +1597,10 @@ async function createRedirectRequest(request, location, body, validateRedirect)
|
|
|
1583
1597
|
cache: request.cache
|
|
1584
1598
|
});
|
|
1585
1599
|
}
|
|
1586
|
-
async function fetchDoubleKnockRequest(request, signedRequest, signal) {
|
|
1600
|
+
async function fetchDoubleKnockRequest(session, request, signedRequest, signal) {
|
|
1587
1601
|
const maxAttempts = request.method === "GET" || request.method === "HEAD" ? 2 : 1;
|
|
1588
1602
|
for (let attempt = 1;; attempt++) try {
|
|
1589
|
-
return await fetch(signedRequest, {
|
|
1603
|
+
return await session.fetch(signedRequest, {
|
|
1590
1604
|
redirect: "manual",
|
|
1591
1605
|
signal
|
|
1592
1606
|
});
|
|
@@ -1637,118 +1651,187 @@ function getAbortReason(signal) {
|
|
|
1637
1651
|
return signal.reason ?? new DOMException("The operation was aborted.", "AbortError");
|
|
1638
1652
|
}
|
|
1639
1653
|
/**
|
|
1640
|
-
* Performs a double-knock request
|
|
1641
|
-
*
|
|
1642
|
-
*
|
|
1654
|
+
* Performs a double-knock request like {@link doubleKnock}, opening a session
|
|
1655
|
+
* for every hop with the given function, and passes the final response to
|
|
1656
|
+
* the given function. The final session is closed after `consume` settles,
|
|
1657
|
+
* so `consume` must read or cancel the response body before it returns.
|
|
1658
|
+
* This is not exported from any entry point.
|
|
1643
1659
|
* @param request The request to send.
|
|
1644
1660
|
* @param identity The identity to use for signing the request.
|
|
1645
1661
|
* @param options The options for double-knock requests.
|
|
1646
|
-
* @
|
|
1647
|
-
*
|
|
1662
|
+
* @param openHop The function to open a session for each hop. The session of
|
|
1663
|
+
* a hop is closed before the next hop is opened.
|
|
1664
|
+
* @param consume The function to consume the final response.
|
|
1665
|
+
* @returns The value returned by `consume`.
|
|
1648
1666
|
*/
|
|
1649
|
-
async function
|
|
1650
|
-
|
|
1667
|
+
async function doubleKnockScoped(request, identity, options, openHop, consume) {
|
|
1668
|
+
const { response, session } = await doubleKnockCore(request, identity, options, openHop);
|
|
1669
|
+
try {
|
|
1670
|
+
return await consume(response);
|
|
1671
|
+
} catch (error) {
|
|
1672
|
+
getLogger([
|
|
1673
|
+
"fedify",
|
|
1674
|
+
"sig",
|
|
1675
|
+
"http"
|
|
1676
|
+
]).debug("Failed to consume the response from {url}; closing the session: {error}", {
|
|
1677
|
+
url: request.url,
|
|
1678
|
+
error
|
|
1679
|
+
});
|
|
1680
|
+
throw error;
|
|
1681
|
+
} finally {
|
|
1682
|
+
await session.close();
|
|
1683
|
+
}
|
|
1651
1684
|
}
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
let response = await fetchDoubleKnockRequest(request, signedRequest, signal);
|
|
1666
|
-
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
1667
|
-
if (redirected >= maximumRedirection) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
|
|
1668
|
-
const redirectRequest = await createRedirectRequest(request, response.headers.get("Location"), body, options.validateRedirect);
|
|
1669
|
-
if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
|
|
1670
|
-
return doubleKnockInternal(redirectRequest, identity, {
|
|
1671
|
-
...options,
|
|
1672
|
-
body
|
|
1673
|
-
}, redirected + 1, visited);
|
|
1674
|
-
} else if (response.status === 400 || response.status === 401 || response.status > 401) {
|
|
1675
|
-
const logger = getLogger([
|
|
1685
|
+
function isRedirectResponse(response) {
|
|
1686
|
+
return response.status >= 300 && response.status < 400 && response.headers.has("Location");
|
|
1687
|
+
}
|
|
1688
|
+
/**
|
|
1689
|
+
* Starts cancelling the body of a response that is not passed to the caller,
|
|
1690
|
+
* without waiting for it to settle. The cancellation of a branch of a tee
|
|
1691
|
+
* (e.g., a body cloned by a fetch mock) settles only after the other branch
|
|
1692
|
+
* is cancelled too, per the Streams standard, so awaiting it could block
|
|
1693
|
+
* forever. Failures are only logged.
|
|
1694
|
+
*/
|
|
1695
|
+
function cancelResponseBody(response, url) {
|
|
1696
|
+
response.body?.cancel().catch((error) => {
|
|
1697
|
+
getLogger([
|
|
1676
1698
|
"fedify",
|
|
1677
1699
|
"sig",
|
|
1678
1700
|
"http"
|
|
1679
|
-
])
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
1699
|
-
|
|
1701
|
+
]).debug("Failed to cancel the response body from {url}: {error}", {
|
|
1702
|
+
url,
|
|
1703
|
+
error
|
|
1704
|
+
});
|
|
1705
|
+
});
|
|
1706
|
+
}
|
|
1707
|
+
async function doubleKnockCore(request, identity, options, openHop) {
|
|
1708
|
+
const { specDeterminer, log, tracerProvider, signal } = options;
|
|
1709
|
+
const maximumRedirection = options.maxRedirection ?? DEFAULT_MAX_REDIRECTION;
|
|
1710
|
+
const visited = /* @__PURE__ */ new Set();
|
|
1711
|
+
const body = options.body !== void 0 ? options.body : request.method !== "GET" && request.method !== "HEAD" ? await request.clone().arrayBuffer() : null;
|
|
1712
|
+
let session = await openHop(request.url);
|
|
1713
|
+
try {
|
|
1714
|
+
for (let redirected = 0;; redirected++) {
|
|
1715
|
+
visited.add(request.url);
|
|
1716
|
+
const origin = new URL(request.url).origin;
|
|
1717
|
+
const firstTrySpec = specDeterminer == null ? "rfc9421" : await specDeterminer.determineSpec(origin);
|
|
1718
|
+
let signedRequest = await signRequest(request, identity.privateKey, identity.keyId, {
|
|
1719
|
+
spec: firstTrySpec,
|
|
1720
|
+
tracerProvider,
|
|
1721
|
+
body
|
|
1722
|
+
});
|
|
1723
|
+
log?.(signedRequest);
|
|
1724
|
+
let response = await fetchDoubleKnockRequest(session, request, signedRequest, signal);
|
|
1725
|
+
const firstRedirected = isRedirectResponse(response);
|
|
1726
|
+
if (!firstRedirected && (response.status === 400 || response.status === 401 || response.status > 401)) {
|
|
1727
|
+
const logger = getLogger([
|
|
1728
|
+
"fedify",
|
|
1729
|
+
"sig",
|
|
1730
|
+
"http"
|
|
1731
|
+
]);
|
|
1732
|
+
const acceptSigHeader = response.headers.get("Accept-Signature");
|
|
1733
|
+
if (acceptSigHeader != null) {
|
|
1734
|
+
const entries = validateAcceptSignature(parseAcceptSignature(acceptSigHeader));
|
|
1735
|
+
const localKeyId = identity.keyId.href;
|
|
1736
|
+
const localAlg = "rsa-v1_5-sha256";
|
|
1737
|
+
let fulfilled = false;
|
|
1738
|
+
let challengeRequest;
|
|
1739
|
+
for (const entry of entries) {
|
|
1740
|
+
const rfc9421 = fulfillAcceptSignature(entry, localKeyId, localAlg);
|
|
1741
|
+
if (rfc9421 == null) continue;
|
|
1742
|
+
logger.debug("Received Accept-Signature challenge; accumulating label {label} and components {components}.", {
|
|
1743
|
+
label: rfc9421.label,
|
|
1744
|
+
components: rfc9421.components
|
|
1745
|
+
});
|
|
1746
|
+
try {
|
|
1747
|
+
challengeRequest = await signRequest(challengeRequest ?? request, identity.privateKey, identity.keyId, {
|
|
1748
|
+
spec: "rfc9421",
|
|
1749
|
+
tracerProvider,
|
|
1750
|
+
body,
|
|
1751
|
+
rfc9421
|
|
1752
|
+
});
|
|
1753
|
+
fulfilled = true;
|
|
1754
|
+
} catch (error) {
|
|
1755
|
+
logger.debug("Failed to fulfill Accept-Signature challenge entry {label}: {error}", {
|
|
1756
|
+
label: entry.label,
|
|
1757
|
+
error
|
|
1758
|
+
});
|
|
1759
|
+
}
|
|
1760
|
+
}
|
|
1761
|
+
if (fulfilled && challengeRequest != null) {
|
|
1762
|
+
cancelResponseBody(response, request.url);
|
|
1763
|
+
signedRequest = challengeRequest;
|
|
1764
|
+
log?.(signedRequest);
|
|
1765
|
+
response = await session.fetch(signedRequest, {
|
|
1766
|
+
redirect: "manual",
|
|
1767
|
+
signal
|
|
1768
|
+
});
|
|
1769
|
+
}
|
|
1770
|
+
if (fulfilled && !isRedirectResponse(response)) {
|
|
1771
|
+
if (response.status < 300) {
|
|
1772
|
+
await specDeterminer?.rememberSpec(origin, "rfc9421");
|
|
1773
|
+
return {
|
|
1774
|
+
response,
|
|
1775
|
+
session
|
|
1776
|
+
};
|
|
1777
|
+
}
|
|
1778
|
+
if (response.status !== 400 && response.status !== 401) return {
|
|
1779
|
+
response,
|
|
1780
|
+
session
|
|
1781
|
+
};
|
|
1782
|
+
}
|
|
1783
|
+
}
|
|
1784
|
+
if (!isRedirectResponse(response)) {
|
|
1785
|
+
const spec = firstTrySpec === "draft-cavage-http-signatures-12" ? "rfc9421" : "draft-cavage-http-signatures-12";
|
|
1786
|
+
getLogger([
|
|
1787
|
+
"fedify",
|
|
1788
|
+
"sig",
|
|
1789
|
+
"http"
|
|
1790
|
+
]).debug("Failed to verify with the spec {spec} ({status} {statusText}); retrying with spec {secondSpec}... (double-knocking)", {
|
|
1791
|
+
spec: firstTrySpec,
|
|
1792
|
+
secondSpec: spec,
|
|
1793
|
+
status: response.status,
|
|
1794
|
+
statusText: response.statusText
|
|
1700
1795
|
});
|
|
1701
|
-
|
|
1702
|
-
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1796
|
+
cancelResponseBody(response, request.url);
|
|
1797
|
+
signedRequest = await signRequest(request, identity.privateKey, identity.keyId, {
|
|
1798
|
+
spec,
|
|
1799
|
+
tracerProvider,
|
|
1800
|
+
body
|
|
1706
1801
|
});
|
|
1802
|
+
log?.(signedRequest);
|
|
1803
|
+
response = await fetchDoubleKnockRequest(session, request, signedRequest, signal);
|
|
1804
|
+
if (!isRedirectResponse(response) && response.status !== 400 && response.status !== 401) await specDeterminer?.rememberSpec(origin, spec);
|
|
1707
1805
|
}
|
|
1708
|
-
}
|
|
1709
|
-
if (
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
});
|
|
1716
|
-
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) return doubleKnock(await createRedirectRequest(request, response.headers.get("Location"), body, options.validateRedirect), identity, {
|
|
1717
|
-
...options,
|
|
1718
|
-
body
|
|
1719
|
-
});
|
|
1720
|
-
}
|
|
1721
|
-
if (fulfilled && response.status < 300) {
|
|
1722
|
-
await specDeterminer?.rememberSpec(origin, "rfc9421");
|
|
1723
|
-
return response;
|
|
1724
|
-
}
|
|
1725
|
-
if (fulfilled && response.status !== 400 && response.status !== 401) return response;
|
|
1726
|
-
}
|
|
1727
|
-
const spec = firstTrySpec === "draft-cavage-http-signatures-12" ? "rfc9421" : "draft-cavage-http-signatures-12";
|
|
1728
|
-
logger.debug("Failed to verify with the spec {spec} ({status} {statusText}); retrying with spec {secondSpec}... (double-knocking)", {
|
|
1729
|
-
spec: firstTrySpec,
|
|
1730
|
-
secondSpec: spec,
|
|
1731
|
-
status: response.status,
|
|
1732
|
-
statusText: response.statusText
|
|
1733
|
-
});
|
|
1734
|
-
signedRequest = await signRequest(request, identity.privateKey, identity.keyId, {
|
|
1735
|
-
spec,
|
|
1736
|
-
tracerProvider,
|
|
1737
|
-
body
|
|
1738
|
-
});
|
|
1739
|
-
log?.(signedRequest);
|
|
1740
|
-
response = await fetchDoubleKnockRequest(request, signedRequest, signal);
|
|
1741
|
-
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
1806
|
+
} else if (!firstRedirected) await specDeterminer?.rememberSpec(origin, firstTrySpec);
|
|
1807
|
+
if (!isRedirectResponse(response)) return {
|
|
1808
|
+
response,
|
|
1809
|
+
session
|
|
1810
|
+
};
|
|
1811
|
+
cancelResponseBody(response, request.url);
|
|
1812
|
+
await session.close();
|
|
1742
1813
|
if (redirected >= maximumRedirection) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
|
|
1743
|
-
const
|
|
1814
|
+
const location = response.headers.get("Location");
|
|
1815
|
+
const redirectRequest = await createRedirectRequest(request, location, body, options.validateRedirect);
|
|
1744
1816
|
if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1817
|
+
request = redirectRequest;
|
|
1818
|
+
session = await openHop(request.url);
|
|
1819
|
+
}
|
|
1820
|
+
} catch (error) {
|
|
1821
|
+
try {
|
|
1822
|
+
await session.close();
|
|
1823
|
+
} catch (closeError) {
|
|
1824
|
+
getLogger([
|
|
1825
|
+
"fedify",
|
|
1826
|
+
"sig",
|
|
1827
|
+
"http"
|
|
1828
|
+
]).debug("Failed to close the session for {url}: {error}", {
|
|
1829
|
+
url: request.url,
|
|
1830
|
+
error: closeError
|
|
1831
|
+
});
|
|
1832
|
+
}
|
|
1833
|
+
throw error;
|
|
1834
|
+
}
|
|
1752
1835
|
}
|
|
1753
1836
|
/**
|
|
1754
1837
|
* Performs a timing-safe equality comparison between two `Uint8Array` values.
|
|
@@ -1778,4 +1861,4 @@ function timingSafeEqual(a, b) {
|
|
|
1778
1861
|
return result === 0;
|
|
1779
1862
|
}
|
|
1780
1863
|
//#endregion
|
|
1781
|
-
export { validateAcceptSignature as _, verifyRequestDetailed as a, fetchKey as c, importJwk as d, validateCryptoKey as f, parseAcceptSignature as g, fulfillAcceptSignature as h, verifyRequest as i, fetchKeyDetailed as l, formatAcceptSignature as m, parseRfc9421SignatureInput as n, exportJwk as o, verifyKeyOwnership as p, signRequest as r, fetchActorDocument as s,
|
|
1864
|
+
export { validateAcceptSignature as _, verifyRequestDetailed as a, fetchKey as c, importJwk as d, validateCryptoKey as f, parseAcceptSignature as g, fulfillAcceptSignature as h, verifyRequest as i, fetchKeyDetailed as l, formatAcceptSignature as m, parseRfc9421SignatureInput as n, exportJwk as o, verifyKeyOwnership as p, signRequest as r, fetchActorDocument as s, doubleKnockScoped as t, generateCryptoKeyPair as u, name as v, version as y };
|