@fedify/fedify 2.3.0-dev.1137 → 2.3.0-dev.1150

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.
Files changed (68) hide show
  1. package/dist/{builder-BCkBXxky.mjs → builder-Bjm1Jq9n.mjs} +2 -2
  2. package/dist/compat/mod.d.cts +1 -1
  3. package/dist/compat/mod.d.ts +1 -1
  4. package/dist/compat/transformers.test.mjs +1 -1
  5. package/dist/{context-DI2gRbyN.d.cts → context-CRXCkTM6.d.cts} +48 -6
  6. package/dist/{context-DCtsSHDv.d.ts → context-MgCh7YGu.d.ts} +48 -6
  7. package/dist/{deno-B_9yJW3w.mjs → deno-CKFE6Uya.mjs} +1 -1
  8. package/dist/{docloader-BT89tyFr.mjs → docloader-B-ZE1cZf.mjs} +2 -2
  9. package/dist/federation/builder.test.mjs +1 -1
  10. package/dist/federation/handler.test.mjs +1363 -44
  11. package/dist/federation/idempotency.test.mjs +2 -2
  12. package/dist/federation/metrics.test.mjs +60 -1
  13. package/dist/federation/middleware.test.mjs +1667 -163
  14. package/dist/federation/mod.cjs +1 -1
  15. package/dist/federation/mod.d.cts +2 -2
  16. package/dist/federation/mod.d.ts +2 -2
  17. package/dist/federation/mod.js +1 -1
  18. package/dist/federation/retry.test.mjs +1 -1
  19. package/dist/federation/send.test.mjs +8 -8
  20. package/dist/federation/temporal.test.d.mts +2 -0
  21. package/dist/federation/temporal.test.mjs +71 -0
  22. package/dist/federation/webfinger.test.mjs +147 -2
  23. package/dist/{getMachineId-bsd-etIyxDet.mjs → getMachineId-bsd-BY01PL1n.mjs} +1 -1
  24. package/dist/{getMachineId-darwin-D23zTf4g.mjs → getMachineId-darwin-Dr1gkBkp.mjs} +1 -1
  25. package/dist/{getMachineId-win-Dpap6v5i.mjs → getMachineId-win-QEYwcJiy.mjs} +1 -1
  26. package/dist/{http-CWoeyogl.cjs → http-DQYEA7AZ.cjs} +53 -1
  27. package/dist/{http-CToqG5ap.js → http-WbS1gKzr.js} +48 -2
  28. package/dist/{http-Cyx5SNuu.mjs → http-vHCgbhTg.mjs} +3 -3
  29. package/dist/{key-CkkMJBjF.mjs → key-N0zP_oJA.mjs} +2 -2
  30. package/dist/{kv-cache-CuCn2xvM.js → kv-cache-DM2O-Yjy.js} +1 -1
  31. package/dist/{kv-cache-DuEwFYcN.cjs → kv-cache-Dsg_bi4N.cjs} +1 -1
  32. package/dist/{kv-cache-VHFP42vY.mjs → kv-cache-GXXZEemD.mjs} +1 -1
  33. package/dist/{ld-k8yqD2a-.mjs → ld-BwKhquPx.mjs} +302 -6
  34. package/dist/{metrics-iRBg8jTk.mjs → metrics-7Vy9FvEw.mjs} +48 -2
  35. package/dist/{middleware-D7FrhN9q.js → middleware-BscgvU-m.js} +496 -115
  36. package/dist/{middleware-BWLUrbS9.cjs → middleware-D_iXrYHJ.cjs} +497 -115
  37. package/dist/{middleware-CztxpARM.mjs → middleware-Db1_qAFG.mjs} +1 -1
  38. package/dist/{middleware-DQEgdr83.mjs → middleware-ZuUcO0t1.mjs} +416 -124
  39. package/dist/{mod-C504qevA.d.cts → mod-C7HOzGqH.d.cts} +11 -2
  40. package/dist/{mod-wYfuXeDE.d.ts → mod-CpQHB3Ys.d.ts} +11 -2
  41. package/dist/mod.cjs +4 -4
  42. package/dist/mod.d.cts +2 -2
  43. package/dist/mod.d.ts +2 -2
  44. package/dist/mod.js +4 -4
  45. package/dist/nodeinfo/handler.test.mjs +1 -1
  46. package/dist/{owner-nmXdvXpc.mjs → owner-FD0H_vpj.mjs} +2 -2
  47. package/dist/{proof-CcsIJLTn.cjs → proof-CYK8T8IS.cjs} +353 -3
  48. package/dist/{proof-NRmtrTDu.js → proof-I3EokKN-.js} +300 -4
  49. package/dist/{proof-DpwO1T4S.mjs → proof-V_lafPmA.mjs} +3 -3
  50. package/dist/{send-DvX2tYyZ.mjs → send-Cc2_10tF.mjs} +3 -3
  51. package/dist/sig/http.test.mjs +2 -2
  52. package/dist/sig/key.test.mjs +1 -1
  53. package/dist/sig/ld.test.mjs +558 -2
  54. package/dist/sig/mod.cjs +2 -2
  55. package/dist/sig/mod.js +2 -2
  56. package/dist/sig/owner.test.mjs +1 -1
  57. package/dist/sig/proof.test.mjs +1 -1
  58. package/dist/temporal-BkmBfs__.mjs +95 -0
  59. package/dist/testing/mod.d.mts +48 -6
  60. package/dist/utils/docloader.test.mjs +2 -2
  61. package/dist/utils/kv-cache.test.mjs +1 -1
  62. package/dist/utils/mod.cjs +1 -1
  63. package/dist/utils/mod.js +1 -1
  64. package/package.json +6 -6
  65. /package/dist/{execAsync-DCBrgFiV.mjs → execAsync-Dxb7rNf3.mjs} +0 -0
  66. /package/dist/{getMachineId-linux-ObI47Hql.mjs → getMachineId-linux-Bbhofx-s.mjs} +0 -0
  67. /package/dist/{getMachineId-unsupported-Ddu-PFeh.mjs → getMachineId-unsupported-dIOte2Ct.mjs} +0 -0
  68. /package/dist/{retry-v_sGLH1d.mjs → retry-_VvV0h9f.mjs} +0 -0
