@guren/server 2.15.0 → 2.16.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 (296) hide show
  1. package/dist/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
  2. package/dist/{Hash-C8aejmi8.js → Hash-D2DFd8xX.js} +7 -57
  3. package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
  4. package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
  5. package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-nNcbCIQX.js} +11 -20
  6. package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
  7. package/dist/agent/AgentApprovalRequested.d.ts +11 -39
  8. package/dist/agent/approval.d.ts +76 -187
  9. package/dist/agent/audit-emitter.d.ts +16 -44
  10. package/dist/agent/audit.d.ts +20 -56
  11. package/dist/agent/derive.d.ts +32 -66
  12. package/dist/agent/dispatch.d.ts +38 -90
  13. package/dist/agent/events.d.ts +11 -19
  14. package/dist/agent/meta-tools.d.ts +18 -46
  15. package/dist/agent/public.d.ts +6 -25
  16. package/dist/agent/public.js +1 -1
  17. package/dist/agent/redact.d.ts +16 -38
  18. package/dist/agent/scopes.d.ts +23 -69
  19. package/dist/auth/AuthManager.d.ts +19 -40
  20. package/dist/auth/AuthenticatableModel.d.ts +2 -2
  21. package/dist/auth/SessionGuard.d.ts +0 -1
  22. package/dist/auth/TokenGuard.d.ts +6 -26
  23. package/dist/auth/api-token.d.ts +16 -148
  24. package/dist/auth/context.d.ts +5 -10
  25. package/dist/auth/email-verification.d.ts +29 -127
  26. package/dist/auth/index.js +1 -1
  27. package/dist/auth/oauth/index.d.ts +35 -57
  28. package/dist/auth/password/DefaultHasher.d.ts +5 -14
  29. package/dist/auth/password/PasswordHasher.d.ts +5 -13
  30. package/dist/auth/password/hash-format.d.ts +5 -13
  31. package/dist/auth/password-reset.d.ts +16 -42
  32. package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
  33. package/dist/auth/providers/UserProvider.d.ts +4 -4
  34. package/dist/auth/signed-token.d.ts +18 -0
  35. package/dist/auth/types.d.ts +9 -32
  36. package/dist/auth/utils.d.ts +6 -27
  37. package/dist/{auth-DkYoAPVn.js → auth-CbdPH4Cd.js} +169 -502
  38. package/dist/authorization/Gate.d.ts +9 -145
  39. package/dist/authorization/Policy.d.ts +6 -53
  40. package/dist/authorization/index.js +1 -1
  41. package/dist/authorization/middleware.d.ts +16 -62
  42. package/dist/authorization/types.d.ts +8 -64
  43. package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
  44. package/dist/broadcasting/BroadcastManager.d.ts +29 -149
  45. package/dist/broadcasting/channels/Channel.d.ts +1 -19
  46. package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
  47. package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
  48. package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
  49. package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
  50. package/dist/broadcasting/drivers/index.d.ts +1 -1
  51. package/dist/broadcasting/index.d.ts +1 -1
  52. package/dist/broadcasting/index.js +1 -1
  53. package/dist/broadcasting/types.d.ts +7 -88
  54. package/dist/{broadcasting-BwodCA4q.js → broadcasting-B5RzB0A2.js} +87 -414
  55. package/dist/cache/CacheManager.d.ts +8 -62
  56. package/dist/cache/TaggedCache.d.ts +2 -35
  57. package/dist/cache/index.js +1 -1
  58. package/dist/cache/stores/FileStore.d.ts +2 -36
  59. package/dist/cache/stores/MemoryStore.d.ts +2 -26
  60. package/dist/cache/stores/RedisStore.d.ts +1 -29
  61. package/dist/cache/types.d.ts +21 -128
  62. package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
  63. package/dist/client-C4TEr_Dd.js +9 -0
  64. package/dist/console/Command.d.ts +17 -126
  65. package/dist/console/ConsoleKernel.d.ts +2 -74
  66. package/dist/console/Input.d.ts +5 -113
  67. package/dist/console/Output.d.ts +3 -99
  68. package/dist/console/types.d.ts +3 -33
  69. package/dist/container/Container.d.ts +12 -103
  70. package/dist/container/ServiceProvider.d.ts +17 -61
  71. package/dist/container/bindings.d.ts +5 -26
  72. package/dist/container/defineModule.d.ts +16 -54
  73. package/dist/container/definePlugin.d.ts +12 -45
  74. package/dist/container/types.d.ts +2 -34
  75. package/dist/context-CXk_umpT.js +21 -0
  76. package/dist/database/Factory.d.ts +4 -57
  77. package/dist/database/Seeder.d.ts +8 -46
  78. package/dist/database/SeederRunner.d.ts +3 -33
  79. package/dist/database/types.d.ts +3 -24
  80. package/dist/discovery/AutoDiscovery.d.ts +10 -82
  81. package/dist/{dispatch-erOS9epZ.js → dispatch-BAwzftws.js} +32 -79
  82. package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
  83. package/dist/docs-viewer/endpoint.d.ts +5 -11
  84. package/dist/encryption/Encrypter.d.ts +5 -71
  85. package/dist/encryption/Hash.d.ts +7 -57
  86. package/dist/encryption/Random.d.ts +6 -99
  87. package/dist/encryption/index.js +3 -3
  88. package/dist/encryption/types.d.ts +10 -72
  89. package/dist/{encryption-D99Vmls3.js → encryption-uwP3Di4D.js} +9 -78
  90. package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
  91. package/dist/endpoint-Dsw3Acvq.js +26 -0
  92. package/dist/errors/ExceptionHandler.d.ts +3 -90
  93. package/dist/errors/HttpException.d.ts +2 -79
  94. package/dist/errors/debug-page.d.ts +3 -17
  95. package/dist/errors/error-page.d.ts +1 -0
  96. package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
  97. package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
  98. package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
  99. package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
  100. package/dist/errors/exceptions/ValidationException.d.ts +2 -43
  101. package/dist/errors/types.d.ts +1 -25
  102. package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
  103. package/dist/events/Event.d.ts +1 -28
  104. package/dist/events/EventManager.d.ts +5 -107
  105. package/dist/events/Listener.d.ts +7 -55
  106. package/dist/events/builtin.d.ts +0 -24
  107. package/dist/events/index.js +1 -1
  108. package/dist/events/types.d.ts +4 -22
  109. package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
  110. package/dist/facades/index.d.ts +2 -14
  111. package/dist/health/HealthCheck.d.ts +0 -24
  112. package/dist/health/HealthManager.d.ts +0 -36
  113. package/dist/health/checks/CacheCheck.d.ts +2 -17
  114. package/dist/health/checks/CustomCheck.d.ts +0 -9
  115. package/dist/health/checks/DatabaseCheck.d.ts +2 -17
  116. package/dist/health/checks/MemoryCheck.d.ts +3 -12
  117. package/dist/health/checks/RedisCheck.d.ts +1 -13
  118. package/dist/health/checks/StorageCheck.d.ts +2 -17
  119. package/dist/health/index.js +1 -1
  120. package/dist/health/types.d.ts +4 -24
  121. package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
  122. package/dist/hot-disposables-B5BXqaIH.js +167 -0
  123. package/dist/hot-reload/hot-disposables.d.ts +22 -74
  124. package/dist/hot-reload/testing.d.ts +4 -9
  125. package/dist/http/Application.d.ts +62 -208
  126. package/dist/http/FormRequest.d.ts +4 -55
  127. package/dist/http/dev-assets.d.ts +13 -31
  128. package/dist/http/dev-banner.d.ts +2 -5
  129. package/dist/http/inertia-assets.d.ts +3 -6
  130. package/dist/http/middleware/capabilities.d.ts +27 -50
  131. package/dist/http/middleware/cors.d.ts +4 -29
  132. package/dist/http/middleware/csp.d.ts +2 -25
  133. package/dist/http/middleware/csrf.d.ts +20 -95
  134. package/dist/http/middleware/detect-locale.d.ts +7 -27
  135. package/dist/http/middleware/force-https.d.ts +6 -24
  136. package/dist/http/middleware/host-authorization.d.ts +2 -12
  137. package/dist/http/middleware/loopback-guard.d.ts +15 -33
  138. package/dist/http/middleware/rate-limit.d.ts +29 -126
  139. package/dist/http/middleware/redirect-safety.d.ts +2 -20
  140. package/dist/http/middleware/request-id.d.ts +1 -14
  141. package/dist/http/middleware/request-logging.d.ts +2 -13
  142. package/dist/http/middleware/response-headers.d.ts +5 -13
  143. package/dist/http/middleware/security-headers.d.ts +2 -16
  144. package/dist/http/middleware/session.d.ts +15 -34
  145. package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
  146. package/dist/http/middleware/validation.d.ts +8 -63
  147. package/dist/http/public-assets.d.ts +11 -7
  148. package/dist/http/request.d.ts +32 -118
  149. package/dist/http/resources/CursorPaginator.d.ts +5 -64
  150. package/dist/http/resources/Paginator.d.ts +7 -84
  151. package/dist/http/resources/Resource.d.ts +9 -65
  152. package/dist/http/resources/ResourceCollection.d.ts +5 -39
  153. package/dist/http/resources/types.d.ts +10 -30
  154. package/dist/http/static-documents.d.ts +10 -20
  155. package/dist/http/validation/Validator.d.ts +25 -85
  156. package/dist/http/validation/rules.d.ts +48 -147
  157. package/dist/http/validation/types.d.ts +16 -61
  158. package/dist/http/vite-assets.d.ts +5 -28
  159. package/dist/http/vite-dev-server.d.ts +6 -9
  160. package/dist/http/vite-manifest.d.ts +19 -33
  161. package/dist/i18n/I18nManager.d.ts +12 -78
  162. package/dist/i18n/Translator.d.ts +3 -54
  163. package/dist/i18n/index.js +1 -1
  164. package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
  165. package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
  166. package/dist/i18n/pluralization.d.ts +4 -13
  167. package/dist/i18n/types.d.ts +17 -69
  168. package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
  169. package/dist/index.d.ts +2 -1
  170. package/dist/index.js +714 -3011
  171. package/dist/internal/agent-preflight.d.ts +9 -21
  172. package/dist/internal/request.d.ts +6 -19
  173. package/dist/internal/request.js +1 -1
  174. package/dist/internal/route-path.d.ts +9 -21
  175. package/dist/internal/route-path.js +9 -21
  176. package/dist/internal/zod-compat.d.ts +55 -122
  177. package/dist/internal/zod-compat.js +39 -70
  178. package/dist/internal/zod-json-schema.d.ts +18 -54
  179. package/dist/internal/zod-json-schema.js +46 -123
  180. package/dist/jsx-runtime.d.ts +3 -8
  181. package/dist/lambda/index.d.ts +17 -79
  182. package/dist/lambda/index.js +11 -59
  183. package/dist/logging/LogManager.d.ts +1 -51
  184. package/dist/logging/Logger.d.ts +8 -47
  185. package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
  186. package/dist/logging/channels/DailyFileChannel.d.ts +1 -3
  187. package/dist/logging/channels/FileChannel.d.ts +1 -3
  188. package/dist/logging/daily-file-path.d.ts +7 -16
  189. package/dist/logging/index.js +1 -1
  190. package/dist/logging/types.d.ts +13 -45
  191. package/dist/{logging-B-kngi3q.js → logging-zOY1XCtq.js} +52 -141
  192. package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
  193. package/dist/mail/Mail.d.ts +10 -106
  194. package/dist/mail/MailManager.d.ts +2 -60
  195. package/dist/mail/index.js +1 -1
  196. package/dist/mail/transports/LogTransport.d.ts +1 -4
  197. package/dist/mail/transports/MemoryTransport.d.ts +1 -63
  198. package/dist/mail/transports/ResendTransport.d.ts +1 -23
  199. package/dist/mail/transports/SmtpTransport.d.ts +1 -31
  200. package/dist/mail/types.d.ts +28 -150
  201. package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
  202. package/dist/mcp/McpServiceProvider.d.ts +4 -10
  203. package/dist/mcp/create-mcp-server.d.ts +25 -57
  204. package/dist/mcp/endpoint.d.ts +12 -36
  205. package/dist/mcp/index.js +1 -1
  206. package/dist/mvc/Controller.d.ts +46 -227
  207. package/dist/mvc/Router.d.ts +50 -129
  208. package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
  209. package/dist/mvc/inertia/shared.d.ts +6 -19
  210. package/dist/mvc/mount-route.d.ts +2 -6
  211. package/dist/mvc/view.d.ts +1 -2
  212. package/dist/notifications/Notification.d.ts +8 -75
  213. package/dist/notifications/NotificationManager.d.ts +15 -88
  214. package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
  215. package/dist/notifications/channels/MailChannel.d.ts +2 -31
  216. package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
  217. package/dist/notifications/channels/SlackChannel.d.ts +3 -48
  218. package/dist/notifications/index.js +1 -1
  219. package/dist/notifications/notifiable-type.d.ts +3 -6
  220. package/dist/notifications/registry.d.ts +8 -27
  221. package/dist/notifications/types.d.ts +16 -53
  222. package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
  223. package/dist/providers/AuthServiceProvider.d.ts +1 -3
  224. package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
  225. package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
  226. package/dist/providers/CacheServiceProvider.d.ts +1 -3
  227. package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
  228. package/dist/providers/ErrorServiceProvider.d.ts +1 -4
  229. package/dist/providers/EventServiceProvider.d.ts +1 -3
  230. package/dist/providers/HealthServiceProvider.d.ts +1 -3
  231. package/dist/providers/I18nServiceProvider.d.ts +6 -10
  232. package/dist/providers/InertiaServiceProvider.d.ts +1 -4
  233. package/dist/providers/LogServiceProvider.d.ts +1 -3
  234. package/dist/providers/MailServiceProvider.d.ts +1 -3
  235. package/dist/providers/NotificationServiceProvider.d.ts +1 -3
  236. package/dist/providers/OAuthServiceProvider.d.ts +1 -3
  237. package/dist/providers/QueueServiceProvider.d.ts +1 -3
  238. package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
  239. package/dist/providers/StorageServiceProvider.d.ts +1 -3
  240. package/dist/queue/FailedJobReporter.d.ts +1 -24
  241. package/dist/queue/Job.d.ts +12 -99
  242. package/dist/queue/QueueManager.d.ts +6 -57
  243. package/dist/queue/Worker.d.ts +4 -65
  244. package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
  245. package/dist/queue/drivers/RedisDriver.d.ts +7 -65
  246. package/dist/queue/drivers/SqsDriver.d.ts +6 -57
  247. package/dist/queue/drivers/SyncDriver.d.ts +10 -13
  248. package/dist/queue/index.js +2 -2
  249. package/dist/queue/types.d.ts +10 -92
  250. package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
  251. package/dist/redis/RedisApiTokenStore.d.ts +4 -56
  252. package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
  253. package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
  254. package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
  255. package/dist/redis/RedisRateLimitStore.d.ts +16 -49
  256. package/dist/redis/RedisSessionStore.d.ts +3 -44
  257. package/dist/redis/client.d.ts +2 -32
  258. package/dist/redis/index.js +47 -232
  259. package/dist/redis/redis-values.d.ts +6 -12
  260. package/dist/redis/scan-keys.d.ts +1 -4
  261. package/dist/request-CLOYytGP.js +68 -0
  262. package/dist/runtime/index.d.ts +2 -0
  263. package/dist/runtime/index.js +50 -92
  264. package/dist/scheduling/CronParser.d.ts +0 -29
  265. package/dist/scheduling/Schedule.d.ts +1 -153
  266. package/dist/scheduling/ScheduledTask.d.ts +0 -31
  267. package/dist/scheduling/Scheduler.d.ts +0 -70
  268. package/dist/scheduling/index.js +1 -1
  269. package/dist/scheduling/types.d.ts +4 -65
  270. package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
  271. package/dist/storage/StorageManager.d.ts +0 -48
  272. package/dist/storage/drivers/LocalDriver.d.ts +1 -25
  273. package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
  274. package/dist/storage/drivers/S3Driver.d.ts +6 -36
  275. package/dist/storage/drivers/s3-acl.d.ts +5 -10
  276. package/dist/storage/index.js +1 -1
  277. package/dist/storage/types.d.ts +27 -265
  278. package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
  279. package/dist/support/contained-path.d.ts +10 -20
  280. package/dist/support/error-polyfill.d.ts +4 -6
  281. package/dist/support/expiry.d.ts +17 -33
  282. package/dist/support/expiry.js +17 -33
  283. package/dist/support/import-map.d.ts +3 -7
  284. package/dist/support/inertia-defaults.d.ts +5 -10
  285. package/dist/support/redirect-target.d.ts +4 -6
  286. package/dist/support/stack-frames.d.ts +11 -50
  287. package/dist/support/trim-slashes.d.ts +4 -7
  288. package/dist/support/warn-once.d.ts +2 -6
  289. package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
  290. package/dist/{vite-manifest-w_RSOvQW.js → vite-manifest-CTQp-SOo.js} +34 -58
  291. package/package.json +2 -2
  292. package/dist/client-Dd7vLcqp.js +0 -27
  293. package/dist/context-DoD0c7J_.js +0 -26
  294. package/dist/endpoint-D-20PiHY.js +0 -46
  295. package/dist/hot-disposables-WsTX2ySN.js +0 -281
  296. package/dist/request-CVQwpu2J.js +0 -129
