@threadbase-sh/streamer 1.53.0 → 1.53.1

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.cjs CHANGED
@@ -4171,21 +4171,16 @@ var authMiddleware = (deps) => async (c, next) => {
4171
4171
  await next();
4172
4172
  return;
4173
4173
  }
4174
- if (deps.localNoAuth) {
4175
- if (isLocalRequest(remoteAddr)) {
4176
- await next();
4177
- return;
4178
- }
4179
- }
4174
+ const loopbackOwner = deps.localNoAuth && isLocalRequest(remoteAddr);
4180
4175
  const authorization = c.req.header("authorization");
4181
4176
  const bearer = authorization?.startsWith("Bearer ") ? authorization.slice(7) : void 0;
4182
4177
  const queryKey = c.req.query("key") ?? void 0;
4183
4178
  const presented = bearer ?? queryKey;
4184
- if (!presented) {
4179
+ if (!presented && !loopbackOwner) {
4185
4180
  return c.json({ error: "Unauthorized" }, 401);
4186
4181
  }
4187
4182
  let principal = null;
4188
- const device = deps.devicesRepo()?.authenticate(presented) ?? null;
4183
+ const device = presented ? deps.devicesRepo()?.authenticate(presented) ?? null : null;
4189
4184
  if (device) {
4190
4185
  principal = {
4191
4186
  kind: "device",
@@ -4196,7 +4191,9 @@ var authMiddleware = (deps) => async (c, next) => {
4196
4191
  deps.devicesRepo()?.touch(device.device_id);
4197
4192
  } catch {
4198
4193
  }
4199
- } else if (validateApiKey(presented, deps.apiKey)) {
4194
+ } else if (presented && validateApiKey(presented, deps.apiKey)) {
4195
+ principal = legacyPrincipal();
4196
+ } else if (loopbackOwner) {
4200
4197
  principal = legacyPrincipal();
4201
4198
  }
4202
4199
  if (!principal) {