From d3c094f91f4b0f7017a01499a8f9f381281fa967 Mon Sep 17 00:00:00 2001 From: Sven Date: Sat, 14 Mar 2026 13:53:40 +0100 Subject: [PATCH] update: activitypub --- package.json | 6 +- ...oint-activitypub-private-url-docloader.mjs | 178 ------------------ 2 files changed, 3 insertions(+), 181 deletions(-) delete mode 100644 scripts/patch-endpoint-activitypub-private-url-docloader.mjs diff --git a/package.json b/package.json index 76ca5e56..c39e4820 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "description": "", "main": "index.js", "scripts": { - "postinstall": "xattr -w com.apple.fileprovider.ignore#P 1 node_modules 2>/dev/null || true && node scripts/patch-lightningcss.mjs && node scripts/patch-endpoint-media-scope.mjs && node scripts/patch-endpoint-media-sharp-runtime.mjs && node scripts/patch-frontend-sharp-runtime.mjs && node scripts/patch-endpoint-files-upload-route.mjs && node scripts/patch-endpoint-files-upload-locales.mjs && node scripts/patch-endpoint-activitypub-locales.mjs && node scripts/patch-endpoint-activitypub-private-url-docloader.mjs && node scripts/patch-endpoint-homepage-locales.mjs && node scripts/patch-endpoint-homepage-identity-defaults.mjs && node scripts/patch-federation-unlisted-guards.mjs && node scripts/patch-endpoint-micropub-where-note-visibility.mjs && node scripts/patch-endpoint-posts-ai-fields.mjs && node scripts/patch-endpoint-posts-ai-cleanup.mjs && node scripts/patch-endpoint-podroll-opml-upload.mjs && node scripts/patch-preset-eleventy-ai-frontmatter.mjs && node scripts/patch-micropub-ai-block-resync.mjs && node scripts/patch-frontend-serviceworker-file.mjs && node scripts/patch-endpoint-comments-locales.mjs && node scripts/patch-conversations-collection-guards.mjs && node scripts/patch-conversations-mastodon-disconnect.mjs && node scripts/patch-indiekit-routes-rate-limits.mjs && node scripts/patch-indiekit-error-production-stack.mjs && node scripts/patch-indieauth-devmode-guard.mjs && node scripts/patch-listening-endpoint-runtime-guards.mjs && node scripts/patch-endpoint-github-changelog-categories.mjs && node scripts/patch-microsub-reader-ap-dispatch.mjs && node scripts/patch-endpoint-blogroll-feeds-alias.mjs && node scripts/patch-endpoint-posts-uid-lookup.mjs && node scripts/patch-endpoint-posts-prefill-url.mjs && node scripts/patch-microsub-feed-discovery.mjs", - "serve":"export NODE_ENV=${NODE_ENV:-production} INDIEKIT_DEBUG=${INDIEKIT_DEBUG:-0} && node scripts/preflight-production-security.mjs && node scripts/preflight-mongo-connection.mjs && node scripts/preflight-activitypub-rsa-key.mjs && node scripts/preflight-activitypub-profile-urls.mjs && node scripts/patch-lightningcss.mjs && node scripts/patch-endpoint-media-scope.mjs && node scripts/patch-endpoint-media-sharp-runtime.mjs && node scripts/patch-frontend-sharp-runtime.mjs && node scripts/patch-endpoint-files-upload-route.mjs && node scripts/patch-endpoint-files-upload-locales.mjs && node scripts/patch-endpoint-activitypub-locales.mjs && node scripts/patch-endpoint-activitypub-private-url-docloader.mjs && node scripts/patch-endpoint-homepage-locales.mjs && node scripts/patch-endpoint-homepage-identity-defaults.mjs && node scripts/patch-federation-unlisted-guards.mjs && node scripts/patch-endpoint-micropub-where-note-visibility.mjs && node scripts/patch-endpoint-posts-ai-fields.mjs && node scripts/patch-endpoint-posts-ai-cleanup.mjs && node scripts/patch-endpoint-podroll-opml-upload.mjs && node scripts/patch-preset-eleventy-ai-frontmatter.mjs && node scripts/patch-micropub-ai-block-resync.mjs && node scripts/patch-frontend-serviceworker-file.mjs && node scripts/patch-endpoint-comments-locales.mjs && node scripts/patch-conversations-collection-guards.mjs && node scripts/patch-conversations-mastodon-disconnect.mjs && node scripts/patch-indiekit-routes-rate-limits.mjs && node scripts/patch-indiekit-error-production-stack.mjs && node scripts/patch-indieauth-devmode-guard.mjs && node scripts/patch-listening-endpoint-runtime-guards.mjs && node scripts/patch-endpoint-github-changelog-categories.mjs && node scripts/patch-microsub-reader-ap-dispatch.mjs && node scripts/patch-endpoint-blogroll-feeds-alias.mjs && node scripts/patch-endpoint-posts-uid-lookup.mjs && node scripts/patch-endpoint-posts-prefill-url.mjs && node scripts/patch-microsub-feed-discovery.mjs && node node_modules/@indiekit/indiekit/bin/cli.js serve --config indiekit.config.mjs", + "postinstall": "xattr -w com.apple.fileprovider.ignore#P 1 node_modules 2>/dev/null || true && node scripts/patch-lightningcss.mjs && node scripts/patch-endpoint-media-scope.mjs && node scripts/patch-endpoint-media-sharp-runtime.mjs && node scripts/patch-frontend-sharp-runtime.mjs && node scripts/patch-endpoint-files-upload-route.mjs && node scripts/patch-endpoint-files-upload-locales.mjs && node scripts/patch-endpoint-activitypub-locales.mjs && node scripts/patch-endpoint-homepage-locales.mjs && node scripts/patch-endpoint-homepage-identity-defaults.mjs && node scripts/patch-federation-unlisted-guards.mjs && node scripts/patch-endpoint-micropub-where-note-visibility.mjs && node scripts/patch-endpoint-posts-ai-fields.mjs && node scripts/patch-endpoint-posts-ai-cleanup.mjs && node scripts/patch-endpoint-podroll-opml-upload.mjs && node scripts/patch-preset-eleventy-ai-frontmatter.mjs && node scripts/patch-micropub-ai-block-resync.mjs && node scripts/patch-frontend-serviceworker-file.mjs && node scripts/patch-endpoint-comments-locales.mjs && node scripts/patch-conversations-collection-guards.mjs && node scripts/patch-conversations-mastodon-disconnect.mjs && node scripts/patch-indiekit-routes-rate-limits.mjs && node scripts/patch-indiekit-error-production-stack.mjs && node scripts/patch-indieauth-devmode-guard.mjs && node scripts/patch-listening-endpoint-runtime-guards.mjs && node scripts/patch-endpoint-github-changelog-categories.mjs && node scripts/patch-microsub-reader-ap-dispatch.mjs && node scripts/patch-endpoint-blogroll-feeds-alias.mjs && node scripts/patch-endpoint-posts-uid-lookup.mjs && node scripts/patch-endpoint-posts-prefill-url.mjs && node scripts/patch-microsub-feed-discovery.mjs", + "serve":"export NODE_ENV=${NODE_ENV:-production} INDIEKIT_DEBUG=${INDIEKIT_DEBUG:-0} && node scripts/preflight-production-security.mjs && node scripts/preflight-mongo-connection.mjs && node scripts/preflight-activitypub-rsa-key.mjs && node scripts/preflight-activitypub-profile-urls.mjs && node scripts/patch-lightningcss.mjs && node scripts/patch-endpoint-media-scope.mjs && node scripts/patch-endpoint-media-sharp-runtime.mjs && node scripts/patch-frontend-sharp-runtime.mjs && node scripts/patch-endpoint-files-upload-route.mjs && node scripts/patch-endpoint-files-upload-locales.mjs && node scripts/patch-endpoint-activitypub-locales.mjs && node scripts/patch-endpoint-homepage-locales.mjs && node scripts/patch-endpoint-homepage-identity-defaults.mjs && node scripts/patch-federation-unlisted-guards.mjs && node scripts/patch-endpoint-micropub-where-note-visibility.mjs && node scripts/patch-endpoint-posts-ai-fields.mjs && node scripts/patch-endpoint-posts-ai-cleanup.mjs && node scripts/patch-endpoint-podroll-opml-upload.mjs && node scripts/patch-preset-eleventy-ai-frontmatter.mjs && node scripts/patch-micropub-ai-block-resync.mjs && node scripts/patch-frontend-serviceworker-file.mjs && node scripts/patch-endpoint-comments-locales.mjs && node scripts/patch-conversations-collection-guards.mjs && node scripts/patch-conversations-mastodon-disconnect.mjs && node scripts/patch-indiekit-routes-rate-limits.mjs && node scripts/patch-indiekit-error-production-stack.mjs && node scripts/patch-indieauth-devmode-guard.mjs && node scripts/patch-listening-endpoint-runtime-guards.mjs && node scripts/patch-endpoint-github-changelog-categories.mjs && node scripts/patch-microsub-reader-ap-dispatch.mjs && node scripts/patch-endpoint-blogroll-feeds-alias.mjs && node scripts/patch-endpoint-posts-uid-lookup.mjs && node scripts/patch-endpoint-posts-prefill-url.mjs && node scripts/patch-microsub-feed-discovery.mjs && node node_modules/@indiekit/indiekit/bin/cli.js serve --config indiekit.config.mjs", "test": "echo \"Error: no test specified\" && exit 1" }, "keywords": [], @@ -25,7 +25,7 @@ "@indiekit/indiekit": "^1.0.0-beta.25", "@indiekit/post-type-repost": "^1.0.0-beta.25", "@indiekit/store-github": "^1.0.0-beta.25", - "@rmdes/indiekit-endpoint-activitypub": "^2.8.2", + "@rmdes/indiekit-endpoint-activitypub": "github:svemagie/indiekit-endpoint-activitypub", "@rmdes/indiekit-endpoint-auth": "^1.0.0-beta.25", "@rmdes/indiekit-endpoint-blogroll": "github:svemagie/indiekit-endpoint-blogroll#bookmark-import", "@rmdes/indiekit-endpoint-comments": "^1.0.0", diff --git a/scripts/patch-endpoint-activitypub-private-url-docloader.mjs b/scripts/patch-endpoint-activitypub-private-url-docloader.mjs deleted file mode 100644 index db56d554..00000000 --- a/scripts/patch-endpoint-activitypub-private-url-docloader.mjs +++ /dev/null @@ -1,178 +0,0 @@ -import { access, readFile, writeFile } from "node:fs/promises"; - -const patchSpecs = [ - // compose.js: createPublicationAwareDocumentLoader and rawDocumentLoader wrapping - // are now built into the fork — no patch needed. - { - name: "activitypub-resolve-author-publication-private-docloader", - candidates: [ - "node_modules/@rmdes/indiekit-endpoint-activitypub/lib/resolve-author.js", - "node_modules/@indiekit/indiekit/node_modules/@rmdes/indiekit-endpoint-activitypub/lib/resolve-author.js", - ], - replacements: [ - { - oldSnippet: [ - "}", - "", - "/**", - " * Resolve the author Actor for a given post URL.", - ].join("\n"), - newSnippet: [ - "}", - "", - "function createPublicationAwareDocumentLoader(documentLoader, publicationUrl) {", - " if (typeof documentLoader !== \"function\") {", - " return documentLoader;", - " }", - "", - " let publicationHost = \"\";", - " try {", - " publicationHost = new URL(publicationUrl).hostname;", - " } catch {", - " return documentLoader;", - " }", - "", - " return (url, options = {}) => {", - " try {", - " const parsed = new URL(", - " typeof url === \"string\" ? url : (url?.href || String(url)),", - " );", - " if (parsed.hostname === publicationHost) {", - " return documentLoader(url, { ...options, allowPrivateAddress: true });", - " }", - " } catch {", - " // Fall through to default loader behavior.", - " }", - "", - " return documentLoader(url, options);", - " };", - "}", - "", - "/**", - " * Resolve the author Actor for a given post URL.", - ].join("\n"), - }, - { - oldSnippet: [ - "export async function resolveAuthor(", - " postUrl,", - " ctx,", - " documentLoader,", - " collections,", - ") {", - " // Strategy 1: Look up remote post via Fedify (signed request)", - ].join("\n"), - newSnippet: [ - "export async function resolveAuthor(", - " postUrl,", - " ctx,", - " documentLoader,", - " collections,", - ") {", - " const publicationLoader = createPublicationAwareDocumentLoader(", - " documentLoader,", - " ctx?.url?.href || \"\",", - " );", - "", - " // Strategy 1: Look up remote post via Fedify (signed request)", - ].join("\n"), - }, - { - oldSnippet: [ - " const remoteObject = await ctx.lookupObject(new URL(postUrl), {", - " documentLoader,", - " });", - " if (remoteObject && typeof remoteObject.getAttributedTo === \"function\") {", - " const author = await remoteObject.getAttributedTo({ documentLoader });", - ].join("\n"), - newSnippet: [ - " const remoteObject = await ctx.lookupObject(new URL(postUrl), {", - " documentLoader: publicationLoader,", - " });", - " if (remoteObject && typeof remoteObject.getAttributedTo === \"function\") {", - " const author = await remoteObject.getAttributedTo({", - " documentLoader: publicationLoader,", - " });", - ].join("\n"), - }, - { - oldSnippet: [ - " const actor = await ctx.lookupObject(new URL(authorUrl), {", - " documentLoader,", - " });", - ].join("\n"), - newSnippet: [ - " const actor = await ctx.lookupObject(new URL(authorUrl), {", - " documentLoader: publicationLoader,", - " });", - ].join("\n"), - }, - { - oldSnippet: [ - " const actor = await ctx.lookupObject(new URL(extractedUrl), {", - " documentLoader,", - " });", - ].join("\n"), - newSnippet: [ - " const actor = await ctx.lookupObject(new URL(extractedUrl), {", - " documentLoader: publicationLoader,", - " });", - ].join("\n"), - }, - ], - }, -]; - -async function exists(filePath) { - try { - await access(filePath); - return true; - } catch { - return false; - } -} - -let filesChecked = 0; -let filesPatched = 0; - -for (const patchSpec of patchSpecs) { - for (const filePath of patchSpec.candidates) { - if (!(await exists(filePath))) { - continue; - } - - filesChecked += 1; - - const source = await readFile(filePath, "utf8"); - let updated = source; - - for (const replacement of patchSpec.replacements) { - if (updated.includes(replacement.newSnippet)) { - continue; - } - - if (!updated.includes(replacement.oldSnippet)) { - continue; - } - - updated = updated.replace(replacement.oldSnippet, replacement.newSnippet); - } - - if (updated === source) { - continue; - } - - await writeFile(filePath, updated, "utf8"); - filesPatched += 1; - } -} - -if (filesChecked === 0) { - console.log("[postinstall] No activitypub private-url patch targets found"); -} else if (filesPatched === 0) { - console.log("[postinstall] activitypub private-url docloader patch already applied"); -} else { - console.log( - `[postinstall] Patched activitypub publication-host private-url handling in ${filesPatched}/${filesChecked} file(s)`, - ); -} \ No newline at end of file