@fedify/fedify 2.1.28 → 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/{assert_rejects-B-qJtC9Z.mjs → assert_rejects-WyYSTDDX.mjs} +2 -20
- package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-D4DNWrux.mjs} +19 -1
- package/dist/{builder-CW1BrLbm.mjs → builder-CTpfuuVp.mjs} +3 -3
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{deno-CJgU2mcr.mjs → deno-BATJ1hq6.mjs} +1 -1
- package/dist/{docloader-o3fCIlIa.mjs → docloader-OLWc7P2D.mjs} +6 -2
- package/dist/federation/builder.test.mjs +3 -3
- package/dist/federation/collection.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +262 -9
- package/dist/federation/idempotency.test.mjs +3 -3
- package/dist/federation/inbox.test.mjs +25 -2
- package/dist/federation/keycache.test.mjs +18 -7
- package/dist/federation/kv.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +128 -10
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +2 -2
- package/dist/federation/negotiation.test.mjs +2 -2
- package/dist/federation/retry.test.mjs +1 -1
- package/dist/federation/router.test.mjs +2 -3
- package/dist/federation/send.test.mjs +7 -6
- package/dist/federation/temporal.test.mjs +3 -3
- package/dist/federation/webfinger.test.mjs +2 -2
- package/dist/{http-Dcj1ulAh.mjs → http-Bjd6I92u.mjs} +2 -2
- package/dist/{http-EEfKB8Qb.cjs → http-BoR1M3W7.cjs} +17 -3
- package/dist/{http-DtypHuuK.js → http-CK3efjgM.js} +17 -3
- package/dist/{inbox-CVYVJI0M.mjs → inbox-9MlBGgs9.mjs} +23 -10
- package/dist/{key-DRLvwDTh.mjs → key-ClQh9Qqh.mjs} +17 -3
- package/dist/{keycache-RFlZObU3.mjs → keycache-DahCaG_m.mjs} +1 -1
- package/dist/{kv-cache-BWVKAAmc.cjs → kv-cache-BxSx_Iyp.cjs} +5 -1
- package/dist/{kv-cache-CEJCaF4E.js → kv-cache-ImApO425.js} +5 -1
- package/dist/{ld-C5BZ98YK.mjs → ld-Crg0Xmwr.mjs} +2 -2
- package/dist/{middleware-CqQoREZ9.mjs → middleware-Bi5D6DBT.mjs} +1 -1
- package/dist/{middleware-wCgWm4Eh.js → middleware-C2AJFk8W.js} +96 -26
- package/dist/{middleware-SSrXiJIV.mjs → middleware-CE0b69gj.mjs} +83 -26
- package/dist/{middleware-Dw9sPiec.cjs → middleware-CmD3lpy4.cjs} +97 -27
- package/dist/{middleware-DZxmsbPB.cjs → middleware-jL9p9V9G.cjs} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/client.test.mjs +1 -1
- package/dist/nodeinfo/handler.test.mjs +2 -2
- package/dist/nodeinfo/types.test.mjs +2 -2
- package/dist/otel/exporter.test.mjs +1 -1
- package/dist/{owner-cPOoPvmr.mjs → owner-BRoKojK1.mjs} +2 -2
- package/dist/{proof-DPU3poip.js → proof-7R4s10TJ.js} +1 -1
- package/dist/{proof-De1y2j-e.cjs → proof-CHXVlsH_.cjs} +1 -1
- package/dist/{proof-BTknCsN7.mjs → proof-DMIAezxz.mjs} +2 -2
- package/dist/{send-DDuHNgHz.mjs → send-BHIt_8ia.mjs} +2 -2
- package/dist/sig/http.test.mjs +6 -6
- package/dist/sig/key.test.mjs +199 -5
- package/dist/sig/ld.test.mjs +49 -4
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +48 -3
- package/dist/sig/proof.test.mjs +54 -3
- package/dist/{std__assert-BUOJXi-Z.mjs → std__assert-DflMZha5.mjs} +2 -2
- package/dist/{temporal-CxXY--ZL.mjs → temporal-DR0JahMu.mjs} +1 -1
- package/dist/utils/docloader.test.mjs +178 -39
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +5 -5
- /package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-BkxW5QJI.mjs} +0 -0
|
@@ -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
|
@@ -3,14 +3,14 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as esm_default } from "../esm-DVILvP5e.mjs";
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
|
-
import { i as assertExists, t as assertStringIncludes } from "../std__assert-
|
|
7
|
-
import {
|
|
6
|
+
import { i as assertExists, t as assertStringIncludes } from "../std__assert-DflMZha5.mjs";
|
|
7
|
+
import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
|
|
8
8
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
9
|
-
import { t as
|
|
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-
|
|
9
|
+
import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
|
|
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
|
@@ -2,13 +2,13 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import { n as assertStrictEquals } from "../std__assert-
|
|
6
|
-
import { t as
|
|
5
|
+
import { n as assertStrictEquals } from "../std__assert-DflMZha5.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
|
-
import { t as
|
|
9
|
-
import { a as generateCryptoKeyPair, i as fetchKeyDetailed, o as importJwk, r as fetchKey, s as validateCryptoKey, t as exportJwk } from "../key-
|
|
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-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
|
@@ -2,12 +2,12 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import {
|
|
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
|
-
import { t as
|
|
8
|
-
import { a as generateCryptoKeyPair } from "../key-
|
|
7
|
+
import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
|
|
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
|
@@ -2,11 +2,11 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import {
|
|
5
|
+
import "../std__assert-DflMZha5.mjs";
|
|
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
|
@@ -2,11 +2,11 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
5
|
+
import "../std__assert-DflMZha5.mjs";
|
|
7
6
|
import { n as assertInstanceOf } from "../assert-BhQd8QHP.mjs";
|
|
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 {};
|
|
@@ -2,8 +2,8 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { a as red, i as buildMessage, l as AssertionError, n as diffStr, r as diff, s as format } from "./assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import "./
|
|
6
|
-
import "./
|
|
5
|
+
import "./assert_throws-D4DNWrux.mjs";
|
|
6
|
+
import "./assert_rejects-WyYSTDDX.mjs";
|
|
7
7
|
//#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert_exists.js
|
|
8
8
|
/**
|
|
9
9
|
* Make an assertion that actual is not null or undefined.
|
|
@@ -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) {
|