@fedify/interaction-controls 2.5.0-dev.2339 → 2.5.0-dev.2358

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,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { Accept, Activity, Actor, Announce, AnnounceAuthorization, AnnounceRequest, Article, ChatMessage, Create, Delete, FeatureAuthorization, FeatureRequest, FeaturedCollection, Like, LikeAuthorization, LikeRequest, Note, Object as Object$1, Question, QuoteAuthorization, QuoteRequest, Reject, ReplyAuthorization, ReplyRequest } from "@fedify/vocab";
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
3
  import { Context } from "@fedify/fedify";
4
4
  import { DocumentLoader } from "@fedify/vocab-runtime";
5
5
 
@@ -448,12 +448,12 @@ declare namespace Intl {
448
448
  //#region src/types.d.ts
449
449
  type InteractionName = "like" | "reply" | "announce" | "quote" | "feature";
450
450
  type InteractionPolicyProperty = "canLike" | "canReply" | "canAnnounce" | "canQuote" | "canFeature";
451
- interface InteractionControl<TRequest extends Activity, TAuthorization extends Object$1, TInteracting extends Object$1, TTarget extends Object$1, TImpoliteSource extends Object$1> {
451
+ interface InteractionControl<TRequest extends Activity, TAuthorization extends Object$1, TInteracting extends Object$1, TTarget extends Object$1, TImpoliteSource extends Object$1, TRequestValidationOptions extends object = Record<never, never>> {
452
452
  readonly name: InteractionName;
453
453
  readonly policyProperty: InteractionPolicyProperty;
454
454
  readonly requestTypeId: URL;
455
455
  readonly authorizationTypeId: URL;
456
- readonly verifyRequest: <TContextData>(context: Context<TContextData>, options: InteractionRequestVerificationOptions<TRequest>) => Promise<InteractionRequestVerification<TRequest, TInteracting, TTarget>>;
456
+ readonly verifyRequest: <TContextData>(context: Context<TContextData>, options: InteractionRequestVerificationOptions<TRequest> & TRequestValidationOptions) => Promise<InteractionRequestVerification<TRequest, TInteracting, TTarget>>;
457
457
  readonly evaluatePolicy: <TContextData>(context: Context<TContextData>, options: InteractionPolicyEvaluationOptions<TContextData, TTarget>) => Promise<InteractionPolicyDecision>;
458
458
  readonly createRequest: (options: InteractionRequestCreationOptions<TInteracting, TTarget>) => TRequest;
459
459
  readonly createAuthorization: (options: InteractionAuthorizationCreationOptions<TInteracting, TTarget>) => TAuthorization;
@@ -468,6 +468,79 @@ interface InteractionControl<TRequest extends Activity, TAuthorization extends O
468
468
  interface InteractionRequestVerificationOptions<TRequest extends Activity> {
469
469
  readonly request: TRequest | URL;
470
470
  readonly documentLoader?: DocumentLoader;
471
+ /**
472
+ * The document loader for remote JSON-LD contexts. Defaults to the
473
+ * document loader used for objects.
474
+ * @since 2.5.0
475
+ */
476
+ readonly contextLoader?: DocumentLoader;
477
+ /**
478
+ * The already resolved interaction target, used instead of dereferencing
479
+ * the request's `object`. It is used only when the request references its
480
+ * `object` by ID; otherwise the request fails as it would without this
481
+ * option. When it is used, the request itself is left untouched.
482
+ *
483
+ * The value is trusted as the resolution of the request's `object`: its ID
484
+ * does not have to match the reference (e.g., a share wrapper resolved to
485
+ * the shared post), and no origin or provenance checks are applied to it.
486
+ * The caller is responsible for those checks. The target type and target
487
+ * binding checks still apply.
488
+ * @since 2.5.0
489
+ */
490
+ readonly resolvedInteractionTarget?: Object$1;
491
+ /**
492
+ * The already resolved interacting object, used instead of dereferencing
493
+ * the request's `instrument`. It is used only when the request references
494
+ * its `instrument` by ID; otherwise the request fails as it would without
495
+ * this option. When it is used, the request itself is left untouched.
496
+ *
497
+ * The value is trusted as the resolution of the request's `instrument`: its
498
+ * ID does not have to match the reference (e.g., after a redirect), and no
499
+ * origin or provenance checks are applied to it. The caller is responsible
500
+ * for those checks, such as checking that the instrument comes from the
501
+ * requester's origin; a matching attribution alone does not authenticate
502
+ * it. The instrument type, requester, and target binding checks still
503
+ * apply.
504
+ * @since 2.5.0
505
+ */
506
+ readonly resolvedInteractingObject?: Object$1;
507
+ }
508
+ /**
509
+ * Options for relaxing how {@link quoteInteraction} validates a quote request.
510
+ * The defaults apply the strictest checks.
511
+ * @since 2.5.0
512
+ */
513
+ interface QuoteRequestValidationOptions {
514
+ /**
515
+ * How the quote post's FEP-044f `quote` and compatible `quoteUrl`
516
+ * references are checked against the requested target:
517
+ *
518
+ * - `"strict"` (default): if both are present they must agree, and the
519
+ * reference must equal the target.
520
+ * - `"preferQuote"`: `quote` must equal the target if present, otherwise
521
+ * `quoteUrl` must; a conflicting `quoteUrl` is ignored.
522
+ * - `"any"`: either `quote` or `quoteUrl` equal to the target suffices,
523
+ * even when the two disagree.
524
+ */
525
+ readonly quoteReference?: "strict" | "preferQuote" | "any";
526
+ /**
527
+ * Which `attributedTo` entries of the quote post may match the requester:
528
+ *
529
+ * - `"first"` (default): the first attribution must be the requester.
530
+ * - `"any"`: any attribution may be the requester.
531
+ */
532
+ readonly attribution?: "first" | "any";
533
+ /**
534
+ * What to do when the quote post has no attribution IRI, i.e., it has no
535
+ * `attributedTo` at all or only attributions embedded without an `id`:
536
+ *
537
+ * - `"reject"` (default): fail with `requesterMismatch`.
538
+ * - `"requester"`: treat the quote post as attributed to the requester.
539
+ *
540
+ * A present attribution IRI that does not match the requester always
541
+ * fails.
542
+ */
543
+ readonly missingAttribution?: "reject" | "requester";
471
544
  }
472
545
  type InteractionRequestVerification<TRequest extends Activity, TInteracting extends Object$1, TTarget extends Object$1> = {
473
546
  readonly verified: true;
@@ -489,14 +562,31 @@ type InteractionRequestVerificationFailure = {
489
562
  readonly type: "notDereferenceable";
490
563
  readonly url: URL;
491
564
  readonly cause?: unknown;
565
+ /**
566
+ * Whether the failure is likely transient, so that verifying again later
567
+ * could succeed. Always set by the built-in helpers.
568
+ * @since 2.5.0
569
+ */
570
+ readonly transient?: boolean;
492
571
  } | {
493
572
  readonly category: "unverifiable";
494
573
  readonly type: "unauthorizedFetchRequired";
495
574
  readonly url: URL;
575
+ /**
576
+ * Whether the failure is likely transient.
577
+ * @since 2.5.0
578
+ */
579
+ readonly transient?: boolean;
496
580
  } | {
497
581
  readonly category: "unverifiable";
498
582
  readonly type: "invalidJsonLd";
499
583
  readonly cause?: unknown;
584
+ /**
585
+ * Whether the failure is likely transient. Always `false` when set by
586
+ * the built-in helpers.
587
+ * @since 2.5.0
588
+ */
589
+ readonly transient?: boolean;
500
590
  } | {
501
591
  readonly category: "invalid";
502
592
  readonly type: "wrongType";
@@ -531,6 +621,42 @@ interface InteractionPolicyEvaluationOptions<TContextData, TTarget extends Objec
531
621
  readonly requester: URL;
532
622
  readonly documentLoader?: DocumentLoader;
533
623
  readonly matchesApprovalCollection?: MatchesApprovalCollection<TContextData>;
624
+ /**
625
+ * The rule to evaluate when the subject has no interaction policy, no rule
626
+ * for this interaction, or a rule without any approval entries. Without
627
+ * it, such subjects get the interaction's default decision.
628
+ * @since 2.5.0
629
+ */
630
+ readonly fallbackRule?: InteractionRule;
631
+ /**
632
+ * The order in which approval entries are matched:
633
+ *
634
+ * - `"actor"` (default): actors listed explicitly in either
635
+ * `automaticApproval` or `manualApproval` first, then the public
636
+ * collection and other collections, automatic before manual. An actor
637
+ * listed in `manualApproval` thus gets a manual decision even when
638
+ * `automaticApproval` contains the public collection.
639
+ * - `"automatic"`: every `automaticApproval` entry first, then every
640
+ * `manualApproval` entry. If an `automaticApproval` collection cannot
641
+ * be checked and no other automatic entry matches, the decision is
642
+ * `denied` with an `unverifiableCollection` reason rather than a manual
643
+ * decision, since the collection could have granted automatic
644
+ * approval.
645
+ * @since 2.5.0
646
+ */
647
+ readonly precedence?: "actor" | "automatic";
648
+ /**
649
+ * What to do when {@link matchesApprovalCollection} throws:
650
+ *
651
+ * - `"deny"` (default): skip the collection; if nothing else decides,
652
+ * the decision is `denied` with an `unverifiableCollection` reason
653
+ * carrying the error as its `cause`.
654
+ * - `"throw"`: rethrow the first error immediately, without calling the
655
+ * callback for later collections, so that the caller can retry later
656
+ * instead of rejecting the interaction.
657
+ * @since 2.5.0
658
+ */
659
+ readonly collectionErrors?: "deny" | "throw";
534
660
  }
535
661
  type MatchesApprovalCollection<TContextData> = (collection: URL, actor: URL, context: Context<TContextData>) => boolean | Promise<boolean>;
536
662
  type InteractionPolicyDecision = {
@@ -566,6 +692,11 @@ type InteractionPolicyDenialReason = {
566
692
  } | {
567
693
  readonly type: "unverifiableCollection";
568
694
  readonly collection: URL;
695
+ /**
696
+ * The error thrown while checking the collection.
697
+ * @since 2.5.0
698
+ */
699
+ readonly cause?: unknown;
569
700
  };
570
701
  interface InteractionRequestCreationOptions<TInteracting extends Object$1, TTarget extends Object$1> {
571
702
  readonly id: URL;
@@ -587,6 +718,34 @@ interface InteractionAuthorizationVerificationOptions<TContextData, TAuthorizati
587
718
  readonly interactionTarget: TTarget | URL;
588
719
  readonly attributedTo?: URL;
589
720
  readonly documentLoader?: DocumentLoader;
721
+ /**
722
+ * The document loader for remote JSON-LD contexts. Defaults to the
723
+ * document loader used for objects.
724
+ * @since 2.5.0
725
+ */
726
+ readonly contextLoader?: DocumentLoader;
727
+ /**
728
+ * The expected ID of the authorization. When the authorization is given
729
+ * as an object, its ID must equal this, or verification fails with
730
+ * `idMismatch`. When it is given as a URL, the URL must equal this.
731
+ *
732
+ * This only checks the identity of the authorization; it does not
733
+ * establish its authenticity. An authorization given as an object still
734
+ * needs {@link verifyAuthenticity}.
735
+ * @since 2.5.0
736
+ */
737
+ readonly authorizationId?: URL;
738
+ /**
739
+ * Whether to accept an authorization whose ID is on a different origin
740
+ * than its attributed actor, if {@link verifyAuthenticity} approves it.
741
+ * This is for authorizations whose authenticity is established by other
742
+ * means, such as a signed `Accept` from the attributed actor or a locally
743
+ * stored grant. Without {@link verifyAuthenticity}, such authorizations
744
+ * still fail with `originMismatch`. All other checks still apply.
745
+ * Defaults to `false`.
746
+ * @since 2.5.0
747
+ */
748
+ readonly allowOffOrigin?: boolean;
590
749
  readonly getRevocation?: GetInteractionAuthorizationRevocation<TContextData>;
591
750
  readonly verifyAuthenticity?: (authorization: TAuthorization, context: Context<TContextData>) => boolean | Promise<boolean>;
592
751
  }
@@ -605,14 +764,31 @@ type InteractionAuthorizationVerificationFailure = {
605
764
  readonly type: "notDereferenceable";
606
765
  readonly url: URL;
607
766
  readonly cause?: unknown;
767
+ /**
768
+ * Whether the failure is likely transient, so that verifying again later
769
+ * could succeed. Always set by the built-in helpers.
770
+ * @since 2.5.0
771
+ */
772
+ readonly transient?: boolean;
608
773
  } | {
609
774
  readonly category: "unverifiable";
610
775
  readonly type: "unauthorizedFetchRequired";
611
776
  readonly url: URL;
777
+ /**
778
+ * Whether the failure is likely transient.
779
+ * @since 2.5.0
780
+ */
781
+ readonly transient?: boolean;
612
782
  } | {
613
783
  readonly category: "unverifiable";
614
784
  readonly type: "invalidJsonLd";
615
785
  readonly cause?: unknown;
786
+ /**
787
+ * Whether the failure is likely transient. Always `false` when set by
788
+ * the built-in helpers.
789
+ * @since 2.5.0
790
+ */
791
+ readonly transient?: boolean;
616
792
  } | {
617
793
  readonly category: "unauthorized";
618
794
  readonly type: "wrongType";
@@ -659,44 +835,53 @@ interface InteractionAuthorizationRevocation {
659
835
  }
660
836
  type InteractionAcceptOptions<TRequest extends Activity, TAuthorization extends Object$1, TInteracting extends Object$1, TTarget extends Object$1> = {
661
837
  readonly mode: "polite";
662
- readonly id: URL;
838
+ readonly id?: URL;
663
839
  readonly actor: URL;
664
840
  readonly request: TRequest | URL;
665
841
  readonly authorization: TAuthorization | URL;
666
- readonly to: URL | readonly URL[];
842
+ readonly to?: URL | readonly URL[];
667
843
  readonly cc?: URL | readonly URL[];
668
844
  } | {
669
845
  readonly mode: "impolite";
670
- readonly id: URL;
846
+ readonly id?: URL;
671
847
  readonly actor: URL;
672
848
  readonly interactingObject: TInteracting | URL;
673
849
  readonly interactionTarget: TTarget | URL;
674
850
  readonly authorization: TAuthorization | URL;
675
- readonly to: URL | readonly URL[];
851
+ readonly to?: URL | readonly URL[];
676
852
  readonly cc?: URL | readonly URL[];
677
853
  };
678
854
  type InteractionRejectOptions<TRequest extends Activity, TInteracting extends Object$1, TTarget extends Object$1> = {
679
855
  readonly mode: "polite";
680
- readonly id: URL;
856
+ readonly id?: URL;
681
857
  readonly actor: URL;
682
858
  readonly request: TRequest | URL;
683
- readonly to: URL | readonly URL[];
859
+ readonly to?: URL | readonly URL[];
684
860
  readonly cc?: URL | readonly URL[];
685
861
  } | {
686
862
  readonly mode: "impolite";
687
- readonly id: URL;
863
+ readonly id?: URL;
688
864
  readonly actor: URL;
689
865
  readonly interactingObject: TInteracting | URL;
690
866
  readonly interactionTarget: TTarget | URL;
691
- readonly to: URL | readonly URL[];
867
+ readonly to?: URL | readonly URL[];
692
868
  readonly cc?: URL | readonly URL[];
693
869
  };
694
870
  interface InteractionRevocationCreationOptions<TAuthorization extends Object$1> {
695
- readonly id: URL;
871
+ readonly id?: URL;
696
872
  readonly actor: URL;
697
873
  readonly authorization: TAuthorization | URL;
698
- readonly to: URL | readonly URL[];
874
+ readonly to?: URL | readonly URL[];
699
875
  readonly cc?: URL | readonly URL[];
876
+ /**
877
+ * Whether to embed the authorization in the `Delete` activity instead of
878
+ * referring to it by its ID. Applies only when the authorization is given
879
+ * as an object. The embedded copy contains only the authorization's ID,
880
+ * attribution, and the IDs of its interacting object and interaction
881
+ * target, so that the revocation does not leak them. Defaults to `false`.
882
+ * @since 2.5.0
883
+ */
884
+ readonly embedAuthorization?: boolean;
700
885
  }
701
886
  interface RecognizedImpoliteInteraction<TInteracting extends Object$1, TTarget extends Object$1, TImpoliteSource extends Object$1> {
702
887
  readonly requester: URL;
@@ -752,11 +937,11 @@ declare const likeInteraction: InteractionControl<LikeRequest, LikeAuthorization
752
937
  //#region src/quote.d.ts
753
938
  type QuotePost = Note | Article | Question | ChatMessage;
754
939
  type QuoteImpoliteSource = Create | QuotePost;
755
- declare const quoteInteraction: InteractionControl<QuoteRequest, QuoteAuthorization, QuotePost, Object$1, QuoteImpoliteSource>;
940
+ declare const quoteInteraction: InteractionControl<QuoteRequest, QuoteAuthorization, QuotePost, Object$1, QuoteImpoliteSource, QuoteRequestValidationOptions>;
756
941
  //#endregion
757
942
  //#region src/reply.d.ts
758
943
  type ReplyPost = Note | Article | Question | ChatMessage;
759
944
  type ReplyImpoliteSource = Create | ReplyPost;
760
945
  declare const replyInteraction: InteractionControl<ReplyRequest, ReplyAuthorization, ReplyPost, Object$1, ReplyImpoliteSource>;
761
946
  //#endregion
762
- export { GetInteractionAuthorizationRevocation, ImpoliteInteractionEvidence, InteractionAcceptOptions, InteractionAuthorizationCreationOptions, InteractionAuthorizationKey, InteractionAuthorizationKeyInput, InteractionAuthorizationRevocation, InteractionAuthorizationVerification, InteractionAuthorizationVerificationFailure, InteractionAuthorizationVerificationOptions, InteractionControl, InteractionKey, InteractionKeyInput, InteractionName, InteractionPolicyDecision, InteractionPolicyDenialReason, InteractionPolicyEvaluationOptions, InteractionPolicyMatchReason, InteractionPolicyProperty, InteractionRejectOptions, InteractionRequestCreationOptions, InteractionRequestVerification, InteractionRequestVerificationFailure, InteractionRequestVerificationOptions, InteractionRevocationCreationOptions, MatchesApprovalCollection, type QuoteImpoliteSource, type QuotePost, RecognizedImpoliteInteraction, type ReplyImpoliteSource, type ReplyPost, announceInteraction, featureInteraction, formatAuthorizationKey, formatInteractionKey, likeInteraction, quoteInteraction, replyInteraction };
947
+ export { GetInteractionAuthorizationRevocation, ImpoliteInteractionEvidence, InteractionAcceptOptions, InteractionAuthorizationCreationOptions, InteractionAuthorizationKey, InteractionAuthorizationKeyInput, InteractionAuthorizationRevocation, InteractionAuthorizationVerification, InteractionAuthorizationVerificationFailure, InteractionAuthorizationVerificationOptions, InteractionControl, InteractionKey, InteractionKeyInput, InteractionName, InteractionPolicyDecision, InteractionPolicyDenialReason, InteractionPolicyEvaluationOptions, InteractionPolicyMatchReason, InteractionPolicyProperty, InteractionRejectOptions, InteractionRequestCreationOptions, InteractionRequestVerification, InteractionRequestVerificationFailure, InteractionRequestVerificationOptions, InteractionRevocationCreationOptions, MatchesApprovalCollection, type QuoteImpoliteSource, type QuotePost, QuoteRequestValidationOptions, RecognizedImpoliteInteraction, type ReplyImpoliteSource, type ReplyPost, announceInteraction, featureInteraction, formatAuthorizationKey, formatInteractionKey, likeInteraction, quoteInteraction, replyInteraction };
package/dist/mod.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference lib="esnext.temporal" />
2
- import { Accept, Activity, Actor, Announce, AnnounceAuthorization, AnnounceRequest, Article, ChatMessage, Create, Delete, FeatureAuthorization, FeatureRequest, FeaturedCollection, Like, LikeAuthorization, LikeRequest, Note, Object as Object$1, Question, QuoteAuthorization, QuoteRequest, Reject, ReplyAuthorization, ReplyRequest } from "@fedify/vocab";
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
3
  import { DocumentLoader } from "@fedify/vocab-runtime";
4
4
  import { Context } from "@fedify/fedify";
5
5
  import { Temporal } from "temporal-polyfill";
@@ -7,12 +7,12 @@ import { Temporal } from "temporal-polyfill";
7
7
  //#region src/types.d.ts
8
8
  type InteractionName = "like" | "reply" | "announce" | "quote" | "feature";
9
9
  type InteractionPolicyProperty = "canLike" | "canReply" | "canAnnounce" | "canQuote" | "canFeature";
10
- interface InteractionControl<TRequest extends Activity, TAuthorization extends Object$1, TInteracting extends Object$1, TTarget extends Object$1, TImpoliteSource extends Object$1> {
10
+ interface InteractionControl<TRequest extends Activity, TAuthorization extends Object$1, TInteracting extends Object$1, TTarget extends Object$1, TImpoliteSource extends Object$1, TRequestValidationOptions extends object = Record<never, never>> {
11
11
  readonly name: InteractionName;
12
12
  readonly policyProperty: InteractionPolicyProperty;
13
13
  readonly requestTypeId: URL;
14
14
  readonly authorizationTypeId: URL;
15
- readonly verifyRequest: <TContextData>(context: Context<TContextData>, options: InteractionRequestVerificationOptions<TRequest>) => Promise<InteractionRequestVerification<TRequest, TInteracting, TTarget>>;
15
+ readonly verifyRequest: <TContextData>(context: Context<TContextData>, options: InteractionRequestVerificationOptions<TRequest> & TRequestValidationOptions) => Promise<InteractionRequestVerification<TRequest, TInteracting, TTarget>>;
16
16
  readonly evaluatePolicy: <TContextData>(context: Context<TContextData>, options: InteractionPolicyEvaluationOptions<TContextData, TTarget>) => Promise<InteractionPolicyDecision>;
17
17
  readonly createRequest: (options: InteractionRequestCreationOptions<TInteracting, TTarget>) => TRequest;
18
18
  readonly createAuthorization: (options: InteractionAuthorizationCreationOptions<TInteracting, TTarget>) => TAuthorization;
@@ -27,6 +27,79 @@ interface InteractionControl<TRequest extends Activity, TAuthorization extends O
27
27
  interface InteractionRequestVerificationOptions<TRequest extends Activity> {
28
28
  readonly request: TRequest | URL;
29
29
  readonly documentLoader?: DocumentLoader;
30
+ /**
31
+ * The document loader for remote JSON-LD contexts. Defaults to the
32
+ * document loader used for objects.
33
+ * @since 2.5.0
34
+ */
35
+ readonly contextLoader?: DocumentLoader;
36
+ /**
37
+ * The already resolved interaction target, used instead of dereferencing
38
+ * the request's `object`. It is used only when the request references its
39
+ * `object` by ID; otherwise the request fails as it would without this
40
+ * option. When it is used, the request itself is left untouched.
41
+ *
42
+ * The value is trusted as the resolution of the request's `object`: its ID
43
+ * does not have to match the reference (e.g., a share wrapper resolved to
44
+ * the shared post), and no origin or provenance checks are applied to it.
45
+ * The caller is responsible for those checks. The target type and target
46
+ * binding checks still apply.
47
+ * @since 2.5.0
48
+ */
49
+ readonly resolvedInteractionTarget?: Object$1;
50
+ /**
51
+ * The already resolved interacting object, used instead of dereferencing
52
+ * the request's `instrument`. It is used only when the request references
53
+ * its `instrument` by ID; otherwise the request fails as it would without
54
+ * this option. When it is used, the request itself is left untouched.
55
+ *
56
+ * The value is trusted as the resolution of the request's `instrument`: its
57
+ * ID does not have to match the reference (e.g., after a redirect), and no
58
+ * origin or provenance checks are applied to it. The caller is responsible
59
+ * for those checks, such as checking that the instrument comes from the
60
+ * requester's origin; a matching attribution alone does not authenticate
61
+ * it. The instrument type, requester, and target binding checks still
62
+ * apply.
63
+ * @since 2.5.0
64
+ */
65
+ readonly resolvedInteractingObject?: Object$1;
66
+ }
67
+ /**
68
+ * Options for relaxing how {@link quoteInteraction} validates a quote request.
69
+ * The defaults apply the strictest checks.
70
+ * @since 2.5.0
71
+ */
72
+ interface QuoteRequestValidationOptions {
73
+ /**
74
+ * How the quote post's FEP-044f `quote` and compatible `quoteUrl`
75
+ * references are checked against the requested target:
76
+ *
77
+ * - `"strict"` (default): if both are present they must agree, and the
78
+ * reference must equal the target.
79
+ * - `"preferQuote"`: `quote` must equal the target if present, otherwise
80
+ * `quoteUrl` must; a conflicting `quoteUrl` is ignored.
81
+ * - `"any"`: either `quote` or `quoteUrl` equal to the target suffices,
82
+ * even when the two disagree.
83
+ */
84
+ readonly quoteReference?: "strict" | "preferQuote" | "any";
85
+ /**
86
+ * Which `attributedTo` entries of the quote post may match the requester:
87
+ *
88
+ * - `"first"` (default): the first attribution must be the requester.
89
+ * - `"any"`: any attribution may be the requester.
90
+ */
91
+ readonly attribution?: "first" | "any";
92
+ /**
93
+ * What to do when the quote post has no attribution IRI, i.e., it has no
94
+ * `attributedTo` at all or only attributions embedded without an `id`:
95
+ *
96
+ * - `"reject"` (default): fail with `requesterMismatch`.
97
+ * - `"requester"`: treat the quote post as attributed to the requester.
98
+ *
99
+ * A present attribution IRI that does not match the requester always
100
+ * fails.
101
+ */
102
+ readonly missingAttribution?: "reject" | "requester";
30
103
  }
31
104
  type InteractionRequestVerification<TRequest extends Activity, TInteracting extends Object$1, TTarget extends Object$1> = {
32
105
  readonly verified: true;
@@ -48,14 +121,31 @@ type InteractionRequestVerificationFailure = {
48
121
  readonly type: "notDereferenceable";
49
122
  readonly url: URL;
50
123
  readonly cause?: unknown;
124
+ /**
125
+ * Whether the failure is likely transient, so that verifying again later
126
+ * could succeed. Always set by the built-in helpers.
127
+ * @since 2.5.0
128
+ */
129
+ readonly transient?: boolean;
51
130
  } | {
52
131
  readonly category: "unverifiable";
53
132
  readonly type: "unauthorizedFetchRequired";
54
133
  readonly url: URL;
134
+ /**
135
+ * Whether the failure is likely transient.
136
+ * @since 2.5.0
137
+ */
138
+ readonly transient?: boolean;
55
139
  } | {
56
140
  readonly category: "unverifiable";
57
141
  readonly type: "invalidJsonLd";
58
142
  readonly cause?: unknown;
143
+ /**
144
+ * Whether the failure is likely transient. Always `false` when set by
145
+ * the built-in helpers.
146
+ * @since 2.5.0
147
+ */
148
+ readonly transient?: boolean;
59
149
  } | {
60
150
  readonly category: "invalid";
61
151
  readonly type: "wrongType";
@@ -90,6 +180,42 @@ interface InteractionPolicyEvaluationOptions<TContextData, TTarget extends Objec
90
180
  readonly requester: URL;
91
181
  readonly documentLoader?: DocumentLoader;
92
182
  readonly matchesApprovalCollection?: MatchesApprovalCollection<TContextData>;
183
+ /**
184
+ * The rule to evaluate when the subject has no interaction policy, no rule
185
+ * for this interaction, or a rule without any approval entries. Without
186
+ * it, such subjects get the interaction's default decision.
187
+ * @since 2.5.0
188
+ */
189
+ readonly fallbackRule?: InteractionRule;
190
+ /**
191
+ * The order in which approval entries are matched:
192
+ *
193
+ * - `"actor"` (default): actors listed explicitly in either
194
+ * `automaticApproval` or `manualApproval` first, then the public
195
+ * collection and other collections, automatic before manual. An actor
196
+ * listed in `manualApproval` thus gets a manual decision even when
197
+ * `automaticApproval` contains the public collection.
198
+ * - `"automatic"`: every `automaticApproval` entry first, then every
199
+ * `manualApproval` entry. If an `automaticApproval` collection cannot
200
+ * be checked and no other automatic entry matches, the decision is
201
+ * `denied` with an `unverifiableCollection` reason rather than a manual
202
+ * decision, since the collection could have granted automatic
203
+ * approval.
204
+ * @since 2.5.0
205
+ */
206
+ readonly precedence?: "actor" | "automatic";
207
+ /**
208
+ * What to do when {@link matchesApprovalCollection} throws:
209
+ *
210
+ * - `"deny"` (default): skip the collection; if nothing else decides,
211
+ * the decision is `denied` with an `unverifiableCollection` reason
212
+ * carrying the error as its `cause`.
213
+ * - `"throw"`: rethrow the first error immediately, without calling the
214
+ * callback for later collections, so that the caller can retry later
215
+ * instead of rejecting the interaction.
216
+ * @since 2.5.0
217
+ */
218
+ readonly collectionErrors?: "deny" | "throw";
93
219
  }
94
220
  type MatchesApprovalCollection<TContextData> = (collection: URL, actor: URL, context: Context<TContextData>) => boolean | Promise<boolean>;
95
221
  type InteractionPolicyDecision = {
@@ -125,6 +251,11 @@ type InteractionPolicyDenialReason = {
125
251
  } | {
126
252
  readonly type: "unverifiableCollection";
127
253
  readonly collection: URL;
254
+ /**
255
+ * The error thrown while checking the collection.
256
+ * @since 2.5.0
257
+ */
258
+ readonly cause?: unknown;
128
259
  };
129
260
  interface InteractionRequestCreationOptions<TInteracting extends Object$1, TTarget extends Object$1> {
130
261
  readonly id: URL;
@@ -146,6 +277,34 @@ interface InteractionAuthorizationVerificationOptions<TContextData, TAuthorizati
146
277
  readonly interactionTarget: TTarget | URL;
147
278
  readonly attributedTo?: URL;
148
279
  readonly documentLoader?: DocumentLoader;
280
+ /**
281
+ * The document loader for remote JSON-LD contexts. Defaults to the
282
+ * document loader used for objects.
283
+ * @since 2.5.0
284
+ */
285
+ readonly contextLoader?: DocumentLoader;
286
+ /**
287
+ * The expected ID of the authorization. When the authorization is given
288
+ * as an object, its ID must equal this, or verification fails with
289
+ * `idMismatch`. When it is given as a URL, the URL must equal this.
290
+ *
291
+ * This only checks the identity of the authorization; it does not
292
+ * establish its authenticity. An authorization given as an object still
293
+ * needs {@link verifyAuthenticity}.
294
+ * @since 2.5.0
295
+ */
296
+ readonly authorizationId?: URL;
297
+ /**
298
+ * Whether to accept an authorization whose ID is on a different origin
299
+ * than its attributed actor, if {@link verifyAuthenticity} approves it.
300
+ * This is for authorizations whose authenticity is established by other
301
+ * means, such as a signed `Accept` from the attributed actor or a locally
302
+ * stored grant. Without {@link verifyAuthenticity}, such authorizations
303
+ * still fail with `originMismatch`. All other checks still apply.
304
+ * Defaults to `false`.
305
+ * @since 2.5.0
306
+ */
307
+ readonly allowOffOrigin?: boolean;
149
308
  readonly getRevocation?: GetInteractionAuthorizationRevocation<TContextData>;
150
309
  readonly verifyAuthenticity?: (authorization: TAuthorization, context: Context<TContextData>) => boolean | Promise<boolean>;
151
310
  }
@@ -164,14 +323,31 @@ type InteractionAuthorizationVerificationFailure = {
164
323
  readonly type: "notDereferenceable";
165
324
  readonly url: URL;
166
325
  readonly cause?: unknown;
326
+ /**
327
+ * Whether the failure is likely transient, so that verifying again later
328
+ * could succeed. Always set by the built-in helpers.
329
+ * @since 2.5.0
330
+ */
331
+ readonly transient?: boolean;
167
332
  } | {
168
333
  readonly category: "unverifiable";
169
334
  readonly type: "unauthorizedFetchRequired";
170
335
  readonly url: URL;
336
+ /**
337
+ * Whether the failure is likely transient.
338
+ * @since 2.5.0
339
+ */
340
+ readonly transient?: boolean;
171
341
  } | {
172
342
  readonly category: "unverifiable";
173
343
  readonly type: "invalidJsonLd";
174
344
  readonly cause?: unknown;
345
+ /**
346
+ * Whether the failure is likely transient. Always `false` when set by
347
+ * the built-in helpers.
348
+ * @since 2.5.0
349
+ */
350
+ readonly transient?: boolean;
175
351
  } | {
176
352
  readonly category: "unauthorized";
177
353
  readonly type: "wrongType";
@@ -218,44 +394,53 @@ interface InteractionAuthorizationRevocation {
218
394
  }
219
395
  type InteractionAcceptOptions<TRequest extends Activity, TAuthorization extends Object$1, TInteracting extends Object$1, TTarget extends Object$1> = {
220
396
  readonly mode: "polite";
221
- readonly id: URL;
397
+ readonly id?: URL;
222
398
  readonly actor: URL;
223
399
  readonly request: TRequest | URL;
224
400
  readonly authorization: TAuthorization | URL;
225
- readonly to: URL | readonly URL[];
401
+ readonly to?: URL | readonly URL[];
226
402
  readonly cc?: URL | readonly URL[];
227
403
  } | {
228
404
  readonly mode: "impolite";
229
- readonly id: URL;
405
+ readonly id?: URL;
230
406
  readonly actor: URL;
231
407
  readonly interactingObject: TInteracting | URL;
232
408
  readonly interactionTarget: TTarget | URL;
233
409
  readonly authorization: TAuthorization | URL;
234
- readonly to: URL | readonly URL[];
410
+ readonly to?: URL | readonly URL[];
235
411
  readonly cc?: URL | readonly URL[];
236
412
  };
237
413
  type InteractionRejectOptions<TRequest extends Activity, TInteracting extends Object$1, TTarget extends Object$1> = {
238
414
  readonly mode: "polite";
239
- readonly id: URL;
415
+ readonly id?: URL;
240
416
  readonly actor: URL;
241
417
  readonly request: TRequest | URL;
242
- readonly to: URL | readonly URL[];
418
+ readonly to?: URL | readonly URL[];
243
419
  readonly cc?: URL | readonly URL[];
244
420
  } | {
245
421
  readonly mode: "impolite";
246
- readonly id: URL;
422
+ readonly id?: URL;
247
423
  readonly actor: URL;
248
424
  readonly interactingObject: TInteracting | URL;
249
425
  readonly interactionTarget: TTarget | URL;
250
- readonly to: URL | readonly URL[];
426
+ readonly to?: URL | readonly URL[];
251
427
  readonly cc?: URL | readonly URL[];
252
428
  };
253
429
  interface InteractionRevocationCreationOptions<TAuthorization extends Object$1> {
254
- readonly id: URL;
430
+ readonly id?: URL;
255
431
  readonly actor: URL;
256
432
  readonly authorization: TAuthorization | URL;
257
- readonly to: URL | readonly URL[];
433
+ readonly to?: URL | readonly URL[];
258
434
  readonly cc?: URL | readonly URL[];
435
+ /**
436
+ * Whether to embed the authorization in the `Delete` activity instead of
437
+ * referring to it by its ID. Applies only when the authorization is given
438
+ * as an object. The embedded copy contains only the authorization's ID,
439
+ * attribution, and the IDs of its interacting object and interaction
440
+ * target, so that the revocation does not leak them. Defaults to `false`.
441
+ * @since 2.5.0
442
+ */
443
+ readonly embedAuthorization?: boolean;
259
444
  }
260
445
  interface RecognizedImpoliteInteraction<TInteracting extends Object$1, TTarget extends Object$1, TImpoliteSource extends Object$1> {
261
446
  readonly requester: URL;
@@ -311,11 +496,11 @@ declare const likeInteraction: InteractionControl<LikeRequest, LikeAuthorization
311
496
  //#region src/quote.d.ts
312
497
  type QuotePost = Note | Article | Question | ChatMessage;
313
498
  type QuoteImpoliteSource = Create | QuotePost;
314
- declare const quoteInteraction: InteractionControl<QuoteRequest, QuoteAuthorization, QuotePost, Object$1, QuoteImpoliteSource>;
499
+ declare const quoteInteraction: InteractionControl<QuoteRequest, QuoteAuthorization, QuotePost, Object$1, QuoteImpoliteSource, QuoteRequestValidationOptions>;
315
500
  //#endregion
316
501
  //#region src/reply.d.ts
317
502
  type ReplyPost = Note | Article | Question | ChatMessage;
318
503
  type ReplyImpoliteSource = Create | ReplyPost;
319
504
  declare const replyInteraction: InteractionControl<ReplyRequest, ReplyAuthorization, ReplyPost, Object$1, ReplyImpoliteSource>;
320
505
  //#endregion
321
- export { GetInteractionAuthorizationRevocation, ImpoliteInteractionEvidence, InteractionAcceptOptions, InteractionAuthorizationCreationOptions, InteractionAuthorizationKey, InteractionAuthorizationKeyInput, InteractionAuthorizationRevocation, InteractionAuthorizationVerification, InteractionAuthorizationVerificationFailure, InteractionAuthorizationVerificationOptions, InteractionControl, InteractionKey, InteractionKeyInput, InteractionName, InteractionPolicyDecision, InteractionPolicyDenialReason, InteractionPolicyEvaluationOptions, InteractionPolicyMatchReason, InteractionPolicyProperty, InteractionRejectOptions, InteractionRequestCreationOptions, InteractionRequestVerification, InteractionRequestVerificationFailure, InteractionRequestVerificationOptions, InteractionRevocationCreationOptions, MatchesApprovalCollection, type QuoteImpoliteSource, type QuotePost, RecognizedImpoliteInteraction, type ReplyImpoliteSource, type ReplyPost, announceInteraction, featureInteraction, formatAuthorizationKey, formatInteractionKey, likeInteraction, quoteInteraction, replyInteraction };
506
+ export { GetInteractionAuthorizationRevocation, ImpoliteInteractionEvidence, InteractionAcceptOptions, InteractionAuthorizationCreationOptions, InteractionAuthorizationKey, InteractionAuthorizationKeyInput, InteractionAuthorizationRevocation, InteractionAuthorizationVerification, InteractionAuthorizationVerificationFailure, InteractionAuthorizationVerificationOptions, InteractionControl, InteractionKey, InteractionKeyInput, InteractionName, InteractionPolicyDecision, InteractionPolicyDenialReason, InteractionPolicyEvaluationOptions, InteractionPolicyMatchReason, InteractionPolicyProperty, InteractionRejectOptions, InteractionRequestCreationOptions, InteractionRequestVerification, InteractionRequestVerificationFailure, InteractionRequestVerificationOptions, InteractionRevocationCreationOptions, MatchesApprovalCollection, type QuoteImpoliteSource, type QuotePost, QuoteRequestValidationOptions, RecognizedImpoliteInteraction, type ReplyImpoliteSource, type ReplyPost, announceInteraction, featureInteraction, formatAuthorizationKey, formatInteractionKey, likeInteraction, quoteInteraction, replyInteraction };