@guren/server 1.0.0-rc.23 → 1.0.0-rc.25

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.
@@ -1,6 +1,6 @@
1
1
  import * as hono from 'hono';
2
2
  import { Context, MiddlewareHandler, Hono, Next, ExecutionContext } from 'hono';
3
- import { A as AuthManager, O as OAuthManager, a as AuthContext, b as ApiToken, C as CreateSessionMiddlewareOptions } from './api-token-BGOsfuI9.js';
3
+ import { A as AuthManager, O as OAuthManager, a as AuthContext, b as ApiToken, C as CreateSessionMiddlewareOptions } from './api-token-ChekhpB7.js';
4
4
  import { InlineConfig, ViteDevServer } from 'vite';
5
5
  import { E as EventManager } from './EventManager-CmIoLt7r.js';
6
6
  import { C as CacheManager } from './CacheManager-BkvHEOZX.js';
@@ -1,4 +1,4 @@
1
- import { C as Container } from './Application-D4_90raL.js';
1
+ import { C as Container } from './Application-Hlryz3ln.js';
2
2
 
3
3
  /**
4
4
  * Parsed argument definition.
@@ -84,6 +84,12 @@ interface UserProvider<User = Authenticatable> {
84
84
  getId(user: User): unknown;
85
85
  setRememberToken?(user: User, token: string | null): Promise<void> | void;
86
86
  getRememberToken?(user: User): Promise<string | null> | string | null;
87
+ /**
88
+ * Strip fields that must never leave the auth layer (password hashes,
89
+ * remember tokens, model `hidden` fields) from a user record before it
90
+ * is cached or handed to application code via guard.user().
91
+ */
92
+ sanitize?(user: User): User;
87
93
  }
88
94
  interface GuardContext {
89
95
  ctx: Context;
@@ -160,6 +166,13 @@ declare class ModelUserProvider<User extends Authenticatable = Authenticatable>
160
166
  retrieveByCredentials(credentials: AuthCredentials): Promise<User | null>;
161
167
  validateCredentials(user: User, credentials: AuthCredentials): Promise<boolean>;
162
168
  getId(user: User): unknown;
169
+ /**
170
+ * Strip the password hash, remember token, and the model's `hidden`
171
+ * fields before the record leaves the auth layer. Credential
172
+ * validation happens on the raw record before sanitizing, so this
173
+ * never affects login — only what `auth.user()` exposes.
174
+ */
175
+ sanitize(user: User): User;
163
176
  setRememberToken(user: User, token: string | null): Promise<void>;
164
177
  getRememberToken(user: User): Promise<string | null>;
165
178
  }
@@ -1,5 +1,5 @@
1
- import { g as Authenticatable, G as Guard, U as UserProvider, S as Session, e as AuthCredentials, a7 as PasswordHasher } from '../api-token-BGOsfuI9.js';
2
- export { c as API_TOKEN_KEY, b as ApiToken, d as ApiTokenStore, a8 as AttachContextOptions, a as AuthContext, A as AuthManager, a9 as AuthManagerContract, f as AuthManagerOptions, B as BaseUserProvider, h as BearerTokenMiddlewareOptions, i as CreateApiTokenOptions, j as CreateApiTokenResult, k as GuardContext, l as GuardFactory, M as MemoryApiTokenStore, m as MemoryOAuthStateStore, o as ModelUserProvider, p as OAuthAuthorizeOptions, q as OAuthCallbackPayload, O as OAuthManager, r as OAuthManagerOptions, s as OAuthProviderConfig, t as OAuthProviderFactoryInput, u as OAuthStateConfig, v as OAuthStatePayload, w as OAuthStateStore, x as OAuthTokenResult, y as OAuthUserProfile, P as ProviderFactory, E as buildOAuthAuthorizeUrl, F as buildOAuthRedirectUrl, H as createApiToken, I as createBearerTokenMiddleware, J as createDiscordOAuthProviderConfig, K as createGitHubOAuthProviderConfig, L as createGoogleOAuthProviderConfig, N as createOAuthManager, Q as createOAuthState, T as exchangeOAuthCode, V as fetchOAuthUserProfile, W as getApiToken, X as getApiTokenOrFail, Z as getUserApiTokens, _ as parseApiToken, $ as parseOAuthRedirectUrl, a0 as revokeAllApiTokens, a1 as revokeApiToken, a2 as tokenCan, a3 as tokenCanAll, a4 as tokenCanAny, a5 as verifyApiToken, a6 as verifyOAuthState } from '../api-token-BGOsfuI9.js';
1
+ import { g as Authenticatable, G as Guard, U as UserProvider, S as Session, e as AuthCredentials, a7 as PasswordHasher } from '../api-token-ChekhpB7.js';
2
+ export { c as API_TOKEN_KEY, b as ApiToken, d as ApiTokenStore, a8 as AttachContextOptions, a as AuthContext, A as AuthManager, a9 as AuthManagerContract, f as AuthManagerOptions, B as BaseUserProvider, h as BearerTokenMiddlewareOptions, i as CreateApiTokenOptions, j as CreateApiTokenResult, k as GuardContext, l as GuardFactory, M as MemoryApiTokenStore, m as MemoryOAuthStateStore, o as ModelUserProvider, p as OAuthAuthorizeOptions, q as OAuthCallbackPayload, O as OAuthManager, r as OAuthManagerOptions, s as OAuthProviderConfig, t as OAuthProviderFactoryInput, u as OAuthStateConfig, v as OAuthStatePayload, w as OAuthStateStore, x as OAuthTokenResult, y as OAuthUserProfile, P as ProviderFactory, E as buildOAuthAuthorizeUrl, F as buildOAuthRedirectUrl, H as createApiToken, I as createBearerTokenMiddleware, J as createDiscordOAuthProviderConfig, K as createGitHubOAuthProviderConfig, L as createGoogleOAuthProviderConfig, N as createOAuthManager, Q as createOAuthState, T as exchangeOAuthCode, V as fetchOAuthUserProfile, W as getApiToken, X as getApiTokenOrFail, Z as getUserApiTokens, _ as parseApiToken, $ as parseOAuthRedirectUrl, a0 as revokeAllApiTokens, a1 as revokeApiToken, a2 as tokenCan, a3 as tokenCanAll, a4 as tokenCanAny, a5 as verifyApiToken, a6 as verifyOAuthState } from '../api-token-ChekhpB7.js';
3
3
  import { PlainObject, Model } from '@guren/orm';
