@fedify/fedify 2.5.0-dev.2440 → 2.5.0-dev.2448

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 (117) hide show
  1. package/dist/{activity-listener-C-BSbKI7.mjs → activity-listener-CELFAodc.mjs} +8 -4
  2. package/dist/{builder-CTasaZgj.mjs → builder-DbC8bn6k.mjs} +5 -5
  3. package/dist/compat/mod.d.cts +1 -1
  4. package/dist/compat/mod.d.ts +1 -1
  5. package/dist/compat/transformers.test.mjs +1 -1
  6. package/dist/{compound-proof-D5r-dQMr.mjs → compound-proof-heeXW2_A.mjs} +2 -2
  7. package/dist/{context-DPocjp1l.d.cts → context-BazwQrHn.d.cts} +307 -5
  8. package/dist/{context-8Tu9kea0.mjs → context-COHd1Rsh.mjs} +2 -0
  9. package/dist/{context-2wLkQrjb.d.ts → context-GlHrzdSP.d.ts} +307 -5
  10. package/dist/{deno-DR1uYWpm.mjs → deno-Dpewt_jJ.mjs} +1 -1
  11. package/dist/{docloader-BpCJ2dHm.mjs → docloader-CpsDyqVN.mjs} +2 -2
  12. package/dist/federation/builder.test.mjs +1 -1
  13. package/dist/federation/compound-fanout.test.mjs +3 -3
  14. package/dist/federation/handler-compound-proof.test.mjs +5 -5
  15. package/dist/federation/handler.test.mjs +21 -6
  16. package/dist/federation/hashlink-media.test.mjs +2 -2
  17. package/dist/federation/idempotency.test.mjs +2 -2
  18. package/dist/federation/inbox-actorless.test.d.mts +2 -0
  19. package/dist/federation/inbox-actorless.test.mjs +487 -0
  20. package/dist/federation/inbox-authentication.test.d.mts +2 -0
  21. package/dist/federation/inbox-authentication.test.mjs +116 -0
  22. package/dist/federation/inbox-report.test.mjs +5 -5
  23. package/dist/federation/inbox-view.test.d.mts +2 -0
  24. package/dist/federation/inbox-view.test.mjs +369 -0
  25. package/dist/federation/inbox.test.mjs +22 -12
  26. package/dist/federation/metrics.test.mjs +1 -1
  27. package/dist/federation/middleware.test.mjs +24 -9
  28. package/dist/federation/mod.cjs +2 -1
  29. package/dist/federation/mod.d.cts +3 -3
  30. package/dist/federation/mod.d.ts +3 -3
  31. package/dist/federation/mod.js +8 -2
  32. package/dist/federation/mq.test.mjs +36 -1
  33. package/dist/federation/outgoing-proof.test.mjs +4 -4
  34. package/dist/federation/portable-actor.test.mjs +3 -3
  35. package/dist/federation/portable-chain.test.mjs +3 -3
  36. package/dist/federation/portable-collection.test.mjs +4 -4
  37. package/dist/federation/portable-delivery.test.mjs +2 -2
  38. package/dist/federation/portable-gateway-keys.test.mjs +6 -6
  39. package/dist/federation/portable-inbox.test.mjs +4 -4
  40. package/dist/federation/portable-parse-uri.test.mjs +1 -1
  41. package/dist/federation/portable-route-activity.test.mjs +2 -2
  42. package/dist/federation/portable.test.mjs +3 -3
  43. package/dist/federation/send.test.mjs +3 -3
  44. package/dist/federation/tasks/enqueue.test.mjs +3 -3
  45. package/dist/federation/tasks/tasks.test.mjs +4 -4
  46. package/dist/federation/temporal.test.mjs +1 -1
  47. package/dist/federation/webfinger.test.mjs +2 -2
  48. package/dist/{federation-eYRUxkUW.cjs → federation-D8YexkP1.cjs} +1174 -132
  49. package/dist/{http-CgaoFGXV.js → http-BBr-VLil.js} +143 -16
  50. package/dist/{http-CRrg14tX.mjs → http-BZkyQIkb.mjs} +4 -4
  51. package/dist/{http-CmFHJm6o.cjs → http-CAl7Num5.cjs} +161 -16
  52. package/dist/inbox-authentication-DflPYlLL.mjs +171 -0
  53. package/dist/inbox-view-NE9wXdLo.mjs +385 -0
  54. package/dist/inbox-wDuMKaFW.mjs +312 -0
  55. package/dist/{kv-cache-MxJrD9gD.mjs → kv-cache-CTQSfkmp.mjs} +1 -1
  56. package/dist/{kv-cache-DvVRGOMw.cjs → kv-cache-CjgCOz3i.cjs} +1 -1
  57. package/dist/{kv-cache-DeagaIIB.js → kv-cache-U7uz5nx4.js} +1 -1
  58. package/dist/{ld-CUM16-EE.mjs → ld-CQFuiah9.mjs} +52 -9
  59. package/dist/ld-CcuZ4NZa.d.ts +250 -0
  60. package/dist/ld-Cel1RRZ5.d.cts +250 -0
  61. package/dist/{metrics-DIM8ZCKq.mjs → metrics-B-QxRSSR.mjs} +1 -1
  62. package/dist/{middleware-Bx_QxJ0s.mjs → middleware-BdlNa8BD.mjs} +1 -1
  63. package/dist/{middleware-CDdFG6xf.mjs → middleware-CuVa0UuS.mjs} +461 -99
  64. package/dist/{middleware-CGfFooYv.js → middleware-P-AZEQMn.js} +1171 -142
  65. package/dist/mod-B2783_3v.d.cts +154 -0
  66. package/dist/mod-BHQE-7WQ.d.ts +154 -0
  67. package/dist/{mod-Dm-7RdhR.d.ts → mod-DjZfJj9R.d.ts} +1 -1
  68. package/dist/{mod-DKGoPoQC.d.cts → mod-DvWOv2Ho.d.cts} +1 -1
  69. package/dist/mod.cjs +5 -4
  70. package/dist/mod.d.cts +6 -6
  71. package/dist/mod.d.ts +6 -6
  72. package/dist/mod.js +5 -5
  73. package/dist/{mq-Dm1Wmtm-.mjs → mq-eF96QxUT.mjs} +6 -0
  74. package/dist/nodeinfo/handler.test.mjs +2 -2
  75. package/dist/{owner-DoQDS_g0.mjs → owner-ccKkQOAf.mjs} +3 -3
  76. package/dist/{portable-collection-DiBqtGSM.mjs → portable-collection-CndnpXfo.mjs} +2 -2
  77. package/dist/{portable-collection-BVKSWfBe.js → portable-collection-DUlQ3s2M.js} +1 -1
  78. package/dist/{portable-collection-C-etRRF0.cjs → portable-collection-TC-kvkVI.cjs} +1 -1
  79. package/dist/{portable-key-DSRuCUpF.mjs → portable-key-D5tFOoV-.mjs} +1 -1
  80. package/dist/{proof-DWpruPWs.mjs → proof-DPoF06nz.mjs} +98 -10
  81. package/dist/{send-H0z9Ey5l.mjs → send-CF44O1Df.mjs} +3 -3
  82. package/dist/sig/compound-proof-discovery.test.mjs +1 -1
  83. package/dist/sig/compound-proof-producer.test.mjs +1 -1
  84. package/dist/sig/compound-proof-verification.test.mjs +2 -2
  85. package/dist/sig/compound-proof.test.mjs +2 -2
  86. package/dist/sig/http.test.mjs +2 -2
  87. package/dist/sig/key.test.mjs +1 -1
  88. package/dist/sig/ld.test.mjs +1 -1
  89. package/dist/sig/mitra-receive-interop.test.mjs +4 -4
  90. package/dist/sig/mitra-send-interop.test.mjs +3 -3
  91. package/dist/sig/mod.cjs +2 -2
  92. package/dist/sig/mod.d.cts +2 -2
  93. package/dist/sig/mod.d.ts +2 -2
  94. package/dist/sig/mod.js +2 -2
  95. package/dist/sig/owner.test.mjs +1 -1
  96. package/dist/sig/portable-collection.test.mjs +1 -1
  97. package/dist/sig/portable-interop.test.mjs +3 -3
  98. package/dist/sig/portable-key.test.mjs +5 -5
  99. package/dist/sig/proof.test.mjs +44 -4
  100. package/dist/sig/tootik-request-interop.test.mjs +4 -4
  101. package/dist/sig/tootik-send-interop.test.mjs +3 -3
  102. package/dist/sig/verification.test.mjs +3 -3
  103. package/dist/{temporal-BiSBCImA.mjs → temporal-XlZ4Wb94.mjs} +1 -1
  104. package/dist/testing/kv.test.mjs +1 -1
  105. package/dist/testing/mod.d.mts +265 -3
  106. package/dist/testing/mod.mjs +2 -2
  107. package/dist/{testing-t8xDeJZ5.mjs → testing-Dbr21vZk.mjs} +1 -1
  108. package/dist/utils/docloader.test.mjs +2 -2
  109. package/dist/utils/kv-cache.test.mjs +1 -1
  110. package/dist/utils/mod.cjs +1 -1
  111. package/dist/utils/mod.js +1 -1
  112. package/package.json +7 -7
  113. package/dist/inbox-BwPoSUEv.mjs +0 -188
  114. package/dist/mod-BRpER-B0.d.ts +0 -320
  115. package/dist/mod-xAfaLS4T.d.cts +0 -320
  116. package/dist/owner-BF0L9cMt.d.cts +0 -78
  117. package/dist/owner-BSzr5-I8.d.ts +0 -78
