@guren/server 1.2.0 → 1.4.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.
Files changed (44) hide show
  1. package/dist/{Application-DN9Ndl37.d.ts → Application-BvBqgc2k.d.ts} +204 -22
  2. package/dist/{AuthManager-SfhCNkAU.d.ts → AuthManager-C84xF5ks.d.ts} +1 -1
  3. package/dist/{BroadcastManager-CGWl9rUO.d.ts → BroadcastManager-D8KoJxiV.d.ts} +21 -0
  4. package/dist/{CacheManager-BkvHEOZX.d.ts → CacheManager-BmDzUKrF.d.ts} +17 -0
  5. package/dist/{ConsoleKernel-DxmUxdAz.d.ts → ConsoleKernel-Dw9X9qZY.d.ts} +1 -1
  6. package/dist/{I18nManager-BiSoczfV.d.ts → I18nManager-CmUqj6bU.d.ts} +1 -1
  7. package/dist/{McpServiceProvider-JW6PDVMD.js → McpServiceProvider-TZWQWXCT.js} +2 -2
  8. package/dist/{Scheduler-BstvSca7.d.ts → Scheduler-pZiT8i57.d.ts} +2 -0
  9. package/dist/{api-token-BSSCLlFW.d.ts → api-token-COQHXyM_.d.ts} +123 -1
  10. package/dist/auth/index.d.ts +5 -5
  11. package/dist/auth/index.js +3 -1
  12. package/dist/authorization/index.js +2 -2
  13. package/dist/broadcasting/index.d.ts +2 -2
  14. package/dist/broadcasting/index.js +2 -1
  15. package/dist/cache/index.d.ts +2 -2
  16. package/dist/cache/index.js +2 -1
  17. package/dist/{chunk-EGU5KB7V.js → chunk-4SBGSJNT.js} +31 -1
  18. package/dist/{chunk-THSX7OOR.js → chunk-63SKW5PS.js} +3 -0
  19. package/dist/{chunk-2T6JN4VR.js → chunk-AUXQISW5.js} +169 -14
  20. package/dist/chunk-DCYKSYAT.js +63 -0
  21. package/dist/{chunk-ZRBLZY3M.js → chunk-FZD2AKJI.js} +1 -1
  22. package/dist/{chunk-HLXL2AYJ.js → chunk-JIT7QVMJ.js} +2 -2
  23. package/dist/{chunk-HKQSAFSN.js → chunk-MC752CQT.js} +15 -0
  24. package/dist/{chunk-WVY45EIW.js → chunk-NQCZQAJL.js} +93 -28
  25. package/dist/{chunk-VT5KRDPH.js → chunk-NYQGAWDN.js} +49 -1
  26. package/dist/{chunk-44F7JQ7I.js → chunk-XMQZENBP.js} +35 -1
  27. package/dist/{client-CKXJLsTe.d.ts → client-BQwF2b9Y.d.ts} +7 -0
  28. package/dist/{email-verification-CAeArjui.d.ts → email-verification-H_WlpsVH.d.ts} +1 -1
  29. package/dist/{errors-JOOPDDQ6.js → errors-PUNHAFL2.js} +1 -1
  30. package/dist/i18n/index.d.ts +2 -2
  31. package/dist/index.d.ts +129 -19
  32. package/dist/index.js +314 -105
  33. package/dist/lambda/index.d.ts +8 -8
  34. package/dist/mcp/index.d.ts +54 -20
  35. package/dist/mcp/index.js +2 -2
  36. package/dist/notifications/index.d.ts +8 -8
  37. package/dist/queue/index.d.ts +8 -8
  38. package/dist/redis/index.d.ts +11 -21
  39. package/dist/redis/index.js +42 -6
  40. package/dist/runtime/index.d.ts +8 -8
  41. package/dist/runtime/index.js +1 -1
  42. package/dist/scheduling/index.d.ts +2 -2
  43. package/dist/scheduling/index.js +2 -1
  44. package/package.json +2 -2
