Commit 12995f1c authored by Hong Minhee's avatar Hong Minhee
Browse files

Merge tag '0.15.7' into 1.0-maintenance

parents e05ef206 7120bc08
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -8,6 +8,19 @@ Version 1.0.9

To be released.

 -  Suppressed a `TypeError` with a message <q>unusable</q> due to Node.js's
    mysterious behavior.  [[#159]]

     -  The `verifyRequest()` function no longer throws a `TypeError`
        when a given `Request` object's body is already consumed or locked.
        Instead, it logs an error message to the `["fedify", "sig", "http"]`
        logger category and returns `null`.
     -  The `Federation.fetch()` method no longer throws a `TypeError`
        when a given `Request` object's body is already consumed or locked.
        Instead, it logs an error message to the `["fedify", "federation",
        "inbox"]` logger category and responds with a `500 Internal Server
        Error`.


Version 1.0.8
-------------
@@ -274,6 +287,27 @@ Released on September 26, 2024.
[#137]: https://github.com/dahlia/fedify/issues/137


Version 0.15.7
--------------

Released on November 14, 2024.

 -  Suppressed a `TypeError` with a message <q>unusable</q> due to Node.js's
    mysterious behavior.  [[#159]]

     -  The `verifyRequest()` function no longer throws a `TypeError`
        when a given `Request` object's body is already consumed or locked.
        Instead, it logs an error message to the `["fedify", "sig", "http"]`
        logger category and returns `null`.
     -  The `Federation.fetch()` method no longer throws a `TypeError`
        when a given `Request` object's body is already consumed or locked.
        Instead, it logs an error message to the `["fedify", "federation",
        "inbox"]` logger category and responds with a `500 Internal Server
        Error`.

[#159]: https://github.com/dahlia/fedify/issues/159


Version 0.15.6
--------------

+13 −0
Original line number Diff line number Diff line
@@ -388,6 +388,19 @@ export async function handleInbox<TContextData>(
      return await onNotFound(request);
    }
  }
  if (request.bodyUsed) {
    logger.error("Request body has already been read.", { identifier });
    return new Response("Internal server error.", {
      status: 500,
      headers: { "Content-Type": "text/plain; charset=utf-8" },
    });
  } else if (request.body?.locked) {
    logger.error("Request body is locked.", { identifier });
    return new Response("Internal server error.", {
      status: 500,
      headers: { "Content-Type": "text/plain; charset=utf-8" },
    });
  }
  let json: unknown;
  try {
    json = await request.clone().json();
+13 −0
Original line number Diff line number Diff line
@@ -123,6 +123,19 @@ export async function verifyRequest(
    VerifyRequestOptions = {},
): Promise<CryptographicKey | null> {
  const logger = getLogger(["fedify", "sig", "http"]);
  if (request.bodyUsed) {
    logger.error(
      "Failed to verify; the request body is already consumed.",
      { url: request.url },
    );
    return null;
  } else if (request.body?.locked) {
    logger.error(
      "Failed to verify; the request body is locked.",
      { url: request.url },
    );
    return null;
  }
  const originalRequest = request;
  request = request.clone();
  const dateHeader = request.headers.get("Date");