@rmdes/indiekit-endpoint-activitypub 3.7.3 → 3.7.4

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/index.js CHANGED
@@ -721,19 +721,13 @@ export default class ActivityPubEndpoint {
721
721
  );
722
722
 
723
723
  // Resolve the remote actor to get their inbox
724
- // Try authenticated document loader first (for Authorized Fetch servers),
725
- // fall back to unsigned if that fails (some servers reject signed GETs)
724
+ // lookupWithSecurity handles signed→unsigned fallback automatically
726
725
  const documentLoader = await ctx.getDocumentLoader({
727
726
  identifier: handle,
728
727
  });
729
- let remoteActor = await lookupWithSecurity(ctx, actorUrl, {
728
+ const remoteActor = await lookupWithSecurity(ctx, actorUrl, {
730
729
  documentLoader,
731
730
  });
732
- if (!remoteActor) {
733
- // Retry without authentication — some servers (e.g., tags.pub)
734
- // may reject or mishandle signed GET requests
735
- remoteActor = await lookupWithSecurity(ctx, actorUrl);
736
- }
737
731
  if (!remoteActor) {
738
732
  return { ok: false, error: "Could not resolve remote actor" };
739
733
  }
@@ -60,7 +60,8 @@ export function resolveController(mountPath, plugin) {
60
60
  let object;
61
61
 
62
62
  try {
63
- object = await lookupWithSecurity(ctx,lookupInput, { documentLoader });
63
+ // lookupWithSecurity handles signed→unsigned fallback automatically
64
+ object = await lookupWithSecurity(ctx, lookupInput, { documentLoader });
64
65
  } catch (error) {
65
66
  console.warn(
66
67
  `[resolve] lookupObject failed for "${query}":`,
@@ -14,14 +14,36 @@
14
14
  * Using `crossOrigin: "ignore"` tells Fedify to silently discard objects
15
15
  * whose id doesn't match the fetch origin, rather than throwing.
16
16
  *
17
+ * When an authenticated document loader is provided (for Authorized Fetch
18
+ * compatibility), the lookup is tried with it first. If it fails (some
19
+ * servers like tags.pub return 400 for signed GETs), a fallback to the
20
+ * default unsigned loader is attempted automatically.
21
+ *
17
22
  * @param {object} ctx - Fedify Context
18
23
  * @param {string|URL} input - URL or handle to look up
19
24
  * @param {object} [options] - Additional options passed to lookupObject
20
25
  * @returns {Promise<object|null>} Resolved object or null
21
26
  */
22
- export function lookupWithSecurity(ctx, input, options = {}) {
23
- return ctx.lookupObject(input, {
24
- crossOrigin: "ignore",
25
- ...options,
26
- });
27
+ export async function lookupWithSecurity(ctx, input, options = {}) {
28
+ const baseOptions = { crossOrigin: "ignore", ...options };
29
+
30
+ let result = null;
31
+ try {
32
+ result = await ctx.lookupObject(input, baseOptions);
33
+ } catch {
34
+ // signed lookup threw — fall through to unsigned
35
+ }
36
+
37
+ // If signed lookup failed and we used a custom documentLoader,
38
+ // retry without it (unsigned GET)
39
+ if (!result && options.documentLoader) {
40
+ try {
41
+ const { documentLoader: _, ...unsignedOptions } = baseOptions;
42
+ result = await ctx.lookupObject(input, unsignedOptions);
43
+ } catch {
44
+ // unsigned also failed — return null
45
+ }
46
+ }
47
+
48
+ return result;
27
49
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-activitypub",
3
- "version": "3.7.3",
3
+ "version": "3.7.4",
4
4
  "description": "ActivityPub federation endpoint for Indiekit via Fedify. Adds full fediverse support: actor, inbox, outbox, followers, following, syndication, and Mastodon migration.",
5
5
  "keywords": [
6
6
  "indiekit",