@guren/server 1.4.0 → 2.0.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/{AuthManager-C84xF5ks.d.ts → AuthManager-DBP4KYsx.d.ts} +1 -1
- package/dist/ConsoleKernel-DlK9j2Lu.d.ts +101 -0
- package/dist/DocsViewerServiceProvider-D7RGJPGM.js +75 -0
- package/dist/{I18nManager-CmUqj6bU.d.ts → I18nManager-BiSoczfV.d.ts} +1 -1
- package/dist/McpServiceProvider-7BB5FPF3.js +8 -0
- package/dist/auth/index.d.ts +39 -29
- package/dist/auth/index.js +2 -2
- package/dist/broadcasting/index.js +2 -2
- package/dist/cache/index.js +2 -2
- package/dist/chunk-2V3YID4H.js +20 -0
- package/dist/{chunk-JIT7QVMJ.js → chunk-4DW4GRWF.js} +3 -3
- package/dist/{chunk-R2TCP7D7.js → chunk-6J6B5KOB.js} +18 -2
- package/dist/chunk-AZOYI43J.js +18 -0
- package/dist/{chunk-DCYKSYAT.js → chunk-B5E5VBDI.js} +54 -2
- package/dist/{chunk-NYQGAWDN.js → chunk-BZMZEFRG.js} +7 -11
- package/dist/{chunk-4SBGSJNT.js → chunk-CWI4AJ47.js} +2 -1
- package/dist/{chunk-NQCZQAJL.js → chunk-DSDX3ASM.js} +21 -2
- package/dist/{chunk-MC752CQT.js → chunk-EI5GYMAT.js} +2 -1
- package/dist/{chunk-AUXQISW5.js → chunk-HONCNQXZ.js} +38 -5
- package/dist/{chunk-CSRQTEQA.js → chunk-HWEWL6TE.js} +6 -1
- package/dist/chunk-JBG4AR24.js +18 -0
- package/dist/{chunk-EDRGAM6G.js → chunk-K6CUBJX6.js} +11 -16
- package/dist/{chunk-WJJ5CTNI.js → chunk-KTNJG7R7.js} +6 -2
- package/dist/{chunk-74HTZG3V.js → chunk-LAJQCSSF.js} +24 -0
- package/dist/{chunk-H32L2NE3.js → chunk-LVJCZCAV.js} +20 -13
- package/dist/{chunk-CSDKWLFD.js → chunk-N7PLD7MB.js} +120 -43
- package/dist/{chunk-ONSDE37A.js → chunk-SFQP6O52.js} +1 -0
- package/dist/{chunk-XMQZENBP.js → chunk-TVY72CLV.js} +3 -1
- package/dist/chunk-WIXGT4TN.js +18 -0
- package/dist/{email-verification-H_WlpsVH.d.ts → email-verification-D8N7P6Pu.d.ts} +1 -1
- package/dist/encryption/index.js +2 -2
- package/dist/events/index.js +1 -1
- package/dist/i18n/index.d.ts +2 -2
- package/dist/index.d.ts +348 -330
- package/dist/index.js +332 -110
- package/dist/lambda/index.d.ts +5 -5
- package/dist/lambda/index.js +1 -1
- package/dist/mail/index.js +4 -3
- package/dist/mcp/index.d.ts +14 -4
- package/dist/mcp/index.js +3 -2
- package/dist/notifications/index.d.ts +55 -6
- package/dist/notifications/index.js +12 -3
- package/dist/queue/index.d.ts +5 -5
- package/dist/queue/index.js +4 -2
- package/dist/redis/index.d.ts +4 -4
- package/dist/redis/index.js +7 -0
- package/dist/runtime/index.d.ts +5 -5
- package/dist/runtime/index.js +24 -9
- package/dist/scheduling/index.js +2 -2
- package/dist/storage/index.js +2 -1
- package/dist/{Application-BvBqgc2k.d.ts → validation-CDR7lRE8.d.ts} +873 -654
- package/package.json +3 -3
- package/dist/ConsoleKernel-Dw9X9qZY.d.ts +0 -207
- package/dist/McpServiceProvider-TZWQWXCT.js +0 -7
- package/dist/{api-token-COQHXyM_.d.ts → api-token-D24VPr_E.d.ts} +101 -101
- package/dist/{client-BQwF2b9Y.d.ts → rate-limit-D9J2b4S1.d.ts} +36 -36
package/dist/index.d.ts
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { E as ErrorResponse,
|
|
2
|
-
export { A as Application,
|
|
1
|
+
import { E as ErrorResponse, S as ServiceProvider, a as Container, e as ServiceProviderConstructor, I as InputInterface, P as ParsedSignature, f as OptionDefinition, g as CommandInstance, O as OutputInterface, h as ServiceBindings, Q as QueueManager, N as NotificationManager } from './validation-CDR7lRE8.js';
|
|
2
|
+
export { A as Application, i as ApplicationListenOptions, j as ApplicationOptions, k as ArgumentDefinition, m as AuthPayload, n as AuthPluginOptions, o as CSRF_FORM_FIELD, p as CSRF_HEADER_NAME, q as CSRF_TOKEN_KEY, C as CommandClass, b as ConsoleKernelOptions, r as ContainerProvider, t as ContextualBinding, u as ContextualBindingBuilder, v as ContextualNeedsBuilder, w as Controller, x as ControllerInertiaProps, y as CsrfOptions, z as DatabaseChannelOptions, B as DatabaseNotification, F as ExceptionClass, H as ExceptionHandler, J as ExceptionHandlerOptions, K as ExceptionRenderer, L as ExceptionReporter, M as FailedJob, R as GurenModule, T as HostAuthorizationOptions, U as HstsOptions, V as InertiaDocumentContext, W as InertiaDocumentOptions, X as InertiaOptions, Y as InertiaPagePayload, Z as InertiaResponse, _ as InertiaSharedProps, $ as InertiaSsrContext, a0 as InertiaSsrOptions, a1 as InertiaSsrRenderer, a2 as InertiaSsrResult, a3 as InferInertiaProps, a4 as Job, a5 as JobClass, a6 as JobFailureHandler, a7 as JobHandler, a8 as JobOptions, a9 as ModuleDefinition, aa as Notifiable, ab as Notification, ac as NotificationAttachment, ad as NotificationChannel, ae as NotificationChannelFactory, af as NotificationClass, ag as NotificationMailMessage, ah as NotificationManagerOptions, ai as ProgressInterface, aj as PromptInterface, ak as ProviderManager, al as QueueConfig, am as QueueDriver, an as QueueDriverFactory, ao as QueuedJob, ap as RendererRegistration, aq as ResolvedSharedInertiaProps, ar as ResourceRouteOptions, as as RouteBuilder, at as RouteContractOptions, au as RouteDefinition, av as RouteOpenApiMetadata, aw as RouteResourceAction, ax as Router, ay as ScheduledCommand, az as SecurityHeadersOptions, aA as SentNotification, aB as ServiceBinding, aC as ServiceClass, aD as ServiceFactory, aE as ServiceProviderClass, aF as ServiceProviderOptions, aG as SharedInertiaPropsResolver, aH as SlackAttachment, aI as SlackBlock, aJ as SlackMessage, aK as VALIDATED_DATA_KEY, aL as ValidateRequestOptions, aM as ValidationSchema, aN as WorkerOptions, aO as abort, aP as abortIf, aQ as abortUnless, aR as clearJobRegistry, aS as createApp, aT as createContainer, aU as createCsrfMiddleware, aV as createExceptionHandler, aW as createHostAuthorizationMiddleware, aX as createNotificationManager, aY as createQueueManager, aZ as createSecurityHeaders, a_ as csrfField, a$ as defineModule, b0 as formatValidationErrors, b1 as getContainer, b2 as getCsrfToken, b3 as getExceptionHandler, b4 as getInertiaSharedPropsResolver, b5 as getJob, b6 as getNotificationManager, b7 as getQueueDriver, b8 as getRegisteredJobs, b9 as getValidatedData, ba as inertia, bb as mountModuleRoutes, bc as parseRequestPayload, bd as registerJob, be as resolve, bf as resolveJobName, bg as setContainer, bh as setExceptionHandler, bi as setInertiaDocument, bj as setInertiaSharedProps, bk as setInertiaSsrRenderer, bl as setNotificationManager, bm as setQueueDriver, bn as shareInertiaProps, bo as validate, bp as validateRequest, bq as validateRequestWith, br as validateSafe, bs as verifyCsrfToken } from './validation-CDR7lRE8.js';
|
|
3
3
|
import * as hono from 'hono';
|
|
4
4
|
import { Context, MiddlewareHandler } from 'hono';
|
|
5
5
|
export { Context } from 'hono';
|
|
6
|
-
import { P as PasswordHasher } from './AuthManager-
|
|
7
|
-
export { A as AuthManager, B as BaseUserProvider, M as ModelUserProvider } from './AuthManager-
|
|
6
|
+
import { P as PasswordHasher } from './AuthManager-DBP4KYsx.js';
|
|
7
|
+
export { A as AuthManager, B as BaseUserProvider, M as ModelUserProvider } from './AuthManager-DBP4KYsx.js';
|
|
8
8
|
export { AuthenticatableModel, NodeHasher, ScryptHasher, SessionGuard } from './auth/index.js';
|
|
9
|
-
export { b as EmailVerificationConfig, a as EmailVerificationToken, c as EmailVerificationTokenResult, E as EmailVerificationTokenStore, M as MemoryEmailVerificationStore, d as MemoryPasswordResetStore, e as PasswordResetConfig, f as PasswordResetTokenResult, P as PasswordResetTokenStore, g as buildPasswordResetUrl, h as buildVerificationUrl, i as completeEmailVerification, j as completePasswordReset, k as createEmailVerificationToken, l as createPasswordResetToken, m as isEmailVerified, p as parsePasswordResetUrl, n as parseVerificationUrl, r as requireVerifiedEmail, v as verifyEmailToken, o as verifyPasswordResetToken } from './email-verification-
|
|
10
|
-
import { g as AuthContext } from './api-token-
|
|
11
|
-
export { m as API_TOKEN_KEY, j as ApiToken, i as ApiTokenStore, a as AuthCredentials, c as AuthManagerOptions, A as Authenticatable, B as BearerTokenMiddlewareOptions, n as CreateApiTokenOptions, o as CreateApiTokenResult, D as DefaultSanitizedKeys, e as Guard, d as GuardContext, G as GuardFactory, M as MemoryApiTokenStore, p as MemoryOAuthStateStore, q as MemorySessionStore, r as OAuthAuthorizeOptions, s as OAuthCallbackPayload, t as OAuthFallbackEmail, l as OAuthManager, u as OAuthManagerOptions, v as OAuthProviderConfig, w as OAuthProviderFactoryInput, x as OAuthStateConfig, k as OAuthStatePayload, O as OAuthStateStore, y as OAuthTokenResult, z as OAuthUserProfile, P as ProviderFactory, E as Sanitized, F as Session, h as SessionData, S as SessionStore, U as UserProvider, H as buildOAuthAuthorizeUrl, I as buildOAuthRedirectUrl, J as createApiToken, K as createBearerTokenMiddleware, L as createDiscordOAuthProviderConfig, N as createGitHubOAuthProviderConfig, Q as createGoogleOAuthProviderConfig, R as createOAuthManager, T as createOAuthState, V as createSessionMiddleware, W as exchangeOAuthCode, X as fetchOAuthUserProfile, Y as getApiToken, Z as getApiTokenOrFail, _ as getSessionFromContext, $ as getUserApiTokens, a0 as parseApiToken, a1 as parseOAuthRedirectUrl, a2 as revokeAllApiTokens, a3 as revokeApiToken, a4 as sanitizeOAuthRedirect, a5 as tokenCan, a6 as tokenCanAll, a7 as tokenCanAny, a8 as verifyApiToken, a9 as verifyOAuthState } from './api-token-
|
|
9
|
+
export { b as EmailVerificationConfig, a as EmailVerificationToken, c as EmailVerificationTokenResult, E as EmailVerificationTokenStore, M as MemoryEmailVerificationStore, d as MemoryPasswordResetStore, e as PasswordResetConfig, f as PasswordResetTokenResult, P as PasswordResetTokenStore, g as buildPasswordResetUrl, h as buildVerificationUrl, i as completeEmailVerification, j as completePasswordReset, k as createEmailVerificationToken, l as createPasswordResetToken, m as isEmailVerified, p as parsePasswordResetUrl, n as parseVerificationUrl, r as requireVerifiedEmail, v as verifyEmailToken, o as verifyPasswordResetToken } from './email-verification-D8N7P6Pu.js';
|
|
10
|
+
import { g as AuthContext } from './api-token-D24VPr_E.js';
|
|
11
|
+
export { m as API_TOKEN_KEY, j as ApiToken, i as ApiTokenStore, a as AuthCredentials, c as AuthManagerOptions, A as Authenticatable, B as BearerTokenMiddlewareOptions, n as CreateApiTokenOptions, o as CreateApiTokenResult, D as DefaultSanitizedKeys, e as Guard, d as GuardContext, G as GuardFactory, M as MemoryApiTokenStore, p as MemoryOAuthStateStore, q as MemorySessionStore, r as OAuthAuthorizeOptions, s as OAuthCallbackPayload, t as OAuthFallbackEmail, l as OAuthManager, u as OAuthManagerOptions, v as OAuthProviderConfig, w as OAuthProviderFactoryInput, x as OAuthStateConfig, k as OAuthStatePayload, O as OAuthStateStore, y as OAuthTokenResult, z as OAuthUserProfile, P as ProviderFactory, E as Sanitized, F as Session, h as SessionData, S as SessionStore, U as UserProvider, H as buildOAuthAuthorizeUrl, I as buildOAuthRedirectUrl, J as createApiToken, K as createBearerTokenMiddleware, L as createDiscordOAuthProviderConfig, N as createGitHubOAuthProviderConfig, Q as createGoogleOAuthProviderConfig, R as createOAuthManager, T as createOAuthState, V as createSessionMiddleware, W as exchangeOAuthCode, X as fetchOAuthUserProfile, Y as getApiToken, Z as getApiTokenOrFail, _ as getSessionFromContext, $ as getUserApiTokens, a0 as parseApiToken, a1 as parseOAuthRedirectUrl, a2 as revokeAllApiTokens, a3 as revokeApiToken, a4 as sanitizeOAuthRedirect, a5 as tokenCan, a6 as tokenCanAll, a7 as tokenCanAny, a8 as verifyApiToken, a9 as verifyOAuthState } from './api-token-D24VPr_E.js';
|
|
12
12
|
export { M as Middleware, d as defineMiddleware, j as jsonResponse } from './index-9_Jzj5jo.js';
|
|
13
13
|
import { E as EventManager } from './EventManager-CmIoLt7r.js';
|
|
14
14
|
export { a as Event, b as EventClass, c as EventListener, d as EventSubscription, L as ListenerOptions, R as RegisteredListener, e as createEventManager } from './EventManager-CmIoLt7r.js';
|
|
@@ -29,23 +29,22 @@ export { getNextOccurrence, getNextOccurrences, isDue, isDueInTimezone, matchesC
|
|
|
29
29
|
import { L as LogManager } from './LogManager-7mxnkaPM.js';
|
|
30
30
|
export { C as ConsoleChannelConfig, D as DailyFileChannelConfig, F as FileChannelConfig, a as LOG_LEVEL_PRIORITY, b as LogChannel, c as LogChannelConfig, d as LogChannelFactory, e as LogConfig, f as LogContext, g as LogEntry, h as LogFormatter, i as LogLevel, j as Logger, k as LoggerOptions, S as StackChannelConfig, l as createLogManager, m as filterSensitiveData, n as getLogManager, s as setLogManager } from './LogManager-7mxnkaPM.js';
|
|
31
31
|
export { ConsoleChannel, DailyFileChannel, FileChannel } from './logging/index.js';
|
|
32
|
-
import { I as I18nManager,
|
|
33
|
-
export { a as I18nConfig, P as PluralizationRule, R as ReplacementValues,
|
|
32
|
+
import { I as I18nManager, d as Translator } from './I18nManager-BiSoczfV.js';
|
|
33
|
+
export { a as I18nConfig, P as PluralizationRule, R as ReplacementValues, T as TranslationLoader, b as TranslationLoaderFactory, c as TranslationMessages, e as TranslatorOptions, f as createI18n, g as getI18n, s as setI18n, t, h as tc } from './I18nManager-BiSoczfV.js';
|
|
34
34
|
export { JsonLoader, MemoryLoader, getPluralizationRule, pluralizationRules, selectPluralForm } from './i18n/index.js';
|
|
35
35
|
export { C as CheckResult, a as HealthCheck, b as HealthCheckOptions, H as HealthManager, c as HealthMiddlewareOptions, d as HealthReport, e as HealthStatus, f as createHealthManager } from './HealthManager-DUyMIzsZ.js';
|
|
36
36
|
export { CacheCheck, CacheCheckOptions, CacheStoreInterface, CustomCheck, CustomCheckCallback, DatabaseCheck, DatabaseCheckOptions, DatabaseConnection, MemoryCheck, MemoryCheckOptions, RedisCheck, RedisCheckOptions, RedisClient, StorageCheck, StorageCheckOptions, StorageDriverInterface, customCheck } from './health/index.js';
|
|
37
|
-
export { DatabaseChannel, MailChannel, MailChannelOptions, MemoryChannel, SlackChannel, SlackChannelOptions } from './notifications/index.js';
|
|
37
|
+
export { DatabaseChannel, MailChannel, MailChannelOptions, MemoryChannel, NotificationConstructor, SlackChannel, SlackChannelOptions, clearNotificationRegistry, getNotification, registerNotification, resolveNotifiableType } from './notifications/index.js';
|
|
38
38
|
import { B as BroadcastManager } from './BroadcastManager-D8KoJxiV.js';
|
|
39
39
|
export { A as AuthMiddlewareOptions, a as BroadcastDriver, b as BroadcastDriverFactory, c as BroadcastEvent, d as BroadcastManagerOptions, e as BroadcastableEvent, C as Channel, f as ChannelAuthorizer, g as ChannelRegistration, P as PresenceBroadcastDriver, h as PresenceChannel, i as PresenceChannelAuthorizer, j as PresenceMember, k as PrivateChannel, S as SSEClient, l as SSEMiddlewareOptions, W as WebSocketClient, m as createBroadcastManager, n as getBroadcastManager, s as setBroadcastManager } from './BroadcastManager-D8KoJxiV.js';
|
|
40
40
|
export { RedisClient as BroadcastRedisClient, RedisDriverOptions as BroadcastRedisDriverOptions, MemoryDriver as MemoryBroadcastDriver, RedisDriver as RedisBroadcastDriver, createTypedBroadcaster } from './broadcasting/index.js';
|
|
41
|
-
import { I as InputInterface, P as ParsedSignature, O as OptionDefinition, a as CommandInstance, b as OutputInterface } from './ConsoleKernel-Dw9X9qZY.js';
|
|
42
|
-
export { A as ArgumentDefinition, c as CommandClass, C as ConsoleKernel, d as ConsoleKernelOptions, e as ProgressInterface, f as PromptInterface, S as ScheduledCommand, g as createConsoleKernel } from './ConsoleKernel-Dw9X9qZY.js';
|
|
43
41
|
import * as readline from 'readline';
|
|
42
|
+
export { C as ConsoleKernel, c as createConsoleKernel } from './ConsoleKernel-DlK9j2Lu.js';
|
|
44
43
|
export { R as AuthResponse, A as AuthUser, a as AuthorizationResponse, b as AuthorizeOptions, G as Gate, c as GateCallback, d as GateDefinition, e as GateOptions, P as PolicyClass, f as PolicyInterface, g as PolicyMethod, h as PolicyRegistration, i as ResourceAction, j as ResponseBuilder, k as authorizeAbility, l as can, m as cannot, n as createGate, o as defineGate, p as getGate, s as setGate } from './Gate-CynjZCtS.js';
|
|
45
44
|
export { AuthorizedContext, Policy, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, definePolicy, withAuthorization } from './authorization/index.js';
|
|
46
45
|
export { A as AppKeyring, D as DecryptOptions, a as EncryptOptions, b as EncryptedPayload, E as Encrypter, c as EncrypterConfig, H as HashAlgorithm, d as HmacOptions, P as PasswordHashOptions, R as RandomStringOptions, e as createEncrypter, f as decrypt, g as deriveAppKey, h as deriveAppKeyring, i as encrypt, j as generateAppKey, k as generateKey, l as getAppKeyringFromEnv, m as getEncrypter, n as normalizeAppKey, p as parseAppKey, o as parsePreviousAppKeys, s as setEncrypter } from './app-key-CsBfRC_Q.js';
|
|
47
46
|
export { MessageSigner, SignMessageOptions, SignedMessageClaims, SignedUrlOptions, VerifySignedMessageOptions, VerifySignedUrlOptions, check as checkHash, generateOtp, generatePassword, generateSlug, hash, hashPassword, hmac, md5, needsRehash, pick, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, sample, secureCompare, sha256, sha512, shuffle, signUrl, urlSafeToken, uuid, verifyHmac, verifyPassword, verifySignedUrl } from './encryption/index.js';
|
|
48
|
-
export { M as MemoryRateLimitStore, a as RateLimitEntry, d as RateLimitInfo, e as RateLimitOptions, R as RateLimitStore, S as SlidingWindowRateLimitStore, f as createRateLimitMiddleware, c as createRedisClient, g as getRateLimitInfo, r as resetRateLimit } from './
|
|
47
|
+
export { M as MemoryRateLimitStore, a as RateLimitEntry, d as RateLimitInfo, e as RateLimitOptions, R as RateLimitStore, S as SlidingWindowRateLimitStore, f as createRateLimitMiddleware, c as createRedisClient, g as getRateLimitInfo, r as resetRateLimit } from './rate-limit-D9J2b4S1.js';
|
|
49
48
|
import 'vite';
|
|
50
49
|
import '@guren/orm';
|
|
51
50
|
import 'ioredis';
|
|
@@ -60,253 +59,17 @@ declare function attachAuthContext(contextFactory: (ctx: Context) => AuthContext
|
|
|
60
59
|
declare function requireAuthenticated(options?: RequireAuthOptions): MiddlewareHandler;
|
|
61
60
|
declare function requireGuest(options?: RequireAuthOptions): MiddlewareHandler;
|
|
62
61
|
|
|
63
|
-
|
|
64
|
-
defaultSrc?: string[];
|
|
65
|
-
scriptSrc?: string[];
|
|
66
|
-
styleSrc?: string[];
|
|
67
|
-
imgSrc?: string[];
|
|
68
|
-
fontSrc?: string[];
|
|
69
|
-
connectSrc?: string[];
|
|
70
|
-
mediaSrc?: string[];
|
|
71
|
-
objectSrc?: string[];
|
|
72
|
-
frameSrc?: string[];
|
|
73
|
-
childSrc?: string[];
|
|
74
|
-
workerSrc?: string[];
|
|
75
|
-
frameAncestors?: string[];
|
|
76
|
-
formAction?: string[];
|
|
77
|
-
baseUri?: string[];
|
|
78
|
-
manifestSrc?: string[];
|
|
79
|
-
upgradeInsecureRequests?: boolean;
|
|
80
|
-
blockAllMixedContent?: boolean;
|
|
81
|
-
/** Escape hatch for directives not listed above. */
|
|
82
|
-
[directive: string]: string[] | boolean | undefined;
|
|
83
|
-
}
|
|
84
|
-
interface CspOptions {
|
|
85
|
-
/** CSP directives configuration. */
|
|
86
|
-
directives?: CspDirectives;
|
|
87
|
-
/** Use Content-Security-Policy-Report-Only instead. Default: false */
|
|
88
|
-
reportOnly?: boolean;
|
|
89
|
-
/** URI for CSP violation reports. */
|
|
90
|
-
reportUri?: string;
|
|
91
|
-
/** Generate a per-request nonce and auto-append to script-src and style-src. Default: false */
|
|
92
|
-
useNonce?: boolean;
|
|
93
|
-
}
|
|
94
|
-
declare const CSP_NONCE_KEY = "csp-nonce";
|
|
95
|
-
/**
|
|
96
|
-
* Retrieve the CSP nonce for the current request.
|
|
97
|
-
* Only available when `useNonce: true` is set.
|
|
98
|
-
*/
|
|
99
|
-
declare function getCspNonce(ctx: Context): string;
|
|
100
|
-
/**
|
|
101
|
-
* Middleware that sets Content-Security-Policy headers.
|
|
102
|
-
*
|
|
103
|
-
* @example
|
|
104
|
-
* ```ts
|
|
105
|
-
* import { createCspMiddleware, getCspNonce } from '@guren/core'
|
|
106
|
-
*
|
|
107
|
-
* app.use('*', createCspMiddleware({
|
|
108
|
-
* directives: {
|
|
109
|
-
* defaultSrc: ["'self'"],
|
|
110
|
-
* scriptSrc: ["'self'", 'https://cdn.example.com'],
|
|
111
|
-
* styleSrc: ["'self'", "'unsafe-inline'"],
|
|
112
|
-
* imgSrc: ["'self'", 'data:', 'https:'],
|
|
113
|
-
* objectSrc: ["'none'"],
|
|
114
|
-
* },
|
|
115
|
-
* useNonce: true,
|
|
116
|
-
* reportUri: '/csp-report',
|
|
117
|
-
* }))
|
|
118
|
-
* ```
|
|
119
|
-
*/
|
|
120
|
-
declare function createCspMiddleware(options?: CspOptions): MiddlewareHandler;
|
|
121
|
-
|
|
122
|
-
interface CorsOptions {
|
|
123
|
-
/**
|
|
124
|
-
* Allowed origins. Default: none (same-origin policy applies).
|
|
125
|
-
* - A string: exact origin match (use '*' to allow all origins)
|
|
126
|
-
* - An array of strings: multiple allowed origins
|
|
127
|
-
* - A function: dynamic origin evaluation
|
|
128
|
-
*/
|
|
129
|
-
origin?: string | string[] | ((origin: string, ctx: unknown) => string | undefined | null);
|
|
130
|
-
/** Allowed HTTP methods. Default: ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH'] */
|
|
131
|
-
allowMethods?: string[];
|
|
132
|
-
/** Allowed request headers. */
|
|
133
|
-
allowHeaders?: string[];
|
|
134
|
-
/** Headers exposed to the browser. */
|
|
135
|
-
exposeHeaders?: string[];
|
|
136
|
-
/** Preflight cache max-age in seconds. */
|
|
137
|
-
maxAge?: number;
|
|
138
|
-
/** Allow credentials (cookies, authorization headers). Default: false */
|
|
139
|
-
credentials?: boolean;
|
|
140
|
-
}
|
|
141
|
-
/**
|
|
142
|
-
* CORS middleware powered by Hono's built-in CORS support.
|
|
143
|
-
*
|
|
144
|
-
* @example
|
|
145
|
-
* ```ts
|
|
146
|
-
* import { createCorsMiddleware } from '@guren/core'
|
|
147
|
-
*
|
|
148
|
-
* // Allow specific origins
|
|
149
|
-
* app.use('/api/*', createCorsMiddleware({
|
|
150
|
-
* origin: ['https://example.com', 'https://app.example.com'],
|
|
151
|
-
* credentials: true,
|
|
152
|
-
* }))
|
|
153
|
-
*
|
|
154
|
-
* // Dynamic origin
|
|
155
|
-
* app.use('/api/*', createCorsMiddleware({
|
|
156
|
-
* origin: (origin) => origin.endsWith('.example.com') ? origin : null,
|
|
157
|
-
* }))
|
|
158
|
-
* ```
|
|
159
|
-
*/
|
|
160
|
-
declare function createCorsMiddleware(options?: CorsOptions): MiddlewareHandler;
|
|
161
|
-
|
|
162
|
-
interface RedirectSafetyOptions {
|
|
163
|
-
/** Additional external hosts allowed as redirect targets. */
|
|
164
|
-
allowedHosts?: string[];
|
|
165
|
-
/** Fallback URL when an unsafe redirect is blocked. Default: '/' */
|
|
166
|
-
fallbackUrl?: string;
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Middleware that prevents open redirect attacks by validating
|
|
170
|
-
* redirect destinations in 3xx responses.
|
|
171
|
-
*
|
|
172
|
-
* @example
|
|
173
|
-
* ```ts
|
|
174
|
-
* import { createRedirectSafetyMiddleware } from '@guren/core'
|
|
175
|
-
*
|
|
176
|
-
* app.use('*', createRedirectSafetyMiddleware({
|
|
177
|
-
* allowedHosts: ['accounts.google.com'],
|
|
178
|
-
* }))
|
|
179
|
-
* ```
|
|
180
|
-
*/
|
|
181
|
-
declare function createRedirectSafetyMiddleware(options?: RedirectSafetyOptions): MiddlewareHandler;
|
|
182
|
-
/**
|
|
183
|
-
* Check whether a redirect URL is safe (same-origin or in the allowed list).
|
|
184
|
-
*
|
|
185
|
-
* @param url - The redirect target URL
|
|
186
|
-
* @param requestUrl - The current request URL (used to determine the origin)
|
|
187
|
-
* @param allowedHosts - Additional allowed external hosts
|
|
188
|
-
*/
|
|
189
|
-
declare function isSafeRedirectUrl(url: string, requestUrl: string, allowedHosts?: string[]): boolean;
|
|
190
|
-
|
|
191
|
-
interface ForceHttpsOptions {
|
|
192
|
-
/**
|
|
193
|
-
* HSTS max-age in seconds. Default: 31536000 (1 year).
|
|
194
|
-
*/
|
|
195
|
-
hstsMaxAge?: number;
|
|
196
|
-
/**
|
|
197
|
-
* Include subdomains in HSTS. Default: true.
|
|
198
|
-
*/
|
|
199
|
-
hstsIncludeSubDomains?: boolean;
|
|
200
|
-
/**
|
|
201
|
-
* Enable HSTS preload. Default: false.
|
|
202
|
-
*/
|
|
203
|
-
hstsPreload?: boolean;
|
|
204
|
-
/**
|
|
205
|
-
* Paths to exclude from HTTPS redirect (e.g., health checks).
|
|
206
|
-
*/
|
|
207
|
-
exclude?: string[];
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Middleware that redirects HTTP requests to HTTPS and sets the
|
|
211
|
-
* Strict-Transport-Security header. Equivalent to Rails' `force_ssl`.
|
|
212
|
-
*
|
|
213
|
-
* @example
|
|
214
|
-
* ```ts
|
|
215
|
-
* import { createForceHttpsMiddleware } from '@guren/core'
|
|
216
|
-
*
|
|
217
|
-
* // In production only
|
|
218
|
-
* if (process.env.NODE_ENV === 'production') {
|
|
219
|
-
* app.use('*', createForceHttpsMiddleware())
|
|
220
|
-
* }
|
|
221
|
-
* ```
|
|
222
|
-
*/
|
|
223
|
-
declare function createForceHttpsMiddleware(options?: ForceHttpsOptions): MiddlewareHandler;
|
|
224
|
-
|
|
225
|
-
/**
|
|
226
|
-
* Middleware that generates a unique request ID for each request.
|
|
227
|
-
* Reads from the `X-Request-ID` header if present, otherwise generates one
|
|
228
|
-
* using `crypto.randomUUID()`.
|
|
229
|
-
* Attaches the ID to the Hono context (`c.get('requestId')`) and sets it
|
|
230
|
-
* on the response header.
|
|
231
|
-
*
|
|
232
|
-
* @example
|
|
233
|
-
* ```ts
|
|
234
|
-
* import { requestIdMiddleware } from '@guren/core'
|
|
235
|
-
*
|
|
236
|
-
* app.use('*', requestIdMiddleware())
|
|
237
|
-
* ```
|
|
238
|
-
*/
|
|
239
|
-
declare function requestIdMiddleware(): hono.MiddlewareHandler<{
|
|
240
|
-
Variables: {
|
|
241
|
-
requestId: string;
|
|
242
|
-
};
|
|
243
|
-
}, string, {}, Response>;
|
|
244
|
-
|
|
62
|
+
type ViewRenderer = (template: string, props: Record<string, unknown>) => Response | Promise<Response>;
|
|
245
63
|
/**
|
|
246
|
-
*
|
|
247
|
-
*
|
|
248
|
-
*
|
|
249
|
-
* Pairs well with {@link requestIdMiddleware} — if a `requestId` is set on the
|
|
250
|
-
* context, it will be included in the log entry.
|
|
251
|
-
*
|
|
252
|
-
* @example
|
|
253
|
-
* ```ts
|
|
254
|
-
* import { requestIdMiddleware, requestLoggingMiddleware } from '@guren/core'
|
|
255
|
-
*
|
|
256
|
-
* app.use('*', requestIdMiddleware())
|
|
257
|
-
* app.use('*', requestLoggingMiddleware())
|
|
258
|
-
* ```
|
|
64
|
+
* Registry for view renderers. Engines are typically registered via service
|
|
65
|
+
* providers so applications can opt into or replace implementations.
|
|
259
66
|
*/
|
|
260
|
-
declare
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
/** Context variables set by {@link detectLocaleMiddleware}, for typing Hono apps. */
|
|
266
|
-
type DetectLocaleVariables = {
|
|
267
|
-
locale: string;
|
|
268
|
-
t?: Translator['t'];
|
|
269
|
-
tc?: Translator['tc'];
|
|
270
|
-
};
|
|
271
|
-
interface DetectLocaleOptions {
|
|
272
|
-
/** Locales the app supports. Detection only ever resolves to one of these. */
|
|
273
|
-
supported: readonly string[];
|
|
274
|
-
/** Locale used when no source matches (defaults to the first supported locale). */
|
|
275
|
-
fallback?: string;
|
|
276
|
-
/** Detection order (defaults to `['query', 'cookie', 'header']`). */
|
|
277
|
-
sources?: readonly LocaleSource[];
|
|
278
|
-
/** Query parameter to read (defaults to `locale`). */
|
|
279
|
-
queryParam?: string;
|
|
280
|
-
/** Cookie to read (defaults to `locale`). */
|
|
281
|
-
cookieName?: string;
|
|
282
|
-
/**
|
|
283
|
-
* i18n manager used to bind request-scoped `t`/`tc` translator helpers.
|
|
284
|
-
* Defaults to the global manager when one was registered via `setI18n()`;
|
|
285
|
-
* pass a manager explicitly (e.g. `app.container.make('i18n')`), or `false`
|
|
286
|
-
* to skip the translator binding entirely.
|
|
287
|
-
*/
|
|
288
|
-
i18n?: I18nManager | false;
|
|
67
|
+
declare class ViewEngine {
|
|
68
|
+
private static readonly engines;
|
|
69
|
+
static register(name: string, renderer: ViewRenderer): void;
|
|
70
|
+
static has(name: string): boolean;
|
|
71
|
+
static render(name: string, template: string, props: Record<string, unknown>): Response | Promise<Response>;
|
|
289
72
|
}
|
|
290
|
-
/**
|
|
291
|
-
* Middleware that resolves the request locale from the query string, a cookie,
|
|
292
|
-
* or the `Accept-Language` header — in that order by default — restricted to
|
|
293
|
-
* the `supported` allowlist.
|
|
294
|
-
*
|
|
295
|
-
* The result is stored as the `locale` context variable, which Inertia
|
|
296
|
-
* responses pick up for the root `<html lang>` attribute. When an i18n manager
|
|
297
|
-
* is available (see the `i18n` option), request-scoped `t`/`tc` translator
|
|
298
|
-
* helpers are attached as well.
|
|
299
|
-
*
|
|
300
|
-
* @example
|
|
301
|
-
* ```ts
|
|
302
|
-
* import { detectLocaleMiddleware } from '@guren/core'
|
|
303
|
-
*
|
|
304
|
-
* app.use('*', detectLocaleMiddleware({ supported: ['en', 'ja'] }))
|
|
305
|
-
* ```
|
|
306
|
-
*/
|
|
307
|
-
declare function detectLocaleMiddleware(options: DetectLocaleOptions): hono.MiddlewareHandler<{
|
|
308
|
-
Variables: DetectLocaleVariables;
|
|
309
|
-
}, string, {}, Response>;
|
|
310
73
|
|
|
311
74
|
/**
|
|
312
75
|
* Base HTTP exception class.
|
|
@@ -606,79 +369,6 @@ declare class MethodNotAllowedException extends HttpException {
|
|
|
606
369
|
|
|
607
370
|
declare function renderErrorPage(statusCode: number, message?: string): string;
|
|
608
371
|
|
|
609
|
-
/**
|
|
610
|
-
* Declarative definition of a plugin's lifecycle hooks.
|
|
611
|
-
*
|
|
612
|
-
* `register` and `boot` mirror the ServiceProvider hooks and receive the
|
|
613
|
-
* container plus the configuration captured by the plugin factory.
|
|
614
|
-
*/
|
|
615
|
-
interface PluginDefinition<TConfig = void> {
|
|
616
|
-
/**
|
|
617
|
-
* Diagnostic name for the plugin (e.g. 'analytics').
|
|
618
|
-
* Used to derive the generated provider class name.
|
|
619
|
-
*/
|
|
620
|
-
name: string;
|
|
621
|
-
/**
|
|
622
|
-
* Register services into the container.
|
|
623
|
-
* Called before any provider has booted.
|
|
624
|
-
*/
|
|
625
|
-
register(container: Container, config: TConfig): void | Promise<void>;
|
|
626
|
-
/**
|
|
627
|
-
* Bootstrap after all providers have registered.
|
|
628
|
-
*/
|
|
629
|
-
boot?(container: Container, config: TConfig): void | Promise<void>;
|
|
630
|
-
/**
|
|
631
|
-
* Defer instantiation until one of the `provides` services is resolved.
|
|
632
|
-
* Maps to `ServiceProvider.deferred`.
|
|
633
|
-
*/
|
|
634
|
-
deferred?: boolean;
|
|
635
|
-
/**
|
|
636
|
-
* Services bound by this plugin (required when `deferred` is true).
|
|
637
|
-
* Maps to `ServiceProvider.provides`.
|
|
638
|
-
*/
|
|
639
|
-
provides?: string[];
|
|
640
|
-
}
|
|
641
|
-
/**
|
|
642
|
-
* A factory returned by `definePlugin()`. Each call produces an independent
|
|
643
|
-
* ServiceProvider subclass with the given configuration captured in a closure.
|
|
644
|
-
*/
|
|
645
|
-
type PluginFactory<TConfig = void> = (config: TConfig) => ServiceProviderConstructor;
|
|
646
|
-
/**
|
|
647
|
-
* Define a configurable Guren plugin without ServiceProvider boilerplate.
|
|
648
|
-
*
|
|
649
|
-
* Unlike storing configuration on a static class property, each factory call
|
|
650
|
-
* returns a fresh provider class, so the same plugin can be registered twice
|
|
651
|
-
* with different configurations.
|
|
652
|
-
*
|
|
653
|
-
* @example
|
|
654
|
-
* ```typescript
|
|
655
|
-
* export const analyticsPlugin = definePlugin<AnalyticsConfig>({
|
|
656
|
-
* name: 'analytics',
|
|
657
|
-
* register(container, config) {
|
|
658
|
-
* container.singleton('analytics', () => new AnalyticsClient(config))
|
|
659
|
-
* },
|
|
660
|
-
* })
|
|
661
|
-
*
|
|
662
|
-
* // In the application:
|
|
663
|
-
* createApp({
|
|
664
|
-
* providers: [analyticsPlugin({ apiKey: process.env.ANALYTICS_API_KEY! })],
|
|
665
|
-
* })
|
|
666
|
-
* ```
|
|
667
|
-
*/
|
|
668
|
-
declare function definePlugin<TConfig = void>(definition: PluginDefinition<TConfig>): PluginFactory<TConfig>;
|
|
669
|
-
|
|
670
|
-
type ViewRenderer = (template: string, props: Record<string, unknown>) => Response | Promise<Response>;
|
|
671
|
-
/**
|
|
672
|
-
* Registry for view renderers. Engines are typically registered via service
|
|
673
|
-
* providers so applications can opt into or replace implementations.
|
|
674
|
-
*/
|
|
675
|
-
declare class ViewEngine {
|
|
676
|
-
private static readonly engines;
|
|
677
|
-
static register(name: string, renderer: ViewRenderer): void;
|
|
678
|
-
static has(name: string): boolean;
|
|
679
|
-
static render(name: string, template: string, props: Record<string, unknown>): Response | Promise<Response>;
|
|
680
|
-
}
|
|
681
|
-
|
|
682
372
|
/**
|
|
683
373
|
* Registers the Inertia view engine and wires up validation error handling
|
|
684
374
|
* for Inertia requests (Laravel-style automatic redirect with flashed errors).
|
|
@@ -758,6 +448,7 @@ declare class I18nServiceProvider extends ServiceProvider {
|
|
|
758
448
|
*/
|
|
759
449
|
declare class NotificationServiceProvider extends ServiceProvider {
|
|
760
450
|
register(): void;
|
|
451
|
+
boot(): void;
|
|
761
452
|
}
|
|
762
453
|
|
|
763
454
|
/**
|
|
@@ -1960,6 +1651,67 @@ declare function cursorPaginate<T>(items: T[], perPage: number, hasMore: boolean
|
|
|
1960
1651
|
prevCursor?: string | null;
|
|
1961
1652
|
}): CursorPaginator<T>;
|
|
1962
1653
|
|
|
1654
|
+
/**
|
|
1655
|
+
* Declarative definition of a plugin's lifecycle hooks.
|
|
1656
|
+
*
|
|
1657
|
+
* `register` and `boot` mirror the ServiceProvider hooks and receive the
|
|
1658
|
+
* container plus the configuration captured by the plugin factory.
|
|
1659
|
+
*/
|
|
1660
|
+
interface PluginDefinition<TConfig = void> {
|
|
1661
|
+
/**
|
|
1662
|
+
* Diagnostic name for the plugin (e.g. 'analytics').
|
|
1663
|
+
* Used to derive the generated provider class name.
|
|
1664
|
+
*/
|
|
1665
|
+
name: string;
|
|
1666
|
+
/**
|
|
1667
|
+
* Register services into the container.
|
|
1668
|
+
* Called before any provider has booted.
|
|
1669
|
+
*/
|
|
1670
|
+
register(container: Container, config: TConfig): void | Promise<void>;
|
|
1671
|
+
/**
|
|
1672
|
+
* Bootstrap after all providers have registered.
|
|
1673
|
+
*/
|
|
1674
|
+
boot?(container: Container, config: TConfig): void | Promise<void>;
|
|
1675
|
+
/**
|
|
1676
|
+
* Defer instantiation until one of the `provides` services is resolved.
|
|
1677
|
+
* Maps to `ServiceProvider.deferred`.
|
|
1678
|
+
*/
|
|
1679
|
+
deferred?: boolean;
|
|
1680
|
+
/**
|
|
1681
|
+
* Services bound by this plugin (required when `deferred` is true).
|
|
1682
|
+
* Maps to `ServiceProvider.provides`.
|
|
1683
|
+
*/
|
|
1684
|
+
provides?: string[];
|
|
1685
|
+
}
|
|
1686
|
+
/**
|
|
1687
|
+
* A factory returned by `definePlugin()`. Each call produces an independent
|
|
1688
|
+
* ServiceProvider subclass with the given configuration captured in a closure.
|
|
1689
|
+
*/
|
|
1690
|
+
type PluginFactory<TConfig = void> = (config: TConfig) => ServiceProviderConstructor;
|
|
1691
|
+
/**
|
|
1692
|
+
* Define a configurable Guren plugin without ServiceProvider boilerplate.
|
|
1693
|
+
*
|
|
1694
|
+
* Unlike storing configuration on a static class property, each factory call
|
|
1695
|
+
* returns a fresh provider class, so the same plugin can be registered twice
|
|
1696
|
+
* with different configurations.
|
|
1697
|
+
*
|
|
1698
|
+
* @example
|
|
1699
|
+
* ```typescript
|
|
1700
|
+
* export const analyticsPlugin = definePlugin<AnalyticsConfig>({
|
|
1701
|
+
* name: 'analytics',
|
|
1702
|
+
* register(container, config) {
|
|
1703
|
+
* container.singleton('analytics', () => new AnalyticsClient(config))
|
|
1704
|
+
* },
|
|
1705
|
+
* })
|
|
1706
|
+
*
|
|
1707
|
+
* // In the application:
|
|
1708
|
+
* createApp({
|
|
1709
|
+
* providers: [analyticsPlugin({ apiKey: process.env.ANALYTICS_API_KEY! })],
|
|
1710
|
+
* })
|
|
1711
|
+
* ```
|
|
1712
|
+
*/
|
|
1713
|
+
declare function definePlugin<TConfig = void>(definition: PluginDefinition<TConfig>): PluginFactory<TConfig>;
|
|
1714
|
+
|
|
1963
1715
|
/**
|
|
1964
1716
|
* Parse a command signature into argument and option definitions.
|
|
1965
1717
|
*
|
|
@@ -1974,6 +1726,18 @@ declare function cursorPaginate<T>(items: T[], perPage: number, hasMore: boolean
|
|
|
1974
1726
|
* - `{--option=default}` - Option with default value
|
|
1975
1727
|
* - `{-o|--option}` - Option with shortcut
|
|
1976
1728
|
* - `{--option=*}` - Array option
|
|
1729
|
+
* - `{argument : Description}` - Argument with a description
|
|
1730
|
+
* - `{--option= : Description}` - Option with a description
|
|
1731
|
+
*
|
|
1732
|
+
* A description is separated from the token by a colon with whitespace on at
|
|
1733
|
+
* least one side, so it may contain spaces and colons freely. Requiring that
|
|
1734
|
+
* whitespace keeps colons inside default values (`{--url=https://example.com}`)
|
|
1735
|
+
* out of descriptions.
|
|
1736
|
+
*
|
|
1737
|
+
* A colon with no whitespace at all (`{argument:Description}`) is accepted for
|
|
1738
|
+
* a single-word description, but only on a token carrying no other marker:
|
|
1739
|
+
* `{argument?}`, `{argument*}` and `{--option=default}` must use the spaced
|
|
1740
|
+
* form, since their markers are stripped before that fallback runs.
|
|
1977
1741
|
*
|
|
1978
1742
|
* @example
|
|
1979
1743
|
* ```typescript
|
|
@@ -1986,6 +1750,10 @@ declare function cursorPaginate<T>(items: T[], perPage: number, hasMore: boolean
|
|
|
1986
1750
|
* // { name: 'role', requiresValue: true, defaultValue: 'user' }
|
|
1987
1751
|
* // ]
|
|
1988
1752
|
* // }
|
|
1753
|
+
*
|
|
1754
|
+
* parseSignature('users:create {name : The full name} {--admin : Grant admin rights}')
|
|
1755
|
+
* // => arguments[0].description === 'The full name'
|
|
1756
|
+
* // options[0].description === 'Grant admin rights'
|
|
1989
1757
|
* ```
|
|
1990
1758
|
*/
|
|
1991
1759
|
declare function parseSignature(signature: string): ParsedSignature;
|
|
@@ -2103,6 +1871,8 @@ declare abstract class Command implements CommandInstance {
|
|
|
2103
1871
|
/**
|
|
2104
1872
|
* The command signature.
|
|
2105
1873
|
* Format: 'command:name {arg} {--option}'
|
|
1874
|
+
* Tokens may carry a description: 'command:name {arg : What it is}'
|
|
1875
|
+
* See `parseSignature` for the full grammar.
|
|
2106
1876
|
*/
|
|
2107
1877
|
static signature: string;
|
|
2108
1878
|
/**
|
|
@@ -2584,4 +2354,252 @@ declare class DefaultHasher implements PasswordHasher {
|
|
|
2584
2354
|
verify(hashed: string, plain: string): Promise<boolean>;
|
|
2585
2355
|
}
|
|
2586
2356
|
|
|
2357
|
+
interface CspDirectives {
|
|
2358
|
+
defaultSrc?: string[];
|
|
2359
|
+
scriptSrc?: string[];
|
|
2360
|
+
styleSrc?: string[];
|
|
2361
|
+
imgSrc?: string[];
|
|
2362
|
+
fontSrc?: string[];
|
|
2363
|
+
connectSrc?: string[];
|
|
2364
|
+
mediaSrc?: string[];
|
|
2365
|
+
objectSrc?: string[];
|
|
2366
|
+
frameSrc?: string[];
|
|
2367
|
+
childSrc?: string[];
|
|
2368
|
+
workerSrc?: string[];
|
|
2369
|
+
frameAncestors?: string[];
|
|
2370
|
+
formAction?: string[];
|
|
2371
|
+
baseUri?: string[];
|
|
2372
|
+
manifestSrc?: string[];
|
|
2373
|
+
upgradeInsecureRequests?: boolean;
|
|
2374
|
+
blockAllMixedContent?: boolean;
|
|
2375
|
+
/** Escape hatch for directives not listed above. */
|
|
2376
|
+
[directive: string]: string[] | boolean | undefined;
|
|
2377
|
+
}
|
|
2378
|
+
interface CspOptions {
|
|
2379
|
+
/** CSP directives configuration. */
|
|
2380
|
+
directives?: CspDirectives;
|
|
2381
|
+
/** Use Content-Security-Policy-Report-Only instead. Default: false */
|
|
2382
|
+
reportOnly?: boolean;
|
|
2383
|
+
/** URI for CSP violation reports. */
|
|
2384
|
+
reportUri?: string;
|
|
2385
|
+
/** Generate a per-request nonce and auto-append to script-src and style-src. Default: false */
|
|
2386
|
+
useNonce?: boolean;
|
|
2387
|
+
}
|
|
2388
|
+
declare const CSP_NONCE_KEY = "csp-nonce";
|
|
2389
|
+
/**
|
|
2390
|
+
* Retrieve the CSP nonce for the current request.
|
|
2391
|
+
* Only available when `useNonce: true` is set.
|
|
2392
|
+
*/
|
|
2393
|
+
declare function getCspNonce(ctx: Context): string;
|
|
2394
|
+
/**
|
|
2395
|
+
* Middleware that sets Content-Security-Policy headers.
|
|
2396
|
+
*
|
|
2397
|
+
* @example
|
|
2398
|
+
* ```ts
|
|
2399
|
+
* import { createCspMiddleware, getCspNonce } from '@guren/core'
|
|
2400
|
+
*
|
|
2401
|
+
* app.use('*', createCspMiddleware({
|
|
2402
|
+
* directives: {
|
|
2403
|
+
* defaultSrc: ["'self'"],
|
|
2404
|
+
* scriptSrc: ["'self'", 'https://cdn.example.com'],
|
|
2405
|
+
* styleSrc: ["'self'", "'unsafe-inline'"],
|
|
2406
|
+
* imgSrc: ["'self'", 'data:', 'https:'],
|
|
2407
|
+
* objectSrc: ["'none'"],
|
|
2408
|
+
* },
|
|
2409
|
+
* useNonce: true,
|
|
2410
|
+
* reportUri: '/csp-report',
|
|
2411
|
+
* }))
|
|
2412
|
+
* ```
|
|
2413
|
+
*/
|
|
2414
|
+
declare function createCspMiddleware(options?: CspOptions): MiddlewareHandler;
|
|
2415
|
+
|
|
2416
|
+
interface CorsOptions {
|
|
2417
|
+
/**
|
|
2418
|
+
* Allowed origins. Default: none (same-origin policy applies).
|
|
2419
|
+
* - A string: exact origin match (use '*' to allow all origins)
|
|
2420
|
+
* - An array of strings: multiple allowed origins
|
|
2421
|
+
* - A function: dynamic origin evaluation
|
|
2422
|
+
*/
|
|
2423
|
+
origin?: string | string[] | ((origin: string, ctx: unknown) => string | undefined | null);
|
|
2424
|
+
/** Allowed HTTP methods. Default: ['GET', 'HEAD', 'PUT', 'POST', 'DELETE', 'PATCH'] */
|
|
2425
|
+
allowMethods?: string[];
|
|
2426
|
+
/** Allowed request headers. */
|
|
2427
|
+
allowHeaders?: string[];
|
|
2428
|
+
/** Headers exposed to the browser. */
|
|
2429
|
+
exposeHeaders?: string[];
|
|
2430
|
+
/** Preflight cache max-age in seconds. */
|
|
2431
|
+
maxAge?: number;
|
|
2432
|
+
/** Allow credentials (cookies, authorization headers). Default: false */
|
|
2433
|
+
credentials?: boolean;
|
|
2434
|
+
}
|
|
2435
|
+
/**
|
|
2436
|
+
* CORS middleware powered by Hono's built-in CORS support.
|
|
2437
|
+
*
|
|
2438
|
+
* @example
|
|
2439
|
+
* ```ts
|
|
2440
|
+
* import { createCorsMiddleware } from '@guren/core'
|
|
2441
|
+
*
|
|
2442
|
+
* // Allow specific origins
|
|
2443
|
+
* app.use('/api/*', createCorsMiddleware({
|
|
2444
|
+
* origin: ['https://example.com', 'https://app.example.com'],
|
|
2445
|
+
* credentials: true,
|
|
2446
|
+
* }))
|
|
2447
|
+
*
|
|
2448
|
+
* // Dynamic origin
|
|
2449
|
+
* app.use('/api/*', createCorsMiddleware({
|
|
2450
|
+
* origin: (origin) => origin.endsWith('.example.com') ? origin : null,
|
|
2451
|
+
* }))
|
|
2452
|
+
* ```
|
|
2453
|
+
*/
|
|
2454
|
+
declare function createCorsMiddleware(options?: CorsOptions): MiddlewareHandler;
|
|
2455
|
+
|
|
2456
|
+
interface RedirectSafetyOptions {
|
|
2457
|
+
/** Additional external hosts allowed as redirect targets. */
|
|
2458
|
+
allowedHosts?: string[];
|
|
2459
|
+
/** Fallback URL when an unsafe redirect is blocked. Default: '/' */
|
|
2460
|
+
fallbackUrl?: string;
|
|
2461
|
+
}
|
|
2462
|
+
/**
|
|
2463
|
+
* Middleware that prevents open redirect attacks by validating
|
|
2464
|
+
* redirect destinations in 3xx responses.
|
|
2465
|
+
*
|
|
2466
|
+
* @example
|
|
2467
|
+
* ```ts
|
|
2468
|
+
* import { createRedirectSafetyMiddleware } from '@guren/core'
|
|
2469
|
+
*
|
|
2470
|
+
* app.use('*', createRedirectSafetyMiddleware({
|
|
2471
|
+
* allowedHosts: ['accounts.google.com'],
|
|
2472
|
+
* }))
|
|
2473
|
+
* ```
|
|
2474
|
+
*/
|
|
2475
|
+
declare function createRedirectSafetyMiddleware(options?: RedirectSafetyOptions): MiddlewareHandler;
|
|
2476
|
+
/**
|
|
2477
|
+
* Check whether a redirect URL is safe (same-origin or in the allowed list).
|
|
2478
|
+
*
|
|
2479
|
+
* @param url - The redirect target URL
|
|
2480
|
+
* @param requestUrl - The current request URL (used to determine the origin)
|
|
2481
|
+
* @param allowedHosts - Additional allowed external hosts
|
|
2482
|
+
*/
|
|
2483
|
+
declare function isSafeRedirectUrl(url: string, requestUrl: string, allowedHosts?: string[]): boolean;
|
|
2484
|
+
|
|
2485
|
+
interface ForceHttpsOptions {
|
|
2486
|
+
/**
|
|
2487
|
+
* HSTS max-age in seconds. Default: 31536000 (1 year).
|
|
2488
|
+
*/
|
|
2489
|
+
hstsMaxAge?: number;
|
|
2490
|
+
/**
|
|
2491
|
+
* Include subdomains in HSTS. Default: true.
|
|
2492
|
+
*/
|
|
2493
|
+
hstsIncludeSubDomains?: boolean;
|
|
2494
|
+
/**
|
|
2495
|
+
* Enable HSTS preload. Default: false.
|
|
2496
|
+
*/
|
|
2497
|
+
hstsPreload?: boolean;
|
|
2498
|
+
/**
|
|
2499
|
+
* Paths to exclude from HTTPS redirect (e.g., health checks).
|
|
2500
|
+
*/
|
|
2501
|
+
exclude?: string[];
|
|
2502
|
+
}
|
|
2503
|
+
/**
|
|
2504
|
+
* Middleware that redirects HTTP requests to HTTPS and sets the
|
|
2505
|
+
* Strict-Transport-Security header. Equivalent to Rails' `force_ssl`.
|
|
2506
|
+
*
|
|
2507
|
+
* @example
|
|
2508
|
+
* ```ts
|
|
2509
|
+
* import { createForceHttpsMiddleware } from '@guren/core'
|
|
2510
|
+
*
|
|
2511
|
+
* // In production only
|
|
2512
|
+
* if (process.env.NODE_ENV === 'production') {
|
|
2513
|
+
* app.use('*', createForceHttpsMiddleware())
|
|
2514
|
+
* }
|
|
2515
|
+
* ```
|
|
2516
|
+
*/
|
|
2517
|
+
declare function createForceHttpsMiddleware(options?: ForceHttpsOptions): MiddlewareHandler;
|
|
2518
|
+
|
|
2519
|
+
/**
|
|
2520
|
+
* Middleware that generates a unique request ID for each request.
|
|
2521
|
+
* Reads from the `X-Request-ID` header if present, otherwise generates one
|
|
2522
|
+
* using `crypto.randomUUID()`.
|
|
2523
|
+
* Attaches the ID to the Hono context (`c.get('requestId')`) and sets it
|
|
2524
|
+
* on the response header.
|
|
2525
|
+
*
|
|
2526
|
+
* @example
|
|
2527
|
+
* ```ts
|
|
2528
|
+
* import { requestIdMiddleware } from '@guren/core'
|
|
2529
|
+
*
|
|
2530
|
+
* app.use('*', requestIdMiddleware())
|
|
2531
|
+
* ```
|
|
2532
|
+
*/
|
|
2533
|
+
declare function requestIdMiddleware(): hono.MiddlewareHandler<{
|
|
2534
|
+
Variables: {
|
|
2535
|
+
requestId: string;
|
|
2536
|
+
};
|
|
2537
|
+
}, string, {}, Response>;
|
|
2538
|
+
|
|
2539
|
+
/**
|
|
2540
|
+
* Middleware that logs HTTP requests with method, path, status, and duration.
|
|
2541
|
+
* Uses structured JSON format suitable for production monitoring and log collectors.
|
|
2542
|
+
*
|
|
2543
|
+
* Pairs well with {@link requestIdMiddleware} — if a `requestId` is set on the
|
|
2544
|
+
* context, it will be included in the log entry.
|
|
2545
|
+
*
|
|
2546
|
+
* @example
|
|
2547
|
+
* ```ts
|
|
2548
|
+
* import { requestIdMiddleware, requestLoggingMiddleware } from '@guren/core'
|
|
2549
|
+
*
|
|
2550
|
+
* app.use('*', requestIdMiddleware())
|
|
2551
|
+
* app.use('*', requestLoggingMiddleware())
|
|
2552
|
+
* ```
|
|
2553
|
+
*/
|
|
2554
|
+
declare function requestLoggingMiddleware(): hono.MiddlewareHandler<any, string, {}, Response>;
|
|
2555
|
+
|
|
2556
|
+
/** Context key for the resolved request locale (read by Inertia for `<html lang>`). */
|
|
2557
|
+
declare const LOCALE_CONTEXT_KEY = "locale";
|
|
2558
|
+
type LocaleSource = 'query' | 'cookie' | 'header';
|
|
2559
|
+
/** Context variables set by {@link detectLocaleMiddleware}, for typing Hono apps. */
|
|
2560
|
+
type DetectLocaleVariables = {
|
|
2561
|
+
locale: string;
|
|
2562
|
+
t?: Translator['t'];
|
|
2563
|
+
tc?: Translator['tc'];
|
|
2564
|
+
};
|
|
2565
|
+
interface DetectLocaleOptions {
|
|
2566
|
+
/** Locales the app supports. Detection only ever resolves to one of these. */
|
|
2567
|
+
supported: readonly string[];
|
|
2568
|
+
/** Locale used when no source matches (defaults to the first supported locale). */
|
|
2569
|
+
fallback?: string;
|
|
2570
|
+
/** Detection order (defaults to `['query', 'cookie', 'header']`). */
|
|
2571
|
+
sources?: readonly LocaleSource[];
|
|
2572
|
+
/** Query parameter to read (defaults to `locale`). */
|
|
2573
|
+
queryParam?: string;
|
|
2574
|
+
/** Cookie to read (defaults to `locale`). */
|
|
2575
|
+
cookieName?: string;
|
|
2576
|
+
/**
|
|
2577
|
+
* i18n manager used to bind request-scoped `t`/`tc` translator helpers.
|
|
2578
|
+
* Defaults to the global manager when one was registered via `setI18n()`;
|
|
2579
|
+
* pass a manager explicitly (e.g. `app.container.make('i18n')`), or `false`
|
|
2580
|
+
* to skip the translator binding entirely.
|
|
2581
|
+
*/
|
|
2582
|
+
i18n?: I18nManager | false;
|
|
2583
|
+
}
|
|
2584
|
+
/**
|
|
2585
|
+
* Middleware that resolves the request locale from the query string, a cookie,
|
|
2586
|
+
* or the `Accept-Language` header — in that order by default — restricted to
|
|
2587
|
+
* the `supported` allowlist.
|
|
2588
|
+
*
|
|
2589
|
+
* The result is stored as the `locale` context variable, which Inertia
|
|
2590
|
+
* responses pick up for the root `<html lang>` attribute. When an i18n manager
|
|
2591
|
+
* is available (see the `i18n` option), request-scoped `t`/`tc` translator
|
|
2592
|
+
* helpers are attached as well.
|
|
2593
|
+
*
|
|
2594
|
+
* @example
|
|
2595
|
+
* ```ts
|
|
2596
|
+
* import { detectLocaleMiddleware } from '@guren/core'
|
|
2597
|
+
*
|
|
2598
|
+
* app.use('*', detectLocaleMiddleware({ supported: ['en', 'ja'] }))
|
|
2599
|
+
* ```
|
|
2600
|
+
*/
|
|
2601
|
+
declare function detectLocaleMiddleware(options: DetectLocaleOptions): hono.MiddlewareHandler<{
|
|
2602
|
+
Variables: DetectLocaleVariables;
|
|
2603
|
+
}, string, {}, Response>;
|
|
2604
|
+
|
|
2587
2605
|
export { AUTH_CONTEXT_KEY, AuthContext, AuthContext as AuthRuntimeContext, AuthServiceProvider, AuthenticationException, AuthorizationException, AuthorizationServiceProvider, AutoDiscovery, BaseFactory, type BaseResource, BaseSeeder, BroadcastManager, BroadcastServiceProvider, BufferedOutput, CSP_NONCE_KEY, CacheManager, CacheServiceProvider, Command, CommandInstance, Container, type CorsOptions, type CspDirectives, type CspOptions, type CursorPaginatedResponse, type CursorPaginationMeta, CursorPaginator, type CursorPaginatorOptions, DefaultHasher, type DetectLocaleOptions, type DetectLocaleVariables, type DiscoveryOptions, type DiscoveryResult, EncryptionServiceProvider, ErrorResponse, ErrorServiceProvider, EventManager, EventServiceProvider, BaseFactory as Factory, type FactoryClass, type Factory as FactoryInterface, FieldValidator, type FileLike, type FileValidationOptions, type ForceHttpsOptions, FormRequest, DefaultHasher as Hash, HealthServiceProvider, HttpException, I18nManager, I18nServiceProvider, type ImageValidationOptions, InertiaServiceProvider, type InferResourceData, Input, InputInterface, JsonResource, LOCALE_CONTEXT_KEY, type LocaleSource, LogManager, LogServiceProvider, MailManager, MailServiceProvider, MethodNotAllowedException, NotFoundHttpException, NotificationManager, NotificationServiceProvider, OAuthServiceProvider, OptionDefinition, Output, OutputInterface, type PaginatedPageProps, type PaginatedResponse, type PaginatedResultLike, type PaginationLinks, type PaginationMeta, type PaginationPageLink, Paginator, type PaginatorOptions, ParsedSignature, type PluginDefinition, type PluginFactory, QueueManager, QueueServiceProvider, type RedirectSafetyOptions, type RequireAuthOptions, Resource, type ResourceClass, ResourceCollection, type ResourceData, type RuleDefinition, Scheduler, SchedulingServiceProvider, BaseSeeder as Seeder, type SeederClass, type Seeder as SeederInterface, SeederRunner, type SeederRunnerOptions, ServiceBindings, ServiceProvider, ServiceProviderConstructor, StorageManager, StorageServiceProvider, Translator, type ValidationErrors, ValidationException, type ValidationResult, type ValidationRule, Validator, type ValidatorOptions, ViewEngine, after, afterOrEqual, alpha, alphaDash, alphaNum, array as arrayRule, attachAuthContext, before, beforeOrEqual, between, boolean as booleanRule, collect, confirmed, createCorsMiddleware, createCspMiddleware, createFacade, createFacades, createForceHttpsMiddleware, createRedirectSafetyMiddleware, createSeederRunner, createValidator, cursorPaginate, custom, dateFormat, date as dateRule, debugErrorMiddleware, decodeCursor, defineFactory, definePlugin, detectLocaleMiddleware, different, email as emailRule, encodeCursor, endsWith, exists, file as fileRule, getCspNonce, image as imageRule, inValues, integer, ip, ipv4, ipv6, isSafeRedirectUrl, json as jsonRule, max, maxFileSize, mimes, min, minFileSize, notIn, nullable, numeric, object as objectRule, paginate, parseSignature, quickValidate, quickValidateOrThrow, regex, renderDebugPage, renderErrorPage, requestIdMiddleware, requestLoggingMiddleware, requireAuthenticated, requireGuest, required, requiredIf, requiredUnless, requiredWith, requiredWithout, resetCalledSeeders, same, size, startsWith, string as stringRule, unique, url as urlRule, uuid as uuidRule };
|