@@ -14,9 +14,12 @@ var ActivityListenerSet = class {
14
14
  clone.#listeners = new Map(this.#listeners);
15
15
  return clone;
16
16
  }
17
- add(type, listener) {
17
+ add(type, listener, options = {}) {
18
18
  if (this.#listeners.has(type)) throw new TypeError("Listener already set for this type.");
19
- this.#listeners.set(type, listener);
19
+ this.#listeners.set(type, {
20
+ listener,
21
+ options: { ...options }
22
+ });
20
23
  }
21
24
  dispatchWithClass(activity) {
22
25
  let cls = activity.constructor;
@@ -26,10 +29,11 @@ var ActivityListenerSet = class {
26
29
  cls = globalThis.Object.getPrototypeOf(cls);
27
30
  }
28
31
  if (cls == null) return null;
29
- const listener = this.#listeners.get(cls);
32
+ const { listener, options } = this.#listeners.get(cls);
30
33
  return {
31
34
  class: cls,
32
- listener
35
+ listener,
36
+ options
33
37
  };
34
38
  }
35
39
  dispatch(activity) {
@@ -2,8 +2,8 @@ import "temporal-polyfill";
2
2
  import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { i as getPortableDid, l as isPortableId, n as getCanonicalPortableId } from "./portable-key-id-Ca30-hOa.mjs";
5
- import { n as version, t as name } from "./deno-DR1uYWpm.mjs";
6
- import { t as ActivityListenerSet } from "./activity-listener-C-BSbKI7.mjs";
5
+ import { n as version, t as name } from "./deno-Dpewt_jJ.mjs";
6
+ import { t as ActivityListenerSet } from "./activity-listener-CELFAodc.mjs";
7
7
  import { getLogger } from "@logtape/logtape";
8
8
  import { Router, RouterError, assertPath } from "@fedify/uri-template";
9
9
  import { Tombstone, getTypeId } from "@fedify/vocab";
@@ -91,7 +91,7 @@ var FederationBuilderImpl = class {
91
91
  * specified.
92
92
  */
93
93
  async build(options) {
94
- const { FederationImpl } = await import("./middleware-Bx_QxJ0s.mjs");
94
+ const { FederationImpl } = await import("./middleware-BdlNa8BD.mjs");
95
95
  const f = new FederationImpl(options);
96
96
  const trailingSlashInsensitiveValue = f.router.trailingSlashInsensitive;
97
97
  f.router = this.router.clone();
@@ -590,8 +590,8 @@ var FederationBuilderImpl = class {
590
590
  }
591
591
  const listeners = this.inboxListeners = new ActivityListenerSet();
592
592
  const setters = {
593
- on(type, listener) {
594
- listeners.add(type, listener);
593
+ on(type, listener, options) {
594
+ listeners.add(type, listener, options);
595
595
  return setters;
596
596
  },
597
597
  onError: (handler) => {
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { en as ActivityTransformer, n as Context } from "../context-DPocjp1l.cjs";
2
+ import { in as ActivityTransformer, n as Context } from "../context-BazwQrHn.cjs";
3
3
  import { Activity } from "@fedify/vocab";
4
4
 
5
5
  //#region src/compat/transformers.d.ts
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { en as ActivityTransformer, n as Context } from "../context-2wLkQrjb.js";
2
+ import { in as ActivityTransformer, n as Context } from "../context-GlHrzdSP.js";
3
3
  import { Activity } from "@fedify/vocab";
4
4
 
5
5
  //#region src/compat/transformers.d.ts
@@ -5,7 +5,7 @@ import { t as MemoryKvStore } from "../kv-DCHkaJ9-.mjs";
5
5
  import { t as assertEquals } from "../assert_equals-Z6IcEbWU.mjs";
6
6
  import { t as assertInstanceOf } from "../assert_instance_of-mrXWWNY-.mjs";
7
7
  import { t as assert } from "../assert-D1Eafmd_.mjs";
8
- import { O as actorDehydrator, k as autoIdAssigner, n as FederationImpl } from "../middleware-CDdFG6xf.mjs";
8
+ import { O as actorDehydrator, k as autoIdAssigner, n as FederationImpl } from "../middleware-CuVa0UuS.mjs";
9
9
  import { Follow, Person } from "@fedify/vocab";
10
10
  import { test } from "@fedify/fixture";
11
11
  //#region src/compat/transformers.test.ts
@@ -3,9 +3,9 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { a as getRawCanonicalPortableId, l as isPortableId, n as getCanonicalPortableId } from "./portable-key-id-Ca30-hOa.mjs";
5
5
  import { a as verificationObservation, t as observeAttempt } from "./verification-Dpfcw8ml.mjs";
6
- import { c as getNormalizationContextLoader } from "./ld-CUM16-EE.mjs";
6
+ import { c as getNormalizationContextLoader } from "./ld-CQFuiah9.mjs";
7
7
  import { n as preloadedOnlyDocumentLoader } from "./public-audience--klBIOk1.mjs";
8
- import { a as preparePortableObjectProofPolicy, f as verifyPreparedPortableObjectProofPolicy, n as classifyFep2277CoreType, s as verifyMapLocalProof, u as verifyPortableObjectProofPolicy } from "./proof-DWpruPWs.mjs";
8
+ import { c as verifyMapLocalProof, f as verifyPortableObjectProofPolicy, m as verifyPreparedPortableObjectProofPolicy, n as classifyFep2277CoreType, o as preparePortableObjectProofPolicy } from "./proof-DPoF06nz.mjs";
9
9
  import { parseIri, preloadedContexts } from "@fedify/vocab-runtime";
10
10
  import jsonld from "@fedify/vocab-runtime/jsonld";
11
11
  //#region src/sig/compound-proof.ts
@@ -1,14 +1,43 @@
1
1
  /// <reference lib="esnext.temporal" />
2
2
  import { o as JsonValue, s as NodeInfo, t as GetNodeInfoOptions } from "./client-D-XP_Ccb.cjs";
3
3
  import { _ as InboxVerificationKey, d as InboxProofPolicyFailureReason, h as InboxVerificationAttempt, w as VerifyRequestFailureReason, y as HttpMessageSignaturesSpec } from "./key-nYGY4QB9.cjs";
4
- import { n as GetKeyOwnerOptions } from "./owner-BF0L9cMt.cjs";
4
+ import { m as GetKeyOwnerOptions, n as EffectiveContextLoaderPolicy } from "./ld-Cel1RRZ5.cjs";
5
5
  import { n as KvStore, t as KvKey } from "./kv-B2mzK5tl.cjs";
6
6
  import { Activity, Actor, Collection, CryptographicKey, Hashtag, Link, LookupObjectOptions, Multikey, Object as Object$1, Recipient, Tombstone, TraverseCollectionOptions } from "@fedify/vocab";
7
- import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions, PortableObjectVerifier } from "@fedify/vocab-runtime";
7
+ import { AuthenticatedDocumentLoaderFactory, DocumentLoader, DocumentLoaderFactory, GetUserAgentOptions, PortableObjectVerifier, RemoteDocument } from "@fedify/vocab-runtime";
8
8
  import { Link as Link$1, LookupWebFingerOptions, ResourceDescriptor } from "@fedify/webfinger";
9
9
  import { MeterProvider, Span, Tracer, TracerProvider } from "@opentelemetry/api";
10
10
  import { StandardSchemaV1 } from "@standard-schema/spec";
11
11
 
12
+ //#region src/federation/activity-listener.d.ts
13
+ /**
14
+ * Options for an inbox listener.
15
+ * @since 2.5.0
16
+ */
17
+ interface InboxListenerOptions {
18
+ /**
19
+ * Whether activities that declare no `actor` at all may reach the listener.
20
+ *
21
+ * Some protocols identify the requester without an `actor`; for example,
22
+ * Mastodon sends [FEP-7aa9] `FeatureRequest` activities without one. When
23
+ * this is `true`, such an activity is dispatched to the listener if Fedify
24
+ * authenticated at least one principal for it, i.e., the signer of its
25
+ * Object Integrity Proofs or Linked Data Signature, or otherwise the signer
26
+ * of the HTTP request, and its `id`, if any, has the same origin as that
27
+ * principal. The listener is then responsible for authorizing the request
28
+ * with {@link InboxContext.authentication}, e.g., with
29
+ * `featureInteraction.verifyRequest()` from
30
+ * `@fedify/interaction-controls`.
31
+ *
32
+ * An activity that declares an `actor` is never affected by this option;
33
+ * its actor must be authenticated as usual.
34
+ *
35
+ * [FEP-7aa9]: https://w3id.org/fep/7aa9
36
+ * @default `false`
37
+ */
38
+ readonly allowActorless?: boolean;
39
+ }
40
+ //#endregion
12
41
  //#region src/federation/inbox-report.d.ts
13
42
  /**
14
43
  * A JSON value retained from the incoming request.
@@ -51,6 +80,13 @@ type InboxAuthentication = {
51
80
  readonly type: "activityOriginMismatch";
52
81
  readonly activityId: URL;
53
82
  readonly actorIds: readonly URL[];
83
+ } | {
84
+ /**
85
+ * The activity declares no actor, and no principal was authenticated
86
+ * for it, although its listener allows activities without an actor.
87
+ * @since 2.5.0
88
+ */
89
+ readonly type: "noAuthenticatedPrincipal";
54
90
  };
55
91
  } | {
56
92
  readonly status: "skipped";
@@ -949,6 +985,18 @@ interface MessageQueue {
949
985
  */
950
986
  readonly atomicEnqueueMany?: boolean;
951
987
  /**
988
+ * The largest message, in bytes, that the backend can hold. Fedify compares
989
+ * it with a conservative estimate of a message's serialized size: the
990
+ * length of its JSON serialization encoded in UTF-8, plus 8 bytes for each
991
+ * JSON value in it, plus what encoding strings beyond Latin-1 as UTF-16
992
+ * adds, which also bounds binary serialization formats. When an
993
+ * incoming activity would make a larger inbox message, Fedify processes the
994
+ * activity right away instead of enqueueing it, as if there were no inbox
995
+ * queue. When omitted, messages are enqueued regardless of their size.
996
+ * @since 2.5.0
997
+ */
998
+ readonly maxMessageSize?: number;
999
+ /**
952
1000
  * Enqueues a message in the queue.
953
1001
  * @param message The message to enqueue.
954
1002
  * @param options Additional options for enqueuing the message.
@@ -1074,6 +1122,11 @@ declare class ParallelMessageQueue implements MessageQueue {
1074
1122
  * @since 2.4.0
1075
1123
  */
1076
1124
  readonly atomicEnqueueMany?: boolean;
1125
+ /**
1126
+ * Inherits the message size limit from the wrapped queue.
1127
+ * @since 2.5.0
1128
+ */
1129
+ readonly maxMessageSize?: number;
1077
1130
  readonly getDepth?: () => Promise<MessageQueueDepth>;
1078
1131
  /**
1079
1132
  * Constructs a new {@link ParallelMessageQueue} with the given queue and
@@ -1090,6 +1143,211 @@ declare class ParallelMessageQueue implements MessageQueue {
1090
1143
  listen(handler: (message: any) => Promise<void> | void, options?: MessageQueueListenOptions): Promise<void>;
1091
1144
  }
1092
1145
  //#endregion
1146
+ //#region src/federation/inbox-authentication.d.ts
1147
+ /**
1148
+ * A party that Fedify authenticated for an incoming activity, independently
1149
+ * of the activity's declared `actor`.
1150
+ * @since 2.5.0
1151
+ */
1152
+ interface InboxPrincipal {
1153
+ /**
1154
+ * What {@link InboxPrincipal.id} is:
1155
+ *
1156
+ * - `"actor"`: an actor whose ownership of the verifying key Fedify
1157
+ * confirmed with the actor's own document.
1158
+ * - `"portableAuthority"`: a DID whose verification method made a valid
1159
+ * Object Integrity Proof. It authenticates the [FEP-ef61] portable
1160
+ * actors of that DID, and nothing else.
1161
+ *
1162
+ * [FEP-ef61]: https://w3id.org/fep/ef61
1163
+ */
1164
+ readonly kind: "actor" | "portableAuthority";
1165
+ /** The actor ID, or the DID if {@link kind} is `"portableAuthority"`. */
1166
+ readonly id: URL;
1167
+ /**
1168
+ * How the principal was authenticated:
1169
+ *
1170
+ * - `"httpSignatures"`: it signed the HTTP request.
1171
+ * - `"linkedDataSignatures"`: it made the Linked Data Signature of the
1172
+ * activity.
1173
+ * - `"objectIntegrityProofs"`: it made an Object Integrity Proof of the
1174
+ * activity.
1175
+ * - `"origin"`: the activity was fetched again from the actor's own web
1176
+ * origin, which happens only for `Context.routeActivity()`.
1177
+ */
1178
+ readonly mechanism: "httpSignatures" | "linkedDataSignatures" | "objectIntegrityProofs" | "origin";
1179
+ /** The key or verification method that authenticated the principal. */
1180
+ readonly keyId: URL | null;
1181
+ }
1182
+ /**
1183
+ * Who Fedify authenticated for an incoming activity, and the interpretation of
1184
+ * the activity it authenticated. Inbox listeners receive it as
1185
+ * {@link InboxContext.authentication}.
1186
+ *
1187
+ * Authenticated principals are independent of the activity's declared
1188
+ * `actor`: an activity forwarded by a relay is signed by the relay in its
1189
+ * HTTP request, but its document may be signed by its author, and some
1190
+ * activities, such as [FEP-7aa9] `FeatureRequest`s sent by Mastodon, declare
1191
+ * no `actor` at all. A valid signature alone does not authorize anything;
1192
+ * use {@link isActorAuthenticated} to check whether a specific actor was
1193
+ * authenticated.
1194
+ *
1195
+ * [FEP-7aa9]: https://w3id.org/fep/7aa9
1196
+ * @since 2.5.0
1197
+ */
1198
+ interface InboxAuthenticationEvidence {
1199
+ /**
1200
+ * Whether signatures were verified at all. It is `false` only when
1201
+ * signature verification is skipped, or when there is no evidence, e.g.,
1202
+ * for an activity queued by an older version of Fedify. In that case all
1203
+ * the principal lists are empty.
1204
+ */
1205
+ readonly verified: boolean;
1206
+ /**
1207
+ * The principals that signed the HTTP request, i.e., the server that
1208
+ * delivered the activity, which may have forwarded it. It is empty when
1209
+ * the activity document was authenticated by its own signatures, so that
1210
+ * HTTP Signatures did not need to be verified.
1211
+ */
1212
+ readonly requestSigners: readonly InboxPrincipal[];
1213
+ /**
1214
+ * The principals that made the verified Linked Data Signature or Object
1215
+ * Integrity Proofs of the activity document. All of them are listed when
1216
+ * there are several proofs.
1217
+ */
1218
+ readonly documentSigners: readonly InboxPrincipal[];
1219
+ /**
1220
+ * The actors authenticated because `Context.routeActivity()` fetched the
1221
+ * activity again from their own web origin. It is always empty for
1222
+ * activities delivered to an inbox.
1223
+ */
1224
+ readonly originAuthenticated: readonly InboxPrincipal[];
1225
+ /**
1226
+ * The activity as Fedify interpreted it while authenticating it, in
1227
+ * expanded JSON-LD. Typed vocabulary objects omit some values, such as
1228
+ * blank node references and values they cannot decode, so authorization
1229
+ * that has to count every value of a property, e.g., that a property has
1230
+ * exactly one value, should inspect this instead. It is deeply frozen.
1231
+ * It is empty when there is no evidence.
1232
+ */
1233
+ readonly expandedActivity: readonly Record<string, unknown>[];
1234
+ /**
1235
+ * The base URL the activity was decoded with, e.g., the URL an activity
1236
+ * fetched by `Context.routeActivity()` was finally retrieved from, or
1237
+ * `null` if none was given. Relative IRIs left in
1238
+ * {@link expandedActivity} resolve against it, or against the activity's
1239
+ * own `@id` if it is `null`, as the decoder resolves them.
1240
+ */
1241
+ readonly baseUrl: URL | null;
1242
+ }
1243
+ /**
1244
+ * Options for {@link isActorAuthenticated}.
1245
+ * @since 2.5.0
1246
+ */
1247
+ interface IsActorAuthenticatedOptions {
1248
+ /**
1249
+ * Which principals to consider:
1250
+ *
1251
+ * - `"effective"` (default): the document signers if there are any,
1252
+ * otherwise the request signers if there are any, otherwise the actors
1253
+ * authenticated by their origin.
1254
+ * - `"document"`: the document signers only.
1255
+ */
1256
+ readonly scope?: "effective" | "document";
1257
+ }
1258
+ /**
1259
+ * Checks whether the given evidence authenticates the given actor.
1260
+ *
1261
+ * Actor IDs are compared exactly, except that [FEP-ef61] portable IDs and
1262
+ * compatible identifiers are compared by their canonical portable IDs, and
1263
+ * a portable authority (a DID) authenticates the portable actors of that DID.
1264
+ *
1265
+ * @example
1266
+ * ``` typescript
1267
+ * federation
1268
+ * .setInboxListeners("/users/{identifier}/inbox", "/inbox")
1269
+ * .on(Follow, async (ctx, follow) => {
1270
+ * if (follow.actorId == null) return;
1271
+ * // The actor is always authenticated for activities that declare one,
1272
+ * // but the same check works for any actor an activity names:
1273
+ * isActorAuthenticated(ctx.authentication, follow.actorId);
1274
+ * });
1275
+ * ```
1276
+ *
1277
+ * [FEP-ef61]: https://w3id.org/fep/ef61
1278
+ * @param evidence The authentication evidence, usually
1279
+ * {@link InboxContext.authentication}.
1280
+ * @param actorId The actor ID to check.
1281
+ * @param options Options.
1282
+ * @returns `true` if the actor is authenticated.
1283
+ * @since 2.5.0
1284
+ */
1285
+ declare function isActorAuthenticated(evidence: InboxAuthenticationEvidence, actorId: URL, options?: IsActorAuthenticatedOptions): boolean;
1286
+ /**
1287
+ * A {@link InboxPrincipal} as stored in a queued message.
1288
+ * @internal
1289
+ */
1290
+ interface SerializedInboxPrincipal {
1291
+ readonly kind: InboxPrincipal["kind"];
1292
+ readonly id: string;
1293
+ readonly mechanism: InboxPrincipal["mechanism"];
1294
+ readonly keyId: string | null;
1295
+ }
1296
+ /**
1297
+ * The principals of an {@link InboxAuthenticationEvidence} as stored in
1298
+ * a queued message. The expanded activity and the base URL are restored
1299
+ * from the queued verified view instead.
1300
+ * @internal
1301
+ */
1302
+ interface SerializedInboxAuthentication {
1303
+ readonly verified: boolean;
1304
+ readonly requestSigners: readonly SerializedInboxPrincipal[];
1305
+ readonly documentSigners: readonly SerializedInboxPrincipal[];
1306
+ readonly originAuthenticated: readonly SerializedInboxPrincipal[];
1307
+ }
1308
+ //#endregion
1309
+ //#region src/federation/inbox-view.d.ts
1310
+ /**
1311
+ * A {@link ContextSnapshotEntry} as stored in a queued message. A response
1312
+ * that equals the one Fedify bundles for the URL is stored as a reference to
1313
+ * the bundled context, along with its hash for diagnostics.
1314
+ * @internal
1315
+ */
1316
+ type SerializedContextSnapshotEntry = {
1317
+ readonly policy: EffectiveContextLoaderPolicy;
1318
+ readonly url: string; /** The SHA-256 of the canonical JSON of the whole response. */
1319
+ readonly sha256: string;
1320
+ } & ({
1321
+ readonly bundled: true;
1322
+ } | {
1323
+ readonly response: RemoteDocument;
1324
+ });
1325
+ /**
1326
+ * The interpretation of an incoming activity that Fedify authenticated, as
1327
+ * stored in a queued message. The document itself is not copied; it is
1328
+ * a field of the message.
1329
+ * @internal
1330
+ */
1331
+ interface SerializedVerifiedActivityView {
1332
+ /** The format version. */
1333
+ readonly version: 1;
1334
+ /** The context loader policy the activity was parsed with. */
1335
+ readonly policy: EffectiveContextLoaderPolicy;
1336
+ /**
1337
+ * Which document the activity was parsed from, with its Linked Data
1338
+ * Signature detached: the `activity` of the message, i.e., the payload as
1339
+ * received, or its `normalizedActivity`, i.e., the payload compacted for
1340
+ * Linked Data Signatures.
1341
+ */
1342
+ readonly source: "activity" | "normalizedActivity";
1343
+ /** The `baseUrl` option the activity was parsed with. */
1344
+ readonly baseUrl: string | null;
1345
+ /** The context responses the interpretation used. */
1346
+ readonly contexts: readonly SerializedContextSnapshotEntry[];
1347
+ /** The digest of the expanded activity. */
1348
+ readonly expandedDigest: string;
1349
+ }
1350
+ //#endregion
1093
1351
  //#region src/federation/handler.d.ts
1094
1352
  /**
1095
1353
  * Options for the {@link respondWithObject} and
@@ -1504,6 +1762,21 @@ interface InboxMessage {
1504
1762
  * @internal
1505
1763
  */
1506
1764
  readonly ldSignatureVerified?: boolean;
1765
+ /**
1766
+ * The interpretation of the activity that Fedify authenticated, i.e., which
1767
+ * document it was parsed from and every JSON-LD context response the parse
1768
+ * used, so that the worker and its retries dispatch the very same
1769
+ * interpretation without loading contexts again. Absent in messages queued
1770
+ * by older Fedify versions.
1771
+ * @internal
1772
+ */
1773
+ readonly verifiedView?: SerializedVerifiedActivityView;
1774
+ /**
1775
+ * Who Fedify authenticated for the activity. Absent in messages queued by
1776
+ * older Fedify versions.
1777
+ * @internal
1778
+ */
1779
+ readonly authentication?: SerializedInboxAuthentication;
1507
1780
  readonly started: string;
1508
1781
  readonly attempt: number;
1509
1782
  readonly identifier: string | null;
@@ -2884,11 +3157,27 @@ interface InboxListenerSetters<TContextData> {
2884
3157
  /**
2885
3158
  * Registers a listener for a specific incoming activity type.
2886
3159
  *
3160
+ * @example
3161
+ * ``` typescript
3162
+ * federation
3163
+ * .setInboxListeners("/users/{identifier}/inbox", "/inbox")
3164
+ * // Mastodon sends FeatureRequest activities without an actor:
3165
+ * .on(FeatureRequest, async (ctx, request) => {
3166
+ * const verification = await featureInteraction.verifyRequest(ctx, {
3167
+ * request,
3168
+ * authentication: ctx.authentication,
3169
+ * });
3170
+ * // ...
3171
+ * }, { allowActorless: true });
3172
+ * ```
3173
+ *
2887
3174
  * @param type A subclass of {@link Activity} to listen to.
2888
3175
  * @param listener A callback to handle an incoming activity.
3176
+ * @param options Options for the listener. See
3177
+ * {@link InboxListenerOptions}. (Since 2.5.0.)
2889
3178
  * @returns The setters object so that settings can be chained.
2890
3179
  */
2891
- on<TActivity extends Activity>(type: new (...args: any[]) => TActivity, listener: InboxListener<TContextData, TActivity>): InboxListenerSetters<TContextData>;
3180
+ on<TActivity extends Activity>(type: new (...args: any[]) => TActivity, listener: InboxListener<TContextData, TActivity>, options?: InboxListenerOptions): InboxListenerSetters<TContextData>;
2892
3181
  /**
2893
3182
  * Registers an error handler for inbox listeners. Any exceptions thrown
2894
3183
  * from the listeners are caught and passed to this handler.
@@ -3730,7 +4019,9 @@ interface Context<TContextData> {
3730
4019
  * Looks up a WebFinger resource.
3731
4020
  *
3732
4021
  * It's almost the same as the {@link lookupWebFinger} function, but it uses
3733
- * the context's configuration by default.
4022
+ * the context's configuration by default. Unlike {@link lookupWebFinger},
4023
+ * it does not support the `withDiagnostics` option; it always returns the
4024
+ * resource descriptor or `null`.
3734
4025
  *
3735
4026
  * @param resource The resource URL to look up.
3736
4027
  * @param options Extra options for looking up the resource.
@@ -4415,6 +4706,17 @@ interface InboxContext<TContextData> extends Context<TContextData> {
4415
4706
  */
4416
4707
  readonly recipient: string | null;
4417
4708
  /**
4709
+ * Who Fedify authenticated for the incoming activity, independently of its
4710
+ * declared `actor`, and the interpretation of the activity that was
4711
+ * authenticated. It is preserved through the inbox queue and its retries.
4712
+ *
4713
+ * Use it with {@link isActorAuthenticated} to authorize requests that do
4714
+ * not declare an `actor`, which reach a listener only if it is registered
4715
+ * with the `allowActorless` option.
4716
+ * @since 2.5.0
4717
+ */
4718
+ readonly authentication: InboxAuthenticationEvidence;
4719
+ /**
4418
4720
  * Creates a new context with the same properties as this one,
4419
4721
  * but with the given data.
4420
4722
  * @param data The new data to associate with the context.
@@ -4834,4 +5136,4 @@ interface ActorKeyPair extends CryptoKeyPair {
4834
5136
  readonly multikey: Multikey;
4835
5137
  }
4836
5138
  //#endregion
4837
- export { respondWithObject as $, digest as $t, InboxChallengePolicy as A, CustomCollectionDispatcher as At, createFederation as B, OutboxListener as Bt, FederationBenchmarkOptions as C, ActorKeyPairsDispatcher as Ct, FederationStartQueueOptions as D, CollectionDispatcher as Dt, FederationOptions as E, CollectionCursor as Et, PortableInboxForwardingOptions as F, MediaUploaderCallback as Ft, TaskEnqueueOptions as G, SharedInboxKeyDispatcher as Gt, createFederationBuilder as H, OutboxPermanentFailureHandler as Ht, Rfc6570Expression as I, NodeInfoDispatcher as It, CreateExponentialBackoffPolicyOptions as J, WebFingerLinksDispatcher as Jt, TaskHandler as K, UnverifiedActivityHandler as Kt, FederationKvPrefixes as L, ObjectAuthorizePredicate as Lt, MediaUploaderSetters as M, HashlinkMediaRequest as Mt, ObjectCallbackSetters as N, InboxErrorHandler as Nt, IdempotencyKeyCallback as O, CustomCollectionCounter as Ot, OutboxListenerSetters as P, InboxListener as Pt, RespondWithObjectOptions as Q, buildCollectionSynchronizationHeader as Qt, FederationOrigin as R, ObjectDispatcher as Rt, Federation as S, ActorHandleMapper as St, FederationFetchOptions as T, CollectionCounter as Tt, TaskDefinition as U, PortableActorIdMapper as Ut, Message as V, OutboxListenerErrorHandler as Vt, TaskDefinitionOptions as W, PortableCollectionOwnerMapper as Wt, RetryPolicy as X, SenderKeyPair as Xt, RetryContext as Y, SendActivityError as Yt, createExponentialBackoffPolicy as Z, PageItems as Zt, ActorCallbackSetters as _, NormalizedCircuitBreakerOptions as _t, GetObjectOptions as a, InboxRequestReport as an, MessageQueueEnqueueOptions as at, CustomCollectionCallbackSetters as b, ActorAliasMapper as bt, IsSignedByAudienceOptions as c, CircuitBreaker as ct, ParseUriResult as d, CircuitBreakerCreateOptions as dt, ActivityTransformer as en, respondWithObjectIfAcceptable as et, PortableRequest as f, CircuitBreakerFailurePolicy as ft, SendActivityOptionsForCollection as g, CircuitBreakerStateChange as gt, SendActivityOptions as h, CircuitBreakerState as ht, GetActorOptions as i, InboxRequestOutcome as in, MessageQueueDepth as it, InboxListenerSetters as j, HashlinkMediaDispatcher as jt, IdempotencyStrategy as k, CustomCollectionCursor as kt, OutboxContext as l, CircuitBreakerActivityDrop as lt, RouteActivityOptions as m, CircuitBreakerOptions as mt, Context as n, InboxJsonValue as nn, InProcessMessageQueueOptions as nt, GetSignedKeyOptions as o, MessageQueueListenOptions as ot, RequestContext as p, CircuitBreakerKvState as pt, TaskRegistry as q, UnverifiedActivityReason as qt, ForwardActivityOptions as r, InboxRequestFinishedHandler as rn, MessageQueue as rt, InboxContext as s, ParallelMessageQueue as st, ActorKeyPair as t, InboxAuthentication as tn, InProcessMessageQueue as tt, ParseUriOptions as u, CircuitBreakerBeforeSendDecision as ut, CollectionCallbackSetters as v, normalizeCircuitBreakerOptions as vt, FederationBuilder as w, AuthorizePredicate as wt, Federatable as x, ActorDispatcher as xt, ConstructorWithTypeId as y, parseCircuitBreakerKvState as yt, FederationQueueOptions as z, OutboxErrorHandler as zt };
5139
+ export { respondWithObject as $, SendActivityError as $t, InboxChallengePolicy as A, CollectionCursor as At, createFederation as B, NodeInfoDispatcher as Bt, FederationBenchmarkOptions as C, parseCircuitBreakerKvState as Ct, FederationStartQueueOptions as D, ActorKeyPairsDispatcher as Dt, FederationOptions as E, ActorHandleMapper as Et, PortableInboxForwardingOptions as F, HashlinkMediaDispatcher as Ft, TaskEnqueueOptions as G, OutboxListenerErrorHandler as Gt, createFederationBuilder as H, ObjectDispatcher as Ht, Rfc6570Expression as I, HashlinkMediaRequest as It, CreateExponentialBackoffPolicyOptions as J, PortableCollectionOwnerMapper as Jt, TaskHandler as K, OutboxPermanentFailureHandler as Kt, FederationKvPrefixes as L, InboxErrorHandler as Lt, MediaUploaderSetters as M, CustomCollectionCounter as Mt, ObjectCallbackSetters as N, CustomCollectionCursor as Nt, IdempotencyKeyCallback as O, AuthorizePredicate as Ot, OutboxListenerSetters as P, CustomCollectionDispatcher as Pt, RespondWithObjectOptions as Q, WebFingerLinksDispatcher as Qt, FederationOrigin as R, InboxListener as Rt, Federation as S, normalizeCircuitBreakerOptions as St, FederationFetchOptions as T, ActorDispatcher as Tt, TaskDefinition as U, OutboxErrorHandler as Ut, Message as V, ObjectAuthorizePredicate as Vt, TaskDefinitionOptions as W, OutboxListener as Wt, RetryPolicy as X, UnverifiedActivityHandler as Xt, RetryContext as Y, SharedInboxKeyDispatcher as Yt, createExponentialBackoffPolicy as Z, UnverifiedActivityReason as Zt, ActorCallbackSetters as _, CircuitBreakerKvState as _t, GetObjectOptions as a, InboxAuthentication as an, InProcessMessageQueue as at, CustomCollectionCallbackSetters as b, CircuitBreakerStateChange as bt, IsSignedByAudienceOptions as c, InboxRequestOutcome as cn, MessageQueueDepth as ct, ParseUriResult as d, ParallelMessageQueue as dt, SenderKeyPair as en, respondWithObjectIfAcceptable as et, PortableRequest as f, CircuitBreaker as ft, SendActivityOptionsForCollection as g, CircuitBreakerFailurePolicy as gt, SendActivityOptions as h, CircuitBreakerCreateOptions as ht, GetActorOptions as i, ActivityTransformer as in, isActorAuthenticated as it, InboxListenerSetters as j, CollectionDispatcher as jt, IdempotencyStrategy as k, CollectionCounter as kt, OutboxContext as l, InboxRequestReport as ln, MessageQueueEnqueueOptions as lt, RouteActivityOptions as m, CircuitBreakerBeforeSendDecision as mt, Context as n, buildCollectionSynchronizationHeader as nn, InboxPrincipal as nt, GetSignedKeyOptions as o, InboxJsonValue as on, InProcessMessageQueueOptions as ot, RequestContext as p, CircuitBreakerActivityDrop as pt, TaskRegistry as q, PortableActorIdMapper as qt, ForwardActivityOptions as r, digest as rn, IsActorAuthenticatedOptions as rt, InboxContext as s, InboxRequestFinishedHandler as sn, MessageQueue as st, ActorKeyPair as t, PageItems as tn, InboxAuthenticationEvidence as tt, ParseUriOptions as u, InboxListenerOptions as un, MessageQueueListenOptions as ut, CollectionCallbackSetters as v, CircuitBreakerOptions as vt, FederationBuilder as w, ActorAliasMapper as wt, Federatable as x, NormalizedCircuitBreakerOptions as xt, ConstructorWithTypeId as y, CircuitBreakerState as yt, FederationQueueOptions as z, MediaUploaderCallback as zt };
@@ -3,6 +3,7 @@ import "urlpattern-polyfill";
3
3
  globalThis.addEventListener = () => {};
4
4
  import { t as mockDocumentLoader } from "./dist-DJQM4u7i.mjs";
5
5
  import { t as isInAudience } from "./audience-CHQ-FlLD.mjs";
6
+ import { i as getEmptyAuthenticationEvidence } from "./inbox-authentication-DflPYlLL.mjs";
6
7
  import { RouterError } from "@fedify/uri-template";
7
8
  import { lookupObject, traverseCollection } from "@fedify/vocab";
8
9
  import { lookupWebFinger } from "@fedify/webfinger";
@@ -120,6 +121,7 @@ function createInboxContext(args) {
120
121
  data
121
122
  })),
122
123
  recipient: args.recipient ?? null,
124
+ authentication: args.authentication ?? getEmptyAuthenticationEvidence(),
123
125
  forwardActivity: args.forwardActivity ?? ((_forwarder, _recipients, _options) => {
124
126
  throw new Error("Not implemented");
125
127
  })