@fedify/fedify 2.2.0-dev.735 → 2.2.0-dev.748
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-2jI6hegp.mjs → builder-BGzN0XIV.mjs} +5 -4
- 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-C0fssarc.d.ts → context-78ecvxf5.d.ts} +60 -5
- package/dist/{context-LmrZPwti.d.cts → context-DYDPdoCb.d.cts} +60 -5
- package/dist/{deno-DNUSPY7U.mjs → deno-BGpYBBba.mjs} +1 -1
- package/dist/{docloader-B8ck-wER.mjs → docloader-B_eTYGFt.mjs} +2 -2
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +77 -5
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +58 -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/send.test.mjs +3 -3
- package/dist/federation/webfinger.test.mjs +37 -4
- package/dist/{http-IIaVPAl2.cjs → http-BA8U-rJX.cjs} +1 -1
- package/dist/{http-B8WmNdHN.js → http-BX8Se31Z.js} +1 -1
- package/dist/{http-Cv2XDsCQ.mjs → http-DukFwiXf.mjs} +2 -2
- package/dist/{inbox-DybrQJ_p.mjs → inbox-wiVtdLY9.mjs} +1 -1
- package/dist/{key-BUolsx1b.mjs → key-CC3yOGF0.mjs} +1 -1
- package/dist/{kv-cache-De67QZby.js → kv-cache-BSseaVt8.js} +1 -1
- package/dist/{kv-cache-BOJJaBI3.cjs → kv-cache-Baf0LigI.cjs} +1 -1
- package/dist/{ld-Cf1yTEdR.mjs → ld-D67kDIA0.mjs} +2 -2
- package/dist/{middleware-DhJ6OSCJ.mjs → middleware-BfOPomng.mjs} +35 -17
- package/dist/{middleware-Dgc7SDvm.cjs → middleware-CP-fzmy_.cjs} +29 -10
- package/dist/{middleware-DzM_lYXe.js → middleware-CXkoAB0x.js} +29 -10
- package/dist/{middleware-C0fVsqQ6.mjs → middleware-DBWbTLAi.mjs} +1 -1
- package/dist/{middleware-D3YnKcat.cjs → middleware-DLm4eyx-.cjs} +1 -1
- package/dist/{mod-Cgpc49fA.d.cts → mod-CEohtXhV.d.cts} +1 -1
- package/dist/{mod-CnwZoDzx.d.ts → mod-CokIUYDr.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-W4ABJwPB.mjs → owner-CxO6322k.mjs} +2 -2
- package/dist/{proof-BrpuZcsU.cjs → proof-9C09_l2r.cjs} +1 -1
- package/dist/{proof-Cy8xM0Tx.js → proof-DaPEktCl.js} +1 -1
- package/dist/{proof-DPq6vDHh.mjs → proof-Dfy2T5tG.mjs} +2 -2
- package/dist/{send-IBbCEOU_.mjs → send-urWboKs6.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 -4
- package/dist/testing/mod.d.mts +59 -4
- package/dist/utils/docloader.test.mjs +2 -2
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +5 -5
|
@@ -2,9 +2,9 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as RouterError, t as Router } from "./router-CrMLXoOr.mjs";
|
|
5
|
-
import { n as version, t as name } from "./deno-
|
|
6
|
-
import { t as InboxListenerSet } from "./inbox-
|
|
7
|
-
import { getTypeId } from "@fedify/vocab";
|
|
5
|
+
import { n as version, t as name } from "./deno-BGpYBBba.mjs";
|
|
6
|
+
import { t as InboxListenerSet } from "./inbox-wiVtdLY9.mjs";
|
|
7
|
+
import { Tombstone, getTypeId } from "@fedify/vocab";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
10
10
|
//#region src/federation/builder.ts
|
|
@@ -43,7 +43,7 @@ var FederationBuilderImpl = class {
|
|
|
43
43
|
this.collectionTypeIds = {};
|
|
44
44
|
}
|
|
45
45
|
async build(options) {
|
|
46
|
-
const { FederationImpl } = await import("./middleware-
|
|
46
|
+
const { FederationImpl } = await import("./middleware-DBWbTLAi.mjs");
|
|
47
47
|
const f = new FederationImpl(options);
|
|
48
48
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
49
49
|
f.router = this.router.clone();
|
|
@@ -106,6 +106,7 @@ var FederationBuilderImpl = class {
|
|
|
106
106
|
]);
|
|
107
107
|
if (actor.id == null) logger.warn("Actor dispatcher returned an actor without an id property. Set the property with Context.getActorUri(identifier).");
|
|
108
108
|
else if (actor.id.href != context.getActorUri(identifier).href) logger.warn("Actor dispatcher returned an actor with an id property that does not match the actor URI. Set the property with Context.getActorUri(identifier).");
|
|
109
|
+
if (actor instanceof Tombstone) return actor;
|
|
109
110
|
if (this.followingCallbacks != null && this.followingCallbacks.dispatcher != null) {
|
|
110
111
|
if (actor.followingId == null) logger.warn("You configured a following collection dispatcher, but the actor does not have a following property. Set the property with Context.getFollowingUri(identifier).");
|
|
111
112
|
else if (actor.followingId.href != context.getFollowingUri(identifier).href) logger.warn("You configured a following collection dispatcher, but the actor's following property does not match the following collection URI. Set the property with Context.getFollowingUri(identifier).");
|
package/dist/compat/mod.d.cts
CHANGED
package/dist/compat/mod.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import {
|
|
3
|
+
import { n as Context, wt as ActivityTransformer } from "../context-78ecvxf5.js";
|
|
4
4
|
import { Activity } from "@fedify/vocab";
|
|
5
5
|
|
|
6
6
|
//#region src/compat/transformers.d.ts
|
|
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
5
5
|
import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
|
|
6
6
|
import { t as assert } from "../assert-ddO5KLpe.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
|
|
8
|
-
import { _ as autoIdAssigner, g as actorDehydrator, n as FederationImpl } from "../middleware-
|
|
8
|
+
import { _ as autoIdAssigner, g as actorDehydrator, n as FederationImpl } from "../middleware-BfOPomng.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
import { Follow, Person } from "@fedify/vocab";
|
|
11
11
|
//#region src/compat/transformers.test.ts
|
|
@@ -4,7 +4,7 @@ import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client
|
|
|
4
4
|
import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-aQzN9Ayi.js";
|
|
5
5
|
import { n as GetKeyOwnerOptions } from "./owner-74ARJ5TL.js";
|
|
6
6
|
import { n as KvStore, t as KvKey } from "./kv-GFYnFoOl.js";
|
|
7
|
-
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, TraverseCollectionOptions } from "@fedify/vocab";
|
|
7
|
+
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
|
|
8
8
|
import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
|
|
9
9
|
import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
|
|
10
10
|
import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
|
|
@@ -107,13 +107,13 @@ type NodeInfoDispatcher<TContextData> = (context: RequestContext<TContextData>)
|
|
|
107
107
|
*/
|
|
108
108
|
type WebFingerLinksDispatcher<TContextData> = (context: RequestContext<TContextData>, resource: URL) => readonly Link$1[] | Promise<readonly Link$1[]>;
|
|
109
109
|
/**
|
|
110
|
-
* A callback that dispatches an {@link Actor} object.
|
|
110
|
+
* A callback that dispatches an {@link Actor} object or a {@link Tombstone}.
|
|
111
111
|
*
|
|
112
112
|
* @template TContextData The context data to pass to the {@link Context}.
|
|
113
113
|
* @param context The request context.
|
|
114
114
|
* @param identifier The actor's internal identifier or username.
|
|
115
115
|
*/
|
|
116
|
-
type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, identifier: string) => Actor | null | Promise<Actor | null>;
|
|
116
|
+
type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, identifier: string) => Actor | Tombstone | null | Promise<Actor | Tombstone | null>;
|
|
117
117
|
/**
|
|
118
118
|
* A callback that dispatches key pairs for an actor.
|
|
119
119
|
*
|
|
@@ -923,7 +923,9 @@ interface Federatable<TContextData> {
|
|
|
923
923
|
* based on URI Template
|
|
924
924
|
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
925
925
|
* must have one variable: `{identifier}`.
|
|
926
|
-
* @param dispatcher An actor dispatcher callback to register.
|
|
926
|
+
* @param dispatcher An actor dispatcher callback to register. It may return
|
|
927
|
+
* an actor, a `Tombstone`, or `null` if the actor is not
|
|
928
|
+
* found.
|
|
927
929
|
* @returns An object with methods to set other actor dispatcher callbacks.
|
|
928
930
|
* @throws {RouterError} Thrown if the path pattern is invalid.
|
|
929
931
|
*/
|
|
@@ -2227,6 +2229,19 @@ interface Context<TContextData> {
|
|
|
2227
2229
|
getCollectionUri<TParam extends Record<string, string>>(name: string | symbol, values: TParam): URL;
|
|
2228
2230
|
}
|
|
2229
2231
|
/**
|
|
2232
|
+
* Options for {@link RequestContext.getActor}.
|
|
2233
|
+
* @since 2.2.0
|
|
2234
|
+
*/
|
|
2235
|
+
interface GetActorOptions {
|
|
2236
|
+
/**
|
|
2237
|
+
* Controls how tombstoned actors are returned.
|
|
2238
|
+
*
|
|
2239
|
+
* By default, tombstones are suppressed and returned as `null`. Set this to
|
|
2240
|
+
* `"passthrough"` to receive a {@link Tombstone} result instead.
|
|
2241
|
+
*/
|
|
2242
|
+
readonly tombstone?: "suppress" | "passthrough";
|
|
2243
|
+
}
|
|
2244
|
+
/**
|
|
2230
2245
|
* A context for a request.
|
|
2231
2246
|
*/
|
|
2232
2247
|
interface RequestContext<TContextData> extends Context<TContextData> {
|
|
@@ -2256,6 +2271,46 @@ interface RequestContext<TContextData> extends Context<TContextData> {
|
|
|
2256
2271
|
*/
|
|
2257
2272
|
getActor(identifier: string): Promise<Actor | null>;
|
|
2258
2273
|
/**
|
|
2274
|
+
* Gets an {@link Actor} object or {@link Tombstone} for the given
|
|
2275
|
+
* identifier.
|
|
2276
|
+
* @param identifier The actor's identifier.
|
|
2277
|
+
* @param options Options for getting the actor. Set
|
|
2278
|
+
* `options.tombstone` to `"passthrough"` to receive
|
|
2279
|
+
* tombstoned actors instead of `null`.
|
|
2280
|
+
* @returns The actor object, a tombstone, or `null` if the actor is not
|
|
2281
|
+
* found.
|
|
2282
|
+
* @throws {Error} If no actor dispatcher is available.
|
|
2283
|
+
* @since 2.2.0
|
|
2284
|
+
*/
|
|
2285
|
+
getActor(identifier: string, options: GetActorOptions & {
|
|
2286
|
+
readonly tombstone: "passthrough";
|
|
2287
|
+
}): Promise<Actor | Tombstone | null>;
|
|
2288
|
+
/**
|
|
2289
|
+
* Gets an {@link Actor} object for the given identifier.
|
|
2290
|
+
* @param identifier The actor's identifier.
|
|
2291
|
+
* @param options Options for getting the actor.
|
|
2292
|
+
* @returns The actor object, or `null` if the actor is not found.
|
|
2293
|
+
* Tombstoned actors are suppressed unless `options.tombstone` is
|
|
2294
|
+
* `"passthrough"`.
|
|
2295
|
+
* @throws {Error} If no actor dispatcher is available.
|
|
2296
|
+
* @since 2.2.0
|
|
2297
|
+
*/
|
|
2298
|
+
getActor(identifier: string, options: GetActorOptions & {
|
|
2299
|
+
readonly tombstone?: "suppress" | undefined;
|
|
2300
|
+
}): Promise<Actor | null>;
|
|
2301
|
+
/**
|
|
2302
|
+
* Gets an {@link Actor} object or {@link Tombstone} for the given
|
|
2303
|
+
* identifier.
|
|
2304
|
+
* @param identifier The actor's identifier.
|
|
2305
|
+
* @param options Options for getting the actor.
|
|
2306
|
+
* @returns The actor object, a tombstone, or `null` if the actor is not
|
|
2307
|
+
* found. This broad overload is used when the caller passes an
|
|
2308
|
+
* options value whose `tombstone` mode is not known statically.
|
|
2309
|
+
* @throws {Error} If no actor dispatcher is available.
|
|
2310
|
+
* @since 2.2.0
|
|
2311
|
+
*/
|
|
2312
|
+
getActor(identifier: string, options: GetActorOptions): Promise<Actor | Tombstone | null>;
|
|
2313
|
+
/**
|
|
2259
2314
|
* Gets an object of the given class with the given values.
|
|
2260
2315
|
* @param cls The class to instantiate.
|
|
2261
2316
|
* @param values The values to pass to the object dispatcher.
|
|
@@ -2589,4 +2644,4 @@ interface ActorKeyPair extends CryptoKeyPair {
|
|
|
2589
2644
|
readonly multikey: Multikey;
|
|
2590
2645
|
}
|
|
2591
2646
|
//#endregion
|
|
2592
|
-
export {
|
|
2647
|
+
export { ActorHandleMapper as $, FederationQueueOptions as A, RouterOptions as B, IdempotencyStrategy as C, digest as Ct, Rfc6570Expression as D, ObjectCallbackSetters as E, createExponentialBackoffPolicy as F, InProcessMessageQueue as G, RespondWithObjectOptions as H, Message as I, MessageQueueEnqueueOptions as J, InProcessMessageQueueOptions as K, createFederationBuilder as L, CreateExponentialBackoffPolicyOptions as M, RetryContext as N, FederationKvPrefixes as O, RetryPolicy as P, ActorDispatcher as Q, Router as R, IdempotencyKeyCallback as S, buildCollectionSynchronizationHeader as St, InboxListenerSetters as T, respondWithObject as U, RouterRouteResult as V, respondWithObjectIfAcceptable as W, ParallelMessageQueue as X, MessageQueueListenOptions as Y, ActorAliasMapper as Z, Federation as _, UnverifiedActivityReason as _t, GetSignedKeyOptions as a, CustomCollectionCounter as at, FederationOptions as b, SenderKeyPair as bt, RequestContext as c, InboxErrorHandler as ct, SendActivityOptionsForCollection as d, ObjectAuthorizePredicate as dt, ActorKeyPairsDispatcher as et, ActorCallbackSetters as f, ObjectDispatcher as ft, Federatable as g, UnverifiedActivityHandler as gt, CustomCollectionCallbackSetters as h, SharedInboxKeyDispatcher as ht, GetActorOptions as i, CollectionDispatcher as it, createFederation as j, FederationOrigin as k, RouteActivityOptions as l, InboxListener as lt, ConstructorWithTypeId as m, OutboxPermanentFailureHandler as mt, Context as n, CollectionCounter as nt, InboxContext as o, CustomCollectionCursor as ot, CollectionCallbackSetters as p, OutboxErrorHandler as pt, MessageQueue as q, ForwardActivityOptions as r, CollectionCursor as rt, ParseUriResult as s, CustomCollectionDispatcher as st, ActorKeyPair as t, AuthorizePredicate as tt, SendActivityOptions as u, NodeInfoDispatcher as ut, FederationBuilder as v, WebFingerLinksDispatcher as vt, InboxChallengePolicy as w, ActivityTransformer as wt, FederationStartQueueOptions as x, PageItems as xt, FederationFetchOptions as y, SendActivityError as yt, RouterError as z };
|
|
@@ -2,7 +2,7 @@ import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client
|
|
|
2
2
|
import { o as VerifyRequestFailureReason, t as HttpMessageSignaturesSpec } from "./http-CrGuipxe.cjs";
|
|
3
3
|
import { n as GetKeyOwnerOptions } from "./owner-CptqhsOy.cjs";
|
|
4
4
|
import { n as KvStore, t as KvKey } from "./kv-CbLNp3zQ.cjs";
|
|
5
|
-
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, TraverseCollectionOptions } from "@fedify/vocab";
|
|
5
|
+
import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
|
|
6
6
|
import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions } from "@fedify/vocab-runtime";
|
|
7
7
|
import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
|
|
8
8
|
import { Span, Tracer, TracerProvider } from "@opentelemetry/api";
|
|
@@ -105,13 +105,13 @@ type NodeInfoDispatcher<TContextData> = (context: RequestContext<TContextData>)
|
|
|
105
105
|
*/
|
|
106
106
|
type WebFingerLinksDispatcher<TContextData> = (context: RequestContext<TContextData>, resource: URL) => readonly Link$1[] | Promise<readonly Link$1[]>;
|
|
107
107
|
/**
|
|
108
|
-
* A callback that dispatches an {@link Actor} object.
|
|
108
|
+
* A callback that dispatches an {@link Actor} object or a {@link Tombstone}.
|
|
109
109
|
*
|
|
110
110
|
* @template TContextData The context data to pass to the {@link Context}.
|
|
111
111
|
* @param context The request context.
|
|
112
112
|
* @param identifier The actor's internal identifier or username.
|
|
113
113
|
*/
|
|
114
|
-
type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, identifier: string) => Actor | null | Promise<Actor | null>;
|
|
114
|
+
type ActorDispatcher<TContextData> = (context: RequestContext<TContextData>, identifier: string) => Actor | Tombstone | null | Promise<Actor | Tombstone | null>;
|
|
115
115
|
/**
|
|
116
116
|
* A callback that dispatches key pairs for an actor.
|
|
117
117
|
*
|
|
@@ -921,7 +921,9 @@ interface Federatable<TContextData> {
|
|
|
921
921
|
* based on URI Template
|
|
922
922
|
* ([RFC 6570](https://tools.ietf.org/html/rfc6570)). The path
|
|
923
923
|
* must have one variable: `{identifier}`.
|
|
924
|
-
* @param dispatcher An actor dispatcher callback to register.
|
|
924
|
+
* @param dispatcher An actor dispatcher callback to register. It may return
|
|
925
|
+
* an actor, a `Tombstone`, or `null` if the actor is not
|
|
926
|
+
* found.
|
|
925
927
|
* @returns An object with methods to set other actor dispatcher callbacks.
|
|
926
928
|
* @throws {RouterError} Thrown if the path pattern is invalid.
|
|
927
929
|
*/
|
|
@@ -2225,6 +2227,19 @@ interface Context<TContextData> {
|
|
|
2225
2227
|
getCollectionUri<TParam extends Record<string, string>>(name: string | symbol, values: TParam): URL;
|
|
2226
2228
|
}
|
|
2227
2229
|
/**
|
|
2230
|
+
* Options for {@link RequestContext.getActor}.
|
|
2231
|
+
* @since 2.2.0
|
|
2232
|
+
*/
|
|
2233
|
+
interface GetActorOptions {
|
|
2234
|
+
/**
|
|
2235
|
+
* Controls how tombstoned actors are returned.
|
|
2236
|
+
*
|
|
2237
|
+
* By default, tombstones are suppressed and returned as `null`. Set this to
|
|
2238
|
+
* `"passthrough"` to receive a {@link Tombstone} result instead.
|
|
2239
|
+
*/
|
|
2240
|
+
readonly tombstone?: "suppress" | "passthrough";
|
|
2241
|
+
}
|
|
2242
|
+
/**
|
|
2228
2243
|
* A context for a request.
|
|
2229
2244
|
*/
|
|
2230
2245
|
interface RequestContext<TContextData> extends Context<TContextData> {
|
|
@@ -2254,6 +2269,46 @@ interface RequestContext<TContextData> extends Context<TContextData> {
|
|
|
2254
2269
|
*/
|
|
2255
2270
|
getActor(identifier: string): Promise<Actor | null>;
|
|
2256
2271
|
/**
|
|
2272
|
+
* Gets an {@link Actor} object or {@link Tombstone} for the given
|
|
2273
|
+
* identifier.
|
|
2274
|
+
* @param identifier The actor's identifier.
|
|
2275
|
+
* @param options Options for getting the actor. Set
|
|
2276
|
+
* `options.tombstone` to `"passthrough"` to receive
|
|
2277
|
+
* tombstoned actors instead of `null`.
|
|
2278
|
+
* @returns The actor object, a tombstone, or `null` if the actor is not
|
|
2279
|
+
* found.
|
|
2280
|
+
* @throws {Error} If no actor dispatcher is available.
|
|
2281
|
+
* @since 2.2.0
|
|
2282
|
+
*/
|
|
2283
|
+
getActor(identifier: string, options: GetActorOptions & {
|
|
2284
|
+
readonly tombstone: "passthrough";
|
|
2285
|
+
}): Promise<Actor | Tombstone | null>;
|
|
2286
|
+
/**
|
|
2287
|
+
* Gets an {@link Actor} object for the given identifier.
|
|
2288
|
+
* @param identifier The actor's identifier.
|
|
2289
|
+
* @param options Options for getting the actor.
|
|
2290
|
+
* @returns The actor object, or `null` if the actor is not found.
|
|
2291
|
+
* Tombstoned actors are suppressed unless `options.tombstone` is
|
|
2292
|
+
* `"passthrough"`.
|
|
2293
|
+
* @throws {Error} If no actor dispatcher is available.
|
|
2294
|
+
* @since 2.2.0
|
|
2295
|
+
*/
|
|
2296
|
+
getActor(identifier: string, options: GetActorOptions & {
|
|
2297
|
+
readonly tombstone?: "suppress" | undefined;
|
|
2298
|
+
}): Promise<Actor | null>;
|
|
2299
|
+
/**
|
|
2300
|
+
* Gets an {@link Actor} object or {@link Tombstone} for the given
|
|
2301
|
+
* identifier.
|
|
2302
|
+
* @param identifier The actor's identifier.
|
|
2303
|
+
* @param options Options for getting the actor.
|
|
2304
|
+
* @returns The actor object, a tombstone, or `null` if the actor is not
|
|
2305
|
+
* found. This broad overload is used when the caller passes an
|
|
2306
|
+
* options value whose `tombstone` mode is not known statically.
|
|
2307
|
+
* @throws {Error} If no actor dispatcher is available.
|
|
2308
|
+
* @since 2.2.0
|
|
2309
|
+
*/
|
|
2310
|
+
getActor(identifier: string, options: GetActorOptions): Promise<Actor | Tombstone | null>;
|
|
2311
|
+
/**
|
|
2257
2312
|
* Gets an object of the given class with the given values.
|
|
2258
2313
|
* @param cls The class to instantiate.
|
|
2259
2314
|
* @param values The values to pass to the object dispatcher.
|
|
@@ -2587,4 +2642,4 @@ interface ActorKeyPair extends CryptoKeyPair {
|
|
|
2587
2642
|
readonly multikey: Multikey;
|
|
2588
2643
|
}
|
|
2589
2644
|
//#endregion
|
|
2590
|
-
export {
|
|
2645
|
+
export { ActorHandleMapper as $, FederationQueueOptions as A, RouterOptions as B, IdempotencyStrategy as C, digest as Ct, Rfc6570Expression as D, ObjectCallbackSetters as E, createExponentialBackoffPolicy as F, InProcessMessageQueue as G, RespondWithObjectOptions as H, Message as I, MessageQueueEnqueueOptions as J, InProcessMessageQueueOptions as K, createFederationBuilder as L, CreateExponentialBackoffPolicyOptions as M, RetryContext as N, FederationKvPrefixes as O, RetryPolicy as P, ActorDispatcher as Q, Router as R, IdempotencyKeyCallback as S, buildCollectionSynchronizationHeader as St, InboxListenerSetters as T, respondWithObject as U, RouterRouteResult as V, respondWithObjectIfAcceptable as W, ParallelMessageQueue as X, MessageQueueListenOptions as Y, ActorAliasMapper as Z, Federation as _, UnverifiedActivityReason as _t, GetSignedKeyOptions as a, CustomCollectionCounter as at, FederationOptions as b, SenderKeyPair as bt, RequestContext as c, InboxErrorHandler as ct, SendActivityOptionsForCollection as d, ObjectAuthorizePredicate as dt, ActorKeyPairsDispatcher as et, ActorCallbackSetters as f, ObjectDispatcher as ft, Federatable as g, UnverifiedActivityHandler as gt, CustomCollectionCallbackSetters as h, SharedInboxKeyDispatcher as ht, GetActorOptions as i, CollectionDispatcher as it, createFederation as j, FederationOrigin as k, RouteActivityOptions as l, InboxListener as lt, ConstructorWithTypeId as m, OutboxPermanentFailureHandler as mt, Context as n, CollectionCounter as nt, InboxContext as o, CustomCollectionCursor as ot, CollectionCallbackSetters as p, OutboxErrorHandler as pt, MessageQueue as q, ForwardActivityOptions as r, CollectionCursor as rt, ParseUriResult as s, CustomCollectionDispatcher as st, ActorKeyPair as t, AuthorizePredicate as tt, SendActivityOptions as u, NodeInfoDispatcher as ut, FederationBuilder as v, WebFingerLinksDispatcher as vt, InboxChallengePolicy as w, ActivityTransformer as wt, FederationStartQueueOptions as x, PageItems as xt, FederationFetchOptions as y, SendActivityError as yt, RouterError as z };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { o as validateCryptoKey } from "./key-
|
|
5
|
-
import { n as doubleKnock } from "./http-
|
|
4
|
+
import { o as validateCryptoKey } from "./key-CC3yOGF0.mjs";
|
|
5
|
+
import { n as doubleKnock } from "./http-DukFwiXf.mjs";
|
|
6
6
|
import { curry } from "es-toolkit";
|
|
7
7
|
import { UrlError, createActivityPubRequest, getRemoteDocument, logRequest, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -5,7 +5,7 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
5
5
|
import { a as assertExists } from "../std__assert-Duiq_YC9.mjs";
|
|
6
6
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
|
|
8
|
-
import { n as createFederationBuilder } from "../builder-
|
|
8
|
+
import { n as createFederationBuilder } from "../builder-BGzN0XIV.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
|
|
@@ -6,18 +6,35 @@ import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
|
6
6
|
import "../std__assert-Duiq_YC9.mjs";
|
|
7
7
|
import { t as assert } from "../assert-ddO5KLpe.mjs";
|
|
8
8
|
import { r as parseAcceptSignature } from "../accept-Dd__NiUL.mjs";
|
|
9
|
-
import { s as signRequest } from "../http-
|
|
9
|
+
import { s as signRequest } from "../http-DukFwiXf.mjs";
|
|
10
10
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, s as rsaPublicKey2 } from "../keys-BAK-tUlf.mjs";
|
|
11
11
|
import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
|
|
12
|
-
import { a as createFederation, c as handleCollection, d as handleObject, f as respondWithObject, l as handleCustomCollection, p as respondWithObjectIfAcceptable, s as handleActor, u as handleInbox } from "../middleware-
|
|
13
|
-
import { t as InboxListenerSet } from "../inbox-
|
|
12
|
+
import { a as createFederation, c as handleCollection, d as handleObject, f as respondWithObject, l as handleCustomCollection, p as respondWithObjectIfAcceptable, s as handleActor, u as handleInbox } from "../middleware-BfOPomng.mjs";
|
|
13
|
+
import { t as InboxListenerSet } from "../inbox-wiVtdLY9.mjs";
|
|
14
14
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
15
|
-
import { Create, Note, Person } from "@fedify/vocab";
|
|
15
|
+
import { Create, Note, Person, Tombstone } from "@fedify/vocab";
|
|
16
16
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
17
17
|
//#region src/federation/handler.test.ts
|
|
18
|
+
const QUOTE_CONTEXT_TERMS = {
|
|
19
|
+
QuoteAuthorization: "https://w3id.org/fep/044f#QuoteAuthorization",
|
|
20
|
+
quote: {
|
|
21
|
+
"@id": "https://w3id.org/fep/044f#quote",
|
|
22
|
+
"@type": "@id"
|
|
23
|
+
},
|
|
24
|
+
quoteAuthorization: {
|
|
25
|
+
"@id": "https://w3id.org/fep/044f#quoteAuthorization",
|
|
26
|
+
"@type": "@id"
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
const WRAPPER_QUOTE_CONTEXT_TERMS = {
|
|
30
|
+
...QUOTE_CONTEXT_TERMS,
|
|
31
|
+
QuoteRequest: "https://w3id.org/fep/044f#QuoteRequest"
|
|
32
|
+
};
|
|
18
33
|
test("handleActor()", async () => {
|
|
34
|
+
const federation = createFederation({ kv: new MemoryKvStore() });
|
|
35
|
+
const deletedAt = Temporal.Instant.from("2024-01-15T00:00:00Z");
|
|
19
36
|
let context = createRequestContext({
|
|
20
|
-
federation
|
|
37
|
+
federation,
|
|
21
38
|
data: void 0,
|
|
22
39
|
url: new URL("https://example.com/"),
|
|
23
40
|
getActorUri(identifier) {
|
|
@@ -31,6 +48,13 @@ test("handleActor()", async () => {
|
|
|
31
48
|
name: "Someone"
|
|
32
49
|
});
|
|
33
50
|
};
|
|
51
|
+
const tombstoneDispatcher = (ctx, identifier) => {
|
|
52
|
+
if (identifier !== "gone") return null;
|
|
53
|
+
return new Tombstone({
|
|
54
|
+
id: ctx.getActorUri(identifier),
|
|
55
|
+
deleted: deletedAt
|
|
56
|
+
});
|
|
57
|
+
};
|
|
34
58
|
let onNotFoundCalled = null;
|
|
35
59
|
const onNotFound = (request) => {
|
|
36
60
|
onNotFoundCalled = request;
|
|
@@ -205,6 +229,42 @@ test("handleActor()", async () => {
|
|
|
205
229
|
});
|
|
206
230
|
assertEquals(onNotFoundCalled, null);
|
|
207
231
|
assertEquals(onUnauthorizedCalled, null);
|
|
232
|
+
onNotFoundCalled = null;
|
|
233
|
+
response = await handleActor(context.request, {
|
|
234
|
+
context,
|
|
235
|
+
identifier: "gone",
|
|
236
|
+
actorDispatcher: tombstoneDispatcher,
|
|
237
|
+
authorizePredicate: () => false,
|
|
238
|
+
onNotFound,
|
|
239
|
+
onUnauthorized
|
|
240
|
+
});
|
|
241
|
+
assertEquals(response.status, 401);
|
|
242
|
+
assertEquals(onNotFoundCalled, null);
|
|
243
|
+
assertEquals(onUnauthorizedCalled, context.request);
|
|
244
|
+
onUnauthorizedCalled = null;
|
|
245
|
+
response = await handleActor(context.request, {
|
|
246
|
+
context,
|
|
247
|
+
identifier: "gone",
|
|
248
|
+
actorDispatcher: tombstoneDispatcher,
|
|
249
|
+
authorizePredicate: () => true,
|
|
250
|
+
onNotFound,
|
|
251
|
+
onUnauthorized
|
|
252
|
+
});
|
|
253
|
+
assertEquals(response.status, 410);
|
|
254
|
+
assertEquals(response.headers.get("Content-Type"), "application/activity+json");
|
|
255
|
+
assertEquals(response.headers.get("Vary"), "Accept");
|
|
256
|
+
assertEquals(await response.json(), {
|
|
257
|
+
"@context": [
|
|
258
|
+
"https://www.w3.org/ns/activitystreams",
|
|
259
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
260
|
+
"https://gotosocial.org/ns"
|
|
261
|
+
],
|
|
262
|
+
id: "https://example.com/users/gone",
|
|
263
|
+
type: "Tombstone",
|
|
264
|
+
deleted: "2024-01-15T00:00:00Z"
|
|
265
|
+
});
|
|
266
|
+
assertEquals(onNotFoundCalled, null);
|
|
267
|
+
assertEquals(onUnauthorizedCalled, null);
|
|
208
268
|
});
|
|
209
269
|
test("handleObject()", async () => {
|
|
210
270
|
let context = createRequestContext({
|
|
@@ -315,6 +375,7 @@ test("handleObject()", async () => {
|
|
|
315
375
|
_misskey_quote: "misskey:_misskey_quote",
|
|
316
376
|
fedibird: "http://fedibird.com/ns#",
|
|
317
377
|
misskey: "https://misskey-hub.net/ns#",
|
|
378
|
+
...QUOTE_CONTEXT_TERMS,
|
|
318
379
|
quoteUri: "fedibird:quoteUri",
|
|
319
380
|
quoteUrl: "as:quoteUrl",
|
|
320
381
|
emojiReactions: {
|
|
@@ -403,6 +464,7 @@ test("handleObject()", async () => {
|
|
|
403
464
|
_misskey_quote: "misskey:_misskey_quote",
|
|
404
465
|
fedibird: "http://fedibird.com/ns#",
|
|
405
466
|
misskey: "https://misskey-hub.net/ns#",
|
|
467
|
+
...QUOTE_CONTEXT_TERMS,
|
|
406
468
|
quoteUri: "fedibird:quoteUri",
|
|
407
469
|
quoteUrl: "as:quoteUrl",
|
|
408
470
|
emojiReactions: {
|
|
@@ -550,6 +612,7 @@ test("handleCollection()", async () => {
|
|
|
550
612
|
"@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
|
|
551
613
|
},
|
|
552
614
|
_misskey_quote: "misskey:_misskey_quote",
|
|
615
|
+
...WRAPPER_QUOTE_CONTEXT_TERMS,
|
|
553
616
|
quoteUri: "fedibird:quoteUri",
|
|
554
617
|
quoteUrl: "as:quoteUrl",
|
|
555
618
|
emojiReactions: {
|
|
@@ -573,6 +636,7 @@ test("handleCollection()", async () => {
|
|
|
573
636
|
sensitive: "as:sensitive",
|
|
574
637
|
votersCount: "toot:votersCount",
|
|
575
638
|
_misskey_quote: "misskey:_misskey_quote",
|
|
639
|
+
...WRAPPER_QUOTE_CONTEXT_TERMS,
|
|
576
640
|
quoteUri: "fedibird:quoteUri",
|
|
577
641
|
quoteUrl: "as:quoteUrl",
|
|
578
642
|
emojiReactions: {
|
|
@@ -657,6 +721,7 @@ test("handleCollection()", async () => {
|
|
|
657
721
|
sensitive: "as:sensitive",
|
|
658
722
|
votersCount: "toot:votersCount",
|
|
659
723
|
_misskey_quote: "misskey:_misskey_quote",
|
|
724
|
+
...WRAPPER_QUOTE_CONTEXT_TERMS,
|
|
660
725
|
quoteUri: "fedibird:quoteUri",
|
|
661
726
|
quoteUrl: "as:quoteUrl",
|
|
662
727
|
emojiReactions: {
|
|
@@ -720,6 +785,7 @@ test("handleCollection()", async () => {
|
|
|
720
785
|
sensitive: "as:sensitive",
|
|
721
786
|
votersCount: "toot:votersCount",
|
|
722
787
|
_misskey_quote: "misskey:_misskey_quote",
|
|
788
|
+
...WRAPPER_QUOTE_CONTEXT_TERMS,
|
|
723
789
|
quoteUri: "fedibird:quoteUri",
|
|
724
790
|
quoteUrl: "as:quoteUrl",
|
|
725
791
|
emojiReactions: {
|
|
@@ -775,6 +841,7 @@ test("handleCollection()", async () => {
|
|
|
775
841
|
sensitive: "as:sensitive",
|
|
776
842
|
votersCount: "toot:votersCount",
|
|
777
843
|
_misskey_quote: "misskey:_misskey_quote",
|
|
844
|
+
...WRAPPER_QUOTE_CONTEXT_TERMS,
|
|
778
845
|
quoteUri: "fedibird:quoteUri",
|
|
779
846
|
quoteUrl: "as:quoteUrl",
|
|
780
847
|
emojiReactions: {
|
|
@@ -834,6 +901,7 @@ test("handleCollection()", async () => {
|
|
|
834
901
|
sensitive: "as:sensitive",
|
|
835
902
|
votersCount: "toot:votersCount",
|
|
836
903
|
_misskey_quote: "misskey:_misskey_quote",
|
|
904
|
+
...WRAPPER_QUOTE_CONTEXT_TERMS,
|
|
837
905
|
quoteUri: "fedibird:quoteUri",
|
|
838
906
|
quoteUrl: "as:quoteUrl",
|
|
839
907
|
emojiReactions: {
|
|
@@ -1076,6 +1144,7 @@ test("respondWithObject()", async () => {
|
|
|
1076
1144
|
_misskey_quote: "misskey:_misskey_quote",
|
|
1077
1145
|
fedibird: "http://fedibird.com/ns#",
|
|
1078
1146
|
misskey: "https://misskey-hub.net/ns#",
|
|
1147
|
+
...QUOTE_CONTEXT_TERMS,
|
|
1079
1148
|
quoteUri: "fedibird:quoteUri",
|
|
1080
1149
|
quoteUrl: "as:quoteUrl",
|
|
1081
1150
|
emojiReactions: {
|
|
@@ -1170,6 +1239,7 @@ test("respondWithObjectIfAcceptable", async () => {
|
|
|
1170
1239
|
_misskey_quote: "misskey:_misskey_quote",
|
|
1171
1240
|
fedibird: "http://fedibird.com/ns#",
|
|
1172
1241
|
misskey: "https://misskey-hub.net/ns#",
|
|
1242
|
+
...QUOTE_CONTEXT_TERMS,
|
|
1173
1243
|
quoteUri: "fedibird:quoteUri",
|
|
1174
1244
|
quoteUrl: "as:quoteUrl",
|
|
1175
1245
|
emojiReactions: {
|
|
@@ -1286,6 +1356,7 @@ test("handleCustomCollection()", async () => {
|
|
|
1286
1356
|
"@type": "http://www.w3.org/2001/XMLSchema#nonNegativeInteger"
|
|
1287
1357
|
},
|
|
1288
1358
|
_misskey_quote: "misskey:_misskey_quote",
|
|
1359
|
+
...WRAPPER_QUOTE_CONTEXT_TERMS,
|
|
1289
1360
|
quoteUri: "fedibird:quoteUri",
|
|
1290
1361
|
quoteUrl: "as:quoteUrl",
|
|
1291
1362
|
emojiReactions: {
|
|
@@ -1308,6 +1379,7 @@ test("handleCustomCollection()", async () => {
|
|
|
1308
1379
|
sensitive: "as:sensitive",
|
|
1309
1380
|
votersCount: "toot:votersCount",
|
|
1310
1381
|
_misskey_quote: "misskey:_misskey_quote",
|
|
1382
|
+
...WRAPPER_QUOTE_CONTEXT_TERMS,
|
|
1311
1383
|
quoteUri: "fedibird:quoteUri",
|
|
1312
1384
|
quoteUrl: "as:quoteUrl",
|
|
1313
1385
|
emojiReactions: {
|
|
@@ -4,9 +4,9 @@ globalThis.addEventListener = () => {};
|
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
5
|
import "../std__assert-Duiq_YC9.mjs";
|
|
6
6
|
import { n as ed25519PrivateKey, r as ed25519PublicKey, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
7
|
-
import { n as signObject } from "../proof-
|
|
7
|
+
import { n as signObject } from "../proof-Dfy2T5tG.mjs";
|
|
8
8
|
import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
|
|
9
|
-
import { a as createFederation } from "../middleware-
|
|
9
|
+
import { a as createFederation } from "../middleware-BfOPomng.mjs";
|
|
10
10
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
11
11
|
import { Create, Follow, Person } from "@fedify/vocab";
|
|
12
12
|
//#region src/federation/idempotency.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 { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
6
|
-
import { t as InboxListenerSet } from "../inbox-
|
|
6
|
+
import { t as InboxListenerSet } from "../inbox-wiVtdLY9.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
import { Activity, Create, Invite, Offer, Update } from "@fedify/vocab";
|
|
9
9
|
//#region src/federation/inbox.test.ts
|
|
@@ -10,14 +10,14 @@ import { t as assertInstanceOf } from "../assert_instance_of-C4Ri6VuN.mjs";
|
|
|
10
10
|
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
11
11
|
import { t as assertNotEquals } from "../assert_not_equals--wG9hV7u.mjs";
|
|
12
12
|
import { t as assert } from "../assert-ddO5KLpe.mjs";
|
|
13
|
-
import { l as verifyRequest, s as signRequest } from "../http-
|
|
13
|
+
import { l as verifyRequest, s as signRequest } from "../http-DukFwiXf.mjs";
|
|
14
14
|
import { a as rsaPrivateKey3, c as rsaPublicKey3, i as rsaPrivateKey2, n as ed25519PrivateKey, r as ed25519PublicKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-BAK-tUlf.mjs";
|
|
15
|
-
import { t as getAuthenticatedDocumentLoader } from "../docloader-
|
|
16
|
-
import { a as signJsonLd, o as verifyJsonLd, r as detachSignature } from "../ld-
|
|
17
|
-
import { t as doesActorOwnKey } from "../owner-
|
|
18
|
-
import { n as signObject, r as verifyObject } from "../proof-
|
|
15
|
+
import { t as getAuthenticatedDocumentLoader } from "../docloader-B_eTYGFt.mjs";
|
|
16
|
+
import { a as signJsonLd, o as verifyJsonLd, r as detachSignature } from "../ld-D67kDIA0.mjs";
|
|
17
|
+
import { t as doesActorOwnKey } from "../owner-CxO6322k.mjs";
|
|
18
|
+
import { n as signObject, r as verifyObject } from "../proof-Dfy2T5tG.mjs";
|
|
19
19
|
import { t as MemoryKvStore } from "../kv-tL2TOE9X.mjs";
|
|
20
|
-
import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-
|
|
20
|
+
import { a as createFederation, i as KvSpecDeterminer, n as FederationImpl, r as InboxContextImpl, t as ContextImpl } from "../middleware-BfOPomng.mjs";
|
|
21
21
|
import { mockDocumentLoader, test } from "@fedify/fixture";
|
|
22
22
|
import * as vocab from "@fedify/vocab";
|
|
23
23
|
import { getTypeId, lookupObject } from "@fedify/vocab";
|
|
@@ -669,12 +669,24 @@ test({
|
|
|
669
669
|
assertEquals(await signedCtx2.getSignedKeyOwner(), expectedOwner);
|
|
670
670
|
assertEquals(await signedCtx2.getSignedKey(), rsaPublicKey3);
|
|
671
671
|
assertEquals(await signedCtx2.getSignedKeyOwner(), expectedOwner);
|
|
672
|
-
federation.setActorDispatcher("/users/{identifier}", (
|
|
672
|
+
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => identifier === "gone" ? new vocab.Tombstone({
|
|
673
|
+
id: ctx.getActorUri(identifier),
|
|
674
|
+
deleted: Temporal.Instant.from("2024-01-15T00:00:00Z")
|
|
675
|
+
}) : new vocab.Person({ preferredUsername: identifier }));
|
|
673
676
|
const ctx2 = federation.createContext(req, 789);
|
|
674
677
|
assertEquals(ctx2.request, req);
|
|
675
678
|
assertEquals(ctx2.url, new URL("https://example.com/"));
|
|
676
679
|
assertEquals(ctx2.data, 789);
|
|
677
680
|
assertEquals(await ctx2.getActor("john"), new vocab.Person({ preferredUsername: "john" }));
|
|
681
|
+
assertEquals(await ctx2.getActor("gone"), null);
|
|
682
|
+
assertEquals(await ctx2.getActor("gone", { tombstone: "passthrough" }), new vocab.Tombstone({
|
|
683
|
+
id: new URL("https://example.com/users/gone"),
|
|
684
|
+
deleted: Temporal.Instant.from("2024-01-15T00:00:00Z")
|
|
685
|
+
}));
|
|
686
|
+
assertEquals(await ctx2.getActor("gone", { tombstone: "passthrough" }), new vocab.Tombstone({
|
|
687
|
+
id: new URL("https://example.com/users/gone"),
|
|
688
|
+
deleted: Temporal.Instant.from("2024-01-15T00:00:00Z")
|
|
689
|
+
}));
|
|
678
690
|
federation.setObjectDispatcher(vocab.Note, "/users/{identifier}/notes/{id}", (_ctx, values) => {
|
|
679
691
|
return new vocab.Note({ summary: `Note ${values.id} by ${values.identifier}` });
|
|
680
692
|
});
|
|
@@ -745,6 +757,10 @@ test("Federation.fetch()", async (t) => {
|
|
|
745
757
|
});
|
|
746
758
|
federation.setActorDispatcher("/users/{identifier}", (ctx, identifier) => {
|
|
747
759
|
dispatches.push(identifier);
|
|
760
|
+
if (identifier === "gone") return new vocab.Tombstone({
|
|
761
|
+
id: ctx.getActorUri(identifier),
|
|
762
|
+
deleted: Temporal.Instant.from("2024-01-15T00:00:00Z")
|
|
763
|
+
});
|
|
748
764
|
return new vocab.Person({
|
|
749
765
|
id: ctx.getActorUri(identifier),
|
|
750
766
|
inbox: ctx.getInboxUri(identifier),
|
|
@@ -845,6 +861,41 @@ test("Federation.fetch()", async (t) => {
|
|
|
845
861
|
assertEquals(dispatches, ["activity"]);
|
|
846
862
|
assertEquals(response.status, 200);
|
|
847
863
|
});
|
|
864
|
+
await t.step("GET tombstoned actor returns 410 Gone", async () => {
|
|
865
|
+
const { federation, dispatches } = createTestContext();
|
|
866
|
+
const response = await federation.fetch(new Request("https://example.com/users/gone", {
|
|
867
|
+
method: "GET",
|
|
868
|
+
headers: { "Accept": "application/activity+json" }
|
|
869
|
+
}), { contextData: void 0 });
|
|
870
|
+
assertEquals(dispatches, ["gone"]);
|
|
871
|
+
assertEquals(response.status, 410);
|
|
872
|
+
assertEquals(await response.json(), {
|
|
873
|
+
"@context": [
|
|
874
|
+
"https://www.w3.org/ns/activitystreams",
|
|
875
|
+
"https://w3id.org/security/data-integrity/v1",
|
|
876
|
+
"https://gotosocial.org/ns"
|
|
877
|
+
],
|
|
878
|
+
id: "https://example.com/users/gone",
|
|
879
|
+
type: "Tombstone",
|
|
880
|
+
deleted: "2024-01-15T00:00:00Z"
|
|
881
|
+
});
|
|
882
|
+
});
|
|
883
|
+
await t.step("WebFinger for tombstoned actor returns 410 Gone", async () => {
|
|
884
|
+
const { federation, dispatches } = createTestContext();
|
|
885
|
+
const response = await federation.fetch(new Request("https://example.com/.well-known/webfinger?resource=acct:gone@example.com"), { contextData: void 0 });
|
|
886
|
+
assertEquals(dispatches, ["gone"]);
|
|
887
|
+
assertEquals(response.status, 410);
|
|
888
|
+
assertEquals(response.headers.get("Access-Control-Allow-Origin"), "*");
|
|
889
|
+
});
|
|
890
|
+
await t.step("POST to tombstoned inbox returns not found", async () => {
|
|
891
|
+
const { federation, inbox } = createTestContext();
|
|
892
|
+
const response = await federation.fetch(new Request("https://example.com/users/gone/inbox", {
|
|
893
|
+
method: "POST",
|
|
894
|
+
headers: { "accept": "application/ld+json" }
|
|
895
|
+
}), { contextData: void 0 });
|
|
896
|
+
assertEquals(inbox, []);
|
|
897
|
+
assertEquals(response.status, 404);
|
|
898
|
+
});
|
|
848
899
|
await t.step("onNotAcceptable with GET", async () => {
|
|
849
900
|
const { federation } = createTestContext();
|
|
850
901
|
let notAcceptableCalled = false;
|
package/dist/federation/mod.cjs
CHANGED
|
@@ -2,7 +2,7 @@ const { Temporal } = require("@js-temporal/polyfill");
|
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
4
4
|
require("../chunk-DDcVe30Y.cjs");
|
|
5
|
-
const require_middleware = require("../middleware-
|
|
5
|
+
const require_middleware = require("../middleware-CP-fzmy_.cjs");
|
|
6
6
|
let es_toolkit = require("es-toolkit");
|
|
7
7
|
//#region src/federation/kv.ts
|
|
8
8
|
/**
|