@fedify/interaction-controls 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.
package/dist/mod.d.cts CHANGED
@@ -1,6 +1,6 @@
1
1
  /// <reference lib="esnext.temporal" />
2
2
  import { Accept, Activity, Actor, Announce, AnnounceAuthorization, AnnounceRequest, Article, ChatMessage, Create, Delete, FeatureAuthorization, FeatureRequest, FeaturedCollection, InteractionRule, Like, LikeAuthorization, LikeRequest, Note, Object as Object$1, Question, QuoteAuthorization, QuoteRequest, Reject, ReplyAuthorization, ReplyRequest } from "@fedify/vocab";
3
- import { Context } from "@fedify/fedify";
3
+ import { Context, InboxAuthenticationEvidence } from "@fedify/fedify";
4
4
  import { DocumentLoader } from "@fedify/vocab-runtime";
5
5
 
6
6
  //#region ../../node_modules/.pnpm/temporal-spec@1.0.0/node_modules/temporal-spec/index.d.ts
@@ -504,6 +504,23 @@ interface InteractionRequestVerificationOptions<TRequest extends Activity> {
504
504
  * @since 2.5.0
505
505
  */
506
506
  readonly resolvedInteractingObject?: Object$1;
507
+ /**
508
+ * Who Fedify authenticated for the request, normally
509
+ * {@link InboxContext.authentication} of the inbox listener that received
510
+ * it.
511
+ *
512
+ * It is required to verify a request that declares no `actor`, such as
513
+ * a [FEP-7aa9] `FeatureRequest` sent by Mastodon: the requester is then the
514
+ * owner of the interacting object, who must have been authenticated. For
515
+ * a request that declares an actor, the actor must have been
516
+ * authenticated, and the request must have exactly one `object` and one
517
+ * `instrument` value, which are checked on the interpretation Fedify
518
+ * authenticated, including values typed parsing drops.
519
+ *
520
+ * [FEP-7aa9]: https://w3id.org/fep/7aa9
521
+ * @since 2.5.0
522
+ */
523
+ readonly authentication?: InboxAuthenticationEvidence;
507
524
  }
508
525
  /**
509
526
  * Options for relaxing how {@link quoteInteraction} validates a quote request.
@@ -615,6 +632,53 @@ type InteractionRequestVerificationFailure = {
615
632
  readonly type: "requesterMismatch";
616
633
  readonly expected: URL;
617
634
  readonly actual?: URL;
635
+ } | {
636
+ /**
637
+ * The URL of the interacting object has a username or a password.
638
+ * @since 2.5.0
639
+ */
640
+ readonly category: "invalid";
641
+ readonly type: "credentialsInUrl";
642
+ readonly url: URL;
643
+ } | {
644
+ /**
645
+ * The document of the interacting object, fetched from its ID, is not
646
+ * acceptable:
647
+ *
648
+ * - `"credentials"`: it was served from a URL with credentials.
649
+ * - `"id"`: its ID does not match the requested one.
650
+ * - `"type"`: it is not of the expected type.
651
+ * - `"attribution"`: it does not have exactly one `attributedTo` value
652
+ * that identifies an actor.
653
+ * - `"decoding"`: it cannot be decoded, e.g., it has a malformed date.
654
+ * @since 2.5.0
655
+ */
656
+ readonly category: "invalid";
657
+ readonly type: "invalidInteractingObject";
658
+ readonly reason: "credentials" | "id" | "type" | "attribution" | "decoding";
659
+ readonly cause?: unknown;
660
+ } | {
661
+ /**
662
+ * The request, as Fedify authenticated it, does not unambiguously have
663
+ * the given property: it has another type or ID than the request being
664
+ * verified, its `actor` values differ, or it does not have exactly one
665
+ * `object` or `instrument` value.
666
+ * @since 2.5.0
667
+ */
668
+ readonly category: "invalid";
669
+ readonly type: "ambiguousRequest";
670
+ readonly property: "type" | "id" | "actor" | "object" | "instrument";
671
+ } | {
672
+ /**
673
+ * The requester was not authenticated: the request's actor, or for
674
+ * a request without an actor, the owner of its interacting object, is not
675
+ * among the principals of the given authentication evidence, or no
676
+ * evidence is available.
677
+ * @since 2.5.0
678
+ */
679
+ readonly category: "unauthorized";
680
+ readonly type: "unauthenticatedRequester";
681
+ readonly requester?: URL;
618
682
  };
