@guren/server 2.1.1 → 2.3.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 (281) hide show
  1. package/dist/{DocsViewerServiceProvider-D7RGJPGM.js → DocsViewerServiceProvider-RUYDFBMW.js} +2 -2
  2. package/dist/McpServiceProvider-FRJ5O7LT.js +8 -0
  3. package/dist/auth/AuthManager.d.ts +30 -0
  4. package/dist/auth/AuthenticatableModel.d.ts +25 -0
  5. package/dist/auth/RequestAuthContext.d.ts +24 -0
  6. package/dist/auth/SessionGuard.d.ts +31 -0
  7. package/dist/auth/api-token.d.ts +299 -0
  8. package/dist/auth/email-verification.d.ts +203 -0
  9. package/dist/auth/index.d.ts +18 -110
  10. package/dist/auth/index.js +4 -1
  11. package/dist/auth/oauth/index.d.ts +239 -0
  12. package/dist/auth/password/DefaultHasher.d.ts +13 -0
  13. package/dist/auth/password/NodeHasher.d.ts +22 -0
  14. package/dist/auth/password/PasswordHasher.d.ts +5 -0
  15. package/dist/auth/password/ScryptHasher.d.ts +26 -0
  16. package/dist/auth/password-reset.d.ts +91 -0
  17. package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
  18. package/dist/auth/providers/UserProvider.d.ts +9 -0
  19. package/dist/auth/types.d.ts +102 -0
  20. package/dist/auth/utils.d.ts +39 -0
  21. package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
  22. package/dist/authorization/Policy.d.ts +77 -0
  23. package/dist/authorization/index.d.ts +5 -129
  24. package/dist/authorization/index.js +3 -1
  25. package/dist/authorization/middleware.d.ts +49 -0
  26. package/dist/authorization/types.d.ts +108 -0
  27. package/dist/broadcasting/BroadcastManager.d.ts +205 -0
  28. package/dist/broadcasting/channels/Channel.d.ts +28 -0
  29. package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
  30. package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
  31. package/dist/broadcasting/channels/index.d.ts +3 -0
  32. package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
  33. package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
  34. package/dist/broadcasting/drivers/index.d.ts +2 -0
  35. package/dist/broadcasting/index.d.ts +6 -233
  36. package/dist/broadcasting/index.js +1 -1
  37. package/dist/broadcasting/typed.d.ts +23 -0
  38. package/dist/broadcasting/types.d.ts +155 -0
  39. package/dist/cache/CacheManager.d.ts +87 -0
  40. package/dist/cache/TaggedCache.d.ts +62 -0
  41. package/dist/cache/index.d.ts +6 -233
  42. package/dist/cache/index.js +1 -1
  43. package/dist/cache/stores/FileStore.d.ts +64 -0
  44. package/dist/cache/stores/MemoryStore.d.ts +52 -0
  45. package/dist/cache/stores/RedisStore.d.ts +53 -0
  46. package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
  47. package/dist/chunk-3KV5X2FL.js +31 -0
  48. package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
  49. package/dist/{chunk-DSDX3ASM.js → chunk-5WL2FTC4.js} +67 -85
  50. package/dist/{chunk-5SZTEZ22.js → chunk-6IGN233M.js} +15 -8
  51. package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
  52. package/dist/{chunk-WIXGT4TN.js → chunk-A5JJ7XTH.js} +8 -2
  53. package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
  54. package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
  55. package/dist/{chunk-BZMZEFRG.js → chunk-LHR6OHI7.js} +11 -0
  56. package/dist/{chunk-JBG4AR24.js → chunk-Q2P6YLRR.js} +8 -2
  57. package/dist/{chunk-J6ETA476.js → chunk-TVV5YNEC.js} +101 -9
  58. package/dist/console/Command.d.ts +179 -0
  59. package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
  60. package/dist/console/Input.d.ts +140 -0
  61. package/dist/console/Output.d.ts +161 -0
  62. package/dist/console/index.d.ts +5 -0
  63. package/dist/console/types.d.ts +106 -0
  64. package/dist/container/Container.d.ts +148 -0
  65. package/dist/container/ServiceProvider.d.ts +103 -0
  66. package/dist/container/bindings.d.ts +55 -0
  67. package/dist/container/defineModule.d.ts +88 -0
  68. package/dist/container/definePlugin.d.ts +62 -0
  69. package/dist/container/index.d.ts +8 -0
  70. package/dist/container/types.d.ts +73 -0
  71. package/dist/database/Factory.d.ts +82 -0
  72. package/dist/database/Seeder.d.ts +35 -0
  73. package/dist/database/SeederRunner.d.ts +41 -0
  74. package/dist/database/index.d.ts +4 -0
  75. package/dist/database/types.d.ts +49 -0
  76. package/dist/discovery/AutoDiscovery.d.ts +113 -0
  77. package/dist/discovery/index.d.ts +2 -0
  78. package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
  79. package/dist/docs-viewer/endpoint.d.ts +29 -0
  80. package/dist/encryption/Encrypter.d.ts +96 -0
  81. package/dist/encryption/Hash.d.ts +69 -0
  82. package/dist/encryption/MessageSigner.d.ts +21 -0
  83. package/dist/encryption/Random.d.ts +119 -0
  84. package/dist/encryption/app-key.d.ts +12 -0
  85. package/dist/encryption/index.d.ts +10 -222
  86. package/dist/encryption/signed-url.d.ts +9 -0
  87. package/dist/encryption/types.d.ts +103 -0
  88. package/dist/errors/ExceptionHandler.d.ts +118 -0
  89. package/dist/errors/HttpException.d.ts +106 -0
  90. package/dist/errors/debug-page.d.ts +22 -0
  91. package/dist/errors/error-page.d.ts +1 -0
  92. package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
  93. package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
  94. package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
  95. package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
  96. package/dist/errors/exceptions/ValidationException.d.ts +60 -0
  97. package/dist/errors/exceptions/index.d.ts +5 -0
  98. package/dist/errors/index.d.ts +5 -0
  99. package/dist/errors/types.d.ts +43 -0
  100. package/dist/events/Event.d.ts +33 -0
  101. package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
  102. package/dist/events/Listener.d.ts +79 -0
  103. package/dist/events/builtin.d.ts +73 -0
  104. package/dist/events/index.d.ts +6 -155
  105. package/dist/events/types.d.ts +48 -0
  106. package/dist/facades/index.d.ts +31 -0
  107. package/dist/health/HealthCheck.d.ts +34 -0
  108. package/dist/health/HealthManager.d.ts +53 -0
  109. package/dist/health/checks/CacheCheck.d.ts +35 -0
  110. package/dist/health/checks/CustomCheck.d.ts +23 -0
  111. package/dist/health/checks/DatabaseCheck.d.ts +33 -0
  112. package/dist/health/checks/MemoryCheck.d.ts +32 -0
  113. package/dist/health/checks/RedisCheck.d.ts +27 -0
  114. package/dist/health/checks/StorageCheck.d.ts +35 -0
  115. package/dist/health/checks/index.d.ts +12 -0
  116. package/dist/health/index.d.ts +5 -185
  117. package/dist/health/types.d.ts +52 -0
  118. package/dist/hot-reload/hot-disposables.d.ts +96 -0
  119. package/dist/hot-reload/testing.d.ts +14 -0
  120. package/dist/http/Application.d.ts +199 -0
  121. package/dist/http/FormRequest.d.ts +73 -0
  122. package/dist/http/dev-assets.d.ts +62 -0
  123. package/dist/http/dev-banner.d.ts +7 -0
  124. package/dist/http/inertia-assets.d.ts +31 -0
  125. package/dist/http/middleware/auth.d.ts +13 -0
  126. package/dist/http/middleware/capabilities.d.ts +22 -0
  127. package/dist/http/middleware/cors.d.ts +40 -0
  128. package/dist/http/middleware/csp.d.ts +59 -0
  129. package/dist/http/middleware/csrf.d.ts +121 -0
  130. package/dist/http/middleware/detect-locale.d.ts +65 -0
  131. package/dist/http/middleware/force-https.d.ts +34 -0
  132. package/dist/http/middleware/host-authorization.d.ts +24 -0
  133. package/dist/http/middleware/index.d.ts +19 -0
  134. package/dist/http/middleware/loopback-guard.d.ts +51 -0
  135. package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
  136. package/dist/http/middleware/redirect-safety.d.ts +29 -0
  137. package/dist/http/middleware/request-id.d.ts +19 -0
  138. package/dist/http/middleware/request-logging.d.ts +16 -0
  139. package/dist/http/middleware/response-headers.d.ts +18 -0
  140. package/dist/http/middleware/security-headers.d.ts +49 -0
  141. package/dist/http/middleware/session.d.ts +93 -0
  142. package/dist/http/middleware/validation.d.ts +94 -0
  143. package/dist/http/public-assets.d.ts +15 -0
  144. package/dist/http/request.d.ts +24 -0
  145. package/dist/http/resources/CursorPaginator.d.ts +106 -0
  146. package/dist/http/resources/Paginator.d.ts +130 -0
  147. package/dist/http/resources/Resource.d.ts +67 -0
  148. package/dist/http/resources/ResourceCollection.d.ts +60 -0
  149. package/dist/http/resources/index.d.ts +6 -0
  150. package/dist/http/resources/types.d.ts +91 -0
  151. package/dist/http/validation/Validator.d.ts +128 -0
  152. package/dist/http/validation/index.d.ts +3 -0
  153. package/dist/http/validation/rules.d.ts +196 -0
  154. package/dist/http/validation/types.d.ts +96 -0
  155. package/dist/http/vite-dev-server.d.ts +27 -0
  156. package/dist/i18n/I18nManager.d.ts +114 -0
  157. package/dist/i18n/Translator.d.ts +80 -0
  158. package/dist/i18n/index.d.ts +6 -101
  159. package/dist/i18n/index.js +5 -3
  160. package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
  161. package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
  162. package/dist/i18n/pluralization.d.ts +19 -0
  163. package/dist/i18n/types.d.ts +106 -0
  164. package/dist/index.d.ts +69 -2605
  165. package/dist/index.js +405 -180
  166. package/dist/lambda/index.d.ts +17 -37
  167. package/dist/logging/LogManager.d.ts +83 -0
  168. package/dist/logging/Logger.d.ts +76 -0
  169. package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
  170. package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
  171. package/dist/logging/channels/FileChannel.d.ts +15 -0
  172. package/dist/logging/index.d.ts +8 -50
  173. package/dist/logging/types.d.ts +96 -0
  174. package/dist/mail/Mail.d.ts +138 -0
  175. package/dist/mail/MailManager.d.ts +79 -0
  176. package/dist/mail/address.d.ts +8 -0
  177. package/dist/mail/index.d.ts +7 -316
  178. package/dist/mail/transports/LogTransport.d.ts +19 -0
  179. package/dist/mail/transports/MemoryTransport.d.ts +84 -0
  180. package/dist/mail/transports/ResendTransport.d.ts +32 -0
  181. package/dist/mail/transports/SmtpTransport.d.ts +40 -0
  182. package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
  183. package/dist/mcp/McpServiceProvider.d.ts +17 -0
  184. package/dist/mcp/create-mcp-server.d.ts +152 -0
  185. package/dist/mcp/endpoint.d.ts +47 -0
  186. package/dist/mcp/index.d.ts +3 -185
  187. package/dist/mcp/index.js +3 -3
  188. package/dist/mvc/Controller.d.ts +326 -0
  189. package/dist/mvc/Router.d.ts +239 -0
  190. package/dist/mvc/ViewEngine.d.ts +11 -0
  191. package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
  192. package/dist/mvc/inertia/shared.d.ts +90 -0
  193. package/dist/mvc/mount-route.d.ts +10 -0
  194. package/dist/notifications/Notification.d.ts +99 -0
  195. package/dist/notifications/NotificationManager.d.ts +150 -0
  196. package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
  197. package/dist/notifications/channels/MailChannel.d.ts +45 -0
  198. package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
  199. package/dist/notifications/channels/SlackChannel.d.ts +73 -0
  200. package/dist/notifications/channels/index.d.ts +4 -0
  201. package/dist/notifications/index.d.ts +6 -322
  202. package/dist/notifications/notifiable-type.d.ts +10 -0
  203. package/dist/notifications/registry.d.ts +39 -0
  204. package/dist/notifications/types.d.ts +162 -0
  205. package/dist/providers/AuthServiceProvider.d.ts +7 -0
  206. package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
  207. package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
  208. package/dist/providers/CacheServiceProvider.d.ts +7 -0
  209. package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
  210. package/dist/providers/ErrorServiceProvider.d.ts +9 -0
  211. package/dist/providers/EventServiceProvider.d.ts +7 -0
  212. package/dist/providers/HealthServiceProvider.d.ts +7 -0
  213. package/dist/providers/I18nServiceProvider.d.ts +27 -0
  214. package/dist/providers/InertiaServiceProvider.d.ts +20 -0
  215. package/dist/providers/LogServiceProvider.d.ts +7 -0
  216. package/dist/providers/MailServiceProvider.d.ts +7 -0
  217. package/dist/providers/NotificationServiceProvider.d.ts +8 -0
  218. package/dist/providers/OAuthServiceProvider.d.ts +7 -0
  219. package/dist/providers/QueueServiceProvider.d.ts +7 -0
  220. package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
  221. package/dist/providers/StorageServiceProvider.d.ts +7 -0
  222. package/dist/providers/index.d.ts +17 -0
  223. package/dist/queue/FailedJobReporter.d.ts +40 -0
  224. package/dist/queue/Job.d.ts +140 -0
  225. package/dist/queue/QueueManager.d.ts +79 -0
  226. package/dist/queue/Worker.d.ts +99 -0
  227. package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
  228. package/dist/queue/drivers/RedisDriver.d.ts +96 -0
  229. package/dist/queue/drivers/SqsDriver.d.ts +108 -0
  230. package/dist/queue/drivers/SyncDriver.d.ts +28 -0
  231. package/dist/queue/index.d.ts +9 -453
  232. package/dist/queue/types.d.ts +171 -0
  233. package/dist/redis/RedisApiTokenStore.d.ts +78 -0
  234. package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
  235. package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
  236. package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
  237. package/dist/redis/RedisRateLimitStore.d.ts +77 -0
  238. package/dist/redis/RedisSessionStore.d.ts +61 -0
  239. package/dist/redis/client.d.ts +41 -0
  240. package/dist/redis/index.d.ts +14 -356
  241. package/dist/redis/index.js +45 -9
  242. package/dist/redis/redis-values.d.ts +17 -0
  243. package/dist/redis/scan-keys.d.ts +6 -0
  244. package/dist/runtime/index.d.ts +8 -95
  245. package/dist/runtime/index.js +101 -68
  246. package/dist/scheduling/CronParser.d.ts +37 -0
  247. package/dist/scheduling/Schedule.d.ts +229 -0
  248. package/dist/scheduling/ScheduledTask.d.ts +47 -0
  249. package/dist/scheduling/Scheduler.d.ts +99 -0
  250. package/dist/scheduling/index.d.ts +5 -41
  251. package/dist/scheduling/types.d.ts +97 -0
  252. package/dist/storage/StorageManager.d.ts +65 -0
  253. package/dist/storage/drivers/LocalDriver.d.ts +55 -0
  254. package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
  255. package/dist/storage/drivers/S3Driver.d.ts +72 -0
  256. package/dist/storage/index.d.ts +5 -197
  257. package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
  258. package/dist/support/contained-path.d.ts +26 -0
  259. package/dist/support/error-polyfill.d.ts +9 -0
  260. package/dist/support/expiry.d.ts +47 -0
  261. package/dist/support/expiry.js +12 -0
  262. package/dist/support/import-map.d.ts +13 -0
  263. package/dist/support/redirect-target.d.ts +11 -0
  264. package/dist/support/stack-frames.d.ts +56 -0
  265. package/dist/support/trim-slashes.d.ts +11 -0
  266. package/dist/vite/index.d.ts +2 -35
  267. package/dist/vite/index.js +0 -3
  268. package/dist/vite/plugin.d.ts +34 -0
  269. package/package.json +7 -3
  270. package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
  271. package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
  272. package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
  273. package/dist/I18nManager-BiSoczfV.d.ts +0 -275
  274. package/dist/LogManager-7mxnkaPM.d.ts +0 -256
  275. package/dist/McpServiceProvider-7BB5FPF3.js +0 -8
  276. package/dist/Scheduler-pZiT8i57.d.ts +0 -471
  277. package/dist/api-token-D24VPr_E.d.ts +0 -663
  278. package/dist/app-key-CsBfRC_Q.d.ts +0 -214
  279. package/dist/email-verification-Dx426KLn.d.ts +0 -336
  280. package/dist/index-9_Jzj5jo.d.ts +0 -7
  281. package/dist/validation-yAL53e1S.d.ts +0 -2610
