@fedify/fedify 1.9.0-dev.1668 → 1.9.0-dev.1704
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-ChSW_rBk.js → actor-B0LpLKRw.js} +7263 -2440
- package/dist/{actor-Ch5yFYFG.d.ts → actor-C1Euqngb.d.ts} +1 -1
- package/dist/{actor-BHAPrCDB.js → actor-CQzdjHs3.js} +1 -1
- package/dist/{actor-fGD4yb1K.cjs → actor-DU96UQUE.cjs} +7263 -2440
- package/dist/{actor-CHOM_AN3.d.cts → actor-Ydzhc8dj.d.cts} +1 -1
- package/dist/{authdocloader-eSrbn3wM.cjs → authdocloader-BkOerKL-.cjs} +3 -3
- package/dist/{authdocloader-CgrKtaQg.js → authdocloader-CzmsYrAn.js} +3 -3
- package/dist/{authdocloader-ChsJ9FJN.js → authdocloader-DI67R2Ku.js} +3 -3
- package/dist/{builder-DI4-Kpdg.js → builder-D2Oyy8AY.js} +14 -8
- package/dist/{client-B8gJ1cw8.js → client-BWusKCWF.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-C51zGhGC.d.ts} +185 -92
- package/dist/{context-KXVF2AhH.d.cts → context-Qnv814-p.d.cts} +185 -92
- package/dist/{docloader-CSB8cAnw.cjs → docloader-NcFUThCx.cjs} +1 -1
- package/dist/{docloader-Bqh-eFNP.js → docloader-isD0ntZv.js} +1 -1
- package/dist/{esm-DTi75ew2.js → esm-BBVcrjH8.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 +3 -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-BpAVdmaR.js → http-BiKoa3o_.js} +2 -2
- package/dist/{http-BDErrXSN.cjs → http-LVXxICJn.cjs} +3 -3
- package/dist/{http-DBHpjcjo.js → http-MyYS6o7t.js} +3 -3
- package/dist/{http-D8Q4xH0d.d.ts → http-wsGR6KkT.d.ts} +1 -1
- package/dist/{inbox-BA9sYsBf.js → inbox-CzGsgKH-.js} +29 -7
- package/dist/key-BEz2ThE9.cjs +10 -0
- package/dist/{key-DSOJOcRH.js → key-C0SCHEcf.js} +3 -3
- package/dist/{key-B27QtSbc.js → key-C5cRHj8g.js} +2 -2
- package/dist/{key-sCE-TgxY.js → key-CRhmBE03.js} +2 -2
- package/dist/{key-CYpTUnwf.cjs → key-Ci8OyUTB.cjs} +2 -2
- package/dist/{key-2rIHnPaA.js → key-DWPlWnFQ.js} +4 -4
- package/dist/{keycache-CiW2SvJu.js → keycache-rO8ea311.js} +1 -1
- package/dist/{keys-5cHW76LQ.js → keys-CWdCy_3n.js} +1 -1
- package/dist/{ld-upnKn3yw.js → ld-BWADNtQr.js} +2 -2
- package/dist/{lookup-B61sZAOY.js → lookup-BBTRFcU5.js} +1 -1
- package/dist/{lookup-BrrOs_g1.cjs → lookup-CILOZed9.cjs} +1 -1
- package/dist/{lookup-CZBG-vCx.js → lookup-RINL4MOa.js} +21 -12
- package/dist/{middleware-CyUVZG3t.js → middleware-Bcv0xCjs.js} +43 -40
- package/dist/middleware-Be9qUuwL.cjs +17 -0
- package/dist/{middleware-CfP7UhQy.js → middleware-BfhSHVoJ.js} +78 -47
- package/dist/middleware-CWlljVpG.js +26 -0
- package/dist/{middleware-P3jCWk4K.cjs → middleware-DDyUhxsm.cjs} +78 -47
- package/dist/middleware-Dm7sDAVJ.js +17 -0
- package/dist/{mod-NKH_G-IY.d.cts → mod-BUbqxBev.d.cts} +19 -1
- 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-YfAcrVbP.d.cts → mod-COTXAYRl.d.cts} +2 -2
- 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-o-hx_hU8.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-zvsMGYzc.js → owner-QEQV9vx-.js} +2 -2
- package/dist/{proof-Bt6yHsMN.js → proof-B_9fbF3f.js} +3 -3
- package/dist/{proof-BgKYSJ00.js → proof-g2_9VhUQ.js} +2 -2
- package/dist/{proof-CC_7UV_j.cjs → proof-v3B5cJ3c.cjs} +3 -3
- 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-DlqdAGHP.js → send-cTLNXtTp.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 +391 -86
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-CAAJTPCt.js → testing-CNtyBr2m.js} +2 -2
- package/dist/{type-BRNRL3aj.js → type-C5udJemk.js} +6943 -2120
- package/dist/{types-Dz0NMslg.cjs → types-C9w81XqW.cjs} +1 -1
- package/dist/{types-C8yjtF5A.js → types-DHq9gRM4.js} +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 +397 -8
- package/dist/{vocab-BDMmyzZA.cjs → vocab-BoyCE2Rn.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-WpDLcZH7.js → vocab-DxoBe7PI.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-Ck4-GNm0.cjs +0 -10
- package/dist/middleware-D8O6iKhr.js +0 -26
- package/dist/middleware-DI4sIaI4.js +0 -17
- package/dist/middleware-lw0MLhVG.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-C5udJemk.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) {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
|
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
|
4
|
+
|
|
5
|
+
require('./docloader-NcFUThCx.cjs');
|
|
6
|
+
require('./actor-DU96UQUE.cjs');
|
|
7
|
+
require('./lookup-CILOZed9.cjs');
|
|
8
|
+
const require_key = require('./key-Ci8OyUTB.cjs');
|
|
9
|
+
|
|
10
|
+
exports.validateCryptoKey = require_key.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-C5udJemk.js";
|
|
7
|
+
import "./actor-CQzdjHs3.js";
|
|
8
|
+
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-C5cRHj8g.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 { 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-C5udJemk.js";
|
|
7
|
+
import { isActor } from "./actor-CQzdjHs3.js";
|
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
|
9
9
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
10
10
|
|
|
@@ -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-isD0ntZv.js";
|
|
6
|
+
import { CryptographicKey, Object as Object$1, isActor } from "./actor-B0LpLKRw.js";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
|
|
@@ -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-NcFUThCx.cjs');
|
|
7
|
+
const require_actor = require('./actor-DU96UQUE.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
|
|
|
@@ -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-isD0ntZv.js";
|
|
6
|
+
import "./actor-B0LpLKRw.js";
|
|
7
|
+
import "./lookup-BBTRFcU5.js";
|
|
8
|
+
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-CRhmBE03.js";
|
|
9
9
|
|
|
10
10
|
export { validateCryptoKey };
|
|
@@ -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-C5udJemk.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-C5udJemk.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-C5udJemk.js";
|
|
7
|
+
import { fetchKey, validateCryptoKey } from "./key-C5cRHj8g.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";
|
|
@@ -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-isD0ntZv.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
|
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-NcFUThCx.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
|
|
|
@@ -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-C5udJemk.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.
|
|
@@ -3,22 +3,22 @@
|
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
|
4
4
|
globalThis.addEventListener = () => {};
|
|
5
5
|
|
|
6
|
-
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, deno_default, getDocumentLoader, getTypeId, kvCache, lookupWebFinger } from "./type-
|
|
7
|
-
import { getNodeInfo } from "./client-
|
|
8
|
-
import { RouterError, lookupObject, traverseCollection } from "./lookup-
|
|
6
|
+
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, deno_default, getDocumentLoader, getTypeId, kvCache, lookupWebFinger } from "./type-C5udJemk.js";
|
|
7
|
+
import { getNodeInfo } from "./client-BWusKCWF.js";
|
|
8
|
+
import { RouterError, lookupObject, traverseCollection } from "./lookup-RINL4MOa.js";
|
|
9
9
|
import { nodeInfoToJson } from "./types-BIgY6c-l.js";
|
|
10
|
-
import { exportJwk, importJwk, validateCryptoKey } from "./key-
|
|
11
|
-
import { verifyRequest } from "./http-
|
|
12
|
-
import { getAuthenticatedDocumentLoader } from "./authdocloader-
|
|
13
|
-
import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-
|
|
14
|
-
import { doesActorOwnKey, getKeyOwner } from "./owner-
|
|
15
|
-
import { signObject, verifyObject } from "./proof-
|
|
16
|
-
import { routeActivity } from "./inbox-
|
|
17
|
-
import { FederationBuilderImpl } from "./builder-
|
|
10
|
+
import { exportJwk, importJwk, validateCryptoKey } from "./key-C5cRHj8g.js";
|
|
11
|
+
import { verifyRequest } from "./http-BiKoa3o_.js";
|
|
12
|
+
import { getAuthenticatedDocumentLoader } from "./authdocloader-CzmsYrAn.js";
|
|
13
|
+
import { detachSignature, hasSignature, signJsonLd, verifyJsonLd } from "./ld-BWADNtQr.js";
|
|
14
|
+
import { doesActorOwnKey, getKeyOwner } from "./owner-QEQV9vx-.js";
|
|
15
|
+
import { signObject, verifyObject } from "./proof-g2_9VhUQ.js";
|
|
16
|
+
import { routeActivity } from "./inbox-CzGsgKH-.js";
|
|
17
|
+
import { FederationBuilderImpl } from "./builder-D2Oyy8AY.js";
|
|
18
18
|
import { buildCollectionSynchronizationHeader } from "./collection-CSzG2j1P.js";
|
|
19
|
-
import { KvKeyCache } from "./keycache-
|
|
19
|
+
import { KvKeyCache } from "./keycache-rO8ea311.js";
|
|
20
20
|
import { createExponentialBackoffPolicy } from "./retry-D4GJ670a.js";
|
|
21
|
-
import { extractInboxes, sendActivity } from "./send-
|
|
21
|
+
import { extractInboxes, sendActivity } from "./send-cTLNXtTp.js";
|
|
22
22
|
import { getLogger, withContext } from "@logtape/logtape";
|
|
23
23
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
24
24
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_HTTP_RESPONSE_HEADER, ATTR_HTTP_RESPONSE_STATUS_CODE, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
|
@@ -671,7 +671,8 @@ async function handleInbox(request, options) {
|
|
|
671
671
|
* @param span The OpenTelemetry span for tracing.
|
|
672
672
|
* @returns A promise that resolves to an HTTP response.
|
|
673
673
|
*/
|
|
674
|
-
async function handleInboxInternal(request,
|
|
674
|
+
async function handleInboxInternal(request, parameters, span) {
|
|
675
|
+
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
|
|
675
676
|
const logger$2 = getLogger([
|
|
676
677
|
"fedify",
|
|
677
678
|
"federation",
|
|
@@ -873,7 +874,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
873
874
|
kvPrefixes,
|
|
874
875
|
queue,
|
|
875
876
|
span,
|
|
876
|
-
tracerProvider
|
|
877
|
+
tracerProvider,
|
|
878
|
+
idempotencyStrategy: parameters.idempotencyStrategy
|
|
877
879
|
});
|
|
878
880
|
if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
|
|
879
881
|
status: 202,
|
|
@@ -903,7 +905,7 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
|
903
905
|
/**
|
|
904
906
|
* Handles a custom collection request.
|
|
905
907
|
* @template TItem The type of items in the collection.
|
|
906
|
-
* @template
|
|
908
|
+
* @template TParam The parameter names of the requested URL.
|
|
907
909
|
* @template TContext The type of the context, extending {@link RequestContext}.
|
|
908
910
|
* @template TContextData The context data to pass to the `TContext`.
|
|
909
911
|
* @param request The HTTP request.
|
|
@@ -922,7 +924,7 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
|
922
924
|
/**
|
|
923
925
|
* Handles an ordered collection request.
|
|
924
926
|
* @template TItem The type of items in the collection.
|
|
925
|
-
* @template
|
|
927
|
+
* @template TParam The parameter names of the requested URL.
|
|
926
928
|
* @template TContext The type of the context, extending {@link RequestContext}.
|
|
927
929
|
* @template TContextData The context data to pass to the `TContext`.
|
|
928
930
|
* @param request The HTTP request.
|
|
@@ -943,7 +945,7 @@ async function _handleOrderedCollection(request, { name, values, context: contex
|
|
|
943
945
|
* The main flow is on `getCollection`, `dispatch`.
|
|
944
946
|
*
|
|
945
947
|
* @template TItem The type of items in the collection.
|
|
946
|
-
* @template
|
|
948
|
+
* @template TParam The parameter names of the requested URL.
|
|
947
949
|
* @template TContext The type of the context. {@link Context} or {@link RequestContext}.
|
|
948
950
|
* @template TContextData The context data to pass to the `TContext`.
|
|
949
951
|
* @template TCollection The type of the collection, extending {@link Collection}.
|
|
@@ -977,14 +979,14 @@ var CustomCollectionHandler = class {
|
|
|
977
979
|
#collection = null;
|
|
978
980
|
/**
|
|
979
981
|
* Creates a new CustomCollection instance.
|
|
980
|
-
* @param
|
|
981
|
-
* @param
|
|
982
|
-
* @param
|
|
983
|
-
* @param
|
|
984
|
-
* @param
|
|
985
|
-
* @param
|
|
986
|
-
* @param
|
|
987
|
-
* @param
|
|
982
|
+
* @param name The name of the collection.
|
|
983
|
+
* @param values The parameter values for the collection.
|
|
984
|
+
* @param context The request context.
|
|
985
|
+
* @param callbacks The collection callbacks.
|
|
986
|
+
* @param tracerProvider The tracer provider for telemetry.
|
|
987
|
+
* @param Collection The Collection constructor.
|
|
988
|
+
* @param CollectionPage The CollectionPage constructor.
|
|
989
|
+
* @param filterPredicate Optional filter predicate for items.
|
|
988
990
|
*/
|
|
989
991
|
constructor(name, values, context$1, callbacks, tracerProvider = trace.getTracerProvider(), Collection$1, CollectionPage$1, filterPredicate) {
|
|
990
992
|
this.name = name;
|
|
@@ -1109,7 +1111,7 @@ var CustomCollectionHandler = class {
|
|
|
1109
1111
|
/**
|
|
1110
1112
|
* Creates a function to wrap the dispatcher so tracing can be applied.
|
|
1111
1113
|
* @param params Parameters including cursor and total items.
|
|
1112
|
-
* @returns
|
|
1114
|
+
* @returns A function that handles the span operation.
|
|
1113
1115
|
*/
|
|
1114
1116
|
spanPages = ({ totalItems = null, cursor = null }) => async (span) => {
|
|
1115
1117
|
try {
|
|
@@ -1130,23 +1132,23 @@ var CustomCollectionHandler = class {
|
|
|
1130
1132
|
};
|
|
1131
1133
|
/**
|
|
1132
1134
|
* Dispatches the collection request to get items.
|
|
1133
|
-
* @param
|
|
1134
|
-
* @returns
|
|
1135
|
+
* @param cursor The cursor for pagination, or null for the first page.
|
|
1136
|
+
* @returns A promise that resolves to the page items.
|
|
1135
1137
|
*/
|
|
1136
1138
|
async dispatch(cursor = null) {
|
|
1137
1139
|
return await this.#dispatcher(this.context, this.values, cursor) ?? new ItemsNotFoundError().throw();
|
|
1138
1140
|
}
|
|
1139
1141
|
/**
|
|
1140
1142
|
* Filters the items in the collection.
|
|
1141
|
-
* @param
|
|
1142
|
-
* @returns
|
|
1143
|
+
* @param items The items to filter.
|
|
1144
|
+
* @returns The filtered items.
|
|
1143
1145
|
*/
|
|
1144
1146
|
filterItems(items) {
|
|
1145
1147
|
return filterCollectionItems(items, this.name, this.filterPredicate);
|
|
1146
1148
|
}
|
|
1147
1149
|
/**
|
|
1148
1150
|
* Appends a cursor to the URL if it exists.
|
|
1149
|
-
* @param
|
|
1151
|
+
* @param cursor The cursor to append, or null/undefined.
|
|
1150
1152
|
* @returns The URL with cursor appended, or null if cursor is null/undefined.
|
|
1151
1153
|
*/
|
|
1152
1154
|
appendToUrl(cursor) {
|
|
@@ -1154,8 +1156,7 @@ var CustomCollectionHandler = class {
|
|
|
1154
1156
|
}
|
|
1155
1157
|
/**
|
|
1156
1158
|
* Gets the stored collection or collection page.
|
|
1157
|
-
* @returns
|
|
1158
|
-
the collection or collection page.
|
|
1159
|
+
* @returns A promise that resolves to the collection or collection page.
|
|
1159
1160
|
*/
|
|
1160
1161
|
get collection() {
|
|
1161
1162
|
if (this.#collection === null) this.#collection = this.getCollection();
|
|
@@ -1163,8 +1164,8 @@ var CustomCollectionHandler = class {
|
|
|
1163
1164
|
}
|
|
1164
1165
|
/**
|
|
1165
1166
|
* Gets the total number of items in the collection.
|
|
1166
|
-
* @returns
|
|
1167
|
-
|
|
1167
|
+
* @returns A promise that resolves to the total items count,
|
|
1168
|
+
* or null if not available.
|
|
1168
1169
|
*/
|
|
1169
1170
|
get totalItems() {
|
|
1170
1171
|
if (this.#totalItems === void 0) this.totalItems = this.callbacks.counter?.(this.context, this.values);
|
|
@@ -1180,8 +1181,8 @@ var CustomCollectionHandler = class {
|
|
|
1180
1181
|
}
|
|
1181
1182
|
/**
|
|
1182
1183
|
* Gets the first cursor for pagination.
|
|
1183
|
-
* @returns
|
|
1184
|
-
or null if not available.
|
|
1184
|
+
* @returns A promise that resolves to the first cursor,
|
|
1185
|
+
* or null if not available.
|
|
1185
1186
|
*/
|
|
1186
1187
|
get firstCursor() {
|
|
1187
1188
|
const cursor = this.callbacks.firstCursor?.(this.context, this.values);
|
|
@@ -2151,7 +2152,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
2151
2152
|
onNotFound,
|
|
2152
2153
|
signatureTimeWindow: this.signatureTimeWindow,
|
|
2153
2154
|
skipSignatureVerification: this.skipSignatureVerification,
|
|
2154
|
-
tracerProvider: this.tracerProvider
|
|
2155
|
+
tracerProvider: this.tracerProvider,
|
|
2156
|
+
idempotencyStrategy: this.idempotencyStrategy
|
|
2155
2157
|
});
|
|
2156
2158
|
case "following": return await handleCollection(request, {
|
|
2157
2159
|
name: "following",
|
|
@@ -2901,7 +2903,8 @@ var ContextImpl = class ContextImpl {
|
|
|
2901
2903
|
kvPrefixes: this.federation.kvPrefixes,
|
|
2902
2904
|
queue: this.federation.inboxQueue,
|
|
2903
2905
|
span,
|
|
2904
|
-
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
|
2906
|
+
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
|
2907
|
+
idempotencyStrategy: this.federation.idempotencyStrategy
|
|
2905
2908
|
});
|
|
2906
2909
|
return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
|
|
2907
2910
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
|
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
|
4
|
+
|
|
5
|
+
require('./transformers-CoBS-oFG.cjs');
|
|
6
|
+
require('./docloader-NcFUThCx.cjs');
|
|
7
|
+
require('./actor-DU96UQUE.cjs');
|
|
8
|
+
const require_middleware = require('./middleware-DDyUhxsm.cjs');
|
|
9
|
+
require('./lookup-CILOZed9.cjs');
|
|
10
|
+
require('./key-Ci8OyUTB.cjs');
|
|
11
|
+
require('./http-LVXxICJn.cjs');
|
|
12
|
+
require('./proof-v3B5cJ3c.cjs');
|
|
13
|
+
require('./types-C9w81XqW.cjs');
|
|
14
|
+
require('./authdocloader-BkOerKL-.cjs');
|
|
15
|
+
require('./vocab-BoyCE2Rn.cjs');
|
|
16
|
+
|
|
17
|
+
exports.FederationImpl = require_middleware.FederationImpl;
|