@guren/server 2.34.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-C252SwRR.js → Gate-BHyDcDKo.js} +45 -5
- package/dist/{HttpException-BlQ2yEmT.js → HttpException-2tfZGamp.js} +8 -2
- package/dist/{Resource-BBKaFgXf.js → Resource-y-7zzZSB.js} +4 -4
- package/dist/{api-token-DJcqSybf.js → api-token-1-INqeVU.js} +1 -1
- package/dist/auth/index.js +2 -2
- package/dist/{auth-Bj9uEHuC.js → auth-CO9MlQNE.js} +2 -2
- package/dist/authorization/Gate.d.ts +4 -1
- package/dist/authorization/index.js +2 -2
- package/dist/{authorization-C81TXOWD.js → authorization-rxx6aprN.js} +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/{broadcasting-3pvO94xV.js → broadcasting-D04a3R02.js} +1 -1
- package/dist/{context-af2n5abO.js → context--l2HdOhy.js} +1 -1
- package/dist/{dev-banner-B_QaY29h.js → dev-banner-BUrHz-LF.js} +7 -3
- package/dist/errors/ExceptionHandler.d.ts +5 -1
- package/dist/errors/HttpException.d.ts +6 -0
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +2 -0
- package/dist/errors/wants-html.d.ts +7 -0
- package/dist/{errors-JpkcCjjn.js → errors-C8neC8go.js} +1 -1
- 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 +201 -144
- package/dist/internal/testing.js +3 -3
- package/dist/providers/InertiaServiceProvider.d.ts +7 -0
- package/dist/runtime/index.js +1 -1
- package/package.json +1 -1
|
@@ -1,6 +1,42 @@
|
|
|
1
|
-
import { t as HttpException } from "./HttpException-
|
|
1
|
+
import { n as NOT_FOUND_MESSAGE, t as HttpException } from "./HttpException-2tfZGamp.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
|
+
//#region src/errors/exceptions/NotFoundHttpException.ts
|
|
5
|
+
/**
|
|
6
|
+
* Set, non-enumerable, by the `for*()` constructors, whose message the framework
|
|
7
|
+
* wrote from the record. Registry-keyed so a second copy of the package reads it;
|
|
8
|
+
* no public field marks it, since the constructor takes a developer's message too.
|
|
9
|
+
*/
|
|
10
|
+
const COMPOSED_MESSAGE = Symbol.for("guren.notFound.composedMessage");
|
|
11
|
+
function composed(error) {
|
|
12
|
+
Object.defineProperty(error, COMPOSED_MESSAGE, { value: true });
|
|
13
|
+
return error;
|
|
14
|
+
}
|
|
15
|
+
/** Whether a `for*()` constructor wrote `error`'s message, which the exception handler replaces outside debug. */
|
|
16
|
+
function hasComposedMessage(error) {
|
|
17
|
+
return error[COMPOSED_MESSAGE] === true;
|
|
18
|
+
}
|
|
19
|
+
/** 404: the requested resource could not be found. */
|
|
20
|
+
var NotFoundHttpException = class NotFoundHttpException extends HttpException {
|
|
21
|
+
resourceType;
|
|
22
|
+
resourceId;
|
|
23
|
+
constructor(message = NOT_FOUND_MESSAGE, resourceType, resourceId) {
|
|
24
|
+
super(404, message);
|
|
25
|
+
this.name = "NotFoundHttpException";
|
|
26
|
+
this.resourceType = resourceType;
|
|
27
|
+
this.resourceId = resourceId;
|
|
28
|
+
}
|
|
29
|
+
static forModel(model, id) {
|
|
30
|
+
return composed(new NotFoundHttpException(`${model} with ID ${id} not found.`, model, id));
|
|
31
|
+
}
|
|
32
|
+
static forRoute(path) {
|
|
33
|
+
return composed(new NotFoundHttpException(`Route ${path} not found.`, "Route"));
|
|
34
|
+
}
|
|
35
|
+
static forResource(resource) {
|
|
36
|
+
return composed(new NotFoundHttpException(`${resource} not found.`, resource));
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
//#endregion
|
|
4
40
|
//#region src/errors/exceptions/AuthorizationException.ts
|
|
5
41
|
/** 403: the user is authenticated but not allowed to perform the action. */
|
|
6
42
|
var AuthorizationException = class AuthorizationException extends HttpException {
|
|
@@ -48,7 +84,7 @@ const Response = {
|
|
|
48
84
|
denyAsNotFound(message) {
|
|
49
85
|
return {
|
|
50
86
|
allowed: false,
|
|
51
|
-
message: message ?? "Not
|
|
87
|
+
message: message ?? "Not Found",
|
|
52
88
|
status: 404
|
|
53
89
|
};
|
|
54
90
|
}
|
|
@@ -78,10 +114,14 @@ function isPlainRecord(value) {
|
|
|
78
114
|
function isPolicyTuple(value) {
|
|
79
115
|
return (value.length === 1 || value.length === 2) && (typeof value[0] === "function" || typeof value[0] === "string");
|
|
80
116
|
}
|
|
81
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Honours `denyWithStatus()` / `denyAsNotFound()` so a policy can hide a record as a 404.
|
|
119
|
+
* A 404 is a `NotFoundHttpException`, so a renderer registered for missing records renders it too.
|
|
120
|
+
*/
|
|
82
121
|
function denialToException(response) {
|
|
83
122
|
const message = response.message ?? "This action is unauthorized.";
|
|
84
123
|
const status = response.status;
|
|
124
|
+
if (status === 404) return new NotFoundHttpException(message);
|
|
85
125
|
if (typeof status === "number" && status !== 403) return new HttpException(status, message);
|
|
86
126
|
return new AuthorizationException(message);
|
|
87
127
|
}
|
|
@@ -275,4 +315,4 @@ async function authorize(ability, ...args) {
|
|
|
275
315
|
return resolveGate().authorize(ability, ...args);
|
|
276
316
|
}
|
|
277
317
|
//#endregion
|
|
278
|
-
export { cannot as a, denialToException as c, resolveGate as d, setGate as f, can as i, getGate as l, Response as n, createGate as o, AuthorizationException as p, authorize as r, defineGate as s, Gate as t, isAuthorizationResponse as u };
|
|
318
|
+
export { cannot as a, denialToException as c, resolveGate as d, setGate as f, hasComposedMessage as h, can as i, getGate as l, NotFoundHttpException as m, Response as n, createGate as o, AuthorizationException as p, authorize as r, defineGate as s, Gate as t, isAuthorizationResponse as u };
|
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
//#region src/errors/HttpException.ts
|
|
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
|
+
const NOT_FOUND_MESSAGE = "Not Found";
|
|
2
8
|
/** Base HTTP exception class. */
|
|
3
9
|
var HttpException = class HttpException extends Error {
|
|
4
10
|
statusCode;
|
|
@@ -42,7 +48,7 @@ var HttpException = class HttpException extends Error {
|
|
|
42
48
|
static forbidden(message = "Forbidden") {
|
|
43
49
|
return new HttpException(403, message);
|
|
44
50
|
}
|
|
45
|
-
static notFound(message =
|
|
51
|
+
static notFound(message = NOT_FOUND_MESSAGE) {
|
|
46
52
|
return new HttpException(404, message);
|
|
47
53
|
}
|
|
48
54
|
static methodNotAllowed(message = "Method Not Allowed") {
|
|
@@ -81,4 +87,4 @@ var HttpException = class HttpException extends Error {
|
|
|
81
87
|
}
|
|
82
88
|
};
|
|
83
89
|
//#endregion
|
|
84
|
-
export { HttpException as t };
|
|
90
|
+
export { NOT_FOUND_MESSAGE as n, HttpException as t };
|
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { i as parseRequestBody, n as flattenRequestQueries, o as parseRequestUploads, t as asRecord } from "./request-CLOYytGP.js";
|
|
2
2
|
import { n as getValidatedInput, r as readValidatedInput } from "./validated-input-D84J8wcC.js";
|
|
3
|
-
import { n as ValidationException } from "./errors-
|
|
3
|
+
import { n as ValidationException } from "./errors-C8neC8go.js";
|
|
4
4
|
import { n as parseImportMap, t as DEFAULT_DEV_STYLES_ENTRY } from "./inertia-defaults-BjrcT7za.js";
|
|
5
5
|
import { t as resolveOptional } from "./resolve-optional-ax6gPWTp.js";
|
|
6
6
|
import { g as warnDeprecatedSetter, h as warnDeprecatedGetter } from "./default-application-s9SE-Er7.js";
|
|
7
7
|
import { n as initialPageElement, t as INITIAL_PAGE_SELECTOR } from "./initial-page-U637q3gO.js";
|
|
8
8
|
import { n as ServiceProvider } from "./ServiceProvider-G0YclITd.js";
|
|
9
|
-
import { o as getApiTokenOrFail } from "./api-token-
|
|
10
|
-
import { r as getAuthContext } from "./context
|
|
9
|
+
import { o as getApiTokenOrFail } from "./api-token-1-INqeVU.js";
|
|
10
|
+
import { r as getAuthContext } from "./context--l2HdOhy.js";
|
|
11
11
|
import { r as tryGetRequestContainer } from "./request-container-BbuH0JJy.js";
|
|
12
12
|
import { a as resolveI18n } from "./i18n-BShPpJZa.js";
|
|
13
|
-
import { d as resolveGate } from "./Gate-
|
|
13
|
+
import { d as resolveGate } from "./Gate-BHyDcDKo.js";
|
|
14
14
|
import { t as jsx_runtime_exports } from "./jsx-runtime.js";
|
|
15
15
|
import { getCookie } from "hono/cookie";
|
|
16
16
|
import { isAbsolute, resolve } from "node:path";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as setResolvedPrincipal, n as createPrincipalAuthContext, o as AuthenticationException, r as getAuthContext, t as AUTH_CONTEXT_KEY } from "./context
|
|
1
|
+
import { a as setResolvedPrincipal, n as createPrincipalAuthContext, o as AuthenticationException, r as getAuthContext, t as AUTH_CONTEXT_KEY } from "./context--l2HdOhy.js";
|
|
2
2
|
import { isOptionalExpiryPast } from "./support/expiry.js";
|
|
3
3
|
import { r as tryGetRequestContainer } from "./request-container-BbuH0JJy.js";
|
|
4
4
|
import { createHash, randomBytes, timingSafeEqual } from "node:crypto";
|
package/dist/auth/index.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as verifyOAuthState, B as ModelUserProvider, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, H as NodeHasher, I as AuthManager, O as parseOAuthRedirectUrl, R as TokenGuard, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as ScryptHasher, W as BaseUserProvider, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, r as completeEmailVerification, s as requireVerifiedEmail, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as SessionGuard } from "../auth-
|
|
2
|
-
import { A as secureStringCompare, D as hashToken, E as generateToken, O as parseTokenUrl, T as generateId, _ as tokenCanAny, a as getApiToken, d as revokeAllApiTokens, f as revokeApiToken, g as tokenCanAll, h as tokenCan, i as createBearerTokenMiddleware, k as secureCompare, l as parseApiToken, n as MemoryApiTokenStore, o as getApiTokenOrFail, r as createApiToken, s as getUserApiTokens, t as API_TOKEN_KEY, u as readBearerToken, v as verifyApiToken, w as buildTokenUrl } from "../api-token-
|
|
1
|
+
import { A as verifyOAuthState, B as ModelUserProvider, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, H as NodeHasher, I as AuthManager, O as parseOAuthRedirectUrl, R as TokenGuard, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as ScryptHasher, W as BaseUserProvider, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, r as completeEmailVerification, s as requireVerifiedEmail, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as SessionGuard } from "../auth-CO9MlQNE.js";
|
|
2
|
+
import { A as secureStringCompare, D as hashToken, E as generateToken, O as parseTokenUrl, T as generateId, _ as tokenCanAny, a as getApiToken, d as revokeAllApiTokens, f as revokeApiToken, g as tokenCanAll, h as tokenCan, i as createBearerTokenMiddleware, k as secureCompare, l as parseApiToken, n as MemoryApiTokenStore, o as getApiTokenOrFail, r as createApiToken, s as getUserApiTokens, t as API_TOKEN_KEY, u as readBearerToken, v as verifyApiToken, w as buildTokenUrl } from "../api-token-1-INqeVU.js";
|
|
3
3
|
export { API_TOKEN_KEY, ScryptHasher as Argon2Hasher, ScryptHasher, AuthManager, AuthenticatableModel, BaseUserProvider, MemoryApiTokenStore, MemoryEmailVerificationStore, MemoryOAuthStateStore, MemoryPasswordResetStore, ModelUserProvider, NodeHasher, OAUTH_SESSION_BINDING_KEY, OAuthManager, SessionGuard, TokenGuard, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildTokenUrl, buildVerificationUrl, completeEmailVerification, completePasswordReset, createApiToken, createBearerTokenMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createOAuthManager, createOAuthState, createPasswordResetToken, exchangeOAuthCode, fetchOAuthUserProfile, generateId, generateToken, getApiToken, getApiTokenOrFail, getUserApiTokens, hashToken, isEmailVerified, parseApiToken, parseOAuthRedirectUrl, parsePasswordResetUrl, parseTokenUrl, parseVerificationUrl, readBearerToken, requireVerifiedEmail, revokeAllApiTokens, revokeApiToken, sanitizeOAuthRedirect, secureCompare, secureStringCompare, tokenCan, tokenCanAll, tokenCanAny, verifyApiToken, verifyEmailToken, verifyOAuthState, verifyPasswordResetToken };
|
|
@@ -1,7 +1,7 @@
|
|
|
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 { 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-
|
|
4
|
-
import { a as setResolvedPrincipal, i as getResolvedPrincipal, o as AuthenticationException, r as getAuthContext } from "./context
|
|
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";
|
|
5
5
|
import { d as verifyPassword, o as needsRehash, r as hashPassword } from "./Hash-D2DFd8xX.js";
|
|
6
6
|
import { t as redactQueryParams } from "./redact-query-params-Ba-sAfcP.js";
|
|
7
7
|
import { isExpired } from "./support/expiry.js";
|
|
@@ -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 {
|
|
@@ -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,6 @@
|
|
|
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
4
|
import { t as redactQueryParams } from "./redact-query-params-Ba-sAfcP.js";
|
|
5
5
|
import { n as isHotReloadRuntime, t as claimHotDisposable } from "./hot-disposables-W2fH-GID.js";
|
|
6
6
|
import { c as randomHex } from "./Random-S0OvCuR8.js";
|
|
@@ -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
|
""
|
|
@@ -20,7 +20,11 @@ export declare class ExceptionHandler {
|
|
|
20
20
|
protected matchesErrorClass(error: Error, errorClass: ExceptionClass): boolean;
|
|
21
21
|
protected renderException(error: Error, ctx: Context): Promise<Response>;
|
|
22
22
|
protected renderDefaultException(error: Error, ctx: Context): Response;
|
|
23
|
-
/**
|
|
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
|
+
*/
|
|
24
28
|
protected wantsHtmlResponse(ctx: Context): boolean;
|
|
25
29
|
middleware(): Middleware;
|
|
26
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,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,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 {
|
|
@@ -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;
|
package/dist/index.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import { A as ensureErrorStackTracePolyfill, C as setInertiaDocument, D as defer, E as always, O as isAlwaysProp, a as renderDocument, b as inertia, c as getRequestLocale, d as mountModuleRoutes, f as definePlugin, g as shareInertiaProps, h as setInertiaSharedProps, i as Controller, k as isDeferredProp, l as getRequestTranslator, m as resolveSharedInertiaProps, n as Resource, o as LOCALE_CONTEXT_KEY, p as getInertiaSharedPropsResolver, r as collect, s as detectLocaleMiddleware, t as JsonResource, u as defineModule, w as setInertiaSsrRenderer } from "./Resource-
|
|
1
|
+
import { A as ensureErrorStackTracePolyfill, C as setInertiaDocument, D as defer, E as always, O as isAlwaysProp, a as renderDocument, b as inertia, c as getRequestLocale, d as mountModuleRoutes, f as definePlugin, g as shareInertiaProps, h as setInertiaSharedProps, i as Controller, k as isDeferredProp, l as getRequestTranslator, m as resolveSharedInertiaProps, n as Resource, o as LOCALE_CONTEXT_KEY, p as getInertiaSharedPropsResolver, r as collect, s as detectLocaleMiddleware, t as JsonResource, u as defineModule, w as setInertiaSsrRenderer } from "./Resource-y-7zzZSB.js";
|
|
2
2
|
import { a as parseRequestPayload, i as parseRequestBody, n as flattenRequestQueries, r as formatValidationErrors } from "./request-CLOYytGP.js";
|
|
3
3
|
import { i as setValidatedInput, n as getValidatedInput } from "./validated-input-D84J8wcC.js";
|
|
4
|
-
import { t as HttpException } from "./HttpException-
|
|
5
|
-
import { n as ValidationException } from "./errors-
|
|
6
|
-
import { a as withAuthorization, c as capabilitiesOf, i as derivableAbility, l as mergeCapabilities, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware, u as stampCapabilities } from "./authorization-
|
|
4
|
+
import { n as NOT_FOUND_MESSAGE, t as HttpException } from "./HttpException-2tfZGamp.js";
|
|
5
|
+
import { n as ValidationException } from "./errors-C8neC8go.js";
|
|
6
|
+
import { a as withAuthorization, c as capabilitiesOf, i as derivableAbility, l as mergeCapabilities, n as authorizeMiddleware, o as Policy, r as authorizeResourceMiddleware, s as definePolicy, t as authorizeAllMiddleware, u as stampCapabilities } from "./authorization-rxx6aprN.js";
|
|
7
7
|
import { a as mapToolResponse, c as AGENT_PREFLIGHT_VERDICT_HEADER, i as describeBuildFailure, n as advertisesStructuredOutput, o as isDispatchedToolRequest, r as buildToolRequest, t as PREFLIGHT_ARGUMENT } from "./dispatch-ENWpBxbE.js";
|
|
8
8
|
import { i as trimSlashes } from "./contained-path-BkNSBljW.js";
|
|
9
9
|
import { PATH_PARAM_PATTERN, extractPathParamNames } from "./internal/route-path.js";
|
|
10
10
|
import { a as generateAppKey, c as parseAppKey, i as encodeDerivedKey, l as parsePreviousAppKeys, n as deriveAppKey, o as getAppKeyringFromEnv, r as deriveAppKeyring, s as normalizeAppKey, t as MessageSigner } from "./MessageSigner-DIUT1Yao.js";
|
|
11
11
|
import { n as detectServerlessRuntime, t as SERVERLESS_RUNTIME_LABELS } from "./serverless-D96rJb6x.js";
|
|
12
|
-
import { A as verifyOAuthState, B as ModelUserProvider, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, F as normalizeRedirectTarget, G as MemorySessionStore, H as NodeHasher, I as AuthManager, J as getSessionFromContext, K as createSessionMiddleware, L as DEFAULT_PROVIDER, M as jsonResponse, N as hostMatchesAllowlist, O as parseOAuthRedirectUrl, P as isAppRelativePath, R as TokenGuard, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as ScryptHasher, V as DefaultHasher, W as BaseUserProvider, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, j as defineMiddleware, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, q as defaultCookieSecure, r as completeEmailVerification, s as requireVerifiedEmail, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as SessionGuard } from "./auth-
|
|
12
|
+
import { A as verifyOAuthState, B as ModelUserProvider, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, F as normalizeRedirectTarget, G as MemorySessionStore, H as NodeHasher, I as AuthManager, J as getSessionFromContext, K as createSessionMiddleware, L as DEFAULT_PROVIDER, M as jsonResponse, N as hostMatchesAllowlist, O as parseOAuthRedirectUrl, P as isAppRelativePath, R as TokenGuard, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as ScryptHasher, V as DefaultHasher, W as BaseUserProvider, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, j as defineMiddleware, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, m as verifyPasswordResetToken, n as buildVerificationUrl, o as parseVerificationUrl, p as parsePasswordResetUrl, q as defaultCookieSecure, r as completeEmailVerification, s as requireVerifiedEmail, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as SessionGuard } from "./auth-CO9MlQNE.js";
|
|
13
13
|
import { t as resolveOptional } from "./resolve-optional-ax6gPWTp.js";
|
|
14
14
|
import { t as warnOnce } from "./warn-once-p-IlMjra.js";
|
|
15
15
|
import { a as defaultApplication, c as resolve, d as createContainer, f as getContainer, g as warnDeprecatedSetter, h as warnDeprecatedGetter, i as bindAmbient, l as useAsDefaultApplication, m as warnDeprecated, n as ambientBinding, o as defaultContainer, p as setContainer, r as ambientContainer, s as resetDefaultApplication, t as adoptDefaultApplication, u as Container } from "./default-application-s9SE-Er7.js";
|
|
16
16
|
import { n as ServiceProvider, t as ProviderManager } from "./ServiceProvider-G0YclITd.js";
|
|
17
|
-
import { C as scopesAllowTool, M as markAgentDispatch, N as readAgentPrincipal, S as parseToolScope, _ as tokenCanAny, a as getApiToken, b as classifyRegistrationScope, c as hasBearerHeader, d as revokeAllApiTokens, f as revokeApiToken, g as tokenCanAll, h as tokenCan, i as createBearerTokenMiddleware, j as installAgentPrincipal, l as parseApiToken, n as MemoryApiTokenStore, o as getApiTokenOrFail, r as createApiToken, s as getUserApiTokens, t as API_TOKEN_KEY, u as readBearerToken, v as verifyApiToken, x as expandToolScopes, y as AGENT_TOOL_NAME_PATTERN } from "./api-token-
|
|
18
|
-
import { o as AuthenticationException, r as getAuthContext, t as AUTH_CONTEXT_KEY } from "./context
|
|
17
|
+
import { C as scopesAllowTool, M as markAgentDispatch, N as readAgentPrincipal, S as parseToolScope, _ as tokenCanAny, a as getApiToken, b as classifyRegistrationScope, c as hasBearerHeader, d as revokeAllApiTokens, f as revokeApiToken, g as tokenCanAll, h as tokenCan, i as createBearerTokenMiddleware, j as installAgentPrincipal, l as parseApiToken, n as MemoryApiTokenStore, o as getApiTokenOrFail, r as createApiToken, s as getUserApiTokens, t as API_TOKEN_KEY, u as readBearerToken, v as verifyApiToken, x as expandToolScopes, y as AGENT_TOOL_NAME_PATTERN } from "./api-token-1-INqeVU.js";
|
|
18
|
+
import { o as AuthenticationException, r as getAuthContext, t as AUTH_CONTEXT_KEY } from "./context--l2HdOhy.js";
|
|
19
19
|
import { a as md5, c as sha256, d as verifyPassword, i as hmac, l as sha512, n as hash, o as needsRehash, r as hashPassword, s as secureCompare, t as check, u as verifyHmac } from "./Hash-D2DFd8xX.js";
|
|
20
20
|
import { t as redactQueryParams } from "./redact-query-params-Ba-sAfcP.js";
|
|
21
21
|
import { n as getRequestContainer, r as tryGetRequestContainer, t as CONTAINER_CONTEXT_KEY } from "./request-container-BbuH0JJy.js";
|
|
@@ -24,10 +24,10 @@ import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemorySt
|
|
|
24
24
|
import { n as createRedisClient, r as RedisSessionStore } from "./client-C5Wj9P9o.js";
|
|
25
25
|
import { c as isDevCenterFeedbackRequest, i as loadRuntimeErrorsModule, l as isMcpEndpointEnabled, r as captureRuntimeError, t as RUNTIME_ERRORS_BINDING } from "./runtime-error-capture-DLRXwp0d.js";
|
|
26
26
|
import { n as isHotReloadRuntime, r as matchingOpenParen, t as claimHotDisposable } from "./hot-disposables-W2fH-GID.js";
|
|
27
|
-
import { a as setBroadcastManager, c as PresenceChannel, d as createWebSocketOriginGuard, 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-
|
|
27
|
+
import { a as setBroadcastManager, c as PresenceChannel, d as createWebSocketOriginGuard, 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";
|
|
28
28
|
import { c as tc, d as Translator, f as getPluralizationRule, i as getI18n, l as tryGetI18n, m as selectPluralForm, n as I18nManager, o as setI18n, p as pluralizationRules, r as createI18n, s as t, t as MemoryLoader, u as JsonLoader } from "./i18n-BShPpJZa.js";
|
|
29
29
|
import { n as isAgentToolRequest } from "./agent-request-Caj6bnbj.js";
|
|
30
|
-
import { a as cannot, f as setGate, i as can, l as getGate, n as Response$1, o as createGate, p as AuthorizationException, r as authorize, s as defineGate, t as Gate } from "./Gate-
|
|
30
|
+
import { a as cannot, f as setGate, h as hasComposedMessage, i as can, l as getGate, m as NotFoundHttpException, n as Response$1, o as createGate, p as AuthorizationException, r as authorize, s as defineGate, t as Gate } from "./Gate-BHyDcDKo.js";
|
|
31
31
|
import { r as isDocsViewerEnabled } from "./endpoint-CTIzcagh.js";
|
|
32
32
|
import { n as isWildcardHost, t as formatHostPort } from "./host-port-t6wQFaRu.js";
|
|
33
33
|
import { C as stopBunServerBounded, S as stopActiveViteDevServer, _ as registerBunTeardown, b as setActiveBunServer, c as isViteProduction, d as startViteDevServer, g as hotReloadStopBound, h as getGlobalState, i as clientManifestCandidates, l as loadViteManifest, m as closeOwnedViteDevServer, n as INJECTED_CLIENT_MANIFEST_SOURCE, o as getManifestFile, p as adoptViteDevServer, r as PUBLIC_ASSETS_URL_PREFIX, s as injectedClientManifest, u as normalizeDevServerUrl, v as releaseActiveBunServer, x as stopActiveBunServer, y as reusableActiveViteDevServer } from "./vite-manifest-DO0pU1vm.js";
|
|
@@ -1225,6 +1225,105 @@ var SessionManager = class {
|
|
|
1225
1225
|
}
|
|
1226
1226
|
};
|
|
1227
1227
|
//#endregion
|
|
1228
|
+
//#region src/errors/error-page.ts
|
|
1229
|
+
function escapeHtml$1(value) {
|
|
1230
|
+
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
1231
|
+
}
|
|
1232
|
+
/** Production error page: no stack traces or internal details are exposed. */
|
|
1233
|
+
function renderErrorPage(statusCode, message) {
|
|
1234
|
+
const title = STATUS_TITLES[statusCode] ?? "Error";
|
|
1235
|
+
return `<!DOCTYPE html>
|
|
1236
|
+
<html lang="en">
|
|
1237
|
+
<head>
|
|
1238
|
+
<meta charset="utf-8">
|
|
1239
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
1240
|
+
<title>${statusCode} ${title}</title>
|
|
1241
|
+
<style>
|
|
1242
|
+
/* Guren UI's tokens (github.com/gurenjs/guren-ui); the link home is the screen's one crimson fill. */
|
|
1243
|
+
:root {
|
|
1244
|
+
color-scheme: light;
|
|
1245
|
+
--g-page: #ffffff; --g-heading: #111827; --g-text-2: #4b5563; --g-muted: #6b7280;
|
|
1246
|
+
--g-accent: #db1b1b; --g-accent-down: #b91c1c; --g-on-accent: #fff5f5;
|
|
1247
|
+
}
|
|
1248
|
+
@media (prefers-color-scheme: dark) {
|
|
1249
|
+
:root { color-scheme: dark; --g-page: #1a1a2e; --g-heading: #e0def4; --g-text-2: #aeabc9; --g-muted: #8d89a7; }
|
|
1250
|
+
}
|
|
1251
|
+
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
1252
|
+
body {
|
|
1253
|
+
font-family: 'Noto Sans JP', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
1254
|
+
min-height: 100vh;
|
|
1255
|
+
display: flex;
|
|
1256
|
+
align-items: center;
|
|
1257
|
+
justify-content: center;
|
|
1258
|
+
background: var(--g-page);
|
|
1259
|
+
color: var(--g-heading);
|
|
1260
|
+
-webkit-font-smoothing: antialiased;
|
|
1261
|
+
}
|
|
1262
|
+
.container { text-align: center; padding: 2rem; }
|
|
1263
|
+
.status { font: 700 6rem/1 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; color: var(--g-muted); }
|
|
1264
|
+
.title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; margin-top: 1rem; }
|
|
1265
|
+
.description { color: var(--g-text-2); margin-top: 0.5rem; max-width: 28rem; }
|
|
1266
|
+
.home-link {
|
|
1267
|
+
display: inline-block; margin-top: 2rem; padding: 8px 16px;
|
|
1268
|
+
background: var(--g-accent); color: var(--g-on-accent); border-radius: 8px;
|
|
1269
|
+
text-decoration: none; font-size: 13.5px; font-weight: 700;
|
|
1270
|
+
}
|
|
1271
|
+
.home-link:hover { background: var(--g-accent-down); }
|
|
1272
|
+
.home-link:focus-visible { outline: 2px solid var(--g-accent); outline-offset: 2px; }
|
|
1273
|
+
</style>
|
|
1274
|
+
</head>
|
|
1275
|
+
<body>
|
|
1276
|
+
<main class="container">
|
|
1277
|
+
<div class="status">${statusCode}</div>
|
|
1278
|
+
<h1 class="title">${title}</h1>
|
|
1279
|
+
<p class="description">${escapeHtml$1(message ?? STATUS_DESCRIPTIONS[statusCode] ?? "An unexpected error occurred.")}</p>
|
|
1280
|
+
<a href="/" class="home-link">Go Home</a>
|
|
1281
|
+
</main>
|
|
1282
|
+
</body>
|
|
1283
|
+
</html>`;
|
|
1284
|
+
}
|
|
1285
|
+
const STATUS_TITLES = {
|
|
1286
|
+
400: "Bad Request",
|
|
1287
|
+
401: "Unauthorized",
|
|
1288
|
+
403: "Forbidden",
|
|
1289
|
+
404: "Not Found",
|
|
1290
|
+
405: "Method Not Allowed",
|
|
1291
|
+
408: "Request Timeout",
|
|
1292
|
+
419: "Page Expired",
|
|
1293
|
+
422: "Unprocessable Entity",
|
|
1294
|
+
429: "Too Many Requests",
|
|
1295
|
+
500: "Server Error",
|
|
1296
|
+
502: "Bad Gateway",
|
|
1297
|
+
503: "Service Unavailable",
|
|
1298
|
+
504: "Gateway Timeout"
|
|
1299
|
+
};
|
|
1300
|
+
const STATUS_DESCRIPTIONS = {
|
|
1301
|
+
400: "The request could not be understood by the server.",
|
|
1302
|
+
401: "You need to sign in to access this page.",
|
|
1303
|
+
403: "You do not have permission to access this page.",
|
|
1304
|
+
404: "The page you are looking for could not be found.",
|
|
1305
|
+
405: "The request method is not supported for this page.",
|
|
1306
|
+
419: "Your session has expired. Please refresh and try again.",
|
|
1307
|
+
422: "The submitted data was invalid.",
|
|
1308
|
+
429: "You are making too many requests. Please slow down.",
|
|
1309
|
+
500: "Something went wrong on our end. Please try again later.",
|
|
1310
|
+
502: "The server received an invalid response from an upstream server.",
|
|
1311
|
+
503: "The service is temporarily unavailable. Please try again later.",
|
|
1312
|
+
504: "The server did not receive a timely response from an upstream server."
|
|
1313
|
+
};
|
|
1314
|
+
//#endregion
|
|
1315
|
+
//#region src/errors/wants-html.ts
|
|
1316
|
+
/**
|
|
1317
|
+
* A browser navigation: it accepts HTML and is not an Inertia visit, an XHR or a
|
|
1318
|
+
* JSON caller, each of which needs a JSON payload. `ExceptionHandler` and the
|
|
1319
|
+
* CSRF middleware both answer an HTML page by this one rule.
|
|
1320
|
+
*/
|
|
1321
|
+
function wantsHtmlResponse(ctx) {
|
|
1322
|
+
if (!ctx?.req?.header) return false;
|
|
1323
|
+
const accept = ctx.req.header("accept") ?? "";
|
|
1324
|
+
return !(accept.includes("application/json") || ctx.req.header("x-requested-with") === "XMLHttpRequest" || ctx.req.header("x-inertia") === "true") && accept.includes("text/html");
|
|
1325
|
+
}
|
|
1326
|
+
//#endregion
|
|
1228
1327
|
//#region src/http/middleware/csrf.ts
|
|
1229
1328
|
const CSRF_TOKEN_KEY = "_csrf_token";
|
|
1230
1329
|
const CSRF_HEADER_NAME = "X-CSRF-TOKEN";
|
|
@@ -1237,6 +1336,9 @@ const DEFAULT_PROTECTED_METHODS = [
|
|
|
1237
1336
|
"PATCH",
|
|
1238
1337
|
"DELETE"
|
|
1239
1338
|
];
|
|
1339
|
+
/** Laravel's "Page Expired"; `renderErrorPage()` titles it so, where a 403 page would read "Forbidden". */
|
|
1340
|
+
const CSRF_PAGE_EXPIRED_STATUS = 419;
|
|
1341
|
+
const CSRF_PAGE_EXPIRED_MESSAGE = "This form expired before it was sent. Go back, reload the page and submit the form again.";
|
|
1240
1342
|
const CSRF_CONTEXT_KEY = "guren:csrf-token";
|
|
1241
1343
|
const CSRF_PURPOSE = "csrf";
|
|
1242
1344
|
function createCsrfSigner() {
|
|
@@ -1426,12 +1528,24 @@ function createCsrfMiddleware(options = {}, cookielessAuthEndpoints) {
|
|
|
1426
1528
|
}
|
|
1427
1529
|
if (!verifyCsrfToken(ctx, await getTokenFromRequest(ctx))) {
|
|
1428
1530
|
if (onError) return onError(ctx);
|
|
1429
|
-
return
|
|
1531
|
+
return csrfMismatchResponse(ctx);
|
|
1430
1532
|
}
|
|
1431
1533
|
await next();
|
|
1432
1534
|
settleCookie(ctx);
|
|
1433
1535
|
};
|
|
1434
1536
|
}
|
|
1537
|
+
/**
|
|
1538
|
+
* A form posted before the page hydrated carries no header token, and a browser
|
|
1539
|
+
* would show the JSON as the page. Every other caller keeps the 403 JSON, whose
|
|
1540
|
+
* message `@guren/testing`'s `withCsrf()` hint and the docs quote.
|
|
1541
|
+
*/
|
|
1542
|
+
function csrfMismatchResponse(ctx) {
|
|
1543
|
+
if (!wantsHtmlResponse(ctx)) return jsonResponse({ message: "CSRF token mismatch" }, 403);
|
|
1544
|
+
return new Response(renderErrorPage(CSRF_PAGE_EXPIRED_STATUS, CSRF_PAGE_EXPIRED_MESSAGE), {
|
|
1545
|
+
status: CSRF_PAGE_EXPIRED_STATUS,
|
|
1546
|
+
headers: { "Content-Type": "text/html; charset=UTF-8" }
|
|
1547
|
+
});
|
|
1548
|
+
}
|
|
1435
1549
|
function setXsrfCookie(ctx, token, options = {}) {
|
|
1436
1550
|
const { path = "/", secure = defaultCookieSecure(), sameSite = "Lax" } = options;
|
|
1437
1551
|
ctx.header("Set-Cookie", `${XSRF_COOKIE_NAME}=${encodeURIComponent(token)}; Path=${path}; SameSite=${sameSite}${secure ? "; Secure" : ""}`, { append: true });
|
|
@@ -1940,6 +2054,24 @@ function isSafeRedirectUrl(url, requestUrl, allowedHosts = []) {
|
|
|
1940
2054
|
return false;
|
|
1941
2055
|
}
|
|
1942
2056
|
}
|
|
2057
|
+
/**
|
|
2058
|
+
* The path of a `Referer` on one of `acceptedHosts` (as `URL.host` spells them,
|
|
2059
|
+
* port included), for redirecting back, or `fallback`. A relative Referer resolves
|
|
2060
|
+
* against `requestUrl`. The scheme is not compared: behind a TLS-terminating proxy
|
|
2061
|
+
* the request reads `http:` while the browser's Referer reads `https:`. Only the
|
|
2062
|
+
* path and query are kept, so the browser stays on its own origin.
|
|
2063
|
+
*/
|
|
2064
|
+
function sameHostRefererPath(referer, requestUrl, acceptedHosts, fallback = "/") {
|
|
2065
|
+
if (!referer) return fallback;
|
|
2066
|
+
try {
|
|
2067
|
+
const target = new URL(referer, requestUrl);
|
|
2068
|
+
if (target.protocol !== "http:" && target.protocol !== "https:" || !acceptedHosts.includes(target.host)) return fallback;
|
|
2069
|
+
const pathname = normalizeRedirectTarget(target.pathname);
|
|
2070
|
+
return isAppRelativePath(pathname) ? `${pathname}${target.search}` : fallback;
|
|
2071
|
+
} catch {
|
|
2072
|
+
return fallback;
|
|
2073
|
+
}
|
|
2074
|
+
}
|
|
1943
2075
|
//#endregion
|
|
1944
2076
|
//#region src/http/middleware/force-https.ts
|
|
1945
2077
|
/**
|
|
@@ -2125,93 +2257,6 @@ var AuthServiceProvider = class extends ServiceProvider {
|
|
|
2125
2257
|
}
|
|
2126
2258
|
};
|
|
2127
2259
|
//#endregion
|
|
2128
|
-
//#region src/errors/error-page.ts
|
|
2129
|
-
function escapeHtml$1(value) {
|
|
2130
|
-
return value.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
2131
|
-
}
|
|
2132
|
-
/** Production error page: no stack traces or internal details are exposed. */
|
|
2133
|
-
function renderErrorPage(statusCode, message) {
|
|
2134
|
-
const title = STATUS_TITLES[statusCode] ?? "Error";
|
|
2135
|
-
return `<!DOCTYPE html>
|
|
2136
|
-
<html lang="en">
|
|
2137
|
-
<head>
|
|
2138
|
-
<meta charset="utf-8">
|
|
2139
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
2140
|
-
<title>${statusCode} ${title}</title>
|
|
2141
|
-
<style>
|
|
2142
|
-
/* Guren UI's tokens (github.com/gurenjs/guren-ui); the link home is the screen's one crimson fill. */
|
|
2143
|
-
:root {
|
|
2144
|
-
color-scheme: light;
|
|
2145
|
-
--g-page: #ffffff; --g-heading: #111827; --g-text-2: #4b5563; --g-line-strong: #d1d5db;
|
|
2146
|
-
--g-accent: #db1b1b; --g-accent-down: #b91c1c; --g-on-accent: #fff5f5;
|
|
2147
|
-
}
|
|
2148
|
-
@media (prefers-color-scheme: dark) {
|
|
2149
|
-
:root { color-scheme: dark; --g-page: #1a1a2e; --g-heading: #e0def4; --g-text-2: #aeabc9; --g-line-strong: #3d3d5c; }
|
|
2150
|
-
}
|
|
2151
|
-
* { margin: 0; padding: 0; box-sizing: border-box; }
|
|
2152
|
-
body {
|
|
2153
|
-
font-family: 'Noto Sans JP', ui-sans-serif, system-ui, -apple-system, 'Segoe UI', sans-serif;
|
|
2154
|
-
min-height: 100vh;
|
|
2155
|
-
display: flex;
|
|
2156
|
-
align-items: center;
|
|
2157
|
-
justify-content: center;
|
|
2158
|
-
background: var(--g-page);
|
|
2159
|
-
color: var(--g-heading);
|
|
2160
|
-
-webkit-font-smoothing: antialiased;
|
|
2161
|
-
}
|
|
2162
|
-
.container { text-align: center; padding: 2rem; }
|
|
2163
|
-
.status { font: 700 6rem/1 'JetBrains Mono', ui-monospace, Menlo, Consolas, monospace; color: var(--g-line-strong); }
|
|
2164
|
-
.title { font-size: 1.5rem; font-weight: 700; letter-spacing: -0.01em; margin-top: 1rem; }
|
|
2165
|
-
.description { color: var(--g-text-2); margin-top: 0.5rem; max-width: 28rem; }
|
|
2166
|
-
.home-link {
|
|
2167
|
-
display: inline-block; margin-top: 2rem; padding: 8px 16px;
|
|
2168
|
-
background: var(--g-accent); color: var(--g-on-accent); border-radius: 8px;
|
|
2169
|
-
text-decoration: none; font-size: 13.5px; font-weight: 700;
|
|
2170
|
-
}
|
|
2171
|
-
.home-link:hover { background: var(--g-accent-down); }
|
|
2172
|
-
.home-link:focus-visible { outline: 2px solid var(--g-accent); outline-offset: 2px; }
|
|
2173
|
-
</style>
|
|
2174
|
-
</head>
|
|
2175
|
-
<body>
|
|
2176
|
-
<div class="container">
|
|
2177
|
-
<div class="status">${statusCode}</div>
|
|
2178
|
-
<h1 class="title">${title}</h1>
|
|
2179
|
-
<p class="description">${escapeHtml$1(message ?? STATUS_DESCRIPTIONS[statusCode] ?? "An unexpected error occurred.")}</p>
|
|
2180
|
-
<a href="/" class="home-link">Go Home</a>
|
|
2181
|
-
</div>
|
|
2182
|
-
</body>
|
|
2183
|
-
</html>`;
|
|
2184
|
-
}
|
|
2185
|
-
const STATUS_TITLES = {
|
|
2186
|
-
400: "Bad Request",
|
|
2187
|
-
401: "Unauthorized",
|
|
2188
|
-
403: "Forbidden",
|
|
2189
|
-
404: "Not Found",
|
|
2190
|
-
405: "Method Not Allowed",
|
|
2191
|
-
408: "Request Timeout",
|
|
2192
|
-
419: "Page Expired",
|
|
2193
|
-
422: "Unprocessable Entity",
|
|
2194
|
-
429: "Too Many Requests",
|
|
2195
|
-
500: "Server Error",
|
|
2196
|
-
502: "Bad Gateway",
|
|
2197
|
-
503: "Service Unavailable",
|
|
2198
|
-
504: "Gateway Timeout"
|
|
2199
|
-
};
|
|
2200
|
-
const STATUS_DESCRIPTIONS = {
|
|
2201
|
-
400: "The request could not be understood by the server.",
|
|
2202
|
-
401: "You need to sign in to access this page.",
|
|
2203
|
-
403: "You do not have permission to access this page.",
|
|
2204
|
-
404: "The page you are looking for could not be found.",
|
|
2205
|
-
405: "The request method is not supported for this page.",
|
|
2206
|
-
419: "Your session has expired. Please refresh and try again.",
|
|
2207
|
-
422: "The submitted data was invalid.",
|
|
2208
|
-
429: "You are making too many requests. Please slow down.",
|
|
2209
|
-
500: "Something went wrong on our end. Please try again later.",
|
|
2210
|
-
502: "The server received an invalid response from an upstream server.",
|
|
2211
|
-
503: "The service is temporarily unavailable. Please try again later.",
|
|
2212
|
-
504: "The server did not receive a timely response from an upstream server."
|
|
2213
|
-
};
|
|
2214
|
-
//#endregion
|
|
2215
2260
|
//#region src/errors/debug-page.ts
|
|
2216
2261
|
/** Development-only error page: exposes the stack trace and request details. */
|
|
2217
2262
|
function renderDebugPage(thrown, request) {
|
|
@@ -2272,8 +2317,8 @@ function renderDebugPage(thrown, request) {
|
|
|
2272
2317
|
.stack-frames { display: flex; flex-direction: column; gap: 2px; }
|
|
2273
2318
|
.frame { padding: 0.6rem 0.75rem; border-radius: 8px; cursor: default; transition: background 0.15s; }
|
|
2274
2319
|
.frame:hover { background: var(--g-raised); }
|
|
2275
|
-
|
|
2276
|
-
.frame.vendor
|
|
2320
|
+
/* Dimmed by color: an opacity fades this text under the 4.5:1 that small text needs. */
|
|
2321
|
+
.frame.vendor .frame-method, .frame.vendor .frame-location { color: var(--g-muted); }
|
|
2277
2322
|
.frame-header { display: flex; align-items: center; gap: 0.75rem; font-size: 0.875rem; }
|
|
2278
2323
|
.frame-index { color: var(--g-muted); font: 500 0.75rem var(--g-font-mono); min-width: 2rem; flex-shrink: 0; }
|
|
2279
2324
|
.frame-method { color: var(--g-heading); font-family: var(--g-font-mono); font-weight: 500; }
|
|
@@ -2299,17 +2344,19 @@ function renderDebugPage(thrown, request) {
|
|
|
2299
2344
|
</head>
|
|
2300
2345
|
<body>
|
|
2301
2346
|
<div class="container">
|
|
2302
|
-
<
|
|
2303
|
-
<
|
|
2304
|
-
|
|
2305
|
-
<
|
|
2306
|
-
|
|
2307
|
-
|
|
2308
|
-
|
|
2347
|
+
<main>
|
|
2348
|
+
<header class="error-header">
|
|
2349
|
+
<div class="status-badge">${statusCode}</div>
|
|
2350
|
+
<div class="error-info">
|
|
2351
|
+
<h1 class="error-class">${escapeHtml(errorName)}</h1>
|
|
2352
|
+
<p class="error-message">${errorMessage}</p>
|
|
2353
|
+
</div>
|
|
2354
|
+
</header>
|
|
2309
2355
|
|
|
2310
|
-
|
|
2311
|
-
|
|
2312
|
-
|
|
2356
|
+
${stackSection}
|
|
2357
|
+
${requestSection}
|
|
2358
|
+
${environmentSection}
|
|
2359
|
+
</main>
|
|
2313
2360
|
|
|
2314
2361
|
<footer class="footer">
|
|
2315
2362
|
<p>Guren Framework — Debug Error Page</p>
|
|
@@ -2561,26 +2608,34 @@ var ExceptionHandler = class {
|
|
|
2561
2608
|
renderDefaultException(error, ctx) {
|
|
2562
2609
|
const debug = this.shouldShowDetails();
|
|
2563
2610
|
const statusCode = resolveExceptionStatus(error);
|
|
2611
|
+
const replacement = !debug && statusCode === 404 && hasComposedNotFoundMessage(error) ? NOT_FOUND_MESSAGE : void 0;
|
|
2564
2612
|
let body;
|
|
2565
|
-
if (HttpException.isHttpException(error))
|
|
2566
|
-
|
|
2567
|
-
|
|
2613
|
+
if (HttpException.isHttpException(error)) {
|
|
2614
|
+
body = error.toResponse(debug).body;
|
|
2615
|
+
if (replacement !== void 0 && body.message === error.message) body = {
|
|
2616
|
+
...body,
|
|
2617
|
+
message: replacement
|
|
2618
|
+
};
|
|
2619
|
+
} else {
|
|
2620
|
+
body = { message: replacement ?? (statusCode < 500 || debug ? error.message : "Internal Server Error") };
|
|
2568
2621
|
if (debug) {
|
|
2569
2622
|
body.exception = error.name;
|
|
2570
2623
|
body.stack = error.stack;
|
|
2571
2624
|
}
|
|
2572
2625
|
}
|
|
2573
2626
|
if (this.wantsHtmlResponse(ctx)) {
|
|
2574
|
-
const html = debug && statusCode >= 500 ? renderDebugPage(error, ctx.req.raw) : renderErrorPage(statusCode, body.message);
|
|
2627
|
+
const html = debug && statusCode >= 500 ? renderDebugPage(error, ctx.req.raw) : renderErrorPage(statusCode, statusCode === 404 && body.message === "Not Found" ? void 0 : body.message);
|
|
2575
2628
|
return ctx.html(html, statusCode);
|
|
2576
2629
|
}
|
|
2577
2630
|
return ctx.json(body, statusCode);
|
|
2578
2631
|
}
|
|
2579
|
-
/**
|
|
2632
|
+
/**
|
|
2633
|
+
* False for Inertia, XHR and JSON callers, which need a JSON payload. The CSRF
|
|
2634
|
+
* middleware picks its page by `wants-html.ts` directly, so an override here
|
|
2635
|
+
* does not change what a rejected form post answers.
|
|
2636
|
+
*/
|
|
2580
2637
|
wantsHtmlResponse(ctx) {
|
|
2581
|
-
|
|
2582
|
-
const accept = ctx.req.header("accept") ?? "";
|
|
2583
|
-
return !(accept.includes("application/json") || ctx.req.header("x-requested-with") === "XMLHttpRequest" || ctx.req.header("x-inertia") === "true") && accept.includes("text/html");
|
|
2638
|
+
return wantsHtmlResponse(ctx);
|
|
2584
2639
|
}
|
|
2585
2640
|
middleware() {
|
|
2586
2641
|
return async (ctx, next) => {
|
|
@@ -2595,6 +2650,14 @@ var ExceptionHandler = class {
|
|
|
2595
2650
|
}
|
|
2596
2651
|
};
|
|
2597
2652
|
/**
|
|
2653
|
+
* A 404 message the framework wrote from the record rather than one a developer
|
|
2654
|
+
* chose: the ORM's `findOrFail()` (by name and `modelName`, since it crosses a
|
|
2655
|
+
* package boundary), a `NotFoundHttpException.for*()`, or none at all.
|
|
2656
|
+
*/
|
|
2657
|
+
function hasComposedNotFoundMessage(error) {
|
|
2658
|
+
return hasComposedMessage(error) || error.name === "ModelNotFoundException" && typeof error.modelName === "string" || error.message === "";
|
|
2659
|
+
}
|
|
2660
|
+
/**
|
|
2598
2661
|
* The HTTP status an exception carries, or 500 when it names none. Duck-typed
|
|
2599
2662
|
* on `statusCode` rather than `instanceof`, so a foreign exception crossing a
|
|
2600
2663
|
* package boundary (`ModelNotFoundException` from `@guren/orm`) still renders
|
|
@@ -2630,7 +2693,7 @@ function getExceptionHandler() {
|
|
|
2630
2693
|
return handler;
|
|
2631
2694
|
}
|
|
2632
2695
|
function abort(statusCode, message, errors) {
|
|
2633
|
-
throw new HttpException(statusCode, message ?? "Error", errors);
|
|
2696
|
+
throw new HttpException(statusCode, message ?? (statusCode === 404 ? "Not Found" : "Error"), errors);
|
|
2634
2697
|
}
|
|
2635
2698
|
function abortIf(condition, statusCode, message) {
|
|
2636
2699
|
if (condition) abort(statusCode, message);
|
|
@@ -2639,28 +2702,6 @@ function abortUnless(condition, statusCode, message) {
|
|
|
2639
2702
|
if (!condition) abort(statusCode, message);
|
|
2640
2703
|
}
|
|
2641
2704
|
//#endregion
|
|
2642
|
-
//#region src/errors/exceptions/NotFoundHttpException.ts
|
|
2643
|
-
/** 404: the requested resource could not be found. */
|
|
2644
|
-
var NotFoundHttpException = class NotFoundHttpException extends HttpException {
|
|
2645
|
-
resourceType;
|
|
2646
|
-
resourceId;
|
|
2647
|
-
constructor(message = "Not Found", resourceType, resourceId) {
|
|
2648
|
-
super(404, message);
|
|
2649
|
-
this.name = "NotFoundHttpException";
|
|
2650
|
-
this.resourceType = resourceType;
|
|
2651
|
-
this.resourceId = resourceId;
|
|
2652
|
-
}
|
|
2653
|
-
static forModel(model, id) {
|
|
2654
|
-
return new NotFoundHttpException(`${model} with ID ${id} not found.`, model, id);
|
|
2655
|
-
}
|
|
2656
|
-
static forRoute(path) {
|
|
2657
|
-
return new NotFoundHttpException(`Route ${path} not found.`, "Route");
|
|
2658
|
-
}
|
|
2659
|
-
static forResource(resource) {
|
|
2660
|
-
return new NotFoundHttpException(`${resource} not found.`, resource);
|
|
2661
|
-
}
|
|
2662
|
-
};
|
|
2663
|
-
//#endregion
|
|
2664
2705
|
//#region src/errors/exceptions/MethodNotAllowedException.ts
|
|
2665
2706
|
/** 405: the HTTP method is not allowed for the route. */
|
|
2666
2707
|
var MethodNotAllowedException = class MethodNotAllowedException extends HttpException {
|
|
@@ -2936,7 +2977,7 @@ var InertiaServiceProvider = class extends ServiceProvider {
|
|
|
2936
2977
|
}, 422);
|
|
2937
2978
|
const flattened = {};
|
|
2938
2979
|
for (const [key, messages] of Object.entries(error.errors ?? {})) flattened[key] = messages[0] ?? "";
|
|
2939
|
-
const headers = { Location: ctx.req.header("Referer")
|
|
2980
|
+
const headers = { Location: sameHostRefererPath(ctx.req.header("Referer"), ctx.req.url, this.refererHosts(ctx.req.url)) };
|
|
2940
2981
|
const session = getSessionFromContext(ctx);
|
|
2941
2982
|
if (session) session.flash("errors", flattened);
|
|
2942
2983
|
else headers["Set-Cookie"] = validationErrorsSetCookie(flattened);
|
|
@@ -2947,6 +2988,21 @@ var InertiaServiceProvider = class extends ServiceProvider {
|
|
|
2947
2988
|
});
|
|
2948
2989
|
}
|
|
2949
2990
|
/**
|
|
2991
|
+
* The request's host, and the one `APP_URL` names (what `config/http.ts`'s host
|
|
2992
|
+
* authorization and the auth scaffold's links key on): a proxy that does not
|
|
2993
|
+
* forward `Host` hands the app its upstream address instead. `X-Forwarded-Host`
|
|
2994
|
+
* is not read, since no app-wide trusted-proxy setting says when it is genuine.
|
|
2995
|
+
*/
|
|
2996
|
+
refererHosts(requestUrl) {
|
|
2997
|
+
const hosts = [new URL(requestUrl).host];
|
|
2998
|
+
const appUrl = this.container.makeOptional("env")?.APP_URL ?? (typeof process === "undefined" ? void 0 : process.env.APP_URL);
|
|
2999
|
+
if (typeof appUrl !== "string" || appUrl.trim() === "") return hosts;
|
|
3000
|
+
try {
|
|
3001
|
+
hosts.push(new URL(appUrl.trim()).host);
|
|
3002
|
+
} catch {}
|
|
3003
|
+
return hosts;
|
|
3004
|
+
}
|
|
3005
|
+
/**
|
|
2950
3006
|
* Auto-inject flashed `errors` into shared props. Scoped to this app's
|
|
2951
3007
|
* container so a second Application booted in the same process keeps its
|
|
2952
3008
|
* own registrations.
|
|
@@ -3569,7 +3625,7 @@ let devBanner;
|
|
|
3569
3625
|
*/
|
|
3570
3626
|
async function loadDevBanner() {
|
|
3571
3627
|
if (typeof process === "undefined") return devBanner;
|
|
3572
|
-
if (process.env.NODE_ENV !== "production") devBanner ??= await import("./dev-banner-
|
|
3628
|
+
if (process.env.NODE_ENV !== "production") devBanner ??= await import("./dev-banner-BUrHz-LF.js").then((n) => n.n);
|
|
3573
3629
|
return devBanner;
|
|
3574
3630
|
}
|
|
3575
3631
|
/**
|
|
@@ -3991,7 +4047,8 @@ var Application = class {
|
|
|
3991
4047
|
if (shouldLogBanner) this.logDevServerBanner({
|
|
3992
4048
|
hostname: boundHostname,
|
|
3993
4049
|
port: boundPort,
|
|
3994
|
-
assetsUrl: resolvedAssetsUrl ?? "http://localhost:5173"
|
|
4050
|
+
assetsUrl: resolvedAssetsUrl ?? "http://localhost:5173",
|
|
4051
|
+
assetServer: startedViteHere || reusableVite ? "managed" : "external"
|
|
3995
4052
|
});
|
|
3996
4053
|
else if (typeof process !== "undefined" && process.env.NODE_ENV === "production") console.info(`[guren] Listening on http://${formatHostPort(boundHostname, boundPort)}`);
|
|
3997
4054
|
return address;
|
|
@@ -5382,7 +5439,7 @@ var Validator = class Validator {
|
|
|
5382
5439
|
async validateOrThrow(data) {
|
|
5383
5440
|
const result = await this.validate(data);
|
|
5384
5441
|
if (!result.success) {
|
|
5385
|
-
const { ValidationException } = await import("./errors-
|
|
5442
|
+
const { ValidationException } = await import("./errors-C8neC8go.js").then((n) => n.t);
|
|
5386
5443
|
throw new ValidationException(result.errors);
|
|
5387
5444
|
}
|
|
5388
5445
|
return result.data;
|
package/dist/internal/testing.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { S as serializePage, T as withDefaultHeaders, _ as INERTIA_VARY, f as definePlugin, i as Controller, n as Resource, r as collect, t as JsonResource, u as defineModule, v as acceptsJson, x as mergeInertiaVary, y as buildInertiaPage } from "../Resource-
|
|
1
|
+
import { S as serializePage, T as withDefaultHeaders, _ as INERTIA_VARY, f as definePlugin, i as Controller, n as Resource, r as collect, t as JsonResource, u as defineModule, v as acceptsJson, x as mergeInertiaVary, y as buildInertiaPage } from "../Resource-y-7zzZSB.js";
|
|
2
2
|
import { r as formatValidationErrors } from "../request-CLOYytGP.js";
|
|
3
|
-
import { n as ValidationException } from "../errors-
|
|
3
|
+
import { n as ValidationException } from "../errors-C8neC8go.js";
|
|
4
4
|
import { n as ServiceProvider } from "../ServiceProvider-G0YclITd.js";
|
|
5
|
-
import { o as AuthenticationException } from "../context
|
|
5
|
+
import { o as AuthenticationException } from "../context--l2HdOhy.js";
|
|
6
6
|
export { AuthenticationException, Controller, INERTIA_VARY, JsonResource, Resource, ServiceProvider, ValidationException, acceptsJson, buildInertiaPage, collect, defineModule, definePlugin, formatValidationErrors, mergeInertiaVary, serializePage, withDefaultHeaders };
|
|
@@ -8,6 +8,13 @@ export declare class InertiaServiceProvider extends ServiceProvider {
|
|
|
8
8
|
boot(): void;
|
|
9
9
|
/** ValidationException on Inertia requests; others fall through to JSON 422. */
|
|
10
10
|
private registerValidationRenderer;
|
|
11
|
+
/**
|
|
12
|
+
* The request's host, and the one `APP_URL` names (what `config/http.ts`'s host
|
|
13
|
+
* authorization and the auth scaffold's links key on): a proxy that does not
|
|
14
|
+
* forward `Host` hands the app its upstream address instead. `X-Forwarded-Host`
|
|
15
|
+
* is not read, since no app-wide trusted-proxy setting says when it is genuine.
|
|
16
|
+
*/
|
|
17
|
+
private refererHosts;
|
|
11
18
|
/**
|
|
12
19
|
* Auto-inject flashed `errors` into shared props. Scoped to this app's
|
|
13
20
|
* container so a second Application booted in the same process keeps its
|
package/dist/runtime/index.js
CHANGED
|
@@ -2,7 +2,7 @@ import { a as trimTrailingSlashes, n as isRealPathWithin, t as isPathWithin } fr
|
|
|
2
2
|
import { n as parseImportMap } from "../inertia-defaults-BjrcT7za.js";
|
|
3
3
|
import { n as hash } from "../Hash-D2DFd8xX.js";
|
|
4
4
|
import { a as getManifestCss, c as isViteProduction, d as startViteDevServer, i as clientManifestCandidates, l as loadViteManifest, o as getManifestFile, r as PUBLIC_ASSETS_URL_PREFIX, u as normalizeDevServerUrl } from "../vite-manifest-DO0pU1vm.js";
|
|
5
|
-
import { r as logDevServerBanner, t as GUREN_ASCII_ART } from "../dev-banner-
|
|
5
|
+
import { r as logDevServerBanner, t as GUREN_ASCII_ART } from "../dev-banner-BUrHz-LF.js";
|
|
6
6
|
import { createRequire } from "node:module";
|
|
7
7
|
import { dirname, extname, join, resolve } from "node:path";
|
|
8
8
|
import { fileURLToPath } from "node:url";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@guren/server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.35.0",
|
|
4
4
|
"description": "HTTP layer of the Guren framework, on Hono: routing, controllers, middleware, auth, sessions, queues and the AWS Lambda adapter. Applications import it through @guren/core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"guren",
|