@fedify/fedify 1.9.0-pr.443.1681 → 1.9.0-pr.455.1742
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-sT_gcgkl.d.ts → actor-C1Euqngb.d.ts} +1 -1
- package/dist/{actor-CX1PqLef.js → actor-CL8lYYUx.js} +1 -1
- package/dist/{actor-D6yXbYgY.js → actor-CYnaKz6k.js} +6169 -2946
- package/dist/{actor-CpDvMeh9.cjs → actor-D_0j9hMV.cjs} +6169 -2946
- package/dist/{actor-D8GmZX63.d.cts → actor-Ydzhc8dj.d.cts} +1 -1
- package/dist/{authdocloader-B02Yhk89.cjs → authdocloader-AGT1bvSf.cjs} +3 -3
- package/dist/{authdocloader-_-SNQ37B.js → authdocloader-BlVoSqyh.js} +3 -3
- package/dist/{authdocloader-CtHAAz1D.js → authdocloader-CRuH00Tu.js} +3 -3
- package/dist/{builder-C5KrSbKS.js → builder-CqMKWEN0.js} +14 -8
- package/dist/{client-DbRgEC98.js → client-BM12q1DJ.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-Cp-kboln.d.ts → context-CXUibY4L.d.ts} +179 -116
- package/dist/{context-BkqGJwLI.d.cts → context-CwUAkopp.d.cts} +179 -116
- package/dist/{docloader-DHrLpvDa.js → docloader-BggS4E4F.js} +1 -1
- package/dist/{docloader-B_lWIYhZ.cjs → docloader-CLtA3Ji8.cjs} +1 -1
- package/dist/{esm-oDAmb3t0.js → esm-B3jpomik.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-BQ0XHmus.cjs → http-2m_h3SPQ.cjs} +3 -3
- package/dist/{http-B9UPBFJz.d.cts → http-B1_DzfAU.d.cts} +1 -1
- package/dist/{http-4lxNFaXA.js → http-D53H7oqD.js} +3 -3
- package/dist/{http-ABY5j3YT.js → http-DNkYeLxx.js} +2 -2
- package/dist/{http-BGqh2jzk.d.ts → http-wsGR6KkT.d.ts} +1 -1
- package/dist/{inbox-D34aGNh3.js → inbox-FbqGLKha.js} +29 -7
- package/dist/{key-DCCZ0IQz.js → key-B42BY6RL.js} +2 -2
- package/dist/{key-B8fuptOf.js → key-BVNVEpXg.js} +2 -2
- package/dist/key-CYO3d3Bc.cjs +10 -0
- package/dist/{key-CUhjb7ia.cjs → key-CZzEU9nv.cjs} +2 -2
- package/dist/{key-BvUiwgvU.js → key-Dj6-orIK.js} +3 -3
- package/dist/{key-D5_cYZv8.js → key-NaBDH7FK.js} +4 -4
- package/dist/{keycache-DPgak-bY.js → keycache-BLtGOP6f.js} +1 -1
- package/dist/{keys-R-SfK3nQ.js → keys-BO3n2h_L.js} +1 -1
- package/dist/{ld-Dng9Ri0Z.js → ld-CMWQXDty.js} +2 -2
- package/dist/{lookup-CgzIxSqk.js → lookup-B5jlZrQb.js} +21 -12
- package/dist/{lookup-Bm9ZRBwj.cjs → lookup-BsOmKssB.cjs} +1 -1
- package/dist/{lookup-4DHxuyI4.js → lookup-C-jJgyrW.js} +1 -1
- package/dist/middleware-BV1L9XDk.cjs +17 -0
- package/dist/{middleware-774Oifc4.js → middleware-CNAH05Vn.js} +78 -47
- package/dist/middleware-Cr46LoSG.js +26 -0
- package/dist/middleware-DAFFQX5e.js +17 -0
- package/dist/{middleware-CpT5VG6o.cjs → middleware-DOd67qPG.cjs} +78 -47
- package/dist/{middleware-B7DkslM_.js → middleware-lg47b3mK.js} +43 -40
- package/dist/{mod-DxjZ8kbs.d.cts → mod-BUbqxBev.d.cts} +19 -1
- package/dist/{mod-OfRtcQo1.d.ts → mod-BcObK1Lz.d.ts} +2 -2
- package/dist/{mod-CnEwcmyF.d.ts → mod-CDObsV1d.d.ts} +19 -1
- package/dist/{mod-TsyIDkKn.d.ts → mod-CIbqfZW0.d.ts} +1 -1
- package/dist/{mod-Cuem8g-I.d.ts → mod-DgcYoyZK.d.ts} +2 -2
- package/dist/{mod-bscaBAIo.d.cts → mod-Dt-G9ZOS.d.cts} +1 -1
- package/dist/{mod-BihGJmMM.d.cts → mod-fjqfsrty.d.cts} +2 -2
- package/dist/{mod-Ds5wiXHw.d.cts → mod-mXx9V0q5.d.cts} +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-BYxDl2qi.d.cts → owner-6KSEp9eV.d.cts} +2 -2
- package/dist/{owner-DOUl7e-t.d.ts → owner-BbeUDvOu.d.ts} +2 -2
- package/dist/{owner-BnmJOCds.js → owner-Ch2ApIpq.js} +2 -2
- package/dist/{proof-QLd9LtLS.cjs → proof-BtqGVz24.cjs} +3 -3
- package/dist/{proof-4d4UTrId.js → proof-Cge6SysA.js} +3 -3
- package/dist/{proof-DRGe3kWw.js → proof-DaD7vIAi.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-VTF45d0K.js → send-DE79ptpc.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 +341 -379
- package/dist/testing/mod.js +3 -3
- package/dist/{testing-DtlapwX9.js → testing-Bh2wmeXp.js} +2 -2
- package/dist/{type-BK1maiHl.js → type-Du-WE8NC.js} +6297 -3074
- package/dist/{types-B11Jr68m.cjs → types-B1n1v8Fa.cjs} +1 -1
- package/dist/{types-ChXkDqkb.js → types-ChEbJU3f.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 +395 -8
- package/dist/{vocab-BW6SWH9P.d.ts → vocab-CDHNj5zp.d.ts} +158 -497
- package/dist/{vocab-qpRpljdS.d.cts → vocab-Cfs0937i.d.cts} +158 -497
- package/dist/{vocab-C2kef9JD.cjs → vocab-DY3aCxLN.cjs} +23 -14
- package/dist/{vocab-B7TUfvy2.js → vocab-Q8XBm9oV.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-DtzwU8SC.cjs +0 -10
- package/dist/middleware-CunKD_hx.js +0 -17
- package/dist/middleware-DpW8xh9z.cjs +0 -17
- package/dist/middleware-umMExV_X.js +0 -26
@@ -3,8 +3,8 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
globalThis.addEventListener = () => {};
|
5
5
|
|
6
|
-
import { CryptographicKey, deno_default } from "./type-
|
7
|
-
import { fetchKey, validateCryptoKey } from "./key-
|
6
|
+
import { CryptographicKey, deno_default } from "./type-Du-WE8NC.js";
|
7
|
+
import { fetchKey, validateCryptoKey } from "./key-B42BY6RL.js";
|
8
8
|
import { getLogger } from "@logtape/logtape";
|
9
9
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
10
10
|
import { ATTR_HTTP_REQUEST_HEADER, ATTR_HTTP_REQUEST_METHOD, ATTR_URL_FULL } from "@opentelemetry/semantic-conventions";
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
3
3
|
import { DocumentLoader } from "./docloader-CxWcuWqQ.js";
|
4
|
-
import { CryptographicKey, Multikey } from "./vocab-
|
4
|
+
import { CryptographicKey, Multikey } from "./vocab-CDHNj5zp.js";
|
5
5
|
import { TracerProvider } from "@opentelemetry/api";
|
6
6
|
|
7
7
|
//#region src/sig/key.d.ts
|
@@ -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-Du-WE8NC.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-Du-WE8NC.js";
|
7
|
+
import { isActor } from "./actor-CL8lYYUx.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-BggS4E4F.js";
|
6
|
+
import { CryptographicKey, Object as Object$1, isActor } from "./actor-CYnaKz6k.js";
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
9
9
|
|
@@ -0,0 +1,10 @@
|
|
1
|
+
|
2
|
+
const { Temporal } = require("@js-temporal/polyfill");
|
3
|
+
const { URLPattern } = require("urlpattern-polyfill");
|
4
|
+
|
5
|
+
require('./docloader-CLtA3Ji8.cjs');
|
6
|
+
require('./actor-D_0j9hMV.cjs');
|
7
|
+
require('./lookup-BsOmKssB.cjs');
|
8
|
+
const require_key = require('./key-CZzEU9nv.cjs');
|
9
|
+
|
10
|
+
exports.validateCryptoKey = require_key.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-CLtA3Ji8.cjs');
|
7
|
+
const require_actor = require('./actor-D_0j9hMV.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,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-Du-WE8NC.js";
|
7
|
+
import "./actor-CL8lYYUx.js";
|
8
|
+
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-B42BY6RL.js";
|
9
9
|
|
10
10
|
export { validateCryptoKey };
|
@@ -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-BggS4E4F.js";
|
6
|
+
import "./actor-CYnaKz6k.js";
|
7
|
+
import "./lookup-C-jJgyrW.js";
|
8
|
+
import { exportJwk, fetchKey, generateCryptoKeyPair, importJwk, validateCryptoKey } from "./key-BVNVEpXg.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-Du-WE8NC.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-Du-WE8NC.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-Du-WE8NC.js";
|
7
|
+
import { fetchKey, validateCryptoKey } from "./key-B42BY6RL.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
|
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-Du-WE8NC.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,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-CLtA3Ji8.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-BggS4E4F.js";
|
6
6
|
import { getLogger } from "@logtape/logtape";
|
7
7
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
8
8
|
|
@@ -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-CLtA3Ji8.cjs');
|
7
|
+
require('./actor-D_0j9hMV.cjs');
|
8
|
+
const require_middleware = require('./middleware-DOd67qPG.cjs');
|
9
|
+
require('./lookup-BsOmKssB.cjs');
|
10
|
+
require('./key-CZzEU9nv.cjs');
|
11
|
+
require('./http-2m_h3SPQ.cjs');
|
12
|
+
require('./proof-BtqGVz24.cjs');
|
13
|
+
require('./types-B1n1v8Fa.cjs');
|
14
|
+
require('./authdocloader-AGT1bvSf.cjs');
|
15
|
+
require('./vocab-DY3aCxLN.cjs');
|
16
|
+
|
17
|
+
exports.FederationImpl = require_middleware.FederationImpl;
|
@@ -3,15 +3,15 @@
|
|
3
3
|
import { URLPattern } from "urlpattern-polyfill";
|
4
4
|
|
5
5
|
import { getDefaultActivityTransformers } from "./transformers-BFT6d7J5.js";
|
6
|
-
import { deno_default, getDocumentLoader, kvCache } from "./docloader-
|
7
|
-
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-
|
8
|
-
import { lookupWebFinger } from "./lookup-
|
9
|
-
import { exportJwk, importJwk, validateCryptoKey } from "./key-
|
10
|
-
import { doubleKnock, verifyRequest } from "./http-
|
11
|
-
import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-
|
12
|
-
import { getNodeInfo, nodeInfoToJson } from "./types-
|
13
|
-
import { getAuthenticatedDocumentLoader } from "./authdocloader-
|
14
|
-
import { lookupObject, traverseCollection } from "./vocab-
|
6
|
+
import { deno_default, getDocumentLoader, kvCache } from "./docloader-BggS4E4F.js";
|
7
|
+
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId } from "./actor-CYnaKz6k.js";
|
8
|
+
import { lookupWebFinger } from "./lookup-C-jJgyrW.js";
|
9
|
+
import { exportJwk, importJwk, validateCryptoKey } from "./key-BVNVEpXg.js";
|
10
|
+
import { doubleKnock, verifyRequest } from "./http-D53H7oqD.js";
|
11
|
+
import { detachSignature, doesActorOwnKey, getKeyOwner, hasSignature, signJsonLd, signObject, verifyJsonLd, verifyObject } from "./proof-Cge6SysA.js";
|
12
|
+
import { getNodeInfo, nodeInfoToJson } from "./types-ChEbJU3f.js";
|
13
|
+
import { getAuthenticatedDocumentLoader } from "./authdocloader-CRuH00Tu.js";
|
14
|
+
import { lookupObject, traverseCollection } from "./vocab-Q8XBm9oV.js";
|
15
15
|
import { getLogger, withContext } from "@logtape/logtape";
|
16
16
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
17
17
|
import { encodeHex } from "byte-encodings/hex";
|
@@ -55,17 +55,39 @@ var InboxListenerSet = class InboxListenerSet {
|
|
55
55
|
return this.dispatchWithClass(activity)?.listener ?? null;
|
56
56
|
}
|
57
57
|
};
|
58
|
-
|
58
|
+
let warnedAboutDefaultIdempotency = false;
|
59
|
+
async function routeActivity({ context: ctx, json, activity, recipient, inboxListeners, inboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
|
59
60
|
const logger$1 = getLogger([
|
60
61
|
"fedify",
|
61
62
|
"federation",
|
62
63
|
"inbox"
|
63
64
|
]);
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
65
|
+
let cacheKey = null;
|
66
|
+
if (activity.id != null) {
|
67
|
+
const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, getTypeId(activity).href);
|
68
|
+
const strategy = idempotencyStrategy ?? "per-origin";
|
69
|
+
if (idempotencyStrategy === void 0 && !warnedAboutDefaultIdempotency) {
|
70
|
+
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().");
|
71
|
+
warnedAboutDefaultIdempotency = true;
|
72
|
+
}
|
73
|
+
let keyString;
|
74
|
+
if (typeof strategy === "function") {
|
75
|
+
const result = await strategy(inboxContext, activity);
|
76
|
+
keyString = result;
|
77
|
+
} else switch (strategy) {
|
78
|
+
case "global":
|
79
|
+
keyString = activity.id.href;
|
80
|
+
break;
|
81
|
+
case "per-origin":
|
82
|
+
keyString = `${ctx.origin}\n${activity.id.href}`;
|
83
|
+
break;
|
84
|
+
case "per-inbox":
|
85
|
+
keyString = `${ctx.origin}\n${activity.id.href}\n${recipient == null ? "sharedInbox" : `inbox\n${recipient}`}`;
|
86
|
+
break;
|
87
|
+
default: keyString = `${ctx.origin}\n${activity.id.href}`;
|
88
|
+
}
|
89
|
+
if (keyString != null) cacheKey = [...kvPrefixes.activityIdempotence, keyString];
|
90
|
+
}
|
69
91
|
if (cacheKey != null) {
|
70
92
|
const cached = await kv.get(cacheKey);
|
71
93
|
if (cached === true) {
|
@@ -307,6 +329,7 @@ var FederationBuilderImpl = class {
|
|
307
329
|
inboxListeners;
|
308
330
|
inboxErrorHandler;
|
309
331
|
sharedInboxKeyDispatcher;
|
332
|
+
idempotencyStrategy;
|
310
333
|
collectionTypeIds;
|
311
334
|
collectionCallbacks;
|
312
335
|
/**
|
@@ -321,7 +344,7 @@ var FederationBuilderImpl = class {
|
|
321
344
|
this.collectionTypeIds = {};
|
322
345
|
}
|
323
346
|
async build(options) {
|
324
|
-
const { FederationImpl: FederationImpl$1 } = await import("./middleware-
|
347
|
+
const { FederationImpl: FederationImpl$1 } = await import("./middleware-DAFFQX5e.js");
|
325
348
|
const f = new FederationImpl$1(options);
|
326
349
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
327
350
|
f.router = this.router.clone();
|
@@ -343,6 +366,7 @@ var FederationBuilderImpl = class {
|
|
343
366
|
f.inboxListeners = this.inboxListeners?.clone();
|
344
367
|
f.inboxErrorHandler = this.inboxErrorHandler;
|
345
368
|
f.sharedInboxKeyDispatcher = this.sharedInboxKeyDispatcher;
|
369
|
+
f.idempotencyStrategy = this.idempotencyStrategy;
|
346
370
|
return f;
|
347
371
|
}
|
348
372
|
_getTracer() {
|
@@ -765,15 +789,19 @@ var FederationBuilderImpl = class {
|
|
765
789
|
setSharedKeyDispatcher: (dispatcher) => {
|
766
790
|
this.sharedInboxKeyDispatcher = dispatcher;
|
767
791
|
return setters;
|
792
|
+
},
|
793
|
+
withIdempotency: (strategy) => {
|
794
|
+
this.idempotencyStrategy = strategy;
|
795
|
+
return setters;
|
768
796
|
}
|
769
797
|
};
|
770
798
|
return setters;
|
771
799
|
}
|
772
|
-
setCollectionDispatcher(name,
|
773
|
-
return this.#setCustomCollectionDispatcher(name, "collection",
|
800
|
+
setCollectionDispatcher(name, itemType, path, dispatcher) {
|
801
|
+
return this.#setCustomCollectionDispatcher(name, "collection", itemType, path, dispatcher);
|
774
802
|
}
|
775
|
-
setOrderedCollectionDispatcher(name,
|
776
|
-
return this.#setCustomCollectionDispatcher(name, "orderedCollection",
|
803
|
+
setOrderedCollectionDispatcher(name, itemType, path, dispatcher) {
|
804
|
+
return this.#setCustomCollectionDispatcher(name, "orderedCollection", itemType, path, dispatcher);
|
777
805
|
}
|
778
806
|
#setCustomCollectionDispatcher(name, collectionType, itemType, path, dispatcher) {
|
779
807
|
const strName = String(name);
|
@@ -1296,7 +1324,8 @@ async function handleInbox(request, options) {
|
|
1296
1324
|
* @param span The OpenTelemetry span for tracing.
|
1297
1325
|
* @returns A promise that resolves to an HTTP response.
|
1298
1326
|
*/
|
1299
|
-
async function handleInboxInternal(request,
|
1327
|
+
async function handleInboxInternal(request, parameters, span) {
|
1328
|
+
const { recipient, context: ctx, inboxContextFactory, kv, kvPrefixes, queue, actorDispatcher, inboxListeners, inboxErrorHandler, onNotFound, signatureTimeWindow, skipSignatureVerification, tracerProvider } = parameters;
|
1300
1329
|
const logger$1 = getLogger([
|
1301
1330
|
"fedify",
|
1302
1331
|
"federation",
|
@@ -1498,7 +1527,8 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
1498
1527
|
kvPrefixes,
|
1499
1528
|
queue,
|
1500
1529
|
span,
|
1501
|
-
tracerProvider
|
1530
|
+
tracerProvider,
|
1531
|
+
idempotencyStrategy: parameters.idempotencyStrategy
|
1502
1532
|
});
|
1503
1533
|
if (routeResult === "alreadyProcessed") return new Response(`Activity <${activity.id}> has already been processed.`, {
|
1504
1534
|
status: 202,
|
@@ -1528,7 +1558,7 @@ async function handleInboxInternal(request, { recipient, context: ctx, inboxCont
|
|
1528
1558
|
/**
|
1529
1559
|
* Handles a custom collection request.
|
1530
1560
|
* @template TItem The type of items in the collection.
|
1531
|
-
* @template
|
1561
|
+
* @template TParam The parameter names of the requested URL.
|
1532
1562
|
* @template TContext The type of the context, extending {@link RequestContext}.
|
1533
1563
|
* @template TContextData The context data to pass to the `TContext`.
|
1534
1564
|
* @param request The HTTP request.
|
@@ -1547,7 +1577,7 @@ async function _handleCustomCollection(request, { name, values, context: context
|
|
1547
1577
|
/**
|
1548
1578
|
* Handles an ordered collection request.
|
1549
1579
|
* @template TItem The type of items in the collection.
|
1550
|
-
* @template
|
1580
|
+
* @template TParam The parameter names of the requested URL.
|
1551
1581
|
* @template TContext The type of the context, extending {@link RequestContext}.
|
1552
1582
|
* @template TContextData The context data to pass to the `TContext`.
|
1553
1583
|
* @param request The HTTP request.
|
@@ -1568,7 +1598,7 @@ async function _handleOrderedCollection(request, { name, values, context: contex
|
|
1568
1598
|
* The main flow is on `getCollection`, `dispatch`.
|
1569
1599
|
*
|
1570
1600
|
* @template TItem The type of items in the collection.
|
1571
|
-
* @template
|
1601
|
+
* @template TParam The parameter names of the requested URL.
|
1572
1602
|
* @template TContext The type of the context. {@link Context} or {@link RequestContext}.
|
1573
1603
|
* @template TContextData The context data to pass to the `TContext`.
|
1574
1604
|
* @template TCollection The type of the collection, extending {@link Collection}.
|
@@ -1602,14 +1632,14 @@ var CustomCollectionHandler = class {
|
|
1602
1632
|
#collection = null;
|
1603
1633
|
/**
|
1604
1634
|
* Creates a new CustomCollection instance.
|
1605
|
-
* @param
|
1606
|
-
* @param
|
1607
|
-
* @param
|
1608
|
-
* @param
|
1609
|
-
* @param
|
1610
|
-
* @param
|
1611
|
-
* @param
|
1612
|
-
* @param
|
1635
|
+
* @param name The name of the collection.
|
1636
|
+
* @param values The parameter values for the collection.
|
1637
|
+
* @param context The request context.
|
1638
|
+
* @param callbacks The collection callbacks.
|
1639
|
+
* @param tracerProvider The tracer provider for telemetry.
|
1640
|
+
* @param Collection The Collection constructor.
|
1641
|
+
* @param CollectionPage The CollectionPage constructor.
|
1642
|
+
* @param filterPredicate Optional filter predicate for items.
|
1613
1643
|
*/
|
1614
1644
|
constructor(name, values, context$1, callbacks, tracerProvider = trace.getTracerProvider(), Collection$1, CollectionPage$1, filterPredicate) {
|
1615
1645
|
this.name = name;
|
@@ -1734,7 +1764,7 @@ var CustomCollectionHandler = class {
|
|
1734
1764
|
/**
|
1735
1765
|
* Creates a function to wrap the dispatcher so tracing can be applied.
|
1736
1766
|
* @param params Parameters including cursor and total items.
|
1737
|
-
* @returns
|
1767
|
+
* @returns A function that handles the span operation.
|
1738
1768
|
*/
|
1739
1769
|
spanPages = ({ totalItems = null, cursor = null }) => async (span) => {
|
1740
1770
|
try {
|
@@ -1755,23 +1785,23 @@ var CustomCollectionHandler = class {
|
|
1755
1785
|
};
|
1756
1786
|
/**
|
1757
1787
|
* Dispatches the collection request to get items.
|
1758
|
-
* @param
|
1759
|
-
* @returns
|
1788
|
+
* @param cursor The cursor for pagination, or null for the first page.
|
1789
|
+
* @returns A promise that resolves to the page items.
|
1760
1790
|
*/
|
1761
1791
|
async dispatch(cursor = null) {
|
1762
1792
|
return await this.#dispatcher(this.context, this.values, cursor) ?? new ItemsNotFoundError().throw();
|
1763
1793
|
}
|
1764
1794
|
/**
|
1765
1795
|
* Filters the items in the collection.
|
1766
|
-
* @param
|
1767
|
-
* @returns
|
1796
|
+
* @param items The items to filter.
|
1797
|
+
* @returns The filtered items.
|
1768
1798
|
*/
|
1769
1799
|
filterItems(items) {
|
1770
1800
|
return filterCollectionItems(items, this.name, this.filterPredicate);
|
1771
1801
|
}
|
1772
1802
|
/**
|
1773
1803
|
* Appends a cursor to the URL if it exists.
|
1774
|
-
* @param
|
1804
|
+
* @param cursor The cursor to append, or null/undefined.
|
1775
1805
|
* @returns The URL with cursor appended, or null if cursor is null/undefined.
|
1776
1806
|
*/
|
1777
1807
|
appendToUrl(cursor) {
|
@@ -1779,8 +1809,7 @@ var CustomCollectionHandler = class {
|
|
1779
1809
|
}
|
1780
1810
|
/**
|
1781
1811
|
* Gets the stored collection or collection page.
|
1782
|
-
* @returns
|
1783
|
-
the collection or collection page.
|
1812
|
+
* @returns A promise that resolves to the collection or collection page.
|
1784
1813
|
*/
|
1785
1814
|
get collection() {
|
1786
1815
|
if (this.#collection === null) this.#collection = this.getCollection();
|
@@ -1788,8 +1817,8 @@ var CustomCollectionHandler = class {
|
|
1788
1817
|
}
|
1789
1818
|
/**
|
1790
1819
|
* Gets the total number of items in the collection.
|
1791
|
-
* @returns
|
1792
|
-
|
1820
|
+
* @returns A promise that resolves to the total items count,
|
1821
|
+
* or null if not available.
|
1793
1822
|
*/
|
1794
1823
|
get totalItems() {
|
1795
1824
|
if (this.#totalItems === void 0) this.totalItems = this.callbacks.counter?.(this.context, this.values);
|
@@ -1805,8 +1834,8 @@ var CustomCollectionHandler = class {
|
|
1805
1834
|
}
|
1806
1835
|
/**
|
1807
1836
|
* Gets the first cursor for pagination.
|
1808
|
-
* @returns
|
1809
|
-
or null if not available.
|
1837
|
+
* @returns A promise that resolves to the first cursor,
|
1838
|
+
* or null if not available.
|
1810
1839
|
*/
|
1811
1840
|
get firstCursor() {
|
1812
1841
|
const cursor = this.callbacks.firstCursor?.(this.context, this.values);
|
@@ -3095,7 +3124,8 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
3095
3124
|
onNotFound,
|
3096
3125
|
signatureTimeWindow: this.signatureTimeWindow,
|
3097
3126
|
skipSignatureVerification: this.skipSignatureVerification,
|
3098
|
-
tracerProvider: this.tracerProvider
|
3127
|
+
tracerProvider: this.tracerProvider,
|
3128
|
+
idempotencyStrategy: this.idempotencyStrategy
|
3099
3129
|
});
|
3100
3130
|
case "following": return await handleCollection(request, {
|
3101
3131
|
name: "following",
|
@@ -3845,7 +3875,8 @@ var ContextImpl = class ContextImpl {
|
|
3845
3875
|
kvPrefixes: this.federation.kvPrefixes,
|
3846
3876
|
queue: this.federation.inboxQueue,
|
3847
3877
|
span,
|
3848
|
-
tracerProvider: options.tracerProvider ?? this.tracerProvider
|
3878
|
+
tracerProvider: options.tracerProvider ?? this.tracerProvider,
|
3879
|
+
idempotencyStrategy: this.federation.idempotencyStrategy
|
3849
3880
|
});
|
3850
3881
|
return routeResult === "alreadyProcessed" || routeResult === "enqueued" || routeResult === "unsupportedActivity" || routeResult === "success";
|
3851
3882
|
}
|
@@ -0,0 +1,26 @@
|
|
1
|
+
|
2
|
+
import { Temporal } from "@js-temporal/polyfill";
|
3
|
+
import { URLPattern } from "urlpattern-polyfill";
|
4
|
+
globalThis.addEventListener = () => {};
|
5
|
+
|
6
|
+
import "./type-Du-WE8NC.js";
|
7
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-lg47b3mK.js";
|
8
|
+
import "./semver-dArNLkR9.js";
|
9
|
+
import "./client-BM12q1DJ.js";
|
10
|
+
import "./lookup-B5jlZrQb.js";
|
11
|
+
import "./types-BIgY6c-l.js";
|
12
|
+
import "./actor-CL8lYYUx.js";
|
13
|
+
import "./key-B42BY6RL.js";
|
14
|
+
import "./http-DNkYeLxx.js";
|
15
|
+
import "./authdocloader-BlVoSqyh.js";
|
16
|
+
import "./ld-CMWQXDty.js";
|
17
|
+
import "./owner-Ch2ApIpq.js";
|
18
|
+
import "./proof-DaD7vIAi.js";
|
19
|
+
import "./inbox-FbqGLKha.js";
|
20
|
+
import "./builder-CqMKWEN0.js";
|
21
|
+
import "./collection-CSzG2j1P.js";
|
22
|
+
import "./keycache-BLtGOP6f.js";
|
23
|
+
import "./retry-D4GJ670a.js";
|
24
|
+
import "./send-DE79ptpc.js";
|
25
|
+
|
26
|
+
export { FederationImpl };
|
@@ -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-BggS4E4F.js";
|
7
|
+
import "./actor-CYnaKz6k.js";
|
8
|
+
import { ContextImpl, FederationImpl, InboxContextImpl, KvSpecDeterminer, createFederation } from "./middleware-CNAH05Vn.js";
|
9
|
+
import "./lookup-C-jJgyrW.js";
|
10
|
+
import "./key-BVNVEpXg.js";
|
11
|
+
import "./http-D53H7oqD.js";
|
12
|
+
import "./proof-Cge6SysA.js";
|
13
|
+
import "./types-ChEbJU3f.js";
|
14
|
+
import "./authdocloader-CRuH00Tu.js";
|
15
|
+
import "./vocab-Q8XBm9oV.js";
|
16
|
+
|
17
|
+
export { FederationImpl };
|