@threadbase-sh/streamer 1.52.6 → 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 +13 -10
- package/dist/cli.cjs.map +1 -1
- package/dist/index.cjs +13 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +13 -10
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4118,21 +4118,16 @@ var authMiddleware = (deps) => async (c, next) => {
|
|
|
4118
4118
|
await next();
|
|
4119
4119
|
return;
|
|
4120
4120
|
}
|
|
4121
|
-
|
|
4122
|
-
if (isLocalRequest(remoteAddr)) {
|
|
4123
|
-
await next();
|
|
4124
|
-
return;
|
|
4125
|
-
}
|
|
4126
|
-
}
|
|
4121
|
+
const loopbackOwner = deps.localNoAuth && isLocalRequest(remoteAddr);
|
|
4127
4122
|
const authorization = c.req.header("authorization");
|
|
4128
4123
|
const bearer = authorization?.startsWith("Bearer ") ? authorization.slice(7) : void 0;
|
|
4129
4124
|
const queryKey = c.req.query("key") ?? void 0;
|
|
4130
4125
|
const presented = bearer ?? queryKey;
|
|
4131
|
-
if (!presented) {
|
|
4126
|
+
if (!presented && !loopbackOwner) {
|
|
4132
4127
|
return c.json({ error: "Unauthorized" }, 401);
|
|
4133
4128
|
}
|
|
4134
4129
|
let principal = null;
|
|
4135
|
-
const device = deps.devicesRepo()?.authenticate(presented) ?? null;
|
|
4130
|
+
const device = presented ? deps.devicesRepo()?.authenticate(presented) ?? null : null;
|
|
4136
4131
|
if (device) {
|
|
4137
4132
|
principal = {
|
|
4138
4133
|
kind: "device",
|
|
@@ -4143,7 +4138,9 @@ var authMiddleware = (deps) => async (c, next) => {
|
|
|
4143
4138
|
deps.devicesRepo()?.touch(device.device_id);
|
|
4144
4139
|
} catch {
|
|
4145
4140
|
}
|
|
4146
|
-
} else if (validateApiKey(presented, deps.apiKey)) {
|
|
4141
|
+
} else if (presented && validateApiKey(presented, deps.apiKey)) {
|
|
4142
|
+
principal = legacyPrincipal();
|
|
4143
|
+
} else if (loopbackOwner) {
|
|
4147
4144
|
principal = legacyPrincipal();
|
|
4148
4145
|
}
|
|
4149
4146
|
if (!principal) {
|
|
@@ -14002,9 +13999,15 @@ function getSortValue(s, key) {
|
|
|
14002
13999
|
case "projectName":
|
|
14003
14000
|
return s.projectName;
|
|
14004
14001
|
case "status":
|
|
14005
|
-
return s
|
|
14002
|
+
return statusSortValue(s);
|
|
14006
14003
|
}
|
|
14007
14004
|
}
|
|
14005
|
+
function statusSortValue(s) {
|
|
14006
|
+
const rank = s.status === "idle" ? 1 : 0;
|
|
14007
|
+
const activeAt = Date.parse(s.lastActivityAt ?? s.startedAt);
|
|
14008
|
+
const recency = String(1e15 - (Number.isNaN(activeAt) ? 0 : activeAt)).padStart(16, "0");
|
|
14009
|
+
return `${rank}:${recency}`;
|
|
14010
|
+
}
|
|
14008
14011
|
function compareValues(a, b) {
|
|
14009
14012
|
if (a === void 0 && b === void 0) return 0;
|
|
14010
14013
|
if (a === void 0) return 1;
|