@fedify/fedify 2.1.31 → 2.1.32
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/attachment-arrays-DZ4JHJD8.mjs +111 -0
- package/dist/{builder-isMRh_I6.mjs → builder--sc-rozj.mjs} +3 -3
- package/dist/callback-BARPujV7.d.mts +2388 -0
- package/dist/{client-BIBzqEIp.d.cts → client-9DPcy_Yx.d.ts} +16 -0
- package/dist/{client-jE7oGvRh.d.ts → client-B3ruDgWg.d.cts} +16 -0
- package/dist/{client-BZr7TGyu.mjs → client-cpPaW7Ww.mjs} +86 -11
- package/dist/compat/attachment-arrays.test.d.mts +2 -0
- package/dist/compat/attachment-arrays.test.mjs +254 -0
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{context-C0uGVzgk.d.ts → context-DE2YrQwM.d.ts} +30 -13
- package/dist/{context-CLaLxi49.d.cts → context-y6ZUQCMf.d.cts} +30 -13
- package/dist/{deno-CiaJqTcu.mjs → deno-L23b3Hba.mjs} +1 -1
- package/dist/{docloader-DOrwedT7.mjs → docloader-DUXr9k_O.mjs} +2 -2
- package/dist/federation/attachment-responses.test.d.mts +2 -0
- package/dist/federation/attachment-responses.test.mjs +182 -0
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/collection.test.mjs +1 -1
- package/dist/federation/delivery-attachments.test.d.mts +2 -0
- package/dist/federation/delivery-attachments.test.mjs +280 -0
- package/dist/federation/handler.test.mjs +208 -16
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +1185 -8
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +1 -1
- package/dist/federation/negotiation.test.mjs +1 -1
- package/dist/federation/retry.test.mjs +1 -1
- package/dist/federation/send.test.mjs +283 -3
- package/dist/federation/temporal.test.mjs +25 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{http-Crml3gei.js → http-BtbMAgTA.js} +6 -4
- package/dist/{http-9IFUxdkp.d.cts → http-C8qLHs_Z.d.cts} +3 -3
- package/dist/{http-CRiVlZd5.cjs → http-D5woFKA_.cjs} +6 -4
- package/dist/{http-SbfezERn.d.ts → http-D8WmcRAF.d.ts} +3 -3
- package/dist/{http-A9mP2uM7.mjs → http-HX6wVyJh.mjs} +6 -4
- package/dist/{inbox-KESLudq4.mjs → inbox-CL7A0HXT.mjs} +1 -1
- package/dist/{key-Dg6-DV_O.mjs → key-Dai3f5yI.mjs} +3 -2
- package/dist/{kv-cache-Cqmm-yQa.cjs → kv-cache-B0V_e231.cjs} +1 -1
- package/dist/{kv-cache-DQcyZL5T.js → kv-cache-BsDg-cT8.js} +1 -1
- package/dist/{ld-COjDN6Nb.mjs → ld-DN6x1iZ8.mjs} +153 -21
- package/dist/ld-signature-DoZcbsZR.mjs +23 -0
- package/dist/{middleware-BtDQUCcz.cjs → middleware-Cl6k5Hrm.cjs} +1 -1
- package/dist/{middleware-BbgR7xOI.cjs → middleware-CrfRuKCf.cjs} +561 -101
- package/dist/{middleware-COFlKeYn.mjs → middleware-DiquMgtt.mjs} +378 -89
- package/dist/{middleware-DIW5S_5L.js → middleware-DunNtbo9.js} +560 -101
- package/dist/{middleware-CuQvczZd.mjs → middleware-SnQS8eIb.mjs} +1 -1
- package/dist/{mod-LOEOKbYd.d.cts → mod-CehHJOV4.d.cts} +30 -13
- package/dist/{mod-CFRocFeQ.d.ts → mod-DLJpnqdw.d.ts} +1 -1
- package/dist/{mod-C7w-QVUv.d.ts → mod-Mh3oIuRK.d.ts} +30 -13
- package/dist/{mod-BRnwh2oy.d.ts → mod-REfljt0T.d.ts} +3 -3
- package/dist/{mod-Co7LEK9X.d.cts → mod-UvIGUHqW.d.cts} +3 -3
- package/dist/{mod-CGUH8Ujp.d.cts → mod-sTa1Zzxk.d.cts} +1 -1
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +8 -8
- package/dist/mod.d.ts +8 -8
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +432 -5
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.d.cts +1 -1
- package/dist/nodeinfo/mod.d.ts +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/nodeinfo/types.test.mjs +1 -1
- package/dist/{owner-CFHq61cq.mjs → owner-DwyDorZI.mjs} +2 -2
- package/dist/{proof-0JkSC_pT.cjs → proof-Be-4K4jn.cjs} +193 -46
- package/dist/{proof-KSHlbPCG.mjs → proof-DYjmyrHh.mjs} +38 -13
- package/dist/{proof-DzksJFK7.js → proof-Du4-5SHY.js} +187 -46
- package/dist/{send-DaDe2YCb.mjs → send-BGSfQkIK.mjs} +92 -21
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key-types.test.d.mts +218 -0
- package/dist/sig/key-types.test.mjs +8 -0
- package/dist/sig/key.test.mjs +2 -2
- package/dist/sig/ld.test.mjs +573 -8
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/proof.test.mjs +95 -3
- package/dist/{temporal-DNGH8o2E.mjs → temporal-CNCchWly.mjs} +3 -5
- package/dist/testing/mod.d.mts +2 -2203
- package/dist/{types-DOvyymM4.cjs → types-B5wRhemi.cjs} +85 -10
- package/dist/{types-B1_pRFE_.js → types-CXy2lRVU.js} +86 -11
- package/dist/utils/docloader.test.mjs +2 -2
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -6
- /package/dist/{collection-BD6-SZ6O.mjs → collection-DnoYNwBC.mjs} +0 -0
- /package/dist/{negotiation-BehA2uul.mjs → negotiation-xb0QR3u_.mjs} +0 -0
- /package/dist/{retry-B_E3V_Dx.mjs → retry-CI1flGDD.mjs} +0 -0
- /package/dist/{types-DCP0WLdt.mjs → types-s4mCTGkT.mjs} +0 -0
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-
|
|
3
|
-
import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-
|
|
2
|
+
import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-B3ruDgWg.cjs";
|
|
3
|
+
import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-C8qLHs_Z.cjs";
|
|
4
4
|
import { n as GetKeyOwnerOptions } from "./owner-B3hNQCG8.cjs";
|
|
5
5
|
import { n as KvStore, t as KvKey } from "./kv-CZKl1IUS.cjs";
|
|
6
6
|
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, TraverseCollectionOptions } from "@fedify/vocab";
|
|
7
|
-
import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
|
|
7
|
+
import { AuthenticatedDocumentLoaderFactory, CryptoKeyLike, CryptoKeyPairLike, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
|
|
8
8
|
import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
|
|
9
9
|
import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
|
|
10
10
|
|
|
@@ -46,13 +46,18 @@ declare function buildCollectionSynchronizationHeader(collectionId: string | URL
|
|
|
46
46
|
//#region src/federation/send.d.ts
|
|
47
47
|
/**
|
|
48
48
|
* A key pair for an actor who sends an activity.
|
|
49
|
+
*
|
|
50
|
+
* The private key type is parameterized so that Fedify can accept keys from
|
|
51
|
+
* `node:crypto` at its input boundaries while `SenderKeyPair` still exposes the
|
|
52
|
+
* ambient `CryptoKey` type by default.
|
|
53
|
+
* @template TKey The type of the private key.
|
|
49
54
|
* @since 0.10.0
|
|
50
55
|
*/
|
|
51
|
-
interface SenderKeyPair {
|
|
56
|
+
interface SenderKeyPair<TKey extends CryptoKeyLike = CryptoKey> {
|
|
52
57
|
/**
|
|
53
58
|
* The actor's private key to sign the request.
|
|
54
59
|
*/
|
|
55
|
-
readonly privateKey:
|
|
60
|
+
readonly privateKey: TKey;
|
|
56
61
|
/**
|
|
57
62
|
* The public key ID that corresponds to the private key.
|
|
58
63
|
*/
|
|
@@ -116,13 +121,19 @@ type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, ide
|
|
|
116
121
|
/**
|
|
117
122
|
* A callback that dispatches key pairs for an actor.
|
|
118
123
|
*
|
|
124
|
+
* The returned key pairs may come from any supported runtime, including keys
|
|
125
|
+
* obtained from `node:crypto`'s Web Crypto API, so the key pair type is
|
|
126
|
+
* parameterized. It defaults to the ambient `CryptoKeyPair` type for
|
|
127
|
+
* compatibility with code that calls a dispatcher directly.
|
|
128
|
+
*
|
|
119
129
|
* @template TContextData The context data to pass to the {@link Context}.
|
|
130
|
+
* @template TKeyPair The type of the key pairs the dispatcher returns.
|
|
120
131
|
* @param context The context.
|
|
121
132
|
* @param identifier The actor's internal identifier or username.
|
|
122
133
|
* @returns The key pairs.
|
|
123
134
|
* @since 0.10.0
|
|
124
135
|
*/
|
|
125
|
-
type ActorKeyPairsDispatcher<TContextData> = (context: Context<TContextData>, identifier: string) =>
|
|
136
|
+
type ActorKeyPairsDispatcher<TContextData, TKeyPair extends CryptoKeyPairLike = CryptoKeyPair> = (context: Context<TContextData>, identifier: string) => TKeyPair[] | Promise<TKeyPair[]>;
|
|
126
137
|
/**
|
|
127
138
|
* A callback that maps a WebFinger username to the corresponding actor's
|
|
128
139
|
* internal identifier, or `null` if the username is not found.
|
|
@@ -252,11 +263,11 @@ type InboxErrorHandler<TContextData> = (context: Context<TContextData>, error: E
|
|
|
252
263
|
* not authorized.
|
|
253
264
|
* @since 0.11.0
|
|
254
265
|
*/
|
|
255
|
-
type SharedInboxKeyDispatcher<TContextData> = (context: Context<TContextData>) => SenderKeyPair | {
|
|
266
|
+
type SharedInboxKeyDispatcher<TContextData, TKeyPair extends CryptoKeyLike = CryptoKey> = (context: Context<TContextData>) => SenderKeyPair<TKeyPair> | {
|
|
256
267
|
identifier: string;
|
|
257
268
|
} | {
|
|
258
269
|
username: string;
|
|
259
|
-
} | null | Promise<SenderKeyPair | {
|
|
270
|
+
} | null | Promise<SenderKeyPair<TKeyPair> | {
|
|
260
271
|
identifier: string;
|
|
261
272
|
} | {
|
|
262
273
|
username: string;
|
|
@@ -1425,6 +1436,12 @@ interface FederationOptions<TContextData> {
|
|
|
1425
1436
|
*
|
|
1426
1437
|
* By default, the queue starts automatically.
|
|
1427
1438
|
*
|
|
1439
|
+
* Automatic startup is best-effort: if a queue cannot start listening,
|
|
1440
|
+
* a warning is logged once per federation instance and the failed worker is
|
|
1441
|
+
* not retried, while an explicit {@link Federation.startQueue} call rejects.
|
|
1442
|
+
* Runtimes that consume the queue elsewhere, such as Cloudflare Workers with
|
|
1443
|
+
* {@link Federation.processQueuedTask}, should set this to `true`.
|
|
1444
|
+
*
|
|
1428
1445
|
* @since 0.12.0
|
|
1429
1446
|
*/
|
|
1430
1447
|
manuallyStartQueue?: boolean;
|
|
@@ -1598,7 +1615,7 @@ interface ActorCallbackSetters<TContextData> {
|
|
|
1598
1615
|
* @returns The setters object so that settings can be chained.
|
|
1599
1616
|
* @since 0.10.0
|
|
1600
1617
|
*/
|
|
1601
|
-
setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
|
|
1618
|
+
setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData, CryptoKeyPairLike>): ActorCallbackSetters<TContextData>;
|
|
1602
1619
|
/**
|
|
1603
1620
|
* Sets the callback function that maps a WebFinger username to
|
|
1604
1621
|
* the corresponding actor's identifier. If it's omitted, the identifier
|
|
@@ -1765,7 +1782,7 @@ interface InboxListenerSetters<TContextData> {
|
|
|
1765
1782
|
* @returns The setters object so that settings can be chained.
|
|
1766
1783
|
* @since 0.11.0
|
|
1767
1784
|
*/
|
|
1768
|
-
setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
|
|
1785
|
+
setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData, CryptoKeyLike>): InboxListenerSetters<TContextData>;
|
|
1769
1786
|
/**
|
|
1770
1787
|
* Configures the strategy for handling activity idempotency in inbox processing.
|
|
1771
1788
|
*
|
|
@@ -2098,7 +2115,7 @@ interface Context<TContextData> {
|
|
|
2098
2115
|
*/
|
|
2099
2116
|
getDocumentLoader(identity: {
|
|
2100
2117
|
keyId: URL;
|
|
2101
|
-
privateKey:
|
|
2118
|
+
privateKey: CryptoKeyLike;
|
|
2102
2119
|
}): DocumentLoader;
|
|
2103
2120
|
/**
|
|
2104
2121
|
* Looks up an ActivityStreams object by its URI (including `acct:` URIs)
|
|
@@ -2211,7 +2228,7 @@ interface Context<TContextData> {
|
|
|
2211
2228
|
* @param activity The activity to send.
|
|
2212
2229
|
* @param options Options for sending the activity.
|
|
2213
2230
|
*/
|
|
2214
|
-
sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
|
|
2231
|
+
sendActivity(sender: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
|
|
2215
2232
|
identifier: string;
|
|
2216
2233
|
} | {
|
|
2217
2234
|
username: string;
|
|
@@ -2431,7 +2448,7 @@ interface InboxContext<TContextData> extends Context<TContextData> {
|
|
|
2431
2448
|
* @param options Options for forwarding the activity.
|
|
2432
2449
|
* @since 1.0.0
|
|
2433
2450
|
*/
|
|
2434
|
-
forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
|
|
2451
|
+
forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
|
|
2435
2452
|
identifier: string;
|
|
2436
2453
|
} | {
|
|
2437
2454
|
username: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { s as validateCryptoKey } from "./key-
|
|
5
|
-
import { r as doubleKnockScoped } from "./http-
|
|
4
|
+
import { s as validateCryptoKey } from "./key-Dai3f5yI.mjs";
|
|
5
|
+
import { r as doubleKnockScoped } from "./http-HX6wVyJh.mjs";
|
|
6
6
|
import { curry } from "es-toolkit";
|
|
7
7
|
import { FetchError, UrlError, createActivityPubRequest, getRemoteDocument, logRequest } from "@fedify/vocab-runtime";
|
|
8
8
|
import { openDirectFetch, openPublicFetch } from "@fedify/vocab-runtime/internal";
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
+
import "../std__assert-DflMZha5.mjs";
|
|
6
|
+
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
7
|
+
import { n as ed25519PrivateKey, t as ed25519Multikey } from "../keys-CtZLJq76.mjs";
|
|
8
|
+
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
9
|
+
import { i as verifyProof, n as signObject } from "../proof-DYjmyrHh.mjs";
|
|
10
|
+
import { a as createFederation, f as respondWithObject, p as respondWithObjectIfAcceptable } from "../middleware-DiquMgtt.mjs";
|
|
11
|
+
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
12
|
+
import { Note, Object as Object$1, OrderedCollection, PropertyValue, Service, Update } from "@fedify/vocab";
|
|
13
|
+
//#region src/federation/attachment-responses.test.ts
|
|
14
|
+
const ACCEPTS = ["application/activity+json", "application/ld+json; profile=\"https://www.w3.org/ns/activitystreams\""];
|
|
15
|
+
function profile(count) {
|
|
16
|
+
return new Service({
|
|
17
|
+
id: new URL("https://example.com/actors/app"),
|
|
18
|
+
preferredUsername: "app",
|
|
19
|
+
attachments: Array.from({ length: count }, (_, i) => new PropertyValue({
|
|
20
|
+
name: `Field ${i}`,
|
|
21
|
+
value: `https://example.com/${i}`
|
|
22
|
+
}))
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
function attachmentValues(value) {
|
|
26
|
+
if (Array.isArray(value)) return value.flatMap(attachmentValues);
|
|
27
|
+
if (typeof value !== "object" || value == null) return [];
|
|
28
|
+
return Object.entries(value).flatMap(([key, item]) => key === "@context" ? [] : key === "attachment" ? [item] : attachmentValues(item));
|
|
29
|
+
}
|
|
30
|
+
test("attachment responses: actor, object, collections and pages negotiate both media types", async () => {
|
|
31
|
+
for (const count of [1, 2]) {
|
|
32
|
+
const actor = profile(count);
|
|
33
|
+
const update = new Update({
|
|
34
|
+
id: new URL("https://example.com/updates/1"),
|
|
35
|
+
actor: actor.id,
|
|
36
|
+
object: actor
|
|
37
|
+
});
|
|
38
|
+
const federation = createFederation({ kv: new MemoryKvStore() });
|
|
39
|
+
federation.setActorDispatcher("/actors/{identifier}", () => actor);
|
|
40
|
+
federation.setObjectDispatcher(Note, "/notes/{id}", () => new Note({ attachments: Array.from({ length: count }, () => new Note({ content: "attachment" })) }));
|
|
41
|
+
federation.setFollowersDispatcher("/actors/{identifier}/followers", () => ({ items: [actor] }));
|
|
42
|
+
federation.setCollectionDispatcher("objects", Object$1, "/collections/{id}", () => ({ items: [update] }));
|
|
43
|
+
federation.setOrderedCollectionDispatcher("ordered", Object$1, "/ordered/{id}", () => ({ items: [update] }));
|
|
44
|
+
for (const accept of ACCEPTS) for (const path of [
|
|
45
|
+
"/actors/app",
|
|
46
|
+
"/notes/1",
|
|
47
|
+
"/actors/app/followers",
|
|
48
|
+
"/actors/app/followers?cursor=a",
|
|
49
|
+
"/collections/1",
|
|
50
|
+
"/collections/1?cursor=a",
|
|
51
|
+
"/ordered/1",
|
|
52
|
+
"/ordered/1?cursor=a"
|
|
53
|
+
]) {
|
|
54
|
+
const response = await federation.fetch(new Request(`https://example.com${path}`, { headers: { Accept: accept } }), { contextData: void 0 });
|
|
55
|
+
assertEquals(response.status, 200, path);
|
|
56
|
+
assertEquals(response.headers.get("Content-Type"), "application/activity+json");
|
|
57
|
+
assertEquals(response.headers.get("Vary"), "Accept");
|
|
58
|
+
const values = attachmentValues(await response.json());
|
|
59
|
+
assert(values.length > 0, path);
|
|
60
|
+
for (const value of values) {
|
|
61
|
+
assert(Array.isArray(value), path);
|
|
62
|
+
assertEquals(value.length, count, path);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
test("attachment responses: helpers normalize without changing the vocabulary cache", async () => {
|
|
68
|
+
const json = await profile(1).toJsonLd();
|
|
69
|
+
const actor = await Service.fromJsonLd(json, { contextLoader: mockDocumentLoader });
|
|
70
|
+
const before = structuredClone(await actor.toJsonLd());
|
|
71
|
+
for (const options of [void 0, { contextLoader: mockDocumentLoader }]) {
|
|
72
|
+
const response = await respondWithObject(actor, options);
|
|
73
|
+
assert(Array.isArray((await response.json()).attachment));
|
|
74
|
+
for (const accept of ACCEPTS) {
|
|
75
|
+
const acceptable = await respondWithObjectIfAcceptable(actor, new Request("https://example.com/", { headers: { Accept: accept } }), options);
|
|
76
|
+
assert(acceptable != null);
|
|
77
|
+
assert(Array.isArray((await acceptable.json()).attachment));
|
|
78
|
+
assertEquals(acceptable.headers.get("Vary"), "Accept");
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
assertEquals(await actor.toJsonLd(), before);
|
|
82
|
+
assertEquals(await respondWithObjectIfAcceptable(actor, new Request("https://example.com/", { headers: { Accept: "text/html" } })), null);
|
|
83
|
+
});
|
|
84
|
+
test("attachment responses: cached actor with deep JSON data remains servable", async () => {
|
|
85
|
+
let data = "leaf";
|
|
86
|
+
for (let i = 0; i < 70; i++) data = { child: data };
|
|
87
|
+
const original = {
|
|
88
|
+
"@context": ["https://www.w3.org/ns/activitystreams", { data: {
|
|
89
|
+
"@id": "https://example.com/data",
|
|
90
|
+
"@type": "@json"
|
|
91
|
+
} }],
|
|
92
|
+
type: "Service",
|
|
93
|
+
id: "https://example.com/actors/app",
|
|
94
|
+
preferredUsername: "app",
|
|
95
|
+
attachment: {
|
|
96
|
+
type: "Note",
|
|
97
|
+
content: "cached attachment"
|
|
98
|
+
},
|
|
99
|
+
data
|
|
100
|
+
};
|
|
101
|
+
const actor = await Service.fromJsonLd(original, { contextLoader: mockDocumentLoader });
|
|
102
|
+
const before = structuredClone(await actor.toJsonLd());
|
|
103
|
+
const federation = createFederation({ kv: new MemoryKvStore() });
|
|
104
|
+
federation.setActorDispatcher("/actors/{identifier}", () => actor);
|
|
105
|
+
for (const accept of ACCEPTS) {
|
|
106
|
+
const response = await federation.fetch(new Request("https://example.com/actors/app", { headers: { Accept: accept } }), { contextData: void 0 });
|
|
107
|
+
assertEquals(response.status, 200);
|
|
108
|
+
assertEquals(await response.json(), before);
|
|
109
|
+
}
|
|
110
|
+
assertEquals(await actor.toJsonLd(), before);
|
|
111
|
+
});
|
|
112
|
+
test("attachment responses: uncached collections serve unsigned cached children with deep or large JSON data", async () => {
|
|
113
|
+
let deep = "leaf";
|
|
114
|
+
for (let i = 0; i < 70; i++) deep = { child: deep };
|
|
115
|
+
for (const data of [deep, Array.from({ length: 100001 }, () => "leaf")]) {
|
|
116
|
+
const original = {
|
|
117
|
+
"@context": ["https://www.w3.org/ns/activitystreams", { data: {
|
|
118
|
+
"@id": "https://example.com/data",
|
|
119
|
+
"@type": "@json"
|
|
120
|
+
} }],
|
|
121
|
+
type: "Note",
|
|
122
|
+
id: "https://example.com/notes/cached",
|
|
123
|
+
content: "unsigned cached child",
|
|
124
|
+
data
|
|
125
|
+
};
|
|
126
|
+
const note = await Note.fromJsonLd(original, { contextLoader: mockDocumentLoader });
|
|
127
|
+
const before = structuredClone(await note.toJsonLd());
|
|
128
|
+
const collection = new OrderedCollection({ items: [note] });
|
|
129
|
+
const options = { contextLoader: mockDocumentLoader };
|
|
130
|
+
const serialized = structuredClone(await collection.toJsonLd(options));
|
|
131
|
+
for (const response of [await respondWithObject(collection, options), ...await Promise.all(ACCEPTS.map((accept) => respondWithObjectIfAcceptable(collection, new Request("https://example.com/", { headers: { Accept: accept } }), options)))]) {
|
|
132
|
+
assert(response != null);
|
|
133
|
+
assertEquals(response.status, 200);
|
|
134
|
+
assertEquals(await response.json(), serialized);
|
|
135
|
+
}
|
|
136
|
+
assertEquals(await note.toJsonLd(), before);
|
|
137
|
+
}
|
|
138
|
+
});
|
|
139
|
+
test("attachment responses: large cached collection remains servable", async () => {
|
|
140
|
+
const original = {
|
|
141
|
+
"@context": "https://www.w3.org/ns/activitystreams",
|
|
142
|
+
type: "OrderedCollection",
|
|
143
|
+
id: "https://example.com/collection",
|
|
144
|
+
orderedItems: Array.from({ length: 100001 }, (_, i) => `https://example.com/items/${i}`)
|
|
145
|
+
};
|
|
146
|
+
const collection = await OrderedCollection.fromJsonLd(original, { contextLoader: mockDocumentLoader });
|
|
147
|
+
const before = structuredClone(await collection.toJsonLd());
|
|
148
|
+
const response = await respondWithObject(collection, { contextLoader: mockDocumentLoader });
|
|
149
|
+
assertEquals(response.status, 200);
|
|
150
|
+
assertEquals(await response.json(), before);
|
|
151
|
+
assertEquals(await collection.toJsonLd(), before);
|
|
152
|
+
});
|
|
153
|
+
test("attachment responses: cached signed roots pass through without invalidating their JCS proof", async () => {
|
|
154
|
+
const signed = await signObject(new Note({
|
|
155
|
+
id: new URL("https://example.com/notes/signed"),
|
|
156
|
+
attachments: [new Note({ content: "signed attachment" })]
|
|
157
|
+
}), ed25519PrivateKey, ed25519Multikey.id, { contextLoader: mockDocumentLoader });
|
|
158
|
+
const json = await signed.toJsonLd({
|
|
159
|
+
format: "compact",
|
|
160
|
+
contextLoader: mockDocumentLoader
|
|
161
|
+
});
|
|
162
|
+
const cached = await Note.fromJsonLd(json, { contextLoader: mockDocumentLoader });
|
|
163
|
+
const proofs = [];
|
|
164
|
+
for await (const proof of signed.getProofs()) proofs.push(proof);
|
|
165
|
+
assertEquals(proofs.length, 1);
|
|
166
|
+
const verification = {
|
|
167
|
+
contextLoader: mockDocumentLoader,
|
|
168
|
+
documentLoader: mockDocumentLoader
|
|
169
|
+
};
|
|
170
|
+
assert(await verifyProof(json, proofs[0], verification) != null);
|
|
171
|
+
const options = { contextLoader: mockDocumentLoader };
|
|
172
|
+
for (const response of [await respondWithObject(cached, options), ...await Promise.all(ACCEPTS.map((accept) => respondWithObjectIfAcceptable(cached, new Request("https://example.com/", { headers: { Accept: accept } }), options)))]) {
|
|
173
|
+
assert(response != null);
|
|
174
|
+
assertEquals(response.status, 200);
|
|
175
|
+
const body = await response.json();
|
|
176
|
+
assertEquals(body, json);
|
|
177
|
+
assert(await verifyProof(body, proofs[0], verification) != null);
|
|
178
|
+
}
|
|
179
|
+
assertEquals(await cached.toJsonLd(), json);
|
|
180
|
+
});
|
|
181
|
+
//#endregion
|
|
182
|
+
export {};
|
|
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
5
5
|
import { i as assertExists, n as assertStrictEquals } from "../std__assert-DflMZha5.mjs";
|
|
6
6
|
import { t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
8
|
-
import { n as createFederationBuilder } from "../builder-
|
|
8
|
+
import { n as createFederationBuilder } from "../builder--sc-rozj.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
import { Activity, Note, Person } from "@fedify/vocab";
|
|
11
11
|
//#region src/federation/builder.test.ts
|
|
@@ -3,7 +3,7 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import "../std__assert-DflMZha5.mjs";
|
|
6
|
-
import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-
|
|
6
|
+
import { n as digest, t as buildCollectionSynchronizationHeader } from "../collection-DnoYNwBC.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
import { decodeHex } from "byte-encodings/hex";
|
|
9
9
|
//#region src/federation/collection.test.ts
|
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { t as esm_default } from "../esm-DVILvP5e.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
|
+
import "../std__assert-DflMZha5.mjs";
|
|
7
|
+
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
8
|
+
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-CtZLJq76.mjs";
|
|
9
|
+
import { t as MemoryKvStore } from "../kv-HvthQAHr.mjs";
|
|
10
|
+
import { _ as verifySignature, c as detachSignature } from "../ld-DN6x1iZ8.mjs";
|
|
11
|
+
import { n as signObject } from "../proof-DYjmyrHh.mjs";
|
|
12
|
+
import { n as FederationImpl, t as ContextImpl, v as prepareActivityJsonLd } from "../middleware-DiquMgtt.mjs";
|
|
13
|
+
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
14
|
+
import { Create, Image, Note, Person, PropertyValue, Update } from "@fedify/vocab";
|
|
15
|
+
import { decodeMultibase } from "@fedify/vocab-runtime";
|
|
16
|
+
import serialize from "json-canon";
|
|
17
|
+
//#region src/federation/delivery-attachments.test.ts
|
|
18
|
+
async function assertRawProof(document, proof, publicKey) {
|
|
19
|
+
const unsigned = { ...document };
|
|
20
|
+
delete unsigned.proof;
|
|
21
|
+
delete unsigned.signature;
|
|
22
|
+
const encoder = new TextEncoder();
|
|
23
|
+
const config = {
|
|
24
|
+
"@context": document["@context"],
|
|
25
|
+
type: "DataIntegrityProof",
|
|
26
|
+
cryptosuite: proof.cryptosuite,
|
|
27
|
+
verificationMethod: proof.verificationMethod,
|
|
28
|
+
proofPurpose: proof.proofPurpose,
|
|
29
|
+
created: proof.created
|
|
30
|
+
};
|
|
31
|
+
const configDigest = await crypto.subtle.digest("SHA-256", encoder.encode(serialize(config)));
|
|
32
|
+
const messageDigest = await crypto.subtle.digest("SHA-256", encoder.encode(serialize(unsigned)));
|
|
33
|
+
const bytes = new Uint8Array(configDigest.byteLength + messageDigest.byteLength);
|
|
34
|
+
bytes.set(new Uint8Array(configDigest));
|
|
35
|
+
bytes.set(new Uint8Array(messageDigest), configDigest.byteLength);
|
|
36
|
+
assert(await crypto.subtle.verify("Ed25519", publicKey, decodeMultibase(proof.proofValue).slice(), bytes), "The proof must cover the exact received JSON representation.");
|
|
37
|
+
}
|
|
38
|
+
test("attachment delivery keeps fetched profiles, proofs, and queued bytes consistent", async (t) => {
|
|
39
|
+
const secondEdKey = await crypto.subtle.generateKey("Ed25519", true, ["sign", "verify"]);
|
|
40
|
+
const inbox = "https://example.com/attachment-inbox";
|
|
41
|
+
const received = [];
|
|
42
|
+
let responseStatus = 202;
|
|
43
|
+
esm_default.spyGlobal();
|
|
44
|
+
esm_default.post(inbox, async ({ request }) => {
|
|
45
|
+
received.push(await request.json());
|
|
46
|
+
return new Response(null, { status: responseStatus });
|
|
47
|
+
});
|
|
48
|
+
try {
|
|
49
|
+
for (const scenario of [
|
|
50
|
+
"rsa",
|
|
51
|
+
"immediate",
|
|
52
|
+
"outbox",
|
|
53
|
+
"fanout",
|
|
54
|
+
"raw-fanout",
|
|
55
|
+
"raw-immediate",
|
|
56
|
+
"raw-outbox",
|
|
57
|
+
"rsa-fanout",
|
|
58
|
+
"retry"
|
|
59
|
+
]) await t.step(scenario, async () => {
|
|
60
|
+
const messages = [];
|
|
61
|
+
const federation = new FederationImpl({
|
|
62
|
+
kv: new MemoryKvStore(),
|
|
63
|
+
queue: {
|
|
64
|
+
enqueue(message) {
|
|
65
|
+
messages.push(message);
|
|
66
|
+
return Promise.resolve();
|
|
67
|
+
},
|
|
68
|
+
async listen() {}
|
|
69
|
+
},
|
|
70
|
+
manuallyStartQueue: true,
|
|
71
|
+
allowPrivateAddress: true
|
|
72
|
+
});
|
|
73
|
+
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => new Person({
|
|
74
|
+
id: ctx.getActorUri(identifier),
|
|
75
|
+
preferredUsername: identifier,
|
|
76
|
+
attachments: [new PropertyValue({
|
|
77
|
+
name: "Website",
|
|
78
|
+
value: "https://example.com/"
|
|
79
|
+
})]
|
|
80
|
+
})).setKeyPairsDispatcher(() => [{
|
|
81
|
+
privateKey: rsaPrivateKey2,
|
|
82
|
+
publicKey: rsaPublicKey2.publicKey
|
|
83
|
+
}, ...scenario.startsWith("rsa") ? [] : [{
|
|
84
|
+
privateKey: ed25519PrivateKey,
|
|
85
|
+
publicKey: ed25519PublicKey.publicKey
|
|
86
|
+
}, {
|
|
87
|
+
privateKey: secondEdKey.privateKey,
|
|
88
|
+
publicKey: secondEdKey.publicKey
|
|
89
|
+
}]]);
|
|
90
|
+
const ctx = new ContextImpl({
|
|
91
|
+
data: void 0,
|
|
92
|
+
federation,
|
|
93
|
+
url: new URL("https://example.com/"),
|
|
94
|
+
documentLoader: mockDocumentLoader,
|
|
95
|
+
contextLoader: mockDocumentLoader
|
|
96
|
+
});
|
|
97
|
+
const actor = new Person({
|
|
98
|
+
id: ctx.getActorUri("alice"),
|
|
99
|
+
preferredUsername: "alice",
|
|
100
|
+
attachments: [new PropertyValue({
|
|
101
|
+
name: "Website",
|
|
102
|
+
value: "https://example.com/"
|
|
103
|
+
})]
|
|
104
|
+
});
|
|
105
|
+
const fetched = await (await federation.fetch(new Request(ctx.getActorUri("alice"), { headers: { Accept: "application/activity+json" } }), { contextData: void 0 })).json();
|
|
106
|
+
assert(Array.isArray(fetched.attachment));
|
|
107
|
+
const keyPairs = await ctx.getActorKeyPairs("alice");
|
|
108
|
+
const start = received.length;
|
|
109
|
+
await ctx.sendActivity(scenario.startsWith("raw-") ? keyPairs.map((kp) => ({
|
|
110
|
+
privateKey: kp.privateKey,
|
|
111
|
+
keyId: kp.keyId
|
|
112
|
+
})) : { identifier: "alice" }, {
|
|
113
|
+
id: new URL("https://example.com/recipient"),
|
|
114
|
+
inboxId: new URL(inbox)
|
|
115
|
+
}, new Update({
|
|
116
|
+
id: new URL(`https://example.com/updates/${scenario}`),
|
|
117
|
+
actor: actor.id,
|
|
118
|
+
object: actor
|
|
119
|
+
}), scenario === "immediate" || scenario === "raw-immediate" || scenario === "rsa" ? { immediate: true } : scenario === "fanout" || scenario === "raw-fanout" || scenario === "rsa-fanout" ? { fanout: "force" } : {});
|
|
120
|
+
if (scenario === "retry") {
|
|
121
|
+
const first = messages.shift();
|
|
122
|
+
assert(first?.type === "outbox");
|
|
123
|
+
const original = structuredClone(first.activity);
|
|
124
|
+
responseStatus = 503;
|
|
125
|
+
await federation.processQueuedTask(void 0, first);
|
|
126
|
+
responseStatus = 202;
|
|
127
|
+
const retried = messages[0];
|
|
128
|
+
assert(retried?.type === "outbox");
|
|
129
|
+
assertEquals(retried.attempt, 1);
|
|
130
|
+
assertEquals(retried.activity, original);
|
|
131
|
+
}
|
|
132
|
+
for (let count = 0; messages.length > 0; count++) {
|
|
133
|
+
assert(count < 10, "The delivery queue must drain.");
|
|
134
|
+
await federation.processQueuedTask(void 0, messages.shift());
|
|
135
|
+
}
|
|
136
|
+
assert(received.length > start);
|
|
137
|
+
const delivered = received.at(-1);
|
|
138
|
+
assertEquals(delivered.object.attachment, fetched.attachment);
|
|
139
|
+
assert(await verifySignature(delivered, {
|
|
140
|
+
contextLoader: mockDocumentLoader,
|
|
141
|
+
keyCache: {
|
|
142
|
+
get(id) {
|
|
143
|
+
return Promise.resolve(keyPairs.find((kp) => kp.cryptographicKey.id?.href === id.href)?.cryptographicKey ?? null);
|
|
144
|
+
},
|
|
145
|
+
async set() {}
|
|
146
|
+
}
|
|
147
|
+
}));
|
|
148
|
+
const wire = detachSignature(delivered);
|
|
149
|
+
const proofs = wire.proof == null ? [] : Array.isArray(wire.proof) ? wire.proof : [wire.proof];
|
|
150
|
+
assertEquals(proofs.length, scenario.startsWith("rsa") ? 0 : 2);
|
|
151
|
+
for (const proof of proofs) {
|
|
152
|
+
const key = keyPairs.find((kp) => kp.multikey.id?.href === proof.verificationMethod || kp.keyId.href === proof.verificationMethod);
|
|
153
|
+
assert(key != null);
|
|
154
|
+
await assertRawProof(wire, proof, key.publicKey);
|
|
155
|
+
}
|
|
156
|
+
if (scenario === "retry") assertEquals(received.at(-2), received.at(-1));
|
|
157
|
+
});
|
|
158
|
+
} finally {
|
|
159
|
+
esm_default.unmockGlobal();
|
|
160
|
+
esm_default.removeRoutes();
|
|
161
|
+
esm_default.clearHistory();
|
|
162
|
+
}
|
|
163
|
+
});
|
|
164
|
+
test("public attachment proof serialization remains unchanged", async () => {
|
|
165
|
+
const signed = await signObject(new Create({
|
|
166
|
+
actor: new URL("https://example.com/actor"),
|
|
167
|
+
object: new Note({ attachments: [new Image({ url: new URL("https://example.com/image.png") })] })
|
|
168
|
+
}), ed25519PrivateKey, ed25519PublicKey.id, { contextLoader: mockDocumentLoader });
|
|
169
|
+
const raw = await signed.toJsonLd({
|
|
170
|
+
format: "compact",
|
|
171
|
+
contextLoader: mockDocumentLoader
|
|
172
|
+
});
|
|
173
|
+
assert(!Array.isArray(raw.object.attachment));
|
|
174
|
+
await assertRawProof(raw, raw.proof, ed25519PublicKey.publicKey);
|
|
175
|
+
const resignedJson = await (await signObject(signed, ed25519PrivateKey, ed25519PublicKey.id, { contextLoader: mockDocumentLoader })).toJsonLd({
|
|
176
|
+
format: "compact",
|
|
177
|
+
contextLoader: mockDocumentLoader
|
|
178
|
+
});
|
|
179
|
+
assert(!Array.isArray(resignedJson.object.attachment));
|
|
180
|
+
assert(Array.isArray(resignedJson.proof));
|
|
181
|
+
assertEquals(resignedJson.proof.length, 2);
|
|
182
|
+
for (const proof of resignedJson.proof) await assertRawProof(resignedJson, proof, ed25519PublicKey.publicKey);
|
|
183
|
+
});
|
|
184
|
+
test("delivery preparation only selects changed proof-free attachment JSON", async () => {
|
|
185
|
+
assertEquals(await prepareActivityJsonLd(new Create({
|
|
186
|
+
actor: new URL("https://example.com/actor"),
|
|
187
|
+
object: new Note({ content: "No attachments" })
|
|
188
|
+
}), mockDocumentLoader), void 0);
|
|
189
|
+
const child = new Note({ attachments: [new Image({ url: new URL("https://example.com/image.png") })] });
|
|
190
|
+
const activity = new Create({
|
|
191
|
+
actor: new URL("https://example.com/actor"),
|
|
192
|
+
object: child
|
|
193
|
+
});
|
|
194
|
+
const before = structuredClone(await activity.toJsonLd());
|
|
195
|
+
const childBefore = structuredClone(await child.toJsonLd());
|
|
196
|
+
const prepared = await prepareActivityJsonLd(activity, mockDocumentLoader);
|
|
197
|
+
assert(prepared != null);
|
|
198
|
+
assert(Array.isArray(prepared.object.attachment));
|
|
199
|
+
assertEquals(await activity.toJsonLd(), before);
|
|
200
|
+
assertEquals(await child.toJsonLd(), childBefore);
|
|
201
|
+
const signedChild = await signObject(child, ed25519PrivateKey, ed25519PublicKey.id, { contextLoader: mockDocumentLoader });
|
|
202
|
+
assertEquals(await prepareActivityJsonLd(new Create({
|
|
203
|
+
actor: activity.actorId,
|
|
204
|
+
object: signedChild
|
|
205
|
+
}), mockDocumentLoader), void 0);
|
|
206
|
+
});
|
|
207
|
+
test("existing root proofs retain baseline delivery signing and scalar attachments", async (t) => {
|
|
208
|
+
const inbox = "https://example.com/existing-proof-inbox";
|
|
209
|
+
let delivered;
|
|
210
|
+
esm_default.spyGlobal();
|
|
211
|
+
esm_default.post(inbox, async ({ request }) => {
|
|
212
|
+
delivered = await request.json();
|
|
213
|
+
return new Response(null, { status: 202 });
|
|
214
|
+
});
|
|
215
|
+
try {
|
|
216
|
+
for (const sender of ["actor", "raw"]) await t.step(sender, async () => {
|
|
217
|
+
const federation = new FederationImpl({
|
|
218
|
+
kv: new MemoryKvStore(),
|
|
219
|
+
allowPrivateAddress: true
|
|
220
|
+
});
|
|
221
|
+
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => new Person({ id: ctx.getActorUri(identifier) })).setKeyPairsDispatcher(() => [{
|
|
222
|
+
privateKey: rsaPrivateKey2,
|
|
223
|
+
publicKey: rsaPublicKey2.publicKey
|
|
224
|
+
}, {
|
|
225
|
+
privateKey: ed25519PrivateKey,
|
|
226
|
+
publicKey: ed25519PublicKey.publicKey
|
|
227
|
+
}]);
|
|
228
|
+
const ctx = new ContextImpl({
|
|
229
|
+
data: void 0,
|
|
230
|
+
federation,
|
|
231
|
+
url: new URL("https://example.com/"),
|
|
232
|
+
documentLoader: mockDocumentLoader,
|
|
233
|
+
contextLoader: mockDocumentLoader
|
|
234
|
+
});
|
|
235
|
+
const activity = await signObject(new Update({
|
|
236
|
+
id: new URL(`https://example.com/existing-proof/${sender}`),
|
|
237
|
+
actor: ctx.getActorUri("alice"),
|
|
238
|
+
object: new Person({
|
|
239
|
+
id: ctx.getActorUri("alice"),
|
|
240
|
+
attachments: [new PropertyValue({
|
|
241
|
+
name: "Site",
|
|
242
|
+
value: "example"
|
|
243
|
+
})]
|
|
244
|
+
})
|
|
245
|
+
}), ed25519PrivateKey, ed25519PublicKey.id, { contextLoader: mockDocumentLoader });
|
|
246
|
+
const before = structuredClone(await activity.toJsonLd());
|
|
247
|
+
assertEquals(await prepareActivityJsonLd(activity, mockDocumentLoader), void 0);
|
|
248
|
+
await ctx.sendActivity(sender === "actor" ? { identifier: "alice" } : [{
|
|
249
|
+
privateKey: rsaPrivateKey2,
|
|
250
|
+
keyId: rsaPublicKey2.id
|
|
251
|
+
}, {
|
|
252
|
+
privateKey: ed25519PrivateKey,
|
|
253
|
+
keyId: ed25519PublicKey.id
|
|
254
|
+
}], {
|
|
255
|
+
id: new URL("https://example.com/recipient"),
|
|
256
|
+
inboxId: new URL(inbox)
|
|
257
|
+
}, activity, { immediate: true });
|
|
258
|
+
assert(delivered != null);
|
|
259
|
+
assert(!Array.isArray(delivered.object.attachment));
|
|
260
|
+
assert(await verifySignature(delivered, {
|
|
261
|
+
contextLoader: mockDocumentLoader,
|
|
262
|
+
keyCache: {
|
|
263
|
+
get: () => Promise.resolve(rsaPublicKey2),
|
|
264
|
+
async set() {}
|
|
265
|
+
}
|
|
266
|
+
}));
|
|
267
|
+
const wire = detachSignature(delivered);
|
|
268
|
+
const proofs = Array.isArray(wire.proof) ? wire.proof : [wire.proof];
|
|
269
|
+
assertEquals(proofs.length, sender === "actor" ? 2 : 1);
|
|
270
|
+
for (const proof of proofs) await assertRawProof(wire, proof, ed25519PublicKey.publicKey);
|
|
271
|
+
assertEquals(await activity.toJsonLd(), before);
|
|
272
|
+
});
|
|
273
|
+
} finally {
|
|
274
|
+
esm_default.unmockGlobal();
|
|
275
|
+
esm_default.removeRoutes();
|
|
276
|
+
esm_default.clearHistory();
|
|
277
|
+
}
|
|
278
|
+
});
|
|
279
|
+
//#endregion
|
|
280
|
+
export {};
|