@fedify/fedify 2.4.6-dev.2837 → 2.4.6
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-5yDbmjEb.mjs +16 -0
- package/dist/{builder-DYeeuJIZ.mjs → builder-CadJYxhX.mjs} +2 -2
- package/dist/callback-DPDs_dxC.d.mts +5280 -0
- package/dist/{client-3InDZbba.d.cts → client-DLHsPY7X.d.cts} +16 -0
- package/dist/{client-3InDZbba.d.ts → client-DLHsPY7X.d.ts} +16 -0
- package/dist/{client-5SIFzW3q.mjs → client-DU3owZBD.mjs} +86 -11
- package/dist/compat/attachment-arrays.test.d.mts +2 -0
- package/dist/compat/attachment-arrays.test.mjs +255 -0
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/outgoing-jsonld.test.mjs +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{compound-proof-CxRUa-wY.mjs → compound-proof-CbWKyg2H.mjs} +2 -2
- package/dist/{context-D0gFIgev.d.cts → context-DUwicVx-.d.cts} +31 -14
- package/dist/{context-CVOOd9pD.d.ts → context-iGMHITvS.d.ts} +31 -14
- package/dist/{deno-CRpGtqm6.mjs → deno-BKSRi6w3.mjs} +1 -1
- package/dist/{docloader-CZtA3Qjh.mjs → docloader-BcDiJfFl.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/compound-fanout.test.mjs +4 -4
- package/dist/federation/delivery-attachments.test.d.mts +2 -0
- package/dist/federation/delivery-attachments.test.mjs +288 -0
- package/dist/federation/handler-compound-proof.test.mjs +3 -3
- package/dist/federation/handler.test.mjs +206 -14
- package/dist/federation/hashlink-media.test.mjs +2 -2
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox-report.test.mjs +5 -5
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/metrics.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +1188 -13
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +1 -1
- package/dist/federation/outgoing-proof.test.mjs +4 -4
- package/dist/federation/portable-actor.test.mjs +3 -3
- package/dist/federation/portable-chain.test.mjs +3 -3
- package/dist/federation/portable-collection.test.mjs +4 -4
- package/dist/federation/portable-delivery.test.mjs +2 -2
- package/dist/federation/portable-gateway-keys.test.mjs +5 -5
- package/dist/federation/portable-inbox.test.mjs +4 -4
- package/dist/federation/portable-parse-uri.test.mjs +1 -1
- package/dist/federation/portable-route-activity.test.mjs +2 -2
- package/dist/federation/portable.test.mjs +3 -3
- package/dist/federation/send.test.mjs +293 -3
- package/dist/federation/tasks/enqueue.test.mjs +1 -1
- package/dist/federation/tasks/tasks.test.mjs +2 -2
- package/dist/federation/temporal.test.mjs +25 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{federation-DkIcc4TV.cjs → federation-CM4nzbhO.cjs} +500 -144
- package/dist/{http-G2ORncQt.mjs → http-B6sfb5xN.mjs} +8 -6
- package/dist/{http-DnJvGLuL.js → http-BwgldAIk.js} +2798 -2629
- package/dist/{http-DWIArxRV.cjs → http-Tj9eQ_rd.cjs} +2634 -2453
- package/dist/{inbox-WfHbmNbc.mjs → inbox-B7NVkb8j.mjs} +2 -2
- package/dist/{key-VEL1QqHF.d.cts → key-CIdQA7Pc.d.cts} +5 -5
- package/dist/{key-CyCcut3h.d.ts → key-CjtBFzaE.d.ts} +5 -5
- package/dist/{kv-cache-CSJwIUzA.js → kv-cache-C-5yfTw-.js} +1 -1
- package/dist/{kv-cache-C9jAD4VW.mjs → kv-cache-CvWuigft.mjs} +1 -1
- package/dist/{kv-cache-C7b-sBZL.cjs → kv-cache-Vbq0yM7W.cjs} +1 -1
- package/dist/{ld-CKWvh95H.mjs → ld-BGnZDnia.mjs} +155 -22
- package/dist/ld-signature-D1tFSFK8.mjs +23 -0
- package/dist/{metrics-Og1y_3kX.mjs → metrics-DHUP4F1-.mjs} +1 -1
- package/dist/{middleware-BLnbBpsz.mjs → middleware-CUb31OGG.mjs} +1 -1
- package/dist/{middleware-ClfuKN0B.js → middleware-DX8wADUa.js} +451 -97
- package/dist/{middleware-CcNRQv7R.mjs → middleware-mRXKHq68.mjs} +355 -86
- package/dist/{mod-B1Qt5cQQ.d.ts → mod-B6s6hA4y.d.ts} +3 -3
- package/dist/{mod-ss0wBUH1.d.cts → mod-CJf5GcVD.d.cts} +3 -3
- package/dist/{mod-makPMVMg.d.cts → mod-CSlxqNto.d.cts} +1 -1
- package/dist/{mod-CpyjFA9s.d.ts → mod-D2DiA8u5.d.cts} +29 -7
- package/dist/{mod-BTxJG7ZH.d.cts → mod-DKRf1FLm.d.ts} +29 -7
- package/dist/{mod-B5COx5Wd.d.ts → mod-Dqu6Dl1k.d.ts} +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 -4
- 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/{outgoing-jsonld-4IJqPYos.mjs → outgoing-jsonld-Dsca6G_Y.mjs} +35 -4
- package/dist/{owner-DxVC0b0R.mjs → owner-DEiBiiqR.mjs} +3 -3
- package/dist/{portable-collection-8BzIIWJb.cjs → portable-collection--h11WDIi.cjs} +1 -1
- package/dist/{portable-collection-pWL8BrQk.mjs → portable-collection-D0-tInp2.mjs} +2 -2
- package/dist/{portable-collection-Bz3Zn527.js → portable-collection-M6d5I5JQ.js} +1 -1
- package/dist/{portable-key-BGmzMBYm.mjs → portable-key-CyVJpWWJ.mjs} +1 -1
- package/dist/{proof-Cgvg3rEH.mjs → proof-C4pwAF2k.mjs} +29 -9
- package/dist/{send-DheMZ6fh.mjs → send-ivzJCtb-.mjs} +100 -22
- package/dist/sig/compound-proof-discovery.test.mjs +1 -1
- package/dist/sig/compound-proof-producer.test.mjs +1 -1
- package/dist/sig/compound-proof-verification.test.mjs +2 -2
- package/dist/sig/compound-proof.test.mjs +3 -3
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key-types.test.d.mts +162 -0
- package/dist/sig/key-types.test.mjs +8 -0
- package/dist/sig/key.test.mjs +1 -1
- package/dist/sig/ld.test.mjs +572 -7
- package/dist/sig/mitra-receive-interop.test.mjs +4 -4
- package/dist/sig/mitra-send-interop.test.mjs +3 -3
- 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/portable-collection.test.mjs +1 -1
- package/dist/sig/portable-interop.test.mjs +3 -3
- package/dist/sig/portable-key.test.mjs +5 -5
- package/dist/sig/proof.test.mjs +100 -6
- package/dist/sig/tootik-request-interop.test.mjs +4 -4
- package/dist/sig/tootik-send-interop.test.mjs +3 -3
- package/dist/sig/verification.test.mjs +3 -3
- package/dist/{temporal-B7odHbLs.mjs → temporal-B6OlxwK_.mjs} +3 -5
- package/dist/testing/kv.test.mjs +1 -1
- package/dist/testing/mod.d.mts +3 -5045
- package/dist/{types-DUjZb4i6.js → types-BbCbtwZp.js} +86 -11
- package/dist/{types-hKCCjii0.cjs → types-C8gac_AD.cjs} +85 -10
- package/dist/utils/docloader.test.mjs +2 -2
- package/dist/utils/kv-cache.test.mjs +1 -1
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/dist/utils/portable-verifier.test.mjs +3 -3
- package/package.json +6 -6
|
@@ -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 { _ as InboxVerificationKey, d as InboxProofPolicyFailureReason, h as InboxVerificationAttempt, w as VerifyRequestFailureReason, y as HttpMessageSignaturesSpec } from "./key-
|
|
2
|
+
import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-DLHsPY7X.cjs";
|
|
3
|
+
import { _ as InboxVerificationKey, d as InboxProofPolicyFailureReason, h as InboxVerificationAttempt, w as VerifyRequestFailureReason, y as HttpMessageSignaturesSpec } from "./key-CIdQA7Pc.cjs";
|
|
4
4
|
import { n as GetKeyOwnerOptions } from "./owner-BF0L9cMt.cjs";
|
|
5
5
|
import { n as KvStore, t as KvKey } from "./kv-B2mzK5tl.cjs";
|
|
6
6
|
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
|
|
7
|
-
import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions, PortableObjectVerifier } from "@fedify/vocab-runtime";
|
|
7
|
+
import { AuthenticatedDocumentLoaderFactory, CryptoKeyLike, CryptoKeyPairLike, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions, PortableObjectVerifier } from "@fedify/vocab-runtime";
|
|
8
8
|
import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
|
|
9
9
|
import { MeterProvider, Span, Tracer, TracerProvider } from "@opentelemetry/api";
|
|
10
10
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -146,13 +146,18 @@ declare function buildCollectionSynchronizationHeader(collectionId: string | URL
|
|
|
146
146
|
//#region src/federation/send.d.ts
|
|
147
147
|
/**
|
|
148
148
|
* A key pair for an actor who sends an activity.
|
|
149
|
+
*
|
|
150
|
+
* The private key type is parameterized so that Fedify can accept keys from
|
|
151
|
+
* `node:crypto` at its input boundaries while `SenderKeyPair` still exposes the
|
|
152
|
+
* ambient `CryptoKey` type by default.
|
|
153
|
+
* @template TKey The type of the private key.
|
|
149
154
|
* @since 0.10.0
|
|
150
155
|
*/
|
|
151
|
-
interface SenderKeyPair {
|
|
156
|
+
interface SenderKeyPair<TKey extends CryptoKeyLike = CryptoKey> {
|
|
152
157
|
/**
|
|
153
158
|
* The actor's private key to sign the request.
|
|
154
159
|
*/
|
|
155
|
-
readonly privateKey:
|
|
160
|
+
readonly privateKey: TKey;
|
|
156
161
|
/**
|
|
157
162
|
* The public key ID that corresponds to the private key.
|
|
158
163
|
*/
|
|
@@ -222,13 +227,19 @@ type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, ide
|
|
|
222
227
|
/**
|
|
223
228
|
* A callback that dispatches key pairs for an actor.
|
|
224
229
|
*
|
|
230
|
+
* The returned key pairs may come from any supported runtime, including keys
|
|
231
|
+
* obtained from `node:crypto`'s Web Crypto API, so the key pair type is
|
|
232
|
+
* parameterized. It defaults to the ambient `CryptoKeyPair` type for
|
|
233
|
+
* compatibility with code that calls a dispatcher directly.
|
|
234
|
+
*
|
|
225
235
|
* @template TContextData The context data to pass to the {@link Context}.
|
|
236
|
+
* @template TKeyPair The type of the key pairs the dispatcher returns.
|
|
226
237
|
* @param context The context.
|
|
227
238
|
* @param identifier The actor's internal identifier or username.
|
|
228
239
|
* @returns The key pairs.
|
|
229
240
|
* @since 0.10.0
|
|
230
241
|
*/
|
|
231
|
-
type ActorKeyPairsDispatcher<TContextData> = (context: Context<TContextData>, identifier: string) =>
|
|
242
|
+
type ActorKeyPairsDispatcher<TContextData, TKeyPair extends CryptoKeyPairLike = CryptoKeyPair> = (context: Context<TContextData>, identifier: string) => TKeyPair[] | Promise<TKeyPair[]>;
|
|
232
243
|
/**
|
|
233
244
|
* A callback that maps a WebFinger username to the corresponding actor's
|
|
234
245
|
* internal identifier, or `null` if the username is not found.
|
|
@@ -483,11 +494,11 @@ type OutboxListenerErrorHandler<TContextData> = (context: OutboxContext<TContext
|
|
|
483
494
|
* not authorized.
|
|
484
495
|
* @since 0.11.0
|
|
485
496
|
*/
|
|
486
|
-
type SharedInboxKeyDispatcher<TContextData> = (context: Context<TContextData>) => SenderKeyPair | {
|
|
497
|
+
type SharedInboxKeyDispatcher<TContextData, TKeyPair extends CryptoKeyLike = CryptoKey> = (context: Context<TContextData>) => SenderKeyPair<TKeyPair> | {
|
|
487
498
|
identifier: string;
|
|
488
499
|
} | {
|
|
489
500
|
username: string;
|
|
490
|
-
} | null | Promise<SenderKeyPair | {
|
|
501
|
+
} | null | Promise<SenderKeyPair<TKeyPair> | {
|
|
491
502
|
identifier: string;
|
|
492
503
|
} | {
|
|
493
504
|
username: string;
|
|
@@ -2374,6 +2385,12 @@ interface FederationOptions<TContextData> {
|
|
|
2374
2385
|
*
|
|
2375
2386
|
* By default, the queue starts automatically.
|
|
2376
2387
|
*
|
|
2388
|
+
* Automatic startup is best-effort: if a queue cannot start listening,
|
|
2389
|
+
* a warning is logged once per federation instance and the failed worker is
|
|
2390
|
+
* not retried, while an explicit {@link Federation.startQueue} call rejects.
|
|
2391
|
+
* Runtimes that consume the queue elsewhere, such as Cloudflare Workers with
|
|
2392
|
+
* {@link Federation.processQueuedTask}, should set this to `true`.
|
|
2393
|
+
*
|
|
2377
2394
|
* @since 0.12.0
|
|
2378
2395
|
*/
|
|
2379
2396
|
manuallyStartQueue?: boolean;
|
|
@@ -2674,7 +2691,7 @@ interface ActorCallbackSetters<TContextData> {
|
|
|
2674
2691
|
* @returns The setters object so that settings can be chained.
|
|
2675
2692
|
* @since 0.10.0
|
|
2676
2693
|
*/
|
|
2677
|
-
setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
|
|
2694
|
+
setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData, CryptoKeyPairLike>): ActorCallbackSetters<TContextData>;
|
|
2678
2695
|
/**
|
|
2679
2696
|
* Sets the callback function that maps a WebFinger username to
|
|
2680
2697
|
* the corresponding actor's identifier. If it's omitted, the identifier
|
|
@@ -2934,7 +2951,7 @@ interface InboxListenerSetters<TContextData> {
|
|
|
2934
2951
|
* @returns The setters object so that settings can be chained.
|
|
2935
2952
|
* @since 0.11.0
|
|
2936
2953
|
*/
|
|
2937
|
-
setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
|
|
2954
|
+
setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData, CryptoKeyLike>): InboxListenerSetters<TContextData>;
|
|
2938
2955
|
/**
|
|
2939
2956
|
* Configures the strategy for handling activity idempotency in inbox processing.
|
|
2940
2957
|
*
|
|
@@ -3611,7 +3628,7 @@ interface Context<TContextData> {
|
|
|
3611
3628
|
*/
|
|
3612
3629
|
getDocumentLoader(identity: {
|
|
3613
3630
|
keyId: URL;
|
|
3614
|
-
privateKey:
|
|
3631
|
+
privateKey: CryptoKeyLike;
|
|
3615
3632
|
}): DocumentLoader;
|
|
3616
3633
|
/**
|
|
3617
3634
|
* Looks up an ActivityStreams object by its URI (including `acct:` URIs)
|
|
@@ -3735,7 +3752,7 @@ interface Context<TContextData> {
|
|
|
3735
3752
|
* @param activity The activity to send.
|
|
3736
3753
|
* @param options Options for sending the activity.
|
|
3737
3754
|
*/
|
|
3738
|
-
sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
|
|
3755
|
+
sendActivity(sender: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
|
|
3739
3756
|
identifier: string;
|
|
3740
3757
|
} | {
|
|
3741
3758
|
username: string;
|
|
@@ -4454,7 +4471,7 @@ interface InboxContext<TContextData> extends Context<TContextData> {
|
|
|
4454
4471
|
* @param options Options for forwarding the activity.
|
|
4455
4472
|
* @since 1.0.0
|
|
4456
4473
|
*/
|
|
4457
|
-
forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
|
|
4474
|
+
forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
|
|
4458
4475
|
identifier: string;
|
|
4459
4476
|
} | {
|
|
4460
4477
|
username: string;
|
|
@@ -4512,7 +4529,7 @@ interface OutboxContext<TContextData> extends Context<TContextData> {
|
|
|
4512
4529
|
* @param options Options for forwarding the activity.
|
|
4513
4530
|
* @since 2.2.0
|
|
4514
4531
|
*/
|
|
4515
|
-
forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
|
|
4532
|
+
forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
|
|
4516
4533
|
identifier: string;
|
|
4517
4534
|
} | {
|
|
4518
4535
|
username: string;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-
|
|
3
|
-
import { _ as InboxVerificationKey, d as InboxProofPolicyFailureReason, h as InboxVerificationAttempt, w as VerifyRequestFailureReason, y as HttpMessageSignaturesSpec } from "./key-
|
|
2
|
+
import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-DLHsPY7X.js";
|
|
3
|
+
import { _ as InboxVerificationKey, d as InboxProofPolicyFailureReason, h as InboxVerificationAttempt, w as VerifyRequestFailureReason, y as HttpMessageSignaturesSpec } from "./key-CjtBFzaE.js";
|
|
4
4
|
import { n as GetKeyOwnerOptions } from "./owner-BSzr5-I8.js";
|
|
5
5
|
import { n as KvStore, t as KvKey } from "./kv-B2mzK5tl.js";
|
|
6
6
|
import { Router } from "@fedify/uri-template";
|
|
7
7
|
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
|
|
8
8
|
import { MeterProvider, Span, Tracer, TracerProvider } from "@opentelemetry/api";
|
|
9
|
-
import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions, PortableObjectVerifier } from "@fedify/vocab-runtime";
|
|
9
|
+
import { AuthenticatedDocumentLoaderFactory, CryptoKeyLike, CryptoKeyPairLike, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions, PortableObjectVerifier } from "@fedify/vocab-runtime";
|
|
10
10
|
import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
|
|
11
11
|
import { MeterProvider as MeterProvider$1, MetricReader } from "@opentelemetry/sdk-metrics";
|
|
12
12
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
|
@@ -148,13 +148,18 @@ declare function buildCollectionSynchronizationHeader(collectionId: string | URL
|
|
|
148
148
|
//#region src/federation/send.d.ts
|
|
149
149
|
/**
|
|
150
150
|
* A key pair for an actor who sends an activity.
|
|
151
|
+
*
|
|
152
|
+
* The private key type is parameterized so that Fedify can accept keys from
|
|
153
|
+
* `node:crypto` at its input boundaries while `SenderKeyPair` still exposes the
|
|
154
|
+
* ambient `CryptoKey` type by default.
|
|
155
|
+
* @template TKey The type of the private key.
|
|
151
156
|
* @since 0.10.0
|
|
152
157
|
*/
|
|
153
|
-
interface SenderKeyPair {
|
|
158
|
+
interface SenderKeyPair<TKey extends CryptoKeyLike = CryptoKey> {
|
|
154
159
|
/**
|
|
155
160
|
* The actor's private key to sign the request.
|
|
156
161
|
*/
|
|
157
|
-
readonly privateKey:
|
|
162
|
+
readonly privateKey: TKey;
|
|
158
163
|
/**
|
|
159
164
|
* The public key ID that corresponds to the private key.
|
|
160
165
|
*/
|
|
@@ -224,13 +229,19 @@ type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, ide
|
|
|
224
229
|
/**
|
|
225
230
|
* A callback that dispatches key pairs for an actor.
|
|
226
231
|
*
|
|
232
|
+
* The returned key pairs may come from any supported runtime, including keys
|
|
233
|
+
* obtained from `node:crypto`'s Web Crypto API, so the key pair type is
|
|
234
|
+
* parameterized. It defaults to the ambient `CryptoKeyPair` type for
|
|
235
|
+
* compatibility with code that calls a dispatcher directly.
|
|
236
|
+
*
|
|
227
237
|
* @template TContextData The context data to pass to the {@link Context}.
|
|
238
|
+
* @template TKeyPair The type of the key pairs the dispatcher returns.
|
|
228
239
|
* @param context The context.
|
|
229
240
|
* @param identifier The actor's internal identifier or username.
|
|
230
241
|
* @returns The key pairs.
|
|
231
242
|
* @since 0.10.0
|
|
232
243
|
*/
|
|
233
|
-
type ActorKeyPairsDispatcher<TContextData> = (context: Context<TContextData>, identifier: string) =>
|
|
244
|
+
type ActorKeyPairsDispatcher<TContextData, TKeyPair extends CryptoKeyPairLike = CryptoKeyPair> = (context: Context<TContextData>, identifier: string) => TKeyPair[] | Promise<TKeyPair[]>;
|
|
234
245
|
/**
|
|
235
246
|
* A callback that maps a WebFinger username to the corresponding actor's
|
|
236
247
|
* internal identifier, or `null` if the username is not found.
|
|
@@ -485,11 +496,11 @@ type OutboxListenerErrorHandler<TContextData> = (context: OutboxContext<TContext
|
|
|
485
496
|
* not authorized.
|
|
486
497
|
* @since 0.11.0
|
|
487
498
|
*/
|
|
488
|
-
type SharedInboxKeyDispatcher<TContextData> = (context: Context<TContextData>) => SenderKeyPair | {
|
|
499
|
+
type SharedInboxKeyDispatcher<TContextData, TKeyPair extends CryptoKeyLike = CryptoKey> = (context: Context<TContextData>) => SenderKeyPair<TKeyPair> | {
|
|
489
500
|
identifier: string;
|
|
490
501
|
} | {
|
|
491
502
|
username: string;
|
|
492
|
-
} | null | Promise<SenderKeyPair | {
|
|
503
|
+
} | null | Promise<SenderKeyPair<TKeyPair> | {
|
|
493
504
|
identifier: string;
|
|
494
505
|
} | {
|
|
495
506
|
username: string;
|
|
@@ -2376,6 +2387,12 @@ interface FederationOptions<TContextData> {
|
|
|
2376
2387
|
*
|
|
2377
2388
|
* By default, the queue starts automatically.
|
|
2378
2389
|
*
|
|
2390
|
+
* Automatic startup is best-effort: if a queue cannot start listening,
|
|
2391
|
+
* a warning is logged once per federation instance and the failed worker is
|
|
2392
|
+
* not retried, while an explicit {@link Federation.startQueue} call rejects.
|
|
2393
|
+
* Runtimes that consume the queue elsewhere, such as Cloudflare Workers with
|
|
2394
|
+
* {@link Federation.processQueuedTask}, should set this to `true`.
|
|
2395
|
+
*
|
|
2379
2396
|
* @since 0.12.0
|
|
2380
2397
|
*/
|
|
2381
2398
|
manuallyStartQueue?: boolean;
|
|
@@ -2676,7 +2693,7 @@ interface ActorCallbackSetters<TContextData> {
|
|
|
2676
2693
|
* @returns The setters object so that settings can be chained.
|
|
2677
2694
|
* @since 0.10.0
|
|
2678
2695
|
*/
|
|
2679
|
-
setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData>): ActorCallbackSetters<TContextData>;
|
|
2696
|
+
setKeyPairsDispatcher(dispatcher: ActorKeyPairsDispatcher<TContextData, CryptoKeyPairLike>): ActorCallbackSetters<TContextData>;
|
|
2680
2697
|
/**
|
|
2681
2698
|
* Sets the callback function that maps a WebFinger username to
|
|
2682
2699
|
* the corresponding actor's identifier. If it's omitted, the identifier
|
|
@@ -2936,7 +2953,7 @@ interface InboxListenerSetters<TContextData> {
|
|
|
2936
2953
|
* @returns The setters object so that settings can be chained.
|
|
2937
2954
|
* @since 0.11.0
|
|
2938
2955
|
*/
|
|
2939
|
-
setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData>): InboxListenerSetters<TContextData>;
|
|
2956
|
+
setSharedKeyDispatcher(dispatcher: SharedInboxKeyDispatcher<TContextData, CryptoKeyLike>): InboxListenerSetters<TContextData>;
|
|
2940
2957
|
/**
|
|
2941
2958
|
* Configures the strategy for handling activity idempotency in inbox processing.
|
|
2942
2959
|
*
|
|
@@ -3613,7 +3630,7 @@ interface Context<TContextData> {
|
|
|
3613
3630
|
*/
|
|
3614
3631
|
getDocumentLoader(identity: {
|
|
3615
3632
|
keyId: URL;
|
|
3616
|
-
privateKey:
|
|
3633
|
+
privateKey: CryptoKeyLike;
|
|
3617
3634
|
}): DocumentLoader;
|
|
3618
3635
|
/**
|
|
3619
3636
|
* Looks up an ActivityStreams object by its URI (including `acct:` URIs)
|
|
@@ -3737,7 +3754,7 @@ interface Context<TContextData> {
|
|
|
3737
3754
|
* @param activity The activity to send.
|
|
3738
3755
|
* @param options Options for sending the activity.
|
|
3739
3756
|
*/
|
|
3740
|
-
sendActivity(sender: SenderKeyPair | SenderKeyPair[] | {
|
|
3757
|
+
sendActivity(sender: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
|
|
3741
3758
|
identifier: string;
|
|
3742
3759
|
} | {
|
|
3743
3760
|
username: string;
|
|
@@ -4456,7 +4473,7 @@ interface InboxContext<TContextData> extends Context<TContextData> {
|
|
|
4456
4473
|
* @param options Options for forwarding the activity.
|
|
4457
4474
|
* @since 1.0.0
|
|
4458
4475
|
*/
|
|
4459
|
-
forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
|
|
4476
|
+
forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
|
|
4460
4477
|
identifier: string;
|
|
4461
4478
|
} | {
|
|
4462
4479
|
username: string;
|
|
@@ -4514,7 +4531,7 @@ interface OutboxContext<TContextData> extends Context<TContextData> {
|
|
|
4514
4531
|
* @param options Options for forwarding the activity.
|
|
4515
4532
|
* @since 2.2.0
|
|
4516
4533
|
*/
|
|
4517
|
-
forwardActivity(forwarder: SenderKeyPair | SenderKeyPair[] | {
|
|
4534
|
+
forwardActivity(forwarder: SenderKeyPair<CryptoKeyLike> | SenderKeyPair<CryptoKeyLike>[] | {
|
|
4518
4535
|
identifier: string;
|
|
4519
4536
|
} | {
|
|
4520
4537
|
username: string;
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import {
|
|
5
|
-
import { r as doubleKnockScoped } from "./http-
|
|
4
|
+
import { D as validateCryptoKey } from "./ld-BGnZDnia.mjs";
|
|
5
|
+
import { r as doubleKnockScoped } from "./http-B6sfb5xN.mjs";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
import { FetchError, UrlError, createActivityPubRequest, getRemoteDocument, logRequest, resolveDocumentLoaderTimeout, withDocumentLoaderTimeout } from "@fedify/vocab-runtime";
|
|
8
8
|
import { curry } from "es-toolkit";
|
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import "temporal-polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
|
|
5
|
+
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
6
|
+
import "../std__assert-DvMDRPes.mjs";
|
|
7
|
+
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
8
|
+
import { a as signObject, d as verifyProof } from "../proof-C4pwAF2k.mjs";
|
|
9
|
+
import { n as ed25519PrivateKey, t as ed25519Multikey } from "../keys-DIJNHW-Y.mjs";
|
|
10
|
+
import { _ as respondWithObjectIfAcceptable, g as respondWithObject, o as createFederation } from "../middleware-mRXKHq68.mjs";
|
|
11
|
+
import { Note, Object as Object$1, OrderedCollection, PropertyValue, Service, Update } from "@fedify/vocab";
|
|
12
|
+
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
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 {};
|
|
@@ -7,7 +7,7 @@ import { t as assertExists } from "../assert_exists-cffSpJ7X.mjs";
|
|
|
7
7
|
import { t as assertThrows } from "../assert_throws-BYITOvPO.mjs";
|
|
8
8
|
import "../std__assert-DvMDRPes.mjs";
|
|
9
9
|
import { t as assertStrictEquals } from "../assert_strict_equals-CYvBmkpC.mjs";
|
|
10
|
-
import { r as createFederationBuilder } from "../builder-
|
|
10
|
+
import { r as createFederationBuilder } from "../builder-CadJYxhX.mjs";
|
|
11
11
|
import { DisallowedOperatorError, DisallowedVarSpecModifierError, DuplicateRouteVariableError, RouteTemplateOptionsNotMatchedError, RouterError } from "@fedify/uri-template";
|
|
12
12
|
import { Activity, Note, Person } from "@fedify/vocab";
|
|
13
13
|
import { test } from "@fedify/fixture";
|
|
@@ -6,11 +6,11 @@ import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
|
|
|
6
6
|
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
7
7
|
import "../std__assert-DvMDRPes.mjs";
|
|
8
8
|
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
9
|
-
import {
|
|
10
|
-
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-
|
|
11
|
-
import { a as signObject, d as verifyProof } from "../proof-
|
|
9
|
+
import { x as exportJwk } from "../ld-BGnZDnia.mjs";
|
|
10
|
+
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-Dsca6G_Y.mjs";
|
|
11
|
+
import { a as signObject, d as verifyProof } from "../proof-C4pwAF2k.mjs";
|
|
12
12
|
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
|
|
13
|
-
import { n as FederationImpl } from "../middleware-
|
|
13
|
+
import { n as FederationImpl } from "../middleware-mRXKHq68.mjs";
|
|
14
14
|
import { Create, DataIntegrityProof, Note } from "@fedify/vocab";
|
|
15
15
|
import { exportDidKey, parseIri } from "@fedify/vocab-runtime";
|
|
16
16
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|