cauthy-auth 0.24.2 → 0.24.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.
package/dist/index.js CHANGED
@@ -1145,10 +1145,11 @@ function createCauthy(given = {}) {
1145
1145
  const clientIp = given.clientIp ?? ((request) => request.headers.get("x-forwarded-for")?.split(",").pop()?.trim() || void 0);
1146
1146
  let noProofUntil = 0;
1147
1147
  async function passedOn(request) {
1148
+ if (Date.now() < noProofUntil) return {};
1148
1149
  const ip = clientIp(request);
1149
- if (!ip || Date.now() < noProofUntil) return {};
1150
1150
  try {
1151
- return { "x-cauthy-client-ip": ip, "x-cauthy-system-token": await ownSystem.token() };
1151
+ const proof = { "x-cauthy-system-token": await ownSystem.token() };
1152
+ return ip ? { ...proof, "x-cauthy-client-ip": ip } : proof;
1152
1153
  } catch {
1153
1154
  noProofUntil = Date.now() + 5 * 6e4;
1154
1155
  return {};