@fedify/fedify 2.2.0-dev.610 → 2.2.0-dev.622
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/README.md +2 -5
- package/dist/{accept-D7sAxyNa.js → accept-Dd__NiUL.mjs} +10 -8
- 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-f3m3epl3.js → assert_not_equals--wG9hV7u.mjs} +6 -13
- package/dist/{assert_rejects-0h7I2Esa.js → assert_rejects-B-qJtC9Z.mjs} +6 -11
- package/dist/{assert_throws-rjdMBf31.js → assert_throws-4NwKEy2q.mjs} +5 -10
- package/dist/{builder-Bkqx5fo0.js → builder-DcSpny3g.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-BxMZiQaD.d.ts → client-AtlibPOU.d.ts} +1 -1
- package/dist/{client-CoCIaTNO.js → client-DEpOVgY1.mjs} +9 -13
- package/dist/{client-C97KOq3x.d.cts → client-z-8dc-e1.d.cts} +1 -1
- package/dist/{collection-CSzG2j1P.js → collection-BD6-SZ6O.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-DyJjQQ_H.d.ts → context-BOiMZBu5.d.ts} +9 -18
- package/dist/{context-BcqA-0BL.d.cts → context-BhZVy7RB.d.cts} +9 -18
- package/dist/{context-Aqenou7c.js → context-Juj6bdHC.mjs} +7 -11
- package/dist/deno-D682wzlW.mjs +8 -0
- package/dist/{docloader-ORTT1bPi.js → docloader-CCWf4tNV.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} +21 -44
- 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} +69 -131
- package/dist/federation/idempotency.test.d.mts +2 -0
- package/dist/federation/{idempotency.test.js → idempotency.test.mjs} +31 -63
- 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 -19
- 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} +173 -262
- 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 -30
- package/dist/federation/webfinger.test.d.mts +2 -0
- package/dist/federation/{webfinger.test.js → webfinger.test.mjs} +22 -56
- package/dist/{http-BDf1pBmE.cjs → http-BQccxQlj.cjs} +177 -302
- package/dist/{http-By9CCocC.js → http-CNsnyqrO.mjs} +23 -43
- package/dist/{http-BudnHZE2.d.cts → http-CrGuipxe.d.cts} +1 -6
- package/dist/{http-DLQMXj_1.js → http-DhwEMhtv.js} +53 -184
- package/dist/{http-Dax_FIBo.d.ts → http-aQzN9Ayi.d.ts} +1 -6
- package/dist/{inbox-CTJeEur6.js → inbox-DegXbbbS.mjs} +18 -26
- package/dist/{key-OaS_196P.js → key-vL60OvqM.mjs} +29 -37
- package/dist/{keycache-CpGWAUbj.js → keycache-CCSwkQcY.mjs} +5 -10
- package/dist/{keys-BFve7QQv.js → keys-BAK-tUlf.mjs} +5 -9
- 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-Bw2F2ABq.js → kv-cache-B01V7s3h.mjs} +4 -8
- package/dist/{kv-cache-COnBmjEC.js → kv-cache-CTj3iCix.js} +6 -13
- package/dist/{kv-cache-DG491NbS.cjs → kv-cache-DxdXJNbj.cjs} +27 -34
- package/dist/{kv-QzKcOQgP.js → kv-tL2TOE9X.mjs} +6 -10
- package/dist/{ld-5udwE1JY.js → ld-C3CO00YY.mjs} +17 -31
- package/dist/{middleware-3FSu2a2W.js → middleware-BmsVSOeS.js} +335 -382
- package/dist/middleware-C7shNcsp.cjs +4 -0
- package/dist/{middleware-CFuio6Y_.cjs → middleware-Cx0Ny6_7.cjs} +532 -587
- package/dist/middleware-DqVGYk56.mjs +5 -0
- package/dist/{middleware-DRWIaDqh.js → middleware-Du-vh7I_.mjs} +282 -317
- package/dist/{mod-em2Il1eD.d.cts → mod-Bp_CzKd4.d.cts} +2 -2
- package/dist/{mod-DCbh1JQ5.d.ts → mod-CLgIXe9w.d.ts} +3 -3
- package/dist/{mod-jfnweK2w.d.cts → mod-CMEbIaNh.d.cts} +3 -3
- package/dist/{mod-D6MdymW7.d.ts → mod-DKOAow7a.d.ts} +2 -2
- package/dist/{mod-Coe7KEgX.d.cts → mod-DoJBjjnO.d.cts} +2 -2
- package/dist/{mod-D6dOd--H.d.ts → mod-DvxszxXC.d.ts} +2 -2
- package/dist/mod.cjs +29 -74
- package/dist/mod.d.cts +11 -14
- package/dist/mod.d.ts +11 -15
- package/dist/mod.js +17 -71
- package/dist/{negotiation-BlAuS_nr.js → negotiation-DnsfFF8I.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 -43
- 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} +124 -178
- 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-DuRG_QYg.js → owner-DF320w6K.mjs} +11 -16
- package/dist/{proof-DG0_Hm4d.js → proof-BCWk5oas.js} +32 -58
- package/dist/{proof-DFffIwhK.js → proof-IyDwwmzL.mjs} +21 -33
- package/dist/{proof-WJjJMjvC.cjs → proof-WhNxSv_N.cjs} +133 -157
- package/dist/{retry-mqLf4b-R.js → retry-B_E3V_Dx.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-CJAMZwWu.js → send-CJQubr5t.mjs} +8 -13
- package/dist/sig/accept.test.d.mts +2 -0
- package/dist/sig/{accept.test.js → accept.test.mjs} +35 -70
- package/dist/sig/http.test.d.mts +2 -0
- package/dist/sig/{http.test.js → http.test.mjs} +166 -280
- 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-X-_kMxKM.js → std__assert-Duiq_YC9.mjs} +12 -24
- package/dist/testing/{mod.d.ts → mod.d.mts} +26 -90
- 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-DCP0WLdt.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 -25
- 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 +8 -8
- package/dist/compat/transformers.test.d.ts +0 -3
- package/dist/compat/transformers.test.js +0 -88
- package/dist/compat-Bb4NuTUO.js +0 -4
- package/dist/compat-DmDDELst.cjs +0 -4
- package/dist/deno-CMcbjYDs.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-BzcyJjau.js +0 -12
- package/dist/middleware-HlNnBIDX.js +0 -27
- package/dist/middleware-i-8IYJwY.cjs +0 -12
- package/dist/mod-B7QkWzrL.d.cts +0 -80
- package/dist/mod-Bh8mqlYw.d.cts +0 -9
- package/dist/mod-D6HodEq7.d.ts +0 -7
- package/dist/mod-SMHOMNpZ.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/accept.test.d.ts +0 -3
- 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,122 +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 { signObject, verifyObject } from "../proof-DFffIwhK.js";
|
|
22
|
-
import { getAuthenticatedDocumentLoader } from "../docloader-ORTT1bPi.js";
|
|
23
|
-
import "../kv-cache-Bw2F2ABq.js";
|
|
24
|
-
import "../inbox-CTJeEur6.js";
|
|
25
|
-
import "../builder-Bkqx5fo0.js";
|
|
26
|
-
import "../collection-CSzG2j1P.js";
|
|
27
|
-
import "../keycache-CpGWAUbj.js";
|
|
28
|
-
import "../negotiation-BlAuS_nr.js";
|
|
29
|
-
import "../retry-mqLf4b-R.js";
|
|
30
|
-
import "../send-CJAMZwWu.js";
|
|
31
|
-
import { assertStrictEquals } from "../std__assert-X-_kMxKM.js";
|
|
32
|
-
import { assertFalse, assertRejects } from "../assert_rejects-0h7I2Esa.js";
|
|
33
|
-
import { assertThrows } from "../assert_throws-rjdMBf31.js";
|
|
34
|
-
import { assertNotEquals } from "../assert_not_equals-f3m3epl3.js";
|
|
35
|
-
import { ed25519Multikey, ed25519PrivateKey, ed25519PublicKey, rsaPrivateKey2, rsaPrivateKey3, rsaPublicKey2, rsaPublicKey3 } from "../keys-BFve7QQv.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-CNsnyqrO.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-BAK-tUlf.mjs";
|
|
15
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-CCWf4tNV.mjs";
|
|
16
|
+
import { a as signJsonLd, o as verifyJsonLd, r as detachSignature } from "../ld-C3CO00YY.mjs";
|
|
17
|
+
import { t as doesActorOwnKey } from "../owner-DF320w6K.mjs";
|
|
18
|
+
import { n as signObject, r as verifyObject } from "../proof-IyDwwmzL.mjs";
|
|
19
|
+
import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
|
|
20
|
+
import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-Du-vh7I_.mjs";
|
|
36
21
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
37
22
|
import * as vocab from "@fedify/vocab";
|
|
38
23
|
import { getTypeId, lookupObject } from "@fedify/vocab";
|
|
39
24
|
import { FetchError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
40
|
-
|
|
41
25
|
//#region ../fixture/src/fixtures/example.com/create.json
|
|
42
|
-
var __context$2 = "https://www.w3.org/ns/activitystreams";
|
|
43
|
-
var type$2 = "Create";
|
|
44
26
|
var id$2 = "https://example.com/create";
|
|
45
|
-
var actor = "https://example.com/person";
|
|
46
27
|
var create_default = {
|
|
47
|
-
"@context":
|
|
48
|
-
type:
|
|
28
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
29
|
+
type: "Create",
|
|
49
30
|
id: id$2,
|
|
50
|
-
actor
|
|
31
|
+
actor: "https://example.com/person"
|
|
51
32
|
};
|
|
52
|
-
|
|
53
33
|
//#endregion
|
|
54
34
|
//#region ../fixture/src/fixtures/example.com/person.json
|
|
55
|
-
var __context$1 = ["https://www.w3.org/ns/activitystreams", "https://w3id.org/security/v1"];
|
|
56
|
-
var id$1 = "https://example.com/person";
|
|
57
|
-
var type$1 = "Person";
|
|
58
|
-
var name$1 = "John Doe";
|
|
59
|
-
var publicKey$1 = [{
|
|
60
|
-
"id": "https://example.com/key",
|
|
61
|
-
"owner": "https://example.com/person",
|
|
62
|
-
"type": "CryptographicKey",
|
|
63
|
-
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyIB9rotX8G6r6/6toT+x\n24BUiQ/HaPH1Em9dOt4c94s+OPFoEdH7DY7Iym9A8LlH4JaGF8KD38bLHWe1S4x0\njV3gHJKhK7veJfGZCKUENcQecBZ+YWUs5HWvUIX1vVB//0luHrg6BQKGOrSOE+WI\nAxyr0qsWCFfZzQrvSnUD2yvg1arJX2xhms14uxoRd5Kg9efKSCmmQaNEapicARUm\nFWrIEpGFa/nUUnqimssAGw1eZFqf3wA4TjhsuARBhGaJtv/3KEa016eMZxy3kDlO\njZnXZTaTgWkXdodwUvy8563fes3Al6BlcS2iJ9qbtha8rSm0FHqoUKH73JsLPKQI\nwQIDAQAB\n-----END PUBLIC KEY-----"
|
|
64
|
-
}, {
|
|
65
|
-
"id": "https://example.com/key2",
|
|
66
|
-
"type": "CryptographicKey",
|
|
67
|
-
"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-----"
|
|
68
|
-
}];
|
|
69
35
|
var person_default = {
|
|
70
|
-
"@context":
|
|
71
|
-
id:
|
|
72
|
-
type:
|
|
73
|
-
name:
|
|
74
|
-
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
|
+
}]
|
|
75
50
|
};
|
|
76
|
-
|
|
77
51
|
//#endregion
|
|
78
52
|
//#region ../fixture/src/fixtures/example.com/person2.json
|
|
79
|
-
var __context = [
|
|
80
|
-
"https://www.w3.org/ns/activitystreams",
|
|
81
|
-
"https://w3id.org/security/v1",
|
|
82
|
-
"https://w3id.org/security/multikey/v1",
|
|
83
|
-
"https://w3id.org/security/data-integrity/v1",
|
|
84
|
-
"https://www.w3.org/ns/did/v1"
|
|
85
|
-
];
|
|
86
|
-
var id = "https://example.com/person2";
|
|
87
|
-
var type = "Person";
|
|
88
|
-
var name = "Jane Doe";
|
|
89
|
-
var publicKey = [{
|
|
90
|
-
"id": "https://example.com/person2#key3",
|
|
91
|
-
"type": "CryptographicKey",
|
|
92
|
-
"owner": "https://example.com/person2",
|
|
93
|
-
"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"
|
|
94
|
-
}, {
|
|
95
|
-
"id": "https://example.com/person2#key4",
|
|
96
|
-
"type": "CryptographicKey",
|
|
97
|
-
"owner": "https://example.com/person2",
|
|
98
|
-
"publicKeyPem": "-----BEGIN PUBLIC KEY-----\nMCowBQYDK2VwAyEALR8epAGDe+cVq5p2Tx49CCfphpk1rNhkNoY9i+XEUfg=\n-----END PUBLIC KEY-----\n"
|
|
99
|
-
}];
|
|
100
|
-
var assertionMethod = [{
|
|
101
|
-
"id": "https://example.com/peson2#key3",
|
|
102
|
-
"type": "Multikey",
|
|
103
|
-
"controller": "https://example.com/person2",
|
|
104
|
-
"publicKeyMultibase": "zgghBUVkqmWS8e1j4aN2yowLAEkJC6wowB9wWmLRACYCok7UzstWcTBp3waKiDUM7wqL9bbBD9W9FvNaXEK2KPCZ9ffhvd5dxChJL9bdPQSrMwa28FEYMGDtcF1uocrYNmZm2dBBMaWrCu8U3s4PpVVhn4hsWDL8GLuE466pkJs9Hy8xmECoaaVgAZLiYDw2gwrjHDiX2i7aDHKfE7aSZWUWmC8nAGNZ7DX5pXoyXK3pxuaCWxNxXwPmaFwgKDyy9uhtBJ8znp9NZXkXHBTQe5uAi8GFwHY5asvqCmYPrAGWxcT6pdbZaJHdWkM7nw6apBHfakKs42oMqdBoJ2WkkresoT1qHrX2GW7gNP9PLtveF4vfEd6cwgHKQCdYgayG3muGfZiPvML75cyfkNrjkctvuQUfMxY9umbd2TG3V3mPnLrvQnqHpuRMZYtCn3nX1qfZaqFhTwT4NFPqVNLqvgR6k9vcuGXn6Ndaumhd5xtTK64jk3e2gPBit9iq6MrFUSoxNsbTty4kqcHAodtkK8CMSxUxbFP1kK3nyy8ZfeMgDCts1KboBcT2m5FMpQpYxKtNBfvhTuyeDDC34uhbY8itmTAnDwSr5mKrniwwDUGPZFejda51TYs1N9D9Ejzaw5Mvr8qN6wahHmsDBWTbWwV6YKVMD1MjAhJBUopWJWB5x6mEBAX25MssKfAEhJyDtqYWjq63uQHUJCsPJp"
|
|
105
|
-
}, {
|
|
106
|
-
"id": "https://example.com/person2#key4",
|
|
107
|
-
"type": "Multikey",
|
|
108
|
-
"controller": "https://example.com/person2",
|
|
109
|
-
"publicKeyMultibase": "z6MkhVPuyvgG1RkMv67azDqDCDERPXVrUg1i3qchXY5EACE3"
|
|
110
|
-
}];
|
|
111
53
|
var person2_default = {
|
|
112
|
-
"@context":
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
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
|
+
}]
|
|
118
86
|
};
|
|
119
|
-
|
|
120
87
|
//#endregion
|
|
121
88
|
//#region src/federation/middleware.test.ts
|
|
122
89
|
const documentLoader = getDocumentLoader();
|
|
@@ -336,23 +303,20 @@ test({
|
|
|
336
303
|
publicKey: ed25519PublicKey.publicKey
|
|
337
304
|
})
|
|
338
305
|
}]);
|
|
339
|
-
|
|
340
|
-
assertEquals(await loader("https://example.com/auth-check"), {
|
|
306
|
+
assertEquals(await (await ctx.getDocumentLoader({ identifier: "handle" }))("https://example.com/auth-check"), {
|
|
341
307
|
contextUrl: null,
|
|
342
308
|
documentUrl: "https://example.com/auth-check",
|
|
343
309
|
document: true
|
|
344
310
|
});
|
|
345
|
-
|
|
346
|
-
assertEquals(await loader2("https://example.com/auth-check"), {
|
|
311
|
+
assertEquals(await (await ctx.getDocumentLoader({ username: "HANDLE" }))("https://example.com/auth-check"), {
|
|
347
312
|
contextUrl: null,
|
|
348
313
|
documentUrl: "https://example.com/auth-check",
|
|
349
314
|
document: true
|
|
350
315
|
});
|
|
351
|
-
|
|
316
|
+
assertEquals(await ctx.getDocumentLoader({
|
|
352
317
|
keyId: new URL("https://example.com/key2"),
|
|
353
318
|
privateKey: rsaPrivateKey2
|
|
354
|
-
})
|
|
355
|
-
assertEquals(await loader3("https://example.com/auth-check"), {
|
|
319
|
+
})("https://example.com/auth-check"), {
|
|
356
320
|
contextUrl: null,
|
|
357
321
|
documentUrl: "https://example.com/auth-check",
|
|
358
322
|
document: true
|
|
@@ -366,13 +330,11 @@ test({
|
|
|
366
330
|
id: "https://example.com/object",
|
|
367
331
|
name: "Fetched object"
|
|
368
332
|
}), { headers: { "Content-Type": "application/activity+json" } }));
|
|
369
|
-
|
|
333
|
+
assertEquals(await createFederation({
|
|
370
334
|
kv,
|
|
371
335
|
documentLoaderFactory: () => documentLoader,
|
|
372
336
|
contextLoaderFactory: () => mockDocumentLoader
|
|
373
|
-
})
|
|
374
|
-
const ctx2 = federation2.createContext(new URL("https://example.com/"), 123);
|
|
375
|
-
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({
|
|
376
338
|
id: new URL("https://example.com/object"),
|
|
377
339
|
name: "Fetched object"
|
|
378
340
|
}));
|
|
@@ -597,8 +559,7 @@ test({
|
|
|
597
559
|
});
|
|
598
560
|
});
|
|
599
561
|
await t.step("Context.clone()", () => {
|
|
600
|
-
const
|
|
601
|
-
const ctx = federation.createContext(new URL("https://example.com/"), 123);
|
|
562
|
+
const ctx = createFederation({ kv }).createContext(new URL("https://example.com/"), 123);
|
|
602
563
|
const clone = ctx.clone(456);
|
|
603
564
|
assertStrictEquals(clone.canonicalOrigin, ctx.canonicalOrigin);
|
|
604
565
|
assertStrictEquals(clone.origin, ctx.origin);
|
|
@@ -634,13 +595,11 @@ test({
|
|
|
634
595
|
}));
|
|
635
596
|
});
|
|
636
597
|
await t.step("Context.lookupNodeInfo()", async () => {
|
|
637
|
-
const
|
|
598
|
+
const ctx = createFederation({
|
|
638
599
|
kv,
|
|
639
600
|
userAgent: "CustomUserAgent/1.2.3"
|
|
640
|
-
});
|
|
641
|
-
|
|
642
|
-
const nodeInfo = await ctx.lookupNodeInfo("https://example.com/");
|
|
643
|
-
assertEquals(nodeInfo, {
|
|
601
|
+
}).createContext(new URL("https://example.com/"), 123);
|
|
602
|
+
assertEquals(await ctx.lookupNodeInfo("https://example.com/"), {
|
|
644
603
|
software: {
|
|
645
604
|
name: "foo",
|
|
646
605
|
version: "1.2.3"
|
|
@@ -652,8 +611,7 @@ test({
|
|
|
652
611
|
localComments: 456
|
|
653
612
|
}
|
|
654
613
|
});
|
|
655
|
-
|
|
656
|
-
assertEquals(rawNodeInfo, {
|
|
614
|
+
assertEquals(await ctx.lookupNodeInfo("https://example.com/", { parse: "none" }), {
|
|
657
615
|
software: {
|
|
658
616
|
name: "foo",
|
|
659
617
|
version: "1.2.3"
|
|
@@ -736,13 +694,11 @@ test({
|
|
|
736
694
|
return mockDocumentLoader(url);
|
|
737
695
|
};
|
|
738
696
|
const signedReq = await signRequest(new Request("https://example.com/", { headers: { accept: "application/activity+json" } }), rsaPrivateKey3, rsaPublicKey3.id);
|
|
739
|
-
|
|
697
|
+
assertEquals(await createFederation({
|
|
740
698
|
kv,
|
|
741
699
|
documentLoaderFactory: () => customDocumentLoader,
|
|
742
700
|
contextLoaderFactory: () => mockDocumentLoader
|
|
743
|
-
});
|
|
744
|
-
const ctx = fed.createContext(signedReq, void 0);
|
|
745
|
-
assertEquals(await ctx.getSignedKeyOwner(), null);
|
|
701
|
+
}).createContext(signedReq, void 0).getSignedKeyOwner(), null);
|
|
746
702
|
});
|
|
747
703
|
await t.step("RequestContext.clone()", () => {
|
|
748
704
|
const federation = createFederation({ kv });
|
|
@@ -782,8 +738,7 @@ test("Federation.fetch()", async (t) => {
|
|
|
782
738
|
authenticatedDocumentLoaderFactory(identity) {
|
|
783
739
|
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
784
740
|
return (url) => {
|
|
785
|
-
|
|
786
|
-
if (urlObj.host === "example.com") return docLoader(url);
|
|
741
|
+
if (new URL(url).host === "example.com") return docLoader(url);
|
|
787
742
|
return mockDocumentLoader(url);
|
|
788
743
|
};
|
|
789
744
|
}
|
|
@@ -806,7 +761,6 @@ test("Federation.fetch()", async (t) => {
|
|
|
806
761
|
});
|
|
807
762
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, (_ctx, activity) => {
|
|
808
763
|
inbox.push(activity.id.toString());
|
|
809
|
-
return;
|
|
810
764
|
});
|
|
811
765
|
return {
|
|
812
766
|
federation,
|
|
@@ -830,10 +784,9 @@ test("Federation.fetch()", async (t) => {
|
|
|
830
784
|
},
|
|
831
785
|
body: JSON.stringify(create_default)
|
|
832
786
|
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
833
|
-
|
|
834
|
-
assertEquals(response.status, 202);
|
|
787
|
+
assertEquals((await federation.fetch(request, { contextData: void 0 })).status, 202);
|
|
835
788
|
assertEquals(inbox.length, 1, "Expected one item in the inbox, json");
|
|
836
|
-
assertEquals(inbox[0],
|
|
789
|
+
assertEquals(inbox[0], id$2);
|
|
837
790
|
});
|
|
838
791
|
await t.step("GET with application/json", async () => {
|
|
839
792
|
const { federation, dispatches } = createTestContext();
|
|
@@ -854,10 +807,9 @@ test("Federation.fetch()", async (t) => {
|
|
|
854
807
|
},
|
|
855
808
|
body: JSON.stringify(create_default)
|
|
856
809
|
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
857
|
-
|
|
858
|
-
assertEquals(response.status, 202);
|
|
810
|
+
assertEquals((await federation.fetch(request, { contextData: void 0 })).status, 202);
|
|
859
811
|
assertEquals(inbox.length, 1, "Expected one inbox activity, ld+json");
|
|
860
|
-
assertEquals(inbox[0],
|
|
812
|
+
assertEquals(inbox[0], id$2);
|
|
861
813
|
});
|
|
862
814
|
await t.step("GET with application/ld+json", async () => {
|
|
863
815
|
const { federation, dispatches } = createTestContext();
|
|
@@ -879,10 +831,9 @@ test("Federation.fetch()", async (t) => {
|
|
|
879
831
|
},
|
|
880
832
|
body: JSON.stringify(create_default)
|
|
881
833
|
}), rsaPrivateKey2, rsaPublicKey2.id);
|
|
882
|
-
|
|
883
|
-
assertEquals(response.status, 202);
|
|
834
|
+
assertEquals((await federation.fetch(request, { contextData: void 0 })).status, 202);
|
|
884
835
|
assertEquals(inbox.length, 1);
|
|
885
|
-
assertEquals(inbox[0],
|
|
836
|
+
assertEquals(inbox[0], id$2);
|
|
886
837
|
});
|
|
887
838
|
await t.step("GET with application/activity+json", async () => {
|
|
888
839
|
const { federation, dispatches } = createTestContext();
|
|
@@ -1083,7 +1034,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
1083
1034
|
await inbox[0][0].documentLoader("https://example.com/person");
|
|
1084
1035
|
assertEquals(authenticatedRequests, [["https://example.com/person", "https://example.com/users/john#main-key"]]);
|
|
1085
1036
|
});
|
|
1086
|
-
await t.step("onUnverifiedActivity()", async (t
|
|
1037
|
+
await t.step("onUnverifiedActivity()", async (t) => {
|
|
1087
1038
|
const options = {
|
|
1088
1039
|
documentLoader: mockDocumentLoader,
|
|
1089
1040
|
contextLoader: mockDocumentLoader
|
|
@@ -1100,41 +1051,39 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
1100
1051
|
if (signature != null) request = await signRequest(request, signature.privateKey, signature.keyId);
|
|
1101
1052
|
return request;
|
|
1102
1053
|
}
|
|
1103
|
-
function createFederationWithLoader(documentLoader
|
|
1054
|
+
function createFederationWithLoader(documentLoader) {
|
|
1104
1055
|
const federation = createFederation({
|
|
1105
1056
|
kv: new MemoryKvStore(),
|
|
1106
|
-
documentLoaderFactory: () => documentLoader
|
|
1057
|
+
documentLoaderFactory: () => documentLoader,
|
|
1107
1058
|
contextLoaderFactory: () => mockDocumentLoader
|
|
1108
1059
|
});
|
|
1109
1060
|
const verified = [];
|
|
1110
1061
|
federation.setActorDispatcher("/users/{identifier}", () => {
|
|
1111
1062
|
return new vocab.Person({});
|
|
1112
1063
|
});
|
|
1113
|
-
const inboxListeners = federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, (_ctx, activity) => {
|
|
1114
|
-
verified.push(activity);
|
|
1115
|
-
});
|
|
1116
1064
|
return {
|
|
1117
1065
|
federation,
|
|
1118
1066
|
verified,
|
|
1119
|
-
inboxListeners
|
|
1067
|
+
inboxListeners: federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, (_ctx, activity) => {
|
|
1068
|
+
verified.push(activity);
|
|
1069
|
+
})
|
|
1120
1070
|
};
|
|
1121
1071
|
}
|
|
1122
|
-
await t
|
|
1072
|
+
await t.step("receives noSignature reason", async () => {
|
|
1123
1073
|
const { federation, verified, inboxListeners } = createFederationWithLoader(mockDocumentLoader);
|
|
1124
1074
|
let receivedReason = null;
|
|
1125
1075
|
inboxListeners.onUnverifiedActivity((_ctx, _activity, reason) => {
|
|
1126
1076
|
receivedReason = reason;
|
|
1127
1077
|
return new Response(null, { status: 202 });
|
|
1128
1078
|
});
|
|
1129
|
-
|
|
1079
|
+
assertEquals((await federation.fetch(await createInboxRequest(new vocab.Create({
|
|
1130
1080
|
id: new URL("https://remote.example/activities/no-signature"),
|
|
1131
1081
|
actor: new URL("https://remote.example/actors/alice")
|
|
1132
|
-
})), { contextData: void 0 });
|
|
1133
|
-
assertEquals(response.status, 202);
|
|
1082
|
+
})), { contextData: void 0 })).status, 202);
|
|
1134
1083
|
assertEquals(receivedReason, { type: "noSignature" });
|
|
1135
1084
|
assertEquals(verified, []);
|
|
1136
1085
|
});
|
|
1137
|
-
await t
|
|
1086
|
+
await t.step("receives keyFetchError for 410 responses", async () => {
|
|
1138
1087
|
const goneKeyId = new URL("https://gone.example/actors/alice#main-key");
|
|
1139
1088
|
const goneLoader = async (url) => {
|
|
1140
1089
|
if (url === goneKeyId.href) throw new FetchError(goneKeyId, `HTTP 410: ${goneKeyId.href}`, new Response(null, { status: 410 }));
|
|
@@ -1146,20 +1095,19 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
1146
1095
|
receivedReason = reason;
|
|
1147
1096
|
return new Response(null, { status: 202 });
|
|
1148
1097
|
});
|
|
1149
|
-
|
|
1098
|
+
assertEquals((await federation.fetch(await createInboxRequest(new vocab.Create({
|
|
1150
1099
|
id: new URL("https://gone.example/activities/delete"),
|
|
1151
1100
|
actor: new URL("https://gone.example/actors/alice")
|
|
1152
1101
|
}), {
|
|
1153
1102
|
privateKey: rsaPrivateKey3,
|
|
1154
1103
|
keyId: goneKeyId
|
|
1155
|
-
}), { contextData: void 0 });
|
|
1156
|
-
assertEquals(response.status, 202);
|
|
1104
|
+
}), { contextData: void 0 })).status, 202);
|
|
1157
1105
|
assertEquals(verified, []);
|
|
1158
1106
|
assertEquals(receivedReason.type, "keyFetchError");
|
|
1159
1107
|
assertEquals(receivedReason.keyId.href, goneKeyId.href);
|
|
1160
1108
|
assertEquals(receivedReason.result.status, 410);
|
|
1161
1109
|
});
|
|
1162
|
-
await t
|
|
1110
|
+
await t.step("preserves keyFetchError details across retries", async () => {
|
|
1163
1111
|
const keyId = new URL("https://gone.example/actors/alice#main-key");
|
|
1164
1112
|
let keyFetches = 0;
|
|
1165
1113
|
const goneLoader = async (url) => {
|
|
@@ -1191,7 +1139,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
1191
1139
|
assertEquals(reasons[1].type, "keyFetchError");
|
|
1192
1140
|
assertEquals(reasons[1].result.status, 410);
|
|
1193
1141
|
});
|
|
1194
|
-
await t
|
|
1142
|
+
await t.step("falls back to 401 when handler returns void", async () => {
|
|
1195
1143
|
const missingKeyId = new URL("https://missing.example/actors/alice#main-key");
|
|
1196
1144
|
const missingLoader = async (url) => {
|
|
1197
1145
|
if (url === missingKeyId.href) throw new FetchError(missingKeyId, `HTTP 404: ${missingKeyId.href}`, new Response(null, { status: 404 }));
|
|
@@ -1202,19 +1150,18 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
1202
1150
|
inboxListeners.onUnverifiedActivity((_ctx, _activity, reason) => {
|
|
1203
1151
|
receivedReason = reason;
|
|
1204
1152
|
});
|
|
1205
|
-
|
|
1153
|
+
assertEquals((await federation.fetch(await createInboxRequest(new vocab.Create({
|
|
1206
1154
|
id: new URL("https://missing.example/activities/delete"),
|
|
1207
1155
|
actor: new URL("https://missing.example/actors/alice")
|
|
1208
1156
|
}), {
|
|
1209
1157
|
privateKey: rsaPrivateKey3,
|
|
1210
1158
|
keyId: missingKeyId
|
|
1211
|
-
}), { contextData: void 0 });
|
|
1212
|
-
assertEquals(response.status, 401);
|
|
1159
|
+
}), { contextData: void 0 })).status, 401);
|
|
1213
1160
|
assertEquals(verified, []);
|
|
1214
1161
|
assertEquals(receivedReason.type, "keyFetchError");
|
|
1215
1162
|
assertEquals(receivedReason.result.status, 404);
|
|
1216
1163
|
});
|
|
1217
|
-
await t
|
|
1164
|
+
await t.step("falls back to 401 and reports hook errors", async () => {
|
|
1218
1165
|
const missingKeyId = new URL("https://missing.example/actors/alice#main-key");
|
|
1219
1166
|
const missingLoader = async (url) => {
|
|
1220
1167
|
if (url === missingKeyId.href) throw new FetchError(missingKeyId, `HTTP 404: ${missingKeyId.href}`, new Response(null, { status: 404 }));
|
|
@@ -1227,18 +1174,17 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
1227
1174
|
}).onError((_ctx, error) => {
|
|
1228
1175
|
receivedErrorMessage = error.message;
|
|
1229
1176
|
});
|
|
1230
|
-
|
|
1177
|
+
assertEquals((await federation.fetch(await createInboxRequest(new vocab.Create({
|
|
1231
1178
|
id: new URL("https://missing.example/activities/error"),
|
|
1232
1179
|
actor: new URL("https://missing.example/actors/alice")
|
|
1233
1180
|
}), {
|
|
1234
1181
|
privateKey: rsaPrivateKey3,
|
|
1235
1182
|
keyId: missingKeyId
|
|
1236
|
-
}), { contextData: void 0 });
|
|
1237
|
-
assertEquals(response.status, 401);
|
|
1183
|
+
}), { contextData: void 0 })).status, 401);
|
|
1238
1184
|
assertEquals(verified, []);
|
|
1239
1185
|
assertEquals(receivedErrorMessage, "Intended unverified hook failure");
|
|
1240
1186
|
});
|
|
1241
|
-
await t
|
|
1187
|
+
await t.step("receives invalidSignature reason", async () => {
|
|
1242
1188
|
const { federation, verified, inboxListeners } = createFederationWithLoader(mockDocumentLoader);
|
|
1243
1189
|
let receivedReason = null;
|
|
1244
1190
|
inboxListeners.onUnverifiedActivity((_ctx, _activity, reason) => {
|
|
@@ -1246,33 +1192,31 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
1246
1192
|
return new Response(null, { status: 202 });
|
|
1247
1193
|
});
|
|
1248
1194
|
const keyId = new URL("https://example.com/person2#key3");
|
|
1249
|
-
|
|
1195
|
+
assertEquals((await federation.fetch(await createInboxRequest(new vocab.Create({
|
|
1250
1196
|
id: new URL("https://example.com/activities/invalid-signature"),
|
|
1251
1197
|
actor: new URL("https://example.com/person2")
|
|
1252
1198
|
}), {
|
|
1253
1199
|
privateKey: rsaPrivateKey2,
|
|
1254
1200
|
keyId
|
|
1255
|
-
}), { contextData: void 0 });
|
|
1256
|
-
assertEquals(response.status, 202);
|
|
1201
|
+
}), { contextData: void 0 })).status, 202);
|
|
1257
1202
|
assertEquals(verified, []);
|
|
1258
1203
|
assertEquals(receivedReason.type, "invalidSignature");
|
|
1259
1204
|
assertEquals(receivedReason.keyId.href, keyId.href);
|
|
1260
1205
|
});
|
|
1261
|
-
await t
|
|
1206
|
+
await t.step("does not run for verified activities", async () => {
|
|
1262
1207
|
const { federation, verified, inboxListeners } = createFederationWithLoader(mockDocumentLoader);
|
|
1263
1208
|
let unverifiedCalls = 0;
|
|
1264
1209
|
inboxListeners.onUnverifiedActivity(() => {
|
|
1265
1210
|
unverifiedCalls++;
|
|
1266
1211
|
return new Response(null, { status: 202 });
|
|
1267
1212
|
});
|
|
1268
|
-
|
|
1213
|
+
assertEquals((await federation.fetch(await createInboxRequest(new vocab.Create({
|
|
1269
1214
|
id: new URL("https://example.com/activities/verified"),
|
|
1270
1215
|
actor: new URL("https://example.com/person2")
|
|
1271
1216
|
}), {
|
|
1272
1217
|
privateKey: rsaPrivateKey3,
|
|
1273
1218
|
keyId: new URL("https://example.com/person2#key3")
|
|
1274
|
-
}), { contextData: void 0 });
|
|
1275
|
-
assertEquals(response.status, 202);
|
|
1219
|
+
}), { contextData: void 0 })).status, 202);
|
|
1276
1220
|
assertEquals(unverifiedCalls, 0);
|
|
1277
1221
|
assertEquals(verified.length, 1);
|
|
1278
1222
|
});
|
|
@@ -1284,8 +1228,7 @@ test("Federation.setInboxListeners()", async (t) => {
|
|
|
1284
1228
|
authenticatedDocumentLoaderFactory(identity) {
|
|
1285
1229
|
const docLoader = getAuthenticatedDocumentLoader(identity);
|
|
1286
1230
|
return (url) => {
|
|
1287
|
-
|
|
1288
|
-
if (urlObj.host === "example.com") return docLoader(url);
|
|
1231
|
+
if (new URL(url).host === "example.com") return docLoader(url);
|
|
1289
1232
|
return mockDocumentLoader(url);
|
|
1290
1233
|
};
|
|
1291
1234
|
}
|
|
@@ -1368,9 +1311,8 @@ test("FederationImpl.sendActivity()", async (t) => {
|
|
|
1368
1311
|
if (verified.length > 0) return new Response(null, { status: 202 });
|
|
1369
1312
|
return new Response(null, { status: 401 });
|
|
1370
1313
|
});
|
|
1371
|
-
const kv = new MemoryKvStore();
|
|
1372
1314
|
const federation = new FederationImpl({
|
|
1373
|
-
kv,
|
|
1315
|
+
kv: new MemoryKvStore(),
|
|
1374
1316
|
contextLoaderFactory: () => mockDocumentLoader
|
|
1375
1317
|
});
|
|
1376
1318
|
const context = federation.createContext(new URL("https://example.com/"));
|
|
@@ -1436,19 +1378,18 @@ test("FederationImpl.processQueuedTask()", async (t) => {
|
|
|
1436
1378
|
await t.step("with MessageQueue having nativeRetrial", async () => {
|
|
1437
1379
|
const kv = new MemoryKvStore();
|
|
1438
1380
|
const queuedMessages = [];
|
|
1439
|
-
const queue = {
|
|
1440
|
-
nativeRetrial: true,
|
|
1441
|
-
enqueue(message, _options) {
|
|
1442
|
-
queuedMessages.push(message);
|
|
1443
|
-
return Promise.resolve();
|
|
1444
|
-
},
|
|
1445
|
-
listen(_handler, _options) {
|
|
1446
|
-
return Promise.resolve();
|
|
1447
|
-
}
|
|
1448
|
-
};
|
|
1449
1381
|
const federation = new FederationImpl({
|
|
1450
1382
|
kv,
|
|
1451
|
-
queue
|
|
1383
|
+
queue: {
|
|
1384
|
+
nativeRetrial: true,
|
|
1385
|
+
enqueue(message, _options) {
|
|
1386
|
+
queuedMessages.push(message);
|
|
1387
|
+
return Promise.resolve();
|
|
1388
|
+
},
|
|
1389
|
+
listen(_handler, _options) {
|
|
1390
|
+
return Promise.resolve();
|
|
1391
|
+
}
|
|
1392
|
+
}
|
|
1452
1393
|
});
|
|
1453
1394
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
|
|
1454
1395
|
throw new Error("Intended error for testing");
|
|
@@ -1499,18 +1440,17 @@ test("FederationImpl.processQueuedTask()", async (t) => {
|
|
|
1499
1440
|
await t.step("with MessageQueue having no nativeRetrial", async () => {
|
|
1500
1441
|
const kv = new MemoryKvStore();
|
|
1501
1442
|
let queuedMessages = [];
|
|
1502
|
-
const queue = {
|
|
1503
|
-
enqueue(message, _options) {
|
|
1504
|
-
queuedMessages.push(message);
|
|
1505
|
-
return Promise.resolve();
|
|
1506
|
-
},
|
|
1507
|
-
listen(_handler, _options) {
|
|
1508
|
-
return Promise.resolve();
|
|
1509
|
-
}
|
|
1510
|
-
};
|
|
1511
1443
|
const federation = new FederationImpl({
|
|
1512
1444
|
kv,
|
|
1513
|
-
queue
|
|
1445
|
+
queue: {
|
|
1446
|
+
enqueue(message, _options) {
|
|
1447
|
+
queuedMessages.push(message);
|
|
1448
|
+
return Promise.resolve();
|
|
1449
|
+
},
|
|
1450
|
+
listen(_handler, _options) {
|
|
1451
|
+
return Promise.resolve();
|
|
1452
|
+
}
|
|
1453
|
+
}
|
|
1514
1454
|
});
|
|
1515
1455
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox").on(vocab.Create, () => {
|
|
1516
1456
|
throw new Error("Intended error for testing");
|
|
@@ -1589,19 +1529,18 @@ test("FederationImpl.processQueuedTask() permanent failure", async (t) => {
|
|
|
1589
1529
|
function setup(options = {}) {
|
|
1590
1530
|
const kv = new MemoryKvStore();
|
|
1591
1531
|
const queuedMessages = [];
|
|
1592
|
-
const queue = {
|
|
1593
|
-
...options.nativeRetrial ? { nativeRetrial: true } : {},
|
|
1594
|
-
enqueue(message, _options) {
|
|
1595
|
-
queuedMessages.push(message);
|
|
1596
|
-
return Promise.resolve();
|
|
1597
|
-
},
|
|
1598
|
-
listen(_handler, _options) {
|
|
1599
|
-
return Promise.resolve();
|
|
1600
|
-
}
|
|
1601
|
-
};
|
|
1602
1532
|
const federation = new FederationImpl({
|
|
1603
1533
|
kv,
|
|
1604
|
-
queue
|
|
1534
|
+
queue: {
|
|
1535
|
+
...options.nativeRetrial ? { nativeRetrial: true } : {},
|
|
1536
|
+
enqueue(message, _options) {
|
|
1537
|
+
queuedMessages.push(message);
|
|
1538
|
+
return Promise.resolve();
|
|
1539
|
+
},
|
|
1540
|
+
listen(_handler, _options) {
|
|
1541
|
+
return Promise.resolve();
|
|
1542
|
+
}
|
|
1543
|
+
},
|
|
1605
1544
|
...options.permanentFailureStatusCodes ? { permanentFailureStatusCodes: options.permanentFailureStatusCodes } : {}
|
|
1606
1545
|
});
|
|
1607
1546
|
federation.setInboxListeners("/users/{identifier}/inbox", "/inbox");
|
|
@@ -1751,24 +1690,19 @@ test("ContextImpl.lookupObject()", async (t) => {
|
|
|
1751
1690
|
}
|
|
1752
1691
|
});
|
|
1753
1692
|
await t.step("allowPrivateAddress: true", async () => {
|
|
1754
|
-
const
|
|
1693
|
+
const result = await createFederation({
|
|
1755
1694
|
kv: new MemoryKvStore(),
|
|
1756
1695
|
allowPrivateAddress: true
|
|
1757
|
-
});
|
|
1758
|
-
const ctx = federation.createContext(new URL("https://example.com/"));
|
|
1759
|
-
const result = await ctx.lookupObject("@test@localhost");
|
|
1696
|
+
}).createContext(new URL("https://example.com/")).lookupObject("@test@localhost");
|
|
1760
1697
|
assertInstanceOf(result, vocab.Person);
|
|
1761
1698
|
assertEquals(result.id, new URL("https://localhost/actor"));
|
|
1762
1699
|
assertEquals(result.preferredUsername, "test");
|
|
1763
1700
|
});
|
|
1764
1701
|
await t.step("allowPrivateAddress: false", async () => {
|
|
1765
|
-
|
|
1702
|
+
assertEquals(await createFederation({
|
|
1766
1703
|
kv: new MemoryKvStore(),
|
|
1767
1704
|
allowPrivateAddress: false
|
|
1768
|
-
});
|
|
1769
|
-
const ctx = federation.createContext(new URL("https://example.com/"));
|
|
1770
|
-
const result = await ctx.lookupObject("@test@localhost");
|
|
1771
|
-
assertEquals(result, null);
|
|
1705
|
+
}).createContext(new URL("https://example.com/")).lookupObject("@test@localhost"), null);
|
|
1772
1706
|
});
|
|
1773
1707
|
esm_default.hardReset();
|
|
1774
1708
|
});
|
|
@@ -1794,11 +1728,9 @@ test("ContextImpl.sendActivity()", async (t) => {
|
|
|
1794
1728
|
contextLoader: mockDocumentLoader,
|
|
1795
1729
|
keyCache: {
|
|
1796
1730
|
async get(keyId) {
|
|
1797
|
-
const
|
|
1798
|
-
const keys
|
|
1799
|
-
|
|
1800
|
-
else return key$1.cryptographicKey;
|
|
1801
|
-
return void 0;
|
|
1731
|
+
const keys = await federation.createContext(new URL("https://example.com/"), void 0).getActorKeyPairs("1");
|
|
1732
|
+
for (const key of keys) if (key.keyId.href === keyId.href) if (key.publicKey.algorithm.name === "Ed25519") return key.multikey;
|
|
1733
|
+
else return key.cryptographicKey;
|
|
1802
1734
|
},
|
|
1803
1735
|
async set(_keyId, _key) {}
|
|
1804
1736
|
}
|
|
@@ -2140,8 +2072,8 @@ test({
|
|
|
2140
2072
|
async fn() {
|
|
2141
2073
|
const federation = new FederationImpl({ kv: new MemoryKvStore() });
|
|
2142
2074
|
const activities = [];
|
|
2143
|
-
federation.setInboxListeners("/u/{identifier}/i", "/i").on(vocab.Offer, (ctx
|
|
2144
|
-
activities.push([ctx
|
|
2075
|
+
federation.setInboxListeners("/u/{identifier}/i", "/i").on(vocab.Offer, (ctx, offer) => {
|
|
2076
|
+
activities.push([ctx.recipient, offer]);
|
|
2145
2077
|
});
|
|
2146
2078
|
const ctx = new ContextImpl({
|
|
2147
2079
|
url: new URL("https://example.com/"),
|
|
@@ -2255,26 +2187,23 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
2255
2187
|
if (verified.length > 0) return new Response(null, { status: 202 });
|
|
2256
2188
|
return new Response(null, { status: 401 });
|
|
2257
2189
|
});
|
|
2258
|
-
const kv = new MemoryKvStore();
|
|
2259
2190
|
const federation = new FederationImpl({
|
|
2260
|
-
kv,
|
|
2191
|
+
kv: new MemoryKvStore(),
|
|
2261
2192
|
contextLoaderFactory: () => mockDocumentLoader
|
|
2262
2193
|
});
|
|
2263
2194
|
await t.step("skip", async () => {
|
|
2264
|
-
|
|
2195
|
+
await new InboxContextImpl(null, {
|
|
2265
2196
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2266
2197
|
"type": "Create",
|
|
2267
2198
|
"id": "https://example.com/activity",
|
|
2268
2199
|
"actor": "https://example.com/person2"
|
|
2269
|
-
}
|
|
2270
|
-
const ctx = new InboxContextImpl(null, activity, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2200
|
+
}, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2271
2201
|
data: void 0,
|
|
2272
2202
|
federation,
|
|
2273
2203
|
url: new URL("https://example.com/"),
|
|
2274
2204
|
documentLoader,
|
|
2275
2205
|
contextLoader: documentLoader
|
|
2276
|
-
})
|
|
2277
|
-
await ctx.forwardActivity([{
|
|
2206
|
+
}).forwardActivity([{
|
|
2278
2207
|
privateKey: rsaPrivateKey2,
|
|
2279
2208
|
keyId: rsaPublicKey2.id
|
|
2280
2209
|
}], {
|
|
@@ -2284,13 +2213,12 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
2284
2213
|
assertEquals(verified, null);
|
|
2285
2214
|
});
|
|
2286
2215
|
await t.step("unsigned", async () => {
|
|
2287
|
-
const
|
|
2216
|
+
const ctx = new InboxContextImpl(null, {
|
|
2288
2217
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2289
2218
|
"type": "Create",
|
|
2290
2219
|
"id": "https://example.com/activity",
|
|
2291
2220
|
"actor": "https://example.com/person2"
|
|
2292
|
-
}
|
|
2293
|
-
const ctx = new InboxContextImpl(null, activity, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2221
|
+
}, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2294
2222
|
data: void 0,
|
|
2295
2223
|
federation,
|
|
2296
2224
|
url: new URL("https://example.com/"),
|
|
@@ -2314,14 +2242,13 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
2314
2242
|
contextLoader: mockDocumentLoader,
|
|
2315
2243
|
documentLoader: mockDocumentLoader
|
|
2316
2244
|
});
|
|
2317
|
-
|
|
2245
|
+
await new InboxContextImpl(null, await activity.toJsonLd({ contextLoader: mockDocumentLoader }), activity.id?.href, getTypeId(activity).href, {
|
|
2318
2246
|
data: void 0,
|
|
2319
2247
|
federation,
|
|
2320
2248
|
url: new URL("https://example.com/"),
|
|
2321
2249
|
documentLoader,
|
|
2322
2250
|
contextLoader: documentLoader
|
|
2323
|
-
})
|
|
2324
|
-
await ctx.forwardActivity([{
|
|
2251
|
+
}).forwardActivity([{
|
|
2325
2252
|
privateKey: rsaPrivateKey2,
|
|
2326
2253
|
keyId: rsaPublicKey2.id
|
|
2327
2254
|
}], {
|
|
@@ -2331,20 +2258,18 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
2331
2258
|
assertEquals(verified, ["proof"]);
|
|
2332
2259
|
});
|
|
2333
2260
|
await t.step("LD Signatures", async () => {
|
|
2334
|
-
|
|
2261
|
+
await new InboxContextImpl(null, await signJsonLd({
|
|
2335
2262
|
"@context": "https://www.w3.org/ns/activitystreams",
|
|
2336
2263
|
"type": "Create",
|
|
2337
2264
|
"id": "https://example.com/activity",
|
|
2338
2265
|
"actor": "https://example.com/person2"
|
|
2339
|
-
}, rsaPrivateKey3, rsaPublicKey3.id, { contextLoader: mockDocumentLoader })
|
|
2340
|
-
const ctx = new InboxContextImpl(null, activity, "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2266
|
+
}, rsaPrivateKey3, rsaPublicKey3.id, { contextLoader: mockDocumentLoader }), "https://example.com/activity", "https://www.w3.org/ns/activitystreams#Create", {
|
|
2341
2267
|
data: void 0,
|
|
2342
2268
|
federation,
|
|
2343
2269
|
url: new URL("https://example.com/"),
|
|
2344
2270
|
documentLoader,
|
|
2345
2271
|
contextLoader: documentLoader
|
|
2346
|
-
})
|
|
2347
|
-
await ctx.forwardActivity([{
|
|
2272
|
+
}).forwardActivity([{
|
|
2348
2273
|
privateKey: rsaPrivateKey2,
|
|
2349
2274
|
keyId: rsaPublicKey2.id
|
|
2350
2275
|
}], {
|
|
@@ -2357,33 +2282,19 @@ test("InboxContextImpl.forwardActivity()", async (t) => {
|
|
|
2357
2282
|
});
|
|
2358
2283
|
test("KvSpecDeterminer", async (t) => {
|
|
2359
2284
|
await t.step("should use default spec when not found in KV", async () => {
|
|
2360
|
-
|
|
2361
|
-
const prefix = ["test", "spec"];
|
|
2362
|
-
const determiner = new KvSpecDeterminer(kv, prefix);
|
|
2363
|
-
const spec = await determiner.determineSpec("example.com");
|
|
2364
|
-
assertEquals(spec, "rfc9421");
|
|
2285
|
+
assertEquals(await new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"]).determineSpec("example.com"), "rfc9421");
|
|
2365
2286
|
});
|
|
2366
2287
|
await t.step("should use custom default spec", async () => {
|
|
2367
|
-
|
|
2368
|
-
const prefix = ["test", "spec"];
|
|
2369
|
-
const determiner = new KvSpecDeterminer(kv, prefix, "draft-cavage-http-signatures-12");
|
|
2370
|
-
const spec = await determiner.determineSpec("example.com");
|
|
2371
|
-
assertEquals(spec, "draft-cavage-http-signatures-12");
|
|
2288
|
+
assertEquals(await new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"], "draft-cavage-http-signatures-12").determineSpec("example.com"), "draft-cavage-http-signatures-12");
|
|
2372
2289
|
});
|
|
2373
2290
|
await t.step("should remember and retrieve spec from KV", async () => {
|
|
2374
|
-
const
|
|
2375
|
-
const prefix = ["test", "spec"];
|
|
2376
|
-
const determiner = new KvSpecDeterminer(kv, prefix);
|
|
2291
|
+
const determiner = new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"]);
|
|
2377
2292
|
await determiner.rememberSpec("example.com", "draft-cavage-http-signatures-12");
|
|
2378
|
-
|
|
2379
|
-
assertEquals(
|
|
2380
|
-
const defaultSpec = await determiner.determineSpec("other.com");
|
|
2381
|
-
assertEquals(defaultSpec, "rfc9421");
|
|
2293
|
+
assertEquals(await determiner.determineSpec("example.com"), "draft-cavage-http-signatures-12");
|
|
2294
|
+
assertEquals(await determiner.determineSpec("other.com"), "rfc9421");
|
|
2382
2295
|
});
|
|
2383
2296
|
await t.step("should override remembered spec", async () => {
|
|
2384
|
-
const
|
|
2385
|
-
const prefix = ["test", "spec"];
|
|
2386
|
-
const determiner = new KvSpecDeterminer(kv, prefix);
|
|
2297
|
+
const determiner = new KvSpecDeterminer(new MemoryKvStore(), ["test", "spec"]);
|
|
2387
2298
|
await determiner.rememberSpec("example.com", "draft-cavage-http-signatures-12");
|
|
2388
2299
|
let spec = await determiner.determineSpec("example.com");
|
|
2389
2300
|
assertEquals(spec, "draft-cavage-http-signatures-12");
|
|
@@ -2392,5 +2303,5 @@ test("KvSpecDeterminer", async (t) => {
|
|
|
2392
2303
|
assertEquals(spec, "rfc9421");
|
|
2393
2304
|
});
|
|
2394
2305
|
});
|
|
2395
|
-
|
|
2396
|
-
|
|
2306
|
+
//#endregion
|
|
2307
|
+
export {};
|