@guren/server 2.1.0 → 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-HONCNQXZ.js → chunk-BUQXOZCT.js} +97 -10
- 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-EARA7JM4.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-D60YF2ZO.d.ts +0 -329
- package/dist/index-9_Jzj5jo.d.ts +0 -7
- package/dist/validation-yAL53e1S.d.ts +0 -2610
|
@@ -1,222 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
purpose?: string;
|
|
12
|
-
expiresIn?: number;
|
|
13
|
-
}
|
|
14
|
-
interface VerifySignedMessageOptions {
|
|
15
|
-
purpose?: string;
|
|
16
|
-
allowExpired?: boolean;
|
|
17
|
-
}
|
|
18
|
-
declare class MessageSigner {
|
|
19
|
-
private readonly keyring;
|
|
20
|
-
constructor(keyring: AppKeyring);
|
|
21
|
-
sign<T extends Record<string, unknown>>(payload: T, options?: SignMessageOptions): string;
|
|
22
|
-
verify<T extends Record<string, unknown> = Record<string, unknown>>(token: string, options?: VerifySignedMessageOptions): (T & SignedMessageClaims) | null;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
interface SignedUrlOptions {
|
|
26
|
-
expiresIn?: number;
|
|
27
|
-
}
|
|
28
|
-
interface VerifySignedUrlOptions {
|
|
29
|
-
requireExpiration?: boolean;
|
|
30
|
-
}
|
|
31
|
-
declare function signUrl(value: string, keyring: AppKeyring, options?: SignedUrlOptions): string;
|
|
32
|
-
declare function verifySignedUrl(value: string, keyring: AppKeyring, options?: VerifySignedUrlOptions): boolean;
|
|
33
|
-
|
|
34
|
-
/**
|
|
35
|
-
* Hash a value using the specified algorithm.
|
|
36
|
-
*
|
|
37
|
-
* @example
|
|
38
|
-
* ```typescript
|
|
39
|
-
* hash('hello') // SHA-256 by default
|
|
40
|
-
* hash('hello', 'sha512')
|
|
41
|
-
* hash('hello', 'md5')
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
declare function hash(value: string | Buffer, algorithm?: HashAlgorithm, encoding?: 'hex' | 'base64'): string;
|
|
45
|
-
/**
|
|
46
|
-
* Create an HMAC signature.
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* ```typescript
|
|
50
|
-
* hmac('message', 'secret-key')
|
|
51
|
-
* hmac('message', 'secret-key', { algorithm: 'sha512' })
|
|
52
|
-
* ```
|
|
53
|
-
*/
|
|
54
|
-
declare function hmac(value: string | Buffer, key: string | Buffer, options?: HmacOptions): string;
|
|
55
|
-
/**
|
|
56
|
-
* Verify an HMAC signature.
|
|
57
|
-
*/
|
|
58
|
-
declare function verifyHmac(value: string | Buffer, signature: string, key: string | Buffer, options?: HmacOptions): boolean;
|
|
59
|
-
/**
|
|
60
|
-
* Create a SHA-256 hash.
|
|
61
|
-
*/
|
|
62
|
-
declare function sha256(value: string | Buffer): string;
|
|
63
|
-
/**
|
|
64
|
-
* Create a SHA-512 hash.
|
|
65
|
-
*/
|
|
66
|
-
declare function sha512(value: string | Buffer): string;
|
|
67
|
-
/**
|
|
68
|
-
* Create an MD5 hash (not secure, use only for checksums).
|
|
69
|
-
*/
|
|
70
|
-
declare function md5(value: string | Buffer): string;
|
|
71
|
-
/**
|
|
72
|
-
* Hash a password using scrypt.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```typescript
|
|
76
|
-
* const hashed = await hashPassword('mypassword')
|
|
77
|
-
* // Returns: $scrypt$N=16384,r=8,p=1$salt$hash
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
declare function hashPassword(password: string, options?: PasswordHashOptions): Promise<string>;
|
|
81
|
-
/**
|
|
82
|
-
* Verify a password against a hash.
|
|
83
|
-
*
|
|
84
|
-
* @example
|
|
85
|
-
* ```typescript
|
|
86
|
-
* const isValid = await verifyPassword('mypassword', hashedPassword)
|
|
87
|
-
* ```
|
|
88
|
-
*/
|
|
89
|
-
declare function verifyPassword(password: string, hash: string): Promise<boolean>;
|
|
90
|
-
/**
|
|
91
|
-
* Check if a password needs to be rehashed (parameters changed).
|
|
92
|
-
*/
|
|
93
|
-
declare function needsRehash(hash: string, options?: PasswordHashOptions): boolean;
|
|
94
|
-
/**
|
|
95
|
-
* Constant-time string comparison.
|
|
96
|
-
*/
|
|
97
|
-
declare function secureCompare(a: string, b: string): boolean;
|
|
98
|
-
/**
|
|
99
|
-
* Check if a value matches a hash.
|
|
100
|
-
*/
|
|
101
|
-
declare function check(value: string | Buffer, hash: string, algorithm?: HashAlgorithm): boolean;
|
|
102
|
-
|
|
103
|
-
/**
|
|
104
|
-
* Generate a cryptographically secure random string.
|
|
105
|
-
*
|
|
106
|
-
* @example
|
|
107
|
-
* ```typescript
|
|
108
|
-
* randomString(32) // 32-character alphanumeric string
|
|
109
|
-
* randomString(16, { charset: 'hex' }) // 16-character hex string
|
|
110
|
-
* randomString(24, { charset: 'url-safe' }) // URL-safe string
|
|
111
|
-
* ```
|
|
112
|
-
*/
|
|
113
|
-
declare function randomString(length: number, options?: RandomStringOptions): string;
|
|
114
|
-
/**
|
|
115
|
-
* Generate random bytes.
|
|
116
|
-
*
|
|
117
|
-
* @example
|
|
118
|
-
* ```typescript
|
|
119
|
-
* const bytes = random(32) // 32 random bytes
|
|
120
|
-
* ```
|
|
121
|
-
*/
|
|
122
|
-
declare function random(length: number): Buffer;
|
|
123
|
-
/**
|
|
124
|
-
* Generate random bytes as hex string.
|
|
125
|
-
*/
|
|
126
|
-
declare function randomHex(length: number): string;
|
|
127
|
-
/**
|
|
128
|
-
* Generate random bytes as base64 string.
|
|
129
|
-
*/
|
|
130
|
-
declare function randomBase64(length: number): string;
|
|
131
|
-
/**
|
|
132
|
-
* Generate random bytes as URL-safe base64 string.
|
|
133
|
-
*/
|
|
134
|
-
declare function randomBase64Url(length: number): string;
|
|
135
|
-
/**
|
|
136
|
-
* Generate a UUID v4.
|
|
137
|
-
*
|
|
138
|
-
* @example
|
|
139
|
-
* ```typescript
|
|
140
|
-
* const id = uuid() // e.g., '550e8400-e29b-41d4-a716-446655440000'
|
|
141
|
-
* ```
|
|
142
|
-
*/
|
|
143
|
-
declare function uuid(): string;
|
|
144
|
-
/**
|
|
145
|
-
* Generate a secure random integer.
|
|
146
|
-
*
|
|
147
|
-
* @example
|
|
148
|
-
* ```typescript
|
|
149
|
-
* randomInt(1, 100) // Random number between 1 and 100 (inclusive)
|
|
150
|
-
* ```
|
|
151
|
-
*/
|
|
152
|
-
declare function randomInt(min: number, max: number): number;
|
|
153
|
-
/**
|
|
154
|
-
* Generate a random token suitable for URLs.
|
|
155
|
-
*
|
|
156
|
-
* @example
|
|
157
|
-
* ```typescript
|
|
158
|
-
* const token = urlSafeToken(32) // URL-safe 32-character token
|
|
159
|
-
* ```
|
|
160
|
-
*/
|
|
161
|
-
declare function urlSafeToken(length?: number): string;
|
|
162
|
-
/**
|
|
163
|
-
* Generate a secure random password.
|
|
164
|
-
*
|
|
165
|
-
* @example
|
|
166
|
-
* ```typescript
|
|
167
|
-
* const password = generatePassword(16) // Random 16-character password
|
|
168
|
-
* ```
|
|
169
|
-
*/
|
|
170
|
-
declare function generatePassword(length?: number, options?: {
|
|
171
|
-
uppercase?: boolean;
|
|
172
|
-
lowercase?: boolean;
|
|
173
|
-
numbers?: boolean;
|
|
174
|
-
symbols?: boolean;
|
|
175
|
-
}): string;
|
|
176
|
-
/**
|
|
177
|
-
* Generate a random OTP (One-Time Password).
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```typescript
|
|
181
|
-
* const otp = generateOtp(6) // e.g., '482901'
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
|
-
declare function generateOtp(length?: number): string;
|
|
185
|
-
/**
|
|
186
|
-
* Generate a random slug-friendly string.
|
|
187
|
-
*
|
|
188
|
-
* @example
|
|
189
|
-
* ```typescript
|
|
190
|
-
* const slug = generateSlug() // e.g., 'a8b2c4d6e8'
|
|
191
|
-
* ```
|
|
192
|
-
*/
|
|
193
|
-
declare function generateSlug(length?: number): string;
|
|
194
|
-
/**
|
|
195
|
-
* Shuffle an array using Fisher-Yates algorithm with secure random.
|
|
196
|
-
*
|
|
197
|
-
* @example
|
|
198
|
-
* ```typescript
|
|
199
|
-
* const shuffled = shuffle([1, 2, 3, 4, 5])
|
|
200
|
-
* ```
|
|
201
|
-
*/
|
|
202
|
-
declare function shuffle<T>(array: T[]): T[];
|
|
203
|
-
/**
|
|
204
|
-
* Pick a random element from an array.
|
|
205
|
-
*
|
|
206
|
-
* @example
|
|
207
|
-
* ```typescript
|
|
208
|
-
* const item = pick(['a', 'b', 'c']) // Random element
|
|
209
|
-
* ```
|
|
210
|
-
*/
|
|
211
|
-
declare function pick<T>(array: T[]): T;
|
|
212
|
-
/**
|
|
213
|
-
* Pick multiple random elements from an array.
|
|
214
|
-
*
|
|
215
|
-
* @example
|
|
216
|
-
* ```typescript
|
|
217
|
-
* const items = sample(['a', 'b', 'c', 'd'], 2) // Two random elements
|
|
218
|
-
* ```
|
|
219
|
-
*/
|
|
220
|
-
declare function sample<T>(array: T[], count: number): T[];
|
|
221
|
-
|
|
222
|
-
export { AppKeyring, HashAlgorithm, HmacOptions, MessageSigner, PasswordHashOptions, RandomStringOptions, type SignMessageOptions, type SignedMessageClaims, type SignedUrlOptions, type VerifySignedMessageOptions, type VerifySignedUrlOptions, check, generateOtp, generatePassword, generateSlug, hash, hashPassword, hmac, md5, needsRehash, pick, random, randomBase64, randomBase64Url, randomHex, randomInt, randomString, sample, secureCompare, sha256, sha512, shuffle, signUrl, urlSafeToken, uuid, verifyHmac, verifyPassword, verifySignedUrl };
|
|
1
|
+
export type { EncryptOptions, DecryptOptions, EncrypterConfig, EncryptedPayload, HashAlgorithm, HmacOptions, PasswordHashOptions, RandomStringOptions, } from './types.js';
|
|
2
|
+
export { Encrypter, generateKey, createEncrypter, setEncrypter, getEncrypter, encrypt, decrypt, } from './Encrypter.js';
|
|
3
|
+
export { generateAppKey, normalizeAppKey, parseAppKey, parsePreviousAppKeys, getAppKeyringFromEnv, deriveAppKey, deriveAppKeyring, encodeDerivedKey, } from './app-key.js';
|
|
4
|
+
export type { AppKeyring } from './app-key.js';
|
|
5
|
+
export { MessageSigner } from './MessageSigner.js';
|
|
6
|
+
export type { SignedMessageClaims, SignMessageOptions, VerifySignedMessageOptions, } from './MessageSigner.js';
|
|
7
|
+
export { signUrl, verifySignedUrl } from './signed-url.js';
|
|
8
|
+
export type { SignedUrlOptions, VerifySignedUrlOptions } from './signed-url.js';
|
|
9
|
+
export { hash, hmac, verifyHmac, sha256, sha512, md5, hashPassword, verifyPassword, needsRehash, secureCompare, check, } from './Hash.js';
|
|
10
|
+
export { randomString, random, randomHex, randomBase64, randomBase64Url, uuid, randomInt, urlSafeToken, generatePassword, generateOtp, generateSlug, shuffle, pick, sample, } from './Random.js';
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { AppKeyring } from './app-key.js';
|
|
2
|
+
export interface SignedUrlOptions {
|
|
3
|
+
expiresIn?: number;
|
|
4
|
+
}
|
|
5
|
+
export interface VerifySignedUrlOptions {
|
|
6
|
+
requireExpiration?: boolean;
|
|
7
|
+
}
|
|
8
|
+
export declare function signUrl(value: string, keyring: AppKeyring, options?: SignedUrlOptions): string;
|
|
9
|
+
export declare function verifySignedUrl(value: string, keyring: AppKeyring, options?: VerifySignedUrlOptions): boolean;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Encryption options.
|
|
3
|
+
*/
|
|
4
|
+
export interface EncryptOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Whether to serialize the value before encryption.
|
|
7
|
+
*/
|
|
8
|
+
serialize?: boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Decryption options.
|
|
12
|
+
*/
|
|
13
|
+
export interface DecryptOptions {
|
|
14
|
+
/**
|
|
15
|
+
* Whether to deserialize the value after decryption.
|
|
16
|
+
*/
|
|
17
|
+
deserialize?: boolean;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Encrypter configuration.
|
|
21
|
+
*/
|
|
22
|
+
export interface EncrypterConfig {
|
|
23
|
+
/**
|
|
24
|
+
* Encryption key (base64 encoded, 32 bytes for AES-256).
|
|
25
|
+
*/
|
|
26
|
+
key: string;
|
|
27
|
+
/**
|
|
28
|
+
* Previous encryption keys used for decryption fallback during key rotation.
|
|
29
|
+
*/
|
|
30
|
+
previousKeys?: string[];
|
|
31
|
+
/**
|
|
32
|
+
* Encryption cipher to use.
|
|
33
|
+
*/
|
|
34
|
+
cipher?: 'aes-256-gcm' | 'aes-256-cbc';
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Encrypted payload structure.
|
|
38
|
+
*/
|
|
39
|
+
export interface EncryptedPayload {
|
|
40
|
+
/**
|
|
41
|
+
* Initialization vector (base64).
|
|
42
|
+
*/
|
|
43
|
+
iv: string;
|
|
44
|
+
/**
|
|
45
|
+
* Encrypted value (base64).
|
|
46
|
+
*/
|
|
47
|
+
value: string;
|
|
48
|
+
/**
|
|
49
|
+
* Authentication tag for GCM mode (base64).
|
|
50
|
+
*/
|
|
51
|
+
tag?: string;
|
|
52
|
+
/**
|
|
53
|
+
* MAC for CBC mode (hex).
|
|
54
|
+
*/
|
|
55
|
+
mac?: string;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Hash algorithm options.
|
|
59
|
+
*/
|
|
60
|
+
export type HashAlgorithm = 'sha256' | 'sha384' | 'sha512' | 'md5' | 'sha1';
|
|
61
|
+
/**
|
|
62
|
+
* HMAC options.
|
|
63
|
+
*/
|
|
64
|
+
export interface HmacOptions {
|
|
65
|
+
/**
|
|
66
|
+
* Hash algorithm to use.
|
|
67
|
+
*/
|
|
68
|
+
algorithm?: HashAlgorithm;
|
|
69
|
+
/**
|
|
70
|
+
* Output encoding.
|
|
71
|
+
*/
|
|
72
|
+
encoding?: 'hex' | 'base64';
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Password hash options.
|
|
76
|
+
*/
|
|
77
|
+
export interface PasswordHashOptions {
|
|
78
|
+
/**
|
|
79
|
+
* Memory cost (for scrypt/argon2).
|
|
80
|
+
*/
|
|
81
|
+
memory?: number;
|
|
82
|
+
/**
|
|
83
|
+
* CPU cost (for scrypt/argon2).
|
|
84
|
+
*/
|
|
85
|
+
cost?: number;
|
|
86
|
+
/**
|
|
87
|
+
* Salt length in bytes.
|
|
88
|
+
*/
|
|
89
|
+
saltLength?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Key length in bytes.
|
|
92
|
+
*/
|
|
93
|
+
keyLength?: number;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Random string options.
|
|
97
|
+
*/
|
|
98
|
+
export interface RandomStringOptions {
|
|
99
|
+
/**
|
|
100
|
+
* Character set to use.
|
|
101
|
+
*/
|
|
102
|
+
charset?: 'alphanumeric' | 'alphabetic' | 'numeric' | 'hex' | 'base64' | 'url-safe';
|
|
103
|
+
}
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
import type { Context } from '../http/Application.js';
|
|
2
|
+
import type { Middleware } from '../http/middleware/index.js';
|
|
3
|
+
import type { ExceptionHandlerOptions, ExceptionReporter, ExceptionRenderer, ExceptionClass, RendererRegistration } from './types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Exception handler for centralized error handling.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* const handler = new ExceptionHandler({ debug: false })
|
|
10
|
+
*
|
|
11
|
+
* // Report exceptions (e.g., to Sentry)
|
|
12
|
+
* handler.report(async (error) => {
|
|
13
|
+
* await sentry.captureException(error)
|
|
14
|
+
* })
|
|
15
|
+
*
|
|
16
|
+
* // Custom renderer for validation errors
|
|
17
|
+
* handler.render(ValidationException, (error, ctx) => {
|
|
18
|
+
* return ctx.json({ errors: error.errors }, 422)
|
|
19
|
+
* })
|
|
20
|
+
*
|
|
21
|
+
* // Don't report 404 errors
|
|
22
|
+
* handler.dontReport(NotFoundHttpException)
|
|
23
|
+
*
|
|
24
|
+
* // Use as middleware
|
|
25
|
+
* app.use('*', handler.middleware())
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export declare class ExceptionHandler {
|
|
29
|
+
/**
|
|
30
|
+
* Exception reporters.
|
|
31
|
+
*/
|
|
32
|
+
protected reporters: ExceptionReporter[];
|
|
33
|
+
/**
|
|
34
|
+
* Exception renderers.
|
|
35
|
+
*/
|
|
36
|
+
protected renderers: RendererRegistration[];
|
|
37
|
+
/**
|
|
38
|
+
* Exception classes to not report.
|
|
39
|
+
*/
|
|
40
|
+
protected dontReportClasses: ExceptionClass[];
|
|
41
|
+
/**
|
|
42
|
+
* Handler options.
|
|
43
|
+
*/
|
|
44
|
+
protected options: ExceptionHandlerOptions;
|
|
45
|
+
constructor(options?: ExceptionHandlerOptions);
|
|
46
|
+
/**
|
|
47
|
+
* Register an exception reporter.
|
|
48
|
+
* Reporters are called for every exception (unless in dontReport list).
|
|
49
|
+
*/
|
|
50
|
+
report(callback: ExceptionReporter): this;
|
|
51
|
+
/**
|
|
52
|
+
* Register a custom renderer for an exception type.
|
|
53
|
+
*/
|
|
54
|
+
render<T extends Error>(errorClass: ExceptionClass<T>, renderer: ExceptionRenderer<T>): this;
|
|
55
|
+
/**
|
|
56
|
+
* Add an exception class to the don't report list.
|
|
57
|
+
*/
|
|
58
|
+
dontReport(errorClass: ExceptionClass): this;
|
|
59
|
+
/**
|
|
60
|
+
* Check if debug mode is enabled.
|
|
61
|
+
*/
|
|
62
|
+
shouldShowDetails(): boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Handle an exception.
|
|
65
|
+
*/
|
|
66
|
+
handle(error: Error, ctx: Context): Promise<Response>;
|
|
67
|
+
/**
|
|
68
|
+
* Report an exception to all reporters.
|
|
69
|
+
*/
|
|
70
|
+
protected reportException(error: Error): Promise<void>;
|
|
71
|
+
/**
|
|
72
|
+
* Check if an exception should not be reported.
|
|
73
|
+
*/
|
|
74
|
+
protected shouldNotReport(error: Error): boolean;
|
|
75
|
+
protected matchesErrorClass(error: Error, errorClass: ExceptionClass): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Render an exception to a response.
|
|
78
|
+
*/
|
|
79
|
+
protected renderException(error: Error, ctx: Context): Promise<Response>;
|
|
80
|
+
/**
|
|
81
|
+
* Default exception rendering.
|
|
82
|
+
*/
|
|
83
|
+
protected renderDefaultException(error: Error, ctx: Context): Response;
|
|
84
|
+
/**
|
|
85
|
+
* Determine whether the request expects an HTML response.
|
|
86
|
+
* Returns false for Inertia, XHR, and JSON API requests so they
|
|
87
|
+
* continue to receive JSON error payloads.
|
|
88
|
+
*/
|
|
89
|
+
protected wantsHtmlResponse(ctx: Context): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* Create middleware for exception handling.
|
|
92
|
+
*/
|
|
93
|
+
middleware(): Middleware;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Create an exception handler.
|
|
97
|
+
*/
|
|
98
|
+
export declare function createExceptionHandler(options?: ExceptionHandlerOptions): ExceptionHandler;
|
|
99
|
+
/**
|
|
100
|
+
* Set the global exception handler.
|
|
101
|
+
*/
|
|
102
|
+
export declare function setExceptionHandler(handler: ExceptionHandler): void;
|
|
103
|
+
/**
|
|
104
|
+
* Get the global exception handler.
|
|
105
|
+
*/
|
|
106
|
+
export declare function getExceptionHandler(): ExceptionHandler;
|
|
107
|
+
/**
|
|
108
|
+
* Abort the request with an HTTP exception.
|
|
109
|
+
*/
|
|
110
|
+
export declare function abort(statusCode: number, message?: string, errors?: Record<string, string[]>): never;
|
|
111
|
+
/**
|
|
112
|
+
* Abort if condition is true.
|
|
113
|
+
*/
|
|
114
|
+
export declare function abortIf(condition: boolean, statusCode: number, message?: string): void;
|
|
115
|
+
/**
|
|
116
|
+
* Abort unless condition is true.
|
|
117
|
+
*/
|
|
118
|
+
export declare function abortUnless(condition: boolean, statusCode: number, message?: string): void;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
import type { ErrorResponse } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Base HTTP exception class.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* // Using factory methods
|
|
8
|
+
* throw HttpException.notFound('User not found')
|
|
9
|
+
* throw HttpException.unauthorized('Invalid credentials')
|
|
10
|
+
*
|
|
11
|
+
* // Custom status code
|
|
12
|
+
* throw new HttpException(418, "I'm a teapot")
|
|
13
|
+
*
|
|
14
|
+
* // With validation errors
|
|
15
|
+
* throw HttpException.unprocessable('Validation failed', {
|
|
16
|
+
* email: ['Email is required', 'Email must be valid'],
|
|
17
|
+
* password: ['Password is too short'],
|
|
18
|
+
* })
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare class HttpException extends Error {
|
|
22
|
+
/**
|
|
23
|
+
* HTTP status code.
|
|
24
|
+
*/
|
|
25
|
+
readonly statusCode: number;
|
|
26
|
+
/**
|
|
27
|
+
* Validation or field-specific errors.
|
|
28
|
+
*/
|
|
29
|
+
readonly errors?: Record<string, string[]>;
|
|
30
|
+
/**
|
|
31
|
+
* Additional error data.
|
|
32
|
+
*/
|
|
33
|
+
readonly data?: Record<string, unknown>;
|
|
34
|
+
constructor(statusCode: number, message: string, errors?: Record<string, string[]>, data?: Record<string, unknown>);
|
|
35
|
+
/**
|
|
36
|
+
* Convert to response format.
|
|
37
|
+
*/
|
|
38
|
+
toResponse(debug?: boolean): {
|
|
39
|
+
status: number;
|
|
40
|
+
body: ErrorResponse;
|
|
41
|
+
};
|
|
42
|
+
/**
|
|
43
|
+
* Convert to JSON.
|
|
44
|
+
*/
|
|
45
|
+
toJSON(): Record<string, unknown>;
|
|
46
|
+
/**
|
|
47
|
+
* Create a 400 Bad Request exception.
|
|
48
|
+
*/
|
|
49
|
+
static badRequest(message?: string): HttpException;
|
|
50
|
+
/**
|
|
51
|
+
* Create a 401 Unauthorized exception.
|
|
52
|
+
*/
|
|
53
|
+
static unauthorized(message?: string): HttpException;
|
|
54
|
+
/**
|
|
55
|
+
* Create a 403 Forbidden exception.
|
|
56
|
+
*/
|
|
57
|
+
static forbidden(message?: string): HttpException;
|
|
58
|
+
/**
|
|
59
|
+
* Create a 404 Not Found exception.
|
|
60
|
+
*/
|
|
61
|
+
static notFound(message?: string): HttpException;
|
|
62
|
+
/**
|
|
63
|
+
* Create a 405 Method Not Allowed exception.
|
|
64
|
+
*/
|
|
65
|
+
static methodNotAllowed(message?: string): HttpException;
|
|
66
|
+
/**
|
|
67
|
+
* Create a 409 Conflict exception.
|
|
68
|
+
*/
|
|
69
|
+
static conflict(message?: string): HttpException;
|
|
70
|
+
/**
|
|
71
|
+
* Create a 410 Gone exception.
|
|
72
|
+
*/
|
|
73
|
+
static gone(message?: string): HttpException;
|
|
74
|
+
/**
|
|
75
|
+
* Create a 422 Unprocessable Entity exception.
|
|
76
|
+
*/
|
|
77
|
+
static unprocessable(message?: string, errors?: Record<string, string[]>): HttpException;
|
|
78
|
+
/**
|
|
79
|
+
* Create a 429 Too Many Requests exception.
|
|
80
|
+
*/
|
|
81
|
+
static tooManyRequests(message?: string): HttpException;
|
|
82
|
+
/**
|
|
83
|
+
* Create a 500 Internal Server Error exception.
|
|
84
|
+
*/
|
|
85
|
+
static internal(message?: string): HttpException;
|
|
86
|
+
/**
|
|
87
|
+
* Create a 501 Not Implemented exception.
|
|
88
|
+
*/
|
|
89
|
+
static notImplemented(message?: string): HttpException;
|
|
90
|
+
/**
|
|
91
|
+
* Create a 502 Bad Gateway exception.
|
|
92
|
+
*/
|
|
93
|
+
static badGateway(message?: string): HttpException;
|
|
94
|
+
/**
|
|
95
|
+
* Create a 503 Service Unavailable exception.
|
|
96
|
+
*/
|
|
97
|
+
static serviceUnavailable(message?: string): HttpException;
|
|
98
|
+
/**
|
|
99
|
+
* Create a 504 Gateway Timeout exception.
|
|
100
|
+
*/
|
|
101
|
+
static gatewayTimeout(message?: string): HttpException;
|
|
102
|
+
/**
|
|
103
|
+
* Check if an error is an HTTP exception.
|
|
104
|
+
*/
|
|
105
|
+
static isHttpException(error: unknown): error is HttpException;
|
|
106
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { MiddlewareHandler } from 'hono';
|
|
2
|
+
/**
|
|
3
|
+
* Render a rich HTML debug error page for development mode.
|
|
4
|
+
*
|
|
5
|
+
* When an error occurs and NODE_ENV is not 'production', this function
|
|
6
|
+
* generates a helpful page displaying the error class, message, stack trace
|
|
7
|
+
* with source context, and request details.
|
|
8
|
+
*/
|
|
9
|
+
export declare function renderDebugPage(error: Error, request?: Request): string;
|
|
10
|
+
/**
|
|
11
|
+
* Middleware that catches errors and renders a debug page in development.
|
|
12
|
+
* In production (NODE_ENV === 'production'), errors are re-thrown so
|
|
13
|
+
* downstream handlers or the ExceptionHandler can process them normally.
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```typescript
|
|
17
|
+
* import { debugErrorMiddleware } from '@guren/server/errors/debug-page'
|
|
18
|
+
*
|
|
19
|
+
* app.use('*', debugErrorMiddleware())
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function debugErrorMiddleware(): MiddlewareHandler;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function renderErrorPage(statusCode: number, message?: string): string;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HttpException } from '../HttpException.js';
|
|
2
|
+
/**
|
|
3
|
+
* Authentication exception.
|
|
4
|
+
*
|
|
5
|
+
* Thrown when a user is not authenticated or credentials are invalid.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* throw new AuthenticationException()
|
|
10
|
+
* throw new AuthenticationException('Invalid token')
|
|
11
|
+
* throw new AuthenticationException('Session expired', 'login')
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class AuthenticationException extends HttpException {
|
|
15
|
+
/**
|
|
16
|
+
* The guard that threw the exception.
|
|
17
|
+
*/
|
|
18
|
+
readonly guard?: string;
|
|
19
|
+
/**
|
|
20
|
+
* URL to redirect to for authentication.
|
|
21
|
+
*/
|
|
22
|
+
readonly redirectTo?: string;
|
|
23
|
+
constructor(message?: string, guard?: string, redirectTo?: string);
|
|
24
|
+
/**
|
|
25
|
+
* Create exception with redirect URL.
|
|
26
|
+
*/
|
|
27
|
+
static withRedirect(redirectTo: string, message?: string): AuthenticationException;
|
|
28
|
+
/**
|
|
29
|
+
* Create exception for a specific guard.
|
|
30
|
+
*/
|
|
31
|
+
static forGuard(guard: string, message?: string): AuthenticationException;
|
|
32
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { HttpException } from '../HttpException.js';
|
|
2
|
+
/**
|
|
3
|
+
* Authorization exception.
|
|
4
|
+
*
|
|
5
|
+
* Thrown when a user is authenticated but not authorized to perform an action.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* throw new AuthorizationException()
|
|
10
|
+
* throw new AuthorizationException('You cannot edit this post')
|
|
11
|
+
* throw new AuthorizationException('Access denied', 'edit', 'Post')
|
|
12
|
+
* ```
|
|
13
|
+
*/
|
|
14
|
+
export declare class AuthorizationException extends HttpException {
|
|
15
|
+
/**
|
|
16
|
+
* The action that was attempted.
|
|
17
|
+
*/
|
|
18
|
+
readonly action?: string;
|
|
19
|
+
/**
|
|
20
|
+
* The resource that was being accessed.
|
|
21
|
+
*/
|
|
22
|
+
readonly resource?: string;
|
|
23
|
+
constructor(message?: string, action?: string, resource?: string);
|
|
24
|
+
/**
|
|
25
|
+
* Create exception for a specific action and resource.
|
|
26
|
+
*/
|
|
27
|
+
static forAction(action: string, resource?: string): AuthorizationException;
|
|
28
|
+
/**
|
|
29
|
+
* Deny access to a resource.
|
|
30
|
+
*/
|
|
31
|
+
static deny(resource?: string): AuthorizationException;
|
|
32
|
+
}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { HttpException } from '../HttpException.js';
|
|
2
|
+
/**
|
|
3
|
+
* Method Not Allowed exception.
|
|
4
|
+
*
|
|
5
|
+
* Thrown when an HTTP method is not allowed for a route.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* throw new MethodNotAllowedException()
|
|
10
|
+
* throw new MethodNotAllowedException('POST', ['GET', 'HEAD'])
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
export declare class MethodNotAllowedException extends HttpException {
|
|
14
|
+
/**
|
|
15
|
+
* The HTTP method that was attempted.
|
|
16
|
+
*/
|
|
17
|
+
readonly method?: string;
|
|
18
|
+
/**
|
|
19
|
+
* The allowed HTTP methods.
|
|
20
|
+
*/
|
|
21
|
+
readonly allowedMethods?: string[];
|
|
22
|
+
constructor(method?: string, allowedMethods?: string[], message?: string);
|
|
23
|
+
/**
|
|
24
|
+
* Get the Allow header value.
|
|
25
|
+
*/
|
|
26
|
+
getAllowHeader(): string;
|
|
27
|
+
/**
|
|
28
|
+
* Create exception with method details.
|
|
29
|
+
*/
|
|
30
|
+
static forMethod(method: string, allowedMethods: string[]): MethodNotAllowedException;
|
|
31
|
+
}
|