@@ -1,7 +1,7 @@
1
1
  import { buildTokenUrl, parseTokenUrl } from './utils.js';
2
2
  /**
3
- * Email verification token data stored in the backing store.
4
- * Only the hashed token is stored for security.
3
+ * Email verification token data stored in the backing store. Only the opaque
4
+ * token ID is stored, never the signed token itself.
5
5
  */
6
6
  export interface EmailVerificationToken {
7
7
  email: string;
@@ -10,48 +10,35 @@ export interface EmailVerificationToken {
10
10
  createdAt: Date;
11
11
  }
12
12
  /**
13
- * Store interface for email verification tokens.
14
- * Implement this to use database-backed storage.
13
+ * Store interface for email verification tokens. The store answers whether a
14
+ * token ID still exists, which is what gives single use and revocation; expiry
15
+ * is decided from the claim signed into the token.
15
16
  */
16
17
  export interface EmailVerificationTokenStore {
17
- /**
18
- * Store a new verification token.
19
- */
18
+ /** Store a new verification token. */
20
19
  store(token: EmailVerificationToken): Promise<void>;
21
- /**
22
- * Find a token by its opaque token ID.
23
- */
20
+ /** Find a token by its opaque token ID. */
24
21
  findByTokenId(tokenId: string): Promise<EmailVerificationToken | null>;
25
- /**
26
- * Delete a token by its opaque token ID.
27
- */
22
+ /** Delete a token by its opaque token ID. */
28
23
  delete(tokenId: string): Promise<void>;
29
- /**
30
- * Delete all tokens for a given email.
31
- */
24
+ /** Delete all tokens for a given email. */
32
25
  deleteForEmail(email: string): Promise<void>;
33
26
  }
34
- /**
35
- * In-memory store for testing purposes.
36
- * Do NOT use in production - tokens will be lost on restart.
37
- */
27
+ /** In-memory store for testing. Tokens are lost on restart. */
38
28
  export declare class MemoryEmailVerificationStore implements EmailVerificationTokenStore {
39
29
  private tokens;
40
30
  store(token: EmailVerificationToken): Promise<void>;
41
31
  findByTokenId(tokenId: string): Promise<EmailVerificationToken | null>;
42
32
  delete(tokenId: string): Promise<void>;
43
33
  deleteForEmail(email: string): Promise<void>;
44
- /**
45
- * Clear all tokens (useful for testing).
46
- */
34
+ /** Clear all tokens (useful for testing). */
47
35
  clear(): void;
48
- /**
49
- * Get the count of stored tokens (useful for testing).
50
- */
36
+ /** Count of stored tokens (useful for testing). */
51
37
  get size(): number;
52
38
  }
53
39
  /**
54
- * Configuration options for email verification.
40
+ * Configuration options for email verification. Applies at issuance only: the
41
+ * expiry is signed into the token, so the verify functions take no config.
55
42
  */
56
43
  export interface EmailVerificationConfig {
57
44
  /**
@@ -65,129 +52,44 @@ export interface EmailVerificationConfig {
65
52
  */
66
53
  tokenLength?: number;
67
54
  }
68
- /**
69
- * Result of creating an email verification token.
70
- */
55
+ /** Result of creating an email verification token. */
71
56
  export interface EmailVerificationTokenResult {
72
57
  /**
73
- * The raw token to send to the user via email.
74
- * This is NOT stored - only the hash is stored.
58
+ * The raw token to send to the user via email. Not stored — only its opaque
59
+ * token ID is.
75
60
  */
76
61
  token: string;
77
- /**
78
- * When the token expires.
79
- */
62
+ /** When the token expires. */
80
63
  expiresAt: Date;
81
64
  }
82
65
  /**
83
- * Create a new email verification token.
84
- *
85
- * @param email - The email address to verify
86
- * @param store - Token store implementation
87
- * @param config - Optional configuration
88
- * @returns The raw token to send via email
89
- *
90
- * @example
91
- * ```ts
92
- * const { token, expiresAt } = await createEmailVerificationToken(
93
- * user.email,
94
- * verificationStore
95
- * )
96
- *
97
- * // Send email with verification link
98
- * await sendEmail({
99
- * to: user.email,
100
- * subject: 'Verify your email',
101
- * html: `<a href="${buildVerificationUrl(baseUrl, token)}">Verify Email</a>`,
102
- * })
103
- * ```
66
+ * Create a new email verification token; the raw token is returned to send by
67
+ * email and is never stored.
104
68
  */
105
69
  export declare function createEmailVerificationToken(email: string, store: EmailVerificationTokenStore, config?: EmailVerificationConfig): Promise<EmailVerificationTokenResult>;
106
70
  /**
107
- * Verify an email verification token.
108
- *
109
- * @param token - The raw token from the verification link
110
- * @param store - Token store implementation
111
- * @param config - Optional configuration (not currently used, reserved for future)
112
- * @returns The email address if valid, null if invalid or expired
113
- *
114
- * @example
115
- * ```ts
116
- * const email = await verifyEmailToken(token, verificationStore)
117
- *
118
- * if (!email) {
119
- * return ctx.json({ error: 'Invalid or expired token' }, 400)
120
- * }
121
- *
122
- * // Mark user as verified
123
- * await User.update({ email }, { emailVerifiedAt: new Date() })
124
- * ```
71
+ * Verify an email verification token, returning the email address it was
72
+ * issued for or `null` when it is invalid or expired.
125
73
  */
126
- export declare function verifyEmailToken(token: string, store: EmailVerificationTokenStore, _config?: EmailVerificationConfig): Promise<string | null>;
74
+ export declare function verifyEmailToken(token: string, store: EmailVerificationTokenStore): Promise<string | null>;
127
75
  /**
128
- * Complete email verification by consuming the token.
129
- *
130
- * @param token - The raw token from the verification link
131
- * @param store - Token store implementation
132
- * @param markVerified - Function to mark the user as verified
133
- * @returns The result of markVerified if successful, null if token invalid
134
- *
135
- * @example
136
- * ```ts
137
- * const result = await completeEmailVerification(
138
- * token,
139
- * verificationStore,
140
- * async (email) => {
141
- * await User.update({ email }, { emailVerifiedAt: new Date() })
142
- * return User.findByEmail(email)
143
- * }
144
- * )
145
- *
146
- * if (!result) {
147
- * return ctx.json({ error: 'Invalid or expired token' }, 400)
148
- * }
149
- *
150
- * return ctx.redirect('/dashboard')
151
- * ```
76
+ * Complete email verification by consuming the token. Returns the result of
77
+ * `markVerified`, or `null` when the token is invalid.
152
78
  */
153
79
  export declare function completeEmailVerification<T>(token: string, store: EmailVerificationTokenStore, markVerified: (email: string) => Promise<T>): Promise<T | null>;
154
- /**
155
- * Build a verification URL.
156
- */
80
+ /** Build a verification URL. */
157
81
  export declare const buildVerificationUrl: typeof buildTokenUrl;
158
- /**
159
- * Parse a verification URL to extract token and email.
160
- */
82
+ /** Parse a verification URL to extract token and email. */
161
83
  export declare const parseVerificationUrl: typeof parseTokenUrl;
162
- /**
163
- * Check if a user's email is verified.
164
- * Helper function for use with User models.
165
- *
166
- * @param user - User object with emailVerifiedAt field
167
- * @returns true if verified, false otherwise
168
- *
169
- * @example
170
- * ```ts
171
- * if (!isEmailVerified(user)) {
172
- * return ctx.redirect('/verify-email')
173
- * }
174
- * ```
175
- */
84
+ /** Whether a user's `emailVerifiedAt` is set. */
176
85
  export declare function isEmailVerified(user: {
177
86
  emailVerifiedAt?: Date | null;
178
87
  } | null): boolean;
179
88
  /**
180
89
  * Middleware factory to require verified email.
181
- *
182
- * @param options - Configuration options
183
- * @returns Middleware function
184
- *
185
90
  * @example
186
91
  * ```ts
187
- * router.get('/dashboard', [DashboardController, 'index'],
188
- * requireAuthenticated(),
189
- * requireVerifiedEmail({ redirectTo: '/verify-email' })
190
- * )
92
+ * requireVerifiedEmail({ redirectTo: '/verify-email' })
191
93
  * ```
192
94
  */
193
95
  export declare function requireVerifiedEmail(options?: {
@@ -1,2 +1,2 @@
1
- import { $ as buildTokenUrl, A as verifyOAuthState, B as getApiToken, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, F as TokenGuard, G as readBearerToken, H as getUserApiTokens, I as API_TOKEN_KEY, J as tokenCan, K as revokeAllApiTokens, L as MemoryApiTokenStore, O as parseOAuthRedirectUrl, P as AuthManager, Q as SessionGuard, R as createApiToken, S as createGitHubOAuthProviderConfig, T as createOAuthState, V as getApiTokenOrFail, W as parseApiToken, X as tokenCanAny, Y as tokenCanAll, Z as verifyApiToken, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, at as secureStringCompare, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, et as generateId, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, it as secureCompare, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, lt as NodeHasher, m as verifyPasswordResetToken, n as buildVerificationUrl, nt as hashToken, o as parseVerificationUrl, ot as ModelUserProvider, p as parsePasswordResetUrl, q as revokeApiToken, r as completeEmailVerification, rt as parseTokenUrl, s as requireVerifiedEmail, st as BaseUserProvider, t as MemoryEmailVerificationStore, tt as generateToken, u as buildPasswordResetUrl, ut as ScryptHasher, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as createBearerTokenMiddleware } from "../auth-DkYoAPVn.js";
1
+ import { $ as buildTokenUrl, A as verifyOAuthState, B as getApiToken, C as createGoogleOAuthProviderConfig, D as fetchOAuthUserProfile, E as exchangeOAuthCode, F as TokenGuard, G as readBearerToken, H as getUserApiTokens, I as API_TOKEN_KEY, J as tokenCan, K as revokeAllApiTokens, L as MemoryApiTokenStore, O as parseOAuthRedirectUrl, P as AuthManager, Q as SessionGuard, R as createApiToken, S as createGitHubOAuthProviderConfig, T as createOAuthState, V as getApiTokenOrFail, W as parseApiToken, X as tokenCanAny, Y as tokenCanAll, Z as verifyApiToken, _ as OAUTH_SESSION_BINDING_KEY, a as isEmailVerified, at as secureStringCompare, b as buildOAuthRedirectUrl, c as verifyEmailToken, d as completePasswordReset, et as generateId, f as createPasswordResetToken, g as MemoryOAuthStateStore, h as AuthenticatableModel, i as createEmailVerificationToken, it as secureCompare, k as sanitizeOAuthRedirect, l as MemoryPasswordResetStore, lt as NodeHasher, m as verifyPasswordResetToken, n as buildVerificationUrl, nt as hashToken, o as parseVerificationUrl, ot as ModelUserProvider, p as parsePasswordResetUrl, q as revokeApiToken, r as completeEmailVerification, rt as parseTokenUrl, s as requireVerifiedEmail, st as BaseUserProvider, t as MemoryEmailVerificationStore, tt as generateToken, u as buildPasswordResetUrl, ut as ScryptHasher, v as OAuthManager, w as createOAuthManager, x as createDiscordOAuthProviderConfig, y as buildOAuthAuthorizeUrl, z as createBearerTokenMiddleware } from "../auth-CbdPH4Cd.js";
2
2
  export { API_TOKEN_KEY, AuthManager, AuthenticatableModel, BaseUserProvider, MemoryApiTokenStore, MemoryEmailVerificationStore, MemoryOAuthStateStore, MemoryPasswordResetStore, ModelUserProvider, NodeHasher, OAUTH_SESSION_BINDING_KEY, OAuthManager, ScryptHasher, SessionGuard, TokenGuard, buildOAuthAuthorizeUrl, buildOAuthRedirectUrl, buildPasswordResetUrl, buildTokenUrl, buildVerificationUrl, completeEmailVerification, completePasswordReset, createApiToken, createBearerTokenMiddleware, createDiscordOAuthProviderConfig, createEmailVerificationToken, createGitHubOAuthProviderConfig, createGoogleOAuthProviderConfig, createOAuthManager, createOAuthState, createPasswordResetToken, exchangeOAuthCode, fetchOAuthUserProfile, generateId, generateToken, getApiToken, getApiTokenOrFail, getUserApiTokens, hashToken, isEmailVerified, parseApiToken, parseOAuthRedirectUrl, parsePasswordResetUrl, parseTokenUrl, parseVerificationUrl, readBearerToken, requireVerifiedEmail, revokeAllApiTokens, revokeApiToken, sanitizeOAuthRedirect, secureCompare, secureStringCompare, tokenCan, tokenCanAll, tokenCanAny, verifyApiToken, verifyEmailToken, verifyOAuthState, verifyPasswordResetToken };
@@ -11,22 +11,16 @@ export interface OAuthProviderConfig {
11
11
  mapProfile?: (raw: Record<string, unknown>, token: OAuthTokenResult) => OAuthUserProfile;
12
12
  /**
13
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.
14
+ * signal (Discord returns `verified`); defaults to OIDC's `email_verified`.
15
+ * Only boolean values are read. Ignored when `mapProfile` is set.
18
16
  */
19
17
  emailVerifiedKey?: string;
20
18
  /**
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.
19
+ * Fallback used when the userinfo response carries no email — GitHub returns
20
+ * `email: null` for a private address even with the `user:email` scope.
21
+ * `emailVerifiedKey` does not carry over: it was read against a response that
22
+ * had no email. A bare string therefore makes no verification claim; return
23
+ * `{ email, emailVerified: true }` to assert one.
30
24
  */
31
25
  fetchFallbackEmail?: (token: OAuthTokenResult) => Promise<string | OAuthFallbackEmail | undefined>;
32
26
  }
@@ -54,11 +48,9 @@ export interface OAuthUserProfile {
54
48
  avatar?: string;
55
49
  /**
56
50
  * 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.
51
+ * `undefined` means the provider sends no such signal (GitHub's `/user`), so
52
+ * the consumer decides its own policy — returning an email is not by itself a
53
+ * claim that it was checked.
62
54
  */
63
55
  emailVerified?: boolean;
64
56
  token: OAuthTokenResult;
@@ -70,12 +62,9 @@ export interface OAuthStatePayload {
70
62
  expiresAt: Date;
71
63
  /**
72
64
  * Hash of the value tying this state to the browser that started the flow.
73
- *
74
65
  * Without it `state` is unguessable and single-use but *transferable*: an
75
66
  * 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.
67
+ * browser through the callback into the attacker's account (RFC 6749 §10.12).
79
68
  */
80
69
  binding?: string;
81
70
  }
@@ -84,14 +73,11 @@ export interface OAuthStateStore {
84
73
  find(stateHash: string): Promise<OAuthStatePayload | null>;
85
74
  delete(stateHash: string): Promise<void>;
86
75
  /**
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.
76
+ * Atomically fetch and delete a state. Exactly one caller may receive the
77
+ * payload; every other concurrent or later call must get null, as must an
78
+ * expired state. Optional for backward compatibility — stores implementing
79
+ * only find/delete keep working, but leave a window where two concurrent
80
+ * callbacks with the same state both pass verification.
95
81
  */
96
82
  consume?(stateHash: string): Promise<OAuthStatePayload | null>;
97
83
  }
@@ -107,10 +93,9 @@ export interface OAuthStateConfig {
107
93
  allowedRedirectHosts?: string[];
108
94
  }
109
95
  /**
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.
96
+ * The slice of a session the manager needs to bind an OAuth flow to a browser.
97
+ * The framework `Session` satisfies it structurally, so controllers pass
98
+ * `this.auth.session()` straight through.
114
99
  */
115
100
  export interface OAuthBindingSession {
116
101
  get<T = unknown>(key: string): T | undefined;
@@ -125,24 +110,19 @@ export interface OAuthAuthorizeOptions {
125
110
  state?: string;
126
111
  extraParams?: Record<string, string>;
127
112
  /**
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.
113
+ * Session of the browser starting the flow — pass `this.auth.session()`. The
114
+ * manager mints a per-browser binding, keeps it here, and hashes it into the
115
+ * state; writing to the session is also what makes a brand-new session persist
116
+ * across the provider round trip. `undefined` leaves the state unbound — the
117
+ * flow works, and `authorize()` warns once about the exposure.
136
118
  */
137
119
  session?: OAuthBindingSession;
138
120
  /**
139
121
  * 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.
122
+ * Prefer `session`, which stores and consumes for you; use this when the
123
+ * binding lives elsewhere (an encrypted cookie, a test). Only its hash
124
+ * reaches the state store, and `handleCallback()` requires the same value.
125
+ * Takes precedence over `session` when both are given.
146
126
  */
147
127
  bindTo?: string;
148
128
  }
@@ -193,10 +173,9 @@ export declare class OAuthManager {
193
173
  }>;
194
174
  user(providerName: string, payload: OAuthCallbackPayload): Promise<OAuthUserProfile>;
195
175
  /**
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.
176
+ * Verify the callback and return the user profile together with the sanitized
177
+ * `redirectTo` stored at authorize time — app-relative paths and allowlisted
178
+ * hosts only, so it is safe to pass to a redirect response.
200
179
  */
201
180
  handleCallback(providerName: string, payload: OAuthCallbackPayload): Promise<{
202
181
  profile: OAuthUserProfile;
@@ -210,11 +189,10 @@ export declare function createOAuthState(provider: string, store: OAuthStateStor
210
189
  }>;
211
190
  export declare function verifyOAuthState(state: string, provider: string, store: OAuthStateStore, config?: OAuthStateConfig, bindTo?: string): Promise<OAuthStatePayload | null>;
212
191
  /**
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`.
192
+ * Reduce a `redirectTo` value to a safe target: app-relative paths always pass;
193
+ * absolute http(s) URLs pass only when their host is in the allowlist (with
194
+ * `*.example.com` wildcards). Everything else — protocol-relative URLs,
195
+ * backslash tricks, `javascript:` and other schemes — returns `undefined`.
218
196
  */
219
197
  export declare function sanitizeOAuthRedirect(redirectTo: string | undefined, allowedHosts?: string[]): string | undefined;
220
198
  export declare function buildOAuthAuthorizeUrl(provider: OAuthProviderConfig, state: string, options?: {
@@ -1,19 +1,10 @@
1
1
  import type { PasswordHasher } from './PasswordHasher.js';
2
2
  /**
3
- * Runtime-detecting password hasher: hashes with `Bun.password` when running
4
- * on Bun (Argon2id by default, despite `ScryptHasher`'s name) and with Node's
5
- * `crypto.scrypt` otherwise (e.g. AWS Lambda or Cloudflare Workers). This is
6
- * the hasher behind the `Hash` export, and the default for
7
- * `AuthenticatableModel` and `ModelUserProvider`.
8
- *
9
- * **Verification routes on the stored hash, not on the runtime.** The two
10
- * delegates write different formats, and neither can read the other's, so
11
- * picking a delegate by runtime alone would 500 on every login for an app
12
- * whose password column was written elsewhere - a seeder run on Bun against a
13
- * database a Node deploy then serves. Bun implements `node:crypto`, so a
14
- * `$scrypt$` hash verifies on either runtime; an Argon2id or bcrypt hash needs
15
- * `Bun.password` and cannot be read off Bun at all, which this reports as
16
- * itself rather than as an opaque parse failure.
3
+ * Runtime-detecting password hasher behind `Hash`, the default for
4
+ * `AuthenticatableModel` and `ModelUserProvider`: `Bun.password` on Bun (Argon2id,
5
+ * despite `ScryptHasher`'s name), `crypto.scrypt` otherwise. **Verification routes
6
+ * on the stored hash, not the runtime**, or a column written elsewhere would 500 on
7
+ * every login; `$scrypt$` verifies anywhere, Argon2id/bcrypt needs `Bun.password`.
17
8
  */
18
9
  export declare class DefaultHasher implements PasswordHasher {
19
10
  private readonly bun;
@@ -1,19 +1,11 @@
1
1
  export interface PasswordHasher {
2
2
  hash(plain: string): Promise<string>;
3
3
  /**
4
- * Checks a plaintext password against a stored hash.
5
- *
6
- * **The stored hash comes first.** This order is the inverse of both
7
- * `Bun.password.verify(plain, hashed)` (which `ScryptHasher` delegates to)
8
- * and `verifyPassword(plain, hashed)` (exported from this package's
9
- * `encryption/Hash`), so the two conventions coexist in one codebase.
10
- *
11
- * Both parameters are `string`, so a swapped call type-checks. The built-in
12
- * hashers detect the obvious case at runtime and throw a `TypeError` naming
13
- * the order; a custom implementation gets no such help.
14
- *
15
- * @param hashed - The stored password hash, e.g. from a `passwordHash` column.
16
- * @param plain - The plaintext password supplied by the request.
4
+ * Checks a plaintext password against a stored hash. **The stored hash comes
5
+ * first** — the inverse of `Bun.password.verify(plain, hashed)` and of
6
+ * `verifyPassword(plain, hashed)`, so both conventions live in one codebase.
7
+ * Both parameters are `string`, so a swapped call type-checks; the built-in
8
+ * hashers throw a `TypeError` naming the order, a custom one gets no such help.
17
9
  */
18
10
  verify(hashed: string, plain: string): Promise<boolean>;
19
11
  needsRehash?(hashed: string): boolean;
@@ -2,18 +2,10 @@
2
2
  export declare const NODE_SCRYPT_PREFIX = "$scrypt$";
3
3
  export declare function looksLikePasswordHash(value: string): boolean;
4
4
  /**
5
- * Throws when `verify()` was called as `verify(plain, hashed)`.
6
- *
7
- * Two-sided on purpose: it fires only when the second argument looks like a
8
- * hash *and* the first does not. A one-sided "the first argument must look
9
- * like a hash" precondition would misdiagnose a legitimate non-hash
10
- * credential column - `passwordHash: 'oauth:...'`, the sentinel this repo
11
- * documents for OAuth-only accounts - as a caller mistake. Those keep falling
12
- * through to the implementation, which rejects them as before.
13
- *
14
- * Neither argument is included in the message: one of them is a plaintext
15
- * password, and this throw is reached on a live login attempt.
16
- *
17
- * See `PasswordHasher.verify` for why the order is easy to get wrong.
5
+ * Throws when `verify()` was called as `verify(plain, hashed)`. Two-sided on
6
+ * purpose: fires only when the second argument looks like a hash *and* the
7
+ * first does not, so a legitimate non-hash credential column
8
+ * (`passwordHash: 'oauth:...'`) is not misdiagnosed as a caller mistake.
9
+ * Neither argument is in the message: one is a plaintext password on a live login.
18
10
  */
19
11
  export declare function assertVerifyArgumentOrder(hashed: string, plain: string): void;
@@ -1,7 +1,8 @@
1
1
  import type { Authenticatable, UserProvider } from './types.js';
2
2
  import { buildTokenUrl, parseTokenUrl } from './utils.js';
3
3
  /**
4
- * Configuration for password reset tokens.
4
+ * Configuration for password reset tokens. Applies at issuance only: the expiry
5
+ * is signed into the token, so the verify functions take no config.
5
6
  */
6
7
  export interface PasswordResetConfig {
7
8
  /** Token expiration time in milliseconds (default: 1 hour) */
@@ -10,12 +11,14 @@ export interface PasswordResetConfig {
10
11
  tokenLength?: number;
11
12
  }
12
13
  /**
13
- * Storage interface for password reset tokens.
14
+ * Storage interface for password reset tokens. The store answers whether a
15
+ * token ID still exists, which is what gives single use and revocation; expiry
16
+ * is decided from the claim signed into the token.
14
17
  */
15
18
  export interface PasswordResetTokenStore {
16
19
  /** Store a token ID with associated email and expiration */
17
20
  store(tokenId: string, email: string, expiresAt: Date): Promise<void>;
18
- /** Find email by token ID, returns null if not found or expired */
21
+ /** Find email by token ID, returns null if not found or already dropped */
19
22
  find(tokenId: string): Promise<{
20
23
  email: string;
21
24
  expiresAt: Date;
@@ -25,9 +28,7 @@ export interface PasswordResetTokenStore {
25
28
  /** Delete all tokens for an email */
26
29
  deleteForEmail(email: string): Promise<void>;
27
30
  }
28
- /**
29
- * In-memory token store for testing and development.
30
- */
31
+ /** In-memory token store for testing and development. */
31
32
  export declare class MemoryPasswordResetStore implements PasswordResetTokenStore {
32
33
  private tokens;
33
34
  store(tokenId: string, email: string, expiresAt: Date): Promise<void>;
@@ -40,9 +41,7 @@ export declare class MemoryPasswordResetStore implements PasswordResetTokenStore
40
41
  /** Clear all tokens (useful for testing) */
41
42
  clear(): void;
42
43
  }
43
- /**
44
- * Result of creating a password reset token.
45
- */
44
+ /** Result of creating a password reset token. */
46
45
  export interface PasswordResetTokenResult {
47
46
  /** The plain-text token to send to the user (via email) */
48
47
  token: string;
@@ -51,41 +50,16 @@ export interface PasswordResetTokenResult {
51
50
  /** When the token expires */
52
51
  expiresAt: Date;
53
52
  }
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
- */
53
+ /** Create a password reset token for a user. */
62
54
  export declare function createPasswordResetToken(email: string, store: PasswordResetTokenStore, config?: PasswordResetConfig): Promise<PasswordResetTokenResult>;
55
+ /** Verify a password reset token, returning the email it was issued for. */
56
+ export declare function verifyPasswordResetToken(token: string, store: PasswordResetTokenStore): Promise<string | null>;
63
57
  /**
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.
58
+ * Complete a password reset: update the user's password and invalidate the
59
+ * token. Returns the user, or `null` when the token is invalid.
86
60
  */
61
+ export declare function completePasswordReset<T extends Authenticatable>(token: string, newPassword: string, store: PasswordResetTokenStore, provider: UserProvider<T>, updatePassword: (user: T, password: string) => Promise<void>): Promise<T | null>;
62
+ /** Build a password reset URL from a base URL and token. */
87
63
  export declare const buildPasswordResetUrl: typeof buildTokenUrl;
88
- /**
89
- * Parse a password reset URL to extract the token and optional email.
90
- */
64
+ /** Parse a password reset URL to extract the token and optional email. */
91
65
  export declare const parsePasswordResetUrl: typeof parseTokenUrl;
@@ -25,10 +25,9 @@ export declare class ModelUserProvider<User extends Authenticatable = Authentica
25
25
  validateCredentials(user: User, credentials: AuthCredentials): Promise<boolean>;
26
26
  getId(user: User): unknown;
27
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.
28
+ * Strip the password hash, remember token, and the model's `hidden` fields
29
+ * before the record leaves the auth layer. Credential validation runs on the
30
+ * raw record first, so this never affects login — only `auth.user()`.
32
31
  */
33
32
  sanitize(user: User): User;
34
33
  setRememberToken(user: User, token: string | null): Promise<void>;
@@ -1,9 +1,9 @@
1
1
  import type { AuthCredentials, Authenticatable, UserProvider } from '../types.js';
2
2
  /**
3
- * Run a user record through the provider's optional `sanitize` before it
4
- * leaves the auth layer. Every guard must call this on anything it returns
5
- * from `user()` — a guard that forgets the optional-chaining ternary leaks
6
- * password hashes, so the ternary lives here, once.
3
+ * Run a user record through the provider's optional `sanitize` before it leaves
4
+ * the auth layer. Every guard must call this on anything it returns from
5
+ * `user()` — a guard that forgets the ternary leaks password hashes, so the
6
+ * ternary lives here, once.
7
7
  */
8
8
  export declare function sanitizeUser<User>(provider: UserProvider<User>, user: User): User;
9
9
  export declare abstract class BaseUserProvider<User extends Authenticatable = Authenticatable> implements UserProvider<User> {
@@ -0,0 +1,18 @@
1
+ import type { MessageSigner } from '../encryption/MessageSigner.js';
2
+ /** The claims a password-reset or email-verification token carries. */
3
+ export interface SignedTokenClaims {
4
+ /** The opaque id the backing store keys the token by. */
5
+ id: string;
6
+ /** The email the token was issued for, lower-cased at issuance. */
7
+ email: string;
8
+ }
9
+ /**
10
+ * Read the claims of a signed one-time token, deciding expiry from the `exp`
11
+ * claim signed into it rather than from the store's copy.
12
+ *
13
+ * The signature is checked before anything is deleted, so the housekeeping
14
+ * `store.delete` only ever runs for an id this app issued.
15
+ */
16
+ export declare function readSignedTokenClaims(signer: MessageSigner, token: string, purpose: string, store: {
17
+ delete(tokenId: string): Promise<void>;
18
+ }): Promise<SignedTokenClaims | null>;