@guren/server 2.18.0 → 2.20.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/{Job-DxQK8h3P.js → Job-CvDwk2Gj.js} +14 -6
- package/dist/Logger-DFifRAtc.js +114 -0
- package/dist/auth/index.js +1 -1
- package/dist/{auth-Gg54ppQi.js → auth-BXcHQwHf.js} +123 -40
- package/dist/cache/index.js +1 -1
- package/dist/cache/types.d.ts +5 -1
- package/dist/{cache-BOOIr324.js → cache-DUhlolkJ.js} +18 -3
- package/dist/client-C5Wj9P9o.js +70 -0
- package/dist/console/Command.d.ts +2 -0
- package/dist/container/Container.d.ts +9 -0
- package/dist/container/bindings.d.ts +3 -0
- package/dist/http/Application.d.ts +2 -0
- package/dist/http/middleware/cookie-session-store.d.ts +38 -0
- package/dist/http/middleware/index.d.ts +6 -0
- package/dist/http/middleware/session-manager.d.ts +86 -0
- package/dist/http/middleware/session.d.ts +40 -2
- package/dist/index.d.ts +4 -2
- package/dist/index.js +236 -23
- package/dist/lambda/index.js +6 -5
- package/dist/logging/index.js +2 -1
- package/dist/{logging-zOY1XCtq.js → logging-DXmqqUl4.js} +2 -114
- package/dist/mail/index.js +1 -1
- package/dist/{mail-76DWy9lj.js → mail-9CrvJyBZ.js} +1 -1
- package/dist/notifications/index.js +1 -1
- package/dist/{notifications-okWFs9ly.js → notifications-D0VXkFLF.js} +1 -1
- package/dist/providers/AuthServiceProvider.d.ts +18 -1
- package/dist/queue/index.js +2 -2
- package/dist/{queue-CcXCjuJI.js → queue-zPPYZdif.js} +1 -1
- package/dist/redis/index.js +1 -62
- package/dist/redis/lazy-client.d.ts +8 -0
- package/dist/runtime/index.js +3 -3
- package/dist/runtime/serverless.d.ts +15 -0
- package/dist/serverless-D96rJb6x.js +22 -0
- package/dist/{vite-manifest-DhbXfFct.js → vite-manifest-BZQ-75hf.js} +2 -2
- package/package.json +2 -2
- package/dist/client-C4TEr_Dd.js +0 -9
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { type SessionCookieOptions, type SessionStore } from './session.js';
|
|
2
|
+
export interface MemorySessionDriverOptions {
|
|
3
|
+
/** Clock for expiry, injectable for tests. @default Date.now */
|
|
4
|
+
now?: () => number;
|
|
5
|
+
}
|
|
6
|
+
export interface RedisSessionDriverOptions {
|
|
7
|
+
/**
|
|
8
|
+
* An ioredis client, or a function returning one *synchronously* (ioredis
|
|
9
|
+
* connects lazily on its own). A function runs when the store is first
|
|
10
|
+
* built, so a declared-but-unselected store opens no socket.
|
|
11
|
+
*/
|
|
12
|
+
client: unknown;
|
|
13
|
+
/** @default 'session:' */
|
|
14
|
+
prefix?: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Open driver registry (RFC 0020 §1). A plugin adds a driver by augmenting this
|
|
18
|
+
* interface, which is what makes `{ driver: 'dynamodb' }` type-check in an
|
|
19
|
+
* app's config, and by calling `registerDriver()` on the bound manager.
|
|
20
|
+
* `@guren/core` adds `database` here; server cannot, since it must not depend
|
|
21
|
+
* on the ORM.
|
|
22
|
+
*/
|
|
23
|
+
export interface SessionDrivers {
|
|
24
|
+
memory: MemorySessionDriverOptions;
|
|
25
|
+
redis: RedisSessionDriverOptions;
|
|
26
|
+
cookie: CookieSessionDriverOptions;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The cookie driver takes no app-facing options: its key comes from `APP_KEY`
|
|
30
|
+
* and its size budget from the middleware. `keyring` and `now` stay on
|
|
31
|
+
* {@link CookieSessionStoreOptions}, for direct construction in tests — a
|
|
32
|
+
* committed `config/session.ts` is the wrong home for key material.
|
|
33
|
+
*/
|
|
34
|
+
export interface CookieSessionDriverOptions {
|
|
35
|
+
}
|
|
36
|
+
export type SessionStoreConfig = {
|
|
37
|
+
[K in keyof SessionDrivers]: {
|
|
38
|
+
driver: K;
|
|
39
|
+
} & SessionDrivers[K];
|
|
40
|
+
}[keyof SessionDrivers];
|
|
41
|
+
/** The store `SessionConfig.default` names when it names none, and the one driver that shares no state between requests. */
|
|
42
|
+
export declare const DEFAULT_SESSION_STORE_NAME = "memory";
|
|
43
|
+
export declare const PER_PROCESS_SESSION_DRIVERS: ReadonlySet<string>;
|
|
44
|
+
/** Cookie and TTL settings plus the named stores one of which is the default. */
|
|
45
|
+
export interface SessionConfig extends SessionCookieOptions {
|
|
46
|
+
/** @default 'memory' */
|
|
47
|
+
default?: string;
|
|
48
|
+
stores?: Record<string, SessionStoreConfig>;
|
|
49
|
+
}
|
|
50
|
+
/** Receives the store's config minus `driver`. Per-write TTLs arrive through `SessionStore.write`. */
|
|
51
|
+
export type SessionDriverFactory<O = unknown> = (options: O) => SessionStore;
|
|
52
|
+
/**
|
|
53
|
+
* Resolves session stores by name from declared configs and registered drivers.
|
|
54
|
+
* Lazy and memoized: a driver registered after construction (a plugin's
|
|
55
|
+
* `register()`) still serves a store declared first, and nothing connects
|
|
56
|
+
* until a request asks. Only the default store's *name* is checked here;
|
|
57
|
+
* `assertDriverRegistered()` is the boot-time check for its driver.
|
|
58
|
+
*/
|
|
59
|
+
export declare class SessionManager {
|
|
60
|
+
/** Cookie and TTL settings for the middleware; the store is resolved through {@link store}. */
|
|
61
|
+
readonly options: SessionCookieOptions;
|
|
62
|
+
private readonly defaultStoreName;
|
|
63
|
+
private readonly configs;
|
|
64
|
+
private readonly driverFactories;
|
|
65
|
+
private readonly resolved;
|
|
66
|
+
constructor(config?: SessionConfig);
|
|
67
|
+
/** The default store when `name` is omitted; built on first call, memoized after. */
|
|
68
|
+
store(name?: string): SessionStore;
|
|
69
|
+
/**
|
|
70
|
+
* Fail now, with `store()`'s own message, if the store's driver is missing,
|
|
71
|
+
* without building the store: what a boot hook can afford where a Redis
|
|
72
|
+
* socket or a Workers binding cannot.
|
|
73
|
+
*/
|
|
74
|
+
assertDriverRegistered(name?: string): void;
|
|
75
|
+
registerDriver<K extends keyof SessionDrivers>(name: K, factory: SessionDriverFactory<SessionDrivers[K]>): void;
|
|
76
|
+
registerDriver(name: string, factory: SessionDriverFactory): void;
|
|
77
|
+
getStoreNames(): string[];
|
|
78
|
+
/**
|
|
79
|
+
* Sweep expired sessions from the default store and from any other store
|
|
80
|
+
* already built, on stores that support it (`deleteExpired`). Stores that
|
|
81
|
+
* were declared but never selected are left unbuilt, so a `redis` entry an
|
|
82
|
+
* environment does not use opens no connection here.
|
|
83
|
+
*/
|
|
84
|
+
pruneExpired(now?: Date): Promise<void>;
|
|
85
|
+
private resolve;
|
|
86
|
+
}
|
|
@@ -13,6 +13,22 @@ export interface SessionStore {
|
|
|
13
13
|
* session that does not exist must be a no-op, not a resurrection.
|
|
14
14
|
*/
|
|
15
15
|
touch?(id: string, ttlSeconds: number): Promise<void>;
|
|
16
|
+
/**
|
|
17
|
+
* Present on stores that keep the session *inside* the cookie (RFC 0020 §3).
|
|
18
|
+
* The middleware then writes `encode()`'s value as the cookie instead of a
|
|
19
|
+
* signed id and reads the next request's back through `decode()`, so
|
|
20
|
+
* `read`/`write`/`destroy` are never called: there is no keyed store behind it.
|
|
21
|
+
*/
|
|
22
|
+
inline?: SessionInlineCodec;
|
|
23
|
+
}
|
|
24
|
+
export interface SessionInlineCodec {
|
|
25
|
+
/** Throws when the session cannot fit the cookie, rather than emitting one a browser drops. */
|
|
26
|
+
encode(id: string, data: SessionData, ttlSeconds: number): string;
|
|
27
|
+
/** Null for a missing, expired, tampered, or undecryptable cookie. */
|
|
28
|
+
decode(cookieValue: string | undefined): {
|
|
29
|
+
id: string;
|
|
30
|
+
data: SessionData;
|
|
31
|
+
} | null;
|
|
16
32
|
}
|
|
17
33
|
export declare class MemorySessionStore implements SessionStore {
|
|
18
34
|
private readonly now;
|
|
@@ -23,7 +39,8 @@ export declare class MemorySessionStore implements SessionStore {
|
|
|
23
39
|
destroy(id: string): Promise<void>;
|
|
24
40
|
touch(id: string, ttlSeconds: number): Promise<void>;
|
|
25
41
|
}
|
|
26
|
-
|
|
42
|
+
/** Everything about the cookie and its lifetime; the store is a separate concern. */
|
|
43
|
+
export interface SessionCookieOptions {
|
|
27
44
|
cookieName?: string;
|
|
28
45
|
cookiePath?: string;
|
|
29
46
|
cookieDomain?: string;
|
|
@@ -32,8 +49,29 @@ export interface SessionOptions {
|
|
|
32
49
|
cookieHttpOnly?: boolean;
|
|
33
50
|
cookieMaxAgeSeconds?: number;
|
|
34
51
|
ttlSeconds?: number;
|
|
35
|
-
store?: SessionStore;
|
|
36
52
|
}
|
|
53
|
+
export interface SessionOptions extends SessionCookieOptions {
|
|
54
|
+
/**
|
|
55
|
+
* Bytes the whole `Set-Cookie` may occupy before the middleware refuses it.
|
|
56
|
+
* Browsers drop a larger one, and a dropped session cookie is a silent logout.
|
|
57
|
+
* @default 4096
|
|
58
|
+
*/
|
|
59
|
+
maxCookieBytes?: number;
|
|
60
|
+
/**
|
|
61
|
+
* The store, or a function returning it, called on every request and never
|
|
62
|
+
* at construction: a Workers binding does not exist before the first request
|
|
63
|
+
* (RFC 0020 §1). `SessionManager.store()` memoizes; a hand-written factory
|
|
64
|
+
* that builds something expensive should memoize too.
|
|
65
|
+
*/
|
|
66
|
+
store?: SessionStore | (() => SessionStore);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Read when a middleware is built, not when this module loads: an app that
|
|
70
|
+
* sets NODE_ENV after importing the framework (tests, some serverless
|
|
71
|
+
* bootstraps) must still get a Secure cookie. Spelled `process.env.NODE_ENV`
|
|
72
|
+
* exactly, so the deploy plugins' `--define` settles it at bundle time.
|
|
73
|
+
*/
|
|
74
|
+
export declare function defaultCookieSecure(): boolean;
|
|
37
75
|
declare const SESSION_CONTEXT_KEY = "guren:session";
|
|
38
76
|
export interface Session {
|
|
39
77
|
readonly id: string;
|
package/dist/index.d.ts
CHANGED
|
@@ -43,9 +43,9 @@ export { InertiaServiceProvider, AuthServiceProvider, OAuthServiceProvider, Even
|
|
|
43
43
|
export { FormRequest } from './http/FormRequest.js';
|
|
44
44
|
export { AuthManager, SessionGuard, TokenGuard, ModelUserProvider, BaseUserProvider, AuthenticatableModel, ScryptHasher, createPasswordResetToken, verifyPasswordResetToken, completePasswordReset, buildPasswordResetUrl, parsePasswordResetUrl, MemoryPasswordResetStore, createEmailVerificationToken, verifyEmailToken, completeEmailVerification, buildVerificationUrl, parseVerificationUrl, isEmailVerified, requireVerifiedEmail, MemoryEmailVerificationStore, createApiToken, parseApiToken, readBearerToken, verifyApiToken, tokenCan, tokenCanAll, tokenCanAny, revokeApiToken, revokeAllApiTokens, getUserApiTokens, createBearerTokenMiddleware, getApiToken, getApiTokenOrFail, MemoryApiTokenStore, API_TOKEN_KEY, OAuthManager, MemoryOAuthStateStore, createOAuthManager, createOAuthState, verifyOAuthState, sanitizeOAuthRedirect, OAUTH_SESSION_BINDING_KEY, buildOAuthAuthorizeUrl, exchangeOAuthCode, fetchOAuthUserProfile, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createDiscordOAuthProviderConfig, buildOAuthRedirectUrl, parseOAuthRedirectUrl, } from './auth/index.js';
|
|
45
45
|
export type { AuthContext as AuthRuntimeContext, AuthCredentials, AuthManagerOptions, Authenticatable, Guard, GuardContext, GuardFactory, UserProvider, ProviderFactory, DefaultSanitizedKeys, Sanitized, PasswordResetConfig, PasswordResetTokenStore, PasswordResetTokenResult, EmailVerificationConfig, EmailVerificationTokenStore, EmailVerificationToken, EmailVerificationTokenResult, ApiToken, ApiTokenGuardOptions, ApiTokenStore, CreateApiTokenOptions, CreateApiTokenResult, BearerTokenMiddlewareOptions, VerifiedApiToken, TokenGuardOptions, OAuthProviderConfig, OAuthTokenResult, OAuthUserProfile, OAuthFallbackEmail, OAuthStatePayload, OAuthStateStore, OAuthStateConfig, OAuthAuthorizeOptions, OAuthCallbackPayload, OAuthManagerOptions, OAuthProviderFactoryInput, OAuthBindingSession, } from './auth/index.js';
|
|
46
|
-
export { defineMiddleware, jsonResponse, createSessionMiddleware, MemorySessionStore, getSessionFromContext, requireAuthenticated, requireGuest, attachAuthContext, createCsrfMiddleware, getCsrfToken, csrfField, verifyCsrfToken, CSRF_TOKEN_KEY, CSRF_HEADER_NAME, CSRF_FORM_FIELD, validateRequest, validateRequestWith, getValidatedData, validate, validateSafe, VALIDATED_DATA_KEY, createRateLimitMiddleware, getRateLimitInfo, resetRateLimit, MemoryRateLimitStore, SlidingWindowRateLimitStore, createSecurityHeaders, createCspMiddleware, getCspNonce, CSP_NONCE_KEY, createHostAuthorizationMiddleware, createCorsMiddleware, createRedirectSafetyMiddleware, isSafeRedirectUrl, createForceHttpsMiddleware, requestIdMiddleware, requestLoggingMiddleware, detectLocaleMiddleware, LOCALE_CONTEXT_KEY, getRequestLocale, getRequestTranslator, } from './http/middleware/index.js';
|
|
46
|
+
export { defineMiddleware, jsonResponse, createSessionMiddleware, MemorySessionStore, SessionManager, CookieSessionStore, DEFAULT_SESSION_STORE_NAME, PER_PROCESS_SESSION_DRIVERS, getSessionFromContext, requireAuthenticated, requireGuest, attachAuthContext, createCsrfMiddleware, getCsrfToken, csrfField, verifyCsrfToken, CSRF_TOKEN_KEY, CSRF_HEADER_NAME, CSRF_FORM_FIELD, validateRequest, validateRequestWith, getValidatedData, validate, validateSafe, VALIDATED_DATA_KEY, createRateLimitMiddleware, getRateLimitInfo, resetRateLimit, MemoryRateLimitStore, SlidingWindowRateLimitStore, createSecurityHeaders, createCspMiddleware, getCspNonce, CSP_NONCE_KEY, createHostAuthorizationMiddleware, createCorsMiddleware, createRedirectSafetyMiddleware, isSafeRedirectUrl, createForceHttpsMiddleware, requestIdMiddleware, requestLoggingMiddleware, detectLocaleMiddleware, LOCALE_CONTEXT_KEY, getRequestLocale, getRequestTranslator, } from './http/middleware/index.js';
|
|
47
47
|
export { AUTH_CONTEXT_KEY } from './http/middleware/auth.js';
|
|
48
|
-
export type { Middleware, Session, SessionData, SessionStore, AuthContext, RequireAuthOptions, CsrfOptions, CookielessAuthEndpoints, ValidationSchema, ValidateRequestOptions, RateLimitOptions, RateLimitStore, RateLimitEntry, RateLimitInfo, SecurityHeadersOptions, HstsOptions, CspOptions, CspDirectives, HostAuthorizationOptions, CorsOptions, RedirectSafetyOptions, ForceHttpsOptions, DetectLocaleOptions, DetectLocaleVariables, TranslatorBinding, LocaleSource, } from './http/middleware/index.js';
|
|
48
|
+
export type { Middleware, Session, SessionData, SessionStore, SessionConfig, SessionDrivers, SessionStoreConfig, SessionDriverFactory, SessionCookieOptions, SessionInlineCodec, CookieSessionStoreOptions, CookieSessionDriverOptions, MemorySessionDriverOptions, RedisSessionDriverOptions, AuthContext, RequireAuthOptions, CsrfOptions, CookielessAuthEndpoints, ValidationSchema, ValidateRequestOptions, RateLimitOptions, RateLimitStore, RateLimitEntry, RateLimitInfo, SecurityHeadersOptions, HstsOptions, CspOptions, CspDirectives, HostAuthorizationOptions, CorsOptions, RedirectSafetyOptions, ForceHttpsOptions, DetectLocaleOptions, DetectLocaleVariables, TranslatorBinding, LocaleSource, } from './http/middleware/index.js';
|
|
49
49
|
export { Validator, FieldValidator, createValidator, quickValidate, quickValidateOrThrow, required, nullable, requiredIf, requiredUnless, requiredWith, requiredWithout, string as stringRule, numeric, integer, boolean as booleanRule, array as arrayRule, object as objectRule, email as emailRule, url as urlRule, uuid as uuidRule, ip, ipv4, ipv6, json as jsonRule, alpha, alphaNum, alphaDash, regex, min, max, between, size, inValues, notIn, confirmed, same, different, date as dateRule, dateFormat, after, afterOrEqual, before, beforeOrEqual, startsWith, endsWith, file as fileRule, image as imageRule, mimes, maxFileSize, minFileSize, custom, unique, exists, } from './http/validation/index.js';
|
|
50
50
|
export type { ValidationRule, RuleDefinition, ValidationResult, FileValidationOptions, ImageValidationOptions, ValidatorOptions, FileLike, } from './http/validation/index.js';
|
|
51
51
|
export { Event, EventManager, createEventManager, Listener, RequestReceived, RequestFinished, UserAuthenticated, UserLoggedOut, JobProcessed, JobFailed, ApplicationStarted, ApplicationShutdown, } from './events/index.js';
|
|
@@ -96,3 +96,5 @@ export type { InertiaI18nProps } from './providers/I18nServiceProvider.js';
|
|
|
96
96
|
export { SqsDriver, createSqsAdapter } from './queue/drivers/SqsDriver.js';
|
|
97
97
|
export { createTypedBroadcaster } from './broadcasting/typed.js';
|
|
98
98
|
export { createRedisClient } from './redis/client.js';
|
|
99
|
+
export { detectServerlessRuntime, SERVERLESS_RUNTIME_LABELS } from './runtime/serverless.js';
|
|
100
|
+
export type { ServerlessRuntime, ServerlessRuntimeId } from './runtime/serverless.js';
|
package/dist/index.js
CHANGED
|
@@ -5,34 +5,37 @@ import { _ as setGate, a as withAuthorization, b as mergeCapabilities, c as Gate
|
|
|
5
5
|
import { a as mapToolResponse, i as describeBuildFailure, n as advertisesStructuredOutput, r as buildToolRequest, s as AGENT_PREFLIGHT_VERDICT_HEADER, t as PREFLIGHT_ARGUMENT } from "./dispatch-BAwzftws.js";
|
|
6
6
|
import { t as trimSlashes } from "./trim-slashes-BLY9hKAa.js";
|
|
7
7
|
import { PATH_PARAM_PATTERN, extractPathParamNames } from "./internal/route-path.js";
|
|
8
|
-
import { a as getRegisteredJobs, c as setQueueDriver, d as getContainer, f as resolve, i as getQueueDriver, l as Container, n as clearJobRegistry, o as registerJob, p as setContainer, r as getJob, s as resolveJobName, t as Job, u as createContainer } from "./Job-
|
|
8
|
+
import { a as getRegisteredJobs, c as setQueueDriver, d as getContainer, f as resolve, i as getQueueDriver, l as Container, n as clearJobRegistry, o as registerJob, p as setContainer, r as getJob, s as resolveJobName, t as Job, u as createContainer } from "./Job-CvDwk2Gj.js";
|
|
9
9
|
import { n as ProviderManager, r as ServiceProvider } from "./loopback-guard-DT9gHF0F.js";
|
|
10
10
|
import { a as generateAppKey, c as parseAppKey, i as encodeDerivedKey, l as parsePreviousAppKeys, n as deriveAppKey, o as getAppKeyringFromEnv, r as deriveAppKeyring, s as normalizeAppKey, t as MessageSigner } from "./MessageSigner-Bd25ZJAV.js";
|
|
11
|
-
import {
|
|
11
|
+
import { n as detectServerlessRuntime, t as SERVERLESS_RUNTIME_LABELS } from "./serverless-D96rJb6x.js";
|
|
12
|
+
import { A as verifyOAuthState, B as getApiToken, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, F as TokenGuard, G as readBearerToken, H as getUserApiTokens, I as API_TOKEN_KEY, J as tokenCan, K as revokeAllApiTokens, L as MemoryApiTokenStore, M as isAppRelativePath, N as normalizeRedirectTarget, O as parseOAuthRedirectUrl, P as AuthManager, Q as SessionGuard, R as createApiToken, S as createGitHubOAuthProviderConfig, T as createOAuthState, U as hasBearerHeader, V as getApiTokenOrFail, W as parseApiToken, X as tokenCanAny, Y as tokenCanAll, Z as verifyApiToken, _ as OAUTH_SESSION_BINDING_KEY, _t as getSessionFromContext, a as isEmailVerified, b as buildOAuthRedirectUrl, c as verifyEmailToken, ct as NodeHasher, d as completePasswordReset, dt as BaseUserProvider, f as createPasswordResetToken, ft as installAgentPrincipal, g as MemoryOAuthStateStore, gt as defaultCookieSecure, h as AuthenticatableModel, ht as createSessionMiddleware, i as createEmailVerificationToken, j as hostMatchesAllowlist, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, lt as ScryptHasher, m as verifyPasswordResetToken, mt as MemorySessionStore, n as buildVerificationUrl, o as parseVerificationUrl, ot as ModelUserProvider, p as parsePasswordResetUrl, pt as readAgentPrincipal, q as revokeApiToken, r as completeEmailVerification, s as requireVerifiedEmail, st as DefaultHasher, t as MemoryEmailVerificationStore, u as buildPasswordResetUrl, ut as AuthenticationException, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as createBearerTokenMiddleware } from "./auth-BXcHQwHf.js";
|
|
12
13
|
import { a as md5, c as sha256, d as verifyPassword, i as hmac, l as sha512, n as hash, o as needsRehash, r as hashPassword, s as secureCompare, t as check, u as verifyHmac } from "./Hash-D2DFd8xX.js";
|
|
13
14
|
import { n as getAuthContext, t as AUTH_CONTEXT_KEY } from "./context-CXk_umpT.js";
|
|
15
|
+
import { n as filterSensitiveData, t as Logger } from "./Logger-DFifRAtc.js";
|
|
16
|
+
import { a as RedisStore, i as FileStore, n as createCacheManager, o as MemoryStore, r as TaggedCache, s as resolveLazyRedisClient, t as CacheManager } from "./cache-DUhlolkJ.js";
|
|
17
|
+
import { n as createRedisClient, r as RedisSessionStore } from "./client-C5Wj9P9o.js";
|
|
14
18
|
import { r as isMcpEndpointEnabled } from "./endpoint-Dsw3Acvq.js";
|
|
15
19
|
import { n as isHotReloadRuntime, r as matchingOpenParen, t as claimHotDisposable } from "./hot-disposables-B5BXqaIH.js";
|
|
16
20
|
import { a as setI18n, c as tryGetI18n, d as getPluralizationRule, f as pluralizationRules, i as getI18n, l as JsonLoader, n as I18nManager, o as t, p as selectPluralForm, r as createI18n, s as tc, t as MemoryLoader, u as Translator } from "./i18n-Cg1aajRP.js";
|
|
17
|
-
import { _ as parseImportMap, c as isViteProduction, d as startViteDevServer, g as DEFAULT_DEV_STYLES_ENTRY, h as logDevServerBanner, i as clientManifestCandidates, l as loadViteManifest, m as isWildcardHost, n as INJECTED_CLIENT_MANIFEST_SOURCE, o as getManifestFile, p as formatHostPort, r as PUBLIC_ASSETS_URL_PREFIX, s as injectedClientManifest, u as normalizeDevServerUrl } from "./vite-manifest-
|
|
21
|
+
import { _ as parseImportMap, c as isViteProduction, d as startViteDevServer, g as DEFAULT_DEV_STYLES_ENTRY, h as logDevServerBanner, i as clientManifestCandidates, l as loadViteManifest, m as isWildcardHost, n as INJECTED_CLIENT_MANIFEST_SOURCE, o as getManifestFile, p as formatHostPort, r as PUBLIC_ASSETS_URL_PREFIX, s as injectedClientManifest, u as normalizeDevServerUrl } from "./vite-manifest-BZQ-75hf.js";
|
|
18
22
|
import { r as isDocsViewerEnabled } from "./endpoint-BXipU2Jj.js";
|
|
19
23
|
import { t as jsx_runtime_exports } from "./jsx-runtime.js";
|
|
20
24
|
import { readObjectSchema, toJsonSchema } from "./internal/zod-json-schema.js";
|
|
21
25
|
import { a as RequestFinished, c as UserLoggedOut, d as createEventManager, f as Event, i as JobProcessed, l as Listener, n as ApplicationStarted, o as RequestReceived, r as JobFailed, s as UserAuthenticated, t as ApplicationShutdown, u as EventManager } from "./events-DOmAHDeP.js";
|
|
22
|
-
import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "./notifications-
|
|
23
|
-
import { a as
|
|
24
|
-
import { a as
|
|
25
|
-
import { a as
|
|
26
|
-
import { a as DailyFileChannel, c as matchDailyFileDate, d as Logger, f as filterSensitiveData, i as setLogManager, l as FileChannel, n as createLogManager, o as dailyFileDateStamp, p as LOG_LEVEL_PRIORITY, r as getLogManager, s as dailyFilePath, t as LogManager, u as ConsoleChannel } from "./logging-zOY1XCtq.js";
|
|
26
|
+
import { a as NotificationManager, c as setNotificationManager, d as getNotification, f as registerNotification, i as MailChannel, l as resolveNotifiableType, n as SlackChannel, o as createNotificationManager, p as Notification, r as DatabaseChannel, s as getNotificationManager, t as MemoryChannel, u as clearNotificationRegistry } from "./notifications-D0VXkFLF.js";
|
|
27
|
+
import { a as processJob, c as RedisDriver$1, i as Worker, l as SyncDriver, n as createQueueManager, o as SqsDriver, r as FailedJobReporter, s as createSqsAdapter, t as QueueManager, u as MemoryDriver$1 } from "./queue-zPPYZdif.js";
|
|
28
|
+
import { a as MailManager, c as MemoryTransport, i as setMailManager, l as ResendTransport, n as getMailManager, o as createMailManager, r as mail, s as LogTransport, t as Mail, u as SmtpTransport } from "./mail-9CrvJyBZ.js";
|
|
29
|
+
import { a as DailyFileChannel, c as matchDailyFileDate, d as LOG_LEVEL_PRIORITY, i as setLogManager, l as FileChannel, n as createLogManager, o as dailyFileDateStamp, r as getLogManager, s as dailyFilePath, t as LogManager, u as ConsoleChannel } from "./logging-DXmqqUl4.js";
|
|
27
30
|
import { a as setBroadcastManager, c as PresenceChannel, i as getBroadcastManager, l as PrivateChannel, n as BroadcastManager, o as RedisDriver, r as createBroadcastManager, s as MemoryDriver, t as createTypedBroadcaster, u as Channel } from "./broadcasting-B5RzB0A2.js";
|
|
28
31
|
import { a as random, c as randomHex, d as sample, f as shuffle, i as pick, l as randomInt, m as uuid, n as generatePassword, o as randomBase64, p as urlSafeToken, r as generateSlug, s as randomBase64Url, t as generateOtp, u as randomString } from "./Random-S0OvCuR8.js";
|
|
29
32
|
import { a as decrypt, c as getEncrypter, i as createEncrypter, l as setEncrypter, n as verifySignedUrl, o as encrypt, r as Encrypter, s as generateKey, t as signUrl } from "./encryption-uwP3Di4D.js";
|
|
30
33
|
import { a as LocalDriver, i as S3Driver, n as createStorageManager, o as warnOnce, r as MemoryDriver$2, t as StorageManager } from "./storage-BB59f07j.js";
|
|
31
34
|
import { a as CacheCheck, c as HealthManager, i as StorageCheck, l as createHealthManager, n as customCheck, o as RedisCheck, r as MemoryCheck, s as DatabaseCheck, t as CustomCheck, u as HealthCheck } from "./health-DQSvUplL.js";
|
|
32
35
|
import { a as ScheduledTask, c as isDue, d as parseCron, f as toTimezone, i as Schedule, l as isDueInTimezone, n as createScheduler, o as getNextOccurrence, r as PendingSchedule, s as getNextOccurrences, t as Scheduler, u as matchesCron } from "./scheduling-C6tcOtUl.js";
|
|
33
|
-
import { n as createRedisClient } from "./client-C4TEr_Dd.js";
|
|
34
36
|
import { Hono } from "hono";
|
|
35
37
|
import { deleteCookie, getCookie } from "hono/cookie";
|
|
38
|
+
import { createCipheriv, createDecipheriv, randomBytes } from "node:crypto";
|
|
36
39
|
import { cors } from "hono/cors";
|
|
37
40
|
import { createMiddleware } from "hono/factory";
|
|
38
41
|
import { parseAccept } from "hono/utils/accept";
|
|
@@ -815,6 +818,183 @@ async function mountModuleRoutes(router, gurenModule) {
|
|
|
815
818
|
await pending;
|
|
816
819
|
}
|
|
817
820
|
//#endregion
|
|
821
|
+
//#region src/http/middleware/cookie-session-store.ts
|
|
822
|
+
const IV_BYTES = 12;
|
|
823
|
+
const TAG_BYTES = 16;
|
|
824
|
+
function isPlainObject(value) {
|
|
825
|
+
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
826
|
+
}
|
|
827
|
+
/**
|
|
828
|
+
* The whole session, encrypted inside the cookie under the app key: the one
|
|
829
|
+
* store needing no server-side resource (RFC 0020 §3). Two limits the docs
|
|
830
|
+
* state outright — everything in the session travels in the cookie, so the
|
|
831
|
+
* middleware caps it; and a logout cannot revoke a copy the client already
|
|
832
|
+
* has, so anything revocable belongs in the database with only its id here.
|
|
833
|
+
*/
|
|
834
|
+
var CookieSessionStore = class {
|
|
835
|
+
keyring;
|
|
836
|
+
now;
|
|
837
|
+
constructor(options = {}) {
|
|
838
|
+
this.keyring = options.keyring ?? deriveAppKeyring(getAppKeyringFromEnv(), "cookie-session");
|
|
839
|
+
this.now = options.now ?? (() => Date.now());
|
|
840
|
+
}
|
|
841
|
+
inline = {
|
|
842
|
+
/**
|
|
843
|
+
* `base64url(iv ‖ tag ‖ ciphertext)` rather than `Encrypter`'s envelope,
|
|
844
|
+
* which base64s the ciphertext into JSON and base64s that again: measured
|
|
845
|
+
* 2.27x the plaintext against 1.52x here, and a cookie's budget is this
|
|
846
|
+
* store's whole constraint. Same primitives, same 12-byte IV and 16-byte tag.
|
|
847
|
+
*/
|
|
848
|
+
encode: (id, data, ttlSeconds) => {
|
|
849
|
+
const payload = {
|
|
850
|
+
id,
|
|
851
|
+
data,
|
|
852
|
+
expiresAt: this.now() + ttlSeconds * 1e3
|
|
853
|
+
};
|
|
854
|
+
const iv = randomBytes(IV_BYTES);
|
|
855
|
+
const cipher = createCipheriv("aes-256-gcm", this.keyring.current, iv, { authTagLength: TAG_BYTES });
|
|
856
|
+
const ciphertext = Buffer.concat([cipher.update(JSON.stringify(payload), "utf8"), cipher.final()]);
|
|
857
|
+
return Buffer.concat([
|
|
858
|
+
iv,
|
|
859
|
+
cipher.getAuthTag(),
|
|
860
|
+
ciphertext
|
|
861
|
+
]).toString("base64url");
|
|
862
|
+
},
|
|
863
|
+
decode: (cookieValue) => {
|
|
864
|
+
if (!cookieValue) return null;
|
|
865
|
+
const raw = Buffer.from(cookieValue, "base64url");
|
|
866
|
+
if (raw.length <= 28) return null;
|
|
867
|
+
const iv = raw.subarray(0, IV_BYTES);
|
|
868
|
+
const tag = raw.subarray(IV_BYTES, 28);
|
|
869
|
+
const ciphertext = raw.subarray(28);
|
|
870
|
+
for (const key of [this.keyring.current, ...this.keyring.previous]) {
|
|
871
|
+
const payload = this.open(key, iv, tag, ciphertext);
|
|
872
|
+
if (payload) return payload;
|
|
873
|
+
}
|
|
874
|
+
return null;
|
|
875
|
+
}
|
|
876
|
+
};
|
|
877
|
+
open(key, iv, tag, ciphertext) {
|
|
878
|
+
let plaintext;
|
|
879
|
+
try {
|
|
880
|
+
const decipher = createDecipheriv("aes-256-gcm", key, iv, { authTagLength: TAG_BYTES });
|
|
881
|
+
decipher.setAuthTag(tag);
|
|
882
|
+
plaintext = Buffer.concat([decipher.update(ciphertext), decipher.final()]).toString("utf8");
|
|
883
|
+
} catch {
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
886
|
+
let payload;
|
|
887
|
+
try {
|
|
888
|
+
payload = JSON.parse(plaintext);
|
|
889
|
+
} catch {
|
|
890
|
+
return null;
|
|
891
|
+
}
|
|
892
|
+
if (!isPlainObject(payload)) return null;
|
|
893
|
+
const { id, data, expiresAt } = payload;
|
|
894
|
+
if (typeof id !== "string" || typeof expiresAt !== "number" || !isPlainObject(data)) return null;
|
|
895
|
+
if (expiresAt <= this.now()) return null;
|
|
896
|
+
return {
|
|
897
|
+
id,
|
|
898
|
+
data
|
|
899
|
+
};
|
|
900
|
+
}
|
|
901
|
+
async read() {
|
|
902
|
+
throw new Error(this.keyedStoreError("read"));
|
|
903
|
+
}
|
|
904
|
+
async write() {
|
|
905
|
+
throw new Error(this.keyedStoreError("write"));
|
|
906
|
+
}
|
|
907
|
+
async destroy() {
|
|
908
|
+
throw new Error(this.keyedStoreError("destroy"));
|
|
909
|
+
}
|
|
910
|
+
keyedStoreError(method) {
|
|
911
|
+
return `CookieSessionStore has no keyed store to ${method}: the session lives in the cookie, which the session middleware reads and writes through \`inline\`. Use a database- or Redis-backed store to look a session up by id.`;
|
|
912
|
+
}
|
|
913
|
+
};
|
|
914
|
+
//#endregion
|
|
915
|
+
//#region src/http/middleware/session-manager.ts
|
|
916
|
+
/** The store `SessionConfig.default` names when it names none, and the one driver that shares no state between requests. */
|
|
917
|
+
const DEFAULT_SESSION_STORE_NAME = "memory";
|
|
918
|
+
const PER_PROCESS_SESSION_DRIVERS = /* @__PURE__ */ new Set([DEFAULT_SESSION_STORE_NAME]);
|
|
919
|
+
function isPrunable(store) {
|
|
920
|
+
return typeof store.deleteExpired === "function";
|
|
921
|
+
}
|
|
922
|
+
/**
|
|
923
|
+
* Resolves session stores by name from declared configs and registered drivers.
|
|
924
|
+
* Lazy and memoized: a driver registered after construction (a plugin's
|
|
925
|
+
* `register()`) still serves a store declared first, and nothing connects
|
|
926
|
+
* until a request asks. Only the default store's *name* is checked here;
|
|
927
|
+
* `assertDriverRegistered()` is the boot-time check for its driver.
|
|
928
|
+
*/
|
|
929
|
+
var SessionManager = class {
|
|
930
|
+
/** Cookie and TTL settings for the middleware; the store is resolved through {@link store}. */
|
|
931
|
+
options;
|
|
932
|
+
defaultStoreName;
|
|
933
|
+
configs = /* @__PURE__ */ new Map();
|
|
934
|
+
driverFactories = /* @__PURE__ */ new Map();
|
|
935
|
+
resolved = /* @__PURE__ */ new Map();
|
|
936
|
+
constructor(config = {}) {
|
|
937
|
+
const { default: defaultName = DEFAULT_SESSION_STORE_NAME, stores = {}, ...options } = config;
|
|
938
|
+
this.options = options;
|
|
939
|
+
this.defaultStoreName = defaultName;
|
|
940
|
+
this.registerDriver("memory", ({ now }) => new MemorySessionStore(now));
|
|
941
|
+
this.registerDriver("cookie", () => new CookieSessionStore());
|
|
942
|
+
this.registerDriver("redis", ({ client, prefix }) => {
|
|
943
|
+
const redis = resolveLazyRedisClient(client, "Session store \"redis\"");
|
|
944
|
+
return new RedisSessionStore(redis, { prefix });
|
|
945
|
+
});
|
|
946
|
+
this.configs.set(DEFAULT_SESSION_STORE_NAME, { driver: "memory" });
|
|
947
|
+
for (const [name, storeConfig] of Object.entries(stores)) this.configs.set(name, storeConfig);
|
|
948
|
+
if (!this.configs.has(defaultName)) throw new Error(`Session store not found: ${defaultName} (declared: ${this.getStoreNames().join(", ")})`);
|
|
949
|
+
}
|
|
950
|
+
/** The default store when `name` is omitted; built on first call, memoized after. */
|
|
951
|
+
store(name) {
|
|
952
|
+
const storeName = name ?? this.defaultStoreName;
|
|
953
|
+
const cached = this.resolved.get(storeName);
|
|
954
|
+
if (cached) return cached;
|
|
955
|
+
const { factory, options } = this.resolve(storeName);
|
|
956
|
+
const store = factory(options);
|
|
957
|
+
this.resolved.set(storeName, store);
|
|
958
|
+
return store;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Fail now, with `store()`'s own message, if the store's driver is missing,
|
|
962
|
+
* without building the store: what a boot hook can afford where a Redis
|
|
963
|
+
* socket or a Workers binding cannot.
|
|
964
|
+
*/
|
|
965
|
+
assertDriverRegistered(name) {
|
|
966
|
+
this.resolve(name ?? this.defaultStoreName);
|
|
967
|
+
}
|
|
968
|
+
registerDriver(name, factory) {
|
|
969
|
+
this.driverFactories.set(name, factory);
|
|
970
|
+
for (const [storeName, config] of this.configs) if (config.driver === name) this.resolved.delete(storeName);
|
|
971
|
+
}
|
|
972
|
+
getStoreNames() {
|
|
973
|
+
return Array.from(this.configs.keys());
|
|
974
|
+
}
|
|
975
|
+
/**
|
|
976
|
+
* Sweep expired sessions from the default store and from any other store
|
|
977
|
+
* already built, on stores that support it (`deleteExpired`). Stores that
|
|
978
|
+
* were declared but never selected are left unbuilt, so a `redis` entry an
|
|
979
|
+
* environment does not use opens no connection here.
|
|
980
|
+
*/
|
|
981
|
+
async pruneExpired(now = /* @__PURE__ */ new Date()) {
|
|
982
|
+
this.store();
|
|
983
|
+
await Promise.all([...this.resolved.values()].filter(isPrunable).map((store) => store.deleteExpired(now)));
|
|
984
|
+
}
|
|
985
|
+
resolve(storeName) {
|
|
986
|
+
const config = this.configs.get(storeName);
|
|
987
|
+
if (!config) throw new Error(`Session store not found: ${storeName} (declared: ${this.getStoreNames().join(", ")})`);
|
|
988
|
+
const { driver, ...options } = config;
|
|
989
|
+
const factory = this.driverFactories.get(driver);
|
|
990
|
+
if (!factory) throw new Error(`Unknown session driver: ${driver} (session store "${storeName}"). Registered: ${[...this.driverFactories.keys()].join(", ")}. Register it with registerDriver(), or build the manager with the factory that provides it.`);
|
|
991
|
+
return {
|
|
992
|
+
factory,
|
|
993
|
+
options
|
|
994
|
+
};
|
|
995
|
+
}
|
|
996
|
+
};
|
|
997
|
+
//#endregion
|
|
818
998
|
//#region src/http/middleware/csrf.ts
|
|
819
999
|
const CSRF_TOKEN_KEY = "_csrf_token";
|
|
820
1000
|
const CSRF_HEADER_NAME = "X-CSRF-TOKEN";
|
|
@@ -827,7 +1007,6 @@ const DEFAULT_PROTECTED_METHODS = [
|
|
|
827
1007
|
"PATCH",
|
|
828
1008
|
"DELETE"
|
|
829
1009
|
];
|
|
830
|
-
const DEFAULT_COOKIE_SECURE = typeof process !== "undefined" ? process.env.NODE_ENV === "production" : true;
|
|
831
1010
|
const CSRF_CONTEXT_KEY = "guren:csrf-token";
|
|
832
1011
|
const CSRF_PURPOSE = "csrf";
|
|
833
1012
|
function createCsrfSigner() {
|
|
@@ -1021,7 +1200,7 @@ function createCsrfMiddleware(options = {}, cookielessAuthEndpoints) {
|
|
|
1021
1200
|
};
|
|
1022
1201
|
}
|
|
1023
1202
|
function setXsrfCookie(ctx, token, options = {}) {
|
|
1024
|
-
const { path = "/", secure =
|
|
1203
|
+
const { path = "/", secure = defaultCookieSecure(), sameSite = "Lax" } = options;
|
|
1025
1204
|
ctx.header("Set-Cookie", `${XSRF_COOKIE_NAME}=${encodeURIComponent(token)}; Path=${path}; SameSite=${sameSite}${secure ? "; Secure" : ""}`, { append: true });
|
|
1026
1205
|
}
|
|
1027
1206
|
//#endregion
|
|
@@ -1772,10 +1951,20 @@ function requireGuest(options = {}) {
|
|
|
1772
1951
|
//#region src/providers/AuthServiceProvider.ts
|
|
1773
1952
|
const DEFAULT_GUARD = "web";
|
|
1774
1953
|
const DEFAULT_PROVIDER = "users";
|
|
1775
|
-
|
|
1954
|
+
const DOUBLE_SESSION_CONFIG = "Sessions are configured twice: `auth.sessionOptions.store` in createApp() and a \"session\" container binding (SessionProvider). Keep one — the manager, or the explicit store.";
|
|
1955
|
+
/**
|
|
1956
|
+
* Sets up authentication guards, session middleware, and auth context. The
|
|
1957
|
+
* session store may come from a `session` container binding (RFC 0020 §1),
|
|
1958
|
+
* which an app's SessionProvider must make in `register()`: the middleware is
|
|
1959
|
+
* built in `boot()`, before any user provider's own boot runs.
|
|
1960
|
+
*/
|
|
1776
1961
|
var AuthServiceProvider = class extends ServiceProvider {
|
|
1962
|
+
app;
|
|
1963
|
+
attachedSession = false;
|
|
1964
|
+
sessionMiddleware;
|
|
1777
1965
|
register() {
|
|
1778
1966
|
const app = this.container.make("app");
|
|
1967
|
+
this.app = app;
|
|
1779
1968
|
const auth = this.container.make("auth");
|
|
1780
1969
|
if (!auth.guardNames().length) {
|
|
1781
1970
|
auth.registerGuard(DEFAULT_GUARD, createDefaultGuardFactory(DEFAULT_PROVIDER));
|
|
@@ -1783,22 +1972,38 @@ var AuthServiceProvider = class extends ServiceProvider {
|
|
|
1783
1972
|
}
|
|
1784
1973
|
const authOptions = app.authOptions ?? {};
|
|
1785
1974
|
if (authOptions.autoSession !== false && !app.hasAutoSessionAttached()) {
|
|
1786
|
-
|
|
1787
|
-
cookieSecure: typeof process !== "undefined" ? process.env.NODE_ENV === "production" : true,
|
|
1788
|
-
...authOptions.sessionOptions
|
|
1789
|
-
};
|
|
1790
|
-
app.use("*", createSessionMiddleware(sessionOptions));
|
|
1975
|
+
app.use("*", (ctx, next) => (this.sessionMiddleware ??= this.buildSessionMiddleware())(ctx, next));
|
|
1791
1976
|
app.markAutoSessionAttached();
|
|
1977
|
+
this.attachedSession = true;
|
|
1792
1978
|
if (authOptions.autoCsrf !== false) {
|
|
1793
1979
|
const csrfOptions = authOptions.csrfOptions ?? {};
|
|
1794
|
-
app.use("*", createCsrfMiddleware(
|
|
1795
|
-
cookieOptions: { secure: typeof process !== "undefined" ? process.env.NODE_ENV === "production" : true },
|
|
1796
|
-
...csrfOptions
|
|
1797
|
-
}, () => app.getCookielessAuthPaths()));
|
|
1980
|
+
app.use("*", createCsrfMiddleware(csrfOptions, () => app.getCookielessAuthPaths()));
|
|
1798
1981
|
}
|
|
1799
1982
|
}
|
|
1800
1983
|
app.use("*", attachAuthContext((ctx) => auth.createAuthContext(ctx)));
|
|
1801
1984
|
}
|
|
1985
|
+
/**
|
|
1986
|
+
* Every provider has registered, so the manager, a double configuration, a
|
|
1987
|
+
* missing driver, and a bad APP_KEY (the cookie signer) all fail here, not
|
|
1988
|
+
* on the first request. Only the store itself stays lazy. A *deferred*
|
|
1989
|
+
* SessionProvider activates on a make() after boot, so that one shape keeps
|
|
1990
|
+
* the first-request build.
|
|
1991
|
+
*/
|
|
1992
|
+
boot() {
|
|
1993
|
+
if (!this.attachedSession || this.app.isDeferredService("session")) return;
|
|
1994
|
+
this.sessionMiddleware = this.buildSessionMiddleware();
|
|
1995
|
+
}
|
|
1996
|
+
buildSessionMiddleware() {
|
|
1997
|
+
const explicit = this.app.authOptions?.sessionOptions ?? {};
|
|
1998
|
+
const manager = this.container.makeOptional("session");
|
|
1999
|
+
if (manager && explicit.store) throw new Error(DOUBLE_SESSION_CONFIG);
|
|
2000
|
+
manager?.assertDriverRegistered();
|
|
2001
|
+
return createSessionMiddleware({
|
|
2002
|
+
...manager?.options,
|
|
2003
|
+
...explicit,
|
|
2004
|
+
...manager && { store: () => manager.store() }
|
|
2005
|
+
});
|
|
2006
|
+
}
|
|
1802
2007
|
};
|
|
1803
2008
|
function createDefaultGuardFactory(providerName) {
|
|
1804
2009
|
return ({ session, manager }) => {
|
|
@@ -2339,7 +2544,7 @@ function inertiaPageUrl(request) {
|
|
|
2339
2544
|
return `${pathname}${search}`;
|
|
2340
2545
|
}
|
|
2341
2546
|
async function renderDocument$1(page, options) {
|
|
2342
|
-
const defaultEntry = process.env.GUREN_INERTIA_ENTRY
|
|
2547
|
+
const defaultEntry = process.env.GUREN_INERTIA_ENTRY || "/resources/js/app.tsx";
|
|
2343
2548
|
const entry = options.entry ?? defaultEntry;
|
|
2344
2549
|
const title = escapeHtml$1(options.title ?? DEFAULT_TITLE);
|
|
2345
2550
|
const isProduction = process.env.NODE_ENV === "production";
|
|
@@ -2946,6 +3151,10 @@ var Application = class {
|
|
|
2946
3151
|
markAutoSessionAttached() {
|
|
2947
3152
|
this.autoSessionAttached = true;
|
|
2948
3153
|
}
|
|
3154
|
+
/** Whether `key` is supplied by a deferred provider, which only activates on a `make()` after boot. */
|
|
3155
|
+
isDeferredService(key) {
|
|
3156
|
+
return this.providerManager.isDeferredService(key);
|
|
3157
|
+
}
|
|
2949
3158
|
hasAutoSessionAttached() {
|
|
2950
3159
|
return this.autoSessionAttached;
|
|
2951
3160
|
}
|
|
@@ -6725,6 +6934,10 @@ var Command = class {
|
|
|
6725
6934
|
if (!this.container) throw new Error("Container not available");
|
|
6726
6935
|
return this.container.make(key);
|
|
6727
6936
|
}
|
|
6937
|
+
/** `resolve()` for a service a command tolerates being absent; fakes and deferred providers count. */
|
|
6938
|
+
resolveOptional(key) {
|
|
6939
|
+
return this.container?.makeOptional(key);
|
|
6940
|
+
}
|
|
6728
6941
|
getSignature() {
|
|
6729
6942
|
return this.constructor.signature;
|
|
6730
6943
|
}
|
|
@@ -7503,4 +7716,4 @@ function renderEnvironmentSection() {
|
|
|
7503
7716
|
//#region src/index.ts
|
|
7504
7717
|
ensureErrorStackTracePolyfill();
|
|
7505
7718
|
//#endregion
|
|
7506
|
-
export { AGENT_APPROVAL_CONFIG_KEY, AGENT_AUDIT_BINDING, AGENT_REDACTED, AGENT_TOOL_NAME_PATTERN, API_TOKEN_KEY, APPROVAL_STATUS_TOOL_NAME, AUTH_CONTEXT_KEY, AgentApprovalRequested, AgentToolDenied, AgentToolInvoked, Application, ApplicationShutdown, ApplicationStarted, AuthManager, Response$1 as AuthResponse, AuthServiceProvider, AuthenticatableModel, AuthenticationException, AuthorizationException, AuthorizationServiceProvider, AutoDiscovery, BaseFactory, BaseFactory as Factory, BaseSeeder, BaseSeeder as Seeder, BaseUserProvider, BroadcastManager, BroadcastServiceProvider, BufferedOutput, CSP_NONCE_KEY, CSRF_FORM_FIELD, CSRF_HEADER_NAME, CSRF_TOKEN_KEY, CacheCheck, CacheManager, CacheServiceProvider, Channel, Command, ConsoleChannel, ConsoleKernel, Container, Controller, CursorPaginator, CustomCheck, DEFAULT_AGENT_APPROVAL_TTL_MS, DEFAULT_AGENT_AUDIT_PATH, DEFAULT_APPROVAL_CONFIGURE_HINT, DEFAULT_SCOPE_SUBJECT, DailyFileChannel, DatabaseChannel, DatabaseCheck, DefaultHasher, DefaultHasher as Hash, Encrypter, EncryptionServiceProvider, ErrorServiceProvider, Event, EventManager, EventServiceProvider, ExceptionHandler, FailedJobReporter, FieldValidator, FileStore as FileCacheStore, FileChannel, FormRequest, Gate, HealthCheck, HealthManager, HealthServiceProvider, HttpException, I18nManager, I18nServiceProvider, InertiaServiceProvider, Input, Job, JobFailed, JobProcessed, JsonLoader, JsonResource, LOCALE_CONTEXT_KEY, LOG_LEVEL_PRIORITY, Listener, LocalDriver as LocalStorageDriver, LogManager, LogServiceProvider, LogTransport, Logger, Mail, MailChannel, MailManager, MailServiceProvider, MemoryApiTokenStore, MemoryDriver as MemoryBroadcastDriver, MemoryStore as MemoryCacheStore, MemoryChannel, MemoryCheck, MemoryDriver$1 as MemoryDriver, MemoryDriver$1 as MemoryQueueDriver, MemoryEmailVerificationStore, MemoryLoader, MemoryOAuthStateStore, MemoryPasswordResetStore, MemoryRateLimitStore, MemorySessionStore, MemoryDriver$2 as MemoryStorageDriver, MemoryTransport, MessageSigner, MethodNotAllowedException, ModelUserProvider, NodeHasher, NotFoundHttpException, Notification, NotificationManager, NotificationServiceProvider, OAUTH_SESSION_BINDING_KEY, OAuthManager, OAuthServiceProvider, Output, PREFLIGHT_ARGUMENT, PREFLIGHT_TOOL_NAME, Paginator, PendingSchedule, Policy, PresenceChannel, PrivateChannel, ProviderManager, QueueManager, QueueServiceProvider, RESERVED_AGENT_TOOL_NAMES, RedisDriver as RedisBroadcastDriver, RedisStore as RedisCacheStore, RedisCheck, RedisDriver$1 as RedisDriver, RedisDriver$1 as RedisQueueDriver, RequestFinished, RequestReceived, ResendTransport, Resource, ResourceCollection, Router, S3Driver, Schedule, ScheduledTask, Scheduler, SchedulingServiceProvider, ScryptHasher, SeederRunner, ServiceProvider, SessionGuard, SlackChannel, SlidingWindowRateLimitStore, SmtpTransport, SqsDriver, StorageCheck, StorageManager, StorageServiceProvider, SyncDriver, SyncDriver as SyncQueueDriver, TaggedCache, TokenGuard, Translator, UserAuthenticated, UserLoggedOut, VALIDATED_DATA_KEY, ValidationException, Validator, ViewEngine, Worker, abort, abortIf, abortUnless, advertisesStructuredOutput, after, afterOrEqual, agentApprovalExpiredAt, agentApprovalFingerprint, agentApprovalPrincipalKey, agentApprovalStatusAt, agentApprovalUsableAt, agentApprovalVisibleTo, alpha, alphaDash, alphaNum, approvalStatusNotFoundMessage, array as arrayRule, attachAuthContext, authorize as authorizeAbility, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, before, beforeOrEqual, between, boolean as booleanRule, buildAgentApprovalRequest, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildToolRequest, buildVerificationUrl, can, cannot, canonicalizeAgentApprovalInput, check as checkHash, classifyRegistrationScope, clearJobRegistry, clearNotificationRegistry, collect, completeEmailVerification, completePasswordReset, confirmed, createAgentApprovalContext, createAgentAuditRecorder, createAgentInvocationPipeline, createApiToken, createApp, createAuditEmitter, createBearerTokenMiddleware, createBroadcastManager, createCacheManager, createConsoleKernel, createContainer, createCorsMiddleware, createCspMiddleware, createCsrfMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createEncrypter, createEventManager, createExceptionHandler, createFacade, createFacades, createForceHttpsMiddleware, createGate, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createHealthManager, createHostAuthorizationMiddleware, createI18n, createLogManager, createMailManager, createNotificationManager, createOAuthManager, createOAuthState, createPasswordResetToken, createQueueManager, createRateLimitMiddleware, createRedirectSafetyMiddleware, createRedisClient, createScheduler, createSecurityHeaders, createSeederRunner, createSessionMiddleware, createSqsAdapter, createStorageManager, createTypedBroadcaster, createValidator, csrfField, cursorPaginate, custom, customCheck, dailyFileDateStamp, dailyFilePath, dateFormat, date as dateRule, debugErrorMiddleware, decodeCursor, decrypt, defineFactory, defineGate, defineMiddleware, defineModule, definePlugin, definePolicy, deriveAgentTools, deriveAppKey, deriveAppKeyring, describeBuildFailure, detectLocaleMiddleware, different, email as emailRule, encodeCursor, encrypt, endsWith, exchangeOAuthCode, exists, expandToolScopes, fetchOAuthUserProfile, file as fileRule, filterSensitiveData, formatValidationErrors, gateApproval, gatePreflight, gateToolCall, generateAppKey, generateKey, generateOtp, generatePassword, generateSlug, getApiToken, getApiTokenOrFail, getAppKeyringFromEnv, getBroadcastManager, getContainer, getCspNonce, getCsrfToken, getEncrypter, getExceptionHandler, getGate, getI18n, getInertiaSharedPropsResolver, getJob, getLogManager, getMailManager, getNextOccurrence, getNextOccurrences, getNotification, getNotificationManager, getPluralizationRule, getQueueDriver, getRateLimitInfo, getRegisteredJobs, getRequestLocale, getRequestTranslator, getSessionFromContext, getUserApiTokens, getValidatedData, hash, hashPassword, hmac, image as imageRule, inValues, inertia, integer, ip, ipv4, ipv6, isDue, isDueInTimezone, isEmailVerified, isReservedAgentToolName, isSafeRedirectUrl, jsonResponse, json as jsonRule, mail, mapToolResponse, matchDailyFileDate, matchesCron, max, maxFileSize, md5, mimes, min, minFileSize, mountModuleRoutes, needsRehash, normalizeAppKey, notIn, notifyApprovers, nullable, numeric, object as objectRule, paginate, parseApiToken, parseAppKey, parseAuditRecord, parseCron, parseOAuthRedirectUrl, parsePasswordResetUrl, parsePreviousAppKeys, parseRequestPayload, parseSignature, parseToolScope, parseVerificationUrl, pick, pluralizationRules, processJob, quickValidate, quickValidateOrThrow, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, readBearerToken, redactAgentArguments, regex, registerJob, registerNotification, renderDebugPage, renderDocument, renderErrorPage, requestIdMiddleware, requestLoggingMiddleware, requireAuthenticated, requireGuest, requireVerifiedEmail, required, requiredIf, requiredUnless, requiredWith, requiredWithout, resetCalledSeeders, resetRateLimit, resolve, resolveJobName, resolveNotifiableType, revokeAllApiTokens, revokeApiToken, same, sample, sanitizeOAuthRedirect, scopedShape, scopesAllowTool, secureCompare, selectPluralForm, setBroadcastManager, setContainer, setEncrypter, setExceptionHandler, setGate, setI18n, setInertiaDocument, setInertiaSharedProps, setInertiaSsrRenderer, setLogManager, setMailManager, setNotificationManager, setQueueDriver, sha256, sha512, shareInertiaProps, shuffle, signUrl, size, startsWith, string as stringRule, t, tc, toApprovalStatusReport, toAuditRecord, toTimezone, tokenCan, tokenCanAll, tokenCanAny, tryGetI18n, unique, url as urlRule, urlSafeToken, uuid, uuid$1 as uuidRule, validate, validateRequest, validateRequestWith, validateSafe, verifyApiToken, verifyCsrfToken, verifyEmailToken, verifyHmac, verifyOAuthState, verifyPassword, verifyPasswordResetToken, verifySignedUrl, viteAsset, withAuthorization };
|
|
7719
|
+
export { AGENT_APPROVAL_CONFIG_KEY, AGENT_AUDIT_BINDING, AGENT_REDACTED, AGENT_TOOL_NAME_PATTERN, API_TOKEN_KEY, APPROVAL_STATUS_TOOL_NAME, AUTH_CONTEXT_KEY, AgentApprovalRequested, AgentToolDenied, AgentToolInvoked, Application, ApplicationShutdown, ApplicationStarted, AuthManager, Response$1 as AuthResponse, AuthServiceProvider, AuthenticatableModel, AuthenticationException, AuthorizationException, AuthorizationServiceProvider, AutoDiscovery, BaseFactory, BaseFactory as Factory, BaseSeeder, BaseSeeder as Seeder, BaseUserProvider, BroadcastManager, BroadcastServiceProvider, BufferedOutput, CSP_NONCE_KEY, CSRF_FORM_FIELD, CSRF_HEADER_NAME, CSRF_TOKEN_KEY, CacheCheck, CacheManager, CacheServiceProvider, Channel, Command, ConsoleChannel, ConsoleKernel, Container, Controller, CookieSessionStore, CursorPaginator, CustomCheck, DEFAULT_AGENT_APPROVAL_TTL_MS, DEFAULT_AGENT_AUDIT_PATH, DEFAULT_APPROVAL_CONFIGURE_HINT, DEFAULT_SCOPE_SUBJECT, DEFAULT_SESSION_STORE_NAME, DailyFileChannel, DatabaseChannel, DatabaseCheck, DefaultHasher, DefaultHasher as Hash, Encrypter, EncryptionServiceProvider, ErrorServiceProvider, Event, EventManager, EventServiceProvider, ExceptionHandler, FailedJobReporter, FieldValidator, FileStore as FileCacheStore, FileChannel, FormRequest, Gate, HealthCheck, HealthManager, HealthServiceProvider, HttpException, I18nManager, I18nServiceProvider, InertiaServiceProvider, Input, Job, JobFailed, JobProcessed, JsonLoader, JsonResource, LOCALE_CONTEXT_KEY, LOG_LEVEL_PRIORITY, Listener, LocalDriver as LocalStorageDriver, LogManager, LogServiceProvider, LogTransport, Logger, Mail, MailChannel, MailManager, MailServiceProvider, MemoryApiTokenStore, MemoryDriver as MemoryBroadcastDriver, MemoryStore as MemoryCacheStore, MemoryChannel, MemoryCheck, MemoryDriver$1 as MemoryDriver, MemoryDriver$1 as MemoryQueueDriver, MemoryEmailVerificationStore, MemoryLoader, MemoryOAuthStateStore, MemoryPasswordResetStore, MemoryRateLimitStore, MemorySessionStore, MemoryDriver$2 as MemoryStorageDriver, MemoryTransport, MessageSigner, MethodNotAllowedException, ModelUserProvider, NodeHasher, NotFoundHttpException, Notification, NotificationManager, NotificationServiceProvider, OAUTH_SESSION_BINDING_KEY, OAuthManager, OAuthServiceProvider, Output, PER_PROCESS_SESSION_DRIVERS, PREFLIGHT_ARGUMENT, PREFLIGHT_TOOL_NAME, Paginator, PendingSchedule, Policy, PresenceChannel, PrivateChannel, ProviderManager, QueueManager, QueueServiceProvider, RESERVED_AGENT_TOOL_NAMES, RedisDriver as RedisBroadcastDriver, RedisStore as RedisCacheStore, RedisCheck, RedisDriver$1 as RedisDriver, RedisDriver$1 as RedisQueueDriver, RequestFinished, RequestReceived, ResendTransport, Resource, ResourceCollection, Router, S3Driver, SERVERLESS_RUNTIME_LABELS, Schedule, ScheduledTask, Scheduler, SchedulingServiceProvider, ScryptHasher, SeederRunner, ServiceProvider, SessionGuard, SessionManager, SlackChannel, SlidingWindowRateLimitStore, SmtpTransport, SqsDriver, StorageCheck, StorageManager, StorageServiceProvider, SyncDriver, SyncDriver as SyncQueueDriver, TaggedCache, TokenGuard, Translator, UserAuthenticated, UserLoggedOut, VALIDATED_DATA_KEY, ValidationException, Validator, ViewEngine, Worker, abort, abortIf, abortUnless, advertisesStructuredOutput, after, afterOrEqual, agentApprovalExpiredAt, agentApprovalFingerprint, agentApprovalPrincipalKey, agentApprovalStatusAt, agentApprovalUsableAt, agentApprovalVisibleTo, alpha, alphaDash, alphaNum, approvalStatusNotFoundMessage, array as arrayRule, attachAuthContext, authorize as authorizeAbility, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, before, beforeOrEqual, between, boolean as booleanRule, buildAgentApprovalRequest, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildToolRequest, buildVerificationUrl, can, cannot, canonicalizeAgentApprovalInput, check as checkHash, classifyRegistrationScope, clearJobRegistry, clearNotificationRegistry, collect, completeEmailVerification, completePasswordReset, confirmed, createAgentApprovalContext, createAgentAuditRecorder, createAgentInvocationPipeline, createApiToken, createApp, createAuditEmitter, createBearerTokenMiddleware, createBroadcastManager, createCacheManager, createConsoleKernel, createContainer, createCorsMiddleware, createCspMiddleware, createCsrfMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createEncrypter, createEventManager, createExceptionHandler, createFacade, createFacades, createForceHttpsMiddleware, createGate, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createHealthManager, createHostAuthorizationMiddleware, createI18n, createLogManager, createMailManager, createNotificationManager, createOAuthManager, createOAuthState, createPasswordResetToken, createQueueManager, createRateLimitMiddleware, createRedirectSafetyMiddleware, createRedisClient, createScheduler, createSecurityHeaders, createSeederRunner, createSessionMiddleware, createSqsAdapter, createStorageManager, createTypedBroadcaster, createValidator, csrfField, cursorPaginate, custom, customCheck, dailyFileDateStamp, dailyFilePath, dateFormat, date as dateRule, debugErrorMiddleware, decodeCursor, decrypt, defineFactory, defineGate, defineMiddleware, defineModule, definePlugin, definePolicy, deriveAgentTools, deriveAppKey, deriveAppKeyring, describeBuildFailure, detectLocaleMiddleware, detectServerlessRuntime, different, email as emailRule, encodeCursor, encrypt, endsWith, exchangeOAuthCode, exists, expandToolScopes, fetchOAuthUserProfile, file as fileRule, filterSensitiveData, formatValidationErrors, gateApproval, gatePreflight, gateToolCall, generateAppKey, generateKey, generateOtp, generatePassword, generateSlug, getApiToken, getApiTokenOrFail, getAppKeyringFromEnv, getBroadcastManager, getContainer, getCspNonce, getCsrfToken, getEncrypter, getExceptionHandler, getGate, getI18n, getInertiaSharedPropsResolver, getJob, getLogManager, getMailManager, getNextOccurrence, getNextOccurrences, getNotification, getNotificationManager, getPluralizationRule, getQueueDriver, getRateLimitInfo, getRegisteredJobs, getRequestLocale, getRequestTranslator, getSessionFromContext, getUserApiTokens, getValidatedData, hash, hashPassword, hmac, image as imageRule, inValues, inertia, integer, ip, ipv4, ipv6, isDue, isDueInTimezone, isEmailVerified, isReservedAgentToolName, isSafeRedirectUrl, jsonResponse, json as jsonRule, mail, mapToolResponse, matchDailyFileDate, matchesCron, max, maxFileSize, md5, mimes, min, minFileSize, mountModuleRoutes, needsRehash, normalizeAppKey, notIn, notifyApprovers, nullable, numeric, object as objectRule, paginate, parseApiToken, parseAppKey, parseAuditRecord, parseCron, parseOAuthRedirectUrl, parsePasswordResetUrl, parsePreviousAppKeys, parseRequestPayload, parseSignature, parseToolScope, parseVerificationUrl, pick, pluralizationRules, processJob, quickValidate, quickValidateOrThrow, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, readBearerToken, redactAgentArguments, regex, registerJob, registerNotification, renderDebugPage, renderDocument, renderErrorPage, requestIdMiddleware, requestLoggingMiddleware, requireAuthenticated, requireGuest, requireVerifiedEmail, required, requiredIf, requiredUnless, requiredWith, requiredWithout, resetCalledSeeders, resetRateLimit, resolve, resolveJobName, resolveNotifiableType, revokeAllApiTokens, revokeApiToken, same, sample, sanitizeOAuthRedirect, scopedShape, scopesAllowTool, secureCompare, selectPluralForm, setBroadcastManager, setContainer, setEncrypter, setExceptionHandler, setGate, setI18n, setInertiaDocument, setInertiaSharedProps, setInertiaSsrRenderer, setLogManager, setMailManager, setNotificationManager, setQueueDriver, sha256, sha512, shareInertiaProps, shuffle, signUrl, size, startsWith, string as stringRule, t, tc, toApprovalStatusReport, toAuditRecord, toTimezone, tokenCan, tokenCanAll, tokenCanAny, tryGetI18n, unique, url as urlRule, urlSafeToken, uuid, uuid$1 as uuidRule, validate, validateRequest, validateRequestWith, validateSafe, verifyApiToken, verifyCsrfToken, verifyEmailToken, verifyHmac, verifyOAuthState, verifyPassword, verifyPasswordResetToken, verifySignedUrl, viteAsset, withAuthorization };
|
package/dist/lambda/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { r as getJob } from "../Job-
|
|
1
|
+
import { r as getJob } from "../Job-CvDwk2Gj.js";
|
|
2
|
+
import { n as detectServerlessRuntime } from "../serverless-D96rJb6x.js";
|
|
2
3
|
import { handle } from "hono/aws-lambda";
|
|
3
4
|
//#region src/lambda/index.ts
|
|
4
5
|
/** Create an AWS Lambda handler from an already booted Guren application. */
|
|
@@ -52,16 +53,16 @@ function createConsoleHandler(kernel) {
|
|
|
52
53
|
* `AWS_LAMBDA_FUNCTION_NAME` variable AWS sets in every Lambda runtime.
|
|
53
54
|
*/
|
|
54
55
|
function isLambda() {
|
|
55
|
-
return
|
|
56
|
+
return detectServerlessRuntime()?.id === "lambda";
|
|
56
57
|
}
|
|
57
58
|
/** Get Lambda environment metadata, or null if not running on Lambda. */
|
|
58
59
|
function getLambdaContext() {
|
|
59
60
|
if (!isLambda()) return null;
|
|
60
61
|
return {
|
|
61
62
|
functionName: process.env.AWS_LAMBDA_FUNCTION_NAME,
|
|
62
|
-
functionVersion: process.env.AWS_LAMBDA_FUNCTION_VERSION
|
|
63
|
-
memorySize: parseInt(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE
|
|
64
|
-
region: process.env.AWS_REGION
|
|
63
|
+
functionVersion: process.env.AWS_LAMBDA_FUNCTION_VERSION || "$LATEST",
|
|
64
|
+
memorySize: parseInt(process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE || "128", 10),
|
|
65
|
+
region: process.env.AWS_REGION || process.env.AWS_DEFAULT_REGION || "us-east-1",
|
|
65
66
|
logGroup: process.env.AWS_LAMBDA_LOG_GROUP_NAME,
|
|
66
67
|
logStream: process.env.AWS_LAMBDA_LOG_STREAM_NAME,
|
|
67
68
|
tmpDir: "/tmp"
|
package/dist/logging/index.js
CHANGED
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { n as filterSensitiveData, t as Logger } from "../Logger-DFifRAtc.js";
|
|
2
|
+
import { a as DailyFileChannel, c as matchDailyFileDate, d as LOG_LEVEL_PRIORITY, i as setLogManager, l as FileChannel, n as createLogManager, o as dailyFileDateStamp, r as getLogManager, s as dailyFilePath, t as LogManager, u as ConsoleChannel } from "../logging-DXmqqUl4.js";
|
|
2
3
|
export { ConsoleChannel, DailyFileChannel, FileChannel, LOG_LEVEL_PRIORITY, LogManager, Logger, createLogManager, dailyFileDateStamp, dailyFilePath, filterSensitiveData, getLogManager, matchDailyFileDate, setLogManager };
|