@guren/server 2.14.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.
- package/dist/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
- package/dist/{Hash-CzrwKeDp.js → Hash-D2DFd8xX.js} +12 -57
- package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
- package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
- package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-nNcbCIQX.js} +11 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +31 -0
- package/dist/agent/approval.d.ts +184 -0
- package/dist/agent/audit-emitter.d.ts +36 -0
- package/dist/agent/audit.d.ts +67 -0
- package/dist/agent/derive.d.ts +32 -66
- package/dist/agent/dispatch.d.ts +53 -63
- package/dist/agent/events.d.ts +11 -19
- package/dist/agent/meta-tools.d.ts +34 -0
- package/dist/agent/public.d.ts +14 -0
- package/dist/agent/public.js +2 -0
- package/dist/agent/redact.d.ts +16 -38
- package/dist/agent/scopes.d.ts +23 -69
- package/dist/auth/AuthManager.d.ts +19 -40
- package/dist/auth/AuthenticatableModel.d.ts +2 -2
- package/dist/auth/SessionGuard.d.ts +0 -1
- package/dist/auth/TokenGuard.d.ts +6 -26
- package/dist/auth/api-token.d.ts +16 -148
- package/dist/auth/context.d.ts +5 -10
- package/dist/auth/email-verification.d.ts +29 -127
- package/dist/auth/index.js +1 -1
- package/dist/auth/oauth/index.d.ts +35 -57
- package/dist/auth/password/DefaultHasher.d.ts +9 -5
- package/dist/auth/password/PasswordHasher.d.ts +7 -0
- package/dist/auth/password/hash-format.d.ts +11 -0
- package/dist/auth/password-reset.d.ts +16 -42
- package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
- package/dist/auth/providers/UserProvider.d.ts +4 -4
- package/dist/auth/signed-token.d.ts +18 -0
- package/dist/auth/types.d.ts +9 -32
- package/dist/auth/utils.d.ts +6 -27
- package/dist/{auth-BSUc14CD.js → auth-CbdPH4Cd.js} +252 -496
- package/dist/authorization/Gate.d.ts +9 -145
- package/dist/authorization/Policy.d.ts +6 -53
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/middleware.d.ts +16 -62
- package/dist/authorization/types.d.ts +8 -64
- package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
- package/dist/broadcasting/BroadcastManager.d.ts +29 -149
- package/dist/broadcasting/channels/Channel.d.ts +1 -19
- package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
- package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
- package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
- package/dist/broadcasting/drivers/index.d.ts +1 -1
- package/dist/broadcasting/index.d.ts +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/types.d.ts +7 -88
- package/dist/{broadcasting-BxU-LIfF.js → broadcasting-B5RzB0A2.js} +87 -414
- package/dist/cache/CacheManager.d.ts +8 -62
- package/dist/cache/TaggedCache.d.ts +2 -35
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +2 -36
- package/dist/cache/stores/MemoryStore.d.ts +2 -26
- package/dist/cache/stores/RedisStore.d.ts +1 -29
- package/dist/cache/types.d.ts +21 -128
- package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
- package/dist/client-C4TEr_Dd.js +9 -0
- package/dist/console/Command.d.ts +17 -126
- package/dist/console/ConsoleKernel.d.ts +2 -74
- package/dist/console/Input.d.ts +5 -113
- package/dist/console/Output.d.ts +3 -99
- package/dist/console/types.d.ts +3 -33
- package/dist/container/Container.d.ts +12 -103
- package/dist/container/ServiceProvider.d.ts +17 -61
- package/dist/container/bindings.d.ts +10 -12
- package/dist/container/defineModule.d.ts +16 -54
- package/dist/container/definePlugin.d.ts +12 -45
- package/dist/container/types.d.ts +2 -34
- package/dist/context-CXk_umpT.js +21 -0
- package/dist/database/Factory.d.ts +4 -57
- package/dist/database/Seeder.d.ts +8 -46
- package/dist/database/SeederRunner.d.ts +3 -33
- package/dist/database/types.d.ts +3 -24
- package/dist/discovery/AutoDiscovery.d.ts +10 -82
- package/dist/dispatch-BAwzftws.js +238 -0
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
- package/dist/docs-viewer/endpoint.d.ts +5 -11
- package/dist/encryption/Encrypter.d.ts +5 -71
- package/dist/encryption/Hash.d.ts +7 -57
- package/dist/encryption/Random.d.ts +6 -99
- package/dist/encryption/index.js +3 -3
- package/dist/encryption/types.d.ts +10 -72
- package/dist/{encryption-DJtkkhiw.js → encryption-uwP3Di4D.js} +13 -79
- package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
- package/dist/endpoint-Dsw3Acvq.js +26 -0
- package/dist/errors/ExceptionHandler.d.ts +3 -90
- package/dist/errors/HttpException.d.ts +2 -79
- package/dist/errors/debug-page.d.ts +3 -17
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
- package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
- package/dist/errors/exceptions/ValidationException.d.ts +2 -43
- package/dist/errors/types.d.ts +1 -25
- package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
- package/dist/events/Event.d.ts +1 -28
- package/dist/events/EventManager.d.ts +5 -107
- package/dist/events/Listener.d.ts +7 -55
- package/dist/events/builtin.d.ts +0 -24
- package/dist/events/index.js +1 -1
- package/dist/events/types.d.ts +4 -22
- package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
- package/dist/facades/index.d.ts +2 -14
- package/dist/health/HealthCheck.d.ts +0 -24
- package/dist/health/HealthManager.d.ts +0 -36
- package/dist/health/checks/CacheCheck.d.ts +2 -17
- package/dist/health/checks/CustomCheck.d.ts +0 -9
- package/dist/health/checks/DatabaseCheck.d.ts +2 -17
- package/dist/health/checks/MemoryCheck.d.ts +3 -12
- package/dist/health/checks/RedisCheck.d.ts +1 -13
- package/dist/health/checks/StorageCheck.d.ts +2 -17
- package/dist/health/index.js +1 -1
- package/dist/health/types.d.ts +4 -24
- package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
- package/dist/hot-disposables-B5BXqaIH.js +167 -0
- package/dist/hot-reload/hot-disposables.d.ts +22 -74
- package/dist/hot-reload/testing.d.ts +4 -9
- package/dist/http/Application.d.ts +62 -208
- package/dist/http/FormRequest.d.ts +4 -55
- package/dist/http/dev-assets.d.ts +16 -18
- package/dist/http/dev-banner.d.ts +2 -5
- package/dist/http/inertia-assets.d.ts +3 -6
- package/dist/http/middleware/capabilities.d.ts +27 -50
- package/dist/http/middleware/cors.d.ts +4 -29
- package/dist/http/middleware/csp.d.ts +2 -25
- package/dist/http/middleware/csrf.d.ts +20 -95
- package/dist/http/middleware/detect-locale.d.ts +7 -27
- package/dist/http/middleware/force-https.d.ts +6 -24
- package/dist/http/middleware/host-authorization.d.ts +2 -12
- package/dist/http/middleware/loopback-guard.d.ts +15 -33
- package/dist/http/middleware/rate-limit.d.ts +29 -126
- package/dist/http/middleware/redirect-safety.d.ts +2 -20
- package/dist/http/middleware/request-id.d.ts +1 -14
- package/dist/http/middleware/request-logging.d.ts +2 -13
- package/dist/http/middleware/response-headers.d.ts +5 -13
- package/dist/http/middleware/security-headers.d.ts +2 -16
- package/dist/http/middleware/session.d.ts +15 -34
- package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
- package/dist/http/middleware/validation.d.ts +8 -63
- package/dist/http/public-assets.d.ts +14 -0
- package/dist/http/request.d.ts +49 -48
- package/dist/http/resources/CursorPaginator.d.ts +5 -64
- package/dist/http/resources/Paginator.d.ts +7 -84
- package/dist/http/resources/Resource.d.ts +9 -65
- package/dist/http/resources/ResourceCollection.d.ts +5 -39
- package/dist/http/resources/types.d.ts +10 -30
- package/dist/http/static-documents.d.ts +21 -0
- package/dist/http/validation/Validator.d.ts +25 -85
- package/dist/http/validation/rules.d.ts +48 -147
- package/dist/http/validation/types.d.ts +16 -61
- package/dist/http/vite-assets.d.ts +5 -28
- package/dist/http/vite-dev-server.d.ts +6 -9
- package/dist/http/vite-manifest.d.ts +19 -33
- package/dist/i18n/I18nManager.d.ts +12 -78
- package/dist/i18n/Translator.d.ts +3 -54
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
- package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
- package/dist/i18n/pluralization.d.ts +4 -13
- package/dist/i18n/types.d.ts +17 -69
- package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
- package/dist/index.d.ts +13 -4
- package/dist/index.js +1036 -3080
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/request.d.ts +10 -17
- package/dist/internal/request.js +2 -2
- package/dist/internal/route-path.d.ts +9 -21
- package/dist/internal/route-path.js +9 -21
- package/dist/internal/zod-compat.d.ts +55 -122
- package/dist/internal/zod-compat.js +39 -70
- package/dist/internal/zod-json-schema.d.ts +18 -54
- package/dist/internal/zod-json-schema.js +46 -123
- package/dist/jsx-runtime.d.ts +3 -8
- package/dist/lambda/index.d.ts +17 -79
- package/dist/lambda/index.js +11 -59
- package/dist/logging/LogManager.d.ts +1 -51
- package/dist/logging/Logger.d.ts +8 -47
- package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
- package/dist/logging/channels/DailyFileChannel.d.ts +1 -5
- package/dist/logging/channels/FileChannel.d.ts +1 -3
- package/dist/logging/daily-file-path.d.ts +15 -0
- package/dist/logging/index.d.ts +1 -0
- package/dist/logging/index.js +2 -2
- package/dist/logging/types.d.ts +13 -45
- package/dist/{logging-CPaRMuPP.js → logging-zOY1XCtq.js} +83 -129
- package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
- package/dist/mail/Mail.d.ts +10 -106
- package/dist/mail/MailManager.d.ts +2 -60
- package/dist/mail/index.js +1 -1
- package/dist/mail/transports/LogTransport.d.ts +1 -4
- package/dist/mail/transports/MemoryTransport.d.ts +1 -63
- package/dist/mail/transports/ResendTransport.d.ts +1 -23
- package/dist/mail/transports/SmtpTransport.d.ts +1 -31
- package/dist/mail/types.d.ts +28 -150
- package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
- package/dist/mcp/McpServiceProvider.d.ts +4 -10
- package/dist/mcp/create-mcp-server.d.ts +25 -57
- package/dist/mcp/endpoint.d.ts +12 -36
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +46 -253
- package/dist/mvc/Router.d.ts +50 -129
- package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
- package/dist/mvc/inertia/shared.d.ts +6 -19
- package/dist/mvc/mount-route.d.ts +2 -6
- package/dist/mvc/view.d.ts +1 -2
- package/dist/notifications/Notification.d.ts +8 -75
- package/dist/notifications/NotificationManager.d.ts +15 -88
- package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
- package/dist/notifications/channels/MailChannel.d.ts +2 -31
- package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
- package/dist/notifications/channels/SlackChannel.d.ts +3 -48
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/notifiable-type.d.ts +3 -6
- package/dist/notifications/registry.d.ts +8 -27
- package/dist/notifications/types.d.ts +16 -53
- package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
- package/dist/providers/AuthServiceProvider.d.ts +1 -3
- package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
- package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
- package/dist/providers/CacheServiceProvider.d.ts +1 -3
- package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
- package/dist/providers/ErrorServiceProvider.d.ts +1 -4
- package/dist/providers/EventServiceProvider.d.ts +1 -3
- package/dist/providers/HealthServiceProvider.d.ts +1 -3
- package/dist/providers/I18nServiceProvider.d.ts +6 -10
- package/dist/providers/InertiaServiceProvider.d.ts +1 -4
- package/dist/providers/LogServiceProvider.d.ts +1 -3
- package/dist/providers/MailServiceProvider.d.ts +1 -3
- package/dist/providers/NotificationServiceProvider.d.ts +1 -3
- package/dist/providers/OAuthServiceProvider.d.ts +1 -3
- package/dist/providers/QueueServiceProvider.d.ts +1 -3
- package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
- package/dist/providers/StorageServiceProvider.d.ts +1 -3
- package/dist/queue/FailedJobReporter.d.ts +1 -24
- package/dist/queue/Job.d.ts +12 -99
- package/dist/queue/QueueManager.d.ts +6 -57
- package/dist/queue/Worker.d.ts +4 -65
- package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
- package/dist/queue/drivers/RedisDriver.d.ts +7 -65
- package/dist/queue/drivers/SqsDriver.d.ts +6 -57
- package/dist/queue/drivers/SyncDriver.d.ts +10 -13
- package/dist/queue/index.js +2 -2
- package/dist/queue/types.d.ts +10 -92
- package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
- package/dist/redis/RedisApiTokenStore.d.ts +4 -56
- package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
- package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
- package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
- package/dist/redis/RedisRateLimitStore.d.ts +16 -49
- package/dist/redis/RedisSessionStore.d.ts +3 -44
- package/dist/redis/client.d.ts +2 -32
- package/dist/redis/index.js +47 -232
- package/dist/redis/redis-values.d.ts +6 -12
- package/dist/redis/scan-keys.d.ts +1 -4
- package/dist/request-CLOYytGP.js +68 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +108 -74
- package/dist/scheduling/CronParser.d.ts +0 -29
- package/dist/scheduling/Schedule.d.ts +1 -153
- package/dist/scheduling/ScheduledTask.d.ts +0 -31
- package/dist/scheduling/Scheduler.d.ts +0 -70
- package/dist/scheduling/index.js +1 -1
- package/dist/scheduling/types.d.ts +4 -65
- package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
- package/dist/storage/StorageManager.d.ts +0 -48
- package/dist/storage/drivers/LocalDriver.d.ts +1 -25
- package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
- package/dist/storage/drivers/S3Driver.d.ts +6 -36
- package/dist/storage/drivers/s3-acl.d.ts +5 -10
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +27 -265
- package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
- package/dist/support/contained-path.d.ts +10 -20
- package/dist/support/error-polyfill.d.ts +4 -6
- package/dist/support/expiry.d.ts +17 -33
- package/dist/support/expiry.js +17 -33
- package/dist/support/import-map.d.ts +3 -7
- package/dist/support/inertia-defaults.d.ts +5 -10
- package/dist/support/redirect-target.d.ts +4 -6
- package/dist/support/stack-frames.d.ts +11 -50
- package/dist/support/trim-slashes.d.ts +4 -7
- package/dist/support/warn-once.d.ts +2 -6
- package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
- package/dist/{vite-manifest-BGfWbPYp.js → vite-manifest-CTQp-SOo.js} +34 -58
- package/package.json +6 -2
- package/dist/client-Dd7vLcqp.js +0 -27
- package/dist/context-DoD0c7J_.js +0 -26
- package/dist/endpoint-D-20PiHY.js +0 -46
- package/dist/hot-disposables-WsTX2ySN.js +0 -281
- package/dist/request-CRVuIiQr.js +0 -78
package/dist/auth/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { $ as
|
|
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
|
|
15
|
-
*
|
|
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 —
|
|
22
|
-
*
|
|
23
|
-
* `
|
|
24
|
-
*
|
|
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
|
-
* `
|
|
58
|
-
*
|
|
59
|
-
*
|
|
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
|
|
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
|
|
88
|
-
*
|
|
89
|
-
*
|
|
90
|
-
*
|
|
91
|
-
*
|
|
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
|
-
*
|
|
112
|
-
*
|
|
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
|
-
*
|
|
131
|
-
*
|
|
132
|
-
*
|
|
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
|
-
*
|
|
142
|
-
*
|
|
143
|
-
*
|
|
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
|
-
*
|
|
198
|
-
* pass to a redirect response
|
|
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
|
-
*
|
|
215
|
-
*
|
|
216
|
-
*
|
|
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,13 +1,17 @@
|
|
|
1
1
|
import type { PasswordHasher } from './PasswordHasher.js';
|
|
2
2
|
/**
|
|
3
|
-
* Runtime-detecting password hasher
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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`.
|
|
7
8
|
*/
|
|
8
9
|
export declare class DefaultHasher implements PasswordHasher {
|
|
9
|
-
private readonly
|
|
10
|
+
private readonly bun;
|
|
11
|
+
private readonly node;
|
|
10
12
|
constructor();
|
|
11
13
|
hash(plain: string): Promise<string>;
|
|
12
14
|
verify(hashed: string, plain: string): Promise<boolean>;
|
|
15
|
+
needsRehash(hashed: string): boolean;
|
|
16
|
+
private delegateFor;
|
|
13
17
|
}
|
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
export interface PasswordHasher {
|
|
2
2
|
hash(plain: string): Promise<string>;
|
|
3
|
+
/**
|
|
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.
|
|
9
|
+
*/
|
|
3
10
|
verify(hashed: string, plain: string): Promise<boolean>;
|
|
4
11
|
needsRehash?(hashed: string): boolean;
|
|
5
12
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** The prefix every hash `NodeHasher` (and `hashPassword()`) writes. */
|
|
2
|
+
export declare const NODE_SCRYPT_PREFIX = "$scrypt$";
|
|
3
|
+
export declare function looksLikePasswordHash(value: string): boolean;
|
|
4
|
+
/**
|
|
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.
|
|
10
|
+
*/
|
|
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
|
|
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
|
-
*
|
|
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
|
-
*
|
|
30
|
-
*
|
|
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
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
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>;
|
package/dist/auth/types.d.ts
CHANGED
|
@@ -27,40 +27,18 @@ export interface UserProvider<User = Authenticatable> {
|
|
|
27
27
|
getRememberToken?(user: User): Promise<string | null> | string | null;
|
|
28
28
|
/**
|
|
29
29
|
* Strip fields that must never leave the auth layer (password hashes,
|
|
30
|
-
* remember tokens, model `hidden` fields)
|
|
31
|
-
* is cached or handed to application code via guard.user().
|
|
30
|
+
* remember tokens, model `hidden` fields) before caching or exposing a user.
|
|
32
31
|
*/
|
|
33
32
|
sanitize?(user: User): User;
|
|
34
33
|
}
|
|
35
|
-
/**
|
|
36
|
-
* The conventional names for the credential columns that
|
|
37
|
-
* `ModelUserProvider.sanitize()` strips: the password column (`password`
|
|
38
|
-
* by default, commonly configured as `passwordHash`/`password_hash`) and
|
|
39
|
-
* the remember-token column (`remember_token` by default, commonly
|
|
40
|
-
* `rememberToken`).
|
|
41
|
-
*/
|
|
34
|
+
/** The conventional credential column names `ModelUserProvider.sanitize()` strips. */
|
|
42
35
|
export type DefaultSanitizedKeys = 'password' | 'passwordHash' | 'password_hash' | 'rememberToken' | 'remember_token';
|
|
43
36
|
/**
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
* The runtime strips exactly the *configured* password/remember-token
|
|
50
|
-
* columns plus the model's `hidden` fields — a static type cannot see
|
|
51
|
-
* that configuration. If your columns use other names, or the model
|
|
52
|
-
* hides additional fields, list them in `Hidden` explicitly. Only
|
|
53
|
-
* meaningful for concrete record types (index-signature records like
|
|
54
|
-
* `Record<string, string>` cannot have individual keys removed).
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* ```ts
|
|
58
|
-
* const user = await this.auth.userOrFail<Sanitized<UserRecord>>()
|
|
59
|
-
* user.passwordHash // compile error — stripped at runtime
|
|
60
|
-
*
|
|
61
|
-
* // With additional hidden fields or custom column names:
|
|
62
|
-
* type SafeUser = Sanitized<UserRecord, 'twoFactorSecret' | 'credentialDigest'>
|
|
63
|
-
* ```
|
|
37
|
+
* A user record after auth-layer sanitization, assuming the provider's columns
|
|
38
|
+
* follow {@link DefaultSanitizedKeys}. The runtime strips the *configured*
|
|
39
|
+
* password/remember-token columns plus the model's `hidden` fields, which a
|
|
40
|
+
* static type cannot see — list any others in `Hidden`, e.g.
|
|
41
|
+
* `Sanitized<UserRecord, 'twoFactorSecret'>`. Index-signature records cannot have keys removed.
|
|
64
42
|
*/
|
|
65
43
|
export type Sanitized<User, Hidden extends string = never> = User extends unknown ? Omit<User, Extract<keyof User, DefaultSanitizedKeys | Hidden>> : never;
|
|
66
44
|
export interface GuardContext {
|
|
@@ -100,9 +78,8 @@ export interface AuthManagerContract {
|
|
|
100
78
|
getDefaultGuard(): string;
|
|
101
79
|
createAuthContext(ctx: Context, options?: AttachContextOptions): AuthContext;
|
|
102
80
|
/**
|
|
103
|
-
* The guard name an unqualified guard() call resolves to
|
|
104
|
-
*
|
|
105
|
-
* as if it always returned the default guard.
|
|
81
|
+
* The guard name an unqualified guard() call resolves to. Implementations
|
|
82
|
+
* without it behave as if it always returned the default guard.
|
|
106
83
|
*/
|
|
107
84
|
resolveGuardName?(ctx: Context, name?: string): string;
|
|
108
85
|
}
|
package/dist/auth/utils.d.ts
CHANGED
|
@@ -1,38 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Hash a token using SHA-256 or SHA-512.
|
|
3
|
-
*/
|
|
4
1
|
export declare function hashToken(token: string, algorithm?: 'sha256' | 'sha512'): string;
|
|
5
|
-
/**
|
|
6
|
-
* Generate a secure random token.
|
|
7
|
-
*/
|
|
8
2
|
export declare function generateToken(length?: number): string;
|
|
9
|
-
/**
|
|
10
|
-
* Generate a random ID (16 bytes = 32 hex chars).
|
|
11
|
-
*/
|
|
3
|
+
/** Generate a random ID (16 bytes = 32 hex chars). */
|
|
12
4
|
export declare function generateId(): string;
|
|
13
5
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* 'yyyy' both decode to nothing — and 'abcz' and 'abdz' both decode to the
|
|
19
|
-
* one byte they share — and would compare equal. A short decode is how the
|
|
20
|
-
* decoder reports that, which beats restating its grammar in a regex here.
|
|
21
|
-
* Use `secureStringCompare` for values that are not hex.
|
|
6
|
+
* Timing-safe comparison of two hex strings. Non-hex or odd-length input is
|
|
7
|
+
* rejected rather than compared: `Buffer.from(x, 'hex')` stops at the first
|
|
8
|
+
* invalid pair, so 'zzzz' and 'yyyy' would both decode to nothing and compare
|
|
9
|
+
* equal. Use `secureStringCompare` for values that are not hex.
|
|
22
10
|
*/
|
|
23
11
|
export declare function secureCompare(a: string, b: string): boolean;
|
|
24
|
-
/**
|
|
25
|
-
* Securely compare two arbitrary strings using timing-safe comparison.
|
|
26
|
-
* Unlike secureCompare, this works with any string encoding (UUIDs, tokens, etc.).
|
|
27
|
-
*/
|
|
12
|
+
/** Timing-safe comparison for arbitrary strings — unlike secureCompare, not hex-only. */
|
|
28
13
|
export declare function secureStringCompare(a: string, b: string): boolean;
|
|
29
|
-
/**
|
|
30
|
-
* Build a URL with token and optional email parameters.
|
|
31
|
-
*/
|
|
32
14
|
export declare function buildTokenUrl(baseUrl: string, token: string, email?: string): string;
|
|
33
|
-
/**
|
|
34
|
-
* Parse a URL to extract token and email parameters.
|
|
35
|
-
*/
|
|
36
15
|
export declare function parseTokenUrl(url: string): {
|
|
37
16
|
token: string | null;
|
|
38
17
|
email: string | null;
|