@guren/server 2.15.0 → 2.16.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/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
- package/dist/{Hash-C8aejmi8.js → Hash-D2DFd8xX.js} +7 -57
- package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
- package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
- package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-nNcbCIQX.js} +11 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +11 -39
- package/dist/agent/approval.d.ts +76 -187
- package/dist/agent/audit-emitter.d.ts +16 -44
- package/dist/agent/audit.d.ts +20 -56
- package/dist/agent/derive.d.ts +32 -66
- package/dist/agent/dispatch.d.ts +38 -90
- package/dist/agent/events.d.ts +11 -19
- package/dist/agent/meta-tools.d.ts +18 -46
- package/dist/agent/public.d.ts +6 -25
- package/dist/agent/public.js +1 -1
- package/dist/agent/redact.d.ts +16 -38
- package/dist/agent/scopes.d.ts +23 -69
- package/dist/auth/AuthManager.d.ts +19 -40
- package/dist/auth/AuthenticatableModel.d.ts +2 -2
- package/dist/auth/SessionGuard.d.ts +0 -1
- package/dist/auth/TokenGuard.d.ts +6 -26
- package/dist/auth/api-token.d.ts +16 -148
- package/dist/auth/context.d.ts +5 -10
- package/dist/auth/email-verification.d.ts +29 -127
- package/dist/auth/index.js +1 -1
- package/dist/auth/oauth/index.d.ts +35 -57
- package/dist/auth/password/DefaultHasher.d.ts +5 -14
- package/dist/auth/password/PasswordHasher.d.ts +5 -13
- package/dist/auth/password/hash-format.d.ts +5 -13
- package/dist/auth/password-reset.d.ts +16 -42
- package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
- package/dist/auth/providers/UserProvider.d.ts +4 -4
- package/dist/auth/signed-token.d.ts +18 -0
- package/dist/auth/types.d.ts +9 -32
- package/dist/auth/utils.d.ts +6 -27
- package/dist/{auth-DkYoAPVn.js → auth-CbdPH4Cd.js} +169 -502
- package/dist/authorization/Gate.d.ts +9 -145
- package/dist/authorization/Policy.d.ts +6 -53
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/middleware.d.ts +16 -62
- package/dist/authorization/types.d.ts +8 -64
- package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
- package/dist/broadcasting/BroadcastManager.d.ts +29 -149
- package/dist/broadcasting/channels/Channel.d.ts +1 -19
- package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
- package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
- package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
- package/dist/broadcasting/drivers/index.d.ts +1 -1
- package/dist/broadcasting/index.d.ts +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/types.d.ts +7 -88
- package/dist/{broadcasting-BwodCA4q.js → broadcasting-B5RzB0A2.js} +87 -414
- package/dist/cache/CacheManager.d.ts +8 -62
- package/dist/cache/TaggedCache.d.ts +2 -35
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +2 -36
- package/dist/cache/stores/MemoryStore.d.ts +2 -26
- package/dist/cache/stores/RedisStore.d.ts +1 -29
- package/dist/cache/types.d.ts +21 -128
- package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
- package/dist/client-C4TEr_Dd.js +9 -0
- package/dist/console/Command.d.ts +17 -126
- package/dist/console/ConsoleKernel.d.ts +2 -74
- package/dist/console/Input.d.ts +5 -113
- package/dist/console/Output.d.ts +3 -99
- package/dist/console/types.d.ts +3 -33
- package/dist/container/Container.d.ts +12 -103
- package/dist/container/ServiceProvider.d.ts +17 -61
- package/dist/container/bindings.d.ts +5 -26
- package/dist/container/defineModule.d.ts +16 -54
- package/dist/container/definePlugin.d.ts +12 -45
- package/dist/container/types.d.ts +2 -34
- package/dist/context-CXk_umpT.js +21 -0
- package/dist/database/Factory.d.ts +4 -57
- package/dist/database/Seeder.d.ts +8 -46
- package/dist/database/SeederRunner.d.ts +3 -33
- package/dist/database/types.d.ts +3 -24
- package/dist/discovery/AutoDiscovery.d.ts +10 -82
- package/dist/{dispatch-erOS9epZ.js → dispatch-BAwzftws.js} +32 -79
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
- package/dist/docs-viewer/endpoint.d.ts +5 -11
- package/dist/encryption/Encrypter.d.ts +5 -71
- package/dist/encryption/Hash.d.ts +7 -57
- package/dist/encryption/Random.d.ts +6 -99
- package/dist/encryption/index.js +3 -3
- package/dist/encryption/types.d.ts +10 -72
- package/dist/{encryption-D99Vmls3.js → encryption-uwP3Di4D.js} +9 -78
- package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
- package/dist/endpoint-Dsw3Acvq.js +26 -0
- package/dist/errors/ExceptionHandler.d.ts +3 -90
- package/dist/errors/HttpException.d.ts +2 -79
- package/dist/errors/debug-page.d.ts +3 -17
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
- package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
- package/dist/errors/exceptions/ValidationException.d.ts +2 -43
- package/dist/errors/types.d.ts +1 -25
- package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
- package/dist/events/Event.d.ts +1 -28
- package/dist/events/EventManager.d.ts +5 -107
- package/dist/events/Listener.d.ts +7 -55
- package/dist/events/builtin.d.ts +0 -24
- package/dist/events/index.js +1 -1
- package/dist/events/types.d.ts +4 -22
- package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
- package/dist/facades/index.d.ts +2 -14
- package/dist/health/HealthCheck.d.ts +0 -24
- package/dist/health/HealthManager.d.ts +0 -36
- package/dist/health/checks/CacheCheck.d.ts +2 -17
- package/dist/health/checks/CustomCheck.d.ts +0 -9
- package/dist/health/checks/DatabaseCheck.d.ts +2 -17
- package/dist/health/checks/MemoryCheck.d.ts +3 -12
- package/dist/health/checks/RedisCheck.d.ts +1 -13
- package/dist/health/checks/StorageCheck.d.ts +2 -17
- package/dist/health/index.js +1 -1
- package/dist/health/types.d.ts +4 -24
- package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
- package/dist/hot-disposables-B5BXqaIH.js +167 -0
- package/dist/hot-reload/hot-disposables.d.ts +22 -74
- package/dist/hot-reload/testing.d.ts +4 -9
- package/dist/http/Application.d.ts +62 -208
- package/dist/http/FormRequest.d.ts +4 -55
- package/dist/http/dev-assets.d.ts +13 -31
- package/dist/http/dev-banner.d.ts +2 -5
- package/dist/http/inertia-assets.d.ts +3 -6
- package/dist/http/middleware/capabilities.d.ts +27 -50
- package/dist/http/middleware/cors.d.ts +4 -29
- package/dist/http/middleware/csp.d.ts +2 -25
- package/dist/http/middleware/csrf.d.ts +20 -95
- package/dist/http/middleware/detect-locale.d.ts +7 -27
- package/dist/http/middleware/force-https.d.ts +6 -24
- package/dist/http/middleware/host-authorization.d.ts +2 -12
- package/dist/http/middleware/loopback-guard.d.ts +15 -33
- package/dist/http/middleware/rate-limit.d.ts +29 -126
- package/dist/http/middleware/redirect-safety.d.ts +2 -20
- package/dist/http/middleware/request-id.d.ts +1 -14
- package/dist/http/middleware/request-logging.d.ts +2 -13
- package/dist/http/middleware/response-headers.d.ts +5 -13
- package/dist/http/middleware/security-headers.d.ts +2 -16
- package/dist/http/middleware/session.d.ts +15 -34
- package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
- package/dist/http/middleware/validation.d.ts +8 -63
- package/dist/http/public-assets.d.ts +11 -7
- package/dist/http/request.d.ts +32 -118
- package/dist/http/resources/CursorPaginator.d.ts +5 -64
- package/dist/http/resources/Paginator.d.ts +7 -84
- package/dist/http/resources/Resource.d.ts +9 -65
- package/dist/http/resources/ResourceCollection.d.ts +5 -39
- package/dist/http/resources/types.d.ts +10 -30
- package/dist/http/static-documents.d.ts +10 -20
- package/dist/http/validation/Validator.d.ts +25 -85
- package/dist/http/validation/rules.d.ts +48 -147
- package/dist/http/validation/types.d.ts +16 -61
- package/dist/http/vite-assets.d.ts +5 -28
- package/dist/http/vite-dev-server.d.ts +6 -9
- package/dist/http/vite-manifest.d.ts +19 -33
- package/dist/i18n/I18nManager.d.ts +12 -78
- package/dist/i18n/Translator.d.ts +3 -54
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
- package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
- package/dist/i18n/pluralization.d.ts +4 -13
- package/dist/i18n/types.d.ts +17 -69
- package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
- package/dist/index.d.ts +2 -1
- package/dist/index.js +714 -3011
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/request.d.ts +6 -19
- package/dist/internal/request.js +1 -1
- package/dist/internal/route-path.d.ts +9 -21
- package/dist/internal/route-path.js +9 -21
- package/dist/internal/zod-compat.d.ts +55 -122
- package/dist/internal/zod-compat.js +39 -70
- package/dist/internal/zod-json-schema.d.ts +18 -54
- package/dist/internal/zod-json-schema.js +46 -123
- package/dist/jsx-runtime.d.ts +3 -8
- package/dist/lambda/index.d.ts +17 -79
- package/dist/lambda/index.js +11 -59
- package/dist/logging/LogManager.d.ts +1 -51
- package/dist/logging/Logger.d.ts +8 -47
- package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
- package/dist/logging/channels/DailyFileChannel.d.ts +1 -3
- package/dist/logging/channels/FileChannel.d.ts +1 -3
- package/dist/logging/daily-file-path.d.ts +7 -16
- package/dist/logging/index.js +1 -1
- package/dist/logging/types.d.ts +13 -45
- package/dist/{logging-B-kngi3q.js → logging-zOY1XCtq.js} +52 -141
- package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
- package/dist/mail/Mail.d.ts +10 -106
- package/dist/mail/MailManager.d.ts +2 -60
- package/dist/mail/index.js +1 -1
- package/dist/mail/transports/LogTransport.d.ts +1 -4
- package/dist/mail/transports/MemoryTransport.d.ts +1 -63
- package/dist/mail/transports/ResendTransport.d.ts +1 -23
- package/dist/mail/transports/SmtpTransport.d.ts +1 -31
- package/dist/mail/types.d.ts +28 -150
- package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
- package/dist/mcp/McpServiceProvider.d.ts +4 -10
- package/dist/mcp/create-mcp-server.d.ts +25 -57
- package/dist/mcp/endpoint.d.ts +12 -36
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +46 -227
- package/dist/mvc/Router.d.ts +50 -129
- package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
- package/dist/mvc/inertia/shared.d.ts +6 -19
- package/dist/mvc/mount-route.d.ts +2 -6
- package/dist/mvc/view.d.ts +1 -2
- package/dist/notifications/Notification.d.ts +8 -75
- package/dist/notifications/NotificationManager.d.ts +15 -88
- package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
- package/dist/notifications/channels/MailChannel.d.ts +2 -31
- package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
- package/dist/notifications/channels/SlackChannel.d.ts +3 -48
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/notifiable-type.d.ts +3 -6
- package/dist/notifications/registry.d.ts +8 -27
- package/dist/notifications/types.d.ts +16 -53
- package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
- package/dist/providers/AuthServiceProvider.d.ts +1 -3
- package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
- package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
- package/dist/providers/CacheServiceProvider.d.ts +1 -3
- package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
- package/dist/providers/ErrorServiceProvider.d.ts +1 -4
- package/dist/providers/EventServiceProvider.d.ts +1 -3
- package/dist/providers/HealthServiceProvider.d.ts +1 -3
- package/dist/providers/I18nServiceProvider.d.ts +6 -10
- package/dist/providers/InertiaServiceProvider.d.ts +1 -4
- package/dist/providers/LogServiceProvider.d.ts +1 -3
- package/dist/providers/MailServiceProvider.d.ts +1 -3
- package/dist/providers/NotificationServiceProvider.d.ts +1 -3
- package/dist/providers/OAuthServiceProvider.d.ts +1 -3
- package/dist/providers/QueueServiceProvider.d.ts +1 -3
- package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
- package/dist/providers/StorageServiceProvider.d.ts +1 -3
- package/dist/queue/FailedJobReporter.d.ts +1 -24
- package/dist/queue/Job.d.ts +12 -99
- package/dist/queue/QueueManager.d.ts +6 -57
- package/dist/queue/Worker.d.ts +4 -65
- package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
- package/dist/queue/drivers/RedisDriver.d.ts +7 -65
- package/dist/queue/drivers/SqsDriver.d.ts +6 -57
- package/dist/queue/drivers/SyncDriver.d.ts +10 -13
- package/dist/queue/index.js +2 -2
- package/dist/queue/types.d.ts +10 -92
- package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
- package/dist/redis/RedisApiTokenStore.d.ts +4 -56
- package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
- package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
- package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
- package/dist/redis/RedisRateLimitStore.d.ts +16 -49
- package/dist/redis/RedisSessionStore.d.ts +3 -44
- package/dist/redis/client.d.ts +2 -32
- package/dist/redis/index.js +47 -232
- package/dist/redis/redis-values.d.ts +6 -12
- package/dist/redis/scan-keys.d.ts +1 -4
- package/dist/request-CLOYytGP.js +68 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +50 -92
- package/dist/scheduling/CronParser.d.ts +0 -29
- package/dist/scheduling/Schedule.d.ts +1 -153
- package/dist/scheduling/ScheduledTask.d.ts +0 -31
- package/dist/scheduling/Scheduler.d.ts +0 -70
- package/dist/scheduling/index.js +1 -1
- package/dist/scheduling/types.d.ts +4 -65
- package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
- package/dist/storage/StorageManager.d.ts +0 -48
- package/dist/storage/drivers/LocalDriver.d.ts +1 -25
- package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
- package/dist/storage/drivers/S3Driver.d.ts +6 -36
- package/dist/storage/drivers/s3-acl.d.ts +5 -10
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +27 -265
- package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
- package/dist/support/contained-path.d.ts +10 -20
- package/dist/support/error-polyfill.d.ts +4 -6
- package/dist/support/expiry.d.ts +17 -33
- package/dist/support/expiry.js +17 -33
- package/dist/support/import-map.d.ts +3 -7
- package/dist/support/inertia-defaults.d.ts +5 -10
- package/dist/support/redirect-target.d.ts +4 -6
- package/dist/support/stack-frames.d.ts +11 -50
- package/dist/support/trim-slashes.d.ts +4 -7
- package/dist/support/warn-once.d.ts +2 -6
- package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
- package/dist/{vite-manifest-w_RSOvQW.js → vite-manifest-CTQp-SOo.js} +34 -58
- package/package.json +2 -2
- package/dist/client-Dd7vLcqp.js +0 -27
- package/dist/context-DoD0c7J_.js +0 -26
- package/dist/endpoint-D-20PiHY.js +0 -46
- package/dist/hot-disposables-WsTX2ySN.js +0 -281
- package/dist/request-CVQwpu2J.js +0 -129
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import type { Application } from './Application.js';
|
|
2
2
|
import { type RootPublicAssetsConfig } from './public-assets.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* pattern for it, and the file's path relative to that base.
|
|
4
|
+
* The vendored Inertia client's mount point: containing directory (always
|
|
5
|
+
* slash-terminated), Hono route pattern, and the file's path relative to it.
|
|
7
6
|
*/
|
|
8
7
|
export declare function resolveInertiaClientRoute(inertiaClientPath: string): {
|
|
9
8
|
base: string;
|
|
@@ -13,13 +12,13 @@ export declare function resolveInertiaClientRoute(inertiaClientPath: string): {
|
|
|
13
12
|
export interface DevAssetsOptions {
|
|
14
13
|
/** Absolute path to the resources directory (e.g. `/app/resources`). */
|
|
15
14
|
resourcesDir?: string;
|
|
16
|
-
/** Base import meta
|
|
15
|
+
/** Base import meta that relative paths resolve against. */
|
|
17
16
|
importMeta?: ImportMeta;
|
|
18
17
|
/** Relative path from `importMeta` to the resources directory. Defaults to `../resources`. */
|
|
19
18
|
resourcesPath?: string;
|
|
20
19
|
/** Path prefix to mount transpiled JS assets. Defaults to `/resources/js`. */
|
|
21
20
|
prefix?: string;
|
|
22
|
-
/** Route pattern
|
|
21
|
+
/** Route pattern serving raw CSS assets. Defaults to `/resources/css/*`. */
|
|
23
22
|
cssRoute?: string;
|
|
24
23
|
/** Absolute path to the CSS directory. Defaults to `<resourcesDir>/../css`. */
|
|
25
24
|
cssDir?: string;
|
|
@@ -42,37 +41,20 @@ export interface DevAssetsOptions {
|
|
|
42
41
|
/** Serve selected files from the public directory without the `/public` prefix. */
|
|
43
42
|
rootPublicAssets?: RootPublicAssetsConfig;
|
|
44
43
|
/**
|
|
45
|
-
* Serve document types (`.svg`, `.html`, XML)
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* a stored `.html` or `.svg` served inline is script in the app's own
|
|
51
|
-
* origin. Turn it on for a public directory holding nothing user-supplied —
|
|
52
|
-
* a static microsite under `public/docs/index.html`, say, which Hono resolves
|
|
53
|
-
* from a directory request and would otherwise hand back as a download.
|
|
54
|
-
*
|
|
55
|
-
* The root-level allowlist route has its own switch,
|
|
56
|
-
* `rootPublicAssets: { inlineDocuments: true }`; an app serving documents
|
|
57
|
-
* both ways sets both.
|
|
44
|
+
* Serve document types (`.svg`, `.html`, XML) inline rather than as
|
|
45
|
+
* downloads. Off by default: `public/` is also where uploads land, and a
|
|
46
|
+
* stored `.html` or `.svg` served inline is script in the app's own origin.
|
|
47
|
+
* The root-level allowlist route has its own `rootPublicAssets:
|
|
48
|
+
* { inlineDocuments: true }`.
|
|
58
49
|
*/
|
|
59
50
|
inlineDocuments?: boolean;
|
|
60
51
|
}
|
|
61
52
|
/**
|
|
62
|
-
*
|
|
63
|
-
* production serves
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* `paths` mapping to the package's TypeScript sources — production serves
|
|
67
|
-
* files, it cannot transpile them. So it anchors on `./package.json`, a
|
|
68
|
-
* subpath such a mapping misses (there is no `src/package.json`) and real
|
|
69
|
-
* package resolution answers with the package root.
|
|
53
|
+
* `@guren/inertia-client`'s build output. Anchored on `./package.json` rather
|
|
54
|
+
* than a code subpath, because production serves files and cannot transpile: a
|
|
55
|
+
* tsconfig `paths` mapping misses that subpath (there is no `src/package.json`)
|
|
56
|
+
* and real package resolution answers with the package root.
|
|
70
57
|
*/
|
|
71
58
|
export declare function resolveInertiaClientDir(): string;
|
|
72
|
-
/**
|
|
73
|
-
* Registers development asset serving middleware.
|
|
74
|
-
* @param app
|
|
75
|
-
* @param options
|
|
76
|
-
*/
|
|
77
59
|
export declare function registerDevAssets(app: Application, options: DevAssetsOptions): void;
|
|
78
60
|
export declare function createStaticRewrite(route: string): (path: string) => string;
|
|
@@ -6,11 +6,8 @@ export interface DevBannerOptions {
|
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* A wildcard bind answers on every interface but is not itself dialable on
|
|
9
|
-
* every platform.
|
|
10
|
-
*
|
|
11
|
-
* Lives here rather than beside its other caller because the banner and
|
|
12
|
-
* `Application.listen()`'s returned address are two renderings of one fact,
|
|
13
|
-
* and a platform caveat added to only one of them is the drift this replaces.
|
|
9
|
+
* every platform. Shared with `Application.listen()`'s returned address, which
|
|
10
|
+
* is the same fact rendered twice.
|
|
14
11
|
*/
|
|
15
12
|
export declare function isWildcardHost(hostname: string): boolean;
|
|
16
13
|
/** `host:port`, bracketing an IPv6 literal so the result is dialable. */
|
|
@@ -20,12 +20,9 @@ export interface AutoConfigureInertiaOptions extends InertiaAssetsOptions {
|
|
|
20
20
|
}
|
|
21
21
|
export declare function configureInertiaAssets(app: Application, options: InertiaAssetsOptions): void;
|
|
22
22
|
/**
|
|
23
|
-
* Serves the built Inertia client and
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
* Split out of {@link configureInertiaAssets} so it can be pointed at a
|
|
27
|
-
* directory: the caller derives `inertiaClientDir` from `import.meta.resolve`,
|
|
28
|
-
* which no test can redirect at a fixture.
|
|
23
|
+
* Serves the built Inertia client and its chunks. Takes a directory rather than
|
|
24
|
+
* deriving one, because the caller's `import.meta.resolve` cannot be redirected
|
|
25
|
+
* at a fixture by a test.
|
|
29
26
|
*/
|
|
30
27
|
export declare function registerBuiltInertiaClient(app: Application, inertiaClientDir: string, inertiaClientPath: string): void;
|
|
31
28
|
export declare function autoConfigureInertiaAssets(app: Application, options: AutoConfigureInertiaOptions): void;
|
|
@@ -1,16 +1,10 @@
|
|
|
1
1
|
import type { MiddlewareHandler } from 'hono';
|
|
2
2
|
/**
|
|
3
|
-
* Internal security-capability marker (RFC 0007)
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
* heuristics. `Symbol.for()` keeps the key identical across duplicated
|
|
9
|
-
* `@guren/server` copies in one process.
|
|
10
|
-
*
|
|
11
|
-
* Deliberately not part of the public API: nothing here is exported from
|
|
12
|
-
* the package root, and the shape may change in any release. A public
|
|
13
|
-
* `defineMiddleware` integration is future work in RFC 0007.
|
|
3
|
+
* Internal security-capability marker (RFC 0007): built-in middleware
|
|
4
|
+
* factories stamp their handlers so tooling can read what a chain enforces
|
|
5
|
+
* without name heuristics. `Symbol.for()` keeps the key identical across
|
|
6
|
+
* duplicated `@guren/server` copies in one process. Not public API — the
|
|
7
|
+
* shape may change in any release.
|
|
14
8
|
*/
|
|
15
9
|
export declare const CAPABILITIES: unique symbol;
|
|
16
10
|
export interface MiddlewareCapabilities {
|
|
@@ -24,55 +18,38 @@ export interface MiddlewareCapabilities {
|
|
|
24
18
|
/**
|
|
25
19
|
* Authorization enforced by the chain (RFC 0016 §4): what makes
|
|
26
20
|
* route → ability derivable without reading controller bodies.
|
|
27
|
-
*
|
|
28
|
-
* - `abilities` — the ability names checked, in the order the chain
|
|
29
|
-
* checks them. Empty when every check derives its ability at request
|
|
30
|
-
* time (see `resource`), and also for the degenerate
|
|
31
|
-
* `authorizeMiddleware([])`, which denies every request.
|
|
32
|
-
* - `mode` — how they combine. `'all'` every listed ability must pass,
|
|
33
|
-
* `'any'` at least one must. A list of exactly one normalizes to
|
|
34
|
-
* `'all'`, because any-of one ability *is* that ability — and the
|
|
35
|
-
* middleware treats it that way at runtime too, down to the denial
|
|
36
|
-
* message. So `'any'` means either two or more alternatives, or the
|
|
37
|
-
* degenerate empty list that denies every request. `'mixed'` means the
|
|
38
|
-
* chain carries more than one check and the conjunction of them is not
|
|
39
|
-
* expressible as either: authorization is present, but the ability is
|
|
40
|
-
* *not* cleanly derivable, and a consumer must treat it as undetermined
|
|
41
|
-
* rather than picking a name out of `abilities`. A single derivable
|
|
42
|
-
* ability is `abilities.length === 1` with `mode: 'all'` and no
|
|
43
|
-
* `resource`.
|
|
44
|
-
* - `resource` — present when a check resolves its ability from the
|
|
45
|
-
* request method (`authorizeResourceMiddleware`). `fromMethodMap: true`
|
|
46
|
-
* means the built-in verb map decides, so a consumer holding the
|
|
47
|
-
* route's method resolves the ability through
|
|
48
|
-
* `resourceAbilityForMethod()` in `../../authorization/middleware`.
|
|
49
|
-
* `false` means an `abilityFor` callback overrides that map and the
|
|
50
|
-
* real ability is unknowable statically — fail closed, do not fall
|
|
51
|
-
* back to the verb map.
|
|
52
21
|
*/
|
|
53
22
|
authorization?: {
|
|
23
|
+
/**
|
|
24
|
+
* In check order. Empty when the ability is resolved at request time
|
|
25
|
+
* (see `resource`), and for `authorizeMiddleware([])`, which denies all.
|
|
26
|
+
*/
|
|
54
27
|
abilities: string[];
|
|
28
|
+
/**
|
|
29
|
+
* A single ability normalizes to `'all'`, so `'any'` means two or more
|
|
30
|
+
* alternatives (or the empty deny-all list). `'mixed'` means several
|
|
31
|
+
* checks whose conjunction is neither: authorization is present but the
|
|
32
|
+
* ability is *not* derivable — treat it as undetermined rather than
|
|
33
|
+
* reading a name out of `abilities`.
|
|
34
|
+
*/
|
|
55
35
|
mode: 'all' | 'any' | 'mixed';
|
|
36
|
+
/**
|
|
37
|
+
* Present when a check resolves its ability from the request method.
|
|
38
|
+
* `fromMethodMap` → resolve through `resourceAbilityForMethod()` in
|
|
39
|
+
* `../../authorization/middleware`; otherwise an `abilityFor` callback
|
|
40
|
+
* overrides the verb map and the ability is statically unknowable, so
|
|
41
|
+
* fail closed rather than falling back to it.
|
|
42
|
+
*/
|
|
56
43
|
resource?: {
|
|
57
44
|
fromMethodMap: boolean;
|
|
58
45
|
};
|
|
59
46
|
};
|
|
60
47
|
}
|
|
61
48
|
/**
|
|
62
|
-
*
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
* non-authoritative check makes the verb map unusable for the whole chain.
|
|
67
|
-
*
|
|
68
|
-
* Mutates `into` and never `stamp` — nested objects and arrays are copied
|
|
69
|
-
* the first time they are taken, so a later merge cannot write back through
|
|
70
|
-
* the aggregate into a handler's stamp.
|
|
71
|
-
*
|
|
72
|
-
* Every call counts as an independent check. Folding the *same* stamp twice
|
|
73
|
-
* would read as two of them and degrade an `'any'` to `'mixed'`, so
|
|
74
|
-
* de-duplicating handlers that appear more than once in a chain is the
|
|
75
|
-
* caller's job.
|
|
49
|
+
* Folds one middleware's stamp into an accumulating aggregate. Mutates `into`
|
|
50
|
+
* and never `stamp`. Every call counts as an independent check, so folding the
|
|
51
|
+
* *same* stamp twice degrades an `'any'` to `'mixed'` — de-duplicating handlers
|
|
52
|
+
* that appear more than once in a chain is the caller's job.
|
|
76
53
|
*/
|
|
77
54
|
export declare function mergeCapabilities(into: MiddlewareCapabilities, stamp: MiddlewareCapabilities): void;
|
|
78
55
|
export declare function stampCapabilities(handler: MiddlewareHandler, capabilities: MiddlewareCapabilities): MiddlewareHandler;
|
|
@@ -1,40 +1,15 @@
|
|
|
1
1
|
import type { MiddlewareHandler } from 'hono';
|
|
2
2
|
export interface CorsOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Allowed origins. Default: none (same-origin policy applies).
|
|
5
|
-
* - A string: exact origin match (use '*' to allow all origins)
|
|
6
|
-
* - An array of strings: multiple allowed origins
|
|
7
|
-
* - A function: dynamic origin evaluation
|
|
8
|
-
*/
|
|
3
|
+
/** Allowed origins. Default: none, so the same-origin policy applies. */
|
|
9
4
|
origin?: string | string[] | ((origin: string, ctx: unknown) => string | undefined | null);
|
|
10
5
|
/** Allowed HTTP methods. Default: ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH', 'QUERY'] */
|
|
11
6
|
allowMethods?: string[];
|
|
12
|
-
/** Allowed request headers. */
|
|
13
7
|
allowHeaders?: string[];
|
|
14
|
-
/** Headers exposed to the browser. */
|
|
15
8
|
exposeHeaders?: string[];
|
|
16
|
-
/** Preflight cache
|
|
9
|
+
/** Preflight cache, in seconds. */
|
|
17
10
|
maxAge?: number;
|
|
18
|
-
/**
|
|
11
|
+
/** Cookies and Authorization headers. Default: false */
|
|
19
12
|
credentials?: boolean;
|
|
20
13
|
}
|
|
21
|
-
/**
|
|
22
|
-
* CORS middleware powered by Hono's built-in CORS support.
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* import { createCorsMiddleware } from '@guren/core'
|
|
27
|
-
*
|
|
28
|
-
* // Allow specific origins
|
|
29
|
-
* app.use('/api/*', createCorsMiddleware({
|
|
30
|
-
* origin: ['https://example.com', 'https://app.example.com'],
|
|
31
|
-
* credentials: true,
|
|
32
|
-
* }))
|
|
33
|
-
*
|
|
34
|
-
* // Dynamic origin
|
|
35
|
-
* app.use('/api/*', createCorsMiddleware({
|
|
36
|
-
* origin: (origin) => origin.endsWith('.example.com') ? origin : null,
|
|
37
|
-
* }))
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
14
|
+
/** CORS middleware powered by Hono's built-in CORS support. */
|
|
40
15
|
export declare function createCorsMiddleware(options?: CorsOptions): MiddlewareHandler;
|
|
@@ -21,7 +21,6 @@ export interface CspDirectives {
|
|
|
21
21
|
[directive: string]: string[] | boolean | undefined;
|
|
22
22
|
}
|
|
23
23
|
export interface CspOptions {
|
|
24
|
-
/** CSP directives configuration. */
|
|
25
24
|
directives?: CspDirectives;
|
|
26
25
|
/** Use Content-Security-Policy-Report-Only instead. Default: false */
|
|
27
26
|
reportOnly?: boolean;
|
|
@@ -31,29 +30,7 @@ export interface CspOptions {
|
|
|
31
30
|
useNonce?: boolean;
|
|
32
31
|
}
|
|
33
32
|
export declare const CSP_NONCE_KEY = "csp-nonce";
|
|
34
|
-
/**
|
|
35
|
-
* Retrieve the CSP nonce for the current request.
|
|
36
|
-
* Only available when `useNonce: true` is set.
|
|
37
|
-
*/
|
|
33
|
+
/** Throws unless the middleware was configured with `useNonce: true`. */
|
|
38
34
|
export declare function getCspNonce(ctx: Context): string;
|
|
39
|
-
/**
|
|
40
|
-
* Middleware that sets Content-Security-Policy headers.
|
|
41
|
-
*
|
|
42
|
-
* @example
|
|
43
|
-
* ```ts
|
|
44
|
-
* import { createCspMiddleware, getCspNonce } from '@guren/core'
|
|
45
|
-
*
|
|
46
|
-
* app.use('*', createCspMiddleware({
|
|
47
|
-
* directives: {
|
|
48
|
-
* defaultSrc: ["'self'"],
|
|
49
|
-
* scriptSrc: ["'self'", 'https://cdn.example.com'],
|
|
50
|
-
* styleSrc: ["'self'", "'unsafe-inline'"],
|
|
51
|
-
* imgSrc: ["'self'", 'data:', 'https:'],
|
|
52
|
-
* objectSrc: ["'none'"],
|
|
53
|
-
* },
|
|
54
|
-
* useNonce: true,
|
|
55
|
-
* reportUri: '/csp-report',
|
|
56
|
-
* }))
|
|
57
|
-
* ```
|
|
58
|
-
*/
|
|
35
|
+
/** Middleware that sets Content-Security-Policy headers. */
|
|
59
36
|
export declare function createCspMiddleware(options?: CspOptions): MiddlewareHandler;
|
|
@@ -5,31 +5,17 @@ export declare const XSRF_HEADER_NAME = "X-XSRF-TOKEN";
|
|
|
5
5
|
export declare const XSRF_COOKIE_NAME = "XSRF-TOKEN";
|
|
6
6
|
export declare const CSRF_FORM_FIELD = "_token";
|
|
7
7
|
export interface CsrfOptions {
|
|
8
|
-
/**
|
|
9
|
-
* Routes to exclude from CSRF protection.
|
|
10
|
-
* Supports exact paths ('/api/webhook') or patterns ('/api/*').
|
|
11
|
-
*/
|
|
8
|
+
/** Exact paths ('/api/webhook') or patterns ('/api/*'). */
|
|
12
9
|
exclude?: string[];
|
|
13
|
-
/**
|
|
14
|
-
* Custom error handler when CSRF validation fails.
|
|
15
|
-
* Defaults to returning a 403 JSON response.
|
|
16
|
-
*/
|
|
10
|
+
/** Defaults to a 403 JSON response. */
|
|
17
11
|
onError?: (ctx: Context) => Response | Promise<Response>;
|
|
18
|
-
/**
|
|
19
|
-
* HTTP methods that require CSRF token validation.
|
|
20
|
-
* Defaults to ['POST', 'PUT', 'PATCH', 'DELETE'].
|
|
21
|
-
*/
|
|
12
|
+
/** Defaults to ['POST', 'PUT', 'PATCH', 'DELETE']. */
|
|
22
13
|
methods?: string[];
|
|
23
14
|
/**
|
|
24
|
-
* Set the
|
|
25
|
-
*
|
|
26
|
-
* and send it back as the `X-XSRF-TOKEN` header.
|
|
27
|
-
* Defaults to true.
|
|
15
|
+
* Set the token as an `XSRF-TOKEN` cookie, which Axios/Inertia read back into
|
|
16
|
+
* the `X-XSRF-TOKEN` header. Defaults to true.
|
|
28
17
|
*/
|
|
29
18
|
cookie?: boolean;
|
|
30
|
-
/**
|
|
31
|
-
* Cookie options when `cookie` is enabled.
|
|
32
|
-
*/
|
|
33
19
|
cookieOptions?: {
|
|
34
20
|
path?: string;
|
|
35
21
|
secure?: boolean;
|
|
@@ -37,88 +23,27 @@ export interface CsrfOptions {
|
|
|
37
23
|
};
|
|
38
24
|
}
|
|
39
25
|
/**
|
|
40
|
-
*
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
* token that is still valid for this request's mode is reused; otherwise a
|
|
46
|
-
* fresh token is minted and set on the response by the middleware.
|
|
47
|
-
*
|
|
48
|
-
* The answer tracks the session as it stands *at the moment of the call*,
|
|
49
|
-
* because a handler can change it: log a user in and the correct token stops
|
|
50
|
-
* being the guest one it would have got a line earlier. A token cached from
|
|
51
|
-
* before that point would be rendered into the response body while the
|
|
52
|
-
* response cookie carried a session-bound one, and `verifyCsrfToken` would
|
|
53
|
-
* then reject the form on submit. So the per-request cache is keyed by the
|
|
54
|
-
* mode it was issued for, and re-issues when the mode moves — which also
|
|
55
|
-
* makes re-reads free, since the common case is that nothing changed.
|
|
26
|
+
* The request's CSRF token: bound to the session when a stable one exists,
|
|
27
|
+
* otherwise a stateless signed double-submit token. Nothing is stored
|
|
28
|
+
* server-side. The per-request cache is keyed by the *mode* it was issued for,
|
|
29
|
+
* because a handler can log a user in mid-request — a token cached from before
|
|
30
|
+
* that would be rendered into the body while the cookie carried a bound one.
|
|
56
31
|
*/
|
|
57
32
|
export declare function getCsrfToken(ctx: Context): string;
|
|
58
|
-
/**
|
|
59
|
-
* Generate an HTML hidden input field containing the CSRF token.
|
|
60
|
-
*/
|
|
61
33
|
export declare function csrfField(ctx: Context): string;
|
|
62
34
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
*
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
* - **Session-bound** (request has a session; token must carry a matching
|
|
69
|
-
* `sid`): immune to cookie injection — a sibling-subdomain attacker can
|
|
70
|
-
* plant a cookie but cannot know the victim's session id. A stateless
|
|
71
|
-
* token is rejected here, which is the point: anyone can mint one.
|
|
72
|
-
* - **Stateless** (request has no session, so no `sid`): the token must match the `XSRF-TOKEN`
|
|
73
|
-
* cookie (double-submit). Guests hold no authenticated state to protect.
|
|
74
|
-
*
|
|
75
|
-
* Legacy fallback: tokens stored in sessions by earlier releases keep
|
|
76
|
-
* verifying against the session until those sessions expire. Remove this
|
|
77
|
-
* branch once all pre-upgrade sessions have aged out (a major release).
|
|
35
|
+
* The token must carry a valid app-key signature, and be in the mode the
|
|
36
|
+
* *request* fixes: session-bound needs a matching `sid` (a sibling-subdomain
|
|
37
|
+
* attacker can plant a cookie but cannot know the session id; a stateless
|
|
38
|
+
* token, which anyone can mint, is rejected); stateless must match the
|
|
39
|
+
* `XSRF-TOKEN` cookie. TODO: drop the legacy session-stored fallback in a major release.
|
|
78
40
|
*/
|
|
79
41
|
export declare function verifyCsrfToken(ctx: Context, token: string | undefined): boolean;
|
|
80
42
|
/**
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* guests it is a stateless double-submit token. Nothing is stored
|
|
87
|
-
* server-side, so anonymous traffic costs no session writes and session
|
|
88
|
-
* middleware is optional.
|
|
89
|
-
* - Validates the token for state-changing HTTP methods (POST, PUT, PATCH,
|
|
90
|
-
* DELETE): always requires a valid app-key signature, then the bound
|
|
91
|
-
* session id or (guest) the cookie match.
|
|
92
|
-
* - Supports token submission via form field (_token) or header (X-CSRF-TOKEN)
|
|
93
|
-
* - Keeps verifying tokens stored in sessions by earlier releases until
|
|
94
|
-
* those sessions expire
|
|
95
|
-
* - Exempts the dev-only MCP endpoint while it is mounted, since agent
|
|
96
|
-
* clients cannot fetch a token first (it guards local-only access instead)
|
|
97
|
-
* - Skips verification for `Authorization: Bearer` requests that carry no
|
|
98
|
-
* cookies (RFC 0016) — token clients authenticate per request and hold no
|
|
99
|
-
* cookie ambient authority for CSRF to defend
|
|
100
|
-
*
|
|
101
|
-
* `cookie: false` disables the `XSRF-TOKEN` cookie for apps that deliver the
|
|
102
|
-
* token themselves (meta tag / form field). Session-bound tokens still
|
|
103
|
-
* verify without the cookie; guest (stateless) tokens require the cookie, so
|
|
104
|
-
* disable it only for session-authenticated flows.
|
|
105
|
-
*
|
|
106
|
-
* **Mount it directly inside the session middleware.** The response cookie is
|
|
107
|
-
* settled once the handler returns, reading the session id as it stands then.
|
|
108
|
-
* Middleware layered *between* the two that mutates the session after its own
|
|
109
|
-
* `await next()` — regenerating or invalidating it — moves the id after this
|
|
110
|
-
* has already committed to a token, and the next mutation is rejected. The
|
|
111
|
-
* automatic registration in `AuthServiceProvider` mounts them adjacently;
|
|
112
|
-
* hand-composed chains have to keep that property.
|
|
113
|
-
*
|
|
114
|
-
* @example
|
|
115
|
-
* ```ts
|
|
116
|
-
* import { createCsrfMiddleware } from '@guren/server'
|
|
117
|
-
*
|
|
118
|
-
* app.use(createSessionMiddleware())
|
|
119
|
-
* app.use(createCsrfMiddleware({
|
|
120
|
-
* exclude: ['/api/webhooks/*']
|
|
121
|
-
* }))
|
|
122
|
-
* ```
|
|
43
|
+
* Issues a signed `XSRF-TOKEN` on safe requests and verifies it on
|
|
44
|
+
* state-changing ones (`_token` field, `X-CSRF-TOKEN` / `X-XSRF-TOKEN` header).
|
|
45
|
+
* `cookie: false` suits session-authenticated flows only; guest tokens need the
|
|
46
|
+
* cookie. **Mount directly inside the session middleware:** anything between
|
|
47
|
+
* the two that mutates the session after its own `await next()` moves the id after this has committed.
|
|
123
48
|
*/
|
|
124
49
|
export declare function createCsrfMiddleware(options?: CsrfOptions): MiddlewareHandler;
|
|
@@ -7,15 +7,9 @@ export type TranslatorBinding = {
|
|
|
7
7
|
t: Translator['t'];
|
|
8
8
|
tc: Translator['tc'];
|
|
9
9
|
};
|
|
10
|
-
/**
|
|
11
|
-
* Read the request locale resolved by {@link detectLocaleMiddleware} (or any
|
|
12
|
-
* middleware that sets the `locale` context variable).
|
|
13
|
-
*/
|
|
10
|
+
/** Reads the `locale` context variable, whoever set it. */
|
|
14
11
|
export declare function getRequestLocale(c: Context): string | undefined;
|
|
15
|
-
/**
|
|
16
|
-
* Read the request-scoped `t`/`tc` translator bound by
|
|
17
|
-
* {@link detectLocaleMiddleware}, when present.
|
|
18
|
-
*/
|
|
12
|
+
/** The request-scoped translator bound by {@link detectLocaleMiddleware}. */
|
|
19
13
|
export declare function getRequestTranslator(c: Context): TranslatorBinding | undefined;
|
|
20
14
|
export type LocaleSource = 'query' | 'cookie' | 'header';
|
|
21
15
|
/** Context variables set by {@link detectLocaleMiddleware}, for typing Hono apps. */
|
|
@@ -36,29 +30,15 @@ export interface DetectLocaleOptions {
|
|
|
36
30
|
/** Cookie to read (defaults to `locale`). */
|
|
37
31
|
cookieName?: string;
|
|
38
32
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* pass a manager explicitly (e.g. `app.container.make('i18n')`), or `false`
|
|
42
|
-
* to skip the translator binding entirely.
|
|
33
|
+
* Manager backing the request-scoped `t`/`tc` helpers. Defaults to the
|
|
34
|
+
* global one registered via `setI18n()`; `false` skips the binding.
|
|
43
35
|
*/
|
|
44
36
|
i18n?: I18nManager | false;
|
|
45
37
|
}
|
|
46
38
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* the `
|
|
50
|
-
*
|
|
51
|
-
* The result is stored as the `locale` context variable, which Inertia
|
|
52
|
-
* responses pick up for the root `<html lang>` attribute. When an i18n manager
|
|
53
|
-
* is available (see the `i18n` option), request-scoped `t`/`tc` translator
|
|
54
|
-
* helpers are attached as well.
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* import { detectLocaleMiddleware } from '@guren/core'
|
|
59
|
-
*
|
|
60
|
-
* app.use('*', detectLocaleMiddleware({ supported: ['en', 'ja'] }))
|
|
61
|
-
* ```
|
|
39
|
+
* Resolves the request locale from the query string, a cookie, or
|
|
40
|
+
* `Accept-Language`, restricted to the `supported` allowlist, and stores it as
|
|
41
|
+
* the `locale` context variable that Inertia reads for `<html lang>`.
|
|
62
42
|
*/
|
|
63
43
|
export declare function detectLocaleMiddleware(options: DetectLocaleOptions): import("hono").MiddlewareHandler<{
|
|
64
44
|
Variables: DetectLocaleVariables;
|
|
@@ -1,34 +1,16 @@
|
|
|
1
1
|
import type { MiddlewareHandler } from 'hono';
|
|
2
2
|
export interface ForceHttpsOptions {
|
|
3
|
-
/**
|
|
4
|
-
* HSTS max-age in seconds. Default: 31536000 (1 year).
|
|
5
|
-
*/
|
|
3
|
+
/** Seconds. Default: 31536000 (1 year). */
|
|
6
4
|
hstsMaxAge?: number;
|
|
7
|
-
/**
|
|
8
|
-
* Include subdomains in HSTS. Default: true.
|
|
9
|
-
*/
|
|
5
|
+
/** Default: true. */
|
|
10
6
|
hstsIncludeSubDomains?: boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Enable HSTS preload. Default: false.
|
|
13
|
-
*/
|
|
7
|
+
/** Default: false. */
|
|
14
8
|
hstsPreload?: boolean;
|
|
15
|
-
/**
|
|
16
|
-
* Paths to exclude from HTTPS redirect (e.g., health checks).
|
|
17
|
-
*/
|
|
9
|
+
/** Paths exempt from the redirect; a trailing `*` matches a prefix. */
|
|
18
10
|
exclude?: string[];
|
|
19
11
|
}
|
|
20
12
|
/**
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* ```ts
|
|
26
|
-
* import { createForceHttpsMiddleware } from '@guren/core'
|
|
27
|
-
*
|
|
28
|
-
* // In production only
|
|
29
|
-
* if (process.env.NODE_ENV === 'production') {
|
|
30
|
-
* app.use('*', createForceHttpsMiddleware())
|
|
31
|
-
* }
|
|
32
|
-
* ```
|
|
13
|
+
* Redirects HTTP to HTTPS and sets Strict-Transport-Security. Equivalent to
|
|
14
|
+
* Rails' `force_ssl`.
|
|
33
15
|
*/
|
|
34
16
|
export declare function createForceHttpsMiddleware(options?: ForceHttpsOptions): MiddlewareHandler;
|
|
@@ -8,17 +8,7 @@ export interface HostAuthorizationOptions {
|
|
|
8
8
|
onError?: (ctx: Context) => Response | Promise<Response>;
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* @example
|
|
15
|
-
* ```ts
|
|
16
|
-
* import { createHostAuthorizationMiddleware } from '@guren/core'
|
|
17
|
-
*
|
|
18
|
-
* app.use('*', createHostAuthorizationMiddleware({
|
|
19
|
-
* allowedHosts: ['example.com', '*.example.com', 'localhost:3000'],
|
|
20
|
-
* exclude: ['/healthcheck'],
|
|
21
|
-
* }))
|
|
22
|
-
* ```
|
|
11
|
+
* Validates the Host header against an allowed list, guarding against DNS
|
|
12
|
+
* rebinding and host header attacks.
|
|
23
13
|
*/
|
|
24
14
|
export declare function createHostAuthorizationMiddleware(options: HostAuthorizationOptions): MiddlewareHandler;
|
|
@@ -1,35 +1,20 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Loopback-only access guard shared by the dev-only framework endpoints
|
|
3
|
-
* (`/_guren/mcp`, `/_guren/docs`).
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* authorization does not help, and a client that sends no `Origin` is
|
|
11
|
-
* otherwise indistinguishable from a local process.
|
|
12
|
-
*
|
|
13
|
-
* The guard fails closed. A request is served only once the runtime has
|
|
14
|
-
* reported a loopback peer; if it reports no peer at all, the request is
|
|
15
|
-
* denied rather than waved through, because "no `Origin` and no peer" is
|
|
16
|
-
* exactly the shape of a remote `curl`. Runtimes that cannot report a peer
|
|
17
|
-
* (Node, or any host calling `app.fetch()` directly instead of
|
|
18
|
-
* `Application.listen()`) need `GUREN_ALLOW_UNVERIFIED_PEER=1`, which the
|
|
19
|
-
* denial names.
|
|
3
|
+
* (`/_guren/mcp`, `/_guren/docs`). Two classes of caller are stopped (see
|
|
4
|
+
* `.claude/rules/common-pitfalls.md`): browser pages, rejected unless `Origin`
|
|
5
|
+
* is loopback (also defeats DNS rebinding), and non-browser clients, rejected
|
|
6
|
+
* unless the socket peer is loopback — templates bind `0.0.0.0`, `Host` is
|
|
7
|
+
* trivially forged, and a client sending no `Origin` looks like a local process.
|
|
8
|
+
* Fails closed: no reported peer is denied ("no `Origin`, no peer" is a remote
|
|
9
|
+
* `curl`); peer-less runtimes (Node, `app.fetch()`) need `GUREN_ALLOW_UNVERIFIED_PEER=1`.
|
|
20
10
|
*/
|
|
21
11
|
import type { MiddlewareHandler } from 'hono';
|
|
22
12
|
/**
|
|
23
13
|
* Whether an `Origin` header value belongs to the developer's own machine.
|
|
24
|
-
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* domain resolves to 127.0.0.1 so the browser skips preflight.
|
|
29
|
-
*
|
|
30
|
-
* This is a *negative* filter only. A loopback `Origin` is never proof that
|
|
31
|
-
* the caller is local: browsers set the header honestly, but any other
|
|
32
|
-
* client sets it with one flag. Never use it to satisfy the peer check.
|
|
14
|
+
* Only a web page's request carries one; restricting it to loopback blocks
|
|
15
|
+
* cross-site requests and DNS rebinding (an attacker's domain resolving to
|
|
16
|
+
* 127.0.0.1 so the browser skips preflight). A *negative* filter only: any
|
|
17
|
+
* non-browser client sets the header with one flag, so never use it to satisfy the peer check.
|
|
33
18
|
*/
|
|
34
19
|
export declare function isLoopbackOrigin(origin: string): boolean;
|
|
35
20
|
/**
|
|
@@ -40,12 +25,9 @@ export declare function isLoopbackOrigin(origin: string): boolean;
|
|
|
40
25
|
*/
|
|
41
26
|
export declare function isLoopbackAddress(address: string): boolean;
|
|
42
27
|
/**
|
|
43
|
-
* Restricts an endpoint to the developer's own machine. `resource` names
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
* a peer that is present and not loopback is a remote caller, while a peer
|
|
48
|
-
* the runtime never reported is a deployment the guard cannot vouch for —
|
|
49
|
-
* the developer needs to know which one they are looking at.
|
|
28
|
+
* Restricts an endpoint to the developer's own machine. `resource` names the
|
|
29
|
+
* endpoint in the 403 body (e.g. "the MCP endpoint"). The two denials say
|
|
30
|
+
* different things on purpose: a present non-loopback peer is a remote caller,
|
|
31
|
+
* a peer the runtime never reported is a deployment the guard cannot vouch for.
|
|
50
32
|
*/
|
|
51
33
|
export declare function createLoopbackGuard(resource: string): MiddlewareHandler;
|