@guren/server 2.33.0 → 2.35.0
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/{Gate-COWQbA96.js → Gate-BHyDcDKo.js} +58 -10
- package/dist/{HttpException-BlQ2yEmT.js → HttpException-2tfZGamp.js} +8 -2
- package/dist/{McpServiceProvider-BDDr-7lh.js → McpServiceProvider-CXOokGax.js} +1 -1
- package/dist/{Resource-LQT1L4j0.js → Resource-y-7zzZSB.js} +43 -32
- package/dist/agent/scopes.d.ts +7 -0
- package/dist/{api-token-BbgDEd6j.js → api-token-1-INqeVU.js} +187 -2
- package/dist/auth/AuthManager.d.ts +4 -1
- package/dist/auth/TokenGuard.d.ts +4 -1
- package/dist/auth/api-token.d.ts +11 -1
- package/dist/auth/index.js +2 -2
- package/dist/{auth-DRMeSwev.js → auth-CO9MlQNE.js} +16 -24
- package/dist/authorization/Gate.d.ts +9 -5
- package/dist/authorization/index.js +2 -2
- package/dist/{authorization-DEHuBps5.js → authorization-rxx6aprN.js} +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/{broadcasting-CcevVE5Y.js → broadcasting-D04a3R02.js} +3 -2
- package/dist/{context-af2n5abO.js → context--l2HdOhy.js} +1 -1
- package/dist/{dev-banner-CSjrSNZi.js → dev-banner-BUrHz-LF.js} +7 -3
- package/dist/errors/ExceptionHandler.d.ts +7 -2
- package/dist/errors/HttpException.d.ts +6 -0
- package/dist/errors/debug-page.d.ts +1 -1
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +2 -0
- package/dist/errors/redact-query-params.d.ts +16 -0
- package/dist/errors/wants-html.d.ts +7 -0
- package/dist/{errors-JpkcCjjn.js → errors-C8neC8go.js} +1 -1
- package/dist/health/index.js +1 -1
- package/dist/{health-Bg0Xj3aD.js → health-Wi_05kkf.js} +2 -1
- package/dist/http/Application.d.ts +12 -0
- package/dist/http/dev-banner.d.ts +6 -1
- package/dist/http/middleware/csrf.d.ts +1 -1
- package/dist/http/middleware/redirect-safety.d.ts +8 -0
- package/dist/index.js +247 -275
- package/dist/internal/agent-principal.d.ts +12 -3
- package/dist/internal/redact-query-params.d.ts +1 -0
- package/dist/internal/redact-query-params.js +2 -0
- package/dist/internal/testing.d.ts +2 -1
- package/dist/internal/testing.js +4 -4
- package/dist/lambda/index.js +3 -2
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +5 -5
- package/dist/mvc/inertia/InertiaEngine.d.ts +6 -0
- package/dist/notifications/index.js +1 -1
- package/dist/{notifications-R7Uj-aT7.js → notifications-DV5Yr6Fl.js} +2 -1
- package/dist/providers/InertiaServiceProvider.d.ts +7 -0
- package/dist/queue/index.js +1 -1
- package/dist/{queue-CO07wib_.js → queue-K4Bi6NRy.js} +17 -11
- package/dist/redact-query-params-Ba-sAfcP.js +106 -0
- package/dist/runtime/index.js +1 -1
- package/dist/{runtime-error-capture-DzllKc0d.js → runtime-error-capture-DLRXwp0d.js} +2 -2
- package/dist/{runtime-errors-D229wyoc.js → runtime-errors-Dh7nA2-p.js} +1 -1
- package/dist/scheduling/index.js +1 -1
- package/dist/{scheduling-DNV5tj44.js → scheduling-iLkx4gID.js} +2 -1
- package/dist/support/default-headers.d.ts +6 -0
- package/package.json +5 -1
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { o as getAppKeyringFromEnv, r as deriveAppKeyring, t as MessageSigner } from "./MessageSigner-DIUT1Yao.js";
|
|
2
2
|
import { n as detectServerlessRuntime, t as SERVERLESS_RUNTIME_LABELS } from "./serverless-D96rJb6x.js";
|
|
3
|
-
import {
|
|
3
|
+
import { A as secureStringCompare, D as hashToken, E as generateToken, N as readAgentPrincipal, O as parseTokenUrl, T as generateId, c as hasBearerHeader, k as secureCompare, l as parseApiToken, m as tokenAuthenticatesRequest, p as revokePresentedToken, t as API_TOKEN_KEY, u as readBearerToken, v as verifyApiToken, w as buildTokenUrl } from "./api-token-1-INqeVU.js";
|
|
4
|
+
import { a as setResolvedPrincipal, i as getResolvedPrincipal, o as AuthenticationException, r as getAuthContext } from "./context--l2HdOhy.js";
|
|
4
5
|
import { d as verifyPassword, o as needsRehash, r as hashPassword } from "./Hash-D2DFd8xX.js";
|
|
5
|
-
import {
|
|
6
|
+
import { t as redactQueryParams } from "./redact-query-params-Ba-sAfcP.js";
|
|
6
7
|
import { isExpired } from "./support/expiry.js";
|
|
7
8
|
import { n as isAgentToolRequest } from "./agent-request-Caj6bnbj.js";
|
|
8
9
|
import { deleteCookie, getCookie, setCookie } from "hono/cookie";
|
|
@@ -361,24 +362,6 @@ function getSessionFromContext(ctx) {
|
|
|
361
362
|
return ctx.get(SESSION_CONTEXT_KEY);
|
|
362
363
|
}
|
|
363
364
|
//#endregion
|
|
364
|
-
//#region src/internal/agent-principal.ts
|
|
365
|
-
const installed = /* @__PURE__ */ new WeakMap();
|
|
366
|
-
/**
|
|
367
|
-
* Mark `request` as carrying `principal`, returning that same object — a copy
|
|
368
|
-
* would key the map on something the auth context never sees. Returning it is
|
|
369
|
-
* what makes the identity requirement hard to get wrong at a call site:
|
|
370
|
-
* `app.fetch(installAgentPrincipal(request, installed), env, ctx)`. Callers
|
|
371
|
-
* reach this through the pipeline's `handoff: 'seam'`, and the reader not at all.
|
|
372
|
-
*/
|
|
373
|
-
function installAgentPrincipal(request, value) {
|
|
374
|
-
installed.set(request, value);
|
|
375
|
-
return request;
|
|
376
|
-
}
|
|
377
|
-
/** The principal installed on this exact request object, or `undefined`. */
|
|
378
|
-
function readAgentPrincipal(request) {
|
|
379
|
-
return installed.get(request);
|
|
380
|
-
}
|
|
381
|
-
//#endregion
|
|
382
365
|
//#region src/auth/providers/UserProvider.ts
|
|
383
366
|
/**
|
|
384
367
|
* Run a user record through the provider's optional `sanitize` before it leaves
|
|
@@ -984,7 +967,7 @@ var SessionGuard = class {
|
|
|
984
967
|
try {
|
|
985
968
|
await this.provider.rehashPasswordIfRequired?.(user, credentials);
|
|
986
969
|
} catch (error) {
|
|
987
|
-
console.warn(`[guren] Rehashing the password for user ${this.describeUser(user)} failed; the login continues.`, error);
|
|
970
|
+
console.warn(`[guren] Rehashing the password for user ${this.describeUser(user)} failed; the login continues.`, redactQueryParams(error));
|
|
988
971
|
}
|
|
989
972
|
return user;
|
|
990
973
|
}
|
|
@@ -1013,6 +996,7 @@ var TokenGuard = class {
|
|
|
1013
996
|
store;
|
|
1014
997
|
provider;
|
|
1015
998
|
updateLastUsed;
|
|
999
|
+
agentEndpoints;
|
|
1016
1000
|
verification;
|
|
1017
1001
|
resolvedUser;
|
|
1018
1002
|
constructor(options) {
|
|
@@ -1020,6 +1004,7 @@ var TokenGuard = class {
|
|
|
1020
1004
|
this.store = options.store;
|
|
1021
1005
|
this.provider = options.provider;
|
|
1022
1006
|
this.updateLastUsed = options.updateLastUsed ?? true;
|
|
1007
|
+
this.agentEndpoints = options.agentEndpoints;
|
|
1023
1008
|
}
|
|
1024
1009
|
verify() {
|
|
1025
1010
|
if (!this.verification) this.verification = (async () => {
|
|
@@ -1027,7 +1012,8 @@ var TokenGuard = class {
|
|
|
1027
1012
|
if (!plainTextToken) return null;
|
|
1028
1013
|
const existing = this.ctx.get(API_TOKEN_KEY);
|
|
1029
1014
|
if (existing && existing.token.id === parseApiToken(plainTextToken)?.id) return existing;
|
|
1030
|
-
const
|
|
1015
|
+
const verified = await verifyApiToken(plainTextToken, this.store, { updateLastUsed: this.updateLastUsed });
|
|
1016
|
+
const result = verified && tokenAuthenticatesRequest(verified, this.ctx, this.agentEndpoints) ? verified : null;
|
|
1031
1017
|
if (result) this.ctx.set(API_TOKEN_KEY, result);
|
|
1032
1018
|
return result;
|
|
1033
1019
|
})();
|
|
@@ -1112,6 +1098,7 @@ var AuthManager = class {
|
|
|
1112
1098
|
tokenGuard = null;
|
|
1113
1099
|
apiTokenStore = null;
|
|
1114
1100
|
apiTokenOptions = {};
|
|
1101
|
+
agentEndpoints;
|
|
1115
1102
|
passwordHasher;
|
|
1116
1103
|
constructor(options = {}) {
|
|
1117
1104
|
this.defaultGuard = options.defaultGuard ?? "web";
|
|
@@ -1264,6 +1251,10 @@ var AuthManager = class {
|
|
|
1264
1251
|
});
|
|
1265
1252
|
this.setDefaultGuard(guardName);
|
|
1266
1253
|
}
|
|
1254
|
+
/** Where a tools-only token is accepted besides a pipeline dispatch; `Application` passes its {@link Application.declareAgentEndpoint} paths. */
|
|
1255
|
+
setAgentEndpoints(endpoints) {
|
|
1256
|
+
this.agentEndpoints = endpoints;
|
|
1257
|
+
}
|
|
1267
1258
|
/**
|
|
1268
1259
|
* Register a bearer-token guard backed by an ApiTokenStore and enable
|
|
1269
1260
|
* header-based guard selection: requests carrying `Authorization: Bearer`
|
|
@@ -1279,7 +1270,8 @@ var AuthManager = class {
|
|
|
1279
1270
|
store,
|
|
1280
1271
|
ctx,
|
|
1281
1272
|
provider: options.provider ? manager.getProvider(options.provider) : void 0,
|
|
1282
|
-
updateLastUsed: options.updateLastUsed
|
|
1273
|
+
updateLastUsed: options.updateLastUsed,
|
|
1274
|
+
agentEndpoints: this.agentEndpoints
|
|
1283
1275
|
});
|
|
1284
1276
|
});
|
|
1285
1277
|
this.tokenGuard = guardName;
|
|
@@ -2097,4 +2089,4 @@ function requireVerifiedEmail(options = {}) {
|
|
|
2097
2089
|
};
|
|
2098
2090
|
}
|
|
2099
2091
|
//#endregion
|
|
2100
|
-
export { verifyOAuthState as A, ModelUserProvider as B, createGoogleOAuthProviderConfig as C, fetchOAuthUserProfile as D, exchangeOAuthCode as E, normalizeRedirectTarget as F,
|
|
2092
|
+
export { verifyOAuthState as A, ModelUserProvider as B, createGoogleOAuthProviderConfig as C, fetchOAuthUserProfile as D, exchangeOAuthCode as E, normalizeRedirectTarget as F, MemorySessionStore as G, NodeHasher as H, AuthManager as I, getSessionFromContext as J, createSessionMiddleware as K, DEFAULT_PROVIDER as L, jsonResponse as M, hostMatchesAllowlist as N, parseOAuthRedirectUrl as O, isAppRelativePath as P, TokenGuard as R, createGitHubOAuthProviderConfig as S, createOAuthState as T, ScryptHasher as U, DefaultHasher as V, BaseUserProvider as W, OAUTH_SESSION_BINDING_KEY as _, isEmailVerified as a, buildOAuthRedirectUrl as b, verifyEmailToken as c, completePasswordReset as d, createPasswordResetToken as f, MemoryOAuthStateStore as g, AuthenticatableModel as h, createEmailVerificationToken as i, defineMiddleware as j, sanitizeOAuthRedirect as k, MemoryPasswordResetStore as l, verifyPasswordResetToken as m, buildVerificationUrl as n, parseVerificationUrl as o, parsePasswordResetUrl as p, defaultCookieSecure as q, completeEmailVerification as r, requireVerifiedEmail as s, MemoryEmailVerificationStore as t, buildPasswordResetUrl as u, OAuthManager as v, createOAuthManager as w, createDiscordOAuthProviderConfig as x, buildOAuthAuthorizeUrl as y, SessionGuard as z };
|
|
@@ -4,7 +4,10 @@ import type { AuthUser, GateCallback, GateBeforeCallback, GateDefinition, GateOp
|
|
|
4
4
|
export declare const Response: ResponseBuilder;
|
|
5
5
|
/** Narrow a policy/gate return value to an `AuthorizationResponse`. */
|
|
6
6
|
export declare function isAuthorizationResponse(value: unknown): value is AuthorizationResponse;
|
|
7
|
-
/**
|
|
7
|
+
/**
|
|
8
|
+
* Honours `denyWithStatus()` / `denyAsNotFound()` so a policy can hide a record as a 404.
|
|
9
|
+
* A 404 is a `NotFoundHttpException`, so a renderer registered for missing records renders it too.
|
|
10
|
+
*/
|
|
8
11
|
export declare function denialToException(response: AuthorizationResponse): Error;
|
|
9
12
|
/** Authorization gate for defining and checking abilities. */
|
|
10
13
|
export declare class Gate {
|
|
@@ -35,10 +38,11 @@ export declare class Gate {
|
|
|
35
38
|
checkResponse(ability: string, user: AuthUser | null, ...args: unknown[]): Promise<AuthorizationResponse>;
|
|
36
39
|
protected settle(user: AuthUser | null, ability: string, response: AuthorizationResponse, args: unknown[]): Promise<AuthorizationResponse>;
|
|
37
40
|
/**
|
|
38
|
-
* The subject may be a class instance (policy resolved via its constructor)
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
41
|
+
* The subject may be a class instance (policy resolved via its constructor),
|
|
42
|
+
* a `[ModelClass, record]` / `['key', record]` tuple, or the bare class or
|
|
43
|
+
* `[ModelClass]` for an ability with no record. ORM records are plain objects,
|
|
44
|
+
* so they need the tuple: a plain record or any other array reaching no policy
|
|
45
|
+
* and no gate throws in `checkResponse()`.
|
|
42
46
|
*/
|
|
43
47
|
protected checkPolicy(ability: string, user: AuthUser | null, model: unknown, additionalArgs: unknown[]): Promise<boolean | AuthorizationResponse | undefined>;
|
|
44
48
|
protected getPolicyInstance(policyClass: PolicyClass): Policy;
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { a as withAuthorization, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware } from "../authorization-
|
|
2
|
-
import { a as cannot, f as setGate, i as can, l as getGate, n as Response, o as createGate, r as authorize, s as defineGate, t as Gate, u as isAuthorizationResponse } from "../Gate-
|
|
1
|
+
import { a as withAuthorization, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware } from "../authorization-rxx6aprN.js";
|
|
2
|
+
import { a as cannot, f as setGate, i as can, l as getGate, n as Response, o as createGate, r as authorize, s as defineGate, t as Gate, u as isAuthorizationResponse } from "../Gate-BHyDcDKo.js";
|
|
3
3
|
export { Gate, Policy, Response, authorize, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, can, cannot, createGate, defineGate, definePolicy, getGate, isAuthorizationResponse, setGate, withAuthorization };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { r as tryGetRequestContainer } from "./request-container-BbuH0JJy.js";
|
|
2
|
-
import { c as denialToException, d as resolveGate, n as Response, p as AuthorizationException } from "./Gate-
|
|
2
|
+
import { c as denialToException, d as resolveGate, n as Response, p as AuthorizationException } from "./Gate-BHyDcDKo.js";
|
|
3
3
|
//#region src/http/middleware/capabilities.ts
|
|
4
4
|
/**
|
|
5
5
|
* Internal security-capability marker (RFC 0007): built-in middleware
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as setBroadcastManager, c as PresenceChannel, i as getBroadcastManager, l as PrivateChannel, n as BroadcastManager, o as RedisDriver, r as createBroadcastManager, s as MemoryDriver, t as createTypedBroadcaster, u as Channel } from "../broadcasting-
|
|
1
|
+
import { a as setBroadcastManager, c as PresenceChannel, i as getBroadcastManager, l as PrivateChannel, n as BroadcastManager, o as RedisDriver, r as createBroadcastManager, s as MemoryDriver, t as createTypedBroadcaster, u as Channel } from "../broadcasting-D04a3R02.js";
|
|
2
2
|
export { BroadcastManager, Channel, MemoryDriver, PresenceChannel, PrivateChannel, RedisDriver, createBroadcastManager, createTypedBroadcaster, getBroadcastManager, setBroadcastManager };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { a as parseRequestPayload, t as asRecord } from "./request-CLOYytGP.js";
|
|
2
2
|
import { g as warnDeprecatedSetter, h as warnDeprecatedGetter, i as bindAmbient, n as ambientBinding } from "./default-application-s9SE-Er7.js";
|
|
3
|
-
import { r as getAuthContext } from "./context
|
|
3
|
+
import { r as getAuthContext } from "./context--l2HdOhy.js";
|
|
4
|
+
import { t as redactQueryParams } from "./redact-query-params-Ba-sAfcP.js";
|
|
4
5
|
import { n as isHotReloadRuntime, t as claimHotDisposable } from "./hot-disposables-W2fH-GID.js";
|
|
5
6
|
import { c as randomHex } from "./Random-S0OvCuR8.js";
|
|
6
7
|
//#region src/http/middleware/websocket-origin.ts
|
|
@@ -645,7 +646,7 @@ var BroadcastManager = class {
|
|
|
645
646
|
return;
|
|
646
647
|
}
|
|
647
648
|
const result = await this.authorizeAndAttach(channel, user, clientId).catch((error) => {
|
|
648
|
-
console.error(`Error authorizing broadcast channel "${channel}":`, error);
|
|
649
|
+
console.error(`Error authorizing broadcast channel "${channel}":`, redactQueryParams(error));
|
|
649
650
|
return { authorized: false };
|
|
650
651
|
});
|
|
651
652
|
await client.send("subscription", {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as HttpException } from "./HttpException-
|
|
1
|
+
import { t as HttpException } from "./HttpException-2tfZGamp.js";
|
|
2
2
|
//#region src/errors/exceptions/AuthenticationException.ts
|
|
3
3
|
/** 401: the user is not authenticated, or the credentials were invalid. */
|
|
4
4
|
var AuthenticationException = class AuthenticationException extends HttpException {
|
|
@@ -4,7 +4,7 @@ import chalk from "chalk";
|
|
|
4
4
|
import figlet from "figlet";
|
|
5
5
|
import standard from "figlet/importable-fonts/Standard.js";
|
|
6
6
|
//#region package.json
|
|
7
|
-
var version = "2.
|
|
7
|
+
var version = "2.35.0";
|
|
8
8
|
//#endregion
|
|
9
9
|
//#region src/http/dev-banner.ts
|
|
10
10
|
var dev_banner_exports = /* @__PURE__ */ __exportAll({
|
|
@@ -26,7 +26,11 @@ function generateAsciiArt(text) {
|
|
|
26
26
|
}
|
|
27
27
|
const GUREN_ASCII_ART = chalk.redBright.bold(generateAsciiArt("GUREN"));
|
|
28
28
|
const GUREN_VERSION = version;
|
|
29
|
-
|
|
29
|
+
const ASSET_SERVER_LABELS = {
|
|
30
|
+
managed: "Vite, started by Guren",
|
|
31
|
+
external: "not started by Guren, run it yourself"
|
|
32
|
+
};
|
|
33
|
+
function logDevServerBanner({ hostname, port, assetsUrl = "http://localhost:5173", assetServer }) {
|
|
30
34
|
const localUrl = `http://localhost:${port}`;
|
|
31
35
|
const boundUrl = `http://${formatHostPort(hostname, port)}`;
|
|
32
36
|
const boundLabel = isWildcardHost(hostname) ? " (all interfaces)" : "";
|
|
@@ -40,7 +44,7 @@ function logDevServerBanner({ hostname, port, assetsUrl = "http://localhost:5173
|
|
|
40
44
|
...header,
|
|
41
45
|
detail("App URL", localUrl),
|
|
42
46
|
detail("Bound address", `${boundUrl}${boundLabel}`),
|
|
43
|
-
detail("Asset server", `${assetsUrl} (Vite)`),
|
|
47
|
+
detail("Asset server", `${assetsUrl} (${assetServer ? ASSET_SERVER_LABELS[assetServer] : "Vite"})`),
|
|
44
48
|
"",
|
|
45
49
|
chalk.yellowBright("Press Ctrl+C to douse the flames."),
|
|
46
50
|
""
|
|
@@ -13,13 +13,18 @@ export declare class ExceptionHandler {
|
|
|
13
13
|
render<T extends Error>(errorClass: ExceptionClass<T>, renderer: ExceptionRenderer<T>): this;
|
|
14
14
|
dontReport(errorClass: ExceptionClass): this;
|
|
15
15
|
shouldShowDetails(): boolean;
|
|
16
|
-
|
|
16
|
+
/** Reporters and renderers receive the error with SQL bound parameters redacted. */
|
|
17
|
+
handle(thrown: Error, ctx: Context): Promise<Response>;
|
|
17
18
|
protected reportException(error: Error): Promise<void>;
|
|
18
19
|
protected shouldNotReport(error: Error): boolean;
|
|
19
20
|
protected matchesErrorClass(error: Error, errorClass: ExceptionClass): boolean;
|
|
20
21
|
protected renderException(error: Error, ctx: Context): Promise<Response>;
|
|
21
22
|
protected renderDefaultException(error: Error, ctx: Context): Response;
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* False for Inertia, XHR and JSON callers, which need a JSON payload. The CSRF
|
|
25
|
+
* middleware picks its page by `wants-html.ts` directly, so an override here
|
|
26
|
+
* does not change what a rejected form post answers.
|
|
27
|
+
*/
|
|
23
28
|
protected wantsHtmlResponse(ctx: Context): boolean;
|
|
24
29
|
middleware(): Middleware;
|
|
25
30
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
import type { ErrorResponse } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* The one 404 message the framework writes itself: `HttpException.notFound()`,
|
|
4
|
+
* `NotFoundHttpException`, `denyAsNotFound()`, `abort(404)`, and what the exception
|
|
5
|
+
* handler puts in place of a message naming a record outside debug.
|
|
6
|
+
*/
|
|
7
|
+
export declare const NOT_FOUND_MESSAGE = "Not Found";
|
|
2
8
|
/** Base HTTP exception class. */
|
|
3
9
|
export declare class HttpException extends Error {
|
|
4
10
|
readonly statusCode: number;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MiddlewareHandler } from 'hono';
|
|
2
2
|
/** Development-only error page: exposes the stack trace and request details. */
|
|
3
|
-
export declare function renderDebugPage(
|
|
3
|
+
export declare function renderDebugPage(thrown: Error, request?: Request): string;
|
|
4
4
|
/**
|
|
5
5
|
* @deprecated since 2.30.0, removed in 3.0.0. The ExceptionHandler renders this
|
|
6
6
|
* page itself for a browser request while debug details are on. Hono hands a
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { HttpException } from '../HttpException.js';
|
|
2
|
+
/** Whether a `for*()` constructor wrote `error`'s message, which the exception handler replaces outside debug. */
|
|
3
|
+
export declare function hasComposedMessage(error: object): boolean;
|
|
2
4
|
/** 404: the requested resource could not be found. */
|
|
3
5
|
export declare class NotFoundHttpException extends HttpException {
|
|
4
6
|
readonly resourceType?: string;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Strips SQL bound parameters out of an exception before anything prints it:
|
|
3
|
+
* drizzle's `DrizzleQueryError` writes `Failed query: <sql>\nparams: <values>`
|
|
4
|
+
* into its message and stack and keeps the values on `.params`, so a failed
|
|
5
|
+
* INSERT would hand a password hash to the 500 body, the debug page and the log.
|
|
6
|
+
* The shape is detected structurally, since the app may load its own drizzle.
|
|
7
|
+
*/
|
|
8
|
+
/**
|
|
9
|
+
* The value itself unless it is an error that, or whose cause chain, carries
|
|
10
|
+
* bound parameters; then a copy with the same prototype and own properties
|
|
11
|
+
* whose message, stack, parameter fields and causes are redacted. Being a copy,
|
|
12
|
+
* it carries no `#private` field a custom renderer or `toResponse()` reads.
|
|
13
|
+
*/
|
|
14
|
+
export declare function redactQueryParams<T>(error: T): T;
|
|
15
|
+
/** `error.message` with bound parameters redacted, for a log line that prints the message alone. */
|
|
16
|
+
export declare function redactedMessage(error: unknown): string | undefined;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
/**
|
|
3
|
+
* A browser navigation: it accepts HTML and is not an Inertia visit, an XHR or a
|
|
4
|
+
* JSON caller, each of which needs a JSON payload. `ExceptionHandler` and the
|
|
5
|
+
* CSRF middleware both answer an HTML page by this one rule.
|
|
6
|
+
*/
|
|
7
|
+
export declare function wantsHtmlResponse(ctx: Context): boolean;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as __exportAll } from "./rolldown-runtime-B4FMCO8f.js";
|
|
2
|
-
import { t as HttpException } from "./HttpException-
|
|
2
|
+
import { t as HttpException } from "./HttpException-2tfZGamp.js";
|
|
3
3
|
//#region src/errors/exceptions/ValidationException.ts
|
|
4
4
|
/** 422: request validation failed. */
|
|
5
5
|
var ValidationException = class ValidationException extends HttpException {
|
package/dist/health/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as CacheCheck, c as HealthManager, i as StorageCheck, l as createHealthManager, n as customCheck, o as RedisCheck, r as MemoryCheck, s as DatabaseCheck, t as CustomCheck, u as HealthCheck } from "../health-
|
|
1
|
+
import { a as CacheCheck, c as HealthManager, i as StorageCheck, l as createHealthManager, n as customCheck, o as RedisCheck, r as MemoryCheck, s as DatabaseCheck, t as CustomCheck, u as HealthCheck } from "../health-Wi_05kkf.js";
|
|
2
2
|
export { CacheCheck, CustomCheck, DatabaseCheck, HealthCheck, HealthManager, MemoryCheck, RedisCheck, StorageCheck, createHealthManager, customCheck };
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { n as redactedMessage } from "./redact-query-params-Ba-sAfcP.js";
|
|
1
2
|
//#region src/health/HealthCheck.ts
|
|
2
3
|
var HealthCheck = class {
|
|
3
4
|
healthy(message, meta) {
|
|
@@ -110,7 +111,7 @@ var HealthManager = class {
|
|
|
110
111
|
return {
|
|
111
112
|
name: check.name,
|
|
112
113
|
status: "unhealthy",
|
|
113
|
-
message: error
|
|
114
|
+
message: redactedMessage(error) ?? "Check failed with error",
|
|
114
115
|
duration
|
|
115
116
|
};
|
|
116
117
|
} finally {
|
|
@@ -158,6 +158,7 @@ export declare class Application {
|
|
|
158
158
|
private disposeBunTeardown?;
|
|
159
159
|
private autoSessionAttached;
|
|
160
160
|
private readonly cookielessAuthPaths;
|
|
161
|
+
private readonly agentEndpointPaths;
|
|
161
162
|
/** {@link configDefinitions} with where each was listed, which ConfigServiceProvider's errors name. */
|
|
162
163
|
readonly configEntries: ReadonlyArray<ConfiguredDefinition>;
|
|
163
164
|
private routeRegistration?;
|
|
@@ -188,6 +189,17 @@ export declare class Application {
|
|
|
188
189
|
declareCookielessAuthPath(path: string): void;
|
|
189
190
|
/** Matched by exact path — see {@link declareCookielessAuthPath}. */
|
|
190
191
|
getCookielessAuthPaths(): ReadonlySet<string>;
|
|
192
|
+
/**
|
|
193
|
+
* Asserts that the endpoint at `path` judges `tool:` / `tools:` scopes itself,
|
|
194
|
+
* so a tools-only token authenticates there (through app-wide auth middleware
|
|
195
|
+
* in front of it) and nowhere else. Call from `boot`, after `mountRoutes()`.
|
|
196
|
+
* Only an app route at exactly this path is detected: a parameterised or
|
|
197
|
+
* wildcard route registered ahead of the endpoint would answer here unseen.
|
|
198
|
+
*/
|
|
199
|
+
declareAgentEndpoint(path: string): void;
|
|
200
|
+
/** Matched by exact pathname — see {@link declareAgentEndpoint}. */
|
|
201
|
+
getAgentEndpointPaths(): ReadonlySet<string>;
|
|
202
|
+
private routeAt;
|
|
191
203
|
mountRoutes(): Promise<void>;
|
|
192
204
|
/** Runs the registrars once; `introspect()` stops here, since mounting refuses an unregistered alias it reports. */
|
|
193
205
|
private registerRoutes;
|
|
@@ -3,5 +3,10 @@ export interface DevBannerOptions {
|
|
|
3
3
|
hostname: string;
|
|
4
4
|
port: number;
|
|
5
5
|
assetsUrl?: string;
|
|
6
|
+
/**
|
|
7
|
+
* `managed` when `listen()` started or adopted the Vite dev server at `assetsUrl`; `external` when it
|
|
8
|
+
* started none (`VITE_DEV_SERVER_URL`, `assetsUrl`, `vite: false`, `GUREN_DEV_VITE=0`). Omitted, the line reads `(Vite)`.
|
|
9
|
+
*/
|
|
10
|
+
assetServer?: 'managed' | 'external';
|
|
6
11
|
}
|
|
7
|
-
export declare function logDevServerBanner({ hostname, port, assetsUrl, }: DevBannerOptions): void;
|
|
12
|
+
export declare function logDevServerBanner({ hostname, port, assetsUrl, assetServer, }: DevBannerOptions): void;
|
|
@@ -7,7 +7,7 @@ export declare const CSRF_FORM_FIELD = "_token";
|
|
|
7
7
|
export interface CsrfOptions {
|
|
8
8
|
/** Exact paths ('/api/webhook') or patterns ('/api/*'). */
|
|
9
9
|
exclude?: string[];
|
|
10
|
-
/** Defaults to a 403 JSON response. */
|
|
10
|
+
/** Defaults to a 403 JSON response, or a 419 "Page Expired" page for a browser navigation. */
|
|
11
11
|
onError?: (ctx: Context) => Response | Promise<Response>;
|
|
12
12
|
/** Defaults to ['POST', 'PUT', 'PATCH', 'DELETE']. */
|
|
13
13
|
methods?: string[];
|
|
@@ -9,3 +9,11 @@ export interface RedirectSafetyOptions {
|
|
|
9
9
|
export declare function createRedirectSafetyMiddleware(options?: RedirectSafetyOptions): MiddlewareHandler;
|
|
10
10
|
/** Safe means same-origin as `requestUrl`, or a host in `allowedHosts`. */
|
|
11
11
|
export declare function isSafeRedirectUrl(url: string, requestUrl: string, allowedHosts?: string[]): boolean;
|
|
12
|
+
/**
|
|
13
|
+
* The path of a `Referer` on one of `acceptedHosts` (as `URL.host` spells them,
|
|
14
|
+
* port included), for redirecting back, or `fallback`. A relative Referer resolves
|
|
15
|
+
* against `requestUrl`. The scheme is not compared: behind a TLS-terminating proxy
|
|
16
|
+
* the request reads `http:` while the browser's Referer reads `https:`. Only the
|
|
17
|
+
* path and query are kept, so the browser stays on its own origin.
|
|
18
|
+
*/
|
|
19
|
+
export declare function sameHostRefererPath(referer: string | undefined, requestUrl: string, acceptedHosts: readonly string[], fallback?: string): string;
|