4
4
  import 'hono';
5
5
 
@@ -18,6 +18,8 @@ declare class SessionGuard<User extends Authenticatable = Authenticatable> imple
18
18
  private sessionKey;
19
19
  private rememberSessionKey;
20
20
  private loadRememberedUser;
21
+ /** Strip auth-internal fields before a record is cached or exposed. */
22
+ private sanitizeUser;
21
23
  private resolveUser;
22
24
  check(): Promise<boolean>;
23
25
  guest(): Promise<boolean>;
@@ -54,7 +54,7 @@ import {
54
54
  verifyEmailToken,
55
55
  verifyOAuthState,
56
56
  verifyPasswordResetToken
57
- } from "../chunk-BJXAHGDR.js";
57
+ } from "../chunk-J2ZAO6TV.js";
58
58
  import "../chunk-DAQKYKLH.js";
59
59
  import "../chunk-ONSDE37A.js";
60
60
  import "../chunk-QQKTH5KX.js";
@@ -9,7 +9,7 @@ import {
9
9
  createTypedBroadcaster,
10
10
  getBroadcastManager,
11
11
  setBroadcastManager
12
- } from "../chunk-AFI3A6GB.js";
12
+ } from "../chunk-44F7JQ7I.js";
13
13
  export {
14
14
  BroadcastManager,
15
15
  Channel,
@@ -490,6 +490,14 @@ async function parseRequestPayload(ctx) {
490
490
  }
491
491
  return {};
492
492
  }