@@ -15,6 +15,14 @@ interface SessionStore {
15
15
  * Destroy a session. Implementations must treat repeated calls as safe.
16
16
  */
17
17
  destroy(id: string): Promise<void>;
18
+ /**
19
+ * Optional: refresh an existing session's TTL without rewriting its data.
20
+ * The middleware uses this for unchanged sessions (rolling expiry); stores
21
+ * that omit it fall back to a full `write`. Refreshing a session that no
22
+ * longer exists — including one that has expired but not yet been swept
23
+ * from storage — must be a no-op, not a resurrection.
24
+ */
25
+ touch?(id: string, ttlSeconds: number): Promise<void>;
18
26
  }
19
27
  declare class MemorySessionStore implements SessionStore {
20
28
  private readonly now;
@@ -23,6 +31,7 @@ declare class MemorySessionStore implements SessionStore {
23
31
  read(id: string): Promise<SessionData | undefined>;
24
32
  write(id: string, data: SessionData, ttlSeconds: number): Promise<void>;
25
33
  destroy(id: string): Promise<void>;
34
+ touch(id: string, ttlSeconds: number): Promise<void>;
26
35
  }
27
36
  interface SessionOptions {
28
37
  cookieName?: string;
@@ -44,6 +53,14 @@ interface Session {
44
53
  forget(key: string): void;
45
54
  flush(): void;
46
55
  all(): SessionData;
56
+ /**
57
+ * Rotate the session id (call after login to mitigate session fixation).
58
+ * The new id is persisted and the old one destroyed at request end. Known
59
+ * limitation shared by every multi-process store: a concurrent request
60
+ * still carrying the old cookie can re-persist the old id afterwards; the
61
+ * resurrected row holds only pre-rotation data (no auth state), so
62
+ * fixation does not escalate, but the row can linger until it expires.
63
+ */
47
64
  regenerate(): void;
48
65
  invalidate(): void;
49
66
  flash(key: string, value: unknown): void;
@@ -90,6 +107,37 @@ interface UserProvider<User = Authenticatable> {
90
107
  */
91
108
  sanitize?(user: User): User;
92
109
  }
110
+ /**
111
+ * The conventional names for the credential columns that
112
+ * `ModelUserProvider.sanitize()` strips: the password column (`password`
113
+ * by default, commonly configured as `passwordHash`/`password_hash`) and
114
+ * the remember-token column (`remember_token` by default, commonly
115
+ * `rememberToken`).
116
+ */
117
+ type DefaultSanitizedKeys = 'password' | 'passwordHash' | 'password_hash' | 'rememberToken' | 'remember_token';
118
+ /**
119
+ * The shape of a user record after auth-layer sanitization — what
120
+ * `auth.user()` returns at runtime when the provider's column names
121
+ * follow the {@link DefaultSanitizedKeys} conventions. Removes those
122
+ * conventional credential keys plus any extra keys passed as `Hidden`.
123
+ *
124
+ * The runtime strips exactly the *configured* password/remember-token
125
+ * columns plus the model's `static hidden` — a static type cannot see
126
+ * that configuration. If your columns use other names, or the model
127
+ * hides additional fields, list them in `Hidden` explicitly. Only
128
+ * meaningful for concrete record types (index-signature records like
129
+ * `Record<string, string>` cannot have individual keys removed).
130
+ *
131
+ * @example
132
+ * ```ts
133
+ * const user = await this.auth.userOrFail<Sanitized<UserRecord>>()
134
+ * user.passwordHash // compile error — stripped at runtime
135
+ *
136
+ * // With additional hidden fields or custom column names:
137
+ * type SafeUser = Sanitized<UserRecord, 'twoFactorSecret' | 'credentialDigest'>
138
+ * ```
139
+ */
140
+ type Sanitized<User, Hidden extends string = never> = User extends unknown ? Omit<User, Extract<keyof User, DefaultSanitizedKeys | Hidden>> : never;
93
141
  interface GuardContext {
94
142
  ctx: Context;
95
143
  session: Session | undefined;
@@ -139,6 +187,35 @@ interface OAuthProviderConfig {
139
187
  tokenAuthMethod?: 'client_secret_post' | 'client_secret_basic';
140
188
  userInfoMethod?: 'GET' | 'POST';
141
189
  mapProfile?: (raw: Record<string, unknown>, token: OAuthTokenResult) => OAuthUserProfile;
190
+ /**
191
+ * Key in the userinfo response carrying the provider's own verification
192
+ * signal for the email address — Discord returns `verified`, for example.
193
+ * Defaults to OIDC's standard `email_verified` claim. Only boolean values
194
+ * are read; anything else leaves `profile.emailVerified` undefined. Ignored
195
+ * when `mapProfile` is set, since that owns the whole mapping.
196
+ */
197
+ emailVerifiedKey?: string;
198
+ /**
199
+ * Fallback used when the userinfo response carries no email — e.g. GitHub
200
+ * returns `email: null` for accounts with a private email even when the
201
+ * `user:email` scope was granted. Returns the email to use, or undefined
202
+ * to leave the profile without one.
203
+ *
204
+ * The signal read via `emailVerifiedKey` does not carry over to a fallback
205
+ * address — it was read against a response that had no email. A bare string
206
+ * therefore makes no verification claim and leaves `profile.emailVerified`
207
+ * undefined; return `{ email, emailVerified: true }` to assert one.
208
+ */
209
+ fetchFallbackEmail?: (token: OAuthTokenResult) => Promise<string | OAuthFallbackEmail | undefined>;
210
+ }
211
+ interface OAuthFallbackEmail {
212
+ email: string;
213
+ /**
214
+ * Whether the provider verified this specific address. Omit it when the
215
+ * lookup cannot tell — the profile then reports `emailVerified: undefined`
216
+ * rather than an unfounded claim.
217
+ */
218
+ emailVerified?: boolean;
142
219
  }
143
220
  interface OAuthTokenResult {
144
221
  accessToken: string;
@@ -153,6 +230,15 @@ interface OAuthUserProfile {
153
230
  email?: string;
154
231
  name?: string;
155
232
  avatar?: string;
233
+ /**
234
+ * Whether the provider itself verified `email`. Tri-state on purpose:
235
+ * `true` — the provider asserts the address is verified; `false` — it
236
+ * asserts it is not; `undefined` — the provider sends no such signal
237
+ * (GitHub's `/user`, for instance), so the consumer decides its own policy.
238
+ * Returning an email is not by itself a claim that it was checked, so
239
+ * treating `undefined` as verified is a decision, not a default.
240
+ */
241
+ emailVerified?: boolean;
156
242
  token: OAuthTokenResult;
157
243
  raw: Record<string, unknown>;
158
244
  }
@@ -165,11 +251,28 @@ interface OAuthStateStore {
165
251
  store(stateHash: string, payload: OAuthStatePayload): Promise<void>;
166
252
  find(stateHash: string): Promise<OAuthStatePayload | null>;
167
253
  delete(stateHash: string): Promise<void>;
254
+ /**
255
+ * Atomically fetch and delete a state in one step. Exactly one caller may
256
+ * receive the payload; every other concurrent caller (and any later call)
257
+ * must get null. Expired states must also return null, mirroring `find`.
258
+ *
259
+ * Optional for backward compatibility: `verifyOAuthState` prefers this
260
+ * when present. Stores that only implement find/delete keep working, but
261
+ * leave a window where two concurrent callbacks with the same state can
262
+ * both pass verification.
263
+ */
264
+ consume?(stateHash: string): Promise<OAuthStatePayload | null>;
168
265
  }
169
266
  interface OAuthStateConfig {
170
267
  expiresIn?: number;
171
268
  stateLength?: number;
172
269
  hashAlgorithm?: 'sha256' | 'sha512';
270
+ /**
271
+ * External hosts allowed as `redirectTo` targets (supports `*.example.com`
272
+ * wildcards). App-relative paths (`/dashboard`) are always allowed; anything
273
+ * else is dropped to prevent open redirects.
274
+ */
275
+ allowedRedirectHosts?: string[];
173
276
  }
174
277
  interface OAuthAuthorizeOptions {
175
278
  scope?: string[];
@@ -195,6 +298,7 @@ declare class MemoryOAuthStateStore implements OAuthStateStore {
195
298
  private sweepExpired;
196
299
  find(stateHash: string): Promise<OAuthStatePayload | null>;
197
300
  delete(stateHash: string): Promise<void>;
301
+ consume(stateHash: string): Promise<OAuthStatePayload | null>;
198
302
  clear(): void;
199
303
  }
200
304
  declare class OAuthManager {
@@ -211,6 +315,16 @@ declare class OAuthManager {
211
315
  expiresAt: Date;
212
316
  }>;
213
317
  user(providerName: string, payload: OAuthCallbackPayload): Promise<OAuthUserProfile>;
318
+ /**
319
+ * Verify the callback and return the user profile together with the
320
+ * sanitized `redirectTo` stored at authorize time. `redirectTo` is safe to
321
+ * pass to a redirect response: app-relative paths and allowlisted hosts
322
+ * only.
323
+ */
324
+ handleCallback(providerName: string, payload: OAuthCallbackPayload): Promise<{
325
+ profile: OAuthUserProfile;
326
+ redirectTo?: string;
327
+ }>;
214
328
  }
215
329
  declare function createOAuthManager(options?: OAuthManagerOptions): OAuthManager;
216
330
  declare function createOAuthState(provider: string, store: OAuthStateStore, config?: OAuthStateConfig, redirectTo?: string, fixedState?: string): Promise<{
@@ -218,6 +332,14 @@ declare function createOAuthState(provider: string, store: OAuthStateStore, conf
218
332
  expiresAt: Date;
219
333
  }>;
220
334
  declare function verifyOAuthState(state: string, provider: string, store: OAuthStateStore, config?: OAuthStateConfig): Promise<OAuthStatePayload | null>;
335
+ /**
336
+ * Reduce a `redirectTo` value to a safe target: app-relative paths always
337
+ * pass; absolute http(s) URLs pass only when their host is in the allowlist
338
+ * (supports `*.example.com` wildcards). Everything else — protocol-relative
339
+ * URLs, backslash tricks, `javascript:` and other schemes — returns
340
+ * `undefined`.
341
+ */
342
+ declare function sanitizeOAuthRedirect(redirectTo: string | undefined, allowedHosts?: string[]): string | undefined;
221
343
  declare function buildOAuthAuthorizeUrl(provider: OAuthProviderConfig, state: string, options?: {
222
344
  scope?: string[];
223
345
  extraParams?: Record<string, string>;
@@ -538,4 +660,4 @@ declare function getApiTokenOrFail(ctx: Context): {
538
660
  abilities: string[];
539
661
  };
540
662
 
541
- export { revokeAllApiTokens as $, type Authenticatable as A, type BearerTokenMiddlewareOptions as B, type CreateSessionMiddlewareOptions as C, buildOAuthAuthorizeUrl as D, buildOAuthRedirectUrl as E, createApiToken as F, type GuardFactory as G, createBearerTokenMiddleware as H, createDiscordOAuthProviderConfig as I, createGitHubOAuthProviderConfig as J, createGoogleOAuthProviderConfig as K, createOAuthManager as L, MemoryApiTokenStore as M, createOAuthState as N, type OAuthStateStore as O, type ProviderFactory as P, createSessionMiddleware as Q, exchangeOAuthCode as R, type SessionStore as S, fetchOAuthUserProfile as T, type UserProvider as U, getApiToken as V, getApiTokenOrFail as W, getSessionFromContext as X, getUserApiTokens as Y, parseApiToken as Z, parseOAuthRedirectUrl as _, type AuthCredentials as a, revokeApiToken as a0, tokenCan as a1, tokenCanAll as a2, tokenCanAny as a3, verifyApiToken as a4, verifyOAuthState as a5, type AuthManagerContract as b, type AuthManagerOptions as c, type GuardContext as d, type Guard as e, type AttachContextOptions as f, type AuthContext as g, type SessionData as h, type ApiTokenStore as i, type ApiToken as j, type OAuthStatePayload as k, OAuthManager as l, API_TOKEN_KEY as m, type CreateApiTokenOptions as n, type CreateApiTokenResult as o, MemoryOAuthStateStore as p, MemorySessionStore as q, type OAuthAuthorizeOptions as r, type OAuthCallbackPayload as s, type OAuthManagerOptions as t, type OAuthProviderConfig as u, type OAuthProviderFactoryInput as v, type OAuthStateConfig as w, type OAuthTokenResult as x, type OAuthUserProfile as y, type Session as z };
663
+ export { getUserApiTokens as $, type Authenticatable as A, type BearerTokenMiddlewareOptions as B, type CreateSessionMiddlewareOptions as C, type DefaultSanitizedKeys as D, type Sanitized as E, type Session as F, type GuardFactory as G, buildOAuthAuthorizeUrl as H, buildOAuthRedirectUrl as I, createApiToken as J, createBearerTokenMiddleware as K, createDiscordOAuthProviderConfig as L, MemoryApiTokenStore as M, createGitHubOAuthProviderConfig as N, type OAuthStateStore as O, type ProviderFactory as P, createGoogleOAuthProviderConfig as Q, createOAuthManager as R, type SessionStore as S, createOAuthState as T, type UserProvider as U, createSessionMiddleware as V, exchangeOAuthCode as W, fetchOAuthUserProfile as X, getApiToken as Y, getApiTokenOrFail as Z, getSessionFromContext as _, type AuthCredentials as a, parseApiToken as a0, parseOAuthRedirectUrl as a1, revokeAllApiTokens as a2, revokeApiToken as a3, sanitizeOAuthRedirect as a4, tokenCan as a5, tokenCanAll as a6, tokenCanAny as a7, verifyApiToken as a8, verifyOAuthState as a9, type AuthManagerContract as b, type AuthManagerOptions as c, type GuardContext as d, type Guard as e, type AttachContextOptions as f, type AuthContext as g, type SessionData as h, type ApiTokenStore as i, type ApiToken as j, type OAuthStatePayload as k, OAuthManager as l, API_TOKEN_KEY as m, type CreateApiTokenOptions as n, type CreateApiTokenResult as o, MemoryOAuthStateStore as p, MemorySessionStore as q, type OAuthAuthorizeOptions as r, type OAuthCallbackPayload as s, type OAuthFallbackEmail as t, type OAuthManagerOptions as u, type OAuthProviderConfig as v, type OAuthProviderFactoryInput as w, type OAuthStateConfig as x, type OAuthTokenResult as y, type OAuthUserProfile as z };
@@ -1,9 +1,9 @@
1
- import { P as PasswordHasher } from '../AuthManager-SfhCNkAU.js';
2
- export { A as AuthManager, B as BaseUserProvider, M as ModelUserProvider } from '../AuthManager-SfhCNkAU.js';
3
- import { A as Authenticatable, e as Guard, U as UserProvider, z as Session, a as AuthCredentials } from '../api-token-BSSCLlFW.js';
4
- export { m as API_TOKEN_KEY, j as ApiToken, i as ApiTokenStore, f as AttachContextOptions, g as AuthContext, b as AuthManagerContract, c as AuthManagerOptions, B as BearerTokenMiddlewareOptions, n as CreateApiTokenOptions, o as CreateApiTokenResult, d as GuardContext, G as GuardFactory, M as MemoryApiTokenStore, p as MemoryOAuthStateStore, r as OAuthAuthorizeOptions, s as OAuthCallbackPayload, l as OAuthManager, t as OAuthManagerOptions, u as OAuthProviderConfig, v as OAuthProviderFactoryInput, w as OAuthStateConfig, k as OAuthStatePayload, O as OAuthStateStore, x as OAuthTokenResult, y as OAuthUserProfile, P as ProviderFactory, D as buildOAuthAuthorizeUrl, E as buildOAuthRedirectUrl, F as createApiToken, H as createBearerTokenMiddleware, I as createDiscordOAuthProviderConfig, J as createGitHubOAuthProviderConfig, K as createGoogleOAuthProviderConfig, L as createOAuthManager, N as createOAuthState, R as exchangeOAuthCode, T as fetchOAuthUserProfile, V as getApiToken, W as getApiTokenOrFail, Y as getUserApiTokens, Z as parseApiToken, _ as parseOAuthRedirectUrl, $ as revokeAllApiTokens, a0 as revokeApiToken, a1 as tokenCan, a2 as tokenCanAll, a3 as tokenCanAny, a4 as verifyApiToken, a5 as verifyOAuthState } from '../api-token-BSSCLlFW.js';
1
+ import { P as PasswordHasher } from '../AuthManager-C84xF5ks.js';
2
+ export { A as AuthManager, B as BaseUserProvider, M as ModelUserProvider } from '../AuthManager-C84xF5ks.js';
3
+ import { A as Authenticatable, e as Guard, U as UserProvider, F as Session, a as AuthCredentials } from '../api-token-COQHXyM_.js';
4
+ export { m as API_TOKEN_KEY, j as ApiToken, i as ApiTokenStore, f as AttachContextOptions, g as AuthContext, b as AuthManagerContract, c as AuthManagerOptions, B as BearerTokenMiddlewareOptions, n as CreateApiTokenOptions, o as CreateApiTokenResult, D as DefaultSanitizedKeys, d as GuardContext, G as GuardFactory, M as MemoryApiTokenStore, p as MemoryOAuthStateStore, r as OAuthAuthorizeOptions, s as OAuthCallbackPayload, t as OAuthFallbackEmail, l as OAuthManager, u as OAuthManagerOptions, v as OAuthProviderConfig, w as OAuthProviderFactoryInput, x as OAuthStateConfig, k as OAuthStatePayload, O as OAuthStateStore, y as OAuthTokenResult, z as OAuthUserProfile, P as ProviderFactory, E as Sanitized, H as buildOAuthAuthorizeUrl, I as buildOAuthRedirectUrl, J as createApiToken, K as createBearerTokenMiddleware, L as createDiscordOAuthProviderConfig, N as createGitHubOAuthProviderConfig, Q as createGoogleOAuthProviderConfig, R as createOAuthManager, T as createOAuthState, W as exchangeOAuthCode, X as fetchOAuthUserProfile, Y as getApiToken, Z as getApiTokenOrFail, $ as getUserApiTokens, a0 as parseApiToken, a1 as parseOAuthRedirectUrl, a2 as revokeAllApiTokens, a3 as revokeApiToken, a4 as sanitizeOAuthRedirect, a5 as tokenCan, a6 as tokenCanAll, a7 as tokenCanAny, a8 as verifyApiToken, a9 as verifyOAuthState } from '../api-token-COQHXyM_.js';
5
5
  import { PlainObject, Model } from '@guren/orm';
6
- export { b as EmailVerificationConfig, a as EmailVerificationToken, c as EmailVerificationTokenResult, E as EmailVerificationTokenStore, M as MemoryEmailVerificationStore, d as MemoryPasswordResetStore, e as PasswordResetConfig, f as PasswordResetTokenResult, P as PasswordResetTokenStore, g as buildPasswordResetUrl, q as buildTokenUrl, h as buildVerificationUrl, i as completeEmailVerification, j as completePasswordReset, k as createEmailVerificationToken, l as createPasswordResetToken, s as generateId, t as generateToken, u as hashToken, m as isEmailVerified, p as parsePasswordResetUrl, w as parseTokenUrl, n as parseVerificationUrl, r as requireVerifiedEmail, x as secureCompare, y as secureStringCompare, v as verifyEmailToken, o as verifyPasswordResetToken } from '../email-verification-CAeArjui.js';
6
+ export { b as EmailVerificationConfig, a as EmailVerificationToken, c as EmailVerificationTokenResult, E as EmailVerificationTokenStore, M as MemoryEmailVerificationStore, d as MemoryPasswordResetStore, e as PasswordResetConfig, f as PasswordResetTokenResult, P as PasswordResetTokenStore, g as buildPasswordResetUrl, q as buildTokenUrl, h as buildVerificationUrl, i as completeEmailVerification, j as completePasswordReset, k as createEmailVerificationToken, l as createPasswordResetToken, s as generateId, t as generateToken, u as hashToken, m as isEmailVerified, p as parsePasswordResetUrl, w as parseTokenUrl, n as parseVerificationUrl, r as requireVerifiedEmail, x as secureCompare, y as secureStringCompare, v as verifyEmailToken, o as verifyPasswordResetToken } from '../email-verification-H_WlpsVH.js';
7
7
  import 'hono';
8
8
 
9
9
  interface SessionGuardOptions {
@@ -45,6 +45,7 @@ import {
45
45
  requireVerifiedEmail,
46
46
  revokeAllApiTokens,
47
47
  revokeApiToken,
48
+ sanitizeOAuthRedirect,
48
49
  secureCompare,
49
50
  secureStringCompare,
50
51
  tokenCan,
@@ -54,7 +55,7 @@ import {
54
55
  verifyEmailToken,
55
56
  verifyOAuthState,
56
57
  verifyPasswordResetToken
57
- } from "../chunk-2T6JN4VR.js";
58
+ } from "../chunk-AUXQISW5.js";
58
59
  import "../chunk-DAQKYKLH.js";
59
60
  import "../chunk-ONSDE37A.js";
60
61
  import "../chunk-QQKTH5KX.js";
@@ -105,6 +106,7 @@ export {
105
106
  requireVerifiedEmail,
106
107
  revokeAllApiTokens,
107
108
  revokeApiToken,
109
+ sanitizeOAuthRedirect,
108
110
  secureCompare,
109
111
  secureStringCompare,
110
112
  tokenCan,
@@ -14,8 +14,8 @@ import {
14
14
  getGate,
15
15
  setGate,
16
16
  withAuthorization
17
- } from "../chunk-ZRBLZY3M.js";
18
- import "../chunk-THSX7OOR.js";
17
+ } from "../chunk-FZD2AKJI.js";
18
+ import "../chunk-63SKW5PS.js";
19
19
  import "../chunk-DAQKYKLH.js";
20
20
  export {
21
21
  Gate,
@@ -1,5 +1,5 @@
1
- import { B as BroadcastManager, P as PresenceBroadcastDriver, c as BroadcastEvent, j as PresenceMember } from '../BroadcastManager-CGWl9rUO.js';
2
- export { A as AuthMiddlewareOptions, a as BroadcastDriver, b as BroadcastDriverFactory, d as BroadcastManagerOptions, e as BroadcastableEvent, C as Channel, f as ChannelAuthorizer, g as ChannelRegistration, h as PresenceChannel, i as PresenceChannelAuthorizer, 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';
1
+ import { B as BroadcastManager, P as PresenceBroadcastDriver, c as BroadcastEvent, j as PresenceMember } from '../BroadcastManager-D8KoJxiV.js';
2
+ export { A as AuthMiddlewareOptions, a as BroadcastDriver, b as BroadcastDriverFactory, d as BroadcastManagerOptions, e as BroadcastableEvent, C as Channel, f as ChannelAuthorizer, g as ChannelRegistration, h as PresenceChannel, i as PresenceChannelAuthorizer, k as PrivateChannel, S as SSEClient, l as SSEMiddlewareOptions, W as WebSocketClient, m as createBroadcastManager, n as getBroadcastManager, s as setBroadcastManager } from '../BroadcastManager-D8KoJxiV.js';
3
3
  import '../index-9_Jzj5jo.js';
4
4
  import 'hono';
5
5
 
@@ -9,7 +9,8 @@ import {
9
9
  createTypedBroadcaster,
10
10
  getBroadcastManager,
11
11
  setBroadcastManager
12
- } from "../chunk-44F7JQ7I.js";
12
+ } from "../chunk-XMQZENBP.js";
13
+ import "../chunk-DCYKSYAT.js";
13
14
  export {
14
15
  BroadcastManager,
15
16
  Channel,
@@ -1,5 +1,5 @@
1
- import { b as CacheStore, M as MemoryStoreOptions, R as RedisStoreOptions, F as FileStoreOptions, T as TaggedCacheStore } from '../CacheManager-BkvHEOZX.js';
2
- export { a as CacheConfig, C as CacheManager, c as CacheStoreFactory, e as CachedItem, S as StoreConfig, f as TaggableCacheStore, d as createCacheManager } from '../CacheManager-BkvHEOZX.js';
1
+ import { b as CacheStore, M as MemoryStoreOptions, R as RedisStoreOptions, F as FileStoreOptions, T as TaggedCacheStore } from '../CacheManager-BmDzUKrF.js';
2
+ export { a as CacheConfig, C as CacheManager, c as CacheStoreFactory, e as CachedItem, S as StoreConfig, f as TaggableCacheStore, d as createCacheManager } from '../CacheManager-BmDzUKrF.js';
3
3
 
4
4
  /**
5
5
  * In-memory cache store.
@@ -5,7 +5,8 @@ import {
5
5
  RedisStore,
6
6
  TaggedCache,
7
7
  createCacheManager
8
- } from "../chunk-EGU5KB7V.js";
8
+ } from "../chunk-4SBGSJNT.js";
9
+ import "../chunk-DCYKSYAT.js";
9
10
  export {
10
11
  CacheManager,
11
12
  FileStore,
@@ -1,3 +1,8 @@
1
+ import {
2
+ claimHotDisposable,
3
+ isHotReloadRuntime
4
+ } from "./chunk-DCYKSYAT.js";
5
+
1
6
  // src/cache/stores/MemoryStore.ts
2
7
  var MemoryStore = class {
3
8
  cache = /* @__PURE__ */ new Map();
@@ -716,7 +721,17 @@ var CacheManager = class {
716
721
  defaultStoreName;
717
722
  storeFactories = /* @__PURE__ */ new Map();
718
723
  resolvedStores = /* @__PURE__ */ new Map();
724
+ /**
725
+ * Where this manager was built, for identifying its stores across hot reloads.
726
+ *
727
+ * Captured here rather than in `store()` because stores resolve lazily, from
728
+ * whichever request first asks for one — a call site that says nothing about
729
+ * which manager owns the result. Skipped outside `--hot`, where it would be a
730
+ * formatted stack string held for the manager's lifetime and never read.
731
+ */
732
+ builtAt;
719
733
  constructor(config = {}) {
734
+ this.builtAt = isHotReloadRuntime() ? new Error().stack : void 0;
720
735
  this.defaultStoreName = config.default ?? "memory";
721
736
  this.registerBuiltinDrivers();
722
737
  if (config.stores) {
@@ -768,10 +783,25 @@ var CacheManager = class {
768
783
  if (!factory) {
769
784
  throw new Error(`Cache store not found: ${storeName}`);
770
785
  }
771
- const store = new TaggableCacheStoreWrapper(factory());
786
+ const raw = factory();
787
+ this.stopPreviousStore(storeName, raw);
788
+ const store = new TaggableCacheStoreWrapper(raw);
772
789
  this.resolvedStores.set(storeName, store);
773
790
  return store;
774
791
  }
792
+ /**
793
+ * Under `bun --hot`, stops the sweep timer held by the store this one replaces.
794
+ *
795
+ * Registered from here rather than from `MemoryStore` itself because this is
796
+ * where the store's name is known, and the name is what keeps two memory
797
+ * stores in one config from sharing a slot and cancelling each other's sweep.
798
+ */
799
+ stopPreviousStore(storeName, store) {
800
+ const disposable = store;
801
+ if (typeof disposable.destroy === "function") {
802
+ claimHotDisposable("cache-store", this.builtAt, storeName, () => disposable.destroy?.());
803
+ }
804
+ }
775
805
  /**
776
806
  * Register a custom store factory.
777
807
  */
@@ -152,6 +152,9 @@ var ExceptionHandler = class {
152
152
  if (this.shouldNotReport(error)) {
153
153
  return;
154
154
  }
155
+ if (this.reporters.length === 0) {
156
+ console.error("Unhandled exception:", error);
157
+ }
155
158
  for (const reporter of this.reporters) {
156
159
  try {
157
160
  await reporter(error);