@fedify/fedify 2.1.30 → 2.1.32
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/attachment-arrays-DZ4JHJD8.mjs +111 -0
- package/dist/{builder-CTpfuuVp.mjs → builder--sc-rozj.mjs} +3 -3
- package/dist/callback-BARPujV7.d.mts +2388 -0
- package/dist/{client-CAM_bQXx.d.cts → client-9DPcy_Yx.d.ts} +16 -1
- package/dist/{client-CSddvgWN.d.ts → client-B3ruDgWg.d.cts} +16 -1
- package/dist/{client-CjDMsn4a.mjs → client-cpPaW7Ww.mjs} +189 -65
- package/dist/compat/attachment-arrays.test.d.mts +2 -0
- package/dist/compat/attachment-arrays.test.mjs +254 -0
- package/dist/compat/mod.d.cts +1 -1
- package/dist/compat/mod.d.ts +1 -1
- package/dist/compat/transformers.test.mjs +1 -1
- package/dist/{context-DLLaDau8.d.ts → context-DE2YrQwM.d.ts} +56 -13
- package/dist/{context-BNwv9Q1v.d.cts → context-y6ZUQCMf.d.cts} +56 -13
- package/dist/{deno-BATJ1hq6.mjs → deno-L23b3Hba.mjs} +1 -1
- package/dist/docloader-DUXr9k_O.mjs +124 -0
- package/dist/federation/attachment-responses.test.d.mts +2 -0
- package/dist/federation/attachment-responses.test.mjs +182 -0
- package/dist/federation/builder.test.mjs +1 -1
- package/dist/federation/collection.test.mjs +1 -1
- package/dist/federation/delivery-attachments.test.d.mts +2 -0
- package/dist/federation/delivery-attachments.test.mjs +280 -0
- package/dist/federation/handler.test.mjs +208 -16
- package/dist/federation/idempotency.test.mjs +2 -2
- package/dist/federation/inbox.test.mjs +1 -1
- package/dist/federation/middleware.test.mjs +1559 -26
- package/dist/federation/mod.cjs +1 -1
- package/dist/federation/mod.d.cts +2 -2
- package/dist/federation/mod.d.ts +2 -2
- package/dist/federation/mod.js +1 -1
- package/dist/federation/negotiation.test.mjs +1 -1
- package/dist/federation/retry.test.mjs +1 -1
- package/dist/federation/send.test.mjs +723 -68
- package/dist/federation/temporal.test.mjs +25 -1
- package/dist/federation/webfinger.test.mjs +1 -1
- package/dist/{http-CK3efjgM.js → http-BtbMAgTA.js} +176 -105
- package/dist/{http-Dl00HXr4.d.ts → http-C8qLHs_Z.d.cts} +3 -4
- package/dist/{http-BoR1M3W7.cjs → http-D5woFKA_.cjs} +177 -106
- package/dist/{http-DqZhyEso.d.cts → http-D8WmcRAF.d.ts} +3 -4
- package/dist/{http-Bjd6I92u.mjs → http-HX6wVyJh.mjs} +198 -98
- package/dist/{inbox-9MlBGgs9.mjs → inbox-CL7A0HXT.mjs} +1 -1
- package/dist/{key-ClQh9Qqh.mjs → key-Dai3f5yI.mjs} +3 -2
- package/dist/{kv-cache-BxSx_Iyp.cjs → kv-cache-B0V_e231.cjs} +59 -17
- package/dist/{kv-cache-ImApO425.js → kv-cache-BsDg-cT8.js} +60 -18
- package/dist/{ld-Crg0Xmwr.mjs → ld-DN6x1iZ8.mjs} +153 -21
- package/dist/ld-signature-DoZcbsZR.mjs +23 -0
- package/dist/{middleware-jL9p9V9G.cjs → middleware-Cl6k5Hrm.cjs} +1 -1
- package/dist/{middleware-CmD3lpy4.cjs → middleware-CrfRuKCf.cjs} +728 -143
- package/dist/{middleware-CE0b69gj.mjs → middleware-DiquMgtt.mjs} +444 -115
- package/dist/{middleware-C2AJFk8W.js → middleware-DunNtbo9.js} +727 -143
- package/dist/{middleware-Bi5D6DBT.mjs → middleware-SnQS8eIb.mjs} +1 -1
- package/dist/{mod-DiuFTYUt.d.cts → mod-CehHJOV4.d.cts} +30 -13
- package/dist/{mod-CWJNbyju.d.ts → mod-DLJpnqdw.d.ts} +1 -1
- package/dist/{mod-BLDHhuW0.d.ts → mod-Mh3oIuRK.d.ts} +30 -13
- package/dist/{mod-DNEgTI8M.d.ts → mod-REfljt0T.d.ts} +4 -9
- package/dist/{mod-Cn9GJ5ex.d.cts → mod-UvIGUHqW.d.cts} +4 -9
- package/dist/{mod-BmlfRBmU.d.cts → mod-sTa1Zzxk.d.cts} +1 -1
- package/dist/mod.cjs +5 -5
- package/dist/mod.d.cts +8 -8
- package/dist/mod.d.ts +8 -8
- package/dist/mod.js +5 -5
- package/dist/nodeinfo/client.test.mjs +764 -19
- package/dist/nodeinfo/handler.test.mjs +1 -1
- package/dist/nodeinfo/mod.cjs +1 -1
- package/dist/nodeinfo/mod.d.cts +1 -1
- package/dist/nodeinfo/mod.d.ts +1 -1
- package/dist/nodeinfo/mod.js +1 -1
- package/dist/nodeinfo/types.test.mjs +1 -1
- package/dist/otel/exporter.test.mjs +292 -30
- package/dist/otel/mod.cjs +36 -30
- package/dist/otel/mod.d.cts +13 -0
- package/dist/otel/mod.d.ts +13 -0
- package/dist/otel/mod.js +36 -30
- package/dist/{owner-BRoKojK1.mjs → owner-DwyDorZI.mjs} +2 -2
- package/dist/{proof-CHXVlsH_.cjs → proof-Be-4K4jn.cjs} +193 -46
- package/dist/{proof-DMIAezxz.mjs → proof-DYjmyrHh.mjs} +38 -13
- package/dist/{proof-7R4s10TJ.js → proof-Du4-5SHY.js} +187 -46
- package/dist/send-BGSfQkIK.mjs +416 -0
- package/dist/sig/http.test.mjs +506 -2
- package/dist/sig/key-types.test.d.mts +218 -0
- package/dist/sig/key-types.test.mjs +8 -0
- package/dist/sig/key.test.mjs +2 -2
- package/dist/sig/ld.test.mjs +573 -8
- package/dist/sig/mod.cjs +2 -2
- package/dist/sig/mod.d.cts +3 -3
- package/dist/sig/mod.d.ts +3 -3
- package/dist/sig/mod.js +2 -2
- package/dist/sig/owner.test.mjs +1 -1
- package/dist/sig/proof.test.mjs +95 -3
- package/dist/{temporal-DR0JahMu.mjs → temporal-CNCchWly.mjs} +3 -5
- package/dist/testing/mod.d.mts +1 -2177
- package/dist/{types-DRPjmHVV.cjs → types-B5wRhemi.cjs} +187 -63
- package/dist/{types-miAYfiGO.js → types-CXy2lRVU.js} +188 -64
- package/dist/utils/docloader.test.mjs +316 -32
- package/dist/utils/mod.cjs +1 -1
- package/dist/utils/mod.d.cts +1 -1
- package/dist/utils/mod.d.ts +1 -1
- package/dist/utils/mod.js +1 -1
- package/package.json +7 -7
- package/dist/docloader-OLWc7P2D.mjs +0 -82
- package/dist/send-BHIt_8ia.mjs +0 -260
- /package/dist/{collection-BD6-SZ6O.mjs → collection-DnoYNwBC.mjs} +0 -0
- /package/dist/{negotiation-BehA2uul.mjs → negotiation-xb0QR3u_.mjs} +0 -0
- /package/dist/{retry-B_E3V_Dx.mjs → retry-CI1flGDD.mjs} +0 -0
- /package/dist/{types-DCP0WLdt.mjs → types-s4mCTGkT.mjs} +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import "@js-temporal/polyfill";
|
|
2
|
+
import "urlpattern-polyfill";
|
|
3
|
+
globalThis.addEventListener = () => {};
|
|
4
|
+
import { preloadedContexts } from "@fedify/vocab-runtime";
|
|
5
|
+
import { getLogger } from "@logtape/logtape";
|
|
6
|
+
import jsonld from "@fedify/vocab-runtime/jsonld";
|
|
7
|
+
//#region src/compat/attachment-arrays.ts
|
|
8
|
+
const logger = getLogger([
|
|
9
|
+
"fedify",
|
|
10
|
+
"compat",
|
|
11
|
+
"attachment-arrays"
|
|
12
|
+
]);
|
|
13
|
+
const MAX_DEPTH = 64;
|
|
14
|
+
const ATTACHMENT = "https://www.w3.org/ns/activitystreams#attachment";
|
|
15
|
+
const PROOF = "https://w3id.org/security#proof";
|
|
16
|
+
/** Recognizes JSON-LD maps without accepting arrays or scalar values. */
|
|
17
|
+
function isMap(value) {
|
|
18
|
+
return typeof value === "object" && value != null && !Array.isArray(value);
|
|
19
|
+
}
|
|
20
|
+
/** Copies only changed branches; cached vocabulary JSON belongs to its owner. */
|
|
21
|
+
function walk(value, depth = 0) {
|
|
22
|
+
if (depth >= MAX_DEPTH) throw new RangeError("JSON-LD nesting limit exceeded.");
|
|
23
|
+
if (Array.isArray(value)) {
|
|
24
|
+
const items = value.map((item) => walk(item, depth + 1));
|
|
25
|
+
return items.some((item, i) => item !== value[i]) ? items : value;
|
|
26
|
+
}
|
|
27
|
+
if (!isMap(value)) return value;
|
|
28
|
+
if (Object.hasOwn(value, "@value")) return value;
|
|
29
|
+
let result;
|
|
30
|
+
for (const [key, item] of Object.entries(value)) {
|
|
31
|
+
let next = key === "@context" ? item : walk(item, depth + 1);
|
|
32
|
+
if ((key === "attachment" || key === ATTACHMENT) && next != null && !Array.isArray(next) && !(isMap(next) && Object.hasOwn(next, "@list"))) next = [next];
|
|
33
|
+
if (next !== item) {
|
|
34
|
+
result ??= Object.assign(Object.create(null), value);
|
|
35
|
+
result[key] = next;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
return result ?? value;
|
|
39
|
+
}
|
|
40
|
+
const preloadedLoader = (url) => {
|
|
41
|
+
if (!Object.hasOwn(preloadedContexts, url)) return Promise.reject(/* @__PURE__ */ new Error("Unknown JSON-LD context: " + url));
|
|
42
|
+
return Promise.resolve({
|
|
43
|
+
contextUrl: null,
|
|
44
|
+
documentUrl: url,
|
|
45
|
+
document: preloadedContexts[url]
|
|
46
|
+
});
|
|
47
|
+
};
|
|
48
|
+
/** Reuses each context resolution across the complete equivalence check. */
|
|
49
|
+
function memoizeLoader(loader) {
|
|
50
|
+
const pending = /* @__PURE__ */ new Map();
|
|
51
|
+
return (url, options) => {
|
|
52
|
+
let result = pending.get(url);
|
|
53
|
+
if (result == null) {
|
|
54
|
+
result = loader(url, options);
|
|
55
|
+
pending.set(url, result);
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/** Finds security predicates in expanded nodes, never inside JSON literals. */
|
|
61
|
+
function hasSecurityPredicate(value) {
|
|
62
|
+
if (Array.isArray(value)) return value.some(hasSecurityPredicate);
|
|
63
|
+
if (!isMap(value) || Object.hasOwn(value, "@value")) return false;
|
|
64
|
+
for (const [key, child] of Object.entries(value)) {
|
|
65
|
+
if (key === PROOF || key === "https://w3id.org/security#signature") return true;
|
|
66
|
+
if (hasSecurityPredicate(child)) return true;
|
|
67
|
+
}
|
|
68
|
+
return false;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Keeps singleton attachments in arrays for raw-JSON ActivityPub consumers.
|
|
72
|
+
* Mastodon's property_values() ignores valid compact JSON-LD scalar values,
|
|
73
|
+
* and its caller clears the profile fields in that case:
|
|
74
|
+
* https://github.com/mastodon/mastodon/blob/594166519a623584920c7e696bae9a009d9183ab/app/services/activitypub/process_account_service.rb#L465-L472
|
|
75
|
+
* Pixelfed likewise rejects singleton media attachments:
|
|
76
|
+
* https://github.com/pixelfed/pixelfed/issues/6588
|
|
77
|
+
*
|
|
78
|
+
* This workaround changes only attachment representation, after serialization.
|
|
79
|
+
* RDF equality protects custom contexts, including JSON literals; it does not
|
|
80
|
+
* protect JCS signatures. Any semantic proof or Linked Data signature leaves
|
|
81
|
+
* the whole serialized document unchanged, as does an unresolved context.
|
|
82
|
+
* This layer does not compose signed objects or repair vocabulary serialization.
|
|
83
|
+
* Remove this
|
|
84
|
+
* workaround only when the supported consumer versions, including deployed
|
|
85
|
+
* older releases, accept scalar attachments. Do not replace it with a
|
|
86
|
+
* vocabulary transformer: subsequent compaction collapses arrays.
|
|
87
|
+
* @internal
|
|
88
|
+
*/
|
|
89
|
+
async function normalizeAttachmentArrays(document, contextLoader) {
|
|
90
|
+
try {
|
|
91
|
+
const normalized = walk(document);
|
|
92
|
+
if (normalized === document) return document;
|
|
93
|
+
const loader = memoizeLoader(contextLoader ?? preloadedLoader);
|
|
94
|
+
if (hasSecurityPredicate(await jsonld.expand(document, { documentLoader: loader }))) return document;
|
|
95
|
+
const [before, after] = await Promise.allSettled([jsonld.canonize(document, {
|
|
96
|
+
format: "application/n-quads",
|
|
97
|
+
documentLoader: loader
|
|
98
|
+
}), jsonld.canonize(normalized, {
|
|
99
|
+
format: "application/n-quads",
|
|
100
|
+
documentLoader: loader
|
|
101
|
+
})]);
|
|
102
|
+
if (before.status === "rejected") throw before.reason;
|
|
103
|
+
if (after.status === "rejected") throw after.reason;
|
|
104
|
+
if (before.value === after.value) return normalized;
|
|
105
|
+
} catch (error) {
|
|
106
|
+
logger.debug("Could not safely normalize attachment arrays; preserving the document: {error}", { error });
|
|
107
|
+
}
|
|
108
|
+
return document;
|
|
109
|
+
}
|
|
110
|
+
//#endregion
|
|
111
|
+
export { normalizeAttachmentArrays as t };
|
|
@@ -2,8 +2,8 @@ import "@js-temporal/polyfill";
|
|
|
2
2
|
import "urlpattern-polyfill";
|
|
3
3
|
globalThis.addEventListener = () => {};
|
|
4
4
|
import { n as RouterError, t as Router } from "./router-CrMLXoOr.mjs";
|
|
5
|
-
import { n as version, t as name } from "./deno-
|
|
6
|
-
import { t as InboxListenerSet } from "./inbox-
|
|
5
|
+
import { n as version, t as name } from "./deno-L23b3Hba.mjs";
|
|
6
|
+
import { t as InboxListenerSet } from "./inbox-CL7A0HXT.mjs";
|
|
7
7
|
import { getTypeId } from "@fedify/vocab";
|
|
8
8
|
import { SpanKind, SpanStatusCode, trace } from "@opentelemetry/api";
|
|
9
9
|
import { getLogger } from "@logtape/logtape";
|
|
@@ -44,7 +44,7 @@ var FederationBuilderImpl = class {
|
|
|
44
44
|
this.collectionTypeIds = {};
|
|
45
45
|
}
|
|
46
46
|
async build(options) {
|
|
47
|
-
const { FederationImpl } = await import("./middleware-
|
|
47
|
+
const { FederationImpl } = await import("./middleware-SnQS8eIb.mjs");
|
|
48
48
|
const f = new FederationImpl(options);
|
|
49
49
|
const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
|
|
50
50
|
f.router = this.router.clone();
|