493
+ function flattenRequestQueries(ctx) {
494
+ const queries = ctx.req.queries();
495
+ const flat = {};
496
+ for (const [key, values] of Object.entries(queries)) {
497
+ flat[key] = values.length === 1 ? values[0] : values;
498
+ }
499
+ return flat;
500
+ }
493
501
  function formatValidationErrors(error, fallbackMessage = "The provided data is invalid.") {
494
502
  const errors = {};
495
503
  for (const issue of error.issues ?? []) {
@@ -927,6 +935,7 @@ function wrapChannel(name, channel) {
927
935
 
928
936
  export {
929
937
  parseRequestPayload,
938
+ flattenRequestQueries,
930
939
  formatValidationErrors,
931
940
  Channel,
932
941
  PrivateChannel,
@@ -270,10 +270,10 @@ function getSessionFromContext(ctx) {
270
270
 
271
271
  // src/auth/RequestAuthContext.ts
272
272
  var RequestAuthContext = class {
273
- constructor(manager, ctx, currentSession, resolveGuard) {
273
+ constructor(manager, ctx, resolveSession, resolveGuard) {
274
274
  this.manager = manager;
275
275
  this.ctx = ctx;
276
- this.currentSession = currentSession;
276
+ this.resolveSession = resolveSession;
277
277
  this.resolveGuard = resolveGuard;
278
278
  }
279
279
  guardCache = /* @__PURE__ */ new Map();
@@ -286,7 +286,7 @@ var RequestAuthContext = class {
286
286
  return this.guardCache.get(key);
287
287
  }
288
288
  session() {
289
- return this.currentSession;
289
+ return this.resolveSession();
290
290
  }
291
291
  async check() {
292
292
  return this.guard().check();
@@ -455,11 +455,31 @@ var ModelUserProvider = class extends BaseUserProvider {
455
455
  getId(user) {
456
456
  return user[this.idColumn];
457
457
  }
458
+ /**
459
+ * Strip the password hash, remember token, and the model's `hidden`
460
+ * fields before the record leaves the auth layer. Credential
461
+ * validation happens on the raw record before sanitizing, so this
462
+ * never affects login — only what `auth.user()` exposes.
463
+ */
464
+ sanitize(user) {
465
+ const blocked = /* @__PURE__ */ new Set([
466
+ this.passwordColumn,
467
+ this.rememberTokenColumn,
468
+ ...this.model.hidden ?? []
469
+ ]);
470
+ const clean = {};
471
+ for (const [key, value] of Object.entries(user)) {
472
+ if (!blocked.has(key)) {
473
+ clean[key] = value;
474
+ }
475
+ }
476
+ return clean;
477
+ }
458
478
  async setRememberToken(user, token) {
459
479
  if (typeof user[this.rememberTokenColumn] !== "undefined") {
460
480
  ;
461
481
  user[this.rememberTokenColumn] = token;
462
- await this.model.update({ [this.idColumn]: this.getId(user) }, { [this.rememberTokenColumn]: token });
482
+ await this.model.forceUpdate({ [this.idColumn]: this.getId(user) }, { [this.rememberTokenColumn]: token });
463
483
  }
464
484
  }
465
485
  async getRememberToken(user) {
@@ -554,9 +574,14 @@ var SessionGuard = class {
554
574
  this.currentSession.forget(this.rememberSessionKey());
555
575
  return null;
556
576
  }
557
- this.cachedUser = user;
558
577
  await this.provider.setRememberToken?.(user, rememberToken);
559
- return user;
578
+ const sanitized = this.sanitizeUser(user);
579
+ this.cachedUser = sanitized;
580
+ return sanitized;
581
+ }
582
+ /** Strip auth-internal fields before a record is cached or exposed. */
583
+ sanitizeUser(user) {
584
+ return this.provider.sanitize ? this.provider.sanitize(user) : user;
560
585
  }
561
586
  async resolveUser() {
562
587
  if (this.cachedUser !== void 0) {
@@ -579,8 +604,9 @@ var SessionGuard = class {
579
604
  this.cachedUser = null;
580
605
  return null;
581
606
  }
582
- this.cachedUser = user;
583
- return user;
607
+ const sanitized = this.sanitizeUser(user);
608
+ this.cachedUser = sanitized;
609
+ return sanitized;
584
610
  }
585
611
  async check() {
586
612
  return await this.resolveUser() !== null;
@@ -616,7 +642,7 @@ var SessionGuard = class {
616
642
  session.regenerate();
617
643
  const identifier = this.provider.getId(castUser);
618
644
  session.set(this.sessionKey(), identifier);
619
- this.cachedUser = castUser;
645
+ this.cachedUser = this.sanitizeUser(castUser);
620
646
  if (remember) {
621
647
  await this.remember(castUser);
622
648
  } else {
@@ -705,16 +731,16 @@ var AuthManager = class {
705
731
  }
706
732
  createAuthContext(ctx, options = {}) {
707
733
  const guardName = options.guard ?? this.defaultGuard;
708
- const session = getSessionFromContext(ctx);
734
+ const resolveSession = () => getSessionFromContext(ctx);
709
735
  const guardFactory = (name) => {
710
736
  const targetName = name ?? guardName;
711
737
  return this.createGuard(targetName, {
712
738
  ctx,
713
- session,
739
+ session: resolveSession(),
714
740
  manager: this
715
741
  });
716
742
  };
717
- return new RequestAuthContext(this, ctx, session, guardFactory);
743
+ return new RequestAuthContext(this, ctx, resolveSession, guardFactory);
718
744
  }
719
745
  async attempt(name, ctx, credentials, remember) {
720
746
  const guard = this.createAuthContext(ctx, { guard: name }).guard(name);
@@ -6,7 +6,7 @@ import standard from "figlet/importable-fonts/Standard.js";
6
6
  // package.json
7
7
  var package_default = {
8
8
  name: "@guren/server",
9
- version: "1.0.0-rc.23",
9
+ version: "1.0.0-rc.25",
10
10
  type: "module",
11
11
  license: "MIT",
12
12
  repository: {
@@ -111,8 +111,8 @@ var package_default = {
111
111
  test: "bun test"
112
112
  },
113
113
  dependencies: {
114
- "@guren/inertia-client": "^1.0.0-rc.22",
115
- "@guren/orm": "^1.0.0-rc.24",
114
+ "@guren/inertia-client": "^1.0.0-rc.24",
115
+ "@guren/orm": "^1.0.0-rc.26",
116
116
  "@modelcontextprotocol/sdk": "^1.27.1",
117
117
  chalk: "^5.3.0",
118
118
  consola: "^3.4.2",
package/dist/index.d.ts CHANGED
@@ -1,10 +1,10 @@
1
- import { E as ErrorResponse, S as ServiceProvider, C as Container, c as ServiceBindings, Q as QueueManager, N as NotificationManager } from './Application-D4_90raL.js';
2
- export { A as Application, d as ApplicationListenOptions, e as AuthPayload, f as CSRF_FORM_FIELD, g as CSRF_HEADER_NAME, h as CSRF_TOKEN_KEY, P as ContainerProvider, i as ContextualBinding, j as ContextualBindingBuilder, k as ContextualNeedsBuilder, m as Controller, n as ControllerInertiaProps, o as CsrfOptions, p as DatabaseChannelOptions, q as DatabaseNotification, r as ExceptionClass, t as ExceptionHandler, u as ExceptionHandlerOptions, v as ExceptionRenderer, w as ExceptionReporter, F as FailedJob, H as HostAuthorizationOptions, x as HstsOptions, I as InertiaOptions, y as InertiaPagePayload, z as InertiaResponse, B as InertiaSharedProps, J as InertiaSsrContext, K as InertiaSsrOptions, L as InertiaSsrRenderer, M as InertiaSsrResult, O as InferInertiaProps, R as Job, T as JobClass, U as JobFailureHandler, V as JobHandler, W as JobOptions, X as Notifiable, Y as Notification, Z as NotificationAttachment, _ as NotificationChannel, $ as NotificationChannelFactory, a0 as NotificationClass, a1 as NotificationMailMessage, a2 as NotificationManagerOptions, a3 as ProviderManager, a4 as QueueConfig, a5 as QueueDriver, a6 as QueueDriverFactory, a7 as QueuedJob, a8 as RendererRegistration, a9 as ResolvedSharedInertiaProps, aa as ResourceRouteOptions, ab as RouteBuilder, ac as RouteContractOptions, ad as RouteDefinition, ae as RouteOpenApiMetadata, af as RouteResourceAction, ag as Router, ah as SecurityHeadersOptions, ai as SentNotification, aj as ServiceBinding, ak as ServiceClass, al as ServiceFactory, am as ServiceProviderClass, an as ServiceProviderConstructor, ao as ServiceProviderOptions, ap as SharedInertiaPropsResolver, aq as SlackAttachment, ar as SlackBlock, as as SlackMessage, at as VALIDATED_DATA_KEY, au as ValidateRequestOptions, av as ValidationSchema, aw as WorkerOptions, ax as abort, ay as abortIf, az as abortUnless, aA as clearJobRegistry, aB as createApp, aC as createContainer, aD as createCsrfMiddleware, aE as createExceptionHandler, aF as createHostAuthorizationMiddleware, aG as createNotificationManager, aH as createQueueManager, aI as createSecurityHeaders, aJ as csrfField, aK as formatValidationErrors, aL as getContainer, aM as getCsrfToken, aN as getExceptionHandler, aO as getInertiaSharedPropsResolver, aP as getJob, aQ as getNotificationManager, aR as getQueueDriver, aS as getRegisteredJobs, aT as getValidatedData, aU as inertia, aV as parseRequestPayload, aW as registerJob, aX as resolve, aY as setContainer, aZ as setExceptionHandler, a_ as setInertiaSharedProps, a$ as setNotificationManager, b0 as setQueueDriver, b1 as shareInertiaProps, b2 as validate, b3 as validateRequest, b4 as validateRequestWith, b5 as validateSafe, b6 as verifyCsrfToken } from './Application-D4_90raL.js';
1
+ import { E as ErrorResponse, S as ServiceProvider, C as Container, c as ServiceBindings, Q as QueueManager, N as NotificationManager } from './Application-Hlryz3ln.js';
2
+ export { A as Application, d as ApplicationListenOptions, e as AuthPayload, f as CSRF_FORM_FIELD, g as CSRF_HEADER_NAME, h as CSRF_TOKEN_KEY, P as ContainerProvider, i as ContextualBinding, j as ContextualBindingBuilder, k as ContextualNeedsBuilder, m as Controller, n as ControllerInertiaProps, o as CsrfOptions, p as DatabaseChannelOptions, q as DatabaseNotification, r as ExceptionClass, t as ExceptionHandler, u as ExceptionHandlerOptions, v as ExceptionRenderer, w as ExceptionReporter, F as FailedJob, H as HostAuthorizationOptions, x as HstsOptions, I as InertiaOptions, y as InertiaPagePayload, z as InertiaResponse, B as InertiaSharedProps, J as InertiaSsrContext, K as InertiaSsrOptions, L as InertiaSsrRenderer, M as InertiaSsrResult, O as InferInertiaProps, R as Job, T as JobClass, U as JobFailureHandler, V as JobHandler, W as JobOptions, X as Notifiable, Y as Notification, Z as NotificationAttachment, _ as NotificationChannel, $ as NotificationChannelFactory, a0 as NotificationClass, a1 as NotificationMailMessage, a2 as NotificationManagerOptions, a3 as ProviderManager, a4 as QueueConfig, a5 as QueueDriver, a6 as QueueDriverFactory, a7 as QueuedJob, a8 as RendererRegistration, a9 as ResolvedSharedInertiaProps, aa as ResourceRouteOptions, ab as RouteBuilder, ac as RouteContractOptions, ad as RouteDefinition, ae as RouteOpenApiMetadata, af as RouteResourceAction, ag as Router, ah as SecurityHeadersOptions, ai as SentNotification, aj as ServiceBinding, ak as ServiceClass, al as ServiceFactory, am as ServiceProviderClass, an as ServiceProviderConstructor, ao as ServiceProviderOptions, ap as SharedInertiaPropsResolver, aq as SlackAttachment, ar as SlackBlock, as as SlackMessage, at as VALIDATED_DATA_KEY, au as ValidateRequestOptions, av as ValidationSchema, aw as WorkerOptions, ax as abort, ay as abortIf, az as abortUnless, aA as clearJobRegistry, aB as createApp, aC as createContainer, aD as createCsrfMiddleware, aE as createExceptionHandler, aF as createHostAuthorizationMiddleware, aG as createNotificationManager, aH as createQueueManager, aI as createSecurityHeaders, aJ as csrfField, aK as formatValidationErrors, aL as getContainer, aM as getCsrfToken, aN as getExceptionHandler, aO as getInertiaSharedPropsResolver, aP as getJob, aQ as getNotificationManager, aR as getQueueDriver, aS as getRegisteredJobs, aT as getValidatedData, aU as inertia, aV as parseRequestPayload, aW as registerJob, aX as resolve, aY as setContainer, aZ as setExceptionHandler, a_ as setInertiaSharedProps, a$ as setNotificationManager, b0 as setQueueDriver, b1 as shareInertiaProps, b2 as validate, b3 as validateRequest, b4 as validateRequestWith, b5 as validateSafe, b6 as verifyCsrfToken } from './Application-Hlryz3ln.js';
3
3
  import * as hono from 'hono';
4
4
  import { Context, MiddlewareHandler } from 'hono';
5
5
  export { Context } from 'hono';
6
- import { a as AuthContext } from './api-token-BGOsfuI9.js';
7
- export { c as API_TOKEN_KEY, b as ApiToken, d as ApiTokenStore, e as AuthCredentials, A as AuthManager, f as AuthManagerOptions, g as Authenticatable, B as BaseUserProvider, h as BearerTokenMiddlewareOptions, i as CreateApiTokenOptions, j as CreateApiTokenResult, G as Guard, k as GuardContext, l as GuardFactory, M as MemoryApiTokenStore, m as MemoryOAuthStateStore, n as MemorySessionStore, o as ModelUserProvider, p as OAuthAuthorizeOptions, q as OAuthCallbackPayload, O as OAuthManager, r as OAuthManagerOptions, s as OAuthProviderConfig, t as OAuthProviderFactoryInput, u as OAuthStateConfig, v as OAuthStatePayload, w as OAuthStateStore, x as OAuthTokenResult, y as OAuthUserProfile, P as ProviderFactory, S as Session, z as SessionData, D as SessionStore, U as UserProvider, E as buildOAuthAuthorizeUrl, F as buildOAuthRedirectUrl, H as createApiToken, I as createBearerTokenMiddleware, J as createDiscordOAuthProviderConfig, K as createGitHubOAuthProviderConfig, L as createGoogleOAuthProviderConfig, N as createOAuthManager, Q as createOAuthState, R as createSessionMiddleware, T as exchangeOAuthCode, V as fetchOAuthUserProfile, W as getApiToken, X as getApiTokenOrFail, Y as getSessionFromContext, Z as getUserApiTokens, _ as parseApiToken, $ as parseOAuthRedirectUrl, a0 as revokeAllApiTokens, a1 as revokeApiToken, a2 as tokenCan, a3 as tokenCanAll, a4 as tokenCanAny, a5 as verifyApiToken, a6 as verifyOAuthState } from './api-token-BGOsfuI9.js';
6
+ import { a as AuthContext } from './api-token-ChekhpB7.js';
7
+ export { c as API_TOKEN_KEY, b as ApiToken, d as ApiTokenStore, e as AuthCredentials, A as AuthManager, f as AuthManagerOptions, g as Authenticatable, B as BaseUserProvider, h as BearerTokenMiddlewareOptions, i as CreateApiTokenOptions, j as CreateApiTokenResult, G as Guard, k as GuardContext, l as GuardFactory, M as MemoryApiTokenStore, m as MemoryOAuthStateStore, n as MemorySessionStore, o as ModelUserProvider, p as OAuthAuthorizeOptions, q as OAuthCallbackPayload, O as OAuthManager, r as OAuthManagerOptions, s as OAuthProviderConfig, t as OAuthProviderFactoryInput, u as OAuthStateConfig, v as OAuthStatePayload, w as OAuthStateStore, x as OAuthTokenResult, y as OAuthUserProfile, P as ProviderFactory, S as Session, z as SessionData, D as SessionStore, U as UserProvider, E as buildOAuthAuthorizeUrl, F as buildOAuthRedirectUrl, H as createApiToken, I as createBearerTokenMiddleware, J as createDiscordOAuthProviderConfig, K as createGitHubOAuthProviderConfig, L as createGoogleOAuthProviderConfig, N as createOAuthManager, Q as createOAuthState, R as createSessionMiddleware, T as exchangeOAuthCode, V as fetchOAuthUserProfile, W as getApiToken, X as getApiTokenOrFail, Y as getSessionFromContext, Z as getUserApiTokens, _ as parseApiToken, $ as parseOAuthRedirectUrl, a0 as revokeAllApiTokens, a1 as revokeApiToken, a2 as tokenCan, a3 as tokenCanAll, a4 as tokenCanAny, a5 as verifyApiToken, a6 as verifyOAuthState } from './api-token-ChekhpB7.js';
8
8
  export { AuthenticatableModel, EmailVerificationConfig, EmailVerificationToken, EmailVerificationTokenResult, EmailVerificationTokenStore, ScryptHasher as Hash, MemoryEmailVerificationStore, MemoryPasswordResetStore, NodeHasher, PasswordResetConfig, PasswordResetTokenResult, PasswordResetTokenStore, ScryptHasher, SessionGuard, buildPasswordResetUrl, buildVerificationUrl, completeEmailVerification, completePasswordReset, createEmailVerificationToken, createPasswordResetToken, isEmailVerified, parsePasswordResetUrl, parseVerificationUrl, requireVerifiedEmail, verifyEmailToken, verifyPasswordResetToken } from './auth/index.js';
9
9
  export { M as Middleware, d as defineMiddleware, j as jsonResponse } from './index-9_Jzj5jo.js';
10
10
  import { E as EventManager } from './EventManager-CmIoLt7r.js';
@@ -35,8 +35,8 @@ export { DatabaseChannel, MailChannel, MailChannelOptions, MemoryChannel, SlackC
35
35
  import { B as BroadcastManager } from './BroadcastManager-CGWl9rUO.js';
36
36
  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-CGWl9rUO.js';
37
37
  export { RedisClient as BroadcastRedisClient, RedisDriverOptions as BroadcastRedisDriverOptions, MemoryDriver as MemoryBroadcastDriver, RedisDriver as RedisBroadcastDriver, createTypedBroadcaster } from './broadcasting/index.js';
38
- import { I as InputInterface, P as ParsedSignature, O as OptionDefinition, a as CommandInstance, b as OutputInterface } from './ConsoleKernel-BPYcP-2f.js';
39
- 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-BPYcP-2f.js';
38
+ import { I as InputInterface, P as ParsedSignature, O as OptionDefinition, a as CommandInstance, b as OutputInterface } from './ConsoleKernel-CVvaK-I6.js';
39
+ 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-CVvaK-I6.js';
40
40
  import * as readline from 'readline';
41
41
  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';
42
42
  export { AuthorizedContext, Policy, authorizeAllMiddleware, authorizeMiddleware, authorizeResourceMiddleware, definePolicy, withAuthorization } from './authorization/index.js';
package/dist/index.js CHANGED
@@ -102,7 +102,7 @@ import {
102
102
  logDevServerBanner,
103
103
  parseImportMap,
104
104
  startViteDevServer
105
- } from "./chunk-NFGDKY3L.js";
105
+ } from "./chunk-X4E2I4Z5.js";
106
106
  import {
107
107
  API_TOKEN_KEY,
108
108
  AuthManager,
@@ -155,7 +155,7 @@ import {
155
155
  verifyEmailToken,
156
156
  verifyOAuthState,
157
157
  verifyPasswordResetToken
158
- } from "./chunk-BJXAHGDR.js";
158
+ } from "./chunk-J2ZAO6TV.js";
159
159
  import {
160
160
  Gate,
161
161
  Policy,
@@ -200,11 +200,12 @@ import {
200
200
  RedisDriver as RedisDriver2,
201
201
  createBroadcastManager,
202
202
  createTypedBroadcaster,
203
+ flattenRequestQueries,
203
204
  formatValidationErrors,
204
205
  getBroadcastManager,
205
206
  parseRequestPayload,
206
207
  setBroadcastManager
207
- } from "./chunk-AFI3A6GB.js";
208
+ } from "./chunk-44F7JQ7I.js";
208
209
  import {
209
210
  CacheManager,
210
211
  FileStore,
@@ -623,7 +624,7 @@ function createContractHandler(path, options, handler) {
623
624
  if (params instanceof Response) {
624
625
  return params;
625
626
  }
626
- const query = parseRouteSegment(options.query, ctx.req.query(), 422);
627
+ const query = parseRouteSegment(options.query, flattenRequestQueries(ctx), 422);
627
628
  if (query instanceof Response) {
628
629
  return query;
629
630
  }
@@ -699,10 +700,11 @@ function createContractValidationMiddleware(route) {
699
700
  }
700
701
  }
701
702
  if (schemas.query) {
702
- const result = parseRouteSegment(schemas.query, c.req.query(), 422);
703
+ const query = flattenRequestQueries(c);
704
+ const result = parseRouteSegment(schemas.query, query, 422);
703
705
  if (result instanceof Response) {
704
706
  throw ValidationException.withMessages(
705
- formatValidationErrors(schemas.query.safeParse(c.req.query()).error)
707
+ formatValidationErrors(schemas.query.safeParse(query).error)
706
708
  );
707
709
  }
708
710
  }
@@ -1793,6 +1795,8 @@ var Application = class {
1793
1795
  }
1794
1796
  if (this.options.auth) {
1795
1797
  this.providerManager.register(AuthServiceProvider);
1798
+ } else {
1799
+ this.hono.use("*", attachAuthContext((ctx) => this.authManager.createAuthContext(ctx)));
1796
1800
  }
1797
1801
  this.providerManager.register(AuthorizationServiceProvider);
1798
1802
  const userProviders = Array.isArray(this.options.providers) ? this.options.providers : [];
@@ -1851,9 +1855,6 @@ var Application = class {
1851
1855
  async boot() {
1852
1856
  this.mountSecurityDefaults();
1853
1857
  await this.providerManager.registerAll();
1854
- if (!this.options.auth) {
1855
- this.hono.use("*", attachAuthContext((ctx) => this.authManager.createAuthContext(ctx)));
1856
- }
1857
1858
  await this.options.boot?.(this.hono);
1858
1859
  await this.mountRoutes();
1859
1860
  await this.mountMcpEndpoint();
@@ -2642,12 +2643,7 @@ var Controller = class {
2642
2643
  }
2643
2644
  /** Flatten query string arrays to scalar values for cleaner schema usage. */
2644
2645
  flattenQueries() {
2645
- const queries = this.ctx.req.queries();
2646
- const flat = {};
2647
- for (const [key, values] of Object.entries(queries)) {
2648
- flat[key] = values.length === 1 ? values[0] : values;
2649
- }
2650
- return flat;
2646
+ return flattenRequestQueries(this.ctx);
2651
2647
  }
2652
2648
  // ─── Validation ─────────────────────────────────────────────────
2653
2649
  /**
@@ -1,10 +1,10 @@
1
1
  import * as hono_aws_lambda from 'hono/aws-lambda';
2
2
  export { APIGatewayProxyResult, LambdaEvent } from 'hono/aws-lambda';
3
- import { A as Application } from '../Application-D4_90raL.js';
3
+ import { A as Application } from '../Application-Hlryz3ln.js';
4
4
  import { S as Scheduler } from '../Scheduler-BstvSca7.js';
5
- import { C as ConsoleKernel } from '../ConsoleKernel-BPYcP-2f.js';
5
+ import { C as ConsoleKernel } from '../ConsoleKernel-CVvaK-I6.js';
6
6
  import 'hono';
7
- import '../api-token-BGOsfuI9.js';
7
+ import '../api-token-ChekhpB7.js';
8
8
  import '@guren/orm';
9
9
  import 'vite';
10
10
  import '../EventManager-CmIoLt7r.js';
@@ -1,7 +1,7 @@
1
1
  import { McpServer } from '@modelcontextprotocol/sdk/server/mcp.js';
2
- import { S as ServiceProvider } from '../Application-D4_90raL.js';
2
+ import { S as ServiceProvider } from '../Application-Hlryz3ln.js';
3
3
  import 'hono';
4
- import '../api-token-BGOsfuI9.js';
4
+ import '../api-token-ChekhpB7.js';
5
5
  import '@guren/orm';
6
6
  import 'vite';
7
7
  import '../EventManager-CmIoLt7r.js';
@@ -1,8 +1,8 @@
1
- import { _ as NotificationChannel, X as Notifiable, Y as Notification, q as DatabaseNotification, p as DatabaseChannelOptions, as as SlackMessage, ai as SentNotification } from '../Application-D4_90raL.js';
2
- export { Z as NotificationAttachment, $ as NotificationChannelFactory, a0 as NotificationClass, a1 as NotificationMailMessage, N as NotificationManager, a2 as NotificationManagerOptions, aq as SlackAttachment, ar as SlackBlock, aG as createNotificationManager, aQ as getNotificationManager, a$ as setNotificationManager } from '../Application-D4_90raL.js';
1
+ import { _ as NotificationChannel, X as Notifiable, Y as Notification, q as DatabaseNotification, p as DatabaseChannelOptions, as as SlackMessage, ai as SentNotification } from '../Application-Hlryz3ln.js';
2
+ export { Z as NotificationAttachment, $ as NotificationChannelFactory, a0 as NotificationClass, a1 as NotificationMailMessage, N as NotificationManager, a2 as NotificationManagerOptions, aq as SlackAttachment, ar as SlackBlock, aG as createNotificationManager, aQ as getNotificationManager, a$ as setNotificationManager } from '../Application-Hlryz3ln.js';
3
3
  import { M as MailManager } from '../MailManager-DpMvYiP9.js';
4
4
  import 'hono';
5
- import '../api-token-BGOsfuI9.js';
5
+ import '../api-token-ChekhpB7.js';
6
6
  import '@guren/orm';
7
7
  import 'vite';
8
8
  import '../EventManager-CmIoLt7r.js';
@@ -1,8 +1,8 @@
1
- import { a5 as QueueDriver, a7 as QueuedJob, F as FailedJob, aw as WorkerOptions } from '../Application-D4_90raL.js';
2
- export { R as Job, T as JobClass, U as JobFailureHandler, V as JobHandler, W as JobOptions, a4 as QueueConfig, a6 as QueueDriverFactory, Q as QueueManager, aA as clearJobRegistry, aH as createQueueManager, aP as getJob, aR as getQueueDriver, aS as getRegisteredJobs, aW as registerJob, b0 as setQueueDriver } from '../Application-D4_90raL.js';
1
+ import { a5 as QueueDriver, a7 as QueuedJob, F as FailedJob, aw as WorkerOptions } from '../Application-Hlryz3ln.js';
2
+ export { R as Job, T as JobClass, U as JobFailureHandler, V as JobHandler, W as JobOptions, a4 as QueueConfig, a6 as QueueDriverFactory, Q as QueueManager, aA as clearJobRegistry, aH as createQueueManager, aP as getJob, aR as getQueueDriver, aS as getRegisteredJobs, aW as registerJob, b0 as setQueueDriver } from '../Application-Hlryz3ln.js';
3
3
  import { Redis } from 'ioredis';
4
4
  import 'hono';
5
- import '../api-token-BGOsfuI9.js';
5
+ import '../api-token-ChekhpB7.js';
6
6
  import '@guren/orm';
7
7
  import 'vite';
8
8
  import '../EventManager-CmIoLt7r.js';
@@ -1,7 +1,7 @@
1
- import { A as Application } from '../Application-D4_90raL.js';
2
- export { D as DevBannerOptions, G as GUREN_ASCII_ART, a as StartViteDevServerOptions, b as StartedViteDevServer, l as logDevServerBanner, s as startViteDevServer } from '../Application-D4_90raL.js';
1
+ import { A as Application } from '../Application-Hlryz3ln.js';
2
+ export { D as DevBannerOptions, G as GUREN_ASCII_ART, a as StartViteDevServerOptions, b as StartedViteDevServer, l as logDevServerBanner, s as startViteDevServer } from '../Application-Hlryz3ln.js';
3
3
  import 'hono';
4
- import '../api-token-BGOsfuI9.js';
4
+ import '../api-token-ChekhpB7.js';
5
5
  import '@guren/orm';
6
6
  import 'vite';
7
7
  import '../EventManager-CmIoLt7r.js';
@@ -3,7 +3,7 @@ import {
3
3
  logDevServerBanner,
4
4
  parseImportMap,
5
5
  startViteDevServer
6
- } from "../chunk-NFGDKY3L.js";
6
+ } from "../chunk-X4E2I4Z5.js";
7
7
  import {
8
8
  hash
9
9
  } from "../chunk-QQKTH5KX.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guren/server",
3
- "version": "1.0.0-rc.23",
3
+ "version": "1.0.0-rc.25",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -105,8 +105,8 @@
105
105
  "test": "bun test"
106
106
  },
107
107
  "dependencies": {
108
- "@guren/inertia-client": "^1.0.0-rc.22",
109
- "@guren/orm": "^1.0.0-rc.24",
108
+ "@guren/inertia-client": "^1.0.0-rc.24",
109
+ "@guren/orm": "^1.0.0-rc.26",
110
110
  "@modelcontextprotocol/sdk": "^1.27.1",
111
111
  "chalk": "^5.3.0",
112
112
  "consola": "^3.4.2",