@fedify/fedify 2.0.7 → 2.0.9
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/{assert-MZs1qjMx.js → assert-ddO5KLpe.mjs} +5 -9
- package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
- package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
- package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals--wG9hV7u.mjs} +6 -13
- package/dist/{assert_rejects-Ce45JcFg.js → assert_rejects-B-qJtC9Z.mjs} +6 -11
- package/dist/{assert_throws-BNXdRGWP.js → assert_throws-4NwKEy2q.mjs} +5 -10
- package/dist/{builder-DA7Qgx_F.js → builder-DDoQaGOu.mjs} +32 -41
- package/dist/{chunk-CGaQZ11T.cjs → chunk-DDcVe30Y.cjs} +23 -24
- package/dist/{chunk-DJNbSFdH.js → chunk-nlSIicah.js} +8 -8
- package/dist/{client-CoCIaTNO.js → client-A1UrnX6I.mjs} +9 -13
- package/dist/{client-BxMZiQaD.d.ts → client-AtlibPOU.d.ts} +1 -1
- package/dist/{client-C97KOq3x.d.cts → client-z-8dc-e1.d.cts} +1 -1
- package/dist/{collection-CcnIw1qY.js → collection-ChgDTHLz.mjs} +7 -12
- package/dist/compat/mod.cjs +5 -8
- package/dist/compat/mod.d.cts +78 -6
- package/dist/compat/mod.d.ts +78 -6
- package/dist/compat/mod.js +4 -8
- package/dist/compat/transformers.test.mjs +62 -0
- package/dist/{context-D3QkEtZd.d.cts → context-CNIt-Qn7.d.cts} +9 -18
- package/dist/{context-DZJhUmzF.d.ts → context-Dyg7P1qW.d.ts} +9 -18
- package/dist/{context-pa9aIrwp.js → context-Juj6bdHC.mjs} +7 -11
- package/dist/deno-CuVDEdyj.mjs +8 -0
- package/dist/{docloader-CJeSPcS_.js → docloader-BPq9yzC_.mjs} +8 -14
- package/dist/{esm-nLm00z9V.js → esm-DVILvP5e.mjs} +50 -89
- package/dist/federation/builder.test.d.mts +2 -0
- package/dist/federation/{builder.test.js → builder.test.mjs} +19 -38
- package/dist/federation/collection.test.d.mts +2 -0
- package/dist/federation/collection.test.mjs +21 -0
- package/dist/federation/handler.test.d.mts +2 -0
- package/dist/federation/{handler.test.js → handler.test.mjs} +26 -56
- package/dist/federation/idempotency.test.d.mts +2 -0
- package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +31 -62
- package/dist/federation/inbox.test.d.mts +2 -0
- package/dist/federation/{inbox.test.js → inbox.test.mjs} +8 -12
- package/dist/federation/keycache.test.d.mts +2 -0
- package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -13
- package/dist/federation/kv.test.d.mts +2 -0
- package/dist/federation/{kv.test.js → kv.test.mjs} +11 -22
- package/dist/federation/middleware.test.d.mts +2 -0
- package/dist/federation/{middleware.test.js → middleware.test.mjs} +146 -225
- package/dist/federation/mod.cjs +327 -16
- package/dist/federation/mod.d.cts +3 -6
- package/dist/federation/mod.d.ts +3 -6
- package/dist/federation/mod.js +322 -13
- package/dist/federation/mq.test.d.mts +2 -0
- package/dist/federation/{mq.test.js → mq.test.mjs} +21 -35
- package/dist/federation/negotiation.test.d.mts +2 -0
- package/dist/federation/{negotiation.test.js → negotiation.test.mjs} +9 -16
- package/dist/federation/retry.test.d.mts +2 -0
- package/dist/federation/{retry.test.js → retry.test.mjs} +8 -11
- package/dist/federation/router.test.d.mts +2 -0
- package/dist/federation/{router.test.js → router.test.mjs} +11 -16
- package/dist/federation/send.test.d.mts +2 -0
- package/dist/federation/{send.test.js → send.test.mjs} +22 -29
- package/dist/federation/webfinger.test.d.mts +2 -0
- package/dist/federation/{webfinger.test.js → webfinger.test.mjs} +22 -55
- package/dist/{http-DkHdFfrc.d.ts → http-B2wiNmSo.d.ts} +1 -6
- package/dist/{http-B3vAjAtl.js → http-Bz7avX57.js} +39 -159
- package/dist/{http-Cz3MlXAZ.d.cts → http-C_tEAiZj.d.cts} +1 -6
- package/dist/{http-CjaLjnRN.js → http-DI213UHg.mjs} +31 -35
- package/dist/{http-CQ7TiYUI.cjs → http-DKBDoudA.cjs} +119 -233
- package/dist/{inbox-B33isX44.js → inbox-Bdn-CSRd.mjs} +18 -26
- package/dist/{key-Cga1p73u.js → key-DzJf84o7.mjs} +12 -19
- package/dist/{keycache-DRxpZ5r9.js → keycache-DaQ3ndaJ.mjs} +15 -10
- package/dist/{keys-ZbcByPg9.js → keys-CtZLJq76.mjs} +5 -9
- package/dist/{kv-QzKcOQgP.js → kv-BrZHNugx.mjs} +6 -10
- package/dist/{kv-BL4nlICN.d.cts → kv-CbLNp3zQ.d.cts} +1 -1
- package/dist/{kv-DXEUEP6z.d.ts → kv-GFYnFoOl.d.ts} +1 -1
- package/dist/{kv-cache-CFdy0BpZ.js → kv-cache-DBd7BezJ.js} +6 -13
- package/dist/{kv-cache--qyREO7e.cjs → kv-cache-Dj1Q7TiW.cjs} +27 -34
- package/dist/{kv-cache-El7We5sy.js → kv-cache-OWmRLHir.mjs} +4 -8
- package/dist/{ld-BWSOukKj.js → ld-DczS1fLK.mjs} +17 -31
- package/dist/middleware-B5CiOImA.mjs +5 -0
- package/dist/{middleware-CP7JdsGq.js → middleware-BKNu57ZI.js} +331 -365
- package/dist/middleware-C36TOX-2.cjs +4 -0
- package/dist/{middleware-Scz2k9eL.cjs → middleware-CyjmpK70.cjs} +523 -565
- package/dist/{middleware-BI1VCuPT.js → middleware-DoHz9oIo.mjs} +260 -292
- package/dist/{mod-DPkRU3EK.d.cts → mod-1xhgsHef.d.cts} +2 -2
- package/dist/{mod-DUWcVv49.d.ts → mod-BGtYJZKu.d.ts} +2 -2
- package/dist/{mod-DXsQakeS.d.cts → mod-Bld7oeqf.d.cts} +3 -3
- package/dist/{mod-DnSsduJF.d.ts → mod-BnAKGh2w.d.ts} +2 -2
- package/dist/{mod-CwZXZJ9d.d.ts → mod-DTOUyCce.d.ts} +3 -3
- package/dist/{mod-Di3W5OdP.d.cts → mod-DWoQffTD.d.cts} +2 -2
- package/dist/mod.cjs +29 -68
- package/dist/mod.d.cts +11 -14
- package/dist/mod.d.ts +11 -15
- package/dist/mod.js +17 -65
- package/dist/{negotiation-5NPJL6zp.js → negotiation-BehA2uul.mjs} +7 -11
- package/dist/nodeinfo/client.test.d.mts +2 -0
- package/dist/nodeinfo/{client.test.js → client.test.mjs} +22 -40
- package/dist/nodeinfo/handler.test.d.mts +2 -0
- package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +13 -42
- package/dist/nodeinfo/mod.cjs +5 -8
- package/dist/nodeinfo/mod.d.cts +2 -3
- package/dist/nodeinfo/mod.d.ts +2 -3
- package/dist/nodeinfo/mod.js +4 -8
- package/dist/nodeinfo/types.test.d.mts +2 -0
- package/dist/nodeinfo/{types.test.js → types.test.mjs} +9 -16
- package/dist/otel/exporter.test.d.mts +2 -0
- package/dist/otel/{exporter.test.js → exporter.test.mjs} +117 -169
- package/dist/otel/mod.cjs +15 -20
- package/dist/otel/mod.d.cts +2 -2
- package/dist/otel/mod.d.ts +2 -2
- package/dist/otel/mod.js +8 -14
- package/dist/{owner-gd0Q9FuU.d.ts → owner-74ARJ5TL.d.ts} +1 -1
- package/dist/{owner-1AbPBOOZ.d.cts → owner-CptqhsOy.d.cts} +1 -1
- package/dist/{owner-HASxJJP1.js → owner-DXMGUEOr.mjs} +11 -16
- package/dist/{proof-BwfRl5J4.js → proof-C-7NljBU.js} +33 -59
- package/dist/{proof-BXt2Oi8t.js → proof-CEOujj0L.mjs} +21 -33
- package/dist/{proof-BYZ4hcgN.cjs → proof-DMu-6A_w.cjs} +133 -157
- package/dist/{retry-D4GJ670a.js → retry-Ddbq3AcK.mjs} +4 -7
- package/dist/{router-D9eI0s4b.js → router-CrMLXoOr.mjs} +4 -8
- package/dist/runtime/mod.cjs +11 -13
- package/dist/runtime/mod.d.cts +6 -2
- package/dist/runtime/mod.d.ts +0 -1
- package/dist/runtime/mod.js +4 -7
- package/dist/{send-BF3omx5-.js → send-DIfrLTB_.mjs} +8 -13
- package/dist/sig/http.test.d.mts +2 -0
- package/dist/sig/{http.test.js → http.test.mjs} +160 -199
- package/dist/sig/key.test.d.mts +2 -0
- package/dist/sig/{key.test.js → key.test.mjs} +11 -18
- package/dist/sig/ld.test.d.mts +2 -0
- package/dist/sig/{ld.test.js → ld.test.mjs} +22 -35
- package/dist/sig/mod.cjs +6 -9
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +5 -9
- package/dist/sig/owner.test.d.mts +2 -0
- package/dist/sig/{owner.test.js → owner.test.mjs} +19 -34
- package/dist/sig/proof.test.d.mts +2 -0
- package/dist/sig/{proof.test.js → proof.test.mjs} +16 -27
- package/dist/{std__assert-DWivtrGR.js → std__assert-Duiq_YC9.mjs} +12 -24
- package/dist/testing/{mod.d.ts → mod.d.mts} +26 -78
- package/dist/testing/mod.mjs +6 -0
- package/dist/{transformers-3g8GZwkZ.cjs → transformers-NeAONrAq.cjs} +20 -25
- package/dist/{transformers-C3FLHUd6.js → transformers-ve6e2xcg.js} +3 -7
- package/dist/{types-CPz01LGH.js → types-C37hquWI.mjs} +4 -7
- package/dist/{types-Cd_hszr_.cjs → types-KC4QAoxe.cjs} +29 -34
- package/dist/{types-C93Ob9cU.js → types-hvL8ElAs.js} +8 -13
- package/dist/utils/docloader.test.d.mts +2 -0
- package/dist/utils/{docloader.test.js → docloader.test.mjs} +14 -24
- package/dist/utils/kv-cache.test.d.mts +2 -0
- package/dist/utils/{kv-cache.test.js → kv-cache.test.mjs} +25 -40
- package/dist/utils/mod.cjs +5 -9
- package/dist/utils/mod.d.cts +1 -3
- package/dist/utils/mod.d.ts +1 -3
- package/dist/utils/mod.js +4 -9
- package/dist/vocab/cjs.test.d.mts +2 -0
- package/dist/vocab/cjs.test.mjs +14 -0
- package/dist/vocab/mod.cjs +10 -12
- package/dist/vocab/mod.js +3 -5
- package/package.json +7 -7
- package/dist/compat/transformers.test.d.ts +0 -3
- package/dist/compat/transformers.test.js +0 -87
- package/dist/compat-Bb4NuTUO.js +0 -4
- package/dist/compat-DmDDELst.cjs +0 -4
- package/dist/deno-CbQK8e-e.js +0 -121
- package/dist/federation/builder.test.d.ts +0 -3
- package/dist/federation/collection.test.d.ts +0 -3
- package/dist/federation/collection.test.js +0 -32
- package/dist/federation/handler.test.d.ts +0 -3
- package/dist/federation/idempotency.test.d.ts +0 -3
- package/dist/federation/inbox.test.d.ts +0 -3
- package/dist/federation/keycache.test.d.ts +0 -3
- package/dist/federation/kv.test.d.ts +0 -3
- package/dist/federation/middleware.test.d.ts +0 -3
- package/dist/federation/mq.test.d.ts +0 -3
- package/dist/federation/negotiation.test.d.ts +0 -3
- package/dist/federation/retry.test.d.ts +0 -3
- package/dist/federation/router.test.d.ts +0 -3
- package/dist/federation/send.test.d.ts +0 -3
- package/dist/federation/webfinger.test.d.ts +0 -3
- package/dist/federation-Bp3HI26G.cjs +0 -350
- package/dist/federation-DaMfqRm4.js +0 -332
- package/dist/middleware-CcXQzfn8.cjs +0 -12
- package/dist/middleware-CoeaBowW.js +0 -12
- package/dist/middleware-vH2jFwC6.js +0 -26
- package/dist/mod-Bh8mqlYw.d.cts +0 -9
- package/dist/mod-D6HodEq7.d.ts +0 -7
- package/dist/mod-DVwHUI_x.d.cts +0 -80
- package/dist/mod-DosD6NsG.d.ts +0 -82
- package/dist/mod-gq_Xfdz8.d.cts +0 -1
- package/dist/nodeinfo/client.test.d.ts +0 -3
- package/dist/nodeinfo/handler.test.d.ts +0 -3
- package/dist/nodeinfo/types.test.d.ts +0 -3
- package/dist/nodeinfo-DoESQxq5.js +0 -4
- package/dist/nodeinfo-DuMYTpbZ.cjs +0 -4
- package/dist/otel/exporter.test.d.ts +0 -3
- package/dist/runtime-c2Njxsry.cjs +0 -17
- package/dist/runtime-poamPCMb.js +0 -13
- package/dist/sig/http.test.d.ts +0 -3
- package/dist/sig/key.test.d.ts +0 -3
- package/dist/sig/ld.test.d.ts +0 -3
- package/dist/sig/owner.test.d.ts +0 -3
- package/dist/sig/proof.test.d.ts +0 -3
- package/dist/sig-BNhspNOf.js +0 -4
- package/dist/sig-vX39WyWI.cjs +0 -4
- package/dist/testing/mod.js +0 -10
- package/dist/utils/docloader.test.d.ts +0 -3
- package/dist/utils/kv-cache.test.d.ts +0 -3
- package/dist/utils-BQ9KqEK9.cjs +0 -4
- package/dist/utils-Dn5OPdSW.js +0 -4
- /package/dist/{mod-AGjRfPjT.d.ts → compat/transformers.test.d.mts} +0 -0
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import { deno_default } from "./deno-CbQK8e-e.js";
|
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-Cga1p73u.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { n as version, t as name } from "./deno-CuVDEdyj.mjs";
|
|
5
|
+
import { a as validateCryptoKey, n as fetchKey } from "./key-DzJf84o7.mjs";
|
|
8
6
|
import { CryptographicKey } from "@fedify/vocab";
|
|
9
|
-
import { getLogger } from "@logtape/logtape";
|
|
10
7
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
|
+
import { FetchError } from "@fedify/vocab-runtime";
|
|
9
|
+
import { getLogger } from "@logtape/logtape";
|
|
11
10
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
12
11
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
13
12
|
import { encodeHex } from "byte-encodings/hex";
|
|
14
13
|
import { Item, decodeDict, encodeItem } from "structured-field-values";
|
|
15
|
-
|
|
16
14
|
//#region src/sig/http.ts
|
|
15
|
+
const DEFAULT_MAX_REDIRECTION = 20;
|
|
17
16
|
/**
|
|
18
17
|
* Signs a request using the given private key.
|
|
19
18
|
* @param request The request to sign.
|
|
@@ -25,9 +24,7 @@ import { Item, decodeDict, encodeItem } from "structured-field-values";
|
|
|
25
24
|
*/
|
|
26
25
|
async function signRequest(request, privateKey, keyId, options = {}) {
|
|
27
26
|
validateCryptoKey(privateKey, "private");
|
|
28
|
-
|
|
29
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
30
|
-
return await tracer.startActiveSpan("http_signatures.sign", async (span) => {
|
|
27
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.sign", async (span) => {
|
|
31
28
|
try {
|
|
32
29
|
const spec = options.spec ?? "draft-cavage-http-signatures-12";
|
|
33
30
|
let signed;
|
|
@@ -122,9 +119,7 @@ function createRfc9421SignatureBase(request, components, parameters) {
|
|
|
122
119
|
* @returns The formatted signature string.
|
|
123
120
|
*/
|
|
124
121
|
function formatRfc9421Signature(signature, components, parameters) {
|
|
125
|
-
|
|
126
|
-
const signatureValue = `sig1=:${encodeBase64(signature)}:`;
|
|
127
|
-
return [signatureInputValue, signatureValue];
|
|
122
|
+
return [`sig1=("${components.join("\" \"")}");${parameters}`, `sig1=:${encodeBase64(signature)}:`];
|
|
128
123
|
}
|
|
129
124
|
/**
|
|
130
125
|
* Parse RFC 9421 Signature-Input header.
|
|
@@ -254,9 +249,7 @@ const supportedHashAlgorithms = {
|
|
|
254
249
|
* could not be verified.
|
|
255
250
|
*/
|
|
256
251
|
async function verifyRequest(request, options = {}) {
|
|
257
|
-
|
|
258
|
-
const tracer = tracerProvider.getTracer(deno_default.name, deno_default.version);
|
|
259
|
-
return await tracer.startActiveSpan("http_signatures.verify", async (span) => {
|
|
252
|
+
return await (options.tracerProvider ?? trace.getTracerProvider()).getTracer(name, version).startActiveSpan("http_signatures.verify", async (span) => {
|
|
260
253
|
if (span.isRecording()) {
|
|
261
254
|
span.setAttribute(ATTR_HTTP_REQUEST_METHOD, request.method);
|
|
262
255
|
span.setAttribute(ATTR_URL_FULL, request.url);
|
|
@@ -446,8 +439,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
446
439
|
const message = headerNames.map((name) => `${name}: ` + (name === "(request-target)" ? `${request.method.toLowerCase()} ${new URL(request.url).pathname}` : name === "(created)" ? sigValues.created ?? "" : name === "(expires)" ? sigValues.expires ?? "" : name === "host" ? request.headers.get("host") ?? new URL(request.url).host : request.headers.get(name))).join("\n");
|
|
447
440
|
const sig = decodeBase64(signature);
|
|
448
441
|
span?.setAttribute("http_signatures.signature", encodeHex(sig));
|
|
449
|
-
|
|
450
|
-
if (!verified) {
|
|
442
|
+
if (!await crypto.subtle.verify("RSASSA-PKCS1-v1_5", key.publicKey, sig, new TextEncoder().encode(message))) {
|
|
451
443
|
if (cached) {
|
|
452
444
|
logger.debug("Failed to verify with the cached key {keyId}; signature {signature} is invalid. Retrying with the freshly fetched key...", {
|
|
453
445
|
keyId,
|
|
@@ -461,7 +453,7 @@ async function verifyRequestDraft(request, span, { documentLoader, contextLoader
|
|
|
461
453
|
currentTime,
|
|
462
454
|
keyCache: {
|
|
463
455
|
get: () => Promise.resolve(void 0),
|
|
464
|
-
set: async (keyId
|
|
456
|
+
set: async (keyId, key) => await keyCache?.set(keyId, key)
|
|
465
457
|
}
|
|
466
458
|
});
|
|
467
459
|
}
|
|
@@ -611,9 +603,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
611
603
|
logger.debug("Failed to verify; Content-Digest header required but not found.", { components: sigInput.components });
|
|
612
604
|
continue;
|
|
613
605
|
}
|
|
614
|
-
|
|
615
|
-
const digestValid = await verifyRfc9421ContentDigest(contentDigestHeader, body);
|
|
616
|
-
if (!digestValid) {
|
|
606
|
+
if (!await verifyRfc9421ContentDigest(contentDigestHeader, await request.arrayBuffer())) {
|
|
617
607
|
logger.debug("Failed to verify; Content-Digest verification failed.", { contentDigest: contentDigestHeader });
|
|
618
608
|
continue;
|
|
619
609
|
}
|
|
@@ -659,8 +649,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
659
649
|
const signatureBaseBytes = new TextEncoder().encode(signatureBase);
|
|
660
650
|
span?.setAttribute("http_signatures.signature", encodeHex(sigBytes));
|
|
661
651
|
try {
|
|
662
|
-
|
|
663
|
-
if (verified) {
|
|
652
|
+
if (await crypto.subtle.verify(algorithm, key.publicKey, sigBytes.slice(), signatureBaseBytes)) {
|
|
664
653
|
validKey = key;
|
|
665
654
|
break;
|
|
666
655
|
} else if (cached) {
|
|
@@ -672,7 +661,7 @@ async function verifyRequestRfc9421(request, span, { documentLoader, contextLoad
|
|
|
672
661
|
currentTime,
|
|
673
662
|
keyCache: {
|
|
674
663
|
get: () => Promise.resolve(void 0),
|
|
675
|
-
set: async (keyId, key
|
|
664
|
+
set: async (keyId, key) => await keyCache?.set(keyId, key)
|
|
676
665
|
},
|
|
677
666
|
spec: "rfc9421"
|
|
678
667
|
});
|
|
@@ -725,7 +714,11 @@ function createRedirectRequest(request, location, body) {
|
|
|
725
714
|
* @since 1.6.0
|
|
726
715
|
*/
|
|
727
716
|
async function doubleKnock(request, identity, options = {}) {
|
|
717
|
+
return await doubleKnockInternal(request, identity, options);
|
|
718
|
+
}
|
|
719
|
+
async function doubleKnockInternal(request, identity, options, redirected = 0, visited = /* @__PURE__ */ new Set()) {
|
|
728
720
|
const { specDeterminer, log, tracerProvider, signal } = options;
|
|
721
|
+
visited.add(request.url);
|
|
729
722
|
const origin = new URL(request.url).origin;
|
|
730
723
|
const firstTrySpec = specDeterminer == null ? "rfc9421" : await specDeterminer.determineSpec(origin);
|
|
731
724
|
const body = options.body !== void 0 ? options.body : request.method !== "GET" && request.method !== "HEAD" ? await request.clone().arrayBuffer() : null;
|
|
@@ -740,11 +733,13 @@ async function doubleKnock(request, identity, options = {}) {
|
|
|
740
733
|
signal
|
|
741
734
|
});
|
|
742
735
|
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
743
|
-
|
|
744
|
-
|
|
736
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
|
|
737
|
+
const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
|
|
738
|
+
if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
|
|
739
|
+
return doubleKnockInternal(redirectRequest, identity, {
|
|
745
740
|
...options,
|
|
746
741
|
body
|
|
747
|
-
});
|
|
742
|
+
}, redirected + 1, visited);
|
|
748
743
|
} else if (response.status === 400 || response.status === 401 || response.status > 401) {
|
|
749
744
|
const spec = firstTrySpec === "draft-cavage-http-signatures-12" ? "rfc9421" : "draft-cavage-http-signatures-12";
|
|
750
745
|
getLogger([
|
|
@@ -768,11 +763,13 @@ async function doubleKnock(request, identity, options = {}) {
|
|
|
768
763
|
signal
|
|
769
764
|
});
|
|
770
765
|
if (response.status >= 300 && response.status < 400 && response.headers.has("Location")) {
|
|
771
|
-
|
|
772
|
-
|
|
766
|
+
if (redirected >= DEFAULT_MAX_REDIRECTION) throw new FetchError(request.url, `Too many redirections (${redirected + 1})`);
|
|
767
|
+
const redirectRequest = createRedirectRequest(request, response.headers.get("Location"), body);
|
|
768
|
+
if (visited.has(redirectRequest.url)) throw new FetchError(request.url, `Redirect loop detected: ${redirectRequest.url}`);
|
|
769
|
+
return doubleKnockInternal(redirectRequest, identity, {
|
|
773
770
|
...options,
|
|
774
771
|
body
|
|
775
|
-
});
|
|
772
|
+
}, redirected + 1, visited);
|
|
776
773
|
} else if (response.status !== 400 && response.status !== 401) await specDeterminer?.rememberSpec(origin, spec);
|
|
777
774
|
} else await specDeterminer?.rememberSpec(origin, firstTrySpec);
|
|
778
775
|
return response;
|
|
@@ -804,6 +801,5 @@ function timingSafeEqual(a, b) {
|
|
|
804
801
|
result |= lenA ^ lenB;
|
|
805
802
|
return result === 0;
|
|
806
803
|
}
|
|
807
|
-
|
|
808
804
|
//#endregion
|
|
809
|
-
export {
|
|
805
|
+
export { parseRfc9421Signature as a, timingSafeEqual as c, formatRfc9421SignatureParameters as i, verifyRequest as l, doubleKnock as n, parseRfc9421SignatureInput as o, formatRfc9421Signature as r, signRequest as s, createRfc9421SignatureBase as t };
|