@@ -0,0 +1,95 @@
1
+ import { Temporal } from "@js-temporal/polyfill";
2
+ import "urlpattern-polyfill";
3
+ globalThis.addEventListener = () => {};
4
+ import { c as getNormalizationContextLoader } from "./ld-BwKhquPx.mjs";
5
+ import jsonld from "@fedify/vocab-runtime/jsonld";
6
+ //#region src/federation/temporal.ts
7
+ function isPlainObject(value) {
8
+ return typeof value === "object" && value != null && !Array.isArray(value);
9
+ }
10
+ function normalizeDateTimeLiteral(value) {
11
+ return value.substring(19).match(/[Z+-]/) ? value : value + "Z";
12
+ }
13
+ function isMalformedDateTimeLiteral(value) {
14
+ if (typeof value !== "string") return false;
15
+ try {
16
+ Temporal.Instant.from(normalizeDateTimeLiteral(value));
17
+ return false;
18
+ } catch {
19
+ return true;
20
+ }
21
+ }
22
+ function isMalformedDurationLiteral(value) {
23
+ if (typeof value !== "string") return false;
24
+ try {
25
+ Temporal.Duration.from(value);
26
+ return false;
27
+ } catch {
28
+ return true;
29
+ }
30
+ }
31
+ const TEMPORAL_DATE_TIME_IRIS = new Set([
32
+ "https://www.w3.org/ns/activitystreams#deleted",
33
+ "https://www.w3.org/ns/activitystreams#endTime",
34
+ "https://www.w3.org/ns/activitystreams#published",
35
+ "https://www.w3.org/ns/activitystreams#startTime",
36
+ "https://www.w3.org/ns/activitystreams#updated",
37
+ "http://purl.org/dc/terms/created",
38
+ "https://w3id.org/security#created"
39
+ ]);
40
+ const TEMPORAL_DURATION_IRIS = new Set(["https://www.w3.org/ns/activitystreams#duration"]);
41
+ const QUESTION_CLOSED_IRI = "https://www.w3.org/ns/activitystreams#closed";
42
+ const XSD_DATE_TIME_IRI = "http://www.w3.org/2001/XMLSchema#dateTime";
43
+ function hasMalformedExpandedDateTimeLiteral(value) {
44
+ if (Array.isArray(value)) return value.some(hasMalformedExpandedDateTimeLiteral);
45
+ return isPlainObject(value) && "@value" in value && isMalformedDateTimeLiteral(value["@value"]);
46
+ }
47
+ function hasMalformedExpandedQuestionClosedLiteral(value) {
48
+ if (Array.isArray(value)) return value.some(hasMalformedExpandedQuestionClosedLiteral);
49
+ if (!isPlainObject(value) || !("@value" in value)) return false;
50
+ const literal = value["@value"];
51
+ if (typeof literal === "boolean") return false;
52
+ if (typeof literal !== "string") return false;
53
+ if (value["@type"] !== XSD_DATE_TIME_IRI) return false;
54
+ if (new Date(literal).toString() === "Invalid Date") return false;
55
+ return isMalformedDateTimeLiteral(literal);
56
+ }
57
+ function hasMalformedExpandedDurationLiteral(value) {
58
+ if (Array.isArray(value)) return value.some(hasMalformedExpandedDurationLiteral);
59
+ return isPlainObject(value) && "@value" in value && isMalformedDurationLiteral(value["@value"]);
60
+ }
61
+ function hasMalformedKnownTemporalLiteralInternal(value, visited) {
62
+ if (Array.isArray(value)) return value.some((item) => hasMalformedKnownTemporalLiteralInternal(item, visited));
63
+ if (!isPlainObject(value)) return false;
64
+ if (visited.has(value)) return false;
65
+ visited.add(value);
66
+ if ("@value" in value) return false;
67
+ for (const [key, child] of Object.entries(value)) {
68
+ if (TEMPORAL_DATE_TIME_IRIS.has(key)) {
69
+ if (hasMalformedExpandedDateTimeLiteral(child)) return true;
70
+ continue;
71
+ }
72
+ if (key === QUESTION_CLOSED_IRI) {
73
+ if (hasMalformedExpandedQuestionClosedLiteral(child)) return true;
74
+ continue;
75
+ }
76
+ if (TEMPORAL_DURATION_IRIS.has(key)) {
77
+ if (hasMalformedExpandedDurationLiteral(child)) return true;
78
+ continue;
79
+ }
80
+ if (hasMalformedKnownTemporalLiteralInternal(child, visited)) return true;
81
+ }
82
+ return false;
83
+ }
84
+ async function hasMalformedKnownTemporalLiteral(value, contextLoader) {
85
+ try {
86
+ return hasMalformedKnownTemporalLiteralInternal(await jsonld.expand(value, {
87
+ documentLoader: getNormalizationContextLoader(contextLoader),
88
+ keepFreeFloatingNodes: true
89
+ }), /* @__PURE__ */ new Set());
90
+ } catch {
91
+ return false;
92
+ }
93
+ }
94
+ //#endregion
95
+ export { hasMalformedKnownTemporalLiteral as t };
@@ -618,6 +618,42 @@ interface InboxMessage {
618
618
  readonly id: ReturnType<typeof crypto.randomUUID>;
619
619
  readonly baseUrl: string;
620
620
  readonly activity: unknown;
621
+ /**
622
+ * The normalized JSON-LD representation of a signed inbox activity that
623
+ * Fedify already compacted successfully while accepting the request. Queue
624
+ * workers can reuse this producer-side parse cache under stricter loader or
625
+ * network constraints without changing the raw payload preserved for
626
+ * forwarding.
627
+ *
628
+ * This may exist even when {@link ldSignatureVerified} is `false`, because
629
+ * fallback-authenticated traffic and already-queued backlog items can still
630
+ * depend on the cached normalized form to avoid re-fetching remote custom
631
+ * contexts during worker processing.
632
+ *
633
+ * This is optional for backward compatibility with messages that were
634
+ * queued by older Fedify versions or that were already in a queue before
635
+ * upgrading.
636
+ *
637
+ * Fedify keeps this on the queued message itself instead of an external
638
+ * sidecar because generic queue backends do not provide reliable lifecycle
639
+ * guarantees for auxiliary storage across retries and redeliveries.
640
+ *
641
+ * @internal
642
+ */
643
+ readonly normalizedActivity?: unknown;
644
+ /**
645
+ * Whether the producer actually verified the Linked Data Signature before
646
+ * queueing this message. This lets workers distinguish verified LDS replay
647
+ * from other authenticated inbox traffic that merely happened to include a
648
+ * signature block. This provenance marker is separate from the optional
649
+ * normalizedActivity parse cache.
650
+ *
651
+ * `undefined` preserves backward compatibility with older queued messages
652
+ * that predate this marker.
653
+ *
654
+ * @internal
655
+ */
656
+ readonly ldSignatureVerified?: boolean;
621
657
  readonly started: string;
622
658
  readonly attempt: number;
623
659
  readonly identifier: string | null;
@@ -2011,9 +2047,12 @@ interface InboxContext<TContextData> extends Context<TContextData> {
2011
2047
  * Forwards a received activity to the recipients' inboxes. The forwarded
2012
2048
  * activity will be signed in HTTP Signatures by the forwarder, but its
2013
2049
  * payload will not be modified, i.e., Linked Data Signatures and Object
2014
- * Integrity Proofs will not be added. Therefore, if the activity is not
2015
- * signed (i.e., it has neither Linked Data Signatures nor Object Integrity
2016
- * Proofs), the recipient probably will not trust the activity.
2050
+ * Integrity Proofs will not be added. Even when Fedify internally
2051
+ * normalizes a Linked Data Signature activity for parsing, this method still
2052
+ * forwards the original received payload so the sender's signatures/proofs
2053
+ * are preserved as-is. Therefore, if the activity is not signed (i.e., it
2054
+ * has neither Linked Data Signatures nor Object Integrity Proofs), the
2055
+ * recipient probably will not trust the activity.
2017
2056
  * @param forwarder The forwarder's identifier or the forwarder's username
2018
2057
  * or the forwarder's key pair(s).
2019
2058
  * @param recipients The recipients of the activity.
@@ -2029,9 +2068,12 @@ interface InboxContext<TContextData> extends Context<TContextData> {
2029
2068
  * Forwards a received activity to the recipients' inboxes. The forwarded
2030
2069
  * activity will be signed in HTTP Signatures by the forwarder, but its
2031
2070
  * payload will not be modified, i.e., Linked Data Signatures and Object
2032
- * Integrity Proofs will not be added. Therefore, if the activity is not
2033
- * signed (i.e., it has neither Linked Data Signatures nor Object Integrity
2034
- * Proofs), the recipient probably will not trust the activity.
2071
+ * Integrity Proofs will not be added. Even when Fedify internally
2072
+ * normalizes a Linked Data Signature activity for parsing, this method still
2073
+ * forwards the original received payload so the sender's signatures/proofs
2074
+ * are preserved as-is. Therefore, if the activity is not signed (i.e., it
2075
+ * has neither Linked Data Signatures nor Object Integrity Proofs), the
2076
+ * recipient probably will not trust the activity.
2035
2077
  * @param forwarder The forwarder's identifier or the forwarder's username.
2036
2078
  * @param recipients In this case, it must be `"followers"`.
2037
2079
  * @param options Options for forwarding the activity.
@@ -5,9 +5,9 @@ import { t as assertEquals } from "../assert_equals-C-ZRDbaf.mjs";
5
5
  import "../std__assert-BBjXFNOb.mjs";
6
6
  import { t as assertRejects } from "../assert_rejects-DN60FHPX.mjs";
7
7
  import { t as esm_default } from "../esm-BQRw925N.mjs";
8
- import { l as verifyRequest } from "../http-Cyx5SNuu.mjs";
8
+ import { l as verifyRequest } from "../http-vHCgbhTg.mjs";
9
9
  import { i as rsaPrivateKey2 } from "../keys-C3kae-6B.mjs";
10
- import { t as getAuthenticatedDocumentLoader } from "../docloader-BT89tyFr.mjs";
10
+ import { t as getAuthenticatedDocumentLoader } from "../docloader-B-ZE1cZf.mjs";
11
11
  import { mockDocumentLoader, test } from "@fedify/fixture";
12
12
  import { UrlError } from "@fedify/vocab-runtime";
13
13
  //#region src/utils/docloader.test.ts
@@ -1,7 +1,7 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
- import { n as kvCache, t as MockKvStore } from "../kv-cache-VHFP42vY.mjs";
4
+ import { n as kvCache, t as MockKvStore } from "../kv-cache-GXXZEemD.mjs";
5
5
  import { deepStrictEqual, throws } from "node:assert";
6
6
  import { createTestMeterProvider, mockDocumentLoader, test } from "@fedify/fixture";
7
7
  import { preloadedContexts } from "@fedify/vocab-runtime";
@@ -1,6 +1,6 @@
1
1
  const { Temporal } = require("@js-temporal/polyfill");
2
2
  const { URLPattern } = require("urlpattern-polyfill");
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
4
- const require_kv_cache = require("../kv-cache-DuEwFYcN.cjs");
4
+ const require_kv_cache = require("../kv-cache-Dsg_bi4N.cjs");
5
5
  exports.getAuthenticatedDocumentLoader = require_kv_cache.getAuthenticatedDocumentLoader;
6
6
  exports.kvCache = require_kv_cache.kvCache;
package/dist/utils/mod.js CHANGED
@@ -1,4 +1,4 @@
1
1
  import { Temporal } from "@js-temporal/polyfill";
2
2
  import { URLPattern } from "urlpattern-polyfill";
3
- import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-CuCn2xvM.js";
3
+ import { n as getAuthenticatedDocumentLoader, t as kvCache } from "../kv-cache-DM2O-Yjy.js";
4
4
  export { getAuthenticatedDocumentLoader, kvCache };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fedify/fedify",
3
- "version": "2.3.0-dev.1137+53a1f26d",
3
+ "version": "2.3.0-dev.1150+8db5848a",
4
4
  "description": "An ActivityPub server framework",
5
5
  "keywords": [
6
6
  "ActivityPub",
@@ -151,10 +151,10 @@
151
151
  "jsonld": "^9.0.0",
152
152
  "structured-field-values": "^2.0.4",
153
153
  "urlpattern-polyfill": "^10.1.0",
154
- "@fedify/vocab-runtime": "2.3.0-dev.1137+53a1f26d",
155
- "@fedify/webfinger": "2.3.0-dev.1137+53a1f26d",
156
- "@fedify/vocab": "2.3.0-dev.1137+53a1f26d",
157
- "@fedify/uri-template": "2.3.0-dev.1137+53a1f26d"
154
+ "@fedify/uri-template": "2.3.0-dev.1150+8db5848a",
155
+ "@fedify/vocab": "2.3.0-dev.1150+8db5848a",
156
+ "@fedify/webfinger": "2.3.0-dev.1150+8db5848a",
157
+ "@fedify/vocab-runtime": "2.3.0-dev.1150+8db5848a"
158
158
  },
159
159
  "devDependencies": {
160
160
  "@opentelemetry/sdk-metrics": "2.7.1",
@@ -168,7 +168,7 @@
168
168
  "typescript": "^6.0.0",
169
169
  "wrangler": "^4.17.0",
170
170
  "@fedify/fixture": "2.0.0",
171
- "@fedify/vocab-tools": "^2.3.0-dev.1137+53a1f26d"
171
+ "@fedify/vocab-tools": "^2.3.0-dev.1150+8db5848a"
172
172
  },
173
173
  "scripts": {
174
174
  "build:self": "tsdown",
File without changes