@fedify/fedify 2.0.33-dev.2413 → 2.0.33
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/{assert_rejects-B-qJtC9Z.mjs → assert_rejects-WyYSTDDX.mjs} +2 -20
- package/dist/{assert_throws-4NwKEy2q.mjs → assert_throws-D4DNWrux.mjs} +19 -1
- package/dist/{builder-DEj2UtTo.mjs → builder-BJHi8-yt.mjs} +3 -3
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{deno-1poG3nVL.mjs → deno-DxxJ7DXK.mjs} +1 -1
- package/dist/{docloader-DHhMJMBx.mjs → docloader-CINB2BX4.mjs} +2 -2
- package/dist/federation/builder.test.mjs +3 -3
- package/dist/federation/collection.test.mjs +1 -1
- package/dist/federation/handler.test.mjs +258 -9
- package/dist/federation/idempotency.test.mjs +3 -3
- package/dist/federation/inbox.test.mjs +25 -2
- package/dist/federation/kv.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +128 -10
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.js +1 -1
- package/dist/federation/mq.test.mjs +2 -2
- package/dist/federation/negotiation.test.mjs +2 -2
- package/dist/federation/retry.test.mjs +1 -1
- package/dist/federation/router.test.mjs +2 -3
- package/dist/federation/send.test.mjs +7 -6
- package/dist/federation/temporal.test.mjs +3 -3
- package/dist/federation/webfinger.test.mjs +2 -2
- package/dist/{http-C8SYUIha.mjs → http-CWWgD1YT.mjs} +2 -2
- package/dist/{http-DaS2vnNk.js → http-DaSZw9Op.js} +1 -1
- package/dist/{http-0H3c-FW0.cjs → http-qvfJE6bK.cjs} +1 -1
- package/dist/{inbox-DvbsFXWB.mjs → inbox-D1LSfOOd.mjs} +23 -10
- package/dist/{key-CDuFq0mQ.mjs → key-Bs7PNRrg.mjs} +1 -1
- package/dist/{kv-cache-BNiY7ea-.cjs → kv-cache-BKk8naEu.cjs} +1 -1
- package/dist/{kv-cache-B7T3rhpo.js → kv-cache-D95UjzfB.js} +1 -1
- package/dist/{ld-5AEMxXBH.mjs → ld-BlH5jQ7T.mjs} +2 -2
- package/dist/{middleware-NUR07Wjx.mjs → middleware-BGMXK3Xj.mjs} +1 -1
- package/dist/{middleware-B4GK0_I-.js → middleware-BGl-31cO.js} +102 -32
- package/dist/{middleware-DlYK6kvo.cjs → middleware-C9GIRvU2.cjs} +103 -33
- package/dist/{middleware-CKBMWB3q.cjs → middleware-D7b2kyYw.cjs} +1 -1
- package/dist/{middleware-Cm5Kx7Nr.mjs → middleware-DOo95yst.mjs} +89 -32
- package/dist/mod.cjs +4 -4
- package/dist/mod.js +4 -4
- package/dist/nodeinfo/client.test.mjs +1 -1
- package/dist/nodeinfo/handler.test.mjs +2 -2
- package/dist/nodeinfo/types.test.mjs +2 -2
- package/dist/otel/exporter.test.mjs +1 -1
- package/dist/{owner-BUnSHtD3.mjs → owner-9OeM4q1P.mjs} +2 -2
- package/dist/{proof-nfrx8WZI.mjs → proof-B-oGOuzf.mjs} +2 -2
- package/dist/{proof-BPWRZzc2.js → proof-BkLdxRY-.js} +1 -1
- package/dist/{proof-Bg4dnzAo.cjs → proof-D7USj3fe.cjs} +1 -1
- package/dist/{send-BVjpjEY-.mjs → send-Bjw1BCUr.mjs} +2 -2
- package/dist/sig/http.test.mjs +5 -5
- package/dist/sig/key.test.mjs +5 -5
- package/dist/sig/ld.test.mjs +4 -4
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +3 -3
- package/dist/sig/proof.test.mjs +3 -3
- package/dist/{std__assert-BUOJXi-Z.mjs → std__assert-DflMZha5.mjs} +2 -2
- package/dist/{temporal-D58JcKAc.mjs → temporal-Bf5PdJPv.mjs} +1 -1
- package/dist/utils/docloader.test.mjs +4 -4
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +6 -6
- /package/dist/{assert_not_equals--wG9hV7u.mjs → assert_not_equals-BkxW5QJI.mjs} +0 -0
|
@@ -2,8 +2,8 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import { r as assertGreaterOrEqual } from "../std__assert-
|
|
6
|
-
import {
|
|
5
|
+
import { r as assertGreaterOrEqual } from "../std__assert-DflMZha5.mjs";
|
|
6
|
+
import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
|
|
7
7
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
import { delay } from "es-toolkit";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import "../std__assert-
|
|
5
|
-
import {
|
|
4
|
+
import "../std__assert-DflMZha5.mjs";
|
|
5
|
+
import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
|
|
6
6
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
7
7
|
import { t as acceptsJsonLd } from "../negotiation-TWEs6Cl8.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
@@ -2,7 +2,7 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { l as AssertionError, t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
5
|
-
import { t as assertNotEquals } from "../assert_not_equals
|
|
5
|
+
import { t as assertNotEquals } from "../assert_not_equals-BkxW5QJI.mjs";
|
|
6
6
|
import { t as createExponentialBackoffPolicy } from "../retry-Ddbq3AcK.mjs";
|
|
7
7
|
import { test } from "@fedify/fixture";
|
|
8
8
|
//#region src/federation/retry.test.ts
|
|
@@ -3,10 +3,9 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as RouterError, t as Router } from "../router-CrMLXoOr.mjs";
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
|
-
import "../std__assert-
|
|
7
|
-
import {
|
|
6
|
+
import "../std__assert-DflMZha5.mjs";
|
|
7
|
+
import { r as assertFalse, t as assertThrows } from "../assert_throws-D4DNWrux.mjs";
|
|
8
8
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
9
|
-
import { t as assertThrows } from "../assert_throws-4NwKEy2q.mjs";
|
|
10
9
|
import { test } from "@fedify/fixture";
|
|
11
10
|
//#region src/federation/router.test.ts
|
|
12
11
|
function setUp(options = {}) {
|
|
@@ -3,14 +3,15 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { t as esm_default } from "../esm-DVILvP5e.mjs";
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
|
-
import "../std__assert-
|
|
7
|
-
import {
|
|
6
|
+
import "../std__assert-DflMZha5.mjs";
|
|
7
|
+
import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
|
|
8
8
|
import { n as assertInstanceOf, t as assert } from "../assert-BhQd8QHP.mjs";
|
|
9
|
-
import { t as assertNotEquals } from "../assert_not_equals
|
|
10
|
-
import {
|
|
9
|
+
import { t as assertNotEquals } from "../assert_not_equals-BkxW5QJI.mjs";
|
|
10
|
+
import { t as assertRejects } from "../assert_rejects-WyYSTDDX.mjs";
|
|
11
|
+
import { l as verifyRequest } from "../http-CWWgD1YT.mjs";
|
|
11
12
|
import { i as rsaPrivateKey2, n as ed25519PrivateKey, s as rsaPublicKey2, t as ed25519Multikey } from "../keys-CCxRJhWa.mjs";
|
|
12
|
-
import { t as doesActorOwnKey } from "../owner-
|
|
13
|
-
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-
|
|
13
|
+
import { t as doesActorOwnKey } from "../owner-9OeM4q1P.mjs";
|
|
14
|
+
import { n as extractInboxes, r as sendActivity, t as SendActivityError } from "../send-Bjw1BCUr.mjs";
|
|
14
15
|
import { createTestTracerProvider, mockDocumentLoader, test } from "@fedify/fixture";
|
|
15
16
|
import { Activity, Application, Endpoints, Group, Person, Service } from "@fedify/vocab";
|
|
16
17
|
import { FetchError, UrlError } from "@fedify/vocab-runtime";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import "../std__assert-
|
|
5
|
-
import {
|
|
4
|
+
import "../std__assert-DflMZha5.mjs";
|
|
5
|
+
import { r as assertFalse } from "../assert_throws-D4DNWrux.mjs";
|
|
6
6
|
import { t as assert } from "../assert-BhQd8QHP.mjs";
|
|
7
|
-
import { t as hasMalformedKnownTemporalLiteral } from "../temporal-
|
|
7
|
+
import { t as hasMalformedKnownTemporalLiteral } from "../temporal-Bf5PdJPv.mjs";
|
|
8
8
|
import { test } from "@fedify/fixture";
|
|
9
9
|
//#region src/federation/temporal.test.ts
|
|
10
10
|
test("hasMalformedKnownTemporalLiteral() detects expanded proof timestamps", async () => {
|
|
@@ -3,9 +3,9 @@ import "urlpattern-polyfill";
|
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as createRequestContext } from "../context-Juj6bdHC.mjs";
|
|
5
5
|
import { t as assertEquals } from "../assert_equals-Ew3jOFa3.mjs";
|
|
6
|
-
import "../std__assert-
|
|
6
|
+
import "../std__assert-DflMZha5.mjs";
|
|
7
7
|
import { t as MemoryKvStore } from "../kv-mI4Ix2EU.mjs";
|
|
8
|
-
import { a as createFederation, o as handleWebFinger } from "../middleware-
|
|
8
|
+
import { a as createFederation, o as handleWebFinger } from "../middleware-DOo95yst.mjs";
|
|
9
9
|
import { test } from "@fedify/fixture";
|
|
10
10
|
import { Image, Link, Person } from "@fedify/vocab";
|
|
11
11
|
//#region src/federation/webfinger.test.ts
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { o as validateCryptoKey, r as fetchKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-DxxJ7DXK.mjs";
|
|
5
|
+
import { o as validateCryptoKey, r as fetchKey } from "./key-Bs7PNRrg.mjs";
|
|
6
6
|
import { CryptographicKey } from "@fedify/vocab";
|
|
7
7
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
import { FetchError } from "@fedify/vocab-runtime";
|
|
@@ -10,7 +10,7 @@ import { decodeBase64, encodeBase64 } from "byte-encodings/base64";
|
|
|
10
10
|
import { Item, decodeDict, encodeItem } from "structured-field-values";
|
|
11
11
|
//#region deno.json
|
|
12
12
|
var name = "@fedify/fedify";
|
|
13
|
-
var version = "2.0.33
|
|
13
|
+
var version = "2.0.33";
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/sig/key.ts
|
|
16
16
|
/** Classifies decoding failures without hiding unexpected loader errors. */
|
|
@@ -11,7 +11,7 @@ let byte_encodings_base64 = require("byte-encodings/base64");
|
|
|
11
11
|
let structured_field_values = require("structured-field-values");
|
|
12
12
|
//#region deno.json
|
|
13
13
|
var name = "@fedify/fedify";
|
|
14
|
-
var version = "2.0.33
|
|
14
|
+
var version = "2.0.33";
|
|
15
15
|
//#endregion
|
|
16
16
|
//#region src/sig/key.ts
|
|
17
17
|
/** Classifies decoding failures without hiding unexpected loader errors. */
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-DxxJ7DXK.mjs";
|
|
5
5
|
import { Activity, getTypeId } from "@fedify/vocab";
|
|
6
6
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
7
7
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -39,12 +39,33 @@ var InboxListenerSet = class InboxListenerSet {
|
|
|
39
39
|
return this.dispatchWithClass(activity)?.listener ?? null;
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
|
+
/**
|
|
43
|
+
* Checks whether an activity's ID and all of its actor IDs have the same
|
|
44
|
+
* non-opaque origin. Activities without an ID have no origin to authenticate.
|
|
45
|
+
*
|
|
46
|
+
* The caller is responsible for rejecting a missing primary actor ID before
|
|
47
|
+
* relying on this check.
|
|
48
|
+
* @internal
|
|
49
|
+
*/
|
|
50
|
+
function actorsHaveSameOrigin(activity) {
|
|
51
|
+
if (activity.id == null) return true;
|
|
52
|
+
const origin = activity.id.origin;
|
|
53
|
+
return origin !== "null" && activity.actorIds.every((actor) => actor.origin === origin);
|
|
54
|
+
}
|
|
42
55
|
async function routeActivity({ context: ctx, json, originalJson, normalizedActivity, ldSignatureVerified, activity, recipient, inboxListeners, inboxContextFactory, listenerInboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
|
|
43
56
|
const logger = getLogger([
|
|
44
57
|
"fedify",
|
|
45
58
|
"federation",
|
|
46
59
|
"inbox"
|
|
47
60
|
]);
|
|
61
|
+
if (activity.actorId == null) {
|
|
62
|
+
logger.error("Missing actor.", { activity: json });
|
|
63
|
+
span.setStatus({
|
|
64
|
+
code: SpanStatusCode.ERROR,
|
|
65
|
+
message: "Missing actor."
|
|
66
|
+
});
|
|
67
|
+
return "missingActor";
|
|
68
|
+
}
|
|
48
69
|
let cacheKey = null;
|
|
49
70
|
if (activity.id != null) {
|
|
50
71
|
const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, getTypeId(activity).href);
|
|
@@ -79,14 +100,6 @@ async function routeActivity({ context: ctx, json, originalJson, normalizedActiv
|
|
|
79
100
|
return "alreadyProcessed";
|
|
80
101
|
}
|
|
81
102
|
}
|
|
82
|
-
if (activity.actorId == null) {
|
|
83
|
-
logger.error("Missing actor.", { activity: json });
|
|
84
|
-
span.setStatus({
|
|
85
|
-
code: SpanStatusCode.ERROR,
|
|
86
|
-
message: "Missing actor."
|
|
87
|
-
});
|
|
88
|
-
return "missingActor";
|
|
89
|
-
}
|
|
90
103
|
span.setAttribute("activitypub.actor.id", activity.actorId.href);
|
|
91
104
|
if (queue != null) {
|
|
92
105
|
const carrier = {};
|
|
@@ -179,4 +192,4 @@ async function routeActivity({ context: ctx, json, originalJson, normalizedActiv
|
|
|
179
192
|
});
|
|
180
193
|
}
|
|
181
194
|
//#endregion
|
|
182
|
-
export {
|
|
195
|
+
export { actorsHaveSameOrigin as n, routeActivity as r, InboxListenerSet as t };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
4
|
+
import { n as version, t as name } from "./deno-DxxJ7DXK.mjs";
|
|
5
5
|
import { CryptographicKey, Object as Object$1, isActor } from "@fedify/vocab";
|
|
6
6
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
7
7
|
import { FetchError, UrlError, getDocumentLoader } from "@fedify/vocab-runtime";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
const { Temporal } = require("@js-temporal/polyfill");
|
|
2
2
|
const { URLPattern } = require("urlpattern-polyfill");
|
|
3
3
|
require("./chunk-DDcVe30Y.cjs");
|
|
4
|
-
const require_http = require("./http-
|
|
4
|
+
const require_http = require("./http-qvfJE6bK.cjs");
|
|
5
5
|
let _logtape_logtape = require("@logtape/logtape");
|
|
6
6
|
let es_toolkit = require("es-toolkit");
|
|
7
7
|
let _fedify_vocab_runtime = require("@fedify/vocab-runtime");
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Temporal } from "@js-temporal/polyfill";
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
|
-
import { l as validateCryptoKey, t as doubleKnock } from "./http-
|
|
3
|
+
import { l as validateCryptoKey, t as doubleKnock } from "./http-DaSZw9Op.js";
|
|
4
4
|
import { getLogger } from "@logtape/logtape";
|
|
5
5
|
import { curry } from "es-toolkit";
|
|
6
6
|
import { FetchError, UrlError, createActivityPubRequest, getRemoteDocument, logRequest, preloadedContexts, validatePublicUrl } from "@fedify/vocab-runtime";
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import "@js-temporal/polyfill";
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
|
-
import { n as version, t as name } from "./deno-
|
|
5
|
-
import { o as validateCryptoKey, r as fetchKey } from "./key-
|
|
4
|
+
import { n as version, t as name } from "./deno-DxxJ7DXK.mjs";
|
|
5
|
+
import { o as validateCryptoKey, r as fetchKey } from "./key-Bs7PNRrg.mjs";
|
|
6
6
|
import { Activity, CryptographicKey, Object as Object$1, getTypeId } from "@fedify/vocab";
|
|
7
7
|
import { SpanStatusCode, trace } from "@opentelemetry/api";
|
|
8
8
|
import { getDocumentLoader } from "@fedify/vocab-runtime";
|
|
@@ -2,10 +2,10 @@ import { Temporal } from "@js-temporal/polyfill";
|
|
|
2
2
|
import { URLPattern } from "urlpattern-polyfill";
|
|
3
3
|
import { t as __exportAll } from "./chunk-CRNNMoPX.js";
|
|
4
4
|
import { r as getDefaultActivityTransformers } from "./transformers-BGMIq1cs.js";
|
|
5
|
-
import { c as importJwk, d as name, f as version, i as exportJwk, l as validateCryptoKey, r as verifyRequest, t as doubleKnock } from "./http-
|
|
5
|
+
import { c as importJwk, d as name, f as version, i as exportJwk, l as validateCryptoKey, r as verifyRequest, t as doubleKnock } from "./http-DaSZw9Op.js";
|
|
6
6
|
import { a as MAX_BODY_SIZE, i as BodyTooLargeError, n as getNodeInfo, o as readBoundedText, t as nodeInfoToJson } from "./types-miAYfiGO.js";
|
|
7
|
-
import { _ as signJsonLd, a as doesActorOwnKey, c as assertSafeJsonLd, f as detachSignature, g as isInvalidUrlTypeError, h as isClearlyMalformedContextReference, m as hasSignature, n as signObject, o as getKeyOwner, p as getNormalizationContextLoader, r as verifyObject, s as InvalidContextReferenceError, u as compactJsonLd, v as verifyCompactJsonLd, x as wrapContextLoaderForJsonLd } from "./proof-
|
|
8
|
-
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-
|
|
7
|
+
import { _ as signJsonLd, a as doesActorOwnKey, c as assertSafeJsonLd, f as detachSignature, g as isInvalidUrlTypeError, h as isClearlyMalformedContextReference, m as hasSignature, n as signObject, o as getKeyOwner, p as getNormalizationContextLoader, r as verifyObject, s as InvalidContextReferenceError, u as compactJsonLd, v as verifyCompactJsonLd, x as wrapContextLoaderForJsonLd } from "./proof-BkLdxRY-.js";
|
|
8
|
+
import { n as getAuthenticatedDocumentLoader, t as kvCache } from "./kv-cache-D95UjzfB.js";
|
|
9
9
|
import { getLogger, withContext } from "@logtape/logtape";
|
|
10
10
|
import { Activity, Collection, CollectionPage, CryptographicKey, Link, Multikey, Object as Object$1, OrderedCollection, OrderedCollectionPage, getTypeId, lookupObject, traverseCollection } from "@fedify/vocab";
|
|
11
11
|
import { SpanKind, SpanStatusCode, context, propagation, trace } from "@opentelemetry/api";
|
|
@@ -52,12 +52,33 @@ var InboxListenerSet = class InboxListenerSet {
|
|
|
52
52
|
return this.dispatchWithClass(activity)?.listener ?? null;
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
+
/**
|
|
56
|
+
* Checks whether an activity's ID and all of its actor IDs have the same
|
|
57
|
+
* non-opaque origin. Activities without an ID have no origin to authenticate.
|
|
58
|
+
*
|
|
59
|
+
* The caller is responsible for rejecting a missing primary actor ID before
|
|
60
|
+
* relying on this check.
|
|
61
|
+
* @internal
|
|
62
|
+
*/
|
|
63
|
+
function actorsHaveSameOrigin(activity) {
|
|
64
|
+
if (activity.id == null) return true;
|
|
65
|
+
const origin = activity.id.origin;
|
|
66
|
+
return origin !== "null" && activity.actorIds.every((actor) => actor.origin === origin);
|
|
67
|
+
}
|
|
55
68
|
async function routeActivity({ context: ctx, json, originalJson, normalizedActivity, ldSignatureVerified, activity, recipient, inboxListeners, inboxContextFactory, listenerInboxContextFactory, inboxErrorHandler, kv, kvPrefixes, queue, span, tracerProvider, idempotencyStrategy }) {
|
|
56
69
|
const logger = getLogger([
|
|
57
70
|
"fedify",
|
|
58
71
|
"federation",
|
|
59
72
|
"inbox"
|
|
60
73
|
]);
|
|
74
|
+
if (activity.actorId == null) {
|
|
75
|
+
logger.error("Missing actor.", { activity: json });
|
|
76
|
+
span.setStatus({
|
|
77
|
+
code: SpanStatusCode.ERROR,
|
|
78
|
+
message: "Missing actor."
|
|
79
|
+
});
|
|
80
|
+
return "missingActor";
|
|
81
|
+
}
|
|
61
82
|
let cacheKey = null;
|
|
62
83
|
if (activity.id != null) {
|
|
63
84
|
const inboxContext = inboxContextFactory(recipient, json, activity.id?.href, getTypeId(activity).href);
|
|
@@ -92,14 +113,6 @@ async function routeActivity({ context: ctx, json, originalJson, normalizedActiv
|
|
|
92
113
|
return "alreadyProcessed";
|
|
93
114
|
}
|
|
94
115
|
}
|
|
95
|
-
if (activity.actorId == null) {
|
|
96
|
-
logger.error("Missing actor.", { activity: json });
|
|
97
|
-
span.setStatus({
|
|
98
|
-
code: SpanStatusCode.ERROR,
|
|
99
|
-
message: "Missing actor."
|
|
100
|
-
});
|
|
101
|
-
return "missingActor";
|
|
102
|
-
}
|
|
103
116
|
span.setAttribute("activitypub.actor.id", activity.actorId.href);
|
|
104
117
|
if (queue != null) {
|
|
105
118
|
const carrier = {};
|
|
@@ -1159,8 +1172,8 @@ async function handleObject(request, { values, context, objectDispatcher, author
|
|
|
1159
1172
|
* @param parameters The parameters for handling the collection.
|
|
1160
1173
|
* @returns A promise that resolves to an HTTP response.
|
|
1161
1174
|
*/
|
|
1162
|
-
async function handleCollection(request, { name: name$
|
|
1163
|
-
const spanName = name$
|
|
1175
|
+
async function handleCollection(request, { name: name$2, identifier, uriGetter, filter, filterPredicate, context, collectionCallbacks, tracerProvider, onUnauthorized, onNotFound }) {
|
|
1176
|
+
const spanName = name$2.trim().replace(/\s+/g, "_");
|
|
1164
1177
|
tracerProvider = tracerProvider ?? trace.getTracerProvider();
|
|
1165
1178
|
const tracer = tracerProvider.getTracer(name, version);
|
|
1166
1179
|
const cursor = new URL(request.url).searchParams.get("cursor");
|
|
@@ -1202,7 +1215,7 @@ async function handleCollection(request, { name: name$1, identifier, uriGetter,
|
|
|
1202
1215
|
collection = new OrderedCollection({
|
|
1203
1216
|
id: baseUri,
|
|
1204
1217
|
totalItems: totalItems == null ? null : Number(totalItems),
|
|
1205
|
-
items: filterCollectionItems(itemsOrResponse, name$
|
|
1218
|
+
items: filterCollectionItems(itemsOrResponse, name$2, filterPredicate)
|
|
1206
1219
|
});
|
|
1207
1220
|
} else {
|
|
1208
1221
|
const lastCursor = await collectionCallbacks.lastCursor?.(context, identifier);
|
|
@@ -1223,7 +1236,7 @@ async function handleCollection(request, { name: name$1, identifier, uriGetter,
|
|
|
1223
1236
|
} else {
|
|
1224
1237
|
const uri = new URL(baseUri);
|
|
1225
1238
|
uri.searchParams.set("cursor", cursor);
|
|
1226
|
-
const pageOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection_page ${name$
|
|
1239
|
+
const pageOrResponse = await tracer.startActiveSpan(`activitypub.dispatch_collection_page ${name$2}`, {
|
|
1227
1240
|
kind: SpanKind.SERVER,
|
|
1228
1241
|
attributes: {
|
|
1229
1242
|
"activitypub.collection.id": uri.href,
|
|
@@ -1267,7 +1280,7 @@ async function handleCollection(request, { name: name$1, identifier, uriGetter,
|
|
|
1267
1280
|
id: uri,
|
|
1268
1281
|
prev,
|
|
1269
1282
|
next,
|
|
1270
|
-
items: filterCollectionItems(items, name$
|
|
1283
|
+
items: filterCollectionItems(items, name$2, filterPredicate),
|
|
1271
1284
|
partOf
|
|
1272
1285
|
});
|
|
1273
1286
|
}
|
|
@@ -1653,6 +1666,36 @@ async function handleInboxInternal(request, parameters, span) {
|
|
|
1653
1666
|
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
1654
1667
|
});
|
|
1655
1668
|
}
|
|
1669
|
+
if (activity.actorId == null) {
|
|
1670
|
+
logger.error("Missing actor.", {
|
|
1671
|
+
activity: json,
|
|
1672
|
+
recipient
|
|
1673
|
+
});
|
|
1674
|
+
span.setStatus({
|
|
1675
|
+
code: SpanStatusCode.ERROR,
|
|
1676
|
+
message: "Missing actor."
|
|
1677
|
+
});
|
|
1678
|
+
return new Response("Missing actor.", {
|
|
1679
|
+
status: 400,
|
|
1680
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
1681
|
+
});
|
|
1682
|
+
}
|
|
1683
|
+
if (!skipSignatureVerification && activity.id != null && !actorsHaveSameOrigin(activity)) {
|
|
1684
|
+
logger.error("The activity ({activityId}) and its actors do not have the same origin.", {
|
|
1685
|
+
activity: json,
|
|
1686
|
+
recipient,
|
|
1687
|
+
activityId: activity.id.href,
|
|
1688
|
+
actorIds: activity.actorIds.map((actor) => actor.href)
|
|
1689
|
+
});
|
|
1690
|
+
span.setStatus({
|
|
1691
|
+
code: SpanStatusCode.ERROR,
|
|
1692
|
+
message: `The activity (${activity.id.href}) and its actors do not have the same origin.`
|
|
1693
|
+
});
|
|
1694
|
+
return new Response("The activity and its actors do not have the same origin.", {
|
|
1695
|
+
status: 401,
|
|
1696
|
+
headers: { "Content-Type": "text/plain; charset=utf-8" }
|
|
1697
|
+
});
|
|
1698
|
+
}
|
|
1656
1699
|
const routeResult = await routeActivity({
|
|
1657
1700
|
context: ctx,
|
|
1658
1701
|
json,
|
|
@@ -1781,8 +1824,8 @@ var CustomCollectionHandler = class {
|
|
|
1781
1824
|
* @param CollectionPage The CollectionPage constructor.
|
|
1782
1825
|
* @param filterPredicate Optional filter predicate for items.
|
|
1783
1826
|
*/
|
|
1784
|
-
constructor(name$
|
|
1785
|
-
this.name = name$
|
|
1827
|
+
constructor(name$1, values, context, callbacks, tracerProvider = trace.getTracerProvider(), Collection, CollectionPage, filterPredicate) {
|
|
1828
|
+
this.name = name$1;
|
|
1786
1829
|
this.values = values;
|
|
1787
1830
|
this.context = context;
|
|
1788
1831
|
this.callbacks = callbacks;
|
|
@@ -3098,6 +3141,33 @@ var FederationImpl = class extends FederationBuilderImpl {
|
|
|
3098
3141
|
activity = await Activity.fromJsonLd(parseInput, parseContext);
|
|
3099
3142
|
span.setAttribute("activitypub.activity.type", getTypeId(activity).href);
|
|
3100
3143
|
if (activity.id != null) span.setAttribute("activitypub.activity.id", activity.id.href);
|
|
3144
|
+
if (activity.actorId == null) {
|
|
3145
|
+
logger.error("Missing actor in queued incoming activity.", {
|
|
3146
|
+
activityId: activity.id?.href,
|
|
3147
|
+
activity: message.activity,
|
|
3148
|
+
recipient: message.identifier
|
|
3149
|
+
});
|
|
3150
|
+
span.setStatus({
|
|
3151
|
+
code: SpanStatusCode.ERROR,
|
|
3152
|
+
message: "Missing actor."
|
|
3153
|
+
});
|
|
3154
|
+
span.end();
|
|
3155
|
+
return;
|
|
3156
|
+
}
|
|
3157
|
+
if (!this.skipSignatureVerification && activity.id != null && !actorsHaveSameOrigin(activity)) {
|
|
3158
|
+
logger.error("The queued activity ({activityId}) and its actors do not have the same origin.", {
|
|
3159
|
+
activityId: activity.id.href,
|
|
3160
|
+
actorIds: activity.actorIds.map((actor) => actor.href),
|
|
3161
|
+
activity: message.activity,
|
|
3162
|
+
recipient: message.identifier
|
|
3163
|
+
});
|
|
3164
|
+
span.setStatus({
|
|
3165
|
+
code: SpanStatusCode.ERROR,
|
|
3166
|
+
message: `The activity (${activity.id.href}) and its actors do not have the same origin.`
|
|
3167
|
+
});
|
|
3168
|
+
span.end();
|
|
3169
|
+
return;
|
|
3170
|
+
}
|
|
3101
3171
|
cacheKey = activity.id == null ? null : [
|
|
3102
3172
|
...this.kvPrefixes.activityIdempotence,
|
|
3103
3173
|
context.origin,
|
|
@@ -4208,20 +4278,6 @@ var ContextImpl = class ContextImpl {
|
|
|
4208
4278
|
activity: await fetched.toJsonLd({ contextLoader })
|
|
4209
4279
|
});
|
|
4210
4280
|
return false;
|
|
4211
|
-
} else if (fetched.actorIds.length < 1) {
|
|
4212
|
-
logger.debug("Fetched activity object is missing an actor; unable to verify.", {
|
|
4213
|
-
recipient,
|
|
4214
|
-
activity: await fetched.toJsonLd({ contextLoader })
|
|
4215
|
-
});
|
|
4216
|
-
return false;
|
|
4217
|
-
}
|
|
4218
|
-
const activityId = fetched.id;
|
|
4219
|
-
if (!fetched.actorIds.every((actor) => actor.origin === activityId.origin)) {
|
|
4220
|
-
logger.debug("Fetched activity object has actors from different origins; unable to verify.", {
|
|
4221
|
-
recipient,
|
|
4222
|
-
activity: await fetched.toJsonLd({ contextLoader })
|
|
4223
|
-
});
|
|
4224
|
-
return false;
|
|
4225
4281
|
}
|
|
4226
4282
|
logger.debug("Successfully fetched the remote activity object {activityId}; ignore the original activity and use the fetched one, which is trustworthy.");
|
|
4227
4283
|
activity = fetched;
|
|
@@ -4230,6 +4286,20 @@ var ContextImpl = class ContextImpl {
|
|
|
4230
4286
|
recipient,
|
|
4231
4287
|
activity: json
|
|
4232
4288
|
});
|
|
4289
|
+
if (activity.actorId == null) {
|
|
4290
|
+
logger.debug("Activity is missing an actor; unable to verify.", {
|
|
4291
|
+
recipient,
|
|
4292
|
+
activity: json
|
|
4293
|
+
});
|
|
4294
|
+
return false;
|
|
4295
|
+
}
|
|
4296
|
+
if (activity.id != null && !actorsHaveSameOrigin(activity)) {
|
|
4297
|
+
logger.debug("Activity has actors from different origins; unable to verify.", {
|
|
4298
|
+
recipient,
|
|
4299
|
+
activity: json
|
|
4300
|
+
});
|
|
4301
|
+
return false;
|
|
4302
|
+
}
|
|
4233
4303
|
const routeResult = await routeActivity({
|
|
4234
4304
|
context: this,
|
|
4235
4305
|
json,
|