@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/cli.cjs CHANGED
@@ -134200,21 +134200,16 @@ var authMiddleware = (deps) => async (c, next) => {
134200
134200
  await next();
134201
134201
  return;
134202
134202
  }
134203
- if (deps.localNoAuth) {
134204
- if (isLocalRequest(remoteAddr)) {
134205
- await next();
134206
- return;
134207
- }
134208
- }
134203
+ const loopbackOwner = deps.localNoAuth && isLocalRequest(remoteAddr);
134209
134204
  const authorization = c.req.header("authorization");
134210
134205
  const bearer = authorization?.startsWith("Bearer ") ? authorization.slice(7) : void 0;
134211
134206
  const queryKey = c.req.query("key") ?? void 0;
134212
134207
  const presented = bearer ?? queryKey;
134213
- if (!presented) {
134208
+ if (!presented && !loopbackOwner) {
134214
134209
  return c.json({ error: "Unauthorized" }, 401);
134215
134210
  }
134216
134211
  let principal = null;
134217
- const device = deps.devicesRepo()?.authenticate(presented) ?? null;
134212
+ const device = presented ? deps.devicesRepo()?.authenticate(presented) ?? null : null;
134218
134213
  if (device) {
134219
134214
  principal = {
134220
134215
  kind: "device",
@@ -134225,7 +134220,9 @@ var authMiddleware = (deps) => async (c, next) => {
134225
134220
  deps.devicesRepo()?.touch(device.device_id);
134226
134221
  } catch {
134227
134222
  }
134228
- } else if (validateApiKey(presented, deps.apiKey)) {
134223
+ } else if (presented && validateApiKey(presented, deps.apiKey)) {
134224
+ principal = legacyPrincipal();
134225
+ } else if (loopbackOwner) {
134229
134226
  principal = legacyPrincipal();
134230
134227
  }
134231
134228
  if (!principal) {