@stacksjs/bun-router 0.0.13 → 0.0.14
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/CHANGELOG.md +770 -0
- package/README.md +584 -261
- package/package.json +43 -47
- package/bin/cli.ts +0 -9
- package/dist/auth.d.ts +0 -134
- package/dist/cache/lru-cache.d.ts +0 -139
- package/dist/cache/middleware-memoization.d.ts +0 -151
- package/dist/cache/route-cache-warmer.d.ts +0 -161
- package/dist/cache/sqlite-cache.d.ts +0 -209
- package/dist/cache/streaming-cache.d.ts +0 -132
- package/dist/chunk-1mvtv6jw.js +0 -13012
- package/dist/cli/colors.d.ts +0 -15
- package/dist/cli/index.d.ts +0 -10
- package/dist/cli/middleware.d.ts +0 -31
- package/dist/cli/openapi.d.ts +0 -17
- package/dist/cli/router.d.ts +0 -15
- package/dist/cli/routes.d.ts +0 -29
- package/dist/cli/utils.d.ts +0 -74
- package/dist/cli.d.ts +0 -1
- package/dist/cli.js +0 -3195
- package/dist/config.d.ts +0 -7
- package/dist/container/container.d.ts +0 -273
- package/dist/container/contextual-binding.d.ts +0 -240
- package/dist/container/decorators.d.ts +0 -141
- package/dist/container/service-provider.d.ts +0 -285
- package/dist/development/hot-reload.d.ts +0 -187
- package/dist/development/index.d.ts +0 -167
- package/dist/development/performance-profiler.d.ts +0 -217
- package/dist/development/route-debugger.d.ts +0 -154
- package/dist/development/route-inspector.d.ts +0 -211
- package/dist/development/typescript-utilities.d.ts +0 -209
- package/dist/docs.d.ts +0 -11
- package/dist/errors/circuit-breaker.d.ts +0 -195
- package/dist/errors/error-handler.d.ts +0 -88
- package/dist/errors/error-reporting.d.ts +0 -144
- package/dist/errors/exceptions.d.ts +0 -184
- package/dist/errors/graceful-degradation.d.ts +0 -154
- package/dist/errors/index.d.ts +0 -9
- package/dist/errors/router-errors.d.ts +0 -110
- package/dist/file-serving/static-files.d.ts +0 -143
- package/dist/index.d.ts +0 -14
- package/dist/index.js +0 -13933
- package/dist/middleware/auth.d.ts +0 -63
- package/dist/middleware/content_security_policy.d.ts +0 -53
- package/dist/middleware/cors.d.ts +0 -5
- package/dist/middleware/csrf.d.ts +0 -7
- package/dist/middleware/ddos_protection.d.ts +0 -39
- package/dist/middleware/file_security.d.ts +0 -26
- package/dist/middleware/file_upload.d.ts +0 -38
- package/dist/middleware/helmet.d.ts +0 -54
- package/dist/middleware/index.d.ts +0 -44
- package/dist/middleware/input_validation.d.ts +0 -45
- package/dist/middleware/json_body.d.ts +0 -4
- package/dist/middleware/performance_alerting.d.ts +0 -87
- package/dist/middleware/performance_dashboard.d.ts +0 -87
- package/dist/middleware/performance_monitor.d.ts +0 -209
- package/dist/middleware/pipeline.d.ts +0 -131
- package/dist/middleware/rate_limit.d.ts +0 -36
- package/dist/middleware/request_id.d.ts +0 -4
- package/dist/middleware/request_signing.d.ts +0 -153
- package/dist/middleware/request_tracer.d.ts +0 -72
- package/dist/middleware/response_cache.d.ts +0 -97
- package/dist/middleware/security.d.ts +0 -69
- package/dist/middleware/security_suite.d.ts +0 -46
- package/dist/middleware/session.d.ts +0 -23
- package/dist/model-binding/index.d.ts +0 -2
- package/dist/model-binding/model-middleware.d.ts +0 -118
- package/dist/model-binding/model-registry.d.ts +0 -164
- package/dist/model-binding.d.ts +0 -185
- package/dist/model-resolver-factory.d.ts +0 -31
- package/dist/observability/correlation.d.ts +0 -187
- package/dist/observability/health-checks.d.ts +0 -186
- package/dist/observability/index.d.ts +0 -60
- package/dist/observability/integration.d.ts +0 -147
- package/dist/observability/metrics.d.ts +0 -184
- package/dist/observability/tracing.d.ts +0 -187
- package/dist/optimization/bun-utilities.d.ts +0 -224
- package/dist/query-builder-integration.d.ts +0 -36
- package/dist/request/context.d.ts +0 -34
- package/dist/request/enhanced-request.d.ts +0 -213
- package/dist/request/macros.d.ts +0 -300
- package/dist/response/macros.d.ts +0 -245
- package/dist/response/response-factory.d.ts +0 -133
- package/dist/router/api-routes.d.ts +0 -5
- package/dist/router/file-based-routing.d.ts +0 -118
- package/dist/router/file-streaming.d.ts +0 -5
- package/dist/router/fluent-router.d.ts +0 -315
- package/dist/router/fluent-routing.d.ts +0 -271
- package/dist/router/group-organization.d.ts +0 -5
- package/dist/router/handler-resolver.d.ts +0 -24
- package/dist/router/http-methods.d.ts +0 -10
- package/dist/router/index.d.ts +0 -114
- package/dist/router/middleware-groups.d.ts +0 -94
- package/dist/router/middleware-integration.d.ts +0 -112
- package/dist/router/middleware.d.ts +0 -5
- package/dist/router/model-binding.d.ts +0 -5
- package/dist/router/optimized-route-matching.d.ts +0 -6
- package/dist/router/route-building.d.ts +0 -5
- package/dist/router/route-compiler.d.ts +0 -153
- package/dist/router/route-matching.d.ts +0 -5
- package/dist/router/route-trie.d.ts +0 -114
- package/dist/router/router.d.ts +0 -294
- package/dist/router/server.d.ts +0 -5
- package/dist/router/validation-integration.d.ts +0 -170
- package/dist/router/view-rendering.d.ts +0 -5
- package/dist/router/websocket.d.ts +0 -5
- package/dist/routing/route-caching.d.ts +0 -129
- package/dist/routing/route-throttling.d.ts +0 -150
- package/dist/routing/subdomain-routing.d.ts +0 -206
- package/dist/session/database-store.d.ts +0 -51
- package/dist/session/file-store.d.ts +0 -22
- package/dist/session/index.d.ts +0 -106
- package/dist/session/memory-store.d.ts +0 -21
- package/dist/session/redis-store.d.ts +0 -31
- package/dist/streaming/index.d.ts +0 -3
- package/dist/streaming/sse-handler.d.ts +0 -138
- package/dist/streaming/stream-handler.d.ts +0 -114
- package/dist/testing/auth-testing.d.ts +0 -156
- package/dist/testing/file-upload-testing.d.ts +0 -190
- package/dist/testing/index.d.ts +0 -10
- package/dist/testing/middleware-testing.d.ts +0 -138
- package/dist/testing/model-binding-testing.d.ts +0 -186
- package/dist/testing/performance-testing.d.ts +0 -235
- package/dist/testing/test-client.d.ts +0 -117
- package/dist/testing/test-request.d.ts +0 -85
- package/dist/testing/test-response.d.ts +0 -90
- package/dist/testing/types.d.ts +0 -207
- package/dist/testing/websocket-testing.d.ts +0 -227
- package/dist/types/controller-types.d.ts +0 -208
- package/dist/types/core.d.ts +0 -543
- package/dist/types/middleware-types.d.ts +0 -227
- package/dist/types/request-response-augmentation.d.ts +0 -261
- package/dist/types/route-inference.d.ts +0 -168
- package/dist/types.d.ts +0 -1782
- package/dist/url.d.ts +0 -56
- package/dist/utils/index.d.ts +0 -1
- package/dist/utils/query-preservation.d.ts +0 -48
- package/dist/utils.d.ts +0 -69
- package/dist/validation/validator.d.ts +0 -140
- package/dist/websocket/clustering.d.ts +0 -185
- package/src/auth.ts +0 -469
- package/src/cache/lru-cache.ts +0 -457
- package/src/cache/middleware-memoization.ts +0 -531
- package/src/cache/route-cache-warmer.ts +0 -486
- package/src/cache/sqlite-cache.ts +0 -783
- package/src/cache/streaming-cache.ts +0 -572
- package/src/cli/colors.ts +0 -29
- package/src/cli/index.ts +0 -287
- package/src/cli/middleware.ts +0 -291
- package/src/cli/openapi.ts +0 -407
- package/src/cli/router.ts +0 -188
- package/src/cli/routes.ts +0 -265
- package/src/cli/utils.ts +0 -531
- package/src/cli.ts +0 -5
- package/src/config.ts +0 -322
- package/src/container/container.ts +0 -740
- package/src/container/contextual-binding.ts +0 -603
- package/src/container/decorators.ts +0 -359
- package/src/container/service-provider.ts +0 -596
- package/src/development/hot-reload.ts +0 -673
- package/src/development/index.ts +0 -499
- package/src/development/performance-profiler.ts +0 -717
- package/src/development/route-debugger.ts +0 -527
- package/src/development/route-inspector.ts +0 -749
- package/src/development/typescript-utilities.ts +0 -682
- package/src/docs.ts +0 -397
- package/src/errors/circuit-breaker.ts +0 -732
- package/src/errors/error-handler.ts +0 -569
- package/src/errors/error-reporting.ts +0 -672
- package/src/errors/exceptions.ts +0 -536
- package/src/errors/graceful-degradation.ts +0 -621
- package/src/errors/index.ts +0 -21
- package/src/errors/router-errors.ts +0 -632
- package/src/file-serving/static-files.ts +0 -581
- package/src/index.ts +0 -14
- package/src/middleware/auth.ts +0 -219
- package/src/middleware/content_security_policy.ts +0 -215
- package/src/middleware/cors.ts +0 -74
- package/src/middleware/csrf.ts +0 -108
- package/src/middleware/ddos_protection.ts +0 -255
- package/src/middleware/file_security.ts +0 -191
- package/src/middleware/file_upload.ts +0 -264
- package/src/middleware/helmet.ts +0 -268
- package/src/middleware/index.ts +0 -117
- package/src/middleware/input_validation.ts +0 -449
- package/src/middleware/json_body.ts +0 -37
- package/src/middleware/performance_alerting.ts +0 -538
- package/src/middleware/performance_dashboard.ts +0 -661
- package/src/middleware/performance_monitor.ts +0 -943
- package/src/middleware/pipeline.ts +0 -489
- package/src/middleware/rate_limit.ts +0 -245
- package/src/middleware/request_id.ts +0 -36
- package/src/middleware/request_signing.ts +0 -636
- package/src/middleware/request_tracer.ts +0 -636
- package/src/middleware/response_cache.ts +0 -743
- package/src/middleware/security.ts +0 -482
- package/src/middleware/security_suite.ts +0 -257
- package/src/middleware/session.ts +0 -91
- package/src/model-binding/index.ts +0 -18
- package/src/model-binding/model-middleware.ts +0 -425
- package/src/model-binding/model-registry.ts +0 -550
- package/src/model-binding.ts +0 -370
- package/src/model-resolver-factory.ts +0 -106
- package/src/observability/correlation.ts +0 -691
- package/src/observability/health-checks.ts +0 -729
- package/src/observability/index.ts +0 -184
- package/src/observability/integration.ts +0 -548
- package/src/observability/metrics.ts +0 -753
- package/src/observability/tracing.ts +0 -638
- package/src/optimization/bun-utilities.ts +0 -778
- package/src/query-builder-integration.ts +0 -137
- package/src/request/context.ts +0 -62
- package/src/request/enhanced-request.ts +0 -857
- package/src/request/macros.ts +0 -688
- package/src/response/macros.ts +0 -612
- package/src/response/response-factory.ts +0 -596
- package/src/router/api-routes.ts +0 -243
- package/src/router/file-based-routing.ts +0 -670
- package/src/router/file-streaming.ts +0 -372
- package/src/router/fluent-router.ts +0 -927
- package/src/router/fluent-routing.ts +0 -797
- package/src/router/group-organization.ts +0 -213
- package/src/router/handler-resolver.ts +0 -291
- package/src/router/http-methods.ts +0 -377
- package/src/router/index.ts +0 -187
- package/src/router/middleware-groups.ts +0 -222
- package/src/router/middleware-integration.ts +0 -399
- package/src/router/middleware.ts +0 -231
- package/src/router/model-binding.ts +0 -215
- package/src/router/optimized-route-matching.ts +0 -253
- package/src/router/route-building.ts +0 -212
- package/src/router/route-compiler.ts +0 -702
- package/src/router/route-matching.ts +0 -349
- package/src/router/route-trie.ts +0 -464
- package/src/router/router.ts +0 -1581
- package/src/router/server.ts +0 -462
- package/src/router/validation-integration.ts +0 -443
- package/src/router/view-rendering.ts +0 -233
- package/src/router/websocket.ts +0 -100
- package/src/routing/route-caching.ts +0 -402
- package/src/routing/route-throttling.ts +0 -469
- package/src/routing/subdomain-routing.ts +0 -492
- package/src/session/database-store.ts +0 -109
- package/src/session/file-store.ts +0 -148
- package/src/session/index.ts +0 -244
- package/src/session/memory-store.ts +0 -88
- package/src/session/redis-store.ts +0 -93
- package/src/streaming/index.ts +0 -17
- package/src/streaming/sse-handler.ts +0 -482
- package/src/streaming/stream-handler.ts +0 -552
- package/src/testing/auth-testing.ts +0 -446
- package/src/testing/file-upload-testing.ts +0 -543
- package/src/testing/index.ts +0 -10
- package/src/testing/middleware-testing.ts +0 -322
- package/src/testing/model-binding-testing.ts +0 -645
- package/src/testing/performance-testing.ts +0 -738
- package/src/testing/test-client.ts +0 -310
- package/src/testing/test-request.ts +0 -315
- package/src/testing/test-response.ts +0 -332
- package/src/testing/types.ts +0 -224
- package/src/testing/websocket-testing.ts +0 -590
- package/src/types/controller-types.ts +0 -385
- package/src/types/core.ts +0 -683
- package/src/types/middleware-types.ts +0 -419
- package/src/types/request-response-augmentation.ts +0 -489
- package/src/types/route-inference.ts +0 -357
- package/src/types.ts +0 -2055
- package/src/url.ts +0 -126
- package/src/utils/index.ts +0 -1
- package/src/utils/query-preservation.ts +0 -201
- package/src/utils.ts +0 -327
- package/src/validation/validator.ts +0 -685
- package/src/websocket/clustering.ts +0 -762
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, Middleware, NextFunction } from '../types';
|
|
2
|
-
export interface AuthOptions {
|
|
3
|
-
/**
|
|
4
|
-
* Authentication type to use
|
|
5
|
-
*/
|
|
6
|
-
type: 'basic' | 'bearer' | 'api-key' | 'oauth2' | 'jwt' | 'custom';
|
|
7
|
-
/**
|
|
8
|
-
* Function to validate credentials
|
|
9
|
-
*/
|
|
10
|
-
validator: (credentials: any, req: EnhancedRequest) => Promise<boolean> | boolean;
|
|
11
|
-
/**
|
|
12
|
-
* Extract user information after successful authentication
|
|
13
|
-
*/
|
|
14
|
-
userExtractor?: (credentials: any, req: EnhancedRequest) => Promise<any> | any;
|
|
15
|
-
/**
|
|
16
|
-
* Where to look for auth information
|
|
17
|
-
*/
|
|
18
|
-
source?: 'header' | 'query' | 'cookie';
|
|
19
|
-
/**
|
|
20
|
-
* Key name for the source (header name, query param, cookie name)
|
|
21
|
-
*/
|
|
22
|
-
key?: string;
|
|
23
|
-
/**
|
|
24
|
-
* Realm for Basic authentication
|
|
25
|
-
*/
|
|
26
|
-
realm?: string;
|
|
27
|
-
/**
|
|
28
|
-
* Custom credentials extractor
|
|
29
|
-
*/
|
|
30
|
-
credentialsExtractor?: (req: EnhancedRequest) => Promise<any> | any;
|
|
31
|
-
/**
|
|
32
|
-
* Whether to attach user info to request
|
|
33
|
-
*/
|
|
34
|
-
attachUser?: boolean;
|
|
35
|
-
}
|
|
36
|
-
/**
|
|
37
|
-
* Extracts and decodes Basic Auth credentials from Authorization header
|
|
38
|
-
*/
|
|
39
|
-
export declare function extractBasicAuth(authHeader: string): {
|
|
40
|
-
username: string;
|
|
41
|
-
password: string;
|
|
42
|
-
} | null;
|
|
43
|
-
/**
|
|
44
|
-
* Extracts Bearer token from Authorization header
|
|
45
|
-
*/
|
|
46
|
-
export declare function extractBearerToken(authHeader: string): string | null;
|
|
47
|
-
/**
|
|
48
|
-
* Extracts API key from various sources
|
|
49
|
-
*/
|
|
50
|
-
export declare function extractApiKey(req: EnhancedRequest, source?: 'header' | 'query' | 'cookie', key?: string): string | null;
|
|
51
|
-
export default class AuthMiddleware implements Middleware {
|
|
52
|
-
private options;
|
|
53
|
-
constructor(options: AuthOptions);
|
|
54
|
-
handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
|
|
55
|
-
}
|
|
56
|
-
export declare function basicAuth(validator: (credentials: {
|
|
57
|
-
username: string;
|
|
58
|
-
password: string;
|
|
59
|
-
}, req: EnhancedRequest) => Promise<boolean> | boolean, options?: Partial<AuthOptions>): AuthMiddleware;
|
|
60
|
-
export declare function bearerAuth(validator: (token: string, req: EnhancedRequest) => Promise<boolean> | boolean, options?: Partial<AuthOptions>): AuthMiddleware;
|
|
61
|
-
export declare function jwtAuth(validator: (token: string, req: EnhancedRequest) => Promise<boolean> | boolean, options?: Partial<AuthOptions>): AuthMiddleware;
|
|
62
|
-
export declare function apiKeyAuth(validator: (apiKey: string, req: EnhancedRequest) => Promise<boolean> | boolean, options?: Partial<AuthOptions>): AuthMiddleware;
|
|
63
|
-
export declare function oauth2Auth(validator: (token: string, req: EnhancedRequest) => Promise<boolean> | boolean, options?: Partial<AuthOptions>): AuthMiddleware;
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, NextFunction } from '../types';
|
|
2
|
-
export interface CSPDirectives {
|
|
3
|
-
'default-src'?: string[];
|
|
4
|
-
'script-src'?: string[];
|
|
5
|
-
'script-src-elem'?: string[];
|
|
6
|
-
'script-src-attr'?: string[];
|
|
7
|
-
'style-src'?: string[];
|
|
8
|
-
'style-src-elem'?: string[];
|
|
9
|
-
'style-src-attr'?: string[];
|
|
10
|
-
'img-src'?: string[];
|
|
11
|
-
'font-src'?: string[];
|
|
12
|
-
'connect-src'?: string[];
|
|
13
|
-
'media-src'?: string[];
|
|
14
|
-
'object-src'?: string[];
|
|
15
|
-
'child-src'?: string[];
|
|
16
|
-
'frame-src'?: string[];
|
|
17
|
-
'worker-src'?: string[];
|
|
18
|
-
'frame-ancestors'?: string[];
|
|
19
|
-
'form-action'?: string[];
|
|
20
|
-
'base-uri'?: string[];
|
|
21
|
-
'manifest-src'?: string[];
|
|
22
|
-
'prefetch-src'?: string[];
|
|
23
|
-
'navigate-to'?: string[];
|
|
24
|
-
'report-uri'?: string[];
|
|
25
|
-
'report-to'?: string[];
|
|
26
|
-
'require-trusted-types-for'?: string[];
|
|
27
|
-
'trusted-types'?: string[];
|
|
28
|
-
'upgrade-insecure-requests'?: boolean;
|
|
29
|
-
'block-all-mixed-content'?: boolean;
|
|
30
|
-
'plugin-types'?: string[];
|
|
31
|
-
'sandbox'?: string[];
|
|
32
|
-
'disown-opener'?: boolean;
|
|
33
|
-
}
|
|
34
|
-
export interface CSPOptions {
|
|
35
|
-
directives?: CSPDirectives;
|
|
36
|
-
reportOnly?: boolean;
|
|
37
|
-
reportUri?: string;
|
|
38
|
-
reportTo?: string;
|
|
39
|
-
useNonces?: boolean;
|
|
40
|
-
nonceLength?: number;
|
|
41
|
-
upgradeInsecureRequests?: boolean;
|
|
42
|
-
blockAllMixedContent?: boolean;
|
|
43
|
-
}
|
|
44
|
-
export default class ContentSecurityPolicy {
|
|
45
|
-
private options;
|
|
46
|
-
private nonces;
|
|
47
|
-
constructor(options?: CSPOptions);
|
|
48
|
-
private generateNonce;
|
|
49
|
-
private buildCSPHeader;
|
|
50
|
-
handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
|
|
51
|
-
getNonce(url: string): string | undefined;
|
|
52
|
-
}
|
|
53
|
-
export declare function contentSecurityPolicy(options?: CSPOptions): (req: EnhancedRequest, next: NextFunction) => Promise<Response>;
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, NextFunction } from '../types';
|
|
2
|
-
export interface DDoSProtectionOptions {
|
|
3
|
-
enabled?: boolean;
|
|
4
|
-
maxRequestsPerSecond?: number;
|
|
5
|
-
maxRequestsPerMinute?: number;
|
|
6
|
-
maxRequestsPerHour?: number;
|
|
7
|
-
burstLimit?: number;
|
|
8
|
-
windowSize?: number;
|
|
9
|
-
blockDuration?: number;
|
|
10
|
-
whitelistedIPs?: string[];
|
|
11
|
-
blacklistedIPs?: string[];
|
|
12
|
-
trustProxy?: boolean;
|
|
13
|
-
skipSuccessfulRequests?: boolean;
|
|
14
|
-
skipFailedRequests?: boolean;
|
|
15
|
-
keyGenerator?: (req: EnhancedRequest) => string;
|
|
16
|
-
onLimitReached?: (req: EnhancedRequest, rateLimitInfo: any) => Response | Promise<Response>;
|
|
17
|
-
store?: 'memory' | 'redis';
|
|
18
|
-
redis?: {
|
|
19
|
-
url: string;
|
|
20
|
-
prefix?: string;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export default class DDoSProtection {
|
|
24
|
-
private options;
|
|
25
|
-
private requestStore;
|
|
26
|
-
private cleanupInterval;
|
|
27
|
-
constructor(options?: DDoSProtectionOptions);
|
|
28
|
-
private defaultKeyGenerator;
|
|
29
|
-
private startCleanupInterval;
|
|
30
|
-
private isWhitelisted;
|
|
31
|
-
private isBlacklisted;
|
|
32
|
-
private getRateLimitInfo;
|
|
33
|
-
private shouldBlock;
|
|
34
|
-
private blockIP;
|
|
35
|
-
private createBlockedResponse;
|
|
36
|
-
handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
|
|
37
|
-
destroy(): void;
|
|
38
|
-
}
|
|
39
|
-
export declare function ddosProtection(options?: DDoSProtectionOptions): (req: EnhancedRequest, next: NextFunction) => Promise<Response>;
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { UploadedFile } from './file_upload';
|
|
2
|
-
export interface FileSecurityConfig {
|
|
3
|
-
scanForMalware?: boolean;
|
|
4
|
-
checkMagicNumbers?: boolean;
|
|
5
|
-
sanitizeFilenames?: boolean;
|
|
6
|
-
preventExecutableUploads?: boolean;
|
|
7
|
-
maxFilenameLength?: number;
|
|
8
|
-
}
|
|
9
|
-
export default class FileSecurity {
|
|
10
|
-
private config;
|
|
11
|
-
private readonly FILE_SIGNATURES;
|
|
12
|
-
private readonly EXECUTABLE_EXTENSIONS;
|
|
13
|
-
constructor(config?: FileSecurityConfig);
|
|
14
|
-
validateFile(file: UploadedFile): {
|
|
15
|
-
isValid: boolean;
|
|
16
|
-
errors: string[];
|
|
17
|
-
};
|
|
18
|
-
private validateFileSignature;
|
|
19
|
-
private sanitizeFilename;
|
|
20
|
-
private getFileExtension;
|
|
21
|
-
private basicMalwareScan;
|
|
22
|
-
getSafeFilename(originalName: string): string;
|
|
23
|
-
isAllowedFileType(mimetype: string, allowedTypes: string[]): boolean;
|
|
24
|
-
isWithinSizeLimit(fileSize: number, maxSize: number): boolean;
|
|
25
|
-
}
|
|
26
|
-
export declare function createFileSecurity(config?: FileSecurityConfig): FileSecurity;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, NextFunction } from '../types';
|
|
2
|
-
import type { FileSecurityConfig } from './file_security';
|
|
3
|
-
export interface UploadedFile {
|
|
4
|
-
fieldName: string;
|
|
5
|
-
originalName: string;
|
|
6
|
-
filename: string;
|
|
7
|
-
path: string;
|
|
8
|
-
size: number;
|
|
9
|
-
mimetype: string;
|
|
10
|
-
buffer: ArrayBuffer;
|
|
11
|
-
}
|
|
12
|
-
export interface FileUploadConfig extends FileSecurityConfig {
|
|
13
|
-
destination?: string;
|
|
14
|
-
maxFileSize?: number;
|
|
15
|
-
maxFiles?: number;
|
|
16
|
-
allowedMimeTypes?: string[];
|
|
17
|
-
allowedExtensions?: string[];
|
|
18
|
-
preserveOriginalName?: boolean;
|
|
19
|
-
generateUniqueFilename?: boolean;
|
|
20
|
-
createDestination?: boolean;
|
|
21
|
-
}
|
|
22
|
-
export interface FileUploadOptions extends FileUploadConfig {
|
|
23
|
-
fieldName?: string | string[];
|
|
24
|
-
}
|
|
25
|
-
export default class FileUpload {
|
|
26
|
-
private config;
|
|
27
|
-
private fileSecurity;
|
|
28
|
-
constructor(config?: FileUploadConfig);
|
|
29
|
-
handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
|
|
30
|
-
private generateFilename;
|
|
31
|
-
private formatBytes;
|
|
32
|
-
private createErrorResponse;
|
|
33
|
-
}
|
|
34
|
-
export declare function fileUpload(config?: FileUploadConfig): FileUpload;
|
|
35
|
-
export declare function singleFileUpload(_fieldName: string, config?: FileUploadConfig): FileUpload;
|
|
36
|
-
export declare function multipleFileUpload(maxFiles?: number, config?: FileUploadConfig): FileUpload;
|
|
37
|
-
export declare function imageUpload(config?: FileUploadConfig): FileUpload;
|
|
38
|
-
export declare function documentUpload(config?: FileUploadConfig): FileUpload;
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, NextFunction } from '../types';
|
|
2
|
-
export interface HelmetOptions {
|
|
3
|
-
contentSecurityPolicy?: boolean | {
|
|
4
|
-
directives?: Record<string, string[]>;
|
|
5
|
-
reportOnly?: boolean;
|
|
6
|
-
reportUri?: string;
|
|
7
|
-
upgradeInsecureRequests?: boolean;
|
|
8
|
-
blockAllMixedContent?: boolean;
|
|
9
|
-
};
|
|
10
|
-
crossOriginEmbedderPolicy?: boolean | {
|
|
11
|
-
policy?: 'require-corp' | 'credentialless';
|
|
12
|
-
};
|
|
13
|
-
crossOriginOpenerPolicy?: boolean | {
|
|
14
|
-
policy?: 'same-origin' | 'same-origin-allow-popups' | 'unsafe-none';
|
|
15
|
-
};
|
|
16
|
-
crossOriginResourcePolicy?: boolean | {
|
|
17
|
-
policy?: 'same-site' | 'same-origin' | 'cross-origin';
|
|
18
|
-
};
|
|
19
|
-
dnsPrefetchControl?: boolean | {
|
|
20
|
-
allow?: boolean;
|
|
21
|
-
};
|
|
22
|
-
expectCt?: boolean | {
|
|
23
|
-
enforce?: boolean;
|
|
24
|
-
maxAge?: number;
|
|
25
|
-
reportUri?: string;
|
|
26
|
-
};
|
|
27
|
-
frameguard?: boolean | {
|
|
28
|
-
action?: 'deny' | 'sameorigin';
|
|
29
|
-
domain?: string;
|
|
30
|
-
};
|
|
31
|
-
hidePoweredBy?: boolean;
|
|
32
|
-
hsts?: boolean | {
|
|
33
|
-
maxAge?: number;
|
|
34
|
-
includeSubDomains?: boolean;
|
|
35
|
-
preload?: boolean;
|
|
36
|
-
};
|
|
37
|
-
ieNoOpen?: boolean;
|
|
38
|
-
noSniff?: boolean;
|
|
39
|
-
originAgentCluster?: boolean;
|
|
40
|
-
permittedCrossDomainPolicies?: boolean | {
|
|
41
|
-
permittedPolicies?: 'none' | 'master-only' | 'by-content-type' | 'all';
|
|
42
|
-
};
|
|
43
|
-
referrerPolicy?: boolean | {
|
|
44
|
-
policy?: string | string[];
|
|
45
|
-
};
|
|
46
|
-
xssFilter?: boolean | {
|
|
47
|
-
setOnOldIE?: boolean;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
export default class Helmet {
|
|
51
|
-
private options;
|
|
52
|
-
constructor(options?: HelmetOptions);
|
|
53
|
-
handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
|
|
54
|
-
}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
import Auth, { apiKeyAuth, basicAuth, bearerAuth, extractApiKey, extractBasicAuth, extractBearerToken, jwtAuth, oauth2Auth } from './auth';
|
|
2
|
-
import Cors from './cors';
|
|
3
|
-
import Csrf from './csrf';
|
|
4
|
-
import JsonBody from './json_body';
|
|
5
|
-
import RequestId from './request_id';
|
|
6
|
-
import Session from './session';
|
|
7
|
-
export { default as Auth } from './auth';
|
|
8
|
-
export { default as ContentSecurityPolicy } from './content_security_policy';
|
|
9
|
-
export { contentSecurityPolicy } from './content_security_policy';
|
|
10
|
-
export { default as Cors } from './cors';
|
|
11
|
-
export { default as Csrf } from './csrf';
|
|
12
|
-
export { default as DDoSProtection } from './ddos_protection';
|
|
13
|
-
export { ddosProtection } from './ddos_protection';
|
|
14
|
-
export { default as FileSecurity } from './file_security';
|
|
15
|
-
export { default as FileUpload } from './file_upload';
|
|
16
|
-
export { documentUpload, fileUpload, imageUpload, multipleFileUpload, singleFileUpload } from './file_upload';
|
|
17
|
-
export { default as Helmet } from './helmet';
|
|
18
|
-
export { default as InputValidation } from './input_validation';
|
|
19
|
-
export { inputValidation } from './input_validation';
|
|
20
|
-
export { default as JsonBody } from './json_body';
|
|
21
|
-
export { default as PerformanceAlerting, performanceAlerting } from './performance_alerting';
|
|
22
|
-
export { default as PerformanceDashboard, performanceDashboard } from './performance_dashboard';
|
|
23
|
-
export { default as PerformanceMonitor, performanceMonitor } from './performance_monitor';
|
|
24
|
-
export { default as RateLimit } from './rate_limit';
|
|
25
|
-
export { rateLimit } from './rate_limit';
|
|
26
|
-
export { default as RequestId } from './request_id';
|
|
27
|
-
export { InMemoryNonceStore, default as RequestSigning, requestSigning, signRequest, verifySignature } from './request_signing';
|
|
28
|
-
export type { NonceStore, RequestSigningOptions, SignatureAlgorithm, SignedPart } from './request_signing';
|
|
29
|
-
export { SignatureError } from './request_signing';
|
|
30
|
-
export { default as RequestTracer, requestTracer } from './request_tracer';
|
|
31
|
-
export { default as Security } from './security';
|
|
32
|
-
export { security } from './security';
|
|
33
|
-
export { default as SecuritySuite } from './security_suite';
|
|
34
|
-
export { securitySuite } from './security_suite';
|
|
35
|
-
export { default as Session } from './session';
|
|
36
|
-
export { apiKeyAuth, basicAuth, bearerAuth, extractApiKey, extractBasicAuth, extractBearerToken, jwtAuth, oauth2Auth, };
|
|
37
|
-
export declare const cors: () => Cors;
|
|
38
|
-
export declare const jsonBody: () => JsonBody;
|
|
39
|
-
export declare const requestId: () => RequestId;
|
|
40
|
-
export declare const session: () => Session;
|
|
41
|
-
export declare const csrf: () => Csrf;
|
|
42
|
-
export declare function auth(): Auth;
|
|
43
|
-
export declare const middleware: Record<string, any>;
|
|
44
|
-
export default middleware;
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, NextFunction } from '../types';
|
|
2
|
-
export interface ValidationRule {
|
|
3
|
-
type: 'string' | 'number' | 'boolean' | 'email' | 'url' | 'uuid' | 'date' | 'regex' | 'custom';
|
|
4
|
-
required?: boolean;
|
|
5
|
-
min?: number;
|
|
6
|
-
max?: number;
|
|
7
|
-
pattern?: RegExp;
|
|
8
|
-
enum?: unknown[];
|
|
9
|
-
custom?: (value: unknown) => boolean | string;
|
|
10
|
-
sanitize?: boolean;
|
|
11
|
-
transform?: (value: unknown) => unknown;
|
|
12
|
-
}
|
|
13
|
-
export interface ValidationSchema {
|
|
14
|
-
[key: string]: ValidationRule | ValidationSchema;
|
|
15
|
-
}
|
|
16
|
-
export interface InputValidationOptions {
|
|
17
|
-
enabled?: boolean;
|
|
18
|
-
schemas?: {
|
|
19
|
-
query?: ValidationSchema;
|
|
20
|
-
body?: ValidationSchema;
|
|
21
|
-
headers?: ValidationSchema;
|
|
22
|
-
params?: ValidationSchema;
|
|
23
|
-
};
|
|
24
|
-
sanitizeByDefault?: boolean;
|
|
25
|
-
strictMode?: boolean;
|
|
26
|
-
allowUnknownFields?: boolean;
|
|
27
|
-
maxDepth?: number;
|
|
28
|
-
onValidationError?: (errors: ValidationError[]) => Response;
|
|
29
|
-
}
|
|
30
|
-
export interface ValidationError {
|
|
31
|
-
field: string;
|
|
32
|
-
message: string;
|
|
33
|
-
value: any;
|
|
34
|
-
rule: string;
|
|
35
|
-
}
|
|
36
|
-
export default class InputValidation {
|
|
37
|
-
private options;
|
|
38
|
-
constructor(options?: InputValidationOptions);
|
|
39
|
-
private validateValue;
|
|
40
|
-
private sanitizeValue;
|
|
41
|
-
private validateObject;
|
|
42
|
-
private parseRequestBody;
|
|
43
|
-
handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
|
|
44
|
-
}
|
|
45
|
-
export declare function inputValidation(options?: InputValidationOptions): (req: EnhancedRequest, next: NextFunction) => Promise<Response>;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, NextFunction } from '../types';
|
|
2
|
-
import type { PerformanceMetrics } from './performance_monitor';
|
|
3
|
-
export interface AlertRule {
|
|
4
|
-
id: string;
|
|
5
|
-
name: string;
|
|
6
|
-
description?: string;
|
|
7
|
-
enabled: boolean;
|
|
8
|
-
metric: 'responseTime' | 'errorRate' | 'memoryUsage' | 'cpuUsage' | 'requestRate' | 'custom';
|
|
9
|
-
condition: 'gt' | 'lt' | 'eq' | 'gte' | 'lte';
|
|
10
|
-
threshold: number;
|
|
11
|
-
duration?: number;
|
|
12
|
-
severity: 'info' | 'warning' | 'critical';
|
|
13
|
-
cooldown?: number;
|
|
14
|
-
customEvaluator?: (metrics: PerformanceMetrics[]) => boolean;
|
|
15
|
-
}
|
|
16
|
-
export interface AlertNotification {
|
|
17
|
-
id: string;
|
|
18
|
-
ruleId: string;
|
|
19
|
-
ruleName: string;
|
|
20
|
-
severity: 'info' | 'warning' | 'critical';
|
|
21
|
-
message: string;
|
|
22
|
-
timestamp: number;
|
|
23
|
-
resolved: boolean;
|
|
24
|
-
resolvedAt?: number;
|
|
25
|
-
metadata: Record<string, any>;
|
|
26
|
-
}
|
|
27
|
-
export interface AlertChannel {
|
|
28
|
-
type: 'webhook' | 'slack' | 'email' | 'console' | 'custom';
|
|
29
|
-
enabled: boolean;
|
|
30
|
-
config: {
|
|
31
|
-
url?: string;
|
|
32
|
-
token?: string;
|
|
33
|
-
channel?: string;
|
|
34
|
-
email?: string;
|
|
35
|
-
customHandler?: (notification: AlertNotification) => Promise<void>;
|
|
36
|
-
};
|
|
37
|
-
filters?: {
|
|
38
|
-
severities?: Array<'info' | 'warning' | 'critical'>;
|
|
39
|
-
rules?: string[];
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export interface AlertingOptions {
|
|
43
|
-
enabled?: boolean;
|
|
44
|
-
rules?: AlertRule[];
|
|
45
|
-
channels?: AlertChannel[];
|
|
46
|
-
defaultCooldown?: number;
|
|
47
|
-
maxAlerts?: number;
|
|
48
|
-
autoResolve?: boolean;
|
|
49
|
-
autoResolveTimeout?: number;
|
|
50
|
-
}
|
|
51
|
-
export default class PerformanceAlerting {
|
|
52
|
-
private options;
|
|
53
|
-
private rules;
|
|
54
|
-
private channels;
|
|
55
|
-
private notifications;
|
|
56
|
-
private lastAlertTimes;
|
|
57
|
-
private metricsBuffer;
|
|
58
|
-
private checkInterval?;
|
|
59
|
-
constructor(options?: AlertingOptions);
|
|
60
|
-
private addDefaultRules;
|
|
61
|
-
private startAlertingEngine;
|
|
62
|
-
private evaluateRules;
|
|
63
|
-
private extractMetricValues;
|
|
64
|
-
private evaluateCondition;
|
|
65
|
-
private triggerAlert;
|
|
66
|
-
private formatAlertMessage;
|
|
67
|
-
private sendNotification;
|
|
68
|
-
private sendConsoleNotification;
|
|
69
|
-
private sendWebhookNotification;
|
|
70
|
-
private sendSlackNotification;
|
|
71
|
-
private sendEmailNotification;
|
|
72
|
-
private cleanupOldNotifications;
|
|
73
|
-
private autoResolveAlerts;
|
|
74
|
-
private generateId;
|
|
75
|
-
addMetrics(metrics: PerformanceMetrics): void;
|
|
76
|
-
addRule(rule: AlertRule): void;
|
|
77
|
-
removeRule(ruleId: string): void;
|
|
78
|
-
updateRule(ruleId: string, updates: Partial<AlertRule>): void;
|
|
79
|
-
addChannel(channel: AlertChannel): void;
|
|
80
|
-
removeChannel(index: number): void;
|
|
81
|
-
getActiveAlerts(): AlertNotification[];
|
|
82
|
-
getAllNotifications(): AlertNotification[];
|
|
83
|
-
resolveAlert(alertId: string): void;
|
|
84
|
-
handle(req: EnhancedRequest, next: NextFunction): Promise<Response>;
|
|
85
|
-
destroy(): void;
|
|
86
|
-
}
|
|
87
|
-
export declare function performanceAlerting(options?: AlertingOptions): PerformanceAlerting;
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { EnhancedRequest, NextFunction } from '../types';
|
|
2
|
-
import type { TraceSpan } from './request_tracer';
|
|
3
|
-
export interface DashboardOptions {
|
|
4
|
-
enabled?: boolean;
|
|
5
|
-
path?: string;
|
|
6
|
-
title?: string;
|
|
7
|
-
refreshInterval?: number;
|
|
8
|
-
maxMetrics?: number;
|
|
9
|
-
authentication?: {
|
|
10
|
-
enabled?: boolean;
|
|
11
|
-
username?: string;
|
|
12
|
-
password?: string;
|
|
13
|
-
apiKey?: string;
|
|
14
|
-
};
|
|
15
|
-
features?: {
|
|
16
|
-
realTimeMetrics?: boolean;
|
|
17
|
-
historicalCharts?: boolean;
|
|
18
|
-
alertsPanel?: boolean;
|
|
19
|
-
tracingView?: boolean;
|
|
20
|
-
systemMetrics?: boolean;
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
export interface DashboardData {
|
|
24
|
-
metrics: {
|
|
25
|
-
current: {
|
|
26
|
-
totalRequests: number;
|
|
27
|
-
averageResponseTime: number;
|
|
28
|
-
errorRate: number;
|
|
29
|
-
requestsPerSecond: number;
|
|
30
|
-
memoryUsage: number;
|
|
31
|
-
cpuUsage: number;
|
|
32
|
-
};
|
|
33
|
-
historical: Array<{
|
|
34
|
-
timestamp: number;
|
|
35
|
-
responseTime: number;
|
|
36
|
-
memoryUsage: number;
|
|
37
|
-
requestCount: number;
|
|
38
|
-
errorCount: number;
|
|
39
|
-
}>;
|
|
40
|
-
distribution: {
|
|
41
|
-
statusCodes: Record<number, number>;
|
|
42
|
-
paths: Record<string, number>;
|
|
43
|
-
methods: Record<string, number>;
|
|
44
|
-
responseTimes: Array<{
|
|
45
|
-
range: string;
|
|
46
|
-
count: number;
|
|
47
|
-
}>;
|
|
48
|
-
};
|
|
49
|
-
};
|
|
50
|
-
alerts: Array<{
|
|
51
|
-
id: string;
|
|
52
|
-
type: 'warning' | 'critical';
|
|
53
|
-
message: string;
|
|
54
|
-
timestamp: number;
|
|
55
|
-
resolved: boolean;
|
|
56
|
-
}>;
|
|
57
|
-
traces: TraceSpan[];
|
|
58
|
-
system: {
|
|
59
|
-
uptime: number;
|
|
60
|
-
nodeVersion: string;
|
|
61
|
-
bunVersion: string;
|
|
62
|
-
platform: string;
|
|
63
|
-
arch: string;
|
|
64
|
-
memory: NodeJS.MemoryUsage;
|
|
65
|
-
cpu: NodeJS.CpuUsage;
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
export default class PerformanceDashboard {
|
|
69
|
-
private options;
|
|
70
|
-
private metricsHistory;
|
|
71
|
-
private alerts;
|
|
72
|
-
private startTime;
|
|
73
|
-
constructor(options?: DashboardOptions);
|
|
74
|
-
private isAuthenticated;
|
|
75
|
-
private generateDashboardHTML;
|
|
76
|
-
private getDashboardData;
|
|
77
|
-
handle(req: EnhancedRequest, next: NextFunction): Promise<Response | null>;
|
|
78
|
-
addAlert(type: 'warning' | 'critical', message: string): void;
|
|
79
|
-
resolveAlert(id: string): void;
|
|
80
|
-
updateMetricsHistory(data: {
|
|
81
|
-
responseTime: number;
|
|
82
|
-
memoryUsage: number;
|
|
83
|
-
requestCount: number;
|
|
84
|
-
errorCount: number;
|
|
85
|
-
}): void;
|
|
86
|
-
}
|
|
87
|
-
export declare function performanceDashboard(options?: DashboardOptions): (req: EnhancedRequest, next: NextFunction) => Promise<Response | null>;
|