@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
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { SeederClass, SeederRunnerOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Seeder runner for executing database seeders.
|
|
4
|
+
*/
|
|
5
|
+
export declare class SeederRunner {
|
|
6
|
+
private options;
|
|
7
|
+
private seeders;
|
|
8
|
+
constructor(options?: SeederRunnerOptions);
|
|
9
|
+
/**
|
|
10
|
+
* Register a seeder class.
|
|
11
|
+
*/
|
|
12
|
+
register(name: string, seeder: SeederClass): this;
|
|
13
|
+
/**
|
|
14
|
+
* Register multiple seeder classes.
|
|
15
|
+
*/
|
|
16
|
+
registerMany(seeders: Record<string, SeederClass>): this;
|
|
17
|
+
/**
|
|
18
|
+
* Run a specific seeder by name or class.
|
|
19
|
+
*/
|
|
20
|
+
run(seeder?: string | SeederClass): Promise<void>;
|
|
21
|
+
/**
|
|
22
|
+
* Run multiple seeders in sequence.
|
|
23
|
+
*/
|
|
24
|
+
runMany(seeders: Array<string | SeederClass>): Promise<void>;
|
|
25
|
+
/**
|
|
26
|
+
* Resolve a seeder by name.
|
|
27
|
+
*/
|
|
28
|
+
private resolveSeeder;
|
|
29
|
+
/**
|
|
30
|
+
* Get available seeders from the seeders directory.
|
|
31
|
+
*/
|
|
32
|
+
getAvailableSeeders(): Promise<string[]>;
|
|
33
|
+
/**
|
|
34
|
+
* Log a message if not silent.
|
|
35
|
+
*/
|
|
36
|
+
private log;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a seeder runner.
|
|
40
|
+
*/
|
|
41
|
+
export declare function createSeederRunner(options?: SeederRunnerOptions): SeederRunner;
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
export type { SeederClass, Seeder as SeederInterface, FactoryClass, Factory as FactoryInterface, SeederRunnerOptions, } from './types.js';
|
|
2
|
+
export { BaseSeeder, Seeder, resetCalledSeeders, } from './Seeder.js';
|
|
3
|
+
export { BaseFactory, Factory, defineFactory, } from './Factory.js';
|
|
4
|
+
export { SeederRunner, createSeederRunner, } from './SeederRunner.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Seeder class interface.
|
|
3
|
+
*/
|
|
4
|
+
export interface SeederClass {
|
|
5
|
+
new (): Seeder;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Abstract seeder interface.
|
|
9
|
+
*/
|
|
10
|
+
export interface Seeder {
|
|
11
|
+
run(): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Factory class interface.
|
|
15
|
+
*/
|
|
16
|
+
export interface FactoryClass<T> {
|
|
17
|
+
new (): Factory<T>;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Abstract factory interface.
|
|
21
|
+
*/
|
|
22
|
+
export interface Factory<T> {
|
|
23
|
+
definition(): Partial<T>;
|
|
24
|
+
make(overrides?: Partial<T>): T;
|
|
25
|
+
makeMany(count: number, overrides?: Partial<T>): T[];
|
|
26
|
+
create(overrides?: Partial<T>): Promise<T>;
|
|
27
|
+
createMany(count: number, overrides?: Partial<T>): Promise<T[]>;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Seeder runner options.
|
|
31
|
+
*/
|
|
32
|
+
export interface SeederRunnerOptions {
|
|
33
|
+
/**
|
|
34
|
+
* Path to seeders directory.
|
|
35
|
+
*/
|
|
36
|
+
seedersPath?: string;
|
|
37
|
+
/**
|
|
38
|
+
* Default seeder class name.
|
|
39
|
+
*/
|
|
40
|
+
defaultSeeder?: string;
|
|
41
|
+
/**
|
|
42
|
+
* Force run in production.
|
|
43
|
+
*/
|
|
44
|
+
force?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* Silent mode (no console output).
|
|
47
|
+
*/
|
|
48
|
+
silent?: boolean;
|
|
49
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Options for configuring the auto-discovery engine.
|
|
3
|
+
*/
|
|
4
|
+
export interface DiscoveryOptions {
|
|
5
|
+
/** Base path for scanning. Defaults to `process.cwd()`. */
|
|
6
|
+
basePath?: string;
|
|
7
|
+
/** Whether to discover service providers in `app/Providers/`. Defaults to `true`. */
|
|
8
|
+
providers?: boolean;
|
|
9
|
+
/** Whether to discover event listeners in `app/Listeners/`. Defaults to `true`. */
|
|
10
|
+
listeners?: boolean;
|
|
11
|
+
/** Whether to discover jobs in `app/Jobs/`. Defaults to `true`. */
|
|
12
|
+
jobs?: boolean;
|
|
13
|
+
/** Whether to discover events in `app/Events/`. Defaults to `true`. */
|
|
14
|
+
events?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result of the auto-discovery scan.
|
|
18
|
+
*/
|
|
19
|
+
export interface DiscoveryResult {
|
|
20
|
+
/** Discovered service provider classes. */
|
|
21
|
+
providers: Array<new (...args: unknown[]) => unknown>;
|
|
22
|
+
/** Discovered event listeners with their associated event name. */
|
|
23
|
+
listeners: Array<{
|
|
24
|
+
event: string;
|
|
25
|
+
listener: new () => unknown;
|
|
26
|
+
}>;
|
|
27
|
+
/** Discovered job classes. */
|
|
28
|
+
jobs: Array<new () => unknown>;
|
|
29
|
+
/** Discovered event classes. */
|
|
30
|
+
events: Array<new () => unknown>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Auto-discovery engine that scans application directories and discovers
|
|
34
|
+
* framework components (providers, listeners, jobs, events).
|
|
35
|
+
*
|
|
36
|
+
* Uses `Bun.Glob` to scan directories and dynamic `import()` to load modules.
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```typescript
|
|
40
|
+
* const discovery = new AutoDiscovery({ basePath: '/app' })
|
|
41
|
+
* const result = await discovery.discover()
|
|
42
|
+
*
|
|
43
|
+
* // Register discovered providers
|
|
44
|
+
* for (const ProviderClass of result.providers) {
|
|
45
|
+
* providerManager.register(ProviderClass)
|
|
46
|
+
* }
|
|
47
|
+
*
|
|
48
|
+
* // Register discovered listeners
|
|
49
|
+
* for (const { event, listener } of result.listeners) {
|
|
50
|
+
* eventManager.listen(event, listener)
|
|
51
|
+
* }
|
|
52
|
+
* ```
|
|
53
|
+
*/
|
|
54
|
+
export declare class AutoDiscovery {
|
|
55
|
+
private basePath;
|
|
56
|
+
private options;
|
|
57
|
+
constructor(options?: DiscoveryOptions);
|
|
58
|
+
/**
|
|
59
|
+
* Run the discovery scan across all enabled directories.
|
|
60
|
+
*/
|
|
61
|
+
discover(): Promise<DiscoveryResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Discover service providers in `app/Providers/`.
|
|
64
|
+
*
|
|
65
|
+
* A module is considered a provider if it exports a class (default or named)
|
|
66
|
+
* that has a `register` method (i.e., implements the Provider interface).
|
|
67
|
+
*/
|
|
68
|
+
private discoverProviders;
|
|
69
|
+
/**
|
|
70
|
+
* Discover event listeners in `app/Listeners/`.
|
|
71
|
+
*
|
|
72
|
+
* A listener class must have a `static event` property (string) that indicates
|
|
73
|
+
* which event it handles, and a `handle` method.
|
|
74
|
+
*/
|
|
75
|
+
private discoverListeners;
|
|
76
|
+
/**
|
|
77
|
+
* Discover jobs in `app/Jobs/`.
|
|
78
|
+
*
|
|
79
|
+
* A job class must have a `handle` method.
|
|
80
|
+
*/
|
|
81
|
+
private discoverJobs;
|
|
82
|
+
/**
|
|
83
|
+
* Discover events in `app/Events/`.
|
|
84
|
+
*
|
|
85
|
+
* Any exported class from the Events directory is considered an event class.
|
|
86
|
+
*/
|
|
87
|
+
private discoverEvents;
|
|
88
|
+
/**
|
|
89
|
+
* Scan a directory for TypeScript files using Bun.Glob.
|
|
90
|
+
* Returns an array of imported modules. Skips `index.ts` barrel files.
|
|
91
|
+
*/
|
|
92
|
+
private scanDirectory;
|
|
93
|
+
/**
|
|
94
|
+
* Extract all class constructors (functions) from a module's exports.
|
|
95
|
+
*/
|
|
96
|
+
private extractClasses;
|
|
97
|
+
/**
|
|
98
|
+
* Check if a value is a constructor function (class).
|
|
99
|
+
*/
|
|
100
|
+
private isConstructor;
|
|
101
|
+
/**
|
|
102
|
+
* Check if a class looks like a service provider (has a `register` method).
|
|
103
|
+
*/
|
|
104
|
+
private isProvider;
|
|
105
|
+
/**
|
|
106
|
+
* Get the `static event` property from a class, if it exists and is a string.
|
|
107
|
+
*/
|
|
108
|
+
private getStaticEvent;
|
|
109
|
+
/**
|
|
110
|
+
* Check if a class has a `handle` method on its prototype.
|
|
111
|
+
*/
|
|
112
|
+
private hasHandleMethod;
|
|
113
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { ServiceProvider } from '../container/ServiceProvider.js';
|
|
2
|
+
/**
|
|
3
|
+
* Registers the docs viewer (RFC 0005) at /_guren/docs: a read-only,
|
|
4
|
+
* loopback-guarded UI that renders the OKF docs bundle as an
|
|
5
|
+
* interactive relation graph. Only active while `isDocsViewerEnabled()`
|
|
6
|
+
* holds. All routes are GET; the whole bundle ships as one payload, so
|
|
7
|
+
* no route takes a path parameter.
|
|
8
|
+
*/
|
|
9
|
+
export declare class DocsViewerServiceProvider extends ServiceProvider {
|
|
10
|
+
register(): void;
|
|
11
|
+
boot(): Promise<void>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Identity and activation rules for the dev-only docs viewer (RFC 0005).
|
|
3
|
+
*
|
|
4
|
+
* Mirrors the MCP endpoint: opt-in via environment variable, never
|
|
5
|
+
* active in production, and every route behind the shared loopback
|
|
6
|
+
* guard. All routes are `GET`, so no CSRF exemption is involved.
|
|
7
|
+
*/
|
|
8
|
+
import type { MiddlewareHandler } from 'hono';
|
|
9
|
+
export declare const DOCS_VIEWER_PATH = "/_guren/docs";
|
|
10
|
+
/**
|
|
11
|
+
* Whether the docs viewer is mounted for this process.
|
|
12
|
+
*
|
|
13
|
+
* Opt-in via `GUREN_DOCS=1` and never active in production: the viewer
|
|
14
|
+
* renders the project's private knowledge bundle, so it must not be
|
|
15
|
+
* reachable unless the developer asked for it.
|
|
16
|
+
*/
|
|
17
|
+
export declare function isDocsViewerEnabled(): boolean;
|
|
18
|
+
/** Restricts the docs viewer to the developer's own machine. */
|
|
19
|
+
export declare function createDocsViewerAccessGuard(): MiddlewareHandler;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
import type { EncrypterConfig, EncryptOptions, DecryptOptions, EncryptedPayload } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Encrypter for secure data encryption using AES.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* const encrypter = new Encrypter({ key: 'base64-encoded-32-byte-key' })
|
|
8
|
+
*
|
|
9
|
+
* // Encrypt
|
|
10
|
+
* const encrypted = encrypter.encrypt({ userId: 123, role: 'admin' })
|
|
11
|
+
*
|
|
12
|
+
* // Decrypt
|
|
13
|
+
* const data = encrypter.decrypt(encrypted)
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
export declare class Encrypter {
|
|
17
|
+
/**
|
|
18
|
+
* Encryption key.
|
|
19
|
+
*/
|
|
20
|
+
protected key: Buffer;
|
|
21
|
+
protected previousKeys: Buffer[];
|
|
22
|
+
/**
|
|
23
|
+
* Cipher algorithm.
|
|
24
|
+
*/
|
|
25
|
+
protected cipher: 'aes-256-gcm' | 'aes-256-cbc';
|
|
26
|
+
constructor(config: EncrypterConfig);
|
|
27
|
+
/**
|
|
28
|
+
* Encrypt a value.
|
|
29
|
+
*/
|
|
30
|
+
encrypt(value: unknown, options?: EncryptOptions): string;
|
|
31
|
+
/**
|
|
32
|
+
* Decrypt a value.
|
|
33
|
+
*/
|
|
34
|
+
decrypt<T = unknown>(payload: string, options?: DecryptOptions): T;
|
|
35
|
+
/**
|
|
36
|
+
* Encrypt a string (no serialization).
|
|
37
|
+
*/
|
|
38
|
+
encryptString(value: string): string;
|
|
39
|
+
/**
|
|
40
|
+
* Decrypt a string (no deserialization).
|
|
41
|
+
*/
|
|
42
|
+
decryptString(payload: string): string;
|
|
43
|
+
/**
|
|
44
|
+
* Encrypt using AES-256-GCM.
|
|
45
|
+
*/
|
|
46
|
+
protected encryptGcm(data: string): string;
|
|
47
|
+
/**
|
|
48
|
+
* Decrypt using AES-256-GCM.
|
|
49
|
+
*/
|
|
50
|
+
protected decryptGcm(payload: EncryptedPayload): string;
|
|
51
|
+
/**
|
|
52
|
+
* Encrypt using AES-256-CBC with HMAC.
|
|
53
|
+
*/
|
|
54
|
+
protected encryptCbc(data: string): string;
|
|
55
|
+
/**
|
|
56
|
+
* Decrypt using AES-256-CBC with HMAC verification.
|
|
57
|
+
*/
|
|
58
|
+
protected decryptCbc(payload: EncryptedPayload): string;
|
|
59
|
+
/**
|
|
60
|
+
* Create HMAC for CBC mode.
|
|
61
|
+
*/
|
|
62
|
+
protected createMac(iv: Buffer, encrypted: Buffer, key?: Buffer): string;
|
|
63
|
+
/**
|
|
64
|
+
* Constant-time string comparison.
|
|
65
|
+
*/
|
|
66
|
+
protected secureCompare(a: string, b: string): boolean;
|
|
67
|
+
/**
|
|
68
|
+
* Get the encryption key (base64).
|
|
69
|
+
*/
|
|
70
|
+
getKey(): string;
|
|
71
|
+
protected tryDecryptWithKeys(run: (key: Buffer) => string): string;
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Generate a random encryption key.
|
|
75
|
+
*/
|
|
76
|
+
export declare function generateKey(): string;
|
|
77
|
+
/**
|
|
78
|
+
* Create an encrypter instance.
|
|
79
|
+
*/
|
|
80
|
+
export declare function createEncrypter(config: EncrypterConfig): Encrypter;
|
|
81
|
+
/**
|
|
82
|
+
* Set the global encrypter.
|
|
83
|
+
*/
|
|
84
|
+
export declare function setEncrypter(encrypter: Encrypter): void;
|
|
85
|
+
/**
|
|
86
|
+
* Get the global encrypter.
|
|
87
|
+
*/
|
|
88
|
+
export declare function getEncrypter(): Encrypter;
|
|
89
|
+
/**
|
|
90
|
+
* Encrypt a value using the global encrypter.
|
|
91
|
+
*/
|
|
92
|
+
export declare function encrypt(value: unknown, options?: EncryptOptions): string;
|
|
93
|
+
/**
|
|
94
|
+
* Decrypt a value using the global encrypter.
|
|
95
|
+
*/
|
|
96
|
+
export declare function decrypt<T = unknown>(payload: string, options?: DecryptOptions): T;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { HashAlgorithm, HmacOptions, PasswordHashOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Hash a value using the specified algorithm.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* hash('hello') // SHA-256 by default
|
|
8
|
+
* hash('hello', 'sha512')
|
|
9
|
+
* hash('hello', 'md5')
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function hash(value: string | Buffer, algorithm?: HashAlgorithm, encoding?: 'hex' | 'base64'): string;
|
|
13
|
+
/**
|
|
14
|
+
* Create an HMAC signature.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* hmac('message', 'secret-key')
|
|
19
|
+
* hmac('message', 'secret-key', { algorithm: 'sha512' })
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function hmac(value: string | Buffer, key: string | Buffer, options?: HmacOptions): string;
|
|
23
|
+
/**
|
|
24
|
+
* Verify an HMAC signature.
|
|
25
|
+
*/
|
|
26
|
+
export declare function verifyHmac(value: string | Buffer, signature: string, key: string | Buffer, options?: HmacOptions): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* Create a SHA-256 hash.
|
|
29
|
+
*/
|
|
30
|
+
export declare function sha256(value: string | Buffer): string;
|
|
31
|
+
/**
|
|
32
|
+
* Create a SHA-512 hash.
|
|
33
|
+
*/
|
|
34
|
+
export declare function sha512(value: string | Buffer): string;
|
|
35
|
+
/**
|
|
36
|
+
* Create an MD5 hash (not secure, use only for checksums).
|
|
37
|
+
*/
|
|
38
|
+
export declare function md5(value: string | Buffer): string;
|
|
39
|
+
/**
|
|
40
|
+
* Hash a password using scrypt.
|
|
41
|
+
*
|
|
42
|
+
* @example
|
|
43
|
+
* ```typescript
|
|
44
|
+
* const hashed = await hashPassword('mypassword')
|
|
45
|
+
* // Returns: $scrypt$N=16384,r=8,p=1$salt$hash
|
|
46
|
+
* ```
|
|
47
|
+
*/
|
|
48
|
+
export declare function hashPassword(password: string, options?: PasswordHashOptions): Promise<string>;
|
|
49
|
+
/**
|
|
50
|
+
* Verify a password against a hash.
|
|
51
|
+
*
|
|
52
|
+
* @example
|
|
53
|
+
* ```typescript
|
|
54
|
+
* const isValid = await verifyPassword('mypassword', hashedPassword)
|
|
55
|
+
* ```
|
|
56
|
+
*/
|
|
57
|
+
export declare function verifyPassword(password: string, hash: string): Promise<boolean>;
|
|
58
|
+
/**
|
|
59
|
+
* Check if a password needs to be rehashed (parameters changed).
|
|
60
|
+
*/
|
|
61
|
+
export declare function needsRehash(hash: string, options?: PasswordHashOptions): boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Constant-time string comparison.
|
|
64
|
+
*/
|
|
65
|
+
export declare function secureCompare(a: string, b: string): boolean;
|
|
66
|
+
/**
|
|
67
|
+
* Check if a value matches a hash.
|
|
68
|
+
*/
|
|
69
|
+
export declare function check(value: string | Buffer, hash: string, algorithm?: HashAlgorithm): boolean;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { AppKeyring } from './app-key.js';
|
|
2
|
+
export interface SignedMessageClaims {
|
|
3
|
+
purpose?: string;
|
|
4
|
+
iat: number;
|
|
5
|
+
exp?: number;
|
|
6
|
+
[key: string]: unknown;
|
|
7
|
+
}
|
|
8
|
+
export interface SignMessageOptions {
|
|
9
|
+
purpose?: string;
|
|
10
|
+
expiresIn?: number;
|
|
11
|
+
}
|
|
12
|
+
export interface VerifySignedMessageOptions {
|
|
13
|
+
purpose?: string;
|
|
14
|
+
allowExpired?: boolean;
|
|
15
|
+
}
|
|
16
|
+
export declare class MessageSigner {
|
|
17
|
+
private readonly keyring;
|
|
18
|
+
constructor(keyring: AppKeyring);
|
|
19
|
+
sign<T extends Record<string, unknown>>(payload: T, options?: SignMessageOptions): string;
|
|
20
|
+
verify<T extends Record<string, unknown> = Record<string, unknown>>(token: string, options?: VerifySignedMessageOptions): (T & SignedMessageClaims) | null;
|
|
21
|
+
}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import type { RandomStringOptions } from './types.js';
|
|
2
|
+
/**
|
|
3
|
+
* Generate a cryptographically secure random string.
|
|
4
|
+
*
|
|
5
|
+
* @example
|
|
6
|
+
* ```typescript
|
|
7
|
+
* randomString(32) // 32-character alphanumeric string
|
|
8
|
+
* randomString(16, { charset: 'hex' }) // 16-character hex string
|
|
9
|
+
* randomString(24, { charset: 'url-safe' }) // URL-safe string
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function randomString(length: number, options?: RandomStringOptions): string;
|
|
13
|
+
/**
|
|
14
|
+
* Generate random bytes.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```typescript
|
|
18
|
+
* const bytes = random(32) // 32 random bytes
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function random(length: number): Buffer;
|
|
22
|
+
/**
|
|
23
|
+
* Generate random bytes as hex string.
|
|
24
|
+
*/
|
|
25
|
+
export declare function randomHex(length: number): string;
|
|
26
|
+
/**
|
|
27
|
+
* Generate random bytes as base64 string.
|
|
28
|
+
*/
|
|
29
|
+
export declare function randomBase64(length: number): string;
|
|
30
|
+
/**
|
|
31
|
+
* Generate random bytes as URL-safe base64 string.
|
|
32
|
+
*/
|
|
33
|
+
export declare function randomBase64Url(length: number): string;
|
|
34
|
+
/**
|
|
35
|
+
* Generate a UUID v4.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const id = uuid() // e.g., '550e8400-e29b-41d4-a716-446655440000'
|
|
40
|
+
* ```
|
|
41
|
+
*/
|
|
42
|
+
export declare function uuid(): string;
|
|
43
|
+
/**
|
|
44
|
+
* Generate a secure random integer.
|
|
45
|
+
*
|
|
46
|
+
* @example
|
|
47
|
+
* ```typescript
|
|
48
|
+
* randomInt(1, 100) // Random number between 1 and 100 (inclusive)
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare function randomInt(min: number, max: number): number;
|
|
52
|
+
/**
|
|
53
|
+
* Generate a random token suitable for URLs.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```typescript
|
|
57
|
+
* const token = urlSafeToken(32) // URL-safe 32-character token
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export declare function urlSafeToken(length?: number): string;
|
|
61
|
+
/**
|
|
62
|
+
* Generate a secure random password.
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* const password = generatePassword(16) // Random 16-character password
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
69
|
+
export declare function generatePassword(length?: number, options?: {
|
|
70
|
+
uppercase?: boolean;
|
|
71
|
+
lowercase?: boolean;
|
|
72
|
+
numbers?: boolean;
|
|
73
|
+
symbols?: boolean;
|
|
74
|
+
}): string;
|
|
75
|
+
/**
|
|
76
|
+
* Generate a random OTP (One-Time Password).
|
|
77
|
+
*
|
|
78
|
+
* @example
|
|
79
|
+
* ```typescript
|
|
80
|
+
* const otp = generateOtp(6) // e.g., '482901'
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
83
|
+
export declare function generateOtp(length?: number): string;
|
|
84
|
+
/**
|
|
85
|
+
* Generate a random slug-friendly string.
|
|
86
|
+
*
|
|
87
|
+
* @example
|
|
88
|
+
* ```typescript
|
|
89
|
+
* const slug = generateSlug() // e.g., 'a8b2c4d6e8'
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function generateSlug(length?: number): string;
|
|
93
|
+
/**
|
|
94
|
+
* Shuffle an array using Fisher-Yates algorithm with secure random.
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* ```typescript
|
|
98
|
+
* const shuffled = shuffle([1, 2, 3, 4, 5])
|
|
99
|
+
* ```
|
|
100
|
+
*/
|
|
101
|
+
export declare function shuffle<T>(array: T[]): T[];
|
|
102
|
+
/**
|
|
103
|
+
* Pick a random element from an array.
|
|
104
|
+
*
|
|
105
|
+
* @example
|
|
106
|
+
* ```typescript
|
|
107
|
+
* const item = pick(['a', 'b', 'c']) // Random element
|
|
108
|
+
* ```
|
|
109
|
+
*/
|
|
110
|
+
export declare function pick<T>(array: T[]): T;
|
|
111
|
+
/**
|
|
112
|
+
* Pick multiple random elements from an array.
|
|
113
|
+
*
|
|
114
|
+
* @example
|
|
115
|
+
* ```typescript
|
|
116
|
+
* const items = sample(['a', 'b', 'c', 'd'], 2) // Two random elements
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare function sample<T>(array: T[], count: number): T[];
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export interface AppKeyring {
|
|
2
|
+
current: Buffer;
|
|
3
|
+
previous: Buffer[];
|
|
4
|
+
}
|
|
5
|
+
export declare function normalizeAppKey(rawKey: string, envName?: string): string;
|
|
6
|
+
export declare function parseAppKey(rawKey: string, envName?: string): Buffer;
|
|
7
|
+
export declare function parsePreviousAppKeys(rawKeys: string | undefined, envName?: string): Buffer[];
|
|
8
|
+
export declare function getAppKeyringFromEnv(env?: NodeJS.ProcessEnv): AppKeyring;
|
|
9
|
+
export declare function deriveAppKey(rootKey: Buffer, purpose: string): Buffer;
|
|
10
|
+
export declare function deriveAppKeyring(keyring: AppKeyring, purpose: string): AppKeyring;
|
|
11
|
+
export declare function encodeDerivedKey(key: Buffer): string;
|
|
12
|
+
export declare function generateAppKey(): string;
|