619
683
  interface InteractionPolicyEvaluationOptions<TContextData, TTarget extends Object$1> {
620
684
  readonly subject: TTarget;
package/dist/mod.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference lib="esnext.temporal" />
2
2
  import { Accept, Activity, Actor, Announce, AnnounceAuthorization, AnnounceRequest, Article, ChatMessage, Create, Delete, FeatureAuthorization, FeatureRequest, FeaturedCollection, InteractionRule, Like, LikeAuthorization, LikeRequest, Note, Object as Object$1, Question, QuoteAuthorization, QuoteRequest, Reject, ReplyAuthorization, ReplyRequest } from "@fedify/vocab";
3
+ import { Context, InboxAuthenticationEvidence } from "@fedify/fedify";
3
4
  import { DocumentLoader } from "@fedify/vocab-runtime";
4
- import { Context } from "@fedify/fedify";
5
5
  import { Temporal } from "temporal-polyfill";
6
6
 
7
7
  //#region src/types.d.ts
@@ -63,6 +63,23 @@ interface InteractionRequestVerificationOptions<TRequest extends Activity> {
63
63
  * @since 2.5.0
64
64
  */
65
65
  readonly resolvedInteractingObject?: Object$1;
66
+ /**
67
+ * Who Fedify authenticated for the request, normally
68
+ * {@link InboxContext.authentication} of the inbox listener that received
69
+ * it.
70
+ *
71
+ * It is required to verify a request that declares no `actor`, such as
72
+ * a [FEP-7aa9] `FeatureRequest` sent by Mastodon: the requester is then the
73
+ * owner of the interacting object, who must have been authenticated. For
74
+ * a request that declares an actor, the actor must have been
75
+ * authenticated, and the request must have exactly one `object` and one
76
+ * `instrument` value, which are checked on the interpretation Fedify
77
+ * authenticated, including values typed parsing drops.
78
+ *
79
+ * [FEP-7aa9]: https://w3id.org/fep/7aa9
80
+ * @since 2.5.0
81
+ */
82
+ readonly authentication?: InboxAuthenticationEvidence;
66
83
  }
67
84
  /**
68
85
  * Options for relaxing how {@link quoteInteraction} validates a quote request.
@@ -174,6 +191,53 @@ type InteractionRequestVerificationFailure = {
174
191
  readonly type: "requesterMismatch";
175
192
  readonly expected: URL;
176
193
  readonly actual?: URL;
194
+ } | {
195
+ /**
196
+ * The URL of the interacting object has a username or a password.
197
+ * @since 2.5.0
198
+ */
199
+ readonly category: "invalid";
200
+ readonly type: "credentialsInUrl";
201
+ readonly url: URL;
202
+ } | {
203
+ /**
204
+ * The document of the interacting object, fetched from its ID, is not
205
+ * acceptable:
206
+ *
207
+ * - `"credentials"`: it was served from a URL with credentials.
208
+ * - `"id"`: its ID does not match the requested one.
209
+ * - `"type"`: it is not of the expected type.
210
+ * - `"attribution"`: it does not have exactly one `attributedTo` value
211
+ * that identifies an actor.
212
+ * - `"decoding"`: it cannot be decoded, e.g., it has a malformed date.
213
+ * @since 2.5.0
214
+ */
215
+ readonly category: "invalid";
216
+ readonly type: "invalidInteractingObject";
217
+ readonly reason: "credentials" | "id" | "type" | "attribution" | "decoding";
218
+ readonly cause?: unknown;
219
+ } | {
220
+ /**
221
+ * The request, as Fedify authenticated it, does not unambiguously have
222
+ * the given property: it has another type or ID than the request being
223
+ * verified, its `actor` values differ, or it does not have exactly one
224
+ * `object` or `instrument` value.
225
+ * @since 2.5.0
226
+ */
227
+ readonly category: "invalid";
228
+ readonly type: "ambiguousRequest";
229
+ readonly property: "type" | "id" | "actor" | "object" | "instrument";
230
+ } | {
231
+ /**
232
+ * The requester was not authenticated: the request's actor, or for
233
+ * a request without an actor, the owner of its interacting object, is not
234
+ * among the principals of the given authentication evidence, or no
235
+ * evidence is available.
236
+ * @since 2.5.0
237
+ */
238
+ readonly category: "unauthorized";
239
+ readonly type: "unauthenticatedRequester";
240
+ readonly requester?: URL;
177
241
  };
178
242
  interface InteractionPolicyEvaluationOptions<TContextData, TTarget extends Object$1> {
179
243
  readonly subject: TTarget;