Skip to content

Commit

Permalink
fix: request.body can return undefined with express 5
Browse files Browse the repository at this point in the history
  • Loading branch information
paulrobertlloyd committed Nov 26, 2024
1 parent ea124af commit c11e926
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion packages/endpoint-auth/lib/controllers/consent.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const consentController = {
* @see {@link https://indieauth.spec.indieweb.org/#authorization-response}
*/
post(request, response) {
let { scope } = request.body;
let scope = request.body?.scope;
const {
client_id,
code_challenge,
Expand Down
2 changes: 1 addition & 1 deletion packages/endpoint-auth/lib/controllers/introspection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export const introspectionController = {
*/
post(request, response) {
try {
let { token } = request.body;
let token = request.body?.token;

if (!token) {
// Remove ‘Bearer ’ from authorization header
Expand Down
2 changes: 1 addition & 1 deletion packages/endpoint-posts/lib/middleware/post-data.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export const postData = {

// Create new post object with default values
const postType = request.query.type || "note";
const properties = request?.body || {};
const properties = request.body || {};

// Get post type config
const { name, fields, h } = publication.postTypes[postType];
Expand Down
4 changes: 2 additions & 2 deletions packages/endpoint-syndicate/lib/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@ import { IndiekitError } from "@indiekit/error";
import jwt from "jsonwebtoken";

export const findBearerToken = (request) => {
if (request.headers?.["x-webhook-signature"] && request?.body?.url) {
if (request.headers?.["x-webhook-signature"] && request.body?.url) {
const signature = request.headers["x-webhook-signature"];
const verifiedToken = verifyToken(signature);
const bearerToken = signToken(verifiedToken, request.body.url);
return bearerToken;
}

if (request?.body?.access_token) {
if (request.body?.access_token) {
const bearerToken = request.body.access_token;
delete request.body.access_token;
return bearerToken;
Expand Down

0 comments on commit c11e926

Please sign in to comment.