@guren/server 2.1.1 → 2.2.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/{McpServiceProvider-7BB5FPF3.js → McpServiceProvider-GRDYNEQG.js} +1 -1
- package/dist/auth/AuthManager.d.ts +30 -0
- package/dist/auth/AuthenticatableModel.d.ts +25 -0
- package/dist/auth/RequestAuthContext.d.ts +24 -0
- package/dist/auth/SessionGuard.d.ts +31 -0
- package/dist/auth/api-token.d.ts +299 -0
- package/dist/auth/email-verification.d.ts +203 -0
- package/dist/auth/index.d.ts +18 -110
- package/dist/auth/index.js +3 -1
- package/dist/auth/oauth/index.d.ts +239 -0
- package/dist/auth/password/DefaultHasher.d.ts +13 -0
- package/dist/auth/password/NodeHasher.d.ts +22 -0
- package/dist/auth/password/PasswordHasher.d.ts +5 -0
- package/dist/auth/password/ScryptHasher.d.ts +26 -0
- package/dist/auth/password-reset.d.ts +91 -0
- package/dist/auth/providers/ModelUserProvider.d.ts +36 -0
- package/dist/auth/providers/UserProvider.d.ts +9 -0
- package/dist/auth/types.d.ts +102 -0
- package/dist/auth/utils.d.ts +39 -0
- package/dist/{Gate-CynjZCtS.d.ts → authorization/Gate.d.ts} +30 -111
- package/dist/authorization/Policy.d.ts +77 -0
- package/dist/authorization/index.d.ts +5 -129
- package/dist/authorization/index.js +3 -1
- package/dist/authorization/middleware.d.ts +49 -0
- package/dist/authorization/types.d.ts +108 -0
- package/dist/broadcasting/BroadcastManager.d.ts +205 -0
- package/dist/broadcasting/channels/Channel.d.ts +28 -0
- package/dist/broadcasting/channels/PresenceChannel.d.ts +72 -0
- package/dist/broadcasting/channels/PrivateChannel.d.ts +32 -0
- package/dist/broadcasting/channels/index.d.ts +3 -0
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +93 -0
- package/dist/broadcasting/drivers/RedisDriver.d.ts +112 -0
- package/dist/broadcasting/drivers/index.d.ts +2 -0
- package/dist/broadcasting/index.d.ts +6 -233
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/typed.d.ts +23 -0
- package/dist/broadcasting/types.d.ts +155 -0
- package/dist/cache/CacheManager.d.ts +87 -0
- package/dist/cache/TaggedCache.d.ts +62 -0
- package/dist/cache/index.d.ts +6 -233
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +64 -0
- package/dist/cache/stores/MemoryStore.d.ts +52 -0
- package/dist/cache/stores/RedisStore.d.ts +53 -0
- package/dist/{CacheManager-BmDzUKrF.d.ts → cache/types.d.ts} +26 -99
- package/dist/{chunk-TVY72CLV.js → chunk-4VE3LYOM.js} +3 -2
- package/dist/{chunk-FZD2AKJI.js → chunk-7OB2YXRE.js} +56 -28
- package/dist/{chunk-J6ETA476.js → chunk-BUQXOZCT.js} +93 -5
- package/dist/{chunk-DSDX3ASM.js → chunk-CDZUNKI6.js} +65 -83
- package/dist/{chunk-CWI4AJ47.js → chunk-HPET6XY5.js} +13 -9
- package/dist/{chunk-A3ISJVEV.js → chunk-HR2KZ3WL.js} +23 -5
- package/dist/{chunk-5SZTEZ22.js → chunk-PZKUDFMW.js} +11 -8
- package/dist/console/Command.d.ts +179 -0
- package/dist/{ConsoleKernel-CJg975mp.d.ts → console/ConsoleKernel.d.ts} +4 -6
- package/dist/console/Input.d.ts +140 -0
- package/dist/console/Output.d.ts +161 -0
- package/dist/console/index.d.ts +5 -0
- package/dist/console/types.d.ts +106 -0
- package/dist/container/Container.d.ts +148 -0
- package/dist/container/ServiceProvider.d.ts +103 -0
- package/dist/container/bindings.d.ts +55 -0
- package/dist/container/defineModule.d.ts +88 -0
- package/dist/container/definePlugin.d.ts +62 -0
- package/dist/container/index.d.ts +8 -0
- package/dist/container/types.d.ts +73 -0
- package/dist/database/Factory.d.ts +82 -0
- package/dist/database/Seeder.d.ts +35 -0
- package/dist/database/SeederRunner.d.ts +41 -0
- package/dist/database/index.d.ts +4 -0
- package/dist/database/types.d.ts +49 -0
- package/dist/discovery/AutoDiscovery.d.ts +113 -0
- package/dist/discovery/index.d.ts +2 -0
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +12 -0
- package/dist/docs-viewer/endpoint.d.ts +19 -0
- package/dist/encryption/Encrypter.d.ts +96 -0
- package/dist/encryption/Hash.d.ts +69 -0
- package/dist/encryption/MessageSigner.d.ts +21 -0
- package/dist/encryption/Random.d.ts +119 -0
- package/dist/encryption/app-key.d.ts +12 -0
- package/dist/encryption/index.d.ts +10 -222
- package/dist/encryption/signed-url.d.ts +9 -0
- package/dist/encryption/types.d.ts +103 -0
- package/dist/errors/ExceptionHandler.d.ts +118 -0
- package/dist/errors/HttpException.d.ts +106 -0
- package/dist/errors/debug-page.d.ts +22 -0
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +32 -0
- package/dist/errors/exceptions/AuthorizationException.d.ts +32 -0
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +31 -0
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +36 -0
- package/dist/errors/exceptions/ValidationException.d.ts +60 -0
- package/dist/errors/exceptions/index.d.ts +5 -0
- package/dist/errors/index.d.ts +5 -0
- package/dist/errors/types.d.ts +43 -0
- package/dist/events/Event.d.ts +33 -0
- package/dist/{EventManager-CmIoLt7r.d.ts → events/EventManager.d.ts} +4 -86
- package/dist/events/Listener.d.ts +79 -0
- package/dist/events/builtin.d.ts +73 -0
- package/dist/events/index.d.ts +6 -155
- package/dist/events/types.d.ts +48 -0
- package/dist/facades/index.d.ts +31 -0
- package/dist/health/HealthCheck.d.ts +34 -0
- package/dist/health/HealthManager.d.ts +53 -0
- package/dist/health/checks/CacheCheck.d.ts +35 -0
- package/dist/health/checks/CustomCheck.d.ts +23 -0
- package/dist/health/checks/DatabaseCheck.d.ts +33 -0
- package/dist/health/checks/MemoryCheck.d.ts +32 -0
- package/dist/health/checks/RedisCheck.d.ts +27 -0
- package/dist/health/checks/StorageCheck.d.ts +35 -0
- package/dist/health/checks/index.d.ts +12 -0
- package/dist/health/index.d.ts +5 -185
- package/dist/health/types.d.ts +52 -0
- package/dist/hot-reload/hot-disposables.d.ts +96 -0
- package/dist/hot-reload/testing.d.ts +14 -0
- package/dist/http/Application.d.ts +187 -0
- package/dist/http/FormRequest.d.ts +73 -0
- package/dist/http/dev-assets.d.ts +51 -0
- package/dist/http/dev-banner.d.ts +7 -0
- package/dist/http/inertia-assets.d.ts +22 -0
- package/dist/http/middleware/auth.d.ts +13 -0
- package/dist/http/middleware/capabilities.d.ts +22 -0
- package/dist/http/middleware/cors.d.ts +40 -0
- package/dist/http/middleware/csp.d.ts +59 -0
- package/dist/http/middleware/csrf.d.ts +121 -0
- package/dist/http/middleware/detect-locale.d.ts +65 -0
- package/dist/http/middleware/force-https.d.ts +34 -0
- package/dist/http/middleware/host-authorization.d.ts +24 -0
- package/dist/http/middleware/index.d.ts +19 -0
- package/dist/http/middleware/loopback-guard.d.ts +38 -0
- package/dist/{rate-limit-D9J2b4S1.d.ts → http/middleware/rate-limit.d.ts} +22 -50
- package/dist/http/middleware/redirect-safety.d.ts +29 -0
- package/dist/http/middleware/request-id.d.ts +19 -0
- package/dist/http/middleware/request-logging.d.ts +16 -0
- package/dist/http/middleware/security-headers.d.ts +49 -0
- package/dist/http/middleware/session.d.ts +93 -0
- package/dist/http/middleware/validation.d.ts +94 -0
- package/dist/http/public-assets.d.ts +15 -0
- package/dist/http/request.d.ts +24 -0
- package/dist/http/resources/CursorPaginator.d.ts +106 -0
- package/dist/http/resources/Paginator.d.ts +130 -0
- package/dist/http/resources/Resource.d.ts +67 -0
- package/dist/http/resources/ResourceCollection.d.ts +60 -0
- package/dist/http/resources/index.d.ts +6 -0
- package/dist/http/resources/types.d.ts +91 -0
- package/dist/http/validation/Validator.d.ts +128 -0
- package/dist/http/validation/index.d.ts +3 -0
- package/dist/http/validation/rules.d.ts +196 -0
- package/dist/http/validation/types.d.ts +96 -0
- package/dist/http/vite-dev-server.d.ts +27 -0
- package/dist/i18n/I18nManager.d.ts +114 -0
- package/dist/i18n/Translator.d.ts +80 -0
- package/dist/i18n/index.d.ts +6 -101
- package/dist/i18n/index.js +5 -3
- package/dist/i18n/loaders/JsonLoader.d.ts +47 -0
- package/dist/i18n/loaders/MemoryLoader.d.ts +37 -0
- package/dist/i18n/pluralization.d.ts +19 -0
- package/dist/i18n/types.d.ts +106 -0
- package/dist/index.d.ts +69 -2605
- package/dist/index.js +332 -152
- package/dist/lambda/index.d.ts +17 -37
- package/dist/logging/LogManager.d.ts +83 -0
- package/dist/logging/Logger.d.ts +76 -0
- package/dist/logging/channels/ConsoleChannel.d.ts +11 -0
- package/dist/logging/channels/DailyFileChannel.d.ts +20 -0
- package/dist/logging/channels/FileChannel.d.ts +15 -0
- package/dist/logging/index.d.ts +8 -50
- package/dist/logging/types.d.ts +96 -0
- package/dist/mail/Mail.d.ts +138 -0
- package/dist/mail/MailManager.d.ts +79 -0
- package/dist/mail/address.d.ts +8 -0
- package/dist/mail/index.d.ts +7 -316
- package/dist/mail/transports/LogTransport.d.ts +19 -0
- package/dist/mail/transports/MemoryTransport.d.ts +84 -0
- package/dist/mail/transports/ResendTransport.d.ts +32 -0
- package/dist/mail/transports/SmtpTransport.d.ts +40 -0
- package/dist/{MailManager-DpMvYiP9.d.ts → mail/types.d.ts} +11 -92
- package/dist/mcp/McpServiceProvider.d.ts +17 -0
- package/dist/mcp/create-mcp-server.d.ts +144 -0
- package/dist/mcp/endpoint.d.ts +29 -0
- package/dist/mcp/index.d.ts +3 -185
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +326 -0
- package/dist/mvc/Router.d.ts +239 -0
- package/dist/mvc/ViewEngine.d.ts +11 -0
- package/dist/mvc/inertia/InertiaEngine.d.ts +114 -0
- package/dist/mvc/inertia/shared.d.ts +90 -0
- package/dist/mvc/mount-route.d.ts +10 -0
- package/dist/notifications/Notification.d.ts +99 -0
- package/dist/notifications/NotificationManager.d.ts +150 -0
- package/dist/notifications/channels/DatabaseChannel.d.ts +55 -0
- package/dist/notifications/channels/MailChannel.d.ts +45 -0
- package/dist/notifications/channels/MemoryChannel.d.ts +85 -0
- package/dist/notifications/channels/SlackChannel.d.ts +73 -0
- package/dist/notifications/channels/index.d.ts +4 -0
- package/dist/notifications/index.d.ts +6 -322
- package/dist/notifications/notifiable-type.d.ts +10 -0
- package/dist/notifications/registry.d.ts +39 -0
- package/dist/notifications/types.d.ts +162 -0
- package/dist/providers/AuthServiceProvider.d.ts +7 -0
- package/dist/providers/AuthorizationServiceProvider.d.ts +9 -0
- package/dist/providers/BroadcastServiceProvider.d.ts +7 -0
- package/dist/providers/CacheServiceProvider.d.ts +7 -0
- package/dist/providers/EncryptionServiceProvider.d.ts +7 -0
- package/dist/providers/ErrorServiceProvider.d.ts +9 -0
- package/dist/providers/EventServiceProvider.d.ts +7 -0
- package/dist/providers/HealthServiceProvider.d.ts +7 -0
- package/dist/providers/I18nServiceProvider.d.ts +27 -0
- package/dist/providers/InertiaServiceProvider.d.ts +20 -0
- package/dist/providers/LogServiceProvider.d.ts +7 -0
- package/dist/providers/MailServiceProvider.d.ts +7 -0
- package/dist/providers/NotificationServiceProvider.d.ts +8 -0
- package/dist/providers/OAuthServiceProvider.d.ts +7 -0
- package/dist/providers/QueueServiceProvider.d.ts +7 -0
- package/dist/providers/SchedulingServiceProvider.d.ts +7 -0
- package/dist/providers/StorageServiceProvider.d.ts +7 -0
- package/dist/providers/index.d.ts +17 -0
- package/dist/queue/FailedJobReporter.d.ts +40 -0
- package/dist/queue/Job.d.ts +140 -0
- package/dist/queue/QueueManager.d.ts +79 -0
- package/dist/queue/Worker.d.ts +99 -0
- package/dist/queue/drivers/MemoryDriver.d.ts +60 -0
- package/dist/queue/drivers/RedisDriver.d.ts +96 -0
- package/dist/queue/drivers/SqsDriver.d.ts +108 -0
- package/dist/queue/drivers/SyncDriver.d.ts +28 -0
- package/dist/queue/index.d.ts +9 -453
- package/dist/queue/types.d.ts +171 -0
- package/dist/redis/RedisApiTokenStore.d.ts +78 -0
- package/dist/redis/RedisEmailVerificationStore.d.ts +54 -0
- package/dist/redis/RedisOAuthStateStore.d.ts +26 -0
- package/dist/redis/RedisPasswordResetStore.d.ts +57 -0
- package/dist/redis/RedisRateLimitStore.d.ts +77 -0
- package/dist/redis/RedisSessionStore.d.ts +61 -0
- package/dist/redis/client.d.ts +41 -0
- package/dist/redis/index.d.ts +14 -356
- package/dist/redis/index.js +5 -2
- package/dist/redis/scan-keys.d.ts +6 -0
- package/dist/runtime/index.d.ts +8 -95
- package/dist/runtime/index.js +1 -1
- package/dist/scheduling/CronParser.d.ts +37 -0
- package/dist/scheduling/Schedule.d.ts +229 -0
- package/dist/scheduling/ScheduledTask.d.ts +47 -0
- package/dist/scheduling/Scheduler.d.ts +99 -0
- package/dist/scheduling/index.d.ts +5 -41
- package/dist/scheduling/types.d.ts +97 -0
- package/dist/storage/StorageManager.d.ts +65 -0
- package/dist/storage/drivers/LocalDriver.d.ts +55 -0
- package/dist/storage/drivers/MemoryDriver.d.ts +66 -0
- package/dist/storage/drivers/S3Driver.d.ts +72 -0
- package/dist/storage/index.d.ts +5 -197
- package/dist/{StorageManager-oZTHqaza.d.ts → storage/types.d.ts} +10 -77
- package/dist/support/error-polyfill.d.ts +9 -0
- package/dist/support/import-map.d.ts +13 -0
- package/dist/support/redirect-target.d.ts +11 -0
- package/dist/support/stack-frames.d.ts +56 -0
- package/dist/support/trim-slashes.d.ts +11 -0
- package/dist/vite/index.d.ts +2 -35
- package/dist/vite/index.js +0 -3
- package/dist/vite/plugin.d.ts +34 -0
- package/package.json +3 -3
- package/dist/AuthManager-DBP4KYsx.d.ts +0 -79
- package/dist/BroadcastManager-D8KoJxiV.d.ts +0 -492
- package/dist/HealthManager-DUyMIzsZ.d.ts +0 -141
- package/dist/I18nManager-BiSoczfV.d.ts +0 -275
- package/dist/LogManager-7mxnkaPM.d.ts +0 -256
- package/dist/Scheduler-pZiT8i57.d.ts +0 -471
- package/dist/api-token-D24VPr_E.d.ts +0 -663
- package/dist/app-key-CsBfRC_Q.d.ts +0 -214
- package/dist/email-verification-Dx426KLn.d.ts +0 -336
- package/dist/index-9_Jzj5jo.d.ts +0 -7
- package/dist/validation-yAL53e1S.d.ts +0 -2610
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { Model, PlainObject } from '@guren/orm';
|
|
3
|
+
import { type ModelUserProviderOptions } from './providers/ModelUserProvider.js';
|
|
4
|
+
import type { AttachContextOptions, AuthContext, AuthManagerContract, AuthManagerOptions, AuthCredentials, Guard, GuardContext, GuardFactory, ProviderFactory, UserProvider } from './types.js';
|
|
5
|
+
export declare class AuthManager implements AuthManagerContract {
|
|
6
|
+
private readonly guards;
|
|
7
|
+
private readonly providers;
|
|
8
|
+
private defaultGuard;
|
|
9
|
+
constructor(options?: AuthManagerOptions);
|
|
10
|
+
registerGuard<User>(name: string, factory: GuardFactory<User>): void;
|
|
11
|
+
registerProvider<User>(name: string, factory: ProviderFactory<User>): void;
|
|
12
|
+
getProvider<User>(name: string): UserProvider<User>;
|
|
13
|
+
createGuard<User>(name: string, context: GuardContext): Guard<User>;
|
|
14
|
+
guardNames(): string[];
|
|
15
|
+
setDefaultGuard(name: string): void;
|
|
16
|
+
getDefaultGuard(): string;
|
|
17
|
+
createAuthContext(ctx: Context, options?: AttachContextOptions): AuthContext;
|
|
18
|
+
attempt(name: string, ctx: Context, credentials: AuthCredentials, remember?: boolean): Promise<boolean>;
|
|
19
|
+
/**
|
|
20
|
+
* Shorthand method to register a model-based authentication provider and session guard.
|
|
21
|
+
* This simplifies the common case of authenticating users via a database model.
|
|
22
|
+
*
|
|
23
|
+
* @param model - The model class to use for user authentication
|
|
24
|
+
* @param options - Options for the ModelUserProvider (partial, with defaults)
|
|
25
|
+
* @param providerName - Name for the provider (defaults to 'users')
|
|
26
|
+
* @param guardName - Name for the guard (defaults to 'web')
|
|
27
|
+
*/
|
|
28
|
+
useModel(model: typeof Model<PlainObject>, options?: Partial<ModelUserProviderOptions>, providerName?: string, guardName?: string): void;
|
|
29
|
+
}
|
|
30
|
+
export type { AuthCredentials } from './types.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Model, type PlainObject } from '@guren/orm';
|
|
2
|
+
import type { PasswordHasher } from './password/PasswordHasher.js';
|
|
3
|
+
export declare abstract class AuthenticatableModel<TRecord extends PlainObject = PlainObject> extends Model<TRecord> {
|
|
4
|
+
static readonly createType: {
|
|
5
|
+
password?: string;
|
|
6
|
+
plainPassword?: string;
|
|
7
|
+
};
|
|
8
|
+
protected static passwordField: string;
|
|
9
|
+
protected static passwordHashField: string;
|
|
10
|
+
protected static rememberTokenField: string;
|
|
11
|
+
protected static passwordHasher: PasswordHasher | null;
|
|
12
|
+
protected static resolvePasswordField(): string;
|
|
13
|
+
static resolvePasswordHashField(): string;
|
|
14
|
+
static resolveRememberTokenField(): string;
|
|
15
|
+
/**
|
|
16
|
+
* Credential columns can never be mass-assigned: the resolved password-hash
|
|
17
|
+
* column (unless the model hashes in place into the password field itself)
|
|
18
|
+
* and the remember-token column. Resolved at call time so a renamed column
|
|
19
|
+
* stays covered. Use `forceCreate()`/`forceUpdate()` for trusted
|
|
20
|
+
* server-side values such as `passwordHash: 'oauth:...'`.
|
|
21
|
+
*/
|
|
22
|
+
protected static deniedFields(): string[];
|
|
23
|
+
protected static resolvePasswordHasher(): PasswordHasher;
|
|
24
|
+
protected static preparePersistencePayload(data: PlainObject): Promise<PlainObject>;
|
|
25
|
+
}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Context } from 'hono';
|
|
2
|
+
import type { Session } from '../http/middleware/index.js';
|
|
3
|
+
import type { AuthContext, AuthCredentials, Guard } from './types.js';
|
|
4
|
+
export type GuardResolver = (name?: string) => Guard<unknown>;
|
|
5
|
+
export declare class RequestAuthContext implements AuthContext {
|
|
6
|
+
private readonly manager;
|
|
7
|
+
private readonly ctx;
|
|
8
|
+
private readonly resolveSession;
|
|
9
|
+
private readonly resolveGuard;
|
|
10
|
+
private readonly guardCache;
|
|
11
|
+
constructor(manager: {
|
|
12
|
+
getDefaultGuard(): string;
|
|
13
|
+
}, ctx: Context, resolveSession: () => Session | undefined, resolveGuard: GuardResolver);
|
|
14
|
+
guard<T = unknown>(name?: string): Guard<T>;
|
|
15
|
+
session<T extends Session = Session>(): T | undefined;
|
|
16
|
+
check(): Promise<boolean>;
|
|
17
|
+
guest(): Promise<boolean>;
|
|
18
|
+
user<T = unknown>(): Promise<T | null>;
|
|
19
|
+
userOrFail<T = unknown>(): Promise<T>;
|
|
20
|
+
id(): Promise<unknown>;
|
|
21
|
+
login<T = unknown>(user: T, remember?: boolean): Promise<void>;
|
|
22
|
+
attempt(credentials: AuthCredentials, remember?: boolean): Promise<boolean>;
|
|
23
|
+
logout(): Promise<void>;
|
|
24
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { Session } from '../http/middleware/index.js';
|
|
2
|
+
import type { AuthCredentials, Authenticatable, Guard, UserProvider } from './types.js';
|
|
3
|
+
export interface SessionGuardOptions {
|
|
4
|
+
provider: UserProvider;
|
|
5
|
+
sessionKey?: string;
|
|
6
|
+
rememberSessionKey?: string;
|
|
7
|
+
session: Session | undefined;
|
|
8
|
+
}
|
|
9
|
+
export declare class SessionGuard<User extends Authenticatable = Authenticatable> implements Guard<User> {
|
|
10
|
+
private readonly options;
|
|
11
|
+
private cachedUser;
|
|
12
|
+
constructor(options: SessionGuardOptions);
|
|
13
|
+
private get currentSession();
|
|
14
|
+
private get provider();
|
|
15
|
+
private sessionKey;
|
|
16
|
+
private rememberSessionKey;
|
|
17
|
+
private loadRememberedUser;
|
|
18
|
+
/** Strip auth-internal fields before a record is cached or exposed. */
|
|
19
|
+
private sanitizeUser;
|
|
20
|
+
private resolveUser;
|
|
21
|
+
check(): Promise<boolean>;
|
|
22
|
+
guest(): Promise<boolean>;
|
|
23
|
+
user<T = User>(): Promise<T | null>;
|
|
24
|
+
id(): Promise<unknown>;
|
|
25
|
+
private remember;
|
|
26
|
+
login<T = User>(user: T, remember?: boolean): Promise<void>;
|
|
27
|
+
logout(): Promise<void>;
|
|
28
|
+
attempt(credentials: AuthCredentials, remember?: boolean): Promise<boolean>;
|
|
29
|
+
validate(credentials: AuthCredentials): Promise<User | null>;
|
|
30
|
+
session<T extends Session = Session>(): T | undefined;
|
|
31
|
+
}
|
|
@@ -0,0 +1,299 @@
|
|
|
1
|
+
import type { MiddlewareHandler, Context } from 'hono';
|
|
2
|
+
/**
|
|
3
|
+
* API token data stored in the backing store.
|
|
4
|
+
*/
|
|
5
|
+
export interface ApiToken {
|
|
6
|
+
id: string;
|
|
7
|
+
name: string;
|
|
8
|
+
hashedToken: string;
|
|
9
|
+
userId: string | number;
|
|
10
|
+
abilities: string[];
|
|
11
|
+
lastUsedAt: Date | null;
|
|
12
|
+
expiresAt: Date | null;
|
|
13
|
+
createdAt: Date;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Store interface for API tokens.
|
|
17
|
+
* Implement this for database-backed storage.
|
|
18
|
+
*/
|
|
19
|
+
export interface ApiTokenStore {
|
|
20
|
+
/**
|
|
21
|
+
* Store a new API token.
|
|
22
|
+
*/
|
|
23
|
+
store(token: ApiToken): Promise<void>;
|
|
24
|
+
/**
|
|
25
|
+
* Find a token by its hashed value.
|
|
26
|
+
*/
|
|
27
|
+
findByHashedToken(hashedToken: string): Promise<ApiToken | null>;
|
|
28
|
+
/**
|
|
29
|
+
* Find all tokens for a user.
|
|
30
|
+
*/
|
|
31
|
+
findByUserId(userId: string | number): Promise<ApiToken[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Delete a token by its ID.
|
|
34
|
+
*/
|
|
35
|
+
delete(id: string): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Delete all tokens for a user.
|
|
38
|
+
*/
|
|
39
|
+
deleteForUser(userId: string | number): Promise<void>;
|
|
40
|
+
/**
|
|
41
|
+
* Update the last used timestamp.
|
|
42
|
+
*/
|
|
43
|
+
updateLastUsed(id: string, timestamp: Date): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* In-memory token store for testing.
|
|
47
|
+
* Do NOT use in production - tokens will be lost on restart.
|
|
48
|
+
*/
|
|
49
|
+
export declare class MemoryApiTokenStore implements ApiTokenStore {
|
|
50
|
+
private tokens;
|
|
51
|
+
private byHash;
|
|
52
|
+
store(token: ApiToken): Promise<void>;
|
|
53
|
+
findByHashedToken(hashedToken: string): Promise<ApiToken | null>;
|
|
54
|
+
findByUserId(userId: string | number): Promise<ApiToken[]>;
|
|
55
|
+
delete(id: string): Promise<void>;
|
|
56
|
+
deleteForUser(userId: string | number): Promise<void>;
|
|
57
|
+
updateLastUsed(id: string, timestamp: Date): Promise<void>;
|
|
58
|
+
/**
|
|
59
|
+
* Clear all tokens (useful for testing).
|
|
60
|
+
*/
|
|
61
|
+
clear(): void;
|
|
62
|
+
/**
|
|
63
|
+
* Get the number of stored tokens.
|
|
64
|
+
*/
|
|
65
|
+
get size(): number;
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* Configuration for API token creation.
|
|
69
|
+
*/
|
|
70
|
+
export interface CreateApiTokenOptions {
|
|
71
|
+
/**
|
|
72
|
+
* Human-readable name for the token.
|
|
73
|
+
*/
|
|
74
|
+
name: string;
|
|
75
|
+
/**
|
|
76
|
+
* User ID the token belongs to.
|
|
77
|
+
*/
|
|
78
|
+
userId: string | number;
|
|
79
|
+
/**
|
|
80
|
+
* Token abilities/scopes.
|
|
81
|
+
* @default ['*'] (all abilities)
|
|
82
|
+
*/
|
|
83
|
+
abilities?: string[];
|
|
84
|
+
/**
|
|
85
|
+
* Token expiration time in milliseconds from now.
|
|
86
|
+
* @default null (never expires)
|
|
87
|
+
*/
|
|
88
|
+
expiresIn?: number | null;
|
|
89
|
+
/**
|
|
90
|
+
* Token byte length (before encoding).
|
|
91
|
+
* @default 32
|
|
92
|
+
*/
|
|
93
|
+
tokenLength?: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Result of creating an API token.
|
|
97
|
+
*/
|
|
98
|
+
export interface CreateApiTokenResult {
|
|
99
|
+
/**
|
|
100
|
+
* The full token to give to the user.
|
|
101
|
+
* Format: {id}|{plainToken}
|
|
102
|
+
* This is the ONLY time the plain token is available.
|
|
103
|
+
*/
|
|
104
|
+
plainTextToken: string;
|
|
105
|
+
/**
|
|
106
|
+
* The token record (without the plain token).
|
|
107
|
+
*/
|
|
108
|
+
token: ApiToken;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Create a new API token.
|
|
112
|
+
*
|
|
113
|
+
* @example
|
|
114
|
+
* ```ts
|
|
115
|
+
* const { plainTextToken, token } = await createApiToken(store, {
|
|
116
|
+
* name: 'My App Token',
|
|
117
|
+
* userId: user.id,
|
|
118
|
+
* abilities: ['read', 'write'],
|
|
119
|
+
* expiresIn: 30 * 24 * 60 * 60 * 1000, // 30 days
|
|
120
|
+
* })
|
|
121
|
+
*
|
|
122
|
+
* // Return plainTextToken to user - this is the only time it's available
|
|
123
|
+
* return ctx.json({ token: plainTextToken })
|
|
124
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare function createApiToken(store: ApiTokenStore, options: CreateApiTokenOptions): Promise<CreateApiTokenResult>;
|
|
127
|
+
/**
|
|
128
|
+
* Parse a plain text token into its components.
|
|
129
|
+
*/
|
|
130
|
+
export declare function parseApiToken(plainTextToken: string): {
|
|
131
|
+
id: string;
|
|
132
|
+
token: string;
|
|
133
|
+
} | null;
|
|
134
|
+
/**
|
|
135
|
+
* Verify an API token and return the associated user ID.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* const result = await verifyApiToken(plainTextToken, store)
|
|
140
|
+
*
|
|
141
|
+
* if (!result) {
|
|
142
|
+
* return ctx.json({ error: 'Invalid token' }, 401)
|
|
143
|
+
* }
|
|
144
|
+
*
|
|
145
|
+
* console.log(`User ${result.userId} authenticated with abilities:`, result.abilities)
|
|
146
|
+
* ```
|
|
147
|
+
*/
|
|
148
|
+
export declare function verifyApiToken(plainTextToken: string, store: ApiTokenStore, options?: {
|
|
149
|
+
updateLastUsed?: boolean;
|
|
150
|
+
}): Promise<{
|
|
151
|
+
token: ApiToken;
|
|
152
|
+
userId: string | number;
|
|
153
|
+
abilities: string[];
|
|
154
|
+
} | null>;
|
|
155
|
+
/**
|
|
156
|
+
* Check if a token has a specific ability.
|
|
157
|
+
*/
|
|
158
|
+
export declare function tokenCan(token: ApiToken | {
|
|
159
|
+
abilities: string[];
|
|
160
|
+
}, ability: string): boolean;
|
|
161
|
+
/**
|
|
162
|
+
* Check if a token has all specified abilities.
|
|
163
|
+
*/
|
|
164
|
+
export declare function tokenCanAll(token: ApiToken | {
|
|
165
|
+
abilities: string[];
|
|
166
|
+
}, abilities: string[]): boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Check if a token has any of the specified abilities.
|
|
169
|
+
*/
|
|
170
|
+
export declare function tokenCanAny(token: ApiToken | {
|
|
171
|
+
abilities: string[];
|
|
172
|
+
}, abilities: string[]): boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Revoke (delete) an API token.
|
|
175
|
+
*
|
|
176
|
+
* @example
|
|
177
|
+
* ```ts
|
|
178
|
+
* await revokeApiToken(tokenId, store)
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
export declare function revokeApiToken(id: string, store: ApiTokenStore): Promise<void>;
|
|
182
|
+
/**
|
|
183
|
+
* Revoke all API tokens for a user.
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* // Revoke all tokens when user changes password
|
|
188
|
+
* await revokeAllApiTokens(user.id, store)
|
|
189
|
+
* ```
|
|
190
|
+
*/
|
|
191
|
+
export declare function revokeAllApiTokens(userId: string | number, store: ApiTokenStore): Promise<void>;
|
|
192
|
+
/**
|
|
193
|
+
* Get all API tokens for a user.
|
|
194
|
+
*
|
|
195
|
+
* @example
|
|
196
|
+
* ```ts
|
|
197
|
+
* const tokens = await getUserApiTokens(user.id, store)
|
|
198
|
+
* // Returns tokens without the plain text (only metadata)
|
|
199
|
+
* ```
|
|
200
|
+
*/
|
|
201
|
+
export declare function getUserApiTokens(userId: string | number, store: ApiTokenStore): Promise<ApiToken[]>;
|
|
202
|
+
/**
|
|
203
|
+
* Context key for storing the authenticated token.
|
|
204
|
+
*/
|
|
205
|
+
export declare const API_TOKEN_KEY = "guren:api-token";
|
|
206
|
+
/**
|
|
207
|
+
* Options for the bearer token middleware.
|
|
208
|
+
*/
|
|
209
|
+
export interface BearerTokenMiddlewareOptions {
|
|
210
|
+
/**
|
|
211
|
+
* Token store implementation.
|
|
212
|
+
*/
|
|
213
|
+
store: ApiTokenStore;
|
|
214
|
+
/**
|
|
215
|
+
* Function to load the user from the user ID.
|
|
216
|
+
*/
|
|
217
|
+
loadUser?: (userId: string | number) => Promise<unknown>;
|
|
218
|
+
/**
|
|
219
|
+
* Required abilities for this route.
|
|
220
|
+
* If not specified, any valid token is accepted.
|
|
221
|
+
*/
|
|
222
|
+
abilities?: string[];
|
|
223
|
+
/**
|
|
224
|
+
* Custom handler when authentication fails.
|
|
225
|
+
*/
|
|
226
|
+
onUnauthorized?: (ctx: Context) => Response | Promise<Response>;
|
|
227
|
+
/**
|
|
228
|
+
* Custom handler when token lacks required abilities.
|
|
229
|
+
*/
|
|
230
|
+
onForbidden?: (ctx: Context, required: string[]) => Response | Promise<Response>;
|
|
231
|
+
/**
|
|
232
|
+
* Header name to extract the token from.
|
|
233
|
+
* @default 'Authorization'
|
|
234
|
+
*/
|
|
235
|
+
headerName?: string;
|
|
236
|
+
/**
|
|
237
|
+
* Whether to update the token's lastUsedAt timestamp.
|
|
238
|
+
* @default true
|
|
239
|
+
*/
|
|
240
|
+
updateLastUsed?: boolean;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Create middleware that authenticates requests using Bearer tokens.
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```ts
|
|
247
|
+
* // Basic usage
|
|
248
|
+
* app.use('/api/*', createBearerTokenMiddleware({ store }))
|
|
249
|
+
*
|
|
250
|
+
* // With ability requirement
|
|
251
|
+
* router.delete('/api/posts/:id', [PostController, 'destroy'],
|
|
252
|
+
* createBearerTokenMiddleware({
|
|
253
|
+
* store,
|
|
254
|
+
* abilities: ['posts:delete'],
|
|
255
|
+
* })
|
|
256
|
+
* )
|
|
257
|
+
*
|
|
258
|
+
* // With user loading
|
|
259
|
+
* app.use('/api/*', createBearerTokenMiddleware({
|
|
260
|
+
* store,
|
|
261
|
+
* loadUser: async (userId) => User.find(userId),
|
|
262
|
+
* }))
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
export declare function createBearerTokenMiddleware(options: BearerTokenMiddlewareOptions): MiddlewareHandler;
|
|
266
|
+
/**
|
|
267
|
+
* Get the authenticated API token from the request context.
|
|
268
|
+
*
|
|
269
|
+
* @example
|
|
270
|
+
* ```ts
|
|
271
|
+
* router.get('/api/me', async (ctx) => {
|
|
272
|
+
* const { token, userId, abilities } = getApiToken(ctx)!
|
|
273
|
+
* return ctx.json({ userId, tokenName: token.name, abilities })
|
|
274
|
+
* })
|
|
275
|
+
* ```
|
|
276
|
+
*/
|
|
277
|
+
export declare function getApiToken(ctx: Context): {
|
|
278
|
+
token: ApiToken;
|
|
279
|
+
userId: string | number;
|
|
280
|
+
abilities: string[];
|
|
281
|
+
} | null;
|
|
282
|
+
/**
|
|
283
|
+
* Get the authenticated API token from the request context, or throw.
|
|
284
|
+
*
|
|
285
|
+
* @throws {AuthenticationException} When no token is present in the context.
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* ```ts
|
|
289
|
+
* router.get('/api/me', async (ctx) => {
|
|
290
|
+
* const { token, userId, abilities } = getApiTokenOrFail(ctx)
|
|
291
|
+
* return ctx.json({ userId, tokenName: token.name, abilities })
|
|
292
|
+
* })
|
|
293
|
+
* ```
|
|
294
|
+
*/
|
|
295
|
+
export declare function getApiTokenOrFail(ctx: Context): {
|
|
296
|
+
token: ApiToken;
|
|
297
|
+
userId: string | number;
|
|
298
|
+
abilities: string[];
|
|
299
|
+
};
|
|
@@ -0,0 +1,203 @@
|
|
|
1
|
+
import { buildTokenUrl, parseTokenUrl } from './utils.js';
|
|
2
|
+
/**
|
|
3
|
+
* Email verification token data stored in the backing store.
|
|
4
|
+
* Only the hashed token is stored for security.
|
|
5
|
+
*/
|
|
6
|
+
export interface EmailVerificationToken {
|
|
7
|
+
email: string;
|
|
8
|
+
tokenId: string;
|
|
9
|
+
expiresAt: Date;
|
|
10
|
+
createdAt: Date;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Store interface for email verification tokens.
|
|
14
|
+
* Implement this to use database-backed storage.
|
|
15
|
+
*/
|
|
16
|
+
export interface EmailVerificationTokenStore {
|
|
17
|
+
/**
|
|
18
|
+
* Store a new verification token.
|
|
19
|
+
*/
|
|
20
|
+
store(token: EmailVerificationToken): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Find a token by its opaque token ID.
|
|
23
|
+
*/
|
|
24
|
+
findByTokenId(tokenId: string): Promise<EmailVerificationToken | null>;
|
|
25
|
+
/**
|
|
26
|
+
* Delete a token by its opaque token ID.
|
|
27
|
+
*/
|
|
28
|
+
delete(tokenId: string): Promise<void>;
|
|
29
|
+
/**
|
|
30
|
+
* Delete all tokens for a given email.
|
|
31
|
+
*/
|
|
32
|
+
deleteForEmail(email: string): Promise<void>;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* In-memory store for testing purposes.
|
|
36
|
+
* Do NOT use in production - tokens will be lost on restart.
|
|
37
|
+
*/
|
|
38
|
+
export declare class MemoryEmailVerificationStore implements EmailVerificationTokenStore {
|
|
39
|
+
private tokens;
|
|
40
|
+
store(token: EmailVerificationToken): Promise<void>;
|
|
41
|
+
findByTokenId(tokenId: string): Promise<EmailVerificationToken | null>;
|
|
42
|
+
delete(tokenId: string): Promise<void>;
|
|
43
|
+
deleteForEmail(email: string): Promise<void>;
|
|
44
|
+
/**
|
|
45
|
+
* Clear all tokens (useful for testing).
|
|
46
|
+
*/
|
|
47
|
+
clear(): void;
|
|
48
|
+
/**
|
|
49
|
+
* Get the count of stored tokens (useful for testing).
|
|
50
|
+
*/
|
|
51
|
+
get size(): number;
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Configuration options for email verification.
|
|
55
|
+
*/
|
|
56
|
+
export interface EmailVerificationConfig {
|
|
57
|
+
/**
|
|
58
|
+
* Token expiration time in milliseconds.
|
|
59
|
+
* @default 86400000 (24 hours)
|
|
60
|
+
*/
|
|
61
|
+
expiresIn?: number;
|
|
62
|
+
/**
|
|
63
|
+
* Token byte length (before hex encoding).
|
|
64
|
+
* @default 32
|
|
65
|
+
*/
|
|
66
|
+
tokenLength?: number;
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Result of creating an email verification token.
|
|
70
|
+
*/
|
|
71
|
+
export interface EmailVerificationTokenResult {
|
|
72
|
+
/**
|
|
73
|
+
* The raw token to send to the user via email.
|
|
74
|
+
* This is NOT stored - only the hash is stored.
|
|
75
|
+
*/
|
|
76
|
+
token: string;
|
|
77
|
+
/**
|
|
78
|
+
* When the token expires.
|
|
79
|
+
*/
|
|
80
|
+
expiresAt: Date;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
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
|
+
* ```
|
|
104
|
+
*/
|
|
105
|
+
export declare function createEmailVerificationToken(email: string, store: EmailVerificationTokenStore, config?: EmailVerificationConfig): Promise<EmailVerificationTokenResult>;
|
|
106
|
+
/**
|
|
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
|
+
* ```
|
|
125
|
+
*/
|
|
126
|
+
export declare function verifyEmailToken(token: string, store: EmailVerificationTokenStore, _config?: EmailVerificationConfig): Promise<string | null>;
|
|
127
|
+
/**
|
|
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
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
export declare function completeEmailVerification<T>(token: string, store: EmailVerificationTokenStore, markVerified: (email: string) => Promise<T>): Promise<T | null>;
|
|
154
|
+
/**
|
|
155
|
+
* Build a verification URL.
|
|
156
|
+
*/
|
|
157
|
+
export declare const buildVerificationUrl: typeof buildTokenUrl;
|
|
158
|
+
/**
|
|
159
|
+
* Parse a verification URL to extract token and email.
|
|
160
|
+
*/
|
|
161
|
+
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
|
+
*/
|
|
176
|
+
export declare function isEmailVerified(user: {
|
|
177
|
+
emailVerifiedAt?: Date | null;
|
|
178
|
+
} | null): boolean;
|
|
179
|
+
/**
|
|
180
|
+
* Middleware factory to require verified email.
|
|
181
|
+
*
|
|
182
|
+
* @param options - Configuration options
|
|
183
|
+
* @returns Middleware function
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* ```ts
|
|
187
|
+
* router.get('/dashboard', [DashboardController, 'index'],
|
|
188
|
+
* requireAuthenticated(),
|
|
189
|
+
* requireVerifiedEmail({ redirectTo: '/verify-email' })
|
|
190
|
+
* )
|
|
191
|
+
* ```
|
|
192
|
+
*/
|
|
193
|
+
export declare function requireVerifiedEmail(options?: {
|
|
194
|
+
redirectTo?: string;
|
|
195
|
+
getUser?: (ctx: {
|
|
196
|
+
get: <T = unknown>(key: string) => T;
|
|
197
|
+
}) => Promise<{
|
|
198
|
+
emailVerifiedAt?: Date | null;
|
|
199
|
+
} | null>;
|
|
200
|
+
}): (ctx: {
|
|
201
|
+
get: <T = unknown>(key: string) => T;
|
|
202
|
+
redirect: (url: string) => Response;
|
|
203
|
+
}, next: () => Promise<void>) => Promise<Response | undefined>;
|