@fedify/fedify 2.1.29 → 2.1.30
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-Mg2G3qj8.mjs → builder-CTpfuuVp.mjs} +3 -3
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{deno-BiYv5RT5.mjs → deno-BATJ1hq6.mjs} +1 -1
- package/dist/{docloader-DrxXBFL8.mjs → docloader-OLWc7P2D.mjs} +5 -3
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +6 -6
- 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 +6 -6
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.js +1 -1
- package/dist/federation/send.test.mjs +3 -3
- package/dist/federation/temporal.test.mjs +1 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{http-C1ga9WQu.mjs → http-Bjd6I92u.mjs} +2 -2
- package/dist/{http-Cginz7L0.cjs → http-BoR1M3W7.cjs} +17 -3
- package/dist/{http-B3rSb2GQ.js → http-CK3efjgM.js} +17 -3
- package/dist/{inbox-BWzL0xMU.mjs → inbox-9MlBGgs9.mjs} +1 -1
- package/dist/{key-O-ATwIGS.mjs → key-ClQh9Qqh.mjs} +17 -3
- package/dist/{keycache-RFlZObU3.mjs → keycache-DahCaG_m.mjs} +1 -1
- package/dist/{kv-cache-BdylAE9w.cjs → kv-cache-BxSx_Iyp.cjs} +4 -2
- package/dist/{kv-cache-8Kg2CHiD.js → kv-cache-ImApO425.js} +4 -2
- package/dist/{ld-C-fCGM-z.mjs → ld-Crg0Xmwr.mjs} +2 -2
- package/dist/{middleware-CxgFiKI3.mjs → middleware-Bi5D6DBT.mjs} +1 -1
- package/dist/{middleware-41MkquTV.js → middleware-C2AJFk8W.js} +4 -4
- package/dist/{middleware-C9UCWOqw.mjs → middleware-CE0b69gj.mjs} +12 -12
- package/dist/{middleware-CVRFS7PZ.cjs → middleware-CmD3lpy4.cjs} +5 -5
- package/dist/{middleware-VvrqPwHL.cjs → middleware-jL9p9V9G.cjs} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/{owner-C8IVASD3.mjs → owner-BRoKojK1.mjs} +2 -2
- package/dist/{proof-cGfRPTiV.js → proof-7R4s10TJ.js} +1 -1
- package/dist/{proof-BbHMAkPG.cjs → proof-CHXVlsH_.cjs} +1 -1
- package/dist/{proof-CUdcBgvg.mjs → proof-DMIAezxz.mjs} +2 -2
- package/dist/{send-BoV4dyVO.mjs → send-BHIt_8ia.mjs} +2 -2
- package/dist/sig/http.test.mjs +3 -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.js +2 -2
- package/dist/sig/owner.test.mjs +46 -1
- package/dist/sig/proof.test.mjs +52 -1
- package/dist/{temporal-BJlnku_d.mjs → temporal-DR0JahMu.mjs} +1 -1
- package/dist/utils/docloader.test.mjs +66 -2
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -6
package/dist/mod.cjs
CHANGED
|
@@ -4,11 +4,11 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
4
4
|
require("./chunk-DDcVe30Y.cjs");
|
|
5
5
|
const require_transformers = require("./transformers-NeAONrAq.cjs");
|
|
6
6
|
require("./compat/mod.cjs");
|
|
7
|
-
const require_http = require("./http-
|
|
8
|
-
const require_middleware = require("./middleware-
|
|
7
|
+
const require_http = require("./http-BoR1M3W7.cjs");
|
|
8
|
+
const require_middleware = require("./middleware-CmD3lpy4.cjs");
|
|
9
9
|
const require_types = require("./types-DRPjmHVV.cjs");
|
|
10
|
-
const require_proof = require("./proof-
|
|
11
|
-
const require_kv_cache = require("./kv-cache-
|
|
10
|
+
const require_proof = require("./proof-CHXVlsH_.cjs");
|
|
11
|
+
const require_kv_cache = require("./kv-cache-BxSx_Iyp.cjs");
|
|
12
12
|
const require_federation_mod = require("./federation/mod.cjs");
|
|
13
13
|
require("./nodeinfo/mod.cjs");
|
|
14
14
|
require("./runtime/mod.cjs");
|
package/dist/mod.js
CHANGED
|
@@ -3,11 +3,11 @@ import { URLPattern } from "urlpattern-polyfill";
|
|
|
3
3
|
import "./chunk-CRNNMoPX.js";
|
|
4
4
|
import { n as autoIdAssigner, r as getDefaultActivityTransformers, t as actorDehydrator } from "./transformers-BGMIq1cs.js";
|
|
5
5
|
import "./compat/mod.js";
|
|
6
|
-
import { _ as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKey, d as importJwk, g as parseAcceptSignature, h as fulfillAcceptSignature, i as verifyRequest, l as fetchKeyDetailed, m as formatAcceptSignature, o as exportJwk, r as signRequest, u as generateCryptoKeyPair } from "./http-
|
|
7
|
-
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-
|
|
6
|
+
import { _ as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKey, d as importJwk, g as parseAcceptSignature, h as fulfillAcceptSignature, i as verifyRequest, l as fetchKeyDetailed, m as formatAcceptSignature, o as exportJwk, r as signRequest, u as generateCryptoKeyPair } from "./http-CK3efjgM.js";
|
|
7
|
+
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-C2AJFk8W.js";
|
|
8
8
|
import { n as getNodeInfo, r as parseNodeInfo, t as nodeInfoToJson } from "./types-miAYfiGO.js";
|
|
9
|
-
import { _ as signJsonLd, a as doesActorOwnKey, b as verifySignature, d as createSignature, f as detachSignature, i as verifyProof, l as attachSignature, n as signObject, o as getKeyOwner, r as verifyObject, t as createProof, y as verifyJsonLd } from "./proof-
|
|
10
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-
|
|
9
|
+
import { _ as signJsonLd, a as doesActorOwnKey, b as verifySignature, d as createSignature, f as detachSignature, i as verifyProof, l as attachSignature, n as signObject, o as getKeyOwner, r as verifyObject, t as createProof, y as verifyJsonLd } from "./proof-7R4s10TJ.js";
|
|
10
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-ImApO425.js";
|
|
11
11
|
import { InProcessMessageQueue, MemoryKvStore, ParallelMessageQueue } from "./federation/mod.js";
|
|
12
12
|
import "./nodeinfo/mod.js";
|
|
13
13
|
import "./runtime/mod.js";
|
|
@@ -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-DflMZha5.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
8
|
-
import { a as createFederation, h as handleNodeInfoJrd, m as handleNodeInfo } from "../middleware-
|
|
8
|
+
import { a as createFederation, h as handleNodeInfoJrd, m as handleNodeInfo } from "../middleware-CE0b69gj.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
//#region src/nodeinfo/handler.test.ts
|
|
11
11
|
test("handleNodeInfo()", async () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { c as verifyKeyOwnership, n as fetchActorDocument, t as exportJwk } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-BATJ1hq6.mjs";
|
|
5
|
+
import { c as verifyKeyOwnership, n as fetchActorDocument, t as exportJwk } from "./key-ClQh9Qqh.mjs";
|
|
6
6
|
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
7
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { c as fetchKey, f as validateCryptoKey, o as exportJwk, p as verifyKeyOwnership, s as fetchActorDocument, v as name, y as version } from "./http-
|
|
3
|
+
import { c as fetchKey, f as validateCryptoKey, o as exportJwk, p as verifyKeyOwnership, s as fetchActorDocument, v as name, y as version } from "./http-CK3efjgM.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { Activity, CryptographicKey, DataIntegrityProof, Multikey, Object as Object$1, getTypeId, isActor } from "@fedify/vocab";
|
|
6
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
const require_chunk = require("./chunk-DDcVe30Y.cjs");
|
|
4
|
-
const require_http = require("./http-
|
|
4
|
+
const require_http = require("./http-BoR1M3W7.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let _fedify_vocab = require("@fedify/vocab");
|
|
7
7
|
let _opentelemetry_api = require("@opentelemetry/api");
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { r as fetchKey, s as validateCryptoKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-BATJ1hq6.mjs";
|
|
5
|
+
import { r as fetchKey, s as validateCryptoKey } from "./key-ClQh9Qqh.mjs";
|
|
6
6
|
import { Activity, DataIntegrityProof, Multikey, getTypeId } from "@fedify/vocab";
|
|
7
7
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { n as version, t as name } from "./deno-BATJ1hq6.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-Bjd6I92u.mjs";
|
|
6
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
7
7
|
import { FetchError, UrlError, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
package/dist/sig/http.test.mjs
CHANGED
|
@@ -7,10 +7,10 @@ import { i as assertExists, t as assertStringIncludes } from "../std__assert-Dfl
|
|
|
7
7
|
import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
|
|
8
8
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
9
9
|
import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
|
|
10
|
-
import { t as exportJwk } from "../key-
|
|
11
|
-
import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-
|
|
10
|
+
import { t as exportJwk } from "../key-ClQh9Qqh.mjs";
|
|
11
|
+
import { a as parseRfc9421Signature, c as timingSafeEqual, i as formatRfc9421SignatureParameters, l as verifyRequest, n as doubleKnock, o as parseRfc9421SignatureInput, r as formatRfc9421Signature, s as signRequest, t as createRfc9421SignatureBase, u as verifyRequestDetailed } from "../http-Bjd6I92u.mjs";
|
|
12
12
|
import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-CtZLJq76.mjs";
|
|
13
|
-
import { t as KvKeyCache } from "../keycache-
|
|
13
|
+
import { t as KvKeyCache } from "../keycache-DahCaG_m.mjs";
|
|
14
14
|
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
15
15
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
16
16
|
import { FetchError, UrlError, exportSpki } from "@fedify/vocab-runtime";
|
package/dist/sig/key.test.mjs
CHANGED
|
@@ -3,12 +3,12 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import { n as assertStrictEquals } from "../std__assert-DflMZha5.mjs";
|
|
6
|
-
import { t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
|
|
6
|
+
import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
|
|
7
7
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
8
8
|
import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
|
|
9
|
-
import { a as generateCryptoKeyPair, i as fetchKeyDetailed, o as importJwk, r as fetchKey, s as validateCryptoKey, t as exportJwk } from "../key-
|
|
9
|
+
import { a as generateCryptoKeyPair, i as fetchKeyDetailed, o as importJwk, r as fetchKey, s as validateCryptoKey, t as exportJwk } from "../key-ClQh9Qqh.mjs";
|
|
10
10
|
import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
|
|
11
|
-
import { g as wrapContextLoaderForJsonLd } from "../ld-
|
|
11
|
+
import { g as wrapContextLoaderForJsonLd } from "../ld-Crg0Xmwr.mjs";
|
|
12
12
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
13
13
|
import { CryptographicKey, Multikey, Person } from "@fedify/vocab";
|
|
14
14
|
import { FetchError, UrlError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
@@ -759,5 +759,199 @@ test("fetchKey() records the controller an actor document establishes", async ()
|
|
|
759
759
|
assertEquals(key?.controllerId, new URL(actorId));
|
|
760
760
|
assert(key?.publicKey != null);
|
|
761
761
|
});
|
|
762
|
+
test("fetchKey() rejects a key whose owner redirects to another actor", async () => {
|
|
763
|
+
const keyId = "https://evil.example/keys/1";
|
|
764
|
+
const victim = "https://victim.example/users/alice";
|
|
765
|
+
const mallory = "https://evil.example/users/mallory";
|
|
766
|
+
const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
767
|
+
const cache = {};
|
|
768
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, {
|
|
769
|
+
documentLoader(resource) {
|
|
770
|
+
if (resource === keyId) return Promise.resolve({
|
|
771
|
+
contextUrl: null,
|
|
772
|
+
documentUrl: resource,
|
|
773
|
+
document: {
|
|
774
|
+
"@context": "https://w3id.org/security/v1",
|
|
775
|
+
id: keyId,
|
|
776
|
+
type: "CryptographicKey",
|
|
777
|
+
owner: victim,
|
|
778
|
+
publicKeyPem
|
|
779
|
+
}
|
|
780
|
+
});
|
|
781
|
+
if (resource === victim || resource === mallory) return Promise.resolve({
|
|
782
|
+
contextUrl: null,
|
|
783
|
+
documentUrl: mallory,
|
|
784
|
+
document: {
|
|
785
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
786
|
+
id: mallory,
|
|
787
|
+
type: "Person",
|
|
788
|
+
publicKey: keyId
|
|
789
|
+
}
|
|
790
|
+
});
|
|
791
|
+
return mockDocumentLoader(resource);
|
|
792
|
+
},
|
|
793
|
+
contextLoader: mockDocumentLoader,
|
|
794
|
+
keyCache: {
|
|
795
|
+
get(keyId) {
|
|
796
|
+
return Promise.resolve(cache[keyId.href]);
|
|
797
|
+
},
|
|
798
|
+
set(keyId, key) {
|
|
799
|
+
cache[keyId.href] = key;
|
|
800
|
+
return Promise.resolve();
|
|
801
|
+
}
|
|
802
|
+
}
|
|
803
|
+
}), {
|
|
804
|
+
key: null,
|
|
805
|
+
cached: false
|
|
806
|
+
});
|
|
807
|
+
assertEquals(cache, { [keyId]: null });
|
|
808
|
+
});
|
|
809
|
+
test("fetchKey() rejects a key whose owner resolves to another actor on the same origin", async () => {
|
|
810
|
+
const keyId = "https://victim.example/keys/bob";
|
|
811
|
+
const victim = "https://victim.example/users/alice";
|
|
812
|
+
const bob = "https://victim.example/users/bob";
|
|
813
|
+
const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
814
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, {
|
|
815
|
+
documentLoader(resource) {
|
|
816
|
+
if (resource === keyId) return Promise.resolve({
|
|
817
|
+
contextUrl: null,
|
|
818
|
+
documentUrl: resource,
|
|
819
|
+
document: {
|
|
820
|
+
"@context": "https://w3id.org/security/v1",
|
|
821
|
+
id: keyId,
|
|
822
|
+
type: "CryptographicKey",
|
|
823
|
+
owner: victim,
|
|
824
|
+
publicKeyPem
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
if (resource === victim || resource === bob) return Promise.resolve({
|
|
828
|
+
contextUrl: null,
|
|
829
|
+
documentUrl: resource,
|
|
830
|
+
document: {
|
|
831
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
832
|
+
id: bob,
|
|
833
|
+
type: "Person",
|
|
834
|
+
publicKey: keyId
|
|
835
|
+
}
|
|
836
|
+
});
|
|
837
|
+
return mockDocumentLoader(resource);
|
|
838
|
+
},
|
|
839
|
+
contextLoader: mockDocumentLoader
|
|
840
|
+
}), {
|
|
841
|
+
key: null,
|
|
842
|
+
cached: false
|
|
843
|
+
});
|
|
844
|
+
});
|
|
845
|
+
test("fetchKey() rejects a Multikey whose controller redirects to another actor", async () => {
|
|
846
|
+
const keyId = "https://evil.example/keys/ed25519";
|
|
847
|
+
const victim = "https://victim.example/users/alice";
|
|
848
|
+
const mallory = "https://evil.example/users/mallory";
|
|
849
|
+
const multikeyDocument = await ed25519Multikey.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
850
|
+
assertEquals(await fetchKey(keyId, Multikey, {
|
|
851
|
+
documentLoader(resource) {
|
|
852
|
+
if (resource === keyId) return Promise.resolve({
|
|
853
|
+
contextUrl: null,
|
|
854
|
+
documentUrl: resource,
|
|
855
|
+
document: {
|
|
856
|
+
...multikeyDocument,
|
|
857
|
+
id: keyId,
|
|
858
|
+
controller: victim
|
|
859
|
+
}
|
|
860
|
+
});
|
|
861
|
+
if (resource === victim || resource === mallory) return Promise.resolve({
|
|
862
|
+
contextUrl: null,
|
|
863
|
+
documentUrl: mallory,
|
|
864
|
+
document: {
|
|
865
|
+
"@context": [
|
|
866
|
+
"https://www.w3.org/ns/activitystreams",
|
|
867
|
+
"https://w3id.org/security/v1",
|
|
868
|
+
"https://w3id.org/security/multikey/v1",
|
|
869
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
870
|
+
"https://www.w3.org/ns/did/v1"
|
|
871
|
+
],
|
|
872
|
+
id: mallory,
|
|
873
|
+
type: "Person",
|
|
874
|
+
assertionMethod: [keyId]
|
|
875
|
+
}
|
|
876
|
+
});
|
|
877
|
+
return mockDocumentLoader(resource);
|
|
878
|
+
},
|
|
879
|
+
contextLoader: mockDocumentLoader
|
|
880
|
+
}), {
|
|
881
|
+
key: null,
|
|
882
|
+
cached: false
|
|
883
|
+
});
|
|
884
|
+
});
|
|
885
|
+
test("fetchKey() accepts an owner whose document URL differs from its id", async () => {
|
|
886
|
+
const keyId = "https://victim.example/keys/alice";
|
|
887
|
+
const alice = "https://victim.example/users/alice";
|
|
888
|
+
const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
889
|
+
const { key, cached } = await fetchKey(keyId, CryptographicKey, {
|
|
890
|
+
documentLoader(resource) {
|
|
891
|
+
if (resource === keyId) return Promise.resolve({
|
|
892
|
+
contextUrl: null,
|
|
893
|
+
documentUrl: resource,
|
|
894
|
+
document: {
|
|
895
|
+
"@context": "https://w3id.org/security/v1",
|
|
896
|
+
id: keyId,
|
|
897
|
+
type: "CryptographicKey",
|
|
898
|
+
owner: alice,
|
|
899
|
+
publicKeyPem
|
|
900
|
+
}
|
|
901
|
+
});
|
|
902
|
+
if (resource === alice) return Promise.resolve({
|
|
903
|
+
contextUrl: null,
|
|
904
|
+
documentUrl: `${alice}.json`,
|
|
905
|
+
document: {
|
|
906
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
907
|
+
id: alice,
|
|
908
|
+
type: "Person",
|
|
909
|
+
publicKey: keyId
|
|
910
|
+
}
|
|
911
|
+
});
|
|
912
|
+
return mockDocumentLoader(resource);
|
|
913
|
+
},
|
|
914
|
+
contextLoader: mockDocumentLoader
|
|
915
|
+
});
|
|
916
|
+
assertFalse(cached);
|
|
917
|
+
assertEquals(key?.id, new URL(keyId));
|
|
918
|
+
assertEquals(key?.ownerId, new URL(alice));
|
|
919
|
+
});
|
|
920
|
+
test("fetchKey() rejects an owner reached through a normalization redirect", async () => {
|
|
921
|
+
const keyId = "https://victim.example/keys/alice";
|
|
922
|
+
const canonical = "https://victim.example/users/alice";
|
|
923
|
+
const nonCanonical = "https://victim.example/users/Alice";
|
|
924
|
+
const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
925
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, {
|
|
926
|
+
documentLoader(resource) {
|
|
927
|
+
if (resource === keyId) return Promise.resolve({
|
|
928
|
+
contextUrl: null,
|
|
929
|
+
documentUrl: resource,
|
|
930
|
+
document: {
|
|
931
|
+
"@context": "https://w3id.org/security/v1",
|
|
932
|
+
id: keyId,
|
|
933
|
+
type: "CryptographicKey",
|
|
934
|
+
owner: nonCanonical,
|
|
935
|
+
publicKeyPem
|
|
936
|
+
}
|
|
937
|
+
});
|
|
938
|
+
if (resource === canonical || resource === nonCanonical) return Promise.resolve({
|
|
939
|
+
contextUrl: null,
|
|
940
|
+
documentUrl: canonical,
|
|
941
|
+
document: {
|
|
942
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
943
|
+
id: canonical,
|
|
944
|
+
type: "Person",
|
|
945
|
+
publicKey: keyId
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
return mockDocumentLoader(resource);
|
|
949
|
+
},
|
|
950
|
+
contextLoader: mockDocumentLoader
|
|
951
|
+
}), {
|
|
952
|
+
key: null,
|
|
953
|
+
cached: false
|
|
954
|
+
});
|
|
955
|
+
});
|
|
762
956
|
//#endregion
|
|
763
957
|
export {};
|
package/dist/sig/ld.test.mjs
CHANGED
|
@@ -5,9 +5,9 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
5
5
|
import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
|
|
6
6
|
import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
|
|
7
7
|
import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
|
|
8
|
-
import { a as generateCryptoKeyPair } from "../key-
|
|
8
|
+
import { a as generateCryptoKeyPair } from "../key-ClQh9Qqh.mjs";
|
|
9
9
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
|
|
10
|
-
import { a as compactJsonLd, d as isInvalidUrlTypeError, f as signJsonLd, h as verifySignature, i as attachSignature, m as verifyJsonLd, n as UnsafeJsonLdError, o as createSignature, s as detachSignature } from "../ld-
|
|
10
|
+
import { a as compactJsonLd, d as isInvalidUrlTypeError, f as signJsonLd, h as verifySignature, i as attachSignature, m as verifyJsonLd, n as UnsafeJsonLdError, o as createSignature, s as detachSignature } from "../ld-Crg0Xmwr.mjs";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
import { CryptographicKey } from "@fedify/vocab";
|
|
13
13
|
import { encodeBase64 } from "byte-encodings/base64";
|
|
@@ -818,5 +818,50 @@ test("verifyJsonLd() rejects a key that claims a forged owner", async () => {
|
|
|
818
818
|
contextLoader: mockDocumentLoader
|
|
819
819
|
}));
|
|
820
820
|
});
|
|
821
|
+
test("verifyJsonLd() rejects a key whose owner redirects to another actor", async () => {
|
|
822
|
+
const keyId = new URL("https://evil.example/keys/1");
|
|
823
|
+
const victim = "https://victim.example/users/alice";
|
|
824
|
+
const mallory = "https://evil.example/users/mallory";
|
|
825
|
+
const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
826
|
+
const signed = await signJsonLd({
|
|
827
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
828
|
+
id: "https://victim.example/activities/forged",
|
|
829
|
+
type: "Create",
|
|
830
|
+
actor: victim,
|
|
831
|
+
object: {
|
|
832
|
+
type: "Note",
|
|
833
|
+
content: "forged"
|
|
834
|
+
}
|
|
835
|
+
}, rsaPrivateKey3, keyId, { contextLoader: mockDocumentLoader });
|
|
836
|
+
const options = {
|
|
837
|
+
documentLoader(resource) {
|
|
838
|
+
if (resource === keyId.href) return Promise.resolve({
|
|
839
|
+
contextUrl: null,
|
|
840
|
+
documentUrl: resource,
|
|
841
|
+
document: {
|
|
842
|
+
"@context": "https://w3id.org/security/v1",
|
|
843
|
+
id: keyId.href,
|
|
844
|
+
type: "CryptographicKey",
|
|
845
|
+
owner: victim,
|
|
846
|
+
publicKeyPem
|
|
847
|
+
}
|
|
848
|
+
});
|
|
849
|
+
if (resource === victim || resource === mallory) return Promise.resolve({
|
|
850
|
+
contextUrl: null,
|
|
851
|
+
documentUrl: mallory,
|
|
852
|
+
document: {
|
|
853
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
854
|
+
id: mallory,
|
|
855
|
+
type: "Person",
|
|
856
|
+
publicKey: keyId.href
|
|
857
|
+
}
|
|
858
|
+
});
|
|
859
|
+
return mockDocumentLoader(resource);
|
|
860
|
+
},
|
|
861
|
+
contextLoader: mockDocumentLoader
|
|
862
|
+
};
|
|
863
|
+
assertEquals(await verifySignature(signed, options), null);
|
|
864
|
+
assertFalse(await verifyJsonLd(signed, options));
|
|
865
|
+
});
|
|
821
866
|
//#endregion
|
|
822
867
|
export {};
|
package/dist/sig/mod.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const require_http = require("../http-
|
|
5
|
-
const require_proof = require("../proof-
|
|
4
|
+
const require_http = require("../http-BoR1M3W7.cjs");
|
|
5
|
+
const require_proof = require("../proof-CHXVlsH_.cjs");
|
|
6
6
|
exports.attachSignature = require_proof.attachSignature;
|
|
7
7
|
exports.createProof = require_proof.createProof;
|
|
8
8
|
exports.createSignature = require_proof.createSignature;
|
package/dist/sig/mod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { _ as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKey, d as importJwk, g as parseAcceptSignature, h as fulfillAcceptSignature, i as verifyRequest, l as fetchKeyDetailed, m as formatAcceptSignature, o as exportJwk, r as signRequest, u as generateCryptoKeyPair } from "../http-
|
|
4
|
-
import { _ as signJsonLd, a as doesActorOwnKey, b as verifySignature, d as createSignature, f as detachSignature, i as verifyProof, l as attachSignature, n as signObject, o as getKeyOwner, r as verifyObject, t as createProof, y as verifyJsonLd } from "../proof-
|
|
3
|
+
import { _ as validateAcceptSignature, a as verifyRequestDetailed, c as fetchKey, d as importJwk, g as parseAcceptSignature, h as fulfillAcceptSignature, i as verifyRequest, l as fetchKeyDetailed, m as formatAcceptSignature, o as exportJwk, r as signRequest, u as generateCryptoKeyPair } from "../http-CK3efjgM.js";
|
|
4
|
+
import { _ as signJsonLd, a as doesActorOwnKey, b as verifySignature, d as createSignature, f as detachSignature, i as verifyProof, l as attachSignature, n as signObject, o as getKeyOwner, r as verifyObject, t as createProof, y as verifyJsonLd } from "../proof-7R4s10TJ.js";
|
|
5
5
|
export { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getKeyOwner, importJwk, parseAcceptSignature, signJsonLd, signObject, signRequest, validateAcceptSignature, verifyJsonLd, verifyObject, verifyProof, verifyRequest, verifyRequestDetailed, verifySignature };
|
package/dist/sig/owner.test.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import "../std__assert-DflMZha5.mjs";
|
|
|
6
6
|
import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
|
|
7
7
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
8
8
|
import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-CtZLJq76.mjs";
|
|
9
|
-
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-
|
|
9
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-BRoKojK1.mjs";
|
|
10
10
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
11
11
|
import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
|
|
12
12
|
//#region src/sig/owner.test.ts
|
|
@@ -153,5 +153,50 @@ test("doesActorOwnKey() matches a key that leaves its id implicit", async () =>
|
|
|
153
153
|
publicKey: rsaPublicKey2.publicKey
|
|
154
154
|
}), options));
|
|
155
155
|
});
|
|
156
|
+
test("doesActorOwnKey() rejects an actor ID that redirects to the key's owner", async () => {
|
|
157
|
+
const keyId = "https://evil.example/keys/1";
|
|
158
|
+
const victim = "https://victim.example/users/alice";
|
|
159
|
+
const mallory = "https://evil.example/users/mallory";
|
|
160
|
+
const { publicKeyPem } = await rsaPublicKey1.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
161
|
+
const serveKeyOwnedBy = (owner) => ({
|
|
162
|
+
documentLoader(resource) {
|
|
163
|
+
if (resource === keyId) return Promise.resolve({
|
|
164
|
+
contextUrl: null,
|
|
165
|
+
documentUrl: resource,
|
|
166
|
+
document: {
|
|
167
|
+
"@context": "https://w3id.org/security/v1",
|
|
168
|
+
id: keyId,
|
|
169
|
+
type: "CryptographicKey",
|
|
170
|
+
owner,
|
|
171
|
+
publicKeyPem
|
|
172
|
+
}
|
|
173
|
+
});
|
|
174
|
+
if (resource === victim || resource === mallory) return Promise.resolve({
|
|
175
|
+
contextUrl: null,
|
|
176
|
+
documentUrl: mallory,
|
|
177
|
+
document: {
|
|
178
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
179
|
+
id: mallory,
|
|
180
|
+
type: "Person",
|
|
181
|
+
publicKey: keyId
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
return mockDocumentLoader(resource);
|
|
185
|
+
},
|
|
186
|
+
contextLoader: mockDocumentLoader
|
|
187
|
+
});
|
|
188
|
+
const activity = new Create({ actor: new URL(victim) });
|
|
189
|
+
assertFalse(await doesActorOwnKey(activity, new CryptographicKey({
|
|
190
|
+
id: new URL(keyId),
|
|
191
|
+
owner: new URL(mallory),
|
|
192
|
+
publicKey: rsaPublicKey1.publicKey
|
|
193
|
+
}), serveKeyOwnedBy(mallory)));
|
|
194
|
+
assertFalse(await doesActorOwnKey(activity, new CryptographicKey({
|
|
195
|
+
id: new URL(keyId),
|
|
196
|
+
owner: new URL(victim),
|
|
197
|
+
publicKey: rsaPublicKey1.publicKey
|
|
198
|
+
}), serveKeyOwnedBy(victim)));
|
|
199
|
+
assertEquals(await getKeyOwner(new URL(keyId), serveKeyOwnedBy(victim)), null);
|
|
200
|
+
});
|
|
156
201
|
//#endregion
|
|
157
202
|
export {};
|
package/dist/sig/proof.test.mjs
CHANGED
|
@@ -6,7 +6,7 @@ import "../std__assert-DflMZha5.mjs";
|
|
|
6
6
|
import { n as assertInstanceOf } from "../assert-BhQd8QHP.mjs";
|
|
7
7
|
import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
|
|
8
8
|
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
|
|
9
|
-
import { i as verifyProof, n as signObject, r as verifyObject, t as createProof } from "../proof-
|
|
9
|
+
import { i as verifyProof, n as signObject, r as verifyObject, t as createProof } from "../proof-DMIAezxz.mjs";
|
|
10
10
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
11
11
|
import { Create, DataIntegrityProof, Multikey, Note, Place } from "@fedify/vocab";
|
|
12
12
|
import { decodeMultibase, importMultibaseKey } from "@fedify/vocab-runtime";
|
|
@@ -322,5 +322,56 @@ test("verifyObject() rejects a key that claims a forged controller", async () =>
|
|
|
322
322
|
contextLoader: mockDocumentLoader
|
|
323
323
|
}), null);
|
|
324
324
|
});
|
|
325
|
+
test("verifyObject() rejects a key whose controller redirects to another actor", async () => {
|
|
326
|
+
const keyId = new URL("https://evil.example/keys/ed25519");
|
|
327
|
+
const victim = "https://victim.example/users/alice";
|
|
328
|
+
const mallory = "https://evil.example/users/mallory";
|
|
329
|
+
const multikeyDocument = await ed25519Multikey.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
330
|
+
const signOptions = {
|
|
331
|
+
format: "compact",
|
|
332
|
+
contextLoader: mockDocumentLoader,
|
|
333
|
+
documentLoader: mockDocumentLoader,
|
|
334
|
+
context: ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"]
|
|
335
|
+
};
|
|
336
|
+
assertEquals(await verifyObject(Create, await (await signObject(new Create({
|
|
337
|
+
id: new URL("https://victim.example/activities/forged"),
|
|
338
|
+
actor: new URL(victim),
|
|
339
|
+
object: new Note({
|
|
340
|
+
id: new URL("https://victim.example/notes/forged"),
|
|
341
|
+
attribution: new URL(victim),
|
|
342
|
+
content: "forged"
|
|
343
|
+
})
|
|
344
|
+
}), ed25519PrivateKey, keyId, signOptions)).toJsonLd(signOptions), {
|
|
345
|
+
documentLoader(resource) {
|
|
346
|
+
if (resource === keyId.href) return Promise.resolve({
|
|
347
|
+
contextUrl: null,
|
|
348
|
+
documentUrl: resource,
|
|
349
|
+
document: {
|
|
350
|
+
...multikeyDocument,
|
|
351
|
+
id: keyId.href,
|
|
352
|
+
controller: victim
|
|
353
|
+
}
|
|
354
|
+
});
|
|
355
|
+
if (resource === victim || resource === mallory) return Promise.resolve({
|
|
356
|
+
contextUrl: null,
|
|
357
|
+
documentUrl: mallory,
|
|
358
|
+
document: {
|
|
359
|
+
"@context": [
|
|
360
|
+
"https://www.w3.org/ns/activitystreams",
|
|
361
|
+
"https://w3id.org/security/v1",
|
|
362
|
+
"https://w3id.org/security/multikey/v1",
|
|
363
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
364
|
+
"https://www.w3.org/ns/did/v1"
|
|
365
|
+
],
|
|
366
|
+
id: mallory,
|
|
367
|
+
type: "Person",
|
|
368
|
+
assertionMethod: [keyId.href]
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
return mockDocumentLoader(resource);
|
|
372
|
+
},
|
|
373
|
+
contextLoader: mockDocumentLoader
|
|
374
|
+
}), null);
|
|
375
|
+
});
|
|
325
376
|
//#endregion
|
|
326
377
|
export {};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { c as getNormalizationContextLoader } from "./ld-
|
|
4
|
+
import { c as getNormalizationContextLoader } from "./ld-Crg0Xmwr.mjs";
|
|
5
5
|
import jsonld from "@fedify/vocab-runtime/jsonld";
|
|
6
6
|
//#region src/federation/temporal.ts
|
|
7
7
|
function isPlainObject(value) {
|
|
@@ -5,9 +5,9 @@ import { t as esm_default } from "../esm-DVILvP5e.mjs";
|
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
6
|
import "../std__assert-DflMZha5.mjs";
|
|
7
7
|
import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
|
|
8
|
-
import { l as verifyRequest } from "../http-
|
|
8
|
+
import { l as verifyRequest } from "../http-Bjd6I92u.mjs";
|
|
9
9
|
import { i as rsaPrivateKey2 } from "../keys-CtZLJq76.mjs";
|
|
10
|
-
import { t as getAuthenticatedDocumentLoader } from "../docloader-
|
|
10
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-OLWc7P2D.mjs";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
import { FetchError, UrlError } from "@fedify/vocab-runtime";
|
|
13
13
|
import { configure, reset } from "@logtape/logtape";
|
|
@@ -450,6 +450,70 @@ const unsupportedUrls = [
|
|
|
450
450
|
"file:///collection",
|
|
451
451
|
`data:application/ld+json,${encodeURIComponent(JSON.stringify({ id: "https://example.com/data" }))}`
|
|
452
452
|
];
|
|
453
|
+
function isCredentialUrlError(error) {
|
|
454
|
+
return error instanceof UrlError && error.reason === "disallowed" && error.message === "URLs with credentials are not allowed";
|
|
455
|
+
}
|
|
456
|
+
test("getAuthenticatedDocumentLoader() rejects URLs with credentials", async (t) => {
|
|
457
|
+
const identity = {
|
|
458
|
+
keyId: new URL("https://example.com/key2"),
|
|
459
|
+
privateKey: rsaPrivateKey2
|
|
460
|
+
};
|
|
461
|
+
const start = "https://8.8.8.8/start";
|
|
462
|
+
const target = "https://user:pass@8.8.8.8/document";
|
|
463
|
+
for (const allowPrivateAddress of [false, true]) {
|
|
464
|
+
const loader = getAuthenticatedDocumentLoader(identity, { allowPrivateAddress });
|
|
465
|
+
for (const path of [
|
|
466
|
+
"direct",
|
|
467
|
+
"redirect",
|
|
468
|
+
"Link",
|
|
469
|
+
"HTML"
|
|
470
|
+
]) await t.step(`${path}, allowPrivateAddress=${allowPrivateAddress}`, async () => {
|
|
471
|
+
await withFetchStub((request) => {
|
|
472
|
+
if (request.url !== start) return Response.json({});
|
|
473
|
+
if (path === "redirect") return Response.redirect(target, 302);
|
|
474
|
+
if (path === "HTML") return new Response(`<link rel="alternate" type="application/activity+json" href="${target}">`, { headers: { "Content-Type": "text/html" } });
|
|
475
|
+
return new Response("", { headers: {
|
|
476
|
+
"Content-Type": "text/plain",
|
|
477
|
+
Link: `<${target}>; rel="alternate"; type="application/activity+json"`
|
|
478
|
+
} });
|
|
479
|
+
}, async (fetched) => {
|
|
480
|
+
await rejects(loader(path === "direct" ? target : start), isCredentialUrlError);
|
|
481
|
+
deepStrictEqual(fetched.map((r) => r.url), path === "direct" ? [] : [start]);
|
|
482
|
+
});
|
|
483
|
+
});
|
|
484
|
+
for (const url of [
|
|
485
|
+
"https://user@8.8.8.8/document",
|
|
486
|
+
"https://:pass@8.8.8.8/document",
|
|
487
|
+
"https://%75ser:p%40ss@8.8.8.8/document",
|
|
488
|
+
"http://user:pass@8.8.8.8/document"
|
|
489
|
+
]) await t.step(`${url}, allowPrivateAddress=${allowPrivateAddress}`, async () => {
|
|
490
|
+
await withFetchStub(() => Response.json({}), async (fetched) => {
|
|
491
|
+
await rejects(loader(url), isCredentialUrlError);
|
|
492
|
+
deepStrictEqual(fetched, []);
|
|
493
|
+
});
|
|
494
|
+
});
|
|
495
|
+
for (const url of ["https://:@8.8.8.8/document", "https://8.8.8.8/@user?q=@pass"]) await t.step(`allows ${url}, allowPrivateAddress=${allowPrivateAddress}`, async () => {
|
|
496
|
+
await withFetchStub(() => Response.json({ done: true }), async (fetched) => {
|
|
497
|
+
deepStrictEqual((await loader(url)).document, { done: true });
|
|
498
|
+
deepStrictEqual(fetched.map((r) => r.url), [new URL(url).href]);
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
}
|
|
502
|
+
for (const firstSpec of ["rfc9421", "draft-cavage-http-signatures-12"]) await t.step(`redirect after fallback from ${firstSpec}`, async () => {
|
|
503
|
+
const loader = getAuthenticatedDocumentLoader(identity, {
|
|
504
|
+
allowPrivateAddress: true,
|
|
505
|
+
specDeterminer: {
|
|
506
|
+
determineSpec: () => firstSpec,
|
|
507
|
+
rememberSpec: () => {}
|
|
508
|
+
}
|
|
509
|
+
});
|
|
510
|
+
await withFetchStub((request) => request.url !== start ? Response.json({}) : request.headers.has("Signature-Input") === (firstSpec === "rfc9421") ? new Response(null, { status: 401 }) : Response.redirect(target, 302), async (fetched) => {
|
|
511
|
+
await rejects(loader(start), isCredentialUrlError);
|
|
512
|
+
deepStrictEqual(fetched.map((r) => r.url), [start, start]);
|
|
513
|
+
deepStrictEqual(fetched.map((r) => r.headers.has("Signature-Input")), [firstSpec === "rfc9421", firstSpec !== "rfc9421"]);
|
|
514
|
+
});
|
|
515
|
+
});
|
|
516
|
+
});
|
|
453
517
|
function isUnsupportedProtocolError(error, url) {
|
|
454
518
|
return error instanceof UrlError && error.message === `Unsupported protocol: ${new URL(url).protocol}` && error.reason === "disallowed";
|
|
455
519
|
}
|
package/dist/utils/mod.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
|
-
const require_kv_cache = require("../kv-cache-
|
|
4
|
+
const require_kv_cache = require("../kv-cache-BxSx_Iyp.cjs");
|
|
5
5
|
exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
|
|
6
6
|
exports.kvCache = require_kv_cache.kvCache;
|