@fedify/fedify 2.4.0-dev.2047 → 2.4.0-dev.2056
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/{builder-Cue1kVHU.mjs → builder-D_XU_Fw2.mjs} +8 -2
- 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/{compound-proof-YT4tajyj.mjs → compound-proof-CwTySDnn.mjs} +1 -1
- package/dist/{context-BJPHhBmD.d.ts → context-D_gg4M0n.d.ts} +102 -1
- package/dist/{context-Bh_mJfbD.d.cts → context-b36TpPoG.d.cts} +102 -1
- package/dist/{deno-Dcj6O4LJ.mjs → deno-BtpLWN2L.mjs} +1 -1
- package/dist/{docloader-BRlNjHlQ.mjs → docloader-CJADEtqb.mjs} +2 -2
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/compound-fanout.test.mjs +3 -3
- package/dist/federation/handler-compound-proof.test.mjs +3 -3
- package/dist/federation/handler.test.mjs +5 -5
- package/dist/federation/hashlink-media.test.d.mts +2 -0
- package/dist/federation/hashlink-media.test.mjs +422 -0
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/metrics.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +7 -7
- 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 +5 -5
- package/dist/federation/portable.test.mjs +3 -3
- package/dist/federation/router.test.mjs +2 -152
- package/dist/federation/send.test.mjs +3 -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 +1 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{federation-Bdu06LEl.cjs → federation-DDwszIrk.cjs} +139 -21
- package/dist/{http-CK6kjLnO.mjs → http-CotELN-4.mjs} +3 -3
- package/dist/{http-CGjvl34X.cjs → http-DW5mt8FG.cjs} +1 -1
- package/dist/{http-BmdqHyms.js → http-iLCx9vk-.js} +1 -1
- package/dist/{key-CzCAq6D9.mjs → key-DrCNkH3Y.mjs} +2 -2
- package/dist/{kv-cache-CvEicbrf.cjs → kv-cache-LOyq_Ty6.cjs} +1 -1
- package/dist/{kv-cache-YATuzCy-.mjs → kv-cache-a1ghEA4h.mjs} +1 -1
- package/dist/{kv-cache-fi_-XZco.js → kv-cache-bXLDSaRu.js} +1 -1
- package/dist/{ld-CNWm8mJc.mjs → ld-BPG92sC0.mjs} +3 -3
- package/dist/{metrics-CDoBPWjf.mjs → metrics-DxVi0UJD.mjs} +1 -1
- package/dist/{middleware-Drzx-OID.js → middleware-1nes8_U-.js} +140 -22
- package/dist/{middleware-CF6uz8wa.mjs → middleware-BIPftTly.mjs} +1 -1
- package/dist/{middleware-CtFNjIUD.mjs → middleware-DohUu-Tz.mjs} +145 -33
- package/dist/{mod-DU8aVzQJ.d.cts → mod-Bfenkg_c.d.cts} +1 -1
- package/dist/{mod-BofpDIcU.d.ts → mod-BhMvsgdF.d.ts} +1 -1
- package/dist/mod.cjs +4 -4
- package/dist/mod.d.cts +4 -4
- package/dist/mod.d.ts +4 -4
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/{owner-B3PgGiJ1.mjs → owner-BN7Mqjso.mjs} +2 -2
- package/dist/{owner-Hurn_ocn.cjs → owner-C2ER4VD7.cjs} +1 -1
- package/dist/{owner-CMnmv7S9.js → owner-SBgt2USF.js} +1 -1
- package/dist/{proof-fKycdssC.mjs → proof-BigVZwkl.mjs} +4 -4
- package/dist/router-u5O5KCQr.mjs +156 -0
- package/dist/{send-BqBILxYE.mjs → send-CvatEhyY.mjs} +3 -3
- 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 +2 -2
- package/dist/sig/http.test.mjs +2 -2
- package/dist/sig/key.test.mjs +1 -1
- package/dist/sig/ld.test.mjs +2 -2
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/proof.test.mjs +3 -3
- package/dist/{temporal-SUiLJ0Co.mjs → temporal-DV5jeBbR.mjs} +1 -1
- package/dist/testing/kv.test.mjs +1 -1
- package/dist/testing/mod.d.mts +101 -0
- 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.js +1 -1
- package/package.json +6 -6
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-BtpLWN2L.mjs";
|
|
5
5
|
import { t as ActivityListenerSet } from "./activity-listener-C-BSbKI7.mjs";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
import { Router, RouterError, assertPath } from "@fedify/uri-template";
|
|
@@ -58,6 +58,7 @@ var FederationBuilderImpl = class {
|
|
|
58
58
|
mediaUploaderPath;
|
|
59
59
|
mediaUploaderCallback;
|
|
60
60
|
mediaUploaderAuthorizePredicate;
|
|
61
|
+
hashlinkMediaDispatcher;
|
|
61
62
|
sharedInboxKeyDispatcher;
|
|
62
63
|
unverifiedActivityHandler;
|
|
63
64
|
outboxPermanentFailureHandler;
|
|
@@ -85,7 +86,7 @@ var FederationBuilderImpl = class {
|
|
|
85
86
|
* specified.
|
|
86
87
|
*/
|
|
87
88
|
async build(options) {
|
|
88
|
-
const { FederationImpl } = await import("./middleware-
|
|
89
|
+
const { FederationImpl } = await import("./middleware-BIPftTly.mjs");
|
|
89
90
|
const f = new FederationImpl(options);
|
|
90
91
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
91
92
|
f.router = this.router.clone();
|
|
@@ -115,6 +116,7 @@ var FederationBuilderImpl = class {
|
|
|
115
116
|
f.mediaUploaderPath = this.mediaUploaderPath;
|
|
116
117
|
f.mediaUploaderCallback = this.mediaUploaderCallback;
|
|
117
118
|
f.mediaUploaderAuthorizePredicate = this.mediaUploaderAuthorizePredicate;
|
|
119
|
+
f.hashlinkMediaDispatcher = this.hashlinkMediaDispatcher;
|
|
118
120
|
f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
|
|
119
121
|
f.unverifiedActivityHandler = this.unverifiedActivityHandler;
|
|
120
122
|
f.outboxPermanentFailureHandler = this.outboxPermanentFailureHandler;
|
|
@@ -422,6 +424,10 @@ var FederationBuilderImpl = class {
|
|
|
422
424
|
} };
|
|
423
425
|
return setters;
|
|
424
426
|
}
|
|
427
|
+
setHashlinkMediaDispatcher(dispatcher) {
|
|
428
|
+
if (this.hashlinkMediaDispatcher != null) throw new RouterError("Hashlink media dispatcher already set.");
|
|
429
|
+
this.hashlinkMediaDispatcher = dispatcher;
|
|
430
|
+
}
|
|
425
431
|
setFollowingDispatcher(path, dispatcher) {
|
|
426
432
|
if (this.router.has("following")) throw new RouterError("Following collection dispatcher already set.");
|
|
427
433
|
assertPath(path);
|
package/dist/compat/mod.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import {
|
|
2
|
+
import { Jt as ActivityTransformer, n as Context } from "../context-b36TpPoG.cjs";
|
|
3
3
|
import { Activity } from "@fedify/vocab";
|
|
4
4
|
|
|
5
5
|
//#region src/compat/transformers.d.ts
|
package/dist/compat/mod.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference lib="esnext.temporal" />
|
|
2
|
-
import {
|
|
2
|
+
import { Jt as ActivityTransformer, n as Context } from "../context-D_gg4M0n.js";
|
|
3
3
|
import { Activity } from "@fedify/vocab";
|
|
4
4
|
|
|
5
5
|
//#region src/compat/transformers.d.ts
|
|
@@ -5,7 +5,7 @@ import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
|
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
6
6
|
import { t as assertInstanceOf } from "../assert_instance_of-mrXWWNY-.mjs";
|
|
7
7
|
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
8
|
-
import {
|
|
8
|
+
import { S as autoIdAssigner, n as FederationImpl, x as actorDehydrator } from "../middleware-DohUu-Tz.mjs";
|
|
9
9
|
import { Follow, Person } from "@fedify/vocab";
|
|
10
10
|
import { test } from "@fedify/fixture";
|
|
11
11
|
//#region src/compat/transformers.test.ts
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { i as verifyMapLocalProof, s as verifyPortableObjectProofPolicy } from "./proof-
|
|
4
|
+
import { i as verifyMapLocalProof, s as verifyPortableObjectProofPolicy } from "./proof-BigVZwkl.mjs";
|
|
5
5
|
//#region src/sig/compound-proof.ts
|
|
6
6
|
const textEncoder = new TextEncoder();
|
|
7
7
|
const PORTABLE_OBJECT_ID_PATTERN = /^ap(?:\+ef61)?:\/\//i;
|
|
@@ -259,6 +259,60 @@ type OutboxListener<TContextData, TActivity extends Activity> = (context: Outbox
|
|
|
259
259
|
*/
|
|
260
260
|
type MediaUploaderCallback<TContextData> = (context: RequestContext<TContextData>, identifier: string, file: File, object: Object$1) => Object$1 | URL | Promise<Object$1 | URL>;
|
|
261
261
|
/**
|
|
262
|
+
* A request for a resource addressed by a hashlink, which an
|
|
263
|
+
* [FEP-ef61](https://w3id.org/fep/ef61) gateway serves at
|
|
264
|
+
* `/.well-known/apgateway/hl:<digestMultibase>`.
|
|
265
|
+
*
|
|
266
|
+
* Fedify validates the hashlink before creating this object, so the digest is
|
|
267
|
+
* always a well-formed SHA-256 multihash.
|
|
268
|
+
*
|
|
269
|
+
* @since 2.4.0
|
|
270
|
+
*/
|
|
271
|
+
interface HashlinkMediaRequest {
|
|
272
|
+
/**
|
|
273
|
+
* The requested hashlink, i.e., `hl:` followed by
|
|
274
|
+
* {@link HashlinkMediaRequest.digestMultibase}, after percent-decoding and
|
|
275
|
+
* with its scheme lowercased.
|
|
276
|
+
*/
|
|
277
|
+
readonly hashlink: `hl:${string}`;
|
|
278
|
+
/**
|
|
279
|
+
* The multibase-encoded multihash as requested, which is the value that
|
|
280
|
+
* publishers put in the `digestMultibase` property. The same digest can be
|
|
281
|
+
* encoded in several multibase encodings; use
|
|
282
|
+
* {@link HashlinkMediaRequest.digest} as a storage key to find a resource
|
|
283
|
+
* regardless of the encoding.
|
|
284
|
+
*/
|
|
285
|
+
readonly digestMultibase: string;
|
|
286
|
+
/** The hash algorithm of the digest. */
|
|
287
|
+
readonly algorithm: "sha2-256";
|
|
288
|
+
/** The raw 32-byte SHA-256 digest of the resource. */
|
|
289
|
+
readonly digest: Uint8Array;
|
|
290
|
+
/**
|
|
291
|
+
* The multihash decoded from
|
|
292
|
+
* {@link HashlinkMediaRequest.digestMultibase}, i.e., the hash algorithm
|
|
293
|
+
* code and the digest length followed by the digest.
|
|
294
|
+
*/
|
|
295
|
+
readonly multihash: Uint8Array;
|
|
296
|
+
}
|
|
297
|
+
/**
|
|
298
|
+
* A callback that serves a resource addressed by a hashlink through the
|
|
299
|
+
* [FEP-ef61](https://w3id.org/fep/ef61) gateway endpoint.
|
|
300
|
+
*
|
|
301
|
+
* The returned response is sent as is, so the callback can stream its body
|
|
302
|
+
* and set headers such as `Content-Type` and `Cache-Control`. Fedify does not
|
|
303
|
+
* verify the response body against the digest, so the complete
|
|
304
|
+
* representation must be the exact bytes that hash to the requested digest.
|
|
305
|
+
*
|
|
306
|
+
* @template TContextData The context data to pass to the {@link Context}.
|
|
307
|
+
* @param context The request context.
|
|
308
|
+
* @param media The requested hashlink and its digest.
|
|
309
|
+
* @returns The response to send, or `null` if the resource is not stored on
|
|
310
|
+
* this server, which results in `404 Not Found`. It may be returned
|
|
311
|
+
* synchronously or wrapped in a `Promise`.
|
|
312
|
+
* @since 2.4.0
|
|
313
|
+
*/
|
|
314
|
+
type HashlinkMediaDispatcher<TContextData> = (context: RequestContext<TContextData>, media: HashlinkMediaRequest) => Response | null | Promise<Response | null>;
|
|
315
|
+
/**
|
|
262
316
|
* The reason why an incoming activity could not be verified.
|
|
263
317
|
*
|
|
264
318
|
* Unlike inbox listeners registered through {@link InboxListenerSetters.on},
|
|
@@ -1635,6 +1689,53 @@ interface Federatable<TContextData> extends TaskRegistry<TContextData> {
|
|
|
1635
1689
|
*/
|
|
1636
1690
|
setMediaUploader(path: `${string}${Rfc6570Expression<"identifier">}${string}`, callback: MediaUploaderCallback<TContextData>): MediaUploaderSetters<TContextData>;
|
|
1637
1691
|
/**
|
|
1692
|
+
* Registers a dispatcher that serves resources addressed by hashlinks, such
|
|
1693
|
+
* as media attached to portable objects, through the
|
|
1694
|
+
* [FEP-ef61](https://w3id.org/fep/ef61) gateway endpoint, e.g.,
|
|
1695
|
+
* `GET /.well-known/apgateway/hl:zQmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n`.
|
|
1696
|
+
*
|
|
1697
|
+
* Fedify responds with `400 Bad Request` without calling the dispatcher if
|
|
1698
|
+
* the hashlink is malformed or its digest is not a SHA-256 multihash, and
|
|
1699
|
+
* with `404 Not Found` if the dispatcher returns `null`. Otherwise, the
|
|
1700
|
+
* response returned by the dispatcher is sent as is. Requests with methods
|
|
1701
|
+
* other than `GET` and `HEAD` get `405 Method Not Allowed`.
|
|
1702
|
+
*
|
|
1703
|
+
* Fedify does not verify the served bytes against the digest, as that would
|
|
1704
|
+
* require buffering the whole response body. The dispatcher must serve only
|
|
1705
|
+
* the resource whose complete representation hashes to the requested
|
|
1706
|
+
* digest, e.g., by using the digest as the storage key.
|
|
1707
|
+
*
|
|
1708
|
+
* This is not the upload API of the ActivityPub Media Upload extension,
|
|
1709
|
+
* which is registered through {@link Federatable.setMediaUploader}.
|
|
1710
|
+
*
|
|
1711
|
+
* @example
|
|
1712
|
+
* ``` typescript
|
|
1713
|
+
* federation.setHashlinkMediaDispatcher(async (ctx, media) => {
|
|
1714
|
+
* const file = await findPublicMedia(media.digest);
|
|
1715
|
+
* if (file == null) return null;
|
|
1716
|
+
* return new Response(
|
|
1717
|
+
* ctx.request.method === "HEAD" ? null : file.stream(),
|
|
1718
|
+
* {
|
|
1719
|
+
* headers: {
|
|
1720
|
+
* "Content-Type": file.mediaType,
|
|
1721
|
+
* "Content-Length": file.size.toString(),
|
|
1722
|
+
* "Cache-Control": "public, max-age=31536000, immutable",
|
|
1723
|
+
* "X-Content-Type-Options": "nosniff",
|
|
1724
|
+
* },
|
|
1725
|
+
* },
|
|
1726
|
+
* );
|
|
1727
|
+
* });
|
|
1728
|
+
* ```
|
|
1729
|
+
*
|
|
1730
|
+
* @param dispatcher A callback that returns the response serving the
|
|
1731
|
+
* requested resource, or `null` if it is not stored on
|
|
1732
|
+
* this server.
|
|
1733
|
+
* @throws {RouterError} Thrown if a hashlink media dispatcher is already
|
|
1734
|
+
* registered.
|
|
1735
|
+
* @since 2.4.0
|
|
1736
|
+
*/
|
|
1737
|
+
setHashlinkMediaDispatcher(dispatcher: HashlinkMediaDispatcher<TContextData>): void;
|
|
1738
|
+
/**
|
|
1638
1739
|
* Registers a following collection dispatcher.
|
|
1639
1740
|
* @param path The URI path pattern for the following collection. The syntax
|
|
1640
1741
|
* is based on URI Template
|
|
@@ -3651,4 +3752,4 @@ interface ActorKeyPair extends CryptoKeyPair {
|
|
|
3651
3752
|
readonly multikey: Multikey;
|
|
3652
3753
|
}
|
|
3653
3754
|
//#endregion
|
|
3654
|
-
export { MessageQueue as $, ObjectCallbackSetters as A,
|
|
3755
|
+
export { MessageQueue as $, ObjectCallbackSetters as A, InboxListener as At, TaskDefinitionOptions as B, UnverifiedActivityHandler as Bt, FederationOptions as C, CollectionDispatcher as Ct, InboxChallengePolicy as D, HashlinkMediaDispatcher as Dt, IdempotencyStrategy as E, CustomCollectionDispatcher as Et, FederationQueueOptions as F, OutboxErrorHandler as Ft, RetryContext as G, PageItems as Gt, TaskHandler as H, WebFingerLinksDispatcher as Ht, createFederation as I, OutboxListener as It, RespondWithObjectOptions as J, ActivityTransformer as Jt, RetryPolicy as K, buildCollectionSynchronizationHeader as Kt, Message as L, OutboxListenerErrorHandler as Lt, Rfc6570Expression as M, NodeInfoDispatcher as Mt, FederationKvPrefixes as N, ObjectAuthorizePredicate as Nt, InboxListenerSetters as O, HashlinkMediaRequest as Ot, FederationOrigin as P, ObjectDispatcher as Pt, InProcessMessageQueueOptions as Q, createFederationBuilder as R, OutboxPermanentFailureHandler as Rt, FederationFetchOptions as S, CollectionCursor as St, IdempotencyKeyCallback as T, CustomCollectionCursor as Tt, TaskRegistry as U, SendActivityError as Ut, TaskEnqueueOptions as V, UnverifiedActivityReason as Vt, CreateExponentialBackoffPolicyOptions as W, SenderKeyPair as Wt, respondWithObjectIfAcceptable as X, respondWithObject as Y, InProcessMessageQueue as Z, CustomCollectionCallbackSetters as _, ActorDispatcher as _t, GetSignedKeyOptions as a, CircuitBreakerActivityDrop as at, FederationBenchmarkOptions as b, AuthorizePredicate as bt, ParseUriResult as c, CircuitBreakerFailurePolicy as ct, RouteActivityOptions as d, CircuitBreakerState as dt, MessageQueueDepth as et, SendActivityOptions as f, CircuitBreakerStateChange as ft, ConstructorWithTypeId as g, ActorAliasMapper as gt, CollectionCallbackSetters as h, parseCircuitBreakerKvState as ht, GetActorOptions as i, CircuitBreaker as it, OutboxListenerSetters as j, MediaUploaderCallback as jt, MediaUploaderSetters as k, InboxErrorHandler as kt, PortableRequest as l, CircuitBreakerKvState as lt, ActorCallbackSetters as m, normalizeCircuitBreakerOptions as mt, Context as n, MessageQueueListenOptions as nt, InboxContext as o, CircuitBreakerBeforeSendDecision as ot, SendActivityOptionsForCollection as p, NormalizedCircuitBreakerOptions as pt, createExponentialBackoffPolicy as q, digest as qt, ForwardActivityOptions as r, ParallelMessageQueue as rt, OutboxContext as s, CircuitBreakerCreateOptions as st, ActorKeyPair as t, MessageQueueEnqueueOptions as tt, RequestContext as u, CircuitBreakerOptions as ut, Federatable as v, ActorHandleMapper as vt, FederationStartQueueOptions as w, CustomCollectionCounter as wt, FederationBuilder as x, CollectionCounter as xt, Federation as y, ActorKeyPairsDispatcher as yt, TaskDefinition as z, SharedInboxKeyDispatcher as zt };
|
|
@@ -257,6 +257,60 @@ type OutboxListener<TContextData, TActivity extends Activity> = (context: Outbox
|
|
|
257
257
|
*/
|
|
258
258
|
type MediaUploaderCallback<TContextData> = (context: RequestContext<TContextData>, identifier: string, file: File, object: Object$1) => Object$1 | URL | Promise<Object$1 | URL>;
|
|
259
259
|
/**
|
|
260
|
+
* A request for a resource addressed by a hashlink, which an
|
|
261
|
+
* [FEP-ef61](https://w3id.org/fep/ef61) gateway serves at
|
|
262
|
+
* `/.well-known/apgateway/hl:<digestMultibase>`.
|
|
263
|
+
*
|
|
264
|
+
* Fedify validates the hashlink before creating this object, so the digest is
|
|
265
|
+
* always a well-formed SHA-256 multihash.
|
|
266
|
+
*
|
|
267
|
+
* @since 2.4.0
|
|
268
|
+
*/
|
|
269
|
+
interface HashlinkMediaRequest {
|
|
270
|
+
/**
|
|
271
|
+
* The requested hashlink, i.e., `hl:` followed by
|
|
272
|
+
* {@link HashlinkMediaRequest.digestMultibase}, after percent-decoding and
|
|
273
|
+
* with its scheme lowercased.
|
|
274
|
+
*/
|
|
275
|
+
readonly hashlink: `hl:${string}`;
|
|
276
|
+
/**
|
|
277
|
+
* The multibase-encoded multihash as requested, which is the value that
|
|
278
|
+
* publishers put in the `digestMultibase` property. The same digest can be
|
|
279
|
+
* encoded in several multibase encodings; use
|
|
280
|
+
* {@link HashlinkMediaRequest.digest} as a storage key to find a resource
|
|
281
|
+
* regardless of the encoding.
|
|
282
|
+
*/
|
|
283
|
+
readonly digestMultibase: string;
|
|
284
|
+
/** The hash algorithm of the digest. */
|
|
285
|
+
readonly algorithm: "sha2-256";
|
|
286
|
+
/** The raw 32-byte SHA-256 digest of the resource. */
|
|
287
|
+
readonly digest: Uint8Array;
|
|
288
|
+
/**
|
|
289
|
+
* The multihash decoded from
|
|
290
|
+
* {@link HashlinkMediaRequest.digestMultibase}, i.e., the hash algorithm
|
|
291
|
+
* code and the digest length followed by the digest.
|
|
292
|
+
*/
|
|
293
|
+
readonly multihash: Uint8Array;
|
|
294
|
+
}
|
|
295
|
+
/**
|
|
296
|
+
* A callback that serves a resource addressed by a hashlink through the
|
|
297
|
+
* [FEP-ef61](https://w3id.org/fep/ef61) gateway endpoint.
|
|
298
|
+
*
|
|
299
|
+
* The returned response is sent as is, so the callback can stream its body
|
|
300
|
+
* and set headers such as `Content-Type` and `Cache-Control`. Fedify does not
|
|
301
|
+
* verify the response body against the digest, so the complete
|
|
302
|
+
* representation must be the exact bytes that hash to the requested digest.
|
|
303
|
+
*
|
|
304
|
+
* @template TContextData The context data to pass to the {@link Context}.
|
|
305
|
+
* @param context The request context.
|
|
306
|
+
* @param media The requested hashlink and its digest.
|
|
307
|
+
* @returns The response to send, or `null` if the resource is not stored on
|
|
308
|
+
* this server, which results in `404 Not Found`. It may be returned
|
|
309
|
+
* synchronously or wrapped in a `Promise`.
|
|
310
|
+
* @since 2.4.0
|
|
311
|
+
*/
|
|
312
|
+
type HashlinkMediaDispatcher<TContextData> = (context: RequestContext<TContextData>, media: HashlinkMediaRequest) => Response | null | Promise<Response | null>;
|
|
313
|
+
/**
|
|
260
314
|
* The reason why an incoming activity could not be verified.
|
|
261
315
|
*
|
|
262
316
|
* Unlike inbox listeners registered through {@link InboxListenerSetters.on},
|
|
@@ -1633,6 +1687,53 @@ interface Federatable<TContextData> extends TaskRegistry<TContextData> {
|
|
|
1633
1687
|
*/
|
|
1634
1688
|
setMediaUploader(path: `${string}${Rfc6570Expression<"identifier">}${string}`, callback: MediaUploaderCallback<TContextData>): MediaUploaderSetters<TContextData>;
|
|
1635
1689
|
/**
|
|
1690
|
+
* Registers a dispatcher that serves resources addressed by hashlinks, such
|
|
1691
|
+
* as media attached to portable objects, through the
|
|
1692
|
+
* [FEP-ef61](https://w3id.org/fep/ef61) gateway endpoint, e.g.,
|
|
1693
|
+
* `GET /.well-known/apgateway/hl:zQmdfTbBqBPQ7VNxZEYEj14VmRuZBkqFbiwReogJgS1zR1n`.
|
|
1694
|
+
*
|
|
1695
|
+
* Fedify responds with `400 Bad Request` without calling the dispatcher if
|
|
1696
|
+
* the hashlink is malformed or its digest is not a SHA-256 multihash, and
|
|
1697
|
+
* with `404 Not Found` if the dispatcher returns `null`. Otherwise, the
|
|
1698
|
+
* response returned by the dispatcher is sent as is. Requests with methods
|
|
1699
|
+
* other than `GET` and `HEAD` get `405 Method Not Allowed`.
|
|
1700
|
+
*
|
|
1701
|
+
* Fedify does not verify the served bytes against the digest, as that would
|
|
1702
|
+
* require buffering the whole response body. The dispatcher must serve only
|
|
1703
|
+
* the resource whose complete representation hashes to the requested
|
|
1704
|
+
* digest, e.g., by using the digest as the storage key.
|
|
1705
|
+
*
|
|
1706
|
+
* This is not the upload API of the ActivityPub Media Upload extension,
|
|
1707
|
+
* which is registered through {@link Federatable.setMediaUploader}.
|
|
1708
|
+
*
|
|
1709
|
+
* @example
|
|
1710
|
+
* ``` typescript
|
|
1711
|
+
* federation.setHashlinkMediaDispatcher(async (ctx, media) => {
|
|
1712
|
+
* const file = await findPublicMedia(media.digest);
|
|
1713
|
+
* if (file == null) return null;
|
|
1714
|
+
* return new Response(
|
|
1715
|
+
* ctx.request.method === "HEAD" ? null : file.stream(),
|
|
1716
|
+
* {
|
|
1717
|
+
* headers: {
|
|
1718
|
+
* "Content-Type": file.mediaType,
|
|
1719
|
+
* "Content-Length": file.size.toString(),
|
|
1720
|
+
* "Cache-Control": "public, max-age=31536000, immutable",
|
|
1721
|
+
* "X-Content-Type-Options": "nosniff",
|
|
1722
|
+
* },
|
|
1723
|
+
* },
|
|
1724
|
+
* );
|
|
1725
|
+
* });
|
|
1726
|
+
* ```
|
|
1727
|
+
*
|
|
1728
|
+
* @param dispatcher A callback that returns the response serving the
|
|
1729
|
+
* requested resource, or `null` if it is not stored on
|
|
1730
|
+
* this server.
|
|
1731
|
+
* @throws {RouterError} Thrown if a hashlink media dispatcher is already
|
|
1732
|
+
* registered.
|
|
1733
|
+
* @since 2.4.0
|
|
1734
|
+
*/
|
|
1735
|
+
setHashlinkMediaDispatcher(dispatcher: HashlinkMediaDispatcher<TContextData>): void;
|
|
1736
|
+
/**
|
|
1636
1737
|
* Registers a following collection dispatcher.
|
|
1637
1738
|
* @param path The URI path pattern for the following collection. The syntax
|
|
1638
1739
|
* is based on URI Template
|
|
@@ -3649,4 +3750,4 @@ interface ActorKeyPair extends CryptoKeyPair {
|
|
|
3649
3750
|
readonly multikey: Multikey;
|
|
3650
3751
|
}
|
|
3651
3752
|
//#endregion
|
|
3652
|
-
export { MessageQueue as $, ObjectCallbackSetters as A,
|
|
3753
|
+
export { MessageQueue as $, ObjectCallbackSetters as A, InboxListener as At, TaskDefinitionOptions as B, UnverifiedActivityHandler as Bt, FederationOptions as C, CollectionDispatcher as Ct, InboxChallengePolicy as D, HashlinkMediaDispatcher as Dt, IdempotencyStrategy as E, CustomCollectionDispatcher as Et, FederationQueueOptions as F, OutboxErrorHandler as Ft, RetryContext as G, PageItems as Gt, TaskHandler as H, WebFingerLinksDispatcher as Ht, createFederation as I, OutboxListener as It, RespondWithObjectOptions as J, ActivityTransformer as Jt, RetryPolicy as K, buildCollectionSynchronizationHeader as Kt, Message as L, OutboxListenerErrorHandler as Lt, Rfc6570Expression as M, NodeInfoDispatcher as Mt, FederationKvPrefixes as N, ObjectAuthorizePredicate as Nt, InboxListenerSetters as O, HashlinkMediaRequest as Ot, FederationOrigin as P, ObjectDispatcher as Pt, InProcessMessageQueueOptions as Q, createFederationBuilder as R, OutboxPermanentFailureHandler as Rt, FederationFetchOptions as S, CollectionCursor as St, IdempotencyKeyCallback as T, CustomCollectionCursor as Tt, TaskRegistry as U, SendActivityError as Ut, TaskEnqueueOptions as V, UnverifiedActivityReason as Vt, CreateExponentialBackoffPolicyOptions as W, SenderKeyPair as Wt, respondWithObjectIfAcceptable as X, respondWithObject as Y, InProcessMessageQueue as Z, CustomCollectionCallbackSetters as _, ActorDispatcher as _t, GetSignedKeyOptions as a, CircuitBreakerActivityDrop as at, FederationBenchmarkOptions as b, AuthorizePredicate as bt, ParseUriResult as c, CircuitBreakerFailurePolicy as ct, RouteActivityOptions as d, CircuitBreakerState as dt, MessageQueueDepth as et, SendActivityOptions as f, CircuitBreakerStateChange as ft, ConstructorWithTypeId as g, ActorAliasMapper as gt, CollectionCallbackSetters as h, parseCircuitBreakerKvState as ht, GetActorOptions as i, CircuitBreaker as it, OutboxListenerSetters as j, MediaUploaderCallback as jt, MediaUploaderSetters as k, InboxErrorHandler as kt, PortableRequest as l, CircuitBreakerKvState as lt, ActorCallbackSetters as m, normalizeCircuitBreakerOptions as mt, Context as n, MessageQueueListenOptions as nt, InboxContext as o, CircuitBreakerBeforeSendDecision as ot, SendActivityOptionsForCollection as p, NormalizedCircuitBreakerOptions as pt, createExponentialBackoffPolicy as q, digest as qt, ForwardActivityOptions as r, ParallelMessageQueue as rt, OutboxContext as s, CircuitBreakerCreateOptions as st, ActorKeyPair as t, MessageQueueEnqueueOptions as tt, RequestContext as u, CircuitBreakerOptions as ut, Federatable as v, ActorHandleMapper as vt, FederationStartQueueOptions as w, CustomCollectionCounter as wt, FederationBuilder as x, CollectionCounter as xt, Federation as y, ActorKeyPairsDispatcher as yt, TaskDefinition as z, SharedInboxKeyDispatcher as zt };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "temporal-polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { s as validateCryptoKey } from "./key-
|
|
5
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { s as validateCryptoKey } from "./key-DrCNkH3Y.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-CotELN-4.mjs";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
import { curry } from "es-toolkit";
|
|
8
8
|
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
@@ -6,7 +6,7 @@ import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
|
|
|
6
6
|
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
|
-
import { r as createFederationBuilder } from "../builder-
|
|
9
|
+
import { r as createFederationBuilder } from "../builder-D_XU_Fw2.mjs";
|
|
10
10
|
import { DisallowedOperatorError, DisallowedVarSpecModifierError, DuplicateRouteVariableError, RouteTemplateOptionsNotMatchedError, RouterError } from "@fedify/uri-template";
|
|
11
11
|
import { Activity, Note, Person } from "@fedify/vocab";
|
|
12
12
|
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 { t as exportJwk } from "../key-
|
|
9
|
+
import { t as exportJwk } from "../key-DrCNkH3Y.mjs";
|
|
10
10
|
import { i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
|
|
11
11
|
import { r as normalizeOutgoingActivityJsonLd } from "../outgoing-jsonld-4IJqPYos.mjs";
|
|
12
|
-
import { n as FederationImpl } from "../middleware-
|
|
13
|
-
import { c as verifyProof, r as signObject } from "../proof-
|
|
12
|
+
import { n as FederationImpl } from "../middleware-DohUu-Tz.mjs";
|
|
13
|
+
import { c as verifyProof, r as signObject } from "../proof-BigVZwkl.mjs";
|
|
14
14
|
import { Create, DataIntegrityProof, Note } from "@fedify/vocab";
|
|
15
15
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
16
16
|
import { exportDidKey, parseIri } from "@fedify/vocab-runtime";
|
|
@@ -5,10 +5,10 @@ import { r as createRequestContext, t as createInboxContext } from "../context-D
|
|
|
5
5
|
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
|
-
import { s as signRequest } from "../http-
|
|
8
|
+
import { s as signRequest } from "../http-CotELN-4.mjs";
|
|
9
9
|
import { a as rsaPrivateKey3, c as rsaPublicKey3 } from "../keys-DIJNHW-Y.mjs";
|
|
10
|
-
import { d as handleInbox, o as createFederation } from "../middleware-
|
|
11
|
-
import { p as signJsonLd } from "../ld-
|
|
10
|
+
import { d as handleInbox, o as createFederation } from "../middleware-DohUu-Tz.mjs";
|
|
11
|
+
import { p as signJsonLd } from "../ld-BPG92sC0.mjs";
|
|
12
12
|
import { t as ActivityListenerSet } from "../activity-listener-C-BSbKI7.mjs";
|
|
13
13
|
import { t as map_local_create_note_default } from "../map-local-create-note-B0SeXJms.mjs";
|
|
14
14
|
import { Create } from "@fedify/vocab";
|
|
@@ -10,12 +10,12 @@ import "../std__assert-DvMDRPes.mjs";
|
|
|
10
10
|
import { t as assertRejects } from "../assert_rejects-CTptdYck.mjs";
|
|
11
11
|
import { t as assert } from "../assert-D1Eafmd_.mjs";
|
|
12
12
|
import { r as parseAcceptSignature } from "../accept-CPVqki78.mjs";
|
|
13
|
-
import { a as generateCryptoKeyPair } from "../key-
|
|
14
|
-
import { s as signRequest } from "../http-
|
|
13
|
+
import { a as generateCryptoKeyPair } from "../key-DrCNkH3Y.mjs";
|
|
14
|
+
import { s as signRequest } from "../http-CotELN-4.mjs";
|
|
15
15
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-DIJNHW-Y.mjs";
|
|
16
|
-
import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-
|
|
17
|
-
import { a as compactJsonLd, p as signJsonLd } from "../ld-
|
|
18
|
-
import { r as signObject } from "../proof-
|
|
16
|
+
import { c as handleActor, d as handleInbox, f as handleObject, h as respondWithObjectIfAcceptable, l as handleCollection, m as respondWithObject, o as createFederation, p as handleOutbox, u as handleCustomCollection } from "../middleware-DohUu-Tz.mjs";
|
|
17
|
+
import { a as compactJsonLd, p as signJsonLd } from "../ld-BPG92sC0.mjs";
|
|
18
|
+
import { r as signObject } from "../proof-BigVZwkl.mjs";
|
|
19
19
|
import { t as ActivityListenerSet } from "../activity-listener-C-BSbKI7.mjs";
|
|
20
20
|
import { Activity, Create, CryptographicKey, Multikey, Note, Person, Tombstone } from "@fedify/vocab";
|
|
21
21
|
import { createTestMeterProvider, createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|