@fedify/fedify 1.9.0-dev.1613 → 1.9.0-dev.1689
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/{actor-Ch5yFYFG.d.ts → actor-C1Euqngb.d.ts} +1 -1
- package/dist/{actor-BkOvltE1.cjs → actor-CK94m0Yv.cjs} +7263 -2440
- package/dist/{actor-BrhPUG_N.js → actor-Dpkqj5Dv.js} +7263 -2440
- package/dist/{actor-Do9KG1O2.js → actor-DzdLVqkJ.js} +1 -1
- package/dist/{actor-CHOM_AN3.d.cts → actor-Ydzhc8dj.d.cts} +1 -1
- package/dist/{authdocloader-lcfCE1vG.cjs → authdocloader-4iBGWlQw.cjs} +3 -3
- package/dist/{authdocloader-CF0X5NR7.js → authdocloader-BVvTFQbi.js} +3 -3
- package/dist/{authdocloader-D_pDyzSu.js → authdocloader-DdSBpn11.js} +3 -3
- package/dist/{builder-CwFGbC7w.js → builder-BR--hcb8.js} +10 -4
- package/dist/{client-CkjMau5E.js → client-BoUqciR8.js} +1 -1
- package/dist/compat/mod.d.cts +7 -7
- package/dist/compat/mod.d.ts +7 -7
- package/dist/compat/transformers.test.js +16 -16
- package/dist/{context-DFruNLny.d.ts → context-CZorAkt8.d.ts} +66 -6
- package/dist/{context-KXVF2AhH.d.cts → context-DCh96LcF.d.cts} +66 -6
- package/dist/{docloader-CCo7N8E2.cjs → docloader-Bui9z8Lb.cjs} +1 -1
- package/dist/{docloader-CB-b64F8.js → docloader-DyvW1gbN.js} +1 -1
- package/dist/{esm-BeBLf_np.js → esm-DMb2eQXG.js} +1 -1
- package/dist/federation/builder.test.js +5 -5
- package/dist/federation/collection.test.js +3 -3
- package/dist/federation/handler.test.js +17 -17
- package/dist/federation/idempotency.test.d.ts +3 -0
- package/dist/federation/idempotency.test.js +202 -0
- package/dist/federation/inbox.test.js +4 -4
- package/dist/federation/keycache.test.js +4 -4
- package/dist/federation/kv.test.js +4 -3
- package/dist/federation/middleware.test.js +18 -18
- package/dist/federation/mod.cjs +10 -10
- package/dist/federation/mod.d.cts +7 -7
- package/dist/federation/mod.d.ts +7 -7
- package/dist/federation/mod.js +10 -10
- package/dist/federation/mq.test.js +3 -3
- package/dist/federation/retry.test.js +3 -3
- package/dist/federation/router.test.js +3 -3
- package/dist/federation/send.test.js +10 -10
- package/dist/fixtures/media.example.com/avatars/test-avatar.jpg.json +6 -0
- package/dist/{http-B_zBcsai.d.cts → http-B1_DzfAU.d.cts} +1 -1
- package/dist/{http-DpcYXIiB.cjs → http-BAaVL480.cjs} +3 -3
- package/dist/{http-zgzZkO8A.js → http-C7nvEG1N.js} +2 -2
- package/dist/{http-D8Q4xH0d.d.ts → http-wsGR6KkT.d.ts} +1 -1
- package/dist/{http-CmDy8xoP.js → http-xsj5Fzwl.js} +3 -3
- package/dist/{inbox-CirfyLns.js → inbox-DZNE3Jtq.js} +29 -7
- package/dist/{key-CN1jS3_Y.js → key-C25gGlmV.js} +2 -2
- package/dist/key-CHU24Npw.cjs +10 -0
- package/dist/{key-Dq2ZV4ZW.js → key-CbnQpdZy.js} +2 -2
- package/dist/{key-BytDOwJJ.js → key-DOPWTj2e.js} +4 -4
- package/dist/{key-DgFXwwZv.js → key-DgZIZVqA.js} +3 -3
- package/dist/{key-4EZXrjJw.cjs → key-DqqCoLbc.cjs} +2 -2
- package/dist/{keycache-COrk8-eB.js → keycache-CoMI1L_W.js} +1 -1
- package/dist/{keys-BieqxHLC.js → keys-CMahfArj.js} +1 -1
- package/dist/{ld-o8aGatC0.js → ld-WZpO-MzE.js} +2 -2
- package/dist/{lookup-CwHCSBI8.cjs → lookup-D_w567L8.cjs} +1 -1
- package/dist/{lookup-DADsKd8V.js → lookup-WoJkw8wY.js} +1 -1
- package/dist/{lookup-BkaLctZw.js → lookup-y6-PEpxS.js} +21 -12
- package/dist/middleware-BYEKw_OJ.js +17 -0
- package/dist/{middleware-BcqldfgB.cjs → middleware-CWlrInU2.cjs} +66 -34
- package/dist/{middleware-CuCsnDA9.js → middleware-Cj9WC_iX.js} +66 -34
- package/dist/{middleware-B1iLu-jg.js → middleware-CjgR6ayA.js} +35 -31
- package/dist/middleware-DbxA0Z6o.js +26 -0
- package/dist/middleware-hTlyJu9R.cjs +17 -0
- package/dist/{mod-NKH_G-IY.d.cts → mod-BUbqxBev.d.cts} +19 -1
- package/dist/{mod-YfAcrVbP.d.cts → mod-BojaEE1l.d.cts} +2 -2
- package/dist/{mod-Cy6pkZSn.d.ts → mod-CDObsV1d.d.ts} +19 -1
- package/dist/{mod-BAuhKa9d.d.ts → mod-CIbqfZW0.d.ts} +1 -1
- package/dist/{mod-B7Pc0I7F.d.ts → mod-DgcYoyZK.d.ts} +2 -2
- package/dist/{mod-C3CGxYoF.d.cts → mod-Dt-G9ZOS.d.cts} +1 -1
- package/dist/{mod-COw_caPC.d.cts → mod-fjqfsrty.d.cts} +2 -2
- package/dist/{mod-CiXjux2r.d.ts → mod-tWXEItkO.d.ts} +2 -2
- package/dist/mod.cjs +10 -10
- package/dist/mod.d.cts +10 -10
- package/dist/mod.d.ts +10 -10
- package/dist/mod.js +10 -10
- package/dist/nodeinfo/client.test.js +5 -5
- package/dist/nodeinfo/handler.test.js +16 -16
- package/dist/nodeinfo/mod.cjs +2 -2
- package/dist/nodeinfo/mod.js +2 -2
- package/dist/nodeinfo/semver.test.js +3 -3
- package/dist/nodeinfo/types.test.js +3 -3
- package/dist/{owner-C9Ry0TOI.d.cts → owner-6KSEp9eV.d.cts} +2 -2
- package/dist/{owner-D38zBIMc.d.ts → owner-BbeUDvOu.d.ts} +2 -2
- package/dist/{owner-qeK3HiL9.js → owner-CPBOVM7l.js} +2 -2
- package/dist/{proof-DasSZLsd.cjs → proof-BLoRsaYR.cjs} +3 -3
- package/dist/{proof-BSqN3lwx.js → proof-CpmDDzvf.js} +3 -3
- package/dist/{proof-0MIJ70kC.js → proof-h0JvKPRP.js} +2 -2
- package/dist/runtime/authdocloader.test.js +9 -9
- package/dist/runtime/docloader.test.js +4 -4
- package/dist/runtime/key.test.js +5 -5
- package/dist/runtime/langstr.test.js +3 -3
- package/dist/runtime/link.test.js +3 -3
- package/dist/runtime/mod.cjs +6 -6
- package/dist/runtime/mod.d.cts +3 -3
- package/dist/runtime/mod.d.ts +3 -3
- package/dist/runtime/mod.js +6 -6
- package/dist/runtime/multibase/multibase.test.js +3 -3
- package/dist/runtime/url.test.js +3 -3
- package/dist/{send-CuL-kYv7.js → send-CD-m2vwX.js} +2 -2
- package/dist/sig/http.test.js +8 -8
- package/dist/sig/key.test.js +6 -6
- package/dist/sig/ld.test.js +7 -7
- package/dist/sig/mod.cjs +6 -6
- package/dist/sig/mod.d.cts +5 -5
- package/dist/sig/mod.d.ts +5 -5
- package/dist/sig/mod.js +6 -6
- package/dist/sig/owner.test.js +7 -7
- package/dist/sig/proof.test.js +7 -7
- package/dist/testing/docloader.test.js +3 -3
- package/dist/testing/mod.d.ts +272 -0
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-Did3bCyV.js → testing-DvTABhvG.js} +2 -2
- package/dist/{type-Bm9mdHQS.js → type-BCazg_Pu.js} +6943 -2120
- package/dist/{types-B9ZmKzEm.js → types-BsM0mf3R.js} +1 -1
- package/dist/{types-DF88bXyE.cjs → types-F8JMlP-f.cjs} +1 -1
- package/dist/vocab/actor.test.js +5 -5
- package/dist/vocab/lookup.test.js +255 -5
- package/dist/vocab/mod.cjs +4 -4
- package/dist/vocab/mod.d.cts +3 -3
- package/dist/vocab/mod.d.ts +3 -3
- package/dist/vocab/mod.js +4 -4
- package/dist/vocab/type.test.js +3 -3
- package/dist/vocab/vocab.test.js +433 -9
- package/dist/{vocab-DFyEBhSA.cjs → vocab-C-qxDq1m.cjs} +23 -14
- package/dist/{vocab-BEEm2I6u.d.ts → vocab-CDHNj5zp.d.ts} +290 -0
- package/dist/{vocab-BzGg7ltX.d.cts → vocab-Cfs0937i.d.cts} +290 -0
- package/dist/{vocab-BVOFD7iz.js → vocab-DdTdRfBW.js} +23 -14
- package/dist/webfinger/handler.test.js +16 -16
- package/dist/webfinger/lookup.test.js +4 -4
- package/dist/webfinger/mod.cjs +2 -2
- package/dist/webfinger/mod.js +2 -2
- package/dist/x/cfworkers.test.js +3 -3
- package/dist/x/hono.d.cts +6 -6
- package/dist/x/hono.d.ts +6 -6
- package/dist/x/sveltekit.d.cts +6 -6
- package/dist/x/sveltekit.d.ts +6 -6
- package/package.json +1 -1
- package/dist/key-BSapRu6X.cjs +0 -10
- package/dist/middleware-3K0jP9Du.js +0 -26
- package/dist/middleware-CZyWbiwd.js +0 -17
- package/dist/middleware-T8MY-txY.cjs +0 -17
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { Activity, deno_default, getTypeId } from "./type-
|
|
6
|
+
import { Activity, deno_default, getTypeId } from "./type-BCazg_Pu.js";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
9
9
|
|
|
@@ -41,17 +41,39 @@ var InboxListenerSet = class InboxListenerSet {
|
|
|
41
41
|
return this.dispatchWithClass(activity)?.listener ?? null;
|
|
42
42
|
}
|
|
43
43
|
};
|
|
44
|
-
|
|
44
|
+
let warnedAboutDefaultIdempotency = false;
|
|
45
|
+
async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
|
|
45
46
|
const logger = getLogger([
|
|
46
47
|
"fedify",
|
|
47
48
|
"federation",
|
|
48
49
|
"inbox"
|
|
49
50
|
]);
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
51
|
+
let cacheKey = null;
|
|
52
|
+
if (activity.id != null) {
|
|
53
|
+
const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, getTypeId(activity).href);
|
|
54
|
+
const strategy = idempotencyStrategy ?? "per-origin";
|
|
55
|
+
if (idempotencyStrategy === void 0 && !warnedAboutDefaultIdempotency) {
|
|
56
|
+
logger.warn("Using default idempotency strategy 'per-origin'. This default will change to 'per-inbox' in Fedify 2.0. Please explicitly set the idempotency strategy using .withIdempotency().");
|
|
57
|
+
warnedAboutDefaultIdempotency = true;
|
|
58
|
+
}
|
|
59
|
+
let keyString;
|
|
60
|
+
if (typeof strategy === "function") {
|
|
61
|
+
const result = await strategy(inboxContext, activity);
|
|
62
|
+
keyString = result;
|
|
63
|
+
} else switch (strategy) {
|
|
64
|
+
case "global":
|
|
65
|
+
keyString = activity.id.href;
|
|
66
|
+
break;
|
|
67
|
+
case "per-origin":
|
|
68
|
+
keyString = `${ctx.origin}\n${activity.id.href}`;
|
|
69
|
+
break;
|
|
70
|
+
case "per-inbox":
|
|
71
|
+
keyString = `${ctx.origin}\n${activity.id.href}\n${recipient == null ? "sharedInbox" : `inbox\n${recipient}`}`;
|
|
72
|
+
break;
|
|
73
|
+
default: keyString = `${ctx.origin}\n${activity.id.href}`;
|
|
74
|
+
}
|
|
75
|
+
if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
|
|
76
|
+
}
|
|
55
77
|
if (cacheKey != null) {
|
|
56
78
|
const cached = await kv.get(cacheKey);
|
|
57
79
|
if (cached === true) {
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { CryptographicKey, Object as Object$1, deno_default, getDocumentLoader } from "./type-
|
|
7
|
-
import { isActor } from "./actor-
|
|
6
|
+
import { CryptographicKey, Object as Object$1, deno_default, getDocumentLoader } from "./type-BCazg_Pu.js";
|
|
7
|
+
import { isActor } from "./actor-DzdLVqkJ.js";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
9
9
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
10
|
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
|
4
|
+
|
|
5
|
+
require('./docloader-Bui9z8Lb.cjs');
|
|
6
|
+
require('./actor-CK94m0Yv.cjs');
|
|
7
|
+
require('./lookup-D_w567L8.cjs');
|
|
8
|
+
const require_key = require('./key-DqqCoLbc.cjs');
|
|
9
|
+
|
|
10
|
+
exports.validateCryptoKey = require_key.validateCryptoKey;
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import { deno_default, getDocumentLoader } from "./docloader-
|
|
6
|
-
import { CryptographicKey, Object as Object$1, isActor } from "./actor-
|
|
5
|
+
import { deno_default, getDocumentLoader } from "./docloader-DyvW1gbN.js";
|
|
6
|
+
import { CryptographicKey, Object as Object$1, isActor } from "./actor-Dpkqj5Dv.js";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import "./docloader-
|
|
6
|
-
import "./actor-
|
|
7
|
-
import "./lookup-
|
|
8
|
-
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-
|
|
5
|
+
import "./docloader-DyvW1gbN.js";
|
|
6
|
+
import "./actor-Dpkqj5Dv.js";
|
|
7
|
+
import "./lookup-WoJkw8wY.js";
|
|
8
|
+
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-CbnQpdZy.js";
|
|
9
9
|
|
|
10
10
|
export { validateCryptoKey };
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import "./type-
|
|
7
|
-
import "./actor-
|
|
8
|
-
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-
|
|
6
|
+
import "./type-BCazg_Pu.js";
|
|
7
|
+
import "./actor-DzdLVqkJ.js";
|
|
8
|
+
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-C25gGlmV.js";
|
|
9
9
|
|
|
10
10
|
export { validateCryptoKey };
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
4
4
|
|
|
5
5
|
const require_chunk = require('./chunk-DqRYRqnO.cjs');
|
|
6
|
-
const require_docloader = require('./docloader-
|
|
7
|
-
const require_actor = require('./actor-
|
|
6
|
+
const require_docloader = require('./docloader-Bui9z8Lb.cjs');
|
|
7
|
+
const require_actor = require('./actor-CK94m0Yv.cjs');
|
|
8
8
|
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
|
9
9
|
const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
|
|
10
10
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { CryptographicKey, Multikey } from "./type-
|
|
6
|
+
import { CryptographicKey, Multikey } from "./type-BCazg_Pu.js";
|
|
7
7
|
|
|
8
8
|
//#region src/federation/keycache.ts
|
|
9
9
|
var KvKeyCache = class {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { CryptographicKey, Multikey, importSpki } from "./type-
|
|
6
|
+
import { CryptographicKey, Multikey, importSpki } from "./type-BCazg_Pu.js";
|
|
7
7
|
|
|
8
8
|
//#region src/testing/keys.ts
|
|
9
9
|
const rsaPublicKey1 = new CryptographicKey({
|
|
@@ -3,8 +3,8 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { Activity, CryptographicKey, Object as Object$1, deno_default, getDocumentLoader, getTypeId } from "./type-
|
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-
|
|
6
|
+
import { Activity, CryptographicKey, Object as Object$1, deno_default, getDocumentLoader, getTypeId } from "./type-BCazg_Pu.js";
|
|
7
|
+
import { fetchKey, validateCryptoKey } from "./key-C25gGlmV.js";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
10
|
import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
4
4
|
|
|
5
5
|
const require_chunk = require('./chunk-DqRYRqnO.cjs');
|
|
6
|
-
const require_docloader = require('./docloader-
|
|
6
|
+
const require_docloader = require('./docloader-Bui9z8Lb.cjs');
|
|
7
7
|
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
|
8
8
|
const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
|
|
9
9
|
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { Temporal } from "@js-temporal/polyfill";
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
|
|
5
|
-
import { UrlError, deno_default, getUserAgent, validatePublicUrl } from "./docloader-
|
|
5
|
+
import { UrlError, deno_default, getUserAgent, validatePublicUrl } from "./docloader-DyvW1gbN.js";
|
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
|
7
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { Object as Object$1, deno_default, getDocumentLoader, getTypeId, lookupWebFinger } from "./type-
|
|
6
|
+
import { Object as Object$1, deno_default, getDocumentLoader, getTypeId, lookupWebFinger } from "./type-BCazg_Pu.js";
|
|
7
7
|
import { cloneDeep, delay } from "es-toolkit";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
@@ -240,14 +240,13 @@ async function lookupObject(identifier, options = {}) {
|
|
|
240
240
|
async function lookupObjectInternal(identifier, options = {}) {
|
|
241
241
|
const documentLoader = options.documentLoader ?? getDocumentLoader({ userAgent: options.userAgent });
|
|
242
242
|
if (typeof identifier === "string") identifier = toAcctUrl(identifier) ?? new URL(identifier);
|
|
243
|
-
let
|
|
243
|
+
let remoteDoc = null;
|
|
244
244
|
if (identifier.protocol === "http:" || identifier.protocol === "https:") try {
|
|
245
|
-
|
|
246
|
-
document = remoteDoc.document;
|
|
245
|
+
remoteDoc = await documentLoader(identifier.href, { signal: options.signal });
|
|
247
246
|
} catch (error) {
|
|
248
247
|
logger.debug("Failed to fetch remote document:\n{error}", { error });
|
|
249
248
|
}
|
|
250
|
-
if (
|
|
249
|
+
if (remoteDoc == null) {
|
|
251
250
|
const jrd = await lookupWebFinger(identifier, {
|
|
252
251
|
userAgent: options.userAgent,
|
|
253
252
|
tracerProvider: options.tracerProvider,
|
|
@@ -258,8 +257,7 @@ async function lookupObjectInternal(identifier, options = {}) {
|
|
|
258
257
|
for (const l of jrd.links) {
|
|
259
258
|
if (l.type !== "application/activity+json" && !l.type?.match(/application\/ld\+json;\s*profile="https:\/\/www.w3.org\/ns\/activitystreams"/) || l.rel !== "self" || l.href == null) continue;
|
|
260
259
|
try {
|
|
261
|
-
|
|
262
|
-
document = remoteDoc.document;
|
|
260
|
+
remoteDoc = await documentLoader(l.href, { signal: options.signal });
|
|
263
261
|
break;
|
|
264
262
|
} catch (error) {
|
|
265
263
|
logger.debug("Failed to fetch remote document:\n{error}", { error });
|
|
@@ -267,23 +265,34 @@ async function lookupObjectInternal(identifier, options = {}) {
|
|
|
267
265
|
}
|
|
268
266
|
}
|
|
269
267
|
}
|
|
270
|
-
if (
|
|
268
|
+
if (remoteDoc == null) return null;
|
|
269
|
+
let object;
|
|
271
270
|
try {
|
|
272
|
-
|
|
271
|
+
object = await Object$1.fromJsonLd(remoteDoc.document, {
|
|
273
272
|
documentLoader,
|
|
274
273
|
contextLoader: options.contextLoader,
|
|
275
|
-
tracerProvider: options.tracerProvider
|
|
274
|
+
tracerProvider: options.tracerProvider,
|
|
275
|
+
baseUrl: new URL(remoteDoc.documentUrl)
|
|
276
276
|
});
|
|
277
277
|
} catch (error) {
|
|
278
278
|
if (error instanceof TypeError) {
|
|
279
279
|
logger.debug("Failed to parse JSON-LD document: {error}\n{document}", {
|
|
280
|
-
|
|
281
|
-
|
|
280
|
+
...remoteDoc,
|
|
281
|
+
error
|
|
282
282
|
});
|
|
283
283
|
return null;
|
|
284
284
|
}
|
|
285
285
|
throw error;
|
|
286
286
|
}
|
|
287
|
+
if (options.crossOrigin !== "trust" && object.id != null && object.id.origin !== new URL(remoteDoc.documentUrl).origin) {
|
|
288
|
+
if (options.crossOrigin === "throw") throw new Error(`The object's @id (${object.id.href}) has a different origin than the document URL (${remoteDoc.documentUrl}); refusing to return the object. If you want to bypass this check and are aware of the security implications, set the crossOrigin option to "trust".`);
|
|
289
|
+
logger.warn("The object's @id ({objectId}) has a different origin than the document URL ({documentUrl}); refusing to return the object. If you want to bypass this check and are aware of the security implications, set the crossOrigin option to \"trust\".", {
|
|
290
|
+
...remoteDoc,
|
|
291
|
+
objectId: object.id.href
|
|
292
|
+
});
|
|
293
|
+
return null;
|
|
294
|
+
}
|
|
295
|
+
return object;
|
|
287
296
|
}
|
|
288
297
|
/**
|
|
289
298
|
* Traverses a collection, yielding each item in the collection.
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
|
4
|
+
|
|
5
|
+
import "./transformers-BFT6d7J5.js";
|
|
6
|
+
import "./docloader-DyvW1gbN.js";
|
|
7
|
+
import "./actor-Dpkqj5Dv.js";
|
|
8
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-Cj9WC_iX.js";
|
|
9
|
+
import "./lookup-WoJkw8wY.js";
|
|
10
|
+
import "./key-CbnQpdZy.js";
|
|
11
|
+
import "./http-xsj5Fzwl.js";
|
|
12
|
+
import "./proof-CpmDDzvf.js";
|
|
13
|
+
import "./types-BsM0mf3R.js";
|
|
14
|
+
import "./authdocloader-BVvTFQbi.js";
|
|
15
|
+
import "./vocab-DdTdRfBW.js";
|
|
16
|
+
|
|
17
|
+
export { FederationImpl };
|
|
@@ -4,15 +4,15 @@
|
|
|
4
4
|
|
|
5
5
|
const require_chunk = require('./chunk-DqRYRqnO.cjs');
|
|
6
6
|
const require_transformers = require('./transformers-CoBS-oFG.cjs');
|
|
7
|
-
const require_docloader = require('./docloader-
|
|
8
|
-
const require_actor = require('./actor-
|
|
9
|
-
const require_lookup = require('./lookup-
|
|
10
|
-
const require_key = require('./key-
|
|
11
|
-
const require_http = require('./http-
|
|
12
|
-
const require_proof = require('./proof-
|
|
13
|
-
const require_types = require('./types-
|
|
14
|
-
const require_authdocloader = require('./authdocloader-
|
|
15
|
-
const require_vocab = require('./vocab-
|
|
7
|
+
const require_docloader = require('./docloader-Bui9z8Lb.cjs');
|
|
8
|
+
const require_actor = require('./actor-CK94m0Yv.cjs');
|
|
9
|
+
const require_lookup = require('./lookup-D_w567L8.cjs');
|
|
10
|
+
const require_key = require('./key-DqqCoLbc.cjs');
|
|
11
|
+
const require_http = require('./http-BAaVL480.cjs');
|
|
12
|
+
const require_proof = require('./proof-BLoRsaYR.cjs');
|
|
13
|
+
const require_types = require('./types-F8JMlP-f.cjs');
|
|
14
|
+
const require_authdocloader = require('./authdocloader-4iBGWlQw.cjs');
|
|
15
|
+
const require_vocab = require('./vocab-C-qxDq1m.cjs');
|
|
16
16
|
const __logtape_logtape = require_chunk.__toESM(require("@logtape/logtape"));
|
|
17
17
|
const __opentelemetry_api = require_chunk.__toESM(require("@opentelemetry/api"));
|
|
18
18
|
const byte_encodings_hex = require_chunk.__toESM(require("byte-encodings/hex"));
|
|
@@ -56,17 +56,39 @@ var InboxListenerSet = class InboxListenerSet {
|
|
|
56
56
|
return this.dispatchWithClass(activity)?.listener ?? null;
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
|
-
|
|
59
|
+
let warnedAboutDefaultIdempotency = false;
|
|
60
|
+
async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
|
|
60
61
|
const logger$1 = (0, __logtape_logtape.getLogger)([
|
|
61
62
|
"fedify",
|
|
62
63
|
"federation",
|
|
63
64
|
"inbox"
|
|
64
65
|
]);
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
66
|
+
let cacheKey = null;
|
|
67
|
+
if (activity.id != null) {
|
|
68
|
+
const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, require_actor.getTypeId(activity).href);
|
|
69
|
+
const strategy = idempotencyStrategy ?? "per-origin";
|
|
70
|
+
if (idempotencyStrategy === void 0 && !warnedAboutDefaultIdempotency) {
|
|
71
|
+
logger$1.warn("Using default idempotency strategy 'per-origin'. This default will change to 'per-inbox' in Fedify 2.0. Please explicitly set the idempotency strategy using .withIdempotency().");
|
|
72
|
+
warnedAboutDefaultIdempotency = true;
|
|
73
|
+
}
|
|
74
|
+
let keyString;
|
|
75
|
+
if (typeof strategy === "function") {
|
|
76
|
+
const result = await strategy(inboxContext, activity);
|
|
77
|
+
keyString = result;
|
|
78
|
+
} else switch (strategy) {
|
|
79
|
+
case "global":
|
|
80
|
+
keyString = activity.id.href;
|
|
81
|
+
break;
|
|
82
|
+
case "per-origin":
|
|
83
|
+
keyString = `${ctx.origin}\n${activity.id.href}`;
|
|
84
|
+
break;
|
|
85
|
+
case "per-inbox":
|
|
86
|
+
keyString = `${ctx.origin}\n${activity.id.href}\n${recipient == null ? "sharedInbox" : `inbox\n${recipient}`}`;
|
|
87
|
+
break;
|
|
88
|
+
default: keyString = `${ctx.origin}\n${activity.id.href}`;
|
|
89
|
+
}
|
|
90
|
+
if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
|
|
91
|
+
}
|
|
70
92
|
if (cacheKey != null) {
|
|
71
93
|
const cached = await kv.get(cacheKey);
|
|
72
94
|
if (cached === true) {
|
|
@@ -308,6 +330,7 @@ var FederationBuilderImpl = class {
|
|
|
308
330
|
inboxListeners;
|
|
309
331
|
inboxErrorHandler;
|
|
310
332
|
sharedInboxKeyDispatcher;
|
|
333
|
+
idempotencyStrategy;
|
|
311
334
|
collectionTypeIds;
|
|
312
335
|
collectionCallbacks;
|
|
313
336
|
/**
|
|
@@ -322,7 +345,7 @@ var FederationBuilderImpl = class {
|
|
|
322
345
|
this.collectionTypeIds = {};
|
|
323
346
|
}
|
|
324
347
|
async build(options) {
|
|
325
|
-
const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-
|
|
348
|
+
const { FederationImpl: FederationImpl$1 } = await Promise.resolve().then(() => require("./middleware-hTlyJu9R.cjs"));
|
|
326
349
|
const f = new FederationImpl$1(options);
|
|
327
350
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
328
351
|
f.router = this.router.clone();
|
|
@@ -344,6 +367,7 @@ var FederationBuilderImpl = class {
|
|
|
344
367
|
f.inboxListeners = this.inboxListeners?.clone();
|
|
345
368
|
f.inboxErrorHandler = this.inboxErrorHandler;
|
|
346
369
|
f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
|
|
370
|
+
f.idempotencyStrategy = this.idempotencyStrategy;
|
|
347
371
|
return f;
|
|
348
372
|
}
|
|
349
373
|
_getTracer() {
|
|
@@ -766,6 +790,10 @@ var FederationBuilderImpl = class {
|
|
|
766
790
|
setSharedKeyDispatcher: (dispatcher) => {
|
|
767
791
|
this.sharedInboxKeyDispatcher = dispatcher;
|
|
768
792
|
return setters;
|
|
793
|
+
},
|
|
794
|
+
withIdempotency: (strategy) => {
|
|
795
|
+
this.idempotencyStrategy = strategy;
|
|
796
|
+
return setters;
|
|
769
797
|
}
|
|
770
798
|
};
|
|
771
799
|
return setters;
|
|
@@ -1297,7 +1325,8 @@ async function handleInbox(request, options) {
|
|
|
1297
1325
|
* @param span The OpenTelemetry span for tracing.
|
|
1298
1326
|
* @returns A promise that resolves to an HTTP response.
|
|
1299
1327
|
*/
|
|
1300
|
-
async function handleInboxInternal(request,
|
|
1328
|
+
async function handleInboxInternal(request, parameters, span) {
|
|
1329
|
+
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
|
|
1301
1330
|
const logger$1 = (0, __logtape_logtape.getLogger)([
|
|
1302
1331
|
"fedify",
|
|
1303
1332
|
"federation",
|
|
@@ -1499,7 +1528,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
1499
1528
|
kvPrefixes,
|
|
1500
1529
|
queue,
|
|
1501
1530
|
span,
|
|
1502
|
-
tracerProvider
|
|
1531
|
+
tracerProvider,
|
|
1532
|
+
idempotencyStrategy: parameters.idempotencyStrategy
|
|
1503
1533
|
});
|
|
1504
1534
|
if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
|
|
1505
1535
|
status: 202,
|
|
@@ -3096,7 +3126,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3096
3126
|
onNotFound,
|
|
3097
3127
|
signatureTimeWindow: this.signatureTimeWindow,
|
|
3098
3128
|
skipSignatureVerification: this.skipSignatureVerification,
|
|
3099
|
-
tracerProvider: this.tracerProvider
|
|
3129
|
+
tracerProvider: this.tracerProvider,
|
|
3130
|
+
idempotencyStrategy: this.idempotencyStrategy
|
|
3100
3131
|
});
|
|
3101
3132
|
case "following": return await handleCollection(request, {
|
|
3102
3133
|
name: "following",
|
|
@@ -3487,15 +3518,16 @@ var ContextImpl = class ContextImpl {
|
|
|
3487
3518
|
"actor"
|
|
3488
3519
|
]);
|
|
3489
3520
|
if (this.federation.actorCallbacks?.keyPairsDispatcher == null) throw new Error("No actor key pairs dispatcher registered.");
|
|
3490
|
-
|
|
3491
|
-
|
|
3492
|
-
|
|
3493
|
-
})
|
|
3494
|
-
|
|
3495
|
-
|
|
3496
|
-
|
|
3521
|
+
let actorUri;
|
|
3522
|
+
try {
|
|
3523
|
+
actorUri = this.getActorUri(identifier);
|
|
3524
|
+
} catch (error) {
|
|
3525
|
+
if (error instanceof RouterError) {
|
|
3526
|
+
logger$1.warn(error.message);
|
|
3527
|
+
return [];
|
|
3528
|
+
}
|
|
3529
|
+
throw error;
|
|
3497
3530
|
}
|
|
3498
|
-
const actorUri = new URL(path, this.canonicalOrigin);
|
|
3499
3531
|
const keyPairs = await this.federation.actorCallbacks?.keyPairsDispatcher(new ContextImpl({
|
|
3500
3532
|
...this,
|
|
3501
3533
|
invokedFromActorKeyPairsDispatcher: { identifier }
|
|
@@ -3656,12 +3688,11 @@ var ContextImpl = class ContextImpl {
|
|
|
3656
3688
|
if (identifier == null) throw new Error("If recipients is \"followers\", sender must be an actor identifier or username.");
|
|
3657
3689
|
expandedRecipients = [];
|
|
3658
3690
|
for await (const recipient of this.getFollowers(identifier)) expandedRecipients.push(recipient);
|
|
3659
|
-
if (options.syncCollection) {
|
|
3660
|
-
|
|
3661
|
-
|
|
3662
|
-
|
|
3663
|
-
|
|
3664
|
-
opts.collectionSync = collectionId == null ? void 0 : new URL(collectionId, this.canonicalOrigin).href;
|
|
3691
|
+
if (options.syncCollection) try {
|
|
3692
|
+
opts.collectionSync = this.getFollowersUri(identifier).href;
|
|
3693
|
+
} catch (error) {
|
|
3694
|
+
if (error instanceof RouterError) opts.collectionSync = void 0;
|
|
3695
|
+
else throw error;
|
|
3665
3696
|
}
|
|
3666
3697
|
} else expandedRecipients = [recipients];
|
|
3667
3698
|
span.setAttribute("activitypub.inboxes", expandedRecipients.length);
|
|
@@ -3846,7 +3877,8 @@ var ContextImpl = class ContextImpl {
|
|
|
3846
3877
|
kvPrefixes: this.federation.kvPrefixes,
|
|
3847
3878
|
queue: this.federation.inboxQueue,
|
|
3848
3879
|
span,
|
|
3849
|
-
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
|
3880
|
+
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
|
3881
|
+
idempotencyStrategy: this.federation.idempotencyStrategy
|
|
3850
3882
|
});
|
|
3851
3883
|
return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
|
|
3852
3884
|
}
|