@fedify/fedify 2.0.7 → 2.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{assert-MZs1qjMx.js → assert-ddO5KLpe.mjs} +5 -9
- package/dist/{assert_equals-DSbWqCm3.js → assert_equals-Ew3jOFa3.mjs} +55 -69
- package/dist/{assert_instance_of-DHz7EHNU.js → assert_instance_of-C4Ri6VuN.mjs} +5 -9
- package/dist/{assert_not_equals-C80BG-_5.js → assert_not_equals--wG9hV7u.mjs} +6 -13
- package/dist/{assert_rejects-Ce45JcFg.js → assert_rejects-B-qJtC9Z.mjs} +6 -11
- package/dist/{assert_throws-BNXdRGWP.js → assert_throws-4NwKEy2q.mjs} +5 -10
- package/dist/{builder-DA7Qgx_F.js → builder-DDoQaGOu.mjs} +32 -41
- package/dist/{chunk-CGaQZ11T.cjs → chunk-DDcVe30Y.cjs} +23 -24
- package/dist/{chunk-DJNbSFdH.js → chunk-nlSIicah.js} +8 -8
- package/dist/{client-CoCIaTNO.js → client-A1UrnX6I.mjs} +9 -13
- package/dist/{client-BxMZiQaD.d.ts → client-AtlibPOU.d.ts} +1 -1
- package/dist/{client-C97KOq3x.d.cts → client-z-8dc-e1.d.cts} +1 -1
- package/dist/{collection-CcnIw1qY.js → collection-ChgDTHLz.mjs} +7 -12
- package/dist/compat/mod.cjs +5 -8
- package/dist/compat/mod.d.cts +78 -6
- package/dist/compat/mod.d.ts +78 -6
- package/dist/compat/mod.js +4 -8
- package/dist/compat/transformers.test.mjs +62 -0
- package/dist/{context-D3QkEtZd.d.cts → context-CNIt-Qn7.d.cts} +9 -18
- package/dist/{context-DZJhUmzF.d.ts → context-Dyg7P1qW.d.ts} +9 -18
- package/dist/{context-pa9aIrwp.js → context-Juj6bdHC.mjs} +7 -11
- package/dist/deno-CuVDEdyj.mjs +8 -0
- package/dist/{docloader-CJeSPcS_.js → docloader-BPq9yzC_.mjs} +8 -14
- package/dist/{esm-nLm00z9V.js → esm-DVILvP5e.mjs} +50 -89
- package/dist/federation/builder.test.d.mts +2 -0
- package/dist/federation/{builder.test.js → builder.test.mjs} +19 -38
- package/dist/federation/collection.test.d.mts +2 -0
- package/dist/federation/collection.test.mjs +21 -0
- package/dist/federation/handler.test.d.mts +2 -0
- package/dist/federation/{handler.test.js → handler.test.mjs} +26 -56
- package/dist/federation/idempotency.test.d.mts +2 -0
- package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +31 -62
- package/dist/federation/inbox.test.d.mts +2 -0
- package/dist/federation/{inbox.test.js → inbox.test.mjs} +8 -12
- package/dist/federation/keycache.test.d.mts +2 -0
- package/dist/federation/{keycache.test.js → keycache.test.mjs} +13 -13
- package/dist/federation/kv.test.d.mts +2 -0
- package/dist/federation/{kv.test.js → kv.test.mjs} +11 -22
- package/dist/federation/middleware.test.d.mts +2 -0
- package/dist/federation/{middleware.test.js → middleware.test.mjs} +146 -225
- package/dist/federation/mod.cjs +327 -16
- package/dist/federation/mod.d.cts +3 -6
- package/dist/federation/mod.d.ts +3 -6
- package/dist/federation/mod.js +322 -13
- package/dist/federation/mq.test.d.mts +2 -0
- package/dist/federation/{mq.test.js → mq.test.mjs} +21 -35
- package/dist/federation/negotiation.test.d.mts +2 -0
- package/dist/federation/{negotiation.test.js → negotiation.test.mjs} +9 -16
- package/dist/federation/retry.test.d.mts +2 -0
- package/dist/federation/{retry.test.js → retry.test.mjs} +8 -11
- package/dist/federation/router.test.d.mts +2 -0
- package/dist/federation/{router.test.js → router.test.mjs} +11 -16
- package/dist/federation/send.test.d.mts +2 -0
- package/dist/federation/{send.test.js → send.test.mjs} +22 -29
- package/dist/federation/webfinger.test.d.mts +2 -0
- package/dist/federation/{webfinger.test.js → webfinger.test.mjs} +22 -55
- package/dist/{http-DkHdFfrc.d.ts → http-B2wiNmSo.d.ts} +1 -6
- package/dist/{http-B3vAjAtl.js → http-Bz7avX57.js} +39 -159
- package/dist/{http-Cz3MlXAZ.d.cts → http-C_tEAiZj.d.cts} +1 -6
- package/dist/{http-CjaLjnRN.js → http-DI213UHg.mjs} +31 -35
- package/dist/{http-CQ7TiYUI.cjs → http-DKBDoudA.cjs} +119 -233
- package/dist/{inbox-B33isX44.js → inbox-Bdn-CSRd.mjs} +18 -26
- package/dist/{key-Cga1p73u.js → key-DzJf84o7.mjs} +12 -19
- package/dist/{keycache-DRxpZ5r9.js → keycache-DaQ3ndaJ.mjs} +15 -10
- package/dist/{keys-ZbcByPg9.js → keys-CtZLJq76.mjs} +5 -9
- package/dist/{kv-QzKcOQgP.js → kv-BrZHNugx.mjs} +6 -10
- package/dist/{kv-BL4nlICN.d.cts → kv-CbLNp3zQ.d.cts} +1 -1
- package/dist/{kv-DXEUEP6z.d.ts → kv-GFYnFoOl.d.ts} +1 -1
- package/dist/{kv-cache-CFdy0BpZ.js → kv-cache-DBd7BezJ.js} +6 -13
- package/dist/{kv-cache--qyREO7e.cjs → kv-cache-Dj1Q7TiW.cjs} +27 -34
- package/dist/{kv-cache-El7We5sy.js → kv-cache-OWmRLHir.mjs} +4 -8
- package/dist/{ld-BWSOukKj.js → ld-DczS1fLK.mjs} +17 -31
- package/dist/middleware-B5CiOImA.mjs +5 -0
- package/dist/{middleware-CP7JdsGq.js → middleware-BKNu57ZI.js} +331 -365
- package/dist/middleware-C36TOX-2.cjs +4 -0
- package/dist/{middleware-Scz2k9eL.cjs → middleware-CyjmpK70.cjs} +523 -565
- package/dist/{middleware-BI1VCuPT.js → middleware-DoHz9oIo.mjs} +260 -292
- package/dist/{mod-DPkRU3EK.d.cts → mod-1xhgsHef.d.cts} +2 -2
- package/dist/{mod-DUWcVv49.d.ts → mod-BGtYJZKu.d.ts} +2 -2
- package/dist/{mod-DXsQakeS.d.cts → mod-Bld7oeqf.d.cts} +3 -3
- package/dist/{mod-DnSsduJF.d.ts → mod-BnAKGh2w.d.ts} +2 -2
- package/dist/{mod-CwZXZJ9d.d.ts → mod-DTOUyCce.d.ts} +3 -3
- package/dist/{mod-Di3W5OdP.d.cts → mod-DWoQffTD.d.cts} +2 -2
- package/dist/mod.cjs +29 -68
- package/dist/mod.d.cts +11 -14
- package/dist/mod.d.ts +11 -15
- package/dist/mod.js +17 -65
- package/dist/{negotiation-5NPJL6zp.js → negotiation-BehA2uul.mjs} +7 -11
- package/dist/nodeinfo/client.test.d.mts +2 -0
- package/dist/nodeinfo/{client.test.js → client.test.mjs} +22 -40
- package/dist/nodeinfo/handler.test.d.mts +2 -0
- package/dist/nodeinfo/{handler.test.js → handler.test.mjs} +13 -42
- package/dist/nodeinfo/mod.cjs +5 -8
- package/dist/nodeinfo/mod.d.cts +2 -3
- package/dist/nodeinfo/mod.d.ts +2 -3
- package/dist/nodeinfo/mod.js +4 -8
- package/dist/nodeinfo/types.test.d.mts +2 -0
- package/dist/nodeinfo/{types.test.js → types.test.mjs} +9 -16
- package/dist/otel/exporter.test.d.mts +2 -0
- package/dist/otel/{exporter.test.js → exporter.test.mjs} +117 -169
- package/dist/otel/mod.cjs +15 -20
- package/dist/otel/mod.d.cts +2 -2
- package/dist/otel/mod.d.ts +2 -2
- package/dist/otel/mod.js +8 -14
- package/dist/{owner-gd0Q9FuU.d.ts → owner-74ARJ5TL.d.ts} +1 -1
- package/dist/{owner-1AbPBOOZ.d.cts → owner-CptqhsOy.d.cts} +1 -1
- package/dist/{owner-HASxJJP1.js → owner-DXMGUEOr.mjs} +11 -16
- package/dist/{proof-BwfRl5J4.js → proof-C-7NljBU.js} +33 -59
- package/dist/{proof-BXt2Oi8t.js → proof-CEOujj0L.mjs} +21 -33
- package/dist/{proof-BYZ4hcgN.cjs → proof-DMu-6A_w.cjs} +133 -157
- package/dist/{retry-D4GJ670a.js → retry-Ddbq3AcK.mjs} +4 -7
- package/dist/{router-D9eI0s4b.js → router-CrMLXoOr.mjs} +4 -8
- package/dist/runtime/mod.cjs +11 -13
- package/dist/runtime/mod.d.cts +6 -2
- package/dist/runtime/mod.d.ts +0 -1
- package/dist/runtime/mod.js +4 -7
- package/dist/{send-BF3omx5-.js → send-DIfrLTB_.mjs} +8 -13
- package/dist/sig/http.test.d.mts +2 -0
- package/dist/sig/{http.test.js → http.test.mjs} +160 -199
- package/dist/sig/key.test.d.mts +2 -0
- package/dist/sig/{key.test.js → key.test.mjs} +11 -18
- package/dist/sig/ld.test.d.mts +2 -0
- package/dist/sig/{ld.test.js → ld.test.mjs} +22 -35
- package/dist/sig/mod.cjs +6 -9
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +5 -9
- package/dist/sig/owner.test.d.mts +2 -0
- package/dist/sig/{owner.test.js → owner.test.mjs} +19 -34
- package/dist/sig/proof.test.d.mts +2 -0
- package/dist/sig/{proof.test.js → proof.test.mjs} +16 -27
- package/dist/{std__assert-DWivtrGR.js → std__assert-Duiq_YC9.mjs} +12 -24
- package/dist/testing/{mod.d.ts → mod.d.mts} +26 -78
- package/dist/testing/mod.mjs +6 -0
- package/dist/{transformers-3g8GZwkZ.cjs → transformers-NeAONrAq.cjs} +20 -25
- package/dist/{transformers-C3FLHUd6.js → transformers-ve6e2xcg.js} +3 -7
- package/dist/{types-CPz01LGH.js → types-C37hquWI.mjs} +4 -7
- package/dist/{types-Cd_hszr_.cjs → types-KC4QAoxe.cjs} +29 -34
- package/dist/{types-C93Ob9cU.js → types-hvL8ElAs.js} +8 -13
- package/dist/utils/docloader.test.d.mts +2 -0
- package/dist/utils/{docloader.test.js → docloader.test.mjs} +14 -24
- package/dist/utils/kv-cache.test.d.mts +2 -0
- package/dist/utils/{kv-cache.test.js → kv-cache.test.mjs} +25 -40
- package/dist/utils/mod.cjs +5 -9
- package/dist/utils/mod.d.cts +1 -3
- package/dist/utils/mod.d.ts +1 -3
- package/dist/utils/mod.js +4 -9
- package/dist/vocab/cjs.test.d.mts +2 -0
- package/dist/vocab/cjs.test.mjs +14 -0
- package/dist/vocab/mod.cjs +10 -12
- package/dist/vocab/mod.js +3 -5
- package/package.json +7 -7
- package/dist/compat/transformers.test.d.ts +0 -3
- package/dist/compat/transformers.test.js +0 -87
- package/dist/compat-Bb4NuTUO.js +0 -4
- package/dist/compat-DmDDELst.cjs +0 -4
- package/dist/deno-CbQK8e-e.js +0 -121
- package/dist/federation/builder.test.d.ts +0 -3
- package/dist/federation/collection.test.d.ts +0 -3
- package/dist/federation/collection.test.js +0 -32
- package/dist/federation/handler.test.d.ts +0 -3
- package/dist/federation/idempotency.test.d.ts +0 -3
- package/dist/federation/inbox.test.d.ts +0 -3
- package/dist/federation/keycache.test.d.ts +0 -3
- package/dist/federation/kv.test.d.ts +0 -3
- package/dist/federation/middleware.test.d.ts +0 -3
- package/dist/federation/mq.test.d.ts +0 -3
- package/dist/federation/negotiation.test.d.ts +0 -3
- package/dist/federation/retry.test.d.ts +0 -3
- package/dist/federation/router.test.d.ts +0 -3
- package/dist/federation/send.test.d.ts +0 -3
- package/dist/federation/webfinger.test.d.ts +0 -3
- package/dist/federation-Bp3HI26G.cjs +0 -350
- package/dist/federation-DaMfqRm4.js +0 -332
- package/dist/middleware-CcXQzfn8.cjs +0 -12
- package/dist/middleware-CoeaBowW.js +0 -12
- package/dist/middleware-vH2jFwC6.js +0 -26
- package/dist/mod-Bh8mqlYw.d.cts +0 -9
- package/dist/mod-D6HodEq7.d.ts +0 -7
- package/dist/mod-DVwHUI_x.d.cts +0 -80
- package/dist/mod-DosD6NsG.d.ts +0 -82
- package/dist/mod-gq_Xfdz8.d.cts +0 -1
- package/dist/nodeinfo/client.test.d.ts +0 -3
- package/dist/nodeinfo/handler.test.d.ts +0 -3
- package/dist/nodeinfo/types.test.d.ts +0 -3
- package/dist/nodeinfo-DoESQxq5.js +0 -4
- package/dist/nodeinfo-DuMYTpbZ.cjs +0 -4
- package/dist/otel/exporter.test.d.ts +0 -3
- package/dist/runtime-c2Njxsry.cjs +0 -17
- package/dist/runtime-poamPCMb.js +0 -13
- package/dist/sig/http.test.d.ts +0 -3
- package/dist/sig/key.test.d.ts +0 -3
- package/dist/sig/ld.test.d.ts +0 -3
- package/dist/sig/owner.test.d.ts +0 -3
- package/dist/sig/proof.test.d.ts +0 -3
- package/dist/sig-BNhspNOf.js +0 -4
- package/dist/sig-vX39WyWI.cjs +0 -4
- package/dist/testing/mod.js +0 -10
- package/dist/utils/docloader.test.d.ts +0 -3
- package/dist/utils/kv-cache.test.d.ts +0 -3
- package/dist/utils-BQ9KqEK9.cjs +0 -4
- package/dist/utils-Dn5OPdSW.js +0 -4
- /package/dist/{mod-AGjRfPjT.d.ts → compat/transformers.test.d.mts} +0 -0
|
@@ -1,121 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { assertInstanceOf } from "../assert_instance_of-
|
|
10
|
-
import {
|
|
11
|
-
import "../
|
|
12
|
-
import {
|
|
13
|
-
import "../
|
|
14
|
-
import {
|
|
15
|
-
import "../
|
|
16
|
-
import "../
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import { getAuthenticatedDocumentLoader } from "../docloader-CJeSPcS_.js";
|
|
22
|
-
import "../kv-cache-El7We5sy.js";
|
|
23
|
-
import "../inbox-B33isX44.js";
|
|
24
|
-
import "../builder-DA7Qgx_F.js";
|
|
25
|
-
import "../collection-CcnIw1qY.js";
|
|
26
|
-
import "../keycache-DRxpZ5r9.js";
|
|
27
|
-
import "../negotiation-5NPJL6zp.js";
|
|
28
|
-
import "../retry-D4GJ670a.js";
|
|
29
|
-
import "../send-BF3omx5-.js";
|
|
30
|
-
import { assertStrictEquals } from "../std__assert-DWivtrGR.js";
|
|
31
|
-
import { assertFalse, assertRejects } from "../assert_rejects-Ce45JcFg.js";
|
|
32
|
-
import { assertThrows } from "../assert_throws-BNXdRGWP.js";
|
|
33
|
-
import { assertNotEquals } from "../assert_not_equals-C80BG-_5.js";
|
|
34
|
-
import { ed25519Multikey, ed25519PrivateKey, ed25519PublicKey, rsaPrivateKey2, rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-ZbcByPg9.js";
|
|
1
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { t as esm_default } from "../esm-DVILvP5e.mjs";
|
|
5
|
+
import { n as RouterError } from "../router-CrMLXoOr.mjs";
|
|
6
|
+
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
7
|
+
import { n as assertStrictEquals } from "../std__assert-Duiq_YC9.mjs";
|
|
8
|
+
import { n as assertFalse, t as assertRejects } from "../assert_rejects-B-qJtC9Z.mjs";
|
|
9
|
+
import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
|
|
10
|
+
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
11
|
+
import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
|
|
12
|
+
import { t as assert } from "../assert-ddO5KLpe.mjs";
|
|
13
|
+
import { l as verifyRequest, s as signRequest } from "../http-DI213UHg.mjs";
|
|
14
|
+
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
|
|
15
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-BPq9yzC_.mjs";
|
|
16
|
+
import { a as signJsonLd, o as verifyJsonLd, r as detachSignature } from "../ld-DczS1fLK.mjs";
|
|
17
|
+
import { t as doesActorOwnKey } from "../owner-DXMGUEOr.mjs";
|
|
18
|
+
import { n as signObject, r as verifyObject } from "../proof-CEOujj0L.mjs";
|
|
19
|
+
import { t as MemoryKvStore } from "../kv-BrZHNugx.mjs";
|
|
20
|
+
import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-DoHz9oIo.mjs";
|
|
35
21
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
36
22
|
import * as vocab from "@fedify/vocab";
|
|
37
23
|
import { getTypeId, lookupObject } from "@fedify/vocab";
|
|
38
24
|
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
39
|
-
|
|
40
25
|
//#region ../fixture/src/fixtures/example.com/create.json
|
|
41
|
-
var __context$2 = "https://www.w3.org/ns/activitystreams";
|
|
42
|
-
var type$2 = "Create";
|
|
43
26
|
var id$2 = "https://example.com/create";
|
|
44
|
-
var actor = "https://example.com/person";
|
|
45
27
|
var create_default = {
|
|
46
|
-
"@context":
|
|
47
|
-
type:
|
|
28
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
29
|
+
type: "Create",
|
|
48
30
|
id: id$2,
|
|
49
|
-
actor
|
|
31
|
+
actor: "https://example.com/person"
|
|
50
32
|
};
|
|
51
|
-
|
|
52
33
|
//#endregion
|
|
53
34
|
//#region ../fixture/src/fixtures/example.com/person.json
|
|
54
|
-
var __context$1 = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
|
|
55
|
-
var id$1 = "https://example.com/person";
|
|
56
|
-
var type$1 = "Person";
|
|
57
|
-
var name$1 = "John Doe";
|
|
58
|
-
var publicKey$1 = [{
|
|
59
|
-
"id": "https://example.com/key",
|
|
60
|
-
"owner": "https://example.com/person",
|
|
61
|
-
"type": "CryptographicKey",
|
|
62
|
-
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyIB9rotX8G6r6/6toT+x\n24BUiQ/HaPH1Em9dOt4c94s+OPFoEdH7DY7Iym9A8LlH4JaGF8KD38bLHWe1S4x0\njV3gHJKhK7veJfGZCKUENcQecBZ+YWUs5HWvUIX1vVB//0luHrg6BQKGOrSOE+WI\nAxyr0qsWCFfZzQrvSnUD2yvg1arJX2xhms14uxoRd5Kg9efKSCmmQaNEapicARUm\nFWrIEpGFa/nUUnqimssAGw1eZFqf3wA4TjhsuARBhGaJtv/3KEa016eMZxy3kDlO\njZnXZTaTgWkXdodwUvy8563fes3Al6BlcS2iJ9qbtha8rSm0FHqoUKH73JsLPKQI\nwQIDAQAB\n-----END PUBLIC KEY-----"
|
|
63
|
-
}, {
|
|
64
|
-
"id": "https://example.com/key2",
|
|
65
|
-
"type": "CryptographicKey",
|
|
66
|
-
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoRmBtnxbdFutoRd1GLGw\nwGTrsqlRRWUe11hHQaoRLGf5LwQ0tIc6I9q+dynliw+2kxYsLn9SH2je6HcTYOol\ngW7F/cOWXZQN04b+OiYcU1ConAhLjmn4k1uKawJ614y0ScPNd8PQ+CljsnlPxbq9\nofaCMe2BV3B6y09aCuGFJ0nxn1/ubjmIBIWWFTAznoz1J9BhJDGyt3IO3ABy3f9z\nDVlR32L/n5VIkXnxkjUKdzMAOzYb62kuKOp1iznRTPrV71SNtivJMwSh/LVgBrmZ\njtIn/oim+KyX/fdLU3tQ7VClyqmJzyAjccOH6Qj6nFTPh+vX07gqN8IlLT2uye4w\nawIDAQAB\n-----END PUBLIC KEY-----"
|
|
67
|
-
}];
|
|
68
35
|
var person_default = {
|
|
69
|
-
"@context":
|
|
70
|
-
id:
|
|
71
|
-
type:
|
|
72
|
-
name:
|
|
73
|
-
publicKey:
|
|
36
|
+
"@context": ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"],
|
|
37
|
+
id: "https://example.com/person",
|
|
38
|
+
type: "Person",
|
|
39
|
+
name: "John Doe",
|
|
40
|
+
publicKey: [{
|
|
41
|
+
"id": "https://example.com/key",
|
|
42
|
+
"owner": "https://example.com/person",
|
|
43
|
+
"type": "CryptographicKey",
|
|
44
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyIB9rotX8G6r6/6toT+x\n24BUiQ/HaPH1Em9dOt4c94s+OPFoEdH7DY7Iym9A8LlH4JaGF8KD38bLHWe1S4x0\njV3gHJKhK7veJfGZCKUENcQecBZ+YWUs5HWvUIX1vVB//0luHrg6BQKGOrSOE+WI\nAxyr0qsWCFfZzQrvSnUD2yvg1arJX2xhms14uxoRd5Kg9efKSCmmQaNEapicARUm\nFWrIEpGFa/nUUnqimssAGw1eZFqf3wA4TjhsuARBhGaJtv/3KEa016eMZxy3kDlO\njZnXZTaTgWkXdodwUvy8563fes3Al6BlcS2iJ9qbtha8rSm0FHqoUKH73JsLPKQI\nwQIDAQAB\n-----END PUBLIC KEY-----"
|
|
45
|
+
}, {
|
|
46
|
+
"id": "https://example.com/key2",
|
|
47
|
+
"type": "CryptographicKey",
|
|
48
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAoRmBtnxbdFutoRd1GLGw\nwGTrsqlRRWUe11hHQaoRLGf5LwQ0tIc6I9q+dynliw+2kxYsLn9SH2je6HcTYOol\ngW7F/cOWXZQN04b+OiYcU1ConAhLjmn4k1uKawJ614y0ScPNd8PQ+CljsnlPxbq9\nofaCMe2BV3B6y09aCuGFJ0nxn1/ubjmIBIWWFTAznoz1J9BhJDGyt3IO3ABy3f9z\nDVlR32L/n5VIkXnxkjUKdzMAOzYb62kuKOp1iznRTPrV71SNtivJMwSh/LVgBrmZ\njtIn/oim+KyX/fdLU3tQ7VClyqmJzyAjccOH6Qj6nFTPh+vX07gqN8IlLT2uye4w\nawIDAQAB\n-----END PUBLIC KEY-----"
|
|
49
|
+
}]
|
|
74
50
|
};
|
|
75
|
-
|
|
76
51
|
//#endregion
|
|
77
52
|
//#region ../fixture/src/fixtures/example.com/person2.json
|
|
78
|
-
var __context = [
|
|
79
|
-
"https://www.w3.org/ns/activitystreams",
|
|
80
|
-
"https://w3id.org/security/v1",
|
|
81
|
-
"https://w3id.org/security/multikey/v1",
|
|
82
|
-
"https://w3id.org/security/data-integrity/v1",
|
|
83
|
-
"https://www.w3.org/ns/did/v1"
|
|
84
|
-
];
|
|
85
|
-
var id = "https://example.com/person2";
|
|
86
|
-
var type = "Person";
|
|
87
|
-
var name = "Jane Doe";
|
|
88
|
-
var publicKey = [{
|
|
89
|
-
"id": "https://example.com/person2#key3",
|
|
90
|
-
"type": "CryptographicKey",
|
|
91
|
-
"owner": "https://example.com/person2",
|
|
92
|
-
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA4GUqWgdiYlN3Su5Gr4l6\ni+xRS8gDDVKZ718vpGk6eIpvqs33q430nRbHIzbHRXRaAhc/1++rUBcK0V4/kjZl\nCSzVtRgGU6HMkmjcD+uE56a8XbTczfltbEDj7afoEuB2F3UhQEWrSz+QJ29DPXaL\nMIa1Yv61NR2vxGqNbdtoMjDORMBYtg77CYbcFkiJHw65PDa7+f/yjLxuCRPye5L7\nhncN0UZuuFoRJmHNRLSg5omBad9WTvQXmSyXEhEdk9fHwlI022AqAzlWbT79hldc\nDSKGGLLbQIs1c3JZIG8G5i6Uh5Vy0Z7tSNBcxbhqoI9i9je4f/x/OPIVc19f04BE\n1LgWuHsftZzRgW9Sdqz53W83XxVdxlyHeywXOnstSWT11f8dkLyQUcHKTH+E6urb\nH+aiPLiRpYK8W7D9KTQA9kZ5JXaEuveBd5vJX7wakhbzAn8pWJU7GYIHNY38Ycok\nmivkU5pY8S2cKFMwY0b7ade3MComlir5P3ZYSjF+n6gRVsT96P+9mNfCu9gXt/f8\nXCyjKlH89kGwuJ7HhR8CuVdm0l+jYozVt6GsDy0hHYyn79NCCAEzP7ZbhBMR0T5V\nrkl+TIGXoJH9WFiz4VxO+NnglF6dNQjDS5IzYLoFRXIK1f3cmQiEB4FZmL70l9HL\nrgwR+Xys83xia79OqFDRezMCAwEAAQ==\n-----END PUBLIC KEY-----\n"
|
|
93
|
-
}, {
|
|
94
|
-
"id": "https://example.com/person2#key4",
|
|
95
|
-
"type": "CryptographicKey",
|
|
96
|
-
"owner": "https://example.com/person2",
|
|
97
|
-
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEALR8epAGDe+cVq5p2Tx49CCfphpk1rNhkNoY9i+XEUfg=\n-----END PUBLIC KEY-----\n"
|
|
98
|
-
}];
|
|
99
|
-
var assertionMethod = [{
|
|
100
|
-
"id": "https://example.com/peson2#key3",
|
|
101
|
-
"type": "Multikey",
|
|
102
|
-
"controller": "https://example.com/person2",
|
|
103
|
-
"publicKeyMultibase": "zgghBUVkqmWS8e1j4aN2yowLAEkJC6wowB9wWmLRACYCok7UzstWcTBp3waKiDUM7wqL9bbBD9W9FvNaXEK2KPCZ9ffhvd5dxChJL9bdPQSrMwa28FEYMGDtcF1uocrYNmZm2dBBMaWrCu8U3s4PpVVhn4hsWDL8GLuE466pkJs9Hy8xmECoaaVgAZLiYDw2gwrjHDiX2i7aDHKfE7aSZWUWmC8nAGNZ7DX5pXoyXK3pxuaCWxNxXwPmaFwgKDyy9uhtBJ8znp9NZXkXHBTQe5uAi8GFwHY5asvqCmYPrAGWxcT6pdbZaJHdWkM7nw6apBHfakKs42oMqdBoJ2WkkresoT1qHrX2GW7gNP9PLtveF4vfEd6cwgHKQCdYgayG3muGfZiPvML75cyfkNrjkctvuQUfMxY9umbd2TG3V3mPnLrvQnqHpuRMZYtCn3nX1qfZaqFhTwT4NFPqVNLqvgR6k9vcuGXn6Ndaumhd5xtTK64jk3e2gPBit9iq6MrFUSoxNsbTty4kqcHAodtkK8CMSxUxbFP1kK3nyy8ZfeMgDCts1KboBcT2m5FMpQpYxKtNBfvhTuyeDDC34uhbY8itmTAnDwSr5mKrniwwDUGPZFejda51TYs1N9D9Ejzaw5Mvr8qN6wahHmsDBWTbWwV6YKVMD1MjAhJBUopWJWB5x6mEBAX25MssKfAEhJyDtqYWjq63uQHUJCsPJp"
|
|
104
|
-
}, {
|
|
105
|
-
"id": "https://example.com/person2#key4",
|
|
106
|
-
"type": "Multikey",
|
|
107
|
-
"controller": "https://example.com/person2",
|
|
108
|
-
"publicKeyMultibase": "z6MkhVPuyvgG1RkMv67azDqDCDERPXVrUg1i3qchXY5EACE3"
|
|
109
|
-
}];
|
|
110
53
|
var person2_default = {
|
|
111
|
-
"@context":
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
54
|
+
"@context": [
|
|
55
|
+
"https://www.w3.org/ns/activitystreams",
|
|
56
|
+
"https://w3id.org/security/v1",
|
|
57
|
+
"https://w3id.org/security/multikey/v1",
|
|
58
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
59
|
+
"https://www.w3.org/ns/did/v1"
|
|
60
|
+
],
|
|
61
|
+
id: "https://example.com/person2",
|
|
62
|
+
type: "Person",
|
|
63
|
+
name: "Jane Doe",
|
|
64
|
+
publicKey: [{
|
|
65
|
+
"id": "https://example.com/person2#key3",
|
|
66
|
+
"type": "CryptographicKey",
|
|
67
|
+
"owner": "https://example.com/person2",
|
|
68
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIICIjANBgkqhkiG9w0BAQEFAAOCAg8AMIICCgKCAgEA4GUqWgdiYlN3Su5Gr4l6\ni+xRS8gDDVKZ718vpGk6eIpvqs33q430nRbHIzbHRXRaAhc/1++rUBcK0V4/kjZl\nCSzVtRgGU6HMkmjcD+uE56a8XbTczfltbEDj7afoEuB2F3UhQEWrSz+QJ29DPXaL\nMIa1Yv61NR2vxGqNbdtoMjDORMBYtg77CYbcFkiJHw65PDa7+f/yjLxuCRPye5L7\nhncN0UZuuFoRJmHNRLSg5omBad9WTvQXmSyXEhEdk9fHwlI022AqAzlWbT79hldc\nDSKGGLLbQIs1c3JZIG8G5i6Uh5Vy0Z7tSNBcxbhqoI9i9je4f/x/OPIVc19f04BE\n1LgWuHsftZzRgW9Sdqz53W83XxVdxlyHeywXOnstSWT11f8dkLyQUcHKTH+E6urb\nH+aiPLiRpYK8W7D9KTQA9kZ5JXaEuveBd5vJX7wakhbzAn8pWJU7GYIHNY38Ycok\nmivkU5pY8S2cKFMwY0b7ade3MComlir5P3ZYSjF+n6gRVsT96P+9mNfCu9gXt/f8\nXCyjKlH89kGwuJ7HhR8CuVdm0l+jYozVt6GsDy0hHYyn79NCCAEzP7ZbhBMR0T5V\nrkl+TIGXoJH9WFiz4VxO+NnglF6dNQjDS5IzYLoFRXIK1f3cmQiEB4FZmL70l9HL\nrgwR+Xys83xia79OqFDRezMCAwEAAQ==\n-----END PUBLIC KEY-----\n"
|
|
69
|
+
}, {
|
|
70
|
+
"id": "https://example.com/person2#key4",
|
|
71
|
+
"type": "CryptographicKey",
|
|
72
|
+
"owner": "https://example.com/person2",
|
|
73
|
+
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEALR8epAGDe+cVq5p2Tx49CCfphpk1rNhkNoY9i+XEUfg=\n-----END PUBLIC KEY-----\n"
|
|
74
|
+
}],
|
|
75
|
+
assertionMethod: [{
|
|
76
|
+
"id": "https://example.com/peson2#key3",
|
|
77
|
+
"type": "Multikey",
|
|
78
|
+
"controller": "https://example.com/person2",
|
|
79
|
+
"publicKeyMultibase": "zgghBUVkqmWS8e1j4aN2yowLAEkJC6wowB9wWmLRACYCok7UzstWcTBp3waKiDUM7wqL9bbBD9W9FvNaXEK2KPCZ9ffhvd5dxChJL9bdPQSrMwa28FEYMGDtcF1uocrYNmZm2dBBMaWrCu8U3s4PpVVhn4hsWDL8GLuE466pkJs9Hy8xmECoaaVgAZLiYDw2gwrjHDiX2i7aDHKfE7aSZWUWmC8nAGNZ7DX5pXoyXK3pxuaCWxNxXwPmaFwgKDyy9uhtBJ8znp9NZXkXHBTQe5uAi8GFwHY5asvqCmYPrAGWxcT6pdbZaJHdWkM7nw6apBHfakKs42oMqdBoJ2WkkresoT1qHrX2GW7gNP9PLtveF4vfEd6cwgHKQCdYgayG3muGfZiPvML75cyfkNrjkctvuQUfMxY9umbd2TG3V3mPnLrvQnqHpuRMZYtCn3nX1qfZaqFhTwT4NFPqVNLqvgR6k9vcuGXn6Ndaumhd5xtTK64jk3e2gPBit9iq6MrFUSoxNsbTty4kqcHAodtkK8CMSxUxbFP1kK3nyy8ZfeMgDCts1KboBcT2m5FMpQpYxKtNBfvhTuyeDDC34uhbY8itmTAnDwSr5mKrniwwDUGPZFejda51TYs1N9D9Ejzaw5Mvr8qN6wahHmsDBWTbWwV6YKVMD1MjAhJBUopWJWB5x6mEBAX25MssKfAEhJyDtqYWjq63uQHUJCsPJp"
|
|
80
|
+
}, {
|
|
81
|
+
"id": "https://example.com/person2#key4",
|
|
82
|
+
"type": "Multikey",
|
|
83
|
+
"controller": "https://example.com/person2",
|
|
84
|
+
"publicKeyMultibase": "z6MkhVPuyvgG1RkMv67azDqDCDERPXVrUg1i3qchXY5EACE3"
|
|
85
|
+
}]
|
|
117
86
|
};
|
|
118
|
-
|
|
119
87
|
//#endregion
|
|
120
88
|
//#region src/federation/middleware.test.ts
|
|
121
89
|
const documentLoader = getDocumentLoader();
|
|
@@ -335,23 +303,20 @@ test({
|
|
|
335
303
|
publicKey: ed25519PublicKey.publicKey
|
|
336
304
|
})
|
|
337
305
|
}]);
|
|
338
|
-
|
|
339
|
-
assertEquals(await loader("https://example.com/auth-check"), {
|
|
306
|
+
assertEquals(await (await ctx.getDocumentLoader({ identifier: "handle" }))("https://example.com/auth-check"), {
|
|
340
307
|
contextUrl: null,
|
|
341
308
|
documentUrl: "https://example.com/auth-check",
|
|
342
309
|
document: true
|
|
343
310
|
});
|
|
344
|
-
|
|
345
|
-
assertEquals(await loader2("https://example.com/auth-check"), {
|
|
311
|
+
assertEquals(await (await ctx.getDocumentLoader({ username: "HANDLE" }))("https://example.com/auth-check"), {
|
|
346
312
|
contextUrl: null,
|
|
347
313
|
documentUrl: "https://example.com/auth-check",
|
|
348
314
|
document: true
|
|
349
315
|
});
|
|
350
|
-
|
|
316
|
+
assertEquals(await ctx.getDocumentLoader({
|
|
351
317
|
keyId: new URL("https://example.com/key2"),
|
|
352
318
|
privateKey: rsaPrivateKey2
|
|
353
|
-
})
|
|
354
|
-
assertEquals(await loader3("https://example.com/auth-check"), {
|
|
319
|
+
})("https://example.com/auth-check"), {
|
|
355
320
|
contextUrl: null,
|
|
356
321
|
documentUrl: "https://example.com/auth-check",
|
|
357
322
|
document: true
|
|
@@ -365,13 +330,11 @@ test({
|
|
|
365
330
|
id: "https://example.com/object",
|
|
366
331
|
name: "Fetched object"
|
|
367
332
|
}), { headers: { "Content-Type": "application/activity+json" } }));
|
|
368
|
-
|
|
333
|
+
assertEquals(await createFederation({
|
|
369
334
|
kv,
|
|
370
335
|
documentLoaderFactory: () => documentLoader,
|
|
371
336
|
contextLoaderFactory: () => mockDocumentLoader
|
|
372
|
-
})
|
|
373
|
-
const ctx2 = federation2.createContext(new URL("https://example.com/"), 123);
|
|
374
|
-
assertEquals(await ctx2.lookupObject("https://example.com/object"), new vocab.Object({
|
|
337
|
+
}).createContext(new URL("https://example.com/"), 123).lookupObject("https://example.com/object"), new vocab.Object({
|
|
375
338
|
id: new URL("https://example.com/object"),
|
|
376
339
|
name: "Fetched object"
|
|
377
340
|
}));
|
|
@@ -596,8 +559,7 @@ test({
|
|
|
596
559
|
});
|
|
597
560
|
});
|
|
598
561
|
await t.step("Context.clone()", () => {
|
|
599
|
-
const
|
|
600
|
-
const ctx = federation.createContext(new URL("https://example.com/"), 123);
|
|
562
|
+
const ctx = createFederation({ kv }).createContext(new URL("https://example.com/"), 123);
|
|
601
563
|
const clone = ctx.clone(456);
|
|
602
564
|
assertStrictEquals(clone.canonicalOrigin, ctx.canonicalOrigin);
|
|
603
565
|
assertStrictEquals(clone.origin, ctx.origin);
|
|
@@ -633,13 +595,11 @@ test({
|
|
|
633
595
|
}));
|
|
634
596
|
});
|
|
635
597
|
await t.step("Context.lookupNodeInfo()", async () => {
|
|
636
|
-
const
|
|
598
|
+
const ctx = createFederation({
|
|
637
599
|
kv,
|
|
638
600
|
userAgent: "CustomUserAgent/1.2.3"
|
|
639
|
-
});
|
|
640
|
-
|
|
641
|
-
const nodeInfo = await ctx.lookupNodeInfo("https://example.com/");
|
|
642
|
-
assertEquals(nodeInfo, {
|
|
601
|
+
}).createContext(new URL("https://example.com/"), 123);
|
|
602
|
+
assertEquals(await ctx.lookupNodeInfo("https://example.com/"), {
|
|
643
603
|
software: {
|
|
644
604
|
name: "foo",
|
|
645
605
|
version: "1.2.3"
|
|
@@ -651,8 +611,7 @@ test({
|
|
|
651
611
|
localComments: 456
|
|
652
612
|
}
|
|
653
613
|
});
|
|
654
|
-
|
|
655
|
-
assertEquals(rawNodeInfo, {
|
|
614
|
+
assertEquals(await ctx.lookupNodeInfo("https://example.com/", { parse: "none" }), {
|
|
656
615
|
software: {
|
|
657
616
|
name: "foo",
|
|
658
617
|
version: "1.2.3"
|
|
@@ -766,8 +725,7 @@ test("Federation.fetch()", async (t) => {
|
|
|
766
725
|
authenticatedDocumentLoaderFactory(identity) {
|
|
767
726
|
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
768
727
|
return (url) => {
|
|
769
|
-
|
|
770
|
-
if (urlObj.host === "example.com") return docLoader(url);
|
|
728
|
+
if (new URL(url).host === "example.com") return docLoader(url);
|
|
771
729
|
return mockDocumentLoader(url);
|
|
772
730
|
};
|
|
773
731
|
}
|
|
@@ -790,7 +748,6 @@ test("Federation.fetch()", async (t) => {
|
|
|
790
748
|
});
|
|
791
749
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, (_ctx, activity) => {
|
|
792
750
|
inbox.push(activity.id.toString());
|
|
793
|
-
return;
|
|
794
751
|
});
|
|
795
752
|
return {
|
|
796
753
|
federation,
|
|
@@ -814,10 +771,9 @@ test("Federation.fetch()", async (t) => {
|
|
|
814
771
|
},
|
|
815
772
|
body: JSON.stringify(create_default)
|
|
816
773
|
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
817
|
-
|
|
818
|
-
assertEquals(response.status, 202);
|
|
774
|
+
assertEquals((await federation.fetch(request, { contextData: void 0 })).status, 202);
|
|
819
775
|
assertEquals(inbox.length, 1, "Expected one item in the inbox, json");
|
|
820
|
-
assertEquals(inbox[0],
|
|
776
|
+
assertEquals(inbox[0], id$2);
|
|
821
777
|
});
|
|
822
778
|
await t.step("GET with application/json", async () => {
|
|
823
779
|
const { federation, dispatches } = createTestContext();
|
|
@@ -838,10 +794,9 @@ test("Federation.fetch()", async (t) => {
|
|
|
838
794
|
},
|
|
839
795
|
body: JSON.stringify(create_default)
|
|
840
796
|
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
841
|
-
|
|
842
|
-
assertEquals(response.status, 202);
|
|
797
|
+
assertEquals((await federation.fetch(request, { contextData: void 0 })).status, 202);
|
|
843
798
|
assertEquals(inbox.length, 1, "Expected one inbox activity, ld+json");
|
|
844
|
-
assertEquals(inbox[0],
|
|
799
|
+
assertEquals(inbox[0], id$2);
|
|
845
800
|
});
|
|
846
801
|
await t.step("GET with application/ld+json", async () => {
|
|
847
802
|
const { federation, dispatches } = createTestContext();
|
|
@@ -863,10 +818,9 @@ test("Federation.fetch()", async (t) => {
|
|
|
863
818
|
},
|
|
864
819
|
body: JSON.stringify(create_default)
|
|
865
820
|
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
866
|
-
|
|
867
|
-
assertEquals(response.status, 202);
|
|
821
|
+
assertEquals((await federation.fetch(request, { contextData: void 0 })).status, 202);
|
|
868
822
|
assertEquals(inbox.length, 1);
|
|
869
|
-
assertEquals(inbox[0],
|
|
823
|
+
assertEquals(inbox[0], id$2);
|
|
870
824
|
});
|
|
871
825
|
await t.step("GET with application/activity+json", async () => {
|
|
872
826
|
const { federation, dispatches } = createTestContext();
|
|
@@ -1074,8 +1028,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
1074
1028
|
authenticatedDocumentLoaderFactory(identity) {
|
|
1075
1029
|
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
1076
1030
|
return (url) => {
|
|
1077
|
-
|
|
1078
|
-
if (urlObj.host === "example.com") return docLoader(url);
|
|
1031
|
+
if (new URL(url).host === "example.com") return docLoader(url);
|
|
1079
1032
|
return mockDocumentLoader(url);
|
|
1080
1033
|
};
|
|
1081
1034
|
}
|
|
@@ -1158,9 +1111,8 @@ test("FederationImpl.sendActivity()", async (t) => {
|
|
|
1158
1111
|
if (verified.length > 0) return new Response(null, { status: 202 });
|
|
1159
1112
|
return new Response(null, { status: 401 });
|
|
1160
1113
|
});
|
|
1161
|
-
const kv = new MemoryKvStore();
|
|
1162
1114
|
const federation = new FederationImpl({
|
|
1163
|
-
kv,
|
|
1115
|
+
kv: new MemoryKvStore(),
|
|
1164
1116
|
contextLoaderFactory: () => mockDocumentLoader
|
|
1165
1117
|
});
|
|
1166
1118
|
const context = federation.createContext(new URL("https://example.com/"));
|
|
@@ -1226,19 +1178,18 @@ test("FederationImpl.processQueuedTask()", async (t) => {
|
|
|
1226
1178
|
await t.step("with MessageQueue having nativeRetrial", async () => {
|
|
1227
1179
|
const kv = new MemoryKvStore();
|
|
1228
1180
|
const queuedMessages = [];
|
|
1229
|
-
const queue = {
|
|
1230
|
-
nativeRetrial: true,
|
|
1231
|
-
enqueue(message, _options) {
|
|
1232
|
-
queuedMessages.push(message);
|
|
1233
|
-
return Promise.resolve();
|
|
1234
|
-
},
|
|
1235
|
-
listen(_handler, _options) {
|
|
1236
|
-
return Promise.resolve();
|
|
1237
|
-
}
|
|
1238
|
-
};
|
|
1239
1181
|
const federation = new FederationImpl({
|
|
1240
1182
|
kv,
|
|
1241
|
-
queue
|
|
1183
|
+
queue: {
|
|
1184
|
+
nativeRetrial: true,
|
|
1185
|
+
enqueue(message, _options) {
|
|
1186
|
+
queuedMessages.push(message);
|
|
1187
|
+
return Promise.resolve();
|
|
1188
|
+
},
|
|
1189
|
+
listen(_handler, _options) {
|
|
1190
|
+
return Promise.resolve();
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1242
1193
|
});
|
|
1243
1194
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
|
|
1244
1195
|
throw new Error("Intended error for testing");
|
|
@@ -1289,18 +1240,17 @@ test("FederationImpl.processQueuedTask()", async (t) => {
|
|
|
1289
1240
|
await t.step("with MessageQueue having no nativeRetrial", async () => {
|
|
1290
1241
|
const kv = new MemoryKvStore();
|
|
1291
1242
|
let queuedMessages = [];
|
|
1292
|
-
const queue = {
|
|
1293
|
-
enqueue(message, _options) {
|
|
1294
|
-
queuedMessages.push(message);
|
|
1295
|
-
return Promise.resolve();
|
|
1296
|
-
},
|
|
1297
|
-
listen(_handler, _options) {
|
|
1298
|
-
return Promise.resolve();
|
|
1299
|
-
}
|
|
1300
|
-
};
|
|
1301
1243
|
const federation = new FederationImpl({
|
|
1302
1244
|
kv,
|
|
1303
|
-
queue
|
|
1245
|
+
queue: {
|
|
1246
|
+
enqueue(message, _options) {
|
|
1247
|
+
queuedMessages.push(message);
|
|
1248
|
+
return Promise.resolve();
|
|
1249
|
+
},
|
|
1250
|
+
listen(_handler, _options) {
|
|
1251
|
+
return Promise.resolve();
|
|
1252
|
+
}
|
|
1253
|
+
}
|
|
1304
1254
|
});
|
|
1305
1255
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
|
|
1306
1256
|
throw new Error("Intended error for testing");
|
|
@@ -1379,19 +1329,18 @@ test("FederationImpl.processQueuedTask() permanent failure", async (t) => {
|
|
|
1379
1329
|
function setup(options = {}) {
|
|
1380
1330
|
const kv = new MemoryKvStore();
|
|
1381
1331
|
const queuedMessages = [];
|
|
1382
|
-
const queue = {
|
|
1383
|
-
...options.nativeRetrial ? { nativeRetrial: true } : {},
|
|
1384
|
-
enqueue(message, _options) {
|
|
1385
|
-
queuedMessages.push(message);
|
|
1386
|
-
return Promise.resolve();
|
|
1387
|
-
},
|
|
1388
|
-
listen(_handler, _options) {
|
|
1389
|
-
return Promise.resolve();
|
|
1390
|
-
}
|
|
1391
|
-
};
|
|
1392
1332
|
const federation = new FederationImpl({
|
|
1393
1333
|
kv,
|
|
1394
|
-
queue
|
|
1334
|
+
queue: {
|
|
1335
|
+
...options.nativeRetrial ? { nativeRetrial: true } : {},
|
|
1336
|
+
enqueue(message, _options) {
|
|
1337
|
+
queuedMessages.push(message);
|
|
1338
|
+
return Promise.resolve();
|
|
1339
|
+
},
|
|
1340
|
+
listen(_handler, _options) {
|
|
1341
|
+
return Promise.resolve();
|
|
1342
|
+
}
|
|
1343
|
+
},
|
|
1395
1344
|
...options.permanentFailureStatusCodes ? { permanentFailureStatusCodes: options.permanentFailureStatusCodes } : {}
|
|
1396
1345
|
});
|
|
1397
1346
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox");
|
|
@@ -1541,24 +1490,19 @@ test("ContextImpl.lookupObject()", async (t) => {
|
|
|
1541
1490
|
}
|
|
1542
1491
|
});
|
|
1543
1492
|
await t.step("allowPrivateAddress: true", async () => {
|
|
1544
|
-
const
|
|
1493
|
+
const result = await createFederation({
|
|
1545
1494
|
kv: new MemoryKvStore(),
|
|
1546
1495
|
allowPrivateAddress: true
|
|
1547
|
-
});
|
|
1548
|
-
const ctx = federation.createContext(new URL("https://example.com/"));
|
|
1549
|
-
const result = await ctx.lookupObject("@test@localhost");
|
|
1496
|
+
}).createContext(new URL("https://example.com/")).lookupObject("@test@localhost");
|
|
1550
1497
|
assertInstanceOf(result, vocab.Person);
|
|
1551
1498
|
assertEquals(result.id, new URL("https://localhost/actor"));
|
|
1552
1499
|
assertEquals(result.preferredUsername, "test");
|
|
1553
1500
|
});
|
|
1554
1501
|
await t.step("allowPrivateAddress: false", async () => {
|
|
1555
|
-
|
|
1502
|
+
assertEquals(await createFederation({
|
|
1556
1503
|
kv: new MemoryKvStore(),
|
|
1557
1504
|
allowPrivateAddress: false
|
|
1558
|
-
});
|
|
1559
|
-
const ctx = federation.createContext(new URL("https://example.com/"));
|
|
1560
|
-
const result = await ctx.lookupObject("@test@localhost");
|
|
1561
|
-
assertEquals(result, null);
|
|
1505
|
+
}).createContext(new URL("https://example.com/")).lookupObject("@test@localhost"), null);
|
|
1562
1506
|
});
|
|
1563
1507
|
esm_default.hardReset();
|
|
1564
1508
|
});
|
|
@@ -1584,11 +1528,9 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1584
1528
|
contextLoader: mockDocumentLoader,
|
|
1585
1529
|
keyCache: {
|
|
1586
1530
|
async get(keyId) {
|
|
1587
|
-
const
|
|
1588
|
-
const keys
|
|
1589
|
-
|
|
1590
|
-
else return key$1.cryptographicKey;
|
|
1591
|
-
return void 0;
|
|
1531
|
+
const keys = await federation.createContext(new URL("https://example.com/"), void 0).getActorKeyPairs("1");
|
|
1532
|
+
for (const key of keys) if (key.keyId.href === keyId.href) if (key.publicKey.algorithm.name === "Ed25519") return key.multikey;
|
|
1533
|
+
else return key.cryptographicKey;
|
|
1592
1534
|
},
|
|
1593
1535
|
async set(_keyId, _key) {}
|
|
1594
1536
|
}
|
|
@@ -1930,8 +1872,8 @@ test({
|
|
|
1930
1872
|
async fn() {
|
|
1931
1873
|
const federation = new FederationImpl({ kv: new MemoryKvStore() });
|
|
1932
1874
|
const activities = [];
|
|
1933
|
-
federation.setInboxListeners("/u/{identifier}/i", "/i").on(vocab.Offer, (ctx
|
|
1934
|
-
activities.push([ctx
|
|
1875
|
+
federation.setInboxListeners("/u/{identifier}/i", "/i").on(vocab.Offer, (ctx, offer) => {
|
|
1876
|
+
activities.push([ctx.recipient, offer]);
|
|
1935
1877
|
});
|
|
1936
1878
|
const ctx = new ContextImpl({
|
|
1937
1879
|
url: new URL("https://example.com/"),
|
|
@@ -2045,26 +1987,23 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
2045
1987
|
if (verified.length > 0) return new Response(null, { status: 202 });
|
|
2046
1988
|
return new Response(null, { status: 401 });
|
|
2047
1989
|
});
|
|
2048
|
-
const kv = new MemoryKvStore();
|
|
2049
1990
|
const federation = new FederationImpl({
|
|
2050
|
-
kv,
|
|
1991
|
+
kv: new MemoryKvStore(),
|
|
2051
1992
|
contextLoaderFactory: () => mockDocumentLoader
|
|
2052
1993
|
});
|
|
2053
1994
|
await t.step("skip", async () => {
|
|
2054
|
-
|
|
1995
|
+
await new InboxContextImpl(null, {
|
|
2055
1996
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2056
1997
|
"type": "Create",
|
|
2057
1998
|
"id": "https://example.com/activity",
|
|
2058
1999
|
"actor": "https://example.com/person2"
|
|
2059
|
-
}
|
|
2060
|
-
const ctx = new InboxContextImpl(null, activity, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2000
|
+
}, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2061
2001
|
data: void 0,
|
|
2062
2002
|
federation,
|
|
2063
2003
|
url: new URL("https://example.com/"),
|
|
2064
2004
|
documentLoader,
|
|
2065
2005
|
contextLoader: documentLoader
|
|
2066
|
-
})
|
|
2067
|
-
await ctx.forwardActivity([{
|
|
2006
|
+
}).forwardActivity([{
|
|
2068
2007
|
privateKey: rsaPrivateKey2,
|
|
2069
2008
|
keyId: rsaPublicKey2.id
|
|
2070
2009
|
}], {
|
|
@@ -2074,13 +2013,12 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
2074
2013
|
assertEquals(verified, null);
|
|
2075
2014
|
});
|
|
2076
2015
|
await t.step("unsigned", async () => {
|
|
2077
|
-
const
|
|
2016
|
+
const ctx = new InboxContextImpl(null, {
|
|
2078
2017
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2079
2018
|
"type": "Create",
|
|
2080
2019
|
"id": "https://example.com/activity",
|
|
2081
2020
|
"actor": "https://example.com/person2"
|
|
2082
|
-
}
|
|
2083
|
-
const ctx = new InboxContextImpl(null, activity, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2021
|
+
}, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2084
2022
|
data: void 0,
|
|
2085
2023
|
federation,
|
|
2086
2024
|
url: new URL("https://example.com/"),
|
|
@@ -2104,14 +2042,13 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
2104
2042
|
contextLoader: mockDocumentLoader,
|
|
2105
2043
|
documentLoader: mockDocumentLoader
|
|
2106
2044
|
});
|
|
2107
|
-
|
|
2045
|
+
await new InboxContextImpl(null, await activity.toJsonLd({ contextLoader: mockDocumentLoader }), activity.id?.href, getTypeId(activity).href, {
|
|
2108
2046
|
data: void 0,
|
|
2109
2047
|
federation,
|
|
2110
2048
|
url: new URL("https://example.com/"),
|
|
2111
2049
|
documentLoader,
|
|
2112
2050
|
contextLoader: documentLoader
|
|
2113
|
-
})
|
|
2114
|
-
await ctx.forwardActivity([{
|
|
2051
|
+
}).forwardActivity([{
|
|
2115
2052
|
privateKey: rsaPrivateKey2,
|
|
2116
2053
|
keyId: rsaPublicKey2.id
|
|
2117
2054
|
}], {
|
|
@@ -2121,20 +2058,18 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
2121
2058
|
assertEquals(verified, ["proof"]);
|
|
2122
2059
|
});
|
|
2123
2060
|
await t.step("LD Signatures", async () => {
|
|
2124
|
-
|
|
2061
|
+
await new InboxContextImpl(null, await signJsonLd({
|
|
2125
2062
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2126
2063
|
"type": "Create",
|
|
2127
2064
|
"id": "https://example.com/activity",
|
|
2128
2065
|
"actor": "https://example.com/person2"
|
|
2129
|
-
}, rsaPrivateKey3, rsaPublicKey3.id, { contextLoader: mockDocumentLoader })
|
|
2130
|
-
const ctx = new InboxContextImpl(null, activity, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2066
|
+
}, rsaPrivateKey3, rsaPublicKey3.id, { contextLoader: mockDocumentLoader }), "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2131
2067
|
data: void 0,
|
|
2132
2068
|
federation,
|
|
2133
2069
|
url: new URL("https://example.com/"),
|
|
2134
2070
|
documentLoader,
|
|
2135
2071
|
contextLoader: documentLoader
|
|
2136
|
-
})
|
|
2137
|
-
await ctx.forwardActivity([{
|
|
2072
|
+
}).forwardActivity([{
|
|
2138
2073
|
privateKey: rsaPrivateKey2,
|
|
2139
2074
|
keyId: rsaPublicKey2.id
|
|
2140
2075
|
}], {
|
|
@@ -2147,33 +2082,19 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
2147
2082
|
});
|
|
2148
2083
|
test("KvSpecDeterminer", async (t) => {
|
|
2149
2084
|
await t.step("should use default spec when not found in KV", async () => {
|
|
2150
|
-
|
|
2151
|
-
const prefix = ["test", "spec"];
|
|
2152
|
-
const determiner = new KvSpecDeterminer(kv, prefix);
|
|
2153
|
-
const spec = await determiner.determineSpec("example.com");
|
|
2154
|
-
assertEquals(spec, "rfc9421");
|
|
2085
|
+
assertEquals(await new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"]).determineSpec("example.com"), "rfc9421");
|
|
2155
2086
|
});
|
|
2156
2087
|
await t.step("should use custom default spec", async () => {
|
|
2157
|
-
|
|
2158
|
-
const prefix = ["test", "spec"];
|
|
2159
|
-
const determiner = new KvSpecDeterminer(kv, prefix, "draft-cavage-http-signatures-12");
|
|
2160
|
-
const spec = await determiner.determineSpec("example.com");
|
|
2161
|
-
assertEquals(spec, "draft-cavage-http-signatures-12");
|
|
2088
|
+
assertEquals(await new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"], "draft-cavage-http-signatures-12").determineSpec("example.com"), "draft-cavage-http-signatures-12");
|
|
2162
2089
|
});
|
|
2163
2090
|
await t.step("should remember and retrieve spec from KV", async () => {
|
|
2164
|
-
const
|
|
2165
|
-
const prefix = ["test", "spec"];
|
|
2166
|
-
const determiner = new KvSpecDeterminer(kv, prefix);
|
|
2091
|
+
const determiner = new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"]);
|
|
2167
2092
|
await determiner.rememberSpec("example.com", "draft-cavage-http-signatures-12");
|
|
2168
|
-
|
|
2169
|
-
assertEquals(
|
|
2170
|
-
const defaultSpec = await determiner.determineSpec("other.com");
|
|
2171
|
-
assertEquals(defaultSpec, "rfc9421");
|
|
2093
|
+
assertEquals(await determiner.determineSpec("example.com"), "draft-cavage-http-signatures-12");
|
|
2094
|
+
assertEquals(await determiner.determineSpec("other.com"), "rfc9421");
|
|
2172
2095
|
});
|
|
2173
2096
|
await t.step("should override remembered spec", async () => {
|
|
2174
|
-
const
|
|
2175
|
-
const prefix = ["test", "spec"];
|
|
2176
|
-
const determiner = new KvSpecDeterminer(kv, prefix);
|
|
2097
|
+
const determiner = new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"]);
|
|
2177
2098
|
await determiner.rememberSpec("example.com", "draft-cavage-http-signatures-12");
|
|
2178
2099
|
let spec = await determiner.determineSpec("example.com");
|
|
2179
2100
|
assertEquals(spec, "draft-cavage-http-signatures-12");
|
|
@@ -2182,5 +2103,5 @@ test("KvSpecDeterminer", async (t) => {
|
|
|
2182
2103
|
assertEquals(spec, "rfc9421");
|
|
2183
2104
|
});
|
|
2184
2105
|
});
|
|
2185
|
-
|
|
2186
|
-
|
|
2106
|
+
//#endregion
|
|
2107
|
+
export {};
|