@kenhkl/agent-gate 0.8.0 → 0.8.2
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/v1/cli.js +18 -8
- package/dist/v1/server.js +14 -7
- package/dist/v3/cli.js +18 -8
- package/package.json +1 -1
package/dist/v1/cli.js
CHANGED
|
@@ -1453,7 +1453,7 @@ var init_version = __esm({
|
|
|
1453
1453
|
"src/version.ts"() {
|
|
1454
1454
|
"use strict";
|
|
1455
1455
|
init_cjs_shims();
|
|
1456
|
-
_version = true ? "0.8.
|
|
1456
|
+
_version = true ? "0.8.2" : (() => {
|
|
1457
1457
|
try {
|
|
1458
1458
|
const require2 = createRequire(importMetaUrl);
|
|
1459
1459
|
const pkg = require2("../package.json");
|
|
@@ -1983,7 +1983,12 @@ function createApp() {
|
|
|
1983
1983
|
allowMethods: ["GET", "POST", "OPTIONS", "DELETE"],
|
|
1984
1984
|
allowHeaders: ["*"]
|
|
1985
1985
|
}));
|
|
1986
|
-
app.use(
|
|
1986
|
+
app.use(
|
|
1987
|
+
"*",
|
|
1988
|
+
(0, import_logger.logger)(
|
|
1989
|
+
(str, ...rest) => console.log(str.replace(/([?&]token=)[^&\s"']+/gi, "$1***"), ...rest)
|
|
1990
|
+
)
|
|
1991
|
+
);
|
|
1987
1992
|
app.use("*", async (c, next) => {
|
|
1988
1993
|
const path = new URL(c.req.url).pathname;
|
|
1989
1994
|
const method = c.req.method.toUpperCase();
|
|
@@ -2082,7 +2087,11 @@ function createApp() {
|
|
|
2082
2087
|
async function dashboardRoute(c) {
|
|
2083
2088
|
if (authEnabled()) {
|
|
2084
2089
|
const token = c.req.query("token") || "";
|
|
2085
|
-
|
|
2090
|
+
const cookie = (0, import_cookie.getCookie)(c, DASHBOARD_COOKIE) || "";
|
|
2091
|
+
const authHeader = c.req.header("authorization") || "";
|
|
2092
|
+
const bearer = authHeader.toLowerCase().startsWith("bearer ") ? authHeader.slice(7).trim() : "";
|
|
2093
|
+
if (bearer && isGlobalToken(bearer)) {
|
|
2094
|
+
} else if (token && isGlobalToken(token)) {
|
|
2086
2095
|
(0, import_cookie.setCookie)(c, DASHBOARD_COOKIE, token, {
|
|
2087
2096
|
httpOnly: true,
|
|
2088
2097
|
sameSite: "Strict",
|
|
@@ -2090,10 +2099,8 @@ async function dashboardRoute(c) {
|
|
|
2090
2099
|
});
|
|
2091
2100
|
c.header("Referrer-Policy", "no-referrer");
|
|
2092
2101
|
return c.redirect("/dashboard/", 302);
|
|
2093
|
-
}
|
|
2094
|
-
|
|
2095
|
-
if (!isGlobalToken(cookie)) {
|
|
2096
|
-
if (token && checkToken(token) || cookie && checkToken(cookie)) {
|
|
2102
|
+
} else if (!isGlobalToken(cookie)) {
|
|
2103
|
+
if (bearer && checkToken(bearer) || token && checkToken(token) || cookie && checkToken(cookie)) {
|
|
2097
2104
|
return c.html(AGENT_FORBIDDEN_HTML, 403, DASHBOARD_SECURITY_HEADERS);
|
|
2098
2105
|
}
|
|
2099
2106
|
return c.html(UNAUTHORIZED_HTML, 401, DASHBOARD_SECURITY_HEADERS);
|
|
@@ -2208,7 +2215,10 @@ async function main() {
|
|
|
2208
2215
|
const app = createApp2();
|
|
2209
2216
|
console.log(`AgentGate HTTP server on ${host}:${port}`);
|
|
2210
2217
|
if (authEnabled2() && authToken2()) {
|
|
2211
|
-
|
|
2218
|
+
const dash = `http://localhost:${port}/dashboard/?token=${authToken2()}`;
|
|
2219
|
+
console.log(
|
|
2220
|
+
`Dashboard: ${process.stdout.isTTY ? dash : dash.replace(/([?&]token=)[^&\s"']+/gi, "$1***")}`
|
|
2221
|
+
);
|
|
2212
2222
|
}
|
|
2213
2223
|
serve({ fetch: app.fetch, hostname: host, port }, (info) => {
|
|
2214
2224
|
console.log(`Listening on http://${host}:${port}`);
|
package/dist/v1/server.js
CHANGED
|
@@ -1343,7 +1343,7 @@ var import_zod = require("zod");
|
|
|
1343
1343
|
|
|
1344
1344
|
// src/version.ts
|
|
1345
1345
|
init_cjs_shims();
|
|
1346
|
-
var _version = true ? "0.8.
|
|
1346
|
+
var _version = true ? "0.8.2" : (() => {
|
|
1347
1347
|
try {
|
|
1348
1348
|
const require2 = createRequire(importMetaUrl);
|
|
1349
1349
|
const pkg = require2("../package.json");
|
|
@@ -1836,7 +1836,12 @@ function createApp() {
|
|
|
1836
1836
|
allowMethods: ["GET", "POST", "OPTIONS", "DELETE"],
|
|
1837
1837
|
allowHeaders: ["*"]
|
|
1838
1838
|
}));
|
|
1839
|
-
app.use(
|
|
1839
|
+
app.use(
|
|
1840
|
+
"*",
|
|
1841
|
+
(0, import_logger.logger)(
|
|
1842
|
+
(str, ...rest) => console.log(str.replace(/([?&]token=)[^&\s"']+/gi, "$1***"), ...rest)
|
|
1843
|
+
)
|
|
1844
|
+
);
|
|
1840
1845
|
app.use("*", async (c, next) => {
|
|
1841
1846
|
const path = new URL(c.req.url).pathname;
|
|
1842
1847
|
const method = c.req.method.toUpperCase();
|
|
@@ -1935,7 +1940,11 @@ function createApp() {
|
|
|
1935
1940
|
async function dashboardRoute(c) {
|
|
1936
1941
|
if (authEnabled()) {
|
|
1937
1942
|
const token = c.req.query("token") || "";
|
|
1938
|
-
|
|
1943
|
+
const cookie = (0, import_cookie.getCookie)(c, DASHBOARD_COOKIE) || "";
|
|
1944
|
+
const authHeader = c.req.header("authorization") || "";
|
|
1945
|
+
const bearer = authHeader.toLowerCase().startsWith("bearer ") ? authHeader.slice(7).trim() : "";
|
|
1946
|
+
if (bearer && isGlobalToken(bearer)) {
|
|
1947
|
+
} else if (token && isGlobalToken(token)) {
|
|
1939
1948
|
(0, import_cookie.setCookie)(c, DASHBOARD_COOKIE, token, {
|
|
1940
1949
|
httpOnly: true,
|
|
1941
1950
|
sameSite: "Strict",
|
|
@@ -1943,10 +1952,8 @@ async function dashboardRoute(c) {
|
|
|
1943
1952
|
});
|
|
1944
1953
|
c.header("Referrer-Policy", "no-referrer");
|
|
1945
1954
|
return c.redirect("/dashboard/", 302);
|
|
1946
|
-
}
|
|
1947
|
-
|
|
1948
|
-
if (!isGlobalToken(cookie)) {
|
|
1949
|
-
if (token && checkToken(token) || cookie && checkToken(cookie)) {
|
|
1955
|
+
} else if (!isGlobalToken(cookie)) {
|
|
1956
|
+
if (bearer && checkToken(bearer) || token && checkToken(token) || cookie && checkToken(cookie)) {
|
|
1950
1957
|
return c.html(AGENT_FORBIDDEN_HTML, 403, DASHBOARD_SECURITY_HEADERS);
|
|
1951
1958
|
}
|
|
1952
1959
|
return c.html(UNAUTHORIZED_HTML, 401, DASHBOARD_SECURITY_HEADERS);
|
package/dist/v3/cli.js
CHANGED
|
@@ -50,7 +50,7 @@ var init_version = __esm({
|
|
|
50
50
|
"src/version.ts"() {
|
|
51
51
|
"use strict";
|
|
52
52
|
init_cjs_shims();
|
|
53
|
-
_version = true ? "0.8.
|
|
53
|
+
_version = true ? "0.8.2" : (() => {
|
|
54
54
|
try {
|
|
55
55
|
const require2 = createRequire(importMetaUrl);
|
|
56
56
|
const pkg = require2("../package.json");
|
|
@@ -1986,7 +1986,12 @@ function createApp() {
|
|
|
1986
1986
|
allowMethods: ["GET", "POST", "OPTIONS", "DELETE"],
|
|
1987
1987
|
allowHeaders: ["*"]
|
|
1988
1988
|
}));
|
|
1989
|
-
app.use(
|
|
1989
|
+
app.use(
|
|
1990
|
+
"*",
|
|
1991
|
+
(0, import_logger.logger)(
|
|
1992
|
+
(str, ...rest) => console.log(str.replace(/([?&]token=)[^&\s"']+/gi, "$1***"), ...rest)
|
|
1993
|
+
)
|
|
1994
|
+
);
|
|
1990
1995
|
app.use("*", async (c, next) => {
|
|
1991
1996
|
const path11 = new URL(c.req.url).pathname;
|
|
1992
1997
|
const method = c.req.method.toUpperCase();
|
|
@@ -2085,7 +2090,11 @@ function createApp() {
|
|
|
2085
2090
|
async function dashboardRoute(c) {
|
|
2086
2091
|
if (authEnabled()) {
|
|
2087
2092
|
const token = c.req.query("token") || "";
|
|
2088
|
-
|
|
2093
|
+
const cookie = (0, import_cookie.getCookie)(c, DASHBOARD_COOKIE) || "";
|
|
2094
|
+
const authHeader = c.req.header("authorization") || "";
|
|
2095
|
+
const bearer = authHeader.toLowerCase().startsWith("bearer ") ? authHeader.slice(7).trim() : "";
|
|
2096
|
+
if (bearer && isGlobalToken(bearer)) {
|
|
2097
|
+
} else if (token && isGlobalToken(token)) {
|
|
2089
2098
|
(0, import_cookie.setCookie)(c, DASHBOARD_COOKIE, token, {
|
|
2090
2099
|
httpOnly: true,
|
|
2091
2100
|
sameSite: "Strict",
|
|
@@ -2093,10 +2102,8 @@ async function dashboardRoute(c) {
|
|
|
2093
2102
|
});
|
|
2094
2103
|
c.header("Referrer-Policy", "no-referrer");
|
|
2095
2104
|
return c.redirect("/dashboard/", 302);
|
|
2096
|
-
}
|
|
2097
|
-
|
|
2098
|
-
if (!isGlobalToken(cookie)) {
|
|
2099
|
-
if (token && checkToken(token) || cookie && checkToken(cookie)) {
|
|
2105
|
+
} else if (!isGlobalToken(cookie)) {
|
|
2106
|
+
if (bearer && checkToken(bearer) || token && checkToken(token) || cookie && checkToken(cookie)) {
|
|
2100
2107
|
return c.html(AGENT_FORBIDDEN_HTML, 403, DASHBOARD_SECURITY_HEADERS);
|
|
2101
2108
|
}
|
|
2102
2109
|
return c.html(UNAUTHORIZED_HTML, 401, DASHBOARD_SECURITY_HEADERS);
|
|
@@ -34172,7 +34179,10 @@ Run options:
|
|
|
34172
34179
|
const app = createApp2();
|
|
34173
34180
|
console.log(`AgentGate HTTP server on ${host}:${port}`);
|
|
34174
34181
|
if (authEnabled2() && authToken2()) {
|
|
34175
|
-
|
|
34182
|
+
const dash = `http://localhost:${port}/dashboard/?token=${authToken2()}`;
|
|
34183
|
+
console.log(
|
|
34184
|
+
`Dashboard: ${process.stdout.isTTY ? dash : dash.replace(/([?&]token=)[^&\s"']+/gi, "$1***")}`
|
|
34185
|
+
);
|
|
34176
34186
|
}
|
|
34177
34187
|
serve({ fetch: app.fetch, hostname: host, port }, (info) => {
|
|
34178
34188
|
console.log(`Listening on http://${host}:${port}`);
|