@@ -1,110 +1,18 @@
1
- import { P as PasswordHasher } from '../AuthManager-DBP4KYsx.js';
2
- export { A as AuthManager, B as BaseUserProvider, M as ModelUserProvider } from '../AuthManager-DBP4KYsx.js';
3
- import { A as Authenticatable, e as Guard, U as UserProvider, F as Session, a as AuthCredentials } from '../api-token-D24VPr_E.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-D24VPr_E.js';
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-Dx426KLn.js';
7
- import 'hono';
8
-
9
- interface NodeHasherOptions {
10
- /** scrypt cost parameter (N). Defaults to 16384. */
11
- cost?: number;
12
- /** scrypt block size (r). Defaults to 8. */
13
- memory?: number;
14
- /** Salt length in bytes. Defaults to 16. */
15
- saltLength?: number;
16
- /** Derived key length in bytes. Defaults to 64. */
17
- keyLength?: number;
18
- }
19
- /**
20
- * Node.js-compatible password hasher using crypto.scrypt.
21
- * Use this instead of ScryptHasher when deploying to non-Bun runtimes (e.g. AWS Lambda).
22
- */
23
- declare class NodeHasher implements PasswordHasher {
24
- private readonly options;
25
- constructor(options?: NodeHasherOptions);
26
- hash(plain: string): Promise<string>;
27
- verify(hashed: string, plain: string): Promise<boolean>;
28
- needsRehash(hashed: string): boolean;
29
- }
30
-
31
- interface SessionGuardOptions {
32
- provider: UserProvider;
33
- sessionKey?: string;
34
- rememberSessionKey?: string;
35
- session: Session | undefined;
36
- }
37
- declare class SessionGuard<User extends Authenticatable = Authenticatable> implements Guard<User> {
38
- private readonly options;
39
- private cachedUser;
40
- constructor(options: SessionGuardOptions);
41
- private get currentSession();
42
- private get provider();
43
- private sessionKey;
44
- private rememberSessionKey;
45
- private loadRememberedUser;
46
- /** Strip auth-internal fields before a record is cached or exposed. */
47
- private sanitizeUser;
48
- private resolveUser;
49
- check(): Promise<boolean>;
50
- guest(): Promise<boolean>;
51
- user<T = User>(): Promise<T | null>;
52
- id(): Promise<unknown>;
53
- private remember;
54
- login<T = User>(user: T, remember?: boolean): Promise<void>;
55
- logout(): Promise<void>;
56
- attempt(credentials: AuthCredentials, remember?: boolean): Promise<boolean>;
57
- validate(credentials: AuthCredentials): Promise<User | null>;
58
- session<T extends Session = Session>(): T | undefined;
59
- }
60
-
61
- type Argon2Algorithm = 'argon2id' | 'argon2i' | 'argon2d';
62
- type SupportedAlgorithm = Argon2Algorithm | 'bcrypt';
63
- interface BunPasswordHasherOptions {
64
- /**
65
- * Hashing algorithm to use. Defaults to Bun's Argon2id implementation.
66
- */
67
- algorithm?: SupportedAlgorithm;
68
- /** Argon2 memory cost (in kibibytes). */
69
- memoryCost?: number;
70
- /** Argon2 time cost (number of iterations). */
71
- timeCost?: number;
72
- /** Bcrypt cost factor (log rounds). */
73
- cost?: number;
74
- }
75
- declare class ScryptHasher implements PasswordHasher {
76
- private readonly algorithm;
77
- private readonly memoryCost?;
78
- private readonly timeCost?;
79
- private readonly cost?;
80
- constructor(options?: BunPasswordHasherOptions);
81
- hash(plain: string): Promise<string>;
82
- verify(hashed: string, plain: string): Promise<boolean>;
83
- needsRehash(hashed: string): boolean;
84
- }
85
-
86
- declare abstract class AuthenticatableModel<TRecord extends PlainObject = PlainObject> extends Model<TRecord> {
87
- static readonly createType: {
88
- password?: string;
89
- plainPassword?: string;
90
- };
91
- protected static passwordField: string;
92
- protected static passwordHashField: string;
93
- protected static rememberTokenField: string;
94
- protected static passwordHasher: PasswordHasher | null;
95
- protected static resolvePasswordField(): string;
96
- static resolvePasswordHashField(): string;
97
- static resolveRememberTokenField(): string;
98
- /**
99
- * Credential columns can never be mass-assigned: the resolved password-hash
100
- * column (unless the model hashes in place into the password field itself)
101
- * and the remember-token column. Resolved at call time so a renamed column
102
- * stays covered. Use `forceCreate()`/`forceUpdate()` for trusted
103
- * server-side values such as `passwordHash: 'oauth:...'`.
104
- */
105
- protected static deniedFields(): string[];
106
- protected static resolvePasswordHasher(): PasswordHasher;
107
- protected static preparePersistencePayload(data: PlainObject): Promise<PlainObject>;
108
- }
109
-
110
- export { AuthCredentials, Authenticatable, AuthenticatableModel, Guard, NodeHasher, PasswordHasher, ScryptHasher, SessionGuard, UserProvider };
1
+ export { AuthManager } from './AuthManager.js';
2
+ export { SessionGuard } from './SessionGuard.js';
3
+ export { BaseUserProvider } from './providers/UserProvider.js';
4
+ export { ModelUserProvider } from './providers/ModelUserProvider.js';
5
+ export { ScryptHasher } from './password/ScryptHasher.js';
6
+ export { NodeHasher } from './password/NodeHasher.js';
7
+ export { AuthenticatableModel } from './AuthenticatableModel.js';
8
+ export { createPasswordResetToken, verifyPasswordResetToken, completePasswordReset, buildPasswordResetUrl, parsePasswordResetUrl, MemoryPasswordResetStore, } from './password-reset.js';
9
+ export { createEmailVerificationToken, verifyEmailToken, completeEmailVerification, buildVerificationUrl, parseVerificationUrl, isEmailVerified, requireVerifiedEmail, MemoryEmailVerificationStore, } from './email-verification.js';
10
+ export type { PasswordHasher } from './password/PasswordHasher.js';
11
+ export type { PasswordResetConfig, PasswordResetTokenStore, PasswordResetTokenResult, } from './password-reset.js';
12
+ export type { EmailVerificationConfig, EmailVerificationTokenStore, EmailVerificationToken, EmailVerificationTokenResult, } from './email-verification.js';
13
+ export { createApiToken, parseApiToken, verifyApiToken, tokenCan, tokenCanAll, tokenCanAny, revokeApiToken, revokeAllApiTokens, getUserApiTokens, createBearerTokenMiddleware, getApiToken, getApiTokenOrFail, MemoryApiTokenStore, API_TOKEN_KEY, } from './api-token.js';
14
+ export { OAuthManager, MemoryOAuthStateStore, createOAuthManager, createOAuthState, verifyOAuthState, buildOAuthAuthorizeUrl, exchangeOAuthCode, fetchOAuthUserProfile, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createDiscordOAuthProviderConfig, buildOAuthRedirectUrl, parseOAuthRedirectUrl, sanitizeOAuthRedirect, OAUTH_SESSION_BINDING_KEY, } from './oauth/index.js';
15
+ export type { ApiToken, ApiTokenStore, CreateApiTokenOptions, CreateApiTokenResult, BearerTokenMiddlewareOptions, } from './api-token.js';
16
+ export type { OAuthProviderConfig, OAuthTokenResult, OAuthUserProfile, OAuthFallbackEmail, OAuthStatePayload, OAuthStateStore, OAuthStateConfig, OAuthAuthorizeOptions, OAuthCallbackPayload, OAuthManagerOptions, OAuthProviderFactoryInput, OAuthBindingSession, } from './oauth/index.js';
17
+ export type { AuthContext, AuthCredentials, AuthManagerOptions, AuthManagerContract, Authenticatable, Guard, GuardContext, GuardFactory, UserProvider, ProviderFactory, AttachContextOptions, DefaultSanitizedKeys, Sanitized, } from './types.js';
18
+ export { hashToken, generateToken, generateId, secureCompare, secureStringCompare, buildTokenUrl, parseTokenUrl, } from './utils.js';
@@ -9,6 +9,7 @@ import {
9
9
  MemoryPasswordResetStore,
10
10
  ModelUserProvider,
11
11
  NodeHasher,
12
+ OAUTH_SESSION_BINDING_KEY,
12
13
  OAuthManager,
13
14
  ScryptHasher,
14
15
  SessionGuard,
@@ -55,7 +56,8 @@ import {
55
56
  verifyEmailToken,
56
57
  verifyOAuthState,
57
58
  verifyPasswordResetToken
58
- } from "../chunk-J6ETA476.js";
59
+ } from "../chunk-TVV5YNEC.js";
60
+ import "../chunk-3KV5X2FL.js";
59
61
  import "../chunk-DAQKYKLH.js";
