@fedify/fedify 2.3.12 → 2.3.14
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-DN60FHPX.mjs → assert_rejects-D1HYAik3.mjs} +2 -20
- package/dist/{assert_throws-BOkhLGYc.mjs → assert_throws-BbSMEFKo.mjs} +19 -1
- package/dist/{builder-B6ixdT3y.mjs → builder-C6yXExXl.mjs} +2 -2
- package/dist/compat/transformers.test.mjs +2 -2
- package/dist/{deno-D4dcoVfF.mjs → deno-y3L4Oa94.mjs} +1 -1
- package/dist/{docloader-NOKfswJV.mjs → docloader-yuyzZC9a.mjs} +6 -2
- package/dist/federation/builder.test.mjs +3 -3
- package/dist/federation/circuit-breaker.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 -1
- package/dist/federation/keycache.test.mjs +19 -8
- package/dist/federation/kv.test.mjs +1 -1
- package/dist/federation/metrics.test.mjs +3 -3
- package/dist/federation/middleware.test.mjs +177 -15
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +4 -3
- package/dist/federation/negotiation.test.mjs +4 -4
- package/dist/federation/retry.test.mjs +1 -1
- package/dist/federation/router.test.mjs +3 -4
- package/dist/federation/send.test.mjs +7 -6
- package/dist/federation/temporal.test.mjs +4 -4
- package/dist/federation/webfinger.test.mjs +2 -2
- package/dist/{http-HjidyDfF.mjs → http-BCSf1KIY.mjs} +3 -3
- package/dist/{http-D_Xrr6kp.cjs → http-D77Wjrcg.cjs} +17 -3
- package/dist/{http-DkyUBs_T.js → http-DNM9KyIO.js} +17 -3
- package/dist/inbox-NObX26c9.mjs +180 -0
- package/dist/{key-Dg-NXm4K.mjs → key-APURZ0ky.mjs} +18 -4
- package/dist/{keycache-Dkc_sflV.mjs → keycache-BimEQucx.mjs} +1 -1
- package/dist/{kv-cache-BwnC6JGt.cjs → kv-cache-Bg4utAuv.cjs} +5 -1
- package/dist/{kv-cache-BpVwvcSI.mjs → kv-cache-C69dzgQi.mjs} +1 -1
- package/dist/{kv-cache-BhGeZk_o.js → kv-cache-LBCwHNLu.js} +5 -1
- package/dist/{ld-C1wveXXf.mjs → ld-BoLqbDaL.mjs} +3 -3
- package/dist/{metrics-cIaMxG0v.mjs → metrics-DBSl8wEr.mjs} +1 -1
- package/dist/{middleware-DhOFTXmo.cjs → middleware-BQUQ0pPl.cjs} +107 -35
- package/dist/{middleware-CnrzVu9i.js → middleware-CRd1JmuL.js} +107 -35
- package/dist/{middleware-I-XlrRVl.mjs → middleware-CZ8tI1qL.mjs} +97 -195
- package/dist/{middleware-VxPpU0h_.mjs → middleware-DAqo2eOY.mjs} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/client.test.mjs +2 -2
- 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-CFKfE85G.mjs → owner-DjKvngeb.mjs} +2 -2
- package/dist/{proof-DBxu6g2K.cjs → proof-CWTnYhjS.cjs} +1 -1
- package/dist/{proof-DtpGEj0u.mjs → proof-D2oFOdNA.mjs} +3 -3
- package/dist/{proof-HU__qtUD.js → proof-s9sy44kx.js} +1 -1
- package/dist/{send-CwMea5r6.mjs → send-xDK5UnL-.mjs} +3 -3
- package/dist/sig/http.test.mjs +7 -7
- package/dist/sig/key.test.mjs +200 -6
- package/dist/sig/ld.test.mjs +50 -5
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +49 -4
- package/dist/sig/proof.test.mjs +56 -4
- package/dist/{std__assert-BvGuO4xO.mjs → std__assert-BjJn2daJ.mjs} +2 -2
- package/dist/{temporal-ClSXyHyu.mjs → temporal-C6icc5n9.mjs} +1 -1
- package/dist/utils/docloader.test.mjs +178 -39
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -6
- /package/dist/{assert-jSdZMYam.mjs → assert-CEO06XCw.mjs} +0 -0
- /package/dist/{circuit-breaker-test-utils-Dm5MM6l9.mjs → circuit-breaker-test-utils-CAdwjgMi.mjs} +0 -0
- /package/dist/{negotiation-CDW-_gUU.mjs → negotiation-DDstyBvc.mjs} +0 -0
- /package/dist/{retry-_VvV0h9f.mjs → retry-CXg_MBI-.mjs} +0 -0
package/dist/sig/key.test.mjs
CHANGED
|
@@ -2,14 +2,14 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { t as
|
|
7
|
-
import { t as
|
|
8
|
-
import { t as
|
|
5
|
+
import "../std__assert-BjJn2daJ.mjs";
|
|
6
|
+
import { r as assertFalse, t as assertThrows } from "../assert_throws-BbSMEFKo.mjs";
|
|
7
|
+
import { t as assertRejects } from "../assert_rejects-D1HYAik3.mjs";
|
|
8
|
+
import { t as assert } from "../assert-CEO06XCw.mjs";
|
|
9
9
|
import { t as assertStrictEquals } from "../assert_strict_equals-XEgZAlrj.mjs";
|
|
10
|
-
import { a as generateCryptoKeyPair, i as fetchKeyDetailed, o as importJwk, r as fetchKey, s as validateCryptoKey, t as exportJwk } from "../key-
|
|
10
|
+
import { a as generateCryptoKeyPair, i as fetchKeyDetailed, o as importJwk, r as fetchKey, s as validateCryptoKey, t as exportJwk } from "../key-APURZ0ky.mjs";
|
|
11
11
|
import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
12
|
-
import { _ as wrapContextLoaderForJsonLd } from "../ld-
|
|
12
|
+
import { _ as wrapContextLoaderForJsonLd } from "../ld-BoLqbDaL.mjs";
|
|
13
13
|
import { CryptographicKey, Multikey, Person } from "@fedify/vocab";
|
|
14
14
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
15
15
|
import { FetchError, UrlError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
@@ -868,5 +868,199 @@ test("fetchKey() records the controller an actor document establishes", async ()
|
|
|
868
868
|
assertEquals(key?.controllerId, new URL(actorId));
|
|
869
869
|
assert(key?.publicKey != null);
|
|
870
870
|
});
|
|
871
|
+
test("fetchKey() rejects a key whose owner redirects to another actor", async () => {
|
|
872
|
+
const keyId = "https://evil.example/keys/1";
|
|
873
|
+
const victim = "https://victim.example/users/alice";
|
|
874
|
+
const mallory = "https://evil.example/users/mallory";
|
|
875
|
+
const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
876
|
+
const cache = {};
|
|
877
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, {
|
|
878
|
+
documentLoader(resource) {
|
|
879
|
+
if (resource === keyId) return Promise.resolve({
|
|
880
|
+
contextUrl: null,
|
|
881
|
+
documentUrl: resource,
|
|
882
|
+
document: {
|
|
883
|
+
"@context": "https://w3id.org/security/v1",
|
|
884
|
+
id: keyId,
|
|
885
|
+
type: "CryptographicKey",
|
|
886
|
+
owner: victim,
|
|
887
|
+
publicKeyPem
|
|
888
|
+
}
|
|
889
|
+
});
|
|
890
|
+
if (resource === victim || resource === mallory) return Promise.resolve({
|
|
891
|
+
contextUrl: null,
|
|
892
|
+
documentUrl: mallory,
|
|
893
|
+
document: {
|
|
894
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
895
|
+
id: mallory,
|
|
896
|
+
type: "Person",
|
|
897
|
+
publicKey: keyId
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
return mockDocumentLoader(resource);
|
|
901
|
+
},
|
|
902
|
+
contextLoader: mockDocumentLoader,
|
|
903
|
+
keyCache: {
|
|
904
|
+
get(keyId) {
|
|
905
|
+
return Promise.resolve(cache[keyId.href]);
|
|
906
|
+
},
|
|
907
|
+
set(keyId, key) {
|
|
908
|
+
cache[keyId.href] = key;
|
|
909
|
+
return Promise.resolve();
|
|
910
|
+
}
|
|
911
|
+
}
|
|
912
|
+
}), {
|
|
913
|
+
key: null,
|
|
914
|
+
cached: false
|
|
915
|
+
});
|
|
916
|
+
assertEquals(cache, { [keyId]: null });
|
|
917
|
+
});
|
|
918
|
+
test("fetchKey() rejects a key whose owner resolves to another actor on the same origin", async () => {
|
|
919
|
+
const keyId = "https://victim.example/keys/bob";
|
|
920
|
+
const victim = "https://victim.example/users/alice";
|
|
921
|
+
const bob = "https://victim.example/users/bob";
|
|
922
|
+
const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
923
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, {
|
|
924
|
+
documentLoader(resource) {
|
|
925
|
+
if (resource === keyId) return Promise.resolve({
|
|
926
|
+
contextUrl: null,
|
|
927
|
+
documentUrl: resource,
|
|
928
|
+
document: {
|
|
929
|
+
"@context": "https://w3id.org/security/v1",
|
|
930
|
+
id: keyId,
|
|
931
|
+
type: "CryptographicKey",
|
|
932
|
+
owner: victim,
|
|
933
|
+
publicKeyPem
|
|
934
|
+
}
|
|
935
|
+
});
|
|
936
|
+
if (resource === victim || resource === bob) return Promise.resolve({
|
|
937
|
+
contextUrl: null,
|
|
938
|
+
documentUrl: resource,
|
|
939
|
+
document: {
|
|
940
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
941
|
+
id: bob,
|
|
942
|
+
type: "Person",
|
|
943
|
+
publicKey: keyId
|
|
944
|
+
}
|
|
945
|
+
});
|
|
946
|
+
return mockDocumentLoader(resource);
|
|
947
|
+
},
|
|
948
|
+
contextLoader: mockDocumentLoader
|
|
949
|
+
}), {
|
|
950
|
+
key: null,
|
|
951
|
+
cached: false
|
|
952
|
+
});
|
|
953
|
+
});
|
|
954
|
+
test("fetchKey() rejects a Multikey whose controller redirects to another actor", async () => {
|
|
955
|
+
const keyId = "https://evil.example/keys/ed25519";
|
|
956
|
+
const victim = "https://victim.example/users/alice";
|
|
957
|
+
const mallory = "https://evil.example/users/mallory";
|
|
958
|
+
const multikeyDocument = await ed25519Multikey.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
959
|
+
assertEquals(await fetchKey(keyId, Multikey, {
|
|
960
|
+
documentLoader(resource) {
|
|
961
|
+
if (resource === keyId) return Promise.resolve({
|
|
962
|
+
contextUrl: null,
|
|
963
|
+
documentUrl: resource,
|
|
964
|
+
document: {
|
|
965
|
+
...multikeyDocument,
|
|
966
|
+
id: keyId,
|
|
967
|
+
controller: victim
|
|
968
|
+
}
|
|
969
|
+
});
|
|
970
|
+
if (resource === victim || resource === mallory) return Promise.resolve({
|
|
971
|
+
contextUrl: null,
|
|
972
|
+
documentUrl: mallory,
|
|
973
|
+
document: {
|
|
974
|
+
"@context": [
|
|
975
|
+
"https://www.w3.org/ns/activitystreams",
|
|
976
|
+
"https://w3id.org/security/v1",
|
|
977
|
+
"https://w3id.org/security/multikey/v1",
|
|
978
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
979
|
+
"https://www.w3.org/ns/did/v1"
|
|
980
|
+
],
|
|
981
|
+
id: mallory,
|
|
982
|
+
type: "Person",
|
|
983
|
+
assertionMethod: [keyId]
|
|
984
|
+
}
|
|
985
|
+
});
|
|
986
|
+
return mockDocumentLoader(resource);
|
|
987
|
+
},
|
|
988
|
+
contextLoader: mockDocumentLoader
|
|
989
|
+
}), {
|
|
990
|
+
key: null,
|
|
991
|
+
cached: false
|
|
992
|
+
});
|
|
993
|
+
});
|
|
994
|
+
test("fetchKey() accepts an owner whose document URL differs from its id", async () => {
|
|
995
|
+
const keyId = "https://victim.example/keys/alice";
|
|
996
|
+
const alice = "https://victim.example/users/alice";
|
|
997
|
+
const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
998
|
+
const { key, cached } = await fetchKey(keyId, CryptographicKey, {
|
|
999
|
+
documentLoader(resource) {
|
|
1000
|
+
if (resource === keyId) return Promise.resolve({
|
|
1001
|
+
contextUrl: null,
|
|
1002
|
+
documentUrl: resource,
|
|
1003
|
+
document: {
|
|
1004
|
+
"@context": "https://w3id.org/security/v1",
|
|
1005
|
+
id: keyId,
|
|
1006
|
+
type: "CryptographicKey",
|
|
1007
|
+
owner: alice,
|
|
1008
|
+
publicKeyPem
|
|
1009
|
+
}
|
|
1010
|
+
});
|
|
1011
|
+
if (resource === alice) return Promise.resolve({
|
|
1012
|
+
contextUrl: null,
|
|
1013
|
+
documentUrl: `${alice}.json`,
|
|
1014
|
+
document: {
|
|
1015
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
1016
|
+
id: alice,
|
|
1017
|
+
type: "Person",
|
|
1018
|
+
publicKey: keyId
|
|
1019
|
+
}
|
|
1020
|
+
});
|
|
1021
|
+
return mockDocumentLoader(resource);
|
|
1022
|
+
},
|
|
1023
|
+
contextLoader: mockDocumentLoader
|
|
1024
|
+
});
|
|
1025
|
+
assertFalse(cached);
|
|
1026
|
+
assertEquals(key?.id, new URL(keyId));
|
|
1027
|
+
assertEquals(key?.ownerId, new URL(alice));
|
|
1028
|
+
});
|
|
1029
|
+
test("fetchKey() rejects an owner reached through a normalization redirect", async () => {
|
|
1030
|
+
const keyId = "https://victim.example/keys/alice";
|
|
1031
|
+
const canonical = "https://victim.example/users/alice";
|
|
1032
|
+
const nonCanonical = "https://victim.example/users/Alice";
|
|
1033
|
+
const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
1034
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, {
|
|
1035
|
+
documentLoader(resource) {
|
|
1036
|
+
if (resource === keyId) return Promise.resolve({
|
|
1037
|
+
contextUrl: null,
|
|
1038
|
+
documentUrl: resource,
|
|
1039
|
+
document: {
|
|
1040
|
+
"@context": "https://w3id.org/security/v1",
|
|
1041
|
+
id: keyId,
|
|
1042
|
+
type: "CryptographicKey",
|
|
1043
|
+
owner: nonCanonical,
|
|
1044
|
+
publicKeyPem
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
1047
|
+
if (resource === canonical || resource === nonCanonical) return Promise.resolve({
|
|
1048
|
+
contextUrl: null,
|
|
1049
|
+
documentUrl: canonical,
|
|
1050
|
+
document: {
|
|
1051
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
1052
|
+
id: canonical,
|
|
1053
|
+
type: "Person",
|
|
1054
|
+
publicKey: keyId
|
|
1055
|
+
}
|
|
1056
|
+
});
|
|
1057
|
+
return mockDocumentLoader(resource);
|
|
1058
|
+
},
|
|
1059
|
+
contextLoader: mockDocumentLoader
|
|
1060
|
+
}), {
|
|
1061
|
+
key: null,
|
|
1062
|
+
cached: false
|
|
1063
|
+
});
|
|
1064
|
+
});
|
|
871
1065
|
//#endregion
|
|
872
1066
|
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-C-ZRDbaf.mjs";
|
|
5
|
-
import {
|
|
6
|
-
import { n as
|
|
7
|
-
import { t as
|
|
8
|
-
import { a as generateCryptoKeyPair } from "../key-
|
|
5
|
+
import { r as assertFalse, t as assertThrows } from "../assert_throws-BbSMEFKo.mjs";
|
|
6
|
+
import { n as assertGreaterOrEqual, t as assertRejects } from "../assert_rejects-D1HYAik3.mjs";
|
|
7
|
+
import { n as assertInstanceOf, t as assert } from "../assert-CEO06XCw.mjs";
|
|
8
|
+
import { a as generateCryptoKeyPair } from "../key-APURZ0ky.mjs";
|
|
9
9
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
10
|
-
import { a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-
|
|
10
|
+
import { a as compactJsonLd, f as isInvalidUrlTypeError, g as verifySignature, h as verifyJsonLd, i as attachSignature, n as UnsafeJsonLdError, o as createSignature, p as signJsonLd, s as detachSignature, u as hasSignatureLike } from "../ld-BoLqbDaL.mjs";
|
|
11
11
|
import { CryptographicKey } from "@fedify/vocab";
|
|
12
12
|
import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
13
13
|
import { encodeBase64 } from "byte-encodings/base64";
|
|
@@ -993,5 +993,50 @@ test("verifyJsonLd() rejects a key that claims a forged owner", async () => {
|
|
|
993
993
|
contextLoader: mockDocumentLoader
|
|
994
994
|
}));
|
|
995
995
|
});
|
|
996
|
+
test("verifyJsonLd() rejects a key whose owner redirects to another actor", async () => {
|
|
997
|
+
const keyId = new URL("https://evil.example/keys/1");
|
|
998
|
+
const victim = "https://victim.example/users/alice";
|
|
999
|
+
const mallory = "https://evil.example/users/mallory";
|
|
1000
|
+
const { publicKeyPem } = await rsaPublicKey3.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
1001
|
+
const signed = await signJsonLd({
|
|
1002
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
1003
|
+
id: "https://victim.example/activities/forged",
|
|
1004
|
+
type: "Create",
|
|
1005
|
+
actor: victim,
|
|
1006
|
+
object: {
|
|
1007
|
+
type: "Note",
|
|
1008
|
+
content: "forged"
|
|
1009
|
+
}
|
|
1010
|
+
}, rsaPrivateKey3, keyId, { contextLoader: mockDocumentLoader });
|
|
1011
|
+
const options = {
|
|
1012
|
+
documentLoader(resource) {
|
|
1013
|
+
if (resource === keyId.href) return Promise.resolve({
|
|
1014
|
+
contextUrl: null,
|
|
1015
|
+
documentUrl: resource,
|
|
1016
|
+
document: {
|
|
1017
|
+
"@context": "https://w3id.org/security/v1",
|
|
1018
|
+
id: keyId.href,
|
|
1019
|
+
type: "CryptographicKey",
|
|
1020
|
+
owner: victim,
|
|
1021
|
+
publicKeyPem
|
|
1022
|
+
}
|
|
1023
|
+
});
|
|
1024
|
+
if (resource === victim || resource === mallory) return Promise.resolve({
|
|
1025
|
+
contextUrl: null,
|
|
1026
|
+
documentUrl: mallory,
|
|
1027
|
+
document: {
|
|
1028
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
1029
|
+
id: mallory,
|
|
1030
|
+
type: "Person",
|
|
1031
|
+
publicKey: keyId.href
|
|
1032
|
+
}
|
|
1033
|
+
});
|
|
1034
|
+
return mockDocumentLoader(resource);
|
|
1035
|
+
},
|
|
1036
|
+
contextLoader: mockDocumentLoader
|
|
1037
|
+
};
|
|
1038
|
+
assertEquals(await verifySignature(signed, options), null);
|
|
1039
|
+
assertFalse(await verifyJsonLd(signed, options));
|
|
1040
|
+
});
|
|
996
1041
|
//#endregion
|
|
997
1042
|
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-D77Wjrcg.cjs");
|
|
5
|
+
const require_proof = require("../proof-CWTnYhjS.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 { F as validateAcceptSignature, M as formatAcceptSignature, N as fulfillAcceptSignature, P as parseAcceptSignature, a as verifyRequestDetailed, c as fetchKey, d as importJwk, i as verifyRequest, l as fetchKeyDetailed, o as exportJwk, r as signRequest, u as generateCryptoKeyPair } from "../http-
|
|
4
|
-
import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "../proof-
|
|
3
|
+
import { F as validateAcceptSignature, M as formatAcceptSignature, N as fulfillAcceptSignature, P as parseAcceptSignature, a as verifyRequestDetailed, c as fetchKey, d as importJwk, i as verifyRequest, l as fetchKeyDetailed, o as exportJwk, r as signRequest, u as generateCryptoKeyPair } from "../http-DNM9KyIO.js";
|
|
4
|
+
import { C as verifySignature, S as verifyJsonLd, _ as hasSignatureLike, a as verifyProof, b as signJsonLd, c as getKeyOwner, d as attachSignature, i as verifyObject, m as detachSignature, n as hasProofLike, p as createSignature, r as signObject, s as doesActorOwnKey, t as createProof } from "../proof-s9sy44kx.js";
|
|
5
5
|
export { attachSignature, createProof, createSignature, detachSignature, doesActorOwnKey, exportJwk, fetchKey, fetchKeyDetailed, formatAcceptSignature, fulfillAcceptSignature, generateCryptoKeyPair, getKeyOwner, hasProofLike, hasSignatureLike, 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-C-ZRDbaf.mjs";
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import { r as assertFalse } from "../
|
|
7
|
-
import { t as assert } from "../assert-
|
|
5
|
+
import "../std__assert-BjJn2daJ.mjs";
|
|
6
|
+
import { r as assertFalse } from "../assert_throws-BbSMEFKo.mjs";
|
|
7
|
+
import { t as assert } from "../assert-CEO06XCw.mjs";
|
|
8
8
|
import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
|
|
9
|
-
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-
|
|
9
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-DjKvngeb.mjs";
|
|
10
10
|
import { Create, CryptographicKey, lookupObject } from "@fedify/vocab";
|
|
11
11
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
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,12 +2,13 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
|
|
5
|
-
import "../std__assert-
|
|
6
|
-
import {
|
|
7
|
-
import { n as
|
|
5
|
+
import "../std__assert-BjJn2daJ.mjs";
|
|
6
|
+
import { r as assertFalse } from "../assert_throws-BbSMEFKo.mjs";
|
|
7
|
+
import { n as assertGreaterOrEqual, t as assertRejects } from "../assert_rejects-D1HYAik3.mjs";
|
|
8
|
+
import { n as assertInstanceOf, t as assert } from "../assert-CEO06XCw.mjs";
|
|
8
9
|
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
9
10
|
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-D4iTv7uM.mjs";
|
|
10
|
-
import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-
|
|
11
|
+
import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-D2oFOdNA.mjs";
|
|
11
12
|
import { Create, DataIntegrityProof, Document, Multikey, Note, PUBLIC_COLLECTION, Place } from "@fedify/vocab";
|
|
12
13
|
import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
13
14
|
import { decodeMultibase, importMultibaseKey } from "@fedify/vocab-runtime";
|
|
@@ -598,5 +599,56 @@ test("verifyObject() rejects a key that claims a forged controller", async () =>
|
|
|
598
599
|
contextLoader: mockDocumentLoader
|
|
599
600
|
}), null);
|
|
600
601
|
});
|
|
602
|
+
test("verifyObject() rejects a key whose controller redirects to another actor", async () => {
|
|
603
|
+
const keyId = new URL("https://evil.example/keys/ed25519");
|
|
604
|
+
const victim = "https://victim.example/users/alice";
|
|
605
|
+
const mallory = "https://evil.example/users/mallory";
|
|
606
|
+
const multikeyDocument = await ed25519Multikey.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
607
|
+
const signOptions = {
|
|
608
|
+
format: "compact",
|
|
609
|
+
contextLoader: mockDocumentLoader,
|
|
610
|
+
documentLoader: mockDocumentLoader,
|
|
611
|
+
context: ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"]
|
|
612
|
+
};
|
|
613
|
+
assertEquals(await verifyObject(Create, await (await signObject(new Create({
|
|
614
|
+
id: new URL("https://victim.example/activities/forged"),
|
|
615
|
+
actor: new URL(victim),
|
|
616
|
+
object: new Note({
|
|
617
|
+
id: new URL("https://victim.example/notes/forged"),
|
|
618
|
+
attribution: new URL(victim),
|
|
619
|
+
content: "forged"
|
|
620
|
+
})
|
|
621
|
+
}), ed25519PrivateKey, keyId, signOptions)).toJsonLd(signOptions), {
|
|
622
|
+
documentLoader(resource) {
|
|
623
|
+
if (resource === keyId.href) return Promise.resolve({
|
|
624
|
+
contextUrl: null,
|
|
625
|
+
documentUrl: resource,
|
|
626
|
+
document: {
|
|
627
|
+
...multikeyDocument,
|
|
628
|
+
id: keyId.href,
|
|
629
|
+
controller: victim
|
|
630
|
+
}
|
|
631
|
+
});
|
|
632
|
+
if (resource === victim || resource === mallory) return Promise.resolve({
|
|
633
|
+
contextUrl: null,
|
|
634
|
+
documentUrl: mallory,
|
|
635
|
+
document: {
|
|
636
|
+
"@context": [
|
|
637
|
+
"https://www.w3.org/ns/activitystreams",
|
|
638
|
+
"https://w3id.org/security/v1",
|
|
639
|
+
"https://w3id.org/security/multikey/v1",
|
|
640
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
641
|
+
"https://www.w3.org/ns/did/v1"
|
|
642
|
+
],
|
|
643
|
+
id: mallory,
|
|
644
|
+
type: "Person",
|
|
645
|
+
assertionMethod: [keyId.href]
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
return mockDocumentLoader(resource);
|
|
649
|
+
},
|
|
650
|
+
contextLoader: mockDocumentLoader
|
|
651
|
+
}), null);
|
|
652
|
+
});
|
|
601
653
|
//#endregion
|
|
602
654
|
export {};
|
|
@@ -2,8 +2,8 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { l as AssertionError } from "./assert_equals-C-ZRDbaf.mjs";
|
|
5
|
-
import "./
|
|
6
|
-
import "./
|
|
5
|
+
import "./assert_throws-BbSMEFKo.mjs";
|
|
6
|
+
import "./assert_rejects-D1HYAik3.mjs";
|
|
7
7
|
import "./assert_strict_equals-XEgZAlrj.mjs";
|
|
8
8
|
//#region ../../node_modules/.pnpm/@jsr+std__assert@0.226.0/node_modules/@jsr/std__assert/assert_exists.js
|
|
9
9
|
/**
|
|
@@ -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-BoLqbDaL.mjs";
|
|
5
5
|
import jsonld from "@fedify/vocab-runtime/jsonld";
|
|
6
6
|
//#region src/federation/temporal.ts
|
|
7
7
|
function isPlainObject(value) {
|