@rmdes/indiekit-endpoint-activitypub 3.5.2 → 3.5.3

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.
@@ -174,7 +174,7 @@ router.get("/.well-known/oauth-authorization-server", (req, res) => {
174
174
 
175
175
  router.get("/oauth/authorize", async (req, res, next) => {
176
176
  try {
177
- const {
177
+ let {
178
178
  client_id,
179
179
  redirect_uri,
180
180
  response_type,
@@ -184,6 +184,21 @@ router.get("/oauth/authorize", async (req, res, next) => {
184
184
  force_login,
185
185
  } = req.query;
186
186
 
187
+ // Restore OAuth params from session after login redirect.
188
+ // Indiekit's login flow doesn't re-encode the redirect param, so query
189
+ // params with & are stripped during the /session/login → /session/auth
190
+ // round-trip. We store them in the session before redirecting.
191
+ if (!response_type && req.session?.pendingOAuth) {
192
+ const p = req.session.pendingOAuth;
193
+ delete req.session.pendingOAuth;
194
+ client_id = p.client_id;
195
+ redirect_uri = p.redirect_uri;
196
+ response_type = p.response_type;
197
+ scope = p.scope;
198
+ code_challenge = p.code_challenge;
199
+ code_challenge_method = p.code_challenge_method;
200
+ }
201
+
187
202
  if (response_type !== "code") {
188
203
  return res.status(400).json({
189
204
  error: "unsupported_response_type",
@@ -219,12 +234,14 @@ router.get("/oauth/authorize", async (req, res, next) => {
219
234
  // Check if user is logged in via IndieAuth session
220
235
  const session = req.session;
221
236
  if (!session?.access_token && !force_login) {
222
- // Not logged in — redirect to Indiekit's login page, then back here.
223
- // Indiekit uses /session/login?redirect=<path> (see indieauth.js authenticate()).
224
- // The redirect value must be a local path (validated by regex in indieauth.js).
225
- return res.redirect(
226
- `/session/login?redirect=${encodeURIComponent(req.originalUrl)}`,
227
- );
237
+ // Store OAuth params in session they won't survive Indiekit's
238
+ // login redirect chain due to a re-encoding bug in indieauth.js.
239
+ req.session.pendingOAuth = {
240
+ client_id, redirect_uri, response_type, scope,
241
+ code_challenge, code_challenge_method,
242
+ };
243
+ // Redirect to Indiekit's login page with a simple return path.
244
+ return res.redirect("/session/login?redirect=/oauth/authorize");
228
245
  }
229
246
 
230
247
  // Render simple authorization page
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmdes/indiekit-endpoint-activitypub",
3
- "version": "3.5.2",
3
+ "version": "3.5.3",
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",