@fedify/fedify 2.2.11 → 2.2.13
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_instance_of-C4Ri6VuN.mjs → assert-BhQd8QHP.mjs} +19 -1
- package/dist/{builder-8d-PNxcc.mjs → builder-uTlVksLw.mjs} +3 -3
- package/dist/{client-dx126nMS.mjs → client-CQ7zd8tW.mjs} +78 -4
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +1 -1
- package/dist/compat/public-audience.test.mjs +1 -1
- package/dist/compat/transformers.test.mjs +3 -4
- package/dist/{context-BU-1O90h.d.ts → context-Bt2jnbC7.d.ts} +4 -3
- package/dist/{context-DVA8wHZ0.d.cts → context-Cls_M1HU.d.cts} +4 -3
- package/dist/{deno-BdneH5EA.mjs → deno-Cg_cZHcI.mjs} +1 -1
- package/dist/{docloader-dW-3XcQa.mjs → docloader-BwXP5fDH.mjs} +2 -2
- package/dist/federation/builder.test.mjs +2 -2
- package/dist/federation/collection.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +127 -10
- package/dist/federation/idempotency.test.mjs +4 -4
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/keycache.test.mjs +44 -10
- package/dist/federation/kv.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +103 -15
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +1 -1
- package/dist/federation/negotiation.test.mjs +2 -2
- package/dist/federation/retry.test.mjs +1 -1
- package/dist/federation/router.test.mjs +1 -1
- package/dist/federation/send.test.mjs +138 -6
- package/dist/federation/temporal.test.mjs +2 -2
- package/dist/federation/webfinger.test.mjs +2 -2
- package/dist/{http-DcjN1Tul.mjs → http-B3V9unT4.mjs} +3 -3
- package/dist/{http-CVNTMjI8.cjs → http-BdbKIiay.cjs} +166 -6
- package/dist/{http-dst14yhu.js → http-DaLdtguq.js} +155 -7
- package/dist/{http-BDZeS5om.d.ts → http-Dl00HXr4.d.ts} +1 -1
- package/dist/{http-C87EWkO0.d.cts → http-DqZhyEso.d.cts} +1 -1
- package/dist/{key-C6EM8eSE.mjs → key-CLRfRmA_.mjs} +154 -6
- package/dist/{keycache-EGATflN-.mjs → keycache-C1aVprwy.mjs} +12 -4
- package/dist/{kv-cache-CSs1SO_n.cjs → kv-cache-K6eHO_YH.cjs} +1 -1
- package/dist/{kv-cache-Dg1p1urK.js → kv-cache-TPuR5wYg.js} +1 -1
- package/dist/{ld-Ci6Z4_tn.mjs → ld-C0s4f-GU.mjs} +2 -2
- package/dist/{middleware-DdSIe9K3.js → middleware-BDRZkGPG.js} +90 -14
- package/dist/{middleware-BVBL4Ug9.cjs → middleware-BDc7xyOx.cjs} +90 -14
- package/dist/{middleware-D7VPt6Mr.mjs → middleware-BsDiZP9H.mjs} +31 -20
- package/dist/{middleware-iVyNebWP.cjs → middleware-D6bGiZn6.cjs} +1 -1
- package/dist/{middleware-cU-cDO0w.mjs → middleware-uaOjlLEG.mjs} +1 -1
- package/dist/{mod-BhU_H1I_.d.ts → mod-0MWo2Nu5.d.ts} +1 -1
- package/dist/{mod-DXY9JF28.d.cts → mod-D2JyWtW3.d.cts} +1 -1
- package/dist/{mod-q-NFLW6B.d.cts → mod-DNvnDTS7.d.cts} +1 -1
- package/dist/{mod-BVt6iTmH.d.ts → mod-DaiJDJdQ.d.ts} +1 -1
- package/dist/{mod-B0rWmfW5.d.cts → mod-DzPMtIV3.d.cts} +1 -1
- package/dist/{mod-DHO9lk3D.d.ts → mod-ej_rLx8h.d.ts} +1 -1
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +6 -6
- package/dist/mod.d.ts +6 -6
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +28 -1
- package/dist/nodeinfo/handler.test.mjs +2 -2
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/nodeinfo/types.test.mjs +1 -1
- package/dist/otel/exporter.test.mjs +1 -1
- package/dist/{outgoing-jsonld-CfUItkGW.mjs → outgoing-jsonld-Dc2OXyB-.mjs} +1 -1
- package/dist/{owner-CnngXDNJ.d.ts → owner-B3hNQCG8.d.cts} +12 -1
- package/dist/{owner-DEvZuyOE.d.cts → owner-CiBPcC6F.d.ts} +12 -1
- package/dist/owner-DLbN_4jZ.mjs +175 -0
- package/dist/{proof-DMMFfNsL.cjs → proof-CTIG9UEI.cjs} +112 -58
- package/dist/{proof-BEwrQa7q.mjs → proof-CW3Zrxmd.mjs} +4 -4
- package/dist/{proof-nHHslj31.js → proof-CqyprEYB.js} +112 -58
- package/dist/{send-B1XNYk6n.mjs → send-B5QvdrZ1.mjs} +64 -6
- package/dist/sig/accept.test.mjs +1 -1
- package/dist/sig/http.test.mjs +4 -4
- package/dist/sig/key.test.mjs +170 -3
- package/dist/sig/ld.test.mjs +56 -4
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +105 -6
- package/dist/sig/proof.test.mjs +73 -5
- package/dist/{temporal-DaRJ05za.mjs → temporal-CFLRXAcm.mjs} +1 -1
- package/dist/{types-m8u9L86X.cjs → types-DWs-qZaY.cjs} +94 -2
- package/dist/{types-DTONwNqL.js → types-sXITXcWa.js} +78 -4
- package/dist/utils/docloader.test.mjs +28 -4
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +5 -5
- package/dist/assert-DikXweDx.mjs +0 -23
- package/dist/owner-ByUYl7Xn.mjs +0 -120
- /package/dist/{accept-CPkZzmGN.mjs → accept-Dd__NiUL.mjs} +0 -0
- /package/dist/{activity-listener-ell7W1s9.mjs → activity-listener-IojJ9SVl.mjs} +0 -0
- /package/dist/{collection-D-HqUuA2.mjs → collection-DnoYNwBC.mjs} +0 -0
- /package/dist/{keys-DGu1NFwu.mjs → keys-BAK-tUlf.mjs} +0 -0
- /package/dist/{kv-rV3vodCc.mjs → kv-CX8qfaad.mjs} +0 -0
- /package/dist/{kv-cache-DYsF2MhP.mjs → kv-cache-FsT1ljhs.mjs} +0 -0
- /package/dist/{negotiation-SQvQgUqe.mjs → negotiation-BHtZN6Y1.mjs} +0 -0
- /package/dist/{public-audience-Ci-r-4Q-.mjs → public-audience-CS1udGkN.mjs} +0 -0
- /package/dist/{retry-v_sGLH1d.mjs → retry-bMXBL97A.mjs} +0 -0
- /package/dist/{types-J53Kw7so.mjs → types-s4mCTGkT.mjs} +0 -0
package/dist/sig/accept.test.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature, t as formatAcceptSignature } from "../accept-
|
|
4
|
+
import { i as validateAcceptSignature, n as fulfillAcceptSignature, r as parseAcceptSignature, t as formatAcceptSignature } from "../accept-Dd__NiUL.mjs";
|
|
5
5
|
import { test } from "@fedify/fixture";
|
|
6
6
|
import { deepStrictEqual, strictEqual } from "node:assert/strict";
|
|
7
7
|
//#region src/sig/accept.test.ts
|
package/dist/sig/http.test.mjs
CHANGED
|
@@ -5,11 +5,11 @@ import { t as esm_default } from "../esm-DVILvP5e.mjs";
|
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
6
|
import { i as assertExists, t as assertStringIncludes } from "../std__assert-CRDpx_HF.mjs";
|
|
7
7
|
import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
8
|
+
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
8
9
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
9
|
-
import { t as
|
|
10
|
-
import { t as
|
|
11
|
-
import {
|
|
12
|
-
import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-DGu1NFwu.mjs";
|
|
10
|
+
import { t as exportJwk } from "../key-CLRfRmA_.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-B3V9unT4.mjs";
|
|
12
|
+
import { i as rsaPrivateKey2, l as rsaPublicKey5, o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
|
|
13
13
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
14
14
|
import { FetchError, exportSpki } from "@fedify/vocab-runtime";
|
|
15
15
|
import { encodeBase64 } from "byte-encodings/base64";
|
package/dist/sig/key.test.mjs
CHANGED
|
@@ -4,9 +4,10 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import "../std__assert-CRDpx_HF.mjs";
|
|
6
6
|
import { t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
7
|
+
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
7
8
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
8
|
-
import { a as
|
|
9
|
-
import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-
|
|
9
|
+
import { a as generateCryptoKeyPair, i as fetchKeyDetailed, o as importJwk, r as fetchKey, s as validateCryptoKey, t as exportJwk } from "../key-CLRfRmA_.mjs";
|
|
10
|
+
import { c as rsaPublicKey3, i as rsaPrivateKey2, o as rsaPublicKey1, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
10
11
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
11
12
|
import { CryptographicKey, Multikey } from "@fedify/vocab";
|
|
12
13
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
@@ -267,7 +268,7 @@ test("fetchKeyDetailed()", async () => {
|
|
|
267
268
|
key: rsaPublicKey1,
|
|
268
269
|
cached: false
|
|
269
270
|
});
|
|
270
|
-
assertEquals(documentLoaderCalls,
|
|
271
|
+
assertEquals(documentLoaderCalls, 2);
|
|
271
272
|
const spans = exporter.getSpans("activitypub.fetch_key");
|
|
272
273
|
assertEquals(spans.length, 2);
|
|
273
274
|
assertEquals(spans[0].attributes["activitypub.actor.key.cached"], true);
|
|
@@ -398,5 +399,171 @@ test("fetchKey() returns null for a malformed actor publicKey", async () => {
|
|
|
398
399
|
cached: true
|
|
399
400
|
});
|
|
400
401
|
});
|
|
402
|
+
test("fetchKey() rejects a key whose owner does not link back", async () => {
|
|
403
|
+
const keyId = "https://attacker.example/key";
|
|
404
|
+
const keyDocument = await rsaPublicKey1.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
405
|
+
const serveKeyOwnedBy = (owner) => ({
|
|
406
|
+
documentLoader(resource) {
|
|
407
|
+
if (resource === keyId) return Promise.resolve({
|
|
408
|
+
contextUrl: null,
|
|
409
|
+
documentUrl: resource,
|
|
410
|
+
document: {
|
|
411
|
+
...keyDocument,
|
|
412
|
+
id: keyId,
|
|
413
|
+
owner
|
|
414
|
+
}
|
|
415
|
+
});
|
|
416
|
+
return mockDocumentLoader(resource);
|
|
417
|
+
},
|
|
418
|
+
contextLoader: mockDocumentLoader
|
|
419
|
+
});
|
|
420
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, serveKeyOwnedBy("https://example.com/person")), {
|
|
421
|
+
key: null,
|
|
422
|
+
cached: false
|
|
423
|
+
});
|
|
424
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, serveKeyOwnedBy("https://impersonated.invalid/users/victim")), {
|
|
425
|
+
key: null,
|
|
426
|
+
cached: false
|
|
427
|
+
});
|
|
428
|
+
});
|
|
429
|
+
test("fetchKey() rejects a Multikey whose controller does not link back", async () => {
|
|
430
|
+
const keyId = "https://attacker.example/multikey";
|
|
431
|
+
const keyDocument = await ed25519Multikey.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
432
|
+
assertEquals(await fetchKey(keyId, Multikey, {
|
|
433
|
+
documentLoader(resource) {
|
|
434
|
+
if (resource === keyId) return Promise.resolve({
|
|
435
|
+
contextUrl: null,
|
|
436
|
+
documentUrl: resource,
|
|
437
|
+
document: {
|
|
438
|
+
...keyDocument,
|
|
439
|
+
id: keyId,
|
|
440
|
+
controller: "https://example.com/person2"
|
|
441
|
+
}
|
|
442
|
+
});
|
|
443
|
+
return mockDocumentLoader(resource);
|
|
444
|
+
},
|
|
445
|
+
contextLoader: mockDocumentLoader
|
|
446
|
+
}), {
|
|
447
|
+
key: null,
|
|
448
|
+
cached: false
|
|
449
|
+
});
|
|
450
|
+
});
|
|
451
|
+
test("fetchKey() rejects an actor document from another origin", async () => {
|
|
452
|
+
const keyId = "https://attacker.example/key";
|
|
453
|
+
const impersonated = "https://example.com/person";
|
|
454
|
+
const { publicKeyPem } = await rsaPublicKey1.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
455
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, {
|
|
456
|
+
documentLoader(resource) {
|
|
457
|
+
if (resource === keyId) return Promise.resolve({
|
|
458
|
+
contextUrl: null,
|
|
459
|
+
documentUrl: resource,
|
|
460
|
+
document: {
|
|
461
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
462
|
+
id: impersonated,
|
|
463
|
+
type: "Person",
|
|
464
|
+
publicKey: [{
|
|
465
|
+
id: `${impersonated}#main-key`,
|
|
466
|
+
type: "CryptographicKey",
|
|
467
|
+
owner: impersonated,
|
|
468
|
+
publicKeyPem
|
|
469
|
+
}]
|
|
470
|
+
}
|
|
471
|
+
});
|
|
472
|
+
return mockDocumentLoader(resource);
|
|
473
|
+
},
|
|
474
|
+
contextLoader: mockDocumentLoader
|
|
475
|
+
}), {
|
|
476
|
+
key: null,
|
|
477
|
+
cached: false
|
|
478
|
+
});
|
|
479
|
+
});
|
|
480
|
+
test("fetchKey() rejects a key that disowns the actor document holding it", async () => {
|
|
481
|
+
const actorId = "https://attacker.example/actor";
|
|
482
|
+
const keyId = `${actorId}#main-key`;
|
|
483
|
+
const { publicKeyPem } = await rsaPublicKey1.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
484
|
+
assertEquals(await fetchKey(keyId, CryptographicKey, {
|
|
485
|
+
documentLoader(resource) {
|
|
486
|
+
if (resource === keyId || resource === actorId) return Promise.resolve({
|
|
487
|
+
contextUrl: null,
|
|
488
|
+
documentUrl: resource,
|
|
489
|
+
document: {
|
|
490
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
491
|
+
id: actorId,
|
|
492
|
+
type: "Person",
|
|
493
|
+
publicKey: [{
|
|
494
|
+
id: keyId,
|
|
495
|
+
type: "CryptographicKey",
|
|
496
|
+
owner: "https://example.com/person",
|
|
497
|
+
publicKeyPem
|
|
498
|
+
}]
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
return mockDocumentLoader(resource);
|
|
502
|
+
},
|
|
503
|
+
contextLoader: mockDocumentLoader
|
|
504
|
+
}), {
|
|
505
|
+
key: null,
|
|
506
|
+
cached: false
|
|
507
|
+
});
|
|
508
|
+
});
|
|
509
|
+
test("fetchKey() records the owner its actor document establishes", async () => {
|
|
510
|
+
const { key } = await fetchKey("https://example.com/users/handle#main-key", CryptographicKey, {
|
|
511
|
+
documentLoader: mockDocumentLoader,
|
|
512
|
+
contextLoader: mockDocumentLoader
|
|
513
|
+
});
|
|
514
|
+
assertEquals(key?.ownerId, new URL("https://example.com/users/handle"));
|
|
515
|
+
});
|
|
516
|
+
test("fetchKey() accepts a key document that leaves its id implicit", async () => {
|
|
517
|
+
const keyId = "https://example.com/key";
|
|
518
|
+
const keyDocument = await rsaPublicKey1.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
519
|
+
delete keyDocument.id;
|
|
520
|
+
const { key } = await fetchKey(keyId, CryptographicKey, {
|
|
521
|
+
documentLoader(resource) {
|
|
522
|
+
if (resource === keyId) return Promise.resolve({
|
|
523
|
+
contextUrl: null,
|
|
524
|
+
documentUrl: resource,
|
|
525
|
+
document: keyDocument
|
|
526
|
+
});
|
|
527
|
+
return mockDocumentLoader(resource);
|
|
528
|
+
},
|
|
529
|
+
contextLoader: mockDocumentLoader
|
|
530
|
+
});
|
|
531
|
+
assertEquals(key?.id, new URL(keyId));
|
|
532
|
+
assertEquals(key?.ownerId, new URL("https://example.com/person"));
|
|
533
|
+
assert(key?.publicKey != null);
|
|
534
|
+
});
|
|
535
|
+
test("fetchKey() records the controller an actor document establishes", async () => {
|
|
536
|
+
const actorId = "https://example.com/multikey-actor";
|
|
537
|
+
const keyId = `${actorId}#assertion`;
|
|
538
|
+
const { publicKeyMultibase } = await ed25519Multikey.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
539
|
+
const { key } = await fetchKey(keyId, Multikey, {
|
|
540
|
+
documentLoader(resource) {
|
|
541
|
+
if (resource === actorId || resource === keyId) return Promise.resolve({
|
|
542
|
+
contextUrl: null,
|
|
543
|
+
documentUrl: actorId,
|
|
544
|
+
document: {
|
|
545
|
+
"@context": [
|
|
546
|
+
"https://www.w3.org/ns/activitystreams",
|
|
547
|
+
"https://w3id.org/security/v1",
|
|
548
|
+
"https://w3id.org/security/multikey/v1",
|
|
549
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
550
|
+
"https://www.w3.org/ns/did/v1"
|
|
551
|
+
],
|
|
552
|
+
id: actorId,
|
|
553
|
+
type: "Person",
|
|
554
|
+
assertionMethod: [{
|
|
555
|
+
id: keyId,
|
|
556
|
+
type: "Multikey",
|
|
557
|
+
publicKeyMultibase
|
|
558
|
+
}]
|
|
559
|
+
}
|
|
560
|
+
});
|
|
561
|
+
return mockDocumentLoader(resource);
|
|
562
|
+
},
|
|
563
|
+
contextLoader: mockDocumentLoader
|
|
564
|
+
});
|
|
565
|
+
assertEquals(key?.controllerId, new URL(actorId));
|
|
566
|
+
assert(key?.publicKey != null);
|
|
567
|
+
});
|
|
401
568
|
//#endregion
|
|
402
569
|
export {};
|
package/dist/sig/ld.test.mjs
CHANGED
|
@@ -3,11 +3,11 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
6
|
+
import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
|
|
6
7
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import { i as
|
|
9
|
-
import { a as
|
|
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-Ci6Z4_tn.mjs";
|
|
8
|
+
import { a as generateCryptoKeyPair } from "../key-CLRfRmA_.mjs";
|
|
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-C0s4f-GU.mjs";
|
|
11
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
12
|
import { CryptographicKey } from "@fedify/vocab";
|
|
13
13
|
import { encodeBase64 } from "byte-encodings/base64";
|
|
@@ -805,5 +805,57 @@ test("compactJsonLd() rejects inputs that compact into @graph wrappers", async (
|
|
|
805
805
|
content: "two"
|
|
806
806
|
}], mockDocumentLoader), UnsafeJsonLdError, "Unsupported JSON-LD keyword: @graph.");
|
|
807
807
|
});
|
|
808
|
+
test("verifyJsonLd() rejects a key that claims a forged owner", async () => {
|
|
809
|
+
const keyId = new URL("https://attacker.example/key");
|
|
810
|
+
const impersonated = "https://example.com/person";
|
|
811
|
+
const { publicKeyPem } = await rsaPublicKey2.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
812
|
+
const signed = await signJsonLd({
|
|
813
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
814
|
+
id: "https://attacker.example/activities/1",
|
|
815
|
+
type: "Create",
|
|
816
|
+
actor: impersonated
|
|
817
|
+
}, rsaPrivateKey2, keyId, { contextLoader: mockDocumentLoader });
|
|
818
|
+
const serveKeyOwnedBy = (owner) => (resource) => {
|
|
819
|
+
if (resource === keyId.href) return Promise.resolve({
|
|
820
|
+
contextUrl: null,
|
|
821
|
+
documentUrl: resource,
|
|
822
|
+
document: {
|
|
823
|
+
"@context": "https://w3id.org/security/v1",
|
|
824
|
+
id: keyId.href,
|
|
825
|
+
type: "CryptographicKey",
|
|
826
|
+
owner,
|
|
827
|
+
publicKeyPem
|
|
828
|
+
}
|
|
829
|
+
});
|
|
830
|
+
if (resource === "https://attacker.example/actor") return Promise.resolve({
|
|
831
|
+
contextUrl: null,
|
|
832
|
+
documentUrl: resource,
|
|
833
|
+
document: {
|
|
834
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
835
|
+
id: resource,
|
|
836
|
+
type: "Person",
|
|
837
|
+
publicKey: [keyId.href]
|
|
838
|
+
}
|
|
839
|
+
});
|
|
840
|
+
return mockDocumentLoader(resource);
|
|
841
|
+
};
|
|
842
|
+
assertEquals(await verifySignature(signed, {
|
|
843
|
+
documentLoader: serveKeyOwnedBy(impersonated),
|
|
844
|
+
contextLoader: mockDocumentLoader
|
|
845
|
+
}), null);
|
|
846
|
+
assertFalse(await verifyJsonLd(signed, {
|
|
847
|
+
documentLoader: serveKeyOwnedBy(impersonated),
|
|
848
|
+
contextLoader: mockDocumentLoader
|
|
849
|
+
}));
|
|
850
|
+
const honestLoader = serveKeyOwnedBy("https://attacker.example/actor");
|
|
851
|
+
assertInstanceOf(await verifySignature(signed, {
|
|
852
|
+
documentLoader: honestLoader,
|
|
853
|
+
contextLoader: mockDocumentLoader
|
|
854
|
+
}), CryptographicKey);
|
|
855
|
+
assertFalse(await verifyJsonLd(signed, {
|
|
856
|
+
documentLoader: honestLoader,
|
|
857
|
+
contextLoader: mockDocumentLoader
|
|
858
|
+
}));
|
|
859
|
+
});
|
|
808
860
|
//#endregion
|
|
809
861
|
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-BdbKIiay.cjs");
|
|
5
|
+
const require_proof = require("../proof-CTIG9UEI.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.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "../http-
|
|
3
|
-
import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "../owner-
|
|
4
|
-
import { _ as hasSignatureLike, a as createProof, b as verifySignature, c as verifyObject, d as SignJsonLdOptions, f as VerifyJsonLdOptions, g as detachSignature, h as createSignature, i as VerifyProofOptions, l as verifyProof, m as attachSignature, n as SignObjectOptions, o as hasProofLike, p as VerifySignatureOptions, r as VerifyObjectOptions, s as signObject, t as CreateProofOptions, u as CreateSignatureOptions, v as signJsonLd, y as verifyJsonLd } from "../mod-
|
|
2
|
+
import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "../http-DqZhyEso.cjs";
|
|
3
|
+
import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "../owner-B3hNQCG8.cjs";
|
|
4
|
+
import { _ as hasSignatureLike, a as createProof, b as verifySignature, c as verifyObject, d as SignJsonLdOptions, f as VerifyJsonLdOptions, g as detachSignature, h as createSignature, i as VerifyProofOptions, l as verifyProof, m as attachSignature, n as SignObjectOptions, o as hasProofLike, p as VerifySignatureOptions, r as VerifyObjectOptions, s as signObject, t as CreateProofOptions, u as CreateSignatureOptions, v as signJsonLd, y as verifyJsonLd } from "../mod-D2JyWtW3.cjs";
|
|
5
5
|
export { AcceptSignatureMember, AcceptSignatureParameters, CreateProofOptions, CreateSignatureOptions, DoesActorOwnKeyOptions, FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, FulfillAcceptSignatureResult, GetKeyOwnerOptions, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, KeyCache, Rfc9421SignRequestOptions, SignJsonLdOptions, SignObjectOptions, SignRequestOptions, VerifyJsonLdOptions, VerifyObjectOptions, VerifyProofOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, VerifySignatureOptions, 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/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "../http-
|
|
3
|
-
import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "../owner-
|
|
4
|
-
import { _ as hasSignatureLike, a as createProof, b as verifySignature, c as verifyObject, d as SignJsonLdOptions, f as VerifyJsonLdOptions, g as detachSignature, h as createSignature, i as VerifyProofOptions, l as verifyProof, m as attachSignature, n as SignObjectOptions, o as hasProofLike, p as VerifySignatureOptions, r as VerifyObjectOptions, s as signObject, t as CreateProofOptions, u as CreateSignatureOptions, v as signJsonLd, y as verifyJsonLd } from "../mod-
|
|
2
|
+
import { C as exportJwk, D as importJwk, E as generateCryptoKeyPair, S as KeyCache, T as fetchKeyDetailed, _ as validateAcceptSignature, a as VerifyRequestDetailedResult, b as FetchKeyOptions, c as signRequest, d as AcceptSignatureMember, f as AcceptSignatureParameters, g as parseAcceptSignature, h as fulfillAcceptSignature, i as SignRequestOptions, l as verifyRequest, m as formatAcceptSignature, n as HttpMessageSignaturesSpecDeterminer, o as VerifyRequestFailureReason, p as FulfillAcceptSignatureResult, r as Rfc9421SignRequestOptions, s as VerifyRequestOptions, t as HttpMessageSignaturesSpec, u as verifyRequestDetailed, v as FetchKeyDetailedResult, w as fetchKey, x as FetchKeyResult, y as FetchKeyErrorResult } from "../http-Dl00HXr4.js";
|
|
3
|
+
import { i as getKeyOwner, n as GetKeyOwnerOptions, r as doesActorOwnKey, t as DoesActorOwnKeyOptions } from "../owner-CiBPcC6F.js";
|
|
4
|
+
import { _ as hasSignatureLike, a as createProof, b as verifySignature, c as verifyObject, d as SignJsonLdOptions, f as VerifyJsonLdOptions, g as detachSignature, h as createSignature, i as VerifyProofOptions, l as verifyProof, m as attachSignature, n as SignObjectOptions, o as hasProofLike, p as VerifySignatureOptions, r as VerifyObjectOptions, s as signObject, t as CreateProofOptions, u as CreateSignatureOptions, v as signJsonLd, y as verifyJsonLd } from "../mod-ej_rLx8h.js";
|
|
5
5
|
export { AcceptSignatureMember, AcceptSignatureParameters, CreateProofOptions, CreateSignatureOptions, DoesActorOwnKeyOptions, FetchKeyDetailedResult, FetchKeyErrorResult, FetchKeyOptions, FetchKeyResult, FulfillAcceptSignatureResult, GetKeyOwnerOptions, HttpMessageSignaturesSpec, HttpMessageSignaturesSpecDeterminer, KeyCache, Rfc9421SignRequestOptions, SignJsonLdOptions, SignObjectOptions, SignRequestOptions, VerifyJsonLdOptions, VerifyObjectOptions, VerifyProofOptions, VerifyRequestDetailedResult, VerifyRequestFailureReason, VerifyRequestOptions, VerifySignatureOptions, 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/mod.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { a as verifyRequestDetailed, c as
|
|
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 { _ 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-DaLdtguq.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-CqyprEYB.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
|
@@ -4,9 +4,9 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import "../std__assert-CRDpx_HF.mjs";
|
|
6
6
|
import { n as assertFalse } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
7
|
-
import { t as assert } from "../assert-
|
|
8
|
-
import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-
|
|
9
|
-
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-
|
|
7
|
+
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
8
|
+
import { o as rsaPublicKey1, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
|
|
9
|
+
import { n as getKeyOwner, t as doesActorOwnKey } from "../owner-DLbN_4jZ.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
|
|
@@ -40,7 +40,7 @@ test("doesActorOwnKey() records OpenTelemetry span", async () => {
|
|
|
40
40
|
id: new URL("https://example.com/activity"),
|
|
41
41
|
actor: new URL("https://example.com/person")
|
|
42
42
|
}), new CryptographicKey({
|
|
43
|
-
id: new URL("https://example.com/
|
|
43
|
+
id: new URL("https://example.com/key"),
|
|
44
44
|
owner: new URL("https://example.com/person")
|
|
45
45
|
}), {
|
|
46
46
|
documentLoader: mockDocumentLoader,
|
|
@@ -50,9 +50,108 @@ test("doesActorOwnKey() records OpenTelemetry span", async () => {
|
|
|
50
50
|
assertEquals(spans.length, 1);
|
|
51
51
|
const span = spans[0];
|
|
52
52
|
assertEquals(span.attributes["activitypub.actor.id"], "https://example.com/person");
|
|
53
|
-
assertEquals(span.attributes["activitypub.key.id"], "https://example.com/
|
|
53
|
+
assertEquals(span.attributes["activitypub.key.id"], "https://example.com/key");
|
|
54
54
|
assertEquals(span.attributes["activitypub.key_ownership.verified"], true);
|
|
55
|
-
assertEquals(span.attributes["activitypub.key_ownership.method"], "
|
|
55
|
+
assertEquals(span.attributes["activitypub.key_ownership.method"], "key_owner");
|
|
56
|
+
});
|
|
57
|
+
test("doesActorOwnKey() rejects a key that only claims to be owned", async () => {
|
|
58
|
+
const options = {
|
|
59
|
+
documentLoader: mockDocumentLoader,
|
|
60
|
+
contextLoader: mockDocumentLoader
|
|
61
|
+
};
|
|
62
|
+
assertFalse(await doesActorOwnKey(new Create({ actor: new URL("https://example.com/person") }), new CryptographicKey({
|
|
63
|
+
id: new URL("https://attacker.example/key"),
|
|
64
|
+
owner: new URL("https://example.com/person")
|
|
65
|
+
}), options));
|
|
66
|
+
const unresolvable = new URL("https://impersonated.invalid/users/victim");
|
|
67
|
+
assertFalse(await doesActorOwnKey(new Create({ actor: unresolvable }), new CryptographicKey({
|
|
68
|
+
id: new URL("https://attacker.example/key"),
|
|
69
|
+
owner: unresolvable
|
|
70
|
+
}), options));
|
|
71
|
+
});
|
|
72
|
+
test("doesActorOwnKey() ignores an actor embedded in the activity", async () => {
|
|
73
|
+
const { publicKeyPem } = await rsaPublicKey1.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
74
|
+
const activity = await Create.fromJsonLd({
|
|
75
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
76
|
+
id: "https://example.com/activity",
|
|
77
|
+
type: "Create",
|
|
78
|
+
actor: {
|
|
79
|
+
id: "https://example.com/person",
|
|
80
|
+
type: "Person",
|
|
81
|
+
publicKey: {
|
|
82
|
+
id: "https://attacker.example/key",
|
|
83
|
+
type: "CryptographicKey",
|
|
84
|
+
owner: "https://example.com/person",
|
|
85
|
+
publicKeyPem
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
}, {
|
|
89
|
+
documentLoader: mockDocumentLoader,
|
|
90
|
+
contextLoader: mockDocumentLoader
|
|
91
|
+
});
|
|
92
|
+
assertEquals(activity.actorId, new URL("https://example.com/person"));
|
|
93
|
+
assertFalse(await doesActorOwnKey(activity, new CryptographicKey({ id: new URL("https://attacker.example/key") }), {
|
|
94
|
+
documentLoader: mockDocumentLoader,
|
|
95
|
+
contextLoader: mockDocumentLoader
|
|
96
|
+
}));
|
|
97
|
+
});
|
|
98
|
+
test("getKeyOwner() rejects an actor document from another origin", async () => {
|
|
99
|
+
const keyId = "https://attacker.example/key";
|
|
100
|
+
const { publicKeyPem } = await rsaPublicKey1.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
101
|
+
const options = {
|
|
102
|
+
documentLoader(resource) {
|
|
103
|
+
if (resource === keyId) return Promise.resolve({
|
|
104
|
+
contextUrl: null,
|
|
105
|
+
documentUrl: resource,
|
|
106
|
+
document: {
|
|
107
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
108
|
+
id: "https://example.com/person",
|
|
109
|
+
type: "Person",
|
|
110
|
+
publicKey: [{
|
|
111
|
+
id: keyId,
|
|
112
|
+
type: "CryptographicKey",
|
|
113
|
+
publicKeyPem
|
|
114
|
+
}]
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
return mockDocumentLoader(resource);
|
|
118
|
+
},
|
|
119
|
+
contextLoader: mockDocumentLoader
|
|
120
|
+
};
|
|
121
|
+
assertEquals(await getKeyOwner(new URL(keyId), options), null);
|
|
122
|
+
});
|
|
123
|
+
test("doesActorOwnKey() matches a key that leaves its id implicit", async () => {
|
|
124
|
+
const actorId = "https://example.com/implicit-key-actor";
|
|
125
|
+
const { publicKeyPem } = await rsaPublicKey1.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
126
|
+
const options = {
|
|
127
|
+
documentLoader(resource) {
|
|
128
|
+
if (resource === actorId) return Promise.resolve({
|
|
129
|
+
contextUrl: null,
|
|
130
|
+
documentUrl: resource,
|
|
131
|
+
document: {
|
|
132
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
133
|
+
id: actorId,
|
|
134
|
+
type: "Person",
|
|
135
|
+
publicKey: [{
|
|
136
|
+
type: "CryptographicKey",
|
|
137
|
+
owner: actorId,
|
|
138
|
+
publicKeyPem
|
|
139
|
+
}]
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
return mockDocumentLoader(resource);
|
|
143
|
+
},
|
|
144
|
+
contextLoader: mockDocumentLoader
|
|
145
|
+
};
|
|
146
|
+
const activity = new Create({ actor: new URL(actorId) });
|
|
147
|
+
assert(await doesActorOwnKey(activity, new CryptographicKey({
|
|
148
|
+
owner: new URL(actorId),
|
|
149
|
+
publicKey: rsaPublicKey1.publicKey
|
|
150
|
+
}), options));
|
|
151
|
+
assertFalse(await doesActorOwnKey(activity, new CryptographicKey({
|
|
152
|
+
owner: new URL(actorId),
|
|
153
|
+
publicKey: rsaPublicKey2.publicKey
|
|
154
|
+
}), options));
|
|
56
155
|
});
|
|
57
156
|
//#endregion
|
|
58
157
|
export {};
|
package/dist/sig/proof.test.mjs
CHANGED
|
@@ -4,11 +4,10 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import "../std__assert-CRDpx_HF.mjs";
|
|
6
6
|
import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import { t as
|
|
9
|
-
import {
|
|
10
|
-
import { r as
|
|
11
|
-
import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-BEwrQa7q.mjs";
|
|
7
|
+
import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
|
|
8
|
+
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
9
|
+
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-Dc2OXyB-.mjs";
|
|
10
|
+
import { a as verifyProof, i as verifyObject, n as hasProofLike, r as signObject, t as createProof } from "../proof-CW3Zrxmd.mjs";
|
|
12
11
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
13
12
|
import { Create, DataIntegrityProof, Document, Multikey, Note, PUBLIC_COLLECTION, Place } from "@fedify/vocab";
|
|
14
13
|
import { decodeMultibase, importMultibaseKey } from "@fedify/vocab-runtime";
|
|
@@ -369,5 +368,74 @@ test("verifyObject()", async () => {
|
|
|
369
368
|
assertInstanceOf(note, Note);
|
|
370
369
|
assertEquals(note.content, "Hello world");
|
|
371
370
|
});
|
|
371
|
+
test("verifyObject() rejects a key that claims a forged controller", async () => {
|
|
372
|
+
const keyId = new URL("https://attacker.example/multikey");
|
|
373
|
+
const impersonated = "https://example.com/person2";
|
|
374
|
+
const attackerActor = "https://attacker.example/actor";
|
|
375
|
+
const multikeyDocument = await ed25519Multikey.toJsonLd({ contextLoader: mockDocumentLoader });
|
|
376
|
+
const options = {
|
|
377
|
+
format: "compact",
|
|
378
|
+
contextLoader: mockDocumentLoader,
|
|
379
|
+
documentLoader: mockDocumentLoader,
|
|
380
|
+
context: ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/data-integrity/v1"]
|
|
381
|
+
};
|
|
382
|
+
const signed = await signObject(new Create({
|
|
383
|
+
id: new URL("https://attacker.example/activities/1"),
|
|
384
|
+
actor: new URL(impersonated),
|
|
385
|
+
object: new Note({
|
|
386
|
+
id: new URL("https://attacker.example/notes/1"),
|
|
387
|
+
attribution: new URL(impersonated),
|
|
388
|
+
content: "Hello world"
|
|
389
|
+
})
|
|
390
|
+
}), ed25519PrivateKey, keyId, options);
|
|
391
|
+
const jsonLd = await signed.toJsonLd(options);
|
|
392
|
+
const serveKeyControlledBy = (controller) => (resource) => {
|
|
393
|
+
if (resource === keyId.href) return Promise.resolve({
|
|
394
|
+
contextUrl: null,
|
|
395
|
+
documentUrl: resource,
|
|
396
|
+
document: {
|
|
397
|
+
...multikeyDocument,
|
|
398
|
+
id: keyId.href,
|
|
399
|
+
controller
|
|
400
|
+
}
|
|
401
|
+
});
|
|
402
|
+
if (resource === attackerActor) return Promise.resolve({
|
|
403
|
+
contextUrl: null,
|
|
404
|
+
documentUrl: resource,
|
|
405
|
+
document: {
|
|
406
|
+
"@context": [
|
|
407
|
+
"https://www.w3.org/ns/activitystreams",
|
|
408
|
+
"https://w3id.org/security/v1",
|
|
409
|
+
"https://w3id.org/security/multikey/v1",
|
|
410
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
411
|
+
"https://www.w3.org/ns/did/v1"
|
|
412
|
+
],
|
|
413
|
+
id: resource,
|
|
414
|
+
type: "Person",
|
|
415
|
+
assertionMethod: [keyId.href]
|
|
416
|
+
}
|
|
417
|
+
});
|
|
418
|
+
return mockDocumentLoader(resource);
|
|
419
|
+
};
|
|
420
|
+
assertEquals(await verifyObject(Create, jsonLd, {
|
|
421
|
+
documentLoader: serveKeyControlledBy(impersonated),
|
|
422
|
+
contextLoader: mockDocumentLoader
|
|
423
|
+
}), null);
|
|
424
|
+
const honestLoader = serveKeyControlledBy(attackerActor);
|
|
425
|
+
let proof = null;
|
|
426
|
+
for await (const p of signed.getProofs(options)) {
|
|
427
|
+
proof = p;
|
|
428
|
+
break;
|
|
429
|
+
}
|
|
430
|
+
assertInstanceOf(proof, DataIntegrityProof);
|
|
431
|
+
assertInstanceOf(await verifyProof(jsonLd, proof, {
|
|
432
|
+
documentLoader: honestLoader,
|
|
433
|
+
contextLoader: mockDocumentLoader
|
|
434
|
+
}), Multikey);
|
|
435
|
+
assertEquals(await verifyObject(Create, jsonLd, {
|
|
436
|
+
documentLoader: honestLoader,
|
|
437
|
+
contextLoader: mockDocumentLoader
|
|
438
|
+
}), null);
|
|
439
|
+
});
|
|
372
440
|
//#endregion
|
|
373
441
|
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-C0s4f-GU.mjs";
|
|
5
5
|
import jsonld from "@fedify/vocab-runtime/jsonld";
|
|
6
6
|
//#region src/federation/temporal.ts
|
|
7
7
|
function isPlainObject(value) {
|