60
62
  import "../chunk-SFQP6O52.js";
61
63
  import "../chunk-QQKTH5KX.js";
@@ -70,6 +72,7 @@ export {
70
72
  MemoryPasswordResetStore,
71
73
  ModelUserProvider,
72
74
  NodeHasher,
75
+ OAUTH_SESSION_BINDING_KEY,
73
76
  OAuthManager,
74
77
  ScryptHasher,
75
78
  SessionGuard,
@@ -0,0 +1,239 @@
1
+ export interface OAuthProviderConfig {
2
+ clientId: string;
3
+ clientSecret: string;
4
+ redirectUri: string;
5
+ authorizeUrl: string;
6
+ tokenUrl: string;
7
+ userInfoUrl: string;
8
+ scopes?: string[];
9
+ tokenAuthMethod?: 'client_secret_post' | 'client_secret_basic';
10
+ userInfoMethod?: 'GET' | 'POST';
11
+ mapProfile?: (raw: Record<string, unknown>, token: OAuthTokenResult) => OAuthUserProfile;
12
+ /**
13
+ * Key in the userinfo response carrying the provider's own verification
14
+ * signal for the email address — Discord returns `verified`, for example.
15
+ * Defaults to OIDC's standard `email_verified` claim. Only boolean values
16
+ * are read; anything else leaves `profile.emailVerified` undefined. Ignored
17
+ * when `mapProfile` is set, since that owns the whole mapping.
18
+ */
19
+ emailVerifiedKey?: string;
20
+ /**
21
+ * Fallback used when the userinfo response carries no email — e.g. GitHub
22
+ * returns `email: null` for accounts with a private email even when the
23
+ * `user:email` scope was granted. Returns the email to use, or undefined
24
+ * to leave the profile without one.
25
+ *
26
+ * The signal read via `emailVerifiedKey` does not carry over to a fallback
27
+ * address — it was read against a response that had no email. A bare string
28
+ * therefore makes no verification claim and leaves `profile.emailVerified`
29
+ * undefined; return `{ email, emailVerified: true }` to assert one.
30
+ */
31
+ fetchFallbackEmail?: (token: OAuthTokenResult) => Promise<string | OAuthFallbackEmail | undefined>;
32
+ }
33
+ export interface OAuthFallbackEmail {
34
+ email: string;
35
+ /**
36
+ * Whether the provider verified this specific address. Omit it when the
37
+ * lookup cannot tell — the profile then reports `emailVerified: undefined`
38
+ * rather than an unfounded claim.
39
+ */
40
+ emailVerified?: boolean;
41
+ }
42
+ export interface OAuthTokenResult {
43
+ accessToken: string;
44
+ tokenType?: string;
45
+ refreshToken?: string;
46
+ expiresIn?: number;
47
+ scope?: string;
48
+ raw: Record<string, unknown>;
49
+ }
50
+ export interface OAuthUserProfile {
51
+ id: string;
52
+ email?: string;
53
+ name?: string;
54
+ avatar?: string;
55
+ /**
56
+ * Whether the provider itself verified `email`. Tri-state on purpose:
57
+ * `true` — the provider asserts the address is verified; `false` — it
58
+ * asserts it is not; `undefined` — the provider sends no such signal
59
+ * (GitHub's `/user`, for instance), so the consumer decides its own policy.
60
+ * Returning an email is not by itself a claim that it was checked, so
61
+ * treating `undefined` as verified is a decision, not a default.
62
+ */
63
+ emailVerified?: boolean;
64
+ token: OAuthTokenResult;
65
+ raw: Record<string, unknown>;
66
+ }
67
+ export interface OAuthStatePayload {
68
+ provider: string;
69
+ redirectTo?: string;
70
+ expiresAt: Date;
71
+ /**
72
+ * Hash of the value tying this state to the browser that started the flow.
73
+ *
74
+ * Without it `state` is unguessable and single-use but *transferable*: an
75
+ * attacker can start a flow, capture their own `code`, and walk a victim's
76
+ * browser through the callback, logging the victim into the attacker's
77
+ * account. RFC 6749 §10.12 requires the binding; storing only the provider
78
+ * name does not provide it.
79
+ */
80
+ binding?: string;
81
+ }
82
+ export interface OAuthStateStore {
83
+ store(stateHash: string, payload: OAuthStatePayload): Promise<void>;
84
+ find(stateHash: string): Promise<OAuthStatePayload | null>;
85
+ delete(stateHash: string): Promise<void>;
86
+ /**
87
+ * Atomically fetch and delete a state in one step. Exactly one caller may
88
+ * receive the payload; every other concurrent caller (and any later call)
89
+ * must get null. Expired states must also return null, mirroring `find`.
90
+ *
91
+ * Optional for backward compatibility: `verifyOAuthState` prefers this
92
+ * when present. Stores that only implement find/delete keep working, but
93
+ * leave a window where two concurrent callbacks with the same state can
94
+ * both pass verification.
95
+ */
96
+ consume?(stateHash: string): Promise<OAuthStatePayload | null>;
97
+ }
98
+ export interface OAuthStateConfig {
99
+ expiresIn?: number;
100
+ stateLength?: number;
101
+ hashAlgorithm?: 'sha256' | 'sha512';
102
+ /**
103
+ * External hosts allowed as `redirectTo` targets (supports `*.example.com`
104
+ * wildcards). App-relative paths (`/dashboard`) are always allowed; anything
105
+ * else is dropped to prevent open redirects.
106
+ */
107
+ allowedRedirectHosts?: string[];
108
+ }
109
+ /**
110
+ * The slice of a session the manager needs to bind an OAuth flow to a
111
+ * browser. The framework `Session` satisfies it structurally, so controllers
112
+ * pass `this.auth.session()` straight through; anything else with these three
113
+ * methods (a cookie jar wrapper, a test double) works too.
114
+ */
115
+ export interface OAuthBindingSession {
116
+ get<T = unknown>(key: string): T | undefined;
117
+ set<T = unknown>(key: string, value: T): void;
118
+ forget(key: string): void;
119
+ }
120
+ /** Session key holding the per-browser bindings between authorize and callback. */
121
+ export declare const OAUTH_SESSION_BINDING_KEY = "guren:oauth.bindings";
122
+ export interface OAuthAuthorizeOptions {
123
+ scope?: string[];
124
+ redirectTo?: string;
125
+ state?: string;
126
+ extraParams?: Record<string, string>;
127
+ /**
128
+ * Session of the browser starting the flow — pass `this.auth.session()`.
129
+ *
130
+ * The manager mints a per-browser binding, keeps it in the session, and
131
+ * hashes it into the state; `handleCallback({ session })` presents it back.
132
+ * Writing to the session is also what makes a visitor's brand-new session
133
+ * persist across the provider round trip. `undefined` (no session
134
+ * middleware, or none established yet) leaves the state unbound — the flow
135
+ * still works, and `authorize()` warns once about the exposure.
136
+ */
137
+ session?: OAuthBindingSession;
138
+ /**
139
+ * Bind the flow to the browser that started it, keeping the value yourself.
140
+ *
141
+ * Prefer `session` — it does the storing and consuming for you. Use this
142
+ * when the binding lives somewhere else (an encrypted cookie, a test): pass
143
+ * a value only this browser can present back. Only its hash reaches the
144
+ * state store, and `handleCallback()` then requires the same value. Takes
145
+ * precedence over `session` when both are given.
146
+ */
147
+ bindTo?: string;
148
+ }
149
+ export interface OAuthCallbackPayload {
150
+ code: string;
151
+ state: string;
152
+ /**
153
+ * The same session handed to `authorize({ session })`. The binding is read
154
+ * from it and removed in one step, so a replayed callback finds nothing.
155
+ */
156
+ session?: OAuthBindingSession;
157
+ /**
158
+ * The value handed to `authorize({ bindTo })`, read back from wherever the
159
+ * app kept it. Required when the state was created with a binding. Takes
160
+ * precedence over `session` when both are given.
161
+ */
162
+ bindTo?: string;
163
+ }
164
+ export interface OAuthManagerOptions {
165
+ stateStore?: OAuthStateStore;
166
+ stateConfig?: OAuthStateConfig;
167
+ }
168
+ export declare class MemoryOAuthStateStore implements OAuthStateStore {
169
+ private readonly states;
170
+ private readonly maxEntries;
171
+ constructor(options?: {
172
+ maxEntries?: number;
173
+ });
174
+ store(stateHash: string, payload: OAuthStatePayload): Promise<void>;
175
+ private sweepExpired;
176
+ find(stateHash: string): Promise<OAuthStatePayload | null>;
177
+ delete(stateHash: string): Promise<void>;
178
+ consume(stateHash: string): Promise<OAuthStatePayload | null>;
179
+ clear(): void;
180
+ }
181
+ export declare class OAuthManager {
182
+ private readonly providers;
183
+ private readonly stateStore;
184
+ private readonly stateConfig;
185
+ constructor(options?: OAuthManagerOptions);
186
+ registerProvider(name: string, config: OAuthProviderConfig): void;
187
+ providerNames(): string[];
188
+ getProvider(name: string): OAuthProviderConfig;
189
+ authorize(providerName: string, options?: OAuthAuthorizeOptions): Promise<{
190
+ url: string;
191
+ state: string;
192
+ expiresAt: Date;
193
+ }>;
194
+ user(providerName: string, payload: OAuthCallbackPayload): Promise<OAuthUserProfile>;
195
+ /**
196
+ * Verify the callback and return the user profile together with the
197
+ * sanitized `redirectTo` stored at authorize time. `redirectTo` is safe to
198
+ * pass to a redirect response: app-relative paths and allowlisted hosts
199
+ * only.
200
+ */
201
+ handleCallback(providerName: string, payload: OAuthCallbackPayload): Promise<{
202
+ profile: OAuthUserProfile;
203
+ redirectTo?: string;
204
+ }>;
205
+ }
206
+ export declare function createOAuthManager(options?: OAuthManagerOptions): OAuthManager;
207
+ export declare function createOAuthState(provider: string, store: OAuthStateStore, config?: OAuthStateConfig, redirectTo?: string, fixedState?: string, bindTo?: string): Promise<{
208
+ state: string;
209
+ expiresAt: Date;
210
+ }>;
211
+ export declare function verifyOAuthState(state: string, provider: string, store: OAuthStateStore, config?: OAuthStateConfig, bindTo?: string): Promise<OAuthStatePayload | null>;
212
+ /**
213
+ * Reduce a `redirectTo` value to a safe target: app-relative paths always
214
+ * pass; absolute http(s) URLs pass only when their host is in the allowlist
215
+ * (supports `*.example.com` wildcards). Everything else — protocol-relative
216
+ * URLs, backslash tricks, `javascript:` and other schemes — returns
217
+ * `undefined`.
218
+ */
219
+ export declare function sanitizeOAuthRedirect(redirectTo: string | undefined, allowedHosts?: string[]): string | undefined;
220
+ export declare function buildOAuthAuthorizeUrl(provider: OAuthProviderConfig, state: string, options?: {
221
+ scope?: string[];
222
+ extraParams?: Record<string, string>;
223
+ }): string;
224
+ export declare function exchangeOAuthCode(provider: OAuthProviderConfig, code: string): Promise<OAuthTokenResult>;
225
+ export declare function fetchOAuthUserProfile(provider: OAuthProviderConfig, token: OAuthTokenResult): Promise<OAuthUserProfile>;
226
+ export interface OAuthProviderFactoryInput {
227
+ clientId: string;
228
+ clientSecret: string;
229
+ redirectUri: string;
230
+ scopes?: string[];
231
+ }
232
+ export declare function createGitHubOAuthProviderConfig(input: OAuthProviderFactoryInput): OAuthProviderConfig;
233
+ export declare function createGoogleOAuthProviderConfig(input: OAuthProviderFactoryInput): OAuthProviderConfig;
234
+ export declare function createDiscordOAuthProviderConfig(input: OAuthProviderFactoryInput): OAuthProviderConfig;
235
+ export declare function buildOAuthRedirectUrl(baseUrl: string, token: string, email?: string): string;
236
+ export declare function parseOAuthRedirectUrl(url: string): {
237
+ token: string | null;
238
+ email: string | null;
239
+ };
@@ -0,0 +1,13 @@
1
+ import type { PasswordHasher } from './PasswordHasher.js';
2
+ /**
3
+ * Runtime-detecting password hasher: uses Bun's native scrypt implementation
4
+ * when running on Bun, and the Node.js crypto implementation otherwise
5
+ * (e.g. AWS Lambda on the Node runtime). This is the hasher behind the
6
+ * `Hash` export, so code written against `Hash` runs on both runtimes.
7
+ */
8
+ export declare class DefaultHasher implements PasswordHasher {
9
+ private readonly delegate;
10
+ constructor();
11
+ hash(plain: string): Promise<string>;
12
+ verify(hashed: string, plain: string): Promise<boolean>;
13
+ }
@@ -0,0 +1,22 @@
1
+ import type { PasswordHasher } from './PasswordHasher.js';
2
+ export interface NodeHasherOptions {
3
+ /** scrypt cost parameter (N). Defaults to 16384. */
4
+ cost?: number;
5
+ /** scrypt block size (r). Defaults to 8. */
6
+ memory?: number;
7
+ /** Salt length in bytes. Defaults to 16. */
8
+ saltLength?: number;
9
+ /** Derived key length in bytes. Defaults to 64. */
10
+ keyLength?: number;
11
+ }
12
+ /**
13
+ * Node.js-compatible password hasher using crypto.scrypt.
14
+ * Use this instead of ScryptHasher when deploying to non-Bun runtimes (e.g. AWS Lambda).
15
+ */
16
+ export declare class NodeHasher implements PasswordHasher {
17
+ private readonly options;
18
+ constructor(options?: NodeHasherOptions);
19
+ hash(plain: string): Promise<string>;
20
+ verify(hashed: string, plain: string): Promise<boolean>;
21
+ needsRehash(hashed: string): boolean;
22
+ }
@@ -0,0 +1,5 @@
1
+ export interface PasswordHasher {
2
+ hash(plain: string): Promise<string>;
3
+ verify(hashed: string, plain: string): Promise<boolean>;
4
+ needsRehash?(hashed: string): boolean;
5
+ }
@@ -0,0 +1,26 @@
1
+ import type { PasswordHasher } from './PasswordHasher.js';
2
+ type Argon2Algorithm = 'argon2id' | 'argon2i' | 'argon2d';
3
+ type SupportedAlgorithm = Argon2Algorithm | 'bcrypt';
4
+ export interface BunPasswordHasherOptions {
5
+ /**
6
+ * Hashing algorithm to use. Defaults to Bun's Argon2id implementation.
7
+ */
8
+ algorithm?: SupportedAlgorithm;
9
+ /** Argon2 memory cost (in kibibytes). */
10
+ memoryCost?: number;
11
+ /** Argon2 time cost (number of iterations). */
12
+ timeCost?: number;
13
+ /** Bcrypt cost factor (log rounds). */
14
+ cost?: number;
15
+ }
16
+ export declare class ScryptHasher implements PasswordHasher {
17
+ private readonly algorithm;
18
+ private readonly memoryCost?;
19
+ private readonly timeCost?;
20
+ private readonly cost?;
21
+ constructor(options?: BunPasswordHasherOptions);
22
+ hash(plain: string): Promise<string>;
23
+ verify(hashed: string, plain: string): Promise<boolean>;
24
+ needsRehash(hashed: string): boolean;
25
+ }
26
+ export {};
@@ -0,0 +1,91 @@
1
+ import type { Authenticatable, UserProvider } from './types.js';
2
+ import { buildTokenUrl, parseTokenUrl } from './utils.js';
3
+ /**
4
+ * Configuration for password reset tokens.
5
+ */
6
+ export interface PasswordResetConfig {
7
+ /** Token expiration time in milliseconds (default: 1 hour) */
8
+ expiresIn?: number;
9
+ /** Token byte length before encoding (default: 32) */
10
+ tokenLength?: number;
11
+ }
12
+ /**
13
+ * Storage interface for password reset tokens.
14
+ */
15
+ export interface PasswordResetTokenStore {
16
+ /** Store a token ID with associated email and expiration */
17
+ store(tokenId: string, email: string, expiresAt: Date): Promise<void>;
18
+ /** Find email by token ID, returns null if not found or expired */
19
+ find(tokenId: string): Promise<{
20
+ email: string;
21
+ expiresAt: Date;
22
+ } | null>;
23
+ /** Delete a token ID from storage */
24
+ delete(tokenId: string): Promise<void>;
25
+ /** Delete all tokens for an email */
26
+ deleteForEmail(email: string): Promise<void>;
27
+ }
28
+ /**
29
+ * In-memory token store for testing and development.
30
+ */
31
+ export declare class MemoryPasswordResetStore implements PasswordResetTokenStore {
32
+ private tokens;
33
+ store(tokenId: string, email: string, expiresAt: Date): Promise<void>;
34
+ find(tokenId: string): Promise<{
35
+ email: string;
36
+ expiresAt: Date;
37
+ } | null>;
38
+ delete(tokenId: string): Promise<void>;
39
+ deleteForEmail(email: string): Promise<void>;
40
+ /** Clear all tokens (useful for testing) */
41
+ clear(): void;
42
+ }
43
+ /**
44
+ * Result of creating a password reset token.
45
+ */
46
+ export interface PasswordResetTokenResult {
47
+ /** The plain-text token to send to the user (via email) */
48
+ token: string;
49
+ /** The token ID stored in the backing store */
50
+ tokenId: string;
51
+ /** When the token expires */
52
+ expiresAt: Date;
53
+ }
54
+ /**
55
+ * Create a password reset token for a user.
56
+ *
57
+ * @param email - The user's email address
58
+ * @param store - The token storage implementation
59
+ * @param config - Optional configuration
60
+ * @returns The token result containing plain token and hash
61
+ */
62
+ export declare function createPasswordResetToken(email: string, store: PasswordResetTokenStore, config?: PasswordResetConfig): Promise<PasswordResetTokenResult>;
63
+ /**
64
+ * Verify a password reset token.
65
+ *
66
+ * @param token - The plain-text token from the reset URL
67
+ * @param store - The token storage implementation
68
+ * @param config - Optional configuration (must match createPasswordResetToken config)
69
+ * @returns The email if token is valid, null otherwise
70
+ */
71
+ export declare function verifyPasswordResetToken(token: string, store: PasswordResetTokenStore, _config?: PasswordResetConfig): Promise<string | null>;
72
+ /**
73
+ * Complete a password reset by updating the user's password and invalidating the token.
74
+ *
75
+ * @param token - The plain-text token from the reset URL
76
+ * @param newPassword - The new password (should be validated by caller)
77
+ * @param store - The token storage implementation
78
+ * @param provider - The user provider to look up and update the user
79
+ * @param updatePassword - Function to update the user's password
80
+ * @param config - Optional configuration
81
+ * @returns The user if reset was successful, null if token is invalid
82
+ */
83
+ export declare function completePasswordReset<T extends Authenticatable>(token: string, newPassword: string, store: PasswordResetTokenStore, provider: UserProvider<T>, updatePassword: (user: T, password: string) => Promise<void>, _config?: PasswordResetConfig): Promise<T | null>;
84
+ /**
85
+ * Build a password reset URL from a base URL and token.
86
+ */
87
+ export declare const buildPasswordResetUrl: typeof buildTokenUrl;
88
+ /**
89
+ * Parse a password reset URL to extract the token and optional email.
90
+ */
91
+ export declare const parsePasswordResetUrl: typeof parseTokenUrl;
@@ -0,0 +1,36 @@
1
+ import type { Model } from '@guren/orm';
2
+ import type { PasswordHasher } from '../password/PasswordHasher.js';
3
+ import type { AuthCredentials, Authenticatable } from '../types.js';
4
+ import { BaseUserProvider } from './UserProvider.js';
5
+ export interface ModelUserProviderOptions {
6
+ idColumn?: string;
7
+ usernameColumn?: string;
8
+ passwordColumn?: string;
9
+ rememberTokenColumn?: string;
10
+ hasher?: PasswordHasher;
11
+ credentialsPasswordField?: string;
12
+ }
13
+ export declare class ModelUserProvider<User extends Authenticatable = Authenticatable> extends BaseUserProvider<User> {
14
+ private readonly model;
15
+ private readonly idColumn;
16
+ private readonly usernameColumn;
17
+ private readonly passwordColumn;
18
+ private readonly rememberTokenColumn;
19
+ private readonly hasher;
20
+ private readonly credentialsPasswordField;
21
+ constructor(model: typeof Model, options?: ModelUserProviderOptions);
22
+ private cast;
23
+ retrieveById(identifier: unknown): Promise<User | null>;
24
+ retrieveByCredentials(credentials: AuthCredentials): Promise<User | null>;
25
+ validateCredentials(user: User, credentials: AuthCredentials): Promise<boolean>;
26
+ getId(user: User): unknown;
27
+ /**
28
+ * Strip the password hash, remember token, and the model's `hidden`
29
+ * fields before the record leaves the auth layer. Credential
30
+ * validation happens on the raw record before sanitizing, so this
31
+ * never affects login — only what `auth.user()` exposes.
32
+ */
33
+ sanitize(user: User): User;
34
+ setRememberToken(user: User, token: string | null): Promise<void>;
35
+ getRememberToken(user: User): Promise<string | null>;
36
+ }
@@ -0,0 +1,9 @@
1
+ import type { AuthCredentials, Authenticatable, UserProvider } from '../types.js';
2
+ export declare abstract class BaseUserProvider<User extends Authenticatable = Authenticatable> implements UserProvider<User> {
3
+ abstract retrieveById(identifier: unknown): Promise<User | null>;
4
+ abstract retrieveByCredentials(credentials: AuthCredentials): Promise<User | null>;
5
+ abstract validateCredentials(user: User, credentials: AuthCredentials): Promise<boolean>;
6
+ abstract getId(user: User): unknown;
7
+ setRememberToken(user: User, token: string | null): Promise<void>;
8
+ getRememberToken(user: User): Promise<string | null>;
9
+ }