@fedify/fedify 2.0.0-pr.559.5 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -0
- package/dist/{builder-BJ8JxPW5.js → builder-DIwRDV19.js} +12 -57
- package/dist/compat/mod.d.cts +2 -2
- package/dist/compat/mod.d.ts +2 -2
- package/dist/compat/transformers.test.js +11 -11
- package/dist/{context-Cf0-LmZC.d.cts → context-BdNW_8a3.d.cts} +19 -46
- package/dist/{context-liIe6DFH.d.ts → context-C-GVKcJR.d.ts} +19 -46
- package/dist/{deno-CQvbJJs6.js → deno-CJgVX6Dr.js} +1 -4
- package/dist/{docloader-C7haPFrm.js → docloader-BMecQIi-.js} +4 -12
- package/dist/federation/builder.test.js +3 -3
- package/dist/federation/handler.test.js +45 -45
- package/dist/federation/idempotency.test.js +11 -11
- package/dist/federation/inbox.test.js +2 -2
- package/dist/federation/middleware.test.js +43 -68
- package/dist/federation/mod.cjs +4 -4
- package/dist/federation/mod.d.cts +3 -3
- package/dist/federation/mod.d.ts +3 -3
- package/dist/federation/mod.js +4 -4
- package/dist/federation/send.test.js +90 -5
- package/dist/federation/webfinger.test.js +12 -15
- package/dist/{http-D75q_hW-.js → http-CMTBVAxQ.js} +2 -2
- package/dist/{http-D3jnynqJ.cjs → http-CowIBMKY.cjs} +1 -4
- package/dist/{http-BO0w34cM.js → http-DoLgvgZ3.js} +1 -4
- package/dist/{inbox-DHboTK3x.js → inbox-BrQMunLn.js} +1 -1
- package/dist/{key-DzOIwgIi.js → key-BQD4Ef_6.js} +1 -1
- package/dist/{kv-cache-Chn8IE8p.cjs → kv-cache-174yQHE6.cjs} +1 -3
- package/dist/{kv-cache-JQOZpm43.js → kv-cache-CFlvozMZ.js} +2 -4
- package/dist/{ld-BDvJI1Ch.js → ld-DNdCEe6l.js} +2 -2
- package/dist/{middleware-CqxuI8xD.js → middleware-BN-t5M_R.js} +157 -210
- package/dist/middleware-BYNnNj-3.cjs +12 -0
- package/dist/{middleware-C1SMUD_l.js → middleware-D5JdOwAE.js} +193 -260
- package/dist/{middleware-HBYhBAM1.js → middleware-UqzNuf3o.js} +11 -11
- package/dist/{middleware-DATx715C.cjs → middleware-aQr0yVne.cjs} +193 -260
- package/dist/{middleware-BDPlUI8Z.js → middleware-dO1Uzsiv.js} +4 -4
- package/dist/{mod-H3ScYaOb.d.cts → mod-5PNty1K9.d.cts} +1 -1
- package/dist/{mod-Do_sZWAA.d.cts → mod-BcpEGTWV.d.cts} +1 -1
- package/dist/{mod-CvhyLrjX.d.ts → mod-CevNbUol.d.ts} +0 -18
- package/dist/{mod-Dquroqiv.d.ts → mod-CtO31FCx.d.ts} +1 -1
- package/dist/{mod-B9_l3te3.d.ts → mod-Da9fNDyC.d.ts} +1 -1
- package/dist/{mod-DWaA45ef.d.cts → mod-ErTjUJs9.d.cts} +0 -18
- package/dist/mod.cjs +4 -4
- package/dist/mod.d.cts +6 -6
- package/dist/mod.d.ts +6 -6
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/handler.test.js +11 -11
- package/dist/{owner-DSRxYIP4.js → owner-DbymvgVI.js} +1 -1
- package/dist/{proof-C_XZU5IE.js → proof-C85CNL5a.js} +1 -1
- package/dist/{proof-CWEkXV08.cjs → proof-DQFAjOse.cjs} +1 -1
- package/dist/{proof-9WkFZv2S.js → proof-DVBdddim.js} +2 -2
- package/dist/{send-qOq9Dgkb.js → send-CkvEc-Tx.js} +35 -4
- package/dist/sig/http.test.js +3 -3
- package/dist/sig/key.test.js +2 -2
- package/dist/sig/ld.test.js +3 -3
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.js +3 -3
- package/dist/sig/proof.test.js +3 -3
- package/dist/testing/mod.d.ts +13 -33
- package/dist/utils/docloader.test.js +4 -4
- package/dist/utils/mod.cjs +2 -2
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +2 -2
- package/package.json +8 -8
- package/dist/middleware-C3SOA_O_.cjs +0 -12
|
@@ -3,10 +3,10 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
5
|
import { getDefaultActivityTransformers } from "./transformers-C3FLHUd6.js";
|
|
6
|
-
import { deno_default, doubleKnock, exportJwk, importJwk, validateCryptoKey, verifyRequest } from "./http-
|
|
7
|
-
import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-
|
|
6
|
+
import { deno_default, doubleKnock, exportJwk, importJwk, validateCryptoKey, verifyRequest } from "./http-DoLgvgZ3.js";
|
|
7
|
+
import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-C85CNL5a.js";
|
|
8
8
|
import { getNodeInfo, nodeInfoToJson } from "./types-C93Ob9cU.js";
|
|
9
|
-
import { getAuthenticatedDocumentLoader, kvCache } from "./kv-cache-
|
|
9
|
+
import { getAuthenticatedDocumentLoader, kvCache } from "./kv-cache-CFlvozMZ.js";
|
|
10
10
|
import { getLogger, withContext } from "@logtape/logtape";
|
|
11
11
|
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
|
|
12
12
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
@@ -338,7 +338,7 @@ var FederationBuilderImpl = class {
|
|
|
338
338
|
this.collectionTypeIds = {};
|
|
339
339
|
}
|
|
340
340
|
async build(options) {
|
|
341
|
-
const { FederationImpl: FederationImpl$1 } = await import("./middleware-
|
|
341
|
+
const { FederationImpl: FederationImpl$1 } = await import("./middleware-dO1Uzsiv.js");
|
|
342
342
|
const f = new FederationImpl$1(options);
|
|
343
343
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
344
344
|
f.router = this.router.clone();
|
|
@@ -370,12 +370,7 @@ var FederationBuilderImpl = class {
|
|
|
370
370
|
setActorDispatcher(path, dispatcher) {
|
|
371
371
|
if (this.router.has("actor")) throw new RouterError("Actor dispatcher already set.");
|
|
372
372
|
const variables = this.router.add(path, "actor");
|
|
373
|
-
if (variables.size !== 1 || !
|
|
374
|
-
if (variables.has("handle")) getLogger([
|
|
375
|
-
"fedify",
|
|
376
|
-
"federation",
|
|
377
|
-
"actor"
|
|
378
|
-
]).warn("The {{handle}} variable in the actor dispatcher path is deprecated. Use {{identifier}} instead.");
|
|
373
|
+
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for actor dispatcher must have one variable: {identifier}");
|
|
379
374
|
const callbacks = { dispatcher: async (context$1, identifier) => {
|
|
380
375
|
const actor = await this._getTracer().startActiveSpan("activitypub.dispatch_actor", {
|
|
381
376
|
kind: SpanKind.SERVER,
|
|
@@ -537,12 +532,7 @@ var FederationBuilderImpl = class {
|
|
|
537
532
|
if (this.inboxPath !== path) throw new RouterError("Inbox dispatcher path must match inbox listener path.");
|
|
538
533
|
} else {
|
|
539
534
|
const variables = this.router.add(path, "inbox");
|
|
540
|
-
if (variables.size !== 1 || !
|
|
541
|
-
if (variables.has("handle")) getLogger([
|
|
542
|
-
"fedify",
|
|
543
|
-
"federation",
|
|
544
|
-
"inbox"
|
|
545
|
-
]).warn("The {{handle}} variable in the inbox dispatcher path is deprecated. Use {{identifier}} instead.");
|
|
535
|
+
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for inbox dispatcher must have one variable: {identifier}");
|
|
546
536
|
this.inboxPath = path;
|
|
547
537
|
}
|
|
548
538
|
const callbacks = { dispatcher };
|
|
@@ -570,12 +560,7 @@ var FederationBuilderImpl = class {
|
|
|
570
560
|
setOutboxDispatcher(path, dispatcher) {
|
|
571
561
|
if (this.router.has("outbox")) throw new RouterError("Outbox dispatcher already set.");
|
|
572
562
|
const variables = this.router.add(path, "outbox");
|
|
573
|
-
if (variables.size !== 1 || !
|
|
574
|
-
if (variables.has("handle")) getLogger([
|
|
575
|
-
"fedify",
|
|
576
|
-
"federation",
|
|
577
|
-
"outbox"
|
|
578
|
-
]).warn("The {{handle}} variable in the outbox dispatcher path is deprecated. Use {{identifier}} instead.");
|
|
563
|
+
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for outbox dispatcher must have one variable: {identifier}");
|
|
579
564
|
const callbacks = { dispatcher };
|
|
580
565
|
this.outboxCallbacks = callbacks;
|
|
581
566
|
const setters = {
|
|
@@ -601,12 +586,7 @@ var FederationBuilderImpl = class {
|
|
|
601
586
|
setFollowingDispatcher(path, dispatcher) {
|
|
602
587
|
if (this.router.has("following")) throw new RouterError("Following collection dispatcher already set.");
|
|
603
588
|
const variables = this.router.add(path, "following");
|
|
604
|
-
if (variables.size !== 1 || !
|
|
605
|
-
if (variables.has("handle")) getLogger([
|
|
606
|
-
"fedify",
|
|
607
|
-
"federation",
|
|
608
|
-
"collection"
|
|
609
|
-
]).warn("The {{handle}} variable in the following collection dispatcher path is deprecated. Use {{identifier}} instead.");
|
|
589
|
+
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for following collection dispatcher must have one variable: {identifier}");
|
|
610
590
|
const callbacks = { dispatcher };
|
|
611
591
|
this.followingCallbacks = callbacks;
|
|
612
592
|
const setters = {
|
|
@@ -632,12 +612,7 @@ var FederationBuilderImpl = class {
|
|
|
632
612
|
setFollowersDispatcher(path, dispatcher) {
|
|
633
613
|
if (this.router.has("followers")) throw new RouterError("Followers collection dispatcher already set.");
|
|
634
614
|
const variables = this.router.add(path, "followers");
|
|
635
|
-
if (variables.size !== 1 || !
|
|
636
|
-
if (variables.has("handle")) getLogger([
|
|
637
|
-
"fedify",
|
|
638
|
-
"federation",
|
|
639
|
-
"collection"
|
|
640
|
-
]).warn("The {{handle}} variable in the followers collection dispatcher path is deprecated. Use {{identifier}} instead.");
|
|
615
|
+
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for followers collection dispatcher must have one variable: {identifier}");
|
|
641
616
|
const callbacks = { dispatcher };
|
|
642
617
|
this.followersCallbacks = callbacks;
|
|
643
618
|
const setters = {
|
|
@@ -663,12 +638,7 @@ var FederationBuilderImpl = class {
|
|
|
663
638
|
setLikedDispatcher(path, dispatcher) {
|
|
664
639
|
if (this.router.has("liked")) throw new RouterError("Liked collection dispatcher already set.");
|
|
665
640
|
const variables = this.router.add(path, "liked");
|
|
666
|
-
if (variables.size !== 1 || !
|
|
667
|
-
if (variables.has("handle")) getLogger([
|
|
668
|
-
"fedify",
|
|
669
|
-
"federation",
|
|
670
|
-
"collection"
|
|
671
|
-
]).warn("The {{handle}} variable in the liked collection dispatcher path is deprecated. Use {{identifier}} instead.");
|
|
641
|
+
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for liked collection dispatcher must have one variable: {identifier}");
|
|
672
642
|
const callbacks = { dispatcher };
|
|
673
643
|
this.likedCallbacks = callbacks;
|
|
674
644
|
const setters = {
|
|
@@ -694,12 +664,7 @@ var FederationBuilderImpl = class {
|
|
|
694
664
|
setFeaturedDispatcher(path, dispatcher) {
|
|
695
665
|
if (this.router.has("featured")) throw new RouterError("Featured collection dispatcher already set.");
|
|
696
666
|
const variables = this.router.add(path, "featured");
|
|
697
|
-
if (variables.size !== 1 || !
|
|
698
|
-
if (variables.has("handle")) getLogger([
|
|
699
|
-
"fedify",
|
|
700
|
-
"federation",
|
|
701
|
-
"collection"
|
|
702
|
-
]).warn("The {{handle}} variable in the featured collection dispatcher path is deprecated. Use {{identifier}} instead.");
|
|
667
|
+
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for featured collection dispatcher must have one variable: {identifier}");
|
|
703
668
|
const callbacks = { dispatcher };
|
|
704
669
|
this.featuredCallbacks = callbacks;
|
|
705
670
|
const setters = {
|
|
@@ -725,12 +690,7 @@ var FederationBuilderImpl = class {
|
|
|
725
690
|
setFeaturedTagsDispatcher(path, dispatcher) {
|
|
726
691
|
if (this.router.has("featuredTags")) throw new RouterError("Featured tags collection dispatcher already set.");
|
|
727
692
|
const variables = this.router.add(path, "featuredTags");
|
|
728
|
-
if (variables.size !== 1 || !
|
|
729
|
-
if (variables.has("handle")) getLogger([
|
|
730
|
-
"fedify",
|
|
731
|
-
"federation",
|
|
732
|
-
"collection"
|
|
733
|
-
]).warn("The {{handle}} variable in the featured tags collection dispatcher path is deprecated. Use {{identifier}} instead.");
|
|
693
|
+
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for featured tags collection dispatcher must have one variable: {identifier}");
|
|
734
694
|
const callbacks = { dispatcher };
|
|
735
695
|
this.featuredTagsCallbacks = callbacks;
|
|
736
696
|
const setters = {
|
|
@@ -759,13 +719,8 @@ var FederationBuilderImpl = class {
|
|
|
759
719
|
if (this.inboxPath !== inboxPath) throw new RouterError("Inbox listener path must match inbox dispatcher path.");
|
|
760
720
|
} else {
|
|
761
721
|
const variables = this.router.add(inboxPath, "inbox");
|
|
762
|
-
if (variables.size !== 1 || !
|
|
722
|
+
if (variables.size !== 1 || !variables.has("identifier")) throw new RouterError("Path for inbox must have one variable: {identifier}");
|
|
763
723
|
this.inboxPath = inboxPath;
|
|
764
|
-
if (variables.has("handle")) getLogger([
|
|
765
|
-
"fedify",
|
|
766
|
-
"federation",
|
|
767
|
-
"inbox"
|
|
768
|
-
]).warn("The {{handle}} variable in the inbox path is deprecated. Use {{identifier}} instead.");
|
|
769
724
|
}
|
|
770
725
|
if (sharedInboxPath != null) {
|
|
771
726
|
const siVars = this.router.add(sharedInboxPath, "sharedInbox");
|
|
@@ -2132,6 +2087,34 @@ function sendActivity(options) {
|
|
|
2132
2087
|
}
|
|
2133
2088
|
});
|
|
2134
2089
|
}
|
|
2090
|
+
const MAX_ERROR_RESPONSE_BODY_BYTES = 1024;
|
|
2091
|
+
async function readLimitedResponseBody(response, maxBytes) {
|
|
2092
|
+
if (response.body == null) return "";
|
|
2093
|
+
const reader = response.body.getReader();
|
|
2094
|
+
const decoder = new TextDecoder();
|
|
2095
|
+
const chunks = [];
|
|
2096
|
+
let totalBytes = 0;
|
|
2097
|
+
let truncated = false;
|
|
2098
|
+
try {
|
|
2099
|
+
while (true) {
|
|
2100
|
+
const { done, value } = await reader.read();
|
|
2101
|
+
if (done) break;
|
|
2102
|
+
if (totalBytes + value.length > maxBytes) {
|
|
2103
|
+
const remaining = maxBytes - totalBytes;
|
|
2104
|
+
if (remaining > 0) chunks.push(decoder.decode(value.slice(0, remaining), { stream: true }));
|
|
2105
|
+
truncated = true;
|
|
2106
|
+
break;
|
|
2107
|
+
}
|
|
2108
|
+
chunks.push(decoder.decode(value, { stream: true }));
|
|
2109
|
+
totalBytes += value.length;
|
|
2110
|
+
}
|
|
2111
|
+
} finally {
|
|
2112
|
+
reader.releaseLock();
|
|
2113
|
+
}
|
|
2114
|
+
let result = chunks.join("");
|
|
2115
|
+
if (truncated) result += "… (truncated)";
|
|
2116
|
+
return result;
|
|
2117
|
+
}
|
|
2135
2118
|
async function sendActivityInternal({ activity, activityId, keys, inbox, headers, specDeterminer, tracerProvider }, span) {
|
|
2136
2119
|
const logger$1 = getLogger([
|
|
2137
2120
|
"fedify",
|
|
@@ -2174,7 +2157,7 @@ async function sendActivityInternal({ activity, activityId, keys, inbox, headers
|
|
|
2174
2157
|
if (!response.ok) {
|
|
2175
2158
|
let error;
|
|
2176
2159
|
try {
|
|
2177
|
-
error = await response
|
|
2160
|
+
error = await readLimitedResponseBody(response, MAX_ERROR_RESPONSE_BODY_BYTES);
|
|
2178
2161
|
} catch (_) {
|
|
2179
2162
|
error = "";
|
|
2180
2163
|
}
|
|
@@ -2209,7 +2192,10 @@ var SendActivityError = class extends Error {
|
|
|
2209
2192
|
*/
|
|
2210
2193
|
statusCode;
|
|
2211
2194
|
/**
|
|
2212
|
-
* The response body from the inbox, if any.
|
|
2195
|
+
* The response body from the inbox, if any. Note that this may be
|
|
2196
|
+
* truncated to a maximum of 1 KiB to prevent excessive memory consumption
|
|
2197
|
+
* when remote servers return large error pages (e.g., Cloudflare error pages).
|
|
2198
|
+
* If truncated, the string will end with `"… (truncated)"`.
|
|
2213
2199
|
*/
|
|
2214
2200
|
responseBody;
|
|
2215
2201
|
/**
|
|
@@ -2394,7 +2380,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2394
2380
|
outboxRetryPolicy;
|
|
2395
2381
|
inboxRetryPolicy;
|
|
2396
2382
|
activityTransformers;
|
|
2397
|
-
|
|
2383
|
+
_tracerProvider;
|
|
2398
2384
|
firstKnock;
|
|
2399
2385
|
constructor(options) {
|
|
2400
2386
|
super();
|
|
@@ -2476,9 +2462,12 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2476
2462
|
this.outboxRetryPolicy = options.outboxRetryPolicy ?? createExponentialBackoffPolicy();
|
|
2477
2463
|
this.inboxRetryPolicy = options.inboxRetryPolicy ?? createExponentialBackoffPolicy();
|
|
2478
2464
|
this.activityTransformers = options.activityTransformers ?? getDefaultActivityTransformers();
|
|
2479
|
-
this.
|
|
2465
|
+
this._tracerProvider = options.tracerProvider;
|
|
2480
2466
|
this.firstKnock = options.firstKnock;
|
|
2481
2467
|
}
|
|
2468
|
+
get tracerProvider() {
|
|
2469
|
+
return this._tracerProvider ?? trace.getTracerProvider();
|
|
2470
|
+
}
|
|
2482
2471
|
_initializeRouter() {
|
|
2483
2472
|
this.router.add("/.well-known/webfinger", "webfinger");
|
|
2484
2473
|
this.router.add("/.well-known/nodeinfo", "nodeInfoJrd");
|
|
@@ -2519,18 +2508,24 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2519
2508
|
kind: SpanKind.CONSUMER,
|
|
2520
2509
|
attributes: { "activitypub.activity.type": message.activityType }
|
|
2521
2510
|
}, extractedContext, async (span) => {
|
|
2522
|
-
|
|
2523
|
-
|
|
2524
|
-
|
|
2525
|
-
|
|
2526
|
-
|
|
2527
|
-
|
|
2528
|
-
|
|
2529
|
-
|
|
2530
|
-
|
|
2531
|
-
|
|
2532
|
-
|
|
2533
|
-
|
|
2511
|
+
const spanCtx = span.spanContext();
|
|
2512
|
+
return await withContext({
|
|
2513
|
+
traceId: spanCtx.traceId,
|
|
2514
|
+
spanId: spanCtx.spanId
|
|
2515
|
+
}, async () => {
|
|
2516
|
+
if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
|
|
2517
|
+
try {
|
|
2518
|
+
await this.#listenFanoutMessage(contextData, message);
|
|
2519
|
+
} catch (e) {
|
|
2520
|
+
span.setStatus({
|
|
2521
|
+
code: SpanStatusCode.ERROR,
|
|
2522
|
+
message: String(e)
|
|
2523
|
+
});
|
|
2524
|
+
throw e;
|
|
2525
|
+
} finally {
|
|
2526
|
+
span.end();
|
|
2527
|
+
}
|
|
2528
|
+
});
|
|
2534
2529
|
});
|
|
2535
2530
|
else if (message.type === "outbox") await tracer.startActiveSpan("activitypub.outbox", {
|
|
2536
2531
|
kind: SpanKind.CONSUMER,
|
|
@@ -2539,34 +2534,46 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2539
2534
|
"activitypub.activity.retries": message.attempt
|
|
2540
2535
|
}
|
|
2541
2536
|
}, extractedContext, async (span) => {
|
|
2542
|
-
|
|
2543
|
-
|
|
2544
|
-
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
|
|
2548
|
-
|
|
2549
|
-
|
|
2550
|
-
|
|
2551
|
-
|
|
2552
|
-
|
|
2553
|
-
|
|
2537
|
+
const spanCtx = span.spanContext();
|
|
2538
|
+
return await withContext({
|
|
2539
|
+
traceId: spanCtx.traceId,
|
|
2540
|
+
spanId: spanCtx.spanId
|
|
2541
|
+
}, async () => {
|
|
2542
|
+
if (message.activityId != null) span.setAttribute("activitypub.activity.id", message.activityId);
|
|
2543
|
+
try {
|
|
2544
|
+
await this.#listenOutboxMessage(contextData, message, span);
|
|
2545
|
+
} catch (e) {
|
|
2546
|
+
span.setStatus({
|
|
2547
|
+
code: SpanStatusCode.ERROR,
|
|
2548
|
+
message: String(e)
|
|
2549
|
+
});
|
|
2550
|
+
throw e;
|
|
2551
|
+
} finally {
|
|
2552
|
+
span.end();
|
|
2553
|
+
}
|
|
2554
|
+
});
|
|
2554
2555
|
});
|
|
2555
2556
|
else if (message.type === "inbox") await tracer.startActiveSpan("activitypub.inbox", {
|
|
2556
2557
|
kind: SpanKind.CONSUMER,
|
|
2557
2558
|
attributes: { "activitypub.shared_inbox": message.identifier == null }
|
|
2558
2559
|
}, extractedContext, async (span) => {
|
|
2559
|
-
|
|
2560
|
-
|
|
2561
|
-
|
|
2562
|
-
|
|
2563
|
-
|
|
2564
|
-
|
|
2565
|
-
|
|
2566
|
-
|
|
2567
|
-
|
|
2568
|
-
|
|
2569
|
-
|
|
2560
|
+
const spanCtx = span.spanContext();
|
|
2561
|
+
return await withContext({
|
|
2562
|
+
traceId: spanCtx.traceId,
|
|
2563
|
+
spanId: spanCtx.spanId
|
|
2564
|
+
}, async () => {
|
|
2565
|
+
try {
|
|
2566
|
+
await this.#listenInboxMessage(contextData, message, span);
|
|
2567
|
+
} catch (e) {
|
|
2568
|
+
span.setStatus({
|
|
2569
|
+
code: SpanStatusCode.ERROR,
|
|
2570
|
+
message: String(e)
|
|
2571
|
+
});
|
|
2572
|
+
throw e;
|
|
2573
|
+
} finally {
|
|
2574
|
+
span.end();
|
|
2575
|
+
}
|
|
2576
|
+
});
|
|
2570
2577
|
});
|
|
2571
2578
|
});
|
|
2572
2579
|
}
|
|
@@ -2730,7 +2737,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2730
2737
|
if (message.identifier != null) context$1 = this.#createContext(baseUrl, ctxData, { documentLoader: await context$1.getDocumentLoader({ identifier: message.identifier }) });
|
|
2731
2738
|
else if (this.sharedInboxKeyDispatcher != null) {
|
|
2732
2739
|
const identity = await this.sharedInboxKeyDispatcher(context$1);
|
|
2733
|
-
if (identity != null) context$1 = this.#createContext(baseUrl, ctxData, { documentLoader: "identifier" in identity || "username" in identity
|
|
2740
|
+
if (identity != null) context$1 = this.#createContext(baseUrl, ctxData, { documentLoader: "identifier" in identity || "username" in identity ? await context$1.getDocumentLoader(identity) : context$1.getDocumentLoader(identity) });
|
|
2734
2741
|
}
|
|
2735
2742
|
const activity = await Activity.fromJsonLd(message.activity, context$1);
|
|
2736
2743
|
span.setAttribute("activitypub.activity.type", getTypeId(activity).href);
|
|
@@ -3039,54 +3046,60 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3039
3046
|
[ATTR_URL_FULL]: request.url
|
|
3040
3047
|
}
|
|
3041
3048
|
}, async (span) => {
|
|
3042
|
-
const
|
|
3043
|
-
|
|
3044
|
-
|
|
3045
|
-
|
|
3046
|
-
|
|
3047
|
-
|
|
3048
|
-
|
|
3049
|
-
|
|
3050
|
-
|
|
3051
|
-
|
|
3052
|
-
|
|
3053
|
-
|
|
3054
|
-
|
|
3055
|
-
|
|
3056
|
-
|
|
3057
|
-
|
|
3058
|
-
|
|
3059
|
-
|
|
3060
|
-
|
|
3049
|
+
const spanCtx = span.spanContext();
|
|
3050
|
+
return await withContext({
|
|
3051
|
+
traceId: spanCtx.traceId,
|
|
3052
|
+
spanId: spanCtx.spanId
|
|
3053
|
+
}, async () => {
|
|
3054
|
+
const logger$1 = getLogger([
|
|
3055
|
+
"fedify",
|
|
3056
|
+
"federation",
|
|
3057
|
+
"http"
|
|
3058
|
+
]);
|
|
3059
|
+
if (span.isRecording()) for (const [k, v] of request.headers) span.setAttribute(ATTR_HTTP_REQUEST_HEADER(k), [v]);
|
|
3060
|
+
let response;
|
|
3061
|
+
try {
|
|
3062
|
+
response = await this.#fetch(request, {
|
|
3063
|
+
...options,
|
|
3064
|
+
span,
|
|
3065
|
+
tracer
|
|
3066
|
+
});
|
|
3067
|
+
if (acceptsJsonLd(request)) response.headers.set("Vary", "Accept");
|
|
3068
|
+
} catch (error) {
|
|
3069
|
+
span.setStatus({
|
|
3070
|
+
code: SpanStatusCode.ERROR,
|
|
3071
|
+
message: `${error}`
|
|
3072
|
+
});
|
|
3073
|
+
span.end();
|
|
3074
|
+
logger$1.error("An error occurred while serving request {method} {url}: {error}", {
|
|
3075
|
+
method: request.method,
|
|
3076
|
+
url: request.url,
|
|
3077
|
+
error
|
|
3078
|
+
});
|
|
3079
|
+
throw error;
|
|
3080
|
+
}
|
|
3081
|
+
if (span.isRecording()) {
|
|
3082
|
+
span.setAttribute(ATTR_HTTP_RESPONSE_STATUS_CODE, response.status);
|
|
3083
|
+
for (const [k, v] of response.headers) span.setAttribute(ATTR_HTTP_RESPONSE_HEADER(k), [v]);
|
|
3084
|
+
span.setStatus({
|
|
3085
|
+
code: response.status >= 500 ? SpanStatusCode.ERROR : SpanStatusCode.UNSET,
|
|
3086
|
+
message: response.statusText
|
|
3087
|
+
});
|
|
3088
|
+
}
|
|
3061
3089
|
span.end();
|
|
3062
|
-
|
|
3090
|
+
const url = new URL(request.url);
|
|
3091
|
+
const logTpl = "{method} {path}: {status}";
|
|
3092
|
+
const values = {
|
|
3063
3093
|
method: request.method,
|
|
3094
|
+
path: `${url.pathname}${url.search}`,
|
|
3064
3095
|
url: request.url,
|
|
3065
|
-
|
|
3066
|
-
}
|
|
3067
|
-
|
|
3068
|
-
|
|
3069
|
-
|
|
3070
|
-
|
|
3071
|
-
|
|
3072
|
-
span.setStatus({
|
|
3073
|
-
code: response.status >= 500 ? SpanStatusCode.ERROR : SpanStatusCode.UNSET,
|
|
3074
|
-
message: response.statusText
|
|
3075
|
-
});
|
|
3076
|
-
}
|
|
3077
|
-
span.end();
|
|
3078
|
-
const url = new URL(request.url);
|
|
3079
|
-
const logTpl = "{method} {path}: {status}";
|
|
3080
|
-
const values = {
|
|
3081
|
-
method: request.method,
|
|
3082
|
-
path: `${url.pathname}${url.search}`,
|
|
3083
|
-
url: request.url,
|
|
3084
|
-
status: response.status
|
|
3085
|
-
};
|
|
3086
|
-
if (response.status >= 500) logger$1.error(logTpl, values);
|
|
3087
|
-
else if (response.status >= 400) logger$1.warn(logTpl, values);
|
|
3088
|
-
else logger$1.info(logTpl, values);
|
|
3089
|
-
return response;
|
|
3096
|
+
status: response.status
|
|
3097
|
+
};
|
|
3098
|
+
if (response.status >= 500) logger$1.error(logTpl, values);
|
|
3099
|
+
else if (response.status >= 400) logger$1.warn(logTpl, values);
|
|
3100
|
+
else logger$1.info(logTpl, values);
|
|
3101
|
+
return response;
|
|
3102
|
+
});
|
|
3090
3103
|
});
|
|
3091
3104
|
});
|
|
3092
3105
|
}
|
|
@@ -3120,9 +3133,9 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3120
3133
|
if (request.method !== "POST" && !acceptsJsonLd(request)) return await onNotAcceptable(request);
|
|
3121
3134
|
switch (routeName) {
|
|
3122
3135
|
case "actor":
|
|
3123
|
-
context$1 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier
|
|
3136
|
+
context$1 = this.#createContext(request, contextData, { invokedFromActorDispatcher: { identifier: route.values.identifier } });
|
|
3124
3137
|
return await handleActor(request, {
|
|
3125
|
-
identifier: route.values.identifier
|
|
3138
|
+
identifier: route.values.identifier,
|
|
3126
3139
|
context: context$1,
|
|
3127
3140
|
actorDispatcher: this.actorCallbacks?.dispatcher,
|
|
3128
3141
|
authorizePredicate: this.actorCallbacks?.authorizePredicate,
|
|
@@ -3148,7 +3161,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3148
3161
|
}
|
|
3149
3162
|
case "outbox": return await handleCollection(request, {
|
|
3150
3163
|
name: "outbox",
|
|
3151
|
-
identifier: route.values.identifier
|
|
3164
|
+
identifier: route.values.identifier,
|
|
3152
3165
|
uriGetter: context$1.getOutboxUri.bind(context$1),
|
|
3153
3166
|
context: context$1,
|
|
3154
3167
|
collectionCallbacks: this.outboxCallbacks,
|
|
@@ -3159,7 +3172,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3159
3172
|
case "inbox":
|
|
3160
3173
|
if (request.method !== "POST") return await handleCollection(request, {
|
|
3161
3174
|
name: "inbox",
|
|
3162
|
-
identifier: route.values.identifier
|
|
3175
|
+
identifier: route.values.identifier,
|
|
3163
3176
|
uriGetter: context$1.getInboxUri.bind(context$1),
|
|
3164
3177
|
context: context$1,
|
|
3165
3178
|
collectionCallbacks: this.inboxCallbacks,
|
|
@@ -3167,15 +3180,15 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3167
3180
|
onUnauthorized,
|
|
3168
3181
|
onNotFound
|
|
3169
3182
|
});
|
|
3170
|
-
context$1 = this.#createContext(request, contextData, { documentLoader: await context$1.getDocumentLoader({ identifier: route.values.identifier
|
|
3183
|
+
context$1 = this.#createContext(request, contextData, { documentLoader: await context$1.getDocumentLoader({ identifier: route.values.identifier }) });
|
|
3171
3184
|
case "sharedInbox":
|
|
3172
3185
|
if (routeName !== "inbox" && this.sharedInboxKeyDispatcher != null) {
|
|
3173
3186
|
const identity = await this.sharedInboxKeyDispatcher(context$1);
|
|
3174
|
-
if (identity != null) context$1 = this.#createContext(request, contextData, { documentLoader: "identifier" in identity || "username" in identity
|
|
3187
|
+
if (identity != null) context$1 = this.#createContext(request, contextData, { documentLoader: "identifier" in identity || "username" in identity ? await context$1.getDocumentLoader(identity) : context$1.getDocumentLoader(identity) });
|
|
3175
3188
|
}
|
|
3176
3189
|
if (!this.manuallyStartQueue) this._startQueueInternal(contextData);
|
|
3177
3190
|
return await handleInbox(request, {
|
|
3178
|
-
recipient: route.values.identifier ??
|
|
3191
|
+
recipient: route.values.identifier ?? null,
|
|
3179
3192
|
context: context$1,
|
|
3180
3193
|
inboxContextFactory: context$1.toInboxContext.bind(context$1),
|
|
3181
3194
|
kv: this.kv,
|
|
@@ -3192,7 +3205,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3192
3205
|
});
|
|
3193
3206
|
case "following": return await handleCollection(request, {
|
|
3194
3207
|
name: "following",
|
|
3195
|
-
identifier: route.values.identifier
|
|
3208
|
+
identifier: route.values.identifier,
|
|
3196
3209
|
uriGetter: context$1.getFollowingUri.bind(context$1),
|
|
3197
3210
|
context: context$1,
|
|
3198
3211
|
collectionCallbacks: this.followingCallbacks,
|
|
@@ -3209,7 +3222,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3209
3222
|
}
|
|
3210
3223
|
return await handleCollection(request, {
|
|
3211
3224
|
name: "followers",
|
|
3212
|
-
identifier: route.values.identifier
|
|
3225
|
+
identifier: route.values.identifier,
|
|
3213
3226
|
uriGetter: baseUrl == null ? context$1.getFollowersUri.bind(context$1) : (identifier) => {
|
|
3214
3227
|
const uri = context$1.getFollowersUri(identifier);
|
|
3215
3228
|
uri.searchParams.set("base-url", baseUrl);
|
|
@@ -3226,7 +3239,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3226
3239
|
}
|
|
3227
3240
|
case "liked": return await handleCollection(request, {
|
|
3228
3241
|
name: "liked",
|
|
3229
|
-
identifier: route.values.identifier
|
|
3242
|
+
identifier: route.values.identifier,
|
|
3230
3243
|
uriGetter: context$1.getLikedUri.bind(context$1),
|
|
3231
3244
|
context: context$1,
|
|
3232
3245
|
collectionCallbacks: this.likedCallbacks,
|
|
@@ -3236,7 +3249,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3236
3249
|
});
|
|
3237
3250
|
case "featured": return await handleCollection(request, {
|
|
3238
3251
|
name: "featured",
|
|
3239
|
-
identifier: route.values.identifier
|
|
3252
|
+
identifier: route.values.identifier,
|
|
3240
3253
|
uriGetter: context$1.getFeaturedUri.bind(context$1),
|
|
3241
3254
|
context: context$1,
|
|
3242
3255
|
collectionCallbacks: this.featuredCallbacks,
|
|
@@ -3246,7 +3259,7 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3246
3259
|
});
|
|
3247
3260
|
case "featuredTags": return await handleCollection(request, {
|
|
3248
3261
|
name: "featured tags",
|
|
3249
|
-
identifier: route.values.identifier
|
|
3262
|
+
identifier: route.values.identifier,
|
|
3250
3263
|
uriGetter: context$1.getFeaturedTagsUri.bind(context$1),
|
|
3251
3264
|
context: context$1,
|
|
3252
3265
|
collectionCallbacks: this.featuredTagsCallbacks,
|
|
@@ -3344,10 +3357,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3344
3357
|
return new URL(path, this.canonicalOrigin);
|
|
3345
3358
|
}
|
|
3346
3359
|
getActorUri(identifier) {
|
|
3347
|
-
const path = this.federation.router.build("actor", {
|
|
3348
|
-
identifier,
|
|
3349
|
-
handle: identifier
|
|
3350
|
-
});
|
|
3360
|
+
const path = this.federation.router.build("actor", { identifier });
|
|
3351
3361
|
if (path == null) throw new RouterError("No actor dispatcher registered.");
|
|
3352
3362
|
return new URL(path, this.canonicalOrigin);
|
|
3353
3363
|
}
|
|
@@ -3360,10 +3370,7 @@ var ContextImpl = class ContextImpl {
|
|
|
3360
3370
|
return new URL(path, this.canonicalOrigin);
|
|
3361
3371
|
}
|
|
3362
3372
|
getOutboxUri(identifier) {
|
|
3363
|
-
const path = this.federation.router.build("outbox", {
|
|
3364
|
-
identifier,
|
|
3365
|
-
handle: identifier
|
|
3366
|
-
});
|
|
3373
|
+
const path = this.federation.router.build("outbox", { identifier });
|
|
3367
3374
|
if (path == null) throw new RouterError("No outbox dispatcher registered.");
|
|
3368
3375
|
return new URL(path, this.canonicalOrigin);
|
|
3369
3376
|
}
|
|
@@ -3373,50 +3380,32 @@ var ContextImpl = class ContextImpl {
|
|
|
3373
3380
|
if (path$1 == null) throw new RouterError("No shared inbox path registered.");
|
|
3374
3381
|
return new URL(path$1, this.canonicalOrigin);
|
|
3375
3382
|
}
|
|
3376
|
-
const path = this.federation.router.build("inbox", {
|
|
3377
|
-
identifier,
|
|
3378
|
-
handle: identifier
|
|
3379
|
-
});
|
|
3383
|
+
const path = this.federation.router.build("inbox", { identifier });
|
|
3380
3384
|
if (path == null) throw new RouterError("No inbox path registered.");
|
|
3381
3385
|
return new URL(path, this.canonicalOrigin);
|
|
3382
3386
|
}
|
|
3383
3387
|
getFollowingUri(identifier) {
|
|
3384
|
-
const path = this.federation.router.build("following", {
|
|
3385
|
-
identifier,
|
|
3386
|
-
handle: identifier
|
|
3387
|
-
});
|
|
3388
|
+
const path = this.federation.router.build("following", { identifier });
|
|
3388
3389
|
if (path == null) throw new RouterError("No following collection path registered.");
|
|
3389
3390
|
return new URL(path, this.canonicalOrigin);
|
|
3390
3391
|
}
|
|
3391
3392
|
getFollowersUri(identifier) {
|
|
3392
|
-
const path = this.federation.router.build("followers", {
|
|
3393
|
-
identifier,
|
|
3394
|
-
handle: identifier
|
|
3395
|
-
});
|
|
3393
|
+
const path = this.federation.router.build("followers", { identifier });
|
|
3396
3394
|
if (path == null) throw new RouterError("No followers collection path registered.");
|
|
3397
3395
|
return new URL(path, this.canonicalOrigin);
|
|
3398
3396
|
}
|
|
3399
3397
|
getLikedUri(identifier) {
|
|
3400
|
-
const path = this.federation.router.build("liked", {
|
|
3401
|
-
identifier,
|
|
3402
|
-
handle: identifier
|
|
3403
|
-
});
|
|
3398
|
+
const path = this.federation.router.build("liked", { identifier });
|
|
3404
3399
|
if (path == null) throw new RouterError("No liked collection path registered.");
|
|
3405
3400
|
return new URL(path, this.canonicalOrigin);
|
|
3406
3401
|
}
|
|
3407
3402
|
getFeaturedUri(identifier) {
|
|
3408
|
-
const path = this.federation.router.build("featured", {
|
|
3409
|
-
identifier,
|
|
3410
|
-
handle: identifier
|
|
3411
|
-
});
|
|
3403
|
+
const path = this.federation.router.build("featured", { identifier });
|
|
3412
3404
|
if (path == null) throw new RouterError("No featured collection path registered.");
|
|
3413
3405
|
return new URL(path, this.canonicalOrigin);
|
|
3414
3406
|
}
|
|
3415
3407
|
getFeaturedTagsUri(identifier) {
|
|
3416
|
-
const path = this.federation.router.build("featuredTags", {
|
|
3417
|
-
identifier,
|
|
3418
|
-
handle: identifier
|
|
3419
|
-
});
|
|
3408
|
+
const path = this.federation.router.build("featuredTags", { identifier });
|
|
3420
3409
|
if (path == null) throw new RouterError("No featured tags collection path registered.");
|
|
3421
3410
|
return new URL(path, this.canonicalOrigin);
|
|
3422
3411
|
}
|
|
@@ -3429,24 +3418,15 @@ var ContextImpl = class ContextImpl {
|
|
|
3429
3418
|
if (uri == null) return null;
|
|
3430
3419
|
if (uri.origin !== this.origin && uri.origin !== this.canonicalOrigin) return null;
|
|
3431
3420
|
const route = this.federation.router.route(uri.pathname);
|
|
3432
|
-
const logger$1 = getLogger(["fedify", "federation"]);
|
|
3433
3421
|
if (route == null) return null;
|
|
3434
3422
|
else if (route.name === "sharedInbox") return {
|
|
3435
3423
|
type: "inbox",
|
|
3436
|
-
identifier: void 0
|
|
3437
|
-
get handle() {
|
|
3438
|
-
logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
3439
|
-
return void 0;
|
|
3440
|
-
}
|
|
3424
|
+
identifier: void 0
|
|
3441
3425
|
};
|
|
3442
|
-
const identifier =
|
|
3426
|
+
const identifier = route.values.identifier;
|
|
3443
3427
|
if (route.name === "actor") return {
|
|
3444
3428
|
type: "actor",
|
|
3445
|
-
identifier
|
|
3446
|
-
get handle() {
|
|
3447
|
-
logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
3448
|
-
return identifier;
|
|
3449
|
-
}
|
|
3429
|
+
identifier
|
|
3450
3430
|
};
|
|
3451
3431
|
else if (route.name.startsWith("object:")) {
|
|
3452
3432
|
const typeId = route.name.replace(/^object:/, "");
|
|
@@ -3458,59 +3438,31 @@ var ContextImpl = class ContextImpl {
|
|
|
3458
3438
|
};
|
|
3459
3439
|
} else if (route.name === "inbox") return {
|
|
3460
3440
|
type: "inbox",
|
|
3461
|
-
identifier
|
|
3462
|
-
get handle() {
|
|
3463
|
-
logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
3464
|
-
return identifier;
|
|
3465
|
-
}
|
|
3441
|
+
identifier
|
|
3466
3442
|
};
|
|
3467
3443
|
else if (route.name === "outbox") return {
|
|
3468
3444
|
type: "outbox",
|
|
3469
|
-
identifier
|
|
3470
|
-
get handle() {
|
|
3471
|
-
logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
3472
|
-
return identifier;
|
|
3473
|
-
}
|
|
3445
|
+
identifier
|
|
3474
3446
|
};
|
|
3475
3447
|
else if (route.name === "following") return {
|
|
3476
3448
|
type: "following",
|
|
3477
|
-
identifier
|
|
3478
|
-
get handle() {
|
|
3479
|
-
logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
3480
|
-
return identifier;
|
|
3481
|
-
}
|
|
3449
|
+
identifier
|
|
3482
3450
|
};
|
|
3483
3451
|
else if (route.name === "followers") return {
|
|
3484
3452
|
type: "followers",
|
|
3485
|
-
identifier
|
|
3486
|
-
get handle() {
|
|
3487
|
-
logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
3488
|
-
return identifier;
|
|
3489
|
-
}
|
|
3453
|
+
identifier
|
|
3490
3454
|
};
|
|
3491
3455
|
else if (route.name === "liked") return {
|
|
3492
3456
|
type: "liked",
|
|
3493
|
-
identifier
|
|
3494
|
-
get handle() {
|
|
3495
|
-
logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
3496
|
-
return identifier;
|
|
3497
|
-
}
|
|
3457
|
+
identifier
|
|
3498
3458
|
};
|
|
3499
3459
|
else if (route.name === "featured") return {
|
|
3500
3460
|
type: "featured",
|
|
3501
|
-
identifier
|
|
3502
|
-
get handle() {
|
|
3503
|
-
logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
3504
|
-
return identifier;
|
|
3505
|
-
}
|
|
3461
|
+
identifier
|
|
3506
3462
|
};
|
|
3507
3463
|
else if (route.name === "featuredTags") return {
|
|
3508
3464
|
type: "featuredTags",
|
|
3509
|
-
identifier
|
|
3510
|
-
get handle() {
|
|
3511
|
-
logger$1.warn("The ParseUriResult.handle property is deprecated; use ParseUriResult.identifier instead.");
|
|
3512
|
-
return identifier;
|
|
3513
|
-
}
|
|
3465
|
+
identifier
|
|
3514
3466
|
};
|
|
3515
3467
|
const collectionTypes = ["collection", "orderedCollection"];
|
|
3516
3468
|
const collectionRegex = /* @__PURE__ */ new RegExp(`^(${collectionTypes.join("|")}):(.*)$`);
|
|
@@ -3612,19 +3564,10 @@ var ContextImpl = class ContextImpl {
|
|
|
3612
3564
|
return null;
|
|
3613
3565
|
}
|
|
3614
3566
|
getDocumentLoader(identity) {
|
|
3615
|
-
if ("identifier" in identity || "username" in identity
|
|
3567
|
+
if ("identifier" in identity || "username" in identity) {
|
|
3616
3568
|
let identifierPromise;
|
|
3617
|
-
if ("username" in identity
|
|
3618
|
-
|
|
3619
|
-
if ("username" in identity) username = identity.username;
|
|
3620
|
-
else {
|
|
3621
|
-
username = identity.handle;
|
|
3622
|
-
getLogger([
|
|
3623
|
-
"fedify",
|
|
3624
|
-
"runtime",
|
|
3625
|
-
"docloader"
|
|
3626
|
-
]).warn("The \"handle\" property is deprecated; use \"identifier\" or \"username\" instead.", { identity });
|
|
3627
|
-
}
|
|
3569
|
+
if ("username" in identity) {
|
|
3570
|
+
const username = identity.username;
|
|
3628
3571
|
const mapper = this.federation.actorCallbacks?.handleMapper;
|
|
3629
3572
|
if (mapper == null) identifierPromise = Promise.resolve(username);
|
|
3630
3573
|
else {
|
|
@@ -3710,15 +3653,10 @@ var ContextImpl = class ContextImpl {
|
|
|
3710
3653
|
]);
|
|
3711
3654
|
let keys;
|
|
3712
3655
|
let identifier = null;
|
|
3713
|
-
if ("identifier" in sender || "username" in sender
|
|
3656
|
+
if ("identifier" in sender || "username" in sender) {
|
|
3714
3657
|
if ("identifier" in sender) identifier = sender.identifier;
|
|
3715
3658
|
else {
|
|
3716
|
-
|
|
3717
|
-
if ("username" in sender) username = sender.username;
|
|
3718
|
-
else {
|
|
3719
|
-
username = sender.handle;
|
|
3720
|
-
logger$1.warn("The \"handle\" property for the sender parameter is deprecated; use \"identifier\" or \"username\" instead.", { sender });
|
|
3721
|
-
}
|
|
3659
|
+
const username = sender.username;
|
|
3722
3660
|
if (this.federation.actorCallbacks?.handleMapper == null) identifier = username;
|
|
3723
3661
|
else {
|
|
3724
3662
|
const mapped = await this.federation.actorCallbacks.handleMapper(this, username);
|
|
@@ -4074,15 +4012,10 @@ var InboxContextImpl = class InboxContextImpl extends ContextImpl {
|
|
|
4074
4012
|
]);
|
|
4075
4013
|
let keys;
|
|
4076
4014
|
let identifier = null;
|
|
4077
|
-
if ("identifier" in forwarder || "username" in forwarder
|
|
4015
|
+
if ("identifier" in forwarder || "username" in forwarder) {
|
|
4078
4016
|
if ("identifier" in forwarder) identifier = forwarder.identifier;
|
|
4079
4017
|
else {
|
|
4080
|
-
|
|
4081
|
-
if ("username" in forwarder) username = forwarder.username;
|
|
4082
|
-
else {
|
|
4083
|
-
username = forwarder.handle;
|
|
4084
|
-
logger$1.warn("The \"handle\" property for the forwarder parameter is deprecated; use \"identifier\" or \"username\" instead.", { forwarder });
|
|
4085
|
-
}
|
|
4018
|
+
const username = forwarder.username;
|
|
4086
4019
|
if (this.federation.actorCallbacks?.handleMapper == null) identifier = username;
|
|
4087
4020
|
else {
|
|
4088
4021
|
const mapped = await this.federation.actorCallbacks.handleMapper(this, username);
|